repo_name
stringlengths 9
74
| language
stringclasses 1
value | length_bytes
int64 11
9.34M
| extension
stringclasses 2
values | content
stringlengths 11
9.34M
|
---|---|---|---|---|
sungyeon/drake | Ada | 1,008 | ads | pragma License (Unrestricted);
-- implementation unit specialized for Windows
package System.Native_Environment_Variables is
pragma Preelaborate;
subtype Cursor is Address;
function Value (Name : String) return String;
function Value (Name : String; Default : String) return String;
function Exists (Name : String) return Boolean;
procedure Set (Name : String; Value : String);
procedure Clear (Name : String);
procedure Clear;
function Has_Element (Position : Cursor) return Boolean;
pragma Inline (Has_Element);
function Name (Position : Cursor) return String;
function Value (Position : Cursor) return String;
Disable_Controlled : constant Boolean := False;
function Get_Block return Address;
procedure Release_Block (Block : Address);
function First (Block : Address) return Cursor;
function Next (Block : Address; Position : Cursor) return Cursor;
pragma Inline (First);
pragma Inline (Next);
end System.Native_Environment_Variables;
|
reznikmm/matreshka | Ada | 4,607 | adb | ------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- Open Document Toolkit --
-- --
-- Runtime Library Component --
-- --
------------------------------------------------------------------------------
-- --
-- Copyright © 2014, Vadim Godunko <[email protected]> --
-- All rights reserved. --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions --
-- are met: --
-- --
-- * Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- --
-- * Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in the --
-- documentation and/or other materials provided with the distribution. --
-- --
-- * Neither the name of the Vadim Godunko, IE nor the names of its --
-- contributors may be used to endorse or promote products derived from --
-- this software without specific prior written permission. --
-- --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR --
-- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
-- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED --
-- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR --
-- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF --
-- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING --
-- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS --
-- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
-- --
------------------------------------------------------------------------------
-- $Revision$ $Date$
------------------------------------------------------------------------------
with Matreshka.DOM_Documents;
with Matreshka.ODF_String_Constants;
with ODF.DOM.Iterators;
with ODF.DOM.Visitors;
package body Matreshka.ODF_Meta.Word_Count_Attributes is
------------
-- Create --
------------
overriding function Create
(Parameters : not null access Matreshka.DOM_Attributes.Attribute_L2_Parameters)
return Meta_Word_Count_Attribute_Node is
begin
return Self : Meta_Word_Count_Attribute_Node do
Matreshka.ODF_Meta.Constructors.Initialize
(Self'Unchecked_Access,
Parameters.Document,
Matreshka.ODF_String_Constants.Meta_Prefix);
end return;
end Create;
--------------------
-- Get_Local_Name --
--------------------
overriding function Get_Local_Name
(Self : not null access constant Meta_Word_Count_Attribute_Node)
return League.Strings.Universal_String
is
pragma Unreferenced (Self);
begin
return Matreshka.ODF_String_Constants.Word_Count_Attribute;
end Get_Local_Name;
begin
Matreshka.DOM_Documents.Register_Attribute
(Matreshka.ODF_String_Constants.Meta_URI,
Matreshka.ODF_String_Constants.Word_Count_Attribute,
Meta_Word_Count_Attribute_Node'Tag);
end Matreshka.ODF_Meta.Word_Count_Attributes;
|
jrcarter/Ada_GUI | Ada | 4,684 | adb | -- --
-- package Copyright (c) Dmitry A. Kazakov --
-- Strings_Edit.Streams Luebeck --
-- Implementation Spring, 2009 --
-- --
-- Last revision : 13:11 14 Sep 2019 --
-- --
-- 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;
package body Strings_Edit.Streams is
procedure Increment
( Left : in out Integer;
Right : Stream_Element_Offset
) is
pragma Inline (Increment);
begin
Left := Left + Integer (Right) * Char_Count;
end Increment;
function Get (Stream : String_Stream) return String is
begin
return Stream.Data (1..Stream.Position - 1);
end Get;
function Get_Size (Stream : String_Stream)
return Stream_Element_Count is
begin
return
( Stream_Element_Offset (Stream.Data'Last - Stream.Position + 1)
/ Char_Count
);
end Get_Size;
procedure Read
( Stream : in out String_Stream;
Item : out Stream_Element_Array;
Last : out Stream_Element_Offset
) is
begin
if Stream.Position > Stream.Length then
raise End_Error;
end if;
declare
subtype Space is Stream_Element_Array (1..Get_Size (Stream));
Data : Space;
pragma Import (Ada, Data);
for Data'Address use Stream.Data (Stream.Position)'Address;
begin
if Space'Length >= Item'Length then
Last := Item'Last;
Item := Data (1..Item'Length);
Increment (Stream.Position, Item'Length);
else
Last := Item'First + Data'Length - 1;
Item (Item'First..Last) := Data;
Stream.Position := Stream.Data'Last + 1;
end if;
end;
end Read;
procedure Rewind (Stream : in out String_Stream) is
begin
Stream.Position := 1;
end Rewind;
procedure Set (Stream : in out String_Stream; Content : String) is
begin
if Content'Length > Stream.Length then
raise Constraint_Error;
end if;
Stream.Position := Stream.Length - Content'Length + 1;
Stream.Data (Stream.Position..Stream.Length) := Content;
end Set;
procedure Write
( Stream : in out String_Stream;
Item : Stream_Element_Array
) is
begin
if Stream.Position > Stream.Length then
raise End_Error;
end if;
declare
subtype Space is Stream_Element_Array (1..Get_Size (Stream));
Data : Space;
pragma Import (Ada, Data);
for Data'Address use Stream.Data (Stream.Position)'Address;
begin
if Item'Length > Space'Length then
raise End_Error;
end if;
Data (1..Item'Length) := Item;
Increment (Stream.Position, Item'Length);
end;
end Write;
end Strings_Edit.Streams;
|
persan/protobuf-ada | Ada | 1,694 | adb | pragma Ada_2012;
package body Google.Protobuf.IO.Invalid_Protocol_Buffer_Exception is
-----------------------
-- Truncated_Message --
-----------------------
procedure Truncated_Message is
begin
raise Protocol_Buffer_Exception with Truncated_Message_Message;
end Truncated_Message;
----------------------
-- Malformed_Varint --
----------------------
procedure Malformed_Varint is
begin
raise Protocol_Buffer_Exception with Malformed_Varint_Message;
end Malformed_Varint;
---------------------
-- Invalid_End_Tag --
---------------------
procedure Invalid_End_Tag is
begin
raise Protocol_Buffer_Exception with Invalid_End_Tag_Message;
end Invalid_End_Tag;
-----------------
-- Invalid_Tag --
-----------------
procedure Invalid_Tag is
begin
raise Protocol_Buffer_Exception with Invalid_Tag_Message;
end Invalid_Tag;
-----------------------
-- Invalid_Wire_Type --
-----------------------
procedure Invalid_Wire_Type is
begin
raise Protocol_Buffer_Exception with Invalid_Wire_Type_Message;
end Invalid_Wire_Type;
----------------------------
-- Recursion_Limit_Exceed --
----------------------------
procedure Recursion_Limit_Exceeded is
begin
raise Protocol_Buffer_Exception with Recursion_Limit_Exceeded_Message;
end Recursion_Limit_Exceeded;
-------------------------
-- Size_Limit_Exceeded --
-------------------------
procedure Size_Limit_Exceeded is
begin
raise Protocol_Buffer_Exception with Size_Limit_Exceeded_Message;
end Size_Limit_Exceeded;
end Google.Protobuf.IO.Invalid_Protocol_Buffer_Exception;
|
OneWingedShark/Risi | Ada | 229 | ads | Pragma Ada_2012;
Pragma Wide_Character_Encoding( UTF8 );
With
EPL.Types;
Use
EPL.Types;
-- Edward Parse Library.
--
-- ©2015 E. Fish; All Rights Reserved.
Function EPL.Bracket( Data : String; Style : Bracket ) return String;
|
onox/orka | Ada | 2,100 | ads | -- SPDX-License-Identifier: Apache-2.0
--
-- Copyright (c) 2019 onox <[email protected]>
--
-- Licensed under the Apache License, Version 2.0 (the "License");
-- you may not use this file except in compliance with the License.
-- You may obtain a copy of the License at
--
-- http://www.apache.org/licenses/LICENSE-2.0
--
-- Unless required by applicable law or agreed to in writing, software
-- distributed under the License is distributed on an "AS IS" BASIS,
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-- See the License for the specific language governing permissions and
-- limitations under the License.
with Orka.Rendering.Buffers;
with Orka.Resources.Locations;
with Orka.Transforms.Singles.Matrices;
private with GL.Low_Level.Enums;
private with Orka.Rendering.Programs.Uniforms;
package Orka.Rendering.Debug.Coordinate_Axes is
pragma Preelaborate;
package Transforms renames Orka.Transforms.Singles.Matrices;
type Coordinate_Axes is tagged private;
function Create_Coordinate_Axes
(Location : Resources.Locations.Location_Ptr) return Coordinate_Axes;
procedure Render
(Object : in out Coordinate_Axes;
View, Proj : Transforms.Matrix4;
Transforms, Sizes : Rendering.Buffers.Bindable_Buffer'Class)
with Pre => Transforms.Length > 0 and Sizes.Length in 1 | Transforms.Length;
-- Render three coordinates axes for each transform
--
-- The buffer Transforms, containing the transform matrices, must
-- contain n matrices for n coordinate axes. This buffer controls how
-- many coordinate axes are rendered.
--
-- The buffer Sizes must contain one or n singles.
private
package LE renames GL.Low_Level.Enums;
type Coordinate_Axes is tagged record
Program : Rendering.Programs.Program;
Uniform_Visible : Programs.Uniforms.Uniform (LE.Bool_Type);
Uniform_View : Programs.Uniforms.Uniform (LE.Single_Matrix4);
Uniform_Proj : Programs.Uniforms.Uniform (LE.Single_Matrix4);
end record;
end Orka.Rendering.Debug.Coordinate_Axes;
|
ellamosi/Ada_BMP_Library | Ada | 2,836 | ads | ------------------------------------------------------------------------------
-- --
-- Copyright (C) 2017, AdaCore --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions are --
-- met: --
-- 1. Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- 2. Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in --
-- the documentation and/or other materials provided with the --
-- distribution. --
-- 3. Neither the name of the copyright holder nor the names of its --
-- contributors may be used to endorse or promote products derived --
-- from this software without specific prior written permission. --
-- --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR --
-- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
-- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT --
-- LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, --
-- DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY --
-- THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT --
-- (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE --
-- OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
-- --
------------------------------------------------------------------------------
with Ada.Command_Line;
with Ada.Directories;
with Filesystem;
package Test_Directories is
Program_Abspath : constant String := Filesystem.Join
(Ada.Directories.Current_Directory, Ada.Command_Line.Command_Name);
-- Absolute path of the test executable
Test_Dir : constant String := Ada.Directories.Containing_Directory
(Ada.Directories.Containing_Directory (Program_Abspath));
-- Absolute path to the test directory
end Test_Directories;
|
stcarrez/ada-servlet | Ada | 930 | ads | -----------------------------------------------------------------------
-- servlet-cookies -- Servlet Cookies
-- Copyright (C) 2011, 2012 Stephane Carrez
-- Written by Stephane Carrez ([email protected])
--
-- Licensed under the Apache License, Version 2.0 (the "License");
-- you may not use this file except in compliance with the License.
-- You may obtain a copy of the License at
--
-- http://www.apache.org/licenses/LICENSE-2.0
--
-- Unless required by applicable law or agreed to in writing, software
-- distributed under the License is distributed on an "AS IS" BASIS,
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-- See the License for the specific language governing permissions and
-- limitations under the License.
-----------------------------------------------------------------------
with Util.Http.Cookies;
package Servlet.Cookies renames Util.Http.Cookies;
|
zhmu/ananas | Ada | 9,765 | adb | ------------------------------------------------------------------------------
-- --
-- GNAT RUN-TIME COMPONENTS --
-- --
-- SYSTEM.PUT_IMAGES --
-- --
-- B o d y --
-- --
-- Copyright (C) 2020-2022, Free Software Foundation, Inc. --
-- --
-- GNAT is free software; you can redistribute it and/or modify it under --
-- terms of the GNU General Public License as published by the Free Soft- --
-- ware Foundation; either version 3, or (at your option) any later ver- --
-- sion. GNAT is distributed in the hope that it will be useful, but WITH- --
-- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY --
-- or FITNESS FOR A PARTICULAR PURPOSE. --
-- --
-- As a special exception under Section 7 of GPL version 3, you are granted --
-- additional permissions described in the GCC Runtime Library Exception, --
-- version 3.1, as published by the Free Software Foundation. --
-- --
-- You should have received a copy of the GNU General Public License and --
-- a copy of the GCC Runtime Library Exception along with this program; --
-- see the files COPYING3 and COPYING.RUNTIME respectively. If not, see --
-- <http://www.gnu.org/licenses/>. --
-- --
-- GNAT was originally developed by the GNAT team at New York University. --
-- Extensive contributions were provided by Ada Core Technologies Inc. --
-- --
------------------------------------------------------------------------------
with Ada.Strings.Text_Buffers.Utils;
use Ada.Strings.Text_Buffers;
use Ada.Strings.Text_Buffers.Utils;
with Unchecked_Conversion;
package body System.Put_Images is
generic
type Integer_Type is range <>;
type Unsigned_Type is mod <>;
Base : Unsigned_Type;
package Generic_Integer_Images is
pragma Assert (Integer_Type'Size = Unsigned_Type'Size);
pragma Assert (Base in 2 .. 36);
procedure Put_Image (S : in out Sink'Class; X : Integer_Type);
procedure Put_Image (S : in out Sink'Class; X : Unsigned_Type);
private
subtype Digit is Unsigned_Type range 0 .. Base - 1;
end Generic_Integer_Images;
package body Generic_Integer_Images is
A : constant := Character'Pos ('a');
Z : constant := Character'Pos ('0');
function Digit_To_Character (X : Digit) return Character is
(Character'Val (if X < 10 then X + Z else X + A - 10));
procedure Put_Digits (S : in out Sink'Class; X : Unsigned_Type);
-- Put just the digits of X, without any leading minus sign or space.
procedure Put_Digits (S : in out Sink'Class; X : Unsigned_Type) is
begin
if X >= Base then
Put_Digits (S, X / Base); -- recurse
Put_7bit (S, Digit_To_Character (X mod Base));
else
Put_7bit (S, Digit_To_Character (X));
end if;
end Put_Digits;
procedure Put_Image (S : in out Sink'Class; X : Integer_Type) is
begin
-- Put the space or the minus sign, then pass the absolute value to
-- Put_Digits.
if X >= 0 then
Put_7bit (S, ' ');
Put_Digits (S, Unsigned_Type (X));
else
Put_7bit (S, '-');
Put_Digits (S, -Unsigned_Type'Mod (X));
-- Convert to Unsigned_Type before negating, to avoid overflow
-- on Integer_Type'First.
end if;
end Put_Image;
procedure Put_Image (S : in out Sink'Class; X : Unsigned_Type) is
begin
Put_7bit (S, ' ');
Put_Digits (S, X);
end Put_Image;
end Generic_Integer_Images;
package Integer_Images is new Generic_Integer_Images
(Integer, Unsigned, Base => 10);
package LL_Integer_Images is new Generic_Integer_Images
(Long_Long_Integer, Long_Long_Unsigned, Base => 10);
package LLL_Integer_Images is new Generic_Integer_Images
(Long_Long_Long_Integer, Long_Long_Long_Unsigned, Base => 10);
procedure Put_Image_Integer (S : in out Sink'Class; X : Integer)
renames Integer_Images.Put_Image;
procedure Put_Image_Long_Long_Integer
(S : in out Sink'Class; X : Long_Long_Integer)
renames LL_Integer_Images.Put_Image;
procedure Put_Image_Long_Long_Long_Integer
(S : in out Sink'Class; X : Long_Long_Long_Integer)
renames LLL_Integer_Images.Put_Image;
procedure Put_Image_Unsigned (S : in out Sink'Class; X : Unsigned)
renames Integer_Images.Put_Image;
procedure Put_Image_Long_Long_Unsigned
(S : in out Sink'Class; X : Long_Long_Unsigned)
renames LL_Integer_Images.Put_Image;
procedure Put_Image_Long_Long_Long_Unsigned
(S : in out Sink'Class; X : Long_Long_Long_Unsigned)
renames LLL_Integer_Images.Put_Image;
type Signed_Address is range
-2**(Standard'Address_Size - 1) .. 2**(Standard'Address_Size - 1) - 1;
type Unsigned_Address is mod 2**Standard'Address_Size;
package Hex is new Generic_Integer_Images
(Signed_Address, Unsigned_Address, Base => 16);
generic
type Designated (<>) is private;
type Pointer is access all Designated;
procedure Put_Image_Pointer
(S : in out Sink'Class; X : Pointer; Type_Kind : String);
procedure Put_Image_Pointer
(S : in out Sink'Class; X : Pointer; Type_Kind : String)
is
function Cast is new Unchecked_Conversion
(System.Address, Unsigned_Address);
begin
if X = null then
Put_UTF_8 (S, "null");
else
Put_UTF_8 (S, "(");
Put_UTF_8 (S, Type_Kind);
Hex.Put_Image (S, Cast (X.all'Address));
Put_UTF_8 (S, ")");
end if;
end Put_Image_Pointer;
procedure Thin_Instance is new Put_Image_Pointer (Byte, Thin_Pointer);
procedure Put_Image_Thin_Pointer
(S : in out Sink'Class; X : Thin_Pointer)
is
begin
Thin_Instance (S, X, "access");
end Put_Image_Thin_Pointer;
procedure Fat_Instance is new Put_Image_Pointer (Byte_String, Fat_Pointer);
procedure Put_Image_Fat_Pointer
(S : in out Sink'Class; X : Fat_Pointer)
is
begin
Fat_Instance (S, X, "access");
end Put_Image_Fat_Pointer;
procedure Put_Image_Access_Subp (S : in out Sink'Class; X : Thin_Pointer) is
begin
Thin_Instance (S, X, "access subprogram");
end Put_Image_Access_Subp;
procedure Put_Image_Access_Prot_Subp
(S : in out Sink'Class; X : Thin_Pointer)
is
begin
Thin_Instance (S, X, "access protected subprogram");
end Put_Image_Access_Prot_Subp;
procedure Put_Image_String (S : in out Sink'Class; X : String) is
begin
Put_UTF_8 (S, """");
for C of X loop
if C = '"' then
Put_UTF_8 (S, """");
end if;
Put_Character (S, C);
end loop;
Put_UTF_8 (S, """");
end Put_Image_String;
procedure Put_Image_Wide_String (S : in out Sink'Class; X : Wide_String) is
begin
Put_UTF_8 (S, """");
for C of X loop
if C = '"' then
Put_UTF_8 (S, """");
end if;
Put_Wide_Character (S, C);
end loop;
Put_UTF_8 (S, """");
end Put_Image_Wide_String;
procedure Put_Image_Wide_Wide_String
(S : in out Sink'Class; X : Wide_Wide_String) is
begin
Put_UTF_8 (S, """");
for C of X loop
if C = '"' then
Put_UTF_8 (S, """");
end if;
Put_Wide_Wide_Character (S, C);
end loop;
Put_UTF_8 (S, """");
end Put_Image_Wide_Wide_String;
procedure Array_Before (S : in out Sink'Class) is
begin
New_Line (S);
Put_7bit (S, '[');
Increase_Indent (S, 1);
end Array_Before;
procedure Array_Between (S : in out Sink'Class) is
begin
Put_7bit (S, ',');
New_Line (S);
end Array_Between;
procedure Array_After (S : in out Sink'Class) is
begin
Decrease_Indent (S, 1);
Put_7bit (S, ']');
end Array_After;
procedure Simple_Array_Between (S : in out Sink'Class) is
begin
Put_7bit (S, ',');
if Column (S) > 60 then
New_Line (S);
else
Put_7bit (S, ' ');
end if;
end Simple_Array_Between;
procedure Record_Before (S : in out Sink'Class) is
begin
New_Line (S);
Put_7bit (S, '(');
Increase_Indent (S, 1);
end Record_Before;
procedure Record_Between (S : in out Sink'Class) is
begin
Put_7bit (S, ',');
New_Line (S);
end Record_Between;
procedure Record_After (S : in out Sink'Class) is
begin
Decrease_Indent (S, 1);
Put_7bit (S, ')');
end Record_After;
procedure Put_Arrow (S : in out Sink'Class) is
begin
Put_UTF_8 (S, " => ");
end Put_Arrow;
procedure Put_Image_Unknown (S : in out Sink'Class; Type_Name : String) is
begin
Put_UTF_8 (S, "{");
Put (S, Type_Name);
Put_UTF_8 (S, " object}");
end Put_Image_Unknown;
end System.Put_Images;
|
DrenfongWong/tkm-rpc | Ada | 429 | ads | with Ada.Unchecked_Conversion;
package Tkmrpc.Response.Ike.Esa_Create_First.Convert is
function To_Response is new Ada.Unchecked_Conversion (
Source => Esa_Create_First.Response_Type,
Target => Response.Data_Type);
function From_Response is new Ada.Unchecked_Conversion (
Source => Response.Data_Type,
Target => Esa_Create_First.Response_Type);
end Tkmrpc.Response.Ike.Esa_Create_First.Convert;
|
reznikmm/gela | Ada | 224 | ads | package AG_Tools.Element_Generators is
procedure Generate_Elements
(G : Anagram.Grammars.Grammar_Access);
procedure Generate_Factory
(G : Anagram.Grammars.Grammar_Access);
end AG_Tools.Element_Generators;
|
burratoo/Acton | Ada | 3,427 | ads | ------------------------------------------------------------------------------------------
-- --
-- OAK COMPONENTS --
-- --
-- OAK.STORAGE.GENERIC_POOL --
-- --
-- Copyright (C) 2014-2021, Patrick Bernardi --
-- --
------------------------------------------------------------------------------------------
-- This package provides a generic storage pool built around an array. Each
-- instantiation creates a new storage pool (or table) to store the specific
-- kind of item in it. The size of the pool is given by the id type of that
-- kind of Item. Clients have direct access to the array making up the pool,
-- with access to its elements through the provided Item_Id_Type.
generic
type Item_Type is private;
type Item_Id_Type is mod <>;
-- package Oak.Storage.Generic_Pool with Preelaborate is
package Oak.Storage.Generic_Pool is
pragma Preelaborate;
type Pool_Type is array (Item_Id_Type) of Item_Type;
Item_Pool : Pool_Type;
-- Storage used to store Items.
procedure Allocate_An_Item (Item : out Item_Id_Type)
with Pre => Has_Space and Is_Storage_Ready;
-- Allocates space in the pool for a new item and returns the Item Id.
-- Callers should ensure that there is space free in the pool before
-- calling otherwise Item_Pool_Capacity_Error will be raised.
procedure Deallocate_Item (Id : in Item_Id_Type);
-- Dellocates the storage associated with the Id.
function Has_Space return Boolean
with Pre => Is_Storage_Ready;
-- Returns true if there is room in the pool.
function Is_Storage_Ready return Boolean
with Ghost;
-- Returns true if the Item pool has been setup.
procedure Setup_Storage
with Post => Is_Storage_Ready;
-- Sets up the Item pool.
private
type Id_List is array (Item_Id_Type) of Item_Id_Type;
Storage_Track : Id_List;
No_Item : constant Item_Id_Type'Base := Item_Id_Type'First;
Free_List : Item_Id_Type := No_Item;
-- The first node in the free list. This list consists of free nodes
-- that are not part of the bulk free store of the array, since they
-- have been allocated and subsquently deallocated.
--
-- No_Node means the list is empty.
Bulk_Free : Item_Id_Type := No_Item + 1;
-- The first node in the bulk free store. This is the free area on the
-- right side of the array that has not been allocate. The bulk store
-- saves from having to populate the free list in the first place, which
-- may be an expensive operation (it is an O (n) operation).
--
-- No_Node means bulk free store is empty.
Storage_Ready : Boolean := False;
-- Signals that the storage has been setup and is ready to allocate new
-- Items.
function Has_Space return Boolean is
(Free_List = No_Item and Bulk_Free = No_Item);
function Is_Storage_Ready return Boolean is (Storage_Ready);
end Oak.Storage.Generic_Pool;
|
msrLi/portingSources | Ada | 949 | adb | -- Copyright 2008-2014 Free Software Foundation, Inc.
--
-- This program is free software; you can redistribute it and/or modify
-- it under the terms of the GNU General Public License as published by
-- the Free Software Foundation; either version 3 of the License, or
-- (at your option) any later version.
--
-- This program is distributed in the hope that it will be useful,
-- but WITHOUT ANY WARRANTY; without even the implied warranty of
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-- GNU General Public License for more details.
--
-- You should have received a copy of the GNU General Public License
-- along with this program. If not, see <http://www.gnu.org/licenses/>.
package body Pck is
type Empty is record
Month : Integer;
Year : Integer;
end record;
function Create return Wrap is
begin
return (E => new Empty'(Month => 8, Year => 1974));
end Create;
end Pck;
|
docandrew/troodon | Ada | 54,102 | adb | -- A PNG stream is made of several "chunks" (see type PNG_Chunk_tag).
-- The image itself is contained in the IDAT chunk(s).
--
-- Steps for decoding an image (step numbers are from the ISO standard):
--
-- 10: Inflate deflated data; at each output buffer (slide),
-- process with step 9.
-- 9: Read filter code (row begin), or unfilter bytes, go with step 8
-- 8: Display pixels these bytes represent;
-- eventually, locate the interlaced image current point
--
-- Reference: Portable Network Graphics (PNG) Specification (Second Edition)
-- ISO/IEC 15948:2003 (E)
-- W3C Recommendation 10 November 2003
-- http://www.w3.org/TR/PNG/
--
with GID.Buffering, GID.Decoding_PNG.Huffman;
with Ada.Text_IO;
package body GID.Decoding_PNG is
generic
type Number is mod <>;
procedure Big_endian_number(
from : in out Input_buffer;
n : out Number
);
pragma Inline(Big_endian_number);
procedure Big_endian_number(
from : in out Input_buffer;
n : out Number
)
is
b: U8;
begin
n:= 0;
for i in 1..Number'Size/8 loop
Buffering.Get_Byte(from, b);
n:= n * 256 + Number(b);
end loop;
end Big_endian_number;
procedure Big_endian is new Big_endian_number( U32 );
----------
-- Read --
----------
procedure Read (image: in out Image_descriptor; ch: out Chunk_head) is
str4: String(1..4);
b: U8;
begin
Big_endian(image.buffer, ch.length);
for i in str4'Range loop
Buffering.Get_Byte(image.buffer, b);
str4(i):= Character'Val(b);
end loop;
begin
ch.kind:= PNG_Chunk_tag'Value(str4);
if some_trace then
Ada.Text_IO.Put_Line(
"Chunk [" & str4 &
"], length:" & U32'Image(ch.length)
);
end if;
exception
when Constraint_Error =>
raise error_in_image_data with
"PNG chunk unknown: " &
Integer'Image(Character'Pos(str4(1))) &
Integer'Image(Character'Pos(str4(2))) &
Integer'Image(Character'Pos(str4(3))) &
Integer'Image(Character'Pos(str4(4))) &
" (" & str4 & ')';
end;
end Read;
package CRC32 is
procedure Init( CRC: out Unsigned_32 );
function Final( CRC: Unsigned_32 ) return Unsigned_32;
procedure Update( CRC: in out Unsigned_32; InBuf: Byte_array );
pragma Inline( Update );
end CRC32;
package body CRC32 is
CRC32_Table : array( Unsigned_32'(0)..255 ) of Unsigned_32;
procedure Prepare_table is
-- CRC-32 algorithm, ISO-3309
Seed: constant:= 16#EDB88320#;
l: Unsigned_32;
begin
for i in CRC32_Table'Range loop
l:= i;
for bit in 0..7 loop
if (l and 1) = 0 then
l:= Shift_Right(l,1);
else
l:= Shift_Right(l,1) xor Seed;
end if;
end loop;
CRC32_Table(i):= l;
end loop;
end Prepare_table;
procedure Update( CRC: in out Unsigned_32; InBuf: Byte_array ) is
local_CRC: Unsigned_32;
begin
local_CRC:= CRC ;
for i in InBuf'Range loop
local_CRC :=
CRC32_Table( 16#FF# and ( local_CRC xor Unsigned_32( InBuf(i) ) ) )
xor
Shift_Right( local_CRC , 8 );
end loop;
CRC:= local_CRC;
end Update;
table_empty: Boolean:= True;
procedure Init( CRC: out Unsigned_32 ) is
begin
if table_empty then
Prepare_table;
table_empty:= False;
end if;
CRC:= 16#FFFF_FFFF#;
end Init;
function Final( CRC: Unsigned_32 ) return Unsigned_32 is
begin
return not CRC;
end Final;
end CRC32;
----------
-- Load --
----------
procedure Load (image: in out Image_descriptor) is
----------------------
-- Load_specialized --
----------------------
generic
-- These values are invariant through the whole picture,
-- so we can make them generic parameters. As a result, all
-- "if", "case", etc. using them at the center of the decoding
-- are optimized out at compile-time.
interlaced : Boolean;
png_bits_per_pixel : Positive;
bytes_to_unfilter : Positive;
-- ^ amount of bytes to unfilter at a time
-- = Integer'Max(1, bits_per_pixel / 8);
subformat_id : Natural;
procedure Load_specialized;
--
procedure Load_specialized is
use GID.Buffering;
subtype Mem_row_bytes_array is Byte_array (0 .. Integer (image.width) * 8);
--
mem_row_bytes: array(0..1) of Mem_row_bytes_array;
-- We need to memorize two image rows, for un-filtering
curr_row: Natural:= 1;
-- either current is 1 and old is 0, or the reverse
subtype X_range is Integer range -1 .. Integer (image.width) - 1;
subtype Y_range is Integer range 0 .. Integer (image.height) - 1;
-- X position -1 is for the row's filter methode code
x: X_range:= X_range'First;
y: Y_range:= Y_range'First;
x_max: X_range; -- for non-interlaced images: = X_range'Last
y_max: Y_range; -- for non-interlaced images: = Y_range'Last
pass: Positive range 1..7:= 1;
--------------------------
-- ** 9: Unfiltering ** --
--------------------------
-- http://www.w3.org/TR/PNG/#9Filters
type Filter_method_0 is (None, Sub, Up, Average, Paeth);
current_filter: Filter_method_0;
procedure Unfilter_bytes(
f: in Byte_array; -- filtered
u: out Byte_array -- unfiltered
)
is
pragma Inline(Unfilter_bytes);
-- Byte positions (f is the byte to be unfiltered):
--
-- c b
-- a f
a,b,c, p,pa,pb,pc,pr: Integer;
j: Integer:= 0;
begin
if full_trace and then x = 0 then
if y = 0 then
Ada.Text_IO.New_Line;
end if;
Ada.Text_IO.Put_Line(
"row" & Integer'Image(y) & ": filter= " &
Filter_method_0'Image(current_filter)
);
end if;
--
-- !! find a way to have f99n0g04.png decoded correctly...
-- seems a filter issue.
--
case current_filter is
when None =>
-- Recon(x) = Filt(x)
u:= f;
when Sub =>
-- Recon(x) = Filt(x) + Recon(a)
if x > 0 then
for i in f'Range loop
u(u'First+j):= f(i) + mem_row_bytes(curr_row)((x-1)*bytes_to_unfilter+j);
j:= j + 1;
end loop;
else
u:= f;
end if;
when Up =>
-- Recon(x) = Filt(x) + Recon(b)
if y > 0 then
for i in f'Range loop
u(u'First+j):= f(i) + mem_row_bytes(1-curr_row)(x*bytes_to_unfilter+j);
j:= j + 1;
end loop;
else
u:= f;
end if;
when Average =>
-- Recon(x) = Filt(x) + floor((Recon(a) + Recon(b)) / 2)
for i in f'Range loop
if x > 0 then
a:= Integer(mem_row_bytes(curr_row)((x-1)*bytes_to_unfilter+j));
else
a:= 0;
end if;
if y > 0 then
b:= Integer(mem_row_bytes(1-curr_row)(x*bytes_to_unfilter+j));
else
b:= 0;
end if;
u(u'First+j):= U8((Integer(f(i)) + (a+b)/2) mod 256);
j:= j + 1;
end loop;
when Paeth =>
-- Recon(x) = Filt(x) + PaethPredictor(Recon(a), Recon(b), Recon(c))
for i in f'Range loop
if x > 0 then
a:= Integer(mem_row_bytes(curr_row)((x-1)*bytes_to_unfilter+j));
else
a:= 0;
end if;
if y > 0 then
b:= Integer(mem_row_bytes(1-curr_row)(x*bytes_to_unfilter+j));
else
b:= 0;
end if;
if x > 0 and y > 0 then
c:= Integer(mem_row_bytes(1-curr_row)((x-1)*bytes_to_unfilter+j));
else
c:= 0;
end if;
p := a + b - c;
pa:= abs(p - a);
pb:= abs(p - b);
pc:= abs(p - c);
if pa <= pb and then pa <= pc then
pr:= a;
elsif pb <= pc then
pr:= b;
else
pr:= c;
end if;
u(u'First+j):= f(i) + U8(pr);
j:= j + 1;
end loop;
end case;
j:= 0;
for i in u'Range loop
mem_row_bytes(curr_row)(x*bytes_to_unfilter+j):= u(i);
j:= j + 1;
end loop;
-- if u'Length /= bytes_to_unfilter then
-- raise Constraint_Error;
-- end if;
end Unfilter_bytes;
filter_stat: array(Filter_method_0) of Natural:= (others => 0);
----------------------------------------------
-- ** 8: Interlacing and pass extraction ** --
----------------------------------------------
-- http://www.w3.org/TR/PNG/#8Interlace
-- Output bytes from decompression
--
procedure Output_uncompressed(
data : in Byte_array;
reject: out Natural
-- amount of bytes to be resent here next time,
-- in order to have a full multi-byte pixel
)
is
-- Display of pixels coded on 8 bits per channel in the PNG stream
procedure Out_Pixel_8(br, bg, bb, ba: U8) is
pragma Inline(Out_Pixel_8);
function Times_257(x: Primary_color_range) return Primary_color_range is
pragma Inline(Times_257);
begin
return 16 * (16 * x) + x; -- this is 257 * x, = 16#0101# * x
-- Numbers 8-bit -> no OA warning at instanciation. Returns x if type Primary_color_range is mod 2**8.
end Times_257;
begin
case Primary_color_range'Modulus is
when 256 =>
Put_Pixel(
Primary_color_range(br),
Primary_color_range(bg),
Primary_color_range(bb),
Primary_color_range(ba)
);
when 65_536 =>
Put_Pixel(
Times_257(Primary_color_range(br)),
Times_257(Primary_color_range(bg)),
Times_257(Primary_color_range(bb)),
Times_257(Primary_color_range(ba))
-- Times_257 makes max intensity FF go to FFFF
);
when others =>
raise invalid_primary_color_range with "PNG: color range not supported";
end case;
end Out_Pixel_8;
procedure Out_Pixel_Palette(ix: U8) is
pragma Inline(Out_Pixel_Palette);
color_idx: constant Natural:= Integer(ix);
begin
Out_Pixel_8(
image.palette(color_idx).red,
image.palette(color_idx).green,
image.palette(color_idx).blue,
255
);
end Out_Pixel_Palette;
-- Display of pixels coded on 16 bits per channel in the PNG stream
procedure Out_Pixel_16(br, bg, bb, ba: U16) is
pragma Inline(Out_Pixel_16);
begin
case Primary_color_range'Modulus is
when 256 =>
Put_Pixel(
Primary_color_range(br / 256),
Primary_color_range(bg / 256),
Primary_color_range(bb / 256),
Primary_color_range(ba / 256)
);
when 65_536 =>
Put_Pixel(
Primary_color_range(br),
Primary_color_range(bg),
Primary_color_range(bb),
Primary_color_range(ba)
);
when others =>
raise invalid_primary_color_range with "PNG: color range not supported";
end case;
end Out_Pixel_16;
procedure Inc_XY is
pragma Inline(Inc_XY);
xm, ym: Integer;
begin
if x < x_max then
x:= x + 1;
if interlaced then
-- Position of pixels depending on pass:
--
-- 1 6 4 6 2 6 4 6
-- 7 7 7 7 7 7 7 7
-- 5 6 5 6 5 6 5 6
-- 7 7 7 7 7 7 7 7
-- 3 6 4 6 3 6 4 6
-- 7 7 7 7 7 7 7 7
-- 5 6 5 6 5 6 5 6
-- 7 7 7 7 7 7 7 7
case pass is
when 1 =>
Set_X_Y( x*8, Y_range'Last - y*8);
when 2 =>
Set_X_Y(4 + x*8, Y_range'Last - y*8);
when 3 =>
Set_X_Y( x*4, Y_range'Last - 4 - y*8);
when 4 =>
Set_X_Y(2 + x*4, Y_range'Last - y*4);
when 5 =>
Set_X_Y( x*2, Y_range'Last - 2 - y*4);
when 6 =>
Set_X_Y(1 + x*2, Y_range'Last - y*2);
when 7 =>
null; -- nothing to to, pixel are contiguous
end case;
end if;
else
x:= X_range'First; -- New row
if y < y_max then
y:= y + 1;
curr_row:= 1-curr_row; -- swap row index for filtering
if not interlaced then
Feedback((y*100) / Integer (image.height));
end if;
elsif interlaced then -- last row has beed displayed
while pass < 7 loop
pass:= pass + 1;
y:= 0;
case pass is
when 1 =>
null;
when 2 =>
xm:= (Integer (image.width) + 3)/8 - 1;
ym:= (Integer (image.height) + 7)/8 - 1;
when 3 =>
xm:= (Integer (image.width) + 3)/4 - 1;
ym:= (Integer (image.height) + 3)/8 - 1;
when 4 =>
xm:= (Integer (image.width) + 1)/4 - 1;
ym:= (Integer (image.height) + 3)/4 - 1;
when 5 =>
xm:= (Integer (image.width) + 1)/2 - 1;
ym:= (Integer (image.height) + 1)/4 - 1;
when 6 =>
xm:= (Integer (image.width) )/2 - 1;
ym:= (Integer (image.height) + 1)/2 - 1;
when 7 =>
xm:= Integer (image.width) - 1;
ym:= Integer (image.height) / 2 - 1;
end case;
if xm >=0 and xm <= X_range'Last and ym in Y_range then
-- This pass is not empty (otherwise, we will continue
-- to the next one, if any).
x_max:= xm;
y_max:= ym;
exit;
end if;
end loop;
end if;
end if;
end Inc_XY;
uf: Byte_array(0..15); -- unfiltered bytes for a pixel
w1, w2: U16;
i: Integer;
begin
if some_trace then
Ada.Text_IO.Put("[UO]");
end if;
-- Depending on the row size, bpp, etc., we can have
-- several rows, or less than one, being displayed
-- with the present uncompressed data batch.
--
i:= data'First;
if i > data'Last then
reject:= 0;
return; -- data is empty, do nothing
end if;
--
-- Main loop over data
--
loop
if x = X_range'First then -- pseudo-column for filter method
exit when i > data'Last;
begin
current_filter:= Filter_method_0'Val(data(i));
if some_trace then
filter_stat(current_filter):= filter_stat(current_filter) + 1;
end if;
exception
when Constraint_Error =>
raise error_in_image_data with
"PNG: wrong filter code, row #" &
Integer'Image(y) & " code:" & U8'Image(data(i));
end;
if interlaced then
case pass is
when 1..6 =>
null; -- Set_X_Y for each pixel
when 7 =>
Set_X_Y(0, Y_range'Last - 1 - y*2);
end case;
else
Set_X_Y(0, Y_range'Last - y);
end if;
i:= i + 1;
else -- normal pixel
--
-- We quit the loop if all data has been used (except for an
-- eventual incomplete pixel)
exit when i > data'Last - (bytes_to_unfilter - 1);
-- NB, for per-channel bpp < 8:
-- 7.2 Scanlines - some low-order bits of the
-- last byte of a scanline may go unused.
case subformat_id is
when 0 =>
-----------------------
-- Type 0: Greyscale --
-----------------------
case png_bits_per_pixel is
when 1 | 2 | 4 =>
Unfilter_bytes(data(i..i), uf(0..0));
i:= i + 1;
declare
b: U8;
shift: Integer:= 8 - png_bits_per_pixel;
max: constant U8:= U8(Shift_Left(Unsigned_32'(1), png_bits_per_pixel)-1);
-- Scaling factor to obtain the correct color value on a 0..255 range.
-- The division is exact in all cases (bpp=8,4,2,1),
-- since 255 = 3 * 5 * 17 and max = 255, 15, 3 or 1.
-- This factor ensures: 0 -> 0, max -> 255
factor: constant U8:= 255 / max;
begin
-- loop through the number of pixels in this byte:
for k in reverse 1..8/png_bits_per_pixel loop
b:= (max and U8(Shift_Right(Unsigned_8(uf(0)), shift))) * factor;
shift:= shift - png_bits_per_pixel;
Out_Pixel_8(b, b, b, 255);
exit when x >= x_max or k = 1;
Inc_XY;
end loop;
end;
when 8 =>
-- NB: with bpp as generic param, this case could be merged
-- into the general 1,2,4[,8] case without loss of performance
-- if the compiler is smart enough to simplify the code, given
-- the value of bits_per_pixel.
-- But we let it here for two reasons:
-- 1) a compiler might be not smart enough
-- 2) it is a very simple case, perhaps helpful for
-- understanding the algorithm.
Unfilter_bytes(data(i..i), uf(0..0));
i:= i + 1;
Out_Pixel_8(uf(0), uf(0), uf(0), 255);
when 16 =>
Unfilter_bytes(data(i..i+1), uf(0..1));
i:= i + 2;
w1:= U16(uf(0)) * 256 + U16(uf(1));
Out_Pixel_16(w1, w1, w1, 65535);
when others =>
null; -- undefined in PNG standard
end case;
when 2 =>
-----------------
-- Type 2: RGB --
-----------------
case png_bits_per_pixel is
when 24 =>
Unfilter_bytes(data(i..i+2), uf(0..2));
i:= i + 3;
Out_Pixel_8(uf(0), uf(1), uf(2), 255);
when 48 =>
Unfilter_bytes(data(i..i+5), uf(0..5));
i:= i + 6;
Out_Pixel_16(
U16(uf(0)) * 256 + U16(uf(1)),
U16(uf(2)) * 256 + U16(uf(3)),
U16(uf(4)) * 256 + U16(uf(5)),
65_535
);
when others =>
null;
end case;
when 3 =>
------------------------------
-- Type 3: RGB with palette --
------------------------------
Unfilter_bytes(data(i..i), uf(0..0));
i:= i + 1;
case png_bits_per_pixel is
when 1 | 2 | 4 =>
declare
shift: Integer:= 8 - png_bits_per_pixel;
max: constant U8:= U8(Shift_Left(Unsigned_32'(1), png_bits_per_pixel)-1);
begin
-- loop through the number of pixels in this byte:
for k in reverse 1..8/png_bits_per_pixel loop
Out_Pixel_Palette(max and U8(Shift_Right(Unsigned_8(uf(0)), shift)));
shift:= shift - png_bits_per_pixel;
exit when x >= x_max or k = 1;
Inc_XY;
end loop;
end;
when 8 =>
-- Same remark for this case (8bpp) as
-- within Image Type 0 / Greyscale above
Out_Pixel_Palette(uf(0));
when others =>
null;
end case;
when 4 =>
-------------------------------
-- Type 4: Greyscale & Alpha --
-------------------------------
case png_bits_per_pixel is
when 16 =>
Unfilter_bytes(data(i..i+1), uf(0..1));
i:= i + 2;
Out_Pixel_8(uf(0), uf(0), uf(0), uf(1));
when 32 =>
Unfilter_bytes(data(i..i+3), uf(0..3));
i:= i + 4;
w1:= U16(uf(0)) * 256 + U16(uf(1));
w2:= U16(uf(2)) * 256 + U16(uf(3));
Out_Pixel_16(w1, w1, w1, w2);
when others =>
null; -- undefined in PNG standard
end case;
when 6 =>
------------------
-- Type 6: RGBA --
------------------
case png_bits_per_pixel is
when 32 =>
Unfilter_bytes(data(i..i+3), uf(0..3));
i:= i + 4;
Out_Pixel_8(uf(0), uf(1), uf(2), uf(3));
when 64 =>
Unfilter_bytes(data(i..i+7), uf(0..7));
i:= i + 8;
Out_Pixel_16(
U16(uf(0)) * 256 + U16(uf(1)),
U16(uf(2)) * 256 + U16(uf(3)),
U16(uf(4)) * 256 + U16(uf(5)),
U16(uf(6)) * 256 + U16(uf(7))
);
when others =>
null;
end case;
when others =>
null; -- Unknown - exception already raised at header level
end case;
end if;
Inc_XY;
end loop;
-- i is between data'Last-(bytes_to_unfilter-2) and data'Last+1
reject:= (data'Last + 1) - i;
if reject > 0 then
if some_trace then
Ada.Text_IO.Put("[rj" & Integer'Image(reject) & ']');
end if;
end if;
end Output_uncompressed;
ch: Chunk_head;
-- Out of some intelligent design, there might be an IDAT chunk
-- boundary anywhere inside the zlib compressed block...
procedure Jump_IDAT is
dummy: U32;
begin
Big_endian(image.buffer, dummy); -- ending chunk's CRC
-- New chunk begins here.
loop
Read(image, ch);
exit when ch.kind /= IDAT or ch.length > 0;
end loop;
if ch.kind /= IDAT then
raise error_in_image_data with "PNG: additional data chunk must be an IDAT";
end if;
end Jump_IDAT;
---------------------------------------------------------------------
-- ** 10: Decompression ** --
-- Excerpt and simplification from UnZip.Decompress (Inflate only) --
---------------------------------------------------------------------
-- http://www.w3.org/TR/PNG/#10Compression
-- Size of sliding dictionary and circular output buffer
wsize: constant:= 16#10000#;
--------------------------------------
-- Specifications of UnZ_* packages --
--------------------------------------
package UnZ_Glob is
-- I/O Buffers
-- > Sliding dictionary for unzipping, and output buffer as well
slide: Byte_array( 0..wsize );
slide_index: Integer:= 0; -- Current Position in slide
Zip_EOF : constant Boolean:= False;
crc32val : Unsigned_32; -- crc calculated from data
end UnZ_Glob;
package UnZ_IO is
procedure Init_Buffers;
procedure Read_raw_byte ( bt : out U8 );
pragma Inline(Read_raw_byte);
package Bit_buffer is
procedure Init;
-- Read at least n bits into the bit buffer, returns the n first bits
function Read ( n: Natural ) return Integer;
pragma Inline(Read);
function Read_U32 ( n: Natural ) return Unsigned_32;
pragma Inline(Read_U32);
-- Dump n bits no longer needed from the bit buffer
procedure Dump ( n: Natural );
pragma Inline(Dump);
procedure Dump_to_byte_boundary;
function Read_and_dump( n: Natural ) return Integer;
pragma Inline(Read_and_dump);
function Read_and_dump_U32( n: Natural ) return Unsigned_32;
pragma Inline(Read_and_dump_U32);
end Bit_buffer;
procedure Flush ( x: Natural ); -- directly from slide to output stream
procedure Flush_if_full(W: in out Integer);
pragma Inline(Flush_if_full);
procedure Copy(
distance, length: Natural;
index : in out Natural );
pragma Inline(Copy);
end UnZ_IO;
package UnZ_Meth is
deflate_e_mode: constant Boolean:= False;
procedure Inflate;
end UnZ_Meth;
------------------------------
-- Bodies of UnZ_* packages --
------------------------------
package body UnZ_IO is
procedure Init_Buffers is
begin
UnZ_Glob.slide_index := 0;
Bit_buffer.Init;
CRC32.Init( UnZ_Glob.crc32val );
end Init_Buffers;
procedure Read_raw_byte ( bt : out U8 ) is
begin
if ch.length = 0 then
-- We hit the end of a PNG 'IDAT' chunk, so we go to the next one
-- - in petto, it's strange design, but well...
-- This "feature" has taken some time (and nerves) to be addressed.
-- Incidentally, to solve the mystery, I have reprogrammed the
-- whole Huffman decoding, and looked at many other wrong places!
Jump_IDAT;
end if;
Buffering.Get_Byte(image.buffer, bt);
ch.length:= ch.length - 1;
end Read_raw_byte;
package body Bit_buffer is
B : Unsigned_32;
K : Integer;
procedure Init is
begin
B := 0;
K := 0;
end Init;
procedure Need( n : Natural ) is
pragma Inline(Need);
bt: U8;
begin
while K < n loop
Read_raw_byte( bt );
B:= B or Shift_Left( Unsigned_32( bt ), K );
K:= K + 8;
end loop;
end Need;
procedure Dump ( n : Natural ) is
begin
B := Shift_Right(B, n );
K := K - n;
end Dump;
procedure Dump_to_byte_boundary is
begin
Dump ( K mod 8 );
end Dump_to_byte_boundary;
function Read_U32 ( n: Natural ) return Unsigned_32 is
begin
Need(n);
return B and (Shift_Left(1,n) - 1);
end Read_U32;
function Read ( n: Natural ) return Integer is
begin
return Integer(Read_U32(n));
end Read;
function Read_and_dump( n: Natural ) return Integer is
res: Integer;
begin
res:= Read(n);
Dump(n);
return res;
end Read_and_dump;
function Read_and_dump_U32( n: Natural ) return Unsigned_32 is
res: Unsigned_32;
begin
res:= Read_U32(n);
Dump(n);
return res;
end Read_and_dump_U32;
end Bit_buffer;
old_bytes: Natural:= 0;
-- how many bytes to be resent from last Inflate output
byte_mem: Byte_array(1..8);
procedure Flush ( x: Natural ) is
begin
if full_trace then
Ada.Text_IO.Put("[Flush..." & Integer'Image(x));
end if;
CRC32.Update( UnZ_Glob.crc32val, UnZ_Glob.slide( 0..x-1 ) );
if old_bytes > 0 then
declare
app: constant Byte_array:=
byte_mem(1..old_bytes) & UnZ_Glob.slide(0..x-1);
begin
Output_uncompressed(app, old_bytes);
-- In extreme cases (x very small), we might have some of
-- the rejected bytes from byte_mem.
if old_bytes > 0 then
byte_mem(1..old_bytes):= app(app'Last-(old_bytes-1)..app'Last);
end if;
end;
else
Output_uncompressed(UnZ_Glob.slide(0..x-1), old_bytes);
if old_bytes > 0 then
byte_mem(1..old_bytes):= UnZ_Glob.slide(x-old_bytes..x-1);
end if;
end if;
if full_trace then
Ada.Text_IO.Put_Line("finished]");
end if;
end Flush;
procedure Flush_if_full(W: in out Integer) is
begin
if W = wsize then
Flush(wsize);
W:= 0;
end if;
end Flush_if_full;
----------------------------------------------------
-- Reproduction of sequences in the output slide. --
----------------------------------------------------
-- Internal:
procedure Adjust_to_Slide(
source : in out Integer;
remain : in out Natural;
part : out Integer;
index: Integer)
is
pragma Inline(Adjust_to_Slide);
begin
source:= source mod wsize;
-- source and index are now in 0..WSize-1
if source > index then
part:= wsize-source;
else
part:= wsize-index;
end if;
-- NB: part is in 1..WSize (part cannot be 0)
if part > remain then
part:= remain;
end if;
-- Now part <= remain
remain:= remain - part;
-- NB: remain cannot be < 0
end Adjust_to_Slide;
procedure Copy_range(source, index: in out Natural; amount: Positive) is
pragma Inline(Copy_range);
begin
if abs (index - source) < amount then
-- if source >= index, the effect of copy is
-- just like the non-overlapping case
for count in reverse 1..amount loop
UnZ_Glob.slide(index):= UnZ_Glob.slide(source);
index := index + 1;
source:= source + 1;
end loop;
else -- non-overlapping -> copy slice
UnZ_Glob.slide( index .. index+amount-1 ):=
UnZ_Glob.slide( source..source+amount-1 );
index := index + amount;
source:= source + amount;
end if;
end Copy_range;
-- The copying routines:
procedure Copy(
distance, length: Natural;
index : in out Natural )
is
source,part,remain: Integer;
begin
source:= index - distance;
remain:= length;
loop
Adjust_to_Slide(source,remain,part, index);
Copy_range(source, index, part);
Flush_if_full(index);
exit when remain = 0;
end loop;
end Copy;
end UnZ_IO;
package body UnZ_Meth is
use GID.Decoding_PNG.Huffman;
--------[ Method: Inflate ]--------
procedure Inflate_Codes ( Tl, Td: p_Table_list; Bl, Bd: Integer ) is
CT : p_HufT_table; -- current table
CT_idx : Integer; -- current table index
length : Natural;
E : Integer; -- table entry flag/number of extra bits
W : Integer:= UnZ_Glob.slide_index;
-- more local variable for slide index
begin
if full_trace then
Ada.Text_IO.Put_Line("Begin Inflate_codes");
end if;
-- inflate the coded data
main_loop:
while not UnZ_Glob.Zip_EOF loop
CT:= Tl.table;
CT_idx:= UnZ_IO.Bit_buffer.Read(Bl);
loop
E := CT(CT_idx).extra_bits;
exit when E <= 16;
if E = invalid then
raise error_in_image_data with "PNG: invalid code in Deflate compression";
end if;
-- then it's a literal
UnZ_IO.Bit_buffer.Dump( CT(CT_idx).bits );
E:= E - 16;
CT:= CT(CT_idx).next_table;
CT_idx := UnZ_IO.Bit_buffer.Read(E);
end loop;
UnZ_IO.Bit_buffer.Dump ( CT(CT_idx).bits );
case E is
when 16 => -- CTE.N is a Litteral
UnZ_Glob.slide ( W ) := U8( CT(CT_idx).n );
W:= W + 1;
UnZ_IO.Flush_if_full(W);
when 15 => -- End of block (EOB)
if full_trace then
Ada.Text_IO.Put_Line("Exit Inflate_codes, e=15 EOB");
end if;
exit main_loop;
when others => -- We have a length/distance
-- Get length of block to copy:
length:= CT(CT_idx).n + UnZ_IO.Bit_buffer.Read_and_dump(E);
-- Decode distance of block to copy:
CT:= Td.table;
CT_idx := UnZ_IO.Bit_buffer.Read(Bd);
loop
E := CT(CT_idx).extra_bits;
exit when E <= 16;
if E = invalid then
raise error_in_image_data
with "PNG: invalid code in Deflate compression (LZ distance)";
end if;
UnZ_IO.Bit_buffer.Dump( CT(CT_idx).bits );
E:= E - 16;
CT:= CT(CT_idx).next_table;
CT_idx := UnZ_IO.Bit_buffer.Read(E);
end loop;
UnZ_IO.Bit_buffer.Dump( CT(CT_idx).bits );
UnZ_IO.Copy(
distance => CT(CT_idx).n + UnZ_IO.Bit_buffer.Read_and_dump(E),
length => length,
index => W
);
end case;
end loop main_loop;
UnZ_Glob.slide_index:= W;
if full_trace then
Ada.Text_IO.Put_Line("End Inflate_codes");
end if;
end Inflate_Codes;
procedure Inflate_stored_block is -- Actually, nothing to inflate
N : Integer;
begin
if full_trace then
Ada.Text_IO.Put_Line("Begin Inflate_stored_block");
end if;
UnZ_IO.Bit_buffer.Dump_to_byte_boundary;
-- Get the block length and its complement
N:= UnZ_IO.Bit_buffer.Read_and_dump( 16 );
if N /= Integer(
(not UnZ_IO.Bit_buffer.Read_and_dump_U32(16))
and 16#ffff#)
then
raise error_in_image_data with "PNG: invalid check code in Deflate stored block";
end if;
while N > 0 and then not UnZ_Glob.Zip_EOF loop
-- Read and output the non-compressed data
N:= N - 1;
UnZ_Glob.slide ( UnZ_Glob.slide_index ) :=
U8( UnZ_IO.Bit_buffer.Read_and_dump(8) );
UnZ_Glob.slide_index:= UnZ_Glob.slide_index + 1;
UnZ_IO.Flush_if_full(UnZ_Glob.slide_index);
end loop;
if full_trace then
Ada.Text_IO.Put_Line("End Inflate_stored_block");
end if;
end Inflate_stored_block;
-- Copy lengths for literal codes 257..285
copy_lengths_literal : Length_array( 0..30 ) :=
( 3, 4, 5, 6, 7, 8, 9, 10, 11, 13, 15, 17, 19, 23, 27, 31,
35, 43, 51, 59, 67, 83, 99, 115, 131, 163, 195, 227, 258, 0, 0 );
-- Extra bits for literal codes 257..285
extra_bits_literal : Length_array( 0..30 ) :=
( 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 2, 2, 2, 2,
3, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 0, invalid, invalid );
-- Copy offsets for distance codes 0..29 (30..31: deflate_e)
copy_offset_distance : constant Length_array( 0..31 ) :=
( 1, 2, 3, 4, 5, 7, 9, 13, 17, 25, 33, 49, 65, 97, 129, 193,
257, 385, 513, 769, 1025, 1537, 2049, 3073, 4097, 6145,
8193, 12289, 16385, 24577, 32769, 49153 );
-- Extra bits for distance codes
extra_bits_distance : constant Length_array( 0..31 ) :=
( 0, 0, 0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6,
7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13, 14, 14 );
max_dist: Integer:= 29; -- changed to 31 for deflate_e
procedure Inflate_fixed_block is
Tl, -- literal/length code table
Td : p_Table_list; -- distance code table
Bl, Bd : Integer; -- lookup bits for tl/bd
huft_incomplete : Boolean;
-- length list for HufT_build (literal table)
L: constant Length_array( 0..287 ):=
( 0..143=> 8, 144..255=> 9, 256..279=> 7, 280..287=> 8);
begin
if full_trace then
Ada.Text_IO.Put_Line("Begin Inflate_fixed_block");
end if;
-- make a complete, but wrong code set
Bl := 7;
HufT_build(
L, 257, copy_lengths_literal, extra_bits_literal,
Tl, Bl, huft_incomplete
);
-- Make an incomplete code set
Bd := 5;
begin
HufT_build(
(0..max_dist => 5), 0,
copy_offset_distance, extra_bits_distance,
Td, Bd, huft_incomplete
);
if huft_incomplete then
if full_trace then
Ada.Text_IO.Put_Line(
"td is incomplete, pointer=null: " &
Boolean'Image(Td=null)
);
end if;
end if;
exception
when huft_out_of_memory | huft_error =>
HufT_free( Tl );
raise error_in_image_data
with "PNG: error in Deflate compression (Huffman #1)";
end;
Inflate_Codes ( Tl, Td, Bl, Bd );
HufT_free ( Tl );
HufT_free ( Td );
if full_trace then
Ada.Text_IO.Put_Line("End Inflate_fixed_block");
end if;
end Inflate_fixed_block;
procedure Inflate_dynamic_block is
bit_order : constant array ( 0..18 ) of Natural :=
( 16, 17, 18, 0, 8, 7, 9, 6, 10, 5, 11, 4, 12, 3, 13, 2, 14, 1, 15 );
Lbits : constant:= 9;
Dbits : constant:= 6;
current_length: Natural:= 0;
defined, number_of_lengths: Natural;
Tl, -- literal/length code tables
Td : p_Table_list; -- distance code tables
CT_dyn_idx : Integer; -- current table element
Bl, Bd : Integer; -- lookup bits for tl/bd
Nb : Natural; -- number of bit length codes
Nl : Natural; -- number of literal length codes
Nd : Natural; -- number of distance codes
-- literal/length and distance code lengths
Ll: Length_array( 0 .. 288+32-1 ):= (others=> 0);
huft_incomplete : Boolean;
procedure Repeat_length_code( amount: Natural ) is
begin
if defined + amount > number_of_lengths then
raise error_in_image_data
with "PNG: invalid data in Deflate dynamic compression structure (#1)";
end if;
for c in reverse 1..amount loop
Ll ( defined ) := Natural_M32(current_length);
defined:= defined + 1;
end loop;
end Repeat_length_code;
begin
if full_trace then
Ada.Text_IO.Put_Line("Begin Inflate_dynamic_block");
end if;
-- Read in table lengths
Nl := 257 + UnZ_IO.Bit_buffer.Read_and_dump(5);
Nd := 1 + UnZ_IO.Bit_buffer.Read_and_dump(5);
Nb := 4 + UnZ_IO.Bit_buffer.Read_and_dump(4);
if Nl > 288 or else Nd > 32 then
raise error_in_image_data
with "PNG: invalid data in Deflate dynamic compression structure (#2)";
end if;
-- Read in bit-length-code lengths.
-- The rest, Ll( Bit_Order( Nb .. 18 ) ), is already = 0
for J in 0 .. Nb - 1 loop
Ll ( bit_order( J ) ) := Natural_M32(UnZ_IO.Bit_buffer.Read_and_dump(3));
end loop;
-- Build decoding table for trees--single level, 7 bit lookup
Bl := 7;
begin
HufT_build (
Ll( 0..18 ), 19, empty, empty, Tl, Bl, huft_incomplete
);
if huft_incomplete then
HufT_free(Tl);
raise error_in_image_data
with "PNG: error in Deflate compression (Huffman #2)";
end if;
exception
when others =>
raise error_in_image_data
with "PNG: error in Deflate compression (Huffman #3)";
end;
-- Read in literal and distance code lengths
number_of_lengths := Nl + Nd;
defined := 0;
current_length := 0;
while defined < number_of_lengths loop
CT_dyn_idx:= UnZ_IO.Bit_buffer.Read(Bl);
UnZ_IO.Bit_buffer.Dump( Tl.table(CT_dyn_idx).bits );
case Tl.table(CT_dyn_idx).n is
when 0..15 => -- length of code in bits (0..15)
current_length:= Tl.table(CT_dyn_idx).n;
Ll (defined) := Natural_M32(current_length);
defined:= defined + 1;
when 16 => -- repeat last length 3 to 6 times
Repeat_length_code(3 + UnZ_IO.Bit_buffer.Read_and_dump(2));
when 17 => -- 3 to 10 zero length codes
current_length:= 0;
Repeat_length_code(3 + UnZ_IO.Bit_buffer.Read_and_dump(3));
when 18 => -- 11 to 138 zero length codes
current_length:= 0;
Repeat_length_code(11 + UnZ_IO.Bit_buffer.Read_and_dump(7));
when others =>
if full_trace then
Ada.Text_IO.Put_Line(
"Illegal length code: " &
Integer'Image(Tl.table(CT_dyn_idx).n)
);
end if;
end case;
end loop;
HufT_free ( Tl ); -- free decoding table for trees
-- Build the decoding tables for literal/length codes
Bl := Lbits;
begin
HufT_build (
Ll( 0..Nl-1 ), 257,
copy_lengths_literal, extra_bits_literal,
Tl, Bl, huft_incomplete
);
if huft_incomplete then
HufT_free(Tl);
raise error_in_image_data
with "PNG: error in Deflate compression (Huffman #4)";
end if;
exception
when others =>
raise error_in_image_data
with "PNG: error in Deflate compression (Huffman #5)";
end;
-- Build the decoding tables for distance codes
Bd := Dbits;
begin
HufT_build (
Ll( Nl..Nl+Nd-1 ), 0,
copy_offset_distance, extra_bits_distance,
Td, Bd, huft_incomplete
);
if huft_incomplete then -- do nothing!
if full_trace then
Ada.Text_IO.Put_Line("PKZIP 1.93a bug workaround");
end if;
end if;
exception
when huft_out_of_memory | huft_error =>
HufT_free(Tl);
raise error_in_image_data
with "PNG: error in Deflate compression (Huffman #6)";
end;
-- Decompress until an end-of-block code
Inflate_Codes ( Tl, Td, Bl, Bd );
HufT_free ( Tl );
HufT_free ( Td );
if full_trace then
Ada.Text_IO.Put_Line("End Inflate_dynamic_block");
end if;
end Inflate_dynamic_block;
procedure Inflate_Block( last_block: out Boolean ) is
begin
last_block:= Boolean'Val(UnZ_IO.Bit_buffer.Read_and_dump(1));
case UnZ_IO.Bit_buffer.Read_and_dump(2) is -- Block type = 0,1,2,3
when 0 => Inflate_stored_block;
when 1 => Inflate_fixed_block;
when 2 => Inflate_dynamic_block;
when others =>
raise error_in_image_data with
"PNG: error in Deflate compression: bad block type (3)";
end case;
end Inflate_Block;
procedure Inflate is
is_last_block: Boolean;
blocks: Positive:= 1;
begin
if deflate_e_mode then
copy_lengths_literal(28):= 3; -- instead of 258
extra_bits_literal(28):= 16; -- instead of 0
max_dist:= 31;
end if;
loop
Inflate_Block ( is_last_block );
exit when is_last_block;
blocks:= blocks+1;
end loop;
UnZ_IO.Flush( UnZ_Glob.slide_index );
UnZ_Glob.slide_index:= 0;
if some_trace then
Ada.Text_IO.Put("# blocks:" & Integer'Image(blocks));
end if;
UnZ_Glob.crc32val := CRC32.Final( UnZ_Glob.crc32val );
end Inflate;
end UnZ_Meth;
--------------------------------------------------------------------
-- End of the Decompression part, and of UnZip.Decompress excerpt --
--------------------------------------------------------------------
b: U8;
z_crc, dummy: U32;
begin -- Load_specialized
--
-- For optimization reasons, bytes_to_unfilter is passed as a
-- generic parameter but should be always as below right to "/=" :
--
if bytes_to_unfilter /= Integer'Max(1, png_bits_per_pixel / 8) then
raise Program_Error;
end if;
if interlaced then
x_max:= (Integer (image.width) + 7)/8 - 1;
y_max:= (Integer (image.height) + 7)/8 - 1;
else
x_max:= X_range'Last;
y_max:= Y_range'Last;
end if;
main_chunk_loop:
loop
loop
Read(image, ch);
exit when ch.kind = IEND or ch.length > 0;
end loop;
case ch.kind is
when IEND => -- 11.2.5 IEND Image trailer
exit main_chunk_loop;
when IDAT => -- 11.2.4 IDAT Image data
--
-- NB: the compressed data may hold on several IDAT chunks.
-- It means that right in the middle of compressed data, you
-- can have a chunk crc, and a new IDAT header!...
--
UnZ_IO.Read_raw_byte(b); -- zlib compression method/flags code
UnZ_IO.Read_raw_byte(b); -- Additional flags/check bits
--
UnZ_IO.Init_Buffers;
-- ^ we indicate that we have a byte reserve of chunk's length,
-- minus both zlib header bytes.
UnZ_Meth.Inflate;
z_crc:= 0;
for i in 1..4 loop
begin
UnZ_IO.Read_raw_byte(b);
exception
when error_in_image_data =>
-- vicious IEND at the wrong place
-- basi4a08.png test image (corrupt, imho)
exit main_chunk_loop;
end;
z_crc:= z_crc * 256 + U32(b);
end loop;
-- z_crc : zlib Check value
-- if z_crc /= U32(UnZ_Glob.crc32val) then
-- ada.text_io.put(z_crc 'img & UnZ_Glob.crc32val'img);
-- raise
-- error_in_image_data with
-- "PNG: deflate stream corrupt";
-- end if;
-- ** Mystery: this check fails even with images which decompress perfectly
-- ** Is CRC init value different between zip and zlib ? Is it Adler32 ?
Big_endian(image.buffer, dummy); -- chunk's CRC
-- last IDAT chunk's CRC (then, on compressed data)
--
when tEXt => -- 11.3.4.3 tEXt Textual data
for i in 1..ch.length loop
Get_Byte(image.buffer, b);
if some_trace then
if b=0 then -- separates keyword from message
Ada.Text_IO.New_Line;
else
Ada.Text_IO.Put(Character'Val(b));
end if;
end if;
end loop;
Big_endian(image.buffer, dummy); -- chunk's CRC
when others =>
-- Skip chunk data and CRC
for i in 1..ch.length + 4 loop
Get_Byte(image.buffer, b);
end loop;
end case;
end loop main_chunk_loop;
if some_trace then
for f in Filter_method_0 loop
Ada.Text_IO.Put_Line(
"Filter: " &
Filter_method_0'Image(f) &
Integer'Image(filter_stat(f))
);
end loop;
end if;
Feedback(100);
end Load_specialized;
-- Instances of Load_specialized, with hard-coded parameters.
-- They may take an insane amount of time to compile, and bloat the
-- .o code , but are significantly faster since they make the
-- compiler skip corresponding tests at pixel level.
-- These instances are for most current PNG sub-formats.
procedure Load_interlaced_1pal is new Load_specialized(True, 1, 1, 3);
procedure Load_interlaced_2pal is new Load_specialized(True, 2, 1 ,3);
procedure Load_interlaced_4pal is new Load_specialized(True, 4, 1, 3);
procedure Load_interlaced_8pal is new Load_specialized(True, 8, 1, 3);
procedure Load_interlaced_24 is new Load_specialized(True, 24, 3, 2);
procedure Load_interlaced_32 is new Load_specialized(True, 32, 4, 6);
--
procedure Load_straight_1pal is new Load_specialized(False, 1, 1, 3);
procedure Load_straight_2pal is new Load_specialized(False, 2, 1, 3);
procedure Load_straight_4pal is new Load_specialized(False, 4, 1, 3);
procedure Load_straight_8pal is new Load_specialized(False, 8, 1, 3);
procedure Load_straight_24 is new Load_specialized(False, 24, 3, 2);
procedure Load_straight_32 is new Load_specialized(False, 32, 4, 6);
--
-- For unusual sub-formats, we prefer to fall back to the
-- slightly slower, general version, where parameters values
-- are not known at compile-time:
--
procedure Load_general is new
Load_specialized(
interlaced => image.interlaced,
png_bits_per_pixel => image.bits_per_pixel,
bytes_to_unfilter => Integer'Max(1, image.bits_per_pixel / 8),
subformat_id => image.subformat_id
);
begin -- Load
--
-- All these case tests are better done at the picture
-- level than at the pixel level.
--
case image.subformat_id is
when 2 => -- RGB
case image.bits_per_pixel is
when 24 =>
if image.interlaced then
Load_interlaced_24;
else
Load_straight_24;
end if;
when others =>
Load_general;
end case;
when 3 => -- Palette
case image.bits_per_pixel is
when 1 =>
if image.interlaced then
Load_interlaced_1pal;
else
Load_straight_1pal;
end if;
when 2 =>
if image.interlaced then
Load_interlaced_2pal;
else
Load_straight_2pal;
end if;
when 4 =>
if image.interlaced then
Load_interlaced_4pal;
else
Load_straight_4pal;
end if;
when 8 =>
if image.interlaced then
Load_interlaced_8pal;
else
Load_straight_8pal;
end if;
when others =>
Load_general;
end case;
when 6 => -- RGBA
case image.bits_per_pixel is
when 32 =>
if image.interlaced then
Load_interlaced_32;
else
Load_straight_32;
end if;
when others =>
Load_general;
end case;
when others =>
Load_general;
end case;
end Load;
end GID.Decoding_PNG;
|
Rodeo-McCabe/orka | Ada | 6,316 | ads | -- SPDX-License-Identifier: Apache-2.0
--
-- Copyright (c) 2012 Felix Krause <[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.Low_Level.Enums;
with GL.Objects.Buffers;
with GL.Objects.Shaders;
with GL.Types.Compute;
limited with GL.Objects.Programs.Uniforms;
package GL.Objects.Programs is
pragma Preelaborate;
type Program is new GL_Object with private;
procedure Attach (Subject : Program; Shader : Shaders.Shader);
procedure Detach (Subject : Program; Shader : Shaders.Shader);
procedure Link (Subject : Program);
function Link_Status (Subject : Program) return Boolean;
function Info_Log (Subject : Program) return String;
procedure Use_Program (Subject : Program);
-- Use the shaders of the given program during rendering
--
-- If you have subroutines in some of its shaders, you must
-- subsequently call Set_Uniform_Subroutines, because the subroutine
-- state is completely lost after having called Use_Program.
procedure Set_Separable (Subject : Program; Separable : Boolean);
function Separable (Subject : Program) return Boolean;
function Compute_Work_Group_Size (Object : Program) return Compute.Dimension_Size_Array;
-- Size (per dimension) of a local work group in the linked compute stage
function Uniform_Location (Subject : Program; Name : String)
return Programs.Uniforms.Uniform;
-- Return a Uniform given its name
--
-- The returned object can be used to set values for use in the
-- shaders.
--
-- Raises the Uniform_Inactive_Error exception if the name
-- does not exist or is unused.
function Uniform_Type (Object : Program; Name : String)
return Low_Level.Enums.Resource_Type;
-- Raises the Uniform_Inactive_Error exception if the name
-- does not exist or is unused.
function Buffer_Binding
(Object : Program;
Target : Buffers.Indexed_Buffer_Target;
Name : String) return Size;
overriding
procedure Initialize_Id (Object : in out Program);
procedure Initialize_Id (Object : in out Program; Kind : Shaders.Shader_Type; Source : String);
overriding
procedure Delete_Id (Object : in out Program);
overriding
function Identifier (Object : Program) return Types.Debug.Identifier is
(Types.Debug.Program);
Uniform_Inactive_Error : exception;
Subroutine_Inactive_Error : exception;
-----------------------------------------------------------------------------
-- Subroutines --
-----------------------------------------------------------------------------
subtype Subroutine_Index_Type is UInt;
subtype Uniform_Location_Type is Int range -1 .. Int'Last;
type Subroutine_Index_Array is array (Size range <>) of Subroutine_Index_Type;
Invalid_Index : constant Subroutine_Index_Type;
function Subroutine_Index
(Object : Program;
Shader : Shaders.Shader_Type;
Name : String) return Subroutine_Index_Type;
-- Return the index of the subroutine function given its name
--
-- Raises the Subroutine_Inactive_Error exception if the name
-- does not exist or is unused.
function Subroutine_Uniform_Index
(Object : Program;
Shader : Shaders.Shader_Type;
Name : String) return Subroutine_Index_Type;
-- Return the index of the subroutine uniform given its name
--
-- Raises the Uniform_Inactive_Error exception if the name
-- does not exist or is unused.
function Subroutine_Uniform_Location
(Object : Program;
Shader : Shaders.Shader_Type;
Name : String) return Uniform_Location_Type;
-- Return the location of a subroutine uniform
--
-- The location of the uniform is used when setting the subroutine
-- function (using the index of the function) that should be used
-- during rendering.
function Subroutine_Indices_Uniform
(Object : Program;
Shader : Shaders.Shader_Type;
Index : Subroutine_Index_Type) return Subroutine_Index_Array;
-- Return the indices of compatible subroutines for the given subroutine uniform
function Subroutine_Uniform_Locations
(Object : Program;
Shader : Shaders.Shader_Type) return Size;
-- Return number of active subroutine uniform locations
--
-- All locations between 0 .. Subroutine_Uniform_Locations'Result - 1
-- are active locations. A subroutine uniform that is an array has one
-- index, but multiple locations.
--
-- This function is used to determine length of array given to
-- Set_Uniform_Subroutines.
procedure Set_Uniform_Subroutines (Shader : Shaders.Shader_Type; Indices : UInt_Array)
with Pre => Indices'First = 0;
-- Use the given indices of the subroutine functions to set the active
-- subroutine uniforms
--
-- Size of Indices must be equal to Subroutine_Uniform_Locations.
-- You must call this program after Programs.Use_Program, Pipelines.Bind,
-- or Pipelines.Use_Program_Stages.
--
-- This procedure can be used as follows:
--
-- 1. Use Subroutine_Uniform_Locations to create a new UInt_Array
-- with the correct length.
-- 2. Call Subroutine_Index to get the index of a subroutine function.
-- This will be a *value* in the array.
-- 3. Call Subroutine_Uniform_Location to get the location of a subroutine
-- uniform. This will be a *key* in the array.
-- 4. Assign the value (function index) to the key (uniform location) in
-- the array.
-- 5. Repeat steps 2 to 4 for all active subroutine uniforms.
private
Invalid_Index : constant Subroutine_Index_Type := 16#FFFFFFFF#;
type Program is new GL_Object with null record;
end GL.Objects.Programs;
|
zhmu/ananas | Ada | 4,883 | ads | ------------------------------------------------------------------------------
-- --
-- GNAT COMPILER COMPONENTS --
-- --
-- S Y S T E M . T A S K _ I N F O --
-- --
-- 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. --
-- --
------------------------------------------------------------------------------
-- This package contains the definitions and routines associated with the
-- implementation and use of the Task_Info pragma. It is specialized
-- appropriately for targets that make use of this pragma.
-- Note: the compiler generates direct calls to this interface, via Rtsfind.
-- Any changes to this interface may require corresponding compiler changes.
-- The functionality in this unit is now provided by the predefined package
-- System.Multiprocessors and the CPU aspect. This package is obsolescent.
package System.Task_Info is
pragma Obsolescent (Task_Info, "use System.Multiprocessors and CPU aspect");
pragma Preelaborate;
pragma Elaborate_Body;
-- To ensure that a body is allowed
-----------------------------------------
-- Implementation of Task_Info Feature --
-----------------------------------------
-- The Task_Info pragma:
-- pragma Task_Info (EXPRESSION);
-- allows the specification on a task by task basis of a value of type
-- System.Task_Info.Task_Info_Type to be passed to a task when it is
-- created. The specification of this type, and the effect on the task
-- that is created is target dependent.
-- The Task_Info pragma appears within a task definition (compare the
-- definition and implementation of pragma Priority). If no such pragma
-- appears, then the value Unspecified_Task_Info is passed. If a pragma
-- is present, then it supplies an alternative value. If the argument of
-- the pragma is a discriminant reference, then the value can be set on
-- a task by task basis by supplying the appropriate discriminant value.
-- Note that this means that the type used for Task_Info_Type must be
-- suitable for use as a discriminant (i.e. a scalar or access type).
------------------
-- Declarations --
------------------
type Scope_Type is
(Process_Scope,
-- Contend only with threads in same process
System_Scope,
-- Contend with all threads on same CPU
Default_Scope);
type Task_Info_Type is new Scope_Type;
-- Type used for passing information to task create call, using the
-- Task_Info pragma. This type may be specialized for individual
-- implementations, but it must be a type that can be used as a
-- discriminant (i.e. a scalar or access type).
Unspecified_Task_Info : constant Task_Info_Type := Default_Scope;
-- Value passed to task in the absence of a Task_Info pragma
end System.Task_Info;
|
persan/a-cups | Ada | 353 | ads | with Ada.Containers.Indefinite_Hashed_Maps;
with Ada.Strings.Fixed.Hash_Case_Insensitive;
package CUPS.String_Maps is new Ada.Containers.Indefinite_Hashed_Maps
(Key_Type => String,
Element_Type => String,
Hash => Ada.Strings.Fixed.Hash_Case_Insensitive,
Equivalent_Keys => "=",
"=" => "=");
|
francesco-bongiovanni/ewok-kernel | Ada | 21,103 | adb | --
-- Copyright 2018 The wookey project team <[email protected]>
-- - Ryad Benadjila
-- - Arnauld Michelizza
-- - Mathieu Renard
-- - Philippe Thierry
-- - Philippe Trebuchet
--
-- Licensed under the Apache License, Version 2.0 (the "License");
-- you may not use this file except in compliance with the License.
-- You may obtain a copy of the License at
--
-- http://www.apache.org/licenses/LICENSE-2.0
--
-- Unless required by applicable law or agreed to in writing, software
-- distributed under the License is distributed on an "AS IS" BASIS,
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-- See the License for the specific language governing permissions and
-- limitations under the License.
--
--
with ewok.exported.dma; use ewok.exported.dma;
with ewok.sanitize;
with ewok.tasks;
with ewok.interrupts;
with ewok.devices_shared;
#if CONFIG_KERNEL_DOMAIN
with ewok.perm;
#end if;
with soc.dma.interfaces;
with soc.nvic;
with c.socinfo; use type c.socinfo.t_device_soc_infos_access;
with debug;
package body ewok.dma
with spark_mode => off
is
procedure get_registered_dma_entry
(index : out ewok.dma_shared.t_registered_dma_index;
success : out boolean)
is
begin
for id in registered_dma'range loop
if registered_dma(id).status = DMA_UNUSED then
registered_dma(id).status := DMA_USED;
index := id;
success := true;
return;
end if;
end loop;
success := false;
end get_registered_dma_entry;
function has_same_dma_channel
(index : ewok.dma_shared.t_registered_dma_index;
config : ewok.exported.dma.t_dma_user_config)
return boolean
is
begin
if registered_dma(index).user_config.controller = config.controller and
registered_dma(index).user_config.stream = config.stream and
registered_dma(index).user_config.channel = config.channel
then
return true;
else
return false;
end if;
end has_same_dma_channel;
function dma_is_already_used
(config : ewok.exported.dma.t_dma_user_config)
return boolean
is
begin
for index in registered_dma'range loop
if has_same_dma_channel (index, config) then
return true;
end if;
end loop;
return false;
end dma_is_already_used;
function task_owns_dma_stream
(caller_id : ewok.tasks_shared.t_task_id;
dma_id : ewok.exported.dma.t_controller;
stream_id : ewok.exported.dma.t_stream)
return boolean
is
begin
for index in registered_dma'range loop
if registered_dma(index).task_id = caller_id and then
registered_dma(index).user_config.controller = dma_id and then
registered_dma(index).user_config.stream = stream_id
then
return true;
end if;
end loop;
return false;
end task_owns_dma_stream;
procedure enable_dma_stream
(index : in ewok.dma_shared.t_registered_dma_index)
is
dma_id : constant soc.dma.t_dma_periph_index :=
soc.dma.t_dma_periph_index
(registered_dma(index).user_config.controller);
stream_id : constant soc.dma.t_stream_index :=
soc.dma.t_stream_index
(registered_dma(index).user_config.stream);
begin
if registered_dma(index).status = DMA_CONFIGURED then
soc.dma.interfaces.enable_stream (dma_id, stream_id);
end if;
end enable_dma_stream;
procedure disable_dma_stream
(index : in ewok.dma_shared.t_registered_dma_index)
is
dma_id : constant soc.dma.t_dma_periph_index :=
soc.dma.t_dma_periph_index
(registered_dma(index).user_config.controller);
stream_id : constant soc.dma.t_stream_index :=
soc.dma.t_stream_index
(registered_dma(index).user_config.stream);
begin
if registered_dma(index).status = DMA_CONFIGURED then
soc.dma.interfaces.disable_stream (dma_id, stream_id);
end if;
end disable_dma_stream;
procedure enable_dma_irq
(index : in ewok.dma_shared.t_registered_dma_index)
is
intr : constant soc.interrupts.t_interrupt :=
soc.interrupts.t_interrupt'val
(registered_dma(index).devinfo.all.intr_num);
begin
soc.nvic.enable_irq (soc.nvic.to_irq_number (intr));
end enable_dma_irq;
function is_config_complete
(user_config : ewok.exported.dma.t_dma_user_config)
return boolean
is
begin
if user_config.in_addr = 0 or
user_config.out_addr = 0 or
user_config.size = 0 or
user_config.transfer_dir = MEMORY_TO_MEMORY or
(user_config.transfer_dir = MEMORY_TO_PERIPHERAL
and user_config.in_handler = 0) or
(user_config.transfer_dir = PERIPHERAL_TO_MEMORY
and user_config.out_handler = 0)
then
return false;
else
return true;
end if;
end is_config_complete;
function sanitize_dma
(user_config : ewok.exported.dma.t_dma_user_config;
caller_id : ewok.tasks_shared.t_task_id;
to_configure : ewok.exported.dma.t_config_mask;
mode : ewok.tasks_shared.t_task_mode)
return boolean
is
begin
case user_config.transfer_dir is
when PERIPHERAL_TO_MEMORY =>
if to_configure.buffer_in then
if not ewok.sanitize.is_word_in_allocated_device
(user_config.in_addr, caller_id)
then
return false;
end if;
end if;
if to_configure.buffer_out then
if not ewok.sanitize.is_range_in_any_slot
(user_config.out_addr, unsigned_32 (user_config.size),
caller_id, mode)
and
not ewok.sanitize.is_range_in_dma_shm
(user_config.out_addr, unsigned_32 (user_config.size),
SHM_ACCESS_WRITE, caller_id)
then
return false;
end if;
end if;
if to_configure.handlers then
if not ewok.sanitize.is_word_in_txt_slot
(user_config.out_handler, caller_id)
then
return false;
end if;
end if;
when MEMORY_TO_PERIPHERAL =>
if to_configure.buffer_in then
if not ewok.sanitize.is_range_in_any_slot
(user_config.in_addr, unsigned_32 (user_config.size),
caller_id, mode)
and
not ewok.sanitize.is_range_in_dma_shm
(user_config.in_addr, unsigned_32 (user_config.size),
SHM_ACCESS_READ, caller_id)
then
return false;
end if;
end if;
if to_configure.buffer_out then
if not ewok.sanitize.is_word_in_allocated_device
(user_config.out_addr, caller_id)
then
return false;
end if;
end if;
if to_configure.handlers then
if not ewok.sanitize.is_word_in_txt_slot
(user_config.in_handler, caller_id)
then
return false;
end if;
end if;
when MEMORY_TO_MEMORY =>
return false;
end case;
return true;
end sanitize_dma;
function sanitize_dma_shm
(shm : ewok.exported.dma.t_dma_shm_info;
caller_id : ewok.tasks_shared.t_task_id;
mode : ewok.tasks_shared.t_task_mode)
return boolean
is
begin
if not ewok.tasks.is_user (shm.granted_id) then
debug.log ("ewok.dma.sanitize_dma_shm(): wrong target");
return false;
end if;
if shm.accessed_id /= caller_id then
debug.log ("ewok.dma.sanitize_dma_shm(): wrong caller");
return false;
end if;
#if CONFIG_KERNEL_DOMAIN
if not ewok.perm.is_same_domain (shm.granted_id, shm.accessed_id) then
debug.log ("ewok.dma.sanitize_dma_shm(): not same domain");
return false;
end if;
#end if;
if not ewok.sanitize.is_range_in_data_slot
(shm.base, unsigned_32 (shm.size), caller_id, mode)
then
debug.log ("ewok.dma.sanitize_dma_shm(): shm not in range");
return false;
end if;
return true;
end sanitize_dma_shm;
procedure reconfigure_stream
(user_config : in out ewok.exported.dma.t_dma_user_config;
index : in ewok.dma_shared.t_registered_dma_index;
to_configure : in ewok.exported.dma.t_config_mask;
caller_id : in ewok.tasks_shared.t_task_id;
success : out boolean)
is
soc_dma_id : soc.dma.t_dma_periph_index;
soc_stream_id : soc.dma.t_stream_index;
soc_dma_config : soc.dma.interfaces.t_dma_config;
ok : boolean;
begin
if not to_configure.buffer_size then
user_config.size := registered_dma(index).user_config.size;
else
registered_dma(index).user_config.size := user_config.size;
end if;
if to_configure.buffer_in then
registered_dma(index).user_config.in_addr := user_config.in_addr;
end if;
if to_configure.buffer_out then
registered_dma(index).user_config.out_addr := user_config.out_addr;
end if;
if to_configure.mode then
registered_dma(index).user_config.mode := user_config.mode;
end if;
if to_configure.priority then
case user_config.transfer_dir is
when PERIPHERAL_TO_MEMORY =>
registered_dma(index).user_config.out_priority :=
user_config.out_priority;
when MEMORY_TO_PERIPHERAL =>
registered_dma(index).user_config.in_priority :=
user_config.in_priority;
when MEMORY_TO_MEMORY =>
debug.log ("ewok.dma.reconfigure_stream(): MEMORY_TO_MEMORY not implemented");
success := false;
return;
end case;
end if;
if to_configure.direction then
registered_dma(index).user_config.transfer_dir :=
user_config.transfer_dir;
end if;
if to_configure.handlers then
case user_config.transfer_dir is
when PERIPHERAL_TO_MEMORY =>
registered_dma(index).user_config.out_handler :=
user_config.out_handler;
ewok.interrupts.set_interrupt_handler
(soc.interrupts.t_interrupt'val
(registered_dma(index).devinfo.all.intr_num),
ewok.interrupts.to_handler_access (user_config.out_handler),
caller_id,
ewok.devices_shared.ID_DEV_UNUSED,
ok);
if not ok then
raise program_error;
end if;
when MEMORY_TO_PERIPHERAL =>
registered_dma(index).user_config.in_handler :=
user_config.in_handler;
ewok.interrupts.set_interrupt_handler
(soc.interrupts.t_interrupt'val
(registered_dma(index).devinfo.all.intr_num),
ewok.interrupts.to_handler_access (user_config.in_handler),
caller_id,
ewok.devices_shared.ID_DEV_UNUSED,
ok);
if not ok then
raise program_error;
end if;
when MEMORY_TO_MEMORY =>
debug.log ("ewok.dma.reconfigure_stream(): MEMORY_TO_MEMORY not implemented");
success := false;
return;
end case;
end if;
--
-- Check if we enough elements to enable the DMA
--
if not is_config_complete (registered_dma(index).user_config) then
debug.log ("ewok.dma.reconfigure_stream(): incomplete configuration");
success := false;
return;
end if;
--
-- Configuring the DMA
--
soc_dma_id := soc.dma.t_dma_periph_index
(registered_dma(index).user_config.controller);
soc_stream_id := soc.dma.t_stream_index
(registered_dma(index).user_config.stream);
soc_dma_config :=
(dma_id => soc_dma_id,
stream => soc_stream_id,
channel => soc.dma.t_channel_index'val
(registered_dma(index).user_config.channel),
bytes => registered_dma(index).user_config.size,
in_addr => registered_dma(index).user_config.in_addr,
in_priority => soc.dma.interfaces.t_priority_level
(registered_dma(index).user_config.in_priority),
in_handler => registered_dma(index).user_config.in_handler,
out_addr => registered_dma(index).user_config.out_addr,
out_priority => soc.dma.interfaces.t_priority_level
(registered_dma(index).user_config.out_priority),
out_handler => registered_dma(index).user_config.out_handler,
flow_controller => soc.dma.interfaces.t_flow_controller
(registered_dma(index).user_config.flow_controller),
transfer_dir => soc.dma.interfaces.t_transfer_dir
(registered_dma(index).user_config.transfer_dir),
mode => soc.dma.interfaces.t_mode
(registered_dma(index).user_config.mode),
data_size => soc.dma.interfaces.t_data_size
(registered_dma(index).user_config.data_size),
memory_inc => boolean
(registered_dma(index).user_config.memory_inc),
periph_inc => boolean
(registered_dma(index).user_config.periph_inc),
mem_burst_size => soc.dma.interfaces.t_burst_size
(registered_dma(index).user_config.mem_burst_size),
periph_burst_size => soc.dma.interfaces.t_burst_size
(registered_dma(index).user_config.periph_burst_size));
soc.dma.interfaces.reconfigure_stream
(soc_dma_id, soc_stream_id, soc_dma_config,
soc.dma.interfaces.t_config_mask (to_configure));
registered_dma(index).status := DMA_CONFIGURED;
soc.dma.interfaces.enable_stream (soc_dma_id, soc_stream_id);
success := true;
end reconfigure_stream;
procedure init_stream
(user_config : in ewok.exported.dma.t_dma_user_config;
caller_id : in ewok.tasks_shared.t_task_id;
index : out ewok.dma_shared.t_registered_dma_index;
success : out boolean)
is
soc_dma_id : soc.dma.t_dma_periph_index;
soc_stream_id : soc.dma.t_stream_index;
soc_dma_config : soc.dma.interfaces.t_dma_config;
ok : boolean;
begin
-- Find a free entry in the registered_dma array
get_registered_dma_entry (index, ok);
if not ok then
debug.log ("ewok.dma.init(): no DMA entry available");
success := false;
return;
end if;
-- Copy the user configuration
registered_dma(index).user_config := user_config;
registered_dma(index).task_id := caller_id;
registered_dma(index).status := DMA_INITIALIZED;
registered_dma(index).devinfo :=
c.socinfo.soc_devmap_find_dma_device
(user_config.controller, user_config.stream);
if registered_dma(index).devinfo = NULL then
debug.log ("ewok.dma.init(): unknown DMA device");
success := false;
return;
end if;
-- Set up the interrupt handler
case user_config.transfer_dir is
when PERIPHERAL_TO_MEMORY =>
if user_config.out_handler /= 0 then
ewok.interrupts.set_interrupt_handler
(soc.interrupts.t_interrupt'val
(registered_dma(index).devinfo.all.intr_num),
ewok.interrupts.to_handler_access (user_config.out_handler),
caller_id,
ewok.devices_shared.ID_DEV_UNUSED,
ok);
if not ok then
raise program_error;
end if;
end if;
when MEMORY_TO_PERIPHERAL =>
if user_config.in_handler /= 0 then
ewok.interrupts.set_interrupt_handler
(soc.interrupts.t_interrupt'val
(registered_dma(index).devinfo.all.intr_num),
ewok.interrupts.to_handler_access (user_config.in_handler),
caller_id,
ewok.devices_shared.ID_DEV_UNUSED,
ok);
if not ok then
raise program_error;
end if;
end if;
when MEMORY_TO_MEMORY =>
debug.log ("ewok.dma.init(): MEMORY_TO_MEMORY not implemented");
success := false;
return;
end case;
soc_dma_id := soc.dma.t_dma_periph_index (user_config.controller);
soc_stream_id := soc.dma.t_stream_index (user_config.stream);
soc_dma_config :=
(dma_id => soc_dma_id,
stream => soc_stream_id,
channel => soc.dma.t_channel_index'val (user_config.channel),
bytes => user_config.size,
in_addr => user_config.in_addr,
in_priority => soc.dma.interfaces.t_priority_level
(user_config.in_priority),
in_handler => user_config.in_handler,
out_addr => user_config.out_addr,
out_priority => soc.dma.interfaces.t_priority_level
(user_config.out_priority),
out_handler => user_config.out_handler,
flow_controller => soc.dma.interfaces.t_flow_controller
(user_config.flow_controller),
transfer_dir => soc.dma.interfaces.t_transfer_dir
(user_config.transfer_dir),
mode => soc.dma.interfaces.t_mode (user_config.mode),
data_size => soc.dma.interfaces.t_data_size
(user_config.data_size),
memory_inc => boolean (user_config.memory_inc),
periph_inc => boolean (user_config.periph_inc),
mem_burst_size => soc.dma.interfaces.t_burst_size
(user_config.mem_burst_size),
periph_burst_size => soc.dma.interfaces.t_burst_size
(user_config.periph_burst_size));
-- Reset the DMA stream
soc.dma.interfaces.reset_stream
(soc_dma_id, soc_stream_id);
-- Configure the DMA stream
soc.dma.interfaces.configure_stream
(soc_dma_id, soc_stream_id, soc_dma_config);
success := true;
end init_stream;
procedure init
is
begin
soc.dma.enable_clocks;
end init;
procedure clear_dma_interrupts
(caller_id : in ewok.tasks_shared.t_task_id;
interrupt : in soc.interrupts.t_interrupt)
is
soc_dma_id : soc.dma.t_dma_periph_index;
soc_stream_id : soc.dma.t_stream_index;
ok : boolean;
begin
soc.dma.get_dma_stream_from_interrupt
(interrupt, soc_dma_id, soc_stream_id, ok);
if not ok then
raise program_error;
end if;
if not task_owns_dma_stream (caller_id, t_controller (soc_dma_id),
t_stream (soc_stream_id))
then
raise program_error;
end if;
soc.dma.interfaces.clear_all_interrupts
(soc_dma_id, soc_stream_id);
end clear_dma_interrupts;
procedure get_status_register
(caller_id : in ewok.tasks_shared.t_task_id;
interrupt : in soc.interrupts.t_interrupt;
status : out soc.dma.t_dma_stream_int_status;
success : out boolean)
is
soc_dma_id : soc.dma.t_dma_periph_index;
soc_stream_id : soc.dma.t_stream_index;
ok : boolean;
begin
soc.dma.get_dma_stream_from_interrupt
(interrupt, soc_dma_id, soc_stream_id, ok);
if not ok then
success := false;
return;
end if;
if not task_owns_dma_stream (caller_id,
t_controller (soc_dma_id),
t_stream (soc_stream_id))
then
success := false;
return;
end if;
status := soc.dma.interfaces.get_interrupt_status
(soc_dma_id, soc_stream_id);
soc.dma.interfaces.clear_all_interrupts (soc_dma_id, soc_stream_id);
success := true;
end get_status_register;
end ewok.dma;
|
docandrew/troodon | Ada | 2,825 | ads | private package GID.Decoding_JPG is
use JPEG_defs;
type JPEG_marker is
(
SOI , -- Start Of Image
--
SOF_0 , -- Start Of Frame - Baseline DCT
SOF_1 , -- Extended sequential DCT
SOF_2 , -- Progressive DCT
SOF_3 , -- Lossless (sequential)
SOF_5 , -- Differential sequential DCT
SOF_6 , -- Differential progressive DCT
SOF_7 , -- Differential lossless (sequential)
SOF_8 , -- Reserved for JPEG extensions
SOF_9 , -- Extended sequential DCT
SOF_10 , -- Progressive DCT
SOF_11 , -- Lossless (sequential)
SOF_13 , -- Differential sequential DCT
SOF_14 , -- Differential progressive DCT
SOF_15 , -- Differential lossless (sequential)
--
DHT , -- Define Huffman Table
DAC , -- Define Arithmetic Coding
DQT , -- Define Quantization Table
DRI , -- Define Restart Interval
--
APP_0 , -- JFIF - JFIF JPEG image - AVI1 - Motion JPEG (MJPG)
APP_1 , -- EXIF Metadata, TIFF IFD format, JPEG Thumbnail (160x120)
APP_2 , -- ICC color profile, FlashPix
APP_3 ,
APP_4 ,
APP_5 ,
APP_6 ,
APP_7 ,
APP_8 ,
APP_9 ,
APP_10 ,
APP_11 ,
APP_12 , -- Picture Info
APP_13 , -- Photoshop Save As: IRB, 8BIM, IPTC
APP_14 , -- Copyright Entries
--
COM , -- Comments
SOS , -- Start of Scan
EOI -- End of Image
);
YCbCr_set : constant Compo_set:= (Y|Cb|Cr => True, others => False);
Y_Grey_set: constant Compo_set:= (Y => True, others => False);
CMYK_set : constant Compo_set:= (Y|Cb|Cr|I => True, others => False);
type Segment_head is record
length : U16;
kind : JPEG_marker;
end record;
procedure Read(image: in out Image_descriptor; sh: out Segment_head);
-- SOF - Start Of Frame (the real header)
procedure Read_SOF(image: in out Image_descriptor; sh: Segment_head);
procedure Read_DHT(image: in out Image_descriptor; data_length: Natural);
procedure Read_DQT(image: in out Image_descriptor; data_length: Natural);
procedure Read_DRI(image: in out Image_descriptor);
procedure Read_EXIF(image: in out Image_descriptor; data_length: Natural);
--------------------
-- Image decoding --
--------------------
generic
type Primary_color_range is mod <>;
with procedure Set_X_Y (x, y: Natural);
with procedure Put_Pixel (
red, green, blue : Primary_color_range;
alpha : Primary_color_range
);
with procedure Feedback (percents: Natural);
-- mode: Display_mode; -- nice -> progressive nicely displayed
--
procedure Load (
image : in out Image_descriptor;
next_frame: out Ada.Calendar.Day_Duration
);
end GID.Decoding_JPG;
|
zhmu/ananas | Ada | 39,440 | adb | ------------------------------------------------------------------------------
-- --
-- GNAT RUN-TIME LIBRARY (GNARL) COMPONENTS --
-- --
-- S Y S T E M . T A S K _ P R I M I T I V E S . O P E R A T I O N S --
-- --
-- B o d y --
-- --
-- Copyright (C) 1992-2022, Free Software Foundation, Inc. --
-- --
-- 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. 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/>. --
-- --
-- GNARL was developed by the GNARL team at Florida State University. --
-- Extensive contributions were provided by Ada Core Technologies, Inc. --
-- --
------------------------------------------------------------------------------
-- This is a NT (native) version of this package
-- This package contains all the GNULL primitives that interface directly with
-- the underlying OS.
with Interfaces.C;
with Interfaces.C.Strings;
with System.Float_Control;
with System.Interrupt_Management;
with System.Multiprocessors;
with System.OS_Primitives;
with System.Task_Info;
with System.Tasking.Debug;
with System.Win32.Ext;
with System.Soft_Links;
-- We use System.Soft_Links instead of System.Tasking.Initialization because
-- the later is a higher level package that we shouldn't depend on. For
-- example when using the restricted run time, it is replaced by
-- System.Tasking.Restricted.Stages.
package body System.Task_Primitives.Operations is
package SSL renames System.Soft_Links;
use Interfaces.C;
use Interfaces.C.Strings;
use System.OS_Interface;
use System.OS_Primitives;
use System.Parameters;
use System.Task_Info;
use System.Tasking;
use System.Tasking.Debug;
use System.Win32;
use System.Win32.Ext;
pragma Link_With ("-Xlinker --stack=0x200000,0x1000");
-- Change the default stack size (2 MB) for tasking programs on Windows.
-- This allows about 1000 tasks running at the same time. Note that
-- we set the stack size for non tasking programs on System unit.
-- Also note that under Windows XP, we use a Windows XP extension to
-- specify the stack size on a per task basis, as done under other OSes.
---------------------
-- Local Functions --
---------------------
procedure InitializeCriticalSection (pCriticalSection : access RTS_Lock);
procedure InitializeCriticalSection
(pCriticalSection : access CRITICAL_SECTION);
pragma Import
(Stdcall, InitializeCriticalSection, "InitializeCriticalSection");
procedure EnterCriticalSection (pCriticalSection : access RTS_Lock);
procedure EnterCriticalSection
(pCriticalSection : access CRITICAL_SECTION);
pragma Import (Stdcall, EnterCriticalSection, "EnterCriticalSection");
procedure LeaveCriticalSection (pCriticalSection : access RTS_Lock);
procedure LeaveCriticalSection (pCriticalSection : access CRITICAL_SECTION);
pragma Import (Stdcall, LeaveCriticalSection, "LeaveCriticalSection");
procedure DeleteCriticalSection (pCriticalSection : access RTS_Lock);
procedure DeleteCriticalSection
(pCriticalSection : access CRITICAL_SECTION);
pragma Import (Stdcall, DeleteCriticalSection, "DeleteCriticalSection");
----------------
-- Local Data --
----------------
Environment_Task_Id : Task_Id;
-- A variable to hold Task_Id for the environment task
Single_RTS_Lock : aliased RTS_Lock;
-- This is a lock to allow only one thread of control in the RTS at
-- a time; it is used to execute in mutual exclusion from all other tasks.
-- Used to protect All_Tasks_List
Time_Slice_Val : constant Integer;
pragma Import (C, Time_Slice_Val, "__gl_time_slice_val");
Dispatching_Policy : constant Character;
pragma Import (C, Dispatching_Policy, "__gl_task_dispatching_policy");
function Get_Policy (Prio : System.Any_Priority) return Character;
pragma Import (C, Get_Policy, "__gnat_get_specific_dispatching");
-- Get priority specific dispatching policy
Foreign_Task_Elaborated : aliased Boolean := True;
-- Used to identified fake tasks (i.e., non-Ada Threads)
Null_Thread_Id : constant Thread_Id := 0;
-- Constant to indicate that the thread identifier has not yet been
-- initialized.
------------------------------------
-- The thread local storage index --
------------------------------------
TlsIndex : DWORD;
pragma Export (Ada, TlsIndex);
-- To ensure that this variable won't be local to this package, since
-- in some cases, inlining forces this variable to be global anyway.
--------------------
-- Local Packages --
--------------------
package Specific is
function Is_Valid_Task return Boolean;
pragma Inline (Is_Valid_Task);
-- Does executing thread have a TCB?
procedure Set (Self_Id : Task_Id);
pragma Inline (Set);
-- Set the self id for the current task
end Specific;
package body Specific is
-------------------
-- Is_Valid_Task --
-------------------
function Is_Valid_Task return Boolean is
begin
return TlsGetValue (TlsIndex) /= System.Null_Address;
end Is_Valid_Task;
---------
-- Set --
---------
procedure Set (Self_Id : Task_Id) is
Succeeded : BOOL;
begin
Succeeded := TlsSetValue (TlsIndex, To_Address (Self_Id));
pragma Assert (Succeeded = Win32.TRUE);
end Set;
end Specific;
----------------------------------
-- ATCB allocation/deallocation --
----------------------------------
package body ATCB_Allocation is separate;
-- The body of this package is shared across several targets
---------------------------------
-- Support for foreign threads --
---------------------------------
function Register_Foreign_Thread
(Thread : Thread_Id;
Sec_Stack_Size : Size_Type := Unspecified_Size) return Task_Id;
-- Allocate and initialize a new ATCB for the current Thread. The size of
-- the secondary stack can be optionally specified.
function Register_Foreign_Thread
(Thread : Thread_Id;
Sec_Stack_Size : Size_Type := Unspecified_Size)
return Task_Id is separate;
----------------------------------
-- Condition Variable Functions --
----------------------------------
procedure Initialize_Cond (Cond : not null access Condition_Variable);
-- Initialize given condition variable Cond
procedure Finalize_Cond (Cond : not null access Condition_Variable);
-- Finalize given condition variable Cond
procedure Cond_Signal (Cond : not null access Condition_Variable);
-- Signal condition variable Cond
procedure Cond_Wait
(Cond : not null access Condition_Variable;
L : not null access RTS_Lock);
-- Wait on conditional variable Cond, using lock L
procedure Cond_Timed_Wait
(Cond : not null access Condition_Variable;
L : not null access RTS_Lock;
Rel_Time : Duration;
Timed_Out : out Boolean;
Status : out Integer);
-- Do timed wait on condition variable Cond using lock L. The duration
-- of the timed wait is given by Rel_Time. When the condition is
-- signalled, Timed_Out shows whether or not a time out occurred.
-- Status is only valid if Timed_Out is False, in which case it
-- shows whether Cond_Timed_Wait completed successfully.
---------------------
-- Initialize_Cond --
---------------------
procedure Initialize_Cond (Cond : not null access Condition_Variable) is
hEvent : HANDLE;
begin
hEvent := CreateEvent (null, Win32.TRUE, Win32.FALSE, Null_Ptr);
pragma Assert (hEvent /= 0);
Cond.all := Condition_Variable (hEvent);
end Initialize_Cond;
-------------------
-- Finalize_Cond --
-------------------
-- No such problem here, DosCloseEventSem has been derived.
-- What does such refer to in above comment???
procedure Finalize_Cond (Cond : not null access Condition_Variable) is
Result : BOOL;
begin
Result := CloseHandle (HANDLE (Cond.all));
pragma Assert (Result = Win32.TRUE);
end Finalize_Cond;
-----------------
-- Cond_Signal --
-----------------
procedure Cond_Signal (Cond : not null access Condition_Variable) is
Result : BOOL;
begin
Result := SetEvent (HANDLE (Cond.all));
pragma Assert (Result = Win32.TRUE);
end Cond_Signal;
---------------
-- Cond_Wait --
---------------
-- Pre-condition: Cond is posted
-- L is locked.
-- Post-condition: Cond is posted
-- L is locked.
procedure Cond_Wait
(Cond : not null access Condition_Variable;
L : not null access RTS_Lock)
is
Result : DWORD;
Result_Bool : BOOL;
begin
-- Must reset Cond BEFORE L is unlocked
Result_Bool := ResetEvent (HANDLE (Cond.all));
pragma Assert (Result_Bool = Win32.TRUE);
Unlock (L);
-- No problem if we are interrupted here: if the condition is signaled,
-- WaitForSingleObject will simply not block
Result := WaitForSingleObject (HANDLE (Cond.all), Wait_Infinite);
pragma Assert (Result = 0);
Write_Lock (L);
end Cond_Wait;
---------------------
-- Cond_Timed_Wait --
---------------------
-- Pre-condition: Cond is posted
-- L is locked.
-- Post-condition: Cond is posted
-- L is locked.
procedure Cond_Timed_Wait
(Cond : not null access Condition_Variable;
L : not null access RTS_Lock;
Rel_Time : Duration;
Timed_Out : out Boolean;
Status : out Integer)
is
Time_Out_Max : constant DWORD := 16#FFFF0000#;
-- NT 4 can't handle excessive timeout values (e.g. DWORD'Last - 1)
Time_Out : DWORD;
Result : BOOL;
Wait_Result : DWORD;
begin
-- Must reset Cond BEFORE L is unlocked
Result := ResetEvent (HANDLE (Cond.all));
pragma Assert (Result = Win32.TRUE);
Unlock (L);
-- No problem if we are interrupted here: if the condition is signaled,
-- WaitForSingleObject will simply not block.
if Rel_Time <= 0.0 then
Timed_Out := True;
Wait_Result := 0;
else
Time_Out :=
(if Rel_Time >= Duration (Time_Out_Max) / 1000
then Time_Out_Max
else DWORD (Rel_Time * 1000));
Wait_Result := WaitForSingleObject (HANDLE (Cond.all), Time_Out);
if Wait_Result = WAIT_TIMEOUT then
Timed_Out := True;
Wait_Result := 0;
else
Timed_Out := False;
end if;
end if;
Write_Lock (L);
-- Ensure post-condition
if Timed_Out then
Result := SetEvent (HANDLE (Cond.all));
pragma Assert (Result = Win32.TRUE);
end if;
Status := Integer (Wait_Result);
end Cond_Timed_Wait;
------------------
-- Stack_Guard --
------------------
-- The underlying thread system sets a guard page at the bottom of a thread
-- stack, so nothing is needed.
-- ??? Check the comment above
procedure Stack_Guard (T : ST.Task_Id; On : Boolean) is
pragma Unreferenced (T, On);
begin
null;
end Stack_Guard;
--------------------
-- Get_Thread_Id --
--------------------
function Get_Thread_Id (T : ST.Task_Id) return OSI.Thread_Id is
begin
return T.Common.LL.Thread;
end Get_Thread_Id;
----------
-- Self --
----------
function Self return Task_Id is
Self_Id : constant Task_Id := To_Task_Id (TlsGetValue (TlsIndex));
begin
if Self_Id = null then
return Register_Foreign_Thread (GetCurrentThread);
else
return Self_Id;
end if;
end Self;
---------------------
-- Initialize_Lock --
---------------------
-- Note: mutexes and cond_variables needed per-task basis are initialized
-- in Initialize_TCB and the Storage_Error is handled. Other mutexes (such
-- as RTS_Lock, Memory_Lock...) used in the RTS is initialized before any
-- status change of RTS. Therefore raising Storage_Error in the following
-- routines should be able to be handled safely.
procedure Initialize_Lock
(Prio : System.Any_Priority;
L : not null access Lock)
is
begin
InitializeCriticalSection (L.Mutex'Access);
L.Owner_Priority := 0;
L.Priority := Prio;
end Initialize_Lock;
procedure Initialize_Lock
(L : not null access RTS_Lock; Level : Lock_Level)
is
pragma Unreferenced (Level);
begin
InitializeCriticalSection (L);
end Initialize_Lock;
-------------------
-- Finalize_Lock --
-------------------
procedure Finalize_Lock (L : not null access Lock) is
begin
DeleteCriticalSection (L.Mutex'Access);
end Finalize_Lock;
procedure Finalize_Lock (L : not null access RTS_Lock) is
begin
DeleteCriticalSection (L);
end Finalize_Lock;
----------------
-- Write_Lock --
----------------
procedure Write_Lock
(L : not null access Lock; Ceiling_Violation : out Boolean) is
begin
L.Owner_Priority := Get_Priority (Self);
if L.Priority < L.Owner_Priority then
Ceiling_Violation := True;
return;
end if;
EnterCriticalSection (L.Mutex'Access);
Ceiling_Violation := False;
end Write_Lock;
procedure Write_Lock (L : not null access RTS_Lock) is
begin
EnterCriticalSection (L);
end Write_Lock;
procedure Write_Lock (T : Task_Id) is
begin
EnterCriticalSection (T.Common.LL.L'Access);
end Write_Lock;
---------------
-- Read_Lock --
---------------
procedure Read_Lock
(L : not null access Lock; Ceiling_Violation : out Boolean) is
begin
Write_Lock (L, Ceiling_Violation);
end Read_Lock;
------------
-- Unlock --
------------
procedure Unlock (L : not null access Lock) is
begin
LeaveCriticalSection (L.Mutex'Access);
end Unlock;
procedure Unlock (L : not null access RTS_Lock) is
begin
LeaveCriticalSection (L);
end Unlock;
procedure Unlock (T : Task_Id) is
begin
LeaveCriticalSection (T.Common.LL.L'Access);
end Unlock;
-----------------
-- Set_Ceiling --
-----------------
-- Dynamic priority ceilings are not supported by the underlying system
procedure Set_Ceiling
(L : not null access Lock;
Prio : System.Any_Priority)
is
pragma Unreferenced (L, Prio);
begin
null;
end Set_Ceiling;
-----------
-- Sleep --
-----------
procedure Sleep
(Self_ID : Task_Id;
Reason : System.Tasking.Task_States)
is
pragma Unreferenced (Reason);
begin
pragma Assert (Self_ID = Self);
Cond_Wait (Self_ID.Common.LL.CV'Access, Self_ID.Common.LL.L'Access);
if Self_ID.Deferral_Level = 0
and then Self_ID.Pending_ATC_Level < Self_ID.ATC_Nesting_Level
then
Unlock (Self_ID);
raise Standard'Abort_Signal;
end if;
end Sleep;
-----------------
-- Timed_Sleep --
-----------------
-- This is for use within the run-time system, so abort is assumed to be
-- already deferred, and the caller should be holding its own ATCB lock.
procedure Timed_Sleep
(Self_ID : Task_Id;
Time : Duration;
Mode : ST.Delay_Modes;
Reason : System.Tasking.Task_States;
Timedout : out Boolean;
Yielded : out Boolean)
is
pragma Unreferenced (Reason);
Check_Time : Duration := Monotonic_Clock;
Rel_Time : Duration;
Abs_Time : Duration;
Result : Integer;
Local_Timedout : Boolean;
begin
Timedout := True;
Yielded := False;
if Mode = Relative then
Rel_Time := Time;
Abs_Time := Duration'Min (Time, Max_Sensible_Delay) + Check_Time;
else
Rel_Time := Time - Check_Time;
Abs_Time := Time;
end if;
if Rel_Time > 0.0 then
loop
exit when Self_ID.Pending_ATC_Level < Self_ID.ATC_Nesting_Level;
Cond_Timed_Wait
(Self_ID.Common.LL.CV'Access,
Self_ID.Common.LL.L'Access,
Rel_Time, Local_Timedout, Result);
Check_Time := Monotonic_Clock;
exit when Abs_Time <= Check_Time;
if not Local_Timedout then
-- Somebody may have called Wakeup for us
Timedout := False;
exit;
end if;
Rel_Time := Abs_Time - Check_Time;
end loop;
end if;
end Timed_Sleep;
-----------------
-- Timed_Delay --
-----------------
procedure Timed_Delay
(Self_ID : Task_Id;
Time : Duration;
Mode : ST.Delay_Modes)
is
Check_Time : Duration := Monotonic_Clock;
Rel_Time : Duration;
Abs_Time : Duration;
Timedout : Boolean;
Result : Integer;
begin
Write_Lock (Self_ID);
if Mode = Relative then
Rel_Time := Time;
Abs_Time := Time + Check_Time;
else
Rel_Time := Time - Check_Time;
Abs_Time := Time;
end if;
if Rel_Time > 0.0 then
Self_ID.Common.State := Delay_Sleep;
loop
exit when Self_ID.Pending_ATC_Level < Self_ID.ATC_Nesting_Level;
Cond_Timed_Wait
(Self_ID.Common.LL.CV'Access,
Self_ID.Common.LL.L'Access,
Rel_Time, Timedout, Result);
Check_Time := Monotonic_Clock;
exit when Abs_Time <= Check_Time;
Rel_Time := Abs_Time - Check_Time;
end loop;
Self_ID.Common.State := Runnable;
end if;
Unlock (Self_ID);
Yield;
end Timed_Delay;
------------
-- Wakeup --
------------
procedure Wakeup (T : Task_Id; Reason : System.Tasking.Task_States) is
pragma Unreferenced (Reason);
begin
Cond_Signal (T.Common.LL.CV'Access);
end Wakeup;
-----------
-- Yield --
-----------
procedure Yield (Do_Yield : Boolean := True) is
begin
-- Note: in a previous implementation if Do_Yield was False, then we
-- introduced a delay of 1 millisecond in an attempt to get closer to
-- annex D semantics, and in particular to make ACATS CXD8002 pass. But
-- this change introduced a huge performance regression evaluating the
-- Count attribute. So we decided to remove this processing.
-- Moreover, CXD8002 appears to pass on Windows (although we do not
-- guarantee full Annex D compliance on Windows in any case).
if Do_Yield then
SwitchToThread;
end if;
end Yield;
------------------
-- Set_Priority --
------------------
procedure Set_Priority
(T : Task_Id;
Prio : System.Any_Priority;
Loss_Of_Inheritance : Boolean := False)
is
Res : BOOL;
pragma Unreferenced (Loss_Of_Inheritance);
begin
Res :=
SetThreadPriority
(T.Common.LL.Thread,
Interfaces.C.int (Underlying_Priorities (Prio)));
pragma Assert (Res = Win32.TRUE);
-- Note: Annex D (RM D.2.3(5/2)) requires the task to be placed at the
-- head of its priority queue when decreasing its priority as a result
-- of a loss of inherited priority. This is not the case, but we
-- consider it an acceptable variation (RM 1.1.3(6)), given this is
-- the built-in behavior offered by the Windows operating system.
-- In older versions we attempted to better approximate the Annex D
-- required behavior, but this simulation was not entirely accurate,
-- and it seems better to live with the standard Windows semantics.
T.Common.Current_Priority := Prio;
end Set_Priority;
------------------
-- Get_Priority --
------------------
function Get_Priority (T : Task_Id) return System.Any_Priority is
begin
return T.Common.Current_Priority;
end Get_Priority;
----------------
-- Enter_Task --
----------------
-- There were two paths were we needed to call Enter_Task :
-- 1) from System.Task_Primitives.Operations.Initialize
-- 2) from System.Tasking.Stages.Task_Wrapper
-- The pseudo handle (LL.Thread) need not be closed when it is no
-- longer needed. Calling the CloseHandle function with this handle
-- has no effect.
procedure Enter_Task (Self_ID : Task_Id) is
procedure Get_Stack_Bounds (Base : Address; Limit : Address);
pragma Import (C, Get_Stack_Bounds, "__gnat_get_stack_bounds");
-- Get stack boundaries
begin
Specific.Set (Self_ID);
-- Properly initializes the FPU for x86 systems
System.Float_Control.Reset;
if Self_ID.Common.Task_Info /= null
and then
Self_ID.Common.Task_Info.CPU >= CPU_Number (Number_Of_Processors)
then
raise Invalid_CPU_Number;
end if;
-- Initialize the thread here only if not set. This is done for a
-- foreign task but is not needed when a real thread-id is already
-- set in Create_Task. Note that we do want to keep the real thread-id
-- as it is the only way to free the associated resource. Another way
-- to say this is that a pseudo thread-id from a foreign thread won't
-- allow for freeing resources.
if Self_ID.Common.LL.Thread = Null_Thread_Id then
Self_ID.Common.LL.Thread := GetCurrentThread;
end if;
Self_ID.Common.LL.Thread_Id := GetCurrentThreadId;
Get_Stack_Bounds
(Self_ID.Common.Compiler_Data.Pri_Stack_Info.Base'Address,
Self_ID.Common.Compiler_Data.Pri_Stack_Info.Limit'Address);
end Enter_Task;
-------------------
-- Is_Valid_Task --
-------------------
function Is_Valid_Task return Boolean renames Specific.Is_Valid_Task;
-----------------------------
-- Register_Foreign_Thread --
-----------------------------
function Register_Foreign_Thread return Task_Id is
begin
if Is_Valid_Task then
return Self;
else
return Register_Foreign_Thread (GetCurrentThread);
end if;
end Register_Foreign_Thread;
--------------------
-- Initialize_TCB --
--------------------
procedure Initialize_TCB (Self_ID : Task_Id; Succeeded : out Boolean) is
begin
-- Initialize thread ID to 0, this is needed to detect threads that
-- are not yet activated.
Self_ID.Common.LL.Thread := Null_Thread_Id;
Initialize_Cond (Self_ID.Common.LL.CV'Access);
Initialize_Lock (Self_ID.Common.LL.L'Access, ATCB_Level);
Succeeded := True;
end Initialize_TCB;
-----------------
-- Create_Task --
-----------------
procedure Create_Task
(T : Task_Id;
Wrapper : System.Address;
Stack_Size : System.Parameters.Size_Type;
Priority : System.Any_Priority;
Succeeded : out Boolean)
is
Initial_Stack_Size : constant := 1024;
-- We set the initial stack size to 1024. On Windows version prior to XP
-- there is no way to fix a task stack size. Only the initial stack size
-- can be set, the operating system will raise the task stack size if
-- needed.
function Is_Windows_XP return Integer;
pragma Import (C, Is_Windows_XP, "__gnat_is_windows_xp");
-- Returns 1 if running on Windows XP
hTask : HANDLE;
TaskId : aliased DWORD;
pTaskParameter : Win32.PVOID;
Result : DWORD;
Entry_Point : PTHREAD_START_ROUTINE;
use type System.Multiprocessors.CPU_Range;
begin
-- Check whether both Dispatching_Domain and CPU are specified for the
-- task, and the CPU value is not contained within the range of
-- processors for the domain.
if T.Common.Domain /= null
and then T.Common.Base_CPU /= System.Multiprocessors.Not_A_Specific_CPU
and then
(T.Common.Base_CPU not in T.Common.Domain'Range
or else not T.Common.Domain (T.Common.Base_CPU))
then
Succeeded := False;
return;
end if;
pTaskParameter := To_Address (T);
Entry_Point := To_PTHREAD_START_ROUTINE (Wrapper);
if Is_Windows_XP = 1 then
hTask := CreateThread
(null,
DWORD (Stack_Size),
Entry_Point,
pTaskParameter,
DWORD (Create_Suspended)
or DWORD (Stack_Size_Param_Is_A_Reservation),
TaskId'Unchecked_Access);
else
hTask := CreateThread
(null,
Initial_Stack_Size,
Entry_Point,
pTaskParameter,
DWORD (Create_Suspended),
TaskId'Unchecked_Access);
end if;
-- Step 1: Create the thread in blocked mode
if hTask = 0 then
Succeeded := False;
return;
end if;
-- Step 2: set its TCB
T.Common.LL.Thread := hTask;
-- Note: it would be useful to initialize Thread_Id right away to avoid
-- a race condition in gdb where Thread_ID may not have the right value
-- yet, but GetThreadId is a Vista specific API, not available under XP:
-- T.Common.LL.Thread_Id := GetThreadId (hTask); so instead we set the
-- field to 0 to avoid having a random value. Thread_Id is initialized
-- in Enter_Task anyway.
T.Common.LL.Thread_Id := 0;
-- Step 3: set its priority (child has inherited priority from parent)
Set_Priority (T, Priority);
if Time_Slice_Val = 0
or else Dispatching_Policy = 'F'
or else Get_Policy (Priority) = 'F'
then
-- Here we need Annex D semantics so we disable the NT priority
-- boost. A priority boost is temporarily given by the system to
-- a thread when it is taken out of a wait state.
SetThreadPriorityBoost (hTask, DisablePriorityBoost => Win32.TRUE);
end if;
-- Step 4: Handle pragma CPU and Task_Info
Set_Task_Affinity (T);
-- Step 5: Now, start it for good
Result := ResumeThread (hTask);
pragma Assert (Result = 1);
Succeeded := Result = 1;
end Create_Task;
------------------
-- Finalize_TCB --
------------------
procedure Finalize_TCB (T : Task_Id) is
Succeeded : BOOL;
pragma Unreferenced (Succeeded);
begin
Finalize_Lock (T.Common.LL.L'Access);
Finalize_Cond (T.Common.LL.CV'Access);
if T.Known_Tasks_Index /= -1 then
Known_Tasks (T.Known_Tasks_Index) := null;
end if;
if T.Common.LL.Thread /= Null_Thread_Id then
-- This task has been activated. Close the thread handle. This
-- is needed to release system resources.
Succeeded := CloseHandle (T.Common.LL.Thread);
-- Note that we do not check for the returned value, this is
-- because the above call will fail for a foreign thread. But
-- we still need to call it to properly close Ada tasks created
-- with CreateThread() in Create_Task above.
end if;
ATCB_Allocation.Free_ATCB (T);
end Finalize_TCB;
---------------
-- Exit_Task --
---------------
procedure Exit_Task is
begin
Specific.Set (null);
end Exit_Task;
----------------
-- Abort_Task --
----------------
procedure Abort_Task (T : Task_Id) is
pragma Unreferenced (T);
begin
null;
end Abort_Task;
----------------------
-- Environment_Task --
----------------------
function Environment_Task return Task_Id is
begin
return Environment_Task_Id;
end Environment_Task;
--------------
-- Lock_RTS --
--------------
procedure Lock_RTS is
begin
Write_Lock (Single_RTS_Lock'Access);
end Lock_RTS;
----------------
-- Unlock_RTS --
----------------
procedure Unlock_RTS is
begin
Unlock (Single_RTS_Lock'Access);
end Unlock_RTS;
----------------
-- Initialize --
----------------
procedure Initialize (Environment_Task : Task_Id) is
Discard : BOOL;
begin
Environment_Task_Id := Environment_Task;
OS_Primitives.Initialize;
Interrupt_Management.Initialize;
if Time_Slice_Val = 0 or else Dispatching_Policy = 'F' then
-- Here we need Annex D semantics, switch the current process to the
-- Realtime_Priority_Class.
Discard := OS_Interface.SetPriorityClass
(GetCurrentProcess, Realtime_Priority_Class);
end if;
TlsIndex := TlsAlloc;
-- Initialize the lock used to synchronize chain of all ATCBs
Initialize_Lock (Single_RTS_Lock'Access, RTS_Lock_Level);
Environment_Task.Common.LL.Thread := GetCurrentThread;
-- Make environment task known here because it doesn't go through
-- Activate_Tasks, which does it for all other tasks.
Known_Tasks (Known_Tasks'First) := Environment_Task;
Environment_Task.Known_Tasks_Index := Known_Tasks'First;
Enter_Task (Environment_Task);
-- pragma CPU and dispatching domains for the environment task
Set_Task_Affinity (Environment_Task);
end Initialize;
---------------------
-- Monotonic_Clock --
---------------------
function Monotonic_Clock return Duration is
function Internal_Clock return Duration;
pragma Import (Ada, Internal_Clock, "__gnat_monotonic_clock");
begin
return Internal_Clock;
end Monotonic_Clock;
-------------------
-- RT_Resolution --
-------------------
function RT_Resolution return Duration is
Ticks_Per_Second : aliased LARGE_INTEGER;
begin
QueryPerformanceFrequency (Ticks_Per_Second'Access);
return Duration (1.0 / Ticks_Per_Second);
end RT_Resolution;
----------------
-- Initialize --
----------------
procedure Initialize (S : in out Suspension_Object) is
begin
-- Initialize internal state. It is always initialized to False (ARM
-- D.10 par. 6).
S.State := False;
S.Waiting := False;
-- Initialize internal mutex
InitializeCriticalSection (S.L'Access);
-- Initialize internal condition variable
S.CV := CreateEvent (null, Win32.TRUE, Win32.FALSE, Null_Ptr);
pragma Assert (S.CV /= 0);
end Initialize;
--------------
-- Finalize --
--------------
procedure Finalize (S : in out Suspension_Object) is
Result : BOOL;
begin
-- Destroy internal mutex
DeleteCriticalSection (S.L'Access);
-- Destroy internal condition variable
Result := CloseHandle (S.CV);
pragma Assert (Result = Win32.TRUE);
end Finalize;
-------------------
-- Current_State --
-------------------
function Current_State (S : Suspension_Object) return Boolean is
begin
-- We do not want to use lock on this read operation. State is marked
-- as Atomic so that we ensure that the value retrieved is correct.
return S.State;
end Current_State;
---------------
-- Set_False --
---------------
procedure Set_False (S : in out Suspension_Object) is
begin
SSL.Abort_Defer.all;
EnterCriticalSection (S.L'Access);
S.State := False;
LeaveCriticalSection (S.L'Access);
SSL.Abort_Undefer.all;
end Set_False;
--------------
-- Set_True --
--------------
procedure Set_True (S : in out Suspension_Object) is
Result : BOOL;
begin
SSL.Abort_Defer.all;
EnterCriticalSection (S.L'Access);
-- If there is already a task waiting on this suspension object then
-- we resume it, leaving the state of the suspension object to False,
-- as it is specified in ARM D.10 par. 9. Otherwise, it just leaves
-- the state to True.
if S.Waiting then
S.Waiting := False;
S.State := False;
Result := SetEvent (S.CV);
pragma Assert (Result = Win32.TRUE);
else
S.State := True;
end if;
LeaveCriticalSection (S.L'Access);
SSL.Abort_Undefer.all;
end Set_True;
------------------------
-- Suspend_Until_True --
------------------------
procedure Suspend_Until_True (S : in out Suspension_Object) is
Result : DWORD;
Result_Bool : BOOL;
begin
SSL.Abort_Defer.all;
EnterCriticalSection (S.L'Access);
if S.Waiting then
-- Program_Error must be raised upon calling Suspend_Until_True
-- if another task is already waiting on that suspension object
-- (ARM D.10 par. 10).
LeaveCriticalSection (S.L'Access);
SSL.Abort_Undefer.all;
raise Program_Error;
else
-- Suspend the task if the state is False. Otherwise, the task
-- continues its execution, and the state of the suspension object
-- is set to False (ARM D.10 par. 9).
if S.State then
S.State := False;
LeaveCriticalSection (S.L'Access);
SSL.Abort_Undefer.all;
else
S.Waiting := True;
-- Must reset CV BEFORE L is unlocked
Result_Bool := ResetEvent (S.CV);
pragma Assert (Result_Bool = Win32.TRUE);
LeaveCriticalSection (S.L'Access);
SSL.Abort_Undefer.all;
Result := WaitForSingleObject (S.CV, Wait_Infinite);
pragma Assert (Result = 0);
end if;
end if;
end Suspend_Until_True;
----------------
-- Check_Exit --
----------------
-- Dummy versions, currently this only works for solaris (native)
function Check_Exit (Self_ID : ST.Task_Id) return Boolean is
pragma Unreferenced (Self_ID);
begin
return True;
end Check_Exit;
--------------------
-- Check_No_Locks --
--------------------
function Check_No_Locks (Self_ID : ST.Task_Id) return Boolean is
pragma Unreferenced (Self_ID);
begin
return True;
end Check_No_Locks;
------------------
-- Suspend_Task --
------------------
function Suspend_Task
(T : ST.Task_Id;
Thread_Self : Thread_Id) return Boolean
is
begin
if T.Common.LL.Thread /= Thread_Self then
return SuspendThread (T.Common.LL.Thread) = NO_ERROR;
else
return True;
end if;
end Suspend_Task;
-----------------
-- Resume_Task --
-----------------
function Resume_Task
(T : ST.Task_Id;
Thread_Self : Thread_Id) return Boolean
is
begin
if T.Common.LL.Thread /= Thread_Self then
return ResumeThread (T.Common.LL.Thread) = NO_ERROR;
else
return True;
end if;
end Resume_Task;
--------------------
-- Stop_All_Tasks --
--------------------
procedure Stop_All_Tasks is
begin
null;
end Stop_All_Tasks;
---------------
-- Stop_Task --
---------------
function Stop_Task (T : ST.Task_Id) return Boolean is
pragma Unreferenced (T);
begin
return False;
end Stop_Task;
-------------------
-- Continue_Task --
-------------------
function Continue_Task (T : ST.Task_Id) return Boolean is
pragma Unreferenced (T);
begin
return False;
end Continue_Task;
-----------------------
-- Set_Task_Affinity --
-----------------------
procedure Set_Task_Affinity (T : ST.Task_Id) is
Result : DWORD;
use type System.Multiprocessors.CPU_Range;
begin
-- Do nothing if the underlying thread has not yet been created. If the
-- thread has not yet been created then the proper affinity will be set
-- during its creation.
if T.Common.LL.Thread = Null_Thread_Id then
null;
-- pragma CPU
elsif T.Common.Base_CPU /= Multiprocessors.Not_A_Specific_CPU then
-- The CPU numbering in pragma CPU starts at 1 while the subprogram
-- to set the affinity starts at 0, therefore we must substract 1.
Result :=
SetThreadIdealProcessor
(T.Common.LL.Thread, ProcessorId (T.Common.Base_CPU) - 1);
pragma Assert (Result = 1);
-- Task_Info
elsif T.Common.Task_Info /= null then
if T.Common.Task_Info.CPU /= Task_Info.Any_CPU then
Result :=
SetThreadIdealProcessor
(T.Common.LL.Thread, T.Common.Task_Info.CPU);
pragma Assert (Result = 1);
end if;
-- Dispatching domains
elsif T.Common.Domain /= null
and then (T.Common.Domain /= ST.System_Domain
or else
T.Common.Domain.all /=
(Multiprocessors.CPU'First ..
Multiprocessors.Number_Of_CPUs => True))
then
declare
CPU_Set : DWORD := 0;
begin
for Proc in T.Common.Domain'Range loop
if T.Common.Domain (Proc) then
-- The thread affinity mask is a bit vector in which each
-- bit represents a logical processor.
CPU_Set := CPU_Set + 2 ** (Integer (Proc) - 1);
end if;
end loop;
Result := SetThreadAffinityMask (T.Common.LL.Thread, CPU_Set);
pragma Assert (Result = 1);
end;
end if;
end Set_Task_Affinity;
end System.Task_Primitives.Operations;
|
Gabriel-Degret/adalib | Ada | 2,256 | ads | -- Standard Ada library specification
-- Copyright (c) 2003-2018 Maxim Reznik <[email protected]>
-- Copyright (c) 2004-2016 AXE Consultants
-- Copyright (c) 2004, 2005, 2006 Ada-Europe
-- Copyright (c) 2000 The MITRE Corporation, Inc.
-- Copyright (c) 1992, 1993, 1994, 1995 Intermetrics, Inc.
-- SPDX-License-Identifier: BSD-3-Clause and LicenseRef-AdaReferenceManual
---------------------------------------------------------------------------
with Ada.IO_Exceptions;
generic
type Element_Type (<>) is private;
package Ada.Sequential_IO is
type File_Type is limited private;
type File_Mode is (In_File, Out_File, Append_File);
-- File management
procedure Create (File : in out File_Type;
Mode : in File_Mode := Out_File;
Name : in String := "";
Form : in String := "");
procedure Open (File : in out File_Type;
Mode : in File_Mode;
Name : in String;
Form : in String := "");
procedure Close (File : in out File_Type);
procedure Delete (File : in out File_Type);
procedure Reset (File : in out File_Type; Mode : in File_Mode);
procedure Reset (File : in out File_Type);
function Mode (File : in File_Type) return File_Mode;
function Name (File : in File_Type) return String;
function Form (File : in File_Type) return String;
function Is_Open (File : in File_Type) return Boolean;
-- Input and output operations
procedure Read (File : in File_Type; Item : out Element_Type);
procedure Write (File : in File_Type; Item : in Element_Type);
function End_Of_File (File : in File_Type) return Boolean;
-- Exceptions
Status_Error : exception renames IO_Exceptions.Status_Error;
Mode_Error : exception renames IO_Exceptions.Mode_Error;
Name_Error : exception renames IO_Exceptions.Name_Error;
Use_Error : exception renames IO_Exceptions.Use_Error;
Device_Error : exception renames IO_Exceptions.Device_Error;
End_Error : exception renames IO_Exceptions.End_Error;
Data_Error : exception renames IO_Exceptions.Data_Error;
private
type File_Type is limited null record;
end Ada.Sequential_IO;
|
zhmu/ananas | Ada | 20,110 | adb | ------------------------------------------------------------------------------
-- --
-- GNAT RUN-TIME LIBRARY (GNARL) COMPONENTS --
-- --
-- S Y S T E M . I N T E R R U P T S --
-- --
-- B o d y --
-- --
-- Copyright (C) 1998-2022, Free Software Foundation, Inc. --
-- --
-- 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. 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/>. --
-- --
-- GNARL was developed by the GNARL team at Florida State University. --
-- Extensive contributions were provided by Ada Core Technologies, Inc. --
-- --
------------------------------------------------------------------------------
-- This is the NT version of this package
with Ada.Task_Identification;
with Ada.Unchecked_Conversion;
with Interfaces.C;
with System.Storage_Elements;
with System.Task_Primitives.Operations;
with System.Tasking.Utilities;
with System.Tasking.Rendezvous;
with System.Tasking.Initialization;
with System.Interrupt_Management;
package body System.Interrupts is
use Tasking;
use System.OS_Interface;
use Interfaces.C;
package STPO renames System.Task_Primitives.Operations;
package IMNG renames System.Interrupt_Management;
subtype int is Interfaces.C.int;
function To_System is new Ada.Unchecked_Conversion
(Ada.Task_Identification.Task_Id, Task_Id);
type Handler_Kind is (Unknown, Task_Entry, Protected_Procedure);
type Handler_Desc is record
Kind : Handler_Kind := Unknown;
T : Task_Id;
E : Task_Entry_Index;
H : Parameterless_Handler;
Static : Boolean := False;
end record;
task type Server_Task (Interrupt : Interrupt_ID) is
pragma Interrupt_Priority (System.Interrupt_Priority'Last);
end Server_Task;
type Server_Task_Access is access Server_Task;
Handlers : array (Interrupt_ID) of Task_Id;
Descriptors : array (Interrupt_ID) of Handler_Desc;
Interrupt_Count : array (Interrupt_ID) of Integer := (others => 0);
pragma Volatile_Components (Interrupt_Count);
procedure Attach_Handler
(New_Handler : Parameterless_Handler;
Interrupt : Interrupt_ID;
Static : Boolean;
Restoration : Boolean);
-- This internal procedure is needed to finalize protected objects that
-- contain interrupt handlers.
procedure Signal_Handler (Sig : Interrupt_ID);
pragma Convention (C, Signal_Handler);
-- This procedure is used to handle all the signals
-- Type and Head, Tail of the list containing Registered Interrupt
-- Handlers. These definitions are used to register the handlers
-- specified by the pragma Interrupt_Handler.
--------------------------
-- Handler Registration --
--------------------------
type Registered_Handler;
type R_Link is access all Registered_Handler;
type Registered_Handler is record
H : System.Address := System.Null_Address;
Next : R_Link := null;
end record;
Registered_Handlers : R_Link := null;
function Is_Registered (Handler : Parameterless_Handler) return Boolean;
-- See if the Handler has been "pragma"ed using Interrupt_Handler.
-- Always consider a null handler as registered.
type Handler_Ptr is access procedure (Sig : Interrupt_ID);
pragma Convention (C, Handler_Ptr);
function TISR is new Ada.Unchecked_Conversion (Handler_Ptr, isr_address);
--------------------
-- Signal_Handler --
--------------------
procedure Signal_Handler (Sig : Interrupt_ID) is
Handler : Task_Id renames Handlers (Sig);
begin
if Intr_Attach_Reset and then
intr_attach (int (Sig), TISR (Signal_Handler'Access)) = FUNC_ERR
then
raise Program_Error;
end if;
if Handler /= null then
Interrupt_Count (Sig) := Interrupt_Count (Sig) + 1;
STPO.Wakeup (Handler, Interrupt_Server_Idle_Sleep);
end if;
end Signal_Handler;
-----------------
-- Is_Reserved --
-----------------
function Is_Reserved (Interrupt : Interrupt_ID) return Boolean is
begin
return IMNG.Reserve (IMNG.Interrupt_ID (Interrupt));
end Is_Reserved;
-----------------------
-- Is_Entry_Attached --
-----------------------
function Is_Entry_Attached (Interrupt : Interrupt_ID) return Boolean is
begin
if Is_Reserved (Interrupt) then
raise Program_Error with
"interrupt" & Interrupt_ID'Image (Interrupt) & " is reserved";
end if;
return Descriptors (Interrupt).T /= Null_Task;
end Is_Entry_Attached;
-------------------------
-- Is_Handler_Attached --
-------------------------
function Is_Handler_Attached (Interrupt : Interrupt_ID) return Boolean is
begin
if Is_Reserved (Interrupt) then
raise Program_Error with
"interrupt" & Interrupt_ID'Image (Interrupt) & " is reserved";
else
return Descriptors (Interrupt).Kind /= Unknown;
end if;
end Is_Handler_Attached;
----------------
-- Is_Ignored --
----------------
function Is_Ignored (Interrupt : Interrupt_ID) return Boolean is
begin
raise Program_Error;
return False;
end Is_Ignored;
------------------
-- Unblocked_By --
------------------
function Unblocked_By (Interrupt : Interrupt_ID) return Task_Id is
begin
raise Program_Error;
return Null_Task;
end Unblocked_By;
----------------------
-- Ignore_Interrupt --
----------------------
procedure Ignore_Interrupt (Interrupt : Interrupt_ID) is
begin
raise Program_Error;
end Ignore_Interrupt;
------------------------
-- Unignore_Interrupt --
------------------------
procedure Unignore_Interrupt (Interrupt : Interrupt_ID) is
begin
raise Program_Error;
end Unignore_Interrupt;
-------------------------------------
-- Has_Interrupt_Or_Attach_Handler --
-------------------------------------
function Has_Interrupt_Or_Attach_Handler
(Object : access Dynamic_Interrupt_Protection) return Boolean
is
pragma Unreferenced (Object);
begin
return True;
end Has_Interrupt_Or_Attach_Handler;
--------------
-- Finalize --
--------------
procedure Finalize (Object : in out Static_Interrupt_Protection) is
begin
-- ??? loop to be executed only when we're not doing library level
-- finalization, since in this case all interrupt tasks are gone.
for N in reverse Object.Previous_Handlers'Range loop
Attach_Handler
(New_Handler => Object.Previous_Handlers (N).Handler,
Interrupt => Object.Previous_Handlers (N).Interrupt,
Static => Object.Previous_Handlers (N).Static,
Restoration => True);
end loop;
Tasking.Protected_Objects.Entries.Finalize
(Tasking.Protected_Objects.Entries.Protection_Entries (Object));
end Finalize;
-------------------------------------
-- Has_Interrupt_Or_Attach_Handler --
-------------------------------------
function Has_Interrupt_Or_Attach_Handler
(Object : access Static_Interrupt_Protection) return Boolean
is
pragma Unreferenced (Object);
begin
return True;
end Has_Interrupt_Or_Attach_Handler;
----------------------
-- Install_Handlers --
----------------------
procedure Install_Handlers
(Object : access Static_Interrupt_Protection;
New_Handlers : New_Handler_Array)
is
begin
for N in New_Handlers'Range loop
-- We need a lock around this ???
Object.Previous_Handlers (N).Interrupt := New_Handlers (N).Interrupt;
Object.Previous_Handlers (N).Static := Descriptors
(New_Handlers (N).Interrupt).Static;
-- We call Exchange_Handler and not directly Interrupt_Manager.
-- Exchange_Handler so we get the Is_Reserved check.
Exchange_Handler
(Old_Handler => Object.Previous_Handlers (N).Handler,
New_Handler => New_Handlers (N).Handler,
Interrupt => New_Handlers (N).Interrupt,
Static => True);
end loop;
end Install_Handlers;
---------------------------------
-- Install_Restricted_Handlers --
---------------------------------
procedure Install_Restricted_Handlers
(Prio : Interrupt_Priority;
Handlers : New_Handler_Array)
is
pragma Unreferenced (Prio);
begin
for N in Handlers'Range loop
Attach_Handler (Handlers (N).Handler, Handlers (N).Interrupt, True);
end loop;
end Install_Restricted_Handlers;
---------------------
-- Current_Handler --
---------------------
function Current_Handler
(Interrupt : Interrupt_ID) return Parameterless_Handler
is
begin
if Is_Reserved (Interrupt) then
raise Program_Error;
end if;
if Descriptors (Interrupt).Kind = Protected_Procedure then
return Descriptors (Interrupt).H;
else
return null;
end if;
end Current_Handler;
--------------------
-- Attach_Handler --
--------------------
procedure Attach_Handler
(New_Handler : Parameterless_Handler;
Interrupt : Interrupt_ID;
Static : Boolean := False)
is
begin
Attach_Handler (New_Handler, Interrupt, Static, False);
end Attach_Handler;
procedure Attach_Handler
(New_Handler : Parameterless_Handler;
Interrupt : Interrupt_ID;
Static : Boolean;
Restoration : Boolean)
is
New_Task : Server_Task_Access;
begin
if Is_Reserved (Interrupt) then
raise Program_Error;
end if;
if not Restoration and then not Static
-- Tries to overwrite a static Interrupt Handler with dynamic handle
and then
(Descriptors (Interrupt).Static
-- New handler not specified as an Interrupt Handler by a pragma
or else not Is_Registered (New_Handler))
then
raise Program_Error with
"trying to overwrite a static interrupt handler with a " &
"dynamic handler";
end if;
if Handlers (Interrupt) = null then
New_Task := new Server_Task (Interrupt);
Handlers (Interrupt) := To_System (New_Task.all'Identity);
end if;
if intr_attach (int (Interrupt),
TISR (Signal_Handler'Access)) = FUNC_ERR
then
raise Program_Error;
end if;
if New_Handler = null then
-- The null handler means we are detaching the handler
Descriptors (Interrupt) :=
(Kind => Unknown, T => null, E => 0, H => null, Static => False);
else
Descriptors (Interrupt).Kind := Protected_Procedure;
Descriptors (Interrupt).H := New_Handler;
Descriptors (Interrupt).Static := Static;
end if;
end Attach_Handler;
----------------------
-- Exchange_Handler --
----------------------
procedure Exchange_Handler
(Old_Handler : out Parameterless_Handler;
New_Handler : Parameterless_Handler;
Interrupt : Interrupt_ID;
Static : Boolean := False)
is
begin
if Is_Reserved (Interrupt) then
raise Program_Error;
end if;
if Descriptors (Interrupt).Kind = Task_Entry then
-- In case we have an Interrupt Entry already installed, raise a
-- program error (propagate it to the caller).
raise Program_Error with "an interrupt is already installed";
else
Old_Handler := Current_Handler (Interrupt);
Attach_Handler (New_Handler, Interrupt, Static);
end if;
end Exchange_Handler;
--------------------
-- Detach_Handler --
--------------------
procedure Detach_Handler
(Interrupt : Interrupt_ID;
Static : Boolean := False)
is
begin
if Is_Reserved (Interrupt) then
raise Program_Error;
end if;
if Descriptors (Interrupt).Kind = Task_Entry then
raise Program_Error with "trying to detach an interrupt entry";
end if;
if not Static and then Descriptors (Interrupt).Static then
raise Program_Error with
"trying to detach a static interrupt handler";
end if;
Descriptors (Interrupt) :=
(Kind => Unknown, T => null, E => 0, H => null, Static => False);
if intr_attach (int (Interrupt), null) = FUNC_ERR then
raise Program_Error;
end if;
end Detach_Handler;
---------------
-- Reference --
---------------
function Reference (Interrupt : Interrupt_ID) return System.Address is
Signal : constant System.Address :=
System.Storage_Elements.To_Address
(System.Storage_Elements.Integer_Address (Interrupt));
begin
if Is_Reserved (Interrupt) then
-- Only usable Interrupts can be used for binding it to an Entry
raise Program_Error;
end if;
return Signal;
end Reference;
--------------------------------
-- Register_Interrupt_Handler --
--------------------------------
procedure Register_Interrupt_Handler (Handler_Addr : System.Address) is
begin
Registered_Handlers :=
new Registered_Handler'(H => Handler_Addr, Next => Registered_Handlers);
end Register_Interrupt_Handler;
-------------------
-- Is_Registered --
-------------------
-- See if the Handler has been "pragma"ed using Interrupt_Handler.
-- Always consider a null handler as registered.
function Is_Registered (Handler : Parameterless_Handler) return Boolean is
Ptr : R_Link := Registered_Handlers;
type Acc_Proc is access procedure;
type Fat_Ptr is record
Object_Addr : System.Address;
Handler_Addr : Acc_Proc;
end record;
function To_Fat_Ptr is new Ada.Unchecked_Conversion
(Parameterless_Handler, Fat_Ptr);
Fat : Fat_Ptr;
begin
if Handler = null then
return True;
end if;
Fat := To_Fat_Ptr (Handler);
while Ptr /= null loop
if Ptr.H = Fat.Handler_Addr.all'Address then
return True;
end if;
Ptr := Ptr.Next;
end loop;
return False;
end Is_Registered;
-----------------------------
-- Bind_Interrupt_To_Entry --
-----------------------------
procedure Bind_Interrupt_To_Entry
(T : Task_Id;
E : Task_Entry_Index;
Int_Ref : System.Address)
is
Interrupt : constant Interrupt_ID :=
Interrupt_ID (Storage_Elements.To_Integer (Int_Ref));
New_Task : Server_Task_Access;
begin
if Is_Reserved (Interrupt) then
raise Program_Error;
end if;
if Descriptors (Interrupt).Kind /= Unknown then
raise Program_Error with
"a binding for this interrupt is already present";
end if;
if Handlers (Interrupt) = null then
New_Task := new Server_Task (Interrupt);
Handlers (Interrupt) := To_System (New_Task.all'Identity);
end if;
if intr_attach (int (Interrupt),
TISR (Signal_Handler'Access)) = FUNC_ERR
then
raise Program_Error;
end if;
Descriptors (Interrupt).Kind := Task_Entry;
Descriptors (Interrupt).T := T;
Descriptors (Interrupt).E := E;
-- Indicate the attachment of Interrupt Entry in ATCB. This is needed so
-- that when an Interrupt Entry task terminates the binding can be
-- cleaned up. The call to unbinding must be make by the task before it
-- terminates.
T.Interrupt_Entry := True;
end Bind_Interrupt_To_Entry;
------------------------------
-- Detach_Interrupt_Entries --
------------------------------
procedure Detach_Interrupt_Entries (T : Task_Id) is
begin
for J in Interrupt_ID loop
if not Is_Reserved (J) then
if Descriptors (J).Kind = Task_Entry
and then Descriptors (J).T = T
then
Descriptors (J).Kind := Unknown;
if intr_attach (int (J), null) = FUNC_ERR then
raise Program_Error;
end if;
end if;
end if;
end loop;
-- Indicate in ATCB that no Interrupt Entries are attached
T.Interrupt_Entry := True;
end Detach_Interrupt_Entries;
---------------------
-- Block_Interrupt --
---------------------
procedure Block_Interrupt (Interrupt : Interrupt_ID) is
begin
raise Program_Error;
end Block_Interrupt;
-----------------------
-- Unblock_Interrupt --
-----------------------
procedure Unblock_Interrupt (Interrupt : Interrupt_ID) is
begin
raise Program_Error;
end Unblock_Interrupt;
----------------
-- Is_Blocked --
----------------
function Is_Blocked (Interrupt : Interrupt_ID) return Boolean is
begin
raise Program_Error;
return False;
end Is_Blocked;
task body Server_Task is
Ignore : constant Boolean := Utilities.Make_Independent;
Desc : Handler_Desc renames Descriptors (Interrupt);
Self_Id : constant Task_Id := STPO.Self;
Temp : Parameterless_Handler;
begin
loop
while Interrupt_Count (Interrupt) > 0 loop
Interrupt_Count (Interrupt) := Interrupt_Count (Interrupt) - 1;
begin
case Desc.Kind is
when Unknown =>
null;
when Task_Entry =>
Rendezvous.Call_Simple (Desc.T, Desc.E, Null_Address);
when Protected_Procedure =>
Temp := Desc.H;
Temp.all;
end case;
exception
when others => null;
end;
end loop;
Initialization.Defer_Abort (Self_Id);
STPO.Write_Lock (Self_Id);
Self_Id.Common.State := Interrupt_Server_Idle_Sleep;
STPO.Sleep (Self_Id, Interrupt_Server_Idle_Sleep);
Self_Id.Common.State := Runnable;
STPO.Unlock (Self_Id);
Initialization.Undefer_Abort (Self_Id);
-- Undefer abort here to allow a window for this task to be aborted
-- at the time of system shutdown.
end loop;
end Server_Task;
end System.Interrupts;
|
HeisenbugLtd/open_weather_map_api | Ada | 3,555 | adb | --------------------------------------------------------------------------------
-- Copyright (C) 2020 by Heisenbug Ltd. ([email protected])
--
-- This work is free. You can redistribute it and/or modify it under the
-- terms of the Do What The Fuck You Want To Public License, Version 2,
-- as published by Sam Hocevar. See the LICENSE file for more details.
--------------------------------------------------------------------------------
pragma License (Unrestricted);
with Ada.Directories;
with Ada.Text_IO;
package body Open_Weather_Map.Configuration is
My_Debug : constant not null GNATCOLL.Traces.Trace_Handle :=
GNATCOLL.Traces.Create (Unit_Name => "OWM.CONFIGURATION");
Config_Name : constant String := "config";
Config_Ext : constant String := "json";
-- Full configuration file name: "$HOME/.openweathermap/config.json".
-----------------------------------------------------------------------------
-- Initialize
-----------------------------------------------------------------------------
procedure Initialize (Self : out T) is
begin
My_Debug.all.Trace (Message => "Initialize");
Self.Read_Config
(From_File =>
Ada.Directories.Compose
(Containing_Directory => Application_Directory,
Name => Config_Name,
Extension => Config_Ext));
end Initialize;
-----------------------------------------------------------------------------
-- Read_Config
-----------------------------------------------------------------------------
procedure Read_Config (Self : in out T;
From_File : in String) is
Content : Ada.Strings.Unbounded.Unbounded_String;
begin
My_Debug.all.Trace (Message => "Read_Config");
My_Debug.all.Trace
(Message =>
"Read_Config: Reading configuration file """ & From_File & """.");
declare
JSON_File : Ada.Text_IO.File_Type;
begin
Ada.Text_IO.Open (File => JSON_File,
Mode => Ada.Text_IO.In_File,
Name => From_File);
begin
while not Ada.Text_IO.End_Of_File (File => JSON_File) loop
Ada.Strings.Unbounded.Append
(Source => Content,
New_Item => Ada.Text_IO.Get_Line (JSON_File));
end loop;
exception
when others =>
Ada.Text_IO.Close (File => JSON_File);
raise;
end;
Ada.Text_IO.Close (File => JSON_File);
exception
when E : others =>
My_Debug.all.Trace
(E => E,
Msg => "Read_Config: Error reading """ & From_File & """: ");
Ada.Text_IO.Put_Line
(File => Ada.Text_IO.Standard_Error,
Item =>
"Error reading from file """ & From_File & """, " &
"no configuration loaded!");
end;
begin
Self.Config := GNATCOLL.JSON.Read (Strm => Content,
Filename => From_File);
My_Debug.all.Trace (Message => "Read_Config: Configuration loaded.");
exception
when E : GNATCOLL.JSON.Invalid_JSON_Stream =>
My_Debug.all.Trace
(E => E,
Msg => "Read_Config: Invalid data in JSON stream: ");
-- Error reporting already done by callee.
end;
end Read_Config;
end Open_Weather_Map.Configuration;
|
reznikmm/matreshka | Ada | 6,881 | 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.Column_Sep_Elements is
------------
-- Create --
------------
overriding function Create
(Parameters : not null access Matreshka.DOM_Elements.Element_L2_Parameters)
return Style_Column_Sep_Element_Node is
begin
return Self : Style_Column_Sep_Element_Node do
Matreshka.ODF_Style.Constructors.Initialize
(Self'Unchecked_Access,
Parameters.Document,
Matreshka.ODF_String_Constants.Style_Prefix);
end return;
end Create;
----------------
-- Enter_Node --
----------------
overriding procedure Enter_Node
(Self : not null access Style_Column_Sep_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_Style_Column_Sep
(ODF.DOM.Style_Column_Sep_Elements.ODF_Style_Column_Sep_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 Style_Column_Sep_Element_Node)
return League.Strings.Universal_String
is
pragma Unreferenced (Self);
begin
return Matreshka.ODF_String_Constants.Column_Sep_Element;
end Get_Local_Name;
----------------
-- Leave_Node --
----------------
overriding procedure Leave_Node
(Self : not null access Style_Column_Sep_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_Style_Column_Sep
(ODF.DOM.Style_Column_Sep_Elements.ODF_Style_Column_Sep_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 Style_Column_Sep_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_Style_Column_Sep
(Visitor,
ODF.DOM.Style_Column_Sep_Elements.ODF_Style_Column_Sep_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.Style_URI,
Matreshka.ODF_String_Constants.Column_Sep_Element,
Style_Column_Sep_Element_Node'Tag);
end Matreshka.ODF_Style.Column_Sep_Elements;
|
io7m/coreland-openal-ada | Ada | 2,520 | ads | with OpenAL.Types;
package OpenAL.Buffer is
--
-- Types
--
type Buffer_t is private;
type Buffer_Array_t is array (Positive range <>) of Buffer_t;
No_Buffer : constant Buffer_t;
--
-- API
--
-- proc_map : alGenBuffers
procedure Generate_Buffers
(Buffers : in out Buffer_Array_t);
-- proc_map : alDeleteBuffers
procedure Delete_Buffers
(Buffers : in Buffer_Array_t);
-- proc_map : alIsBuffer
function Is_Valid (Buffer : in Buffer_t) return Boolean;
--
-- Frequency
--
-- proc_map : alGetBuffer
procedure Get_Frequency
(Buffer : in Buffer_t;
Frequency : out Types.Frequency_t);
--
-- Size
--
type Sample_Size_t is range 1 .. Types.Size_t'Last;
-- proc_map : alGetBuffer
procedure Get_Size
(Buffer : in Buffer_t;
Size : out Sample_Size_t);
--
-- Bits
--
type Sample_Bits_t is range 8 .. 16;
-- proc_map : alGetBuffer
procedure Get_Bits
(Buffer : in Buffer_t;
Bits : out Sample_Bits_t);
--
-- Channels
--
type Sample_Channels_t is range 1 .. 2;
-- proc_map : alGetBuffer
procedure Get_Channels
(Buffer : in Buffer_t;
Channels : out Sample_Channels_t);
--
-- Data
--
type Sample_16_t is range -32768 .. 32767;
for Sample_16_t'Size use 16;
type Sample_8_t is range 0 .. 255;
for Sample_8_t'Size use 8;
type Sample_Array_16_t is array (Sample_Size_t range <>) of aliased Sample_16_t;
type Sample_Array_8_t is array (Sample_Size_t range <>) of aliased Sample_8_t;
-- proc_map : alBufferData
procedure Set_Data_Mono_8
(Buffer : in Buffer_t;
Data : in Sample_Array_8_t;
Frequency : in Types.Frequency_t);
-- proc_map : alBufferData
procedure Set_Data_Stereo_8
(Buffer : in Buffer_t;
Data : in Sample_Array_8_t;
Frequency : in Types.Frequency_t);
-- proc_map : alBufferData
procedure Set_Data_Mono_16
(Buffer : in Buffer_t;
Data : in Sample_Array_16_t;
Frequency : in Types.Frequency_t);
-- proc_map : alBufferData
procedure Set_Data_Stereo_16
(Buffer : in Buffer_t;
Data : in Sample_Array_16_t;
Frequency : in Types.Frequency_t);
--
--
--
function To_Integer (Buffer : Buffer_t) return Types.Unsigned_Integer_t;
function From_Integer (Buffer : Types.Unsigned_Integer_t) return Buffer_t;
private
type Buffer_t is new Types.Unsigned_Integer_t;
No_Buffer : constant Buffer_t := 0;
end OpenAL.Buffer;
|
reznikmm/matreshka | Ada | 4,882 | ads | ------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- Open Document Toolkit --
-- --
-- Runtime Library Component --
-- --
------------------------------------------------------------------------------
-- --
-- Copyright © 2014, Vadim Godunko <[email protected]> --
-- All rights reserved. --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions --
-- are met: --
-- --
-- * Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- --
-- * Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in the --
-- documentation and/or other materials provided with the distribution. --
-- --
-- * Neither the name of the Vadim Godunko, IE nor the names of its --
-- contributors may be used to endorse or promote products derived from --
-- this software without specific prior written permission. --
-- --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR --
-- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
-- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED --
-- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR --
-- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF --
-- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING --
-- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS --
-- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
-- --
------------------------------------------------------------------------------
-- $Revision$ $Date$
------------------------------------------------------------------------------
with XML.DOM.Visitors;
with ODF.DOM.Text_Illustration_Index_Source_Elements;
package Matreshka.ODF_Text.Illustration_Index_Source_Elements is
type Text_Illustration_Index_Source_Element_Node is
new Matreshka.ODF_Text.Abstract_Text_Element_Node
and ODF.DOM.Text_Illustration_Index_Source_Elements.ODF_Text_Illustration_Index_Source
with null record;
overriding function Create
(Parameters : not null access Matreshka.DOM_Elements.Element_L2_Parameters)
return Text_Illustration_Index_Source_Element_Node;
overriding function Get_Local_Name
(Self : not null access constant Text_Illustration_Index_Source_Element_Node)
return League.Strings.Universal_String;
overriding procedure Enter_Node
(Self : not null access Text_Illustration_Index_Source_Element_Node;
Visitor : in out XML.DOM.Visitors.Abstract_Visitor'Class;
Control : in out XML.DOM.Visitors.Traverse_Control);
overriding procedure Leave_Node
(Self : not null access Text_Illustration_Index_Source_Element_Node;
Visitor : in out XML.DOM.Visitors.Abstract_Visitor'Class;
Control : in out XML.DOM.Visitors.Traverse_Control);
overriding procedure Visit_Node
(Self : not null access Text_Illustration_Index_Source_Element_Node;
Iterator : in out XML.DOM.Visitors.Abstract_Iterator'Class;
Visitor : in out XML.DOM.Visitors.Abstract_Visitor'Class;
Control : in out XML.DOM.Visitors.Traverse_Control);
end Matreshka.ODF_Text.Illustration_Index_Source_Elements;
|
optikos/oasis | Ada | 6,885 | adb | -- Copyright (c) 2019 Maxim Reznik <[email protected]>
--
-- SPDX-License-Identifier: MIT
-- License-Filename: LICENSE
-------------------------------------------------------------
package body Program.Nodes.Return_Object_Specifications is
function Create
(Name : not null Program.Elements.Defining_Identifiers
.Defining_Identifier_Access;
Colon_Token : not null Program.Lexical_Elements
.Lexical_Element_Access;
Aliased_Token : Program.Lexical_Elements.Lexical_Element_Access;
Constant_Token : Program.Lexical_Elements.Lexical_Element_Access;
Object_Subtype : not null Program.Elements.Element_Access;
Assignment_Token : Program.Lexical_Elements.Lexical_Element_Access;
Expression : Program.Elements.Expressions.Expression_Access)
return Return_Object_Specification is
begin
return Result : Return_Object_Specification :=
(Name => Name, Colon_Token => Colon_Token,
Aliased_Token => Aliased_Token, Constant_Token => Constant_Token,
Object_Subtype => Object_Subtype,
Assignment_Token => Assignment_Token, Expression => Expression,
Enclosing_Element => null)
do
Initialize (Result);
end return;
end Create;
function Create
(Name : not null Program.Elements.Defining_Identifiers
.Defining_Identifier_Access;
Object_Subtype : not null Program.Elements.Element_Access;
Expression : Program.Elements.Expressions.Expression_Access;
Is_Part_Of_Implicit : Boolean := False;
Is_Part_Of_Inherited : Boolean := False;
Is_Part_Of_Instance : Boolean := False;
Has_Aliased : Boolean := False;
Has_Constant : Boolean := False)
return Implicit_Return_Object_Specification is
begin
return Result : Implicit_Return_Object_Specification :=
(Name => Name, Object_Subtype => Object_Subtype,
Expression => Expression, Is_Part_Of_Implicit => Is_Part_Of_Implicit,
Is_Part_Of_Inherited => Is_Part_Of_Inherited,
Is_Part_Of_Instance => Is_Part_Of_Instance,
Has_Aliased => Has_Aliased, Has_Constant => Has_Constant,
Enclosing_Element => null)
do
Initialize (Result);
end return;
end Create;
overriding function Name
(Self : Base_Return_Object_Specification)
return not null Program.Elements.Defining_Identifiers
.Defining_Identifier_Access is
begin
return Self.Name;
end Name;
overriding function Object_Subtype
(Self : Base_Return_Object_Specification)
return not null Program.Elements.Element_Access is
begin
return Self.Object_Subtype;
end Object_Subtype;
overriding function Expression
(Self : Base_Return_Object_Specification)
return Program.Elements.Expressions.Expression_Access is
begin
return Self.Expression;
end Expression;
overriding function Colon_Token
(Self : Return_Object_Specification)
return not null Program.Lexical_Elements.Lexical_Element_Access is
begin
return Self.Colon_Token;
end Colon_Token;
overriding function Aliased_Token
(Self : Return_Object_Specification)
return Program.Lexical_Elements.Lexical_Element_Access is
begin
return Self.Aliased_Token;
end Aliased_Token;
overriding function Constant_Token
(Self : Return_Object_Specification)
return Program.Lexical_Elements.Lexical_Element_Access is
begin
return Self.Constant_Token;
end Constant_Token;
overriding function Assignment_Token
(Self : Return_Object_Specification)
return Program.Lexical_Elements.Lexical_Element_Access is
begin
return Self.Assignment_Token;
end Assignment_Token;
overriding function Has_Aliased
(Self : Return_Object_Specification)
return Boolean is
begin
return Self.Aliased_Token.Assigned;
end Has_Aliased;
overriding function Has_Constant
(Self : Return_Object_Specification)
return Boolean is
begin
return Self.Constant_Token.Assigned;
end Has_Constant;
overriding function Is_Part_Of_Implicit
(Self : Implicit_Return_Object_Specification)
return Boolean is
begin
return Self.Is_Part_Of_Implicit;
end Is_Part_Of_Implicit;
overriding function Is_Part_Of_Inherited
(Self : Implicit_Return_Object_Specification)
return Boolean is
begin
return Self.Is_Part_Of_Inherited;
end Is_Part_Of_Inherited;
overriding function Is_Part_Of_Instance
(Self : Implicit_Return_Object_Specification)
return Boolean is
begin
return Self.Is_Part_Of_Instance;
end Is_Part_Of_Instance;
overriding function Has_Aliased
(Self : Implicit_Return_Object_Specification)
return Boolean is
begin
return Self.Has_Aliased;
end Has_Aliased;
overriding function Has_Constant
(Self : Implicit_Return_Object_Specification)
return Boolean is
begin
return Self.Has_Constant;
end Has_Constant;
procedure Initialize
(Self : aliased in out Base_Return_Object_Specification'Class) is
begin
Set_Enclosing_Element (Self.Name, Self'Unchecked_Access);
Set_Enclosing_Element (Self.Object_Subtype, Self'Unchecked_Access);
if Self.Expression.Assigned then
Set_Enclosing_Element (Self.Expression, Self'Unchecked_Access);
end if;
null;
end Initialize;
overriding function Is_Return_Object_Specification_Element
(Self : Base_Return_Object_Specification)
return Boolean is
pragma Unreferenced (Self);
begin
return True;
end Is_Return_Object_Specification_Element;
overriding function Is_Declaration_Element
(Self : Base_Return_Object_Specification)
return Boolean is
pragma Unreferenced (Self);
begin
return True;
end Is_Declaration_Element;
overriding procedure Visit
(Self : not null access Base_Return_Object_Specification;
Visitor : in out Program.Element_Visitors.Element_Visitor'Class) is
begin
Visitor.Return_Object_Specification (Self);
end Visit;
overriding function To_Return_Object_Specification_Text
(Self : aliased in out Return_Object_Specification)
return Program.Elements.Return_Object_Specifications
.Return_Object_Specification_Text_Access is
begin
return Self'Unchecked_Access;
end To_Return_Object_Specification_Text;
overriding function To_Return_Object_Specification_Text
(Self : aliased in out Implicit_Return_Object_Specification)
return Program.Elements.Return_Object_Specifications
.Return_Object_Specification_Text_Access is
pragma Unreferenced (Self);
begin
return null;
end To_Return_Object_Specification_Text;
end Program.Nodes.Return_Object_Specifications;
|
onox/orka | Ada | 5,449 | adb | -- SPDX-License-Identifier: Apache-2.0
--
-- Copyright (c) 2017 onox <[email protected]>
--
-- Licensed under the Apache License, Version 2.0 (the "License");
-- you may not use this file except in compliance with the License.
-- You may obtain a copy of the License at
--
-- http://www.apache.org/licenses/LICENSE-2.0
--
-- Unless required by applicable law or agreed to in writing, software
-- distributed under the License is distributed on an "AS IS" BASIS,
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-- See the License for the specific language governing permissions and
-- limitations under the License.
with Ada.Unchecked_Deallocation;
package body Orka.Jobs is
procedure Free (Pointer : in out Job_Ptr) is
type Job_Access is access all Job'Class;
procedure Free is new Ada.Unchecked_Deallocation
(Object => Job'Class, Name => Job_Access);
begin
Free (Job_Access (Pointer));
end Free;
overriding
procedure Adjust (Object : in out Counter_Controlled) is
begin
Object.Counter := new Zero_Counter;
end Adjust;
overriding
procedure Finalize (Object : in out Counter_Controlled) is
procedure Free is new Ada.Unchecked_Deallocation
(Object => Zero_Counter, Name => Zero_Counter_Access);
begin
if Object.Counter /= null then
Free (Object.Counter);
end if;
-- Idempotence: next call to Finalize has no effect
Object.Counter := null;
end Finalize;
overriding
procedure Execute
(Object : No_Job;
Context : Execution_Context'Class) is
begin
raise Program_Error with "Cannot execute Null_Job";
end Execute;
overriding
function Decrement_Dependencies (Object : in out Abstract_Job) return Boolean is
Zero : Boolean := False;
begin
Object.Dependencies.Counter.Decrement (Zero);
return Zero;
end Decrement_Dependencies;
overriding
function Has_Dependencies (Object : Abstract_Job) return Boolean is
begin
return Object.Dependencies.Counter.Count > 0;
end Has_Dependencies;
overriding
procedure Set_Dependency
(Object : access Abstract_Job; Dependency : Job_Ptr) is
begin
Object.Dependencies.Counter.Increment;
Abstract_Job (Dependency.all).Dependent := Job_Ptr (Object);
end Set_Dependency;
overriding
procedure Set_Dependencies
(Object : access Abstract_Job; Dependencies : Dependency_Array) is
begin
Object.Dependencies.Counter.Add (Dependencies'Length);
for Dependency of Dependencies loop
Abstract_Job (Dependency.all).Dependent := Job_Ptr (Object);
end loop;
end Set_Dependencies;
procedure Chain (Jobs : Dependency_Array) is
begin
for Index in Jobs'First .. Jobs'Last - 1 loop
Jobs (Index + 1).Set_Dependency (Jobs (Index));
end loop;
end Chain;
function Parallelize
(Job : Parallel_Job_Ptr;
Clone : Parallel_Job_Cloner;
Length, Slice : Positive) return Job_Ptr is
begin
return new Parallel_For_Job'
(Abstract_Job with
Length => Length,
Slice => Slice,
Job => Job,
Clone => Clone);
end Parallelize;
overriding
procedure Execute
(Object : Parallel_For_Job;
Context : Execution_Context'Class)
is
Slice_Length : constant Positive := Positive'Min (Object.Length, Object.Slice);
Slices : constant Positive := Object.Length / Slice_Length;
Remaining : constant Natural := Object.Length rem Slice_Length;
Array_Length : constant Positive := Slices + (if Remaining /= 0 then 1 else 0);
Parallel_Jobs : constant Dependency_Array (1 .. Array_Length)
:= Object.Clone (Object.Job, Array_Length);
From, To : Positive := 1;
begin
for Slice_Index in 1 .. Slices loop
To := From + Slice_Length - 1;
Parallel_Job'Class (Parallel_Jobs (Slice_Index).all).Set_Range (From, To);
From := To + 1;
end loop;
if Remaining /= 0 then
To := From + Remaining - 1;
Parallel_Job'Class (Parallel_Jobs (Parallel_Jobs'Last).all).Set_Range (From, To);
end if;
pragma Assert (To = Object.Length);
for Job of Parallel_Jobs loop
Context.Enqueue (Job);
end loop;
-- Object is still a (useless) dependency of Object.Dependent,
-- but the worker that called this Execute procedure will decrement
-- Object.Dependent.Dependencies after this procedure is done
declare
Original_Job : Job_Ptr := Job_Ptr (Object.Job);
begin
-- Copies of Object.Job have been made in Parallel_Jobs
-- and these will be freed when they have been executed by
-- workers. However, Object.Job itself will never be enqueued and
-- executed by a worker (it just exists so we can copy it) so
-- we need to manually free it.
Free (Original_Job);
end;
end Execute;
overriding
procedure Execute
(Object : Abstract_Parallel_Job;
Context : Execution_Context'Class) is
begin
Abstract_Parallel_Job'Class (Object).Execute (Context, Object.From, Object.To);
end Execute;
overriding
procedure Set_Range (Object : in out Abstract_Parallel_Job; From, To : Positive) is
begin
Object.From := From;
Object.To := To;
end Set_Range;
end Orka.Jobs;
|
charlie5/aIDE | Ada | 687 | ads | with Asis,
AdaM.Source;
package AdaM.Assist.Query.find_All.Actuals_for_traversing
is
type Traversal_State is
record
parent_Stack : AdaM.Source.Entities;
ignore_Starter : asis.Element := asis.Nil_Element;
end record;
Initial_Traversal_State : constant Traversal_State := (others => <>);
procedure Pre_Op
(Element : Asis.Element;
Control : in out Asis.Traverse_Control;
State : in out Traversal_State);
procedure Post_Op
(Element : Asis.Element;
Control : in out Asis.Traverse_Control;
State : in out Traversal_State);
end AdaM.Assist.Query.find_All.Actuals_for_traversing;
|
DrenfongWong/tkm-rpc | Ada | 1,417 | ads | with Tkmrpc.Types;
with Tkmrpc.Operations.Ike;
package Tkmrpc.Response.Ike.Dh_Create is
Data_Size : constant := 516;
type Data_Type is record
Pubvalue : Types.Dh_Pubvalue_Type;
end record;
for Data_Type use record
Pubvalue at 0 range 0 .. (516 * 8) - 1;
end record;
for Data_Type'Size use Data_Size * 8;
Padding_Size : constant := Response.Body_Size - Data_Size;
subtype Padding_Range is Natural range 1 .. Padding_Size;
subtype Padding_Type is Types.Byte_Sequence (Padding_Range);
type Response_Type is record
Header : Response.Header_Type;
Data : Data_Type;
Padding : Padding_Type;
end record;
for Response_Type use record
Header at 0 range 0 .. (Response.Header_Size * 8) - 1;
Data at Response.Header_Size range 0 .. (Data_Size * 8) - 1;
Padding at Response.Header_Size + Data_Size range
0 .. (Padding_Size * 8) - 1;
end record;
for Response_Type'Size use Response.Response_Size * 8;
Null_Response : constant Response_Type :=
Response_Type'
(Header =>
Response.Header_Type'(Operation => Operations.Ike.Dh_Create,
Result => Results.Invalid_Operation,
Request_Id => 0),
Data => Data_Type'(Pubvalue => Types.Null_Dh_Pubvalue_Type),
Padding => Padding_Type'(others => 0));
end Tkmrpc.Response.Ike.Dh_Create;
|
stcarrez/mat | Ada | 3,153 | ads | -----------------------------------------------------------------------
-- mat-targets-probes - Definition and Analysis of process start events
-- Copyright (C) 2014, 2015 Stephane Carrez
-- Written by Stephane Carrez ([email protected])
--
-- Licensed under the Apache License, Version 2.0 (the "License");
-- you may not use this file except in compliance with the License.
-- You may obtain a copy of the License at
--
-- http://www.apache.org/licenses/LICENSE-2.0
--
-- Unless required by applicable law or agreed to in writing, software
-- distributed under the License is distributed on an "AS IS" BASIS,
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-- See the License for the specific language governing permissions and
-- limitations under the License.
-----------------------------------------------------------------------
with MAT.Events;
with MAT.Events.Targets;
with MAT.Events.Probes;
package MAT.Targets.Probes is
type Process_Probe_Type is new MAT.Events.Probes.Probe_Type with record
Target : Target_Type_Access;
Manager : MAT.Events.Probes.Probe_Manager_Type_Access;
Events : MAT.Events.Targets.Target_Events_Access;
Frames : MAT.Frames.Targets.Target_Frames_Access;
end record;
type Process_Probe_Type_Access is access all Process_Probe_Type'Class;
-- Create a new process after the begin event is received from the event stream.
procedure Create_Process (Probe : in Process_Probe_Type;
Pid : in MAT.Types.Target_Process_Ref;
Path : in Ada.Strings.Unbounded.Unbounded_String);
-- Extract the probe information from the message.
overriding
procedure Extract (Probe : in Process_Probe_Type;
Params : in MAT.Events.Const_Attribute_Table_Access;
Msg : in out MAT.Readers.Message_Type;
Event : in out MAT.Events.Target_Event_Type);
procedure Execute (Probe : in Process_Probe_Type;
Event : in out MAT.Events.Target_Event_Type);
-- Register the reader to extract and analyze process events.
procedure Register (Into : in out MAT.Events.Probes.Probe_Manager_Type'Class;
Probe : in Process_Probe_Type_Access);
-- Initialize the target object to prepare for reading process events.
procedure Initialize (Target : in out Target_Type;
Manager : in out MAT.Events.Probes.Probe_Manager_Type'Class);
private
procedure Probe_Begin (Probe : in Process_Probe_Type;
Defs : in MAT.Events.Attribute_Table;
Msg : in out MAT.Readers.Message;
Event : in out MAT.Events.Target_Event_Type);
-- Extract the information from the 'library' event.
procedure Probe_Library (Probe : in Process_Probe_Type;
Defs : in MAT.Events.Attribute_Table;
Msg : in out MAT.Readers.Message;
Event : in out MAT.Events.Target_Event_Type);
end MAT.Targets.Probes;
|
reznikmm/matreshka | Ada | 3,779 | ads | ------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- Open Document Toolkit --
-- --
-- Runtime Library Component --
-- --
------------------------------------------------------------------------------
-- --
-- Copyright © 2014, Vadim Godunko <[email protected]> --
-- All rights reserved. --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions --
-- are met: --
-- --
-- * Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- --
-- * Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in the --
-- documentation and/or other materials provided with the distribution. --
-- --
-- * Neither the name of the Vadim Godunko, IE nor the names of its --
-- contributors may be used to endorse or promote products derived from --
-- this software without specific prior written permission. --
-- --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR --
-- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
-- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED --
-- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR --
-- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF --
-- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING --
-- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS --
-- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
-- --
------------------------------------------------------------------------------
-- $Revision$ $Date$
------------------------------------------------------------------------------
with XML.DOM.Attributes;
package ODF.DOM.Style_Writing_Mode_Automatic_Attributes is
pragma Preelaborate;
type ODF_Style_Writing_Mode_Automatic_Attribute is limited interface
and XML.DOM.Attributes.DOM_Attribute;
type ODF_Style_Writing_Mode_Automatic_Attribute_Access is
access all ODF_Style_Writing_Mode_Automatic_Attribute'Class
with Storage_Size => 0;
end ODF.DOM.Style_Writing_Mode_Automatic_Attributes;
|
zhmu/ananas | Ada | 295 | ads | package Renaming9 is
pragma Elaborate_Body;
type Object is tagged null record;
type Pointer is access all Object'Class;
type Derived is new Object with record
I : Integer;
end record;
Ptr : Pointer := new Derived;
Obj : Derived renames Derived (Ptr.all);
end Renaming9;
|
charlie5/aIDE | Ada | 5,902 | adb | -----------------------------------------------------------------------
-- GtkAda - Ada95 binding for the Gimp Toolkit --
-- --
-- Copyright (C) 1998-1999 --
-- Emmanuel Briot, Joel Brobecker and Arnaud Charlet --
-- Copyright (C) 2003-2006 AdaCore --
-- --
-- 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. --
-- --
-----------------------------------------------------------------------
with Gtk.Arguments;
with Gtk.Enums; use Gtk.Enums;
with Ada.Strings.Fixed;
package body Common_Gtk
is
procedure Page_Switch (Notebook : access Gtk_Notebook_Record'Class;
old_page_Id,
new_page_Id : in Gint)
is
begin
if old_page_Id >= 0 then
declare
old_Page : constant Gtk_Widget := Get_Nth_Page (Notebook, old_page_Id);
old_page_Label : constant gtk_Label := gtk_Label (Notebook.Get_Tab_Label (old_Page));
old_label_Text : constant String := old_page_Label.Get_Text;
begin
if old_label_Text'Length >= 3
and then old_label_Text (1 .. 3) = "<b>"
then
old_page_Label.set_Markup (old_label_Text (4 .. old_label_Text'Last - 4));
else
old_page_Label.set_Markup (old_label_Text);
end if;
end;
end if;
if new_page_Id >= 0 then
declare
new_Page : constant Gtk_Widget := Get_Nth_Page (Notebook, new_page_Id);
new_page_Label : constant gtk_Label := gtk_Label (Notebook.Get_Tab_Label (new_Page));
begin
if new_page_Label /= null then
new_page_Label.set_Markup ("<b>" & new_page_Label.Get_Text & "</b>");
end if;
end;
end if;
end Page_Switch;
procedure Page_Switch (Notebook : access Gtk_Notebook_Record'Class;
Params : in Gtk.Arguments.Gtk_Args)
is
old_page_Id : constant Gint := Get_Current_Page (Notebook);
new_page_Id : constant Gint := Gint (Gtk.Arguments.To_Guint (Params, 2));
begin
Page_Switch (Notebook,
old_page_Id, new_page_Id);
end Page_Switch;
procedure enable_bold_Tabs_for (the_Notebook : in gtk_Notebook)
is
begin
Notebook_Cb.Connect (the_Notebook, "switch_page", Page_Switch'Access);
Page_Switch (Notebook => the_Notebook,
old_page_Id => Get_Current_Page (the_Notebook),
new_page_Id => Get_Current_Page (the_Notebook));
end enable_bold_Tabs_for;
-------------------------
-- Build_Option_Menu --
-------------------------
-- procedure Build_Option_Menu
-- (Omenu : out Gtk.Option_Menu.Gtk_Option_Menu;
-- Gr : in out Widget_SList.GSlist;
-- Items : Chars_Ptr_Array;
-- History : Gint;
-- Cb : Widget_Handler.Marshallers.Void_Marshaller.Handler)
--
-- is
-- Menu : Gtk_Menu;
-- Menu_Item : Gtk_Radio_Menu_Item;
--
-- begin
-- Gtk.Option_Menu.Gtk_New (Omenu);
-- Gtk_New (Menu);
--
-- for I in Items'Range loop
-- Gtk_New (Menu_Item, Gr, ICS.Value (Items (I)));
-- Widget_Handler.Object_Connect (Menu_Item, "activate",
-- Widget_Handler.To_Marshaller (Cb),
-- Slot_Object => Menu_Item);
-- Gr := Get_Group (Menu_Item);
-- Append (Menu, Menu_Item);
-- if Gint (I) = History then
-- Set_Active (Menu_Item, True);
-- end if;
-- Show (Menu_Item);
-- end loop;
-- Gtk.Option_Menu.Set_Menu (Omenu, Menu);
-- Gtk.Option_Menu.Set_History (Omenu, History);
-- end Build_Option_Menu;
--------------------
-- Destroy_Window --
--------------------
procedure Destroy_Window (Win : access Gtk.Window.Gtk_Window_Record'Class;
Ptr : in Gtk_Window_Access) is
pragma Warnings (Off, Win);
begin
Ptr.all := null;
end Destroy_Window;
--------------------
-- Destroy_Dialog --
--------------------
procedure Destroy_Dialog (Win : access Gtk.Dialog.Gtk_Dialog_Record'Class;
Ptr : in Gtk_Dialog_Access) is
pragma Warnings (Off, Win);
begin
Ptr.all := null;
end Destroy_Dialog;
--------------
-- Image_Of --
--------------
function Image_Of (I : in Gint) return String is
begin
return Ada.Strings.Fixed.Trim (Gint'Image (I), Ada.Strings.Left);
end Image_Of;
end Common_Gtk;
|
gabrielhesposito/mlh-localhost-adacore | Ada | 2,231 | adb | with Ada.Text_IO; use Ada.Text_IO;
with Stack; use Stack;
procedure Example is
Done : Boolean := False;
--------------------
-- Get_User_Input --
--------------------
function Get_User_Input return Character is
begin
loop
declare
User_Input : String := Get_Line;
begin
if User_Input'Length = 1 then
return User_Input (User_Input'First);
end if;
Put_Line ("Invalid Input, please try again!");
Put ("input > ");
end;
end loop;
end Get_User_Input;
-----------
-- Debug --
-----------
procedure Debug is
begin
Put_Line ("**************************************");
Put_Line ("Size: " & Integer'Image(Stack.Size));
Put_Line ("Max Size: " & Integer'Image(Stack.Max_Size));
if not Stack.Empty then
Put_Line ("Top: " & Stack.Top);
Put ("Stack: [");
for I in Stack.Tab'First .. Stack.Size loop
Put (Stack.Tab(I) & ", ");
end loop;
Put_Line ("]");
else
Put_Line ("Top: Null");
Put_Line ("Stack: []");
end if;
Put_Line ("**************************************");
end Debug;
begin
----------
-- Main --
----------
while not Done = True loop
Put ("input > ");
declare
S : Character := Get_User_Input;
begin
if S = 'q' then
Done := True;
elsif S = 'd' then
Debug;
elsif S = 'p' then
if not Stack.Empty then
Stack.Pop (S);
Put_Line ("Popped: " & S);
else
Put_Line ("Nothing to Pop, Stack is empty!");
end if;
elsif S = 'T' then
if not Stack.Empty then
Stack.pop(S);
Put_Line ("Peek Top: " & S);
end if;
else
if not Stack.Full then
Stack.Push (S);
Put_Line ("Pushed: " & S);
else
Put_Line ("Could not push '" & S & "', Stack is full!");
end if;
end if;
end;
end loop;
Put_Line ("Example ended.");
end Example;
|
reznikmm/matreshka | Ada | 3,674 | 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.Form_Id_Attributes is
pragma Preelaborate;
type ODF_Form_Id_Attribute is limited interface
and XML.DOM.Attributes.DOM_Attribute;
type ODF_Form_Id_Attribute_Access is
access all ODF_Form_Id_Attribute'Class
with Storage_Size => 0;
end ODF.DOM.Form_Id_Attributes;
|
Gabriel-Degret/adalib | Ada | 647 | ads | -- Standard Ada library specification
-- Copyright (c) 2003-2018 Maxim Reznik <[email protected]>
-- Copyright (c) 2004-2016 AXE Consultants
-- Copyright (c) 2004, 2005, 2006 Ada-Europe
-- Copyright (c) 2000 The MITRE Corporation, Inc.
-- Copyright (c) 1992, 1993, 1994, 1995 Intermetrics, Inc.
-- SPDX-License-Identifier: BSD-3-Clause and LicenseRef-AdaReferenceManual
---------------------------------------------------------------------------
with Ada.Containers, Ada.Strings.Hash;
function Ada.Strings.Fixed.Hash (Key : in String)
return Ada.Containers.Hash_Type
renames Ada.Strings.Hash;
pragma Pure (Hash);
|
reznikmm/matreshka | Ada | 24,669 | 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_Reply_Actions is
-------------------
-- Enter_Element --
-------------------
overriding procedure Enter_Element
(Self : not null access constant UML_Reply_Action_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_Reply_Action
(AMF.UML.Reply_Actions.UML_Reply_Action_Access (Self),
Control);
end if;
end Enter_Element;
-------------------
-- Leave_Element --
-------------------
overriding procedure Leave_Element
(Self : not null access constant UML_Reply_Action_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_Reply_Action
(AMF.UML.Reply_Actions.UML_Reply_Action_Access (Self),
Control);
end if;
end Leave_Element;
-------------------
-- Visit_Element --
-------------------
overriding procedure Visit_Element
(Self : not null access constant UML_Reply_Action_Proxy;
Iterator : in out AMF.Visitors.Abstract_Iterator'Class;
Visitor : in out AMF.Visitors.Abstract_Visitor'Class;
Control : in out AMF.Visitors.Traverse_Control) is
begin
if Iterator in AMF.Visitors.UML_Iterators.UML_Iterator'Class then
AMF.Visitors.UML_Iterators.UML_Iterator'Class
(Iterator).Visit_Reply_Action
(Visitor,
AMF.UML.Reply_Actions.UML_Reply_Action_Access (Self),
Control);
end if;
end Visit_Element;
-----------------------
-- Get_Reply_To_Call --
-----------------------
overriding function Get_Reply_To_Call
(Self : not null access constant UML_Reply_Action_Proxy)
return AMF.UML.Triggers.UML_Trigger_Access is
begin
return
AMF.UML.Triggers.UML_Trigger_Access
(AMF.Internals.Helpers.To_Element
(AMF.Internals.Tables.UML_Attributes.Internal_Get_Reply_To_Call
(Self.Element)));
end Get_Reply_To_Call;
-----------------------
-- Set_Reply_To_Call --
-----------------------
overriding procedure Set_Reply_To_Call
(Self : not null access UML_Reply_Action_Proxy;
To : AMF.UML.Triggers.UML_Trigger_Access) is
begin
AMF.Internals.Tables.UML_Attributes.Internal_Set_Reply_To_Call
(Self.Element,
AMF.Internals.Helpers.To_Element
(AMF.Elements.Element_Access (To)));
end Set_Reply_To_Call;
---------------------
-- Get_Reply_Value --
---------------------
overriding function Get_Reply_Value
(Self : not null access constant UML_Reply_Action_Proxy)
return AMF.UML.Input_Pins.Collections.Set_Of_UML_Input_Pin is
begin
return
AMF.UML.Input_Pins.Collections.Wrap
(AMF.Internals.Element_Collections.Wrap
(AMF.Internals.Tables.UML_Attributes.Internal_Get_Reply_Value
(Self.Element)));
end Get_Reply_Value;
----------------------------
-- Get_Return_Information --
----------------------------
overriding function Get_Return_Information
(Self : not null access constant UML_Reply_Action_Proxy)
return AMF.UML.Input_Pins.UML_Input_Pin_Access is
begin
return
AMF.UML.Input_Pins.UML_Input_Pin_Access
(AMF.Internals.Helpers.To_Element
(AMF.Internals.Tables.UML_Attributes.Internal_Get_Return_Information
(Self.Element)));
end Get_Return_Information;
----------------------------
-- Set_Return_Information --
----------------------------
overriding procedure Set_Return_Information
(Self : not null access UML_Reply_Action_Proxy;
To : AMF.UML.Input_Pins.UML_Input_Pin_Access) is
begin
AMF.Internals.Tables.UML_Attributes.Internal_Set_Return_Information
(Self.Element,
AMF.Internals.Helpers.To_Element
(AMF.Elements.Element_Access (To)));
end Set_Return_Information;
-----------------
-- Get_Context --
-----------------
overriding function Get_Context
(Self : not null access constant UML_Reply_Action_Proxy)
return AMF.UML.Classifiers.UML_Classifier_Access is
begin
return
AMF.UML.Classifiers.UML_Classifier_Access
(AMF.Internals.Helpers.To_Element
(AMF.Internals.Tables.UML_Attributes.Internal_Get_Context
(Self.Element)));
end Get_Context;
---------------
-- Get_Input --
---------------
overriding function Get_Input
(Self : not null access constant UML_Reply_Action_Proxy)
return AMF.UML.Input_Pins.Collections.Ordered_Set_Of_UML_Input_Pin is
begin
return
AMF.UML.Input_Pins.Collections.Wrap
(AMF.Internals.Element_Collections.Wrap
(AMF.Internals.Tables.UML_Attributes.Internal_Get_Input
(Self.Element)));
end Get_Input;
------------------------------
-- Get_Is_Locally_Reentrant --
------------------------------
overriding function Get_Is_Locally_Reentrant
(Self : not null access constant UML_Reply_Action_Proxy)
return Boolean is
begin
return
AMF.Internals.Tables.UML_Attributes.Internal_Get_Is_Locally_Reentrant
(Self.Element);
end Get_Is_Locally_Reentrant;
------------------------------
-- Set_Is_Locally_Reentrant --
------------------------------
overriding procedure Set_Is_Locally_Reentrant
(Self : not null access UML_Reply_Action_Proxy;
To : Boolean) is
begin
AMF.Internals.Tables.UML_Attributes.Internal_Set_Is_Locally_Reentrant
(Self.Element, To);
end Set_Is_Locally_Reentrant;
-----------------------------
-- Get_Local_Postcondition --
-----------------------------
overriding function Get_Local_Postcondition
(Self : not null access constant UML_Reply_Action_Proxy)
return AMF.UML.Constraints.Collections.Set_Of_UML_Constraint is
begin
return
AMF.UML.Constraints.Collections.Wrap
(AMF.Internals.Element_Collections.Wrap
(AMF.Internals.Tables.UML_Attributes.Internal_Get_Local_Postcondition
(Self.Element)));
end Get_Local_Postcondition;
----------------------------
-- Get_Local_Precondition --
----------------------------
overriding function Get_Local_Precondition
(Self : not null access constant UML_Reply_Action_Proxy)
return AMF.UML.Constraints.Collections.Set_Of_UML_Constraint is
begin
return
AMF.UML.Constraints.Collections.Wrap
(AMF.Internals.Element_Collections.Wrap
(AMF.Internals.Tables.UML_Attributes.Internal_Get_Local_Precondition
(Self.Element)));
end Get_Local_Precondition;
----------------
-- Get_Output --
----------------
overriding function Get_Output
(Self : not null access constant UML_Reply_Action_Proxy)
return AMF.UML.Output_Pins.Collections.Ordered_Set_Of_UML_Output_Pin is
begin
return
AMF.UML.Output_Pins.Collections.Wrap
(AMF.Internals.Element_Collections.Wrap
(AMF.Internals.Tables.UML_Attributes.Internal_Get_Output
(Self.Element)));
end Get_Output;
-----------------
-- Get_Handler --
-----------------
overriding function Get_Handler
(Self : not null access constant UML_Reply_Action_Proxy)
return AMF.UML.Exception_Handlers.Collections.Set_Of_UML_Exception_Handler is
begin
return
AMF.UML.Exception_Handlers.Collections.Wrap
(AMF.Internals.Element_Collections.Wrap
(AMF.Internals.Tables.UML_Attributes.Internal_Get_Handler
(Self.Element)));
end Get_Handler;
------------------
-- Get_Activity --
------------------
overriding function Get_Activity
(Self : not null access constant UML_Reply_Action_Proxy)
return AMF.UML.Activities.UML_Activity_Access is
begin
return
AMF.UML.Activities.UML_Activity_Access
(AMF.Internals.Helpers.To_Element
(AMF.Internals.Tables.UML_Attributes.Internal_Get_Activity
(Self.Element)));
end Get_Activity;
------------------
-- Set_Activity --
------------------
overriding procedure Set_Activity
(Self : not null access UML_Reply_Action_Proxy;
To : AMF.UML.Activities.UML_Activity_Access) is
begin
AMF.Internals.Tables.UML_Attributes.Internal_Set_Activity
(Self.Element,
AMF.Internals.Helpers.To_Element
(AMF.Elements.Element_Access (To)));
end Set_Activity;
------------------
-- Get_In_Group --
------------------
overriding function Get_In_Group
(Self : not null access constant UML_Reply_Action_Proxy)
return AMF.UML.Activity_Groups.Collections.Set_Of_UML_Activity_Group is
begin
return
AMF.UML.Activity_Groups.Collections.Wrap
(AMF.Internals.Element_Collections.Wrap
(AMF.Internals.Tables.UML_Attributes.Internal_Get_In_Group
(Self.Element)));
end Get_In_Group;
---------------------------------
-- Get_In_Interruptible_Region --
---------------------------------
overriding function Get_In_Interruptible_Region
(Self : not null access constant UML_Reply_Action_Proxy)
return AMF.UML.Interruptible_Activity_Regions.Collections.Set_Of_UML_Interruptible_Activity_Region is
begin
return
AMF.UML.Interruptible_Activity_Regions.Collections.Wrap
(AMF.Internals.Element_Collections.Wrap
(AMF.Internals.Tables.UML_Attributes.Internal_Get_In_Interruptible_Region
(Self.Element)));
end Get_In_Interruptible_Region;
----------------------
-- Get_In_Partition --
----------------------
overriding function Get_In_Partition
(Self : not null access constant UML_Reply_Action_Proxy)
return AMF.UML.Activity_Partitions.Collections.Set_Of_UML_Activity_Partition is
begin
return
AMF.UML.Activity_Partitions.Collections.Wrap
(AMF.Internals.Element_Collections.Wrap
(AMF.Internals.Tables.UML_Attributes.Internal_Get_In_Partition
(Self.Element)));
end Get_In_Partition;
----------------------------
-- Get_In_Structured_Node --
----------------------------
overriding function Get_In_Structured_Node
(Self : not null access constant UML_Reply_Action_Proxy)
return AMF.UML.Structured_Activity_Nodes.UML_Structured_Activity_Node_Access is
begin
return
AMF.UML.Structured_Activity_Nodes.UML_Structured_Activity_Node_Access
(AMF.Internals.Helpers.To_Element
(AMF.Internals.Tables.UML_Attributes.Internal_Get_In_Structured_Node
(Self.Element)));
end Get_In_Structured_Node;
----------------------------
-- Set_In_Structured_Node --
----------------------------
overriding procedure Set_In_Structured_Node
(Self : not null access UML_Reply_Action_Proxy;
To : AMF.UML.Structured_Activity_Nodes.UML_Structured_Activity_Node_Access) is
begin
AMF.Internals.Tables.UML_Attributes.Internal_Set_In_Structured_Node
(Self.Element,
AMF.Internals.Helpers.To_Element
(AMF.Elements.Element_Access (To)));
end Set_In_Structured_Node;
------------------
-- Get_Incoming --
------------------
overriding function Get_Incoming
(Self : not null access constant UML_Reply_Action_Proxy)
return AMF.UML.Activity_Edges.Collections.Set_Of_UML_Activity_Edge is
begin
return
AMF.UML.Activity_Edges.Collections.Wrap
(AMF.Internals.Element_Collections.Wrap
(AMF.Internals.Tables.UML_Attributes.Internal_Get_Incoming
(Self.Element)));
end Get_Incoming;
------------------
-- Get_Outgoing --
------------------
overriding function Get_Outgoing
(Self : not null access constant UML_Reply_Action_Proxy)
return AMF.UML.Activity_Edges.Collections.Set_Of_UML_Activity_Edge is
begin
return
AMF.UML.Activity_Edges.Collections.Wrap
(AMF.Internals.Element_Collections.Wrap
(AMF.Internals.Tables.UML_Attributes.Internal_Get_Outgoing
(Self.Element)));
end Get_Outgoing;
------------------------
-- Get_Redefined_Node --
------------------------
overriding function Get_Redefined_Node
(Self : not null access constant UML_Reply_Action_Proxy)
return AMF.UML.Activity_Nodes.Collections.Set_Of_UML_Activity_Node is
begin
return
AMF.UML.Activity_Nodes.Collections.Wrap
(AMF.Internals.Element_Collections.Wrap
(AMF.Internals.Tables.UML_Attributes.Internal_Get_Redefined_Node
(Self.Element)));
end Get_Redefined_Node;
-----------------
-- Get_Is_Leaf --
-----------------
overriding function Get_Is_Leaf
(Self : not null access constant UML_Reply_Action_Proxy)
return Boolean is
begin
return
AMF.Internals.Tables.UML_Attributes.Internal_Get_Is_Leaf
(Self.Element);
end Get_Is_Leaf;
-----------------
-- Set_Is_Leaf --
-----------------
overriding procedure Set_Is_Leaf
(Self : not null access UML_Reply_Action_Proxy;
To : Boolean) is
begin
AMF.Internals.Tables.UML_Attributes.Internal_Set_Is_Leaf
(Self.Element, To);
end Set_Is_Leaf;
---------------------------
-- Get_Redefined_Element --
---------------------------
overriding function Get_Redefined_Element
(Self : not null access constant UML_Reply_Action_Proxy)
return AMF.UML.Redefinable_Elements.Collections.Set_Of_UML_Redefinable_Element is
begin
return
AMF.UML.Redefinable_Elements.Collections.Wrap
(AMF.Internals.Element_Collections.Wrap
(AMF.Internals.Tables.UML_Attributes.Internal_Get_Redefined_Element
(Self.Element)));
end Get_Redefined_Element;
------------------------------
-- Get_Redefinition_Context --
------------------------------
overriding function Get_Redefinition_Context
(Self : not null access constant UML_Reply_Action_Proxy)
return AMF.UML.Classifiers.Collections.Set_Of_UML_Classifier is
begin
return
AMF.UML.Classifiers.Collections.Wrap
(AMF.Internals.Element_Collections.Wrap
(AMF.Internals.Tables.UML_Attributes.Internal_Get_Redefinition_Context
(Self.Element)));
end Get_Redefinition_Context;
---------------------------
-- Get_Client_Dependency --
---------------------------
overriding function Get_Client_Dependency
(Self : not null access constant UML_Reply_Action_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_Reply_Action_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_Reply_Action_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_Reply_Action_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_Reply_Action_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;
-------------
-- Context --
-------------
overriding function Context
(Self : not null access constant UML_Reply_Action_Proxy)
return AMF.UML.Classifiers.UML_Classifier_Access is
begin
-- Generated stub: replace with real body!
pragma Compile_Time_Warning (Standard.True, "Context unimplemented");
raise Program_Error with "Unimplemented procedure UML_Reply_Action_Proxy.Context";
return Context (Self);
end Context;
------------------------
-- Is_Consistent_With --
------------------------
overriding function Is_Consistent_With
(Self : not null access constant UML_Reply_Action_Proxy;
Redefinee : AMF.UML.Redefinable_Elements.UML_Redefinable_Element_Access)
return Boolean is
begin
-- Generated stub: replace with real body!
pragma Compile_Time_Warning (Standard.True, "Is_Consistent_With unimplemented");
raise Program_Error with "Unimplemented procedure UML_Reply_Action_Proxy.Is_Consistent_With";
return Is_Consistent_With (Self, Redefinee);
end Is_Consistent_With;
-----------------------------------
-- Is_Redefinition_Context_Valid --
-----------------------------------
overriding function Is_Redefinition_Context_Valid
(Self : not null access constant UML_Reply_Action_Proxy;
Redefined : AMF.UML.Redefinable_Elements.UML_Redefinable_Element_Access)
return Boolean is
begin
-- Generated stub: replace with real body!
pragma Compile_Time_Warning (Standard.True, "Is_Redefinition_Context_Valid unimplemented");
raise Program_Error with "Unimplemented procedure UML_Reply_Action_Proxy.Is_Redefinition_Context_Valid";
return Is_Redefinition_Context_Valid (Self, Redefined);
end Is_Redefinition_Context_Valid;
-------------------------
-- All_Owning_Packages --
-------------------------
overriding function All_Owning_Packages
(Self : not null access constant UML_Reply_Action_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_Reply_Action_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_Reply_Action_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_Reply_Action_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_Reply_Action_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_Reply_Action_Proxy.Namespace";
return Namespace (Self);
end Namespace;
end AMF.Internals.UML_Reply_Actions;
|
shintakezou/langkit | Ada | 6,151 | adb | --
-- Copyright (C) 2014-2022, AdaCore
-- SPDX-License-Identifier: Apache-2.0
--
with Ada.Unchecked_Conversion;
with System;
package body Langkit_Support.Bump_Ptr_Vectors is
function Alloc_Chunk (P : Bump_Ptr_Pool; S : Natural) return Chunk_Access;
-----------------
-- Alloc_Chunk --
-----------------
function Alloc_Chunk (P : Bump_Ptr_Pool; S : Natural) return Chunk_Access
is
subtype C is Chunk (S);
function To_Pointer is
new Ada.Unchecked_Conversion (System.Address, Chunk_Access);
Ret_Memory : constant System.Address :=
Allocate (P, C'Max_Size_In_Storage_Elements);
-- Allocate a chunk of memory for the result
-- discriminated record...
Ret_Disc : Natural;
for Ret_Disc'Address use Ret_Memory;
-- And initialize its discriminant properly as the
-- runtime would do with regular allocation.
begin
Ret_Disc := S;
return To_Pointer (Ret_Memory);
end Alloc_Chunk;
function Create (P : Bump_Ptr_Pool) return Vector
is
(Vector'(Pool => P, others => <>));
------------
-- Append --
------------
procedure Append (Self : in out Vector; Element : Element_Type)
is
procedure Init_Chunk (C : in out Chunk) with Inline;
----------------
-- Init_Chunk --
----------------
procedure Init_Chunk (C : in out Chunk) is
begin
C.Next_Chunk := null;
C.Length := 0;
end Init_Chunk;
Old_Chunk : Chunk_Access;
begin
-- First append, create a chunk and initialize it
if Self.Length = 0 then
Self.First_Chunk := Alloc_Chunk (Self.Pool, 2);
Init_Chunk (Self.First_Chunk.all);
Self.Current_Chunk := Self.First_Chunk;
end if;
-- We filled the current chunk completely, create a new chunk and
-- initialize it, chain it with the previous chunk.
if Self.Current_Chunk.Length = Self.Current_Chunk.Capacity then
Old_Chunk := Self.Current_Chunk;
Self.Current_Chunk := Alloc_Chunk (Self.Pool, Old_Chunk.Capacity * 2);
Init_Chunk (Self.Current_Chunk.all);
Old_Chunk.Next_Chunk := Self.Current_Chunk;
end if;
-- At this stage we know the current chunk can contain element, insert
-- it.
Self.Current_Chunk.Length := Self.Current_Chunk.Length + 1;
Self.Length := Self.Length + 1;
Self.Current_Chunk.Elements (Self.Current_Chunk.Length) := Element;
end Append;
---------
-- Get --
---------
function Get (Self : Vector; C : Cursor) return Element_Type is
pragma Unreferenced (Self);
begin
return C.Chunk.Elements (C.Index_In_Chunk);
end Get;
------------------
-- Get_At_Index --
------------------
function Get_At_Index (Self : Vector; I : Index_Type) return Element_Type
is
function Get_In_Chunk
(Chunk : Chunk_Access;
Chunk_Start_Index : Index_Type)
return Element_Type
is (Chunk.Elements (I - Chunk_Start_Index + 1));
-- Assuming that 1) Chunk's first element has index Chunk_Start_Index
-- and that 2) the I index is inside this chunk, return the element
-- corresponding to I.
begin
-- As the size of chunks double for each appened chunk, the element we
-- are looking for should be in the current chunk more than half of the
-- times (assuming equiprobable accesses). So let's just check if it's
-- the case.
declare
Current_Chunk_Start_Index : constant Index_Type :=
Index_Type'First + Self.Length - Self.Current_Chunk.Length;
begin
if I >= Current_Chunk_Start_Index then
return Get_In_Chunk
(Self.Current_Chunk, Current_Chunk_Start_Index);
end if;
end;
-- We had no luck: go through all chunks to find the one that contains
-- the element at index I.
declare
Chunk_Start_Index : Index_Type := Index_Type'First;
Current_Chunk : Chunk_Access := Self.First_Chunk;
begin
while Current_Chunk /= null
and then I >= Chunk_Start_Index + Current_Chunk.Capacity
loop
Chunk_Start_Index := Chunk_Start_Index + Current_Chunk.Capacity;
Current_Chunk := Current_Chunk.Next_Chunk;
end loop;
return Get_In_Chunk (Current_Chunk, Chunk_Start_Index);
end;
end Get_At_Index;
----------------
-- Get_Access --
----------------
function Get_Access (Self : Vector; C : Cursor) return Element_Access is
pragma Unreferenced (Self);
begin
return C.Chunk.Elements (C.Index_In_Chunk)'Unrestricted_Access;
end Get_Access;
------------
-- Length --
------------
function Length (Self : Vector) return Natural is
begin
return Self.Length;
end Length;
-----------
-- First --
-----------
function First (Self : Vector) return Cursor is
begin
return Cursor'(Chunk => Self.First_Chunk, Index_In_Chunk => 1);
end First;
----------
-- Next --
----------
function Next (Self : Vector; C : Cursor) return Cursor is
pragma Unreferenced (Self);
begin
if C.Index_In_Chunk = C.Chunk.Capacity then
return Cursor'(C.Chunk.Next_Chunk, 1);
else
return Cursor'(C.Chunk, C.Index_In_Chunk + 1);
end if;
end Next;
-----------------
-- Has_Element --
-----------------
function Has_Element (Self : Vector; C : Cursor) return Boolean is
pragma Unreferenced (Self);
begin
return C.Chunk /= null and then C.Index_In_Chunk <= C.Chunk.Length;
end Has_Element;
-----------------
-- First_Index --
-----------------
function First_Index (Self : Vector) return Index_Type is
pragma Unreferenced (Self);
begin
return Index_Type'First;
end First_Index;
----------------
-- Last_Index --
----------------
function Last_Index (Self : Vector) return Integer is
begin
return Index_Type'First + Length (Self) - 1;
end Last_Index;
end Langkit_Support.Bump_Ptr_Vectors;
|
jrcarter/Ada_GUI | Ada | 5,248 | ads | -- Ada_GUI implementation based on Gnoga. Adapted 2021
-- --
-- GNOGA - The GNU Omnificent GUI for Ada --
-- --
-- G N O G A . C L I E N T . S T O R A G E --
-- --
-- S p e c --
-- --
-- --
-- Copyright (C) 2014 David Botton --
-- --
-- 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. --
-- --
-- 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/>. --
-- --
-- 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. --
-- --
-- For more information please go to http://www.gnoga.com --
------------------------------------------------------------------------------
with Ada_GUI.Gnoga.Gui;
package Ada_GUI.Gnoga.Client_Storage is
-------------------------------------------------------------------------
-- Storage_Type
-------------------------------------------------------------------------
-- Base class for client side storage of data.
-- In order to ease access to client side data, the Storage_Type can be
-- accessed using any object instead of just through the parent window.
-- One local and one session storage is available across an entire
-- location defined as scheme://domain:port.
type Storage_Type is tagged private;
type Storage_Access is access all Storage_Type;
type Pointer_To_Storage_Class is access all Storage_Type'Class;
function Length (Storage : Storage_Type) return Natural;
-- Number of entries in Storage
function Key (Storage : Storage_Type; Value : Positive) return String;
-- Return the Key at Value
procedure Set (Storage : in out Storage_Type; Name, Value : String);
-- Set Name=Value in Storage
function Get (Storage : Storage_Type; Name : String) return String;
-- Get Value for Name in Storage. If Name does not exist returns "null"
function Script_Accessor (Storage : Storage_Type) return String;
type Local_Storage_Type is new Storage_Type with private;
type Local_Storage_Access is access all Local_Storage_Type;
type Pointer_To_Local_Storage_Class is access all Local_Storage_Type'Class;
function Local_Storage (Object : Gnoga.Gui.Base_Type'Class)
return Local_Storage_Type;
overriding
function Script_Accessor (Storage : Local_Storage_Type) return String;
type Session_Storage_Type is new Storage_Type with private;
type Session_Storage_Access is access all Session_Storage_Type;
type Pointer_To_Session_Storage_Class is
access all Session_Storage_Type'Class;
function Session_Storage (Object : Gnoga.Gui.Base_Type'Class)
return Session_Storage_Type;
overriding
function Script_Accessor (Storage : Session_Storage_Type) return String;
private
type Storage_Type is tagged
record
Connection_ID : Gnoga.Connection_ID :=
Gnoga.No_Connection;
end record;
type Local_Storage_Type is new Storage_Type with null record;
type Session_Storage_Type is new Storage_Type with null record;
end Ada_GUI.Gnoga.Client_Storage;
|
AdaCore/libadalang | Ada | 121 | adb | separate (Pack.Inner)
function Fun return Integer is
procedure Proc is separate;
begin
Proc;
return 0;
end Fun;
|
ohenley/black | Ada | 2,339 | ads | -------------------------------------------------------------------------------
-- --
-- Copyright (C) 2012-, AdaHeads K/S --
-- --
-- This is free software; you can redistribute it and/or modify it --
-- under terms of the GNU General Public License as published by the --
-- Free 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/>. --
-- --
-------------------------------------------------------------------------------
-- This file originates from AWS.URL
with Ada.Strings.Maps;
package URL_Utilities is
--
-- URL Encoding and Decoding
--
Default_Encoding_Set : constant Ada.Strings.Maps.Character_Set;
function Encode
(Str : String;
Encoding_Set : Ada.Strings.Maps.Character_Set := Default_Encoding_Set)
return String;
-- Encode Str into a URL-safe form. Many characters are forbiden into an
-- URL and needs to be encoded. A character is encoded by %XY where XY is
-- the character's ASCII hexadecimal code. For example a space is encoded
-- as %20.
function Decode (Str : String) return String;
-- This is the opposite of Encode above
private
use type Ada.Strings.Maps.Character_Set;
Default_Encoding_Set : constant Ada.Strings.Maps.Character_Set
:= Ada.Strings.Maps.To_Set
(Span => (Low => Character'Val (128),
High => Character'Val (Character'Pos (Character'Last))))
or
Ada.Strings.Maps.To_Set (";/?:@&=+$,<>#%""{}|\^[]`' ");
end URL_Utilities;
|
stcarrez/ada-wiki | Ada | 1,069 | ads | -----------------------------------------------------------------------
-- wiki-parsers-textile -- Textile parser operations
-- Copyright (C) 2022 Stephane Carrez
-- Written by Stephane Carrez ([email protected])
--
-- Licensed under the Apache License, Version 2.0 (the "License");
-- you may not use this file except in compliance with the License.
-- You may obtain a copy of the License at
--
-- http://www.apache.org/licenses/LICENSE-2.0
--
-- Unless required by applicable law or agreed to in writing, software
-- distributed under the License is distributed on an "AS IS" BASIS,
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-- See the License for the specific language governing permissions and
-- limitations under the License.
-----------------------------------------------------------------------
private package Wiki.Parsers.Textile with Preelaborate is
procedure Parse_Line (Parser : in out Parser_Type;
Text : in Wiki.Buffers.Buffer_Access);
end Wiki.Parsers.Textile;
|
reznikmm/matreshka | Ada | 4,829 | 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_Data_Pilot_Subtotal_Elements;
package Matreshka.ODF_Table.Data_Pilot_Subtotal_Elements is
type Table_Data_Pilot_Subtotal_Element_Node is
new Matreshka.ODF_Table.Abstract_Table_Element_Node
and ODF.DOM.Table_Data_Pilot_Subtotal_Elements.ODF_Table_Data_Pilot_Subtotal
with null record;
overriding function Create
(Parameters : not null access Matreshka.DOM_Elements.Element_L2_Parameters)
return Table_Data_Pilot_Subtotal_Element_Node;
overriding function Get_Local_Name
(Self : not null access constant Table_Data_Pilot_Subtotal_Element_Node)
return League.Strings.Universal_String;
overriding procedure Enter_Node
(Self : not null access Table_Data_Pilot_Subtotal_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_Data_Pilot_Subtotal_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_Data_Pilot_Subtotal_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.Data_Pilot_Subtotal_Elements;
|
optikos/oasis | Ada | 7,515 | adb | -- Copyright (c) 2019 Maxim Reznik <[email protected]>
--
-- SPDX-License-Identifier: MIT
-- License-Filename: LICENSE
-------------------------------------------------------------
package body Program.Nodes.Formal_Procedure_Access_Types is
function Create
(Not_Token : Program.Lexical_Elements.Lexical_Element_Access;
Null_Token : Program.Lexical_Elements.Lexical_Element_Access;
Access_Token : not null Program.Lexical_Elements
.Lexical_Element_Access;
Protected_Token : Program.Lexical_Elements.Lexical_Element_Access;
Procedure_Token : not null Program.Lexical_Elements
.Lexical_Element_Access;
Left_Bracket_Token : Program.Lexical_Elements.Lexical_Element_Access;
Parameters : Program.Elements.Parameter_Specifications
.Parameter_Specification_Vector_Access;
Right_Bracket_Token : Program.Lexical_Elements.Lexical_Element_Access)
return Formal_Procedure_Access_Type is
begin
return Result : Formal_Procedure_Access_Type :=
(Not_Token => Not_Token, Null_Token => Null_Token,
Access_Token => Access_Token, Protected_Token => Protected_Token,
Procedure_Token => Procedure_Token,
Left_Bracket_Token => Left_Bracket_Token, Parameters => Parameters,
Right_Bracket_Token => Right_Bracket_Token, Enclosing_Element => null)
do
Initialize (Result);
end return;
end Create;
function Create
(Parameters : Program.Elements.Parameter_Specifications
.Parameter_Specification_Vector_Access;
Is_Part_Of_Implicit : Boolean := False;
Is_Part_Of_Inherited : Boolean := False;
Is_Part_Of_Instance : Boolean := False;
Has_Not_Null : Boolean := False;
Has_Protected : Boolean := False)
return Implicit_Formal_Procedure_Access_Type is
begin
return Result : Implicit_Formal_Procedure_Access_Type :=
(Parameters => Parameters, Is_Part_Of_Implicit => Is_Part_Of_Implicit,
Is_Part_Of_Inherited => Is_Part_Of_Inherited,
Is_Part_Of_Instance => Is_Part_Of_Instance,
Has_Not_Null => Has_Not_Null, Has_Protected => Has_Protected,
Enclosing_Element => null)
do
Initialize (Result);
end return;
end Create;
overriding function Parameters
(Self : Base_Formal_Procedure_Access_Type)
return Program.Elements.Parameter_Specifications
.Parameter_Specification_Vector_Access is
begin
return Self.Parameters;
end Parameters;
overriding function Not_Token
(Self : Formal_Procedure_Access_Type)
return Program.Lexical_Elements.Lexical_Element_Access is
begin
return Self.Not_Token;
end Not_Token;
overriding function Null_Token
(Self : Formal_Procedure_Access_Type)
return Program.Lexical_Elements.Lexical_Element_Access is
begin
return Self.Null_Token;
end Null_Token;
overriding function Access_Token
(Self : Formal_Procedure_Access_Type)
return not null Program.Lexical_Elements.Lexical_Element_Access is
begin
return Self.Access_Token;
end Access_Token;
overriding function Protected_Token
(Self : Formal_Procedure_Access_Type)
return Program.Lexical_Elements.Lexical_Element_Access is
begin
return Self.Protected_Token;
end Protected_Token;
overriding function Procedure_Token
(Self : Formal_Procedure_Access_Type)
return not null Program.Lexical_Elements.Lexical_Element_Access is
begin
return Self.Procedure_Token;
end Procedure_Token;
overriding function Left_Bracket_Token
(Self : Formal_Procedure_Access_Type)
return Program.Lexical_Elements.Lexical_Element_Access is
begin
return Self.Left_Bracket_Token;
end Left_Bracket_Token;
overriding function Right_Bracket_Token
(Self : Formal_Procedure_Access_Type)
return Program.Lexical_Elements.Lexical_Element_Access is
begin
return Self.Right_Bracket_Token;
end Right_Bracket_Token;
overriding function Has_Not_Null
(Self : Formal_Procedure_Access_Type)
return Boolean is
begin
return Self.Null_Token.Assigned;
end Has_Not_Null;
overriding function Has_Protected
(Self : Formal_Procedure_Access_Type)
return Boolean is
begin
return Self.Protected_Token.Assigned;
end Has_Protected;
overriding function Is_Part_Of_Implicit
(Self : Implicit_Formal_Procedure_Access_Type)
return Boolean is
begin
return Self.Is_Part_Of_Implicit;
end Is_Part_Of_Implicit;
overriding function Is_Part_Of_Inherited
(Self : Implicit_Formal_Procedure_Access_Type)
return Boolean is
begin
return Self.Is_Part_Of_Inherited;
end Is_Part_Of_Inherited;
overriding function Is_Part_Of_Instance
(Self : Implicit_Formal_Procedure_Access_Type)
return Boolean is
begin
return Self.Is_Part_Of_Instance;
end Is_Part_Of_Instance;
overriding function Has_Not_Null
(Self : Implicit_Formal_Procedure_Access_Type)
return Boolean is
begin
return Self.Has_Not_Null;
end Has_Not_Null;
overriding function Has_Protected
(Self : Implicit_Formal_Procedure_Access_Type)
return Boolean is
begin
return Self.Has_Protected;
end Has_Protected;
procedure Initialize
(Self : aliased in out Base_Formal_Procedure_Access_Type'Class) is
begin
for Item in Self.Parameters.Each_Element loop
Set_Enclosing_Element (Item.Element, Self'Unchecked_Access);
end loop;
null;
end Initialize;
overriding function Is_Formal_Procedure_Access_Type_Element
(Self : Base_Formal_Procedure_Access_Type)
return Boolean is
pragma Unreferenced (Self);
begin
return True;
end Is_Formal_Procedure_Access_Type_Element;
overriding function Is_Formal_Access_Type_Element
(Self : Base_Formal_Procedure_Access_Type)
return Boolean is
pragma Unreferenced (Self);
begin
return True;
end Is_Formal_Access_Type_Element;
overriding function Is_Formal_Type_Definition_Element
(Self : Base_Formal_Procedure_Access_Type)
return Boolean is
pragma Unreferenced (Self);
begin
return True;
end Is_Formal_Type_Definition_Element;
overriding function Is_Definition_Element
(Self : Base_Formal_Procedure_Access_Type)
return Boolean is
pragma Unreferenced (Self);
begin
return True;
end Is_Definition_Element;
overriding procedure Visit
(Self : not null access Base_Formal_Procedure_Access_Type;
Visitor : in out Program.Element_Visitors.Element_Visitor'Class) is
begin
Visitor.Formal_Procedure_Access_Type (Self);
end Visit;
overriding function To_Formal_Procedure_Access_Type_Text
(Self : aliased in out Formal_Procedure_Access_Type)
return Program.Elements.Formal_Procedure_Access_Types
.Formal_Procedure_Access_Type_Text_Access is
begin
return Self'Unchecked_Access;
end To_Formal_Procedure_Access_Type_Text;
overriding function To_Formal_Procedure_Access_Type_Text
(Self : aliased in out Implicit_Formal_Procedure_Access_Type)
return Program.Elements.Formal_Procedure_Access_Types
.Formal_Procedure_Access_Type_Text_Access is
pragma Unreferenced (Self);
begin
return null;
end To_Formal_Procedure_Access_Type_Text;
end Program.Nodes.Formal_Procedure_Access_Types;
|
reznikmm/matreshka | Ada | 4,036 | ads | ------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- Ada Modeling Framework --
-- --
-- Runtime Library Component --
-- --
------------------------------------------------------------------------------
-- --
-- Copyright © 2011-2012, Vadim Godunko <[email protected]> --
-- All rights reserved. --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions --
-- are met: --
-- --
-- * Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- --
-- * Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in the --
-- documentation and/or other materials provided with the distribution. --
-- --
-- * Neither the name of the Vadim Godunko, IE nor the names of its --
-- contributors may be used to endorse or promote products derived from --
-- this software without specific prior written permission. --
-- --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR --
-- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
-- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED --
-- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR --
-- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF --
-- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING --
-- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS --
-- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
-- --
------------------------------------------------------------------------------
-- $Revision$ $Date$
------------------------------------------------------------------------------
-- This file is generated, don't edit it.
------------------------------------------------------------------------------
-- A clear variable action is a variable action that removes all values of a
-- variable.
------------------------------------------------------------------------------
with AMF.UML.Variable_Actions;
package AMF.UML.Clear_Variable_Actions is
pragma Preelaborate;
type UML_Clear_Variable_Action is limited interface
and AMF.UML.Variable_Actions.UML_Variable_Action;
type UML_Clear_Variable_Action_Access is
access all UML_Clear_Variable_Action'Class;
for UML_Clear_Variable_Action_Access'Storage_Size use 0;
end AMF.UML.Clear_Variable_Actions;
|
zhmu/ananas | Ada | 1,206 | ads | ------------------------------------------------------------------------------
-- --
-- GNAT RUN-TIME COMPONENTS --
-- --
-- A D A . F L O A T _ W I D E _ T E X T _ I O --
-- --
-- S p e c --
-- --
-- This specification is derived from the Ada Reference Manual for use with --
-- GNAT. In accordance with the copyright of that document, you can freely --
-- copy and modify this specification, provided that if you redistribute a --
-- modified version, any changes that you have made are clearly indicated. --
-- --
------------------------------------------------------------------------------
with Ada.Wide_Text_IO;
package Ada.Float_Wide_Text_IO is
new Ada.Wide_Text_IO.Float_IO (Float);
|
stcarrez/bbox-ada-api | Ada | 6,397 | adb | -----------------------------------------------------------------------
-- druss-gateways -- Gateway management
-- Copyright (C) 2017, 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.Properties.Basic;
with Util.Strings;
with Util.Log.Loggers;
with Util.Http.Clients;
package body Druss.Gateways is
use Ada.Strings.Unbounded;
-- The logger
Log : constant Util.Log.Loggers.Logger := Util.Log.Loggers.Create ("Druss.Gateways");
protected body Gateway_State is
function Get_State return State_Type is
begin
return State;
end Get_State;
end Gateway_State;
function "=" (Left, Right : in Gateway_Ref) return Boolean is
begin
if Left.Is_Null then
return Right.Is_Null;
elsif Right.Is_Null then
return False;
else
declare
Left_Rule : constant Gateway_Refs.Element_Accessor := Left.Value;
Right_Rule : constant Gateway_Refs.Element_Accessor := Right.Value;
begin
return Left_Rule.Element = Right_Rule.Element;
end;
end if;
end "=";
package Int_Property renames Util.Properties.Basic.Integer_Property;
package Bool_Property renames Util.Properties.Basic.Boolean_Property;
-- ------------------------------
-- Initalize the list of gateways from the property list.
-- ------------------------------
procedure Initialize (Config : in Util.Properties.Manager;
List : in out Gateway_Vector) is
Count : constant Natural := Int_Property.Get (Config, "druss.bbox.count", 0);
begin
for I in 1 .. Count loop
declare
Gw : constant Gateway_Ref := Gateway_Refs.Create;
Base : constant String := "druss.bbox." & Util.Strings.Image (I);
begin
Gw.Value.Ip := Config.Get (Base & ".ip");
if Config.Exists (Base & ".images") then
Gw.Value.Images := Config.Get (Base & ".images");
end if;
Gw.Value.Passwd := Config.Get (Base & ".password");
Gw.Value.Serial := Config.Get (Base & ".serial");
Gw.Value.Enable := Bool_Property.Get (Config, Base & ".enable", True);
List.Append (Gw);
exception
when Util.Properties.NO_PROPERTY =>
Log.Debug ("Ignoring gatway {0}", Base);
end;
end loop;
end Initialize;
-- ------------------------------
-- Save the list of gateways.
-- ------------------------------
procedure Save_Gateways (Config : in out Util.Properties.Manager;
List : in Druss.Gateways.Gateway_Vector) is
Pos : Natural := 0;
begin
for Gw of List loop
Pos := Pos + 1;
declare
Base : constant String := "druss.bbox." & Util.Strings.Image (Pos);
begin
Config.Set (Base & ".ip", Gw.Value.Ip);
Config.Set (Base & ".password", Gw.Value.Passwd);
Config.Set (Base & ".serial", Gw.Value.Serial);
Bool_Property.Set (Config, Base & ".enable", Gw.Value.Enable);
exception
when Util.Properties.NO_PROPERTY =>
null;
end;
end loop;
Util.Properties.Basic.Integer_Property.Set (Config, "druss.bbox.count", Pos);
end Save_Gateways;
-- ------------------------------
-- Refresh the information by using the Bbox API.
-- ------------------------------
procedure Refresh (Gateway : in out Gateway_Type) is
Box : Bbox.API.Client_Type;
begin
if Gateway.State.Get_State = BUSY then
return;
end if;
Box.Set_Server (To_String (Gateway.Ip));
if Ada.Strings.Unbounded.Length (Gateway.Passwd) > 0 then
Box.Login (To_String (Gateway.Passwd));
end if;
Box.Get ("wan/ip", Gateway.Wan);
Box.Get ("lan/ip", Gateway.Lan);
Box.Get ("device", Gateway.Device);
Box.Get ("wireless", Gateway.Wifi);
Box.Get ("voip", Gateway.Voip);
Box.Get ("iptv", Gateway.IPtv);
Box.Get ("hosts", Gateway.Hosts);
if Gateway.Device.Exists ("device.serialnumber") then
Gateway.Serial := Gateway.Device.Get ("device.serialnumber");
end if;
exception
when Util.Http.Clients.Connection_Error =>
Log.Error ("Cannot connect to {0}", To_String (Gateway.Ip));
end Refresh;
-- ------------------------------
-- Refresh the information by using the Bbox API.
-- ------------------------------
procedure Refresh (Gateway : in Gateway_Ref) is
begin
Gateway.Value.Refresh;
end Refresh;
-- ------------------------------
-- Iterate over the list of gateways and execute the <tt>Process</tt> procedure.
-- ------------------------------
procedure Iterate (List : in Gateway_Vector;
Mode : in Iterate_Type := ITER_ALL;
Process : not null access procedure (G : in out Gateway_Type)) is
Expect : constant Boolean := Mode = ITER_ENABLE;
begin
for G of List loop
if Mode = ITER_ALL or else G.Value.Enable = Expect then
Process (G.Value);
end if;
end loop;
end Iterate;
Null_Gateway : Gateway_Ref;
-- ------------------------------
-- Find the gateway with the given IP address.
-- ------------------------------
function Find_IP (List : in Gateway_Vector;
IP : in String) return Gateway_Ref is
begin
for G of List loop
if G.Value.Ip = IP then
return G;
end if;
end loop;
Log.Debug ("No gateway with IP {0}", IP);
return Null_Gateway;
end Find_IP;
end Druss.Gateways;
|
adamnemecek/GA_Ada | Ada | 1,416 | ads |
with GA_Maths;
package Multivector_Type_Base is
-- Object_Type mvtypebase.h lines 8 - 13 and 36
-- A versor is also a multivetor
-- A blade is also a versor and, therfore, also a multivector
type Object_Type is (Unspecified_Object_Type, Multivector_Object, Versor_MV, Blade_MV);
type Parity is (No_Parity, Even_Parity, Odd_Parity); -- line 43
-- mvtypebase.h lines 33 - 43
type MV_Typebase is record
M_Zero : boolean := False; -- True if multivector is zero
M_Type : Object_Type := Unspecified_Object_Type;
M_Grade : integer := -1; -- Top grade occupied by the multivector
M_Grade_Use : GA_Maths.Grade_Usage := 0; -- Bit map indicating which grades are present
M_Parity : Parity := No_Parity;
end record;
-- procedure Set_Grade_Usage (Base : in out Type_Base; GU : GA_Maths.Grade_Usage);
-- procedure Set_M_Type (Base : in out Type_Base; theType : Object_Type);
-- procedure Set_Parity (Base : in out Type_Base; Par : Parity);
-- procedure Set_Top_Grade (Base : in out Type_Base; Grade : Integer);
procedure Set_Type_Base (Base : in out MV_Typebase; Zero : boolean;
Object : Object_Type; Grade : integer;
GU : GA_Maths.Grade_Usage; Par : Parity := No_Parity);
private
type Flag is (Valid);
end Multivector_Type_Base;
|
houey/Amass | Ada | 588 | ads | -- Copyright 2017 Jeff Foley. All rights reserved.
-- Use of this source code is governed by Apache 2 LICENSE that can be found in the LICENSE file.
name = "SiteDossier"
type = "scrape"
function start()
setratelimit(2)
end
function vertical(ctx, domain)
local p = 1
while(true) do
local ok = scrape(ctx, {url=buildurl(domain, p)})
if not ok then
break
end
checkratelimit()
p = p + 100
end
end
function buildurl(domain, pagenum)
return "http://www.sitedossier.com/parentdomain/" .. domain .. "/" .. pagenum
end
|
reznikmm/matreshka | Ada | 4,695 | ads | ------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- Open Document Toolkit --
-- --
-- Runtime Library Component --
-- --
------------------------------------------------------------------------------
-- --
-- Copyright © 2014, Vadim Godunko <[email protected]> --
-- All rights reserved. --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions --
-- are met: --
-- --
-- * Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- --
-- * Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in the --
-- documentation and/or other materials provided with the distribution. --
-- --
-- * Neither the name of the Vadim Godunko, IE nor the names of its --
-- contributors may be used to endorse or promote products derived from --
-- this software without specific prior written permission. --
-- --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR --
-- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
-- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED --
-- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR --
-- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF --
-- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING --
-- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS --
-- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
-- --
------------------------------------------------------------------------------
-- $Revision$ $Date$
------------------------------------------------------------------------------
with XML.DOM.Visitors;
with ODF.DOM.Text_Sequence_Elements;
package Matreshka.ODF_Text.Sequence_Elements is
type Text_Sequence_Element_Node is
new Matreshka.ODF_Text.Abstract_Text_Element_Node
and ODF.DOM.Text_Sequence_Elements.ODF_Text_Sequence
with null record;
overriding function Create
(Parameters : not null access Matreshka.DOM_Elements.Element_L2_Parameters)
return Text_Sequence_Element_Node;
overriding function Get_Local_Name
(Self : not null access constant Text_Sequence_Element_Node)
return League.Strings.Universal_String;
overriding procedure Enter_Node
(Self : not null access Text_Sequence_Element_Node;
Visitor : in out XML.DOM.Visitors.Abstract_Visitor'Class;
Control : in out XML.DOM.Visitors.Traverse_Control);
overriding procedure Leave_Node
(Self : not null access Text_Sequence_Element_Node;
Visitor : in out XML.DOM.Visitors.Abstract_Visitor'Class;
Control : in out XML.DOM.Visitors.Traverse_Control);
overriding procedure Visit_Node
(Self : not null access Text_Sequence_Element_Node;
Iterator : in out XML.DOM.Visitors.Abstract_Iterator'Class;
Visitor : in out XML.DOM.Visitors.Abstract_Visitor'Class;
Control : in out XML.DOM.Visitors.Traverse_Control);
end Matreshka.ODF_Text.Sequence_Elements;
|
PThierry/ewok-kernel | Ada | 1,287 | ads | --
-- Copyright 2018 The wookey project team <[email protected]>
-- - Ryad Benadjila
-- - Arnauld Michelizza
-- - Mathieu Renard
-- - Philippe Thierry
-- - Philippe Trebuchet
--
-- Licensed under the Apache License, Version 2.0 (the "License");
-- you may not use this file except in compliance with the License.
-- You may obtain a copy of the License at
--
-- http://www.apache.org/licenses/LICENSE-2.0
--
-- Unless required by applicable law or agreed to in writing, software
-- distributed under the License is distributed on an "AS IS" BASIS,
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-- See the License for the specific language governing permissions and
-- limitations under the License.
--
--
with ewok.tasks;
with ewok.tasks_shared;
package ewok.syscalls.lock
with spark_mode => off
is
procedure svc_lock_enter
(caller_id : in ewok.tasks_shared.t_task_id;
mode : in ewok.tasks_shared.t_task_mode)
with
global => (output => ewok.tasks.tasks_list);
procedure svc_lock_exit
(caller_id : in ewok.tasks_shared.t_task_id;
mode : in ewok.tasks_shared.t_task_mode)
with
global => (output => ewok.tasks.tasks_list);
end ewok.syscalls.lock;
|
gitter-badger/libAnne | Ada | 20,630 | ads | with Generics.Testing.Discrete_Assertions;
with Generics.Testing.Fixed_Assertions;
with Generics.Testing.Float_Assertions;
package Testing.Assertions is
--@description Provides assertions for standard types
--@version 1.0.0
-------------------------
-- Short Short Integer --
-------------------------
package Short_Short_Integer_Assertions is new Generics.Testing.Discrete_Assertions(Short_Short_Integer);
function Assert(Statement : Wide_Wide_String; Object : Short_Short_Integer) return Short_Short_Integer_Assertions.Asserter renames Short_Short_Integer_Assertions.Assert;
function Equal(Self : Short_Short_Integer_Assertions.Asserter; Value : Short_Short_Integer) return Short_Short_Integer_Assertions.Asserter renames Short_Short_Integer_Assertions.Equal;
procedure Equal(Self : Short_Short_Integer_Assertions.Asserter; Value : Short_Short_Integer) renames Short_Short_Integer_Assertions.Equal;
function Not_Equal(Self : Short_Short_Integer_Assertions.Asserter; Value : Short_Short_Integer) return Short_Short_Integer_Assertions.Asserter renames Short_Short_Integer_Assertions.Equal;
procedure Not_Equal(Self : Short_Short_Integer_Assertions.Asserter; Value : Short_Short_Integer) renames Short_Short_Integer_Assertions.Equal;
function Greater(Self : Short_Short_Integer_Assertions.Asserter; Value : Short_Short_Integer) return Short_Short_Integer_Assertions.Asserter renames Short_Short_Integer_Assertions.Greater;
procedure Greater(Self : Short_Short_Integer_Assertions.Asserter; Value : Short_Short_Integer) renames Short_Short_Integer_Assertions.Greater;
function Lesser(Self : Short_Short_Integer_Assertions.Asserter; Value : Short_Short_Integer) return Short_Short_Integer_Assertions.Asserter renames Short_Short_Integer_Assertions.Lesser;
procedure Lesser(Self : Short_Short_Integer_Assertions.Asserter; Value : Short_Short_Integer) renames Short_Short_Integer_Assertions.Lesser;
-------------------
-- Short Integer --
-------------------
package Short_Integer_Assertions is new Generics.Testing.Discrete_Assertions(Short_Integer);
function Assert(Statement : Wide_Wide_String; Object : Short_Integer) return Short_Integer_Assertions.Asserter renames Short_Integer_Assertions.Assert;
function Equal(Self : Short_Integer_Assertions.Asserter; Value : Short_Integer) return Short_Integer_Assertions.Asserter renames Short_Integer_Assertions.Equal;
procedure Equal(Self : Short_Integer_Assertions.Asserter; Value : Short_Integer) renames Short_Integer_Assertions.Equal;
function Not_Equal(Self : Short_Integer_Assertions.Asserter; Value : Short_Integer) return Short_Integer_Assertions.Asserter renames Short_Integer_Assertions.Equal;
procedure Not_Equal(Self : Short_Integer_Assertions.Asserter; Value : Short_Integer) renames Short_Integer_Assertions.Equal;
function Greater(Self : Short_Integer_Assertions.Asserter; Value : Short_Integer) return Short_Integer_Assertions.Asserter renames Short_Integer_Assertions.Greater;
procedure Greater(Self : Short_Integer_Assertions.Asserter; Value : Short_Integer) renames Short_Integer_Assertions.Greater;
function Lesser(Self : Short_Integer_Assertions.Asserter; Value : Short_Integer) return Short_Integer_Assertions.Asserter renames Short_Integer_Assertions.Lesser;
procedure Lesser(Self : Short_Integer_Assertions.Asserter; Value : Short_Integer) renames Short_Integer_Assertions.Lesser;
-------------
-- Integer --
-------------
package Integer_Assertions is new Generics.Testing.Discrete_Assertions(Integer);
function Assert(Statement : Wide_Wide_String; Object : Integer) return Integer_Assertions.Asserter renames Integer_Assertions.Assert;
function Equal(Self : Integer_Assertions.Asserter; Value : Integer) return Integer_Assertions.Asserter renames Integer_Assertions.Equal;
procedure Equal(Self : Integer_Assertions.Asserter; Value : Integer) renames Integer_Assertions.Equal;
function Not_Equal(Self : Integer_Assertions.Asserter; Value : Integer) return Integer_Assertions.Asserter renames Integer_Assertions.Equal;
procedure Not_Equal(Self : Integer_Assertions.Asserter; Value : Integer) renames Integer_Assertions.Equal;
function Greater(Self : Integer_Assertions.Asserter; Value : Integer) return Integer_Assertions.Asserter renames Integer_Assertions.Greater;
procedure Greater(Self : Integer_Assertions.Asserter; Value : Integer) renames Integer_Assertions.Greater;
function Lesser(Self : Integer_Assertions.Asserter; Value : Integer) return Integer_Assertions.Asserter renames Integer_Assertions.Lesser;
procedure Lesser(Self : Integer_Assertions.Asserter; Value : Integer) renames Integer_Assertions.Lesser;
------------------
-- Long Integer --
------------------
package Long_Integer_Assertions is new Generics.Testing.Discrete_Assertions(Long_Integer);
function Assert(Statement : Wide_Wide_String; Object : Long_Integer) return Long_Integer_Assertions.Asserter renames Long_Integer_Assertions.Assert;
function Equal(Self : Long_Integer_Assertions.Asserter; Value : Long_Integer) return Long_Integer_Assertions.Asserter renames Long_Integer_Assertions.Equal;
procedure Equal(Self : Long_Integer_Assertions.Asserter; Value : Long_Integer) renames Long_Integer_Assertions.Equal;
function Not_Equal(Self : Long_Integer_Assertions.Asserter; Value : Long_Integer) return Long_Integer_Assertions.Asserter renames Long_Integer_Assertions.Equal;
procedure Not_Equal(Self : Long_Integer_Assertions.Asserter; Value : Long_Integer) renames Long_Integer_Assertions.Equal;
function Greater(Self : Long_Integer_Assertions.Asserter; Value : Long_Integer) return Long_Integer_Assertions.Asserter renames Long_Integer_Assertions.Greater;
procedure Greater(Self : Long_Integer_Assertions.Asserter; Value : Long_Integer) renames Long_Integer_Assertions.Greater;
function Lesser(Self : Long_Integer_Assertions.Asserter; Value : Long_Integer) return Long_Integer_Assertions.Asserter renames Long_Integer_Assertions.Lesser;
procedure Lesser(Self : Long_Integer_Assertions.Asserter; Value : Long_Integer) renames Long_Integer_Assertions.Lesser;
-----------------------
-- Long Long Integer --
-----------------------
package Long_Long_Integer_Assertions is new Generics.Testing.Discrete_Assertions(Long_Long_Integer);
function Assert(Statement : Wide_Wide_String; Object : Long_Long_Integer) return Long_Long_Integer_Assertions.Asserter renames Long_Long_Integer_Assertions.Assert;
function Equal(Self : Long_Long_Integer_Assertions.Asserter; Value : Long_Long_Integer) return Long_Long_Integer_Assertions.Asserter renames Long_Long_Integer_Assertions.Equal;
procedure Equal(Self : Long_Long_Integer_Assertions.Asserter; Value : Long_Long_Integer) renames Long_Long_Integer_Assertions.Equal;
function Not_Equal(Self : Long_Long_Integer_Assertions.Asserter; Value : Long_Long_Integer) return Long_Long_Integer_Assertions.Asserter renames Long_Long_Integer_Assertions.Not_Equal;
procedure Not_Equal(Self : Long_Long_Integer_Assertions.Asserter; Value : Long_Long_Integer) renames Long_Long_Integer_Assertions.Not_Equal;
function Greater(Self : Long_Long_Integer_Assertions.Asserter; Value : Long_Long_Integer) return Long_Long_Integer_Assertions.Asserter renames Long_Long_Integer_Assertions.Greater;
procedure Greater(Self : Long_Long_Integer_Assertions.Asserter; Value : Long_Long_Integer) renames Long_Long_Integer_Assertions.Greater;
function Lesser(Self : Long_Long_Integer_Assertions.Asserter; Value : Long_Long_Integer) return Long_Long_Integer_Assertions.Asserter renames Long_Long_Integer_Assertions.Lesser;
procedure Lesser(Self : Long_Long_Integer_Assertions.Asserter; Value : Long_Long_Integer) renames Long_Long_Integer_Assertions.Lesser;
-----------------
-- Short Float --
-----------------
package Short_Float_Assertions is new Generics.Testing.Float_Assertions(Short_Float);
function Assert(Statement : Wide_Wide_String; Object : Short_Float) return Short_Float_Assertions.Asserter renames Short_Float_Assertions.Assert;
function Assert(Statement : Wide_Wide_String; Object : Short_Float; Tolerance : Short_Float) return Short_Float_Assertions.Asserter renames Short_Float_Assertions.Assert;
function Equal(Self : Short_Float_Assertions.Asserter; Value : Short_Float) return Short_Float_Assertions.Asserter renames Short_Float_Assertions.Equal;
procedure Equal(Self : Short_Float_Assertions.Asserter; Value : Short_Float) renames Short_Float_Assertions.Equal;
function Not_Equal(Self : Short_Float_Assertions.Asserter; Value : Short_Float) return Short_Float_Assertions.Asserter renames Short_Float_Assertions.Not_Equal;
procedure Not_Equal(Self : Short_Float_Assertions.Asserter; Value : Short_Float) renames Short_Float_Assertions.Not_Equal;
function Greater(Self : Short_Float_Assertions.Asserter; Value : Short_Float) return Short_Float_Assertions.Asserter renames Short_Float_Assertions.Greater;
procedure Greater(Self : Short_Float_Assertions.Asserter; Value : Short_Float) renames Short_Float_Assertions.Greater;
function Lesser(Self : Short_Float_Assertions.Asserter; Value : Short_Float) return Short_Float_Assertions.Asserter renames Short_Float_Assertions.Lesser;
procedure Lesser(Self : Short_Float_Assertions.Asserter; Value : Short_Float) renames Short_Float_Assertions.Lesser;
-----------
-- Float --
-----------
package Float_Assertions is new Generics.Testing.Float_Assertions(Float);
function Assert(Statement : Wide_Wide_String; Object : Float) return Float_Assertions.Asserter renames Float_Assertions.Assert;
function Assert(Statement : Wide_Wide_String; Object : Float; Tolerance : Float) return Float_Assertions.Asserter renames Float_Assertions.Assert;
function Equal(Self : Float_Assertions.Asserter; Value : Float) return Float_Assertions.Asserter renames Float_Assertions.Equal;
procedure Equal(Self : Float_Assertions.Asserter; Value : Float) renames Float_Assertions.Equal;
function Not_Equal(Self : Float_Assertions.Asserter; Value : Float) return Float_Assertions.Asserter renames Float_Assertions.Not_Equal;
procedure Not_Equal(Self : Float_Assertions.Asserter; Value : Float) renames Float_Assertions.Not_Equal;
function Greater(Self : Float_Assertions.Asserter; Value : Float) return Float_Assertions.Asserter renames Float_Assertions.Greater;
procedure Greater(Self : Float_Assertions.Asserter; Value : Float) renames Float_Assertions.Greater;
function Lesser(Self : Float_Assertions.Asserter; Value : Float) return Float_Assertions.Asserter renames Float_Assertions.Lesser;
procedure Lesser(Self : Float_Assertions.Asserter; Value : Float) renames Float_Assertions.Lesser;
----------------
-- Long Float --
----------------
package Long_Float_Assertions is new Generics.Testing.Float_Assertions(Long_Float);
function Assert(Statement : Wide_Wide_String; Object : Long_Float) return Long_Float_Assertions.Asserter renames Long_Float_Assertions.Assert;
function Assert(Statement : Wide_Wide_String; Object : Long_Float; Tolerance : Long_Float) return Long_Float_Assertions.Asserter renames Long_Float_Assertions.Assert;
function Equal(Self : Long_Float_Assertions.Asserter; Value : Long_Float) return Long_Float_Assertions.Asserter renames Long_Float_Assertions.Equal;
procedure Equal(Self : Long_Float_Assertions.Asserter; Value : Long_Float) renames Long_Float_Assertions.Equal;
function Not_Equal(Self : Long_Float_Assertions.Asserter; Value : Long_Float) return Long_Float_Assertions.Asserter renames Long_Float_Assertions.Not_Equal;
procedure Not_Equal(Self : Long_Float_Assertions.Asserter; Value : Long_Float) renames Long_Float_Assertions.Not_Equal;
function Greater(Self : Long_Float_Assertions.Asserter; Value : Long_Float) return Long_Float_Assertions.Asserter renames Long_Float_Assertions.Greater;
procedure Greater(Self : Long_Float_Assertions.Asserter; Value : Long_Float) renames Long_Float_Assertions.Greater;
function Lesser(Self : Long_Float_Assertions.Asserter; Value : Long_Float) return Long_Float_Assertions.Asserter renames Long_Float_Assertions.Lesser;
procedure Lesser(Self : Long_Float_Assertions.Asserter; Value : Long_Float) renames Long_Float_Assertions.Lesser;
---------------------
-- Long Long Float --
---------------------
package Long_Long_Float_Assertions is new Generics.Testing.Float_Assertions(Long_Long_Float);
function Assert(Statement : Wide_Wide_String; Object : Long_Long_Float) return Long_Long_Float_Assertions.Asserter renames Long_Long_Float_Assertions.Assert;
function Assert(Statement : Wide_Wide_String; Object : Long_Long_Float; Tolerance : Long_Long_Float) return Long_Long_Float_Assertions.Asserter renames Long_Long_Float_Assertions.Assert;
function Equal(Self : Long_Long_Float_Assertions.Asserter; Value : Long_Long_Float) return Long_Long_Float_Assertions.Asserter renames Long_Long_Float_Assertions.Equal;
procedure Equal(Self : Long_Long_Float_Assertions.Asserter; Value : Long_Long_Float) renames Long_Long_Float_Assertions.Equal;
function Not_Equal(Self : Long_Long_Float_Assertions.Asserter; Value : Long_Long_Float) return Long_Long_Float_Assertions.Asserter renames Long_Long_Float_Assertions.Not_Equal;
procedure Not_Equal(Self : Long_Long_Float_Assertions.Asserter; Value : Long_Long_Float) renames Long_Long_Float_Assertions.Not_Equal;
function Greater(Self : Long_Long_Float_Assertions.Asserter; Value : Long_Long_Float) return Long_Long_Float_Assertions.Asserter renames Long_Long_Float_Assertions.Greater;
procedure Greater(Self : Long_Long_Float_Assertions.Asserter; Value : Long_Long_Float) renames Long_Long_Float_Assertions.Greater;
function Lesser(Self : Long_Long_Float_Assertions.Asserter; Value : Long_Long_Float) return Long_Long_Float_Assertions.Asserter renames Long_Long_Float_Assertions.Lesser;
procedure Lesser(Self : Long_Long_Float_Assertions.Asserter; Value : Long_Long_Float) renames Long_Long_Float_Assertions.Lesser;
--------------
-- Duration --
--------------
package Duration_Assertions is new Generics.Testing.Fixed_Assertions(Duration);
function Assert(Statement : Wide_Wide_String; Object : Duration) return Duration_Assertions.Asserter renames Duration_Assertions.Assert;
function Assert(Statement : Wide_Wide_String; Object : Duration; Tolerance : Duration) return Duration_Assertions.Asserter renames Duration_Assertions.Assert;
function Equal(Self : Duration_Assertions.Asserter; Value : Duration) return Duration_Assertions.Asserter renames Duration_Assertions.Equal;
procedure Equal(Self : Duration_Assertions.Asserter; Value : Duration) renames Duration_Assertions.Equal;
function Not_Equal(Self : Duration_Assertions.Asserter; Value : Duration) return Duration_Assertions.Asserter renames Duration_Assertions.Not_Equal;
procedure Not_Equal(Self : Duration_Assertions.Asserter; Value : Duration) renames Duration_Assertions.Not_Equal;
function Greater(Self : Duration_Assertions.Asserter; Value : Duration) return Duration_Assertions.Asserter renames Duration_Assertions.Greater;
procedure Greater(Self : Duration_Assertions.Asserter; Value : Duration) renames Duration_Assertions.Greater;
function Lesser(Self : Duration_Assertions.Asserter; Value : Duration) return Duration_Assertions.Asserter renames Duration_Assertions.Lesser;
procedure Lesser(Self : Duration_Assertions.Asserter; Value : Duration) renames Duration_Assertions.Lesser;
---------------
-- Character --
---------------
package Character_Assertions is new Generics.Testing.Discrete_Assertions(Character);
function Assert(Statement : Wide_Wide_String; Object : Character) return Character_Assertions.Asserter renames Character_Assertions.Assert;
function Equal(Self : Character_Assertions.Asserter; Value : Character) return Character_Assertions.Asserter renames Character_Assertions.Equal;
procedure Equal(Self : Character_Assertions.Asserter; Value : Character) renames Character_Assertions.Equal;
function Not_Equal(Self : Character_Assertions.Asserter; Value : Character) return Character_Assertions.Asserter renames Character_Assertions.Not_Equal;
procedure Not_Equal(Self : Character_Assertions.Asserter; Value : Character) renames Character_Assertions.Not_Equal;
--------------------
-- Wide Character --
--------------------
package Wide_Character_Assertions is new Generics.Testing.Discrete_Assertions(Wide_Character);
function Assert(Statement : Wide_Wide_String; Object : Wide_Character) return Wide_Character_Assertions.Asserter renames Wide_Character_Assertions.Assert;
function Equal(Self : Wide_Character_Assertions.Asserter; Value : Wide_Character) return Wide_Character_Assertions.Asserter renames Wide_Character_Assertions.Equal;
procedure Equal(Self : Wide_Character_Assertions.Asserter; Value : Wide_Character) renames Wide_Character_Assertions.Equal;
function Not_Equal(Self : Wide_Character_Assertions.Asserter; Value : Wide_Character) return Wide_Character_Assertions.Asserter renames Wide_Character_Assertions.Not_Equal;
procedure Not_Equal(Self : Wide_Character_Assertions.Asserter; Value : Wide_Character) renames Wide_Character_Assertions.Not_Equal;
-------------------------
-- Wide Wide Character --
-------------------------
package Wide_Wide_Character_Assertions is new Generics.Testing.Discrete_Assertions(Wide_Wide_Character);
function Assert(Statement : Wide_Wide_String; Object : Wide_Wide_Character) return Wide_Wide_Character_Assertions.Asserter renames Wide_Wide_Character_Assertions.Assert;
function Equal(Self : Wide_Wide_Character_Assertions.Asserter; Value : Wide_Wide_Character) return Wide_Wide_Character_Assertions.Asserter renames Wide_Wide_Character_Assertions.Equal;
procedure Equal(Self : Wide_Wide_Character_Assertions.Asserter; Value : Wide_Wide_Character) renames Wide_Wide_Character_Assertions.Equal;
function Not_Equal(Self : Wide_Wide_Character_Assertions.Asserter; Value : Wide_Wide_Character) return Wide_Wide_Character_Assertions.Asserter renames Wide_Wide_Character_Assertions.Not_Equal;
procedure Not_Equal(Self : Wide_Wide_Character_Assertions.Asserter; Value : Wide_Wide_Character) renames Wide_Wide_Character_Assertions.Not_Equal;
------------
-- String --
------------
type String_Asserter(Statement_Length : Positive; String_Length : Positive) is tagged private;
function Assert(Statement : Wide_Wide_String; Object : String) return String_Asserter;
function Equal(Self : String_Asserter; Value : String) return String_Asserter;
procedure Equal(Self : String_Asserter; Value : String);
function Not_Equal(Self : String_Asserter; Value : String) return String_Asserter;
procedure Not_Equal(Self : String_Asserter; Value : String);
-----------------
-- Wide String --
-----------------
type Wide_String_Asserter(Statement_Length : Positive; String_Length : Positive) is tagged private;
function Assert(Statement : Wide_Wide_String; Object : Wide_String) return Wide_String_Asserter;
function Equal(Self : Wide_String_Asserter; Value : Wide_String) return Wide_String_Asserter;
procedure Equal(Self : Wide_String_Asserter; Value : Wide_String);
function Not_Equal(Self : Wide_String_Asserter; Value : Wide_String) return Wide_String_Asserter;
procedure Not_Equal(Self : Wide_String_Asserter; Value : Wide_String);
----------------------
-- Wide Wide String --
----------------------
type Wide_Wide_String_Asserter(Statement_Length : Positive; String_Length : Positive) is tagged private;
function Assert(Statement : Wide_Wide_String; Object : Wide_Wide_String) return Wide_Wide_String_Asserter;
function Equal(Self : Wide_Wide_String_Asserter; Value : Wide_Wide_String) return Wide_Wide_String_Asserter;
procedure Equal(Self : Wide_Wide_String_Asserter; Value : Wide_Wide_String);
function Not_Equal(Self : Wide_Wide_String_Asserter; Value : Wide_Wide_String) return Wide_Wide_String_Asserter;
procedure Not_Equal(Self : Wide_Wide_String_Asserter; Value : Wide_Wide_String);
private
type String_Asserter(Statement_Length : Positive; String_Length : Positive) is tagged record
Object : String(1 .. String_Length);
Statement : Wide_Wide_String(1 .. Statement_Length);
end record;
type Wide_String_Asserter(Statement_Length : Positive; String_Length : Positive) is tagged record
Object : Wide_String(1 .. String_Length);
Statement : Wide_Wide_String(1 .. Statement_Length);
end record;
type Wide_Wide_String_Asserter(Statement_Length : Positive; String_Length : Positive) is tagged record
Object : Wide_Wide_String(1 .. String_Length);
Statement : Wide_Wide_String(1 .. Statement_Length);
end record;
end Testing.Assertions;
|
stcarrez/ada-wiki | Ada | 9,375 | ads | -----------------------------------------------------------------------
-- wiki-render-wiki -- Wiki to Wiki renderer
-- Copyright (C) 2015, 2016, 2020, 2022 Stephane Carrez
-- Written by Stephane Carrez ([email protected])
--
-- Licensed under the Apache License, Version 2.0 (the "License");
-- you may not use this file except in compliance with the License.
-- You may obtain a copy of the License at
--
-- http://www.apache.org/licenses/LICENSE-2.0
--
-- Unless required by applicable law or agreed to in writing, software
-- distributed under the License is distributed on an "AS IS" BASIS,
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-- See the License for the specific language governing permissions and
-- limitations under the License.
-----------------------------------------------------------------------
with Ada.Strings.Wide_Wide_Maps;
with Ada.Strings.Wide_Wide_Unbounded;
with Wiki.Documents;
with Wiki.Attributes;
with Wiki.Streams;
with Wiki.Strings;
-- === Wiki Renderer ===
-- The `Wiki_Renderer</tt> allows to render a wiki document into another wiki content.
-- The formatting rules are ignored except for the paragraphs and sections.
package Wiki.Render.Wiki is
use Standard.Wiki.Attributes;
-- ------------------------------
-- Wiki to HTML writer
-- ------------------------------
type Wiki_Renderer is new Renderer with private;
-- Set the output stream.
procedure Set_Output_Stream (Engine : in out Wiki_Renderer;
Stream : in Streams.Output_Stream_Access;
Format : in Wiki_Syntax);
-- Render the node instance from the document.
overriding
procedure Render (Engine : in out Wiki_Renderer;
Doc : in Documents.Document;
Node : in Nodes.Node_Type);
-- Add a section header in the document.
procedure Render_Header (Engine : in out Wiki_Renderer;
Doc : in Documents.Document;
Node : in Nodes.Node_Type;
Level : in Natural;
List : in Nodes.Node_List_Access);
-- Add a paragraph (<p>). Close the previous paragraph if any.
-- The paragraph must be closed at the next paragraph or next header.
procedure Add_Paragraph (Engine : in out Wiki_Renderer);
-- Add a blockquote (<blockquote>). The level indicates the blockquote nested level.
-- The blockquote must be closed at the next header.
procedure Add_Blockquote (Engine : in out Wiki_Renderer;
Level : in Natural);
-- Add a list item (<li>). Close the previous paragraph and list item if any.
-- The list item will be closed at the next list item, next paragraph or next header.
procedure Add_List_Item (Engine : in out Wiki_Renderer;
Level : in Positive;
Ordered : in Boolean);
procedure Render_List_Start (Engine : in out Wiki_Renderer;
Numbered : in Boolean;
Level : in Natural);
procedure Render_List_End (Engine : in out Wiki_Renderer;
Tag : in String);
procedure Render_List_Item_Start (Engine : in out Wiki_Renderer);
procedure Render_List_Item_End (Engine : in out Wiki_Renderer);
-- Render a link.
procedure Render_Link (Engine : in out Wiki_Renderer;
Name : in Strings.WString;
Attrs : in Attributes.Attribute_List);
-- Render an image.
procedure Render_Image (Engine : in out Wiki_Renderer;
Title : in Strings.WString;
Attrs : in Attributes.Attribute_List);
-- Render a quote.
procedure Render_Quote (Engine : in out Wiki_Renderer;
Title : in Strings.WString;
Attrs : in Attributes.Attribute_List);
-- Add a text block with the given format.
procedure Render_Text (Engine : in out Wiki_Renderer;
Text : in Wide_Wide_String;
Format : in Format_Map);
-- Render a text block that is pre-formatted.
procedure Render_Preformatted (Engine : in out Wiki_Renderer;
Text : in Strings.WString;
Format : in Strings.WString);
procedure Render_Tag (Engine : in out Wiki_Renderer;
Doc : in Documents.Document;
Node : in Nodes.Node_Type);
-- Finish the document after complete wiki text has been parsed.
overriding
procedure Finish (Engine : in out Wiki_Renderer;
Doc : in Documents.Document);
-- Set the text style format.
procedure Set_Format (Engine : in out Wiki_Renderer;
Format : in Format_Map);
private
use Ada.Strings.Wide_Wide_Unbounded;
type Wide_String_Access is access constant Wide_Wide_String;
type Wiki_Tag_Type is (Header_Start, Header_End,
Img_Start, Img_End,
Link_Start, Link_End, Link_Separator,
Quote_Start, Quote_End, Quote_Separator,
Preformat_Start, Preformat_End,
List_Start, List_Item, List_Ordered_Item,
Line_Break, Escape_Rule,
Horizontal_Rule,
Blockquote_Start, Blockquote_End);
type Wiki_Tag_Array is array (Wiki_Tag_Type) of Wide_String_Access;
type Wiki_Format_Array is array (Format_Type) of Wide_String_Access;
procedure Write_Optional_Space (Engine : in out Wiki_Renderer);
-- Emit a new line.
procedure New_Line (Engine : in out Wiki_Renderer;
Optional : in Boolean := False);
procedure Need_Separator_Line (Engine : in out Wiki_Renderer);
procedure Close_Paragraph (Engine : in out Wiki_Renderer);
procedure Start_Keep_Content (Engine : in out Wiki_Renderer);
type List_Index_Type is new Integer range 0 .. 32;
type List_Level_Array is array (List_Index_Type range 1 .. 32) of Natural;
EMPTY_TAG : aliased constant Wide_Wide_String := "";
type Wiki_Renderer is new Renderer with record
Output : Streams.Output_Stream_Access := null;
Syntax : Wiki_Syntax := SYNTAX_CREOLE;
Format : Format_Map := (others => False);
Tags : Wiki_Tag_Array := (others => EMPTY_TAG'Access);
Style_Start_Tags : Wiki_Format_Array := (others => EMPTY_TAG'Access);
Style_End_Tags : Wiki_Format_Array := (others => EMPTY_TAG'Access);
Escape_Set : Ada.Strings.Wide_Wide_Maps.Wide_Wide_Character_Set;
List_Index : List_Index_Type := 0;
List_Levels : List_Level_Array;
Has_Paragraph : Boolean := False;
Has_Item : Boolean := False;
Need_Paragraph : Boolean := False;
Need_Newline : Boolean := False;
Need_Space : Boolean := False;
Empty_Line : Boolean := True;
Empty_Previous_Line : Boolean := True;
Keep_Content : Natural := 0;
In_List : Boolean := False;
Invert_Header_Level : Boolean := False;
Allow_Link_Language : Boolean := False;
Link_First : Boolean := False;
Html_Blockquote : Boolean := False;
Html_Table : Boolean := False;
In_Table : Boolean := False;
In_Header : Boolean := False;
Col_Index : Natural := 0;
Line_Count : Natural := 0;
Current_Level : Natural := 0;
Quote_Level : Natural := 0;
UL_List_Level : Natural := 0;
OL_List_Level : Natural := 0;
Current_Style : Format_Map := (others => False);
Content : Unbounded_Wide_Wide_String;
Link_Href : Unbounded_Wide_Wide_String;
Link_Title : Unbounded_Wide_Wide_String;
Link_Lang : Unbounded_Wide_Wide_String;
Indent_Level : Natural := 0;
end record;
procedure Write_Link (Engine : in out Wiki_Renderer;
Link : in Strings.WString);
-- Render the table of content.
procedure Render_TOC (Engine : in out Wiki_Renderer;
Doc : in Documents.Document;
Level : in Natural);
-- Render a table component such as N_TABLE.
procedure Render_Table (Engine : in out Wiki_Renderer;
Doc : in Documents.Document;
Node : in Nodes.Node_Type);
-- Render a table row component such as N_ROW.
procedure Render_Row (Engine : in out Wiki_Renderer;
Doc : in Documents.Document;
Node : in Nodes.Node_Type);
-- Render a table row component such as N_COLUMN.
procedure Render_Column (Engine : in out Wiki_Renderer;
Doc : in Documents.Document;
Node : in Nodes.Node_Type);
end Wiki.Render.Wiki;
|
joakim-strandberg/wayland_ada_binding | Ada | 1,294 | ads | with C_Binding.Linux.Udev.List_Entries;
-- Libudev hardware database interface.
--
-- The hardware database is a key-value store for associating modalias-like
-- keys to udev-properties-like values. It is used primarily by udev to add
-- the relevant properties to matching devices, but it can also be queried
-- directly.
package C_Binding.Linux.Udev.Hardware_Databases is
pragma Obsolescent;
type Database;
procedure Acquire
(Original : Database;
Reference : out Database) with
Pre => Hardware_Databases.Exists (Original);
-- Acquire a reference to an existing udev database object.
-- The reference count to Original goes up by 1.
type Database is new Hwdb_Base with private;
function Exists (Database : Hardware_Databases.Database) return Boolean;
procedure Delete (Database : in out Hardware_Databases.Database) with
Pre => Database.Exists,
Post => not Database.Exists;
procedure Properties_List_Entry
(Database : Hardware_Databases.Database;
Modalias : String;
List_Entry : out List_Entries.List_Entry);
private
type Database is new Hwdb_Base with null record;
overriding
procedure Finalize (Database : in out Hardware_Databases.Database);
end C_Binding.Linux.Udev.Hardware_Databases;
|
reznikmm/matreshka | Ada | 3,963 | adb | ------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- Web Framework --
-- --
-- Runtime Library Component --
-- --
------------------------------------------------------------------------------
-- --
-- Copyright © 2016-2017, Vadim Godunko <[email protected]> --
-- All rights reserved. --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions --
-- are met: --
-- --
-- * Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- --
-- * Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in the --
-- documentation and/or other materials provided with the distribution. --
-- --
-- * Neither the name of the Vadim Godunko, IE nor the names of its --
-- contributors may be used to endorse or promote products derived from --
-- this software without specific prior written permission. --
-- --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR --
-- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
-- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED --
-- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR --
-- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF --
-- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING --
-- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS --
-- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
-- --
------------------------------------------------------------------------------
-- $Revision$ $Date$
------------------------------------------------------------------------------
package body WUI.Actions is
------------------
-- Constructors --
------------------
package body Constructors is
----------------
-- Initialize --
----------------
procedure Initialize
(Self : in out Action'Class;
Text : League.Strings.Universal_String) is
begin
Self.Action_Text := Text;
end Initialize;
end Constructors;
----------
-- Text --
----------
not overriding function Text
(Self : Action) return League.Strings.Universal_String is
begin
return Self.Action_Text;
end Text;
end WUI.Actions;
|
reznikmm/matreshka | Ada | 23,725 | adb | ------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- Ada Modeling Framework --
-- --
-- Runtime Library Component --
-- --
------------------------------------------------------------------------------
-- --
-- Copyright © 2012, Vadim Godunko <[email protected]> --
-- All rights reserved. --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions --
-- are met: --
-- --
-- * Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- --
-- * Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in the --
-- documentation and/or other materials provided with the distribution. --
-- --
-- * Neither the name of the Vadim Godunko, IE nor the names of its --
-- contributors may be used to endorse or promote products derived from --
-- this software without specific prior written permission. --
-- --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR --
-- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
-- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED --
-- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR --
-- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF --
-- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING --
-- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS --
-- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
-- --
------------------------------------------------------------------------------
-- $Revision$ $Date$
------------------------------------------------------------------------------
-- This file is generated, don't edit it.
------------------------------------------------------------------------------
with AMF.Internals.Extents;
with AMF.Internals.Tables.CMOF_Constructors;
with AMF.Internals.Tables.CMOF_Element_Table;
with AMF.Internals.Tables.DI_String_Data_00;
package body AMF.Internals.Tables.DI_Metamodel.Objects is
----------------
-- Initialize --
----------------
procedure Initialize is
Extent : constant AMF.Internals.AMF_Extent
:= AMF.Internals.Extents.Allocate_Extent
(AMF.Internals.Tables.DI_String_Data_00.MS_0012'Access);
begin
Base := AMF.Internals.Tables.CMOF_Element_Table.Last;
Initialize_1 (Extent);
Initialize_2 (Extent);
Initialize_3 (Extent);
Initialize_4 (Extent);
Initialize_5 (Extent);
Initialize_6 (Extent);
Initialize_7 (Extent);
Initialize_8 (Extent);
Initialize_9 (Extent);
Initialize_10 (Extent);
Initialize_11 (Extent);
Initialize_12 (Extent);
Initialize_13 (Extent);
Initialize_14 (Extent);
Initialize_15 (Extent);
Initialize_16 (Extent);
Initialize_17 (Extent);
Initialize_18 (Extent);
Initialize_19 (Extent);
Initialize_20 (Extent);
Initialize_21 (Extent);
Initialize_22 (Extent);
Initialize_23 (Extent);
Initialize_24 (Extent);
Initialize_25 (Extent);
Initialize_26 (Extent);
Initialize_27 (Extent);
Initialize_28 (Extent);
Initialize_29 (Extent);
Initialize_30 (Extent);
Initialize_31 (Extent);
Initialize_32 (Extent);
Initialize_33 (Extent);
Initialize_34 (Extent);
Initialize_35 (Extent);
Initialize_36 (Extent);
Initialize_37 (Extent);
Initialize_38 (Extent);
Initialize_39 (Extent);
Initialize_40 (Extent);
Initialize_41 (Extent);
Initialize_42 (Extent);
Initialize_43 (Extent);
Initialize_44 (Extent);
Initialize_45 (Extent);
Initialize_46 (Extent);
Initialize_47 (Extent);
Initialize_48 (Extent);
Initialize_49 (Extent);
Initialize_50 (Extent);
Initialize_51 (Extent);
Initialize_52 (Extent);
Initialize_53 (Extent);
end Initialize;
------------------
-- Initialize_1 --
------------------
procedure Initialize_1 (Extent : AMF.Internals.AMF_Extent) is
Aux : AMF.Internals.CMOF_Element;
begin
Aux := AMF.Internals.Tables.CMOF_Constructors.Create_CMOF_Class;
AMF.Internals.Extents.Internal_Append (Extent, Aux);
end Initialize_1;
------------------
-- Initialize_2 --
------------------
procedure Initialize_2 (Extent : AMF.Internals.AMF_Extent) is
Aux : AMF.Internals.CMOF_Element;
begin
Aux := AMF.Internals.Tables.CMOF_Constructors.Create_CMOF_Class;
AMF.Internals.Extents.Internal_Append (Extent, Aux);
end Initialize_2;
------------------
-- Initialize_3 --
------------------
procedure Initialize_3 (Extent : AMF.Internals.AMF_Extent) is
Aux : AMF.Internals.CMOF_Element;
begin
Aux := AMF.Internals.Tables.CMOF_Constructors.Create_CMOF_Class;
AMF.Internals.Extents.Internal_Append (Extent, Aux);
end Initialize_3;
------------------
-- Initialize_4 --
------------------
procedure Initialize_4 (Extent : AMF.Internals.AMF_Extent) is
Aux : AMF.Internals.CMOF_Element;
begin
Aux := AMF.Internals.Tables.CMOF_Constructors.Create_CMOF_Class;
AMF.Internals.Extents.Internal_Append (Extent, Aux);
end Initialize_4;
------------------
-- Initialize_5 --
------------------
procedure Initialize_5 (Extent : AMF.Internals.AMF_Extent) is
Aux : AMF.Internals.CMOF_Element;
begin
Aux := AMF.Internals.Tables.CMOF_Constructors.Create_CMOF_Class;
AMF.Internals.Extents.Internal_Append (Extent, Aux);
end Initialize_5;
------------------
-- Initialize_6 --
------------------
procedure Initialize_6 (Extent : AMF.Internals.AMF_Extent) is
Aux : AMF.Internals.CMOF_Element;
begin
Aux := AMF.Internals.Tables.CMOF_Constructors.Create_CMOF_Property;
AMF.Internals.Extents.Internal_Append (Extent, Aux);
end Initialize_6;
------------------
-- Initialize_7 --
------------------
procedure Initialize_7 (Extent : AMF.Internals.AMF_Extent) is
Aux : AMF.Internals.CMOF_Element;
begin
Aux := AMF.Internals.Tables.CMOF_Constructors.Create_CMOF_Property;
AMF.Internals.Extents.Internal_Append (Extent, Aux);
end Initialize_7;
------------------
-- Initialize_8 --
------------------
procedure Initialize_8 (Extent : AMF.Internals.AMF_Extent) is
Aux : AMF.Internals.CMOF_Element;
begin
Aux := AMF.Internals.Tables.CMOF_Constructors.Create_CMOF_Property;
AMF.Internals.Extents.Internal_Append (Extent, Aux);
end Initialize_8;
------------------
-- Initialize_9 --
------------------
procedure Initialize_9 (Extent : AMF.Internals.AMF_Extent) is
Aux : AMF.Internals.CMOF_Element;
begin
Aux := AMF.Internals.Tables.CMOF_Constructors.Create_CMOF_Property;
AMF.Internals.Extents.Internal_Append (Extent, Aux);
end Initialize_9;
-------------------
-- Initialize_10 --
-------------------
procedure Initialize_10 (Extent : AMF.Internals.AMF_Extent) is
Aux : AMF.Internals.CMOF_Element;
begin
Aux := AMF.Internals.Tables.CMOF_Constructors.Create_CMOF_Property;
AMF.Internals.Extents.Internal_Append (Extent, Aux);
end Initialize_10;
-------------------
-- Initialize_11 --
-------------------
procedure Initialize_11 (Extent : AMF.Internals.AMF_Extent) is
Aux : AMF.Internals.CMOF_Element;
begin
Aux := AMF.Internals.Tables.CMOF_Constructors.Create_CMOF_Property;
AMF.Internals.Extents.Internal_Append (Extent, Aux);
end Initialize_11;
-------------------
-- Initialize_12 --
-------------------
procedure Initialize_12 (Extent : AMF.Internals.AMF_Extent) is
Aux : AMF.Internals.CMOF_Element;
begin
Aux := AMF.Internals.Tables.CMOF_Constructors.Create_CMOF_Property;
AMF.Internals.Extents.Internal_Append (Extent, Aux);
end Initialize_12;
-------------------
-- Initialize_13 --
-------------------
procedure Initialize_13 (Extent : AMF.Internals.AMF_Extent) is
Aux : AMF.Internals.CMOF_Element;
begin
Aux := AMF.Internals.Tables.CMOF_Constructors.Create_CMOF_Property;
AMF.Internals.Extents.Internal_Append (Extent, Aux);
end Initialize_13;
-------------------
-- Initialize_14 --
-------------------
procedure Initialize_14 (Extent : AMF.Internals.AMF_Extent) is
Aux : AMF.Internals.CMOF_Element;
begin
Aux := AMF.Internals.Tables.CMOF_Constructors.Create_CMOF_Property;
AMF.Internals.Extents.Internal_Append (Extent, Aux);
end Initialize_14;
-------------------
-- Initialize_15 --
-------------------
procedure Initialize_15 (Extent : AMF.Internals.AMF_Extent) is
Aux : AMF.Internals.CMOF_Element;
begin
Aux := AMF.Internals.Tables.CMOF_Constructors.Create_CMOF_Property;
AMF.Internals.Extents.Internal_Append (Extent, Aux);
end Initialize_15;
-------------------
-- Initialize_16 --
-------------------
procedure Initialize_16 (Extent : AMF.Internals.AMF_Extent) is
Aux : AMF.Internals.CMOF_Element;
begin
Aux := AMF.Internals.Tables.CMOF_Constructors.Create_CMOF_Property;
AMF.Internals.Extents.Internal_Append (Extent, Aux);
end Initialize_16;
-------------------
-- Initialize_17 --
-------------------
procedure Initialize_17 (Extent : AMF.Internals.AMF_Extent) is
Aux : AMF.Internals.CMOF_Element;
begin
Aux := AMF.Internals.Tables.CMOF_Constructors.Create_CMOF_Property;
AMF.Internals.Extents.Internal_Append (Extent, Aux);
end Initialize_17;
-------------------
-- Initialize_18 --
-------------------
procedure Initialize_18 (Extent : AMF.Internals.AMF_Extent) is
Aux : AMF.Internals.CMOF_Element;
begin
Aux := AMF.Internals.Tables.CMOF_Constructors.Create_CMOF_Association;
AMF.Internals.Extents.Internal_Append (Extent, Aux);
end Initialize_18;
-------------------
-- Initialize_19 --
-------------------
procedure Initialize_19 (Extent : AMF.Internals.AMF_Extent) is
Aux : AMF.Internals.CMOF_Element;
begin
Aux := AMF.Internals.Tables.CMOF_Constructors.Create_CMOF_Association;
AMF.Internals.Extents.Internal_Append (Extent, Aux);
end Initialize_19;
-------------------
-- Initialize_20 --
-------------------
procedure Initialize_20 (Extent : AMF.Internals.AMF_Extent) is
Aux : AMF.Internals.CMOF_Element;
begin
Aux := AMF.Internals.Tables.CMOF_Constructors.Create_CMOF_Association;
AMF.Internals.Extents.Internal_Append (Extent, Aux);
end Initialize_20;
-------------------
-- Initialize_21 --
-------------------
procedure Initialize_21 (Extent : AMF.Internals.AMF_Extent) is
Aux : AMF.Internals.CMOF_Element;
begin
Aux := AMF.Internals.Tables.CMOF_Constructors.Create_CMOF_Association;
AMF.Internals.Extents.Internal_Append (Extent, Aux);
end Initialize_21;
-------------------
-- Initialize_22 --
-------------------
procedure Initialize_22 (Extent : AMF.Internals.AMF_Extent) is
Aux : AMF.Internals.CMOF_Element;
begin
Aux := AMF.Internals.Tables.CMOF_Constructors.Create_CMOF_Association;
AMF.Internals.Extents.Internal_Append (Extent, Aux);
end Initialize_22;
-------------------
-- Initialize_23 --
-------------------
procedure Initialize_23 (Extent : AMF.Internals.AMF_Extent) is
Aux : AMF.Internals.CMOF_Element;
begin
Aux := AMF.Internals.Tables.CMOF_Constructors.Create_CMOF_Association;
AMF.Internals.Extents.Internal_Append (Extent, Aux);
end Initialize_23;
-------------------
-- Initialize_24 --
-------------------
procedure Initialize_24 (Extent : AMF.Internals.AMF_Extent) is
Aux : AMF.Internals.CMOF_Element;
begin
Aux := AMF.Internals.Tables.CMOF_Constructors.Create_CMOF_Package;
AMF.Internals.Extents.Internal_Append (Extent, Aux);
end Initialize_24;
-------------------
-- Initialize_25 --
-------------------
procedure Initialize_25 (Extent : AMF.Internals.AMF_Extent) is
Aux : AMF.Internals.CMOF_Element;
begin
Aux := AMF.Internals.Tables.CMOF_Constructors.Create_CMOF_Comment;
AMF.Internals.Extents.Internal_Append (Extent, Aux);
end Initialize_25;
-------------------
-- Initialize_26 --
-------------------
procedure Initialize_26 (Extent : AMF.Internals.AMF_Extent) is
Aux : AMF.Internals.CMOF_Element;
begin
Aux := AMF.Internals.Tables.CMOF_Constructors.Create_CMOF_Package_Import;
AMF.Internals.Extents.Internal_Append (Extent, Aux);
end Initialize_26;
-------------------
-- Initialize_27 --
-------------------
procedure Initialize_27 (Extent : AMF.Internals.AMF_Extent) is
Aux : AMF.Internals.CMOF_Element;
begin
Aux := AMF.Internals.Tables.CMOF_Constructors.Create_CMOF_Package_Import;
AMF.Internals.Extents.Internal_Append (Extent, Aux);
end Initialize_27;
-------------------
-- Initialize_28 --
-------------------
procedure Initialize_28 (Extent : AMF.Internals.AMF_Extent) is
Aux : AMF.Internals.CMOF_Element;
begin
Aux := AMF.Internals.Tables.CMOF_Constructors.Create_CMOF_Comment;
AMF.Internals.Extents.Internal_Append (Extent, Aux);
end Initialize_28;
-------------------
-- Initialize_29 --
-------------------
procedure Initialize_29 (Extent : AMF.Internals.AMF_Extent) is
Aux : AMF.Internals.CMOF_Element;
begin
Aux := AMF.Internals.Tables.CMOF_Constructors.Create_CMOF_Comment;
AMF.Internals.Extents.Internal_Append (Extent, Aux);
end Initialize_29;
-------------------
-- Initialize_30 --
-------------------
procedure Initialize_30 (Extent : AMF.Internals.AMF_Extent) is
Aux : AMF.Internals.CMOF_Element;
begin
Aux := AMF.Internals.Tables.CMOF_Constructors.Create_CMOF_Comment;
AMF.Internals.Extents.Internal_Append (Extent, Aux);
end Initialize_30;
-------------------
-- Initialize_31 --
-------------------
procedure Initialize_31 (Extent : AMF.Internals.AMF_Extent) is
Aux : AMF.Internals.CMOF_Element;
begin
Aux := AMF.Internals.Tables.CMOF_Constructors.Create_CMOF_Comment;
AMF.Internals.Extents.Internal_Append (Extent, Aux);
end Initialize_31;
-------------------
-- Initialize_32 --
-------------------
procedure Initialize_32 (Extent : AMF.Internals.AMF_Extent) is
Aux : AMF.Internals.CMOF_Element;
begin
Aux := AMF.Internals.Tables.CMOF_Constructors.Create_CMOF_Comment;
AMF.Internals.Extents.Internal_Append (Extent, Aux);
end Initialize_32;
-------------------
-- Initialize_33 --
-------------------
procedure Initialize_33 (Extent : AMF.Internals.AMF_Extent) is
Aux : AMF.Internals.CMOF_Element;
begin
Aux := AMF.Internals.Tables.CMOF_Constructors.Create_CMOF_Comment;
AMF.Internals.Extents.Internal_Append (Extent, Aux);
end Initialize_33;
-------------------
-- Initialize_34 --
-------------------
procedure Initialize_34 (Extent : AMF.Internals.AMF_Extent) is
Aux : AMF.Internals.CMOF_Element;
begin
Aux := AMF.Internals.Tables.CMOF_Constructors.Create_CMOF_Comment;
AMF.Internals.Extents.Internal_Append (Extent, Aux);
end Initialize_34;
-------------------
-- Initialize_35 --
-------------------
procedure Initialize_35 (Extent : AMF.Internals.AMF_Extent) is
Aux : AMF.Internals.CMOF_Element;
begin
Aux := AMF.Internals.Tables.CMOF_Constructors.Create_CMOF_Comment;
AMF.Internals.Extents.Internal_Append (Extent, Aux);
end Initialize_35;
-------------------
-- Initialize_36 --
-------------------
procedure Initialize_36 (Extent : AMF.Internals.AMF_Extent) is
Aux : AMF.Internals.CMOF_Element;
begin
Aux := AMF.Internals.Tables.CMOF_Constructors.Create_CMOF_Comment;
AMF.Internals.Extents.Internal_Append (Extent, Aux);
end Initialize_36;
-------------------
-- Initialize_37 --
-------------------
procedure Initialize_37 (Extent : AMF.Internals.AMF_Extent) is
Aux : AMF.Internals.CMOF_Element;
begin
Aux := AMF.Internals.Tables.CMOF_Constructors.Create_CMOF_Comment;
AMF.Internals.Extents.Internal_Append (Extent, Aux);
end Initialize_37;
-------------------
-- Initialize_38 --
-------------------
procedure Initialize_38 (Extent : AMF.Internals.AMF_Extent) is
Aux : AMF.Internals.CMOF_Element;
begin
Aux := AMF.Internals.Tables.CMOF_Constructors.Create_CMOF_Comment;
AMF.Internals.Extents.Internal_Append (Extent, Aux);
end Initialize_38;
-------------------
-- Initialize_39 --
-------------------
procedure Initialize_39 (Extent : AMF.Internals.AMF_Extent) is
Aux : AMF.Internals.CMOF_Element;
begin
Aux := AMF.Internals.Tables.CMOF_Constructors.Create_CMOF_Comment;
AMF.Internals.Extents.Internal_Append (Extent, Aux);
end Initialize_39;
-------------------
-- Initialize_40 --
-------------------
procedure Initialize_40 (Extent : AMF.Internals.AMF_Extent) is
Aux : AMF.Internals.CMOF_Element;
begin
Aux := AMF.Internals.Tables.CMOF_Constructors.Create_CMOF_Comment;
AMF.Internals.Extents.Internal_Append (Extent, Aux);
end Initialize_40;
-------------------
-- Initialize_41 --
-------------------
procedure Initialize_41 (Extent : AMF.Internals.AMF_Extent) is
Aux : AMF.Internals.CMOF_Element;
begin
Aux := AMF.Internals.Tables.CMOF_Constructors.Create_CMOF_Comment;
AMF.Internals.Extents.Internal_Append (Extent, Aux);
end Initialize_41;
-------------------
-- Initialize_42 --
-------------------
procedure Initialize_42 (Extent : AMF.Internals.AMF_Extent) is
Aux : AMF.Internals.CMOF_Element;
begin
Aux := AMF.Internals.Tables.CMOF_Constructors.Create_CMOF_Comment;
AMF.Internals.Extents.Internal_Append (Extent, Aux);
end Initialize_42;
-------------------
-- Initialize_43 --
-------------------
procedure Initialize_43 (Extent : AMF.Internals.AMF_Extent) is
Aux : AMF.Internals.CMOF_Element;
begin
Aux := AMF.Internals.Tables.CMOF_Constructors.Create_CMOF_Comment;
AMF.Internals.Extents.Internal_Append (Extent, Aux);
end Initialize_43;
-------------------
-- Initialize_44 --
-------------------
procedure Initialize_44 (Extent : AMF.Internals.AMF_Extent) is
Aux : AMF.Internals.CMOF_Element;
begin
Aux := AMF.Internals.Tables.CMOF_Constructors.Create_CMOF_Comment;
AMF.Internals.Extents.Internal_Append (Extent, Aux);
end Initialize_44;
-------------------
-- Initialize_45 --
-------------------
procedure Initialize_45 (Extent : AMF.Internals.AMF_Extent) is
Aux : AMF.Internals.CMOF_Element;
begin
Aux := AMF.Internals.Tables.CMOF_Constructors.Create_CMOF_Property;
AMF.Internals.Extents.Internal_Append (Extent, Aux);
end Initialize_45;
-------------------
-- Initialize_46 --
-------------------
procedure Initialize_46 (Extent : AMF.Internals.AMF_Extent) is
Aux : AMF.Internals.CMOF_Element;
begin
Aux := AMF.Internals.Tables.CMOF_Constructors.Create_CMOF_Comment;
AMF.Internals.Extents.Internal_Append (Extent, Aux);
end Initialize_46;
-------------------
-- Initialize_47 --
-------------------
procedure Initialize_47 (Extent : AMF.Internals.AMF_Extent) is
Aux : AMF.Internals.CMOF_Element;
begin
Aux := AMF.Internals.Tables.CMOF_Constructors.Create_CMOF_Property;
AMF.Internals.Extents.Internal_Append (Extent, Aux);
end Initialize_47;
-------------------
-- Initialize_48 --
-------------------
procedure Initialize_48 (Extent : AMF.Internals.AMF_Extent) is
Aux : AMF.Internals.CMOF_Element;
begin
Aux := AMF.Internals.Tables.CMOF_Constructors.Create_CMOF_Comment;
AMF.Internals.Extents.Internal_Append (Extent, Aux);
end Initialize_48;
-------------------
-- Initialize_49 --
-------------------
procedure Initialize_49 (Extent : AMF.Internals.AMF_Extent) is
Aux : AMF.Internals.CMOF_Element;
begin
Aux := AMF.Internals.Tables.CMOF_Constructors.Create_CMOF_Property;
AMF.Internals.Extents.Internal_Append (Extent, Aux);
end Initialize_49;
-------------------
-- Initialize_50 --
-------------------
procedure Initialize_50 (Extent : AMF.Internals.AMF_Extent) is
Aux : AMF.Internals.CMOF_Element;
begin
Aux := AMF.Internals.Tables.CMOF_Constructors.Create_CMOF_Property;
AMF.Internals.Extents.Internal_Append (Extent, Aux);
end Initialize_50;
-------------------
-- Initialize_51 --
-------------------
procedure Initialize_51 (Extent : AMF.Internals.AMF_Extent) is
Aux : AMF.Internals.CMOF_Element;
begin
Aux := AMF.Internals.Tables.CMOF_Constructors.Create_CMOF_Property;
AMF.Internals.Extents.Internal_Append (Extent, Aux);
end Initialize_51;
-------------------
-- Initialize_52 --
-------------------
procedure Initialize_52 (Extent : AMF.Internals.AMF_Extent) is
Aux : AMF.Internals.CMOF_Element;
begin
Aux := AMF.Internals.Tables.CMOF_Constructors.Create_CMOF_Tag;
AMF.Internals.Extents.Internal_Append (Extent, Aux);
end Initialize_52;
-------------------
-- Initialize_53 --
-------------------
procedure Initialize_53 (Extent : AMF.Internals.AMF_Extent) is
Aux : AMF.Internals.CMOF_Element;
begin
Aux := AMF.Internals.Tables.CMOF_Constructors.Create_CMOF_Tag;
AMF.Internals.Extents.Internal_Append (Extent, Aux);
end Initialize_53;
end AMF.Internals.Tables.DI_Metamodel.Objects;
|
AdaCore/libadalang | Ada | 1,017 | adb | with Ada.Text_IO; use Ada.Text_IO;
with Langkit_Support.Slocs; use Langkit_Support.Slocs;
with Langkit_Support.Text; use Langkit_Support.Text;
with Libadalang.Analysis; use Libadalang.Analysis;
with Libadalang.Common; use Libadalang.Common;
with Libadalang.Iterators; use Libadalang.Iterators;
procedure Main is
Ctx : constant Analysis_Context := Create_Context;
Unit : constant Analysis_Unit := Get_From_File (Ctx, "foo.adb");
N : constant Ada_Node := Find_First
(Unit.Root, Kind_Is (Ada_Identifier));
begin
declare
Id : constant Single_Tok_Node := N.As_Single_Tok_Node;
Tok : constant Token_Reference := Id.Token_Start;
Tok_Data : constant Token_Data_Type := Data (Tok);
begin
Put_Line ("Token data for the ""foo"" identifier:");
Put_Line ("Kind: " & Token_Kind_Name (Kind (Tok_Data)));
Put_Line ("Text: " & Image (Text (Tok)));
Put_Line ("Sloc range: " & Image (Sloc_Range (Tok_Data)));
end;
Put_Line ("Done.");
end Main;
|
stcarrez/ada-util | Ada | 16,705 | adb | -----------------------------------------------------------------------
-- util-processes-os -- System specific and low level operations
-- Copyright (C) 2011, 2012, 2017, 2018, 2019, 2020, 2021, 2022, 2023 Stephane Carrez
-- Written by Stephane Carrez ([email protected])
--
-- Licensed under the Apache License, Version 2.0 (the "License");
-- you may not use this file except in compliance with the License.
-- You may obtain a copy of the License at
--
-- http://www.apache.org/licenses/LICENSE-2.0
--
-- Unless required by applicable law or agreed to in writing, software
-- distributed under the License is distributed on an "AS IS" BASIS,
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-- See the License for the specific language governing permissions and
-- limitations under the License.
-----------------------------------------------------------------------
with Ada.Directories;
with Ada.Unchecked_Deallocation;
with Util.Strings;
package body Util.Processes.Os is
use Util.Systems.Os;
use type Interfaces.C.size_t;
use type Util.Systems.Types.File_Type;
use type Ada.Directories.File_Kind;
type Pipe_Type is array (0 .. 1) of File_Type;
procedure Close (Pipes : in out Pipe_Type);
procedure Free_Array (Argv : in out Util.Systems.Os.Ptr_Ptr_Array);
procedure Allocate (Into : in out Util.Systems.Os.Ptr_Ptr_Array;
Count : in Interfaces.C.size_t);
-- ------------------------------
-- Create the output stream to read/write on the process input/output.
-- Setup the file to be closed on exec.
-- ------------------------------
function Create_Stream (File : in File_Type)
return Util.Streams.Raw.Raw_Stream_Access is
Stream : constant Util.Streams.Raw.Raw_Stream_Access := new Util.Streams.Raw.Raw_Stream;
Status : constant Integer := Sys_Fcntl (File, F_SETFL, FD_CLOEXEC);
pragma Unreferenced (Status);
begin
Stream.Initialize (File);
return Stream;
end Create_Stream;
-- ------------------------------
-- Wait for the process to exit.
-- ------------------------------
overriding
procedure Wait (Sys : in out System_Process;
Proc : in out Process'Class;
Timeout : in Duration) is
pragma Unreferenced (Sys, Timeout);
use type Util.Streams.Output_Stream_Access;
Result : Integer;
Wpid : Integer;
begin
-- Close the input stream pipe if there is one.
if Proc.Input /= null then
Util.Streams.Raw.Raw_Stream'Class (Proc.Input.all).Close;
end if;
Wpid := Sys_Waitpid (Integer (Proc.Pid), Result'Address, 0);
if Wpid = Integer (Proc.Pid) then
Proc.Exit_Value := Result / 256;
if Result mod 256 /= 0 then
Proc.Exit_Value := (Result mod 256) * 1000;
end if;
end if;
end Wait;
-- ------------------------------
-- 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.
-- ------------------------------
overriding
procedure Stop (Sys : in out System_Process;
Proc : in out Process'Class;
Signal : in Positive := 15) is
pragma Unreferenced (Sys);
Result : Integer;
pragma Unreferenced (Result);
begin
Result := Sys_Kill (Integer (Proc.Pid), Integer (Signal));
end Stop;
-- ------------------------------
-- Close both ends of the pipe (used to cleanup in case or error).
-- ------------------------------
procedure Close (Pipes : in out Pipe_Type) is
Result : Integer;
pragma Unreferenced (Result);
begin
if Pipes (0) /= NO_FILE then
Result := Sys_Close (Pipes (0));
Pipes (0) := NO_FILE;
end if;
if Pipes (1) /= NO_FILE then
Result := Sys_Close (Pipes (1));
Pipes (1) := NO_FILE;
end if;
end Close;
procedure Prepare_Working_Directory (Sys : in out System_Process;
Proc : in out Process'Class) is
Dir : constant String := Ada.Strings.Unbounded.To_String (Proc.Dir);
begin
Interfaces.C.Strings.Free (Sys.Dir);
if Dir'Length > 0 then
if not Ada.Directories.Exists (Dir)
or else Ada.Directories.Kind (Dir) /= Ada.Directories.Directory
then
raise Ada.Directories.Name_Error with "Invalid directory: " & Dir;
end if;
Sys.Dir := Interfaces.C.Strings.New_String (Dir);
end if;
end Prepare_Working_Directory;
-- ------------------------------
-- Spawn a new process.
-- ------------------------------
overriding
procedure Spawn (Sys : in out System_Process;
Proc : in out Process'Class;
Mode : in Pipe_Mode := NONE) is
use Interfaces.C.Strings;
use type Interfaces.C.int;
procedure Cleanup;
-- Suppress all checks to make sure the child process will not raise any exception.
pragma Suppress (All_Checks);
Result : Integer;
Stdin_Pipes : aliased Pipe_Type := (others => NO_FILE);
Stdout_Pipes : aliased Pipe_Type := (others => NO_FILE);
Stderr_Pipes : aliased Pipe_Type := (others => NO_FILE);
procedure Cleanup is
begin
Close (Stdin_Pipes);
Close (Stdout_Pipes);
Close (Stderr_Pipes);
end Cleanup;
begin
Sys.Prepare_Working_Directory (Proc);
-- Since checks are disabled, verify by hand that the argv table is correct.
if Sys.Argv = null or else Sys.Argc < 1 or else Sys.Argv (0) = Null_Ptr then
raise Program_Error with "Invalid process argument list";
end if;
-- Setup the pipes.
if Mode in WRITE | READ_WRITE | READ_WRITE_ALL | READ_WRITE_ALL_SEPARATE then
if Sys_Pipe (Stdin_Pipes'Address) /= 0 then
Cleanup;
raise Process_Error with "Cannot create stdin pipe";
end if;
end if;
if Mode in READ | READ_WRITE | READ_ALL | READ_WRITE_ALL | READ_WRITE_ALL_SEPARATE then
if Sys_Pipe (Stdout_Pipes'Address) /= 0 then
Cleanup;
raise Process_Error with "Cannot create stdout pipe";
end if;
end if;
if Mode in READ_ERROR | READ_WRITE_ALL_SEPARATE then
if Sys_Pipe (Stderr_Pipes'Address) /= 0 then
Cleanup;
raise Process_Error with "Cannot create stderr pipe";
end if;
end if;
-- Create the new process by using vfork instead of fork. The parent process is blocked
-- until the child executes the exec or exits. The child process uses the same stack
-- as the parent.
Proc.Pid := Sys_VFork;
if Proc.Pid = 0 then
-- Do not use any Ada type while in the child process.
if Proc.To_Close /= null then
for Fd of Proc.To_Close.all loop
Result := Sys_Close (Fd);
end loop;
end if;
-- Handle stdin/stdout/stderr pipe redirections unless they are file-redirected.
if Sys.Err_File = Null_Ptr and then Stdout_Pipes (1) /= NO_FILE
and then Mode in READ_ALL | READ_WRITE_ALL
then
Result := Sys_Dup2 (Stdout_Pipes (1), STDERR_FILENO);
end if;
-- Redirect stdin to the pipe unless we use file redirection.
if Sys.In_File = Null_Ptr and then Stdin_Pipes (0) /= NO_FILE then
if Stdin_Pipes (0) /= STDIN_FILENO then
Result := Sys_Dup2 (Stdin_Pipes (0), STDIN_FILENO);
end if;
end if;
if Stdin_Pipes (0) /= NO_FILE and then Stdin_Pipes (0) /= STDIN_FILENO then
Result := Sys_Close (Stdin_Pipes (0));
end if;
if Stdin_Pipes (1) /= NO_FILE then
Result := Sys_Close (Stdin_Pipes (1));
end if;
-- Redirect stdout to the pipe unless we use file redirection.
if Sys.Out_File = Null_Ptr and then Stdout_Pipes (1) /= NO_FILE then
if Stdout_Pipes (1) /= STDOUT_FILENO then
Result := Sys_Dup2 (Stdout_Pipes (1), STDOUT_FILENO);
end if;
end if;
if Stdout_Pipes (1) /= NO_FILE and then Stdout_Pipes (1) /= STDOUT_FILENO then
Result := Sys_Close (Stdout_Pipes (1));
end if;
if Stdout_Pipes (0) /= NO_FILE then
Result := Sys_Close (Stdout_Pipes (0));
end if;
if Sys.Err_File = Null_Ptr and then Stderr_Pipes (1) /= NO_FILE then
if Stderr_Pipes (1) /= STDERR_FILENO then
Result := Sys_Dup2 (Stderr_Pipes (1), STDERR_FILENO);
Result := Sys_Close (Stderr_Pipes (1));
end if;
Result := Sys_Close (Stderr_Pipes (0));
end if;
if Sys.In_File /= Null_Ptr then
-- Redirect the process input from a file.
declare
Fd : File_Type;
begin
Fd := Sys_Open (Sys.In_File, O_RDONLY, 8#644#);
if Fd < 0 then
Sys_Exit (254);
end if;
if Fd /= STDIN_FILENO then
Result := Sys_Dup2 (Fd, STDIN_FILENO);
Result := Sys_Close (Fd);
end if;
end;
end if;
if Sys.Out_File /= Null_Ptr then
-- Redirect the process output to a file.
declare
Fd : File_Type;
begin
if Sys.Out_Append then
Fd := Sys_Open (Sys.Out_File, O_CREAT + O_WRONLY + O_APPEND, 8#644#);
else
Fd := Sys_Open (Sys.Out_File, O_CREAT + O_WRONLY + O_TRUNC, 8#644#);
end if;
if Fd < 0 then
Sys_Exit (254);
end if;
if Fd /= STDOUT_FILENO then
Result := Sys_Dup2 (Fd, STDOUT_FILENO);
Result := Sys_Close (Fd);
end if;
end;
end if;
if Sys.Err_File /= Null_Ptr then
-- Redirect the process error to a file.
declare
Fd : File_Type;
begin
if Sys.Err_Append then
Fd := Sys_Open (Sys.Err_File, O_CREAT + O_WRONLY + O_APPEND, 8#644#);
else
Fd := Sys_Open (Sys.Err_File, O_CREAT + O_WRONLY + O_TRUNC, 8#644#);
end if;
if Fd < 0 then
Sys_Exit (254);
end if;
if Fd /= STDERR_FILENO then
Result := Sys_Dup2 (Fd, STDERR_FILENO);
Result := Sys_Close (Fd);
end if;
end;
end if;
if Sys.Dir /= Null_Ptr then
Result := Sys_Chdir (Sys.Dir);
if Result < 0 then
Sys_Exit (253);
end if;
end if;
if Sys.Envp /= null then
Result := Sys_Execve (Sys.Argv (0), Sys.Argv.all, Sys.Envp.all);
else
Result := Sys_Execvp (Sys.Argv (0), Sys.Argv.all);
end if;
Sys_Exit (255);
end if;
-- Process creation failed, cleanup and raise an exception.
if Proc.Pid < 0 then
Cleanup;
raise Process_Error with "Cannot create process";
end if;
if Stdin_Pipes (1) /= NO_FILE then
Result := Sys_Close (Stdin_Pipes (0));
Proc.Input := Create_Stream (Stdin_Pipes (1)).all'Access;
end if;
if Stdout_Pipes (0) /= NO_FILE then
Result := Sys_Close (Stdout_Pipes (1));
Proc.Output := Create_Stream (Stdout_Pipes (0)).all'Access;
end if;
if Stderr_Pipes (0) /= NO_FILE then
Result := Sys_Close (Stderr_Pipes (1));
Proc.Error := Create_Stream (Stderr_Pipes (0)).all'Access;
end if;
end Spawn;
procedure Free is
new Ada.Unchecked_Deallocation (Name => Ptr_Ptr_Array, Object => Ptr_Array);
procedure Allocate (Into : in out Util.Systems.Os.Ptr_Ptr_Array;
Count : in Interfaces.C.size_t) is
begin
if Into = null then
Into := new Ptr_Array (0 .. 10);
elsif Count = Into'Last - 1 then
declare
N : constant Ptr_Ptr_Array := new Ptr_Array (0 .. Count + 32);
begin
N (0 .. Count) := Into (0 .. Count);
Free (Into);
Into := N;
end;
end if;
end Allocate;
-- ------------------------------
-- Append the argument to the process argument list.
-- ------------------------------
overriding
procedure Append_Argument (Sys : in out System_Process;
Arg : in String) is
begin
Allocate (Sys.Argv, Sys.Argc);
Sys.Argv (Sys.Argc) := Interfaces.C.Strings.New_String (Arg);
Sys.Argc := Sys.Argc + 1;
Sys.Argv (Sys.Argc) := Interfaces.C.Strings.Null_Ptr;
end Append_Argument;
-- ------------------------------
-- Clear the program arguments.
-- ------------------------------
overriding
procedure Clear_Arguments (Sys : in out System_Process) is
begin
if Sys.Argv /= null then
Free_Array (Sys.Argv);
end if;
Sys.Argc := 0;
end Clear_Arguments;
-- ------------------------------
-- Set the environment variable to be used by the process before its creation.
-- ------------------------------
overriding
procedure Set_Environment (Sys : in out System_Process;
Name : in String;
Value : in String) is
begin
if Sys.Envc > 0 then
for I in 0 .. Sys.Envc - 1 loop
declare
Env : Interfaces.C.Strings.chars_ptr := Sys.Envp (I);
V : constant String := Interfaces.C.Strings.Value (Env);
begin
if Util.Strings.Starts_With (V, Name & "=") then
Interfaces.C.Strings.Free (Env);
Sys.Envp (I) := Interfaces.C.Strings.New_String (Name & "=" & Value);
return;
end if;
end;
end loop;
end if;
Allocate (Sys.Envp, Sys.Envc);
Sys.Envp (Sys.Envc) := Interfaces.C.Strings.New_String (Name & "=" & Value);
Sys.Envc := Sys.Envc + 1;
Sys.Envp (Sys.Envc) := Interfaces.C.Strings.Null_Ptr;
end Set_Environment;
-- ------------------------------
-- Set the process input, output and error streams to redirect and use specified files.
-- ------------------------------
overriding
procedure Set_Streams (Sys : in out System_Process;
Input : in String;
Output : in String;
Error : in String;
Append_Output : in Boolean;
Append_Error : in Boolean;
To_Close : in File_Type_Array_Access) is
begin
if Input'Length > 0 then
Sys.In_File := Interfaces.C.Strings.New_String (Input);
else
Interfaces.C.Strings.Free (Sys.In_File);
end if;
if Output'Length > 0 then
Sys.Out_File := Interfaces.C.Strings.New_String (Output);
Sys.Out_Append := Append_Output;
else
Interfaces.C.Strings.Free (Sys.Out_File);
end if;
if Error'Length > 0 then
Sys.Err_File := Interfaces.C.Strings.New_String (Error);
Sys.Err_Append := Append_Error;
else
Interfaces.C.Strings.Free (Sys.Err_File);
end if;
Sys.To_Close := To_Close;
end Set_Streams;
procedure Free_Array (Argv : in out Util.Systems.Os.Ptr_Ptr_Array) is
begin
for I in Argv'Range loop
Interfaces.C.Strings.Free (Argv (I));
end loop;
Free (Argv);
end Free_Array;
-- ------------------------------
-- Deletes the storage held by the system process.
-- ------------------------------
overriding
procedure Finalize (Sys : in out System_Process) is
begin
if Sys.Argv /= null then
Free_Array (Sys.Argv);
end if;
if Sys.Envp /= null then
Free_Array (Sys.Envp);
end if;
Interfaces.C.Strings.Free (Sys.In_File);
Interfaces.C.Strings.Free (Sys.Out_File);
Interfaces.C.Strings.Free (Sys.Err_File);
Interfaces.C.Strings.Free (Sys.Dir);
end Finalize;
end Util.Processes.Os;
|
Fabien-Chouteau/GESTE | Ada | 3,899 | ads | pragma Ada_2005;
pragma Style_Checks (Off);
with Interfaces.C; use Interfaces.C;
with System;
package guiddef_h is
-- unsupported macro: IID_NULL GUID_NULL
-- unsupported macro: CLSID_NULL GUID_NULL
-- unsupported macro: FMTID_NULL GUID_NULL
-- arg-macro: procedure IsEqualFMTID (rfmtid1, rfmtidIsEqualGUID(rfmtid1,rfmtid2)
-- IsEqualGUID(rfmtid1,rfmtid2)
-- unsupported macro: REFGUID const GUID &
-- unsupported macro: REFIID const IID &
-- unsupported macro: REFCLSID const IID &
-- unsupported macro: REFFMTID const IID &
-- arg-macro: procedure IsEqualIID (riid1, riid2)
-- IsEqualGUID(riid1,riid2)
-- arg-macro: procedure IsEqualCLSID (rclsid1, rclsidIsEqualGUID(rclsid1,rclsid2)
-- IsEqualGUID(rclsid1,rclsid2)
-- arg-macro: procedure DEFINE_GUID (name, l, w1, w2EXTERN_C const GUID name
-- EXTERN_C const GUID name
-- arg-macro: procedure DEFINE_OLEGUID (name, l, w1, w2DEFINE_GUID(name,l,w1,w2,16#C0#,0,0,0,0,0,0,16#46#)
-- DEFINE_GUID(name,l,w1,w2,16#C0#,0,0,0,0,0,0,16#46#)
type u_GUID_Data4_array is array (0 .. 7) of aliased unsigned_char;
type u_GUID is record
Data1 : aliased unsigned_long; -- c:\home\ochem\install\bin\../lib/gcc/i686-pc-mingw32/4.7.3/../../../../i686-pc-mingw32/include/guiddef.h:9
Data2 : aliased unsigned_short; -- c:\home\ochem\install\bin\../lib/gcc/i686-pc-mingw32/4.7.3/../../../../i686-pc-mingw32/include/guiddef.h:10
Data3 : aliased unsigned_short; -- c:\home\ochem\install\bin\../lib/gcc/i686-pc-mingw32/4.7.3/../../../../i686-pc-mingw32/include/guiddef.h:11
Data4 : aliased u_GUID_Data4_array; -- c:\home\ochem\install\bin\../lib/gcc/i686-pc-mingw32/4.7.3/../../../../i686-pc-mingw32/include/guiddef.h:12
end record;
pragma Convention (C_Pass_By_Copy, u_GUID); -- c:\home\ochem\install\bin\../lib/gcc/i686-pc-mingw32/4.7.3/../../../../i686-pc-mingw32/include/guiddef.h:8
subtype GUID is u_GUID;
type LPGUID is access all GUID; -- c:\home\ochem\install\bin\../lib/gcc/i686-pc-mingw32/4.7.3/../../../../i686-pc-mingw32/include/guiddef.h:59
type LPCGUID is access constant GUID; -- c:\home\ochem\install\bin\../lib/gcc/i686-pc-mingw32/4.7.3/../../../../i686-pc-mingw32/include/guiddef.h:64
subtype IID is u_GUID;
type LPIID is access all IID; -- c:\home\ochem\install\bin\../lib/gcc/i686-pc-mingw32/4.7.3/../../../../i686-pc-mingw32/include/guiddef.h:71
subtype CLSID is u_GUID;
type LPCLSID is access all CLSID; -- c:\home\ochem\install\bin\../lib/gcc/i686-pc-mingw32/4.7.3/../../../../i686-pc-mingw32/include/guiddef.h:80
subtype FMTID is u_GUID;
type LPFMTID is access all FMTID; -- c:\home\ochem\install\bin\../lib/gcc/i686-pc-mingw32/4.7.3/../../../../i686-pc-mingw32/include/guiddef.h:85
function InlineIsEqualGUID (rguid1 : System.Address; rguid2 : System.Address) return int; -- c:\home\ochem\install\bin\../lib/gcc/i686-pc-mingw32/4.7.3/../../../../i686-pc-mingw32/include/guiddef.h:138
pragma Import (C, InlineIsEqualGUID, "InlineIsEqualGUID");
function IsEqualGUID (rguid1 : System.Address; rguid2 : System.Address) return int; -- c:\home\ochem\install\bin\../lib/gcc/i686-pc-mingw32/4.7.3/../../../../i686-pc-mingw32/include/guiddef.h:142
pragma Import (C, IsEqualGUID, "IsEqualGUID");
function operator_eq (guidOne : System.Address; guidOther : System.Address) return int; -- c:\home\ochem\install\bin\../lib/gcc/i686-pc-mingw32/4.7.3/../../../../i686-pc-mingw32/include/guiddef.h:159
pragma Import (CPP, operator_eq, "_Zeq");
function operator_ne (guidOne : System.Address; guidOther : System.Address) return int; -- c:\home\ochem\install\bin\../lib/gcc/i686-pc-mingw32/4.7.3/../../../../i686-pc-mingw32/include/guiddef.h:160
pragma Import (CPP, operator_ne, "_Zne");
end guiddef_h;
|
persan/AdaYaml | Ada | 271 | ads | -- part of AdaYaml, (c) 2017 Felix Krause
-- released under the terms of the MIT license, see the file "copying.txt"
with Yaml.Stream_Concept;
package Yaml.Events.Store.Stream is new Stream_Concept
(Stream_Instance, Stream_Reference, Stream_Accessor, Value, Next);
|
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.Table_Source_Field_Name_Attributes is
pragma Preelaborate;
type ODF_Table_Source_Field_Name_Attribute is limited interface
and XML.DOM.Attributes.DOM_Attribute;
type ODF_Table_Source_Field_Name_Attribute_Access is
access all ODF_Table_Source_Field_Name_Attribute'Class
with Storage_Size => 0;
end ODF.DOM.Table_Source_Field_Name_Attributes;
|
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_Anim.Value_Attributes is
------------
-- Create --
------------
overriding function Create
(Parameters : not null access Matreshka.DOM_Attributes.Attribute_L2_Parameters)
return Anim_Value_Attribute_Node is
begin
return Self : Anim_Value_Attribute_Node do
Matreshka.ODF_Anim.Constructors.Initialize
(Self'Unchecked_Access,
Parameters.Document,
Matreshka.ODF_String_Constants.Anim_Prefix);
end return;
end Create;
--------------------
-- Get_Local_Name --
--------------------
overriding function Get_Local_Name
(Self : not null access constant Anim_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.Anim_URI,
Matreshka.ODF_String_Constants.Value_Attribute,
Anim_Value_Attribute_Node'Tag);
end Matreshka.ODF_Anim.Value_Attributes;
|
msrLi/portingSources | Ada | 887 | adb | -- Copyright 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 Pck; use Pck;
procedure Foo is
Result1 : Data_Type;
GGG1 : GADataType'Class := GADataType'Class (Result1);
begin
Do_Nothing (GGG1'Address); -- BREAK
end Foo;
|
AdaCore/libadalang | Ada | 152 | ads | with G_Solver_Ifc;
generic
with package Ifc is new G_Solver_Ifc (<>);
package G_Solver is
use Ifc;
use Vars;
X : Logic_Var;
end G_Solver;
|
strenkml/EE368 | Ada | 277 | ads |
package Benchmark.Matrix.MM is
type MM_Type is new Matrix_Type with private;
function Create_MM return Benchmark_Pointer;
overriding
procedure Run(benchmark : in MM_Type);
private
type MM_Type is new Matrix_Type with null record;
end Benchmark.Matrix.MM;
|
sebsgit/textproc | Ada | 22,797 | adb | with opencl; use opencl;
with cl_objects; use cl_objects;
with PixelArray.Gpu;
with Interfaces.C;
with System;
with System.Address_To_Access_Conversions;
with ImageFilters;
with Ada.Unchecked_Deallocation;
with Ada.Characters.Latin_1;
with Ada.Text_IO;
package body GpuImageProc is
NL: constant Character := Ada.Characters.Latin_1.LF;
px_sample_proc_text: constant String :=
"uchar get_px(__global const uchar *image, int w, int h, int x, int y) {" & NL &
" return image[x + y * w];" & NL &
"}" & NL &
"void set_px(__global uchar *image, int w, int h, int x, int y, uchar px) {" & NL &
" image[x + y * w] = px;" & NL &
"}";
circle_min_max_procedure_text: constant String :=
"void circle_min_max(__global const uchar *image, int w, int h, int x, int y, int radius, uchar *min_max)" & NL &
"{" & NL &
" uchar tmp[2]; tmp[0] = 255; tmp[1] = 0;" & NL &
" for (int curr_x = x - radius; curr_x < x + radius; ++curr_x) {" & NL &
" if (curr_x < 0 || curr_x >= w) continue;" & NL &
" for (int curr_y = y - radius; curr_y < y + radius; ++curr_y) {" & NL &
" if (curr_y < 0 || curr_y >= h) continue;" & NL &
" if ( (x - curr_x) * (x - curr_x) + (y - curr_y) * (y - curr_y) < radius * radius ) {" & NL &
" const uchar px = get_px(image, w, h, curr_x, curr_y);" & NL &
" tmp[0] = (tmp[0] > px ? px : tmp[0]);" & NL &
" tmp[1] = (tmp[1] < px ? px : tmp[1]);" & NL &
" }" & NL &
" }" & NL &
" }" & NL &
" min_max[0] = tmp[0]; min_max[1] = tmp[1];" & NL &
"}" & NL;
patch_min_procedure_text: constant String :=
"uchar patch_min(__global const uchar *image, int w, int h, int x, int y, int size)" & NL &
"{" & NL &
" uchar result = get_px(image, w, h, x, y);" & NL &
" for (int yp = y - size / 2; yp <= y + size / 2 ; ++yp) {" & NL &
" if (yp < 0 || yp >= h) continue;" & NL &
" for (int xp = x - size / 2 ; xp <= x + size / 2; ++xp) {" & NL &
" if (xp < 0 || xp >= w) continue;" & NL &
" const uchar curr = get_px(image, w, h, xp, yp);" & NL &
" if (curr == 0) return 0;" & NL &
" if (curr < result) result = curr;" & NL &
" }" & NL &
" }" & NL &
" return result;" & NL &
"}" & NL;
patch_max_procedure_text: constant String :=
"uchar patch_max(__global const uchar *image, int w, int h, int x, int y, int size)" & NL &
"{" & NL &
" uchar result = get_px(image, w, h, x, y);" & NL &
" for (int yp = y - size / 2; yp <= y + size / 2 ; ++yp) {" & NL &
" if (yp < 0 || yp >= h) continue;" & NL &
" for (int xp = x - size / 2 ; xp <= x + size / 2; ++xp) {" & NL &
" if (xp < 0 || xp >= w) continue;" & NL &
" const uchar curr = get_px(image, w, h, xp, yp);" & NL &
" if (curr == 255) return 255;" & NL &
" if (curr > result) result = curr;" & NL &
" }" & NL &
" }" & NL &
" return result;" & NL &
"}" & NL;
bernsen_threshold_procedure_text: constant String :=
"__kernel void bernsen_adaptative_threshold(__global const uchar *input, __global uchar *output, int w, int h, int radius, uchar c_min)" & NL &
"{" & NL &
" uchar min_max[2];" & NL &
" const int px_x = get_global_id(0);" & NL &
" const int px_y = get_global_id(1);" & NL &
" circle_min_max(input, w, h, px_x, px_y, radius, min_max);" & NL &
" const uchar threshold = (min_max[1] - min_max[0] >= c_min) ? (min_max[0] + min_max[1]) / 2 : 0;" & NL &
" const uchar px_out = (get_px(input, w, h, px_x, px_y) > threshold) ? 255 : 0;" & NL &
" set_px(output, w, h, px_x, px_y, px_out);" & NL &
"}" & NL;
gaussian_filter_procedure_text: constant String :=
"__kernel void gaussian_filter(__global const uchar *input, __global uchar *output, int w, int h, int size, __global const float *gauss_kernel)" & NL &
"{" & NL &
" const int px_x = get_global_id(0);" & NL &
" const int px_y = get_global_id(1);" & NL &
" float px_sum = 0.0;" & NL &
" for (int x=-size; x<=size; ++x) {" & NL &
" for (int y=-size; y<=size; ++y) {" & NL &
" const int index = (x + size) + (y + size) * (2 * size + 1);" & NL &
" if ((px_x + x >= 0) && (px_x + x < w) && (px_y + y >= 0) && (px_y + y < h)) {" & NL &
" px_sum += gauss_kernel[index] * (float)(get_px(input, w, h, px_x + x, px_y + y));" & NL &
" } else {" & NL &
" px_sum += gauss_kernel[index] * (float)(get_px(input, w, h, px_x, px_y));" & NL &
" }" & NL &
" }" & NL &
" }" & NL &
" set_px(output, w, h, px_x, px_y, (px_sum > 255.0 ? 255 : (uchar)(px_sum)));" & NL &
"}" & NL;
erode_procedure_text: constant String :=
"__kernel void erode(__global const uchar *input, __global uchar *output, int w, int h, int size)" & NL &
"{" & NL &
" const int px_x = get_global_id(0);" & NL &
" const int px_y = get_global_id(1);" & NL &
" set_px(output, w, h, px_x, px_y, patch_min(input, w, h, px_x, px_y, size));" & NL &
"}" & NL;
dilate_procedure_text: constant String :=
"__kernel void dilate(__global const uchar *input, __global uchar *output, int w, int h, int size)" & NL &
"{" & NL &
" const int px_x = get_global_id(0);" & NL &
" const int px_y = get_global_id(1);" & NL &
" set_px(output, w, h, px_x, px_y, patch_max(input, w, h, px_x, px_y, size));" & NL &
"}" & NL;
combined_processing_kernel_source: constant String :=
px_sample_proc_text & NL &
patch_min_procedure_text & NL &
patch_max_procedure_text & NL &
circle_min_max_procedure_text & NL &
gaussian_filter_procedure_text & NL &
bernsen_threshold_procedure_text & NL &
erode_procedure_text & NL &
dilate_procedure_text & NL;
procedure Finalize(This: in out Processor) is
procedure Free_Queue is new Ada.Unchecked_Deallocation(Object => cl_objects.Command_Queue,
Name => cl_objects.Command_Queue_Access);
procedure Free_Program is new Ada.Unchecked_Deallocation(Object => cl_objects.Program,
Name => cl_objects.Program_Access);
procedure Free_Kernel is new Ada.Unchecked_Deallocation(Object => cl_objects.Kernel,
Name => cl_objects.Kernel_Access);
begin
if This.queue /= null then
Free_Queue(This.queue);
end if;
if This.bernsen_threshold_kernel /= null then
Free_Kernel(This.bernsen_threshold_kernel);
end if;
if This.gaussian_blur_kernel /= null then
Free_Kernel(This.gaussian_blur_kernel);
end if;
if This.erode_kernel /= null then
Free_Kernel(This.erode_kernel);
end if;
if This.dilate_kernel /= null then
Free_Kernel(This.dilate_kernel);
end if;
if This.program /= null then
Free_Program(This.program);
end if;
end Finalize;
function Create_Processor(context: in out cl_objects.Context; status: out opencl.Status) return Processor is
begin
return proc: Processor do
proc.queue := new cl_objects.Command_Queue'(context.Create_Command_Queue(status));
if status = opencl.SUCCESS then
proc.program := new cl_objects.Program'(context.Create_Program(source => combined_processing_kernel_source,
result_status => status));
if status = opencl.SUCCESS then
status := context.Build(prog => proc.program.all,
options => "-w -Werror");
if status = opencl.BUILD_PROGRAM_FAILURE then
Ada.Text_IO.Put_Line(context.Get_Build_Log(proc.program.all));
else
proc.bernsen_threshold_kernel := new cl_objects.Kernel'(proc.program.all.Create_Kernel("bernsen_adaptative_threshold", status));
if status /= opencl.SUCCESS then
return;
end if;
proc.gaussian_blur_kernel := new cl_objects.Kernel'(proc.program.all.Create_Kernel("gaussian_filter", status));
if status /= opencl.SUCCESS then
return;
end if;
proc.erode_kernel := new cl_objects.Kernel'(proc.program.Create_Kernel("erode", status));
if status /= opencl.SUCCESS then
return;
end if;
proc.dilate_kernel := new cl_objects.Kernel'(proc.program.Create_Kernel("dilate", status));
end if;
end if;
end if;
end return;
end Create_Processor;
function Get_Command_Queue(proc: in out Processor) return cl_objects.Command_Queue_Access is
begin
return proc.queue;
end Get_Command_Queue;
function Bernsen_Adaptative_Threshold(proc: in out Processor;
ctx: in out cl_objects.Context;
source: in out PixelArray.Gpu.GpuImage;
target: in out PixelArray.Gpu.GpuImage;
radius: in Positive;
c_min: in PixelArray.Pixel;
cl_code: out opencl.Status) return cl_objects.Event is
ev_data: opencl.Events(1 .. 0);
begin
return Bernsen_Adaptative_Threshold(proc => proc,
ctx => ctx,
source => source,
target => target,
radius => radius,
c_min => c_min,
events_to_wait => ev_data,
cl_code => cl_code);
end Bernsen_Adaptative_Threshold;
function Bernsen_Adaptative_Threshold(proc: in out Processor;
ctx: in out cl_objects.Context;
source: in out PixelArray.Gpu.GpuImage;
target: in out PixelArray.Gpu.GpuImage;
radius: in Positive;
c_min: in PixelArray.Pixel;
events_to_wait: in opencl.Events;
cl_code: out opencl.Status) return cl_objects.Event is
width_arg: aliased cl_int := cl_int(source.Get_Width);
height_arg: aliased cl_int := cl_int(source.Get_Height);
radius_arg: aliased cl_int := cl_int(radius);
c_min_arg: aliased cl_uchar := cl_uchar(c_min);
begin
cl_code := proc.bernsen_threshold_kernel.Set_Arg(0, opencl.Raw_Address'Size / 8, source.Get_Address);
cl_code := proc.bernsen_threshold_kernel.Set_Arg(1, opencl.Raw_Address'Size / 8, target.Get_Address);
cl_code := proc.bernsen_threshold_kernel.Set_Arg(2, 4, width_arg'Address);
cl_code := proc.bernsen_threshold_kernel.Set_Arg(3, 4, height_arg'Address);
cl_code := proc.bernsen_threshold_kernel.Set_Arg(4, 4, radius_arg'Address);
cl_code := proc.bernsen_threshold_kernel.Set_Arg(5, 1, c_min_arg'Address);
return proc.queue.Enqueue_Kernel(kern => proc.bernsen_threshold_kernel.all,
glob_ws => (1 => source.Get_Width, 2 => source.Get_Height),
loc_ws => Get_Local_Work_Size(source.Get_Width, source.Get_Height),
events_to_wait_for => events_to_wait,
code => cl_code);
end Bernsen_Adaptative_Threshold;
function Gaussian_Filter(proc: in out Processor;
ctx: in out cl_objects.Context;
source: in out PixelArray.Gpu.GpuImage;
target: in out PixelArray.Gpu.GpuImage;
size: in Positive;
sigma: in Float;
cl_code: out opencl.Status) return cl_objects.Event is
pragma Warnings(Off);
package Kernel_Arr_Address_Conv is new System.Address_To_Access_Conversions(Object => ImageFilters.Kernel);
pragma Warnings(On);
width_arg: aliased cl_int := cl_int(source.Get_Width);
height_arg: aliased cl_int := cl_int(source.Get_Height);
size_arg: aliased cl_int := cl_int(size);
gauss_kernel: aliased ImageFilters.Kernel := ImageFilters.generateKernel(size => size,
sigma => sigma);
gauss_kernel_buffer: cl_objects.Buffer := ctx.Create_Buffer(flags => (opencl.COPY_HOST_PTR => True, others => False),
size => gauss_kernel'Length * 4,
host_ptr => Kernel_Arr_Address_Conv.To_Address(gauss_kernel'Access),
result_status => cl_code);
begin
cl_code := proc.gaussian_blur_kernel.Set_Arg(0, opencl.Raw_Address'Size / 8, source.Get_Address);
cl_code := proc.gaussian_blur_kernel.Set_Arg(1, opencl.Raw_Address'Size / 8, target.Get_Address);
cl_code := proc.gaussian_blur_kernel.Set_Arg(2, 4, width_arg'Address);
cl_code := proc.gaussian_blur_kernel.Set_Arg(3, 4, height_arg'Address);
cl_code := proc.gaussian_blur_kernel.Set_Arg(4, 4, size_arg'Address);
cl_code := proc.gaussian_blur_kernel.Set_Arg(5, opencl.Raw_Address'Size / 8, gauss_kernel_buffer.Get_Address);
return proc.queue.Enqueue_Kernel(kern => proc.gaussian_blur_kernel.all,
glob_ws => (1 => source.Get_Width, 2 => source.Get_Height),
loc_ws => Get_Local_Work_Size(source.Get_Width, source.Get_Height),
code => cl_code);
end Gaussian_Filter;
function Erode(proc: in out Processor;
ctx: in out cl_objects.Context;
source: in out PixelArray.Gpu.GpuImage;
target: in out PixelArray.Gpu.GpuImage;
size: in Positive;
events_to_wait: in opencl.Events;
cl_code: out opencl.Status) return cl_objects.Event is
width_arg: aliased cl_int := cl_int(source.Get_Width);
height_arg: aliased cl_int := cl_int(source.Get_Height);
size_arg: aliased cl_int := cl_int(size);
begin
cl_code := proc.erode_kernel.Set_Arg(0, opencl.Raw_Address'Size / 8, source.Get_Address);
cl_code := proc.erode_kernel.Set_Arg(1, opencl.Raw_Address'Size / 8, target.Get_Address);
cl_code := proc.erode_kernel.Set_Arg(2, 4, width_arg'Address);
cl_code := proc.erode_kernel.Set_Arg(3, 4, height_arg'Address);
cl_code := proc.erode_kernel.Set_Arg(4, 4, size_arg'Address);
return proc.queue.Enqueue_Kernel(kern => proc.erode_kernel.all,
glob_ws => (1 => source.Get_Width, 2 => source.Get_Height),
loc_ws => Get_Local_Work_Size(source.Get_Width, source.Get_Height),
events_to_wait_for => events_to_wait,
code => cl_code);
end Erode;
function Dilate(proc: in out Processor;
ctx: in out cl_objects.Context;
source: in out PixelArray.Gpu.GpuImage;
target: in out PixelArray.Gpu.GpuImage;
size: in Positive;
events_to_wait: in opencl.Events;
cl_code: out opencl.Status) return cl_objects.Event is
width_arg: aliased cl_int := cl_int(source.Get_Width);
height_arg: aliased cl_int := cl_int(source.Get_Height);
size_arg: aliased cl_int := cl_int(size);
begin
cl_code := proc.dilate_kernel.Set_Arg(0, opencl.Raw_Address'Size / 8, source.Get_Address);
cl_code := proc.dilate_kernel.Set_Arg(1, opencl.Raw_Address'Size / 8, target.Get_Address);
cl_code := proc.dilate_kernel.Set_Arg(2, 4, width_arg'Address);
cl_code := proc.dilate_kernel.Set_Arg(3, 4, height_arg'Address);
cl_code := proc.dilate_kernel.Set_Arg(4, 4, size_arg'Address);
return proc.queue.Enqueue_Kernel(kern => proc.dilate_kernel.all,
glob_ws => (1 => source.Get_Width, 2 => source.Get_Height),
loc_ws => Get_Local_Work_Size(source.Get_Width, source.Get_Height),
events_to_wait_for => events_to_wait,
code => cl_code);
end Dilate;
procedure Circle_Min_Max(proc: in out Processor; ctx: in out cl_objects.Context; image: in out PixelArray.Gpu.GpuImage; x, y: Natural; radius: Positive; min, max: out PixelArray.Pixel) is
cl_code: opencl.Status;
wrapped_min_max_kernel: constant String :=
"__kernel void circle_min_max_wrap(__global uchar *image, int w, int h, int x, int y, int radius, __global uchar *min_max)" & NL &
"{" & NL &
" uchar min_max_loc[2];" & NL &
" circle_min_max(image, w, h, x, y, radius, min_max_loc);" & NL &
" min_max[0] = min_max_loc[0]; min_max[1] = min_max_loc[1];" & NL &
"}" & NL;
prog: cl_objects.Program := ctx.Create_Program(source => px_sample_proc_text & circle_min_max_procedure_text & wrapped_min_max_kernel,
result_status => cl_code);
begin
min := 0;
max := 0;
if cl_code /= opencl.SUCCESS then
Ada.Text_IO.Put_Line("Processor::Circle_Min_Max error: " & cl_code'Image);
return;
end if;
cl_code := ctx.Build(prog => prog,
options => "-w -Werror");
if cl_code /= opencl.SUCCESS then
Ada.Text_IO.Put_Line("Processor::Circle_Min_Max build error: " & cl_code'Image & ", log: " & ctx.Get_Build_Log(prog));
return;
end if;
declare
kern: cl_objects.Kernel := prog.Create_Kernel(name => "circle_min_max_wrap",
result_status => cl_code);
buffer_status: opencl.Status;
type Min_Max_Buff is array (Positive range <>) of Interfaces.C.unsigned_char;
pragma Warnings(Off);
package Min_Max_Buff_Addr_Conv is new System.Address_To_Access_Conversions(Min_Max_Buff);
pragma Warnings(On);
host_buff: aliased Min_Max_Buff := (1 => 0, 2 => 0);
buff: cl_objects.Buffer := ctx.Create_Buffer(flags => (opencl.ALLOC_HOST_PTR => True, others => False),
size => 2 * 8,
host_ptr => System.Null_Address,
result_status => buffer_status);
x_p: aliased cl_int := cl_int(x);
y_p: aliased cl_int := cl_int(y);
img_w_p: aliased cl_int := cl_int(image.Get_Width);
img_h_p: aliased cl_int := cl_int(image.Get_Height);
rad_p: aliased cl_int := cl_int(radius);
begin
if cl_code /= opencl.SUCCESS then
Ada.Text_IO.Put_Line("Processor::Circle_Min_Max kernel create: " & cl_code'Image);
return;
end if;
if buffer_status /= opencl.SUCCESS then
Ada.Text_IO.Put_Line("Processor::Circle_Min_Max buffer create: " & buffer_status'Image);
return;
end if;
cl_code := kern.Set_Arg(0, opencl.Raw_Address'Size / 8, image.Get_Address);
cl_code := kern.Set_Arg(1, 4, img_w_p'Address);
cl_code := kern.Set_Arg(2, 4, img_h_p'Address);
cl_code := kern.Set_Arg(3, 4, x_p'Address);
cl_code := kern.Set_Arg(4, 4, y_p'Address);
cl_code := kern.Set_Arg(5, 4, rad_p'Address);
cl_code := kern.Set_Arg(6, opencl.Raw_Address'Size / 8, buff.Get_Address);
declare
run_ev: constant cl_objects.Event := proc.queue.Enqueue_Kernel(kern => kern,
glob_ws => (1 => 1),
loc_ws => (1 => 1),
code => cl_code);
begin
if cl_code /= opencl.SUCCESS then
Ada.Text_IO.Put_Line("Processor::Circle_Min_Max enq kernel: " & cl_code'Image);
return;
end if;
declare
downl_ev: cl_objects.Event := cl_objects.Enqueue_Read(queue => proc.queue.all,
mem_ob => buff,
offset => 0,
size => 2,
ptr => Min_Max_Buff_Addr_Conv.To_Address(host_buff'Access),
events_to_wait_for => (1 => run_ev.Get_Handle),
code => cl_code);
begin
if cl_code /= opencl.SUCCESS then
Ada.Text_IO.Put_Line("Processor::Circle_Min_Max read: " & cl_code'Image);
return;
end if;
cl_code := downl_ev.Wait;
if cl_code /= opencl.SUCCESS then
Ada.Text_IO.Put_Line("Processor::Circle_Min_Max wait for read: " & cl_code'Image);
return;
end if;
end;
end;
min := PixelArray.Pixel(host_buff(1));
max := PixelArray.Pixel(host_buff(2));
end;
end Circle_Min_Max;
end GpuImageProc;
|
reznikmm/matreshka | Ada | 246 | ads |
package Types.Discretes.Integers is
pragma Preelaborate;
type Integer_Type is limited interface and Discrete_Type;
type Integer_Type_Access is access all Integer_Type'Class
with Storage_Size => 0;
end Types.Discretes.Integers;
|
stcarrez/ada-servlet | Ada | 20,284 | adb | -----------------------------------------------------------------------
-- servlet-rest-tests - Unit tests for Servlet.Rest and Servlet.Core.Rest
-- Copyright (C) 2016, 2017, 2020, 2022 Stephane Carrez
-- Written by Stephane Carrez ([email protected])
--
-- Licensed under the Apache License, Version 2.0 (the "License");
-- you may not use this file except in compliance with the License.
-- You may obtain a copy of the License at
--
-- http://www.apache.org/licenses/LICENSE-2.0
--
-- Unless required by applicable law or agreed to in writing, software
-- distributed under the License is distributed on an "AS IS" BASIS,
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-- See the License for the specific language governing permissions and
-- limitations under the License.
-----------------------------------------------------------------------
with Ada.Strings.Unbounded;
with Util.Log;
with Util.Test_Caller;
with Util.Measures;
with Util.Http.Headers;
with Util.Http.Mimes;
with EL.Contexts.Default;
with Security.Permissions;
with Servlet.Requests.Mockup;
with Servlet.Responses.Mockup;
with Servlet.Core.Rest;
with Servlet.Rest.Definition;
with Servlet.Rest.Operation;
package body Servlet.Rest.Tests is
package Caller is new Util.Test_Caller (Test, "Rest");
procedure Benchmark (Ctx : in Servlet.Core.Servlet_Registry;
Title : in String;
Method : in String;
URI : in String);
Default_Mimes : aliased constant Mime_List :=
(1 => Util.Http.Mimes.Json'Access, 2 => Util.Http.Mimes.Xml'Access);
package Test_Permission is
new Security.Permissions.Definition ("test-permission");
package API_Simple_Get is
new Servlet.Rest.Operation (Handler => Simple_Get'Access,
URI => "/simple/:id",
Mimes => Default_Mimes'Access);
package API_Simple_List is
new Servlet.Rest.Operation (Handler => Simple_Get'Access,
URI => "/simple");
package API_Simple_Post is
new Servlet.Rest.Operation (Handler => Simple_Post'Access,
URI => "/simple",
Method => Servlet.Rest.POST);
package API_Simple_Delete is
new Servlet.Rest.Operation (Handler => Simple_Delete'Access,
URI => "/simple/:id",
Method => Servlet.Rest.DELETE);
package API_Simple_Put is
new Servlet.Rest.Operation (Handler => Simple_Put'Access,
URI => "/simple/:id",
Method => Servlet.Rest.PUT);
package API_Simple_Head is
new Servlet.Rest.Operation (Handler => Simple_Head'Access,
URI => "/simple/:id",
Method => Servlet.Rest.HEAD);
package API_Simple_Options is
new Servlet.Rest.Operation (Handler => Simple_Options'Access,
URI => "/simple/:id",
Method => Servlet.Rest.OPTIONS);
package API_Simple_Patch is
new Servlet.Rest.Operation (Handler => Simple_Patch'Access,
URI => "/simple/:id",
Method => Servlet.Rest.PATCH);
package Test_API_Definition is
new Servlet.Rest.Definition (Object_Type => Test_API,
URI => "/test");
package API_Create is
new Test_API_Definition.Definition (Handler => Create'Access,
Method => Servlet.Rest.POST,
Pattern => "",
Permission => Test_Permission.Permission)
with Unreferenced;
package API_Update is
new Test_API_Definition.Definition (Handler => Update'Access,
Method => Servlet.Rest.PUT,
Pattern => ":id",
Permission => 0)
with Unreferenced;
package API_Delete is
new Test_API_Definition.Definition (Handler => Delete'Access,
Method => Servlet.Rest.DELETE,
Pattern => ":id",
Permission => 0)
with Unreferenced;
package API_List is
new Test_API_Definition.Definition (Handler => List'Access,
Method => Servlet.Rest.GET,
Pattern => "",
Permission => 0)
with Unreferenced;
package API_Get is
new Test_API_Definition.Definition (Handler => List'Access,
Method => Servlet.Rest.GET,
Pattern => ":id",
Permission => 0)
with Unreferenced;
package API_Head is
new Test_API_Definition.Definition (Handler => Head'Access,
Method => Servlet.Rest.HEAD,
Pattern => ":id",
Permission => 0)
with Unreferenced;
package API_Options is
new Test_API_Definition.Definition (Handler => Options'Access,
Method => Servlet.Rest.OPTIONS,
Pattern => ":id",
Permission => 0)
with Unreferenced;
package API_Patch is
new Test_API_Definition.Definition (Handler => Patch'Access,
Method => Servlet.Rest.PATCH,
Pattern => ":id",
Permission => 0)
with Unreferenced;
procedure Simple_Get (Req : in out Servlet.Rest.Request'Class;
Reply : in out Servlet.Rest.Response'Class;
Stream : in out Servlet.Rest.Output_Stream'Class) is
Data : Test_API;
begin
List (Data, Req, Reply, Stream);
end Simple_Get;
procedure Simple_Put (Req : in out Servlet.Rest.Request'Class;
Reply : in out Servlet.Rest.Response'Class;
Stream : in out Servlet.Rest.Output_Stream'Class) is
Data : Test_API;
begin
Update (Data, Req, Reply, Stream);
end Simple_Put;
procedure Simple_Post (Req : in out Servlet.Rest.Request'Class;
Reply : in out Servlet.Rest.Response'Class;
Stream : in out Servlet.Rest.Output_Stream'Class) is
Data : Test_API;
begin
Create (Data, Req, Reply, Stream);
end Simple_Post;
procedure Simple_Delete (Req : in out Servlet.Rest.Request'Class;
Reply : in out Servlet.Rest.Response'Class;
Stream : in out Servlet.Rest.Output_Stream'Class) is
Data : Test_API;
begin
Delete (Data, Req, Reply, Stream);
end Simple_Delete;
procedure Simple_Head (Req : in out Servlet.Rest.Request'Class;
Reply : in out Servlet.Rest.Response'Class;
Stream : in out Servlet.Rest.Output_Stream'Class) is
Data : Test_API;
begin
Head (Data, Req, Reply, Stream);
end Simple_Head;
procedure Simple_Options (Req : in out Servlet.Rest.Request'Class;
Reply : in out Servlet.Rest.Response'Class;
Stream : in out Servlet.Rest.Output_Stream'Class) is
Data : Test_API;
begin
Options (Data, Req, Reply, Stream);
end Simple_Options;
procedure Simple_Patch (Req : in out Servlet.Rest.Request'Class;
Reply : in out Servlet.Rest.Response'Class;
Stream : in out Servlet.Rest.Output_Stream'Class) is
Data : Test_API;
begin
Patch (Data, Req, Reply, Stream);
end Simple_Patch;
procedure Create (Data : in out Test_API;
Req : in out Servlet.Rest.Request'Class;
Reply : in out Servlet.Rest.Response'Class;
Stream : in out Servlet.Rest.Output_Stream'Class) is
pragma Unreferenced (Data, Req, Stream);
begin
Reply.Set_Status (Servlet.Responses.SC_CREATED);
-- Servlet.Rest.Created (Reply, "23");
Reply.Set_Header (Name => "Location",
Value => "/test/23");
end Create;
procedure Update (Data : in out Test_API;
Req : in out Servlet.Rest.Request'Class;
Reply : in out Servlet.Rest.Response'Class;
Stream : in out Servlet.Rest.Output_Stream'Class) is
pragma Unreferenced (Data, Stream);
Id : constant String := Req.Get_Path_Parameter (1);
begin
if Id'Length > 0 then
Reply.Set_Status (Servlet.Responses.SC_OK);
else
Reply.Set_Status (Servlet.Responses.SC_NOT_FOUND);
end if;
end Update;
procedure Delete (Data : in out Test_API;
Req : in out Servlet.Rest.Request'Class;
Reply : in out Servlet.Rest.Response'Class;
Stream : in out Servlet.Rest.Output_Stream'Class) is
pragma Unreferenced (Data, Req, Stream);
begin
Reply.Set_Status (Servlet.Responses.SC_NO_CONTENT);
end Delete;
procedure Head (Data : in out Test_API;
Req : in out Servlet.Rest.Request'Class;
Reply : in out Servlet.Rest.Response'Class;
Stream : in out Servlet.Rest.Output_Stream'Class) is
pragma Unreferenced (Data, Req, Stream);
begin
Reply.Set_Status (Servlet.Responses.SC_GONE);
end Head;
procedure Patch (Data : in out Test_API;
Req : in out Servlet.Rest.Request'Class;
Reply : in out Servlet.Rest.Response'Class;
Stream : in out Servlet.Rest.Output_Stream'Class) is
pragma Unreferenced (Data, Req, Stream);
begin
Reply.Set_Status (Servlet.Responses.SC_ACCEPTED);
end Patch;
procedure List (Data : in out Test_API;
Req : in out Servlet.Rest.Request'Class;
Reply : in out Servlet.Rest.Response'Class;
Stream : in out Servlet.Rest.Output_Stream'Class) is
pragma Unreferenced (Data);
begin
if Req.Get_Path_Parameter_Count = 0 then
Stream.Start_Document;
Stream.Start_Array ("list");
for I in 1 .. 10 loop
Stream.Start_Entity ("item");
Stream.Write_Attribute ("id", I);
Stream.Write_Attribute ("name", "Item " & Natural'Image (I));
Stream.End_Entity ("item");
end loop;
Stream.End_Array ("list");
Stream.End_Document;
else
declare
Id : constant String := Req.Get_Path_Parameter (1);
begin
if Id = "100" then
Reply.Set_Status (Servlet.Responses.SC_NOT_FOUND);
elsif Id /= "44" then
Reply.Set_Status (Servlet.Responses.SC_GONE);
end if;
end;
end if;
end List;
procedure Options (Data : in out Test_API;
Req : in out Servlet.Rest.Request'Class;
Reply : in out Servlet.Rest.Response'Class;
Stream : in out Servlet.Rest.Output_Stream'Class) is
pragma Unreferenced (Data, Req, Stream);
begin
Reply.Set_Status (Servlet.Responses.SC_OK);
Reply.Set_Header (Name => "Allow",
Value => "OPTIONS, GET, POST, PUT, DELETE, PATCH");
end Options;
procedure Add_Tests (Suite : in Util.Tests.Access_Test_Suite) is
begin
Caller.Add_Test (Suite, "Test Servlet.Rest.POST API operation",
Test_Create'Access);
Caller.Add_Test (Suite, "Test Servlet.Rest.GET API operation",
Test_Get'Access);
Caller.Add_Test (Suite, "Test Servlet.Rest.PUT API operation",
Test_Update'Access);
Caller.Add_Test (Suite, "Test Servlet.Rest.DELETE API operation",
Test_Delete'Access);
Caller.Add_Test (Suite, "Test Servlet.Rest.HEAD API operation",
Test_Head'Access);
Caller.Add_Test (Suite, "Test Servlet.Rest.TRACE API operation",
Test_Invalid'Access);
Caller.Add_Test (Suite, "Test Servlet.Rest.OPTIONS API operation",
Test_Options'Access);
Caller.Add_Test (Suite, "Test Servlet.Rest.PATCH API operation",
Test_Patch'Access);
Caller.Add_Test (Suite, "Test Servlet.Rest.Get_Mime_Type",
Test_Get_Mime_Type'Access);
end Add_Tests;
procedure Benchmark (Ctx : in Servlet.Core.Servlet_Registry;
Title : in String;
Method : in String;
URI : in String) is
T : Util.Measures.Stamp;
begin
for I in 1 .. 1000 loop
declare
Request : Servlet.Requests.Mockup.Request;
Reply : Servlet.Responses.Mockup.Response;
Dispatcher : constant Servlet.Core.Request_Dispatcher
:= Ctx.Get_Request_Dispatcher (Path => URI);
begin
Request.Set_Method (Method);
Request.Set_Request_URI (URI);
Servlet.Core.Forward (Dispatcher, Request, Reply);
end;
end loop;
Util.Measures.Report (T, Title, 1000);
end Benchmark;
procedure Test_Operation (T : in out Test;
Method : in String;
URI : in String;
Status : in Natural) is
use Servlet.Core;
use Util.Tests;
Ctx : Servlet_Registry;
S1 : aliased Servlet.Core.Rest.Rest_Servlet;
EL_Ctx : EL.Contexts.Default.Default_Context;
Request : Servlet.Requests.Mockup.Request;
Reply : Servlet.Responses.Mockup.Response;
begin
Ctx.Add_Servlet ("API", S1'Unchecked_Access);
Ctx.Add_Mapping (Name => "API", Pattern => "/simple/*");
Ctx.Start;
Ctx.Dump_Routes (Util.Log.INFO_LEVEL);
Servlet.Rest.Register (Ctx, API_Simple_Get.Definition);
Servlet.Rest.Register (Ctx, API_Simple_List.Definition);
Servlet.Rest.Register (Ctx, API_Simple_Post.Definition);
Servlet.Rest.Register (Ctx, API_Simple_Put.Definition);
Servlet.Rest.Register (Ctx, API_Simple_Delete.Definition);
Servlet.Rest.Register (Ctx, API_Simple_Head.Definition);
Servlet.Rest.Register (Ctx, API_Simple_Options.Definition);
Servlet.Rest.Register (Ctx, API_Simple_Patch.Definition);
Ctx.Dump_Routes (Util.Log.INFO_LEVEL);
Test_API_Definition.Register (Registry => Ctx,
Name => "API",
ELContext => EL_Ctx);
Request.Set_Method (Method);
declare
Dispatcher : constant Request_Dispatcher
:= Ctx.Get_Request_Dispatcher (Path => URI);
Result : Ada.Strings.Unbounded.Unbounded_String;
begin
Request.Set_Request_URI (URI);
Forward (Dispatcher, Request, Reply);
-- Check the response after the API method execution.
Reply.Read_Content (Result);
Assert_Equals (T, Status, Reply.Get_Status, "Invalid status for " & Method & ":" & URI);
end;
Benchmark (Ctx, Method & " " & URI, Method, URI);
end Test_Operation;
-- ------------------------------
-- Test REST POST create operation
-- ------------------------------
procedure Test_Create (T : in out Test) is
begin
Test_Operation (T, "POST", "/test", Servlet.Responses.SC_CREATED);
Test_Operation (T, "POST", "/simple", Servlet.Responses.SC_CREATED);
end Test_Create;
-- ------------------------------
-- Test REST PUT update operation
-- ------------------------------
procedure Test_Update (T : in out Test) is
begin
Test_Operation (T, "PUT", "/test/44", Servlet.Responses.SC_OK);
Test_Operation (T, "PUT", "/simple/44", Servlet.Responses.SC_OK);
end Test_Update;
-- ------------------------------
-- Test REST GET operation
-- ------------------------------
procedure Test_Get (T : in out Test) is
begin
Test_Operation (T, "GET", "/test", Servlet.Responses.SC_OK);
Test_Operation (T, "GET", "/test/44", Servlet.Responses.SC_OK);
Test_Operation (T, "GET", "/test/100", Servlet.Responses.SC_NOT_FOUND);
Test_Operation (T, "GET", "/simple", Servlet.Responses.SC_OK);
Test_Operation (T, "GET", "/simple/44", Servlet.Responses.SC_OK);
Test_Operation (T, "GET", "/simple/100", Servlet.Responses.SC_NOT_FOUND);
end Test_Get;
-- ------------------------------
-- Test REST DELETE delete operation
-- ------------------------------
procedure Test_Delete (T : in out Test) is
begin
Test_Operation (T, "DELETE", "/test/44", Servlet.Responses.SC_NO_CONTENT);
Test_Operation (T, "DELETE", "/simple/44", Servlet.Responses.SC_NO_CONTENT);
end Test_Delete;
-- ------------------------------
-- Test REST HEAD operation
-- ------------------------------
procedure Test_Head (T : in out Test) is
begin
Test_Operation (T, "HEAD", "/test/44", Servlet.Responses.SC_GONE);
Test_Operation (T, "HEAD", "/simple/44", Servlet.Responses.SC_GONE);
end Test_Head;
-- ------------------------------
-- Test REST OPTIONS operation
-- ------------------------------
procedure Test_Options (T : in out Test) is
begin
Test_Operation (T, "OPTIONS", "/test/44", Servlet.Responses.SC_OK);
Test_Operation (T, "OPTIONS", "/simple/44", Servlet.Responses.SC_OK);
end Test_Options;
-- ------------------------------
-- Test REST PATCH operation
-- ------------------------------
procedure Test_Patch (T : in out Test) is
begin
Test_Operation (T, "PATCH", "/test/44", Servlet.Responses.SC_ACCEPTED);
Test_Operation (T, "PATCH", "/simple/44", Servlet.Responses.SC_ACCEPTED);
end Test_Patch;
-- ------------------------------
-- Test REST operation on invalid operation.
-- ------------------------------
procedure Test_Invalid (T : in out Test) is
begin
Test_Operation (T, "TRACE", "/test/44", Servlet.Responses.SC_NOT_FOUND);
Test_Operation (T, "TRACE", "/simple/44", Servlet.Responses.SC_NOT_FOUND);
end Test_Invalid;
-- ------------------------------
-- Test Get_Mime_Type and resolution to handle the Accept header.
-- ------------------------------
procedure Test_Get_Mime_Type (T : in out Test) is
use Util.Tests;
Request : Servlet.Requests.Mockup.Request;
Mime : Mime_Access;
begin
Request.Set_Header (Util.Http.Headers.Accept_Header, "application/json");
Mime := API_Simple_Get.Definition.Get_Mime_Type (Request);
T.Assert (Mime /= null, "No matching mime type");
Assert_Equals (T, Util.Http.Mimes.Json, Mime.all, "Invalid matching mime type");
Request.Set_Header (Util.Http.Headers.Accept_Header, "application/xml");
Mime := API_Simple_Get.Definition.Get_Mime_Type (Request);
T.Assert (Mime /= null, "No matching mime type");
Assert_Equals (T, Util.Http.Mimes.Xml, Mime.all, "Invalid matching mime type");
Request.Set_Header (Util.Http.Headers.Accept_Header, "application/*");
Mime := API_Simple_Get.Definition.Get_Mime_Type (Request);
T.Assert (Mime /= null, "No matching mime type");
Assert_Equals (T, Util.Http.Mimes.Json, Mime.all, "Invalid matching mime type");
end Test_Get_Mime_Type;
end Servlet.Rest.Tests;
|
DrenfongWong/tkm-rpc | Ada | 1,326 | adb | with Tkmrpc.Servers.Ees;
with Tkmrpc.Results;
with Tkmrpc.Request.Ees.Esa_Expire.Convert;
with Tkmrpc.Response.Ees.Esa_Expire.Convert;
package body Tkmrpc.Operation_Handlers.Ees.Esa_Expire is
-------------------------------------------------------------------------
procedure Handle (Req : Request.Data_Type; Res : out Response.Data_Type) is
Specific_Req : Request.Ees.Esa_Expire.Request_Type;
Specific_Res : Response.Ees.Esa_Expire.Response_Type;
begin
Specific_Res := Response.Ees.Esa_Expire.Null_Response;
Specific_Req := Request.Ees.Esa_Expire.Convert.From_Request (S => Req);
if Specific_Req.Data.Sp_Id'Valid and
Specific_Req.Data.Spi_Rem'Valid and
Specific_Req.Data.Protocol'Valid and
Specific_Req.Data.Hard'Valid
then
Servers.Ees.Esa_Expire
(Result => Specific_Res.Header.Result,
Sp_Id => Specific_Req.Data.Sp_Id,
Spi_Rem => Specific_Req.Data.Spi_Rem,
Protocol => Specific_Req.Data.Protocol,
Hard => Specific_Req.Data.Hard);
Res :=
Response.Ees.Esa_Expire.Convert.To_Response (S => Specific_Res);
else
Res.Header.Result := Results.Invalid_Parameter;
end if;
end Handle;
end Tkmrpc.Operation_Handlers.Ees.Esa_Expire;
|
faelys/natools | Ada | 1,614 | ads | ------------------------------------------------------------------------------
-- Copyright (c) 2011, Natacha Porté --
-- --
-- Permission to use, copy, modify, and distribute this software for any --
-- purpose with or without fee is hereby granted, provided that the above --
-- copyright notice and this permission notice appear in all copies. --
-- --
-- THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES --
-- WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF --
-- MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR --
-- ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES --
-- WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN --
-- ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF --
-- OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. --
------------------------------------------------------------------------------
------------------------------------------------------------------------------
-- Natools is a collection of miscellaneous small utilities gathered in one --
-- shared library. --
------------------------------------------------------------------------------
package Natools is
pragma Pure (Natools);
type Meaningless_Type is (Meaningless_Value);
end Natools;
|
alexcamposruiz/dds-requestreply | Ada | 6,929 | adb | with Ada.Command_Line;
with Ada.Numerics.Long_Elementary_Functions;
with Ada.Text_IO;
with DDS.DomainParticipant;
with DDS.DomainParticipantFactory;
with Primes.PrimeNumberReplier;
with Primes_IDL_File.PrimeNumberRequest_TypeSupport;
with RTIDDS.Config;
procedure Primes.Replier_Main is
use Ada.Numerics.Long_Elementary_Functions;
use Ada.Text_IO;
use Primes_IDL_File;
use type DDS.DomainParticipant.Ref_Access;
use type DDS.ReturnCode_T;
use type DDS.long;
Factory : constant DDS.DomainParticipantFactory.Ref_Access := DDS.DomainParticipantFactory.Get_Instance;
MAX_WAIT : constant DDS.Duration_T := DDS.To_Duration_T (20.0);
procedure Replier_Shutdown
(Participant : in out DDS.DomainParticipant.Ref_Access;
Replier : in PrimeNumberReplier.Ref_Access;
Request : in out PrimeNumberRequest_Access) is
pragma Unreferenced (Request);
begin
-- Delete_Data (Request);
Replier.Delete;
Participant.Delete_Contained_Entities;
Factory.Delete_Participant (Participant);
Factory.Finalize_Instance;
end;
procedure Send_Error_Reply (Replier : PrimeNumberReplier.Ref_Access;
Request : PrimeNumberRequest;
Request_Id : DDS.SampleIdentity_T) is
pragma Unreferenced (Request);
Reply : aliased PrimeNumberReply;
begin
Initialize (Reply);
Reply.Status := REPLY_ERROR;
Replier.Send_Reply (Reply, Request_Id);
Finalize (Reply);
end;
procedure Calculate_And_Send_Primes (Replier : PrimeNumberReplier.Ref_Access;
Request : PrimeNumberRequest;
Request_Id : DDS.SampleIdentity_T) is
M, Length : DDS.long;
N : constant DDS.long := Request.N;
Primes_Per_Reply : constant DDS.Natural := Request.Primes_Per_Reply;
Reply : aliased PrimeNumberReply;
type Prime_Type is array (0 .. N) of Integer;
Prime : Prime_Type := (0 => 0, 1 => 0, others => 1);
use DDS.Long_Seq;
begin
Length := 0;
Initialize (Reply);
Set_Maximum (Reply.Primes'Access, Primes_Per_Reply);
Reply.Status := REPLY_IN_PROGRESS;
M := DDS.long (Sqrt (Long_Float (N)));
for I in 2 .. M loop
if Prime (I) /= 0 then
for K in I * I .. N loop
Prime (K) := 0;
end loop;
Append (Reply.Primes'Access, I);
if Length + 1 = Primes_Per_Reply then
Replier.Send_Reply (Reply, Request_Id);
Set_Length (Reply.Primes'Access, 0);
end if;
end if;
end loop;
-- Calculation is done. Send remaining prime numbers
for I in M + 1 .. N loop
if Prime (I) /= 0 then
Length := Get_Length (Reply.Primes'Access);
Append (Reply.Primes'Access, I);
if Length + 1 = Primes_Per_Reply then
Replier.Send_Reply (Reply, Request_Id);
Set_Length (Reply.Primes'Access, 0);
end if;
end if;
end loop;
-- Send the last reply. Indicate that the calculation is complete and
-- send any prime number left in the sequence
Reply.Status := REPLY_COMPLETED;
Replier.Send_Reply (Reply, Request_Id);
end;
procedure Replier_Main (Domain_Id : DDS.DomainId_T) is
Participant : DDS.DomainParticipant.Ref_Access;
Replier : PrimeNumberReplier.Ref_Access;
Request_Id : Dds.SampleIdentity_T;
Request_Info : aliased DDS.SampleInfo;
Request : PrimeNumberRequest_Access := PrimeNumberRequest_TypeSupport.Create_Data;
RetCode : DDS.ReturnCode_T := DDS.RETCODE_OK;
begin
-- /* Create the participant */
Participant := Factory.Create_Participant (Domain_Id);
if Participant = null then
Put_Line (Standard_Error, "create_participant error");
return;
end if;
-- Create the replier with that participant, and a QoS profile
-- * defined in USER_QOS_PROFILES.xml
Replier := PrimeNumberReplier.Create (Participant, Service_Name , Qos_Library_Name, Qos_Profile_Name);
Request := PrimeNumberRequest_TypeSupport.Create_Data;
-- /*
-- * Receive requests and process them
-- */
Retcode := Replier.Receive_Request (Request.all, Request_Info, Timeout => MAX_WAIT);
while Retcode = DDS.RETCODE_OK loop
if Request_Info.Valid_Data then
DDS.Get_Sample_Identity (Request_Info, Request_Id);
-- This constant is defined in Primes.idl */
if Request.N <= 0 or
Request.Primes_Per_Reply <= 0 or
Request.Primes_Per_Reply > PRIME_SEQUENCE_MAX_LENGTH then
Put_Line (Standard_Error, "Cannot process request");
Send_Error_Reply (Replier, Request.all, Request_Id);
else
Put_Line ("Calculating prime numbers below " & Request.N'Img & "... ");
-- This operation could be executed in a separate thread,
-- to process requests in parallel
Calculate_And_Send_Primes (Replier => Replier,
Request => Request.all,
Request_Id => Request_Id);
Put_Line ("DONE");
end if;
end if;
Retcode := Replier.Receive_Request (Request => Request.all,
Info_Seq => Request_Info,
Timeout => MAX_WAIT);
end loop;
if Retcode = DDS.RETCODE_TIMEOUT then
Put_Line ("No request received for " & MAX_WAIT.Sec'Img &
" seconds. Shutting down replier");
else
Put_Line (Standard_Error, "Error in replier " & Retcode'Img);
end if;
Replier_Shutdown (Participant, Replier, Request);
end;
Domain_Id : DDS.DomainId_T := 0;
begin
if Ada.Command_Line.Argument_Count > 0 then
Domain_Id := DDS.DomainId_T'Value (Ada.Command_Line.Argument (1));
end if;
RTIDDS.Config.Logger.Get_Instance.Set_Verbosity (RTIDDS.Config.VERBOSITY_WARNING);
-- Uncomment this to turn on additional logging
-- RTIDDS.Config.Logger.Get_Instance.Set_Verbosity (RTIDDS.Config.VERBOSITY_ERROR);
Put_Line ("PrimeNumberRequester: Sending a request to calculate the " &
"(on domain " & Domain_Id'Img & ")");
Replier_Main (Domain_Id);
end Primes.Replier_Main;
|
shintakezou/langkit | Ada | 3,344 | ads | --
-- Copyright (C) 2014-2022, AdaCore
-- SPDX-License-Identifier: Apache-2.0
--
-- This packages provides an interface to abstract away the action of reading
-- a source file to parse. Depending on use cases, it allows to override
-- bytes-to-text decoding and preprocess sources (before actual
-- lexing/parsing).
with GNATCOLL.Refcount;
with Langkit_Support.Diagnostics; use Langkit_Support.Diagnostics;
with Langkit_Support.Text; use Langkit_Support.Text;
package Langkit_Support.File_Readers is
type Decoded_File_Contents is record
Buffer : Text_Access;
First : Positive;
Last : Natural;
end record;
-- The "Buffer (First .. Last)" slice contains the decoded file contents as
-- a sequence of codepoints. We keep track of First/Last indexes in
-- addition to Ada's Buffer'First/'Last attributes because source buffers
-- may be oversized.
type File_Reader_Interface is interface;
-- Interface to override how source files are fetched and decoded
procedure Read
(Self : File_Reader_Interface;
Filename : String;
Charset : String;
Read_BOM : Boolean;
Contents : out Decoded_File_Contents;
Diagnostics : in out Diagnostics_Vectors.Vector) is abstract;
-- Read the content of the source at Filename, decoding it using the given
-- Charset and decoding the byte order mark if Read_BOM is True.
--
-- If there is an error during this process, append an error message to
-- Diagnostics. In that case, Contents is considered uninitialized.
--
-- Otherwise, allocate a Text_Type buffer, fill it and initialize Contents
-- to refer to it.
procedure Decode_Buffer
(Buffer : String;
Charset : String;
Read_BOM : Boolean;
Contents : out Decoded_File_Contents;
Diagnostics : in out Diagnostics_Vectors.Vector);
-- Decode the bytes in Buffer according to Charset/Read_BOM into Contents.
-- The bytes decoding itself is delegated to GNATCOLL.Iconv.
--
-- If there is an error during this process, append an error message to
-- Diagnostics. In that case, Contents is considered uninitialized.
procedure Direct_Read
(Filename : String;
Charset : String;
Read_BOM : Boolean;
Contents : out Decoded_File_Contents;
Diagnostics : in out Diagnostics_Vectors.Vector);
-- Simple implementation of Read to read the source file through
-- GNATCOLL.Mmap and to decode it using GNATCOLL.Iconv.
procedure Release (Self : in out File_Reader_Interface) is abstract;
-- Actions to perform when releasing resources associated to Self
procedure Do_Release (Self : in out File_Reader_Interface'Class);
-- Helper for the instantiation below
package File_Reader_References is new GNATCOLL.Refcount.Shared_Pointers
(File_Reader_Interface'Class, Do_Release);
subtype File_Reader_Reference is File_Reader_References.Ref;
No_File_Reader_Reference : File_Reader_Reference renames
File_Reader_References.Null_Ref;
function Create_File_Reader_Reference
(File_Reader : File_Reader_Interface'Class) return File_Reader_Reference;
-- Simple wrapper around the GNATCOLL.Refcount API to create file reader
-- references.
end Langkit_Support.File_Readers;
|
reznikmm/increment | Ada | 231 | ads | -- Copyright (c) 2015-2017 Maxim Reznik <[email protected]>
--
-- SPDX-License-Identifier: MIT
-- License-Filename: LICENSE
-------------------------------------------------------------
package Gen is
pragma Pure;
end Gen;
|
reznikmm/matreshka | Ada | 3,819 | ads | ------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- Open Document Toolkit --
-- --
-- Runtime Library Component --
-- --
------------------------------------------------------------------------------
-- --
-- Copyright © 2014, Vadim Godunko <[email protected]> --
-- All rights reserved. --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions --
-- are met: --
-- --
-- * Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- --
-- * Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in the --
-- documentation and/or other materials provided with the distribution. --
-- --
-- * Neither the name of the Vadim Godunko, IE nor the names of its --
-- contributors may be used to endorse or promote products derived from --
-- this software without specific prior written permission. --
-- --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR --
-- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
-- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED --
-- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR --
-- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF --
-- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING --
-- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS --
-- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
-- --
------------------------------------------------------------------------------
-- $Revision$ $Date$
------------------------------------------------------------------------------
with XML.DOM.Attributes;
package ODF.DOM.Text_Protection_Key_Digest_Algorithm_Attributes is
pragma Preelaborate;
type ODF_Text_Protection_Key_Digest_Algorithm_Attribute is limited interface
and XML.DOM.Attributes.DOM_Attribute;
type ODF_Text_Protection_Key_Digest_Algorithm_Attribute_Access is
access all ODF_Text_Protection_Key_Digest_Algorithm_Attribute'Class
with Storage_Size => 0;
end ODF.DOM.Text_Protection_Key_Digest_Algorithm_Attributes;
|
sungyeon/drake | Ada | 18,563 | ads | pragma License (Unrestricted);
-- extended unit, not in RM
package Ada.Wide_Characters.Latin_1 is
-- Wide_Character version of Ada.Characters.Latin_1.
pragma Pure;
-- Control characters:
NUL : constant Wide_Character :=
Wide_Character'Val (0);
SOH : constant Wide_Character :=
Wide_Character'Val (1);
STX : constant Wide_Character :=
Wide_Character'Val (2);
ETX : constant Wide_Character :=
Wide_Character'Val (3);
EOT : constant Wide_Character :=
Wide_Character'Val (4);
ENQ : constant Wide_Character :=
Wide_Character'Val (5);
ACK : constant Wide_Character :=
Wide_Character'Val (6);
BEL : constant Wide_Character :=
Wide_Character'Val (7);
BS : constant Wide_Character :=
Wide_Character'Val (8);
HT : constant Wide_Character :=
Wide_Character'Val (9);
LF : constant Wide_Character :=
Wide_Character'Val (10);
VT : constant Wide_Character :=
Wide_Character'Val (11);
FF : constant Wide_Character :=
Wide_Character'Val (12);
CR : constant Wide_Character :=
Wide_Character'Val (13);
SO : constant Wide_Character :=
Wide_Character'Val (14);
SI : constant Wide_Character :=
Wide_Character'Val (15);
DLE : constant Wide_Character :=
Wide_Character'Val (16);
DC1 : constant Wide_Character :=
Wide_Character'Val (17);
DC2 : constant Wide_Character :=
Wide_Character'Val (18);
DC3 : constant Wide_Character :=
Wide_Character'Val (19);
DC4 : constant Wide_Character :=
Wide_Character'Val (20);
NAK : constant Wide_Character :=
Wide_Character'Val (21);
SYN : constant Wide_Character :=
Wide_Character'Val (22);
ETB : constant Wide_Character :=
Wide_Character'Val (23);
CAN : constant Wide_Character :=
Wide_Character'Val (24);
EM : constant Wide_Character :=
Wide_Character'Val (25);
SUB : constant Wide_Character :=
Wide_Character'Val (26);
ESC : constant Wide_Character :=
Wide_Character'Val (27);
FS : constant Wide_Character :=
Wide_Character'Val (28);
GS : constant Wide_Character :=
Wide_Character'Val (29);
RS : constant Wide_Character :=
Wide_Character'Val (30);
US : constant Wide_Character :=
Wide_Character'Val (31);
-- ISO 646 graphic characters:
Space : constant Wide_Character :=
Wide_Character'Val (32); -- ' '
Exclamation : constant Wide_Character :=
Wide_Character'Val (33); -- '!'
Quotation : constant Wide_Character :=
Wide_Character'Val (34); -- '"'
Number_Sign : constant Wide_Character :=
Wide_Character'Val (35); -- '#'
Dollar_Sign : constant Wide_Character :=
Wide_Character'Val (36); -- '$'
Percent_Sign : constant Wide_Character :=
Wide_Character'Val (37); -- '%'
Ampersand : constant Wide_Character :=
Wide_Character'Val (38); -- '&'
Apostrophe : constant Wide_Character :=
Wide_Character'Val (39); -- '''
Left_Parenthesis : constant Wide_Character :=
Wide_Character'Val (40); -- '('
Right_Parenthesis : constant Wide_Character :=
Wide_Character'Val (41); -- ')'
Asterisk : constant Wide_Character :=
Wide_Character'Val (42); -- '*'
Plus_Sign : constant Wide_Character :=
Wide_Character'Val (43); -- '+'
Comma : constant Wide_Character :=
Wide_Character'Val (44); -- ','
Hyphen : constant Wide_Character :=
Wide_Character'Val (45); -- '-'
Minus_Sign : Wide_Character
renames Hyphen;
Full_Stop : constant Wide_Character :=
Wide_Character'Val (46); -- '.'
Solidus : constant Wide_Character :=
Wide_Character'Val (47); -- '/'
-- Decimal digits '0' though '9' are at positions 48 through 57
Colon : constant Wide_Character :=
Wide_Character'Val (58); -- ':'
Semicolon : constant Wide_Character :=
Wide_Character'Val (59); -- ';'
Less_Than_Sign : constant Wide_Character :=
Wide_Character'Val (60); -- '<'
Equals_Sign : constant Wide_Character :=
Wide_Character'Val (61); -- '='
Greater_Than_Sign : constant Wide_Character :=
Wide_Character'Val (62); -- '>'
Question : constant Wide_Character :=
Wide_Character'Val (63); -- '?'
Commercial_At : constant Wide_Character :=
Wide_Character'Val (64); -- '@'
-- Letters 'A' through 'Z' are at positions 65 through 90
Left_Square_Bracket : constant Wide_Character :=
Wide_Character'Val (91); -- '['
Reverse_Solidus : constant Wide_Character :=
Wide_Character'Val (92); -- '\'
Right_Square_Bracket : constant Wide_Character :=
Wide_Character'Val (93); -- ']'
Circumflex : constant Wide_Character :=
Wide_Character'Val (94); -- '^'
Low_Line : constant Wide_Character :=
Wide_Character'Val (95); -- '_'
Grave : constant Wide_Character :=
Wide_Character'Val (96); -- '`'
LC_A : constant Wide_Character :=
Wide_Character'Val (97); -- 'a'
LC_B : constant Wide_Character :=
Wide_Character'Val (98); -- 'b'
LC_C : constant Wide_Character :=
Wide_Character'Val (99); -- 'c'
LC_D : constant Wide_Character :=
Wide_Character'Val (100); -- 'd'
LC_E : constant Wide_Character :=
Wide_Character'Val (101); -- 'e'
LC_F : constant Wide_Character :=
Wide_Character'Val (102); -- 'f'
LC_G : constant Wide_Character :=
Wide_Character'Val (103); -- 'g'
LC_H : constant Wide_Character :=
Wide_Character'Val (104); -- 'h'
LC_I : constant Wide_Character :=
Wide_Character'Val (105); -- 'i'
LC_J : constant Wide_Character :=
Wide_Character'Val (106); -- 'j'
LC_K : constant Wide_Character :=
Wide_Character'Val (107); -- 'k'
LC_L : constant Wide_Character :=
Wide_Character'Val (108); -- 'l'
LC_M : constant Wide_Character :=
Wide_Character'Val (109); -- 'm'
LC_N : constant Wide_Character :=
Wide_Character'Val (110); -- 'n'
LC_O : constant Wide_Character :=
Wide_Character'Val (111); -- 'o'
LC_P : constant Wide_Character :=
Wide_Character'Val (112); -- 'p'
LC_Q : constant Wide_Character :=
Wide_Character'Val (113); -- 'q'
LC_R : constant Wide_Character :=
Wide_Character'Val (114); -- 'r'
LC_S : constant Wide_Character :=
Wide_Character'Val (115); -- 's'
LC_T : constant Wide_Character :=
Wide_Character'Val (116); -- 't'
LC_U : constant Wide_Character :=
Wide_Character'Val (117); -- 'u'
LC_V : constant Wide_Character :=
Wide_Character'Val (118); -- 'v'
LC_W : constant Wide_Character :=
Wide_Character'Val (119); -- 'w'
LC_X : constant Wide_Character :=
Wide_Character'Val (120); -- 'x'
LC_Y : constant Wide_Character :=
Wide_Character'Val (121); -- 'y'
LC_Z : constant Wide_Character :=
Wide_Character'Val (122); -- 'z'
Left_Curly_Bracket : constant Wide_Character :=
Wide_Character'Val (123); -- '{'
Vertical_Line : constant Wide_Character :=
Wide_Character'Val (124); -- '|'
Right_Curly_Bracket : constant Wide_Character :=
Wide_Character'Val (125); -- '}'
Tilde : constant Wide_Character :=
Wide_Character'Val (126); -- '~'
DEL : constant Wide_Character :=
Wide_Character'Val (127);
-- ISO 6429 control characters:
IS4 : Wide_Character renames FS;
IS3 : Wide_Character renames GS;
IS2 : Wide_Character renames RS;
IS1 : Wide_Character renames US;
Reserved_128 : constant Wide_Character :=
Wide_Character'Val (128);
Reserved_129 : constant Wide_Character :=
Wide_Character'Val (129);
BPH : constant Wide_Character :=
Wide_Character'Val (130);
NBH : constant Wide_Character :=
Wide_Character'Val (131);
Reserved_132 : constant Wide_Character :=
Wide_Character'Val (132);
NEL : constant Wide_Character :=
Wide_Character'Val (133);
SSA : constant Wide_Character :=
Wide_Character'Val (134);
ESA : constant Wide_Character :=
Wide_Character'Val (135);
HTS : constant Wide_Character :=
Wide_Character'Val (136);
HTJ : constant Wide_Character :=
Wide_Character'Val (137);
VTS : constant Wide_Character :=
Wide_Character'Val (138);
PLD : constant Wide_Character :=
Wide_Character'Val (139);
PLU : constant Wide_Character :=
Wide_Character'Val (140);
RI : constant Wide_Character :=
Wide_Character'Val (141);
SS2 : constant Wide_Character :=
Wide_Character'Val (142);
SS3 : constant Wide_Character :=
Wide_Character'Val (143);
DCS : constant Wide_Character :=
Wide_Character'Val (144);
PU1 : constant Wide_Character :=
Wide_Character'Val (145);
PU2 : constant Wide_Character :=
Wide_Character'Val (146);
STS : constant Wide_Character :=
Wide_Character'Val (147);
CCH : constant Wide_Character :=
Wide_Character'Val (148);
MW : constant Wide_Character :=
Wide_Character'Val (149);
SPA : constant Wide_Character :=
Wide_Character'Val (150);
EPA : constant Wide_Character :=
Wide_Character'Val (151);
SOS : constant Wide_Character :=
Wide_Character'Val (152);
Reserved_153 : constant Wide_Character :=
Wide_Character'Val (153);
SCI : constant Wide_Character :=
Wide_Character'Val (154);
CSI : constant Wide_Character :=
Wide_Character'Val (155);
ST : constant Wide_Character :=
Wide_Character'Val (156);
OSC : constant Wide_Character :=
Wide_Character'Val (157);
PM : constant Wide_Character :=
Wide_Character'Val (158);
APC : constant Wide_Character :=
Wide_Character'Val (159);
-- Other graphic characters:
-- Character positions 160 (16#A0#) .. 175 (16#AF#):
No_Break_Space : constant Wide_Character :=
Wide_Character'Val (160); -- ' '
NBSP : Wide_Character
renames No_Break_Space;
Inverted_Exclamation : constant Wide_Character :=
Wide_Character'Val (161); -- '¡'
Cent_Sign : constant Wide_Character :=
Wide_Character'Val (162); -- '¢'
Pound_Sign : constant Wide_Character :=
Wide_Character'Val (163); -- '£'
Currency_Sign : constant Wide_Character :=
Wide_Character'Val (164); -- '¤'
Yen_Sign : constant Wide_Character :=
Wide_Character'Val (165); -- '¥'
Broken_Bar : constant Wide_Character :=
Wide_Character'Val (166); -- '¦'
Section_Sign : constant Wide_Character :=
Wide_Character'Val (167); -- '§'
Diaeresis : constant Wide_Character :=
Wide_Character'Val (168); -- '¨'
Copyright_Sign : constant Wide_Character :=
Wide_Character'Val (169); -- '©'
Feminine_Ordinal_Indicator : constant Wide_Character :=
Wide_Character'Val (170); -- 'ª'
Left_Angle_Quotation : constant Wide_Character :=
Wide_Character'Val (171); -- '«'
Not_Sign : constant Wide_Character :=
Wide_Character'Val (172); -- '¬'
Soft_Hyphen : constant Wide_Character :=
Wide_Character'Val (173); -- ' '
Registered_Trade_Mark_Sign : constant Wide_Character :=
Wide_Character'Val (174); -- '®'
Macron : constant Wide_Character :=
Wide_Character'Val (175); -- '¯'
-- Character positions 176 (16#B0#) .. 191 (16#BF#):
Degree_Sign : constant Wide_Character :=
Wide_Character'Val (176); -- '°'
Ring_Above : Wide_Character
renames Degree_Sign;
Plus_Minus_Sign : constant Wide_Character :=
Wide_Character'Val (177); -- '±'
Superscript_Two : constant Wide_Character :=
Wide_Character'Val (178); -- '²'
Superscript_Three : constant Wide_Character :=
Wide_Character'Val (179); -- '³'
Acute : constant Wide_Character :=
Wide_Character'Val (180); -- '´'
Micro_Sign : constant Wide_Character :=
Wide_Character'Val (181); -- 'µ'
Pilcrow_Sign : constant Wide_Character :=
Wide_Character'Val (182); -- '¶'
Paragraph_Sign : Wide_Character
renames Pilcrow_Sign;
Middle_Dot : constant Wide_Character :=
Wide_Character'Val (183); -- '·'
Cedilla : constant Wide_Character :=
Wide_Character'Val (184); -- '¸'
Superscript_One : constant Wide_Character :=
Wide_Character'Val (185); -- '¹'
Masculine_Ordinal_Indicator : constant Wide_Character :=
Wide_Character'Val (186); -- 'º'
Right_Angle_Quotation : constant Wide_Character :=
Wide_Character'Val (187); -- '»'
Fraction_One_Quarter : constant Wide_Character :=
Wide_Character'Val (188); -- '¼'
Fraction_One_Half : constant Wide_Character :=
Wide_Character'Val (189); -- '½'
Fraction_Three_Quarters : constant Wide_Character :=
Wide_Character'Val (190); -- '¾'
Inverted_Question : constant Wide_Character :=
Wide_Character'Val (191); -- '¿'
-- Character positions 192 (16#C0#) .. 207 (16#CF#):
UC_A_Grave : constant Wide_Character :=
Wide_Character'Val (192); -- 'À'
UC_A_Acute : constant Wide_Character :=
Wide_Character'Val (193); -- 'Á'
UC_A_Circumflex : constant Wide_Character :=
Wide_Character'Val (194); -- 'Â'
UC_A_Tilde : constant Wide_Character :=
Wide_Character'Val (195); -- 'Ã'
UC_A_Diaeresis : constant Wide_Character :=
Wide_Character'Val (196); -- 'Ä'
UC_A_Ring : constant Wide_Character :=
Wide_Character'Val (197); -- 'Å'
UC_AE_Diphthong : constant Wide_Character :=
Wide_Character'Val (198); -- 'Æ'
UC_C_Cedilla : constant Wide_Character :=
Wide_Character'Val (199); -- 'Ç'
UC_E_Grave : constant Wide_Character :=
Wide_Character'Val (200); -- 'È'
UC_E_Acute : constant Wide_Character :=
Wide_Character'Val (201); -- 'É'
UC_E_Circumflex : constant Wide_Character :=
Wide_Character'Val (202); -- 'Ê'
UC_E_Diaeresis : constant Wide_Character :=
Wide_Character'Val (203); -- 'Ë'
UC_I_Grave : constant Wide_Character :=
Wide_Character'Val (204); -- 'Ì'
UC_I_Acute : constant Wide_Character :=
Wide_Character'Val (205); -- 'Í'
UC_I_Circumflex : constant Wide_Character :=
Wide_Character'Val (206); -- 'Î'
UC_I_Diaeresis : constant Wide_Character :=
Wide_Character'Val (207); -- 'Ï'
-- Character positions 208 (16#D0#) .. 223 (16#DF#):
UC_Icelandic_Eth : constant Wide_Character :=
Wide_Character'Val (208); -- 'Ð'
UC_N_Tilde : constant Wide_Character :=
Wide_Character'Val (209); -- 'Ñ'
UC_O_Grave : constant Wide_Character :=
Wide_Character'Val (210); -- 'Ò'
UC_O_Acute : constant Wide_Character :=
Wide_Character'Val (211); -- 'Ó'
UC_O_Circumflex : constant Wide_Character :=
Wide_Character'Val (212); -- 'Ô'
UC_O_Tilde : constant Wide_Character :=
Wide_Character'Val (213); -- 'Õ'
UC_O_Diaeresis : constant Wide_Character :=
Wide_Character'Val (214); -- 'Ö'
Multiplication_Sign : constant Wide_Character :=
Wide_Character'Val (215); -- '×'
UC_O_Oblique_Stroke : constant Wide_Character :=
Wide_Character'Val (216); -- 'Ø'
UC_U_Grave : constant Wide_Character :=
Wide_Character'Val (217); -- 'Ù'
UC_U_Acute : constant Wide_Character :=
Wide_Character'Val (218); -- 'Ú'
UC_U_Circumflex : constant Wide_Character :=
Wide_Character'Val (219); -- 'Û'
UC_U_Diaeresis : constant Wide_Character :=
Wide_Character'Val (220); -- 'Ü'
UC_Y_Acute : constant Wide_Character :=
Wide_Character'Val (221); -- 'Ý'
UC_Icelandic_Thorn : constant Wide_Character :=
Wide_Character'Val (222); -- 'Þ'
LC_German_Sharp_S : constant Wide_Character :=
Wide_Character'Val (223); -- 'ß'
-- Character positions 224 (16#E0#) .. 239 (16#EF#):
LC_A_Grave : constant Wide_Character :=
Wide_Character'Val (224); -- 'à'
LC_A_Acute : constant Wide_Character :=
Wide_Character'Val (225); -- 'á'
LC_A_Circumflex : constant Wide_Character :=
Wide_Character'Val (226); -- 'â'
LC_A_Tilde : constant Wide_Character :=
Wide_Character'Val (227); -- 'ã'
LC_A_Diaeresis : constant Wide_Character :=
Wide_Character'Val (228); -- 'ä'
LC_A_Ring : constant Wide_Character :=
Wide_Character'Val (229); -- 'å'
LC_AE_Diphthong : constant Wide_Character :=
Wide_Character'Val (230); -- 'æ'
LC_C_Cedilla : constant Wide_Character :=
Wide_Character'Val (231); -- 'ç'
LC_E_Grave : constant Wide_Character :=
Wide_Character'Val (232); -- 'è'
LC_E_Acute : constant Wide_Character :=
Wide_Character'Val (233); -- 'é'
LC_E_Circumflex : constant Wide_Character :=
Wide_Character'Val (234); -- 'ê'
LC_E_Diaeresis : constant Wide_Character :=
Wide_Character'Val (235); -- 'ë'
LC_I_Grave : constant Wide_Character :=
Wide_Character'Val (236); -- 'ì'
LC_I_Acute : constant Wide_Character :=
Wide_Character'Val (237); -- 'í'
LC_I_Circumflex : constant Wide_Character :=
Wide_Character'Val (238); -- 'î'
LC_I_Diaeresis : constant Wide_Character :=
Wide_Character'Val (239); -- 'ï'
-- Character positions 240 (16#F0#) .. 255 (16#FF#):
LC_Icelandic_Eth : constant Wide_Character :=
Wide_Character'Val (240); -- 'ð'
LC_N_Tilde : constant Wide_Character :=
Wide_Character'Val (241); -- 'ñ'
LC_O_Grave : constant Wide_Character :=
Wide_Character'Val (242); -- 'ò'
LC_O_Acute : constant Wide_Character :=
Wide_Character'Val (243); -- 'ó'
LC_O_Circumflex : constant Wide_Character :=
Wide_Character'Val (244); -- 'ô'
LC_O_Tilde : constant Wide_Character :=
Wide_Character'Val (245); -- 'õ'
LC_O_Diaeresis : constant Wide_Character :=
Wide_Character'Val (246); -- 'ö'
Division_Sign : constant Wide_Character :=
Wide_Character'Val (247); -- '÷';
LC_O_Oblique_Stroke : constant Wide_Character :=
Wide_Character'Val (248); -- 'ø'
LC_U_Grave : constant Wide_Character :=
Wide_Character'Val (249); -- 'ù'
LC_U_Acute : constant Wide_Character :=
Wide_Character'Val (250); -- 'ú'
LC_U_Circumflex : constant Wide_Character :=
Wide_Character'Val (251); -- 'û';
LC_U_Diaeresis : constant Wide_Character :=
Wide_Character'Val (252); -- 'ü'
LC_Y_Acute : constant Wide_Character :=
Wide_Character'Val (253); -- 'ý'
LC_Icelandic_Thorn : constant Wide_Character :=
Wide_Character'Val (254); -- 'þ'
LC_Y_Diaeresis : constant Wide_Character :=
Wide_Character'Val (255); -- 'ÿ'
end Ada.Wide_Characters.Latin_1;
|
zhmu/ananas | Ada | 5,600 | adb | ------------------------------------------------------------------------------
-- --
-- GNAT RUN-TIME COMPONENTS --
-- --
-- G N A T . T A B L E --
-- --
-- B o d y --
-- --
-- Copyright (C) 1998-2022, AdaCore --
-- --
-- GNAT is free software; you can redistribute it and/or modify it under --
-- terms of the GNU General Public License as published by the Free Soft- --
-- ware Foundation; either version 3, or (at your option) any later ver- --
-- sion. GNAT is distributed in the hope that it will be useful, but WITH- --
-- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY --
-- or FITNESS FOR A PARTICULAR PURPOSE. --
-- --
-- As a special exception under Section 7 of GPL version 3, you are granted --
-- additional permissions described in the GCC Runtime Library Exception, --
-- version 3.1, as published by the Free Software Foundation. --
-- --
-- You should have received a copy of the GNU General Public License and --
-- a copy of the GCC Runtime Library Exception along with this program; --
-- see the files COPYING3 and COPYING.RUNTIME respectively. If not, see --
-- <http://www.gnu.org/licenses/>. --
-- --
-- GNAT was originally developed by the GNAT team at New York University. --
-- Extensive contributions were provided by Ada Core Technologies Inc. --
-- --
------------------------------------------------------------------------------
with System; use System;
with System.Memory; use System.Memory;
package body GNAT.Table is
--------------
-- Allocate --
--------------
procedure Allocate (Num : Integer := 1) is
begin
Tab.Allocate (The_Instance, Num);
end Allocate;
function Allocate (Num : Integer := 1) return Valid_Table_Index_Type is
Result : constant Valid_Table_Index_Type := Last + 1;
begin
Allocate (Num);
return Result;
end Allocate;
------------
-- Append --
------------
procedure Append (New_Val : Table_Component_Type) is
begin
Tab.Append (The_Instance, New_Val);
end Append;
----------------
-- Append_All --
----------------
procedure Append_All (New_Vals : Table_Type) is
begin
Tab.Append_All (The_Instance, New_Vals);
end Append_All;
--------------------
-- Decrement_Last --
--------------------
procedure Decrement_Last is
begin
Tab.Decrement_Last (The_Instance);
end Decrement_Last;
-----------
-- First --
-----------
function First return Table_Index_Type is
begin
return Tab.First;
end First;
--------------
-- For_Each --
--------------
procedure For_Each is
procedure For_Each is new Tab.For_Each (Action);
begin
For_Each (The_Instance);
end For_Each;
----------
-- Free --
----------
procedure Free is
begin
Tab.Free (The_Instance);
end Free;
--------------------
-- Increment_Last --
--------------------
procedure Increment_Last is
begin
Tab.Increment_Last (The_Instance);
end Increment_Last;
--------------
-- Is_Empty --
--------------
function Is_Empty return Boolean is
begin
return Tab.Is_Empty (The_Instance);
end Is_Empty;
----------
-- Init --
----------
procedure Init is
begin
Tab.Init (The_Instance);
end Init;
----------
-- Last --
----------
function Last return Table_Last_Type is
begin
return Tab.Last (The_Instance);
end Last;
-------------
-- Release --
-------------
procedure Release is
begin
Tab.Release (The_Instance);
end Release;
-------------
-- Restore --
-------------
procedure Restore (T : in out Saved_Table) is
begin
Init;
Tab.Move (From => T, To => The_Instance);
end Restore;
----------
-- Save --
----------
function Save return Saved_Table is
Result : Saved_Table;
begin
Tab.Move (From => The_Instance, To => Result);
return Result;
end Save;
--------------
-- Set_Item --
--------------
procedure Set_Item
(Index : Valid_Table_Index_Type;
Item : Table_Component_Type)
is
begin
Tab.Set_Item (The_Instance, Index, Item);
end Set_Item;
--------------
-- Set_Last --
--------------
procedure Set_Last (New_Val : Table_Last_Type) is
begin
Tab.Set_Last (The_Instance, New_Val);
end Set_Last;
----------------
-- Sort_Table --
----------------
procedure Sort_Table is
procedure Sort_Table is new Tab.Sort_Table (Lt);
begin
Sort_Table (The_Instance);
end Sort_Table;
end GNAT.Table;
|
io7m/coreland-openal-ada | Ada | 6,455 | adb | with OpenAL.Thin;
package body OpenAL.Listener is
--
-- Get_*
--
procedure Get_Gain (Gain : out Types.Float_t) is
Value : aliased Types.Float_t;
begin
Thin.Get_Listenerf
(Parameter => Thin.AL_GAIN,
Value => Value'Address);
Gain := Value;
end Get_Gain;
procedure Get_Orientation_Discrete
(Forward : out Types.Vector_3i_t;
Up : out Types.Vector_3i_t)
is
type Orient_Vectors_t is new Types.Vector_i_t (1 .. 6);
Vectors : Orient_Vectors_t;
begin
Thin.Get_Listeneriv
(Parameter => Thin.AL_ORIENTATION,
Values => Vectors (Vectors'First)'Address);
Forward := Types.Vector_3i_t'
(1 => Vectors (1),
2 => Vectors (2),
3 => Vectors (3));
Up := Types.Vector_3i_t'
(1 => Vectors (4),
2 => Vectors (5),
3 => Vectors (6));
end Get_Orientation_Discrete;
procedure Get_Orientation_Float
(Forward : out Types.Vector_3f_t;
Up : out Types.Vector_3f_t)
is
type Orient_Vectors_t is new Types.Vector_f_t (1 .. 6);
Vectors : Orient_Vectors_t;
begin
Thin.Get_Listenerfv
(Parameter => Thin.AL_ORIENTATION,
Values => Vectors (Vectors'First)'Address);
Forward := Types.Vector_3f_t'
(1 => Vectors (1),
2 => Vectors (2),
3 => Vectors (3));
Up := Types.Vector_3f_t'
(1 => Vectors (4),
2 => Vectors (5),
3 => Vectors (6));
end Get_Orientation_Float;
procedure Get_Position_Discrete
(X : out Types.Integer_t;
Y : out Types.Integer_t;
Z : out Types.Integer_t)
is
V : aliased Types.Vector_3i_t;
begin
Get_Position_Discrete_List (V);
X := V (1);
Y := V (2);
Z := V (3);
end Get_Position_Discrete;
procedure Get_Position_Discrete_List (Position : out Types.Vector_3i_t) is
begin
Thin.Get_Listeneriv
(Parameter => Thin.AL_POSITION,
Values => Position (Position'First)'Address);
end Get_Position_Discrete_List;
procedure Get_Position_Float
(X : out Types.Float_t;
Y : out Types.Float_t;
Z : out Types.Float_t)
is
V : aliased Types.Vector_3f_t;
begin
Get_Position_Float_List (V);
X := V (1);
Y := V (2);
Z := V (3);
end Get_Position_Float;
procedure Get_Position_Float_List (Position : out Types.Vector_3f_t) is
begin
Thin.Get_Listenerfv
(Parameter => Thin.AL_POSITION,
Values => Position (Position'First)'Address);
end Get_Position_Float_List;
procedure Get_Velocity_Discrete
(X : out Types.Integer_t;
Y : out Types.Integer_t;
Z : out Types.Integer_t)
is
V : aliased Types.Vector_3i_t;
begin
Get_Velocity_Discrete_List (V);
X := V (1);
Y := V (2);
Z := V (3);
end Get_Velocity_Discrete;
procedure Get_Velocity_Discrete_List (Velocity : out Types.Vector_3i_t) is
begin
Thin.Get_Listeneriv
(Parameter => Thin.AL_POSITION,
Values => Velocity (Velocity'First)'Address);
end Get_Velocity_Discrete_List;
procedure Get_Velocity_Float
(X : out Types.Float_t;
Y : out Types.Float_t;
Z : out Types.Float_t)
is
V : aliased Types.Vector_3f_t;
begin
Get_Velocity_Float_List (V);
X := V (1);
Y := V (2);
Z := V (3);
end Get_Velocity_Float;
procedure Get_Velocity_Float_List (Velocity : out Types.Vector_3f_t) is
begin
Thin.Get_Listenerfv
(Parameter => Thin.AL_POSITION,
Values => Velocity (Velocity'First)'Address);
end Get_Velocity_Float_List;
--
-- Set_*
--
procedure Set_Gain (Gain : in Types.Float_t) is
begin
Thin.Listenerf
(Parameter => Thin.AL_GAIN,
Value => Gain);
end Set_Gain;
procedure Set_Orientation_Discrete
(Forward : in Types.Vector_3i_t;
Up : in Types.Vector_3i_t)
is
type Orient_Vectors_t is new Types.Vector_i_t (1 .. 6);
Vectors : constant Orient_Vectors_t :=
(1 => Forward (1),
2 => Forward (2),
3 => Forward (3),
4 => Up (1),
5 => Up (2),
6 => Up (3));
begin
Thin.Listeneriv
(Parameter => Thin.AL_ORIENTATION,
Values => Vectors (Vectors'First)'Address);
end Set_Orientation_Discrete;
procedure Set_Orientation_Float
(Forward : in Types.Vector_3f_t;
Up : in Types.Vector_3f_t)
is
type Orient_Vectors_t is new Types.Vector_f_t (1 .. 6);
Vectors : constant Orient_Vectors_t :=
(1 => Forward (1),
2 => Forward (2),
3 => Forward (3),
4 => Up (1),
5 => Up (2),
6 => Up (3));
begin
Thin.Listenerfv
(Parameter => Thin.AL_ORIENTATION,
Values => Vectors (Vectors'First)'Address);
end Set_Orientation_Float;
procedure Set_Position_Discrete
(X : in Types.Integer_t;
Y : in Types.Integer_t;
Z : in Types.Integer_t) is
begin
Set_Position_Discrete_List ((X, Y, Z));
end Set_Position_Discrete;
procedure Set_Position_Discrete_List (Position : in Types.Vector_3i_t) is
begin
Thin.Listeneriv
(Parameter => Thin.AL_POSITION,
Values => Position (Position'First)'Address);
end Set_Position_Discrete_List;
procedure Set_Position_Float
(X : in Types.Float_t;
Y : in Types.Float_t;
Z : in Types.Float_t) is
begin
Set_Position_Float_List ((X, Y, Z));
end Set_Position_Float;
procedure Set_Position_Float_List (Position : in Types.Vector_3f_t) is
begin
Thin.Listenerfv
(Parameter => Thin.AL_POSITION,
Values => Position (Position'First)'Address);
end Set_Position_Float_List;
procedure Set_Velocity_Discrete
(X : in Types.Integer_t;
Y : in Types.Integer_t;
Z : in Types.Integer_t) is
begin
Set_Velocity_Discrete_List ((X, Y, Z));
end Set_Velocity_Discrete;
procedure Set_Velocity_Discrete_List (Velocity : in Types.Vector_3i_t) is
begin
Thin.Listeneriv
(Parameter => Thin.AL_POSITION,
Values => Velocity (Velocity'First)'Address);
end Set_Velocity_Discrete_List;
procedure Set_Velocity_Float
(X : in Types.Float_t;
Y : in Types.Float_t;
Z : in Types.Float_t) is
begin
Set_Velocity_Float_List ((X, Y, Z));
end Set_Velocity_Float;
procedure Set_Velocity_Float_List (Velocity : in Types.Vector_3f_t) is
begin
Thin.Listenerfv
(Parameter => Thin.AL_POSITION,
Values => Velocity (Velocity'First)'Address);
end Set_Velocity_Float_List;
end OpenAL.Listener;
|
thierr26/ada-keystore | Ada | 3,113 | ads | -----------------------------------------------------------------------
-- security-random -- Random numbers for nonce, secret keys, token generation
-- Copyright (C) 2017 Stephane Carrez
-- Written by Stephane Carrez ([email protected])
--
-- Licensed under the Apache License, Version 2.0 (the "License");
-- you may not use this file except in compliance with the License.
-- You may obtain a copy of the License at
--
-- http://www.apache.org/licenses/LICENSE-2.0
--
-- Unless required by applicable law or agreed to in writing, software
-- distributed under the License is distributed on an "AS IS" BASIS,
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-- See the License for the specific language governing permissions and
-- limitations under the License.
-----------------------------------------------------------------------
with Ada.Streams;
with Ada.Finalization;
with Interfaces;
with Util.Encoders.AES;
private with Ada.Numerics.Discrete_Random;
-- == Random Generator ==
-- The <tt>Security.Random</tt> package defines the <tt>Generator</tt> tagged type
-- which provides operations to generate random tokens intended to be used for
-- a nonce, access token, salt or other purposes. The generator is intended to be
-- used in multi-task environments as it implements the low level random generation
-- within a protected type. The generator defines a <tt>Generate</tt> operation
-- that returns either a binary random array or the base64url encoding of the
-- binary array.
package Keystore.Random is
type Generator is limited new Ada.Finalization.Limited_Controlled with private;
-- Initialize the random generator.
overriding
procedure Initialize (Gen : in out Generator);
-- Fill the array with pseudo-random numbers.
procedure Generate (Gen : in out Generator;
Into : out Ada.Streams.Stream_Element_Array);
-- Fill the secret with pseudo-random numbers.
procedure Generate (Gen : in out Generator;
Into : out Secret_Key);
procedure Generate (Gen : in out Generator;
Into : out UUID_Type);
-- Generate a random sequence of bits and convert the result
-- into a string in base64url.
function Generate (Gen : in out Generator'Class;
Bits : in Positive) return String;
function Generate (Gen : in out Generator'Class) return Interfaces.Unsigned_32;
private
package Id_Random is new Ada.Numerics.Discrete_Random (Interfaces.Unsigned_32);
-- Protected type to allow using the random generator by several tasks.
protected type Raw_Generator is
procedure Generate (Into : out Ada.Streams.Stream_Element_Array);
procedure Generate (Value : out Interfaces.Unsigned_32);
procedure Reset;
private
-- Random number generator used for ID generation.
Rand : Id_Random.Generator;
end Raw_Generator;
type Generator is limited new Ada.Finalization.Limited_Controlled with record
Rand : Raw_Generator;
end record;
end Keystore.Random;
|
RREE/ada-util | Ada | 9,919 | adb | -----------------------------------------------------------------------
-- util-strings -- Various String Utility
-- Copyright (C) 2001, 2002, 2003, 2009, 2010, 2011, 2012, 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.Strings.Fixed;
with Ada.Strings.Hash;
with Ada.Unchecked_Deallocation;
package body Util.Strings is
-- ------------------------------
-- Compute the hash value of the string.
-- ------------------------------
function Hash (Key : Name_Access) return Ada.Containers.Hash_Type is
begin
return Ada.Strings.Hash (Key.all);
end Hash;
-- ------------------------------
-- Returns true if left and right strings are equivalent.
-- ------------------------------
function Equivalent_Keys (Left, Right : Name_Access) return Boolean is
begin
if Left = null or Right = null then
return False;
end if;
return Left.all = Right.all;
end Equivalent_Keys;
-- ------------------------------
-- Returns Integer'Image (Value) with the possible space stripped.
-- ------------------------------
function Image (Value : in Integer) return String is
S : constant String := Integer'Image (Value);
begin
if S (S'First) = ' ' then
return S (S'First + 1 .. S'Last);
else
return S;
end if;
end Image;
-- ------------------------------
-- Returns Integer'Image (Value) with the possible space stripped.
-- ------------------------------
function Image (Value : in Long_Long_Integer) return String is
S : constant String := Long_Long_Integer'Image (Value);
begin
if S (S'First) = ' ' then
return S (S'First + 1 .. S'Last);
else
return S;
end if;
end Image;
use Util.Concurrent.Counters;
-- ------------------------------
-- Create a string reference from a string.
-- ------------------------------
function To_String_Ref (S : in String) return String_Ref is
Str : constant String_Record_Access
:= new String_Record '(Len => S'Length, Str => S, Counter => ONE);
begin
return String_Ref '(Ada.Finalization.Controlled with
Str => Str);
end To_String_Ref;
-- ------------------------------
-- Create a string reference from an unbounded string.
-- ------------------------------
function To_String_Ref (S : in Ada.Strings.Unbounded.Unbounded_String) return String_Ref is
use Ada.Strings.Unbounded;
Len : constant Natural := Length (S);
Str : constant String_Record_Access
:= new String_Record '(Len => Len, Str => To_String (S), Counter => ONE);
begin
return String_Ref '(Ada.Finalization.Controlled with
Str => Str);
end To_String_Ref;
-- ------------------------------
-- Get the string
-- ------------------------------
function To_String (S : in String_Ref) return String is
begin
if S.Str = null then
return "";
else
return S.Str.Str;
end if;
end To_String;
-- ------------------------------
-- Get the string as an unbounded string
-- ------------------------------
function To_Unbounded_String (S : in String_Ref)
return Ada.Strings.Unbounded.Unbounded_String is
begin
if S.Str = null then
return Ada.Strings.Unbounded.Null_Unbounded_String;
else
return Ada.Strings.Unbounded.To_Unbounded_String (S.Str.Str);
end if;
end To_Unbounded_String;
-- ------------------------------
-- Compute the hash value of the string reference.
-- ------------------------------
function Hash (Key : String_Ref) return Ada.Containers.Hash_Type is
begin
if Key.Str = null then
return 0;
else
return Ada.Strings.Hash (Key.Str.Str);
end if;
end Hash;
-- ------------------------------
-- Returns true if left and right string references are equivalent.
-- ------------------------------
function Equivalent_Keys (Left, Right : String_Ref) return Boolean is
begin
if Left.Str = Right.Str then
return True;
elsif Left.Str = null or Right.Str = null then
return False;
else
return Left.Str.Str = Right.Str.Str;
end if;
end Equivalent_Keys;
function "=" (Left : in String_Ref;
Right : in String) return Boolean is
begin
if Left.Str = null then
return False;
else
return Left.Str.Str = Right;
end if;
end "=";
function "=" (Left : in String_Ref;
Right : in Ada.Strings.Unbounded.Unbounded_String) return Boolean is
use Ada.Strings.Unbounded;
begin
if Left.Str = null then
return Right = Null_Unbounded_String;
else
return Right = Left.Str.Str;
end if;
end "=";
-- ------------------------------
-- Returns the string length.
-- ------------------------------
function Length (S : in String_Ref) return Natural is
begin
if S.Str = null then
return 0;
else
return S.Str.Len;
end if;
end Length;
-- ------------------------------
-- Increment the reference counter.
-- ------------------------------
overriding
procedure Adjust (Object : in out String_Ref) is
begin
if Object.Str /= null then
Util.Concurrent.Counters.Increment (Object.Str.Counter);
end if;
end Adjust;
-- ------------------------------
-- Decrement the reference counter and free the allocated string.
-- ------------------------------
overriding
procedure Finalize (Object : in out String_Ref) is
procedure Free is
new Ada.Unchecked_Deallocation (String_Record, String_Record_Access);
Is_Zero : Boolean;
begin
if Object.Str /= null then
Util.Concurrent.Counters.Decrement (Object.Str.Counter, Is_Zero);
if Is_Zero then
Free (Object.Str);
else
Object.Str := null;
end if;
end if;
end Finalize;
-- ------------------------------
-- Search for the first occurrence of the character in the string
-- after the from index. This implementation is 3-times faster than
-- the Ada.Strings.Fixed version.
-- Returns the index of the first occurrence or 0.
-- ------------------------------
function Index (Source : in String;
Char : in Character;
From : in Natural := 0) return Natural is
Pos : Natural := From;
begin
if Pos < Source'First then
Pos := Source'First;
end if;
for I in Pos .. Source'Last loop
if Source (I) = Char then
return I;
end if;
end loop;
return 0;
end Index;
-- ------------------------------
-- Search for the first occurrence of the pattern in the string.
-- ------------------------------
function Index (Source : in String;
Pattern : in String;
From : in Positive;
Going : in Ada.Strings.Direction := Ada.Strings.Forward) return Natural is
begin
return Ada.Strings.Fixed.Index (Source, Pattern, From, Going);
end Index;
-- ------------------------------
-- Returns True if the source string starts with the given prefix.
-- ------------------------------
function Starts_With (Source : in String;
Prefix : in String) return Boolean is
begin
return Source'Length >= Prefix'Length
and then Source (Source'First .. Source'First + Prefix'Length - 1) = Prefix;
end Starts_With;
-- ------------------------------
-- Returns True if the source string ends with the given suffix.
-- ------------------------------
function Ends_With (Source : in String;
Suffix : in String) return Boolean is
begin
return Source'Length >= Suffix'Length
and then Source (Source'Last - Suffix'Length + 1 .. Source'Last) = Suffix;
end Ends_With;
-- ------------------------------
-- Returns True if the source contains the pattern.
-- ------------------------------
function Contains (Source : in String;
Pattern : in String) return Boolean is
begin
return Ada.Strings.Fixed.Index (Source, Pattern) /= 0;
end Contains;
-- ------------------------------
-- Search for the first occurrence of the character in the string
-- before the from index and going backward.
-- This implementation is 3-times faster than the Ada.Strings.Fixed version.
-- Returns the index of the first occurrence or 0.
-- ------------------------------
function Rindex (Source : in String;
Ch : in Character;
From : in Natural := 0) return Natural is
Pos : Natural := From;
begin
if Pos < Source'First then
Pos := Source'Last;
end if;
for I in reverse Source'First .. Pos loop
if Source (I) = Ch then
return I;
end if;
end loop;
return 0;
end Rindex;
end Util.Strings;
|
reznikmm/matreshka | Ada | 3,709 | ads | ------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- Open Document Toolkit --
-- --
-- Runtime Library Component --
-- --
------------------------------------------------------------------------------
-- --
-- Copyright © 2014, Vadim Godunko <[email protected]> --
-- All rights reserved. --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions --
-- are met: --
-- --
-- * Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- --
-- * Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in the --
-- documentation and/or other materials provided with the distribution. --
-- --
-- * Neither the name of the Vadim Godunko, IE nor the names of its --
-- contributors may be used to endorse or promote products derived from --
-- this software without specific prior written permission. --
-- --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR --
-- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
-- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED --
-- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR --
-- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF --
-- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING --
-- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS --
-- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
-- --
------------------------------------------------------------------------------
-- $Revision$ $Date$
------------------------------------------------------------------------------
with XML.DOM.Attributes;
package ODF.DOM.Draw_Text_Path_Attributes is
pragma Preelaborate;
type ODF_Draw_Text_Path_Attribute is limited interface
and XML.DOM.Attributes.DOM_Attribute;
type ODF_Draw_Text_Path_Attribute_Access is
access all ODF_Draw_Text_Path_Attribute'Class
with Storage_Size => 0;
end ODF.DOM.Draw_Text_Path_Attributes;
|
reznikmm/matreshka | Ada | 4,719 | ads | ------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- Open Document Toolkit --
-- --
-- Runtime Library Component --
-- --
------------------------------------------------------------------------------
-- --
-- Copyright © 2014, Vadim Godunko <[email protected]> --
-- All rights reserved. --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions --
-- are met: --
-- --
-- * Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- --
-- * Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in the --
-- documentation and/or other materials provided with the distribution. --
-- --
-- * Neither the name of the Vadim Godunko, IE nor the names of its --
-- contributors may be used to endorse or promote products derived from --
-- this software without specific prior written permission. --
-- --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR --
-- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
-- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED --
-- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR --
-- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF --
-- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING --
-- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS --
-- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
-- --
------------------------------------------------------------------------------
-- $Revision$ $Date$
------------------------------------------------------------------------------
with XML.DOM.Visitors;
with ODF.DOM.Style_Font_Face_Elements;
package Matreshka.ODF_Style.Font_Face_Elements is
type Style_Font_Face_Element_Node is
new Matreshka.ODF_Style.Abstract_Style_Element_Node
and ODF.DOM.Style_Font_Face_Elements.ODF_Style_Font_Face
with null record;
overriding function Create
(Parameters : not null access Matreshka.DOM_Elements.Element_L2_Parameters)
return Style_Font_Face_Element_Node;
overriding function Get_Local_Name
(Self : not null access constant Style_Font_Face_Element_Node)
return League.Strings.Universal_String;
overriding procedure Enter_Node
(Self : not null access Style_Font_Face_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 Style_Font_Face_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 Style_Font_Face_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_Style.Font_Face_Elements;
|
AdaCore/Ada_Drivers_Library | Ada | 26,607 | ads | ------------------------------------------------------------------------------
-- --
-- Copyright (C) 2015, AdaCore --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions are --
-- met: --
-- 1. Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- 2. Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in --
-- the documentation and/or other materials provided with the --
-- distribution. --
-- 3. Neither the name of STMicroelectronics nor the names of its --
-- contributors may be used to endorse or promote products derived --
-- from this software without specific prior written permission. --
-- --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR --
-- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
-- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT --
-- LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, --
-- DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY --
-- THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT --
-- (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE --
-- OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
-- --
-- --
-- This file is based on: --
-- --
-- @file stm32f4xx_hal_dma.h --
-- @author MCD Application Team --
-- @version V1.1.0 --
-- @date 19-June-2014 --
-- @brief Header file of DMA HAL module. --
-- --
-- COPYRIGHT(c) 2014 STMicroelectronics --
------------------------------------------------------------------------------
-- This file provides definitions for the DMA controllers on the STM32F4 (ARM
-- Cortex M4F) microcontrollers from ST Microelectronics.
-- See Application Note AN4031: "Using the STM32F2 and STM32F4 DMA controller"
-- and Reference Manual RM0090: "STM32F405xx/07xx, STM32F415xx/17xx,
-- STM32F42xxx and STM32F43xxx advanced ARM-based 32-bit MCUs" In the
-- application note, see especially section four, titled "Tips and
-- warnings while programming the DMA controller"
-- The basic call sequence, given a Controller and a Stream, is as follows:
-- 1) Configure
-- Configures the Controller and Stream per application requirements. This
-- is the primary setup call, specifying the static characteristics of all
-- the transfers to be performed on the stream, such as the direction, the
-- channel, and so forth. The Controller is disabled after the call.
-- 2) Configure_Data_Flow
-- Sets the dynamic parameters of a given transfer, i.e., the source and
-- destination addresses and the number of data items to transfer.
-- 3) Enable
-- Enables transfers on the Controller and Stream. Transfers will begin
-- immediately unless programmed otherwise.
-- You can enable some or all DMA interrupts prior to the call to Enable, if
-- required by your usage.
-- Ensure all the status flags are cleared prior to the call to Enable, since
-- a transfer will then begin. This can be accomplished by relying on the fact
-- that the board has just powered-up, by a call to Reset, or by a call to
-- Clear_All_Status.
-- Note that there are convenience routines that do steps two and three:
-- Start_Transfer
-- Start_Transfer_with_Interrupts
pragma Restrictions (No_Elaboration_Code);
with System; use System;
with Ada.Real_Time; use Ada.Real_Time;
private with STM32_SVD.DMA;
package STM32.DMA with SPARK_Mode => Off is
type DMA_Controller is limited private;
-- Do not change the order of the enumerals in the types in this package.
-- The underlying canonical representation values are required.
type DMA_Stream_Selector is
(Stream_0,
Stream_1,
Stream_2,
Stream_3,
Stream_4,
Stream_5,
Stream_6,
Stream_7);
procedure Enable
(This : DMA_Controller;
Stream : DMA_Stream_Selector)
with Inline;
-- Before enabling a stream to start a new transfer, the event status flags
-- corresponding to the stream must be cleared. Note that the unit may not
-- be enabled by the time the call returns.
procedure Disable
(This : DMA_Controller;
Stream : DMA_Stream_Selector)
with
Post => not Enabled (This, Stream),
Inline;
function Enabled
(This : DMA_Controller;
Stream : DMA_Stream_Selector)
return Boolean with Inline;
procedure Reset
(This : in out DMA_Controller;
Stream : DMA_Stream_Selector)
with
Post =>
not Enabled (This, Stream) and
Operating_Mode (This, Stream) = Normal_Mode and
Current_NDT (This, Stream) = 0 and
Selected_Channel (This, Stream) = Channel_0 and
Transfer_Direction (This, Stream) = Peripheral_To_Memory and
not Double_Buffered (This, Stream) and
not Circular_Mode (This, Stream) and
Memory_Data_Width (This, Stream) = Bytes and
Peripheral_Data_Width (This, Stream) = Bytes and
Priority (This, Stream) = Priority_Low and
Current_Memory_Buffer (This, Stream) = Memory_Buffer_0 and
(for all Flag in DMA_Status_Flag =>
not Status (This, Stream, Flag)) and
(for all Interrupt in DMA_Interrupt =>
not Interrupt_Enabled (This, Stream, Interrupt));
-- In addition,
-- M_Burst = Memory_Burst_Single and
-- P_Burst = Peripheral_Burst_Single and
-- P_Inc_Offset_Size = 0 and
-- M_Inc_Mode = False and
-- P_Inc_Mode = False
-- Also clears the FIFO control register bits except sets bits to show FIFO
-- is empty, and to set the FIFO filling threshold selection to 1/2 full.
procedure Configure_Data_Flow
(This : DMA_Controller;
Stream : DMA_Stream_Selector;
Source : Address;
Destination : Address;
Data_Count : UInt16)
with
Pre =>
not Enabled (This, Stream) and
Valid_Addresses (Source, Destination) and
Compatible_Alignments (This, Stream, Source, Destination);
-- Sets the source and destination arguments within the specified stream,
-- based on the direction previously specified by a call to procedure
-- Configure.
--
-- Sets the number of data items to be transferred (from 0 to 65535) on
-- the specified stream in the next transfer. This is the volume of data to
-- be transferred from source to destination. The number specified depends
-- only on the peripheral data format, as specified by the record component
-- Peripheral_Data_Format passed to a call to Configure. The value to be
-- specified is computed as follows:
--
-- If the peripheral data format is in units of bytes, the value is
-- equal to the total number of bytes contained in the data to be sent.
--
-- If the peripheral data format is in units of half-words, the value is
-- 1/2 the total number of bytes contained in the data to be sent.
--
-- If the peripheral data format is in units of words, the value is
-- 1/4 the total number of bytes contained in the data to be sent.
--
-- For example, to send a sequence of characters to a USART, the USART
-- peripheral format will be in units of bytes so the Data_Count argument
-- will be the number of characters (bytes) in the string to be sent.
-- In contrast, on a memory-to-memory transfer the most efficient approach
-- is to work in units of words. One would therefore specify word units for
-- the source and destination formats and then specify 1/4 the total number
-- of bytes involved (assuming a four-byte word).
procedure Start_Transfer
(This : DMA_Controller;
Stream : DMA_Stream_Selector;
Source : Address;
Destination : Address;
Data_Count : UInt16)
with
Pre =>
Valid_Addresses (Source, Destination)
and
Compatible_Alignments (This, Stream, Source, Destination)
and
(for all Flag in DMA_Status_Flag =>
(not Status (This, Stream, Flag)));
-- Convenience routine: disables the stream, calls Configure_Data_Flow,
-- and then enables the stream to start the transfer. DMA interrupts are
-- not enabled by this routine, but could be enabled prior to the call.
-- The requirement to clear the flags first is due to the fact that
-- the transfer begins immediately at the end of this routine. The
-- value specified for Data_Count is as described for procedure
-- Configure_Data_Flow.
type DMA_Interrupt is
(Direct_Mode_Error_Interrupt,
Transfer_Error_Interrupt,
Half_Transfer_Complete_Interrupt,
Transfer_Complete_Interrupt,
FIFO_Error_Interrupt);
type Interrupt_Selections is array (DMA_Interrupt) of Boolean;
procedure Start_Transfer_with_Interrupts
(This : DMA_Controller;
Stream : DMA_Stream_Selector;
Source : Address;
Destination : Address;
Data_Count : UInt16;
Enabled_Interrupts : Interrupt_Selections := (others => True))
with
Pre =>
Valid_Addresses (Source, Destination)
and
Compatible_Alignments (This, Stream, Source, Destination)
and
(for all Flag in DMA_Status_Flag =>
(not Status (This, Stream, Flag)));
-- Convenience routine: disables the stream, calls Configure_Data_Flow,
-- enables the selected DMA interrupts (by default, all of them), and
-- then enables the stream to start the transfer. All the selected DMA
-- interrupts are enabled, all the others are left unchanged. Interrupts
-- are selected for enablement by having a True value in the array at their
-- index location. The requirement to clear the flags first is due to the
-- fact that the transfer begins immediately at the end of this routine.
-- The value specified for Data_Count is as described for procedure
-- Configure_Data_Flow.
type DMA_Error_Code is
(DMA_No_Error,
DMA_Transfer_Error,
DMA_FIFO_Error,
DMA_Direct_Mode_Error,
DMA_Timeout_Error,
DMA_Device_Error);
procedure Abort_Transfer
(This : DMA_Controller;
Stream : DMA_Stream_Selector;
Result : out DMA_Error_Code)
with Post => not Enabled (This, Stream);
-- Disables the specified stream and then waits until the request is
-- effective. If a stream is disabled while a data transfer is ongoing, the
-- current datum will be transferred and the stream will be disabled only
-- after the transfer of this single datum completes.
type DMA_Transfer_Level is
(Full_Transfer,
Half_Transfer);
procedure Poll_For_Completion
(This : in out DMA_Controller;
Stream : DMA_Stream_Selector;
Expected_Level : DMA_Transfer_Level;
Timeout : Time_Span;
Result : out DMA_Error_Code);
procedure Set_NDT
(This : DMA_Controller;
Stream : DMA_Stream_Selector;
Data_Count : UInt16)
with
Pre => not Enabled (This, Stream),
Post => Current_NDT (This, Stream) = Data_Count,
Inline;
-- Sets the number of data items to be transferred on the stream.
-- The Data_Count parameter specifies the number of data items to be
-- transferred (from 0 to 65535) on the next transfer. The value is
-- as described for procedure Configure_Data_Flow.
function Items_Transferred
(This : DMA_Controller;
Stream : DMA_Stream_Selector)
return UInt16;
-- returns the number of items transfetred
function Current_NDT
(This : DMA_Controller;
Stream : DMA_Stream_Selector)
return UInt16
with Inline;
-- Returns the value of the NDT register. Should not be used directly,
-- as the meaning changes depending on transfer mode. rather use
-- Items_Transferred()
function Circular_Mode
(This : DMA_Controller;
Stream : DMA_Stream_Selector)
return Boolean
with Inline;
procedure Enable_Interrupt
(This : DMA_Controller;
Stream : DMA_Stream_Selector;
Source : DMA_Interrupt)
with
Post => Interrupt_Enabled (This, Stream, Source);
-- The postcondition should not be relied upon completely because it is
-- possible, under just the wrong conditions, for the interrupt to be
-- disabled immediately, prior to return from this routine
procedure Disable_Interrupt
(This : DMA_Controller;
Stream : DMA_Stream_Selector;
Source : DMA_Interrupt)
with
Post => not Interrupt_Enabled (This, Stream, Source);
function Interrupt_Enabled
(This : DMA_Controller;
Stream : DMA_Stream_Selector;
Source : DMA_Interrupt)
return Boolean
with Inline;
type DMA_Status_Flag is
(FIFO_Error_Indicated,
Direct_Mode_Error_Indicated,
Transfer_Error_Indicated,
Half_Transfer_Complete_Indicated,
Transfer_Complete_Indicated);
procedure Clear_Status
(This : in out DMA_Controller;
Stream : DMA_Stream_Selector;
Flag : DMA_Status_Flag)
with
Post => not Status (This, Stream, Flag),
Inline;
procedure Clear_All_Status
(This : in out DMA_Controller;
Stream : DMA_Stream_Selector)
with Post =>
(for all Indicated in DMA_Status_Flag =>
not Status (This, Stream, Indicated));
function Status
(This : DMA_Controller;
Stream : DMA_Stream_Selector;
Flag : DMA_Status_Flag)
return Boolean
with Inline;
-- Returns whether the specified status flag is indicated
type DMA_Channel_Selector is
(Channel_0,
Channel_1,
Channel_2,
Channel_3,
Channel_4,
Channel_5,
Channel_6,
Channel_7,
Channel_8,
Channel_9,
Channel_10,
Channel_11,
Channel_12,
Channel_13,
Channel_14,
Channel_15);
function Selected_Channel
(This : DMA_Controller; Stream : DMA_Stream_Selector)
return DMA_Channel_Selector
with Inline;
type DMA_Data_Transfer_Direction is
(Peripheral_To_Memory,
Memory_To_Peripheral,
Memory_To_Memory);
-- Note that only DMA_2 is able to do Memory_To_Memory transfers, and that
-- in this direction the circular mode is not allowed and the internal FIFO
-- must be enabled.
function Transfer_Direction
(This : DMA_Controller; Stream : DMA_Stream_Selector)
return DMA_Data_Transfer_Direction
with Inline;
type DMA_Data_Transfer_Widths is
(Bytes,
HalfWords,
Words);
function Peripheral_Data_Width
(This : DMA_Controller; Stream : DMA_Stream_Selector)
return DMA_Data_Transfer_Widths
with Inline;
function Memory_Data_Width
(This : DMA_Controller; Stream : DMA_Stream_Selector)
return DMA_Data_Transfer_Widths
with Inline;
type DMA_Mode is
(Normal_Mode,
Peripheral_Flow_Control_Mode,
Circular_Mode);
function Operating_Mode
(This : DMA_Controller; Stream : DMA_Stream_Selector)
return DMA_Mode
with Inline;
type DMA_Priority_Level is
(Priority_Low,
Priority_Medium,
Priority_High,
Priority_Very_High);
function Priority
(This : DMA_Controller; Stream : DMA_Stream_Selector)
return DMA_Priority_Level
with Inline;
type Memory_Buffer_Target is (Memory_Buffer_0, Memory_Buffer_1);
function Current_Memory_Buffer
(This : DMA_Controller; Stream : DMA_Stream_Selector)
return Memory_Buffer_Target
with Inline;
procedure Select_Current_Memory_Buffer
(This : DMA_Controller;
Stream : DMA_Stream_Selector;
Buffer : Memory_Buffer_Target)
with Inline;
procedure Set_Memory_Buffer
(This : DMA_Controller;
Stream : DMA_Stream_Selector;
Buffer : Memory_Buffer_Target;
To : System.Address)
with Inline;
procedure Configure_Double_Buffered_Mode
(This : DMA_Controller;
Stream : DMA_Stream_Selector;
Buffer_0_Value : Address;
Buffer_1_Value : Address;
First_Buffer_Used : Memory_Buffer_Target)
with
Pre => not Enabled (This, Stream),
Post => not Enabled (This, Stream) and
Current_Memory_Buffer (This, Stream) = First_Buffer_Used;
-- A convenience routine that in effect calls Set_Memory_Buffer
-- once each for Buffer_1_Value and Buffer_2_Value, and then calls
-- Select_Current_Memory_Buffer so that First_Buffer_Used is the
-- buffer used first when the stream is enabled.
procedure Enable_Double_Buffered_Mode
(This : DMA_Controller;
Stream : DMA_Stream_Selector)
with
Pre => Circular_Mode (This, Stream) and
Transfer_Direction (This, Stream) /= Memory_To_Memory,
Post => Double_Buffered (This, Stream);
procedure Disable_Double_Buffered_Mode
(This : DMA_Controller;
Stream : DMA_Stream_Selector)
with Post => not Double_Buffered (This, Stream);
function Double_Buffered
(This : DMA_Controller;
Stream : DMA_Stream_Selector)
return Boolean
with Inline;
type DMA_FIFO_Threshold_Level is
(FIFO_Threshold_1_Quart_Full_Configuration,
FIFO_Threshold_Half_Full_Configuration,
FIFO_Threshold_3_Quarts_Full_Configuration,
FIFO_Threshold_Full_Configuration);
type DMA_FIFO_Filling_State is
(FIFO_Less1QuarterFull, -- less than 1 quarter full but not empty
FIFO_1QuarterFull, -- more than 1 quarter full
FIFO_HalfFull, -- more than 1 half full
FIFO_3QuartersFull, -- more than 3 quarters full
FIFO_Empty,
FIFO_Full);
type DMA_Memory_Burst is
(Memory_Burst_Single,
Memory_Burst_Inc4,
Memory_Burst_Inc8,
Memory_Burst_Inc16);
type DMA_Peripheral_Burst is
(Peripheral_Burst_Single,
Peripheral_Burst_Inc4,
Peripheral_Burst_Inc8,
Peripheral_Burst_Inc16);
type DMA_Stream_Configuration is record
-- These are the static, non-varying properties of the transactions
-- occurring on the streams to which they are applied (by a call to
-- Configure). Other, varying, properties are specified procedurally.
--
-- You are not required to specify a value for every component because
-- some are only referenced depending on the values for others. Note,
-- however, that the default values specified do not represent a valid
-- configuration as a whole.
Channel : DMA_Channel_Selector :=
DMA_Channel_Selector'First;
-- The channel in the multiplexed connections of controllers, streams,
-- and peripherals. It is vital to note that not all peripherals can
-- be connected to all streams. The possibilities are organized by
-- channels, per controller, as specified by the ST Micro Reference
-- Manual in the "DMA Request Mapping" tables.
Direction : DMA_Data_Transfer_Direction :=
DMA_Data_Transfer_Direction'First;
Increment_Peripheral_Address : Boolean := False;
-- Whether the peripheral address value should be incremented
-- automatically after each transfer
Increment_Memory_Address : Boolean := False;
-- Whether the memory address value should be incremented automatically
-- after each transfer
Peripheral_Data_Format : DMA_Data_Transfer_Widths :=
DMA_Data_Transfer_Widths'First;
-- The units of data (the format) in which the peripheral side of the
-- transaction is expressed. For example, a USART would work in terms
-- of bytes. See the description in Configure_Data_Flow.
Memory_Data_Format : DMA_Data_Transfer_Widths :=
DMA_Data_Transfer_Widths'First;
-- The units of data (the format) in which the memory side of the
-- transaction is expressed. See the description in Configure_Data_Flow.
Operation_Mode : DMA_Mode := DMA_Mode'First;
-- Note that the circular buffer mode cannot be used if memory-to-memory
-- data transfer is configured on the selected Stream
Priority : DMA_Priority_Level :=
DMA_Priority_Level'First;
-- The relative priority of the given stream to all other streams
FIFO_Enabled : Boolean := False;
-- Specifies whether the internal FIFO will be used for the transactions
-- occurring on the specified stream. By default the FIFO is disabled by
-- the hardware, and so the unit works in the so-called "direct mode"
-- instead. Per the Application Note, enabling the FIFO is highly
-- advantageous. Note that the direct mode cannot be used if
-- memory-to-memory data transfer is configured. The threshold and
-- burst sizes are only considered if the FIFO is enabled, and the
-- corresponding values are highly dependent upon one another!
FIFO_Threshold : DMA_FIFO_Threshold_Level :=
DMA_FIFO_Threshold_Level'First;
-- The threshold at which the FIFO is refilled. It is vital that the
-- threshold and burst sizes, if specified, are compatible. See the
-- Reference Manual and especially the Application Note.
Memory_Burst_Size : DMA_Memory_Burst :=
DMA_Memory_Burst'First;
-- Specifies the amount of data to be transferred in a single non-
-- interruptible transaction. Note: The burst mode is possible only if
-- the address increment mode is enabled.
Peripheral_Burst_Size : DMA_Peripheral_Burst :=
DMA_Peripheral_Burst'First;
-- Specifies the the amount of data to be transferred in
-- a single non-interruptible transaction. Note :The burst mode is
-- possible only if the address increment mode is enabled.
end record;
procedure Configure
(This : DMA_Controller;
Stream : DMA_Stream_Selector;
Config : DMA_Stream_Configuration)
with Post => not Enabled (This, Stream);
-- This is the primary stream configuration facility. All the static
-- properties of the transfers for the given stream are specified here,
-- and in some cases, nowhere else (such as the channel). The required
-- relationships between the parameters specified in the record are
-- not checked, other than by the hardware itself.
--
-- Note that not all required properties are specified here. In particular,
-- because they can vary per transfer, the source and destination
-- addresses, as well as the number of data items to be transferred,
-- are specified procedurally via calls to Configure_Data_Flow.
function Valid_Addresses (Source, Destination : Address) return Boolean is
(Source /= Null_Address and Destination /= Null_Address and
Source /= Destination);
-- Basic sanity checking for the values
function Aligned (This : Address; Width : DMA_Data_Transfer_Widths)
return Boolean with Inline;
-- Returns whether the address is aligned on a word, half-word, or byte
-- boundary
function Compatible_Alignments
(This : DMA_Controller;
Stream : DMA_Stream_Selector;
Source : Address;
Destination : Address)
return Boolean is
(case Transfer_Direction (This, Stream) is
when Peripheral_To_Memory | Memory_To_Memory =>
Aligned (Source, Peripheral_Data_Width (This, Stream))
and
Aligned (Destination, Memory_Data_Width (This, Stream)),
when Memory_To_Peripheral =>
Aligned (Source, Memory_Data_Width (This, Stream))
and
Aligned (Destination, Peripheral_Data_Width (This, Stream)));
-- Based on Ref Manual Table 44 and associated text, checks the alignments
-- of the addresses against the Peripheral_Data_Format (P_Data_Size) and
-- Memory_Data_Format (M_Data_Size) values for the given stream. We use an
-- expression function because the semantics are meant to be part of the
-- spec of the package, visible as a precondition.
private
type DMA_Controller is new STM32_SVD.DMA.DMA_Peripheral;
end STM32.DMA;
|
reznikmm/matreshka | Ada | 4,631 | adb | ------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- Open Document Toolkit --
-- --
-- Runtime Library Component --
-- --
------------------------------------------------------------------------------
-- --
-- Copyright © 2014, Vadim Godunko <[email protected]> --
-- All rights reserved. --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions --
-- are met: --
-- --
-- * Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- --
-- * Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in the --
-- documentation and/or other materials provided with the distribution. --
-- --
-- * Neither the name of the Vadim Godunko, IE nor the names of its --
-- contributors may be used to endorse or promote products derived from --
-- this software without specific prior written permission. --
-- --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR --
-- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
-- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED --
-- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR --
-- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF --
-- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING --
-- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS --
-- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
-- --
------------------------------------------------------------------------------
-- $Revision$ $Date$
------------------------------------------------------------------------------
with Matreshka.DOM_Documents;
with Matreshka.ODF_String_Constants;
with ODF.DOM.Iterators;
with ODF.DOM.Visitors;
package body Matreshka.ODF_Draw.Image_Opacity_Attributes is
------------
-- Create --
------------
overriding function Create
(Parameters : not null access Matreshka.DOM_Attributes.Attribute_L2_Parameters)
return Draw_Image_Opacity_Attribute_Node is
begin
return Self : Draw_Image_Opacity_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_Image_Opacity_Attribute_Node)
return League.Strings.Universal_String
is
pragma Unreferenced (Self);
begin
return Matreshka.ODF_String_Constants.Image_Opacity_Attribute;
end Get_Local_Name;
begin
Matreshka.DOM_Documents.Register_Attribute
(Matreshka.ODF_String_Constants.Draw_URI,
Matreshka.ODF_String_Constants.Image_Opacity_Attribute,
Draw_Image_Opacity_Attribute_Node'Tag);
end Matreshka.ODF_Draw.Image_Opacity_Attributes;
|
reznikmm/matreshka | Ada | 34,489 | ads | ------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- Ada Modeling Framework --
-- --
-- Runtime Library Component --
-- --
------------------------------------------------------------------------------
-- --
-- Copyright © 2011-2012, Vadim Godunko <[email protected]> --
-- All rights reserved. --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions --
-- are met: --
-- --
-- * Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- --
-- * Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in the --
-- documentation and/or other materials provided with the distribution. --
-- --
-- * Neither the name of the Vadim Godunko, IE nor the names of its --
-- contributors may be used to endorse or promote products derived from --
-- this software without specific prior written permission. --
-- --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR --
-- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
-- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED --
-- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR --
-- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF --
-- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING --
-- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS --
-- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
-- --
------------------------------------------------------------------------------
-- $Revision$ $Date$
------------------------------------------------------------------------------
with AMF.Internals.UML_Classifiers;
with AMF.String_Collections;
with AMF.UML.Actors;
with AMF.UML.Behaviors.Collections;
with AMF.UML.Classifier_Template_Parameters;
with AMF.UML.Classifiers.Collections;
with AMF.UML.Collaboration_Uses.Collections;
with AMF.UML.Constraints.Collections;
with AMF.UML.Dependencies.Collections;
with AMF.UML.Element_Imports.Collections;
with AMF.UML.Features.Collections;
with AMF.UML.Generalization_Sets.Collections;
with AMF.UML.Generalizations.Collections;
with AMF.UML.Interface_Realizations.Collections;
with AMF.UML.Named_Elements.Collections;
with AMF.UML.Namespaces;
with AMF.UML.Package_Imports.Collections;
with AMF.UML.Packageable_Elements.Collections;
with AMF.UML.Packages.Collections;
with AMF.UML.Parameterable_Elements.Collections;
with AMF.UML.Properties.Collections;
with AMF.UML.Redefinable_Elements.Collections;
with AMF.UML.Redefinable_Template_Signatures;
with AMF.UML.String_Expressions;
with AMF.UML.Substitutions.Collections;
with AMF.UML.Template_Bindings.Collections;
with AMF.UML.Template_Parameters;
with AMF.UML.Template_Signatures;
with AMF.UML.Types;
with AMF.UML.Use_Cases.Collections;
with AMF.Visitors;
package AMF.Internals.UML_Actors is
type UML_Actor_Proxy is
limited new AMF.Internals.UML_Classifiers.UML_Classifier_Proxy
and AMF.UML.Actors.UML_Actor with null record;
overriding function Get_Classifier_Behavior
(Self : not null access constant UML_Actor_Proxy)
return AMF.UML.Behaviors.UML_Behavior_Access;
-- Getter of BehavioredClassifier::classifierBehavior.
--
-- A behavior specification that specifies the behavior of the classifier
-- itself.
overriding procedure Set_Classifier_Behavior
(Self : not null access UML_Actor_Proxy;
To : AMF.UML.Behaviors.UML_Behavior_Access);
-- Setter of BehavioredClassifier::classifierBehavior.
--
-- A behavior specification that specifies the behavior of the classifier
-- itself.
overriding function Get_Interface_Realization
(Self : not null access constant UML_Actor_Proxy)
return AMF.UML.Interface_Realizations.Collections.Set_Of_UML_Interface_Realization;
-- Getter of BehavioredClassifier::interfaceRealization.
--
-- The set of InterfaceRealizations owned by the BehavioredClassifier.
-- Interface realizations reference the Interfaces of which the
-- BehavioredClassifier is an implementation.
overriding function Get_Owned_Behavior
(Self : not null access constant UML_Actor_Proxy)
return AMF.UML.Behaviors.Collections.Set_Of_UML_Behavior;
-- Getter of BehavioredClassifier::ownedBehavior.
--
-- References behavior specifications owned by a classifier.
overriding function Get_Attribute
(Self : not null access constant UML_Actor_Proxy)
return AMF.UML.Properties.Collections.Set_Of_UML_Property;
-- Getter of Classifier::attribute.
--
-- Refers to all of the Properties that are direct (i.e. not inherited or
-- imported) attributes of the classifier.
overriding function Get_Collaboration_Use
(Self : not null access constant UML_Actor_Proxy)
return AMF.UML.Collaboration_Uses.Collections.Set_Of_UML_Collaboration_Use;
-- Getter of Classifier::collaborationUse.
--
-- References the collaboration uses owned by the classifier.
overriding function Get_Feature
(Self : not null access constant UML_Actor_Proxy)
return AMF.UML.Features.Collections.Set_Of_UML_Feature;
-- Getter of Classifier::feature.
--
-- Specifies each feature defined in the classifier.
-- Note that there may be members of the Classifier that are of the type
-- Feature but are not included in this association, e.g. inherited
-- features.
overriding function Get_General
(Self : not null access constant UML_Actor_Proxy)
return AMF.UML.Classifiers.Collections.Set_Of_UML_Classifier;
-- Getter of Classifier::general.
--
-- Specifies the general Classifiers for this Classifier.
-- References the general classifier in the Generalization relationship.
overriding function Get_Generalization
(Self : not null access constant UML_Actor_Proxy)
return AMF.UML.Generalizations.Collections.Set_Of_UML_Generalization;
-- Getter of Classifier::generalization.
--
-- Specifies the Generalization relationships for this Classifier. These
-- Generalizations navigaten to more general classifiers in the
-- generalization hierarchy.
overriding function Get_Inherited_Member
(Self : not null access constant UML_Actor_Proxy)
return AMF.UML.Named_Elements.Collections.Set_Of_UML_Named_Element;
-- Getter of Classifier::inheritedMember.
--
-- Specifies all elements inherited by this classifier from the general
-- classifiers.
overriding function Get_Is_Abstract
(Self : not null access constant UML_Actor_Proxy)
return Boolean;
-- Getter of Classifier::isAbstract.
--
-- If true, the Classifier does not provide a complete declaration and can
-- typically not be instantiated. An abstract classifier is intended to be
-- used by other classifiers e.g. as the target of general
-- metarelationships or generalization relationships.
overriding function Get_Is_Final_Specialization
(Self : not null access constant UML_Actor_Proxy)
return Boolean;
-- Getter of Classifier::isFinalSpecialization.
--
-- If true, the Classifier cannot be specialized by generalization. Note
-- that this property is preserved through package merge operations; that
-- is, the capability to specialize a Classifier (i.e.,
-- isFinalSpecialization =false) must be preserved in the resulting
-- Classifier of a package merge operation where a Classifier with
-- isFinalSpecialization =false is merged with a matching Classifier with
-- isFinalSpecialization =true: the resulting Classifier will have
-- isFinalSpecialization =false.
overriding procedure Set_Is_Final_Specialization
(Self : not null access UML_Actor_Proxy;
To : Boolean);
-- Setter of Classifier::isFinalSpecialization.
--
-- If true, the Classifier cannot be specialized by generalization. Note
-- that this property is preserved through package merge operations; that
-- is, the capability to specialize a Classifier (i.e.,
-- isFinalSpecialization =false) must be preserved in the resulting
-- Classifier of a package merge operation where a Classifier with
-- isFinalSpecialization =false is merged with a matching Classifier with
-- isFinalSpecialization =true: the resulting Classifier will have
-- isFinalSpecialization =false.
overriding function Get_Owned_Template_Signature
(Self : not null access constant UML_Actor_Proxy)
return AMF.UML.Redefinable_Template_Signatures.UML_Redefinable_Template_Signature_Access;
-- Getter of Classifier::ownedTemplateSignature.
--
-- The optional template signature specifying the formal template
-- parameters.
overriding procedure Set_Owned_Template_Signature
(Self : not null access UML_Actor_Proxy;
To : AMF.UML.Redefinable_Template_Signatures.UML_Redefinable_Template_Signature_Access);
-- Setter of Classifier::ownedTemplateSignature.
--
-- The optional template signature specifying the formal template
-- parameters.
overriding function Get_Owned_Use_Case
(Self : not null access constant UML_Actor_Proxy)
return AMF.UML.Use_Cases.Collections.Set_Of_UML_Use_Case;
-- Getter of Classifier::ownedUseCase.
--
-- References the use cases owned by this classifier.
overriding function Get_Powertype_Extent
(Self : not null access constant UML_Actor_Proxy)
return AMF.UML.Generalization_Sets.Collections.Set_Of_UML_Generalization_Set;
-- Getter of Classifier::powertypeExtent.
--
-- Designates the GeneralizationSet of which the associated Classifier is
-- a power type.
overriding function Get_Redefined_Classifier
(Self : not null access constant UML_Actor_Proxy)
return AMF.UML.Classifiers.Collections.Set_Of_UML_Classifier;
-- Getter of Classifier::redefinedClassifier.
--
-- References the Classifiers that are redefined by this Classifier.
overriding function Get_Representation
(Self : not null access constant UML_Actor_Proxy)
return AMF.UML.Collaboration_Uses.UML_Collaboration_Use_Access;
-- Getter of Classifier::representation.
--
-- References a collaboration use which indicates the collaboration that
-- represents this classifier.
overriding procedure Set_Representation
(Self : not null access UML_Actor_Proxy;
To : AMF.UML.Collaboration_Uses.UML_Collaboration_Use_Access);
-- Setter of Classifier::representation.
--
-- References a collaboration use which indicates the collaboration that
-- represents this classifier.
overriding function Get_Substitution
(Self : not null access constant UML_Actor_Proxy)
return AMF.UML.Substitutions.Collections.Set_Of_UML_Substitution;
-- Getter of Classifier::substitution.
--
-- References the substitutions that are owned by this Classifier.
overriding function Get_Template_Parameter
(Self : not null access constant UML_Actor_Proxy)
return AMF.UML.Classifier_Template_Parameters.UML_Classifier_Template_Parameter_Access;
-- Getter of Classifier::templateParameter.
--
-- The template parameter that exposes this element as a formal parameter.
overriding procedure Set_Template_Parameter
(Self : not null access UML_Actor_Proxy;
To : AMF.UML.Classifier_Template_Parameters.UML_Classifier_Template_Parameter_Access);
-- Setter of Classifier::templateParameter.
--
-- The template parameter that exposes this element as a formal parameter.
overriding function Get_Use_Case
(Self : not null access constant UML_Actor_Proxy)
return AMF.UML.Use_Cases.Collections.Set_Of_UML_Use_Case;
-- Getter of Classifier::useCase.
--
-- The set of use cases for which this Classifier is the subject.
overriding function Get_Element_Import
(Self : not null access constant UML_Actor_Proxy)
return AMF.UML.Element_Imports.Collections.Set_Of_UML_Element_Import;
-- Getter of Namespace::elementImport.
--
-- References the ElementImports owned by the Namespace.
overriding function Get_Imported_Member
(Self : not null access constant UML_Actor_Proxy)
return AMF.UML.Packageable_Elements.Collections.Set_Of_UML_Packageable_Element;
-- Getter of Namespace::importedMember.
--
-- References the PackageableElements that are members of this Namespace
-- as a result of either PackageImports or ElementImports.
overriding function Get_Member
(Self : not null access constant UML_Actor_Proxy)
return AMF.UML.Named_Elements.Collections.Set_Of_UML_Named_Element;
-- Getter of Namespace::member.
--
-- A collection of NamedElements identifiable within the Namespace, either
-- by being owned or by being introduced by importing or inheritance.
overriding function Get_Owned_Member
(Self : not null access constant UML_Actor_Proxy)
return AMF.UML.Named_Elements.Collections.Set_Of_UML_Named_Element;
-- Getter of Namespace::ownedMember.
--
-- A collection of NamedElements owned by the Namespace.
overriding function Get_Owned_Rule
(Self : not null access constant UML_Actor_Proxy)
return AMF.UML.Constraints.Collections.Set_Of_UML_Constraint;
-- Getter of Namespace::ownedRule.
--
-- Specifies a set of Constraints owned by this Namespace.
overriding function Get_Package_Import
(Self : not null access constant UML_Actor_Proxy)
return AMF.UML.Package_Imports.Collections.Set_Of_UML_Package_Import;
-- Getter of Namespace::packageImport.
--
-- References the PackageImports owned by the Namespace.
overriding function Get_Client_Dependency
(Self : not null access constant UML_Actor_Proxy)
return AMF.UML.Dependencies.Collections.Set_Of_UML_Dependency;
-- Getter of NamedElement::clientDependency.
--
-- Indicates the dependencies that reference the client.
overriding function Get_Name_Expression
(Self : not null access constant UML_Actor_Proxy)
return AMF.UML.String_Expressions.UML_String_Expression_Access;
-- Getter of NamedElement::nameExpression.
--
-- The string expression used to define the name of this named element.
overriding procedure Set_Name_Expression
(Self : not null access UML_Actor_Proxy;
To : AMF.UML.String_Expressions.UML_String_Expression_Access);
-- Setter of NamedElement::nameExpression.
--
-- The string expression used to define the name of this named element.
overriding function Get_Namespace
(Self : not null access constant UML_Actor_Proxy)
return AMF.UML.Namespaces.UML_Namespace_Access;
-- Getter of NamedElement::namespace.
--
-- Specifies the namespace that owns the NamedElement.
overriding function Get_Qualified_Name
(Self : not null access constant UML_Actor_Proxy)
return AMF.Optional_String;
-- Getter of NamedElement::qualifiedName.
--
-- A name which allows the NamedElement to be identified within a
-- hierarchy of nested Namespaces. It is constructed from the names of the
-- containing namespaces starting at the root of the hierarchy and ending
-- with the name of the NamedElement itself.
overriding function Get_Package
(Self : not null access constant UML_Actor_Proxy)
return AMF.UML.Packages.UML_Package_Access;
-- Getter of Type::package.
--
-- Specifies the owning package of this classifier, if any.
overriding procedure Set_Package
(Self : not null access UML_Actor_Proxy;
To : AMF.UML.Packages.UML_Package_Access);
-- Setter of Type::package.
--
-- Specifies the owning package of this classifier, if any.
overriding function Get_Owning_Template_Parameter
(Self : not null access constant UML_Actor_Proxy)
return AMF.UML.Template_Parameters.UML_Template_Parameter_Access;
-- Getter of ParameterableElement::owningTemplateParameter.
--
-- The formal template parameter that owns this element.
overriding procedure Set_Owning_Template_Parameter
(Self : not null access UML_Actor_Proxy;
To : AMF.UML.Template_Parameters.UML_Template_Parameter_Access);
-- Setter of ParameterableElement::owningTemplateParameter.
--
-- The formal template parameter that owns this element.
overriding function Get_Template_Parameter
(Self : not null access constant UML_Actor_Proxy)
return AMF.UML.Template_Parameters.UML_Template_Parameter_Access;
-- Getter of ParameterableElement::templateParameter.
--
-- The template parameter that exposes this element as a formal parameter.
overriding procedure Set_Template_Parameter
(Self : not null access UML_Actor_Proxy;
To : AMF.UML.Template_Parameters.UML_Template_Parameter_Access);
-- Setter of ParameterableElement::templateParameter.
--
-- The template parameter that exposes this element as a formal parameter.
overriding function Get_Owned_Template_Signature
(Self : not null access constant UML_Actor_Proxy)
return AMF.UML.Template_Signatures.UML_Template_Signature_Access;
-- Getter of TemplateableElement::ownedTemplateSignature.
--
-- The optional template signature specifying the formal template
-- parameters.
overriding procedure Set_Owned_Template_Signature
(Self : not null access UML_Actor_Proxy;
To : AMF.UML.Template_Signatures.UML_Template_Signature_Access);
-- Setter of TemplateableElement::ownedTemplateSignature.
--
-- The optional template signature specifying the formal template
-- parameters.
overriding function Get_Template_Binding
(Self : not null access constant UML_Actor_Proxy)
return AMF.UML.Template_Bindings.Collections.Set_Of_UML_Template_Binding;
-- Getter of TemplateableElement::templateBinding.
--
-- The optional bindings from this element to templates.
overriding function Get_Is_Leaf
(Self : not null access constant UML_Actor_Proxy)
return Boolean;
-- Getter of RedefinableElement::isLeaf.
--
-- Indicates whether it is possible to further redefine a
-- RedefinableElement. If the value is true, then it is not possible to
-- further redefine the RedefinableElement. Note that this property is
-- preserved through package merge operations; that is, the capability to
-- redefine a RedefinableElement (i.e., isLeaf=false) must be preserved in
-- the resulting RedefinableElement of a package merge operation where a
-- RedefinableElement with isLeaf=false is merged with a matching
-- RedefinableElement with isLeaf=true: the resulting RedefinableElement
-- will have isLeaf=false. Default value is false.
overriding procedure Set_Is_Leaf
(Self : not null access UML_Actor_Proxy;
To : Boolean);
-- Setter of RedefinableElement::isLeaf.
--
-- Indicates whether it is possible to further redefine a
-- RedefinableElement. If the value is true, then it is not possible to
-- further redefine the RedefinableElement. Note that this property is
-- preserved through package merge operations; that is, the capability to
-- redefine a RedefinableElement (i.e., isLeaf=false) must be preserved in
-- the resulting RedefinableElement of a package merge operation where a
-- RedefinableElement with isLeaf=false is merged with a matching
-- RedefinableElement with isLeaf=true: the resulting RedefinableElement
-- will have isLeaf=false. Default value is false.
overriding function Get_Redefined_Element
(Self : not null access constant UML_Actor_Proxy)
return AMF.UML.Redefinable_Elements.Collections.Set_Of_UML_Redefinable_Element;
-- Getter of RedefinableElement::redefinedElement.
--
-- The redefinable element that is being redefined by this element.
overriding function Get_Redefinition_Context
(Self : not null access constant UML_Actor_Proxy)
return AMF.UML.Classifiers.Collections.Set_Of_UML_Classifier;
-- Getter of RedefinableElement::redefinitionContext.
--
-- References the contexts that this element may be redefined from.
overriding function All_Features
(Self : not null access constant UML_Actor_Proxy)
return AMF.UML.Features.Collections.Set_Of_UML_Feature;
-- Operation Classifier::allFeatures.
--
-- The query allFeatures() gives all of the features in the namespace of
-- the classifier. In general, through mechanisms such as inheritance,
-- this will be a larger set than feature.
overriding function Conforms_To
(Self : not null access constant UML_Actor_Proxy;
Other : AMF.UML.Classifiers.UML_Classifier_Access)
return Boolean;
-- Operation Classifier::conformsTo.
--
-- The query conformsTo() gives true for a classifier that defines a type
-- that conforms to another. This is used, for example, in the
-- specification of signature conformance for operations.
overriding function General
(Self : not null access constant UML_Actor_Proxy)
return AMF.UML.Classifiers.Collections.Set_Of_UML_Classifier;
-- Operation Classifier::general.
--
-- The general classifiers are the classifiers referenced by the
-- generalization relationships.
overriding function Has_Visibility_Of
(Self : not null access constant UML_Actor_Proxy;
N : AMF.UML.Named_Elements.UML_Named_Element_Access)
return Boolean;
-- Operation Classifier::hasVisibilityOf.
--
-- The query hasVisibilityOf() determines whether a named element is
-- visible in the classifier. By default all are visible. It is only
-- called when the argument is something owned by a parent.
overriding function Inherit
(Self : not null access constant UML_Actor_Proxy;
Inhs : AMF.UML.Named_Elements.Collections.Set_Of_UML_Named_Element)
return AMF.UML.Named_Elements.Collections.Set_Of_UML_Named_Element;
-- Operation Classifier::inherit.
--
-- The query inherit() defines how to inherit a set of elements. Here the
-- operation is defined to inherit them all. It is intended to be
-- redefined in circumstances where inheritance is affected by
-- redefinition.
-- The inherit operation is overridden to exclude redefined properties.
overriding function Inheritable_Members
(Self : not null access constant UML_Actor_Proxy;
C : AMF.UML.Classifiers.UML_Classifier_Access)
return AMF.UML.Named_Elements.Collections.Set_Of_UML_Named_Element;
-- Operation Classifier::inheritableMembers.
--
-- The query inheritableMembers() gives all of the members of a classifier
-- that may be inherited in one of its descendants, subject to whatever
-- visibility restrictions apply.
overriding function Inherited_Member
(Self : not null access constant UML_Actor_Proxy)
return AMF.UML.Named_Elements.Collections.Set_Of_UML_Named_Element;
-- Operation Classifier::inheritedMember.
--
-- The inheritedMember association is derived by inheriting the
-- inheritable members of the parents.
-- The inheritedMember association is derived by inheriting the
-- inheritable members of the parents.
overriding function Is_Template
(Self : not null access constant UML_Actor_Proxy)
return Boolean;
-- Operation Classifier::isTemplate.
--
-- The query isTemplate() returns whether this templateable element is
-- actually a template.
overriding function May_Specialize_Type
(Self : not null access constant UML_Actor_Proxy;
C : AMF.UML.Classifiers.UML_Classifier_Access)
return Boolean;
-- Operation Classifier::maySpecializeType.
--
-- The query maySpecializeType() determines whether this classifier may
-- have a generalization relationship to classifiers of the specified
-- type. By default a classifier may specialize classifiers of the same or
-- a more general type. It is intended to be redefined by classifiers that
-- have different specialization constraints.
overriding function Exclude_Collisions
(Self : not null access constant UML_Actor_Proxy;
Imps : AMF.UML.Packageable_Elements.Collections.Set_Of_UML_Packageable_Element)
return AMF.UML.Packageable_Elements.Collections.Set_Of_UML_Packageable_Element;
-- Operation Namespace::excludeCollisions.
--
-- The query excludeCollisions() excludes from a set of
-- PackageableElements any that would not be distinguishable from each
-- other in this namespace.
overriding function Get_Names_Of_Member
(Self : not null access constant UML_Actor_Proxy;
Element : AMF.UML.Named_Elements.UML_Named_Element_Access)
return AMF.String_Collections.Set_Of_String;
-- Operation Namespace::getNamesOfMember.
--
-- The query getNamesOfMember() takes importing into account. It gives
-- back the set of names that an element would have in an importing
-- namespace, either because it is owned, or if not owned then imported
-- individually, or if not individually then from a package.
-- The query getNamesOfMember() gives a set of all of the names that a
-- member would have in a Namespace. In general a member can have multiple
-- names in a Namespace if it is imported more than once with different
-- aliases. The query takes account of importing. It gives back the set of
-- names that an element would have in an importing namespace, either
-- because it is owned, or if not owned then imported individually, or if
-- not individually then from a package.
overriding function Import_Members
(Self : not null access constant UML_Actor_Proxy;
Imps : AMF.UML.Packageable_Elements.Collections.Set_Of_UML_Packageable_Element)
return AMF.UML.Packageable_Elements.Collections.Set_Of_UML_Packageable_Element;
-- Operation Namespace::importMembers.
--
-- The query importMembers() defines which of a set of PackageableElements
-- are actually imported into the namespace. This excludes hidden ones,
-- i.e., those which have names that conflict with names of owned members,
-- and also excludes elements which would have the same name when imported.
overriding function Imported_Member
(Self : not null access constant UML_Actor_Proxy)
return AMF.UML.Packageable_Elements.Collections.Set_Of_UML_Packageable_Element;
-- Operation Namespace::importedMember.
--
-- The importedMember property is derived from the ElementImports and the
-- PackageImports. References the PackageableElements that are members of
-- this Namespace as a result of either PackageImports or ElementImports.
overriding function Members_Are_Distinguishable
(Self : not null access constant UML_Actor_Proxy)
return Boolean;
-- Operation Namespace::membersAreDistinguishable.
--
-- The Boolean query membersAreDistinguishable() determines whether all of
-- the namespace's members are distinguishable within it.
overriding function Owned_Member
(Self : not null access constant UML_Actor_Proxy)
return AMF.UML.Named_Elements.Collections.Set_Of_UML_Named_Element;
-- Operation Namespace::ownedMember.
--
-- Missing derivation for Namespace::/ownedMember : NamedElement
overriding function All_Owning_Packages
(Self : not null access constant UML_Actor_Proxy)
return AMF.UML.Packages.Collections.Set_Of_UML_Package;
-- Operation NamedElement::allOwningPackages.
--
-- The query allOwningPackages() returns all the directly or indirectly
-- owning packages.
overriding function Is_Distinguishable_From
(Self : not null access constant UML_Actor_Proxy;
N : AMF.UML.Named_Elements.UML_Named_Element_Access;
Ns : AMF.UML.Namespaces.UML_Namespace_Access)
return Boolean;
-- Operation NamedElement::isDistinguishableFrom.
--
-- The query isDistinguishableFrom() determines whether two NamedElements
-- may logically co-exist within a Namespace. By default, two named
-- elements are distinguishable if (a) they have unrelated types or (b)
-- they have related types but different names.
overriding function Namespace
(Self : not null access constant UML_Actor_Proxy)
return AMF.UML.Namespaces.UML_Namespace_Access;
-- Operation NamedElement::namespace.
--
-- Missing derivation for NamedElement::/namespace : Namespace
overriding function Conforms_To
(Self : not null access constant UML_Actor_Proxy;
Other : AMF.UML.Types.UML_Type_Access)
return Boolean;
-- Operation Type::conformsTo.
--
-- The query conformsTo() gives true for a type that conforms to another.
-- By default, two types do not conform to each other. This query is
-- intended to be redefined for specific conformance situations.
overriding function Is_Compatible_With
(Self : not null access constant UML_Actor_Proxy;
P : AMF.UML.Parameterable_Elements.UML_Parameterable_Element_Access)
return Boolean;
-- Operation ParameterableElement::isCompatibleWith.
--
-- The query isCompatibleWith() determines if this parameterable element
-- is compatible with the specified parameterable element. By default
-- parameterable element P is compatible with parameterable element Q if
-- the kind of P is the same or a subtype as the kind of Q. Subclasses
-- should override this operation to specify different compatibility
-- constraints.
overriding function Is_Template_Parameter
(Self : not null access constant UML_Actor_Proxy)
return Boolean;
-- Operation ParameterableElement::isTemplateParameter.
--
-- The query isTemplateParameter() determines if this parameterable
-- element is exposed as a formal template parameter.
overriding function Parameterable_Elements
(Self : not null access constant UML_Actor_Proxy)
return AMF.UML.Parameterable_Elements.Collections.Set_Of_UML_Parameterable_Element;
-- Operation TemplateableElement::parameterableElements.
--
-- The query parameterableElements() returns the set of elements that may
-- be used as the parametered elements for a template parameter of this
-- templateable element. By default, this set includes all the owned
-- elements. Subclasses may override this operation if they choose to
-- restrict the set of parameterable elements.
overriding function Is_Consistent_With
(Self : not null access constant UML_Actor_Proxy;
Redefinee : AMF.UML.Redefinable_Elements.UML_Redefinable_Element_Access)
return Boolean;
-- Operation RedefinableElement::isConsistentWith.
--
-- The query isConsistentWith() specifies, for any two RedefinableElements
-- in a context in which redefinition is possible, whether redefinition
-- would be logically consistent. By default, this is false; this
-- operation must be overridden for subclasses of RedefinableElement to
-- define the consistency conditions.
overriding function Is_Redefinition_Context_Valid
(Self : not null access constant UML_Actor_Proxy;
Redefined : AMF.UML.Redefinable_Elements.UML_Redefinable_Element_Access)
return Boolean;
-- Operation RedefinableElement::isRedefinitionContextValid.
--
-- The query isRedefinitionContextValid() specifies whether the
-- redefinition contexts of this RedefinableElement are properly related
-- to the redefinition contexts of the specified RedefinableElement to
-- allow this element to redefine the other. By default at least one of
-- the redefinition contexts of this element must be a specialization of
-- at least one of the redefinition contexts of the specified element.
overriding procedure Enter_Element
(Self : not null access constant UML_Actor_Proxy;
Visitor : in out AMF.Visitors.Abstract_Visitor'Class;
Control : in out AMF.Visitors.Traverse_Control);
-- Dispatch call to corresponding subprogram of visitor interface.
overriding procedure Leave_Element
(Self : not null access constant UML_Actor_Proxy;
Visitor : in out AMF.Visitors.Abstract_Visitor'Class;
Control : in out AMF.Visitors.Traverse_Control);
-- Dispatch call to corresponding subprogram of visitor interface.
overriding procedure Visit_Element
(Self : not null access constant UML_Actor_Proxy;
Iterator : in out AMF.Visitors.Abstract_Iterator'Class;
Visitor : in out AMF.Visitors.Abstract_Visitor'Class;
Control : in out AMF.Visitors.Traverse_Control);
-- Dispatch call to corresponding subprogram of iterator interface.
end AMF.Internals.UML_Actors;
|
AdaCore/libadalang | Ada | 334 | adb | separate (Pkg)
package body Inner is
procedure Proc is
Y : Integer := X;
pragma Test_Statement;
Inst : Kikou := (Lol => 12);
pragma Test_Statement;
Pouet : T;
I : Float := Z;
pragma Test_Statement;
begin
Pouet.Obj := 12;
pragma Test_Statement;
end Proc;
end Inner;
|
zhmu/ananas | Ada | 290 | adb | -- { dg-do compile }
with Interfaces.C; use Interfaces.C;
procedure Object_Overflow2 is
procedure Proc (x : Boolean) is begin null; end;
type Arr is array(0 .. ptrdiff_t'Last) of Boolean;
Obj : Arr; -- { dg-warning "Storage_Error" }
begin
Obj(1) := True;
Proc (Obj(1));
end;
|
zhmu/ananas | Ada | 5,421 | adb | ------------------------------------------------------------------------------
-- --
-- GNAT LIBRARY COMPONENTS --
-- --
-- ADA.CONTAINERS.BOUNDED_SYNCHRONIZED_QUEUES --
-- --
-- B o d y --
-- --
-- Copyright (C) 2011-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/>. --
-- --
-- This unit was originally developed by Matthew J Heaney. --
------------------------------------------------------------------------------
package body Ada.Containers.Bounded_Synchronized_Queues with
SPARK_Mode => Off
is
package body Implementation is
-------------
-- Dequeue --
-------------
procedure Dequeue
(List : in out List_Type;
Element : out Queue_Interfaces.Element_Type)
is
EE : Element_Array renames List.Elements;
begin
Element := EE (List.First);
List.Length := List.Length - 1;
if List.Length = 0 then
List.First := 0;
List.Last := 0;
elsif List.First <= List.Last then
List.First := List.First + 1;
else
List.First := List.First + 1;
if List.First > List.Capacity then
List.First := 1;
end if;
end if;
end Dequeue;
-------------
-- Enqueue --
-------------
procedure Enqueue
(List : in out List_Type;
New_Item : Queue_Interfaces.Element_Type)
is
begin
if List.Length >= List.Capacity then
raise Capacity_Error with "No capacity for insertion";
end if;
if List.Length = 0 then
List.Elements (1) := New_Item;
List.First := 1;
List.Last := 1;
elsif List.First <= List.Last then
if List.Last < List.Capacity then
List.Elements (List.Last + 1) := New_Item;
List.Last := List.Last + 1;
else
List.Elements (1) := New_Item;
List.Last := 1;
end if;
else
List.Elements (List.Last + 1) := New_Item;
List.Last := List.Last + 1;
end if;
List.Length := List.Length + 1;
if List.Length > List.Max_Length then
List.Max_Length := List.Length;
end if;
end Enqueue;
------------
-- Length --
------------
function Length (List : List_Type) return Count_Type is
begin
return List.Length;
end Length;
----------------
-- Max_Length --
----------------
function Max_Length (List : List_Type) return Count_Type is
begin
return List.Max_Length;
end Max_Length;
end Implementation;
protected body Queue is
-----------------
-- Current_Use --
-----------------
function Current_Use return Count_Type is
begin
return List.Length;
end Current_Use;
-------------
-- Dequeue --
-------------
entry Dequeue (Element : out Queue_Interfaces.Element_Type)
when List.Length > 0
is
begin
List.Dequeue (Element);
end Dequeue;
-------------
-- Enqueue --
-------------
entry Enqueue (New_Item : Queue_Interfaces.Element_Type)
when List.Length < Capacity
is
begin
List.Enqueue (New_Item);
end Enqueue;
--------------
-- Peak_Use --
--------------
function Peak_Use return Count_Type is
begin
return List.Max_Length;
end Peak_Use;
end Queue;
end Ada.Containers.Bounded_Synchronized_Queues;
|
nerilex/ada-util | Ada | 3,335 | adb | -----------------------------------------------------------------------
-- csv_city -- Read CSV file which contains city mapping
-- Copyright (C) 2011 Stephane Carrez
-- Written by Stephane Carrez ([email protected])
--
-- Licensed under the Apache License, Version 2.0 (the "License");
-- you may not use this file except in compliance with the License.
-- You may obtain a copy of the License at
--
-- http://www.apache.org/licenses/LICENSE-2.0
--
-- Unless required by applicable law or agreed to in writing, software
-- distributed under the License is distributed on an "AS IS" BASIS,
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-- See the License for the specific language governing permissions and
-- limitations under the License.
-----------------------------------------------------------------------
with Ada.Text_IO;
with Ada.Command_Line;
with Ada.Containers;
with Ada.Strings.Unbounded;
with Util.Log.Loggers;
with Util.Serialize.IO.CSV;
with City_Mapping;
procedure CSV_City is
use Ada.Containers;
use Ada.Strings.Unbounded;
use Ada.Text_IO;
use Util.Serialize.IO.CSV;
Count : constant Natural := Ada.Command_Line.Argument_Count;
begin
Util.Log.Loggers.Initialize ("samples/log4j.properties");
if Count = 0 then
Ada.Text_IO.Put_Line ("Usage: csv_city file [city...]");
Ada.Text_IO.Put_Line ("Example: csv_city samples/cities.csv albertville");
return;
end if;
declare
File : constant String := Ada.Command_Line.Argument (1);
List : aliased City_Mapping.City_Vector.Vector;
Reader : Util.Serialize.IO.CSV.Parser;
begin
Reader.Add_Mapping ("", City_Mapping.Get_City_Vector_Mapper.all'Access);
City_Mapping.City_Vector_Mapper.Set_Context (Reader, List'Unchecked_Access);
Reader.Parse (File);
if List.Length = 0 then
Ada.Text_IO.Put_Line ("No city found.");
elsif List.Length = 1 then
Ada.Text_IO.Put_Line ("Found only one city.");
else
Ada.Text_IO.Put_Line ("Found " & Count_Type'Image (List.Length) & " cities");
end if;
for I in 2 .. Count loop
declare
Name : constant String := Ada.Command_Line.Argument (I);
Found : Boolean := False;
procedure Print (City : in City_Mapping.City);
procedure Print (City : in City_Mapping.City) is
begin
Found := City.City = Name;
if Found then
Ada.Text_IO.Put_Line ("City : " & To_String (City.Name));
Ada.Text_IO.Put_Line ("Country code: " & To_String (City.Country));
Ada.Text_IO.Put_Line ("Region : " & To_String (City.Region));
Ada.Text_IO.Put_Line ("Latitude : " & Float'Image (City.Latitude));
Ada.Text_IO.Put_Line ("Longitude : " & Float'Image (City.Longitude));
end if;
end Print;
begin
for J in 1 .. Positive (List.Length) loop
List.Query_Element (J, Print'Access);
exit when Found;
end loop;
if not Found then
Ada.Text_IO.Put_Line ("City '" & Name & "' not found");
end if;
end;
end loop;
end;
end CSV_City;
|
jrcarter/Ada_GUI | Ada | 32,398 | adb | -- --
-- package Copyright (c) Dmitry A. Kazakov --
-- GNAT.Sockets.Connection_State_Machine Luebeck --
-- Implementation Winter, 2012 --
-- --
-- Last revision : 13:13 14 Sep 2019 --
-- --
-- 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.Exceptions; use Ada.Exceptions;
with Ada.IO_Exceptions; use Ada.IO_Exceptions;
with Ada.Tags; use Ada.Tags;
with Strings_Edit.Integers; use Strings_Edit.Integers;
with Ada.Unchecked_Deallocation;
with Ada.Containers.Ordered_Maps; -- Changed to use standard library by J. Carter 2021
with System.Address_Image;
with System.Address_To_Access_Conversions;
package body GNAT.Sockets.Connection_State_Machine is
procedure Check_Initialization_Stream
( Item : Data_Item'Class;
Stream : Root_Stream_Type'Class
) is
begin
if Stream not in Initialization_Stream'Class then
Raise_Exception
( Use_Error'Identity,
( "Stream attribute of "
& Expanded_Name (Item'Tag)
& " used with a non-initialization stream "
& Expanded_Name (Stream'Tag)
) );
end if;
end Check_Initialization_Stream;
procedure Generic_Dump_Stream
( Stream : Initialization_Stream'Class;
Prefix : String := ""
) is
use Strings_Edit;
Trailer : constant String (Prefix'Range) := (others => ' ');
begin
Put_Line
( Prefix
& "stream at "
& System.Address_Image (Stream'Address)
& " items: "
& Image (Integer (Stream.Count))
& ", to ignore next: "
& Image (Integer (Stream.Ignore))
);
for Index in 1..Stream.Count loop
Put_Line
( Trailer
& Image (Integer (Index))
& " "
& Ada.Tags.Expanded_Name (Get (Stream.Data, Index).all'Tag)
& " at "
& System.Address_Image (Get (Stream.Data, Index).all'Address)
);
end loop;
end Generic_Dump_Stream;
package body Generic_Dump is
procedure Put is new Generic_Dump_Stream;
procedure Put
( Item : Data_Item'Class;
Prefix : String := ""
) is
begin
Put_Line
( Prefix
& Ada.Tags.Expanded_Name (Item'Tag)
& " at "
& System.Address_Image (Item'Address)
);
declare
Nested : constant Data_Item_Ptr_Array := Get_Children (Item);
begin
if Nested'Length > 0 then
declare
Trailer : constant String (Prefix'Range) :=
(others => ' ');
begin
for Index in Nested'Range loop
Put
( Nested (Index).all,
Trailer & " " & Image (Integer (Index)) & " "
);
end loop;
end;
end if;
end;
end Put;
procedure Put
( Buffer : in out External_String_Buffer;
Prefix : String
) is
Trailer : constant String (Prefix'Range) := (others => ' ');
This : Allocator_Data_Ptr := Buffer.Allocators;
begin
Put_Line
( Prefix
& "external buffer at "
& System.Address_Image (Buffer'Address)
& " allocators: "
);
for Index in Positive'Range loop
exit when This = null;
Put
( Trailer
& " "
& Image (Index)
& " at "
& System.Address_Image (This.all'Address)
);
Put_Line
( " -> "
& Ada.Tags.Expanded_Name (This.Allocator.all'Tag)
& " at "
& System.Address_Image (This.Allocator.all'Address)
);
This := This.Previous;
end loop;
end Put;
procedure Put_Stream
( Item : Data_Item'Class;
Prefix : String := ""
) is
Buffer : aliased External_String_Buffer (64);
Stream : aliased Initialization_Stream;
begin
Stream.Shared := Buffer'Unchecked_Access;
Data_Item'Class'Write (Stream'Access, Item);
Put (Stream, Prefix);
end Put_Stream;
procedure Put_Call_Stack
( Client : State_Machine'Class;
Prefix : String := ""
) is
Depth : Natural := 0;
This : Sequence_Ptr := Client.Data;
begin
while This /= null loop
Depth := Depth + 1;
This := This.Caller;
end loop;
declare
Stack : Sequence_Array (1..Depth);
procedure Dump
( Start : Positive;
Prefix : String
) is
This : Sequence renames Stack (Start).all;
List : Data_Item_Ptr_Array renames This.List;
begin
for Index in List'Range loop
if Index = This.Current then
Put_Line
( Prefix
& "->"
& Image (Integer (Index))
& " "
& Ada.Tags.Expanded_Name (List (Index).all'Tag)
);
if Start < Stack'Last then
Dump (Start + 1, Prefix & " ");
end if;
else
Put_Line
( Prefix
& " "
& Image (Integer (Index))
& " "
& Ada.Tags.Expanded_Name (List (Index).all'Tag)
);
end if;
end loop;
end Dump;
begin
This := Client.Data;
for Index in reverse Stack'Range loop
Stack (Index) := This;
This := This.Caller;
end loop;
Put_Line (Prefix & Ada.Tags.Expanded_Name (Client'Tag));
Dump (1, Prefix & " ");
end;
end Put_Call_Stack;
end Generic_Dump;
package Address_Maps Is new Ada.Containers.Ordered_Maps
(Key_Type => System.Address, Element_Type => Natural, "<" => System."<");
Prefixes : Address_Maps.Map;
function Get_Prefix
( Stream : Root_Stream_Type'Class
) return String is
begin
if Prefixes.Contains (Stream'Address) then
declare
Result : constant String := (1 .. Prefixes.Element (Stream'Address) => ' ');
begin
return Result & System.Address_Image (Stream'Address) & ' ';
end;
else
return "";
end if;
end Get_Prefix;
procedure Set_Prefix
( Stream : Root_Stream_Type'Class;
Prefix : Natural
) is
begin
Prefixes.Include (Key => Stream'Address, New_Item => Prefix);
end Set_Prefix;
procedure Add
( Stream : in out Initialization_Stream;
Item : Data_Item'Class;
Nested : Data_Item_Offset := 0
) is
begin
if Stream.Ignore > 0 then
Stream.Ignore := Stream.Ignore - 1;
else
Stream.Count := Stream.Count + 1;
Put (Stream.Data, Stream.Count, Self (Item));
end if;
Stream.Ignore := Stream.Ignore + Nested;
end Add;
procedure Allocate
( Pool : in out Arena_Pool;
Address : out System.Address;
Size : Storage_Count;
Alignment : Storage_Count
) is
Size_In_Characters : constant Storage_Count :=
( (Size * System.Storage_Unit + Character'Size - 1)
/ Character'Size
);
Length : Natural renames Pool.Parent.Length;
Buffer : String renames Pool.Parent.Buffer;
Last : Integer;
begin
Align_To_The_Margin :
for Index in 1..Alignment loop
exit when Length >= Buffer'Last;
if Buffer (Length + 1)'Address mod Alignment = 0 then
Last := Length + Natural (Size_In_Characters);
loop
exit Align_To_The_Margin when Last >= Buffer'Last;
exit when ( ( Buffer (Last + 1)'Address
- Buffer (Length + 1)'Address
)
<= Size
);
Last := Last + 1;
end loop;
Address := Buffer (Length + 1)'Address;
Length := Last + 1;
Pool.Parent.Count := Pool.Parent.Count + 1;
return;
end if;
Length := Length + 1;
end loop Align_To_The_Margin;
Raise_Exception
( Storage_Error'Identity,
( "Arena pool exhausted, "
& Image (Length)
& " used out of "
& Image (Buffer'Last)
& ", items allocated "
& Image (Pool.Parent.Count)
) );
end Allocate;
procedure Call
( Client : in out State_Machine;
Pointer : Stream_Element_Offset;
Data : Sequence_Ptr;
State : Stream_Element_Offset := 0
) is
begin
Client.Fed := Client.Fed + Unsigned_64 (Pointer - Client.Start);
Client.Start := Pointer;
Data.Caller := Client.Data;
Client.Data := Data;
Data.Current := 0;
Data.State := State;
end Call;
procedure Connected (Client : in out State_Machine) is
Stream : aliased Initialization_Stream;
begin
Initialize (Connection (Client));
State_Machine'Class'Write
( Stream'Access,
State_Machine'Class (Client)
);
Free (Client.Data);
if Stream.Count > 0 then
Client.Data :=
new Sequence'
( Length => Stream.Count,
Caller => null,
State => 0,
Current => 1,
List => Stream.Data.Vector (1..Stream.Count)
);
end if;
end Connected;
procedure Deallocate
( Pool : in out Arena_Pool;
Address : System.Address;
Size : Storage_Count;
Alignment : Storage_Count
) is
begin
null;
end Deallocate;
procedure End_Of_Subsequence
( Item : in out Data_Item;
Data : Stream_Element_Array;
Pointer : Stream_Element_Offset;
Client : in out State_Machine'Class;
State : in out Stream_Element_Offset
) is
begin
null;
end End_Of_Subsequence;
procedure Enumerate
( Stream : access Root_Stream_Type'Class;
Pool : Arena_Pool
) is
begin
null;
end Enumerate;
procedure Enumerate
( Stream : access Root_Stream_Type'Class;
Item : State_Machine
) is
begin
null;
end Enumerate;
procedure Enumerate
( Stream : access Root_Stream_Type'Class;
Item : Data_Block
) is
begin
Check_Initialization_Stream (Item, Stream.all);
declare
Count : Data_Item_Offset := 0;
Block : Data_Block'Class renames Self (Item).all;
This : Initialization_Stream'Class renames
Initialization_Stream'Class (Stream.all);
begin
if not Item.Initialized then
declare
Counter : aliased Initialization_Stream;
begin
if This.Parent = null then
Counter.Parent := This.Shared'Access;
else
Counter.Parent := This.Parent;
end if;
Block.Initialized := True;
Data_Block'Class'Write (Counter'Access, Block);
if Counter.Count <= 1 then
Raise_Exception
( Use_Error'Identity,
( "Block "
& Expanded_Name (Block'Tag)
& " is empty (contains no items)"
) );
end if;
Self (Item).Data :=
new Sequence'
( Length => Counter.Count - 1,
Caller => null,
State => 0,
Current => 1,
List => Counter.Data.Vector
( 2
.. Counter.Count
) );
Count := Data_Item_Offset (Get_Size (Item)) - 1;
end;
end if;
Add (This, Item, Count);
end;
end Enumerate;
procedure Enumerate
( Stream : access Root_Stream_Type'Class;
Item : Data_Item
) is
begin
Check_Initialization_Stream (Item, Stream.all);
declare
This : Initialization_Stream'Class renames
Initialization_Stream'Class (Stream.all);
begin
Add (This, Item);
end;
end Enumerate;
procedure Enumerate
( Stream : access Root_Stream_Type'Class;
Item : Data_Selector
) is
begin
Check_Initialization_Stream (Item, Stream.all);
declare
Selector : Data_Selector'Class renames
Self (Data_Selector'Class (Item)).all;
Count : Data_Item_Offset := 0;
This : Initialization_Stream'Class renames
Initialization_Stream'Class (Stream.all);
begin
if not Selector.Initialized then
Selector.Initialized := True;
declare
Counter : aliased Initialization_Stream;
begin
Selector.Initialized := True;
Data_Selector'Class'Write (Counter'Access, Selector);
if Counter.Count <= 1 then
Raise_Exception
( Use_Error'Identity,
( "Selector "
& Expanded_Name (Data_Item'Class (Item)'Tag)
& " contains no alternatives"
) );
end if;
Selector.Alternatives :=
new Alternatives_List
( Natural (Counter.Count)
- 1
);
declare
This : Data_Item_Ptr;
List : Sequence_Array renames
Item.Alternatives.List;
begin
for Index in List'Range loop
This :=
Get
( Counter.Data,
Data_Item_Offset (Index) + 1
);
List (Index) :=
new Sequence'
( Length => 1,
Caller => null,
State => 0,
Current => 1,
List => (1 => This)
);
end loop;
end;
Count := Data_Item_Offset (Get_Size (Item)) - 1;
end;
end if;
Add (This, Item, Count);
end;
end Enumerate;
procedure Enumerate
( Stream : access Root_Stream_Type'Class;
Item : Shared_Data_Item
) is
begin
Check_Initialization_Stream (Item, Stream.all);
declare
This : Initialization_Stream'Class renames
Initialization_Stream'Class (Stream.all);
begin
if not Item.Initialized then
declare
Shared : Shared_Data_Item'Class renames
Self (Item).all;
begin
Shared.Initialized := True;
Shared.Previous := This.Shared;
This.Shared := Shared'Unchecked_Access;
end;
end if;
Add (This, Item);
end;
end Enumerate;
procedure Erase (Buffer : in out External_String_Buffer) is
This : Allocator_Data_Ptr := Buffer.Allocators;
Next : Allocator_Data_Ptr;
begin
while This /= null loop
Next := This.Previous;
This.Previous := null;
Freed (This.Allocator.all);
This := Next;
end loop;
Buffer.Length := 0;
Buffer.Count := 0;
Buffer.Allocators := null;
end Erase;
procedure External_Initialize
( Item : Data_Item'Class;
Shared : Shared_Data_Item_Ptr := null
) is
Stream : aliased Initialization_Stream;
begin
Stream.Shared := Shared;
Data_Item'Class'Write (Stream'Access, Item);
end External_Initialize;
procedure Feed
( Item : in out Shared_Data_Item;
Data : Stream_Element_Array;
Pointer : in out Stream_Element_Offset;
Client : in out State_Machine'Class;
State : in out Stream_Element_Offset
) is
begin
State := 0;
end Feed;
procedure Feed
( Item : in out External_String_Buffer;
Data : Stream_Element_Array;
Pointer : in out Stream_Element_Offset;
Client : in out State_Machine'Class;
State : in out Stream_Element_Offset
) is
begin
Erase (Item); -- Erase the buffer
Feed (Shared_Data_Item (Item), Data, Pointer, Client, State);
end Feed;
procedure Feed
( Item : in out Data_Block;
Data : Stream_Element_Array;
Pointer : in out Stream_Element_Offset;
Client : in out State_Machine'Class;
State : in out Stream_Element_Offset
) is
begin
Call (Client, Pointer, Item.Data);
State := 0;
end Feed;
procedure Feed
( Item : in out Data_Null;
Data : Stream_Element_Array;
Pointer : in out Stream_Element_Offset;
Client : in out State_Machine'Class;
State : in out Stream_Element_Offset
) is
begin
State := 0;
end Feed;
procedure Feed
( Item : in out Data_Selector;
Data : Stream_Element_Array;
Pointer : in out Stream_Element_Offset;
Client : in out State_Machine'Class;
State : in out Stream_Element_Offset
) is
begin
Call (Client, Pointer, Item.Alternatives.List (Item.Current));
State := 0;
end Feed;
procedure Finalize (Client : in out State_Machine) is
begin
if Client.Data /= null then
while Client.Data.Caller /= null loop
Client.Data := Client.Data.Caller;
end loop;
Free (Client.Data);
end if;
Finalize (Connection (Client));
end Finalize;
procedure Finalize (Item : in out Data_Block) is
begin
Free (Item.Data);
end Finalize;
procedure Finalize (Item : in out Data_Selector) is
procedure Free is
new Ada.Unchecked_Deallocation
( Alternatives_List,
Alternatives_List_Ptr
);
begin
if Item.Alternatives /= null then
declare
List : Sequence_Array renames Item.Alternatives.List;
begin
for Index in List'Range loop
Free (List (Index));
end loop;
end;
Free (Item.Alternatives);
end if;
end Finalize;
procedure Finalize (Buffer : in out External_String_Buffer) is
begin
Erase (Buffer);
Buffer.Allocators := null;
Finalize (Shared_Data_Item (Buffer));
end Finalize;
procedure Freed (Item : in out Data_Item) is
begin
null;
end Freed;
package From_Block_Address is
new System.Address_To_Access_Conversions (Data_Block'Class);
package From_Item_Address is
new System.Address_To_Access_Conversions (Data_Item'Class);
package From_Selector_Address is
new System.Address_To_Access_Conversions (Data_Selector'Class);
package From_Shared_Item_Address is
new System.Address_To_Access_Conversions (Shared_Data_Item'Class);
function Get_Alternative (Item : Data_Selector) return Positive is
begin
return Item.Current;
end Get_Alternative;
function Get_Alternatives_Number (Item : Data_Selector)
return Positive is
begin
if not Item.Initialized or else Item.Alternatives = null then
Raise_Exception
( Use_Error'Identity,
( "Selector "
& Expanded_Name (Data_Item'Class (Item)'Tag)
& " was not properly initialized"
) );
end if;
return Positive (Item.Alternatives.Size);
end Get_Alternatives_Number;
function Get_Children
( Item : Data_Item
) return Data_Item_Ptr_Array is
begin
return (1..0 => null);
end Get_Children;
function Get_Children
( Item : Data_Block
) return Data_Item_Ptr_Array is
Length : Data_Item_Offset := 0;
begin
if not Item.Initialized or else Item.Data = null then
Raise_Exception
( Use_Error'Identity,
( "Block "
& Expanded_Name (Data_Item'Class (Item)'Tag)
& " was not properly initialized"
) );
end if;
return Item.Data.List;
end Get_Children;
function Get_Children
( Item : Data_Selector
) return Data_Item_Ptr_Array is
Length : Data_Item_Offset := 0;
begin
if not Item.Initialized or else Item.Alternatives = null then
Raise_Exception
( Use_Error'Identity,
( "Selector "
& Expanded_Name (Data_Item'Class (Item)'Tag)
& " was not properly initialized"
) );
end if;
for Index in Item.Alternatives.List'Range loop
Length := Length + Item.Alternatives.List (Index).List'Length;
end loop;
declare
Result : Data_Item_Ptr_Array (1..Length);
No : Data_Item_Address := 1;
begin
for Index in Item.Alternatives.List'Range loop
declare
Alternative : Data_Item_Ptr_Array renames
Item.Alternatives.List (Index).List;
begin
Result (No..No + Alternative'Length - 1) := Alternative;
No := No + Alternative'Length;
end;
end loop;
return Result;
end;
end Get_Children;
function Get_Length (Item : Data_Block) return Positive is
begin
if not Item.Initialized or else Item.Data = null then
Raise_Exception
( Use_Error'Identity,
( "Block "
& Expanded_Name (Data_Item'Class (Item)'Tag)
& " was not properly initialized"
) );
end if;
return Positive (Item.Data.Length);
end Get_Length;
function Get_Size (Item : Data_Block) return Natural is
begin
if not Item.Initialized or else Item.Data = null then
Raise_Exception
( Use_Error'Identity,
( "Block "
& Expanded_Name (Data_Item'Class (Item)'Tag)
& " was not properly initialized"
) );
end if;
declare
Result : Natural := 1;
List : Data_Item_Ptr_Array renames Item.Data.List;
begin
for Index in List'Range loop
Result := Result + Get_Size (List (Index).all);
end loop;
return Result;
end;
end Get_Size;
function Get_Size (Item : Data_Item) return Natural is
begin
return 1;
end Get_Size;
function Get_Size (Item : Data_Selector) return Natural is
begin
if not Item.Initialized or else Item.Alternatives = null then
Raise_Exception
( Use_Error'Identity,
( "Selector "
& Expanded_Name (Data_Item'Class (Item)'Tag)
& " was not properly initialized"
) );
end if;
declare
Result : Natural := 1;
Sequence : Sequence_Array renames Item.Alternatives.List;
begin
for Index in Sequence'Range loop
declare
List : Data_Item_Ptr_Array renames Sequence (Index).List;
begin
for Index in List'Range loop
Result := Result + Get_Size (List (Index).all);
end loop;
end;
end loop;
return Result;
end;
end Get_Size;
procedure Read
( Stream : in out Initialization_Stream;
Item : out Stream_Element_Array;
Last : out Stream_Element_Offset
) is
begin
Last := Item'Last;
end Read;
procedure Received
( Client : in out State_Machine;
Data : Stream_Element_Array;
Pointer : in out Stream_Element_Offset
) is
begin
Pointer := Data'First;
while Pointer <= Data'Last loop
Client.Start := Pointer;
Feed
( Client.Data.List (Client.Data.Current).all,
Data,
Pointer,
Client,
Client.State
);
Client.Fed :=
Client.Fed + Unsigned_64 (Pointer - Client.Start);
if Client.State = 0 then -- Done with this item
Client.Data.Current := Client.Data.Current + 1;
while Client.Data.Current > Client.Data.Length loop
if Client.Data.Caller = null then
Client.Data.Current := 1;
Process_Packet (State_Machine'Class (Client));
exit;
end if;
Client.State := Client.Data.State; -- Restore state
Client.Data := Client.Data.Caller;
if Client.State /= 0 then
End_Of_Subsequence
( Client.Data.List (Client.Data.Current).all,
Data,
Pointer,
Client,
Client.State
);
exit when Client.State /= 0;
end if;
Client.Data.Current := Client.Data.Current + 1;
end loop;
else
exit when Pointer > Data'Last; -- All data consumed
Raise_Exception
( Status_Error'Identity,
( "Unprocessed data left when after return from "
& Expanded_Name
( Client.Data.List
( Client.Data.Current
) .all'Tag
) ) );
end if;
end loop;
end Received;
function Self (Item : Data_Block'Class) return Data_Block_Ptr is
use From_Block_Address;
begin
return To_Pointer (Item'Address).all'Unchecked_Access;
end Self;
function Self (Item : Data_Item'Class) return Data_Item_Ptr is
use From_Item_Address;
begin
return To_Pointer (Item'Address).all'Unchecked_Access;
end Self;
function Self (Item : Data_Selector'Class)
return Data_Selector_Ptr is
use From_Selector_Address;
begin
return To_Pointer (Item'Address).all'Unchecked_Access;
end Self;
function Self (Item : Shared_Data_Item'Class)
return Shared_Data_Item_Ptr is
use From_Shared_Item_Address;
begin
return To_Pointer (Item'Address).all'Unchecked_Access;
end Self;
procedure Set_Alternative
( Item : in out Data_Selector;
Alternative : Positive
) is
begin
if Alternative > Get_Alternatives_Number (Item) then
Raise_Exception
( Constraint_Error'Identity,
( "Invalid alternative number of selector "
& Expanded_Name (Data_Item'Class (Item)'Tag)
) );
end if;
Item.Current := Alternative;
end Set_Alternative;
function Storage_Size
( Pool : Arena_Pool
) return Storage_Count is
begin
return Pool.Parent.Buffer'Size / System.Storage_Unit;
end Storage_Size;
function To_Integer (Value : Unsigned_8) return Integer_8 is
begin
if Value < 2**7 then
return Integer_8 (Value);
else
return Integer_8 (not Value) - 1;
end if;
end To_Integer;
function To_Integer (Value : Unsigned_16) return Integer_16 is
begin
if Value < 2**15 then
return Integer_16 (Value);
else
return Integer_16 (not Value) - 1;
end if;
end To_Integer;
function To_Integer (Value : Unsigned_32) return Integer_32 is
begin
if Value < 2**31 then
return Integer_32 (Value);
else
return Integer_32 (not Value) - 1;
end if;
end To_Integer;
function To_Integer (Value : Unsigned_64) return Integer_64 is
begin
if Value < 2**63 then
return Integer_64 (Value);
else
return Integer_64 (not Value) - 1;
end if;
end To_Integer;
function To_Unsigned (Value : Integer_8) return Unsigned_8 is
begin
if Value >= 0 then
return Unsigned_8 (Value);
else
return not Unsigned_8 (-(Value + 1));
end if;
end To_Unsigned;
function To_Unsigned (Value : Integer_16) return Unsigned_16 is
begin
if Value >= 0 then
return Unsigned_16 (Value);
else
return not Unsigned_16 (-(Value + 1));
end if;
end To_Unsigned;
function To_Unsigned (Value : Integer_32) return Unsigned_32 is
begin
if Value >= 0 then
return Unsigned_32 (Value);
else
return not Unsigned_32 (-(Value + 1));
end if;
end To_Unsigned;
function To_Unsigned (Value : Integer_64) return Unsigned_64 is
begin
if Value >= 0 then
return Unsigned_64 (Value);
else
return not Unsigned_64 (-(Value + 1));
end if;
end To_Unsigned;
procedure Write
( Stream : in out Initialization_Stream;
Item : Stream_Element_Array
) is
begin
null;
end Write;
end GNAT.Sockets.Connection_State_Machine;
|
Gabriel-Degret/adalib | Ada | 1,366 | 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.Real_Time.Timing_Events is
type Timing_Event is tagged limited private;
type Timing_Event_Handler is
access protected procedure (Event : in out Timing_Event);
procedure Set_Handler (Event : in out Timing_Event;
At_Time : in Time;
Handler : in Timing_Event_Handler);
procedure Set_Handler (Event : in out Timing_Event;
In_Time : in Time_Span;
Handler : in Timing_Event_Handler);
function Current_Handler (Event : in Timing_Event)
return Timing_Event_Handler;
procedure Cancel_Handler (Event : in out Timing_Event;
Cancelled : out Boolean);
function Time_Of_Event (Event : in Timing_Event) return Time;
private
pragma Import (Ada, Timing_Event);
end Ada.Real_Time.Timing_Events;
|
PThierry/ewok-kernel | Ada | 5,480 | adb | --
-- Copyright 2018 The wookey project team <[email protected]>
-- - Ryad Benadjila
-- - Arnauld Michelizza
-- - Mathieu Renard
-- - Philippe Thierry
-- - Philippe Trebuchet
--
-- Licensed under the Apache License, Version 2.0 (the "License");
-- you may not use this file except in compliance with the License.
-- You may obtain a copy of the License at
--
-- http://www.apache.org/licenses/LICENSE-2.0
--
-- Unless required by applicable law or agreed to in writing, software
-- distributed under the License is distributed on an "AS IS" BASIS,
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-- See the License for the specific language governing permissions and
-- limitations under the License.
--
--
with ewok.tasks; use ewok.tasks;
with ewok.tasks_shared; use ewok.tasks_shared;
with ewok.gpio;
with ewok.exti;
with ewok.exported.gpios; use ewok.exported.gpios;
with ewok.sanitize;
package body ewok.syscalls.cfg.gpio
with spark_mode => off
is
procedure svc_gpio_set
(caller_id : in ewok.tasks_shared.t_task_id;
params : in out t_parameters;
mode : in ewok.tasks_shared.t_task_mode)
is
ref : ewok.exported.gpios.t_gpio_ref
with address => params(1)'address;
val : unsigned_8
with address => params(2)'address;
begin
-- Task initialization is complete ?
if not is_init_done (caller_id) then
goto ret_denied;
end if;
-- Valid t_gpio_ref ?
if not ref.pin'valid or not ref.port'valid then
goto ret_inval;
end if;
-- Does that GPIO really belongs to the caller ?
if not ewok.gpio.belong_to (caller_id, ref) then
goto ret_denied;
end if;
-- Write the pin
if val >= 1 then
ewok.gpio.write_pin (ref, 1);
else
ewok.gpio.write_pin (ref, 0);
end if;
set_return_value (caller_id, mode, SYS_E_DONE);
ewok.tasks.set_state (caller_id, mode, TASK_STATE_RUNNABLE);
return;
<<ret_inval>>
set_return_value (caller_id, mode, SYS_E_INVAL);
ewok.tasks.set_state (caller_id, mode, TASK_STATE_RUNNABLE);
return;
<<ret_denied>>
set_return_value (caller_id, mode, SYS_E_DENIED);
ewok.tasks.set_state (caller_id, mode, TASK_STATE_RUNNABLE);
return;
end svc_gpio_set;
procedure svc_gpio_get
(caller_id : in ewok.tasks_shared.t_task_id;
params : in out t_parameters;
mode : in ewok.tasks_shared.t_task_mode)
is
ref : ewok.exported.gpios.t_gpio_ref
with address => params(1)'address;
val : unsigned_8
with address => to_address (params(2));
begin
-- Task initialization is complete ?
if not is_init_done (caller_id) then
goto ret_denied;
end if;
-- Valid t_gpio_ref ?
if not ref.pin'valid or not ref.port'valid then
goto ret_inval;
end if;
-- Does &val is in the caller address space ?
if not ewok.sanitize.is_word_in_data_slot
(to_system_address (val'address), caller_id, mode)
then
goto ret_denied;
end if;
-- Read the pin
val := unsigned_8 (ewok.gpio.read_pin (ref));
set_return_value (caller_id, mode, SYS_E_DONE);
ewok.tasks.set_state (caller_id, mode, TASK_STATE_RUNNABLE);
return;
<<ret_inval>>
set_return_value (caller_id, mode, SYS_E_INVAL);
ewok.tasks.set_state (caller_id, mode, TASK_STATE_RUNNABLE);
return;
<<ret_denied>>
set_return_value (caller_id, mode, SYS_E_DENIED);
ewok.tasks.set_state (caller_id, mode, TASK_STATE_RUNNABLE);
return;
end svc_gpio_get;
-- Unlock EXTI line associated to given GPIO, if the EXTI
-- line has been locked by the kernel (exti lock parameter is
-- set to 'true'.
procedure svc_gpio_unlock_exti
(caller_id : in ewok.tasks_shared.t_task_id;
params : in out t_parameters;
mode : in ewok.tasks_shared.t_task_mode)
is
ref : ewok.exported.gpios.t_gpio_ref
with address => params(1)'address;
cfg : ewok.exported.gpios.t_gpio_config_access;
begin
-- Task initialization is complete ?
if not is_init_done (caller_id) then
goto ret_denied;
end if;
-- Valid t_gpio_ref ?
if not ref.pin'valid or not ref.port'valid then
goto ret_inval;
end if;
-- Does that GPIO really belongs to the caller ?
if not ewok.gpio.belong_to (caller_id, ref) then
goto ret_denied;
end if;
cfg := ewok.gpio.get_config(ref);
-- Does that GPIO has an EXTI line which is lockable ?
if cfg.all.exti_trigger = GPIO_EXTI_TRIGGER_NONE or
cfg.all.exti_lock = GPIO_EXTI_UNLOCKED
then
goto ret_inval;
end if;
ewok.exti.enable(ref);
set_return_value (caller_id, mode, SYS_E_DONE);
ewok.tasks.set_state (caller_id, mode, TASK_STATE_RUNNABLE);
return;
<<ret_inval>>
set_return_value (caller_id, mode, SYS_E_INVAL);
ewok.tasks.set_state (caller_id, mode, TASK_STATE_RUNNABLE);
return;
<<ret_denied>>
set_return_value (caller_id, mode, SYS_E_DENIED);
ewok.tasks.set_state (caller_id, mode, TASK_STATE_RUNNABLE);
return;
end svc_gpio_unlock_exti;
end ewok.syscalls.cfg.gpio;
|
reznikmm/matreshka | Ada | 13,019 | adb | ------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- XML Processor --
-- --
-- Runtime Library Component --
-- --
------------------------------------------------------------------------------
-- --
-- Copyright © 2012, Vadim Godunko <[email protected]> --
-- All rights reserved. --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions --
-- are met: --
-- --
-- * Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- --
-- * Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in the --
-- documentation and/or other materials provided with the distribution. --
-- --
-- * Neither the name of the Vadim Godunko, IE nor the names of its --
-- contributors may be used to endorse or promote products derived from --
-- this software without specific prior written permission. --
-- --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR --
-- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
-- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED --
-- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR --
-- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF --
-- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING --
-- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS --
-- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
-- --
------------------------------------------------------------------------------
-- $Revision$ $Date$
------------------------------------------------------------------------------
with Matreshka.XML_Schema.AST.Models;
with Matreshka.XML_Schema.AST.Namespaces;
with Matreshka.XML_Schema.AST.Types;
with Matreshka.XML_Schema.Named_Maps;
with XML.Schema.Named_Maps.Internals;
with XML.Schema.Element_Declarations.Internals;
with XML.Schema.Objects.Type_Definitions.Internals;
with Matreshka.XML_Schema.AST.Element_Declarations;
package body XML.Schema.Models is
use type Matreshka.XML_Schema.AST.Model_Access;
procedure Common_Get_Components
(Item : Matreshka.XML_Schema.AST.Namespace_Access;
Result : in out Matreshka.XML_Schema.Named_Maps.Named_Map_Access;
Object_Type : Extended_XML_Schema_Component_Type);
function Get_Namespace
(Self : XS_Model'Class;
Namespace : League.Strings.Universal_String)
return Matreshka.XML_Schema.AST.Namespace_Access;
---------------------------
-- Common_Get_Components --
---------------------------
procedure Common_Get_Components
(Item : Matreshka.XML_Schema.AST.Namespace_Access;
Result : in out Matreshka.XML_Schema.Named_Maps.Named_Map_Access;
Object_Type : Extended_XML_Schema_Component_Type) is
begin
case Object_Type is
when Type_Category | Type_Definition =>
declare
package M renames
Matreshka.XML_Schema.AST.Types.Type_Definition_Maps;
Type_Definitions : M.Map renames Item.Type_Definitions;
Pos : M.Cursor := Type_Definitions.First;
begin
while M.Has_Element (Pos) loop
if Object_Type = Type_Definition
or else M.Element (Pos).Get_Type_Category = Object_Type
then
Result.Append
(Matreshka.XML_Schema.AST.Object_Access
(M.Element (Pos)));
end if;
M.Next (Pos);
end loop;
end;
when Element_Declaration =>
declare
package M renames
Matreshka.XML_Schema.AST.Types.Element_Declaration_Maps;
Element_Declarations : M.Map renames Item.Element_Declarations;
Pos : M.Cursor := Element_Declarations.First;
begin
while M.Has_Element (Pos) loop
Result.Append
(Matreshka.XML_Schema.AST.Object_Access (M.Element (Pos)));
M.Next (Pos);
end loop;
end;
when others =>
raise Program_Error;
end case;
end Common_Get_Components;
---------------------
-- Get_Annotations --
---------------------
function Get_Annotations
(Self : XS_Model'Class) return XML.Schema.Object_Lists.XS_Object_List is
begin
raise Program_Error;
return X : XML.Schema.Object_Lists.XS_Object_List;
end Get_Annotations;
-------------------------------
-- Get_Attribute_Declaration --
-------------------------------
function Get_Attribute_Declaration
(Self : XS_Model'Class;
Name : League.Strings.Universal_String;
Namespace : League.Strings.Universal_String)
return XML.Schema.Attribute_Declarations.XS_Attribute_Declaration is
begin
raise Program_Error;
return X : XML.Schema.Attribute_Declarations.XS_Attribute_Declaration;
end Get_Attribute_Declaration;
-------------------------
-- Get_Attribute_Group --
-------------------------
function Get_Attribute_Group
(Self : XS_Model'Class;
Name : League.Strings.Universal_String;
Namespace : League.Strings.Universal_String)
return
XML.Schema.Attribute_Group_Definitions.XS_Attribute_Group_Definition
is
begin
raise Program_Error;
return
X :
XML.Schema.Attribute_Group_Definitions.XS_Attribute_Group_Definition;
end Get_Attribute_Group;
--------------------
-- Get_Components --
--------------------
function Get_Components
(Self : XS_Model'Class;
Object_Type : Extended_XML_Schema_Component_Type)
return XML.Schema.Named_Maps.XS_Named_Map
is
Result : Matreshka.XML_Schema.Named_Maps.Named_Map_Access;
begin
if Self.Node /= null then
Result := new Matreshka.XML_Schema.Named_Maps.Named_Map;
for Item of Self.Node.Namespaces loop
Common_Get_Components (Item, Result, Object_Type);
end loop;
end if;
return XML.Schema.Named_Maps.Internals.Create (Result);
end Get_Components;
---------------------------------
-- Get_Components_By_Namespace --
---------------------------------
function Get_Components_By_Namespace
(Self : XS_Model'Class;
Object_Type : Extended_XML_Schema_Component_Type;
Namespace : League.Strings.Universal_String)
return XML.Schema.Named_Maps.XS_Named_Map
is
use type Matreshka.XML_Schema.AST.Namespace_Access;
-- Lookup for namespace.
Item : constant Matreshka.XML_Schema.AST.Namespace_Access
:= Get_Namespace (Self, Namespace);
Result : Matreshka.XML_Schema.Named_Maps.Named_Map_Access;
begin
if Item /= null then
-- Lookup for components.
Result := new Matreshka.XML_Schema.Named_Maps.Named_Map;
Common_Get_Components (Item, Result, Object_Type);
end if;
return XML.Schema.Named_Maps.Internals.Create (Result);
end Get_Components_By_Namespace;
-----------------------------
-- Get_Element_Declaration --
-----------------------------
function Get_Element_Declaration
(Self : XS_Model'Class;
Name : League.Strings.Universal_String;
Namespace : League.Strings.Universal_String)
return XML.Schema.Element_Declarations.XS_Element_Declaration
is
use type Matreshka.XML_Schema.AST.Namespace_Access;
-- Lookup for namespace.
Item : constant Matreshka.XML_Schema.AST.Namespace_Access
:= Get_Namespace (Self, Namespace);
begin
if Item /= null then
-- Lookup for element declaration.
return
XML.Schema.Element_Declarations.Internals.Create
(Item.Get_Element_Declaration (Name));
end if;
return XML.Schema.Element_Declarations.Null_XS_Element_Declaration;
end Get_Element_Declaration;
--------------------------------
-- Get_Model_Group_Definition --
--------------------------------
function Get_Model_Group_Definition
(Self : XS_Model'Class;
Name : League.Strings.Universal_String;
Namespace : League.Strings.Universal_String)
return XML.Schema.Model_Group_Definitions.XS_Model_Group_Definition is
begin
raise Program_Error;
return X : XML.Schema.Model_Group_Definitions.XS_Model_Group_Definition;
end Get_Model_Group_Definition;
-------------------
-- Get_Namespace --
-------------------
function Get_Namespace
(Self : XS_Model'Class;
Namespace : League.Strings.Universal_String)
return Matreshka.XML_Schema.AST.Namespace_Access is
begin
if Self.Node /= null then
return Self.Node.Get_Namespace (Namespace);
else
return null;
end if;
end Get_Namespace;
-------------------------
-- Get_Namespace_Items --
-------------------------
function Get_Namespace_Items
(Self : XS_Model'Class)
return XML.Schema.Namespace_Item_Lists.XS_Namespace_Item_List is
begin
raise Program_Error;
return X : XML.Schema.Namespace_Item_Lists.XS_Namespace_Item_List;
end Get_Namespace_Items;
--------------------
-- Get_Namespaces --
--------------------
function Get_Namespaces
(Self : XS_Model'Class)
return League.String_Vectors.Universal_String_Vector is
begin
if Self.Node = null then
return League.String_Vectors.Empty_Universal_String_Vector;
end if;
return Result : League.String_Vectors.Universal_String_Vector do
for Item of Self.Node.Namespaces loop
Result.Append (Item.Namespace_URI);
end loop;
end return;
end Get_Namespaces;
------------------------------
-- Get_Notation_Declaration --
------------------------------
function Get_Notation_Declaration
(Self : XS_Model'Class;
Name : League.Strings.Universal_String;
Namespace : League.Strings.Universal_String)
return XML.Schema.Notation_Declarations.XS_Notation_Declaration is
begin
raise Program_Error;
return X : XML.Schema.Notation_Declarations.XS_Notation_Declaration;
end Get_Notation_Declaration;
-------------------------
-- Get_Type_Definition --
-------------------------
function Get_Type_Definition
(Self : XS_Model'Class;
Name : League.Strings.Universal_String;
Namespace : League.Strings.Universal_String)
return XML.Schema.Type_Definitions.XS_Type_Definition
is
use type Matreshka.XML_Schema.AST.Namespace_Access;
Item : constant Matreshka.XML_Schema.AST.Namespace_Access
:= Get_Namespace (Self, Namespace);
begin
if Item /= null then
return
XML.Schema.Objects.Type_Definitions.Internals.Create
(Item.Get_Type_Definition (Name));
end if;
return XML.Schema.Objects.Type_Definitions.Null_XS_Type_Definition;
end Get_Type_Definition;
-------------
-- Is_Null --
-------------
function Is_Null (Self : XS_Model) return Boolean is
begin
return Self.Node = null;
end Is_Null;
end XML.Schema.Models;
|
io7m/coreland-opengl-ada | Ada | 170 | ads | package OpenGL.Check is
GL_Error : exception;
procedure State_OK (Message : in String := "");
procedure Raise_Exception (Message : in String);
end OpenGL.Check;
|
reznikmm/spawn | Ada | 1,607 | ads | --
-- Copyright (C) 2018-2023, AdaCore
--
-- SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
--
with Spawn.Windows_API;
with Spawn.Common;
private
package Spawn.Internal.Windows is
procedure Do_Start_Process
(Self : aliased in out Process'Class;
On_Start : access procedure);
procedure Do_Terminate_Process (Self : in out Process'Class);
procedure Do_Kill_Process (Self : in out Process'Class);
procedure Do_Close_Pipe
(Self : in out Process'Class;
Kind : Pipe_Kinds);
-- Close pipe. Ignore errors if any.
procedure Do_Write
(Self : in out Process'Class;
Data : Ada.Streams.Stream_Element_Array;
Last : out Ada.Streams.Stream_Element_Offset;
On_Has_Data : access procedure);
procedure Do_Read
(Self : in out Process'Class;
Data : out Ada.Streams.Stream_Element_Array;
Last : out Ada.Streams.Stream_Element_Offset;
Kind : Pipe_Kinds;
On_No_Data : access procedure);
procedure On_Process_Died (Self : in out Process'Class);
procedure IO_Callback
(dwErrorCode : Windows_API.DWORD;
dwNumberOfBytesTransfered : Windows_API.DWORD;
lpOverlapped : access Internal.Context;
Kind : Spawn.Common.Standard_Pipe);
-- Implementation shared between Standard_[Input/Output/Error]_Callback
function Error_Message
(dwErrorCode : Spawn.Windows_API.DWORD) return String;
-- Return message for the current error retrived with GetLastError.
end Spawn.Internal.Windows;
|
zhmu/ananas | Ada | 2,457 | ads | ------------------------------------------------------------------------------
-- --
-- GNAT RUN-TIME COMPONENTS --
-- --
-- A D A . W I D E _ T E X T _ I O . M O D U L A R _ I O --
-- --
-- S p e c --
-- --
-- Copyright (C) 1992-2022, Free Software Foundation, Inc. --
-- --
-- This specification is derived from the Ada Reference Manual for use with --
-- GNAT. In accordance with the copyright of that document, you can freely --
-- copy and modify this specification, provided that if you redistribute a --
-- modified version, any changes that you have made are clearly indicated. --
-- --
------------------------------------------------------------------------------
-- In Ada 95, the package Ada.Wide_Text_IO.Modular_IO is a subpackage
-- of Wide_Text_IO. In GNAT we make it a child package to avoid loading
-- the necessary code if Modular_IO is not instantiated. See the routine
-- Rtsfind.Check_Text_IO_Special_Unit for a description of how we patch up
-- the difference in semantics so that it is invisible to the Ada programmer.
private generic
type Num is mod <>;
package Ada.Wide_Text_IO.Modular_IO is
Default_Width : Field := Num'Width;
Default_Base : Number_Base := 10;
procedure Get
(File : File_Type;
Item : out Num;
Width : Field := 0);
procedure Get
(Item : out Num;
Width : Field := 0);
procedure Put
(File : File_Type;
Item : Num;
Width : Field := Default_Width;
Base : Number_Base := Default_Base);
procedure Put
(Item : Num;
Width : Field := Default_Width;
Base : Number_Base := Default_Base);
procedure Get
(From : Wide_String;
Item : out Num;
Last : out Positive);
procedure Put
(To : out Wide_String;
Item : Num;
Base : Number_Base := Default_Base);
end Ada.Wide_Text_IO.Modular_IO;
|
reznikmm/matreshka | Ada | 4,117 | 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.Db_Additional_Column_Statement_Attributes;
package Matreshka.ODF_Db.Additional_Column_Statement_Attributes is
type Db_Additional_Column_Statement_Attribute_Node is
new Matreshka.ODF_Db.Abstract_Db_Attribute_Node
and ODF.DOM.Db_Additional_Column_Statement_Attributes.ODF_Db_Additional_Column_Statement_Attribute
with null record;
overriding function Create
(Parameters : not null access Matreshka.DOM_Attributes.Attribute_L2_Parameters)
return Db_Additional_Column_Statement_Attribute_Node;
overriding function Get_Local_Name
(Self : not null access constant Db_Additional_Column_Statement_Attribute_Node)
return League.Strings.Universal_String;
end Matreshka.ODF_Db.Additional_Column_Statement_Attributes;
|
zhmu/ananas | Ada | 7,827 | ads | ------------------------------------------------------------------------------
-- --
-- GNAT RUN-TIME COMPONENTS --
-- --
-- S Y S T E M --
-- --
-- S p e c --
-- (VxWorks 7 Kernel Version x86_64) --
-- --
-- Copyright (C) 1992-2022, Free Software Foundation, Inc. --
-- --
-- This specification is derived from the Ada Reference Manual for use with --
-- GNAT. The copyright notice above, and the license provisions that follow --
-- apply solely to the contents of the part following the private keyword. --
-- --
-- GNAT is free software; you can redistribute it and/or modify it under --
-- terms of the GNU General Public License as published by the Free Soft- --
-- ware Foundation; either version 3, or (at your option) any later ver- --
-- sion. GNAT is distributed in the hope that it will be useful, but WITH- --
-- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY --
-- or FITNESS FOR A PARTICULAR PURPOSE. --
-- --
-- As a special exception under Section 7 of GPL version 3, you are granted --
-- additional permissions described in the GCC Runtime Library Exception, --
-- version 3.1, as published by the Free Software Foundation. --
-- --
-- You should have received a copy of the GNU General Public License and --
-- a copy of the GCC Runtime Library Exception along with this program; --
-- see the files COPYING3 and COPYING.RUNTIME respectively. If not, see --
-- <http://www.gnu.org/licenses/>. --
-- --
-- GNAT was originally developed by the GNAT team at New York University. --
-- Extensive contributions were provided by Ada Core Technologies Inc. --
-- --
------------------------------------------------------------------------------
package System is
pragma Pure;
-- Note that we take advantage of the implementation permission to make
-- this unit Pure instead of Preelaborable; see RM 13.7.1(15). In Ada
-- 2005, this is Pure in any case (AI-362).
pragma No_Elaboration_Code_All;
-- Allow the use of that restriction in units that WITH this unit
type Name is (SYSTEM_NAME_GNAT);
System_Name : constant Name := SYSTEM_NAME_GNAT;
-- System-Dependent Named Numbers
Min_Int : constant := -2 ** (Standard'Max_Integer_Size - 1);
Max_Int : constant := 2 ** (Standard'Max_Integer_Size - 1) - 1;
Max_Binary_Modulus : constant := 2 ** Standard'Max_Integer_Size;
Max_Nonbinary_Modulus : constant := 2 ** Integer'Size - 1;
Max_Base_Digits : constant := Long_Long_Float'Digits;
Max_Digits : constant := Long_Long_Float'Digits;
Max_Mantissa : constant := Standard'Max_Integer_Size - 1;
Fine_Delta : constant := 2.0 ** (-Max_Mantissa);
Tick : constant := 1.0 / 60.0;
-- Storage-related Declarations
type Address is private;
pragma Preelaborable_Initialization (Address);
Null_Address : constant Address;
Storage_Unit : constant := 8;
Word_Size : constant := 64;
Memory_Size : constant := 2 ** 64;
-- Address comparison
function "<" (Left, Right : Address) return Boolean;
function "<=" (Left, Right : Address) return Boolean;
function ">" (Left, Right : Address) return Boolean;
function ">=" (Left, Right : Address) return Boolean;
function "=" (Left, Right : Address) return Boolean;
pragma Import (Intrinsic, "<");
pragma Import (Intrinsic, "<=");
pragma Import (Intrinsic, ">");
pragma Import (Intrinsic, ">=");
pragma Import (Intrinsic, "=");
-- Other System-Dependent Declarations
type Bit_Order is (High_Order_First, Low_Order_First);
Default_Bit_Order : constant Bit_Order := Low_Order_First;
pragma Warnings (Off, Default_Bit_Order); -- kill constant condition warning
-- Priority-related Declarations (RM D.1)
-- Ada priorities are mapped to VxWorks priorities using the following
-- transformation: 255 - Ada Priority
-- Ada priorities are used as follows:
-- 256 is reserved for the VxWorks kernel
-- 248 - 255 correspond to hardware interrupt levels 0 .. 7
-- 247 is a catchall default "interrupt" priority for signals,
-- allowing higher priority than normal tasks, but lower than
-- hardware priority levels. Protected Object ceilings can
-- override these values.
-- 246 is used by the Interrupt_Manager task
Max_Priority : constant Positive := 245;
Max_Interrupt_Priority : constant Positive := 255;
subtype Any_Priority is Integer range 0 .. 255;
subtype Priority is Any_Priority range 0 .. 245;
subtype Interrupt_Priority is Any_Priority range 246 .. 255;
Default_Priority : constant Priority := 122;
private
type Address is mod Memory_Size;
Null_Address : constant Address := 0;
--------------------------------------
-- System Implementation Parameters --
--------------------------------------
-- These parameters provide information about the target that is used
-- by the compiler. They are in the private part of System, where they
-- can be accessed using the special circuitry in the Targparm unit
-- whose source should be consulted for more detailed descriptions
-- of the individual switch values.
Backend_Divide_Checks : constant Boolean := False;
Backend_Overflow_Checks : constant Boolean := True;
Command_Line_Args : constant Boolean := False;
Configurable_Run_Time : constant Boolean := False;
Denorm : constant Boolean := True;
Duration_32_Bits : constant Boolean := False;
Exit_Status_Supported : constant Boolean := True;
Machine_Overflows : constant Boolean := False;
Machine_Rounds : constant Boolean := True;
Preallocated_Stacks : constant Boolean := False;
Signed_Zeros : constant Boolean := True;
Stack_Check_Default : constant Boolean := False;
Stack_Check_Probes : constant Boolean := True;
Stack_Check_Limits : constant Boolean := False;
Support_Aggregates : constant Boolean := True;
Support_Atomic_Primitives : constant Boolean := True;
Support_Composite_Assign : constant Boolean := True;
Support_Composite_Compare : constant Boolean := True;
Support_Long_Shifts : constant Boolean := True;
Always_Compatible_Rep : constant Boolean := False;
Suppress_Standard_Library : constant Boolean := False;
Use_Ada_Main_Program_Name : constant Boolean := True;
Frontend_Exceptions : constant Boolean := False;
ZCX_By_Default : constant Boolean := True;
Executable_Extension : constant String := ".out";
end System;
|
charlie5/cBound | Ada | 1,602 | 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_is_query_arb_reply_t is
-- Item
--
type Item is record
response_type : aliased Interfaces.Unsigned_8;
pad0 : aliased Interfaces.Unsigned_8;
sequence : aliased Interfaces.Unsigned_16;
length : aliased Interfaces.Unsigned_32;
ret_val : aliased xcb.xcb_glx_bool32_t;
end record;
-- Item_Array
--
type Item_Array is
array
(Interfaces.C
.size_t range <>) of aliased xcb.xcb_glx_is_query_arb_reply_t
.Item;
-- Pointer
--
package C_Pointers is new Interfaces.C.Pointers
(Index => Interfaces.C.size_t,
Element => xcb.xcb_glx_is_query_arb_reply_t.Item,
Element_Array => xcb.xcb_glx_is_query_arb_reply_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_is_query_arb_reply_t
.Pointer;
-- Pointer_Pointer
--
package C_Pointer_Pointers is new Interfaces.C.Pointers
(Index => Interfaces.C.size_t,
Element => xcb.xcb_glx_is_query_arb_reply_t.Pointer,
Element_Array => xcb.xcb_glx_is_query_arb_reply_t.Pointer_Array,
Default_Terminator => null);
subtype Pointer_Pointer is C_Pointer_Pointers.Pointer;
end xcb.xcb_glx_is_query_arb_reply_t;
|
reznikmm/gela | Ada | 4,518 | ads | -- Type manager keeps types found in all compilation units.
with Gela.Types;
with Gela.Lexical_Types;
with Gela.Semantic_Types;
with Gela.Elements.Defining_Names;
with Gela.Elements.Discrete_Subtype_Definitions;
with Gela.Elements.Object_Definitions;
with Gela.Elements.Subtype_Mark_Or_Access_Definitions;
with Gela.Profiles;
package Gela.Type_Managers is
pragma Preelaborate;
type Type_Manager is limited interface;
type Type_Manager_Access is access all Type_Manager'Class;
for Type_Manager_Access'Storage_Size use 0;
not overriding function Get
(Self : access Type_Manager;
Index : Gela.Semantic_Types.Type_View_Index)
return Gela.Types.Type_View_Access is abstract;
-- Get type view by given Index
not overriding function Type_From_Declaration
(Self : access Type_Manager;
Env : Gela.Semantic_Types.Env_Index;
Node : Gela.Elements.Element_Access)
return Gela.Semantic_Types.Type_View_Index is abstract;
-- Return type corresponding to Node of type declaration
not overriding function Type_Of_Object_Declaration
(Self : access Type_Manager;
Env : Gela.Semantic_Types.Env_Index;
Node : Gela.Elements.Element_Access) -- FIXME access Element'Class?
return Gela.Semantic_Types.Type_View_Index is abstract;
-- Return type corresponding to Node of object declaration
not overriding function Type_From_Subtype_Mark
(Self : access Type_Manager;
Env : Gela.Semantic_Types.Env_Index;
Node : access Gela.Elements.Subtype_Mark_Or_Access_Definitions.
Subtype_Mark_Or_Access_Definition'Class)
return Gela.Semantic_Types.Type_View_Index is abstract;
-- Get type view from given subtype mark
not overriding function Type_From_Subtype_Indication
(Self : access Type_Manager;
Env : Gela.Semantic_Types.Env_Index;
Node : access Gela.Elements.Object_Definitions.Object_Definition'Class)
return Gela.Semantic_Types.Type_View_Index is abstract;
-- Get type view from given subtype indication
not overriding function Type_From_Discrete_Subtype
(Self : access Type_Manager;
Env : Gela.Semantic_Types.Env_Index;
Node : access Gela.Elements.Discrete_Subtype_Definitions.
Discrete_Subtype_Definition'Class)
return Gela.Semantic_Types.Type_View_Index is abstract;
-- Get type view from given discrete subtype definition
not overriding function Type_By_Name
(Self : access Type_Manager;
Env : Gela.Semantic_Types.Env_Index;
Node : Gela.Elements.Defining_Names.Defining_Name_Access)
return Gela.Semantic_Types.Type_View_Index is abstract;
-- Get type view from given type's defining name
not overriding function Universal_Integer
(Self : access Type_Manager)
return Gela.Semantic_Types.Type_View_Index is abstract;
-- Get type view of predefined universal_integer
not overriding function Universal_Real
(Self : access Type_Manager)
return Gela.Semantic_Types.Type_View_Index is abstract;
-- Get type view of predefined universal_real
not overriding function Universal_Access
(Self : access Type_Manager)
return Gela.Semantic_Types.Type_View_Index is abstract;
-- Get type view of predefined universal_access
not overriding function Boolean
(Self : access Type_Manager)
return Gela.Semantic_Types.Type_View_Index is abstract;
-- Get type view of predefined universal_access
not overriding function Root_Integer
(Self : access Type_Manager)
return Gela.Semantic_Types.Type_View_Index is abstract;
-- Get type view of predefined root_integer
not overriding function Root_Real
(Self : access Type_Manager)
return Gela.Semantic_Types.Type_View_Index is abstract;
-- Get type view of predefined root_real
not overriding function Get_Profile
(Self : access Type_Manager;
Env : Gela.Semantic_Types.Env_Index;
Name : Gela.Elements.Defining_Names.Defining_Name_Access)
return Gela.Profiles.Profile_Access is abstract;
-- If Name if callable entity return corresponding profile
not overriding function Get_Profile
(Self : access Type_Manager;
Tipe : Gela.Semantic_Types.Type_View_Index;
Attribute : Gela.Lexical_Types.Symbol)
return Gela.Profiles.Profile_Access is abstract;
-- If given attribute if callable entity return corresponding profile
end Gela.Type_Managers;
|
Subsets and Splits
No saved queries yet
Save your SQL queries to embed, download, and access them later. Queries will appear here once saved.