repo_name
stringlengths 9
74
| language
stringclasses 1
value | length_bytes
int64 11
9.34M
| extension
stringclasses 2
values | content
stringlengths 11
9.34M
|
---|---|---|---|---|
optikos/oasis | Ada | 4,753 | adb | -- Copyright (c) 2019 Maxim Reznik <[email protected]>
--
-- SPDX-License-Identifier: MIT
-- License-Filename: LICENSE
-------------------------------------------------------------
package body Program.Nodes.Discrete_Range_Attribute_References is
function Create
(Range_Attribute : not null Program.Elements
.Attribute_References.Attribute_Reference_Access;
Is_Discrete_Subtype_Definition : Boolean := False)
return Discrete_Range_Attribute_Reference is
begin
return Result : Discrete_Range_Attribute_Reference :=
(Range_Attribute => Range_Attribute,
Is_Discrete_Subtype_Definition => Is_Discrete_Subtype_Definition,
Enclosing_Element => null)
do
Initialize (Result);
end return;
end Create;
function Create
(Range_Attribute : not null Program.Elements
.Attribute_References.Attribute_Reference_Access;
Is_Part_Of_Implicit : Boolean := False;
Is_Part_Of_Inherited : Boolean := False;
Is_Part_Of_Instance : Boolean := False;
Is_Discrete_Subtype_Definition : Boolean := False)
return Implicit_Discrete_Range_Attribute_Reference is
begin
return Result : Implicit_Discrete_Range_Attribute_Reference :=
(Range_Attribute => Range_Attribute,
Is_Part_Of_Implicit => Is_Part_Of_Implicit,
Is_Part_Of_Inherited => Is_Part_Of_Inherited,
Is_Part_Of_Instance => Is_Part_Of_Instance,
Is_Discrete_Subtype_Definition => Is_Discrete_Subtype_Definition,
Enclosing_Element => null)
do
Initialize (Result);
end return;
end Create;
overriding function Range_Attribute
(Self : Base_Discrete_Range_Attribute_Reference)
return not null Program.Elements.Attribute_References
.Attribute_Reference_Access is
begin
return Self.Range_Attribute;
end Range_Attribute;
overriding function Is_Discrete_Subtype_Definition
(Self : Base_Discrete_Range_Attribute_Reference)
return Boolean is
begin
return Self.Is_Discrete_Subtype_Definition;
end Is_Discrete_Subtype_Definition;
overriding function Is_Part_Of_Implicit
(Self : Implicit_Discrete_Range_Attribute_Reference)
return Boolean is
begin
return Self.Is_Part_Of_Implicit;
end Is_Part_Of_Implicit;
overriding function Is_Part_Of_Inherited
(Self : Implicit_Discrete_Range_Attribute_Reference)
return Boolean is
begin
return Self.Is_Part_Of_Inherited;
end Is_Part_Of_Inherited;
overriding function Is_Part_Of_Instance
(Self : Implicit_Discrete_Range_Attribute_Reference)
return Boolean is
begin
return Self.Is_Part_Of_Instance;
end Is_Part_Of_Instance;
procedure Initialize
(Self : aliased in out Base_Discrete_Range_Attribute_Reference'Class) is
begin
Set_Enclosing_Element (Self.Range_Attribute, Self'Unchecked_Access);
null;
end Initialize;
overriding function Is_Discrete_Range_Attribute_Reference_Element
(Self : Base_Discrete_Range_Attribute_Reference)
return Boolean is
pragma Unreferenced (Self);
begin
return True;
end Is_Discrete_Range_Attribute_Reference_Element;
overriding function Is_Discrete_Range_Element
(Self : Base_Discrete_Range_Attribute_Reference)
return Boolean is
pragma Unreferenced (Self);
begin
return True;
end Is_Discrete_Range_Element;
overriding function Is_Definition_Element
(Self : Base_Discrete_Range_Attribute_Reference)
return Boolean is
pragma Unreferenced (Self);
begin
return True;
end Is_Definition_Element;
overriding procedure Visit
(Self : not null access Base_Discrete_Range_Attribute_Reference;
Visitor : in out Program.Element_Visitors.Element_Visitor'Class) is
begin
Visitor.Discrete_Range_Attribute_Reference (Self);
end Visit;
overriding function To_Discrete_Range_Attribute_Reference_Text
(Self : aliased in out Discrete_Range_Attribute_Reference)
return Program.Elements.Discrete_Range_Attribute_References
.Discrete_Range_Attribute_Reference_Text_Access is
begin
return Self'Unchecked_Access;
end To_Discrete_Range_Attribute_Reference_Text;
overriding function To_Discrete_Range_Attribute_Reference_Text
(Self : aliased in out Implicit_Discrete_Range_Attribute_Reference)
return Program.Elements.Discrete_Range_Attribute_References
.Discrete_Range_Attribute_Reference_Text_Access is
pragma Unreferenced (Self);
begin
return null;
end To_Discrete_Range_Attribute_Reference_Text;
end Program.Nodes.Discrete_Range_Attribute_References;
|
AdaCore/libadalang | Ada | 356 | adb | procedure Test is
A, B, C : Integer;
function Foo return Integer;
function Foo return Boolean;
begin
pragma Section("Test elsif branches");
A := (if Foo then Foo elsif True then B else C);
pragma Test_Statement;
pragma Section("Test single then");
A := (if (if Foo then Foo) then Foo else B);
pragma Test_Statement;
end Test;
|
RREE/ada-util | Ada | 13,056 | adb | -----------------------------------------------------------------------
-- util-http-clients -- HTTP Clients
-- Copyright (C) 2011, 2012, 2013, 2017, 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 Ada.Unchecked_Deallocation;
with Util.Log.Loggers;
package body Util.Http.Clients is
Log : constant Util.Log.Loggers.Logger := Util.Log.Loggers.Create ("Util.Http.Clients");
procedure Initialize (Form : in out Form_Data;
Size : in Positive) is
begin
Form.Buffer.Initialize (Output => null,
Size => Size);
Form.Initialize (Form.Buffer'Unchecked_Access);
end Initialize;
-- ------------------------------
-- Returns a boolean indicating whether the named response header has already
-- been set.
-- ------------------------------
overriding
function Contains_Header (Reply : in Response;
Name : in String) return Boolean is
begin
if Reply.Delegate = null then
return False;
else
return Reply.Delegate.Contains_Header (Name);
end if;
end Contains_Header;
-- ------------------------------
-- Returns the value of the specified response header as a String. If the response
-- did not include a header of the specified name, this method returns null.
-- If there are multiple headers with the same name, this method returns the
-- first head in the request. The header name is case insensitive. You can use
-- this method with any response header.
-- ------------------------------
overriding
function Get_Header (Reply : in Response;
Name : in String) return String is
begin
if Reply.Delegate = null then
return "";
else
return Reply.Delegate.Get_Header (Name);
end if;
end Get_Header;
-- ------------------------------
-- Sets a message header with the given name and value. If the header had already
-- been set, the new value overwrites the previous one. The containsHeader
-- method can be used to test for the presence of a header before setting its value.
-- ------------------------------
overriding
procedure Set_Header (Reply : in out Response;
Name : in String;
Value : in String) is
begin
Reply.Delegate.Set_Header (Name, Value);
end Set_Header;
-- ------------------------------
-- Adds a request header with the given name and value.
-- This method allows request headers to have multiple values.
-- ------------------------------
overriding
procedure Add_Header (Reply : in out Response;
Name : in String;
Value : in String) is
begin
Reply.Delegate.Add_Header (Name, Value);
end Add_Header;
-- ------------------------------
-- Iterate over the response headers and executes the <b>Process</b> procedure.
-- ------------------------------
overriding
procedure Iterate_Headers (Reply : in Response;
Process : not null access
procedure (Name : in String;
Value : in String)) is
begin
if Reply.Delegate /= null then
Reply.Delegate.Iterate_Headers (Process);
end if;
end Iterate_Headers;
-- ------------------------------
-- Get the response body as a string.
-- ------------------------------
overriding
function Get_Body (Reply : in Response) return String is
begin
if Reply.Delegate = null then
return "";
else
return Reply.Delegate.Get_Body;
end if;
end Get_Body;
-- ------------------------------
-- Get the response status code.
-- ------------------------------
function Get_Status (Reply : in Response) return Natural is
begin
return Reply.Delegate.Get_Status;
end Get_Status;
-- ------------------------------
-- Returns a boolean indicating whether the named response header has already
-- been set.
-- ------------------------------
overriding
function Contains_Header (Request : in Client;
Name : in String) return Boolean is
begin
if Request.Delegate = null then
return False;
else
return Request.Delegate.Contains_Header (Name);
end if;
end Contains_Header;
-- ------------------------------
-- Returns the value of the specified request header as a String. If the request
-- did not include a header of the specified name, this method returns null.
-- If there are multiple headers with the same name, this method returns the
-- first head in the request. The header name is case insensitive. You can use
-- this method with any response header.
-- ------------------------------
overriding
function Get_Header (Request : in Client;
Name : in String) return String is
begin
if Request.Delegate = null then
return "";
else
return Request.Delegate.Get_Header (Name);
end if;
end Get_Header;
-- ------------------------------
-- Sets a header with the given name and value. If the header had already
-- been set, the new value overwrites the previous one. The containsHeader
-- method can be used to test for the presence of a header before setting its value.
-- ------------------------------
overriding
procedure Set_Header (Request : in out Client;
Name : in String;
Value : in String) is
begin
Request.Delegate.Set_Header (Name, Value);
end Set_Header;
-- ------------------------------
-- Adds a header with the given name and value.
-- This method allows headers to have multiple values.
-- ------------------------------
overriding
procedure Add_Header (Request : in out Client;
Name : in String;
Value : in String) is
begin
Request.Delegate.Add_Header (Name, Value);
end Add_Header;
-- ------------------------------
-- Iterate over the request headers and executes the <b>Process</b> procedure.
-- ------------------------------
overriding
procedure Iterate_Headers (Request : in Client;
Process : not null access
procedure (Name : in String;
Value : in String)) is
begin
Request.Delegate.Iterate_Headers (Process);
end Iterate_Headers;
-- ------------------------------
-- Removes all headers with the given name.
-- ------------------------------
procedure Remove_Header (Request : in out Client;
Name : in String) is
begin
null;
end Remove_Header;
-- ------------------------------
-- Initialize the client
-- ------------------------------
overriding
procedure Initialize (Http : in out Client) is
begin
Http.Delegate := null;
Http.Manager := Default_Http_Manager;
if Http.Manager = null then
Log.Error ("No HTTP manager was defined");
raise Program_Error with "No HTTP manager was defined.";
end if;
Http.Manager.Create (Http);
end Initialize;
overriding
procedure Finalize (Http : in out Client) is
procedure Free is new Ada.Unchecked_Deallocation (Http_Request'Class,
Http_Request_Access);
begin
Free (Http.Delegate);
end Finalize;
-- ------------------------------
-- Execute an http GET request on the given URL. Additional request parameters,
-- cookies and headers should have been set on the client object.
-- ------------------------------
procedure Get (Request : in out Client;
URL : in String;
Reply : out Response'Class) is
begin
Request.Manager.Do_Get (Request, URL, Reply);
end Get;
-- ------------------------------
-- Execute an http POST request on the given URL. The post data is passed in <b>Data</b>.
-- Additional request cookies and headers should have been set on the client object.
-- ------------------------------
procedure Post (Request : in out Client;
URL : in String;
Data : in String;
Reply : out Response'Class) is
begin
Request.Manager.Do_Post (Request, URL, Data, Reply);
end Post;
procedure Post (Request : in out Client;
URL : in String;
Data : in Form_Data'Class;
Reply : out Response'Class) is
begin
Request.Manager.Do_Post (Request, URL, Util.Streams.Texts.To_String (Data.Buffer), Reply);
end Post;
-- ------------------------------
-- Execute an http PUT request on the given URL. The post data is passed in <b>Data</b>.
-- Additional request cookies and headers should have been set on the client object.
-- ------------------------------
procedure Put (Request : in out Client;
URL : in String;
Data : in String;
Reply : out Response'Class) is
begin
Request.Manager.Do_Put (Request, URL, Data, Reply);
end Put;
-- ------------------------------
-- Execute an http PATCH request on the given URL. The post data is passed in <b>Data</b>.
-- Additional request cookies and headers should have been set on the client object.
-- ------------------------------
procedure Patch (Request : in out Client;
URL : in String;
Data : in String;
Reply : out Response'Class) is
begin
Request.Manager.Do_Patch (Request, URL, Data, Reply);
end Patch;
-- ------------------------------
-- Execute a http DELETE request on the given URL.
-- ------------------------------
procedure Delete (Request : in out Client;
URL : in String;
Reply : out Response'Class) is
begin
Request.Manager.Do_Delete (Request, URL, Reply);
end Delete;
-- ------------------------------
-- Execute an http HEAD request on the given URL. Additional request parameters,
-- cookies and headers should have been set on the client object.
-- ------------------------------
procedure Head (Request : in out Client;
URL : in String;
Reply : out Response'Class) is
begin
Request.Manager.Do_Head (Request, URL, Reply);
end Head;
-- ------------------------------
-- Execute an http OPTIONS request on the given URL. Additional request parameters,
-- cookies and headers should have been set on the client object.
-- ------------------------------
procedure Options (Request : in out Client;
URL : in String;
Reply : out Response'Class) is
begin
Request.Manager.Do_Options (Request, URL, Reply);
end Options;
-- ------------------------------
-- Set the timeout for the connection.
-- ------------------------------
procedure Set_Timeout (Request : in out Client;
Timeout : in Duration) is
begin
Request.Manager.Set_Timeout (Request, Timeout);
end Set_Timeout;
-- ------------------------------
-- Adds the specified cookie to the request. This method can be called multiple
-- times to set more than one cookie.
-- ------------------------------
procedure Add_Cookie (Http : in out Client;
Cookie : in Util.Http.Cookies.Cookie) is
begin
null;
end Add_Cookie;
-- ------------------------------
-- Free the resource used by the response.
-- ------------------------------
overriding
procedure Finalize (Reply : in out Response) is
procedure Free is new Ada.Unchecked_Deallocation (Http_Response'Class,
Http_Response_Access);
begin
Free (Reply.Delegate);
end Finalize;
end Util.Http.Clients;
|
stcarrez/ada-util | Ada | 1,108 | ads | -----------------------------------------------------------------------
-- util-nullables-tests - Test for nullables types
-- Copyright (C) 2021 Stephane Carrez
-- Written by Stephane Carrez ([email protected])
--
-- Licensed under the Apache License, Version 2.0 (the "License");
-- you may not use this file except in compliance with the License.
-- You may obtain a copy of the License at
--
-- http://www.apache.org/licenses/LICENSE-2.0
--
-- Unless required by applicable law or agreed to in writing, software
-- distributed under the License is distributed on an "AS IS" BASIS,
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-- See the License for the specific language governing permissions and
-- limitations under the License.
-----------------------------------------------------------------------
with Util.Tests;
package Util.Nullables.Tests is
procedure Add_Tests (Suite : in Util.Tests.Access_Test_Suite);
type Test is new Util.Tests.Test with null record;
procedure Test_Nullables (T : in out Test);
end Util.Nullables.Tests;
|
faelys/natools | Ada | 8,376 | adb | ------------------------------------------------------------------------------
-- Copyright (c) 2015-2017, Natacha Porté --
-- --
-- Permission to use, copy, modify, and distribute this software for any --
-- purpose with or without fee is hereby granted, provided that the above --
-- copyright notice and this permission notice appear in all copies. --
-- --
-- THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES --
-- WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF --
-- MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR --
-- ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES --
-- WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN --
-- ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF --
-- OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. --
------------------------------------------------------------------------------
with Ada.Characters.Handling;
with Ada.Strings.Fixed;
with Natools.Static_Maps.S_Expressions.Conditionals.Strings;
package body Natools.S_Expressions.Conditionals.Strings is
package Fixed renames Ada.Strings.Fixed;
function Conditional_On_Atoms
(Context : in Strings.Context;
Arguments : in out Lockable.Descriptor'Class;
Element : access function (Context : in Strings.Context;
Data : in Atom)
return Boolean;
Conjunction : in Boolean)
return Boolean;
-- Evaluate Element on all atoms of Arguments and combine them
function Contains (Context : in Strings.Context; Data : in Atom)
return Boolean;
-- Check whether Context contains Data
function Is_Equal_To (Context : in Strings.Context; Data : in Atom)
return Boolean;
-- Check whether Context is equal to Data
function Is_Prefix (Context : in Strings.Context; Data : in Atom)
return Boolean;
-- Check whether Context starts with Data
function To_Lower (Item : in Character) return Character
renames Ada.Characters.Handling.To_Lower;
-- Clearer name for lower case translation, used for case-insentivity
------------------------------
-- Local Helper Subprograms --
------------------------------
function Conditional_On_Atoms
(Context : in Strings.Context;
Arguments : in out Lockable.Descriptor'Class;
Element : access function (Context : in Strings.Context;
Data : in Atom)
return Boolean;
Conjunction : in Boolean)
return Boolean
is
Result : Boolean := not Conjunction;
Event : Events.Event := Arguments.Current_Event;
begin
while Event = Events.Add_Atom loop
Result := Element.all (Context, Arguments.Current_Atom);
exit when Result /= Conjunction;
Arguments.Next (Event);
end loop;
return Result;
end Conditional_On_Atoms;
function Contains (Context : in Strings.Context; Data : in Atom)
return Boolean
is
Str_Value : String := To_String (Data);
begin
if Context.Settings.Case_Sensitive then
return Fixed.Index
(Context.Data.all,
Str_Value,
Str_Value'First,
Ada.Strings.Forward) > 0;
else
Fixed.Translate (Str_Value, To_Lower'Access);
return Fixed.Index
(Context.Data.all,
Str_Value,
Str_Value'First,
Ada.Strings.Forward,
Ada.Characters.Handling.To_Lower'Access) > 0;
end if;
end Contains;
function Is_Equal_To (Context : in Strings.Context; Data : in Atom)
return Boolean is
begin
if Context.Data.all'Length /= Data'Length then
return False;
end if;
if Context.Settings.Case_Sensitive then
return Context.Data.all = To_String (Data);
else
return Fixed.Translate (Context.Data.all, To_Lower'Access)
= Fixed.Translate (To_String (Data), To_Lower'Access);
end if;
end Is_Equal_To;
function Is_Prefix (Context : in Strings.Context; Data : in Atom)
return Boolean is
begin
if Context.Data.all'Length < Data'Length then
return False;
end if;
declare
Prefix : String renames Context.Data.all
(Context.Data.all'First
.. Context.Data.all'First + Data'Length - 1);
begin
if Context.Settings.Case_Sensitive then
return Prefix = To_String (Data);
else
return Fixed.Translate (Prefix, To_Lower'Access)
= Fixed.Translate (To_String (Data), To_Lower'Access);
end if;
end;
end Is_Prefix;
---------------------------
-- Evaluation Primitives --
---------------------------
function Parametric_Evaluate
(Context : in Strings.Context;
Name : in Atom;
Arguments : in out Lockable.Descriptor'Class)
return Boolean
is
use Natools.Static_Maps.S_Expressions.Conditionals.Strings;
begin
case To_Parametric (To_String (Name)) is
when Unknown_Parametric_Condition =>
if Context.Parametric_Fallback /= null then
return Context.Parametric_Fallback
(Context.Settings, Name, Arguments);
else
raise Constraint_Error with "Unknown parametric condition """
& To_String (Name) & '"';
end if;
when Case_Insensitive =>
declare
New_Context : Strings.Context := Context;
begin
New_Context.Settings.Case_Sensitive := False;
return Evaluate (New_Context, Arguments);
end;
when Case_Sensitive =>
declare
New_Context : Strings.Context := Context;
begin
New_Context.Settings.Case_Sensitive := True;
return Evaluate (New_Context, Arguments);
end;
when Contains_All =>
return Conditional_On_Atoms
(Context, Arguments, Contains'Access, True);
when Contains_Any =>
return Conditional_On_Atoms
(Context, Arguments, Contains'Access, False);
when Is_Equal_To =>
return Conditional_On_Atoms
(Context, Arguments, Is_Equal_To'Access, False);
when Starts_With =>
return Conditional_On_Atoms
(Context, Arguments, Is_Prefix'Access, False);
end case;
end Parametric_Evaluate;
function Simple_Evaluate
(Context : in Strings.Context;
Name : in Atom)
return Boolean
is
use Natools.Static_Maps.S_Expressions.Conditionals.Strings;
begin
case To_Simple (To_String (Name)) is
when Unknown_Simple_Condition =>
if Context.Parametric_Fallback /= null then
return Context.Simple_Fallback (Context.Settings, Name);
else
raise Constraint_Error with "Unknown simple condition """
& To_String (Name) & '"';
end if;
when Is_ASCII =>
for I in Context.Data.all'Range loop
if Context.Data (I)
not in Character'Val (0) .. Character'Val (127)
then
return False;
end if;
end loop;
return True;
when Is_Empty =>
return Context.Data.all'Length = 0;
end case;
end Simple_Evaluate;
--------------------------
-- Evaluation Shortcuts --
--------------------------
function Evaluate
(Text : in String;
Expression : in out Lockable.Descriptor'Class)
return Boolean
is
Aliased_Text : aliased constant String := Text;
Context : constant Strings.Context
:= (Data => Aliased_Text'Access,
Parametric_Fallback => null,
Simple_Fallback => null,
Settings => <>);
begin
return Evaluate (Context, Expression);
end Evaluate;
end Natools.S_Expressions.Conditionals.Strings;
|
persan/AUnit-addons | Ada | 118 | ads | with AUnit.Test_Cases.Simple_Main_Generic;
procedure Tc.Main is new AUnit.Test_Cases.Simple_Main_Generic (Test_Case);
|
ekoeppen/STM32_Generic_Ada_Drivers | Ada | 34,443 | ads | -- This spec has been automatically generated from STM32F030.svd
pragma Restrictions (No_Elaboration_Code);
pragma Ada_2012;
pragma Style_Checks (Off);
with System;
package STM32_SVD.RCC is
pragma Preelaborate;
---------------
-- Registers --
---------------
subtype CR_HSION_Field is STM32_SVD.Bit;
subtype CR_HSIRDY_Field is STM32_SVD.Bit;
subtype CR_HSITRIM_Field is STM32_SVD.UInt5;
subtype CR_HSICAL_Field is STM32_SVD.Byte;
subtype CR_HSEON_Field is STM32_SVD.Bit;
subtype CR_HSERDY_Field is STM32_SVD.Bit;
subtype CR_HSEBYP_Field is STM32_SVD.Bit;
subtype CR_CSSON_Field is STM32_SVD.Bit;
subtype CR_PLLON_Field is STM32_SVD.Bit;
subtype CR_PLLRDY_Field is STM32_SVD.Bit;
-- Clock control register
type CR_Register is record
-- Internal High Speed clock enable
HSION : CR_HSION_Field := 16#1#;
-- Read-only. Internal High Speed clock ready flag
HSIRDY : CR_HSIRDY_Field := 16#1#;
-- unspecified
Reserved_2_2 : STM32_SVD.Bit := 16#0#;
-- Internal High Speed clock trimming
HSITRIM : CR_HSITRIM_Field := 16#10#;
-- Read-only. Internal High Speed clock Calibration
HSICAL : CR_HSICAL_Field := 16#0#;
-- External High Speed clock enable
HSEON : CR_HSEON_Field := 16#0#;
-- Read-only. External High Speed clock ready flag
HSERDY : CR_HSERDY_Field := 16#0#;
-- External High Speed clock Bypass
HSEBYP : CR_HSEBYP_Field := 16#0#;
-- Clock Security System enable
CSSON : CR_CSSON_Field := 16#0#;
-- unspecified
Reserved_20_23 : STM32_SVD.UInt4 := 16#0#;
-- PLL enable
PLLON : CR_PLLON_Field := 16#0#;
-- Read-only. PLL clock ready flag
PLLRDY : CR_PLLRDY_Field := 16#0#;
-- unspecified
Reserved_26_31 : STM32_SVD.UInt6 := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for CR_Register use record
HSION at 0 range 0 .. 0;
HSIRDY at 0 range 1 .. 1;
Reserved_2_2 at 0 range 2 .. 2;
HSITRIM at 0 range 3 .. 7;
HSICAL at 0 range 8 .. 15;
HSEON at 0 range 16 .. 16;
HSERDY at 0 range 17 .. 17;
HSEBYP at 0 range 18 .. 18;
CSSON at 0 range 19 .. 19;
Reserved_20_23 at 0 range 20 .. 23;
PLLON at 0 range 24 .. 24;
PLLRDY at 0 range 25 .. 25;
Reserved_26_31 at 0 range 26 .. 31;
end record;
subtype CFGR_SW_Field is STM32_SVD.UInt2;
subtype CFGR_SWS_Field is STM32_SVD.UInt2;
subtype CFGR_HPRE_Field is STM32_SVD.UInt4;
subtype CFGR_PPRE_Field is STM32_SVD.UInt3;
subtype CFGR_ADCPRE_Field is STM32_SVD.Bit;
subtype CFGR_PLLSRC_Field is STM32_SVD.UInt2;
subtype CFGR_PLLXTPRE_Field is STM32_SVD.Bit;
subtype CFGR_PLLMUL_Field is STM32_SVD.UInt4;
subtype CFGR_MCO_Field is STM32_SVD.UInt3;
subtype CFGR_MCOPRE_Field is STM32_SVD.UInt3;
subtype CFGR_PLLNODIV_Field is STM32_SVD.Bit;
-- Clock configuration register (RCC_CFGR)
type CFGR_Register is record
-- System clock Switch
SW : CFGR_SW_Field := 16#0#;
-- Read-only. System Clock Switch Status
SWS : CFGR_SWS_Field := 16#0#;
-- AHB prescaler
HPRE : CFGR_HPRE_Field := 16#0#;
-- APB Low speed prescaler (APB1)
PPRE : CFGR_PPRE_Field := 16#0#;
-- unspecified
Reserved_11_13 : STM32_SVD.UInt3 := 16#0#;
-- ADC prescaler
ADCPRE : CFGR_ADCPRE_Field := 16#0#;
-- PLL input clock source
PLLSRC : CFGR_PLLSRC_Field := 16#0#;
-- HSE divider for PLL entry
PLLXTPRE : CFGR_PLLXTPRE_Field := 16#0#;
-- PLL Multiplication Factor
PLLMUL : CFGR_PLLMUL_Field := 16#0#;
-- unspecified
Reserved_22_23 : STM32_SVD.UInt2 := 16#0#;
-- Microcontroller clock output
MCO : CFGR_MCO_Field := 16#0#;
-- unspecified
Reserved_27_27 : STM32_SVD.Bit := 16#0#;
-- Microcontroller Clock Output Prescaler
MCOPRE : CFGR_MCOPRE_Field := 16#0#;
-- PLL clock not divided for MCO
PLLNODIV : CFGR_PLLNODIV_Field := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for CFGR_Register use record
SW at 0 range 0 .. 1;
SWS at 0 range 2 .. 3;
HPRE at 0 range 4 .. 7;
PPRE at 0 range 8 .. 10;
Reserved_11_13 at 0 range 11 .. 13;
ADCPRE at 0 range 14 .. 14;
PLLSRC at 0 range 15 .. 16;
PLLXTPRE at 0 range 17 .. 17;
PLLMUL at 0 range 18 .. 21;
Reserved_22_23 at 0 range 22 .. 23;
MCO at 0 range 24 .. 26;
Reserved_27_27 at 0 range 27 .. 27;
MCOPRE at 0 range 28 .. 30;
PLLNODIV at 0 range 31 .. 31;
end record;
subtype CIR_LSIRDYF_Field is STM32_SVD.Bit;
subtype CIR_LSERDYF_Field is STM32_SVD.Bit;
subtype CIR_HSIRDYF_Field is STM32_SVD.Bit;
subtype CIR_HSERDYF_Field is STM32_SVD.Bit;
subtype CIR_PLLRDYF_Field is STM32_SVD.Bit;
subtype CIR_HSI14RDYF_Field is STM32_SVD.Bit;
subtype CIR_HSI48RDYF_Field is STM32_SVD.Bit;
subtype CIR_CSSF_Field is STM32_SVD.Bit;
subtype CIR_LSIRDYIE_Field is STM32_SVD.Bit;
subtype CIR_LSERDYIE_Field is STM32_SVD.Bit;
subtype CIR_HSIRDYIE_Field is STM32_SVD.Bit;
subtype CIR_HSERDYIE_Field is STM32_SVD.Bit;
subtype CIR_PLLRDYIE_Field is STM32_SVD.Bit;
subtype CIR_HSI14RDYE_Field is STM32_SVD.Bit;
subtype CIR_HSI48RDYIE_Field is STM32_SVD.Bit;
subtype CIR_LSIRDYC_Field is STM32_SVD.Bit;
subtype CIR_LSERDYC_Field is STM32_SVD.Bit;
subtype CIR_HSIRDYC_Field is STM32_SVD.Bit;
subtype CIR_HSERDYC_Field is STM32_SVD.Bit;
subtype CIR_PLLRDYC_Field is STM32_SVD.Bit;
subtype CIR_HSI14RDYC_Field is STM32_SVD.Bit;
subtype CIR_HSI48RDYC_Field is STM32_SVD.Bit;
subtype CIR_CSSC_Field is STM32_SVD.Bit;
-- Clock interrupt register (RCC_CIR)
type CIR_Register is record
-- Read-only. LSI Ready Interrupt flag
LSIRDYF : CIR_LSIRDYF_Field := 16#0#;
-- Read-only. LSE Ready Interrupt flag
LSERDYF : CIR_LSERDYF_Field := 16#0#;
-- Read-only. HSI Ready Interrupt flag
HSIRDYF : CIR_HSIRDYF_Field := 16#0#;
-- Read-only. HSE Ready Interrupt flag
HSERDYF : CIR_HSERDYF_Field := 16#0#;
-- Read-only. PLL Ready Interrupt flag
PLLRDYF : CIR_PLLRDYF_Field := 16#0#;
-- Read-only. HSI14 ready interrupt flag
HSI14RDYF : CIR_HSI14RDYF_Field := 16#0#;
-- Read-only. HSI48 ready interrupt flag
HSI48RDYF : CIR_HSI48RDYF_Field := 16#0#;
-- Read-only. Clock Security System Interrupt flag
CSSF : CIR_CSSF_Field := 16#0#;
-- LSI Ready Interrupt Enable
LSIRDYIE : CIR_LSIRDYIE_Field := 16#0#;
-- LSE Ready Interrupt Enable
LSERDYIE : CIR_LSERDYIE_Field := 16#0#;
-- HSI Ready Interrupt Enable
HSIRDYIE : CIR_HSIRDYIE_Field := 16#0#;
-- HSE Ready Interrupt Enable
HSERDYIE : CIR_HSERDYIE_Field := 16#0#;
-- PLL Ready Interrupt Enable
PLLRDYIE : CIR_PLLRDYIE_Field := 16#0#;
-- HSI14 ready interrupt enable
HSI14RDYE : CIR_HSI14RDYE_Field := 16#0#;
-- HSI48 ready interrupt enable
HSI48RDYIE : CIR_HSI48RDYIE_Field := 16#0#;
-- unspecified
Reserved_15_15 : STM32_SVD.Bit := 16#0#;
-- Write-only. LSI Ready Interrupt Clear
LSIRDYC : CIR_LSIRDYC_Field := 16#0#;
-- Write-only. LSE Ready Interrupt Clear
LSERDYC : CIR_LSERDYC_Field := 16#0#;
-- Write-only. HSI Ready Interrupt Clear
HSIRDYC : CIR_HSIRDYC_Field := 16#0#;
-- Write-only. HSE Ready Interrupt Clear
HSERDYC : CIR_HSERDYC_Field := 16#0#;
-- Write-only. PLL Ready Interrupt Clear
PLLRDYC : CIR_PLLRDYC_Field := 16#0#;
-- Write-only. HSI 14 MHz Ready Interrupt Clear
HSI14RDYC : CIR_HSI14RDYC_Field := 16#0#;
-- Write-only. HSI48 Ready Interrupt Clear
HSI48RDYC : CIR_HSI48RDYC_Field := 16#0#;
-- Write-only. Clock security system interrupt clear
CSSC : CIR_CSSC_Field := 16#0#;
-- unspecified
Reserved_24_31 : STM32_SVD.Byte := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for CIR_Register use record
LSIRDYF at 0 range 0 .. 0;
LSERDYF at 0 range 1 .. 1;
HSIRDYF at 0 range 2 .. 2;
HSERDYF at 0 range 3 .. 3;
PLLRDYF at 0 range 4 .. 4;
HSI14RDYF at 0 range 5 .. 5;
HSI48RDYF at 0 range 6 .. 6;
CSSF at 0 range 7 .. 7;
LSIRDYIE at 0 range 8 .. 8;
LSERDYIE at 0 range 9 .. 9;
HSIRDYIE at 0 range 10 .. 10;
HSERDYIE at 0 range 11 .. 11;
PLLRDYIE at 0 range 12 .. 12;
HSI14RDYE at 0 range 13 .. 13;
HSI48RDYIE at 0 range 14 .. 14;
Reserved_15_15 at 0 range 15 .. 15;
LSIRDYC at 0 range 16 .. 16;
LSERDYC at 0 range 17 .. 17;
HSIRDYC at 0 range 18 .. 18;
HSERDYC at 0 range 19 .. 19;
PLLRDYC at 0 range 20 .. 20;
HSI14RDYC at 0 range 21 .. 21;
HSI48RDYC at 0 range 22 .. 22;
CSSC at 0 range 23 .. 23;
Reserved_24_31 at 0 range 24 .. 31;
end record;
subtype APB2RSTR_SYSCFGRST_Field is STM32_SVD.Bit;
subtype APB2RSTR_ADCRST_Field is STM32_SVD.Bit;
subtype APB2RSTR_TIM1RST_Field is STM32_SVD.Bit;
subtype APB2RSTR_SPI1RST_Field is STM32_SVD.Bit;
subtype APB2RSTR_USART1RST_Field is STM32_SVD.Bit;
subtype APB2RSTR_TIM15RST_Field is STM32_SVD.Bit;
subtype APB2RSTR_TIM16RST_Field is STM32_SVD.Bit;
subtype APB2RSTR_TIM17RST_Field is STM32_SVD.Bit;
subtype APB2RSTR_DBGMCURST_Field is STM32_SVD.Bit;
-- APB2 peripheral reset register (RCC_APB2RSTR)
type APB2RSTR_Register is record
-- SYSCFG and COMP reset
SYSCFGRST : APB2RSTR_SYSCFGRST_Field := 16#0#;
-- unspecified
Reserved_1_8 : STM32_SVD.Byte := 16#0#;
-- ADC interface reset
ADCRST : APB2RSTR_ADCRST_Field := 16#0#;
-- unspecified
Reserved_10_10 : STM32_SVD.Bit := 16#0#;
-- TIM1 timer reset
TIM1RST : APB2RSTR_TIM1RST_Field := 16#0#;
-- SPI 1 reset
SPI1RST : APB2RSTR_SPI1RST_Field := 16#0#;
-- unspecified
Reserved_13_13 : STM32_SVD.Bit := 16#0#;
-- USART1 reset
USART1RST : APB2RSTR_USART1RST_Field := 16#0#;
-- unspecified
Reserved_15_15 : STM32_SVD.Bit := 16#0#;
-- TIM15 timer reset
TIM15RST : APB2RSTR_TIM15RST_Field := 16#0#;
-- TIM16 timer reset
TIM16RST : APB2RSTR_TIM16RST_Field := 16#0#;
-- TIM17 timer reset
TIM17RST : APB2RSTR_TIM17RST_Field := 16#0#;
-- unspecified
Reserved_19_21 : STM32_SVD.UInt3 := 16#0#;
-- Debug MCU reset
DBGMCURST : APB2RSTR_DBGMCURST_Field := 16#0#;
-- unspecified
Reserved_23_31 : STM32_SVD.UInt9 := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for APB2RSTR_Register use record
SYSCFGRST at 0 range 0 .. 0;
Reserved_1_8 at 0 range 1 .. 8;
ADCRST at 0 range 9 .. 9;
Reserved_10_10 at 0 range 10 .. 10;
TIM1RST at 0 range 11 .. 11;
SPI1RST at 0 range 12 .. 12;
Reserved_13_13 at 0 range 13 .. 13;
USART1RST at 0 range 14 .. 14;
Reserved_15_15 at 0 range 15 .. 15;
TIM15RST at 0 range 16 .. 16;
TIM16RST at 0 range 17 .. 17;
TIM17RST at 0 range 18 .. 18;
Reserved_19_21 at 0 range 19 .. 21;
DBGMCURST at 0 range 22 .. 22;
Reserved_23_31 at 0 range 23 .. 31;
end record;
subtype APB1RSTR_TIM3RST_Field is STM32_SVD.Bit;
subtype APB1RSTR_TIM6RST_Field is STM32_SVD.Bit;
subtype APB1RSTR_TIM14RST_Field is STM32_SVD.Bit;
subtype APB1RSTR_WWDGRST_Field is STM32_SVD.Bit;
subtype APB1RSTR_SPI2RST_Field is STM32_SVD.Bit;
subtype APB1RSTR_USART2RST_Field is STM32_SVD.Bit;
subtype APB1RSTR_I2C1RST_Field is STM32_SVD.Bit;
subtype APB1RSTR_I2C2RST_Field is STM32_SVD.Bit;
subtype APB1RSTR_PWRRST_Field is STM32_SVD.Bit;
-- APB1 peripheral reset register (RCC_APB1RSTR)
type APB1RSTR_Register is record
-- unspecified
Reserved_0_0 : STM32_SVD.Bit := 16#0#;
-- Timer 3 reset
TIM3RST : APB1RSTR_TIM3RST_Field := 16#0#;
-- unspecified
Reserved_2_3 : STM32_SVD.UInt2 := 16#0#;
-- Timer 6 reset
TIM6RST : APB1RSTR_TIM6RST_Field := 16#0#;
-- unspecified
Reserved_5_7 : STM32_SVD.UInt3 := 16#0#;
-- Timer 14 reset
TIM14RST : APB1RSTR_TIM14RST_Field := 16#0#;
-- unspecified
Reserved_9_10 : STM32_SVD.UInt2 := 16#0#;
-- Window watchdog reset
WWDGRST : APB1RSTR_WWDGRST_Field := 16#0#;
-- unspecified
Reserved_12_13 : STM32_SVD.UInt2 := 16#0#;
-- SPI2 reset
SPI2RST : APB1RSTR_SPI2RST_Field := 16#0#;
-- unspecified
Reserved_15_16 : STM32_SVD.UInt2 := 16#0#;
-- USART 2 reset
USART2RST : APB1RSTR_USART2RST_Field := 16#0#;
-- unspecified
Reserved_18_20 : STM32_SVD.UInt3 := 16#0#;
-- I2C1 reset
I2C1RST : APB1RSTR_I2C1RST_Field := 16#0#;
-- I2C2 reset
I2C2RST : APB1RSTR_I2C2RST_Field := 16#0#;
-- unspecified
Reserved_23_27 : STM32_SVD.UInt5 := 16#0#;
-- Power interface reset
PWRRST : APB1RSTR_PWRRST_Field := 16#0#;
-- unspecified
Reserved_29_31 : STM32_SVD.UInt3 := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for APB1RSTR_Register use record
Reserved_0_0 at 0 range 0 .. 0;
TIM3RST at 0 range 1 .. 1;
Reserved_2_3 at 0 range 2 .. 3;
TIM6RST at 0 range 4 .. 4;
Reserved_5_7 at 0 range 5 .. 7;
TIM14RST at 0 range 8 .. 8;
Reserved_9_10 at 0 range 9 .. 10;
WWDGRST at 0 range 11 .. 11;
Reserved_12_13 at 0 range 12 .. 13;
SPI2RST at 0 range 14 .. 14;
Reserved_15_16 at 0 range 15 .. 16;
USART2RST at 0 range 17 .. 17;
Reserved_18_20 at 0 range 18 .. 20;
I2C1RST at 0 range 21 .. 21;
I2C2RST at 0 range 22 .. 22;
Reserved_23_27 at 0 range 23 .. 27;
PWRRST at 0 range 28 .. 28;
Reserved_29_31 at 0 range 29 .. 31;
end record;
subtype AHBENR_DMAEN_Field is STM32_SVD.Bit;
subtype AHBENR_SRAMEN_Field is STM32_SVD.Bit;
subtype AHBENR_FLITFEN_Field is STM32_SVD.Bit;
subtype AHBENR_CRCEN_Field is STM32_SVD.Bit;
subtype AHBENR_IOPAEN_Field is STM32_SVD.Bit;
subtype AHBENR_IOPBEN_Field is STM32_SVD.Bit;
subtype AHBENR_IOPCEN_Field is STM32_SVD.Bit;
subtype AHBENR_IOPDEN_Field is STM32_SVD.Bit;
subtype AHBENR_IOPFEN_Field is STM32_SVD.Bit;
-- AHB Peripheral Clock enable register (RCC_AHBENR)
type AHBENR_Register is record
-- DMA1 clock enable
DMAEN : AHBENR_DMAEN_Field := 16#0#;
-- unspecified
Reserved_1_1 : STM32_SVD.Bit := 16#0#;
-- SRAM interface clock enable
SRAMEN : AHBENR_SRAMEN_Field := 16#1#;
-- unspecified
Reserved_3_3 : STM32_SVD.Bit := 16#0#;
-- FLITF clock enable
FLITFEN : AHBENR_FLITFEN_Field := 16#1#;
-- unspecified
Reserved_5_5 : STM32_SVD.Bit := 16#0#;
-- CRC clock enable
CRCEN : AHBENR_CRCEN_Field := 16#0#;
-- unspecified
Reserved_7_16 : STM32_SVD.UInt10 := 16#0#;
-- I/O port A clock enable
IOPAEN : AHBENR_IOPAEN_Field := 16#0#;
-- I/O port B clock enable
IOPBEN : AHBENR_IOPBEN_Field := 16#0#;
-- I/O port C clock enable
IOPCEN : AHBENR_IOPCEN_Field := 16#0#;
-- I/O port D clock enable
IOPDEN : AHBENR_IOPDEN_Field := 16#0#;
-- unspecified
Reserved_21_21 : STM32_SVD.Bit := 16#0#;
-- I/O port F clock enable
IOPFEN : AHBENR_IOPFEN_Field := 16#0#;
-- unspecified
Reserved_23_31 : STM32_SVD.UInt9 := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for AHBENR_Register use record
DMAEN at 0 range 0 .. 0;
Reserved_1_1 at 0 range 1 .. 1;
SRAMEN at 0 range 2 .. 2;
Reserved_3_3 at 0 range 3 .. 3;
FLITFEN at 0 range 4 .. 4;
Reserved_5_5 at 0 range 5 .. 5;
CRCEN at 0 range 6 .. 6;
Reserved_7_16 at 0 range 7 .. 16;
IOPAEN at 0 range 17 .. 17;
IOPBEN at 0 range 18 .. 18;
IOPCEN at 0 range 19 .. 19;
IOPDEN at 0 range 20 .. 20;
Reserved_21_21 at 0 range 21 .. 21;
IOPFEN at 0 range 22 .. 22;
Reserved_23_31 at 0 range 23 .. 31;
end record;
subtype APB2ENR_SYSCFGEN_Field is STM32_SVD.Bit;
subtype APB2ENR_ADCEN_Field is STM32_SVD.Bit;
subtype APB2ENR_TIM1EN_Field is STM32_SVD.Bit;
subtype APB2ENR_SPI1EN_Field is STM32_SVD.Bit;
subtype APB2ENR_USART1EN_Field is STM32_SVD.Bit;
subtype APB2ENR_TIM15EN_Field is STM32_SVD.Bit;
subtype APB2ENR_TIM16EN_Field is STM32_SVD.Bit;
subtype APB2ENR_TIM17EN_Field is STM32_SVD.Bit;
subtype APB2ENR_DBGMCUEN_Field is STM32_SVD.Bit;
-- APB2 peripheral clock enable register (RCC_APB2ENR)
type APB2ENR_Register is record
-- SYSCFG clock enable
SYSCFGEN : APB2ENR_SYSCFGEN_Field := 16#0#;
-- unspecified
Reserved_1_8 : STM32_SVD.Byte := 16#0#;
-- ADC 1 interface clock enable
ADCEN : APB2ENR_ADCEN_Field := 16#0#;
-- unspecified
Reserved_10_10 : STM32_SVD.Bit := 16#0#;
-- TIM1 Timer clock enable
TIM1EN : APB2ENR_TIM1EN_Field := 16#0#;
-- SPI 1 clock enable
SPI1EN : APB2ENR_SPI1EN_Field := 16#0#;
-- unspecified
Reserved_13_13 : STM32_SVD.Bit := 16#0#;
-- USART1 clock enable
USART1EN : APB2ENR_USART1EN_Field := 16#0#;
-- unspecified
Reserved_15_15 : STM32_SVD.Bit := 16#0#;
-- TIM15 timer clock enable
TIM15EN : APB2ENR_TIM15EN_Field := 16#0#;
-- TIM16 timer clock enable
TIM16EN : APB2ENR_TIM16EN_Field := 16#0#;
-- TIM17 timer clock enable
TIM17EN : APB2ENR_TIM17EN_Field := 16#0#;
-- unspecified
Reserved_19_21 : STM32_SVD.UInt3 := 16#0#;
-- MCU debug module clock enable
DBGMCUEN : APB2ENR_DBGMCUEN_Field := 16#0#;
-- unspecified
Reserved_23_31 : STM32_SVD.UInt9 := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for APB2ENR_Register use record
SYSCFGEN at 0 range 0 .. 0;
Reserved_1_8 at 0 range 1 .. 8;
ADCEN at 0 range 9 .. 9;
Reserved_10_10 at 0 range 10 .. 10;
TIM1EN at 0 range 11 .. 11;
SPI1EN at 0 range 12 .. 12;
Reserved_13_13 at 0 range 13 .. 13;
USART1EN at 0 range 14 .. 14;
Reserved_15_15 at 0 range 15 .. 15;
TIM15EN at 0 range 16 .. 16;
TIM16EN at 0 range 17 .. 17;
TIM17EN at 0 range 18 .. 18;
Reserved_19_21 at 0 range 19 .. 21;
DBGMCUEN at 0 range 22 .. 22;
Reserved_23_31 at 0 range 23 .. 31;
end record;
subtype APB1ENR_TIM3EN_Field is STM32_SVD.Bit;
subtype APB1ENR_TIM6EN_Field is STM32_SVD.Bit;
subtype APB1ENR_TIM14EN_Field is STM32_SVD.Bit;
subtype APB1ENR_WWDGEN_Field is STM32_SVD.Bit;
subtype APB1ENR_SPI2EN_Field is STM32_SVD.Bit;
subtype APB1ENR_USART2EN_Field is STM32_SVD.Bit;
subtype APB1ENR_I2C1EN_Field is STM32_SVD.Bit;
subtype APB1ENR_I2C2EN_Field is STM32_SVD.Bit;
subtype APB1ENR_PWREN_Field is STM32_SVD.Bit;
-- APB1 peripheral clock enable register (RCC_APB1ENR)
type APB1ENR_Register is record
-- unspecified
Reserved_0_0 : STM32_SVD.Bit := 16#0#;
-- Timer 3 clock enable
TIM3EN : APB1ENR_TIM3EN_Field := 16#0#;
-- unspecified
Reserved_2_3 : STM32_SVD.UInt2 := 16#0#;
-- Timer 6 clock enable
TIM6EN : APB1ENR_TIM6EN_Field := 16#0#;
-- unspecified
Reserved_5_7 : STM32_SVD.UInt3 := 16#0#;
-- Timer 14 clock enable
TIM14EN : APB1ENR_TIM14EN_Field := 16#0#;
-- unspecified
Reserved_9_10 : STM32_SVD.UInt2 := 16#0#;
-- Window watchdog clock enable
WWDGEN : APB1ENR_WWDGEN_Field := 16#0#;
-- unspecified
Reserved_12_13 : STM32_SVD.UInt2 := 16#0#;
-- SPI 2 clock enable
SPI2EN : APB1ENR_SPI2EN_Field := 16#0#;
-- unspecified
Reserved_15_16 : STM32_SVD.UInt2 := 16#0#;
-- USART 2 clock enable
USART2EN : APB1ENR_USART2EN_Field := 16#0#;
-- unspecified
Reserved_18_20 : STM32_SVD.UInt3 := 16#0#;
-- I2C 1 clock enable
I2C1EN : APB1ENR_I2C1EN_Field := 16#0#;
-- I2C 2 clock enable
I2C2EN : APB1ENR_I2C2EN_Field := 16#0#;
-- unspecified
Reserved_23_27 : STM32_SVD.UInt5 := 16#0#;
-- Power interface clock enable
PWREN : APB1ENR_PWREN_Field := 16#0#;
-- unspecified
Reserved_29_31 : STM32_SVD.UInt3 := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for APB1ENR_Register use record
Reserved_0_0 at 0 range 0 .. 0;
TIM3EN at 0 range 1 .. 1;
Reserved_2_3 at 0 range 2 .. 3;
TIM6EN at 0 range 4 .. 4;
Reserved_5_7 at 0 range 5 .. 7;
TIM14EN at 0 range 8 .. 8;
Reserved_9_10 at 0 range 9 .. 10;
WWDGEN at 0 range 11 .. 11;
Reserved_12_13 at 0 range 12 .. 13;
SPI2EN at 0 range 14 .. 14;
Reserved_15_16 at 0 range 15 .. 16;
USART2EN at 0 range 17 .. 17;
Reserved_18_20 at 0 range 18 .. 20;
I2C1EN at 0 range 21 .. 21;
I2C2EN at 0 range 22 .. 22;
Reserved_23_27 at 0 range 23 .. 27;
PWREN at 0 range 28 .. 28;
Reserved_29_31 at 0 range 29 .. 31;
end record;
subtype BDCR_LSEON_Field is STM32_SVD.Bit;
subtype BDCR_LSERDY_Field is STM32_SVD.Bit;
subtype BDCR_LSEBYP_Field is STM32_SVD.Bit;
subtype BDCR_LSEDRV_Field is STM32_SVD.UInt2;
subtype BDCR_RTCSEL_Field is STM32_SVD.UInt2;
subtype BDCR_RTCEN_Field is STM32_SVD.Bit;
subtype BDCR_BDRST_Field is STM32_SVD.Bit;
-- Backup domain control register (RCC_BDCR)
type BDCR_Register is record
-- External Low Speed oscillator enable
LSEON : BDCR_LSEON_Field := 16#0#;
-- Read-only. External Low Speed oscillator ready
LSERDY : BDCR_LSERDY_Field := 16#0#;
-- External Low Speed oscillator bypass
LSEBYP : BDCR_LSEBYP_Field := 16#0#;
-- LSE oscillator drive capability
LSEDRV : BDCR_LSEDRV_Field := 16#0#;
-- unspecified
Reserved_5_7 : STM32_SVD.UInt3 := 16#0#;
-- RTC clock source selection
RTCSEL : BDCR_RTCSEL_Field := 16#0#;
-- unspecified
Reserved_10_14 : STM32_SVD.UInt5 := 16#0#;
-- RTC clock enable
RTCEN : BDCR_RTCEN_Field := 16#0#;
-- Backup domain software reset
BDRST : BDCR_BDRST_Field := 16#0#;
-- unspecified
Reserved_17_31 : STM32_SVD.UInt15 := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for BDCR_Register use record
LSEON at 0 range 0 .. 0;
LSERDY at 0 range 1 .. 1;
LSEBYP at 0 range 2 .. 2;
LSEDRV at 0 range 3 .. 4;
Reserved_5_7 at 0 range 5 .. 7;
RTCSEL at 0 range 8 .. 9;
Reserved_10_14 at 0 range 10 .. 14;
RTCEN at 0 range 15 .. 15;
BDRST at 0 range 16 .. 16;
Reserved_17_31 at 0 range 17 .. 31;
end record;
subtype CSR_LSION_Field is STM32_SVD.Bit;
subtype CSR_LSIRDY_Field is STM32_SVD.Bit;
subtype CSR_RMVF_Field is STM32_SVD.Bit;
subtype CSR_OBLRSTF_Field is STM32_SVD.Bit;
subtype CSR_PINRSTF_Field is STM32_SVD.Bit;
subtype CSR_PORRSTF_Field is STM32_SVD.Bit;
subtype CSR_SFTRSTF_Field is STM32_SVD.Bit;
subtype CSR_IWDGRSTF_Field is STM32_SVD.Bit;
subtype CSR_WWDGRSTF_Field is STM32_SVD.Bit;
subtype CSR_LPWRRSTF_Field is STM32_SVD.Bit;
-- Control/status register (RCC_CSR)
type CSR_Register is record
-- Internal low speed oscillator enable
LSION : CSR_LSION_Field := 16#0#;
-- Read-only. Internal low speed oscillator ready
LSIRDY : CSR_LSIRDY_Field := 16#0#;
-- unspecified
Reserved_2_23 : STM32_SVD.UInt22 := 16#0#;
-- Remove reset flag
RMVF : CSR_RMVF_Field := 16#0#;
-- Option byte loader reset flag
OBLRSTF : CSR_OBLRSTF_Field := 16#0#;
-- PIN reset flag
PINRSTF : CSR_PINRSTF_Field := 16#1#;
-- POR/PDR reset flag
PORRSTF : CSR_PORRSTF_Field := 16#1#;
-- Software reset flag
SFTRSTF : CSR_SFTRSTF_Field := 16#0#;
-- Independent watchdog reset flag
IWDGRSTF : CSR_IWDGRSTF_Field := 16#0#;
-- Window watchdog reset flag
WWDGRSTF : CSR_WWDGRSTF_Field := 16#0#;
-- Low-power reset flag
LPWRRSTF : CSR_LPWRRSTF_Field := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for CSR_Register use record
LSION at 0 range 0 .. 0;
LSIRDY at 0 range 1 .. 1;
Reserved_2_23 at 0 range 2 .. 23;
RMVF at 0 range 24 .. 24;
OBLRSTF at 0 range 25 .. 25;
PINRSTF at 0 range 26 .. 26;
PORRSTF at 0 range 27 .. 27;
SFTRSTF at 0 range 28 .. 28;
IWDGRSTF at 0 range 29 .. 29;
WWDGRSTF at 0 range 30 .. 30;
LPWRRSTF at 0 range 31 .. 31;
end record;
subtype AHBRSTR_IOPARST_Field is STM32_SVD.Bit;
subtype AHBRSTR_IOPBRST_Field is STM32_SVD.Bit;
subtype AHBRSTR_IOPCRST_Field is STM32_SVD.Bit;
subtype AHBRSTR_IOPDRST_Field is STM32_SVD.Bit;
subtype AHBRSTR_IOPFRST_Field is STM32_SVD.Bit;
-- AHB peripheral reset register
type AHBRSTR_Register is record
-- unspecified
Reserved_0_16 : STM32_SVD.UInt17 := 16#0#;
-- I/O port A reset
IOPARST : AHBRSTR_IOPARST_Field := 16#0#;
-- I/O port B reset
IOPBRST : AHBRSTR_IOPBRST_Field := 16#0#;
-- I/O port C reset
IOPCRST : AHBRSTR_IOPCRST_Field := 16#0#;
-- I/O port D reset
IOPDRST : AHBRSTR_IOPDRST_Field := 16#0#;
-- unspecified
Reserved_21_21 : STM32_SVD.Bit := 16#0#;
-- I/O port F reset
IOPFRST : AHBRSTR_IOPFRST_Field := 16#0#;
-- unspecified
Reserved_23_31 : STM32_SVD.UInt9 := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for AHBRSTR_Register use record
Reserved_0_16 at 0 range 0 .. 16;
IOPARST at 0 range 17 .. 17;
IOPBRST at 0 range 18 .. 18;
IOPCRST at 0 range 19 .. 19;
IOPDRST at 0 range 20 .. 20;
Reserved_21_21 at 0 range 21 .. 21;
IOPFRST at 0 range 22 .. 22;
Reserved_23_31 at 0 range 23 .. 31;
end record;
subtype CFGR2_PREDIV_Field is STM32_SVD.UInt4;
-- Clock configuration register 2
type CFGR2_Register is record
-- PREDIV division factor
PREDIV : CFGR2_PREDIV_Field := 16#0#;
-- unspecified
Reserved_4_31 : STM32_SVD.UInt28 := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for CFGR2_Register use record
PREDIV at 0 range 0 .. 3;
Reserved_4_31 at 0 range 4 .. 31;
end record;
subtype CFGR3_USART1SW_Field is STM32_SVD.UInt2;
subtype CFGR3_I2C1SW_Field is STM32_SVD.Bit;
subtype CFGR3_ADCSW_Field is STM32_SVD.Bit;
subtype CFGR3_USART2SW_Field is STM32_SVD.UInt2;
-- Clock configuration register 3
type CFGR3_Register is record
-- USART1 clock source selection
USART1SW : CFGR3_USART1SW_Field := 16#0#;
-- unspecified
Reserved_2_3 : STM32_SVD.UInt2 := 16#0#;
-- I2C1 clock source selection
I2C1SW : CFGR3_I2C1SW_Field := 16#0#;
-- unspecified
Reserved_5_7 : STM32_SVD.UInt3 := 16#0#;
-- ADC clock source selection
ADCSW : CFGR3_ADCSW_Field := 16#0#;
-- unspecified
Reserved_9_15 : STM32_SVD.UInt7 := 16#0#;
-- USART2 clock source selection
USART2SW : CFGR3_USART2SW_Field := 16#0#;
-- unspecified
Reserved_18_31 : STM32_SVD.UInt14 := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for CFGR3_Register use record
USART1SW at 0 range 0 .. 1;
Reserved_2_3 at 0 range 2 .. 3;
I2C1SW at 0 range 4 .. 4;
Reserved_5_7 at 0 range 5 .. 7;
ADCSW at 0 range 8 .. 8;
Reserved_9_15 at 0 range 9 .. 15;
USART2SW at 0 range 16 .. 17;
Reserved_18_31 at 0 range 18 .. 31;
end record;
subtype CR2_HSI14ON_Field is STM32_SVD.Bit;
subtype CR2_HSI14RDY_Field is STM32_SVD.Bit;
subtype CR2_HSI14DIS_Field is STM32_SVD.Bit;
subtype CR2_HSI14TRIM_Field is STM32_SVD.UInt5;
subtype CR2_HSI14CAL_Field is STM32_SVD.Byte;
subtype CR2_HSI48ON_Field is STM32_SVD.Bit;
subtype CR2_HSI48RDY_Field is STM32_SVD.Bit;
subtype CR2_HSI48CAL_Field is STM32_SVD.Bit;
-- Clock control register 2
type CR2_Register is record
-- HSI14 clock enable
HSI14ON : CR2_HSI14ON_Field := 16#0#;
-- Read-only. HR14 clock ready flag
HSI14RDY : CR2_HSI14RDY_Field := 16#0#;
-- HSI14 clock request from ADC disable
HSI14DIS : CR2_HSI14DIS_Field := 16#0#;
-- HSI14 clock trimming
HSI14TRIM : CR2_HSI14TRIM_Field := 16#10#;
-- Read-only. HSI14 clock calibration
HSI14CAL : CR2_HSI14CAL_Field := 16#0#;
-- HSI48 clock enable
HSI48ON : CR2_HSI48ON_Field := 16#0#;
-- Read-only. HSI48 clock ready flag
HSI48RDY : CR2_HSI48RDY_Field := 16#0#;
-- unspecified
Reserved_18_23 : STM32_SVD.UInt6 := 16#0#;
-- Read-only. HSI48 factory clock calibration
HSI48CAL : CR2_HSI48CAL_Field := 16#0#;
-- unspecified
Reserved_25_31 : STM32_SVD.UInt7 := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for CR2_Register use record
HSI14ON at 0 range 0 .. 0;
HSI14RDY at 0 range 1 .. 1;
HSI14DIS at 0 range 2 .. 2;
HSI14TRIM at 0 range 3 .. 7;
HSI14CAL at 0 range 8 .. 15;
HSI48ON at 0 range 16 .. 16;
HSI48RDY at 0 range 17 .. 17;
Reserved_18_23 at 0 range 18 .. 23;
HSI48CAL at 0 range 24 .. 24;
Reserved_25_31 at 0 range 25 .. 31;
end record;
-----------------
-- Peripherals --
-----------------
-- Reset and clock control
type RCC_Peripheral is record
-- Clock control register
CR : aliased CR_Register;
-- Clock configuration register (RCC_CFGR)
CFGR : aliased CFGR_Register;
-- Clock interrupt register (RCC_CIR)
CIR : aliased CIR_Register;
-- APB2 peripheral reset register (RCC_APB2RSTR)
APB2RSTR : aliased APB2RSTR_Register;
-- APB1 peripheral reset register (RCC_APB1RSTR)
APB1RSTR : aliased APB1RSTR_Register;
-- AHB Peripheral Clock enable register (RCC_AHBENR)
AHBENR : aliased AHBENR_Register;
-- APB2 peripheral clock enable register (RCC_APB2ENR)
APB2ENR : aliased APB2ENR_Register;
-- APB1 peripheral clock enable register (RCC_APB1ENR)
APB1ENR : aliased APB1ENR_Register;
-- Backup domain control register (RCC_BDCR)
BDCR : aliased BDCR_Register;
-- Control/status register (RCC_CSR)
CSR : aliased CSR_Register;
-- AHB peripheral reset register
AHBRSTR : aliased AHBRSTR_Register;
-- Clock configuration register 2
CFGR2 : aliased CFGR2_Register;
-- Clock configuration register 3
CFGR3 : aliased CFGR3_Register;
-- Clock control register 2
CR2 : aliased CR2_Register;
end record
with Volatile;
for RCC_Peripheral use record
CR at 16#0# range 0 .. 31;
CFGR at 16#4# range 0 .. 31;
CIR at 16#8# range 0 .. 31;
APB2RSTR at 16#C# range 0 .. 31;
APB1RSTR at 16#10# range 0 .. 31;
AHBENR at 16#14# range 0 .. 31;
APB2ENR at 16#18# range 0 .. 31;
APB1ENR at 16#1C# range 0 .. 31;
BDCR at 16#20# range 0 .. 31;
CSR at 16#24# range 0 .. 31;
AHBRSTR at 16#28# range 0 .. 31;
CFGR2 at 16#2C# range 0 .. 31;
CFGR3 at 16#30# range 0 .. 31;
CR2 at 16#34# range 0 .. 31;
end record;
-- Reset and clock control
RCC_Periph : aliased RCC_Peripheral
with Import, Address => System'To_Address (16#40021000#);
end STM32_SVD.RCC;
|
sungyeon/drake | Ada | 10,441 | adb | with System.UTF_Conversions;
package body System.C_Encoding is
use type C.size_t;
use type C.wchar_t;
-- implementation of Character (UTF-8) from/to char (UTF-8)
function To_char (
Item : Character;
Substitute : C.char)
return C.char
is
pragma Unreferenced (Substitute);
begin
return C.char (Item);
end To_char;
function To_Character (
Item : C.char;
Substitute : Character)
return Character
is
pragma Unreferenced (Substitute);
begin
return Character (Item);
end To_Character;
procedure To_Non_Nul_Terminated (
Item : String;
Target : out C.char_array;
Count : out C.size_t;
Substitute : C.char_array)
is
pragma Unreferenced (Substitute);
begin
Count := Item'Length;
if Count > 0 then
if Count > Target'Length then
raise Constraint_Error;
end if;
declare
Item_As_C : C.char_array (0 .. Count - 1);
for Item_As_C'Address use Item'Address;
begin
Target (Target'First .. Target'First + (Count - 1)) := Item_As_C;
end;
end if;
end To_Non_Nul_Terminated;
procedure From_Non_Nul_Terminated (
Item : C.char_array;
Target : out String;
Count : out Natural;
Substitute : String)
is
pragma Unreferenced (Substitute);
begin
Count := Item'Length;
if Count > Target'Length then
raise Constraint_Error;
end if;
declare
Item_As_Ada : String (1 .. Count);
for Item_As_Ada'Address use Item'Address;
begin
Target (Target'First .. Target'First + (Count - 1)) := Item_As_Ada;
end;
end From_Non_Nul_Terminated;
-- implementation of Wide_Character (UTF-16) from/to wchar_t (UTF-32)
function To_wchar_t (
Item : Wide_Character;
Substitute : C.wchar_t)
return C.wchar_t is
begin
if Wide_Character'Pos (Item) in 16#d800# .. 16#dfff# then
return Substitute;
else
return C.wchar_t'Val (Wide_Character'Pos (Item));
end if;
end To_wchar_t;
function To_Wide_Character (
Item : C.wchar_t;
Substitute : Wide_Character)
return Wide_Character is
begin
if Item > C.wchar_t'Val (16#ffff#) then
-- a check for detecting illegal sequence are omitted
return Substitute;
else
return Wide_Character'Val (C.wchar_t'Pos (Item));
end if;
end To_Wide_Character;
procedure To_Non_Nul_Terminated (
Item : Wide_String;
Target : out C.wchar_t_array;
Count : out C.size_t;
Substitute : C.wchar_t_array)
is
Item_Index : Positive := Item'First;
begin
Count := 0;
if Item_Index <= Item'Last then
declare
Target_As_Ada : Wide_Wide_String (1 .. Target'Length);
for Target_As_Ada'Address use Target'Address;
Target_Index : C.size_t := Target'First;
begin
loop
declare
Code : UTF_Conversions.UCS_4;
Item_Used : Natural;
From_Status : UTF_Conversions.From_Status_Type;
Target_Ada_Last : Natural;
Target_Last : C.size_t;
To_Status : UTF_Conversions.To_Status_Type;
begin
UTF_Conversions.From_UTF_16 (
Item (Item_Index .. Item'Last),
Item_Used,
Code,
From_Status);
case From_Status is
when UTF_Conversions.Success =>
UTF_Conversions.To_UTF_32 (
Code,
Target_As_Ada (
Target_As_Ada'First
+ Integer (Target_Index - Target'First) ..
Target_As_Ada'Last),
Target_Ada_Last,
To_Status);
Target_Last := Target'First
+ C.size_t (Target_Ada_Last - Target_As_Ada'First);
case To_Status is
when UTF_Conversions.Success =>
null;
when UTF_Conversions.Overflow
| UTF_Conversions.Unmappable =>
-- all values of UTF-16 are mappable to UTF-32
raise Constraint_Error;
end case;
when UTF_Conversions.Illegal_Sequence
| UTF_Conversions.Non_Shortest
| UTF_Conversions.Truncated =>
-- Non_Shortest does not returned in UTF-16.
Target_Last := Target_Index + (Substitute'Length - 1);
if Target_Last > Target'Last then
raise Constraint_Error; -- overflow
end if;
Target (Target_Index .. Target_Last) := Substitute;
end case;
Count := Target_Last - Target'First + 1;
exit when Item_Used >= Item'Last;
Item_Index := Item_Used + 1;
Target_Index := Target_Last + 1;
end;
end loop;
end;
end if;
end To_Non_Nul_Terminated;
procedure From_Non_Nul_Terminated (
Item : C.wchar_t_array;
Target : out Wide_String;
Count : out Natural;
Substitute : Wide_String)
is
Item_Index : C.size_t := Item'First;
begin
Count := 0;
if Item_Index <= Item'Last then
declare
Item_As_Ada : Wide_Wide_String (1 .. Item'Length);
for Item_As_Ada'Address use Item'Address;
Target_Index : Positive := Target'First;
begin
loop
declare
Code : UTF_Conversions.UCS_4;
Item_Ada_Used : Natural;
Item_Used : C.size_t;
From_Status : UTF_Conversions.From_Status_Type;
Target_Last : Natural;
To_Status : UTF_Conversions.To_Status_Type;
Put_Substitute : Boolean;
begin
UTF_Conversions.From_UTF_32 (
Item_As_Ada (
Item_As_Ada'First
+ Integer (Item_Index - Item'First) ..
Item_As_Ada'Last),
Item_Ada_Used,
Code,
From_Status);
Item_Used :=
Item'First + C.size_t (Item_Ada_Used - Item_As_Ada'First);
case From_Status is
when UTF_Conversions.Success =>
UTF_Conversions.To_UTF_16 (
Code,
Target (Target_Index .. Target'Last),
Target_Last,
To_Status);
case To_Status is
when UTF_Conversions.Success =>
Put_Substitute := False;
when UTF_Conversions.Overflow =>
raise Constraint_Error;
when UTF_Conversions.Unmappable =>
Put_Substitute := True;
end case;
when UTF_Conversions.Illegal_Sequence
| UTF_Conversions.Non_Shortest
| UTF_Conversions.Truncated =>
-- Non_Shortest and Truncated do not returned in
-- UTF-32.
Put_Substitute := True;
end case;
if Put_Substitute then
Target_Last := Target_Index + (Substitute'Length - 1);
if Target_Last > Target'Last then
raise Constraint_Error; -- overflow
end if;
Target (Target_Index .. Target_Last) := Substitute;
end if;
Count := Target_Last - Target'First + 1;
exit when Item_Used >= Item'Last;
Item_Index := Item_Used + 1;
Target_Index := Target_Last + 1;
end;
end loop;
end;
end if;
end From_Non_Nul_Terminated;
-- Wide_Wide_Character (UTF-32) from/to wchar_t (UTF-32)
function To_wchar_t (
Item : Wide_Wide_Character;
Substitute : C.wchar_t)
return C.wchar_t
is
pragma Unreferenced (Substitute);
begin
return C.wchar_t'Val (Wide_Wide_Character'Pos (Item));
end To_wchar_t;
function To_Wide_Wide_Character (
Item : C.wchar_t;
Substitute : Wide_Wide_Character)
return Wide_Wide_Character
is
pragma Unreferenced (Substitute);
begin
return Wide_Wide_Character'Val (C.wchar_t'Pos (Item));
end To_Wide_Wide_Character;
procedure To_Non_Nul_Terminated (
Item : Wide_Wide_String;
Target : out C.wchar_t_array;
Count : out C.size_t;
Substitute : C.wchar_t_array)
is
pragma Unreferenced (Substitute);
begin
Count := Item'Length;
if Count > 0 then
if Count > Target'Length then
raise Constraint_Error;
end if;
declare
Item_As_C : C.wchar_t_array (0 .. Count - 1);
for Item_As_C'Address use Item'Address;
begin
Target (Target'First .. Target'First + (Count - 1)) := Item_As_C;
end;
end if;
end To_Non_Nul_Terminated;
procedure From_Non_Nul_Terminated (
Item : C.wchar_t_array;
Target : out Wide_Wide_String;
Count : out Natural;
Substitute : Wide_Wide_String)
is
pragma Unreferenced (Substitute);
begin
Count := Item'Length;
if Count > Target'Length then
raise Constraint_Error;
end if;
declare
Item_As_Ada : Wide_Wide_String (1 .. Count);
for Item_As_Ada'Address use Item'Address;
begin
Target (Target'First .. Target'First + (Count - 1)) := Item_As_Ada;
end;
end From_Non_Nul_Terminated;
end System.C_Encoding;
|
micahwelf/FLTK-Ada | Ada | 2,750 | ads |
package FLTK.Widgets.Groups.Color_Choosers is
type Color_Chooser is new Group with private;
type Color_Chooser_Reference (Data : not null access Color_Chooser'Class) is
limited null record with Implicit_Dereference => Data;
type Color_Mode is (RGB, Byte, Hex, HSV);
package Forge is
function Create
(X, Y, W, H : in Integer;
Text : in String)
return Color_Chooser;
end Forge;
function Get_Red
(This : in Color_Chooser)
return Long_Float;
function Get_Green
(This : in Color_Chooser)
return Long_Float;
function Get_Blue
(This : in Color_Chooser)
return Long_Float;
procedure Set_RGB
(This : in out Color_Chooser;
R, G, B : in Long_Float);
function Get_Hue
(This : in Color_Chooser)
return Long_Float;
function Get_Saturation
(This : in Color_Chooser)
return Long_Float;
function Get_Value
(This : in Color_Chooser)
return Long_Float;
procedure Set_HSV
(This : in out Color_Chooser;
H, S, V : in Long_Float);
procedure HSV_To_RGB
(H, S, V : in Long_Float;
R, G, B : out Long_Float);
procedure RGB_To_HSV
(R, G, B : in Long_Float;
H, S, V : out Long_Float);
function Color_Was_Changed
(This : in Color_Chooser)
return Boolean;
procedure Clear_Changed
(This : in out Color_Chooser);
function Get_Mode
(This : in Color_Chooser)
return Color_Mode;
procedure Set_Mode
(This : in out Color_Chooser;
To : in Color_Mode);
procedure Draw
(This : in out Color_Chooser);
function Handle
(This : in out Color_Chooser;
Event : in Event_Kind)
return Event_Outcome;
private
type Color_Chooser is new Group with record
Was_Changed : Boolean := False;
end record;
overriding procedure Finalize
(This : in out Color_Chooser);
pragma Inline (Get_Red);
pragma Inline (Get_Green);
pragma Inline (Get_Blue);
pragma Inline (Set_RGB);
pragma Inline (Get_Hue);
pragma Inline (Get_Saturation);
pragma Inline (Get_Value);
pragma Inline (Set_HSV);
pragma Inline (HSV_To_RGB);
pragma Inline (RGB_To_HSV);
pragma Inline (Color_Was_Changed);
pragma Inline (Clear_Changed);
pragma Inline (Get_Mode);
pragma Inline (Set_Mode);
pragma Inline (Draw);
pragma Inline (Handle);
end FLTK.Widgets.Groups.Color_Choosers;
|
gusthoff/ada_wavefiles_gtk_app | Ada | 1,773 | ads | -------------------------------------------------------------------------------
--
-- WAVEFILES GTK APPLICATION
--
-- Main Application
--
-- The MIT License (MIT)
--
-- Copyright (c) 2017 Gustavo A. Hoffmann
--
-- Permission is hereby granted, free of charge, to any person obtaining a copy
-- of this software and associated documentation files (the "Software"), to
-- deal in the Software without restriction, including without limitation the
-- rights to use, copy, modify, merge, publish, distribute, sublicense, and /
-- or sell copies of the Software, and to permit persons to whom the Software
-- is furnished to do so, subject to the following conditions:
--
-- The above copyright notice and this permission notice shall be included in
-- all copies or substantial portions of the Software.
--
-- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
-- FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
-- IN THE SOFTWARE.
-------------------------------------------------------------------------------
with Gtk.Window;
with Gtk.Box;
package WaveFiles_Gtk is
procedure Create;
private
procedure Destroy_Window;
function Get_Window
return not null access Gtk.Window.Gtk_Window_Record'Class;
function Get_VBox
return not null access Gtk.Box.Gtk_Vbox_Record'Class;
procedure Set_Wavefile_Info (Info : String);
end WaveFiles_Gtk;
|
charlie5/cBound | Ada | 1,744 | ads | -- This file is generated by SWIG. Please do not modify by hand.
--
with Interfaces;
with Interfaces.C;
with Interfaces.C.Pointers;
package xcb.xcb_glx_create_glx_pixmap_request_t is
-- Item
--
type Item is record
major_opcode : aliased Interfaces.Unsigned_8;
minor_opcode : aliased Interfaces.Unsigned_8;
length : aliased Interfaces.Unsigned_16;
screen : aliased Interfaces.Unsigned_32;
visual : aliased xcb.xcb_visualid_t;
pixmap : aliased xcb.xcb_pixmap_t;
glx_pixmap : aliased xcb.xcb_glx_pixmap_t;
end record;
-- Item_Array
--
type Item_Array is
array
(Interfaces.C
.size_t range <>) of aliased xcb.xcb_glx_create_glx_pixmap_request_t
.Item;
-- Pointer
--
package C_Pointers is new Interfaces.C.Pointers
(Index => Interfaces.C.size_t,
Element => xcb.xcb_glx_create_glx_pixmap_request_t.Item,
Element_Array => xcb.xcb_glx_create_glx_pixmap_request_t.Item_Array,
Default_Terminator => (others => <>));
subtype Pointer is C_Pointers.Pointer;
-- Pointer_Array
--
type Pointer_Array is
array
(Interfaces.C
.size_t range <>) of aliased xcb.xcb_glx_create_glx_pixmap_request_t
.Pointer;
-- Pointer_Pointer
--
package C_Pointer_Pointers is new Interfaces.C.Pointers
(Index => Interfaces.C.size_t,
Element => xcb.xcb_glx_create_glx_pixmap_request_t.Pointer,
Element_Array => xcb.xcb_glx_create_glx_pixmap_request_t.Pointer_Array,
Default_Terminator => null);
subtype Pointer_Pointer is C_Pointer_Pointers.Pointer;
end xcb.xcb_glx_create_glx_pixmap_request_t;
|
reznikmm/matreshka | Ada | 4,567 | adb | ------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- Open Document Toolkit --
-- --
-- Runtime Library Component --
-- --
------------------------------------------------------------------------------
-- --
-- Copyright © 2014, Vadim Godunko <[email protected]> --
-- All rights reserved. --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions --
-- are met: --
-- --
-- * Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- --
-- * Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in the --
-- documentation and/or other materials provided with the distribution. --
-- --
-- * Neither the name of the Vadim Godunko, IE nor the names of its --
-- contributors may be used to endorse or promote products derived from --
-- this software without specific prior written permission. --
-- --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR --
-- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
-- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED --
-- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR --
-- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF --
-- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING --
-- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS --
-- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
-- --
------------------------------------------------------------------------------
-- $Revision$ $Date$
------------------------------------------------------------------------------
with Matreshka.DOM_Documents;
with Matreshka.ODF_String_Constants;
with ODF.DOM.Iterators;
with ODF.DOM.Visitors;
package body Matreshka.ODF_Draw.Value_Attributes is
------------
-- Create --
------------
overriding function Create
(Parameters : not null access Matreshka.DOM_Attributes.Attribute_L2_Parameters)
return Draw_Value_Attribute_Node is
begin
return Self : Draw_Value_Attribute_Node do
Matreshka.ODF_Draw.Constructors.Initialize
(Self'Unchecked_Access,
Parameters.Document,
Matreshka.ODF_String_Constants.Draw_Prefix);
end return;
end Create;
--------------------
-- Get_Local_Name --
--------------------
overriding function Get_Local_Name
(Self : not null access constant Draw_Value_Attribute_Node)
return League.Strings.Universal_String
is
pragma Unreferenced (Self);
begin
return Matreshka.ODF_String_Constants.Value_Attribute;
end Get_Local_Name;
begin
Matreshka.DOM_Documents.Register_Attribute
(Matreshka.ODF_String_Constants.Draw_URI,
Matreshka.ODF_String_Constants.Value_Attribute,
Draw_Value_Attribute_Node'Tag);
end Matreshka.ODF_Draw.Value_Attributes;
|
charlie5/lace | Ada | 179 | ads | with
any_Math.any_Algebra.any_linear.any_d3;
package float_Math.Algebra.linear.d3 is new float_Math.Algebra.linear.any_d3;
pragma Pure (float_Math.Algebra.linear.d3);
|
mirror/ncurses | Ada | 3,114 | ads | ------------------------------------------------------------------------------
-- --
-- GNAT ncurses Binding Samples --
-- --
-- ncurses --
-- --
-- B O D Y --
-- --
------------------------------------------------------------------------------
-- Copyright 2020 Thomas E. Dickey --
-- Copyright 2000,2006 Free Software Foundation, Inc. --
-- --
-- Permission is hereby granted, free of charge, to any person obtaining a --
-- copy of this software and associated documentation files (the --
-- "Software"), to deal in the Software without restriction, including --
-- without limitation the rights to use, copy, modify, merge, publish, --
-- distribute, distribute with modifications, sublicense, and/or sell --
-- copies of the Software, and to permit persons to whom the Software is --
-- furnished to do so, subject to the following conditions: --
-- --
-- The above copyright notice and this permission notice shall be included --
-- in all copies or substantial portions of the Software. --
-- --
-- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS --
-- OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF --
-- MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. --
-- IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, --
-- DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR --
-- OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR --
-- THE USE OR OTHER DEALINGS IN THE SOFTWARE. --
-- --
-- Except as contained in this notice, the name(s) of the above copyright --
-- holders shall not be used in advertising or otherwise to promote the --
-- sale, use or other dealings in this Software without prior written --
-- authorization. --
------------------------------------------------------------------------------
-- Author: Eugene V. Melaragno <[email protected]> 2000
-- Version Control
-- $Revision: 1.3 $
-- $Date: 2020/02/02 23:34:34 $
-- Binding Version 01.00
------------------------------------------------------------------------------
procedure ncurses2.attr_test;
|
stcarrez/ada-awa | Ada | 7,884 | adb | -----------------------------------------------------------------------
-- awa-comments-module -- Comments module
-- Copyright (C) 2011, 2012, 2013, 2014 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.Calendar;
with Util.Log.Loggers;
with ADO.Sessions;
with ADO.Sessions.Entities;
with Security.Permissions;
with AWA.Users.Models;
with AWA.Permissions;
with AWA.Modules.Beans;
with AWA.Services.Contexts;
with AWA.Comments.Beans;
package body AWA.Comments.Modules is
Log : constant Util.Log.Loggers.Logger := Util.Log.Loggers.Create ("AWA.Comments.Module");
package Register is new AWA.Modules.Beans (Module => Comment_Module,
Module_Access => Comment_Module_Access);
-- ------------------------------
-- Initialize the comments module.
-- ------------------------------
overriding
procedure Initialize (Plugin : in out Comment_Module;
App : in AWA.Modules.Application_Access;
Props : in ASF.Applications.Config) is
begin
Log.Info ("Initializing the comments module");
-- Setup the resource bundles.
App.Register ("commentMsg", "comments");
-- Register the comment list bean.
Register.Register (Plugin => Plugin,
Name => "AWA.Comments.Beans.Comment_List_Bean",
Handler => AWA.Comments.Beans.Create_Comment_List_Bean'Access);
-- Register the comment bean.
Register.Register (Plugin => Plugin,
Name => "AWA.Comments.Beans.Comment_Bean",
Handler => AWA.Comments.Beans.Create_Comment_Bean'Access);
AWA.Modules.Module (Plugin).Initialize (App, Props);
end Initialize;
-- ------------------------------
-- Load the comment identified by the given identifier.
-- ------------------------------
procedure Load_Comment (Model : in Comment_Module;
Comment : in out AWA.Comments.Models.Comment_Ref'Class;
Id : in ADO.Identifier) is
pragma Unreferenced (Model);
Ctx : constant Services.Contexts.Service_Context_Access := AWA.Services.Contexts.Current;
DB : ADO.Sessions.Session := AWA.Services.Contexts.Get_Session (Ctx);
Found : Boolean;
begin
Comment.Load (DB, Id, Found);
end Load_Comment;
-- ------------------------------
-- Create a new comment for the associated database entity.
-- ------------------------------
procedure Create_Comment (Model : in Comment_Module;
Permission : in String;
Entity_Type : in String;
Comment : in out AWA.Comments.Models.Comment_Ref'Class) is
Ctx : constant Services.Contexts.Service_Context_Access := AWA.Services.Contexts.Current;
User : constant AWA.Users.Models.User_Ref := Ctx.Get_User;
DB : ADO.Sessions.Master_Session := AWA.Services.Contexts.Get_Master_Session (Ctx);
begin
Ctx.Start;
Log.Info ("Creating new comment for {0}", ADO.Identifier'Image (Comment.Get_Entity_Id));
-- Check that the user has the create permission on the given workspace.
AWA.Permissions.Check (Permission => Security.Permissions.Get_Permission_Index (Permission),
Entity => Comment.Get_Entity_Id);
Comment.Set_Entity_Type (ADO.Sessions.Entities.Find_Entity_Type (DB, Entity_Type));
Comment.Set_Author (User);
Comment.Set_Create_Date (Ada.Calendar.Clock);
Comment.Save (DB);
Comment_Lifecycle.Notify_Create (Model, Comment);
Ctx.Commit;
end Create_Comment;
-- ------------------------------
-- Update the comment represented by <tt>Comment</tt> if the current user has the
-- permission identified by <tt>Permission</tt>.
-- ------------------------------
procedure Update_Comment (Model : in Comment_Module;
Permission : in String;
Comment : in out AWA.Comments.Models.Comment_Ref'Class) is
Ctx : constant Services.Contexts.Service_Context_Access := AWA.Services.Contexts.Current;
DB : ADO.Sessions.Master_Session := AWA.Services.Contexts.Get_Master_Session (Ctx);
begin
if not Comment.Is_Inserted then
Log.Error ("The comment was not created");
raise Not_Found with "The comment was not inserted";
end if;
Ctx.Start;
Log.Info ("Updating the comment {0}", ADO.Identifier'Image (Comment.Get_Id));
-- Check that the user has the update permission on the given comment.
AWA.Permissions.Check (Permission => Security.Permissions.Get_Permission_Index (Permission),
Entity => Comment);
Comment_Lifecycle.Notify_Update (Model, Comment);
Comment.Save (DB);
Ctx.Commit;
end Update_Comment;
-- ------------------------------
-- Delete the comment represented by <tt>Comment</tt> if the current user has the
-- permission identified by <tt>Permission</tt>.
-- ------------------------------
procedure Delete_Comment (Model : in Comment_Module;
Permission : in String;
Comment : in out AWA.Comments.Models.Comment_Ref'Class) is
Ctx : constant Services.Contexts.Service_Context_Access := AWA.Services.Contexts.Current;
DB : ADO.Sessions.Master_Session := AWA.Services.Contexts.Get_Master_Session (Ctx);
begin
Ctx.Start;
-- Check that the user has the delete permission on the given answer.
AWA.Permissions.Check (Permission => Security.Permissions.Get_Permission_Index (Permission),
Entity => Comment);
Comment_Lifecycle.Notify_Delete (Model, Comment);
Comment.Delete (DB);
Ctx.Commit;
end Delete_Comment;
-- ------------------------------
-- Set the publication status of the comment represented by <tt>Comment</tt>
-- if the current user has the permission identified by <tt>Permission</tt>.
-- ------------------------------
procedure Publish_Comment (Model : in Comment_Module;
Permission : in String;
Id : in ADO.Identifier;
Status : in AWA.Comments.Models.Status_Type;
Comment : in out AWA.Comments.Models.Comment_Ref'Class) is
pragma Unreferenced (Model);
Ctx : constant Services.Contexts.Service_Context_Access := AWA.Services.Contexts.Current;
DB : ADO.Sessions.Master_Session := AWA.Services.Contexts.Get_Master_Session (Ctx);
begin
Ctx.Start;
-- Check that the user has the permission to publish for the given comment.
AWA.Permissions.Check (Permission => Security.Permissions.Get_Permission_Index (Permission),
Entity => Id);
Comment.Load (DB, Id);
Comment.Set_Status (Status);
Comment.Save (DB);
Ctx.Commit;
end Publish_Comment;
end AWA.Comments.Modules;
|
reznikmm/matreshka | Ada | 3,993 | 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.Draw_Nav_Order_Attributes;
package Matreshka.ODF_Draw.Nav_Order_Attributes is
type Draw_Nav_Order_Attribute_Node is
new Matreshka.ODF_Draw.Abstract_Draw_Attribute_Node
and ODF.DOM.Draw_Nav_Order_Attributes.ODF_Draw_Nav_Order_Attribute
with null record;
overriding function Create
(Parameters : not null access Matreshka.DOM_Attributes.Attribute_L2_Parameters)
return Draw_Nav_Order_Attribute_Node;
overriding function Get_Local_Name
(Self : not null access constant Draw_Nav_Order_Attribute_Node)
return League.Strings.Universal_String;
end Matreshka.ODF_Draw.Nav_Order_Attributes;
|
Samsung/TizenRT | Ada | 5,120 | adb | --------------------------------------------------------------- -
-- ZLib for Ada thick binding. --
-- --
-- Copyright(C) 2002 - 2003 Dmitriy Anisimkov --
-- --
-- Open source license information is in the zlib.ads file. --
----------------------------------------------------------------
-- $Id: zlib - streams.adb, v 1.10 2004 / 05 / 31 10:53:40 vagul Exp $
with Ada.Unchecked_Deallocation;
package body ZLib.Streams is
-----------
-- Close --
---------- -
procedure Close(Stream : in out Stream_Type) is
procedure Free is new Ada.Unchecked_Deallocation
(Stream_Element_Array, Buffer_Access);
begin
if Stream.Mode = Out_Stream or Stream.Mode = Duplex then
-- We should flush the data written by the writer.
Flush(Stream, Finish);
Close(Stream.Writer);
end if ;
if Stream.Mode = In_Stream or Stream.Mode = Duplex then
Close(Stream.Reader);
Free(Stream.Buffer);
end if ;
end Close;
----------- -
-- Create --
------------
procedure Create
(Stream : out Stream_Type;
Mode : in Stream_Mode;
Back : in Stream_Access;
Back_Compressed : in Boolean;
Level : in Compression_Level : = Default_Compression;
Strategy : in Strategy_Type : = Default_Strategy;
Header : in Header_Type : = Default;
Read_Buffer_Size : in Ada.Streams.Stream_Element_Offset
: = Default_Buffer_Size;
Write_Buffer_Size : in Ada.Streams.Stream_Element_Offset
: = Default_Buffer_Size)
is
subtype Buffer_Subtype is Stream_Element_Array(1 .. Read_Buffer_Size);
procedure Init_Filter
(Filter : in out Filter_Type;
Compress : in Boolean);
-----------------
-- Init_Filter --
---------------- -
procedure Init_Filter
(Filter : in out Filter_Type;
Compress : in Boolean) is
begin
if Compress then
Deflate_Init
(Filter, Level, Strategy, Header => Header);
else
{
Inflate_Init(Filter, Header => Header);
}
end if ;
end Init_Filter;
begin
Stream.Back :
= Back;
Stream.Mode :
= Mode;
if Mode = Out_Stream or Mode = Duplex then
Init_Filter(Stream.Writer, Back_Compressed);
Stream.Buffer_Size :
= Write_Buffer_Size;
else
{
Stream.Buffer_Size :
= 0;
}
end if ;
if Mode = In_Stream or Mode = Duplex then
Init_Filter(Stream.Reader, not Back_Compressed);
Stream.Buffer :
= new Buffer_Subtype;
Stream.Rest_First :
= Stream.Buffer'Last + 1;
Stream.Rest_Last :
= Stream.Buffer'Last;
end if ;
end Create;
-----------
-- Flush --
---------- -
procedure Flush
(Stream : in out Stream_Type;
Mode : in Flush_Mode : = Sync_Flush)
is
Buffer :
Stream_Element_Array(1 .. Stream.Buffer_Size);
Last :
Stream_Element_Offset;
begin
loop
Flush(Stream.Writer, Buffer, Last, Mode);
Ada.Streams.Write(Stream.Back.all, Buffer(1 .. Last));
exit when Last < Buffer'Last;
end loop;
end Flush;
-------------
-- Is_Open --
------------ -
function Is_Open(Stream : Stream_Type) return Boolean is
begin
return Is_Open(Stream.Reader) or else
{
Is_Open(Stream.Writer);
}
end Is_Open;
--------- -
-- Read --
----------
procedure Read
(Stream : in out Stream_Type;
Item : out Stream_Element_Array;
Last : out Stream_Element_Offset)
is
procedure Read
(Item : out Stream_Element_Array;
Last : out Stream_Element_Offset);
--------- -
-- Read --
----------
procedure Read
(Item : out Stream_Element_Array;
Last : out Stream_Element_Offset) is
begin
Ada.Streams.Read(Stream.Back.all, Item, Last);
end Read;
procedure Read is new ZLib.Read
(Read => Read,
Buffer => Stream.Buffer.all,
Rest_First => Stream.Rest_First,
Rest_Last => Stream.Rest_Last);
begin
Read(Stream.Reader, Item, Last);
end Read;
-------------------
-- Read_Total_In --
------------------ -
function Read_Total_In(Stream : in Stream_Type) return Count is
begin
return Total_In(Stream.Reader);
end Read_Total_In;
------------------- -
-- Read_Total_Out --
--------------------
function Read_Total_Out(Stream : in Stream_Type) return Count is
begin
return Total_Out(Stream.Reader);
end Read_Total_Out;
-----------
-- Write --
---------- -
procedure Write
(Stream : in out Stream_Type;
Item : in Stream_Element_Array)
is
procedure Write(Item : in Stream_Element_Array);
-----------
-- Write --
---------- -
procedure Write(Item : in Stream_Element_Array) is
begin
Ada.Streams.Write(Stream.Back.all, Item);
end Write;
procedure Write is new ZLib.Write
(Write => Write,
Buffer_Size => Stream.Buffer_Size);
begin
Write(Stream.Writer, Item, No_Flush);
end Write;
------------------- -
-- Write_Total_In --
--------------------
function Write_Total_In(Stream : in Stream_Type) return Count is
begin
return Total_In(Stream.Writer);
end Write_Total_In;
---------------------
-- Write_Total_Out --
-------------------- -
function Write_Total_Out(Stream : in Stream_Type) return Count is
begin
return Total_Out(Stream.Writer);
end Write_Total_Out;
end ZLib.Streams;
|
reznikmm/matreshka | Ada | 4,802 | ads | ------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- Web Framework --
-- --
-- Runtime Library Component --
-- --
------------------------------------------------------------------------------
-- --
-- Copyright © 2015, Vadim Godunko <[email protected]> --
-- All rights reserved. --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions --
-- are met: --
-- --
-- * Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- --
-- * Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in the --
-- documentation and/or other materials provided with the distribution. --
-- --
-- * Neither the name of the Vadim Godunko, IE nor the names of its --
-- contributors may be used to endorse or promote products derived from --
-- this software without specific prior written permission. --
-- --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR --
-- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
-- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED --
-- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR --
-- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF --
-- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING --
-- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS --
-- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
-- --
------------------------------------------------------------------------------
-- $Revision$ $Date$
------------------------------------------------------------------------------
generic
type Listener is limited interface;
type Listener_Access is access all Listener'Class;
package Core.Objects.Listeners is
pragma Preelaborate;
type Listener_Registry
(Owner : not null access Core.Objects.Abstract_Object'Class) is
tagged limited private;
procedure Add
(Self : in out Listener_Registry'Class;
Listener : not null Listener_Access);
procedure Remove
(Self : in out Listener_Registry'Class;
Listener : not null Listener_Access);
generic
with procedure Notify (Self : in out Listener) is abstract;
procedure Generic_Notify (Self : Listener_Registry);
generic
type Parameter_Type is limited private;
with procedure Notify
(Self : in out Listener; Parameter : Parameter_Type) is abstract;
procedure Generic_Notify_1
(Self : Listener_Registry; Parameter : Parameter_Type);
private
type Listener_Registry
(Owner : not null access Core.Objects.Abstract_Object'Class) is
new Core.Objects.Listener_Registry (Owner) with null record;
type Listener_Record
(Collection : not null access Listener_Registry'Class;
Object : not null access Abstract_Object'Class;
Listener : not null access Core.Objects.Listeners.Listener'Class) is
new Core.Objects.Listener_Record (Collection, Object) with null record;
type Listener_Record_Access is access all Listener_Record'Class;
end Core.Objects.Listeners;
|
LudvikGalois/Ichiban_Quest | Ada | 6,191 | adb |
package body Allegro_Bindings is
function Allegro_Init return unsigned_char;
pragma Import (C, Allegro_Init, "allegro_init");
function Allegro_Install_Keyboard return unsigned_char;
pragma Import (C, Allegro_Install_Keyboard, "al_install_keyboard");
function Allegro_Init_Image_Addon return unsigned_char;
pragma Import (C, Allegro_Init_Image_Addon, "al_init_image_addon");
function Allegro_Create_Display (width : Int; height : Int) return System.Address;
pragma Import (C, Allegro_Create_Display, "al_create_display");
function Allegro_Create_Timer (interval : Double) return System.Address;
pragma Import (C, Allegro_Create_Timer, "al_create_timer");
function Allegro_Create_Event_Queue return System.Address;
pragma Import (C, Allegro_Create_Event_Queue, "al_create_event_queue");
procedure Allegro_Start_Timer (target_timer : Timer);
pragma Import (C, Allegro_Start_Timer, "al_start_timer");
function Allegro_Get_Keyboard_Event_Source return Event_Source;
pragma Import (C, Allegro_Get_Keyboard_Event_Source,
"al_get_keyboard_event_source");
function Allegro_Get_Timer_Event_Source (target_timer : Timer)
return Event_Source;
pragma Import (C, Allegro_Get_Timer_Event_Source,
"al_get_timer_event_source");
function Allegro_Get_Display_Event_Source (target_display : Display)
return Event_Source;
pragma Import (C, Allegro_Get_Display_Event_Source,
"al_get_display_event_source");
procedure Allegro_Register_Event_Source (target_queue : Event_Queue;
target_source : Event_Source);
pragma Import (C, Allegro_Register_Event_Source, "al_register_event_source");
procedure Allegro_Wait_For_Event (target_queue : Event_Queue;
target_event : System.Address);
pragma Import (C, Allegro_Wait_For_Event, "al_wait_for_event");
function Allegro_Load_Bitmap (filepath : char_array) return System.Address;
pragma Import (C, Allegro_Load_Bitmap, "al_load_bitmap");
function Allegro_Map_RGB (red : Unsigned_char; blue : Unsigned_char;
green : Unsigned_char) return Color;
pragma Import (C, Allegro_Map_RGB, "al_map_rgb");
procedure Allegro_Clear_To_Color (target_color : Color);
pragma Import (C, Allegro_Clear_To_Color, "al_clear_to_color");
procedure Allegro_Flip_Display;
pragma Import (C, Allegro_Flip_Display, "al_flip_display");
procedure Allegro_Draw_Bitmap (target_bitmap : Bitmap; dx : Float;
dy : Float; flags : Int);
pragma Import (C, Allegro_Draw_Bitmap, "al_draw_bitmap");
procedure Init is begin
if Allegro_Init = 0 then
raise Init_Error;
end if;
end Init;
procedure Install_Keyboard is begin
if Allegro_Install_Keyboard = 0 then
raise Keyboard_Error;
end if;
end Install_Keyboard;
procedure Init_Image_Addon is begin
if Allegro_Init_Image_Addon = 0 then
raise Image_Addon_Init_Error;
end if;
end Init_Image_Addon;
function Create_Display (width : Int; height : Int) return Display is
disp : System.Address := Allegro_Create_Display (width, height);
begin
if disp = System.Null_Address then
raise Display_Error;
end if;
return Display (disp);
end Create_Display;
function Create_Timer (interval : Double) return Timer is
new_timer : System.Address := Allegro_Create_Timer (interval);
begin
if new_timer = System.Null_Address then
raise Timer_Init_Error;
end if;
return Timer (new_timer);
end Create_Timer;
function Create_Event_Queue return Event_Queue is
queue : System.Address := Allegro_Create_Event_Queue;
begin
if queue = System.Null_Address then
raise Event_Queue_Init_Error;
end if;
return Event_Queue (queue);
end Create_Event_Queue;
function Get_Keyboard_Event_Source return Event_Source is
begin
return Allegro_Get_Keyboard_Event_Source;
end Get_Keyboard_Event_Source;
function Get_Timer_Event_Source (target_timer : Timer) return Event_Source is
begin
return Allegro_Get_Timer_Event_Source (target_timer);
end Get_Timer_Event_Source;
function Get_Display_Event_Source (target_display : Display)
return Event_Source is
begin
return Allegro_Get_Display_Event_Source (target_display);
end Get_Display_Event_Source;
procedure Start_Timer (target_timer : Timer) is
begin
Allegro_Start_Timer(target_timer);
end Start_Timer;
procedure Register_Event_Source (target_queue : Event_Queue ;
target_source : Event_Source ) is
begin
Allegro_Register_Event_Source (target_queue, target_source);
end Register_Event_Source;
procedure Wait_For_Event (target_queue : in Event_Queue ;
target_event : out Event) is
begin
Allegro_Wait_For_Event(target_queue, target_event'Address);
end Wait_For_Event;
function Load_Bitmap (filepath : String) return Bitmap is
new_bitmap : System.Address := Allegro_Load_Bitmap (To_C (filepath));
begin
if new_bitmap = System.Null_Address then
raise Bitmap_Load_Error;
end if;
return Bitmap (new_bitmap);
end Load_Bitmap;
function Map_RGB (red : Color_Channel; blue : Color_Channel;
green : Color_Channel) return Color is
begin
return Allegro_Map_RGB (Unsigned_char (red), Unsigned_char (blue),
Unsigned_char (green));
end Map_RGB;
procedure Clear_To_Color (target_color : Color) is
begin
Allegro_Clear_To_Color(target_color);
end Clear_To_Color;
procedure Flip_Display is
begin
Allegro_Flip_Display;
end Flip_Display;
procedure Draw_Bitmap (target_bitmap : Bitmap; dx : Float; dy : Float) is
begin
Allegro_Draw_Bitmap (target_bitmap, dx, dy, 0);
end Draw_Bitmap;
end Allegro_Bindings;
|
stcarrez/dynamo | Ada | 18,632 | adb | ------------------------------------------------------------------------------
-- --
-- GNAT COMPILER COMPONENTS --
-- --
-- T R E E _ I O --
-- --
-- B o d y --
-- --
-- Copyright (C) 1992-2014, Free Software Foundation, Inc. --
-- --
-- GNAT is free software; you can redistribute it and/or modify it under --
-- terms of the GNU General Public License as published by the Free Soft- --
-- ware Foundation; either version 3, or (at your option) any later ver- --
-- sion. GNAT is distributed in the hope that it will be useful, but WITH- --
-- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY --
-- or FITNESS FOR A PARTICULAR PURPOSE. --
-- --
-- As a special exception under Section 7 of GPL version 3, you are granted --
-- additional permissions described in the GCC Runtime Library Exception, --
-- version 3.1, as published by the Free Software Foundation. --
-- --
-- You should have received a copy of the GNU General Public License and --
-- a copy of the GCC Runtime Library Exception along with this program; --
-- see the files COPYING3 and COPYING.RUNTIME respectively. If not, see --
-- <http://www.gnu.org/licenses/>. --
-- --
-- GNAT was originally developed by the GNAT team at New York University. --
-- Extensive contributions were provided by Ada Core Technologies Inc. --
-- --
------------------------------------------------------------------------------
with Debug; use Debug;
with Output; use Output;
with Unchecked_Conversion;
package body Tree_IO is
Debug_Flag_Tree : Boolean := False;
-- Debug flag for debug output from tree read/write
-------------------------------------------
-- Compression Scheme Used for Tree File --
-------------------------------------------
-- We don't just write the data directly, but instead do a mild form
-- of compression, since we expect lots of compressible zeroes and
-- blanks. The compression scheme is as follows:
-- 00nnnnnn followed by nnnnnn bytes (non compressed data)
-- 01nnnnnn indicates nnnnnn binary zero bytes
-- 10nnnnnn indicates nnnnnn ASCII space bytes
-- 11nnnnnn bbbbbbbb indicates nnnnnnnn occurrences of byte bbbbbbbb
-- Since we expect many zeroes in trees, and many spaces in sources,
-- this compression should be reasonably efficient. We can put in
-- something better later on.
-- Note that this compression applies to the Write_Tree_Data and
-- Read_Tree_Data calls, not to the calls to read and write single
-- scalar values, which are written in memory format without any
-- compression.
C_Noncomp : constant := 2#00_000000#;
C_Zeros : constant := 2#01_000000#;
C_Spaces : constant := 2#10_000000#;
C_Repeat : constant := 2#11_000000#;
-- Codes for compression sequences
Max_Count : constant := 63;
-- Maximum data length for one compression sequence
-- The above compression scheme applies only to data written with the
-- Tree_Write routine and read with Tree_Read. Data written using the
-- Tree_Write_Char or Tree_Write_Int routines and read using the
-- corresponding input routines is not compressed.
type Int_Bytes is array (1 .. 4) of Byte;
for Int_Bytes'Size use 32;
function To_Int_Bytes is new Unchecked_Conversion (Int, Int_Bytes);
function To_Int is new Unchecked_Conversion (Int_Bytes, Int);
----------------------
-- Global Variables --
----------------------
Tree_FD : File_Descriptor;
-- File descriptor for tree
Buflen : constant Int := 8_192;
-- Length of buffer for read and write file data
Buf : array (Pos range 1 .. Buflen) of Byte;
-- Read/write file data buffer
Bufn : Nat;
-- Number of bytes read/written from/to buffer
Buft : Nat;
-- Total number of bytes in input buffer containing valid data. Used only
-- for input operations. There is data left to be processed in the buffer
-- if Buft > Bufn. A value of zero for Buft means that the buffer is empty.
-----------------------
-- Local Subprograms --
-----------------------
procedure Read_Buffer;
-- Reads data into buffer, setting Bufn appropriately
function Read_Byte return Byte;
pragma Inline (Read_Byte);
-- Returns next byte from input file, raises Tree_Format_Error if none left
procedure Write_Buffer;
-- Writes out current buffer contents
procedure Write_Byte (B : Byte);
pragma Inline (Write_Byte);
-- Write one byte to output buffer, checking for buffer-full condition
-----------------
-- Read_Buffer --
-----------------
procedure Read_Buffer is
begin
Buft := Int (Read (Tree_FD, Buf (1)'Address, Integer (Buflen)));
if Buft = 0 then
raise Tree_Format_Error;
else
Bufn := 0;
end if;
end Read_Buffer;
---------------
-- Read_Byte --
---------------
function Read_Byte return Byte is
begin
if Bufn = Buft then
Read_Buffer;
end if;
Bufn := Bufn + 1;
return Buf (Bufn);
end Read_Byte;
--------------------
-- Tree_Read_Bool --
--------------------
procedure Tree_Read_Bool (B : out Boolean) is
begin
B := Boolean'Val (Read_Byte);
if Debug_Flag_Tree then
if B then
Write_Str ("True");
else
Write_Str ("False");
end if;
Write_Eol;
end if;
end Tree_Read_Bool;
--------------------
-- Tree_Read_Char --
--------------------
procedure Tree_Read_Char (C : out Character) is
begin
C := Character'Val (Read_Byte);
if Debug_Flag_Tree then
Write_Str ("==> transmitting Character = ");
Write_Char (C);
Write_Eol;
end if;
end Tree_Read_Char;
--------------------
-- Tree_Read_Data --
--------------------
procedure Tree_Read_Data (Addr : Address; Length : Int) is
type S is array (Pos) of Byte;
-- This is a big array, for which we have to suppress the warning
type SP is access all S;
function To_SP is new Unchecked_Conversion (Address, SP);
Data : constant SP := To_SP (Addr);
-- Data buffer to be read as an indexable array of bytes
OP : Pos := 1;
-- Pointer to next byte of data buffer to be read into
B : Byte;
C : Byte;
L : Int;
begin
if Debug_Flag_Tree then
Write_Str ("==> transmitting ");
Write_Int (Length);
Write_Str (" data bytes");
Write_Eol;
end if;
-- Verify data length
Tree_Read_Int (L);
if L /= Length then
Write_Str ("==> transmitting, expected ");
Write_Int (Length);
Write_Str (" bytes, found length = ");
Write_Int (L);
Write_Eol;
raise Tree_Format_Error;
end if;
-- Loop to read data
while OP <= Length loop
-- Get compression control character
B := Read_Byte;
C := B and 2#00_111111#;
B := B and 2#11_000000#;
-- Non-repeat case
if B = C_Noncomp then
if Debug_Flag_Tree then
Write_Str ("==> uncompressed: ");
Write_Int (Int (C));
Write_Str (", starting at ");
Write_Int (OP);
Write_Eol;
end if;
for J in 1 .. C loop
Data (OP) := Read_Byte;
OP := OP + 1;
end loop;
-- Repeated zeroes
elsif B = C_Zeros then
if Debug_Flag_Tree then
Write_Str ("==> zeroes: ");
Write_Int (Int (C));
Write_Str (", starting at ");
Write_Int (OP);
Write_Eol;
end if;
for J in 1 .. C loop
Data (OP) := 0;
OP := OP + 1;
end loop;
-- Repeated spaces
elsif B = C_Spaces then
if Debug_Flag_Tree then
Write_Str ("==> spaces: ");
Write_Int (Int (C));
Write_Str (", starting at ");
Write_Int (OP);
Write_Eol;
end if;
for J in 1 .. C loop
Data (OP) := Character'Pos (' ');
OP := OP + 1;
end loop;
-- Specified repeated character
else -- B = C_Repeat
B := Read_Byte;
if Debug_Flag_Tree then
Write_Str ("==> other char: ");
Write_Int (Int (C));
Write_Str (" (");
Write_Int (Int (B));
Write_Char (')');
Write_Str (", starting at ");
Write_Int (OP);
Write_Eol;
end if;
for J in 1 .. C loop
Data (OP) := B;
OP := OP + 1;
end loop;
end if;
end loop;
-- At end of loop, data item must be exactly filled
if OP /= Length + 1 then
raise Tree_Format_Error;
end if;
end Tree_Read_Data;
--------------------------
-- Tree_Read_Initialize --
--------------------------
procedure Tree_Read_Initialize (Desc : File_Descriptor) is
begin
Buft := 0;
Bufn := 0;
Tree_FD := Desc;
Debug_Flag_Tree := Debug_Flag_5;
end Tree_Read_Initialize;
-------------------
-- Tree_Read_Int --
-------------------
procedure Tree_Read_Int (N : out Int) is
N_Bytes : Int_Bytes;
begin
for J in 1 .. 4 loop
N_Bytes (J) := Read_Byte;
end loop;
N := To_Int (N_Bytes);
if Debug_Flag_Tree then
Write_Str ("==> transmitting Int = ");
Write_Int (N);
Write_Eol;
end if;
end Tree_Read_Int;
-------------------
-- Tree_Read_Str --
-------------------
procedure Tree_Read_Str (S : out String_Ptr) is
N : Nat;
begin
Tree_Read_Int (N);
S := new String (1 .. Natural (N));
Tree_Read_Data (S.all (1)'Address, N);
end Tree_Read_Str;
-------------------------
-- Tree_Read_Terminate --
-------------------------
procedure Tree_Read_Terminate is
begin
-- Must be at end of input buffer, so we should get Tree_Format_Error
-- if we try to read one more byte, if not, we have a format error.
declare
B : Byte;
pragma Warnings (Off, B);
begin
B := Read_Byte;
exception
when Tree_Format_Error => return;
end;
raise Tree_Format_Error;
end Tree_Read_Terminate;
---------------------
-- Tree_Write_Bool --
---------------------
procedure Tree_Write_Bool (B : Boolean) is
begin
if Debug_Flag_Tree then
Write_Str ("==> transmitting Boolean = ");
if B then
Write_Str ("True");
else
Write_Str ("False");
end if;
Write_Eol;
end if;
Write_Byte (Boolean'Pos (B));
end Tree_Write_Bool;
---------------------
-- Tree_Write_Char --
---------------------
procedure Tree_Write_Char (C : Character) is
begin
if Debug_Flag_Tree then
Write_Str ("==> transmitting Character = ");
Write_Char (C);
Write_Eol;
end if;
Write_Byte (Character'Pos (C));
end Tree_Write_Char;
---------------------
-- Tree_Write_Data --
---------------------
procedure Tree_Write_Data (Addr : Address; Length : Int) is
type S is array (Pos) of Byte;
-- This is a big array, for which we have to suppress the warning
type SP is access all S;
function To_SP is new Unchecked_Conversion (Address, SP);
Data : constant SP := To_SP (Addr);
-- Pointer to data to be written, converted to array type
IP : Pos := 1;
-- Input buffer pointer, next byte to be processed
NC : Nat range 0 .. Max_Count := 0;
-- Number of bytes of non-compressible sequence
C : Byte;
procedure Write_Non_Compressed_Sequence;
-- Output currently collected sequence of non-compressible data
-----------------------------------
-- Write_Non_Compressed_Sequence --
-----------------------------------
procedure Write_Non_Compressed_Sequence is
begin
if NC > 0 then
Write_Byte (C_Noncomp + Byte (NC));
if Debug_Flag_Tree then
Write_Str ("==> uncompressed: ");
Write_Int (NC);
Write_Str (", starting at ");
Write_Int (IP - NC);
Write_Eol;
end if;
for J in reverse 1 .. NC loop
Write_Byte (Data (IP - J));
end loop;
NC := 0;
end if;
end Write_Non_Compressed_Sequence;
-- Start of processing for Tree_Write_Data
begin
if Debug_Flag_Tree then
Write_Str ("==> transmitting ");
Write_Int (Length);
Write_Str (" data bytes");
Write_Eol;
end if;
-- We write the count at the start, so that we can check it on
-- the corresponding read to make sure that reads and writes match
Tree_Write_Int (Length);
-- Conversion loop
-- IP is index of next input character
-- NC is number of non-compressible bytes saved up
loop
-- If input is completely processed, then we are all done
if IP > Length then
Write_Non_Compressed_Sequence;
return;
end if;
-- Test for compressible sequence, must be at least three identical
-- bytes in a row to be worthwhile compressing.
if IP + 2 <= Length
and then Data (IP) = Data (IP + 1)
and then Data (IP) = Data (IP + 2)
then
Write_Non_Compressed_Sequence;
-- Count length of new compression sequence
C := 3;
IP := IP + 3;
while IP < Length
and then Data (IP) = Data (IP - 1)
and then C < Max_Count
loop
C := C + 1;
IP := IP + 1;
end loop;
-- Output compression sequence
if Data (IP - 1) = 0 then
if Debug_Flag_Tree then
Write_Str ("==> zeroes: ");
Write_Int (Int (C));
Write_Str (", starting at ");
Write_Int (IP - Int (C));
Write_Eol;
end if;
Write_Byte (C_Zeros + C);
elsif Data (IP - 1) = Character'Pos (' ') then
if Debug_Flag_Tree then
Write_Str ("==> spaces: ");
Write_Int (Int (C));
Write_Str (", starting at ");
Write_Int (IP - Int (C));
Write_Eol;
end if;
Write_Byte (C_Spaces + C);
else
if Debug_Flag_Tree then
Write_Str ("==> other char: ");
Write_Int (Int (C));
Write_Str (" (");
Write_Int (Int (Data (IP - 1)));
Write_Char (')');
Write_Str (", starting at ");
Write_Int (IP - Int (C));
Write_Eol;
end if;
Write_Byte (C_Repeat + C);
Write_Byte (Data (IP - 1));
end if;
-- No compression possible here
else
-- Output non-compressed sequence if at maximum length
if NC = Max_Count then
Write_Non_Compressed_Sequence;
end if;
NC := NC + 1;
IP := IP + 1;
end if;
end loop;
end Tree_Write_Data;
---------------------------
-- Tree_Write_Initialize --
---------------------------
procedure Tree_Write_Initialize (Desc : File_Descriptor) is
begin
Bufn := 0;
Tree_FD := Desc;
Set_Standard_Error;
Debug_Flag_Tree := Debug_Flag_5;
end Tree_Write_Initialize;
--------------------
-- Tree_Write_Int --
--------------------
procedure Tree_Write_Int (N : Int) is
N_Bytes : constant Int_Bytes := To_Int_Bytes (N);
begin
if Debug_Flag_Tree then
Write_Str ("==> transmitting Int = ");
Write_Int (N);
Write_Eol;
end if;
for J in 1 .. 4 loop
Write_Byte (N_Bytes (J));
end loop;
end Tree_Write_Int;
--------------------
-- Tree_Write_Str --
--------------------
procedure Tree_Write_Str (S : String_Ptr) is
begin
Tree_Write_Int (S'Length);
Tree_Write_Data (S (1)'Address, S'Length);
end Tree_Write_Str;
--------------------------
-- Tree_Write_Terminate --
--------------------------
procedure Tree_Write_Terminate is
begin
if Bufn > 0 then
Write_Buffer;
end if;
end Tree_Write_Terminate;
------------------
-- Write_Buffer --
------------------
procedure Write_Buffer is
begin
if Integer (Bufn) = Write (Tree_FD, Buf'Address, Integer (Bufn)) then
Bufn := 0;
else
Set_Standard_Error;
Write_Str ("fatal error: disk full");
OS_Exit (2);
end if;
end Write_Buffer;
----------------
-- Write_Byte --
----------------
procedure Write_Byte (B : Byte) is
begin
Bufn := Bufn + 1;
Buf (Bufn) := B;
if Bufn = Buflen then
Write_Buffer;
end if;
end Write_Byte;
end Tree_IO;
|
LedgerHQ/lib-ledger-core | Ada | 13,016 | ads | --
-- Thin wrapper for the simple interface of the SOCI database access library.
--
-- Copyright (C) 2008-2011 Maciej Sobczak
-- Distributed under the Boost Software License, Version 1.0.
-- (See accompanying file LICENSE_1_0.txt or copy at
-- http://www.boost.org/LICENSE_1_0.txt)
with Ada.Calendar;
with Interfaces.C;
private with System;
private with Ada.Finalization;
package SOCI is
--
-- General exception related to database and library usage.
--
Database_Error : exception;
--
-- Session.
--
type Session is tagged limited private;
not overriding
function Make_Session (Connection_String : in String) return Session;
not overriding
procedure Open (This : in out Session; Connection_String : in String);
not overriding
procedure Close (This : in out Session);
not overriding
function Is_Open (This : in Session) return Boolean;
-- Transaction management.
not overriding
procedure Start (This : in Session);
not overriding
procedure Commit (This : in Session);
not overriding
procedure Rollback (This : in Session);
-- Immediate query execution.
not overriding
procedure Execute (This : in Session; Query : in String);
--
-- Connection pool management.
--
type Connection_Pool (Size : Positive) is tagged limited private;
not overriding
procedure Open
(This : in out Connection_Pool;
Position : in Positive;
Connection_String : in String);
not overriding
procedure Close (This : in out Connection_Pool; Position : in Positive);
not overriding
procedure Lease (This : in out Connection_Pool; S : in out Session'Class);
--
-- Statement.
--
type Statement (<>) is tagged limited private;
type Data_State is (Data_Null, Data_Not_Null);
type Into_Position is private;
type Vector_Index is new Natural;
not overriding
function Make_Statement (Sess : in Session'Class) return Statement;
-- Statement preparation and execution.
not overriding
procedure Prepare (This : in Statement; Query : in String);
not overriding
procedure Execute
(This : in Statement;
With_Data_Exchange : in Boolean := False);
not overriding
function Execute
(This : in Statement;
With_Data_Exchange : in Boolean := False) return Boolean;
not overriding
function Fetch (This : in Statement) return Boolean;
not overriding
function Got_Data (This : in Statement) return Boolean;
--
-- Data items handling.
--
-- Database-specific types.
-- These types are most likely identical to standard Integer,
-- Long_Long_Integer and Long_Float, but are defined distinctly
-- to avoid interfacing problems with other compilers.
type DB_Integer is new Interfaces.C.int;
type DB_Long_Long_Integer is new Interfaces.Integer_64;
type DB_Long_Float is new Interfaces.C.double;
-- Creation of single into elements.
not overriding
function Into_String (This : in Statement) return Into_Position;
not overriding
function Into_Integer (This : in Statement) return Into_Position;
not overriding
function Into_Long_Long_Integer (This : in Statement) return Into_Position;
not overriding
function Into_Long_Float (This : in Statement) return Into_Position;
not overriding
function Into_Time (This : in Statement) return Into_Position;
-- Creation of vector into elements.
not overriding
function Into_Vector_String (This : in Statement) return Into_Position;
not overriding
function Into_Vector_Integer (This : in Statement) return Into_Position;
not overriding
function Into_Vector_Long_Long_Integer (This : in Statement) return Into_Position;
not overriding
function Into_Vector_Long_Float (This : in Statement) return Into_Position;
not overriding
function Into_Vector_Time (This : in Statement) return Into_Position;
-- Inspection of single into elements.
not overriding
function Get_Into_State
(This : in Statement;
Position : in Into_Position)
return Data_State;
not overriding
function Get_Into_String
(This : in Statement;
Position : in Into_Position)
return String;
not overriding
function Get_Into_Integer
(This : in Statement;
Position : in Into_Position)
return DB_Integer;
not overriding
function Get_Into_Long_Long_Integer
(This : in Statement;
Position : in Into_Position)
return DB_Long_Long_Integer;
not overriding
function Get_Into_Long_Float
(This : in Statement;
Position : in Into_Position)
return DB_Long_Float;
not overriding
function Get_Into_Time
(This : in Statement;
Position : in Into_Position)
return Ada.Calendar.Time;
-- Inspection of vector into elements.
not overriding
function Get_Into_Vectors_Size (This : in Statement) return Natural;
not overriding
function Into_Vectors_First_Index (This : in Statement) return Vector_Index;
not overriding
function Into_Vectors_Last_Index (This : in Statement) return Vector_Index;
not overriding
procedure Into_Vectors_Resize (This : in Statement; New_Size : in Natural);
not overriding
function Get_Into_Vector_State
(This : in Statement;
Position : in Into_Position;
Index : in Vector_Index)
return Data_State;
not overriding
function Get_Into_Vector_String
(This : in Statement;
Position : in Into_Position;
Index : in Vector_Index)
return String;
not overriding
function Get_Into_Vector_Integer
(This : in Statement;
Position : in Into_Position;
Index : in Vector_Index)
return DB_Integer;
not overriding
function Get_Into_Vector_Long_Long_Integer
(This : in Statement;
Position : in Into_Position;
Index : in Vector_Index)
return DB_Long_Long_Integer;
not overriding
function Get_Into_Vector_Long_Float
(This : in Statement;
Position : in Into_Position;
Index : in Vector_Index)
return DB_Long_Float;
not overriding
function Get_Into_Vector_Time
(This : in Statement;
Position : in Into_Position;
Index : in Vector_Index)
return Ada.Calendar.Time;
-- Creation of single use elements.
not overriding
procedure Use_String (This : in Statement; Name : in String);
not overriding
procedure Use_Integer (This : in Statement; Name : in String);
not overriding
procedure Use_Long_Long_Integer (This : in Statement; Name : in String);
not overriding
procedure Use_Long_Float (This : in Statement; Name : in String);
not overriding
procedure Use_Time (This : in Statement; Name : in String);
-- Creation of vector use elements.
not overriding
procedure Use_Vector_String (This : in Statement; Name : in String);
not overriding
procedure Use_Vector_Integer (This : in Statement; Name : in String);
not overriding
procedure Use_Vector_Long_Long_Integer (This : in Statement; Name : in String);
not overriding
procedure Use_Vector_Long_Float (This : in Statement; Name : in String);
not overriding
procedure Use_Vector_Time (This : in Statement; Name : in String);
-- Modifiers for single use elements.
not overriding
procedure Set_Use_State
(This : in Statement;
Name : in String;
State : in Data_State);
not overriding
procedure Set_Use_String
(This : in Statement;
Name : in String;
Value : in String);
not overriding
procedure Set_Use_Integer
(This : in Statement;
Name : in String;
Value : in DB_Integer);
not overriding
procedure Set_Use_Long_Long_Integer
(This : in Statement;
Name : in String;
Value : in DB_Long_Long_Integer);
not overriding
procedure Set_Use_Long_Float
(This : in Statement;
Name : in String;
Value : in DB_Long_Float);
not overriding
procedure Set_Use_Time
(This : in Statement;
Name : in String;
Value : in Ada.Calendar.Time);
-- Modifiers for vector use elements.
not overriding
function Get_Use_Vectors_Size (This : in Statement) return Natural;
not overriding
function Use_Vectors_First_Index (This : in Statement) return Vector_Index;
not overriding
function Use_Vectors_Last_Index (This : in Statement) return Vector_Index;
not overriding
procedure Use_Vectors_Resize (This : in Statement; New_Size : in Natural);
not overriding
procedure Set_Use_Vector_State
(This : in Statement;
Name : in String;
Index : in Vector_Index;
State : in Data_State);
not overriding
procedure Set_Use_Vector_String
(This : in Statement;
Name : in String;
Index : in Vector_Index;
Value : in String);
not overriding
procedure Set_Use_Vector_Integer
(This : in Statement;
Name : in String;
Index : in Vector_Index;
Value : in DB_Integer);
not overriding
procedure Set_Use_Vector_Long_Long_Integer
(This : in Statement;
Name : in String;
Index : in Vector_Index;
Value : in DB_Long_Long_Integer);
not overriding
procedure Set_Use_Vector_Long_Float
(This : in Statement;
Name : in String;
Index : in Vector_Index;
Value : in DB_Long_Float);
not overriding
procedure Set_Use_Vector_Time
(This : in Statement;
Name : in String;
Index : in Vector_Index;
Value : in Ada.Calendar.Time);
-- Inspection of single use elements.
--
-- Note: Use elements can be modified by the database if they
-- are bound to out and inout parameters of stored procedures
-- (although this is not supported by all database backends).
-- This feature is available only for single use elements.
not overriding
function Get_Use_State
(This : in Statement;
Name : in String)
return Data_State;
not overriding
function Get_Use_String
(This : in Statement;
Name : in String)
return String;
not overriding
function Get_Use_Integer
(This : in Statement;
Name : in String)
return DB_Integer;
not overriding
function Get_Use_Long_Long_Integer
(This : in Statement;
Name : in String)
return DB_Long_Long_Integer;
not overriding
function Get_Use_Long_Float
(This : in Statement;
Name : in String)
return DB_Long_Float;
not overriding
function Get_Use_Time
(This : in Statement;
Name : in String)
return Ada.Calendar.Time;
private
-- Connection pool and supporting types.
type Connection_Array is array (Positive range <>) of Session;
type Used_Array is array (Positive range <>) of Boolean;
-- Protected state for the connection pool.
protected type Connection_Pool_PS (Size : Positive) is
procedure Open (Position : in Positive; Connection_String : in String);
procedure Close (Position : in Positive);
entry Lease (S : in out Session'Class);
procedure Give_Back (Position : in Positive);
private
Connections : Connection_Array (1 .. Size);
Is_Used : Used_Array (1 .. Size) := (others => False);
Available : Boolean := True;
end Connection_Pool_PS;
type Connection_Pool_PS_Ptr is access all Connection_Pool_PS;
type Connection_Pool (Size : Positive) is tagged limited record
Pool : aliased Connection_Pool_PS (Size);
end record;
-- Session and supporting types.
type Session_Handle is new System.Address;
Null_Session_Handle : constant Session_Handle :=
Session_Handle (System.Null_Address);
type Session is new Ada.Finalization.Limited_Controlled with record
Handle : Session_Handle;
Initialized : Boolean := False;
Belongs_To_Pool : Boolean := False;
Pool : Connection_Pool_PS_Ptr;
Position_In_Pool : Positive;
end record;
overriding
procedure Finalize (This : in out Session);
-- Statement and supporting types.
type Statement_Handle is new System.Address;
Null_Statement_Handle : constant Statement_Handle :=
Statement_Handle (System.Null_Address);
type Statement is new Ada.Finalization.Limited_Controlled with record
Handle : Statement_Handle;
Initialized : Boolean := False;
end record;
overriding
procedure Finalize (This : in out Statement);
type Into_Position is new Natural;
end SOCI;
|
AdaCore/libadalang | Ada | 37 | ads | with G_F;
procedure P.F is new G_F;
|
ohenley/ada-util | Ada | 8,716 | ads | -----------------------------------------------------------------------
-- util-encoders -- Encode/Decode streams and strings from one format to another
-- Copyright (C) 2009, 2010, 2011, 2012, 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 Ada.Streams;
with Ada.Finalization;
with Interfaces;
-- === Encoder and Decoders ===
-- The <b>Util.Encoders</b> package defines the <b>Encoder</b> and <b>Decode</b> objects
-- which provide a mechanism to transform a stream from one format into
-- another format.
--
-- ==== Simple encoding and decoding ====
--
package Util.Encoders is
pragma Preelaborate;
Not_Supported : exception;
Encoding_Error : exception;
-- Encoder/decoder for Base64 (RFC 4648)
BASE_64 : constant String := "base64";
-- Encoder/decoder for Base64 (RFC 4648) using the URL alphabet
-- (+ and / are replaced by - and _)
BASE_64_URL : constant String := "base64url";
-- Encoder/decoder for Base16 (RFC 4648)
BASE_16 : constant String := "base16";
HEX : constant String := "hex";
-- Encoder for SHA1 (RFC 3174)
HASH_SHA1 : constant String := "sha1";
-- ------------------------------
-- Encoder context object
-- ------------------------------
-- The <b>Encoder</b> provides operations to encode and decode
-- strings or stream of data from one format to another.
-- The <b>Encoded</b> contains two <b>Transformer</b>
-- which either <i>encodes</i> or <i>decodes</i> the stream.
type Encoder is tagged limited private;
-- Encodes the input string <b>Data</b> using the transformation
-- rules provided by the <b>E</b> encoder.
--
-- Returns the encoded string.
--
-- Raises the <b>Encoding_Error</b> exception if the source string
-- cannot be encoded.
-- Raises the <b>Not_Supported</b> exception if the encoding is not
-- supported.
function Encode (E : in Encoder;
Data : in String) return String;
function Encode_Binary (E : in Encoder;
Data : in Ada.Streams.Stream_Element_Array) return String;
-- Create the encoder object for the specified encoding format.
function Create (Name : in String) return Encoder;
type Decoder is tagged limited private;
-- Decodes the input string <b>Data</b> using the transformation
-- rules provided by the <b>E</b> encoder.
--
-- Returns the encoded string.
--
-- Raises the <b>Encoding_Error</b> exception if the source string
-- cannot be decoded.
-- Raises the <b>Not_Supported</b> exception if the decoding is not
-- supported.
function Decode (E : in Decoder;
Data : in String) return String;
function Decode_Binary (E : in Decoder;
Data : in String) return Ada.Streams.Stream_Element_Array;
-- Create the decoder object for the specified encoding format.
function Create (Name : in String) return Decoder;
-- ------------------------------
-- Stream Transformation interface
-- ------------------------------
-- The <b>Transformer</b> interface defines the operation to transform
-- a stream from one data format to another.
type Transformer is limited interface;
type Transformer_Access is access all Transformer'Class;
-- Transform the input array represented by <b>Data</b> into
-- the output array <b>Into</b>. The transformation made by
-- the object can be of any nature (Hex encoding, Base64 encoding,
-- Hex decoding, Base64 decoding, encryption, compression, ...).
--
-- If the transformer does not have enough room to write the result,
-- it must return in <b>Encoded</b> the index of the last encoded
-- position in the <b>Data</b> array.
--
-- The transformer returns in <b>Last</b> the last valid position
-- in the output array <b>Into</b>.
--
-- The <b>Encoding_Error</b> exception is raised if the input
-- array cannot be transformed.
procedure Transform (E : in out Transformer;
Data : in Ada.Streams.Stream_Element_Array;
Into : out Ada.Streams.Stream_Element_Array;
Last : out Ada.Streams.Stream_Element_Offset;
Encoded : out Ada.Streams.Stream_Element_Offset) is abstract;
-- Finish encoding the input array.
procedure Finish (E : in out Transformer;
Into : in out Ada.Streams.Stream_Element_Array;
Last : in out Ada.Streams.Stream_Element_Offset) is null;
-- Transform the input string <b>Data</b> using the transformation
-- rules provided by the <b>E</b> transformer.
--
-- Returns the transformed string.
--
-- Raises the <b>Encoding_Error</b> exception if the source string
-- cannot be transformed
function Transform (E : in out Transformer'Class;
Data : in String) return String;
-- Transform the input string <b>Data</b> using the transformation
-- rules provided by the <b>E</b> transformer.
--
-- Returns the transformed string.
--
-- Raises the <b>Encoding_Error</b> exception if the source string
-- cannot be transformed
function Transform (E : in out Transformer'Class;
Data : in Ada.Streams.Stream_Element_Array) return String;
function Transform (E : in out Transformer'Class;
Data : in Ada.Streams.Stream_Element_Array)
return Ada.Streams.Stream_Element_Array;
-- Transform the input string <b>Data</b> using the transformation
-- rules provided by the <b>E</b> transformer and return the data in
-- the <b>Into</b> array, setting <b>Last</b> to the last index.
--
-- Raises the <b>Encoding_Error</b> exception if the source string
-- cannot be transformed
procedure Transform (E : in out Transformer'Class;
Data : in String;
Into : out Ada.Streams.Stream_Element_Array;
Last : out Ada.Streams.Stream_Element_Offset);
-- Encode the value represented by <tt>Val</tt> in the stream array <tt>Into</tt> starting
-- at position <tt>Pos</tt> in that array. The value is encoded using LEB128 format, 7-bits
-- at a time until all non zero bits are written. The <tt>Last</tt> parameter is updated
-- to indicate the position of the last valid byte written in <tt>Into</tt>.
procedure Encode_LEB128 (Into : in out Ada.Streams.Stream_Element_Array;
Pos : in Ada.Streams.Stream_Element_Offset;
Val : in Interfaces.Unsigned_64;
Last : out Ada.Streams.Stream_Element_Offset);
-- Decode from the byte array <tt>From</tt> the value represented as LEB128 format starting
-- at position <tt>Pos</tt> in that array. After decoding, the <tt>Last</tt> index is updated
-- to indicate the last position in the byte array.
procedure Decode_LEB128 (From : in Ada.Streams.Stream_Element_Array;
Pos : in Ada.Streams.Stream_Element_Offset;
Val : out Interfaces.Unsigned_64;
Last : out Ada.Streams.Stream_Element_Offset);
private
-- Transform the input data into the target string.
procedure Convert (E : in out Transformer'Class;
Data : in Ada.Streams.Stream_Element_Array;
Into : out String);
type Encoder is new Ada.Finalization.Limited_Controlled with record
Encode : Transformer_Access := null;
end record;
-- Delete the transformers
overriding
procedure Finalize (E : in out Encoder);
type Decoder is new Ada.Finalization.Limited_Controlled with record
Decode : Transformer_Access := null;
end record;
-- Delete the transformers
overriding
procedure Finalize (E : in out Decoder);
end Util.Encoders;
|
godunko/adawebpack | Ada | 4,089 | ads | ------------------------------------------------------------------------------
-- --
-- AdaWebPack --
-- --
------------------------------------------------------------------------------
-- Copyright © 2021-2022, Vadim Godunko --
-- 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 copyright holder nor the names of its --
-- contributors may be used to endorse or promote products derived --
-- from this software without specific prior written permission. --
-- --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR --
-- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
-- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT --
-- LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, --
-- DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY --
-- THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT --
-- (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE --
-- OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
------------------------------------------------------------------------------
-- This package define indicies of known object's methods to be used with
-- helper functions to call object's methods. See WASM.Objects.Methods for
-- more information.
with Interfaces;
package WASM.Methods is
pragma Pure;
type Method_Index is new Interfaces.Unsigned_32;
-- This declaration must be synchronized with list of attributes' name in
-- adawebpack.mjs file.
Bind_Framebuffer : constant := 0;
Bind_Renderbuffer : constant := 1;
Clone_Node : constant := 2;
Create_Buffer : constant := 3;
Create_Framebuffer : constant := 4;
Create_Program : constant := 5;
Create_Renderbuffer : constant := 6;
Create_Texture : constant := 7;
Delete_Framebuffer : constant := 8;
Framebuffer_Renderbuffer : constant := 9;
Framebuffer_Texture_2D : constant := 10;
Get : constant := 11;
Get_Element_By_Id : constant := 12;
Has : constant := 13;
Named_Item : constant := 14;
Renderbuffer_Storage : constant := 15;
Send : constant := 16;
Set : constant := 17;
Tex_Parameteri : constant := 18;
To_String : constant := 19;
end WASM.Methods;
|
reznikmm/matreshka | Ada | 3,754 | 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.Presentation_Start_Page_Attributes is
pragma Preelaborate;
type ODF_Presentation_Start_Page_Attribute is limited interface
and XML.DOM.Attributes.DOM_Attribute;
type ODF_Presentation_Start_Page_Attribute_Access is
access all ODF_Presentation_Start_Page_Attribute'Class
with Storage_Size => 0;
end ODF.DOM.Presentation_Start_Page_Attributes;
|
jhumphry/auto_counters | Ada | 5,066 | adb | -- kvflyweight_example.adb
-- An example of using the KVFlyweight package
-- Copyright (c) 2016-2023, James Humphry
--
-- Permission to use, copy, modify, and/or distribute this software for any
-- purpose with or without fee is hereby granted, provided that the above
-- copyright notice and this permission notice appear in all copies.
--
-- THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
-- REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
-- AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
-- INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
-- LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
-- OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
-- PERFORMANCE OF THIS SOFTWARE.
with Ada.Text_IO;
use Ada.Text_IO;
with Ada.Strings.Hash;
with Basic_Refcounted_KVFlyweights;
-- with Basic_Untracked_KVFlyweights;
-- with Protected_Refcounted_KVFlyweights;
-- with Protected_Untracked_KVFlyweights;
procedure KVFlyweight_Example is
type String_Ptr is access String;
function Make_String_Value (K : in String) return String_Ptr is
begin
return new String'("VALUE: " & K);
end Make_String_Value;
package String_KVFlyweights is
new Basic_Refcounted_KVFlyweights(Key => String,
Value => String,
Value_Access => String_Ptr,
Factory => Make_String_Value,
Hash => Ada.Strings.Hash,
Capacity => 16);
-- By commenting out the definition above and uncommenting one of the
-- definitions below, this example can use one of the other versions of the
-- Flyweights with no other changes required. The gnatmem tool can be used
-- to demonstrate the difference between the reference-counted and untracked
-- versions.
-- package String_KVFlyweights is
-- new Basic_Untracked_KVFlyweights(Key => String,
-- Value => String,
-- Value_Access => String_Ptr,
-- Factory => Make_String_Value,
-- Hash => Ada.Strings.Hash,
-- Capacity => 16);
-- package String_KVFlyweights is
-- new Protected_Refcounted_KVFlyweights(Key => String,
-- Value => String,
-- Value_Access => String_Ptr,
-- Factory => Make_String_Value,
-- Hash => Ada.Strings.Hash,
-- Capacity => 16);
-- package String_KVFlyweights is
-- new Protected_Untracked_KVFlyweights(Key => String,
-- Value => String,
-- Value_Access => String_Ptr,
-- Factory => Make_String_Value,
-- Hash => Ada.Strings.Hash,
-- Capacity => 16);
use String_KVFlyweights;
Resources : aliased KVFlyweight;
HelloWorld : constant Value_Ptr
:= Insert_Ptr (F => Resources, K => "Hello, World!");
begin
Put_Line("An example of using the KVFlyweights package."); New_Line;
Put_Line("The key string ""Hello, World!"" has been added to the Resources");
Put_Line("Retrieving value string via pointer HelloWorld: " &
HelloWorld.P);
Put_Line("Adding the same key string again..."); Flush;
declare
HelloWorld2: constant Value_Ref
:= Insert_Ref (F => Resources, K => "Hello, World!");
begin
Put_Line("Retrieving value string via reference HelloWorld2: " &
HelloWorld2);
Put_Line("Changing the comma to a colon via HelloWorld2");
HelloWorld2(13) := ':';
Put_Line("Now HelloWorld and HelloWorld2 should both have altered, as " &
"they should both point to the same string");
Put_Line("Retrieving string value via pointer HelloWorld: " &
HelloWorld.P);
Put_Line("Retrieving string value via reference HelloWorld2: " &
HelloWorld2); Flush;
declare
HelloWorld3 : constant Value_Ptr
:= Make_Ptr (HelloWorld2);
begin
Put_Line("Make a pointer HelloWorld3 from ref HelloWorld2: " &
HelloWorld3.P); Flush;
end;
end;
Put_Line("Now HelloWorld2 and HelloWorld3 are out of scope.");
Put_Line("HelloWorld should still point to the same string value: " &
HelloWorld.P);
Flush;
end KVFlyweight_Example;
|
jhumphry/auto_counters | Ada | 6,367 | adb | -- flyweights-refcounted_ptrs.adb
-- A package of reference-counting generalised references which point to
-- resources inside a Flyweight
-- Copyright (c) 2016-2023, James Humphry
--
-- Permission to use, copy, modify, and/or distribute this software for any
-- purpose with or without fee is hereby granted, provided that the above
-- copyright notice and this permission notice appear in all copies.
--
-- THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
-- REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
-- AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
-- INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
-- LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
-- OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
-- PERFORMANCE OF THIS SOFTWARE.
pragma Profile (No_Implementation_Extensions);
with Ada.Unchecked_Conversion;
package body Flyweights.Refcounted_Ptrs is
type Access_Element is access all Element;
function Access_Element_To_Element_Access is
new Ada.Unchecked_Conversion(Source => Access_Element,
Target => Element_Access);
subtype Hash_Type is Ada.Containers.Hash_Type;
----------------------------
-- Refcounted_Element_Ptr --
----------------------------
function P (P : Refcounted_Element_Ptr) return E_Ref is
(E_Ref'(E => P.E));
function Get (P : Refcounted_Element_Ptr) return Element_Access is
(P.E);
function Make_Ref (P : Refcounted_Element_Ptr'Class)
return Refcounted_Element_Ref is
begin
Flyweight_Hashtables.Increment(F => P.Containing_Flyweight.all,
Bucket => P.Containing_Bucket,
Data_Ptr => P.E);
return Refcounted_Element_Ref'(Ada.Finalization.Controlled
with E => P.E,
Containing_Flyweight => P.Containing_Flyweight,
Containing_Bucket => P.Containing_Bucket,
Underlying_Element => P.E);
end Make_Ref;
function Insert_Ptr (F : aliased in out Flyweight_Hashtables.Flyweight;
E : in out Element_Access) return Refcounted_Element_Ptr is
Bucket : Hash_Type ;
begin
Flyweight_Hashtables.Insert (F => F,
Bucket => Bucket,
Data_Ptr => E);
return Refcounted_Element_Ptr'(Ada.Finalization.Controlled
with E => E,
Containing_Flyweight => F'Unchecked_Access,
Containing_Bucket => Bucket);
end Insert_Ptr;
overriding procedure Adjust (Object : in out Refcounted_Element_Ptr) is
begin
if Object.E /= null and Object.Containing_Flyweight /= null then
Flyweight_Hashtables.Increment(F => Object.Containing_Flyweight.all,
Bucket => Object.Containing_Bucket,
Data_Ptr => Object.E);
end if;
end Adjust;
overriding procedure Finalize (Object : in out Refcounted_Element_Ptr) is
begin
if Object.E /= null and Object.Containing_Flyweight /= null then
Flyweight_Hashtables.Remove(F => Object.Containing_Flyweight.all,
Bucket => Object.Containing_Bucket,
Data_Ptr => Object.E);
Object.Containing_Flyweight := null;
end if;
end Finalize;
----------------------------
-- Refcounted_Element_Ref --
----------------------------
function Make_Ptr (R : Refcounted_Element_Ref'Class)
return Refcounted_Element_Ptr is
begin
Flyweight_Hashtables.Increment(F => R.Containing_Flyweight.all,
Bucket => R.Containing_Bucket,
Data_Ptr => R.Underlying_Element);
return Refcounted_Element_Ptr'(Ada.Finalization.Controlled
with E => R.Underlying_Element,
Containing_Flyweight => R.Containing_Flyweight,
Containing_Bucket => R.Containing_Bucket);
end Make_Ptr;
function Get (P : Refcounted_Element_Ref) return Element_Access is
(P.Underlying_Element);
function Insert_Ref (F : aliased in out Flyweight_Hashtables.Flyweight;
E : in out Element_Access) return Refcounted_Element_Ref is
Bucket : Hash_Type ;
begin
Flyweight_Hashtables.Insert (F => F,
Bucket => Bucket,
Data_Ptr => E);
return Refcounted_Element_Ref'(Ada.Finalization.Controlled
with E => E,
Containing_Flyweight => F'Unchecked_Access,
Containing_Bucket => Bucket,
Underlying_Element => E);
end Insert_Ref;
overriding procedure Initialize (Object : in out Refcounted_Element_Ref) is
begin
raise Program_Error
with "Refcounted_Element_Ref should not be created outside the package";
end Initialize;
overriding procedure Adjust (Object : in out Refcounted_Element_Ref) is
begin
if Object.Containing_Flyweight /= null then
Flyweight_Hashtables.Increment(F => Object.Containing_Flyweight.all,
Bucket => Object.Containing_Bucket,
Data_Ptr => Object.Underlying_Element);
end if;
end Adjust;
overriding procedure Finalize (Object : in out Refcounted_Element_Ref) is
begin
if Object.Containing_Flyweight /= null then
Flyweight_Hashtables.Remove(F => Object.Containing_Flyweight.all,
Bucket => Object.Containing_Bucket,
Data_Ptr => Object.Underlying_Element);
Object.Containing_Flyweight := null;
end if;
end Finalize;
end Flyweights.Refcounted_Ptrs;
|
jrcarter/Ada_GUI | Ada | 5,967 | adb | -- --
-- package Strings_Edit.Quoted Copyright (c) Dmitry A. Kazakov --
-- Implementation Luebeck --
-- Winter, 2004 --
-- --
-- Last revision : 21:03 21 Apr 2009 --
-- --
-- This library is free software; you can redistribute it and/or --
-- modify it under the terms of the GNU General Public License as --
-- published by the Free Software Foundation; either version 2 of --
-- the License, or (at your option) any later version. This library --
-- is distributed in the hope that it will be useful, but WITHOUT --
-- ANY WARRANTY; without even the implied warranty of --
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU --
-- General Public License for more details. You should have --
-- received a copy of the GNU General Public License along with --
-- this library; if not, write to the Free Software Foundation, --
-- Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. --
-- --
-- As a special exception, if other files instantiate generics from --
-- this unit, or you link this unit with other files to produce an --
-- executable, this unit does not by itself cause the resulting --
-- executable to be covered by the GNU General Public License. This --
-- exception does not however invalidate any other reasons why the --
-- executable file might be covered by the GNU Public License. --
--____________________________________________________________________--
with Ada.IO_Exceptions; use Ada.IO_Exceptions;
with Strings_Edit.Fields; use Strings_Edit.Fields;
package body Strings_Edit.Quoted is
function Get_Quoted_Length
( Source : String;
Pointer : access Integer;
Mark : Character := '"'
) return Natural is
Index : Integer := Pointer.all;
Length : Natural := 0;
begin
if Index < Source'First or else Index > Source'Last + 1 then
raise Layout_Error;
end if;
if Index > Source'Last or else Source (Index) /= Mark then
raise Data_Error;
end if;
Index := Index + 1;
loop
if Index > Source'Last then
raise Data_Error;
end if;
if Source (Index) = Mark then
Index := Index + 1;
exit when
Index > Source'Last or else Source (Index) /= Mark;
end if;
Length := Length + 1;
Index := Index + 1;
end loop;
Pointer.all := Index;
return Length;
end Get_Quoted_Length;
function Get_Quoted
( Source : String;
Pointer : access Integer;
Mark : Character := '"'
) return String is
Result : String (1..Get_Quoted_Length (Source, Pointer, Mark));
Index : Integer := Pointer.all - 2;
begin
for Item in reverse Result'Range loop
Result (Item) := Source (Index);
if Result (Item) = Mark then
Index := Index - 2;
else
Index := Index - 1;
end if;
end loop;
return Result;
end Get_Quoted;
procedure Put_Quoted
( Destination : in out String;
Pointer : in out Integer;
Text : String;
Mark : Character := '"';
Field : Natural := 0;
Justify : Alignment := Left;
Fill : Character := ' '
) is
Out_Field : constant Natural :=
Get_Output_Field (Destination, Pointer, Field);
subtype Output is String (Pointer..Pointer + Out_Field - 1);
Result : Output renames
Destination (Pointer..Pointer + Out_Field - 1);
Index : Integer := Pointer;
begin
Result (Index) := Mark;
Index := Index + 1;
for Item in Text'Range loop
if Index >= Result'Last then
raise Layout_Error;
end if;
Result (Index) := Text (Item);
Index := Index + 1;
if Text (Item) = Mark then
Result (Index) := Mark;
Index := Index + 1;
end if;
end loop;
if Index > Result'Last then
raise Layout_Error;
end if;
Result (Index) := Mark;
Index := Index + 1;
Adjust_Output_Field
( Destination,
Pointer,
Index,
Out_Field,
Field,
Justify,
Fill
);
end Put_Quoted;
function Quote (Text : String; Mark : Character := '"')
return String is
Length : Natural := Text'Length + 2;
begin
for Index in Text'Range loop
if Text (Index) = Mark then
Length := Length + 1;
end if;
end loop;
declare
Result : String (1..Length);
Pointer : Positive := Result'First;
begin
Result (Pointer) := Mark;
Pointer := Pointer + 1;
for Index in Text'Range loop
if Text (Index) = Mark then
Result (Pointer) := Mark;
Result (Pointer + 1) := Mark;
Pointer := Pointer + 2;
else
Result (Pointer) := Text (Index);
Pointer := Pointer + 1;
end if;
end loop;
Result (Pointer) := Mark;
return Result;
end;
end Quote;
end Strings_Edit.Quoted;
|
sungyeon/drake | Ada | 2,504 | adb | with Ada.Strings.Naked_Maps.Case_Folding;
function Ada.Strings.Generic_Less_Case_Insensitive (Left, Right : String_Type)
return Boolean
is
Mapping : constant not null Naked_Maps.Character_Mapping_Access :=
Naked_Maps.Case_Folding.Case_Folding_Map;
Left_Last : Natural := Left'First - 1;
Right_Last : Natural := Right'First - 1;
begin
while Left_Last < Left'Last and then Right_Last < Right'Last loop
declare
Left_Index : constant Positive := Left_Last + 1;
Left_Code : Wide_Wide_Character;
Left_Is_Illegal_Sequence : Boolean;
Right_Index : constant Positive := Right_Last + 1;
Right_Code : Wide_Wide_Character;
Right_Is_Illegal_Sequence : Boolean;
begin
Get (
Left (Left_Index .. Left'Last),
Left_Last,
Left_Code,
Left_Is_Illegal_Sequence);
Get (
Right (Right_Index .. Right'Last),
Right_Last,
Right_Code,
Right_Is_Illegal_Sequence);
if not Left_Is_Illegal_Sequence then
if not Right_Is_Illegal_Sequence then
-- Left and Right are legal
Left_Code := Naked_Maps.Value (Mapping.all, Left_Code);
Right_Code := Naked_Maps.Value (Mapping.all, Right_Code);
if Left_Code < Right_Code then
return True;
elsif Left_Code > Right_Code then
return False;
end if;
else
-- Left is legal, Right is illegal
return True; -- legal < illegal
end if;
else
if not Right_Is_Illegal_Sequence then
-- Left is illegal, Right is legal
return False; -- illegal > legal
else
-- Left and Right are illegal
declare
Left_Seq : String_Type
renames Left (Left_Index .. Left_Last);
Right_Seq : String_Type
renames Right (Right_Index .. Right_Last);
begin
if Left_Seq < Right_Seq then
return True;
elsif Left_Seq > Right_Seq then
return False;
end if;
end;
end if;
end if;
end;
end loop;
return (Left_Last >= Left'Last) and then (Right_Last < Right'Last);
end Ada.Strings.Generic_Less_Case_Insensitive;
|
ekoeppen/STM32_Generic_Ada_Drivers | Ada | 704 | ads | with STM32GD.GPIO;
with STM32GD.GPIO.Pin;
with STM32GD.I2C;
with STM32GD.I2C.Peripheral;
with Drivers.Si7006;
package Peripherals is
package GPIO renames STM32GD.GPIO;
package SCL is new GPIO.Pin (Pin => GPIO.Pin_6, Port => GPIO.Port_B,
Mode => GPIO.Mode_AF, Alternate_Function => 1);
package SCL_OUT is new GPIO.Pin (Pin => GPIO.Pin_6, Port => GPIO.Port_B,
Mode => GPIO.Mode_Out);
package SDA is new GPIO.Pin (Pin => GPIO.Pin_7, Port => GPIO.Port_B,
Mode => GPIO.Mode_AF, Alternate_Function => 1);
package I2C is new STM32GD.I2C.Peripheral (
I2C => STM32GD.I2C.I2C_1);
package Si7006 is new Drivers.Si7006 (I2C => I2C);
procedure Init;
end Peripherals;
|
ekoeppen/STM32_Generic_Ada_Drivers | Ada | 1,714 | adb | with STM32_SVD.GPIO; use STM32_SVD.GPIO;
with STM32_SVD.SYSCFG; use STM32_SVD.SYSCFG;
with STM32GD.EXTI;
with STM32GD.EXTI.IRQ;
package body STM32GD.GPIO_IRQ is
function Interrupt_Line_Number return STM32GD.EXTI.External_Line_Number is
begin
return STM32GD.EXTI.External_Line_Number'Val (Integer (Pin.Pin));
end Interrupt_Line_Number;
procedure Wait_For_Trigger is
begin
STM32GD.EXTI.IRQ.IRQ_Handler.Wait;
end Wait_For_Trigger;
procedure Clear_Trigger is
begin
STM32GD.EXTI.IRQ.IRQ_Handler.Reset_Status (Interrupt_Line_Number);
end Clear_Trigger;
function Triggered return Boolean is
begin
return STM32GD.EXTI.IRQ.IRQ_Handler.Status (Interrupt_Line_Number);
end Triggered;
procedure Cancel_Wait is
begin
STM32GD.EXTI.IRQ.IRQ_Handler.Cancel;
end Cancel_Wait;
procedure Configure_Trigger (Event : Boolean := False; Rising : Boolean := False; Falling : Boolean := False) is
use STM32GD.EXTI;
Line : constant External_Line_Number := External_Line_Number'Val (Integer (Pin.Pin));
T : External_Triggers;
begin
Connect_External_Interrupt (Pin.Pin, Pin.Port_Index);
if Event then
if Rising and Falling then T := Event_Rising_Falling_Edge;
elsif Rising then T := Event_Rising_Edge;
else T := Event_Falling_Edge;
Enable_External_Event (Line, T);
end if;
else
if Rising and Falling then T := Interrupt_Rising_Falling_Edge;
elsif Rising then T := Interrupt_Rising_Edge;
else T := Interrupt_Falling_Edge;
end if;
Enable_External_Interrupt (Line, T);
end if;
end Configure_Trigger;
end STM32GD.GPIO_IRQ;
|
Rodeo-McCabe/orka | Ada | 2,193 | adb | -- SPDX-License-Identifier: Apache-2.0
--
-- Copyright (c) 2016 onox <[email protected]>
--
-- Licensed under the Apache License, Version 2.0 (the "License");
-- you may not use this file except in compliance with the License.
-- You may obtain a copy of the License at
--
-- http://www.apache.org/licenses/LICENSE-2.0
--
-- Unless required by applicable law or agreed to in writing, software
-- distributed under the License is distributed on an "AS IS" BASIS,
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-- See the License for the specific language governing permissions and
-- limitations under the License.
package body Orka.SIMD.SSE.Singles.Swizzle is
Mask_1_0_1_0 : constant Unsigned_32 := 1 * 64 or 0 * 16 or 1 * 4 or 0;
Mask_3_2_3_2 : constant Unsigned_32 := 3 * 64 or 2 * 16 or 3 * 4 or 2;
Mask_2_0_2_0 : constant Unsigned_32 := 2 * 64 or 0 * 16 or 2 * 4 or 0;
Mask_3_1_3_1 : constant Unsigned_32 := 3 * 64 or 1 * 16 or 3 * 4 or 1;
procedure Transpose (Matrix : in out m128_Array) is
M0 : constant m128 := Unpack_Low (Matrix (X), Matrix (Y));
M1 : constant m128 := Unpack_Low (Matrix (Z), Matrix (W));
M2 : constant m128 := Unpack_High (Matrix (X), Matrix (Y));
M3 : constant m128 := Unpack_High (Matrix (Z), Matrix (W));
begin
Matrix (X) := Move_LH (M0, M1);
Matrix (Y) := Move_HL (M1, M0);
Matrix (Z) := Move_LH (M2, M3);
Matrix (W) := Move_HL (M3, M2);
end Transpose;
function Transpose (Matrix : m128_Array) return m128_Array is
Result : m128_Array;
M0 : constant m128 := Shuffle (Matrix (X), Matrix (Y), Mask_1_0_1_0);
M1 : constant m128 := Shuffle (Matrix (Z), Matrix (W), Mask_1_0_1_0);
M2 : constant m128 := Shuffle (Matrix (X), Matrix (Y), Mask_3_2_3_2);
M3 : constant m128 := Shuffle (Matrix (Z), Matrix (W), Mask_3_2_3_2);
begin
Result (X) := Shuffle (M0, M1, Mask_2_0_2_0);
Result (Y) := Shuffle (M0, M1, Mask_3_1_3_1);
Result (Z) := Shuffle (M2, M3, Mask_2_0_2_0);
Result (W) := Shuffle (M2, M3, Mask_3_1_3_1);
return Result;
end Transpose;
end Orka.SIMD.SSE.Singles.Swizzle;
|
reznikmm/matreshka | Ada | 14,380 | adb | ------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- Ada Modeling Framework --
-- --
-- Runtime Library Component --
-- --
------------------------------------------------------------------------------
-- --
-- Copyright © 2011-2012, Vadim Godunko <[email protected]> --
-- All rights reserved. --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions --
-- are met: --
-- --
-- * Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- --
-- * Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in the --
-- documentation and/or other materials provided with the distribution. --
-- --
-- * Neither the name of the Vadim Godunko, IE nor the names of its --
-- contributors may be used to endorse or promote products derived from --
-- this software without specific prior written permission. --
-- --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR --
-- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
-- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED --
-- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR --
-- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF --
-- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING --
-- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS --
-- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
-- --
------------------------------------------------------------------------------
-- $Revision$ $Date$
------------------------------------------------------------------------------
with AMF.Elements;
with AMF.Internals.Element_Collections;
with AMF.Internals.Helpers;
with AMF.Internals.Tables.UML_Attributes;
with AMF.Visitors.UML_Iterators;
with AMF.Visitors.UML_Visitors;
with League.Strings.Internals;
with Matreshka.Internals.Strings;
package body AMF.Internals.UML_Duration_Observations is
-------------------
-- Enter_Element --
-------------------
overriding procedure Enter_Element
(Self : not null access constant UML_Duration_Observation_Proxy;
Visitor : in out AMF.Visitors.Abstract_Visitor'Class;
Control : in out AMF.Visitors.Traverse_Control) is
begin
if Visitor in AMF.Visitors.UML_Visitors.UML_Visitor'Class then
AMF.Visitors.UML_Visitors.UML_Visitor'Class
(Visitor).Enter_Duration_Observation
(AMF.UML.Duration_Observations.UML_Duration_Observation_Access (Self),
Control);
end if;
end Enter_Element;
-------------------
-- Leave_Element --
-------------------
overriding procedure Leave_Element
(Self : not null access constant UML_Duration_Observation_Proxy;
Visitor : in out AMF.Visitors.Abstract_Visitor'Class;
Control : in out AMF.Visitors.Traverse_Control) is
begin
if Visitor in AMF.Visitors.UML_Visitors.UML_Visitor'Class then
AMF.Visitors.UML_Visitors.UML_Visitor'Class
(Visitor).Leave_Duration_Observation
(AMF.UML.Duration_Observations.UML_Duration_Observation_Access (Self),
Control);
end if;
end Leave_Element;
-------------------
-- Visit_Element --
-------------------
overriding procedure Visit_Element
(Self : not null access constant UML_Duration_Observation_Proxy;
Iterator : in out AMF.Visitors.Abstract_Iterator'Class;
Visitor : in out AMF.Visitors.Abstract_Visitor'Class;
Control : in out AMF.Visitors.Traverse_Control) is
begin
if Iterator in AMF.Visitors.UML_Iterators.UML_Iterator'Class then
AMF.Visitors.UML_Iterators.UML_Iterator'Class
(Iterator).Visit_Duration_Observation
(Visitor,
AMF.UML.Duration_Observations.UML_Duration_Observation_Access (Self),
Control);
end if;
end Visit_Element;
---------------
-- Get_Event --
---------------
overriding function Get_Event
(Self : not null access constant UML_Duration_Observation_Proxy)
return AMF.UML.Named_Elements.Collections.Set_Of_UML_Named_Element is
begin
return
AMF.UML.Named_Elements.Collections.Wrap
(AMF.Internals.Element_Collections.Wrap
(AMF.Internals.Tables.UML_Attributes.Internal_Get_Event
(Self.Element)));
end Get_Event;
---------------------
-- Get_First_Event --
---------------------
overriding function Get_First_Event
(Self : not null access constant UML_Duration_Observation_Proxy)
return AMF.Boolean_Collections.Set_Of_Boolean is
begin
raise Program_Error;
return Get_First_Event (Self);
end Get_First_Event;
---------------------------
-- Get_Client_Dependency --
---------------------------
overriding function Get_Client_Dependency
(Self : not null access constant UML_Duration_Observation_Proxy)
return AMF.UML.Dependencies.Collections.Set_Of_UML_Dependency is
begin
return
AMF.UML.Dependencies.Collections.Wrap
(AMF.Internals.Element_Collections.Wrap
(AMF.Internals.Tables.UML_Attributes.Internal_Get_Client_Dependency
(Self.Element)));
end Get_Client_Dependency;
-------------------------
-- Get_Name_Expression --
-------------------------
overriding function Get_Name_Expression
(Self : not null access constant UML_Duration_Observation_Proxy)
return AMF.UML.String_Expressions.UML_String_Expression_Access is
begin
return
AMF.UML.String_Expressions.UML_String_Expression_Access
(AMF.Internals.Helpers.To_Element
(AMF.Internals.Tables.UML_Attributes.Internal_Get_Name_Expression
(Self.Element)));
end Get_Name_Expression;
-------------------------
-- Set_Name_Expression --
-------------------------
overriding procedure Set_Name_Expression
(Self : not null access UML_Duration_Observation_Proxy;
To : AMF.UML.String_Expressions.UML_String_Expression_Access) is
begin
AMF.Internals.Tables.UML_Attributes.Internal_Set_Name_Expression
(Self.Element,
AMF.Internals.Helpers.To_Element
(AMF.Elements.Element_Access (To)));
end Set_Name_Expression;
-------------------
-- Get_Namespace --
-------------------
overriding function Get_Namespace
(Self : not null access constant UML_Duration_Observation_Proxy)
return AMF.UML.Namespaces.UML_Namespace_Access is
begin
return
AMF.UML.Namespaces.UML_Namespace_Access
(AMF.Internals.Helpers.To_Element
(AMF.Internals.Tables.UML_Attributes.Internal_Get_Namespace
(Self.Element)));
end Get_Namespace;
------------------------
-- Get_Qualified_Name --
------------------------
overriding function Get_Qualified_Name
(Self : not null access constant UML_Duration_Observation_Proxy)
return AMF.Optional_String is
begin
declare
use type Matreshka.Internals.Strings.Shared_String_Access;
Aux : constant Matreshka.Internals.Strings.Shared_String_Access
:= AMF.Internals.Tables.UML_Attributes.Internal_Get_Qualified_Name (Self.Element);
begin
if Aux = null then
return (Is_Empty => True);
else
return (False, League.Strings.Internals.Create (Aux));
end if;
end;
end Get_Qualified_Name;
-----------------------------------
-- Get_Owning_Template_Parameter --
-----------------------------------
overriding function Get_Owning_Template_Parameter
(Self : not null access constant UML_Duration_Observation_Proxy)
return AMF.UML.Template_Parameters.UML_Template_Parameter_Access is
begin
return
AMF.UML.Template_Parameters.UML_Template_Parameter_Access
(AMF.Internals.Helpers.To_Element
(AMF.Internals.Tables.UML_Attributes.Internal_Get_Owning_Template_Parameter
(Self.Element)));
end Get_Owning_Template_Parameter;
-----------------------------------
-- Set_Owning_Template_Parameter --
-----------------------------------
overriding procedure Set_Owning_Template_Parameter
(Self : not null access UML_Duration_Observation_Proxy;
To : AMF.UML.Template_Parameters.UML_Template_Parameter_Access) is
begin
AMF.Internals.Tables.UML_Attributes.Internal_Set_Owning_Template_Parameter
(Self.Element,
AMF.Internals.Helpers.To_Element
(AMF.Elements.Element_Access (To)));
end Set_Owning_Template_Parameter;
----------------------------
-- Get_Template_Parameter --
----------------------------
overriding function Get_Template_Parameter
(Self : not null access constant UML_Duration_Observation_Proxy)
return AMF.UML.Template_Parameters.UML_Template_Parameter_Access is
begin
return
AMF.UML.Template_Parameters.UML_Template_Parameter_Access
(AMF.Internals.Helpers.To_Element
(AMF.Internals.Tables.UML_Attributes.Internal_Get_Template_Parameter
(Self.Element)));
end Get_Template_Parameter;
----------------------------
-- Set_Template_Parameter --
----------------------------
overriding procedure Set_Template_Parameter
(Self : not null access UML_Duration_Observation_Proxy;
To : AMF.UML.Template_Parameters.UML_Template_Parameter_Access) is
begin
AMF.Internals.Tables.UML_Attributes.Internal_Set_Template_Parameter
(Self.Element,
AMF.Internals.Helpers.To_Element
(AMF.Elements.Element_Access (To)));
end Set_Template_Parameter;
-------------------------
-- All_Owning_Packages --
-------------------------
overriding function All_Owning_Packages
(Self : not null access constant UML_Duration_Observation_Proxy)
return AMF.UML.Packages.Collections.Set_Of_UML_Package is
begin
-- Generated stub: replace with real body!
pragma Compile_Time_Warning (Standard.True, "All_Owning_Packages unimplemented");
raise Program_Error with "Unimplemented procedure UML_Duration_Observation_Proxy.All_Owning_Packages";
return All_Owning_Packages (Self);
end All_Owning_Packages;
-----------------------------
-- Is_Distinguishable_From --
-----------------------------
overriding function Is_Distinguishable_From
(Self : not null access constant UML_Duration_Observation_Proxy;
N : AMF.UML.Named_Elements.UML_Named_Element_Access;
Ns : AMF.UML.Namespaces.UML_Namespace_Access)
return Boolean is
begin
-- Generated stub: replace with real body!
pragma Compile_Time_Warning (Standard.True, "Is_Distinguishable_From unimplemented");
raise Program_Error with "Unimplemented procedure UML_Duration_Observation_Proxy.Is_Distinguishable_From";
return Is_Distinguishable_From (Self, N, Ns);
end Is_Distinguishable_From;
---------------
-- Namespace --
---------------
overriding function Namespace
(Self : not null access constant UML_Duration_Observation_Proxy)
return AMF.UML.Namespaces.UML_Namespace_Access is
begin
-- Generated stub: replace with real body!
pragma Compile_Time_Warning (Standard.True, "Namespace unimplemented");
raise Program_Error with "Unimplemented procedure UML_Duration_Observation_Proxy.Namespace";
return Namespace (Self);
end Namespace;
------------------------
-- Is_Compatible_With --
------------------------
overriding function Is_Compatible_With
(Self : not null access constant UML_Duration_Observation_Proxy;
P : AMF.UML.Parameterable_Elements.UML_Parameterable_Element_Access)
return Boolean is
begin
-- Generated stub: replace with real body!
pragma Compile_Time_Warning (Standard.True, "Is_Compatible_With unimplemented");
raise Program_Error with "Unimplemented procedure UML_Duration_Observation_Proxy.Is_Compatible_With";
return Is_Compatible_With (Self, P);
end Is_Compatible_With;
---------------------------
-- Is_Template_Parameter --
---------------------------
overriding function Is_Template_Parameter
(Self : not null access constant UML_Duration_Observation_Proxy)
return Boolean is
begin
-- Generated stub: replace with real body!
pragma Compile_Time_Warning (Standard.True, "Is_Template_Parameter unimplemented");
raise Program_Error with "Unimplemented procedure UML_Duration_Observation_Proxy.Is_Template_Parameter";
return Is_Template_Parameter (Self);
end Is_Template_Parameter;
end AMF.Internals.UML_Duration_Observations;
|
tum-ei-rcs/StratoX | Ada | 6,693 | adb | ------------------------------------------------------------------------------
-- --
-- Copyright (C) 2015, AdaCore --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions are --
-- met: --
-- 1. Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- 2. Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in --
-- the documentation and/or other materials provided with the --
-- distribution. --
-- 3. Neither the name of STMicroelectronics nor the names of its --
-- contributors may be used to endorse or promote products derived --
-- from this software without specific prior written permission. --
-- --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR --
-- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
-- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT --
-- LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, --
-- DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY --
-- THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT --
-- (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE --
-- OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
-- --
-- --
-- This file is based on: --
-- --
-- @file stm32f429i_discovery_ts.c --
-- @author MCD Application Team --
-- @version V1.1.0 --
-- @date 19-June-2014 --
-- @brief This file provides a set of functions needed to manage Touch --
-- screen available with STMPE811 IO Expander device mounted on --
-- STM32F429I-Discovery Kit. --
-- --
-- COPYRIGHT(c) 2014 STMicroelectronics --
------------------------------------------------------------------------------
with STM32.Board;
with STM32.I2C; use STM32.I2C;
with STM32.GPIO; use STM32.GPIO;
with STM32.Device; use STM32.Device;
with HAL.Touch_Panel; use HAL.Touch_Panel;
with HAL.I2C;
with STMPE811; use STMPE811;
package body Touch_Panel_STMPE811 is
use type HAL.I2C.I2C_Status;
SCL : GPIO_Point renames PA8;
SCL_AF : constant GPIO_Alternate_Function := GPIO_AF_I2C;
SDA : GPIO_Point renames PC9;
SDA_AF : constant GPIO_Alternate_Function := GPIO_AF_I2C;
procedure TP_Ctrl_Lines;
procedure TP_I2C_Config;
-------------------
-- TP_Ctrl_Lines --
-------------------
procedure TP_Ctrl_Lines is
GPIO_Conf : GPIO_Port_Configuration;
begin
Enable_Clock (GPIO_Points'(SDA, SCL));
Enable_Clock (TP_I2C);
SCL.Configure_Alternate_Function (SCL_AF);
SDA.Configure_Alternate_Function (SDA_AF);
GPIO_Conf.Speed := Speed_25MHz;
GPIO_Conf.Mode := Mode_AF;
GPIO_Conf.Output_Type := Open_Drain;
GPIO_Conf.Resistors := Floating;
Configure_IO (GPIO_Points'(SCL, SDA), GPIO_Conf);
SCL.Lock;
SDA.Lock;
end TP_Ctrl_Lines;
-------------------
-- TP_I2C_Config --
-------------------
procedure TP_I2C_Config is
begin
if not TP_I2C.Port_Enabled then
Reset (TP_I2C);
TP_I2C.Configure
((Mode => I2C_Mode,
Duty_Cycle => DutyCycle_2,
Own_Address => 16#00#,
Addressing_Mode => Addressing_Mode_7bit,
General_Call_Enabled => False,
Clock_Stretching_Enabled => True,
Clock_Speed => 100_000));
end if;
end TP_I2C_Config;
----------------
-- Initialize --
----------------
function Initialize
(This : in out Touch_Panel;
Orientation : HAL.Framebuffer.Display_Orientation :=
HAL.Framebuffer.Default) return Boolean
is
Status : Boolean;
begin
TP_Ctrl_Lines;
TP_I2C_Config;
Status := STMPE811_Device (This).Initialize;
This.Set_Orientation (Orientation);
return Status;
end Initialize;
----------------
-- Initialize --
----------------
procedure Initialize (This : in out Touch_Panel;
Orientation : HAL.Framebuffer.Display_Orientation :=
HAL.Framebuffer.Default) is
begin
if not This.Initialize (Orientation) then
raise Constraint_Error with "Cannot initialize the touch panel";
end if;
end Initialize;
---------------------
-- Set_Orientation --
---------------------
procedure Set_Orientation
(This : in out Touch_Panel;
Orientation : HAL.Framebuffer.Display_Orientation)
is
begin
case Orientation is
when HAL.Framebuffer.Default | HAL.Framebuffer.Portrait =>
This.Set_Bounds (STM32.Board.LCD_Natural_Width,
STM32.Board.LCD_Natural_Height,
0);
when HAL.Framebuffer.Landscape =>
This.Set_Bounds (STM32.Board.LCD_Natural_Width,
STM32.Board.LCD_Natural_Height,
Swap_XY or Invert_Y);
end case;
end Set_Orientation;
end Touch_Panel_STMPE811;
|
tum-ei-rcs/StratoX | Ada | 8,512 | ads | -- Project: StratoX
-- System: Stratosphere Balloon Flight Controller
-- Author: Martin Becker ([email protected])
-- based on AdaCore's Ada_Driver_Library
-- XXX! Nothing here is thread-safe!
-- @summary Directory (end directory entries) handling for FAT FS
package FAT_Filesystem.Directories with SPARK_Mode => Off is
type Directory_Handle is private; -- used to read directories
function Open_Root_Directory
(FS : FAT_Filesystem_Access;
Dir : out Directory_Handle) return Status_Code;
type Directory_Entry is private; -- used to represent one item in directory
function Open
(E : Directory_Entry;
Dir : out Directory_Handle) return Status_Code
with Pre => Is_Subdirectory (E);
-- get handle of given item. Handle can be used with Read().
function Make_Directory
(Parent : in out Directory_Handle;
newname : String;
D_Entry : out Directory_Entry) return Status_Code
with Pre => newname'Length < 12;
-- create a new directory within the given one
-- we only allow short names for now.
-- if directory already exists, returns its entry.
procedure Close (Dir : in out Directory_Handle);
function Read (Dir : in out Directory_Handle;
DEntry : out Directory_Entry;
Deleted : Boolean := False) return Status_Code;
-- @summary get the next entry in the given directory
-- after calling this, Dir.Dir_Current are invalid iff return /= OK.
-- However, the Dir_Begin and Dir_End components are always valid.
-- if Deleted is true, then deleted entries are also returned and
-- marked with FS=null
function Get_Name (E : Directory_Entry) return String;
function Is_Read_Only (E : Directory_Entry) return Boolean;
function Is_Hidden (E : Directory_Entry) return Boolean;
function Is_System_File (E : Directory_Entry) return Boolean;
function Is_Subdirectory (E : Directory_Entry) return Boolean;
function Is_Archive (E : Directory_Entry) return Boolean;
private
pragma SPARK_Mode (Off);
type FAT_Directory_Entry_Attribute is record
Read_Only : Boolean;
Hidden : Boolean;
System_File : Boolean;
Volume_Label : Boolean;
Subdirectory : Boolean;
Archive : Boolean;
end record with Size => 8, Pack;
type FAT_Directory_Entry is record
Filename : String (1 .. 8);
Extension : String (1 .. 3);
Attributes : FAT_Directory_Entry_Attribute;
Reserved : String (1 .. 8);
Cluster_H : Unsigned_16;
Time : Unsigned_16;
Date : Unsigned_16;
Cluster_L : Unsigned_16;
Size : Unsigned_32; -- TODO: what is this?
end record with Size => 32 * 8; -- 32 Byte per entry
for FAT_Directory_Entry use record
Filename at 16#00# range 0 .. 63;
Extension at 16#08# range 0 .. 23;
Attributes at 16#0B# range 0 .. 7;
Reserved at 16#0C# range 0 .. 63;
Cluster_H at 16#14# range 0 .. 15;
Time at 16#16# range 0 .. 15;
Date at 16#18# range 0 .. 15;
Cluster_L at 16#1A# range 0 .. 15;
Size at 16#1C# range 0 .. 31;
end record;
ENTRY_SIZE : constant := 32;
VFAT_Directory_Entry_Attribute : constant FAT_Directory_Entry_Attribute :=
(Subdirectory => False,
Archive => False,
others => True);
-- Attrite value 16#F0# defined at offset 16#0B# and identifying a VFAT
-- entry rather than a regular directory entry
type VFAT_Sequence_Number is mod 2 ** 5
with Size => 5;
type VFAT_Sequence is record
Sequence : VFAT_Sequence_Number;
Stop_Bit : Boolean;
end record with Size => 8, Pack;
type VFAT_Directory_Entry is record
VFAT_Attr : VFAT_Sequence;
Name_1 : Wide_String (1 .. 5);
Attribute : FAT_Directory_Entry_Attribute;
E_Type : Unsigned_8;
Checksum : Unsigned_8;
Name_2 : Wide_String (1 .. 6);
Cluster : Unsigned_16;
Name_3 : Wide_String (1 .. 2);
end record with Pack, Size => 32 * 8;
-- type File_Object_Structure is record
-- FS : FAT_Filesystem_Access;
-- Flags : Unsigned_8;
-- Err : Unsigned_8;
-- File_Ptr : Unsigned_32 := 0;
-- File_Size : Unsigned_32;
-- Start_Cluster : Unsigned_32;
-- Current_Cluster : Unsigned_32;
-- end record;
-- FIXME: encapsulate this, and provide function "move_forward" or something.
type Directory_Handle_Pointer is record
Index : Unsigned_16;
Cluster : Unsigned_32;
Block : Unsigned_32;
end record;
procedure Invalidate_Handle_Pointer (h : in out Directory_Handle_Pointer);
function Valid_Handle_Pointer (h : Directory_Handle_Pointer) return Boolean;
type Directory_Handle is record
FS : FAT_Filesystem_Access;
Dir_Begin : Directory_Handle_Pointer; -- points to the first entry of the directory
Dir_Current : Directory_Handle_Pointer; -- points to the current, valid entry
Dir_End : Directory_Handle_Pointer; -- points past the last valid entry
end record;
-- used to read directories
type Directory_Entry is record
FS : FAT_Filesystem_Access;
Name : String (1 .. 128);
Name_First : Natural := 129; -- where the string starts within 'Name'
Name_Last : Natural := 0; -- where the string ends within 'Name'
CRC : Unsigned_8 := 0;
Attributes : FAT_Directory_Entry_Attribute;
Start_Cluster : Unsigned_32; -- the address of the data/contents of the entry
Size : Unsigned_32;
Entry_Address : FAT_Address; -- the address of the entry itself
-- FIXME: add time stamps, attributes, etc.
end record;
-- each item in a directory is described by this in high-level view
procedure Rewind (Dir : in out Directory_Handle);
function Get_Entry_Or_Deleted
(Parent : in out Directory_Handle;
E_Name : String;
Ent : out Directory_Entry;
Deleted : out Boolean) return Boolean;
-- search for entry with the given name.
-- if Deleted is true, then the 'Ent' points
-- to an empty directory entry that can be
-- re-used. If Deleted is false, then an entry
-- with the given name was actually found
function Is_Deleted (F_Entry : FAT_Directory_Entry) return Boolean;
function Get_Entry
(Parent : in out Directory_Handle;
E_Name : String;
Ent : out Directory_Entry) return Boolean;
-- search for entry with the given name.
procedure Goto_Last_Entry (Parent : in out Directory_Handle);
-- proceed to last entry in given directory
function Allocate_Entry
(Parent : in out Directory_Handle;
New_Name : String;
Ent_Addr : out FAT_Address) return Status_Code;
-- find a location for a new entry within Parent_Ent
-- and make sure that the directory stays terminated
procedure Set_Name (newname : String; D : in out Directory_Entry)
with Pre => newname'Length > 0;
procedure Set_Name (newname : String; E : in out FAT_Directory_Entry)
with Pre => newname'Length > 0;
function Directory_To_FAT_Entry
(D_Entry : in Directory_Entry;
F_Entry : out FAT_Directory_Entry) return Status_Code;
function FAT_To_Directory_Entry
(FS : FAT_Filesystem_Access;
F_Entry : in FAT_Directory_Entry;
D_Entry : in out Directory_Entry;
Last_Seq : in out VFAT_Sequence_Number) return Status_Code;
-- @summary decypher the raw entry (file/dir name, etc) and write
-- to record.
-- @return OK when decipher is complete, otherwise needs to be
-- called again with the next entry (VFAT entries have
-- multiple parts)
function Is_Read_Only (E : Directory_Entry) return Boolean
is (E.Attributes.Read_Only);
function Is_Hidden (E : Directory_Entry) return Boolean
is (E.Attributes.Hidden);
function Is_System_File (E : Directory_Entry) return Boolean
is (E.Attributes.System_File);
function Is_Subdirectory (E : Directory_Entry) return Boolean
is (E.Attributes.Subdirectory);
function Is_Archive (E : Directory_Entry) return Boolean
is (E.Attributes.Archive);
end FAT_Filesystem.Directories;
|
RREE/ada-util | Ada | 7,718 | ads | -----------------------------------------------------------------------
-- util-streams-pipes -- Pipe stream to or from a process
-- Copyright (C) 2011, 2013, 2015, 2016, 2017, 2018, 2019, 2021 Stephane Carrez
-- Written by Stephane Carrez ([email protected])
--
-- Licensed under the Apache License, Version 2.0 (the "License");
-- you may not use this file except in compliance with the License.
-- You may obtain a copy of the License at
--
-- http://www.apache.org/licenses/LICENSE-2.0
--
-- Unless required by applicable law or agreed to in writing, software
-- distributed under the License is distributed on an "AS IS" BASIS,
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-- See the License for the specific language governing permissions and
-- limitations under the License.
-----------------------------------------------------------------------
with Util.Processes;
-- == Pipes ==
-- The `Util.Streams.Pipes` package defines a pipe stream to or from a process.
-- It allows to launch an external program while getting the program standard output or
-- providing the program standard input. The `Pipe_Stream` type represents the input or
-- output stream for the external program. This is a portable interface that works on
-- Unix and Windows.
--
-- The process is created and launched by the `Open` operation. The pipe allows
-- to read or write to the process through the `Read` and `Write` operation.
-- It is very close to the *popen* operation provided by the C stdio library.
-- First, create the pipe instance:
--
-- with Util.Streams.Pipes;
-- ...
-- Pipe : aliased Util.Streams.Pipes.Pipe_Stream;
--
-- The pipe instance can be associated with only one process at a time.
-- The process is launched by using the `Open` command and by specifying the command
-- to execute as well as the pipe redirection mode:
--
-- * `READ` to read the process standard output,
-- * `WRITE` to write the process standard input.
--
-- For example to run the `ls -l` command and read its output, we could run it by using:
--
-- Pipe.Open (Command => "ls -l", Mode => Util.Processes.READ);
--
-- The `Pipe_Stream` is not buffered and a buffer can be configured easily by using the
-- `Input_Buffer_Stream` type and connecting the buffer to the pipe so that it reads
-- the pipe to fill the buffer. The initialization of the buffer is the following:
--
-- with Util.Streams.Buffered;
-- ...
-- Buffer : Util.Streams.Buffered.Input_Buffer_Stream;
-- ...
-- Buffer.Initialize (Input => Pipe'Access, Size => 1024);
--
-- And to read the process output, one can use the following:
--
-- Content : Ada.Strings.Unbounded.Unbounded_String;
-- ...
-- Buffer.Read (Into => Content);
--
-- The pipe object should be closed when reading or writing to it is finished.
-- By closing the pipe, the caller will wait for the termination of the process.
-- The process exit status can be obtained by using the `Get_Exit_Status` function.
--
-- Pipe.Close;
-- if Pipe.Get_Exit_Status /= 0 then
-- Ada.Text_IO.Put_Line ("Command exited with status "
-- & Integer'Image (Pipe.Get_Exit_Status));
-- end if;
--
-- You will note that the `Pipe_Stream` is a limited type and thus cannot be copied.
-- When leaving the scope of the `Pipe_Stream` instance, the application will wait for
-- the process to terminate.
--
-- Before opening the pipe, it is possible to have some control on the process that
-- will be created to configure:
--
-- * The shell that will be used to launch the process,
-- * The process working directory,
-- * Redirect the process output to a file,
-- * Redirect the process error to a file,
-- * Redirect the process input from a file.
--
-- All these operations must be made before calling the `Open` procedure.
package Util.Streams.Pipes is
use Util.Processes;
subtype Pipe_Mode is Util.Processes.Pipe_Mode range READ .. READ_WRITE;
-- -----------------------
-- Pipe stream
-- -----------------------
-- The <b>Pipe_Stream</b> is an output/input stream that reads or writes
-- to or from a process.
type Pipe_Stream is limited new Output_Stream and Input_Stream with private;
-- Set the shell executable path to use to launch a command. The default on Unix is
-- the /bin/sh command. Argument splitting is done by the /bin/sh -c command.
-- When setting an empty shell command, the argument splitting is done by the
-- <tt>Spawn</tt> procedure.
procedure Set_Shell (Stream : in out Pipe_Stream;
Shell : in String);
-- Before launching the process, redirect the input stream of the process
-- to the specified file.
-- Raises <b>Invalid_State</b> if the process is running.
procedure Set_Input_Stream (Stream : in out Pipe_Stream;
File : in String);
-- Set the output stream of the process.
-- Raises <b>Invalid_State</b> if the process is running.
procedure Set_Output_Stream (Stream : in out Pipe_Stream;
File : in String;
Append : in Boolean := False);
-- Set the error stream of the process.
-- Raises <b>Invalid_State</b> if the process is running.
procedure Set_Error_Stream (Stream : in out Pipe_Stream;
File : in String;
Append : in Boolean := False);
-- Set the working directory that the process will use once it is created.
-- The directory must exist or the <b>Invalid_Directory</b> exception will be raised.
procedure Set_Working_Directory (Stream : in out Pipe_Stream;
Path : in String);
-- Closes the given file descriptor in the child process before executing the command.
procedure Add_Close (Stream : in out Pipe_Stream;
Fd : in Util.Processes.File_Type);
-- Open a pipe to read or write to an external process. The pipe is created and the
-- command is executed with the input and output streams redirected through the pipe.
procedure Open (Stream : in out Pipe_Stream;
Command : in String;
Mode : in Pipe_Mode := READ);
-- Close the pipe and wait for the external process to terminate.
overriding
procedure Close (Stream : in out Pipe_Stream);
-- Get the process exit status.
function Get_Exit_Status (Stream : in Pipe_Stream) return Integer;
-- Returns True if the process is running.
function Is_Running (Stream : in Pipe_Stream) return Boolean;
-- Write the buffer array to the output stream.
overriding
procedure Write (Stream : in out Pipe_Stream;
Buffer : in Ada.Streams.Stream_Element_Array);
-- Read into the buffer as many bytes as possible and return in
-- <b>last</b> the position of the last byte read.
overriding
procedure Read (Stream : in out Pipe_Stream;
Into : out Ada.Streams.Stream_Element_Array;
Last : out Ada.Streams.Stream_Element_Offset);
-- Terminate the process by sending a signal on Unix and exiting the process on Windows.
-- This operation is not portable and has a different behavior between Unix and Windows.
-- Its intent is to stop the process.
procedure Stop (Stream : in out Pipe_Stream;
Signal : in Positive := 15);
private
type Pipe_Stream is limited new Output_Stream and Input_Stream with record
Proc : Util.Processes.Process;
end record;
end Util.Streams.Pipes;
|
stcarrez/ada-util | Ada | 2,963 | adb | -----------------------------------------------------------------------
-- util-beans-ranges-tests -- Unit tests for bean range definitions
-- Copyright (C) 2011, 2021 Stephane Carrez
-- Written by Stephane Carrez ([email protected])
--
-- Licensed under the Apache License, Version 2.0 (the "License");
-- you may not use this file except in compliance with the License.
-- You may obtain a copy of the License at
--
-- http://www.apache.org/licenses/LICENSE-2.0
--
-- Unless required by applicable law or agreed to in writing, software
-- distributed under the License is distributed on an "AS IS" BASIS,
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-- See the License for the specific language governing permissions and
-- limitations under the License.
-----------------------------------------------------------------------
with Util.Test_Caller;
package body Util.Beans.Ranges.Tests is
use Util.Tests;
package Caller is new Util.Test_Caller (Test, "Beans.Ranges");
procedure Add_Tests (Suite : in Util.Tests.Access_Test_Suite) is
begin
Caller.Add_Test (Suite, "Test Util.Beans.Ranges.Create",
Test_Range'Access);
Caller.Add_Test (Suite, "Test Util.Beans.Ranges.Iterate",
Test_Iterate_Range'Access);
end Add_Tests;
-- ------------------------------
-- Test the creation and range definition.
-- ------------------------------
procedure Test_Range (T : in out Test) is
C : Integer_Ranges.Range_Bean := Integer_Ranges.Create (1, 10);
begin
Assert_Equals (T, 1, C.Get_First, "Invalid first range value");
Assert_Equals (T, 10, C.Get_Last, "Invalid first range value");
Assert_Equals (T, 10, C.Get_Count, "Invalid range count");
C := Integer_Ranges.Create (10, 10);
Assert_Equals (T, 10, C.Get_First, "Invalid first range value");
Assert_Equals (T, 10, C.Get_Last, "Invalid first range value");
Assert_Equals (T, 1, C.Get_Count, "Invalid range count");
end Test_Range;
-- ------------------------------
-- Test iterating over a range definition.
-- ------------------------------
procedure Test_Iterate_Range (T : in out Test) is
use Util.Beans.Objects;
C : aliased Integer_Ranges.Range_Bean := Integer_Ranges.Create (-3, 10);
List : constant Basic.List_Bean_Access := C'Unchecked_Access;
Value : Util.Beans.Objects.Object;
begin
for I in 1 .. List.Get_Count loop
List.Set_Row_Index (I);
Value := List.Get_Row;
Assert (T, not Util.Beans.Objects.Is_Null (Value), "Null row returned");
Assert (T, Util.Beans.Objects.Get_Type (Value) = Util.Beans.Objects.TYPE_INTEGER,
"Invalid value type");
Assert_Equals (T, -3 + Integer (I - 1), To_Integer (Value), "Invalid value");
end loop;
end Test_Iterate_Range;
end Util.Beans.Ranges.Tests;
|
jwarwick/aoc_2020 | Ada | 476 | ads | -- AOC 2020, Day 9
with Ada.Containers.Vectors;
package Day is
package XMAS_Vector is new Ada.Containers.Vectors
(Index_Type => Natural,
Element_Type => Long_Integer);
use XMAS_Vector;
function load_file(filename : in String) return XMAS_Vector.Vector;
function first_invalid(v : in XMAS_Vector.Vector; preamble : in Positive) return Long_Integer;
function find_sum(v : in XMAS_Vector.Vector; target : in Long_Integer) return Long_Integer;
end Day;
|
charlie5/cBound | Ada | 1,318 | ads | -- This file is generated by SWIG. Please do not modify by hand.
--
with Interfaces.C;
with Interfaces.C.Strings;
with Interfaces.C;
with Interfaces.C.Pointers;
package xcb.xcb_extension_t is
-- Item
--
type Item is record
name : aliased Interfaces.C.Strings.chars_ptr;
global_id : aliased Interfaces.C.int;
end record;
-- Item_Array
--
type Item_Array is
array (Interfaces.C.size_t range <>) of aliased xcb.xcb_extension_t.Item;
-- Pointer
--
package C_Pointers is new Interfaces.C.Pointers
(Index => Interfaces.C.size_t,
Element => xcb.xcb_extension_t.Item,
Element_Array => xcb.xcb_extension_t.Item_Array,
Default_Terminator => (others => <>));
subtype Pointer is C_Pointers.Pointer;
-- Pointer_Array
--
type Pointer_Array is
array
(Interfaces.C.size_t range <>) of aliased xcb.xcb_extension_t.Pointer;
-- Pointer_Pointer
--
package C_Pointer_Pointers is new Interfaces.C.Pointers
(Index => Interfaces.C.size_t,
Element => xcb.xcb_extension_t.Pointer,
Element_Array => xcb.xcb_extension_t.Pointer_Array,
Default_Terminator => null);
subtype Pointer_Pointer is C_Pointer_Pointers.Pointer;
end xcb.xcb_extension_t;
|
reznikmm/matreshka | Ada | 3,957 | ads | ------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- Open Document Toolkit --
-- --
-- Runtime Library Component --
-- --
------------------------------------------------------------------------------
-- --
-- Copyright © 2013, Vadim Godunko <[email protected]> --
-- All rights reserved. --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions --
-- are met: --
-- --
-- * Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- --
-- * Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in the --
-- documentation and/or other materials provided with the distribution. --
-- --
-- * Neither the name of the Vadim Godunko, IE nor the names of its --
-- contributors may be used to endorse or promote products derived from --
-- this software without specific prior written permission. --
-- --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR --
-- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
-- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED --
-- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR --
-- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF --
-- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING --
-- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS --
-- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
-- --
------------------------------------------------------------------------------
-- $Revision$ $Date$
------------------------------------------------------------------------------
with Matreshka.ODF_Elements.Style.Page_Layout_Properties;
package ODF.DOM.Elements.Style.Page_Layout_Properties.Internals is
function Create
(Node : Matreshka.ODF_Elements.Style.Page_Layout_Properties.Style_Page_Layout_Properties_Access)
return ODF.DOM.Elements.Style.Page_Layout_Properties.ODF_Style_Page_Layout_Properties;
function Wrap
(Node : Matreshka.ODF_Elements.Style.Page_Layout_Properties.Style_Page_Layout_Properties_Access)
return ODF.DOM.Elements.Style.Page_Layout_Properties.ODF_Style_Page_Layout_Properties;
end ODF.DOM.Elements.Style.Page_Layout_Properties.Internals;
|
reznikmm/matreshka | Ada | 6,798 | adb | ------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- Open Document Toolkit --
-- --
-- Runtime Library Component --
-- --
------------------------------------------------------------------------------
-- --
-- Copyright © 2014, Vadim Godunko <[email protected]> --
-- All rights reserved. --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions --
-- are met: --
-- --
-- * Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- --
-- * Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in the --
-- documentation and/or other materials provided with the distribution. --
-- --
-- * Neither the name of the Vadim Godunko, IE nor the names of its --
-- contributors may be used to endorse or promote products derived from --
-- this software without specific prior written permission. --
-- --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR --
-- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
-- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED --
-- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR --
-- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF --
-- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING --
-- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS --
-- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
-- --
------------------------------------------------------------------------------
-- $Revision$ $Date$
------------------------------------------------------------------------------
with Matreshka.DOM_Documents;
with Matreshka.ODF_String_Constants;
with ODF.DOM.Iterators;
with ODF.DOM.Visitors;
package body Matreshka.ODF_Db.Delimiter_Elements is
------------
-- Create --
------------
overriding function Create
(Parameters : not null access Matreshka.DOM_Elements.Element_L2_Parameters)
return Db_Delimiter_Element_Node is
begin
return Self : Db_Delimiter_Element_Node do
Matreshka.ODF_Db.Constructors.Initialize
(Self'Unchecked_Access,
Parameters.Document,
Matreshka.ODF_String_Constants.Db_Prefix);
end return;
end Create;
----------------
-- Enter_Node --
----------------
overriding procedure Enter_Node
(Self : not null access Db_Delimiter_Element_Node;
Visitor : in out XML.DOM.Visitors.Abstract_Visitor'Class;
Control : in out XML.DOM.Visitors.Traverse_Control) is
begin
if Visitor in ODF.DOM.Visitors.Abstract_ODF_Visitor'Class then
ODF.DOM.Visitors.Abstract_ODF_Visitor'Class
(Visitor).Enter_Db_Delimiter
(ODF.DOM.Db_Delimiter_Elements.ODF_Db_Delimiter_Access
(Self),
Control);
else
Matreshka.DOM_Elements.Abstract_Element_Node
(Self.all).Enter_Node (Visitor, Control);
end if;
end Enter_Node;
--------------------
-- Get_Local_Name --
--------------------
overriding function Get_Local_Name
(Self : not null access constant Db_Delimiter_Element_Node)
return League.Strings.Universal_String
is
pragma Unreferenced (Self);
begin
return Matreshka.ODF_String_Constants.Delimiter_Element;
end Get_Local_Name;
----------------
-- Leave_Node --
----------------
overriding procedure Leave_Node
(Self : not null access Db_Delimiter_Element_Node;
Visitor : in out XML.DOM.Visitors.Abstract_Visitor'Class;
Control : in out XML.DOM.Visitors.Traverse_Control) is
begin
if Visitor in ODF.DOM.Visitors.Abstract_ODF_Visitor'Class then
ODF.DOM.Visitors.Abstract_ODF_Visitor'Class
(Visitor).Leave_Db_Delimiter
(ODF.DOM.Db_Delimiter_Elements.ODF_Db_Delimiter_Access
(Self),
Control);
else
Matreshka.DOM_Elements.Abstract_Element_Node
(Self.all).Leave_Node (Visitor, Control);
end if;
end Leave_Node;
----------------
-- Visit_Node --
----------------
overriding procedure Visit_Node
(Self : not null access Db_Delimiter_Element_Node;
Iterator : in out XML.DOM.Visitors.Abstract_Iterator'Class;
Visitor : in out XML.DOM.Visitors.Abstract_Visitor'Class;
Control : in out XML.DOM.Visitors.Traverse_Control) is
begin
if Iterator in ODF.DOM.Iterators.Abstract_ODF_Iterator'Class then
ODF.DOM.Iterators.Abstract_ODF_Iterator'Class
(Iterator).Visit_Db_Delimiter
(Visitor,
ODF.DOM.Db_Delimiter_Elements.ODF_Db_Delimiter_Access
(Self),
Control);
else
Matreshka.DOM_Elements.Abstract_Element_Node
(Self.all).Visit_Node (Iterator, Visitor, Control);
end if;
end Visit_Node;
begin
Matreshka.DOM_Documents.Register_Element
(Matreshka.ODF_String_Constants.Db_URI,
Matreshka.ODF_String_Constants.Delimiter_Element,
Db_Delimiter_Element_Node'Tag);
end Matreshka.ODF_Db.Delimiter_Elements;
|
HeisenbugLtd/msg_passing | Ada | 772 | ads | ------------------------------------------------------------------------
-- Copyright (C) 2010-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);
------------------------------------------------------------------------
-- The receiver task package.
--
-- Nothing to see here, as everything is in the body.
------------------------------------------------------------------------
package Receiver with
Elaborate_Body => True
is
end Receiver;
|
strenkml/EE368 | Ada | 851 | adb |
package body Benchmark.Matrix.LU is
function Create_LU return Benchmark_Pointer is
begin
return new LU_Type;
end Create_LU;
procedure Run(benchmark : in LU_Type) is
addr : constant Address_Type := 0;
begin
for k in 0 .. benchmark.size - 1 loop
for j in k + 1 .. benchmark.size - 1 loop
Read(benchmark, addr, k, j);
Read(benchmark, addr, k, k);
Write(benchmark, addr, k, j);
end loop;
for i in k + 1 .. benchmark.size - 1 loop
for j in k + 1 .. benchmark.size - 1 loop
Read(benchmark, addr, i, j);
Read(benchmark, addr, i, k);
Read(benchmark, addr, k, j);
Write(benchmark, addr, i, j);
end loop;
end loop;
end loop;
end Run;
end Benchmark.Matrix.LU;
|
reznikmm/matreshka | Ada | 4,671 | 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.Footnotes_Position_Attributes is
------------
-- Create --
------------
overriding function Create
(Parameters : not null access Matreshka.DOM_Attributes.Attribute_L2_Parameters)
return Text_Footnotes_Position_Attribute_Node is
begin
return Self : Text_Footnotes_Position_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_Footnotes_Position_Attribute_Node)
return League.Strings.Universal_String
is
pragma Unreferenced (Self);
begin
return Matreshka.ODF_String_Constants.Footnotes_Position_Attribute;
end Get_Local_Name;
begin
Matreshka.DOM_Documents.Register_Attribute
(Matreshka.ODF_String_Constants.Text_URI,
Matreshka.ODF_String_Constants.Footnotes_Position_Attribute,
Text_Footnotes_Position_Attribute_Node'Tag);
end Matreshka.ODF_Text.Footnotes_Position_Attributes;
|
skill-lang/adaCommon | Ada | 1,664 | ads | -- ___ _ ___ _ _ --
-- / __| |/ (_) | | Common SKilL implementation --
-- \__ \ ' <| | | |__ file parser implementation --
-- |___/_|\_\_|_|____| by: Timm Felden --
-- --
pragma Ada_2012;
with Skill.Streams;
with Skill.Files;
with Skill.Types;
with Skill.String_Pools;
with Skill.Types.Pools;
with Skill.Field_Types;
with Skill.Streams.Reader;
with Skill.Field_Types.Builtin;
with Skill.Field_Types.Builtin.String_Type_P;
-- documentation can be found in java common
package Skill.Internal.File_Parsers is
generic
type Result_T is new Skill.Files.File_T with private;
type Result is access Result_T;
with function New_Pool
(Type_ID : Natural;
Name : Skill.Types.String_Access;
Super : Skill.Types.Pools.Pool) return Skill.Types.Pools.Pool is <>;
with function Make_State
(Path : Types.String_Access;
Mode : Files.Write_Mode;
Strings : String_Pools.Pool;
String_Type : Skill.Field_Types.Builtin.String_Type_P.Field_Type;
Annotation_Type : Skill.Field_Types.Builtin.Annotation_Type_P
.Field_Type;
Types : Skill.Types.Pools.Type_Vector;
Types_By_Name : Skill.Types.Pools.Type_Map) return Result is <>;
function Read
(Input : Skill.Streams.Reader.Input_Stream;
Mode : Skill.Files.Write_Mode) return Result;
end Skill.Internal.File_Parsers;
|
docandrew/troodon | Ada | 16,003 | adb | with Ada.Calendar;
with Ada.Text_IO;
with Ada.Streams.Stream_IO;
with Ada.Unchecked_Deallocation;
with Interfaces.C; use Interfaces.C;
with System;
with bits_types_h;
with xcb; use xcb;
with xproto; use xproto;
with GID;
with GL;
with GLext;
with GLX;
with X11;
with Render;
with Render.Shaders;
with Render.Util;
with Setup;
with Util;
package body Desktop is
dtWindow : xcb_window_t;
dtGLXWindow : GLX.GLXWindow;
dtDrawable : GLX.GLXDrawable;
type ByteArray is array (Integer range <>) of aliased Interfaces.Unsigned_8;
type ByteArrayPtr is access ByteArray;
procedure free is new Ada.Unchecked_Deallocation(ByteArray, ByteArrayPtr);
wallpaper : ByteArrayPtr;
wallpaperW : Natural;
wallpaperH : Natural;
-- Screen information (@TODO - screen(s) information)
screenW : Natural;
screenH : Natural;
-- Framebuffer object we'll draw the wallpaper on.
fbo : aliased GL.GLuint;
-- Texture to hold the wallpaper
tex : aliased GL.GLuint;
---------------------------------------------------------------------------
-- getWindow
---------------------------------------------------------------------------
function getWindow return xproto.xcb_window_t is
begin
return dtWindow;
end getWindow;
---------------------------------------------------------------------------
-- changeWallpaper
---------------------------------------------------------------------------
procedure changeWallpaper (c : access xcb_connection_t;
rend : Render.Renderer;
filename : String) is
-- cookie : xcb_void_cookie_t;
-- error : access xcb_generic_error_t;
file : Ada.Streams.Stream_IO.File_Type;
stream : Ada.Streams.Stream_IO.Stream_Access;
image : GID.Image_descriptor;
-- Procedure to load byte array with image contents
--
procedure loadImage (image : in out GID.Image_descriptor;
buffer : in out ByteArrayPtr) is
subtype Primary_color_range is Interfaces.Unsigned_8;
ignore : Ada.Calendar.Day_Duration;
width : constant Positive := GID.Pixel_width (image);
height : constant Positive := GID.Pixel_height (image);
idx : Natural;
bpp : constant := 3; -- bytes per pixel
-- Set draw location
procedure Set_X_Y (x, y: Natural) is
begin
idx := bpp * (x + width * (height - 1 - y));
end Set_X_Y;
-- Set pixel color
procedure Put_Pixel (red, green, blue : Primary_color_range;
alpha : Primary_color_range) is
begin
--@note if we support other bpps here we need to change this line.
buffer(idx..idx+2) := (red, green, blue);
idx := idx + bpp;
end Put_pixel;
-- Feedback (ignored here)
procedure Feedback (percents : Natural) is
begin
Ada.Text_IO.Put_Line ("Reading file: " & percents'Image & "%");
end Feedback;
-- Instantiation of GID template
procedure GID_load_image is new GID.Load_image_contents
(Primary_color_range, Set_X_Y, Put_Pixel, Feedback, GID.nice);
begin
free (buffer);
buffer := new ByteArray(0..(bpp * width * height - 1));
GID_load_image (image, ignore);
end loadImage;
begin
-- Get image header from GID, so we know how big to make our wallpaper pixmap
Ada.Streams.Stream_IO.Open (File => file,
Mode => Ada.Streams.Stream_IO.In_File,
Name => filename);
stream := Ada.Streams.Stream_IO.Stream (file);
GID.Load_image_header (image => image, from => stream.all);
wallpaperW := GID.Pixel_width (image);
wallpaperH := GID.Pixel_height (image);
Ada.Text_IO.Put_Line ("Troodon: (Desktop) Loading wallpaper " & filename & "size:" & wallpaperW'Image & " x" & wallpaperH'Image);
loadImage (image, wallpaper);
Ada.Streams.Stream_IO.Close (file);
draw (rend);
end changeWallpaper;
---------------------------------------------------------------------------
-- draw
---------------------------------------------------------------------------
procedure draw (rend : Render.Renderer) is
glxRet : Interfaces.C.int;
orthoM : Render.Util.Mat4;
-- Destination quad to render desktop to.
dest : Render.Util.Box;
begin
glxRet := GLX.glXMakeContextCurrent (dpy => rend.display,
draw => dtDrawable,
read => dtDrawable,
ctx => rend.context);
GLext.glUseProgram (Render.Shaders.winShaderProg);
GL.glActiveTexture (GL.GL_TEXTURE0);
GL.glGenTextures (1, tex'Access);
GL.glBindTexture (GL.GL_TEXTURE_2D, tex);
-- Load wallpaper bytes into our texture (and hence the framebuffer)
-- @TODO perform scaling, tiling, etc. if the sizes don't match.
GL.glTexImage2D (target => GL.GL_TEXTURE_2D,
level => 0,
internalFormat => GL.GL_RGB,
width => Interfaces.C.int(wallpaperW),
height => Interfaces.C.int(wallpaperH),
border => 0,
format => GL.GL_RGB,
c_type => GL.GL_UNSIGNED_BYTE,
pixels => wallpaper(0)'Address);
GL.glTexParameteri (target => GL.GL_TEXTURE_2D,
pname => GL.GL_TEXTURE_MIN_FILTER,
param => GL.GL_LINEAR);
GL.glTexParameteri (target => GL.GL_TEXTURE_2D,
pname => GL.GL_TEXTURE_MAG_FILTER,
param => GL.GL_LINEAR);
GL.glClearColor (red => 0.7,
green => 0.0,
blue => 0.7,
alpha => 1.0);
GL.glClear (GL.GL_COLOR_BUFFER_BIT);
-- Set up viewport, projection, uniforms
GL.glViewport (x => 0,
y => 0,
width => Interfaces.C.int(screenW),
height => Interfaces.C.int(screenH));
orthoM := Render.Util.ortho (0.0, Float(screenW), Float(screenH), 0.0, -1.0, 1.0);
GLext.glUniformMatrix4fv (location => Render.Shaders.winUniformOrtho,
count => 1,
transpose => GL.GL_TRUE,
value => orthoM(1)'Access);
GLext.glUniform1f (location => Render.Shaders.winUniformAlpha,
v0 => 1.0);
-- Set up attribs
GLext.glGenBuffers (1, Render.Shaders.winVBO'Access);
GLext.glEnableVertexAttribArray (GL.GLuint(Render.Shaders.winAttribCoord));
GLext.glBindBuffer (target => GLext.GL_ARRAY_BUFFER,
buffer => Render.Shaders.winVBO);
GLext.glVertexAttribPointer (index => GL.GLuint(Render.Shaders.winAttribCoord),
size => 4,
c_type => GL.GL_FLOAT,
normalized => GL.GL_FALSE,
stride => 0,
pointer => System.Null_Address);
-- Quad coords
dest := (
1 => (0.0, Float(screenH), 0.0, 1.0), -- Bottom left
2 => (0.0, 0.0, 0.0, 0.0), -- Top left
3 => (Float(screenW), Float(screenH), 1.0, 1.0), -- Bottom right
4 => (Float(screenW), 0.0, 1.0, 0.0) -- Top right
);
GLext.glBufferData (target => GLext.GL_ARRAY_BUFFER,
size => dest'Size / 8,
data => dest'Address,
usage => GLext.GL_DYNAMIC_DRAW);
GL.glDrawArrays (mode => GL.GL_TRIANGLE_STRIP,
first => 0,
count => Interfaces.C.int(dest'Last));
GLX.glXSwapBuffers (rend.display, dtDrawable);
GL.glDeleteTextures (1, tex'Access);
GLext.glDisableVertexAttribArray (GL.GLuint(Render.Shaders.winAttribCoord));
GLext.glUseProgram (0);
end draw;
---------------------------------------------------------------------------
-- initFramebuffer
--
-- To draw the wallpaper we perform a framebuffer blit. This sets that up.
---------------------------------------------------------------------------
-- procedure initFramebuffer (c : access xcb_connection_t;
-- rend : Render.Renderer) is
-- begin
-- -- Reserve storage ahead of time for this texture.
-- -- GL.glTexImage2D (target => GL.GL_TEXTURE_2D,
-- -- level => 0,
-- -- internalFormat => GL.GL_RGB8, -- alpha doesn't really make sense here.
-- -- width => screenW,
-- -- height => screenH,
-- -- border => 0,
-- -- format => GL.GL_RGB8,
-- -- c_type => GL.GL_UNSIGNED_BYTE,
-- -- pixels => System.Null_Address);
-- end initFramebuffer;
---------------------------------------------------------------------------
-- @TODO
-- query randr for displays
-- for each display, create a window of the size of that display
-- eventually make a nice way to get wallpapers aligned
---------------------------------------------------------------------------
procedure start (c : access xcb_connection_t;
rend : Render.Renderer) is
screen : access xcb_screen_t;
geom : xcb_get_geometry_reply_t;
cookie : xcb_void_cookie_t;
error : access xcb_generic_error_t;
desktopAttr : aliased xcb_create_window_value_list_t;
desktopValueMask : Interfaces.C.unsigned;
wmType : xcb_atom_t;
glxRet : Interfaces.C.int;
junkpix : xcb_pixmap_t;
junkpixGLX : GLX.GLXPixmap;
begin
screen := xcb_setup_roots_iterator (xcb_get_setup (c)).data;
geom := Util.getWindowGeometry (c, screen.root);
dtWindow := xcb_generate_id (c);
Ada.Text_IO.Put_Line ("Troodon: (Desktop) Creating new window with id" & dtWindow'Image);
desktopAttr.background_pixel := 0;
desktopAttr.border_pixel := 0;
desktopAttr.colormap := rend.colormap;
desktopAttr.event_mask := XCB_EVENT_MASK_EXPOSURE or
XCB_EVENT_MASK_BUTTON_PRESS or
XCB_EVENT_MASK_BUTTON_RELEASE;
desktopValueMask := XCB_CW_BACK_PIXEL or
XCB_CW_BORDER_PIXEL or
XCB_CW_COLORMAP or
XCB_CW_EVENT_MASK;
-- Save screen info for later. In the event that additional monitors are detected,
-- plugged in, etc. we'll want to update this.
screenW := Natural(geom.width);
screenH := Natural(geom.height);
cookie :=
xcb_create_window_aux (c => c,
depth => 32,
wid => dtWindow,
parent => screen.root,
x => 0,
y => 0,
width => geom.width,
height => geom.height,
border_width => 0,
u_class => xcb_window_class_t'Pos (XCB_WINDOW_CLASS_INPUT_OUTPUT),
visual => rend.visualID,
value_mask => desktopValueMask,
value_list => desktopAttr'Access);
if setup.ewmh /= null then
wmType := Setup.ewmh.u_NET_WM_WINDOW_TYPE_DESKTOP;
Ada.Text_IO.Put_Line ("Troodon: (Desktop) Setting window type to desktop");
cookie := xcb_change_property(c => c,
mode => unsigned_char(xcb_prop_mode_t'Pos(XCB_PROP_MODE_REPLACE)),
window => dtWindow,
property => setup.ewmh.u_NET_WM_WINDOW_TYPE,
c_type => XCB_ATOM_ATOM,
format => 8,
data_len => xcb_atom_t'Size / 8,
data => wmType'Address);
end if;
Ada.Text_IO.Put_Line ("Troodon: (Desktop) Mapping window");
cookie := xcb_map_window_checked (c, dtWindow);
error := xcb_request_check (c, cookie);
if error /= null then
Ada.Text_IO.Put_Line ("Troodon: (Desktop) Unable to map desktop window, error:" & error.error_code'Image);
end if;
Ada.Text_IO.Put_Line ("Troodon: (Desktop) Creating OpenGL drawable");
dtGLXWindow := GLX.glXCreateWindow (dpy => rend.display,
config => rend.fbConfig,
win => Interfaces.C.unsigned_long(dtWindow),
attribList => null);
Ada.Text_IO.Put_Line ("Troodon: (Desktop) Created OpenGL drawable with id:" & dtGLXWindow'Image);
dtDrawable := GLX.GLXDrawable(dtGLXWindow);
-- The only _real_ reason to do this here is because we'd like to initShaders, and
-- need a drawable and current context to do so.
glxRet := GLX.glXMakeContextCurrent (dpy => rend.display,
draw => dtDrawable,
read => dtDrawable,
ctx => rend.context);
if glxRet = 0 then
raise DesktopException with "Troodon: (Desktop) Failed to make GLX context current";
end if;
end start;
---------------------------------------------------------------------------
-- stop
---------------------------------------------------------------------------
procedure stop (c : access xcb_connection_t; rend : Render.Renderer) is
cookie : xcb_void_cookie_t;
error : access xcb_generic_error_t;
begin
Ada.Text_IO.Put_Line ("Troodon: (Desktop) Shutting down.");
GLX.glXDestroyWindow (rend.display, GLX.GLXWindow(dtDrawable));
cookie := xcb_destroy_window_checked (c, dtWindow);
error := xcb_request_check (c, cookie);
if error /= null then
Ada.Text_IO.Put_Line ("Troodon: (Desktop) Error destroying desktop window, error:" & error.error_code'Image);
end if;
Ada.Text_IO.Put_Line ("Troodon: (Desktop) Stopped.");
end stop;
end Desktop; |
xeenta/learning-ada | Ada | 355 | adb | package body Moving_Thing is
procedure Faster (T : in out Thing;
D : in Direction;
M : in Float) is
begin
null; -- null statement
end Faster;
procedure Stop (T : in out Thing) is
begin
T.Spd.Vx := 0.0;
T.Spd.Vy := 0.0;
T.Spd.Vz := 0.0;
end;
end Moving_Thing;
|
KipodAfterFree/KAF-2019-FireHog | Ada | 3,045 | ads | ------------------------------------------------------------------------------
-- --
-- GNAT ncurses Binding Samples --
-- --
-- Sample.Form_Demo --
-- --
-- S P E C --
-- --
------------------------------------------------------------------------------
-- Copyright (c) 1998 Free Software Foundation, Inc. --
-- --
-- Permission is hereby granted, free of charge, to any person obtaining a --
-- copy of this software and associated documentation files (the --
-- "Software"), to deal in the Software without restriction, including --
-- without limitation the rights to use, copy, modify, merge, publish, --
-- distribute, distribute with modifications, sublicense, and/or sell --
-- copies of the Software, and to permit persons to whom the Software is --
-- furnished to do so, subject to the following conditions: --
-- --
-- The above copyright notice and this permission notice shall be included --
-- in all copies or substantial portions of the Software. --
-- --
-- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS --
-- OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF --
-- MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. --
-- IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, --
-- DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR --
-- OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR --
-- THE USE OR OTHER DEALINGS IN THE SOFTWARE. --
-- --
-- Except as contained in this notice, the name(s) of the above copyright --
-- holders shall not be used in advertising or otherwise to promote the --
-- sale, use or other dealings in this Software without prior written --
-- authorization. --
------------------------------------------------------------------------------
-- Author: Juergen Pfeifer <[email protected]> 1996
-- Version Control
-- $Revision: 1.5 $
-- Binding Version 00.93
------------------------------------------------------------------------------
package Sample.Form_Demo is
procedure Demo;
end Sample.Form_Demo;
|
persan/advent-of-code-2020 | Ada | 4,170 | ads | -- --- Day 5: Binary Boarding ---
--
-- You board your plane only to discover a new problem: you dropped your boarding pass!
-- You aren't sure which seat is yours, and all of the flight attendants are busy with
-- the flood of people that suddenly made it through passport control.
--
-- You write a quick program to use your phone's camera to scan all of the nearby boarding passes (your puzzle input);
-- perhaps you can find your seat through process of elimination.
--
-- Instead of zones or groups, this airline uses binary space partitioning to seat people.
-- A seat might be specified like FBFBBFFRLR, where F means "front", B means "back", L means "left", and R means "right".
--
-- The first 7 characters will either be F or B; these specify exactly one of the 128 rows on the plane (numbered 0 through 127).
-- Each letter tells you which half of a region the given seat is in.
-- Start with the whole list of rows;
-- the first letter indicates whether the seat is in the front (0 through 63) or the back (64 through 127).
-- The next letter indicates which half of that region the seat is in, and so on until you're left with exactly one row.
--
-- For example, consider just the first seven characters of FBFBBFFRLR:
--
-- Start by considering the whole range, rows 0 through 127.
-- F means to take the lower half, keeping rows 0 through 63.
-- B means to take the upper half, keeping rows 32 through 63.
-- F means to take the lower half, keeping rows 32 through 47.
-- B means to take the upper half, keeping rows 40 through 47.
-- B keeps rows 44 through 47.
-- F keeps rows 44 through 45.
-- The final F keeps the lower of the two, row 44.
--
-- The last three characters will be either L or R;
-- these specify exactly one of the 8 columns of seats on the plane (numbered 0 through 7).
-- The same process as above proceeds again, this time with only three steps.
-- L means to keep the lower half, while R means to keep the upper half.
--
-- For example, consider just the last 3 characters of FBFBBFFRLR:
--
-- Start by considering the whole range, columns 0 through 7.
-- R means to take the upper half, keeping columns 4 through 7.
-- L means to take the lower half, keeping columns 4 through 5.
-- The final R keeps the upper of the two, column 5.
--
-- So, decoding FBFBBFFRLR reveals that it is the seat at row 44, column 5.
--
-- Every seat also has a unique seat ID: multiply the row by 8, then add the column.
-- In this example, the seat has ID 44 * 8 + 5 = 357.
--
-- Here are some other boarding passes:
--
-- BFFFBBFRRR: row 70, column 7, seat ID 567.
-- FFFBBBFRRR: row 14, column 7, seat ID 119.
-- BBFFBBFRLL: row 102, column 4, seat ID 820.
--
-- As a sanity check, look through your list of boarding passes. What is the highest seat ID on a boarding pass?
-- =======================================================================================================================
--- Part Two ---
-- Ding! The "fasten seat belt" signs have turned on. Time to find your seat.
--
-- It's a completely full flight, so your seat should be the only missing boarding pass in your list.
-- However, there's a catch: some of the seats at the very front and back of the plane don't exist on this aircraft,
-- so they'll be missing from your list as well.
--
-- Your seat wasn't at the very front or back, though; the seats with IDs +1 and -1 from yours will be in your list.
--
-- What is the ID of your seat?
-- =======================================================================================================================
package Adventofcode.Day_5 is
MAX_SEAT_ROW : constant := 127;
MAX_SEAT_ON_ROW : constant := 7;
type Seat_Row_Type is range 0 .. MAX_SEAT_ROW;
type Seat_On_Row_Type is range 0 .. MAX_SEAT_ON_ROW;
type Seat_Id_Type is range 0 .. (MAX_SEAT_ROW + 1) * 8 + (MAX_SEAT_ON_ROW + 1);
function Get_Seat_Id (From : String) return Seat_Id_Type with
Pre => (From'Length = 10 and then
(for all I in From'Range => From (I) in 'F' | 'B' | 'R' | 'L'));
end Adventofcode.Day_5;
|
reznikmm/matreshka | Ada | 3,633 | 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.Duration_Constraints.Hash is
new AMF.Elements.Generic_Hash (UML_Duration_Constraint, UML_Duration_Constraint_Access);
|
zhmu/ananas | Ada | 52,505 | adb | ------------------------------------------------------------------------------
-- --
-- GNAT COMPILER COMPONENTS --
-- --
-- P A R . P R A G --
-- --
-- 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. 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. --
-- --
------------------------------------------------------------------------------
-- Generally the parser checks the basic syntax of pragmas, but does not
-- do specialized syntax checks for individual pragmas, these are deferred
-- to semantic analysis time (see unit Sem_Prag). There are some pragmas
-- which require recognition and either partial or complete processing
-- during parsing, and this unit performs this required processing.
with Fname.UF; use Fname.UF;
with Osint; use Osint;
with Rident; use Rident;
with Restrict; use Restrict;
with Stringt; use Stringt;
with Stylesw; use Stylesw;
with Uintp; use Uintp;
with Uname; use Uname;
with System.WCh_Con; use System.WCh_Con;
separate (Par)
function Prag (Pragma_Node : Node_Id; Semi : Source_Ptr) return Node_Id is
Prag_Name : constant Name_Id := Pragma_Name_Unmapped (Pragma_Node);
Prag_Id : constant Pragma_Id := Get_Pragma_Id (Prag_Name);
Pragma_Sloc : constant Source_Ptr := Sloc (Pragma_Node);
Arg_Count : Nat;
Arg_Node : Node_Id;
-----------------------
-- Local Subprograms --
-----------------------
procedure Add_List_Pragma_Entry (PT : List_Pragma_Type; Loc : Source_Ptr);
-- Make a new entry in the List_Pragmas table if this entry is not already
-- in the table (it will always be the last one if there is a duplication
-- resulting from the use of Save/Restore_Scan_State).
function Arg1 return Node_Id;
function Arg2 return Node_Id;
function Arg3 return Node_Id;
-- Obtain specified Pragma_Argument_Association. It is allowable to call
-- the routine for the argument one past the last present argument, but
-- that is the only case in which a non-present argument can be referenced.
procedure Check_Arg_Count (Required : Int);
-- Check argument count for pragma = Required. If not give error and raise
-- Error_Resync.
procedure Check_Arg_Is_String_Literal (Arg : Node_Id);
-- Check the expression of the specified argument to make sure that it
-- is a string literal. If not give error and raise Error_Resync.
procedure Check_Arg_Is_On_Or_Off (Arg : Node_Id);
-- Check the expression of the specified argument to make sure that it
-- is an identifier which is either ON or OFF, and if not, then issue
-- an error message and raise Error_Resync.
procedure Check_No_Identifier (Arg : Node_Id);
-- Checks that the given argument does not have an identifier. If
-- an identifier is present, then an error message is issued, and
-- Error_Resync is raised.
procedure Check_Optional_Identifier (Arg : Node_Id; Id : Name_Id);
-- Checks if the given argument has an identifier, and if so, requires
-- it to match the given identifier name. If there is a non-matching
-- identifier, then an error message is given and Error_Resync raised.
procedure Check_Required_Identifier (Arg : Node_Id; Id : Name_Id);
-- Same as Check_Optional_Identifier, except that the name is required
-- to be present and to match the given Id value.
procedure Process_Restrictions_Or_Restriction_Warnings;
-- Common processing for Restrictions and Restriction_Warnings pragmas.
-- For the most part, restrictions need not be processed at parse time,
-- since they only affect semantic processing. This routine handles the
-- exceptions as follows
--
-- No_Obsolescent_Features must be processed at parse time, since there
-- are some obsolescent features (e.g. character replacements) which are
-- handled at parse time.
--
-- No_Dependence must be processed at parse time, since otherwise it gets
-- handled too late.
--
-- No_Unrecognized_Aspects must be processed at parse time, since
-- unrecognized aspects are ignored by the parser.
--
-- Note that we don't need to do full error checking for badly formed cases
-- of restrictions, since these will be caught during semantic analysis.
---------------------------
-- Add_List_Pragma_Entry --
---------------------------
procedure Add_List_Pragma_Entry (PT : List_Pragma_Type; Loc : Source_Ptr) is
begin
if List_Pragmas.Last < List_Pragmas.First
or else (List_Pragmas.Table (List_Pragmas.Last)) /= ((PT, Loc))
then
List_Pragmas.Append ((PT, Loc));
end if;
end Add_List_Pragma_Entry;
----------
-- Arg1 --
----------
function Arg1 return Node_Id is
begin
return First (Pragma_Argument_Associations (Pragma_Node));
end Arg1;
----------
-- Arg2 --
----------
function Arg2 return Node_Id is
begin
return Next (Arg1);
end Arg2;
----------
-- Arg3 --
----------
function Arg3 return Node_Id is
begin
return Next (Arg2);
end Arg3;
---------------------
-- Check_Arg_Count --
---------------------
procedure Check_Arg_Count (Required : Int) is
begin
if Arg_Count /= Required then
Error_Msg_N ("wrong number of arguments for pragma%", Pragma_Node);
raise Error_Resync;
end if;
end Check_Arg_Count;
----------------------------
-- Check_Arg_Is_On_Or_Off --
----------------------------
procedure Check_Arg_Is_On_Or_Off (Arg : Node_Id) is
Argx : constant Node_Id := Expression (Arg);
begin
if Nkind (Expression (Arg)) /= N_Identifier
or else Chars (Argx) not in Name_On | Name_Off
then
Error_Msg_Name_2 := Name_On;
Error_Msg_Name_3 := Name_Off;
Error_Msg_N ("argument for pragma% must be% or%", Argx);
raise Error_Resync;
end if;
end Check_Arg_Is_On_Or_Off;
---------------------------------
-- Check_Arg_Is_String_Literal --
---------------------------------
procedure Check_Arg_Is_String_Literal (Arg : Node_Id) is
begin
if Nkind (Expression (Arg)) /= N_String_Literal then
Error_Msg_N
("argument for pragma% must be string literal",
Expression (Arg));
raise Error_Resync;
end if;
end Check_Arg_Is_String_Literal;
-------------------------
-- Check_No_Identifier --
-------------------------
procedure Check_No_Identifier (Arg : Node_Id) is
begin
if Chars (Arg) /= No_Name then
Error_Msg_N ("pragma% does not permit named arguments", Arg);
raise Error_Resync;
end if;
end Check_No_Identifier;
-------------------------------
-- Check_Optional_Identifier --
-------------------------------
procedure Check_Optional_Identifier (Arg : Node_Id; Id : Name_Id) is
begin
if Present (Arg) and then Chars (Arg) /= No_Name then
if Chars (Arg) /= Id then
Error_Msg_Name_2 := Id;
Error_Msg_N ("pragma% argument expects identifier%", Arg);
end if;
end if;
end Check_Optional_Identifier;
-------------------------------
-- Check_Required_Identifier --
-------------------------------
procedure Check_Required_Identifier (Arg : Node_Id; Id : Name_Id) is
begin
if Chars (Arg) /= Id then
Error_Msg_Name_2 := Id;
Error_Msg_N ("pragma% argument must have identifier%", Arg);
end if;
end Check_Required_Identifier;
--------------------------------------------------
-- Process_Restrictions_Or_Restriction_Warnings --
--------------------------------------------------
procedure Process_Restrictions_Or_Restriction_Warnings is
Arg : Node_Id;
Id : Name_Id;
Expr : Node_Id;
begin
Arg := Arg1;
while Present (Arg) loop
Id := Chars (Arg);
Expr := Expression (Arg);
if Id = No_Name and then Nkind (Expr) = N_Identifier then
case Chars (Expr) is
when Name_No_Obsolescent_Features =>
Set_Restriction (No_Obsolescent_Features, Pragma_Node);
Restriction_Warnings (No_Obsolescent_Features) :=
Prag_Id = Pragma_Restriction_Warnings;
when Name_SPARK_05 =>
Error_Msg_Name_1 := Chars (Expr);
Error_Msg_N
("??% restriction is obsolete and ignored, consider " &
"using 'S'P'A'R'K_'Mode and gnatprove instead", Arg);
when Name_No_Unrecognized_Aspects =>
Set_Restriction
(No_Unrecognized_Aspects,
Pragma_Node,
Prag_Id = Pragma_Restriction_Warnings);
when others =>
null;
end case;
elsif Id = Name_No_Dependence then
Set_Restriction_No_Dependence
(Unit => Expr,
Warn => Prag_Id = Pragma_Restriction_Warnings
or else Treat_Restrictions_As_Warnings);
end if;
Next (Arg);
end loop;
end Process_Restrictions_Or_Restriction_Warnings;
-- Start of processing for Prag
begin
Error_Msg_Name_1 := Prag_Name;
-- Ignore unrecognized pragma. We let Sem post the warning for this, since
-- it is a semantic error, not a syntactic one (we have already checked
-- the syntax for the unrecognized pragma as required by (RM 2.8(11)).
if Prag_Id = Unknown_Pragma then
return Pragma_Node;
end if;
-- Ignore pragma if Ignore_Pragma applies. Also ignore pragma
-- Default_Scalar_Storage_Order if the -gnatI switch was given.
if Should_Ignore_Pragma_Par (Prag_Name)
or else (Prag_Id = Pragma_Default_Scalar_Storage_Order
and then Ignore_Rep_Clauses)
then
return Pragma_Node;
end if;
-- Count number of arguments. This loop also checks if any of the arguments
-- are Error, indicating a syntax error as they were parsed. If so, we
-- simply return, because we get into trouble with cascaded errors if we
-- try to perform our error checks on junk arguments.
Arg_Count := 0;
if Present (Pragma_Argument_Associations (Pragma_Node)) then
Arg_Node := Arg1;
while Arg_Node /= Empty loop
Arg_Count := Arg_Count + 1;
if Expression (Arg_Node) = Error then
return Error;
end if;
Next (Arg_Node);
end loop;
end if;
-- Remaining processing is pragma dependent
case Prag_Id is
-- Ada version pragmas must be processed at parse time, because we want
-- to set the Ada version properly at parse time to recognize the
-- appropriate Ada version syntax. However, pragma Ada_2005 and higher
-- have an optional argument; it is only the zero argument form that
-- must be processed at parse time.
------------
-- Ada_83 --
------------
when Pragma_Ada_83 =>
if not Latest_Ada_Only then
Ada_Version := Ada_83;
Ada_Version_Explicit := Ada_83;
Ada_Version_Pragma := Pragma_Node;
end if;
------------
-- Ada_95 --
------------
when Pragma_Ada_95 =>
if not Latest_Ada_Only then
Ada_Version := Ada_95;
Ada_Version_Explicit := Ada_95;
Ada_Version_Pragma := Pragma_Node;
end if;
---------------------
-- Ada_05/Ada_2005 --
---------------------
when Pragma_Ada_05
| Pragma_Ada_2005
=>
if Arg_Count = 0 and not Latest_Ada_Only then
Ada_Version := Ada_2005;
Ada_Version_Explicit := Ada_2005;
Ada_Version_Pragma := Pragma_Node;
end if;
---------------------
-- Ada_12/Ada_2012 --
---------------------
when Pragma_Ada_12
| Pragma_Ada_2012
=>
if Arg_Count = 0 then
Ada_Version := Ada_2012;
Ada_Version_Explicit := Ada_2012;
Ada_Version_Pragma := Pragma_Node;
end if;
--------------
-- Ada_2022 --
--------------
when Pragma_Ada_2022 =>
if Arg_Count = 0 then
Ada_Version := Ada_2022;
Ada_Version_Explicit := Ada_2022;
Ada_Version_Pragma := Pragma_Node;
end if;
-----------
-- Debug --
-----------
-- pragma Debug ([boolean_EXPRESSION,] PROCEDURE_CALL_STATEMENT);
when Pragma_Debug =>
Check_No_Identifier (Arg1);
if Arg_Count = 2 then
Check_No_Identifier (Arg2);
else
Check_Arg_Count (1);
end if;
-------------------------------
-- Extensions_Allowed (GNAT) --
-------------------------------
-- pragma Extensions_Allowed (Off | On)
-- The processing for pragma Extensions_Allowed must be done at
-- parse time, since extensions mode may affect what is accepted.
when Pragma_Extensions_Allowed =>
Check_Arg_Count (1);
Check_No_Identifier (Arg1);
Check_Arg_Is_On_Or_Off (Arg1);
if Chars (Expression (Arg1)) = Name_On then
Ada_Version := Ada_With_Extensions;
else
Ada_Version := Ada_Version_Explicit;
end if;
-------------------
-- Ignore_Pragma --
-------------------
-- Processing for this pragma must be done at parse time, since we want
-- be able to ignore pragmas that are otherwise processed at parse time.
when Pragma_Ignore_Pragma => Ignore_Pragma : declare
A : Node_Id;
begin
Check_Arg_Count (1);
Check_No_Identifier (Arg1);
A := Expression (Arg1);
if Nkind (A) /= N_Identifier then
Error_Msg_N ("incorrect argument for pragma %", A);
else
Set_Name_Table_Boolean3 (Chars (A), True);
end if;
end Ignore_Pragma;
----------------
-- List (2.8) --
----------------
-- pragma List (Off | On)
-- The processing for pragma List must be done at parse time, since a
-- listing can be generated in parse only mode.
when Pragma_List =>
Check_Arg_Count (1);
Check_No_Identifier (Arg1);
Check_Arg_Is_On_Or_Off (Arg1);
-- We unconditionally make a List_On entry for the pragma, so that
-- in the List (Off) case, the pragma will print even in a region
-- of code with listing turned off (this is required).
Add_List_Pragma_Entry (List_On, Sloc (Pragma_Node));
-- Now generate the list off entry for pragma List (Off)
if Chars (Expression (Arg1)) = Name_Off then
Add_List_Pragma_Entry (List_Off, Semi);
end if;
----------------
-- Page (2.8) --
----------------
-- pragma Page;
-- Processing for this pragma must be done at parse time, since a
-- listing can be generated in parse only mode with semantics off.
when Pragma_Page =>
Check_Arg_Count (0);
Add_List_Pragma_Entry (Page, Semi);
------------------
-- Restrictions --
------------------
-- pragma Restrictions (RESTRICTION {, RESTRICTION});
-- RESTRICTION ::=
-- restriction_IDENTIFIER
-- | restriction_parameter_IDENTIFIER => EXPRESSION
-- We process the case of No_Obsolescent_Features, since this has
-- a syntactic effect that we need to detect at parse time (the use
-- of replacement characters such as colon for pound sign).
when Pragma_Restrictions =>
Process_Restrictions_Or_Restriction_Warnings;
--------------------------
-- Restriction_Warnings --
--------------------------
-- pragma Restriction_Warnings (RESTRICTION {, RESTRICTION});
-- RESTRICTION ::=
-- restriction_IDENTIFIER
-- | restriction_parameter_IDENTIFIER => EXPRESSION
-- See above comment for pragma Restrictions
when Pragma_Restriction_Warnings =>
Process_Restrictions_Or_Restriction_Warnings;
----------------------------------------------------------
-- Source_File_Name and Source_File_Name_Project (GNAT) --
----------------------------------------------------------
-- These two pragmas have the same syntax and semantics.
-- There are five forms of these pragmas:
-- pragma Source_File_Name[_Project] (
-- [UNIT_NAME =>] unit_NAME,
-- BODY_FILE_NAME => STRING_LITERAL
-- [, [INDEX =>] INTEGER_LITERAL]);
-- pragma Source_File_Name[_Project] (
-- [UNIT_NAME =>] unit_NAME,
-- SPEC_FILE_NAME => STRING_LITERAL
-- [, [INDEX =>] INTEGER_LITERAL]);
-- pragma Source_File_Name[_Project] (
-- BODY_FILE_NAME => STRING_LITERAL
-- [, DOT_REPLACEMENT => STRING_LITERAL]
-- [, CASING => CASING_SPEC]);
-- pragma Source_File_Name[_Project] (
-- SPEC_FILE_NAME => STRING_LITERAL
-- [, DOT_REPLACEMENT => STRING_LITERAL]
-- [, CASING => CASING_SPEC]);
-- pragma Source_File_Name[_Project] (
-- SUBUNIT_FILE_NAME => STRING_LITERAL
-- [, DOT_REPLACEMENT => STRING_LITERAL]
-- [, CASING => CASING_SPEC]);
-- CASING_SPEC ::= Uppercase | Lowercase | Mixedcase
-- Pragma Source_File_Name_Project (SFNP) is equivalent to pragma
-- Source_File_Name (SFN), however their usage is exclusive:
-- SFN can only be used when no project file is used, while
-- SFNP can only be used when a project file is used.
-- The Project Manager produces a configuration pragmas file that
-- is communicated to the compiler with -gnatec switch. This file
-- contains only SFNP pragmas (at least two for the default naming
-- scheme. As this configuration pragmas file is always the first
-- processed by the compiler, it prevents the use of pragmas SFN in
-- other config files when a project file is in use.
-- Note: we process this during parsing, since we need to have the
-- source file names set well before the semantic analysis starts,
-- since we load the spec and with'ed packages before analysis.
when Pragma_Source_File_Name
| Pragma_Source_File_Name_Project
=>
Source_File_Name : declare
Unam : Unit_Name_Type;
Expr1 : Node_Id;
Pat : String_Ptr;
Typ : Character;
Dot : String_Ptr;
Cas : Casing_Type;
Nast : Nat;
Expr : Node_Id;
Index : Nat;
function Get_Fname (Arg : Node_Id) return File_Name_Type;
-- Process file name from unit name form of pragma
function Get_String_Argument (Arg : Node_Id) return String_Ptr;
-- Process string literal value from argument
procedure Process_Casing (Arg : Node_Id);
-- Process Casing argument of pattern form of pragma
procedure Process_Dot_Replacement (Arg : Node_Id);
-- Process Dot_Replacement argument of pattern form of pragma
---------------
-- Get_Fname --
---------------
function Get_Fname (Arg : Node_Id) return File_Name_Type is
begin
String_To_Name_Buffer (Strval (Expression (Arg)));
for J in 1 .. Name_Len loop
if Is_Directory_Separator (Name_Buffer (J)) then
Error_Msg
("directory separator character not allowed",
Sloc (Expression (Arg)) + Source_Ptr (J));
end if;
end loop;
return Name_Find;
end Get_Fname;
-------------------------
-- Get_String_Argument --
-------------------------
function Get_String_Argument (Arg : Node_Id) return String_Ptr is
Str : String_Id;
begin
if Nkind (Expression (Arg)) /= N_String_Literal
and then
Nkind (Expression (Arg)) /= N_Operator_Symbol
then
Error_Msg_N
("argument for pragma% must be string literal", Arg);
raise Error_Resync;
end if;
Str := Strval (Expression (Arg));
-- Check string has no wide chars
for J in 1 .. String_Length (Str) loop
if Get_String_Char (Str, J) > 255 then
Error_Msg
("wide character not allowed in pattern for pragma%",
Sloc (Expression (Arg2)) + Text_Ptr (J) - 1);
end if;
end loop;
-- Acquire string
String_To_Name_Buffer (Str);
return new String'(Name_Buffer (1 .. Name_Len));
end Get_String_Argument;
--------------------
-- Process_Casing --
--------------------
procedure Process_Casing (Arg : Node_Id) is
Expr : constant Node_Id := Expression (Arg);
begin
Check_Required_Identifier (Arg, Name_Casing);
if Nkind (Expr) = N_Identifier then
if Chars (Expr) = Name_Lowercase then
Cas := All_Lower_Case;
return;
elsif Chars (Expr) = Name_Uppercase then
Cas := All_Upper_Case;
return;
elsif Chars (Expr) = Name_Mixedcase then
Cas := Mixed_Case;
return;
end if;
end if;
Error_Msg_N
("Casing argument for pragma% must be " &
"one of Mixedcase, Lowercase, Uppercase",
Arg);
end Process_Casing;
-----------------------------
-- Process_Dot_Replacement --
-----------------------------
procedure Process_Dot_Replacement (Arg : Node_Id) is
begin
Check_Required_Identifier (Arg, Name_Dot_Replacement);
Dot := Get_String_Argument (Arg);
end Process_Dot_Replacement;
-- Start of processing for Source_File_Name and
-- Source_File_Name_Project pragmas.
begin
if Prag_Id = Pragma_Source_File_Name then
if Project_File_In_Use = In_Use then
Error_Msg_N
("pragma Source_File_Name cannot be used " &
"with a project file", Pragma_Node);
else
Project_File_In_Use := Not_In_Use;
end if;
else
if Project_File_In_Use = Not_In_Use then
Error_Msg_N
("pragma Source_File_Name_Project should only be used " &
"with a project file", Pragma_Node);
else
Project_File_In_Use := In_Use;
end if;
end if;
-- We permit from 1 to 3 arguments
if Arg_Count not in 1 .. 3 then
Check_Arg_Count (1);
end if;
Expr1 := Expression (Arg1);
-- If first argument is identifier or selected component, then
-- we have the specific file case of the Source_File_Name pragma,
-- and the first argument is a unit name.
if Nkind (Expr1) = N_Identifier
or else
(Nkind (Expr1) = N_Selected_Component
and then
Nkind (Selector_Name (Expr1)) = N_Identifier)
then
if Nkind (Expr1) = N_Identifier
and then Chars (Expr1) = Name_System
then
Error_Msg_N
("pragma Source_File_Name may not be used for System",
Arg1);
return Error;
end if;
-- Process index argument if present
if Arg_Count = 3 then
Expr := Expression (Arg3);
if Nkind (Expr) /= N_Integer_Literal
or else not UI_Is_In_Int_Range (Intval (Expr))
or else Intval (Expr) > 999
or else Intval (Expr) <= 0
then
Error_Msg_N
("pragma% index must be integer literal" &
" in range 1 .. 999", Expr);
raise Error_Resync;
else
Index := UI_To_Int (Intval (Expr));
end if;
-- No index argument present
else
Check_Arg_Count (2);
Index := 0;
end if;
Check_Optional_Identifier (Arg1, Name_Unit_Name);
Unam := Get_Unit_Name (Expr1);
Check_Arg_Is_String_Literal (Arg2);
if Chars (Arg2) = Name_Spec_File_Name then
Set_File_Name
(Get_Spec_Name (Unam), Get_Fname (Arg2), Index);
elsif Chars (Arg2) = Name_Body_File_Name then
Set_File_Name
(Unam, Get_Fname (Arg2), Index);
else
Error_Msg_N
("pragma% argument has incorrect identifier", Arg2);
return Pragma_Node;
end if;
-- If the first argument is not an identifier, then we must have
-- the pattern form of the pragma, and the first argument must be
-- the pattern string with an appropriate name.
else
if Chars (Arg1) = Name_Spec_File_Name then
Typ := 's';
elsif Chars (Arg1) = Name_Body_File_Name then
Typ := 'b';
elsif Chars (Arg1) = Name_Subunit_File_Name then
Typ := 'u';
elsif Chars (Arg1) = Name_Unit_Name then
Error_Msg_N
("Unit_Name parameter for pragma% must be an identifier",
Arg1);
raise Error_Resync;
else
Error_Msg_N
("pragma% argument has incorrect identifier", Arg1);
raise Error_Resync;
end if;
Pat := Get_String_Argument (Arg1);
-- Check pattern has exactly one asterisk
Nast := 0;
for J in Pat'Range loop
if Pat (J) = '*' then
Nast := Nast + 1;
end if;
end loop;
if Nast /= 1 then
Error_Msg_N
("file name pattern must have exactly one * character",
Arg1);
return Pragma_Node;
end if;
-- Set defaults for Casing and Dot_Separator parameters
Cas := All_Lower_Case;
Dot := new String'(".");
-- Process second and third arguments if present
if Arg_Count > 1 then
if Chars (Arg2) = Name_Casing then
Process_Casing (Arg2);
if Arg_Count = 3 then
Process_Dot_Replacement (Arg3);
end if;
else
Process_Dot_Replacement (Arg2);
if Arg_Count = 3 then
Process_Casing (Arg3);
end if;
end if;
end if;
Set_File_Name_Pattern (Pat, Typ, Dot, Cas);
end if;
end Source_File_Name;
-----------------------------
-- Source_Reference (GNAT) --
-----------------------------
-- pragma Source_Reference
-- (INTEGER_LITERAL [, STRING_LITERAL] );
-- Processing for this pragma must be done at parse time, since error
-- messages needing the proper line numbers can be generated in parse
-- only mode with semantic checking turned off, and indeed we usually
-- turn off semantic checking anyway if any parse errors are found.
when Pragma_Source_Reference => Source_Reference : declare
Fname : File_Name_Type;
begin
if Arg_Count /= 1 then
Check_Arg_Count (2);
Check_No_Identifier (Arg2);
end if;
-- Check that this is first line of file. We skip this test if
-- we are in syntax check only mode, since we may be dealing with
-- multiple compilation units.
if Get_Physical_Line_Number (Pragma_Sloc) /= 1
and then Num_SRef_Pragmas (Current_Source_File) = 0
and then Operating_Mode /= Check_Syntax
then
Error_Msg_N -- CODEFIX
("first % pragma must be first line of file", Pragma_Node);
raise Error_Resync;
end if;
Check_No_Identifier (Arg1);
if Arg_Count = 1 then
if Num_SRef_Pragmas (Current_Source_File) = 0 then
Error_Msg_N
("file name required for first % pragma in file",
Pragma_Node);
raise Error_Resync;
else
Fname := No_File;
end if;
-- File name present
else
Check_Arg_Is_String_Literal (Arg2);
String_To_Name_Buffer (Strval (Expression (Arg2)));
Fname := Name_Find;
if Num_SRef_Pragmas (Current_Source_File) > 0 then
if Fname /= Full_Ref_Name (Current_Source_File) then
Error_Msg_N
("file name must be same in all % pragmas", Pragma_Node);
raise Error_Resync;
end if;
end if;
end if;
if Nkind (Expression (Arg1)) /= N_Integer_Literal then
Error_Msg_N
("argument for pragma% must be integer literal",
Expression (Arg1));
raise Error_Resync;
-- OK, this source reference pragma is effective, however, we
-- ignore it if it is not in the first unit in the multiple unit
-- case. This is because the only purpose in this case is to
-- provide source pragmas for subsequent use by gnatchop.
else
if Num_Library_Units = 1 then
Register_Source_Ref_Pragma
(Fname,
Strip_Directory (Fname),
UI_To_Int (Intval (Expression (Arg1))),
Get_Physical_Line_Number (Pragma_Sloc) + 1);
end if;
end if;
end Source_Reference;
-------------------------
-- Style_Checks (GNAT) --
-------------------------
-- pragma Style_Checks (On | Off | ALL_CHECKS | STRING_LITERAL);
-- This is processed by the parser since some of the style
-- checks take place during source scanning and parsing.
when Pragma_Style_Checks => Style_Checks : declare
A : Node_Id;
S : String_Id;
C : Char_Code;
OK : Boolean := True;
begin
-- Two argument case is only for semantics
if Arg_Count = 2 then
null;
else
Check_Arg_Count (1);
Check_No_Identifier (Arg1);
A := Expression (Arg1);
if Nkind (A) = N_String_Literal then
S := Strval (A);
declare
Slen : constant Natural := Natural (String_Length (S));
Options : String (1 .. Slen);
J : Positive;
Ptr : Positive;
begin
J := 1;
loop
C := Get_String_Char (S, Pos (J));
if not In_Character_Range (C) then
OK := False;
Ptr := J;
exit;
else
Options (J) := Get_Character (C);
end if;
if J = Slen then
if not Ignore_Style_Checks_Pragmas then
Set_Style_Check_Options (Options, OK, Ptr);
end if;
exit;
else
J := J + 1;
end if;
end loop;
if not OK then
Error_Msg
(Style_Msg_Buf (1 .. Style_Msg_Len),
Sloc (Expression (Arg1)) + Source_Ptr (Ptr));
raise Error_Resync;
end if;
end;
elsif Nkind (A) /= N_Identifier then
OK := False;
elsif Chars (A) = Name_All_Checks then
if not Ignore_Style_Checks_Pragmas then
if GNAT_Mode then
Stylesw.Set_GNAT_Style_Check_Options;
else
Stylesw.Set_Default_Style_Check_Options;
end if;
end if;
elsif Chars (A) = Name_On then
if not Ignore_Style_Checks_Pragmas then
Style_Check := True;
end if;
elsif Chars (A) = Name_Off then
if not Ignore_Style_Checks_Pragmas then
Style_Check := False;
end if;
else
OK := False;
end if;
if not OK then
Error_Msg_N ("incorrect argument for pragma%", A);
raise Error_Resync;
end if;
end if;
end Style_Checks;
-------------------------
-- Suppress_All (GNAT) --
-------------------------
-- pragma Suppress_All
-- This is a rather odd pragma, because other compilers allow it in
-- strange places. DEC allows it at the end of units, and Rational
-- allows it as a program unit pragma, when it would be more natural
-- if it were a configuration pragma.
-- Since the reason we provide this pragma is for compatibility with
-- these other compilers, we want to accommodate these strange placement
-- rules, and the easiest thing is simply to allow it anywhere in a
-- unit. If this pragma appears anywhere within a unit, then the effect
-- is as though a pragma Suppress (All_Checks) had appeared as the first
-- line of the current file, i.e. as the first configuration pragma in
-- the current unit.
-- To get this effect, we set the flag Has_Pragma_Suppress_All in the
-- compilation unit node for the current source file then in the last
-- stage of parsing a file, if this flag is set, we materialize the
-- Suppress (All_Checks) pragma, marked as not coming from Source.
when Pragma_Suppress_All =>
Set_Has_Pragma_Suppress_All (Cunit (Current_Source_Unit));
----------------------
-- Warning_As_Error --
----------------------
-- pragma Warning_As_Error (static_string_EXPRESSION);
-- Further processing is done in Sem_Prag
when Pragma_Warning_As_Error =>
Check_Arg_Count (1);
Check_Arg_Is_String_Literal (Arg1);
Warnings_As_Errors_Count := Warnings_As_Errors_Count + 1;
Warnings_As_Errors (Warnings_As_Errors_Count) :=
new String'(Acquire_Warning_Match_String (Get_Pragma_Arg (Arg1)));
---------------------
-- Warnings (GNAT) --
---------------------
-- pragma Warnings ([TOOL_NAME,] DETAILS [, REASON]);
-- DETAILS ::= On | Off
-- DETAILS ::= On | Off, local_NAME
-- DETAILS ::= static_string_EXPRESSION
-- DETAILS ::= On | Off, static_string_EXPRESSION
-- TOOL_NAME ::= GNAT | GNATprove
-- REASON ::= Reason => STRING_LITERAL {& STRING_LITERAL}
-- Note: If the first argument matches an allowed tool name, it is
-- always considered to be a tool name, even if there is a string
-- variable of that name.
-- The one argument ON/OFF case is processed by the parser, since it may
-- control parser warnings as well as semantic warnings, and in any case
-- we want to be absolutely sure that the range in the warnings table is
-- set well before any semantic analysis is performed. Note that we
-- ignore this pragma if debug flag -gnatd.i is set.
-- Also note that the "one argument" case may have two or three
-- arguments if the first one is a tool name, and/or the last one is a
-- reason argument.
when Pragma_Warnings => Warnings : declare
function First_Arg_Is_Matching_Tool_Name return Boolean;
-- Returns True if the first argument is a tool name matching the
-- current tool being run.
function Last_Arg return Node_Id;
-- Returns the last argument
function Last_Arg_Is_Reason return Boolean;
-- Returns True if the last argument is a reason argument
function Get_Reason return String_Id;
-- Analyzes Reason argument and returns corresponding String_Id
-- value, or null if there is no Reason argument, or if the
-- argument is not of the required form.
-------------------------------------
-- First_Arg_Is_Matching_Tool_Name --
-------------------------------------
function First_Arg_Is_Matching_Tool_Name return Boolean is
begin
return Nkind (Arg1) = N_Identifier
-- Return True if the tool name is GNAT, and we're not in
-- GNATprove or CodePeer mode...
and then ((Chars (Arg1) = Name_Gnat
and then not
(CodePeer_Mode or GNATprove_Mode))
-- or if the tool name is GNATprove, and we're in GNATprove
-- mode.
or else
(Chars (Arg1) = Name_Gnatprove
and then GNATprove_Mode));
end First_Arg_Is_Matching_Tool_Name;
----------------
-- Get_Reason --
----------------
function Get_Reason return String_Id is
Arg : constant Node_Id := Last_Arg;
begin
if Last_Arg_Is_Reason then
Start_String;
Get_Reason_String (Expression (Arg));
return End_String;
else
return Null_String_Id;
end if;
end Get_Reason;
--------------
-- Last_Arg --
--------------
function Last_Arg return Node_Id is
Last_Arg : Node_Id;
begin
if Arg_Count = 1 then
Last_Arg := Arg1;
elsif Arg_Count = 2 then
Last_Arg := Arg2;
elsif Arg_Count = 3 then
Last_Arg := Arg3;
elsif Arg_Count = 4 then
Last_Arg := Next (Arg3);
-- Illegal case, error issued in semantic analysis
else
Last_Arg := Empty;
end if;
return Last_Arg;
end Last_Arg;
------------------------
-- Last_Arg_Is_Reason --
------------------------
function Last_Arg_Is_Reason return Boolean is
Arg : constant Node_Id := Last_Arg;
begin
return Nkind (Arg) in N_Has_Chars
and then Chars (Arg) = Name_Reason;
end Last_Arg_Is_Reason;
The_Arg : Node_Id; -- On/Off argument
Argx : Node_Id;
-- Start of processing for Warnings
begin
if not Debug_Flag_Dot_I
and then (Arg_Count = 1
or else (Arg_Count = 2
and then (First_Arg_Is_Matching_Tool_Name
or else
Last_Arg_Is_Reason))
or else (Arg_Count = 3
and then First_Arg_Is_Matching_Tool_Name
and then Last_Arg_Is_Reason))
then
if First_Arg_Is_Matching_Tool_Name then
The_Arg := Arg2;
else
The_Arg := Arg1;
end if;
Check_No_Identifier (The_Arg);
Argx := Expression (The_Arg);
if Nkind (Argx) = N_Identifier then
if Chars (Argx) = Name_On then
Set_Warnings_Mode_On (Pragma_Sloc);
elsif Chars (Argx) = Name_Off then
Set_Warnings_Mode_Off (Pragma_Sloc, Get_Reason);
end if;
end if;
end if;
end Warnings;
-----------------------------
-- Wide_Character_Encoding --
-----------------------------
-- pragma Wide_Character_Encoding (IDENTIFIER | CHARACTER_LITERAL);
-- This is processed by the parser, since the scanner is affected
when Pragma_Wide_Character_Encoding => Wide_Character_Encoding : declare
A : Node_Id;
begin
Check_Arg_Count (1);
Check_No_Identifier (Arg1);
A := Expression (Arg1);
if Nkind (A) = N_Identifier then
Get_Name_String (Chars (A));
Wide_Character_Encoding_Method :=
Get_WC_Encoding_Method (Name_Buffer (1 .. Name_Len));
elsif Nkind (A) = N_Character_Literal then
declare
R : constant Char_Code :=
Char_Code (UI_To_Int (Char_Literal_Value (A)));
begin
if In_Character_Range (R) then
Wide_Character_Encoding_Method :=
Get_WC_Encoding_Method (Get_Character (R));
else
raise Constraint_Error;
end if;
end;
else
raise Constraint_Error;
end if;
Upper_Half_Encoding :=
Wide_Character_Encoding_Method in
WC_Upper_Half_Encoding_Method;
exception
when Constraint_Error =>
Error_Msg_N ("invalid argument for pragma%", Arg1);
end Wide_Character_Encoding;
-----------------------
-- All Other Pragmas --
-----------------------
-- For all other pragmas, checking and processing is handled entirely in
-- Sem_Prag, and no further checking is done by Par.
when Pragma_Abort_Defer
| Pragma_Abstract_State
| Pragma_Aggregate_Individually_Assign
| Pragma_All_Calls_Remote
| Pragma_Allow_Integer_Address
| Pragma_Annotate
| Pragma_Assert
| Pragma_Assert_And_Cut
| Pragma_Assertion_Policy
| Pragma_Assume
| Pragma_Assume_No_Invalid_Values
| Pragma_Async_Readers
| Pragma_Async_Writers
| Pragma_Asynchronous
| Pragma_Atomic
| Pragma_Atomic_Components
| Pragma_Attach_Handler
| Pragma_Attribute_Definition
| Pragma_CPP_Class
| Pragma_CPP_Constructor
| Pragma_CPP_Virtual
| Pragma_CPP_Vtable
| Pragma_CPU
| Pragma_CUDA_Device
| Pragma_CUDA_Execute
| Pragma_CUDA_Global
| Pragma_C_Pass_By_Copy
| Pragma_Check
| Pragma_Check_Float_Overflow
| Pragma_Check_Name
| Pragma_Check_Policy
| Pragma_Comment
| Pragma_Common_Object
| Pragma_Compile_Time_Error
| Pragma_Compile_Time_Warning
| Pragma_Complete_Representation
| Pragma_Complex_Representation
| Pragma_Component_Alignment
| Pragma_Constant_After_Elaboration
| Pragma_Contract_Cases
| Pragma_Controlled
| Pragma_Convention
| Pragma_Convention_Identifier
| Pragma_Deadline_Floor
| Pragma_Debug_Policy
| Pragma_Default_Initial_Condition
| Pragma_Default_Scalar_Storage_Order
| Pragma_Default_Storage_Pool
| Pragma_Depends
| Pragma_Detect_Blocking
| Pragma_Disable_Atomic_Synchronization
| Pragma_Discard_Names
| Pragma_Dispatching_Domain
| Pragma_Effective_Reads
| Pragma_Effective_Writes
| Pragma_Elaborate
| Pragma_Elaborate_All
| Pragma_Elaborate_Body
| Pragma_Elaboration_Checks
| Pragma_Eliminate
| Pragma_Enable_Atomic_Synchronization
| Pragma_Export
| Pragma_Export_Function
| Pragma_Export_Object
| Pragma_Export_Procedure
| Pragma_Export_Valued_Procedure
| Pragma_Extend_System
| Pragma_Extensions_Visible
| Pragma_External
| Pragma_External_Name_Casing
| Pragma_Fast_Math
| Pragma_Favor_Top_Level
| Pragma_Finalize_Storage_Only
| Pragma_Ghost
| Pragma_Global
| Pragma_GNAT_Annotate
| Pragma_Ident
| Pragma_Implementation_Defined
| Pragma_Implemented
| Pragma_Implicit_Packing
| Pragma_Import
| Pragma_Import_Function
| Pragma_Import_Object
| Pragma_Import_Procedure
| Pragma_Import_Valued_Procedure
| Pragma_Independent
| Pragma_Independent_Components
| Pragma_Initial_Condition
| Pragma_Initialize_Scalars
| Pragma_Initializes
| Pragma_Inline
| Pragma_Inline_Always
| Pragma_Inline_Generic
| Pragma_Inspection_Point
| Pragma_Interface
| Pragma_Interface_Name
| Pragma_Interrupt_Handler
| Pragma_Interrupt_Priority
| Pragma_Interrupt_State
| Pragma_Invariant
| Pragma_Keep_Names
| Pragma_License
| Pragma_Link_With
| Pragma_Linker_Alias
| Pragma_Linker_Constructor
| Pragma_Linker_Destructor
| Pragma_Linker_Options
| Pragma_Linker_Section
| Pragma_Lock_Free
| Pragma_Locking_Policy
| Pragma_Loop_Invariant
| Pragma_Loop_Optimize
| Pragma_Loop_Variant
| Pragma_Machine_Attribute
| Pragma_Main
| Pragma_Main_Storage
| Pragma_Max_Entry_Queue_Depth
| Pragma_Max_Entry_Queue_Length
| Pragma_Max_Queue_Length
| Pragma_Memory_Size
| Pragma_No_Body
| Pragma_No_Caching
| Pragma_No_Component_Reordering
| Pragma_No_Elaboration_Code_All
| Pragma_No_Heap_Finalization
| Pragma_No_Inline
| Pragma_No_Return
| Pragma_No_Run_Time
| Pragma_No_Strict_Aliasing
| Pragma_No_Tagged_Streams
| Pragma_Normalize_Scalars
| Pragma_Obsolescent
| Pragma_Optimize
| Pragma_Optimize_Alignment
| Pragma_Ordered
| Pragma_Overflow_Mode
| Pragma_Overriding_Renamings
| Pragma_Pack
| Pragma_Part_Of
| Pragma_Partition_Elaboration_Policy
| Pragma_Passive
| Pragma_Persistent_BSS
| Pragma_Post
| Pragma_Post_Class
| Pragma_Postcondition
| Pragma_Pre
| Pragma_Pre_Class
| Pragma_Precondition
| Pragma_Predicate
| Pragma_Predicate_Failure
| Pragma_Preelaborable_Initialization
| Pragma_Preelaborate
| Pragma_Prefix_Exception_Messages
| Pragma_Priority
| Pragma_Priority_Specific_Dispatching
| Pragma_Profile
| Pragma_Profile_Warnings
| Pragma_Propagate_Exceptions
| Pragma_Provide_Shift_Operators
| Pragma_Psect_Object
| Pragma_Pure
| Pragma_Pure_Function
| Pragma_Queuing_Policy
| Pragma_Rational
| Pragma_Ravenscar
| Pragma_Refined_Depends
| Pragma_Refined_Global
| Pragma_Refined_Post
| Pragma_Refined_State
| Pragma_Relative_Deadline
| Pragma_Remote_Access_Type
| Pragma_Remote_Call_Interface
| Pragma_Remote_Types
| Pragma_Rename_Pragma
| Pragma_Restricted_Run_Time
| Pragma_Reviewable
| Pragma_SPARK_Mode
| Pragma_Secondary_Stack_Size
| Pragma_Share_Generic
| Pragma_Shared
| Pragma_Shared_Passive
| Pragma_Short_Circuit_And_Or
| Pragma_Short_Descriptors
| Pragma_Simple_Storage_Pool_Type
| Pragma_Static_Elaboration_Desired
| Pragma_Storage_Size
| Pragma_Storage_Unit
| Pragma_Stream_Convert
| Pragma_Subtitle
| Pragma_Subprogram_Variant
| Pragma_Suppress
| Pragma_Suppress_Debug_Info
| Pragma_Suppress_Exception_Locations
| Pragma_Suppress_Initialization
| Pragma_System_Name
| Pragma_Task_Dispatching_Policy
| Pragma_Task_Info
| Pragma_Task_Name
| Pragma_Task_Storage
| Pragma_Test_Case
| Pragma_Thread_Local_Storage
| Pragma_Time_Slice
| Pragma_Title
| Pragma_Type_Invariant
| Pragma_Type_Invariant_Class
| Pragma_Unchecked_Union
| Pragma_Unevaluated_Use_Of_Old
| Pragma_Unimplemented_Unit
| Pragma_Universal_Aliasing
| Pragma_Unmodified
| Pragma_Unreferenced
| Pragma_Unreferenced_Objects
| Pragma_Unreserve_All_Interrupts
| Pragma_Unsuppress
| Pragma_Unused
| Pragma_Use_VADS_Size
| Pragma_Validity_Checks
| Pragma_Volatile
| Pragma_Volatile_Components
| Pragma_Volatile_Full_Access
| Pragma_Volatile_Function
| Pragma_Weak_External
=>
null;
--------------------
-- Unknown_Pragma --
--------------------
-- Should be impossible, since we excluded this case earlier on
when Unknown_Pragma =>
raise Program_Error;
end case;
return Pragma_Node;
--------------------
-- Error Handling --
--------------------
exception
when Error_Resync =>
return Error;
end Prag;
|
gitter-badger/libAnne | Ada | 3,816 | ads | package Generics.Mathematics.Arrays.IO is
--@Description Provides generic input/output operations for Mathematics.Arrays
--@Version 1.0
-------------------
-- Integer Array --
-------------------
generic
type Integer_Type is range <>;
type Integer_Array_Type is array(Positive range <>) of Integer_Type;
function Integer_Array_Image(Value : Integer_Array_Type) return String with Inline, Pure_Function;
generic
type Integer_Type is range <>;
type Integer_Array_Type is array(Positive range <>) of Integer_Type;
function Integer_Array_Wide_Image(Value : Integer_Array_Type) return Wide_String with Inline, Pure_Function;
generic
type Integer_Type is range <>;
type Integer_Array_Type is array(Positive range <>) of Integer_Type;
function Integer_Array_Wide_Wide_Image(Value : Integer_Array_Type) return Wide_Wide_String with Inline, Pure_Function;
-------------------
-- Modular Array --
-------------------
generic
type Modular_Type is mod <>;
type Modular_Array_Type is array(Positive range <>) of Modular_Type;
function Modular_Array_Image(Value : Modular_Array_Type) return String with Inline, Pure_Function;
generic
type Modular_Type is mod <>;
type Modular_Array_Type is array(Positive range <>) of Modular_Type;
function Modular_Array_Wide_Image(Value : Modular_Array_Type) return Wide_String with Inline, Pure_Function;
generic
type Modular_Type is mod <>;
type Modular_Array_Type is array(Positive range <>) of Modular_Type;
function Modular_Array_Wide_Wide_Image(Value : Modular_Array_Type) return Wide_Wide_String with Inline, Pure_Function;
-------------------
-- Fixed Array --
-------------------
generic
type Fixed_Type is delta <>;
type Fixed_Array_Type is array(Positive range <>) of Fixed_Type;
function Fixed_Array_Image(Value : Fixed_Array_Type) return String with Inline, Pure_Function;
generic
type Fixed_Type is delta <>;
type Fixed_Array_Type is array(Positive range <>) of Fixed_Type;
function Fixed_Array_Wide_Image(Value : Fixed_Array_Type) return Wide_String with Inline, Pure_Function;
generic
type Fixed_Type is delta <>;
type Fixed_Array_Type is array(Positive range <>) of Fixed_Type;
function Fixed_Array_Wide_Wide_Image(Value : Fixed_Array_Type) return Wide_Wide_String with Inline, Pure_Function;
-------------------
-- Decimal Array --
-------------------
generic
type Decimal_Type is delta <> digits <>;
type Decimal_Array_Type is array(Positive range <>) of Decimal_Type;
function Decimal_Array_Image(Value : Decimal_Array_Type) return String with Inline, Pure_Function;
generic
type Decimal_Type is delta <> digits <>;
type Decimal_Array_Type is array(Positive range <>) of Decimal_Type;
function Decimal_Array_Wide_Image(Value : Decimal_Array_Type) return Wide_String with Inline, Pure_Function;
generic
type Decimal_Type is delta <> digits <>;
type Decimal_Array_Type is array(Positive range <>) of Decimal_Type;
function Decimal_Array_Wide_Wide_Image(Value : Decimal_Array_Type) return Wide_Wide_String with Inline, Pure_Function;
-------------------
-- Float Array --
-------------------
generic
type Float_Type is digits <>;
type Float_Array_Type is array(Positive range <>) of Float_Type;
function Float_Array_Image(Value : Float_Array_Type) return String with Inline, Pure_Function;
generic
type Float_Type is digits <>;
type Float_Array_Type is array(Positive range <>) of Float_Type;
function Float_Array_Wide_Image(Value : Float_Array_Type) return Wide_String with Inline, Pure_Function;
generic
type Float_Type is digits <>;
type Float_Array_Type is array(Positive range <>) of Float_Type;
function Float_Array_Wide_Wide_Image(Value : Float_Array_Type) return Wide_Wide_String with Inline, Pure_Function;
end Generics.Mathematics.Arrays.IO;
|
reznikmm/matreshka | Ada | 3,749 | 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.Table_Acceptance_State_Attributes is
pragma Preelaborate;
type ODF_Table_Acceptance_State_Attribute is limited interface
and XML.DOM.Attributes.DOM_Attribute;
type ODF_Table_Acceptance_State_Attribute_Access is
access all ODF_Table_Acceptance_State_Attribute'Class
with Storage_Size => 0;
end ODF.DOM.Table_Acceptance_State_Attributes;
|
Robert-Tice/EmbeddedFractal | Ada | 7,865 | adb | with Ada.Real_Time; use Ada.Real_Time;
with System;
with SAM.Device;
with HAL; use HAL;
with HAL.GPIO;
with HAL.SPI; use HAL.SPI;
with SAM.GPIO;
with SAM.SPI;
with FT801;
with FT801.Coproc;
with FT801.Display_List;
with Fractal_Impl; use Fractal_Impl;
with Image_Types;
with Screen_ISR;
with Screen_Settings; use Screen_Settings;
procedure Main
is
use RGB565_Image_Types;
Viewport : Viewport_Info := (Width => Image_Width,
Height => Image_Height,
Zoom => 12,
Center => (X => Image_Width / 2,
Y => Image_Height / 2));
MISO : SAM.GPIO.GPIO_Point renames SAM.Device.PD20;
MOSI : SAM.GPIO.GPIO_Point renames SAM.Device.PD21;
SPCK : SAM.GPIO.GPIO_Point renames SAM.Device.PD22;
NPCS1 : SAM.GPIO.GPIO_Point renames SAM.Device.PD25;
SPI_Cfg_Init : SAM.SPI.Configuration := (Baud => 10_000_000,
Tx_On_Rx_Empty => False,
Cs_Beh => SAM.SPI.Keep_Low,
others => <>);
SPI_Cfg : SAM.SPI.Configuration := (Baud => 30_000_000,
Tx_On_Rx_Empty => False,
Cs_Beh => SAM.SPI.Keep_Low,
others => <>);
procedure Wait (Period : Time_Span)
is
begin
delay until (Period + Clock);
end Wait;
procedure Initialize_GPIOs is
use SAM.GPIO;
begin
Enable_Clock (SAM.Device.GPIO_A);
Enable_Clock (SAM.Device.GPIO_C);
SAM.GPIO.Configure_IO (This => Screen_ISR.Interrupt_Line,
Config => SAM.GPIO.GPIO_Port_Configuration'(Mode => Mode_In,
others => <>));
SAM.GPIO.Enable_Interrupt (This => Screen_ISR.Interrupt_Line,
Trigger => Falling_Edge);
Screen_Power_Down.Configure_IO
(Config => GPIO_Port_Configuration'(Mode => Mode_Out,
Resistors => <>,
Output_Type => Push_Pull));
end Initialize_GPIOs;
procedure Initialize_SPI is
use SAM.GPIO;
begin
MISO.Configure_IO (Config => (Mode => Mode_AF,
Resistors => <>,
AF_Output_Type => Push_Pull,
AF => Periph_B));
MOSI.Configure_IO (Config => (Mode => Mode_AF,
Resistors => <>,
AF_Output_Type => Push_Pull,
AF => Periph_B));
SPCK.Configure_IO (Config => (Mode => Mode_AF,
Resistors => <>,
AF_Output_Type => Push_Pull,
AF => Periph_B));
NPCS1.Configure_IO (Config => (Mode => Mode_AF,
Resistors => <>,
AF_Output_Type => Push_Pull,
AF => Periph_B));
SAM.SPI.Configure (This => Screen_Settings.SPI_Port,
Cfg => SPI_Cfg_Init);
end Initialize_SPI;
procedure Initialize_Fractal
is
begin
Fractal_Impl.Init (Viewport => Viewport);
end Initialize_Fractal;
procedure Initialize_Screen
is
begin
FT801.Initialize (This => Screen,
Settings => Screen_Cfg);
SAM.SPI.Configure (This => Screen_Settings.SPI_Port,
Cfg => SPI_Cfg);
FT801.Display_On (This => Screen);
end Initialize_Screen;
Screen_Data : UInt8_Array (1 .. Natural (Fractal_Impl.Buffer_Size))
with Address => RawDataRow.all'Address;
begin
Initialize_GPIOs;
Initialize_SPI;
Initialize_Fractal;
Initialize_Screen;
loop
for I in 1 .. Image_Height loop
Fractal_Impl.Compute_Row (Row => I,
Buffer => RawDataRow);
FT801.Fill_G_Ram (This => Screen,
Start => UInt22 (I - 1) * UInt22 (Buffer_Size),
Buffer => Screen_Data);
end loop;
Fractal_Impl.Increment_Frame;
FT801.Coproc.Send_Coproc_Cmds (This => Screen,
Cmds => (FT801.Coproc.CMD_DLSTART,
FT801.Display_List.Clear'(Color => True,
Stencil => True,
Tag => True,
others => <>).Val,
FT801.Display_List.Bitmap_Source'(Addr => FT801.RAM_G_Address,
others => <>).Val,
FT801.Display_List.Bitmap_Layout'(Format => Ft801.RGB565,
Linestride => UInt10 (Linestride),
Height => Image_Height,
others => <>).Val,
FT801.Display_List.Bitmap_Size'(Filter => FT801.Display_List.NEAREST,
Wrapx => FT801.Display_List.BORDER,
WrapY => FT801.Display_List.BORDER,
Width => Image_Width,
Height => Image_Height,
others => <>).Val,
FT801.Display_List.Cmd_Begin'(Prim => FT801.Display_List.BITMAPS,
others => <>).Val,
FT801.Display_List.ColorRGB'(Red => 255,
Blue => 255,
Green => 255,
others => <>).Val,
FT801.Display_List.Vertex2ii'(X => Image_Pos_X,
Y => Image_Pos_Y,
Handle => 0,
Cell => 0,
others => <>).Val,
FT801.Display_List.Cmd_End'(others => <>).Val,
FT801.Display_List.Display'(others => <>).Val,
FT801.Coproc.CMD_DLSWAP));
FT801.Wait_For_Coproc_Sync (This => Screen);
Wait (Period => Milliseconds (2));
end loop;
end Main;
|
micahwelf/FLTK-Ada | Ada | 2,213 | ads |
with
FLTK.Images.RGB;
package FLTK.Images.Shared is
type Shared_Image is new Image with private;
type Shared_Image_Reference (Data : not null access Shared_Image'Class) is
limited null record with Implicit_Dereference => Data;
package Forge is
function Create
(Filename : in String;
W, H : in Integer)
return Shared_Image;
function Create
(From : in FLTK.Images.RGB.RGB_Image'Class)
return Shared_Image;
function Find
(Name : in String;
W, H : in Integer := 0)
return Shared_Image;
end Forge;
function Copy
(This : in Shared_Image;
Width, Height : in Natural)
return Shared_Image'Class;
function Copy
(This : in Shared_Image)
return Shared_Image'Class;
procedure Color_Average
(This : in out Shared_Image;
Col : in Color;
Amount : in Blend);
procedure Desaturate
(This : in out Shared_Image);
function Name
(This : in Shared_Image)
return String;
procedure Reload
(This : in out Shared_Image);
procedure Set_Scaling_Algorithm
(To : in Scaling_Kind);
procedure Scale
(This : in out Shared_Image;
W, H : in Integer;
Proportional : in Boolean := True;
Can_Expand : in Boolean := False);
procedure Draw
(This : in Shared_Image;
X, Y, W, H : in Integer;
CX, CY : in Integer := 0);
procedure Draw
(This : in Shared_Image;
X, Y : in Integer);
private
type Shared_Image is new Image with null record;
overriding procedure Finalize
(This : in out Shared_Image);
pragma Inline (Copy);
pragma Inline (Color_Average);
pragma Inline (Desaturate);
pragma Inline (Name);
pragma Inline (Reload);
pragma Inline (Set_Scaling_Algorithm);
pragma Inline (Scale);
pragma Inline (Draw);
end FLTK.Images.Shared;
|
zhmu/ananas | Ada | 2,939 | adb | ------------------------------------------------------------------------------
-- --
-- GNAT RUN-TIME LIBRARY (GNARL) COMPONENTS --
-- --
-- S Y S T E M . T A S K I N G . P R O T E C T E D _ O B J E C T S . --
-- M U L T I P R O C E S S O R S --
-- B o d y --
-- --
-- Copyright (C) 2010-2022, AdaCore --
-- --
-- GNARL 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. GNARL 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/>. --
-- --
-- GNARL was developed by the GNARL team at Florida State University. --
-- Extensive contributions were provided by Ada Core Technologies, Inc. --
-- --
------------------------------------------------------------------------------
package body System.Tasking.Protected_Objects.Multiprocessors is
------------
-- Served --
------------
procedure Served (Entry_Call : Entry_Call_Link) is
pragma Unreferenced (Entry_Call);
begin
pragma Assert (Standard.False, "Invalid operation");
end Served;
-------------------------
-- Wakeup_Served_Entry --
-------------------------
procedure Wakeup_Served_Entry is
begin
pragma Assert (Standard.False, "Invalid operation");
end Wakeup_Served_Entry;
end System.Tasking.Protected_Objects.Multiprocessors;
|
zhmu/ananas | Ada | 501 | ads | -- { dg-do compile }
pragma Restrictions (No_Implicit_Heap_Allocations);
package Discr3 is
type T (Big : Boolean := False) is record
case Big is
when True =>
Content : Integer;
when False =>
null;
end case;
end record;
D : constant T := (True, 0);
Var : T := D; -- OK, maximum size
Con : constant T := D; -- Violation of restriction
Ter : constant T := Con; -- Violation of restriction
end Discr3;
|
persan/AdaYaml | Ada | 5,038 | adb | -- part of AdaYaml, (c) 2017 Felix Krause
-- released under the terms of the MIT license, see the file "copying.txt"
with Ada.Exceptions;
with Yaml.Events.Queue;
with Yaml.Parser;
With GNAT.Strings;
procedure Yaml.Inspect (Input : String) is
use GNAT.Strings;
type Error_Kind is (None, From_Lexer, From_Parser);
P : Parser.Instance;
Cur_Pos : Positive := 1;
Next_Pos : Positive;
Cur_Event : Event;
Read_Events : constant Events.Queue.Reference := Events.Queue.New_Queue;
Occurred_Error : Error_Kind := None;
Lexer_Token_Start, Lexer_Token_End : Mark;
Exception_Message : String_Access;
begin
P.Set_Input (Input);
Start_Emitting;
Start_Parsed_Input;
begin
loop
Cur_Event := P.Next;
Read_Events.Value.Append (Cur_Event);
if Cur_Event.Start_Position.Index > Cur_Pos then
Next_Pos := Cur_Pos;
while Next_Pos <= Input'Last and then
Next_Pos < Cur_Event.Start_Position.Index loop
if Input (Next_Pos) = '#' then
if Cur_Pos < Next_Pos then
Emit_Whitespace (Input (Cur_Pos .. Next_Pos - 1));
Cur_Pos := Next_Pos;
end if;
while Next_Pos < Cur_Event.Start_Position.Index and then
Input (Next_Pos) /= Character'Val (10) loop
Next_Pos := Next_Pos + 1;
end loop;
Emit_Comment (Input (Cur_Pos .. Next_Pos - 1));
end if;
Next_Pos := Next_Pos + 1;
end loop;
if Cur_Pos < Next_Pos then
Emit_Whitespace (Input (Cur_Pos .. Next_Pos - 1));
Cur_Pos := Next_Pos;
end if;
end if;
Start_Rendered_Event (Cur_Event);
declare
Content : constant String :=
Input (Cur_Pos .. Cur_Event.End_Position.Index - 1);
Cur : Positive := Content'First;
Start : Positive;
begin
while Cur <= Content'Last loop
if Content (Cur) in ' ' | Character'Val (10) then
Start := Cur;
loop
Cur := Cur + 1;
exit when Cur > Content'Last or else
Content (Cur) in ' ' | Character'Val (10);
end loop;
Emit_Whitespace (Content (Start .. Cur - 1));
exit when Cur > Content'Last;
end if;
Start := Cur;
case Content (Cur) is
when '&' =>
loop
Cur := Cur + 1;
exit when Cur > Content'Last or else
Content (Cur) in ' ' | Character'Val (10);
end loop;
Emit_Anchor (Content (Start .. Cur - 1));
when '!' =>
loop
Cur := Cur + 1;
exit when Cur > Content'Last or else
Content (Cur) in ' ' | Character'Val (10);
end loop;
Emit_Tag (Content (Start .. Cur - 1));
when others =>
Emit_Event_Content (Content (Start .. Content'Last));
exit;
end case;
end loop;
end;
End_Rendered_Event;
Cur_Pos := Cur_Event.End_Position.Index;
exit when Cur_Event.Kind = Stream_End;
end loop;
exception
when Error : Lexer_Error =>
Emit_Unparseable (Input (Cur_Pos .. Input'Last));
Occurred_Error := From_Lexer;
Lexer_Token_Start := P.Current_Lexer_Token_Start;
Lexer_Token_End := P.Current_Input_Character;
Exception_Message := new String'(Ada.Exceptions.Exception_Message (Error));
when Error : Parser_Error =>
Emit_Unparseable (Input (Cur_Pos .. Input'Last));
Occurred_Error := From_Parser;
Lexer_Token_Start := P.Recent_Lexer_Token_Start;
Lexer_Token_End := P.Recent_Lexer_Token_End;
Exception_Message := new String'(Ada.Exceptions.Exception_Message (Error));
end;
End_Parsed_Input;
Start_Parsed_Output;
case Occurred_Error is
when None =>
declare
Iterator : constant Events.Queue.Stream_Reference :=
Events.Queue.As_Stream (Read_Events);
begin
loop
Cur_Event := Iterator.Value.Next;
Emit_Raw_Event (Cur_Event);
exit when Cur_Event.Kind = Stream_End;
end loop;
end;
when From_Lexer =>
Emit_Lexer_Error (Lexer_Token_Start, Lexer_Token_End,
Exception_Message.all);
when From_Parser =>
Emit_Parser_Error (Lexer_Token_Start, Lexer_Token_End,
Exception_Message.all);
end case;
End_Parsed_Output;
Finish_Emitting;
end Yaml.Inspect;
|
zhmu/ananas | Ada | 711 | ads | package Prot6 is
generic
type TD is private;
type TI is synchronized interface;
package Set_Get is
type T is synchronized interface and TI;
procedure Set (E : in out T; D : TD) is abstract;
function Get (E : T) return TD is abstract;
end Set_Get;
type My_Type_Interface is synchronized interface;
package Set_Get_Integer is
new Set_Get (TD => Integer,
TI => My_Type_Interface);
use Set_Get_Integer;
protected type My_Type is
new Set_Get_Integer.T with
overriding procedure Set (D : Integer);
overriding function Get return Integer;
private
I : Integer;
end My_Type;
procedure Dummy;
end Prot6;
|
AdaCore/gpr | Ada | 38 | adb | procedure Main is
begin
null;
end;
|
msrLi/portingSources | Ada | 944 | adb | -- Copyright 2013-2014 Free Software Foundation, Inc.
--
-- This program is free software; you can redistribute it and/or modify
-- it under the terms of the GNU General Public License as published by
-- the Free Software Foundation; either version 3 of the License, or
-- (at your option) any later version.
--
-- This program is distributed in the hope that it will be useful,
-- but WITHOUT ANY WARRANTY; without even the implied warranty of
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-- GNU General Public License for more details.
--
-- You should have received a copy of the GNU General Public License
-- along with this program. If not, see <http://www.gnu.org/licenses/>.
with IO; use IO;
package body Callee is
procedure Increment (Val : in out Float; Msg: String) is
begin
if Val > 200.0 then
Put_Line (Msg);
end if;
Val := Val + 1.0;
end Increment;
end Callee;
|
reznikmm/ada-pretty | Ada | 6,207 | ads | -- Copyright (c) 2017 Maxim Reznik <[email protected]>
--
-- SPDX-License-Identifier: MIT
-- License-Filename: LICENSE
-------------------------------------------------------------
private package Ada_Pretty.Statements is
type Assignment is new Node with private;
function New_Assignment
(Left : not null Node_Access;
Right : not null Node_Access) return Node'Class;
type Case_Statement is new Node with private;
function New_Case
(Expression : not null Node_Access;
List : not null Node_Access) return Node'Class;
type Case_Path is new Node with private;
function New_Case_Path
(Choice : not null Node_Access;
List : not null Node_Access) return Node'Class;
type Elsif_Statement is new Node with private;
function New_Elsif
(Condition : not null Node_Access;
List : not null Node_Access) return Node'Class;
type If_Statement is new Node with private;
function New_If
(Condition : not null Node_Access;
Then_Path : not null Node_Access;
Elsif_List : Node_Access;
Else_Path : Node_Access) return Node'Class;
type For_Statement is new Node with private;
function New_For
(Name : not null Node_Access;
Iterator : not null Node_Access;
Statements : not null Node_Access) return Node'Class;
type Loop_Statement is new Node with private;
function New_Loop
(Condition : Node_Access;
Statements : not null Node_Access) return Node'Class;
type Return_Statement is new Node with private;
function New_Return
(Expression : Node_Access) return Node'Class;
type Extended_Return_Statement is new Node with private;
function New_Extended_Return
(Name : not null Node_Access;
Type_Definition : not null Node_Access;
Initialization : Node_Access;
Statements : not null Node_Access) return Node'Class;
type Statement is new Node with private;
function New_Statement
(Expression : Node_Access) return Node'Class;
type Block_Statement is new Node with private;
function New_Block_Statement
(Declarations : Node_Access;
Statements : Node_Access;
Exceptions : Node_Access) return Node'Class;
private
type Assignment is new Node with record
Left : not null Node_Access;
Right : not null Node_Access;
end record;
overriding function Document
(Self : Assignment;
Printer : not null access League.Pretty_Printers.Printer'Class;
Pad : Natural)
return League.Pretty_Printers.Document;
type Case_Statement is new Node with record
Expression : not null Node_Access;
List : not null Node_Access;
end record;
overriding function Document
(Self : Case_Statement;
Printer : not null access League.Pretty_Printers.Printer'Class;
Pad : Natural)
return League.Pretty_Printers.Document;
type Case_Path is new Node with record
Choice : not null Node_Access;
List : not null Node_Access;
end record;
overriding function Document
(Self : Case_Path;
Printer : not null access League.Pretty_Printers.Printer'Class;
Pad : Natural)
return League.Pretty_Printers.Document;
type Elsif_Statement is new Node with record
Condition : not null Node_Access;
List : not null Node_Access;
end record;
overriding function Document
(Self : Elsif_Statement;
Printer : not null access League.Pretty_Printers.Printer'Class;
Pad : Natural)
return League.Pretty_Printers.Document;
type If_Statement is new Node with record
Condition : not null Node_Access;
Then_Path : not null Node_Access;
Elsif_List : Node_Access;
Else_Path : Node_Access;
end record;
overriding function Document
(Self : If_Statement;
Printer : not null access League.Pretty_Printers.Printer'Class;
Pad : Natural)
return League.Pretty_Printers.Document;
type For_Statement is new Node with record
Name : not null Node_Access;
Iterator : not null Node_Access;
Statements : not null Node_Access;
end record;
overriding function Document
(Self : For_Statement;
Printer : not null access League.Pretty_Printers.Printer'Class;
Pad : Natural)
return League.Pretty_Printers.Document;
type Loop_Statement is new Node with record
Condition : Node_Access;
Statements : not null Node_Access;
end record;
overriding function Document
(Self : Loop_Statement;
Printer : not null access League.Pretty_Printers.Printer'Class;
Pad : Natural)
return League.Pretty_Printers.Document;
type Return_Statement is new Node with record
Expression : Node_Access;
end record;
overriding function Document
(Self : Return_Statement;
Printer : not null access League.Pretty_Printers.Printer'Class;
Pad : Natural)
return League.Pretty_Printers.Document;
type Extended_Return_Statement is new Node with record
Name : not null Node_Access;
Type_Definition : not null Node_Access;
Initialization : Node_Access;
Statements : not null Node_Access;
end record;
overriding function Document
(Self : Extended_Return_Statement;
Printer : not null access League.Pretty_Printers.Printer'Class;
Pad : Natural)
return League.Pretty_Printers.Document;
type Statement is new Node with record
Expression : Node_Access;
end record;
overriding function Document
(Self : Statement;
Printer : not null access League.Pretty_Printers.Printer'Class;
Pad : Natural)
return League.Pretty_Printers.Document;
type Block_Statement is new Node with record
Declarations : Node_Access;
Statements : Node_Access;
Exceptions : Node_Access;
end record;
overriding function Document
(Self : Block_Statement;
Printer : not null access League.Pretty_Printers.Printer'Class;
Pad : Natural)
return League.Pretty_Printers.Document;
end Ada_Pretty.Statements;
|
reznikmm/matreshka | Ada | 5,130 | ads | ------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- Ada Modeling Framework --
-- --
-- Runtime Library Component --
-- --
------------------------------------------------------------------------------
-- --
-- Copyright © 2011-2012, Vadim Godunko <[email protected]> --
-- All rights reserved. --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions --
-- are met: --
-- --
-- * Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- --
-- * Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in the --
-- documentation and/or other materials provided with the distribution. --
-- --
-- * Neither the name of the Vadim Godunko, IE nor the names of its --
-- contributors may be used to endorse or promote products derived from --
-- this software without specific prior written permission. --
-- --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR --
-- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
-- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED --
-- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR --
-- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF --
-- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING --
-- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS --
-- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
-- --
------------------------------------------------------------------------------
-- $Revision$ $Date$
------------------------------------------------------------------------------
-- This file is generated, don't edit it.
------------------------------------------------------------------------------
with AMF.Generic_Collections;
package AMF.UML.State_Invariants.Collections is
pragma Preelaborate;
package UML_State_Invariant_Collections is
new AMF.Generic_Collections
(UML_State_Invariant,
UML_State_Invariant_Access);
type Set_Of_UML_State_Invariant is
new UML_State_Invariant_Collections.Set with null record;
Empty_Set_Of_UML_State_Invariant : constant Set_Of_UML_State_Invariant;
type Ordered_Set_Of_UML_State_Invariant is
new UML_State_Invariant_Collections.Ordered_Set with null record;
Empty_Ordered_Set_Of_UML_State_Invariant : constant Ordered_Set_Of_UML_State_Invariant;
type Bag_Of_UML_State_Invariant is
new UML_State_Invariant_Collections.Bag with null record;
Empty_Bag_Of_UML_State_Invariant : constant Bag_Of_UML_State_Invariant;
type Sequence_Of_UML_State_Invariant is
new UML_State_Invariant_Collections.Sequence with null record;
Empty_Sequence_Of_UML_State_Invariant : constant Sequence_Of_UML_State_Invariant;
private
Empty_Set_Of_UML_State_Invariant : constant Set_Of_UML_State_Invariant
:= (UML_State_Invariant_Collections.Set with null record);
Empty_Ordered_Set_Of_UML_State_Invariant : constant Ordered_Set_Of_UML_State_Invariant
:= (UML_State_Invariant_Collections.Ordered_Set with null record);
Empty_Bag_Of_UML_State_Invariant : constant Bag_Of_UML_State_Invariant
:= (UML_State_Invariant_Collections.Bag with null record);
Empty_Sequence_Of_UML_State_Invariant : constant Sequence_Of_UML_State_Invariant
:= (UML_State_Invariant_Collections.Sequence with null record);
end AMF.UML.State_Invariants.Collections;
|
francesco-bongiovanni/ewok-kernel | Ada | 2,912 | ads | -- Here are the general restriction on Ada implementation.
-- Some are automatically added when activated SPARK mode in SPARK modules
-- no RTE double stacking
pragma restrictions (no_secondary_stack);
-- no elaboration code must be required at start
pragma restrictions (no_elaboration_code);
-- ... and no finalization (cleaning of elaboration)
pragma restrictions (no_finalization);
-- no exception should arise
pragma restrictions (no_exception_handlers);
-- no recursion call
pragma restrictions (no_recursion);
-- no wide chars
pragma restrictions (no_wide_characters);
with system;
with ada.unchecked_conversion;
with interfaces; use interfaces;
package types
with SPARK_Mode => On
is
KBYTE : constant := 2 ** 10;
MBYTE : constant := 2 ** 20;
GBYTE : constant := 2 ** 30;
subtype byte is unsigned_8;
subtype short is unsigned_16;
subtype word is unsigned_32;
subtype milliseconds is unsigned_64;
subtype microseconds is unsigned_64;
subtype system_address is unsigned_32;
function to_address is new ada.unchecked_conversion
(system_address, system.address);
function to_system_address is new ada.unchecked_conversion
(system.address, system_address);
function to_word is new ada.unchecked_conversion
(system.address, word);
function to_unsigned_32 is new ada.unchecked_conversion
(system.address, unsigned_32);
--
-- u8, u16 vers u32
--
pragma warnings (off);
function to_unsigned_32 is new ada.unchecked_conversion
(unsigned_8, unsigned_32);
function to_unsigned_32 is new ada.unchecked_conversion
(unsigned_16, unsigned_32);
pragma warnings (on);
type byte_array is array (unsigned_32 range <>) of byte;
for byte_array'component_size use byte'size;
type short_array is array (unsigned_32 range <>) of short;
for short_array'component_size use short'size;
type word_array is array (unsigned_32 range <>) of word;
for word_array'component_size use word'size;
type unsigned_8_array is new byte_array;
type unsigned_16_array is new short_array;
type unsigned_32_array is new word_array;
nul : constant character := character'First;
type bit is mod 2**1 with size => 1;
type bits_2 is mod 2**2 with size => 2;
type bits_3 is mod 2**3 with size => 3;
type bits_4 is mod 2**4 with size => 4;
type bits_5 is mod 2**5 with size => 5;
type bits_6 is mod 2**6 with size => 6;
type bits_7 is mod 2**7 with size => 7;
type bits_9 is mod 2**9 with size => 9;
type bits_10 is mod 2**10 with size => 10;
type bits_24 is mod 2**24 with size => 24;
type bits_27 is mod 2**27 with size => 27;
type bool is new boolean with size => 1;
for bool use (true => 1, false => 0);
function to_bit
(u : unsigned_8) return types.bit;
function to_bit
(u : unsigned_32) return types.bit;
end types;
|
Fabien-Chouteau/tiled-code-gen | Ada | 12,678 | adb | ------------------------------------------------------------------------------
-- --
-- tiled-code-gen --
-- --
-- Copyright (C) 2020 Fabien Chouteau --
-- --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions are --
-- met: --
-- 1. Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- 2. Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in --
-- the documentation and/or other materials provided with the --
-- distribution. --
-- 3. Neither the name of the copyright holder nor the names of its --
-- contributors may be used to endorse or promote products derived --
-- from this software without specific prior written permission. --
-- --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR --
-- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
-- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT --
-- LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, --
-- DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY --
-- THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT --
-- (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE --
-- OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
-- --
------------------------------------------------------------------------------
with Ada.Directories; use Ada.Directories;
with Ada.Text_IO; use Ada.Text_IO;
with TCG.Utils; use TCG.Utils;
with TCG.Tilesets;
use TCG;
package body TCG.Outputs.RSTE is
use type Tilesets.Master_Tile_Id;
use type Palette.Color_Id;
procedure Generate_Tileset (Filepath : String;
Package_Name : String);
procedure Generate_Tileset_Collisions (Filepath : String);
procedure Generate_Root_Module
(Filename : String;
Format : Palette.Output_Color_Format;
Map_List : TCG.Maps.List.List);
----------------------
-- Generate_Tileset --
----------------------
procedure Generate_Tileset (Filepath : String;
Package_Name : String)
is
pragma Unreferenced (Package_Name);
Output : Ada.Text_IO.File_Type;
procedure P (Str : String);
procedure PL (Str : String);
procedure NL;
procedure P (Str : String) is
begin
Put (Output, Str);
end P;
procedure PL (Str : String) is
begin
Put_Line (Output, Str);
end PL;
procedure NL is
begin
New_Line (Output);
end NL;
begin
Create (Output, Out_File, Filepath);
PL ("pub type ColorId = usize;");
PL ("pub type Tile = [ColorId; super::TILE_SIZE * super::TILE_SIZE];");
PL ("pub static TILE_SET : [Tile; " &
Natural'Image (Tilesets.Number_Of_Tiles + 1)
& "] = ");
PL (" [");
-- The RSTE tile set has a special 0 tile that use for empty tile
P (" [");
for X in 1 .. Tilesets.Tile_Width loop
for Y in 1 .. Tilesets.Tile_Height loop
P (" 0,");
end loop;
NL;
P (" ");
end loop;
PL ("],");
for Id in Tilesets.First_Id .. Tilesets.Last_Id loop
if Id /= Tilesets.No_Tile then
P (" [");
for Y in 1 .. Tilesets.Tile_Height loop
if Y /= 1 then
P (" ");
end if;
for X in 1 .. Tilesets.Tile_Width loop
P (Palette.Color_Id'Image ((Tilesets.Pix (Id, X, Y))));
if X /= Tilesets.Tile_Height then
P (",");
end if;
end loop;
if Y /= Tilesets.Tile_Width then
PL (",");
else
P ("]");
end if;
end loop;
if Id /= Tilesets.Last_Id then
PL (",");
else
PL ("];");
end if;
end if;
end loop;
Close (Output);
end Generate_Tileset;
---------------------------------
-- Generate_Tileset_Collisions --
---------------------------------
procedure Generate_Tileset_Collisions (Filepath : String) is
Output : Ada.Text_IO.File_Type;
procedure P (Str : String);
procedure PL (Str : String);
procedure NL;
procedure P (Str : String) is
begin
Put (Output, Str);
end P;
procedure PL (Str : String) is
begin
Put_Line (Output, Str);
end PL;
procedure NL is
begin
New_Line (Output);
end NL;
begin
Create (Output, Out_File, Filepath);
PL ("pub type Tile = [bool; super::TILE_SIZE * super::TILE_SIZE];");
PL ("pub static TILE_SET : [Tile; " &
Natural'Image (Tilesets.Number_Of_Tiles + 1)
& "] = ");
PL (" [");
-- The RSTE tile set has a special 0 tile that use for empty tile
P (" [");
for X in 1 .. Tilesets.Tile_Width loop
for Y in 1 .. Tilesets.Tile_Height loop
P ("false,");
end loop;
NL;
P (" ");
end loop;
PL ("],");
for Id in Tilesets.First_Id .. Tilesets.Last_Id loop
if Id /= Tilesets.No_Tile then
P (" [");
for Y in 1 .. Tilesets.Tile_Height loop
if Y /= 1 then
P (" ");
end if;
for X in 1 .. Tilesets.Tile_Width loop
P (if Tilesets.Collision (Id, X, Y) then
"true"
else
"false");
if X /= Tilesets.Tile_Height then
P (",");
end if;
end loop;
if Y /= Tilesets.Tile_Width then
PL (",");
else
P ("]");
end if;
end loop;
if Id /= Tilesets.Last_Id then
PL (",");
else
PL ("];");
end if;
end if;
end loop;
Close (Output);
end Generate_Tileset_Collisions;
--------------------------
-- Generate_Root_Module --
--------------------------
procedure Generate_Root_Module
(Filename : String;
Format : Palette.Output_Color_Format;
Map_List : TCG.Maps.List.List)
is
use TCG.Palette;
Output : File_Type;
begin
Create (Output, Out_File, Filename);
Put_Line (Output, "pub mod tileset;");
Put_Line (Output, "pub mod tileset_collisions;");
for Map of Map_List loop
Put_Line (Output,
"pub mod " & To_Rust_Identifier (Maps.Name (Map)) & ";");
end loop;
New_Line (Output);
case Format is
when Palette.ARGB =>
Put_Line (Output, "pub struct OutputColor {");
Put_Line (Output, " a : u8,");
Put_Line (Output, " r : u8,");
Put_Line (Output, " g : u8,");
Put_Line (Output, " b : u8,");
Put_Line (Output, "};");
when Palette.RGB565 | Palette.RGB565_Swap | Palette.RGB555 =>
Put_Line (Output, "pub type OutputColor = u16;");
when Palette.RGB888 =>
Put_Line (Output, "pub type OutputColor = u32;");
end case;
New_Line (Output);
Put_Line (Output, "pub const TRANSPARENT : OutputColor = " &
Palette.Image (Palette.Transparent, Format) & ";");
New_Line (Output);
Put_Line (Output, "pub const TILE_SIZE : usize = " &
Tilesets.Tile_Width'Img & ";");
Put_Line (Output, "pub const NO_TILE : usize = 0;");
New_Line (Output);
Put_Line (Output, "pub static PALETTE : [u32; " &
Color_Id'Image (Palette.Last_Id - Palette.First_Id + 1) &
"] = [");
for Id in Palette.First_Id .. Palette.Last_Id loop
Put (Output, " " & Palette.Image (Palette.Convert (Id), Format));
if Id /= Palette.Last_Id then
Put_Line (Output, ",");
end if;
end loop;
Put_Line (Output, "];");
New_Line (Output);
Put_Line (Output, "pub enum ObjectKind {Rectangle, Point,");
Put_Line (Output, " Ellipse, Polygon, Tile, Text}");
New_Line (Output);
Put_Line (Output, "pub struct Object {");
Put_Line (Output, " kind : ObjectKind,");
Put_Line (Output, " name : &'static str,");
Put_Line (Output, " id : u32,");
Put_Line (Output, " x : f32,");
Put_Line (Output, " y : f32,");
Put_Line (Output, " width : f32,");
Put_Line (Output, " height : f32,");
Put_Line (Output, " str : &'static str,");
Put_Line (Output, " flip_vertical : bool,");
Put_Line (Output, " flip_horizontal: bool,");
Put_Line (Output, " tile_id : usize,");
Put_Line (Output, "}");
New_Line (Output);
Put_Line (Output, "pub type ObjectArray = [Object];");
New_Line (Output);
Close (Output);
end Generate_Root_Module;
-----------------
-- Gen_PDF_Doc --
-----------------
procedure Gen_RSTE_Source
(Directory : String;
Root_Module_Name : String;
Format : Palette.Output_Color_Format;
Map_List : TCG.Maps.List.List)
is
Module_Dir : constant String := Compose (Directory, Root_Module_Name);
begin
if not TCG.Utils.Make_Dir (Directory) then
Ada.Text_IO.Put_Line
(Ada.Text_IO.Standard_Error,
"Cannot create directory for RSTE code: '" & Directory & "'");
return;
end if;
if not TCG.Utils.Make_Dir (Module_Dir) then
Ada.Text_IO.Put_Line
(Ada.Text_IO.Standard_Error,
"Cannot create directory for RSTE code: '" & Module_Dir & "'");
return;
end if;
if Tilesets.Tile_Width /= Tilesets.Tile_Height then
raise Program_Error with "Tiles are not square";
end if;
declare
Module_Name : constant String := "mod";
Filename : constant String :=
Compose (Module_Dir, To_Rust_Filename (Module_Name));
begin
Generate_Root_Module (Filename, Format, Map_List);
end;
declare
Module_Name : constant String := "tileset";
Filename : constant String :=
Compose (Module_Dir, To_Rust_Filename (Module_Name));
begin
Generate_Tileset (Filename, Module_Name);
end;
declare
Module_Name : constant String := "tileset_collisions";
Filename : constant String :=
Compose (Module_Dir, To_Rust_Filename (Module_Name));
begin
Generate_Tileset_Collisions (Filename);
end;
for Map of Map_List loop
declare
Module_Name : constant String :=
To_Rust_Identifier (Maps.Name (Map));
Filename : constant String :=
Compose (Module_Dir, To_Rust_Filename (Module_Name));
begin
TCG.Maps.Generate_RSTE_Source (Map, Filename);
end;
end loop;
end Gen_RSTE_Source;
end TCG.Outputs.RSTE;
|
AdaCore/ada-traits-containers | Ada | 5,872 | ads | --
-- Copyright (C) 2016, AdaCore
--
-- SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
--
pragma Ada_2012;
with Conts; use Conts;
private with Conts.Functional.Base;
generic
type Key_Type (<>) is private;
type Element_Type (<>) is private;
with function "=" (Left, Right : Key_Type) return Boolean is <>;
package Conts.Functional.Maps with SPARK_Mode is
pragma Assertion_Policy
(Pre => Suppressible, Ghost => Suppressible, Post => Ignore);
type Map is private with
Default_Initial_Condition => Is_Empty (Map) and Length (Map) = 0,
Iterable => (First => Iter_First,
Next => Iter_Next,
Has_Element => Iter_Has_Element,
Element => Iter_Element);
-- Maps are empty when default initialized.
-- For in quantification over maps should not be used.
-- For of quantification over maps iterates over keys.
-- Maps are axiomatized using Mem and Get encoding respectively the
-- presence of a key in a map and an accessor to elements associated to its
-- keys. The length of a map is also added to protect Add against overflows
-- but it is not actually modeled.
function Mem (M : Map; K : Key_Type) return Boolean with
Global => null;
function Get (M : Map; K : Key_Type) return Element_Type with
Global => null,
Pre => Mem (M, K);
function Length (M : Map) return Count_Type with
Global => null;
function "<=" (M1, M2 : Map) return Boolean with
-- Map inclusion.
Global => null,
Post => "<="'Result =
(for all K of M1 => Mem (M2, K)
and then Get (M2, K) = Get (M1, K));
function "=" (M1, M2 : Map) return Boolean with
-- Extensional equality over maps.
Global => null,
Post => "="'Result =
((for all K of M1 => Mem (M2, K)
and then Get (M2, K) = Get (M1, K))
and (for all K of M2 => Mem (M1, K)));
pragma Warnings (Off, "unused variable ""K""");
function Is_Empty (M : Map) return Boolean with
-- A map is empty if it contains no key.
Global => null,
Post => Is_Empty'Result = (for all K of M => False);
pragma Warnings (On, "unused variable ""K""");
function Is_Add
(M : Map; K : Key_Type; E : Element_Type; Result : Map) return Boolean
-- Returns True if Result is M augmented with the mapping K -> E.
with
Global => null,
Post => Is_Add'Result =
(not Mem (M, K)
and then (Mem (Result, K) and then Get (Result, K) = E
and then (for all K of M => Mem (Result, K)
and then Get (Result, K) = Get (M, K))
and then (for all KK of Result => KK = K or Mem (M, KK))));
function Add (M : Map; K : Key_Type; E : Element_Type) return Map with
-- Returns M augmented with the mapping K -> E.
-- Is_Add (M, K, E, Result) should be used instead of
-- Result = Add (M, K, E) whenever possible both for execution and for
-- proof.
Global => null,
Pre => not Mem (M, K) and Length (M) < Count_Type'Last,
Post => Length (M) + 1 = Length (Add'Result)
and Is_Add (M, K, E, Add'Result);
function Is_Set
(M : Map; K : Key_Type; E : Element_Type; Result : Map) return Boolean
-- Returns True if Result is M where the element associated to K has been
-- replaced by E.
with
Global => null,
Post => Is_Set'Result =
(Mem (M, K)
and then Mem (Result, K)
and then Get (Result, K) = E
and then (for all KK of M => Mem (Result, KK)
and then (if K /= KK
then Get (Result, KK) = Get (M, KK)))
and then (for all K of Result => Mem (M, K)));
function Set (M : Map; K : Key_Type; E : Element_Type) return Map with
-- Returns M where the element associated to K has been replaced by E.
-- Is_Set (M, K, E, Result) should be used instead of
-- Result = Set (M, K, E) whenever possible both for execution and for
-- proof.
Global => null,
Pre => Mem (M, K),
Post => Length (M) = Length (Set'Result)
and Is_Set (M, K, E, Set'Result);
---------------------------
-- Iteration Primitives --
---------------------------
type Private_Key is private;
function Iter_First (M : Map) return Private_Key with
Global => null;
function Iter_Has_Element (M : Map; K : Private_Key) return Boolean with
Global => null;
function Iter_Next (M : Map; K : Private_Key) return Private_Key with
Global => null,
Pre => Iter_Has_Element (M, K);
function Iter_Element (M : Map; K : Private_Key) return Key_Type with
Global => null,
Pre => Iter_Has_Element (M, K);
pragma Annotate (GNATprove, Iterable_For_Proof, "Contains", Mem);
private
pragma SPARK_Mode (Off);
package Element_Containers is new Conts.Functional.Base
(Element_Type => Element_Type,
Index_Type => Positive_Count_Type);
package Key_Containers is new Conts.Functional.Base
(Element_Type => Key_Type,
Index_Type => Positive_Count_Type);
type Map is record
Keys : Key_Containers.Container;
Elements : Element_Containers.Container;
end record;
type Private_Key is new Count_Type;
function Iter_First (M : Map) return Private_Key is (1);
function Iter_Has_Element (M : Map; K : Private_Key) return Boolean is
(Count_Type (K) in 1 .. Key_Containers.Length (M.Keys));
function Iter_Next (M : Map; K : Private_Key) return Private_Key is
(if K = Private_Key'Last then 0 else K + 1);
function Iter_Element (M : Map; K : Private_Key) return Key_Type is
(Key_Containers.Get (M.Keys, Count_Type (K)));
end Conts.Functional.Maps;
|
ecalderini/bingada | Ada | 348 | adb | with GTK.MAIN;
with Q_BINGADA;
procedure BINGADA is
begin
GTK.MAIN.INIT;
Q_BINGADA.P_CREATE_WIDGETS;
-- All GTK applications must have a Gtk.Main.Main. Control ends here
-- and waits for an event to occur (like a key press or a mouse event),
-- until Gtk.Main.Main_Quit is called.
GTK.MAIN.MAIN;
end BINGADA;
|
reznikmm/matreshka | Ada | 4,073 | 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_Direction_Attributes;
package Matreshka.ODF_Presentation.Direction_Attributes is
type Presentation_Direction_Attribute_Node is
new Matreshka.ODF_Presentation.Abstract_Presentation_Attribute_Node
and ODF.DOM.Presentation_Direction_Attributes.ODF_Presentation_Direction_Attribute
with null record;
overriding function Create
(Parameters : not null access Matreshka.DOM_Attributes.Attribute_L2_Parameters)
return Presentation_Direction_Attribute_Node;
overriding function Get_Local_Name
(Self : not null access constant Presentation_Direction_Attribute_Node)
return League.Strings.Universal_String;
end Matreshka.ODF_Presentation.Direction_Attributes;
|
AdaCore/training_material | Ada | 11,052 | ads | pragma Ada_2005;
pragma Style_Checks (Off);
with Interfaces.C; use Interfaces.C;
package avxintrin_h is
-- Copyright (C) 2008-2017 Free Software Foundation, Inc.
-- This file is part of GCC.
-- GCC is free software; you can redistribute it and/or modify
-- it under the terms of the GNU General Public License as published by
-- the Free Software Foundation; either version 3, or (at your option)
-- any later version.
-- GCC is distributed in the hope that it will be useful,
-- but WITHOUT ANY WARRANTY; without even the implied warranty of
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-- GNU General Public License for more details.
-- Under Section 7 of GPL version 3, you are granted additional
-- permissions described in the GCC Runtime Library Exception, version
-- 3.1, as published by the Free Software Foundation.
-- You should have received a copy of the GNU General Public License and
-- a copy of the GCC Runtime Library Exception along with this program;
-- see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
-- <http://www.gnu.org/licenses/>.
-- Implemented from the specification included in the Intel C++ Compiler
-- User Guide and Reference, version 11.0.
-- Internal data types for implementing the intrinsics.
subtype uu_v4df is <vector>; -- d:\install\gpl2018\lib\gcc\x86_64-pc-mingw32\7.3.1\include\avxintrin.h:41
subtype uu_v8sf is <vector>; -- d:\install\gpl2018\lib\gcc\x86_64-pc-mingw32\7.3.1\include\avxintrin.h:42
subtype uu_v4di is <vector>; -- d:\install\gpl2018\lib\gcc\x86_64-pc-mingw32\7.3.1\include\avxintrin.h:43
subtype uu_v4du is <vector>; -- d:\install\gpl2018\lib\gcc\x86_64-pc-mingw32\7.3.1\include\avxintrin.h:44
subtype uu_v8si is <vector>; -- d:\install\gpl2018\lib\gcc\x86_64-pc-mingw32\7.3.1\include\avxintrin.h:45
subtype uu_v8su is <vector>; -- d:\install\gpl2018\lib\gcc\x86_64-pc-mingw32\7.3.1\include\avxintrin.h:46
subtype uu_v16hi is <vector>; -- d:\install\gpl2018\lib\gcc\x86_64-pc-mingw32\7.3.1\include\avxintrin.h:47
subtype uu_v16hu is <vector>; -- d:\install\gpl2018\lib\gcc\x86_64-pc-mingw32\7.3.1\include\avxintrin.h:48
subtype uu_v32qi is <vector>; -- d:\install\gpl2018\lib\gcc\x86_64-pc-mingw32\7.3.1\include\avxintrin.h:49
subtype uu_v32qu is <vector>; -- d:\install\gpl2018\lib\gcc\x86_64-pc-mingw32\7.3.1\include\avxintrin.h:50
-- The Intel API is flexible enough that we must allow aliasing with other
-- vector types, and their scalar components.
subtype uu_m256 is <vector>; -- d:\install\gpl2018\lib\gcc\x86_64-pc-mingw32\7.3.1\include\avxintrin.h:54
subtype uu_m256i is <vector>; -- d:\install\gpl2018\lib\gcc\x86_64-pc-mingw32\7.3.1\include\avxintrin.h:56
subtype uu_m256d is <vector>; -- d:\install\gpl2018\lib\gcc\x86_64-pc-mingw32\7.3.1\include\avxintrin.h:58
-- Unaligned version of the same types.
subtype uu_m256_u is <vector>; -- d:\install\gpl2018\lib\gcc\x86_64-pc-mingw32\7.3.1\include\avxintrin.h:62
subtype uu_m256i_u is <vector>; -- d:\install\gpl2018\lib\gcc\x86_64-pc-mingw32\7.3.1\include\avxintrin.h:65
subtype uu_m256d_u is <vector>; -- d:\install\gpl2018\lib\gcc\x86_64-pc-mingw32\7.3.1\include\avxintrin.h:68
-- Compare predicates for scalar and packed compare intrinsics.
-- Equal (ordered, non-signaling)
-- Less-than (ordered, signaling)
-- Less-than-or-equal (ordered, signaling)
-- Unordered (non-signaling)
-- Not-equal (unordered, non-signaling)
-- Not-less-than (unordered, signaling)
-- Not-less-than-or-equal (unordered, signaling)
-- Ordered (nonsignaling)
-- Equal (unordered, non-signaling)
-- Not-greater-than-or-equal (unordered, signaling)
-- Not-greater-than (unordered, signaling)
-- False (ordered, non-signaling)
-- Not-equal (ordered, non-signaling)
-- Greater-than-or-equal (ordered, signaling)
-- Greater-than (ordered, signaling)
-- True (unordered, non-signaling)
-- Equal (ordered, signaling)
-- Less-than (ordered, non-signaling)
-- Less-than-or-equal (ordered, non-signaling)
-- Unordered (signaling)
-- Not-equal (unordered, signaling)
-- Not-less-than (unordered, non-signaling)
-- Not-less-than-or-equal (unordered, non-signaling)
-- Ordered (signaling)
-- Equal (unordered, signaling)
-- Not-greater-than-or-equal (unordered, non-signaling)
-- Not-greater-than (unordered, non-signaling)
-- False (ordered, signaling)
-- Not-equal (ordered, signaling)
-- Greater-than-or-equal (ordered, non-signaling)
-- Greater-than (ordered, non-signaling)
-- True (unordered, signaling)
-- skipped func _mm256_add_pd
-- skipped func _mm256_add_ps
-- skipped func _mm256_addsub_pd
-- skipped func _mm256_addsub_ps
-- skipped func _mm256_and_pd
-- skipped func _mm256_and_ps
-- skipped func _mm256_andnot_pd
-- skipped func _mm256_andnot_ps
-- Double/single precision floating point blend instructions - select
-- data from 2 sources using constant/variable mask.
-- skipped func _mm256_blendv_pd
-- skipped func _mm256_blendv_ps
-- skipped func _mm256_div_pd
-- skipped func _mm256_div_ps
-- Dot product instructions with mask-defined summing and zeroing parts
-- of result.
-- skipped func _mm256_hadd_pd
-- skipped func _mm256_hadd_ps
-- skipped func _mm256_hsub_pd
-- skipped func _mm256_hsub_ps
-- skipped func _mm256_max_pd
-- skipped func _mm256_max_ps
-- skipped func _mm256_min_pd
-- skipped func _mm256_min_ps
-- skipped func _mm256_mul_pd
-- skipped func _mm256_mul_ps
-- skipped func _mm256_or_pd
-- skipped func _mm256_or_ps
-- skipped func _mm256_sub_pd
-- skipped func _mm256_sub_ps
-- skipped func _mm256_xor_pd
-- skipped func _mm256_xor_ps
-- skipped func _mm256_cvtepi32_pd
-- skipped func _mm256_cvtepi32_ps
-- skipped func _mm256_cvtpd_ps
-- skipped func _mm256_cvtps_epi32
-- skipped func _mm256_cvtps_pd
-- skipped func _mm256_cvttpd_epi32
-- skipped func _mm256_cvtpd_epi32
-- skipped func _mm256_cvttps_epi32
-- skipped func _mm256_cvtsd_f64
-- skipped func _mm256_cvtss_f32
-- skipped func _mm256_zeroall
-- skipped func _mm256_zeroupper
-- skipped func _mm_permutevar_pd
-- skipped func _mm256_permutevar_pd
-- skipped func _mm_permutevar_ps
-- skipped func _mm256_permutevar_ps
-- skipped func _mm_broadcast_ss
-- skipped func _mm256_broadcast_sd
-- skipped func _mm256_broadcast_ss
-- skipped func _mm256_broadcast_pd
-- skipped func _mm256_broadcast_ps
-- skipped func _mm256_load_pd
-- skipped func _mm256_store_pd
-- skipped func _mm256_load_ps
-- skipped func _mm256_store_ps
-- skipped func _mm256_loadu_pd
-- skipped func _mm256_storeu_pd
-- skipped func _mm256_loadu_ps
-- skipped func _mm256_storeu_ps
-- skipped func _mm256_load_si256
-- skipped func _mm256_store_si256
-- skipped func _mm256_loadu_si256
-- skipped func _mm256_storeu_si256
-- skipped func _mm_maskload_pd
-- skipped func _mm_maskstore_pd
-- skipped func _mm256_maskload_pd
-- skipped func _mm256_maskstore_pd
-- skipped func _mm_maskload_ps
-- skipped func _mm_maskstore_ps
-- skipped func _mm256_maskload_ps
-- skipped func _mm256_maskstore_ps
-- skipped func _mm256_movehdup_ps
-- skipped func _mm256_moveldup_ps
-- skipped func _mm256_movedup_pd
-- skipped func _mm256_lddqu_si256
-- skipped func _mm256_stream_si256
-- skipped func _mm256_stream_pd
-- skipped func _mm256_stream_ps
-- skipped func _mm256_rcp_ps
-- skipped func _mm256_rsqrt_ps
-- skipped func _mm256_sqrt_pd
-- skipped func _mm256_sqrt_ps
-- skipped func _mm256_unpackhi_pd
-- skipped func _mm256_unpacklo_pd
-- skipped func _mm256_unpackhi_ps
-- skipped func _mm256_unpacklo_ps
-- skipped func _mm_testz_pd
-- skipped func _mm_testc_pd
-- skipped func _mm_testnzc_pd
-- skipped func _mm_testz_ps
-- skipped func _mm_testc_ps
-- skipped func _mm_testnzc_ps
-- skipped func _mm256_testz_pd
-- skipped func _mm256_testc_pd
-- skipped func _mm256_testnzc_pd
-- skipped func _mm256_testz_ps
-- skipped func _mm256_testc_ps
-- skipped func _mm256_testnzc_ps
-- skipped func _mm256_testz_si256
-- skipped func _mm256_testc_si256
-- skipped func _mm256_testnzc_si256
-- skipped func _mm256_movemask_pd
-- skipped func _mm256_movemask_ps
-- skipped func _mm256_undefined_pd
-- skipped func _mm256_undefined_ps
-- skipped func _mm256_undefined_si256
-- skipped func _mm256_setzero_pd
-- skipped func _mm256_setzero_ps
-- skipped func _mm256_setzero_si256
-- Create the vector [A B C D].
-- skipped func _mm256_set_pd
-- Create the vector [A B C D E F G H].
-- skipped func _mm256_set_ps
-- Create the vector [A B C D E F G H].
-- skipped func _mm256_set_epi32
-- skipped func _mm256_set_epi16
-- skipped func _mm256_set_epi8
-- skipped func _mm256_set_epi64x
-- Create a vector with all elements equal to A.
-- skipped func _mm256_set1_pd
-- Create a vector with all elements equal to A.
-- skipped func _mm256_set1_ps
-- Create a vector with all elements equal to A.
-- skipped func _mm256_set1_epi32
-- skipped func _mm256_set1_epi16
-- skipped func _mm256_set1_epi8
-- skipped func _mm256_set1_epi64x
-- Create vectors of elements in the reversed order from the
-- _mm256_set_XXX functions.
-- skipped func _mm256_setr_pd
-- skipped func _mm256_setr_ps
-- skipped func _mm256_setr_epi32
-- skipped func _mm256_setr_epi16
-- skipped func _mm256_setr_epi8
-- skipped func _mm256_setr_epi64x
-- Casts between various SP, DP, INT vector types. Note that these do no
-- conversion of values, they just change the type.
-- skipped func _mm256_castpd_ps
-- skipped func _mm256_castpd_si256
-- skipped func _mm256_castps_pd
-- skipped func _mm256_castps_si256
-- skipped func _mm256_castsi256_ps
-- skipped func _mm256_castsi256_pd
-- skipped func _mm256_castpd256_pd128
-- skipped func _mm256_castps256_ps128
-- skipped func _mm256_castsi256_si128
-- When cast is done from a 128 to 256-bit type, the low 128 bits of
-- the 256-bit result contain source parameter value and the upper 128
-- bits of the result are undefined. Those intrinsics shouldn't
-- generate any extra moves.
-- skipped func _mm256_castpd128_pd256
-- skipped func _mm256_castps128_ps256
-- skipped func _mm256_castsi128_si256
end avxintrin_h;
|
AdaCore/gpr | Ada | 386 | ads | --
-- Copyright (C) 2019-2023, AdaCore
--
-- SPDX-License-Identifier: Apache-2.0 WITH LLVM-Exception
--
with Ada.Containers.Indefinite_Ordered_Maps;
package GPR2.Project.Typ.Set is
-- The type names must not be case-sensitive
package Set is new Ada.Containers.Indefinite_Ordered_Maps
(Name_Type, Object, "<");
subtype Object is Set.Map;
end GPR2.Project.Typ.Set;
|
Intelligente-sanntidssystemer/Ada-prosjekt | Ada | 4,057 | ads | ------------------------------------------------------------------------------
-- --
-- Copyright (C) 2016-2020, AdaCore --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions are --
-- met: --
-- 1. Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- 2. Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in --
-- the documentation and/or other materials provided with the --
-- distribution. --
-- 3. Neither the name of the copyright holder nor the names of its --
-- contributors may be used to endorse or promote products derived --
-- from this software without specific prior written permission. --
-- --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR --
-- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
-- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT --
-- LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, --
-- DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY --
-- THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT --
-- (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE --
-- OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
-- --
------------------------------------------------------------------------------
with HAL; use HAL;
with HAL.Time;
package NRF52_DK.Time is
subtype Time_Ms is UInt64;
function Clock return Time_Ms;
procedure Delay_Ms (Milliseconds : UInt64);
procedure Sleep (Milliseconds : UInt64) renames Delay_Ms;
function Tick_Period return Time_Ms;
type Tick_Callback is access procedure;
function Tick_Subscriber (Callback : not null Tick_Callback) return Boolean;
-- Return True if callback is already a tick event subscriber
function Tick_Subscribe (Callback : not null Tick_Callback) return Boolean
with Pre => not Tick_Subscriber (Callback),
Post => (if Tick_Subscribe'Result then Tick_Subscriber (Callback));
-- Subscribe a callback to the tick event. The function return True on
-- success, False if there's no more room for subscribers.
function Tick_Unsubscribe (Callback : not null Tick_Callback) return Boolean
with Pre => Tick_Subscriber (Callback),
Post => (if Tick_Unsubscribe'Result then not Tick_Subscriber (Callback));
-- Unsubscribe a callback to the tick event. The function return True on
-- success, False if the callback was not a subscriber.
function HAL_Delay return not null HAL.Time.Any_Delays;
type MB_Delays is new HAL.Time.Delays with null record;
overriding
procedure Delay_Microseconds (This : in out MB_Delays;
Us : Integer);
overriding
procedure Delay_Milliseconds (This : in out MB_Delays;
Ms : Integer);
overriding
procedure Delay_Seconds (This : in out MB_Delays;
S : Integer);
private
end NRF52_DK.Time;
|
AdaCore/ada-traits-containers | Ada | 8,873 | adb | --
-- Copyright (C) 2015-2016, AdaCore
--
-- SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
--
pragma Ada_2012;
with Ada.Text_IO; use Ada.Text_IO;
with GNAT.Directory_Operations; use GNAT.Directory_Operations;
with Interfaces.C; use Interfaces.C;
with Interfaces.C.Strings; use Interfaces.C.Strings;
with Memory;
with System;
with Perf_Support; use Perf_Support;
package body Report is
type Output_Access is access all Output'Class;
pragma No_Strict_Aliasing (Output_Access);
function To_Output is new Ada.Unchecked_Conversion
(System.Address, Output_Access);
procedure Start_Container_Test
(Self : System.Address;
Name, Category : chars_ptr;
Favorite : Integer)
with Export, Convention => C, External_Name => "start_container_test";
procedure Save_Container_Size
(Self : System.Address;
Size : Long_Integer)
with Export, Convention => C, External_Name => "save_container_size";
procedure End_Container_Test
(Self : System.Address;
Allocated, Allocs_Count, Frees_Count : Natural)
with Export, Convention => C, External_Name => "end_container_test";
procedure Start_Test
(Self : System.Address;
Name : chars_ptr;
Start_Group : Interfaces.C.int)
with Export, Convention => C, External_Name => "start_test";
procedure End_Test
(Self : System.Address;
Allocated, Allocs_Count, Frees_Count : Natural)
with Export, Convention => C, External_Name => "end_test";
procedure End_Test_Not_Run (Self : System.Address)
with Export, Convention => C, External_Name => "end_test_not_run";
--------------------------
-- Start_Container_Test --
--------------------------
procedure Start_Container_Test
(Self : not null access Output'Class;
Name : String;
Category : String;
Favorite : Boolean := False) is
begin
if Self.Global_Result = JSON_Null then
Memory.Pause;
Self.Global_Result := Create_Object;
Self.Global_Result.Set_Field ("repeat_count", Repeat_Count);
Self.Global_Result.Set_Field ("items_count", Integer_Items_Count);
end if;
Self.End_Container_Test; -- In case one was started
Memory.Pause;
Self.Container_Test := GNATCOLL.JSON.Create_Object;
Append (Self.All_Tests, Self.Container_Test);
Self.Container_Test.Set_Field ("name", Name);
Self.Container_Test.Set_Field ("category", Category);
if Favorite then
Self.Container_Test.Set_Field ("favorite", Favorite);
end if;
Self.Tests_In_Container := Create_Object;
Self.Container_Test.Set_Field ("tests", Self.Tests_In_Container);
Memory.Reset;
Memory.Unpause;
end Start_Container_Test;
-------------------------
-- Save_Container_Size --
-------------------------
procedure Save_Container_Size
(Self : not null access Output'Class;
Size : Long_Integer) is
begin
Memory.Pause;
Self.Container_Test.Set_Field ("size", Size);
Memory.Pause;
end Save_Container_Size;
------------------------
-- End_Container_Test --
------------------------
procedure End_Container_Test (Self : not null access Output'Class) is
begin
Memory.Pause;
Self.End_Test; -- In case one was started
if Self.Container_Test /= JSON_Null then
Self.Container_Test.Set_Field
("allocated", Current.Total_Allocated'Img);
Self.Container_Test.Set_Field ("allocs", Current.Allocs);
Self.Container_Test.Set_Field ("reallocs", Current.Reallocs);
Self.Container_Test.Set_Field ("frees", Current.Frees);
end if;
Memory.Unpause;
end End_Container_Test;
----------------
-- Start_Test --
----------------
procedure Start_Test
(Self : not null access Output'Class;
Name : String;
Comment : String := "";
Start_Group : Boolean := False) is
begin
Self.End_Test; -- In case one was started
Memory.Pause;
-- Is this a second run for this test ?
Self.Current_Test := Self.Tests_In_Container.Get (Name);
if Self.Current_Test = JSON_Null then
Self.Current_Test := GNATCOLL.JSON.Create_Object;
Self.Tests_In_Container.Set_Field (Name, Self.Current_Test);
Self.Current_Test.Set_Field ("duration", Empty_Array);
if Start_Group then
Self.Current_Test.Set_Field ("group", True);
end if;
end if;
if Comment /= "" then
Self.Current_Test.Set_Field ("comment", Comment);
end if;
Self.At_Test_Start := Memory.Current;
Memory.Unpause;
Self.Start_Time := Clock;
end Start_Test;
----------------------
-- End_Test_Not_Run --
----------------------
procedure End_Test_Not_Run (Self : not null access Output'Class) is
begin
if Self.Current_Test /= JSON_Null then
Memory.Pause;
Self.Current_Test.Set_Field ("duration", Empty_Array);
Self.Current_Test := JSON_Null;
Memory.Unpause;
end if;
end End_Test_Not_Run;
--------------
-- End_Test --
--------------
procedure End_Test (Self : not null access Output'Class) is
E : constant Time := Clock;
Info : Mem_Info;
begin
if Self.Current_Test /= JSON_Null then
Memory.Pause;
declare
Arr : JSON_Array := Self.Current_Test.Get ("duration");
begin
Append (Arr, Create (Float (E - Self.Start_Time)));
Self.Current_Test.Set_Field ("duration", Arr);
end;
Info := Memory.Current - Self.At_Test_Start;
Self.Current_Test.Set_Field ("allocated", Info.Total_Allocated'Img);
Self.Current_Test.Set_Field ("allocs", Info.Allocs);
Self.Current_Test.Set_Field ("reallocs", Info.Reallocs);
Self.Current_Test.Set_Field ("frees", Info.Frees);
Self.Current_Test := JSON_Null;
Memory.Unpause;
end if;
end End_Test;
-------------
-- Display --
-------------
procedure Display (Self : not null access Output'Class) is
F : File_Type;
begin
Self.Global_Result.Set_Field ("tests", Self.All_Tests);
Create (F, Out_File, "data.js");
Put (F, "var data = ");
Put (F, GNATCOLL.JSON.Write (Self.Global_Result, Compact => False));
Put (F, ";");
Close (F);
Put_Line ("Open file://" & Get_Current_Dir & "/index.html");
end Display;
--------------------------
-- Start_Container_Test --
--------------------------
procedure Start_Container_Test
(Self : System.Address;
Name, Category : chars_ptr;
Favorite : Integer) is
begin
Start_Container_Test
(To_Output (Self), Value (Name),
Value (Category), Favorite => Favorite /= 0);
end Start_Container_Test;
-------------------------
-- Save_Container_Size --
-------------------------
procedure Save_Container_Size
(Self : System.Address;
Size : Long_Integer) is
begin
Save_Container_Size (To_Output (Self), Size);
end Save_Container_Size;
------------------------
-- End_Container_Test --
------------------------
procedure End_Container_Test
(Self : System.Address;
Allocated, Allocs_Count, Frees_Count : Natural) is
begin
Memory.Current := (Total_Allocated => Long_Long_Integer (Allocated),
Allocs => Allocs_Count,
Frees => Frees_Count,
Reallocs => 0);
End_Container_Test (To_Output (Self));
end End_Container_Test;
----------------
-- Start_Test --
----------------
procedure Start_Test
(Self : System.Address;
Name : chars_ptr;
Start_Group : Interfaces.C.int) is
begin
Start_Test
(To_Output (Self), Value (Name), Start_Group => Start_Group /= 0);
end Start_Test;
--------------
-- End_Test --
--------------
procedure End_Test
(Self : System.Address;
Allocated, Allocs_Count, Frees_Count : Natural) is
begin
Memory.Current := (Total_Allocated => Long_Long_Integer (Allocated),
Allocs => Allocs_Count,
Frees => Frees_Count,
Reallocs => 0);
End_Test (To_Output (Self));
end End_Test;
----------------------
-- End_Test_Not_Run --
----------------------
procedure End_Test_Not_Run (Self : System.Address) is
begin
End_Test_Not_Run (To_Output (Self));
end End_Test_Not_Run;
end Report;
|
Gabriel-Degret/adalib | Ada | 946 | 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
---------------------------------------------------------------------------
package Ada.Synchronous_Task_Control is
pragma Preelaborate (Synchronous_Task_Control);
type Suspension_Object is limited private;
procedure Set_True (S : in out Suspension_Object);
procedure Set_False (S : in out Suspension_Object);
function Current_State (S : in Suspension_Object) return Boolean;
procedure Suspend_Until_True (S : in out Suspension_Object);
private
pragma Import (Ada, Suspension_Object);
end Ada.Synchronous_Task_Control;
|
BrickBot/Bound-T-H8-300 | Ada | 3,266 | ads | -- Flow.Pruning (decl)
--
-- Pruning of infeasible parts and paths in the control-flow graphs
-- or actually in computation models associated with flow-graphs.
--
-- A component of the Bound-T Worst-Case Execution Time Tool.
--
-------------------------------------------------------------------------------
-- Copyright (c) 1999 .. 2015 Tidorum Ltd
-- All rights reserved.
--
-- Redistribution and use in source and binary forms, with or without
-- modification, are permitted provided that the following conditions are met:
--
-- 1. Redistributions of source code must retain the above copyright notice, this
-- list of conditions and the following disclaimer.
-- 2. Redistributions in binary form must reproduce the above copyright notice,
-- this list of conditions and the following disclaimer in the documentation
-- and/or other materials provided with the distribution.
--
-- This software is provided by the copyright holders and contributors "as is" and
-- any express or implied warranties, including, but not limited to, the implied
-- warranties of merchantability and fitness for a particular purpose are
-- disclaimed. In no event shall the copyright owner or contributors be liable for
-- any direct, indirect, incidental, special, exemplary, or consequential damages
-- (including, but not limited to, procurement of substitute goods or services;
-- loss of use, data, or profits; or business interruption) however caused and
-- on any theory of liability, whether in contract, strict liability, or tort
-- (including negligence or otherwise) arising in any way out of the use of this
-- software, even if advised of the possibility of such damage.
--
-- Other modules (files) of this software composition should contain their
-- own copyright statements, which may have different copyright and usage
-- conditions. The above conditions apply to this file.
-------------------------------------------------------------------------------
--
-- $Revision: 1.4 $
-- $Date: 2015/10/24 19:36:49 $
--
-- $Log: flow-pruning.ads,v $
-- Revision 1.4 2015/10/24 19:36:49 niklas
-- Moved to free licence.
--
-- Revision 1.3 2007-12-17 13:54:37 niklas
-- BT-CH-0098: Assertions on stack usage and final stack height, etc.
--
-- Revision 1.2 2005/02/16 21:11:45 niklas
-- BT-CH-0002.
--
-- Revision 1.1 2004/04/28 19:07:50 niklas
-- First version.
--
with Flow.Computation;
package Flow.Pruning is
procedure Prune (Model : in out Computation.Model_Ref);
--
-- Given a computation Model for a flow-graph with some parts (steps
-- or edges) marked as infeasible, this operation propagates the
-- infeasibility to adjacent parts of the Model, as necessary.
-- The flow-graph should not contain loose edges, but may contain
-- dynamic edges.
--
-- A flow-graph part is feasible if and only if:
--
-- > there is a feasible path from the entry step to this part, and
--
-- > there is a feasible path from this part to a return step, or
-- to a call that does not return to the caller, or to the head
-- of an eternal loop (a loop with no feasible exit edges).
--
-- All the changes are applied to the computation Model. The
-- underlying flow-graph is not modified.
end Flow.Pruning;
|
tum-ei-rcs/StratoX | Ada | 6,938 | ads | -- This spec has been automatically generated from STM32F427x.svd
pragma Restrictions (No_Elaboration_Code);
pragma Ada_2012;
with System;
with HAL;
package STM32_SVD.DBG is
pragma Preelaborate;
---------------
-- Registers --
---------------
----------------------------
-- DBGMCU_IDCODE_Register --
----------------------------
subtype DBGMCU_IDCODE_DEV_ID_Field is HAL.UInt12;
subtype DBGMCU_IDCODE_REV_ID_Field is HAL.Short;
-- IDCODE
type DBGMCU_IDCODE_Register is record
-- Read-only. DEV_ID
DEV_ID : DBGMCU_IDCODE_DEV_ID_Field;
-- unspecified
Reserved_12_15 : HAL.UInt4;
-- Read-only. REV_ID
REV_ID : DBGMCU_IDCODE_REV_ID_Field;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for DBGMCU_IDCODE_Register use record
DEV_ID at 0 range 0 .. 11;
Reserved_12_15 at 0 range 12 .. 15;
REV_ID at 0 range 16 .. 31;
end record;
------------------------
-- DBGMCU_CR_Register --
------------------------
subtype DBGMCU_CR_TRACE_MODE_Field is HAL.UInt2;
-- Control Register
type DBGMCU_CR_Register is record
-- DBG_SLEEP
DBG_SLEEP : Boolean := False;
-- DBG_STOP
DBG_STOP : Boolean := False;
-- DBG_STANDBY
DBG_STANDBY : Boolean := False;
-- unspecified
Reserved_3_4 : HAL.UInt2 := 16#0#;
-- TRACE_IOEN
TRACE_IOEN : Boolean := False;
-- TRACE_MODE
TRACE_MODE : DBGMCU_CR_TRACE_MODE_Field := 16#0#;
-- unspecified
Reserved_8_31 : HAL.UInt24 := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for DBGMCU_CR_Register use record
DBG_SLEEP at 0 range 0 .. 0;
DBG_STOP at 0 range 1 .. 1;
DBG_STANDBY at 0 range 2 .. 2;
Reserved_3_4 at 0 range 3 .. 4;
TRACE_IOEN at 0 range 5 .. 5;
TRACE_MODE at 0 range 6 .. 7;
Reserved_8_31 at 0 range 8 .. 31;
end record;
-----------------------------
-- DBGMCU_APB1_FZ_Register --
-----------------------------
-- Debug MCU APB1 Freeze registe
type DBGMCU_APB1_FZ_Register is record
-- DBG_TIM2_STOP
DBG_TIM2_STOP : Boolean := False;
-- DBG_TIM3 _STOP
DBG_TIM3_STOP : Boolean := False;
-- DBG_TIM4_STOP
DBG_TIM4_STOP : Boolean := False;
-- DBG_TIM5_STOP
DBG_TIM5_STOP : Boolean := False;
-- DBG_TIM6_STOP
DBG_TIM6_STOP : Boolean := False;
-- DBG_TIM7_STOP
DBG_TIM7_STOP : Boolean := False;
-- DBG_TIM12_STOP
DBG_TIM12_STOP : Boolean := False;
-- DBG_TIM13_STOP
DBG_TIM13_STOP : Boolean := False;
-- DBG_TIM14_STOP
DBG_TIM14_STOP : Boolean := False;
-- unspecified
Reserved_9_10 : HAL.UInt2 := 16#0#;
-- DBG_WWDG_STOP
DBG_WWDG_STOP : Boolean := False;
-- DBG_IWDEG_STOP
DBG_IWDEG_STOP : Boolean := False;
-- unspecified
Reserved_13_20 : HAL.Byte := 16#0#;
-- DBG_J2C1_SMBUS_TIMEOUT
DBG_J2C1_SMBUS_TIMEOUT : Boolean := False;
-- DBG_J2C2_SMBUS_TIMEOUT
DBG_J2C2_SMBUS_TIMEOUT : Boolean := False;
-- DBG_J2C3SMBUS_TIMEOUT
DBG_J2C3SMBUS_TIMEOUT : Boolean := False;
-- unspecified
Reserved_24_24 : HAL.Bit := 16#0#;
-- DBG_CAN1_STOP
DBG_CAN1_STOP : Boolean := False;
-- DBG_CAN2_STOP
DBG_CAN2_STOP : Boolean := False;
-- unspecified
Reserved_27_31 : HAL.UInt5 := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for DBGMCU_APB1_FZ_Register use record
DBG_TIM2_STOP at 0 range 0 .. 0;
DBG_TIM3_STOP at 0 range 1 .. 1;
DBG_TIM4_STOP at 0 range 2 .. 2;
DBG_TIM5_STOP at 0 range 3 .. 3;
DBG_TIM6_STOP at 0 range 4 .. 4;
DBG_TIM7_STOP at 0 range 5 .. 5;
DBG_TIM12_STOP at 0 range 6 .. 6;
DBG_TIM13_STOP at 0 range 7 .. 7;
DBG_TIM14_STOP at 0 range 8 .. 8;
Reserved_9_10 at 0 range 9 .. 10;
DBG_WWDG_STOP at 0 range 11 .. 11;
DBG_IWDEG_STOP at 0 range 12 .. 12;
Reserved_13_20 at 0 range 13 .. 20;
DBG_J2C1_SMBUS_TIMEOUT at 0 range 21 .. 21;
DBG_J2C2_SMBUS_TIMEOUT at 0 range 22 .. 22;
DBG_J2C3SMBUS_TIMEOUT at 0 range 23 .. 23;
Reserved_24_24 at 0 range 24 .. 24;
DBG_CAN1_STOP at 0 range 25 .. 25;
DBG_CAN2_STOP at 0 range 26 .. 26;
Reserved_27_31 at 0 range 27 .. 31;
end record;
-----------------------------
-- DBGMCU_APB2_FZ_Register --
-----------------------------
-- Debug MCU APB2 Freeze registe
type DBGMCU_APB2_FZ_Register is record
-- TIM1 counter stopped when core is halted
DBG_TIM1_STOP : Boolean := False;
-- TIM8 counter stopped when core is halted
DBG_TIM8_STOP : Boolean := False;
-- unspecified
Reserved_2_15 : HAL.UInt14 := 16#0#;
-- TIM9 counter stopped when core is halted
DBG_TIM9_STOP : Boolean := False;
-- TIM10 counter stopped when core is halted
DBG_TIM10_STOP : Boolean := False;
-- TIM11 counter stopped when core is halted
DBG_TIM11_STOP : Boolean := False;
-- unspecified
Reserved_19_31 : HAL.UInt13 := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for DBGMCU_APB2_FZ_Register use record
DBG_TIM1_STOP at 0 range 0 .. 0;
DBG_TIM8_STOP at 0 range 1 .. 1;
Reserved_2_15 at 0 range 2 .. 15;
DBG_TIM9_STOP at 0 range 16 .. 16;
DBG_TIM10_STOP at 0 range 17 .. 17;
DBG_TIM11_STOP at 0 range 18 .. 18;
Reserved_19_31 at 0 range 19 .. 31;
end record;
-----------------
-- Peripherals --
-----------------
-- Debug support
type DBG_Peripheral is record
-- IDCODE
DBGMCU_IDCODE : DBGMCU_IDCODE_Register;
-- Control Register
DBGMCU_CR : DBGMCU_CR_Register;
-- Debug MCU APB1 Freeze registe
DBGMCU_APB1_FZ : DBGMCU_APB1_FZ_Register;
-- Debug MCU APB2 Freeze registe
DBGMCU_APB2_FZ : DBGMCU_APB2_FZ_Register;
end record
with Volatile;
for DBG_Peripheral use record
DBGMCU_IDCODE at 0 range 0 .. 31;
DBGMCU_CR at 4 range 0 .. 31;
DBGMCU_APB1_FZ at 8 range 0 .. 31;
DBGMCU_APB2_FZ at 12 range 0 .. 31;
end record;
-- Debug support
DBG_Periph : aliased DBG_Peripheral
with Import, Address => DBG_Base;
end STM32_SVD.DBG;
|
glencornell/ada-object-framework | Ada | 2,399 | ads | -- Copyright (C) 2020 Glen Cornell <[email protected]>
--
-- 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/>.
with Aof.Core.Root_Objects;
with Aof.Core.Generic_Signals;
with Ada.Strings.Unbounded;
package Aof.Core.Signals is
pragma Preelaborate;
package Empty is new Aof.Core.Generic_Signals.S0
(Object => Aof.Core.Root_Objects.Root_Object,
Access_Object => Aof.Core.Root_Objects.Access_Object);
package Access_Objects is new Aof.Core.Generic_Signals.S1
(Object => Aof.Core.Root_Objects.Root_Object,
Access_Object => Aof.Core.Root_Objects.Access_Object,
Param_1 => Aof.Core.Root_Objects.Access_Object);
package Strings is new Aof.Core.Generic_Signals.S1
(Object => Aof.Core.Root_Objects.Root_Object,
Access_Object => Aof.Core.Root_Objects.Access_Object,
Param_1 => Ada.Strings.Unbounded.Unbounded_String);
package Naturals is new Aof.Core.Generic_Signals.S1
(Object => Aof.Core.Root_Objects.Root_Object,
Access_Object => Aof.Core.Root_Objects.Access_Object,
Param_1 => Natural);
package Integers is new Aof.Core.Generic_Signals.S1
(Object => Aof.Core.Root_Objects.Root_Object,
Access_Object => Aof.Core.Root_Objects.Access_Object,
Param_1 => Integer);
package Floats is new Aof.Core.Generic_Signals.S1
(Object => Aof.Core.Root_Objects.Root_Object,
Access_Object => Aof.Core.Root_Objects.Access_Object,
Param_1 => Float);
package Long_Floats is new Aof.Core.Generic_Signals.S1
(Object => Aof.Core.Root_Objects.Root_Object,
Access_Object => Aof.Core.Root_Objects.Access_Object,
Param_1 => Long_Float);
end Aof.Core.Signals;
|
reznikmm/matreshka | Ada | 9,522 | adb | ------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- Ada Modeling Framework --
-- --
-- Runtime Library Component --
-- --
------------------------------------------------------------------------------
-- --
-- Copyright © 2011-2012, Vadim Godunko <[email protected]> --
-- All rights reserved. --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions --
-- are met: --
-- --
-- * Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- --
-- * Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in the --
-- documentation and/or other materials provided with the distribution. --
-- --
-- * Neither the name of the Vadim Godunko, IE nor the names of its --
-- contributors may be used to endorse or promote products derived from --
-- this software without specific prior written permission. --
-- --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR --
-- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
-- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED --
-- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR --
-- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF --
-- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING --
-- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS --
-- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
-- --
------------------------------------------------------------------------------
-- $Revision$ $Date$
------------------------------------------------------------------------------
with AMF.Elements;
with AMF.Internals.Element_Collections;
with AMF.Internals.Helpers;
with AMF.Internals.Tables.UML_Attributes;
with AMF.Visitors.UML_Iterators;
with AMF.Visitors.UML_Visitors;
package body AMF.Internals.UML_Template_Bindings is
-------------------
-- Enter_Element --
-------------------
overriding procedure Enter_Element
(Self : not null access constant UML_Template_Binding_Proxy;
Visitor : in out AMF.Visitors.Abstract_Visitor'Class;
Control : in out AMF.Visitors.Traverse_Control) is
begin
if Visitor in AMF.Visitors.UML_Visitors.UML_Visitor'Class then
AMF.Visitors.UML_Visitors.UML_Visitor'Class
(Visitor).Enter_Template_Binding
(AMF.UML.Template_Bindings.UML_Template_Binding_Access (Self),
Control);
end if;
end Enter_Element;
-------------------
-- Leave_Element --
-------------------
overriding procedure Leave_Element
(Self : not null access constant UML_Template_Binding_Proxy;
Visitor : in out AMF.Visitors.Abstract_Visitor'Class;
Control : in out AMF.Visitors.Traverse_Control) is
begin
if Visitor in AMF.Visitors.UML_Visitors.UML_Visitor'Class then
AMF.Visitors.UML_Visitors.UML_Visitor'Class
(Visitor).Leave_Template_Binding
(AMF.UML.Template_Bindings.UML_Template_Binding_Access (Self),
Control);
end if;
end Leave_Element;
-------------------
-- Visit_Element --
-------------------
overriding procedure Visit_Element
(Self : not null access constant UML_Template_Binding_Proxy;
Iterator : in out AMF.Visitors.Abstract_Iterator'Class;
Visitor : in out AMF.Visitors.Abstract_Visitor'Class;
Control : in out AMF.Visitors.Traverse_Control) is
begin
if Iterator in AMF.Visitors.UML_Iterators.UML_Iterator'Class then
AMF.Visitors.UML_Iterators.UML_Iterator'Class
(Iterator).Visit_Template_Binding
(Visitor,
AMF.UML.Template_Bindings.UML_Template_Binding_Access (Self),
Control);
end if;
end Visit_Element;
-----------------------
-- Get_Bound_Element --
-----------------------
overriding function Get_Bound_Element
(Self : not null access constant UML_Template_Binding_Proxy)
return AMF.UML.Templateable_Elements.UML_Templateable_Element_Access is
begin
return
AMF.UML.Templateable_Elements.UML_Templateable_Element_Access
(AMF.Internals.Helpers.To_Element
(AMF.Internals.Tables.UML_Attributes.Internal_Get_Bound_Element
(Self.Element)));
end Get_Bound_Element;
-----------------------
-- Set_Bound_Element --
-----------------------
overriding procedure Set_Bound_Element
(Self : not null access UML_Template_Binding_Proxy;
To : AMF.UML.Templateable_Elements.UML_Templateable_Element_Access) is
begin
AMF.Internals.Tables.UML_Attributes.Internal_Set_Bound_Element
(Self.Element,
AMF.Internals.Helpers.To_Element
(AMF.Elements.Element_Access (To)));
end Set_Bound_Element;
--------------------------------
-- Get_Parameter_Substitution --
--------------------------------
overriding function Get_Parameter_Substitution
(Self : not null access constant UML_Template_Binding_Proxy)
return AMF.UML.Template_Parameter_Substitutions.Collections.Set_Of_UML_Template_Parameter_Substitution is
begin
return
AMF.UML.Template_Parameter_Substitutions.Collections.Wrap
(AMF.Internals.Element_Collections.Wrap
(AMF.Internals.Tables.UML_Attributes.Internal_Get_Parameter_Substitution
(Self.Element)));
end Get_Parameter_Substitution;
-------------------
-- Get_Signature --
-------------------
overriding function Get_Signature
(Self : not null access constant UML_Template_Binding_Proxy)
return AMF.UML.Template_Signatures.UML_Template_Signature_Access is
begin
return
AMF.UML.Template_Signatures.UML_Template_Signature_Access
(AMF.Internals.Helpers.To_Element
(AMF.Internals.Tables.UML_Attributes.Internal_Get_Signature
(Self.Element)));
end Get_Signature;
-------------------
-- Set_Signature --
-------------------
overriding procedure Set_Signature
(Self : not null access UML_Template_Binding_Proxy;
To : AMF.UML.Template_Signatures.UML_Template_Signature_Access) is
begin
AMF.Internals.Tables.UML_Attributes.Internal_Set_Signature
(Self.Element,
AMF.Internals.Helpers.To_Element
(AMF.Elements.Element_Access (To)));
end Set_Signature;
----------------
-- Get_Source --
----------------
overriding function Get_Source
(Self : not null access constant UML_Template_Binding_Proxy)
return AMF.UML.Elements.Collections.Set_Of_UML_Element is
begin
return
AMF.UML.Elements.Collections.Wrap
(AMF.Internals.Element_Collections.Wrap
(AMF.Internals.Tables.UML_Attributes.Internal_Get_Source
(Self.Element)));
end Get_Source;
----------------
-- Get_Target --
----------------
overriding function Get_Target
(Self : not null access constant UML_Template_Binding_Proxy)
return AMF.UML.Elements.Collections.Set_Of_UML_Element is
begin
return
AMF.UML.Elements.Collections.Wrap
(AMF.Internals.Element_Collections.Wrap
(AMF.Internals.Tables.UML_Attributes.Internal_Get_Target
(Self.Element)));
end Get_Target;
-------------------------
-- Get_Related_Element --
-------------------------
overriding function Get_Related_Element
(Self : not null access constant UML_Template_Binding_Proxy)
return AMF.UML.Elements.Collections.Set_Of_UML_Element is
begin
return
AMF.UML.Elements.Collections.Wrap
(AMF.Internals.Element_Collections.Wrap
(AMF.Internals.Tables.UML_Attributes.Internal_Get_Related_Element
(Self.Element)));
end Get_Related_Element;
end AMF.Internals.UML_Template_Bindings;
|
reznikmm/matreshka | Ada | 5,691 | ads | ------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- Ada Modeling Framework --
-- --
-- Runtime Library Component --
-- --
------------------------------------------------------------------------------
-- --
-- Copyright © 2011-2012, Vadim Godunko <[email protected]> --
-- All rights reserved. --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions --
-- are met: --
-- --
-- * Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- --
-- * Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in the --
-- documentation and/or other materials provided with the distribution. --
-- --
-- * Neither the name of the Vadim Godunko, IE nor the names of its --
-- contributors may be used to endorse or promote products derived from --
-- this software without specific prior written permission. --
-- --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR --
-- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
-- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED --
-- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR --
-- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF --
-- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING --
-- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS --
-- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
-- --
------------------------------------------------------------------------------
-- $Revision$ $Date$
------------------------------------------------------------------------------
-- This file is generated, don't edit it.
------------------------------------------------------------------------------
with AMF.Generic_Collections;
package AMF.UML.Start_Classifier_Behavior_Actions.Collections is
pragma Preelaborate;
package UML_Start_Classifier_Behavior_Action_Collections is
new AMF.Generic_Collections
(UML_Start_Classifier_Behavior_Action,
UML_Start_Classifier_Behavior_Action_Access);
type Set_Of_UML_Start_Classifier_Behavior_Action is
new UML_Start_Classifier_Behavior_Action_Collections.Set with null record;
Empty_Set_Of_UML_Start_Classifier_Behavior_Action : constant Set_Of_UML_Start_Classifier_Behavior_Action;
type Ordered_Set_Of_UML_Start_Classifier_Behavior_Action is
new UML_Start_Classifier_Behavior_Action_Collections.Ordered_Set with null record;
Empty_Ordered_Set_Of_UML_Start_Classifier_Behavior_Action : constant Ordered_Set_Of_UML_Start_Classifier_Behavior_Action;
type Bag_Of_UML_Start_Classifier_Behavior_Action is
new UML_Start_Classifier_Behavior_Action_Collections.Bag with null record;
Empty_Bag_Of_UML_Start_Classifier_Behavior_Action : constant Bag_Of_UML_Start_Classifier_Behavior_Action;
type Sequence_Of_UML_Start_Classifier_Behavior_Action is
new UML_Start_Classifier_Behavior_Action_Collections.Sequence with null record;
Empty_Sequence_Of_UML_Start_Classifier_Behavior_Action : constant Sequence_Of_UML_Start_Classifier_Behavior_Action;
private
Empty_Set_Of_UML_Start_Classifier_Behavior_Action : constant Set_Of_UML_Start_Classifier_Behavior_Action
:= (UML_Start_Classifier_Behavior_Action_Collections.Set with null record);
Empty_Ordered_Set_Of_UML_Start_Classifier_Behavior_Action : constant Ordered_Set_Of_UML_Start_Classifier_Behavior_Action
:= (UML_Start_Classifier_Behavior_Action_Collections.Ordered_Set with null record);
Empty_Bag_Of_UML_Start_Classifier_Behavior_Action : constant Bag_Of_UML_Start_Classifier_Behavior_Action
:= (UML_Start_Classifier_Behavior_Action_Collections.Bag with null record);
Empty_Sequence_Of_UML_Start_Classifier_Behavior_Action : constant Sequence_Of_UML_Start_Classifier_Behavior_Action
:= (UML_Start_Classifier_Behavior_Action_Collections.Sequence with null record);
end AMF.UML.Start_Classifier_Behavior_Actions.Collections;
|
AdaCore/Ada_Drivers_Library | Ada | 15,523 | ads | -- This spec has been automatically generated from cm4f.svd
pragma Restrictions (No_Elaboration_Code);
pragma Ada_2012;
pragma Style_Checks (Off);
with HAL;
with System;
-- Memory Protection Unit
package Cortex_M_SVD.MPU is
pragma Preelaborate;
---------------
-- Registers --
---------------
-- Indicates support for unified or separate instruction and data memory
-- maps.
type TYPE_SEPARATE_Field is
(
-- Only unified memory maps are supported.
Unified)
with Size => 1;
for TYPE_SEPARATE_Field use
(Unified => 0);
subtype MPU_TYPE_DREGION_Field is HAL.UInt8;
subtype MPU_TYPE_IREGION_Field is HAL.UInt8;
-- MPU Type Register
type MPU_TYPE_Register is record
-- Read-only. Indicates support for unified or separate instruction and
-- data memory maps.
SEPARATE_k : TYPE_SEPARATE_Field;
-- unspecified
Reserved_1_7 : HAL.UInt7;
-- Read-only. Indicates the number of supported MPU data regions
-- depending on your implementation.
DREGION : MPU_TYPE_DREGION_Field;
-- Read-only. Indicates the number of supported MPU instruction regions.
-- Always contains 0x0: the MPU memory map is unified and is described
-- by the DREGION field.
IREGION : MPU_TYPE_IREGION_Field;
-- unspecified
Reserved_24_31 : HAL.UInt8;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for MPU_TYPE_Register use record
SEPARATE_k at 0 range 0 .. 0;
Reserved_1_7 at 0 range 1 .. 7;
DREGION at 0 range 8 .. 15;
IREGION at 0 range 16 .. 23;
Reserved_24_31 at 0 range 24 .. 31;
end record;
-- MPU Control Register
type MPU_CTRL_Register is record
-- Enables the optional MPU.
ENABLE : Boolean := False;
-- Enables the operation of MPU during hard fault, NMI, and FAULTMASK
-- handlers.
HFNMIENA : Boolean := False;
-- Enables privileged software access to the default memory map.
PRIVDEFENA : Boolean := False;
-- unspecified
Reserved_3_31 : HAL.UInt29 := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for MPU_CTRL_Register use record
ENABLE at 0 range 0 .. 0;
HFNMIENA at 0 range 1 .. 1;
PRIVDEFENA at 0 range 2 .. 2;
Reserved_3_31 at 0 range 3 .. 31;
end record;
subtype MPU_RNR_REGION_Field is HAL.UInt8;
-- MPU Region Number Register
type MPU_RNR_Register is record
-- Indicates the MPU region referenced by the MPU_RBAR and MPU_RASR
-- registers.
REGION : MPU_RNR_REGION_Field := 16#0#;
-- unspecified
Reserved_8_31 : HAL.UInt24 := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for MPU_RNR_Register use record
REGION at 0 range 0 .. 7;
Reserved_8_31 at 0 range 8 .. 31;
end record;
subtype MPU_RBAR_REGION_Field is HAL.UInt4;
subtype MPU_RBAR_ADDR_Field is HAL.UInt27;
-- MPU Region Base Address Register
type MPU_RBAR_Register is record
-- On Write, see the VALID field. On read, specifies the region number.
REGION : MPU_RBAR_REGION_Field := 16#0#;
-- MPU Region number valid bit. Depending on your implementation, this
-- has the following effect: 0 - either updates the base address for the
-- region specified by MPU_RNR or ignores the value of the REGION field.
-- 1 - either updates the value of the MPU_RNR to the value of the
-- REGION field or updates the base address for the region specified in
-- the REGION field.
VALID : Boolean := False;
-- The ADDR field is bits[31:N] of the MPU_RBAR. The region size, as
-- specified by the SIZE field in the MPU_RASR, defines the value of N:
-- N = Log2(Region size in bytes). If the region size is configured to
-- 4GB, in the MPU_RASR, there is no valid ADDR field. In this case, the
-- region occupies the complete memory map, and the base address is
-- 0x00000000. The base address is aligned to the size of the region.
-- For example, a 64KB region must be aligned on a multiple of 64KB, for
-- example, at 0x00010000 or 0x00020000.
ADDR : MPU_RBAR_ADDR_Field := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for MPU_RBAR_Register use record
REGION at 0 range 0 .. 3;
VALID at 0 range 4 .. 4;
ADDR at 0 range 5 .. 31;
end record;
subtype MPU_RASR_SIZE_Field is HAL.UInt5;
-- MPU_RASR_SRD array
type MPU_RASR_SRD_Field_Array is array (0 .. 7) of Boolean
with Component_Size => 1, Size => 8;
-- Type definition for MPU_RASR_SRD
type MPU_RASR_SRD_Field
(As_Array : Boolean := False)
is record
case As_Array is
when False =>
-- SRD as a value
Val : HAL.UInt8;
when True =>
-- SRD as an array
Arr : MPU_RASR_SRD_Field_Array;
end case;
end record
with Unchecked_Union, Size => 8;
for MPU_RASR_SRD_Field use record
Val at 0 range 0 .. 7;
Arr at 0 range 0 .. 7;
end record;
subtype MPU_RASR_TEX_Field is HAL.UInt3;
-- Access permission field
type RASR_AP_Field is
(
-- All accesses generate a permission fault.
No_Access,
-- Access from privileged software only.
Privileged_Rw,
-- Writes by unprivileged software generates a permission fault.
Unpriviledged_Ro,
-- Full Access.
Full_Access,
-- Reads by privileged software only.
Privileged_Ro,
-- Read_Only by privileged or unprivileged software.
Read_Only,
-- Read_Only by privileged or unprivileged software.
Read_Only_1)
with Size => 3;
for RASR_AP_Field use
(No_Access => 0,
Privileged_Rw => 1,
Unpriviledged_Ro => 2,
Full_Access => 3,
Privileged_Ro => 5,
Read_Only => 6,
Read_Only_1 => 7);
-- Instruction access disable bit
type RASR_XN_Field is
(
-- Instruction fetches enabled.
I_Enabled,
-- Instruction fetches disabled.
I_Disabled)
with Size => 1;
for RASR_XN_Field use
(I_Enabled => 0,
I_Disabled => 1);
-- MPU Region Base Attribute and Size Register
type MPU_RASR_Register is record
-- Region enable bit.
ENABLE : Boolean := False;
-- Specifies the size of the MPU protection region. Minimum value is 4.
-- The Region size is defined as (Region size in bytes) = 2^(SIZE+1)
SIZE : MPU_RASR_SIZE_Field := 16#0#;
-- unspecified
Reserved_6_7 : HAL.UInt2 := 16#0#;
-- Subregion disable bits
SRD : MPU_RASR_SRD_Field :=
(As_Array => False, Val => 16#0#);
-- Memory access attribute.
B : Boolean := False;
-- Memory access attribute.
C : Boolean := False;
-- Shareable bit. Applies to Normal memory only.
S : Boolean := False;
-- Memory access attribute.
TEX : MPU_RASR_TEX_Field := 16#0#;
-- unspecified
Reserved_22_23 : HAL.UInt2 := 16#0#;
-- Access permission field
AP : RASR_AP_Field := Cortex_M_SVD.MPU.No_Access;
-- unspecified
Reserved_27_27 : HAL.Bit := 16#0#;
-- Instruction access disable bit
XN : RASR_XN_Field := Cortex_M_SVD.MPU.I_Enabled;
-- unspecified
Reserved_29_31 : HAL.UInt3 := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for MPU_RASR_Register use record
ENABLE at 0 range 0 .. 0;
SIZE at 0 range 1 .. 5;
Reserved_6_7 at 0 range 6 .. 7;
SRD at 0 range 8 .. 15;
B at 0 range 16 .. 16;
C at 0 range 17 .. 17;
S at 0 range 18 .. 18;
TEX at 0 range 19 .. 21;
Reserved_22_23 at 0 range 22 .. 23;
AP at 0 range 24 .. 26;
Reserved_27_27 at 0 range 27 .. 27;
XN at 0 range 28 .. 28;
Reserved_29_31 at 0 range 29 .. 31;
end record;
subtype RBAR_A_REGION_Field is HAL.UInt4;
subtype RBAR_A_ADDR_Field is HAL.UInt27;
-- Uses (MPU_RNR[7:2]<<2) + 1
type RBAR_A_Register is record
-- On Write, see the VALID field. On read, specifies the region number.
REGION : RBAR_A_REGION_Field := 16#0#;
-- MPU Region number valid bit. Depending on your implementation, this
-- has the following effect: 0 - either updates the base address for the
-- region specified by MPU_RNR or ignores the value of the REGION field.
-- 1 - either updates the value of the MPU_RNR to the value of the
-- REGION field or updates the base address for the region specified in
-- the REGION field.
VALID : Boolean := False;
-- The ADDR field is bits[31:N] of the MPU_RBAR. The region size, as
-- specified by the SIZE field in the MPU_RASR, defines the value of N:
-- N = Log2(Region size in bytes). If the region size is configured to
-- 4GB, in the MPU_RASR, there is no valid ADDR field. In this case, the
-- region occupies the complete memory map, and the base address is
-- 0x00000000. The base address is aligned to the size of the region.
-- For example, a 64KB region must be aligned on a multiple of 64KB, for
-- example, at 0x00010000 or 0x00020000.
ADDR : RBAR_A_ADDR_Field := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for RBAR_A_Register use record
REGION at 0 range 0 .. 3;
VALID at 0 range 4 .. 4;
ADDR at 0 range 5 .. 31;
end record;
subtype RASR_A_SIZE_Field is HAL.UInt5;
-- RASR_A_SRD array
type RASR_A_SRD_Field_Array is array (0 .. 7) of Boolean
with Component_Size => 1, Size => 8;
-- Type definition for RASR_A_SRD
type RASR_A_SRD_Field
(As_Array : Boolean := False)
is record
case As_Array is
when False =>
-- SRD as a value
Val : HAL.UInt8;
when True =>
-- SRD as an array
Arr : RASR_A_SRD_Field_Array;
end case;
end record
with Unchecked_Union, Size => 8;
for RASR_A_SRD_Field use record
Val at 0 range 0 .. 7;
Arr at 0 range 0 .. 7;
end record;
subtype RASR_A_TEX_Field is HAL.UInt3;
-- Access permission field
type RASR_A1_AP_Field is
(
-- All accesses generate a permission fault.
No_Access,
-- Access from privileged software only.
Privileged_Rw,
-- Writes by unprivileged software generates a permission fault.
Unpriviledged_Ro,
-- Full Access.
Full_Access,
-- Reads by privileged software only.
Privileged_Ro,
-- Read_Only by privileged or unprivileged software.
Read_Only,
-- Read_Only by privileged or unprivileged software.
Read_Only_1)
with Size => 3;
for RASR_A1_AP_Field use
(No_Access => 0,
Privileged_Rw => 1,
Unpriviledged_Ro => 2,
Full_Access => 3,
Privileged_Ro => 5,
Read_Only => 6,
Read_Only_1 => 7);
-- Instruction access disable bit
type RASR_A1_XN_Field is
(
-- Instruction fetches enabled.
I_Enabled,
-- Instruction fetches disabled.
I_Disabled)
with Size => 1;
for RASR_A1_XN_Field use
(I_Enabled => 0,
I_Disabled => 1);
-- Uses (MPU_RNR[7:2]<<2) + 1
type RASR_A_Register is record
-- Region enable bit.
ENABLE : Boolean := False;
-- Specifies the size of the MPU protection region. Minimum value is 4.
-- The Region size is defined as (Region size in bytes) = 2^(SIZE+1)
SIZE : RASR_A_SIZE_Field := 16#0#;
-- unspecified
Reserved_6_7 : HAL.UInt2 := 16#0#;
-- Subregion disable bits
SRD : RASR_A_SRD_Field := (As_Array => False, Val => 16#0#);
-- Memory access attribute.
B : Boolean := False;
-- Memory access attribute.
C : Boolean := False;
-- Shareable bit. Applies to Normal memory only.
S : Boolean := False;
-- Memory access attribute.
TEX : RASR_A_TEX_Field := 16#0#;
-- unspecified
Reserved_22_23 : HAL.UInt2 := 16#0#;
-- Access permission field
AP : RASR_A1_AP_Field := Cortex_M_SVD.MPU.No_Access;
-- unspecified
Reserved_27_27 : HAL.Bit := 16#0#;
-- Instruction access disable bit
XN : RASR_A1_XN_Field := Cortex_M_SVD.MPU.I_Enabled;
-- unspecified
Reserved_29_31 : HAL.UInt3 := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for RASR_A_Register use record
ENABLE at 0 range 0 .. 0;
SIZE at 0 range 1 .. 5;
Reserved_6_7 at 0 range 6 .. 7;
SRD at 0 range 8 .. 15;
B at 0 range 16 .. 16;
C at 0 range 17 .. 17;
S at 0 range 18 .. 18;
TEX at 0 range 19 .. 21;
Reserved_22_23 at 0 range 22 .. 23;
AP at 0 range 24 .. 26;
Reserved_27_27 at 0 range 27 .. 27;
XN at 0 range 28 .. 28;
Reserved_29_31 at 0 range 29 .. 31;
end record;
-----------------
-- Peripherals --
-----------------
-- Memory Protection Unit
type MPU_Peripheral is record
-- MPU Type Register
TYPE_k : aliased MPU_TYPE_Register;
-- MPU Control Register
CTRL : aliased MPU_CTRL_Register;
-- MPU Region Number Register
RNR : aliased MPU_RNR_Register;
-- MPU Region Base Address Register
RBAR : aliased MPU_RBAR_Register;
-- MPU Region Base Attribute and Size Register
RASR : aliased MPU_RASR_Register;
-- Uses (MPU_RNR[7:2]<<2) + 1
RBAR_A1 : aliased RBAR_A_Register;
-- Uses (MPU_RNR[7:2]<<2) + 1
RASR_A1 : aliased RASR_A_Register;
-- Uses (MPU_RNR[7:2]<<2) + 2
RBAR_A2 : aliased RBAR_A_Register;
-- Uses (MPU_RNR[7:2]<<2) + 2
RASR_A2 : aliased RASR_A_Register;
-- Uses (MPU_RNR[7:2]<<2) + 3
RBAR_A3 : aliased RBAR_A_Register;
-- Uses (MPU_RNR[7:2]<<2) + 3
RASR_A3 : aliased RASR_A_Register;
end record
with Volatile;
for MPU_Peripheral use record
TYPE_k at 16#0# range 0 .. 31;
CTRL at 16#4# range 0 .. 31;
RNR at 16#8# range 0 .. 31;
RBAR at 16#C# range 0 .. 31;
RASR at 16#10# range 0 .. 31;
RBAR_A1 at 16#14# range 0 .. 31;
RASR_A1 at 16#18# range 0 .. 31;
RBAR_A2 at 16#1C# range 0 .. 31;
RASR_A2 at 16#20# range 0 .. 31;
RBAR_A3 at 16#24# range 0 .. 31;
RASR_A3 at 16#28# range 0 .. 31;
end record;
-- Memory Protection Unit
MPU_Periph : aliased MPU_Peripheral
with Import, Address => MPU_Base;
end Cortex_M_SVD.MPU;
|
zhmu/ananas | Ada | 477 | ads | package Array38_Pkg is
type Byte is mod 2**8;
type Length is new Natural;
subtype Index is Length range 1 .. Length'Last;
type Bytes is array (Index range <>) of Byte with
Predicate => Bytes'Length > 0;
generic
type Index_Type is (<>);
type Element_Type is (<>);
type Array_Type is array (Index_Type range <>) of Element_Type;
type Value_Type is (<>);
function F (Data : Array_Type) return Value_Type;
end Array38_Pkg;
|
HeisenbugLtd/msg_passing | Ada | 1,753 | ads | ------------------------------------------------------------------------
-- Copyright (C) 2010-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);
------------------------------------------------------------------------
-- Msg_Passing
--
-- Root package for the several message passing algorithms, like
-- blackboards, whiteboards, and queues.
--
------------------------------------------------------------------------
generic
-- Type of message being exchanged.
-- May be any constrained type.
type Letter is private;
package Msg_Passing is
pragma Pure;
---------------------------------------------------------------------
-- The messenger object
---------------------------------------------------------------------
type Object is abstract tagged limited private;
---------------------------------------------------------------------
-- Object.Read
---------------------------------------------------------------------
procedure Read (Instance : in out Object;
Message : out Letter) is abstract;
---------------------------------------------------------------------
-- Object.Write
---------------------------------------------------------------------
procedure Write (Instance : in out Object;
Message : in Letter) is abstract;
private
type Object is abstract tagged limited null record;
end Msg_Passing;
|
zhmu/ananas | Ada | 3,895 | ads | ------------------------------------------------------------------------------
-- --
-- GNAT RUN-TIME COMPONENTS --
-- --
-- S Y S T E M . P A C K _ 1 4 --
-- --
-- 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 = 14
package System.Pack_14 is
pragma Preelaborate;
Bits : constant := 14;
type Bits_14 is mod 2 ** Bits;
for Bits_14'Size use Bits;
-- In all subprograms below, Rev_SSO is set True if the array has the
-- non-default scalar storage order.
function Get_14
(Arr : System.Address;
N : Natural;
Rev_SSO : Boolean) return Bits_14 with Inline;
-- Arr is the address of the packed array, N is the zero-based
-- subscript. This element is extracted and returned.
procedure Set_14
(Arr : System.Address;
N : Natural;
E : Bits_14;
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_14
(Arr : System.Address;
N : Natural;
Rev_SSO : Boolean) return Bits_14 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_14
(Arr : System.Address;
N : Natural;
E : Bits_14;
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_14;
|
ytomino/openssl-ada | Ada | 1,263 | adb | package body Crypto is
use type Ada.Streams.Stream_Element;
procedure Value (
Image : String;
Result : out Ada.Streams.Stream_Element_Array)
is
function Digit (C : Character) return Ada.Streams.Stream_Element is
begin
if C in '0' .. '9' then
return Character'Pos (C) - Character'Pos ('0');
elsif C in 'a' .. 'f' then
return Character'Pos (C) - Character'Pos ('a') + 10;
elsif C in 'A' .. 'F' then
return Character'Pos (C) - Character'Pos ('A') + 10;
else
raise Constraint_Error;
end if;
end Digit;
begin
for I in Result'Range loop
declare
Hi : constant Character := Image (2 * Integer (I) + 1);
Lo : constant Character := Image (2 * Integer (I) + 2);
begin
Result (I) := Digit (Hi) * 16 + Digit (Lo);
end;
end loop;
end Value;
procedure Image (
Value : Ada.Streams.Stream_Element_Array;
Result : out String)
is
Hex_Tab : constant array (0 .. 15) of Character := "0123456789abcdef";
begin
for I in Value'Range loop
declare
Item : constant Ada.Streams.Stream_Element := Value (I);
begin
Result (2 * Integer (I) + 1) := Hex_Tab (Natural (Item / 16));
Result (2 * Integer (I) + 2) := Hex_Tab (Natural (Item mod 16));
end;
end loop;
end Image;
end Crypto;
|
HackInvent/Ada_Drivers_Library | Ada | 42,034 | ads | -- This spec has been automatically generated from STM32H7x3.svd
pragma Restrictions (No_Elaboration_Code);
pragma Ada_2012;
pragma Style_Checks (Off);
with System;
package STM32_SVD.TIMs is
pragma Preelaborate;
---------------
-- Registers --
---------------
subtype CR1_CKD_Field is STM32_SVD.UInt2;
-- control register 1
type CR1_Register is record
-- Counter enable
CEN : Boolean := False;
-- Update disable
UDIS : Boolean := False;
-- Update request source
URS : Boolean := False;
-- One-pulse mode
OPM : Boolean := False;
-- unspecified
Reserved_4_6 : STM32_SVD.UInt3 := 16#0#;
-- Auto-reload preload enable
ARPE : Boolean := False;
-- Clock division
CKD : CR1_CKD_Field := 16#0#;
-- unspecified
Reserved_10_10 : STM32_SVD.Bit := 16#0#;
-- UIF status bit remapping
UIFREMAP : Boolean := False;
-- unspecified
Reserved_12_31 : STM32_SVD.UInt20 := 16#0#;
end record
with Volatile_Full_Access, Object_Size => 32,
Bit_Order => System.Low_Order_First;
for CR1_Register use record
CEN at 0 range 0 .. 0;
UDIS at 0 range 1 .. 1;
URS at 0 range 2 .. 2;
OPM at 0 range 3 .. 3;
Reserved_4_6 at 0 range 4 .. 6;
ARPE at 0 range 7 .. 7;
CKD at 0 range 8 .. 9;
Reserved_10_10 at 0 range 10 .. 10;
UIFREMAP at 0 range 11 .. 11;
Reserved_12_31 at 0 range 12 .. 31;
end record;
subtype CR2_MMS_Field is STM32_SVD.UInt3;
-- control register 2
type CR2_Register is record
-- Capture/compare preloaded control
CCPC : Boolean := False;
-- unspecified
Reserved_1_1 : STM32_SVD.Bit := 16#0#;
-- Capture/compare control update selection
CCUS : Boolean := False;
-- Capture/compare DMA selection
CCDS : Boolean := False;
-- Master mode selection
MMS : CR2_MMS_Field := 16#0#;
-- TI1 selection
TI1S : Boolean := False;
-- Output Idle state 1
OIS1 : Boolean := False;
-- Output Idle state 1
OIS1N : Boolean := False;
-- Output Idle state 2
OIS2 : Boolean := False;
-- unspecified
Reserved_11_31 : STM32_SVD.UInt21 := 16#0#;
end record
with Volatile_Full_Access, Object_Size => 32,
Bit_Order => System.Low_Order_First;
for CR2_Register use record
CCPC at 0 range 0 .. 0;
Reserved_1_1 at 0 range 1 .. 1;
CCUS at 0 range 2 .. 2;
CCDS at 0 range 3 .. 3;
MMS at 0 range 4 .. 6;
TI1S at 0 range 7 .. 7;
OIS1 at 0 range 8 .. 8;
OIS1N at 0 range 9 .. 9;
OIS2 at 0 range 10 .. 10;
Reserved_11_31 at 0 range 11 .. 31;
end record;
subtype SMCR_SMS_Field is STM32_SVD.UInt3;
subtype SMCR_TS_2_0_Field is STM32_SVD.UInt3;
subtype SMCR_TS_4_3_Field is STM32_SVD.UInt2;
-- slave mode control register
type SMCR_Register is record
-- Slave mode selection
SMS : SMCR_SMS_Field := 16#0#;
-- unspecified
Reserved_3_3 : STM32_SVD.Bit := 16#0#;
-- Trigger selection
TS_2_0 : SMCR_TS_2_0_Field := 16#0#;
-- Master/Slave mode
MSM : Boolean := False;
-- unspecified
Reserved_8_15 : STM32_SVD.Byte := 16#0#;
-- Slave mode selection bit 3
SMS_3 : Boolean := False;
-- unspecified
Reserved_17_19 : STM32_SVD.UInt3 := 16#0#;
-- Trigger selection - bit 4:3
TS_4_3 : SMCR_TS_4_3_Field := 16#0#;
-- unspecified
Reserved_22_31 : STM32_SVD.UInt10 := 16#0#;
end record
with Volatile_Full_Access, Object_Size => 32,
Bit_Order => System.Low_Order_First;
for SMCR_Register use record
SMS at 0 range 0 .. 2;
Reserved_3_3 at 0 range 3 .. 3;
TS_2_0 at 0 range 4 .. 6;
MSM at 0 range 7 .. 7;
Reserved_8_15 at 0 range 8 .. 15;
SMS_3 at 0 range 16 .. 16;
Reserved_17_19 at 0 range 17 .. 19;
TS_4_3 at 0 range 20 .. 21;
Reserved_22_31 at 0 range 22 .. 31;
end record;
-- DMA/Interrupt enable register
type DIER_Register is record
-- Update interrupt enable
UIE : Boolean := False;
-- Capture/Compare 1 interrupt enable
CC1IE : Boolean := False;
-- Capture/Compare 2 interrupt enable
CC2IE : Boolean := False;
-- unspecified
Reserved_3_4 : STM32_SVD.UInt2 := 16#0#;
-- COM interrupt enable
COMIE : Boolean := False;
-- Trigger interrupt enable
TIE : Boolean := False;
-- Break interrupt enable
BIE : Boolean := False;
-- Update DMA request enable
UDE : Boolean := False;
-- Capture/Compare 1 DMA request enable
CC1DE : Boolean := False;
-- Capture/Compare 2 DMA request enable
CC2DE : Boolean := False;
-- unspecified
Reserved_11_12 : STM32_SVD.UInt2 := 16#0#;
-- COM DMA request enable
COMDE : Boolean := False;
-- Trigger DMA request enable
TDE : Boolean := False;
-- unspecified
Reserved_15_31 : STM32_SVD.UInt17 := 16#0#;
end record
with Volatile_Full_Access, Object_Size => 32,
Bit_Order => System.Low_Order_First;
for DIER_Register use record
UIE at 0 range 0 .. 0;
CC1IE at 0 range 1 .. 1;
CC2IE at 0 range 2 .. 2;
Reserved_3_4 at 0 range 3 .. 4;
COMIE at 0 range 5 .. 5;
TIE at 0 range 6 .. 6;
BIE at 0 range 7 .. 7;
UDE at 0 range 8 .. 8;
CC1DE at 0 range 9 .. 9;
CC2DE at 0 range 10 .. 10;
Reserved_11_12 at 0 range 11 .. 12;
COMDE at 0 range 13 .. 13;
TDE at 0 range 14 .. 14;
Reserved_15_31 at 0 range 15 .. 31;
end record;
-- status register
type SR_Register is record
-- Update interrupt flag
UIF : Boolean := False;
-- Capture/compare 1 interrupt flag
CC1IF : Boolean := False;
-- Capture/Compare 2 interrupt flag
CC2IF : Boolean := False;
-- unspecified
Reserved_3_4 : STM32_SVD.UInt2 := 16#0#;
-- COM interrupt flag
COMIF : Boolean := False;
-- Trigger interrupt flag
TIF : Boolean := False;
-- Break interrupt flag
BIF : Boolean := False;
-- unspecified
Reserved_8_8 : STM32_SVD.Bit := 16#0#;
-- Capture/Compare 1 overcapture flag
CC1OF : Boolean := False;
-- Capture/compare 2 overcapture flag
CC2OF : Boolean := False;
-- unspecified
Reserved_11_31 : STM32_SVD.UInt21 := 16#0#;
end record
with Volatile_Full_Access, Object_Size => 32,
Bit_Order => System.Low_Order_First;
for SR_Register use record
UIF at 0 range 0 .. 0;
CC1IF at 0 range 1 .. 1;
CC2IF at 0 range 2 .. 2;
Reserved_3_4 at 0 range 3 .. 4;
COMIF at 0 range 5 .. 5;
TIF at 0 range 6 .. 6;
BIF at 0 range 7 .. 7;
Reserved_8_8 at 0 range 8 .. 8;
CC1OF at 0 range 9 .. 9;
CC2OF at 0 range 10 .. 10;
Reserved_11_31 at 0 range 11 .. 31;
end record;
-- event generation register
type EGR_Register is record
-- Write-only. Update generation
UG : Boolean := False;
-- Write-only. Capture/compare 1 generation
CC1G : Boolean := False;
-- Write-only. Capture/compare 2 generation
CC2G : Boolean := False;
-- unspecified
Reserved_3_4 : STM32_SVD.UInt2 := 16#0#;
-- Write-only. Capture/Compare control update generation
COMG : Boolean := False;
-- Write-only. Trigger generation
TG : Boolean := False;
-- Write-only. Break generation
BG : Boolean := False;
-- unspecified
Reserved_8_31 : STM32_SVD.UInt24 := 16#0#;
end record
with Volatile_Full_Access, Object_Size => 32,
Bit_Order => System.Low_Order_First;
for EGR_Register use record
UG at 0 range 0 .. 0;
CC1G at 0 range 1 .. 1;
CC2G at 0 range 2 .. 2;
Reserved_3_4 at 0 range 3 .. 4;
COMG at 0 range 5 .. 5;
TG at 0 range 6 .. 6;
BG at 0 range 7 .. 7;
Reserved_8_31 at 0 range 8 .. 31;
end record;
subtype CCMR1_Output_CC1S_Field is STM32_SVD.UInt2;
subtype CCMR1_Output_OC1M_Field is STM32_SVD.UInt3;
subtype CCMR1_Output_CC2S_Field is STM32_SVD.UInt2;
subtype CCMR1_Output_OC2M_Field is STM32_SVD.UInt3;
-- capture/compare mode register (output mode)
type CCMR1_Output_Register is record
-- Capture/Compare 1 selection
CC1S : CCMR1_Output_CC1S_Field := 16#0#;
-- Output Compare 1 fast enable
OC1FE : Boolean := False;
-- Output Compare 1 preload enable
OC1PE : Boolean := False;
-- Output Compare 1 mode
OC1M : CCMR1_Output_OC1M_Field := 16#0#;
-- unspecified
Reserved_7_7 : STM32_SVD.Bit := 16#0#;
-- Capture/Compare 2 selection
CC2S : CCMR1_Output_CC2S_Field := 16#0#;
-- Output Compare 2 fast enable
OC2FE : Boolean := False;
-- Output Compare 2 preload enable
OC2PE : Boolean := False;
-- Output Compare 2 mode
OC2M : CCMR1_Output_OC2M_Field := 16#0#;
-- unspecified
Reserved_15_15 : STM32_SVD.Bit := 16#0#;
-- Output Compare 1 mode bit 3
OC1M_3 : Boolean := False;
-- unspecified
Reserved_17_23 : STM32_SVD.UInt7 := 16#0#;
-- Output Compare 2 mode bit 3
OC2M_3 : Boolean := False;
-- unspecified
Reserved_25_31 : STM32_SVD.UInt7 := 16#0#;
end record
with Volatile_Full_Access, Object_Size => 32,
Bit_Order => System.Low_Order_First;
for CCMR1_Output_Register use record
CC1S at 0 range 0 .. 1;
OC1FE at 0 range 2 .. 2;
OC1PE at 0 range 3 .. 3;
OC1M at 0 range 4 .. 6;
Reserved_7_7 at 0 range 7 .. 7;
CC2S at 0 range 8 .. 9;
OC2FE at 0 range 10 .. 10;
OC2PE at 0 range 11 .. 11;
OC2M at 0 range 12 .. 14;
Reserved_15_15 at 0 range 15 .. 15;
OC1M_3 at 0 range 16 .. 16;
Reserved_17_23 at 0 range 17 .. 23;
OC2M_3 at 0 range 24 .. 24;
Reserved_25_31 at 0 range 25 .. 31;
end record;
subtype CCMR1_Input_CC1S_Field is STM32_SVD.UInt2;
subtype CCMR1_Input_IC1PSC_Field is STM32_SVD.UInt2;
subtype CCMR1_Input_IC1F_Field is STM32_SVD.UInt4;
subtype CCMR1_Input_CC2S_Field is STM32_SVD.UInt2;
subtype CCMR1_Input_IC2PSC_Field is STM32_SVD.UInt2;
subtype CCMR1_Input_IC2F_Field is STM32_SVD.UInt4;
-- capture/compare mode register 1 (input mode)
type CCMR1_Input_Register is record
-- Capture/Compare 1 selection
CC1S : CCMR1_Input_CC1S_Field := 16#0#;
-- Input capture 1 prescaler
IC1PSC : CCMR1_Input_IC1PSC_Field := 16#0#;
-- Input capture 1 filter
IC1F : CCMR1_Input_IC1F_Field := 16#0#;
-- Capture/Compare 2 selection
CC2S : CCMR1_Input_CC2S_Field := 16#0#;
-- Input capture 2 prescaler
IC2PSC : CCMR1_Input_IC2PSC_Field := 16#0#;
-- Input capture 2 filter
IC2F : CCMR1_Input_IC2F_Field := 16#0#;
-- unspecified
Reserved_16_31 : STM32_SVD.UInt16 := 16#0#;
end record
with Volatile_Full_Access, Object_Size => 32,
Bit_Order => System.Low_Order_First;
for CCMR1_Input_Register use record
CC1S at 0 range 0 .. 1;
IC1PSC at 0 range 2 .. 3;
IC1F at 0 range 4 .. 7;
CC2S at 0 range 8 .. 9;
IC2PSC at 0 range 10 .. 11;
IC2F at 0 range 12 .. 15;
Reserved_16_31 at 0 range 16 .. 31;
end record;
-- capture/compare enable register
type CCER_Register is record
-- Capture/Compare 1 output enable
CC1E : Boolean := False;
-- Capture/Compare 1 output Polarity
CC1P : Boolean := False;
-- Capture/Compare 1 complementary output enable
CC1NE : Boolean := False;
-- Capture/Compare 1 output Polarity
CC1NP : Boolean := False;
-- Capture/Compare 2 output enable
CC2E : Boolean := False;
-- Capture/Compare 2 output Polarity
CC2P : Boolean := False;
-- unspecified
Reserved_6_6 : STM32_SVD.Bit := 16#0#;
-- Capture/Compare 2 output Polarity
CC2NP : Boolean := False;
-- unspecified
Reserved_8_31 : STM32_SVD.UInt24 := 16#0#;
end record
with Volatile_Full_Access, Object_Size => 32,
Bit_Order => System.Low_Order_First;
for CCER_Register use record
CC1E at 0 range 0 .. 0;
CC1P at 0 range 1 .. 1;
CC1NE at 0 range 2 .. 2;
CC1NP at 0 range 3 .. 3;
CC2E at 0 range 4 .. 4;
CC2P at 0 range 5 .. 5;
Reserved_6_6 at 0 range 6 .. 6;
CC2NP at 0 range 7 .. 7;
Reserved_8_31 at 0 range 8 .. 31;
end record;
subtype CNT_CNT_Field is STM32_SVD.UInt16;
-- counter
type CNT_Register is record
-- counter value
CNT : CNT_CNT_Field := 16#0#;
-- unspecified
Reserved_16_30 : STM32_SVD.UInt15 := 16#0#;
-- Read-only. UIF copy
UIFCPY : Boolean := False;
end record
with Volatile_Full_Access, Object_Size => 32,
Bit_Order => System.Low_Order_First;
for CNT_Register use record
CNT at 0 range 0 .. 15;
Reserved_16_30 at 0 range 16 .. 30;
UIFCPY at 0 range 31 .. 31;
end record;
subtype PSC_PSC_Field is STM32_SVD.UInt16;
-- prescaler
type PSC_Register is record
-- Prescaler value
PSC : PSC_PSC_Field := 16#0#;
-- unspecified
Reserved_16_31 : STM32_SVD.UInt16 := 16#0#;
end record
with Volatile_Full_Access, Object_Size => 32,
Bit_Order => System.Low_Order_First;
for PSC_Register use record
PSC at 0 range 0 .. 15;
Reserved_16_31 at 0 range 16 .. 31;
end record;
subtype ARR_ARR_Field is STM32_SVD.UInt16;
-- auto-reload register
type ARR_Register is record
-- Auto-reload value
ARR : ARR_ARR_Field := 16#0#;
-- unspecified
Reserved_16_31 : STM32_SVD.UInt16 := 16#0#;
end record
with Volatile_Full_Access, Object_Size => 32,
Bit_Order => System.Low_Order_First;
for ARR_Register use record
ARR at 0 range 0 .. 15;
Reserved_16_31 at 0 range 16 .. 31;
end record;
subtype RCR_REP_Field is STM32_SVD.Byte;
-- repetition counter register
type RCR_Register is record
-- Repetition counter value
REP : RCR_REP_Field := 16#0#;
-- unspecified
Reserved_8_31 : STM32_SVD.UInt24 := 16#0#;
end record
with Volatile_Full_Access, Object_Size => 32,
Bit_Order => System.Low_Order_First;
for RCR_Register use record
REP at 0 range 0 .. 7;
Reserved_8_31 at 0 range 8 .. 31;
end record;
subtype CCR1_CCR1_Field is STM32_SVD.UInt16;
-- capture/compare register 1
type CCR1_Register is record
-- Capture/Compare 1 value
CCR1 : CCR1_CCR1_Field := 16#0#;
-- unspecified
Reserved_16_31 : STM32_SVD.UInt16 := 16#0#;
end record
with Volatile_Full_Access, Object_Size => 32,
Bit_Order => System.Low_Order_First;
for CCR1_Register use record
CCR1 at 0 range 0 .. 15;
Reserved_16_31 at 0 range 16 .. 31;
end record;
subtype CCR2_CCR2_Field is STM32_SVD.UInt16;
-- capture/compare register 2
type CCR2_Register is record
-- Capture/Compare 2 value
CCR2 : CCR2_CCR2_Field := 16#0#;
-- unspecified
Reserved_16_31 : STM32_SVD.UInt16 := 16#0#;
end record
with Volatile_Full_Access, Object_Size => 32,
Bit_Order => System.Low_Order_First;
for CCR2_Register use record
CCR2 at 0 range 0 .. 15;
Reserved_16_31 at 0 range 16 .. 31;
end record;
subtype BDTR_DTG_Field is STM32_SVD.Byte;
subtype BDTR_LOCK_Field is STM32_SVD.UInt2;
subtype BDTR_BKF_Field is STM32_SVD.UInt4;
-- break and dead-time register
type BDTR_Register is record
-- Dead-time generator setup
DTG : BDTR_DTG_Field := 16#0#;
-- Lock configuration
LOCK : BDTR_LOCK_Field := 16#0#;
-- Off-state selection for Idle mode
OSSI : Boolean := False;
-- Off-state selection for Run mode
OSSR : Boolean := False;
-- Break enable
BKE : Boolean := False;
-- Break polarity
BKP : Boolean := False;
-- Automatic output enable
AOE : Boolean := False;
-- Main output enable
MOE : Boolean := False;
-- Break filter
BKF : BDTR_BKF_Field := 16#0#;
-- unspecified
Reserved_20_31 : STM32_SVD.UInt12 := 16#0#;
end record
with Volatile_Full_Access, Object_Size => 32,
Bit_Order => System.Low_Order_First;
for BDTR_Register use record
DTG at 0 range 0 .. 7;
LOCK at 0 range 8 .. 9;
OSSI at 0 range 10 .. 10;
OSSR at 0 range 11 .. 11;
BKE at 0 range 12 .. 12;
BKP at 0 range 13 .. 13;
AOE at 0 range 14 .. 14;
MOE at 0 range 15 .. 15;
BKF at 0 range 16 .. 19;
Reserved_20_31 at 0 range 20 .. 31;
end record;
subtype DCR_DBA_Field is STM32_SVD.UInt5;
subtype DCR_DBL_Field is STM32_SVD.UInt5;
-- DMA control register
type DCR_Register is record
-- DMA base address
DBA : DCR_DBA_Field := 16#0#;
-- unspecified
Reserved_5_7 : STM32_SVD.UInt3 := 16#0#;
-- DMA burst length
DBL : DCR_DBL_Field := 16#0#;
-- unspecified
Reserved_13_31 : STM32_SVD.UInt19 := 16#0#;
end record
with Volatile_Full_Access, Object_Size => 32,
Bit_Order => System.Low_Order_First;
for DCR_Register use record
DBA at 0 range 0 .. 4;
Reserved_5_7 at 0 range 5 .. 7;
DBL at 0 range 8 .. 12;
Reserved_13_31 at 0 range 13 .. 31;
end record;
subtype DMAR_DMAB_Field is STM32_SVD.UInt16;
-- DMA address for full transfer
type DMAR_Register is record
-- DMA register for burst accesses
DMAB : DMAR_DMAB_Field := 16#0#;
-- unspecified
Reserved_16_31 : STM32_SVD.UInt16 := 16#0#;
end record
with Volatile_Full_Access, Object_Size => 32,
Bit_Order => System.Low_Order_First;
for DMAR_Register use record
DMAB at 0 range 0 .. 15;
Reserved_16_31 at 0 range 16 .. 31;
end record;
-- TIM15 alternate fdfsdm1_breakon register 1
type AF1_Register is record
-- BRK BKIN input enable
BKINE : Boolean := False;
-- BRK COMP1 enable
BKCMP1E : Boolean := False;
-- BRK COMP2 enable
BKCMP2E : Boolean := False;
-- unspecified
Reserved_3_7 : STM32_SVD.UInt5 := 16#0#;
-- BRK dfsdm1_break[0] enable
BKDF1BK0E : Boolean := False;
-- BRK BKIN input polarity
BKINP : Boolean := False;
-- BRK COMP1 input polarity
BKCMP1P : Boolean := False;
-- BRK COMP2 input polarity
BKCMP2P : Boolean := False;
-- unspecified
Reserved_12_31 : STM32_SVD.UInt20 := 16#0#;
end record
with Volatile_Full_Access, Object_Size => 32,
Bit_Order => System.Low_Order_First;
for AF1_Register use record
BKINE at 0 range 0 .. 0;
BKCMP1E at 0 range 1 .. 1;
BKCMP2E at 0 range 2 .. 2;
Reserved_3_7 at 0 range 3 .. 7;
BKDF1BK0E at 0 range 8 .. 8;
BKINP at 0 range 9 .. 9;
BKCMP1P at 0 range 10 .. 10;
BKCMP2P at 0 range 11 .. 11;
Reserved_12_31 at 0 range 12 .. 31;
end record;
subtype TISEL_TI1SEL_Field is STM32_SVD.UInt4;
subtype TISEL_TI2SEL_Field is STM32_SVD.UInt4;
-- TIM15 input selection register
type TISEL_Register is record
-- selects TI1[0] to TI1[15] input
TI1SEL : TISEL_TI1SEL_Field := 16#0#;
-- unspecified
Reserved_4_7 : STM32_SVD.UInt4 := 16#0#;
-- selects TI2[0] to TI2[15] input
TI2SEL : TISEL_TI2SEL_Field := 16#0#;
-- unspecified
Reserved_12_31 : STM32_SVD.UInt20 := 16#0#;
end record
with Volatile_Full_Access, Object_Size => 32,
Bit_Order => System.Low_Order_First;
for TISEL_Register use record
TI1SEL at 0 range 0 .. 3;
Reserved_4_7 at 0 range 4 .. 7;
TI2SEL at 0 range 8 .. 11;
Reserved_12_31 at 0 range 12 .. 31;
end record;
-- control register 2
type CR2_Register_1 is record
-- Capture/compare preloaded control
CCPC : Boolean := False;
-- unspecified
Reserved_1_1 : STM32_SVD.Bit := 16#0#;
-- Capture/compare control update selection
CCUS : Boolean := False;
-- Capture/compare DMA selection
CCDS : Boolean := False;
-- unspecified
Reserved_4_7 : STM32_SVD.UInt4 := 16#0#;
-- Output Idle state 1
OIS1 : Boolean := False;
-- Output Idle state 1
OIS1N : Boolean := False;
-- unspecified
Reserved_10_31 : STM32_SVD.UInt22 := 16#0#;
end record
with Volatile_Full_Access, Object_Size => 32,
Bit_Order => System.Low_Order_First;
for CR2_Register_1 use record
CCPC at 0 range 0 .. 0;
Reserved_1_1 at 0 range 1 .. 1;
CCUS at 0 range 2 .. 2;
CCDS at 0 range 3 .. 3;
Reserved_4_7 at 0 range 4 .. 7;
OIS1 at 0 range 8 .. 8;
OIS1N at 0 range 9 .. 9;
Reserved_10_31 at 0 range 10 .. 31;
end record;
-- DMA/Interrupt enable register
type DIER_Register_1 is record
-- Update interrupt enable
UIE : Boolean := False;
-- Capture/Compare 1 interrupt enable
CC1IE : Boolean := False;
-- unspecified
Reserved_2_4 : STM32_SVD.UInt3 := 16#0#;
-- COM interrupt enable
COMIE : Boolean := False;
-- unspecified
Reserved_6_6 : STM32_SVD.Bit := 16#0#;
-- Break interrupt enable
BIE : Boolean := False;
-- Update DMA request enable
UDE : Boolean := False;
-- Capture/Compare 1 DMA request enable
CC1DE : Boolean := False;
-- unspecified
Reserved_10_12 : STM32_SVD.UInt3 := 16#0#;
-- COM DMA request enable
COMDE : Boolean := False;
-- unspecified
Reserved_14_31 : STM32_SVD.UInt18 := 16#0#;
end record
with Volatile_Full_Access, Object_Size => 32,
Bit_Order => System.Low_Order_First;
for DIER_Register_1 use record
UIE at 0 range 0 .. 0;
CC1IE at 0 range 1 .. 1;
Reserved_2_4 at 0 range 2 .. 4;
COMIE at 0 range 5 .. 5;
Reserved_6_6 at 0 range 6 .. 6;
BIE at 0 range 7 .. 7;
UDE at 0 range 8 .. 8;
CC1DE at 0 range 9 .. 9;
Reserved_10_12 at 0 range 10 .. 12;
COMDE at 0 range 13 .. 13;
Reserved_14_31 at 0 range 14 .. 31;
end record;
-- status register
type SR_Register_1 is record
-- Update interrupt flag
UIF : Boolean := False;
-- Capture/compare 1 interrupt flag
CC1IF : Boolean := False;
-- unspecified
Reserved_2_4 : STM32_SVD.UInt3 := 16#0#;
-- COM interrupt flag
COMIF : Boolean := False;
-- unspecified
Reserved_6_6 : STM32_SVD.Bit := 16#0#;
-- Break interrupt flag
BIF : Boolean := False;
-- unspecified
Reserved_8_8 : STM32_SVD.Bit := 16#0#;
-- Capture/Compare 1 overcapture flag
CC1OF : Boolean := False;
-- unspecified
Reserved_10_31 : STM32_SVD.UInt22 := 16#0#;
end record
with Volatile_Full_Access, Object_Size => 32,
Bit_Order => System.Low_Order_First;
for SR_Register_1 use record
UIF at 0 range 0 .. 0;
CC1IF at 0 range 1 .. 1;
Reserved_2_4 at 0 range 2 .. 4;
COMIF at 0 range 5 .. 5;
Reserved_6_6 at 0 range 6 .. 6;
BIF at 0 range 7 .. 7;
Reserved_8_8 at 0 range 8 .. 8;
CC1OF at 0 range 9 .. 9;
Reserved_10_31 at 0 range 10 .. 31;
end record;
-- event generation register
type EGR_Register_1 is record
-- Write-only. Update generation
UG : Boolean := False;
-- Write-only. Capture/compare 1 generation
CC1G : Boolean := False;
-- unspecified
Reserved_2_4 : STM32_SVD.UInt3 := 16#0#;
-- Write-only. Capture/Compare control update generation
COMG : Boolean := False;
-- unspecified
Reserved_6_6 : STM32_SVD.Bit := 16#0#;
-- Write-only. Break generation
BG : Boolean := False;
-- unspecified
Reserved_8_31 : STM32_SVD.UInt24 := 16#0#;
end record
with Volatile_Full_Access, Object_Size => 32,
Bit_Order => System.Low_Order_First;
for EGR_Register_1 use record
UG at 0 range 0 .. 0;
CC1G at 0 range 1 .. 1;
Reserved_2_4 at 0 range 2 .. 4;
COMG at 0 range 5 .. 5;
Reserved_6_6 at 0 range 6 .. 6;
BG at 0 range 7 .. 7;
Reserved_8_31 at 0 range 8 .. 31;
end record;
-- capture/compare mode register (output mode)
type CCMR1_Output_Register_1 is record
-- Capture/Compare 1 selection
CC1S : CCMR1_Output_CC1S_Field := 16#0#;
-- Output Compare 1 fast enable
OC1FE : Boolean := False;
-- Output Compare 1 preload enable
OC1PE : Boolean := False;
-- Output Compare 1 mode
OC1M : CCMR1_Output_OC1M_Field := 16#0#;
-- unspecified
Reserved_7_15 : STM32_SVD.UInt9 := 16#0#;
-- Output Compare 1 mode
OC1M_3 : Boolean := False;
-- unspecified
Reserved_17_31 : STM32_SVD.UInt15 := 16#0#;
end record
with Volatile_Full_Access, Object_Size => 32,
Bit_Order => System.Low_Order_First;
for CCMR1_Output_Register_1 use record
CC1S at 0 range 0 .. 1;
OC1FE at 0 range 2 .. 2;
OC1PE at 0 range 3 .. 3;
OC1M at 0 range 4 .. 6;
Reserved_7_15 at 0 range 7 .. 15;
OC1M_3 at 0 range 16 .. 16;
Reserved_17_31 at 0 range 17 .. 31;
end record;
-- capture/compare mode register 1 (input mode)
type CCMR1_Input_Register_1 is record
-- Capture/Compare 1 selection
CC1S : CCMR1_Input_CC1S_Field := 16#0#;
-- Input capture 1 prescaler
IC1PSC : CCMR1_Input_IC1PSC_Field := 16#0#;
-- Input capture 1 filter
IC1F : CCMR1_Input_IC1F_Field := 16#0#;
-- unspecified
Reserved_8_31 : STM32_SVD.UInt24 := 16#0#;
end record
with Volatile_Full_Access, Object_Size => 32,
Bit_Order => System.Low_Order_First;
for CCMR1_Input_Register_1 use record
CC1S at 0 range 0 .. 1;
IC1PSC at 0 range 2 .. 3;
IC1F at 0 range 4 .. 7;
Reserved_8_31 at 0 range 8 .. 31;
end record;
-- capture/compare enable register
type CCER_Register_1 is record
-- Capture/Compare 1 output enable
CC1E : Boolean := False;
-- Capture/Compare 1 output Polarity
CC1P : Boolean := False;
-- Capture/Compare 1 complementary output enable
CC1NE : Boolean := False;
-- Capture/Compare 1 output Polarity
CC1NP : Boolean := False;
-- unspecified
Reserved_4_31 : STM32_SVD.UInt28 := 16#0#;
end record
with Volatile_Full_Access, Object_Size => 32,
Bit_Order => System.Low_Order_First;
for CCER_Register_1 use record
CC1E at 0 range 0 .. 0;
CC1P at 0 range 1 .. 1;
CC1NE at 0 range 2 .. 2;
CC1NP at 0 range 3 .. 3;
Reserved_4_31 at 0 range 4 .. 31;
end record;
-- TIM16 alternate function register 1
type TIM16_AF1_Register is record
-- BRK BKIN input enable
BKINE : Boolean := False;
-- BRK COMP1 enable
BKCMP1E : Boolean := False;
-- BRK COMP2 enable
BKCMP2E : Boolean := False;
-- unspecified
Reserved_3_7 : STM32_SVD.UInt5 := 16#0#;
-- BRK dfsdm1_break[1] enable
BKDFBK1E : Boolean := False;
-- BRK BKIN input polarity
BKINP : Boolean := False;
-- BRK COMP1 input polarity
BKCMP1P : Boolean := False;
-- BRK COMP2 input polarity
BKCMP2P : Boolean := False;
-- unspecified
Reserved_12_31 : STM32_SVD.UInt20 := 16#0#;
end record
with Volatile_Full_Access, Object_Size => 32,
Bit_Order => System.Low_Order_First;
for TIM16_AF1_Register use record
BKINE at 0 range 0 .. 0;
BKCMP1E at 0 range 1 .. 1;
BKCMP2E at 0 range 2 .. 2;
Reserved_3_7 at 0 range 3 .. 7;
BKDFBK1E at 0 range 8 .. 8;
BKINP at 0 range 9 .. 9;
BKCMP1P at 0 range 10 .. 10;
BKCMP2P at 0 range 11 .. 11;
Reserved_12_31 at 0 range 12 .. 31;
end record;
subtype TIM16_TISEL_TI1SEL_Field is STM32_SVD.UInt4;
-- TIM16 input selection register
type TIM16_TISEL_Register is record
-- selects TI1[0] to TI1[15] input
TI1SEL : TIM16_TISEL_TI1SEL_Field := 16#0#;
-- unspecified
Reserved_4_31 : STM32_SVD.UInt28 := 16#0#;
end record
with Volatile_Full_Access, Object_Size => 32,
Bit_Order => System.Low_Order_First;
for TIM16_TISEL_Register use record
TI1SEL at 0 range 0 .. 3;
Reserved_4_31 at 0 range 4 .. 31;
end record;
-- TIM17 alternate function register 1
type TIM17_AF1_Register is record
-- BRK BKIN input enable
BKINE : Boolean := False;
-- BRK COMP1 enable
BKCMP1E : Boolean := False;
-- BRK COMP2 enable
BKCMP2E : Boolean := False;
-- unspecified
Reserved_3_7 : STM32_SVD.UInt5 := 16#0#;
-- BRK dfsdm1_break[1] enable
BKDFBK1E : Boolean := False;
-- BRK BKIN input polarity
BKINP : Boolean := False;
-- BRK COMP1 input polarity
BKCMP1P : Boolean := False;
-- BRK COMP2 input polarity
BKCMP2P : Boolean := False;
-- unspecified
Reserved_12_31 : STM32_SVD.UInt20 := 16#0#;
end record
with Volatile_Full_Access, Object_Size => 32,
Bit_Order => System.Low_Order_First;
for TIM17_AF1_Register use record
BKINE at 0 range 0 .. 0;
BKCMP1E at 0 range 1 .. 1;
BKCMP2E at 0 range 2 .. 2;
Reserved_3_7 at 0 range 3 .. 7;
BKDFBK1E at 0 range 8 .. 8;
BKINP at 0 range 9 .. 9;
BKCMP1P at 0 range 10 .. 10;
BKCMP2P at 0 range 11 .. 11;
Reserved_12_31 at 0 range 12 .. 31;
end record;
subtype TIM17_TISEL_TI1SEL_Field is STM32_SVD.UInt4;
-- TIM17 input selection register
type TIM17_TISEL_Register is record
-- selects TI1[0] to TI1[15] input
TI1SEL : TIM17_TISEL_TI1SEL_Field := 16#0#;
-- unspecified
Reserved_4_31 : STM32_SVD.UInt28 := 16#0#;
end record
with Volatile_Full_Access, Object_Size => 32,
Bit_Order => System.Low_Order_First;
for TIM17_TISEL_Register use record
TI1SEL at 0 range 0 .. 3;
Reserved_4_31 at 0 range 4 .. 31;
end record;
-----------------
-- Peripherals --
-----------------
type TIM15_Disc is
(Output,
Input);
-- General purpose timers
type TIM15_Peripheral
(Discriminent : TIM15_Disc := Output)
is record
-- control register 1
CR1 : aliased CR1_Register;
-- control register 2
CR2 : aliased CR2_Register;
-- slave mode control register
SMCR : aliased SMCR_Register;
-- DMA/Interrupt enable register
DIER : aliased DIER_Register;
-- status register
SR : aliased SR_Register;
-- event generation register
EGR : aliased EGR_Register;
-- capture/compare enable register
CCER : aliased CCER_Register;
-- counter
CNT : aliased CNT_Register;
-- prescaler
PSC : aliased PSC_Register;
-- auto-reload register
ARR : aliased ARR_Register;
-- repetition counter register
RCR : aliased RCR_Register;
-- capture/compare register 1
CCR1 : aliased CCR1_Register;
-- capture/compare register 2
CCR2 : aliased CCR2_Register;
-- break and dead-time register
BDTR : aliased BDTR_Register;
-- DMA control register
DCR : aliased DCR_Register;
-- DMA address for full transfer
DMAR : aliased DMAR_Register;
-- TIM15 alternate fdfsdm1_breakon register 1
AF1 : aliased AF1_Register;
-- TIM15 input selection register
TISEL : aliased TISEL_Register;
case Discriminent is
when Output =>
-- capture/compare mode register (output mode)
CCMR1_Output : aliased CCMR1_Output_Register;
when Input =>
-- capture/compare mode register 1 (input mode)
CCMR1_Input : aliased CCMR1_Input_Register;
end case;
end record
with Unchecked_Union, Volatile;
for TIM15_Peripheral use record
CR1 at 16#0# range 0 .. 31;
CR2 at 16#4# range 0 .. 31;
SMCR at 16#8# range 0 .. 31;
DIER at 16#C# range 0 .. 31;
SR at 16#10# range 0 .. 31;
EGR at 16#14# range 0 .. 31;
CCER at 16#20# range 0 .. 31;
CNT at 16#24# range 0 .. 31;
PSC at 16#28# range 0 .. 31;
ARR at 16#2C# range 0 .. 31;
RCR at 16#30# range 0 .. 31;
CCR1 at 16#34# range 0 .. 31;
CCR2 at 16#38# range 0 .. 31;
BDTR at 16#44# range 0 .. 31;
DCR at 16#48# range 0 .. 31;
DMAR at 16#4C# range 0 .. 31;
AF1 at 16#60# range 0 .. 31;
TISEL at 16#68# range 0 .. 31;
CCMR1_Output at 16#18# range 0 .. 31;
CCMR1_Input at 16#18# range 0 .. 31;
end record;
-- General purpose timers
TIM15_Periph : aliased TIM15_Peripheral
with Import, Address => TIM15_Base;
type TIM16_Disc is
(Output,
Input);
-- General-purpose-timers
type TIM16_Peripheral
(Discriminent : TIM16_Disc := Output)
is record
-- control register 1
CR1 : aliased CR1_Register;
-- control register 2
CR2 : aliased CR2_Register_1;
-- DMA/Interrupt enable register
DIER : aliased DIER_Register_1;
-- status register
SR : aliased SR_Register_1;
-- event generation register
EGR : aliased EGR_Register_1;
-- capture/compare enable register
CCER : aliased CCER_Register_1;
-- counter
CNT : aliased CNT_Register;
-- prescaler
PSC : aliased PSC_Register;
-- auto-reload register
ARR : aliased ARR_Register;
-- repetition counter register
RCR : aliased RCR_Register;
-- capture/compare register 1
CCR1 : aliased CCR1_Register;
-- break and dead-time register
BDTR : aliased BDTR_Register;
-- DMA control register
DCR : aliased DCR_Register;
-- DMA address for full transfer
DMAR : aliased DMAR_Register;
-- TIM16 alternate function register 1
TIM16_AF1 : aliased TIM16_AF1_Register;
-- TIM16 input selection register
TIM16_TISEL : aliased TIM16_TISEL_Register;
case Discriminent is
when Output =>
-- capture/compare mode register (output mode)
CCMR1_Output : aliased CCMR1_Output_Register_1;
when Input =>
-- capture/compare mode register 1 (input mode)
CCMR1_Input : aliased CCMR1_Input_Register_1;
end case;
end record
with Unchecked_Union, Volatile;
for TIM16_Peripheral use record
CR1 at 16#0# range 0 .. 31;
CR2 at 16#4# range 0 .. 31;
DIER at 16#C# range 0 .. 31;
SR at 16#10# range 0 .. 31;
EGR at 16#14# range 0 .. 31;
CCER at 16#20# range 0 .. 31;
CNT at 16#24# range 0 .. 31;
PSC at 16#28# range 0 .. 31;
ARR at 16#2C# range 0 .. 31;
RCR at 16#30# range 0 .. 31;
CCR1 at 16#34# range 0 .. 31;
BDTR at 16#44# range 0 .. 31;
DCR at 16#48# range 0 .. 31;
DMAR at 16#4C# range 0 .. 31;
TIM16_AF1 at 16#60# range 0 .. 31;
TIM16_TISEL at 16#68# range 0 .. 31;
CCMR1_Output at 16#18# range 0 .. 31;
CCMR1_Input at 16#18# range 0 .. 31;
end record;
-- General-purpose-timers
TIM16_Periph : aliased TIM16_Peripheral
with Import, Address => TIM16_Base;
type TIM17_Disc is
(Output,
Input);
-- General-purpose-timers
type TIM17_Peripheral
(Discriminent : TIM17_Disc := Output)
is record
-- control register 1
CR1 : aliased CR1_Register;
-- control register 2
CR2 : aliased CR2_Register_1;
-- DMA/Interrupt enable register
DIER : aliased DIER_Register_1;
-- status register
SR : aliased SR_Register_1;
-- event generation register
EGR : aliased EGR_Register_1;
-- capture/compare enable register
CCER : aliased CCER_Register_1;
-- counter
CNT : aliased CNT_Register;
-- prescaler
PSC : aliased PSC_Register;
-- auto-reload register
ARR : aliased ARR_Register;
-- repetition counter register
RCR : aliased RCR_Register;
-- capture/compare register 1
CCR1 : aliased CCR1_Register;
-- break and dead-time register
BDTR : aliased BDTR_Register;
-- DMA control register
DCR : aliased DCR_Register;
-- DMA address for full transfer
DMAR : aliased DMAR_Register;
-- TIM17 alternate function register 1
TIM17_AF1 : aliased TIM17_AF1_Register;
-- TIM17 input selection register
TIM17_TISEL : aliased TIM17_TISEL_Register;
case Discriminent is
when Output =>
-- capture/compare mode register (output mode)
CCMR1_Output : aliased CCMR1_Output_Register_1;
when Input =>
-- capture/compare mode register 1 (input mode)
CCMR1_Input : aliased CCMR1_Input_Register_1;
end case;
end record
with Unchecked_Union, Volatile;
for TIM17_Peripheral use record
CR1 at 16#0# range 0 .. 31;
CR2 at 16#4# range 0 .. 31;
DIER at 16#C# range 0 .. 31;
SR at 16#10# range 0 .. 31;
EGR at 16#14# range 0 .. 31;
CCER at 16#20# range 0 .. 31;
CNT at 16#24# range 0 .. 31;
PSC at 16#28# range 0 .. 31;
ARR at 16#2C# range 0 .. 31;
RCR at 16#30# range 0 .. 31;
CCR1 at 16#34# range 0 .. 31;
BDTR at 16#44# range 0 .. 31;
DCR at 16#48# range 0 .. 31;
DMAR at 16#4C# range 0 .. 31;
TIM17_AF1 at 16#60# range 0 .. 31;
TIM17_TISEL at 16#68# range 0 .. 31;
CCMR1_Output at 16#18# range 0 .. 31;
CCMR1_Input at 16#18# range 0 .. 31;
end record;
-- General-purpose-timers
TIM17_Periph : aliased TIM17_Peripheral
with Import, Address => TIM17_Base;
end STM32_SVD.TIMs;
|
twdroeger/ada-awa | Ada | 27,807 | adb | -----------------------------------------------------------------------
-- AWA.Comments.Models -- AWA.Comments.Models
-----------------------------------------------------------------------
-- File generated by ada-gen DO NOT MODIFY
-- Template used: templates/model/package-body.xhtml
-- Ada Generator: https://ada-gen.googlecode.com/svn/trunk Revision 1095
-----------------------------------------------------------------------
-- Copyright (C) 2019 Stephane Carrez
-- Written by Stephane Carrez ([email protected])
--
-- Licensed under the Apache License, Version 2.0 (the "License");
-- you may not use this file except in compliance with the License.
-- You may obtain a copy of the License at
--
-- http://www.apache.org/licenses/LICENSE-2.0
--
-- Unless required by applicable law or agreed to in writing, software
-- distributed under the License is distributed on an "AS IS" BASIS,
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-- See the License for the specific language governing permissions and
-- limitations under the License.
-----------------------------------------------------------------------
with Ada.Unchecked_Deallocation;
with Util.Beans.Objects.Time;
with ASF.Events.Faces.Actions;
package body AWA.Comments.Models is
use type ADO.Objects.Object_Record_Access;
use type ADO.Objects.Object_Ref;
pragma Warnings (Off, "formal parameter * is not referenced");
function Comment_Key (Id : in ADO.Identifier) return ADO.Objects.Object_Key is
Result : ADO.Objects.Object_Key (Of_Type => ADO.Objects.KEY_INTEGER,
Of_Class => COMMENT_DEF'Access);
begin
ADO.Objects.Set_Value (Result, Id);
return Result;
end Comment_Key;
function Comment_Key (Id : in String) return ADO.Objects.Object_Key is
Result : ADO.Objects.Object_Key (Of_Type => ADO.Objects.KEY_INTEGER,
Of_Class => COMMENT_DEF'Access);
begin
ADO.Objects.Set_Value (Result, Id);
return Result;
end Comment_Key;
function "=" (Left, Right : Comment_Ref'Class) return Boolean is
begin
return ADO.Objects.Object_Ref'Class (Left) = ADO.Objects.Object_Ref'Class (Right);
end "=";
procedure Set_Field (Object : in out Comment_Ref'Class;
Impl : out Comment_Access) is
Result : ADO.Objects.Object_Record_Access;
begin
Object.Prepare_Modify (Result);
Impl := Comment_Impl (Result.all)'Access;
end Set_Field;
-- Internal method to allocate the Object_Record instance
procedure Allocate (Object : in out Comment_Ref) is
Impl : Comment_Access;
begin
Impl := new Comment_Impl;
Impl.Create_Date := ADO.DEFAULT_TIME;
Impl.Entity_Id := ADO.NO_IDENTIFIER;
Impl.Version := 0;
Impl.Entity_Type := 0;
Impl.Status := AWA.Comments.Models.Status_Type'First;
Impl.Format := AWA.Comments.Models.Format_Type'First;
ADO.Objects.Set_Object (Object, Impl.all'Access);
end Allocate;
-- ----------------------------------------
-- Data object: Comment
-- ----------------------------------------
procedure Set_Create_Date (Object : in out Comment_Ref;
Value : in Ada.Calendar.Time) is
Impl : Comment_Access;
begin
Set_Field (Object, Impl);
ADO.Objects.Set_Field_Time (Impl.all, 1, Impl.Create_Date, Value);
end Set_Create_Date;
function Get_Create_Date (Object : in Comment_Ref)
return Ada.Calendar.Time is
Impl : constant Comment_Access
:= Comment_Impl (Object.Get_Load_Object.all)'Access;
begin
return Impl.Create_Date;
end Get_Create_Date;
procedure Set_Message (Object : in out Comment_Ref;
Value : in String) is
Impl : Comment_Access;
begin
Set_Field (Object, Impl);
ADO.Audits.Set_Field_String (Impl.all, 2, Impl.Message, Value);
end Set_Message;
procedure Set_Message (Object : in out Comment_Ref;
Value : in Ada.Strings.Unbounded.Unbounded_String) is
Impl : Comment_Access;
begin
Set_Field (Object, Impl);
ADO.Audits.Set_Field_Unbounded_String (Impl.all, 2, Impl.Message, Value);
end Set_Message;
function Get_Message (Object : in Comment_Ref)
return String is
begin
return Ada.Strings.Unbounded.To_String (Object.Get_Message);
end Get_Message;
function Get_Message (Object : in Comment_Ref)
return Ada.Strings.Unbounded.Unbounded_String is
Impl : constant Comment_Access
:= Comment_Impl (Object.Get_Load_Object.all)'Access;
begin
return Impl.Message;
end Get_Message;
procedure Set_Entity_Id (Object : in out Comment_Ref;
Value : in ADO.Identifier) is
Impl : Comment_Access;
begin
Set_Field (Object, Impl);
ADO.Objects.Set_Field_Identifier (Impl.all, 3, Impl.Entity_Id, Value);
end Set_Entity_Id;
function Get_Entity_Id (Object : in Comment_Ref)
return ADO.Identifier is
Impl : constant Comment_Access
:= Comment_Impl (Object.Get_Load_Object.all)'Access;
begin
return Impl.Entity_Id;
end Get_Entity_Id;
procedure Set_Id (Object : in out Comment_Ref;
Value : in ADO.Identifier) is
Impl : Comment_Access;
begin
Set_Field (Object, Impl);
ADO.Objects.Set_Field_Key_Value (Impl.all, 4, Value);
end Set_Id;
function Get_Id (Object : in Comment_Ref)
return ADO.Identifier is
Impl : constant Comment_Access
:= Comment_Impl (Object.Get_Object.all)'Access;
begin
return Impl.Get_Key_Value;
end Get_Id;
function Get_Version (Object : in Comment_Ref)
return Integer is
Impl : constant Comment_Access
:= Comment_Impl (Object.Get_Load_Object.all)'Access;
begin
return Impl.Version;
end Get_Version;
procedure Set_Entity_Type (Object : in out Comment_Ref;
Value : in ADO.Entity_Type) is
Impl : Comment_Access;
begin
Set_Field (Object, Impl);
ADO.Objects.Set_Field_Entity_Type (Impl.all, 6, Impl.Entity_Type, Value);
end Set_Entity_Type;
function Get_Entity_Type (Object : in Comment_Ref)
return ADO.Entity_Type is
Impl : constant Comment_Access
:= Comment_Impl (Object.Get_Load_Object.all)'Access;
begin
return Impl.Entity_Type;
end Get_Entity_Type;
procedure Set_Status (Object : in out Comment_Ref;
Value : in AWA.Comments.Models.Status_Type) is
procedure Set_Field_Enum is
new ADO.Audits.Set_Field_Operation (Status_Type,
Status_Type_Objects.To_Object);
Impl : Comment_Access;
begin
Set_Field (Object, Impl);
Set_Field_Enum (Impl.all, 7, Impl.Status, Value);
end Set_Status;
function Get_Status (Object : in Comment_Ref)
return AWA.Comments.Models.Status_Type is
Impl : constant Comment_Access
:= Comment_Impl (Object.Get_Load_Object.all)'Access;
begin
return Impl.Status;
end Get_Status;
procedure Set_Format (Object : in out Comment_Ref;
Value : in AWA.Comments.Models.Format_Type) is
procedure Set_Field_Enum is
new ADO.Audits.Set_Field_Operation (Format_Type,
Format_Type_Objects.To_Object);
Impl : Comment_Access;
begin
Set_Field (Object, Impl);
Set_Field_Enum (Impl.all, 8, Impl.Format, Value);
end Set_Format;
function Get_Format (Object : in Comment_Ref)
return AWA.Comments.Models.Format_Type is
Impl : constant Comment_Access
:= Comment_Impl (Object.Get_Load_Object.all)'Access;
begin
return Impl.Format;
end Get_Format;
procedure Set_Author (Object : in out Comment_Ref;
Value : in AWA.Users.Models.User_Ref'Class) is
Impl : Comment_Access;
begin
Set_Field (Object, Impl);
ADO.Objects.Set_Field_Object (Impl.all, 9, Impl.Author, Value);
end Set_Author;
function Get_Author (Object : in Comment_Ref)
return AWA.Users.Models.User_Ref'Class is
Impl : constant Comment_Access
:= Comment_Impl (Object.Get_Load_Object.all)'Access;
begin
return Impl.Author;
end Get_Author;
-- Copy of the object.
procedure Copy (Object : in Comment_Ref;
Into : in out Comment_Ref) is
Result : Comment_Ref;
begin
if not Object.Is_Null then
declare
Impl : constant Comment_Access
:= Comment_Impl (Object.Get_Load_Object.all)'Access;
Copy : constant Comment_Access
:= new Comment_Impl;
begin
ADO.Objects.Set_Object (Result, Copy.all'Access);
Copy.Copy (Impl.all);
Copy.Create_Date := Impl.Create_Date;
Copy.Message := Impl.Message;
Copy.Entity_Id := Impl.Entity_Id;
Copy.Version := Impl.Version;
Copy.Entity_Type := Impl.Entity_Type;
Copy.Status := Impl.Status;
Copy.Format := Impl.Format;
Copy.Author := Impl.Author;
end;
end if;
Into := Result;
end Copy;
procedure Find (Object : in out Comment_Ref;
Session : in out ADO.Sessions.Session'Class;
Query : in ADO.SQL.Query'Class;
Found : out Boolean) is
Impl : constant Comment_Access := new Comment_Impl;
begin
Impl.Find (Session, Query, Found);
if Found then
ADO.Objects.Set_Object (Object, Impl.all'Access);
else
ADO.Objects.Set_Object (Object, null);
Destroy (Impl);
end if;
end Find;
procedure Load (Object : in out Comment_Ref;
Session : in out ADO.Sessions.Session'Class;
Id : in ADO.Identifier) is
Impl : constant Comment_Access := new Comment_Impl;
Found : Boolean;
Query : ADO.SQL.Query;
begin
Query.Bind_Param (Position => 1, Value => Id);
Query.Set_Filter ("id = ?");
Impl.Find (Session, Query, Found);
if not Found then
Destroy (Impl);
raise ADO.Objects.NOT_FOUND;
end if;
ADO.Objects.Set_Object (Object, Impl.all'Access);
end Load;
procedure Load (Object : in out Comment_Ref;
Session : in out ADO.Sessions.Session'Class;
Id : in ADO.Identifier;
Found : out Boolean) is
Impl : constant Comment_Access := new Comment_Impl;
Query : ADO.SQL.Query;
begin
Query.Bind_Param (Position => 1, Value => Id);
Query.Set_Filter ("id = ?");
Impl.Find (Session, Query, Found);
if not Found then
Destroy (Impl);
else
ADO.Objects.Set_Object (Object, Impl.all'Access);
end if;
end Load;
procedure Save (Object : in out Comment_Ref;
Session : in out ADO.Sessions.Master_Session'Class) is
Impl : ADO.Objects.Object_Record_Access := Object.Get_Object;
begin
if Impl = null then
Impl := new Comment_Impl;
ADO.Objects.Set_Object (Object, Impl);
end if;
if not ADO.Objects.Is_Created (Impl.all) then
Impl.Create (Session);
else
Impl.Save (Session);
end if;
end Save;
procedure Delete (Object : in out Comment_Ref;
Session : in out ADO.Sessions.Master_Session'Class) is
Impl : constant ADO.Objects.Object_Record_Access := Object.Get_Object;
begin
if Impl /= null then
Impl.Delete (Session);
end if;
end Delete;
-- --------------------
-- Free the object
-- --------------------
procedure Destroy (Object : access Comment_Impl) is
type Comment_Impl_Ptr is access all Comment_Impl;
procedure Unchecked_Free is new Ada.Unchecked_Deallocation
(Comment_Impl, Comment_Impl_Ptr);
pragma Warnings (Off, "*redundant conversion*");
Ptr : Comment_Impl_Ptr := Comment_Impl (Object.all)'Access;
pragma Warnings (On, "*redundant conversion*");
begin
Unchecked_Free (Ptr);
end Destroy;
procedure Find (Object : in out Comment_Impl;
Session : in out ADO.Sessions.Session'Class;
Query : in ADO.SQL.Query'Class;
Found : out Boolean) is
Stmt : ADO.Statements.Query_Statement
:= Session.Create_Statement (Query, COMMENT_DEF'Access);
begin
Stmt.Execute;
if Stmt.Has_Elements then
Object.Load (Stmt, Session);
Stmt.Next;
Found := not Stmt.Has_Elements;
else
Found := False;
end if;
end Find;
overriding
procedure Load (Object : in out Comment_Impl;
Session : in out ADO.Sessions.Session'Class) is
Found : Boolean;
Query : ADO.SQL.Query;
Id : constant ADO.Identifier := Object.Get_Key_Value;
begin
Query.Bind_Param (Position => 1, Value => Id);
Query.Set_Filter ("id = ?");
Object.Find (Session, Query, Found);
if not Found then
raise ADO.Objects.NOT_FOUND;
end if;
end Load;
procedure Save (Object : in out Comment_Impl;
Session : in out ADO.Sessions.Master_Session'Class) is
Stmt : ADO.Statements.Update_Statement
:= Session.Create_Statement (COMMENT_DEF'Access);
begin
if Object.Is_Modified (1) then
Stmt.Save_Field (Name => COL_0_1_NAME, -- create_date
Value => Object.Create_Date);
Object.Clear_Modified (1);
end if;
if Object.Is_Modified (2) then
Stmt.Save_Field (Name => COL_1_1_NAME, -- message
Value => Object.Message);
Object.Clear_Modified (2);
end if;
if Object.Is_Modified (4) then
Stmt.Save_Field (Name => COL_3_1_NAME, -- id
Value => Object.Get_Key);
Object.Clear_Modified (4);
end if;
if Object.Is_Modified (7) then
Stmt.Save_Field (Name => COL_6_1_NAME, -- status
Value => Integer (Status_Type'Pos (Object.Status)));
Object.Clear_Modified (7);
end if;
if Object.Is_Modified (8) then
Stmt.Save_Field (Name => COL_7_1_NAME, -- format
Value => Integer (Format_Type'Pos (Object.Format)));
Object.Clear_Modified (8);
end if;
if Object.Is_Modified (9) then
Stmt.Save_Field (Name => COL_8_1_NAME, -- author_id
Value => Object.Author);
Object.Clear_Modified (9);
end if;
if Stmt.Has_Save_Fields then
Object.Version := Object.Version + 1;
Stmt.Save_Field (Name => "version",
Value => Object.Version);
Stmt.Set_Filter (Filter => "id = ? and version = ?");
Stmt.Add_Param (Value => Object.Get_Key);
Stmt.Add_Param (Value => Object.Version - 1);
declare
Result : Integer;
begin
Stmt.Execute (Result);
if Result /= 1 then
if Result /= 0 then
raise ADO.Objects.UPDATE_ERROR;
else
raise ADO.Objects.LAZY_LOCK;
end if;
end if;
ADO.Audits.Save (Object, Session);
end;
end if;
end Save;
procedure Create (Object : in out Comment_Impl;
Session : in out ADO.Sessions.Master_Session'Class) is
Query : ADO.Statements.Insert_Statement
:= Session.Create_Statement (COMMENT_DEF'Access);
Result : Integer;
begin
Object.Version := 1;
Query.Save_Field (Name => COL_0_1_NAME, -- create_date
Value => Object.Create_Date);
Query.Save_Field (Name => COL_1_1_NAME, -- message
Value => Object.Message);
Query.Save_Field (Name => COL_2_1_NAME, -- entity_id
Value => Object.Entity_Id);
Session.Allocate (Id => Object);
Query.Save_Field (Name => COL_3_1_NAME, -- id
Value => Object.Get_Key);
Query.Save_Field (Name => COL_4_1_NAME, -- version
Value => Object.Version);
Query.Save_Field (Name => COL_5_1_NAME, -- entity_type
Value => Object.Entity_Type);
Query.Save_Field (Name => COL_6_1_NAME, -- status
Value => Integer (Status_Type'Pos (Object.Status)));
Query.Save_Field (Name => COL_7_1_NAME, -- format
Value => Integer (Format_Type'Pos (Object.Format)));
Query.Save_Field (Name => COL_8_1_NAME, -- author_id
Value => Object.Author);
Query.Execute (Result);
if Result /= 1 then
raise ADO.Objects.INSERT_ERROR;
end if;
ADO.Objects.Set_Created (Object);
ADO.Audits.Save (Object, Session);
end Create;
procedure Delete (Object : in out Comment_Impl;
Session : in out ADO.Sessions.Master_Session'Class) is
Stmt : ADO.Statements.Delete_Statement
:= Session.Create_Statement (COMMENT_DEF'Access);
begin
Stmt.Set_Filter (Filter => "id = ?");
Stmt.Add_Param (Value => Object.Get_Key);
Stmt.Execute;
end Delete;
-- ------------------------------
-- Get the bean attribute identified by the name.
-- ------------------------------
overriding
function Get_Value (From : in Comment_Ref;
Name : in String) return Util.Beans.Objects.Object is
Obj : ADO.Objects.Object_Record_Access;
Impl : access Comment_Impl;
begin
if From.Is_Null then
return Util.Beans.Objects.Null_Object;
end if;
Obj := From.Get_Load_Object;
Impl := Comment_Impl (Obj.all)'Access;
if Name = "create_date" then
return Util.Beans.Objects.Time.To_Object (Impl.Create_Date);
elsif Name = "message" then
return Util.Beans.Objects.To_Object (Impl.Message);
elsif Name = "entity_id" then
return Util.Beans.Objects.To_Object (Long_Long_Integer (Impl.Entity_Id));
elsif Name = "id" then
return ADO.Objects.To_Object (Impl.Get_Key);
elsif Name = "entity_type" then
return Util.Beans.Objects.To_Object (Long_Long_Integer (Impl.Entity_Type));
elsif Name = "status" then
return AWA.Comments.Models.Status_Type_Objects.To_Object (Impl.Status);
elsif Name = "format" then
return AWA.Comments.Models.Format_Type_Objects.To_Object (Impl.Format);
end if;
return Util.Beans.Objects.Null_Object;
end Get_Value;
-- ------------------------------
-- Load the object from current iterator position
-- ------------------------------
procedure Load (Object : in out Comment_Impl;
Stmt : in out ADO.Statements.Query_Statement'Class;
Session : in out ADO.Sessions.Session'Class) is
begin
Object.Create_Date := Stmt.Get_Time (0);
Object.Message := Stmt.Get_Unbounded_String (1);
Object.Entity_Id := Stmt.Get_Identifier (2);
Object.Set_Key_Value (Stmt.Get_Identifier (3));
Object.Entity_Type := ADO.Entity_Type (Stmt.Get_Integer (5));
Object.Status := Status_Type'Val (Stmt.Get_Integer (6));
Object.Format := Format_Type'Val (Stmt.Get_Integer (7));
if not Stmt.Is_Null (8) then
Object.Author.Set_Key_Value (Stmt.Get_Identifier (8), Session);
end if;
Object.Version := Stmt.Get_Integer (4);
ADO.Objects.Set_Created (Object);
end Load;
-- ------------------------------
-- Get the bean attribute identified by the name.
-- ------------------------------
overriding
function Get_Value (From : in Comment_Info;
Name : in String) return Util.Beans.Objects.Object is
begin
if Name = "id" then
return Util.Beans.Objects.To_Object (Long_Long_Integer (From.Id));
elsif Name = "author" then
return Util.Beans.Objects.To_Object (From.Author);
elsif Name = "email" then
return Util.Beans.Objects.To_Object (From.Email);
elsif Name = "date" then
return Util.Beans.Objects.Time.To_Object (From.Date);
elsif Name = "format" then
return AWA.Comments.Models.Format_Type_Objects.To_Object (From.Format);
elsif Name = "comment" then
return Util.Beans.Objects.To_Object (From.Comment);
elsif Name = "status" then
return AWA.Comments.Models.Status_Type_Objects.To_Object (From.Status);
end if;
return Util.Beans.Objects.Null_Object;
end Get_Value;
-- ------------------------------
-- Set the value identified by the name
-- ------------------------------
overriding
procedure Set_Value (Item : in out Comment_Info;
Name : in String;
Value : in Util.Beans.Objects.Object) is
begin
if Name = "id" then
Item.Id := ADO.Identifier (Util.Beans.Objects.To_Long_Long_Integer (Value));
elsif Name = "author" then
Item.Author := Util.Beans.Objects.To_Unbounded_String (Value);
elsif Name = "email" then
Item.Email := Util.Beans.Objects.To_Unbounded_String (Value);
elsif Name = "date" then
Item.Date := Util.Beans.Objects.Time.To_Time (Value);
elsif Name = "format" then
Item.Format := AWA.Comments.Models.Format_Type_Objects.To_Value (Value);
elsif Name = "comment" then
Item.Comment := Util.Beans.Objects.To_Unbounded_String (Value);
elsif Name = "status" then
Item.Status := AWA.Comments.Models.Status_Type_Objects.To_Value (Value);
end if;
end Set_Value;
-- --------------------
-- Run the query controlled by <b>Context</b> and append the list in <b>Object</b>.
-- --------------------
procedure List (Object : in out Comment_Info_List_Bean'Class;
Session : in out ADO.Sessions.Session'Class;
Context : in out ADO.Queries.Context'Class) is
begin
List (Object.List, Session, Context);
end List;
-- --------------------
-- The comment information.
-- --------------------
procedure List (Object : in out Comment_Info_Vector;
Session : in out ADO.Sessions.Session'Class;
Context : in out ADO.Queries.Context'Class) is
procedure Read (Into : in out Comment_Info);
Stmt : ADO.Statements.Query_Statement
:= Session.Create_Statement (Context);
Pos : Positive := 1;
procedure Read (Into : in out Comment_Info) is
begin
Into.Id := Stmt.Get_Identifier (0);
Into.Author := Stmt.Get_Unbounded_String (1);
Into.Email := Stmt.Get_Unbounded_String (2);
Into.Date := Stmt.Get_Time (3);
Into.Format := AWA.Comments.Models.Format_Type'Val (Stmt.Get_Integer (4));
Into.Comment := Stmt.Get_Unbounded_String (5);
Into.Status := AWA.Comments.Models.Status_Type'Val (Stmt.Get_Integer (6));
end Read;
begin
Stmt.Execute;
Comment_Info_Vectors.Clear (Object);
while Stmt.Has_Elements loop
Object.Insert_Space (Before => Pos);
Object.Update_Element (Index => Pos, Process => Read'Access);
Pos := Pos + 1;
Stmt.Next;
end loop;
end List;
procedure Op_Create (Bean : in out Comment_Bean;
Outcome : in out Ada.Strings.Unbounded.Unbounded_String);
procedure Op_Create (Bean : in out Comment_Bean;
Outcome : in out Ada.Strings.Unbounded.Unbounded_String) is
begin
Comment_Bean'Class (Bean).Create (Outcome);
end Op_Create;
package Binding_Comment_Bean_1 is
new ASF.Events.Faces.Actions.Action_Method.Bind (Bean => Comment_Bean,
Method => Op_Create,
Name => "create");
procedure Op_Delete (Bean : in out Comment_Bean;
Outcome : in out Ada.Strings.Unbounded.Unbounded_String);
procedure Op_Delete (Bean : in out Comment_Bean;
Outcome : in out Ada.Strings.Unbounded.Unbounded_String) is
begin
Comment_Bean'Class (Bean).Delete (Outcome);
end Op_Delete;
package Binding_Comment_Bean_2 is
new ASF.Events.Faces.Actions.Action_Method.Bind (Bean => Comment_Bean,
Method => Op_Delete,
Name => "delete");
procedure Op_Save (Bean : in out Comment_Bean;
Outcome : in out Ada.Strings.Unbounded.Unbounded_String);
procedure Op_Save (Bean : in out Comment_Bean;
Outcome : in out Ada.Strings.Unbounded.Unbounded_String) is
begin
Comment_Bean'Class (Bean).Save (Outcome);
end Op_Save;
package Binding_Comment_Bean_3 is
new ASF.Events.Faces.Actions.Action_Method.Bind (Bean => Comment_Bean,
Method => Op_Save,
Name => "save");
procedure Op_Publish (Bean : in out Comment_Bean;
Outcome : in out Ada.Strings.Unbounded.Unbounded_String);
procedure Op_Publish (Bean : in out Comment_Bean;
Outcome : in out Ada.Strings.Unbounded.Unbounded_String) is
begin
Comment_Bean'Class (Bean).Publish (Outcome);
end Op_Publish;
package Binding_Comment_Bean_4 is
new ASF.Events.Faces.Actions.Action_Method.Bind (Bean => Comment_Bean,
Method => Op_Publish,
Name => "publish");
Binding_Comment_Bean_Array : aliased constant Util.Beans.Methods.Method_Binding_Array
:= (1 => Binding_Comment_Bean_1.Proxy'Access,
2 => Binding_Comment_Bean_2.Proxy'Access,
3 => Binding_Comment_Bean_3.Proxy'Access,
4 => Binding_Comment_Bean_4.Proxy'Access
);
-- ------------------------------
-- This bean provides some methods that can be used in a Method_Expression.
-- ------------------------------
overriding
function Get_Method_Bindings (From : in Comment_Bean)
return Util.Beans.Methods.Method_Binding_Array_Access is
pragma Unreferenced (From);
begin
return Binding_Comment_Bean_Array'Access;
end Get_Method_Bindings;
-- ------------------------------
-- Set the value identified by the name
-- ------------------------------
overriding
procedure Set_Value (Item : in out Comment_Bean;
Name : in String;
Value : in Util.Beans.Objects.Object) is
begin
if Name = "create_date" then
Item.Set_Create_Date (Util.Beans.Objects.Time.To_Time (Value));
elsif Name = "message" then
Item.Set_Message (Util.Beans.Objects.To_String (Value));
elsif Name = "status" then
Item.Set_Status (Status_Type_Objects.To_Value (Value));
elsif Name = "format" then
Item.Set_Format (Format_Type_Objects.To_Value (Value));
end if;
end Set_Value;
end AWA.Comments.Models;
|
reznikmm/matreshka | Ada | 4,688 | 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_Style.Layout_Grid_Snap_To_Attributes is
------------
-- Create --
------------
overriding function Create
(Parameters : not null access Matreshka.DOM_Attributes.Attribute_L2_Parameters)
return Style_Layout_Grid_Snap_To_Attribute_Node is
begin
return Self : Style_Layout_Grid_Snap_To_Attribute_Node do
Matreshka.ODF_Style.Constructors.Initialize
(Self'Unchecked_Access,
Parameters.Document,
Matreshka.ODF_String_Constants.Style_Prefix);
end return;
end Create;
--------------------
-- Get_Local_Name --
--------------------
overriding function Get_Local_Name
(Self : not null access constant Style_Layout_Grid_Snap_To_Attribute_Node)
return League.Strings.Universal_String
is
pragma Unreferenced (Self);
begin
return Matreshka.ODF_String_Constants.Layout_Grid_Snap_To_Attribute;
end Get_Local_Name;
begin
Matreshka.DOM_Documents.Register_Attribute
(Matreshka.ODF_String_Constants.Style_URI,
Matreshka.ODF_String_Constants.Layout_Grid_Snap_To_Attribute,
Style_Layout_Grid_Snap_To_Attribute_Node'Tag);
end Matreshka.ODF_Style.Layout_Grid_Snap_To_Attributes;
|
burratoo/Acton | Ada | 1,679 | ads | ------------------------------------------------------------------------------------------
-- --
-- OAK PROCESSOR SUPPORT PACKAGE --
-- FREESCALE MPC5544 --
-- --
-- MPC5554 --
-- --
-- Copyright (C) 2010-2021, Patrick Bernardi --
-- --
------------------------------------------------------------------------------------------
with System;
package MPC5554 with Pure is
type Enable_Type is (Disable, Enable);
for Enable_Type use (Disable => 0, Enable => 1);
type Enable_Array is array (Integer range <>) of Enable_Type with Pack;
type Disable_Type is (Enable, Disable);
for Disable_Type use (Enable => 0, Disable => 1);
type Pin_State_Type is (Low, High);
for Pin_State_Type use (Low => 0, High => 1);
type Occurred_Type is (Not_Occurred, Occurred);
for Occurred_Type use (Not_Occurred => 0, Occurred => 1);
type Yes_No_Type is (No, Yes);
for Yes_No_Type use (No => 0, Yes => 1);
type Success_Type is (Failed, Successful);
for Success_Type use (Failed => 0, Successful => 1);
type Register_Elements is range 0 .. System.Word_Size;
end MPC5554;
|
zhmu/ananas | Ada | 7,225 | adb | ------------------------------------------------------------------------------
-- --
-- GNAT RUN-TIME COMPONENTS --
-- --
-- A D A . W I D E _ W I D E _ T E X T _ I O . I N T E G E R _ I O --
-- --
-- B o d y --
-- --
-- Copyright (C) 1992-2022, Free Software Foundation, Inc. --
-- --
-- GNAT is free software; you can redistribute it and/or modify it under --
-- terms of the GNU General Public License as published by the Free Soft- --
-- ware Foundation; either version 3, or (at your option) any later ver- --
-- sion. GNAT is distributed in the hope that it will be useful, but WITH- --
-- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY --
-- or FITNESS FOR A PARTICULAR PURPOSE. --
-- --
-- As a special exception under Section 7 of GPL version 3, you are granted --
-- additional permissions described in the GCC Runtime Library Exception, --
-- version 3.1, as published by the Free Software Foundation. --
-- --
-- You should have received a copy of the GNU General Public License and --
-- a copy of the GCC Runtime Library Exception along with this program; --
-- see the files COPYING3 and COPYING.RUNTIME respectively. If not, see --
-- <http://www.gnu.org/licenses/>. --
-- --
-- GNAT was originally developed by the GNAT team at New York University. --
-- Extensive contributions were provided by Ada Core Technologies Inc. --
-- --
------------------------------------------------------------------------------
with Ada.Wide_Wide_Text_IO.Integer_Aux;
with System.Img_BIU; use System.Img_BIU;
with System.Img_Int; use System.Img_Int;
with System.Img_LLB; use System.Img_LLB;
with System.Img_LLI; use System.Img_LLI;
with System.Img_LLW; use System.Img_LLW;
with System.Img_LLLB; use System.Img_LLLB;
with System.Img_LLLI; use System.Img_LLLI;
with System.Img_LLLW; use System.Img_LLLW;
with System.Img_WIU; use System.Img_WIU;
with System.Val_Int; use System.Val_Int;
with System.Val_LLI; use System.Val_LLI;
with System.Val_LLLI; use System.Val_LLLI;
with System.WCh_Con; use System.WCh_Con;
with System.WCh_WtS; use System.WCh_WtS;
package body Ada.Wide_Wide_Text_IO.Integer_IO is
package Aux_Int is new
Ada.Wide_Wide_Text_IO.Integer_Aux
(Integer,
Scan_Integer,
Set_Image_Integer,
Set_Image_Width_Integer,
Set_Image_Based_Integer);
package Aux_LLI is new
Ada.Wide_Wide_Text_IO.Integer_Aux
(Long_Long_Integer,
Scan_Long_Long_Integer,
Set_Image_Long_Long_Integer,
Set_Image_Width_Long_Long_Integer,
Set_Image_Based_Long_Long_Integer);
package Aux_LLLI is new
Ada.Wide_Wide_Text_IO.Integer_Aux
(Long_Long_Long_Integer,
Scan_Long_Long_Long_Integer,
Set_Image_Long_Long_Long_Integer,
Set_Image_Width_Long_Long_Long_Integer,
Set_Image_Based_Long_Long_Long_Integer);
Need_LLI : constant Boolean := Num'Base'Size > Integer'Size;
Need_LLLI : constant Boolean := Num'Base'Size > Long_Long_Integer'Size;
-- Throughout this generic body, we distinguish between cases where type
-- Integer is acceptable, where type Long_Long_Integer is acceptable and
-- where type Long_Long_Long_Integer is needed. These boolean constants
-- are used to test for these cases and since they are constant, only code
-- for the relevant case will be included in the instance.
---------
-- Get --
---------
procedure Get
(File : File_Type;
Item : out Num;
Width : Field := 0)
is
-- We depend on a range check to get Data_Error
pragma Unsuppress (Range_Check);
pragma Unsuppress (Overflow_Check);
begin
if Need_LLLI then
Aux_LLLI.Get (File, Long_Long_Long_Integer (Item), Width);
elsif Need_LLI then
Aux_LLI.Get (File, Long_Long_Integer (Item), Width);
else
Aux_Int.Get (File, Integer (Item), Width);
end if;
exception
when Constraint_Error => raise Data_Error;
end Get;
procedure Get
(Item : out Num;
Width : Field := 0)
is
begin
Get (Current_In, Item, Width);
end Get;
procedure Get
(From : Wide_Wide_String;
Item : out Num;
Last : out Positive)
is
-- We depend on a range check to get Data_Error
pragma Unsuppress (Range_Check);
pragma Unsuppress (Overflow_Check);
S : constant String := Wide_Wide_String_To_String (From, WCEM_Upper);
-- String on which we do the actual conversion. Note that the method
-- used for wide character encoding is irrelevant, since if there is
-- a character outside the Standard.Character range then the call to
-- Aux.Gets will raise Data_Error in any case.
begin
if Need_LLLI then
Aux_LLLI.Gets (S, Long_Long_Long_Integer (Item), Last);
elsif Need_LLI then
Aux_LLI.Gets (S, Long_Long_Integer (Item), Last);
else
Aux_Int.Gets (S, Integer (Item), Last);
end if;
exception
when Constraint_Error => raise Data_Error;
end Get;
---------
-- Put --
---------
procedure Put
(File : File_Type;
Item : Num;
Width : Field := Default_Width;
Base : Number_Base := Default_Base)
is
begin
if Need_LLLI then
Aux_LLLI.Put (File, Long_Long_Long_Integer (Item), Width, Base);
elsif Need_LLI then
Aux_LLI.Put (File, Long_Long_Integer (Item), Width, Base);
else
Aux_Int.Put (File, Integer (Item), Width, Base);
end if;
end Put;
procedure Put
(Item : Num;
Width : Field := Default_Width;
Base : Number_Base := Default_Base)
is
begin
Put (Current_Out, Item, Width, Base);
end Put;
procedure Put
(To : out Wide_Wide_String;
Item : Num;
Base : Number_Base := Default_Base)
is
S : String (To'First .. To'Last);
begin
if Need_LLLI then
Aux_LLLI.Puts (S, Long_Long_Long_Integer (Item), Base);
elsif Need_LLI then
Aux_LLI.Puts (S, Long_Long_Integer (Item), Base);
else
Aux_Int.Puts (S, Integer (Item), Base);
end if;
for J in S'Range loop
To (J) := Wide_Wide_Character'Val (Character'Pos (S (J)));
end loop;
end Put;
end Ada.Wide_Wide_Text_IO.Integer_IO;
|
caqg/linux-home | Ada | 1,575 | ads | -- Abstract :
--
-- External process parser for gpr mode
--
-- Copyright (C) 2017 - 2019 Free Software Foundation, Inc.
--
-- This program is free software; you can redistribute it and/or
-- modify it under terms of the GNU General Public License as
-- published by the Free Software Foundation; either version 3, or (at
-- your option) any later version. This 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
-- distributed with this program; see file COPYING. If not, write to
-- the Free Software Foundation, 51 Franklin Street, Suite 500, Boston,
-- MA 02110-1335, USA.
pragma License (GPL);
with Gen_Emacs_Wisi_LR_Parse;
with Gpr_Process_Actions;
with Gpr_Process_LR1_Main;
with Wisi.Gpr;
procedure Gpr_Mode_Wisi_Parse is new Gen_Emacs_Wisi_LR_Parse
(Parse_Data_Type => Wisi.Gpr.Parse_Data_Type,
Language_Protocol_Version => Wisi.Gpr.Language_Protocol_Version,
Name => "gpr_mode_wisi_parse",
Descriptor => Gpr_Process_Actions.Descriptor,
Partial_Parse_Active => Gpr_Process_Actions.Partial_Parse_Active,
Language_Fixes => null,
Language_Matching_Begin_Tokens => null,
Language_String_ID_Set => null,
Create_Parser => Gpr_Process_LR1_Main.Create_Parser);
|
zhmu/ananas | Ada | 403 | ads | package Predicate2 is
type Optional_Name_Type is new String;
subtype Name_Type is Optional_Name_Type
with Dynamic_Predicate => Name_Type'Length > 0;
-- A non case sensitive name
subtype Value_Type is String;
overriding function "=" (Left, Right : Optional_Name_Type) return Boolean;
overriding function "<" (Left, Right : Optional_Name_Type) return Boolean;
end Predicate2;
|
reznikmm/gela | Ada | 63,137 | ads | -------------------------------------------------------------------------------
-------------------------------------------------------------------------------
-- 17 package Asis.Expressions
-------------------------------------------------------------------------------
-------------------------------------------------------------------------------
package Asis.Expressions is
-- pragma Preelaborate;
-------------------------------------------------------------------------------
-------------------------------------------------------------------------------
-- Asis.Expressions encapsulates a set of queries that operate on
-- An_Expression and An_Association elements.
-------------------------------------------------------------------------------
-------------------------------------------------------------------------------
-- 17.1 function Corresponding_Expression_Type
-------------------------------------------------------------------------------
function Corresponding_Expression_Type (Expression : in Asis.Expression)
return Asis.Declaration;
-------------------------------------------------------------------------------
-- Expression - Specifies the expression to query
--
-- Returns the type declaration for the type or subtype of the expression.
-- This query does not "unwind" subtypes or derived types to get to the
-- Corresponding_First_Subtype or Corresponding_Parent_Subtype declarations.
-- For example, for the following program text:
--
-- type Int is range -5_000 .. 5_000;
-- type My_Int is new Int;
-- type Good_Int is new My_Int;
-- Var: Good_Int;
--
-- The type declaration for Good_Int should be returned. The "unwinding"
-- should not occur. The type declaration for either My_Int or Int should
-- not be returned.
--
-- Returns a Nil_Element if the argument Expression does not represent an Ada
-- expression having an Ada type, including the following classes:
--
-- - Naming expressions that name packages, subprograms, tasks, etc. These
-- expressions do have a Corresponding_Name_Definition and a
-- Corresponding_Name_Declaration. Although task objects do have
-- a type, this query is limited, on purpose. Thus, when a naming
-- expression is given to this query (for packages, subprograms,
-- tasks, etc.), this query will return Nil_Element. As the
-- Application Note below indicates, if any further information
-- is needed, the element should be queried by
-- Corresponding_Name_Definition or Corresponding_Name_Declaration,
-- which should eventually return an A_Task_Type_Declaration element.
--
-- - When An_Identifier Element representing an attribute designator is
-- passed as the actual to this query.
--
-- - The Actual_Parameter Expression from A_Pragma_Argument_Association for
-- a Pragma may or may not have a Corresponding_Expression_Type.
--
-- - An_Attribute_Reference Element also may or may not have a
-- Corresponding_Expression_Type;
--
-- - An enumeration_aggregate which is a part of
-- enumeration_representation_clause.
--
-- - A_Box_Expression returned by Component_Expression applied to an
-- unnormalized record association.
--
-- AASIS Note: This is necessary as the <> of an unnnormalized record
-- association may represent several components of different types. If the
-- record association is normalized, it has a single component and the type
-- of A_Box_Expression is that of the component. Similarly, the type of
-- A_Box_Expression for an array association is that of the component type.
--
-- Returns a Nil_Element, if the statically determinable type of Expression
-- is a class-wide type, or the Expression corresponds to an inner
-- sub-aggregate in multi-dimensional array aggregates.
--
-- |AN Application Note:
-- |AN
-- |AN If the returned declaration is Nil, an application should make its own
-- |AN analysis based on Corresponding_Name_Definition or
-- |AN Corresponding_Name_Declaration to get more information about the
-- |AN argument, including the static type resolution for class-wide
-- |AN expressions, if needed. Use Enclosing_Element to determine if
-- |AN Expression is from pragma argument association. If for such an
-- |AN expression, Corresponding_Name_Definition raises ASIS_Failed (with a
-- |AN Status of Value_Error), this An_Expression element does not represent
-- |AN a normal Ada expression at all and does not follow normal Ada semantic
-- |AN rules.
-- |AN For example, "pragma Private_Part (Open => Yes);", the "Yes" expression
-- |AN may simply be a "keyword" that is specially recognized by the
-- |AN implementor's compilation system and may not refer to any
-- |AN declared object.
--
-- Appropriate Element_Kinds:
-- An_Expression
--
-- Returns Element_Kinds:
-- Not_An_Element
-- A_Declaration
--
-- |ER An_Integer_Literal - 2.4 - No child elements
-- |ER A_Real_Literal - 2.4 - No child elements
-- |ER A_String_Literal - 2.6 - No child elements
-- |ER
-- |ER A string image returned by:
-- |ER function Value_Image
--
-------------------------------------------------------------------------------
-- 17.2 function Value_Image
-------------------------------------------------------------------------------
function Value_Image (Expression : in Asis.Expression) return Wide_String;
-------------------------------------------------------------------------------
-- Expression - Specifies the expression to query
--
-- Returns the string image of the value of the string, integer, or real
-- literal.
--
-- For string literals, Value will return the quotes around the string
-- literal, these quotes are doubled, just as any quote appearing embedded in
-- the string literal in the program text.
--
-- The form of numbers returned by this query may vary between implementors.
-- Implementors are encouraged, but not required, to return numeric literals
-- using the same based or exponent form used in the original compilation
-- text.
--
-- Appropriate Expression_Kinds:
-- An_Integer_Literal
-- A_Real_Literal
-- A_String_Literal
--
-------------------------------------------------------------------------------
-- |ER An_Identifier - 4.1 - No child elements
-- |ER An_Operator_Symbol - 4.1 - No child elements
-- |ER A_Character_Literal - 4.1 - No child elements
-- |ER An_Enumeration_Literal - 4.1 - No child elements
-- |ER
-- |ER A string image returned by:
-- |ER function Name_Image
-- |ER
-- |ER Semantic elements returned by:
-- |ER function Corresponding_Name_Definition
-- |ER function Corresponding_Name_Definition_List
-- |ER function Corresponding_Name_Declaration
--
-------------------------------------------------------------------------------
-- 17.3 function Name_Image
-------------------------------------------------------------------------------
function Name_Image (Expression : in Asis.Expression) return Program_Text;
-------------------------------------------------------------------------------
-- Name - Specifies the name to query
--
-- Returns the program text image of the name.
--
-- An_Operator_Symbol elements have names with embedded quotes """abs"""
-- (function "abs").
--
-- A_Character_Literal elements have names with embedded apostrophes "'x'"
-- (literal 'x').
--
-- An_Enumeration_Literal and An_Identifier elements have identifier names
-- "Blue" (literal Blue) "Abc" (identifier Abc).
--
-- Note: Implicit subtypes that can be encountered while traversing the
-- semantic information embedded in implicit inherited subprogram declarations
-- (Reference Manual 3.4 (17-22)) could have names that are unique in a
-- particular scope. This is because these subtypes are Is_Part_Of_Implicit
-- declarations that do not form part of the physical text of the original
-- compilation units. Some applications may wish to carefully separate the
-- names of declarations from the names of Is_Part_Of_Implicit declaration
-- when creating symbol tables and other name-specific lookup mechanisms.
--
-- The case of names returned by this query may vary between implementors.
-- Implementors are encouraged, but not required, to return names in the
-- same case as was used in the original compilation text.
--
-- Appropriate Expression_Kinds:
-- An_Identifier
-- An_Operator_Symbol
-- A_Character_Literal
-- An_Enumeration_Literal
--
-------------------------------------------------------------------------------
-- 17.4 function References
-------------------------------------------------------------------------------
function References (Name : in Asis.Element;
Within_Element : in Asis.Element;
Implicitly : in Boolean := False)
return Asis.Name_List;
-------------------------------------------------------------------------------
-- Name - Specifies the entity to query
-- Within_Element - Specifies the limits for the query which is limited
-- to the Element and its children.
--
-- If the Implicitly argument is True:
-- Returns all usage references of the given entity made by both explicit
-- and implicit elements within the given limits.
--
-- If the Implicitly argument is False:
-- Returns all usage references of the given entity made only by explicit
-- elements within the given limits.
--
-- Returned references are in their order of appearance.
--
-- Appropriate Element_Kinds:
-- A_Defining_Name
-- Returns Element_Kinds:
-- An_Expression
--
-- May raise ASIS_Failed with a Status of Obsolete_Reference_Error if the
-- argument is part of an inconsistent compilation unit.
--
-------------------------------------------------------------------------------
-- 17.5 function Is_Referenced
-------------------------------------------------------------------------------
function Is_Referenced (Name : in Asis.Element;
Within_Element : in Asis.Element;
Implicitly : in Boolean := False)
return Boolean;
-------------------------------------------------------------------------------
-- Name - Specifies the entity to query
-- Within_Element - Specifies the limits for the query which is limited
-- to the Element and its children.
--
-- If the Implicitly argument is True:
-- Returns True if the Name is referenced by either implicit or explicit
-- elements within the given limits.
--
-- If the Implicitly argument is False:
-- Returns True only if the Name is referenced by explicit elements.
--
-- Returns False for any unexpected Element.
--
-- Expected Element_Kinds:
-- A_Defining_Name
--
-- May raise ASIS_Failed with a Status of Obsolete_Reference_Error if the
-- argument is part of an inconsistent compilation unit.
--
-------------------------------------------------------------------------------
-- 17.6 function Corresponding_Name_Definition
-------------------------------------------------------------------------------
function Corresponding_Name_Definition (Reference : in Asis.Expression)
return Asis.Defining_Name;
-------------------------------------------------------------------------------
-- Reference - Specifies an expression to query
--
-- Returns the defining_identifier, defining_character_literal,
-- defining_operator_symbol, or defining_program_unit_name from the
-- declaration of the referenced entity.
--
-- - Record component references return the defining name of the
-- record discriminant or component_declaration. For references to inherited
-- declarations of derived types, the Corresponding_Name_Definition returns
-- the defining name of the implicit inherited declaration.
--
-- - References to implicit operators and inherited subprograms will return
-- an Is_Part_Of_Implicit defining name for the operation. The
-- Enclosing_Element of the name is an implicit declaration for the
-- operation. The Enclosing_Element of the declaration is the associated
-- derived_type_definition.
--
-- - References to formal parameters given in calls to inherited subprograms
-- will return an Is_Part_Of_Implicit defining name for the
-- Parameter_Specification from the inherited subprogram specification.
--
-- - References to visible components of instantiated generic packages will
-- return a name from the expanded generic specification instance.
--
-- - References, within expanded generic instances, that refer to other
-- components of the same, or an enclosing, expanded generic instance,
-- return a name from the appropriate expanded specification or body
-- instance.
--
-- In case of renaming, the function returns the new name for the entity.
--
-- Returns a Nil_Element if the reference is to an implicitly declared
-- element for which the implementation does not provide declarations and
-- defining name elements.
--
-- Returns a Nil_Element if the argument is a dispatching call.
--
-- The Enclosing_Element of a non-Nil result is either a Declaration or a
-- Statement.
--
-- Appropriate Expression_Kinds:
-- An_Identifier
-- An_Operator_Symbol
-- A_Character_Literal
-- An_Enumeration_Literal
--
-- Returns Element_Kinds:
-- Not_An_Element
-- A_Defining_Name
--
-- |IP Implementation Permissions:
-- |IP
-- |IP An implementation may choose to return any part of multi-part
-- |IP declarations and definitions. Multi-part declaration/definitions
-- |IP can occur for:
-- |IP
-- |IP - Subprogram specification in package specification, package body,
-- |IP and subunits (is separate);
-- |IP
-- |IP - Entries in package specification, package body, and subunits (is
-- |IP separate);
-- |IP
-- |IP - Private type and full type declarations;
-- |IP
-- |IP - Incomplete type and full type declarations; and
-- |IP
-- |IP - Deferred constant and full constant declarations.
-- |IP
-- |IP No guarantee is made that the element will be the first part or
-- |IP that the determination will be made due to any visibility rules.
-- |IP An application should make its own analysis for each case based
-- |IP on which part is returned.
-- |IP
-- |IP Some implementations do not represent all forms of implicit
-- |IP declarations such that elements representing them can be easily
-- |IP provided. An implementation can choose whether or not to construct
-- |IP and provide artificial declarations for implicitly declared elements.
--
-- |IR Implementation Requirements:
-- |IR
-- |IR Raises ASIS_Inappropriate_Element, with a Status of Value_Error, if
-- |IR passed a reference that does not have a declaration:
-- |IR
-- |IR - a reference to an attribute_designator. Attributes are defined, but
-- |IR have no implicit or explicit declarations;
-- |IR
-- |IR - an identifier which syntactically is placed before "=>" in a
-- |IR pragma_argument_association which has the form of a named
-- |IR association; such an identifier can never have a declaration;
-- |IR
-- |IR - an identifier specific to a pragma (Reference Manual, 2.8(10));
-- |IR
-- |IR pragma Should_I_Check ( Really => Yes );
-- |IR
-- |IR In this example, both the names Really and Yes have no declaration.
-- |IR
-- |IR Raises ASIS_Inappropriate_Element, with a Status of Value_Error, if
-- |IR passed a portion of a pragma that was "ignored" by the compiler and
-- |IR which does not have (sufficient) semantic information for a proper
-- |IR return result to be computed. For example,
-- |IR
-- |IR pragma I_Am_Ignored (Foof);
-- |IR
-- |IR The "Foof" expression is An_Identifier but raises this exception
-- |IR if passed to Corresponding_Name_Definition if the pragma was ignored
-- |IR or unprocessed.
-- |IR
-- |IR Raises ASIS_Inappropriate_Element, with a Status of Value_Error, if
-- |IR passed a portion of a pragma that is an ambiguous reference to more
-- |IR than one entity. For example,
-- |IR
-- |IR pragma Inline ("+"); -- Inlines all "+" operators
-- |IR
-- |IR The "+" expression is An_Operator_Symbol but raises this
-- |IR exception if it referenced more than one "+" operator. In this
-- |IR case, the Corresponding_Name_Definition_List query can be used to
-- |IR obtain a list of referenced entities.
--
-------------------------------------------------------------------------------
-- 17.7 function Corresponding_Name_Definition_List
-------------------------------------------------------------------------------
function Corresponding_Name_Definition_List (Reference : in Asis.Element)
return Asis.Defining_Name_List;
-------------------------------------------------------------------------------
-- Reference - Specifies an entity reference to query
--
-- Exactly like Corresponding_Name_Definition except it returns a list.
-- The list will almost always have a length of one. The exception to this
-- is the case where an expression in a pragma is ambiguous and reference
-- more than one entity. For example,
--
-- pragma Inline ("+"); -- Inlines all "+" operators
--
-- The "+" expression is An_Operator_Symbol but could reference more than one
-- "+" operator. In this case, the resulting list includes all referenced
-- entities.
--
-- Appropriate Expression_Kinds:
-- An_Identifier
-- An_Operator_Symbol
-- A_Character_Literal
-- An_Enumeration_Literal
--
-- Returns Element_Kinds:
-- A_Defining_Name
--
-------------------------------------------------------------------------------
-- 17.8 function Corresponding_Name_Declaration
-------------------------------------------------------------------------------
function Corresponding_Name_Declaration (Reference : in Asis.Expression)
return Asis.Element;
-------------------------------------------------------------------------------
-- Reference - Specifies the entity reference to query
--
-- Returns the declaration that declared the entity named by the given
-- reference. The result is exactly the same as:
--
-- Result := Corresponding_Name_Definition (Reference);
-- if not Is_Nil (Result) then
-- Result := Enclosing_Element (Result);
-- end if;
-- return Result;
--
-- See the comments for Corresponding_Name_Definition for details.
-- The result is either a Declaration or a Statement. Statements result
-- from references to statement labels, loop identifiers, and block
-- identifiers.
--
-- Appropriate Element_Kinds:
-- An_Expression
--
-- Appropriate Expression_Kinds:
-- An_Identifier
-- An_Operator_Symbol
-- A_Character_Literal
-- An_Enumeration_Literal
--
-- Returns Element_Kinds:
-- A_Declaration
-- A_Statement
--
-- Predefined types, exceptions, operators in package Standard can be
-- checked by testing that the enclosing Compilation_Unit is standard.
--
-- |ER------------------------------------------------------------------------
-- |ER An_Explicit_Dereference - 4.1
-- |CR
-- |CR Child elements returned by: function Prefix
--
-------------------------------------------------------------------------------
-- 17.9 function Prefix
-------------------------------------------------------------------------------
function Prefix (Expression : in Asis.Expression) return Asis.Expression;
-------------------------------------------------------------------------------
-- Expression - Specifies the name expression to query
--
-- Returns the prefix (the construct to the left of: the rightmost unnested
-- left parenthesis in function_call elements and indexed_component elements
-- or slice elements, the rightmost 'dot' for selected_component elements,
-- or the rightmost tick for attribute_reference elements).
--
-- Returns the operator_symbol for infix operator function calls. The infix
-- form A + B is equivalent to the prefix form "+"(A, B).
--
-- Appropriate Expression_Kinds:
-- An_Explicit_Dereference P.ALL
-- An_Attribute_Reference Priv'Base'First
-- A_Function_Call Abc(...) or Integer'Image(...)
-- An_Indexed_Component An_Array(3)
-- A_Selected_Component A.B.C
-- A_Slice An_Array(3 .. 5)
--
-- Returns Expression_Kinds:
-- An_Expression
--
-- |ER------------------------------------------------------------------------
-- |ER An_Indexed_Component - 4.1.1
-- |ER
-- |CR
-- |CR Child elements returned by:
-- |CR function Prefix
-- |CR function Index_Expressions
-- |CR
--
-------------------------------------------------------------------------------
-- 17.10 function Index_Expressions
-------------------------------------------------------------------------------
function Index_Expressions (Expression : in Asis.Expression)
return Asis.Expression_List;
-------------------------------------------------------------------------------
-- Expression - Specifies an indexed_component to query
--
-- Returns the list of expressions (possibly only one) within the parenthesis,
-- in their order of appearance.
--
-- Appropriate Expression_Kinds:
-- An_Indexed_Component
--
-- Returns Element_Kinds:
-- An_Expression
--
-- |ER------------------------------------------------------------------------
-- |ER A_Slice - 4.1.2
-- |CR
-- |CR Child elements returned by:
-- |CR function Prefix
-- |CR function Slice_Range
-- |CR
--
-------------------------------------------------------------------------------
-- 17.11 function Slice_Range
-------------------------------------------------------------------------------
function Slice_Range (Expression : in Asis.Expression)
return Asis.Discrete_Range;
-------------------------------------------------------------------------------
-- Expression - Specifies the slice to query
--
-- Returns the discrete range of the slice.
--
-- Appropriate Expression_Kinds:
-- A_Slice
--
-- Returns Definition_Kinds:
-- A_Discrete_Range
--
-------------------------------------------------------------------------------
-- 17.12 function Selector
-------------------------------------------------------------------------------
function Selector (Expression : in Asis.Expression)
return Asis.Expression;
-------------------------------------------------------------------------------
-- Expression - Specifies the selected_component to query
--
-- Returns the selector (the construct to the right of the rightmost 'dot' in
-- the selected_component).
--
-- Appropriate Expression_Kinds:
-- A_Selected_Component
--
-- Returns Expression_Kinds:
-- An_Identifier
-- An_Operator_Symbol
-- A_Character_Literal
-- An_Enumeration_Literal
--
-------------------------------------------------------------------------------
-- 17.13 function Attribute_Designator_Identifier
-------------------------------------------------------------------------------
function Attribute_Designator_Identifier
(Expression : in Asis.Expression)
return Asis.Expression;
-------------------------------------------------------------------------------
-- Expression - Specifies an attribute_reference expression to query
--
-- Returns the identifier of the attribute_designator (the construct to the
-- right of the rightmost tick of the attribute_reference). The Prefix of
-- the attribute_reference can itself be an attribute_reference as in
-- T'BASE'FIRST where the prefix is T'BASE and the attribute_designator name
-- is FIRST.
--
-- Attribute_designator reserved words "access", "delta", and "digits" are
-- treated as An_Identifier.
--
-- Appropriate Expression_Kinds:
-- An_Attribute_Reference
--
-- Returns Expression_Kinds:
-- An_Identifier
--
-------------------------------------------------------------------------------
-- 17.14 function Attribute_Designator_Expressions
-------------------------------------------------------------------------------
function Attribute_Designator_Expressions
(Expression : in Asis.Expression)
return Asis.Expression_List;
-------------------------------------------------------------------------------
-- Expression - Specifies an attribute expression to query
--
-- Returns the static expressions associated with the optional argument of
-- the attribute_designator. Expected predefined attributes are A'First(N),
-- A'Last(N), A'Length(N), and A'Range(N).
--
-- Returns a Nil_Element_List if there are no arguments.
--
-- Appropriate Expression_Kinds:
-- An_Attribute_Reference
-- Appropriate Attribute_Kinds:
-- A_First_Attribute
-- A_Last_Attribute
-- A_Length_Attribute
-- A_Range_Attribute
-- An_Implementation_Defined_Attribute
-- An_Unknown_Attribute
--
-- Returns Element_Kinds:
-- An_Expression
--
-- |IP Implementation Permissions:
-- |IP
-- |IP This query returns a list to support implementation-defined attributes
-- |IP that may have more than one static_expression.
--
-------------------------------------------------------------------------------
-- 17.15 function Record_Component_Associations
-------------------------------------------------------------------------------
function Record_Component_Associations
(Expression : in Asis.Expression;
Normalized : in Boolean := False)
return Asis.Association_List;
-------------------------------------------------------------------------------
-- Expression - Specifies an aggregate expression to query
-- Normalized - Specifies whether the normalized form is desired
--
-- Returns a list of the record_component_association elements of a
-- record_aggregate or an extension_aggregate.
--
-- Returns a Nil_Element_List if the aggregate is of the form (null record).
--
-- An unnormalized list contains all needed associations ordered as they
-- appear in the program text. Each unnormalized association has an optional
-- list of discriminant_selector_name elements, and an explicit expression.
--
-- A normalized list contains artificial associations representing all
-- needed components in an order matching the declaration order of the
-- needed components.
--
-- Each normalized association represents a one on one mapping of a
-- component to the explicit expression. A normalized association has one
-- A_Defining_Name component that denotes the discriminant_specification or
-- component_declaration, and one An_Expression component that is the
-- expression.
--
-- Appropriate Expression_Kinds:
-- A_Record_Aggregate
-- An_Extension_Aggregate
--
-- Returns Association_Kinds:
-- A_Record_Component_Association
--
-- |IR Implementation Requirements:
-- |IR
-- |IR Normalized associations are Is_Normalized and Is_Part_Of_Implicit.
-- |IR Normalized associations are never Is_Equal to unnormalized
-- |IR associations.
--
-- |IP Implementation Permissions:
-- |IP
-- |IP An implementation may choose to normalize its internal representation
-- |IP to use the defining_identifier element instead of the
-- |IP component_selector_name element.
-- |IP
-- |IP If so, this query will return Is_Normalized associations even if
-- |IP Normalized is False, and the query
-- |IP Record_Component_Associations_Normalized will return True.
--
-------------------------------------------------------------------------------
-- 17.16 function Extension_Aggregate_Expression
-------------------------------------------------------------------------------
function Extension_Aggregate_Expression
(Expression : in Asis.Expression)
return Asis.Expression;
-------------------------------------------------------------------------------
-- Expression - Specifies an extension_aggregate expression to query
--
-- Returns the ancestor_part expression preceding the reserved word with in
-- the extension_aggregate.
--
-- Appropriate Expression_Kinds:
-- An_Extension_Aggregate
--
-- Returns Element_Kinds:
-- An_Expression
--
-------------------------------------------------------------------------------
-- 17.17 function Array_Component_Associations
-------------------------------------------------------------------------------
function Array_Component_Associations
(Expression : in Asis.Expression)
return Asis.Association_List;
-------------------------------------------------------------------------------
-- Expression - Specifies an array aggregate expression to query
--
-- Returns a list of the Array_Component_Associations in an array aggregate.
--
-- Appropriate Expression_Kinds:
-- A_Positional_Array_Aggregate
-- A_Named_Array_Aggregate
--
-- Returns Association_Kinds:
-- An_Array_Component_Association
--
-- |AN Application Note:
-- |AN
-- |AN While positional_array_aggregate elements do not have
-- |AN array_component_association elements defined by Ada syntax, ASIS treats
-- |AN A_Positional_Array_Aggregate as if it were A_Named_Array_Aggregate.
-- |AN The An_Array_Component_Association elements returned will have
-- |AN Array_Component_Choices that are a Nil_Element_List for all positional
-- |AN expressions except an others choice.
--
-------------------------------------------------------------------------------
-- 17.18 function Array_Component_Choices
-------------------------------------------------------------------------------
function Array_Component_Choices
(Association : in Asis.Association)
return Asis.Expression_List;
-------------------------------------------------------------------------------
-- Association - Specifies the component association to query
--
-- If the Association is from a named_array_aggregate:
--
-- - Returns the discrete_choice_list order of appearance. The choices are
-- either An_Expression or A_Discrete_Range elements, or a single
-- An_Others_Choice element.
--
-- If the Association is from a positional_array_aggregate:
--
-- - Returns a single An_Others_Choice if the association is an others
-- choice (others => expression).
--
-- - Returns a Nil_Element_List otherwise.
--
-- Appropriate Association_Kinds:
-- An_Array_Component_Association
--
-- Returns Element_Kinds:
-- A_Definition
-- An_Expression
--
-- Returns Definition_Kinds:
-- A_Discrete_Range
-- An_Others_Choice
--
-------------------------------------------------------------------------------
-- 17.19 function Record_Component_Choices
-------------------------------------------------------------------------------
function Record_Component_Choices
(Association : in Asis.Association)
return Asis.Expression_List;
-------------------------------------------------------------------------------
-- Association - Specifies the component association to query
--
-- If the Association argument is from an unnormalized list:
--
-- - If the Association is a named component association:
--
-- o Returns the component_choice_list order of appearance. The choices are
-- either An_Identifier elements representing component_selector_name
-- elements, or a single An_Others_Choice element.
--
-- o The Enclosing_Element of the choices is the Association argument.
--
-- - If the Association is a positional component association:
--
-- o Returns a Nil_Element_List.
--
-- If the Association argument is from a Normalized list:
--
-- - Returns a list containing a single choice:
--
-- o A_Defining_Name element representing the defining_identifier of
-- the component_declaration.
--
-- o The Enclosing_Element of the A_Defining_Name is the
-- component_declaration.
--
-- Normalized lists contain artificial ASIS An_Association elements that
-- provide one formal A_Defining_Name => An_Expression pair per
-- association. These artificial associations are Is_Normalized. Their
-- component A_Defining_Name is not Is_Normalized.
--
-- Appropriate Association_Kinds:
-- A_Record_Component_Association
--
-- Returns Element_Kinds:
-- A_Defining_Name -- Is_Normalized(Association)
-- An_Expression -- not Is_Normalized(Association)
-- Returns Expression_Kinds:
-- An_Identifier
-- A_Definition
-- Returns Definition_Kinds:
-- An_Others_Choice
--
-------------------------------------------------------------------------------
-- 17.20 function Component_Expression
-------------------------------------------------------------------------------
function Component_Expression (Association : in Asis.Association)
return Asis.Expression;
-------------------------------------------------------------------------------
-- Association - Specifies the component association to query
--
-- Returns the expression of the record_component_association or
-- array_component_association.
--
-- The Enclosing_Element of the expression is the Association argument.
--
-- Normalized lists contain artificial ASIS An_Association elements that
-- provide one formal A_Defining_Name => An_Expression pair per
-- association. These artificial associations are Is_Normalized. Their
-- component An_Expression elements are not Is_Normalized.
--
-- For An_Array_Component_Association and non-normalized
-- A_Record_Component_Association where the association contains a
-- box expression, Asis.Expressions.Component_Expression
-- returns A_Box_Expression.
--
-- For a normalized A_Record_Component_Association, where the association
-- contains a a box expression, if the corresponding record type that
-- contains this component contains a default expression,
-- Asis.Expressions.Component_Expression returns this default
-- expression, otherwise Asis.Expressions.Component_Expression
-- returns A_Box_Expression.
--
-- Appropriate Association_Kinds:
-- A_Record_Component_Association
-- An_Array_Component_Association
-- A_Box_Expression
--
-- Returns Element_Kinds:
-- An_Expression
--
-------------------------------------------------------------------------------
-- 17.21 function Formal_Parameter
-------------------------------------------------------------------------------
function Formal_Parameter (Association : in Asis.Association)
return Asis.Element;
-------------------------------------------------------------------------------
-- Association - Specifies the association to query
--
-- If the Association argument is from an unnormalized list:
--
-- - If the Association is given in named notation:
--
-- Returns An_Identifier representing the formal_parameter_selector_name,
-- generic_formal_parameter_selector_name, or pragma_argument_identifier.
--
-- The Enclosing_Element of the An_Identifier element is the Association
-- argument.
--
-- - If the Association is given in positional notation:
--
-- Returns a Nil_Element.
--
-- - May return An_Others_Choice for A_Generic_Association argument
--
-- If the Association argument is from a Normalized list:
--
-- - Returns A_Defining_Name representing the defining_identifier of the
-- parameter_specification or generic_formal_parameter_declaration.
-- Pragma_argument_association elements are not available in normalized
-- form.
--
-- - The Enclosing_Element of the A_Defining_Name is the
-- parameter_specification or generic_formal_parameter_declaration element.
--
-- Normalized lists contain artificial ASIS An_Association elements that
-- provide one formal A_Defining_Name => An_Expression pair per
-- association. These artificial associations are Is_Normalized. Their
-- component A_Defining_Name elements are not Is_Normalized.
--
-- Appropriate Association_Kinds:
-- A_Parameter_Association
-- A_Generic_Association
-- A_Pragma_Argument_Association
--
-- Returns Element_Kinds:
-- Not_An_Element
-- An_Operator_Symbol
-- A_Defining_Name -- Is_Normalized(Association)
-- An_Expression -- not Is_Normalized(Association)
-- Returns Expression_Kinds:
-- An_Identifier
-- Definition_Kinds -- Added by Gela for SI99-0014-1
-- Returns Definition_Kinds:
-- An_Others_Choice
--
-------------------------------------------------------------------------------
-- 17.22 function Actual_Parameter
-------------------------------------------------------------------------------
function Actual_Parameter (Association : in Asis.Association)
return Asis.Expression;
-------------------------------------------------------------------------------
-- Association - Specifies the association to query
--
-- If the Association argument is from an unnormalized list:
--
-- - Returns An_Expression representing:
--
-- o the explicit_actual_parameter of a parameter_association.
--
-- o the explicit_generic_actual_parameter of a generic_association.
--
-- o the name or expression of a pragma_argument_association.
--
-- - The Enclosing_Element of An_Expression is the Association argument.
--
-- If the Association argument is from a Normalized list:
--
-- - If the Association is given explicitly:
--
-- o Returns An_Expression representing:
--
-- + the explicit_actual_parameter of a parameter_association.
--
-- + the explicit_generic_actual_parameter of a generic_association.
--
-- o The Enclosing_Element of An_Expression is the Association argument.
--
-- - If the Association is given by default:
--
-- o Returns An_Expression representing:
--
-- + the corresponding default_expression of the Is_Normalized
-- A_Parameter_Association.
--
-- + the corresponding default_expression or default_name of the
-- Is_Normalized A_Generic_Association.
--
-- o The Enclosing_Element of the An_Expression element is the
-- parameter_specification or generic_formal_parameter_declaration that
-- contains the default_expression or default_name, except for the case
-- when this An_Expression element is an implicit naming expression
-- representing the actual subprogram selected at the place of the
-- instantiation for A_Box_Default. In the latter case, the
-- Enclosing_Element for such An_Expression is the instantiation.
--
-- o Normalized lists contain artificial ASIS An_Association elements that
-- provide one formal A_Defining_Name => An_Expression pair per
-- association. These artificial associations are Is_Normalized.
-- Artificial associations of default associations are
-- Is_Defaulted_Association. Their component An_Expression elements are
-- not Is_Normalized and are not Is_Defaulted_Association.
--
-- If the argument is A_Pragma_Argument_Association, then this function may
-- return any expression to support implementation-defined pragmas.
--
-- Appropriate Association_Kinds:
-- A_Parameter_Association
-- A_Generic_Association
-- A_Pragma_Argument_Association
--
-- Returns Element_Kinds:
-- An_Expression
--
-------------------------------------------------------------------------------
-- 17.23 function Discriminant_Selector_Names
-------------------------------------------------------------------------------
function Discriminant_Selector_Names
(Association : in Asis.Discriminant_Association)
return Asis.Expression_List;
-------------------------------------------------------------------------------
-- Association - Specifies the discriminant association to query
--
-- If the Association argument is from an unnormalized list:
--
-- - If the Association is a named discriminant_association:
--
-- o Returns a list of the An_Identifier discriminant_selector_name elements
-- in order of appearance.
--
-- o The Enclosing_Element of the names is the Association argument.
--
-- - If the Association is a positional discriminant_association:
--
-- o Returns a Nil_Element_List.
--
-- If the Association argument is from a Normalized list:
--
-- - Returns a list containing a single A_Defining_Name element representing
-- the defining_identifier of the discriminant_specification.
--
-- - The Enclosing_Element of the A_Defining_Name is the
-- discriminant_specification.
--
-- - Normalized lists contain artificial ASIS An_Association elements that
-- provide one formal A_Defining_Name => An_Expression pair per
-- association. These artificial associations are Is_Normalized. Their
-- component A_Defining_Name elements are not Is_Normalized.
--
-- Appropriate Association_Kinds:
-- A_Discriminant_Association
--
-- Returns Element_Kinds:
-- A_Defining_Name -- Is_Normalized(Association)
-- An_Expression -- not Is_Normalized(Association)
-- Returns Expression_Kinds:
-- An_Identifier
--
-------------------------------------------------------------------------------
-- 17.24 function Discriminant_Expression
-------------------------------------------------------------------------------
function Discriminant_Expression
(Association : in Asis.Discriminant_Association)
return Asis.Expression;
-------------------------------------------------------------------------------
-- Association - Specifies the discriminant_association to query
--
-- If the Association argument is from an unnormalized list:
--
-- - Returns An_Expression representing the expression of the
-- discriminant_association.
--
-- - The Enclosing_Element of An_Expression is the Association argument.
--
-- If the Association argument is from a Normalized list:
--
-- - If the Association is given explicitly:
--
-- o Returns An_Expression representing the expression of the
-- discriminant_association.
--
-- o The Enclosing_Element of An_Expression is the Association argument.
--
-- - If the Association is given by default:
--
-- o Returns An_Expression representing:
--
-- + the corresponding default_expression of the Is_Normalized
-- A_Discriminant_Association.
--
-- o The Enclosing_Element of the An_Expression element is the
-- discriminant_specification that contains the default_expression.
--
-- - Normalized lists contain artificial ASIS An_Association elements that
-- provide one formal A_Defining_Name => An_Expression pair per
-- association. These artificial associations are Is_Normalized.
-- Artificial associations of default associations are
-- Is_Defaulted_Association. Their component An_Expression elements are
-- not Is_Normalized and are not Is_Defaulted_Association.
--
-- Appropriate Association_Kinds:
-- A_Discriminant_Association
--
-- Returns Element_Kinds:
-- An_Expression
--
-------------------------------------------------------------------------------
-- 17.25 function Is_Normalized
-------------------------------------------------------------------------------
function Is_Normalized (Association : in Asis.Association) return Boolean;
-------------------------------------------------------------------------------
-- Association - Specifies the association to query
--
-- Returns True if the association is a normalized, artificially created
-- association returned by the queries Discriminant_Associations,
-- Generic_Actual_Part, Call_Statement_Parameters,
-- Record_Component_Associations, or Function_Call_Parameters where
-- Normalized => True (or the operation returns Is_Normalized associations
-- even if Normalized => False). See the Implementation Permissions for
-- these queries.
--
-- Returns False for any unexpected Element.
--
-- Expected Association_Kinds:
-- A_Discriminant_Association
-- A_Record_Component_Association
-- A_Parameter_Association
-- A_Generic_Association
--
-------------------------------------------------------------------------------
-- 17.26 function Is_Defaulted_Association
-------------------------------------------------------------------------------
function Is_Defaulted_Association
(Association : in Asis.Association) return Boolean;
-------------------------------------------------------------------------------
-- Association - Specifies the association to query
--
-- Returns True if the association is a normalized, artificially created
-- association returned by the queries Discriminant_Associations,
-- Generic_Actual_Part, Record_Component_Associations,
-- Call_Statement_Parameters, or Function_Call_Parameters where
-- Normalized => True (or the operation returns default associations even if
-- Normalized => False) and the association contains a default expression.
-- A default expression is one that is implicitly supplied by the language
-- semantics and that was not explicitly supplied (typed) by the user.
--
-- Returns False for any unexpected Element.
--
-- Expected Association_Kinds:
-- A_Parameter_Association
-- A_Generic_Association
--
-- |AN Application Note:
-- |AN
-- |AN Always returns False for discriminant associations. Defaulted
-- |AN discriminant associations occur only when the discriminant constraint
-- |AN is completely missing from a subtype indication. Consequently, it is
-- |AN not possible to obtain a (normalized) discriminant constraint list for
-- |AN such subtype indications. Always returns False for component
-- |AN associations. Aggregates cannot have defaulted components.
--
-------------------------------------------------------------------------------
-- 17.27 function Expression_Parenthesized
-------------------------------------------------------------------------------
function Expression_Parenthesized (Expression : in Asis.Expression)
return Asis.Expression;
-------------------------------------------------------------------------------
-- Expression - Specifies the parenthesized expression to query
--
-- Returns the expression within the parenthesis. This operation unwinds
-- only one set of parenthesis at a time, so the result may itself be
-- A_Parenthesized_Expression.
--
-- A_Parenthesized_Expression kind corresponds only to the (expression)
-- alternative in the syntax notion of primary in Reference Manual 4.4. For
-- example, an expression of a type_conversion is A_Parenthesized_Expression
-- only if it is similar to the form subtype_mark((expression)) where it has
-- at least one set of its own parenthesis.
--
-- Appropriate Expression_Kinds:
-- A_Parenthesized_Expression
--
-- Returns Element_Kinds:
-- An_Expression
--
-------------------------------------------------------------------------------
-- 17.28 function Is_Prefix_Call
-------------------------------------------------------------------------------
function Is_Prefix_Call (Expression : in Asis.Expression) return Boolean;
-------------------------------------------------------------------------------
-- Expression - Specifies the function call expression to query
--
-- Returns True if the function call is in prefix form.
--
-- Returns False for any unexpected Element.
--
-- For example,
--
-- Foo (A, B); -- Returns TRUE
-- "<" (A, B); -- Returns TRUE
-- ... A < B ... -- Returns FALSE
--
-- Expected Expression_Kinds:
-- A_Function_Call
--
-------------------------------------------------------------------------------
-- 17.29 function Corresponding_Called_Function
-------------------------------------------------------------------------------
function Corresponding_Called_Function
(Expression : in Asis.Expression)
return Asis.Declaration;
-------------------------------------------------------------------------------
-- Expression - Specifies the function_call to query
--
-- Returns the declaration of the called function.
--
-- Returns a Nil_Element if the:
--
-- - function_prefix denotes a predefined operator for which the
-- implementation does not provide an artificial function declaration,
--
-- - prefix of the call denotes an access to a function implicit or explicit
-- dereference,
--
-- - argument is a dispatching call.
--
-- If function_prefix denotes an attribute_reference, and if the corresponding
-- attribute is (re)defined by an attribute definition clause, an
-- implementation is encouraged, but not required, to return the definition
-- of the corresponding subprogram whose name is used after "use" in this
-- attribute definition clause. If an implementation cannot return such a
-- subprogram definition, a Nil_Element should be returned. For an attribute
-- reference which is not (re)defined by an attribute definition clause,
-- a Nil_Element should be returned.
--
-- Appropriate Expression_Kinds:
-- A_Function_Call
--
-- Returns Declaration_Kinds:
-- Not_A_Declaration
-- A_Function_Declaration
-- A_Function_Body_Declaration
-- A_Function_Body_Stub
-- A_Function_Renaming_Declaration
-- A_Function_Instantiation
-- A_Formal_Function_Declaration
-- A_Generic_Function_Declaration
--
-- |IP Implementation Permissions:
-- |IP
-- |IP An implementation may choose to return any part of multi-part
-- |IP declarations and definitions. Multi-part declaration/definitions can
-- |IP occur for:
-- |IP
-- |IP - Subprogram specification in package specification, package body,
-- |IP and subunits (is separate);
-- |IP - Entries in package specification, package body, and subunits
-- |IP (is separate);
-- |IP - Private type and full type declarations;
-- |IP - Incomplete type and full type declarations; and
-- |IP - Deferred constant and full constant declarations.
-- |IP
-- |IP No guarantee is made that the element will be the first part or
-- |IP that the determination will be made due to any visibility rules.
-- |IP An application should make its own analysis for each case based
-- |IP on which part is returned.
-- |IP
-- |IP An implementation can choose whether or not to construct and provide
-- |IP artificial implicit declarations for predefined operators.
--
-------------------------------------------------------------------------------
-- 17.30 function Function_Call_Parameters
-------------------------------------------------------------------------------
function Function_Call_Parameters (Expression : in Asis.Expression;
Normalized : in Boolean := False)
return Asis.Association_List;
-------------------------------------------------------------------------------
-- Expression - Specifies the function call expression to query
-- Normalized - Specifies whether the normalized form is desired
--
-- Returns a list of parameter_association elements of the call.
--
-- Returns a Nil_Element_List if there are no parameter_association elements.
--
-- An unnormalized list contains only explicit associations ordered as they
-- appear in the program text. Each unnormalized association has an optional
-- formal_parameter_selector_name and an explicit_actual_parameter component.
--
-- A normalized list contains artificial associations representing all
-- explicit and default associations. It has a length equal to the number of
-- parameter_specification elements of the formal_part of the
-- parameter_and_result_profile. The order of normalized associations matches
-- the order of parameter_specification elements.
--
-- Each normalized association represents a one on one mapping of a
-- parameter_specification elements to the explicit or default expression.
-- A normalized association has one A_Defining_Name component that denotes
-- the parameter_specification, and one An_Expression component that is
-- either the explicit_actual_parameter or a default_expression.
--
-- If the prefix of the call denotes an access to a function implicit or
-- explicit deference, normalized associations are constructed on the basis
-- of the formal_part of the parameter_and_result_profile from the
-- corresponding access_to_subprogram definition.
-- Returns Nil_Element for normalized associations in the case where
-- the called function can be determined only dynamically (dispatching
-- calls). ASIS cannot produce any meaningful result in this case.
-- The exception ASIS_Inappropriate_Element is raised when the function
-- call is an attribute reference and Is_Normalized is True.
--
-- Appropriate Expression_Kinds:
-- A_Function_Call
--
-- Returns Element_Kinds:
-- A_Parameter_Association
--
-- |IR Implementation Requirements:
-- |IR
-- |IR Normalized associations are Is_Normalized and Is_Part_Of_Implicit.
-- |IR Normalized associations provided by default are
-- |IR Is_Defaulted_Association.
-- |IR Normalized associations are never Is_Equal to unnormalized
-- |IR associations.
--
-- |IP Implementation Permissions:
-- |IP
-- |IP An implementation may choose to always include default parameters in
-- |IP its internal representation.
-- |IP
-- |IP An implementation may also choose to normalize its representation
-- |IP to use defining_identifier elements rather than
-- |IP formal_parameter_selector_name elements.
-- |IP
-- |IP In either case, this query will return Is_Normalized associations even
-- |IP if Normalized is False, and the query
-- |IP Function_Call_Parameters_Normalized will return True.
--
-------------------------------------------------------------------------------
-- 17.31 function Short_Circuit_Operation_Left_Expression
-------------------------------------------------------------------------------
function Short_Circuit_Operation_Left_Expression
(Expression : in Asis.Expression)
return Asis.Expression;
-------------------------------------------------------------------------------
-- Expression - Specifies the short circuit operation to query
--
-- Returns the expression preceding the reserved words "and then" or
-- "or else" in the short circuit expression.
--
-- Appropriate Expression_Kinds:
-- An_And_Then_Short_Circuit
-- An_Or_Else_Short_Circuit
--
-- Returns Element_Kinds:
-- An_Expression
--
-------------------------------------------------------------------------------
-- 17.32 function Short_Circuit_Operation_Right_Expression
-------------------------------------------------------------------------------
function Short_Circuit_Operation_Right_Expression
(Expression : in Asis.Expression)
return Asis.Expression;
-------------------------------------------------------------------------------
-- Expression - Specifies the short circuit operation to query
--
-- Returns the expression following the reserved words "or else" or
-- "and then" in the short circuit expression.
--
-- Appropriate Expression_Kinds:
-- An_And_Then_Short_Circuit
-- An_Or_Else_Short_Circuit
--
-- Returns Element_Kinds:
-- An_Expression
--
-------------------------------------------------------------------------------
-- 17.33 function Membership_Test_Expression
-------------------------------------------------------------------------------
function Membership_Test_Expression (Expression : in Asis.Expression)
return Asis.Expression;
-------------------------------------------------------------------------------
-- Expression - Specifies the membership test operation to query
--
-- Returns the expression on the left hand side of the membership test.
--
-- Appropriate Expression_Kinds:
-- An_In_Range_Membership_Test
-- A_Not_In_Range_Membership_Test
-- An_In_Type_Membership_Test
-- A_Not_In_Type_Membership_Test
--
-- Returns Element_Kinds:
-- An_Expression
--
-------------------------------------------------------------------------------
-- 17.34 function Membership_Test_Range
-------------------------------------------------------------------------------
function Membership_Test_Range
(Expression : in Asis.Expression)
return Asis.Range_Constraint;
-------------------------------------------------------------------------------
-- Expression - Specifies the membership test operation to query
--
-- Returns the range following the reserved words "in" or "not in" from the
-- membership test.
--
-- Appropriate Expression_Kinds:
-- An_In_Range_Membership_Test
-- A_Not_In_Range_Membership_Test
--
-- Returns Constraint_Kinds:
-- A_Range_Attribute_Reference
-- A_Simple_Expression_Range
--
-------------------------------------------------------------------------------
-- 17.35 function Membership_Test_Subtype_Mark
-------------------------------------------------------------------------------
function Membership_Test_Subtype_Mark
(Expression : in Asis.Expression)
return Asis.Expression;
-------------------------------------------------------------------------------
-- Expression - Specifies the membership test operation to query
--
-- Returns the subtype_mark expression following the reserved words "in" or
-- "not in" from the membership test.
--
-- Appropriate Expression_Kinds:
-- An_In_Type_Membership_Test
-- A_Not_In_Type_Membership_Test
--
-- Returns Expression_Kinds:
-- An_Identifier
-- A_Selected_Component
-- An_Attribute_Reference
--
-------------------------------------------------------------------------------
-- 17.36 function Converted_Or_Qualified_Subtype_Mark
-------------------------------------------------------------------------------
function Converted_Or_Qualified_Subtype_Mark
(Expression : in Asis.Expression)
return Asis.Expression;
-------------------------------------------------------------------------------
-- Expression - Specifies the type conversion or qualified expression to
-- query.
--
-- Returns the subtype_mark expression that converts or qualifies the
-- expression.
--
-- Appropriate Expression_Kinds:
-- A_Type_Conversion
-- A_Qualified_Expression
--
-- Returns Expression_Kinds:
-- An_Identifier
-- A_Selected_Component
-- An_Attribute_Reference
--
-------------------------------------------------------------------------------
-- 17.37 function Converted_Or_Qualified_Expression
-------------------------------------------------------------------------------
function Converted_Or_Qualified_Expression
(Expression : in Asis.Expression)
return Asis.Expression;
-------------------------------------------------------------------------------
-- Expression - Specifies the type conversion or qualified expression to
-- query
--
-- Returns the expression being converted or qualified.
--
-- Appropriate Expression_Kinds:
-- A_Type_Conversion
-- A_Qualified_Expression
--
-- Returns Element_Kinds:
-- An_Expression
--
-------------------------------------------------------------------------------
-- 17.38 function Allocator_Subtype_Indication
-------------------------------------------------------------------------------
function Allocator_Subtype_Indication (Expression : in Asis.Expression)
return Asis.Subtype_Indication;
-------------------------------------------------------------------------------
-- Expression - Specifies the allocator expression to query
--
-- Returns the subtype indication for the object being allocated.
--
-- Appropriate Expression_Kinds:
-- An_Allocation_From_Subtype
--
-- Returns Definition_Kinds:
-- A_Subtype_Indication
--
-------------------------------------------------------------------------------
-- 17.39 function Allocator_Qualified_Expression
-------------------------------------------------------------------------------
function Allocator_Qualified_Expression (Expression : in Asis.Expression)
return Asis.Expression;
-------------------------------------------------------------------------------
-- Expression - Specifies the allocator expression to query
--
-- Returns the qualified expression for the object being allocated.
--
-- Appropriate Expression_Kinds:
-- An_Allocation_From_Qualified_Expression
--
-- Returns Expression_Kinds:
-- A_Qualified_Expression
--
-------------------------------------------------------------------------------
end Asis.Expressions;
------------------------------------------------------------------------------
-- Copyright (c) 2006-2013, Maxim Reznik
-- 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 Maxim Reznik, 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 OWNER OR CONTRIBUTORS BE
-- LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
-- CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
-- SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
-- INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
-- CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
-- ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
-- POSSIBILITY OF SUCH DAMAGE.
------------------------------------------------------------------------------
|
Rodeo-McCabe/orka | Ada | 2,510 | adb | -- SPDX-License-Identifier: Apache-2.0
--
-- Copyright (c) 2016 onox <[email protected]>
--
-- Licensed under the Apache License, Version 2.0 (the "License");
-- you may not use this file except in compliance with the License.
-- You may obtain a copy of the License at
--
-- http://www.apache.org/licenses/LICENSE-2.0
--
-- Unless required by applicable law or agreed to in writing, software
-- distributed under the License is distributed on an "AS IS" BASIS,
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-- See the License for the specific language governing permissions and
-- limitations under the License.
with GL.Types;
with Orka.Contexts;
with Orka.Rendering.Buffers;
with Orka.Rendering.Drawing;
with Orka.Rendering.Framebuffers;
with Orka.Rendering.Programs.Modules;
with Orka.Resources.Locations.Directories;
with Orka.Windows.GLFW;
procedure Orka_Test.Test_3_Module_Array is
Library : constant Orka.Contexts.Library'Class
:= Orka.Windows.GLFW.Initialize (Major => 4, Minor => 2);
Window : aliased Orka.Windows.Window'Class
:= Library.Create_Window (Width => 500, Height => 500, Resizable => False);
Context : constant Orka.Contexts.Context'Class := Window.Context;
pragma Unreferenced (Context);
use Orka.Rendering.Buffers;
use Orka.Rendering.Framebuffers;
use Orka.Rendering.Programs;
use Orka.Resources;
Location_Shaders : constant Locations.Location_Ptr
:= Locations.Directories.Create_Location ("../examples/orka/shaders");
Program_1 : Program := Create_Program (Modules.Module_Array'(
Modules.Create_Module (Location_Shaders,
FS => "test-3-module-1.frag"),
Modules.Create_Module (Location_Shaders,
VS => "test-3-module-2.vert",
FS => "test-3-module-2.frag")
));
FB_D : Framebuffer := Create_Default_Framebuffer (500, 500);
use GL.Types;
Vertices : constant Single_Array
:= (-0.5, -0.5,
0.5, -0.5,
0.0, 0.5);
-- Upload Vertices data to VBO
Buffer_1 : constant Buffer := Create_Buffer ((others => False), Vertices);
begin
FB_D.Set_Default_Values ((Color => (0.0, 0.0, 0.0, 1.0), others => <>));
Program_1.Use_Program;
Buffer_1.Bind (Shader_Storage, 0);
while not Window.Should_Close loop
Window.Process_Input;
FB_D.Clear ((Color => True, others => False));
Orka.Rendering.Drawing.Draw (Triangles, 0, 3);
Window.Swap_Buffers;
end loop;
end Orka_Test.Test_3_Module_Array;
|
AdaCore/training_material | Ada | 111 | ads | package Spark_Ada is
One : Boolean;
Two : Boolean;
Three : Boolean := One < Two;
end Spark_Ada;
|
reznikmm/matreshka | Ada | 4,019 | 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_Logarithmic_Attributes;
package Matreshka.ODF_Chart.Logarithmic_Attributes is
type Chart_Logarithmic_Attribute_Node is
new Matreshka.ODF_Chart.Abstract_Chart_Attribute_Node
and ODF.DOM.Chart_Logarithmic_Attributes.ODF_Chart_Logarithmic_Attribute
with null record;
overriding function Create
(Parameters : not null access Matreshka.DOM_Attributes.Attribute_L2_Parameters)
return Chart_Logarithmic_Attribute_Node;
overriding function Get_Local_Name
(Self : not null access constant Chart_Logarithmic_Attribute_Node)
return League.Strings.Universal_String;
end Matreshka.ODF_Chart.Logarithmic_Attributes;
|
zhmu/ananas | Ada | 3,909 | ads | ------------------------------------------------------------------------------
-- --
-- GNAT RUN-TIME COMPONENTS --
-- --
-- S Y S T E M . P A C K _ 1 0 4 --
-- --
-- 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 = 104
package System.Pack_104 is
pragma Preelaborate;
Bits : constant := 104;
type Bits_104 is mod 2 ** Bits;
for Bits_104'Size use Bits;
-- In all subprograms below, Rev_SSO is set True if the array has the
-- non-default scalar storage order.
function Get_104
(Arr : System.Address;
N : Natural;
Rev_SSO : Boolean) return Bits_104 with Inline;
-- Arr is the address of the packed array, N is the zero-based
-- subscript. This element is extracted and returned.
procedure Set_104
(Arr : System.Address;
N : Natural;
E : Bits_104;
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_104
(Arr : System.Address;
N : Natural;
Rev_SSO : Boolean) return Bits_104 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_104
(Arr : System.Address;
N : Natural;
E : Bits_104;
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_104;
|
reznikmm/matreshka | Ada | 3,684 | 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.Draw_Area_Polygon_Elements is
pragma Preelaborate;
type ODF_Draw_Area_Polygon is limited interface
and XML.DOM.Elements.DOM_Element;
type ODF_Draw_Area_Polygon_Access is
access all ODF_Draw_Area_Polygon'Class
with Storage_Size => 0;
end ODF.DOM.Draw_Area_Polygon_Elements;
|
AdaCore/langkit | Ada | 1,752 | adb | with Ada.Directories; use Ada.Directories;
with Ada.Text_IO; use Ada.Text_IO;
with Libfoolang.Analysis; use Libfoolang.Analysis;
with Libfoolang.Common; use Libfoolang.Common;
procedure Main is
procedure Check (Label : String; T : Token_Reference);
-- Try to access to the token data referenced by ``T``
-----------
-- Check --
-----------
procedure Check (Label : String; T : Token_Reference) is
begin
Put_Line (Label & ":");
begin
Put_Line (" Image: " & Image (T));
exception
when Stale_Reference_Error =>
Put_Line ("Got a Stale_Reference_Error");
end;
begin
Put_Line (" Unit: " & Simple_Name (Get_Filename (Unit (T))));
exception
when Stale_Reference_Error =>
Put_Line ("Got a Stale_Reference_Error");
end;
New_Line;
end Check;
U : Analysis_Unit;
T : Token_Reference;
begin
Put_Line ("main.adb: Running...");
-- Create an analysis unit and get a reference to one of its tokens. Then
-- perform the only legitimate use of this token reference.
U := Create_Context.Get_From_Buffer
(Filename => "foo.txt",
Buffer => "example",
Charset => "ascii");
T := U.First_Token;
Check ("Valid", T);
-- Reparse the analysis unit, making the token reference stale even though
-- the analysis context and its token data handlers are still the same.
U.Reparse (Buffer => "# example");
Check ("After reparse", T);
-- Now destroy the analysis unit (and its context), making the token
-- reference stale.
--
T := U.First_Token;
U := No_Analysis_Unit;
Check ("After context destruction", T);
Put_Line ("main.adb: Done.");
end Main;
|
reznikmm/matreshka | Ada | 3,763 | ads | ------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- Web Framework --
-- --
-- Web API Definition --
-- --
------------------------------------------------------------------------------
-- --
-- Copyright © 2014-2015, Vadim Godunko <[email protected]> --
-- All rights reserved. --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions --
-- are met: --
-- --
-- * Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- --
-- * Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in the --
-- documentation and/or other materials provided with the distribution. --
-- --
-- * Neither the name of the Vadim Godunko, IE nor the names of its --
-- contributors may be used to endorse or promote products derived from --
-- this software without specific prior written permission. --
-- --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR --
-- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
-- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED --
-- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR --
-- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF --
-- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING --
-- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS --
-- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
-- --
------------------------------------------------------------------------------
-- $Revision$ $Date$
------------------------------------------------------------------------------
-- This package provides binding to interface Comment.
------------------------------------------------------------------------------
with WebAPI.DOM.Character_Datas;
package WebAPI.DOM.Comments is
pragma Preelaborate;
type Comment is limited interface
and WebAPI.DOM.Character_Datas.Character_Data;
type Comment_Access is access all Comment'Class
with Storage_Size => 0;
end WebAPI.DOM.Comments;
|
AaronC98/PlaneSystem | Ada | 9,738 | ads | ------------------------------------------------------------------------------
-- Ada Web Server --
-- --
-- Copyright (C) 2003-2012, AdaCore --
-- --
-- This library is free software; you can redistribute it and/or modify --
-- it under terms of the GNU General Public License as published by the --
-- Free Software Foundation; either version 3, or (at your option) any --
-- later version. This library is distributed in the hope that it will be --
-- useful, but WITHOUT ANY WARRANTY; without even the implied warranty of --
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. --
-- --
-- --
-- --
-- --
-- --
-- You should have received a copy of the GNU General Public License and --
-- a copy of the GCC Runtime Library Exception along with this program; --
-- see the files COPYING3 and COPYING.RUNTIME respectively. If not, see --
-- <http://www.gnu.org/licenses/>. --
-- --
-- --
-- --
-- --
-- --
-- --
-- --
------------------------------------------------------------------------------
with Ada.Finalization;
with Ada.Strings.Unbounded;
with AWS.Headers;
with AWS.Net.Std;
with AWS.Resources.Streams;
with AWS.Utils;
package AWS.POP is
use Ada.Strings.Unbounded;
POP_Error : exception;
-- Raised by all routines when an error has been detected
-------------
-- Mailbox --
-------------
Default_POP_Port : constant := 110;
type Mailbox is private;
type Authenticate_Mode is (Clear_Text, APOP);
function Initialize
(Server_Name : String;
User : String;
Password : String;
Authenticate : Authenticate_Mode := Clear_Text;
Port : Positive := Default_POP_Port) return Mailbox;
-- Connect on the given Port to Server_Name and open User's Mailbox. This
-- mailbox object will be used to retrieve messages.
procedure Close (Mailbox : POP.Mailbox);
-- Close mailbox
function User_Name (Mailbox : POP.Mailbox) return String;
-- Returns User's name for this mailbox
function Message_Count (Mailbox : POP.Mailbox) return Natural;
-- Returns the number of messages in the user's mailbox
function Size (Mailbox : POP.Mailbox) return Natural;
-- Returns the total size in bytes of the user's mailbox
-------------
-- Message --
-------------
type Message is tagged private;
function Get
(Mailbox : POP.Mailbox;
N : Positive;
Remove : Boolean := False) return Message;
-- Retrieve Nth message from the mailbox, let the message on the mailbox
-- if Remove is False.
procedure Delete
(Mailbox : POP.Mailbox;
N : Positive);
-- Detele message number N from the mailbox
function Get_Header
(Mailbox : POP.Mailbox;
N : Positive) return Message;
-- Retrieve headers for the Nth message from the mailbox, let the message
-- on the mailbox. This is useful to build a quick summary of the mailbox.
generic
with procedure Action
(Message : POP.Message;
Index : Positive;
Quit : in out Boolean);
procedure For_Every_Message
(Mailbox : POP.Mailbox;
Remove : Boolean := False);
-- Calls Action for each message read on the mailbox, delete the message
-- from the mailbox if Remove is True. Set Quit to True to stop the
-- iterator. Index is the mailbox's message index.
generic
with procedure Action
(Message : POP.Message;
Index : Positive;
Quit : in out Boolean);
procedure For_Every_Message_Header (Mailbox : POP.Mailbox);
-- Calls Action for each message read on the mailbox. Only the headers are
-- read from the mailbox. Set Quit to True to stop the iterator. Index is
-- the mailbox's message index.
function Size (Message : POP.Message) return Natural;
-- Returns the message size in bytes
function Content (Message : POP.Message) return Unbounded_String;
-- Returns message's content as an Unbounded_String. Each line are
-- separated by CR+LF characters.
function From (Message : POP.Message) return String;
-- Returns From header value
function To (Message : POP.Message; N : Natural := 0) return String;
-- Returns the To header value. If N = 0 returns all recipients separated
-- by a coma otherwise it returns the Nth To recipient.
function To_Count (Message : POP.Message) return Natural;
-- Returns the number of To recipient for Message. returns 0 if there is
-- no To for this message.
function CC (Message : POP.Message; N : Natural := 0) return String;
-- Retruns the CC header value. If N = 0 returns all recipients separated
-- by a coma otherwise it returns the Nth CC recipient.
function CC_Count (Message : POP.Message) return Natural;
-- Returns the number of CC recipient for Message. Returns 0 if there is
-- no CC for this message.
function Subject (Message : POP.Message) return String;
-- Returns Subject header value
function Date (Message : POP.Message) return String;
-- Returns Date header value
function Header
(Message : POP.Message;
Header : String) return String;
-- Returns header value for header named Header, returns the empty string
-- if such header does not exist.
----------------
-- Attachment --
----------------
type Attachment is private;
function Attachment_Count (Message : POP.Message) return Natural;
-- Returns the number of Attachments into Message
function Get
(Message : POP.Message'Class;
Index : Positive) return Attachment;
-- Returns the Nth Attachment for Message, Raises Constraint_Error if
-- there is not such attachment.
generic
with procedure Action
(Attachment : POP.Attachment;
Index : Positive;
Quit : in out Boolean);
procedure For_Every_Attachment (Message : POP.Message);
-- Calls action for every Attachment in Message. Stop iterator if Quit is
-- set to True, Quit is set to False by default.
function Content
(Attachment : POP.Attachment)
return AWS.Resources.Streams.Stream_Access;
-- Returns Attachment's content as a memory stream. Note that the stream
-- has already been decoded. Most attachments are MIME Base64 encoded.
function Content (Attachment : POP.Attachment) return Unbounded_String;
-- Returns Attachment's content as an Unbounded_String. This routine must
-- only be used for non file attachments. Raises Constraint_Error if
-- called for a file attachment.
function Filename (Attachment : POP.Attachment) return String;
-- Returns the Attachment filename or the empty string if it is not a file
-- but an embedded message.
function Is_File (Attachment : POP.Attachment) return Boolean;
-- Returns True if Attachment is a file
procedure Write (Attachment : POP.Attachment; Directory : String);
-- Writes Attachment's file content into Directory. This must only be used
-- for a file attachment.
private
use Ada;
-------------
-- Mailbox --
-------------
type Mailbox is record
Sock : Net.Std.Socket_Type;
Name : Unbounded_String;
User_Name : Unbounded_String;
Message_Count : Natural;
Size : Natural;
end record;
type Attachment_Access is access Attachment;
-------------
-- Message --
-------------
type Message is new Finalization.Controlled with record
Ref_Count : AWS.Utils.Counter_Access;
Size : Natural;
Headers : AWS.Headers.List;
Content : Unbounded_String;
Attachments : Attachment_Access;
Last : Attachment_Access;
end record;
overriding procedure Initialize (Message : in out POP.Message);
overriding procedure Adjust (Message : in out POP.Message);
overriding procedure Finalize (Message : in out POP.Message);
----------------
-- Attachment --
----------------
type Attachment is new Finalization.Controlled with record
Ref_Count : AWS.Utils.Counter_Access;
Headers : AWS.Headers.List;
Content : AWS.Resources.Streams.Stream_Access;
Filename : Unbounded_String;
Next : Attachment_Access;
end record;
overriding procedure Initialize (Attachment : in out POP.Attachment);
overriding procedure Adjust (Attachment : in out POP.Attachment);
overriding procedure Finalize (Attachment : in out POP.Attachment);
end AWS.POP;
|
reznikmm/matreshka | Ada | 4,840 | ads | ------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- Open Document Toolkit --
-- --
-- Runtime Library Component --
-- --
------------------------------------------------------------------------------
-- --
-- Copyright © 2014, Vadim Godunko <[email protected]> --
-- All rights reserved. --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions --
-- are met: --
-- --
-- * Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- --
-- * Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in the --
-- documentation and/or other materials provided with the distribution. --
-- --
-- * Neither the name of the Vadim Godunko, IE nor the names of its --
-- contributors may be used to endorse or promote products derived from --
-- this software without specific prior written permission. --
-- --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR --
-- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
-- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED --
-- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR --
-- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF --
-- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING --
-- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS --
-- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
-- --
------------------------------------------------------------------------------
-- $Revision$ $Date$
------------------------------------------------------------------------------
with XML.DOM.Visitors;
with ODF.DOM.Table_Table_Header_Columns_Elements;
package Matreshka.ODF_Table.Table_Header_Columns_Elements is
type Table_Table_Header_Columns_Element_Node is
new Matreshka.ODF_Table.Abstract_Table_Element_Node
and ODF.DOM.Table_Table_Header_Columns_Elements.ODF_Table_Table_Header_Columns
with null record;
overriding function Create
(Parameters : not null access Matreshka.DOM_Elements.Element_L2_Parameters)
return Table_Table_Header_Columns_Element_Node;
overriding function Get_Local_Name
(Self : not null access constant Table_Table_Header_Columns_Element_Node)
return League.Strings.Universal_String;
overriding procedure Enter_Node
(Self : not null access Table_Table_Header_Columns_Element_Node;
Visitor : in out XML.DOM.Visitors.Abstract_Visitor'Class;
Control : in out XML.DOM.Visitors.Traverse_Control);
overriding procedure Leave_Node
(Self : not null access Table_Table_Header_Columns_Element_Node;
Visitor : in out XML.DOM.Visitors.Abstract_Visitor'Class;
Control : in out XML.DOM.Visitors.Traverse_Control);
overriding procedure Visit_Node
(Self : not null access Table_Table_Header_Columns_Element_Node;
Iterator : in out XML.DOM.Visitors.Abstract_Iterator'Class;
Visitor : in out XML.DOM.Visitors.Abstract_Visitor'Class;
Control : in out XML.DOM.Visitors.Traverse_Control);
end Matreshka.ODF_Table.Table_Header_Columns_Elements;
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.