repo_name
stringlengths 9
74
| language
stringclasses 1
value | length_bytes
int64 11
9.34M
| extension
stringclasses 2
values | content
stringlengths 11
9.34M
|
---|---|---|---|---|
stcarrez/ada-ado | Ada | 23,841 | ads | -----------------------------------------------------------------------
-- Regtests.Audits.Model -- Regtests.Audits.Model
-----------------------------------------------------------------------
-- File generated by Dynamo DO NOT MODIFY
-- Template used: templates/model/package-spec.xhtml
-- Ada Generator: https://github.com/stcarrez/dynamo Version 1.4.0
-----------------------------------------------------------------------
-- Copyright (C) 2022 Stephane Carrez
-- Written by Stephane Carrez ([email protected])
--
-- Licensed under the Apache License, Version 2.0 (the "License");
-- you may not use this file except in compliance with the License.
-- You may obtain a copy of the License at
--
-- http://www.apache.org/licenses/LICENSE-2.0
--
-- Unless required by applicable law or agreed to in writing, software
-- distributed under the License is distributed on an "AS IS" BASIS,
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-- See the License for the specific language governing permissions and
-- limitations under the License.
-----------------------------------------------------------------------
pragma Warnings (Off);
with ADO.Sessions;
with ADO.Objects;
with ADO.Statements;
with ADO.SQL;
with ADO.Schemas;
with Ada.Calendar;
with Ada.Containers.Vectors;
with Ada.Strings.Unbounded;
with Util.Beans.Objects;
with Util.Beans.Basic.Lists;
with ADO.Audits;
pragma Warnings (On);
package Regtests.Audits.Model is
pragma Style_Checks ("-mrIu");
type Audit_Ref is new ADO.Objects.Object_Ref with null record;
type Email_Ref is new ADO.Objects.Object_Ref with null record;
type Property_Ref is new ADO.Objects.Object_Ref with null record;
-- --------------------
-- This is the Audit_Info table
-- --------------------
-- Create an object key for Audit.
function Audit_Key (Id : in ADO.Identifier) return ADO.Objects.Object_Key;
-- Create an object key for Audit from a string.
-- Raises Constraint_Error if the string cannot be converted into the object key.
function Audit_Key (Id : in String) return ADO.Objects.Object_Key;
Null_Audit : constant Audit_Ref;
function "=" (Left, Right : Audit_Ref'Class) return Boolean;
-- Set null
procedure Set_Id (Object : in out Audit_Ref;
Value : in ADO.Identifier);
-- Get null
function Get_Id (Object : in Audit_Ref)
return ADO.Identifier;
-- Set the entity id
procedure Set_Entity_Id (Object : in out Audit_Ref;
Value : in ADO.Identifier);
-- Get the entity id
function Get_Entity_Id (Object : in Audit_Ref)
return ADO.Identifier;
-- Set the entity type
procedure Set_Entity_Type (Object : in out Audit_Ref;
Value : in ADO.Entity_Type);
-- Get the entity type
function Get_Entity_Type (Object : in Audit_Ref)
return ADO.Entity_Type;
-- Set the old value
procedure Set_Old_Value (Object : in out Audit_Ref;
Value : in ADO.Nullable_String);
procedure Set_Old_Value (Object : in out Audit_Ref;
Value : in String);
-- Get the old value
function Get_Old_Value (Object : in Audit_Ref)
return ADO.Nullable_String;
function Get_Old_Value (Object : in Audit_Ref)
return String;
-- Set the new value
procedure Set_New_Value (Object : in out Audit_Ref;
Value : in ADO.Nullable_String);
procedure Set_New_Value (Object : in out Audit_Ref;
Value : in String);
-- Get the new value
function Get_New_Value (Object : in Audit_Ref)
return ADO.Nullable_String;
function Get_New_Value (Object : in Audit_Ref)
return String;
-- Set the audit date
procedure Set_Date (Object : in out Audit_Ref;
Value : in Ada.Calendar.Time);
-- Get the audit date
function Get_Date (Object : in Audit_Ref)
return Ada.Calendar.Time;
-- Load the entity identified by 'Id'.
-- Raises the NOT_FOUND exception if it does not exist.
procedure Load (Object : in out Audit_Ref;
Session : in out ADO.Sessions.Session'Class;
Id : in ADO.Identifier);
-- Load the entity identified by 'Id'.
-- Returns True in <b>Found</b> if the object was found and False if it does not exist.
procedure Load (Object : in out Audit_Ref;
Session : in out ADO.Sessions.Session'Class;
Id : in ADO.Identifier;
Found : out Boolean);
-- Find and load the entity.
overriding
procedure Find (Object : in out Audit_Ref;
Session : in out ADO.Sessions.Session'Class;
Query : in ADO.SQL.Query'Class;
Found : out Boolean);
-- Save the entity. If the entity does not have an identifier, an identifier is allocated
-- and it is inserted in the table. Otherwise, only data fields which have been changed
-- are updated.
overriding
procedure Save (Object : in out Audit_Ref;
Session : in out ADO.Sessions.Master_Session'Class);
-- Delete the entity.
overriding
procedure Delete (Object : in out Audit_Ref;
Session : in out ADO.Sessions.Master_Session'Class);
overriding
function Get_Value (From : in Audit_Ref;
Name : in String) return Util.Beans.Objects.Object;
-- Table definition
AUDIT_TABLE : constant ADO.Schemas.Class_Mapping_Access;
-- Internal method to allocate the Object_Record instance
overriding
procedure Allocate (Object : in out Audit_Ref);
-- Copy of the object.
procedure Copy (Object : in Audit_Ref;
Into : in out Audit_Ref);
package Audit_Vectors is
new Ada.Containers.Vectors (Index_Type => Positive,
Element_Type => Audit_Ref,
"=" => "=");
subtype Audit_Vector is Audit_Vectors.Vector;
procedure List (Object : in out Audit_Vector;
Session : in out ADO.Sessions.Session'Class;
Query : in ADO.SQL.Query'Class);
-- --------------------
-- This is the User email table
-- --------------------
-- Create an object key for Email.
function Email_Key (Id : in ADO.Identifier) return ADO.Objects.Object_Key;
-- Create an object key for Email from a string.
-- Raises Constraint_Error if the string cannot be converted into the object key.
function Email_Key (Id : in String) return ADO.Objects.Object_Key;
Null_Email : constant Email_Ref;
function "=" (Left, Right : Email_Ref'Class) return Boolean;
-- Set null
procedure Set_Id (Object : in out Email_Ref;
Value : in ADO.Identifier);
-- Get null
function Get_Id (Object : in Email_Ref)
return ADO.Identifier;
-- Set the user email address
procedure Set_Email (Object : in out Email_Ref;
Value : in ADO.Nullable_String);
procedure Set_Email (Object : in out Email_Ref;
Value : in String);
-- Get the user email address
function Get_Email (Object : in Email_Ref)
return ADO.Nullable_String;
function Get_Email (Object : in Email_Ref)
return String;
-- Set the user email status
procedure Set_Status (Object : in out Email_Ref;
Value : in ADO.Nullable_Integer);
-- Get the user email status
function Get_Status (Object : in Email_Ref)
return ADO.Nullable_Integer;
-- Set the email date
procedure Set_Date (Object : in out Email_Ref;
Value : in ADO.Nullable_Time);
-- Get the email date
function Get_Date (Object : in Email_Ref)
return ADO.Nullable_Time;
-- Set the email creation date
procedure Set_Create_Date (Object : in out Email_Ref;
Value : in Ada.Calendar.Time);
-- Get the email creation date
function Get_Create_Date (Object : in Email_Ref)
return Ada.Calendar.Time;
-- Set the email info
procedure Set_Info (Object : in out Email_Ref;
Value : in Ada.Strings.Unbounded.Unbounded_String);
procedure Set_Info (Object : in out Email_Ref;
Value : in String);
-- Get the email info
function Get_Info (Object : in Email_Ref)
return Ada.Strings.Unbounded.Unbounded_String;
function Get_Info (Object : in Email_Ref)
return String;
-- Load the entity identified by 'Id'.
-- Raises the NOT_FOUND exception if it does not exist.
procedure Load (Object : in out Email_Ref;
Session : in out ADO.Sessions.Session'Class;
Id : in ADO.Identifier);
-- Load the entity identified by 'Id'.
-- Returns True in <b>Found</b> if the object was found and False if it does not exist.
procedure Load (Object : in out Email_Ref;
Session : in out ADO.Sessions.Session'Class;
Id : in ADO.Identifier;
Found : out Boolean);
-- Find and load the entity.
overriding
procedure Find (Object : in out Email_Ref;
Session : in out ADO.Sessions.Session'Class;
Query : in ADO.SQL.Query'Class;
Found : out Boolean);
-- Save the entity. If the entity does not have an identifier, an identifier is allocated
-- and it is inserted in the table. Otherwise, only data fields which have been changed
-- are updated.
overriding
procedure Save (Object : in out Email_Ref;
Session : in out ADO.Sessions.Master_Session'Class);
-- Delete the entity.
overriding
procedure Delete (Object : in out Email_Ref;
Session : in out ADO.Sessions.Master_Session'Class);
overriding
function Get_Value (From : in Email_Ref;
Name : in String) return Util.Beans.Objects.Object;
-- Table definition
EMAIL_TABLE : constant ADO.Schemas.Class_Mapping_Access;
-- Internal method to allocate the Object_Record instance
overriding
procedure Allocate (Object : in out Email_Ref);
-- Copy of the object.
procedure Copy (Object : in Email_Ref;
Into : in out Email_Ref);
-- --------------------
-- This is a generic property
-- --------------------
-- Create an object key for Property.
function Property_Key (Id : in ADO.Identifier) return ADO.Objects.Object_Key;
-- Create an object key for Property from a string.
-- Raises Constraint_Error if the string cannot be converted into the object key.
function Property_Key (Id : in String) return ADO.Objects.Object_Key;
Null_Property : constant Property_Ref;
function "=" (Left, Right : Property_Ref'Class) return Boolean;
-- Set null
procedure Set_Id (Object : in out Property_Ref;
Value : in Ada.Strings.Unbounded.Unbounded_String);
procedure Set_Id (Object : in out Property_Ref;
Value : in String);
-- Get null
function Get_Id (Object : in Property_Ref)
return Ada.Strings.Unbounded.Unbounded_String;
function Get_Id (Object : in Property_Ref)
return String;
-- Set the property value
procedure Set_Value (Object : in out Property_Ref;
Value : in ADO.Nullable_Integer);
-- Get the property value
function Get_Value (Object : in Property_Ref)
return ADO.Nullable_Integer;
-- Set a float property value
procedure Set_Float_Value (Object : in out Property_Ref;
Value : in Float);
-- Get a float property value
function Get_Float_Value (Object : in Property_Ref)
return Float;
-- Set a double property value
procedure Set_Double_Value (Object : in out Property_Ref;
Value : in Long_Float);
-- Get a double property value
function Get_Double_Value (Object : in Property_Ref)
return Long_Float;
-- Set the property entity type
procedure Set_Kind (Object : in out Property_Ref;
Value : in ADO.Entity_Type);
-- Get the property entity type
function Get_Kind (Object : in Property_Ref)
return ADO.Entity_Type;
-- Set the optional property entity type
procedure Set_Optional_Kind (Object : in out Property_Ref;
Value : in ADO.Nullable_Entity_Type);
-- Get the optional property entity type
function Get_Optional_Kind (Object : in Property_Ref)
return ADO.Nullable_Entity_Type;
-- Set the optional object_id
procedure Set_Object_Id (Object : in out Property_Ref;
Value : in ADO.Identifier);
-- Get the optional object_id
function Get_Object_Id (Object : in Property_Ref)
return ADO.Identifier;
-- Load the entity identified by 'Id'.
-- Raises the NOT_FOUND exception if it does not exist.
procedure Load (Object : in out Property_Ref;
Session : in out ADO.Sessions.Session'Class;
Id : in Ada.Strings.Unbounded.Unbounded_String);
-- Load the entity identified by 'Id'.
-- Returns True in <b>Found</b> if the object was found and False if it does not exist.
procedure Load (Object : in out Property_Ref;
Session : in out ADO.Sessions.Session'Class;
Id : in Ada.Strings.Unbounded.Unbounded_String;
Found : out Boolean);
-- Find and load the entity.
overriding
procedure Find (Object : in out Property_Ref;
Session : in out ADO.Sessions.Session'Class;
Query : in ADO.SQL.Query'Class;
Found : out Boolean);
-- Save the entity. If the entity does not have an identifier, an identifier is allocated
-- and it is inserted in the table. Otherwise, only data fields which have been changed
-- are updated.
overriding
procedure Save (Object : in out Property_Ref;
Session : in out ADO.Sessions.Master_Session'Class);
-- Delete the entity.
overriding
procedure Delete (Object : in out Property_Ref;
Session : in out ADO.Sessions.Master_Session'Class);
overriding
function Get_Value (From : in Property_Ref;
Name : in String) return Util.Beans.Objects.Object;
-- Table definition
PROPERTY_TABLE : constant ADO.Schemas.Class_Mapping_Access;
-- Internal method to allocate the Object_Record instance
overriding
procedure Allocate (Object : in out Property_Ref);
-- Copy of the object.
procedure Copy (Object : in Property_Ref;
Into : in out Property_Ref);
private
AUDIT_NAME : aliased constant String := "audit_info";
COL_0_1_NAME : aliased constant String := "id";
COL_1_1_NAME : aliased constant String := "entity_id";
COL_2_1_NAME : aliased constant String := "entity_type";
COL_3_1_NAME : aliased constant String := "old_value";
COL_4_1_NAME : aliased constant String := "new_value";
COL_5_1_NAME : aliased constant String := "date";
AUDIT_DEF : aliased constant ADO.Schemas.Class_Mapping :=
(Count => 6,
Table => AUDIT_NAME'Access,
Members => (
1 => COL_0_1_NAME'Access,
2 => COL_1_1_NAME'Access,
3 => COL_2_1_NAME'Access,
4 => COL_3_1_NAME'Access,
5 => COL_4_1_NAME'Access,
6 => COL_5_1_NAME'Access)
);
AUDIT_TABLE : constant ADO.Schemas.Class_Mapping_Access
:= AUDIT_DEF'Access;
Null_Audit : constant Audit_Ref
:= Audit_Ref'(ADO.Objects.Object_Ref with null record);
type Audit_Impl is
new ADO.Objects.Object_Record (Key_Type => ADO.Objects.KEY_INTEGER,
Of_Class => AUDIT_DEF'Access)
with record
Entity_Id : ADO.Identifier;
Entity_Type : ADO.Entity_Type;
Old_Value : ADO.Nullable_String;
New_Value : ADO.Nullable_String;
Date : Ada.Calendar.Time;
end record;
type Audit_Access is access all Audit_Impl;
overriding
procedure Destroy (Object : access Audit_Impl);
overriding
procedure Find (Object : in out Audit_Impl;
Session : in out ADO.Sessions.Session'Class;
Query : in ADO.SQL.Query'Class;
Found : out Boolean);
overriding
procedure Load (Object : in out Audit_Impl;
Session : in out ADO.Sessions.Session'Class);
procedure Load (Object : in out Audit_Impl;
Stmt : in out ADO.Statements.Query_Statement'Class;
Session : in out ADO.Sessions.Session'Class);
overriding
procedure Save (Object : in out Audit_Impl;
Session : in out ADO.Sessions.Master_Session'Class);
overriding
procedure Create (Object : in out Audit_Impl;
Session : in out ADO.Sessions.Master_Session'Class);
overriding
procedure Delete (Object : in out Audit_Impl;
Session : in out ADO.Sessions.Master_Session'Class);
procedure Set_Field (Object : in out Audit_Ref'Class;
Impl : out Audit_Access);
EMAIL_NAME : aliased constant String := "audit_email";
COL_0_2_NAME : aliased constant String := "id";
COL_1_2_NAME : aliased constant String := "user_email";
COL_2_2_NAME : aliased constant String := "email_status";
COL_3_2_NAME : aliased constant String := "email_date";
COL_4_2_NAME : aliased constant String := "email_create_date";
COL_5_2_NAME : aliased constant String := "email_info";
EMAIL_DEF : aliased constant ADO.Schemas.Class_Mapping :=
(Count => 6,
Table => EMAIL_NAME'Access,
Members => (
1 => COL_0_2_NAME'Access,
2 => COL_1_2_NAME'Access,
3 => COL_2_2_NAME'Access,
4 => COL_3_2_NAME'Access,
5 => COL_4_2_NAME'Access,
6 => COL_5_2_NAME'Access)
);
EMAIL_TABLE : constant ADO.Schemas.Class_Mapping_Access
:= EMAIL_DEF'Access;
EMAIL_AUDIT_DEF : aliased constant ADO.Audits.Auditable_Mapping :=
(Count => 5,
Of_Class => EMAIL_DEF'Access,
Members => (
1 => 1,
2 => 2,
3 => 3,
4 => 4,
5 => 5)
);
EMAIL_AUDIT_TABLE : constant ADO.Audits.Auditable_Mapping_Access
:= EMAIL_AUDIT_DEF'Access;
Null_Email : constant Email_Ref
:= Email_Ref'(ADO.Objects.Object_Ref with null record);
type Email_Impl is
new ADO.Audits.Auditable_Object_Record (Key_Type => ADO.Objects.KEY_INTEGER,
Of_Class => EMAIL_DEF'Access,
With_Audit => EMAIL_AUDIT_DEF'Access)
with record
Email : ADO.Nullable_String;
Status : ADO.Nullable_Integer;
Date : ADO.Nullable_Time;
Create_Date : Ada.Calendar.Time;
Info : Ada.Strings.Unbounded.Unbounded_String;
end record;
type Email_Access is access all Email_Impl;
overriding
procedure Destroy (Object : access Email_Impl);
overriding
procedure Find (Object : in out Email_Impl;
Session : in out ADO.Sessions.Session'Class;
Query : in ADO.SQL.Query'Class;
Found : out Boolean);
overriding
procedure Load (Object : in out Email_Impl;
Session : in out ADO.Sessions.Session'Class);
procedure Load (Object : in out Email_Impl;
Stmt : in out ADO.Statements.Query_Statement'Class;
Session : in out ADO.Sessions.Session'Class);
overriding
procedure Save (Object : in out Email_Impl;
Session : in out ADO.Sessions.Master_Session'Class);
overriding
procedure Create (Object : in out Email_Impl;
Session : in out ADO.Sessions.Master_Session'Class);
overriding
procedure Delete (Object : in out Email_Impl;
Session : in out ADO.Sessions.Master_Session'Class);
procedure Set_Field (Object : in out Email_Ref'Class;
Impl : out Email_Access);
PROPERTY_NAME : aliased constant String := "audit_property";
COL_0_3_NAME : aliased constant String := "id";
COL_1_3_NAME : aliased constant String := "user_email";
COL_2_3_NAME : aliased constant String := "float_value";
COL_3_3_NAME : aliased constant String := "double_value";
COL_4_3_NAME : aliased constant String := "kind";
COL_5_3_NAME : aliased constant String := "optional_kind";
COL_6_3_NAME : aliased constant String := "object_id";
PROPERTY_DEF : aliased constant ADO.Schemas.Class_Mapping :=
(Count => 7,
Table => PROPERTY_NAME'Access,
Members => (
1 => COL_0_3_NAME'Access,
2 => COL_1_3_NAME'Access,
3 => COL_2_3_NAME'Access,
4 => COL_3_3_NAME'Access,
5 => COL_4_3_NAME'Access,
6 => COL_5_3_NAME'Access,
7 => COL_6_3_NAME'Access)
);
PROPERTY_TABLE : constant ADO.Schemas.Class_Mapping_Access
:= PROPERTY_DEF'Access;
PROPERTY_AUDIT_DEF : aliased constant ADO.Audits.Auditable_Mapping :=
(Count => 6,
Of_Class => PROPERTY_DEF'Access,
Members => (
1 => 1,
2 => 2,
3 => 3,
4 => 4,
5 => 5,
6 => 6)
);
PROPERTY_AUDIT_TABLE : constant ADO.Audits.Auditable_Mapping_Access
:= PROPERTY_AUDIT_DEF'Access;
Null_Property : constant Property_Ref
:= Property_Ref'(ADO.Objects.Object_Ref with null record);
type Property_Impl is
new ADO.Audits.Auditable_Object_Record (Key_Type => ADO.Objects.KEY_STRING,
Of_Class => PROPERTY_DEF'Access,
With_Audit => PROPERTY_AUDIT_DEF'Access)
with record
Value : ADO.Nullable_Integer;
Float_Value : Float;
Double_Value : Long_Float;
Kind : ADO.Entity_Type;
Optional_Kind : ADO.Nullable_Entity_Type;
Object_Id : ADO.Identifier;
end record;
type Property_Access is access all Property_Impl;
overriding
procedure Destroy (Object : access Property_Impl);
overriding
procedure Find (Object : in out Property_Impl;
Session : in out ADO.Sessions.Session'Class;
Query : in ADO.SQL.Query'Class;
Found : out Boolean);
overriding
procedure Load (Object : in out Property_Impl;
Session : in out ADO.Sessions.Session'Class);
procedure Load (Object : in out Property_Impl;
Stmt : in out ADO.Statements.Query_Statement'Class;
Session : in out ADO.Sessions.Session'Class);
overriding
procedure Save (Object : in out Property_Impl;
Session : in out ADO.Sessions.Master_Session'Class);
overriding
procedure Create (Object : in out Property_Impl;
Session : in out ADO.Sessions.Master_Session'Class);
overriding
procedure Delete (Object : in out Property_Impl;
Session : in out ADO.Sessions.Master_Session'Class);
procedure Set_Field (Object : in out Property_Ref'Class;
Impl : out Property_Access);
end Regtests.Audits.Model;
|
reznikmm/matreshka | Ada | 10,833 | 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 League.Strings.Internals;
with Matreshka.Internals.Strings;
with AMF.Internals.Helpers;
with AMF.Internals.Tables.CMOF_Attributes;
with AMF.Visitors.CMOF_Iterators;
with AMF.Visitors.CMOF_Visitors;
package body AMF.Internals.CMOF_Parameters is
use AMF.Internals.Tables.CMOF_Attributes;
use type Matreshka.Internals.Strings.Shared_String_Access;
-------------------
-- Enter_Element --
-------------------
overriding procedure Enter_Element
(Self : not null access constant CMOF_Parameter_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_Parameter
(AMF.CMOF.Parameters.CMOF_Parameter_Access (Self),
Control);
end if;
end Enter_Element;
-----------------
-- Get_Default --
-----------------
overriding function Get_Default
(Self : not null access constant CMOF_Parameter_Proxy)
return Optional_String
is
Aux : constant Matreshka.Internals.Strings.Shared_String_Access
:= Internal_Get_Default (Self.Element);
begin
if Aux = null then
return (Is_Empty => True);
else
return (False, League.Strings.Internals.Create (Aux));
end if;
end Get_Default;
-------------------
-- Get_Direction --
-------------------
overriding function Get_Direction
(Self : not null access constant CMOF_Parameter_Proxy)
return CMOF.CMOF_Parameter_Direction_Kind is
begin
return Internal_Get_Direction (Self.Element);
end Get_Direction;
-------------------
-- Get_Operation --
-------------------
overriding function Get_Operation
(Self : not null access constant CMOF_Parameter_Proxy)
return AMF.CMOF.Operations.CMOF_Operation_Access is
begin
return
AMF.CMOF.Operations.CMOF_Operation_Access
(AMF.Internals.Helpers.To_Element (Internal_Get_Operation (Self.Element)));
end Get_Operation;
-------------------
-- Leave_Element --
-------------------
overriding procedure Leave_Element
(Self : not null access constant CMOF_Parameter_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_Parameter
(AMF.CMOF.Parameters.CMOF_Parameter_Access (Self),
Control);
end if;
end Leave_Element;
-------------------
-- Set_Direction --
-------------------
overriding procedure Set_Direction
(Self : not null access CMOF_Parameter_Proxy;
To : CMOF.CMOF_Parameter_Direction_Kind) is
begin
Internal_Set_Direction (Self.Element, To);
end Set_Direction;
-------------------
-- Visit_Element --
-------------------
overriding procedure Visit_Element
(Self : not null access constant CMOF_Parameter_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_Parameter
(Visitor,
AMF.CMOF.Parameters.CMOF_Parameter_Access (Self),
Control);
end if;
end Visit_Element;
------------------------
-- All_Owned_Elements --
------------------------
overriding function All_Owned_Elements
(Self : not null access constant CMOF_Parameter_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;
-------------------
-- Set_Is_Unique --
-------------------
overriding procedure Set_Is_Unique
(Self : not null access CMOF_Parameter_Proxy;
To : Boolean)
is
begin
-- Generated stub: replace with real body!
pragma Compile_Time_Warning (Standard.True, "Set_Is_Unique unimplemented");
raise Program_Error;
end Set_Is_Unique;
---------------------------
-- Includes_Multiplicity --
---------------------------
overriding function Includes_Multiplicity
(Self : not null access constant CMOF_Parameter_Proxy;
M : AMF.CMOF.Multiplicity_Elements.CMOF_Multiplicity_Element_Access)
return Boolean
is
begin
-- Generated stub: replace with real body!
pragma Compile_Time_Warning (Standard.True, "Includes_Multiplicity unimplemented");
raise Program_Error;
return Includes_Multiplicity (Self, M);
end Includes_Multiplicity;
--------------------------
-- Includes_Cardinality --
--------------------------
overriding function Includes_Cardinality
(Self : not null access constant CMOF_Parameter_Proxy;
C : Integer)
return Boolean
is
begin
-- Generated stub: replace with real body!
pragma Compile_Time_Warning (Standard.True, "Includes_Cardinality unimplemented");
raise Program_Error;
return Includes_Cardinality (Self, C);
end Includes_Cardinality;
------------------------
-- Get_Qualified_Name --
------------------------
overriding function Get_Qualified_Name
(Self : not null access constant CMOF_Parameter_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_Parameter_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;
-----------------
-- Set_Default --
-----------------
overriding procedure Set_Default
(Self : not null access CMOF_Parameter_Proxy;
To : Optional_String)
is
begin
-- Generated stub: replace with real body!
pragma Compile_Time_Warning (Standard.True, "Set_Default unimplemented");
raise Program_Error;
end Set_Default;
-------------------
-- Set_Operation --
-------------------
overriding procedure Set_Operation
(Self : not null access CMOF_Parameter_Proxy;
To : AMF.CMOF.Operations.CMOF_Operation_Access)
is
begin
-- Generated stub: replace with real body!
pragma Compile_Time_Warning (Standard.True, "Set_Operation unimplemented");
raise Program_Error;
end Set_Operation;
end AMF.Internals.CMOF_Parameters;
|
charlie5/aIDE | Ada | 1,037 | ads | with
AdaM.a_Type.record_type,
Ada.Streams;
package AdaM.a_Type.tagged_record_type
is
type Item is new a_Type.record_type.item with private;
type View is access all Item'Class;
-- Forge
--
function new_Type (Name : in String := "") return tagged_record_type.view;
overriding
procedure destruct (Self : in out Item);
procedure free (Self : in out tagged_record_type.view);
-- Attributes
--
overriding
function Id (Self : access Item) return AdaM.Id;
private
type Item is new a_Type.record_type.item with
record
null;
end record;
-- Streams
--
procedure View_write (Stream : not null access Ada.Streams.Root_Stream_Type'Class;
Self : in View);
procedure View_read (Stream : not null access Ada.Streams.Root_Stream_Type'Class;
Self : out View);
for View'write use View_write;
for View'read use View_read;
end AdaM.a_Type.tagged_record_type;
|
onrik/Amass | Ada | 1,371 | 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(1)
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(ctx, {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
|
Fabien-Chouteau/Ada_Drivers_Library | Ada | 2,314 | ads | -- Copyright (c) 2013, Nordic Semiconductor ASA
-- All rights reserved.
--
-- Redistribution and use in source and binary forms, with or without
-- modification, are permitted provided that the following conditions are met:
--
-- * Redistributions of source code must retain the above copyright notice, this
-- list of conditions and the following disclaimer.
--
-- * Redistributions in binary form must reproduce the above copyright notice,
-- this list of conditions and the following disclaimer in the documentation
-- and/or other materials provided with the distribution.
--
-- * Neither the name of Nordic Semiconductor ASA nor the names of its
-- contributors may be used to endorse or promote products derived from
-- this software without specific prior written permission.
--
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
-- AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
-- IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
-- DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
-- FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
-- DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
-- SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
-- CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
-- OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-- OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
--
-- This spec has been automatically generated from nrf51.svd
pragma Restrictions (No_Elaboration_Code);
pragma Ada_2012;
pragma Style_Checks (Off);
with HAL;
with System;
package NRF51_SVD.SWI is
pragma Preelaborate;
---------------
-- Registers --
---------------
-----------------
-- Peripherals --
-----------------
-- SW Interrupts.
type SWI_Peripheral is record
-- Unused.
UNUSED : aliased HAL.UInt32;
end record
with Volatile;
for SWI_Peripheral use record
UNUSED at 0 range 0 .. 31;
end record;
-- SW Interrupts.
SWI_Periph : aliased SWI_Peripheral
with Import, Address => System'To_Address (16#40014000#);
end NRF51_SVD.SWI;
|
reznikmm/matreshka | Ada | 13,148 | 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.
------------------------------------------------------------------------------
package AMF.Internals.Tables.DG_Metamodel.Links is
procedure Initialize;
private
procedure Initialize_1;
procedure Initialize_2;
procedure Initialize_3;
procedure Initialize_4;
procedure Initialize_5;
procedure Initialize_6;
procedure Initialize_7;
procedure Initialize_8;
procedure Initialize_9;
procedure Initialize_10;
procedure Initialize_11;
procedure Initialize_12;
procedure Initialize_13;
procedure Initialize_14;
procedure Initialize_15;
procedure Initialize_16;
procedure Initialize_17;
procedure Initialize_18;
procedure Initialize_19;
procedure Initialize_20;
procedure Initialize_21;
procedure Initialize_22;
procedure Initialize_23;
procedure Initialize_24;
procedure Initialize_25;
procedure Initialize_26;
procedure Initialize_27;
procedure Initialize_28;
procedure Initialize_29;
procedure Initialize_30;
procedure Initialize_31;
procedure Initialize_32;
procedure Initialize_33;
procedure Initialize_34;
procedure Initialize_35;
procedure Initialize_36;
procedure Initialize_37;
procedure Initialize_38;
procedure Initialize_39;
procedure Initialize_40;
procedure Initialize_41;
procedure Initialize_42;
procedure Initialize_43;
procedure Initialize_44;
procedure Initialize_45;
procedure Initialize_46;
procedure Initialize_47;
procedure Initialize_48;
procedure Initialize_49;
procedure Initialize_50;
procedure Initialize_51;
procedure Initialize_52;
procedure Initialize_53;
procedure Initialize_54;
procedure Initialize_55;
procedure Initialize_56;
procedure Initialize_57;
procedure Initialize_58;
procedure Initialize_59;
procedure Initialize_60;
procedure Initialize_61;
procedure Initialize_62;
procedure Initialize_63;
procedure Initialize_64;
procedure Initialize_65;
procedure Initialize_66;
procedure Initialize_67;
procedure Initialize_68;
procedure Initialize_69;
procedure Initialize_70;
procedure Initialize_71;
procedure Initialize_72;
procedure Initialize_73;
procedure Initialize_74;
procedure Initialize_75;
procedure Initialize_76;
procedure Initialize_77;
procedure Initialize_78;
procedure Initialize_79;
procedure Initialize_80;
procedure Initialize_81;
procedure Initialize_82;
procedure Initialize_83;
procedure Initialize_84;
procedure Initialize_85;
procedure Initialize_86;
procedure Initialize_87;
procedure Initialize_88;
procedure Initialize_89;
procedure Initialize_90;
procedure Initialize_91;
procedure Initialize_92;
procedure Initialize_93;
procedure Initialize_94;
procedure Initialize_95;
procedure Initialize_96;
procedure Initialize_97;
procedure Initialize_98;
procedure Initialize_99;
procedure Initialize_100;
procedure Initialize_101;
procedure Initialize_102;
procedure Initialize_103;
procedure Initialize_104;
procedure Initialize_105;
procedure Initialize_106;
procedure Initialize_107;
procedure Initialize_108;
procedure Initialize_109;
procedure Initialize_110;
procedure Initialize_111;
procedure Initialize_112;
procedure Initialize_113;
procedure Initialize_114;
procedure Initialize_115;
procedure Initialize_116;
procedure Initialize_117;
procedure Initialize_118;
procedure Initialize_119;
procedure Initialize_120;
procedure Initialize_121;
procedure Initialize_122;
procedure Initialize_123;
procedure Initialize_124;
procedure Initialize_125;
procedure Initialize_126;
procedure Initialize_127;
procedure Initialize_128;
procedure Initialize_129;
procedure Initialize_130;
procedure Initialize_131;
procedure Initialize_132;
procedure Initialize_133;
procedure Initialize_134;
procedure Initialize_135;
procedure Initialize_136;
procedure Initialize_137;
procedure Initialize_138;
procedure Initialize_139;
procedure Initialize_140;
procedure Initialize_141;
procedure Initialize_142;
procedure Initialize_143;
procedure Initialize_144;
procedure Initialize_145;
procedure Initialize_146;
procedure Initialize_147;
procedure Initialize_148;
procedure Initialize_149;
procedure Initialize_150;
procedure Initialize_151;
procedure Initialize_152;
procedure Initialize_153;
procedure Initialize_154;
procedure Initialize_155;
procedure Initialize_156;
procedure Initialize_157;
procedure Initialize_158;
procedure Initialize_159;
procedure Initialize_160;
procedure Initialize_161;
procedure Initialize_162;
procedure Initialize_163;
procedure Initialize_164;
procedure Initialize_165;
procedure Initialize_166;
procedure Initialize_167;
procedure Initialize_168;
procedure Initialize_169;
procedure Initialize_170;
procedure Initialize_171;
procedure Initialize_172;
procedure Initialize_173;
procedure Initialize_174;
procedure Initialize_175;
procedure Initialize_176;
procedure Initialize_177;
procedure Initialize_178;
procedure Initialize_179;
procedure Initialize_180;
procedure Initialize_181;
procedure Initialize_182;
procedure Initialize_183;
procedure Initialize_184;
procedure Initialize_185;
procedure Initialize_186;
procedure Initialize_187;
procedure Initialize_188;
procedure Initialize_189;
procedure Initialize_190;
procedure Initialize_191;
procedure Initialize_192;
procedure Initialize_193;
procedure Initialize_194;
procedure Initialize_195;
procedure Initialize_196;
procedure Initialize_197;
procedure Initialize_198;
procedure Initialize_199;
procedure Initialize_200;
procedure Initialize_201;
procedure Initialize_202;
procedure Initialize_203;
procedure Initialize_204;
procedure Initialize_205;
procedure Initialize_206;
procedure Initialize_207;
procedure Initialize_208;
procedure Initialize_209;
procedure Initialize_210;
procedure Initialize_211;
procedure Initialize_212;
procedure Initialize_213;
procedure Initialize_214;
procedure Initialize_215;
procedure Initialize_216;
procedure Initialize_217;
procedure Initialize_218;
procedure Initialize_219;
procedure Initialize_220;
procedure Initialize_221;
procedure Initialize_222;
procedure Initialize_223;
procedure Initialize_224;
procedure Initialize_225;
procedure Initialize_226;
procedure Initialize_227;
procedure Initialize_228;
procedure Initialize_229;
procedure Initialize_230;
procedure Initialize_231;
procedure Initialize_232;
procedure Initialize_233;
procedure Initialize_234;
procedure Initialize_235;
procedure Initialize_236;
procedure Initialize_237;
procedure Initialize_238;
procedure Initialize_239;
procedure Initialize_240;
procedure Initialize_241;
procedure Initialize_242;
procedure Initialize_243;
procedure Initialize_244;
procedure Initialize_245;
procedure Initialize_246;
procedure Initialize_247;
procedure Initialize_248;
procedure Initialize_249;
procedure Initialize_250;
procedure Initialize_251;
procedure Initialize_252;
procedure Initialize_253;
procedure Initialize_254;
procedure Initialize_255;
procedure Initialize_256;
procedure Initialize_257;
procedure Initialize_258;
procedure Initialize_259;
procedure Initialize_260;
procedure Initialize_261;
procedure Initialize_262;
procedure Initialize_263;
procedure Initialize_264;
procedure Initialize_265;
procedure Initialize_266;
procedure Initialize_267;
procedure Initialize_268;
procedure Initialize_269;
procedure Initialize_270;
procedure Initialize_271;
procedure Initialize_272;
procedure Initialize_273;
procedure Initialize_274;
procedure Initialize_275;
procedure Initialize_276;
procedure Initialize_277;
procedure Initialize_278;
procedure Initialize_279;
procedure Initialize_280;
procedure Initialize_281;
procedure Initialize_282;
procedure Initialize_283;
procedure Initialize_284;
procedure Initialize_285;
procedure Initialize_286;
procedure Initialize_287;
procedure Initialize_288;
procedure Initialize_289;
procedure Initialize_290;
procedure Initialize_291;
procedure Initialize_292;
procedure Initialize_293;
procedure Initialize_294;
procedure Initialize_295;
procedure Initialize_296;
procedure Initialize_297;
procedure Initialize_298;
procedure Initialize_299;
procedure Initialize_300;
procedure Initialize_301;
procedure Initialize_302;
procedure Initialize_303;
procedure Initialize_304;
procedure Initialize_305;
procedure Initialize_306;
procedure Initialize_307;
procedure Initialize_308;
procedure Initialize_309;
procedure Initialize_310;
procedure Initialize_311;
procedure Initialize_312;
procedure Initialize_313;
procedure Initialize_314;
procedure Initialize_315;
procedure Initialize_316;
procedure Initialize_317;
procedure Initialize_318;
procedure Initialize_319;
procedure Initialize_320;
procedure Initialize_321;
procedure Initialize_322;
end AMF.Internals.Tables.DG_Metamodel.Links;
|
MinimSecure/unum-sdk | Ada | 818 | adb | -- Copyright 2012-2019 Free Software Foundation, Inc.
--
-- This program is free software; you can redistribute it and/or modify
-- it under the terms of the GNU General Public License as published by
-- the Free Software Foundation; either version 3 of the License, or
-- (at your option) any later version.
--
-- This program is distributed in the hope that it will be useful,
-- but WITHOUT ANY WARRANTY; without even the implied warranty of
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-- GNU General Public License for more details.
--
-- You should have received a copy of the GNU General Public License
-- along with this program. If not, see <http://www.gnu.org/licenses/>.
package body IO is
procedure Put_Line (S : String) is
begin
null;
end Put_Line;
end IO;
|
reznikmm/ada-pretty | Ada | 27,709 | adb | -- Copyright (c) 2017 Maxim Reznik <[email protected]>
--
-- SPDX-License-Identifier: MIT
-- License-Filename: LICENSE
-------------------------------------------------------------
with Ada_Pretty.Definitions;
with Ada_Pretty.Clauses;
with Ada_Pretty.Declarations;
with Ada_Pretty.Expressions;
with Ada_Pretty.Joins;
with Ada_Pretty.Statements;
with Ada_Pretty.Units;
package body Ada_Pretty is
--------------
-- Document --
--------------
not overriding function Document
(Self : Node;
Printer : not null access League.Pretty_Printers.Printer'Class;
Pad : Natural)
return League.Pretty_Printers.Document is
begin
raise Program_Error;
return Printer.New_Document;
end Document;
----------
-- Join --
----------
overriding function Join
(Self : Declaration;
List : Node_Access_Array;
Pad : Natural;
Printer : not null access League.Pretty_Printers.Printer'Class)
return League.Pretty_Printers.Document
is
Result : League.Pretty_Printers.Document := Printer.New_Document;
begin
Result.Append (Node'Class (Self).Document (Printer, Pad));
for J in List'Range loop
Result.New_Line;
Result.Append (List (J).Document (Printer, Pad));
end loop;
return Result;
end Join;
----------
-- Join --
----------
not overriding function Join
(Self : Node;
List : Node_Access_Array;
Pad : Natural;
Printer : not null access League.Pretty_Printers.Printer'Class)
return League.Pretty_Printers.Document
is
Result : League.Pretty_Printers.Document := Printer.New_Document;
begin
Result.Append (Node'Class (Self).Document (Printer, Pad));
for J in List'Range loop
Result.Append (List (J).Document (Printer, Pad));
end loop;
return Result;
end Join;
----------
-- Join --
----------
overriding function Join
(Self : Expression;
List : Node_Access_Array;
Pad : Natural;
Printer : not null access League.Pretty_Printers.Printer'Class)
return League.Pretty_Printers.Document
is
Result : League.Pretty_Printers.Document := Printer.New_Document;
begin
Result.Append (Node'Class (Self).Document (Printer, Pad));
for J in List'Range loop
if List (J).all not in Expressions.Infix then
Result.Put (",");
Result.New_Line;
end if;
Result.Append (List (J).Document (Printer, Pad));
end loop;
Result.Group;
return Result;
end Join;
----------------
-- New_Access --
----------------
not overriding function New_Access
(Self : access Factory;
Modifier : Access_Modifier := Unspecified;
Target : not null Node_Access) return not null Node_Access
is
pragma Unreferenced (Self);
begin
return new Node'Class'(Definitions.New_Access
(Modifier => Modifier, Target => Target));
end New_Access;
---------------
-- New_Apply --
---------------
not overriding function New_Apply
(Self : access Factory;
Prefix : not null Node_Access;
Arguments : not null Node_Access) return not null Node_Access
is
pragma Unreferenced (Self);
begin
return new Node'Class'(Expressions.New_Apply
(Prefix, Arguments));
end New_Apply;
------------------------------
-- New_Argument_Association --
------------------------------
not overriding function New_Argument_Association
(Self : access Factory;
Value : not null Node_Access;
Choice : Node_Access := null) return not null Node_Access
is
pragma Unreferenced (Self);
begin
return new Node'Class'(Expressions.New_Argument_Association
(Choice, Value));
end New_Argument_Association;
---------------
-- New_Array --
---------------
not overriding function New_Array
(Self : access Factory;
Indexes : not null Node_Access;
Component : not null Node_Access) return not null Node_Access
is
pragma Unreferenced (Self);
begin
return new Node'Class'(Definitions.New_Array (Indexes, Component));
end New_Array;
----------------
-- New_Aspect --
----------------
not overriding function New_Aspect
(Self : access Factory;
Name : not null Node_Access;
Value : Node_Access := null) return not null Node_Access
is
pragma Unreferenced (Self);
begin
return new Node'Class'(Clauses.New_Aspect (Name, Value));
end New_Aspect;
--------------------
-- New_Assignment --
--------------------
not overriding function New_Assignment
(Self : access Factory;
Left : not null Node_Access;
Right : not null Node_Access) return not null Node_Access
is
pragma Unreferenced (Self);
begin
return new Node'Class'(Statements.New_Assignment (Left, Right));
end New_Assignment;
---------------
-- New_Block --
---------------
not overriding function New_Block
(Self : access Factory;
Declarations : Node_Access := null;
Statements : Node_Access := null;
Exceptions : Node_Access := null) return not null Node_Access
is
pragma Unreferenced (Self);
begin
return new Node'Class'(Ada_Pretty.Statements.New_Block_Statement
(Declarations, Statements, Exceptions));
end New_Block;
--------------
-- New_Case --
--------------
not overriding function New_Case
(Self : access Factory;
Expression : not null Node_Access;
List : not null Node_Access) return not null Node_Access
is
pragma Unreferenced (Self);
begin
return new Node'Class'(Statements.New_Case (Expression, List));
end New_Case;
-------------------
-- New_Case_Path --
-------------------
not overriding function New_Case_Path
(Self : access Factory;
Choice : not null Node_Access;
List : not null Node_Access) return not null Node_Access
is
pragma Unreferenced (Self);
begin
return new Node'Class'(Statements.New_Case_Path (Choice, List));
end New_Case_Path;
--------------------------
-- New_Compilation_Unit --
--------------------------
not overriding function New_Compilation_Unit
(Self : access Factory;
Root : not null Node_Access;
Clauses : Node_Access := null;
License : League.Strings.Universal_String :=
League.Strings.Empty_Universal_String)
return not null Node_Access
is
pragma Unreferenced (Self);
begin
return new Node'Class'(Units.New_Compilation_Unit
(Root, Clauses, License));
end New_Compilation_Unit;
-------------------------------
-- New_Component_Association --
-------------------------------
not overriding function New_Component_Association
(Self : access Factory;
Value : not null Node_Access;
Choices : Node_Access := null) return not null Node_Access
is
pragma Unreferenced (Self);
begin
return new Node'Class'(Expressions.New_Component_Association
(Choices, Value));
end New_Component_Association;
-----------------
-- New_Derived --
-----------------
not overriding function New_Derived
(Self : access Factory;
Parent : not null Node_Access) return not null Node_Access
is
pragma Unreferenced (Self);
begin
return new Node'Class'(Definitions.New_Derived (Parent));
end New_Derived;
---------------
-- New_Elsif --
---------------
not overriding function New_Elsif
(Self : access Factory;
Condition : not null Node_Access;
List : not null Node_Access) return not null Node_Access
is
pragma Unreferenced (Self);
begin
return new Node'Class'(Statements.New_Elsif (Condition, List));
end New_Elsif;
-------------------------
-- New_Extended_Return --
-------------------------
not overriding function New_Extended_Return
(Self : access Factory;
Name : not null Node_Access;
Type_Definition : not null Node_Access;
Initialization : Node_Access := null;
Statements : not null Node_Access) return not null Node_Access
is
pragma Unreferenced (Self);
begin
return new Node'Class'(Ada_Pretty.Statements.New_Extended_Return
(Name, Type_Definition,
Initialization, Statements));
end New_Extended_Return;
-------------
-- New_For --
-------------
not overriding function New_For
(Self : access Factory;
Name : not null Node_Access;
Iterator : not null Node_Access;
Statements : not null Node_Access) return not null Node_Access
is
pragma Unreferenced (Self);
begin
return new Node'Class'(Ada_Pretty.Statements.New_For
(Name, Iterator, Statements));
end New_For;
----------------------
-- New_If_Statement --
----------------------
not overriding function New_If
(Self : access Factory;
Condition : not null Node_Access;
Then_Path : not null Node_Access;
Elsif_List : Node_Access := null;
Else_Path : Node_Access := null) return not null Node_Access
is
pragma Unreferenced (Self);
begin
return new Node'Class'(Statements.New_If
(Condition, Then_Path, Elsif_List, Else_Path));
end New_If;
-----------------------
-- New_If_Expression --
-----------------------
not overriding function New_If_Expression
(Self : access Factory;
Condition : not null Node_Access;
Then_Path : not null Node_Access;
Elsif_List : Node_Access := null;
Else_Path : Node_Access := null) return not null Node_Access
is
pragma Unreferenced (Self);
begin
return new Node'Class'(Expressions.New_If
(Condition, Then_Path, Elsif_List, Else_Path));
end New_If_Expression;
---------------
-- New_Infix --
---------------
not overriding function New_Infix
(Self : access Factory;
Operator : League.Strings.Universal_String;
Left : not null Node_Access) return not null Node_Access
is
pragma Unreferenced (Self);
begin
return new Node'Class'(Expressions.New_Infix (Operator, Left));
end New_Infix;
-------------------
-- New_Interface --
-------------------
not overriding function New_Interface
(Self : access Factory;
Is_Limited : Boolean := False;
Parents : Node_Access := null) return not null Node_Access
is
pragma Unreferenced (Self);
begin
return new Node'Class'(Definitions.New_Interface
(Is_Limited, Parents));
end New_Interface;
--------------
-- New_List --
--------------
not overriding function New_List
(Self : access Factory;
Head : Node_Access;
Tail : not null Node_Access) return not null Node_Access
is
pragma Unreferenced (Self);
begin
if Head = null then
return Tail;
else
return new Node'Class'(Joins.New_Join (Head, Tail));
end if;
end New_List;
--------------
-- New_List --
--------------
not overriding function New_List
(Self : access Factory;
List : Node_Access_Array) return not null Node_Access
is
Result : Node_Access := List (List'First);
begin
for J in List'First + 1 .. List'Last loop
Result := Self.New_List (Result, List (J));
end loop;
return Result;
end New_List;
-----------------
-- New_Literal --
-----------------
not overriding function New_Literal
(Self : access Factory;
Value : Natural;
Base : Positive := 10) return not null Node_Access
is
pragma Unreferenced (Self);
begin
return new Node'Class'(Expressions.New_Literal
(Value, Base));
end New_Literal;
--------------
-- New_Loop --
--------------
not overriding function New_Loop
(Self : access Factory;
Condition : Node_Access;
Statements : not null Node_Access) return not null Node_Access
is
pragma Unreferenced (Self);
begin
return new Node'Class'(Ada_Pretty.Statements.New_Loop
(Condition, Statements));
end New_Loop;
--------------
-- New_Name --
--------------
not overriding function New_Name
(Self : access Factory;
Name : League.Strings.Universal_String)
return not null Node_Access
is
pragma Unreferenced (Self);
begin
return new Node'Class'(Expressions.New_Name (Name));
end New_Name;
------------------------
-- New_Null_Exclusion --
------------------------
not overriding function New_Null_Exclusion
(Self : access Factory;
Definition : not null Node_Access;
Exclude : Boolean := True) return not null Node_Access
is
pragma Unreferenced (Self);
begin
return new Node'Class'(Definitions.New_Null_Exclusion
(Definition, Exclude));
end New_Null_Exclusion;
-----------------
-- New_Package --
-----------------
not overriding function New_Package
(Self : access Factory;
Name : not null Node_Access;
Public_Part : Node_Access := null;
Private_Part : Node_Access := null;
Comment : League.Strings.Universal_String :=
League.Strings.Empty_Universal_String)
return not null Node_Access
is
pragma Unreferenced (Self);
begin
return new Node'Class'(Declarations.New_Package
(Name, Public_Part, Private_Part, Comment));
end New_Package;
----------------------
-- New_Package_Body --
----------------------
not overriding function New_Package_Body
(Self : access Factory;
Name : not null Node_Access;
List : Node_Access := null) return not null Node_Access
is
pragma Unreferenced (Self);
begin
return new Node'Class'(Declarations.New_Package_Body
(Name, List));
end New_Package_Body;
-------------------------------
-- New_Package_Instantiation --
-------------------------------
not overriding function New_Package_Instantiation
(Self : access Factory;
Name : not null Node_Access;
Template : not null Node_Access;
Actual_Part : Node_Access := null;
Comment : League.Strings.Universal_String :=
League.Strings.Empty_Universal_String) return not null Node_Access
is
pragma Unreferenced (Self);
begin
return new Node'Class'(Declarations.New_Package_Instantiation
(Name, Template, Actual_Part, Comment));
end New_Package_Instantiation;
-------------------
-- New_Parameter --
-------------------
not overriding function New_Parameter
(Self : access Factory;
Name : not null Node_Access;
Type_Definition : not null Node_Access;
Initialization : Node_Access := null;
Is_In : Boolean := False;
Is_Out : Boolean := False;
Is_Aliased : Boolean := False;
Comment : League.Strings.Universal_String :=
League.Strings.Empty_Universal_String) return not null Node_Access
is
pragma Unreferenced (Self);
begin
return new Node'Class'(Declarations.New_Parameter
(Name, Type_Definition, Initialization,
Is_In, Is_Out, Is_Aliased, Comment));
end New_Parameter;
---------------------
-- New_Parentheses --
---------------------
not overriding function New_Parentheses
(Self : access Factory;
Child : not null Node_Access) return not null Node_Access
is
pragma Unreferenced (Self);
begin
return new Node'Class'(Expressions.New_Parentheses (Child));
end New_Parentheses;
----------------
-- New_Pragma --
----------------
not overriding function New_Pragma
(Self : access Factory;
Name : not null Node_Access;
Arguments : Node_Access := null;
Comment : League.Strings.Universal_String :=
League.Strings.Empty_Universal_String)
return not null Node_Access
is
pragma Unreferenced (Self, Comment);
begin
return new Node'Class'(Clauses.New_Pragma (Name, Arguments));
end New_Pragma;
------------------------
-- New_Private_Record --
------------------------
not overriding function New_Private_Record
(Self : access Factory;
Is_Tagged : Boolean := False;
Is_Limited : Boolean := False;
Parents : Node_Access := null) return not null Node_Access
is
pragma Unreferenced (Self);
begin
return new Node'Class'(Definitions.New_Private_Record
(Is_Tagged, Is_Limited, Parents));
end New_Private_Record;
-----------------------------
-- New_Qualified_Expession --
-----------------------------
not overriding function New_Qualified_Expession
(Self : access Factory;
Prefix : not null Node_Access;
Argument : not null Node_Access) return not null Node_Access
is
pragma Unreferenced (Self);
begin
return new Node'Class'(Expressions.New_Qualified (Prefix, Argument));
end New_Qualified_Expession;
----------------
-- New_Record --
----------------
not overriding function New_Record
(Self : access Factory;
Parent : Node_Access := null;
Components : Node_Access := null;
Is_Abstract : Boolean := False;
Is_Tagged : Boolean := False;
Is_Limited : Boolean := False) return not null Node_Access
is
pragma Unreferenced (Self);
begin
return new Node'Class'(Definitions.New_Record
(Parent, Components,
Is_Abstract, Is_Tagged, Is_Limited));
end New_Record;
----------------
-- New_Return --
----------------
not overriding function New_Return
(Self : access Factory;
Expression : Node_Access := null) return not null Node_Access
is
pragma Unreferenced (Self);
begin
return new Node'Class'(Statements.New_Return (Expression));
end New_Return;
-----------------------
-- New_Selected_Name --
-----------------------
not overriding function New_Selected_Name
(Self : access Factory;
Prefix : not null Node_Access;
Selector : not null Node_Access)
return not null Node_Access
is
pragma Unreferenced (Self);
begin
return new Node'Class'(Expressions.New_Selected_Name
(Prefix, Selector));
end New_Selected_Name;
not overriding function New_Selected_Name
(Self : access Factory;
Name : League.Strings.Universal_String) return not null Node_Access
is
List : constant League.String_Vectors.Universal_String_Vector :=
Name.Split ('.');
Result : Node_Access := Self.New_Name (List.Element (1));
begin
for J in 2 .. List.Length loop
Result := Self.New_Selected_Name
(Result, Self.New_Name (List.Element (J)));
end loop;
return Result;
end New_Selected_Name;
-------------------
-- New_Statement --
-------------------
not overriding function New_Statement
(Self : access Factory;
Expression : Node_Access := null) return not null Node_Access
is
pragma Unreferenced (Self);
begin
return new Node'Class'(Statements.New_Statement (Expression));
end New_Statement;
------------------------
-- New_String_Literal --
------------------------
not overriding function New_String_Literal
(Self : access Factory;
Text : League.Strings.Universal_String)
return not null Node_Access
is
pragma Unreferenced (Self);
begin
return new Node'Class'(Expressions.New_String (Text));
end New_String_Literal;
-------------------------
-- New_Subprogram_Body --
-------------------------
not overriding function New_Subprogram_Body
(Self : access Factory;
Specification : not null Node_Access;
Declarations : Node_Access := null;
Statements : Node_Access := null;
Exceptions : Node_Access := null) return not null Node_Access is
pragma Unreferenced (Self);
begin
return new Node'Class'(Ada_Pretty.Declarations.New_Subprogram_Body
(Specification,
Declarations,
Statements,
Exceptions));
end New_Subprogram_Body;
--------------------------------
-- New_Subprogram_Declaration --
--------------------------------
not overriding function New_Subprogram_Declaration
(Self : access Factory;
Specification : not null Node_Access;
Aspects : Node_Access := null;
Is_Abstract : Boolean := False;
Is_Null : Boolean := False;
Expression : Node_Access := null;
Renamed : Node_Access := null;
Comment : League.Strings.Universal_String :=
League.Strings.Empty_Universal_String) return not null Node_Access
is
pragma Unreferenced (Self);
begin
return new Node'Class'(Declarations.New_Subprogram_Declaration
(Specification,
Aspects,
Is_Abstract, Is_Null,
Expression, Renamed,
Comment));
end New_Subprogram_Declaration;
--------------------
-- New_Subprogram --
--------------------
not overriding function New_Subprogram_Specification
(Self : access Factory;
Is_Overriding : Trilean := Unspecified;
Name : Node_Access := null;
Parameters : Node_Access := null;
Result : Node_Access := null) return not null Node_Access
is
pragma Unreferenced (Self);
begin
return new Node'Class'(Definitions.New_Subprogram
(Is_Overriding,
Name,
Parameters,
Result));
end New_Subprogram_Specification;
-----------------
-- New_Subtype --
-----------------
pragma Warnings (Off);
not overriding function New_Subtype
(Self : access Factory;
Name : not null Node_Access;
Definition : not null Node_Access;
Constrain : Node_Access := null;
Comment : League.Strings.Universal_String :=
League.Strings.Empty_Universal_String)
return not null Node_Access
is
begin
-- Generated stub: replace with real body!
pragma Compile_Time_Warning (Standard.True, "New_Subtype unimplemented");
return raise Program_Error with "Unimplemented function New_Subtype";
end New_Subtype;
pragma Warnings (On);
-----------------
-- New_Subunit --
-----------------
not overriding function New_Subunit
(Self : access Factory;
Parent_Name : not null Node_Access;
Proper_Body : not null Node_Access) return not null Node_Access
is
pragma Unreferenced (Self);
begin
return new Node'Class'(Units.New_Subunit (Parent_Name, Proper_Body));
end New_Subunit;
--------------
-- New_Type --
--------------
not overriding function New_Type
(Self : access Factory;
Name : not null Node_Access;
Discriminants : Node_Access := null;
Definition : Node_Access := null;
Aspects : Node_Access := null;
Comment : League.Strings.Universal_String :=
League.Strings.Empty_Universal_String)
return not null Node_Access
is
pragma Unreferenced (Self);
begin
return new Node'Class'(Declarations.New_Type
(Name,
Discriminants,
Definition,
Aspects,
Comment));
end New_Type;
-------------
-- New_Use --
-------------
not overriding function New_Use
(Self : access Factory;
Name : not null Node_Access;
Use_Type : Boolean := False) return not null Node_Access
is
pragma Unreferenced (Self);
begin
return new Node'Class'(Clauses.New_Use (Name, Use_Type));
end New_Use;
------------------
-- New_Variable --
------------------
not overriding function New_Variable
(Self : access Factory;
Name : not null Node_Access;
Type_Definition : Node_Access := null;
Initialization : Node_Access := null;
Rename : Node_Access := null;
Is_Constant : Boolean := False;
Is_Aliased : Boolean := False;
Aspects : Node_Access := null;
Comment : League.Strings.Universal_String :=
League.Strings.Empty_Universal_String) return not null Node_Access
is
pragma Unreferenced (Self);
begin
return new Node'Class'(Declarations.New_Variable
(Name,
Type_Definition,
Initialization,
Rename,
Is_Constant,
Is_Aliased,
Aspects,
Comment));
end New_Variable;
--------------
-- New_With --
--------------
not overriding function New_With
(Self : access Factory;
Name : not null Node_Access;
Is_Limited : Boolean := False;
Is_Private : Boolean := False) return not null Node_Access
is
pragma Unreferenced (Self);
begin
return new Node'Class'(Clauses.New_With
(Name, Is_Limited, Is_Private));
end New_With;
------------------
-- Print_Aspect --
------------------
function Print_Aspect
(Aspect : Node_Access;
Printer : not null access League.Pretty_Printers.Printer'Class)
return League.Pretty_Printers.Document
is
Result : League.Pretty_Printers.Document := Printer.New_Document;
Pad : constant Natural := 0;
begin
if Aspect = null then
return Result;
end if;
Result.New_Line;
Result.Put ("with ");
Result.Append (Aspect.Document (Printer, Pad));
Result.Nest (2);
if Aspect.all in Clauses.Aspect then
Result.Group;
end if;
return Result;
end Print_Aspect;
-------------
-- To_Text --
-------------
not overriding function To_Text
(Self : access Factory;
Unit : not null Node_Access)
return League.String_Vectors.Universal_String_Vector
is
pragma Unreferenced (Self);
Printer : aliased League.Pretty_Printers.Printer;
Document : constant League.Pretty_Printers.Document :=
Unit.Document (Printer'Access, 0);
begin
return Printer.Pretty (Width => 79, Input => Document);
end To_Text;
end Ada_Pretty;
|
zhmu/ananas | Ada | 11,839 | adb | ------------------------------------------------------------------------------
-- --
-- GNAT COMPILER COMPONENTS --
-- --
-- S I N F O . U T I L S --
-- --
-- B o d y --
-- --
-- Copyright (C) 2020-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. --
-- --
------------------------------------------------------------------------------
with Atree; use Atree;
with Debug; use Debug;
with Output; use Output;
with Seinfo;
with Sinput; use Sinput;
package body Sinfo.Utils is
---------------
-- Debugging --
---------------
-- Suppose you find that node 12345 is messed up. You might want to find
-- the code that created that node. There are two ways to do this:
-- One way is to set a conditional breakpoint on New_Node_Debugging_Output
-- (nickname "nnd"):
-- break nnd if n = 12345
-- and run gnat1 again from the beginning.
-- The other way is to set a breakpoint near the beginning (e.g. on
-- gnat1drv), and run. Then set Watch_Node (nickname "ww") to 12345 in gdb:
-- ww := 12345
-- and set a breakpoint on New_Node_Breakpoint (nickname "nn"). Continue.
-- Either way, gnat1 will stop when node 12345 is created, or certain other
-- interesting operations are performed, such as Rewrite. To see exactly
-- which operations, search for "pragma Debug" below.
-- The second method is much faster if the amount of Ada code being
-- compiled is large.
ww : Node_Id'Base := Node_Low_Bound - 1;
pragma Export (Ada, ww);
Watch_Node : Node_Id'Base renames ww;
-- Node to "watch"; that is, whenever a node is created, we check if it
-- is equal to Watch_Node, and if so, call New_Node_Breakpoint. You have
-- presumably set a breakpoint on New_Node_Breakpoint. Note that the
-- initial value of Node_Id'First - 1 ensures that by default, no node
-- will be equal to Watch_Node.
procedure nn;
pragma Export (Ada, nn);
procedure New_Node_Breakpoint renames nn;
-- This doesn't do anything interesting; it's just for setting breakpoint
-- on as explained above.
procedure nnd (N : Node_Id);
pragma Export (Ada, nnd);
-- For debugging. If debugging is turned on, New_Node and New_Entity (etc.)
-- call this. If debug flag N is turned on, this prints out the new node.
--
-- If Node = Watch_Node, this prints out the new node and calls
-- New_Node_Breakpoint. Otherwise, does nothing.
procedure Node_Debug_Output (Op : String; N : Node_Id);
-- Called by nnd; writes Op followed by information about N
-------------------------
-- New_Node_Breakpoint --
-------------------------
procedure nn is
begin
Write_Str ("Watched node ");
Write_Int (Int (Watch_Node));
Write_Eol;
end nn;
-------------------------------
-- New_Node_Debugging_Output --
-------------------------------
procedure nnd (N : Node_Id) is
Node_Is_Watched : constant Boolean := N = Watch_Node;
begin
if Debug_Flag_N or else Node_Is_Watched then
Node_Debug_Output ("Node", N);
if Node_Is_Watched then
New_Node_Breakpoint;
end if;
end if;
end nnd;
procedure New_Node_Debugging_Output (N : Node_Id) is
begin
pragma Debug (nnd (N));
end New_Node_Debugging_Output;
-----------------------
-- Node_Debug_Output --
-----------------------
procedure Node_Debug_Output (Op : String; N : Node_Id) is
begin
Write_Str (Op);
if Nkind (N) in N_Entity then
Write_Str (" entity");
else
Write_Str (" node");
end if;
Write_Str (" Id = ");
Write_Int (Int (N));
Write_Str (" ");
Write_Location (Sloc (N));
Write_Str (" ");
Write_Str (Node_Kind'Image (Nkind (N)));
Write_Eol;
end Node_Debug_Output;
-------------------------------
-- Parent-related operations --
-------------------------------
procedure Copy_Parent (To, From : Node_Or_Entity_Id) is
begin
if Atree.Present (To) and Atree.Present (From) then
Atree.Set_Parent (To, Atree.Parent (From));
else
pragma Assert
(if Atree.Present (To) then Atree.No (Atree.Parent (To)));
end if;
end Copy_Parent;
function Parent_Kind (N : Node_Id) return Node_Kind is
begin
if Atree.No (N) then
return N_Empty;
else
return Nkind (Atree.Parent (N));
end if;
end Parent_Kind;
-------------------------
-- Iterator Procedures --
-------------------------
procedure Next_Entity (N : in out Node_Id) is
begin
N := Next_Entity (N);
end Next_Entity;
procedure Next_Named_Actual (N : in out Node_Id) is
begin
N := Next_Named_Actual (N);
end Next_Named_Actual;
procedure Next_Rep_Item (N : in out Node_Id) is
begin
N := Next_Rep_Item (N);
end Next_Rep_Item;
procedure Next_Use_Clause (N : in out Node_Id) is
begin
N := Next_Use_Clause (N);
end Next_Use_Clause;
------------------
-- End_Location --
------------------
function End_Location (N : Node_Id) return Source_Ptr is
L : constant Valid_Uint := End_Span (N);
begin
return Source_Ptr (Int (Sloc (N)) + UI_To_Int (L));
end End_Location;
--------------------
-- Get_Pragma_Arg --
--------------------
function Get_Pragma_Arg (Arg : Node_Id) return Node_Id is
begin
if Nkind (Arg) = N_Pragma_Argument_Association then
return Expression (Arg);
else
return Arg;
end if;
end Get_Pragma_Arg;
----------------------
-- Set_End_Location --
----------------------
procedure Set_End_Location (N : Node_Id; S : Source_Ptr) is
begin
Set_End_Span (N,
UI_From_Int (Int (S) - Int (Sloc (N))));
end Set_End_Location;
--------------------------
-- Pragma_Name_Unmapped --
--------------------------
function Pragma_Name_Unmapped (N : Node_Id) return Name_Id is
begin
return Chars (Pragma_Identifier (N));
end Pragma_Name_Unmapped;
------------------------------------
-- Helpers for Walk_Sinfo_Fields* --
------------------------------------
function Get_Node_Field_Union is new
Atree.Atree_Private_Part.Get_32_Bit_Field (Union_Id) with Inline;
procedure Set_Node_Field_Union is new
Atree.Atree_Private_Part.Set_32_Bit_Field (Union_Id) with Inline;
use Seinfo;
function Is_In_Union_Id (F_Kind : Field_Kind) return Boolean is
-- True if the field type is one that can be converted to Types.Union_Id
(case F_Kind is
when Node_Id_Field
| List_Id_Field
| Elist_Id_Field
| Name_Id_Field
| String_Id_Field
| Valid_Uint_Field
| Unat_Field
| Upos_Field
| Nonzero_Uint_Field
| Uint_Field
| Ureal_Field
| Union_Id_Field => True,
when Flag_Field
| Node_Kind_Type_Field
| Entity_Kind_Type_Field
| Source_Ptr_Field
| Small_Paren_Count_Type_Field
| Convention_Id_Field
| Component_Alignment_Kind_Field
| Mechanism_Type_Field => False);
-----------------------
-- Walk_Sinfo_Fields --
-----------------------
procedure Walk_Sinfo_Fields (N : Node_Id) is
Fields : Node_Field_Array renames
Node_Field_Table (Nkind (N)).all;
begin
for J in Fields'Range loop
if Fields (J) /= F_Link then -- Don't walk Parent!
declare
Desc : Field_Descriptor renames
Field_Descriptors (Fields (J));
pragma Assert (Desc.Type_Only = No_Type_Only);
-- Type_Only is for entities
begin
if Is_In_Union_Id (Desc.Kind) then
Action (Get_Node_Field_Union (N, Desc.Offset));
end if;
end;
end if;
end loop;
end Walk_Sinfo_Fields;
--------------------------------
-- Walk_Sinfo_Fields_Pairwise --
--------------------------------
procedure Walk_Sinfo_Fields_Pairwise (N1, N2 : Node_Id) is
pragma Assert (Nkind (N1) = Nkind (N2));
Fields : Node_Field_Array renames
Node_Field_Table (Nkind (N1)).all;
begin
for J in Fields'Range loop
if Fields (J) /= F_Link then -- Don't walk Parent!
declare
Desc : Field_Descriptor renames
Field_Descriptors (Fields (J));
pragma Assert (Desc.Type_Only = No_Type_Only);
-- Type_Only is for entities
begin
if Is_In_Union_Id (Desc.Kind) then
Set_Node_Field_Union
(N1, Desc.Offset,
Transform (Get_Node_Field_Union (N2, Desc.Offset)));
end if;
end;
end if;
end loop;
end Walk_Sinfo_Fields_Pairwise;
---------------------
-- Map_Pragma_Name --
---------------------
-- We don't want to introduce a dependence on some hash table package or
-- similar, so we use a simple array of Key => Value pairs, and do a linear
-- search. Linear search is plenty efficient, given that we don't expect
-- more than a couple of entries in the mapping.
type Name_Pair is record
Key : Name_Id;
Value : Name_Id;
end record;
type Pragma_Map_Index is range 1 .. 100;
Pragma_Map : array (Pragma_Map_Index) of Name_Pair;
Last_Pair : Pragma_Map_Index'Base range 0 .. Pragma_Map_Index'Last := 0;
procedure Map_Pragma_Name (From, To : Name_Id) is
begin
if Last_Pair = Pragma_Map'Last then
raise Too_Many_Pragma_Mappings;
end if;
Last_Pair := Last_Pair + 1;
Pragma_Map (Last_Pair) := (Key => From, Value => To);
end Map_Pragma_Name;
-----------------
-- Pragma_Name --
-----------------
function Pragma_Name (N : Node_Id) return Name_Id is
Result : constant Name_Id := Pragma_Name_Unmapped (N);
begin
for J in Pragma_Map'First .. Last_Pair loop
if Result = Pragma_Map (J).Key then
return Pragma_Map (J).Value;
end if;
end loop;
return Result;
end Pragma_Name;
end Sinfo.Utils;
|
stcarrez/ada-css | Ada | 2,344 | adb | -----------------------------------------------------------------------
-- css-commands-analyze -- List command for CSS tools
-- Copyright (C) 2018, 2020 Stephane Carrez
-- Written by Stephane Carrez ([email protected])
--
-- Licensed under the Apache License, Version 2.0 (the "License");
-- you may not use this file except in compliance with the License.
-- You may obtain a copy of the License at
--
-- http://www.apache.org/licenses/LICENSE-2.0
--
-- Unless required by applicable law or agreed to in writing, software
-- distributed under the License is distributed on an "AS IS" BASIS,
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-- See the License for the specific language governing permissions and
-- limitations under the License.
-----------------------------------------------------------------------
with CSS.Analysis.Duplicates;
with CSS.Analysis.Rules.Main;
package body CSS.Commands.Analyze is
-- ------------------------------
-- Execute the command with the arguments.
-- ------------------------------
overriding
procedure Execute (Cmd : in out Command;
Name : in String;
Args : in Argument_List'Class;
Context : in out CSS.Commands.Context_Type) is
pragma Unreferenced (Cmd, Name);
begin
CSS.Commands.Load (Args, Context);
CSS.Analysis.Duplicates.Analyze (Context.Doc.Rules, Context.Err_Handler,
Context.Dup_Rules);
CSS.Analysis.Rules.Main.Analyze (Context.Doc, Context.Err_Handler);
-- Err_Handler.Iterate (Print_Message'Access);
CSS.Analysis.Classes.Analyze (Context.Doc, Context.Class_Map,
Context.Err_Handler);
end Execute;
-- ------------------------------
-- Write the help associated with the command.
-- ------------------------------
overriding
procedure Help (Cmd : in out Command;
Name : in String;
Context : in out CSS.Commands.Context_Type) is
pragma Unreferenced (Cmd, Name);
Console : constant CSS.Commands.Console_Access := Context.Console;
begin
Console.Notice (N_HELP, "analyze: analyze the CSS files");
end Help;
end CSS.Commands.Analyze;
|
tum-ei-rcs/StratoX | Ada | 1,651 | ads | -- Institution: Technische Universitaet Muenchen
-- Department: Realtime Computer Systems (RCS)
-- Project: StratoX
--
-- Authors: Martin Becker ([email protected]>
with HIL.Devices.Timers;
with Units; use Units;
with HAL; use HAL;
-- @summary
-- Target-independent specification for simple HIL of Hardware Timers
package HIL.Timers with SPARK_Mode => Off is
-- TODO: this package is unfinished business. It simply allows to set up
-- a very basic timer configuration w/o interrupts. This makes sense,
-- the alternative function of the respective timer is activated as pinout.
-- In that case, the timer's overflow etc. can be given to a device,
-- e.g., as square signal to a buzzer, or LED (dimming).
subtype HIL_Timer is HIL.Devices.Timers.HIL_Timer; -- expose type
subtype HIL_Timer_Channel is HIL.Devices.Timers.HIL_Timer_Channel;
procedure Initialize (t : in out HIL_Timer);
procedure Enable (t : in out HIL_Timer; ch : HIL.Timers.HIL_Timer_Channel);
procedure Disable (t : in out HIL_Timer; ch : HIL.Timers.HIL_Timer_Channel);
procedure Configure_OC_Toggle
(This : in out HIL_Timer;
Frequency : Frequency_Type;
Channel : HIL_Timer_Channel)
with Pre => Frequency in 1.0 .. 1_000_000.0;
-- configure output compare toggle on given timer and channel.
-- the channel is toggled every time the timer reaches zero.
-- i.e., the channel shows a 50% square waveform with given
-- frequency.
-- procedure Set_Autoreload (This : in out HIL_Timer; Value : Word);
-- procedure Set_Counter (This : in out HIL_Timer; Value : Word);
end HIL.Timers;
|
stcarrez/dynamo | Ada | 4,184 | adb | -- part of AdaYaml, (c) 2017 Felix Krause
-- released under the terms of the MIT license, see the file "copying.txt"
with Ada.Unchecked_Deallocation;
with Yaml.Tags;
package body Yaml is
function Version_Major return Natural is (1);
function Version_Minor return Natural is (3);
function Version_Patch return Natural is (0);
use type Text.Reference;
function Default_Properties return Properties is
((Anchor => Text.Empty, Tag => Tags.Question_Mark));
function Is_Empty (Props : Properties) return Boolean is
((Props.Anchor = Text.Empty and then Props.Tag = Tags.Question_Mark));
function To_String (E : Event) return String is
function Prop_String (A : Properties) return String is
((if A.Anchor = Text.Empty then "" else " &" & To_String (A.Anchor)) &
(if A.Tag = Tags.Question_Mark then "" else " <" & To_String (A.Tag) & '>'));
function Scalar_Indicator (S : Scalar_Style_Type) return String is
((case S is
when Plain | Any => " :",
when Single_Quoted => " '",
when Double_Quoted => " """,
when Literal => " |",
when Folded => " >"));
function Escaped (C : Text.Reference) return String;
function Escaped (C : Text.Reference) return String is
S : constant String := To_String (C);
Ret : String (1 .. S'Length * 2);
Pos : Positive := 1;
begin
for I in S'Range loop
case S (I) is
when Character'Val (7) =>
Ret (Pos .. Pos + 1) := "\a";
Pos := Pos + 2;
when Character'Val (8) =>
Ret (Pos .. Pos + 1) := "\b";
Pos := Pos + 2;
when Character'Val (9) =>
Ret (Pos .. Pos + 1) := "\t";
Pos := Pos + 2;
when Character'Val (10) =>
Ret (Pos .. Pos + 1) := "\n";
Pos := Pos + 2;
when Character'Val (13) =>
Ret (Pos .. Pos + 1) := "\r";
Pos := Pos + 2;
when '\' =>
Ret (Pos .. Pos + 1) := "\\";
Pos := Pos + 2;
when others =>
Ret (Pos) := S (I);
Pos := Pos + 1;
end case;
end loop;
return Ret (1 .. Pos - 1);
end Escaped;
begin
case E.Kind is
when Stream_Start => return "+STR";
when Stream_End => return "-STR";
when Document_Start =>
return "+DOC" & (if E.Implicit_Start then "" else " ---");
when Document_End =>
return "-DOC" & (if E.Implicit_End then "" else " ...");
when Mapping_Start =>
return "+MAP" & Prop_String (E.Collection_Properties);
when Mapping_End =>
return "-MAP";
when Sequence_Start =>
return "+SEQ" & Prop_String (E.Collection_Properties);
when Sequence_End =>
return "-SEQ";
when Scalar =>
return "=VAL" & Prop_String (E.Scalar_Properties) &
Scalar_Indicator (E.Scalar_Style) & Escaped (E.Content);
when Alias =>
return "=ALI *" & To_String (E.Target);
when Annotation_Start =>
return "+ANN" & Prop_String (E.Annotation_Properties) & ' ' &
To_String (E.Namespace & E.Name);
when Annotation_End =>
return "-ANN";
end case;
end To_String;
procedure Increase_Refcount (Object : not null access Refcount_Base'Class) is
begin
Object.Refcount := Object.Refcount + 1;
end Increase_Refcount;
procedure Decrease_Refcount (Object : not null access Refcount_Base'Class) is
type Base_Access is access all Refcount_Base'Class;
Ptr : Base_Access := Base_Access (Object);
procedure Free is new Ada.Unchecked_Deallocation (Refcount_Base'Class,
Base_Access);
begin
Ptr.Refcount := Ptr.Refcount - 1;
if Ptr.Refcount = 0 then
Free (Ptr);
end if;
end Decrease_Refcount;
end Yaml;
|
erik/ada-irc | Ada | 2,079 | adb | with Ada.Text_IO;
package body Irc.Message is
function Parse_Line (Line : in SU.Unbounded_String) return Message is
Msg : Message;
Index : Natural := 2;
Start, Finish : Natural := 0;
Size : Natural := SU.Length (Line);
procedure Read_Word;
procedure Read_Word is
Next_WS : Natural := SU.Index (Line, " ", Index);
begin
Start := Index;
if Next_WS > Size then
raise Parse_Error;
end if;
Finish := Next_WS - 1;
Index := Next_WS + 1;
end Read_Word;
begin
if SU.To_String (Line) (1) /= ':' then
if SU.Index (Line, "PING") = 1 then
Msg.Sender := SU.To_Unbounded_String ("");
Msg.Command := SU.To_Unbounded_String ("PING");
Msg.Args := SU.Unbounded_Slice (Line, 1 + 6, Size);
return Msg;
end if;
raise Parse_Error;
end if;
Read_Word;
Msg.Sender := SU.Unbounded_Slice (Line, Start, Finish);
Read_Word;
Msg.Command := SU.Unbounded_Slice (Line, Start, Finish);
Msg.Args := SU.Unbounded_Slice (Line, Finish + 2, Size);
if Msg.Command = "PRIVMSG" then
Msg.Parse_Privmsg;
end if;
return Msg;
end Parse_Line;
procedure Print (This : Message) is
use Ada.Text_IO;
begin
Ada.Text_IO.Put_Line
(SU.To_String
(This.Sender & "» " & This.Command & " " & This.Args));
end Print;
procedure Parse_Privmsg (Msg : in out Message) is
begin
Msg.Privmsg.Target := SU.Unbounded_Slice
(Msg.Args, 1, SU.Index (Msg.Args, " ") - 1);
Msg.Privmsg.Content := SU.Unbounded_Slice
(Msg.Args, SU.Index (Msg.Args, ":"), SU.Length (Msg.Args));
-- message sent to nick directly instead of in a channel
if SU.To_String (Msg.Privmsg.Target) (1) /= '#' then
Msg.Privmsg.Target := SU.To_Unbounded_String
(SU.Slice (Msg.Sender, 1, SU.Index (Msg.Sender, "!") - 1));
end if;
end Parse_Privmsg;
end Irc.Message;
|
KyrreHaugland/TTK4145Sanntidsprogrammering-Exercise7 | Ada | 3,863 | adb | with Ada.Text_IO, Ada.Integer_Text_IO, Ada.Numerics.Float_Random;
use Ada.Text_IO, Ada.Integer_Text_IO, Ada.Numerics.Float_Random;
procedure exercise7 is
Count_Failed : exception; -- Exception to be raised when counting fails
Gen : Generator; -- Random number generator
protected type Transaction_Manager (N : Positive) is
entry Finished;
function Commit return Boolean;
procedure Signal_Abort;
private
Finished_Gate_Open : Boolean := False;
Aborted : Boolean := False;
Should_Commit : Boolean := True;
end Transaction_Manager;
protected body Transaction_Manager is
entry Finished when Finished_Gate_Open or Finished'Count = N is
begin
------------------------------------------
-- PART 3: Complete the exit protocol here
------------------------------------------
Should_commit := not Aborted;
if Finished'Count > 0 then
Finished_Gate_Open := true;
else
Finished_Gate_Open := false;
end if;
if Finished'Count = 0 then
Aborted := false;
end if;
-------------------------------------------
end Finished;
procedure Signal_Abort is
begin
Aborted := True;
end Signal_Abort;
function Commit return Boolean is
begin
return Should_Commit;
end Commit;
end Transaction_Manager;
function Unreliable_Slow_Add (x : Integer) return Integer is
Error_Rate : Constant := 0.15; -- (between 0 and 1)
begin
-------------------------------------------
-- PART 1: Create the transaction work here
-------------------------------------------
if Random(Gen) < Error_Rate then
raise Count_Failed; -- raise = throw
else
delay 4*Duration(Random(Gen));
return x+10;
end if;
--------------------------------------------
end Unreliable_Slow_Add;
task type Transaction_Worker (Initial : Integer; Manager : access Transaction_Manager);
task body Transaction_Worker is
Num : Integer := Initial;
Prev : Integer := Num;
Round_Num : Integer := 0;
begin
Put_Line ("Worker" & Integer'Image(Initial) & " started");
loop
Put_Line ("Worker" & Integer'Image(Initial) & " started round" & Integer'Image(Round_Num));
Round_Num := Round_Num + 1;
---------------------------------------
-- PART 2: Do the transaction work here
---------------------------------------
begin
Prev := Num;
Num := Unreliable_Slow_Add(Num);
exception
when Count_Failed => Manager.Signal_Abort;
end;
Manager.Finished;
----------------------------------------
if Manager.Commit = True then
Put_Line (" Worker" & Integer'Image(Initial) & " comitting" & Integer'Image(Num));
else
Put_Line (" Worker" & Integer'Image(Initial) &
" reverting from" & Integer'Image(Num) &
" to" & Integer'Image(Prev));
-------------------------------------------
-- PART 2: Roll back to previous value here
-------------------------------------------
Num := Prev;
-------------------------------------------
end if;
Prev := Num;
delay 0.5;
end loop;
end Transaction_Worker;
Manager : aliased Transaction_Manager (3);
Worker_1 : Transaction_Worker (0, Manager'Access);
Worker_2 : Transaction_Worker (1, Manager'Access);
Worker_3 : Transaction_Worker (2, Manager'Access);
begin
Reset(Gen); -- Seed the
--number generator
end exercise7;
|
reznikmm/matreshka | Ada | 4,696 | adb | ------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- Open Document Toolkit --
-- --
-- Runtime Library Component --
-- --
------------------------------------------------------------------------------
-- --
-- Copyright © 2014, Vadim Godunko <[email protected]> --
-- All rights reserved. --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions --
-- are met: --
-- --
-- * Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- --
-- * Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in the --
-- documentation and/or other materials provided with the distribution. --
-- --
-- * Neither the name of the Vadim Godunko, IE nor the names of its --
-- contributors may be used to endorse or promote products derived from --
-- this software without specific prior written permission. --
-- --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR --
-- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
-- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED --
-- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR --
-- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF --
-- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING --
-- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS --
-- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
-- --
------------------------------------------------------------------------------
-- $Revision$ $Date$
------------------------------------------------------------------------------
with Matreshka.DOM_Documents;
with Matreshka.ODF_String_Constants;
with ODF.DOM.Iterators;
with ODF.DOM.Visitors;
package body Matreshka.ODF_Table.Number_Rows_Repeated_Attributes is
------------
-- Create --
------------
overriding function Create
(Parameters : not null access Matreshka.DOM_Attributes.Attribute_L2_Parameters)
return Table_Number_Rows_Repeated_Attribute_Node is
begin
return Self : Table_Number_Rows_Repeated_Attribute_Node do
Matreshka.ODF_Table.Constructors.Initialize
(Self'Unchecked_Access,
Parameters.Document,
Matreshka.ODF_String_Constants.Table_Prefix);
end return;
end Create;
--------------------
-- Get_Local_Name --
--------------------
overriding function Get_Local_Name
(Self : not null access constant Table_Number_Rows_Repeated_Attribute_Node)
return League.Strings.Universal_String
is
pragma Unreferenced (Self);
begin
return Matreshka.ODF_String_Constants.Number_Rows_Repeated_Attribute;
end Get_Local_Name;
begin
Matreshka.DOM_Documents.Register_Attribute
(Matreshka.ODF_String_Constants.Table_URI,
Matreshka.ODF_String_Constants.Number_Rows_Repeated_Attribute,
Table_Number_Rows_Repeated_Attribute_Node'Tag);
end Matreshka.ODF_Table.Number_Rows_Repeated_Attributes;
|
reznikmm/matreshka | Ada | 3,675 | adb | ------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- Ada Modeling Framework --
-- --
-- Runtime Library Component --
-- --
------------------------------------------------------------------------------
-- --
-- Copyright © 2012, Vadim Godunko <[email protected]> --
-- All rights reserved. --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions --
-- are met: --
-- --
-- * Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- --
-- * Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in the --
-- documentation and/or other materials provided with the distribution. --
-- --
-- * Neither the name of the Vadim Godunko, IE nor the names of its --
-- contributors may be used to endorse or promote products derived from --
-- this software without specific prior written permission. --
-- --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR --
-- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
-- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED --
-- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR --
-- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF --
-- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING --
-- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS --
-- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
-- --
------------------------------------------------------------------------------
-- $Revision$ $Date$
------------------------------------------------------------------------------
package body AMF.DG.Path_Command_Collections.Internals is
---------------
-- To_Holder --
---------------
function To_Holder
(Item : AMF.DG.Sequence_Of_Path_Command) return League.Holders.Holder is
begin
return League.Holders.Empty_Holder;
end To_Holder;
end AMF.DG.Path_Command_Collections.Internals;
|
Fabien-Chouteau/GESTE | Ada | 2,182 | ads | pragma Style_Checks (Off);
with Interfaces.C; use Interfaces.C;
with SDL_SDL_stdinc_h;
with SDL_SDL_keysym_h;
with Interfaces.C.Strings;
package SDL_SDL_keyboard_h is
SDL_ALL_HOTKEYS : constant := 16#FFFFFFFF#; -- ../include/SDL/SDL_keyboard.h:67
SDL_DEFAULT_REPEAT_DELAY : constant := 500; -- ../include/SDL/SDL_keyboard.h:84
SDL_DEFAULT_REPEAT_INTERVAL : constant := 30; -- ../include/SDL/SDL_keyboard.h:85
type SDL_keysym is record
scancode : aliased SDL_SDL_stdinc_h.Uint8; -- ../include/SDL/SDL_keyboard.h:60
sym : aliased SDL_SDL_keysym_h.SDLKey; -- ../include/SDL/SDL_keyboard.h:61
c_mod : aliased SDL_SDL_keysym_h.SDLMod; -- ../include/SDL/SDL_keyboard.h:62
unicode : aliased SDL_SDL_stdinc_h.Uint16; -- ../include/SDL/SDL_keyboard.h:63
end record;
pragma Convention (C_Pass_By_Copy, SDL_keysym); -- ../include/SDL/SDL_keyboard.h:59
function SDL_EnableUNICODE (enable : int) return int; -- ../include/SDL/SDL_keyboard.h:82
pragma Import (C, SDL_EnableUNICODE, "SDL_EnableUNICODE");
function SDL_EnableKeyRepeat (c_delay : int; interval : int) return int; -- ../include/SDL/SDL_keyboard.h:98
pragma Import (C, SDL_EnableKeyRepeat, "SDL_EnableKeyRepeat");
procedure SDL_GetKeyRepeat (c_delay : access int; interval : access int); -- ../include/SDL/SDL_keyboard.h:99
pragma Import (C, SDL_GetKeyRepeat, "SDL_GetKeyRepeat");
function SDL_GetKeyState (numkeys : access int) return access SDL_SDL_stdinc_h.Uint8; -- ../include/SDL/SDL_keyboard.h:110
pragma Import (C, SDL_GetKeyState, "SDL_GetKeyState");
function SDL_GetModState return SDL_SDL_keysym_h.SDLMod; -- ../include/SDL/SDL_keyboard.h:115
pragma Import (C, SDL_GetModState, "SDL_GetModState");
procedure SDL_SetModState (modstate : SDL_SDL_keysym_h.SDLMod); -- ../include/SDL/SDL_keyboard.h:121
pragma Import (C, SDL_SetModState, "SDL_SetModState");
function SDL_GetKeyName (key : SDL_SDL_keysym_h.SDLKey) return Interfaces.C.Strings.chars_ptr; -- ../include/SDL/SDL_keyboard.h:126
pragma Import (C, SDL_GetKeyName, "SDL_GetKeyName");
end SDL_SDL_keyboard_h;
|
AdaCore/training_material | Ada | 147 | adb | with Ada.Text_IO;
procedure Main is
begin
for J in 0 .. 10 when J mod 2 /= 0 loop
Ada.Text_IO.Put_Line (J'Image);
end loop;
end Main;
|
pmderodat/sdlada | Ada | 19,339 | adb | --------------------------------------------------------------------------------------------------------------------
-- 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.
--------------------------------------------------------------------------------------------------------------------
with Ada.Unchecked_Conversion;
with SDL.Error;
package body SDL.Video.Surfaces is
use type C.int;
function Pixel_Format (Self : in Surface) return Pixel_Formats.Pixel_Format_Access is
begin
return Self.Internal.Pixel_Format;
end Pixel_Format;
function Size (Self : in Surface) return SDL.Sizes is
begin
return SDL.Sizes'(Self.Internal.Width, Self.Internal.Height);
end Size;
function Pixels (Self : in Surface) return System.Address is
use type C.int;
begin
if Must_Lock (Self) and then Self.Internal.Locked <= 0 then
raise Surface_Error with "Surface must be locked before access can be gained to the pixel data.";
end if;
return Self.Internal.Pixels;
end Pixels;
package body User_Data is
function Convert is new Ada.Unchecked_Conversion (Source => Data_Pointer,
Target => User_Data_Pointer);
function Convert is new Ada.Unchecked_Conversion (Source => User_Data_Pointer,
Target => Data_Pointer);
function Get (Self : in Surface) return Data_Pointer is
begin
return Convert (Self.Internal.User_Data);
end Get;
procedure Set (Self : in out Surface; Data : in Data_Pointer) is
begin
Self.Internal.User_Data := Convert (Data);
end Set;
end User_Data;
procedure Blit (Self : in out Surface;
Source : in Surface) is
function SDL_Blit_Surface (S : in Internal_Surface_Pointer;
SR : access Rectangles.Rectangle;
D : in Internal_Surface_Pointer;
DR : access Rectangles.Rectangle) return C.int with
Import => True,
Convention => C,
External_Name => "SDL_UpperBlit"; -- SDL_BlitSurface is a macro in SDL_surface.h
Result : C.int := SDL_Blit_Surface (Source.Internal, null, Self.Internal, null);
begin
if Result /= SDL.Success then
raise Surface_Error with SDL.Error.Get;
end if;
end Blit;
procedure Blit (Self : in out Surface;
Self_Area : in out Rectangles.Rectangle;
Source : in Surface;
Source_Area : in out Rectangles.Rectangle) is
function SDL_Blit_Surface (S : in Internal_Surface_Pointer;
SR : access Rectangles.Rectangle;
D : in Internal_Surface_Pointer;
DR : access Rectangles.Rectangle) return C.int with
Import => True,
Convention => C,
External_Name => "SDL_UpperBlit"; -- SDL_BlitSurface is a macro in SDL_surface.h
use type Rectangles.Rectangle;
Result : C.int := 0;
Src_Area : aliased Rectangles.Rectangle := Source_Area;
Dest_Area : aliased Rectangles.Rectangle := Self_Area;
begin
if Dest_Area = Rectangles.Null_Rectangle then
if Src_Area = Rectangles.Null_Rectangle then
Result := SDL_Blit_Surface (Source.Internal, null, Self.Internal, null);
else
Result := SDL_Blit_Surface (Source.Internal, Src_Area'Access, Self.Internal, null);
Source_Area := Src_Area;
end if;
else
if Src_Area = Rectangles.Null_Rectangle then
Result := SDL_Blit_Surface (Source.Internal, null, Self.Internal, Dest_Area'Access);
else
Result := SDL_Blit_Surface (Source.Internal, Src_Area'Access, Self.Internal, Dest_Area'Access);
Source_Area := Src_Area;
end if;
Self_Area := Dest_Area;
end if;
if Result /= SDL.Success then
raise Surface_Error with SDL.Error.Get;
end if;
end Blit;
procedure Blit_Scaled (Self : in out Surface;
Source : in Surface) is
function SDL_Blit_Scaled (S : in Internal_Surface_Pointer;
SR : access Rectangles.Rectangle;
D : in Internal_Surface_Pointer;
DR : access Rectangles.Rectangle) return C.int with
Import => True,
Convention => C,
External_Name => "SDL_UpperBlitScaled"; -- SDL_BlitScaled is a macro in SDL_surface.h
Result : C.int := SDL_Blit_Scaled (Source.Internal, null, Self.Internal, null);
begin
if Result /= SDL.Success then
raise Surface_Error with SDL.Error.Get;
end if;
end Blit_Scaled;
procedure Blit_Scaled (Self : in out Surface;
Self_Area : in out Rectangles.Rectangle;
Source : in Surface;
Source_Area : in Rectangles.Rectangle := Rectangles.Null_Rectangle) is
function SDL_Blit_Scaled (S : in Internal_Surface_Pointer;
SR : in Rectangles.Rectangle;
D : in Internal_Surface_Pointer;
DR : access Rectangles.Rectangle) return C.int with
Import => True,
Convention => C,
External_Name => "SDL_UpperBlitScaled"; -- SDL_BlitScaled is a macro in SDL_surface.h
use type Rectangles.Rectangle;
Result : C.int := 0;
Area : aliased Rectangles.Rectangle;
begin
if Self_Area = Rectangles.Null_Rectangle then
Result := SDL_Blit_Scaled (Source.Internal, Source_Area, Self.Internal, null);
else
Result := SDL_Blit_Scaled (Source.Internal, Source_Area, Self.Internal, Area'Access);
Self_Area := Area;
end if;
if Result /= SDL.Success then
raise Surface_Error with SDL.Error.Get;
end if;
end Blit_Scaled;
procedure Lower_Blit (Self : in out Surface;
Self_Area : in Rectangles.Rectangle;
Source : in Surface;
Source_Area : in Rectangles.Rectangle) is
function SDL_Lower_Blit (S : in Internal_Surface_Pointer;
SR : in Rectangles.Rectangle;
D : in Internal_Surface_Pointer;
DR : in Rectangles.Rectangle) return C.int with
Import => True,
Convention => C,
External_Name => "SDL_LowerBlit";
Result : C.int := SDL_Lower_Blit (Source.Internal, Source_Area, Self.Internal, Self_Area);
begin
if Result /= SDL.Success then
raise Surface_Error with SDL.Error.Get;
end if;
end Lower_Blit;
procedure Lower_Blit_Scaled (Self : in out Surface;
Self_Area : in Rectangles.Rectangle;
Source : in Surface;
Source_Area : in Rectangles.Rectangle) is
function SDL_Lower_Blit_Scaled (S : in Internal_Surface_Pointer;
SR : in Rectangles.Rectangle;
D : in Internal_Surface_Pointer;
DR : in Rectangles.Rectangle) return C.int with
Import => True,
Convention => C,
External_Name => "SDL_LowerBlitScaled";
Result : C.int := SDL_Lower_Blit_Scaled (Source.Internal, Source_Area, Self.Internal, Self_Area);
begin
if Result /= SDL.Success then
raise Surface_Error with SDL.Error.Get;
end if;
end Lower_Blit_Scaled;
procedure Fill (Self : in out Surface;
Area : in Rectangles.Rectangle;
Colour : in Interfaces.Unsigned_32) is
function SDL_Fill_Rect (S : in Internal_Surface_Pointer;
Rect : in Rectangles.Rectangle;
Colour : in Interfaces.Unsigned_32) return C.int with
Import => True,
Convention => C,
External_Name => "SDL_FillRect";
Result : C.int := SDL_Fill_Rect (Self.Internal, Area, Colour);
begin
if Result < SDL.Success then
raise Surface_Error with SDL.Error.Get;
end if;
end Fill;
procedure Fill (Self : in out Surface;
Areas : in Rectangles.Rectangle_Arrays;
Colour : in Interfaces.Unsigned_32) is
function SDL_Fill_Rects (S : in Internal_Surface_Pointer;
Rects : in Rectangles.Rectangle_Arrays;
Count : in C.int;
Colour : in Interfaces.Unsigned_32) return C.int with
Import => True,
Convention => C,
External_Name => "SDL_FillRects";
Result : C.int := SDL_Fill_Rects (Self.Internal, Areas, Areas'Length, Colour);
begin
if Result < SDL.Success then
raise Surface_Error with SDL.Error.Get;
end if;
end Fill;
function Clip_Rectangle (Self : in Surface) return Rectangles.Rectangle is
procedure SDL_Get_Clip_Rect (S : in Internal_Surface_Pointer;
R : out Rectangles.Rectangle) with
Import => True,
Convention => C,
External_Name => "SDL_GetClipRect";
begin
return Result : Rectangles.Rectangle := Rectangles.Null_Rectangle do
SDL_Get_Clip_Rect (Self.Internal, Result);
end return;
end Clip_Rectangle;
procedure Set_Clip_Rectangle (Self : in out Surface; Now : in Rectangles.Rectangle) is
function SDL_Set_Clip_Rect (S : in Internal_Surface_Pointer;
R : in Rectangles.Rectangle) return SDL_Bool with
Import => True,
Convention => C,
External_Name => "SDL_SetClipRect";
Result : SDL_Bool := SDL_Set_Clip_Rect (S => Self.Internal, R => Now);
begin
if Result = SDL_False then
raise Surface_Error with SDL.Error.Get;
end if;
end Set_Clip_Rectangle;
function Colour_Key (Self : in Surface) return Palettes.Colour is
function SDL_Get_Color_Key (S : in Internal_Surface_Pointer;
K : out Interfaces.Unsigned_32) return C.int with
Import => True,
Convention => C,
External_Name => "SDL_GetColorKey";
Key : Interfaces.Unsigned_32;
Result : C.int := SDL_Get_Color_Key (Self.Internal, Key);
begin
if Result < SDL.Success then
-- TODO: The SDL source does not set an error message, see https://bugzilla.libsdl.org/show_bug.cgi?id=3992
raise Surface_Error with "No colour key set for this surface."; -- with SDL.Error.Get;
end if;
return Pixel_Formats.To_Colour (Pixel => Key,
Format => Self.Pixel_Format);
end Colour_Key;
procedure Set_Colour_Key (Self : in out Surface; Now : in Palettes.Colour; Enable : in Boolean := True) is
-- TODO: This can work as an "in out Internal_Surface" as the compiler will pass the object as a reference.
-- Should the entire API use this? For review!
function SDL_Set_Color_Key (S : in Internal_Surface_Pointer;
F : in C.int;
K : in Interfaces.Unsigned_32) return C.int with
Import => True,
Convention => C,
External_Name => "SDL_SetColorKey";
Result : C.int := SDL_Set_Color_Key (S => Self.Internal,
F => (if Enable then 1 else 0),
K => Pixel_Formats.To_Pixel (Colour => Now,
Format => Self.Pixel_Format));
begin
if Result < SDL.Success then
raise Surface_Error with SDL.Error.Get;
end if;
end Set_Colour_Key;
function Alpha_Blend (Self : in Surface) return Palettes.Colour_Component is
function SDL_Get_Surface_Alpha_Mod (S : in Internal_Surface_Pointer;
A : out Palettes.Colour_Component) return C.int with
Import => True,
Convention => C,
External_Name => "SDL_GetSurfaceAlphaMod";
Alpha : Palettes.Colour_Component;
Result : C.int := SDL_Get_Surface_Alpha_Mod (S => Self.Internal, A => Alpha);
begin
if Result < SDL.Success then
raise Surface_Error with SDL.Error.Get;
end if;
return Alpha;
end Alpha_Blend;
procedure Set_Alpha_Blend (Self : in out Surface; Now : in Palettes.Colour_Component) is
function SDL_Set_Surface_Alpha_Mod (S : in Internal_Surface_Pointer;
A : in Palettes.Colour_Component) return C.int with
Import => True,
Convention => C,
External_Name => "SDL_SetSurfaceAlphaMod";
Result : C.int := SDL_Set_Surface_Alpha_Mod (S => Self.Internal, A => Now);
begin
if Result < SDL.Success then
raise Surface_Error with SDL.Error.Get;
end if;
end Set_Alpha_Blend;
function Blend_Mode (Self : in Surface) return Blend_Modes is
function SDL_Get_Surface_Blend_Mode (S : in Internal_Surface_Pointer;
B : out Blend_Modes) return C.int with
Import => True,
Convention => C,
External_Name => "SDL_GetSurfaceAlphaMod";
Blend_Mode : Blend_Modes;
Result : C.int := SDL_Get_Surface_Blend_Mode (S => Self.Internal, B => Blend_Mode);
begin
if Result < SDL.Success then
raise Surface_Error with SDL.Error.Get;
end if;
return Blend_Mode;
end Blend_Mode;
procedure Set_Blend_Mode (Self : in out Surface; Now : in Blend_Modes) is
function SDL_Set_Surface_Blend_Mode (S : in Internal_Surface_Pointer;
B : in Blend_Modes) return C.int with
Import => True,
Convention => C,
External_Name => "SDL_SetSurfaceBlendMode";
Result : C.int := SDL_Set_Surface_Blend_Mode (S => Self.Internal, B => Now);
begin
if Result < SDL.Success then
raise Surface_Error with SDL.Error.Get;
end if;
end Set_Blend_Mode;
function Colour (Self : in Surface) return Palettes.RGB_Colour is
function SDL_Get_Surface_Color_Mod (S : in Internal_Surface_Pointer;
R : out Palettes.Colour_Component;
G : out Palettes.Colour_Component;
B : out Palettes.Colour_Component) return C.int with
Import => True,
Convention => C,
External_Name => "SDL_GetSurfaceColorMod";
Red : Palettes.Colour_Component;
Green : Palettes.Colour_Component;
Blue : Palettes.Colour_Component;
Result : C.int := SDL_Get_Surface_Color_Mod (S => Self.Internal, R => Red, G => Green, B => Blue);
begin
if Result < SDL.Success then
raise Surface_Error with SDL.Error.Get;
end if;
return (Red, Green, Blue);
end Colour;
procedure Set_Colour (Self : in out Surface; Now : in Palettes.RGB_Colour) is
function SDL_Set_Surface_Color_Mod (S : in Internal_Surface_Pointer;
R : in Palettes.Colour_Component;
G : in Palettes.Colour_Component;
B : in Palettes.Colour_Component) return C.int with
Import => True,
Convention => C,
External_Name => "SDL_SetSurfaceColorMod";
Result : C.int := SDL_Set_Surface_Color_Mod (S => Self.Internal, R => Now.Red, G => Now.Green, B => Now.Blue);
begin
if Result < SDL.Success then
raise Surface_Error with SDL.Error.Get;
end if;
end Set_Colour;
procedure Lock (Self : in out Surface) is
function SDL_Lock_Surface (Self : in Internal_Surface_Pointer) return C.int with
Import => True,
Convention => C,
External_Name => "SDL_LockSurface";
Result : C.int := SDL_Lock_Surface (Self.Internal);
begin
if Result < SDL.Success then
raise Surface_Error with SDL.Error.Get;
end if;
end Lock;
procedure Unlock (Self : in out Surface) is
procedure SDL_Unlock_Surface (Self : in Internal_Surface_Pointer) with
Import => True,
Convention => C,
External_Name => "SDL_UnlockSurface";
begin
SDL_Unlock_Surface (Self.Internal);
end Unlock;
procedure Set_RLE (Self : in out Surface; Enabled : in Boolean) is
function SDL_Set_Surface_RLE (Self : in Internal_Surface_Pointer; Enabled : in C.int) return C.int with
Import => True,
Convention => C,
External_Name => "SDL_SetSurfaceRLE";
Result : C.int := SDL_Set_Surface_RLE (Self.Internal, C.int (if Enabled then 1 else 0));
begin
if Result < SDL.Success then
raise Surface_Error with SDL.Error.Get;
end if;
end Set_RLE;
-- This is equivalent to the macro SDL_MUSTLOCK in SDL_surface.h.
function Must_Lock (Self : in Surface) return Boolean is
begin
return (Self.Internal.Flags and RLE_Encoded) = RLE_Encoded;
end Must_Lock;
overriding
procedure Adjust (Self : in out Surface) is
begin
-- if Self.Internal.Flags and Dont_Free = Dont_Free then
-- end if;
if Self.Internal /= null and Self.Owns then
Self.Internal.Reference_Count := Self.Internal.Reference_Count + 1;
end if;
end Adjust;
overriding
procedure Finalize (Self : in out Surface) is
procedure SDL_Free_Surface (S : in Internal_Surface_Pointer) with
Import => True,
Convention => C,
External_Name => "SDL_FreeSurface";
begin
if Self.Internal /= null and then Self.Owns then
SDL_Free_Surface (Self.Internal);
end if;
end Finalize;
end SDL.Video.Surfaces;
|
gitter-badger/spat | Ada | 4,167 | adb | ------------------------------------------------------------------------------
-- Copyright (C) 2020 by Heisenbug Ltd. ([email protected])
--
-- This work is free. You can redistribute it and/or modify it under the
-- terms of the Do What The Fuck You Want To Public License, Version 2,
-- as published by Sam Hocevar. See the LICENSE file for more details.
------------------------------------------------------------------------------
pragma License (Unrestricted);
------------------------------------------------------------------------------
--
-- SPARK Proof Analysis Tool
--
-- S.P.A.T. - Main program - separate Print_Suggestion
--
------------------------------------------------------------------------------
with Ada.Strings.Fixed;
with SPAT.Log;
with SPAT.Spark_Info.Heuristics;
with SPAT.Strings;
separate (Run_SPAT)
------------------------------------------------------------------------------
-- Print_Suggestion
------------------------------------------------------------------------------
procedure Print_Suggestion (Info : in SPAT.Spark_Info.T) is
Indent : constant String := " ";
Results : SPAT.Spark_Info.Heuristics.File_Vectors.Vector;
use type SPAT.Spark_Info.Heuristics.Prover_Vectors.Cursor;
begin
SPAT.Log.Warning
(Message => "You requested a suggested prover configuration.");
SPAT.Log.Warning (Message => "This feature is highly experimental.");
SPAT.Log.Warning (Message => "Please consult the documentation.");
Results := SPAT.Spark_Info.Heuristics.Find_Optimum (Info => Info);
SPAT.Log.Message (Message => "");
SPAT.Log.Message (Message => "package Prove is");
For_Each_File :
for File of Results loop
Find_Minima :
declare
Min_Steps : SPAT.Prover_Steps := 0;
Min_Timeout : Duration := 0.0;
begin
if not File.Provers.Is_Empty then
SPAT.Log.Message
(Message =>
Indent & "for Prover_Switches (""" &
SPAT.To_String (Source => File.Name) & """) use (""",
New_Line => False);
SPAT.Log.Message (Message => "--provers=",
New_Line => False);
For_Each_Prover :
for Prover in File.Provers.Iterate loop
Min_Steps :=
SPAT.Prover_Steps'Max (File.Provers (Prover).Time.Max_Steps,
Min_Steps);
Min_Timeout :=
Duration'Max (File.Provers (Prover).Time.Max_Success,
Min_Timeout);
SPAT.Log.Message
(Message => SPAT.To_String (File.Provers (Prover).Name),
New_Line => False);
if Prover /= File.Provers.Last then
SPAT.Log.Message (Message => ",",
New_Line => False);
end if;
end loop For_Each_Prover;
SPAT.Log.Message (Message => """, ",
New_Line => False);
SPAT.Log.Message
(Message =>
"""--steps=" &
Ada.Strings.Fixed.Trim (Source => Min_Steps'Image,
Side => Ada.Strings.Both) &
"""",
New_Line => False);
SPAT.Log.Message (Message => """, ",
New_Line => False);
SPAT.Log.Message
(Message =>
"""--timeout=" &
Ada.Strings.Fixed.Trim
(Source => Integer'Image (Integer (Min_Timeout + 0.5)),
Side => Ada.Strings.Both) &
"""",
New_Line => False);
SPAT.Log.Message (Message => ");");
else
SPAT.Log.Message
(Message =>
Indent & "-- """ & SPAT.To_String (Source => File.Name) &
""" -- no data found.");
end if;
end Find_Minima;
end loop For_Each_File;
SPAT.Log.Message (Message => "end Prove;");
SPAT.Log.Message (Message => "");
end Print_Suggestion;
|
reznikmm/matreshka | Ada | 4,053 | 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 trigger for an AnyReceiveEvent is triggered by the receipt of any
-- message that is not explicitly handled by any related trigger.
------------------------------------------------------------------------------
with AMF.UML.Message_Events;
package AMF.UML.Any_Receive_Events is
pragma Preelaborate;
type UML_Any_Receive_Event is limited interface
and AMF.UML.Message_Events.UML_Message_Event;
type UML_Any_Receive_Event_Access is
access all UML_Any_Receive_Event'Class;
for UML_Any_Receive_Event_Access'Storage_Size use 0;
end AMF.UML.Any_Receive_Events;
|
reznikmm/matreshka | Ada | 3,719 | ads | ------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- Open Document Toolkit --
-- --
-- Runtime Library Component --
-- --
------------------------------------------------------------------------------
-- --
-- Copyright © 2014, Vadim Godunko <[email protected]> --
-- All rights reserved. --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions --
-- are met: --
-- --
-- * Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- --
-- * Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in the --
-- documentation and/or other materials provided with the distribution. --
-- --
-- * Neither the name of the Vadim Godunko, IE nor the names of its --
-- contributors may be used to endorse or promote products derived from --
-- this software without specific prior written permission. --
-- --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR --
-- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
-- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED --
-- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR --
-- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF --
-- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING --
-- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS --
-- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
-- --
------------------------------------------------------------------------------
-- $Revision$ $Date$
------------------------------------------------------------------------------
with XML.DOM.Attributes;
package ODF.DOM.Draw_Page_Number_Attributes is
pragma Preelaborate;
type ODF_Draw_Page_Number_Attribute is limited interface
and XML.DOM.Attributes.DOM_Attribute;
type ODF_Draw_Page_Number_Attribute_Access is
access all ODF_Draw_Page_Number_Attribute'Class
with Storage_Size => 0;
end ODF.DOM.Draw_Page_Number_Attributes;
|
AdaCore/libadalang | Ada | 418 | adb | procedure Test is
function Temp (x,y: Integer) return Boolean is Null;
procedure Outer_Procedure (x: Integer) is
function Inner_Procedure (x: Integer) return Boolean is
begin
return Temp (Outer_Procedure.x, x);
--% node.f_return_expr.f_suffix[0].f_r_expr.f_prefix.p_is_call
end Inner_Procedure;
begin
Null;
end Outer_Procedure;
begin
null;
end Test;
|
zhmu/ananas | Ada | 59,305 | adb | ------------------------------------------------------------------------------
-- --
-- GNAT RUN-TIME COMPONENTS --
-- --
-- A D A . S T R I N G S . W I D E _ U N B O U N D E D --
-- --
-- B o d y --
-- --
-- Copyright (C) 1992-2022, Free Software Foundation, Inc. --
-- --
-- GNAT is free software; you can redistribute it and/or modify it under --
-- terms of the GNU General Public License as published by the Free Soft- --
-- ware Foundation; either version 3, or (at your option) any later ver- --
-- sion. GNAT is distributed in the hope that it will be useful, but WITH- --
-- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY --
-- or FITNESS FOR A PARTICULAR PURPOSE. --
-- --
-- As a special exception under Section 7 of GPL version 3, you are granted --
-- additional permissions described in the GCC Runtime Library Exception, --
-- version 3.1, as published by the Free Software Foundation. --
-- --
-- You should have received a copy of the GNU General Public License and --
-- a copy of the GCC Runtime Library Exception along with this program; --
-- see the files COPYING3 and COPYING.RUNTIME respectively. If not, see --
-- <http://www.gnu.org/licenses/>. --
-- --
-- GNAT was originally developed by the GNAT team at New York University. --
-- Extensive contributions were provided by Ada Core Technologies Inc. --
-- --
------------------------------------------------------------------------------
with Ada.Strings.Wide_Search;
with Ada.Unchecked_Deallocation;
package body Ada.Strings.Wide_Unbounded is
use Ada.Strings.Wide_Maps;
Growth_Factor : constant := 32;
-- The growth factor controls how much extra space is allocated when
-- we have to increase the size of an allocated unbounded string. By
-- allocating extra space, we avoid the need to reallocate on every
-- append, particularly important when a string is built up by repeated
-- append operations of small pieces. This is expressed as a factor so
-- 32 means add 1/32 of the length of the string as growth space.
Min_Mul_Alloc : constant := Standard'Maximum_Alignment;
-- Allocation will be done by a multiple of Min_Mul_Alloc. This causes
-- no memory loss as most (all?) malloc implementations are obliged to
-- align the returned memory on the maximum alignment as malloc does not
-- know the target alignment.
function Aligned_Max_Length (Max_Length : Natural) return Natural;
-- Returns recommended length of the shared string which is greater or
-- equal to specified length. Calculation take in sense alignment of
-- the allocated memory segments to use memory effectively by
-- Append/Insert/etc operations.
---------
-- "&" --
---------
function "&"
(Left : Unbounded_Wide_String;
Right : Unbounded_Wide_String) return Unbounded_Wide_String
is
LR : constant Shared_Wide_String_Access := Left.Reference;
RR : constant Shared_Wide_String_Access := Right.Reference;
DL : constant Natural := LR.Last + RR.Last;
DR : Shared_Wide_String_Access;
begin
-- Result is an empty string, reuse shared empty string
if DL = 0 then
Reference (Empty_Shared_Wide_String'Access);
DR := Empty_Shared_Wide_String'Access;
-- Left string is empty, return Right string
elsif LR.Last = 0 then
Reference (RR);
DR := RR;
-- Right string is empty, return Left string
elsif RR.Last = 0 then
Reference (LR);
DR := LR;
-- Overwise, allocate new shared string and fill data
else
DR := Allocate (DL);
DR.Data (1 .. LR.Last) := LR.Data (1 .. LR.Last);
DR.Data (LR.Last + 1 .. DL) := RR.Data (1 .. RR.Last);
DR.Last := DL;
end if;
return (AF.Controlled with Reference => DR);
end "&";
function "&"
(Left : Unbounded_Wide_String;
Right : Wide_String) return Unbounded_Wide_String
is
LR : constant Shared_Wide_String_Access := Left.Reference;
DL : constant Natural := LR.Last + Right'Length;
DR : Shared_Wide_String_Access;
begin
-- Result is an empty string, reuse shared empty string
if DL = 0 then
Reference (Empty_Shared_Wide_String'Access);
DR := Empty_Shared_Wide_String'Access;
-- Right is an empty string, return Left string
elsif Right'Length = 0 then
Reference (LR);
DR := LR;
-- Otherwise, allocate new shared string and fill it
else
DR := Allocate (DL);
DR.Data (1 .. LR.Last) := LR.Data (1 .. LR.Last);
DR.Data (LR.Last + 1 .. DL) := Right;
DR.Last := DL;
end if;
return (AF.Controlled with Reference => DR);
end "&";
function "&"
(Left : Wide_String;
Right : Unbounded_Wide_String) return Unbounded_Wide_String
is
RR : constant Shared_Wide_String_Access := Right.Reference;
DL : constant Natural := Left'Length + RR.Last;
DR : Shared_Wide_String_Access;
begin
-- Result is an empty string, reuse shared one
if DL = 0 then
Reference (Empty_Shared_Wide_String'Access);
DR := Empty_Shared_Wide_String'Access;
-- Left is empty string, return Right string
elsif Left'Length = 0 then
Reference (RR);
DR := RR;
-- Otherwise, allocate new shared string and fill it
else
DR := Allocate (DL);
DR.Data (1 .. Left'Length) := Left;
DR.Data (Left'Length + 1 .. DL) := RR.Data (1 .. RR.Last);
DR.Last := DL;
end if;
return (AF.Controlled with Reference => DR);
end "&";
function "&"
(Left : Unbounded_Wide_String;
Right : Wide_Character) return Unbounded_Wide_String
is
LR : constant Shared_Wide_String_Access := Left.Reference;
DL : constant Natural := LR.Last + 1;
DR : Shared_Wide_String_Access;
begin
DR := Allocate (DL);
DR.Data (1 .. LR.Last) := LR.Data (1 .. LR.Last);
DR.Data (DL) := Right;
DR.Last := DL;
return (AF.Controlled with Reference => DR);
end "&";
function "&"
(Left : Wide_Character;
Right : Unbounded_Wide_String) return Unbounded_Wide_String
is
RR : constant Shared_Wide_String_Access := Right.Reference;
DL : constant Natural := 1 + RR.Last;
DR : Shared_Wide_String_Access;
begin
DR := Allocate (DL);
DR.Data (1) := Left;
DR.Data (2 .. DL) := RR.Data (1 .. RR.Last);
DR.Last := DL;
return (AF.Controlled with Reference => DR);
end "&";
---------
-- "*" --
---------
function "*"
(Left : Natural;
Right : Wide_Character) return Unbounded_Wide_String
is
DR : Shared_Wide_String_Access;
begin
-- Result is an empty string, reuse shared empty string
if Left = 0 then
Reference (Empty_Shared_Wide_String'Access);
DR := Empty_Shared_Wide_String'Access;
-- Otherwise, allocate new shared string and fill it
else
DR := Allocate (Left);
for J in 1 .. Left loop
DR.Data (J) := Right;
end loop;
DR.Last := Left;
end if;
return (AF.Controlled with Reference => DR);
end "*";
function "*"
(Left : Natural;
Right : Wide_String) return Unbounded_Wide_String
is
DL : constant Natural := Left * Right'Length;
DR : Shared_Wide_String_Access;
K : Positive;
begin
-- Result is an empty string, reuse shared empty string
if DL = 0 then
Reference (Empty_Shared_Wide_String'Access);
DR := Empty_Shared_Wide_String'Access;
-- Otherwise, allocate new shared string and fill it
else
DR := Allocate (DL);
K := 1;
for J in 1 .. Left loop
DR.Data (K .. K + Right'Length - 1) := Right;
K := K + Right'Length;
end loop;
DR.Last := DL;
end if;
return (AF.Controlled with Reference => DR);
end "*";
function "*"
(Left : Natural;
Right : Unbounded_Wide_String) return Unbounded_Wide_String
is
RR : constant Shared_Wide_String_Access := Right.Reference;
DL : constant Natural := Left * RR.Last;
DR : Shared_Wide_String_Access;
K : Positive;
begin
-- Result is an empty string, reuse shared empty string
if DL = 0 then
Reference (Empty_Shared_Wide_String'Access);
DR := Empty_Shared_Wide_String'Access;
-- Coefficient is one, just return string itself
elsif Left = 1 then
Reference (RR);
DR := RR;
-- Otherwise, allocate new shared string and fill it
else
DR := Allocate (DL);
K := 1;
for J in 1 .. Left loop
DR.Data (K .. K + RR.Last - 1) := RR.Data (1 .. RR.Last);
K := K + RR.Last;
end loop;
DR.Last := DL;
end if;
return (AF.Controlled with Reference => DR);
end "*";
---------
-- "<" --
---------
function "<"
(Left : Unbounded_Wide_String;
Right : Unbounded_Wide_String) return Boolean
is
LR : constant Shared_Wide_String_Access := Left.Reference;
RR : constant Shared_Wide_String_Access := Right.Reference;
begin
return LR.Data (1 .. LR.Last) < RR.Data (1 .. RR.Last);
end "<";
function "<"
(Left : Unbounded_Wide_String;
Right : Wide_String) return Boolean
is
LR : constant Shared_Wide_String_Access := Left.Reference;
begin
return LR.Data (1 .. LR.Last) < Right;
end "<";
function "<"
(Left : Wide_String;
Right : Unbounded_Wide_String) return Boolean
is
RR : constant Shared_Wide_String_Access := Right.Reference;
begin
return Left < RR.Data (1 .. RR.Last);
end "<";
----------
-- "<=" --
----------
function "<="
(Left : Unbounded_Wide_String;
Right : Unbounded_Wide_String) return Boolean
is
LR : constant Shared_Wide_String_Access := Left.Reference;
RR : constant Shared_Wide_String_Access := Right.Reference;
begin
-- LR = RR means two strings shares shared string, thus they are equal
return LR = RR or else LR.Data (1 .. LR.Last) <= RR.Data (1 .. RR.Last);
end "<=";
function "<="
(Left : Unbounded_Wide_String;
Right : Wide_String) return Boolean
is
LR : constant Shared_Wide_String_Access := Left.Reference;
begin
return LR.Data (1 .. LR.Last) <= Right;
end "<=";
function "<="
(Left : Wide_String;
Right : Unbounded_Wide_String) return Boolean
is
RR : constant Shared_Wide_String_Access := Right.Reference;
begin
return Left <= RR.Data (1 .. RR.Last);
end "<=";
---------
-- "=" --
---------
function "="
(Left : Unbounded_Wide_String;
Right : Unbounded_Wide_String) return Boolean
is
LR : constant Shared_Wide_String_Access := Left.Reference;
RR : constant Shared_Wide_String_Access := Right.Reference;
begin
return LR = RR or else LR.Data (1 .. LR.Last) = RR.Data (1 .. RR.Last);
-- LR = RR means two strings shares shared string, thus they are equal
end "=";
function "="
(Left : Unbounded_Wide_String;
Right : Wide_String) return Boolean
is
LR : constant Shared_Wide_String_Access := Left.Reference;
begin
return LR.Data (1 .. LR.Last) = Right;
end "=";
function "="
(Left : Wide_String;
Right : Unbounded_Wide_String) return Boolean
is
RR : constant Shared_Wide_String_Access := Right.Reference;
begin
return Left = RR.Data (1 .. RR.Last);
end "=";
---------
-- ">" --
---------
function ">"
(Left : Unbounded_Wide_String;
Right : Unbounded_Wide_String) return Boolean
is
LR : constant Shared_Wide_String_Access := Left.Reference;
RR : constant Shared_Wide_String_Access := Right.Reference;
begin
return LR.Data (1 .. LR.Last) > RR.Data (1 .. RR.Last);
end ">";
function ">"
(Left : Unbounded_Wide_String;
Right : Wide_String) return Boolean
is
LR : constant Shared_Wide_String_Access := Left.Reference;
begin
return LR.Data (1 .. LR.Last) > Right;
end ">";
function ">"
(Left : Wide_String;
Right : Unbounded_Wide_String) return Boolean
is
RR : constant Shared_Wide_String_Access := Right.Reference;
begin
return Left > RR.Data (1 .. RR.Last);
end ">";
----------
-- ">=" --
----------
function ">="
(Left : Unbounded_Wide_String;
Right : Unbounded_Wide_String) return Boolean
is
LR : constant Shared_Wide_String_Access := Left.Reference;
RR : constant Shared_Wide_String_Access := Right.Reference;
begin
-- LR = RR means two strings shares shared string, thus they are equal
return LR = RR or else LR.Data (1 .. LR.Last) >= RR.Data (1 .. RR.Last);
end ">=";
function ">="
(Left : Unbounded_Wide_String;
Right : Wide_String) return Boolean
is
LR : constant Shared_Wide_String_Access := Left.Reference;
begin
return LR.Data (1 .. LR.Last) >= Right;
end ">=";
function ">="
(Left : Wide_String;
Right : Unbounded_Wide_String) return Boolean
is
RR : constant Shared_Wide_String_Access := Right.Reference;
begin
return Left >= RR.Data (1 .. RR.Last);
end ">=";
------------
-- Adjust --
------------
procedure Adjust (Object : in out Unbounded_Wide_String) is
begin
Reference (Object.Reference);
end Adjust;
------------------------
-- Aligned_Max_Length --
------------------------
function Aligned_Max_Length (Max_Length : Natural) return Natural is
Static_Size : constant Natural :=
Empty_Shared_Wide_String'Size / Standard'Storage_Unit;
-- Total size of all static components
Element_Size : constant Natural :=
Wide_Character'Size / Standard'Storage_Unit;
begin
return
(((Static_Size + Max_Length * Element_Size - 1) / Min_Mul_Alloc + 2)
* Min_Mul_Alloc - Static_Size) / Element_Size;
end Aligned_Max_Length;
--------------
-- Allocate --
--------------
function Allocate (Max_Length : Natural) return Shared_Wide_String_Access is
begin
-- Empty string requested, return shared empty string
if Max_Length = 0 then
Reference (Empty_Shared_Wide_String'Access);
return Empty_Shared_Wide_String'Access;
-- Otherwise, allocate requested space (and probably some more room)
else
return new Shared_Wide_String (Aligned_Max_Length (Max_Length));
end if;
end Allocate;
------------
-- Append --
------------
procedure Append
(Source : in out Unbounded_Wide_String;
New_Item : Unbounded_Wide_String)
is
SR : constant Shared_Wide_String_Access := Source.Reference;
NR : constant Shared_Wide_String_Access := New_Item.Reference;
DL : constant Natural := SR.Last + NR.Last;
DR : Shared_Wide_String_Access;
begin
-- Source is an empty string, reuse New_Item data
if SR.Last = 0 then
Reference (NR);
Source.Reference := NR;
Unreference (SR);
-- New_Item is empty string, nothing to do
elsif NR.Last = 0 then
null;
-- Try to reuse existent shared string
elsif Can_Be_Reused (SR, DL) then
SR.Data (SR.Last + 1 .. DL) := NR.Data (1 .. NR.Last);
SR.Last := DL;
-- Otherwise, allocate new one and fill it
else
DR := Allocate (DL + DL / Growth_Factor);
DR.Data (1 .. SR.Last) := SR.Data (1 .. SR.Last);
DR.Data (SR.Last + 1 .. DL) := NR.Data (1 .. NR.Last);
DR.Last := DL;
Source.Reference := DR;
Unreference (SR);
end if;
end Append;
procedure Append
(Source : in out Unbounded_Wide_String;
New_Item : Wide_String)
is
SR : constant Shared_Wide_String_Access := Source.Reference;
DL : constant Natural := SR.Last + New_Item'Length;
DR : Shared_Wide_String_Access;
begin
-- New_Item is an empty string, nothing to do
if New_Item'Length = 0 then
null;
-- Try to reuse existing shared string
elsif Can_Be_Reused (SR, DL) then
SR.Data (SR.Last + 1 .. DL) := New_Item;
SR.Last := DL;
-- Otherwise, allocate new one and fill it
else
DR := Allocate (DL + DL / Growth_Factor);
DR.Data (1 .. SR.Last) := SR.Data (1 .. SR.Last);
DR.Data (SR.Last + 1 .. DL) := New_Item;
DR.Last := DL;
Source.Reference := DR;
Unreference (SR);
end if;
end Append;
procedure Append
(Source : in out Unbounded_Wide_String;
New_Item : Wide_Character)
is
SR : constant Shared_Wide_String_Access := Source.Reference;
DL : constant Natural := SR.Last + 1;
DR : Shared_Wide_String_Access;
begin
-- Try to reuse existing shared string
if Can_Be_Reused (SR, SR.Last + 1) then
SR.Data (SR.Last + 1) := New_Item;
SR.Last := SR.Last + 1;
-- Otherwise, allocate new one and fill it
else
DR := Allocate (DL + DL / Growth_Factor);
DR.Data (1 .. SR.Last) := SR.Data (1 .. SR.Last);
DR.Data (DL) := New_Item;
DR.Last := DL;
Source.Reference := DR;
Unreference (SR);
end if;
end Append;
-------------------
-- Can_Be_Reused --
-------------------
function Can_Be_Reused
(Item : Shared_Wide_String_Access;
Length : Natural) return Boolean is
begin
return
System.Atomic_Counters.Is_One (Item.Counter)
and then Item.Max_Length >= Length
and then Item.Max_Length <=
Aligned_Max_Length (Length + Length / Growth_Factor);
end Can_Be_Reused;
-----------
-- Count --
-----------
function Count
(Source : Unbounded_Wide_String;
Pattern : Wide_String;
Mapping : Wide_Maps.Wide_Character_Mapping := Wide_Maps.Identity)
return Natural
is
SR : constant Shared_Wide_String_Access := Source.Reference;
begin
return Wide_Search.Count (SR.Data (1 .. SR.Last), Pattern, Mapping);
end Count;
function Count
(Source : Unbounded_Wide_String;
Pattern : Wide_String;
Mapping : Wide_Maps.Wide_Character_Mapping_Function) return Natural
is
SR : constant Shared_Wide_String_Access := Source.Reference;
begin
return Wide_Search.Count (SR.Data (1 .. SR.Last), Pattern, Mapping);
end Count;
function Count
(Source : Unbounded_Wide_String;
Set : Wide_Maps.Wide_Character_Set) return Natural
is
SR : constant Shared_Wide_String_Access := Source.Reference;
begin
return Wide_Search.Count (SR.Data (1 .. SR.Last), Set);
end Count;
------------
-- Delete --
------------
function Delete
(Source : Unbounded_Wide_String;
From : Positive;
Through : Natural) return Unbounded_Wide_String
is
SR : constant Shared_Wide_String_Access := Source.Reference;
DL : Natural;
DR : Shared_Wide_String_Access;
begin
-- Empty slice is deleted, use the same shared string
if From > Through then
Reference (SR);
DR := SR;
-- Index is out of range
elsif Through > SR.Last then
raise Index_Error;
-- Compute size of the result
else
DL := SR.Last - (Through - From + 1);
-- Result is an empty string, reuse shared empty string
if DL = 0 then
Reference (Empty_Shared_Wide_String'Access);
DR := Empty_Shared_Wide_String'Access;
-- Otherwise, allocate new shared string and fill it
else
DR := Allocate (DL);
DR.Data (1 .. From - 1) := SR.Data (1 .. From - 1);
DR.Data (From .. DL) := SR.Data (Through + 1 .. SR.Last);
DR.Last := DL;
end if;
end if;
return (AF.Controlled with Reference => DR);
end Delete;
procedure Delete
(Source : in out Unbounded_Wide_String;
From : Positive;
Through : Natural)
is
SR : constant Shared_Wide_String_Access := Source.Reference;
DL : Natural;
DR : Shared_Wide_String_Access;
begin
-- Nothing changed, return
if From > Through then
null;
-- Through is outside of the range
elsif Through > SR.Last then
raise Index_Error;
else
DL := SR.Last - (Through - From + 1);
-- Result is empty, reuse shared empty string
if DL = 0 then
Reference (Empty_Shared_Wide_String'Access);
Source.Reference := Empty_Shared_Wide_String'Access;
Unreference (SR);
-- Try to reuse existent shared string
elsif Can_Be_Reused (SR, DL) then
SR.Data (From .. DL) := SR.Data (Through + 1 .. SR.Last);
SR.Last := DL;
-- Otherwise, allocate new shared string
else
DR := Allocate (DL);
DR.Data (1 .. From - 1) := SR.Data (1 .. From - 1);
DR.Data (From .. DL) := SR.Data (Through + 1 .. SR.Last);
DR.Last := DL;
Source.Reference := DR;
Unreference (SR);
end if;
end if;
end Delete;
-------------
-- Element --
-------------
function Element
(Source : Unbounded_Wide_String;
Index : Positive) return Wide_Character
is
SR : constant Shared_Wide_String_Access := Source.Reference;
begin
if Index <= SR.Last then
return SR.Data (Index);
else
raise Index_Error;
end if;
end Element;
--------------
-- Finalize --
--------------
procedure Finalize (Object : in out Unbounded_Wide_String) is
SR : constant Shared_Wide_String_Access := Object.Reference;
begin
if SR /= null then
-- The same controlled object can be finalized several times for
-- some reason. As per 7.6.1(24) this should have no ill effect,
-- so we need to add a guard for the case of finalizing the same
-- object twice.
Object.Reference := null;
Unreference (SR);
end if;
end Finalize;
----------------
-- Find_Token --
----------------
procedure Find_Token
(Source : Unbounded_Wide_String;
Set : Wide_Maps.Wide_Character_Set;
From : Positive;
Test : Strings.Membership;
First : out Positive;
Last : out Natural)
is
SR : constant Shared_Wide_String_Access := Source.Reference;
begin
Wide_Search.Find_Token
(SR.Data (From .. SR.Last), Set, Test, First, Last);
end Find_Token;
procedure Find_Token
(Source : Unbounded_Wide_String;
Set : Wide_Maps.Wide_Character_Set;
Test : Strings.Membership;
First : out Positive;
Last : out Natural)
is
SR : constant Shared_Wide_String_Access := Source.Reference;
begin
Wide_Search.Find_Token
(SR.Data (1 .. SR.Last), Set, Test, First, Last);
end Find_Token;
----------
-- Free --
----------
procedure Free (X : in out Wide_String_Access) is
procedure Deallocate is
new Ada.Unchecked_Deallocation (Wide_String, Wide_String_Access);
begin
Deallocate (X);
end Free;
----------
-- Head --
----------
function Head
(Source : Unbounded_Wide_String;
Count : Natural;
Pad : Wide_Character := Wide_Space) return Unbounded_Wide_String
is
SR : constant Shared_Wide_String_Access := Source.Reference;
DR : Shared_Wide_String_Access;
begin
-- Result is empty, reuse shared empty string
if Count = 0 then
Reference (Empty_Shared_Wide_String'Access);
DR := Empty_Shared_Wide_String'Access;
-- Length of the string is the same as requested, reuse source shared
-- string.
elsif Count = SR.Last then
Reference (SR);
DR := SR;
-- Otherwise, allocate new shared string and fill it
else
DR := Allocate (Count);
-- Length of the source string is more than requested, copy
-- corresponding slice.
if Count < SR.Last then
DR.Data (1 .. Count) := SR.Data (1 .. Count);
-- Length of the source string is less than requested, copy all
-- contents and fill others by Pad character.
else
DR.Data (1 .. SR.Last) := SR.Data (1 .. SR.Last);
for J in SR.Last + 1 .. Count loop
DR.Data (J) := Pad;
end loop;
end if;
DR.Last := Count;
end if;
return (AF.Controlled with Reference => DR);
end Head;
procedure Head
(Source : in out Unbounded_Wide_String;
Count : Natural;
Pad : Wide_Character := Wide_Space)
is
SR : constant Shared_Wide_String_Access := Source.Reference;
DR : Shared_Wide_String_Access;
begin
-- Result is empty, reuse empty shared string
if Count = 0 then
Reference (Empty_Shared_Wide_String'Access);
Source.Reference := Empty_Shared_Wide_String'Access;
Unreference (SR);
-- Result is same with source string, reuse source shared string
elsif Count = SR.Last then
null;
-- Try to reuse existent shared string
elsif Can_Be_Reused (SR, Count) then
if Count > SR.Last then
for J in SR.Last + 1 .. Count loop
SR.Data (J) := Pad;
end loop;
end if;
SR.Last := Count;
-- Otherwise, allocate new shared string and fill it
else
DR := Allocate (Count);
-- Length of the source string is greater than requested, copy
-- corresponding slice.
if Count < SR.Last then
DR.Data (1 .. Count) := SR.Data (1 .. Count);
-- Length of the source string is less than requested, copy all
-- exists data and fill others by Pad character.
else
DR.Data (1 .. SR.Last) := SR.Data (1 .. SR.Last);
for J in SR.Last + 1 .. Count loop
DR.Data (J) := Pad;
end loop;
end if;
DR.Last := Count;
Source.Reference := DR;
Unreference (SR);
end if;
end Head;
-----------
-- Index --
-----------
function Index
(Source : Unbounded_Wide_String;
Pattern : Wide_String;
Going : Strings.Direction := Strings.Forward;
Mapping : Wide_Maps.Wide_Character_Mapping := Wide_Maps.Identity)
return Natural
is
SR : constant Shared_Wide_String_Access := Source.Reference;
begin
return Wide_Search.Index
(SR.Data (1 .. SR.Last), Pattern, Going, Mapping);
end Index;
function Index
(Source : Unbounded_Wide_String;
Pattern : Wide_String;
Going : Direction := Forward;
Mapping : Wide_Maps.Wide_Character_Mapping_Function) return Natural
is
SR : constant Shared_Wide_String_Access := Source.Reference;
begin
return Wide_Search.Index
(SR.Data (1 .. SR.Last), Pattern, Going, Mapping);
end Index;
function Index
(Source : Unbounded_Wide_String;
Set : Wide_Maps.Wide_Character_Set;
Test : Strings.Membership := Strings.Inside;
Going : Strings.Direction := Strings.Forward) return Natural
is
SR : constant Shared_Wide_String_Access := Source.Reference;
begin
return Wide_Search.Index (SR.Data (1 .. SR.Last), Set, Test, Going);
end Index;
function Index
(Source : Unbounded_Wide_String;
Pattern : Wide_String;
From : Positive;
Going : Direction := Forward;
Mapping : Wide_Maps.Wide_Character_Mapping := Wide_Maps.Identity)
return Natural
is
SR : constant Shared_Wide_String_Access := Source.Reference;
begin
return Wide_Search.Index
(SR.Data (1 .. SR.Last), Pattern, From, Going, Mapping);
end Index;
function Index
(Source : Unbounded_Wide_String;
Pattern : Wide_String;
From : Positive;
Going : Direction := Forward;
Mapping : Wide_Maps.Wide_Character_Mapping_Function) return Natural
is
SR : constant Shared_Wide_String_Access := Source.Reference;
begin
return Wide_Search.Index
(SR.Data (1 .. SR.Last), Pattern, From, Going, Mapping);
end Index;
function Index
(Source : Unbounded_Wide_String;
Set : Wide_Maps.Wide_Character_Set;
From : Positive;
Test : Membership := Inside;
Going : Direction := Forward) return Natural
is
SR : constant Shared_Wide_String_Access := Source.Reference;
begin
return Wide_Search.Index
(SR.Data (1 .. SR.Last), Set, From, Test, Going);
end Index;
---------------------
-- Index_Non_Blank --
---------------------
function Index_Non_Blank
(Source : Unbounded_Wide_String;
Going : Strings.Direction := Strings.Forward) return Natural
is
SR : constant Shared_Wide_String_Access := Source.Reference;
begin
return Wide_Search.Index_Non_Blank (SR.Data (1 .. SR.Last), Going);
end Index_Non_Blank;
function Index_Non_Blank
(Source : Unbounded_Wide_String;
From : Positive;
Going : Direction := Forward) return Natural
is
SR : constant Shared_Wide_String_Access := Source.Reference;
begin
return Wide_Search.Index_Non_Blank
(SR.Data (1 .. SR.Last), From, Going);
end Index_Non_Blank;
----------------
-- Initialize --
----------------
procedure Initialize (Object : in out Unbounded_Wide_String) is
begin
Reference (Object.Reference);
end Initialize;
------------
-- Insert --
------------
function Insert
(Source : Unbounded_Wide_String;
Before : Positive;
New_Item : Wide_String) return Unbounded_Wide_String
is
SR : constant Shared_Wide_String_Access := Source.Reference;
DL : constant Natural := SR.Last + New_Item'Length;
DR : Shared_Wide_String_Access;
begin
-- Check index first
if Before > SR.Last + 1 then
raise Index_Error;
end if;
-- Result is empty, reuse empty shared string
if DL = 0 then
Reference (Empty_Shared_Wide_String'Access);
DR := Empty_Shared_Wide_String'Access;
-- Inserted string is empty, reuse source shared string
elsif New_Item'Length = 0 then
Reference (SR);
DR := SR;
-- Otherwise, allocate new shared string and fill it
else
DR := Allocate (DL + DL / Growth_Factor);
DR.Data (1 .. Before - 1) := SR.Data (1 .. Before - 1);
DR.Data (Before .. Before + New_Item'Length - 1) := New_Item;
DR.Data (Before + New_Item'Length .. DL) :=
SR.Data (Before .. SR.Last);
DR.Last := DL;
end if;
return (AF.Controlled with Reference => DR);
end Insert;
procedure Insert
(Source : in out Unbounded_Wide_String;
Before : Positive;
New_Item : Wide_String)
is
SR : constant Shared_Wide_String_Access := Source.Reference;
DL : constant Natural := SR.Last + New_Item'Length;
DR : Shared_Wide_String_Access;
begin
-- Check bounds
if Before > SR.Last + 1 then
raise Index_Error;
end if;
-- Result is empty string, reuse empty shared string
if DL = 0 then
Reference (Empty_Shared_Wide_String'Access);
Source.Reference := Empty_Shared_Wide_String'Access;
Unreference (SR);
-- Inserted string is empty, nothing to do
elsif New_Item'Length = 0 then
null;
-- Try to reuse existent shared string first
elsif Can_Be_Reused (SR, DL) then
SR.Data (Before + New_Item'Length .. DL) :=
SR.Data (Before .. SR.Last);
SR.Data (Before .. Before + New_Item'Length - 1) := New_Item;
SR.Last := DL;
-- Otherwise, allocate new shared string and fill it
else
DR := Allocate (DL + DL / Growth_Factor);
DR.Data (1 .. Before - 1) := SR.Data (1 .. Before - 1);
DR.Data (Before .. Before + New_Item'Length - 1) := New_Item;
DR.Data (Before + New_Item'Length .. DL) :=
SR.Data (Before .. SR.Last);
DR.Last := DL;
Source.Reference := DR;
Unreference (SR);
end if;
end Insert;
------------
-- Length --
------------
function Length (Source : Unbounded_Wide_String) return Natural is
begin
return Source.Reference.Last;
end Length;
---------------
-- Overwrite --
---------------
function Overwrite
(Source : Unbounded_Wide_String;
Position : Positive;
New_Item : Wide_String) return Unbounded_Wide_String
is
SR : constant Shared_Wide_String_Access := Source.Reference;
DL : Natural;
DR : Shared_Wide_String_Access;
begin
-- Check bounds
if Position > SR.Last + 1 then
raise Index_Error;
end if;
DL := Integer'Max (SR.Last, Position + New_Item'Length - 1);
-- Result is empty string, reuse empty shared string
if DL = 0 then
Reference (Empty_Shared_Wide_String'Access);
DR := Empty_Shared_Wide_String'Access;
-- Result is same with source string, reuse source shared string
elsif New_Item'Length = 0 then
Reference (SR);
DR := SR;
-- Otherwise, allocate new shared string and fill it
else
DR := Allocate (DL);
DR.Data (1 .. Position - 1) := SR.Data (1 .. Position - 1);
DR.Data (Position .. Position + New_Item'Length - 1) := New_Item;
DR.Data (Position + New_Item'Length .. DL) :=
SR.Data (Position + New_Item'Length .. SR.Last);
DR.Last := DL;
end if;
return (AF.Controlled with Reference => DR);
end Overwrite;
procedure Overwrite
(Source : in out Unbounded_Wide_String;
Position : Positive;
New_Item : Wide_String)
is
SR : constant Shared_Wide_String_Access := Source.Reference;
DL : Natural;
DR : Shared_Wide_String_Access;
begin
-- Bounds check
if Position > SR.Last + 1 then
raise Index_Error;
end if;
DL := Integer'Max (SR.Last, Position + New_Item'Length - 1);
-- Result is empty string, reuse empty shared string
if DL = 0 then
Reference (Empty_Shared_Wide_String'Access);
Source.Reference := Empty_Shared_Wide_String'Access;
Unreference (SR);
-- String unchanged, nothing to do
elsif New_Item'Length = 0 then
null;
-- Try to reuse existent shared string
elsif Can_Be_Reused (SR, DL) then
SR.Data (Position .. Position + New_Item'Length - 1) := New_Item;
SR.Last := DL;
-- Otherwise allocate new shared string and fill it
else
DR := Allocate (DL);
DR.Data (1 .. Position - 1) := SR.Data (1 .. Position - 1);
DR.Data (Position .. Position + New_Item'Length - 1) := New_Item;
DR.Data (Position + New_Item'Length .. DL) :=
SR.Data (Position + New_Item'Length .. SR.Last);
DR.Last := DL;
Source.Reference := DR;
Unreference (SR);
end if;
end Overwrite;
---------------
-- Reference --
---------------
procedure Reference (Item : not null Shared_Wide_String_Access) is
begin
System.Atomic_Counters.Increment (Item.Counter);
end Reference;
---------------------
-- Replace_Element --
---------------------
procedure Replace_Element
(Source : in out Unbounded_Wide_String;
Index : Positive;
By : Wide_Character)
is
SR : constant Shared_Wide_String_Access := Source.Reference;
DR : Shared_Wide_String_Access;
begin
-- Bounds check
if Index <= SR.Last then
-- Try to reuse existent shared string
if Can_Be_Reused (SR, SR.Last) then
SR.Data (Index) := By;
-- Otherwise allocate new shared string and fill it
else
DR := Allocate (SR.Last);
DR.Data (1 .. SR.Last) := SR.Data (1 .. SR.Last);
DR.Data (Index) := By;
DR.Last := SR.Last;
Source.Reference := DR;
Unreference (SR);
end if;
else
raise Index_Error;
end if;
end Replace_Element;
-------------------
-- Replace_Slice --
-------------------
function Replace_Slice
(Source : Unbounded_Wide_String;
Low : Positive;
High : Natural;
By : Wide_String) return Unbounded_Wide_String
is
SR : constant Shared_Wide_String_Access := Source.Reference;
DL : Natural;
DR : Shared_Wide_String_Access;
begin
-- Check bounds
if Low > SR.Last + 1 then
raise Index_Error;
end if;
-- Do replace operation when removed slice is not empty
if High >= Low then
DL := By'Length + SR.Last + Low - Integer'Min (High, SR.Last) - 1;
-- This is the number of characters remaining in the string after
-- replacing the slice.
-- Result is empty string, reuse empty shared string
if DL = 0 then
Reference (Empty_Shared_Wide_String'Access);
DR := Empty_Shared_Wide_String'Access;
-- Otherwise allocate new shared string and fill it
else
DR := Allocate (DL);
DR.Data (1 .. Low - 1) := SR.Data (1 .. Low - 1);
DR.Data (Low .. Low + By'Length - 1) := By;
DR.Data (Low + By'Length .. DL) := SR.Data (High + 1 .. SR.Last);
DR.Last := DL;
end if;
return (AF.Controlled with Reference => DR);
-- Otherwise just insert string
else
return Insert (Source, Low, By);
end if;
end Replace_Slice;
procedure Replace_Slice
(Source : in out Unbounded_Wide_String;
Low : Positive;
High : Natural;
By : Wide_String)
is
SR : constant Shared_Wide_String_Access := Source.Reference;
DL : Natural;
DR : Shared_Wide_String_Access;
begin
-- Bounds check
if Low > SR.Last + 1 then
raise Index_Error;
end if;
-- Do replace operation only when replaced slice is not empty
if High >= Low then
DL := By'Length + SR.Last + Low - Integer'Min (High, SR.Last) - 1;
-- This is the number of characters remaining in the string after
-- replacing the slice.
-- Result is empty string, reuse empty shared string
if DL = 0 then
Reference (Empty_Shared_Wide_String'Access);
Source.Reference := Empty_Shared_Wide_String'Access;
Unreference (SR);
-- Try to reuse existent shared string
elsif Can_Be_Reused (SR, DL) then
SR.Data (Low + By'Length .. DL) := SR.Data (High + 1 .. SR.Last);
SR.Data (Low .. Low + By'Length - 1) := By;
SR.Last := DL;
-- Otherwise allocate new shared string and fill it
else
DR := Allocate (DL);
DR.Data (1 .. Low - 1) := SR.Data (1 .. Low - 1);
DR.Data (Low .. Low + By'Length - 1) := By;
DR.Data (Low + By'Length .. DL) := SR.Data (High + 1 .. SR.Last);
DR.Last := DL;
Source.Reference := DR;
Unreference (SR);
end if;
-- Otherwise just insert item
else
Insert (Source, Low, By);
end if;
end Replace_Slice;
-------------------------------
-- Set_Unbounded_Wide_String --
-------------------------------
procedure Set_Unbounded_Wide_String
(Target : out Unbounded_Wide_String;
Source : Wide_String)
is
TR : constant Shared_Wide_String_Access := Target.Reference;
DR : Shared_Wide_String_Access;
begin
-- In case of empty string, reuse empty shared string
if Source'Length = 0 then
Reference (Empty_Shared_Wide_String'Access);
Target.Reference := Empty_Shared_Wide_String'Access;
else
-- Try to reuse existent shared string
if Can_Be_Reused (TR, Source'Length) then
Reference (TR);
DR := TR;
-- Otherwise allocate new shared string
else
DR := Allocate (Source'Length);
Target.Reference := DR;
end if;
DR.Data (1 .. Source'Length) := Source;
DR.Last := Source'Length;
end if;
Unreference (TR);
end Set_Unbounded_Wide_String;
-----------
-- Slice --
-----------
function Slice
(Source : Unbounded_Wide_String;
Low : Positive;
High : Natural) return Wide_String
is
SR : constant Shared_Wide_String_Access := Source.Reference;
begin
-- Note: test of High > Length is in accordance with AI95-00128
if Low > SR.Last + 1 or else High > SR.Last then
raise Index_Error;
else
return SR.Data (Low .. High);
end if;
end Slice;
----------
-- Tail --
----------
function Tail
(Source : Unbounded_Wide_String;
Count : Natural;
Pad : Wide_Character := Wide_Space) return Unbounded_Wide_String
is
SR : constant Shared_Wide_String_Access := Source.Reference;
DR : Shared_Wide_String_Access;
begin
-- For empty result reuse empty shared string
if Count = 0 then
Reference (Empty_Shared_Wide_String'Access);
DR := Empty_Shared_Wide_String'Access;
-- Result is hole source string, reuse source shared string
elsif Count = SR.Last then
Reference (SR);
DR := SR;
-- Otherwise allocate new shared string and fill it
else
DR := Allocate (Count);
if Count < SR.Last then
DR.Data (1 .. Count) := SR.Data (SR.Last - Count + 1 .. SR.Last);
else
for J in 1 .. Count - SR.Last loop
DR.Data (J) := Pad;
end loop;
DR.Data (Count - SR.Last + 1 .. Count) := SR.Data (1 .. SR.Last);
end if;
DR.Last := Count;
end if;
return (AF.Controlled with Reference => DR);
end Tail;
procedure Tail
(Source : in out Unbounded_Wide_String;
Count : Natural;
Pad : Wide_Character := Wide_Space)
is
SR : constant Shared_Wide_String_Access := Source.Reference;
DR : Shared_Wide_String_Access;
procedure Common
(SR : Shared_Wide_String_Access;
DR : Shared_Wide_String_Access;
Count : Natural);
-- Common code of tail computation. SR/DR can point to the same object
------------
-- Common --
------------
procedure Common
(SR : Shared_Wide_String_Access;
DR : Shared_Wide_String_Access;
Count : Natural) is
begin
if Count < SR.Last then
DR.Data (1 .. Count) := SR.Data (SR.Last - Count + 1 .. SR.Last);
else
DR.Data (Count - SR.Last + 1 .. Count) := SR.Data (1 .. SR.Last);
for J in 1 .. Count - SR.Last loop
DR.Data (J) := Pad;
end loop;
end if;
DR.Last := Count;
end Common;
begin
-- Result is empty string, reuse empty shared string
if Count = 0 then
Reference (Empty_Shared_Wide_String'Access);
Source.Reference := Empty_Shared_Wide_String'Access;
Unreference (SR);
-- Length of the result is the same with length of the source string,
-- reuse source shared string.
elsif Count = SR.Last then
null;
-- Try to reuse existent shared string
elsif Can_Be_Reused (SR, Count) then
Common (SR, SR, Count);
-- Otherwise allocate new shared string and fill it
else
DR := Allocate (Count);
Common (SR, DR, Count);
Source.Reference := DR;
Unreference (SR);
end if;
end Tail;
--------------------
-- To_Wide_String --
--------------------
function To_Wide_String
(Source : Unbounded_Wide_String) return Wide_String is
begin
return Source.Reference.Data (1 .. Source.Reference.Last);
end To_Wide_String;
------------------------------
-- To_Unbounded_Wide_String --
------------------------------
function To_Unbounded_Wide_String
(Source : Wide_String) return Unbounded_Wide_String
is
DR : Shared_Wide_String_Access;
begin
if Source'Length = 0 then
Reference (Empty_Shared_Wide_String'Access);
DR := Empty_Shared_Wide_String'Access;
else
DR := Allocate (Source'Length);
DR.Data (1 .. Source'Length) := Source;
DR.Last := Source'Length;
end if;
return (AF.Controlled with Reference => DR);
end To_Unbounded_Wide_String;
function To_Unbounded_Wide_String
(Length : Natural) return Unbounded_Wide_String
is
DR : Shared_Wide_String_Access;
begin
if Length = 0 then
Reference (Empty_Shared_Wide_String'Access);
DR := Empty_Shared_Wide_String'Access;
else
DR := Allocate (Length);
DR.Last := Length;
end if;
return (AF.Controlled with Reference => DR);
end To_Unbounded_Wide_String;
---------------
-- Translate --
---------------
function Translate
(Source : Unbounded_Wide_String;
Mapping : Wide_Maps.Wide_Character_Mapping) return Unbounded_Wide_String
is
SR : constant Shared_Wide_String_Access := Source.Reference;
DR : Shared_Wide_String_Access;
begin
-- Nothing to translate, reuse empty shared string
if SR.Last = 0 then
Reference (Empty_Shared_Wide_String'Access);
DR := Empty_Shared_Wide_String'Access;
-- Otherwise, allocate new shared string and fill it
else
DR := Allocate (SR.Last);
for J in 1 .. SR.Last loop
DR.Data (J) := Value (Mapping, SR.Data (J));
end loop;
DR.Last := SR.Last;
end if;
return (AF.Controlled with Reference => DR);
end Translate;
procedure Translate
(Source : in out Unbounded_Wide_String;
Mapping : Wide_Maps.Wide_Character_Mapping)
is
SR : constant Shared_Wide_String_Access := Source.Reference;
DR : Shared_Wide_String_Access;
begin
-- Nothing to translate
if SR.Last = 0 then
null;
-- Try to reuse shared string
elsif Can_Be_Reused (SR, SR.Last) then
for J in 1 .. SR.Last loop
SR.Data (J) := Value (Mapping, SR.Data (J));
end loop;
-- Otherwise, allocate new shared string
else
DR := Allocate (SR.Last);
for J in 1 .. SR.Last loop
DR.Data (J) := Value (Mapping, SR.Data (J));
end loop;
DR.Last := SR.Last;
Source.Reference := DR;
Unreference (SR);
end if;
end Translate;
function Translate
(Source : Unbounded_Wide_String;
Mapping : Wide_Maps.Wide_Character_Mapping_Function)
return Unbounded_Wide_String
is
SR : constant Shared_Wide_String_Access := Source.Reference;
DR : Shared_Wide_String_Access;
begin
-- Nothing to translate, reuse empty shared string
if SR.Last = 0 then
Reference (Empty_Shared_Wide_String'Access);
DR := Empty_Shared_Wide_String'Access;
-- Otherwise, allocate new shared string and fill it
else
DR := Allocate (SR.Last);
for J in 1 .. SR.Last loop
DR.Data (J) := Mapping.all (SR.Data (J));
end loop;
DR.Last := SR.Last;
end if;
return (AF.Controlled with Reference => DR);
exception
when others =>
Unreference (DR);
raise;
end Translate;
procedure Translate
(Source : in out Unbounded_Wide_String;
Mapping : Wide_Maps.Wide_Character_Mapping_Function)
is
SR : constant Shared_Wide_String_Access := Source.Reference;
DR : Shared_Wide_String_Access;
begin
-- Nothing to translate
if SR.Last = 0 then
null;
-- Try to reuse shared string
elsif Can_Be_Reused (SR, SR.Last) then
for J in 1 .. SR.Last loop
SR.Data (J) := Mapping.all (SR.Data (J));
end loop;
-- Otherwise allocate new shared string and fill it
else
DR := Allocate (SR.Last);
for J in 1 .. SR.Last loop
DR.Data (J) := Mapping.all (SR.Data (J));
end loop;
DR.Last := SR.Last;
Source.Reference := DR;
Unreference (SR);
end if;
exception
when others =>
if DR /= null then
Unreference (DR);
end if;
raise;
end Translate;
----------
-- Trim --
----------
function Trim
(Source : Unbounded_Wide_String;
Side : Trim_End) return Unbounded_Wide_String
is
SR : constant Shared_Wide_String_Access := Source.Reference;
DL : Natural;
DR : Shared_Wide_String_Access;
Low : Natural;
High : Natural;
begin
Low := Index_Non_Blank (Source, Forward);
-- All blanks, reuse empty shared string
if Low = 0 then
Reference (Empty_Shared_Wide_String'Access);
DR := Empty_Shared_Wide_String'Access;
else
case Side is
when Left =>
High := SR.Last;
DL := SR.Last - Low + 1;
when Right =>
Low := 1;
High := Index_Non_Blank (Source, Backward);
DL := High;
when Both =>
High := Index_Non_Blank (Source, Backward);
DL := High - Low + 1;
end case;
-- Length of the result is the same as length of the source string,
-- reuse source shared string.
if DL = SR.Last then
Reference (SR);
DR := SR;
-- Otherwise, allocate new shared string
else
DR := Allocate (DL);
DR.Data (1 .. DL) := SR.Data (Low .. High);
DR.Last := DL;
end if;
end if;
return (AF.Controlled with Reference => DR);
end Trim;
procedure Trim
(Source : in out Unbounded_Wide_String;
Side : Trim_End)
is
SR : constant Shared_Wide_String_Access := Source.Reference;
DL : Natural;
DR : Shared_Wide_String_Access;
Low : Natural;
High : Natural;
begin
Low := Index_Non_Blank (Source, Forward);
-- All blanks, reuse empty shared string
if Low = 0 then
Reference (Empty_Shared_Wide_String'Access);
Source.Reference := Empty_Shared_Wide_String'Access;
Unreference (SR);
else
case Side is
when Left =>
High := SR.Last;
DL := SR.Last - Low + 1;
when Right =>
Low := 1;
High := Index_Non_Blank (Source, Backward);
DL := High;
when Both =>
High := Index_Non_Blank (Source, Backward);
DL := High - Low + 1;
end case;
-- Length of the result is the same as length of the source string,
-- nothing to do.
if DL = SR.Last then
null;
-- Try to reuse existent shared string
elsif Can_Be_Reused (SR, DL) then
SR.Data (1 .. DL) := SR.Data (Low .. High);
SR.Last := DL;
-- Otherwise, allocate new shared string
else
DR := Allocate (DL);
DR.Data (1 .. DL) := SR.Data (Low .. High);
DR.Last := DL;
Source.Reference := DR;
Unreference (SR);
end if;
end if;
end Trim;
function Trim
(Source : Unbounded_Wide_String;
Left : Wide_Maps.Wide_Character_Set;
Right : Wide_Maps.Wide_Character_Set) return Unbounded_Wide_String
is
SR : constant Shared_Wide_String_Access := Source.Reference;
DL : Natural;
DR : Shared_Wide_String_Access;
Low : Natural;
High : Natural;
begin
Low := Index (Source, Left, Outside, Forward);
-- Source includes only characters from Left set, reuse empty shared
-- string.
if Low = 0 then
Reference (Empty_Shared_Wide_String'Access);
DR := Empty_Shared_Wide_String'Access;
else
High := Index (Source, Right, Outside, Backward);
DL := Integer'Max (0, High - Low + 1);
-- Source includes only characters from Right set or result string
-- is empty, reuse empty shared string.
if High = 0 or else DL = 0 then
Reference (Empty_Shared_Wide_String'Access);
DR := Empty_Shared_Wide_String'Access;
-- Otherwise, allocate new shared string and fill it
else
DR := Allocate (DL);
DR.Data (1 .. DL) := SR.Data (Low .. High);
DR.Last := DL;
end if;
end if;
return (AF.Controlled with Reference => DR);
end Trim;
procedure Trim
(Source : in out Unbounded_Wide_String;
Left : Wide_Maps.Wide_Character_Set;
Right : Wide_Maps.Wide_Character_Set)
is
SR : constant Shared_Wide_String_Access := Source.Reference;
DL : Natural;
DR : Shared_Wide_String_Access;
Low : Natural;
High : Natural;
begin
Low := Index (Source, Left, Outside, Forward);
-- Source includes only characters from Left set, reuse empty shared
-- string.
if Low = 0 then
Reference (Empty_Shared_Wide_String'Access);
Source.Reference := Empty_Shared_Wide_String'Access;
Unreference (SR);
else
High := Index (Source, Right, Outside, Backward);
DL := Integer'Max (0, High - Low + 1);
-- Source includes only characters from Right set or result string
-- is empty, reuse empty shared string.
if High = 0 or else DL = 0 then
Reference (Empty_Shared_Wide_String'Access);
Source.Reference := Empty_Shared_Wide_String'Access;
Unreference (SR);
-- Try to reuse existent shared string
elsif Can_Be_Reused (SR, DL) then
SR.Data (1 .. DL) := SR.Data (Low .. High);
SR.Last := DL;
-- Otherwise, allocate new shared string and fill it
else
DR := Allocate (DL);
DR.Data (1 .. DL) := SR.Data (Low .. High);
DR.Last := DL;
Source.Reference := DR;
Unreference (SR);
end if;
end if;
end Trim;
---------------------
-- Unbounded_Slice --
---------------------
function Unbounded_Slice
(Source : Unbounded_Wide_String;
Low : Positive;
High : Natural) return Unbounded_Wide_String
is
SR : constant Shared_Wide_String_Access := Source.Reference;
DL : Natural;
DR : Shared_Wide_String_Access;
begin
-- Check bounds
if Low > SR.Last + 1 or else High > SR.Last then
raise Index_Error;
-- Result is empty slice, reuse empty shared string
elsif Low > High then
Reference (Empty_Shared_Wide_String'Access);
DR := Empty_Shared_Wide_String'Access;
-- Otherwise, allocate new shared string and fill it
else
DL := High - Low + 1;
DR := Allocate (DL);
DR.Data (1 .. DL) := SR.Data (Low .. High);
DR.Last := DL;
end if;
return (AF.Controlled with Reference => DR);
end Unbounded_Slice;
procedure Unbounded_Slice
(Source : Unbounded_Wide_String;
Target : out Unbounded_Wide_String;
Low : Positive;
High : Natural)
is
SR : constant Shared_Wide_String_Access := Source.Reference;
TR : constant Shared_Wide_String_Access := Target.Reference;
DL : Natural;
DR : Shared_Wide_String_Access;
begin
-- Check bounds
if Low > SR.Last + 1 or else High > SR.Last then
raise Index_Error;
-- Result is empty slice, reuse empty shared string
elsif Low > High then
Reference (Empty_Shared_Wide_String'Access);
Target.Reference := Empty_Shared_Wide_String'Access;
Unreference (TR);
else
DL := High - Low + 1;
-- Try to reuse existent shared string
if Can_Be_Reused (TR, DL) then
TR.Data (1 .. DL) := SR.Data (Low .. High);
TR.Last := DL;
-- Otherwise, allocate new shared string and fill it
else
DR := Allocate (DL);
DR.Data (1 .. DL) := SR.Data (Low .. High);
DR.Last := DL;
Target.Reference := DR;
Unreference (TR);
end if;
end if;
end Unbounded_Slice;
-----------------
-- Unreference --
-----------------
procedure Unreference (Item : not null Shared_Wide_String_Access) is
procedure Free is
new Ada.Unchecked_Deallocation
(Shared_Wide_String, Shared_Wide_String_Access);
Aux : Shared_Wide_String_Access := Item;
begin
if System.Atomic_Counters.Decrement (Aux.Counter) then
-- Reference counter of Empty_Shared_Wide_String must never reach
-- zero.
pragma Assert (Aux /= Empty_Shared_Wide_String'Access);
Free (Aux);
end if;
end Unreference;
end Ada.Strings.Wide_Unbounded;
|
kqr/qweyboard | Ada | 1,248 | ads | with Ada.Strings.Wide_Wide_Unbounded;
with Ada.Characters.Conversions;
with Ada.Strings.Wide_Wide_Maps.Wide_Wide_Constants;
with Ada.Wide_Wide_Text_IO;
-- Package to make it easier to deal with strings in general, but wide,
-- international strings in particular.
package Unicode_Strings is
package Unbounded
renames Ada.Strings.Wide_Wide_Unbounded;
package Conversions
renames Ada.Characters.Conversions;
package IO
renames Ada.Wide_Wide_Text_IO;
package Character_Maps
renames Ada.Strings.Wide_Wide_Maps.Wide_Wide_Constants;
function W (Item : String)
return Wide_Wide_String
renames Conversions.To_Wide_Wide_String;
function From_Unbounded (Item : Unbounded.Unbounded_Wide_Wide_String)
return Wide_Wide_String
renames Unbounded.To_Wide_Wide_String;
function To_Unbounded (Item : Wide_Wide_String)
return Unbounded.Unbounded_Wide_Wide_String
renames Unbounded.To_Unbounded_Wide_Wide_String;
function Un_W (Item : Wide_Wide_String)
return String
is (Conversions.To_String (Item, Substitute => '?'));
package Characters is
LF : constant Wide_Wide_Character := Wide_Wide_Character'Val (16#0a#);
end Characters;
end Unicode_Strings;
|
vpodzime/ada-util | Ada | 25,958 | adb | -----------------------------------------------------------------------
-- util-serialize-mappers -- Serialize objects in various formats
-- Copyright (C) 2010, 2011, 2012, 2014, 2017 Stephane Carrez
-- Written by Stephane Carrez ([email protected])
--
-- Licensed under the Apache License, Version 2.0 (the "License");
-- you may not use this file except in compliance with the License.
-- You may obtain a copy of the License at
--
-- http://www.apache.org/licenses/LICENSE-2.0
--
-- Unless required by applicable law or agreed to in writing, software
-- distributed under the License is distributed on an "AS IS" BASIS,
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-- See the License for the specific language governing permissions and
-- limitations under the License.
-----------------------------------------------------------------------
with System.Address_Image;
with Util.Strings;
with Ada.Tags;
with Ada.Exceptions;
with Ada.Unchecked_Deallocation;
package body Util.Serialize.Mappers is
use Util.Log;
-- The logger
Log : constant Loggers.Logger := Loggers.Create ("Util.Serialize.Mappers",
Util.Log.WARN_LEVEL);
-- -----------------------
-- Execute the mapping operation on the object associated with the current context.
-- The object is extracted from the context and the <b>Execute</b> operation is called.
-- -----------------------
procedure Execute (Handler : in Mapper;
Map : in Mapping'Class;
Ctx : in out Util.Serialize.Contexts.Context'Class;
Value : in Util.Beans.Objects.Object) is
begin
if Handler.Mapper /= null then
Handler.Mapper.all.Execute (Map, Ctx, Value);
end if;
end Execute;
function Is_Proxy (Controller : in Mapper) return Boolean is
begin
return Controller.Is_Proxy_Mapper;
end Is_Proxy;
-- -----------------------
-- Returns true if the mapper is a wildcard node (matches any element).
-- -----------------------
function Is_Wildcard (Controller : in Mapper) return Boolean is
begin
return Controller.Is_Wildcard;
end Is_Wildcard;
-- -----------------------
-- Returns the mapping name.
-- -----------------------
function Get_Name (Controller : in Mapper) return String is
begin
return Ada.Strings.Unbounded.To_String (Controller.Name);
end Get_Name;
-- -----------------------
-- Find the mapper associated with the given name.
-- Returns null if there is no mapper.
-- -----------------------
function Find_Mapper (Controller : in Mapper;
Name : in String;
Attribute : in Boolean := False) return Mapper_Access is
use type Ada.Strings.Unbounded.Unbounded_String;
Node : Mapper_Access := Controller.First_Child;
Recurse : Boolean := True;
Result : Mapper_Access := null;
begin
if Node = null and Controller.Mapper /= null then
return Controller.Mapper.Find_Mapper (Name, Attribute);
end if;
while Node /= null loop
if not Attribute and Node.Is_Wildcard then
Result := Node.Find_Mapper (Name, Attribute);
if Result /= null then
return Result;
else
return Node;
end if;
end if;
if Node.Name = Name then
if (Attribute = False and Node.Mapping = null)
or else not Node.Mapping.Is_Attribute
then
return Node;
end if;
if Attribute and Node.Mapping.Is_Attribute then
return Node;
end if;
end if;
if Node.Is_Deep_Wildcard and not Attribute and Node.Mapper /= null and Recurse then
Node := Node.Mapper.First_Child;
Result := Node.Mapper;
Recurse := False;
else
Node := Node.Next_Mapping;
end if;
end loop;
return Result;
end Find_Mapper;
-- -----------------------
-- Find a path component representing a child mapper under <b>From</b> and
-- identified by the given <b>Name</b>. If the mapper is not found, a new
-- Mapper_Node is created.
-- -----------------------
procedure Find_Path_Component (From : in out Mapper'Class;
Name : in String;
Root : in out Mapper_Access;
Result : out Mapper_Access) is
use Ada.Strings.Unbounded;
Node : Mapper_Access := From.First_Child;
Previous : Mapper_Access := null;
Wildcard : constant Boolean := Name = "*";
Deep_Wildcard : constant Boolean := Name = "**";
begin
if Root = null and Deep_Wildcard then
Root := Node;
end if;
if Node = null then
Result := new Mapper;
Result.Name := To_Unbounded_String (Name);
Result.Is_Wildcard := Wildcard or Deep_Wildcard;
Result.Is_Deep_Wildcard := Deep_Wildcard;
From.First_Child := Result;
else
loop
if Node.Name = Name then
Result := Node;
exit;
end if;
if Node.Next_Mapping = null then
Result := new Mapper;
Result.Name := To_Unbounded_String (Name);
Result.Is_Wildcard := Wildcard or Deep_Wildcard;
Result.Is_Deep_Wildcard := Deep_Wildcard;
if not Wildcard and not Deep_Wildcard then
Result.Next_Mapping := Node;
if Previous = null then
From.First_Child := Result;
else
Previous.Next_Mapping := Result;
end if;
else
Node.Next_Mapping := Result;
end if;
exit;
end if;
Previous := Node;
Node := Node.Next_Mapping;
end loop;
end if;
-- For deep wildcard mapping the mapping tree has to somehow redirect and use a
-- root node (ie, the '**' node). Create a proxy node to point to that wildcard root.
-- The wildcard nodes must be checked last and therefore appear at end of the mapping list.
if Root /= null then
Previous := Result;
while Previous.Next_Mapping /= null loop
Previous := Previous.Next_Mapping;
end loop;
if not Previous.Is_Wildcard and not Previous.Is_Deep_Wildcard then
Node := new Mapper;
Node.Name := To_Unbounded_String ("**");
Node.Is_Deep_Wildcard := True;
Node.Mapper := Root;
Previous.Next_Mapping := Node;
end if;
end if;
end Find_Path_Component;
-- -----------------------
-- Build the mapping tree that corresponds to the given <b>Path</b>.
-- Each path component is represented by a <b>Mapper_Node</b> element.
-- The node is created if it does not exists.
-- -----------------------
procedure Build_Path (Into : in out Mapper'Class;
Path : in String;
Last_Pos : out Natural;
Node : out Mapper_Access) is
Pos : Natural;
Root : Mapper_Access := null;
begin
Node := Into'Unchecked_Access;
Last_Pos := Path'First;
loop
Pos := Util.Strings.Index (Source => Path,
Char => '/',
From => Last_Pos);
if Pos = 0 then
Node.Find_Path_Component (Name => Path (Last_Pos .. Path'Last),
Root => Root,
Result => Node);
Last_Pos := Path'Last + 1;
else
Node.Find_Path_Component (Name => Path (Last_Pos .. Pos - 1),
Root => Root,
Result => Node);
Last_Pos := Pos + 1;
end if;
exit when Last_Pos > Path'Last;
end loop;
end Build_Path;
-- -----------------------
-- Add a mapping to associate the given <b>Path</b> to the mapper defined in <b>Map</b>.
-- The <b>Path</b> string describes the matching node using a simplified XPath notation.
-- Example:
-- info/first_name matches: <info><first_name>...</first_name></info>
-- info/a/b/name matches: <info><a><b><name>...</name></b></a></info>
-- */a/b/name matches: <i><i><j><a><b><name>...</name></b></a></j></i></i>
-- **/name matches: <i><name>...</name></i>, <b><c><name>...</name></c></b>
-- -----------------------
procedure Add_Mapping (Into : in out Mapper;
Path : in String;
Map : in Mapper_Access) is
procedure Copy (To : in Mapper_Access;
From : in Mapper_Access);
procedure Add_Mapper (From, To : in Mapper_Access);
function Find_Mapper (From : in Mapper_Access) return Mapper_Access;
procedure Append (To : in Mapper_Access;
Item : in Mapper_Access);
-- For the support of deep wildcard mapping (**), we must map a proxy node mapper
-- to the copy that was made. We maintain a small list of mapper pairs.
-- The implementation is intended to be simple for now...
type Mapper_Pair is record
First : Mapper_Access;
Second : Mapper_Access;
end record;
Node : Mapper_Access;
Last_Pos : Natural;
Mappers : array (1 .. 10) of Mapper_Pair;
procedure Add_Mapper (From, To : in Mapper_Access) is
begin
for I in Mappers'Range loop
if Mappers (I).First = null then
Mappers (I).First := From;
Mappers (I).Second := To;
return;
end if;
end loop;
Log.Error ("Too many wildcard mappers");
raise Mapping_Error with "Too many wildcard mapping, mapping is too complex!";
end Add_Mapper;
function Find_Mapper (From : in Mapper_Access) return Mapper_Access is
begin
for I in Mappers'Range loop
if Mappers (I).First = From then
return Mappers (I).Second;
end if;
end loop;
Log.Error ("Cannot find mapper {0}", System.Address_Image (From.all'Address));
return null;
end Find_Mapper;
procedure Append (To : in Mapper_Access;
Item : in Mapper_Access) is
Node : Mapper_Access := To.First_Child;
begin
if Node = null then
To.First_Child := Item;
else
while Node.Next_Mapping /= null loop
Node := Node.Next_Mapping;
end loop;
Node.Next_Mapping := Item;
end if;
end Append;
procedure Copy (To : in Mapper_Access;
From : in Mapper_Access) is
N : Mapper_Access;
Src : Mapper_Access := From;
begin
while Src /= null loop
N := Src.Clone;
N.Is_Clone := True;
if N.Is_Deep_Wildcard then
if N.Mapper /= null then
N.Mapper := Find_Mapper (N.Mapper);
else
Add_Mapper (Src, N);
end if;
end if;
Append (To, N);
if Src.First_Child /= null then
Copy (N, Src.First_Child);
end if;
Src := Src.Next_Mapping;
end loop;
end Copy;
use type Util.Log.Level_Type;
begin
if Log.Get_Level >= Util.Log.INFO_LEVEL then
Log.Info ("Mapping '{0}' for mapper {1}",
Path, Ada.Tags.Expanded_Name (Map'Tag));
end if;
-- Find or build the mapping tree.
Into.Build_Path (Path, Last_Pos, Node);
if Last_Pos < Path'Last then
Log.Warn ("Ignoring the end of mapping path {0}", Path);
end if;
if Node.Mapper /= null then
Log.Warn ("Overriding the mapping {0} for mapper X", Path);
end if;
if Map.First_Child /= null then
Copy (Node, Map.First_Child);
else
Node.Mapper := Map;
end if;
end Add_Mapping;
procedure Add_Mapping (Into : in out Mapper;
Path : in String;
Map : in Mapping_Access) is
use Ada.Strings.Unbounded;
Node : Mapper_Access;
Last_Pos : Natural;
begin
if Log.Get_Level >= Util.Log.INFO_LEVEL then
Log.Info ("Mapping '{0}' for mapper {1}",
Path, Ada.Tags.Expanded_Name (Map'Tag));
end if;
-- Find or build the mapping tree.
Into.Build_Path (Path, Last_Pos, Node);
if Last_Pos < Path'Last then
Log.Warn ("Ignoring the end of mapping path {0}", Path);
end if;
if Node.Mapping /= null then
Log.Warn ("Overriding the mapping {0} for mapper X", Path);
end if;
if Length (Node.Name) = 0 then
Log.Warn ("Mapped name is empty in mapping path {0}", Path);
elsif Element (Node.Name, 1) = '@' then
Delete (Node.Name, 1, 1);
Map.Is_Attribute := True;
else
Map.Is_Attribute := False;
end if;
Node.Mapping := Map;
Node.Mapper := Into'Unchecked_Access;
end Add_Mapping;
-- -----------------------
-- Clone the <b>Handler</b> instance and get a copy of that single object.
-- -----------------------
function Clone (Handler : in Mapper) return Mapper_Access is
Result : constant Mapper_Access := new Mapper;
begin
Result.Name := Handler.Name;
Result.Mapper := Handler.Mapper;
Result.Mapping := Handler.Mapping;
Result.Is_Proxy_Mapper := Handler.Is_Proxy_Mapper;
Result.Is_Clone := True;
Result.Is_Wildcard := Handler.Is_Wildcard;
Result.Is_Deep_Wildcard := Handler.Is_Deep_Wildcard;
return Result;
end Clone;
-- -----------------------
-- Set the name/value pair on the current object. For each active mapping,
-- find whether a rule matches our name and execute it.
-- -----------------------
procedure Set_Member (Handler : in Mapper;
Name : in String;
Value : in Util.Beans.Objects.Object;
Attribute : in Boolean := False;
Context : in out Util.Serialize.Contexts.Context'Class) is
Map : constant Mapper_Access := Mapper'Class (Handler).Find_Mapper (Name, Attribute);
begin
if Map /= null and then Map.Mapping /= null and then Map.Mapper /= null then
Map.Mapper.all.Execute (Map.Mapping.all, Context, Value);
end if;
end Set_Member;
procedure Start_Object (Handler : in Mapper;
Context : in out Util.Serialize.Contexts.Context'Class;
Name : in String) is
begin
if Handler.Mapper /= null then
Handler.Mapper.Start_Object (Context, Name);
end if;
end Start_Object;
procedure Finish_Object (Handler : in Mapper;
Context : in out Util.Serialize.Contexts.Context'Class;
Name : in String) is
begin
if Handler.Mapper /= null then
Handler.Mapper.Finish_Object (Context, Name);
end if;
end Finish_Object;
-- -----------------------
-- Dump the mapping tree on the logger using the INFO log level.
-- -----------------------
procedure Dump (Handler : in Mapper'Class;
Log : in Util.Log.Loggers.Logger'Class;
Prefix : in String := "") is
procedure Dump (Map : in Mapper'Class);
-- -----------------------
-- Dump the mapping description
-- -----------------------
procedure Dump (Map : in Mapper'Class) is
Name : constant String := Ada.Strings.Unbounded.To_String (Map.Name);
begin
if Map.Mapping /= null and then Map.Mapping.Is_Attribute then
Log.Info (" {0}@{1}", Prefix,
Ada.Strings.Unbounded.To_String (Map.Mapping.Name));
else
Log.Info (" {0}/{1}", Prefix, Name);
Dump (Map, Log, Prefix & "/" & Name);
end if;
end Dump;
begin
Iterate (Handler, Dump'Access);
end Dump;
procedure Iterate (Controller : in Mapper;
Process : not null access procedure (Map : in Mapper'Class)) is
Node : Mapper_Access := Controller.First_Child;
begin
-- Pass 1: process the attributes first
while Node /= null loop
if Node.Mapping /= null and then Node.Mapping.Is_Attribute then
Process.all (Node.all);
end if;
Node := Node.Next_Mapping;
end loop;
-- Pass 2: process the elements
Node := Controller.First_Child;
while Node /= null loop
if Node.Mapping = null or else not Node.Mapping.Is_Attribute then
Process.all (Node.all);
end if;
Node := Node.Next_Mapping;
end loop;
end Iterate;
-- -----------------------
-- Finalize the object and release any mapping.
-- -----------------------
overriding
procedure Finalize (Controller : in out Mapper) is
procedure Free is new Ada.Unchecked_Deallocation (Mapper'Class, Mapper_Access);
procedure Free is new Ada.Unchecked_Deallocation (Mapping'Class, Mapping_Access);
Node : Mapper_Access := Controller.First_Child;
Next : Mapper_Access;
begin
Controller.First_Child := null;
while Node /= null loop
Next := Node.Next_Mapping;
Free (Node);
Node := Next;
end loop;
if not Controller.Is_Clone then
Free (Controller.Mapping);
else
Controller.Mapping := null;
end if;
end Finalize;
-- ------------------------------
-- Start a document.
-- ------------------------------
procedure Start_Document (Stream : in out Processing) is
Context : Element_Context_Access;
begin
Context_Stack.Clear (Stream.Stack);
Context_Stack.Push (Stream.Stack);
Context := Context_Stack.Current (Stream.Stack);
Context.Active_Nodes (1) := Stream.Mapping_Tree'Unchecked_Access;
end Start_Document;
-- ------------------------------
-- Push the current context when entering in an element.
-- ------------------------------
procedure Push (Handler : in out Processing) is
use type Util.Serialize.Mappers.Mapper_Access;
begin
Context_Stack.Push (Handler.Stack);
end Push;
-- ------------------------------
-- Pop the context and restore the previous context when leaving an element
-- ------------------------------
procedure Pop (Handler : in out Processing) is
begin
Context_Stack.Pop (Handler.Stack);
end Pop;
function Find_Mapper (Handler : in Processing;
Name : in String) return Util.Serialize.Mappers.Mapper_Access is
pragma Unreferenced (Handler, Name);
begin
return null;
end Find_Mapper;
-- ------------------------------
-- Start a new object associated with the given name. This is called when
-- the '{' is reached. The reader must be updated so that the next
-- <b>Set_Member</b> procedure will associate the name/value pair on the
-- new object.
-- ------------------------------
procedure Start_Object (Handler : in out Processing;
Name : in String;
Logger : in out Util.Log.Logging'Class) is
pragma Unreferenced (Logger);
use type Util.Serialize.Mappers.Mapper_Access;
Current : constant Element_Context_Access := Context_Stack.Current (Handler.Stack);
Next : Element_Context_Access;
Pos : Positive;
begin
Log.Debug ("Start object {0}", Name);
Context_Stack.Push (Handler.Stack);
Next := Context_Stack.Current (Handler.Stack);
if Current /= null then
Pos := 1;
-- Notify we are entering in the given node for each active mapping.
for I in Current.Active_Nodes'Range loop
declare
Node : constant Mappers.Mapper_Access := Current.Active_Nodes (I);
Child : Mappers.Mapper_Access;
begin
exit when Node = null;
Child := Node.Find_Mapper (Name => Name);
if Child = null and then Node.Is_Wildcard then
Child := Node;
end if;
if Child /= null then
Log.Debug ("{0} is matching {1}", Name, Child.Get_Name);
Child.Start_Object (Handler, Name);
Next.Active_Nodes (Pos) := Child;
Pos := Pos + 1;
end if;
end;
end loop;
while Pos <= Next.Active_Nodes'Last loop
Next.Active_Nodes (Pos) := null;
Pos := Pos + 1;
end loop;
else
Next.Active_Nodes (1) := Handler.Mapping_Tree.Find_Mapper (Name);
end if;
end Start_Object;
-- ------------------------------
-- Finish an object associated with the given name. The reader must be
-- updated to be associated with the previous object.
-- ------------------------------
procedure Finish_Object (Handler : in out Processing;
Name : in String;
Logger : in out Util.Log.Logging'Class) is
pragma Unreferenced (Logger);
use type Util.Serialize.Mappers.Mapper_Access;
begin
Log.Debug ("Finish object {0}", Name);
declare
Current : constant Element_Context_Access := Context_Stack.Current (Handler.Stack);
begin
if Current /= null then
-- Notify we are leaving the given node for each active mapping.
for I in Current.Active_Nodes'Range loop
declare
Node : constant Mappers.Mapper_Access := Current.Active_Nodes (I);
begin
exit when Node = null;
Node.Finish_Object (Handler, Name);
end;
end loop;
end if;
end;
Handler.Pop;
end Finish_Object;
procedure Start_Array (Handler : in out Processing;
Name : in String;
Logger : in out Util.Log.Logging'Class) is
pragma Unreferenced (Name, Logger);
begin
Handler.Push;
end Start_Array;
procedure Finish_Array (Handler : in out Processing;
Name : in String;
Count : in Natural;
Logger : in out Util.Log.Logging'Class) is
pragma Unreferenced (Name, Count, Logger);
begin
Handler.Pop;
end Finish_Array;
-- -----------------------
-- Set the name/value pair on the current object. For each active mapping,
-- find whether a rule matches our name and execute it.
-- -----------------------
procedure Set_Member (Handler : in out Processing;
Name : in String;
Value : in Util.Beans.Objects.Object;
Logger : in out Util.Log.Logging'Class;
Attribute : in Boolean := False) is
use Util.Serialize.Mappers;
Current : constant Element_Context_Access := Context_Stack.Current (Handler.Stack);
begin
Log.Debug ("Set member {0}", Name);
if Current /= null then
-- Look each active mapping node.
for I in Current.Active_Nodes'Range loop
declare
Node : constant Mapper_Access := Current.Active_Nodes (I);
begin
exit when Node = null;
Node.Set_Member (Name => Name,
Value => Value,
Attribute => Attribute,
Context => Handler);
exception
when E : Util.Serialize.Mappers.Field_Error =>
Logger.Error (Message => Ada.Exceptions.Exception_Message (E));
when E : Util.Serialize.Mappers.Field_Fatal_Error =>
Logger.Error (Message => Ada.Exceptions.Exception_Message (E));
raise;
-- For other exception, report an error with the field name and value.
when E : others =>
Logger.Error (Message => "Cannot set field '" & Name & "' to '"
& Util.Beans.Objects.To_String (Value) & "': "
& Ada.Exceptions.Exception_Message (E));
raise;
end;
end loop;
end if;
end Set_Member;
procedure Add_Mapping (Handler : in out Processing;
Path : in String;
Mapper : in Util.Serialize.Mappers.Mapper_Access) is
begin
Handler.Mapping_Tree.Add_Mapping (Path, Mapper);
end Add_Mapping;
-- ------------------------------
-- Dump the mapping tree on the logger using the INFO log level.
-- ------------------------------
procedure Dump (Handler : in Processing'Class;
Logger : in Util.Log.Loggers.Logger'Class) is
begin
Util.Serialize.Mappers.Dump (Handler.Mapping_Tree, Logger, "Mapping ");
end Dump;
end Util.Serialize.Mappers;
|
reznikmm/matreshka | Ada | 3,922 | 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$
------------------------------------------------------------------------------
package AMF.UTP is
pragma Preelaborate;
type Optional_Timezone (Is_Empty : Boolean := True) is record
case Is_Empty is
when False =>
Value : Integer;
when True =>
null;
end case;
end record;
type UTP_Verdict is
(None,
Pass,
Inconclusive,
Fail,
Error);
type Optional_UTP_Verdict (Is_Empty : Boolean := True) is record
case Is_Empty is
when True =>
null;
when False =>
Value : UTP_Verdict;
end case;
end record;
end AMF.UTP;
|
iyan22/AprendeAda | Ada | 574 | adb | with Datos;
use Datos;
function Posicion ( L : Lista; Num : Integer ) return Natural is
-- pre:
-- post: el resultado es la posicion de la primera aparicion de Num,
-- caso de que Num pertenezca a L, y cero en otro caso
LCopia : Lista;
Found : Boolean;
Pos, PosDev : Integer;
begin
LCopia := L;
Pos := 0;
PosDev := 0;
Found := False;
while LCopia /= null and Found = False loop
pos := pos+1;
if LCopia.all.info = Num then
PosDev := Pos;
Found := True;
end if;
LCopia := LCopia.all.sig;
end loop;
return PosDev;
end Posicion;
|
meowthsli/EVB1000 | Ada | 18,079 | ads | -- This spec has been automatically generated from STM32F105xx.svd
pragma Restrictions (No_Elaboration_Code);
pragma Ada_2012;
with System;
package STM32.DMA is
pragma Preelaborate;
---------------
-- Registers --
---------------
------------------
-- ISR_Register --
------------------
subtype ISR_GIF1_Field is STM32.Bit;
subtype ISR_TCIF1_Field is STM32.Bit;
subtype ISR_HTIF1_Field is STM32.Bit;
subtype ISR_TEIF1_Field is STM32.Bit;
subtype ISR_GIF2_Field is STM32.Bit;
subtype ISR_TCIF2_Field is STM32.Bit;
subtype ISR_HTIF2_Field is STM32.Bit;
subtype ISR_TEIF2_Field is STM32.Bit;
subtype ISR_GIF3_Field is STM32.Bit;
subtype ISR_TCIF3_Field is STM32.Bit;
subtype ISR_HTIF3_Field is STM32.Bit;
subtype ISR_TEIF3_Field is STM32.Bit;
subtype ISR_GIF4_Field is STM32.Bit;
subtype ISR_TCIF4_Field is STM32.Bit;
subtype ISR_HTIF4_Field is STM32.Bit;
subtype ISR_TEIF4_Field is STM32.Bit;
subtype ISR_GIF5_Field is STM32.Bit;
subtype ISR_TCIF5_Field is STM32.Bit;
subtype ISR_HTIF5_Field is STM32.Bit;
subtype ISR_TEIF5_Field is STM32.Bit;
subtype ISR_GIF6_Field is STM32.Bit;
subtype ISR_TCIF6_Field is STM32.Bit;
subtype ISR_HTIF6_Field is STM32.Bit;
subtype ISR_TEIF6_Field is STM32.Bit;
subtype ISR_GIF7_Field is STM32.Bit;
subtype ISR_TCIF7_Field is STM32.Bit;
subtype ISR_HTIF7_Field is STM32.Bit;
subtype ISR_TEIF7_Field is STM32.Bit;
-- DMA interrupt status register (DMA_ISR)
type ISR_Register is record
-- Read-only. Channel 1 Global interrupt flag
GIF1 : ISR_GIF1_Field;
-- Read-only. Channel 1 Transfer Complete flag
TCIF1 : ISR_TCIF1_Field;
-- Read-only. Channel 1 Half Transfer Complete flag
HTIF1 : ISR_HTIF1_Field;
-- Read-only. Channel 1 Transfer Error flag
TEIF1 : ISR_TEIF1_Field;
-- Read-only. Channel 2 Global interrupt flag
GIF2 : ISR_GIF2_Field;
-- Read-only. Channel 2 Transfer Complete flag
TCIF2 : ISR_TCIF2_Field;
-- Read-only. Channel 2 Half Transfer Complete flag
HTIF2 : ISR_HTIF2_Field;
-- Read-only. Channel 2 Transfer Error flag
TEIF2 : ISR_TEIF2_Field;
-- Read-only. Channel 3 Global interrupt flag
GIF3 : ISR_GIF3_Field;
-- Read-only. Channel 3 Transfer Complete flag
TCIF3 : ISR_TCIF3_Field;
-- Read-only. Channel 3 Half Transfer Complete flag
HTIF3 : ISR_HTIF3_Field;
-- Read-only. Channel 3 Transfer Error flag
TEIF3 : ISR_TEIF3_Field;
-- Read-only. Channel 4 Global interrupt flag
GIF4 : ISR_GIF4_Field;
-- Read-only. Channel 4 Transfer Complete flag
TCIF4 : ISR_TCIF4_Field;
-- Read-only. Channel 4 Half Transfer Complete flag
HTIF4 : ISR_HTIF4_Field;
-- Read-only. Channel 4 Transfer Error flag
TEIF4 : ISR_TEIF4_Field;
-- Read-only. Channel 5 Global interrupt flag
GIF5 : ISR_GIF5_Field;
-- Read-only. Channel 5 Transfer Complete flag
TCIF5 : ISR_TCIF5_Field;
-- Read-only. Channel 5 Half Transfer Complete flag
HTIF5 : ISR_HTIF5_Field;
-- Read-only. Channel 5 Transfer Error flag
TEIF5 : ISR_TEIF5_Field;
-- Read-only. Channel 6 Global interrupt flag
GIF6 : ISR_GIF6_Field;
-- Read-only. Channel 6 Transfer Complete flag
TCIF6 : ISR_TCIF6_Field;
-- Read-only. Channel 6 Half Transfer Complete flag
HTIF6 : ISR_HTIF6_Field;
-- Read-only. Channel 6 Transfer Error flag
TEIF6 : ISR_TEIF6_Field;
-- Read-only. Channel 7 Global interrupt flag
GIF7 : ISR_GIF7_Field;
-- Read-only. Channel 7 Transfer Complete flag
TCIF7 : ISR_TCIF7_Field;
-- Read-only. Channel 7 Half Transfer Complete flag
HTIF7 : ISR_HTIF7_Field;
-- Read-only. Channel 7 Transfer Error flag
TEIF7 : ISR_TEIF7_Field;
-- unspecified
Reserved_28_31 : STM32.UInt4;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for ISR_Register use record
GIF1 at 0 range 0 .. 0;
TCIF1 at 0 range 1 .. 1;
HTIF1 at 0 range 2 .. 2;
TEIF1 at 0 range 3 .. 3;
GIF2 at 0 range 4 .. 4;
TCIF2 at 0 range 5 .. 5;
HTIF2 at 0 range 6 .. 6;
TEIF2 at 0 range 7 .. 7;
GIF3 at 0 range 8 .. 8;
TCIF3 at 0 range 9 .. 9;
HTIF3 at 0 range 10 .. 10;
TEIF3 at 0 range 11 .. 11;
GIF4 at 0 range 12 .. 12;
TCIF4 at 0 range 13 .. 13;
HTIF4 at 0 range 14 .. 14;
TEIF4 at 0 range 15 .. 15;
GIF5 at 0 range 16 .. 16;
TCIF5 at 0 range 17 .. 17;
HTIF5 at 0 range 18 .. 18;
TEIF5 at 0 range 19 .. 19;
GIF6 at 0 range 20 .. 20;
TCIF6 at 0 range 21 .. 21;
HTIF6 at 0 range 22 .. 22;
TEIF6 at 0 range 23 .. 23;
GIF7 at 0 range 24 .. 24;
TCIF7 at 0 range 25 .. 25;
HTIF7 at 0 range 26 .. 26;
TEIF7 at 0 range 27 .. 27;
Reserved_28_31 at 0 range 28 .. 31;
end record;
-------------------
-- IFCR_Register --
-------------------
subtype IFCR_CGIF1_Field is STM32.Bit;
subtype IFCR_CTCIF1_Field is STM32.Bit;
subtype IFCR_CHTIF1_Field is STM32.Bit;
subtype IFCR_CTEIF1_Field is STM32.Bit;
subtype IFCR_CGIF2_Field is STM32.Bit;
subtype IFCR_CTCIF2_Field is STM32.Bit;
subtype IFCR_CHTIF2_Field is STM32.Bit;
subtype IFCR_CTEIF2_Field is STM32.Bit;
subtype IFCR_CGIF3_Field is STM32.Bit;
subtype IFCR_CTCIF3_Field is STM32.Bit;
subtype IFCR_CHTIF3_Field is STM32.Bit;
subtype IFCR_CTEIF3_Field is STM32.Bit;
subtype IFCR_CGIF4_Field is STM32.Bit;
subtype IFCR_CTCIF4_Field is STM32.Bit;
subtype IFCR_CHTIF4_Field is STM32.Bit;
subtype IFCR_CTEIF4_Field is STM32.Bit;
subtype IFCR_CGIF5_Field is STM32.Bit;
subtype IFCR_CTCIF5_Field is STM32.Bit;
subtype IFCR_CHTIF5_Field is STM32.Bit;
subtype IFCR_CTEIF5_Field is STM32.Bit;
subtype IFCR_CGIF6_Field is STM32.Bit;
subtype IFCR_CTCIF6_Field is STM32.Bit;
subtype IFCR_CHTIF6_Field is STM32.Bit;
subtype IFCR_CTEIF6_Field is STM32.Bit;
subtype IFCR_CGIF7_Field is STM32.Bit;
subtype IFCR_CTCIF7_Field is STM32.Bit;
subtype IFCR_CHTIF7_Field is STM32.Bit;
subtype IFCR_CTEIF7_Field is STM32.Bit;
-- DMA interrupt flag clear register (DMA_IFCR)
type IFCR_Register is record
-- Write-only. Channel 1 Global interrupt clear
CGIF1 : IFCR_CGIF1_Field := 16#0#;
-- Write-only. Channel 1 Transfer Complete clear
CTCIF1 : IFCR_CTCIF1_Field := 16#0#;
-- Write-only. Channel 1 Half Transfer clear
CHTIF1 : IFCR_CHTIF1_Field := 16#0#;
-- Write-only. Channel 1 Transfer Error clear
CTEIF1 : IFCR_CTEIF1_Field := 16#0#;
-- Write-only. Channel 2 Global interrupt clear
CGIF2 : IFCR_CGIF2_Field := 16#0#;
-- Write-only. Channel 2 Transfer Complete clear
CTCIF2 : IFCR_CTCIF2_Field := 16#0#;
-- Write-only. Channel 2 Half Transfer clear
CHTIF2 : IFCR_CHTIF2_Field := 16#0#;
-- Write-only. Channel 2 Transfer Error clear
CTEIF2 : IFCR_CTEIF2_Field := 16#0#;
-- Write-only. Channel 3 Global interrupt clear
CGIF3 : IFCR_CGIF3_Field := 16#0#;
-- Write-only. Channel 3 Transfer Complete clear
CTCIF3 : IFCR_CTCIF3_Field := 16#0#;
-- Write-only. Channel 3 Half Transfer clear
CHTIF3 : IFCR_CHTIF3_Field := 16#0#;
-- Write-only. Channel 3 Transfer Error clear
CTEIF3 : IFCR_CTEIF3_Field := 16#0#;
-- Write-only. Channel 4 Global interrupt clear
CGIF4 : IFCR_CGIF4_Field := 16#0#;
-- Write-only. Channel 4 Transfer Complete clear
CTCIF4 : IFCR_CTCIF4_Field := 16#0#;
-- Write-only. Channel 4 Half Transfer clear
CHTIF4 : IFCR_CHTIF4_Field := 16#0#;
-- Write-only. Channel 4 Transfer Error clear
CTEIF4 : IFCR_CTEIF4_Field := 16#0#;
-- Write-only. Channel 5 Global interrupt clear
CGIF5 : IFCR_CGIF5_Field := 16#0#;
-- Write-only. Channel 5 Transfer Complete clear
CTCIF5 : IFCR_CTCIF5_Field := 16#0#;
-- Write-only. Channel 5 Half Transfer clear
CHTIF5 : IFCR_CHTIF5_Field := 16#0#;
-- Write-only. Channel 5 Transfer Error clear
CTEIF5 : IFCR_CTEIF5_Field := 16#0#;
-- Write-only. Channel 6 Global interrupt clear
CGIF6 : IFCR_CGIF6_Field := 16#0#;
-- Write-only. Channel 6 Transfer Complete clear
CTCIF6 : IFCR_CTCIF6_Field := 16#0#;
-- Write-only. Channel 6 Half Transfer clear
CHTIF6 : IFCR_CHTIF6_Field := 16#0#;
-- Write-only. Channel 6 Transfer Error clear
CTEIF6 : IFCR_CTEIF6_Field := 16#0#;
-- Write-only. Channel 7 Global interrupt clear
CGIF7 : IFCR_CGIF7_Field := 16#0#;
-- Write-only. Channel 7 Transfer Complete clear
CTCIF7 : IFCR_CTCIF7_Field := 16#0#;
-- Write-only. Channel 7 Half Transfer clear
CHTIF7 : IFCR_CHTIF7_Field := 16#0#;
-- Write-only. Channel 7 Transfer Error clear
CTEIF7 : IFCR_CTEIF7_Field := 16#0#;
-- unspecified
Reserved_28_31 : STM32.UInt4 := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for IFCR_Register use record
CGIF1 at 0 range 0 .. 0;
CTCIF1 at 0 range 1 .. 1;
CHTIF1 at 0 range 2 .. 2;
CTEIF1 at 0 range 3 .. 3;
CGIF2 at 0 range 4 .. 4;
CTCIF2 at 0 range 5 .. 5;
CHTIF2 at 0 range 6 .. 6;
CTEIF2 at 0 range 7 .. 7;
CGIF3 at 0 range 8 .. 8;
CTCIF3 at 0 range 9 .. 9;
CHTIF3 at 0 range 10 .. 10;
CTEIF3 at 0 range 11 .. 11;
CGIF4 at 0 range 12 .. 12;
CTCIF4 at 0 range 13 .. 13;
CHTIF4 at 0 range 14 .. 14;
CTEIF4 at 0 range 15 .. 15;
CGIF5 at 0 range 16 .. 16;
CTCIF5 at 0 range 17 .. 17;
CHTIF5 at 0 range 18 .. 18;
CTEIF5 at 0 range 19 .. 19;
CGIF6 at 0 range 20 .. 20;
CTCIF6 at 0 range 21 .. 21;
CHTIF6 at 0 range 22 .. 22;
CTEIF6 at 0 range 23 .. 23;
CGIF7 at 0 range 24 .. 24;
CTCIF7 at 0 range 25 .. 25;
CHTIF7 at 0 range 26 .. 26;
CTEIF7 at 0 range 27 .. 27;
Reserved_28_31 at 0 range 28 .. 31;
end record;
------------------
-- CCR_Register --
------------------
subtype CCR1_EN_Field is STM32.Bit;
subtype CCR1_TCIE_Field is STM32.Bit;
subtype CCR1_HTIE_Field is STM32.Bit;
subtype CCR1_TEIE_Field is STM32.Bit;
subtype CCR1_DIR_Field is STM32.Bit;
subtype CCR1_CIRC_Field is STM32.Bit;
subtype CCR1_PINC_Field is STM32.Bit;
subtype CCR1_MINC_Field is STM32.Bit;
subtype CCR1_PSIZE_Field is STM32.UInt2;
subtype CCR1_MSIZE_Field is STM32.UInt2;
subtype CCR1_PL_Field is STM32.UInt2;
subtype CCR1_MEM2MEM_Field is STM32.Bit;
-- DMA channel configuration register (DMA_CCR)
type CCR_Register is record
-- Channel enable
EN : CCR1_EN_Field := 16#0#;
-- Transfer complete interrupt enable
TCIE : CCR1_TCIE_Field := 16#0#;
-- Half Transfer interrupt enable
HTIE : CCR1_HTIE_Field := 16#0#;
-- Transfer error interrupt enable
TEIE : CCR1_TEIE_Field := 16#0#;
-- Data transfer direction
DIR : CCR1_DIR_Field := 16#0#;
-- Circular mode
CIRC : CCR1_CIRC_Field := 16#0#;
-- Peripheral increment mode
PINC : CCR1_PINC_Field := 16#0#;
-- Memory increment mode
MINC : CCR1_MINC_Field := 16#0#;
-- Peripheral size
PSIZE : CCR1_PSIZE_Field := 16#0#;
-- Memory size
MSIZE : CCR1_MSIZE_Field := 16#0#;
-- Channel Priority level
PL : CCR1_PL_Field := 16#0#;
-- Memory to memory mode
MEM2MEM : CCR1_MEM2MEM_Field := 16#0#;
-- unspecified
Reserved_15_31 : STM32.UInt17 := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for CCR_Register use record
EN at 0 range 0 .. 0;
TCIE at 0 range 1 .. 1;
HTIE at 0 range 2 .. 2;
TEIE at 0 range 3 .. 3;
DIR at 0 range 4 .. 4;
CIRC at 0 range 5 .. 5;
PINC at 0 range 6 .. 6;
MINC at 0 range 7 .. 7;
PSIZE at 0 range 8 .. 9;
MSIZE at 0 range 10 .. 11;
PL at 0 range 12 .. 13;
MEM2MEM at 0 range 14 .. 14;
Reserved_15_31 at 0 range 15 .. 31;
end record;
--------------------
-- CNDTR_Register --
--------------------
subtype CNDTR1_NDT_Field is STM32.Short;
-- DMA channel 1 number of data register
type CNDTR_Register is record
-- Number of data to transfer
NDT : CNDTR1_NDT_Field := 16#0#;
-- unspecified
Reserved_16_31 : STM32.Short := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for CNDTR_Register use record
NDT at 0 range 0 .. 15;
Reserved_16_31 at 0 range 16 .. 31;
end record;
-----------------
-- Peripherals --
-----------------
-- DMA controller
type DMA_Peripheral is record
-- DMA interrupt status register (DMA_ISR)
ISR : ISR_Register;
-- DMA interrupt flag clear register (DMA_IFCR)
IFCR : IFCR_Register;
-- DMA channel configuration register (DMA_CCR)
CCR1 : CCR_Register;
-- DMA channel 1 number of data register
CNDTR1 : CNDTR_Register;
-- DMA channel 1 peripheral address register
CPAR1 : STM32.Word;
-- DMA channel 1 memory address register
CMAR1 : STM32.Word;
-- DMA channel configuration register (DMA_CCR)
CCR2 : CCR_Register;
-- DMA channel 2 number of data register
CNDTR2 : CNDTR_Register;
-- DMA channel 2 peripheral address register
CPAR2 : STM32.Word;
-- DMA channel 2 memory address register
CMAR2 : STM32.Word;
-- DMA channel configuration register (DMA_CCR)
CCR3 : CCR_Register;
-- DMA channel 3 number of data register
CNDTR3 : CNDTR_Register;
-- DMA channel 3 peripheral address register
CPAR3 : STM32.Word;
-- DMA channel 3 memory address register
CMAR3 : STM32.Word;
-- DMA channel configuration register (DMA_CCR)
CCR4 : CCR_Register;
-- DMA channel 4 number of data register
CNDTR4 : CNDTR_Register;
-- DMA channel 4 peripheral address register
CPAR4 : STM32.Word;
-- DMA channel 4 memory address register
CMAR4 : STM32.Word;
-- DMA channel configuration register (DMA_CCR)
CCR5 : CCR_Register;
-- DMA channel 5 number of data register
CNDTR5 : CNDTR_Register;
-- DMA channel 5 peripheral address register
CPAR5 : STM32.Word;
-- DMA channel 5 memory address register
CMAR5 : STM32.Word;
-- DMA channel configuration register (DMA_CCR)
CCR6 : CCR_Register;
-- DMA channel 6 number of data register
CNDTR6 : CNDTR_Register;
-- DMA channel 6 peripheral address register
CPAR6 : STM32.Word;
-- DMA channel 6 memory address register
CMAR6 : STM32.Word;
-- DMA channel configuration register (DMA_CCR)
CCR7 : CCR_Register;
-- DMA channel 7 number of data register
CNDTR7 : CNDTR_Register;
-- DMA channel 7 peripheral address register
CPAR7 : STM32.Word;
-- DMA channel 7 memory address register
CMAR7 : STM32.Word;
end record
with Volatile;
for DMA_Peripheral use record
ISR at 0 range 0 .. 31;
IFCR at 4 range 0 .. 31;
CCR1 at 8 range 0 .. 31;
CNDTR1 at 12 range 0 .. 31;
CPAR1 at 16 range 0 .. 31;
CMAR1 at 20 range 0 .. 31;
CCR2 at 28 range 0 .. 31;
CNDTR2 at 32 range 0 .. 31;
CPAR2 at 36 range 0 .. 31;
CMAR2 at 40 range 0 .. 31;
CCR3 at 48 range 0 .. 31;
CNDTR3 at 52 range 0 .. 31;
CPAR3 at 56 range 0 .. 31;
CMAR3 at 60 range 0 .. 31;
CCR4 at 68 range 0 .. 31;
CNDTR4 at 72 range 0 .. 31;
CPAR4 at 76 range 0 .. 31;
CMAR4 at 80 range 0 .. 31;
CCR5 at 88 range 0 .. 31;
CNDTR5 at 92 range 0 .. 31;
CPAR5 at 96 range 0 .. 31;
CMAR5 at 100 range 0 .. 31;
CCR6 at 108 range 0 .. 31;
CNDTR6 at 112 range 0 .. 31;
CPAR6 at 116 range 0 .. 31;
CMAR6 at 120 range 0 .. 31;
CCR7 at 128 range 0 .. 31;
CNDTR7 at 132 range 0 .. 31;
CPAR7 at 136 range 0 .. 31;
CMAR7 at 140 range 0 .. 31;
end record;
-- DMA controller
DMA1_Periph : aliased DMA_Peripheral
with Import, Address => DMA1_Base;
-- DMA controller
DMA2_Periph : aliased DMA_Peripheral
with Import, Address => DMA2_Base;
end STM32.DMA;
|
reznikmm/matreshka | Ada | 3,434 | ads | ------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- XML Processor --
-- --
-- Runtime Library Component --
-- --
------------------------------------------------------------------------------
-- --
-- Copyright © 2011, Vadim Godunko <[email protected]> --
-- All rights reserved. --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions --
-- are met: --
-- --
-- * Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- --
-- * Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in the --
-- documentation and/or other materials provided with the distribution. --
-- --
-- * Neither the name of the Vadim Godunko, IE nor the names of its --
-- contributors may be used to endorse or promote products derived from --
-- this software without specific prior written permission. --
-- --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR --
-- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
-- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED --
-- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR --
-- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF --
-- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING --
-- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS --
-- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
-- --
------------------------------------------------------------------------------
-- $Revision$ $Date$
------------------------------------------------------------------------------
with XML.DOM.Nodes.Attributes;
package XML.DOM.Attributes renames XML.DOM.Nodes.Attributes;
|
charlie5/lace | Ada | 567 | ads | private package GID.Decoding_GIF is
--------------------
-- Image decoding --
--------------------
generic
type Primary_color_range is mod <>;
with procedure Set_X_Y (x, y: Natural);
with procedure Put_Pixel (
red, green, blue : Primary_color_range;
alpha : Primary_color_range
);
with procedure Feedback (percents: Natural);
mode: Display_mode;
--
procedure Load (
image : in out Image_descriptor;
next_frame: out Ada.Calendar.Day_Duration
);
end GID.Decoding_GIF;
|
caqg/linux-home | Ada | 4,468 | adb | ------------------------------------------------------------------------------
-- G P S --
-- --
-- Copyright (C) 2000-2016, 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 this software; see file --
-- COPYING3. If not, go to http://www.gnu.org/licenses for a complete copy --
-- of the license. --
------------------------------------------------------------------------------
with GNAT.Strings; use GNAT.Strings;
with Ada.Characters.Handling; use Ada.Characters.Handling;
package body Basic_Types is
--------------
-- Is_Equal --
--------------
function Is_Equal
(List1, List2 : GNAT.OS_Lib.Argument_List;
Case_Sensitive : Boolean := True;
Ordered : Boolean := False) return Boolean is
begin
if List1'Length /= List2'Length then
return False;
elsif Ordered then
for L in List1'Range loop
if List1 (L).all /= List2 (L - List1'First + List2'First).all then
return False;
end if;
end loop;
return True;
else
declare
L1 : GNAT.OS_Lib.Argument_List := List1;
L2 : GNAT.OS_Lib.Argument_List := List2;
begin
for A in L1'Range loop
for B in L2'Range loop
if L2 (B) /= null and then
((Case_Sensitive and then L1 (A).all = L2 (B).all)
or else
(not Case_Sensitive
and then To_Lower (L1 (A).all) = To_Lower (L2 (B).all)))
then
L1 (A) := null;
L2 (B) := null;
exit;
end if;
end loop;
end loop;
return L1 = (L1'Range => null)
and then L2 = (L2'Range => null);
end;
end if;
end Is_Equal;
--------------
-- Contains --
--------------
function Contains
(List : GNAT.OS_Lib.Argument_List;
Str : String;
Case_Sensitive : Boolean := True) return Boolean is
begin
if not Case_Sensitive then
declare
S : constant String := To_Lower (Str);
begin
for L in List'Range loop
if To_Lower (List (L).all) = S then
return True;
end if;
end loop;
end;
else
for L in List'Range loop
if List (L).all = Str then
return True;
end if;
end loop;
end if;
return False;
end Contains;
---------
-- "<" --
---------
function "<" (Left, Right : Date_Type) return Boolean is
begin
if Left.Year < Right.Year then
return True;
elsif Left.Year = Right.Year then
if Left.Month < Right.Month then
return True;
elsif Left.Month = Right.Month then
if Left.Day < Right.Day then
return True;
end if;
end if;
end if;
return False;
end "<";
----------
-- "<=" --
----------
function "<=" (Left, Right : Date_Type) return Boolean is
begin
return Left < Right or else Left = Right;
end "<=";
---------
-- ">" --
---------
function ">" (Left, Right : Date_Type) return Boolean is
begin
return not (Left < Right or else Left = Right);
end ">";
----------
-- ">=" --
----------
function ">=" (Left, Right : Date_Type) return Boolean is
begin
return not (Left < Right);
end ">=";
end Basic_Types;
|
AdaCore/libadalang | Ada | 609 | adb | procedure Test is
type R (B : Boolean) is record
case B is
when False =>
X : Integer;
when True =>
null;
end case;
end record;
--% node.p_get_aspect("unchecked_union")
pragma Unchecked_Union (R);
type Arr is array (1 .. 10) of Integer;
--% node.p_get_aspect("volatile_components")
--% node.p_get_aspect("independent_components")
pragma Volatile_Components (Arr);
pragma Independent_Components (Arr);
type Enum is (A, B, C);
--% node.p_get_aspect("discard_names")
pragma Discard_Names (Enum);
begin
null;
end Test;
|
stcarrez/hestia | Ada | 12,081 | adb | -----------------------------------------------------------------------
-- hestia-display -- Display manager
-- Copyright (C) 2016, 2017 Stephane Carrez
-- Written by Stephane Carrez ([email protected])
--
-- Licensed under the Apache License, Version 2.0 (the "License");
-- you may not use this file except in compliance with the License.
-- You may obtain a copy of the License at
--
-- http://www.apache.org/licenses/LICENSE-2.0
--
-- Unless required by applicable law or agreed to in writing, software
-- distributed under the License is distributed on an "AS IS" BASIS,
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-- See the License for the specific language governing permissions and
-- limitations under the License.
-----------------------------------------------------------------------
with STM32.Board;
with Bitmapped_Drawing;
with BMP_Fonts;
with Interfaces;
with UI.Texts;
with Hestia.Network;
with Hestia.Time;
with Net.NTP;
with Hestia.Scheduler;
package body Hestia.Display is
use type Interfaces.Unsigned_32;
use type Interfaces.Unsigned_64;
use UI.Texts;
use type Net.Uint16;
-- Convert the integer to a string without a leading space.
function Image (Value : in Net.Uint32) return String;
function Image (Value : in Net.Uint64) return String;
function To_Digits (Val : Natural) return String;
function To_String (H, M, S : Natural) return String;
Buttons : UI.Buttons.Button_Array (B_MAIN .. B_STAT) :=
(B_MAIN => (Name => "Main ", State => UI.Buttons.B_PRESSED, others => <>),
B_SETUP => (Name => "Setup", others => <>),
B_STAT => (Name => "Stats", others => <>));
-- Kb, Mb, Gb units.
KB : constant Net.Uint64 := 1024;
MB : constant Net.Uint64 := KB * KB;
GB : constant Net.Uint64 := MB * MB;
-- Convert the integer to a string without a leading space.
function Image (Value : in Net.Uint32) return String is
Result : constant String := Net.Uint32'Image (Value);
begin
return Result (Result'First + 1 .. Result'Last);
end Image;
function Image (Value : in Net.Uint64) return String is
Result : constant String := Net.Uint64'Image (Value);
begin
return Result (Result'First + 1 .. Result'Last);
end Image;
Dec_String : constant String := "0123456789";
function To_Digits (Val : Natural) return String is
Result : String (1 .. 2);
begin
Result (1) := Dec_String (Positive ((Val / 10) + 1));
Result (2) := Dec_String (Positive ((Val mod 10) + 1));
return Result;
end To_Digits;
function To_String (H, M, S : Natural) return String is
begin
return To_Digits (H) & ":" & To_Digits (M) & ":" & To_Digits (S);
end To_String;
function Format_Packets (Value : in Net.Uint32) return String is
begin
return Net.Uint32'Image (Value);
end Format_Packets;
function Format_Bytes (Value : in Net.Uint64) return String is
begin
if Value < 10 * KB then
return Image (Net.Uint32 (Value));
elsif Value < 10 * MB then
return Image (Value / KB) & "." & Image (((Value mod KB) * 10) / KB) & "Kb";
elsif Value < 10 * GB then
return Image (Value / MB) & "." & Image (((Value mod MB) * 10) / MB) & "Mb";
else
return Image (Value / GB) & "." & Image (((Value mod GB) * 10) / GB) & "Gb";
end if;
end Format_Bytes;
function Format_Bandwidth (Value : in Net.Uint32) return String is
begin
if Value < Net.Uint32 (KB) then
return Image (Value);
elsif Value < Net.Uint32 (MB) then
return Image (Value / Net.Uint32 (KB)) & "."
& Image (((Value mod Net.Uint32 (KB)) * 10) / Net.Uint32 (KB)) & "Kbs";
else
return Image (Value / Net.Uint32 (MB)) & "."
& Image (((Value mod Net.Uint32 (MB)) * 10) / Net.Uint32 (MB)) & "Mbs";
end if;
end Format_Bandwidth;
-- ------------------------------
-- Initialize the display.
-- ------------------------------
procedure Initialize is
begin
STM32.Board.Display.Initialize;
STM32.Board.Display.Initialize_Layer (1, HAL.Bitmap.ARGB_1555);
-- Initialize touch panel
STM32.Board.Touch_Panel.Initialize;
end Initialize;
-- ------------------------------
-- Draw the display buttons.
-- ------------------------------
procedure Draw_Buttons (Buffer : in out HAL.Bitmap.Bitmap_Buffer'Class) is
begin
UI.Buttons.Draw_Buttons (Buffer => Buffer,
List => Buttons,
X => 0,
Y => 0,
Width => 95,
Height => 34);
end Draw_Buttons;
-- ------------------------------
-- Draw the layout presentation frame.
-- ------------------------------
procedure Draw_Frame (Buffer : in out HAL.Bitmap.Bitmap_Buffer'Class) is
begin
Buffer.Set_Source (UI.Texts.Background);
Buffer.Fill;
Draw_Buttons (Buffer);
Buffer.Set_Source (Line_Color);
Buffer.Draw_Vertical_Line (Pt => (98, 0),
Height => Buffer.Height);
end Draw_Frame;
-- ------------------------------
-- Display the current heat schedule and status.
-- ------------------------------
procedure Display_Main (Buffer : in out HAL.Bitmap.Bitmap_Buffer'Class) is
Ref : constant Net.NTP.NTP_Reference := Hestia.Network.Get_Time;
T : Hestia.Time.Date_Time;
begin
if Ref.Status in Net.NTP.SYNCED | Net.NTP.RESYNC then
T := Hestia.Time.Convert (Ref);
Buffer.Set_Source (UI.Texts.Background);
Buffer.Fill_Rect (Area => (Position => (100, 0),
Width => Buffer.Width - 100,
Height => Buffer.Height));
Hestia.Scheduler.Display (Buffer, T);
end if;
end Display_Main;
-- ------------------------------
-- Display devices found on the network.
-- ------------------------------
procedure Display_Setup (Buffer : in out HAL.Bitmap.Bitmap_Buffer'Class) is
Y : constant Natural := 0;
W : Natural := Buffer.Width;
begin
Buffer.Set_Source (UI.Texts.Background);
Buffer.Fill_Rect (Area => (Position => (100, 0),
Width => Buffer.Width - 100,
Height => Buffer.Height));
-- Draw some column header.
Buffer.Set_Source (Line_Color);
Buffer.Draw_Horizontal_Line (Pt => (100, Y + 14),
Width => Buffer.Width - 100);
UI.Texts.Draw_String (Buffer, (200, 60), 175, "Lundi");
Buffer.Set_Source (Hot_Color);
Buffer.Fill_Rect (Area => (Position => (100, 100),
Width => Buffer.Width - 100,
Height => 40));
Buffer.Fill_Rect (Area => (Position => (100, 200),
Width => Buffer.Width - 100,
Height => 40));
Buffer.Set_Source (HAL.Bitmap.White_Smoke);
W := W - 100;
for I in 0 .. 11 loop
Buffer.Draw_Vertical_Line (Pt => (100 + (I * W) / 12, 100 - 5),
Height => 5);
Buffer.Draw_Vertical_Line (Pt => (100 + (I * W) / 12, 200 - 5),
Height => 5);
end loop;
UI.Texts.Foreground := HAL.Bitmap.Green;
UI.Texts.Current_Font := BMP_Fonts.Font8x8;
UI.Texts.Draw_String (Buffer, (100, 100 - 10), 175, "0h");
UI.Texts.Draw_String (Buffer, (100 + 62, 100 - 10), 175, "2h");
UI.Texts.Draw_String (Buffer, (100 + 62 * 2 - 8, 100 - 10), 175, "4h");
UI.Texts.Draw_String (Buffer, (100 + 62 * 3 - 8, 100 - 10), 175, "6h");
UI.Texts.Draw_String (Buffer, (100 + 62 * 4 - 8, 100 - 10), 175, "8h");
UI.Texts.Draw_String (Buffer, (100 + 62 * 5 - 12, 100 - 10), 175, "10h");
UI.Texts.Foreground := HAL.Bitmap.Green;
UI.Texts.Foreground := HAL.Bitmap.White;
end Display_Setup;
use Ada.Real_Time;
Prev_Time : Ada.Real_Time.Time := Ada.Real_Time.Clock;
Deadline : Ada.Real_Time.Time := Prev_Time + Ada.Real_Time.Seconds (1);
Speed : Net.Uint32 := 0;
Bandwidth : Natural := 0;
Pkts : Net.Uint32 := 0;
Bytes : Net.Uint64 := 0;
ONE_MS : constant Ada.Real_Time.Time_Span := Ada.Real_Time.Milliseconds (1);
procedure Display_Time (Buffer : in out HAL.Bitmap.Bitmap_Buffer'Class;
Deadline : out Ada.Real_Time.Time) is
Ref : constant Net.NTP.NTP_Reference := Hestia.Network.Get_Time;
W : Net.Uint64;
T : Hestia.Time.Date_Time;
begin
if not (Ref.Status in Net.NTP.SYNCED | Net.NTP.RESYNC) then
Deadline := Ada.Real_Time.Clock + Ada.Real_Time.Seconds (1);
else
T := Hestia.Time.Convert (Ref);
W := Net.Uint64 (Net.Uint32'Last - T.Sub_Seconds);
W := Interfaces.Shift_Right (W * 1_000_000, 32);
Deadline := Ada.Real_Time.Clock + Ada.Real_Time.Microseconds (Integer (W));
UI.Texts.Current_Font := BMP_Fonts.Font16x24;
UI.Texts.Draw_String (Buffer, (30, 10), 128, Hestia.Time.Day_Names (T.Week_Day));
UI.Texts.Draw_String (Buffer, (140, 10), 128, Natural'Image (T.Day));
UI.Texts.Draw_String (Buffer, (200, 10), 128,
Hestia.Time.Month_Names (T.Month) (1 .. 3));
UI.Texts.Draw_String (Buffer, (300, 10), 175, To_String (T.Hour, T.Minute, T.Second));
UI.Texts.Current_Font := BMP_Fonts.Font12x12;
end if;
end Display_Time;
-- ------------------------------
-- Display a performance summary indicator.
-- ------------------------------
procedure Display_Summary (Buffer : in out HAL.Bitmap.Bitmap_Buffer'Class) is
Now : constant Ada.Real_Time.Time := Ada.Real_Time.Clock;
Cur_Pkts : Net.Uint32;
Cur_Bytes : Net.Uint64;
D : Net.Uint32;
C : Net.Uint32;
begin
if Deadline < Now then
Cur_Bytes := Hestia.Network.Ifnet.Rx_Stats.Bytes;
Cur_Pkts := Hestia.Network.Ifnet.Rx_Stats.Packets;
C := Net.Uint32 ((Now - Prev_Time) / ONE_MS);
D := Net.Uint32 (Cur_Pkts - Pkts);
Speed := Net.Uint32 (D * 1000) / C;
Bandwidth := Natural (((Cur_Bytes - Bytes) * 8000) / Net.Uint64 (C));
Prev_Time := Now;
Deadline := Deadline + Ada.Real_Time.Seconds (1);
Pkts := Cur_Pkts;
Bytes := Cur_Bytes;
end if;
Buffer.Set_Source (UI.Texts.Background);
Buffer.Fill_Rect (Area => (Position => (0, 160),
Width => 99,
Height => Buffer.Height - 160));
Bitmapped_Drawing.Draw_String
(Buffer,
Start => (3, 220),
Msg => "pkts/s",
Font => BMP_Fonts.Font12x12,
Foreground => UI.Texts.Foreground,
Background => UI.Texts.Background);
Bitmapped_Drawing.Draw_String
(Buffer,
Start => (3, 160),
Msg => "bps",
Font => BMP_Fonts.Font12x12,
Foreground => UI.Texts.Foreground,
Background => UI.Texts.Background);
Bitmapped_Drawing.Draw_String
(Buffer,
Start => (0, 250),
Msg => Image (Speed),
Font => BMP_Fonts.Font16x24,
Foreground => UI.Texts.Foreground,
Background => UI.Texts.Background);
Bitmapped_Drawing.Draw_String
(Buffer,
Start => (0, 180),
Msg => Format_Bandwidth (Interfaces.Unsigned_32 (Bandwidth)),
Font => BMP_Fonts.Font16x24,
Foreground => UI.Texts.Foreground,
Background => UI.Texts.Background);
end Display_Summary;
end Hestia.Display;
|
MinimSecure/unum-sdk | Ada | 949 | adb | -- Copyright 2008-2019 Free Software Foundation, Inc.
--
-- This program is free software; you can redistribute it and/or modify
-- it under the terms of the GNU General Public License as published by
-- the Free Software Foundation; either version 3 of the License, or
-- (at your option) any later version.
--
-- This program is distributed in the hope that it will be useful,
-- but WITHOUT ANY WARRANTY; without even the implied warranty of
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-- GNU General Public License for more details.
--
-- You should have received a copy of the GNU General Public License
-- along with this program. If not, see <http://www.gnu.org/licenses/>.
package body Pck is
type Empty is record
Month : Integer;
Year : Integer;
end record;
function Create return Wrap is
begin
return (E => new Empty'(Month => 8, Year => 1974));
end Create;
end Pck;
|
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.Elements;
package ODF.DOM.Table_Data_Pilot_Field_Reference_Elements is
pragma Preelaborate;
type ODF_Table_Data_Pilot_Field_Reference is limited interface
and XML.DOM.Elements.DOM_Element;
type ODF_Table_Data_Pilot_Field_Reference_Access is
access all ODF_Table_Data_Pilot_Field_Reference'Class
with Storage_Size => 0;
end ODF.DOM.Table_Data_Pilot_Field_Reference_Elements;
|
Pateldisolution/tictactoe | Ada | 661 | ads | with Tictactoe; use Tictactoe;
package Stack
with SPARK_Mode => On
is
procedure Push (V : Board)
with Pre => not Full,
Post => Size = Size'Old + 1;
procedure Pop (V : out Board)
with Pre => not Empty,
Post => Size = Size'Old - 1;
procedure Clear;
function Top return Board
with Pre => not Empty;
Max_Size : constant := 9;
-- The stack size.
Last : Natural range 0 .. Max_Size := 0;
-- Indicates the top of the stack. When 0 the stack is empty.
function Full return Boolean is (Last >= Max_Size);
function Empty return Boolean is (Last < 1);
function Size return Integer is (Last);
end Stack;
|
reznikmm/matreshka | Ada | 6,740 | adb | ------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- Open Document Toolkit --
-- --
-- Runtime Library Component --
-- --
------------------------------------------------------------------------------
-- --
-- Copyright © 2014, Vadim Godunko <[email protected]> --
-- All rights reserved. --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions --
-- are met: --
-- --
-- * Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- --
-- * Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in the --
-- documentation and/or other materials provided with the distribution. --
-- --
-- * Neither the name of the Vadim Godunko, IE nor the names of its --
-- contributors may be used to endorse or promote products derived from --
-- this software without specific prior written permission. --
-- --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR --
-- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
-- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED --
-- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR --
-- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF --
-- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING --
-- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS --
-- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
-- --
------------------------------------------------------------------------------
-- $Revision$ $Date$
------------------------------------------------------------------------------
with Matreshka.DOM_Documents;
with Matreshka.ODF_String_Constants;
with ODF.DOM.Iterators;
with ODF.DOM.Visitors;
package body Matreshka.ODF_Math.Math_Elements is
------------
-- Create --
------------
overriding function Create
(Parameters : not null access Matreshka.DOM_Elements.Element_L2_Parameters)
return Math_Math_Element_Node is
begin
return Self : Math_Math_Element_Node do
Matreshka.ODF_Math.Constructors.Initialize
(Self'Unchecked_Access,
Parameters.Document,
Matreshka.ODF_String_Constants.Math_Prefix);
end return;
end Create;
----------------
-- Enter_Node --
----------------
overriding procedure Enter_Node
(Self : not null access Math_Math_Element_Node;
Visitor : in out XML.DOM.Visitors.Abstract_Visitor'Class;
Control : in out XML.DOM.Visitors.Traverse_Control) is
begin
if Visitor in ODF.DOM.Visitors.Abstract_ODF_Visitor'Class then
ODF.DOM.Visitors.Abstract_ODF_Visitor'Class
(Visitor).Enter_Math_Math
(ODF.DOM.Math_Math_Elements.ODF_Math_Math_Access
(Self),
Control);
else
Matreshka.DOM_Elements.Abstract_Element_Node
(Self.all).Enter_Node (Visitor, Control);
end if;
end Enter_Node;
--------------------
-- Get_Local_Name --
--------------------
overriding function Get_Local_Name
(Self : not null access constant Math_Math_Element_Node)
return League.Strings.Universal_String
is
pragma Unreferenced (Self);
begin
return Matreshka.ODF_String_Constants.Math_Element;
end Get_Local_Name;
----------------
-- Leave_Node --
----------------
overriding procedure Leave_Node
(Self : not null access Math_Math_Element_Node;
Visitor : in out XML.DOM.Visitors.Abstract_Visitor'Class;
Control : in out XML.DOM.Visitors.Traverse_Control) is
begin
if Visitor in ODF.DOM.Visitors.Abstract_ODF_Visitor'Class then
ODF.DOM.Visitors.Abstract_ODF_Visitor'Class
(Visitor).Leave_Math_Math
(ODF.DOM.Math_Math_Elements.ODF_Math_Math_Access
(Self),
Control);
else
Matreshka.DOM_Elements.Abstract_Element_Node
(Self.all).Leave_Node (Visitor, Control);
end if;
end Leave_Node;
----------------
-- Visit_Node --
----------------
overriding procedure Visit_Node
(Self : not null access Math_Math_Element_Node;
Iterator : in out XML.DOM.Visitors.Abstract_Iterator'Class;
Visitor : in out XML.DOM.Visitors.Abstract_Visitor'Class;
Control : in out XML.DOM.Visitors.Traverse_Control) is
begin
if Iterator in ODF.DOM.Iterators.Abstract_ODF_Iterator'Class then
ODF.DOM.Iterators.Abstract_ODF_Iterator'Class
(Iterator).Visit_Math_Math
(Visitor,
ODF.DOM.Math_Math_Elements.ODF_Math_Math_Access
(Self),
Control);
else
Matreshka.DOM_Elements.Abstract_Element_Node
(Self.all).Visit_Node (Iterator, Visitor, Control);
end if;
end Visit_Node;
begin
Matreshka.DOM_Documents.Register_Element
(Matreshka.ODF_String_Constants.Math_URI,
Matreshka.ODF_String_Constants.Math_Element,
Math_Math_Element_Node'Tag);
end Matreshka.ODF_Math.Math_Elements;
|
reznikmm/clic | Ada | 65 | ads | package CLIC_Ex.Commands.Topics is
end CLIC_Ex.Commands.Topics;
|
pchapin/acrypto | Ada | 459 | ads | ---------------------------------------------------------------------------
-- FILE : test_hashes.ads
-- SUBJECT : Specification of test package for hash functions.
-- AUTHOR : (C) Copyright 2009 by Peter Chapin
--
-- Please send comments or bug reports to
--
-- Peter Chapin <[email protected]>
---------------------------------------------------------------------------
package Test_Hashers is
procedure Execute;
end Test_Hashers;
|
persan/AdaYaml | Ada | 524 | ads | -- part of ParserTools, (c) 2017 Felix Krause
-- released under the terms of the MIT license, see the file "copying.txt"
with Strings_Edit.UTF8;
package Lexer.Base.Unicode is
-- this package assumes that the input is encoded in UTF-8.
subtype Rune is Strings_Edit.UTF8.UTF8_Code_Point;
function Next (Object : in out Instance'Class) return Rune with Inline;
End_Of_Input : constant Rune := 4;
Line_Feed : constant Rune := 10;
Carriage_Return : constant Rune := 13;
end Lexer.Base.Unicode;
|
reznikmm/matreshka | Ada | 4,097 | 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.Presentation_Mouse_As_Pen_Attributes;
package Matreshka.ODF_Presentation.Mouse_As_Pen_Attributes is
type Presentation_Mouse_As_Pen_Attribute_Node is
new Matreshka.ODF_Presentation.Abstract_Presentation_Attribute_Node
and ODF.DOM.Presentation_Mouse_As_Pen_Attributes.ODF_Presentation_Mouse_As_Pen_Attribute
with null record;
overriding function Create
(Parameters : not null access Matreshka.DOM_Attributes.Attribute_L2_Parameters)
return Presentation_Mouse_As_Pen_Attribute_Node;
overriding function Get_Local_Name
(Self : not null access constant Presentation_Mouse_As_Pen_Attribute_Node)
return League.Strings.Universal_String;
end Matreshka.ODF_Presentation.Mouse_As_Pen_Attributes;
|
stcarrez/mat | Ada | 1,603 | ads | -----------------------------------------------------------------------
-- mat-readers-streams -- Reader for streams
-- Copyright (C) 2014, 2015, 2019 Stephane Carrez
-- Written by Stephane Carrez ([email protected])
--
-- Licensed under the Apache License, Version 2.0 (the "License");
-- you may not use this file except in compliance with the License.
-- You may obtain a copy of the License at
--
-- http://www.apache.org/licenses/LICENSE-2.0
--
-- Unless required by applicable law or agreed to in writing, software
-- distributed under the License is distributed on an "AS IS" BASIS,
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-- See the License for the specific language governing permissions and
-- limitations under the License.
-----------------------------------------------------------------------
with Util.Streams.Buffered;
with MAT.Events.Probes;
package MAT.Readers.Streams is
type Stream_Reader_Type is new MAT.Events.Probes.Probe_Manager_Type with private;
-- Read the events from the stream and stop when the end of the stream is reached.
procedure Read_All (Reader : in out Stream_Reader_Type);
-- Read a message from the stream.
overriding
procedure Read_Message (Reader : in out Stream_Reader_Type;
Msg : in out Message_Type);
private
type Stream_Reader_Type is new MAT.Events.Probes.Probe_Manager_Type with record
Stream : Util.Streams.Buffered.Input_Buffer_Stream;
Data : Util.Streams.Buffered.Buffer_Access;
end record;
end MAT.Readers.Streams;
|
France-ioi/taskgrader | Ada | 193 | adb | with Ada.Text_IO;
with Ada.Strings.Fixed;
use Ada.Text_IO;
procedure Main is
begin
Put_Line (Ada.Strings.Fixed.Trim (Integer'Image (2 * (Integer'Value (Get_Line))), Ada.Strings.Left));
end;
|
onox/sdlada | Ada | 2,200 | adb | --------------------------------------------------------------------------------------------------------------------
-- 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.Inputs.Joysticks.Makers
--------------------------------------------------------------------------------------------------------------------
with Interfaces.C;
private with SDL.C_Pointers;
package body SDL.Inputs.Joysticks.Makers is
package C renames Interfaces.C;
use type C.int;
use type SDL.C_Pointers.Joystick_Pointer;
function SDL_Joystick_Open (Device : in C.int) return SDL.C_Pointers.Joystick_Pointer with
Import => True,
Convention => C,
External_Name => "SDL_JoystickOpen";
function Create (Device : in Devices) return Joystick is
begin
return J : Joystick := (Ada.Finalization.Limited_Controlled with
Internal => SDL_Joystick_Open (C.int (Device) - 1), Owns => True) do
null;
end return;
end Create;
procedure Create (Device : in Devices; Actual_Stick : out Joystick) is
begin
Actual_Stick.Internal := SDL_Joystick_Open (C.int (Device) - 1);
end Create;
end SDL.Inputs.Joysticks.Makers;
|
pchapin/acrypto | Ada | 1,384 | adb | ---------------------------------------------------------------------------
-- FILE : aco-bit_operations.ads
-- SUBJECT : Bit manipulation operations that (currently) can't be proven by SPARK.
-- AUTHOR : (C) Copyright 2014 by Peter Chapin
--
-- Please send comments or bug reports to
--
-- Peter Chapin <[email protected]>
---------------------------------------------------------------------------
pragma SPARK_Mode(Off);
with ACO.Octuple_Octet_Operations;
with ACO.Quadruple_Octet_Operations;
package body ACO.Bit_Operations is
procedure Split32_To_Word8(Value : in ACO.Quadruple_Octet; Most, Middle_High, Middle_Low, Least : out ACO.Octet) is
begin
Most := ACO.Octet(Quadruple_Octet_Operations.Shift_Right(Value and 16#FF000000#, 24));
Middle_High := ACO.Octet(Quadruple_Octet_Operations.Shift_Right(Value and 16#00FF0000#, 16));
Middle_Low := ACO.Octet(Quadruple_Octet_Operations.Shift_Right(Value and 16#0000FF00#, 8));
Least := ACO.Octet(Value and 16#000000FF#);
end Split32_To_Word8;
procedure Split64_To_Word32(Value : in ACO.Octuple_Octet; Most, Least : out ACO.Quadruple_Octet) is
begin
Most := ACO.Quadruple_Octet(Octuple_Octet_Operations.Shift_Right(Value, 32));
Least := ACO.Quadruple_Octet(Value and 16#00000000FFFFFFFF#);
end Split64_To_Word32;
end ACO.Bit_Operations;
|
ellamosi/Ada_BMP_Library | Ada | 8,830 | adb | ------------------------------------------------------------------------------
-- --
-- Copyright (C) 2015-2016, AdaCore --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions are --
-- met: --
-- 1. Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- 2. Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in --
-- the documentation and/or other materials provided with the --
-- distribution. --
-- 3. Neither the name of the copyright holder nor the names of its --
-- contributors may be used to endorse or promote products derived --
-- from this software without specific prior written permission. --
-- --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR --
-- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
-- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT --
-- LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, --
-- DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY --
-- THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT --
-- (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE --
-- OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
-- --
------------------------------------------------------------------------------
with Bitmap.Color_Conversion; use Bitmap.Color_Conversion;
package body Bitmapped_Drawing is
---------------
-- Draw_Char --
---------------
procedure Draw_Char
(Buffer : in out Bitmap_Buffer'Class;
Start : Point;
Char : Character;
Font : BMP_Font;
Foreground : UInt32;
Background : UInt32)
is
begin
for H in 0 .. Char_Height (Font) - 1 loop
for W in 0 .. Char_Width (Font) - 1 loop
if (Data (Font, Char, H) and Mask (Font, W)) /= 0 then
Buffer.Set_Pixel
((Start.X + W, Start.Y + H), Foreground);
else
Buffer.Set_Pixel
((Start.X + W, Start.Y + H), Background);
end if;
end loop;
end loop;
end Draw_Char;
-----------------
-- Draw_String --
-----------------
procedure Draw_String
(Buffer : in out Bitmap_Buffer'Class;
Start : Point;
Msg : String;
Font : BMP_Font;
Foreground : Bitmap_Color;
Background : Bitmap_Color)
is
Count : Natural := 0;
FG : constant UInt32 := Bitmap_Color_To_Word (Buffer.Color_Mode,
Foreground);
BG : constant UInt32 := Bitmap_Color_To_Word (Buffer.Color_Mode,
Background);
begin
for C of Msg loop
exit when Start.X + Count * Char_Width (Font) > Buffer.Width;
Draw_Char
(Buffer,
(Start.X + Count * Char_Width (Font), Start.Y),
C,
Font,
FG,
BG);
Count := Count + 1;
end loop;
end Draw_String;
-----------------
-- Draw_String --
-----------------
procedure Draw_String
(Buffer : in out Bitmap_Buffer'Class;
Start : Point;
Msg : String;
Font : Hershey_Font;
Height : Natural;
Bold : Boolean;
Foreground : Bitmap_Color;
Fast : Boolean := True)
is
FG : constant UInt32 := Bitmap_Color_To_Word (Buffer.Color_Mode,
Foreground);
procedure Internal_Draw_Line
(X0, Y0, X1, Y1 : Natural;
Width : Positive);
procedure Internal_Draw_Line
(X0, Y0, X1, Y1 : Natural;
Width : Positive)
is
begin
Draw_Line (Buffer,
FG,
(X0, Y0),
(X1, Y1),
Width,
Fast => Fast);
end Internal_Draw_Line;
procedure Draw_Glyph is new Hershey_Fonts.Draw_Glyph
(Internal_Draw_Line);
Current : Point := Start;
begin
for C of Msg loop
exit when Current.X > Buffer.Width;
Draw_Glyph
(Fnt => Font,
C => C,
X => Current.X,
Y => Current.Y,
Height => Height,
Bold => Bold);
end loop;
end Draw_String;
-----------------
-- Draw_String --
-----------------
procedure Draw_String
(Buffer : in out Bitmap_Buffer'Class;
Area : Rect;
Msg : String;
Font : Hershey_Font;
Bold : Boolean;
Outline : Boolean;
Foreground : Bitmap_Color;
Fast : Boolean := True)
is
Length : constant Natural :=
Hershey_Fonts.Strlen (Msg, Font, Area.Height);
Ratio : Float;
Current : Point := (0, 0);
Prev : UInt32;
FG : constant UInt32 := Bitmap_Color_To_Word (Buffer.Color_Mode,
Foreground);
Blk : constant UInt32 := Bitmap_Color_To_Word (Buffer.Color_Mode,
Black);
procedure Internal_Draw_Line
(X0, Y0, X1, Y1 : Natural;
Width : Positive);
procedure Internal_Draw_Line
(X0, Y0, X1, Y1 : Natural;
Width : Positive)
is
begin
Draw_Line (Buffer,
Foreground,
(Area.Position.X + Natural (Float (X0) * Ratio),
Area.Position.Y + Y0),
(Area.Position.X + Natural (Float (X1) * Ratio),
Area.Position.Y + Y1),
Width,
Fast);
end Internal_Draw_Line;
procedure Draw_Glyph is new Hershey_Fonts.Draw_Glyph
(Internal_Draw_Line);
begin
if Length > Area.Width then
Ratio := Float (Area.Width) / Float (Length);
else
Ratio := 1.0;
Current.X := (Area.Width - Length) / 2;
end if;
for C of Msg loop
Draw_Glyph
(Fnt => Font,
C => C,
X => Current.X,
Y => Current.Y,
Height => Area.Height,
Bold => Bold);
end loop;
if Outline and then Area.Height > 40 then
for Y in Area.Position.Y + 1 .. Area.Position.Y + Area.Height loop
Prev := Buffer.Pixel ((Area.Position.X, Y));
if Prev = FG then
Buffer.Set_Pixel ((Area.Position.X, Y), Black);
end if;
for X in Area.Position.X + 1 .. Area.Position.X + Area.Width loop
declare
Col : constant UInt32 := Buffer.Pixel ((X, Y));
Top : constant UInt32 := Buffer.Pixel ((X, Y - 1));
begin
if Prev /= FG
and then Col = FG
then
Buffer.Set_Pixel ((X, Y), Blk);
elsif Prev = FG
and then Col /= FG
then
Buffer.Set_Pixel ((X - 1, Y), Blk);
elsif Top /= FG
and then Top /= Blk
and then Col = FG
then
Buffer.Set_Pixel ((X, Y), Blk);
elsif Top = FG
and then Col /= FG
then
Buffer.Set_Pixel ((X, Y - 1), Blk);
end if;
Prev := Col;
end;
end loop;
end loop;
end if;
end Draw_String;
end Bitmapped_Drawing;
|
charlie5/lace | Ada | 8,888 | adb | with
openGL.Primitive.indexed,
openGL.Geometry.lit_textured,
openGL.Model.hexagon;
package body openGL.Model.hexagon_Column.lit_textured_rounded
is
---------
--- Forge
--
function new_hexagon_Column (Radius : in Real;
Height : in Real;
Upper,
Lower : in hex_Face;
Shaft : in shaft_Face) return View
is
Self : constant View := new Item;
begin
Self.Radius := Radius;
Self.Height := Height;
Self.upper_Face := Upper;
Self.lower_Face := Lower;
Self.Shaft := Shaft;
return Self;
end new_hexagon_Column;
--------------
--- 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
is
pragma unreferenced (Fonts);
use Geometry.lit_textured,
Model.hexagon,
Texture;
shaft_Height : constant Real := Self.Height;
height_Offset : constant Vector_3 := (0.0, shaft_Height / 2.0, 0.0);
mid_Sites : constant hexagon.Sites := vertex_Sites (Self.Radius);
upper_Sites : hexagon.Sites := mid_Sites;
lower_Sites : hexagon.Sites := mid_Sites;
function new_hexagon_Face (Vertices : in Geometry.lit_textured.Vertex_array;
Flip : in Boolean := False) return Geometry.lit_textured.view
is
use Primitive;
function the_Indices return Indices
is
begin
if Flip
then return (1, 7, 6, 5, 4, 3, 2, 7);
else return (1, 2, 3, 4, 5, 6, 7, 2);
end if;
end the_Indices;
the_Geometry : constant Geometry.lit_textured.view
:= Geometry.lit_textured.new_Geometry;
the_Primitive : constant Primitive.view
:= Primitive.indexed.new_Primitive (triangle_Fan,
the_Indices).all'Access;
begin
the_Geometry.Vertices_are (Vertices);
the_Geometry.add (the_Primitive);
return the_Geometry;
end new_hexagon_Face;
function new_shaft_Face (Vertices : in Geometry.lit_textured.Vertex_array)
return Geometry.lit_textured.view
is
use Primitive;
the_Indices : constant Indices := (1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 1, 2);
the_Geometry : constant Geometry.lit_textured.view
:= Geometry.lit_textured.new_Geometry;
the_Primitive : constant Primitive.indexed.view
:= Primitive.indexed.new_Primitive (triangle_Strip,
the_Indices);
begin
the_Geometry.Vertices_are (Vertices);
the_Geometry.add (Primitive.view (the_Primitive));
return the_Geometry;
end new_shaft_Face;
upper_Face : Geometry.lit_textured.view;
lower_Face : Geometry.lit_textured.view;
shaft_Face : Geometry.lit_textured.view;
begin
for i in mid_Sites'Range
loop
upper_Sites (i) := upper_Sites (i) + height_Offset;
lower_Sites (i) := lower_Sites (i) - height_Offset;
end loop;
-- Upper
--
declare
the_Vertices : constant Geometry.lit_textured.Vertex_array
:= (1 => (Site => height_Offset, Normal => Normal, Coords => (0.0, 0.0), Shine => default_Shine),
2 => (Site => upper_Sites (1), Normal => Normal, Coords => (0.0, 0.0), Shine => default_Shine),
3 => (Site => upper_Sites (2), Normal => Normal, Coords => (1.0, 0.0), Shine => default_Shine),
4 => (Site => upper_Sites (3), Normal => Normal, Coords => (1.0, 1.0), Shine => default_Shine),
5 => (Site => upper_Sites (4), Normal => Normal, Coords => (0.0, 1.0), Shine => default_Shine),
6 => (Site => upper_Sites (5), Normal => Normal, Coords => (0.0, 1.0), Shine => default_Shine),
7 => (Site => upper_Sites (6), Normal => Normal, Coords => (0.0, 1.0), Shine => default_Shine));
begin
upper_Face := new_hexagon_Face (Vertices => the_Vertices);
if Self.upper_Face.Texture /= null_Asset
then
upper_Face.Texture_is (Textures.fetch (Self.upper_Face.Texture));
end if;
end;
-- Lower
--
declare
the_Vertices : constant Geometry.lit_textured.Vertex_array
:= (1 => (Site => -height_Offset, Normal => -Normal, Coords => (0.0, 0.0), Shine => default_Shine),
2 => (Site => lower_Sites (1), Normal => -Normal, Coords => (0.0, 0.0), Shine => default_Shine),
3 => (Site => lower_Sites (2), Normal => -Normal, Coords => (1.0, 0.0), Shine => default_Shine),
4 => (Site => lower_Sites (3), Normal => -Normal, Coords => (1.0, 1.0), Shine => default_Shine),
5 => (Site => lower_Sites (4), Normal => -Normal, Coords => (0.0, 1.0), Shine => default_Shine),
6 => (Site => lower_Sites (5), Normal => -Normal, Coords => (0.0, 1.0), Shine => default_Shine),
7 => (Site => lower_Sites (6), Normal => -Normal, Coords => (0.0, 1.0), Shine => default_Shine));
begin
lower_Face := new_hexagon_Face (Vertices => the_Vertices,
flip => True);
if Self.lower_Face.Texture /= null_Asset
then
lower_Face.Texture_is (Textures.fetch (Self.lower_Face.Texture));
end if;
end;
--- Shaft
--
declare
type shaft_Normals is array (1 .. 6) of Vector_3;
function get_Normals return shaft_Normals
is
use linear_Algebra_3D;
Rotation : constant Matrix_3x3 := y_Rotation_from (-math.to_Radians (60.0));
the_Normal : Vector_3 := (1.0, 0.0, 0.0);
Result : shaft_Normals;
begin
Result (1) := the_Normal;
the_Normal := Rotation * the_Normal;
Result (2) := the_Normal;
the_Normal := Rotation * the_Normal;
Result (3) := the_Normal;
the_Normal := (0.0, 0.0, 1.0);
Result (4) := the_Normal;
the_Normal := Rotation * the_Normal;
Result (5) := the_Normal;
the_Normal := Rotation * the_Normal;
Result (6) := the_Normal;
return Result;
end get_Normals;
Normals : constant shaft_Normals := get_Normals;
the_Vertices : constant Geometry.lit_textured.Vertex_array
:= ( 1 => (Site => upper_Sites (1), Normal => Normals (1), Coords => (0.0, 1.0), Shine => default_Shine),
2 => (Site => lower_Sites (1), Normal => Normals (1), Coords => (0.0, 0.0), Shine => default_Shine),
3 => (Site => upper_Sites (2), Normal => Normals (2), Coords => (0.2, 1.0), Shine => default_Shine),
4 => (Site => lower_Sites (2), Normal => Normals (2), Coords => (0.2, 0.0), Shine => default_Shine),
5 => (Site => upper_Sites (3), Normal => Normals (3), Coords => (0.4, 1.0), Shine => default_Shine),
6 => (Site => lower_Sites (3), Normal => Normals (3), Coords => (0.4, 0.0), Shine => default_Shine),
7 => (Site => upper_Sites (4), Normal => Normals (4), Coords => (0.6, 1.0), Shine => default_Shine),
8 => (Site => lower_Sites (4), Normal => Normals (4), Coords => (0.6, 0.0), Shine => default_Shine),
9 => (Site => upper_Sites (5), Normal => Normals (5), Coords => (0.8, 1.0), Shine => default_Shine),
10 => (Site => lower_Sites (5), Normal => Normals (5), Coords => (0.8, 0.0), Shine => default_Shine),
11 => (Site => upper_Sites (6), Normal => Normals (6), Coords => (1.0, 1.0), Shine => default_Shine),
12 => (Site => lower_Sites (6), Normal => Normals (6), Coords => (1.0, 0.0), Shine => default_Shine));
begin
shaft_Face := new_shaft_Face (Vertices => the_Vertices);
if Self.Shaft.Texture /= null_Asset
then
shaft_Face.Texture_is (Textures.fetch (Self.Shaft.Texture));
end if;
end;
return (1 => upper_Face.all'Access,
2 => lower_Face.all'Access,
3 => shaft_Face.all'Access);
end to_GL_Geometries;
end openGL.Model.hexagon_Column.lit_textured_rounded;
|
fnarenji/BezierToSTL | Ada | 902 | ads | with Courbes; use Courbes;
package Courbes.Bezier_Cubiques is
use Liste_Points;
type Bezier_Cubique is new Courbe with private;
-- Crée une Bezier_Cubique
function Ctor_Bezier_Cubique (Debut, Fin, C1, C2 : Point2D) return Bezier_Cubique;
-- Obtient un point d'une Bezier_Cubique
overriding function Obtenir_Point(Self : Bezier_Cubique; X : Coordonnee_Normalisee) return Point2D;
overriding procedure Accepter (Self : Bezier_Cubique; Visiteur : Courbes.Visiteurs.Visiteur_Courbe'Class);
function Obtenir_Controle1 (Self : Bezier_Cubique) return Point2D;
function Obtenir_Controle2 (Self : Bezier_Cubique) return Point2D;
private
type Bezier_Cubique_Controles is array (1 .. 2) of Point2D;
type Bezier_Cubique is new Courbe with
record
Controles : Bezier_Cubique_Controles;
end record;
end Courbes.Bezier_Cubiques;
|
zhmu/ananas | Ada | 381 | adb | -- { dg-do run }
procedure Interface_Conv is
package Pkg is
type I1 is interface;
procedure Prim (X : I1) is null;
type I2 is interface;
procedure Prim (X : I2) is null;
type DT is new I1 and I2 with null record;
end Pkg;
use Pkg;
Obj : DT;
CW_3 : I2'Class := Obj;
CW_5 : I1'Class := I1'Class (CW_3); -- test
begin
null;
end;
|
rogermc2/GA_Ada | Ada | 2,004 | ads |
-- Based on libgasandbox.draw.h
with GL.Objects.Programs;
with C3GA;
with Multivector_Analyze;
with Palet;
package GA_Draw is
type Method_Type is (Draw_Method_Undefined, Draw_Bivector_Circle,
Draw_Bivector_Parallelogram,
Draw_Bivector_Parallelogram_No_Vectors,
Draw_Bivector_Cross, Draw_Bivector_Curly_Tail,
Draw_Bivector_Swirl, Draw_Bivector_Circle_Outline,
Draw_TV_Sphere, Draw_TV_Cross, Draw_TV_Curly_Tail,
Draw_TV_Parellelepiped,
Draw_TV_Parellelepiped_No_Vectors);
procedure Draw_Bivector (Render_Program : GL.Objects.Programs.Program;
Base, Normal, Ortho_1, Ortho_2 : C3GA.Vector_E3;
Palet_Type : Palet.Colour_Palet;
Scale : float := 1.0;
Method : Method_Type := Draw_Bivector_Circle);
procedure Draw_Line (Render_Program : GL.Objects.Programs.Program;
Direction : C3GA.Vector_E3; Weight : Float := 1.0);
procedure Draw_Trivector (Render_Program : GL.Objects.Programs.Program;
Base : C3GA.Vector_E3; Scale : float := 1.0;
Palet_Type : Palet.Colour_Palet;
Method : Method_Type := Draw_TV_Sphere);
procedure Draw_Trivector (Render_Program : GL.Objects.Programs.Program;
Base : C3GA.Vector_E3; Scale : float := 1.0;
V : Multivector_Analyze.E3_Vector_Array;
-- Palet_Type : Palet.Colour_Palet;
Method : Method_Type := Draw_TV_Sphere);
procedure Draw_Vector (Render_Program : GL.Objects.Programs.Program;
Tail, Direction : C3GA.Vector_E3;
Scale : float := 1.0);
end GA_Draw;
|
reznikmm/matreshka | Ada | 4,727 | adb | ------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- Open Document Toolkit --
-- --
-- Runtime Library Component --
-- --
------------------------------------------------------------------------------
-- --
-- Copyright © 2014, Vadim Godunko <[email protected]> --
-- All rights reserved. --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions --
-- are met: --
-- --
-- * Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- --
-- * Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in the --
-- documentation and/or other materials provided with the distribution. --
-- --
-- * Neither the name of the Vadim Godunko, IE nor the names of its --
-- contributors may be used to endorse or promote products derived from --
-- this software without specific prior written permission. --
-- --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR --
-- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
-- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED --
-- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR --
-- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF --
-- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING --
-- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS --
-- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
-- --
------------------------------------------------------------------------------
-- $Revision$ $Date$
------------------------------------------------------------------------------
with Matreshka.DOM_Documents;
with Matreshka.ODF_String_Constants;
with ODF.DOM.Iterators;
with ODF.DOM.Visitors;
package body Matreshka.ODF_Presentation.Transition_Speed_Attributes is
------------
-- Create --
------------
overriding function Create
(Parameters : not null access Matreshka.DOM_Attributes.Attribute_L2_Parameters)
return Presentation_Transition_Speed_Attribute_Node is
begin
return Self : Presentation_Transition_Speed_Attribute_Node do
Matreshka.ODF_Presentation.Constructors.Initialize
(Self'Unchecked_Access,
Parameters.Document,
Matreshka.ODF_String_Constants.Presentation_Prefix);
end return;
end Create;
--------------------
-- Get_Local_Name --
--------------------
overriding function Get_Local_Name
(Self : not null access constant Presentation_Transition_Speed_Attribute_Node)
return League.Strings.Universal_String
is
pragma Unreferenced (Self);
begin
return Matreshka.ODF_String_Constants.Transition_Speed_Attribute;
end Get_Local_Name;
begin
Matreshka.DOM_Documents.Register_Attribute
(Matreshka.ODF_String_Constants.Presentation_URI,
Matreshka.ODF_String_Constants.Transition_Speed_Attribute,
Presentation_Transition_Speed_Attribute_Node'Tag);
end Matreshka.ODF_Presentation.Transition_Speed_Attributes;
|
reznikmm/matreshka | Ada | 5,733 | ads | ------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- Web Framework --
-- --
-- Runtime Library Component --
-- --
------------------------------------------------------------------------------
-- --
-- Copyright © 2012, Vadim Godunko <[email protected]> --
-- All rights reserved. --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions --
-- are met: --
-- --
-- * Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- --
-- * Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in the --
-- documentation and/or other materials provided with the distribution. --
-- --
-- * Neither the name of the Vadim Godunko, IE nor the names of its --
-- contributors may be used to endorse or promote products derived from --
-- this software without specific prior written permission. --
-- --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR --
-- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
-- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED --
-- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR --
-- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF --
-- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING --
-- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS --
-- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
-- --
------------------------------------------------------------------------------
-- $Revision$ $Date$
------------------------------------------------------------------------------
with League.Strings;
package Web_Services.SOAP.Security.Constants is
WSSE_Namespace_URI : constant League.Strings.Universal_String
:= League.Strings.To_Universal_String
("http://docs.oasis-open.org/wss/2004/01/"
& "oasis-200401-wss-wssecurity-secext-1.0.xsd");
WSU_Namespace_URI : constant League.Strings.Universal_String
:= League.Strings.To_Universal_String
("http://docs.oasis-open.org/wss/2004/01/"
& "oasis-200401-wss-wssecurity-utility-1.0.xsd");
Password_Digest_URI : constant League.Strings.Universal_String
:= League.Strings.To_Universal_String
("http://docs.oasis-open.org/wss/2004/01/"
& "oasis-200401-wss-username-token-profile-1.0#PasswordDigest");
Password_Text_URI : constant League.Strings.Universal_String
:= League.Strings.To_Universal_String
("http://docs.oasis-open.org/wss/2004/01/"
& "oasis-200401-wss-username-token-profile-1.0#PasswordText");
WSSE_Namespace_Prefix : constant League.Strings.Universal_String
:= League.Strings.To_Universal_String ("wsse");
WSU_Namespace_Prefix : constant League.Strings.Universal_String
:= League.Strings.To_Universal_String ("wsu");
Security_Element : constant League.Strings.Universal_String
:= League.Strings.To_Universal_String ("Security");
Username_Token_Element : constant League.Strings.Universal_String
:= League.Strings.To_Universal_String ("UsernameToken");
Username_Element : constant League.Strings.Universal_String
:= League.Strings.To_Universal_String ("Username");
Password_Element : constant League.Strings.Universal_String
:= League.Strings.To_Universal_String ("Password");
Nonce_Element : constant League.Strings.Universal_String
:= League.Strings.To_Universal_String ("Nonce");
Created_Element : constant League.Strings.Universal_String
:= League.Strings.To_Universal_String ("Created");
Type_Attribute : constant League.Strings.Universal_String
:= League.Strings.To_Universal_String ("Type");
Id_Attribute : constant League.Strings.Universal_String
:= League.Strings.To_Universal_String ("Id");
Id_Attribute_Value : constant League.Strings.Universal_String
:= League.Strings.To_Universal_String ("User");
end Web_Services.SOAP.Security.Constants;
|
AdaCore/libadalang | Ada | 173 | adb | package body Q.S is
function F (A : P.T) return Integer is
I : Integer := P.First (A).Val;
pragma Test_Statement;
begin
return I;
end F;
end Q.S;
|
Gabriel-Degret/adalib | Ada | 587 | ads | -- Standard Ada library specification
-- Copyright (c) 2003-2018 Maxim Reznik <[email protected]>
-- Copyright (c) 2004-2016 AXE Consultants
-- Copyright (c) 2004, 2005, 2006 Ada-Europe
-- Copyright (c) 2000 The MITRE Corporation, Inc.
-- Copyright (c) 1992, 1993, 1994, 1995 Intermetrics, Inc.
-- SPDX-License-Identifier: BSD-3-Clause and LicenseRef-AdaReferenceManual
---------------------------------------------------------------------------
with Ada.Wide_Wide_Text_IO;
package Ada.Float_Wide_Wide_Text_IO is
new Ada.Wide_Wide_Text_IO.Float_IO (Float);
|
stcarrez/ada-util | Ada | 386 | adb | with Ada.Text_IO;
with Util.Beans.Objects;
procedure ObjCalc is
package UBO renames Util.Beans.Objects;
use type UBO.Object;
Value : UBO.Object := UBO.To_Object (Integer (0));
begin
Value := Value + UBO.To_Object (Integer (123));
Value := Value - UBO.To_Object (String '("12"));
-- Should print '111'
Ada.Text_IO.Put_Line (UBO.To_String (Value));
end ObjCalc;
|
zhmu/ananas | Ada | 3,909 | ads | ------------------------------------------------------------------------------
-- --
-- GNAT RUN-TIME COMPONENTS --
-- --
-- S Y S T E M . P A C K _ 1 0 8 --
-- --
-- S p e c --
-- --
-- Copyright (C) 1992-2022, Free Software Foundation, Inc. --
-- --
-- GNAT is free software; you can redistribute it and/or modify it under --
-- terms of the GNU General Public License as published by the Free Soft- --
-- ware Foundation; either version 3, or (at your option) any later ver- --
-- sion. GNAT is distributed in the hope that it will be useful, but WITH- --
-- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY --
-- or FITNESS FOR A PARTICULAR PURPOSE. --
-- --
-- As a special exception under Section 7 of GPL version 3, you are granted --
-- additional permissions described in the GCC Runtime Library Exception, --
-- version 3.1, as published by the Free Software Foundation. --
-- --
-- You should have received a copy of the GNU General Public License and --
-- a copy of the GCC Runtime Library Exception along with this program; --
-- see the files COPYING3 and COPYING.RUNTIME respectively. If not, see --
-- <http://www.gnu.org/licenses/>. --
-- --
-- GNAT was originally developed by the GNAT team at New York University. --
-- Extensive contributions were provided by Ada Core Technologies Inc. --
-- --
------------------------------------------------------------------------------
-- Handling of packed arrays with Component_Size = 108
package System.Pack_108 is
pragma Preelaborate;
Bits : constant := 108;
type Bits_108 is mod 2 ** Bits;
for Bits_108'Size use Bits;
-- In all subprograms below, Rev_SSO is set True if the array has the
-- non-default scalar storage order.
function Get_108
(Arr : System.Address;
N : Natural;
Rev_SSO : Boolean) return Bits_108 with Inline;
-- Arr is the address of the packed array, N is the zero-based
-- subscript. This element is extracted and returned.
procedure Set_108
(Arr : System.Address;
N : Natural;
E : Bits_108;
Rev_SSO : Boolean) with Inline;
-- Arr is the address of the packed array, N is the zero-based
-- subscript. This element is set to the given value.
function GetU_108
(Arr : System.Address;
N : Natural;
Rev_SSO : Boolean) return Bits_108 with Inline;
-- Arr is the address of the packed array, N is the zero-based
-- subscript. This element is extracted and returned. This version
-- is used when Arr may represent an unaligned address.
procedure SetU_108
(Arr : System.Address;
N : Natural;
E : Bits_108;
Rev_SSO : Boolean) with Inline;
-- Arr is the address of the packed array, N is the zero-based
-- subscript. This element is set to the given value. This version
-- is used when Arr may represent an unaligned address
end System.Pack_108;
|
reznikmm/matreshka | Ada | 4,600 | adb | ------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- Open Document Toolkit --
-- --
-- Runtime Library Component --
-- --
------------------------------------------------------------------------------
-- --
-- Copyright © 2014, Vadim Godunko <[email protected]> --
-- All rights reserved. --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions --
-- are met: --
-- --
-- * Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- --
-- * Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in the --
-- documentation and/or other materials provided with the distribution. --
-- --
-- * Neither the name of the Vadim Godunko, IE nor the names of its --
-- contributors may be used to endorse or promote products derived from --
-- this software without specific prior written permission. --
-- --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR --
-- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
-- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED --
-- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR --
-- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF --
-- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING --
-- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS --
-- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
-- --
------------------------------------------------------------------------------
-- $Revision$ $Date$
------------------------------------------------------------------------------
with Matreshka.DOM_Documents;
with Matreshka.ODF_String_Constants;
with ODF.DOM.Iterators;
with ODF.DOM.Visitors;
package body Matreshka.ODF_Table.Position_Attributes is
------------
-- Create --
------------
overriding function Create
(Parameters : not null access Matreshka.DOM_Attributes.Attribute_L2_Parameters)
return Table_Position_Attribute_Node is
begin
return Self : Table_Position_Attribute_Node do
Matreshka.ODF_Table.Constructors.Initialize
(Self'Unchecked_Access,
Parameters.Document,
Matreshka.ODF_String_Constants.Table_Prefix);
end return;
end Create;
--------------------
-- Get_Local_Name --
--------------------
overriding function Get_Local_Name
(Self : not null access constant Table_Position_Attribute_Node)
return League.Strings.Universal_String
is
pragma Unreferenced (Self);
begin
return Matreshka.ODF_String_Constants.Position_Attribute;
end Get_Local_Name;
begin
Matreshka.DOM_Documents.Register_Attribute
(Matreshka.ODF_String_Constants.Table_URI,
Matreshka.ODF_String_Constants.Position_Attribute,
Table_Position_Attribute_Node'Tag);
end Matreshka.ODF_Table.Position_Attributes;
|
flyx/OpenGLAda | Ada | 10,796 | adb | -- part of OpenGLAda, (c) 2017 Felix Krause
-- released under the terms of the MIT license, see the file "COPYING"
with Ada.Containers.Indefinite_Hashed_Maps;
with Ada.Unchecked_Conversion;
with GL.API;
with GL.Enums.Getter;
package body GL.Objects.Framebuffers is
------------
function Status (Target : Framebuffer_Target) return Framebuffer_Status is
begin
return API.Check_Framebuffer_Status (Target.Kind);
end Status;
procedure Attach_Renderbuffer (Target : Framebuffer_Target;
Attachment : Attachment_Point;
Object : Renderbuffers.Renderbuffer'Class) is
begin
API.Framebuffer_Renderbuffer (Target.Kind, Attachment,
Low_Level.Enums.Renderbuffer,
Object.Raw_Id);
Raise_Exception_On_OpenGL_Error;
end Attach_Renderbuffer;
procedure Attach_Texture (Target : Framebuffer_Target;
Attachment : Attachment_Point;
Object : Textures.Texture'Class;
Level : Textures.Mipmap_Level) is
begin
API.Framebuffer_Texture (Target.Kind, Attachment, Object.Raw_Id, Level);
Raise_Exception_On_OpenGL_Error;
end Attach_Texture;
procedure Attach_Texture_Layer (Target : Framebuffer_Target;
Attachment : Attachment_Point;
Object : Textures.Texture'Class;
Level : Textures.Mipmap_Level;
Layer : Int) is
begin
API.Framebuffer_Texture_Layer (Target.Kind, Attachment, Object.Raw_Id,
Level, Layer);
Raise_Exception_On_OpenGL_Error;
end Attach_Texture_Layer;
procedure Invalidate (Target : in out Framebuffer_Target;
Attachments : Attachment_List) is
begin
API.Invalidate_Framebuffer (Target.Kind, Attachments'Length, Attachments);
Raise_Exception_On_OpenGL_Error;
end Invalidate;
procedure Invalidate_Sub (Target : in out Framebuffer_Target;
Attachments : Attachment_List;
X, Y : Int;
Width, Height : Size) is
begin
API.Invalidate_Sub_Framebuffer (Target.Kind, Attachments'Length,
Attachments, X, Y, Width, Height);
Raise_Exception_On_OpenGL_Error;
end Invalidate_Sub;
procedure Blit (Src_X0, Src_Y0, Src_X1, Src_Y1,
Dst_X0, Dst_Y0, Dst_X1, Dst_Y1 : Int;
Mask : Buffers.Buffer_Bits;
Filter : Textures.Magnifying_Function) is
use type Low_Level.Bitfield;
function Convert is new Ada.Unchecked_Conversion
(Buffers.Buffer_Bits, Low_Level.Bitfield);
Raw_Bits : constant Low_Level.Bitfield
:= Convert (Mask) and 2#0100010100000000#;
begin
API.Blit_Framebuffer (Src_X0, Src_Y0, Src_X1, Src_Y1,
Dst_X0, Dst_Y0, Dst_X1, Dst_Y1, Raw_Bits, Filter);
Raise_Exception_On_OpenGL_Error;
end Blit;
procedure Set_Default_Width (Target : in out Framebuffer_Target;
Value : Size) is
begin
API.Framebuffer_Parameter_Size (Target.Kind, Enums.Default_Width, Value);
Raise_Exception_On_OpenGL_Error;
end Set_Default_Width;
function Default_Width (Target : Framebuffer_Target) return Size is
Ret : Size;
begin
API.Get_Framebuffer_Parameter_Size
(Target.Kind, Enums.Default_Width, Ret);
Raise_Exception_On_OpenGL_Error;
return Ret;
end Default_Width;
function Max_Framebuffer_Width return Size is
Ret : aliased Size;
begin
API.Get_Size (Enums.Getter.Max_Framebuffer_Width, Ret'Access);
Raise_Exception_On_OpenGL_Error;
return Ret;
end Max_Framebuffer_Width;
procedure Set_Default_Height (Target : in out Framebuffer_Target;
Value : Size) is
begin
API.Framebuffer_Parameter_Size (Target.Kind, Enums.Default_Height,
Value);
Raise_Exception_On_OpenGL_Error;
end Set_Default_Height;
function Default_Height (Target : Framebuffer_Target) return Size is
Ret : Size;
begin
API.Get_Framebuffer_Parameter_Size (Target.Kind, Enums.Default_Height,
Ret);
Raise_Exception_On_OpenGL_Error;
return Ret;
end Default_Height;
function Max_Framebuffer_Height return Size is
Ret : aliased Size;
begin
API.Get_Size (Enums.Getter.Max_Framebuffer_Height, Ret'Unchecked_Access);
Raise_Exception_On_OpenGL_Error;
return Ret;
end Max_Framebuffer_Height;
procedure Set_Default_Layers (Target : in out Framebuffer_Target;
Value : Size) is
begin
API.Framebuffer_Parameter_Size (Target.Kind, Enums.Default_Layers, Value);
Raise_Exception_On_OpenGL_Error;
end Set_Default_Layers;
function Default_Layers (Target : Framebuffer_Target) return Size is
Ret : Size;
begin
API.Get_Framebuffer_Parameter_Size (Target.Kind, Enums.Default_Layers,
Ret);
Raise_Exception_On_OpenGL_Error;
return Ret;
end Default_Layers;
function Max_Framebuffer_Layers return Size is
Ret : aliased Size;
begin
API.Get_Size (Enums.Getter.Max_Framebuffer_Layers, Ret'Unchecked_Access);
Raise_Exception_On_OpenGL_Error;
return Ret;
end Max_Framebuffer_Layers;
procedure Set_Default_Samples (Target : in out Framebuffer_Target;
Value : Size) is
begin
API.Framebuffer_Parameter_Size (Target.Kind, Enums.Default_Samples,
Value);
Raise_Exception_On_OpenGL_Error;
end Set_Default_Samples;
function Default_Samples
(Target : Framebuffer_Target) return Size is
Ret : Size;
begin
API.Get_Framebuffer_Parameter_Size (Target.Kind, Enums.Default_Samples,
Ret);
Raise_Exception_On_OpenGL_Error;
return Ret;
end Default_Samples;
function Max_Framebuffer_Samples return Size is
Ret : aliased Size;
begin
API.Get_Size (Enums.Getter.Max_Framebuffer_Samples, Ret'Unchecked_Access);
Raise_Exception_On_OpenGL_Error;
return Ret;
end Max_Framebuffer_Samples;
procedure Set_Default_Fixed_Sample_Locactions
(Target : in out Framebuffer_Target; Value : Boolean) is
begin
API.Framebuffer_Parameter_Bool
(Target.Kind, Enums.Default_Fixed_Sample_Locations,
Low_Level.Bool (Value));
Raise_Exception_On_OpenGL_Error;
end Set_Default_Fixed_Sample_Locactions;
function Default_Fixed_Sample_Locations (Target : Framebuffer_Target)
return Boolean is
Ret : Low_Level.Bool;
begin
API.Get_Framebuffer_Parameter_Bool
(Target.Kind, Enums.Default_Fixed_Sample_Locations, Ret);
Raise_Exception_On_OpenGL_Error;
return Boolean (Ret);
end Default_Fixed_Sample_Locations;
overriding
procedure Internal_Create_Id (Object : Framebuffer; Id : out UInt) is
pragma Unreferenced (Object);
begin
API.Gen_Framebuffers (1, Id);
Raise_Exception_On_OpenGL_Error;
end Internal_Create_Id;
overriding
procedure Internal_Release_Id (Object : Framebuffer; Id : UInt) is
pragma Unreferenced (Object);
begin
API.Delete_Framebuffers (1, (1 => Id));
Raise_Exception_On_OpenGL_Error;
end Internal_Release_Id;
function Hash (Key : Low_Level.Enums.Framebuffer_Kind)
return Ada.Containers.Hash_Type is
function Value is new Ada.Unchecked_Conversion
(Source => Low_Level.Enums.Framebuffer_Kind, Target => Low_Level.Enum);
begin
return Ada.Containers.Hash_Type (Value (Key));
end Hash;
package Framebuffer_Maps is new Ada.Containers.Indefinite_Hashed_Maps
(Key_Type => Low_Level.Enums.Framebuffer_Kind,
Element_Type => Framebuffer'Class,
Hash => Hash,
Equivalent_Keys => Low_Level.Enums."=");
use type Framebuffer_Maps.Cursor;
Current_Framebuffers : Framebuffer_Maps.Map;
type Framebuffer_Kind_Array is array (Positive range <>) of
Low_Level.Enums.Framebuffer_Kind;
function Backend_Framebuffer_Targets
(Kind : Low_Level.Enums.Framebuffer_Kind) return Framebuffer_Kind_Array is
begin
case Kind is
when Low_Level.Enums.Read => return (1 => Low_Level.Enums.Read);
when Low_Level.Enums.Draw => return (1 => Low_Level.Enums.Draw);
when Low_Level.Enums.Read_Draw =>
return (1 => Low_Level.Enums.Draw, 2 => Low_Level.Enums.Read);
end case;
end Backend_Framebuffer_Targets;
pragma Inline (Backend_Framebuffer_Targets);
procedure Bind (Target : Framebuffer_Target;
Object : Framebuffer'Class) is
-- Read_Draw bind to both read and draw framebuffer, we need to set
-- the current framebuffer objects accordingly.
Targets : constant Framebuffer_Kind_Array
:= Backend_Framebuffer_Targets (Target.Kind);
Cursor : Framebuffer_Maps.Cursor;
begin
API.Bind_Framebuffer (Target.Kind, Object.Reference.GL_Id);
Raise_Exception_On_OpenGL_Error;
for Index in Targets'Range loop
Cursor := Current_Framebuffers.Find (Targets (Index));
if Cursor = Framebuffer_Maps.No_Element then
Current_Framebuffers.Insert (Targets (Index), Object);
elsif Framebuffer_Maps.Element (Cursor).Reference.GL_Id
/= Object.Reference.GL_Id then
Current_Framebuffers.Replace_Element (Cursor, Object);
end if;
end loop;
end Bind;
function Current (Target : Framebuffer_Target) return Framebuffer'Class is
Targets : constant Framebuffer_Kind_Array
:= Backend_Framebuffer_Targets (Target.Kind);
-- If target is Read_Draw, return the draw framebuffer
-- (Note: this is necessary because distinct read/draw framebuffers
-- were added later to the API and therefore might not be available
-- in the context. So everything needs to work with just Read_Draw).
Cursor : constant Framebuffer_Maps.Cursor
:= Current_Framebuffers.Find (Targets (1));
begin
if Cursor = Framebuffer_Maps.No_Element then
raise No_Object_Bound_Exception with Target.Kind'Img;
else
return Framebuffer_Maps.Element (Cursor);
end if;
end Current;
end GL.Objects.Framebuffers;
|
reznikmm/matreshka | Ada | 5,107 | 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.Internals.Utp_Elements;
with AMF.UML.Call_Operation_Actions;
with AMF.Utp.Stop_Timer_Actions;
with AMF.Visitors;
package AMF.Internals.Utp_Stop_Timer_Actions is
type Utp_Stop_Timer_Action_Proxy is
limited new AMF.Internals.Utp_Elements.Utp_Element_Proxy
and AMF.Utp.Stop_Timer_Actions.Utp_Stop_Timer_Action with null record;
overriding function Get_Base_Call_Operation_Action
(Self : not null access constant Utp_Stop_Timer_Action_Proxy)
return AMF.UML.Call_Operation_Actions.UML_Call_Operation_Action_Access;
-- Getter of StopTimerAction::base_CallOperationAction.
--
overriding procedure Set_Base_Call_Operation_Action
(Self : not null access Utp_Stop_Timer_Action_Proxy;
To : AMF.UML.Call_Operation_Actions.UML_Call_Operation_Action_Access);
-- Setter of StopTimerAction::base_CallOperationAction.
--
overriding procedure Enter_Element
(Self : not null access constant Utp_Stop_Timer_Action_Proxy;
Visitor : in out AMF.Visitors.Abstract_Visitor'Class;
Control : in out AMF.Visitors.Traverse_Control);
overriding procedure Leave_Element
(Self : not null access constant Utp_Stop_Timer_Action_Proxy;
Visitor : in out AMF.Visitors.Abstract_Visitor'Class;
Control : in out AMF.Visitors.Traverse_Control);
overriding procedure Visit_Element
(Self : not null access constant Utp_Stop_Timer_Action_Proxy;
Iterator : in out AMF.Visitors.Abstract_Iterator'Class;
Visitor : in out AMF.Visitors.Abstract_Visitor'Class;
Control : in out AMF.Visitors.Traverse_Control);
end AMF.Internals.Utp_Stop_Timer_Actions;
|
reznikmm/matreshka | Ada | 3,659 | ads | ------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- Open Document Toolkit --
-- --
-- Runtime Library Component --
-- --
------------------------------------------------------------------------------
-- --
-- Copyright © 2014, Vadim Godunko <[email protected]> --
-- All rights reserved. --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions --
-- are met: --
-- --
-- * Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- --
-- * Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in the --
-- documentation and/or other materials provided with the distribution. --
-- --
-- * Neither the name of the Vadim Godunko, IE nor the names of its --
-- contributors may be used to endorse or promote products derived from --
-- this software without specific prior written permission. --
-- --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR --
-- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
-- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED --
-- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR --
-- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF --
-- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING --
-- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS --
-- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
-- --
------------------------------------------------------------------------------
-- $Revision$ $Date$
------------------------------------------------------------------------------
with XML.DOM.Elements;
package ODF.DOM.Office_Image_Elements is
pragma Preelaborate;
type ODF_Office_Image is limited interface
and XML.DOM.Elements.DOM_Element;
type ODF_Office_Image_Access is
access all ODF_Office_Image'Class
with Storage_Size => 0;
end ODF.DOM.Office_Image_Elements;
|
AdaCore/gpr | Ada | 503 | ads | --
-- Copyright (C) 2021-2023, AdaCore
--
-- SPDX-License-Identifier: Apache-2.0 WITH LLVM-Exception
--
package GPR2.Source_Info.Parser.D is
type Object (Language : Language_Id) is
new Parser.Object (Language, LI) with null record;
overriding procedure Compute
(Self : not null access Object;
Data : in out Source_Info.Object'Class;
Source : Project.Source.Object);
-- Setup Data with the information from parsing Ada source file
end GPR2.Source_Info.Parser.D;
|
charlie5/lace | Ada | 385 | ads | package openGL.IO.lat_long_Radius
--
-- Provides a function to convert a model file containing longitude, latitude
-- and radius triplets (one triplet per line) to an openGL IO model.
--
is
function to_Model (model_File : in String) return IO.Model;
function to_Model (math_Model : access Geometry_3d.a_Model) return IO.Model;
end openGL.IO.lat_long_Radius;
|
AdaCore/gpr | Ada | 2,467 | adb | --
-- Copyright (C) 2019-2023, AdaCore
--
-- SPDX-License-Identifier: Apache-2.0 WITH LLVM-Exception
--
package body GPR2.Project.Name_Values is
function Build_Map (Values : Containers.Source_Value_List)
return Containers.Value_Source_Reference;
-- Returns a set with the value in values
---------------
-- Build_Set --
---------------
function Build_Map (Values : Containers.Source_Value_List)
return Containers.Value_Source_Reference is
begin
return R : Containers.Value_Source_Reference do
for V of Values loop
R.Include (V.Text, V);
end loop;
end return;
end Build_Map;
------------------
-- Count_Values --
------------------
function Count_Values (Self : Object) return Containers.Count_Type is
begin
return Self.Values.Length;
end Count_Values;
------------
-- Create --
------------
function Create
(Name : Source_Reference.Identifier.Object;
Value : Source_Reference.Value.Object) return Object
is
Sloc : constant Source_Reference.Object :=
Source_Reference.Object (Name);
Values : constant Containers.Source_Value_List :=
Containers.Source_Value_Type_List.To_Vector
(Value, 1);
begin
return Object'
(Sloc
with Single,
Name, Values, Build_Map (Values));
end Create;
function Create
(Name : Source_Reference.Identifier.Object;
Values : Containers.Source_Value_List) return Object is
begin
return Object'
(Source_Reference.Object (Name)
with List,
Name, Values, Build_Map (Values));
end Create;
----------
-- Kind --
----------
function Kind (Self : Object'Class) return Registry.Attribute.Value_Kind is
begin
return Self.Kind;
end Kind;
----------
-- Name --
----------
function Name (Self : Object) return Source_Reference.Identifier.Object is
begin
return Self.Name;
end Name;
-----------
-- Value --
-----------
function Value (Self : Object) return Source_Reference.Value.Object is
begin
return Self.Values.First_Element;
end Value;
------------
-- Values --
------------
function Values (Self : Object) return Containers.Source_Value_List is
begin
return Self.Values;
end Values;
end GPR2.Project.Name_Values;
|
sungyeon/drake | Ada | 1,018 | ads | pragma License (Unrestricted);
-- separated and auto-loaded by compiler
private generic
type Num is delta <> digits <>;
package Ada.Text_IO.Decimal_IO is
Default_Fore : Field := Num'Fore;
Default_Aft : Field := Num'Aft;
Default_Exp : Field := 0;
procedure Get (
File : File_Type; -- Input_File_Type
Item : out Num;
Width : Field := 0);
procedure Get (
Item : out Num;
Width : Field := 0);
procedure Put (
File : File_Type; -- Output_File_Type
Item : Num;
Fore : Field := Default_Fore;
Aft : Field := Default_Aft;
Exp : Field := Default_Exp);
procedure Put (
Item : Num;
Fore : Field := Default_Fore;
Aft : Field := Default_Aft;
Exp : Field := Default_Exp);
procedure Get (
From : String;
Item : out Num;
Last : out Positive);
procedure Put (
To : out String;
Item : Num;
Aft : Field := Default_Aft;
Exp : Field := Default_Exp);
end Ada.Text_IO.Decimal_IO;
|
Kurinkitos/Twizy-Security | Ada | 4,532 | ads | with perception_data_h; use perception_data_h;
with localization_data_h; use localization_data_h;
with speed_data_h; use speed_data_h;
with gpsModule;
with types; use types;
with Interfaces.C; use Interfaces.C;
with Interfaces.C.Extensions;
with Interface_utils; use Interface_utils;
with converters; use converters;
package Wrapper
with SPARK_Mode
is
Initialized : Boolean := False;
-- This is the big one. Once this has been set to false the value is not allowed to change
-- outside of a restart. Once this is set to false the car will emergency brake
-- and ignore any other commands until it is reset
Safe : Boolean := True;
-- Variable to cache the current speed in.
-- Should be updated every time the canbus callback is run
CurrentSpeed : Speed := 0.0;
-- Variable to cache current position
CurrentPosition : Pose_Ada;
LastPerceptionTimestamp : Interfaces.C.double := 0.0;
LastPositionTimestamp : Interfaces.C.double := 0.0;
LastSpeedTimestamp : Interfaces.C.double := 0.0;
-- TODO: Determine these in a proper way
MaxPerceptionDelay : constant Interfaces.C.double := 1000.0;
MaxPositionDelay : constant Interfaces.C.double := 1000.0;
MaxSpeedDelay : constant Interfaces.C.double := 100.0;
-- Here should any initialzation code be run
procedure Init
with
Global => (Output => Initialized, In_Out => CurrentSpeed, Input => Safe),
Convention => C,
Export,
External_Name => "init_ada";
procedure WaitForData
with
Global => (Input => (LastSpeedTimestamp, LastPositionTimestamp, LastPerceptionTimestamp));
-- Simply returns if the init function has been run or not
pragma Warnings (Off, "return type of ""Is_Initialized"" is an 8-bit Ada Boolean",
Reason => "Handeled by the c++ wrapper");
function Is_Initialized return Boolean
with
Global => (Input => Initialized),
Convention => C,
Export,
External_Name => "is_initialized_ada";
pragma Warnings (On, "return type of ""Is_Initialized"" is an 8-bit Ada Boolean");
-- This block is the callback functions for the c++ wrapper to attatch to the ROS topics
procedure Update_Perception(perception_data : in perception_obstacle_ada)
with
Global => (Input => (CurrentPosition, CurrentSpeed), In_Out => (Safe, LastPerceptionTimestamp)),
Convention => C,
Export,
External_Name => "update_perception_ada";
procedure Update_GPS(localization_estimate : in localization_estimate_ada)
with
Global => (In_Out => (Safe, CurrentPosition, LastPositionTimestamp)),
Convention => C,
Export,
External_Name => "update_gps_ada";
procedure Update_Speed(speed : in speed_ada)
with
Global => (In_Out => (Safe, CurrentSpeed, LastSpeedTimestamp)),
Convention => C,
Export,
External_Name => "update_speed_ada",
Post =>
((LastSpeedTimestamp = LastSpeedTimestamp'Old) or (LastSpeedTimestamp > LastSpeedTimestamp'Old))
and (if (speed.timestamp < LastSpeedTimestamp and
Convert_C_Bool(speed.valid_timestamp) and
Convert_C_Bool(speed.valid_speed)) then Safe = False)
and (if Convert_C_Bool(speed.valid_speed) and (speed.speed > 5.5) then Safe = False);
procedure Check_Brake_Pedal(pedal_status : Interfaces.C.Extensions.bool)
with
Global => (In_Out => Safe),
Convention => C,
Export,
External_Name => "check_brake_pedal_ada";
procedure CheckTimestamps(currentTime : in Interfaces.C.double)
with
Global => (
Input => (LastSpeedTimestamp, LastPositionTimestamp, LastPerceptionTimestamp),
In_Out => Safe
),
Convention => C,
Export,
External_Name => "check_timestamps_ada";
-- Returns whether we are safe or not
-- The result is based on the last run of the callback functions
-- Once it has switched to unsafe, it will not switch back without resetting
pragma Warnings (Off, "return type of ""Is_Safe"" is an 8-bit Ada Boolean",
Reason => "Handeled by the c++ wrapper");
function Is_Safe return Boolean
with
Global => (Input => Safe),
Convention => C,
Export,
External_Name => "is_safe_ada";
pragma Warnings (On, "return type of ""Is_Safe"" is an 8-bit Ada Boolean");
end Wrapper;
|
reznikmm/matreshka | Ada | 6,763 | 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_00B1 is
pragma Preelaborate;
Group_00B1 : aliased constant Core_Second_Stage
:= (16#08# => -- B108
(Other_Letter, Wide,
LV, A_Letter, O_Letter, H2,
(Alphabetic
| Grapheme_Base
| ID_Continue
| ID_Start
| XID_Continue
| XID_Start => True,
others => False)),
16#24# => -- B124
(Other_Letter, Wide,
LV, A_Letter, O_Letter, H2,
(Alphabetic
| Grapheme_Base
| ID_Continue
| ID_Start
| XID_Continue
| XID_Start => True,
others => False)),
16#40# => -- B140
(Other_Letter, Wide,
LV, A_Letter, O_Letter, H2,
(Alphabetic
| Grapheme_Base
| ID_Continue
| ID_Start
| XID_Continue
| XID_Start => True,
others => False)),
16#5C# => -- B15C
(Other_Letter, Wide,
LV, A_Letter, O_Letter, H2,
(Alphabetic
| Grapheme_Base
| ID_Continue
| ID_Start
| XID_Continue
| XID_Start => True,
others => False)),
16#78# => -- B178
(Other_Letter, Wide,
LV, A_Letter, O_Letter, H2,
(Alphabetic
| Grapheme_Base
| ID_Continue
| ID_Start
| XID_Continue
| XID_Start => True,
others => False)),
16#94# => -- B194
(Other_Letter, Wide,
LV, A_Letter, O_Letter, H2,
(Alphabetic
| Grapheme_Base
| ID_Continue
| ID_Start
| XID_Continue
| XID_Start => True,
others => False)),
16#B0# => -- B1B0
(Other_Letter, Wide,
LV, A_Letter, O_Letter, H2,
(Alphabetic
| Grapheme_Base
| ID_Continue
| ID_Start
| XID_Continue
| XID_Start => True,
others => False)),
16#CC# => -- B1CC
(Other_Letter, Wide,
LV, A_Letter, O_Letter, H2,
(Alphabetic
| Grapheme_Base
| ID_Continue
| ID_Start
| XID_Continue
| XID_Start => True,
others => False)),
16#E8# => -- B1E8
(Other_Letter, Wide,
LV, A_Letter, O_Letter, H2,
(Alphabetic
| Grapheme_Base
| ID_Continue
| ID_Start
| XID_Continue
| XID_Start => True,
others => False)),
others =>
(Other_Letter, Wide,
LVT, A_Letter, O_Letter, H3,
(Alphabetic
| Grapheme_Base
| ID_Continue
| ID_Start
| XID_Continue
| XID_Start => True,
others => False)));
end Matreshka.Internals.Unicode.Ucd.Core_00B1;
|
persan/AdaYaml | Ada | 3,658 | ads | -- part of AdaYaml, (c) 2017 Felix Krause
-- released under the terms of the MIT license, see the file "copying.txt"
private with Ada.Finalization;
package Yaml.Events.Queue is
type Instance is limited new Refcount_Base with private;
type Instance_Access is access all Instance;
type Reference is tagged private;
type Accessor (Data : not null access Instance) is limited null record with
Implicit_Dereference => Data;
type Element_Accessor (Data : not null access Event) is limited null record
with Implicit_Dereference => Data;
type Mark is private;
procedure Append (Object : in out Instance; E : Event);
procedure Append (Object : in out Instance; E : Event; Position : out Mark);
function Length (Object : Instance) return Natural;
function Length (Object : Reference) return Natural;
function First (Object : in Instance) return Event;
procedure Dequeue (Object : in out Instance);
function Value (Object : Reference) return Accessor;
function New_Queue return Reference;
function Element (Object : Instance; Position : Mark)
return Element_Accessor;
type Stream_Instance is new Refcount_Base with private;
type Stream_Instance_Access is access all Stream_Instance;
type Stream_Reference is tagged private;
type Stream_Accessor (Data : not null access Stream_Instance) is limited
null record with Implicit_Dereference => Data;
type Optional_Stream_Reference is tagged private;
Null_Reference : constant Optional_Stream_Reference;
function Value (Object : Stream_Reference) return Stream_Accessor;
function Value (Object : Optional_Stream_Reference) return Stream_Accessor
with Pre => Object /= Null_Reference;
function Next (Object : in out Stream_Instance) return Event;
function Required (Object : Optional_Stream_Reference'Class)
return Stream_Reference;
function Optional (Object : Stream_Reference'Class)
return Optional_Stream_Reference;
function As_Stream (Object : Reference'Class) return Stream_Reference;
private
type Reference is new Ada.Finalization.Controlled with record
Data : not null access Instance;
end record;
overriding procedure Adjust (Object : in out Reference);
overriding procedure Finalize (Object : in out Reference);
type Instance is limited new Event_Holder with record
First_Pos : Positive := 1;
Stream_Count : Natural := 0;
end record;
overriding procedure Copy_Data (Source : Instance;
Target : not null Event_Array_Access)
with Pre => Target.all'Length >= Source.Data.all'Length;
type Mark is new Positive;
type Instance_Pointer is access all Instance;
type Stream_Instance is new Refcount_Base with record
Buffer : Reference;
Offset : Natural := 0;
end record;
overriding procedure Finalize (Object : in out Stream_Instance);
type Stream_Reference is new Ada.Finalization.Controlled with record
Data : not null access Stream_Instance;
end record;
overriding procedure Adjust (Object : in out Stream_Reference);
overriding procedure Finalize (Object : in out Stream_Reference);
type Optional_Stream_Reference is new Ada.Finalization.Controlled with record
Data : access Stream_Instance;
end record;
overriding procedure Adjust (Object : in out Optional_Stream_Reference);
overriding procedure Finalize (Object : in out Optional_Stream_Reference);
Null_Reference : constant Optional_Stream_Reference :=
(Ada.Finalization.Controlled with Data => null);
end Yaml.Events.Queue;
|
Fabien-Chouteau/samd51-hal | Ada | 3,818 | ads | pragma Style_Checks (Off);
-- This spec has been automatically generated from ATSAMD51G19A.svd
pragma Restrictions (No_Elaboration_Code);
with HAL;
with System;
package SAM_SVD.TRNG is
pragma Preelaborate;
---------------
-- Registers --
---------------
-- Control A
type TRNG_CTRLA_Register is record
-- unspecified
Reserved_0_0 : HAL.Bit := 16#0#;
-- Enable
ENABLE : Boolean := False;
-- unspecified
Reserved_2_5 : HAL.UInt4 := 16#0#;
-- Run in Standby
RUNSTDBY : Boolean := False;
-- unspecified
Reserved_7_7 : HAL.Bit := 16#0#;
end record
with Volatile_Full_Access, Object_Size => 8,
Bit_Order => System.Low_Order_First;
for TRNG_CTRLA_Register use record
Reserved_0_0 at 0 range 0 .. 0;
ENABLE at 0 range 1 .. 1;
Reserved_2_5 at 0 range 2 .. 5;
RUNSTDBY at 0 range 6 .. 6;
Reserved_7_7 at 0 range 7 .. 7;
end record;
-- Event Control
type TRNG_EVCTRL_Register is record
-- Data Ready Event Output
DATARDYEO : Boolean := False;
-- unspecified
Reserved_1_7 : HAL.UInt7 := 16#0#;
end record
with Volatile_Full_Access, Object_Size => 8,
Bit_Order => System.Low_Order_First;
for TRNG_EVCTRL_Register use record
DATARDYEO at 0 range 0 .. 0;
Reserved_1_7 at 0 range 1 .. 7;
end record;
-- Interrupt Enable Clear
type TRNG_INTENCLR_Register is record
-- Data Ready Interrupt Enable
DATARDY : Boolean := False;
-- unspecified
Reserved_1_7 : HAL.UInt7 := 16#0#;
end record
with Volatile_Full_Access, Object_Size => 8,
Bit_Order => System.Low_Order_First;
for TRNG_INTENCLR_Register use record
DATARDY at 0 range 0 .. 0;
Reserved_1_7 at 0 range 1 .. 7;
end record;
-- Interrupt Enable Set
type TRNG_INTENSET_Register is record
-- Data Ready Interrupt Enable
DATARDY : Boolean := False;
-- unspecified
Reserved_1_7 : HAL.UInt7 := 16#0#;
end record
with Volatile_Full_Access, Object_Size => 8,
Bit_Order => System.Low_Order_First;
for TRNG_INTENSET_Register use record
DATARDY at 0 range 0 .. 0;
Reserved_1_7 at 0 range 1 .. 7;
end record;
-- Interrupt Flag Status and Clear
type TRNG_INTFLAG_Register is record
-- Data Ready Interrupt Flag
DATARDY : Boolean := False;
-- unspecified
Reserved_1_7 : HAL.UInt7 := 16#0#;
end record
with Volatile_Full_Access, Object_Size => 8,
Bit_Order => System.Low_Order_First;
for TRNG_INTFLAG_Register use record
DATARDY at 0 range 0 .. 0;
Reserved_1_7 at 0 range 1 .. 7;
end record;
-----------------
-- Peripherals --
-----------------
-- True Random Generator
type TRNG_Peripheral is record
-- Control A
CTRLA : aliased TRNG_CTRLA_Register;
-- Event Control
EVCTRL : aliased TRNG_EVCTRL_Register;
-- Interrupt Enable Clear
INTENCLR : aliased TRNG_INTENCLR_Register;
-- Interrupt Enable Set
INTENSET : aliased TRNG_INTENSET_Register;
-- Interrupt Flag Status and Clear
INTFLAG : aliased TRNG_INTFLAG_Register;
-- Output Data
DATA : aliased HAL.UInt32;
end record
with Volatile;
for TRNG_Peripheral use record
CTRLA at 16#0# range 0 .. 7;
EVCTRL at 16#4# range 0 .. 7;
INTENCLR at 16#8# range 0 .. 7;
INTENSET at 16#9# range 0 .. 7;
INTFLAG at 16#A# range 0 .. 7;
DATA at 16#20# range 0 .. 31;
end record;
-- True Random Generator
TRNG_Periph : aliased TRNG_Peripheral
with Import, Address => TRNG_Base;
end SAM_SVD.TRNG;
|
stcarrez/ada-asf | Ada | 4,231 | adb | -----------------------------------------------------------------------
-- components-utils-files -- Include raw files in the output
-- Copyright (C) 2012 Stephane Carrez
-- Written by Stephane Carrez ([email protected])
--
-- Licensed under the Apache License, Version 2.0 (the "License");
-- you may not use this file except in compliance with the License.
-- You may obtain a copy of the License at
--
-- http://www.apache.org/licenses/LICENSE-2.0
--
-- Unless required by applicable law or agreed to in writing, software
-- distributed under the License is distributed on an "AS IS" BASIS,
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-- See the License for the specific language governing permissions and
-- limitations under the License.
-----------------------------------------------------------------------
with Ada.Streams;
with Ada.Streams.Stream_IO;
with ASF.Requests;
with ASF.Contexts.Writer;
with Util.Beans.Objects;
with Util.Streams.Files;
with Util.Log.Loggers;
package body ASF.Components.Utils.Files is
use Util.Log;
-- The logger
Log : constant Loggers.Logger := Loggers.Create ("ASF.Components.Utils.Files");
-- ------------------------------
-- Get the resource path that must be included.
-- The resource path is identified by the <b>src</b> attribute.
-- ------------------------------
function Get_Resource (UI : in UIFile;
Context : in ASF.Contexts.Faces.Faces_Context'Class) return String is
Req : constant ASF.Requests.Request_Access := Context.Get_Request;
Src : constant Util.Beans.Objects.Object := UI.Get_Attribute (Context => Context,
Name => "src");
begin
if Util.Beans.Objects.Is_Null (Src) then
UI.Log_Error ("Missing 'src' parameter");
return "";
else
return Req.Get_Resource (Util.Beans.Objects.To_String (Src));
end if;
end Get_Resource;
-- ------------------------------
-- Copy the stream represented by <b>From</b> in the output stream associated with
-- the context <b>Context</b>. When <b>Escape</b> is True, escape any special character
-- using HTML escape rules.
-- ------------------------------
procedure Copy (UI : in UIFile;
From : in out Util.Streams.Input_Stream'Class;
Escape : in Boolean;
Context : in out ASF.Contexts.Faces.Faces_Context'Class) is
pragma Unreferenced (UI);
use Ada.Streams;
Writer : constant ASF.Contexts.Writer.Response_Writer_Access := Context.Get_Response_Writer;
Buffer : Stream_Element_Array (0 .. 4_096);
Last : Stream_Element_Offset;
begin
Writer.Close_Current;
loop
From.Read (Buffer, Last);
if Last > Buffer'First then
if not Escape then
Writer.Write (Buffer (Buffer'First .. Last));
else
for I in Buffer'First .. Last loop
Writer.Write_Char (Char => Character'Val (Buffer (I)));
end loop;
end if;
end if;
exit when Last < Buffer'Last;
end loop;
end Copy;
-- ------------------------------
-- Include in the output stream the resource identified by the <b>Get_Resource</b>
-- function.
-- ------------------------------
overriding
procedure Encode_Begin (UI : in UIFile;
Context : in out ASF.Contexts.Faces.Faces_Context'Class) is
begin
if not UI.Is_Rendered (Context) then
return;
end if;
declare
Path : constant String := UIFile'Class (UI).Get_Resource (Context);
Escape : constant Boolean := UI.Get_Attribute ("escape", Context, True);
From : Util.Streams.Files.File_Stream;
begin
if Path /= "" then
Log.Info ("Including file {0} in view", Path);
From.Open (Name => Path, Mode => Ada.Streams.Stream_IO.In_File);
UIFile'Class (UI).Copy (From, Escape, Context);
end if;
end;
end Encode_Begin;
end ASF.Components.Utils.Files;
|
Lyanf/pok | Ada | 66 | ads | package Subprograms is
procedure Hello_Part1;
end Subprograms;
|
reznikmm/matreshka | Ada | 4,615 | adb | ------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- Open Document Toolkit --
-- --
-- Runtime Library Component --
-- --
------------------------------------------------------------------------------
-- --
-- Copyright © 2014, Vadim Godunko <[email protected]> --
-- All rights reserved. --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions --
-- are met: --
-- --
-- * Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- --
-- * Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in the --
-- documentation and/or other materials provided with the distribution. --
-- --
-- * Neither the name of the Vadim Godunko, IE nor the names of its --
-- contributors may be used to endorse or promote products derived from --
-- this software without specific prior written permission. --
-- --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR --
-- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
-- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED --
-- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR --
-- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF --
-- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING --
-- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS --
-- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
-- --
------------------------------------------------------------------------------
-- $Revision$ $Date$
------------------------------------------------------------------------------
with Matreshka.DOM_Documents;
with Matreshka.ODF_String_Constants;
with ODF.DOM.Iterators;
with ODF.DOM.Visitors;
package body Matreshka.ODF_Text.Time_Adjust_Attributes is
------------
-- Create --
------------
overriding function Create
(Parameters : not null access Matreshka.DOM_Attributes.Attribute_L2_Parameters)
return Text_Time_Adjust_Attribute_Node is
begin
return Self : Text_Time_Adjust_Attribute_Node do
Matreshka.ODF_Text.Constructors.Initialize
(Self'Unchecked_Access,
Parameters.Document,
Matreshka.ODF_String_Constants.Text_Prefix);
end return;
end Create;
--------------------
-- Get_Local_Name --
--------------------
overriding function Get_Local_Name
(Self : not null access constant Text_Time_Adjust_Attribute_Node)
return League.Strings.Universal_String
is
pragma Unreferenced (Self);
begin
return Matreshka.ODF_String_Constants.Time_Adjust_Attribute;
end Get_Local_Name;
begin
Matreshka.DOM_Documents.Register_Attribute
(Matreshka.ODF_String_Constants.Text_URI,
Matreshka.ODF_String_Constants.Time_Adjust_Attribute,
Text_Time_Adjust_Attribute_Node'Tag);
end Matreshka.ODF_Text.Time_Adjust_Attributes;
|
AdaCore/Ada_Drivers_Library | Ada | 19,315 | ads | -- Copyright (c) 2013, Nordic Semiconductor ASA
-- All rights reserved.
--
-- Redistribution and use in source and binary forms, with or without
-- modification, are permitted provided that the following conditions are met:
--
-- * Redistributions of source code must retain the above copyright notice, this
-- list of conditions and the following disclaimer.
--
-- * Redistributions in binary form must reproduce the above copyright notice,
-- this list of conditions and the following disclaimer in the documentation
-- and/or other materials provided with the distribution.
--
-- * Neither the name of Nordic Semiconductor ASA nor the names of its
-- contributors may be used to endorse or promote products derived from
-- this software without specific prior written permission.
--
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
-- AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
-- IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
-- DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
-- FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
-- DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
-- SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
-- CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
-- OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-- OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
--
-- This spec has been automatically generated from nrf51.svd
pragma Restrictions (No_Elaboration_Code);
pragma Ada_2012;
pragma Style_Checks (Off);
with HAL;
with System;
package NRF_SVD.SPIS is
pragma Preelaborate;
---------------
-- Registers --
---------------
-- Shortcut between END event and the ACQUIRE task.
type SHORTS_END_ACQUIRE_Field is
(-- Shortcut disabled.
Disabled,
-- Shortcut enabled.
Enabled)
with Size => 1;
for SHORTS_END_ACQUIRE_Field use
(Disabled => 0,
Enabled => 1);
-- Shortcuts for SPIS.
type SHORTS_Register is record
-- unspecified
Reserved_0_1 : HAL.UInt2 := 16#0#;
-- Shortcut between END event and the ACQUIRE task.
END_ACQUIRE : SHORTS_END_ACQUIRE_Field := NRF_SVD.SPIS.Disabled;
-- unspecified
Reserved_3_31 : HAL.UInt29 := 16#0#;
end record
with Volatile_Full_Access, Object_Size => 32,
Bit_Order => System.Low_Order_First;
for SHORTS_Register use record
Reserved_0_1 at 0 range 0 .. 1;
END_ACQUIRE at 0 range 2 .. 2;
Reserved_3_31 at 0 range 3 .. 31;
end record;
-- Enable interrupt on END event.
type INTENSET_END_Field is
(-- Interrupt disabled.
Disabled,
-- Interrupt enabled.
Enabled)
with Size => 1;
for INTENSET_END_Field use
(Disabled => 0,
Enabled => 1);
-- Enable interrupt on END event.
type INTENSET_END_Field_1 is
(-- Reset value for the field
Intenset_End_Field_Reset,
-- Enable interrupt on write.
Set)
with Size => 1;
for INTENSET_END_Field_1 use
(Intenset_End_Field_Reset => 0,
Set => 1);
-- Enable interrupt on ACQUIRED event.
type INTENSET_ACQUIRED_Field is
(-- Interrupt disabled.
Disabled,
-- Interrupt enabled.
Enabled)
with Size => 1;
for INTENSET_ACQUIRED_Field use
(Disabled => 0,
Enabled => 1);
-- Enable interrupt on ACQUIRED event.
type INTENSET_ACQUIRED_Field_1 is
(-- Reset value for the field
Intenset_Acquired_Field_Reset,
-- Enable interrupt on write.
Set)
with Size => 1;
for INTENSET_ACQUIRED_Field_1 use
(Intenset_Acquired_Field_Reset => 0,
Set => 1);
-- Interrupt enable set register.
type INTENSET_Register is record
-- unspecified
Reserved_0_0 : HAL.Bit := 16#0#;
-- Enable interrupt on END event.
END_k : INTENSET_END_Field_1 := Intenset_End_Field_Reset;
-- unspecified
Reserved_2_9 : HAL.UInt8 := 16#0#;
-- Enable interrupt on ACQUIRED event.
ACQUIRED : INTENSET_ACQUIRED_Field_1 :=
Intenset_Acquired_Field_Reset;
-- unspecified
Reserved_11_31 : HAL.UInt21 := 16#0#;
end record
with Volatile_Full_Access, Object_Size => 32,
Bit_Order => System.Low_Order_First;
for INTENSET_Register use record
Reserved_0_0 at 0 range 0 .. 0;
END_k at 0 range 1 .. 1;
Reserved_2_9 at 0 range 2 .. 9;
ACQUIRED at 0 range 10 .. 10;
Reserved_11_31 at 0 range 11 .. 31;
end record;
-- Disable interrupt on END event.
type INTENCLR_END_Field is
(-- Interrupt disabled.
Disabled,
-- Interrupt enabled.
Enabled)
with Size => 1;
for INTENCLR_END_Field use
(Disabled => 0,
Enabled => 1);
-- Disable interrupt on END event.
type INTENCLR_END_Field_1 is
(-- Reset value for the field
Intenclr_End_Field_Reset,
-- Disable interrupt on write.
Clear)
with Size => 1;
for INTENCLR_END_Field_1 use
(Intenclr_End_Field_Reset => 0,
Clear => 1);
-- Disable interrupt on ACQUIRED event.
type INTENCLR_ACQUIRED_Field is
(-- Interrupt disabled.
Disabled,
-- Interrupt enabled.
Enabled)
with Size => 1;
for INTENCLR_ACQUIRED_Field use
(Disabled => 0,
Enabled => 1);
-- Disable interrupt on ACQUIRED event.
type INTENCLR_ACQUIRED_Field_1 is
(-- Reset value for the field
Intenclr_Acquired_Field_Reset,
-- Disable interrupt on write.
Clear)
with Size => 1;
for INTENCLR_ACQUIRED_Field_1 use
(Intenclr_Acquired_Field_Reset => 0,
Clear => 1);
-- Interrupt enable clear register.
type INTENCLR_Register is record
-- unspecified
Reserved_0_0 : HAL.Bit := 16#0#;
-- Disable interrupt on END event.
END_k : INTENCLR_END_Field_1 := Intenclr_End_Field_Reset;
-- unspecified
Reserved_2_9 : HAL.UInt8 := 16#0#;
-- Disable interrupt on ACQUIRED event.
ACQUIRED : INTENCLR_ACQUIRED_Field_1 :=
Intenclr_Acquired_Field_Reset;
-- unspecified
Reserved_11_31 : HAL.UInt21 := 16#0#;
end record
with Volatile_Full_Access, Object_Size => 32,
Bit_Order => System.Low_Order_First;
for INTENCLR_Register use record
Reserved_0_0 at 0 range 0 .. 0;
END_k at 0 range 1 .. 1;
Reserved_2_9 at 0 range 2 .. 9;
ACQUIRED at 0 range 10 .. 10;
Reserved_11_31 at 0 range 11 .. 31;
end record;
-- Semaphore status.
type SEMSTAT_SEMSTAT_Field is
(-- Semaphore is free.
Free,
-- Semaphore is assigned to the CPU.
Cpu,
-- Semaphore is assigned to the SPIS.
Spis,
-- Semaphore is assigned to the SPIS, but a handover to the CPU is pending.
Cpupending)
with Size => 2;
for SEMSTAT_SEMSTAT_Field use
(Free => 0,
Cpu => 1,
Spis => 2,
Cpupending => 3);
-- Semaphore status.
type SEMSTAT_Register is record
-- Read-only. Semaphore status.
SEMSTAT : SEMSTAT_SEMSTAT_Field;
-- unspecified
Reserved_2_31 : HAL.UInt30;
end record
with Volatile_Full_Access, Object_Size => 32,
Bit_Order => System.Low_Order_First;
for SEMSTAT_Register use record
SEMSTAT at 0 range 0 .. 1;
Reserved_2_31 at 0 range 2 .. 31;
end record;
-- TX buffer overread detected, and prevented.
type STATUS_OVERREAD_Field is
(-- Error not present.
Notpresent,
-- Error present.
Present)
with Size => 1;
for STATUS_OVERREAD_Field use
(Notpresent => 0,
Present => 1);
-- TX buffer overread detected, and prevented.
type STATUS_OVERREAD_Field_1 is
(-- Reset value for the field
Status_Overread_Field_Reset,
-- Clear on write.
Clear)
with Size => 1;
for STATUS_OVERREAD_Field_1 use
(Status_Overread_Field_Reset => 0,
Clear => 1);
-- RX buffer overflow detected, and prevented.
type STATUS_OVERFLOW_Field is
(-- Error not present.
Notpresent,
-- Error present.
Present)
with Size => 1;
for STATUS_OVERFLOW_Field use
(Notpresent => 0,
Present => 1);
-- RX buffer overflow detected, and prevented.
type STATUS_OVERFLOW_Field_1 is
(-- Reset value for the field
Status_Overflow_Field_Reset,
-- Clear on write.
Clear)
with Size => 1;
for STATUS_OVERFLOW_Field_1 use
(Status_Overflow_Field_Reset => 0,
Clear => 1);
-- Status from last transaction.
type STATUS_Register is record
-- TX buffer overread detected, and prevented.
OVERREAD : STATUS_OVERREAD_Field_1 := Status_Overread_Field_Reset;
-- RX buffer overflow detected, and prevented.
OVERFLOW : STATUS_OVERFLOW_Field_1 := Status_Overflow_Field_Reset;
-- unspecified
Reserved_2_31 : HAL.UInt30 := 16#0#;
end record
with Volatile_Full_Access, Object_Size => 32,
Bit_Order => System.Low_Order_First;
for STATUS_Register use record
OVERREAD at 0 range 0 .. 0;
OVERFLOW at 0 range 1 .. 1;
Reserved_2_31 at 0 range 2 .. 31;
end record;
-- Enable or disable SPIS.
type ENABLE_ENABLE_Field is
(-- Disabled SPIS.
Disabled,
-- Enable SPIS.
Enabled)
with Size => 3;
for ENABLE_ENABLE_Field use
(Disabled => 0,
Enabled => 2);
-- Enable SPIS.
type ENABLE_Register is record
-- Enable or disable SPIS.
ENABLE : ENABLE_ENABLE_Field := NRF_SVD.SPIS.Disabled;
-- unspecified
Reserved_3_31 : HAL.UInt29 := 16#0#;
end record
with Volatile_Full_Access, Object_Size => 32,
Bit_Order => System.Low_Order_First;
for ENABLE_Register use record
ENABLE at 0 range 0 .. 2;
Reserved_3_31 at 0 range 3 .. 31;
end record;
subtype MAXRX_MAXRX_Field is HAL.UInt8;
-- Maximum number of bytes in the receive buffer.
type MAXRX_Register is record
-- Maximum number of bytes in the receive buffer.
MAXRX : MAXRX_MAXRX_Field := 16#0#;
-- unspecified
Reserved_8_31 : HAL.UInt24 := 16#0#;
end record
with Volatile_Full_Access, Object_Size => 32,
Bit_Order => System.Low_Order_First;
for MAXRX_Register use record
MAXRX at 0 range 0 .. 7;
Reserved_8_31 at 0 range 8 .. 31;
end record;
subtype AMOUNTRX_AMOUNTRX_Field is HAL.UInt8;
-- Number of bytes received in last granted transaction.
type AMOUNTRX_Register is record
-- Read-only. Number of bytes received in last granted transaction.
AMOUNTRX : AMOUNTRX_AMOUNTRX_Field;
-- unspecified
Reserved_8_31 : HAL.UInt24;
end record
with Volatile_Full_Access, Object_Size => 32,
Bit_Order => System.Low_Order_First;
for AMOUNTRX_Register use record
AMOUNTRX at 0 range 0 .. 7;
Reserved_8_31 at 0 range 8 .. 31;
end record;
subtype MAXTX_MAXTX_Field is HAL.UInt8;
-- Maximum number of bytes in the transmit buffer.
type MAXTX_Register is record
-- Maximum number of bytes in the transmit buffer.
MAXTX : MAXTX_MAXTX_Field := 16#0#;
-- unspecified
Reserved_8_31 : HAL.UInt24 := 16#0#;
end record
with Volatile_Full_Access, Object_Size => 32,
Bit_Order => System.Low_Order_First;
for MAXTX_Register use record
MAXTX at 0 range 0 .. 7;
Reserved_8_31 at 0 range 8 .. 31;
end record;
subtype AMOUNTTX_AMOUNTTX_Field is HAL.UInt8;
-- Number of bytes transmitted in last granted transaction.
type AMOUNTTX_Register is record
-- Read-only. Number of bytes transmitted in last granted transaction.
AMOUNTTX : AMOUNTTX_AMOUNTTX_Field;
-- unspecified
Reserved_8_31 : HAL.UInt24;
end record
with Volatile_Full_Access, Object_Size => 32,
Bit_Order => System.Low_Order_First;
for AMOUNTTX_Register use record
AMOUNTTX at 0 range 0 .. 7;
Reserved_8_31 at 0 range 8 .. 31;
end record;
-- Bit order.
type CONFIG_ORDER_Field is
(-- Most significant bit transmitted out first.
Msbfirst,
-- Least significant bit transmitted out first.
Lsbfirst)
with Size => 1;
for CONFIG_ORDER_Field use
(Msbfirst => 0,
Lsbfirst => 1);
-- Serial clock (SCK) phase.
type CONFIG_CPHA_Field is
(-- Sample on leading edge of the clock. Shift serial data on trailing edge.
Leading,
-- Sample on trailing edge of the clock. Shift serial data on leading edge.
Trailing)
with Size => 1;
for CONFIG_CPHA_Field use
(Leading => 0,
Trailing => 1);
-- Serial clock (SCK) polarity.
type CONFIG_CPOL_Field is
(-- Active high.
Activehigh,
-- Active low.
Activelow)
with Size => 1;
for CONFIG_CPOL_Field use
(Activehigh => 0,
Activelow => 1);
-- Configuration register.
type CONFIG_Register is record
-- Bit order.
ORDER : CONFIG_ORDER_Field := NRF_SVD.SPIS.Msbfirst;
-- Serial clock (SCK) phase.
CPHA : CONFIG_CPHA_Field := NRF_SVD.SPIS.Leading;
-- Serial clock (SCK) polarity.
CPOL : CONFIG_CPOL_Field := NRF_SVD.SPIS.Activehigh;
-- unspecified
Reserved_3_31 : HAL.UInt29 := 16#0#;
end record
with Volatile_Full_Access, Object_Size => 32,
Bit_Order => System.Low_Order_First;
for CONFIG_Register use record
ORDER at 0 range 0 .. 0;
CPHA at 0 range 1 .. 1;
CPOL at 0 range 2 .. 2;
Reserved_3_31 at 0 range 3 .. 31;
end record;
subtype DEF_DEF_Field is HAL.UInt8;
-- Default character.
type DEF_Register is record
-- Default character.
DEF : DEF_DEF_Field := 16#0#;
-- unspecified
Reserved_8_31 : HAL.UInt24 := 16#0#;
end record
with Volatile_Full_Access, Object_Size => 32,
Bit_Order => System.Low_Order_First;
for DEF_Register use record
DEF at 0 range 0 .. 7;
Reserved_8_31 at 0 range 8 .. 31;
end record;
subtype ORC_ORC_Field is HAL.UInt8;
-- Over-read character.
type ORC_Register is record
-- Over-read character.
ORC : ORC_ORC_Field := 16#0#;
-- unspecified
Reserved_8_31 : HAL.UInt24 := 16#0#;
end record
with Volatile_Full_Access, Object_Size => 32,
Bit_Order => System.Low_Order_First;
for ORC_Register use record
ORC at 0 range 0 .. 7;
Reserved_8_31 at 0 range 8 .. 31;
end record;
-- Peripheral power control.
type POWER_POWER_Field is
(-- Module power disabled.
Disabled,
-- Module power enabled.
Enabled)
with Size => 1;
for POWER_POWER_Field use
(Disabled => 0,
Enabled => 1);
-- Peripheral power control.
type POWER_Register is record
-- Peripheral power control.
POWER : POWER_POWER_Field := NRF_SVD.SPIS.Disabled;
-- unspecified
Reserved_1_31 : HAL.UInt31 := 16#0#;
end record
with Volatile_Full_Access, Object_Size => 32,
Bit_Order => System.Low_Order_First;
for POWER_Register use record
POWER at 0 range 0 .. 0;
Reserved_1_31 at 0 range 1 .. 31;
end record;
-----------------
-- Peripherals --
-----------------
-- SPI slave 1.
type SPIS_Peripheral is record
-- Acquire SPI semaphore.
TASKS_ACQUIRE : aliased HAL.UInt32;
-- Release SPI semaphore.
TASKS_RELEASE : aliased HAL.UInt32;
-- Granted transaction completed.
EVENTS_END : aliased HAL.UInt32;
-- Semaphore acquired.
EVENTS_ACQUIRED : aliased HAL.UInt32;
-- Shortcuts for SPIS.
SHORTS : aliased SHORTS_Register;
-- Interrupt enable set register.
INTENSET : aliased INTENSET_Register;
-- Interrupt enable clear register.
INTENCLR : aliased INTENCLR_Register;
-- Semaphore status.
SEMSTAT : aliased SEMSTAT_Register;
-- Status from last transaction.
STATUS : aliased STATUS_Register;
-- Enable SPIS.
ENABLE : aliased ENABLE_Register;
-- Pin select for SCK.
PSELSCK : aliased HAL.UInt32;
-- Pin select for MISO.
PSELMISO : aliased HAL.UInt32;
-- Pin select for MOSI.
PSELMOSI : aliased HAL.UInt32;
-- Pin select for CSN.
PSELCSN : aliased HAL.UInt32;
-- RX data pointer.
RXDPTR : aliased HAL.UInt32;
-- Maximum number of bytes in the receive buffer.
MAXRX : aliased MAXRX_Register;
-- Number of bytes received in last granted transaction.
AMOUNTRX : aliased AMOUNTRX_Register;
-- TX data pointer.
TXDPTR : aliased HAL.UInt32;
-- Maximum number of bytes in the transmit buffer.
MAXTX : aliased MAXTX_Register;
-- Number of bytes transmitted in last granted transaction.
AMOUNTTX : aliased AMOUNTTX_Register;
-- Configuration register.
CONFIG : aliased CONFIG_Register;
-- Default character.
DEF : aliased DEF_Register;
-- Over-read character.
ORC : aliased ORC_Register;
-- Peripheral power control.
POWER : aliased POWER_Register;
end record
with Volatile;
for SPIS_Peripheral use record
TASKS_ACQUIRE at 16#24# range 0 .. 31;
TASKS_RELEASE at 16#28# range 0 .. 31;
EVENTS_END at 16#104# range 0 .. 31;
EVENTS_ACQUIRED at 16#128# range 0 .. 31;
SHORTS at 16#200# range 0 .. 31;
INTENSET at 16#304# range 0 .. 31;
INTENCLR at 16#308# range 0 .. 31;
SEMSTAT at 16#400# range 0 .. 31;
STATUS at 16#440# range 0 .. 31;
ENABLE at 16#500# range 0 .. 31;
PSELSCK at 16#508# range 0 .. 31;
PSELMISO at 16#50C# range 0 .. 31;
PSELMOSI at 16#510# range 0 .. 31;
PSELCSN at 16#514# range 0 .. 31;
RXDPTR at 16#534# range 0 .. 31;
MAXRX at 16#538# range 0 .. 31;
AMOUNTRX at 16#53C# range 0 .. 31;
TXDPTR at 16#544# range 0 .. 31;
MAXTX at 16#548# range 0 .. 31;
AMOUNTTX at 16#54C# range 0 .. 31;
CONFIG at 16#554# range 0 .. 31;
DEF at 16#55C# range 0 .. 31;
ORC at 16#5C0# range 0 .. 31;
POWER at 16#FFC# range 0 .. 31;
end record;
-- SPI slave 1.
SPIS1_Periph : aliased SPIS_Peripheral
with Import, Address => SPIS1_Base;
end NRF_SVD.SPIS;
|
micahwelf/FLTK-Ada | Ada | 1,597 | adb |
with
Interfaces.C,
System;
use type
System.Address;
package body FLTK.Images.Bitmaps.XBM is
function new_fl_xbm_image
(F : in Interfaces.C.char_array)
return System.Address;
pragma Import (C, new_fl_xbm_image, "new_fl_xbm_image");
pragma Inline (new_fl_xbm_image);
procedure free_fl_xbm_image
(P : in System.Address);
pragma Import (C, free_fl_xbm_image, "free_fl_xbm_image");
pragma Inline (free_fl_xbm_image);
overriding procedure Finalize
(This : in out XBM_Image) is
begin
if This.Void_Ptr /= System.Null_Address and then
This in XBM_Image'Class
then
free_fl_xbm_image (This.Void_Ptr);
This.Void_Ptr := System.Null_Address;
end if;
Finalize (Bitmap (This));
end Finalize;
package body Forge is
function Create
(Filename : in String)
return XBM_Image is
begin
return This : XBM_Image do
This.Void_Ptr := new_fl_xbm_image
(Interfaces.C.To_C (Filename));
case fl_image_fail (This.Void_Ptr) is
when 1 =>
raise No_Image_Error;
when 2 =>
raise File_Access_Error;
when 3 =>
raise Format_Error;
when others =>
null;
end case;
end return;
end Create;
end Forge;
end FLTK.Images.Bitmaps.XBM;
|
yannickmoy/StratoX | Ada | 20,144 | adb | -- Institution: Technische Universitaet Muenchen
-- Department: Realtime Computer Systems (RCS)
-- Project: StratoX
--
-- Authors: Emanuel Regnath ([email protected])
-- Martin Becker ([email protected])
with Units; use Units;
with Units.Operations; use Units.Operations;
with MS5611.Register; use MS5611.Register;
with Ada.Real_Time; use Ada.Real_Time;
with HIL.SPI;
-- @summary Driver for the Barometer MS5611-01BA03
package body MS5611.Driver with SPARK_Mode,
Refined_State => (State => (G_Baro_State, temperature_raw, temperature, pressure_raw, pressure),
Coefficients => (G_sens_t1, G_off_t1, G_tcs, G_tco, G_t_ref, G_tempsens, dT, SENS, OFF, TEMP))
is
type Data_Array is array (Natural range <>) of HIL.Byte with
Component_Size => 8;
-- baro device states
type Baro_FSM_Type is
(NOT_INITIALIZED,
READY,
TEMPERATURE_CONVERSION,
PRESSURE_CONVERSION)
with Default_Value => NOT_INITIALIZED;
type Conversion_Info_Type is record
OSR : OSR_Type;
Start : Time_Type;
end record;
-- the current state of the sensor device
-- @field FSM_State what the device is currently doing
-- @field Conv_Info_Temp context for state TEMPERATURE_CONVERSION
-- @field Conv_Info_Pres context for state PRESSURE_CONVERSION
type Baro_State_Type is record
FSM_State : Baro_FSM_Type;
Conv_Info_Temp : Conversion_Info_Type;
Conv_Info_Pres : Conversion_Info_Type;
end record;
type Conversion_Time_LUT_Type is array (OSR_Type) of Time_Type;
type Coefficient_ID_Type is (COEFF_SENS_T1, COEFF_OFF_T1, COEFF_TCS, COEFF_TCO, COEFF_T_REF, COEFF_TEMPSENS);
type Coefficient_Data_Type is mod 2**16 with
Size => 16;
type Conversion_ID_Type is (D1, D2);
type Conversion_Data_Type is mod 2**24 with Size => 24;
subtype Sens_T1_Type is Float range 0.0 .. Float ((2**16 - 1) * 2**15);
subtype Off_T1_Type is Float range 0.0 .. Float ((2**16 - 1) * 2**16);
subtype TCS_Type is Float range 0.0 .. Float (2**16 - 1) / Float (2**8);
subtype TCO_Type is Float range 0.0 .. Float (2**16 - 1) / Float (2**7);
subtype T_Ref_Type is Float range 0.0 .. Float ((2**16 - 1) * 2**8);
subtype Tempsens_Type is Float range 0.0 .. Float (2**16 - 1) / Float (2**23);
subtype DT_Type is Float range -16776960.9 .. 16777216.9;
subtype Sense_Type is Float range -4294836225.9 .. 6442352640.9;
subtype OFF_Type is Float range -8589672450.9 .. 12884705280.9;
subtype TEMP_Type is Float range -4000.9 .. 8500.9;
-- a bunch of functions that allows to add/sub/cast types without range problems
function Sat_Cast_Tref is new Units.Saturated_Cast (T_Ref_Type);
function Sat_Cast_Tempsense is new Units.Saturated_Cast (Tempsens_Type);
function Sat_Cast_TCO is new Units.Saturated_Cast (TCO_Type);
function Sat_Cast_TCS is new Units.Saturated_Cast (TCS_Type);
function Sat_Cast_OffType is new Units.Saturated_Cast (OFF_Type);
function Sat_Cast_TEMPType is new Units.Saturated_Cast (TEMP_Type);
function Sat_Cast_SensType is new Units.Saturated_Cast (Sense_Type);
function Sat_Add_OffType is new Units.Saturated_Addition (OFF_Type);
function Sat_Add_SensType is new Units.Saturated_Addition (Sense_Type);
function Sat_Add_TempType is new Units.Saturated_Addition (TEMP_Type);
function Sat_Sub_TempType is new Units.Saturated_Subtraction (TEMP_Type);
function Sat_Sub_OffType is new Units.Saturated_Subtraction (OFF_Type);
function Sat_Sub_SensType is new Units.Saturated_Subtraction (Sense_Type);
----------------------
-- PROTOTYPES
----------------------
procedure start_conversion (ID : Conversion_ID_Type; OSR : OSR_Type);
function calculateTemperatureDifference
(Temp_Raw : Conversion_Data_Type;
T_Ref : Float) return DT_Type;
procedure compensateTemperature;
function conversion_Finished (state : Baro_State_Type;
conv_time : Conversion_Time_LUT_Type;
now : Time) return Boolean;
function convertToKelvin (thisTemp : in TEMP_Type) return Temperature_Type;
function calculatePressure
(arg_pressure_raw : Conversion_Data_Type;
arg_sense : Sense_Type;
arg_offset : OFF_Type) return Pressure_Type;
-- calculate physical pressure from raw measurements
-- @param arg_pressure_raw raw pressure data
-- @param arg_sense raw sense data
-- @param arg_offset calibration offset
-- @return barometric pressure
procedure writeToDevice (Device : Device_Type; data : in Data_Array);
procedure selectDevice (Device : Device_Type);
procedure deselectDevice (Device : Device_Type);
procedure transferWithDevice (Device : Device_Type;
data_tx : in Data_Array;
data_rx : out Data_Array);
procedure read_coefficient (Device : Device_Type;
coeff_id : Coefficient_ID_Type;
coeff_data : out Coefficient_Data_Type);
procedure read_adc (Device : Device_Type; adc_value : out Conversion_Data_Type);
-------------
-- LUTS
-------------
-- maximum conversion times (taken from the datasheet)
Conversion_Time_LUT : constant Conversion_Time_LUT_Type :=
(OSR_256 => Time_Type (0.60 / 1000.0),
OSR_512 => Time_Type (1.17 / 1000.0),
OSR_1024 => Time_Type (2.28 / 1000.0),
OSR_2048 => Time_Type (4.54 / 1000.0),
OSR_4096 => Time_Type (9.04 / 1000.0));
-- conversion variables
G_Baro_State : Baro_State_Type :=
(FSM_State => NOT_INITIALIZED,
Conv_Info_Temp => (OSR_256, Time_Type (0.0)),
Conv_Info_Pres => (OSR_256, Time_Type (0.0)));
-- calibration variables (read values)
G_sens_t1 : Sens_T1_Type := 0.0; -- Pressure sensitivity (54487)
G_off_t1 : Off_T1_Type := 0.0; -- Pressure offset (51552)
G_tcs : TCS_Type := 0.0; -- Temperature coefficient of pressure sensitivity (33258)
G_tco : TCO_Type := 0.0; -- Temperature coefficient of pressure offset (27255)
G_t_ref : T_Ref_Type := 0.0; -- barometer reference temperature (29426)
G_tempsens : Tempsens_Type := 0.0; -- Temperature coefficient of the temperature (27777)
-- ADC values
temperature_raw : Conversion_Data_Type := 0; -- raw temperture read from baro
pressure_raw : Conversion_Data_Type := 0; -- raw pressure read from baro
-- Compensation values
dT : DT_Type := 0.0; -- difference between actual and reference temperature
SENS : Sense_Type := 0.0; -- pressure sensitivity at the actual temperature
OFF : OFF_Type := 0.0; -- pressure offset at actual temperature
TEMP : TEMP_Type := 0.0;
-- final measurement values
pressure : Pressure_Type := 101300.0 * Units.Pascal; -- invalid initial value
temperature : Temperature_Type := 293.15 * Units.Kelvin;
G_CELSIUS_0 : constant := 273.15;
-- Glue Code
-- the following procedures access the Hardware Interface Layer (HIL)
----------------------
-- selectDevice
----------------------
procedure selectDevice (Device : Device_Type) is
begin
if Device = Baro then
HIL.SPI.select_Chip (HIL.SPI.Barometer);
end if;
end selectDevice;
----------------------
-- deselectDevice
----------------------
procedure deselectDevice (Device : Device_Type) is
begin
if Device = Baro then
HIL.SPI.deselect_Chip (HIL.SPI.Barometer);
end if;
end deselectDevice;
----------------------
-- writeToDevice
----------------------
procedure writeToDevice (Device : Device_Type; data : in Data_Array) is
begin
selectDevice (Device);
HIL.SPI.write (HIL.SPI.Barometer, HIL.SPI.Data_Type (data));
deselectDevice (Device);
end writeToDevice;
----------------------
-- transferWithDevice
----------------------
procedure transferWithDevice
(Device : Device_Type;
data_tx : in Data_Array;
data_rx : out Data_Array)
is
begin
selectDevice (Device);
HIL.SPI.transceive
(HIL.SPI.Barometer,
HIL.SPI.Data_Type (data_tx),
HIL.SPI.Data_Type (data_rx));
deselectDevice (Device);
end transferWithDevice;
----------------------
-- read_coefficient
----------------------
procedure read_coefficient
(Device : Device_Type;
coeff_id : Coefficient_ID_Type;
coeff_data : out Coefficient_Data_Type)
is
Data_TX : Data_Array (1 .. 3) := (others => 0);
Data_RX : Data_Array (1 .. 3);
begin
case coeff_id is
when COEFF_SENS_T1 =>
Data_TX (1) := HIL.Byte (CMD_READ_C1);
when COEFF_OFF_T1 =>
Data_TX (1) := HIL.Byte (CMD_READ_C2);
when COEFF_TCS =>
Data_TX (1) := HIL.Byte (CMD_READ_C3);
when COEFF_TCO =>
Data_TX (1) := HIL.Byte (CMD_READ_C4);
when COEFF_T_REF =>
Data_TX (1) := HIL.Byte (CMD_READ_C5);
when COEFF_TEMPSENS =>
Data_TX (1) := HIL.Byte (CMD_READ_C6);
end case;
transferWithDevice (Device, Data_TX, Data_RX);
coeff_data :=
Coefficient_Data_Type (Data_RX (3)) +
Coefficient_Data_Type (Data_RX (2)) * (2**8);
-- coeff_data := Convert( data(1 .. 2) );
end read_coefficient;
----------------------
-- read_adc
----------------------
-- reads the 24 bit ADC value from the barometer
procedure read_adc (Device : Device_Type; adc_value : out Conversion_Data_Type)
is
Data_TX : constant Data_Array (1 .. 4) :=
(1 => HIL.Byte (CMD_ADC_READ), others => 0);
Data_RX : Data_Array (1 .. 4);
begin
transferWithDevice (Device, Data_TX, Data_RX);
adc_value :=
Conversion_Data_Type (Data_RX (4)) +
Conversion_Data_Type (Data_RX (3)) * (2**8) +
Conversion_Data_Type (Data_RX (2)) * (2**16);
end read_adc;
----------------------
-- reset
----------------------
procedure Reset is
begin
writeToDevice (Baro, (1 => HIL.Byte (CMD_RESET)));
end Reset;
-------------
-- Init
-------------
-- This function sequentially initializes the barometer.
-- Therefore, the barometer is reset, the PROM-Coefficients are read and
-- the takeoff altitude (altitude_offset) is calculated.
procedure Init is
c1 : Coefficient_Data_Type;
c2 : Coefficient_Data_Type;
c3 : Coefficient_Data_Type;
c4 : Coefficient_Data_Type;
c5 : Coefficient_Data_Type;
c6 : Coefficient_Data_Type;
begin
read_coefficient (Baro, COEFF_SENS_T1, c1);
G_sens_t1 := Float (c1) * Float (2**15);
read_coefficient (Baro, COEFF_OFF_T1, c2);
G_off_t1 := Float (c2) * Float (2**16);
read_coefficient (Baro, COEFF_TCS, c3);
G_tcs := (Float (c3) / Float (2**8));
read_coefficient (Baro, COEFF_TCO, c4);
G_tco := (Float (c4) / Float (2**7));
read_coefficient (Baro, COEFF_T_REF, c5);
G_t_ref := (Float (c5) * Float (2**8));
read_coefficient (Baro, COEFF_TEMPSENS, c6);
G_tempsens := (Float (c6) / Float (2**23));
G_Baro_State.FSM_State := READY;
end Init;
----------------------
-- start_conversion
----------------------
procedure start_conversion (ID : Conversion_ID_Type; OSR : OSR_Type) is
data : Data_Array (1 .. 1) := (others => 0);
now : constant Ada.Real_Time.Time := Ada.Real_Time.Clock;
begin
case (ID) is
when D1 =>
case (OSR) is
when OSR_256 =>
data (1) := HIL.Byte (CMD_D1_CONV_256);
when OSR_512 =>
data (1) := HIL.Byte (CMD_D1_CONV_512);
when OSR_1024 =>
data (1) := HIL.Byte (CMD_D1_CONV_1024);
when OSR_2048 =>
data (1) := HIL.Byte (CMD_D1_CONV_2048);
when OSR_4096 =>
data (1) := HIL.Byte (CMD_D1_CONV_4096);
end case;
G_Baro_State.Conv_Info_Pres.OSR := OSR;
G_Baro_State.Conv_Info_Pres.Start := Units.To_Time (now);
when D2 =>
case (OSR) is
when OSR_256 =>
data (1) := HIL.Byte (CMD_D2_CONV_256);
when OSR_512 =>
data (1) := HIL.Byte (CMD_D2_CONV_512);
when OSR_1024 =>
data (1) := HIL.Byte (CMD_D2_CONV_1024);
when OSR_2048 =>
data (1) := HIL.Byte (CMD_D2_CONV_2048);
when OSR_4096 =>
data (1) := HIL.Byte (CMD_D2_CONV_4096);
end case;
G_Baro_State.Conv_Info_Temp.OSR := OSR;
G_Baro_State.Conv_Info_Temp.Start := Units.To_Time (now);
end case;
writeToDevice (Baro, data);
end start_conversion;
----------------------
-- self_check
----------------------
procedure Self_Check (Status : out Error_Type) is
later : Ada.Real_Time.Time := Ada.Real_Time.Clock;
have_update : Boolean;
begin
Wait_Value_Loop :
for k in 0 .. 4 loop
Update_Val (have_update);
exit Wait_Value_Loop when have_update;
later := later + Milliseconds (100); -- easily enough
delay until later;
end loop Wait_Value_Loop;
Status := (if have_update then SUCCESS else FAILURE);
end Self_Check;
----------------------
-- conversion_Finished
----------------------
function conversion_Finished (state : Baro_State_Type;
conv_time : Conversion_Time_LUT_Type;
now : Time) return Boolean
is
result : Boolean;
begin
case (state.FSM_State) is
when TEMPERATURE_CONVERSION =>
result := (Sum_Time (state.Conv_Info_Temp.Start,
conv_time (state.Conv_Info_Temp.OSR)) < Units.To_Time (now));
when PRESSURE_CONVERSION =>
result := (Sum_Time (state.Conv_Info_Pres.Start,
conv_time (state.Conv_Info_Pres.OSR)) < Units.To_Time (now));
when others =>
result := False;
end case;
return result;
end conversion_Finished;
------------------------------------
-- calculateTemperatureDifference
------------------------------------
function calculateTemperatureDifference
(Temp_Raw : Conversion_Data_Type;
T_Ref : Float) return DT_Type
is
begin
return DT_Type (Float (Temp_Raw) - T_Ref);
end calculateTemperatureDifference;
----------------------
-- convertToKelvin
----------------------
function convertToKelvin (thisTemp : in TEMP_Type) return Temperature_Type is
ret : Temperature_Type := Temperature_Type'First; -- init required, otherwise constraint error!
cand : constant Float := Float (G_CELSIUS_0) + Float (thisTemp) / 100.0;
-- function Sat_Cast_Temperature is new Units.Saturated_Cast (Temperature_Type);
-- cannot use Sat_Cast here, because that builds on units,
-- which requires default value of 0.0, which isn't in Temperature_Type'Range
begin
if cand > Float (Temperature_Type'Last) then
ret := Temperature_Type'Last;
elsif cand < Float (Temperature_Type'First) then
ret := Temperature_Type'First;
else
ret := Temperature_Type (cand);
end if;
return ret;
end convertToKelvin;
---------------------------
-- compensateTemperature
---------------------------
-- compensates values according to datasheet
procedure compensateTemperature is
T2 : TEMP_Type := 0.0;
OFF2 : OFF_Type := 0.0;
SENS2 : Sense_Type := 0.0;
begin
if TEMP < TEMP_Type (2000.0) then
T2 := Sat_Cast_TEMPType (dT**2 / Float (2**31));
OFF2 := Sat_Cast_OffType (5.0 * (TEMP - TEMP_Type (2000.0))**2 / 2.0);
SENS2 := Sense_Type (OFF2 / 2.0);
if TEMP < TEMP_Type (-1500.0) then
OFF2 := Sat_Add_OffType (OFF2, Sat_Cast_OffType (7.0 * (TEMP - TEMP_Type (1500.0))**2));
SENS2 := Sat_Add_SensType (SENS2, Sat_Cast_SensType (11.0 * (TEMP - TEMP_Type (1500.0))**2 / 2.0));
end if;
end if;
TEMP := Sat_Sub_TempType (TEMP, T2); -- this compensates the final temperature value
OFF := Sat_Sub_OffType (OFF, OFF2);
SENS := Sat_Sub_SensType (SENS, SENS2);
end compensateTemperature;
----------------------
-- calculatePressure
----------------------
function calculatePressure
(arg_pressure_raw : Conversion_Data_Type;
arg_sense : Sense_Type;
arg_offset : OFF_Type) return Pressure_Type
is
begin
return Pressure_Type
((Float (arg_pressure_raw) * arg_sense / Float (2**21) - arg_offset) /
Float (2**15));
end calculatePressure;
----------------------
-- get_temperature
----------------------
function Get_Temperature return Temperature_Type is
begin
return temperature;
end Get_Temperature;
----------------------
-- get_pressure
----------------------
function Get_Pressure return Pressure_Type is
begin
return pressure;
end Get_Pressure;
----------------------
-- update_val
----------------------
procedure Update_Val (have_update : out Boolean) is
begin
-- Barometer takes 10ms (8.2ms) for one conversion, barometer_update_val gets called every main_loop (5ms)
-- read conversion value every second to make sure barometer timing constraint is not violated
have_update := False;
case G_Baro_State.FSM_State is
when NOT_INITIALIZED =>
null;
when READY =>
start_conversion (D2, OSR_4096);
G_Baro_State.FSM_State := TEMPERATURE_CONVERSION;
when TEMPERATURE_CONVERSION =>
-- ToDo check time
declare
t_abs : constant Ada.Real_Time.Time := Clock; -- see SPARK RM 7.1.3-12
begin
if conversion_Finished (G_Baro_State, Conversion_Time_LUT, t_abs) then
read_adc (Baro, temperature_raw);
if temperature_raw /= 0 then
dT := calculateTemperatureDifference (temperature_raw, G_t_ref);
TEMP := Sat_Add_TempType (2000.0, Sat_Cast_TEMPType (dT * G_tempsens));
OFF := Sat_Add_OffType (G_off_t1, Sat_Cast_OffType (G_tco * dT));
SENS := Sat_Add_SensType (G_sens_t1, Sat_Cast_SensType (G_tcs * dT));
compensateTemperature;
temperature := convertToKelvin (TEMP);
start_conversion (D1, OSR_4096);
G_Baro_State.FSM_State := PRESSURE_CONVERSION;
else -- Read error, restart
start_conversion (D2, OSR_4096);
G_Baro_State.FSM_State := TEMPERATURE_CONVERSION;
end if;
end if;
end;
when PRESSURE_CONVERSION =>
declare
t_abs : constant Ada.Real_Time.Time := Clock; -- see SPARK RM 7.1.3-12
begin
if conversion_Finished (G_Baro_State, Conversion_Time_LUT, t_abs) then
read_adc (Baro, pressure_raw);
if pressure_raw /= 0 then
pressure := calculatePressure (pressure_raw, SENS, OFF);
have_update := True;
start_conversion (D2, OSR_4096);
G_Baro_State.FSM_State := TEMPERATURE_CONVERSION;
else
start_conversion (D1, OSR_4096);
G_Baro_State.FSM_State := PRESSURE_CONVERSION;
end if;
end if;
end;
end case;
end Update_Val;
end MS5611.Driver;
|
NormanDunbar/Sarge | Ada | 1,316 | ads | -- sarge.ads - Specification file for the Sarge command line argument parser project.
-- Revision 0
-- Notes:
-- -
-- 2019/04/10, Maya Posch
with Ada.Strings
use Ada.Strings
with Ada.Containers.Vectors;
with Ada.Containers.Indefinite_Ordered_Maps;
use Ada.Containers;
package Sarge is
type Argument is record
arg_short: string;
arg_long: string;
description: string;
hasValue: boolean := Boolean.False;
value: string;
parsed: boolean := Boolean.False;
end record;
type Argument_Access is access all Argument;
procedure setArgument(arg_short: in string, arg_long: in string, desc: in string, hasVal: in boolean);
procedure setDescription(desc: in string);
procedure setUsage(usage: in string);
function parseArguments() return boolean;
function getFlag(arg_flag: in string, arg_value: out arg_value) return boolean;
function exists(arg_flag: in string) returns boolean;
procedure printHelp();
function flagCount() return integer;
function executableName() return string;
private
package arg_vector is new Vectors(Natural, Argument);
args: arg_vector.vector;
package argNames_map is new Indefinite_Ordered_Maps(string, Argument_Access);
argNames: argNames_map.map;
parsed: boolean;
flagCounter: 0;
execName: string;
description: string;
usage: string;
end Sarge;
|
msrLi/portingSources | Ada | 3,092 | ads | ------------------------------------------------------------------------------
-- --
-- GNAT ncurses Binding Samples --
-- --
-- Rain --
-- --
-- S P E C --
-- --
------------------------------------------------------------------------------
-- Copyright (c) 1998 Free Software Foundation, Inc. --
-- --
-- Permission is hereby granted, free of charge, to any person obtaining a --
-- copy of this software and associated documentation files (the --
-- "Software"), to deal in the Software without restriction, including --
-- without limitation the rights to use, copy, modify, merge, publish, --
-- distribute, distribute with modifications, sublicense, and/or sell --
-- copies of the Software, and to permit persons to whom the Software is --
-- furnished to do so, subject to the following conditions: --
-- --
-- The above copyright notice and this permission notice shall be included --
-- in all copies or substantial portions of the Software. --
-- --
-- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS --
-- OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF --
-- MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. --
-- IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, --
-- DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR --
-- OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR --
-- THE USE OR OTHER DEALINGS IN THE SOFTWARE. --
-- --
-- Except as contained in this notice, the name(s) of the above copyright --
-- holders shall not be used in advertising or otherwise to promote the --
-- sale, use or other dealings in this Software without prior written --
-- authorization. --
------------------------------------------------------------------------------
-- Author: Laurent Pautet <[email protected]>
-- Modified by: Juergen Pfeifer, 1997
-- Version Control
-- $Revision: 1.6 $
-- Binding Version 01.00
------------------------------------------------------------------------------
-- --
procedure Rain;
|
hsgrewal/learning-ada | Ada | 587 | adb | -- basic_types_ranges.adb
with Ada.Text_IO; use Ada.Text_IO;
procedure basic_types_ranges is
begin
Put_Line("The min range of an integer [" & Integer'Image(Integer'First) & "] and the max range of an integer [" & Integer'Image(Integer'Last) & "].");
Put_Line("The min range of a positive [" & Positive'Image(Positive'First) & "] and the max range of a positive [" & Positive'Image(Positive'Last) & "].");
Put_Line("The min range of a natural [" & Natural'Image(Natural'First) & "] and the max range of a natural [" & Natural'Image(Natural'Last) & "].");
end basic_types_ranges;
|
iyan22/AprendeAda | Ada | 2,469 | adb | with Ada.Text_Io; use Ada.Text_Io;
with vectores; use vectores;
with esta_en_vector;
procedure prueba_esta_en_vector is
-- este programa hace llamadas a la funcion esta_en_vector y es util
-- para comprobar si su funcionamiento es correcto
procedure escribir_booleano(valor: in Boolean) is
begin
if(valor) then
put("True");
else
put("False");
end if;
end escribir_booleano;
Vector1: Vector_De_Enteros(1..10);
Vector2: Vector_De_Enteros(800..804);
rdo: boolean;
begin
vector1 := (1, 3, 5, 7, 19, 6, 13, 15, 17, 9);
put_line("Caso 1: el valor esta en medio");
put_line(" esta_en_vector(13, (1, 3, 5, 7, 19, 6, 13, 15, 17, 9))");
put_line(" debe ser True y el resultado es ");
rdo:=esta_en_vector(13, vector1);
escribir_booleano(rdo);
new_line(3);
put_line("Pulsa return para continuar");
skip_line;
new_line(3);
vector1 := (1, 3, 5, 7, 19, 6, 13, 15, 17, 9);
put_line("Caso 2: el valor esta al final");
put_line(" esta_en_vector(9, (1, 3, 5, 7, 19, 6, 13, 15, 17, 9))");
put_line(" debe ser True y el resultado es ");
rdo:=esta_en_vector(9, vector1);
escribir_booleano(rdo);
new_line(3);
put_line("Pulsa return para continuar");
skip_line;
new_line(3);
vector1 := (1, 3, 5, 7, 19, 6, 13, 15, 17, 9);
put_line("Caso 3: el valor no esta, se debe recorrer todo el vector");
put_line(" esta_en_vector(45, (1, 3, 5, 7, 19, 6, 13, 15, 17, 9))");
put_line(" debe ser False y el resultado es ");
rdo:=esta_en_vector(45, vector1);
escribir_booleano(rdo);
new_line(3);
put_line("Pulsa return para continuar");
skip_line;
new_line(3);
-- mis casos de prueba
vector2 := (0, 1, 3, 5, 7);
put_line("Caso 3: vector corto, el valor esta al final");
put_line(" esta_en_vector(7, (1, 3, 5, 7))");
put_line(" debe ser True y el resultado es ");
rdo:=esta_en_vector(7, vector1);
escribir_booleano(rdo);
new_line(3);
put_line("Pulsa return para continuar");
skip_line;
new_line(3);
vector2 := (0, 13, 15, 17, 9);
put_line("Caso 3: vector corto, el valor no esta, se debe recorrer todo el vector");
put_line(" esta_en_vector(45, (13, 15, 17, 9))");
put_line(" debe ser False y el resultado es ");
rdo:=esta_en_vector(45, vector1);
escribir_booleano(rdo);
new_line(3);
put_line("Pulsa return para continuar");
skip_line;
new_line(3);
end prueba_esta_en_vector;
|
reznikmm/matreshka | Ada | 1,451 | ads | package scanner.DFA is
Aflex_Debug : Boolean := False;
YYText_Ptr : Integer; -- points to start of yytext in buffer
-- yy_ch_buf has to be 2 characters longer than YY_BUF_SIZE because we
-- need to put in 2 end-of-buffer characters (this is explained where
-- it is done) at the end of yy_ch_buf
YY_READ_BUF_SIZE : constant Integer := 8192;
YY_BUF_SIZE : constant Integer := YY_READ_BUF_SIZE * 2;
-- Size of input buffer
type Unbounded_Character_Array is
array (Integer range <>) of Wide_Wide_Character;
type Ch_Buf_Type is record
Data : Unbounded_Character_Array (0 .. YY_BUF_SIZE + 1);
end record;
function Previous
(Data : Ch_Buf_Type; Index : Integer) return Wide_Wide_Character;
procedure Next
(Data : Ch_Buf_Type;
Index : in out Integer;
Code : out Wide_Wide_Character);
YY_Ch_Buf : Ch_Buf_Type;
YY_CP : Integer;
YY_BP : Integer;
YY_C_Buf_P : Integer; -- Points to current character in buffer
function YYText return Wide_Wide_String;
function YYLength return Integer;
procedure YY_DO_BEFORE_ACTION;
-- These variables are needed between calls to YYLex.
YY_Init : Boolean := True; -- do we need to initialize YYLex?
YY_Start : Integer := 0; -- current start state number
subtype YY_State_Type is Integer;
YY_Last_Accepting_State : YY_State_Type;
YY_Last_Accepting_Cpos : Integer;
end scanner.DFA;
|
reznikmm/matreshka | Ada | 4,131 | 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.Chart_Values_Cell_Range_Address_Attributes;
package Matreshka.ODF_Chart.Values_Cell_Range_Address_Attributes is
type Chart_Values_Cell_Range_Address_Attribute_Node is
new Matreshka.ODF_Chart.Abstract_Chart_Attribute_Node
and ODF.DOM.Chart_Values_Cell_Range_Address_Attributes.ODF_Chart_Values_Cell_Range_Address_Attribute
with null record;
overriding function Create
(Parameters : not null access Matreshka.DOM_Attributes.Attribute_L2_Parameters)
return Chart_Values_Cell_Range_Address_Attribute_Node;
overriding function Get_Local_Name
(Self : not null access constant Chart_Values_Cell_Range_Address_Attribute_Node)
return League.Strings.Universal_String;
end Matreshka.ODF_Chart.Values_Cell_Range_Address_Attributes;
|
reznikmm/matreshka | Ada | 3,621 | ads | ------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- Ada Modeling Framework --
-- --
-- Runtime Library Component --
-- --
------------------------------------------------------------------------------
-- --
-- Copyright © 2011-2012, Vadim Godunko <[email protected]> --
-- All rights reserved. --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions --
-- are met: --
-- --
-- * Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- --
-- * Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in the --
-- documentation and/or other materials provided with the distribution. --
-- --
-- * Neither the name of the Vadim Godunko, IE nor the names of its --
-- contributors may be used to endorse or promote products derived from --
-- this software without specific prior written permission. --
-- --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR --
-- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
-- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED --
-- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR --
-- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF --
-- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING --
-- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS --
-- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
-- --
------------------------------------------------------------------------------
-- $Revision$ $Date$
------------------------------------------------------------------------------
-- This file is generated, don't edit it.
------------------------------------------------------------------------------
with AMF.Elements.Generic_Hash;
function AMF.UML.Data_Store_Nodes.Hash is
new AMF.Elements.Generic_Hash (UML_Data_Store_Node, UML_Data_Store_Node_Access);
|
stcarrez/ada-wiki | Ada | 5,967 | adb | -----------------------------------------------------------------------
-- wiki-streams-text_io -- Text_IO input output streams
-- Copyright (C) 2016, 2022 Stephane Carrez
-- Written by Stephane Carrez ([email protected])
--
-- Licensed under the Apache License, Version 2.0 (the "License");
-- you may not use this file except in compliance with the License.
-- You may obtain a copy of the License at
--
-- http://www.apache.org/licenses/LICENSE-2.0
--
-- Unless required by applicable law or agreed to in writing, software
-- distributed under the License is distributed on an "AS IS" BASIS,
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-- See the License for the specific language governing permissions and
-- limitations under the License.
-----------------------------------------------------------------------
with Ada.IO_Exceptions;
with Wiki.Helpers;
package body Wiki.Streams.Text_IO is
-- ------------------------------
-- Open the file and prepare to read the input stream.
-- ------------------------------
procedure Open (Stream : in out File_Input_Stream;
Path : in String;
Form : in String := "") is
begin
Ada.Wide_Wide_Text_IO.Open (Stream.File, Ada.Wide_Wide_Text_IO.In_File, Path, Form);
Stream.Stdin := False;
end Open;
-- ------------------------------
-- Close the file.
-- ------------------------------
procedure Close (Stream : in out File_Input_Stream) is
begin
if Ada.Wide_Wide_Text_IO.Is_Open (Stream.File) then
Ada.Wide_Wide_Text_IO.Close (Stream.File);
end if;
end Close;
-- ------------------------------
-- Close the stream.
-- ------------------------------
overriding
procedure Finalize (Stream : in out File_Input_Stream) is
begin
Stream.Close;
end Finalize;
-- ------------------------------
-- Read the input stream and fill the `Into` buffer until either it is full or
-- we reach the end of line. Returns in `Last` the last valid position in the
-- `Into` buffer. When there is no character to read, return True in
-- the `Eof` indicator.
-- ------------------------------
overriding
procedure Read (Input : in out File_Input_Stream;
Into : in out Wiki.Strings.WString;
Last : out Natural;
Eof : out Boolean) is
begin
if Input.Stdin then
if not Ada.Wide_Wide_Text_IO.End_Of_File then
Ada.Wide_Wide_Text_IO.Get_Line (Into, Last);
if Last < Into'Last then
Into (Last + 1) := Helpers.LF;
Last := Last + 1;
end if;
Eof := False;
else
Last := Into'First - 1;
Eof := True;
end if;
else
if not Ada.Wide_Wide_Text_IO.End_Of_File (Input.File) then
Ada.Wide_Wide_Text_IO.Get_Line (Input.File, Into, Last);
if Last < Into'Last then
Into (Last + 1) := Helpers.LF;
Last := Last + 1;
end if;
Eof := False;
else
Last := Into'First - 1;
Eof := True;
end if;
end if;
exception
when Ada.IO_Exceptions.End_Error =>
Last := Into'First - 1;
Eof := True;
end Read;
-- ------------------------------
-- Open the file and prepare to write the output stream.
-- ------------------------------
procedure Open (Stream : in out File_Output_Stream;
Path : in String;
Form : in String := "") is
begin
if Ada.Wide_Wide_Text_IO.Is_Open (Stream.File) then
Ada.Wide_Wide_Text_IO.Close (Stream.File);
end if;
Ada.Wide_Wide_Text_IO.Open (Stream.File, Ada.Wide_Wide_Text_IO.Out_File, Path, Form);
Ada.Wide_Wide_Text_IO.Set_Line_Length (Ada.Wide_Wide_Text_IO.Count'Last);
Stream.Stdout := False;
end Open;
-- ------------------------------
-- Create the file and prepare to write the output stream.
-- ------------------------------
procedure Create (Stream : in out File_Output_Stream;
Path : in String;
Form : in String := "") is
begin
Ada.Wide_Wide_Text_IO.Create (Stream.File, Ada.Wide_Wide_Text_IO.Out_File, Path, Form);
Ada.Wide_Wide_Text_IO.Set_Line_Length (Ada.Wide_Wide_Text_IO.Count'Last);
Stream.Stdout := False;
end Create;
-- ------------------------------
-- Close the file.
-- ------------------------------
procedure Close (Stream : in out File_Output_Stream) is
begin
if Ada.Wide_Wide_Text_IO.Is_Open (Stream.File) then
Ada.Wide_Wide_Text_IO.Close (Stream.File);
end if;
end Close;
-- ------------------------------
-- Write the string to the output stream.
-- ------------------------------
overriding
procedure Write (Stream : in out File_Output_Stream;
Content : in Wiki.Strings.WString) is
begin
if not Stream.Stdout then
Ada.Wide_Wide_Text_IO.Put (Stream.File, Content);
else
Ada.Wide_Wide_Text_IO.Put (Content);
end if;
end Write;
-- ------------------------------
-- Write a single character to the output stream.
-- ------------------------------
overriding
procedure Write (Stream : in out File_Output_Stream;
Char : in Wiki.Strings.WChar) is
begin
if not Stream.Stdout then
Ada.Wide_Wide_Text_IO.Put (Stream.File, Char);
else
Ada.Wide_Wide_Text_IO.Put (Char);
end if;
end Write;
-- ------------------------------
-- Close the stream.
-- ------------------------------
overriding
procedure Finalize (Stream : in out File_Output_Stream) is
begin
Stream.Close;
end Finalize;
end Wiki.Streams.Text_IO;
|
reznikmm/matreshka | Ada | 4,600 | adb | ------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- Open Document Toolkit --
-- --
-- Runtime Library Component --
-- --
------------------------------------------------------------------------------
-- --
-- Copyright © 2014, Vadim Godunko <[email protected]> --
-- All rights reserved. --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions --
-- are met: --
-- --
-- * Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- --
-- * Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in the --
-- documentation and/or other materials provided with the distribution. --
-- --
-- * Neither the name of the Vadim Godunko, IE nor the names of its --
-- contributors may be used to endorse or promote products derived from --
-- this software without specific prior written permission. --
-- --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR --
-- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
-- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED --
-- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR --
-- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF --
-- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING --
-- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS --
-- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
-- --
------------------------------------------------------------------------------
-- $Revision$ $Date$
------------------------------------------------------------------------------
with Matreshka.DOM_Documents;
with Matreshka.ODF_String_Constants;
with ODF.DOM.Iterators;
with ODF.DOM.Visitors;
package body Matreshka.ODF_Table.Date_End_Attributes is
------------
-- Create --
------------
overriding function Create
(Parameters : not null access Matreshka.DOM_Attributes.Attribute_L2_Parameters)
return Table_Date_End_Attribute_Node is
begin
return Self : Table_Date_End_Attribute_Node do
Matreshka.ODF_Table.Constructors.Initialize
(Self'Unchecked_Access,
Parameters.Document,
Matreshka.ODF_String_Constants.Table_Prefix);
end return;
end Create;
--------------------
-- Get_Local_Name --
--------------------
overriding function Get_Local_Name
(Self : not null access constant Table_Date_End_Attribute_Node)
return League.Strings.Universal_String
is
pragma Unreferenced (Self);
begin
return Matreshka.ODF_String_Constants.Date_End_Attribute;
end Get_Local_Name;
begin
Matreshka.DOM_Documents.Register_Attribute
(Matreshka.ODF_String_Constants.Table_URI,
Matreshka.ODF_String_Constants.Date_End_Attribute,
Table_Date_End_Attribute_Node'Tag);
end Matreshka.ODF_Table.Date_End_Attributes;
|
Letractively/ada-ado | Ada | 2,423 | ads | -----------------------------------------------------------------------
-- ado-schemas-entities -- Entity types cache
-- Copyright (C) 2011, 2012 Stephane Carrez
-- Written by Stephane Carrez ([email protected])
--
-- Licensed under the Apache License, Version 2.0 (the "License");
-- you may not use this file except in compliance with the License.
-- You may obtain a copy of the License at
--
-- http://www.apache.org/licenses/LICENSE-2.0
--
-- Unless required by applicable law or agreed to in writing, software
-- distributed under the License is distributed on an "AS IS" BASIS,
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-- See the License for the specific language governing permissions and
-- limitations under the License.
-----------------------------------------------------------------------
with Ada.Containers;
with Ada.Containers.Indefinite_Hashed_Maps;
with Ada.Strings.Hash;
with ADO.Sessions;
package ADO.Schemas.Entities is
No_Entity_Type : exception;
-- The entity cache maintains a static cache of database entities.
type Entity_Cache is private;
-- Find the entity type index associated with the given database table.
-- Raises the No_Entity_Type exception if no such mapping exist.
function Find_Entity_Type (Cache : in Entity_Cache;
Table : in Class_Mapping_Access) return ADO.Entity_Type;
-- Find the entity type index associated with the given database table.
-- Raises the No_Entity_Type exception if no such mapping exist.
function Find_Entity_Type (Cache : in Entity_Cache;
Name : in Util.Strings.Name_Access) return ADO.Entity_Type;
-- Initialize the entity cache by reading the database entity table.
procedure Initialize (Cache : in out Entity_Cache;
Session : in out ADO.Sessions.Session'Class);
private
package Entity_Map is new
Ada.Containers.Indefinite_Hashed_Maps (Key_Type => String,
Element_Type => ADO.Entity_Type,
Hash => Ada.Strings.Hash,
Equivalent_Keys => "=");
type Entity_Cache is record
Entities : Entity_Map.Map;
end record;
end ADO.Schemas.Entities;
|
rogermc2/GA_Ada | Ada | 785 | ads |
with GA_Maths;
with Multivectors; use Multivectors;
package C3GA_Utilities is
-- function exp is implemented in the Multivectors package
-- special exp() for 3D bivectors
function exp (BV : Bivector) return Rotor;
-- special log() for 3D rotors
function Log_Rotor (R : Rotor) return Bivector;
function Log_TR_Versor (V : TR_Versor) return Dual_Line;
procedure Print_Rotor (Name : String; R : Rotor);
-- procedure Print_Vector (Name : String; aVector : E2GA.Vector);
-- procedure Print_Vector (Name : String; aVector : E3GA.Vector);
procedure Rotor_To_Matrix (R : Rotor; M : out GA_Maths.GA_Matrix3);
function Rotor_Vector_To_Vector (From_V1, To_V2 : Multivectors.M_Vector)
return Rotor;
end C3GA_Utilities;
|
Fabien-Chouteau/GESTE | Ada | 667 | ads | with Ada.Text_IO; use Ada.Text_IO;
with GESTE_Config;
with GESTE;
generic
Width : Natural;
Height : Natural;
Buffer_Size : Positive;
Init_Char : Character;
package Console_Char_Screen is
Screen_Rect : constant GESTE.Pix_Rect := ((0, 0), (Width - 1, Height - 1));
Buffer : GESTE.Output_Buffer (1 .. Buffer_Size);
procedure Push_Pixels (Buffer : GESTE.Output_Buffer);
procedure Set_Drawing_Area (Area : GESTE.Pix_Rect);
procedure Print;
procedure Verbose;
procedure Set_Output (Output : File_Type);
procedure Test_Collision (X, Y : Integer;
Expected : Boolean);
end Console_Char_Screen;
|
notdb/LC-Practice | Ada | 424 | adb | with Ada.Text_IO; use Ada.Text_IO;
procedure Greet_5b is
I : Integer := 1; -- Variable declaration
-- ^ Type
-- ^ Initial value
begin
loop
Put_Line ("Hello, World!" & Integer'Image (I));
exit when I = 5; -- Exit statement
-- ^ Boolean condition
-- Assignment
I := I + 1; -- There is no i++ short form to increment a variable
end loop;
end Greet_5b;
|
DrenfongWong/tkm-rpc | Ada | 2,053 | ads | --
-- Copyright (C) 2013 Reto Buerki <[email protected]>
-- Copyright (C) 2013 Adrian-Ken Rueegsegger <[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:
-- 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 University 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 REGENTS 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 REGENTS 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 Ahven.Framework;
package Tkmrpc_Request_Tests
is
type Testcase is new Ahven.Framework.Test_Case with null record;
procedure Initialize (T : in out Testcase);
-- Initialize testcase.
procedure Stream_Conversion;
-- Verify request data to/from stream conversions.
procedure Request_Validation;
-- Verify request data validity checks.
end Tkmrpc_Request_Tests;
|
AdaCore/libadalang | Ada | 171 | adb | package body Test is
package body Inner is
function F (A : Address_Type) return Boolean is
begin
return True;
end F;
end Inner;
end Test;
|
io7m/coreland-opengl-ada | Ada | 936 | adb | package body OpenGL.Vertex is
--
-- Immediate mode.
--
function Primitive_Type_To_Constant
(Mode : in Primitive_Type_t) return Thin.Enumeration_t is
begin
case Mode is
when Points => return Thin.GL_POINTS;
when Lines => return Thin.GL_LINES;
when Line_Strip => return Thin.GL_LINE_STRIP;
when Line_Loop => return Thin.GL_LINE_LOOP;
when Triangles => return Thin.GL_TRIANGLES;
when Triangle_Strip => return Thin.GL_TRIANGLE_STRIP;
when Triangle_Fan => return Thin.GL_TRIANGLE_FAN;
when Quads => return Thin.GL_QUADS;
when Quad_Strip => return Thin.GL_QUAD_STRIP;
when Polygon => return Thin.GL_POLYGON;
end case;
end Primitive_Type_To_Constant;
procedure GL_Begin (Mode : in Primitive_Type_t) is
begin
Thin.GL_Begin (Primitive_Type_To_Constant (Mode));
end GL_Begin;
end OpenGL.Vertex;
|
reznikmm/matreshka | Ada | 3,744 | ads | ------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- Open Document Toolkit --
-- --
-- Runtime Library Component --
-- --
------------------------------------------------------------------------------
-- --
-- Copyright © 2014, Vadim Godunko <[email protected]> --
-- All rights reserved. --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions --
-- are met: --
-- --
-- * Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- --
-- * Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in the --
-- documentation and/or other materials provided with the distribution. --
-- --
-- * Neither the name of the Vadim Godunko, IE nor the names of its --
-- contributors may be used to endorse or promote products derived from --
-- this software without specific prior written permission. --
-- --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR --
-- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
-- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED --
-- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR --
-- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF --
-- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING --
-- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS --
-- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
-- --
------------------------------------------------------------------------------
-- $Revision$ $Date$
------------------------------------------------------------------------------
with XML.DOM.Attributes;
package ODF.DOM.Svg_GradientTransform_Attributes is
pragma Preelaborate;
type ODF_Svg_GradientTransform_Attribute is limited interface
and XML.DOM.Attributes.DOM_Attribute;
type ODF_Svg_GradientTransform_Attribute_Access is
access all ODF_Svg_GradientTransform_Attribute'Class
with Storage_Size => 0;
end ODF.DOM.Svg_GradientTransform_Attributes;
|
optikos/oasis | Ada | 1,766 | ads | -- Copyright (c) 2019 Maxim Reznik <[email protected]>
--
-- SPDX-License-Identifier: MIT
-- License-Filename: LICENSE
-------------------------------------------------------------
with Program.Lexical_Elements;
with Program.Elements.Identifiers;
with Program.Elements.Parameter_Associations;
package Program.Elements.Pragmas is
pragma Pure (Program.Elements.Pragmas);
type Pragma_Element is limited interface and Program.Elements.Element;
type Pragma_Access is access all Pragma_Element'Class
with Storage_Size => 0;
not overriding function Name
(Self : Pragma_Element)
return not null Program.Elements.Identifiers.Identifier_Access
is abstract;
not overriding function Arguments
(Self : Pragma_Element)
return Program.Elements.Parameter_Associations
.Parameter_Association_Vector_Access is abstract;
type Pragma_Text is limited interface;
type Pragma_Text_Access is access all Pragma_Text'Class
with Storage_Size => 0;
not overriding function To_Pragma_Text
(Self : aliased in out Pragma_Element)
return Pragma_Text_Access is abstract;
not overriding function Pragma_Token
(Self : Pragma_Text)
return not null Program.Lexical_Elements.Lexical_Element_Access
is abstract;
not overriding function Left_Bracket_Token
(Self : Pragma_Text)
return Program.Lexical_Elements.Lexical_Element_Access is abstract;
not overriding function Right_Bracket_Token
(Self : Pragma_Text)
return Program.Lexical_Elements.Lexical_Element_Access is abstract;
not overriding function Semicolon_Token
(Self : Pragma_Text)
return not null Program.Lexical_Elements.Lexical_Element_Access
is abstract;
end Program.Elements.Pragmas;
|
reznikmm/matreshka | Ada | 3,714 | ads | ------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- Open Document Toolkit --
-- --
-- Runtime Library Component --
-- --
------------------------------------------------------------------------------
-- --
-- Copyright © 2014, Vadim Godunko <[email protected]> --
-- All rights reserved. --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions --
-- are met: --
-- --
-- * Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- --
-- * Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in the --
-- documentation and/or other materials provided with the distribution. --
-- --
-- * Neither the name of the Vadim Godunko, IE nor the names of its --
-- contributors may be used to endorse or promote products derived from --
-- this software without specific prior written permission. --
-- --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR --
-- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
-- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED --
-- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR --
-- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF --
-- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING --
-- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS --
-- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
-- --
------------------------------------------------------------------------------
-- $Revision$ $Date$
------------------------------------------------------------------------------
with XML.DOM.Attributes;
package ODF.DOM.Text_Row_Number_Attributes is
pragma Preelaborate;
type ODF_Text_Row_Number_Attribute is limited interface
and XML.DOM.Attributes.DOM_Attribute;
type ODF_Text_Row_Number_Attribute_Access is
access all ODF_Text_Row_Number_Attribute'Class
with Storage_Size => 0;
end ODF.DOM.Text_Row_Number_Attributes;
|
tum-ei-rcs/StratoX | Ada | 4,061 | ads | ------------------------------------------------------------------------------
-- --
-- Copyright (C) 2015, AdaCore --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions are --
-- met: --
-- 1. Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- 2. Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in --
-- the documentation and/or other materials provided with the --
-- distribution. --
-- 3. Neither the name of STMicroelectronics nor the names of its --
-- contributors may be used to endorse or promote products derived --
-- from this software without specific prior written permission. --
-- --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR --
-- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
-- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT --
-- LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, --
-- DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY --
-- THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT --
-- (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE --
-- OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
-- --
------------------------------------------------------------------------------
pragma Restrictions (No_Elaboration_Code);
package STM32.RCC is
-- type RCC_System_Clocks is record
-- SYSCLK : Word;
-- HCLK : Word;
-- PCLK1 : Word;
-- PCLK2 : Word;
-- TIMCLK1 : Word;
-- TIMCLK2 : Word;
-- end record;
--
-- function System_Clock_Frequencies return RCC_System_Clocks;
-- Part below is obsolete and should be moved to the corresponding driver.
procedure CRC_Clock_Enable with Inline;
procedure BKPSRAM_Clock_Enable with Inline;
-- procedure CCMDATARAMEN_Clock_Enable with Inline;
-- procedure DMA2D_Clock_Enable with Inline;
procedure WWDG_Clock_Enable with Inline;
-- procedure SDIO_Clock_Enable with Inline;
procedure SYSCFG_Clock_Enable with Inline;
procedure AHB1_Force_Reset with Inline;
procedure AHB1_Release_Reset with Inline;
procedure AHB2_Force_Reset with Inline;
procedure AHB2_Release_Reset with Inline;
procedure APB1_Force_Reset with Inline;
procedure APB1_Release_Reset with Inline;
procedure APB2_Force_Reset with Inline;
procedure APB2_Release_Reset with Inline;
procedure CRC_Force_Reset with Inline;
procedure CRC_Release_Reset with Inline;
-- procedure DMA2D_Force_Reset with Inline;
-- procedure DMA2D_Release_Reset with Inline;
procedure OTGFS_Force_Reset with Inline;
procedure OTGFS_Release_Reset with Inline;
procedure WWDG_Force_Reset with Inline;
procedure WWDG_Release_Reset with Inline;
-- procedure SDIO_Force_Reset with Inline;
-- procedure SDIO_Release_Reset with Inline;
procedure SYSCFG_Force_Reset with Inline;
procedure SYSCFG_Release_Reset with Inline;
end STM32.RCC;
|
sungyeon/drake | Ada | 1,301 | ads | pragma License (Unrestricted);
-- separated and auto-loaded by compiler
private generic
type Num is delta <>;
package Ada.Text_IO.Fixed_IO is
Default_Fore : Field := Num'Fore;
Default_Aft : Field := Num'Aft;
Default_Exp : Field := 0;
procedure Get (
File : File_Type; -- Input_File_Type
Item : out Num;
Width : Field := 0);
procedure Get (
Item : out Num;
Width : Field := 0);
procedure Get (
File : not null File_Access;
Item : out Num;
Width : Field := 0); -- alt
procedure Put (
File : File_Type; -- Output_File_Type
Item : Num;
Fore : Field := Default_Fore;
Aft : Field := Default_Aft;
Exp : Field := Default_Exp);
procedure Put (
Item : Num;
Fore : Field := Default_Fore;
Aft : Field := Default_Aft;
Exp : Field := Default_Exp);
procedure Put (
File : not null File_Access;
Item : Num;
Fore : Field := Default_Fore;
Aft : Field := Default_Aft;
Exp : Field := Default_Exp); -- alt
procedure Get (
From : String;
Item : out Num;
Last : out Positive);
procedure Put (
To : out String;
Item : Num;
Aft : Field := Default_Aft;
Exp : Field := Default_Exp);
end Ada.Text_IO.Fixed_IO;
|
reznikmm/matreshka | Ada | 3,744 | ads | ------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- Open Document Toolkit --
-- --
-- Runtime Library Component --
-- --
------------------------------------------------------------------------------
-- --
-- Copyright © 2014, Vadim Godunko <[email protected]> --
-- All rights reserved. --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions --
-- are met: --
-- --
-- * Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- --
-- * Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in the --
-- documentation and/or other materials provided with the distribution. --
-- --
-- * Neither the name of the Vadim Godunko, IE nor the names of its --
-- contributors may be used to endorse or promote products derived from --
-- this software without specific prior written permission. --
-- --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR --
-- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
-- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED --
-- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR --
-- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF --
-- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING --
-- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS --
-- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
-- --
------------------------------------------------------------------------------
-- $Revision$ $Date$
------------------------------------------------------------------------------
with XML.DOM.Elements;
package ODF.DOM.Table_Data_Pilot_Display_Info_Elements is
pragma Preelaborate;
type ODF_Table_Data_Pilot_Display_Info is limited interface
and XML.DOM.Elements.DOM_Element;
type ODF_Table_Data_Pilot_Display_Info_Access is
access all ODF_Table_Data_Pilot_Display_Info'Class
with Storage_Size => 0;
end ODF.DOM.Table_Data_Pilot_Display_Info_Elements;
|
reznikmm/matreshka | Ada | 7,933 | 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$
------------------------------------------------------------------------------
-- This file is generated, don't edit it.
------------------------------------------------------------------------------
with AMF.Elements;
with AMF.Internals.Helpers;
with AMF.Internals.Tables.UML_Attributes;
with AMF.UML.Behavioral_Features;
with AMF.UML.Usages;
with AMF.Visitors.Standard_Profile_L2_Iterators;
with AMF.Visitors.Standard_Profile_L2_Visitors;
package body AMF.Internals.Standard_Profile_L2_Creates is
---------------------------------
-- Get_Base_Behavioral_Feature --
---------------------------------
overriding function Get_Base_Behavioral_Feature
(Self : not null access constant Standard_Profile_L2_Create_Proxy)
return AMF.UML.Behavioral_Features.UML_Behavioral_Feature_Access is
begin
return
AMF.UML.Behavioral_Features.UML_Behavioral_Feature_Access
(AMF.Internals.Helpers.To_Element
(AMF.Internals.Tables.UML_Attributes.Internal_Get_Base_Behavioral_Feature
(Self.Element)));
end Get_Base_Behavioral_Feature;
---------------------------------
-- Set_Base_Behavioral_Feature --
---------------------------------
overriding procedure Set_Base_Behavioral_Feature
(Self : not null access Standard_Profile_L2_Create_Proxy;
To : AMF.UML.Behavioral_Features.UML_Behavioral_Feature_Access) is
begin
AMF.Internals.Tables.UML_Attributes.Internal_Set_Base_Behavioral_Feature
(Self.Element,
AMF.Internals.Helpers.To_Element
(AMF.Elements.Element_Access (To)));
end Set_Base_Behavioral_Feature;
--------------------
-- Get_Base_Usage --
--------------------
overriding function Get_Base_Usage
(Self : not null access constant Standard_Profile_L2_Create_Proxy)
return AMF.UML.Usages.UML_Usage_Access is
begin
return
AMF.UML.Usages.UML_Usage_Access
(AMF.Internals.Helpers.To_Element
(AMF.Internals.Tables.UML_Attributes.Internal_Get_Base_Usage
(Self.Element)));
end Get_Base_Usage;
--------------------
-- Set_Base_Usage --
--------------------
overriding procedure Set_Base_Usage
(Self : not null access Standard_Profile_L2_Create_Proxy;
To : AMF.UML.Usages.UML_Usage_Access) is
begin
AMF.Internals.Tables.UML_Attributes.Internal_Set_Base_Usage
(Self.Element,
AMF.Internals.Helpers.To_Element
(AMF.Elements.Element_Access (To)));
end Set_Base_Usage;
-------------------
-- Enter_Element --
-------------------
overriding procedure Enter_Element
(Self : not null access constant Standard_Profile_L2_Create_Proxy;
Visitor : in out AMF.Visitors.Abstract_Visitor'Class;
Control : in out AMF.Visitors.Traverse_Control) is
begin
if Visitor in AMF.Visitors.Standard_Profile_L2_Visitors.Standard_Profile_L2_Visitor'Class then
AMF.Visitors.Standard_Profile_L2_Visitors.Standard_Profile_L2_Visitor'Class
(Visitor).Enter_Create
(AMF.Standard_Profile_L2.Creates.Standard_Profile_L2_Create_Access (Self),
Control);
end if;
end Enter_Element;
-------------------
-- Leave_Element --
-------------------
overriding procedure Leave_Element
(Self : not null access constant Standard_Profile_L2_Create_Proxy;
Visitor : in out AMF.Visitors.Abstract_Visitor'Class;
Control : in out AMF.Visitors.Traverse_Control) is
begin
if Visitor in AMF.Visitors.Standard_Profile_L2_Visitors.Standard_Profile_L2_Visitor'Class then
AMF.Visitors.Standard_Profile_L2_Visitors.Standard_Profile_L2_Visitor'Class
(Visitor).Leave_Create
(AMF.Standard_Profile_L2.Creates.Standard_Profile_L2_Create_Access (Self),
Control);
end if;
end Leave_Element;
-------------------
-- Visit_Element --
-------------------
overriding procedure Visit_Element
(Self : not null access constant Standard_Profile_L2_Create_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.Standard_Profile_L2_Iterators.Standard_Profile_L2_Iterator'Class then
AMF.Visitors.Standard_Profile_L2_Iterators.Standard_Profile_L2_Iterator'Class
(Iterator).Visit_Create
(Visitor,
AMF.Standard_Profile_L2.Creates.Standard_Profile_L2_Create_Access (Self),
Control);
end if;
end Visit_Element;
end AMF.Internals.Standard_Profile_L2_Creates;
|
Tim-Tom/project-euler | Ada | 58 | ads | package Problem_32 is
procedure Solve;
end Problem_32;
|
reznikmm/matreshka | Ada | 6,960 | adb | ------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- Open Document Toolkit --
-- --
-- Runtime Library Component --
-- --
------------------------------------------------------------------------------
-- --
-- Copyright © 2014, Vadim Godunko <[email protected]> --
-- All rights reserved. --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions --
-- are met: --
-- --
-- * Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- --
-- * Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in the --
-- documentation and/or other materials provided with the distribution. --
-- --
-- * Neither the name of the Vadim Godunko, IE nor the names of its --
-- contributors may be used to endorse or promote products derived from --
-- this software without specific prior written permission. --
-- --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR --
-- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
-- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED --
-- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR --
-- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF --
-- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING --
-- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS --
-- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
-- --
------------------------------------------------------------------------------
-- $Revision$ $Date$
------------------------------------------------------------------------------
with Matreshka.DOM_Documents;
with Matreshka.ODF_String_Constants;
with ODF.DOM.Iterators;
with ODF.DOM.Visitors;
package body Matreshka.ODF_Text.Paragraph_Count_Elements is
------------
-- Create --
------------
overriding function Create
(Parameters : not null access Matreshka.DOM_Elements.Element_L2_Parameters)
return Text_Paragraph_Count_Element_Node is
begin
return Self : Text_Paragraph_Count_Element_Node do
Matreshka.ODF_Text.Constructors.Initialize
(Self'Unchecked_Access,
Parameters.Document,
Matreshka.ODF_String_Constants.Text_Prefix);
end return;
end Create;
----------------
-- Enter_Node --
----------------
overriding procedure Enter_Node
(Self : not null access Text_Paragraph_Count_Element_Node;
Visitor : in out XML.DOM.Visitors.Abstract_Visitor'Class;
Control : in out XML.DOM.Visitors.Traverse_Control) is
begin
if Visitor in ODF.DOM.Visitors.Abstract_ODF_Visitor'Class then
ODF.DOM.Visitors.Abstract_ODF_Visitor'Class
(Visitor).Enter_Text_Paragraph_Count
(ODF.DOM.Text_Paragraph_Count_Elements.ODF_Text_Paragraph_Count_Access
(Self),
Control);
else
Matreshka.DOM_Elements.Abstract_Element_Node
(Self.all).Enter_Node (Visitor, Control);
end if;
end Enter_Node;
--------------------
-- Get_Local_Name --
--------------------
overriding function Get_Local_Name
(Self : not null access constant Text_Paragraph_Count_Element_Node)
return League.Strings.Universal_String
is
pragma Unreferenced (Self);
begin
return Matreshka.ODF_String_Constants.Paragraph_Count_Element;
end Get_Local_Name;
----------------
-- Leave_Node --
----------------
overriding procedure Leave_Node
(Self : not null access Text_Paragraph_Count_Element_Node;
Visitor : in out XML.DOM.Visitors.Abstract_Visitor'Class;
Control : in out XML.DOM.Visitors.Traverse_Control) is
begin
if Visitor in ODF.DOM.Visitors.Abstract_ODF_Visitor'Class then
ODF.DOM.Visitors.Abstract_ODF_Visitor'Class
(Visitor).Leave_Text_Paragraph_Count
(ODF.DOM.Text_Paragraph_Count_Elements.ODF_Text_Paragraph_Count_Access
(Self),
Control);
else
Matreshka.DOM_Elements.Abstract_Element_Node
(Self.all).Leave_Node (Visitor, Control);
end if;
end Leave_Node;
----------------
-- Visit_Node --
----------------
overriding procedure Visit_Node
(Self : not null access Text_Paragraph_Count_Element_Node;
Iterator : in out XML.DOM.Visitors.Abstract_Iterator'Class;
Visitor : in out XML.DOM.Visitors.Abstract_Visitor'Class;
Control : in out XML.DOM.Visitors.Traverse_Control) is
begin
if Iterator in ODF.DOM.Iterators.Abstract_ODF_Iterator'Class then
ODF.DOM.Iterators.Abstract_ODF_Iterator'Class
(Iterator).Visit_Text_Paragraph_Count
(Visitor,
ODF.DOM.Text_Paragraph_Count_Elements.ODF_Text_Paragraph_Count_Access
(Self),
Control);
else
Matreshka.DOM_Elements.Abstract_Element_Node
(Self.all).Visit_Node (Iterator, Visitor, Control);
end if;
end Visit_Node;
begin
Matreshka.DOM_Documents.Register_Element
(Matreshka.ODF_String_Constants.Text_URI,
Matreshka.ODF_String_Constants.Paragraph_Count_Element,
Text_Paragraph_Count_Element_Node'Tag);
end Matreshka.ODF_Text.Paragraph_Count_Elements;
|
Subsets and Splits
No saved queries yet
Save your SQL queries to embed, download, and access them later. Queries will appear here once saved.