repo_name
stringlengths 9
74
| language
stringclasses 1
value | length_bytes
int64 11
9.34M
| extension
stringclasses 2
values | content
stringlengths 11
9.34M
|
---|---|---|---|---|
AdaDoom3/wayland_ada_binding | Ada | 21,228 | ads | ------------------------------------------------------------------------------
-- Copyright (C) 2016, AdaCore --
-- --
-- This library is free software; you can redistribute it and/or modify it --
-- under terms of the GNU General Public License as published by the Free --
-- Software Foundation; either version 3, or (at your option) any later --
-- version. This library is distributed in the hope that it will be useful, --
-- but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHAN- --
-- TABILITY 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/>. --
-- --
------------------------------------------------------------------------------
-- Implementation details for the map container.
-- This package takes the same formal arguments as Conts.Vectors.Generics
-- and provides the internal implementation as well as annotations for
-- all the primitive operations.
pragma Ada_2012;
with Conts.Elements;
with Conts.Functional.Sequences;
with Conts.Functional.Maps;
generic
with package Keys is new Conts.Elements.Traits (<>);
with package Elements is new Conts.Elements.Traits (<>);
type Container_Base_Type is abstract tagged limited private;
with function Hash (Key : Keys.Element_Type) return Hash_Type;
type Probing is new Probing_Strategy with private;
with package Pool is new Conts.Pools (<>);
with function "="
(Left : Keys.Element_Type;
Right : Keys.Stored_Type) return Boolean is <>;
with function Resize_Strategy
(Used : Count_Type;
Fill : Count_Type;
Capacity : Count_Type) return Count_Type is Resize_2_3;
package Conts.Maps.Impl with SPARK_Mode is
pragma Assertion_Policy
(Pre => Suppressible, Ghost => Suppressible, Post => Ignore);
subtype Key_Type is Keys.Element_Type;
subtype Element_Type is Elements.Element_Type;
subtype Returned_Type is Elements.Returned_Type;
subtype Constant_Returned_Type is Elements.Constant_Returned_Type;
subtype Constant_Returned_Key_Type is Keys.Constant_Returned_Type;
use type Elements.Element_Type;
use type Elements.Constant_Returned_Type;
use type Keys.Element_Type;
use type Keys.Constant_Returned_Type;
type Base_Map is new Container_Base_Type with private;
type Cursor is private;
No_Element : constant Cursor;
-- A cursor is only valid until the next change to the map. As soon as
-- an element is added or removed, the cursor should no longer be used.
-- For performance reasons, this is not checked.
function Capacity (Self : Base_Map'Class) return Count_Type with
Global => null;
function Length (Self : Base_Map'Class) return Count_Type with
Global => null,
Post => Length'Result = 0 or Length'Result < Capacity (Self);
-- The length of a map is always strictly smaller than its capacity
-- except when the map's capacity is 0.
------------------
-- Formal Model --
------------------
type P_Map is private with Ghost,
Iterable => (First => P_Iter_First,
Has_Element => P_Iter_Has_Element,
Next => P_Iter_Next,
Element => P_Iter_Element);
function "=" (M1, M2 : P_Map) return Boolean with
Ghost,
Global => null,
Post => "="'Result =
((for all K of M1 =>
P_Mem (M2, K) and then P_Get (M2, K) = P_Get (M1, K))
and then (for all K of M2 => P_Mem (M1, K)));
type P_Private_Cursor is private with Ghost;
function P_Iter_First (M : P_Map) return P_Private_Cursor with Ghost;
function P_Iter_Next
(M : P_Map; C : P_Private_Cursor) return P_Private_Cursor with Ghost;
function P_Iter_Has_Element
(M : P_Map; C : P_Private_Cursor) return Boolean with Ghost;
function P_Iter_Element (M : P_Map; C : P_Private_Cursor) return Cursor
with Ghost;
function P_Mem (M : P_Map; C : Cursor) return Boolean with Ghost;
function P_Get (M : P_Map; C : Cursor) return Positive_Count_Type
with
Ghost,
Pre => P_Mem (M, C);
pragma Annotate (GNATprove, Iterable_For_Proof, "Contains", P_Mem);
package K is new Conts.Functional.Sequences
(Element_Type => Key_Type,
Index_Type => Positive_Count_Type);
-- This instance should be ghost but it is not currently allowed by the RM.
-- See P523-006
package M is new Conts.Functional.Maps
(Element_Type => Element_Type,
Key_Type => Key_Type);
-- This instance should be ghost but it is not currently allowed by the RM.
-- See P523-006
use type M.Map;
use type K.Sequence;
function Model (Self : Base_Map'Class) return M.Map
-- The highlevel model of a map is a map from keys to elements. Neither
-- cursors nor order of elements are represented in this model.
with
Ghost,
Global => null;
function S_Keys (Self : Base_Map'Class) return K.Sequence
-- The S_Keys sequence represents the underlying list structure of
-- maps that is used for iteration. It does not model cursors nor elements.
with
Ghost,
Global => null,
Post => K.Length (S_Keys'Result) = Length (Self)
-- It only contains keys contained in Model.
and then (for all Key of S_Keys'Result => M.Mem (Model (Self), Key))
-- It contains all the keys contained in Model.
and then (for all Key of Model (Self) =>
(for some L of S_Keys'Result => L = Key))
-- It has no duplicate.
and then
(for all I in 1 .. Length (Self) =>
(for all J in 1 .. Length (Self) =>
(if K.Get (S_Keys'Result, I) =
K.Get (S_Keys'Result, J)
then I = J)));
function Positions (Self : Base_Map'Class) return P_Map
-- The Positions map is used to model cursors. It only contains valid
-- cursors and map them to their position in the container.
with
Ghost,
Global => null,
Post => not P_Mem (Positions'Result, No_Element)
-- Positions of cursors are smaller than the container's length.
and then
(for all I of Positions'Result =>
P_Get (Positions'Result, I) in 1 .. Length (Self)
-- No two cursors have the same position. Note that we do not
-- state that there is a cursor in the map for each position,
-- as it is rarely needed.
and then
(for all J of Positions'Result =>
(if P_Get (Positions'Result, I) =
P_Get (Positions'Result, J)
then I = J)));
procedure Lift_Abstraction_Level (Self : Base_Map'Class)
-- Lift_Abstraction_Level is a ghost procedure that does nothing but
-- assume that we can access to the same elements by iterating over
-- positions or cursors.
-- This information is not generally useful except when switching from
-- a lowlevel, cursor aware view of a container, to a highlevel position
-- based view.
with
Ghost,
Global => null,
Post =>
(for all Key of S_Keys (Self) =>
(for some Cu of Positions (Self) =>
K.Get (S_Keys (Self),
P_Get (Positions (Self), Cu)) = Key));
function Element (S : M.Map; K : Key_Type) return Element_Type
renames M.Get;
-----------------
-- Subprograms --
-----------------
function Contains (Self : Base_Map'Class; Key : Key_Type) return Boolean
with
Global => null,
Post => Contains'Result = M.Mem (Model (Self), Key);
pragma Annotate (GNATprove, Inline_For_Proof, Entity => Contains);
procedure Assign
(Self : in out Base_Map'Class; Source : Base_Map'Class)
with
Global => null,
Post => Length (Self) = Length (Source)
and then Model (Self) = Model (Source);
procedure Resize
(Self : in out Base_Map'Class;
New_Size : Count_Type)
-- Change the capacity of the container.
-- It does not change the high level model of Self.
with
Global => null,
Post => Length (Self) = Length (Self)'Old
and Model (Self) = Model (Self)'Old
and Capacity (Self) >= New_Size;
procedure Set
(Self : in out Base_Map'Class;
Key : Keys.Element_Type;
Value : Elements.Element_Type)
-- Insert a key Key and an element Element in Self if Key is not already in
-- present.
-- Otherwise, replace the element associated to Key by Element.
with
Global => null,
Pre => Contains (Self, Key)
or else Length (Self) < Count_Type'Last - 1,
Contract_Cases =>
-- If Key is already in Self, then Key now maps to Element in Model.
(M.Mem (Model (Self), Key) => Capacity (Self) = Capacity (Self)'Old
and Length (Self) = Length (Self)'Old
and M.Is_Set (Model (Self)'Old, Key, Value, Model (Self))
-- Keys and cursors are preserved
and S_Keys (Self) = S_Keys (Self)'Old
and Positions (Self) = Positions (Self)'Old,
-- If Key was not in Self, then Element is a new element of its
-- model.
others => Capacity (Self) >= Capacity (Self)'Old
and Length (Self) = Length (Self)'Old + 1
and M.Is_Add (Model (Self)'Old, Key, Value, Model (Self)));
function Get
(Self : Base_Map'Class;
Key : Keys.Element_Type)
return Elements.Constant_Returned_Type
with
Global => null,
Pre => Contains (Self, Key),
Post => Elements.To_Element (Get'Result) =
Element (Model (Self), Key);
function As_Element
(Self : Base_Map'Class; Key : Keys.Element_Type) return Element_Type
is (Elements.To_Element (Self.Get (Key)))
with
Inline,
Global => null,
Pre => Contains (Self, Key),
Post => As_Element'Result = Element (Model (Self), Key);
pragma Annotate (GNATprove, Inline_For_Proof, As_Element);
procedure Clear (Self : in out Base_Map'Class)
-- Remove all elements from the map
with
Global => null,
Post => Length (Self) = 0
and then M.Is_Empty (Model (Self));
function Mapping_Preserved
(S1, S2 : K.Sequence; P1, P2 : P_Map) return Boolean
-- The mapping between cursors and elements represented by the position
-- map P1 and the sequence of keys S1 is preserved by P2 and S2.
with
Ghost,
Post => Mapping_Preserved'Result =
(for all I of P1 =>
P_Mem (P2, I)
and then K.Get (S1, P_Get (P1, I)) = K.Get (S2, P_Get (P2, I)));
function Cursors_Preserved
(P1, P2 : P_Map; S1 : K.Sequence; V : Key_Type) return Boolean
-- The cursors of P1 are those of P2 except the one mapped to V by S1.
with
Ghost,
Post => Cursors_Preserved'Result =
(for all I of P1 =>
P_Mem (P2, I) or else K.Get (S1, P_Get (P1, I)) = V);
procedure Delete
(Self : in out Base_Map'Class;
Key : Keys.Element_Type)
-- Remove the element from the map.
-- No exception is raised if the element is not in the map.
with
Global => null,
Post => Capacity (Self) = Capacity (Self)'Old,
Contract_Cases =>
-- If Key was in Self then it is removed from its model.
(M.Mem (Model (Self), Key) =>
Length (Self) = Length (Self)'Old - 1
and M.Is_Add
(Model (Self),
Key,
Element (Model (Self)'Old, Key),
Model (Self)'Old)
-- Cursors that are valid in Self were already valid and
-- designating the same element.
and Mapping_Preserved
(S1 => S_Keys (Self),
S2 => S_Keys (Self)'Old,
P1 => Positions (Self),
P2 => Positions (Self)'Old)
-- Cursors that were valid in Self continue to be valid in Self
-- except for the newly deleted cursor.
-- Nothing is said about the order of keys in Self after the
-- call.
and Cursors_Preserved
(P1 => Positions (Self)'Old,
P2 => Positions (Self),
S1 => S_Keys (Self)'Old,
V => Key),
-- If Key was not in Self, then nothing is changed.
others => Length (Self) = Length (Self)'Old
and Model (Self)'Old = Model (Self)
and S_Keys (Self)'Old = S_Keys (Self)
and Positions (Self)'Old = Positions (Self));
function Key
(Self : Base_Map'Class; Position : Cursor)
return Constant_Returned_Key_Type
with
Inline,
Global => null,
Pre => Has_Element (Self, Position),
Post =>
-- Query Positions to get the position of Position in Self and use
-- it to fetch the corresponding key in Keys.
Keys.To_Element (Key'Result) =
K.Get (S_Keys (Self), P_Get (Positions (Self), Position));
function As_Key
(Self : Base_Map'Class; Position : Cursor) return Key_Type
is (Keys.To_Element (Self.Key (Position)))
with
Inline,
Global => null,
Pre => Has_Element (Self, Position),
Post => As_Key'Result =
K.Get (S_Keys (Self), P_Get (Positions (Self), Position));
pragma Annotate (GNATprove, Inline_For_Proof, As_Key);
function Element
(Self : Base_Map'Class; Position : Cursor)
return Constant_Returned_Type
with
Inline,
Global => null,
Pre => Has_Element (Self, Position),
Post =>
-- Query Positions to get the position of Position in Self, use it
-- to fetch the corresponding key in Keys, and then use this key to
-- get the associated element from Model.
Elements.To_Element (Element'Result) = Element
(Model (Self), K.Get (S_Keys (Self),
P_Get (Positions (Self), Position)));
function As_Element
(Self : Base_Map'Class; Position : Cursor) return Element_Type
is (Elements.To_Element (Self.Element (Position)))
with
Inline,
Global => null,
Pre => Has_Element (Self, Position),
Post => As_Element'Result = Element
(Model (Self), K.Get (S_Keys (Self),
P_Get (Positions (Self), Position)));
pragma Annotate (GNATprove, Inline_For_Proof, As_Element);
function First (Self : Base_Map'Class) return Cursor
with
Inline,
Global => null,
Contract_Cases =>
(Length (Self) = 0 => First'Result = No_Element,
others => Has_Element (Self, First'Result)
and then P_Get (Positions (Self), First'Result) = 1);
function Has_Element
(Self : Base_Map'Class; Position : Cursor) return Boolean
with
Inline,
Global => null,
Post => Has_Element'Result = P_Mem (Positions (Self), Position);
pragma Annotate (GNATprove, Inline_For_Proof, Entity => Has_Element);
function Next
(Self : Base_Map'Class; Position : Cursor) return Cursor
-- Actual implementation for the subprograms renamed in generics. See the
-- descriptions in generics.
with
Inline,
Global => null,
Pre => Has_Element (Self, Position),
Contract_Cases =>
(P_Get (Positions (Self), Position) = Length (Self) =>
not Has_Element (Self, Next'Result),
others => Has_Element (Self, Next'Result)
and then P_Get (Positions (Self), Next'Result) =
P_Get (Positions (Self), Position) + 1);
function First_Primitive (Self : Base_Map) return Cursor
is (First (Self)) with Inline;
function Key_Primitive
(Self : Base_Map; Position : Cursor) return Constant_Returned_Key_Type
is (Key (Self, Position))
with
Inline,
Pre'Class => Has_Element (Self, Position);
function Has_Element_Primitive
(Self : Base_Map; Position : Cursor) return Boolean
is (Has_Element (Self, Position)) with Inline;
function Next_Primitive
(Self : Base_Map; Position : Cursor) return Cursor
-- These are only needed because the Iterable aspect expects a parameter
-- of type Map instead of Map'Class. But then it means that the loop
-- is doing a lot of dynamic dispatching, and is twice as slow as a loop
-- using an explicit cursor.
is (Next (Self, Position))
with
Inline,
Pre'Class => Has_Element (Self, Position);
private
pragma SPARK_Mode (Off);
procedure Adjust (Self : in out Base_Map);
procedure Finalize (Self : in out Base_Map);
-- In case the mp is a controlled type, but irrelevant when Self
-- is not controlled.
type Slot_Kind is (Empty, Dummy, Full);
-- A node can have three statuses:
-- * empty: it was never assigned
-- Hash is 0
-- * dummy: the node had been allocated, but was then deleted. It can
-- be reused as soon as possible
-- Hash is 0
-- * full: the node is currently in use.
type Slot is record
Key : Keys.Stored_Type;
Value : Elements.Stored_Type;
Hash : Hash_Type;
-- Cached value for the hash, to speed lookups in the table
-- (before we do more extensive comparison of the key), and
-- also to speed up the resizing.
Kind : Slot_Kind := Empty;
end record;
pragma Pack (Slot);
-- The order of fields is important here to achieve a compact structure
-- and save memory.
-- On our example with 250000 items stored in the table, we end up
-- allocating/reallocating 15900kb instead of 19500kb.
type Slot_Table is array (Hash_Type range <>) of Slot;
type Slot_Table_Access is access Slot_Table;
for Slot_Table_Access'Storage_Pool use Pool.Pool;
type Cursor is record
Index : Hash_Type := Hash_Type'Last;
end record;
No_Element : constant Cursor := (Index => Hash_Type'Last);
type Base_Map is new Container_Base_Type with record
Used : Count_Type := 0;
-- Number of slots occupied by keys
Fill : Count_Type := 0;
-- Number of slots occupied by keys or dummy slots
Table : Slot_Table_Access;
-- The slots table. This is always a power of 2, since we use the
-- size as a mask for hashes.
end record;
------------------
-- Formal Model --
------------------
package P is new Conts.Functional.Maps
(Element_Type => Positive_Count_Type,
Key_Type => Cursor);
-- This instance should be ghost but it is not currently allowed by the RM.
-- See P523-006
type P_Map is record
Content : P.Map;
end record;
type P_Private_Cursor is new P.Private_Key;
use type P.Map;
function P_Iter_First (M : P_Map) return P_Private_Cursor
is (P_Private_Cursor (P.Iter_First (M.Content)));
function P_Iter_Next
(M : P_Map; C : P_Private_Cursor) return P_Private_Cursor
is (P_Private_Cursor (P.Iter_Next (M.Content, P.Private_Key (C))));
function P_Iter_Has_Element
(M : P_Map; C : P_Private_Cursor) return Boolean
is (P.Iter_Has_Element (M.Content, P.Private_Key (C)));
function P_Iter_Element (M : P_Map; C : P_Private_Cursor) return Cursor
is (P.Iter_Element (M.Content, P.Private_Key (C)));
function P_Mem (M : P_Map; C : Cursor) return Boolean
is (P.Mem (M.Content, C));
function P_Get (M : P_Map; C : Cursor) return Positive_Count_Type
is (P.Get (M.Content, C));
function "=" (M1, M2 : P_Map) return Boolean is (M1.Content = M2.Content);
function Mapping_Preserved
(S1, S2 : K.Sequence; P1, P2 : P_Map) return Boolean
is (for all I of P1 => P_Mem (P2, I)
and K.Get (S1, P_Get (P1, I)) = K.Get (S2, P_Get (P2, I)));
function Cursors_Preserved
(P1, P2 : P_Map; S1 : K.Sequence; V : Key_Type) return Boolean
is (for all I of P1 => P_Mem (P2, I) or K.Get (S1, P_Get (P1, I)) = V);
end Conts.Maps.Impl;
|
Irvise/Ada_Scheme_Example | Ada | 505 | ads | with Ada.Text_IO; use Ada.Text_IO;
with Interfaces.C; use Interfaces.C;
package Scheme_Test is
procedure Adainit;
pragma Import (C, AdaInit);
procedure Adafinal;
pragma Import (C, AdaFinal);
function Hello_Ada(Num : Int) return Int
with
Export => True,
Convention => C,
External_Name => "hello_ada";
function Hello_Scheme (String : Char_Array) return Int
with
Import => True,
Convention => C,
External_Name => "hello_scheme";
end Scheme_Test;
|
reznikmm/matreshka | Ada | 6,874 | adb | ------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- Ada Modeling Framework --
-- --
-- Tools 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 AMF.CMOF.Properties.Collections;
with AMF.CMOF.Types;
with Generator.Type_Mapping;
package body Generator.Attribute_Mapping is
----------------------------
-- Is_Ada_Distinguishable --
----------------------------
function Is_Ada_Distinguishable
(Attribute_1 : not null AMF.CMOF.Properties.CMOF_Property_Access;
Attribute_2 : not null AMF.CMOF.Properties.CMOF_Property_Access;
Mode : Subprogram_Kinds) return Boolean
is
use type AMF.Optional_String;
use type League.Strings.Universal_String;
Redefined_1 : AMF.CMOF.Properties.Collections.Set_Of_CMOF_Property;
Redefined_2 : AMF.CMOF.Properties.Collections.Set_Of_CMOF_Property;
Actual_1 : AMF.CMOF.Properties.CMOF_Property_Access;
Actual_2 : AMF.CMOF.Properties.CMOF_Property_Access;
Type_1 : AMF.CMOF.Types.CMOF_Type_Access;
begin
if Attribute_1.Get_Name /= Attribute_2.Get_Name then
-- Two subprograms with different names is distinguishable in Ada.
return True;
end if;
case Mode is
when Public | Proxy =>
return
Type_Mapping.Public_Ada_Type_Qualified_Name
(Attribute_1.Get_Type, Representation (Attribute_1))
/= Type_Mapping.Public_Ada_Type_Qualified_Name
(Attribute_2.Get_Type, Representation (Attribute_2));
when Internal =>
Actual_1 := Attribute_1;
Actual_2 := Attribute_2;
Type_1 := Attribute_1.Get_Type;
if Type_1.all not in AMF.CMOF.Classes.CMOF_Class'Class then
-- Looking for deepest redefined property for each attribute.
-- This allows to detect situation when redefined property has
-- multivalued multiplicity but source property is not
-- multivalued.
Redefined_1 := Attribute_1.Get_Redefined_Property;
while not Redefined_1.Is_Empty loop
Actual_1 := Redefined_1.Element (1);
Redefined_1 := Actual_1.Get_Redefined_Property;
end loop;
Redefined_2 := Attribute_2.Get_Redefined_Property;
while not Redefined_2.Is_Empty loop
Actual_2 := Redefined_2.Element (1);
Redefined_2 := Actual_2.Get_Redefined_Property;
end loop;
end if;
return
Type_Mapping.Internal_Ada_Type_Qualified_Name
(Actual_1.Get_Type, Representation (Actual_1))
/= Type_Mapping.Internal_Ada_Type_Qualified_Name
(Actual_2.Get_Type, Representation (Actual_2));
end case;
end Is_Ada_Distinguishable;
--------------------
-- Representation --
--------------------
function Representation
(Attribute : not null AMF.CMOF.Properties.CMOF_Property_Access)
return Representation_Kinds is
begin
if Attribute.Is_Multivalued then
if Attribute.Get_Is_Unique then
if Attribute.Get_Is_Ordered then
return Ordered_Set;
else
return Set;
end if;
else
if Attribute.Get_Is_Ordered then
return Sequence;
else
return Bag;
end if;
end if;
elsif Attribute.Lower_Bound = 0 then
return Holder;
else
return Value;
end if;
end Representation;
end Generator.Attribute_Mapping;
|
reznikmm/matreshka | Ada | 4,329 | 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.Attributes.Internals;
package body ODF.DOM.Attributes.Text.Footnotes_Position.Internals is
------------
-- Create --
------------
function Create
(Node : Matreshka.ODF_Attributes.Text.Footnotes_Position.Text_Footnotes_Position_Access)
return ODF.DOM.Attributes.Text.Footnotes_Position.ODF_Text_Footnotes_Position is
begin
return
(XML.DOM.Attributes.Internals.Create
(Matreshka.DOM_Nodes.Attribute_Access (Node)) with null record);
end Create;
----------
-- Wrap --
----------
function Wrap
(Node : Matreshka.ODF_Attributes.Text.Footnotes_Position.Text_Footnotes_Position_Access)
return ODF.DOM.Attributes.Text.Footnotes_Position.ODF_Text_Footnotes_Position is
begin
return
(XML.DOM.Attributes.Internals.Wrap
(Matreshka.DOM_Nodes.Attribute_Access (Node)) with null record);
end Wrap;
end ODF.DOM.Attributes.Text.Footnotes_Position.Internals;
|
BrickBot/Bound-T-H8-300 | Ada | 3,293 | adb | -- Bounded_Queues (body)
--
-- A component of the Bound-T Worst-Case Execution Time Tool.
--
-------------------------------------------------------------------------------
-- Copyright (c) 1999 .. 2015 Tidorum Ltd
-- All rights reserved.
--
-- Redistribution and use in source and binary forms, with or without
-- modification, are permitted provided that the following conditions are met:
--
-- 1. Redistributions of source code must retain the above copyright notice, this
-- list of conditions and the following disclaimer.
-- 2. Redistributions in binary form must reproduce the above copyright notice,
-- this list of conditions and the following disclaimer in the documentation
-- and/or other materials provided with the distribution.
--
-- This software is provided by the copyright holders and contributors "as is" and
-- any express or implied warranties, including, but not limited to, the implied
-- warranties of merchantability and fitness for a particular purpose are
-- disclaimed. In no event shall the copyright owner or contributors be liable for
-- any direct, indirect, incidental, special, exemplary, or consequential damages
-- (including, but not limited to, procurement of substitute goods or services;
-- loss of use, data, or profits; or business interruption) however caused and
-- on any theory of liability, whether in contract, strict liability, or tort
-- (including negligence or otherwise) arising in any way out of the use of this
-- software, even if advised of the possibility of such damage.
--
-- Other modules (files) of this software composition should contain their
-- own copyright statements, which may have different copyright and usage
-- conditions. The above conditions apply to this file.
-------------------------------------------------------------------------------
--
-- $Revision: 1.3 $
-- $Date: 2015/10/24 20:05:46 $
--
-- $Log: bounded_queues.adb,v $
-- Revision 1.3 2015/10/24 20:05:46 niklas
-- Moved to free licence.
--
-- Revision 1.2 2007-10-26 12:44:34 niklas
-- BT-CH-0091: Reanalyse a boundable edge only if its domain grows.
--
-- Revision 1.1 2001/01/07 21:54:14 holsti
-- First version.
--
package body Bounded_Queues is
function Length (Item : Queue_Type) return Natural
is
begin
return Item.Length;
end Length;
procedure Put (
Element : in Element_Type;
Into : in out Queue_Type)
is
Next : Positive;
-- The index of the next position, where we will
-- put the Element.
begin
if Into.Length >= Into.Max_Length then
raise Overflow;
end if;
Next := Into.First + Into.Length;
if Next > Into.Room'Last then
Next := Next - Into.Max_Length;
end if;
Into.Room (Next) := Element;
Into.Length := Into.Length + 1;
end Put;
procedure Get (
From : in out Queue_Type;
Element : out Element_Type)
is
begin
if From.Length = 0 then
raise Underflow;
end if;
Element := From.Room (From.First);
if From.First < From.Room'Last then
From.First := From.First + 1;
else
From.First := From.Room'First;
end if;
From.Length := From.Length - 1;
end Get;
end Bounded_Queues;
|
stcarrez/ada-asf | Ada | 5,152 | adb | -----------------------------------------------------------------------
-- asf-requests-tests - Unit tests for requests
-- Copyright (C) 2012, 2013, 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.Test_Caller;
with Util.Log.Loggers;
with ASF.Requests.Mockup;
package body ASF.Requests.Tests is
use Util.Tests;
-- The logger
Log : constant Util.Log.Loggers.Logger := Util.Log.Loggers.Create ("ASF.Requests.Tests");
package Caller is new Util.Test_Caller (Test, "Requests");
procedure Add_Tests (Suite : in Util.Tests.Access_Test_Suite) is
begin
Caller.Add_Test (Suite, "Test ASF.Requests.Split_Header",
Test_Split_Header'Access);
Caller.Add_Test (Suite, "Test ASF.Requests.Accept_Locales",
Test_Accept_Locales'Access);
Caller.Add_Test (Suite, "Test ASF.Requests.Set_Attribute",
Test_Set_Attribute'Access);
end Add_Tests;
-- ------------------------------
-- Test the Split_Header procedure.
-- ------------------------------
procedure Test_Split_Header (T : in out Test) is
procedure Process_Text (Item : in String;
Quality : in Quality_Type);
Count : Natural := 0;
procedure Process_Text (Item : in String;
Quality : in Quality_Type) is
begin
T.Assert (Item = "text/plain" or Item = "text/html" or Item = "text/x-dvi"
or Item = "text/x-c", "Invalid item: " & Item);
T.Assert (Quality = 0.5 or Quality = 0.8 or Quality = 1.0,
"Invalid quality");
if Item = "text/plain" then
T.Assert (Quality = 0.5, "Invalid quality for " & Item);
elsif Item = "text/x-dvi" or Item = "text/html" then
T.Assert (Quality = 0.8, "Invalid quality for " & Item);
else
T.Assert (Quality = 1.0, "Invalid quality for " & Item);
end if;
Count := Count + 1;
end Process_Text;
begin
Split_Header ("text/plain; q=0.5, text/html,text/x-dvi; q=0.8, text/x-c",
Process_Text'Access);
Util.Tests.Assert_Equals (T, 4, Count, "Invalid number of items");
end Test_Split_Header;
-- ------------------------------
-- Test the Accept_Locales procedure.
-- ------------------------------
procedure Test_Accept_Locales (T : in out Test) is
procedure Process_Locale (Locale : in Util.Locales.Locale;
Quality : in Quality_Type);
use Util.Locales;
Req : ASF.Requests.Mockup.Request;
Count : Natural := 0;
procedure Process_Locale (Locale : in Util.Locales.Locale;
Quality : in Quality_Type) is
pragma Unreferenced (Quality);
Lang : constant String := Util.Locales.Get_Language (Locale);
begin
Log.Info ("Found locale: {0}", Util.Locales.To_String (Locale));
T.Assert (Lang = "da" or Lang = "en_GB" or Lang = "en",
"Invalid lang: " & Lang);
Count := Count + 1;
end Process_Locale;
begin
Req.Accept_Locales (Process_Locale'Access);
Util.Tests.Assert_Equals (T, 1, Count, "Invalid number of calls");
Count := 0;
Req.Set_Header ("Accept-Language", "da, en-gb;q=0.8, en;q=0.7");
Req.Accept_Locales (Process_Locale'Access);
Util.Tests.Assert_Equals (T, 3, Count, "Invalid number of calls");
end Test_Accept_Locales;
-- ------------------------------
-- Test the Set_Attribute procedure.
-- ------------------------------
procedure Test_Set_Attribute (T : in out Test) is
use Util.Beans.Objects;
Req : ASF.Requests.Mockup.Request;
begin
Req.Set_Attribute ("page", Util.Beans.Objects.To_Object (Integer (1)));
Util.Tests.Assert_Equals (T, 1, Util.Beans.Objects.To_Integer (Req.Get_Attribute ("page")),
"Invalid page attribute");
Req.Remove_Attribute ("page");
T.Assert (Util.Beans.Objects.Is_Null (Req.Get_Attribute ("page")),
"Attribute page is not null");
Req.Set_Attribute ("page", Util.Beans.Objects.To_Object (Integer (1)));
Req.Set_Attribute ("page", Util.Beans.Objects.Null_Object);
T.Assert (Util.Beans.Objects.Is_Null (Req.Get_Attribute ("page")),
"Attribute page is not null");
end Test_Set_Attribute;
end ASF.Requests.Tests;
|
alvaromb/Compilemon | Ada | 22,791 | adb |
-- UNIT: generic package body of VSTRINGS
--
-- FILES: vstring_body.a in publiclib
-- related file is vstring_spec.a in publiclib
--
-- PURPOSE: An implementation of the abstract data type "variable-length
-- string."
--
-- DESCRIPTION: This package provides a private type VSTRING. VSTRING objects
-- are "strings" that have a length between zero and LAST, where
-- LAST is the generic parameter supplied in the package
-- instantiation.
--
-- In addition to the type VSTRING, a subtype and two constants
-- are declared. The subtype STRINDEX is an index to a VSTRING,
-- The STRINDEX constant FIRST is an index to the first character
-- of the string, and the VSTRING constant NUL is a VSTRING of
-- length zero. NUL is the default initial value of a VSTRING.
--
-- The following sets of functions, procedures, and operators
-- are provided as operations on the type VSTRING:
--
-- ATTRIBUTE FUNCTIONS: LEN, MAX, STR, CHAR
-- The attribute functions return the characteristics of
-- a VSTRING.
--
-- COMPARISON OPERATORS: "=", "/=", "<", ">", "<=", ">="
-- The comparison operators are the same as for the predefined
-- type STRING.
--
-- INPUT/OUTPUT PROCEDURES: GET, GET_LINE, PUT, PUT_LINE
--
-- The input/output procedures are similar to those for the
-- predefined type STRING, with the following exceptions:
--
-- - GET has an optional parameter LENGTH, which indicates
-- the number of characters to get (default is LAST).
--
-- - GET_LINE does not have a parameter to return the length
-- of the string (the LEN function should be used instead).
--
-- EXTRACTION FUNCTIONS: SLICE, SUBSTR, DELETE
-- The SLICE function returns the slice of a VSTRING between
-- two indices (equivalent to STR(X)(A .. B)).
--
-- SUBSTR returns a substring of a VSTRING taken from a given
-- index and extending a given length.
--
-- The DELETE function returns the VSTRING which results from
-- removing the slice between two indices.
--
-- EDITING FUNCTIONS: INSERT, APPEND, REPLACE
-- The editing functions return the VSTRING which results from
-- inserting, appending, or replacing at a given index with a
-- VSTRING, STRING, or CHARACTER. The index must be in the
-- current range of the VSTRING; i.e., zero cannot be used.
--
-- CONCATENATION OPERATOR: "&"
-- The concatenation operator is the same as for the type
-- STRING. It should be used instead of APPEND when the
-- APPEND would always be after the last character.
--
-- POSITION FUNCTIONS: INDEX, RINDEX
-- The position functions return an index to the Nth occurrence
-- of a VSTRING, STRING, or CHARACTER from the front or back
-- of a VSTRING. Zero is returned if the search is not
-- successful.
--
-- CONVERSION FUNCTIONS AND OPERATOR: VSTR, CONVERT, "+"
-- VSTR converts a STRING or a CHARACTER to a VSTRING.
--
-- CONVERT is a generic function which can be instantiated to
-- convert from any given variable-length string to another,
-- provided the FROM type has a function equivelent to STR
-- defined for it, and that the TO type has a function equiv-
-- elent to VSTR defined for it. This provides a means for
-- converting between VSTRINGs declared in separate instant-
-- iations of VSTRINGS. When instantiating CONVERT for
-- VSTRINGs, the STR and VSTR functions are implicitly defined,
-- provided that they have been made visible (by a use clause).
--
-- Note: CONVERT is NOT implicitly associated with the type
-- VSTRING declared in this package (since it would not be a
-- derivable function (see RM 3.4(11))).
--
-- Caution: CONVERT cannot be instantiated directly with the
-- names VSTR and STR, since the name of the subprogram being
-- declared would hide the generic parameters with the same
-- names (see RM 8.3(16)). CONVERT can be instantiated with
-- the operator "+", and any instantiation of CONVERT can
-- subsequently be renamed VSTR or STR.
--
-- Example: Given two VSTRINGS instantiations X and Y:
-- function "+" is new X.CONVERT(X.VSTRING, Y.VSTRING);
-- function "+" is new X.CONVERT(Y.VSTRING, X.VSTRING);
--
-- (Y.CONVERT could have been used in place of X.CONVERT)
--
-- function VSTR(A : X.VSTRING) return Y.VSTRING renames "+";
-- function VSTR(A : Y.VSTRING) return X.VSTRING renames "+";
--
-- "+" is equivelent to VSTR. It is supplied as a short-hand
-- notation for the function. The "+" operator cannot immed-
-- iately follow the "&" operator; use ... & (+ ...) instead.
pragma PAGE;
-- DISCUSSION:
--
-- This package implements the type "variable-length string" (vstring)
-- using generics. The alternative approaches are to use a discriminant
-- record in which the discriminant controls the length of a STRING inside
-- the record, or a record containing an access type which points to a
-- string, which can be deallocated and reallocated when necessary.
--
-- Advantages of this package:
-- * The other approaches force the vstring to be a limited private
-- type. Thus, their vstrings cannot appear on the left side of
-- the assignment operator; ie., their vstrings cannot be given
-- initial values or values by direct assignment. This package
-- uses a private type; therefore, these things can be done.
--
-- * The other approach stores the vstring in a string whose length
-- is determined dynamically. This package uses a fixed length
-- string. This difference might be reflected in faster and more
-- consistent execution times (this has NOT been verified).
--
-- Disadvantages of this package:
-- * Different instantiations must be used to declare vstrings with
-- different maximum lengths (this may be desirable, since
-- CONSTRAINT_ERROR will be raised if the maximum is exceeded).
--
-- * A second declaration is required to give the type declared by
-- the instantiation a name other than "VSTRING."
--
-- * The storage required for a vstring is determined by the generic
-- parameter LAST and not the actual length of its contents. Thus,
-- each object is allocated the maximum amount of storage, regardless
-- of its actual size.
--
-- MISCELLANEOUS:
-- Constraint checking is done explicitly in the code; thus, it cannot
-- be suppressed. On the other hand, constraint checking is not lost
-- if pragma suppress is supplied to the compilation (-S option)
-- (The robustness of the explicit constraint checking has NOT been
-- determined).
--
-- Compiling with the optimizer (-O option) may significantly reduce
-- the size (and possibly execution time) of the resulting executable.
--
-- Compiling an instantiation of VSTRINGS is roughly equivelent to
-- recompiling VSTRINGS. Since this takes a significant amount of time,
-- and the instantiation does not depend on any other library units,
-- it is STRONGLY recommended that the instantiation be compiled
-- separately, and thus done only ONCE.
--
-- USAGE: with VSTRINGS;
-- package package_name is new VSTRINGS(maximum_length);
-- .......................................................................... --
pragma PAGE;
package body vstrings is
-- local declarations
FILL_CHAR : constant CHARACTER := ASCII.NUL;
-- procedure FORMAT(THE_STRING : in out VSTRING; OLDLEN : in STRINDEX := LAST) is
-- -- fill the string with FILL_CHAR to null out old values
-- begin -- FORMAT (Local Procedure)
-- THE_STRING.VALUE(THE_STRING.LEN + 1 .. OLDLEN) :=
-- (others => FILL_CHAR);
-- end FORMAT;
-- CvdL: the above assignment will be compiled wrongly with gcc-2.6.0
-- and gnat-1.83. It overwrites parts if the runtime stack by writing
-- fill_char for a fixed amount(?) of times.
-- Maybe the error is in the caller... it is called FORMAT(Str, 0)!!!
-- The following procedure is far from optimal but it doesn't break
-- NOTE: gcc-2.6.2 and gnat-2.00 do it wrong too!
procedure FORMAT(THE_STRING : in out VSTRING; OLDLEN : in STRINDEX := LAST)
is
-- fill the string with FILL_CHAR to null out old values
begin -- FORMAT (Local Procedure)
for I in the_string.len+1..oldlen loop
THE_STRING.VALUE(I) := FILL_CHAR;
end loop;
end FORMAT;
-- bodies of visible operations
function LEN(FROM : VSTRING) return STRINDEX is
begin -- LEN
return(FROM.LEN);
end LEN;
function MAX(FROM : VSTRING) return STRINDEX is
begin -- MAX
return(LAST);
end MAX;
function STR(FROM : VSTRING) return STRING is
begin -- STR
return(FROM.VALUE(FIRST .. FROM.LEN));
end STR;
function CHAR(FROM : VSTRING; POSITION : STRINDEX := FIRST)
return CHARACTER is
begin -- CHAR
if POSITION not in FIRST .. FROM.LEN
then raise CONSTRAINT_ERROR;
end if;
return(FROM.VALUE(POSITION));
end CHAR;
function "<" (LEFT: VSTRING; RIGHT: VSTRING) return BOOLEAN is
begin -- "<"
return(LEFT.VALUE < RIGHT.VALUE);
end "<";
function ">" (LEFT: VSTRING; RIGHT: VSTRING) return BOOLEAN is
begin -- ">"
return(LEFT.VALUE > RIGHT.VALUE);
end ">";
function "<=" (LEFT: VSTRING; RIGHT: VSTRING) return BOOLEAN is
begin -- "<="
return(LEFT.VALUE <= RIGHT.VALUE);
end "<=";
function ">=" (LEFT: VSTRING; RIGHT: VSTRING) return BOOLEAN is
begin -- ">="
return(LEFT.VALUE >= RIGHT.VALUE);
end ">=";
procedure PUT(FILE : in FILE_TYPE; ITEM : in VSTRING) is
begin -- PUT
PUT(FILE, ITEM.VALUE(FIRST .. ITEM.LEN));
end PUT;
procedure Put(ITEM : in VSTRING) is
begin -- PUT
PUT(ITEM.VALUE(FIRST .. ITEM.LEN));
end PUT;
procedure PUT_LINE(FILE : in FILE_TYPE; ITEM : in VSTRING) is
begin -- PUT_LINE
PUT_LINE(FILE, ITEM.VALUE(FIRST .. ITEM.LEN));
end PUT_LINE;
procedure PUT_LINE(ITEM : in VSTRING) is
begin -- PUT_LINE
PUT_LINE(ITEM.VALUE(FIRST .. ITEM.LEN));
end PUT_LINE;
procedure GET(FILE : in FILE_TYPE; ITEM : out VSTRING;
LENGTH : in STRINDEX := LAST) is
begin -- GET
if LENGTH not in FIRST .. LAST
then raise CONSTRAINT_ERROR;
end if;
ITEM := NUL;
for INDEX in FIRST .. LENGTH loop
GET(FILE, ITEM.VALUE(INDEX));
ITEM.LEN := INDEX;
end loop;
end GET;
procedure GET(ITEM : out VSTRING; LENGTH : in STRINDEX := LAST) is
begin -- GET
if LENGTH not in FIRST .. LAST
then raise CONSTRAINT_ERROR;
end if;
ITEM := NUL;
for INDEX in FIRST .. LENGTH loop
GET(ITEM.VALUE(INDEX));
ITEM.LEN := INDEX;
end loop;
end GET;
procedure GET_LINE(FILE : in FILE_TYPE; ITEM : in out VSTRING) is
OLDLEN : constant STRINDEX := ITEM.LEN;
begin -- GET_LINE
GET_LINE(FILE, ITEM.VALUE, ITEM.LEN);
FORMAT(ITEM, OLDLEN);
end GET_LINE;
procedure GET_LINE(ITEM : in out VSTRING) is
OLDLEN : constant STRINDEX := ITEM.LEN;
begin -- GET_LINE
GET_LINE(ITEM.VALUE, ITEM.LEN);
FORMAT(ITEM, OLDLEN);
end GET_LINE;
function SLICE(FROM : VSTRING; FRONT, BACK : STRINDEX) return VSTRING is
begin -- SLICE
if ((FRONT not in FIRST .. FROM.LEN) or else
(BACK not in FIRST .. FROM.LEN)) and then FRONT <= BACK
then raise CONSTRAINT_ERROR;
end if;
return(Vstr(FROM.VALUE(FRONT .. BACK)));
end SLICE;
function SUBSTR(FROM : VSTRING; START, LENGTH : STRINDEX) return VSTRING is
begin -- SUBSTR
if (START not in FIRST .. FROM.LEN) or else
((START + LENGTH - 1 not in FIRST .. FROM.LEN)
and then (LENGTH > 0))
then raise CONSTRAINT_ERROR;
end if;
return(Vstr(FROM.VALUE(START .. START + LENGTH -1)));
end SUBSTR;
function DELETE(FROM : VSTRING; FRONT, BACK : STRINDEX) return VSTRING is
TEMP : VSTRING := FROM;
begin -- DELETE
if ((FRONT not in FIRST .. FROM.LEN) or else
(BACK not in FIRST .. FROM.LEN)) and then FRONT <= BACK
then raise CONSTRAINT_ERROR;
end if;
if FRONT > BACK then return(FROM); end if;
TEMP.LEN := FROM.LEN - (BACK - FRONT) - 1;
TEMP.VALUE(FRONT .. TEMP.LEN) := FROM.VALUE(BACK + 1 .. FROM.LEN);
FORMAT(TEMP, FROM.LEN);
return(TEMP);
end DELETE;
function INSERT(TARGET: VSTRING; ITEM: VSTRING;
POSITION : STRINDEX := FIRST) return VSTRING is
TEMP : VSTRING;
begin -- INSERT
if POSITION not in FIRST .. TARGET.LEN
then raise CONSTRAINT_ERROR;
end if;
if TARGET.LEN + ITEM.LEN > LAST
then raise CONSTRAINT_ERROR;
else TEMP.LEN := TARGET.LEN + ITEM.LEN;
end if;
TEMP.VALUE(FIRST .. POSITION - 1) := TARGET.VALUE(FIRST .. POSITION - 1);
TEMP.VALUE(POSITION .. (POSITION + ITEM.LEN - 1)) :=
ITEM.VALUE(FIRST .. ITEM.LEN);
TEMP.VALUE((POSITION + ITEM.LEN) .. TEMP.LEN) :=
TARGET.VALUE(POSITION .. TARGET.LEN);
return(TEMP);
end INSERT;
function INSERT(TARGET: VSTRING; ITEM: STRING;
POSITION : STRINDEX := FIRST) return VSTRING is
begin -- INSERT
return INSERT(TARGET, VSTR(ITEM), POSITION);
end INSERT;
function INSERT(TARGET: VSTRING; ITEM: CHARACTER;
POSITION : STRINDEX := FIRST) return VSTRING is
begin -- INSERT
return INSERT(TARGET, VSTR(ITEM), POSITION);
end INSERT;
function APPEND(TARGET: VSTRING; ITEM: VSTRING; POSITION : STRINDEX)
return VSTRING is
TEMP : VSTRING;
POS : STRINDEX := POSITION;
begin -- APPEND
if POSITION not in FIRST .. TARGET.LEN
then raise CONSTRAINT_ERROR;
end if;
if TARGET.LEN + ITEM.LEN > LAST
then raise CONSTRAINT_ERROR;
else TEMP.LEN := TARGET.LEN + ITEM.LEN;
end if;
TEMP.VALUE(FIRST .. POS) := TARGET.VALUE(FIRST .. POS);
TEMP.VALUE(POS + 1 .. (POS + ITEM.LEN)) := ITEM.VALUE(FIRST .. ITEM.LEN);
TEMP.VALUE((POS + ITEM.LEN + 1) .. TEMP.LEN) :=
TARGET.VALUE(POS + 1 .. TARGET.LEN);
return(TEMP);
end APPEND;
function APPEND(TARGET: VSTRING; ITEM: STRING; POSITION : STRINDEX)
return VSTRING is
begin -- APPEND
return APPEND(TARGET, VSTR(ITEM), POSITION);
end APPEND;
function APPEND(TARGET: VSTRING; ITEM: CHARACTER; POSITION : STRINDEX)
return VSTRING is
begin -- APPEND
return APPEND(TARGET, VSTR(ITEM), POSITION);
end APPEND;
function APPEND(TARGET: VSTRING; ITEM: VSTRING) return VSTRING is
begin -- APPEND
return(APPEND(TARGET, ITEM, TARGET.LEN));
end APPEND;
function APPEND(TARGET: VSTRING; ITEM: STRING) return VSTRING is
begin -- APPEND
return(APPEND(TARGET, VSTR(ITEM), TARGET.LEN));
end APPEND;
function APPEND(TARGET: VSTRING; ITEM: CHARACTER) return VSTRING is
begin -- APPEND
return(APPEND(TARGET, VSTR(ITEM), TARGET.LEN));
end APPEND;
function REPLACE(TARGET: VSTRING; ITEM: VSTRING;
POSITION : STRINDEX := FIRST) return VSTRING is
TEMP : VSTRING;
begin -- REPLACE
if POSITION not in FIRST .. TARGET.LEN
then raise CONSTRAINT_ERROR;
end if;
if POSITION + ITEM.LEN - 1 <= TARGET.LEN
then TEMP.LEN := TARGET.LEN;
elsif POSITION + ITEM.LEN - 1 > LAST
then raise CONSTRAINT_ERROR;
else TEMP.LEN := POSITION + ITEM.LEN - 1;
end if;
TEMP.VALUE(FIRST .. POSITION - 1) := TARGET.VALUE(FIRST .. POSITION - 1);
TEMP.VALUE(POSITION .. (POSITION + ITEM.LEN - 1)) :=
ITEM.VALUE(FIRST .. ITEM.LEN);
TEMP.VALUE((POSITION + ITEM.LEN) .. TEMP.LEN) :=
TARGET.VALUE((POSITION + ITEM.LEN) .. TARGET.LEN);
return(TEMP);
end REPLACE;
function REPLACE(TARGET: VSTRING; ITEM: STRING;
POSITION : STRINDEX := FIRST) return VSTRING is
begin -- REPLACE
return REPLACE(TARGET, VSTR(ITEM), POSITION);
end REPLACE;
function REPLACE(TARGET: VSTRING; ITEM: CHARACTER;
POSITION : STRINDEX := FIRST) return VSTRING is
begin -- REPLACE
return REPLACE(TARGET, VSTR(ITEM), POSITION);
end REPLACE;
function "&"(LEFT:VSTRING; RIGHT : VSTRING) return VSTRING is
TEMP : VSTRING;
begin -- "&"
if LEFT.LEN + RIGHT.LEN > LAST
then raise CONSTRAINT_ERROR;
else TEMP.LEN := LEFT.LEN + RIGHT.LEN;
end if;
TEMP.VALUE(FIRST .. TEMP.LEN) := LEFT.VALUE(FIRST .. LEFT.LEN) &
RIGHT.VALUE(FIRST .. RIGHT.LEN);
return(TEMP);
end "&";
function "&"(LEFT:VSTRING; RIGHT : STRING) return VSTRING is
begin -- "&"
return LEFT & VSTR(RIGHT);
end "&";
function "&"(LEFT:VSTRING; RIGHT : CHARACTER) return VSTRING is
begin -- "&"
return LEFT & VSTR(RIGHT);
end "&";
function "&"(LEFT : STRING; RIGHT : VSTRING) return VSTRING is
begin -- "&"
return VSTR(LEFT) & RIGHT;
end "&";
function "&"(LEFT : CHARACTER; RIGHT : VSTRING) return VSTRING is
begin -- "&"
return VSTR(LEFT) & RIGHT;
end "&";
Function INDEX(WHOLE : VSTRING; PART : VSTRING; OCCURRENCE : NATURAL := 1)
return STRINDEX is
NOT_FOUND : constant NATURAL := 0;
INDEX : NATURAL := FIRST;
COUNT : NATURAL := 0;
begin -- INDEX
if PART = NUL then return(NOT_FOUND); -- by definition
end if;
while INDEX + PART.LEN - 1 <= WHOLE.LEN and then COUNT < OCCURRENCE loop
if WHOLE.VALUE(INDEX .. PART.LEN + INDEX - 1) =
PART.VALUE(1 .. PART.LEN)
then COUNT := COUNT + 1;
end if;
INDEX := INDEX + 1;
end loop;
if COUNT = OCCURRENCE
then return(INDEX - 1);
else return(NOT_FOUND);
end if;
end INDEX;
Function INDEX(WHOLE : VSTRING; PART : STRING; OCCURRENCE : NATURAL := 1)
return STRINDEX is
begin -- Index
return(Index(WHOLE, VSTR(PART), OCCURRENCE));
end INDEX;
Function INDEX(WHOLE : VSTRING; PART : CHARACTER; OCCURRENCE : NATURAL := 1)
return STRINDEX is
begin -- Index
return(Index(WHOLE, VSTR(PART), OCCURRENCE));
end INDEX;
function RINDEX(WHOLE: VSTRING; PART:VSTRING; OCCURRENCE:NATURAL := 1)
return STRINDEX is
NOT_FOUND : constant NATURAL := 0;
INDEX : INTEGER := WHOLE.LEN - (PART.LEN -1);
COUNT : NATURAL := 0;
begin -- RINDEX
if PART = NUL then return(NOT_FOUND); -- by definition
end if;
while INDEX >= FIRST and then COUNT < OCCURRENCE loop
if WHOLE.VALUE(INDEX .. PART.LEN + INDEX - 1) =
PART.VALUE(1 .. PART.LEN)
then COUNT := COUNT + 1;
end if;
INDEX := INDEX - 1;
end loop;
if COUNT = OCCURRENCE
then
if COUNT > 0
then return(INDEX + 1);
else return(NOT_FOUND);
end if;
else return(NOT_FOUND);
end if;
end RINDEX;
Function RINDEX(WHOLE : VSTRING; PART : STRING; OCCURRENCE : NATURAL := 1)
return STRINDEX is
begin -- Rindex
return(RINDEX(WHOLE, VSTR(PART), OCCURRENCE));
end RINDEX;
Function RINDEX(WHOLE : VSTRING; PART : CHARACTER; OCCURRENCE : NATURAL := 1)
return STRINDEX is
begin -- Rindex
return(RINDEX(WHOLE, VSTR(PART), OCCURRENCE));
end RINDEX;
function VSTR(FROM : CHARACTER) return VSTRING is
TEMP : VSTRING;
begin -- VSTR
if LAST < 1
then raise CONSTRAINT_ERROR;
else TEMP.LEN := 1;
end if;
TEMP.VALUE(FIRST) := FROM;
return(TEMP);
end VSTR;
function VSTR(FROM : STRING) return VSTRING is
TEMP : VSTRING;
begin -- VSTR
if FROM'LENGTH > LAST
then raise CONSTRAINT_ERROR;
else TEMP.LEN := FROM'LENGTH;
end if;
TEMP.VALUE(FIRST .. FROM'LENGTH) := FROM;
return(TEMP);
end VSTR;
Function "+" (FROM : STRING) return VSTRING is
begin -- "+"
return(VSTR(FROM));
end "+";
Function "+" (FROM : CHARACTER) return VSTRING is
begin
return(VSTR(FROM));
end "+";
function CONVERT(X : FROM) return TO is
begin -- CONVERT
return(VSTR(STR(X)));
end CONVERT;
end vstrings;
-- .......................................................................... --
--
-- DISTRIBUTION AND COPYRIGHT:
--
-- This software is released to the Public Domain (note:
-- software released to the Public Domain is not subject
-- to copyright protection).
-- Restrictions on use or distribution: NONE
--
-- DISCLAIMER:
--
-- This software and its documentation are provided "AS IS" and
-- without any expressed or implied warranties whatsoever.
-- No warranties as to performance, merchantability, or fitness
-- for a particular purpose exist.
--
-- Because of the diversity of conditions and hardware under
-- which this software may be used, no warranty of fitness for
-- a particular purpose is offered. The user is advised to
-- test the software thoroughly before relying on it. The user
-- must assume the entire risk and liability of using this
-- software.
--
-- In no event shall any person or organization of people be
-- held responsible for any direct, indirect, consequential
-- or inconsequential damages or lost profits.
|
vpodzime/ada-util | Ada | 6,077 | ads | -----------------------------------------------------------------------
-- Util.Streams.Buffered -- Buffered streams Stream utilities
-- Copyright (C) 2010, 2013, 2015, 2016 Stephane Carrez
-- Written by Stephane Carrez ([email protected])
--
-- Licensed under the Apache License, Version 2.0 (the "License");
-- you may not use this file except in compliance with the License.
-- You may obtain a copy of the License at
--
-- http://www.apache.org/licenses/LICENSE-2.0
--
-- Unless required by applicable law or agreed to in writing, software
-- distributed under the License is distributed on an "AS IS" BASIS,
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-- See the License for the specific language governing permissions and
-- limitations under the License.
-----------------------------------------------------------------------
with Ada.Strings.Unbounded;
with Ada.Strings.Wide_Wide_Unbounded;
with Ada.Finalization;
package Util.Streams.Buffered is
pragma Preelaborate;
-- -----------------------
-- Buffered stream
-- -----------------------
-- The <b>Buffered_Stream</b> is an output/input stream which uses
-- an intermediate buffer. It can be configured to read or write to
-- another stream that it will read or write using the buffer.
--
-- It is necessary to call <b>Flush</b> to make sure the data
-- is written to the target stream. The <b>Flush</b> operation will
-- be called when finalizing the buffered stream.
type Buffered_Stream is limited new Output_Stream and Input_Stream with private;
type Buffer_Access is access Ada.Streams.Stream_Element_Array;
-- Initialize the stream to read or write on the given streams.
-- An internal buffer is allocated for writing the stream.
procedure Initialize (Stream : in out Buffered_Stream;
Output : in Output_Stream_Access;
Input : in Input_Stream_Access;
Size : in Positive);
-- Initialize the stream with a buffer of <b>Size</b> bytes.
procedure Initialize (Stream : in out Buffered_Stream;
Size : in Positive);
-- Initialize the stream to read from the string.
procedure Initialize (Stream : in out Buffered_Stream;
Content : in String);
-- Close the sink.
overriding
procedure Close (Stream : in out Buffered_Stream);
-- Get the direct access to the buffer.
function Get_Buffer (Stream : in Buffered_Stream) return Buffer_Access;
-- Write a raw character on the stream.
procedure Write (Stream : in out Buffered_Stream;
Char : in Character);
-- Write a wide character on the stream doing some conversion if necessary.
-- The default implementation translates the wide character to a UTF-8 sequence.
procedure Write_Wide (Stream : in out Buffered_Stream;
Item : in Wide_Wide_Character);
-- Write a raw string on the stream.
procedure Write (Stream : in out Buffered_Stream;
Item : in String);
-- Write a raw string on the stream.
procedure Write (Stream : in out Buffered_Stream;
Item : in Ada.Strings.Unbounded.Unbounded_String);
-- Write a raw string on the stream.
procedure Write (Stream : in out Buffered_Stream;
Item : in Ada.Strings.Wide_Wide_Unbounded.Unbounded_Wide_Wide_String);
-- Write the buffer array to the output stream.
overriding
procedure Write (Stream : in out Buffered_Stream;
Buffer : in Ada.Streams.Stream_Element_Array);
-- Flush the buffer by writing on the output stream.
-- Raises Data_Error if there is no output stream.
overriding
procedure Flush (Stream : in out Buffered_Stream);
-- Get the number of element in the stream.
function Get_Size (Stream : in Buffered_Stream) return Natural;
-- Fill the buffer by reading the input stream.
-- Raises Data_Error if there is no input stream;
procedure Fill (Stream : in out Buffered_Stream);
-- Read one character from the input stream.
procedure Read (Stream : in out Buffered_Stream;
Char : out Character);
-- Read into the buffer as many bytes as possible and return in
-- <b>last</b> the position of the last byte read.
overriding
procedure Read (Stream : in out Buffered_Stream;
Into : out Ada.Streams.Stream_Element_Array;
Last : out Ada.Streams.Stream_Element_Offset);
-- Read into the buffer as many bytes as possible and return in
-- <b>last</b> the position of the last byte read.
procedure Read (Stream : in out Buffered_Stream;
Into : in out Ada.Strings.Unbounded.Unbounded_String);
-- Returns True if the end of the stream is reached.
function Is_Eof (Stream : in Buffered_Stream) return Boolean;
private
use Ada.Streams;
type Buffered_Stream is limited new Ada.Finalization.Limited_Controlled
and Output_Stream and Input_Stream with record
-- The buffer where the data is written before being flushed.
Buffer : Buffer_Access := null;
-- The next write position within the buffer.
Write_Pos : Stream_Element_Offset := 0;
-- The next read position within the buffer.
Read_Pos : Stream_Element_Offset := 1;
-- The last valid write position within the buffer.
Last : Stream_Element_Offset := 0;
-- The output stream to use for flushing the buffer.
Output : Output_Stream_Access := null;
-- The input stream to use to fill the buffer.
Input : Input_Stream_Access := null;
No_Flush : Boolean := False;
-- Reached end of file when reading.
Eof : Boolean := False;
end record;
-- Flush the stream and release the buffer.
overriding
procedure Finalize (Object : in out Buffered_Stream);
end Util.Streams.Buffered;
|
stcarrez/jason | Ada | 52,662 | adb | -----------------------------------------------------------------------
-- Jason.Projects.Models -- Jason.Projects.Models
-----------------------------------------------------------------------
-- File generated by Dynamo DO NOT MODIFY
-- Template used: templates/model/package-body.xhtml
-- Ada Generator: https://github.com/stcarrez/dynamo Version 1.4.0
-----------------------------------------------------------------------
-- Copyright (C) 2023 Stephane.Carrez
-- Written by Stephane.Carrez ([email protected])
--
-- Licensed under the Apache License, Version 2.0 (the "License");
-- you may not use this file except in compliance with the License.
-- You may obtain a copy of the License at
--
-- http://www.apache.org/licenses/LICENSE-2.0
--
-- Unless required by applicable law or agreed to in writing, software
-- distributed under the License is distributed on an "AS IS" BASIS,
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-- See the License for the specific language governing permissions and
-- limitations under the License.
-----------------------------------------------------------------------
pragma Warnings (Off);
with Ada.Unchecked_Deallocation;
with Util.Beans.Objects.Time;
with ASF.Events.Faces.Actions;
pragma Warnings (On);
package body Jason.Projects.Models is
pragma Style_Checks ("-mrIu");
pragma Warnings (Off, "formal parameter * is not referenced");
pragma Warnings (Off, "use clause for type *");
pragma Warnings (Off, "use clause for private type *");
use type ADO.Objects.Object_Record_Access;
use type ADO.Objects.Object_Ref;
function Project_Key (Id : in ADO.Identifier) return ADO.Objects.Object_Key is
Result : ADO.Objects.Object_Key (Of_Type => ADO.Objects.KEY_INTEGER,
Of_Class => PROJECT_DEF'Access);
begin
ADO.Objects.Set_Value (Result, Id);
return Result;
end Project_Key;
function Project_Key (Id : in String) return ADO.Objects.Object_Key is
Result : ADO.Objects.Object_Key (Of_Type => ADO.Objects.KEY_INTEGER,
Of_Class => PROJECT_DEF'Access);
begin
ADO.Objects.Set_Value (Result, Id);
return Result;
end Project_Key;
function "=" (Left, Right : Project_Ref'Class) return Boolean is
begin
return ADO.Objects.Object_Ref'Class (Left) = ADO.Objects.Object_Ref'Class (Right);
end "=";
procedure Set_Field (Object : in out Project_Ref'Class;
Impl : out Project_Access) is
Result : ADO.Objects.Object_Record_Access;
begin
Object.Prepare_Modify (Result);
Impl := Project_Impl (Result.all)'Access;
end Set_Field;
-- Internal method to allocate the Object_Record instance
overriding
procedure Allocate (Object : in out Project_Ref) is
Impl : Project_Access;
begin
Impl := new Project_Impl;
Impl.Version := 0;
Impl.Create_Date := ADO.DEFAULT_TIME;
Impl.Status := Status_Type'First;
Impl.Last_Ticket := 0;
Impl.Update_Date := ADO.DEFAULT_TIME;
ADO.Objects.Set_Object (Object, Impl.all'Access);
end Allocate;
-- ----------------------------------------
-- Data object: Project
-- ----------------------------------------
procedure Set_Id (Object : in out Project_Ref;
Value : in ADO.Identifier) is
Impl : Project_Access;
begin
Set_Field (Object, Impl);
ADO.Objects.Set_Field_Key_Value (Impl.all, 1, Value);
end Set_Id;
function Get_Id (Object : in Project_Ref)
return ADO.Identifier is
Impl : constant Project_Access
:= Project_Impl (Object.Get_Object.all)'Access;
begin
return Impl.Get_Key_Value;
end Get_Id;
function Get_Version (Object : in Project_Ref)
return Integer is
Impl : constant Project_Access
:= Project_Impl (Object.Get_Load_Object.all)'Access;
begin
return Impl.Version;
end Get_Version;
procedure Set_Name (Object : in out Project_Ref;
Value : in String) is
Impl : Project_Access;
begin
Set_Field (Object, Impl);
ADO.Objects.Set_Field_String (Impl.all, 3, Impl.Name, Value);
end Set_Name;
procedure Set_Name (Object : in out Project_Ref;
Value : in Ada.Strings.Unbounded.Unbounded_String) is
Impl : Project_Access;
begin
Set_Field (Object, Impl);
ADO.Objects.Set_Field_Unbounded_String (Impl.all, 3, Impl.Name, Value);
end Set_Name;
function Get_Name (Object : in Project_Ref)
return String is
begin
return Ada.Strings.Unbounded.To_String (Object.Get_Name);
end Get_Name;
function Get_Name (Object : in Project_Ref)
return Ada.Strings.Unbounded.Unbounded_String is
Impl : constant Project_Access
:= Project_Impl (Object.Get_Load_Object.all)'Access;
begin
return Impl.Name;
end Get_Name;
procedure Set_Create_Date (Object : in out Project_Ref;
Value : in Ada.Calendar.Time) is
Impl : Project_Access;
begin
Set_Field (Object, Impl);
ADO.Objects.Set_Field_Time (Impl.all, 4, Impl.Create_Date, Value);
end Set_Create_Date;
function Get_Create_Date (Object : in Project_Ref)
return Ada.Calendar.Time is
Impl : constant Project_Access
:= Project_Impl (Object.Get_Load_Object.all)'Access;
begin
return Impl.Create_Date;
end Get_Create_Date;
procedure Set_Status (Object : in out Project_Ref;
Value : in Status_Type) is
procedure Set_Field_Discrete is
new ADO.Objects.Set_Field_Operation
(Status_Type);
Impl : Project_Access;
begin
Set_Field (Object, Impl);
Set_Field_Discrete (Impl.all, 5, Impl.Status, Value);
end Set_Status;
function Get_Status (Object : in Project_Ref)
return Status_Type is
Impl : constant Project_Access
:= Project_Impl (Object.Get_Load_Object.all)'Access;
begin
return Impl.Status;
end Get_Status;
procedure Set_Last_Ticket (Object : in out Project_Ref;
Value : in Integer) is
Impl : Project_Access;
begin
Set_Field (Object, Impl);
ADO.Objects.Set_Field_Integer (Impl.all, 6, Impl.Last_Ticket, Value);
end Set_Last_Ticket;
function Get_Last_Ticket (Object : in Project_Ref)
return Integer is
Impl : constant Project_Access
:= Project_Impl (Object.Get_Load_Object.all)'Access;
begin
return Impl.Last_Ticket;
end Get_Last_Ticket;
procedure Set_Update_Date (Object : in out Project_Ref;
Value : in Ada.Calendar.Time) is
Impl : Project_Access;
begin
Set_Field (Object, Impl);
ADO.Objects.Set_Field_Time (Impl.all, 7, Impl.Update_Date, Value);
end Set_Update_Date;
function Get_Update_Date (Object : in Project_Ref)
return Ada.Calendar.Time is
Impl : constant Project_Access
:= Project_Impl (Object.Get_Load_Object.all)'Access;
begin
return Impl.Update_Date;
end Get_Update_Date;
procedure Set_Description (Object : in out Project_Ref;
Value : in String) is
Impl : Project_Access;
begin
Set_Field (Object, Impl);
ADO.Objects.Set_Field_String (Impl.all, 8, Impl.Description, Value);
end Set_Description;
procedure Set_Description (Object : in out Project_Ref;
Value : in Ada.Strings.Unbounded.Unbounded_String) is
Impl : Project_Access;
begin
Set_Field (Object, Impl);
ADO.Objects.Set_Field_Unbounded_String (Impl.all, 8, Impl.Description, Value);
end Set_Description;
function Get_Description (Object : in Project_Ref)
return String is
begin
return Ada.Strings.Unbounded.To_String (Object.Get_Description);
end Get_Description;
function Get_Description (Object : in Project_Ref)
return Ada.Strings.Unbounded.Unbounded_String is
Impl : constant Project_Access
:= Project_Impl (Object.Get_Load_Object.all)'Access;
begin
return Impl.Description;
end Get_Description;
procedure Set_Wiki (Object : in out Project_Ref;
Value : in AWA.Wikis.Models.Wiki_Space_Ref'Class) is
Impl : Project_Access;
begin
Set_Field (Object, Impl);
ADO.Objects.Set_Field_Object (Impl.all, 9, Impl.Wiki, Value);
end Set_Wiki;
function Get_Wiki (Object : in Project_Ref)
return AWA.Wikis.Models.Wiki_Space_Ref'Class is
Impl : constant Project_Access
:= Project_Impl (Object.Get_Load_Object.all)'Access;
begin
return Impl.Wiki;
end Get_Wiki;
procedure Set_Owner (Object : in out Project_Ref;
Value : in AWA.Users.Models.User_Ref'Class) is
Impl : Project_Access;
begin
Set_Field (Object, Impl);
ADO.Objects.Set_Field_Object (Impl.all, 10, Impl.Owner, Value);
end Set_Owner;
function Get_Owner (Object : in Project_Ref)
return AWA.Users.Models.User_Ref'Class is
Impl : constant Project_Access
:= Project_Impl (Object.Get_Load_Object.all)'Access;
begin
return Impl.Owner;
end Get_Owner;
-- Copy of the object.
procedure Copy (Object : in Project_Ref;
Into : in out Project_Ref) is
Result : Project_Ref;
begin
if not Object.Is_Null then
declare
Impl : constant Project_Access
:= Project_Impl (Object.Get_Load_Object.all)'Access;
Copy : constant Project_Access
:= new Project_Impl;
begin
ADO.Objects.Set_Object (Result, Copy.all'Access);
Copy.Copy (Impl.all);
Copy.Version := Impl.Version;
Copy.Name := Impl.Name;
Copy.Create_Date := Impl.Create_Date;
Copy.Status := Impl.Status;
Copy.Last_Ticket := Impl.Last_Ticket;
Copy.Update_Date := Impl.Update_Date;
Copy.Description := Impl.Description;
Copy.Wiki := Impl.Wiki;
Copy.Owner := Impl.Owner;
end;
end if;
Into := Result;
end Copy;
overriding
procedure Find (Object : in out Project_Ref;
Session : in out ADO.Sessions.Session'Class;
Query : in ADO.SQL.Query'Class;
Found : out Boolean) is
Impl : constant Project_Access := new Project_Impl;
begin
Impl.Find (Session, Query, Found);
if Found then
ADO.Objects.Set_Object (Object, Impl.all'Access);
else
ADO.Objects.Set_Object (Object, null);
Destroy (Impl);
end if;
end Find;
procedure Load (Object : in out Project_Ref;
Session : in out ADO.Sessions.Session'Class;
Id : in ADO.Identifier) is
Impl : constant Project_Access := new Project_Impl;
Found : Boolean;
Query : ADO.SQL.Query;
begin
Query.Bind_Param (Position => 1, Value => Id);
Query.Set_Filter ("id = ?");
Impl.Find (Session, Query, Found);
if not Found then
Destroy (Impl);
raise ADO.Objects.NOT_FOUND;
end if;
ADO.Objects.Set_Object (Object, Impl.all'Access);
end Load;
procedure Load (Object : in out Project_Ref;
Session : in out ADO.Sessions.Session'Class;
Id : in ADO.Identifier;
Found : out Boolean) is
Impl : constant Project_Access := new Project_Impl;
Query : ADO.SQL.Query;
begin
Query.Bind_Param (Position => 1, Value => Id);
Query.Set_Filter ("id = ?");
Impl.Find (Session, Query, Found);
if not Found then
Destroy (Impl);
else
ADO.Objects.Set_Object (Object, Impl.all'Access);
end if;
end Load;
procedure Reload (Object : in out Project_Ref;
Session : in out ADO.Sessions.Session'Class;
Updated : out Boolean) is
Result : ADO.Objects.Object_Record_Access;
Impl : Project_Access;
Query : ADO.SQL.Query;
Id : ADO.Identifier;
begin
if Object.Is_Null then
raise ADO.Objects.NULL_ERROR;
end if;
Object.Prepare_Modify (Result);
Impl := Project_Impl (Result.all)'Access;
Id := ADO.Objects.Get_Key_Value (Impl.all);
Query.Bind_Param (Position => 1, Value => Id);
Query.Bind_Param (Position => 2, Value => Impl.Version);
Query.Set_Filter ("id = ? AND version != ?");
declare
Stmt : ADO.Statements.Query_Statement
:= Session.Create_Statement (Query, PROJECT_DEF'Access);
begin
Stmt.Execute;
if Stmt.Has_Elements then
Updated := True;
Impl.Load (Stmt, Session);
else
Updated := False;
end if;
end;
end Reload;
overriding
procedure Save (Object : in out Project_Ref;
Session : in out ADO.Sessions.Master_Session'Class) is
Impl : ADO.Objects.Object_Record_Access := Object.Get_Object;
begin
if Impl = null then
Impl := new Project_Impl;
ADO.Objects.Set_Object (Object, Impl);
end if;
if not ADO.Objects.Is_Created (Impl.all) then
Impl.Create (Session);
else
Impl.Save (Session);
end if;
end Save;
overriding
procedure Delete (Object : in out Project_Ref;
Session : in out ADO.Sessions.Master_Session'Class) is
Impl : constant ADO.Objects.Object_Record_Access := Object.Get_Object;
begin
if Impl /= null then
Impl.Delete (Session);
end if;
end Delete;
-- --------------------
-- Free the object
-- --------------------
overriding
procedure Destroy (Object : access Project_Impl) is
type Project_Impl_Ptr is access all Project_Impl;
procedure Unchecked_Free is new Ada.Unchecked_Deallocation
(Project_Impl, Project_Impl_Ptr);
pragma Warnings (Off, "*redundant conversion*");
Ptr : Project_Impl_Ptr := Project_Impl (Object.all)'Access;
pragma Warnings (On, "*redundant conversion*");
begin
Unchecked_Free (Ptr);
end Destroy;
overriding
procedure Find (Object : in out Project_Impl;
Session : in out ADO.Sessions.Session'Class;
Query : in ADO.SQL.Query'Class;
Found : out Boolean) is
Stmt : ADO.Statements.Query_Statement
:= Session.Create_Statement (Query, PROJECT_DEF'Access);
begin
Stmt.Execute;
if Stmt.Has_Elements then
Object.Load (Stmt, Session);
Stmt.Next;
Found := not Stmt.Has_Elements;
else
Found := False;
end if;
end Find;
overriding
procedure Load (Object : in out Project_Impl;
Session : in out ADO.Sessions.Session'Class) is
Found : Boolean;
Query : ADO.SQL.Query;
Id : constant ADO.Identifier := Object.Get_Key_Value;
begin
Query.Bind_Param (Position => 1, Value => Id);
Query.Set_Filter ("id = ?");
Object.Find (Session, Query, Found);
if not Found then
raise ADO.Objects.NOT_FOUND;
end if;
end Load;
overriding
procedure Save (Object : in out Project_Impl;
Session : in out ADO.Sessions.Master_Session'Class) is
Stmt : ADO.Statements.Update_Statement
:= Session.Create_Statement (PROJECT_DEF'Access);
begin
if Object.Is_Modified (1) then
Stmt.Save_Field (Name => COL_0_1_NAME, -- id
Value => Object.Get_Key);
Object.Clear_Modified (1);
end if;
if Object.Is_Modified (3) then
Stmt.Save_Field (Name => COL_2_1_NAME, -- name
Value => Object.Name);
Object.Clear_Modified (3);
end if;
if Object.Is_Modified (4) then
Stmt.Save_Field (Name => COL_3_1_NAME, -- create_date
Value => Object.Create_Date);
Object.Clear_Modified (4);
end if;
if Object.Is_Modified (5) then
Stmt.Save_Field (Name => COL_4_1_NAME, -- status
Value => Integer (Status_Type'Enum_Rep (Object.Status)));
Object.Clear_Modified (5);
end if;
if Object.Is_Modified (6) then
Stmt.Save_Field (Name => COL_5_1_NAME, -- last_ticket
Value => Object.Last_Ticket);
Object.Clear_Modified (6);
end if;
if Object.Is_Modified (7) then
Stmt.Save_Field (Name => COL_6_1_NAME, -- update_date
Value => Object.Update_Date);
Object.Clear_Modified (7);
end if;
if Object.Is_Modified (8) then
Stmt.Save_Field (Name => COL_7_1_NAME, -- description
Value => Object.Description);
Object.Clear_Modified (8);
end if;
if Object.Is_Modified (9) then
Stmt.Save_Field (Name => COL_8_1_NAME, -- wiki_id
Value => Object.Wiki);
Object.Clear_Modified (9);
end if;
if Object.Is_Modified (10) then
Stmt.Save_Field (Name => COL_9_1_NAME, -- owner_id
Value => Object.Owner);
Object.Clear_Modified (10);
end if;
if Stmt.Has_Save_Fields then
Object.Version := Object.Version + 1;
Stmt.Save_Field (Name => "version",
Value => Object.Version);
Stmt.Set_Filter (Filter => "id = ? and version = ?");
Stmt.Add_Param (Value => Object.Get_Key);
Stmt.Add_Param (Value => Object.Version - 1);
declare
Result : Integer;
begin
Stmt.Execute (Result);
if Result /= 1 then
if Result /= 0 then
raise ADO.Objects.UPDATE_ERROR;
else
raise ADO.Objects.LAZY_LOCK;
end if;
end if;
end;
end if;
end Save;
overriding
procedure Create (Object : in out Project_Impl;
Session : in out ADO.Sessions.Master_Session'Class) is
Query : ADO.Statements.Insert_Statement
:= Session.Create_Statement (PROJECT_DEF'Access);
Result : Integer;
begin
Object.Version := 1;
Session.Allocate (Id => Object);
Query.Save_Field (Name => COL_0_1_NAME, -- id
Value => Object.Get_Key);
Query.Save_Field (Name => COL_1_1_NAME, -- version
Value => Object.Version);
Query.Save_Field (Name => COL_2_1_NAME, -- name
Value => Object.Name);
Query.Save_Field (Name => COL_3_1_NAME, -- create_date
Value => Object.Create_Date);
Query.Save_Field (Name => COL_4_1_NAME, -- status
Value => Integer (Status_Type'Enum_Rep (Object.Status)));
Query.Save_Field (Name => COL_5_1_NAME, -- last_ticket
Value => Object.Last_Ticket);
Query.Save_Field (Name => COL_6_1_NAME, -- update_date
Value => Object.Update_Date);
Query.Save_Field (Name => COL_7_1_NAME, -- description
Value => Object.Description);
Query.Save_Field (Name => COL_8_1_NAME, -- wiki_id
Value => Object.Wiki);
Query.Save_Field (Name => COL_9_1_NAME, -- owner_id
Value => Object.Owner);
Query.Execute (Result);
if Result /= 1 then
raise ADO.Objects.INSERT_ERROR;
end if;
ADO.Objects.Set_Created (Object);
end Create;
overriding
procedure Delete (Object : in out Project_Impl;
Session : in out ADO.Sessions.Master_Session'Class) is
Stmt : ADO.Statements.Delete_Statement
:= Session.Create_Statement (PROJECT_DEF'Access);
begin
Stmt.Set_Filter (Filter => "id = ?");
Stmt.Add_Param (Value => Object.Get_Key);
Stmt.Execute;
end Delete;
-- ------------------------------
-- Get the bean attribute identified by the name.
-- ------------------------------
overriding
function Get_Value (From : in Project_Ref;
Name : in String) return Util.Beans.Objects.Object is
Obj : ADO.Objects.Object_Record_Access;
Impl : access Project_Impl;
begin
if From.Is_Null then
return Util.Beans.Objects.Null_Object;
end if;
Obj := From.Get_Load_Object;
Impl := Project_Impl (Obj.all)'Access;
if Name = "id" then
return ADO.Objects.To_Object (Impl.Get_Key);
elsif Name = "name" then
return Util.Beans.Objects.To_Object (Impl.Name);
elsif Name = "create_date" then
return Util.Beans.Objects.Time.To_Object (Impl.Create_Date);
elsif Name = "status" then
return Status_Type_Objects.To_Object (Impl.Status);
elsif Name = "last_ticket" then
return Util.Beans.Objects.To_Object (Long_Long_Integer (Impl.Last_Ticket));
elsif Name = "update_date" then
return Util.Beans.Objects.Time.To_Object (Impl.Update_Date);
elsif Name = "description" then
return Util.Beans.Objects.To_Object (Impl.Description);
end if;
return Util.Beans.Objects.Null_Object;
end Get_Value;
procedure List (Object : in out Project_Vector;
Session : in out ADO.Sessions.Session'Class;
Query : in ADO.SQL.Query'Class) is
Stmt : ADO.Statements.Query_Statement
:= Session.Create_Statement (Query, PROJECT_DEF'Access);
begin
Stmt.Execute;
Project_Vectors.Clear (Object);
while Stmt.Has_Elements loop
declare
Item : Project_Ref;
Impl : constant Project_Access := new Project_Impl;
begin
Impl.Load (Stmt, Session);
ADO.Objects.Set_Object (Item, Impl.all'Access);
Object.Append (Item);
end;
Stmt.Next;
end loop;
end List;
-- ------------------------------
-- Load the object from current iterator position
-- ------------------------------
procedure Load (Object : in out Project_Impl;
Stmt : in out ADO.Statements.Query_Statement'Class;
Session : in out ADO.Sessions.Session'Class) is
begin
Object.Set_Key_Value (Stmt.Get_Identifier (0));
Object.Name := Stmt.Get_Unbounded_String (2);
Object.Create_Date := Stmt.Get_Time (3);
Object.Status := Status_Type'Enum_Val (Stmt.Get_Integer (4));
Object.Last_Ticket := Stmt.Get_Integer (5);
Object.Update_Date := Stmt.Get_Time (6);
Object.Description := Stmt.Get_Unbounded_String (7);
if not Stmt.Is_Null (8) then
Object.Wiki.Set_Key_Value (Stmt.Get_Identifier (8), Session);
end if;
if not Stmt.Is_Null (9) then
Object.Owner.Set_Key_Value (Stmt.Get_Identifier (9), Session);
end if;
Object.Version := Stmt.Get_Integer (1);
ADO.Objects.Set_Created (Object);
end Load;
function Attribute_Definition_Key (Id : in ADO.Identifier) return ADO.Objects.Object_Key is
Result : ADO.Objects.Object_Key (Of_Type => ADO.Objects.KEY_INTEGER,
Of_Class => ATTRIBUTE_DEFINITION_DEF'Access);
begin
ADO.Objects.Set_Value (Result, Id);
return Result;
end Attribute_Definition_Key;
function Attribute_Definition_Key (Id : in String) return ADO.Objects.Object_Key is
Result : ADO.Objects.Object_Key (Of_Type => ADO.Objects.KEY_INTEGER,
Of_Class => ATTRIBUTE_DEFINITION_DEF'Access);
begin
ADO.Objects.Set_Value (Result, Id);
return Result;
end Attribute_Definition_Key;
function "=" (Left, Right : Attribute_Definition_Ref'Class) return Boolean is
begin
return ADO.Objects.Object_Ref'Class (Left) = ADO.Objects.Object_Ref'Class (Right);
end "=";
procedure Set_Field (Object : in out Attribute_Definition_Ref'Class;
Impl : out Attribute_Definition_Access) is
Result : ADO.Objects.Object_Record_Access;
begin
Object.Prepare_Modify (Result);
Impl := Attribute_Definition_Impl (Result.all)'Access;
end Set_Field;
-- Internal method to allocate the Object_Record instance
overriding
procedure Allocate (Object : in out Attribute_Definition_Ref) is
Impl : Attribute_Definition_Access;
begin
Impl := new Attribute_Definition_Impl;
Impl.Version := 0;
ADO.Objects.Set_Object (Object, Impl.all'Access);
end Allocate;
-- ----------------------------------------
-- Data object: Attribute_Definition
-- ----------------------------------------
procedure Set_Id (Object : in out Attribute_Definition_Ref;
Value : in ADO.Identifier) is
Impl : Attribute_Definition_Access;
begin
Set_Field (Object, Impl);
ADO.Objects.Set_Field_Key_Value (Impl.all, 1, Value);
end Set_Id;
function Get_Id (Object : in Attribute_Definition_Ref)
return ADO.Identifier is
Impl : constant Attribute_Definition_Access
:= Attribute_Definition_Impl (Object.Get_Object.all)'Access;
begin
return Impl.Get_Key_Value;
end Get_Id;
function Get_Version (Object : in Attribute_Definition_Ref)
return Integer is
Impl : constant Attribute_Definition_Access
:= Attribute_Definition_Impl (Object.Get_Load_Object.all)'Access;
begin
return Impl.Version;
end Get_Version;
procedure Set_Name (Object : in out Attribute_Definition_Ref;
Value : in String) is
Impl : Attribute_Definition_Access;
begin
Set_Field (Object, Impl);
ADO.Objects.Set_Field_String (Impl.all, 3, Impl.Name, Value);
end Set_Name;
procedure Set_Name (Object : in out Attribute_Definition_Ref;
Value : in Ada.Strings.Unbounded.Unbounded_String) is
Impl : Attribute_Definition_Access;
begin
Set_Field (Object, Impl);
ADO.Objects.Set_Field_Unbounded_String (Impl.all, 3, Impl.Name, Value);
end Set_Name;
function Get_Name (Object : in Attribute_Definition_Ref)
return String is
begin
return Ada.Strings.Unbounded.To_String (Object.Get_Name);
end Get_Name;
function Get_Name (Object : in Attribute_Definition_Ref)
return Ada.Strings.Unbounded.Unbounded_String is
Impl : constant Attribute_Definition_Access
:= Attribute_Definition_Impl (Object.Get_Load_Object.all)'Access;
begin
return Impl.Name;
end Get_Name;
procedure Set_Default_Value (Object : in out Attribute_Definition_Ref;
Value : in String) is
Impl : Attribute_Definition_Access;
begin
Set_Field (Object, Impl);
ADO.Objects.Set_Field_String (Impl.all, 4, Impl.Default_Value, Value);
end Set_Default_Value;
procedure Set_Default_Value (Object : in out Attribute_Definition_Ref;
Value : in Ada.Strings.Unbounded.Unbounded_String) is
Impl : Attribute_Definition_Access;
begin
Set_Field (Object, Impl);
ADO.Objects.Set_Field_Unbounded_String (Impl.all, 4, Impl.Default_Value, Value);
end Set_Default_Value;
function Get_Default_Value (Object : in Attribute_Definition_Ref)
return String is
begin
return Ada.Strings.Unbounded.To_String (Object.Get_Default_Value);
end Get_Default_Value;
function Get_Default_Value (Object : in Attribute_Definition_Ref)
return Ada.Strings.Unbounded.Unbounded_String is
Impl : constant Attribute_Definition_Access
:= Attribute_Definition_Impl (Object.Get_Load_Object.all)'Access;
begin
return Impl.Default_Value;
end Get_Default_Value;
procedure Set_Project (Object : in out Attribute_Definition_Ref;
Value : in Project_Ref'Class) is
Impl : Attribute_Definition_Access;
begin
Set_Field (Object, Impl);
ADO.Objects.Set_Field_Object (Impl.all, 5, Impl.Project, Value);
end Set_Project;
function Get_Project (Object : in Attribute_Definition_Ref)
return Project_Ref'Class is
Impl : constant Attribute_Definition_Access
:= Attribute_Definition_Impl (Object.Get_Load_Object.all)'Access;
begin
return Impl.Project;
end Get_Project;
-- Copy of the object.
procedure Copy (Object : in Attribute_Definition_Ref;
Into : in out Attribute_Definition_Ref) is
Result : Attribute_Definition_Ref;
begin
if not Object.Is_Null then
declare
Impl : constant Attribute_Definition_Access
:= Attribute_Definition_Impl (Object.Get_Load_Object.all)'Access;
Copy : constant Attribute_Definition_Access
:= new Attribute_Definition_Impl;
begin
ADO.Objects.Set_Object (Result, Copy.all'Access);
Copy.Copy (Impl.all);
Copy.Version := Impl.Version;
Copy.Name := Impl.Name;
Copy.Default_Value := Impl.Default_Value;
Copy.Project := Impl.Project;
end;
end if;
Into := Result;
end Copy;
overriding
procedure Find (Object : in out Attribute_Definition_Ref;
Session : in out ADO.Sessions.Session'Class;
Query : in ADO.SQL.Query'Class;
Found : out Boolean) is
Impl : constant Attribute_Definition_Access := new Attribute_Definition_Impl;
begin
Impl.Find (Session, Query, Found);
if Found then
ADO.Objects.Set_Object (Object, Impl.all'Access);
else
ADO.Objects.Set_Object (Object, null);
Destroy (Impl);
end if;
end Find;
procedure Load (Object : in out Attribute_Definition_Ref;
Session : in out ADO.Sessions.Session'Class;
Id : in ADO.Identifier) is
Impl : constant Attribute_Definition_Access := new Attribute_Definition_Impl;
Found : Boolean;
Query : ADO.SQL.Query;
begin
Query.Bind_Param (Position => 1, Value => Id);
Query.Set_Filter ("id = ?");
Impl.Find (Session, Query, Found);
if not Found then
Destroy (Impl);
raise ADO.Objects.NOT_FOUND;
end if;
ADO.Objects.Set_Object (Object, Impl.all'Access);
end Load;
procedure Load (Object : in out Attribute_Definition_Ref;
Session : in out ADO.Sessions.Session'Class;
Id : in ADO.Identifier;
Found : out Boolean) is
Impl : constant Attribute_Definition_Access := new Attribute_Definition_Impl;
Query : ADO.SQL.Query;
begin
Query.Bind_Param (Position => 1, Value => Id);
Query.Set_Filter ("id = ?");
Impl.Find (Session, Query, Found);
if not Found then
Destroy (Impl);
else
ADO.Objects.Set_Object (Object, Impl.all'Access);
end if;
end Load;
procedure Reload (Object : in out Attribute_Definition_Ref;
Session : in out ADO.Sessions.Session'Class;
Updated : out Boolean) is
Result : ADO.Objects.Object_Record_Access;
Impl : Attribute_Definition_Access;
Query : ADO.SQL.Query;
Id : ADO.Identifier;
begin
if Object.Is_Null then
raise ADO.Objects.NULL_ERROR;
end if;
Object.Prepare_Modify (Result);
Impl := Attribute_Definition_Impl (Result.all)'Access;
Id := ADO.Objects.Get_Key_Value (Impl.all);
Query.Bind_Param (Position => 1, Value => Id);
Query.Bind_Param (Position => 2, Value => Impl.Version);
Query.Set_Filter ("id = ? AND version != ?");
declare
Stmt : ADO.Statements.Query_Statement
:= Session.Create_Statement (Query, ATTRIBUTE_DEFINITION_DEF'Access);
begin
Stmt.Execute;
if Stmt.Has_Elements then
Updated := True;
Impl.Load (Stmt, Session);
else
Updated := False;
end if;
end;
end Reload;
overriding
procedure Save (Object : in out Attribute_Definition_Ref;
Session : in out ADO.Sessions.Master_Session'Class) is
Impl : ADO.Objects.Object_Record_Access := Object.Get_Object;
begin
if Impl = null then
Impl := new Attribute_Definition_Impl;
ADO.Objects.Set_Object (Object, Impl);
end if;
if not ADO.Objects.Is_Created (Impl.all) then
Impl.Create (Session);
else
Impl.Save (Session);
end if;
end Save;
overriding
procedure Delete (Object : in out Attribute_Definition_Ref;
Session : in out ADO.Sessions.Master_Session'Class) is
Impl : constant ADO.Objects.Object_Record_Access := Object.Get_Object;
begin
if Impl /= null then
Impl.Delete (Session);
end if;
end Delete;
-- --------------------
-- Free the object
-- --------------------
overriding
procedure Destroy (Object : access Attribute_Definition_Impl) is
type Attribute_Definition_Impl_Ptr is access all Attribute_Definition_Impl;
procedure Unchecked_Free is new Ada.Unchecked_Deallocation
(Attribute_Definition_Impl, Attribute_Definition_Impl_Ptr);
pragma Warnings (Off, "*redundant conversion*");
Ptr : Attribute_Definition_Impl_Ptr := Attribute_Definition_Impl (Object.all)'Access;
pragma Warnings (On, "*redundant conversion*");
begin
Unchecked_Free (Ptr);
end Destroy;
overriding
procedure Find (Object : in out Attribute_Definition_Impl;
Session : in out ADO.Sessions.Session'Class;
Query : in ADO.SQL.Query'Class;
Found : out Boolean) is
Stmt : ADO.Statements.Query_Statement
:= Session.Create_Statement (Query, ATTRIBUTE_DEFINITION_DEF'Access);
begin
Stmt.Execute;
if Stmt.Has_Elements then
Object.Load (Stmt, Session);
Stmt.Next;
Found := not Stmt.Has_Elements;
else
Found := False;
end if;
end Find;
overriding
procedure Load (Object : in out Attribute_Definition_Impl;
Session : in out ADO.Sessions.Session'Class) is
Found : Boolean;
Query : ADO.SQL.Query;
Id : constant ADO.Identifier := Object.Get_Key_Value;
begin
Query.Bind_Param (Position => 1, Value => Id);
Query.Set_Filter ("id = ?");
Object.Find (Session, Query, Found);
if not Found then
raise ADO.Objects.NOT_FOUND;
end if;
end Load;
overriding
procedure Save (Object : in out Attribute_Definition_Impl;
Session : in out ADO.Sessions.Master_Session'Class) is
Stmt : ADO.Statements.Update_Statement
:= Session.Create_Statement (ATTRIBUTE_DEFINITION_DEF'Access);
begin
if Object.Is_Modified (1) then
Stmt.Save_Field (Name => COL_0_2_NAME, -- id
Value => Object.Get_Key);
Object.Clear_Modified (1);
end if;
if Object.Is_Modified (3) then
Stmt.Save_Field (Name => COL_2_2_NAME, -- name
Value => Object.Name);
Object.Clear_Modified (3);
end if;
if Object.Is_Modified (4) then
Stmt.Save_Field (Name => COL_3_2_NAME, -- default_value
Value => Object.Default_Value);
Object.Clear_Modified (4);
end if;
if Object.Is_Modified (5) then
Stmt.Save_Field (Name => COL_4_2_NAME, -- project_id
Value => Object.Project);
Object.Clear_Modified (5);
end if;
if Stmt.Has_Save_Fields then
Object.Version := Object.Version + 1;
Stmt.Save_Field (Name => "version",
Value => Object.Version);
Stmt.Set_Filter (Filter => "id = ? and version = ?");
Stmt.Add_Param (Value => Object.Get_Key);
Stmt.Add_Param (Value => Object.Version - 1);
declare
Result : Integer;
begin
Stmt.Execute (Result);
if Result /= 1 then
if Result /= 0 then
raise ADO.Objects.UPDATE_ERROR;
else
raise ADO.Objects.LAZY_LOCK;
end if;
end if;
end;
end if;
end Save;
overriding
procedure Create (Object : in out Attribute_Definition_Impl;
Session : in out ADO.Sessions.Master_Session'Class) is
Query : ADO.Statements.Insert_Statement
:= Session.Create_Statement (ATTRIBUTE_DEFINITION_DEF'Access);
Result : Integer;
begin
Object.Version := 1;
Session.Allocate (Id => Object);
Query.Save_Field (Name => COL_0_2_NAME, -- id
Value => Object.Get_Key);
Query.Save_Field (Name => COL_1_2_NAME, -- version
Value => Object.Version);
Query.Save_Field (Name => COL_2_2_NAME, -- name
Value => Object.Name);
Query.Save_Field (Name => COL_3_2_NAME, -- default_value
Value => Object.Default_Value);
Query.Save_Field (Name => COL_4_2_NAME, -- project_id
Value => Object.Project);
Query.Execute (Result);
if Result /= 1 then
raise ADO.Objects.INSERT_ERROR;
end if;
ADO.Objects.Set_Created (Object);
end Create;
overriding
procedure Delete (Object : in out Attribute_Definition_Impl;
Session : in out ADO.Sessions.Master_Session'Class) is
Stmt : ADO.Statements.Delete_Statement
:= Session.Create_Statement (ATTRIBUTE_DEFINITION_DEF'Access);
begin
Stmt.Set_Filter (Filter => "id = ?");
Stmt.Add_Param (Value => Object.Get_Key);
Stmt.Execute;
end Delete;
-- ------------------------------
-- Get the bean attribute identified by the name.
-- ------------------------------
overriding
function Get_Value (From : in Attribute_Definition_Ref;
Name : in String) return Util.Beans.Objects.Object is
Obj : ADO.Objects.Object_Record_Access;
Impl : access Attribute_Definition_Impl;
begin
if From.Is_Null then
return Util.Beans.Objects.Null_Object;
end if;
Obj := From.Get_Load_Object;
Impl := Attribute_Definition_Impl (Obj.all)'Access;
if Name = "id" then
return ADO.Objects.To_Object (Impl.Get_Key);
elsif Name = "name" then
return Util.Beans.Objects.To_Object (Impl.Name);
elsif Name = "default_value" then
return Util.Beans.Objects.To_Object (Impl.Default_Value);
end if;
return Util.Beans.Objects.Null_Object;
end Get_Value;
procedure List (Object : in out Attribute_Definition_Vector;
Session : in out ADO.Sessions.Session'Class;
Query : in ADO.SQL.Query'Class) is
Stmt : ADO.Statements.Query_Statement
:= Session.Create_Statement (Query, ATTRIBUTE_DEFINITION_DEF'Access);
begin
Stmt.Execute;
Attribute_Definition_Vectors.Clear (Object);
while Stmt.Has_Elements loop
declare
Item : Attribute_Definition_Ref;
Impl : constant Attribute_Definition_Access := new Attribute_Definition_Impl;
begin
Impl.Load (Stmt, Session);
ADO.Objects.Set_Object (Item, Impl.all'Access);
Object.Append (Item);
end;
Stmt.Next;
end loop;
end List;
-- ------------------------------
-- Load the object from current iterator position
-- ------------------------------
procedure Load (Object : in out Attribute_Definition_Impl;
Stmt : in out ADO.Statements.Query_Statement'Class;
Session : in out ADO.Sessions.Session'Class) is
begin
Object.Set_Key_Value (Stmt.Get_Identifier (0));
Object.Name := Stmt.Get_Unbounded_String (2);
Object.Default_Value := Stmt.Get_Unbounded_String (3);
if not Stmt.Is_Null (4) then
Object.Project.Set_Key_Value (Stmt.Get_Identifier (4), Session);
end if;
Object.Version := Stmt.Get_Integer (1);
ADO.Objects.Set_Created (Object);
end Load;
-- ------------------------------
-- Get the bean attribute identified by the name.
-- ------------------------------
overriding
function Get_Value (From : in List_Info;
Name : in String) return Util.Beans.Objects.Object is
begin
if Name = "id" then
return Util.Beans.Objects.To_Object (Long_Long_Integer (From.Id));
elsif Name = "title" then
return Util.Beans.Objects.To_Object (From.Title);
elsif Name = "status" then
return Status_Type_Objects.To_Object (From.Status);
elsif Name = "create_date" then
return Util.Beans.Objects.Time.To_Object (From.Create_Date);
elsif Name = "total_duration" then
return Util.Beans.Objects.To_Object (Long_Long_Integer (From.Total_Duration));
elsif Name = "total_done" then
return Util.Beans.Objects.To_Object (From.Total_Done);
elsif Name = "close_count" then
return Util.Beans.Objects.To_Object (Long_Long_Integer (From.Close_Count));
elsif Name = "open_count" then
return Util.Beans.Objects.To_Object (Long_Long_Integer (From.Open_Count));
end if;
return Util.Beans.Objects.Null_Object;
end Get_Value;
-- ------------------------------
-- Set the value identified by the name
-- ------------------------------
overriding
procedure Set_Value (Item : in out List_Info;
Name : in String;
Value : in Util.Beans.Objects.Object) is
begin
if Name = "id" then
Item.Id := ADO.Identifier (Util.Beans.Objects.To_Long_Long_Integer (Value));
elsif Name = "title" then
Item.Title := Util.Beans.Objects.To_Unbounded_String (Value);
elsif Name = "status" then
Item.Status := Status_Type_Objects.To_Value (Value);
elsif Name = "create_date" then
Item.Create_Date := Util.Beans.Objects.Time.To_Time (Value);
elsif Name = "total_duration" then
Item.Total_Duration := Util.Beans.Objects.To_Integer (Value);
elsif Name = "total_done" then
Item.Total_Done := Util.Beans.Objects.To_Float (Value);
elsif Name = "close_count" then
Item.Close_Count := Util.Beans.Objects.To_Integer (Value);
elsif Name = "open_count" then
Item.Open_Count := Util.Beans.Objects.To_Integer (Value);
end if;
end Set_Value;
-- --------------------
-- Run the query controlled by <b>Context</b> and append the list in <b>Object</b>.
-- --------------------
procedure List (Object : in out List_Info_List_Bean'Class;
Session : in out ADO.Sessions.Session'Class;
Context : in out ADO.Queries.Context'Class) is
begin
List (Object.List, Session, Context);
end List;
-- --------------------
-- The list of projects.
-- --------------------
procedure List (Object : in out List_Info_Vector;
Session : in out ADO.Sessions.Session'Class;
Context : in out ADO.Queries.Context'Class) is
procedure Read (Into : in out List_Info);
Stmt : ADO.Statements.Query_Statement
:= Session.Create_Statement (Context);
Pos : Positive := 1;
procedure Read (Into : in out List_Info) is
begin
Into.Id := Stmt.Get_Identifier (0);
Into.Title := Stmt.Get_Unbounded_String (1);
Into.Status := Status_Type'Enum_Val (Stmt.Get_Integer (2));
Into.Create_Date := Stmt.Get_Time (3);
Into.Total_Duration := Stmt.Get_Natural (4);
Into.Total_Done := Stmt.Get_Float (5);
Into.Close_Count := Stmt.Get_Natural (6);
Into.Open_Count := Stmt.Get_Natural (7);
end Read;
begin
Stmt.Execute;
List_Info_Vectors.Clear (Object);
while Stmt.Has_Elements loop
Object.Insert_Space (Before => Pos);
Object.Update_Element (Index => Pos, Process => Read'Access);
Pos := Pos + 1;
Stmt.Next;
end loop;
end List;
procedure Op_Load (Bean : in out Project_Bean;
Outcome : in out Ada.Strings.Unbounded.Unbounded_String);
procedure Op_Load (Bean : in out Project_Bean;
Outcome : in out Ada.Strings.Unbounded.Unbounded_String) is
begin
Project_Bean'Class (Bean).Load (Outcome);
end Op_Load;
package Binding_Project_Bean_1 is
new ASF.Events.Faces.Actions.Action_Method.Bind (Bean => Project_Bean,
Method => Op_Load,
Name => "load");
procedure Op_Create (Bean : in out Project_Bean;
Outcome : in out Ada.Strings.Unbounded.Unbounded_String);
procedure Op_Create (Bean : in out Project_Bean;
Outcome : in out Ada.Strings.Unbounded.Unbounded_String) is
begin
Project_Bean'Class (Bean).Create (Outcome);
end Op_Create;
package Binding_Project_Bean_2 is
new ASF.Events.Faces.Actions.Action_Method.Bind (Bean => Project_Bean,
Method => Op_Create,
Name => "create");
procedure Op_Save (Bean : in out Project_Bean;
Outcome : in out Ada.Strings.Unbounded.Unbounded_String);
procedure Op_Save (Bean : in out Project_Bean;
Outcome : in out Ada.Strings.Unbounded.Unbounded_String) is
begin
Project_Bean'Class (Bean).Save (Outcome);
end Op_Save;
package Binding_Project_Bean_3 is
new ASF.Events.Faces.Actions.Action_Method.Bind (Bean => Project_Bean,
Method => Op_Save,
Name => "save");
procedure Op_Create_Wiki (Bean : in out Project_Bean;
Outcome : in out Ada.Strings.Unbounded.Unbounded_String);
procedure Op_Create_Wiki (Bean : in out Project_Bean;
Outcome : in out Ada.Strings.Unbounded.Unbounded_String) is
begin
Project_Bean'Class (Bean).Create_Wiki (Outcome);
end Op_Create_Wiki;
package Binding_Project_Bean_4 is
new ASF.Events.Faces.Actions.Action_Method.Bind (Bean => Project_Bean,
Method => Op_Create_Wiki,
Name => "create_wiki");
procedure Op_Load_Wiki (Bean : in out Project_Bean;
Outcome : in out Ada.Strings.Unbounded.Unbounded_String);
procedure Op_Load_Wiki (Bean : in out Project_Bean;
Outcome : in out Ada.Strings.Unbounded.Unbounded_String) is
begin
Project_Bean'Class (Bean).Load_Wiki (Outcome);
end Op_Load_Wiki;
package Binding_Project_Bean_5 is
new ASF.Events.Faces.Actions.Action_Method.Bind (Bean => Project_Bean,
Method => Op_Load_Wiki,
Name => "load_wiki");
Binding_Project_Bean_Array : aliased constant Util.Beans.Methods.Method_Binding_Array
:= (1 => Binding_Project_Bean_1.Proxy'Access,
2 => Binding_Project_Bean_2.Proxy'Access,
3 => Binding_Project_Bean_3.Proxy'Access,
4 => Binding_Project_Bean_4.Proxy'Access,
5 => Binding_Project_Bean_5.Proxy'Access
);
-- ------------------------------
-- This bean provides some methods that can be used in a Method_Expression.
-- ------------------------------
overriding
function Get_Method_Bindings (From : in Project_Bean)
return Util.Beans.Methods.Method_Binding_Array_Access is
pragma Unreferenced (From);
begin
return Binding_Project_Bean_Array'Access;
end Get_Method_Bindings;
-- ------------------------------
-- Set the value identified by the name
-- ------------------------------
overriding
procedure Set_Value (Item : in out Project_Bean;
Name : in String;
Value : in Util.Beans.Objects.Object) is
begin
if Name = "name" then
Item.Set_Name (Util.Beans.Objects.To_String (Value));
elsif Name = "create_date" then
Item.Set_Create_Date (Util.Beans.Objects.Time.To_Time (Value));
elsif Name = "status" then
Item.Set_Status (Status_Type_Objects.To_Value (Value));
elsif Name = "last_ticket" then
Item.Set_Last_Ticket (Util.Beans.Objects.To_Integer (Value));
elsif Name = "update_date" then
Item.Set_Update_Date (Util.Beans.Objects.Time.To_Time (Value));
elsif Name = "description" then
Item.Set_Description (Util.Beans.Objects.To_String (Value));
end if;
end Set_Value;
procedure Op_Load (Bean : in out Project_List_Bean;
Outcome : in out Ada.Strings.Unbounded.Unbounded_String);
procedure Op_Load (Bean : in out Project_List_Bean;
Outcome : in out Ada.Strings.Unbounded.Unbounded_String) is
begin
Project_List_Bean'Class (Bean).Load (Outcome);
end Op_Load;
package Binding_Project_List_Bean_1 is
new ASF.Events.Faces.Actions.Action_Method.Bind (Bean => Project_List_Bean,
Method => Op_Load,
Name => "load");
Binding_Project_List_Bean_Array : aliased constant Util.Beans.Methods.Method_Binding_Array
:= (1 => Binding_Project_List_Bean_1.Proxy'Access
);
-- ------------------------------
-- This bean provides some methods that can be used in a Method_Expression.
-- ------------------------------
overriding
function Get_Method_Bindings (From : in Project_List_Bean)
return Util.Beans.Methods.Method_Binding_Array_Access is
pragma Unreferenced (From);
begin
return Binding_Project_List_Bean_Array'Access;
end Get_Method_Bindings;
-- ------------------------------
-- Get the bean attribute identified by the name.
-- ------------------------------
overriding
function Get_Value (From : in Project_List_Bean;
Name : in String) return Util.Beans.Objects.Object is
begin
if Name = "page" then
return Util.Beans.Objects.To_Object (Long_Long_Integer (From.Page));
elsif Name = "page_size" then
return Util.Beans.Objects.To_Object (Long_Long_Integer (From.Page_Size));
elsif Name = "count" then
return Util.Beans.Objects.To_Object (Long_Long_Integer (From.Count));
elsif Name = "tag" then
return Util.Beans.Objects.To_Object (From.Tag);
end if;
return Util.Beans.Objects.Null_Object;
end Get_Value;
-- ------------------------------
-- Set the value identified by the name
-- ------------------------------
overriding
procedure Set_Value (Item : in out Project_List_Bean;
Name : in String;
Value : in Util.Beans.Objects.Object) is
begin
if Name = "page" then
Item.Page := Util.Beans.Objects.To_Integer (Value);
elsif Name = "page_size" then
Item.Page_Size := Util.Beans.Objects.To_Integer (Value);
elsif Name = "count" then
Item.Count := Util.Beans.Objects.To_Integer (Value);
elsif Name = "tag" then
Item.Tag := Util.Beans.Objects.To_Unbounded_String (Value);
end if;
end Set_Value;
end Jason.Projects.Models;
|
RREE/ada-util | Ada | 3,258 | adb | -----------------------------------------------------------------------
-- lzma_decrypt -- Decrypt and decompress file using Util.Streams.AES
-- Copyright (C) 2019, 2021 Stephane Carrez
-- Written by Stephane Carrez ([email protected])
--
-- Licensed under the Apache License, Version 2.0 (the "License");
-- you may not use this file except in compliance with the License.
-- You may obtain a copy of the License at
--
-- http://www.apache.org/licenses/LICENSE-2.0
--
-- Unless required by applicable law or agreed to in writing, software
-- distributed under the License is distributed on an "AS IS" BASIS,
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-- See the License for the specific language governing permissions and
-- limitations under the License.
-----------------------------------------------------------------------
with Ada.Text_IO;
with Ada.Command_Line;
with Ada.Streams.Stream_IO;
with Util.Streams.Files;
with Util.Streams.AES;
with Util.Streams.Buffered.Lzma;
with Util.Encoders.AES;
with Util.Encoders.KDF.PBKDF2_HMAC_SHA256;
procedure Lzma_Decrypt is
use Util.Encoders.KDF;
procedure Decrypt_File (Source : in String;
Destination : in String;
Password : in String);
procedure Decrypt_File (Source : in String;
Destination : in String;
Password : in String) is
In_Stream : aliased Util.Streams.Files.File_Stream;
Out_Stream : aliased Util.Streams.Files.File_Stream;
Decompress : aliased Util.Streams.Buffered.Lzma.Decompress_Stream;
Decipher : aliased Util.Streams.AES.Decoding_Stream;
Password_Key : constant Util.Encoders.Secret_Key := Util.Encoders.Create (Password);
Salt : constant Util.Encoders.Secret_Key := Util.Encoders.Create ("fake-salt");
Key : Util.Encoders.Secret_Key (Length => Util.Encoders.AES.AES_256_Length);
begin
-- Generate a derived key from the password.
PBKDF2_HMAC_SHA256 (Password => Password_Key,
Salt => Salt,
Counter => 20000,
Result => Key);
-- Setup file -> input and cipher -> output file streams.
In_Stream.Open (Ada.Streams.Stream_IO.In_File, Source);
Out_Stream.Create (Mode => Ada.Streams.Stream_IO.Out_File, Name => Destination);
Decipher.Consumes (Input => In_Stream'Access, Size => 32768);
Decipher.Set_Key (Secret => Key, Mode => Util.Encoders.AES.ECB);
Decompress.Initialize (Input => Decipher'Access, Size => 32768);
-- Copy input to output through the cipher.
Util.Streams.Copy (From => Decompress, Into => Out_Stream);
end Decrypt_File;
begin
if Ada.Command_Line.Argument_Count /= 3 then
Ada.Text_IO.Put_Line ("Usage: decrypt source password destination");
return;
end if;
Decrypt_File (Source => Ada.Command_Line.Argument (1),
Destination => Ada.Command_Line.Argument (3),
Password => Ada.Command_Line.Argument (2));
end Lzma_Decrypt;
|
AdaCore/ada-traits-containers | Ada | 2,078 | ads | --
-- Copyright (C) 2015-2016, AdaCore
--
-- SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
--
-- Unbounded lists of unconstrained elements.
-- Cursors are indexes into an array, to be able to write post-conditions
-- and for added safety
pragma Ada_2012;
with Conts.Elements.Indefinite_SPARK;
with Conts.Lists.Storage.Unbounded_SPARK;
with Conts.Lists.Generics;
with Conts.Properties.SPARK;
generic
type Element_Type (<>) is private;
-- Element_Type must not be a controlled type that needs to be
-- Adjusted when it is moved in memory, since the list will use the
-- realloc() system call.
package Conts.Lists.Indefinite_Unbounded_SPARK with SPARK_Mode is
pragma Assertion_Policy
(Pre => Suppressible, Ghost => Suppressible, Post => Ignore);
package Elements is new Conts.Elements.Indefinite_SPARK
(Element_Type, Pool => Conts.Global_Pool);
package Storage is new Conts.Lists.Storage.Unbounded_SPARK
(Elements => Elements.Traits,
Container_Base_Type => Limited_Base);
package Lists is new Conts.Lists.Generics (Storage.Traits);
subtype Constant_Returned is Elements.Traits.Constant_Returned;
subtype Cursor is Lists.Cursor;
subtype List is Lists.List;
subtype Element_Sequence is Lists.Impl.M.Sequence with Ghost;
subtype Cursor_Position_Map is Lists.Impl.P_Map with Ghost;
use type Element_Sequence;
function Copy (Self : List'Class) return List'Class;
-- Return a deep copy of Self
-- Complexity: O(n)
package Cursors renames Lists.Cursors;
package Maps renames Lists.Maps;
package Content_Models is new Conts.Properties.SPARK.Content_Models
(Map_Type => Lists.Base_List'Class,
Element_Type => Element_Type,
Model_Type => Element_Sequence,
Index_Type => Lists.Impl.M.Extended_Index,
Model => Lists.Impl.Model,
Get => Lists.Impl.M.Get,
First => Lists.Impl.M.First,
Last => Lists.Impl.M.Last);
end Conts.Lists.Indefinite_Unbounded_SPARK;
|
AdaCore/libadalang | Ada | 34 | ads | generic
package Pkg6 is
end Pkg6;
|
frett27/Ada-Synthetizer | Ada | 7,620 | adb | -- The Beer-Ware License (revision 42)
--
-- Jacob Sparre Andersen <[email protected]> wrote this. As long as you
-- retain this notice you can do whatever you want with this stuff. If we meet
-- some day, and you think this stuff is worth it, you can buy me a beer in
-- return.
--
-- Jacob Sparre Andersen
with
Interfaces.C.Strings;
package body Sound.Stereo_Recording is
procedure Close (Line : in out Line_Type) is
use type Interfaces.C.int;
Error : Interfaces.C.int;
begin
Error := snd_pcm_close (Line);
if Error /= 0 then
raise Program_Error with "snd_pcm_close failed: " & Error'Img;
end if;
end Close;
function Is_Open (Line : in Line_Type) return Boolean is
use Sound.ALSA;
begin
case snd_pcm_state (Line) is
when Prepared | Running =>
return True;
when Open | Setup | XRun | Draining | Paused | Suspended
| Disconnected =>
return False;
end case;
end Is_Open;
procedure Open (Line : in out Line_Type;
Resolution : in out Sample_Frequency;
Buffer_Size : in out Duration;
Period : in out Duration) is
use Interfaces.C, Interfaces.C.Strings, Sound.ALSA;
Name : aliased char_array := To_C ("plughw:0,0");
Error : Interfaces.C.int;
Local_Line : aliased Line_Type := Line;
Settings : aliased Sound.ALSA.snd_pcm_hw_params_t;
begin
Error := snd_pcm_open (pcmp => Local_Line'Access,
name => To_Chars_Ptr (Name'Unchecked_Access),
stream => Sound.ALSA.Capture,
mode => 0);
if Error /= 0 then
raise Program_Error with "Error code (snd_pcm_open): " & Error'Img;
end if;
Clear_Settings :
begin
Error := snd_pcm_hw_params_any (pcm => Local_Line,
params => Settings'Access);
if Error /= 0 then
raise Program_Error with
"Error code (snd_pcm_hw_params_any): " & Error'Img;
end if;
end Clear_Settings;
Set_Resampling_Rate :
begin
Error := snd_pcm_hw_params_set_rate_resample
(pcm => Local_Line,
params => Settings'Access,
val => False);
if Error /= 0 then
raise Program_Error with
"Error code (snd_pcm_hw_params_set_rate_resample): " & Error'Img;
end if;
end Set_Resampling_Rate;
Set_Sampling_Layout :
begin
Error := snd_pcm_hw_params_set_access
(pcm => Local_Line,
params => Settings'Access,
val => Read_Write_Interleaved);
if Error /= 0 then
raise Program_Error with
"Error code (snd_pcm_hw_params_set_access): " & Error'Img;
end if;
end Set_Sampling_Layout;
Set_Recording_Format :
begin
Error := snd_pcm_hw_params_set_format
(pcm => Local_Line,
params => Settings'Access,
format => Sound.ALSA.Signed_16_Bit);
if Error /= 0 then
raise Program_Error with
"Error code (snd_pcm_hw_params_set_format): " & Error'Img;
end if;
end Set_Recording_Format;
Set_Channel_Count :
begin
Error := snd_pcm_hw_params_set_channels
(pcm => Local_Line,
params => Settings'Access,
val => 2);
if Error /= 0 then
raise Program_Error with
"Error code (snd_pcm_hw_params_set_channels): " & Error'Img;
end if;
end Set_Channel_Count;
Set_Sample_Frequency :
declare
Sample_Rate : aliased Interfaces.C.unsigned :=
Interfaces.C.unsigned (Resolution);
Approximation : aliased Sound.ALSA.Approximation_Direction := +1;
begin
Error := snd_pcm_hw_params_set_rate_near
(pcm => Local_Line,
params => Settings'Access,
val => Sample_Rate'Access,
dir => Approximation'Access);
if Error /= 0 then
raise Program_Error with
"Error code (snd_pcm_hw_params_set_rate_near): " & Error'Img;
end if;
Resolution := Sample_Frequency (Sample_Rate);
end Set_Sample_Frequency;
Set_Buffer_Time :
declare
Buffer_Time : aliased Interfaces.C.unsigned :=
Interfaces.C.unsigned (1_000_000 * Buffer_Size);
Approximation : aliased Sound.ALSA.Approximation_Direction := +1;
begin
Error := snd_pcm_hw_params_set_buffer_time_near
(pcm => Local_Line,
params => Settings'Access,
val => Buffer_Time'Access,
dir => Approximation'Access);
if Error /= 0 then
raise Program_Error with
"Error code (snd_pcm_hw_params_set_buffer_time_near): " &
Error'Img;
end if;
Buffer_Size := Duration (Buffer_Time) / 1_000_000.0;
end Set_Buffer_Time;
Set_Period :
declare
Period_Time : aliased Interfaces.C.unsigned :=
Interfaces.C.unsigned (1_000_000 * Period);
Approximation : aliased Sound.ALSA.Approximation_Direction := +1;
begin
Error := snd_pcm_hw_params_set_period_time_near
(pcm => Local_Line,
params => Settings'Access,
val => Period_Time'Access,
dir => Approximation'Access);
if Error /= 0 then
raise Program_Error with
"Error code (snd_pcm_hw_params_set_period_time_near): " &
Error'Img;
end if;
Period := Duration (Period_Time) / 1_000_000.0;
end Set_Period;
Register_Settings :
begin
Error := snd_pcm_hw_params (pcm => Local_Line,
params => Settings'Access);
if Error /= 0 then
raise Program_Error with
"Error code (snd_pcm_hw_params): " & Error'Img;
end if;
end Register_Settings;
Line := Local_Line;
end Open;
procedure Read (Line : in Line_Type;
Item : out Frame_Array;
Last : out Natural) is
pragma Unmodified (Item); -- As we cheat with "function snd_pcm_readi".
function snd_pcm_readi (pcm : in Line_Type;
buffer : in Frame_Array; -- actually "out"
size : in ALSA.snd_pcm_uframes_t)
return ALSA.snd_pcm_sframes_t;
pragma Import (C, snd_pcm_readi);
use type Sound.ALSA.snd_pcm_sframes_t;
Received_Frame_Count : Sound.ALSA.snd_pcm_sframes_t;
begin
Received_Frame_Count := snd_pcm_readi
(pcm => Line,
buffer => Item,
size => Item'Length);
if Received_Frame_Count < 0 then
raise Program_Error with
"snd_pcm_readi failed: " & Received_Frame_Count'Img;
else
Last := Item'First - 1 + Natural (Received_Frame_Count);
end if;
end Read;
end Sound.Stereo_Recording;
|
zhmu/ananas | Ada | 2,534 | adb | ------------------------------------------------------------------------------
-- --
-- GNAT COMPILER COMPONENTS --
-- --
-- G N A T . A L T I V E C . L O W _ L E V E L _ V E C T O R S --
-- --
-- B o d y --
-- (Hard Binding Version) --
-- --
-- Copyright (C) 2004-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. --
-- --
------------------------------------------------------------------------------
package body GNAT.Altivec.Low_Level_Vectors is
end GNAT.Altivec.Low_Level_Vectors;
|
AdaCore/training_material | Ada | 1,328 | adb | with Ada.Wide_Wide_Text_IO;
package body Drawable_Chars.Tests is
procedure Test_By_Black_Ratio (TC : Test_Case_T'Class) is
C : Drawable_Charset_T := (+".", +" ");
Charac : Drawable_Char_Caracteristics_List_T := (1, 0);
SC : Sorted_Charset_T := Sort_By (C, Charac);
use Chars_Sorted_By_Characteristic_Pkg;
It : Cursor := SC.First;
begin
pragma Assert (Element (It).Char.all = " ");
It := Next (It);
pragma Assert (Element (It).Char.all = ".");
end Test_By_Black_Ratio;
procedure Test_Identical_Values (TC : Test_Case_T'Class) is
By_Height : Sorted_Charset_T := Sort_By ((+"-", +"+"), (0, 0));
begin
null;
end Test_Identical_Values;
procedure Test_Closest_By_Height (TC : Test_Case_T'Class) is
C : Drawable_Charset_T := (+".", +"-", +"_", +"'");
Height : Drawable_Char_Caracteristics_List_T := (-1, 0, -5, 1);
By_Height : Sorted_Charset_T := Sort_By (C, Height);
use Chars_Sorted_By_Characteristic_Pkg;
begin
pragma Assert (Image (Closest (By_Height, 0)) = "-");
pragma Assert (Image (Closest (By_Height, -2)) = ".");
pragma Assert (Image (Closest (By_Height, -4)) = "_");
pragma Assert (Image (Closest (By_Height, 2)) = "'");
end Test_Closest_By_Height;
end Drawable_Chars.Tests;
|
Ximalas/synth | Ada | 1,587 | ads | -- This file is covered by the Internet Software Consortium (ISC) License
-- Reference: ../License.txt
package Definitions is
pragma Pure;
synth_version_major : constant String := "2";
synth_version_minor : constant String := "05";
copyright_years : constant String := "2015-2018";
host_localbase : constant String := "/usr/local";
host_make : constant String := "/usr/bin/make";
host_pkg8 : constant String := host_localbase & "/sbin/pkg";
host_bmake : constant String := host_localbase & "/bin/bmake";
host_make_program : constant String := host_make;
chroot_make : constant String := "/usr/bin/make";
chroot_bmake : constant String := "/usr/pkg/bin/bmake -m /usr/pkg/share/mk";
chroot_make_program : constant String := chroot_make;
jobs_per_cpu : constant := 2;
type cpu_range is range 1 .. 32;
type scanners is range cpu_range'First .. cpu_range'Last;
type builders is range cpu_range'First .. cpu_range'Last * jobs_per_cpu;
type package_system is (ports_collection, pkgsrc);
software_framework : constant package_system := ports_collection;
-- Notes for tailoring Synth. Use sed to:
-- 1. Modify host_localbase to value of LOCALBASE
-- 2. Change software_framework to "pkgsrc" for pkgsrc version
-- 3. Change host_make_program to "host_bmake" for Non-NetBSD pkgsrc platforms
-- 4. Change chroot_make_program to "chroot_bmake" for pkgsrc version
-- 5. On replicant.ads, change "/usr/local" to "/usr/pkg" on pkgsrc
end Definitions;
|
danieagle/ASAP-Modular_Hashing | Ada | 5,618 | ads | ------------------------------------------------------------------------------
-- --
-- Modular Hash Infrastructure --
-- --
-- SHA1 --
-- --
-- ------------------------------------------------------------------------ --
-- --
-- Copyright (C) 2018-2021, ANNEXI-STRAYLINE Trans-Human Ltd. --
-- All rights reserved. --
-- --
-- Original Contributors: --
-- * Ensi Martini (ANNEXI-STRAYLINE) --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions are --
-- met: --
-- --
-- * Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- --
-- * Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in --
-- the documentation and/or other materials provided with the --
-- distribution. --
-- --
-- * Neither the name of the copyright holder nor the names of its --
-- contributors may be used to endorse or promote products derived --
-- from this software without specific prior written permission. --
-- --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A --
-- PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
-- OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT --
-- LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, --
-- DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY --
-- THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT --
-- (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE --
-- OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
-- --
------------------------------------------------------------------------------
with Interfaces;
with Ada.Streams;
package Modular_Hashing.SHA1 is
type SHA1_Hash is new Hash with private;
-- The final hash is a 160-bit message digest, which can also be displayed
-- as a 40 character hex string and is 20 bytes long
overriding function "<" (Left, Right : SHA1_Hash) return Boolean;
overriding function ">" (Left, Right : SHA1_Hash) return Boolean;
overriding function "=" (Left, Right : SHA1_Hash) return Boolean;
SHA1_Hash_Bytes: constant := 20;
overriding function Binary_Bytes (Value: SHA1_Hash) return Positive is
(SHA1_Hash_Bytes);
overriding function Binary (Value: SHA1_Hash) return Hash_Binary_Value with
Post => Binary'Result'Length = SHA1_Hash_Bytes;
type SHA1_Engine is new Hash_Algorithm with private;
overriding
procedure Write (Stream : in out SHA1_Engine;
Item : in Ada.Streams.Stream_Element_Array);
overriding procedure Reset (Engine : in out SHA1_Engine);
overriding function Digest (Engine : in out SHA1_Engine)
return Hash'Class;
private
use Ada.Streams, Interfaces;
type Message_Digest is array (1 .. 5) of Unsigned_32;
type SHA1_Hash is new Hash with
record
Digest: Message_Digest;
end record;
-----------------
-- SHA1_Engine --
-----------------
-- SHA-1 Defined initialization constants
H0_Initial: constant := 16#67452301#;
H1_Initial: constant := 16#EFCDAB89#;
H2_Initial: constant := 16#98BADCFE#;
H3_Initial: constant := 16#10325476#;
H4_Initial: constant := 16#C3D2E1F0#;
type SHA1_Engine is new Hash_Algorithm with record
Last_Element_Index : Stream_Element_Offset := 0;
Buffer : Stream_Element_Array(1 .. 64);
Message_Length : Unsigned_64 := 0;
H0 : Unsigned_32 := H0_Initial;
H1 : Unsigned_32 := H1_Initial;
H2 : Unsigned_32 := H2_Initial;
H3 : Unsigned_32 := H3_Initial;
H4 : Unsigned_32 := H4_Initial;
end record;
end Modular_Hashing.SHA1;
|
persan/protobuf-ada | Ada | 227 | ads |
with Google.Protobuf.Generated_Message_Utilities;
package Protocol_Buffers.Generated_Message_Utilities renames Google.Protobuf.Generated_Message_Utilities with Obsolescent => "use Google.Protobuf.Generated_Message_Utilities";
|
alban-linard/adda | Ada | 3,884 | adb | package body Adda.Generator is
use Successors;
overriding procedure Initialize
(Object : in out Decision_Diagram) is
begin
if Object.Data /= null then
Object.Data.Reference_Counter.all :=
Object.Data.Reference_Counter.all + 1;
end if;
end Initialize;
overriding procedure Adjust
(Object : in out Decision_Diagram) renames Initialize;
overriding procedure Finalize
(Object : in out Decision_Diagram) is
begin
if Object.Data /= null then
Object.Data.Reference_Counter.all :=
Object.Data.Reference_Counter.all - 1;
if Object.Data.Reference_Counter.all = 0 then
null; -- FIXME
end if;
end if;
end Finalize;
function Hash
(Element : in Decision_Diagram)
return Hash_Type is
begin
return Hash_Type (Element.Data.Identifier);
end Hash;
function "="
(Left, Right : in Decision_Diagram)
return Boolean is
begin
return Left.Data
= Right.Data; -- TODO: check that it is a pointer comparison
end "=";
function Hash
(Element : in Structure)
return Hash_Type is
begin
case Element.Of_Type is
when Terminal =>
return Hash_Terminal (Element.Value);
when Non_Terminal =>
declare
Result : Hash_Type := Hash_Variable (Element.Variable);
Current : Successors.Cursor :=
Successors.First (Element.Alpha);
begin
while Successors.Has_Element (Current) loop
Result :=
Result
xor
(Hash_Value (Successors.Key (Current))
xor Hash (Successors.Element (Current)));
Successors.Next (Current);
end loop;
return Result;
end;
end case;
end Hash;
overriding function "="
(Left, Right : in Structure)
return Boolean is
begin
if Left.Of_Type = Right.Of_Type then
case Left.Of_Type is
when Terminal =>
return Left.Value = Right.Value;
when Non_Terminal =>
return Left.Variable = Right.Variable
and then Left.Alpha = Right.Alpha;
end case;
else
return False;
end if;
end "=";
function Make
(Value : in Terminal_Type)
return Decision_Diagram is
To_Insert : constant Structure :=
(Of_Type => Terminal,
Identifier => 0,
Reference_Counter => null,
Value => Value);
Position : Unicity.Cursor;
Inserted : Boolean;
begin
Unicity_Table.Insert
(New_Item => To_Insert,
Position => Position,
Inserted => Inserted);
declare
Subdata : aliased Structure := Unicity.Element (Position);
Data : constant Any_Structure := Subdata'Unchecked_Access;
begin
if Inserted then
Identifier := Identifier + 1;
Subdata.Identifier := Identifier + 1;
Subdata.Reference_Counter := new Natural'(0);
end if;
return (Controlled with Data => Data);
end;
end Make;
function Make
(Variable : in Variable_Type;
Value : in Value_Type;
Successor : in Decision_Diagram)
return Decision_Diagram is
Result : Decision_Diagram;
begin
return Result;
end Make;
begin
null;
end Adda.Generator;
|
zertovitch/hac | Ada | 605 | adb | with Ada.Text_IO;
procedure Show_MIT_License
(file : Ada.Text_IO.File_Type; source_with_license : String)
is
use Ada.Text_IO;
begin
New_Line (file);
Put_Line (file, "| This software is free and open-source.");
Put_Line (file, "| It is provided ""as is"", WITHOUT WARRANTY OF ANY KIND.");
Put_Line (file, "| For the full license wording, see the header" &
" (copyright & MIT license)");
Put_Line (file, "| appearing on top of this software's source files.");
Put_Line (file, "| In doubt, check the file: " & source_with_license);
New_Line (file);
end Show_MIT_License;
|
reznikmm/matreshka | Ada | 6,911 | 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 generalization is a taxonomic relationship between a more general
-- classifier and a more specific classifier. Each instance of the specific
-- classifier is also an indirect instance of the general classifier. Thus,
-- the specific classifier inherits the features of the more general
-- classifier.
--
-- A generalization relates a specific classifier to a more general
-- classifier, and is owned by the specific classifier.
------------------------------------------------------------------------------
limited with AMF.UML.Classifiers;
with AMF.UML.Directed_Relationships;
limited with AMF.UML.Generalization_Sets.Collections;
package AMF.UML.Generalizations is
pragma Preelaborate;
type UML_Generalization is limited interface
and AMF.UML.Directed_Relationships.UML_Directed_Relationship;
type UML_Generalization_Access is
access all UML_Generalization'Class;
for UML_Generalization_Access'Storage_Size use 0;
not overriding function Get_General
(Self : not null access constant UML_Generalization)
return AMF.UML.Classifiers.UML_Classifier_Access is abstract;
-- Getter of Generalization::general.
--
-- References the general classifier in the Generalization relationship.
not overriding procedure Set_General
(Self : not null access UML_Generalization;
To : AMF.UML.Classifiers.UML_Classifier_Access) is abstract;
-- Setter of Generalization::general.
--
-- References the general classifier in the Generalization relationship.
not overriding function Get_Generalization_Set
(Self : not null access constant UML_Generalization)
return AMF.UML.Generalization_Sets.Collections.Set_Of_UML_Generalization_Set is abstract;
-- Getter of Generalization::generalizationSet.
--
-- Designates a set in which instances of Generalization is considered
-- members.
not overriding function Get_Is_Substitutable
(Self : not null access constant UML_Generalization)
return AMF.Optional_Boolean is abstract;
-- Getter of Generalization::isSubstitutable.
--
-- Indicates whether the specific classifier can be used wherever the
-- general classifier can be used. If true, the execution traces of the
-- specific classifier will be a superset of the execution traces of the
-- general classifier.
not overriding procedure Set_Is_Substitutable
(Self : not null access UML_Generalization;
To : AMF.Optional_Boolean) is abstract;
-- Setter of Generalization::isSubstitutable.
--
-- Indicates whether the specific classifier can be used wherever the
-- general classifier can be used. If true, the execution traces of the
-- specific classifier will be a superset of the execution traces of the
-- general classifier.
not overriding function Get_Specific
(Self : not null access constant UML_Generalization)
return AMF.UML.Classifiers.UML_Classifier_Access is abstract;
-- Getter of Generalization::specific.
--
-- References the specializing classifier in the Generalization
-- relationship.
not overriding procedure Set_Specific
(Self : not null access UML_Generalization;
To : AMF.UML.Classifiers.UML_Classifier_Access) is abstract;
-- Setter of Generalization::specific.
--
-- References the specializing classifier in the Generalization
-- relationship.
end AMF.UML.Generalizations;
|
LiberatorUSA/GUCEF | Ada | 21,101 | adb | ----------------------------------------------------------------
-- ZLib for Ada thick binding. --
-- --
-- Copyright (C) 2002-2004 Dmitriy Anisimkov --
-- --
-- Open source license information is in the zlib.ads file. --
----------------------------------------------------------------
-- $Id: zlib.adb,v 1.31 2004/09/06 06:53:19 vagul Exp $
with Ada.Exceptions;
with Ada.Unchecked_Conversion;
with Ada.Unchecked_Deallocation;
with Interfaces.C.Strings;
with ZLib.Thin;
package body ZLib is
use type Thin.Int;
type Z_Stream is new Thin.Z_Stream;
type Return_Code_Enum is
(OK,
STREAM_END,
NEED_DICT,
ERRNO,
STREAM_ERROR,
DATA_ERROR,
MEM_ERROR,
BUF_ERROR,
VERSION_ERROR);
type Flate_Step_Function is access
function (Strm : in Thin.Z_Streamp; Flush : in Thin.Int) return Thin.Int;
pragma Convention (C, Flate_Step_Function);
type Flate_End_Function is access
function (Ctrm : in Thin.Z_Streamp) return Thin.Int;
pragma Convention (C, Flate_End_Function);
type Flate_Type is record
Step : Flate_Step_Function;
Done : Flate_End_Function;
end record;
subtype Footer_Array is Stream_Element_Array (1 .. 8);
Simple_GZip_Header : constant Stream_Element_Array (1 .. 10)
:= (16#1f#, 16#8b#, -- Magic header
16#08#, -- Z_DEFLATED
16#00#, -- Flags
16#00#, 16#00#, 16#00#, 16#00#, -- Time
16#00#, -- XFlags
16#03# -- OS code
);
-- The simplest gzip header is not for informational, but just for
-- gzip format compatibility.
-- Note that some code below is using assumption
-- Simple_GZip_Header'Last > Footer_Array'Last, so do not make
-- Simple_GZip_Header'Last <= Footer_Array'Last.
Return_Code : constant array (Thin.Int range <>) of Return_Code_Enum
:= (0 => OK,
1 => STREAM_END,
2 => NEED_DICT,
-1 => ERRNO,
-2 => STREAM_ERROR,
-3 => DATA_ERROR,
-4 => MEM_ERROR,
-5 => BUF_ERROR,
-6 => VERSION_ERROR);
Flate : constant array (Boolean) of Flate_Type
:= (True => (Step => Thin.Deflate'Access,
Done => Thin.DeflateEnd'Access),
False => (Step => Thin.Inflate'Access,
Done => Thin.InflateEnd'Access));
Flush_Finish : constant array (Boolean) of Flush_Mode
:= (True => Finish, False => No_Flush);
procedure Raise_Error (Stream : in Z_Stream);
pragma Inline (Raise_Error);
procedure Raise_Error (Message : in String);
pragma Inline (Raise_Error);
procedure Check_Error (Stream : in Z_Stream; Code : in Thin.Int);
procedure Free is new Ada.Unchecked_Deallocation
(Z_Stream, Z_Stream_Access);
function To_Thin_Access is new Ada.Unchecked_Conversion
(Z_Stream_Access, Thin.Z_Streamp);
procedure Translate_GZip
(Filter : in out Filter_Type;
In_Data : in Ada.Streams.Stream_Element_Array;
In_Last : out Ada.Streams.Stream_Element_Offset;
Out_Data : out Ada.Streams.Stream_Element_Array;
Out_Last : out Ada.Streams.Stream_Element_Offset;
Flush : in Flush_Mode);
-- Separate translate routine for make gzip header.
procedure Translate_Auto
(Filter : in out Filter_Type;
In_Data : in Ada.Streams.Stream_Element_Array;
In_Last : out Ada.Streams.Stream_Element_Offset;
Out_Data : out Ada.Streams.Stream_Element_Array;
Out_Last : out Ada.Streams.Stream_Element_Offset;
Flush : in Flush_Mode);
-- translate routine without additional headers.
-----------------
-- Check_Error --
-----------------
procedure Check_Error (Stream : in Z_Stream; Code : in Thin.Int) is
use type Thin.Int;
begin
if Code /= Thin.Z_OK then
Raise_Error
(Return_Code_Enum'Image (Return_Code (Code))
& ": " & Last_Error_Message (Stream));
end if;
end Check_Error;
-----------
-- Close --
-----------
procedure Close
(Filter : in out Filter_Type;
Ignore_Error : in Boolean := False)
is
Code : Thin.Int;
begin
if not Ignore_Error and then not Is_Open (Filter) then
raise Status_Error;
end if;
Code := Flate (Filter.Compression).Done (To_Thin_Access (Filter.Strm));
if Ignore_Error or else Code = Thin.Z_OK then
Free (Filter.Strm);
else
declare
Error_Message : constant String
:= Last_Error_Message (Filter.Strm.all);
begin
Free (Filter.Strm);
Ada.Exceptions.Raise_Exception
(ZLib_Error'Identity,
Return_Code_Enum'Image (Return_Code (Code))
& ": " & Error_Message);
end;
end if;
end Close;
-----------
-- CRC32 --
-----------
function CRC32
(CRC : in Unsigned_32;
Data : in Ada.Streams.Stream_Element_Array)
return Unsigned_32
is
use Thin;
begin
return Unsigned_32 (crc32 (ULong (CRC),
Data'Address,
Data'Length));
end CRC32;
procedure CRC32
(CRC : in out Unsigned_32;
Data : in Ada.Streams.Stream_Element_Array) is
begin
CRC := CRC32 (CRC, Data);
end CRC32;
------------------
-- Deflate_Init --
------------------
procedure Deflate_Init
(Filter : in out Filter_Type;
Level : in Compression_Level := Default_Compression;
Strategy : in Strategy_Type := Default_Strategy;
Method : in Compression_Method := Deflated;
Window_Bits : in Window_Bits_Type := Default_Window_Bits;
Memory_Level : in Memory_Level_Type := Default_Memory_Level;
Header : in Header_Type := Default)
is
use type Thin.Int;
Win_Bits : Thin.Int := Thin.Int (Window_Bits);
begin
if Is_Open (Filter) then
raise Status_Error;
end if;
-- We allow ZLib to make header only in case of default header type.
-- Otherwise we would either do header by ourselfs, or do not do
-- header at all.
if Header = None or else Header = GZip then
Win_Bits := -Win_Bits;
end if;
-- For the GZip CRC calculation and make headers.
if Header = GZip then
Filter.CRC := 0;
Filter.Offset := Simple_GZip_Header'First;
else
Filter.Offset := Simple_GZip_Header'Last + 1;
end if;
Filter.Strm := new Z_Stream;
Filter.Compression := True;
Filter.Stream_End := False;
Filter.Header := Header;
if Thin.Deflate_Init
(To_Thin_Access (Filter.Strm),
Level => Thin.Int (Level),
method => Thin.Int (Method),
windowBits => Win_Bits,
memLevel => Thin.Int (Memory_Level),
strategy => Thin.Int (Strategy)) /= Thin.Z_OK
then
Raise_Error (Filter.Strm.all);
end if;
end Deflate_Init;
-----------
-- Flush --
-----------
procedure Flush
(Filter : in out Filter_Type;
Out_Data : out Ada.Streams.Stream_Element_Array;
Out_Last : out Ada.Streams.Stream_Element_Offset;
Flush : in Flush_Mode)
is
No_Data : Stream_Element_Array := (1 .. 0 => 0);
Last : Stream_Element_Offset;
begin
Translate (Filter, No_Data, Last, Out_Data, Out_Last, Flush);
end Flush;
-----------------------
-- Generic_Translate --
-----------------------
procedure Generic_Translate
(Filter : in out ZLib.Filter_Type;
In_Buffer_Size : in Integer := Default_Buffer_Size;
Out_Buffer_Size : in Integer := Default_Buffer_Size)
is
In_Buffer : Stream_Element_Array
(1 .. Stream_Element_Offset (In_Buffer_Size));
Out_Buffer : Stream_Element_Array
(1 .. Stream_Element_Offset (Out_Buffer_Size));
Last : Stream_Element_Offset;
In_Last : Stream_Element_Offset;
In_First : Stream_Element_Offset;
Out_Last : Stream_Element_Offset;
begin
Main : loop
Data_In (In_Buffer, Last);
In_First := In_Buffer'First;
loop
Translate
(Filter => Filter,
In_Data => In_Buffer (In_First .. Last),
In_Last => In_Last,
Out_Data => Out_Buffer,
Out_Last => Out_Last,
Flush => Flush_Finish (Last < In_Buffer'First));
if Out_Buffer'First <= Out_Last then
Data_Out (Out_Buffer (Out_Buffer'First .. Out_Last));
end if;
exit Main when Stream_End (Filter);
-- The end of in buffer.
exit when In_Last = Last;
In_First := In_Last + 1;
end loop;
end loop Main;
end Generic_Translate;
------------------
-- Inflate_Init --
------------------
procedure Inflate_Init
(Filter : in out Filter_Type;
Window_Bits : in Window_Bits_Type := Default_Window_Bits;
Header : in Header_Type := Default)
is
use type Thin.Int;
Win_Bits : Thin.Int := Thin.Int (Window_Bits);
procedure Check_Version;
-- Check the latest header types compatibility.
procedure Check_Version is
begin
if Version <= "1.1.4" then
Raise_Error
("Inflate header type " & Header_Type'Image (Header)
& " incompatible with ZLib version " & Version);
end if;
end Check_Version;
begin
if Is_Open (Filter) then
raise Status_Error;
end if;
case Header is
when None =>
Check_Version;
-- Inflate data without headers determined
-- by negative Win_Bits.
Win_Bits := -Win_Bits;
when GZip =>
Check_Version;
-- Inflate gzip data defined by flag 16.
Win_Bits := Win_Bits + 16;
when Auto =>
Check_Version;
-- Inflate with automatic detection
-- of gzip or native header defined by flag 32.
Win_Bits := Win_Bits + 32;
when Default => null;
end case;
Filter.Strm := new Z_Stream;
Filter.Compression := False;
Filter.Stream_End := False;
Filter.Header := Header;
if Thin.Inflate_Init
(To_Thin_Access (Filter.Strm), Win_Bits) /= Thin.Z_OK
then
Raise_Error (Filter.Strm.all);
end if;
end Inflate_Init;
-------------
-- Is_Open --
-------------
function Is_Open (Filter : in Filter_Type) return Boolean is
begin
return Filter.Strm /= null;
end Is_Open;
-----------------
-- Raise_Error --
-----------------
procedure Raise_Error (Message : in String) is
begin
Ada.Exceptions.Raise_Exception (ZLib_Error'Identity, Message);
end Raise_Error;
procedure Raise_Error (Stream : in Z_Stream) is
begin
Raise_Error (Last_Error_Message (Stream));
end Raise_Error;
----------
-- Read --
----------
procedure Read
(Filter : in out Filter_Type;
Item : out Ada.Streams.Stream_Element_Array;
Last : out Ada.Streams.Stream_Element_Offset;
Flush : in Flush_Mode := No_Flush)
is
In_Last : Stream_Element_Offset;
Item_First : Ada.Streams.Stream_Element_Offset := Item'First;
V_Flush : Flush_Mode := Flush;
begin
pragma Assert (Rest_First in Buffer'First .. Buffer'Last + 1);
pragma Assert (Rest_Last in Buffer'First - 1 .. Buffer'Last);
loop
if Rest_Last = Buffer'First - 1 then
V_Flush := Finish;
elsif Rest_First > Rest_Last then
Read (Buffer, Rest_Last);
Rest_First := Buffer'First;
if Rest_Last < Buffer'First then
V_Flush := Finish;
end if;
end if;
Translate
(Filter => Filter,
In_Data => Buffer (Rest_First .. Rest_Last),
In_Last => In_Last,
Out_Data => Item (Item_First .. Item'Last),
Out_Last => Last,
Flush => V_Flush);
Rest_First := In_Last + 1;
exit when Stream_End (Filter)
or else Last = Item'Last
or else (Last >= Item'First and then Allow_Read_Some);
Item_First := Last + 1;
end loop;
end Read;
----------------
-- Stream_End --
----------------
function Stream_End (Filter : in Filter_Type) return Boolean is
begin
if Filter.Header = GZip and Filter.Compression then
return Filter.Stream_End
and then Filter.Offset = Footer_Array'Last + 1;
else
return Filter.Stream_End;
end if;
end Stream_End;
--------------
-- Total_In --
--------------
function Total_In (Filter : in Filter_Type) return Count is
begin
return Count (Thin.Total_In (To_Thin_Access (Filter.Strm).all));
end Total_In;
---------------
-- Total_Out --
---------------
function Total_Out (Filter : in Filter_Type) return Count is
begin
return Count (Thin.Total_Out (To_Thin_Access (Filter.Strm).all));
end Total_Out;
---------------
-- Translate --
---------------
procedure Translate
(Filter : in out Filter_Type;
In_Data : in Ada.Streams.Stream_Element_Array;
In_Last : out Ada.Streams.Stream_Element_Offset;
Out_Data : out Ada.Streams.Stream_Element_Array;
Out_Last : out Ada.Streams.Stream_Element_Offset;
Flush : in Flush_Mode) is
begin
if Filter.Header = GZip and then Filter.Compression then
Translate_GZip
(Filter => Filter,
In_Data => In_Data,
In_Last => In_Last,
Out_Data => Out_Data,
Out_Last => Out_Last,
Flush => Flush);
else
Translate_Auto
(Filter => Filter,
In_Data => In_Data,
In_Last => In_Last,
Out_Data => Out_Data,
Out_Last => Out_Last,
Flush => Flush);
end if;
end Translate;
--------------------
-- Translate_Auto --
--------------------
procedure Translate_Auto
(Filter : in out Filter_Type;
In_Data : in Ada.Streams.Stream_Element_Array;
In_Last : out Ada.Streams.Stream_Element_Offset;
Out_Data : out Ada.Streams.Stream_Element_Array;
Out_Last : out Ada.Streams.Stream_Element_Offset;
Flush : in Flush_Mode)
is
use type Thin.Int;
Code : Thin.Int;
begin
if not Is_Open (Filter) then
raise Status_Error;
end if;
if Out_Data'Length = 0 and then In_Data'Length = 0 then
raise Constraint_Error;
end if;
Set_Out (Filter.Strm.all, Out_Data'Address, Out_Data'Length);
Set_In (Filter.Strm.all, In_Data'Address, In_Data'Length);
Code := Flate (Filter.Compression).Step
(To_Thin_Access (Filter.Strm),
Thin.Int (Flush));
if Code = Thin.Z_STREAM_END then
Filter.Stream_End := True;
else
Check_Error (Filter.Strm.all, Code);
end if;
In_Last := In_Data'Last
- Stream_Element_Offset (Avail_In (Filter.Strm.all));
Out_Last := Out_Data'Last
- Stream_Element_Offset (Avail_Out (Filter.Strm.all));
end Translate_Auto;
--------------------
-- Translate_GZip --
--------------------
procedure Translate_GZip
(Filter : in out Filter_Type;
In_Data : in Ada.Streams.Stream_Element_Array;
In_Last : out Ada.Streams.Stream_Element_Offset;
Out_Data : out Ada.Streams.Stream_Element_Array;
Out_Last : out Ada.Streams.Stream_Element_Offset;
Flush : in Flush_Mode)
is
Out_First : Stream_Element_Offset;
procedure Add_Data (Data : in Stream_Element_Array);
-- Add data to stream from the Filter.Offset till necessary,
-- used for add gzip headr/footer.
procedure Put_32
(Item : in out Stream_Element_Array;
Data : in Unsigned_32);
pragma Inline (Put_32);
--------------
-- Add_Data --
--------------
procedure Add_Data (Data : in Stream_Element_Array) is
Data_First : Stream_Element_Offset renames Filter.Offset;
Data_Last : Stream_Element_Offset;
Data_Len : Stream_Element_Offset; -- -1
Out_Len : Stream_Element_Offset; -- -1
begin
Out_First := Out_Last + 1;
if Data_First > Data'Last then
return;
end if;
Data_Len := Data'Last - Data_First;
Out_Len := Out_Data'Last - Out_First;
if Data_Len <= Out_Len then
Out_Last := Out_First + Data_Len;
Data_Last := Data'Last;
else
Out_Last := Out_Data'Last;
Data_Last := Data_First + Out_Len;
end if;
Out_Data (Out_First .. Out_Last) := Data (Data_First .. Data_Last);
Data_First := Data_Last + 1;
Out_First := Out_Last + 1;
end Add_Data;
------------
-- Put_32 --
------------
procedure Put_32
(Item : in out Stream_Element_Array;
Data : in Unsigned_32)
is
D : Unsigned_32 := Data;
begin
for J in Item'First .. Item'First + 3 loop
Item (J) := Stream_Element (D and 16#FF#);
D := Shift_Right (D, 8);
end loop;
end Put_32;
begin
Out_Last := Out_Data'First - 1;
if not Filter.Stream_End then
Add_Data (Simple_GZip_Header);
Translate_Auto
(Filter => Filter,
In_Data => In_Data,
In_Last => In_Last,
Out_Data => Out_Data (Out_First .. Out_Data'Last),
Out_Last => Out_Last,
Flush => Flush);
CRC32 (Filter.CRC, In_Data (In_Data'First .. In_Last));
end if;
if Filter.Stream_End and then Out_Last <= Out_Data'Last then
-- This detection method would work only when
-- Simple_GZip_Header'Last > Footer_Array'Last
if Filter.Offset = Simple_GZip_Header'Last + 1 then
Filter.Offset := Footer_Array'First;
end if;
declare
Footer : Footer_Array;
begin
Put_32 (Footer, Filter.CRC);
Put_32 (Footer (Footer'First + 4 .. Footer'Last),
Unsigned_32 (Total_In (Filter)));
Add_Data (Footer);
end;
end if;
end Translate_GZip;
-------------
-- Version --
-------------
function Version return String is
begin
return Interfaces.C.Strings.Value (Thin.zlibVersion);
end Version;
-----------
-- Write --
-----------
procedure Write
(Filter : in out Filter_Type;
Item : in Ada.Streams.Stream_Element_Array;
Flush : in Flush_Mode := No_Flush)
is
Buffer : Stream_Element_Array (1 .. Buffer_Size);
In_Last : Stream_Element_Offset;
Out_Last : Stream_Element_Offset;
In_First : Stream_Element_Offset := Item'First;
begin
if Item'Length = 0 and Flush = No_Flush then
return;
end if;
loop
Translate
(Filter => Filter,
In_Data => Item (In_First .. Item'Last),
In_Last => In_Last,
Out_Data => Buffer,
Out_Last => Out_Last,
Flush => Flush);
if Out_Last >= Buffer'First then
Write (Buffer (1 .. Out_Last));
end if;
exit when In_Last = Item'Last or Stream_End (Filter);
In_First := In_Last + 1;
end loop;
end Write;
end ZLib;
|
sungyeon/drake | Ada | 590 | ads | pragma License (Unrestricted);
-- generalized unit of Ada.Strings.Less_Case_Insensitive
generic
type Character_Type is (<>);
type String_Type is array (Positive range <>) of Character_Type;
with procedure Get (
Item : String_Type;
Last : out Natural;
Value : out Wide_Wide_Character;
Is_Illegal_Sequence : out Boolean);
function Ada.Strings.Generic_Less_Case_Insensitive (Left, Right : String_Type)
return Boolean;
-- pragma Pure (Ada.Strings.Generic_Less_Case_Insensitive);
pragma Preelaborate (Ada.Strings.Generic_Less_Case_Insensitive); -- use maps
|
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_Weight_Complex;
package ODF.DOM.Attributes.Style.Font_Weight_Complex.Internals is
function Create
(Node : Matreshka.ODF_Attributes.Style.Font_Weight_Complex.Style_Font_Weight_Complex_Access)
return ODF.DOM.Attributes.Style.Font_Weight_Complex.ODF_Style_Font_Weight_Complex;
function Wrap
(Node : Matreshka.ODF_Attributes.Style.Font_Weight_Complex.Style_Font_Weight_Complex_Access)
return ODF.DOM.Attributes.Style.Font_Weight_Complex.ODF_Style_Font_Weight_Complex;
end ODF.DOM.Attributes.Style.Font_Weight_Complex.Internals;
|
AdaCore/Ada-IntelliJ | Ada | 3,252 | ads | ------------------------------------------------------------------------------
-- --
-- GNAT EXAMPLE --
-- --
-- Copyright (C) 2014, Free Software Foundation, Inc. --
-- --
-- GNAT is free software; you can redistribute it and/or modify it under --
-- terms of the GNU General Public License as published by the Free Soft- --
-- ware Foundation; either version 3, or (at your option) any later ver- --
-- sion. GNAT is distributed in the hope that it will be useful, but WITH- --
-- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY --
-- or FITNESS FOR A PARTICULAR PURPOSE. --
-- --
-- As a special exception under Section 7 of GPL version 3, you are granted --
-- additional permissions described in the GCC Runtime Library Exception, --
-- version 3.1, as published by the Free Software Foundation. --
-- --
-- You should have received a copy of the GNU General Public License and --
-- a copy of the GCC Runtime Library Exception along with this program; --
-- see the files COPYING3 and COPYING.RUNTIME respectively. If not, see --
-- <http://www.gnu.org/licenses/>. --
-- --
-- GNAT was originally developed by the GNAT team at New York University. --
-- Extensive contributions were provided by Ada Core Technologies Inc. --
-- --
------------------------------------------------------------------------------
-- This file provides register definitions for the STM32F4 (ARM Cortex M4F)
-- microcontrollers from ST Microelectronics.
pragma Restrictions (No_Elaboration_Code);
package STM32F4.SYSCONFIG_Control is
type EXTI_Register is record
IMR : Bits_32x1;
EMR : Bits_32x1;
RTSR : Bits_32x1;
FTSR : Bits_32x1;
SWIER : Bits_32x1;
PR : Bits_32x1;
end record;
for EXTI_Register use record
IMR at 0 range 0 .. 31;
EMR at 4 range 0 .. 31;
RTSR at 8 range 0 .. 31;
FTSR at 12 range 0 .. 31;
SWIER at 16 range 0 .. 31;
PR at 20 range 0 .. 31;
end record;
type SYSCFG_Register is record
MEMRM : Word;
PMC : Word;
EXTICR1 : Bits_8x4;
EXTICR2 : Bits_8x4;
EXTICR3 : Bits_8x4;
EXTICR4 : Bits_8x4;
CMPCR : Word;
end record;
for SYSCFG_Register use record
MEMRM at 0 range 0 .. 31;
PMC at 4 range 0 .. 31;
EXTICR1 at 8 range 0 .. 31;
EXTICR2 at 12 range 0 .. 31;
EXTICR3 at 16 range 0 .. 31;
EXTICR4 at 20 range 0 .. 31;
CMPCR at 24 range 0 .. 31;
end record;
end STM32F4.SYSCONFIG_Control;
|
stcarrez/ada-keystore | Ada | 24,865 | adb | -----------------------------------------------------------------------
-- keystore-repository-data -- Data access and management for the keystore
-- Copyright (C) 2019, 2020, 2022, 2023 Stephane Carrez
-- Written by Stephane Carrez ([email protected])
--
-- Licensed under the Apache License, Version 2.0 (the "License");
-- you may not use this file except in compliance with the License.
-- You may obtain a copy of the License at
--
-- http://www.apache.org/licenses/LICENSE-2.0
--
-- Unless required by applicable law or agreed to in writing, software
-- distributed under the License is distributed on an "AS IS" BASIS,
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-- See the License for the specific language governing permissions and
-- limitations under the License.
-----------------------------------------------------------------------
with Interfaces;
with Util.Log.Loggers;
with Util.Encoders.SHA256;
with Util.Encoders.HMAC.SHA256;
with Ada.IO_Exceptions;
with Keystore.Logs;
with Keystore.Buffers;
with Keystore.Marshallers;
with Keystore.Repository.Data;
package body Keystore.Repository.Workers is
use type Interfaces.Unsigned_16;
use type Interfaces.Unsigned_32;
procedure Check_Raise_Error (Status : in Status_Type) with Inline;
Log : constant Util.Log.Loggers.Logger
:= Util.Log.Loggers.Create ("Keystore.Repository.Workers");
procedure Check_Raise_Error (Status : in Status_Type) is
begin
case Status is
when DATA_CORRUPTION =>
raise Keystore.Corrupted;
when PENDING | SUCCESS =>
null;
when others =>
raise Keystore.Invalid_Block;
end case;
end Check_Raise_Error;
procedure Initialize_Queue (Manager : in out Wallet_Repository) is
begin
Manager.Workers.Sequence := 0;
Manager.Workers.Data_Queue.Reset_Sequence;
end Initialize_Queue;
procedure Queue_Decipher_Work (Manager : in out Wallet_Repository;
Work : in Data_Work_Access;
Queued : out Boolean) is
Status : Status_Type;
begin
if Manager.Workers.Work_Manager /= null then
Manager.Workers.Sequence := Manager.Workers.Sequence + 1;
Manager.Workers.Work_Manager.Execute (Work.all'Access);
Queued := True;
else
Work.Do_Decipher_Data;
Status := Work.Status;
Workers.Put_Work (Manager.Workers.all, Work);
Check_Raise_Error (Status);
Queued := False;
end if;
end Queue_Decipher_Work;
procedure Queue_Cipher_Work (Manager : in out Wallet_Repository;
Work : in Data_Work_Access) is
Status : Status_Type;
begin
if Manager.Workers.Work_Manager /= null then
Manager.Workers.Sequence := Manager.Workers.Sequence + 1;
Manager.Workers.Work_Manager.Execute (Work.all'Access);
else
Work.Do_Cipher_Data;
Status := Work.Status;
Workers.Put_Work (Manager.Workers.all, Work);
Check_Raise_Error (Status);
end if;
end Queue_Cipher_Work;
procedure Queue_Delete_Work (Manager : in out Wallet_Repository;
Work : in Data_Work_Access) is
Status : Status_Type;
begin
if Manager.Workers.Work_Manager /= null then
Manager.Workers.Sequence := Manager.Workers.Sequence + 1;
Manager.Workers.Work_Manager.Execute (Work.all'Access);
else
Work.Do_Delete_Data;
Status := Work.Status;
Workers.Put_Work (Manager.Workers.all, Work);
Check_Raise_Error (Status);
end if;
end Queue_Delete_Work;
procedure Fill (Work : in out Data_Work;
Input : in out Util.Streams.Input_Stream'Class;
Space : in Buffer_Offset;
Data_Size : out Buffers.Buffer_Size) is
Pos : Buffer_Offset := Work.Data'First;
Limit : constant Buffer_Offset := Pos + Space - 1;
Last : Stream_Element_Offset;
begin
Work.Buffer_Pos := 1;
loop
Input.Read (Work.Data (Pos .. Limit), Last);
-- Reached end of buffer.
if Last >= Limit then
Work.Last_Pos := Limit;
Data_Size := Last;
return;
end if;
-- Reached end of stream.
if Last < Pos then
if Last >= Work.Data'First then
Work.Last_Pos := Last;
Data_Size := Last;
else
Data_Size := 0;
end if;
return;
end if;
Pos := Last + 1;
end loop;
end Fill;
procedure Fill (Work : in out Data_Work;
Input : in Ada.Streams.Stream_Element_Array;
Input_Pos : in Ada.Streams.Stream_Element_Offset;
Data_Size : out Buffers.Buffer_Size) is
Size : Stream_Element_Offset;
begin
Size := Input'Last - Input_Pos + 1;
if Size > DATA_MAX_SIZE then
Size := DATA_MAX_SIZE;
end if;
Data_Size := Size;
Work.Last_Pos := Size;
Work.Data (1 .. Size) := Input (Input_Pos .. Input_Pos + Size - 1);
end Fill;
procedure Put_Work (Worker : in out Wallet_Worker;
Work : in Data_Work_Access) is
begin
Worker.Pool_Count := Worker.Pool_Count + 1;
Worker.Work_Pool (Worker.Pool_Count) := Work;
end Put_Work;
function Get_Work (Worker : in out Wallet_Worker) return Data_Work_Access is
begin
if Worker.Pool_Count = 0 then
return null;
else
Worker.Pool_Count := Worker.Pool_Count - 1;
return Worker.Work_Pool (Worker.Pool_Count + 1);
end if;
end Get_Work;
procedure Allocate_Work (Manager : in out Wallet_Repository;
Kind : in Data_Work_Type;
Process : access procedure (Work : in Data_Work_Access);
Iterator : in Keys.Data_Key_Iterator;
Work : out Data_Work_Access) is
Workers : constant access Wallet_Worker := Manager.Workers;
Seq : Natural;
Status : Status_Type;
begin
loop
Work := Get_Work (Workers.all);
exit when Work /= null;
Workers.Data_Queue.Dequeue (Work, Seq);
Status := Work.Status;
if Process /= null and then Status = SUCCESS then
Process (Work);
end if;
Put_Work (Workers.all, Work);
Check_Raise_Error (Status);
end loop;
Work.Kind := Kind;
Work.Buffer_Pos := Work.Data'First;
if Kind = DATA_DECRYPT then
Work.Last_Pos := Work.Data'First + Iterator.Data_Size - 1;
end if;
Work.Entry_Id := Iterator.Entry_Id;
Work.Key_Pos := Iterator.Key_Pos;
Work.Key_Block.Buffer := Iterator.Current.Buffer;
Work.Data_Block := Iterator.Data_Block;
Work.Data_Need_Setup := False;
Work.Data_Offset := Iterator.Current_Offset;
Work.Sequence := Workers.Sequence;
Work.Status := PENDING;
end Allocate_Work;
procedure Flush_Queue (Manager : in out Wallet_Repository;
Process : access procedure (Work : in Data_Work_Access)) is
Workers : constant access Wallet_Worker := Manager.Workers;
Seq : Natural;
Work : Data_Work_Access;
Status : Status_Type := SUCCESS;
begin
if Workers /= null then
while Workers.Pool_Count < Workers.Work_Count loop
Workers.Data_Queue.Dequeue (Work, Seq);
if Status = SUCCESS then
Status := Work.Status;
end if;
if Process /= null and then Status = SUCCESS then
Process (Work);
end if;
Put_Work (Workers.all, Work);
end loop;
Check_Raise_Error (Status);
end if;
end Flush_Queue;
-- ------------------------------
-- Load the data block in the wallet manager buffer. Extract the data descriptors
-- the first time the data block is read.
-- ------------------------------
procedure Load_Data (Work : in out Data_Work;
Data_Block : in out IO.Marshaller) is
Btype : Interfaces.Unsigned_16;
Wid : Interfaces.Unsigned_32;
Size : IO.Block_Index;
begin
Logs.Debug (Log, "Load data block{0} and key block{1}",
Work.Data_Block, Work.Key_Block.Buffer.Block);
Data_Block.Buffer := Buffers.Allocate (Work.Data_Block);
if Work.Data_Need_Setup then
Work.Fragment_Count := 1;
Work.Fragment_Pos := 1;
Size := Work.Last_Pos - Work.Buffer_Pos + 1;
Work.Start_Data := IO.Block_Index'Last - AES_Align (Size) + 1;
Work.End_Aligned_Data := IO.Block_Index'Last;
Work.End_Data := Work.Start_Data + Size - 1;
Marshallers.Set_Header (Into => Data_Block,
Tag => IO.BT_WALLET_DATA,
Id => Work.Manager.Id);
return;
end if;
-- Read wallet data block.
Keystore.Keys.Set_IV (Work.Info_Cryptor, Work.Data_Block.Block);
Work.Stream.Read (Decipher => Work.Info_Cryptor.Decipher,
Sign => Work.Info_Cryptor.Sign,
Decrypt_Size => Size,
Into => Data_Block.Buffer);
-- Check block type.
Btype := Marshallers.Get_Header_16 (Data_Block);
if Btype /= IO.BT_WALLET_DATA then
Logs.Error (Log, "Block{0} invalid block type", Data_Block.Buffer.Block);
Work.Status := DATA_CORRUPTION;
return;
end if;
Marshallers.Skip (Data_Block, 2);
-- Check that this is a block for the current wallet.
Wid := Marshallers.Get_Unsigned_32 (Data_Block);
if Wid /= Interfaces.Unsigned_32 (Work.Manager.Id) then
Logs.Error (Log, "Block{0} invalid block wallet identifier",
Work.Data_Block);
Work.Status := DATA_CORRUPTION;
return;
end if;
Marshallers.Skip (Data_Block, 8);
declare
Index : Wallet_Entry_Index;
Slot_Size : IO.Buffer_Size;
Data_Pos : IO.Block_Index;
Fragment_Pos : Natural := 0;
begin
Data_Pos := IO.Block_Index'Last;
Work.Fragment_Count := Natural (Size / DATA_ENTRY_SIZE);
while Data_Block.Pos < IO.BT_DATA_START + Size loop
Index := Wallet_Entry_Index (Marshallers.Get_Unsigned_32 (Data_Block));
Slot_Size := Marshallers.Get_Buffer_Size (Data_Block);
if Index = Work.Entry_Id then
Work.Fragment_Pos := Fragment_Pos + 1;
Work.End_Aligned_Data := Data_Pos;
Data_Pos := Data_Pos - AES_Align (Slot_Size) + 1;
Work.Start_Data := Data_Pos;
Work.End_Data := Data_Pos + Slot_Size - 1;
Marshallers.Skip (Data_Block, 2);
Work.Data_Offset := Marshallers.Get_Unsigned_64 (Data_Block);
if Work.Kind = DATA_ENCRYPT then
Size := Work.Last_Pos - Work.Buffer_Pos + 1;
Work.Start_Data := Work.End_Aligned_Data - AES_Align (Size) + 1;
Work.End_Data := Work.Start_Data + Size - 1;
end if;
return;
end if;
Fragment_Pos := Fragment_Pos + 1;
Data_Pos := Data_Pos - AES_Align (Slot_Size);
Marshallers.Skip (Data_Block, DATA_ENTRY_SIZE - 4 - 2);
end loop;
Logs.Error (Log, "Block{0} does not contain expected data entry", Work.Data_Block);
Work.Status := DATA_CORRUPTION;
end;
exception
when Ada.IO_Exceptions.End_Error | Ada.IO_Exceptions.Data_Error =>
Logs.Error (Log, "Block{0} cannot be read", Work.Data_Block);
Work.Status := DATA_CORRUPTION;
end Load_Data;
procedure Do_Decipher_Data (Work : in out Data_Work) is
Data_Block : IO.Marshaller;
Last : Stream_Element_Offset;
Encoded : Stream_Element_Offset;
Secret : Secret_Key (Length => Util.Encoders.AES.AES_256_Length);
IV : Secret_Key (Length => IO.SIZE_IV);
begin
if Log.Get_Level >= Util.Log.INFO_LEVEL then
Log.Info ("Decipher {3} bytes data block{0} with key block{1}@{2}",
Buffers.To_String (Work.Data_Block),
Buffers.To_String (Work.Key_Block.Buffer.Block),
Buffers.Image (Work.Key_Pos),
Buffers.Image (Work.Last_Pos - Work.Buffer_Pos + 1));
end if;
-- Read the encrypted data block.
Load_Data (Work, Data_Block);
if Work.Status /= PENDING then
return;
end if;
declare
Buf : constant Buffers.Buffer_Accessor := Data_Block.Buffer.Data.Value;
Last_Pos : constant IO.Block_Index := Work.Buffer_Pos + Work.End_Data - Work.Start_Data;
HMAC : Util.Encoders.SHA256.Hash_Array;
begin
Work.Key_Block.Pos := Work.Key_Pos;
Marshallers.Get_Secret (Work.Key_Block, IV, Work.Manager.Config.Key.Key,
Work.Manager.Config.Key.IV);
Marshallers.Get_Secret (Work.Key_Block, Secret, Work.Manager.Config.Key.Key,
Work.Manager.Config.Key.IV);
Work.Data_Decipher.Set_IV (IV);
Work.Data_Decipher.Set_Key (Secret, Util.Encoders.AES.CBC);
Work.Data_Decipher.Set_Padding (Util.Encoders.AES.ZERO_PADDING);
Work.Data_Decipher.Transform
(Data => Buf.Data (Work.Start_Data .. Work.End_Aligned_Data),
Into => Work.Data (Work.Buffer_Pos .. Last_Pos),
Last => Last,
Encoded => Encoded);
Work.Data_Decipher.Finish (Into => Work.Data (Last + 1 .. Last_Pos),
Last => Last);
Util.Encoders.HMAC.SHA256.Sign (Key => Work.Info_Cryptor.Sign,
Data => Work.Data (Work.Buffer_Pos .. Last),
Result => HMAC);
if HMAC /= Buf.Data (Data_Block.Pos + 1 .. Data_Block.Pos + IO.SIZE_HMAC) then
Log.Error ("Data fragment hmac does not match in block {0}",
Buffers.To_String (Work.Data_Block));
Work.Status := DATA_CORRUPTION;
else
Work.Status := SUCCESS;
end if;
if Log.Get_Level >= Util.Log.DEBUG_LEVEL then
Log.Debug ("Key pos for decrypt at {0}", Buffers.Image (Work.Key_Pos));
Log.Debug ("Current pos {0}", Buffers.Image (Work.Key_Block.Pos));
Log.Debug ("Dump encrypted data:");
Logs.Dump (Log, Buf.Data (Work.Start_Data .. Work.End_Aligned_Data));
Log.Debug ("Dump data:");
Logs.Dump (Log, Work.Data (Work.Buffer_Pos .. Last_Pos));
end if;
end;
exception
when others =>
Work.Status := DATA_CORRUPTION;
end Do_Decipher_Data;
procedure Do_Cipher_Data (Work : in out Data_Work) is
Data_Block : IO.Marshaller;
Encoded : Stream_Element_Offset;
Start_Pos : constant Stream_Element_Offset := Work.Buffer_Pos;
Last_Pos : constant Stream_Element_Offset := Work.Last_Pos;
Write_Pos : Stream_Element_Offset;
Secret : Secret_Key (Length => Util.Encoders.AES.AES_256_Length);
IV : Secret_Key (Length => 16);
begin
if Log.Get_Level >= Util.Log.INFO_LEVEL then
Log.Info ("Cipher {3} bytes data block{0} with key block{1}@{2}",
Buffers.To_String (Work.Data_Block),
Buffers.To_String (Work.Key_Block.Buffer.Block),
Buffers.Image (Work.Key_Pos),
Buffers.Image (Work.Last_Pos - Work.Buffer_Pos + 1));
end if;
-- Read the encrypted data block.
Load_Data (Work, Data_Block);
if Work.Status /= PENDING then
return;
end if;
-- Generate a new IV and key.
Work.Random.Generate (IV);
Work.Random.Generate (Secret);
Work.Key_Block.Pos := Work.Key_Pos;
Marshallers.Put_Secret (Work.Key_Block, IV, Work.Manager.Config.Key.Key,
Work.Manager.Config.Key.IV);
Marshallers.Put_Secret (Work.Key_Block, Secret, Work.Manager.Config.Key.Key,
Work.Manager.Config.Key.IV);
-- Encrypt the data content using the item encryption key and IV.
Work.Data_Cipher.Set_IV (IV);
Work.Data_Cipher.Set_Key (Secret, Util.Encoders.AES.CBC);
Work.Data_Cipher.Set_Padding (Util.Encoders.AES.ZERO_PADDING);
Data_Block.Pos := Data.Data_Entry_Offset (Work.Fragment_Pos);
Marshallers.Put_Unsigned_32 (Data_Block, Interfaces.Unsigned_32 (Work.Entry_Id));
Marshallers.Put_Unsigned_16 (Data_Block, Interfaces.Unsigned_16 (Last_Pos - Start_Pos + 1));
Marshallers.Put_Unsigned_16 (Data_Block, 0);
Marshallers.Put_Unsigned_64 (Data_Block, Work.Data_Offset);
-- Make HMAC-SHA256 signature of the data content before encryption.
Marshallers.Put_HMAC_SHA256 (Into => Data_Block,
Key => Work.Info_Cryptor.Sign,
Content => Work.Data (Start_Pos .. Last_Pos));
declare
Buf : constant Buffers.Buffer_Accessor := Data_Block.Buffer.Data.Value;
End_Pos : constant IO.Block_Index := Work.End_Aligned_Data;
Encrypt_Size : IO.Block_Index;
begin
-- This is a new block, fill empty area with zero or random values.
if Work.Data_Need_Setup and then Data_Block.Pos < Work.Start_Data then
if Work.Manager.Config.Randomize then
Work.Random.Generate (Buf.Data (Data_Block.Pos + 1 .. Work.Start_Data - 1));
else
Buf.Data (Data_Block.Pos + 1 .. Work.Start_Data - 1) := (others => 0);
end if;
end if;
Encrypt_Size := IO.Block_Index (Work.Fragment_Count * DATA_ENTRY_SIZE);
Work.Data_Cipher.Transform (Data => Work.Data (Start_Pos .. Last_Pos),
Into => Buf.Data (Work.Start_Data .. End_Pos),
Last => Write_Pos,
Encoded => Encoded);
if Write_Pos < End_Pos then
Work.Data_Cipher.Finish (Into => Buf.Data (Write_Pos + 1 .. End_Pos),
Last => Write_Pos);
end if;
-- Write the encrypted data block.
Keystore.Keys.Set_IV (Work.Info_Cryptor, Work.Data_Block.Block);
Work.Stream.Write (Encrypt_Size => Encrypt_Size,
Cipher => Work.Info_Cryptor.Cipher,
Sign => Work.Info_Cryptor.Sign,
From => Data_Block.Buffer);
if Log.Get_Level >= Util.Log.DEBUG_LEVEL then
Log.Debug ("Key pos for encryption at {0}", Buffers.Image (Work.Key_Pos));
Log.Debug ("Current pos {0}", Buffers.Image (Work.Key_Block.Pos));
Log.Debug ("Dump clear data:");
Logs.Dump (Log, Work.Data (Start_Pos .. Last_Pos));
Log.Debug ("Dump encrypted data:");
Logs.Dump (Log, Buf.Data (Work.Start_Data .. Work.End_Aligned_Data));
end if;
Work.Status := SUCCESS;
end;
exception
when others =>
Work.Status := DATA_CORRUPTION;
end Do_Cipher_Data;
procedure Do_Delete_Data (Work : in out Data_Work) is
Data_Block : IO.Marshaller;
begin
if Log.Get_Level >= Util.Log.INFO_LEVEL then
Log.Info ("Delete data block{0}", Buffers.To_String (Work.Data_Block));
end if;
-- Read the encrypted data block to release the data fragment or the full data block.
Load_Data (Work, Data_Block);
if Work.Status /= PENDING then
return;
end if;
if Work.Fragment_Count > 1 then
-- The data block looks like:
-- +-----+-----------------------------+-----+----------------------------------------+
-- | HDR | Ent1 | ... | Enti | ... EntN| 0 0 | xxx | FragN | .. | Fragi | ... | Frag1 |
-- +-----+-----------------------------+-----+----------------------------------------+
--
-- When we remove entry I, we also remove the fragment I.
-- +-----+------------------+------------------------------------+--------------------+
-- | HDR | Ent1 | ... | EntN| 0 0 | xxx | FragN | .. | Frag1 |
-- +-----+------------------+------------------------------------+--------------------+
--
declare
Buf : constant Buffers.Buffer_Accessor := Data_Block.Buffer.Data.Value;
Start_Entry : IO.Block_Index;
Last_Entry : IO.Block_Index;
Start_Pos : IO.Block_Index;
Slot_Size : IO.Buffer_Size;
Data_Size : constant IO.Block_Index := Work.End_Aligned_Data - Work.Start_Data;
Encrypt_Size : constant IO.Block_Index
:= Data.Data_Entry_Offset (Work.Fragment_Count);
begin
Last_Entry := Data.Data_Entry_Offset (Work.Fragment_Count) + DATA_ENTRY_SIZE - 1;
-- Move the data entry to the beginning.
if Work.Fragment_Pos /= Work.Fragment_Count then
Start_Entry := Data.Data_Entry_Offset (Work.Fragment_Pos);
Buf.Data (Start_Entry .. Last_Entry - DATA_ENTRY_SIZE)
:= Buf.Data (Start_Entry + DATA_ENTRY_SIZE .. Last_Entry);
end if;
Buf.Data (Last_Entry - DATA_ENTRY_SIZE + 1 .. Last_Entry) := (others => 0);
Start_Pos := Work.Start_Data;
Data_Block.Pos := Start_Entry + 4;
while Data_Block.Pos < Last_Entry - DATA_ENTRY_SIZE loop
Slot_Size := Marshallers.Get_Buffer_Size (Data_Block);
Start_Pos := Start_Pos - AES_Align (Slot_Size);
Marshallers.Skip (Data_Block, DATA_ENTRY_SIZE - 2);
end loop;
-- Move the data before the slot being removed.
if Work.Start_Data /= Start_Pos then
Buf.Data (Start_Pos + Data_Size .. Work.Start_Data - 1)
:= Buf.Data (Start_Pos .. Work.End_Aligned_Data);
end if;
-- Erase the content that was dropped.
Buf.Data (Start_Pos .. Start_Pos + Data_Size - 1) := (others => 0);
-- Write the data block.
Work.Stream.Write (Encrypt_Size => Encrypt_Size,
Cipher => Work.Info_Cryptor.Cipher,
Sign => Work.Info_Cryptor.Sign,
From => Data_Block.Buffer);
end;
else
Work.Stream.Release (Block => Work.Data_Block);
end if;
Work.Status := SUCCESS;
end Do_Delete_Data;
overriding
procedure Execute (Work : in out Data_Work) is
begin
begin
case Work.Kind is
when DATA_ENCRYPT =>
Work.Do_Cipher_Data;
when DATA_DECRYPT =>
Work.Do_Decipher_Data;
when DATA_RELEASE =>
Work.Do_Delete_Data;
end case;
exception
when E : others =>
Log.Error ("Unexpected exception", E);
Work.Status := DATA_CORRUPTION;
end;
Work.Queue.Enqueue (Work'Unchecked_Access, Work.Sequence);
end Execute;
-- ------------------------------
-- Create the wallet encryption and decryption work manager.
-- ------------------------------
function Create (Manager : access Wallet_Repository;
Work_Manager : in Keystore.Task_Manager_Access;
Count : in Positive) return Wallet_Worker_Access is
Result : Wallet_Worker_Access := new Wallet_Worker (Count);
Work : Data_Work_Access;
begin
Result.Work_Manager := Work_Manager;
Result.Data_Queue.Set_Size (Capacity => Count);
for I in 1 .. Count loop
Work := Result.Work_Slots (I)'Access;
Work.Stream := Manager.Stream;
Keystore.Keys.Set_Key (Work.Info_Cryptor, Manager.Config.Data);
Result.Work_Pool (I) := Work;
Result.Work_Slots (I).Queue := Result.Data_Queue'Access;
Result.Work_Slots (I).Manager := Manager;
end loop;
Result.Pool_Count := Count;
return Result;
end Create;
end Keystore.Repository.Workers;
|
skordal/ada-regex | Ada | 3,380 | adb | -- Ada regular expression library
-- (c) Kristian Klomsten Skordal 2020-2023 <[email protected]>
-- Report bugs and issues on <https://github.com/skordal/ada-regex>
with AUnit.Assertions;
use AUnit.Assertions;
with Regex.Utilities; use Regex.Utilities;
with Regex.Utilities.Sorted_Sets;
package body Utilities_Test_Cases is
package Integer_Sets is new Regex.Utilities.Sorted_Sets (Element_Type => Integer);
procedure Test_Escape (T : in out Test_Fixture) is
pragma Unreferenced (T);
Test_String : constant String := "abc()[]\|+-$*.?";
Expected_String : constant String := "abc\(\)\[\]\\\|\+\-\$\*\.\?";
begin
Assert (Expected_String = Escape (Test_String), "Escaped string does not escape all characters");
end Test_Escape;
procedure Test_Empty_Set (T : in out Test_Fixture) is
pragma Unreferenced (T);
Test_Set : constant Integer_Sets.Sorted_Set := Integer_Sets.Empty_Set;
begin
Assert (Test_Set.Length = 0, "Length of an empty set is not 0!");
for Value of Test_Set loop
Assert (False, "It should not be possible to iterate through an empty set");
end loop;
end Test_Empty_Set;
procedure Test_Basic_Ops (T : in out Test_Fixture) is
pragma Unreferenced (T);
Test_Set : Integer_Sets.Sorted_Set := Integer_Sets.Empty_Set;
begin
for I in 1 .. 1000 loop
Test_Set.Add (I);
end loop;
Assert (Test_Set.Length = 1000, "Test_Set length is not 1000!");
declare
Expected_Value : Natural := 1;
begin
for Value of Test_Set loop
Assert (Value = Expected_Value, "Values in array does not match expected values");
Expected_Value := Expected_Value + 1;
end loop;
end;
end Test_Basic_Ops;
procedure Test_Assignment (T : in out Test_Fixture) is
pragma Unreferenced (T);
use type Integer_Sets.Sorted_Set;
Test_Set : Integer_Sets.Sorted_Set := Integer_Sets.Empty_Set;
Test_Set_2 : Integer_Sets.Sorted_Set := Integer_Sets.Empty_Set;
begin
for I in 0 .. 10 loop
Test_Set.Add (I);
end loop;
Assert (Test_Set_2.Length = 0, "Test_Set_2.Length is not 0!");
Test_Set_2 := Test_Set;
Assert (Test_Set_2.Length = Test_Set.Length, "Set lengths do not match");
Assert (Test_Set_2 = Test_Set, "Set contents do not match according to = operator");
declare
Expected_Value : Natural := 0;
begin
for Value of Test_Set_2 loop
Assert (Value = Expected_Value, "Values in copied set does not match expected values");
Expected_Value := Expected_Value + 1;
end loop;
end;
end Test_Assignment;
procedure Test_Ordering (T : in out Test_Fixture) is
pragma Unreferenced (T);
Test_Set : Integer_Sets.Sorted_Set := Integer_Sets.Empty_Set;
begin
for I in reverse 1 .. 1000 loop
Test_Set.Add (I);
end loop;
Assert (Test_Set.Length = 1000, "Test_Set length is not 1000!");
declare
Expected_Value : Natural := 1;
begin
for Value of Test_Set loop
Assert (Value = Expected_Value, "Values in array does not match expected values");
Expected_Value := Expected_Value + 1;
end loop;
end;
end Test_Ordering;
end Utilities_Test_Cases;
|
onox/orka | Ada | 4,865 | adb | -- SPDX-License-Identifier: Apache-2.0
--
-- Copyright (c) 2016 onox <[email protected]>
--
-- Licensed under the Apache License, Version 2.0 (the "License");
-- you may not use this file except in compliance with the License.
-- You may obtain a copy of the License at
--
-- http://www.apache.org/licenses/LICENSE-2.0
--
-- Unless required by applicable law or agreed to in writing, software
-- distributed under the License is distributed on an "AS IS" BASIS,
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-- See the License for the specific language governing permissions and
-- limitations under the License.
package body Orka.Rendering.Buffers.MDI is
procedure Append
(Object : in out Batch;
Instances : Natural;
Vertices : Natural;
Indices : Natural;
Append_Vertices : not null access procedure (Offset, Count : Natural);
Append_Indices : not null access procedure (Offset, Count : Natural))
is
Index_Count : constant Natural := Indices;
Vertex_Count : constant Natural := Vertices;
Commands : Indirect.Elements_Indirect_Command_Array (1 .. 1);
begin
Commands (1) :=
(Count => UInt (Index_Count),
Instances => UInt (Instances),
First_Index => UInt (Object.Index_Offset),
Base_Vertex => UInt (Object.Vertex_Offset),
Base_Instance => UInt (Object.Instance_Index));
Append_Vertices (Offset => Object.Vertex_Offset, Count => Vertex_Count);
Append_Indices (Offset => Object.Index_Offset, Count => Index_Count);
-- Upload command to command buffer
Object.Commands.Write_Data (Commands, Offset => Object.Draw_Index);
Object.Index_Offset := Object.Index_Offset + Index_Count;
Object.Vertex_Offset := Object.Vertex_Offset + Vertex_Count;
Object.Draw_Index := Object.Draw_Index + 1;
Object.Instance_Index := Object.Instance_Index + Instances;
end Append;
function Create_Batch
(Vertex_Kind : Types.Numeric_Type;
Index_Kind : Types.Index_Type;
Parts, Vertex_Data, Indices : Positive) return Batch
is
use all type Mapped.Unsynchronized.Unsynchronized_Mapped_Buffer;
begin
return Result : Batch (Vertex_Kind, Index_Kind) do
Result.Commands := Create_Buffer
(Types.Elements_Command_Type, Parts, Mapped.Write);
Result.Data := Create_Buffer
(Vertex_Kind, Vertex_Data, Mapped.Write);
-- Indices
Result.Indices := Create_Buffer (Index_Kind, Indices, Mapped.Write);
Result.Data.Map;
Result.Indices.Map;
Result.Commands.Map;
end return;
end Create_Batch;
procedure Finish_Batch (Object : in out Batch) is
begin
Object.Data.Unmap;
Object.Indices.Unmap;
Object.Commands.Unmap;
end Finish_Batch;
-----------------------------------------------------------------------------
Interleaved_Half_Type_Elements : constant := 8;
function Create_Batch (Parts, Vertices, Indices : Positive) return Batch is
(Create_Batch (Types.Half_Type, Types.UInt_Type,
Parts, Vertices * Interleaved_Half_Type_Elements, Indices));
procedure Append
(Object : in out Batch;
Positions : not null Indirect.Half_Array_Access;
Normals : not null Indirect.Half_Array_Access;
UVs : not null Indirect.Half_Array_Access;
Indices : not null Indirect.UInt_Array_Access)
is
Vertex_Count : constant Natural := Positions'Length / 3;
Index_Count : constant Natural := Indices'Length;
pragma Assert (Positions'Length = Normals'Length);
pragma Assert (Vertex_Count = UVs'Length / 2);
procedure Write_Vertices (Vertex_Offset, Vertex_Count : Natural) is
begin
-- Iterate over the vertices to interleave all the data into one buffer
for I in 1 .. Size (Vertex_Count) loop
declare
Offset : constant Natural := (Vertex_Offset + Natural (I) - 1)
* Interleaved_Half_Type_Elements;
begin
Object.Data.Write_Data (Positions.all (I * 3 - 2 .. I * 3), Offset => Offset + 0);
Object.Data.Write_Data (Normals.all (I * 3 - 2 .. I * 3), Offset => Offset + 3);
Object.Data.Write_Data (UVs.all (I * 2 - 1 .. I * 2), Offset => Offset + 6);
end;
end loop;
end Write_Vertices;
procedure Write_Indices (Index_Offset, Index_Count : Natural) is
pragma Assert (Indices'Length = Index_Count);
begin
Object.Indices.Write_Data (Indices.all, Offset => Index_Offset);
end Write_Indices;
begin
Object.Append (0, Vertex_Count, Index_Count, Write_Vertices'Access, Write_Indices'Access);
end Append;
end Orka.Rendering.Buffers.MDI;
|
reznikmm/matreshka | Ada | 2,287 | adb | with Ada.Wide_Wide_Text_IO;
with AMF.Elements;
with AMF.UML.Elements;
with AMF.UML.Models;
with AMF.UML.Properties.Collections;
with AMF.UML.Types;
with League.Strings;
package body Generators is
use Ada.Wide_Wide_Text_IO;
use type AMF.Optional_String;
function "+"
(Item : Wide_Wide_String) return League.Strings.Universal_String
renames League.Strings.To_Universal_String;
-----------------
-- Enter_Class --
-----------------
overriding procedure Enter_Class
(Self : in out Generator;
Element : not null AMF.UML.Classes.UML_Class_Access)
is
use type AMF.Optional_Integer;
Owned_Attribute : constant
AMF.UML.Properties.Collections.Ordered_Set_Of_UML_Property
:= Element.Get_Owned_Attribute;
Attribute : AMF.UML.Properties.UML_Property_Access;
First : Boolean := True;
Attribute_Type : AMF.UML.Types.UML_Type_Access;
Owner : AMF.UML.Elements.UML_Element_Access;
begin
Owner :=
AMF.UML.Elements.UML_Element_Access
(AMF.Elements.Element_Access (Element).Container);
if Owner.all not in AMF.UML.Models.UML_Model'Class
or else AMF.UML.Models.UML_Model_Access (Owner).Get_Name /= +"Schema"
then
-- Return immediately when owner of current UML::Class is not
-- UML::Model called "Schema".
return;
end if;
Put ("CREATE TABLE " & Element.Get_Name.Value.To_Wide_Wide_String);
for J in 1 .. Owned_Attribute.Length loop
Attribute := Owned_Attribute.Element (J);
Attribute_Type := Attribute.Get_Type;
if not Attribute.Is_Multivalued then
if First then
New_Line;
Put (" (");
First := False;
else
Put_Line (";");
Put (" ");
end if;
Put (Attribute.Get_Name.Value.To_Wide_Wide_String);
Put (' ');
Put
(Attribute_Type.Get_Name.Value.To_Uppercase.To_Wide_Wide_String);
if Attribute.Lower_Bound = 1 then
Put (" NOT NULL");
end if;
end if;
end loop;
Put_Line (");");
end Enter_Class;
end Generators;
|
AdaCore/Ada_Drivers_Library | Ada | 4,147 | adb | ------------------------------------------------------------------------------
-- --
-- Copyright (C) 2017-2022, 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 is a demo of the features available on the STM32F4-DISCOVERY board.
--
-- Press the blue button to change the note of the sound played in the
-- headphone jack. Press the black button to reset.
with HAL; use HAL;
with STM32.Board; use STM32.Board;
with HAL.Audio; use HAL.Audio;
with Simple_Synthesizer;
with Audio_Stream; use Audio_Stream;
with System; use System;
with Interfaces; use Interfaces;
with STM32.User_Button;
with Last_Chance_Handler; pragma Unreferenced (Last_Chance_Handler);
procedure Main is
Synth : Simple_Synthesizer.Synthesizer
(Stereo => True,
Amplitude => Natural (Integer_16'Last / 3));
Audio_Data_0 : Audio_Buffer (1 .. 64);
Audio_Data_1 : Audio_Buffer (1 .. 64);
Note : Float := 110.0;
begin
Initialize_LEDs;
Initialize_Audio;
STM32.User_Button.Initialize;
Synth.Set_Frequency (STM32.Board.Audio_Rate);
STM32.Board.Audio_DAC.Set_Volume (60);
STM32.Board.Audio_DAC.Play;
Audio_TX_DMA_Int.Start (Destination => STM32.Board.Audio_I2S.Data_Register_Address,
Source_0 => Audio_Data_0'Address,
Source_1 => Audio_Data_1'Address,
Data_Count => Audio_Data_0'Length);
loop
if STM32.User_Button.Has_Been_Pressed then
Note := Note * 2.0;
if Note > 880.0 then
Note := 110.0;
end if;
end if;
Synth.Set_Note_Frequency (Note);
Audio_TX_DMA_Int.Wait_For_Transfer_Complete;
if Audio_TX_DMA_Int.Not_In_Transfer = Audio_Data_0'Address then
Synth.Receive (Audio_Data_0);
else
Synth.Receive (Audio_Data_1);
end if;
end loop;
end Main;
|
ekoeppen/STM32_Generic_Ada_Drivers | Ada | 5,418 | ads | -- This spec has been automatically generated from STM32L0x1.svd
pragma Restrictions (No_Elaboration_Code);
pragma Ada_2012;
pragma Style_Checks (Off);
with System;
package STM32_SVD.MPU is
pragma Preelaborate;
---------------
-- Registers --
---------------
-- MPU type register
type MPU_TYPER_Register is record
-- Read-only. Separate flag
SEPARATE_k : STM32_SVD.Bit;
-- unspecified
Reserved_1_7 : STM32_SVD.UInt7;
-- Read-only. Number of MPU data regions
DREGION : STM32_SVD.Byte;
-- Read-only. Number of MPU instruction regions
IREGION : STM32_SVD.Byte;
-- unspecified
Reserved_24_31 : STM32_SVD.Byte;
end record
with Volatile_Full_Access, Object_Size => 32,
Bit_Order => System.Low_Order_First;
for MPU_TYPER_Register use record
SEPARATE_k at 0 range 0 .. 0;
Reserved_1_7 at 0 range 1 .. 7;
DREGION at 0 range 8 .. 15;
IREGION at 0 range 16 .. 23;
Reserved_24_31 at 0 range 24 .. 31;
end record;
-- MPU control register
type MPU_CTRL_Register is record
-- Read-only. Enables the MPU
ENABLE : STM32_SVD.Bit;
-- Read-only. Enables the operation of MPU during hard fault
HFNMIENA : STM32_SVD.Bit;
-- Read-only. Enable priviliged software access to default memory map
PRIVDEFENA : STM32_SVD.Bit;
-- unspecified
Reserved_3_31 : STM32_SVD.UInt29;
end record
with Volatile_Full_Access, Object_Size => 32,
Bit_Order => System.Low_Order_First;
for MPU_CTRL_Register use record
ENABLE at 0 range 0 .. 0;
HFNMIENA at 0 range 1 .. 1;
PRIVDEFENA at 0 range 2 .. 2;
Reserved_3_31 at 0 range 3 .. 31;
end record;
-- MPU region number register
type MPU_RNR_Register is record
-- MPU region
REGION : STM32_SVD.Byte;
-- unspecified
Reserved_8_31 : STM32_SVD.UInt24;
end record
with Volatile_Full_Access, Object_Size => 32,
Bit_Order => System.Low_Order_First;
for MPU_RNR_Register use record
REGION at 0 range 0 .. 7;
Reserved_8_31 at 0 range 8 .. 31;
end record;
-- MPU region base address register
type MPU_RBAR_Register is record
-- MPU region field
REGION : STM32_SVD.UInt4;
-- MPU region number valid
VALID : STM32_SVD.Bit;
-- Region base address field
ADDR : STM32_SVD.UInt27;
end record
with Volatile_Full_Access, Object_Size => 32,
Bit_Order => System.Low_Order_First;
for MPU_RBAR_Register use record
REGION at 0 range 0 .. 3;
VALID at 0 range 4 .. 4;
ADDR at 0 range 5 .. 31;
end record;
-- MPU region attribute and size register
type MPU_RASR_Register is record
-- Region enable bit.
ENABLE : STM32_SVD.Bit;
-- Size of the MPU protection region
SIZE : STM32_SVD.UInt5;
-- unspecified
Reserved_6_7 : STM32_SVD.UInt2;
-- Subregion disable bits
SRD : STM32_SVD.Byte;
-- memory attribute
B : STM32_SVD.Bit;
-- memory attribute
C : STM32_SVD.Bit;
-- Shareable memory attribute
S : STM32_SVD.Bit;
-- memory attribute
TEX : STM32_SVD.UInt3;
-- unspecified
Reserved_22_23 : STM32_SVD.UInt2;
-- Access permission
AP : STM32_SVD.UInt3;
-- unspecified
Reserved_27_27 : STM32_SVD.Bit;
-- Instruction access disable bit
XN : STM32_SVD.Bit;
-- unspecified
Reserved_29_31 : STM32_SVD.UInt3;
end record
with Volatile_Full_Access, Object_Size => 32,
Bit_Order => System.Low_Order_First;
for MPU_RASR_Register use record
ENABLE at 0 range 0 .. 0;
SIZE at 0 range 1 .. 5;
Reserved_6_7 at 0 range 6 .. 7;
SRD at 0 range 8 .. 15;
B at 0 range 16 .. 16;
C at 0 range 17 .. 17;
S at 0 range 18 .. 18;
TEX at 0 range 19 .. 21;
Reserved_22_23 at 0 range 22 .. 23;
AP at 0 range 24 .. 26;
Reserved_27_27 at 0 range 27 .. 27;
XN at 0 range 28 .. 28;
Reserved_29_31 at 0 range 29 .. 31;
end record;
-----------------
-- Peripherals --
-----------------
-- Memory protection unit
type MPU_Peripheral is record
-- MPU type register
MPU_TYPER : aliased MPU_TYPER_Register;
-- MPU control register
MPU_CTRL : aliased MPU_CTRL_Register;
-- MPU region number register
MPU_RNR : aliased MPU_RNR_Register;
-- MPU region base address register
MPU_RBAR : aliased MPU_RBAR_Register;
-- MPU region attribute and size register
MPU_RASR : aliased MPU_RASR_Register;
end record
with Volatile;
for MPU_Peripheral use record
MPU_TYPER at 16#0# range 0 .. 31;
MPU_CTRL at 16#4# range 0 .. 31;
MPU_RNR at 16#8# range 0 .. 31;
MPU_RBAR at 16#C# range 0 .. 31;
MPU_RASR at 16#10# range 0 .. 31;
end record;
-- Memory protection unit
MPU_Periph : aliased MPU_Peripheral
with Import, Address => MPU_Base;
end STM32_SVD.MPU;
|
reznikmm/matreshka | Ada | 4,558 | ads | ------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- Ada Modeling Framework --
-- --
-- Runtime Library Component --
-- --
------------------------------------------------------------------------------
-- --
-- Copyright © 2011, Vadim Godunko <[email protected]> --
-- All rights reserved. --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions --
-- are met: --
-- --
-- * Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- --
-- * Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in the --
-- documentation and/or other materials provided with the distribution. --
-- --
-- * Neither the name of the Vadim Godunko, IE nor the names of its --
-- contributors may be used to endorse or promote products derived from --
-- this software without specific prior written permission. --
-- --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR --
-- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
-- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED --
-- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR --
-- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF --
-- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING --
-- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS --
-- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
-- --
------------------------------------------------------------------------------
-- $Revision$ $Date$
------------------------------------------------------------------------------
-- This file is generated, don't edit it.
------------------------------------------------------------------------------
-- A typed element is a kind of named element that represents an element with
-- a type.
------------------------------------------------------------------------------
with AMF.CMOF.Named_Elements;
limited with AMF.CMOF.Types;
package AMF.CMOF.Typed_Elements is
pragma Preelaborate;
type CMOF_Typed_Element is limited interface
and AMF.CMOF.Named_Elements.CMOF_Named_Element;
type CMOF_Typed_Element_Access is
access all CMOF_Typed_Element'Class;
for CMOF_Typed_Element_Access'Storage_Size use 0;
not overriding function Get_Type
(Self : not null access constant CMOF_Typed_Element)
return AMF.CMOF.Types.CMOF_Type_Access is abstract;
-- Getter of TypedElement::type.
--
-- This information is derived from the return result for this Operation.
not overriding procedure Set_Type
(Self : not null access CMOF_Typed_Element;
To : AMF.CMOF.Types.CMOF_Type_Access) is abstract;
-- Setter of TypedElement::type.
--
-- This information is derived from the return result for this Operation.
end AMF.CMOF.Typed_Elements;
|
stcarrez/ada-servlet | Ada | 7,759 | adb | -----------------------------------------------------------------------
-- servlet-responses.web -- Servlet Responses with AWS server
-- Copyright (C) 2009, 2010, 2011, 2017, 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 AWS.Headers;
with AWS.Messages;
with AWS.Response.Set;
with AWS.Containers.Tables;
package body Servlet.Responses.Web is
overriding
procedure Initialize (Resp : in out Response) is
begin
Resp.Content.Initialize (Size => 256 * 1024,
Output => Resp'Unchecked_Access);
Resp.Stream := Resp.Content'Unchecked_Access;
end Initialize;
-- ------------------------------
-- Write the buffer array to the output stream.
-- ------------------------------
overriding
procedure Write (Stream : in out Response;
Buffer : in Ada.Streams.Stream_Element_Array) is
begin
AWS.Response.Set.Append_Body (D => Stream.Data,
Item => Buffer);
end Write;
-- ------------------------------
-- Flush the buffer (if any) to the sink.
-- ------------------------------
overriding
procedure Flush (Stream : in out Response) is
begin
null;
end Flush;
function To_Status_Code (Status : in Natural) return AWS.Messages.Status_Code;
function To_Status_Code (Status : in Natural) return AWS.Messages.Status_Code is
use AWS.Messages;
begin
case Status is
when 100 =>
return S100;
when 101 =>
return S101;
when 102 =>
return S102;
when 200 =>
return S200;
when 201 =>
return S201;
when 202 =>
return S202;
when 203 =>
return S203;
when 204 =>
return S204;
when 205 =>
return S205;
when 206 =>
return S206;
when 207 =>
return S207;
when 301 =>
return S301;
when 302 =>
return S302;
when 400 =>
return S400;
when 401 =>
return S401;
when 402 =>
return S402;
when 403 =>
return S403;
when 404 =>
return S404;
when 405 =>
return S405;
when others =>
return S500;
end case;
end To_Status_Code;
-- ------------------------------
-- Iterate over the response headers and executes the <b>Process</b> procedure.
-- ------------------------------
overriding
procedure Iterate_Headers (Resp : in Response;
Process : not null access
procedure (Name : in String;
Value : in String)) is
Headers : constant AWS.Headers.List := AWS.Response.Header (Resp.Data);
begin
AWS.Containers.Tables.Iterate_Names (AWS.Containers.Tables.Table_Type (Headers),
";", Process);
end Iterate_Headers;
-- ------------------------------
-- Returns a boolean indicating whether the named response header has already
-- been set.
-- ------------------------------
overriding
function Contains_Header (Resp : in Response;
Name : in String) return Boolean is
begin
raise Program_Error with "Contains_Header is not implemented";
return False;
end Contains_Header;
-- ------------------------------
-- Sets a response header with the given name and value. If the header had already
-- been set, the new value overwrites the previous one. The containsHeader
-- method can be used to test for the presence of a header before setting its value.
-- ------------------------------
overriding
procedure Set_Header (Resp : in out Response;
Name : in String;
Value : in String) is
begin
if AWS.Response.Header (Resp.Data, Name)'Length = 0 then
AWS.Response.Set.Add_Header (D => Resp.Data,
Name => Name,
Value => Value);
end if;
end Set_Header;
-- ------------------------------
-- Adds a response header with the given name and value.
-- This method allows response headers to have multiple values.
-- ------------------------------
overriding
procedure Add_Header (Resp : in out Response;
Name : in String;
Value : in String) is
begin
AWS.Response.Set.Add_Header (D => Resp.Data,
Name => Name,
Value => Value);
end Add_Header;
-- ------------------------------
-- Sends a temporary redirect response to the client using the specified redirect
-- location URL. This method can accept relative URLs; the servlet container must
-- convert the relative URL to an absolute URL before sending the response to the
-- client. If the location is relative without a leading '/' the container
-- interprets it as relative to the current request URI. If the location is relative
-- with a leading '/' the container interprets it as relative to the servlet
-- container root.
--
-- If the response has already been committed, this method throws an
-- IllegalStateException. After using this method, the response should be
-- considered to be committed and should not be written to.
-- ------------------------------
overriding
procedure Send_Redirect (Resp : in out Response;
Location : in String) is
begin
Response'Class (Resp).Set_Status (SC_FOUND);
Response'Class (Resp).Set_Header (Name => "Location",
Value => Location);
Resp.Redirect := True;
end Send_Redirect;
-- ------------------------------
-- Prepare the response data by collecting the status, content type and message body.
-- ------------------------------
procedure Build (Resp : in out Response) is
begin
if not Resp.Redirect then
AWS.Response.Set.Content_Type (D => Resp.Data,
Value => Resp.Get_Content_Type);
Resp.Content.Flush;
if AWS.Response.Is_Empty (Resp.Data) then
AWS.Response.Set.Message_Body (Resp.Data, "");
end if;
else
AWS.Response.Set.Mode (D => Resp.Data,
Value => AWS.Response.Header);
end if;
AWS.Response.Set.Status_Code (D => Resp.Data,
Value => To_Status_Code (Resp.Get_Status));
end Build;
-- ------------------------------
-- Get the response data
-- ------------------------------
function Get_Data (Resp : in Response) return AWS.Response.Data is
begin
return Resp.Data;
end Get_Data;
end Servlet.Responses.Web;
|
io7m/coreland-plexlog-ada | Ada | 2,635 | adb | with Plexlog.Dir_Stack;
with test;
procedure t_dir1 is
Stack : Plexlog.Dir_Stack.Dir_Stack_t;
begin
test.assert
(check => Plexlog.Dir_Stack.Size (Stack) = 0,
pass_message => "size: " & Natural'Image (Plexlog.Dir_Stack.Size (Stack)),
fail_message => "size: " & Natural'Image (Plexlog.Dir_Stack.Size (Stack)));
Plexlog.Dir_Stack.Push
(Stack => Stack,
Path => "testdata");
test.assert
(check => Plexlog.Dir_Stack.Size (Stack) = 1,
pass_message => "size: " & Natural'Image (Plexlog.Dir_Stack.Size (Stack)),
fail_message => "size: " & Natural'Image (Plexlog.Dir_Stack.Size (Stack)));
Plexlog.Dir_Stack.Push
(Stack => Stack,
Path => "init");
test.assert
(check => Plexlog.Dir_Stack.Size (Stack) = 2,
pass_message => "size: " & Natural'Image (Plexlog.Dir_Stack.Size (Stack)),
fail_message => "size: " & Natural'Image (Plexlog.Dir_Stack.Size (Stack)));
Plexlog.Dir_Stack.Pop (Stack);
test.assert
(check => Plexlog.Dir_Stack.Size (Stack) = 1,
pass_message => "size: " & Natural'Image (Plexlog.Dir_Stack.Size (Stack)),
fail_message => "size: " & Natural'Image (Plexlog.Dir_Stack.Size (Stack)));
Plexlog.Dir_Stack.Pop (Stack);
test.assert
(check => Plexlog.Dir_Stack.Size (Stack) = 0,
pass_message => "size: " & Natural'Image (Plexlog.Dir_Stack.Size (Stack)),
fail_message => "size: " & Natural'Image (Plexlog.Dir_Stack.Size (Stack)));
Plexlog.Dir_Stack.Push
(Stack => Stack,
Path => "testdata");
test.assert
(check => Plexlog.Dir_Stack.Size (Stack) = 1,
pass_message => "size: " & Natural'Image (Plexlog.Dir_Stack.Size (Stack)),
fail_message => "size: " & Natural'Image (Plexlog.Dir_Stack.Size (Stack)));
Plexlog.Dir_Stack.Push
(Stack => Stack,
Path => "init");
test.assert
(check => Plexlog.Dir_Stack.Size (Stack) = 2,
pass_message => "size: " & Natural'Image (Plexlog.Dir_Stack.Size (Stack)),
fail_message => "size: " & Natural'Image (Plexlog.Dir_Stack.Size (Stack)));
Plexlog.Dir_Stack.Pop (Stack);
test.assert
(check => Plexlog.Dir_Stack.Size (Stack) = 1,
pass_message => "size: " & Natural'Image (Plexlog.Dir_Stack.Size (Stack)),
fail_message => "size: " & Natural'Image (Plexlog.Dir_Stack.Size (Stack)));
Plexlog.Dir_Stack.Pop (Stack);
test.assert
(check => Plexlog.Dir_Stack.Size (Stack) = 0,
pass_message => "size: " & Natural'Image (Plexlog.Dir_Stack.Size (Stack)),
fail_message => "size: " & Natural'Image (Plexlog.Dir_Stack.Size (Stack)));
end t_dir1;
|
niechaojun/Amass | Ada | 1,366 | ads | -- Copyright 2017 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 = "HackerTarget"
type = "api"
function start()
setratelimit(2)
end
function vertical(ctx, domain)
scrape(ctx, {url=buildurl(domain)})
end
function buildurl(domain)
return "http://api.hackertarget.com/hostsearch/?q=" .. domain
end
function asn(ctx, addr)
local c
local cfg = datasrc_config()
local resp
local aurl = asnurl(addr)
-- Check if the response data is in the graph database
if (cfg and cfg.ttl ~= nil and cfg.ttl > 0) then
resp = obtain_response(aurl, cfg.ttl)
end
if (resp == nil or resp == "") then
local err
resp, err = request({url=aurl})
if (err ~= nil and err ~= "") then
return
end
if (cfg and cfg.ttl ~= nil and cfg.ttl > 0) then
cache_response(aurl, resp)
end
end
local j = json.decode("{\"results\": [" .. resp .. "]}")
if (j == nil or #(j.results) < 4) then
return
end
newasn(ctx, {
['addr']=addr,
asn=tonumber(j.results[2]),
prefix=j.results[3],
desc=j.results[4],
})
end
function asnurl(addr)
return "https://api.hackertarget.com/aslookup/?q=" .. addr
end
|
annexi-strayline/AURA | Ada | 6,002 | adb | ------------------------------------------------------------------------------
-- --
-- Ada User Repository Annex (AURA) --
-- ANNEXI-STRAYLINE Reference Implementation --
-- --
-- Core --
-- --
-- ------------------------------------------------------------------------ --
-- --
-- Copyright (C) 2020, ANNEXI-STRAYLINE Trans-Human Ltd. --
-- All rights reserved. --
-- --
-- Original Contributors: --
-- * Richard Wai (ANNEXI-STRAYLINE) --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions are --
-- met: --
-- --
-- * Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- --
-- * Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in --
-- the documentation and/or other materials provided with the --
-- distribution. --
-- --
-- * Neither the name of the copyright holder nor the names of its --
-- contributors may be used to endorse or promote products derived --
-- from this software without specific prior written permission. --
-- --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A --
-- PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
-- OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT --
-- LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, --
-- DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY --
-- THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT --
-- (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE --
-- OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
-- --
------------------------------------------------------------------------------
with Ada.Containers;
with Ada.Strings.Unbounded;
with Registrar.Registry;
with Registrar.Registration;
with Registrar.Subsystems;
with Registrar.Executive.Subsystems_Request;
package body Registrar.Executive.Library_Units_Request is
-----------
-- Image --
-----------
function Image (Order: Library_Units_Request_Order)
return String
is
use Ada.Strings.Unbounded;
use type Ada.Containers.Count_Type;
Image_String: Unbounded_String;
begin
Set_Unbounded_String
(Target => Image_String,
Source => "[Library_Units_Request_Order]" & New_Line
& "Requested Units:");
if Order.Requested_Units.Length = 0 then
Append (Source => Image_String,
New_Item => " NONE");
else
for Unit of Order.Requested_Units loop
Append (Source => Image_String,
New_Item => New_Line & "- " & Unit.Name.To_UTF8_String);
end loop;
end if;
return To_String (Image_String);
end Image;
-------------
-- Execute --
-------------
procedure Execute (Order: in out Library_Units_Request_Order) is
use Unit_Names;
use Registrar.Subsystems;
use Registrar.Library_Units;
use Registrar.Executive.Subsystems_Request;
package All_Library_Units renames Registrar.Registry.All_Library_Units;
SS_Req_Order: Subsystems_Request_Order;
SS_Reqs : Subsystem_Sets.Set
renames SS_Req_Order.Requested_Subsystems;
Requested_Units: Library_Unit_Sets.Set renames Order.Requested_Units;
begin
pragma Assert (not Order.Requested_Units.Is_Empty);
SS_Req_Order.Tracker := Registration.Entry_Progress'Access;
-- Build the Subsystem request set
for Unit of Order.Requested_Units loop
pragma Assert (Unit.State = Requested);
declare
SS_Request: Subsystem (AURA => True);
begin
SS_Request.Name := Unit_Name (Unit.Name.Subsystem_Name);
SS_Request.State := Requested;
SS_Reqs.Include (SS_Request);
end;
end loop;
-- Submit the subsystem requests
SS_Req_Order.Tracker.Increment_Total_Items;
Workers.Enqueue_Order (SS_Req_Order);
-- Include the unit requests
All_Library_Units.Union (Requested_Units);
end Execute;
end Registrar.Executive.Library_Units_Request;
|
reznikmm/matreshka | Ada | 3,388 | ads | ------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- Web Framework --
-- --
-- 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$
------------------------------------------------------------------------------
package ESAPI is
pragma Pure;
end ESAPI;
|
reznikmm/matreshka | Ada | 5,031 | ads | ------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- Ada Modeling Framework --
-- --
-- Runtime Library Component --
-- --
------------------------------------------------------------------------------
-- --
-- Copyright © 2012, Vadim Godunko <[email protected]> --
-- All rights reserved. --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions --
-- are met: --
-- --
-- * Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- --
-- * Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in the --
-- documentation and/or other materials provided with the distribution. --
-- --
-- * Neither the name of the Vadim Godunko, IE nor the names of its --
-- contributors may be used to endorse or promote products derived from --
-- this software without specific prior written permission. --
-- --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR --
-- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
-- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED --
-- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR --
-- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF --
-- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING --
-- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS --
-- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
-- --
------------------------------------------------------------------------------
-- $Revision$ $Date$
------------------------------------------------------------------------------
-- This file is generated, don't edit it.
------------------------------------------------------------------------------
with AMF.Generic_Collections;
package AMF.Utp.Test_Contexts.Collections is
pragma Preelaborate;
package Utp_Test_Context_Collections is
new AMF.Generic_Collections
(Utp_Test_Context,
Utp_Test_Context_Access);
type Set_Of_Utp_Test_Context is
new Utp_Test_Context_Collections.Set with null record;
Empty_Set_Of_Utp_Test_Context : constant Set_Of_Utp_Test_Context;
type Ordered_Set_Of_Utp_Test_Context is
new Utp_Test_Context_Collections.Ordered_Set with null record;
Empty_Ordered_Set_Of_Utp_Test_Context : constant Ordered_Set_Of_Utp_Test_Context;
type Bag_Of_Utp_Test_Context is
new Utp_Test_Context_Collections.Bag with null record;
Empty_Bag_Of_Utp_Test_Context : constant Bag_Of_Utp_Test_Context;
type Sequence_Of_Utp_Test_Context is
new Utp_Test_Context_Collections.Sequence with null record;
Empty_Sequence_Of_Utp_Test_Context : constant Sequence_Of_Utp_Test_Context;
private
Empty_Set_Of_Utp_Test_Context : constant Set_Of_Utp_Test_Context
:= (Utp_Test_Context_Collections.Set with null record);
Empty_Ordered_Set_Of_Utp_Test_Context : constant Ordered_Set_Of_Utp_Test_Context
:= (Utp_Test_Context_Collections.Ordered_Set with null record);
Empty_Bag_Of_Utp_Test_Context : constant Bag_Of_Utp_Test_Context
:= (Utp_Test_Context_Collections.Bag with null record);
Empty_Sequence_Of_Utp_Test_Context : constant Sequence_Of_Utp_Test_Context
:= (Utp_Test_Context_Collections.Sequence with null record);
end AMF.Utp.Test_Contexts.Collections;
|
caqg/linux-home | Ada | 28,826 | adb | -- generated parser support file.
-- command line: wisitoken-bnf-generate.exe --generate LR1 Ada_Emacs re2c PROCESS text_rep ada.wy
--
-- Copyright (C) 2013 - 2019 Free Software Foundation, Inc.
-- This program is free software; you can redistribute it and/or
-- modify it under the terms of the GNU General Public License as
-- published by the Free Software Foundation; either version 3, or (at
-- your option) any later version.
--
-- This software 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 GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
with Ada_Process_Actions; use Ada_Process_Actions;
with WisiToken.Lexer.re2c;
with ada_re2c_c;
package body Ada_Process_LR1_Main is
package Lexer is new WisiToken.Lexer.re2c
(ada_re2c_c.New_Lexer,
ada_re2c_c.Free_Lexer,
ada_re2c_c.Reset_Lexer,
ada_re2c_c.Next_Token);
procedure Create_Parser
(Parser : out WisiToken.Parse.LR.Parser.Parser;
Language_Fixes : in WisiToken.Parse.LR.Parser.Language_Fixes_Access;
Language_Matching_Begin_Tokens : in WisiToken.Parse.LR.Parser.Language_Matching_Begin_Tokens_Access;
Language_String_ID_Set : in WisiToken.Parse.LR.Parser.Language_String_ID_Set_Access;
Trace : not null access WisiToken.Trace'Class;
User_Data : in WisiToken.Syntax_Trees.User_Data_Access;
Text_Rep_File_Name : in String)
is
use WisiToken.Parse.LR;
McKenzie_Param : constant McKenzie_Param_Type :=
(First_Terminal => 3,
Last_Terminal => 108,
First_Nonterminal => 109,
Last_Nonterminal => 333,
Insert =>
(4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 2, 4, 4, 4, 4, 4, 4, 4, 4, 3, 4, 4, 4, 4, 4, 4, 4, 2, 4, 4, 4, 4, 4, 4,
4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4),
Delete =>
(4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
4, 4, 1, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4),
Push_Back =>
(2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2),
Undo_Reduce =>
(2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 0, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 0, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 0, 0, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2),
Minimal_Complete_Cost_Delta => -3,
Fast_Forward => 2,
Matching_Begin => 3,
Ignore_Check_Fail => 2,
Task_Count => 0,
Check_Limit => 4,
Check_Delta_Limit => 100,
Enqueue_Limit => 58000);
function Actions return WisiToken.Parse.LR.Semantic_Action_Array_Arrays.Vector
is begin
return Acts : WisiToken.Parse.LR.Semantic_Action_Array_Arrays.Vector do
Acts.Set_First_Last (109, 333);
Acts (113).Set_First_Last (0, 0);
Acts (113)(0) := (abstract_subprogram_declaration_0'Access, null);
Acts (114).Set_First_Last (0, 1);
Acts (114)(0) := (accept_statement_0'Access, accept_statement_0_check'Access);
Acts (114)(1) := (accept_statement_1'Access, null);
Acts (115).Set_First_Last (0, 2);
Acts (115)(0) := (access_definition_0'Access, null);
Acts (115)(1) := (access_definition_1'Access, null);
Acts (115)(2) := (access_definition_2'Access, null);
Acts (116).Set_First_Last (0, 1);
Acts (116)(0) := (actual_parameter_part_0'Access, null);
Acts (116)(1) := (actual_parameter_part_1'Access, null);
Acts (118).Set_First_Last (0, 5);
Acts (118)(0) := (aggregate_0'Access, null);
Acts (118)(1) := (aggregate_1'Access, null);
Acts (118)(3) := (aggregate_3'Access, null);
Acts (118)(4) := (aggregate_4'Access, null);
Acts (118)(5) := (aggregate_5'Access, null);
Acts (121).Set_First_Last (0, 1);
Acts (121)(0) := (array_type_definition_0'Access, null);
Acts (121)(1) := (array_type_definition_1'Access, null);
Acts (122).Set_First_Last (0, 3);
Acts (122)(0) := (aspect_clause_0'Access, null);
Acts (123).Set_First_Last (0, 1);
Acts (123)(0) := (aspect_specification_opt_0'Access, null);
Acts (124).Set_First_Last (0, 0);
Acts (124)(0) := (assignment_statement_0'Access, null);
Acts (125).Set_First_Last (0, 6);
Acts (125)(0) := (association_opt_0'Access, null);
Acts (125)(2) := (association_opt_2'Access, null);
Acts (125)(3) := (association_opt_3'Access, null);
Acts (125)(4) := (association_opt_4'Access, null);
Acts (125)(5) := (association_opt_5'Access, null);
Acts (127).Set_First_Last (0, 0);
Acts (127)(0) := (asynchronous_select_0'Access, null);
Acts (128).Set_First_Last (0, 0);
Acts (128)(0) := (at_clause_0'Access, null);
Acts (132).Set_First_Last (0, 0);
Acts (132)(0) := (block_label_0'Access, block_label_0_check'Access);
Acts (133).Set_First_Last (0, 1);
Acts (133)(0) := (null, block_label_opt_0_check'Access);
Acts (133)(1) := (null, null);
Acts (134).Set_First_Last (0, 1);
Acts (134)(0) := (block_statement_0'Access, block_statement_0_check'Access);
Acts (134)(1) := (block_statement_1'Access, block_statement_1_check'Access);
Acts (137).Set_First_Last (0, 0);
Acts (137)(0) := (case_expression_0'Access, null);
Acts (138).Set_First_Last (0, 0);
Acts (138)(0) := (case_expression_alternative_0'Access, null);
Acts (139).Set_First_Last (0, 1);
Acts (139)(0) := (case_expression_alternative_list_0'Access, null);
Acts (140).Set_First_Last (0, 0);
Acts (140)(0) := (case_statement_0'Access, null);
Acts (141).Set_First_Last (0, 0);
Acts (141)(0) := (case_statement_alternative_0'Access, null);
Acts (142).Set_First_Last (0, 1);
Acts (142)(0) := (case_statement_alternative_list_0'Access, null);
Acts (143).Set_First_Last (0, 4);
Acts (143)(2) := (compilation_unit_2'Access, null);
Acts (144).Set_First_Last (0, 1);
Acts (144)(0) := (compilation_unit_list_0'Access, null);
Acts (144)(1) := (compilation_unit_list_1'Access, compilation_unit_list_1_check'Access);
Acts (145).Set_First_Last (0, 0);
Acts (145)(0) := (component_clause_0'Access, null);
Acts (147).Set_First_Last (0, 1);
Acts (147)(0) := (component_declaration_0'Access, null);
Acts (147)(1) := (component_declaration_1'Access, null);
Acts (150).Set_First_Last (0, 4);
Acts (150)(4) := (component_list_4'Access, null);
Acts (153).Set_First_Last (0, 0);
Acts (153)(0) := (conditional_entry_call_0'Access, null);
Acts (158).Set_First_Last (0, 16);
Acts (158)(9) := (declaration_9'Access, null);
Acts (162).Set_First_Last (0, 1);
Acts (162)(0) := (delay_statement_0'Access, null);
Acts (162)(1) := (delay_statement_1'Access, null);
Acts (163).Set_First_Last (0, 1);
Acts (163)(0) := (derived_type_definition_0'Access, null);
Acts (163)(1) := (derived_type_definition_1'Access, null);
Acts (170).Set_First_Last (0, 2);
Acts (170)(1) := (discriminant_part_opt_1'Access, null);
Acts (173).Set_First_Last (0, 0);
Acts (173)(0) := (elsif_expression_item_0'Access, null);
Acts (174).Set_First_Last (0, 1);
Acts (174)(0) := (elsif_expression_list_0'Access, null);
Acts (175).Set_First_Last (0, 0);
Acts (175)(0) := (elsif_statement_item_0'Access, null);
Acts (176).Set_First_Last (0, 1);
Acts (176)(0) := (elsif_statement_list_0'Access, null);
Acts (177).Set_First_Last (0, 0);
Acts (177)(0) := (entry_body_0'Access, entry_body_0_check'Access);
Acts (178).Set_First_Last (0, 1);
Acts (178)(0) := (entry_body_formal_part_0'Access, null);
Acts (180).Set_First_Last (0, 1);
Acts (180)(0) := (entry_declaration_0'Access, null);
Acts (180)(1) := (entry_declaration_1'Access, null);
Acts (183).Set_First_Last (0, 0);
Acts (183)(0) := (enumeration_representation_clause_0'Access, null);
Acts (184).Set_First_Last (0, 0);
Acts (184)(0) := (enumeration_type_definition_0'Access, null);
Acts (187).Set_First_Last (0, 0);
Acts (187)(0) := (exception_declaration_0'Access, null);
Acts (188).Set_First_Last (0, 1);
Acts (188)(0) := (exception_handler_0'Access, null);
Acts (188)(1) := (exception_handler_1'Access, null);
Acts (189).Set_First_Last (0, 2);
Acts (189)(0) := (exception_handler_list_0'Access, null);
Acts (191).Set_First_Last (0, 1);
Acts (191)(0) := (exit_statement_0'Access, null);
Acts (191)(1) := (exit_statement_1'Access, null);
Acts (194).Set_First_Last (0, 0);
Acts (194)(0) := (expression_function_declaration_0'Access, null);
Acts (195).Set_First_Last (0, 1);
Acts (195)(0) := (extended_return_object_declaration_0'Access, null);
Acts (195)(1) := (extended_return_object_declaration_1'Access, null);
Acts (197).Set_First_Last (0, 1);
Acts (197)(0) := (extended_return_statement_0'Access, null);
Acts (197)(1) := (extended_return_statement_1'Access, null);
Acts (199).Set_First_Last (0, 3);
Acts (199)(0) := (formal_object_declaration_0'Access, null);
Acts (199)(1) := (formal_object_declaration_1'Access, null);
Acts (199)(2) := (formal_object_declaration_2'Access, null);
Acts (199)(3) := (formal_object_declaration_3'Access, null);
Acts (200).Set_First_Last (0, 0);
Acts (200)(0) := (formal_part_0'Access, null);
Acts (201).Set_First_Last (0, 3);
Acts (201)(0) := (formal_subprogram_declaration_0'Access, null);
Acts (201)(1) := (formal_subprogram_declaration_1'Access, null);
Acts (201)(2) := (formal_subprogram_declaration_2'Access, null);
Acts (201)(3) := (formal_subprogram_declaration_3'Access, null);
Acts (202).Set_First_Last (0, 2);
Acts (202)(0) := (formal_type_declaration_0'Access, null);
Acts (202)(1) := (formal_type_declaration_1'Access, null);
Acts (202)(2) := (formal_type_declaration_2'Access, null);
Acts (204).Set_First_Last (0, 1);
Acts (204)(0) := (formal_derived_type_definition_0'Access, null);
Acts (204)(1) := (formal_derived_type_definition_1'Access, null);
Acts (205).Set_First_Last (0, 0);
Acts (205)(0) := (formal_package_declaration_0'Access, null);
Acts (207).Set_First_Last (0, 2);
Acts (207)(0) := (full_type_declaration_0'Access, null);
Acts (208).Set_First_Last (0, 0);
Acts (208)(0) := (function_specification_0'Access, function_specification_0_check'Access);
Acts (211).Set_First_Last (0, 1);
Acts (211)(0) := (generic_formal_part_0'Access, null);
Acts (211)(1) := (generic_formal_part_1'Access, null);
Acts (214).Set_First_Last (0, 2);
Acts (214)(0) := (generic_instantiation_0'Access, null);
Acts (214)(1) := (generic_instantiation_1'Access, null);
Acts (214)(2) := (generic_instantiation_2'Access, null);
Acts (215).Set_First_Last (0, 0);
Acts (215)(0) := (generic_package_declaration_0'Access, null);
Acts (216).Set_First_Last (0, 2);
Acts (216)(0) := (generic_renaming_declaration_0'Access, null);
Acts (216)(1) := (generic_renaming_declaration_1'Access, null);
Acts (216)(2) := (generic_renaming_declaration_2'Access, null);
Acts (217).Set_First_Last (0, 0);
Acts (217)(0) := (generic_subprogram_declaration_0'Access, null);
Acts (218).Set_First_Last (0, 0);
Acts (218)(0) := (goto_label_0'Access, null);
Acts (219).Set_First_Last (0, 1);
Acts (219)(0) := (handled_sequence_of_statements_0'Access, null);
Acts (220).Set_First_Last (0, 1);
Acts (220)(0) := (identifier_list_0'Access, null);
Acts (220)(1) := (identifier_list_1'Access, null);
Acts (221).Set_First_Last (0, 1);
Acts (221)(0) := (null, identifier_opt_0_check'Access);
Acts (221)(1) := (null, null);
Acts (222).Set_First_Last (0, 3);
Acts (222)(0) := (if_expression_0'Access, null);
Acts (222)(1) := (if_expression_1'Access, null);
Acts (222)(2) := (if_expression_2'Access, null);
Acts (222)(3) := (if_expression_3'Access, null);
Acts (223).Set_First_Last (0, 3);
Acts (223)(0) := (if_statement_0'Access, null);
Acts (223)(1) := (if_statement_1'Access, null);
Acts (223)(2) := (if_statement_2'Access, null);
Acts (223)(3) := (if_statement_3'Access, null);
Acts (224).Set_First_Last (0, 1);
Acts (224)(0) := (incomplete_type_declaration_0'Access, null);
Acts (224)(1) := (incomplete_type_declaration_1'Access, null);
Acts (225).Set_First_Last (0, 0);
Acts (225)(0) := (index_constraint_0'Access, null);
Acts (228).Set_First_Last (0, 1);
Acts (228)(0) := (interface_list_0'Access, null);
Acts (228)(1) := (interface_list_1'Access, null);
Acts (230).Set_First_Last (0, 1);
Acts (230)(0) := (iteration_scheme_0'Access, null);
Acts (230)(1) := (iteration_scheme_1'Access, null);
Acts (231).Set_First_Last (0, 5);
Acts (231)(2) := (iterator_specification_2'Access, null);
Acts (231)(5) := (iterator_specification_5'Access, null);
Acts (233).Set_First_Last (0, 1);
Acts (233)(0) := (loop_statement_0'Access, loop_statement_0_check'Access);
Acts (233)(1) := (loop_statement_1'Access, loop_statement_1_check'Access);
Acts (240).Set_First_Last (0, 8);
Acts (240)(0) := (name_0'Access, null);
Acts (240)(1) := (name_1'Access, null);
Acts (240)(2) := (null, name_2_check'Access);
Acts (240)(3) := (null, null);
Acts (240)(4) := (null, null);
Acts (240)(5) := (name_5'Access, name_5_check'Access);
Acts (240)(6) := (null, null);
Acts (240)(7) := (null, name_7_check'Access);
Acts (240)(8) := (null, null);
Acts (241).Set_First_Last (0, 1);
Acts (241)(0) := (null, name_opt_0_check'Access);
Acts (241)(1) := (null, null);
Acts (243).Set_First_Last (0, 3);
Acts (243)(0) := (null_exclusion_opt_name_type_0'Access, null);
Acts (243)(1) := (null_exclusion_opt_name_type_1'Access, null);
Acts (243)(2) := (null_exclusion_opt_name_type_2'Access, null);
Acts (243)(3) := (null_exclusion_opt_name_type_3'Access, null);
Acts (244).Set_First_Last (0, 0);
Acts (244)(0) := (null_procedure_declaration_0'Access, null);
Acts (245).Set_First_Last (0, 7);
Acts (245)(0) := (object_declaration_0'Access, null);
Acts (245)(1) := (object_declaration_1'Access, null);
Acts (245)(2) := (object_declaration_2'Access, null);
Acts (245)(3) := (object_declaration_3'Access, null);
Acts (245)(4) := (object_declaration_4'Access, null);
Acts (245)(5) := (object_declaration_5'Access, null);
Acts (246).Set_First_Last (0, 2);
Acts (246)(0) := (object_renaming_declaration_0'Access, null);
Acts (246)(1) := (object_renaming_declaration_1'Access, null);
Acts (246)(2) := (object_renaming_declaration_2'Access, null);
Acts (247).Set_First_Last (0, 2);
Acts (247)(0) := (overriding_indicator_opt_0'Access, null);
Acts (247)(1) := (overriding_indicator_opt_1'Access, null);
Acts (248).Set_First_Last (0, 1);
Acts (248)(0) := (package_body_0'Access, package_body_0_check'Access);
Acts (248)(1) := (package_body_1'Access, package_body_1_check'Access);
Acts (249).Set_First_Last (0, 0);
Acts (249)(0) := (package_body_stub_0'Access, null);
Acts (250).Set_First_Last (0, 0);
Acts (250)(0) := (package_declaration_0'Access, null);
Acts (251).Set_First_Last (0, 0);
Acts (251)(0) := (package_renaming_declaration_0'Access, null);
Acts (252).Set_First_Last (0, 1);
Acts (252)(0) := (package_specification_0'Access, package_specification_0_check'Access);
Acts (252)(1) := (package_specification_1'Access, package_specification_1_check'Access);
Acts (253).Set_First_Last (0, 1);
Acts (253)(0) := (parameter_and_result_profile_0'Access, null);
Acts (255).Set_First_Last (0, 4);
Acts (255)(0) := (parameter_specification_0'Access, null);
Acts (255)(1) := (parameter_specification_1'Access, null);
Acts (255)(2) := (parameter_specification_2'Access, null);
Acts (255)(3) := (parameter_specification_3'Access, null);
Acts (257).Set_First_Last (0, 1);
Acts (257)(0) := (paren_expression_0'Access, null);
Acts (258).Set_First_Last (0, 2);
Acts (258)(0) := (pragma_g_0'Access, null);
Acts (258)(1) := (pragma_g_1'Access, null);
Acts (258)(2) := (pragma_g_2'Access, null);
Acts (259).Set_First_Last (0, 4);
Acts (259)(0) := (primary_0'Access, null);
Acts (259)(2) := (primary_2'Access, null);
Acts (259)(4) := (primary_4'Access, null);
Acts (260).Set_First_Last (0, 0);
Acts (260)(0) := (private_extension_declaration_0'Access, null);
Acts (261).Set_First_Last (0, 0);
Acts (261)(0) := (private_type_declaration_0'Access, null);
Acts (262).Set_First_Last (0, 0);
Acts (262)(0) := (procedure_call_statement_0'Access, null);
Acts (263).Set_First_Last (0, 0);
Acts (263)(0) := (procedure_specification_0'Access, procedure_specification_0_check'Access);
Acts (265).Set_First_Last (0, 0);
Acts (265)(0) := (protected_body_0'Access, protected_body_0_check'Access);
Acts (266).Set_First_Last (0, 0);
Acts (266)(0) := (protected_body_stub_0'Access, null);
Acts (267).Set_First_Last (0, 1);
Acts (267)(0) := (protected_definition_0'Access, protected_definition_0_check'Access);
Acts (267)(1) := (protected_definition_1'Access, protected_definition_1_check'Access);
Acts (272).Set_First_Last (0, 1);
Acts (272)(0) := (protected_type_declaration_0'Access, protected_type_declaration_0_check'Access);
Acts (272)(1) := (protected_type_declaration_1'Access, protected_type_declaration_1_check'Access);
Acts (273).Set_First_Last (0, 0);
Acts (273)(0) := (qualified_expression_0'Access, null);
Acts (274).Set_First_Last (0, 0);
Acts (274)(0) := (quantified_expression_0'Access, null);
Acts (276).Set_First_Last (0, 1);
Acts (276)(0) := (raise_expression_0'Access, null);
Acts (277).Set_First_Last (0, 2);
Acts (277)(0) := (raise_statement_0'Access, null);
Acts (277)(1) := (raise_statement_1'Access, null);
Acts (277)(2) := (raise_statement_2'Access, null);
Acts (278).Set_First_Last (0, 2);
Acts (278)(0) := (range_g_0'Access, null);
Acts (281).Set_First_Last (0, 1);
Acts (281)(0) := (record_definition_0'Access, null);
Acts (282).Set_First_Last (0, 0);
Acts (282)(0) := (record_representation_clause_0'Access, null);
Acts (291).Set_First_Last (0, 1);
Acts (291)(0) := (requeue_statement_0'Access, null);
Acts (291)(1) := (requeue_statement_1'Access, null);
Acts (292).Set_First_Last (0, 1);
Acts (292)(0) := (result_profile_0'Access, null);
Acts (292)(1) := (result_profile_1'Access, null);
Acts (294).Set_First_Last (0, 3);
Acts (294)(0) := (selected_component_0'Access, selected_component_0_check'Access);
Acts (294)(1) := (selected_component_1'Access, null);
Acts (294)(2) := (selected_component_2'Access, selected_component_2_check'Access);
Acts (294)(3) := (selected_component_3'Access, null);
Acts (295).Set_First_Last (0, 1);
Acts (295)(0) := (selective_accept_0'Access, null);
Acts (295)(1) := (selective_accept_1'Access, null);
Acts (296).Set_First_Last (0, 5);
Acts (296)(0) := (select_alternative_0'Access, null);
Acts (296)(1) := (select_alternative_1'Access, null);
Acts (296)(2) := (select_alternative_2'Access, null);
Acts (296)(4) := (select_alternative_4'Access, null);
Acts (297).Set_First_Last (0, 1);
Acts (297)(0) := (select_alternative_list_0'Access, null);
Acts (297)(1) := (select_alternative_list_1'Access, null);
Acts (303).Set_First_Last (0, 0);
Acts (303)(0) := (simple_return_statement_0'Access, null);
Acts (304).Set_First_Last (0, 10);
Acts (304)(0) := (simple_statement_0'Access, null);
Acts (304)(3) := (simple_statement_3'Access, null);
Acts (304)(8) := (simple_statement_8'Access, null);
Acts (305).Set_First_Last (0, 1);
Acts (305)(0) := (single_protected_declaration_0'Access, single_protected_declaration_0_check'Access);
Acts (305)(1) := (single_protected_declaration_1'Access, single_protected_declaration_1_check'Access);
Acts (306).Set_First_Last (0, 2);
Acts (306)(0) := (single_task_declaration_0'Access, single_task_declaration_0_check'Access);
Acts (306)(1) := (single_task_declaration_1'Access, single_task_declaration_1_check'Access);
Acts (306)(2) := (single_task_declaration_2'Access, null);
Acts (308).Set_First_Last (0, 0);
Acts (308)(0) := (subprogram_body_0'Access, subprogram_body_0_check'Access);
Acts (309).Set_First_Last (0, 0);
Acts (309)(0) := (subprogram_body_stub_0'Access, null);
Acts (310).Set_First_Last (0, 0);
Acts (310)(0) := (subprogram_declaration_0'Access, null);
Acts (311).Set_First_Last (0, 2);
Acts (311)(0) := (subprogram_default_0'Access, null);
Acts (312).Set_First_Last (0, 0);
Acts (312)(0) := (subprogram_renaming_declaration_0'Access, null);
Acts (313).Set_First_Last (0, 1);
Acts (313)(0) := (null, subprogram_specification_0_check'Access);
Acts (313)(1) := (null, subprogram_specification_1_check'Access);
Acts (314).Set_First_Last (0, 0);
Acts (314)(0) := (subtype_declaration_0'Access, null);
Acts (315).Set_First_Last (0, 3);
Acts (315)(0) := (subtype_indication_0'Access, null);
Acts (315)(1) := (subtype_indication_1'Access, null);
Acts (315)(2) := (subtype_indication_2'Access, null);
Acts (315)(3) := (subtype_indication_3'Access, null);
Acts (316).Set_First_Last (0, 0);
Acts (316)(0) := (subunit_0'Access, null);
Acts (317).Set_First_Last (0, 0);
Acts (317)(0) := (task_body_0'Access, task_body_0_check'Access);
Acts (318).Set_First_Last (0, 0);
Acts (318)(0) := (task_body_stub_0'Access, null);
Acts (319).Set_First_Last (0, 1);
Acts (319)(0) := (task_definition_0'Access, null);
Acts (319)(1) := (task_definition_1'Access, null);
Acts (320).Set_First_Last (0, 2);
Acts (320)(0) := (task_type_declaration_0'Access, task_type_declaration_0_check'Access);
Acts (320)(1) := (task_type_declaration_1'Access, task_type_declaration_1_check'Access);
Acts (320)(2) := (task_type_declaration_2'Access, null);
Acts (324).Set_First_Last (0, 0);
Acts (324)(0) := (timed_entry_call_0'Access, null);
Acts (328).Set_First_Last (0, 0);
Acts (328)(0) := (variant_part_0'Access, null);
Acts (329).Set_First_Last (0, 1);
Acts (329)(0) := (variant_list_0'Access, null);
Acts (330).Set_First_Last (0, 0);
Acts (330)(0) := (variant_0'Access, null);
Acts (332).Set_First_Last (0, 2);
Acts (332)(0) := (use_clause_0'Access, null);
Acts (332)(1) := (use_clause_1'Access, null);
Acts (332)(2) := (use_clause_2'Access, null);
Acts (333).Set_First_Last (0, 3);
Acts (333)(0) := (with_clause_0'Access, null);
Acts (333)(1) := (with_clause_1'Access, null);
Acts (333)(2) := (with_clause_2'Access, null);
Acts (333)(3) := (with_clause_3'Access, null);
end return;
end Actions;
Table : constant Parse_Table_Ptr := Get_Text_Rep
(Text_Rep_File_Name, McKenzie_Param, Actions);
begin
WisiToken.Parse.LR.Parser.New_Parser
(Parser,
Trace,
Lexer.New_Lexer (Trace.Descriptor),
Table,
Language_Fixes,
Language_Matching_Begin_Tokens,
Language_String_ID_Set,
User_Data,
Max_Parallel => 15,
Terminate_Same_State => True);
end Create_Parser;
end Ada_Process_LR1_Main;
|
strenkml/EE368 | Ada | 1,615 | adb |
package body Util is
function "+"(a, b : Cost_Type) return Cost_Type is
begin
if a > Cost_Type'Last - b then
return Cost_Type'Last;
else
return Cost_Type(Long_Integer(a) + Long_Integer(b));
end if;
end "+";
function Log2(n : Natural) return Natural is
i : Natural := n;
r : Natural := 0;
begin
while i > 0 loop
r := r + 1;
i := i / 2;
end loop;
return r;
end Log2;
function Log2(n : Long_Integer) return Natural is
i : Long_Integer := n;
r : Natural := 0;
begin
while i > 0 loop
r := r + 1;
i := i / 2;
end loop;
return r;
end Log2;
function Round_Power2(n : Natural) return Natural is
begin
return 2 ** Log2(n);
end Round_Power2;
function To_String(i : Integer) return String is
str : constant String := Integer'Image(i);
begin
if str(str'First) = ' ' then
return str(str'First + 1 .. str'Last);
else
return str;
end if;
end To_String;
function To_String(i : Long_Integer) return String is
str : constant String := Long_Integer'Image(i);
begin
if str(str'First) = ' ' then
return str(str'First + 1 .. str'Last);
else
return str;
end if;
end To_String;
function To_String(f : Long_Float) return String is
str : constant String := Long_Float'Image(f);
begin
if str(str'First) = ' ' then
return str(str'First + 1 .. str'Last);
else
return str;
end if;
end To_String;
end Util;
|
stcarrez/helios | Ada | 1,287 | ads | -- Hyperion API
-- Hyperion Monitoring API The monitoring agent is first registered so that the server knows it as well as its security key. Each host are then registered by a monitoring agent.
--
-- The version of the OpenAPI document: 1.0.0
-- Contact: [email protected]
--
-- NOTE: This package is auto generated by OpenAPI-Generator 4.1.0-SNAPSHOT.
-- https://openapi-generator.tech
-- Do not edit the class manually.
with Helios.Rest.Models;
with Swagger.Clients;
package Helios.Rest.Clients is
type Client_Type is new Swagger.Clients.Client_Type with null record;
-- Register a monitoring agent
-- Register a new monitoring agent in the system
procedure Register_Agent
(Client : in out Client_Type;
Name : in Swagger.UString;
Ip : in Swagger.UString;
Agent_Key : in Swagger.UString;
Result : out Helios.Rest.Models.Agent_Type);
-- Create a host
-- Register a new host in the monitoring system
procedure Create_Host
(Client : in out Client_Type;
Name : in Swagger.UString;
Ip : in Swagger.UString;
Host_Key : in Swagger.UString;
Agent_Key : in Swagger.UString;
Agent_Id : in Integer;
Result : out Helios.Rest.Models.Host_Type);
end Helios.Rest.Clients;
|
reznikmm/matreshka | Ada | 3,734 | 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.Office_Target_Frame_Attributes is
pragma Preelaborate;
type ODF_Office_Target_Frame_Attribute is limited interface
and XML.DOM.Attributes.DOM_Attribute;
type ODF_Office_Target_Frame_Attribute_Access is
access all ODF_Office_Target_Frame_Attribute'Class
with Storage_Size => 0;
end ODF.DOM.Office_Target_Frame_Attributes;
|
thierr26/ada-keystore | Ada | 1,751 | adb | -----------------------------------------------------------------------
-- akt-commands-set -- Set content in 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.
-----------------------------------------------------------------------
package body AKT.Commands.Set is
-- ------------------------------
-- Insert a new value in the keystore.
-- ------------------------------
overriding
procedure Execute (Command : in out Command_Type;
Name : in String;
Args : in Argument_List'Class;
Context : in out Context_Type) is
pragma Unreferenced (Command);
begin
-- Open keystore without use workers because we expect small data.
Context.Open_Keystore (Args, Use_Worker => False);
if Args.Get_Count /= Context.First_Arg + 1 then
AKT.Commands.Usage (Args, Context, Name);
else
Context.Wallet.Set (Name => Args.Get_Argument (Context.First_Arg),
Content => Args.Get_Argument (Context.First_Arg + 1));
end if;
end Execute;
end AKT.Commands.Set;
|
reznikmm/matreshka | Ada | 3,779 | ads | ------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- Web Framework --
-- --
-- Tools Component --
-- --
------------------------------------------------------------------------------
-- --
-- Copyright © 2012, Vadim Godunko <[email protected]> --
-- All rights reserved. --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions --
-- are met: --
-- --
-- * Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- --
-- * Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in the --
-- documentation and/or other materials provided with the distribution. --
-- --
-- * Neither the name of the Vadim Godunko, IE nor the names of its --
-- contributors may be used to endorse or promote products derived from --
-- this software without specific prior written permission. --
-- --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR --
-- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
-- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED --
-- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR --
-- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF --
-- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING --
-- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS --
-- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
-- --
------------------------------------------------------------------------------
-- $Revision$ $Date$
------------------------------------------------------------------------------
with League.Strings;
private package WSDL.Generator.Naming_Conventions is
function To_Ada_Identifier
(Item : League.Strings.Universal_String)
return League.Strings.Universal_String;
-- Converts identifier into Ada style.
function Plural
(Item : League.Strings.Universal_String)
return League.Strings.Universal_String;
-- Converts identifier into plural form.
end WSDL.Generator.Naming_Conventions;
|
burratoo/Acton | Ada | 1,585 | ads | ------------------------------------------------------------------------------------------
-- --
-- OAK COMPONENTS --
-- --
-- OAK.BROKERS --
-- --
-- Copyright (C) 2014-2021, Patrick Bernardi --
-- --
------------------------------------------------------------------------------------------
-- This package defines the types that define Oak's brokers. They are housed
-- together in this package together to prevent circular dependencies
-- among the Broker children.
-- Protected_Broker Broker that represents protected objects.
with Oak.Project_Support_Package; use Oak.Project_Support_Package;
package Oak.Brokers with Pure is
Protected_Id_Low_Bound : constant := 1;
Protected_Id_High_Bound : constant := Max_Protected_Agents;
type Protected_Id_With_No is mod Protected_Id_High_Bound + 1;
subtype Protected_Id is Protected_Id_With_No range
Protected_Id_Low_Bound .. Protected_Id_High_Bound;
No_Protected_Object : constant Protected_Id_With_No :=
Protected_Id_With_No'First;
end Oak.Brokers;
|
hfegran/efx32_ada_examples | Ada | 7,109 | adb | with Leds; use Leds;
with Interfaces.EFM32; use Interfaces.EFM32;
with Ada.Real_Time; use Ada.Real_Time;
package body Leds is
procedure Led_Init is
begin
CMU_Periph.CTRL.HFPERCLKEN := 1;
CMU_Periph.HFBUSCLKEN0.GPIO := 1;
GPIO_Periph.PA_MODEH.Arr(12) := PUSHPULL;
GPIO_Periph.PA_MODEH.Arr(13) := PUSHPULL;
GPIO_Periph.PA_MODEH.Arr(14) := PUSHPULL;
GPIO_Periph.PD_MODEL.Arr(6) := PUSHPULL;
GPIO_Periph.PF_MODEH.Arr(12) := PUSHPULL;
GPIO_Periph.PE_MODEH.Arr(12) := PUSHPULL;
Led_Set(LED0, Blue);
Led_Set(LED1, Green);
end Led_Init;
procedure Blink(LED: Led_No; Led_Color : Color; Duration : Time_Span) is
Timeout : Time := Clock;
begin
Led_Set(LED, Led_Color);
Timeout := Timeout + Duration/2;
delay until Timeout;
Timeout := Timeout + Duration/2;
delay until Timeout;
end Blink;
procedure GPIO_Set_Pin(Port : Port_Type; Pin : Pin_Type) is
begin
case Port is
when PA =>
GPIO_Periph.PA_DOUT.DOUT := GPIO_Periph.PA_DOUT.DOUT or
Shift_Left(16#0001#, Pin_Type'Pos(Pin));
when PB =>
GPIO_Periph.PB_DOUT.DOUT := GPIO_Periph.PB_DOUT.DOUT or
Shift_Left(16#0001#, Pin_Type'Pos(Pin));
when PC =>
GPIO_Periph.PC_DOUT.DOUT := GPIO_Periph.PC_DOUT.DOUT or
Shift_Left(16#0001#, Pin_Type'Pos(Pin));
when PD =>
GPIO_Periph.PD_DOUT.DOUT := GPIO_Periph.PD_DOUT.DOUT or
Shift_Left(16#0001#, Pin_Type'Pos(Pin));
when PE =>
GPIO_Periph.PE_DOUT.DOUT := GPIO_Periph.PE_DOUT.DOUT or
Shift_Left(16#0001#, Pin_Type'Pos(Pin));
when PF =>
GPIO_Periph.PF_DOUT.DOUT := GPIO_Periph.PF_DOUT.DOUT or
Shift_Left(16#0001#, Pin_Type'Pos(Pin));
end case;
end GPIO_Set_Pin;
procedure GPIO_Clr_Pin(Port : Port_Type; Pin : Pin_Type) is
begin
case Port is
when PA =>
GPIO_Periph.PA_DOUT.DOUT := GPIO_Periph.PA_DOUT.DOUT and
not Shift_Left(16#0001#, Pin_Type'Pos(Pin));
when PB =>
GPIO_Periph.PB_DOUT.DOUT := GPIO_Periph.PB_DOUT.DOUT and
not Shift_Left(16#0001#, Pin_Type'Pos(Pin));
when PC =>
GPIO_Periph.PC_DOUT.DOUT := GPIO_Periph.PC_DOUT.DOUT and
not Shift_Left(16#0001#, Pin_Type'Pos(Pin));
when PD =>
GPIO_Periph.PD_DOUT.DOUT := GPIO_Periph.PD_DOUT.DOUT and
not Shift_Left(16#0001#, Pin_Type'Pos(Pin));
when PE =>
GPIO_Periph.PE_DOUT.DOUT := GPIO_Periph.PE_DOUT.DOUT and
not Shift_Left(16#0001#, Pin_Type'Pos(Pin));
when PF =>
GPIO_Periph.PF_DOUT.DOUT := GPIO_Periph.PF_DOUT.DOUT and
not Shift_Left(16#0001#, Pin_Type'Pos(Pin));
end case;
end GPIO_Clr_Pin;
Procedure GPIO_Tgl_Pin(Port : Port_Type; Pin : Pin_Type) is
begin
case Port is
when PA =>
GPIO_Periph.PA_DOUTTGL.DOUTTGL := Shift_Left(16#0001#, Pin_Type'Pos(Pin));
when PB =>
GPIO_Periph.PB_DOUTTGL.DOUTTGL := Shift_Left(16#0001#, Pin_Type'Pos(Pin));
when PC =>
GPIO_Periph.PC_DOUTTGL.DOUTTGL := Shift_Left(16#0001#, Pin_Type'Pos(Pin));
when PD =>
GPIO_Periph.PD_DOUTTGL.DOUTTGL := Shift_Left(16#0001#, Pin_Type'Pos(Pin));
when PE =>
GPIO_Periph.PE_DOUTTGL.DOUTTGL := Shift_Left(16#0001#, Pin_Type'Pos(Pin));
when PF =>
GPIO_Periph.PF_DOUTTGL.DOUTTGL := Shift_Left(16#0001#, Pin_Type'Pos(Pin));
end case;
end GPIO_Tgl_Pin;
procedure Led_Set (LED : Led_No; Led_Color : Color) is
begin
case Led_Color is
when Blue =>
case LED is
when LED0 =>
GPIO_Set_Pin(PA, P12);
GPIO_Set_Pin(PA, P14);
GPIO_Clr_Pin(PA, P13);
when LED1 =>
GPIO_Set_Pin(PD, P6);
GPIO_Set_Pin(PF, P12);
GPIO_Clr_Pin(PE, P12);
end case;
when Green =>
case LED is
when LED0 =>
GPIO_Set_Pin(PA, P12);
GPIO_Clr_Pin(PA, P14);
GPIO_Set_Pin(PA, P13);
when LED1 =>
GPIO_Set_Pin(PD, P6);
GPIO_Clr_Pin(PF, P12);
GPIO_Set_Pin(PE, P12);
end case;
when Cyan =>
case LED is
when LED0 =>
GPIO_Set_Pin(PA, P12);
GPIO_Clr_Pin(PA, P14);
GPIO_Clr_Pin(PA, P13);
when LED1 =>
GPIO_Set_Pin(PD, P6);
GPIO_Clr_Pin(PF, P12);
GPIO_Clr_Pin(PE, P12);
end case;
when Red =>
case LED is
when LED0 =>
GPIO_Clr_Pin(PA, P12);
GPIO_Set_Pin(PA, P14);
GPIO_Set_Pin(PA, P13);
when LED1 =>
GPIO_Clr_Pin(PD, P6);
GPIO_Set_Pin(PF, P12);
GPIO_Set_Pin(PE, P12);
end case;
when Magenta =>
case LED is
when LED0 =>
GPIO_Clr_Pin(PA, P12);
GPIO_Set_Pin(PA, P14);
GPIO_Clr_Pin(PA, P13);
when LED1 =>
GPIO_Clr_Pin(PD, P6);
GPIO_Set_Pin(PF, P12);
GPIO_Clr_Pin(PE, P12);
end case;
when Yellow =>
case LED is
when LED0 =>
GPIO_Clr_Pin(PA, P12);
GPIO_Clr_Pin(PA, P14);
GPIO_Set_Pin(PA, P13);
when LED1 =>
GPIO_Clr_Pin(PD, P6);
GPIO_Clr_Pin(PF, P12);
GPIO_Set_Pin(PE, P12);
end case;
when White =>
case LED is
when LED0 =>
GPIO_Clr_Pin(PA, P12);
GPIO_Clr_Pin(PA, P14);
GPIO_Clr_Pin(PA, P13);
when LED1 =>
GPIO_Clr_Pin(PD, P6);
GPIO_Clr_Pin(PF, P12);
GPIO_Clr_Pin(PE, P12);
end case;
when Black =>
case LED is
when LED0 =>
GPIO_Set_Pin(PA, P12);
GPIO_Set_Pin(PA, P14);
GPIO_Set_Pin(PA, P13);
when LED1 =>
GPIO_Set_Pin(PD, P6);
GPIO_Set_Pin(PF, P12);
GPIO_Set_Pin(PE, P12);
end case;
end case;
end Led_Set;
end Leds;
|
kontena/ruby-packer | Ada | 3,830 | adb | ------------------------------------------------------------------------------
-- --
-- GNAT ncurses Binding --
-- --
-- Terminal_Interface.Curses.Forms.Field_Types.IntField --
-- --
-- B O D Y --
-- --
------------------------------------------------------------------------------
-- Copyright (c) 1998-2011,2014 Free Software Foundation, Inc. --
-- --
-- Permission is hereby granted, free of charge, to any person obtaining a --
-- copy of this software and associated documentation files (the --
-- "Software"), to deal in the Software without restriction, including --
-- without limitation the rights to use, copy, modify, merge, publish, --
-- distribute, distribute with modifications, sublicense, and/or sell --
-- copies of the Software, and to permit persons to whom the Software is --
-- furnished to do so, subject to the following conditions: --
-- --
-- The above copyright notice and this permission notice shall be included --
-- in all copies or substantial portions of the Software. --
-- --
-- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS --
-- OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF --
-- MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. --
-- IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, --
-- DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR --
-- OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR --
-- THE USE OR OTHER DEALINGS IN THE SOFTWARE. --
-- --
-- Except as contained in this notice, the name(s) of the above copyright --
-- holders shall not be used in advertising or otherwise to promote the --
-- sale, use or other dealings in this Software without prior written --
-- authorization. --
------------------------------------------------------------------------------
-- Author: Juergen Pfeifer, 1996
-- Version Control:
-- $Revision: 1.13 $
-- $Date: 2014/05/24 21:31:05 $
-- Binding Version 01.00
------------------------------------------------------------------------------
with Terminal_Interface.Curses.Aux; use Terminal_Interface.Curses.Aux;
package body Terminal_Interface.Curses.Forms.Field_Types.IntField is
procedure Set_Field_Type (Fld : Field;
Typ : Integer_Field)
is
function Set_Fld_Type (F : Field := Fld;
Arg1 : C_Int;
Arg2 : C_Long_Int;
Arg3 : C_Long_Int) return Eti_Error;
pragma Import (C, Set_Fld_Type, "set_field_type_integer");
begin
Eti_Exception (Set_Fld_Type (Arg1 => C_Int (Typ.Precision),
Arg2 => C_Long_Int (Typ.Lower_Limit),
Arg3 => C_Long_Int (Typ.Upper_Limit)));
Wrap_Builtin (Fld, Typ);
end Set_Field_Type;
end Terminal_Interface.Curses.Forms.Field_Types.IntField;
|
charlie5/lace | Ada | 1,818 | ads | with
openGL.Geometry,
openGL.Texture;
package openGL.Model.hexagon_Column.lit_colored_textured_rounded
--
-- Models a lit, colored and textured column with six rounded sides.
--
-- The shaft of the column appears rounded, whereas the top and bottom appear as hexagons.
--
is
type Item is new Model.hexagon_Column.item with private;
type View is access all Item'Class;
---------
--- Faces
--
type hex_Face is
record
center_Color : lucid_Color; -- The color of the center of the hex.
Colors : lucid_Colors (1 .. 6); -- The color of each of the faces 4 vertices.
Texture : asset_Name := null_Asset; -- The texture to be applied to the face.
end record;
type shaft_Face is
record
Color : lucid_Color; -- The color of the shaft.
Texture : asset_Name := openGL.null_Asset; -- The texture to be applied to the shaft.
end record;
---------
--- Forge
--
function new_hexagon_Column (Radius : in Real;
Height : in Real;
Upper,
Lower : in hex_Face;
Shaft : in shaft_Face) return View;
--------------
--- Attributes
--
overriding
function to_GL_Geometries (Self : access Item; Textures : access Texture.name_Map_of_texture'Class;
Fonts : in Font.font_id_Map_of_font) return Geometry.views;
private
type Item is new Model.hexagon_Column.item with
record
upper_Face,
lower_Face : hex_Face;
Shaft : shaft_Face;
end record;
end openGL.Model.hexagon_Column.lit_colored_textured_rounded;
|
onox/orka | Ada | 18,664 | adb | -- SPDX-License-Identifier: Apache-2.0
--
-- Copyright (c) 2017 onox <[email protected]>
--
-- Licensed under the Apache License, Version 2.0 (the "License");
-- you may not use this file except in compliance with the License.
-- You may obtain a copy of the License at
--
-- http://www.apache.org/licenses/LICENSE-2.0
--
-- Unless required by applicable law or agreed to in writing, software
-- distributed under the License is distributed on an "AS IS" BASIS,
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-- See the License for the specific language governing permissions and
-- limitations under the License.
package body Orka.Rendering.Buffers.Mapped is
overriding
function Length (Object : Mapped_Buffer) return Positive is
(Object.Buffer.Length);
procedure Map
(Object : in out Mapped_Buffer;
Length : Size;
Flags : GL.Objects.Buffers.Access_Bits) is
begin
case Object.Kind is
-- Numeric types
when UByte_Type =>
Pointers.UByte.Map_Range
(Object.Buffer.Buffer, Flags, 0, Length, Object.Pointer_UByte);
when UShort_Type =>
Pointers.UShort.Map_Range
(Object.Buffer.Buffer, Flags, 0, Length, Object.Pointer_UShort);
when UInt_Type =>
Pointers.UInt.Map_Range
(Object.Buffer.Buffer, Flags, 0, Length, Object.Pointer_UInt);
when Byte_Type =>
Pointers.Byte.Map_Range
(Object.Buffer.Buffer, Flags, 0, Length, Object.Pointer_Byte);
when Short_Type =>
Pointers.Short.Map_Range
(Object.Buffer.Buffer, Flags, 0, Length, Object.Pointer_Short);
when Int_Type =>
Pointers.Int.Map_Range
(Object.Buffer.Buffer, Flags, 0, Length, Object.Pointer_Int);
when Half_Type =>
Pointers.Half.Map_Range
(Object.Buffer.Buffer, Flags, 0, Length, Object.Pointer_Half);
when Single_Type =>
Pointers.Single.Map_Range
(Object.Buffer.Buffer, Flags, 0, Length, Object.Pointer_Single);
when Double_Type =>
Pointers.Double.Map_Range
(Object.Buffer.Buffer, Flags, 0, Length, Object.Pointer_Double);
-- Composite types
when Single_Vector_Type =>
Pointers.Single_Vector4.Map_Range
(Object.Buffer.Buffer, Flags, 0, Length, Object.Pointer_SV);
when Double_Vector_Type =>
Pointers.Double_Vector4.Map_Range
(Object.Buffer.Buffer, Flags, 0, Length, Object.Pointer_DV);
when Single_Matrix_Type =>
Pointers.Single_Matrix4.Map_Range
(Object.Buffer.Buffer, Flags, 0, Length, Object.Pointer_SM);
when Double_Matrix_Type =>
Pointers.Double_Matrix4.Map_Range
(Object.Buffer.Buffer, Flags, 0, Length, Object.Pointer_DM);
when Arrays_Command_Type =>
Pointers.Arrays_Command.Map_Range
(Object.Buffer.Buffer, Flags, 0, Length, Object.Pointer_AC);
when Elements_Command_Type =>
Pointers.Elements_Command.Map_Range
(Object.Buffer.Buffer, Flags, 0, Length, Object.Pointer_EC);
when Dispatch_Command_Type =>
Pointers.Dispatch_Command.Map_Range
(Object.Buffer.Buffer, Flags, 0, Length, Object.Pointer_DC);
end case;
end Map;
-----------------------------------------------------------------------------
overriding
procedure Bind
(Object : Mapped_Buffer;
Target : Indexed_Buffer_Target;
Index : Natural)
is
Buffer_Target : access constant GL.Objects.Buffers.Buffer_Target;
Offset : constant Size := Size (Object.Offset);
Length : constant Size := Size (Mapped_Buffer'Class (Object).Length);
begin
case Target is
when Uniform =>
Buffer_Target := GL.Objects.Buffers.Uniform_Buffer'Access;
when Shader_Storage =>
Buffer_Target := GL.Objects.Buffers.Shader_Storage_Buffer'Access;
end case;
case Object.Kind is
-- Numeric types
when UByte_Type =>
Pointers.UByte.Bind_Range
(Buffer_Target.all, Object.Buffer.Buffer, Index, Offset, Length);
when UShort_Type =>
Pointers.UShort.Bind_Range
(Buffer_Target.all, Object.Buffer.Buffer, Index, Offset, Length);
when UInt_Type =>
Pointers.UInt.Bind_Range
(Buffer_Target.all, Object.Buffer.Buffer, Index, Offset, Length);
when Byte_Type =>
Pointers.Byte.Bind_Range
(Buffer_Target.all, Object.Buffer.Buffer, Index, Offset, Length);
when Short_Type =>
Pointers.Short.Bind_Range
(Buffer_Target.all, Object.Buffer.Buffer, Index, Offset, Length);
when Int_Type =>
Pointers.Int.Bind_Range
(Buffer_Target.all, Object.Buffer.Buffer, Index, Offset, Length);
when Half_Type =>
Pointers.Half.Bind_Range
(Buffer_Target.all, Object.Buffer.Buffer, Index, Offset, Length);
when Single_Type =>
Pointers.Single.Bind_Range
(Buffer_Target.all, Object.Buffer.Buffer, Index, Offset, Length);
when Double_Type =>
Pointers.Double.Bind_Range
(Buffer_Target.all, Object.Buffer.Buffer, Index, Offset, Length);
-- Composite types
when Single_Vector_Type =>
Pointers.Single_Vector4.Bind_Range
(Buffer_Target.all, Object.Buffer.Buffer, Index, Offset, Length);
when Double_Vector_Type =>
Pointers.Double_Vector4.Bind_Range
(Buffer_Target.all, Object.Buffer.Buffer, Index, Offset, Length);
when Single_Matrix_Type =>
Pointers.Single_Matrix4.Bind_Range
(Buffer_Target.all, Object.Buffer.Buffer, Index, Offset, Length);
when Double_Matrix_Type =>
Pointers.Double_Matrix4.Bind_Range
(Buffer_Target.all, Object.Buffer.Buffer, Index, Offset, Length);
when Arrays_Command_Type =>
Pointers.Arrays_Command.Bind_Range
(Buffer_Target.all, Object.Buffer.Buffer, Index, Offset, Length);
when Elements_Command_Type =>
Pointers.Elements_Command.Bind_Range
(Buffer_Target.all, Object.Buffer.Buffer, Index, Offset, Length);
when Dispatch_Command_Type =>
Pointers.Dispatch_Command.Bind_Range
(Buffer_Target.all, Object.Buffer.Buffer, Index, Offset, Length);
end case;
end Bind;
overriding
procedure Bind (Object : Mapped_Buffer; Target : Buffer_Target) is
begin
case Target is
when Index =>
GL.Objects.Buffers.Element_Array_Buffer.Bind (Object.Buffer.Buffer);
when Dispatch_Indirect =>
GL.Objects.Buffers.Dispatch_Indirect_Buffer.Bind (Object.Buffer.Buffer);
when Draw_Indirect =>
GL.Objects.Buffers.Draw_Indirect_Buffer.Bind (Object.Buffer.Buffer);
when Parameter =>
GL.Objects.Buffers.Parameter_Buffer.Bind (Object.Buffer.Buffer);
when Pixel_Pack =>
GL.Objects.Buffers.Pixel_Pack_Buffer.Bind (Object.Buffer.Buffer);
when Pixel_Unpack =>
GL.Objects.Buffers.Pixel_Unpack_Buffer.Bind (Object.Buffer.Buffer);
when Query =>
GL.Objects.Buffers.Query_Buffer.Bind (Object.Buffer.Buffer);
end case;
end Bind;
-----------------------------------------------------------------------------
procedure Write_Data
(Object : Mapped_Buffer;
Data : Unsigned_8_Array;
Offset : Natural := 0) is
begin
Pointers.UByte.Set_Mapped_Data
(Object.Pointer_UByte, Size (Object.Offset + Offset), Data);
end Write_Data;
procedure Write_Data
(Object : Mapped_Buffer;
Data : Unsigned_16_Array;
Offset : Natural := 0) is
begin
Pointers.UShort.Set_Mapped_Data
(Object.Pointer_UShort, Size (Object.Offset + Offset), Data);
end Write_Data;
procedure Write_Data
(Object : Mapped_Buffer;
Data : Unsigned_32_Array;
Offset : Natural := 0) is
begin
Pointers.UInt.Set_Mapped_Data
(Object.Pointer_UInt, Size (Object.Offset + Offset), Data);
end Write_Data;
procedure Write_Data
(Object : Mapped_Buffer;
Data : Integer_8_Array;
Offset : Natural := 0) is
begin
Pointers.Byte.Set_Mapped_Data
(Object.Pointer_Byte, Size (Object.Offset + Offset), Data);
end Write_Data;
procedure Write_Data
(Object : Mapped_Buffer;
Data : Integer_16_Array;
Offset : Natural := 0) is
begin
Pointers.Short.Set_Mapped_Data
(Object.Pointer_Short, Size (Object.Offset + Offset), Data);
end Write_Data;
procedure Write_Data
(Object : Mapped_Buffer;
Data : Integer_32_Array;
Offset : Natural := 0) is
begin
Pointers.Int.Set_Mapped_Data
(Object.Pointer_Int, Size (Object.Offset + Offset), Data);
end Write_Data;
procedure Write_Data
(Object : Mapped_Buffer;
Data : Float_16_Array;
Offset : Natural := 0) is
begin
Pointers.Half.Set_Mapped_Data
(Object.Pointer_Half, Size (Object.Offset + Offset), Data);
end Write_Data;
procedure Write_Data
(Object : Mapped_Buffer;
Data : Float_32_Array;
Offset : Natural := 0) is
begin
Pointers.Single.Set_Mapped_Data
(Object.Pointer_Single, Size (Object.Offset + Offset), Data);
end Write_Data;
procedure Write_Data
(Object : Mapped_Buffer;
Data : Float_64_Array;
Offset : Natural := 0) is
begin
Pointers.Double.Set_Mapped_Data
(Object.Pointer_Double, Size (Object.Offset + Offset), Data);
end Write_Data;
-----------------------------------------------------------------------------
procedure Write_Data
(Object : Mapped_Buffer;
Data : Orka.Types.Singles.Vector4_Array;
Offset : Natural := 0) is
begin
Pointers.Single_Vector4.Set_Mapped_Data
(Object.Pointer_SV, Size (Object.Offset + Offset), Data);
end Write_Data;
procedure Write_Data
(Object : Mapped_Buffer;
Data : Orka.Types.Singles.Matrix4_Array;
Offset : Natural := 0) is
begin
Pointers.Single_Matrix4.Set_Mapped_Data
(Object.Pointer_SM, Size (Object.Offset + Offset), Data);
end Write_Data;
procedure Write_Data
(Object : Mapped_Buffer;
Data : Orka.Types.Doubles.Vector4_Array;
Offset : Natural := 0) is
begin
Pointers.Double_Vector4.Set_Mapped_Data
(Object.Pointer_DV, Size (Object.Offset + Offset), Data);
end Write_Data;
procedure Write_Data
(Object : Mapped_Buffer;
Data : Orka.Types.Doubles.Matrix4_Array;
Offset : Natural := 0) is
begin
Pointers.Double_Matrix4.Set_Mapped_Data
(Object.Pointer_DM, Size (Object.Offset + Offset), Data);
end Write_Data;
procedure Write_Data
(Object : Mapped_Buffer;
Data : Indirect.Arrays_Indirect_Command_Array;
Offset : Natural := 0) is
begin
Pointers.Arrays_Command.Set_Mapped_Data
(Object.Pointer_AC, Size (Object.Offset + Offset), Data);
end Write_Data;
procedure Write_Data
(Object : Mapped_Buffer;
Data : Indirect.Elements_Indirect_Command_Array;
Offset : Natural := 0) is
begin
Pointers.Elements_Command.Set_Mapped_Data
(Object.Pointer_EC, Size (Object.Offset + Offset), Data);
end Write_Data;
procedure Write_Data
(Object : Mapped_Buffer;
Data : Indirect.Dispatch_Indirect_Command_Array;
Offset : Natural := 0) is
begin
Pointers.Dispatch_Command.Set_Mapped_Data
(Object.Pointer_DC, Size (Object.Offset + Offset), Data);
end Write_Data;
-----------------------------------------------------------------------------
procedure Write_Data
(Object : Mapped_Buffer;
Value : Orka.Types.Singles.Vector4;
Offset : Natural) is
begin
Pointers.Single_Vector4.Set_Mapped_Data
(Object.Pointer_SV, Size (Object.Offset + Offset), Value);
end Write_Data;
procedure Write_Data
(Object : Mapped_Buffer;
Value : Orka.Types.Singles.Matrix4;
Offset : Natural) is
begin
Pointers.Single_Matrix4.Set_Mapped_Data
(Object.Pointer_SM, Size (Object.Offset + Offset), Value);
end Write_Data;
procedure Write_Data
(Object : Mapped_Buffer;
Value : Orka.Types.Doubles.Vector4;
Offset : Natural) is
begin
Pointers.Double_Vector4.Set_Mapped_Data
(Object.Pointer_DV, Size (Object.Offset + Offset), Value);
end Write_Data;
procedure Write_Data
(Object : Mapped_Buffer;
Value : Orka.Types.Doubles.Matrix4;
Offset : Natural) is
begin
Pointers.Double_Matrix4.Set_Mapped_Data
(Object.Pointer_DM, Size (Object.Offset + Offset), Value);
end Write_Data;
procedure Write_Data
(Object : Mapped_Buffer;
Value : Indirect.Arrays_Indirect_Command;
Offset : Natural) is
begin
Pointers.Arrays_Command.Set_Mapped_Data
(Object.Pointer_AC, Size (Object.Offset + Offset), Value);
end Write_Data;
procedure Write_Data
(Object : Mapped_Buffer;
Value : Indirect.Elements_Indirect_Command;
Offset : Natural) is
begin
Pointers.Elements_Command.Set_Mapped_Data
(Object.Pointer_EC, Size (Object.Offset + Offset), Value);
end Write_Data;
procedure Write_Data
(Object : Mapped_Buffer;
Value : Indirect.Dispatch_Indirect_Command;
Offset : Natural) is
begin
Pointers.Dispatch_Command.Set_Mapped_Data
(Object.Pointer_DC, Size (Object.Offset + Offset), Value);
end Write_Data;
-----------------------------------------------------------------------------
procedure Read_Data
(Object : Mapped_Buffer;
Data : out Unsigned_8_Array;
Offset : Natural := 0) is
begin
Data := Pointers.UByte.Get_Mapped_Data
(Object.Pointer_UByte, Size (Object.Offset + Offset), Data'Length);
end Read_Data;
procedure Read_Data
(Object : Mapped_Buffer;
Data : out Unsigned_16_Array;
Offset : Natural := 0) is
begin
Data := Pointers.UShort.Get_Mapped_Data
(Object.Pointer_UShort, Size (Object.Offset + Offset), Data'Length);
end Read_Data;
procedure Read_Data
(Object : Mapped_Buffer;
Data : out Unsigned_32_Array;
Offset : Natural := 0) is
begin
Data := Pointers.UInt.Get_Mapped_Data
(Object.Pointer_UInt, Size (Object.Offset + Offset), Data'Length);
end Read_Data;
procedure Read_Data
(Object : Mapped_Buffer;
Data : out Integer_8_Array;
Offset : Natural := 0) is
begin
Data := Pointers.Byte.Get_Mapped_Data
(Object.Pointer_Byte, Size (Object.Offset + Offset), Data'Length);
end Read_Data;
procedure Read_Data
(Object : Mapped_Buffer;
Data : out Integer_16_Array;
Offset : Natural := 0) is
begin
Data := Pointers.Short.Get_Mapped_Data
(Object.Pointer_Short, Size (Object.Offset + Offset), Data'Length);
end Read_Data;
procedure Read_Data
(Object : Mapped_Buffer;
Data : out Integer_32_Array;
Offset : Natural := 0) is
begin
Data := Pointers.Int.Get_Mapped_Data
(Object.Pointer_Int, Size (Object.Offset + Offset), Data'Length);
end Read_Data;
procedure Read_Data
(Object : Mapped_Buffer;
Data : out Float_16_Array;
Offset : Natural := 0) is
begin
Data := Pointers.Half.Get_Mapped_Data
(Object.Pointer_Half, Size (Object.Offset + Offset), Data'Length);
end Read_Data;
procedure Read_Data
(Object : Mapped_Buffer;
Data : out Float_32_Array;
Offset : Natural := 0) is
begin
Data := Pointers.Single.Get_Mapped_Data
(Object.Pointer_Single, Size (Object.Offset + Offset), Data'Length);
end Read_Data;
procedure Read_Data
(Object : Mapped_Buffer;
Data : out Float_64_Array;
Offset : Natural := 0) is
begin
Data := Pointers.Double.Get_Mapped_Data
(Object.Pointer_Double, Size (Object.Offset + Offset), Data'Length);
end Read_Data;
-----------------------------------------------------------------------------
procedure Read_Data
(Object : Mapped_Buffer;
Data : out Orka.Types.Singles.Vector4_Array;
Offset : Natural := 0) is
begin
Data := Pointers.Single_Vector4.Get_Mapped_Data
(Object.Pointer_SV, Size (Object.Offset + Offset), Data'Length);
end Read_Data;
procedure Read_Data
(Object : Mapped_Buffer;
Data : out Orka.Types.Singles.Matrix4_Array;
Offset : Natural := 0) is
begin
Data := Pointers.Single_Matrix4.Get_Mapped_Data
(Object.Pointer_SM, Size (Object.Offset + Offset), Data'Length);
end Read_Data;
procedure Read_Data
(Object : Mapped_Buffer;
Data : out Orka.Types.Doubles.Vector4_Array;
Offset : Natural := 0) is
begin
Data := Pointers.Double_Vector4.Get_Mapped_Data
(Object.Pointer_DV, Size (Object.Offset + Offset), Data'Length);
end Read_Data;
procedure Read_Data
(Object : Mapped_Buffer;
Data : out Orka.Types.Doubles.Matrix4_Array;
Offset : Natural := 0) is
begin
Data := Pointers.Double_Matrix4.Get_Mapped_Data
(Object.Pointer_DM, Size (Object.Offset + Offset), Data'Length);
end Read_Data;
procedure Read_Data
(Object : Mapped_Buffer;
Data : out Indirect.Arrays_Indirect_Command_Array;
Offset : Natural := 0) is
begin
Data := Pointers.Arrays_Command.Get_Mapped_Data
(Object.Pointer_AC, Size (Object.Offset + Offset), Data'Length);
end Read_Data;
procedure Read_Data
(Object : Mapped_Buffer;
Data : out Indirect.Elements_Indirect_Command_Array;
Offset : Natural := 0) is
begin
Data := Pointers.Elements_Command.Get_Mapped_Data
(Object.Pointer_EC, Size (Object.Offset + Offset), Data'Length);
end Read_Data;
procedure Read_Data
(Object : Mapped_Buffer;
Data : out Indirect.Dispatch_Indirect_Command_Array;
Offset : Natural := 0) is
begin
Data := Pointers.Dispatch_Command.Get_Mapped_Data
(Object.Pointer_DC, Size (Object.Offset + Offset), Data'Length);
end Read_Data;
end Orka.Rendering.Buffers.Mapped;
|
jwarwick/aoc_2019_ada | Ada | 3,742 | adb | with AUnit.Assertions; use AUnit.Assertions;
with Ada.Containers;
use type Ada.Containers.Count_Type;
package body IntCode.Test is
procedure Test_Load (T : in out AUnit.Test_Cases.Test_Case'Class) is
pragma Unreferenced (T);
begin
Assert(memory.length = 0, "Vector before load should be size 0, got: " & Ada.Containers.Count_Type'Image(memory.length));
load("99");
Assert(memory.length = 1, "Vector after load should be size 1, got: " & Ada.Containers.Count_Type'Image(memory.length));
Assert(memory(0) = 99, "First element of vector should be 99, got: " & Integer'Image(memory(0)));
load("16,42,0,-1");
Assert(memory.length = 4, "Vector after load should be size 4, got: " & Ada.Containers.Count_Type'Image(memory.length));
Assert(memory(0) = 16, "First element of vector should be 16, got: " & Integer'Image(memory(0)));
Assert(memory(1) = 42, "First element of vector should be 16, got: " & Integer'Image(memory(1)));
Assert(memory(2) = 0, "First element of vector should be 16, got: " & Integer'Image(memory(2)));
Assert(memory(3) = -1, "First element of vector should be 16, got: " & Integer'Image(memory(3)));
end Test_Load;
procedure Test_Poke (T : in out AUnit.Test_Cases.Test_Case'Class) is
pragma Unreferenced (T);
begin
load("16,42,0,-1");
Assert(memory.length = 4, "Vector after load should be size 4, got: " & Ada.Containers.Count_Type'Image(memory.length));
Assert(memory(0) = 16, "First element of vector should be 16, got: " & Integer'Image(memory(0)));
Assert(memory(1) = 42, "First element of vector should be 16, got: " & Integer'Image(memory(1)));
Assert(memory(2) = 0, "First element of vector should be 16, got: " & Integer'Image(memory(2)));
Assert(memory(3) = -1, "First element of vector should be 16, got: " & Integer'Image(memory(3)));
poke(0, -5);
Assert(memory(0) = -5, "Poked element of vector should be -5, got: " & Integer'Image(memory(0)));
-- XXX - test exception
-- poke(10, 11);
Assert(peek(3) = -1, "Peeking element of vector should be -1, got: " & Integer'Image(memory(3)));
end Test_Poke;
procedure Test_Eval (T : in out AUnit.Test_Cases.Test_Case'Class) is
pragma Unreferenced (T);
type Memory_Array is array(Integer range <>) of Integer;
function to_memory(a : Memory_Array) return Memory_Vector.Vector is
m : Memory_Vector.Vector;
begin
for val of a loop
m.append(val);
end loop;
return m;
end to_memory;
procedure eval_test(input : in Memory_Array; expected : in Memory_Array; desc : in String) is
use type Memory_Vector.Vector;
m : Memory_Vector.Vector := to_memory(input);
e : Memory_Vector.Vector := to_memory(expected);
begin
memory := m;
eval;
Assert(memory = e, desc & ", got: " & dump);
end eval_test;
begin
eval_test((1, 0, 0, 0, 99), (2, 0, 0, 0, 99), "Simple add test");
eval_test((2,3,0,3,99), (2,3,0,6,99), "Simple mult test");
eval_test((2,4,4,5,99,0), (2,4,4,5,99,9801), "Bigger mult test");
eval_test((1,1,1,4,99,5,6,0,99), (30,1,1,4,2,5,6,0,99), "Multiple write test");
end Test_Eval;
function Name (T : Test) return AUnit.Message_String is
pragma Unreferenced (T);
begin
return AUnit.Format ("IntCode Package");
end Name;
procedure Register_Tests (T : in out Test) is
use AUnit.Test_Cases.Registration;
begin
Register_Routine (T, Test_Load'Access, "Loading");
Register_Routine (T, Test_Poke'Access, "Peek/Poke");
Register_Routine (T, Test_Eval'Access, "Evaluation");
end Register_Tests;
end IntCode.Test;
|
reznikmm/matreshka | Ada | 4,953 | ads | ------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- Web Framework --
-- --
-- Web API Definition --
-- --
------------------------------------------------------------------------------
-- --
-- Copyright © 2014-2018, 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 is root package to expose WebGL API to Ada applications.
------------------------------------------------------------------------------
with Interfaces;
package WebAPI.WebGL is
pragma Preelaborate;
type GLboolean is new Interfaces.Unsigned_8;
type GLenum is new Interfaces.Unsigned_32;
type GLbitfield is new Interfaces.Unsigned_32;
type GLint is new Interfaces.Integer_32;
subtype GLsizei is GLint range 0 .. GLint'Last;
type GLuint is new Interfaces.Unsigned_32;
type GLfloat is new Interfaces.IEEE_Float_32;
subtype GLclampf is GLfloat range 0.0 .. 1.0;
type GLintptr is new Interfaces.Integer_64;
type GLfloat_Vector_2 is array (Positive range 1 .. 2) of GLfloat;
pragma JavaScript_Array_Buffer (GLfloat_Vector_2);
type GLfloat_Vector_3 is array (Positive range 1 .. 3) of GLfloat;
pragma JavaScript_Array_Buffer (GLfloat_Vector_3);
type GLfloat_Vector_4 is array (Positive range 1 .. 4) of GLfloat;
pragma JavaScript_Array_Buffer (GLfloat_Vector_4);
type GLfloat_Matrix_2x2 is
array (Positive range 1 .. 2, Positive range 1 .. 2) of GLfloat
with Convention => Fortran;
pragma JavaScript_Array_Buffer (GLfloat_Matrix_2x2);
type GLfloat_Matrix_3x3 is
array (Positive range 1 .. 3, Positive range 1 .. 3) of GLfloat
with Convention => Fortran;
pragma JavaScript_Array_Buffer (GLfloat_Matrix_3x3);
type GLfloat_Matrix_4x4 is
array (Positive range 1 .. 4, Positive range 1 .. 4) of GLfloat
with Convention => Fortran;
pragma JavaScript_Array_Buffer (GLfloat_Matrix_4x4);
end WebAPI.WebGL;
|
zhmu/ananas | Ada | 410 | adb | -- { dg-do run }
-- { dg-options "-gnatws" }
procedure Biased_Subtype is
CIM_Max_AA : constant := 9_999_999;
CIM_Min_AA : constant := -999_999;
type TIM_AA is range CIM_Min_AA..CIM_Max_AA + 1;
for TIM_AA'Size use 24;
subtype STIM_AA is TIM_AA range TIM_AA(CIM_Min_AA)..TIM_AA(CIM_Max_AA);
SAA : STIM_AA := 1;
begin
if Integer(SAA) /= 1 then
raise Program_Error;
end if;
end;
|
Fabien-Chouteau/AGATE | Ada | 9,675 | adb | ------------------------------------------------------------------------------
-- --
-- Copyright (C) 2017-2020, Fabien Chouteau --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions are --
-- met: --
-- 1. Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- 2. Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in --
-- the documentation and/or other materials provided with the --
-- distribution. --
-- 3. Neither the name of the copyright holder nor the names of its --
-- contributors may be used to endorse or promote products derived --
-- from this software without specific prior written permission. --
-- --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR --
-- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
-- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT --
-- LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, --
-- DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY --
-- THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT --
-- (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE --
-- OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
-- --
------------------------------------------------------------------------------
with Ada.Text_IO; use Ada.Text_IO;
with Cortex_M_SVD.SCB; use Cortex_M_SVD.SCB;
with Cortex_M_SVD.NVIC; use Cortex_M_SVD.NVIC;
with AGATE.Arch.ArmvX_m;
with AGATE.Scheduler;
package body AGATE.Traps is
Handlers_Table : array (Trap_ID) of Trap_Handler
:= (others => null);
Priorities_Table : array (Trap_ID) of Trap_Priority
:= (others => Trap_Priority'First);
pragma Unreferenced (Priorities_Table);
procedure IRQ_Handler;
pragma Export (C, IRQ_Handler, "__unknown_interrupt_handler");
procedure Initialize;
procedure Print_Fault;
procedure Hard_Fault_Handler;
pragma Export (C, Hard_Fault_Handler, "HardFault_Handler");
procedure Mem_Manage_Handler;
pragma Export (C, Mem_Manage_Handler, "MemMang_Handler");
procedure Bus_Fault_Handler;
pragma Export (C, Bus_Fault_Handler, "BusFault_Handler");
procedure Usage_Fault_Handler;
pragma Export (C, Usage_Fault_Handler, "UsageFault_Handler");
-----------------
-- Print_Fault --
-----------------
procedure Print_Fault
is
type Stack_Array is array (1 .. 8) of Word
with Pack, Size => 8 * 32;
SP : constant System.Address := System.Address (Arch.ArmvX_m.PSP);
SCB : SCB_Peripheral renames SCB_Periph;
begin
Put_Line ("Forced HardFault : " & SCB_Periph.HFSR.FORCED'Img);
Put_Line ("Vector table read VECTTBL : " & SCB.HFSR.VECTTBL'Img);
Put_Line ("MemManage:");
Put_Line (" - Instruction access : " & SCB.MMSR.IACCVIOL'Img);
Put_Line (" - Data access : " & SCB.MMSR.DACCVIOL'Img);
Put_Line (" - Unstacking from excp : " & SCB.MMSR.MUNSTKERR'Img);
Put_Line (" - Stacking for excp : " & SCB.MMSR.MSTKERR'Img);
Put_Line (" - FPU Lazy state preserv : " & SCB.MMSR.MLSPERR'Img);
if SCB.MMSR.MMARVALID then
Put_Line ("-> address : " & SCB.MMAR'Img);
end if;
Put_Line ("BusFault:");
Put_Line (" - Instruction bus error : " & SCB.BFSR.IBUSERR'Img);
Put_Line (" - Precise data bus error : " &
SCB.BFSR.PRECISERR'Img);
Put_Line (" - Imprecise data bus err : " &
SCB.BFSR.IMPRECISERR'Img);
Put_Line (" - Unstacking from excp : " &
SCB.BFSR.UNSTKERR'Img);
Put_Line (" - Stacking for excp : " & SCB.BFSR.STKERR'Img);
Put_Line (" - FPU Lazy state preserv : " & SCB.BFSR.LSPERR'Img);
if SCB.BFSR.BFARVALID then
Put_Line ("-> address : " & SCB.BFAR'Img);
end if;
Put_Line ("UsageFault:");
Put_Line (" - Undefined instruction : " &
SCB.UFSR.UNDEFINSTR'Img);
Put_Line (" - Invalid state : " &
SCB.UFSR.INVSTATE'Img);
Put_Line (" - Invalid PC load : " & SCB.UFSR.INVPC'Img);
Put_Line (" - No co-processor : " & SCB.UFSR.NOCP'Img);
Put_Line (" - Unaligned access : " &
SCB.UFSR.UNALIGNED'Img);
Put_Line (" - Division by zero : " &
SCB.UFSR.DIVBYZERO'Img);
Put_Line ("PSP: " & Hex (UInt32 (To_Integer (SP))));
if To_Integer (SP) = 0 or else SP mod Stack_Array'Alignment /= 0 then
Put_Line ("Invalid PSP");
else
declare
Context : Stack_Array with Address => SP;
begin
Put_Line ("R0 : " & Hex (UInt32 (Context (1))));
Put_Line ("R1 : " & Hex (UInt32 (Context (2))));
Put_Line ("R2 : " & Hex (UInt32 (Context (3))));
Put_Line ("R3 : " & Hex (UInt32 (Context (4))));
Put_Line ("R12: " & Hex (UInt32 (Context (5))));
Put_Line ("LR : " & Hex (UInt32 (Context (6))));
Put_Line ("PC : " & Hex (UInt32 (Context (7))));
Put_Line ("PSR: " & Hex (UInt32 (Context (8))));
end;
end if;
end Print_Fault;
------------------------
-- Hard_Fault_Handler --
------------------------
procedure Hard_Fault_Handler is
begin
Put_Line ("In HardFault");
Print_Fault;
loop
null;
end loop;
end Hard_Fault_Handler;
------------------------
-- Mem_Manage_Handler --
------------------------
procedure Mem_Manage_Handler is
begin
Put_Line ("In mem manage fault");
Print_Fault;
Scheduler.Fault;
if Scheduler.Context_Switch_Needed then
Scheduler.Do_Context_Switch;
end if;
end Mem_Manage_Handler;
-----------------------
-- Bus_Fault_Handler --
-----------------------
procedure Bus_Fault_Handler is
begin
Put_Line ("In bus fault");
Print_Fault;
Scheduler.Fault;
if Scheduler.Context_Switch_Needed then
Scheduler.Do_Context_Switch;
end if;
end Bus_Fault_Handler;
-------------------------
-- Usage_Fault_Handler --
-------------------------
procedure Usage_Fault_Handler is
begin
Put_Line ("In usage fault");
Print_Fault;
Scheduler.Fault;
if Scheduler.Context_Switch_Needed then
Scheduler.Do_Context_Switch;
end if;
end Usage_Fault_Handler;
----------------
-- Initialize --
----------------
procedure Initialize
is
Vector : Word;
pragma Import (C, Vector, "__vectors");
Vector_Address : constant Word := Word (To_Integer (Vector'Address));
begin
SCB_Periph.VTOR := UInt32 (Vector_Address);
-- Processor can enter Thread mode from any level under the control of
-- an EXC_RETURN value.
SCB_Periph.CCR.NONBASETHREADENA := On_Exc_Return;
-- No unalign access traps.
SCB_Periph.CCR.UNALIGNED_TRP := False;
-- Enable Faults
SCB_Periph.SHPRS.MEMFAULTENA := True;
SCB_Periph.SHPRS.BUSFAULTENA := True;
SCB_Periph.SHPRS.USGFAULTENA := True;
AGATE.Arch.ArmvX_m.Enable_Faults;
end Initialize;
--------------
-- Register --
--------------
procedure Register
(Handler : Trap_Handler;
ID : Trap_ID;
Priority : Trap_Priority)
is
begin
Handlers_Table (ID) := Handler;
Priorities_Table (ID) := Priority;
end Register;
------------
-- Enable --
------------
procedure Enable (ID : Trap_ID) is
Reg_Index : constant Natural := Natural (ID) / 32;
Bit : constant UInt32 := 2**(Natural (ID) mod 32);
begin
NVIC_Periph.NVIC_ISER (Reg_Index) := Bit;
end Enable;
-------------
-- Disable --
-------------
procedure Disable (ID : Trap_ID) is
Reg_Index : constant Natural := Natural (ID) / 32;
Bit : constant UInt32 := 2**(Natural (ID) mod 32);
begin
NVIC_Periph.NVIC_ICER (Reg_Index) := Bit;
end Disable;
-----------------
-- IRQ_Handler --
-----------------
procedure IRQ_Handler
is
ID : constant Trap_ID :=
Trap_ID (Integer (SCB_Periph.ICSR.VECTACTIVE) - 16);
begin
if Handlers_Table (ID) /= null then
Handlers_Table (ID).all;
else
Ada.Text_IO.Put_Line ("No handler for: " & ID'Img);
loop
null;
end loop;
end if;
if Scheduler.Context_Switch_Needed then
Scheduler.Do_Context_Switch;
end if;
end IRQ_Handler;
begin
Initialize;
end AGATE.Traps;
|
SayCV/rtems-addon-packages | Ada | 14,825 | adb | ------------------------------------------------------------------------------
-- --
-- GNAT ncurses Binding Samples --
-- --
-- Sample.Menu_Demo --
-- --
-- B O D Y --
-- --
------------------------------------------------------------------------------
-- Copyright (c) 1998-2008,2011 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; use Terminal_Interface.Curses;
with Terminal_Interface.Curses.Panels; use Terminal_Interface.Curses.Panels;
with Terminal_Interface.Curses.Menus; use Terminal_Interface.Curses.Menus;
with Terminal_Interface.Curses.Menus.Menu_User_Data;
with Terminal_Interface.Curses.Menus.Item_User_Data;
with Sample.Manifest; use Sample.Manifest;
with Sample.Function_Key_Setting; use Sample.Function_Key_Setting;
with Sample.Menu_Demo.Handler;
with Sample.Helpers; use Sample.Helpers;
with Sample.Explanation; use Sample.Explanation;
package body Sample.Menu_Demo is
package Spacing_Demo is
procedure Spacing_Test;
end Spacing_Demo;
package body Spacing_Demo is
procedure Spacing_Test
is
function My_Driver (M : Menu;
K : Key_Code;
P : Panel) return Boolean;
procedure Set_Option_Key;
procedure Set_Select_Key;
procedure Set_Description_Key;
procedure Set_Hide_Key;
package Mh is new Sample.Menu_Demo.Handler (My_Driver);
I : Item_Array_Access := new Item_Array'
(New_Item ("January", "31 Days"),
New_Item ("February", "28/29 Days"),
New_Item ("March", "31 Days"),
New_Item ("April", "30 Days"),
New_Item ("May", "31 Days"),
New_Item ("June", "30 Days"),
New_Item ("July", "31 Days"),
New_Item ("August", "31 Days"),
New_Item ("September", "30 Days"),
New_Item ("October", "31 Days"),
New_Item ("November", "30 Days"),
New_Item ("December", "31 Days"),
Null_Item);
M : Menu := New_Menu (I);
Flip_State : Boolean := True;
Hide_Long : Boolean := False;
type Format_Code is (Four_By_1, Four_By_2, Four_By_3);
type Operations is (Flip, Reorder, Reformat, Reselect, Describe);
type Change is array (Operations) of Boolean;
pragma Pack (Change);
No_Change : constant Change := Change'(others => False);
Current_Format : Format_Code := Four_By_1;
To_Change : Change := No_Change;
function My_Driver (M : Menu;
K : Key_Code;
P : Panel) return Boolean
is
begin
if M = Null_Menu then
raise Menu_Exception;
end if;
if P = Null_Panel then
raise Panel_Exception;
end if;
To_Change := No_Change;
if K in User_Key_Code'Range then
if K = QUIT then
return True;
end if;
end if;
if K in Special_Key_Code'Range then
case K is
when Key_F4 =>
To_Change (Flip) := True;
return True;
when Key_F5 =>
To_Change (Reformat) := True;
Current_Format := Four_By_1;
return True;
when Key_F6 =>
To_Change (Reformat) := True;
Current_Format := Four_By_2;
return True;
when Key_F7 =>
To_Change (Reformat) := True;
Current_Format := Four_By_3;
return True;
when Key_F8 =>
To_Change (Reorder) := True;
return True;
when Key_F9 =>
To_Change (Reselect) := True;
return True;
when Key_F10 =>
if Current_Format /= Four_By_3 then
To_Change (Describe) := True;
return True;
else
return False;
end if;
when Key_F11 =>
Hide_Long := not Hide_Long;
declare
O : Item_Option_Set;
begin
for J in I'Range loop
Get_Options (I.all (J), O);
O.Selectable := True;
if Hide_Long then
case J is
when 1 | 3 | 5 | 7 | 8 | 10 | 12 =>
O.Selectable := False;
when others => null;
end case;
end if;
Set_Options (I.all (J), O);
end loop;
end;
return False;
when others => null;
end case;
end if;
return False;
end My_Driver;
procedure Set_Option_Key
is
O : Menu_Option_Set;
begin
if Current_Format = Four_By_1 then
Set_Soft_Label_Key (8, "");
else
Get_Options (M, O);
if O.Row_Major_Order then
Set_Soft_Label_Key (8, "O-Col");
else
Set_Soft_Label_Key (8, "O-Row");
end if;
end if;
Refresh_Soft_Label_Keys_Without_Update;
end Set_Option_Key;
procedure Set_Select_Key
is
O : Menu_Option_Set;
begin
Get_Options (M, O);
if O.One_Valued then
Set_Soft_Label_Key (9, "Multi");
else
Set_Soft_Label_Key (9, "Singl");
end if;
Refresh_Soft_Label_Keys_Without_Update;
end Set_Select_Key;
procedure Set_Description_Key
is
O : Menu_Option_Set;
begin
if Current_Format = Four_By_3 then
Set_Soft_Label_Key (10, "");
else
Get_Options (M, O);
if O.Show_Descriptions then
Set_Soft_Label_Key (10, "-Desc");
else
Set_Soft_Label_Key (10, "+Desc");
end if;
end if;
Refresh_Soft_Label_Keys_Without_Update;
end Set_Description_Key;
procedure Set_Hide_Key
is
begin
if Hide_Long then
Set_Soft_Label_Key (11, "Enab");
else
Set_Soft_Label_Key (11, "Disab");
end if;
Refresh_Soft_Label_Keys_Without_Update;
end Set_Hide_Key;
begin
Push_Environment ("MENU01");
Notepad ("MENU-PAD01");
Default_Labels;
Set_Soft_Label_Key (4, "Flip");
Set_Soft_Label_Key (5, "4x1");
Set_Soft_Label_Key (6, "4x2");
Set_Soft_Label_Key (7, "4x3");
Set_Option_Key;
Set_Select_Key;
Set_Description_Key;
Set_Hide_Key;
Set_Format (M, 4, 1);
loop
Mh.Drive_Me (M);
exit when To_Change = No_Change;
if To_Change (Flip) then
if Flip_State then
Flip_State := False;
Set_Spacing (M, 3, 2, 0);
else
Flip_State := True;
Set_Spacing (M);
end if;
elsif To_Change (Reformat) then
case Current_Format is
when Four_By_1 => Set_Format (M, 4, 1);
when Four_By_2 => Set_Format (M, 4, 2);
when Four_By_3 =>
declare
O : Menu_Option_Set;
begin
Get_Options (M, O);
O.Show_Descriptions := False;
Set_Options (M, O);
Set_Format (M, 4, 3);
end;
end case;
Set_Option_Key;
Set_Description_Key;
elsif To_Change (Reorder) then
declare
O : Menu_Option_Set;
begin
Get_Options (M, O);
O.Row_Major_Order := not O.Row_Major_Order;
Set_Options (M, O);
Set_Option_Key;
end;
elsif To_Change (Reselect) then
declare
O : Menu_Option_Set;
begin
Get_Options (M, O);
O.One_Valued := not O.One_Valued;
Set_Options (M, O);
Set_Select_Key;
end;
elsif To_Change (Describe) then
declare
O : Menu_Option_Set;
begin
Get_Options (M, O);
O.Show_Descriptions := not O.Show_Descriptions;
Set_Options (M, O);
Set_Description_Key;
end;
else
null;
end if;
end loop;
Set_Spacing (M);
Pop_Environment;
pragma Assert (Get_Index (Items (M, 1)) = Get_Index (I (1)));
Delete (M);
Free (I, True);
end Spacing_Test;
end Spacing_Demo;
procedure Demo
is
-- We use this datatype only to test the instantiation of
-- the Menu_User_Data generic package. No functionality
-- behind it.
type User_Data is new Integer;
type User_Data_Access is access User_Data;
-- Those packages are only instantiated to test the usability.
-- No real functionality is shown in the demo.
package MUD is new Menu_User_Data (User_Data, User_Data_Access);
package IUD is new Item_User_Data (User_Data, User_Data_Access);
function My_Driver (M : Menu;
K : Key_Code;
P : Panel) return Boolean;
package Mh is new Sample.Menu_Demo.Handler (My_Driver);
Itm : Item_Array_Access := new Item_Array'
(New_Item ("Menu Layout Options"),
New_Item ("Demo of Hook functions"),
Null_Item);
M : Menu := New_Menu (Itm);
U1 : constant User_Data_Access := new User_Data'(4711);
U2 : User_Data_Access;
U3 : constant User_Data_Access := new User_Data'(4712);
U4 : User_Data_Access;
function My_Driver (M : Menu;
K : Key_Code;
P : Panel) return Boolean
is
Idx : constant Positive := Get_Index (Current (M));
begin
if K in User_Key_Code'Range then
if K = QUIT then
return True;
elsif K = SELECT_ITEM then
if Idx in Itm'Range then
Hide (P);
Update_Panels;
end if;
case Idx is
when 1 => Spacing_Demo.Spacing_Test;
when others => Not_Implemented;
end case;
if Idx in Itm'Range then
Top (P);
Show (P);
Update_Panels;
Update_Screen;
end if;
end if;
end if;
return False;
end My_Driver;
begin
Push_Environment ("MENU00");
Notepad ("MENU-PAD00");
Default_Labels;
Refresh_Soft_Label_Keys_Without_Update;
Set_Pad_Character (M, '|');
MUD.Set_User_Data (M, U1);
IUD.Set_User_Data (Itm.all (1), U3);
Mh.Drive_Me (M);
MUD.Get_User_Data (M, U2);
pragma Assert (U1 = U2 and U1.all = 4711);
IUD.Get_User_Data (Itm.all (1), U4);
pragma Assert (U3 = U4 and U3.all = 4712);
Pop_Environment;
Delete (M);
Free (Itm, True);
end Demo;
end Sample.Menu_Demo;
|
AdaCore/gpr | Ada | 54 | ads | package AAA is
generic
procedure Proc;
end AAA;
|
sungyeon/drake | Ada | 1,633 | ads | pragma License (Unrestricted);
-- implementation unit for System.Initialization
private with Ada.Tags;
package System.Storage_Pools.Overlaps is
pragma Preelaborate;
type Overlay_Pool is limited new Root_Storage_Pool with null record
with Disable_Controlled => True;
-- Actually, an allocation address is stored in TLS.
pragma Finalize_Storage_Only (Overlay_Pool);
procedure Set_Address (Storage_Address : Address);
pragma Inline (Set_Address);
overriding procedure Allocate (
Pool : in out Overlay_Pool;
Storage_Address : out Address;
Size_In_Storage_Elements : Storage_Elements.Storage_Count;
Alignment : Storage_Elements.Storage_Count);
pragma Inline (Allocate);
overriding procedure Deallocate (
Pool : in out Overlay_Pool;
Storage_Address : Address;
Size_In_Storage_Elements : Storage_Elements.Storage_Count;
Alignment : Storage_Elements.Storage_Count);
pragma Inline (Deallocate);
overriding function Storage_Size (Pool : Overlay_Pool)
return Storage_Elements.Storage_Count is (0);
Pool : constant not null access Overlay_Pool;
-- Note: If it is declared as a local pool, Any objects allocated from it
-- will be finalized when the local pool is out of scope,
-- because the objects also belongs to the same scope.
-- Therefore it should be declared in library-level.
private
Dispatcher : aliased constant Ada.Tags.Tag := Overlay_Pool'Tag;
Pool : constant not null access Overlay_Pool :=
Overlay_Pool'Deref (Dispatcher'Address)'Unrestricted_Access;
end System.Storage_Pools.Overlaps;
|
persan/protobuf-ada | Ada | 922 | ads | with Ada.Streams;
with Google.Protobuf.Wire_Format;
package Test_Helpers is
procedure Assert_Write_Raw_Varint (Data : in Ada.Streams.Stream_Element_Array; Value : in Google.Protobuf.Wire_Format.PB_UInt64);
procedure Assert_Write_Raw_Little_Endian_32 (Data : in Ada.Streams.Stream_Element_Array; Value : in Google.Protobuf.Wire_Format.PB_Int64);
procedure Assert_Write_Raw_Little_Endian_64 (Data : in Ada.Streams.Stream_Element_Array; Value : in Google.Protobuf.Wire_Format.PB_Int64);
procedure Assert_Read_Raw_Varint (Data : in Ada.Streams.Stream_Element_Array; Value : in Google.Protobuf.Wire_Format.PB_UInt64);
procedure Assert_Read_Raw_Little_Endian_32 (Data : in Ada.Streams.Stream_Element_Array; Value : in Google.Protobuf.Wire_Format.PB_UInt32);
procedure Assert_Read_Raw_Little_Endian_64 (Data : in Ada.Streams.Stream_Element_Array; Value : in Google.Protobuf.Wire_Format.PB_UInt64);
end Test_Helpers;
|
AdaCore/gpr | Ada | 8,538 | adb | ------------------------------------------------------------------------------
-- --
-- GPR2 PROJECT MANAGER --
-- --
-- Copyright (C) 2020-2023, AdaCore --
-- --
-- This 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. This software is distributed in the hope that it will be useful, --
-- but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHAN- --
-- TABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public --
-- License for more details. You should have received a copy of the GNU --
-- General Public License distributed with GNAT; see file COPYING. If not, --
-- see <http://www.gnu.org/licenses/>. --
-- --
------------------------------------------------------------------------------
-- This utility collects all files of the GPRconfig Knowledge Base and
-- composes them into a single file intended for embedding in GPR2 library.
with Ada.Containers.Indefinite_Doubly_Linked_Lists;
with Ada.Characters.Handling;
with Ada.Directories;
with Ada.Exceptions;
with Ada.Strings.Fixed;
with Ada.Strings.Unbounded;
with Ada.Text_IO;
with GNAT.Command_Line;
with GNAT.OS_Lib;
with Direct_IO;
procedure Collect_KB is
use Ada;
use Ada.Strings.Unbounded;
use GNAT;
Collect_KB_Error : exception;
-- Raised to terminate execution
Default_Output_Name : constant String := "config.kb";
Output_File : Unbounded_String :=
To_Unbounded_String
(OS_Lib.Normalize_Pathname
(Default_Output_Name,
Directory => Directories.Current_Directory,
Case_Sensitive => False));
-- Output file where composed knoledge base should be written
KB_Dir : Unbounded_String;
-- Location of knowledge base
Search : Directories.Search_Type;
File : Directories.Directory_Entry_Type;
KB_File_In : Text_IO.File_Type;
procedure Help;
-- Displays help on using this application
procedure Fail (S : String);
-- Outputs S to Standard_Error and raises Collect_KB_Error
procedure Add_Buffer_To_Input (F_Name : String);
-- Adds contents of Input_Buffer to All_Input, prepending it by base name
-- of F_Name and length of buffer contents:
-- <old_input><base_file_name>:<length>:<buffer_contents>
----------
-- Fail --
----------
procedure Fail (S : String) is
begin
Text_IO.Put_Line (Text_IO.Standard_Error, S);
raise Collect_KB_Error;
end Fail;
----------
-- Help --
----------
procedure Help is
begin
Text_IO.Put_Line ("Usage: collect_kb [opts] dirname");
Text_IO.Put_Line (" -h : Show help message");
Text_IO.Put_Line (" -v : Verbose mode");
Text_IO.Put_Line (" -o <file> : Output file name");
Text_IO.Put_Line
(" Default is " & Default_Output_Name);
end Help;
Verbose_Mode : Boolean := False;
-- Verbose output
package String_Lists is new
Ada.Containers.Indefinite_Doubly_Linked_Lists (String);
use String_Lists;
Entities : List;
XML_Files : List;
Schema : Unbounded_String;
Input_Buffer, All_Input : Unbounded_String;
-------------------------
-- Add_Buffer_To_Input --
-------------------------
procedure Add_Buffer_To_Input (F_Name : String) is
use Ada.Strings.Fixed;
Length_Img : constant String :=
Trim (Length (Input_Buffer)'Img, Ada.Strings.Both);
begin
Append
(All_Input,
Directories.Simple_Name (F_Name)
& ":" & Length_Img & ":" & Input_Buffer);
end Add_Buffer_To_Input;
begin
loop
case Command_Line.Getopt ("h v o:") is
when ASCII.NUL =>
exit;
when 'o' =>
Output_File := To_Unbounded_String
(OS_Lib.Normalize_Pathname
(Command_Line.Parameter,
Directory => Directories.Current_Directory,
Case_Sensitive => False));
when 'h' =>
Help;
return;
when 'v' =>
Verbose_Mode := True;
when others =>
Fail ("collect_kb: unknown switch " & Command_Line.Full_Switch);
end case;
end loop;
KB_Dir := To_Unbounded_String
(OS_Lib.Normalize_Pathname
(Command_Line.Get_Argument,
Case_Sensitive => False));
if KB_Dir = "" then
Fail ("collect_kb: knowledge base dirname not specified");
elsif not OS_Lib.Is_Directory (To_String (KB_Dir)) then
Fail ("collect_kb: cannot find directory " & To_String (KB_Dir));
end if;
if Verbose_Mode then
Text_IO.Put_Line ("collect_kb: parsing " & To_String (KB_Dir));
end if;
Directories.Start_Search
(Search,
Directory => To_String (KB_Dir),
Pattern => "",
Filter => (Directories.Ordinary_File => True, others => False));
while Directories.More_Entries (Search) loop
Directories.Get_Next_Entry (Search, File);
if Verbose_Mode then
Text_IO.Put_Line (" " & Directories.Full_Name (File));
end if;
declare
Ext : constant String :=
Characters.Handling.To_Lower
(Directories.Extension (Directories.Full_Name (File)));
begin
if Ext = "xml" then
XML_Files.Append (Directories.Full_Name (File));
elsif Ext = "ent" then
Entities.Append (Directories.Full_Name (File));
elsif Ext = "xsd" then
if Schema = Null_Unbounded_String then
Schema := To_Unbounded_String (Directories.Full_Name (File));
else
Fail ("collect_kb: only one schema file is allowed");
end if;
else
if Verbose_Mode then
Text_IO.Put_Line (" unknown file type, skipping");
end if;
end if;
end;
end loop;
Directories.End_Search (Search);
if XML_Files.Is_Empty then
Fail ("collect_kb: no xml files found in " & To_String (KB_Dir));
end if;
if Schema /= Null_Unbounded_String then
Text_IO.Open (KB_File_In, Text_IO.In_File, To_String (Schema));
while not Text_IO.End_Of_File (KB_File_In) loop
Append (Input_Buffer, Text_IO.Get_Line (KB_File_In) & ASCII.LF);
end loop;
Text_IO.Close (KB_File_In);
Add_Buffer_To_Input (To_String (Schema));
end if;
Input_Buffer := Null_Unbounded_String;
for Ent_File of Entities loop
Text_IO.Open (KB_File_In, Text_IO.In_File, Ent_File);
while not Text_IO.End_Of_File (KB_File_In) loop
Append (Input_Buffer, Text_IO.Get_Line (KB_File_In) & ASCII.LF);
end loop;
Text_IO.Close (KB_File_In);
Add_Buffer_To_Input (Ent_File);
Input_Buffer := Null_Unbounded_String;
end loop;
Entities.Clear;
for XML_File of XML_Files loop
Text_IO.Open (KB_File_In, Text_IO.In_File, XML_File);
while not Text_IO.End_Of_File (KB_File_In) loop
Append (Input_Buffer, Text_IO.Get_Line (KB_File_In) & ASCII.LF);
end loop;
Text_IO.Close (KB_File_In);
Add_Buffer_To_Input (XML_File);
Input_Buffer := Null_Unbounded_String;
end loop;
XML_Files.Clear;
declare
type Substring is new String (1 .. Length (All_Input));
package Output is new Direct_IO (Substring);
F : Output.File_Type;
begin
Output.Create (F, Output.Out_File, To_String (Output_File));
Output.Write (F, Substring (To_String (All_Input)));
Output.Close (F);
end;
exception
when Ex : Command_Line.Invalid_Switch =>
Text_IO.Put_Line
(Text_IO.Standard_Error, Ada.Exceptions.Exception_Message (Ex));
Help;
OS_Lib.OS_Exit (1);
when Ex : others =>
Text_IO.Put_Line
(Text_IO.Standard_Error, Ada.Exceptions.Exception_Information (Ex));
OS_Lib.OS_Exit (2);
end Collect_KB;
|
VMika/DES_Ada | Ada | 184 | adb |
WITH P_DesHandler;
USE P_DesHandler;
----------
-- Main --
----------
procedure mainSequential is
DesAlg : aliased DesHandler;
begin
DesAlg.Process;
end mainSequential;
|
optikos/oasis | Ada | 1,522 | ads | -- Copyright (c) 2019 Maxim Reznik <[email protected]>
--
-- SPDX-License-Identifier: MIT
-- License-Filename: LICENSE
-------------------------------------------------------------
with Program.Elements.Expressions;
with Program.Lexical_Elements;
package Program.Elements.Parenthesized_Expressions is
pragma Pure (Program.Elements.Parenthesized_Expressions);
type Parenthesized_Expression is
limited interface and Program.Elements.Expressions.Expression;
type Parenthesized_Expression_Access is
access all Parenthesized_Expression'Class with Storage_Size => 0;
not overriding function Expression
(Self : Parenthesized_Expression)
return not null Program.Elements.Expressions.Expression_Access
is abstract;
type Parenthesized_Expression_Text is limited interface;
type Parenthesized_Expression_Text_Access is
access all Parenthesized_Expression_Text'Class with Storage_Size => 0;
not overriding function To_Parenthesized_Expression_Text
(Self : aliased in out Parenthesized_Expression)
return Parenthesized_Expression_Text_Access is abstract;
not overriding function Left_Bracket_Token
(Self : Parenthesized_Expression_Text)
return not null Program.Lexical_Elements.Lexical_Element_Access
is abstract;
not overriding function Right_Bracket_Token
(Self : Parenthesized_Expression_Text)
return not null Program.Lexical_Elements.Lexical_Element_Access
is abstract;
end Program.Elements.Parenthesized_Expressions;
|
BrickBot/Bound-T-H8-300 | Ada | 11,463 | ads | -- Unbounded_Controlled_Vectors (decl)
--
-- Vector structure of unbounded (dynamic) length, generic in
-- the element type, indexed by Positive, controlled for dynamic
-- memory usage.
--
-- A component of the Bound-T Worst-Case Execution Time Tool.
--
-------------------------------------------------------------------------------
-- Copyright (c) 1999 .. 2015 Tidorum Ltd
-- All rights reserved.
--
-- Redistribution and use in source and binary forms, with or without
-- modification, are permitted provided that the following conditions are met:
--
-- 1. Redistributions of source code must retain the above copyright notice, this
-- list of conditions and the following disclaimer.
-- 2. Redistributions in binary form must reproduce the above copyright notice,
-- this list of conditions and the following disclaimer in the documentation
-- and/or other materials provided with the distribution.
--
-- This software is provided by the copyright holders and contributors "as is" and
-- any express or implied warranties, including, but not limited to, the implied
-- warranties of merchantability and fitness for a particular purpose are
-- disclaimed. In no event shall the copyright owner or contributors be liable for
-- any direct, indirect, incidental, special, exemplary, or consequential damages
-- (including, but not limited to, procurement of substitute goods or services;
-- loss of use, data, or profits; or business interruption) however caused and
-- on any theory of liability, whether in contract, strict liability, or tort
-- (including negligence or otherwise) arising in any way out of the use of this
-- software, even if advised of the possibility of such damage.
--
-- Other modules (files) of this software composition should contain their
-- own copyright statements, which may have different copyright and usage
-- conditions. The above conditions apply to this file.
-------------------------------------------------------------------------------
--
-- $Revision: 1.2 $
-- $Date: 2015/10/24 19:36:53 $
--
-- $Log: unbounded_controlled_vectors.ads,v $
-- Revision 1.2 2015/10/24 19:36:53 niklas
-- Moved to free licence.
--
-- Revision 1.1 2009-10-07 19:26:11 niklas
-- BT-CH-0183: Cell-sets are a tagged-type class.
--
with Ada.Finalization;
--:dbpool with GNAT.Debug_Pools;
generic
type Element_Type is private;
--
-- The vector element type.
type Vector_Type is array (Positive range <>) of Element_Type;
--
-- An unbounded vector can be converted to a "normal" vector
-- of this type.
Initial_Size : Positive := 5;
--
-- The initial storage allocation for an unbounded vector,
-- in terms of the number of elements it can hold.
Size_Increment : Positive := 10;
--
-- When an unbounded vector grows past its current storage
-- allocation, its allocation is increased by the necessary
-- multiple of this number of elements.
Deallocate : in out Boolean;
--
-- Option variable to enable or disable the use of
-- Unchecked_Deallocation to discard unused heap memory.
package Unbounded_Controlled_Vectors is
subtype Index_Type is Positive;
--
-- Vectors are indexed by values of this type, perhaps further
-- constrained by First_Index, below.
First_Index : constant := 1;
--
-- The indices always start with 1.
subtype Real_Index_Type is Index_Type range First_Index .. Index_Type'Last;
--
-- The index range that can really be used.
type Unbounded_Vector is new Ada.Finalization.Controlled with private;
--
-- An ordered sequence of values of Element_Type, indexed
-- by a dense sequence (range) of values of Real_Index_Type.
-- Given an index, the element at that index can be read
-- or written. New elements can be added after the last one,
-- but not before the first one.
-- Currently, the index range of a vector always starts at
-- First_Index, with the upper end dynamically set.
--
-- The initial value of an unbounded vector is the null sequence
-- (no elements). See also Null_Unbounded_Vector, below.
-- overriding
procedure Adjust (Object : in out Unbounded_Vector);
-- overriding
procedure Finalize (Object : in out Unbounded_Vector);
Null_Unbounded_Vector : constant Unbounded_Vector;
--
-- An empty sequence.
--
-- Null_Unbounded_Vector is the default initial value of every
-- object object of type Unbounded_Vector.
function "=" (Left, Right : Unbounded_Vector) return Boolean;
--
-- Whether the Left and Right have exactly equal elements
-- and in the same order.
function Length (V : Unbounded_Vector) return Natural;
--
-- The number of elements in the vector.
function First (V : Unbounded_Vector) return Index_Type;
--
-- The index of the first element in the vector.
-- Currently, this is always First_Index, but this
-- function is provided for symmetry and for possible
-- future extensions.
function Last (V : Unbounded_Vector) return Natural;
--
-- The index of the last element in the vector.
-- If the vector is null (length = 0), the returned
-- value is Index_Type'Pred (First(V)).
-- This will currently be zero, since First_Index = 1.
function Next (V : Unbounded_Vector) return Index_Type;
--
-- The index that follows the last index in the vector.
-- If the vector is null (length = 0) the return value is
-- First_Index, otherwise it is Index_Type'Succ(Last(V)).
procedure Set (
Vector : in out Unbounded_Vector;
Index : in Index_Type;
To : in Element_Type);
--
-- Changes the value of the Vector element at Index to
-- the value To.
--
-- If Index is greater than Last(Vector), the values of
-- elements for the indices between Last(Vector) and Index
-- are undefined (unless Element_Type has a defined default
-- value).
--
-- After Set, Length (Vector) and Last (Vector) will reflect the
-- possible growth in the vector's length.
procedure Append (
Value : in Element_Type;
To : in out Unbounded_Vector);
--
-- Extends the To vector by one element, assigning it
-- the given value.
-- This is equivalent to Set (To, Next (To), Value).
procedure Truncate_Length (
Vector : in out Unbounded_Vector;
To : in Natural);
--
-- Truncates the Vector To the given length, but leaves the
-- "excess" storage (if any) allocated.
--
-- Propagates Constraint_Error if the Vector is shorter than
-- the desired length (To), in other words if the operation
-- tries to lengthen the Vector.
procedure Erase (Item : in out Unbounded_Vector);
--
-- Truncates the vector to a null vector (zero length)
-- and discards the allocated storage, if any.
function Element (
Vector : Unbounded_Vector;
Index : Index_Type)
return Element_Type;
--
-- Returns the value of the element at the given Index in the
-- given Vector.
--
-- If Index is not in the range First (Vector) .. Last (Vector),
-- Constraint_Error is raised.
function Index (
Source : Unbounded_Vector;
Value : Element_Type)
return Index_Type;
--
-- Searches the Source vector for an element with the given
-- Value, and returns the (first) index where the value
-- is found. If no element matches Value, the function
-- returns Index_Type'Succ (Last (Vector)).
procedure Drop (
Index : in Index_Type;
From : in out Unbounded_Vector);
--
-- Removes the element at the given Index From the given vector
-- and fills the gap by shifting later elements down one index
-- position. Raises Constraint_Error if the Index is not in the
-- range First (From) .. Last (From).
function Is_Element (
Source : Unbounded_Vector;
Value : Element_Type)
return Boolean;
--
-- Whether the given Value is an element of the Source vector.
procedure Find_Or_Add (
Value : in Element_Type;
Vector : in out Unbounded_Vector;
Index : out Index_Type);
--
-- Finds the Value in the Vector and returns the (first) Index
-- where Element (Vector, Index) = Value. If the Value is not
-- in the Vector originally, the procedure adds it to the Vector
-- (using Append) and returns the new Index which in this case
-- equals Last (Vector) on return. Note that Last (Vector) has
-- in this case increased by one relative to its value before
-- the call.
procedure Add (
Value : in Element_Type;
To : in out Unbounded_Vector);
--
-- Adds the Value To the vector, if the Value is not in the
-- vector originally. Same as Find_Or_Add but ignoring the Index.
procedure Move_All (
From : in out Unbounded_Vector;
To : in out Unbounded_Vector);
--
-- Moves all elements From a given vector To another given
-- vector when the element is not already in the other vector.
-- That is, each element From the first vector is added To
-- the second vector and removed from the first vector.
-- If the two parameters are different vector objects, the
-- procedure erases the From vector. If they are the same
-- vector object, the procedure has no effect.
function To_Vector (V : Unbounded_Vector) return Vector_Type;
--
-- Returns a normal (bounded) array that contains the same
-- index range and the same values as the given vector.
procedure Extend (
Vector : in out Unbounded_Vector;
To_Index : in Index_Type);
--
-- Extends the space allocated for the Vector at least To the
-- given Index. The current length and contents of the Vector
-- are not changed. Nothing is done if the Vector already has
-- at least the required storage allocated.
procedure Print_Debug_Pool;
--
-- Prints the information collected by GNAT.Debug_Pool, if enabled.
private
type Shared_Vector_Type (Max_Length : Natural) is record
Ref_Count : Natural;
Length : Natural := 0;
Vector : Vector_Type (1 .. Max_Length);
end record;
--
-- A vector of at most Max_Length elements, currently with Length
-- elements in Vector(1 .. Length). Thus Length <= Max_Length and
-- may be < if there is some excess allocation of storage.
--
-- The vector may be shared as an element-container for several
-- Unbounded_Vector objects. The Ref_Count component shows how
-- many objects share this vector. A shared vector is immutable
-- if Ref_Count is larger than 1. Any attempt to change such a
-- shared vector creates a copy ("copy on change").
type Shared_Vector_Ref is access Shared_Vector_Type;
--:dbpool Shared_Vector_Pool : GNAT.Debug_Pools.Debug_Pool;
--:dbpool for Shared_Vector_Ref'Storage_Pool use Shared_Vector_Pool;
type Unbounded_Vector is new Ada.Finalization.Controlled with record
Store : Shared_Vector_Ref;
end record;
--
-- A vector of elements with an unbounded length.
--
-- Store
-- The storage allocated for the elements, possibly shared with
-- other Unbounded_Vector objects.
-- If Store = null the vector is logically a null vector of
-- zero length.
Null_Unbounded_Vector : constant Unbounded_Vector := (
Ada.Finalization.Controlled with Store => null);
end Unbounded_Controlled_Vectors;
|
charlie5/lace | Ada | 403 | adb | with
ada.Text_IO,
xml.Writer;
procedure launch_Write
is
use ada.Text_IO, xml.Writer;
begin
start_Document (Standard_Output);
start (standard_Output, "foo", "bar" + "bing");
empty (standard_Output, "frodo", MkAtt ("hobbit" + "true", "ring" + "1") & ("purpose" + "To rule them all."));
finish (standard_Output, "foo");
end_Document (Standard_Output);
end launch_Write;
|
stcarrez/dynamo | Ada | 3,455 | ads | ------------------------------------------------------------------------------
-- --
-- ASIS-for-GNAT IMPLEMENTATION COMPONENTS --
-- --
-- A 4 G . A _ S T A N D --
-- --
-- S p e c --
-- --
-- $Revision: 15117 $
-- --
-- Copyright (c) 2002, Free Software Foundation, Inc. --
-- --
-- ASIS-for-GNAT is free software; you can redistribute it and/or modify it --
-- under terms of the GNU General Public License as published by the Free --
-- Software Foundation; either version 2, or (at your option) any later --
-- version. ASIS-for-GNAT is distributed in the hope that it will be use- --
-- ful, but WITHOUT ANY WARRANTY; without even the implied warranty of MER- --
-- CHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General --
-- Public License for more details. You should have received a copy of the --
-- GNU General Public License distributed with ASIS-for-GNAT; see file --
-- COPYING. If not, write to the Free Software Foundation, 59 Temple Place --
-- - Suite 330, Boston, MA 02111-1307, USA. --
-- --
-- --
-- --
-- --
-- --
-- --
-- --
-- --
-- ASIS-for-GNAT was originally developed by the ASIS-for-GNAT team at the --
-- Software Engineering Laboratory of the Swiss Federal Institute of --
-- Technology (LGL-EPFL) in Lausanne, Switzerland, in cooperation with the --
-- Scientific Research Computer Center of Moscow State University (SRCC --
-- MSU), Russia, with funding partially provided by grants from the Swiss --
-- National Science Foundation and the Swiss Academy of Engineering --
-- Sciences. ASIS-for-GNAT is now maintained by Ada Core Technologies Inc --
-- (http://www.gnat.com). --
-- --
------------------------------------------------------------------------------
-- We need this renaming because the GNAT Stand package and the ASIS A4G.Stand
-- package conflict if mentioned in the same context clause. This renaming
-- seems to be the cheapest way to correct the old bad choice of the name
-- of the ASIS package (A4G.Stand)
with A4G.Stand;
package A4G.A_Stand renames A4G.Stand;
|
reznikmm/matreshka | Ada | 12,188 | ads | ------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- Ada Modeling Framework --
-- --
-- Runtime Library Component --
-- --
------------------------------------------------------------------------------
-- --
-- Copyright © 2011-2012, Vadim Godunko <[email protected]> --
-- All rights reserved. --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions --
-- are met: --
-- --
-- * Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- --
-- * Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in the --
-- documentation and/or other materials provided with the distribution. --
-- --
-- * Neither the name of the Vadim Godunko, IE nor the names of its --
-- contributors may be used to endorse or promote products derived from --
-- this software without specific prior written permission. --
-- --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR --
-- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
-- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED --
-- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR --
-- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF --
-- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING --
-- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS --
-- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
-- --
------------------------------------------------------------------------------
-- $Revision$ $Date$
------------------------------------------------------------------------------
with AMF.Internals.UML_Value_Specifications;
with AMF.UML.Dependencies.Collections;
with AMF.UML.Literal_Unlimited_Naturals;
with AMF.UML.Named_Elements;
with AMF.UML.Namespaces;
with AMF.UML.Packages.Collections;
with AMF.UML.Parameterable_Elements;
with AMF.UML.String_Expressions;
with AMF.UML.Template_Parameters;
with AMF.UML.Types;
with AMF.Visitors;
package AMF.Internals.UML_Literal_Unlimited_Naturals is
type UML_Literal_Unlimited_Natural_Proxy is
limited new AMF.Internals.UML_Value_Specifications.UML_Value_Specification_Proxy
and AMF.UML.Literal_Unlimited_Naturals.UML_Literal_Unlimited_Natural with null record;
overriding function Get_Value
(Self : not null access constant UML_Literal_Unlimited_Natural_Proxy)
return AMF.Unlimited_Natural;
-- Getter of LiteralUnlimitedNatural::value.
--
-- The specified UnlimitedNatural value.
overriding procedure Set_Value
(Self : not null access UML_Literal_Unlimited_Natural_Proxy;
To : AMF.Unlimited_Natural);
-- Setter of LiteralUnlimitedNatural::value.
--
-- The specified UnlimitedNatural value.
overriding function Get_Type
(Self : not null access constant UML_Literal_Unlimited_Natural_Proxy)
return AMF.UML.Types.UML_Type_Access;
-- Getter of TypedElement::type.
--
-- The type of the TypedElement.
-- This information is derived from the return result for this Operation.
overriding procedure Set_Type
(Self : not null access UML_Literal_Unlimited_Natural_Proxy;
To : AMF.UML.Types.UML_Type_Access);
-- Setter of TypedElement::type.
--
-- The type of the TypedElement.
-- This information is derived from the return result for this Operation.
overriding function Get_Client_Dependency
(Self : not null access constant UML_Literal_Unlimited_Natural_Proxy)
return AMF.UML.Dependencies.Collections.Set_Of_UML_Dependency;
-- Getter of NamedElement::clientDependency.
--
-- Indicates the dependencies that reference the client.
overriding function Get_Name_Expression
(Self : not null access constant UML_Literal_Unlimited_Natural_Proxy)
return AMF.UML.String_Expressions.UML_String_Expression_Access;
-- Getter of NamedElement::nameExpression.
--
-- The string expression used to define the name of this named element.
overriding procedure Set_Name_Expression
(Self : not null access UML_Literal_Unlimited_Natural_Proxy;
To : AMF.UML.String_Expressions.UML_String_Expression_Access);
-- Setter of NamedElement::nameExpression.
--
-- The string expression used to define the name of this named element.
overriding function Get_Namespace
(Self : not null access constant UML_Literal_Unlimited_Natural_Proxy)
return AMF.UML.Namespaces.UML_Namespace_Access;
-- Getter of NamedElement::namespace.
--
-- Specifies the namespace that owns the NamedElement.
overriding function Get_Qualified_Name
(Self : not null access constant UML_Literal_Unlimited_Natural_Proxy)
return AMF.Optional_String;
-- Getter of NamedElement::qualifiedName.
--
-- A name which allows the NamedElement to be identified within a
-- hierarchy of nested Namespaces. It is constructed from the names of the
-- containing namespaces starting at the root of the hierarchy and ending
-- with the name of the NamedElement itself.
overriding function Get_Owning_Template_Parameter
(Self : not null access constant UML_Literal_Unlimited_Natural_Proxy)
return AMF.UML.Template_Parameters.UML_Template_Parameter_Access;
-- Getter of ParameterableElement::owningTemplateParameter.
--
-- The formal template parameter that owns this element.
overriding procedure Set_Owning_Template_Parameter
(Self : not null access UML_Literal_Unlimited_Natural_Proxy;
To : AMF.UML.Template_Parameters.UML_Template_Parameter_Access);
-- Setter of ParameterableElement::owningTemplateParameter.
--
-- The formal template parameter that owns this element.
overriding function Get_Template_Parameter
(Self : not null access constant UML_Literal_Unlimited_Natural_Proxy)
return AMF.UML.Template_Parameters.UML_Template_Parameter_Access;
-- Getter of ParameterableElement::templateParameter.
--
-- The template parameter that exposes this element as a formal parameter.
overriding procedure Set_Template_Parameter
(Self : not null access UML_Literal_Unlimited_Natural_Proxy;
To : AMF.UML.Template_Parameters.UML_Template_Parameter_Access);
-- Setter of ParameterableElement::templateParameter.
--
-- The template parameter that exposes this element as a formal parameter.
overriding function Is_Computable
(Self : not null access constant UML_Literal_Unlimited_Natural_Proxy)
return Boolean;
-- Operation LiteralUnlimitedNatural::isComputable.
--
-- The query isComputable() is redefined to be true.
overriding function Unlimited_Value
(Self : not null access constant UML_Literal_Unlimited_Natural_Proxy)
return AMF.Unlimited_Natural;
-- Operation LiteralUnlimitedNatural::unlimitedValue.
--
-- The query unlimitedValue() gives the value.
overriding function Is_Compatible_With
(Self : not null access constant UML_Literal_Unlimited_Natural_Proxy;
P : AMF.UML.Parameterable_Elements.UML_Parameterable_Element_Access)
return Boolean;
-- Operation ValueSpecification::isCompatibleWith.
--
-- The query isCompatibleWith() determines if this parameterable element
-- is compatible with the specified parameterable element. By default
-- parameterable element P is compatible with parameterable element Q if
-- the kind of P is the same or a subtype as the kind of Q. In addition,
-- for ValueSpecification, the type must be conformant with the type of
-- the specified parameterable element.
overriding function Unlimited_Value
(Self : not null access constant UML_Literal_Unlimited_Natural_Proxy)
return AMF.Optional_Unlimited_Natural;
-- Operation ValueSpecification::unlimitedValue.
--
-- The query unlimitedValue() gives a single UnlimitedNatural value when
-- one can be computed.
overriding function All_Owning_Packages
(Self : not null access constant UML_Literal_Unlimited_Natural_Proxy)
return AMF.UML.Packages.Collections.Set_Of_UML_Package;
-- Operation NamedElement::allOwningPackages.
--
-- The query allOwningPackages() returns all the directly or indirectly
-- owning packages.
overriding function Is_Distinguishable_From
(Self : not null access constant UML_Literal_Unlimited_Natural_Proxy;
N : AMF.UML.Named_Elements.UML_Named_Element_Access;
Ns : AMF.UML.Namespaces.UML_Namespace_Access)
return Boolean;
-- Operation NamedElement::isDistinguishableFrom.
--
-- The query isDistinguishableFrom() determines whether two NamedElements
-- may logically co-exist within a Namespace. By default, two named
-- elements are distinguishable if (a) they have unrelated types or (b)
-- they have related types but different names.
overriding function Namespace
(Self : not null access constant UML_Literal_Unlimited_Natural_Proxy)
return AMF.UML.Namespaces.UML_Namespace_Access;
-- Operation NamedElement::namespace.
--
-- Missing derivation for NamedElement::/namespace : Namespace
overriding function Is_Template_Parameter
(Self : not null access constant UML_Literal_Unlimited_Natural_Proxy)
return Boolean;
-- Operation ParameterableElement::isTemplateParameter.
--
-- The query isTemplateParameter() determines if this parameterable
-- element is exposed as a formal template parameter.
overriding procedure Enter_Element
(Self : not null access constant UML_Literal_Unlimited_Natural_Proxy;
Visitor : in out AMF.Visitors.Abstract_Visitor'Class;
Control : in out AMF.Visitors.Traverse_Control);
-- Dispatch call to corresponding subprogram of visitor interface.
overriding procedure Leave_Element
(Self : not null access constant UML_Literal_Unlimited_Natural_Proxy;
Visitor : in out AMF.Visitors.Abstract_Visitor'Class;
Control : in out AMF.Visitors.Traverse_Control);
-- Dispatch call to corresponding subprogram of visitor interface.
overriding procedure Visit_Element
(Self : not null access constant UML_Literal_Unlimited_Natural_Proxy;
Iterator : in out AMF.Visitors.Abstract_Iterator'Class;
Visitor : in out AMF.Visitors.Abstract_Visitor'Class;
Control : in out AMF.Visitors.Traverse_Control);
-- Dispatch call to corresponding subprogram of iterator interface.
end AMF.Internals.UML_Literal_Unlimited_Naturals;
|
francesco-bongiovanni/ewok-kernel | Ada | 4,912 | 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 ada.unchecked_conversion;
with m4.systick;
package body soc.dwt
with spark_mode => on,
Refined_State => (Cnt => DWT_CYCCNT,
Ctrl => DWT_CONTROL,
Ini_F => init_done,
Loo => dwt_loops,
Last => last_dwt,
Lar_register => LAR,
Dem => DEMCR)
is
-----------------------------------------------------
-- SPARK ghost functions and procedures
-----------------------------------------------------
function init_is_done
return boolean
is
begin
return init_done;
end init_is_done;
function check_32bits_overflow
return boolean
is
begin
return (init_done and then dwt_loops < unsigned_64(unsigned_32'Last));
end;
--------------------------------------------------
-- The Data Watchpoint and Trace unit (DWT) --
-- (Cf. ARMv7-M Arch. Ref. Manual, C1.8, p.779) --
--------------------------------------------------
procedure reset_timer
with
Refined_Global => (Input => init_done,
In_Out => (DEMCR, DWT_CONTROL),
Output => (LAR, DWT_CYCCNT))
is
begin
DEMCR.TRCENA := true;
LAR := LAR_ENABLE_WRITE_KEY;
DWT_CYCCNT := 0; -- reset the counter
DWT_CONTROL.CYCCNTENA := false;
end reset_timer;
procedure start_timer
with
Refined_Global => (Input => init_done,
In_Out => DWT_CONTROL)
is
begin
DWT_CONTROL.CYCCNTENA := true; -- enable the counter
end start_timer;
procedure stop_timer
with
Refined_Global=> (Input => init_done,
In_Out => DWT_CONTROL)
is
begin
DWT_CONTROL.CYCCNTENA := false; -- stop the counter
end stop_timer;
procedure ovf_manage
with
Refined_Post => (dwt_loops = dwt_loops'Old
or dwt_loops = (dwt_loops'Old + 1))
is
dwt : unsigned_32;
begin
dwt := DWT_CYCCNT;
if dwt < last_dwt then
dwt_loops := dwt_loops + 1;
end if;
last_dwt := dwt;
end ovf_manage;
procedure init
with
Refined_Post => (init_done),
Refined_Global => (In_Out => (init_done,
DWT_CONTROL,
DEMCR),
Output => (last_dwt,
dwt_loops,
DWT_CYCCNT,
LAR))
is
begin
last_dwt := 0;
dwt_loops := 0;
reset_timer;
start_timer;
init_done := True;
end init;
procedure get_cycles_32 (cycles : out unsigned_32)
with
Refined_Global=> (Input => init_done,
In_Out => DWT_CYCCNT)
is
begin
cycles := DWT_CYCCNT; -- can't return volatile (SPARK RM 7.1.3(12))
end get_cycles_32;
procedure get_cycles (cycles : out unsigned_64)
with
Refined_Global => (Input => (init_done, dwt_loops),
In_Out => DWT_CYCCNT)
is
cyccnt : unsigned_64;
begin
cyccnt := unsigned_64(DWT_CYCCNT);
cyccnt := cyccnt and 16#0000_0000_ffff_ffff#;
cycles := interfaces.shift_left (dwt_loops, 32) + cyccnt;
end get_cycles;
procedure get_microseconds (micros : out unsigned_64)
with
Refined_Global => (Input => (init_done, dwt_loops),
In_Out => DWT_CYCCNT)
is
cycles : unsigned_64;
begin
get_cycles(cycles);
micros := cycles / (m4.systick.MAIN_CLOCK_FREQUENCY / 1000_000);
end get_microseconds;
procedure get_milliseconds (milli : out unsigned_64)
with
Refined_Global => (Input => (init_done, dwt_loops),
In_Out => DWT_CYCCNT)
is
cycles : unsigned_64;
begin
get_cycles(cycles);
milli := cycles / (m4.systick.MAIN_CLOCK_FREQUENCY / 1000);
end get_milliseconds;
end soc.dwt;
|
reznikmm/matreshka | Ada | 15,242 | ads | ------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- Ada Modeling Framework --
-- --
-- Runtime Library Component --
-- --
------------------------------------------------------------------------------
-- --
-- Copyright © 2012-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$
------------------------------------------------------------------------------
-- This file is generated, don't edit it.
------------------------------------------------------------------------------
package AMF.Internals.Tables.OCL_Metamodel.Objects is
procedure Initialize;
private
procedure Initialize_1 (Extent : AMF.Internals.AMF_Extent);
procedure Initialize_2 (Extent : AMF.Internals.AMF_Extent);
procedure Initialize_3 (Extent : AMF.Internals.AMF_Extent);
procedure Initialize_4 (Extent : AMF.Internals.AMF_Extent);
procedure Initialize_5 (Extent : AMF.Internals.AMF_Extent);
procedure Initialize_6 (Extent : AMF.Internals.AMF_Extent);
procedure Initialize_7 (Extent : AMF.Internals.AMF_Extent);
procedure Initialize_8 (Extent : AMF.Internals.AMF_Extent);
procedure Initialize_9 (Extent : AMF.Internals.AMF_Extent);
procedure Initialize_10 (Extent : AMF.Internals.AMF_Extent);
procedure Initialize_11 (Extent : AMF.Internals.AMF_Extent);
procedure Initialize_12 (Extent : AMF.Internals.AMF_Extent);
procedure Initialize_13 (Extent : AMF.Internals.AMF_Extent);
procedure Initialize_14 (Extent : AMF.Internals.AMF_Extent);
procedure Initialize_15 (Extent : AMF.Internals.AMF_Extent);
procedure Initialize_16 (Extent : AMF.Internals.AMF_Extent);
procedure Initialize_17 (Extent : AMF.Internals.AMF_Extent);
procedure Initialize_18 (Extent : AMF.Internals.AMF_Extent);
procedure Initialize_19 (Extent : AMF.Internals.AMF_Extent);
procedure Initialize_20 (Extent : AMF.Internals.AMF_Extent);
procedure Initialize_21 (Extent : AMF.Internals.AMF_Extent);
procedure Initialize_22 (Extent : AMF.Internals.AMF_Extent);
procedure Initialize_23 (Extent : AMF.Internals.AMF_Extent);
procedure Initialize_24 (Extent : AMF.Internals.AMF_Extent);
procedure Initialize_25 (Extent : AMF.Internals.AMF_Extent);
procedure Initialize_26 (Extent : AMF.Internals.AMF_Extent);
procedure Initialize_27 (Extent : AMF.Internals.AMF_Extent);
procedure Initialize_28 (Extent : AMF.Internals.AMF_Extent);
procedure Initialize_29 (Extent : AMF.Internals.AMF_Extent);
procedure Initialize_30 (Extent : AMF.Internals.AMF_Extent);
procedure Initialize_31 (Extent : AMF.Internals.AMF_Extent);
procedure Initialize_32 (Extent : AMF.Internals.AMF_Extent);
procedure Initialize_33 (Extent : AMF.Internals.AMF_Extent);
procedure Initialize_34 (Extent : AMF.Internals.AMF_Extent);
procedure Initialize_35 (Extent : AMF.Internals.AMF_Extent);
procedure Initialize_36 (Extent : AMF.Internals.AMF_Extent);
procedure Initialize_37 (Extent : AMF.Internals.AMF_Extent);
procedure Initialize_38 (Extent : AMF.Internals.AMF_Extent);
procedure Initialize_39 (Extent : AMF.Internals.AMF_Extent);
procedure Initialize_40 (Extent : AMF.Internals.AMF_Extent);
procedure Initialize_41 (Extent : AMF.Internals.AMF_Extent);
procedure Initialize_42 (Extent : AMF.Internals.AMF_Extent);
procedure Initialize_43 (Extent : AMF.Internals.AMF_Extent);
procedure Initialize_44 (Extent : AMF.Internals.AMF_Extent);
procedure Initialize_45 (Extent : AMF.Internals.AMF_Extent);
procedure Initialize_46 (Extent : AMF.Internals.AMF_Extent);
procedure Initialize_47 (Extent : AMF.Internals.AMF_Extent);
procedure Initialize_48 (Extent : AMF.Internals.AMF_Extent);
procedure Initialize_49 (Extent : AMF.Internals.AMF_Extent);
procedure Initialize_50 (Extent : AMF.Internals.AMF_Extent);
procedure Initialize_51 (Extent : AMF.Internals.AMF_Extent);
procedure Initialize_52 (Extent : AMF.Internals.AMF_Extent);
procedure Initialize_53 (Extent : AMF.Internals.AMF_Extent);
procedure Initialize_54 (Extent : AMF.Internals.AMF_Extent);
procedure Initialize_55 (Extent : AMF.Internals.AMF_Extent);
procedure Initialize_56 (Extent : AMF.Internals.AMF_Extent);
procedure Initialize_57 (Extent : AMF.Internals.AMF_Extent);
procedure Initialize_58 (Extent : AMF.Internals.AMF_Extent);
procedure Initialize_59 (Extent : AMF.Internals.AMF_Extent);
procedure Initialize_60 (Extent : AMF.Internals.AMF_Extent);
procedure Initialize_61 (Extent : AMF.Internals.AMF_Extent);
procedure Initialize_62 (Extent : AMF.Internals.AMF_Extent);
procedure Initialize_63 (Extent : AMF.Internals.AMF_Extent);
procedure Initialize_64 (Extent : AMF.Internals.AMF_Extent);
procedure Initialize_65 (Extent : AMF.Internals.AMF_Extent);
procedure Initialize_66 (Extent : AMF.Internals.AMF_Extent);
procedure Initialize_67 (Extent : AMF.Internals.AMF_Extent);
procedure Initialize_68 (Extent : AMF.Internals.AMF_Extent);
procedure Initialize_69 (Extent : AMF.Internals.AMF_Extent);
procedure Initialize_70 (Extent : AMF.Internals.AMF_Extent);
procedure Initialize_71 (Extent : AMF.Internals.AMF_Extent);
procedure Initialize_72 (Extent : AMF.Internals.AMF_Extent);
procedure Initialize_73 (Extent : AMF.Internals.AMF_Extent);
procedure Initialize_74 (Extent : AMF.Internals.AMF_Extent);
procedure Initialize_75 (Extent : AMF.Internals.AMF_Extent);
procedure Initialize_76 (Extent : AMF.Internals.AMF_Extent);
procedure Initialize_77 (Extent : AMF.Internals.AMF_Extent);
procedure Initialize_78 (Extent : AMF.Internals.AMF_Extent);
procedure Initialize_79 (Extent : AMF.Internals.AMF_Extent);
procedure Initialize_80 (Extent : AMF.Internals.AMF_Extent);
procedure Initialize_81 (Extent : AMF.Internals.AMF_Extent);
procedure Initialize_82 (Extent : AMF.Internals.AMF_Extent);
procedure Initialize_83 (Extent : AMF.Internals.AMF_Extent);
procedure Initialize_84 (Extent : AMF.Internals.AMF_Extent);
procedure Initialize_85 (Extent : AMF.Internals.AMF_Extent);
procedure Initialize_86 (Extent : AMF.Internals.AMF_Extent);
procedure Initialize_87 (Extent : AMF.Internals.AMF_Extent);
procedure Initialize_88 (Extent : AMF.Internals.AMF_Extent);
procedure Initialize_89 (Extent : AMF.Internals.AMF_Extent);
procedure Initialize_90 (Extent : AMF.Internals.AMF_Extent);
procedure Initialize_91 (Extent : AMF.Internals.AMF_Extent);
procedure Initialize_92 (Extent : AMF.Internals.AMF_Extent);
procedure Initialize_93 (Extent : AMF.Internals.AMF_Extent);
procedure Initialize_94 (Extent : AMF.Internals.AMF_Extent);
procedure Initialize_95 (Extent : AMF.Internals.AMF_Extent);
procedure Initialize_96 (Extent : AMF.Internals.AMF_Extent);
procedure Initialize_97 (Extent : AMF.Internals.AMF_Extent);
procedure Initialize_98 (Extent : AMF.Internals.AMF_Extent);
procedure Initialize_99 (Extent : AMF.Internals.AMF_Extent);
procedure Initialize_100 (Extent : AMF.Internals.AMF_Extent);
procedure Initialize_101 (Extent : AMF.Internals.AMF_Extent);
procedure Initialize_102 (Extent : AMF.Internals.AMF_Extent);
procedure Initialize_103 (Extent : AMF.Internals.AMF_Extent);
procedure Initialize_104 (Extent : AMF.Internals.AMF_Extent);
procedure Initialize_105 (Extent : AMF.Internals.AMF_Extent);
procedure Initialize_106 (Extent : AMF.Internals.AMF_Extent);
procedure Initialize_107 (Extent : AMF.Internals.AMF_Extent);
procedure Initialize_108 (Extent : AMF.Internals.AMF_Extent);
procedure Initialize_109 (Extent : AMF.Internals.AMF_Extent);
procedure Initialize_110 (Extent : AMF.Internals.AMF_Extent);
procedure Initialize_111 (Extent : AMF.Internals.AMF_Extent);
procedure Initialize_112 (Extent : AMF.Internals.AMF_Extent);
procedure Initialize_113 (Extent : AMF.Internals.AMF_Extent);
procedure Initialize_114 (Extent : AMF.Internals.AMF_Extent);
procedure Initialize_115 (Extent : AMF.Internals.AMF_Extent);
procedure Initialize_116 (Extent : AMF.Internals.AMF_Extent);
procedure Initialize_117 (Extent : AMF.Internals.AMF_Extent);
procedure Initialize_118 (Extent : AMF.Internals.AMF_Extent);
procedure Initialize_119 (Extent : AMF.Internals.AMF_Extent);
procedure Initialize_120 (Extent : AMF.Internals.AMF_Extent);
procedure Initialize_121 (Extent : AMF.Internals.AMF_Extent);
procedure Initialize_122 (Extent : AMF.Internals.AMF_Extent);
procedure Initialize_123 (Extent : AMF.Internals.AMF_Extent);
procedure Initialize_124 (Extent : AMF.Internals.AMF_Extent);
procedure Initialize_125 (Extent : AMF.Internals.AMF_Extent);
procedure Initialize_126 (Extent : AMF.Internals.AMF_Extent);
procedure Initialize_127 (Extent : AMF.Internals.AMF_Extent);
procedure Initialize_128 (Extent : AMF.Internals.AMF_Extent);
procedure Initialize_129 (Extent : AMF.Internals.AMF_Extent);
procedure Initialize_130 (Extent : AMF.Internals.AMF_Extent);
procedure Initialize_131 (Extent : AMF.Internals.AMF_Extent);
procedure Initialize_132 (Extent : AMF.Internals.AMF_Extent);
procedure Initialize_133 (Extent : AMF.Internals.AMF_Extent);
procedure Initialize_134 (Extent : AMF.Internals.AMF_Extent);
procedure Initialize_135 (Extent : AMF.Internals.AMF_Extent);
procedure Initialize_136 (Extent : AMF.Internals.AMF_Extent);
procedure Initialize_137 (Extent : AMF.Internals.AMF_Extent);
procedure Initialize_138 (Extent : AMF.Internals.AMF_Extent);
procedure Initialize_139 (Extent : AMF.Internals.AMF_Extent);
procedure Initialize_140 (Extent : AMF.Internals.AMF_Extent);
procedure Initialize_141 (Extent : AMF.Internals.AMF_Extent);
procedure Initialize_142 (Extent : AMF.Internals.AMF_Extent);
procedure Initialize_143 (Extent : AMF.Internals.AMF_Extent);
procedure Initialize_144 (Extent : AMF.Internals.AMF_Extent);
procedure Initialize_145 (Extent : AMF.Internals.AMF_Extent);
procedure Initialize_146 (Extent : AMF.Internals.AMF_Extent);
procedure Initialize_147 (Extent : AMF.Internals.AMF_Extent);
procedure Initialize_148 (Extent : AMF.Internals.AMF_Extent);
procedure Initialize_149 (Extent : AMF.Internals.AMF_Extent);
procedure Initialize_150 (Extent : AMF.Internals.AMF_Extent);
procedure Initialize_151 (Extent : AMF.Internals.AMF_Extent);
procedure Initialize_152 (Extent : AMF.Internals.AMF_Extent);
procedure Initialize_153 (Extent : AMF.Internals.AMF_Extent);
procedure Initialize_154 (Extent : AMF.Internals.AMF_Extent);
procedure Initialize_155 (Extent : AMF.Internals.AMF_Extent);
procedure Initialize_156 (Extent : AMF.Internals.AMF_Extent);
procedure Initialize_157 (Extent : AMF.Internals.AMF_Extent);
procedure Initialize_158 (Extent : AMF.Internals.AMF_Extent);
procedure Initialize_159 (Extent : AMF.Internals.AMF_Extent);
procedure Initialize_160 (Extent : AMF.Internals.AMF_Extent);
procedure Initialize_161 (Extent : AMF.Internals.AMF_Extent);
procedure Initialize_162 (Extent : AMF.Internals.AMF_Extent);
procedure Initialize_163 (Extent : AMF.Internals.AMF_Extent);
procedure Initialize_164 (Extent : AMF.Internals.AMF_Extent);
procedure Initialize_165 (Extent : AMF.Internals.AMF_Extent);
procedure Initialize_166 (Extent : AMF.Internals.AMF_Extent);
procedure Initialize_167 (Extent : AMF.Internals.AMF_Extent);
procedure Initialize_168 (Extent : AMF.Internals.AMF_Extent);
procedure Initialize_169 (Extent : AMF.Internals.AMF_Extent);
procedure Initialize_170 (Extent : AMF.Internals.AMF_Extent);
procedure Initialize_171 (Extent : AMF.Internals.AMF_Extent);
procedure Initialize_172 (Extent : AMF.Internals.AMF_Extent);
procedure Initialize_173 (Extent : AMF.Internals.AMF_Extent);
procedure Initialize_174 (Extent : AMF.Internals.AMF_Extent);
procedure Initialize_175 (Extent : AMF.Internals.AMF_Extent);
procedure Initialize_176 (Extent : AMF.Internals.AMF_Extent);
procedure Initialize_177 (Extent : AMF.Internals.AMF_Extent);
procedure Initialize_178 (Extent : AMF.Internals.AMF_Extent);
end AMF.Internals.Tables.OCL_Metamodel.Objects;
|
redparavoz/ada-wiki | Ada | 2,348 | ads | -----------------------------------------------------------------------
-- wiki-filters-autolink -- Autolink filter to identify links in wiki
-- Copyright (C) 2016 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.
-----------------------------------------------------------------------
-- === Autolink Filters ===
-- The <tt>Wiki.Filters.Autolink</tt> package defines a filter that transforms URLs
-- in the Wiki text into links. The filter should be inserted in the filter chain
-- after the HTML and after the collector filters. The filter looks for the
-- text and transforms http:// and https:// links into real links. When such links
-- are found, the text is split so that next filters see only the text without
-- links and the <tt>Add_Link</tt> filter operations are called with the link.
package Wiki.Filters.Autolink is
pragma Preelaborate;
type Autolink_Filter is new Filter_Type with null record;
type Autolink_Filter_Access is access all Autolink_Filter'Class;
-- Find the position of the end of the link.
-- Returns 0 if the content is not a link.
function Find_End_Link (Filter : in Autolink_Filter;
Content : in Wiki.Strings.WString) return Natural;
-- Add a text content with the given format to the document. Identify URLs in the text
-- and transform them into links. For each link, call the Add_Link operation. The operation
-- recognizes http:// https:// ftp:// ftps://
overriding
procedure Add_Text (Filter : in out Autolink_Filter;
Document : in out Wiki.Documents.Document;
Text : in Wiki.Strings.WString;
Format : in Wiki.Format_Map);
end Wiki.Filters.Autolink;
|
sparre/JSA | Ada | 1,080 | adb | with
Ada.Calendar;
package body JSA.Intermediate_Backups is
In_A_Loop : Boolean := False;
Save_Time : Duration;
Loop_Start : Ada.Calendar.Time;
Saved : Boolean;
procedure Begin_Loop is
begin
In_A_Loop := True;
Save_Time := 0.0;
Saved := False;
Loop_Start := Ada.Calendar.Clock;
end Begin_Loop;
procedure End_Loop is
begin
if not Saved then
Save_State;
Saved := True;
end if;
In_A_Loop := False;
end End_Loop;
procedure End_Of_Iteration is
use Ada.Calendar;
Total_Time : constant Float := Float (Clock - Loop_Start);
Timestamp : Time;
begin
if Fraction * Total_Time > Float (Save_Time) then
Timestamp := Ada.Calendar.Clock;
Save_State;
Save_Time := Save_Time + (Clock - Timestamp);
Saved := True;
else
Saved := False;
end if;
end End_Of_Iteration;
function In_Loop return Boolean is
begin
return In_A_Loop;
end In_Loop;
end JSA.Intermediate_Backups;
|
reznikmm/matreshka | Ada | 5,451 | ads | ------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- Localization, Internationalization, Globalization for Ada --
-- --
-- Runtime Library Component --
-- --
------------------------------------------------------------------------------
-- --
-- Copyright © 2012-2015, Vadim Godunko <[email protected]> --
-- All rights reserved. --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions --
-- are met: --
-- --
-- * Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- --
-- * Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in the --
-- documentation and/or other materials provided with the distribution. --
-- --
-- * Neither the name of the Vadim Godunko, IE nor the names of its --
-- contributors may be used to endorse or promote products derived from --
-- this software without specific prior written permission. --
-- --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR --
-- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
-- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED --
-- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR --
-- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF --
-- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING --
-- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS --
-- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
-- --
------------------------------------------------------------------------------
-- $Revision$ $Date$
------------------------------------------------------------------------------
pragma Restrictions (No_Elaboration_Code);
-- GNAT: enforce generation of preinitialized data section instead of
-- generation of elaboration code.
package Matreshka.Internals.Unicode.Ucd.Core_0104 is
pragma Preelaborate;
Group_0104 : aliased constant Core_Second_Stage
:= (16#00# .. 16#27# => -- 010400 .. 010427
(Uppercase_Letter, Neutral,
Other, A_Letter, Upper, Alphabetic,
(Alphabetic
| Cased
| Changes_When_Lowercased
| Changes_When_Casefolded
| Changes_When_Casemapped
| Grapheme_Base
| ID_Continue
| ID_Start
| Uppercase
| XID_Continue
| XID_Start
| Changes_When_NFKC_Casefolded => True,
others => False)),
16#28# .. 16#4F# => -- 010428 .. 01044F
(Lowercase_Letter, Neutral,
Other, A_Letter, Lower, Alphabetic,
(Alphabetic
| Cased
| Changes_When_Uppercased
| Changes_When_Titlecased
| Changes_When_Casemapped
| Grapheme_Base
| ID_Continue
| ID_Start
| Lowercase
| XID_Continue
| XID_Start => True,
others => False)),
16#50# .. 16#9D# => -- 010450 .. 01049D
(Other_Letter, Neutral,
Other, A_Letter, O_Letter, Alphabetic,
(Alphabetic
| Grapheme_Base
| ID_Continue
| ID_Start
| XID_Continue
| XID_Start => True,
others => False)),
16#A0# .. 16#A9# => -- 0104A0 .. 0104A9
(Decimal_Number, Neutral,
Other, Numeric, Numeric, Numeric,
(Grapheme_Base
| ID_Continue
| XID_Continue => True,
others => False)),
others =>
(Unassigned, Neutral,
Other, Other, Other, Unknown,
(others => False)));
end Matreshka.Internals.Unicode.Ucd.Core_0104;
|
reznikmm/matreshka | Ada | 3,759 | ads | ------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- Open Document Toolkit --
-- --
-- Runtime Library Component --
-- --
------------------------------------------------------------------------------
-- --
-- Copyright © 2014, Vadim Godunko <[email protected]> --
-- All rights reserved. --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions --
-- are met: --
-- --
-- * Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- --
-- * Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in the --
-- documentation and/or other materials provided with the distribution. --
-- --
-- * Neither the name of the Vadim Godunko, IE nor the names of its --
-- contributors may be used to endorse or promote products derived from --
-- this software without specific prior written permission. --
-- --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR --
-- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
-- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED --
-- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR --
-- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF --
-- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING --
-- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS --
-- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
-- --
------------------------------------------------------------------------------
-- $Revision$ $Date$
------------------------------------------------------------------------------
with XML.DOM.Attributes;
package ODF.DOM.Style_Font_Style_Complex_Attributes is
pragma Preelaborate;
type ODF_Style_Font_Style_Complex_Attribute is limited interface
and XML.DOM.Attributes.DOM_Attribute;
type ODF_Style_Font_Style_Complex_Attribute_Access is
access all ODF_Style_Font_Style_Complex_Attribute'Class
with Storage_Size => 0;
end ODF.DOM.Style_Font_Style_Complex_Attributes;
|
AdaCore/gpr | Ada | 1,402 | adb | --
-- Copyright (C) 2019-2023, AdaCore
--
-- SPDX-License-Identifier: Apache-2.0
--
with Ada.Strings.Fixed;
with Ada.Text_IO;
with GPR2.Context;
with GPR2.Path_Name;
with GPR2.Project.Tree;
with GPR2.Project.View;
procedure Main is
use Ada;
use GPR2;
use GPR2.Project;
procedure Display (Prj : Project.View.Object);
function Filter_Path (Filename : Path_Name.Full_Name) return String;
-------------
-- Display --
-------------
procedure Display (Prj : Project.View.Object) is
begin
Text_IO.Put (String (Prj.Name) & " ");
Text_IO.Set_Col (10);
Text_IO.Put_Line (Prj.Qualifier'Img);
Text_IO.Put_Line (Filter_Path (Prj.Object_Directory.Value));
end Display;
-----------------
-- Filter_Path --
-----------------
function Filter_Path (Filename : Path_Name.Full_Name) return String is
D : constant String := "object-directory";
I : constant Positive := Strings.Fixed.Index (Filename, D);
begin
return Filename (I .. Filename'Last);
end Filter_Path;
Prj : Project.Tree.Object;
Ctx : Context.Object;
begin
Project.Tree.Load (Prj, Create ("demo1.gpr"), Ctx);
Display (Prj.Root_Project);
Project.Tree.Load (Prj, Create ("demo2.gpr"), Ctx);
Display (Prj.Root_Project);
Project.Tree.Load (Prj, Create ("demo2.gpr"), Ctx, Subdirs => "debug");
Display (Prj.Root_Project);
end Main;
|
Fabien-Chouteau/Ada_Drivers_Library | Ada | 15,088 | adb | ------------------------------------------------------------------------------
-- --
-- Copyright (C) 2015-2018, AdaCore --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions are --
-- met: --
-- 1. Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- 2. Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in --
-- the documentation and/or other materials provided with the --
-- distribution. --
-- 3. Neither the name of 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_gpio.c --
-- @author MCD Application Team --
-- @version V1.1.0 --
-- @date 19-June-2014 --
-- @brief GPIO HAL module driver. --
-- --
-- COPYRIGHT(c) 2014 STMicroelectronics --
------------------------------------------------------------------------------
with System; use System;
with STM32_SVD.GPIO; use STM32_SVD.GPIO;
with STM32.RCC;
with STM32.SYSCFG;
with System.Machine_Code;
package body STM32.GPIO is
procedure Lock_The_Pin (This : in out GPIO_Port; Pin : GPIO_Pin);
-- This is the routine that actually locks the pin for the port. It is an
-- internal routine and has no preconditions. We use it to avoid redundant
-- calls to the precondition that checks that the pin is not already
-- locked. The redundancy would otherwise occur because the routine that
-- locks an array of pins is implemented by calling the routine that locks
-- a single pin: both those Lock routines have a precondition that checks
-- that the pin(s) is not already being locked.
subtype GPIO_Pin_Index is Natural range 0 .. GPIO_Pin'Pos (GPIO_Pin'Last);
-------------
-- Any_Set --
-------------
function Any_Set (Pins : GPIO_Points) return Boolean is
begin
for Pin of Pins loop
if Pin.Set then
return True;
end if;
end loop;
return False;
end Any_Set;
----------
-- Mode --
----------
overriding
function Mode (This : GPIO_Point) return HAL.GPIO.GPIO_Mode is
begin
case Pin_IO_Mode (This) is
when Mode_Out => return HAL.GPIO.Output;
when Mode_In => return HAL.GPIO.Input;
when others => return HAL.GPIO.Unknown_Mode;
end case;
end Mode;
-----------------
-- Pin_IO_Mode --
-----------------
function Pin_IO_Mode (This : GPIO_Point) return Pin_IO_Modes is
Index : constant GPIO_Pin_Index := GPIO_Pin'Pos (This.Pin);
begin
return Pin_IO_Modes'Val (This.Periph.MODER.Arr (Index));
end Pin_IO_Mode;
--------------
-- Set_Mode --
--------------
overriding
procedure Set_Mode
(This : in out GPIO_Point;
Mode : HAL.GPIO.GPIO_Config_Mode)
is
Index : constant GPIO_Pin_Index := GPIO_Pin'Pos (This.Pin);
begin
case Mode is
when HAL.GPIO.Output =>
This.Periph.MODER.Arr (Index) := Pin_IO_Modes'Enum_Rep (Mode_Out);
when HAL.GPIO.Input =>
This.Periph.MODER.Arr (Index) := Pin_IO_Modes'Enum_Rep (Mode_In);
end case;
end Set_Mode;
-------------------
-- Pull_Resistor --
-------------------
overriding
function Pull_Resistor
(This : GPIO_Point)
return HAL.GPIO.GPIO_Pull_Resistor
is
Index : constant GPIO_Pin_Index := GPIO_Pin'Pos (This.Pin);
begin
if This.Periph.PUPDR.Arr (Index) = 0 then
return HAL.GPIO.Floating;
elsif This.Periph.PUPDR.Arr (Index) = 1 then
return HAL.GPIO.Pull_Up;
else
return HAL.GPIO.Pull_Down;
end if;
end Pull_Resistor;
-----------------------
-- Set_Pull_Resistor --
-----------------------
overriding
procedure Set_Pull_Resistor
(This : in out GPIO_Point;
Pull : HAL.GPIO.GPIO_Pull_Resistor)
is
Index : constant GPIO_Pin_Index := GPIO_Pin'Pos (This.Pin);
begin
case Pull is
when HAL.GPIO.Floating =>
This.Periph.PUPDR.Arr (Index) := 0;
when HAL.GPIO.Pull_Up =>
This.Periph.PUPDR.Arr (Index) := 1;
when HAL.GPIO.Pull_Down =>
This.Periph.PUPDR.Arr (Index) := 2;
end case;
end Set_Pull_Resistor;
---------
-- Set --
---------
overriding
function Set (This : GPIO_Point) return Boolean is
Pin_Mask : constant UInt16 := GPIO_Pin'Enum_Rep (This.Pin);
begin
return (This.Periph.IDR.IDR.Val and Pin_Mask) = Pin_Mask;
end Set;
-------------
-- All_Set --
-------------
function All_Set (Pins : GPIO_Points) return Boolean is
begin
for Pin of Pins loop
if not Pin.Set then
return False;
end if;
end loop;
return True;
end All_Set;
---------
-- Set --
---------
overriding
procedure Set (This : in out GPIO_Point) is
begin
This.Periph.BSRR.BS.Val := GPIO_Pin'Enum_Rep (This.Pin);
-- The bit-set and bit-reset registers ignore writes of zeros so we
-- don't need to preserve the existing bit values in those registers.
end Set;
---------
-- Set --
---------
procedure Set (Pins : in out GPIO_Points) is
begin
for Pin of Pins loop
Pin.Set;
end loop;
end Set;
-----------
-- Clear --
-----------
overriding
procedure Clear (This : in out GPIO_Point) is
begin
This.Periph.BSRR.BR.Val := GPIO_Pin'Enum_Rep (This.Pin);
-- The bit-set and bit-reset registers ignore writes of zeros so we
-- don't need to preserve the existing bit values in those registers.
end Clear;
-----------
-- Clear --
-----------
procedure Clear (Pins : in out GPIO_Points) is
begin
for Pin of Pins loop
Pin.Clear;
end loop;
end Clear;
------------
-- Toggle --
------------
overriding
procedure Toggle (This : in out GPIO_Point) is
begin
This.Periph.ODR.ODR.Val := This.Periph.ODR.ODR.Val xor GPIO_Pin'Enum_Rep (This.Pin);
end Toggle;
------------
-- Toggle --
------------
procedure Toggle (Points : in out GPIO_Points) is
begin
for Point of Points loop
Point.Toggle;
end loop;
end Toggle;
-----------
-- Drive --
-----------
procedure Drive (This : in out GPIO_Point; Condition : Boolean) is
begin
if Condition then
This.Set;
else
This.Clear;
end if;
end Drive;
------------
-- Locked --
------------
function Locked (This : GPIO_Point) return Boolean is
Mask : constant UInt16 := GPIO_Pin'Enum_Rep (This.Pin);
begin
return (This.Periph.LCKR.LCK.Val and Mask) = Mask;
end Locked;
------------------
-- Lock_The_Pin --
------------------
procedure Lock_The_Pin (This : in out GPIO_Port; Pin : GPIO_Pin) is
Temp : UInt32;
pragma Volatile (Temp);
use System.Machine_Code;
use ASCII;
begin
-- As per the Reference Manual (RM0090; Doc ID 018909 Rev 6) pg 282,
-- a specific sequence is required to set the Lock bit. Throughout the
-- sequence the same value for the lower 15 bits of the word must be
-- used (ie the pin number). The lock bit is referred to as LCKK in
-- the doc.
-- Temp := LCCK or Pin'Enum_Rep;
--
-- -- set the lock bit
-- Port.LCKR := Temp;
--
-- -- clear the lock bit
-- Port.LCKR := Pin'Enum_Rep;
--
-- -- set the lock bit again
-- Port.LCKR := Temp;
--
-- -- read the lock bit
-- Temp := Port.LCKR;
--
-- -- read the lock bit again
-- Temp := Port.LCKR;
-- We use the following assembly language sequence because the above
-- high-level version in Ada works only if the optimizer is enabled.
-- This is not an issue specific to Ada. If you need a specific sequence
-- of instructions you should really specify those instructions.
-- We don't want the functionality to depend on the switches, and we
-- don't want to preclude debugging, hence the following:
Asm ("orr r3, %2, #65536" & LF & HT &
"str r3, %0" & LF & HT &
"ldr r3, %0" & LF & HT & -- temp <- pin or LCCK
"str r3, [%1, #28]" & LF & HT & -- temp -> lckr
"str %2, [%1, #28]" & LF & HT & -- pin -> lckr
"ldr r3, %0" & LF & HT &
"str r3, [%1, #28]" & LF & HT & -- temp -> lckr
"ldr r3, [%1, #28]" & LF & HT &
"str r3, %0" & LF & HT & -- temp <- lckr
"ldr r3, [%1, #28]" & LF & HT &
"str r3, %0" & LF & HT, -- temp <- lckr
Inputs => (Address'Asm_Input ("r", This'Address), -- %1
(GPIO_Pin'Asm_Input ("r", Pin))), -- %2
Outputs => (UInt32'Asm_Output ("=m", Temp)), -- %0
Volatile => True,
Clobber => ("r2, r3"));
end Lock_The_Pin;
----------
-- Lock --
----------
procedure Lock (This : GPIO_Point) is
begin
Lock_The_Pin (This.Periph.all, This.Pin);
end Lock;
----------
-- Lock --
----------
procedure Lock (Points : GPIO_Points) is
begin
for Point of Points loop
if not Locked (Point) then
Point.Lock;
end if;
end loop;
end Lock;
------------------
-- Configure_IO --
------------------
procedure Configure_IO
(This : GPIO_Point;
Config : GPIO_Port_Configuration)
is
Index : constant GPIO_Pin_Index := GPIO_Pin'Pos (This.Pin);
begin
This.Periph.MODER.Arr (Index) := Pin_IO_Modes'Enum_Rep (Config.Mode);
This.Periph.PUPDR.Arr (Index) := Internal_Pin_Resistors'Enum_Rep (Config.Resistors);
case Config.Mode is
when Mode_In | Mode_Analog =>
null;
when Mode_Out =>
This.Periph.OTYPER.OT.Arr (Index) := Config.Output_Type = Open_Drain;
This.Periph.OSPEEDR.Arr (Index) := Pin_Output_Speeds'Enum_Rep (Config.Speed);
when Mode_AF =>
This.Periph.OTYPER.OT.Arr (Index) := Config.AF_Output_Type = Open_Drain;
This.Periph.OSPEEDR.Arr (Index) := Pin_Output_Speeds'Enum_Rep (Config.AF_Speed);
Configure_Alternate_Function (This, Config.AF);
end case;
end Configure_IO;
------------------
-- Configure_IO --
------------------
procedure Configure_IO
(Points : GPIO_Points;
Config : GPIO_Port_Configuration)
is
begin
for Point of Points loop
Point.Configure_IO (Config);
end loop;
end Configure_IO;
----------------------------------
-- Configure_Alternate_Function --
----------------------------------
procedure Configure_Alternate_Function
(This : GPIO_Point;
AF : GPIO_Alternate_Function)
is
Index : constant GPIO_Pin_Index := GPIO_Pin'Pos (This.Pin);
begin
if Index < 8 then
This.Periph.AFRL.Arr (Index) := UInt4 (AF);
else
This.Periph.AFRH.Arr (Index) := UInt4 (AF);
end if;
end Configure_Alternate_Function;
----------------------------------
-- Configure_Alternate_Function --
----------------------------------
procedure Configure_Alternate_Function
(Points : GPIO_Points;
AF : GPIO_Alternate_Function)
is
begin
for Point of Points loop
Point.Configure_Alternate_Function (AF);
end loop;
end Configure_Alternate_Function;
---------------------------
-- Interrupt_Line_Number --
---------------------------
function Interrupt_Line_Number
(This : GPIO_Point) return EXTI.External_Line_Number
is
begin
return EXTI.External_Line_Number'Val (GPIO_Pin'Pos (This.Pin));
end Interrupt_Line_Number;
-----------------------
-- Configure_Trigger --
-----------------------
procedure Configure_Trigger
(This : GPIO_Point;
Trigger : EXTI.External_Triggers)
is
use STM32.EXTI;
Line : constant External_Line_Number := External_Line_Number'Val (GPIO_Pin'Pos (This.Pin));
use STM32.SYSCFG, STM32.RCC;
begin
SYSCFG_Clock_Enable;
Connect_External_Interrupt (This);
if Trigger in Interrupt_Triggers then
Enable_External_Interrupt (Line, Trigger);
else
Enable_External_Event (Line, Trigger);
end if;
end Configure_Trigger;
-----------------------
-- Configure_Trigger --
-----------------------
procedure Configure_Trigger
(Points : GPIO_Points;
Trigger : EXTI.External_Triggers)
is
begin
for Point of Points loop
Point.Configure_Trigger (Trigger);
end loop;
end Configure_Trigger;
end STM32.GPIO;
|
ekoeppen/MSP430_Generic_Ada_Drivers | Ada | 1,160 | ads | with Startup;
with MSPGD.GPIO; use MSPGD.GPIO;
with MSPGD.GPIO.Pin;
with MSPGD.UART.Peripheral;
with MSPGD.SPI.Peripheral;
package MSPGD.Board is
pragma Preelaborate;
package LED_RED is new MSPGD.GPIO.Pin (Port => 1, Pin => 0, Direction => Output);
package LED_GREEN is new MSPGD.GPIO.Pin (Port => 2, Pin => 4, Direction => Output);
package RX is new MSPGD.GPIO.Pin (Port => 1, Pin => 1, Alt_Func => Secondary);
package TX is new MSPGD.GPIO.Pin (Port => 1, Pin => 2, Alt_Func => Secondary);
package SCLK is new MSPGD.GPIO.Pin (Port => 1, Pin => 5, Alt_Func => Secondary);
package MISO is new MSPGD.GPIO.Pin (Port => 1, Pin => 6, Alt_Func => Secondary);
package MOSI is new MSPGD.GPIO.Pin (Port => 1, Pin => 7, Alt_Func => Secondary);
package SSEL is new MSPGD.GPIO.Pin (Port => 2, Pin => 1, Direction => Output);
package BUTTON is new MSPGD.GPIO.Pin (Port => 2, Pin => 3, Pull_Resistor => Up);
package UART is new MSPGD.UART.Peripheral (Speed => 9600, Clock => 8_000_000);
package SPI is new MSPGD.SPI.Peripheral (Module => MSPGD.SPI.USCI_B, Speed => 1_000_000, Clock => 1_000_000);
procedure Init;
end MSPGD.Board;
|
pchapin/augusta | Ada | 2,254 | ads | ---------------------------------------------------------------------------
-- FILE : augusta-characters-handling.ads
-- SUBJECT : Specification of character conversions package.
-- AUTHOR : (C) Copyright 2013 by the Augusta Contributors
--
-- Please send comments or bug reports to
--
-- Peter C. Chapin <[email protected]>
---------------------------------------------------------------------------
-- See A.3.4.
package Augusta.Characters.Conversions is
pragma Pure(Conversions);
-- Type Character.
function Is_Character(Item : in Wide_Character) return Boolean;
function Is_String(Item : in Wide_String) return Boolean;
function Is_Character(Item : in Wide_Wide_Character) return Boolean;
function Is_String(Item : in Wide_Wide_String) return Boolean;
function Is_Wide_Character(Item : in Wide_Wide_Character) return Boolean;
function Is_Wide_String(Item : in Wide_Wide_String) return Boolean;
-- Type Wide_Character.
function To_Wide_Character(Item : in Character) return Wide_Character;
function To_Wide_String(Item : in String) return Wide_String;
function To_Wide_Wide_Character(Item : in Character) return Wide_Wide_Character;
function To_Wide_Wide_String(Item : in String) return Wide_Wide_String;
function To_Wide_Wide_Character(Item : in Wide_Character) return Wide_Wide_Character;
function To_Wide_Wide_String(Item : in Wide_String) return Wide_Wide_String;
-- Type Wide_Wide_Character.
function To_Character
(Item : in Wide_Character;
Substitute : in Character := ' ') return Character;
function To_String
(Item : in Wide_String;
Substitute : in Character := ' ') return String;
function To_Character
(Item : in Wide_Wide_Character;
Substitute : in Character := ' ') return Character;
function To_String
(Item : in Wide_Wide_String;
Substitute : in Character := ' ') return String;
function To_Wide_Character
(Item : in Wide_Wide_Character;
Substitute : in Wide_Character := ' ') return Wide_Character;
function To_Wide_String
(Item : in Wide_Wide_String;
Substitute : in Wide_Character := ' ') return Wide_String;
end Augusta.Characters.Conversions;
|
AdaCore/training_material | Ada | 254 | adb | with Tasks; use Tasks;
procedure Test_Protected_Objects is
begin
T1.Start;
T1.Receive_Message;
T2.Start;
T2.Receive_Message;
T2.Receive_Message;
T1.Receive_Message;
-- Ugly...
abort T1;
abort T2;
end Test_Protected_Objects;
|
buotex/BICEPS | Ada | 13,182 | adb | ----------------------------------------------------------------
-- ZLib for Ada thick binding. --
-- --
-- Copyright (C) 2002-2003 Dmitriy Anisimkov --
-- --
-- Open source license information is in the zlib.ads file. --
----------------------------------------------------------------
-- $Id: test.adb,v 1.1 2008/06/11 20:00:39 chambers Exp $
-- The program has a few aims.
-- 1. Test ZLib.Ada95 thick binding functionality.
-- 2. Show the example of use main functionality of the ZLib.Ada95 binding.
-- 3. Build this program automatically compile all ZLib.Ada95 packages under
-- GNAT Ada95 compiler.
with ZLib.Streams;
with Ada.Streams.Stream_IO;
with Ada.Numerics.Discrete_Random;
with Ada.Text_IO;
with Ada.Calendar;
procedure Test is
use Ada.Streams;
use Stream_IO;
------------------------------------
-- Test configuration parameters --
------------------------------------
File_Size : Count := 100_000;
Continuous : constant Boolean := False;
Header : constant ZLib.Header_Type := ZLib.Default;
-- ZLib.None;
-- ZLib.Auto;
-- ZLib.GZip;
-- Do not use Header other then Default in ZLib versions 1.1.4
-- and older.
Strategy : constant ZLib.Strategy_Type := ZLib.Default_Strategy;
Init_Random : constant := 10;
-- End --
In_File_Name : constant String := "testzlib.in";
-- Name of the input file
Z_File_Name : constant String := "testzlib.zlb";
-- Name of the compressed file.
Out_File_Name : constant String := "testzlib.out";
-- Name of the decompressed file.
File_In : File_Type;
File_Out : File_Type;
File_Back : File_Type;
File_Z : ZLib.Streams.Stream_Type;
Filter : ZLib.Filter_Type;
Time_Stamp : Ada.Calendar.Time;
procedure Generate_File;
-- Generate file of spetsified size with some random data.
-- The random data is repeatable, for the good compression.
procedure Compare_Streams
(Left, Right : in out Root_Stream_Type'Class);
-- The procedure compearing data in 2 streams.
-- It is for compare data before and after compression/decompression.
procedure Compare_Files (Left, Right : String);
-- Compare files. Based on the Compare_Streams.
procedure Copy_Streams
(Source, Target : in out Root_Stream_Type'Class;
Buffer_Size : in Stream_Element_Offset := 1024);
-- Copying data from one stream to another. It is for test stream
-- interface of the library.
procedure Data_In
(Item : out Stream_Element_Array;
Last : out Stream_Element_Offset);
-- this procedure is for generic instantiation of
-- ZLib.Generic_Translate.
-- reading data from the File_In.
procedure Data_Out (Item : in Stream_Element_Array);
-- this procedure is for generic instantiation of
-- ZLib.Generic_Translate.
-- writing data to the File_Out.
procedure Stamp;
-- Store the timestamp to the local variable.
procedure Print_Statistic (Msg : String; Data_Size : ZLib.Count);
-- Print the time statistic with the message.
procedure Translate is new ZLib.Generic_Translate
(Data_In => Data_In,
Data_Out => Data_Out);
-- This procedure is moving data from File_In to File_Out
-- with compression or decompression, depend on initialization of
-- Filter parameter.
-------------------
-- Compare_Files --
-------------------
procedure Compare_Files (Left, Right : String) is
Left_File, Right_File : File_Type;
begin
Open (Left_File, In_File, Left);
Open (Right_File, In_File, Right);
Compare_Streams (Stream (Left_File).all, Stream (Right_File).all);
Close (Left_File);
Close (Right_File);
end Compare_Files;
---------------------
-- Compare_Streams --
---------------------
procedure Compare_Streams
(Left, Right : in out Ada.Streams.Root_Stream_Type'Class)
is
Left_Buffer, Right_Buffer : Stream_Element_Array (0 .. 16#FFF#);
Left_Last, Right_Last : Stream_Element_Offset;
begin
loop
Read (Left, Left_Buffer, Left_Last);
Read (Right, Right_Buffer, Right_Last);
if Left_Last /= Right_Last then
Ada.Text_IO.Put_Line ("Compare error :"
& Stream_Element_Offset'Image (Left_Last)
& " /= "
& Stream_Element_Offset'Image (Right_Last));
raise Constraint_Error;
elsif Left_Buffer (0 .. Left_Last)
/= Right_Buffer (0 .. Right_Last)
then
Ada.Text_IO.Put_Line ("ERROR: IN and OUT files is not equal.");
raise Constraint_Error;
end if;
exit when Left_Last < Left_Buffer'Last;
end loop;
end Compare_Streams;
------------------
-- Copy_Streams --
------------------
procedure Copy_Streams
(Source, Target : in out Ada.Streams.Root_Stream_Type'Class;
Buffer_Size : in Stream_Element_Offset := 1024)
is
Buffer : Stream_Element_Array (1 .. Buffer_Size);
Last : Stream_Element_Offset;
begin
loop
Read (Source, Buffer, Last);
Write (Target, Buffer (1 .. Last));
exit when Last < Buffer'Last;
end loop;
end Copy_Streams;
-------------
-- Data_In --
-------------
procedure Data_In
(Item : out Stream_Element_Array;
Last : out Stream_Element_Offset) is
begin
Read (File_In, Item, Last);
end Data_In;
--------------
-- Data_Out --
--------------
procedure Data_Out (Item : in Stream_Element_Array) is
begin
Write (File_Out, Item);
end Data_Out;
-------------------
-- Generate_File --
-------------------
procedure Generate_File is
subtype Visible_Symbols is Stream_Element range 16#20# .. 16#7E#;
package Random_Elements is
new Ada.Numerics.Discrete_Random (Visible_Symbols);
Gen : Random_Elements.Generator;
Buffer : Stream_Element_Array := (1 .. 77 => 16#20#) & 10;
Buffer_Count : constant Count := File_Size / Buffer'Length;
-- Number of same buffers in the packet.
Density : constant Count := 30; -- from 0 to Buffer'Length - 2;
procedure Fill_Buffer (J, D : in Count);
-- Change the part of the buffer.
-----------------
-- Fill_Buffer --
-----------------
procedure Fill_Buffer (J, D : in Count) is
begin
for K in 0 .. D loop
Buffer
(Stream_Element_Offset ((J + K) mod (Buffer'Length - 1) + 1))
:= Random_Elements.Random (Gen);
end loop;
end Fill_Buffer;
begin
Random_Elements.Reset (Gen, Init_Random);
Create (File_In, Out_File, In_File_Name);
Fill_Buffer (1, Buffer'Length - 2);
for J in 1 .. Buffer_Count loop
Write (File_In, Buffer);
Fill_Buffer (J, Density);
end loop;
-- fill remain size.
Write
(File_In,
Buffer
(1 .. Stream_Element_Offset
(File_Size - Buffer'Length * Buffer_Count)));
Flush (File_In);
Close (File_In);
end Generate_File;
---------------------
-- Print_Statistic --
---------------------
procedure Print_Statistic (Msg : String; Data_Size : ZLib.Count) is
use Ada.Calendar;
use Ada.Text_IO;
package Count_IO is new Integer_IO (ZLib.Count);
Curr_Dur : Duration := Clock - Time_Stamp;
begin
Put (Msg);
Set_Col (20);
Ada.Text_IO.Put ("size =");
Count_IO.Put
(Data_Size,
Width => Stream_IO.Count'Image (File_Size)'Length);
Put_Line (" duration =" & Duration'Image (Curr_Dur));
end Print_Statistic;
-----------
-- Stamp --
-----------
procedure Stamp is
begin
Time_Stamp := Ada.Calendar.Clock;
end Stamp;
begin
Ada.Text_IO.Put_Line ("ZLib " & ZLib.Version);
loop
Generate_File;
for Level in ZLib.Compression_Level'Range loop
Ada.Text_IO.Put_Line ("Level ="
& ZLib.Compression_Level'Image (Level));
-- Test generic interface.
Open (File_In, In_File, In_File_Name);
Create (File_Out, Out_File, Z_File_Name);
Stamp;
-- Deflate using generic instantiation.
ZLib.Deflate_Init
(Filter => Filter,
Level => Level,
Strategy => Strategy,
Header => Header);
Translate (Filter);
Print_Statistic ("Generic compress", ZLib.Total_Out (Filter));
ZLib.Close (Filter);
Close (File_In);
Close (File_Out);
Open (File_In, In_File, Z_File_Name);
Create (File_Out, Out_File, Out_File_Name);
Stamp;
-- Inflate using generic instantiation.
ZLib.Inflate_Init (Filter, Header => Header);
Translate (Filter);
Print_Statistic ("Generic decompress", ZLib.Total_Out (Filter));
ZLib.Close (Filter);
Close (File_In);
Close (File_Out);
Compare_Files (In_File_Name, Out_File_Name);
-- Test stream interface.
-- Compress to the back stream.
Open (File_In, In_File, In_File_Name);
Create (File_Back, Out_File, Z_File_Name);
Stamp;
ZLib.Streams.Create
(Stream => File_Z,
Mode => ZLib.Streams.Out_Stream,
Back => ZLib.Streams.Stream_Access
(Stream (File_Back)),
Back_Compressed => True,
Level => Level,
Strategy => Strategy,
Header => Header);
Copy_Streams
(Source => Stream (File_In).all,
Target => File_Z);
-- Flushing internal buffers to the back stream.
ZLib.Streams.Flush (File_Z, ZLib.Finish);
Print_Statistic ("Write compress",
ZLib.Streams.Write_Total_Out (File_Z));
ZLib.Streams.Close (File_Z);
Close (File_In);
Close (File_Back);
-- Compare reading from original file and from
-- decompression stream.
Open (File_In, In_File, In_File_Name);
Open (File_Back, In_File, Z_File_Name);
ZLib.Streams.Create
(Stream => File_Z,
Mode => ZLib.Streams.In_Stream,
Back => ZLib.Streams.Stream_Access
(Stream (File_Back)),
Back_Compressed => True,
Header => Header);
Stamp;
Compare_Streams (Stream (File_In).all, File_Z);
Print_Statistic ("Read decompress",
ZLib.Streams.Read_Total_Out (File_Z));
ZLib.Streams.Close (File_Z);
Close (File_In);
Close (File_Back);
-- Compress by reading from compression stream.
Open (File_Back, In_File, In_File_Name);
Create (File_Out, Out_File, Z_File_Name);
ZLib.Streams.Create
(Stream => File_Z,
Mode => ZLib.Streams.In_Stream,
Back => ZLib.Streams.Stream_Access
(Stream (File_Back)),
Back_Compressed => False,
Level => Level,
Strategy => Strategy,
Header => Header);
Stamp;
Copy_Streams
(Source => File_Z,
Target => Stream (File_Out).all);
Print_Statistic ("Read compress",
ZLib.Streams.Read_Total_Out (File_Z));
ZLib.Streams.Close (File_Z);
Close (File_Out);
Close (File_Back);
-- Decompress to decompression stream.
Open (File_In, In_File, Z_File_Name);
Create (File_Back, Out_File, Out_File_Name);
ZLib.Streams.Create
(Stream => File_Z,
Mode => ZLib.Streams.Out_Stream,
Back => ZLib.Streams.Stream_Access
(Stream (File_Back)),
Back_Compressed => False,
Header => Header);
Stamp;
Copy_Streams
(Source => Stream (File_In).all,
Target => File_Z);
Print_Statistic ("Write decompress",
ZLib.Streams.Write_Total_Out (File_Z));
ZLib.Streams.Close (File_Z);
Close (File_In);
Close (File_Back);
Compare_Files (In_File_Name, Out_File_Name);
end loop;
Ada.Text_IO.Put_Line (Count'Image (File_Size) & " Ok.");
exit when not Continuous;
File_Size := File_Size + 1;
end loop;
end Test;
|
charlie5/cBound | Ada | 2,338 | ads | -- This file is generated by SWIG. Please do not modify by hand.
--
with Interfaces;
with Interfaces.C;
with Interfaces.C.Pointers;
package xcb.xcb_change_window_attributes_value_list_t is
-- Item
--
type Item is record
background_pixmap : aliased xcb.xcb_pixmap_t;
background_pixel : aliased Interfaces.Unsigned_32;
border_pixmap : aliased xcb.xcb_pixmap_t;
border_pixel : aliased Interfaces.Unsigned_32;
bit_gravity : aliased Interfaces.Unsigned_32;
win_gravity : aliased Interfaces.Unsigned_32;
backing_store : aliased Interfaces.Unsigned_32;
backing_planes : aliased Interfaces.Unsigned_32;
backing_pixel : aliased Interfaces.Unsigned_32;
override_redirect : aliased xcb.xcb_bool32_t;
save_under : aliased xcb.xcb_bool32_t;
event_mask : aliased Interfaces.Unsigned_32;
do_not_propogate_mask : aliased Interfaces.Unsigned_32;
colormap : aliased xcb.xcb_colormap_t;
cursor : aliased xcb.xcb_cursor_t;
end record;
-- Item_Array
--
type Item_Array is
array
(Interfaces.C
.size_t range <>) of aliased xcb
.xcb_change_window_attributes_value_list_t
.Item;
-- Pointer
--
package C_Pointers is new Interfaces.C.Pointers
(Index => Interfaces.C.size_t,
Element => xcb.xcb_change_window_attributes_value_list_t.Item,
Element_Array =>
xcb.xcb_change_window_attributes_value_list_t.Item_Array,
Default_Terminator => (others => <>));
subtype Pointer is C_Pointers.Pointer;
-- Pointer_Array
--
type Pointer_Array is
array
(Interfaces.C
.size_t range <>) of aliased xcb
.xcb_change_window_attributes_value_list_t
.Pointer;
-- Pointer_Pointer
--
package C_Pointer_Pointers is new Interfaces.C.Pointers
(Index => Interfaces.C.size_t,
Element => xcb.xcb_change_window_attributes_value_list_t.Pointer,
Element_Array =>
xcb.xcb_change_window_attributes_value_list_t.Pointer_Array,
Default_Terminator => null);
subtype Pointer_Pointer is C_Pointer_Pointers.Pointer;
end xcb.xcb_change_window_attributes_value_list_t;
|
zhmu/ananas | Ada | 9,171 | ads | ------------------------------------------------------------------------------
-- --
-- GNAT COMPILER COMPONENTS --
-- --
-- S E M _ C A T --
-- --
-- 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. --
-- --
------------------------------------------------------------------------------
-- This unit contains the routines used for checking for conformance with
-- the semantic restrictions required for the categorization pragmas:
--
-- Preelaborate
-- Pure
-- Remote_Call_Interface
-- Remote_Types
-- Shared_Passive
--
-- Note that we treat Preelaborate as a categorization pragma, even though
-- strictly, according to RM E.2(2,3), the term does not apply in this case.
with Exp_Tss; use Exp_Tss;
with Types; use Types;
package Sem_Cat is
function Has_Stream_Attribute_Definition
(Typ : Entity_Id;
Nam : TSS_Name_Type;
Real_Rep : out Node_Id;
At_Any_Place : Boolean := False) return Boolean;
-- True when there is a attribute definition clause specifying attribute
-- Nam for Typ. In Ada 2005 mode, returns True only when the attribute
-- definition clause is visible, unless At_Any_Place is True (in which case
-- no visibility test is made, and True is returned as long as an attribute
-- is visible at any place). Note that attribute definition clauses
-- inherited from parent types are taken into account by this predicate
-- (to test for presence of an attribute definition clause for one
-- specific type, excluding inherited definitions, the flags
-- Has_Specified_Stream_* can be used instead).
-- The stream operation may be specified by an attribute definition
-- clause in the source, or by an aspect that generates such an
-- attribute definition. For an aspect, the generated attribute
-- definition may be placed at the freeze point of the full view of
-- the type, but the aspect specification makes the operation visible
-- to a client wherever the partial view is visible. This real
-- representation is returned in the Real_Rep parameter.
function In_Preelaborated_Unit return Boolean;
-- Determines if the current scope is within a preelaborated compilation
-- unit, that is one to which one of the pragmas Preelaborate, Pure,
-- Shared_Passive, Remote_Types, or inside a unit other than a package
-- body with pragma Remote_Call_Interface.
function In_Pure_Unit return Boolean;
pragma Inline (In_Pure_Unit);
-- Determines if the current scope is within pure compilation unit,
-- that is, one to which the pragmas Pure is applied.
function In_Subprogram_Task_Protected_Unit return Boolean;
-- Determines if the current scope is within a subprogram, task
-- or protected unit. Used to validate if the library unit is Pure
-- (RM 10.2.1(16)).
procedure Set_Categorization_From_Pragmas (N : Node_Id);
-- Since validation of categorization dependency is done during Analyze,
-- categorization flags from following pragmas should be set before
-- validation begin. N is the N_Compilation_Unit node.
procedure Set_Categorization_From_Scope (E : Entity_Id; Scop : Entity_Id);
-- Set categorization flags Pure, Remote_Call_Interface and Remote_Types
-- on entity E according to those of Scop.
procedure Validate_Access_Type_Declaration (T : Entity_Id; N : Node_Id);
-- Validate all constraints against declaration of access types in
-- categorized library units. Usually this is a violation in Pure unit,
-- Shared_Passive unit. N is the declaration node.
procedure Validate_Ancestor_Part (N : Node_Id);
-- Checks that a type given as the ancestor in an extension aggregate
-- satisfies the restriction of 10.2.1(9).
procedure Validate_Categorization_Dependency (N : Node_Id; E : Entity_Id);
-- There are restrictions on lib unit that semantically depends on other
-- units (RM E.2(5), 10.2.1(11). This procedure checks the restrictions
-- on categorizations. N is the current unit node, and E is the current
-- library unit entity.
procedure Validate_Controlled_Object (E : Entity_Id);
-- Given an entity for a library level controlled object, check that it is
-- not in a preelaborated unit (prohibited by RM 10.2.1(9)).
procedure Validate_Null_Statement_Sequence (N : Node_Id);
-- Given N, a package body node, check that a handled statement sequence
-- in a preelaborable body contains no statements other than labels or
-- null statements, as required by RM 10.2.1(6).
procedure Validate_Object_Declaration (N : Node_Id);
-- Given N, an object declaration node, validates all the constraints in
-- a preelaborable library unit, including creation of task objects etc.
-- Note that this is called when the corresponding object is frozen since
-- the checks cannot be made before knowing if the object is imported.
procedure Validate_RCI_Declarations (P : Entity_Id);
-- Apply semantic checks given in E2.3(10-14)
procedure Validate_RCI_Subprogram_Declaration (N : Node_Id);
-- Check RCI subprogram declarations for illegal inlining and formals not
-- supporting external streaming.
procedure Validate_Remote_Access_To_Class_Wide_Type (N : Node_Id);
-- Checks that Storage_Pool and Storage_Size attribute references are
-- not applied to remote access-to-class-wide types. Also checks that the
-- expected type for an allocator cannot be a remote access-to-class-wide
-- type. Also checks that a remote access-to-class-wide type cannot be an
-- actual parameter for a generic formal access type. RM E.2.2(17).
procedure Validate_RT_RAT_Component (N : Node_Id);
-- Given N, the package library unit declaration node, we should check
-- against RM:9.95 E.2.2(8): the full view of a type declared in the
-- visible part of a Remote Types unit has a part that is of a non-remote
-- access type which has no read/write.
procedure Validate_Remote_Type_Type_Conversion (N : Node_Id);
-- Check for remote-type type conversion constraints. First, a value of
-- a remote access-to-subprogram type can be converted only to another
-- type conformant remote access-to-subprogram type. Secondly, a value
-- of a remote access-to-class-wide type can be converted only to another
-- remote access-to-class-wide type (RM E.2.3(17,20)).
procedure Validate_SP_Access_Object_Type_Decl (T : Entity_Id);
-- Check validity of declaration if shared passive unit. It should not
-- contain the declaration of an access-to-object type whose designated
-- type is a class-wide type ,task type or protected type. E.2.1(7).
-- T is the entity of the declared type.
procedure Validate_Static_Object_Name (N : Node_Id);
-- In the elaboration code of a preelaborated library unit, check that we
-- do not have the evaluation of a primary that is a name of an object,
-- unless the name is a static expression (RM 10.2.1(8)). Non-static
-- constant and variable are the targets, generic parameters are not
-- are not included because the generic declaration and body are
-- preelaborable.
procedure Validate_RACW_Primitives (T : Entity_Id);
-- Enforce constraints on primitive operations of the designated type of
-- an RACW. Note that since the complete set of primitive operations of the
-- designated type needs to be known, we must defer these checks until the
-- designated type is frozen.
end Sem_Cat;
|
clairvoyant/anagram | Ada | 468 | ads | -- 1
with League.Strings;
with Anagram.Grammars.Constructors;
package Ag is
type Parser is tagged limited private;
procedure Read
(Self : in out Parser;
Text : League.Strings.Universal_String;
Tail_List : Boolean := False);
function Grammar (Self : in out Parser) return Anagram.Grammars.Grammar;
private
type Parser is tagged limited record
Constructor : Anagram.Grammars.Constructors.Constructor;
end record;
-- 2
end Ag;
|
MatrixMike/Ada_Drivers_Library | Ada | 4,682 | adb | ------------------------------------------------------------------------------
-- --
-- Copyright (C) 2018, AdaCore --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions are --
-- met: --
-- 1. Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- 2. Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in --
-- the documentation and/or other materials provided with the --
-- distribution. --
-- 3. Neither the name of the copyright holder nor the names of its --
-- contributors may be used to endorse or promote products derived --
-- from this software without specific prior written permission. --
-- --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR --
-- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
-- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT --
-- LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, --
-- DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY --
-- THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT --
-- (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE --
-- OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
-- --
------------------------------------------------------------------------------
with Ada.Text_IO; use Ada.Text_IO;
with MicroBit.Display; use MicroBit.Display;
with MicroBit.IOs; use MicroBit.IOs;
with MicroBit.Servos; use MicroBit.Servos;
with MicroBit.Buttons; use MicroBit.Buttons;
with MicroBit.Time; use MicroBit.Time;
procedure Main is
subtype Servo_Pin_Id is Pin_Id range 1 .. 2;
type Servo_Pin_State (Active : Boolean := False) is record
case Active is
when True => Setpoint : Servo_Set_Point;
when False => null;
end case;
end record;
type Servo_Pin_Array is array (Servo_Pin_Id) of Servo_Pin_State;
Servo_Pins, Cur_Servo_Pins : Servo_Pin_Array := (others => (Active => False));
Code : Character := ' ';
Button_AB : Boolean;
Starting : Boolean := False;
begin
Put_Line ("Start");
loop
-- Update PWM pulse size
if Starting or else Cur_Servo_Pins /= Servo_Pins then
Starting := False;
Clear;
Display (Code);
for J in Servo_Pins'Range loop
if Servo_Pins (J).Active then
Go (J, Servo_Pins (J).Setpoint);
else
Stop (J);
end if;
end loop;
Cur_Servo_Pins := Servo_Pins;
end if;
-- Check buttons
if State (Button_A) = Released and then State (Button_B) = Released then
-- Reset double press latch
Button_AB := False;
elsif State (Button_A) = Pressed and then State (Button_B) = Pressed then
Servo_Pins := (others => (Active => False));
Code := '0';
-- Latch double press mode so that when one button is released, we
-- ignore the other.
Button_AB := True;
elsif Button_AB then
-- After double press, ignore single button state until both buttons
-- are released.
null;
elsif State (Button_A) = Pressed then
Servo_Pins := (1 => (Active => True, Setpoint => 0),
2 => (Active => True, Setpoint => 180));
Code := 'A';
elsif State (Button_B) = Pressed then
Servo_Pins := (1 => (Active => True, Setpoint => 180),
2 => (Active => True, Setpoint => 0));
Code := 'R';
end if;
-- Delay for at least 1 PWM frame
Delay_Ms (20);
end loop;
end Main;
|
reznikmm/matreshka | Ada | 4,753 | adb | ------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- SQL Database Access --
-- --
-- Testsuite 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$
------------------------------------------------------------------------------
-- Checks whether obtain of LAST_INSERT_ROWID pseudo-parameter works for
-- SQLite3 driver.
------------------------------------------------------------------------------
with League.Holders;
with League.Strings;
with SQL.Databases;
with SQL.Options;
with SQL.Queries;
with Matreshka.Internals.SQL_Drivers.SQLite3.Factory;
procedure Test_303 is
Last_Insert_Rowid : constant League.Strings.Universal_String
:= League.Strings.To_Universal_String ("LAST_INSERT_ROWID");
Driver : constant League.Strings.Universal_String
:= League.Strings.To_Universal_String ("SQLITE3");
Options : SQL.Options.SQL_Options;
Database : SQL.Databases.SQL_Database
:= SQL.Databases.Create (Driver, Options);
Query : SQL.Queries.SQL_Query := Database.Query;
begin
Database.Open;
Query.Prepare
(League.Strings.To_Universal_String
("CREATE TABLE test"
& " (id INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,"
& " value CHARACTER VARYING NOT NULL)"));
Query.Execute;
Query.Prepare
(League.Strings.To_Universal_String
("INSERT INTO test (value) VALUES ('dummy')"));
for J in 1 .. 10 loop
Query.Execute;
if Integer
(League.Holders.Universal_Integer'
(League.Holders.Element (Query.Bound_Value (Last_Insert_Rowid))))
/= J
then
raise Program_Error;
end if;
end loop;
end Test_303;
|
reznikmm/matreshka | Ada | 16,311 | ads | ------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- Ada Modeling Framework --
-- --
-- Runtime Library Component --
-- --
------------------------------------------------------------------------------
-- --
-- Copyright © 2011-2012, Vadim Godunko <[email protected]> --
-- All rights reserved. --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions --
-- are met: --
-- --
-- * Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- --
-- * Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in the --
-- documentation and/or other materials provided with the distribution. --
-- --
-- * Neither the name of the Vadim Godunko, IE nor the names of its --
-- contributors may be used to endorse or promote products derived from --
-- this software without specific prior written permission. --
-- --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR --
-- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
-- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED --
-- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR --
-- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF --
-- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING --
-- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS --
-- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
-- --
------------------------------------------------------------------------------
-- $Revision$ $Date$
------------------------------------------------------------------------------
with AMF.Internals.UML_Named_Elements;
with AMF.UML.Activities;
with AMF.UML.Activity_Edges.Collections;
with AMF.UML.Activity_Groups.Collections;
with AMF.UML.Activity_Nodes;
with AMF.UML.Activity_Partitions.Collections;
with AMF.UML.Classifiers.Collections;
with AMF.UML.Control_Flows;
with AMF.UML.Dependencies.Collections;
with AMF.UML.Interruptible_Activity_Regions;
with AMF.UML.Named_Elements;
with AMF.UML.Namespaces;
with AMF.UML.Packages.Collections;
with AMF.UML.Redefinable_Elements.Collections;
with AMF.UML.String_Expressions;
with AMF.UML.Structured_Activity_Nodes;
with AMF.UML.Value_Specifications;
with AMF.Visitors;
package AMF.Internals.UML_Control_Flows is
type UML_Control_Flow_Proxy is
limited new AMF.Internals.UML_Named_Elements.UML_Named_Element_Proxy
and AMF.UML.Control_Flows.UML_Control_Flow with null record;
overriding function Get_Activity
(Self : not null access constant UML_Control_Flow_Proxy)
return AMF.UML.Activities.UML_Activity_Access;
-- Getter of ActivityEdge::activity.
--
-- Activity containing the edge.
overriding procedure Set_Activity
(Self : not null access UML_Control_Flow_Proxy;
To : AMF.UML.Activities.UML_Activity_Access);
-- Setter of ActivityEdge::activity.
--
-- Activity containing the edge.
overriding function Get_Guard
(Self : not null access constant UML_Control_Flow_Proxy)
return AMF.UML.Value_Specifications.UML_Value_Specification_Access;
-- Getter of ActivityEdge::guard.
--
-- Specification evaluated at runtime to determine if the edge can be
-- traversed.
overriding procedure Set_Guard
(Self : not null access UML_Control_Flow_Proxy;
To : AMF.UML.Value_Specifications.UML_Value_Specification_Access);
-- Setter of ActivityEdge::guard.
--
-- Specification evaluated at runtime to determine if the edge can be
-- traversed.
overriding function Get_In_Group
(Self : not null access constant UML_Control_Flow_Proxy)
return AMF.UML.Activity_Groups.Collections.Set_Of_UML_Activity_Group;
-- Getter of ActivityEdge::inGroup.
--
-- Groups containing the edge.
overriding function Get_In_Partition
(Self : not null access constant UML_Control_Flow_Proxy)
return AMF.UML.Activity_Partitions.Collections.Set_Of_UML_Activity_Partition;
-- Getter of ActivityEdge::inPartition.
--
-- Partitions containing the edge.
overriding function Get_In_Structured_Node
(Self : not null access constant UML_Control_Flow_Proxy)
return AMF.UML.Structured_Activity_Nodes.UML_Structured_Activity_Node_Access;
-- Getter of ActivityEdge::inStructuredNode.
--
-- Structured activity node containing the edge.
overriding procedure Set_In_Structured_Node
(Self : not null access UML_Control_Flow_Proxy;
To : AMF.UML.Structured_Activity_Nodes.UML_Structured_Activity_Node_Access);
-- Setter of ActivityEdge::inStructuredNode.
--
-- Structured activity node containing the edge.
overriding function Get_Interrupts
(Self : not null access constant UML_Control_Flow_Proxy)
return AMF.UML.Interruptible_Activity_Regions.UML_Interruptible_Activity_Region_Access;
-- Getter of ActivityEdge::interrupts.
--
-- Region that the edge can interrupt.
overriding procedure Set_Interrupts
(Self : not null access UML_Control_Flow_Proxy;
To : AMF.UML.Interruptible_Activity_Regions.UML_Interruptible_Activity_Region_Access);
-- Setter of ActivityEdge::interrupts.
--
-- Region that the edge can interrupt.
overriding function Get_Redefined_Edge
(Self : not null access constant UML_Control_Flow_Proxy)
return AMF.UML.Activity_Edges.Collections.Set_Of_UML_Activity_Edge;
-- Getter of ActivityEdge::redefinedEdge.
--
-- Inherited edges replaced by this edge in a specialization of the
-- activity.
overriding function Get_Source
(Self : not null access constant UML_Control_Flow_Proxy)
return AMF.UML.Activity_Nodes.UML_Activity_Node_Access;
-- Getter of ActivityEdge::source.
--
-- Node from which tokens are taken when they traverse the edge.
overriding procedure Set_Source
(Self : not null access UML_Control_Flow_Proxy;
To : AMF.UML.Activity_Nodes.UML_Activity_Node_Access);
-- Setter of ActivityEdge::source.
--
-- Node from which tokens are taken when they traverse the edge.
overriding function Get_Target
(Self : not null access constant UML_Control_Flow_Proxy)
return AMF.UML.Activity_Nodes.UML_Activity_Node_Access;
-- Getter of ActivityEdge::target.
--
-- Node to which tokens are put when they traverse the edge.
overriding procedure Set_Target
(Self : not null access UML_Control_Flow_Proxy;
To : AMF.UML.Activity_Nodes.UML_Activity_Node_Access);
-- Setter of ActivityEdge::target.
--
-- Node to which tokens are put when they traverse the edge.
overriding function Get_Weight
(Self : not null access constant UML_Control_Flow_Proxy)
return AMF.UML.Value_Specifications.UML_Value_Specification_Access;
-- Getter of ActivityEdge::weight.
--
-- The minimum number of tokens that must traverse the edge at the same
-- time.
overriding procedure Set_Weight
(Self : not null access UML_Control_Flow_Proxy;
To : AMF.UML.Value_Specifications.UML_Value_Specification_Access);
-- Setter of ActivityEdge::weight.
--
-- The minimum number of tokens that must traverse the edge at the same
-- time.
overriding function Get_Is_Leaf
(Self : not null access constant UML_Control_Flow_Proxy)
return Boolean;
-- Getter of RedefinableElement::isLeaf.
--
-- Indicates whether it is possible to further redefine a
-- RedefinableElement. If the value is true, then it is not possible to
-- further redefine the RedefinableElement. Note that this property is
-- preserved through package merge operations; that is, the capability to
-- redefine a RedefinableElement (i.e., isLeaf=false) must be preserved in
-- the resulting RedefinableElement of a package merge operation where a
-- RedefinableElement with isLeaf=false is merged with a matching
-- RedefinableElement with isLeaf=true: the resulting RedefinableElement
-- will have isLeaf=false. Default value is false.
overriding procedure Set_Is_Leaf
(Self : not null access UML_Control_Flow_Proxy;
To : Boolean);
-- Setter of RedefinableElement::isLeaf.
--
-- Indicates whether it is possible to further redefine a
-- RedefinableElement. If the value is true, then it is not possible to
-- further redefine the RedefinableElement. Note that this property is
-- preserved through package merge operations; that is, the capability to
-- redefine a RedefinableElement (i.e., isLeaf=false) must be preserved in
-- the resulting RedefinableElement of a package merge operation where a
-- RedefinableElement with isLeaf=false is merged with a matching
-- RedefinableElement with isLeaf=true: the resulting RedefinableElement
-- will have isLeaf=false. Default value is false.
overriding function Get_Redefined_Element
(Self : not null access constant UML_Control_Flow_Proxy)
return AMF.UML.Redefinable_Elements.Collections.Set_Of_UML_Redefinable_Element;
-- Getter of RedefinableElement::redefinedElement.
--
-- The redefinable element that is being redefined by this element.
overriding function Get_Redefinition_Context
(Self : not null access constant UML_Control_Flow_Proxy)
return AMF.UML.Classifiers.Collections.Set_Of_UML_Classifier;
-- Getter of RedefinableElement::redefinitionContext.
--
-- References the contexts that this element may be redefined from.
overriding function Get_Client_Dependency
(Self : not null access constant UML_Control_Flow_Proxy)
return AMF.UML.Dependencies.Collections.Set_Of_UML_Dependency;
-- Getter of NamedElement::clientDependency.
--
-- Indicates the dependencies that reference the client.
overriding function Get_Name_Expression
(Self : not null access constant UML_Control_Flow_Proxy)
return AMF.UML.String_Expressions.UML_String_Expression_Access;
-- Getter of NamedElement::nameExpression.
--
-- The string expression used to define the name of this named element.
overriding procedure Set_Name_Expression
(Self : not null access UML_Control_Flow_Proxy;
To : AMF.UML.String_Expressions.UML_String_Expression_Access);
-- Setter of NamedElement::nameExpression.
--
-- The string expression used to define the name of this named element.
overriding function Get_Namespace
(Self : not null access constant UML_Control_Flow_Proxy)
return AMF.UML.Namespaces.UML_Namespace_Access;
-- Getter of NamedElement::namespace.
--
-- Specifies the namespace that owns the NamedElement.
overriding function Get_Qualified_Name
(Self : not null access constant UML_Control_Flow_Proxy)
return AMF.Optional_String;
-- Getter of NamedElement::qualifiedName.
--
-- A name which allows the NamedElement to be identified within a
-- hierarchy of nested Namespaces. It is constructed from the names of the
-- containing namespaces starting at the root of the hierarchy and ending
-- with the name of the NamedElement itself.
overriding function Is_Consistent_With
(Self : not null access constant UML_Control_Flow_Proxy;
Redefinee : AMF.UML.Redefinable_Elements.UML_Redefinable_Element_Access)
return Boolean;
-- Operation RedefinableElement::isConsistentWith.
--
-- The query isConsistentWith() specifies, for any two RedefinableElements
-- in a context in which redefinition is possible, whether redefinition
-- would be logically consistent. By default, this is false; this
-- operation must be overridden for subclasses of RedefinableElement to
-- define the consistency conditions.
overriding function Is_Redefinition_Context_Valid
(Self : not null access constant UML_Control_Flow_Proxy;
Redefined : AMF.UML.Redefinable_Elements.UML_Redefinable_Element_Access)
return Boolean;
-- Operation RedefinableElement::isRedefinitionContextValid.
--
-- The query isRedefinitionContextValid() specifies whether the
-- redefinition contexts of this RedefinableElement are properly related
-- to the redefinition contexts of the specified RedefinableElement to
-- allow this element to redefine the other. By default at least one of
-- the redefinition contexts of this element must be a specialization of
-- at least one of the redefinition contexts of the specified element.
overriding function All_Owning_Packages
(Self : not null access constant UML_Control_Flow_Proxy)
return AMF.UML.Packages.Collections.Set_Of_UML_Package;
-- Operation NamedElement::allOwningPackages.
--
-- The query allOwningPackages() returns all the directly or indirectly
-- owning packages.
overriding function Is_Distinguishable_From
(Self : not null access constant UML_Control_Flow_Proxy;
N : AMF.UML.Named_Elements.UML_Named_Element_Access;
Ns : AMF.UML.Namespaces.UML_Namespace_Access)
return Boolean;
-- Operation NamedElement::isDistinguishableFrom.
--
-- The query isDistinguishableFrom() determines whether two NamedElements
-- may logically co-exist within a Namespace. By default, two named
-- elements are distinguishable if (a) they have unrelated types or (b)
-- they have related types but different names.
overriding function Namespace
(Self : not null access constant UML_Control_Flow_Proxy)
return AMF.UML.Namespaces.UML_Namespace_Access;
-- Operation NamedElement::namespace.
--
-- Missing derivation for NamedElement::/namespace : Namespace
overriding procedure Enter_Element
(Self : not null access constant UML_Control_Flow_Proxy;
Visitor : in out AMF.Visitors.Abstract_Visitor'Class;
Control : in out AMF.Visitors.Traverse_Control);
-- Dispatch call to corresponding subprogram of visitor interface.
overriding procedure Leave_Element
(Self : not null access constant UML_Control_Flow_Proxy;
Visitor : in out AMF.Visitors.Abstract_Visitor'Class;
Control : in out AMF.Visitors.Traverse_Control);
-- Dispatch call to corresponding subprogram of visitor interface.
overriding procedure Visit_Element
(Self : not null access constant UML_Control_Flow_Proxy;
Iterator : in out AMF.Visitors.Abstract_Iterator'Class;
Visitor : in out AMF.Visitors.Abstract_Visitor'Class;
Control : in out AMF.Visitors.Traverse_Control);
-- Dispatch call to corresponding subprogram of iterator interface.
end AMF.Internals.UML_Control_Flows;
|
reznikmm/matreshka | Ada | 3,987 | ads | ------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- Open Document Toolkit --
-- --
-- Runtime Library Component --
-- --
------------------------------------------------------------------------------
-- --
-- Copyright © 2014, Vadim Godunko <[email protected]> --
-- All rights reserved. --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions --
-- are met: --
-- --
-- * Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- --
-- * Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in the --
-- documentation and/or other materials provided with the distribution. --
-- --
-- * Neither the name of the Vadim Godunko, IE nor the names of its --
-- contributors may be used to endorse or promote products derived from --
-- this software without specific prior written permission. --
-- --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR --
-- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
-- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED --
-- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR --
-- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF --
-- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING --
-- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS --
-- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
-- --
------------------------------------------------------------------------------
-- $Revision$ $Date$
------------------------------------------------------------------------------
with ODF.DOM.Table_Country_Attributes;
package Matreshka.ODF_Table.Country_Attributes is
type Table_Country_Attribute_Node is
new Matreshka.ODF_Table.Abstract_Table_Attribute_Node
and ODF.DOM.Table_Country_Attributes.ODF_Table_Country_Attribute
with null record;
overriding function Create
(Parameters : not null access Matreshka.DOM_Attributes.Attribute_L2_Parameters)
return Table_Country_Attribute_Node;
overriding function Get_Local_Name
(Self : not null access constant Table_Country_Attribute_Node)
return League.Strings.Universal_String;
end Matreshka.ODF_Table.Country_Attributes;
|
tum-ei-rcs/StratoX | Ada | 2,598 | adb | ------------------------------------------------------------------------------
-- --
-- GNAT COMPILER COMPONENTS --
-- --
-- S Y S T E M . A D D R E S S _ T O _ A C C E S S _ C O N V E R S I O N S --
-- --
-- B o d y --
-- --
-- Copyright (C) 1992-2012, Free Software Foundation, Inc. --
-- --
-- GNAT is free software; you can redistribute it and/or modify it under --
-- terms of the GNU General Public License as published by the Free Soft- --
-- ware Foundation; either version 3, or (at your option) any later ver- --
-- sion. GNAT is distributed in the hope that it will be useful, but WITH- --
-- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY --
-- or FITNESS FOR A PARTICULAR PURPOSE. --
-- --
-- --
-- --
-- --
-- --
-- You should have received a copy of the GNU General Public License and --
-- a copy of the GCC Runtime Library Exception along with this program; --
-- see the files COPYING3 and COPYING.RUNTIME respectively. If not, see --
-- <http://www.gnu.org/licenses/>. --
-- --
-- GNAT was originally developed by the GNAT team at New York University. --
-- Extensive contributions were provided by Ada Core Technologies Inc. --
-- --
------------------------------------------------------------------------------
-- This package does not require a body, since it is a package renaming. We
-- provide a dummy file containing a No_Body pragma so that previous versions
-- of the body (which did exist) will not interfere.
pragma No_Body;
|
onox/sdlada | Ada | 2,841 | ads | --------------------------------------------------------------------------------------------------------------------
-- Copyright (c) 2013-2018 Luke A. Guest
--
-- This software is provided 'as-is', without any express or implied
-- warranty. In no event will the authors be held liable for any damages
-- arising from the use of this software.
--
-- Permission is granted to anyone to use this software for any purpose,
-- including commercial applications, and to alter it and redistribute it
-- freely, subject to the following restrictions:
--
-- 1. The origin of this software must not be misrepresented; you must not
-- claim that you wrote the original software. If you use this software
-- in a product, an acknowledgment in the product documentation would be
-- appreciated but is not required.
--
-- 2. Altered source versions must be plainly marked as such, and must not be
-- misrepresented as being the original software.
--
-- 3. This notice may not be removed or altered from any source
-- distribution.
--------------------------------------------------------------------------------------------------------------------
-- SDL.Events.Windows
--
-- Window specific events.
--------------------------------------------------------------------------------------------------------------------
package SDL.Events.Windows is
-- Window events.
Window : constant Event_Types := 16#0000_0200#;
System_Window_Manager : constant Event_Types := Window + 1;
type Window_Event_ID is
(None,
Shown,
Hidden,
Exposed,
Moved,
Resized,
Size_Changed,
Minimised,
Maximised,
Restored,
Enter,
Leave,
Focus_Gained,
Focus_Lost,
Close) with
Convention => C;
type Window_Events is
record
Event_Type : Event_Types; -- Will be set to Window.
Time_Stamp : Time_Stamps;
ID : SDL.Video.Windows.ID;
Event_ID : Window_Event_ID;
Padding_1 : Padding_8;
Padding_2 : Padding_8;
Padding_3 : Padding_8;
Data_1 : Interfaces.Integer_32;
Data_2 : Interfaces.Integer_32;
end record with
Convention => C;
private
for Window_Events use
record
Event_Type at 0 * SDL.Word range 0 .. 31;
Time_Stamp at 1 * SDL.Word range 0 .. 31;
ID at 2 * SDL.Word range 0 .. 31;
Event_ID at 3 * SDL.Word range 0 .. 7;
Padding_1 at 3 * SDL.Word range 8 .. 15;
Padding_2 at 3 * SDL.Word range 16 .. 23;
Padding_3 at 3 * SDL.Word range 24 .. 31;
Data_1 at 4 * SDL.Word range 0 .. 31;
Data_2 at 5 * SDL.Word range 0 .. 31;
end record;
end SDL.Events.Windows;
|
faelys/natools | Ada | 6,920 | adb | ------------------------------------------------------------------------------
-- Copyright (c) 2016-2017, Natacha Porté --
-- --
-- Permission to use, copy, modify, and distribute this software for any --
-- purpose with or without fee is hereby granted, provided that the above --
-- copyright notice and this permission notice appear in all copies. --
-- --
-- THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES --
-- WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF --
-- MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR --
-- ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES --
-- WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN --
-- ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF --
-- OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. --
------------------------------------------------------------------------------
package body Natools.Smaz_Implementations.Base_256 is
use type Ada.Streams.Stream_Element;
use type Ada.Streams.Stream_Element_Offset;
procedure Read_Code
(Input : in Ada.Streams.Stream_Element_Array;
Offset : in out Ada.Streams.Stream_Element_Offset;
Code : out Ada.Streams.Stream_Element;
Verbatim_Length : out Natural;
Last_Code : in Ada.Streams.Stream_Element;
Variable_Length_Verbatim : in Boolean)
is
Input_Byte : constant Ada.Streams.Stream_Element := Input (Offset);
begin
if Input_Byte <= Last_Code then
Code := Input_Byte;
Verbatim_Length := 0;
else
Code := 0;
if not Variable_Length_Verbatim then
Verbatim_Length
:= Natural (Ada.Streams.Stream_Element'Last - Input_Byte) + 1;
elsif Input_Byte < Ada.Streams.Stream_Element'Last then
Verbatim_Length
:= Positive (Ada.Streams.Stream_Element'Last - Input_Byte);
else
Offset := Offset + 1;
Verbatim_Length
:= Positive (Input (Offset))
+ Natural (Ada.Streams.Stream_Element'Last - Last_Code)
- 1;
end if;
end if;
Offset := Offset + 1;
end Read_Code;
procedure Read_Verbatim
(Input : in Ada.Streams.Stream_Element_Array;
Offset : in out Ada.Streams.Stream_Element_Offset;
Output : out String) is
begin
for I in Output'Range loop
Output (I) := Character'Val (Input (Offset));
Offset := Offset + 1;
end loop;
end Read_Verbatim;
procedure Skip_Verbatim
(Input : in Ada.Streams.Stream_Element_Array;
Offset : in out Ada.Streams.Stream_Element_Offset;
Verbatim_Length : in Positive)
is
pragma Unreferenced (Input);
begin
Offset := Offset + Ada.Streams.Stream_Element_Offset (Verbatim_Length);
end Skip_Verbatim;
function Verbatim_Size
(Input_Length : in Positive;
Last_Code : in Ada.Streams.Stream_Element;
Variable_Length_Verbatim : in Boolean)
return Ada.Streams.Stream_Element_Count
is
Verbatim1_Max_Size : constant Ada.Streams.Stream_Element_Count
:= Ada.Streams.Stream_Element_Count
(Ada.Streams.Stream_Element'Last - Last_Code)
- Boolean'Pos (Variable_Length_Verbatim);
Verbatim2_Max_Size : constant Ada.Streams.Stream_Element_Count
:= Ada.Streams.Stream_Element_Count (Ada.Streams.Stream_Element'Last)
+ Verbatim1_Max_Size;
Remaining : Ada.Streams.Stream_Element_Count
:= Ada.Streams.Stream_Element_Count (Input_Length);
Overhead : Ada.Streams.Stream_Element_Count := 0;
begin
if Variable_Length_Verbatim then
if Remaining >= Verbatim2_Max_Size then
declare
Full_Blocks : constant Ada.Streams.Stream_Element_Count
:= Remaining / Verbatim2_Max_Size;
begin
Overhead := Overhead + 2 * Full_Blocks;
Remaining := Remaining - Verbatim2_Max_Size * Full_Blocks;
end;
end if;
if Remaining > Verbatim1_Max_Size then
Overhead := Overhead + 2;
Remaining := 0;
end if;
end if;
declare
Block_Count : constant Ada.Streams.Stream_Element_Count
:= (Remaining + Verbatim1_Max_Size - 1) / Verbatim1_Max_Size;
begin
Overhead := Overhead + Block_Count;
end;
return Overhead + Ada.Streams.Stream_Element_Count (Input_Length);
end Verbatim_Size;
procedure Write_Code
(Output : in out Ada.Streams.Stream_Element_Array;
Offset : in out Ada.Streams.Stream_Element_Offset;
Code : in Ada.Streams.Stream_Element) is
begin
Output (Offset) := Code;
Offset := Offset + 1;
end Write_Code;
procedure Write_Verbatim
(Output : in out Ada.Streams.Stream_Element_Array;
Offset : in out Ada.Streams.Stream_Element_Offset;
Input : in String;
Last_Code : in Ada.Streams.Stream_Element;
Variable_Length_Verbatim : in Boolean)
is
Verbatim1_Max_Size : constant Natural
:= Natural (Ada.Streams.Stream_Element'Last - Last_Code)
- Boolean'Pos (Variable_Length_Verbatim);
Verbatim2_Max_Size : constant Natural
:= Natural (Ada.Streams.Stream_Element'Last)
+ Verbatim1_Max_Size;
Input_Index : Positive := Input'First;
Remaining_Length, Block_Length : Positive;
begin
while Input_Index in Input'Range loop
Remaining_Length := Input'Last - Input_Index + 1;
if Variable_Length_Verbatim
and then Remaining_Length > Verbatim1_Max_Size
then
Block_Length := Positive'Min
(Remaining_Length, Verbatim2_Max_Size);
Output (Offset) := Ada.Streams.Stream_Element'Last;
Output (Offset + 1) := Ada.Streams.Stream_Element
(Block_Length - Verbatim1_Max_Size);
Offset := Offset + 2;
else
Block_Length := Positive'Min
(Remaining_Length, Verbatim1_Max_Size);
Output (Offset)
:= Ada.Streams.Stream_Element'Last
- Ada.Streams.Stream_Element
(Block_Length - 1 + Boolean'Pos (Variable_Length_Verbatim));
Offset := Offset + 1;
end if;
Verbatim_Copy :
for I in 1 .. Block_Length loop
Output (Offset) := Character'Pos (Input (Input_Index));
Offset := Offset + 1;
Input_Index := Input_Index + 1;
end loop Verbatim_Copy;
end loop;
end Write_Verbatim;
end Natools.Smaz_Implementations.Base_256;
|
charlie5/cBound | Ada | 1,413 | ads | -- This file is generated by SWIG. Please do not modify by hand.
--
with Interfaces.C;
with xcb.xcb_char2b_t;
with Interfaces.C;
with Interfaces.C.Pointers;
package xcb.xcb_char2b_iterator_t is
-- Item
--
type Item is record
data : access xcb.xcb_char2b_t.Item;
the_rem : aliased Interfaces.C.int;
index : aliased Interfaces.C.int;
end record;
-- Item_Array
--
type Item_Array is
array
(Interfaces.C.size_t range <>) of aliased xcb.xcb_char2b_iterator_t
.Item;
-- Pointer
--
package C_Pointers is new Interfaces.C.Pointers
(Index => Interfaces.C.size_t,
Element => xcb.xcb_char2b_iterator_t.Item,
Element_Array => xcb.xcb_char2b_iterator_t.Item_Array,
Default_Terminator => (others => <>));
subtype Pointer is C_Pointers.Pointer;
-- Pointer_Array
--
type Pointer_Array is
array
(Interfaces.C.size_t range <>) of aliased xcb.xcb_char2b_iterator_t
.Pointer;
-- Pointer_Pointer
--
package C_Pointer_Pointers is new Interfaces.C.Pointers
(Index => Interfaces.C.size_t,
Element => xcb.xcb_char2b_iterator_t.Pointer,
Element_Array => xcb.xcb_char2b_iterator_t.Pointer_Array,
Default_Terminator => null);
subtype Pointer_Pointer is C_Pointer_Pointers.Pointer;
end xcb.xcb_char2b_iterator_t;
|
jquorning/iNow | Ada | 4,592 | adb | pragma License (Restricted);
--
-- Copyright (C) 2020 Jesper Quorning All Rights Reserved.
--
-- The author disclaims copyright to this source code. In place of
-- a legal notice, here is a blessing:
--
-- May you do good and not evil.
-- May you find forgiveness for yourself and forgive others.
-- May you share freely, not taking more than you give.
--
with Ada.Strings.Unbounded;
with Interfaces;
with SQLite;
package body Database.Jobs is
use Ada.Strings.Unbounded;
function Get_Id (S : SQLite.Statement) return Interfaces.Integer_64;
function Get_Id (S : SQLite.Statement) return Interfaces.Integer_64 is
begin
return SQLite.Column (S, 1);
end Get_Id;
function Get_Current_Job return Types.Job_Id is
use SQLite, Interfaces;
Command : constant Statement :=
Prepare (Database.DB,
"SELECT Job FROM Current");
begin
Command.Step;
return
Types.Job_Id (Integer_64'(Command.Column (1)));
end Get_Current_Job;
procedure Set_Current_Job (Job : in Types.Job_Id) is
use SQLite, Interfaces;
Command : constant Statement :=
Prepare (Database.DB,
"UPDATE Current SET Job=?");
begin
Command.Bind (1, Integer_64 (Job));
Command.Step;
end Set_Current_Job;
function Get_Jobs (Top : in Types.Job_Id)
return Types.Job_Sets.Vector
is
use SQLite;
Command : Statement;
Count : Positive := Positive'First;
Jobs : Types.Job_Sets.Vector;
begin
Jobs.Clear;
if Top = All_Jobs then
Command := Prepare (Database.DB,
"SELECT Id, Title " &
"FROM Job");
else
Command := Prepare (Database.DB,
"SELECT Id, Title " &
"FROM Job WHERE List = ?");
Command.Bind (1, Interfaces.Integer_64 (Top));
end if;
while Command.Step loop
declare
Title_Image : constant String := Column (Command, 2);
Id : constant Types.Job_Id
:= Types.Job_Id (Get_Id (Command));
begin
Jobs.Append
((Id, Ada.Strings.Unbounded.To_Unbounded_String
(Title_Image)));
end;
Count := Positive'Succ (Count);
end loop;
return Jobs;
end Get_Jobs;
function Get_Job_Info (Job : in Types.Job_Id)
return Types.Job_Info
is
use SQLite, Interfaces;
Command : constant Statement :=
Prepare (Database.DB,
"SELECT Title, List, Owner " &
"FROM Job " &
"WHERE Id=?");
begin
Command.Bind (1, Integer_64 (Job));
Command.Step;
declare
Title : constant String := Command.Column (1);
List : constant Integer_64 := Command.Column (2);
Owner : constant String := Command.Column (3);
begin
return Types.Job_Info'(To_Unbounded_String (Title),
Types.Job_Id (List),
To_Unbounded_String (Owner));
end;
end Get_Job_Info;
procedure Add_Job (Id : in Types.Job_Id;
Title : in String;
Parent : in Types.Job_Id;
Owner : in String)
is
use SQLite, Interfaces;
Command : constant Statement :=
Prepare (Database.DB,
"INSERT INTO Job (Id, Title, List, Owner) " &
"VALUES (?,?,?,?)");
begin
Bind (Command, 1, Integer_64 (Id));
Bind (Command, 2, Title);
Bind (Command, 3, Integer_64 (Parent));
Bind (Command, 4, Owner);
Command.Step;
end Add_Job;
function Get_New_Job_Id return Types.Job_Id
is
use SQLite;
Command : constant Statement :=
Prepare (Database.DB,
"SELECT MAX(Id) + 1 FROM Job");
Id : Types.Job_Id;
begin
Command.Step;
Id := Types.Job_Id (Get_Id (Command));
return Id;
end Get_New_Job_Id;
procedure Transfer (Job : in Types.Job_Id;
To_Parent : in Types.Job_Id)
is
use SQLite, Interfaces;
Command : constant Statement :=
Prepare (Database.DB,
"UPDATE Job SET List=? " &
"WHERE Id=?");
begin
Command.Bind (1, Integer_64 (To_Parent));
Command.Bind (2, Integer_64 (Job));
Command.Step;
end Transfer;
end Database.Jobs;
|
AaronC98/PlaneSystem | Ada | 4,699 | ads | ------------------------------------------------------------------------------
-- Ada Web Server --
-- --
-- Copyright (C) 2003-2014, AdaCore --
-- --
-- This library is free software; you can redistribute it and/or modify --
-- it under terms of the GNU General Public License as published by the --
-- Free Software Foundation; either version 3, or (at your option) any --
-- later version. This library is distributed in the hope that it will be --
-- useful, but WITHOUT ANY WARRANTY; without even the implied warranty of --
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. --
-- --
-- --
-- --
-- --
-- --
-- You should have received a copy of the GNU General Public License and --
-- a copy of the GCC Runtime Library Exception along with this program; --
-- see the files COPYING3 and COPYING.RUNTIME respectively. If not, see --
-- <http://www.gnu.org/licenses/>. --
-- --
-- --
-- --
-- --
-- --
-- --
-- --
------------------------------------------------------------------------------
pragma Ada_2012;
-- API to handle a memory stream. A memory stream is first created
-- empty. User can add chunk of data using the Append routines. The stream
-- is then read using the Read procedure.
with AWS.Utils;
private with AWS.Containers.Memory_Streams;
package AWS.Resources.Streams.Memory is
type Stream_Type is new Streams.Stream_Type with private;
subtype Stream_Element_Access is Utils.Stream_Element_Array_Access;
subtype Buffer_Access is Utils.Stream_Element_Array_Constant_Access;
procedure Append
(Resource : in out Stream_Type;
Buffer : Stream_Element_Array;
Trim : Boolean := False);
-- Append Buffer into the memory stream
procedure Append
(Resource : in out Stream_Type;
Buffer : Stream_Element_Access);
-- Append static data pointed to Buffer into the memory stream as is.
-- The stream will free the memory on close.
procedure Append
(Resource : in out Stream_Type;
Buffer : Buffer_Access);
-- Append static data pointed to Buffer into the memory stream as is.
-- The stream would not try to free the memory on close.
overriding procedure Read
(Resource : in out Stream_Type;
Buffer : out Stream_Element_Array;
Last : out Stream_Element_Offset);
-- Returns a chunck of data in Buffer, Last point to the last element
-- returned in Buffer.
overriding function End_Of_File (Resource : Stream_Type) return Boolean;
-- Returns True if the end of the memory stream has been reached
procedure Clear (Resource : in out Stream_Type) with Inline;
-- Delete all data from memory stream
overriding procedure Reset (Resource : in out Stream_Type);
-- Reset the streaming data to the first position
overriding procedure Set_Index
(Resource : in out Stream_Type;
To : Stream_Element_Offset);
-- Set the position in the stream, next Read will start at the position
-- whose index is To.
overriding function Size
(Resource : Stream_Type) return Stream_Element_Offset;
-- Returns the number of bytes in the memory stream
overriding procedure Close (Resource : in out Stream_Type);
-- Close the memory stream. Release all memory associated with the stream
private
package Containers renames AWS.Containers.Memory_Streams;
type Stream_Type is new Streams.Stream_Type with record
Data : Containers.Stream_Type;
end record;
end AWS.Resources.Streams.Memory;
|
thierr26/ada-keystore | Ada | 23,444 | adb | -----------------------------------------------------------------------
-- keystore-io-files -- Ada keystore IO for files
-- Copyright (C) 2019 Stephane Carrez
-- Written by Stephane Carrez ([email protected])
--
-- Licensed under the Apache License, Version 2.0 (the "License");
-- you may not use this file except in compliance with the License.
-- You may obtain a copy of the License at
--
-- http://www.apache.org/licenses/LICENSE-2.0
--
-- Unless required by applicable law or agreed to in writing, software
-- distributed under the License is distributed on an "AS IS" BASIS,
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-- See the License for the specific language governing permissions and
-- limitations under the License.
-----------------------------------------------------------------------
with Ada.IO_Exceptions;
with Ada.Unchecked_Deallocation;
with Ada.Directories;
with Interfaces.C.Strings;
with Util.Encoders.AES;
with Util.Log.Loggers;
with Util.Strings;
with Util.Systems.Os;
with Util.Systems.Constants;
-- File header
-- +------------------+
-- | 41 64 61 00 | 4b = Ada
-- | 00 9A 72 57 | 4b = 10/12/1815
-- | 01 9D B1 AC | 4b = 27/11/1852
-- | 00 00 00 01 | 4b = Version 1
-- +------------------+
-- | Keystore UUID | 16b
-- | Storage ID | 4b
-- | Block size | 4b
-- | PAD 0 | 4b
-- | Header HMAC-256 | 32b
-- +------------------+-----
package body Keystore.IO.Files is
use Ada.Strings.Unbounded;
use type Util.Systems.Types.File_Type;
use type Interfaces.C.int;
use Util.Systems.Constants;
Log : constant Util.Log.Loggers.Logger := Util.Log.Loggers.Create ("Keystore.IO.Files");
subtype off_t is Util.Systems.Types.off_t;
function Sys_Error return String;
function Get_Default_Data (Path : in String) return String;
procedure Free is
new Ada.Unchecked_Deallocation (Object => File_Stream,
Name => File_Stream_Access);
function Sys_Error return String is
Msg : constant Interfaces.C.Strings.chars_ptr
:= Util.Systems.Os.Strerror (Util.Systems.Os.Errno);
begin
return Interfaces.C.Strings.Value (Msg);
end Sys_Error;
function Hash (Value : Storage_Identifier) return Ada.Containers.Hash_Type is
begin
return Ada.Containers.Hash_Type (Value);
end Hash;
function Get_Default_Data (Path : in String) return String is
Pos : constant Natural := Util.Strings.Rindex (Path, '.');
begin
if Pos > 0 then
return Path (Path'First .. Pos - 1);
else
return Ada.Directories.Containing_Directory (Path);
end if;
end Get_Default_Data;
-- ------------------------------
-- Open the wallet stream.
-- ------------------------------
procedure Open (Stream : in out Wallet_Stream;
Path : in String;
Data_Path : in String) is
begin
if Data_Path'Length > 0 then
Stream.Descriptor.Open (Path, Data_Path, Stream.Sign);
else
Stream.Descriptor.Open (Path, Get_Default_Data (Path), Stream.Sign);
end if;
end Open;
procedure Create (Stream : in out Wallet_Stream;
Path : in String;
Data_Path : in String;
Config : in Wallet_Config) is
begin
if Data_Path'Length > 0 then
Stream.Descriptor.Create (Path, Data_Path, Config, Stream.Sign);
else
Stream.Descriptor.Create (Path, Get_Default_Data (Path), Config, Stream.Sign);
end if;
if Config.Storage_Count > 1 then
Stream.Add_Storage (Config.Storage_Count - 1);
end if;
end Create;
-- ------------------------------
-- Get information about the keystore file.
-- ------------------------------
function Get_Info (Stream : in out Wallet_Stream) return Wallet_Info is
File : File_Stream_Access;
begin
Stream.Descriptor.Get (DEFAULT_STORAGE_ID, File);
return File.Get_Info;
end Get_Info;
-- ------------------------------
-- Read from the wallet stream the block identified by the number and
-- call the `Process` procedure with the data block content.
-- ------------------------------
overriding
procedure Read (Stream : in out Wallet_Stream;
Block : in Storage_Block;
Process : not null access
procedure (Data : in IO_Block_Type)) is
File : File_Stream_Access;
begin
Stream.Descriptor.Get (Block.Storage, File);
File.Read (Block.Block, Process);
end Read;
-- ------------------------------
-- Write in the wallet stream the block identified by the block number.
-- ------------------------------
overriding
procedure Write (Stream : in out Wallet_Stream;
Block : in Storage_Block;
Process : not null access
procedure (Data : out IO_Block_Type)) is
File : File_Stream_Access;
begin
Stream.Descriptor.Get (Block.Storage, File);
File.Write (Block.Block, Process);
end Write;
-- ------------------------------
-- Allocate a new block and return the block number in `Block`.
-- ------------------------------
overriding
procedure Allocate (Stream : in out Wallet_Stream;
Kind : in Block_Kind;
Block : out Storage_Block) is
File : File_Stream_Access;
begin
Stream.Descriptor.Allocate (Kind, Block.Storage, File);
File.Allocate (Block.Block);
end Allocate;
-- ------------------------------
-- Release the block number.
-- ------------------------------
overriding
procedure Release (Stream : in out Wallet_Stream;
Block : in Storage_Block) is
File : File_Stream_Access;
begin
Stream.Descriptor.Get (Block.Storage, File);
File.Release (Block.Block);
end Release;
overriding
function Is_Used (Stream : in out Wallet_Stream;
Block : in Storage_Block) return Boolean is
File : File_Stream_Access;
begin
Stream.Descriptor.Get (Block.Storage, File);
return File.Is_Used (Block.Block);
end Is_Used;
overriding
procedure Set_Header_Data (Stream : in out Wallet_Stream;
Index : in Header_Slot_Index_Type;
Kind : in Header_Slot_Type;
Data : in Ada.Streams.Stream_Element_Array) is
File : File_Stream_Access;
begin
Stream.Descriptor.Get (DEFAULT_STORAGE_ID, File);
File.Set_Header_Data (Index, Kind, Data, Stream.Sign);
end Set_Header_Data;
overriding
procedure Get_Header_Data (Stream : in out Wallet_Stream;
Index : in Header_Slot_Index_Type;
Kind : out Header_Slot_Type;
Data : out Ada.Streams.Stream_Element_Array;
Last : out Ada.Streams.Stream_Element_Offset) is
File : File_Stream_Access;
begin
Stream.Descriptor.Get (DEFAULT_STORAGE_ID, File);
File.Get_Header_Data (Index, Kind, Data, Last);
end Get_Header_Data;
-- ------------------------------
-- Add up to Count data storage files associated with the wallet.
-- ------------------------------
procedure Add_Storage (Stream : in out Wallet_Stream;
Count : in Positive) is
begin
Stream.Descriptor.Add_Storage (Count, Stream.Sign);
end Add_Storage;
-- ------------------------------
-- Close the wallet stream and release any resource.
-- ------------------------------
procedure Close (Stream : in out Wallet_Stream) is
begin
Stream.Descriptor.Close;
end Close;
function Get_Block_Offset (Block : in Block_Number) return off_t is
(Util.Systems.Types.off_t (Block) * Block_Size);
protected body File_Stream is
procedure Open (File_Descriptor : in Util.Systems.Types.File_Type;
Storage : in Storage_Identifier;
Sign : in Secret_Key;
File_Size : in Block_Count;
UUID : out UUID_Type) is
begin
File.Initialize (File_Descriptor);
Size := File_Size;
Current_Pos := Block_Size;
Header.Buffer := Buffers.Allocate ((Storage, HEADER_BLOCK_NUM));
declare
Buf : constant Buffers.Buffer_Accessor := Header.Buffer.Data.Value;
Last : Ada.Streams.Stream_Element_Offset;
begin
File.Read (Data, Last);
if Last /= Data'Last then
Log.Warn ("Header block is too short");
raise Invalid_Keystore;
end if;
Buf.Data := Data (Buf.Data'Range);
Keystore.IO.Headers.Sign_Header (Header, Sign);
if Header.HMAC /= Data (BT_HMAC_HEADER_POS .. Data'Last) then
Log.Warn ("Header block HMAC signature is invalid");
raise Invalid_Block;
end if;
Keystore.IO.Headers.Read_Header (Header);
UUID := Header.UUID;
end;
end Open;
procedure Create (File_Descriptor : in Util.Systems.Types.File_Type;
Storage : in Storage_Identifier;
UUID : in UUID_Type;
Sign : in Secret_Key) is
begin
File.Initialize (File_Descriptor);
Size := 1;
Current_Pos := Block_Size;
Header.Buffer := Buffers.Allocate ((Storage, HEADER_BLOCK_NUM));
Header.UUID := UUID;
Keystore.IO.Headers.Build_Header (UUID, Storage, Header);
Keystore.IO.Headers.Sign_Header (Header, Sign);
declare
Buf : constant Buffers.Buffer_Accessor := Header.Buffer.Data.Value;
begin
File.Write (Buf.Data);
File.Write (Header.HMAC);
end;
end Create;
function Get_Info return Wallet_Info is
Result : Wallet_Info;
begin
Result.UUID := Header.UUID;
Result.Header_Count := Header.Data_Count;
Result.Storage_Count := Header.Storage_Count;
return Result;
end Get_Info;
-- Read from the wallet stream the block identified by the number and
-- call the `Process` procedure with the data block content.
procedure Read (Block : in Block_Number;
Process : not null access
procedure (Data : in IO_Block_Type)) is
Pos : constant off_t := Get_Block_Offset (Block);
Last : Ada.Streams.Stream_Element_Offset;
begin
if Pos /= Current_Pos then
File.Seek (Pos => Pos, Mode => Util.Systems.Types.SEEK_SET);
end if;
File.Read (Data, Last);
Process (Data);
Current_Pos := Pos + Block_Size;
end Read;
-- Write in the wallet stream the block identified by the block number.
procedure Write (Block : in Block_Number;
Process : not null access
procedure (Data : out IO_Block_Type)) is
Pos : constant off_t := Get_Block_Offset (Block);
begin
if Pos /= Current_Pos then
File.Seek (Pos => Pos, Mode => Util.Systems.Types.SEEK_SET);
end if;
Process (Data);
File.Write (Data);
Current_Pos := Pos + Block_Size;
end Write;
-- ------------------------------
-- Returns true if the block number is allocated.
-- ------------------------------
function Is_Used (Block : in Block_Number) return Boolean is
begin
return Block <= Size and not Free_Blocks.Contains (Block);
end Is_Used;
-- ------------------------------
-- Allocate a new block and return the block number in `Block`.
-- ------------------------------
procedure Allocate (Block : out Block_Number) is
begin
if not Free_Blocks.Is_Empty then
Block := Free_Blocks.First_Element;
Free_Blocks.Delete_First;
else
Block := Block_Number (Size);
Size := Size + 1;
end if;
end Allocate;
-- ------------------------------
-- Release the block number.
-- ------------------------------
procedure Release (Block : in Block_Number) is
begin
Free_Blocks.Insert (Block);
end Release;
procedure Save_Header (Sign : in Secret_Key) is
Buf : constant Buffers.Buffer_Accessor := Header.Buffer.Data.Value;
begin
Keystore.IO.Headers.Sign_Header (Header, Sign);
File.Seek (Pos => 0, Mode => Util.Systems.Types.SEEK_SET);
File.Write (Buf.Data);
File.Write (Header.HMAC);
Current_Pos := Block_Size;
end Save_Header;
procedure Set_Header_Data (Index : in Header_Slot_Index_Type;
Kind : in Header_Slot_Type;
Data : in Ada.Streams.Stream_Element_Array;
Sign : in Secret_Key) is
begin
IO.Headers.Set_Header_Data (Header, Index, Kind, Data);
Save_Header (Sign);
end Set_Header_Data;
procedure Get_Header_Data (Index : in Header_Slot_Index_Type;
Kind : out Header_Slot_Type;
Data : out Ada.Streams.Stream_Element_Array;
Last : out Ada.Streams.Stream_Element_Offset) is
begin
IO.Headers.Get_Header_Data (Header, Index, Kind, Data, Last);
end Get_Header_Data;
procedure Add_Storage (Identifier : in Storage_Identifier;
Sign : in Secret_Key) is
Pos : Block_Index;
begin
IO.Headers.Add_Storage (Header, Identifier, 1, Pos);
Save_Header (Sign);
end Add_Storage;
procedure Scan_Storage (Process : not null
access procedure (Storage : in Wallet_Storage)) is
begin
IO.Headers.Scan_Storage (Header, Process);
end Scan_Storage;
procedure Close is
Last : Block_Number := Size;
Free_Block : Block_Number;
Iter : Block_Number_Sets.Cursor := Free_Blocks.Last;
begin
-- Look at free blocks to see if we can truncate the file when
-- the last blocks are all deleted.
while Block_Number_Sets.Has_Element (Iter) loop
Free_Block := Block_Number_Sets.Element (Iter);
exit when Free_Block /= Last - 1;
Last := Last - 1;
Block_Number_Sets.Previous (Iter);
end loop;
-- We have the last deleted block and we can truncate the file to it inclusive.
if Last /= Size then
declare
Length : constant off_t := Get_Block_Offset (Last);
Result : Integer;
begin
Result := Util.Systems.Os.Sys_Ftruncate (File.Get_File, Length);
if Result /= 0 then
Log.Warn ("Truncate to drop deleted blocks failed: {0}", Sys_Error);
end if;
end;
end if;
File.Close;
end Close;
end File_Stream;
protected body Stream_Descriptor is
function Get_Storage_Path (Storage_Id : in Storage_Identifier) return String is
Prefix : constant String := To_String (UUID);
Index : constant String := Storage_Identifier'Image (Storage_Id);
Name : constant String := Prefix & "-" & Index (Index'First + 1 .. Index'Last);
begin
return Ada.Directories.Compose (To_String (Directory), Name & ".dkt");
end Get_Storage_Path;
procedure Open (Path : in String;
Identifier : in Storage_Identifier;
Sign : in Secret_Key;
Tag : out UUID_Type) is
Fd : Util.Systems.Types.File_Type := Util.Systems.Os.NO_FILE;
P : Interfaces.C.Strings.chars_ptr;
File : File_Stream_Access;
Flags : Interfaces.C.int;
Stat : aliased Util.Systems.Types.Stat_Type;
Size : Block_Count;
Result : Integer;
begin
Flags := O_CLOEXEC + O_RDWR;
P := Interfaces.C.Strings.New_String (Path);
Fd := Util.Systems.Os.Sys_Open (P, Flags, 8#600#);
Interfaces.C.Strings.Free (P);
if Fd = Util.Systems.Os.NO_FILE then
Log.Error ("Cannot open keystore '{0}': {1}", Path, Sys_Error);
raise Ada.IO_Exceptions.Name_Error with Path;
end if;
Result := Util.Systems.Os.Sys_Fstat (Fd, Stat'Access);
if Result /= 0 then
Result := Util.Systems.Os.Sys_Close (Fd);
Log.Error ("Invalid keystore file '{0}': {1}", Path, Sys_Error);
raise Ada.IO_Exceptions.Name_Error with Path;
end if;
if Stat.st_size mod IO.Block_Size /= 0 then
Result := Util.Systems.Os.Sys_Close (Fd);
Log.Error ("Invalid or truncated keystore file '{0}': size is incorrect", Path);
raise Ada.IO_Exceptions.Name_Error with Path;
end if;
Size := Block_Count (Stat.st_size / IO.Block_Size);
File := new File_Stream;
Files.Insert (Identifier, File);
File.Open (Fd, Identifier, Sign, Size, Tag);
end Open;
procedure Open (Path : in String;
Data_Path : in String;
Sign : in Secret_Key) is
procedure Open_Storage (Storage : in Wallet_Storage);
procedure Open_Storage (Storage : in Wallet_Storage) is
Path : constant String := Get_Storage_Path (Storage.Identifier);
Tag : UUID_Type;
begin
Open (Path, Storage.Identifier, Sign, Tag);
if Tag /= UUID then
Log.Error ("Invalid UUID for storage file {0}", Path);
end if;
if Storage.Identifier > Last_Id then
Last_Id := Storage.Identifier;
end if;
Alloc_Id := 1;
end Open_Storage;
File : File_Stream_Access;
begin
if Data_Path'Length > 0 then
Directory := To_Unbounded_String (Data_Path);
else
Directory := To_Unbounded_String (Ada.Directories.Containing_Directory (Path));
end if;
Open (Path, DEFAULT_STORAGE_ID, Sign, UUID);
Get (DEFAULT_STORAGE_ID, File);
Last_Id := DEFAULT_STORAGE_ID;
File.Scan_Storage (Open_Storage'Access);
end Open;
procedure Create (Path : in String;
Data_Path : in String;
Config : in Wallet_Config;
Sign : in Secret_Key) is
Fd : Util.Systems.Types.File_Type := Util.Systems.Os.NO_FILE;
P : Interfaces.C.Strings.chars_ptr;
File : File_Stream_Access;
Flags : Interfaces.C.int;
Result : Integer with Unreferenced => True;
begin
Directory := To_Unbounded_String (Data_Path);
Flags := O_CREAT + O_TRUNC + O_CLOEXEC + O_RDWR;
if not Config.Overwrite then
Flags := Flags + O_EXCL;
end if;
P := Interfaces.C.Strings.New_String (Path);
Fd := Util.Systems.Os.Sys_Open (P, Flags, 8#600#);
Interfaces.C.Strings.Free (P);
if Fd = Util.Systems.Os.NO_FILE then
Log.Error ("Cannot create keystore '{0}': {1}", Path, Sys_Error);
raise Ada.IO_Exceptions.Name_Error with Path;
end if;
File := new File_Stream;
Random.Generate (UUID);
File.Create (Fd, DEFAULT_STORAGE_ID, UUID, Sign);
Files.Insert (DEFAULT_STORAGE_ID, File);
Last_Id := DEFAULT_STORAGE_ID;
end Create;
procedure Create_Storage (Storage_Id : in Storage_Identifier;
Sign : in Secret_Key) is
Path : constant String := Get_Storage_Path (Storage_Id);
Fd : Util.Systems.Types.File_Type := Util.Systems.Os.NO_FILE;
P : Interfaces.C.Strings.chars_ptr;
File : File_Stream_Access;
Flags : Interfaces.C.int;
Result : Integer with Unreferenced => True;
begin
Flags := O_CREAT + O_TRUNC + O_CLOEXEC + O_RDWR;
P := Interfaces.C.Strings.New_String (Path);
Fd := Util.Systems.Os.Sys_Open (P, Flags, 8#600#);
Interfaces.C.Strings.Free (P);
if Fd = Util.Systems.Os.NO_FILE then
Log.Error ("Cannot create keystore storage '{0}': {1}", Path, Sys_Error);
raise Ada.IO_Exceptions.Name_Error with Path;
end if;
File := new File_Stream;
File.Create (Fd, Storage_Id, UUID, Sign);
Files.Insert (Storage_Id, File);
end Create_Storage;
procedure Add_Storage (Count : in Positive;
Sign : in Secret_Key) is
File : File_Stream_Access;
Dir : constant String := To_String (Directory);
begin
Get (DEFAULT_STORAGE_ID, File);
if not Ada.Directories.Exists (Dir) then
Ada.Directories.Create_Path (Dir);
end if;
for I in 1 .. Count loop
Last_Id := Last_Id + 1;
Create_Storage (Last_Id, Sign);
File.Add_Storage (Last_Id, Sign);
end loop;
if Alloc_Id = DEFAULT_STORAGE_ID then
Alloc_Id := 1;
end if;
end Add_Storage;
procedure Get (Storage : in Storage_Identifier;
File : out File_Stream_Access) is
Pos : constant File_Stream_Maps.Cursor := Files.Find (Storage);
begin
if not File_Stream_Maps.Has_Element (Pos) then
Log.Error ("Storage{0} not found", Storage_Identifier'Image (Storage));
raise Keystore.Invalid_Storage;
end if;
File := File_Stream_Maps.Element (Pos);
end Get;
procedure Allocate (Kind : in Block_Kind;
Storage : out Storage_Identifier;
File : out File_Stream_Access) is
begin
if Kind = IO.MASTER_BLOCK or Kind = IO.DIRECTORY_BLOCK
or Last_Id = DEFAULT_STORAGE_ID
then
Storage := DEFAULT_STORAGE_ID;
else
Storage := Alloc_Id;
Alloc_Id := Alloc_Id + 1;
if Alloc_Id > Last_Id then
Alloc_Id := 1;
end if;
end if;
Get (Storage, File);
end Allocate;
procedure Close is
First : File_Stream_Maps.Cursor;
File : File_Stream_Access;
begin
while not File_Stream_Maps.Is_Empty (Files) loop
First := Files.First;
File := File_Stream_Maps.Element (First);
Files.Delete (First);
File.Close;
Free (File);
end loop;
end Close;
end Stream_Descriptor;
end Keystore.IO.Files;
|
reznikmm/matreshka | Ada | 3,635 | ads | ------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- Open Document Toolkit --
-- --
-- Runtime Library Component --
-- --
------------------------------------------------------------------------------
-- --
-- Copyright © 2013, Vadim Godunko <[email protected]> --
-- All rights reserved. --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions --
-- are met: --
-- --
-- * Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- --
-- * Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in the --
-- documentation and/or other materials provided with the distribution. --
-- --
-- * Neither the name of the Vadim Godunko, IE nor the names of its --
-- contributors may be used to endorse or promote products derived from --
-- this software without specific prior written permission. --
-- --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR --
-- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
-- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED --
-- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR --
-- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF --
-- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING --
-- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS --
-- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
-- --
------------------------------------------------------------------------------
-- $Revision$ $Date$
------------------------------------------------------------------------------
with XML.DOM.Attributes;
package ODF.DOM.Attributes.FO.Margin_Top is
type ODF_FO_Margin_Top is
new XML.DOM.Attributes.DOM_Attribute with private;
private
type ODF_FO_Margin_Top is
new XML.DOM.Attributes.DOM_Attribute with null record;
end ODF.DOM.Attributes.FO.Margin_Top;
|
onox/orka | Ada | 1,648 | ads | -- SPDX-License-Identifier: Apache-2.0
--
-- Copyright (c) 2021 onox <[email protected]>
--
-- Licensed under the Apache License, Version 2.0 (the "License");
-- you may not use this file except in compliance with the License.
-- You may obtain a copy of the License at
--
-- http://www.apache.org/licenses/LICENSE-2.0
--
-- Unless required by applicable law or agreed to in writing, software
-- distributed under the License is distributed on an "AS IS" BASIS,
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-- See the License for the specific language governing permissions and
-- limitations under the License.
with Orka.SIMD.AVX.Singles;
package Orka.SIMD.AVX2.Integers.Random
with SPARK_Mode => On
is
pragma Pure;
use Orka.SIMD.AVX.Singles;
type State is limited private;
pragma Preelaborable_Initialization (State);
procedure Next (S : in out State; Value : out m256i)
with Inline_Always,
Global => null,
Depends => ((S, Value) => S);
-- Use and modify the given state to generate multiple
-- random unsigned integers
procedure Next (S : in out State; Value : out m256)
with Inline_Always,
Global => null,
Depends => ((S, Value) => S);
-- Use and modify the given state to generate multiple random
-- floating-point numbers in the interval [0, 1).
procedure Reset (S : out State; Seed : Duration)
with Global => null,
Depends => (S => Seed),
Pre => Seed /= 0.0;
private
type State is array (Integer_32 range 0 .. 3) of m256i;
end Orka.SIMD.AVX2.Integers.Random;
|
AdaCore/libadalang | Ada | 178 | ads | limited with Bar;
package Foo is
type Foo_Type is record
B : access Bar_Type;
end record;
F : constant Foo_Type := (B => null);
pragma Test (F.B);
end Foo;
|
io7m/coreland-c_string | Ada | 1,960 | adb | with Ada.Strings.Unbounded;
with Ada.Text_IO;
with C_String.Arrays;
with Test;
procedure t_convert1 is
package IO renames Ada.Text_IO;
package UStrings renames Ada.Strings.Unbounded;
function ccall return C_String.Arrays.Pointer_Array_t;
pragma Import (c, ccall, "ccall");
begin
IO.Put_Line ("-- Ada begin");
declare
Address : constant C_String.Arrays.Pointer_Array_t := ccall;
Tab : constant C_String.Arrays.String_Array_t :=
C_String.Arrays.Convert
(Pointer => Address,
Size => C_String.Arrays.Size_Terminated (Address));
begin
Test.Assert
(Check => UStrings.To_String (Tab (0)) = "abcdefgh",
Pass_Message => "Tab (0) = " & UStrings.To_String (Tab (0)),
Fail_Message => "Tab (0) = " & UStrings.To_String (Tab (0)));
Test.Assert
(Check => UStrings.To_String (Tab (1)) = "zyxwvuts",
Pass_Message => "Tab (1) = " & UStrings.To_String (Tab (1)),
Fail_Message => "Tab (1) = " & UStrings.To_String (Tab (1)));
Test.Assert
(Check => UStrings.To_String (Tab (2)) = "12345678",
Pass_Message => "Tab (2) = " & UStrings.To_String (Tab (2)),
Fail_Message => "Tab (2) = " & UStrings.To_String (Tab (2)));
Test.Assert
(Check => UStrings.To_String (Tab (3)) = "klmnopqr",
Pass_Message => "Tab (3) = " & UStrings.To_String (Tab (3)),
Fail_Message => "Tab (3) = " & UStrings.To_String (Tab (3)));
Test.Assert
(Check => UStrings.To_String (Tab (4)) = "@@@@@@@@",
Pass_Message => "Tab (4) = " & UStrings.To_String (Tab (4)),
Fail_Message => "Tab (4) = " & UStrings.To_String (Tab (4)));
Test.Assert
(Check => UStrings.To_String (Tab (5)) = "&&&&&&&&",
Pass_Message => "Tab (5) = " & UStrings.To_String (Tab (5)),
Fail_Message => "Tab (5) = " & UStrings.To_String (Tab (5)));
end;
IO.Put_Line ("-- Ada exit");
end t_convert1;
|
ytomino/web-ada | Ada | 9,746 | adb | with System;
package body Web.HTML is
use type String_Maps.Cursor;
procedure By_Stream (Item : in String; Params : in System.Address) is
function To_Pointer (Value : System.Address)
return access Ada.Streams.Root_Stream_Type'Class
with Import, Convention => Intrinsic;
begin
String'Write (To_Pointer (Params), Item);
end By_Stream;
Alt_Quot : aliased constant String := """;
Alt_Apos : aliased constant String := "'";
Alt_LF : aliased constant String := " ";
procedure Write_In_Attribute_Internal (
Version : in HTML_Version;
Item : in String;
Params : in System.Address;
Write : not null access procedure (
Item : in String;
Params : in System.Address))
is
Alt : access constant String;
First : Positive := Item'First;
Last : Natural := First - 1;
I : Positive := Item'First;
begin
while I <= Item'Last loop
case Item (I) is
when '"' =>
Alt := Alt_Quot'Access;
goto FLUSH;
when ''' =>
Alt := Alt_Apos'Access;
goto FLUSH;
when Ada.Characters.Latin_1.LF =>
goto NEW_LINE;
when Ada.Characters.Latin_1.CR =>
if I < Item'Last
and then Item (I + 1) = Ada.Characters.Latin_1.LF
then
goto CONTINUE; -- skip
else
goto NEW_LINE;
end if;
when others =>
Last := I;
goto CONTINUE;
end case;
<<NEW_LINE>>
case Version is
when HTML =>
Alt := Line_Break'Access;
when XHTML =>
Alt := Alt_LF'Access;
end case;
<<FLUSH>>
if First <= Last then
Write (Item (First .. Last), Params);
end if;
Write (Alt.all, Params);
First := I + 1;
goto CONTINUE;
<<CONTINUE>>
I := I + 1;
end loop;
if First <= Last then
Write (Item (First .. Last), Params);
end if;
end Write_In_Attribute_Internal;
Alt_Sp : aliased constant String := " ";
Alt_Amp : aliased constant String := "&";
Alt_LT : aliased constant String := "<";
Alt_GT : aliased constant String := ">";
Alt_BRO : aliased constant String := "<br>";
Alt_BRS : aliased constant String := "<br />";
procedure Write_In_HTML_Internal (
Version : in HTML_Version;
Item : in String;
Pre : in Boolean;
Params : in System.Address;
Write : not null access procedure (
Item : in String;
Params : in System.Address))
is
Alt : access constant String;
First : Positive := Item'First;
Last : Natural := First - 1;
In_Spaces : Boolean := True;
Previous_In_Spaces : Boolean;
I : Positive := Item'First;
begin
while I <= Item'Last loop
Previous_In_Spaces := In_Spaces;
In_Spaces := False;
case Item (I) is
when ' ' =>
if not Pre
and then (
Previous_In_Spaces or else (I < Item'Last and then Item (I + 1) = ' '))
then
In_Spaces := True;
Alt := Alt_Sp'Access;
goto FLUSH;
else
Last := I;
goto CONTINUE;
end if;
when '&' =>
Alt := Alt_Amp'Access;
goto FLUSH;
when '<' =>
Alt := Alt_LT'Access;
goto FLUSH;
when '>' =>
Alt := Alt_GT'Access;
goto FLUSH;
when Ada.Characters.Latin_1.LF =>
goto NEW_LINE;
when Ada.Characters.Latin_1.CR =>
if I < Item'Last and then Item (I + 1) = Ada.Characters.Latin_1.LF then
goto CONTINUE; -- skip
else
goto NEW_LINE;
end if;
when others =>
Last := I;
goto CONTINUE;
end case;
<<NEW_LINE>>
if Pre then
Alt := Line_Break'Access;
else
case Version is
when HTML =>
Alt := Alt_BRO'Access;
when XHTML =>
Alt := Alt_BRS'Access;
end case;
end if;
<<FLUSH>>
if First <= Last then
Write (Item (First .. Last), Params);
end if;
Write (Alt.all, Params);
First := I + 1;
goto CONTINUE;
<<CONTINUE>>
I := I + 1;
end loop;
if First <= Last then
Write (Item (First .. Last), Params);
end if;
end Write_In_HTML_Internal;
procedure Write_Query_In_Attribute_Internal (
Version : in HTML_Version;
Item : in Query_Strings;
Params : in System.Address;
Write : not null access procedure (
Item : in String;
Params : in System.Address)) is
begin
if not Item.Is_Empty then
declare
First : constant String_Maps.Cursor := Item.First;
Position : String_Maps.Cursor := First;
begin
while String_Maps.Has_Element (Position) loop
if Position = First then
Write ("?", Params);
else
Write ("&", Params);
end if;
Write_In_Attribute_Internal (Version, String_Maps.Key (Position), Params,
Write => Write);
Write ("=", Params);
Write_In_Attribute_Internal (Version, String_Maps.Element (Position), Params,
Write => Write);
String_Maps.Next (Position);
end loop;
end;
end if;
end Write_Query_In_Attribute_Internal;
procedure Write_Query_In_HTML_Internal (
Version : in HTML_Version;
Item : in Query_Strings;
Params : in System.Address;
Write : not null access procedure (
Item : in String;
Params : in System.Address))
is
Position : String_Maps.Cursor := Item.First;
begin
while String_Maps.Has_Element (Position) loop
Write ("<input type=""hidden"" name=""", Params);
Write_In_Attribute_Internal (Version, String_Maps.Key (Position), Params,
Write => Write);
Write (""" value=""", Params);
Write_In_Attribute_Internal (Version, String_Maps.Element (Position), Params,
Write => Write);
case Version is
when HTML =>
Write (""">", Params);
when XHTML =>
Write (""" />", Params);
end case;
String_Maps.Next (Position);
end loop;
end Write_Query_In_HTML_Internal;
Begin_Attribute : constant String := "=""";
End_Attribute : constant String := """";
-- implementation of input
function Checkbox_Value (S : String) return Boolean is
begin
return Equal_Case_Insensitive (S, L => "on");
end Checkbox_Value;
-- implementation of output
procedure Generic_Write_In_HTML (
Item : in String;
Pre : in Boolean := False)
is
procedure By_Callback (Item : in String; Params : in System.Address) is
pragma Unreferenced (Params);
begin
Write (Item);
end By_Callback;
begin
Write_In_HTML_Internal (Version, Item, Pre, System.Null_Address,
Write => By_Callback'Access);
end Generic_Write_In_HTML;
procedure Write_In_HTML (
Stream : not null access Ada.Streams.Root_Stream_Type'Class;
Version : in HTML_Version;
Item : in String;
Pre : in Boolean := False)
is
function To_Address (Value : access Ada.Streams.Root_Stream_Type'Class)
return System.Address
with Import, Convention => Intrinsic;
begin
Write_In_HTML_Internal (Version, Item, Pre, To_Address (Stream),
Write => By_Stream'Access);
end Write_In_HTML;
procedure Generic_Write_Begin_Attribute (Name : in String) is
begin
Write (Name);
Write (Begin_Attribute);
end Generic_Write_Begin_Attribute;
procedure Write_Begin_Attribute (
Stream : not null access Ada.Streams.Root_Stream_Type'Class;
Name : in String) is
begin
String'Write (Stream, Name);
String'Write (Stream, Begin_Attribute);
end Write_Begin_Attribute;
procedure Generic_Write_In_Attribute (Item : in String) is
procedure By_Callback (Item : in String; Params : in System.Address) is
pragma Unreferenced (Params);
begin
Write (Item);
end By_Callback;
begin
Write_In_Attribute_Internal (Version, Item, System.Null_Address,
Write => By_Callback'Access);
end Generic_Write_In_Attribute;
procedure Write_In_Attribute (
Stream : not null access Ada.Streams.Root_Stream_Type'Class;
Version : in HTML_Version;
Item : in String)
is
function To_Address (Value : access Ada.Streams.Root_Stream_Type'Class)
return System.Address
with Import, Convention => Intrinsic;
begin
Write_In_Attribute_Internal (Version, Item, To_Address (Stream),
Write => By_Stream'Access);
end Write_In_Attribute;
procedure Generic_Write_End_Attribute is
begin
Write (End_Attribute);
end Generic_Write_End_Attribute;
procedure Write_End_Attribute (
Stream : not null access Ada.Streams.Root_Stream_Type'Class) is
begin
String'Write (Stream, End_Attribute);
end Write_End_Attribute;
procedure Generic_Write_Query_In_HTML (Item : in Query_Strings) is
procedure By_Callback (Item : in String; Params : in System.Address) is
pragma Unreferenced (Params);
begin
Write (Item);
end By_Callback;
begin
Write_Query_In_HTML_Internal (Version, Item, System.Null_Address,
Write => By_Callback'Access);
end Generic_Write_Query_In_HTML;
procedure Write_Query_In_HTML (
Stream : not null access Ada.Streams.Root_Stream_Type'Class;
Version : in HTML_Version;
Item : in Query_Strings)
is
function To_Address (Value : access Ada.Streams.Root_Stream_Type'Class)
return System.Address
with Import, Convention => Intrinsic;
begin
Write_Query_In_HTML_Internal (Version, Item, To_Address (Stream),
Write => By_Stream'Access);
end Write_Query_In_HTML;
procedure Generic_Write_Query_In_Attribute (Item : in Query_Strings) is
procedure By_Callback (Item : in String; Params : in System.Address) is
pragma Unreferenced (Params);
begin
Write (Item);
end By_Callback;
begin
Write_Query_In_Attribute_Internal (Version, Item, System.Null_Address,
Write => By_Callback'Access);
end Generic_Write_Query_In_Attribute;
procedure Write_Query_In_Attribute (
Stream : not null access Ada.Streams.Root_Stream_Type'Class;
Version : in HTML_Version;
Item : in Query_Strings)
is
function To_Address (Value : access Ada.Streams.Root_Stream_Type'Class)
return System.Address
with Import, Convention => Intrinsic;
begin
Write_Query_In_Attribute_Internal (Version, Item, To_Address (Stream),
Write => By_Stream'Access);
end Write_Query_In_Attribute;
end Web.HTML;
|
iyan22/AprendeAda | Ada | 1,120 | adb |
with Matriz, Ada.Text_IO, matriz_toeplitz, escribir_matriz;
use Matriz, Ada.Text_IO;
procedure prueba_matriz_toeplitz is
V : Vector_De_Enteros (1..6);
M : Matriz_de_Enteros(1..6,1..6);
begin
V := (1,2,3,4,5,6);
-- prueba 1:
put_line("El vector es (1,2,3,4,5,6)");
put_line("El resultado tiene que ser:");
put_line("(1 2 3 4 5 6)");
put_line("(6 1 2 3 4 5)");
put_line("(5 6 1 2 3 4)");
put_line("(4 5 6 1 2 3)");
put_line("(3 4 5 6 1 2)");
put_line("(2 3 4 5 6 1)");
Matriz_Toeplitz(V,M);
put_line("y vuestro programa dice que:");
escribir_matriz(M);
put_line("Pulsa enter");
skip_line;
V := (1,0,0,0,0,0);
-- prueba 2:
put_line("El vector es (1,0,0,0,0,0)");
put_line("El resultado tiene que ser:");
put_line("(1 0 0 0 0 0)");
put_line("(0 1 0 0 0 0)");
put_line("(0 0 1 0 0 0)");
put_line("(0 0 0 1 0 0)");
put_line("(0 0 0 0 1 0)");
put_line("(0 0 0 0 0 1)");
Matriz_Toeplitz(V,M);
put_line("y vuestro programa dice que:");
escribir_matriz(M);
put_line("Pulsa enter");
skip_line;
end prueba_matriz_toeplitz;
|
jhumphry/aLua | Ada | 423 | ads | -- Example_Adafunctions
-- A example of using the Ada 2012 interface to Lua for functions / closures etc
-- Copyright (c) 2015, James Humphry - see LICENSE for terms
with Lua; use Lua;
package Example_AdaFunctions is
function FooBar (L : Lua_State'Class) return Natural;
function Multret (L : Lua_State'Class) return Natural;
function Closure (L : Lua_State'Class) return Natural;
end Example_AdaFunctions;
|
reznikmm/matreshka | Ada | 9,911 | 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.Visitors.CMOF_Iterators;
with AMF.Visitors.CMOF_Visitors;
package body AMF.Internals.CMOF_Expressions is
-------------------
-- Enter_Element --
-------------------
overriding procedure Enter_Element
(Self : not null access constant CMOF_Expression_Proxy;
Visitor : in out AMF.Visitors.Abstract_Visitor'Class;
Control : in out AMF.Visitors.Traverse_Control) is
begin
if Visitor in AMF.Visitors.CMOF_Visitors.CMOF_Visitor'Class then
AMF.Visitors.CMOF_Visitors.CMOF_Visitor'Class
(Visitor).Enter_Expression
(AMF.CMOF.Expressions.CMOF_Expression_Access (Self),
Control);
end if;
end Enter_Element;
-------------------
-- Leave_Element --
-------------------
overriding procedure Leave_Element
(Self : not null access constant CMOF_Expression_Proxy;
Visitor : in out AMF.Visitors.Abstract_Visitor'Class;
Control : in out AMF.Visitors.Traverse_Control) is
begin
if Visitor in AMF.Visitors.CMOF_Visitors.CMOF_Visitor'Class then
AMF.Visitors.CMOF_Visitors.CMOF_Visitor'Class
(Visitor).Leave_Expression
(AMF.CMOF.Expressions.CMOF_Expression_Access (Self),
Control);
end if;
end Leave_Element;
-------------------
-- Visit_Element --
-------------------
overriding procedure Visit_Element
(Self : not null access constant CMOF_Expression_Proxy;
Iterator : in out AMF.Visitors.Abstract_Iterator'Class;
Visitor : in out AMF.Visitors.Abstract_Visitor'Class;
Control : in out AMF.Visitors.Traverse_Control) is
begin
if Iterator in AMF.Visitors.CMOF_Iterators.CMOF_Iterator'Class then
AMF.Visitors.CMOF_Iterators.CMOF_Iterator'Class
(Iterator).Visit_Expression
(Visitor,
AMF.CMOF.Expressions.CMOF_Expression_Access (Self),
Control);
end if;
end Visit_Element;
------------------------
-- All_Owned_Elements --
------------------------
overriding function All_Owned_Elements
(Self : not null access constant CMOF_Expression_Proxy)
return AMF.CMOF.Elements.Collections.Set_Of_CMOF_Element
is
begin
-- Generated stub: replace with real body!
pragma Compile_Time_Warning (Standard.True, "All_Owned_Elements unimplemented");
raise Program_Error;
return All_Owned_Elements (Self);
end All_Owned_Elements;
------------------------
-- Get_Qualified_Name --
------------------------
overriding function Get_Qualified_Name
(Self : not null access constant CMOF_Expression_Proxy)
return Optional_String
is
begin
-- Generated stub: replace with real body!
pragma Compile_Time_Warning (Standard.True, "Get_Qualified_Name unimplemented");
raise Program_Error;
return Get_Qualified_Name (Self);
end Get_Qualified_Name;
-----------------------------
-- Is_Distinguishable_From --
-----------------------------
overriding function Is_Distinguishable_From
(Self : not null access constant CMOF_Expression_Proxy;
N : AMF.CMOF.Named_Elements.CMOF_Named_Element_Access;
Ns : AMF.CMOF.Namespaces.CMOF_Namespace_Access)
return Boolean
is
begin
-- Generated stub: replace with real body!
pragma Compile_Time_Warning (Standard.True, "Is_Distinguishable_From unimplemented");
raise Program_Error;
return Is_Distinguishable_From (Self, N, Ns);
end Is_Distinguishable_From;
-------------------
-- Is_Computable --
-------------------
overriding function Is_Computable
(Self : not null access constant CMOF_Expression_Proxy)
return Boolean
is
begin
-- Generated stub: replace with real body!
pragma Compile_Time_Warning (Standard.True, "Is_Computable unimplemented");
raise Program_Error;
return Is_Computable (Self);
end Is_Computable;
-------------------
-- Integer_Value --
-------------------
overriding function Integer_Value
(Self : not null access constant CMOF_Expression_Proxy)
return Integer
is
begin
-- Generated stub: replace with real body!
pragma Compile_Time_Warning (Standard.True, "Integer_Value unimplemented");
raise Program_Error;
return Integer_Value (Self);
end Integer_Value;
-------------------
-- Boolean_Value --
-------------------
overriding function Boolean_Value
(Self : not null access constant CMOF_Expression_Proxy)
return Boolean
is
begin
-- Generated stub: replace with real body!
pragma Compile_Time_Warning (Standard.True, "Boolean_Value unimplemented");
raise Program_Error;
return Boolean_Value (Self);
end Boolean_Value;
------------------
-- String_Value --
------------------
overriding function String_Value
(Self : not null access constant CMOF_Expression_Proxy)
return League.Strings.Universal_String
is
begin
-- Generated stub: replace with real body!
pragma Compile_Time_Warning (Standard.True, "String_Value unimplemented");
raise Program_Error;
return String_Value (Self);
end String_Value;
---------------------
-- Unlimited_Value --
---------------------
overriding function Unlimited_Value
(Self : not null access constant CMOF_Expression_Proxy)
return Unlimited_Natural
is
begin
-- Generated stub: replace with real body!
pragma Compile_Time_Warning (Standard.True, "Unlimited_Value unimplemented");
raise Program_Error;
return Unlimited_Value (Self);
end Unlimited_Value;
-------------
-- Is_Null --
-------------
overriding function Is_Null
(Self : not null access constant CMOF_Expression_Proxy)
return Boolean
is
begin
-- Generated stub: replace with real body!
pragma Compile_Time_Warning (Standard.True, "Is_Null unimplemented");
raise Program_Error;
return Is_Null (Self);
end Is_Null;
-----------------
-- Get_Operand --
-----------------
overriding function Get_Operand
(Self : not null access constant CMOF_Expression_Proxy)
return AMF.CMOF.Value_Specifications.Collections.Ordered_Set_Of_CMOF_Value_Specification
is
begin
-- Generated stub: replace with real body!
pragma Compile_Time_Warning (Standard.True, "Get_Operand unimplemented");
raise Program_Error;
return Get_Operand (Self);
end Get_Operand;
end AMF.Internals.CMOF_Expressions;
|
riccardo-bernardini/eugen | Ada | 1,852 | adb | pragma Ada_2012;
with Ada.Containers.Indefinite_Ordered_Maps;
with Project_Processor.Parsers.Abstract_Parsers;
package body Project_Processor.Parsers is
package Extension_Maps is
new Ada.Containers.Indefinite_Ordered_Maps (Key_Type => string,
Element_Type => Parser_ID);
Extension_To_Parser : Extension_Maps.Map;
-------------------
-- Parse_Project --
-------------------
function Parse_Project
(Input : String;
Format : Parser_ID;
Parameters : Parser_Parameter_access)
return EU_Projects.Projects.Project_Descriptor
is
use Abstract_Parsers;
Parser : Abstract_Parser'Class := Get_Parser (Format, Parameters);
begin
return Project : EU_Projects.Projects.Project_Descriptor do
Parser.Parse (Project, Input);
end return;
end Parse_Project;
-----------------
-- Find_Parser --
-----------------
function Find_Parser (File_Extension : String) return Parser_ID
is
use Extension_Maps;
Pos : constant Cursor := Extension_To_Parser.Find (File_Extension);
begin
if Pos = No_Element then
return No_Parser;
else
return Extension_To_Parser (Pos);
end if;
end Find_Parser;
------------------------
-- Register_Extension --
------------------------
procedure Register_Extension (Parser : Parser_ID;
File_Extension : String)
is
begin
if Extension_To_Parser.Contains (File_Extension) then
raise Constraint_Error with "Extension '" & File_Extension & "' already known";
end if;
Extension_To_Parser.Include (Key => File_Extension,
New_Item => Parser);
end Register_Extension;
end Project_Processor.Parsers;
|
reznikmm/matreshka | Ada | 10,106 | ads | ------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- XML Processor --
-- --
-- Runtime Library Component --
-- --
------------------------------------------------------------------------------
-- --
-- Copyright © 2010, Vadim Godunko <[email protected]> --
-- All rights reserved. --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions --
-- are met: --
-- --
-- * Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- --
-- * Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in the --
-- documentation and/or other materials provided with the distribution. --
-- --
-- * Neither the name of the Vadim Godunko, IE nor the names of its --
-- contributors may be used to endorse or promote products derived from --
-- this software without specific prior written permission. --
-- --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR --
-- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
-- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED --
-- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR --
-- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF --
-- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING --
-- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS --
-- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
-- --
------------------------------------------------------------------------------
-- $Revision$ $Date$
------------------------------------------------------------------------------
with League.Strings;
with Matreshka.StAX.Attributes;
with Matreshka.StAX.Entity_Declarations;
with Matreshka.StAX.Namespace_Declarations;
with Matreshka.StAX.Notation_Declarations;
package Matreshka.StAX.Readers is
pragma Preelaborate;
type StAX_Tokens is
(No_Token,
Invalid,
Start_Document,
End_Document,
Start_Element,
End_Element,
Characters,
Comment,
DTD,
Entity_Reference,
Processing_Instruction);
type StAX_Reader is limited interface;
not overriding procedure Add_External_Namespace_Declaration
(Self : not null access constant StAX_Reader;
Namespace :
Matreshka.StAX.Namespace_Declarations.StAX_Namespace_Declaration)
is abstract;
not overriding procedure Add_External_Namespace_Declarations
(Self : not null access StAX_Reader;
Namespaces :
Matreshka.StAX.Namespace_Declarations.StAX_Namespace_Declarations)
is abstract;
not overriding function At_End
(Self : not null access constant StAX_Reader) return Boolean is abstract;
not overriding function Attributes
(Self : not null access constant StAX_Reader)
return Matreshka.StAX.Attributes.StAX_Attributes is abstract;
not overriding function Document_Encoding
(Self : not null access constant StAX_Reader)
return League.Strings.Universal_Slice is abstract;
not overriding function Document_Version
(Self : not null access constant StAX_Reader)
return League.Strings.Universal_Slice is abstract;
not overriding function DTD_Name
(Self : not null access constant StAX_Reader)
return League.Strings.Universal_Slice is abstract;
not overriding function DTD_Public_Id
(Self : not null access constant StAX_Reader)
return League.Strings.Universal_Slice is abstract;
not overriding function DTD_System_Id
(Self : not null access constant StAX_Reader)
return League.Strings.Universal_Slice is abstract;
not overriding function Entity_Declarations
(Self : not null access constant StAX_Reader)
return Matreshka.StAX.Entity_Declarations.StAX_Entity_Declarations
is abstract;
not overriding function Error_String
(Self : not null access constant StAX_Reader)
return League.Strings.Universal_Slice is abstract;
not overriding function Has_Error
(Self : not null access constant StAX_Reader) return Boolean is abstract;
not overriding function Is_CDATA
(Self : not null access constant StAX_Reader) return Boolean is abstract;
not overriding function Is_Characters
(Self : not null access constant StAX_Reader) return Boolean is abstract;
not overriding function Is_Comment
(Self : not null access constant StAX_Reader) return Boolean is abstract;
not overriding function Is_DTD
(Self : not null access constant StAX_Reader) return Boolean is abstract;
not overriding function Is_End_Document
(Self : not null access constant StAX_Reader) return Boolean is abstract;
not overriding function Is_End_Element
(Self : not null access constant StAX_Reader) return Boolean is abstract;
not overriding function Is_Entity_Reference
(Self : not null access constant StAX_Reader) return Boolean is abstract;
not overriding function Is_Processing_Instruction
(Self : not null access constant StAX_Reader) return Boolean is abstract;
not overriding function Is_Standalone_Document
(Self : not null access constant StAX_Reader) return Boolean is abstract;
not overriding function Is_Start_Document
(Self : not null access constant StAX_Reader) return Boolean is abstract;
not overriding function Is_Start_Element
(Self : not null access constant StAX_Reader) return Boolean is abstract;
not overriding function Is_Whitespace
(Self : not null access constant StAX_Reader) return Boolean is abstract;
not overriding function Name
(Self : not null access constant StAX_Reader)
return League.Strings.Universal_Slice is abstract;
not overriding function Namespace_Declarations
(Self : not null access constant StAX_Reader)
return Matreshka.StAX.Namespace_Declarations.StAX_Namespace_Declarations
is abstract;
not overriding function Namespace_Processing
(Self : not null access constant StAX_Reader) return Boolean is abstract;
not overriding function Namespace_URI
(Self : not null access constant StAX_Reader)
return League.Strings.Universal_Slice is abstract;
not overriding function Notation_Declarations
(Self : not null access constant StAX_Reader)
return Matreshka.StAX.Notation_Declarations.StAX_Notation_Declarations
is abstract;
not overriding function Prefix
(Self : not null access constant StAX_Reader)
return League.Strings.Universal_Slice is abstract;
not overriding function Processing_Instruction_Data
(Self : not null access constant StAX_Reader)
return League.Strings.Universal_Slice is abstract;
not overriding function Processing_Instruction_Target
(Self : not null access constant StAX_Reader)
return League.Strings.Universal_Slice is abstract;
not overriding function Qualified_Name
(Self : not null access constant StAX_Reader)
return League.Strings.Universal_Slice is abstract;
not overriding procedure Raise_Error
(Self : not null access StAX_Reader;
Error : League.Strings.Universal_Slice) is abstract;
not overriding function Read_Element_Text
(Self : not null access StAX_Reader)
return League.Strings.Universal_String is abstract;
not overriding function Read_Next
(Self : not null access StAX_Reader) return StAX_Tokens is abstract;
not overriding procedure Read_Next
(Self : not null access StAX_Reader) is abstract;
not overriding function Read_Next_Start_Element
(Self : not null access StAX_Reader) return Boolean is abstract;
not overriding procedure Read_Next_Start_Element
(Self : not null access StAX_Reader) is abstract;
not overriding procedure Set_Namespace_Processing
(Self : not null access StAX_Reader;
Enabled : Boolean) is abstract;
not overriding procedure Skip_Current_Element
(Self : not null access StAX_Reader) is abstract;
not overriding function Text
(Self : not null access constant StAX_Reader)
return League.Strings.Universal_Slice is abstract;
not overriding function Token_String
(Self : not null access constant StAX_Reader)
return League.Strings.Universal_String is abstract;
not overriding function Token
(Self : not null access constant StAX_Reader)
return StAX_Tokens is abstract;
end Matreshka.StAX.Readers;
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.