repo_name
stringlengths 9
74
| language
stringclasses 1
value | length_bytes
int64 11
9.34M
| extension
stringclasses 2
values | content
stringlengths 11
9.34M
|
---|---|---|---|---|
reznikmm/matreshka | Ada | 3,922 | adb | ------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- Web Framework --
-- --
-- Runtime Library Component --
-- --
------------------------------------------------------------------------------
-- --
-- Copyright © 2013, Vadim Godunko <[email protected]> --
-- All rights reserved. --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions --
-- are met: --
-- --
-- * Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- --
-- * Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in the --
-- documentation and/or other materials provided with the distribution. --
-- --
-- * Neither the name of the Vadim Godunko, IE nor the names of its --
-- contributors may be used to endorse or promote products derived from --
-- this software without specific prior written permission. --
-- --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR --
-- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
-- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED --
-- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR --
-- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF --
-- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING --
-- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS --
-- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
-- --
------------------------------------------------------------------------------
-- $Revision$ $Date$
------------------------------------------------------------------------------
package body FastCGI.Field_Values is
--------------------
-- To_Field_Value --
--------------------
function To_Field_Value
(Item : League.Strings.Universal_String) return Field_Value is
begin
return (Item with null record);
end To_Field_Value;
-------------------------
-- To_Universal_String --
-------------------------
function To_Universal_String
(Self : Field_Value) return League.Strings.Universal_String is
begin
return League.Strings.Universal_String (Self);
end To_Universal_String;
end FastCGI.Field_Values;
|
reznikmm/matreshka | Ada | 4,679 | adb | ------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- Open Document Toolkit --
-- --
-- Runtime Library Component --
-- --
------------------------------------------------------------------------------
-- --
-- Copyright © 2014, Vadim Godunko <[email protected]> --
-- All rights reserved. --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions --
-- are met: --
-- --
-- * Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- --
-- * Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in the --
-- documentation and/or other materials provided with the distribution. --
-- --
-- * Neither the name of the Vadim Godunko, IE nor the names of its --
-- contributors may be used to endorse or promote products derived from --
-- this software without specific prior written permission. --
-- --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR --
-- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
-- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED --
-- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR --
-- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF --
-- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING --
-- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS --
-- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
-- --
------------------------------------------------------------------------------
-- $Revision$ $Date$
------------------------------------------------------------------------------
with Matreshka.DOM_Documents;
with Matreshka.ODF_String_Constants;
with ODF.DOM.Iterators;
with ODF.DOM.Visitors;
package body Matreshka.ODF_Text.Animation_Direction_Attributes is
------------
-- Create --
------------
overriding function Create
(Parameters : not null access Matreshka.DOM_Attributes.Attribute_L2_Parameters)
return Text_Animation_Direction_Attribute_Node is
begin
return Self : Text_Animation_Direction_Attribute_Node do
Matreshka.ODF_Text.Constructors.Initialize
(Self'Unchecked_Access,
Parameters.Document,
Matreshka.ODF_String_Constants.Text_Prefix);
end return;
end Create;
--------------------
-- Get_Local_Name --
--------------------
overriding function Get_Local_Name
(Self : not null access constant Text_Animation_Direction_Attribute_Node)
return League.Strings.Universal_String
is
pragma Unreferenced (Self);
begin
return Matreshka.ODF_String_Constants.Animation_Direction_Attribute;
end Get_Local_Name;
begin
Matreshka.DOM_Documents.Register_Attribute
(Matreshka.ODF_String_Constants.Text_URI,
Matreshka.ODF_String_Constants.Animation_Direction_Attribute,
Text_Animation_Direction_Attribute_Node'Tag);
end Matreshka.ODF_Text.Animation_Direction_Attributes;
|
sungyeon/drake | Ada | 1,426 | ads | pragma License (Unrestricted);
-- extended unit
private with System.Native_Directories.Temporary;
package Ada.Directories.Temporary is
-- Creating temporary files and directories.
-- settings
function Temporary_Directory return String;
procedure Set_Temporary_Directory (Name : String);
pragma Inline (Temporary_Directory); -- renamed
pragma Inline (Set_Temporary_Directory); -- renamed
-- creating new entries
function Create_Temporary_File (
Directory : String := Temporary_Directory)
return String;
function Create_Temporary_Directory (
Directory : String := Temporary_Directory)
return String;
pragma Inline (Create_Temporary_File); -- renamed
pragma Inline (Create_Temporary_Directory); -- renamed
private
function Temporary_Directory return String
renames System.Native_Directories.Temporary.Temporary_Directory;
procedure Set_Temporary_Directory (Name : String)
renames System.Native_Directories.Temporary.Set_Temporary_Directory;
function Create_Temporary_File (
Directory : String := Temporary_Directory)
return String
renames System.Native_Directories.Temporary.Create_Temporary_File;
function Create_Temporary_Directory (
Directory : String := Temporary_Directory)
return String
renames System.Native_Directories.Temporary.Create_Temporary_Directory;
end Ada.Directories.Temporary;
|
reznikmm/matreshka | Ada | 4,873 | 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_Display_Info_Elements;
package Matreshka.ODF_Table.Data_Pilot_Display_Info_Elements is
type Table_Data_Pilot_Display_Info_Element_Node is
new Matreshka.ODF_Table.Abstract_Table_Element_Node
and ODF.DOM.Table_Data_Pilot_Display_Info_Elements.ODF_Table_Data_Pilot_Display_Info
with null record;
overriding function Create
(Parameters : not null access Matreshka.DOM_Elements.Element_L2_Parameters)
return Table_Data_Pilot_Display_Info_Element_Node;
overriding function Get_Local_Name
(Self : not null access constant Table_Data_Pilot_Display_Info_Element_Node)
return League.Strings.Universal_String;
overriding procedure Enter_Node
(Self : not null access Table_Data_Pilot_Display_Info_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_Display_Info_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_Display_Info_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_Display_Info_Elements;
|
Lucretia/Cherry | Ada | 5,509 | ads | --
-- The author disclaims copyright to this source code. In place of
-- a legal notice, here is a blessing:
--
-- May you do good and not evil.
-- May you find forgiveness for yourself and forgive others.
-- May you share freely, not taking more than you give.
--
with Ada.Containers;
with Ada.Strings.Unbounded;
with Ada.Containers.Vectors;
limited with Rules;
package Symbols is
type Symbol_Kind is
(Terminal,
Non_Terminal,
Multi_Terminal);
pragma Convention (C, Symbol_Kind);
type E_Assoc is
(Left,
Right,
None,
Unk);
pragma Convention (C, E_Assoc);
type Symbol_Record;
type Symbol_Access is access all Symbol_Record;
package Symbol_Vectors is
new Ada.Containers.Vectors
(Positive,
Symbol_Access);
use Symbol_Vectors;
use Ada.Strings.Unbounded;
package Alias_Vectors is
new Ada.Containers.Vectors
(Positive,
Unbounded_String);
subtype S_Set is Unbounded_String;
Null_Set : S_Set renames Null_Unbounded_String;
function "=" (Left, Right : S_Set)
return Boolean
renames Ada.Strings.Unbounded."=";
type Symbol_Index is new Natural;
subtype Key_Type is Unbounded_String;
type Symbol_Record is
record
Name : Key_Type;
Index : Symbol_Index; -- Index number for this symbol
Kind : Symbol_Kind; -- Symbols are all either TERMINALS or NTs
Rule : access Rules.Rule_Record; -- Linked list of rules of this (if an NT)
Fallback : access Symbol_Record; -- fallback token in case this token doesn't parse
Prec : Integer; -- Precedence if defined (-1 otherwise)
Assoc : E_Assoc; -- Associativity if precedence is defined
First_Set : Unbounded_String; -- First-set for all rules of this symbol
Lambda : Boolean; -- True if NT and can generate an empty string
Use_Cnt : Integer; -- Number of times used
Destructor : aliased Unbounded_String;
-- Code which executes whenever this symbol is
-- popped from the stack during error processing
Dest_Lineno : aliased Integer;
-- Line number for start of destructor. Set to
-- -1 for duplicate destructors.
Data_Type : aliased Unbounded_String; -- Strings.chars_ptr;
-- The data type of information held by this
-- object. Only used if type==NONTERMINAL
Dt_Num : Integer;
-- The data type number. In the parser, the value
-- stack is a union. The .yy%d element of this
-- union is the correct data type for this object
Content : Boolean;
-- True if this symbol ever carries content - if
-- it is ever more than just syntax
-- The following fields are used by MULTITERMINALs only
Sub_Sym : Vector; -- Array of constituent symbols
end record;
type Symbol_Access_Array is
array (Natural range <>) of Symbols.Symbol_Access;
subtype Symbol_Name is Ada.Strings.Unbounded.Unbounded_String;
--
-- Routines for handling symbols of the grammar
--
function To_Key (Item : in String) return Key_Type;
-- Make symbol name from plain string.
function From_Key (Key : in Key_Type) return String;
-- procedure Do_Sort (Container : in out Symbol_Access_Array);
procedure Do_Some_Things (Count_In : in Symbol_Index;
Count_Out : out Symbol_Index);
procedure Symbol_Init;
-- Allocate a new associative array.
function Create (Name : in String) return Symbol_Access;
-- Return a pointer to the (terminal or nonterminal) symbol "x".
-- Create a new symbol if this is the first time "x" has been seen.
-- function Symbol_Find (Key : in Key_Type) return Symbol_Access;
function Find (Key : in String) return Symbol_Access;
-- Return a pointer to data assigned to the given key. Return NULL
-- if no such key.
-- function Symbol_Nth (Index : in Symbol_Index)
-- return Symbol_Cursor; -- Symbol_Access;
-- Return the n-th data. Return NULL if n is out of range.
procedure Symbol_Allocate (Count : in Ada.Containers.Count_Type);
-- Return an array of pointers to all data in the table.
-- The array is obtained from malloc. Return NULL if memory allocation
-- problems, or if the array is empty.
function "<" (Left, Right : in Symbol_Record)
return Boolean;
-- Compare two symbols for sorting purposes. Return negative,
-- zero, or positive if a is less then, equal to, or greater
-- than b.
--
-- Symbols that begin with upper case letters (terminals or tokens)
-- must sort before symbols that begin with lower case letters
-- (non-terminals). And MULTITERMINAL symbols (created using the
-- %token_class directive) must sort at the very end. Other than
-- that, the order does not matter.
--
-- We find experimentally that leaving the symbols in their original
-- order (the order they appeared in the grammar file) gives the
-- smallest parser tables in SQLite.
-- function Lime_Symbol_New
-- (Name : in Interfaces.C.Strings.chars_ptr)
-- return Symbol_Access;
-- function Lime_Symbol_Find
-- (Name : in Interfaces.C.Strings.chars_ptr)
-- return Symbol_Access;
end Symbols;
|
reznikmm/matreshka | Ada | 7,644 | ads | ------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- Web Framework --
-- --
-- Runtime Library Component --
-- --
------------------------------------------------------------------------------
-- --
-- Copyright © 2014-2020, 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$
------------------------------------------------------------------------------
-- Defines an object to provide client request information to a servlet. The
-- servlet container creates a ServletRequest object and passes it as an
-- argument to the servlet's service method.
------------------------------------------------------------------------------
with Ada.Streams;
with League.String_Vectors;
with League.Strings;
with Servlet.Contexts;
package Servlet.Requests is
pragma Preelaborate;
type Servlet_Request is limited interface;
type Servlet_Request_Access is access all Servlet_Request'Class;
not overriding function Get_Content_Type
(Self : Servlet_Request)
return League.Strings.Universal_String is abstract;
-- Returns the MIME type of the body of the request, or null if the type
-- is not known. For HTTP servlets, same as the value of the CGI variable
-- CONTENT_TYPE.
not overriding function Get_Input_Stream
(Self : Servlet_Request)
return not null access Ada.Streams.Root_Stream_Type'Class is abstract;
-- Retrieves the body of the request as binary data using a stream.
function Get_Parameter
(Self : Servlet_Request'Class;
Name : League.Strings.Universal_String)
return League.Strings.Universal_String;
-- Returns the value of a request parameter as a String, or empty string if
-- the parameter does not exist. Request parameters are extra information
-- sent with the request. For HTTP servlets, parameters are contained in
-- the query string or posted form data.
--
-- You should only use this method when you are sure the parameter has only
-- one value. If the parameter might have more than one value, use
-- Get_Parameter_Values.
--
-- If you use this method with a multivalued parameter, the value returned
-- is equal to the first value in the array returned by
-- Get_Parameter_Values.
--
-- If the parameter data was sent in the request body, such as occurs with
-- an HTTP POST request, then reading the body directly via
-- Get_Input_Stream or Get_Reader can interfere with the execution of this
-- method.
not overriding function Get_Parameter_Names
(Self : Servlet_Request)
return League.String_Vectors.Universal_String_Vector is abstract;
-- Returns an vector of String containing the names of the parameters
-- contained in this request. If the request has no parameters, the method
-- returns an empty vector.
not overriding function Get_Parameter_Values
(Self : Servlet_Request;
Name : League.Strings.Universal_String)
return League.String_Vectors.Universal_String_Vector is abstract;
-- Returns an array of String objects containing all of the values the
-- given request parameter has, or null if the parameter does not exist.
--
-- If the parameter has a single value, the array has a length of 1.
not overriding function Get_Scheme
(Self : Servlet_Request) return League.Strings.Universal_String
is abstract;
-- Returns the name of the scheme used to make this request, for example,
-- http, https, or ftp. Different schemes have different rules for
-- constructing URLs, as noted in RFC 1738.
not overriding function Get_Server_Name
(Self : Servlet_Request) return League.Strings.Universal_String
is abstract;
-- Returns the host name of the server to which the request was sent. It is
-- the value of the part before ":" in the Host header value, if any, or
-- the resolved server name, or the server IP address.
not overriding function Get_Server_Port
(Self : Servlet_Request) return Positive is abstract;
-- Returns the port number to which the request was sent. It is the value
-- of the part after ":" in the Host header value, if any, or the server
-- port where the client connection was accepted on.
not overriding function Get_Servlet_Context
(Self : Servlet_Request)
return access Servlet.Contexts.Servlet_Context'Class is abstract;
-- Gets the servlet context to which this ServletRequest was last
-- dispatched.
not overriding function Is_Async_Supported
(Self : not null access Servlet_Request) return Boolean is abstract;
-- Checks if this request supports asynchronous operation.
end Servlet.Requests;
|
brock7/TianLong | Ada | 13,542 | ads | ------------------------------------------------------------------------------
-- ZLib for Ada thick binding. --
-- --
-- Copyright (C) 2002-2004 Dmitriy Anisimkov --
-- --
-- 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.Streams;
with Interfaces;
package ZLib is
ZLib_Error : exception;
Status_Error : exception;
type Compression_Level is new Integer range -1 .. 9;
type Flush_Mode is private;
type Compression_Method is private;
type Window_Bits_Type is new Integer range 8 .. 15;
type Memory_Level_Type is new Integer range 1 .. 9;
type Unsigned_32 is new Interfaces.Unsigned_32;
type Strategy_Type is private;
type Header_Type is (None, Auto, Default, GZip);
-- Header type usage have a some limitation for inflate.
-- See comment for Inflate_Init.
subtype Count is Ada.Streams.Stream_Element_Count;
Default_Memory_Level : constant Memory_Level_Type := 8;
Default_Window_Bits : constant Window_Bits_Type := 15;
----------------------------------
-- Compression method constants --
----------------------------------
Deflated : constant Compression_Method;
-- Only one method allowed in this ZLib version
---------------------------------
-- Compression level constants --
---------------------------------
No_Compression : constant Compression_Level := 0;
Best_Speed : constant Compression_Level := 1;
Best_Compression : constant Compression_Level := 9;
Default_Compression : constant Compression_Level := -1;
--------------------------
-- Flush mode constants --
--------------------------
No_Flush : constant Flush_Mode;
-- Regular way for compression, no flush
Partial_Flush : constant Flush_Mode;
-- Will be removed, use Z_SYNC_FLUSH instead
Sync_Flush : constant Flush_Mode;
-- All pending output is flushed to the output buffer and the output
-- is aligned on a byte boundary, so that the decompressor can get all
-- input data available so far. (In particular avail_in is zero after the
-- call if enough output space has been provided before the call.)
-- Flushing may degrade compression for some compression algorithms and so
-- it should be used only when necessary.
Block_Flush : constant Flush_Mode;
-- Z_BLOCK requests that inflate() stop
-- if and when it get to the next deflate block boundary. When decoding the
-- zlib or gzip format, this will cause inflate() to return immediately
-- after the header and before the first block. When doing a raw inflate,
-- inflate() will go ahead and process the first block, and will return
-- when it gets to the end of that block, or when it runs out of data.
Full_Flush : constant Flush_Mode;
-- All output is flushed as with SYNC_FLUSH, and the compression state
-- is reset so that decompression can restart from this point if previous
-- compressed data has been damaged or if random access is desired. Using
-- Full_Flush too often can seriously degrade the compression.
Finish : constant Flush_Mode;
-- Just for tell the compressor that input data is complete.
------------------------------------
-- Compression strategy constants --
------------------------------------
-- RLE stategy could be used only in version 1.2.0 and later.
Filtered : constant Strategy_Type;
Huffman_Only : constant Strategy_Type;
RLE : constant Strategy_Type;
Default_Strategy : constant Strategy_Type;
Default_Buffer_Size : constant := 4096;
type Filter_Type is tagged limited private;
-- The filter is for compression and for decompression.
-- The usage of the type is depend of its initialization.
function Version return String;
pragma Inline (Version);
-- Return string representation of the ZLib version.
procedure Deflate_Init
(Filter : in out Filter_Type;
Level : in Compression_Level := Default_Compression;
Strategy : in Strategy_Type := Default_Strategy;
Method : in Compression_Method := Deflated;
Window_Bits : in Window_Bits_Type := Default_Window_Bits;
Memory_Level : in Memory_Level_Type := Default_Memory_Level;
Header : in Header_Type := Default);
-- Compressor initialization.
-- When Header parameter is Auto or Default, then default zlib header
-- would be provided for compressed data.
-- When Header is GZip, then gzip header would be set instead of
-- default header.
-- When Header is None, no header would be set for compressed data.
procedure Inflate_Init
(Filter : in out Filter_Type;
Window_Bits : in Window_Bits_Type := Default_Window_Bits;
Header : in Header_Type := Default);
-- Decompressor initialization.
-- Default header type mean that ZLib default header is expecting in the
-- input compressed stream.
-- Header type None mean that no header is expecting in the input stream.
-- GZip header type mean that GZip header is expecting in the
-- input compressed stream.
-- Auto header type mean that header type (GZip or Native) would be
-- detected automatically in the input stream.
-- Note that header types parameter values None, GZip and Auto are
-- supported for inflate routine only in ZLib versions 1.2.0.2 and later.
-- Deflate_Init is supporting all header types.
function Is_Open (Filter : in Filter_Type) return Boolean;
pragma Inline (Is_Open);
-- Is the filter opened for compression or decompression.
procedure Close
(Filter : in out Filter_Type;
Ignore_Error : in Boolean := False);
-- Closing the compression or decompressor.
-- If stream is closing before the complete and Ignore_Error is False,
-- The exception would be raised.
generic
with procedure Data_In
(Item : out Ada.Streams.Stream_Element_Array;
Last : out Ada.Streams.Stream_Element_Offset);
with procedure Data_Out
(Item : in Ada.Streams.Stream_Element_Array);
procedure Generic_Translate
(Filter : in out Filter_Type;
In_Buffer_Size : in Integer := Default_Buffer_Size;
Out_Buffer_Size : in Integer := Default_Buffer_Size);
-- Compress/decompress data fetch from Data_In routine and pass the result
-- to the Data_Out routine. User should provide Data_In and Data_Out
-- for compression/decompression data flow.
-- Compression or decompression depend on Filter initialization.
function Total_In (Filter : in Filter_Type) return Count;
pragma Inline (Total_In);
-- Returns total number of input bytes read so far
function Total_Out (Filter : in Filter_Type) return Count;
pragma Inline (Total_Out);
-- Returns total number of bytes output so far
function CRC32
(CRC : in Unsigned_32;
Data : in Ada.Streams.Stream_Element_Array)
return Unsigned_32;
pragma Inline (CRC32);
-- Compute CRC32, it could be necessary for make gzip format
procedure CRC32
(CRC : in out Unsigned_32;
Data : in Ada.Streams.Stream_Element_Array);
pragma Inline (CRC32);
-- Compute CRC32, it could be necessary for make gzip format
-------------------------------------------------
-- Below is more complex low level routines. --
-------------------------------------------------
procedure Translate
(Filter : in out Filter_Type;
In_Data : in Ada.Streams.Stream_Element_Array;
In_Last : out Ada.Streams.Stream_Element_Offset;
Out_Data : out Ada.Streams.Stream_Element_Array;
Out_Last : out Ada.Streams.Stream_Element_Offset;
Flush : in Flush_Mode);
-- Compress/decompress the In_Data buffer and place the result into
-- Out_Data. In_Last is the index of last element from In_Data accepted by
-- the Filter. Out_Last is the last element of the received data from
-- Filter. To tell the filter that incoming data are complete put the
-- Flush parameter to Finish.
function Stream_End (Filter : in Filter_Type) return Boolean;
pragma Inline (Stream_End);
-- Return the true when the stream is complete.
procedure Flush
(Filter : in out Filter_Type;
Out_Data : out Ada.Streams.Stream_Element_Array;
Out_Last : out Ada.Streams.Stream_Element_Offset;
Flush : in Flush_Mode);
pragma Inline (Flush);
-- Flushing the data from the compressor.
generic
with procedure Write
(Item : in Ada.Streams.Stream_Element_Array);
-- User should provide this routine for accept
-- compressed/decompressed data.
Buffer_Size : in Ada.Streams.Stream_Element_Offset
:= Default_Buffer_Size;
-- Buffer size for Write user routine.
procedure Write
(Filter : in out Filter_Type;
Item : in Ada.Streams.Stream_Element_Array;
Flush : in Flush_Mode := No_Flush);
-- Compress/Decompress data from Item to the generic parameter procedure
-- Write. Output buffer size could be set in Buffer_Size generic parameter.
generic
with procedure Read
(Item : out Ada.Streams.Stream_Element_Array;
Last : out Ada.Streams.Stream_Element_Offset);
-- User should provide data for compression/decompression
-- thru this routine.
Buffer : in out Ada.Streams.Stream_Element_Array;
-- Buffer for keep remaining data from the previous
-- back read.
Rest_First, Rest_Last : in out Ada.Streams.Stream_Element_Offset;
-- Rest_First have to be initialized to Buffer'Last + 1
-- Rest_Last have to be initialized to Buffer'Last
-- before usage.
Allow_Read_Some : in Boolean := False;
-- Is it allowed to return Last < Item'Last before end of data.
procedure Read
(Filter : in out Filter_Type;
Item : out Ada.Streams.Stream_Element_Array;
Last : out Ada.Streams.Stream_Element_Offset;
Flush : in Flush_Mode := No_Flush);
-- Compress/Decompress data from generic parameter procedure Read to the
-- Item. User should provide Buffer and initialized Rest_First, Rest_Last
-- indicators. If Allow_Read_Some is True, Read routines could return
-- Last < Item'Last only at end of stream.
private
use Ada.Streams;
pragma Assert (Ada.Streams.Stream_Element'Size = 8);
pragma Assert (Ada.Streams.Stream_Element'Modulus = 2**8);
type Flush_Mode is new Integer range 0 .. 5;
type Compression_Method is new Integer range 8 .. 8;
type Strategy_Type is new Integer range 0 .. 3;
No_Flush : constant Flush_Mode := 0;
Partial_Flush : constant Flush_Mode := 1;
Sync_Flush : constant Flush_Mode := 2;
Full_Flush : constant Flush_Mode := 3;
Finish : constant Flush_Mode := 4;
Block_Flush : constant Flush_Mode := 5;
Filtered : constant Strategy_Type := 1;
Huffman_Only : constant Strategy_Type := 2;
RLE : constant Strategy_Type := 3;
Default_Strategy : constant Strategy_Type := 0;
Deflated : constant Compression_Method := 8;
type Z_Stream;
type Z_Stream_Access is access all Z_Stream;
type Filter_Type is tagged limited record
Strm : Z_Stream_Access;
Compression : Boolean;
Stream_End : Boolean;
Header : Header_Type;
CRC : Unsigned_32;
Offset : Stream_Element_Offset;
-- Offset for gzip header/footer output.
end record;
end ZLib;
|
damaki/libkeccak | Ada | 1,969 | ads | -------------------------------------------------------------------------------
-- Copyright (c) 2019, Daniel King
-- 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.
-- * The name of the copyright holder may not 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 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.
-------------------------------------------------------------------------------
package Ascon.Permutations
with SPARK_Mode => On
is
procedure Permute_12 is new Permute (Num_Rounds => 12);
procedure Permute_8 is new Permute (Num_Rounds => 8);
procedure Permute_6 is new Permute (Num_Rounds => 6);
end Ascon.Permutations;
|
stcarrez/jason | Ada | 1,672 | adb | -----------------------------------------------------------------------
-- Jason-server -- Application server
-- Copyright (C) 2016 Stephane.Carrez
-- Written by Stephane.Carrez ([email protected])
--
-- Licensed under the Apache License, Version 2.0 (the "License");
-- you may not use this file except in compliance with the License.
-- You may obtain a copy of the License at
--
-- http://www.apache.org/licenses/LICENSE-2.0
--
-- Unless required by applicable law or agreed to in writing, software
-- distributed under the License is distributed on an "AS IS" BASIS,
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-- See the License for the specific language governing permissions and
-- limitations under the License.
-----------------------------------------------------------------------
with Ada.Exceptions;
with Util.Log.loggers;
with ASF.Server.Web;
with Jason.Applications;
procedure Jason.Server is
Log : constant Util.Log.Loggers.Logger := Util.Log.Loggers.Create ("Jason.Server");
App : constant Jason.Applications.Application_Access := new Jason.Applications.Application;
WS : ASF.Server.Web.AWS_Container;
begin
Jason.Applications.Initialize (App);
WS.Register_Application (Jason.Applications.CONTEXT_PATH, App.all'Access);
Log.Info ("Connect you browser to: http://localhost:8080/jason/index.html");
WS.Start;
delay 365.0 * 24.0 * 3600.0;
App.Close;
exception
when E: others =>
Log.Error ("Exception in server: " &
Ada.Exceptions.Exception_Name (E) & ": " &
Ada.Exceptions.Exception_Message (E));
end Jason.Server;
|
onox/orka | Ada | 2,130 | ads | -- 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.
limited with Orka.Contexts;
package Orka.Windows is
pragma Preelaborate;
type Window is limited interface;
function Create_Window
(Context : aliased Contexts.Surface_Context'Class;
Width, Height : Positive;
Title : String := "";
Samples : Natural := 0;
Visible, Resizable : Boolean := True;
Transparent : Boolean := False) return Window is abstract;
function Width (Object : Window) return Positive is abstract;
function Height (Object : Window) return Positive is abstract;
procedure Set_Title (Object : in out Window; Value : String) is abstract;
-- Set the title of the window
--
-- Task safety: Must only be called from the environment task.
procedure Close (Object : in out Window) is abstract;
function Should_Close (Object : Window) return Boolean is abstract;
procedure Swap_Buffers (Object : in out Window) is abstract;
-- Swap the front and back buffers of the window
--
-- Task safety: Must only be called from the rendering task.
procedure Set_Vertical_Sync (Object : in out Window; Enable : Boolean) is abstract;
-- Request the vertical retrace synchronization or vsync to be enabled
-- or disabled
--
-- Vsync causes the video driver to wait for a screen update before
-- swapping the buffers. The video driver may ignore the request.
-- Enablng vsync avoids tearing.
end Orka.Windows;
|
stcarrez/stm32-ui | Ada | 3,681 | ads | -----------------------------------------------------------------------
-- ui-displays -- Display manager
-- Copyright (C) 2018 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.Real_Time;
with HAL.Bitmap;
with HAL.Touch_Panel;
-- == Display ==
-- The `Display_Type` is a tagged record that defines several operations to handle
-- the main display and its interaction with the user.
package UI.Displays is
type Refresh_Mode is (REFRESH_CURRENT, REFRESH_BOTH);
type Display_Buffer_Index is new Natural range 0 .. 1;
type Display_Type is abstract tagged limited private;
type Display_Access is not null access all Display_Type'Class;
-- Get the index of current buffer visible on screen.
function Current_Buffer_Index (Display : in Display_Type) return Display_Buffer_Index;
-- Returns True if a refresh is needed.
function Need_Refresh (Display : in Display_Type;
Now : in Ada.Real_Time.Time) return Boolean;
-- Process touch panel event if there is one.
procedure Process_Event (Display : in out Display_Type;
Buffer : in out HAL.Bitmap.Bitmap_Buffer'Class;
Now : in Ada.Real_Time.Time);
procedure Refresh (Display : in out Display_Type;
Buffer : in out HAL.Bitmap.Bitmap_Buffer'Class;
Mode : in Refresh_Mode := REFRESH_CURRENT);
procedure On_Pause (Display : in out Display_Type;
Buffer : in out HAL.Bitmap.Bitmap_Buffer'Class) is null;
procedure On_Restore (Display : in out Display_Type;
Buffer : in out HAL.Bitmap.Bitmap_Buffer'Class) is null;
-- Refresh the current display.
procedure On_Refresh (Display : in out Display_Type;
Buffer : in out HAL.Bitmap.Bitmap_Buffer'Class;
Deadline : out Ada.Real_Time.Time) is null;
-- Handle touch events on the display.
procedure On_Touch (Display : in out Display_Type;
Buffer : in out HAL.Bitmap.Bitmap_Buffer'Class;
States : in HAL.Touch_Panel.TP_State) is null;
-- Handle refresh timeout event.
procedure On_Timeout (Display : in out Display_Type;
Buffer : in out HAL.Bitmap.Bitmap_Buffer'Class;
Deadline : out Ada.Real_Time.Time) is null;
procedure Initialize;
-- Push a new display.
procedure Push_Display (Display : in Display_Access);
-- Pop the display to go back to the previous one.
procedure Pop_Display;
-- Get the current display.
function Current_Display return Display_Access;
private
type Display_Type is abstract tagged limited record
Current_Buffer : Display_Buffer_Index := 0;
Deadline : Ada.Real_Time.Time;
Refresh_Flag : Boolean := True;
Button_Changed : Boolean := True;
Previous : access Display_Type;
end record;
end UI.Displays;
|
wookey-project/ewok-legacy | Ada | 1,435 | 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_shared;
package ewok.syscalls.cfg.gpio
with spark_mode => off
is
procedure gpio_set
(caller_id : in ewok.tasks_shared.t_task_id;
params : in out t_parameters;
mode : in ewok.tasks_shared.t_task_mode);
procedure gpio_get
(caller_id : in ewok.tasks_shared.t_task_id;
params : in out t_parameters;
mode : in ewok.tasks_shared.t_task_mode);
procedure 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);
end ewok.syscalls.cfg.gpio;
|
1Crazymoney/LearnAda | Ada | 908 | adb | package body Sorok is
procedure Hiext( S: in out Sor; E: in Elem ) is
begin
if not Is_Full(S) then
S.Size := S.Size + 1;
S.Adatok(S.Size) := E;
end if;
end;
procedure Lopop( S: in out Sor; E: out Elem ) is
begin
E := Lov(S);
for I in 1..S.Size-1 loop
S.Adatok(I) := S.Adatok(I + 1);
end loop;
S.Size := S.Size - 1;
end;
function Lov( S: Sor ) return Elem is
begin
return S.Adatok(1);
end;
function Is_Empty( S: Sor ) return Boolean is
begin
return Size(S) = 0;
end;
function Is_Full( S: Sor ) return Boolean is
begin
return Size(S) = S.Max;
end;
function Size( S: Sor ) return Natural is
begin
return S.Size;
end;
end Sorok;
|
docandrew/troodon | Ada | 2,588 | ads | private package GID.Decoding_PNG is
type PNG_Chunk_tag is (
--
-- Critical chunks
--
IHDR, -- must be the first chunk; it contains the header.
PLTE, -- contains the palette; list of colors.
IDAT, -- contains the image, which may be split among multiple IDAT chunks.
IEND, -- marks the image end.
--
-- Ancillary chunks
--
bKGD, -- gives the default background color.
cHRM, -- gives the chromaticity coordinates of the display primaries and white point.
gAMA, -- specifies gamma.
hIST, -- can store the histogram, or total amount of each color in the image.
iCCP, -- is an ICC color profile.
iTXt, -- contains UTF-8 text, compressed or not, with an optional language tag.
pHYs, -- holds the intended pixel size and/or aspect ratio of the image.
sBIT, -- (significant bits) indicates the color-accuracy of the source data.
sPLT, -- suggests a palette to use if the full range of colors is unavailable.
sRGB, -- indicates that the standard sRGB color space is used.
tEXt, -- can store text that can be represented in ISO/IEC 8859-1.
tIME, -- stores the time that the image was last changed.
tRNS, -- contains transparency information.
zTXt, -- contains compressed text with the same limits as tEXt.
--
-- Public extentions
-- PNG Extensions and Register of Public Chunks and Keywords
--
oFFs, -- image offset from frame or page origin
pCAL, -- physical calibration of pixel values
sCAL, -- physical scale of image subject
sTER, -- stereographic subimage layout
gIFg, -- GIF Graphic Control Extension
gIFx, -- GIF Application Extension
fRAc, -- fractal image parameters
--
-- Private chunks (not defined in the ISO standard)
--
vpAg, -- used in ImageMagick to store "virtual page" size
spAL,
prVW,
cmOD,
cmPP,
cpIp,
mkBF,
mkBS,
mkBT,
mkTS,
pcLb
);
type Chunk_head is record
length: U32;
kind : PNG_Chunk_tag;
end record;
procedure Read( image: in out Image_descriptor; ch: out Chunk_head);
--------------------
-- 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);
--
procedure Load (image: in out Image_descriptor);
end GID.Decoding_PNG;
|
SayCV/rtems-addon-packages | Ada | 6,235 | adb | ------------------------------------------------------------------------------
-- --
-- GNAT ncurses Binding Samples --
-- --
-- Sample.Curses_Demo --
-- --
-- B O D Y --
-- --
------------------------------------------------------------------------------
-- Copyright (c) 1998-2004,2011 Free Software Foundation, Inc. --
-- --
-- Permission is hereby granted, free of charge, to any person obtaining a --
-- copy of this software and associated documentation files (the --
-- "Software"), to deal in the Software without restriction, including --
-- without limitation the rights to use, copy, modify, merge, publish, --
-- distribute, distribute with modifications, sublicense, and/or sell --
-- copies of the Software, and to permit persons to whom the Software is --
-- furnished to do so, subject to the following conditions: --
-- --
-- The above copyright notice and this permission notice shall be included --
-- in all copies or substantial portions of the Software. --
-- --
-- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS --
-- OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF --
-- MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. --
-- IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, --
-- DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR --
-- OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR --
-- THE USE OR OTHER DEALINGS IN THE SOFTWARE. --
-- --
-- Except as contained in this notice, the name(s) of the above copyright --
-- holders shall not be used in advertising or otherwise to promote the --
-- sale, use or other dealings in this Software without prior written --
-- authorization. --
------------------------------------------------------------------------------
-- Author: Juergen Pfeifer, 1996
-- Version Control
-- $Revision$
-- $Date$
-- Binding Version 01.00
------------------------------------------------------------------------------
with Terminal_Interface.Curses; use Terminal_Interface.Curses;
with Terminal_Interface.Curses.Menus; use Terminal_Interface.Curses.Menus;
with Terminal_Interface.Curses.Mouse; use Terminal_Interface.Curses.Mouse;
with Terminal_Interface.Curses.Panels; use Terminal_Interface.Curses.Panels;
with Terminal_Interface.Curses.Panels.User_Data;
with Sample.Manifest; use Sample.Manifest;
with Sample.Helpers; use Sample.Helpers;
with Sample.Function_Key_Setting; use Sample.Function_Key_Setting;
with Sample.Explanation; use Sample.Explanation;
with Sample.Menu_Demo.Handler;
with Sample.Curses_Demo.Mouse;
with Sample.Curses_Demo.Attributes;
package body Sample.Curses_Demo is
type User_Data is new Integer;
type User_Data_Access is access all User_Data;
package PUD is new Panels.User_Data (User_Data, User_Data_Access);
-- We use above instantiation of the generic User_Data package to
-- demonstrate and test the use of the user data mechanism.
procedure Demo
is
function My_Driver (M : Menu;
K : Key_Code;
Pan : Panel) return Boolean;
package Mh is new Sample.Menu_Demo.Handler (My_Driver);
Itm : Item_Array_Access := new Item_Array'
(New_Item ("Attributes Demo"),
New_Item ("Mouse Demo"),
Null_Item);
M : Menu := New_Menu (Itm);
U1 : constant User_Data_Access := new User_Data'(4711);
U2 : User_Data_Access;
function My_Driver (M : Menu;
K : Key_Code;
Pan : Panel) return Boolean
is
Idx : constant Positive := Get_Index (Current (M));
Result : Boolean := False;
begin
PUD.Set_User_Data (Pan, U1); -- set some user data, just for fun
if K in User_Key_Code'Range then
if K = QUIT then
Result := True;
elsif K = SELECT_ITEM then
if Idx in Itm'Range then
Hide (Pan);
Update_Panels;
end if;
case Idx is
when 1 => Sample.Curses_Demo.Attributes.Demo;
when 2 => Sample.Curses_Demo.Mouse.Demo;
when others => Not_Implemented;
end case;
if Idx in Itm'Range then
Top (Pan);
Show (Pan);
Update_Panels;
Update_Screen;
end if;
end if;
end if;
PUD.Get_User_Data (Pan, U2); -- get the user data
pragma Assert (U1.all = U2.all and then U1 = U2);
return Result;
end My_Driver;
begin
if (1 + Item_Count (M)) /= Itm'Length then
raise Constraint_Error;
end if;
if not Has_Mouse then
declare
O : Item_Option_Set;
begin
Get_Options (Itm.all (2), O);
O.Selectable := False;
Set_Options (Itm.all (2), O);
end;
end if;
Push_Environment ("CURSES00");
Notepad ("CURSES-PAD00");
Default_Labels;
Refresh_Soft_Label_Keys_Without_Update;
Mh.Drive_Me (M, " Demo ");
Pop_Environment;
Delete (M);
Free (Itm, True);
end Demo;
end Sample.Curses_Demo;
|
reznikmm/matreshka | Ada | 783 | ads | with Ada.Streams;
with League.Strings;
with League.String_Vectors;
package Styx.Messages.Walks is
type Walk_Request is new Request with record
FID : Styx.Messages.FID;
New_FID : Styx.Messages.FID;
Names : League.String_Vectors.Universal_String_Vector;
end record;
procedure Visit
(Visiter : in out Styx.Request_Visiters.Request_Visiter'Class;
Value : Walk_Request);
type Walk_Request_Access is access all Walk_Request;
type QID_Array is array (Positive range <>) of QID;
type Walk_Reply (Count : Natural) is new Reply with record
List : QID_Array (1 .. Count);
end record;
procedure Visit
(Visiter : in out Styx.Reply_Visiters.Reply_Visiter'Class;
Value : Walk_Reply);
end Styx.Messages.Walks;
|
zhmu/ananas | Ada | 1,418 | ads | package Rep_Clause6 is
type B1_Type is range 0 .. 2**1 - 1;
for B1_Type'Size use 1;
type U10_Type is range 0 .. 2**10 - 1;
for U10_Type'Size use 10;
type B5_Type is range 0 .. 2**5 - 1;
for B5_Type'Size use 5;
type B11_Type is range 0 .. 2**11 - 1;
for B11_Type'Size use 11;
type Rec1 is record
B1 : B1_Type;
U10 : U10_Type;
B5 : B5_Type;
end record;
for Rec1 use record
B1 at 0 range 0 .. 0;
U10 at 0 range 1 .. 10;
B5 at 0 range 11 .. 15;
end record;
for Rec1'Size use 16;
type Arr is array (1 .. 5) of Rec1;
for Arr'Size use 80;
subtype Header_Type is String (1 .. 16);
type Rec2 is record
Header : Header_Type;
Spare_5 : B5_Type;
Deleted_Reports : Arr;
Block_End : B11_Type;
end record;
for Rec2 use record
Header at 0 range 0 .. 127;
Spare_5 at 16 range 0 .. 4;
Deleted_Reports at 16 range 5 .. 84;
Block_End at 24 range 21 .. 31;
end record;
for Rec2'Size use 224;
type Enum is (A_Msg, B_Msg, C_Msg, D_Msg);
type Rec3 (Msg_Type : Enum := Enum'First) is record
case Msg_Type is
when A_Msg => A_M : Arr;
when B_Msg => B_M : Arr;
when C_Msg => C_M : Rec2;
when others => null;
end case;
end record;
procedure Dummy;
end Rep_Clause6;
|
stcarrez/mat | Ada | 1,218 | adb | -----------------------------------------------------------------------
-- gtkmatp -- Gtk MAT application
-- Copyright (C) 2014 Stephane Carrez
-- Written by Stephane Carrez ([email protected])
--
-- Licensed under the Apache License, Version 2.0 (the "License");
-- you may not use this file except in compliance with the License.
-- You may obtain a copy of the License at
--
-- http://www.apache.org/licenses/LICENSE-2.0
--
-- Unless required by applicable law or agreed to in writing, software
-- distributed under the License is distributed on an "AS IS" BASIS,
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-- See the License for the specific language governing permissions and
-- limitations under the License.
-----------------------------------------------------------------------
with MAT.Commands;
with MAT.Targets;
with MAT.Targets.Gtkmat;
with Gtk.Widget;
procedure GtkMatp is
Main : Gtk.Widget.Gtk_Widget;
Target : aliased MAT.Targets.Gtkmat.Target_Type;
begin
Target.Initialize_Options;
Target.Initialize_Widget (Main);
MAT.Commands.Initialize_Files (Target);
Target.Start;
Target.Interactive;
Target.Stop;
end GtkMatp;
|
MinimSecure/unum-sdk | Ada | 944 | adb | -- Copyright 2013-2016 Free Software Foundation, Inc.
--
-- This program is free software; you can redistribute it and/or modify
-- it under the terms of the GNU General Public License as published by
-- the Free Software Foundation; either version 3 of the License, or
-- (at your option) any later version.
--
-- This program is distributed in the hope that it will be useful,
-- but WITHOUT ANY WARRANTY; without even the implied warranty of
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-- GNU General Public License for more details.
--
-- You should have received a copy of the GNU General Public License
-- along with this program. If not, see <http://www.gnu.org/licenses/>.
with IO; use IO;
package body Callee is
procedure Increment (Val : in out Float; Msg: String) is
begin
if Val > 200.0 then
Put_Line (Msg);
end if;
Val := Val + 1.0;
end Increment;
end Callee;
|
Jellix/elan520 | Ada | 3,359 | ads | ------------------------------------------------------------------------
-- Copyright (C) 2004-2020 by <[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);
------------------------------------------------------------------------
-- AMD Élan(tm) SC 520 embedded microprocessor --
-- MMCR -> SDRAM Buffer Control Registers (DBCTL) --
------------------------------------------------------------------------
with Elan520.Basic_Types;
package Elan520.SDRAM_Buffer_Control is
---------------------------------------------------------------------
-- SDRAM Buffer Control (DBCTL) --
-- Memory Mapped, Read/Write --
-- MMCR Offset 40h --
---------------------------------------------------------------------
---------------------------------------------------------------------
-- sub types for SDRAM_Buffer_Control
-- water mark, unit is DWords
type Write_Buffer_Watermark is (Twenty_Eight,
Twenty_Four,
Sixteen,
Eight);
for Write_Buffer_Watermark use (Twenty_Eight => 2#00#,
Twenty_Four => 2#01#,
Sixteen => 2#10#,
Eight => 2#11#);
for Write_Buffer_Watermark'Size use 2;
DEFAULT_WRITE_BUFFER_WATERMARK :
constant Write_Buffer_Watermark := Twenty_Eight;
---------------------------------------------------------------------
-- SDRAM Buffer Control at MMCR offset 16#40#
---------------------------------------------------------------------
MMCR_OFFSET_SDRAM_BUFFER_CONTROL : constant := 16#40#;
SDRAM_BUFFER_CONTROL_SIZE : constant := 8;
type SDRAM_Buffer_Control is
record
-- shall we use the Write Buffer at all?
WB : Basic_Types.Positive_Bit;
-- writing an Enabled forces the write buffer to be flushed, a
-- Disabled indicates that the flush cycle has been completed
WB_Flush : Basic_Types.Positive_Bit;
-- the write buffer water mark
WB_Watermark : Write_Buffer_Watermark;
-- shall we enable the read ahead feature?
-- should be disabled during RAM test or sizing on boot
Read_Ahead : Basic_Types.Positive_Bit;
end record;
for SDRAM_Buffer_Control use
record
WB at 0 range 0 .. 0;
WB_Flush at 0 range 1 .. 1;
WB_Watermark at 0 range 2 .. 3;
Read_Ahead at 0 range 4 .. 4;
-- bits [5:7] are reserved
end record;
for SDRAM_Buffer_Control'Size use SDRAM_BUFFER_CONTROL_SIZE;
end Elan520.SDRAM_Buffer_Control;
|
Gabriel-Degret/adalib | Ada | 863 | 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
---------------------------------------------------------------------------
generic
type Index_Type is (<>);
type Element_Type is private;
type Array_Type is array (Index_Type range <>) of Element_Type;
with function "<" (Left : in Element_Type;
Right : in Element_Type)
return Boolean is <>;
procedure Ada.Containers.Generic_Array_Sort (Container : in out Array_Type);
pragma Pure (Ada.Containers.Generic_Array_Sort);
|
mfkiwl/ewok-kernel-security-OS | Ada | 2,246 | 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 system;
package soc.flash
with spark_mode => on
is
-----------------------------------------------
-- Flash access control register (FLASH_ACR) --
-- for STM32F42xxx and STM32F43xxx --
-----------------------------------------------
type t_FLASH_ACR is record
LATENCY : bits_4;
-- reserved_04_07
PRFTEN : boolean; -- Prefetch enable
ICEN : boolean; -- Instruction cache enable
DCEN : boolean; -- Data cache enable
ICRST : boolean; -- Instruction cache reset
DCRST : boolean; -- Data cache reset
-- reserved_13_31
end record
with volatile_full_access, size => 32;
for t_FLASH_ACR use record
LATENCY at 0 range 0 .. 3;
-- reserved_04_07
PRFTEN at 0 range 8 .. 8;
ICEN at 0 range 9 .. 9;
DCEN at 0 range 10 .. 10;
ICRST at 0 range 11 .. 11;
DCRST at 0 range 12 .. 12;
-- reserved_13_31
end record;
----------------------
-- FLASH peripheral --
----------------------
type t_FLASH_peripheral is record
ACR : t_FLASH_ACR;
end record
with volatile;
for t_FLASH_peripheral use record
ACR at 16#00# range 0 .. 31;
end record;
FLASH : t_FLASH_peripheral
with
import,
volatile,
address => system'to_address(16#4002_3C00#);
end soc.flash;
|
AaronC98/PlaneSystem | Ada | 37,746 | adb | ------------------------------------------------------------------------------
-- Ada Web Server --
-- --
-- Copyright (C) 2000-2019, AdaCore --
-- --
-- This library is free software; you can redistribute it and/or modify --
-- it under terms of the GNU General Public License as published by the --
-- Free Software Foundation; either version 3, or (at your option) any --
-- later version. This library is distributed in the hope that it will be --
-- useful, but WITHOUT ANY WARRANTY; without even the implied warranty of --
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. --
-- --
-- --
-- --
-- --
-- --
-- You should have received a copy of the GNU General Public License and --
-- a copy of the GCC Runtime Library Exception along with this program; --
-- see the files COPYING3 and COPYING.RUNTIME respectively. If not, see --
-- <http://www.gnu.org/licenses/>. --
-- --
-- --
-- --
-- --
-- --
-- --
-- --
------------------------------------------------------------------------------
pragma Ada_2012;
with Ada.Streams;
with Ada.Tags;
with Ada.Text_IO;
with Ada.Unchecked_Deallocation;
with AWS.Config.Set;
with AWS.Dispatchers.Callback;
with AWS.Messages;
with AWS.MIME;
with AWS.Net.WebSocket.Registry.Control;
with AWS.Server.HTTP_Utils;
with AWS.Server.Log;
with AWS.Services.Transient_Pages.Control;
with AWS.Session.Control;
with AWS.Status.Translate_Set;
with AWS.Templates;
package body AWS.Server is
use type Net.Socket_Access;
procedure Start
(Web_Server : in out HTTP;
Dispatcher : Dispatchers.Handler'Class);
-- Start web server with current configuration
procedure Protocol_Handler (LA : in out Line_Attribute_Record);
-- Handle the lines, this is where all the HTTP protocol is defined
function Accept_Socket_Serialized
(Server : not null access HTTP)
return not null access Net.Socket_Type'Class;
-- Do a protected accept on the HTTP socket. It is not safe to call
-- multiple accept on the same socket on some platforms.
procedure Force_Clean (Web_Server : in out HTTP);
-- Close a socket on a slot for which a force timeout has expired
Server_Counter : Utils.Counter (Initial_Value => 0);
------------------------------
-- Accept_Socket_Serialized --
------------------------------
function Accept_Socket_Serialized
(Server : not null access HTTP)
return not null access Net.Socket_Type'Class
is
use type Ada.Tags.Tag;
New_Socket : Net.Socket_Access;
procedure Accept_Error (E : Ada.Exceptions.Exception_Occurrence);
------------------
-- Accept_Error --
------------------
procedure Accept_Error (E : Ada.Exceptions.Exception_Occurrence) is
begin
AWS.Log.Write
(Server.Error_Log,
"Accept error "
& Utils.CRLF_2_Spaces (Ada.Exceptions.Exception_Information (E)));
Force_Clean (Server.all);
end Accept_Error;
begin
Net.Acceptors.Get (Server.Acceptor, New_Socket, Accept_Error'Access);
if CNF.Security (Server.Properties)
and then New_Socket'Tag /= Net.SSL.Socket_Type'Tag
then
declare
SSL_Socket : Net.Socket_Access;
begin
SSL_Socket := new Net.SSL.Socket_Type'
(Net.SSL.Secure_Server (New_Socket.all, Server.SSL_Config));
Net.Free (New_Socket);
return SSL_Socket;
exception
when others =>
Net.Shutdown (New_Socket.all);
Net.Free (New_Socket);
raise;
end;
else
return New_Socket;
end if;
end Accept_Socket_Serialized;
-------------------
-- Add_Listening --
-------------------
procedure Add_Listening
(Web_Server : in out HTTP;
Host : String;
Port : Natural;
Family : Net.Family_Type := Net.Family_Unspec;
Reuse_Address : Boolean := False;
IPv6_Only : Boolean := False) is
begin
Net.Acceptors.Add_Listening
(Web_Server.Acceptor, Host, Port, Family, IPv6_Only => IPv6_Only,
Reuse_Address => Reuse_Address);
end Add_Listening;
------------
-- Config --
------------
function Config (Web_Server : HTTP) return AWS.Config.Object is
begin
return Web_Server.Properties;
end Config;
------------------------------------------
-- Default_Unexpected_Exception_Handler --
------------------------------------------
procedure Default_Unexpected_Exception_Handler
(E : Exception_Occurrence;
Log : in out AWS.Log.Object;
Error : Exceptions.Data;
Answer : in out Response.Data)
is
pragma Unreferenced (Log);
use type Templates.Translate_Set;
Fatal_Error_Template : constant String := "500.tmplt";
begin
if Error.Fatal then
Text_IO.Put_Line
(Text_IO.Current_Error, "Fatal error, slot"
& Positive'Image (Error.Slot) & " is dead now.");
Text_IO.New_Line (Text_IO.Current_Error);
Text_IO.Put_Line
(Text_IO.Current_Error, Exception_Information (E));
else
if Utils.Is_Regular_File (Fatal_Error_Template) then
Answer := Response.Build
(MIME.Text_HTML,
String'(Templates.Parse
(Fatal_Error_Template,
Status.Translate_Set (Error.Request)
& Templates.Assoc
("EXCEPTION", Exception_Information (E)))),
Messages.S500);
else
Answer := Response.Build
(MIME.Text_HTML,
"Internal Server Error.<br>"
& "Please, send the following information to the Web "
& "Master, thanks.<br><hr><br>"
& "<pre>" & Exception_Information (E) & "</pre>"
& "<br><hr>",
Messages.S500);
end if;
end if;
end Default_Unexpected_Exception_Handler;
--------------
-- Finalize --
--------------
overriding procedure Finalize (Web_Server : in out HTTP) is
begin
Shutdown (Web_Server);
end Finalize;
-----------------
-- Force_Clean --
-----------------
procedure Force_Clean (Web_Server : in out HTTP) is
Socket : Socket_Access;
Slot : Positive := Line_Attribute.Reference.Line;
-- Initialize the slot by the current slot number to avoid current slot
-- abortion.
begin
Web_Server.Slots.Abort_On_Timeout (Socket, Slot);
if Socket /= null then
Net.Shutdown (Socket.all);
Web_Server.Slots.Shutdown_Done (Slot);
end if;
end Force_Clean;
-----------------
-- Get_Current --
-----------------
function Get_Current return not null access HTTP is
begin
return Line_Attribute.Reference.Server;
end Get_Current;
----------------------
-- Get_Message_Body --
----------------------
procedure Get_Message_Body is
use type Ada.Streams.Stream_Element_Count;
TA : constant Line_Attribute.Attribute_Handle :=
Line_Attribute.Reference;
begin
if not Status.Is_Body_Uploaded (TA.Stat)
and then
(Status.Content_Length (TA.Stat) > 0
or else Status.Transfer_Encoding (TA.Stat) = "chunked")
then
HTTP_Utils.Get_Message_Data
(TA.Server.all, TA.Line, TA.Stat, TA.Expect_100);
end if;
end Get_Message_Body;
----------------
-- Get_Status --
----------------
function Get_Status return Status.Data is
begin
return Line_Attribute.Reference.Stat;
end Get_Status;
----------------------
-- Give_Back_Socket --
----------------------
procedure Give_Back_Socket
(Web_Server : in out HTTP;
Socket : not null access Net.Socket_Type'Class) is
begin
Net.Acceptors.Give_Back (Web_Server.Acceptor, Socket);
end Give_Back_Socket;
procedure Give_Back_Socket
(Web_Server : in out HTTP; Socket : Net.Socket_Type'Class)
is
S : constant not null Net.Socket_Access :=
new Net.Socket_Type'Class'(Socket);
begin
Give_Back_Socket (Web_Server, S);
end Give_Back_Socket;
----------
-- Line --
----------
task body Line is
TA : constant Line_Attribute.Attribute_Handle :=
Line_Attribute.Reference;
begin
select
accept Start
(Server : HTTP;
Index : Positive)
do
TA.Server := Server.Self;
TA.Line := Index;
end Start;
or
terminate;
end select;
-- Real job start here, we will exit only if there is an unrecoverable
-- problem.
while not TA.Server.Shutdown loop
declare
-- Wait for an incoming connection. Each call for the same server
-- is serialized as some platforms do not handle properly
-- multiple accepts on the same socket.
Socket : Net.Socket_Access :=
Accept_Socket_Serialized (TA.Server);
Need_Shutdown : Boolean;
begin
if AWS.Config.Send_Buffer_Size (TA.Server.Config) /= 0 then
Net.Set_Send_Buffer_Size
(Socket.all, AWS.Config.Send_Buffer_Size (TA.Server.Config));
end if;
Net.Set_No_Delay
(Socket.all, AWS.Config.TCP_No_Delay (TA.Server.Config));
TA.Server.Slots.Set (Socket, TA.Line);
Protocol_Handler (TA.all);
TA.Server.Slots.Release (TA.Line, Need_Shutdown);
if Need_Shutdown then
Socket.Shutdown;
-- Don't use Socket.Free, it does not deallocate Socket
Net.Free (Socket);
end if;
end;
end loop;
exception
when E : others =>
if not TA.Server.Shutdown then
declare
S : Status.Data with Warnings => Off;
Answer : Response.Data;
begin
AWS.Log.Write
(TA.Server.Error_Log,
"Dead slot " & Utils.Image (TA.Line) & ' '
& Utils.CRLF_2_Spaces (Exception_Information (E)));
TA.Server.Exception_Handler
(E, TA.Server.Error_Log, (True, TA.Line, S), Answer);
end;
end if;
end Line;
----------------
-- Line_Tasks --
----------------
function Line_Tasks (Web_Server : HTTP) return Task_Id_Array is
Result : Task_Id_Array (Web_Server.Lines'Range);
begin
for J in Result'Range loop
Result (J) := Web_Server.Lines (J)'Identity;
end loop;
return Result;
end Line_Tasks;
--------------------------
-- Session_Private_Name --
--------------------------
function Session_Private_Name return String is
begin
return AWS.Config.Session_Private_Name (Server.Get_Current.Config);
end Session_Private_Name;
----------------------
-- Protocol_Handler --
----------------------
procedure Protocol_Handler (LA : in out Line_Attribute_Record) is separate;
------------------
-- Session_Name --
------------------
function Session_Name return String is
begin
return AWS.Config.Session_Name (Server.Get_Current.Config);
end Session_Name;
---------
-- Set --
---------
procedure Set
(Web_Server : in out HTTP;
Dispatcher : Dispatchers.Handler'Class) is
begin
Dispatchers.Free (Web_Server.New_Dispatcher);
Web_Server.New_Dispatcher :=
new Dispatchers.Handler'Class'
(Dispatchers.Handler'Class (Dispatcher.Clone));
end Set;
---------------
-- Set_Field --
---------------
procedure Set_Field (Id, Value : String) is
Task_Ptr : constant Line_Attribute.Attribute_Handle :=
Line_Attribute.Reference;
begin
AWS.Log.Set_Field (Task_Ptr.Server.Log, Task_Ptr.Log_Data, Id, Value);
end Set_Field;
------------------
-- Set_Security --
------------------
procedure Set_Security
(Web_Server : in out HTTP;
Certificate_Filename : String;
Security_Mode : Net.SSL.Method := Net.SSL.TLS_Server;
Key_Filename : String := "") is
begin
AWS.Config.Set.Certificate (Web_Server.Properties, Certificate_Filename);
if Key_Filename = "" then
AWS.Config.Set.Key (Web_Server.Properties, Certificate_Filename);
else
AWS.Config.Set.Key (Web_Server.Properties, Key_Filename);
end if;
AWS.Config.Set.Security_Mode
(Web_Server.Properties, Net.SSL.Method'Image (Security_Mode));
end Set_Security;
----------------------------
-- Set_Socket_Constructor --
----------------------------
procedure Set_Socket_Constructor
(Web_Server : in out HTTP;
Socket_Constructor : Net.Socket_Constructor) is
begin
Net.Acceptors.Set_Socket_Constructor
(Web_Server.Acceptor, Socket_Constructor);
end Set_Socket_Constructor;
--------------------
-- Set_SSL_Config --
--------------------
procedure Set_SSL_Config
(Web_Server : in out HTTP; SSL_Config : Net.SSL.Config) is
begin
Web_Server.SSL_Config := SSL_Config;
end Set_SSL_Config;
--------------------------------------
-- Set_Unexpected_Exception_Handler --
--------------------------------------
procedure Set_Unexpected_Exception_Handler
(Web_Server : in out HTTP;
Handler : Exceptions.Unexpected_Exception_Handler) is
begin
if Web_Server.Shutdown then
Web_Server.Exception_Handler := Handler;
else
raise Constraint_Error
with "Could not change exception handler on the active server.";
end if;
end Set_Unexpected_Exception_Handler;
--------------
-- Shutdown --
--------------
procedure Shutdown (Web_Server : in out HTTP) is
procedure Unchecked_Free is
new Unchecked_Deallocation (Line_Set, Line_Set_Access);
procedure Unchecked_Free is
new Unchecked_Deallocation (Slots, Slots_Access);
procedure Unchecked_Free is
new Unchecked_Deallocation (Line, Line_Access);
All_Lines_Terminated : Boolean := False;
Slot_State : Slot_Phase := Closed;
Slot_Index : Positive := Positive'Last;
Wait_Counter : Natural := 0;
begin
if Web_Server.Shutdown then
return;
end if;
-- Set the current server status to shutdown. This will ensure than no
-- request will be accepted anymore. All current lines on the
-- Accept_Socket_Serialized queue will return. This leaves a single
-- line to handle. See below.
Web_Server.Shutdown := True;
-- In the queue, waiting for a connection we have a single line waiting.
-- We need to unlock this line properly. Closing the server socket
-- directly is not possible as this line could be waiting on the routine
-- Accept_Socket or poll (see Wait_For implementation). On some OS (AIX
-- for example), trying to close a sockets waiting on a select/poll
-- will lock until the select/poll return or timeout. So the server
-- termination is a bit tricky and requires some attention.
-- Net.Acceptors doing shutdown in the accepting task,
-- Net.Acceptors.Shutdown only sending command into task where the
-- waiting for accept is.
Net.Acceptors.Shutdown (Web_Server.Acceptor);
-- Release the slots
for S in 1 .. Web_Server.Slots.N loop
declare
Socket : Socket_Access;
begin
Web_Server.Slots.Get_For_Shutdown (S, Socket);
if Socket /= null then
Net.Shutdown (Socket.all);
Web_Server.Slots.Shutdown_Done (S);
end if;
exception
when others =>
Web_Server.Slots.Shutdown_Done (S);
raise;
end;
end loop;
-- Wait for all lines to be terminated to be able to release associated
-- memory.
while not All_Lines_Terminated loop
All_Lines_Terminated := True;
for K in Web_Server.Lines'Range loop
if not Web_Server.Lines (K)'Terminated then
All_Lines_Terminated := False;
Slot_Index := K;
Slot_State := Web_Server.Slots.Get (K).Phase;
end if;
end loop;
delay 0.5;
Wait_Counter := Wait_Counter + 1;
if Wait_Counter > 30 then
Ada.Text_IO.Put_Line
(Text_IO.Current_Error,
"Can't terminate all lines. Slot" & Positive'Image (Slot_Index)
& " in " & Slot_State'Img & " state.");
exit;
end if;
end loop;
-- Release lines and slots memory
for K in Web_Server.Lines'Range loop
Unchecked_Free (Web_Server.Lines (K));
end loop;
Unchecked_Free (Web_Server.Lines);
Unchecked_Free (Web_Server.Slots);
Dispatchers.Free (Web_Server.Dispatcher);
-- Release the session server if needed
if CNF.Session (Web_Server.Properties) then
Session.Control.Shutdown;
end if;
Services.Transient_Pages.Control.Shutdown;
Net.WebSocket.Registry.Control.Shutdown;
if CNF.Security (Web_Server.Properties) then
Net.SSL.Release (Web_Server.SSL_Config);
end if;
-- Close logs, this ensure that all data will be written to the file
Log.Stop (Web_Server);
Log.Stop_Error (Web_Server);
-- Server removed
Server_Counter.Decrement (Value => Wait_Counter);
if Wait_Counter = 0 then
No_Servers.all;
end if;
end Shutdown;
---------------------
-- Skip_Log_Record --
---------------------
procedure Skip_Log_Record is
begin
Line_Attribute.Reference.Skip_Log := True;
end Skip_Log_Record;
-----------
-- Slots --
-----------
protected body Slots is
----------------------
-- Abort_On_Timeout --
----------------------
procedure Abort_On_Timeout
(Socket : out Socket_Access; Index : in out Positive)
is
use Ada.Calendar;
Now : constant Time := Clock;
function Test_Slot (S : Positive) return Boolean;
---------------
-- Test_Slot --
---------------
function Test_Slot (S : Positive) return Boolean is
begin
if Is_Abortable (S) then
Get_For_Shutdown (S, Socket);
if Socket /= null then
Index := S;
return True;
end if;
end if;
return False;
end Test_Slot;
begin
Socket := null;
if Now - Last_Force < 0.5 then
-- Look for force timeout not faster than two times in a second
return;
end if;
Last_Force := Now;
for S in Index + 1 .. Table'Last loop
if Test_Slot (S) then
return;
end if;
end loop;
for S in Table'First .. Index - 1 loop
if Test_Slot (S) then
return;
end if;
end loop;
end Abort_On_Timeout;
------------------------
-- Check_Data_Timeout --
------------------------
procedure Check_Data_Timeout (Index : Positive) is
use Ada.Real_Time;
begin
if Clock - Table (Index).Phase_Time_Stamp
> To_Time_Span (Timeouts (Cleaner, Table (Index).Phase))
then
raise Net.Socket_Error;
end if;
end Check_Data_Timeout;
----------------
-- Free_Slots --
----------------
function Free_Slots return Natural is
begin
return Count;
end Free_Slots;
---------
-- Get --
---------
function Get (Index : Positive) return Slot is
begin
return Table (Index);
end Get;
----------------------
-- Get_For_Shutdown --
----------------------
procedure Get_For_Shutdown
(Index : Positive; Socket : out Socket_Access) is
begin
if Table (Index).Phase not in Closed .. Aborted then
Socket := Table (Index).Sock;
if Socket = null then
Mark_Phase (Index, Aborted);
else
Mark_Phase (Index, In_Shutdown);
Shutdown_Count := Shutdown_Count + 1;
end if;
else
Socket := null;
end if;
end Get_For_Shutdown;
------------------
-- Get_Peername --
------------------
function Get_Peername (Index : Positive) return String is
Socket : constant Socket_Access := Table (Index).Sock;
begin
if Socket = null then
return "";
else
return Net.Peer_Addr (Socket.all);
end if;
end Get_Peername;
---------------------
-- Get_Socket_Info --
---------------------
function Get_Socket_Info (Index : Positive) return Socket_Data is
Socket : constant Socket_Access := Table (Index).Sock;
begin
if Socket = null then
return Socket_Data'
(Peername_Length => 1, Peername => "-", FD => 0);
else
declare
Peername : constant String := Net.Peer_Addr (Socket.all);
begin
return Socket_Data'
(Peername_Length => Peername'Length,
Peername => Peername,
FD => Net.Get_FD (Socket.all));
end;
end if;
end Get_Socket_Info;
-------------------------------------
-- Increment_Slot_Activity_Counter --
-------------------------------------
procedure Increment_Slot_Activity_Counter
(Index : Positive; Free_Slots : out Natural) is
begin
Table (Index).Slot_Activity_Counter :=
Table (Index).Slot_Activity_Counter + 1;
Table (Index).Alive_Counter :=
Table (Index).Alive_Counter + 1;
Free_Slots := Count;
end Increment_Slot_Activity_Counter;
------------------
-- Is_Abortable --
------------------
function Is_Abortable (Index : Positive) return Boolean is
use Real_Time;
Phase : constant Slot_Phase := Table (Index).Phase;
begin
return Phase in Abortable_Phase
and then Clock - Table (Index).Phase_Time_Stamp
> To_Time_Span (Timeouts (Force, Phase));
end Is_Abortable;
----------------
-- Mark_Phase --
----------------
procedure Mark_Phase (Index : Positive; Phase : Slot_Phase) is
Mode : constant array (Boolean) of Timeout_Mode :=
(True => Force, False => Cleaner);
begin
-- Check if the Aborted phase happen after socket operation
-- and before Mark_Phase call.
if Table (Index).Phase in In_Shutdown .. Aborted
and then Phase in Wait_For_Client .. Server_Processing
then
raise Net.Socket_Error;
end if;
Table (Index).Phase_Time_Stamp := Real_Time.Clock;
Table (Index).Phase := Phase;
if Phase in Data_Phase then
Net.Set_Timeout (Table (Index).Sock.all, Data_Timeouts (Phase));
elsif Phase in Abortable_Phase then
Net.Set_Timeout
(Table (Index).Sock.all, Timeouts (Mode (Count = 0), Phase));
end if;
end Mark_Phase;
-----------
-- Phase --
-----------
function Phase (Index : Positive) return Slot_Phase is
begin
return Table (Index).Phase;
end Phase;
------------------
-- Prepare_Back --
------------------
procedure Prepare_Back (Index : Positive; Possible : out Boolean) is
begin
Possible := not (Table (Index).Phase in In_Shutdown .. Aborted);
if Possible then
Mark_Phase (Index, Closed);
Table (Index).Sock := null;
end if;
end Prepare_Back;
-------------
-- Release --
-------------
entry Release
(Index : Positive; Shutdown : out Boolean) when Shutdown_Count = 0 is
begin
pragma Assert (Count < N);
-- No more release than it is possible
pragma Assert
((Table (Index).Phase = Closed
and then -- If phase is closed, then Sock must be null
Table (Index).Sock = null)
or else -- or phase is not closed
Table (Index).Phase /= Closed);
Count := Count + 1;
Shutdown := False;
if Table (Index).Phase /= Closed then
if not Table (Index).Socket_Taken then
if Table (Index).Phase /= Aborted then
-- We have to shutdown socket only if it is not in state:
-- In_Shutdow, Aborted or Closed.
Shutdown := True;
else
Net.Free (Table (Index).Sock);
end if;
else
Table (Index).Socket_Taken := False;
end if;
Mark_Phase (Index, Closed);
Table (Index).Sock := null;
end if;
end Release;
---------
-- Set --
---------
procedure Set
(Socket : not null access Net.Socket_Type'Class;
Index : Positive) is
begin
pragma Assert (Count > 0);
Table (Index).Sock := Socket;
Table (Index).Alive_Counter := 0;
Table (Index).Alive_Time_Stamp := Ada.Calendar.Clock;
Table (Index).Activity_Counter := Table (Index).Activity_Counter + 1;
Count := Count - 1;
end Set;
------------------
-- Set_Timeouts --
------------------
procedure Set_Timeouts
(Phase_Timeouts : Timeouts_Array;
Data_Timeouts : Data_Timeouts_Array) is
begin
Timeouts := Phase_Timeouts;
Slots.Data_Timeouts := Set_Timeouts.Data_Timeouts;
end Set_Timeouts;
-------------------
-- Shutdown_Done --
-------------------
procedure Shutdown_Done (Index : Positive) is
begin
if Table (Index).Phase = In_Shutdown then
Mark_Phase (Index, Aborted);
Shutdown_Count := Shutdown_Count - 1;
end if;
end Shutdown_Done;
------------------
-- Socket_Taken --
------------------
procedure Socket_Taken (Index : Positive) is
begin
Table (Index).Socket_Taken := True;
Table (Index).Sock := null;
end Socket_Taken;
end Slots;
------------------
-- Socket_Taken --
------------------
procedure Socket_Taken is
TA : constant Line_Attribute.Attribute_Handle :=
Line_Attribute.Reference;
begin
TA.Server.Slots.Socket_Taken (TA.Line);
end Socket_Taken;
----------------
-- SSL_Config --
----------------
function SSL_Config
(Web_Server : in out HTTP) return not null access Net.SSL.Config is
begin
return Web_Server.SSL_Config'Unchecked_Access;
end SSL_Config;
-----------
-- Start --
-----------
procedure Start
(Web_Server : in out HTTP;
Name : String;
Callback : Response.Callback;
Max_Connection : Positive := Default.Max_Connection;
Admin_URI : String := Default.Admin_URI;
Port : Natural := Default.Server_Port;
Security : Boolean := False;
Session : Boolean := False;
Case_Sensitive_Parameters : Boolean := True;
Upload_Directory : String := Default.Upload_Directory;
Line_Stack_Size : Positive := Default.Line_Stack_Size) is
begin
CNF.Set.Server_Name (Web_Server.Properties, Name);
CNF.Set.Admin_URI (Web_Server.Properties, Admin_URI);
CNF.Set.Server_Port (Web_Server.Properties, Port);
CNF.Set.Security (Web_Server.Properties, Security);
CNF.Set.Session (Web_Server.Properties, Session);
CNF.Set.Upload_Directory (Web_Server.Properties, Upload_Directory);
CNF.Set.Max_Connection (Web_Server.Properties, Max_Connection);
CNF.Set.Line_Stack_Size (Web_Server.Properties, Line_Stack_Size);
CNF.Set.Case_Sensitive_Parameters
(Web_Server.Properties, Case_Sensitive_Parameters);
Start (Web_Server, Dispatchers.Callback.Create (Callback));
end Start;
-----------
-- Start --
-----------
procedure Start
(Web_Server : in out HTTP;
Callback : Response.Callback;
Config : AWS.Config.Object) is
begin
Web_Server.Properties := Config;
Start (Web_Server, Dispatchers.Callback.Create (Callback));
end Start;
-----------
-- Start --
-----------
procedure Start
(Web_Server : in out HTTP;
Dispatcher : Dispatchers.Handler'Class;
Config : AWS.Config.Object) is
begin
Web_Server.Properties := Config;
Start (Web_Server, Dispatcher);
end Start;
-----------
-- Start --
-----------
procedure Start
(Web_Server : in out HTTP;
Dispatcher : Dispatchers.Handler'Class)
is
use type Net.SSL.Config;
Max_Connection : constant Positive :=
CNF.Max_Connection (Web_Server.Properties);
SC : Natural;
function Security_Mode return Net.SSL.Method;
-- Returns the server security mode, returns the default method if the
-- current one is not recognized.
-------------------
-- Security_Mode --
-------------------
function Security_Mode return Net.SSL.Method is
begin
return Net.SSL.Method'Value
(CNF.Security_Mode (Web_Server.Properties));
exception
when Constraint_Error =>
return Net.SSL.Method'Value (Default.Security_Mode);
end Security_Mode;
begin
-- If it is an SSL connection, initialize the SSL library
if CNF.Security (Web_Server.Properties)
and then Web_Server.SSL_Config = Net.SSL.Null_Config
then
Net.SSL.Initialize
(Web_Server.SSL_Config,
CNF.Certificate (Web_Server.Properties),
Security_Mode,
Priorities =>
CNF.Cipher_Priorities (Web_Server.Properties),
Ticket_Support =>
CNF.TLS_Ticket_Support (Web_Server.Properties),
Key_Filename =>
CNF.Key (Web_Server.Properties),
Exchange_Certificate =>
CNF.Exchange_Certificate (Web_Server.Properties),
Certificate_Required =>
CNF.Certificate_Required (Web_Server.Properties),
Trusted_CA_Filename =>
CNF.Trusted_CA (Web_Server.Properties),
CRL_Filename =>
CNF.CRL_File (Web_Server.Properties),
Session_Cache_Size =>
CNF.SSL_Session_Cache_Size (Web_Server.Properties));
end if;
-- Create the Web Server socket set
Net.Acceptors.Listen
(Acceptor => Web_Server.Acceptor,
Host => CNF.Server_Host (Web_Server.Properties),
Port => CNF.Server_Port (Web_Server.Properties),
Queue_Size => CNF.Accept_Queue_Size (Web_Server.Properties),
Family =>
Net.Family_Type'Value (CNF.Protocol_Family (Web_Server.Properties)),
Timeout =>
CNF.Cleaner_Wait_For_Client_Timeout (Web_Server.Properties),
First_Timeout =>
CNF.Cleaner_Client_Header_Timeout (Web_Server.Properties),
Force_Timeout =>
CNF.Force_Wait_For_Client_Timeout (Web_Server.Properties),
Force_First_Timeout =>
CNF.Force_Client_Header_Timeout (Web_Server.Properties),
Force_Length =>
CNF.Keep_Alive_Force_Limit (Web_Server.Properties),
Close_Length =>
CNF.Keep_Alive_Close_Limit (Web_Server.Properties),
Reuse_Address => CNF.Reuse_Address (Web_Server.Properties),
IPv6_Only => CNF.IPv6_Only (Web_Server.Properties));
-- Clone main dispatcher
Web_Server.Dispatcher :=
new Dispatchers.Handler'Class'
(Dispatchers.Handler'Class (Dispatcher.Clone));
-- Initialize slots
Web_Server.Slots := new Slots (Max_Connection);
-- Set timeouts
Web_Server.Slots.Set_Timeouts
((Cleaner => -- Timeouts for Line_Cleaner
(Wait_For_Client =>
CNF.Cleaner_Wait_For_Client_Timeout (Web_Server.Properties),
Client_Header =>
CNF.Cleaner_Client_Header_Timeout (Web_Server.Properties),
Client_Data =>
CNF.Cleaner_Client_Data_Timeout (Web_Server.Properties),
Server_Response =>
CNF.Cleaner_Server_Response_Timeout (Web_Server.Properties)),
Force => -- Force timeouts used when there is no free slot
(Wait_For_Client =>
CNF.Force_Wait_For_Client_Timeout (Web_Server.Properties),
Client_Header =>
CNF.Force_Client_Header_Timeout (Web_Server.Properties),
Client_Data =>
CNF.Force_Client_Data_Timeout (Web_Server.Properties),
Server_Response =>
CNF.Force_Server_Response_Timeout (Web_Server.Properties))),
(Client_Data =>
CNF.Receive_Timeout (Web_Server.Properties),
Server_Response =>
CNF.Send_Timeout (Web_Server.Properties)));
-- Started time
Web_Server.Start_Time := Calendar.Clock;
-- Initialize the connection lines
Web_Server.Lines := new Line_Set'
(1 .. Max_Connection => new Line
(Priority => CNF.Server_Priority (Web_Server.Properties),
Stack_Size => CNF.Line_Stack_Size (Web_Server.Properties)));
-- Set Shutdown to False here since it must be done before starting the
-- lines.
Web_Server.Shutdown := False;
-- Start each connection lines
for I in 1 .. Max_Connection loop
Web_Server.Lines (I).Start (Web_Server, I);
end loop;
-- Initialize session server
if AWS.Config.Session (Web_Server.Properties) then
AWS.Session.Control.Start
(Session_Check_Interval => CNF.Session_Cleanup_Interval,
Session_Lifetime => CNF.Session_Lifetime);
end if;
-- Initialize transient service
Services.Transient_Pages.Control.Register
(Transient_Check_Interval => CNF.Transient_Cleanup_Interval);
Server_Counter.Increment (Value => SC);
if SC = 1 then
First_Server.all;
end if;
-- Activate log if requested
if CNF.Log_Activated (Web_Server.Properties) then
Log.Start
(Web_Server,
Split_Mode => AWS.Log.Split_Mode'Value
(CNF.Log_Split_Mode (Web_Server.Properties)));
end if;
if CNF.Error_Log_Activated (Web_Server.Properties) then
Log.Start_Error
(Web_Server,
Split_Mode => AWS.Log.Split_Mode'Value
(CNF.Error_Log_Split_Mode (Web_Server.Properties)));
end if;
end Start;
----------
-- Wait --
----------
procedure Wait (Mode : Termination := No_Server) is
begin
case Mode is
when No_Server =>
Server_Counter.Zero;
when Q_Key_Pressed =>
declare
K : Character;
begin
loop
Text_IO.Get_Immediate (K);
exit when K = 'q' or else K = 'Q';
end loop;
end;
when Forever =>
loop
delay Duration'Last;
end loop;
end case;
end Wait;
end AWS.Server;
|
stardog-union/boost | Ada | 4,443 | ads | ----------------------------------------------------------------
-- ZLib for Ada thick binding. --
-- --
-- Copyright (C) 2002-2003 Dmitriy Anisimkov --
-- --
-- Open source license information is in the zlib.ads file. --
----------------------------------------------------------------
-- $Id: zlib-streams.ads,v 1.12 2004/05/31 10:53:40 vagul Exp $
package ZLib.Streams is
type Stream_Mode is (In_Stream, Out_Stream, Duplex);
type Stream_Access is access all Ada.Streams.Root_Stream_Type'Class;
type Stream_Type is
new Ada.Streams.Root_Stream_Type with private;
procedure Read
(Stream : in out Stream_Type;
Item : out Ada.Streams.Stream_Element_Array;
Last : out Ada.Streams.Stream_Element_Offset);
procedure Write
(Stream : in out Stream_Type;
Item : in Ada.Streams.Stream_Element_Array);
procedure Flush
(Stream : in out Stream_Type;
Mode : in Flush_Mode := Sync_Flush);
-- Flush the written data to the back stream,
-- all data placed to the compressor is flushing to the Back stream.
-- Should not be used until necessary, because it is decreasing
-- compression.
function Read_Total_In (Stream : in Stream_Type) return Count;
pragma Inline (Read_Total_In);
-- Return total number of bytes read from back stream so far.
function Read_Total_Out (Stream : in Stream_Type) return Count;
pragma Inline (Read_Total_Out);
-- Return total number of bytes read so far.
function Write_Total_In (Stream : in Stream_Type) return Count;
pragma Inline (Write_Total_In);
-- Return total number of bytes written so far.
function Write_Total_Out (Stream : in Stream_Type) return Count;
pragma Inline (Write_Total_Out);
-- Return total number of bytes written to the back stream.
procedure Create
(Stream : out Stream_Type;
Mode : in Stream_Mode;
Back : in Stream_Access;
Back_Compressed : in Boolean;
Level : in Compression_Level := Default_Compression;
Strategy : in Strategy_Type := Default_Strategy;
Header : in Header_Type := Default;
Read_Buffer_Size : in Ada.Streams.Stream_Element_Offset
:= Default_Buffer_Size;
Write_Buffer_Size : in Ada.Streams.Stream_Element_Offset
:= Default_Buffer_Size);
-- Create the Comression/Decompression stream.
-- If mode is In_Stream then Write operation is disabled.
-- If mode is Out_Stream then Read operation is disabled.
-- If Back_Compressed is true then
-- Data written to the Stream is compressing to the Back stream
-- and data read from the Stream is decompressed data from the Back stream.
-- If Back_Compressed is false then
-- Data written to the Stream is decompressing to the Back stream
-- and data read from the Stream is compressed data from the Back stream.
-- !!! When the Need_Header is False ZLib-Ada is using undocumented
-- ZLib 1.1.4 functionality to do not create/wait for ZLib headers.
function Is_Open (Stream : Stream_Type) return Boolean;
procedure Close (Stream : in out Stream_Type);
private
use Ada.Streams;
type Buffer_Access is access all Stream_Element_Array;
type Stream_Type
is new Root_Stream_Type with
record
Mode : Stream_Mode;
Buffer : Buffer_Access;
Rest_First : Stream_Element_Offset;
Rest_Last : Stream_Element_Offset;
-- Buffer for Read operation.
-- We need to have this buffer in the record
-- because not all read data from back stream
-- could be processed during the read operation.
Buffer_Size : Stream_Element_Offset;
-- Buffer size for write operation.
-- We do not need to have this buffer
-- in the record because all data could be
-- processed in the write operation.
Back : Stream_Access;
Reader : Filter_Type;
Writer : Filter_Type;
end record;
end ZLib.Streams;
|
zhmu/ananas | Ada | 13,954 | adb | ------------------------------------------------------------------------------
-- --
-- GNAT RUN-TIME COMPONENTS --
-- --
-- S Y S T E M . P O O L _ S I Z E --
-- --
-- B o d y --
-- --
-- Copyright (C) 1992-2022, Free Software Foundation, Inc. --
-- --
-- GNAT is free software; you can redistribute it and/or modify it under --
-- terms of the GNU General Public License as published by the Free Soft- --
-- ware Foundation; either version 3, or (at your option) any later ver- --
-- sion. GNAT is distributed in the hope that it will be useful, but WITH- --
-- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY --
-- or FITNESS FOR A PARTICULAR PURPOSE. --
-- --
-- As a special exception under Section 7 of GPL version 3, you are granted --
-- additional permissions described in the GCC Runtime Library Exception, --
-- version 3.1, as published by the Free Software Foundation. --
-- --
-- You should have received a copy of the GNU General Public License and --
-- a copy of the GCC Runtime Library Exception along with this program; --
-- see the files COPYING3 and COPYING.RUNTIME respectively. If not, see --
-- <http://www.gnu.org/licenses/>. --
-- --
-- GNAT was originally developed by the GNAT team at New York University. --
-- Extensive contributions were provided by Ada Core Technologies Inc. --
-- --
------------------------------------------------------------------------------
with System.Soft_Links;
with Ada.Unchecked_Conversion;
package body System.Pool_Size is
package SSE renames System.Storage_Elements;
use type SSE.Storage_Offset;
-- Even though these storage pools are typically only used by a single
-- task, if multiple tasks are declared at the same or a more nested scope
-- as the storage pool, there still may be concurrent access. The current
-- implementation of Stack_Bounded_Pool always uses a global lock for
-- protecting access. This should eventually be replaced by an atomic
-- linked list implementation for efficiency reasons.
package SSL renames System.Soft_Links;
type Storage_Count_Access is access SSE.Storage_Count;
function To_Storage_Count_Access is
new Ada.Unchecked_Conversion (Address, Storage_Count_Access);
SC_Size : constant := SSE.Storage_Count'Object_Size / System.Storage_Unit;
package Variable_Size_Management is
-- Embedded pool that manages allocation of variable-size data
-- This pool is used as soon as the Elmt_Size of the pool object is 0
-- Allocation is done on the first chunk long enough for the request.
-- Deallocation just puts the freed chunk at the beginning of the list.
procedure Initialize (Pool : in out Stack_Bounded_Pool);
procedure Allocate
(Pool : in out Stack_Bounded_Pool;
Address : out System.Address;
Storage_Size : SSE.Storage_Count;
Alignment : SSE.Storage_Count);
procedure Deallocate
(Pool : in out Stack_Bounded_Pool;
Address : System.Address;
Storage_Size : SSE.Storage_Count;
Alignment : SSE.Storage_Count);
end Variable_Size_Management;
package Vsize renames Variable_Size_Management;
--------------
-- Allocate --
--------------
procedure Allocate
(Pool : in out Stack_Bounded_Pool;
Address : out System.Address;
Storage_Size : SSE.Storage_Count;
Alignment : SSE.Storage_Count)
is
begin
SSL.Lock_Task.all;
if Pool.Elmt_Size = 0 then
Vsize.Allocate (Pool, Address, Storage_Size, Alignment);
elsif Pool.First_Free /= 0 then
Address := Pool.The_Pool (Pool.First_Free)'Address;
Pool.First_Free := To_Storage_Count_Access (Address).all;
elsif
Pool.First_Empty <= (Pool.Pool_Size - Pool.Aligned_Elmt_Size + 1)
then
Address := Pool.The_Pool (Pool.First_Empty)'Address;
Pool.First_Empty := Pool.First_Empty + Pool.Aligned_Elmt_Size;
else
raise Storage_Error;
end if;
SSL.Unlock_Task.all;
exception
when others =>
SSL.Unlock_Task.all;
raise;
end Allocate;
----------------
-- Deallocate --
----------------
procedure Deallocate
(Pool : in out Stack_Bounded_Pool;
Address : System.Address;
Storage_Size : SSE.Storage_Count;
Alignment : SSE.Storage_Count)
is
begin
SSL.Lock_Task.all;
if Pool.Elmt_Size = 0 then
Vsize.Deallocate (Pool, Address, Storage_Size, Alignment);
else
To_Storage_Count_Access (Address).all := Pool.First_Free;
Pool.First_Free := Address - Pool.The_Pool'Address + 1;
end if;
SSL.Unlock_Task.all;
exception
when others =>
SSL.Unlock_Task.all;
raise;
end Deallocate;
----------------
-- Initialize --
----------------
procedure Initialize (Pool : in out Stack_Bounded_Pool) is
-- Define the appropriate alignment for allocations. This is the
-- maximum of the requested alignment, and the alignment required
-- for Storage_Count values. The latter test is to ensure that we
-- can properly reference the linked list pointers for free lists.
Align : constant SSE.Storage_Count :=
SSE.Storage_Count'Max
(SSE.Storage_Count'Alignment, Pool.Alignment);
begin
if Pool.Elmt_Size = 0 then
Vsize.Initialize (Pool);
else
Pool.First_Free := 0;
Pool.First_Empty := 1;
-- Compute the size to allocate given the size of the element and
-- the possible alignment requirement as defined above.
Pool.Aligned_Elmt_Size :=
SSE.Storage_Count'Max (SC_Size,
((Pool.Elmt_Size + Align - 1) / Align) * Align);
end if;
end Initialize;
------------------
-- Storage_Size --
------------------
function Storage_Size
(Pool : Stack_Bounded_Pool) return SSE.Storage_Count
is
begin
return Pool.Pool_Size;
end Storage_Size;
------------------------------
-- Variable_Size_Management --
------------------------------
package body Variable_Size_Management is
Minimum_Size : constant := 2 * SC_Size;
procedure Set_Size
(Pool : Stack_Bounded_Pool;
Chunk, Size : SSE.Storage_Count);
-- Update the field 'size' of a chunk of available storage
procedure Set_Next
(Pool : Stack_Bounded_Pool;
Chunk, Next : SSE.Storage_Count);
-- Update the field 'next' of a chunk of available storage
function Size
(Pool : Stack_Bounded_Pool;
Chunk : SSE.Storage_Count) return SSE.Storage_Count;
-- Fetch the field 'size' of a chunk of available storage
function Next
(Pool : Stack_Bounded_Pool;
Chunk : SSE.Storage_Count) return SSE.Storage_Count;
-- Fetch the field 'next' of a chunk of available storage
function Chunk_Of
(Pool : Stack_Bounded_Pool;
Addr : System.Address) return SSE.Storage_Count;
-- Give the chunk number in the pool from its Address
--------------
-- Allocate --
--------------
procedure Allocate
(Pool : in out Stack_Bounded_Pool;
Address : out System.Address;
Storage_Size : SSE.Storage_Count;
Alignment : SSE.Storage_Count)
is
Chunk : SSE.Storage_Count;
New_Chunk : SSE.Storage_Count;
Prev_Chunk : SSE.Storage_Count;
Our_Align : constant SSE.Storage_Count :=
SSE.Storage_Count'Max (SSE.Storage_Count'Alignment,
Alignment);
Align_Size : constant SSE.Storage_Count :=
SSE.Storage_Count'Max (
Minimum_Size,
((Storage_Size + Our_Align - 1) / Our_Align) *
Our_Align);
begin
-- Look for the first big enough chunk
Prev_Chunk := Pool.First_Free;
Chunk := Next (Pool, Prev_Chunk);
while Chunk /= 0 and then Size (Pool, Chunk) < Align_Size loop
Prev_Chunk := Chunk;
Chunk := Next (Pool, Chunk);
end loop;
-- Raise storage_error if no big enough chunk available
if Chunk = 0 then
raise Storage_Error;
end if;
-- When the chunk is bigger than what is needed, take appropriate
-- amount and build a new shrinked chunk with the remainder.
if Size (Pool, Chunk) - Align_Size > Minimum_Size then
New_Chunk := Chunk + Align_Size;
Set_Size (Pool, New_Chunk, Size (Pool, Chunk) - Align_Size);
Set_Next (Pool, New_Chunk, Next (Pool, Chunk));
Set_Next (Pool, Prev_Chunk, New_Chunk);
-- If the chunk is the right size, just delete it from the chain
else
Set_Next (Pool, Prev_Chunk, Next (Pool, Chunk));
end if;
Address := Pool.The_Pool (Chunk)'Address;
end Allocate;
--------------
-- Chunk_Of --
--------------
function Chunk_Of
(Pool : Stack_Bounded_Pool;
Addr : System.Address) return SSE.Storage_Count
is
begin
return 1 + abs (Addr - Pool.The_Pool (1)'Address);
end Chunk_Of;
----------------
-- Deallocate --
----------------
procedure Deallocate
(Pool : in out Stack_Bounded_Pool;
Address : System.Address;
Storage_Size : SSE.Storage_Count;
Alignment : SSE.Storage_Count)
is
pragma Warnings (Off, Pool);
Align_Size : constant SSE.Storage_Count :=
((Storage_Size + Alignment - 1) / Alignment) *
Alignment;
Chunk : constant SSE.Storage_Count := Chunk_Of (Pool, Address);
begin
-- Attach the freed chunk to the chain
Set_Size (Pool, Chunk,
SSE.Storage_Count'Max (Align_Size, Minimum_Size));
Set_Next (Pool, Chunk, Next (Pool, Pool.First_Free));
Set_Next (Pool, Pool.First_Free, Chunk);
end Deallocate;
----------------
-- Initialize --
----------------
procedure Initialize (Pool : in out Stack_Bounded_Pool) is
begin
Pool.First_Free := 1;
if Pool.Pool_Size > Minimum_Size then
Set_Next (Pool, Pool.First_Free, Pool.First_Free + Minimum_Size);
Set_Size (Pool, Pool.First_Free, 0);
Set_Size (Pool, Pool.First_Free + Minimum_Size,
Pool.Pool_Size - Minimum_Size);
Set_Next (Pool, Pool.First_Free + Minimum_Size, 0);
end if;
end Initialize;
----------
-- Next --
----------
function Next
(Pool : Stack_Bounded_Pool;
Chunk : SSE.Storage_Count) return SSE.Storage_Count
is
begin
pragma Warnings (Off);
-- Kill alignment warnings, we are careful to make sure
-- that the alignment is correct.
return To_Storage_Count_Access
(Pool.The_Pool (Chunk + SC_Size)'Address).all;
pragma Warnings (On);
end Next;
--------------
-- Set_Next --
--------------
procedure Set_Next
(Pool : Stack_Bounded_Pool;
Chunk, Next : SSE.Storage_Count)
is
begin
pragma Warnings (Off);
-- Kill alignment warnings, we are careful to make sure
-- that the alignment is correct.
To_Storage_Count_Access
(Pool.The_Pool (Chunk + SC_Size)'Address).all := Next;
pragma Warnings (On);
end Set_Next;
--------------
-- Set_Size --
--------------
procedure Set_Size
(Pool : Stack_Bounded_Pool;
Chunk, Size : SSE.Storage_Count)
is
begin
pragma Warnings (Off);
-- Kill alignment warnings, we are careful to make sure
-- that the alignment is correct.
To_Storage_Count_Access
(Pool.The_Pool (Chunk)'Address).all := Size;
pragma Warnings (On);
end Set_Size;
----------
-- Size --
----------
function Size
(Pool : Stack_Bounded_Pool;
Chunk : SSE.Storage_Count) return SSE.Storage_Count
is
begin
pragma Warnings (Off);
-- Kill alignment warnings, we are careful to make sure
-- that the alignment is correct.
return To_Storage_Count_Access (Pool.The_Pool (Chunk)'Address).all;
pragma Warnings (On);
end Size;
end Variable_Size_Management;
end System.Pool_Size;
|
reznikmm/matreshka | Ada | 3,689 | 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_Value_Attributes is
pragma Preelaborate;
type ODF_Form_Value_Attribute is limited interface
and XML.DOM.Attributes.DOM_Attribute;
type ODF_Form_Value_Attribute_Access is
access all ODF_Form_Value_Attribute'Class
with Storage_Size => 0;
end ODF.DOM.Form_Value_Attributes;
|
AdaDoom3/oto | Ada | 7,582 | adb | ------------------------------------------------------------------------------
-- EMAIL: <[email protected]> --
-- License: ISC --
-- --
-- Copyright © 2014 - 2016 darkestkhan --
------------------------------------------------------------------------------
-- Permission to use, copy, modify, and/or distribute this software for any --
-- purpose with or without fee is hereby granted, provided that the above --
-- copyright notice and this permission notice appear in all copies. --
-- --
-- The software is provided "as is" and the author disclaims all warranties --
-- with regard to this software including all implied warranties of --
-- merchantability and fitness. In no event shall the author be liable for --
-- any special, direct, indirect, or consequential damages or any damages --
-- whatsoever resulting from loss of use, data or profits, whether in an --
-- action of contract, negligence or other tortious action, arising out of --
-- or in connection with the use or performance of this software. --
------------------------------------------------------------------------------
with Interfaces.C;
with Interfaces.C.Strings;
package body Oto.ALUT is
---------------------------------------------------------------------------
-------------------
-- R E N A M E S --
-------------------
---------------------------------------------------------------------------
package IC renames Interfaces.C;
package CStrings renames Interfaces.C.Strings;
---------------------------------------------------------------------------
---------------------------------
-- I N S T A N T I A T I O N S --
---------------------------------
---------------------------------------------------------------------------
procedure Free is new
Ada.Unchecked_Deallocation (IC.char_array, CStrings.char_array_access);
---------------------------------------------------------------------------
-------------------------------------------
-- S U B P R O G R A M S ' B O D I E S --
-------------------------------------------
---------------------------------------------------------------------------
function Init (Arguments: in String_Array) return AL.Bool
is
function alutInit
( Argcp : in AL.Pointer;
Argv : in CStrings.chars_ptr_array
) return AL.Bool
with Import => True, Convention => StdCall, External_Name => "alutInit";
Argcp : constant AL.Int := AL.Int (Arguments'Length);
CString: CStrings.char_array_access;
Success: AL.Bool;
begin
if Arguments'Length /= 0 then
declare
Argv: CStrings.chars_ptr_array (0 .. IC.size_t (Arguments'Length - 1));
begin
for K in Argv'Range loop
CString := new
IC.char_array'(IC.To_C
( Arguments (Arguments'First + Natural (K)).all) );
Argv (K) := CStrings.To_Chars_Ptr (CString);
Free (CString);
end loop;
Success := alutInit (Argcp'Address, Argv);
for K in Argv'Range loop
CStrings.Free (Argv (K));
end loop;
end;
else
declare
Argv : CStrings.chars_ptr_array (1 .. 0);
begin
Success := alutInit (Argcp'Address, Argv);
end;
end if;
return Success;
end Init;
---------------------------------------------------------------------------
function Init_Without_Context (Arguments: in String_Array) return AL.Bool
is
function alutInitWithoutContext
( Argcp : in AL.Pointer;
Argv : in CStrings.chars_ptr_array
) return AL.Bool
with Import => True, Convention => StdCall,
External_Name => "alutInitWithoutContext";
Argcp : constant AL.Int := AL.Int (Arguments'Length);
CString: CStrings.char_array_access;
Success: AL.Bool;
begin
if Arguments'Length /= 0 then
declare
Argv: CStrings.chars_ptr_array (0 .. IC.size_t (Arguments'Length - 1));
begin
for K in Argv'Range loop
CString := new
IC.char_array'(IC.To_C
( Arguments (Arguments'First + Natural (K)).all) );
Argv (K) := CStrings.To_Chars_Ptr (CString);
Free (CString);
end loop;
Success := alutInitWithoutContext (Argcp'Address, Argv);
for K in Argv'Range loop
CStrings.Free (Argv (K));
end loop;
end;
else
declare
Argv : CStrings.chars_ptr_array (1 .. 0);
begin
Success := alutInitWithoutContext (Argcp'Address, Argv);
end;
end if;
return Success;
end Init_Without_Context;
---------------------------------------------------------------------------
function Get_Error_String (Error: in AL.Enum) return String
is
function alutGetErrorString (Error: in AL.Enum) return CStrings.chars_ptr
with Import => True, Convention => StdCall,
External_Name => "alutGetErrorString";
begin
return IC.To_Ada (CStrings.Value (alutGetErrorString (Error)));
end Get_Error_String;
---------------------------------------------------------------------------
function Create_Buffer_From_File (File_Name: in String) return AL.UInt
is
function alutCreateBufferFromFile (F: in CStrings.chars_ptr) return AL.UInt
with Import => True, Convention => StdCall,
External_Name => "alutCreateBufferFromFile";
CString: CStrings.char_array_access :=
new IC.char_array'(IC.To_C (File_Name));
Buffer: AL.UInt;
begin
Buffer := alutCreateBufferFromFile (CStrings.To_Chars_Ptr (CString));
Free (CString);
return Buffer;
end Create_Buffer_From_File;
---------------------------------------------------------------------------
function Load_Memory_From_File
( File_Name : in String;
Format : in AL.Pointer;
Size : in AL.Pointer;
Frequency : in AL.Pointer
) return AL.Pointer
is
function alutLoadMemoryFromFile
( File_Name : in CStrings.chars_ptr;
Format : in AL.Pointer;
Size : in AL.Pointer;
Frequency : in AL.Pointer
) return AL.Pointer
with Import => True, Convention => StdCall,
External_Name => "alutLoadMemoryFromFile";
CString: CStrings.char_array_access :=
new IC.char_array'(IC.To_C (File_Name));
Address: AL.Pointer;
begin
Address :=
alutLoadMemoryFromFile
( CStrings.To_Chars_Ptr (CString),
Format,
Size,
Frequency
);
Free (CString);
return Address;
end Load_Memory_From_File;
---------------------------------------------------------------------------
function Get_MIME_Types (Loader: in AL.Enum) return String
is
function alutGetMIMETypes (Loader: in AL.Enum) return CStrings.chars_ptr
with Import => True, Convention => StdCall,
External_Name => "alutGetMIMETypes";
begin
return IC.To_Ada (CStrings.Value (alutGetMIMETypes (Loader)));
end Get_MIME_Types;
---------------------------------------------------------------------------
end Oto.ALUT;
|
MinimSecure/unum-sdk | Ada | 871 | ads | -- Copyright 2016-2019 Free Software Foundation, Inc.
--
-- This program is free software; you can redistribute it and/or modify
-- it under the terms of the GNU General Public License as published by
-- the Free Software Foundation; either version 3 of the License, or
-- (at your option) any later version.
--
-- This program is distributed in the hope that it will be useful,
-- but WITHOUT ANY WARRANTY; without even the implied warranty of
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-- GNU General Public License for more details.
--
-- You should have received a copy of the GNU General Public License
-- along with this program. If not, see <http://www.gnu.org/licenses/>.
package Pkg is
type Bits_Type is array (1 .. 10) of Boolean
with Pack => True;
procedure Flip (Bits : in out Bits_Type; I : Natural);
end Pkg;
|
charlie5/cBound | Ada | 1,612 | ads | -- This file is generated by SWIG. Please do not modify by hand.
--
with Interfaces;
with Interfaces.C;
with Interfaces.C.Pointers;
package xcb.xcb_change_hosts_request_t is
-- Item
--
type Item is record
major_opcode : aliased Interfaces.Unsigned_8;
mode : aliased Interfaces.Unsigned_8;
length : aliased Interfaces.Unsigned_16;
family : aliased Interfaces.Unsigned_8;
pad0 : aliased Interfaces.Unsigned_8;
address_len : aliased Interfaces.Unsigned_16;
end record;
-- Item_Array
--
type Item_Array is
array
(Interfaces.C.size_t range <>) of aliased xcb.xcb_change_hosts_request_t
.Item;
-- Pointer
--
package C_Pointers is new Interfaces.C.Pointers
(Index => Interfaces.C.size_t,
Element => xcb.xcb_change_hosts_request_t.Item,
Element_Array => xcb.xcb_change_hosts_request_t.Item_Array,
Default_Terminator => (others => <>));
subtype Pointer is C_Pointers.Pointer;
-- Pointer_Array
--
type Pointer_Array is
array
(Interfaces.C.size_t range <>) of aliased xcb.xcb_change_hosts_request_t
.Pointer;
-- Pointer_Pointer
--
package C_Pointer_Pointers is new Interfaces.C.Pointers
(Index => Interfaces.C.size_t,
Element => xcb.xcb_change_hosts_request_t.Pointer,
Element_Array => xcb.xcb_change_hosts_request_t.Pointer_Array,
Default_Terminator => null);
subtype Pointer_Pointer is C_Pointer_Pointers.Pointer;
end xcb.xcb_change_hosts_request_t;
|
PThierry/ewok-kernel | Ada | 35 | ads | ../stm32f439/soc-dwt-interfaces.ads |
reznikmm/matreshka | Ada | 4,570 | ads | ------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- Localization, Internationalization, Globalization for Ada --
-- --
-- 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$
------------------------------------------------------------------------------
private package Matreshka.Internals.Text_Codecs.KOI8U is
pragma Preelaborate;
-------------------------
-- KOI8U_Decoder --
-------------------------
type KOI8U_Decoder is new Abstract_Decoder with private;
overriding function Is_Error (Self : KOI8U_Decoder) return Boolean;
overriding function Is_Mailformed
(Self : KOI8U_Decoder) return Boolean;
overriding procedure Decode_Append
(Self : in out KOI8U_Decoder;
Data : Ada.Streams.Stream_Element_Array;
String : in out Matreshka.Internals.Strings.Shared_String_Access);
function Decoder (Mode : Decoder_Mode) return Abstract_Decoder'Class;
-------------------------
-- KOI8U_Encoder --
-------------------------
type KOI8U_Encoder is new Abstract_Encoder with private;
overriding procedure Encode
(Self : in out KOI8U_Encoder;
String : not null Matreshka.Internals.Strings.Shared_String_Access;
Buffer : out MISEV.Shared_Stream_Element_Vector_Access);
function Encoder return Abstract_Encoder'Class;
private
type KOI8U_Decoder is new Abstract_Decoder with null record;
type KOI8U_Encoder is new Abstract_Encoder with null record;
end Matreshka.Internals.Text_Codecs.KOI8U;
|
onox/orka | Ada | 5,618 | 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.Exceptions;
with Ada.Tags;
with Orka.Containers.Bounded_Vectors;
with Orka.Futures;
with Orka.Loggers;
with Orka.Logging.Default;
package body Orka.Jobs.Executors is
use all type Orka.Logging.Default_Module;
use all type Orka.Logging.Severity;
procedure Log is new Orka.Logging.Default.Generic_Log (Engine);
function Get_Root_Dependent (Element : Job_Ptr) return Job_Ptr is
Result : Job_Ptr := Element;
begin
while Result.Dependent /= Null_Job loop
Result := Result.Dependent;
end loop;
return Result;
end Get_Root_Dependent;
procedure Execute_Jobs
(Name : String;
Kind : Queues.Executor_Kind;
Queue : Queues.Queue_Ptr)
is
use type Futures.Status;
use Ada.Exceptions;
Pair : Queues.Pair;
Stop : Boolean := False;
Null_Pair : constant Queues.Pair := (others => <>);
package Vectors is new Orka.Containers.Bounded_Vectors (Positive, Job_Ptr);
type Executor_Context (Jobs : not null access Vectors.Vector)
is new Execution_Context with null record;
overriding
procedure Enqueue (Object : Executor_Context; Element : Job_Ptr) is
begin
Object.Jobs.Append (Element);
end Enqueue;
begin
loop
Queue.Dequeue (Kind) (Pair, Stop);
exit when Stop;
declare
Job : Job_Ptr renames Pair.Job;
Future : Futures.Pointers.Reference renames Pair.Future.Get;
Promise : Futures.Promise'Class renames Futures.Promise'Class (Future.Value.all);
Jobs : aliased Vectors.Vector (Capacity => Maximum_Enqueued_By_Job);
Context : Executor_Context (Jobs'Access);
procedure Set_Root_Dependent (Last_Job : Job_Ptr) is
Root_Dependents : Vectors.Vector (Capacity => Jobs.Length);
procedure Set_Dependencies (Elements : Vectors.Element_Array) is
begin
Last_Job.Set_Dependencies (Dependency_Array (Elements));
end Set_Dependencies;
begin
for Job of Jobs loop
declare
Root : constant Job_Ptr := Get_Root_Dependent (Job);
begin
if (for all Dependent of Root_Dependents => Root /= Dependent) then
Root_Dependents.Append (Root);
end if;
end;
end loop;
Root_Dependents.Query (Set_Dependencies'Access);
end Set_Root_Dependent;
Tag : String renames Ada.Tags.Expanded_Name (Job'Tag);
begin
if Future.Current_Status = Futures.Waiting then
Promise.Set_Status (Futures.Running);
end if;
if Future.Current_Status = Futures.Running then
begin
Job.Execute (Context);
exception
when Error : others =>
Promise.Set_Failed (Error);
Log (Loggers.Error,
Kind'Image & " job " & Tag & " " & Exception_Information (Error));
end;
else
Log (Warning,
Kind'Image & " job " & Tag & " already " & Future.Current_Status'Image);
end if;
if Job.Dependent /= Null_Job then
-- Make the root dependents of the jobs in Jobs
-- dependencies of Job.Dependent
if not Jobs.Is_Empty then
Set_Root_Dependent (Job.Dependent);
end if;
-- If another job depends on this job, decrement its dependencies counter
-- and if it has reached zero then it can be scheduled
if Job.Dependent.Decrement_Dependencies then
pragma Assert (Jobs.Is_Empty);
Queue.Enqueue (Job.Dependent, Pair.Future);
end if;
elsif Jobs.Is_Empty then
Promise.Set_Status (Futures.Done);
else
-- If the job has enqueued new jobs, we need to create an
-- empty job which has the root dependents of these new jobs
-- as dependencies. This is so that the empty job will be the
-- last job that is given Pair.Future
Set_Root_Dependent (Create_Empty_Job);
end if;
if not Jobs.Is_Empty then
for Job of Jobs loop
Queue.Enqueue (Job, Pair.Future);
end loop;
end if;
Free (Job);
end;
-- Finalize the smart pointer (Pair.Future) to reduce the number
-- of references to the Future object
Pair := Null_Pair;
end loop;
exception
when Error : others =>
Log (Loggers.Error, Exception_Information (Error));
end Execute_Jobs;
end Orka.Jobs.Executors;
|
reznikmm/matreshka | Ada | 4,608 | 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_Chart.Hole_Size_Attributes is
------------
-- Create --
------------
overriding function Create
(Parameters : not null access Matreshka.DOM_Attributes.Attribute_L2_Parameters)
return Chart_Hole_Size_Attribute_Node is
begin
return Self : Chart_Hole_Size_Attribute_Node do
Matreshka.ODF_Chart.Constructors.Initialize
(Self'Unchecked_Access,
Parameters.Document,
Matreshka.ODF_String_Constants.Chart_Prefix);
end return;
end Create;
--------------------
-- Get_Local_Name --
--------------------
overriding function Get_Local_Name
(Self : not null access constant Chart_Hole_Size_Attribute_Node)
return League.Strings.Universal_String
is
pragma Unreferenced (Self);
begin
return Matreshka.ODF_String_Constants.Hole_Size_Attribute;
end Get_Local_Name;
begin
Matreshka.DOM_Documents.Register_Attribute
(Matreshka.ODF_String_Constants.Chart_URI,
Matreshka.ODF_String_Constants.Hole_Size_Attribute,
Chart_Hole_Size_Attribute_Node'Tag);
end Matreshka.ODF_Chart.Hole_Size_Attributes;
|
NCommander/dnscatcher | Ada | 4,346 | adb | -- Copyright 2019 Michael Casadevall <[email protected]>
--
-- Permission is hereby granted, free of charge, to any person obtaining a copy
-- of this software and associated documentation files (the "Software"), to
-- deal in the Software without restriction, including without limitation the
-- rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
-- sell copies of the Software, and to permit persons to whom the Software is
-- furnished to do so, subject to the following conditions:
--
-- The above copyright notice and this permission notice shall be included in
-- all copies or substantial portions of the Software.
--
-- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
-- THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
-- FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
-- DEALINGS IN THE SOFTWARE.
with Interfaces; use Interfaces;
package body DNSCatcher.DNS.Processor.RData.OPT_Parser is
-- EDNS is a pretty harry beast and incorporates a lot of stuff in ways
-- different from all other packets. As such parsing is quite a bit more
-- complicated than it is for other packet types.
procedure From_Parsed_RR
(This : in out Parsed_OPT_RData;
DNS_Header : DNS_Packet_Header;
Parsed_RR : Parsed_DNS_Resource_Record)
is
Top_Half_TTL : Interfaces.Unsigned_16;
Bottom_Half_TTL : Interfaces.Unsigned_16;
Full_RCode : Interfaces.Unsigned_16 := 0;
begin
-- RClass is the UDP requester size
This.Requester_UDP_Size := Parsed_RR.RClass;
--!pp off
-- TTL is subdivided into the following parts
-- 0..7 - Extended RCode
-- 8..16 - EDNS Version (must be zero)
--
-- The remainder is a 16-bit flags register set by
-- IANA. At the time of writing, only a single flag,
-- DO, is specified. The registry is available here:
-- https://www.iana.org/assignments/dns-parameters/dns-parameters.xhtml#dns-parameters-13
--
-- EDNS Flags:
-- 17 - DO
-- 18..32 - Must be zero
--
-- The horseshit however continues. Despite being a 32-bit int, it's
-- essentially two 16-bit ones, so we need to split this into a high
-- and low half and then compare it. My brain is already hurting ...
--!pp on
-- To get the full RCode, we need to take the 4-bit "normal" RCode, then
-- tack on the EDNS ones at the top for 12 bits total
-- Since we're network byte order, load the high half first from the
-- bottom bits
Top_Half_TTL :=
Interfaces.Unsigned_16
(Shift_Right (Interfaces.Unsigned_32 (Parsed_RR.TTL), 16));
Bottom_Half_TTL := Interfaces.Unsigned_16 (Parsed_RR.TTL and 16#ffff#);
-- 0..7 MSB is our RCode
Full_RCode := Top_Half_TTL and 16#ff00#;
Full_RCode := Shift_Right (Full_RCode, 4);
Full_RCode :=
Full_RCode or Interfaces.Unsigned_16 (DNS_Header.Response_Code);
This.Extended_RCode := RCodes'Enum_Val (Full_RCode);
-- Grab the EDNS version. It should be zero
This.EDNS_Version :=
Interfaces.C.Extensions.Unsigned_8 (Top_Half_TTL and 16#ff#);
-- Easiest way to fish out these bits is doing ANDs
This.DNSSEC_OK := (Bottom_Half_TTL and 16#8000#) /= 0;
This.Z_Section := Unsigned_15 (Bottom_Half_TTL and 16#7FF#);
-- Mask off top bits
end From_Parsed_RR;
function RData_To_String
(This : in Parsed_OPT_RData)
return String
is
begin
return "RCode: " & This.Extended_RCode'Image & " Version: " &
This.EDNS_Version'Image & " DO: " & This.DNSSEC_OK'Image & " Z: " &
This.Z_Section'Image;
end RData_To_String;
function Print_Packet
(This : in Parsed_OPT_RData)
return String
is
begin
return "OPT " & RData_To_String (This);
end Print_Packet;
-- Obliberate ourselves
procedure Delete (This : in out Parsed_OPT_RData) is
begin
null;
end Delete;
end DNSCatcher.DNS.Processor.RData.OPT_Parser;
|
justinjhendrick/learning-ada | Ada | 395 | ads | package Positions is
type Position is tagged private;
type Position_Type is access Position;
function Create(X : Integer; Y : Integer) return Position_Type;
function Get_X(this : Position_Type) return Integer;
function Get_Y(this : Position_Type) return Integer;
private
type Position is tagged
record
X : Integer;
Y : Integer;
end record;
end Positions;
|
HeisenbugLtd/msg_passing | Ada | 10,633 | adb | ------------------------------------------------------------------------
-- Copyright (C) 2010-2020 by Heisenbug Ltd. ([email protected])
--
-- This work is free. You can redistribute it and/or modify it under
-- the terms of the Do What The Fuck You Want To Public License,
-- Version 2, as published by Sam Hocevar. See the LICENSE file for
-- more details.
------------------------------------------------------------------------
pragma License (Unrestricted);
------------------------------------------------------------------------
-- Local_Message_Passing
--
-- Generic package providing mailbox communication channels.
--
-- All mailboxes instantiated from this package can be shared by name
-- between different tasks without needing the specific package where
-- the mailbox is located.
--
------------------------------------------------------------------------
with Ada.Real_Time;
with System.Address_To_Access_Conversions;
with System.Storage_Elements;
use type Ada.Real_Time.Time;
use type Ada.Real_Time.Time_Span;
use type System.Storage_Elements.Storage_Count;
package body Local_Message_Passing is
package SSE renames System.Storage_Elements;
-- Due to alignment rules, the size of the type and that of an
-- object of that type may be different, so use the size of a
-- (dummy) object instead of Message'Size for consistency checks.
-- TODO: Use 'Object_Size instead.
Dummy : Message;
MESSAGE_OBJECT_LENGTH : constant SSE.Storage_Count :=
(Dummy'Size + System.Storage_Unit - 1) / System.Storage_Unit;
---------------------------------------------------------------------
-- Conv
--
-- To convert between a Mailbox and its Handle we simply convert the
-- address into an access type.
--
-- This avoids 'Unchecked_Access at the danger of creating dangling
-- pointers if the scope of the mailbox is smaller than that of its
-- pointer to it.
---------------------------------------------------------------------
package Conv is
new System.Address_To_Access_Conversions (Object => Mailbox);
---------------------------------------------------------------------
-- Export_Mailbox
--
-- Exports a mailbox by name for use by other processes.
--
-- The name given to the mailbox is only significant up to the first
-- 31 characters, and shall be unique in those.
---------------------------------------------------------------------
procedure Export_Mailbox (Mbx : in out Mailbox;
Name : in String);
---------------------------------------------------------------------
-- Conditional_Receive
---------------------------------------------------------------------
procedure Conditional_Receive (Mbx : in Handle;
Msg : out Message;
Success : out Boolean) is
begin
Mbx.all.Try_Get (Msg, Success);
end Conditional_Receive;
---------------------------------------------------------------------
-- Conditional_Send
---------------------------------------------------------------------
procedure Conditional_Send (Mbx : in Handle;
Msg : in Message;
Success : out Boolean) is
begin
Mbx.all.Try_Put (Msg, Success);
end Conditional_Send;
---------------------------------------------------------------------
-- Export_Mailbox
---------------------------------------------------------------------
procedure Export_Mailbox (Mbx : in out Mailbox;
Name : in String) is
begin
Mailbox_Sharing.Add_Mailbox
(Mbx'Address, Name, MESSAGE_OBJECT_LENGTH);
end Export_Mailbox;
---------------------------------------------------------------------
-- Import_Mailbox
---------------------------------------------------------------------
procedure Import_Mailbox (Name : in String;
Hnd : out Handle;
Max_Wait : in Ada.Real_Time.Time_Span)
is
-- Convert the relative delay to an absolute one.
Latest : constant Ada.Real_Time.Time :=
Ada.Real_Time.Clock + Max_Wait;
begin
Hnd :=
Handle
(Conv.To_Pointer
(Mailbox_Sharing.Find_Mailbox
(Name, MESSAGE_OBJECT_LENGTH, Latest)));
end Import_Mailbox;
---------------------------------------------------------------------
-- Open_Mailbox
---------------------------------------------------------------------
procedure Open_Mailbox (Mbx : in out Mailbox;
Hnd : out Handle;
Export_Name : in String := "") is
begin
Mbx.Clear;
Hnd := Handle (Conv.To_Pointer (Mbx'Address));
if Export_Name /= "" then
Export_Mailbox (Mbx, Export_Name);
end if;
end Open_Mailbox;
---------------------------------------------------------------------
-- Receive
---------------------------------------------------------------------
procedure Receive (Mbx : in Handle;
Msg : out Message) is
begin
Mbx.all.Get (Msg);
end Receive;
---------------------------------------------------------------------
-- Send
---------------------------------------------------------------------
procedure Send (Mbx : in Handle;
Msg : in Message) is
begin
Mbx.all.Put (Msg);
end Send;
---------------------------------------------------------------------
-- Timed_Receive
---------------------------------------------------------------------
procedure Timed_Receive (Mbx : in Handle;
Msg : out Message;
Latest : in Ada.Real_Time.Time;
Success : out Boolean) is
begin
select
Mbx.all.Get (Msg);
Success := True;
or
delay until Latest;
Success := False;
end select;
end Timed_Receive;
---------------------------------------------------------------------
-- Timed_Receive
---------------------------------------------------------------------
procedure Timed_Receive (Mbx : in Handle;
Msg : out Message;
Max_Wait : in Ada.Real_Time.Time_Span;
Success : out Boolean)
is
begin
Timed_Receive (Mbx, Msg, Ada.Real_Time.Clock + Max_Wait, Success);
end Timed_Receive;
---------------------------------------------------------------------
-- Timed_Send
---------------------------------------------------------------------
procedure Timed_Send (Mbx : in Handle;
Msg : in Message;
Latest : in Ada.Real_Time.Time;
Success : out Boolean) is
begin
select
Mbx.all.Put (Msg);
Success := True;
or
delay until Latest;
Success := False;
end select;
end Timed_Send;
---------------------------------------------------------------------
-- Timed_Send
---------------------------------------------------------------------
procedure Timed_Send (Mbx : in Handle;
Msg : in Message;
Max_Wait : in Ada.Real_Time.Time_Span;
Success : out Boolean)
is
begin
Timed_Send (Mbx, Msg, Ada.Real_Time.Clock + Max_Wait, Success);
end Timed_Send;
---------------------------------------------------------------------
-- Mailbox
---------------------------------------------------------------------
protected body Mailbox is
------------------------------------------------------------------
-- Mailbox.Clear
------------------------------------------------------------------
procedure Clear is
begin
-- Reset number of messages and indices.
Num_Messages := 0;
Oldest := Msg_Queue'First;
Latest := Msg_Queue'First;
end Clear;
------------------------------------------------------------------
-- Mailbox.Get
------------------------------------------------------------------
entry Get (Msg : out Message) when Num_Messages > 0 is
begin
-- Get oldest message from queue and advance index.
Msg := Msg_Queue (Oldest);
Oldest := (Oldest mod Size) + 1;
-- Message has been retrieved now.
Num_Messages := Num_Messages - 1;
end Get;
------------------------------------------------------------------
-- Mailbox.Put
------------------------------------------------------------------
entry Put (Msg : in Message) when Num_Messages < Size is
begin
-- Put message into latest slot and advance index.
Msg_Queue (Latest) := Msg;
Latest := (Latest mod Size) + 1;
-- One more message deposited.
Num_Messages := Num_Messages + 1;
end Put;
------------------------------------------------------------------
-- Mailbox.Try_Get
------------------------------------------------------------------
procedure Try_Get (Msg : out Message;
Success : out Boolean)
is
begin
Success := Num_Messages > 0;
if Success then
-- Get message from oldest slot and advance index.
Msg := Msg_Queue (Oldest);
Oldest := (Oldest mod Size) + 1;
-- One message retrieved.
Num_Messages := Num_Messages - 1;
end if;
end Try_Get;
------------------------------------------------------------------
-- Mailbox.Try_Put
------------------------------------------------------------------
procedure Try_Put (Msg : in Message;
Success : out Boolean)
is
begin
Success := Num_Messages < Size;
if Success then
-- Put message into latest slot and advance index.
Msg_Queue (Latest) := Msg;
Latest := (Latest mod Size) + 1;
-- One more message deposited.
Num_Messages := Num_Messages + 1;
end if;
end Try_Put;
end Mailbox;
end Local_Message_Passing;
|
charlie5/lace | Ada | 1,069 | ads | package openGL.Impostor.simple
--
-- Can impostor any 'visual'.
--
is
type Item is new Impostor.item with private;
type View is access all Item'Class;
overriding
function current_Camera_look_at_Rotation (Self : in Item) return Matrix_3x3;
overriding
function update_Required (Self : access Item; the_Camera : access Camera.item'Class) return Boolean;
overriding
procedure pre_update (Self : in out Item; the_Camera : access Camera.item'Class);
overriding
procedure update (Self : in out Item; the_Camera : access Camera.item'Class;
texture_Pool : in Texture.Pool_view);
overriding
procedure post_update (Self : in out Item; the_Camera : access Camera.item'Class);
procedure free (Self : in out View);
private
type Item is new Impostor.item with
record
current_Camera_look_at_Rotation : Matrix_3x3;
camera_world_Rotation_original : Matrix_3x3;
end record;
end openGL.Impostor.simple;
|
reznikmm/matreshka | Ada | 3,673 | ads | ------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- Open Document Toolkit --
-- --
-- Runtime Library Component --
-- --
------------------------------------------------------------------------------
-- --
-- Copyright © 2013, Vadim Godunko <[email protected]> --
-- All rights reserved. --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions --
-- are met: --
-- --
-- * Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- --
-- * Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in the --
-- documentation and/or other materials provided with the distribution. --
-- --
-- * Neither the name of the Vadim Godunko, IE nor the names of its --
-- contributors may be used to endorse or promote products derived from --
-- this software without specific prior written permission. --
-- --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR --
-- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
-- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED --
-- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR --
-- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF --
-- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING --
-- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS --
-- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
-- --
------------------------------------------------------------------------------
-- $Revision$ $Date$
------------------------------------------------------------------------------
with XML.DOM.Elements;
package ODF.DOM.Elements.Style.Table_Row_Properties is
type ODF_Style_Table_Row_Properties is
new XML.DOM.Elements.DOM_Element with private;
private
type ODF_Style_Table_Row_Properties is
new XML.DOM.Elements.DOM_Element with null record;
end ODF.DOM.Elements.Style.Table_Row_Properties;
|
Fabien-Chouteau/GESTE-examples | Ada | 645 | ads | with GESTE;
with Interfaces; use Interfaces;
generic
Width : Natural;
Height : Natural;
Pixel_Scale : Natural;
Buffer_Size : Positive;
package SDL_Display is
Screen_Rect : constant GESTE.Pix_Rect := ((0, 0), (Width - 1, Height - 1));
Buffer : GESTE.Output_Buffer (1 .. Buffer_Size);
procedure Push_Pixels (Pixels : GESTE.Output_Buffer);
procedure Set_Drawing_Area (Area : GESTE.Pix_Rect);
procedure Set_Screen_Offset (Pt : GESTE.Pix_Point);
procedure Update;
subtype SDL_Pixel is Unsigned_16;
function To_SDL_Color (R, G, B : Unsigned_8) return SDL_Pixel;
procedure Kill;
end SDL_Display;
|
Tim-Tom/project-euler | Ada | 3,659 | adb | with Ada.Text_IO;
with Ada.Containers.Ordered_Sets;
with Ada.Containers.Doubly_Linked_Lists;
package body Problem_44 is
package IO renames Ada.Text_IO;
package Positive_Set is new Ada.Containers.Ordered_Sets(Element_Type => Positive);
package Positive_List is new Ada.Containers.Doubly_Linked_Lists(Element_Type => Positive);
procedure Solve is
pentagonal_numbers : Positive_Set.Set := Positive_Set.Empty_Set;
compares : Positive_List.List := Positive_List.Empty_List;
largest_generated : Positive := 1;
largest_generated_index : Positive := 1;
maximum_bound : Positive := Positive'Last;
function Is_Pentagonal(number : Positive) return Boolean is
begin
while number > largest_generated loop
largest_generated_index := Positive'Succ(largest_generated_index);
largest_generated := largest_generated_index * (3*largest_generated_index - 1) / 2;
-- IO.Put_Line("Generated " & Positive'Image(largest_generated));
pentagonal_numbers.Insert(largest_generated);
end loop;
return pentagonal_numbers.Contains(number);
end Is_Pentagonal;
procedure Trim_Comparison_List(minimum_bound : Positive) is
cursor : Positive_List.Cursor := compares.First;
function "=" (left,right : Positive_List.Cursor) return Boolean renames Positive_List."=";
begin
while cursor /= Positive_List.No_Element loop
exit when Positive_List.Element(cursor) >= minimum_bound;
compares.Delete(cursor);
end loop;
end Trim_Comparison_List;
pentagonal : Positive := 1;
index : Positive := 1;
begin
pentagonal_numbers.Insert(1);
main_loop:
loop
declare
difference : constant Positive := 3*index + 1;
minimum_bound : Positive renames difference;
begin
exit when minimum_bound > maximum_bound;
Trim_Comparison_List(minimum_bound);
pentagonal := pentagonal + difference;
index := index + 1;
-- IO.Put_Line(Positive'Image(pentagonal));
declare
cursor : Positive_List.Cursor := compares.Last;
function "=" (left,right : Positive_List.Cursor) return Boolean renames Positive_List."=";
begin
check_loop:
while cursor /= Positive_List.No_Element loop
declare
previous_pent : constant Positive := Positive_List.Element(cursor);
begin
if Is_Pentagonal(pentagonal + previous_pent) and then Is_Pentagonal(pentagonal - previous_pent) then
if maximum_bound > pentagonal - previous_pent then
maximum_bound := pentagonal - previous_pent;
-- As far as my analysis goes, this should just be exit check_loop
-- (which is why it's called the maximum bound), but the bound ends
-- up being huge, so we don't really terminate with any celerity.
-- It would require generating over 1 million of these numbers to
-- satisfy that bound.
exit main_loop;
end if;
end if;
Positive_List.Previous(cursor);
end;
end loop check_loop;
end;
compares.Append(pentagonal);
end;
end loop main_loop;
IO.Put_Line(Positive'Image(maximum_bound));
end Solve;
end Problem_44;
|
strenkml/EE368 | Ada | 142 | ads |
with Memory; use Memory;
-- A function to simplify memory subsystems.
function Simplify_Memory(mem : Memory_Pointer) return Memory_Pointer;
|
dshadrin/AProxy | Ada | 1,771 | ads | ------------------------------------------------------------------------------
-- --
-- File: --
-- formatted_output-integer_output.ads --
-- --
-- Description: --
-- Formatted_Output.Integer_Output generic package specification, --
-- contains prototypes of functions that supports formatted output of --
-- integer types --
-- --
-- Author: --
-- Eugene Nonko, [email protected] --
-- --
-- Revision history: --
-- 27/01/99 - original --
-- --
------------------------------------------------------------------------------
generic
type Item_Type is range <>;
package Formatted_Output.Integer_Output is
function "&" (Fmt : Format_Type; Value : Item_Type) return Format_Type;
-- Replaces leftmost formatting sequence in Fmt with formatted
-- Value image, then returns Fmt. Raises exception Format_Error
-- when invalid formatting sequence is found or no formatting
-- sequence found at all
end Formatted_Output.Integer_Output;
|
reznikmm/matreshka | Ada | 3,734 | ads | ------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- Open Document Toolkit --
-- --
-- Runtime Library Component --
-- --
------------------------------------------------------------------------------
-- --
-- Copyright © 2014, Vadim Godunko <[email protected]> --
-- All rights reserved. --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions --
-- are met: --
-- --
-- * Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- --
-- * Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in the --
-- documentation and/or other materials provided with the distribution. --
-- --
-- * Neither the name of the Vadim Godunko, IE nor the names of its --
-- contributors may be used to endorse or promote products derived from --
-- this software without specific prior written permission. --
-- --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR --
-- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
-- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED --
-- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR --
-- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF --
-- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING --
-- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS --
-- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
-- --
------------------------------------------------------------------------------
-- $Revision$ $Date$
------------------------------------------------------------------------------
with XML.DOM.Attributes;
package ODF.DOM.Office_String_Value_Attributes is
pragma Preelaborate;
type ODF_Office_String_Value_Attribute is limited interface
and XML.DOM.Attributes.DOM_Attribute;
type ODF_Office_String_Value_Attribute_Access is
access all ODF_Office_String_Value_Attribute'Class
with Storage_Size => 0;
end ODF.DOM.Office_String_Value_Attributes;
|
AenBleidd/rappture-runtime | Ada | 19,378 | adb | ----------------------------------------------------------------
-- ZLib for Ada thick binding. --
-- --
-- Copyright (C) 2002-2003 Dmitriy Anisimkov --
-- --
-- Open source license information is in the zlib.ads file. --
----------------------------------------------------------------
-- $Id: zlib.adb,v 1.1 2004/08/12 20:24:12 andreas_kupries Exp $
with Ada.Exceptions;
with Ada.Unchecked_Conversion;
with Ada.Unchecked_Deallocation;
with Interfaces.C.Strings;
with ZLib.Thin;
package body ZLib is
use type Thin.Int;
type Z_Stream is new Thin.Z_Stream;
type Return_Code_Enum is
(OK,
STREAM_END,
NEED_DICT,
ERRNO,
STREAM_ERROR,
DATA_ERROR,
MEM_ERROR,
BUF_ERROR,
VERSION_ERROR);
type Flate_Step_Function is access
function (Strm : Thin.Z_Streamp; flush : Thin.Int) return Thin.Int;
pragma Convention (C, Flate_Step_Function);
type Flate_End_Function is access
function (Ctrm : in Thin.Z_Streamp) return Thin.Int;
pragma Convention (C, Flate_End_Function);
type Flate_Type is record
Step : Flate_Step_Function;
Done : Flate_End_Function;
end record;
subtype Footer_Array is Stream_Element_Array (1 .. 8);
Simple_GZip_Header : constant Stream_Element_Array (1 .. 10)
:= (16#1f#, 16#8b#, -- Magic header
16#08#, -- Z_DEFLATED
16#00#, -- Flags
16#00#, 16#00#, 16#00#, 16#00#, -- Time
16#00#, -- XFlags
16#03# -- OS code
);
-- The simplest gzip header is not for informational, but just for
-- gzip format compatibility.
-- Note that some code below is using assumption
-- Simple_GZip_Header'Last > Footer_Array'Last, so do not make
-- Simple_GZip_Header'Last <= Footer_Array'Last.
Return_Code : constant array (Thin.Int range <>) of Return_Code_Enum
:= (0 => OK,
1 => STREAM_END,
2 => NEED_DICT,
-1 => ERRNO,
-2 => STREAM_ERROR,
-3 => DATA_ERROR,
-4 => MEM_ERROR,
-5 => BUF_ERROR,
-6 => VERSION_ERROR);
Flate : constant array (Boolean) of Flate_Type
:= (True => (Step => Thin.Deflate'Access,
Done => Thin.DeflateEnd'Access),
False => (Step => Thin.Inflate'Access,
Done => Thin.InflateEnd'Access));
Flush_Finish : constant array (Boolean) of Flush_Mode
:= (True => Finish, False => No_Flush);
procedure Raise_Error (Stream : Z_Stream);
pragma Inline (Raise_Error);
procedure Raise_Error (Message : String);
pragma Inline (Raise_Error);
procedure Check_Error (Stream : Z_Stream; Code : Thin.Int);
procedure Free is new Ada.Unchecked_Deallocation
(Z_Stream, Z_Stream_Access);
function To_Thin_Access is new Ada.Unchecked_Conversion
(Z_Stream_Access, Thin.Z_Streamp);
procedure Translate_GZip
(Filter : in out Filter_Type;
In_Data : in Ada.Streams.Stream_Element_Array;
In_Last : out Ada.Streams.Stream_Element_Offset;
Out_Data : out Ada.Streams.Stream_Element_Array;
Out_Last : out Ada.Streams.Stream_Element_Offset;
Flush : in Flush_Mode);
-- Separate translate routine for make gzip header.
procedure Translate_Auto
(Filter : in out Filter_Type;
In_Data : in Ada.Streams.Stream_Element_Array;
In_Last : out Ada.Streams.Stream_Element_Offset;
Out_Data : out Ada.Streams.Stream_Element_Array;
Out_Last : out Ada.Streams.Stream_Element_Offset;
Flush : in Flush_Mode);
-- translate routine without additional headers.
-----------------
-- Check_Error --
-----------------
procedure Check_Error (Stream : Z_Stream; Code : Thin.Int) is
use type Thin.Int;
begin
if Code /= Thin.Z_OK then
Raise_Error
(Return_Code_Enum'Image (Return_Code (Code))
& ": " & Last_Error_Message (Stream));
end if;
end Check_Error;
-----------
-- Close --
-----------
procedure Close
(Filter : in out Filter_Type;
Ignore_Error : in Boolean := False)
is
Code : Thin.Int;
begin
Code := Flate (Filter.Compression).Done
(To_Thin_Access (Filter.Strm));
Filter.Opened := False;
if Ignore_Error or else Code = Thin.Z_OK then
Free (Filter.Strm);
else
declare
Error_Message : constant String
:= Last_Error_Message (Filter.Strm.all);
begin
Free (Filter.Strm);
Ada.Exceptions.Raise_Exception
(ZLib_Error'Identity,
Return_Code_Enum'Image (Return_Code (Code))
& ": " & Error_Message);
end;
end if;
end Close;
-----------
-- CRC32 --
-----------
function CRC32
(CRC : in Unsigned_32;
Data : in Ada.Streams.Stream_Element_Array)
return Unsigned_32
is
use Thin;
begin
return Unsigned_32 (crc32
(ULong (CRC),
Bytes.To_Pointer (Data'Address),
Data'Length));
end CRC32;
procedure CRC32
(CRC : in out Unsigned_32;
Data : in Ada.Streams.Stream_Element_Array) is
begin
CRC := CRC32 (CRC, Data);
end CRC32;
------------------
-- Deflate_Init --
------------------
procedure Deflate_Init
(Filter : in out Filter_Type;
Level : in Compression_Level := Default_Compression;
Strategy : in Strategy_Type := Default_Strategy;
Method : in Compression_Method := Deflated;
Window_Bits : in Window_Bits_Type := 15;
Memory_Level : in Memory_Level_Type := 8;
Header : in Header_Type := Default)
is
use type Thin.Int;
Win_Bits : Thin.Int := Thin.Int (Window_Bits);
begin
-- We allow ZLib to make header only in case of default header type.
-- Otherwise we would either do header by ourselfs, or do not do
-- header at all.
if Header = None or else Header = GZip then
Win_Bits := -Win_Bits;
end if;
-- For the GZip CRC calculation and make headers.
if Header = GZip then
Filter.CRC := 0;
Filter.Offset := Simple_GZip_Header'First;
else
Filter.Offset := Simple_GZip_Header'Last + 1;
end if;
Filter.Strm := new Z_Stream;
Filter.Compression := True;
Filter.Stream_End := False;
Filter.Opened := True;
Filter.Header := Header;
if Thin.Deflate_Init
(To_Thin_Access (Filter.Strm),
Level => Thin.Int (Level),
method => Thin.Int (Method),
windowBits => Win_Bits,
memLevel => Thin.Int (Memory_Level),
strategy => Thin.Int (Strategy)) /= Thin.Z_OK
then
Raise_Error (Filter.Strm.all);
end if;
end Deflate_Init;
-----------
-- Flush --
-----------
procedure Flush
(Filter : in out Filter_Type;
Out_Data : out Ada.Streams.Stream_Element_Array;
Out_Last : out Ada.Streams.Stream_Element_Offset;
Flush : in Flush_Mode)
is
No_Data : Stream_Element_Array := (1 .. 0 => 0);
Last : Stream_Element_Offset;
begin
Translate (Filter, No_Data, Last, Out_Data, Out_Last, Flush);
end Flush;
-----------------------
-- Generic_Translate --
-----------------------
procedure Generic_Translate
(Filter : in out ZLib.Filter_Type;
In_Buffer_Size : Integer := Default_Buffer_Size;
Out_Buffer_Size : Integer := Default_Buffer_Size)
is
In_Buffer : Stream_Element_Array
(1 .. Stream_Element_Offset (In_Buffer_Size));
Out_Buffer : Stream_Element_Array
(1 .. Stream_Element_Offset (Out_Buffer_Size));
Last : Stream_Element_Offset;
In_Last : Stream_Element_Offset;
In_First : Stream_Element_Offset;
Out_Last : Stream_Element_Offset;
begin
Main : loop
Data_In (In_Buffer, Last);
In_First := In_Buffer'First;
loop
Translate
(Filter,
In_Buffer (In_First .. Last),
In_Last,
Out_Buffer,
Out_Last,
Flush_Finish (Last < In_Buffer'First));
Data_Out (Out_Buffer (Out_Buffer'First .. Out_Last));
exit Main when Stream_End (Filter);
-- The end of in buffer.
exit when In_Last = Last;
In_First := In_Last + 1;
end loop;
end loop Main;
end Generic_Translate;
------------------
-- Inflate_Init --
------------------
procedure Inflate_Init
(Filter : in out Filter_Type;
Window_Bits : in Window_Bits_Type := 15;
Header : in Header_Type := Default)
is
use type Thin.Int;
Win_Bits : Thin.Int := Thin.Int (Window_Bits);
procedure Check_Version;
-- Check the latest header types compatibility.
procedure Check_Version is
begin
if Version <= "1.1.4" then
Raise_Error
("Inflate header type " & Header_Type'Image (Header)
& " incompatible with ZLib version " & Version);
end if;
end Check_Version;
begin
case Header is
when None =>
Check_Version;
-- Inflate data without headers determined
-- by negative Win_Bits.
Win_Bits := -Win_Bits;
when GZip =>
Check_Version;
-- Inflate gzip data defined by flag 16.
Win_Bits := Win_Bits + 16;
when Auto =>
Check_Version;
-- Inflate with automatic detection
-- of gzip or native header defined by flag 32.
Win_Bits := Win_Bits + 32;
when Default => null;
end case;
Filter.Strm := new Z_Stream;
Filter.Compression := False;
Filter.Stream_End := False;
Filter.Opened := True;
Filter.Header := Header;
if Thin.Inflate_Init
(To_Thin_Access (Filter.Strm), Win_Bits) /= Thin.Z_OK
then
Raise_Error (Filter.Strm.all);
end if;
end Inflate_Init;
-----------------
-- Raise_Error --
-----------------
procedure Raise_Error (Message : String) is
begin
Ada.Exceptions.Raise_Exception (ZLib_Error'Identity, Message);
end Raise_Error;
procedure Raise_Error (Stream : Z_Stream) is
begin
Raise_Error (Last_Error_Message (Stream));
end Raise_Error;
----------
-- Read --
----------
procedure Read
(Filter : in out Filter_Type;
Item : out Ada.Streams.Stream_Element_Array;
Last : out Ada.Streams.Stream_Element_Offset)
is
In_Last : Stream_Element_Offset;
Item_First : Ada.Streams.Stream_Element_Offset := Item'First;
begin
pragma Assert (Rest_First in Buffer'First .. Buffer'Last + 1);
loop
if Rest_First > Buffer'Last then
Read (Buffer, Rest_Last);
Rest_First := Buffer'First;
end if;
pragma Assert (Rest_Last in Buffer'First - 1 .. Buffer'Last);
Translate
(Filter => Filter,
In_Data => Buffer (Rest_First .. Rest_Last),
In_Last => In_Last,
Out_Data => Item (Item_First .. Item'Last),
Out_Last => Last,
Flush => Flush_Finish (Rest_Last < Rest_First));
Rest_First := In_Last + 1;
exit when Last = Item'Last or else Stream_End (Filter);
Item_First := Last + 1;
end loop;
end Read;
----------------
-- Stream_End --
----------------
function Stream_End (Filter : in Filter_Type) return Boolean is
begin
if Filter.Header = GZip and Filter.Compression then
return Filter.Stream_End
and then Filter.Offset = Footer_Array'Last + 1;
else
return Filter.Stream_End;
end if;
end Stream_End;
--------------
-- Total_In --
--------------
function Total_In (Filter : in Filter_Type) return Count is
begin
return Count (Thin.Total_In (To_Thin_Access (Filter.Strm).all));
end Total_In;
---------------
-- Total_Out --
---------------
function Total_Out (Filter : in Filter_Type) return Count is
begin
return Count (Thin.Total_Out (To_Thin_Access (Filter.Strm).all));
end Total_Out;
---------------
-- Translate --
---------------
procedure Translate
(Filter : in out Filter_Type;
In_Data : in Ada.Streams.Stream_Element_Array;
In_Last : out Ada.Streams.Stream_Element_Offset;
Out_Data : out Ada.Streams.Stream_Element_Array;
Out_Last : out Ada.Streams.Stream_Element_Offset;
Flush : in Flush_Mode) is
begin
if Filter.Header = GZip and then Filter.Compression then
Translate_GZip
(Filter => Filter,
In_Data => In_Data,
In_Last => In_Last,
Out_Data => Out_Data,
Out_Last => Out_Last,
Flush => Flush);
else
Translate_Auto
(Filter => Filter,
In_Data => In_Data,
In_Last => In_Last,
Out_Data => Out_Data,
Out_Last => Out_Last,
Flush => Flush);
end if;
end Translate;
--------------------
-- Translate_Auto --
--------------------
procedure Translate_Auto
(Filter : in out Filter_Type;
In_Data : in Ada.Streams.Stream_Element_Array;
In_Last : out Ada.Streams.Stream_Element_Offset;
Out_Data : out Ada.Streams.Stream_Element_Array;
Out_Last : out Ada.Streams.Stream_Element_Offset;
Flush : in Flush_Mode)
is
use type Thin.Int;
Code : Thin.Int;
begin
if Filter.Opened = False then
raise ZLib_Error;
end if;
if Out_Data'Length = 0 then
raise Constraint_Error;
end if;
Set_Out (Filter.Strm.all, Out_Data'Address, Out_Data'Length);
Set_In (Filter.Strm.all, In_Data'Address, In_Data'Length);
Code := Flate (Filter.Compression).Step
(To_Thin_Access (Filter.Strm),
Thin.Int (Flush));
if Code = Thin.Z_STREAM_END then
Filter.Stream_End := True;
else
Check_Error (Filter.Strm.all, Code);
end if;
In_Last := In_Data'Last
- Stream_Element_Offset (Avail_In (Filter.Strm.all));
Out_Last := Out_Data'Last
- Stream_Element_Offset (Avail_Out (Filter.Strm.all));
end Translate_Auto;
--------------------
-- Translate_GZip --
--------------------
procedure Translate_GZip
(Filter : in out Filter_Type;
In_Data : in Ada.Streams.Stream_Element_Array;
In_Last : out Ada.Streams.Stream_Element_Offset;
Out_Data : out Ada.Streams.Stream_Element_Array;
Out_Last : out Ada.Streams.Stream_Element_Offset;
Flush : in Flush_Mode)
is
Out_First : Stream_Element_Offset;
procedure Add_Data (Data : in Stream_Element_Array);
-- Add data to stream from the Filter.Offset till necessary,
-- used for add gzip headr/footer.
procedure Put_32
(Item : in out Stream_Element_Array;
Data : in Unsigned_32);
pragma Inline (Put_32);
--------------
-- Add_Data --
--------------
procedure Add_Data (Data : in Stream_Element_Array) is
Data_First : Stream_Element_Offset renames Filter.Offset;
Data_Last : Stream_Element_Offset;
Data_Len : Stream_Element_Offset; -- -1
Out_Len : Stream_Element_Offset; -- -1
begin
Out_First := Out_Last + 1;
if Data_First > Data'Last then
return;
end if;
Data_Len := Data'Last - Data_First;
Out_Len := Out_Data'Last - Out_First;
if Data_Len <= Out_Len then
Out_Last := Out_First + Data_Len;
Data_Last := Data'Last;
else
Out_Last := Out_Data'Last;
Data_Last := Data_First + Out_Len;
end if;
Out_Data (Out_First .. Out_Last) := Data (Data_First .. Data_Last);
Data_First := Data_Last + 1;
Out_First := Out_Last + 1;
end Add_Data;
------------
-- Put_32 --
------------
procedure Put_32
(Item : in out Stream_Element_Array;
Data : in Unsigned_32)
is
D : Unsigned_32 := Data;
begin
for J in Item'First .. Item'First + 3 loop
Item (J) := Stream_Element (D and 16#FF#);
D := Shift_Right (D, 8);
end loop;
end Put_32;
begin
Out_Last := Out_Data'First - 1;
if not Filter.Stream_End then
Add_Data (Simple_GZip_Header);
Translate_Auto
(Filter => Filter,
In_Data => In_Data,
In_Last => In_Last,
Out_Data => Out_Data (Out_First .. Out_Data'Last),
Out_Last => Out_Last,
Flush => Flush);
CRC32 (Filter.CRC, In_Data (In_Data'First .. In_Last));
end if;
if Filter.Stream_End and then Out_Last <= Out_Data'Last then
-- This detection method would work only when
-- Simple_GZip_Header'Last > Footer_Array'Last
if Filter.Offset = Simple_GZip_Header'Last + 1 then
Filter.Offset := Footer_Array'First;
end if;
declare
Footer : Footer_Array;
begin
Put_32 (Footer, Filter.CRC);
Put_32 (Footer (Footer'First + 4 .. Footer'Last),
Unsigned_32 (Total_In (Filter)));
Add_Data (Footer);
end;
end if;
end Translate_GZip;
-------------
-- Version --
-------------
function Version return String is
begin
return Interfaces.C.Strings.Value (Thin.zlibVersion);
end Version;
-----------
-- Write --
-----------
procedure Write
(Filter : in out Filter_Type;
Item : in Ada.Streams.Stream_Element_Array;
Flush : in Flush_Mode)
is
Buffer : Stream_Element_Array (1 .. Buffer_Size);
In_Last, Out_Last : Stream_Element_Offset;
In_First : Stream_Element_Offset := Item'First;
begin
if Item'Length = 0 and Flush = No_Flush then
return;
end if;
loop
Translate
(Filter => Filter,
In_Data => Item (In_First .. Item'Last),
In_Last => In_Last,
Out_Data => Buffer,
Out_Last => Out_Last,
Flush => Flush);
if Out_Last >= Buffer'First then
Write (Buffer (1 .. Out_Last));
end if;
exit when In_Last = Item'Last or Stream_End (Filter);
In_First := In_Last + 1;
end loop;
end Write;
end ZLib;
|
smola/language-dataset | Ada | 25,948 | ads |
-- --
-- N E O E N G I N E --
-- --
-- Copyright (C) 2016 Justin Squirek --
-- --
-- Neo 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. --
-- --
-- Neo 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 Neo. If not, see gnu.org/licenses --
-- --
with Ada.Numerics.Generic_Elementary_Functions;
with Neo.Core.Vectors;
-- Based on Foundations of Game Engine Development Vol. 1: http://foundationsofgameenginedev.com/FGED1-code.cpp
package Neo.Core.Math is
type Dimension_Kind is (X_Dimension, Y_Dimension, Z_Dimension);
package Calc_64 is new Ada.Numerics.Generic_Elementary_Functions (Real_64); use Calc_64;
package Calc_32 is new Ada.Numerics.Generic_Elementary_Functions (Real_32); use Calc_32;
-----------
-- Point --
-----------
-- Definitions
type Point_2D is record X, Y : Real_32 := 0.0; end record;
type Point_3D is record X, Y, Z : Real_32 := 0.0; end record; -- Listing 2.8
type Point_4D is record X, Y, Z, W : Real_32 := 0.0; end record;
package Vector_Point_2D is new Neo.Core.Vectors (Point_2D);
package Vector_Point_3D is new Neo.Core.Vectors (Point_3D);
package Vector_Point_4D is new Neo.Core.Vectors (Point_4D);
ZERO_POINT_2D : constant Point_2D := (others => 0.0);
ZERO_POINT_3D : constant Point_3D := (others => 0.0);
ZERO_POINT_4D : constant Point_4D := (others => 0.0);
-- 3D Operations
function "+" (A, B : Point_3D) return Point_3D is ((A.X + B.X, A.Y + B.Y, A.Z + B.Z));
function "-" (A, B : Point_3D) return Point_3D is ((A.X - B.X, A.Y - B.Y, A.Z - B.Z));
------------
-- Vector --
------------
-- Definitions
type Vector_2D is record X, Y : Real_32 := 0.0; end record; -- Listing 1.1
type Vector_3D is record X, Y, Z : Real_32 := 0.0; end record; -- Listing 1.1
type Vector_4D is record X, Y, Z, W : Real_32 := 0.0; end record;
package Vector_Vector_2D is new Neo.Core.Vectors (Vector_2D);
package Vector_Vector_3D is new Neo.Core.Vectors (Vector_3D);
package Vector_Vector_4D is new Neo.Core.Vectors (Vector_4D);
ZERO_VECTOR_2D : constant Vector_2D := (others => 0.0);
ZERO_VECTOR_3D : constant Vector_3D := (others => 0.0);
ZERO_VECTOR_4D : constant Vector_4D := (others => 0.0);
-- Conversions
function To_Vector_3D (P : Point_3D) return Vector_3D is ((P.X, P.Y, P.Z));
function To_Vector_3D (V : Vector_4D) return Vector_3D is ((V.X, V.Y, V.Z));
function To_Vector_4D (V : Vector_3D; W : Real_32) return Vector_4D is ((V.X, V.Y, V.Z, W));
-- 3D Operations
function "*" (V : Vector_3D; S : Real_32) return Vector_3D is ((V.X * S, V.Y * S, V.Z * S)); -- Listing 1.2
function "/" (V : Vector_3D; S : Real_32) return Vector_3D is (V * (1.0 / S)); -- Listing 1.2
function "-" (V : Vector_3D) return Vector_3D is ((-V.X, -V.Y, -V.Z)); -- Listing 1.2
function "+" (A, B : Vector_3D) return Vector_3D is ((A.X + B.X, A.Y + B.Y, A.Z + B.Z)); -- Listing 1.3
function "-" (A, B : Vector_3D) return Vector_3D is ((A.X - B.X, A.Y - B.Y, A.Z - B.Z)); -- Listing 1.3
function Magnitude (V : Vector_3D) return Real_32 is (Sqrt (V.X ** 2 + V.Y ** 2 + V.Z ** 2)); -- Listing 1.2
function Normal (V : Vector_3D) return Vector_3D is (V / Magnitude (V)); -- Listing 1.2
function Dot (A, B : Vector_3D) return Real_32 is (A.X * B.X + A.Y * B.Y + A.Z * B.Z); -- Listing 1.6
function Project (A, B : Vector_3D) return Vector_3D is (B * (Dot (A, B) / Dot (B, B))); -- Listing 1.8
function Reject (A, B : Vector_3D) return Vector_3D is (A - Project (A, B)); -- Listing 1.8
function Cross (A, B : Vector_3D) return Vector_3D is ((A.Y * B.Z - A.Z * B.Y, -- Listing 1.7
A.Z * B.X - A.X * B.Z,
A.X * B.Y - A.Y * B.X));
-- 4D Operations
function "*" (V : Vector_4D; S : Real_32) return Vector_4D is ((V.X * S, V.Y * S, V.Z * S, V.W * S));
function "/" (V : Vector_4D; S : Real_32) return Vector_4D is (V * (1.0 / S));
function "-" (V : Vector_4D) return Vector_4D is ((-V.X, -V.Y, -V.Z, -V.W));
function "+" (A, B : Vector_4D) return Vector_4D is ((A.X + B.X, A.Y + B.Y, A.Z + B.Z, A.W + B.W));
function "-" (A, B : Vector_4D) return Vector_4D is ((A.X - B.X, A.Y - B.Y, A.Z - B.Z, A.W - B.W));
function Magnitude (V : Vector_4D) return Real_32 is (Sqrt (V.X ** 2 + V.Y ** 2 + V.Z ** 2 + V.W ** 2));
function Normal (V : Vector_4D) return Vector_4D is (V / Magnitude (V));
function Dot (A, B : Vector_4D) return Real_32 is (A.X * B.X + A.Y * B.Y + A.Z * B.Z + A.W * B.W);
function Project (A, B : Vector_4D) return Vector_4D is (B * (Dot (A, B) / Dot (B, B)));
function Reject (A, B : Vector_4D) return Vector_4D is (A - Project (A, B));
------------
-- Matrix --
------------
-- Definitions
type Matrix_2D is record
XX, YX,
XY, YY : Real_32 := 0.0;
end record;
type Matrix_3D is record -- Listing 1.3
XX, YX, ZX,
XY, YY, ZY,
XZ, YZ, ZZ : Real_32 := 0.0;
end record;
type Matrix_4D is record
XX, YX, ZX, WX,
XY, YY, ZY, WY,
XZ, YZ, ZZ, WZ,
XW, YW, ZW, WW : Real_32 := 0.0;
end record;
package Vector_Matrix_2D is new Neo.Core.Vectors (Matrix_2D);
package Vector_Matrix_3D is new Neo.Core.Vectors (Matrix_3D);
package Vector_Matrix_4D is new Neo.Core.Vectors (Matrix_4D);
ZERO_MATRIX_2D : constant Matrix_2D := (others => 0.0);
ZERO_MATRIX_3D : constant Matrix_3D := (others => 0.0);
ZERO_MATRIX_4D : constant Matrix_4D := (others => 0.0);
-- 3D Conversions
procedure Set_Matrix_3D_X (M : in out Matrix_3D; V : Vector_3D);
procedure Set_Matrix_3D_Y (M : in out Matrix_3D; V : Vector_3D);
procedure Set_Matrix_3D_Z (M : in out Matrix_3D; V : Vector_3D);
function Get_Matrix_3D_X (M : Matrix_3D) return Vector_3D is ((M.XX, M.XY, M.XZ));
function Get_Matrix_3D_Y (M : Matrix_3D) return Vector_3D is ((M.YX, M.YY, M.YZ));
function Get_Matrix_3D_Z (M : Matrix_3D) return Vector_3D is ((M.ZX, M.ZY, M.ZZ));
function To_Matrix_3D (A, B, C : Vector_3D) return Matrix_3D is ((A.X, B.X, C.X,
A.Y, B.Y, C.Y,
A.Z, B.Z, C.Z));
-- 3D Operations
function Inverse (M : Matrix_3D) return Matrix_3D; -- Listing 1.10
function Determinant (M : Matrix_3D) return Real_32 is (M.XX * (M.YY * M.ZZ - M.ZY * M.YZ) + -- Listing 1.9
M.YX * (M.ZY * M.XZ - M.XY * M.ZZ) +
M.ZX * (M.XY * M.YZ - M.YY * M.XZ));
function "*" (M : Matrix_3D; V : Vector_3D) return Vector_3D is ((M.XX * V.X + M.YX * V.Y + M.ZX * V.Z, -- Listing 1.5
M.XY * V.X + M.YY * V.Y + M.ZY * V.Z,
M.XZ * V.X + M.YZ * V.Y + M.ZZ * V.Z));
function "*" (A, B : Matrix_3D) return Matrix_3D is ((A.XX * B.XX + A.YX * B.XY + A.ZX * B.XZ, -- Listing 1.5
A.XX * B.YX + A.YX * B.YY + A.ZX * B.YZ,
A.XX * B.ZX + A.YX * B.ZY + A.ZX * B.ZZ,
A.XY * B.XX + A.YY * B.XY + A.ZY * B.XZ,
A.XY * B.YX + A.YY * B.YY + A.ZY * B.YZ,
A.XY * B.ZX + A.YY * B.ZY + A.ZY * B.ZZ,
A.XZ * B.XX + A.YZ * B.XY + A.ZZ * B.XZ,
A.XZ * B.YX + A.YZ * B.YY + A.ZZ * B.YZ,
A.XZ * B.ZX + A.YZ * B.ZY + A.ZZ * B.ZZ));
-- 4D Conversions
procedure Set_Matrix_4D_X (M : in out Matrix_4D; V : Vector_4D);
procedure Set_Matrix_4D_Y (M : in out Matrix_4D; V : Vector_4D);
procedure Set_Matrix_4D_Z (M : in out Matrix_4D; V : Vector_4D);
procedure Set_Matrix_4D_W (M : in out Matrix_4D; V : Vector_4D);
function Get_Matrix_4D_X (M : Matrix_4D) return Vector_4D is ((M.XX, M.XY, M.XZ, M.XW));
function Get_Matrix_4D_Y (M : Matrix_4D) return Vector_4D is ((M.YX, M.YY, M.YZ, M.YW));
function Get_Matrix_4D_Z (M : Matrix_4D) return Vector_4D is ((M.ZX, M.ZY, M.ZZ, M.ZW));
function Get_Matrix_4D_W (M : Matrix_4D) return Vector_4D is ((M.WX, M.WY, M.WZ, M.WW));
function Get_Matrix_4D_X (M : Matrix_4D) return Vector_3D is ((M.XX, M.XY, M.XZ));
function Get_Matrix_4D_Y (M : Matrix_4D) return Vector_3D is ((M.YX, M.YY, M.YZ));
function Get_Matrix_4D_Z (M : Matrix_4D) return Vector_3D is ((M.ZX, M.ZY, M.ZZ));
function Get_Matrix_4D_W (M : Matrix_4D) return Vector_3D is ((M.WX, M.WY, M.WZ));
function To_Matrix_4D (A, B, C, D : Vector_4D) return Matrix_4D is ((A.X, B.X, C.X, D.X,
A.Y, B.Y, C.Y, D.Y,
A.Z, B.Z, C.Z, D.Z,
A.W, B.W, C.W, D.W));
-- 4D Operations
function Inverse (M : Matrix_4D) return Matrix_4D; -- Listing 1.11
function "*" (A : Matrix_4D; B : Vector_4D) return Vector_4D is ((A.XX * B.X + A.YX * B.Y + A.ZX * B.Z + A.WX * B.W,
A.XY * B.X + A.YY * B.Y + A.ZY * B.Z + A.WY * B.W,
A.XZ * B.X + A.YZ * B.Y + A.ZZ * B.Z + A.WZ * B.W,
A.XW * B.X + A.YW * B.Y + A.ZW * B.Z + A.WW * B.W));
function "*" (A, B : Matrix_4D) return Matrix_4D is ((A.XX * B.XX + A.YX * B.XY + A.ZX * B.XZ,
A.XX * B.YX + A.YX * B.YY + A.ZX * B.YZ,
A.XX * B.ZX + A.YX * B.ZY + A.ZX * B.ZZ,
A.XX * B.WX + A.YX * B.WY + A.ZX * B.WZ,
A.XY * B.XX + A.YY * B.XY + A.ZY * B.XZ,
A.XY * B.YX + A.YY * B.YY + A.ZY * B.YZ,
A.XY * B.ZX + A.YY * B.ZY + A.ZY * B.ZZ,
A.XY * B.WX + A.YY * B.WY + A.ZY * B.WZ,
A.XZ * B.XX + A.YZ * B.XY + A.ZZ * B.XZ,
A.XZ * B.YX + A.YZ * B.YY + A.ZZ * B.YZ,
A.XZ * B.ZX + A.YZ * B.ZY + A.ZZ * B.ZZ,
A.XZ * B.WX + A.YZ * B.WY + A.ZZ * B.WZ,
A.XW * B.XX + A.YZ * B.XY + A.ZW * B.XZ,
A.XW * B.YX + A.YZ * B.YY + A.ZW * B.YZ,
A.XW * B.ZX + A.YZ * B.ZY + A.ZW * B.ZZ,
A.XW * B.WX + A.YZ * B.WY + A.ZW * B.WZ));
---------------
-- Transform --
---------------
-- Definition
type Transform_3D is record
XX, YX, ZX,
XY, YY, ZY : Real_32 := 0.0;
-- 0.0, 0.0, 1.0
end record;
type Transform_4D is record -- Listing 2.9
XX, YX, ZX, WX,
XY, YY, ZY, WY,
XZ, YZ, ZZ, WZ : Real_32 := 0.0;
-- 0.0, 0.0, 0.0, 1.0
end record;
package Vector_Transform_3D is new Neo.Core.Vectors (Transform_3D);
package Vector_Transform_4D is new Neo.Core.Vectors (Transform_4D);
ZERO_TRANSFORM_3D : constant Transform_3D := (others => 0.0);
ZERO_TRANSFORM_4D : constant Transform_3D := (others => 0.0);
-- Conversions
procedure Set_Transform_4D_X (H : in out Transform_4D; V : Vector_3D); -- Listing 2.9
procedure Set_Transform_4D_Y (H : in out Transform_4D; V : Vector_3D); -- Listing 2.9
procedure Set_Transform_4D_Z (H : in out Transform_4D; V : Vector_3D); -- Listing 2.9
procedure Set_Transform_4D_W (H : in out Transform_4D; V : Vector_3D); -- Listing 2.9
procedure Set_Translate (H : in out Transform_4D; P : Point_3D); -- Listing 2.9
function Get_Transform_4D_X (H : Transform_4D) return Vector_3D is ((H.XX, H.XY, H.XZ)); -- Listing 2.9
function Get_Transform_4D_Y (H : Transform_4D) return Vector_3D is ((H.YX, H.YY, H.YZ)); -- Listing 2.9
function Get_Transform_4D_Z (H : Transform_4D) return Vector_3D is ((H.ZX, H.ZY, H.ZZ)); -- Listing 2.9
function Get_Transform_4D_W (H : Transform_4D) return Vector_3D is ((H.WX, H.WY, H.WZ)); -- Listing 2.9
function Get_Translate (H : Transform_4D) return Point_3D is ((H.WX, H.WY, H.WZ)); -- Listing 2.9
function To_Matrix_4D (H : Transform_4D) return Matrix_4D is ((H.XX, H.YX, H.ZX, H.WX,
H.XY, H.YY, H.ZY, H.WY,
H.XZ, H.YZ, H.ZZ, H.WZ,
0.0, 0.0, 0.0, 1.0));
function To_Transform_4D (M : Matrix_4D) return Transform_4D is ((M.XX, M.YX, M.ZX, M.WX,
M.XY, M.YY, M.ZY, M.WY,
M.XZ, M.YZ, M.ZZ, M.WZ));
function To_Transform_4D (A, B, C : Vector_3D; P : Point_3D) return Transform_4D is ((A.X, B.X, C.X, P.X, -- Listing 2.9
A.Y, B.Y, C.Y, P.Y,
A.Z, B.Z, C.Z, P.Z));
-- Operations
-- function Transpose () return Matrix_3D;
function Rotate (Angle : Real_32; Kind : Dimension_Kind) return Matrix_3D; -- Listing 2.1
function Rotate (Angle : Real_32; Axis : Vector_3D) return Matrix_3D; -- Listing 2.2
function Reflect (A : Vector_3D) return Matrix_3D; -- Listing 2.3
function Involution (A : Vector_3D) return Matrix_3D; -- Listing 2.4
function Scale (SX, SY, SZ : Real_32) return Matrix_3D; -- Listing 2.5
function Scale (S : Real_32; A : Vector_3D) return Matrix_3D; -- Listing 2.6
function Skew (Angle : Real_32; A, B : Vector_3D) return Matrix_3D; -- Listing 2.7
function Inverse (H : Transform_4D) return Transform_4D; -- Listing 2.9
function "*" (A, B : Transform_4D) return Transform_4D is ((A.XX * B.XX + A.YX * B.XY + A.ZX * B.XZ, -- Listing 2.9
A.XX * B.YX + A.YX * B.YY + A.ZX * B.YZ,
A.XX * B.ZX + A.YX * B.ZY + A.ZX * B.ZZ,
A.XX * B.WX + A.YX * B.WY + A.ZX * B.WZ + A.WX,
A.XY * B.XX + A.YY * B.XY + A.ZY * B.XZ,
A.XY * B.YX + A.YY * B.YY + A.ZY * B.YZ,
A.XY * B.ZX + A.YY * B.ZY + A.ZY * B.ZZ,
A.XY * B.WX + A.YY * B.WY + A.ZY * B.WZ + A.WY,
A.XZ * B.XX + A.YZ * B.XY + A.ZZ * B.XZ,
A.XZ * B.YX + A.YZ * B.YY + A.ZZ * B.YZ,
A.XZ * B.ZX + A.YZ * B.ZY + A.ZZ * B.ZZ,
A.XZ * B.WX + A.YZ * B.WY + A.ZZ * B.WZ + A.WZ));
function "*" (H : Transform_4D; V : Vector_3D) return Vector_3D is ((H.XX * V.X + H.YX * V.Y + H.ZX * V.Z, -- Listing 2.9
H.XY * V.X + H.YY * V.Y + H.ZY * V.Z,
H.XZ * V.X + H.YZ * V.Y + H.ZZ * V.Z));
function "*" (H : Transform_4D; P : Point_3D) return Point_3D is ((H.XX * P.X + H.YX * P.Y + H.ZX * P.Z + H.ZX, -- Listing 2.9
H.XY * P.X + H.YY * P.Y + H.ZY * P.Z + H.ZY,
H.XZ * P.X + H.YZ * P.Y + H.ZZ * P.Z + H.ZZ));
function "*" (N : Vector_3D; H : Transform_4D) return Vector_3D is ((N.X * H.XX + N.Y * H.XY + N.Z * H.XZ, -- Listing 3.1
N.X * H.YX + N.Y * H.YY + N.Z * H.YZ,
N.X * H.ZX + N.Y * H.ZY + N.Z * H.ZZ));
----------------
-- Quaternion --
----------------
-- Definition
type Quaternion_4D is new Vector_4D; -- Listing 2.10
package Vector_Quaternion_4D is new Neo.Core.Vectors (Quaternion_4D);
ZERO_QUATERNION_4D : constant Quaternion_4D := (others => 0.0);
-- Conversions
function To_Vector_3D (Q : Quaternion_4D) return Vector_3D is ((Q.X, Q.Y, Q.Z)); -- Listing 2.10
function To_Quaternion_4D (V : Vector_3D; S : Real_32) return Quaternion_4D is ((V.X, V.Y, V.Z, S)); -- Listing 2.10
function To_Quaternion_4D (V : Vector_3D) return Quaternion_4D;
-- Operations
function "*" (Q1, Q2 : Quaternion_4D) return Quaternion_4D is ((Q1.W * Q2.X + Q1.X * Q2.W + Q1.Y * Q2.Z - Q1.Z * Q2.Y, -- Listing 2.10
Q1.W * Q2.Y - Q1.X * Q2.Z + Q1.Y * Q2.W + Q1.Z * Q2.X,
Q1.W * Q2.Z + Q1.X * Q2.Y - Q1.Y * Q2.X + Q1.Z * Q2.W,
Q1.W * Q2.W - Q1.X * Q2.X - Q1.Y * Q2.Y - Q1.Z * Q2.Z));
function Transform (Q : Quaternion_4D; V : Vector_3D) return Vector_3D; -- Listing 2.11
function Rotation (Q : Quaternion_4D) return Matrix_3D; -- Listing 2.12
procedure Rotate (Q : in out Quaternion_4D; M : Matrix_3D); -- Listing 2.13
-----------
-- Plane --
-----------
-- Definition
type Plane_4D is new Vector_4D; -- Listing 3.4
package Vector_Plane_4D is new Vectors (Plane_4D);
ZERO_PLANE_4D : constant Plane_4D := (others => 0.0);
-- Operations
function Reflect (F : Plane_4D) return Transform_4D; -- Listing 3.5
function Normal (F : Plane_4D) return Vector_3D is ((F.X, F.Y, F.Z)); -- Listing 3.4
function Dot (F : Plane_4D; V : Vector_3D) return Real_32 is (F.X * V.X + F.Y * V.Y + F.Z * V.Z); -- Listing 3.4
function Dot (F : Plane_4D; P : Point_3D) return Real_32 is (F.X * P.X + F.Y * P.Y + F.Z * P.Z + F.W); -- Listing 3.4
function "*" (F : Plane_4D; H : Transform_4D) return Plane_4D is ((F.X * H.XX + F.Y * H.XY + F.Z * H.XZ, -- Listing 3.9
F.X * H.YX + F.Y * H.YY + F.Z * H.YZ,
F.X * H.ZX + F.Y * H.ZY + F.Z * H.ZZ,
F.X * H.WX + F.Y * H.WY + F.Z * H.WZ + F.W));
----------
-- Line --
----------
-- Definition
type Line_3D is record -- Listing 3.10
Direction : Vector_3D := (others => <>);
Moment : Vector_3D := (others => <>);
end record;
-- Operations
function Transform (L : Line_3D; H : Transform_4D) return Line_3D; -- Listing 3.11
-------------
-- Frustum --
-------------
type Frustum_State is record
Target, Right, Up, Beginning, Ending : Vector_3D := (others => <>);
end record;
-------------
-- Algebra -- Listing 4.1 and Table 4.6
-------------
-- {0|0} if p and q are coincident
function Contain (P, Q : Point_3D) return Line_3D is (((Q.X - P.X,
Q.Y - P.Y,
Q.Z - P.Z),
(P.Y * Q.Z - P.Z * Q.Y,
P.Z * Q.X - P.X * Q.Z,
P.X * Q.Y - P.Y * Q.X)));
-- [0|0] if p lies on line L
function Contain (L : Line_3D; P : Point_3D) return Plane_4D is ((L.Direction.Y * P.Z - L.Direction.Z * P.Y + L.Moment.X,
L.Direction.Z * P.X - L.Direction.X * P.Z + L.Moment.Y,
L.Direction.X * P.Y - L.Direction.Y * P.X + L.Moment.Z,
-L.Moment.X * P.X - L.Moment.Y * P.Y - L.Moment.Z * P.Z));
-- [0|0] if all three points are collinear
function Contain (P, Q, R : Point_3D) return Plane_4D is (Contain (Contain (P, Q), R));
-- {0|0} if f and a are coincident, {0|m} if f and g are parallel but not coincident
function Intersect (F, G : Plane_4D) return Line_3D is (((F.Y * G.Z - F.Z * G.Y,
F.Z * G.X - F.X * G.Z,
F.X * G.Y - F.Y * G.X),
(G.X * F.W - F.X * G.W,
G.Y * F.W - F.Y * G.W,
G.Z * F.W - F.Z * G.W)));
-- (0|0) if L lies in the plane f, (p|0) if L is parallel to f but does not lie in f
function Intersect (L : Line_3D; F : Plane_4D) return Vector_4D is ((L.Moment.Y * F.Z - L.Moment.Z * F.Y + L.Direction.X,
L.Moment.Z * F.X - L.Moment.X * F.Z + L.Direction.Y,
L.Moment.X * F.Y - L.Moment.Y * F.X + L.Direction.Z,
-L.Direction.X * F.X - L.Direction.Y * F.Y - L.Direction.Z * F.Z));
-- (0|0) if any two planes are coincident or all three planes are parallel, (p|0) if planes all intersect at parallel lines
function Intersect (F, G, H : Plane_4D) return Vector_4D is (Intersect (Intersect (F, G), H));
-- 0 if L1 and L2 are coplanar
function Distance (L1, L2 : Line_3D) return Real_32 is (-(Dot (L1.Direction, L2.Moment) + Dot (L2.Direction, L1.Moment)));
-- 0 if p lies in the plane f
function Distance (P : Point_3D; F : Plane_4D) return Real_32 is (P.X * F.X + P.Y * F.Y + P.Z * F.Z + F.W);
end;
|
1Crazymoney/LearnAda | Ada | 7,640 | adb | pragma Ada_95;
pragma Source_File_Name (ada_main, Spec_File_Name => "b__signof.ads");
pragma Source_File_Name (ada_main, Body_File_Name => "b__signof.adb");
pragma Suppress (Overflow_Check);
with Ada.Exceptions;
package body ada_main is
pragma Warnings (Off);
E074 : Short_Integer; pragma Import (Ada, E074, "system__os_lib_E");
E013 : Short_Integer; pragma Import (Ada, E013, "system__soft_links_E");
E023 : Short_Integer; pragma Import (Ada, E023, "system__exception_table_E");
E048 : Short_Integer; pragma Import (Ada, E048, "ada__io_exceptions_E");
E050 : Short_Integer; pragma Import (Ada, E050, "ada__tags_E");
E047 : Short_Integer; pragma Import (Ada, E047, "ada__streams_E");
E072 : Short_Integer; pragma Import (Ada, E072, "interfaces__c_E");
E025 : Short_Integer; pragma Import (Ada, E025, "system__exceptions_E");
E077 : Short_Integer; pragma Import (Ada, E077, "system__file_control_block_E");
E066 : Short_Integer; pragma Import (Ada, E066, "system__file_io_E");
E070 : Short_Integer; pragma Import (Ada, E070, "system__finalization_root_E");
E068 : Short_Integer; pragma Import (Ada, E068, "ada__finalization_E");
E017 : Short_Integer; pragma Import (Ada, E017, "system__secondary_stack_E");
E045 : Short_Integer; pragma Import (Ada, E045, "ada__text_io_E");
E099 : Short_Integer; pragma Import (Ada, E099, "mat_E");
Local_Priority_Specific_Dispatching : constant String := "";
Local_Interrupt_States : constant String := "";
Is_Elaborated : Boolean := False;
procedure finalize_library is
begin
E045 := E045 - 1;
declare
procedure F1;
pragma Import (Ada, F1, "ada__text_io__finalize_spec");
begin
F1;
end;
declare
procedure F2;
pragma Import (Ada, F2, "system__file_io__finalize_body");
begin
E066 := E066 - 1;
F2;
end;
declare
procedure Reraise_Library_Exception_If_Any;
pragma Import (Ada, Reraise_Library_Exception_If_Any, "__gnat_reraise_library_exception_if_any");
begin
Reraise_Library_Exception_If_Any;
end;
end finalize_library;
procedure adafinal is
procedure s_stalib_adafinal;
pragma Import (C, s_stalib_adafinal, "system__standard_library__adafinal");
procedure Runtime_Finalize;
pragma Import (C, Runtime_Finalize, "__gnat_runtime_finalize");
begin
if not Is_Elaborated then
return;
end if;
Is_Elaborated := False;
Runtime_Finalize;
s_stalib_adafinal;
end adafinal;
type No_Param_Proc is access procedure;
procedure adainit is
Main_Priority : Integer;
pragma Import (C, Main_Priority, "__gl_main_priority");
Time_Slice_Value : Integer;
pragma Import (C, Time_Slice_Value, "__gl_time_slice_val");
WC_Encoding : Character;
pragma Import (C, WC_Encoding, "__gl_wc_encoding");
Locking_Policy : Character;
pragma Import (C, Locking_Policy, "__gl_locking_policy");
Queuing_Policy : Character;
pragma Import (C, Queuing_Policy, "__gl_queuing_policy");
Task_Dispatching_Policy : Character;
pragma Import (C, Task_Dispatching_Policy, "__gl_task_dispatching_policy");
Priority_Specific_Dispatching : System.Address;
pragma Import (C, Priority_Specific_Dispatching, "__gl_priority_specific_dispatching");
Num_Specific_Dispatching : Integer;
pragma Import (C, Num_Specific_Dispatching, "__gl_num_specific_dispatching");
Main_CPU : Integer;
pragma Import (C, Main_CPU, "__gl_main_cpu");
Interrupt_States : System.Address;
pragma Import (C, Interrupt_States, "__gl_interrupt_states");
Num_Interrupt_States : Integer;
pragma Import (C, Num_Interrupt_States, "__gl_num_interrupt_states");
Unreserve_All_Interrupts : Integer;
pragma Import (C, Unreserve_All_Interrupts, "__gl_unreserve_all_interrupts");
Detect_Blocking : Integer;
pragma Import (C, Detect_Blocking, "__gl_detect_blocking");
Default_Stack_Size : Integer;
pragma Import (C, Default_Stack_Size, "__gl_default_stack_size");
Leap_Seconds_Support : Integer;
pragma Import (C, Leap_Seconds_Support, "__gl_leap_seconds_support");
procedure Runtime_Initialize (Install_Handler : Integer);
pragma Import (C, Runtime_Initialize, "__gnat_runtime_initialize");
Finalize_Library_Objects : No_Param_Proc;
pragma Import (C, Finalize_Library_Objects, "__gnat_finalize_library_objects");
begin
if Is_Elaborated then
return;
end if;
Is_Elaborated := True;
Main_Priority := -1;
Time_Slice_Value := -1;
WC_Encoding := 'b';
Locking_Policy := ' ';
Queuing_Policy := ' ';
Task_Dispatching_Policy := ' ';
Priority_Specific_Dispatching :=
Local_Priority_Specific_Dispatching'Address;
Num_Specific_Dispatching := 0;
Main_CPU := -1;
Interrupt_States := Local_Interrupt_States'Address;
Num_Interrupt_States := 0;
Unreserve_All_Interrupts := 0;
Detect_Blocking := 0;
Default_Stack_Size := -1;
Leap_Seconds_Support := 0;
Runtime_Initialize (1);
Finalize_Library_Objects := finalize_library'access;
System.Soft_Links'Elab_Spec;
System.Exception_Table'Elab_Body;
E023 := E023 + 1;
Ada.Io_Exceptions'Elab_Spec;
E048 := E048 + 1;
Ada.Tags'Elab_Spec;
Ada.Streams'Elab_Spec;
E047 := E047 + 1;
Interfaces.C'Elab_Spec;
System.Exceptions'Elab_Spec;
E025 := E025 + 1;
System.File_Control_Block'Elab_Spec;
E077 := E077 + 1;
System.Finalization_Root'Elab_Spec;
E070 := E070 + 1;
Ada.Finalization'Elab_Spec;
E068 := E068 + 1;
System.File_Io'Elab_Body;
E066 := E066 + 1;
E072 := E072 + 1;
Ada.Tags'Elab_Body;
E050 := E050 + 1;
System.Soft_Links'Elab_Body;
E013 := E013 + 1;
System.Os_Lib'Elab_Body;
E074 := E074 + 1;
System.Secondary_Stack'Elab_Body;
E017 := E017 + 1;
Ada.Text_Io'Elab_Spec;
Ada.Text_Io'Elab_Body;
E045 := E045 + 1;
E099 := E099 + 1;
end adainit;
procedure Ada_Main_Program;
pragma Import (Ada, Ada_Main_Program, "_ada_signof");
function main
(argc : Integer;
argv : System.Address;
envp : System.Address)
return Integer
is
procedure Initialize (Addr : System.Address);
pragma Import (C, Initialize, "__gnat_initialize");
procedure Finalize;
pragma Import (C, Finalize, "__gnat_finalize");
SEH : aliased array (1 .. 2) of Integer;
Ensure_Reference : aliased System.Address := Ada_Main_Program_Name'Address;
pragma Volatile (Ensure_Reference);
begin
gnat_argc := argc;
gnat_argv := argv;
gnat_envp := envp;
Initialize (SEH'Address);
adainit;
Ada_Main_Program;
adafinal;
Finalize;
return (gnat_exit_status);
end;
-- BEGIN Object file/option list
-- C:\Users\Soba95\Desktop\ada\mat.o
-- C:\Users\Soba95\Desktop\ada\signof.o
-- -LC:\Users\Soba95\Desktop\ada\
-- -LC:\Users\Soba95\Desktop\ada\
-- -LC:/gnat/2015/lib/gcc/i686-pc-mingw32/4.9.3/adalib/
-- -static
-- -lgnat
-- -Wl,--stack=0x2000000
-- END Object file/option list
end ada_main;
|
BrickBot/Bound-T-H8-300 | Ada | 3,231 | adb | -- Symbols.Opt (body)
--
-- A component of the Bound-T Worst-Case Execution Time Tool.
--
-------------------------------------------------------------------------------
-- Copyright (c) 1999 .. 2015 Tidorum Ltd
-- All rights reserved.
--
-- Redistribution and use in source and binary forms, with or without
-- modification, are permitted provided that the following conditions are met:
--
-- 1. Redistributions of source code must retain the above copyright notice, this
-- list of conditions and the following disclaimer.
-- 2. Redistributions in binary form must reproduce the above copyright notice,
-- this list of conditions and the following disclaimer in the documentation
-- and/or other materials provided with the distribution.
--
-- This software is provided by the copyright holders and contributors "as is" and
-- any express or implied warranties, including, but not limited to, the implied
-- warranties of merchantability and fitness for a particular purpose are
-- disclaimed. In no event shall the copyright owner or contributors be liable for
-- any direct, indirect, incidental, special, exemplary, or consequential damages
-- (including, but not limited to, procurement of substitute goods or services;
-- loss of use, data, or profits; or business interruption) however caused and
-- on any theory of liability, whether in contract, strict liability, or tort
-- (including negligence or otherwise) arising in any way out of the use of this
-- software, even if advised of the possibility of such damage.
--
-- Other modules (files) of this software composition should contain their
-- own copyright statements, which may have different copyright and usage
-- conditions. The above conditions apply to this file.
-------------------------------------------------------------------------------
--
-- $Revision: 1.3 $
-- $Date: 2015/10/24 20:05:52 $
--
-- $Log: symbols-opt.adb,v $
-- Revision 1.3 2015/10/24 20:05:52 niklas
-- Moved to free licence.
--
-- Revision 1.2 2011-08-31 04:23:34 niklas
-- BT-CH-0222: Option registry. Option -dump. External help files.
--
-- Revision 1.1 2008/10/11 08:16:14 niklas
-- BT-CH-0148: Symbols from text files and the -symbols option.
--
with Options;
with Options.Groups;
package body Symbols.Opt is
begin -- Symbols.Opt
Options.Register (
Option => Symbol_File_Names_Opt'Access,
Name => "symbols",
Group => Options.Groups.Inputs);
Options.Register (
Option => Trace_Opt'Access,
Name => Options.Trace_Item ("symbols"),
Group => Options.Groups.Trace);
Options.Register (
Option => Trace_Scopes_Opt'Access,
Name => Options.Trace_Item ("scopes"),
Group => Options.Groups.Trace);
Options.Register (
Option => Trace_Insertion_Opt'Access,
Name => Options.Trace_Item ("symins"),
Group => Options.Groups.Trace);
Options.Register (
Option => Warn_Duplicated_Symbol_Opt'Access,
Name => Options.Warn_Item ("symbol"),
Group => Options.Groups.Warn);
Options.Register (
Option => Warn_Shallow_Line_Scope_Opt'Access,
Name => Options.Warn_Item ("line_scope"),
Group => Options.Groups.Warn);
end Symbols.Opt;
|
AdaCore/libadalang | Ada | 388 | adb | procedure Test is
type Integer_Access is access all Integer;
package Pkg is
type T is tagged record
Foo : Integer_Access;
end record;
procedure Foo (Self : T);
end Pkg;
package body Pkg is
procedure Foo (Self : T) is null;
end Pkg;
X : Pkg.T;
begin
if X.Foo /= null then
null;
end if;
pragma Test_Statement;
end Test;
|
reznikmm/matreshka | Ada | 4,057 | ads | ------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- Open Document Toolkit --
-- --
-- Runtime Library Component --
-- --
------------------------------------------------------------------------------
-- --
-- Copyright © 2014, Vadim Godunko <[email protected]> --
-- All rights reserved. --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions --
-- are met: --
-- --
-- * Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- --
-- * Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in the --
-- documentation and/or other materials provided with the distribution. --
-- --
-- * Neither the name of the Vadim Godunko, IE nor the names of its --
-- contributors may be used to endorse or promote products derived from --
-- this software without specific prior written permission. --
-- --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR --
-- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
-- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED --
-- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR --
-- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF --
-- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING --
-- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS --
-- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
-- --
------------------------------------------------------------------------------
-- $Revision$ $Date$
------------------------------------------------------------------------------
with ODF.DOM.Draw_Marker_End_Center_Attributes;
package Matreshka.ODF_Draw.Marker_End_Center_Attributes is
type Draw_Marker_End_Center_Attribute_Node is
new Matreshka.ODF_Draw.Abstract_Draw_Attribute_Node
and ODF.DOM.Draw_Marker_End_Center_Attributes.ODF_Draw_Marker_End_Center_Attribute
with null record;
overriding function Create
(Parameters : not null access Matreshka.DOM_Attributes.Attribute_L2_Parameters)
return Draw_Marker_End_Center_Attribute_Node;
overriding function Get_Local_Name
(Self : not null access constant Draw_Marker_End_Center_Attribute_Node)
return League.Strings.Universal_String;
end Matreshka.ODF_Draw.Marker_End_Center_Attributes;
|
Vovanium/Encodings | Ada | 985 | ads | generic
type Character_Type is (<>); -- Character, Wide_Character, Wide_Wide_Character (or whatever)
type String_Type is array(Positive range <>) of Character_Type;
Carriage_Return: in Character_Type; -- CR in the corresponding type
Line_Feed: in Character_Type; -- LF in the corresponding type
type Coder_Base is abstract tagged private; -- Type to derive
package Encodings.Line_Endings.Generic_Add_CR is
type Coder is new Coder_Base with private;
procedure Convert(
This: in out Coder; -- Coder state
Source: in String_Type; -- String to be converted
Source_Last: out Natural; -- Last index of source string read (length if string is starting at 1)
Target: out String_Type; -- Converted string
Target_Last: out Natural -- Last Index of destination string written
);
private
type Coder_State is (
Initial,
Have_CR,
Need_LF
);
type Coder is new Coder_Base with record
State: Coder_State := Initial;
end record;
end Encodings.Line_Endings.Generic_Add_CR;
|
reznikmm/matreshka | Ada | 4,615 | adb | ------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- Open Document Toolkit --
-- --
-- Runtime Library Component --
-- --
------------------------------------------------------------------------------
-- --
-- Copyright © 2014, Vadim Godunko <[email protected]> --
-- All rights reserved. --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions --
-- are met: --
-- --
-- * Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- --
-- * Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in the --
-- documentation and/or other materials provided with the distribution. --
-- --
-- * Neither the name of the Vadim Godunko, IE nor the names of its --
-- contributors may be used to endorse or promote products derived from --
-- this software without specific prior written permission. --
-- --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR --
-- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
-- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED --
-- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR --
-- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF --
-- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING --
-- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS --
-- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
-- --
------------------------------------------------------------------------------
-- $Revision$ $Date$
------------------------------------------------------------------------------
with Matreshka.DOM_Documents;
with Matreshka.ODF_String_Constants;
with ODF.DOM.Iterators;
with ODF.DOM.Visitors;
package body Matreshka.ODF_Form.Linked_Cell_Attributes is
------------
-- Create --
------------
overriding function Create
(Parameters : not null access Matreshka.DOM_Attributes.Attribute_L2_Parameters)
return Form_Linked_Cell_Attribute_Node is
begin
return Self : Form_Linked_Cell_Attribute_Node do
Matreshka.ODF_Form.Constructors.Initialize
(Self'Unchecked_Access,
Parameters.Document,
Matreshka.ODF_String_Constants.Form_Prefix);
end return;
end Create;
--------------------
-- Get_Local_Name --
--------------------
overriding function Get_Local_Name
(Self : not null access constant Form_Linked_Cell_Attribute_Node)
return League.Strings.Universal_String
is
pragma Unreferenced (Self);
begin
return Matreshka.ODF_String_Constants.Linked_Cell_Attribute;
end Get_Local_Name;
begin
Matreshka.DOM_Documents.Register_Attribute
(Matreshka.ODF_String_Constants.Form_URI,
Matreshka.ODF_String_Constants.Linked_Cell_Attribute,
Form_Linked_Cell_Attribute_Node'Tag);
end Matreshka.ODF_Form.Linked_Cell_Attributes;
|
sungyeon/drake | Ada | 5,293 | adb | with System.Address_To_Named_Access_Conversions;
with System.Growth;
with System.Debug; -- assertions
with C.basetsd;
with C.winbase;
with C.windef;
package body System.Unbounded_Allocators is
use type Storage_Elements.Storage_Offset;
use type C.size_t;
use type C.basetsd.SSIZE_T;
use type C.windef.WORD;
use type C.windef.WINBOOL;
use type C.winnt.HANDLE; -- C.void_ptr
package HANDLE_ptr_Conv is
new Address_To_Named_Access_Conversions (
C.winnt.HANDLE,
C.winnt.HANDLE_ptr);
type HANDLE_array is array (C.size_t range <>) of C.winnt.HANDLE
with Convention => C;
function Is_In (Storage_Address : Address; Heap : C.winnt.HANDLE)
return Boolean;
function Is_In (Storage_Address : Address; Heap : C.winnt.HANDLE)
return Boolean
is
Result : Boolean := False;
begin
Result :=
C.winbase.HeapValidate (
Heap,
0,
C.void_const_ptr (Storage_Address)) /=
C.windef.FALSE;
-- Result := False;
-- Dummy := C.winbase.HeapLock (Heap);
-- declare
-- Heap_Entry : aliased C.winbase.PROCESS_HEAP_ENTRY :=
-- (lpData => C.void_ptr (Null_Address), others => <>);
-- begin
-- while C.winbase.HeapWalk (Heap, Heap_Entry'Access) /=
-- C.windef.FALSE
-- loop
-- if (Heap_Entry.wFlags and C.winbase.PROCESS_HEAP_REGION) /= 0
-- and then Storage_Address >=
-- Address (Heap_Entry.anonymous_1.Region.lpFirstBlock)
-- and then Storage_Address <
-- Address (Heap_Entry.anonymous_1.Region.lpLastBlock)
-- then
-- Result := True;
-- exit;
-- end if;
-- end loop;
-- end;
-- Dummy := C.winbase.HeapUnlock (Heap);
return Result;
end Is_In;
-- implementation
procedure Initialize (Object : in out Unbounded_Allocator) is
begin
Object := Unbounded_Allocator (C.winbase.HeapCreate (0, 0, 0));
end Initialize;
procedure Finalize (Object : in out Unbounded_Allocator) is
Success : C.windef.WINBOOL;
begin
Success := C.winbase.HeapDestroy (C.winnt.HANDLE (Object));
pragma Check (Debug,
Check =>
Success /= C.windef.FALSE
or else Debug.Runtime_Error ("HeapDestroy failed"));
end Finalize;
procedure Allocate (
Allocator : Unbounded_Allocator;
Storage_Address : out Address;
Size_In_Storage_Elements : Storage_Elements.Storage_Count;
Alignment : Storage_Elements.Storage_Count) is
begin
Storage_Address := Address (
C.winbase.HeapAlloc (
C.winnt.HANDLE (Allocator),
0,
C.basetsd.SIZE_T (Size_In_Storage_Elements)));
if Storage_Address = Null_Address then
raise Storage_Error;
elsif Storage_Address mod Alignment /= 0 then
Deallocate (
Allocator,
Storage_Address,
Size_In_Storage_Elements,
Alignment);
raise Storage_Error;
end if;
end Allocate;
procedure Deallocate (
Allocator : Unbounded_Allocator;
Storage_Address : Address;
Size_In_Storage_Elements : Storage_Elements.Storage_Count;
Alignment : Storage_Elements.Storage_Count)
is
pragma Unreferenced (Size_In_Storage_Elements);
pragma Unreferenced (Alignment);
Success : C.windef.WINBOOL;
begin
Success := C.winbase.HeapFree (
C.winnt.HANDLE (Allocator),
0,
C.windef.LPVOID (Storage_Address));
pragma Check (Debug,
Check =>
Success /= C.windef.FALSE
or else Debug.Runtime_Error ("HeapFree failed"));
end Deallocate;
function Allocator_Of (Storage_Address : Address)
return Unbounded_Allocator
is
package Holder is
new Growth.Scoped_Holder (
C.basetsd.SSIZE_T,
Component_Size => HANDLE_array'Component_Size);
Buffer_Length : C.size_t;
begin
Holder.Reserve_Capacity (64);
loop
declare
Length : C.basetsd.SSIZE_T;
begin
Length :=
C.basetsd.SSIZE_T (
C.winbase.GetProcessHeaps (
C.windef.DWORD (Holder.Capacity),
HANDLE_ptr_Conv.To_Pointer (Holder.Storage_Address)));
if Length = 0 then
raise Program_Error; -- GetProcessHeaps failed
end if;
if Length <= Holder.Capacity then
Buffer_Length := C.size_t (Length);
exit;
end if;
end;
-- growth
declare
function Grow is new Growth.Fast_Grow (C.basetsd.SSIZE_T);
begin
Holder.Reserve_Capacity (Grow (Holder.Capacity));
end;
end loop;
declare
Heaps : HANDLE_array (0 .. Buffer_Length - 1);
for Heaps'Address use Holder.Storage_Address;
begin
for I in Heaps'Range loop
if Is_In (Storage_Address, Heaps (I)) then
return Unbounded_Allocator (Heaps (I)); -- found
end if;
end loop;
end;
raise Program_Error; -- not found
end Allocator_Of;
end System.Unbounded_Allocators;
|
reznikmm/matreshka | Ada | 5,091 | 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.ODF_String_Constants;
package body Matreshka.ODF_XForms is
------------------
-- Constructors --
------------------
package body Constructors is
----------------
-- Initialize --
----------------
procedure Initialize
(Self : not null access Abstract_XForms_Attribute_Node'Class;
Document : not null Matreshka.DOM_Nodes.Document_Access;
Prefix : League.Strings.Universal_String) is
begin
Matreshka.DOM_Attributes.Constructors.Initialize (Self, Document);
Self.Prefix := Prefix;
end Initialize;
----------------
-- Initialize --
----------------
procedure Initialize
(Self : not null access Abstract_XForms_Element_Node'Class;
Document : not null Matreshka.DOM_Nodes.Document_Access;
Prefix : League.Strings.Universal_String) is
begin
Matreshka.DOM_Elements.Constructors.Initialize (Self, Document);
Self.Prefix := Prefix;
end Initialize;
end Constructors;
-----------------------
-- Get_Namespace_URI --
-----------------------
overriding function Get_Namespace_URI
(Self : not null access constant Abstract_XForms_Attribute_Node)
return League.Strings.Universal_String is
begin
return Matreshka.ODF_String_Constants.XForms_URI;
end Get_Namespace_URI;
-----------------------
-- Get_Namespace_URI --
-----------------------
overriding function Get_Namespace_URI
(Self : not null access constant Abstract_XForms_Element_Node)
return League.Strings.Universal_String is
begin
return Matreshka.ODF_String_Constants.XForms_URI;
end Get_Namespace_URI;
end Matreshka.ODF_XForms;
|
albinjal/ada_basic | Ada | 2,817 | adb | with Ada.Text_IO; use Ada.Text_IO;
with Ada.Integer_Text_IO; use Ada.Integer_Text_IO;
with Ada.Unchecked_Deallocation;
package body Sorted_List is
procedure Free is
new Ada.Unchecked_Deallocation(Post, List_Type);
function Empty(List: List_Type)
return Boolean is
begin
return List = null;
end Empty;
procedure Insert_First(List: in out List_Type; Int: in Integer) is
Temp: List_Type;
begin
Temp := List;
List := new Post;
List.Data := Int;
List.Point := Temp;
end Insert_First;
procedure Insert(List: in out List_Type; Int: in Integer) is
begin
if Empty(List) then
Insert_First(List, Int);
elsif Int < List.Data then
Insert_First(List, Int);
else
Insert(List.Point, Int);
end if;
end Insert;
procedure Put(List: List_Type) is
begin
if not Empty(List) then
Put(List.all.Data);
New_Line;
Put(List.all.Point);
end if;
end Put;
function Member(List: List_Type; Search: Integer)
return Boolean is
begin
if Empty(List) then
return False;
end if;
if List.Data = Search then
return True;
else
return Member(List.all.Point, Search);
end if;
end Member;
procedure RemoveCurrent(List: in out List_Type) is
Temp: List_Type;
begin
Temp := List;
List := List.Point;
Free(Temp);
end RemoveCurrent;
procedure Remove(List: in out List_Type; Search: in Integer) is
begin
if Empty(List) then
raise CANTFIND_ERROR;
end if;
if List.Data = Search then
RemoveCurrent(List);
else
if List.Point = null then
raise CANTFIND_ERROR;
end if;
Remove(List.Point, Search);
end if;
end Remove;
procedure Delete(List: in out List_Type) is
begin
if List.Point = null then
Free(List);
List := null;
else
RemoveCurrent(List);
Delete(List);
end if;
end Delete;
function Find(List: List_Type; Search: Integer)
return Integer is
begin
if Empty(List) then
raise CANTFIND_ERROR;
end if;
if List.Data = Search then
return List.Data;
end if;
if List.Point = null then
raise CANTFIND_ERROR;
end if;
return Find(List.Point, Search);
end Find;
procedure Find(List: in List_Type; Search: in Integer; Data: out Integer) is
begin
Data := Find(List, Search);
end Find;
function Length(List: List_Type)
return Integer is
begin
if List.Point /= null then
return 1 + Length(List.Point);
end if;
return 1;
end Length;
end Sorted_List;
|
reznikmm/matreshka | Ada | 7,081 | adb | ------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- Open Document Toolkit --
-- --
-- Runtime Library Component --
-- --
------------------------------------------------------------------------------
-- --
-- Copyright © 2014, Vadim Godunko <[email protected]> --
-- All rights reserved. --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions --
-- are met: --
-- --
-- * Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- --
-- * Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in the --
-- documentation and/or other materials provided with the distribution. --
-- --
-- * Neither the name of the Vadim Godunko, IE nor the names of its --
-- contributors may be used to endorse or promote products derived from --
-- this software without specific prior written permission. --
-- --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR --
-- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
-- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED --
-- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR --
-- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF --
-- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING --
-- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS --
-- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
-- --
------------------------------------------------------------------------------
-- $Revision$ $Date$
------------------------------------------------------------------------------
with Matreshka.DOM_Documents;
with Matreshka.ODF_String_Constants;
with ODF.DOM.Iterators;
with ODF.DOM.Visitors;
package body Matreshka.ODF_Table.Target_Range_Address_Elements is
------------
-- Create --
------------
overriding function Create
(Parameters : not null access Matreshka.DOM_Elements.Element_L2_Parameters)
return Table_Target_Range_Address_Element_Node is
begin
return Self : Table_Target_Range_Address_Element_Node do
Matreshka.ODF_Table.Constructors.Initialize
(Self'Unchecked_Access,
Parameters.Document,
Matreshka.ODF_String_Constants.Table_Prefix);
end return;
end Create;
----------------
-- Enter_Node --
----------------
overriding procedure Enter_Node
(Self : not null access Table_Target_Range_Address_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_Table_Target_Range_Address
(ODF.DOM.Table_Target_Range_Address_Elements.ODF_Table_Target_Range_Address_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 Table_Target_Range_Address_Element_Node)
return League.Strings.Universal_String
is
pragma Unreferenced (Self);
begin
return Matreshka.ODF_String_Constants.Target_Range_Address_Element;
end Get_Local_Name;
----------------
-- Leave_Node --
----------------
overriding procedure Leave_Node
(Self : not null access Table_Target_Range_Address_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_Table_Target_Range_Address
(ODF.DOM.Table_Target_Range_Address_Elements.ODF_Table_Target_Range_Address_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 Table_Target_Range_Address_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_Table_Target_Range_Address
(Visitor,
ODF.DOM.Table_Target_Range_Address_Elements.ODF_Table_Target_Range_Address_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.Table_URI,
Matreshka.ODF_String_Constants.Target_Range_Address_Element,
Table_Target_Range_Address_Element_Node'Tag);
end Matreshka.ODF_Table.Target_Range_Address_Elements;
|
AdaCore/libadalang | Ada | 95 | ads | package Types is
type Content is tagged record
I : Integer;
end record;
end Types;
|
strenkml/EE368 | Ada | 2,314 | ads |
package Memory.Option is
type Option_Type is new Memory_Type with private;
type Option_Pointer is access all Option_Type'Class;
function Create_Option return Option_Pointer;
function Clone(mem : Option_Type) return Memory_Pointer;
procedure Permute(mem : in out Option_Type;
generator : in Distribution_Type;
max_cost : in Cost_Type);
procedure Add_Memory(mem : in out Option_Type;
other : access Memory_Type'Class);
overriding
function Done(mem : Option_Type) return Boolean;
overriding
procedure Reset(mem : in out Option_Type;
context : in Natural);
overriding
procedure Set_Port(mem : in out Option_Type;
port : in Natural;
ready : out Boolean);
overriding
procedure Read(mem : in out Option_Type;
address : in Address_Type;
size : in Positive);
overriding
procedure Write(mem : in out Option_Type;
address : in Address_Type;
size : in Positive);
overriding
procedure Idle(mem : in out Option_Type;
cycles : in Time_Type);
overriding
function Get_Time(mem : Option_Type) return Time_Type;
overriding
function Get_Writes(mem : Option_Type) return Long_Integer;
overriding
function To_String(mem : Option_Type) return Unbounded_String;
overriding
function Get_Cost(mem : Option_Type) return Cost_Type;
overriding
function Get_Word_Size(mem : Option_Type) return Positive;
overriding
procedure Generate(mem : in Option_Type;
sigs : in out Unbounded_String;
code : in out Unbounded_String);
overriding
function Get_Ports(mem : Option_Type) return Port_Vector_Type;
private
package Memory_Vectors is new Vectors(Natural, Memory_Pointer);
subtype Memory_Vector_Type is Memory_Vectors.Vector;
type Option_Type is new Memory_Type with record
memories : Memory_Vector_Type;
index : Natural := 0;
end record;
overriding
procedure Adjust(mem : in out Option_Type);
overriding
procedure Finalize(mem : in out Option_Type);
end Memory.Option;
|
reznikmm/matreshka | Ada | 4,592 | adb | ------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- Open Document Toolkit --
-- --
-- Runtime Library Component --
-- --
------------------------------------------------------------------------------
-- --
-- Copyright © 2014, Vadim Godunko <[email protected]> --
-- All rights reserved. --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions --
-- are met: --
-- --
-- * Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- --
-- * Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in the --
-- documentation and/or other materials provided with the distribution. --
-- --
-- * Neither the name of the Vadim Godunko, IE nor the names of its --
-- contributors may be used to endorse or promote products derived from --
-- this software without specific prior written permission. --
-- --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR --
-- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
-- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED --
-- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR --
-- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF --
-- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING --
-- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS --
-- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
-- --
------------------------------------------------------------------------------
-- $Revision$ $Date$
------------------------------------------------------------------------------
with Matreshka.DOM_Documents;
with Matreshka.ODF_String_Constants;
with ODF.DOM.Iterators;
with ODF.DOM.Visitors;
package body Matreshka.ODF_Table.Protect_Attributes is
------------
-- Create --
------------
overriding function Create
(Parameters : not null access Matreshka.DOM_Attributes.Attribute_L2_Parameters)
return Table_Protect_Attribute_Node is
begin
return Self : Table_Protect_Attribute_Node do
Matreshka.ODF_Table.Constructors.Initialize
(Self'Unchecked_Access,
Parameters.Document,
Matreshka.ODF_String_Constants.Table_Prefix);
end return;
end Create;
--------------------
-- Get_Local_Name --
--------------------
overriding function Get_Local_Name
(Self : not null access constant Table_Protect_Attribute_Node)
return League.Strings.Universal_String
is
pragma Unreferenced (Self);
begin
return Matreshka.ODF_String_Constants.Protect_Attribute;
end Get_Local_Name;
begin
Matreshka.DOM_Documents.Register_Attribute
(Matreshka.ODF_String_Constants.Table_URI,
Matreshka.ODF_String_Constants.Protect_Attribute,
Table_Protect_Attribute_Node'Tag);
end Matreshka.ODF_Table.Protect_Attributes;
|
drm343/Space-War-3000 | Ada | 1,262 | adb | package body Planet is
package body Origin_Define is
function Build (name : String;
colony: Integer;
starship: Integer;
station: Integer)
return Object
is
planet: Object;
add_error: exception;
begin
if (colony + starship + station) = 5 then
planet.Name := SU.To_Unbounded_String (name);
planet.Colony := colony;
planet.Starship := starship;
planet.Station := station;
planet.Damage := false;
return planet;
else
raise add_error;
end if;
end Build;
-----------------------
-- Operator
-----------------------
function show (planet: in Object) return String is
begin
return SU.To_String (planet.Name);
end show;
procedure attack (planet: in out Object) is
begin
planet.damage := true;
end attack;
function "=" (Left, Right : Object) return Boolean is
begin
if SU."=" (Left.Name, Right.Name) then
return True;
else
return False;
end if;
end "=";
end Origin_Define;
end Planet;
|
reznikmm/matreshka | Ada | 4,171 | ads | ------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- Open Document Toolkit --
-- --
-- Runtime Library Component --
-- --
------------------------------------------------------------------------------
-- --
-- Copyright © 2014, Vadim Godunko <[email protected]> --
-- All rights reserved. --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions --
-- are met: --
-- --
-- * Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- --
-- * Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in the --
-- documentation and/or other materials provided with the distribution. --
-- --
-- * Neither the name of the Vadim Godunko, IE nor the names of its --
-- contributors may be used to endorse or promote products derived from --
-- this software without specific prior written permission. --
-- --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR --
-- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
-- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED --
-- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR --
-- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF --
-- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING --
-- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS --
-- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
-- --
------------------------------------------------------------------------------
-- $Revision$ $Date$
------------------------------------------------------------------------------
with ODF.DOM.Table_Condition_Source_Range_Address_Attributes;
package Matreshka.ODF_Table.Condition_Source_Range_Address_Attributes is
type Table_Condition_Source_Range_Address_Attribute_Node is
new Matreshka.ODF_Table.Abstract_Table_Attribute_Node
and ODF.DOM.Table_Condition_Source_Range_Address_Attributes.ODF_Table_Condition_Source_Range_Address_Attribute
with null record;
overriding function Create
(Parameters : not null access Matreshka.DOM_Attributes.Attribute_L2_Parameters)
return Table_Condition_Source_Range_Address_Attribute_Node;
overriding function Get_Local_Name
(Self : not null access constant Table_Condition_Source_Range_Address_Attribute_Node)
return League.Strings.Universal_String;
end Matreshka.ODF_Table.Condition_Source_Range_Address_Attributes;
|
osannolik/ada-canopen | Ada | 4,614 | adb | with AUnit.Assertions; use AUnit.Assertions;
with ACO.Utils.DS.Generic_Table;
package body Generic_Table_Test is
pragma Assertion_Policy (Check);
type Key_Type is new Character;
subtype Test_Keys is Key_Type range 'a' .. 'z';
type Value_Type is new Positive;
function Hashit (Key : Key_Type) return Natural is
(Key_Type'Pos (Key));
Number_Of_Buckets : constant := 3;
Maximum_Size : constant :=
Test_Keys'Pos(Test_Keys'Last) - Test_Keys'Pos(Test_Keys'First) + 1;
package Table_Pack is new ACO.Utils.DS.Generic_Table
(Key_Type => Key_Type,
"=" => "=",
Hash => Hashit,
Value_Type => Value_Type);
subtype T is Table_Pack.Table
(Number_Of_Buckets => Number_Of_Buckets,
Maximum_Size => Maximum_Size);
function Name (T : Test) return AUnit.Message_String is
pragma Unreferenced (T);
begin
return AUnit.Format ("Data Structures: Generic Table Test");
end Name;
procedure Init_Test
is
Table : T;
begin
Assert (Table.Is_Empty, "Table is not initially empty");
Assert (Table.Length = 0, "Table has not initially the length zero");
Assert (not Table.Is_Full, "Table is initially full");
for K in Key_Type'Range loop
Assert (not Table.Is_Bound (K), "Table has a bound key at init");
end loop;
end Init_Test;
procedure Asserted_Fill
(Table : in out T)
is
V : Value_Type;
L : Natural := 0;
begin
for K in Test_Keys'Range loop
V := Key_Type'Pos(K);
Table.Bind (K, V);
L := L + 1;
Assert (Table.Is_Bound (K), "Key is not bound");
Assert (Table.Value_Of (K) = V, "Value for key incorrect");
Assert (Table.Length = L, "Length is not" & L'Img);
end loop;
Assert (Table.Is_Full, "Table not full");
Assert (not Table.Is_Empty, "Table is empty");
end Asserted_Fill;
procedure Bind
is
Table : T;
begin
Asserted_Fill (Table);
end Bind;
procedure Bind_New_To_Full
is
Table : T;
K : constant Key_Type := Key_Type'Succ (Test_Keys'Last);
begin
Asserted_Fill (Table);
Table.Bind (K, 1337);
end Bind_New_To_Full;
procedure Bind_Existing_To_Full
is
Table : T;
K : constant Key_Type := Test_Keys'First;
V : constant Value_Type := 1337;
L : Natural;
begin
Asserted_Fill (Table); -- Should fill with keys in Test_Keys'Range
L := Table.Length;
Assert (Table.Value_Of (K) /= V,
"Test precondition fail: test value already bound to test key");
Table.Bind (K, V);
Assert (Table.Value_Of (K) = V,
"Value of existing key not replaced when binding to full table");
Assert (Table.Length = L, "Length has changed");
Assert (Table.Is_Full, "Table shall still be full");
end Bind_Existing_To_Full;
procedure Unbind
is
Table : T;
L : Natural;
begin
Asserted_Fill (Table);
L := Table.Length;
for K in Test_Keys'Range loop
Table.Unbind (K);
L := L - 1;
Assert (not Table.Is_Bound (K), "Key is bound after unbind");
Assert (Table.Length = L, "Length is not" & L'Img);
end loop;
Assert (Table.Is_Empty, "Table not empty");
Assert (not Table.Is_Full, "Table is full");
end Unbind;
procedure Unbind_Empty
is
Table : T;
K : constant Key_Type := 'X';
begin
Table.Unbind (K);
Assert (not Table.Is_Bound (K), "Key is bound after unbinding empty table");
Assert (Table.Length = 0, "Length not 0 after unbinding to empty table");
Assert (Table.Is_Empty, "Table not empty after unbinding to empty table");
Assert (not Table.Is_Full, "Table is full after unbinding to empty table");
end Unbind_Empty;
procedure Value_Of_Nonexisting
is
Table : T;
V : Value_Type;
K : constant Key_Type := Key_Type'Succ (Test_Keys'Last);
pragma Unreferenced (V);
begin
V := Table.Value_Of (K);
end Value_Of_Nonexisting;
procedure Run_Test (T : in out Test) is
pragma Unreferenced (T);
begin
Init_Test;
Bind;
Unbind;
Unbind_Empty;
Bind_Existing_To_Full;
Assert_Exception
(Bind_New_To_Full'Access,
"Expected an exception when binding a new key to an already full table");
Assert_Exception
(Value_Of_Nonexisting'Access,
"Expected an exception when accessing value of key not bound");
end Run_Test;
end Generic_Table_Test;
|
zhmu/ananas | Ada | 3,065 | ads | ------------------------------------------------------------------------------
-- --
-- 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 --
-- --
-- S p e c --
-- --
-- Copyright (C) 1991-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 no tasking version of this package
package System.Task_Primitives is
pragma Preelaborate;
type Lock is new Integer;
type RTS_Lock is new Integer;
type Suspension_Object is new Integer;
type Task_Body_Access is access procedure;
type Private_Data is limited record
Thread : aliased Integer;
CV : aliased Integer;
L : aliased RTS_Lock;
end record;
subtype Task_Address is System.Address;
Task_Address_Size : constant := Standard'Address_Size;
-- Type used for task addresses and its size
Alternate_Stack_Size : constant := 0;
-- No alternate signal stack is used on this platform
end System.Task_Primitives;
|
io7m/coreland-posix-ada | Ada | 52 | ads | package POSIX is
pragma Pure (POSIX);
end POSIX;
|
sungyeon/drake | Ada | 448 | ads | pragma License (Unrestricted);
-- Ada 2012
with Ada.Characters.Conversions;
with Ada.Strings.Generic_Less_Case_Insensitive;
function Ada.Strings.Wide_Wide_Less_Case_Insensitive is
new Generic_Less_Case_Insensitive (
Wide_Wide_Character,
Wide_Wide_String,
Characters.Conversions.Get);
-- pragma Pure (Ada.Strings.Wide_Wide_Less_Case_Insensitive);
pragma Preelaborate (Ada.Strings.Wide_Wide_Less_Case_Insensitive); -- use maps
|
reznikmm/matreshka | Ada | 6,442 | adb | ------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- Open Document Toolkit --
-- --
-- Runtime Library Component --
-- --
------------------------------------------------------------------------------
-- --
-- Copyright © 2013, Vadim Godunko <[email protected]> --
-- All rights reserved. --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions --
-- are met: --
-- --
-- * Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- --
-- * Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in the --
-- documentation and/or other materials provided with the distribution. --
-- --
-- * Neither the name of the Vadim Godunko, IE nor the names of its --
-- contributors may be used to endorse or promote products derived from --
-- this software without specific prior written permission. --
-- --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR --
-- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
-- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED --
-- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR --
-- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF --
-- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING --
-- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS --
-- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
-- --
------------------------------------------------------------------------------
-- $Revision$ $Date$
------------------------------------------------------------------------------
with ODF.Constants;
with ODF.DOM.Elements.Text.Linenumbering_Configuration.Internals;
with ODF.DOM.Iterators;
with ODF.DOM.Visitors;
package body Matreshka.ODF_Elements.Text.Linenumbering_Configuration is
-------------------
-- Enter_Element --
-------------------
overriding procedure Enter_Element
(Self : not null access Text_Linenumbering_Configuration_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.ODF_Visitor'Class then
ODF.DOM.Visitors.ODF_Visitor'Class
(Visitor).Enter_Text_Linenumbering_Configuration
(ODF.DOM.Elements.Text.Linenumbering_Configuration.Internals.Create
(Text_Linenumbering_Configuration_Access (Self)),
Control);
else
Matreshka.DOM_Nodes.Elements.Abstract_Element
(Self.all).Enter_Element (Visitor, Control);
end if;
end Enter_Element;
--------------------
-- Get_Local_Name --
--------------------
overriding function Get_Local_Name
(Self : not null access constant Text_Linenumbering_Configuration_Node)
return League.Strings.Universal_String is
begin
return ODF.Constants.Linenumbering_Configuration_Name;
end Get_Local_Name;
-------------------
-- Leave_Element --
-------------------
overriding procedure Leave_Element
(Self : not null access Text_Linenumbering_Configuration_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.ODF_Visitor'Class then
ODF.DOM.Visitors.ODF_Visitor'Class
(Visitor).Leave_Text_Linenumbering_Configuration
(ODF.DOM.Elements.Text.Linenumbering_Configuration.Internals.Create
(Text_Linenumbering_Configuration_Access (Self)),
Control);
else
Matreshka.DOM_Nodes.Elements.Abstract_Element
(Self.all).Leave_Element (Visitor, Control);
end if;
end Leave_Element;
-------------------
-- Visit_Element --
-------------------
overriding procedure Visit_Element
(Self : not null access Text_Linenumbering_Configuration_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.ODF_Iterator'Class then
ODF.DOM.Iterators.ODF_Iterator'Class
(Iterator).Visit_Text_Linenumbering_Configuration
(Visitor,
ODF.DOM.Elements.Text.Linenumbering_Configuration.Internals.Create
(Text_Linenumbering_Configuration_Access (Self)),
Control);
else
Matreshka.DOM_Nodes.Elements.Abstract_Element
(Self.all).Visit_Element (Iterator, Visitor, Control);
end if;
end Visit_Element;
end Matreshka.ODF_Elements.Text.Linenumbering_Configuration;
|
reznikmm/matreshka | Ada | 4,679 | adb | ------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- Open Document Toolkit --
-- --
-- Runtime Library Component --
-- --
------------------------------------------------------------------------------
-- --
-- Copyright © 2014, Vadim Godunko <[email protected]> --
-- All rights reserved. --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions --
-- are met: --
-- --
-- * Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- --
-- * Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in the --
-- documentation and/or other materials provided with the distribution. --
-- --
-- * Neither the name of the Vadim Godunko, IE nor the names of its --
-- contributors may be used to endorse or promote products derived from --
-- this software without specific prior written permission. --
-- --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR --
-- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
-- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED --
-- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR --
-- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF --
-- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING --
-- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS --
-- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
-- --
------------------------------------------------------------------------------
-- $Revision$ $Date$
------------------------------------------------------------------------------
with Matreshka.DOM_Documents;
with Matreshka.ODF_String_Constants;
with ODF.DOM.Iterators;
with ODF.DOM.Visitors;
package body Matreshka.ODF_Presentation.Style_Name_Attributes is
------------
-- Create --
------------
overriding function Create
(Parameters : not null access Matreshka.DOM_Attributes.Attribute_L2_Parameters)
return Presentation_Style_Name_Attribute_Node is
begin
return Self : Presentation_Style_Name_Attribute_Node do
Matreshka.ODF_Presentation.Constructors.Initialize
(Self'Unchecked_Access,
Parameters.Document,
Matreshka.ODF_String_Constants.Presentation_Prefix);
end return;
end Create;
--------------------
-- Get_Local_Name --
--------------------
overriding function Get_Local_Name
(Self : not null access constant Presentation_Style_Name_Attribute_Node)
return League.Strings.Universal_String
is
pragma Unreferenced (Self);
begin
return Matreshka.ODF_String_Constants.Style_Name_Attribute;
end Get_Local_Name;
begin
Matreshka.DOM_Documents.Register_Attribute
(Matreshka.ODF_String_Constants.Presentation_URI,
Matreshka.ODF_String_Constants.Style_Name_Attribute,
Presentation_Style_Name_Attribute_Node'Tag);
end Matreshka.ODF_Presentation.Style_Name_Attributes;
|
reznikmm/matreshka | Ada | 5,196 | ads | ------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- Ada Modeling Framework --
-- --
-- Runtime Library Component --
-- --
------------------------------------------------------------------------------
-- --
-- Copyright © 2011-2012, Vadim Godunko <[email protected]> --
-- All rights reserved. --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions --
-- are met: --
-- --
-- * Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- --
-- * Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in the --
-- documentation and/or other materials provided with the distribution. --
-- --
-- * Neither the name of the Vadim Godunko, IE nor the names of its --
-- contributors may be used to endorse or promote products derived from --
-- this software without specific prior written permission. --
-- --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR --
-- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
-- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED --
-- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR --
-- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF --
-- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING --
-- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS --
-- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
-- --
------------------------------------------------------------------------------
-- $Revision$ $Date$
------------------------------------------------------------------------------
-- This file is generated, don't edit it.
------------------------------------------------------------------------------
with AMF.Generic_Collections;
package AMF.UML.String_Expressions.Collections is
pragma Preelaborate;
package UML_String_Expression_Collections is
new AMF.Generic_Collections
(UML_String_Expression,
UML_String_Expression_Access);
type Set_Of_UML_String_Expression is
new UML_String_Expression_Collections.Set with null record;
Empty_Set_Of_UML_String_Expression : constant Set_Of_UML_String_Expression;
type Ordered_Set_Of_UML_String_Expression is
new UML_String_Expression_Collections.Ordered_Set with null record;
Empty_Ordered_Set_Of_UML_String_Expression : constant Ordered_Set_Of_UML_String_Expression;
type Bag_Of_UML_String_Expression is
new UML_String_Expression_Collections.Bag with null record;
Empty_Bag_Of_UML_String_Expression : constant Bag_Of_UML_String_Expression;
type Sequence_Of_UML_String_Expression is
new UML_String_Expression_Collections.Sequence with null record;
Empty_Sequence_Of_UML_String_Expression : constant Sequence_Of_UML_String_Expression;
private
Empty_Set_Of_UML_String_Expression : constant Set_Of_UML_String_Expression
:= (UML_String_Expression_Collections.Set with null record);
Empty_Ordered_Set_Of_UML_String_Expression : constant Ordered_Set_Of_UML_String_Expression
:= (UML_String_Expression_Collections.Ordered_Set with null record);
Empty_Bag_Of_UML_String_Expression : constant Bag_Of_UML_String_Expression
:= (UML_String_Expression_Collections.Bag with null record);
Empty_Sequence_Of_UML_String_Expression : constant Sequence_Of_UML_String_Expression
:= (UML_String_Expression_Collections.Sequence with null record);
end AMF.UML.String_Expressions.Collections;
|
MinimSecure/unum-sdk | Ada | 848 | adb | -- Copyright 2012-2016 Free Software Foundation, Inc.
--
-- This program is free software; you can redistribute it and/or modify
-- it under the terms of the GNU General Public License as published by
-- the Free Software Foundation; either version 3 of the License, or
-- (at your option) any later version.
--
-- This program is distributed in the hope that it will be useful,
-- but WITHOUT ANY WARRANTY; without even the implied warranty of
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-- GNU General Public License for more details.
--
-- You should have received a copy of the GNU General Public License
-- along with this program. If not, see <http://www.gnu.org/licenses/>.
with Pck; use Pck;
procedure P is
A : Action;
begin
A := Get_Action;
if A = Archive then
Archive;
end if;
end P;
|
ekoeppen/STM32_Generic_Ada_Drivers | Ada | 4,392 | ads | -- This spec has been automatically generated from STM32F0xx.svd
pragma Restrictions (No_Elaboration_Code);
pragma Ada_2012;
pragma Style_Checks (Off);
with System;
package STM32_SVD.COMP is
pragma Preelaborate;
---------------
-- Registers --
---------------
subtype CSR_COMP1EN_Field is STM32_SVD.Bit;
subtype CSR_COMP1_INP_DAC_Field is STM32_SVD.Bit;
subtype CSR_COMP1MODE_Field is STM32_SVD.UInt2;
subtype CSR_COMP1INSEL_Field is STM32_SVD.UInt3;
subtype CSR_COMP1OUTSEL_Field is STM32_SVD.UInt3;
subtype CSR_COMP1POL_Field is STM32_SVD.Bit;
subtype CSR_COMP1HYST_Field is STM32_SVD.UInt2;
subtype CSR_COMP1OUT_Field is STM32_SVD.Bit;
subtype CSR_COMP1LOCK_Field is STM32_SVD.Bit;
subtype CSR_COMP2EN_Field is STM32_SVD.Bit;
subtype CSR_COMP2MODE_Field is STM32_SVD.UInt2;
subtype CSR_COMP2INSEL_Field is STM32_SVD.UInt3;
subtype CSR_WNDWEN_Field is STM32_SVD.Bit;
subtype CSR_COMP2OUTSEL_Field is STM32_SVD.UInt3;
subtype CSR_COMP2POL_Field is STM32_SVD.Bit;
subtype CSR_COMP2HYST_Field is STM32_SVD.UInt2;
subtype CSR_COMP2OUT_Field is STM32_SVD.Bit;
subtype CSR_COMP2LOCK_Field is STM32_SVD.Bit;
-- control and status register
type CSR_Register is record
-- Comparator 1 enable
COMP1EN : CSR_COMP1EN_Field := 16#0#;
-- COMP1_INP_DAC
COMP1_INP_DAC : CSR_COMP1_INP_DAC_Field := 16#0#;
-- Comparator 1 mode
COMP1MODE : CSR_COMP1MODE_Field := 16#0#;
-- Comparator 1 inverting input selection
COMP1INSEL : CSR_COMP1INSEL_Field := 16#0#;
-- unspecified
Reserved_7_7 : STM32_SVD.Bit := 16#0#;
-- Comparator 1 output selection
COMP1OUTSEL : CSR_COMP1OUTSEL_Field := 16#0#;
-- Comparator 1 output polarity
COMP1POL : CSR_COMP1POL_Field := 16#0#;
-- Comparator 1 hysteresis
COMP1HYST : CSR_COMP1HYST_Field := 16#0#;
-- Read-only. Comparator 1 output
COMP1OUT : CSR_COMP1OUT_Field := 16#0#;
-- Comparator 1 lock
COMP1LOCK : CSR_COMP1LOCK_Field := 16#0#;
-- Comparator 2 enable
COMP2EN : CSR_COMP2EN_Field := 16#0#;
-- unspecified
Reserved_17_17 : STM32_SVD.Bit := 16#0#;
-- Comparator 2 mode
COMP2MODE : CSR_COMP2MODE_Field := 16#0#;
-- Comparator 2 inverting input selection
COMP2INSEL : CSR_COMP2INSEL_Field := 16#0#;
-- Window mode enable
WNDWEN : CSR_WNDWEN_Field := 16#0#;
-- Comparator 2 output selection
COMP2OUTSEL : CSR_COMP2OUTSEL_Field := 16#0#;
-- Comparator 2 output polarity
COMP2POL : CSR_COMP2POL_Field := 16#0#;
-- Comparator 2 hysteresis
COMP2HYST : CSR_COMP2HYST_Field := 16#0#;
-- Read-only. Comparator 2 output
COMP2OUT : CSR_COMP2OUT_Field := 16#0#;
-- Comparator 2 lock
COMP2LOCK : CSR_COMP2LOCK_Field := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for CSR_Register use record
COMP1EN at 0 range 0 .. 0;
COMP1_INP_DAC at 0 range 1 .. 1;
COMP1MODE at 0 range 2 .. 3;
COMP1INSEL at 0 range 4 .. 6;
Reserved_7_7 at 0 range 7 .. 7;
COMP1OUTSEL at 0 range 8 .. 10;
COMP1POL at 0 range 11 .. 11;
COMP1HYST at 0 range 12 .. 13;
COMP1OUT at 0 range 14 .. 14;
COMP1LOCK at 0 range 15 .. 15;
COMP2EN at 0 range 16 .. 16;
Reserved_17_17 at 0 range 17 .. 17;
COMP2MODE at 0 range 18 .. 19;
COMP2INSEL at 0 range 20 .. 22;
WNDWEN at 0 range 23 .. 23;
COMP2OUTSEL at 0 range 24 .. 26;
COMP2POL at 0 range 27 .. 27;
COMP2HYST at 0 range 28 .. 29;
COMP2OUT at 0 range 30 .. 30;
COMP2LOCK at 0 range 31 .. 31;
end record;
-----------------
-- Peripherals --
-----------------
-- Comparator
type COMP_Peripheral is record
-- control and status register
CSR : aliased CSR_Register;
end record
with Volatile;
for COMP_Peripheral use record
CSR at 0 range 0 .. 31;
end record;
-- Comparator
COMP_Periph : aliased COMP_Peripheral
with Import, Address => System'To_Address (16#4001001C#);
end STM32_SVD.COMP;
|
alvaromb/Compilemon | Ada | 1,902 | ads | -- DECLS-DTDESC.ads
-- Declaracions de descripcio
with Decls.Dgenerals,
Decls.D_Taula_De_Noms;
use Decls.Dgenerals,
Decls.D_Taula_De_Noms;
package Decls.Dtdesc is
--pragma pure;
-- Representa tambit
Max_Nprof : constant Integer := 25;
type Nprof is new Integer
range -1 .. Max_Nprof;
Nul_Nprof : constant Nprof := 0;
No_Prof : constant Nprof := -1;
type Despl is new Integer;
-- Representa texpansio
type Rang_Despl is new Integer
range 0 .. (Max_Id * Max_Nprof);
Nul_Despl : constant Rang_Despl := 0;
type Tdescrip is
(Dnula,
Dconst,
Dvar,
Dtipus,
Dproc,
Dcamp,
Dargc);
type Tipussubjacent is
(Tsbool,
Tscar,
Tsstr,
Tsent,
Tsrec,
Tsarr,
Tsnul);
type Descriptipus (Tt: Tipussubjacent := Tsnul) is
record
Ocup : Despl;
case Tt is
when Tsbool | Tscar | Tsent =>
Linf, Lsup : Valor;
when Tsarr | Tsstr => Tcamp : Id_Nom;
Base : Valor;
when Tsrec | Tsnul => null;
end case;
end record;
type Descrip (Td : Tdescrip := Dnula) is
record
case Td is
when Dnula => null;
when Dtipus => Dt : Descriptipus;
when Dvar => Tr : Id_Nom;
Nv : Num_Var;
when Dproc => Np : Num_Proc;
when Dconst => Tc : Id_Nom;
Vc : Valor;
Nvc : Num_Var;
when Dargc => Nvarg : Num_Var;
Targ : Id_Nom;
when Dcamp => Tcamp : Id_Nom;
Dsp : Despl;
end case;
end record;
end Decls.Dtdesc;
|
io7m/coreland-posix-ada | Ada | 7,402 | adb | with C_String;
with Interfaces.C;
with POSIX.C_Types;
with System;
package body POSIX.User_DB is
subtype C_Passwd_Return_Type_t is C_Types.Int_t range 0 .. 2;
Passwd_Result_OK : constant C_Passwd_Return_Type_t := 0;
Passwd_Result_No_User : constant C_Passwd_Return_Type_t := 1;
Passwd_Result_Error : constant C_Passwd_Return_Type_t := 2;
procedure C_Get_Entry_By_Name_Boundary
(User_Name : in String;
Database_Entry : out Database_Entry_t;
Return_Value : out C_Passwd_Return_Type_t)
--# global in Errno.Errno_Value;
--# derives Database_Entry, Return_Value from User_Name, Errno.Errno_Value;
--# post
--# ((Return_Value = Passwd_Result_Error) and
--# (Error.Get_Error (Errno.Errno_Value) = Error.Error_None))
--# or
--# ((Return_Value /= Passwd_Result_Error) and
--# (Error.Get_Error (Errno.Errno_Value) /= Error.Error_None));
is
--# hide C_Get_Entry_By_Name_Boundary
function C_posix_getpwnam
(User_Name : in C_String.String_Not_Null_Ptr_t;
Database_Entry : in System.Address) return C_Passwd_Return_Type_t;
pragma Import (C, C_posix_getpwnam, "posix_getpwnam");
begin
declare
C_User_Name_Buffer : aliased Interfaces.C.char_array :=
Interfaces.C.To_C (User_Name, Append_Nul => True);
begin
Return_Value := C_posix_getpwnam
(User_Name => C_String.To_C_String (C_User_Name_Buffer'Unchecked_Access),
Database_Entry => Database_Entry.C_Data (Database_Entry.C_Data'First)'Address);
end;
exception
-- Do not propagate exceptions.
when Storage_Error =>
Error.Set_Error (Error.Error_Out_Of_Memory);
Return_Value := Passwd_Result_Error;
when others =>
Error.Set_Error (Error.Error_Unknown);
Return_Value := Passwd_Result_Error;
end C_Get_Entry_By_Name_Boundary;
procedure Get_Entry_By_Name
(User_Name : in String;
Database_Entry : out Database_Entry_t;
Found_Entry : out Boolean;
Error_Value : out Error.Error_t)
is
Returned_Value : C_Passwd_Return_Type_t;
begin
C_Get_Entry_By_Name_Boundary
(User_Name => User_Name,
Database_Entry => Database_Entry,
Return_Value => Returned_Value);
case Returned_Value is
when Passwd_Result_OK =>
Found_Entry := True;
Database_Entry.Valid := True;
Error_Value := Error.Error_None;
when Passwd_Result_Error =>
Found_Entry := False;
Database_Entry.Valid := False;
Error_Value := Error.Get_Error;
when Passwd_Result_No_User =>
Found_Entry := False;
Database_Entry.Valid := False;
Error_Value := Error.Error_None;
end case;
end Get_Entry_By_Name;
--
-- Accessor subprograms.
--
function Is_Valid (Database_Entry : in Database_Entry_t) return Boolean is
begin
return Database_Entry.Valid;
end Is_Valid;
function C_Get_User_ID (Database_Entry : in Database_Entry_t) return User_ID_t is
--# hide C_Get_User_ID
function C_posix_passwd_get_uid (Database_Entry : System.Address) return User_ID_t;
pragma Import (C, C_posix_passwd_get_uid, "posix_passwd_get_uid");
begin
return C_posix_passwd_get_uid
(Database_Entry.C_Data (Database_Entry.C_Data'First)'Address);
end C_Get_User_ID;
function Get_User_ID (Database_Entry : in Database_Entry_t) return User_ID_t is
begin
return C_Get_User_ID (Database_Entry);
end Get_User_ID;
function C_Get_Group_ID (Database_Entry : in Database_Entry_t) return Group_ID_t is
--# hide C_Get_Group_ID
function C_posix_passwd_get_gid (Database_Entry : System.Address) return Group_ID_t;
pragma Import (C, C_posix_passwd_get_gid, "posix_passwd_get_gid");
begin
return C_posix_passwd_get_gid
(Database_Entry.C_Data (Database_Entry.C_Data'First)'Address);
end C_Get_Group_ID;
function Get_Group_ID (Database_Entry : in Database_Entry_t) return Group_ID_t is
begin
return C_Get_Group_ID (Database_Entry);
end Get_Group_ID;
procedure C_Get_User_Name
(Database_Entry : in Database_Entry_t;
User_Name : out User_Name_t;
Last_Index : out User_Name_Index_t)
--# derives User_Name, Last_Index from Database_Entry;
is
--# hide C_Get_User_Name
procedure C_posix_passwd_get_pw_name
(Database_Entry : in System.Address;
User_Name : in System.Address;
Last_Index : out User_Name_Index_t);
pragma Import (C, C_posix_passwd_get_pw_name, "posix_passwd_get_pw_name");
begin
C_posix_passwd_get_pw_name
(Database_Entry => Database_Entry.C_Data (Database_Entry.C_Data'First)'Address,
User_Name => User_Name (User_Name'First)'Address,
Last_Index => Last_Index);
end C_Get_User_Name;
procedure Get_User_Name
(Database_Entry : in Database_Entry_t;
User_Name : out User_Name_t;
Last_Index : out User_Name_Index_t) is
begin
C_Get_User_Name
(Database_Entry => Database_Entry,
User_Name => User_Name,
Last_Index => Last_Index);
end Get_User_Name;
procedure C_Get_Home_Directory
(Database_Entry : in Database_Entry_t;
Home_Directory : out Home_Directory_t;
Last_Index : out Home_Directory_Index_t)
--# derives Home_Directory, Last_Index from Database_Entry;
is
--# hide C_Get_Home_Directory
procedure C_posix_passwd_get_pw_dir
(Database_Entry : in System.Address;
Home_Directory : in System.Address;
Last_Index : out Home_Directory_Index_t);
pragma Import (C, C_posix_passwd_get_pw_dir, "posix_passwd_get_pw_dir");
begin
C_posix_passwd_get_pw_dir
(Database_Entry => Database_Entry.C_Data (Database_Entry.C_Data'First)'Address,
Home_Directory => Home_Directory (Home_Directory'First)'Address,
Last_Index => Last_Index);
end C_Get_Home_Directory;
procedure Get_Home_Directory
(Database_Entry : in Database_Entry_t;
Home_Directory : out Home_Directory_t;
Last_Index : out Home_Directory_Index_t) is
begin
C_Get_Home_Directory
(Database_Entry => Database_Entry,
Home_Directory => Home_Directory,
Last_Index => Last_Index);
end Get_Home_Directory;
procedure C_Get_Shell
(Database_Entry : in Database_Entry_t;
Shell_Path : out Shell_Path_t;
Last_Index : out Shell_Path_Index_t)
--# derives Shell_Path, Last_Index from Database_Entry;
is
--# hide C_Get_Shell
procedure C_posix_passwd_get_pw_shell
(Database_Entry : in System.Address;
Shell_Path : in System.Address;
Last_Index : out Shell_Path_Index_t);
pragma Import (C, C_posix_passwd_get_pw_shell, "posix_passwd_get_pw_shell");
begin
C_posix_passwd_get_pw_shell
(Database_Entry => Database_Entry.C_Data (Database_Entry.C_Data'First)'Address,
Shell_Path => Shell_Path (Shell_Path'First)'Address,
Last_Index => Last_Index);
end C_Get_Shell;
procedure Get_Shell
(Database_Entry : in Database_Entry_t;
Shell_Path : out Shell_Path_t;
Last_Index : out Shell_Path_Index_t) is
begin
C_Get_Shell
(Database_Entry => Database_Entry,
Shell_Path => Shell_Path,
Last_Index => Last_Index);
end Get_Shell;
end POSIX.User_DB;
|
reznikmm/matreshka | Ada | 4,672 | 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_Chart.Three_Dimensional_Attributes is
------------
-- Create --
------------
overriding function Create
(Parameters : not null access Matreshka.DOM_Attributes.Attribute_L2_Parameters)
return Chart_Three_Dimensional_Attribute_Node is
begin
return Self : Chart_Three_Dimensional_Attribute_Node do
Matreshka.ODF_Chart.Constructors.Initialize
(Self'Unchecked_Access,
Parameters.Document,
Matreshka.ODF_String_Constants.Chart_Prefix);
end return;
end Create;
--------------------
-- Get_Local_Name --
--------------------
overriding function Get_Local_Name
(Self : not null access constant Chart_Three_Dimensional_Attribute_Node)
return League.Strings.Universal_String
is
pragma Unreferenced (Self);
begin
return Matreshka.ODF_String_Constants.Three_Dimensional_Attribute;
end Get_Local_Name;
begin
Matreshka.DOM_Documents.Register_Attribute
(Matreshka.ODF_String_Constants.Chart_URI,
Matreshka.ODF_String_Constants.Three_Dimensional_Attribute,
Chart_Three_Dimensional_Attribute_Node'Tag);
end Matreshka.ODF_Chart.Three_Dimensional_Attributes;
|
reznikmm/matreshka | Ada | 3,694 | 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_Method_Attributes is
pragma Preelaborate;
type ODF_Form_Method_Attribute is limited interface
and XML.DOM.Attributes.DOM_Attribute;
type ODF_Form_Method_Attribute_Access is
access all ODF_Form_Method_Attribute'Class
with Storage_Size => 0;
end ODF.DOM.Form_Method_Attributes;
|
reznikmm/matreshka | Ada | 5,130 | ads | ------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- Ada Modeling Framework --
-- --
-- Runtime Library Component --
-- --
------------------------------------------------------------------------------
-- --
-- Copyright © 2011-2012, Vadim Godunko <[email protected]> --
-- All rights reserved. --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions --
-- are met: --
-- --
-- * Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- --
-- * Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in the --
-- documentation and/or other materials provided with the distribution. --
-- --
-- * Neither the name of the Vadim Godunko, IE nor the names of its --
-- contributors may be used to endorse or promote products derived from --
-- this software without specific prior written permission. --
-- --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR --
-- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
-- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED --
-- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR --
-- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF --
-- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING --
-- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS --
-- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
-- --
------------------------------------------------------------------------------
-- $Revision$ $Date$
------------------------------------------------------------------------------
-- This file is generated, don't edit it.
------------------------------------------------------------------------------
with AMF.Generic_Collections;
package AMF.UML.Time_Expressions.Collections is
pragma Preelaborate;
package UML_Time_Expression_Collections is
new AMF.Generic_Collections
(UML_Time_Expression,
UML_Time_Expression_Access);
type Set_Of_UML_Time_Expression is
new UML_Time_Expression_Collections.Set with null record;
Empty_Set_Of_UML_Time_Expression : constant Set_Of_UML_Time_Expression;
type Ordered_Set_Of_UML_Time_Expression is
new UML_Time_Expression_Collections.Ordered_Set with null record;
Empty_Ordered_Set_Of_UML_Time_Expression : constant Ordered_Set_Of_UML_Time_Expression;
type Bag_Of_UML_Time_Expression is
new UML_Time_Expression_Collections.Bag with null record;
Empty_Bag_Of_UML_Time_Expression : constant Bag_Of_UML_Time_Expression;
type Sequence_Of_UML_Time_Expression is
new UML_Time_Expression_Collections.Sequence with null record;
Empty_Sequence_Of_UML_Time_Expression : constant Sequence_Of_UML_Time_Expression;
private
Empty_Set_Of_UML_Time_Expression : constant Set_Of_UML_Time_Expression
:= (UML_Time_Expression_Collections.Set with null record);
Empty_Ordered_Set_Of_UML_Time_Expression : constant Ordered_Set_Of_UML_Time_Expression
:= (UML_Time_Expression_Collections.Ordered_Set with null record);
Empty_Bag_Of_UML_Time_Expression : constant Bag_Of_UML_Time_Expression
:= (UML_Time_Expression_Collections.Bag with null record);
Empty_Sequence_Of_UML_Time_Expression : constant Sequence_Of_UML_Time_Expression
:= (UML_Time_Expression_Collections.Sequence with null record);
end AMF.UML.Time_Expressions.Collections;
|
zhmu/ananas | Ada | 132 | ads | package Array18_Pkg is
function N return Positive;
subtype S is String (1 .. N);
function F return S;
end Array18_Pkg;
|
stcarrez/ada-keystore | Ada | 2,745 | ads | -----------------------------------------------------------------------
-- akt-commands-otp -- One-time-password generation with otpauth
-- Copyright (C) 2023 Stephane Carrez
-- Written by Stephane Carrez ([email protected])
--
-- Licensed under the Apache License, Version 2.0 (the "License");
-- you may not use this file except in compliance with the License.
-- You may obtain a copy of the License at
--
-- http://www.apache.org/licenses/LICENSE-2.0
--
-- Unless required by applicable law or agreed to in writing, software
-- distributed under the License is distributed on an "AS IS" BASIS,
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-- See the License for the specific language governing permissions and
-- limitations under the License.
-----------------------------------------------------------------------
with AKT.Commands.Drivers;
private with Util.Strings.Vectors;
private package AKT.Commands.OTP is
type Command_Type is new AKT.Commands.Drivers.Command_Type with private;
-- Store the otpauth secret or generate the OTP code.
overriding
procedure Execute (Command : in out Command_Type;
Name : in String;
Args : in Argument_List'Class;
Context : in out Context_Type);
-- Setup the command before parsing the arguments and executing it.
overriding
procedure Setup (Command : in out Command_Type;
Config : in out GNAT.Command_Line.Command_Line_Configuration;
Context : in out Context_Type);
private
type Command_Type is new AKT.Commands.Drivers.Command_Type with record
Remove : aliased Boolean := False;
Force : aliased Boolean := False;
Interactive : aliased Boolean := False;
end record;
-- Register or update an otpauth URI.
procedure Register (Command : in out Command_Type;
URI : in String;
Context : in out Context_Type);
-- Generate to OTP code for the selected account.
procedure Generate (Command : in out Command_Type;
Account : in String;
Context : in out Context_Type);
-- List the OTP authorizations that are registered.
procedure List (Command : in out Command_Type;
Context : in out Context_Type);
procedure Interactive (Command : in out Command_Type;
Context : in out Context_Type);
-- Collect the list of OTP definitions in the keystore.
procedure Collect_List (Context : in out Context_Type;
Into : in out Util.Strings.Vectors.Vector);
end AKT.Commands.OTP;
|
AdaCore/gpr | Ada | 54,490 | adb |
--
-- Copyright (C) 2019-2023, AdaCore
-- SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
--
pragma Warnings (Off, "internal");
with Ada.Strings.Wide_Wide_Unbounded.Aux;
pragma Warnings (On, "internal");
with GNATCOLL.Iconv;
with Gpr_Parser_Support.Token_Data_Handlers;
use Gpr_Parser_Support.Token_Data_Handlers;
with Gpr_Parser.Common; use Gpr_Parser.Common;
with Gpr_Parser.Implementation; use Gpr_Parser.Implementation;
with Gpr_Parser.Private_Converters;
use Gpr_Parser.Private_Converters;
package body Gpr_Parser.Unparsing_Implementation is
subtype String_Access is Ada.Strings.Unbounded.String_Access;
-- The "template" data structures below are helpers for the original
-- source code formatting preservation algorithms. A template can be
-- thought as the instantiation of an unparser from an original AST node.
-- It captures actual sequences of tokens.
type Token_Sequence_Template (Present : Boolean := False) is record
case Present is
when False => null;
when True =>
First, Last : Token_Reference;
end case;
end record;
-- Captured sequence of tokens
subtype Present_Token_Sequence_Template is Token_Sequence_Template (True);
Empty_Token_Sequence_Template : constant Present_Token_Sequence_Template :=
(Present => True, First => No_Token, Last => No_Token);
function Create_Token_Sequence
(Unparser : Token_Sequence_Access;
First_Token : in out Token_Reference)
return Present_Token_Sequence_Template
with Pre => First_Token /= No_Token;
-- Create a present sequence of tokens starting from First_Token and
-- containing the same number of tokens as indicated in Unparser. Before
-- returning, this updates First_Token to point at the first token that
-- appear after the sequence.
type Token_Sequence_Template_Array is
array (Positive range <>) of Present_Token_Sequence_Template;
type Field_Template (Present : Boolean := False) is record
case Present is
when False => null;
when True =>
Pre_Tokens, Post_Tokens : Token_Sequence_Template (Present);
end case;
end record;
-- Captured sequences of tokens before and after a node field. This is the
-- instantiation of Field_Unparser.
type Field_Template_Array is array (Positive range <>) of Field_Template;
type Regular_Node_Template (Present : Boolean; Count : Natural) is record
case Present is
when False => null;
when True =>
Pre_Tokens : Present_Token_Sequence_Template;
Fields : Field_Template_Array (1 .. Count);
Inter_Tokens : Token_Sequence_Template_Array (1 .. Count);
Post_Tokens : Present_Token_Sequence_Template;
end case;
end record;
-- Captured sequences of tokens corresponding to a regular node. This is
-- the instantiation of Regular_Node_Unparser.
function Extract_Regular_Node_Template
(Unparser : Regular_Node_Unparser;
Rewritten_Node : Bare_Gpr_Node) return Regular_Node_Template;
-- Return the regular node template corresponding to the instatiation of
-- Rewritten_Node according to Unparser.
--
-- This is an absent template if Rewritten_Node is null. Likewise, returned
-- field templates are absent if the corresponding Rewritten_Node children
-- are absent.
function Field_Present
(Node : Abstract_Node;
Unparser : Field_Unparser) return Boolean;
-- Return whether the given field is to be considered present according to
-- the given field unparser.
procedure Update_Sloc
(Sloc : in out Source_Location; Char : Wide_Wide_Character);
-- Update Sloc as if it represented a cursor that move right-wards after
-- inserting Char to a buffer.
procedure Unparse_Node
(Node : Abstract_Node;
Preserve_Formatting : Boolean;
Result : in out Unparsing_Buffer);
-- Using the Node_Unparsers unparsing tables, unparse the given Node
procedure Unparse_Regular_Node
(Node : Abstract_Node;
Unparser : Regular_Node_Unparser;
Rewritten_Node : Bare_Gpr_Node;
Preserve_Formatting : Boolean;
Result : in out Unparsing_Buffer);
-- Helper for Unparse_Node, focuses on regular nodes
procedure Unparse_List_Node
(Node : Abstract_Node;
Unparser : List_Node_Unparser;
Rewritten_Node : Bare_Gpr_Node;
Preserve_Formatting : Boolean;
Result : in out Unparsing_Buffer);
-- Helper for Unparse_Node, focuses on list nodes
procedure Unparse_Token
(Unparser : Token_Unparser;
Result : in out Unparsing_Buffer);
-- Using the Unparser unparsing table, unparse a token
procedure Unparse_Token_Sequence
(Unparser : Token_Sequence_Access;
Result : in out Unparsing_Buffer);
-- Using the Unparser unparsing table, unparse a sequence of tokens
function Relative_Token
(Token : Token_Reference; Offset : Integer) return Token_Reference with
Pre => Token /= No_Token
and then not Is_Trivia (Token)
and then
Token_Index (Integer (Get_Token_Index (Token).Token) + Offset)
in First_Token_Index .. Last_Token (Get_Token_TDH (Token).all),
Post => Relative_Token'Result /= No_Token;
-- Considering only tokens that are not trivia and assuming Token is at
-- index I, return the token that is at index I + Offset.
function Last_Trivia (Token : Token_Reference) return Token_Reference
with Pre => Token /= No_Token;
-- If Token (which can be a token or a trivia) is followed by a sequence of
-- trivias, return the last of them. Otherwise, return Token itself.
procedure Append_Tokens
(Result : in out Unparsing_Buffer;
First_Token, Last_Token : Token_Reference;
With_Trailing_Trivia : Boolean := True);
-- Emit to Result the sequence of tokens from First_Token to Last_Token.
-- Trivias that appear between tokens in the sequence to emit are emitted
-- as well. If With_Trailing_Trivia is true, also emit the sequence of
-- trivia that follows Last_Token.
procedure Append_Tokens
(Result : in out Unparsing_Buffer;
Template : Token_Sequence_Template);
-- Emit to Result the sequence of tokens in Template, or do nothing if the
-- template is absent.
Token_Spacing_Table : array (Token_Family, Token_Family) of Boolean :=
(Common.Alphanumericals => (Common.Alphanumericals => True, Common.Default_Family => False), Common.Default_Family => (Common.Alphanumericals => False, Common.Default_Family => False));
-- A space must be inserted between two consecutive tokens T1 and T2 iff
-- given their respective families TF1 and TF2, the following is true:
-- Token_Spacing_Table (TF1, TF2).
Token_Newline_Table : array (Token_Kind) of Boolean :=
(Common.Gpr_Termination => False, Common.Gpr_Lexing_Failure => False, Common.Gpr_Identifier => False, Common.Gpr_All => False, Common.Gpr_Abstract => False, Common.Gpr_At => False, Common.Gpr_Case => False, Common.Gpr_End => False, Common.Gpr_For => False, Common.Gpr_Is => False, Common.Gpr_Limited => False, Common.Gpr_Private => False, Common.Gpr_Null => False, Common.Gpr_Others => False, Common.Gpr_Package => False, Common.Gpr_Renames => False, Common.Gpr_Type => False, Common.Gpr_Use => False, Common.Gpr_Pragma => False, Common.Gpr_When => False, Common.Gpr_With => False, Common.Gpr_Extends => False, Common.Gpr_Par_Open => False, Common.Gpr_Par_Close => False, Common.Gpr_Semicolon => False, Common.Gpr_Colon => False, Common.Gpr_Comma => False, Common.Gpr_Dot => False, Common.Gpr_Amp => False, Common.Gpr_Tick => False, Common.Gpr_Pipe => False, Common.Gpr_Assign => False, Common.Gpr_Arrow => False, Common.Gpr_String => False, Common.Gpr_Number => False, Common.Gpr_Label => False, Common.Gpr_Char => False, Common.Gpr_Comment => True, Common.Gpr_Whitespace => False);
-- A line break must be append during unparsing after a token T iff
-- Token_Newline_Table (T) is true.
--------------------------
-- Create_Abstract_Node --
--------------------------
function Create_Abstract_Node
(Parsing_Node : Bare_Gpr_Node) return Abstract_Node is
begin
return (From_Parsing, Parsing_Node);
end Create_Abstract_Node;
--------------------------
-- Create_Abstract_Node --
--------------------------
function Create_Abstract_Node
(Rewriting_Node : Node_Rewriting_Handle) return Abstract_Node is
begin
return (From_Rewriting, Rewriting_Node);
end Create_Abstract_Node;
-------------
-- Is_Null --
-------------
function Is_Null (Node : Abstract_Node) return Boolean is
begin
case Node.Kind is
when From_Parsing =>
return Node.Parsing_Node = null;
when From_Rewriting =>
return Node.Rewriting_Node = null;
end case;
end Is_Null;
----------
-- Kind --
----------
function Kind (Node : Abstract_Node) return Gpr_Node_Kind_Type is
begin
case Node.Kind is
when From_Parsing =>
return Node.Parsing_Node.Kind;
when From_Rewriting =>
return Node.Rewriting_Node.Kind;
end case;
end Kind;
--------------------
-- Children_Count --
--------------------
function Children_Count (Node : Abstract_Node) return Natural is
begin
case Node.Kind is
when From_Parsing =>
return Children_Count (Node.Parsing_Node);
when From_Rewriting =>
return Children_Count (Node.Rewriting_Node);
end case;
end Children_Count;
-----------
-- Child --
-----------
function Child
(Node : Abstract_Node; Index : Positive) return Abstract_Node is
begin
case Node.Kind is
when From_Parsing =>
return Create_Abstract_Node (Child (Node.Parsing_Node, Index));
when From_Rewriting =>
-- In the context of unparsing, it is pointless to expand the
-- rewritting tree (which is what Rewriting_Implementation.Child
-- does). If the node is not expanded, switch to the original
-- node instead.
declare
RN : constant Node_Rewriting_Handle := Node.Rewriting_Node;
begin
if RN.Children.Kind = Unexpanded then
return Create_Abstract_Node (Child (RN.Node, Index));
else
return Create_Abstract_Node
(RN.Children.Vector.Element (Index));
end if;
end;
end case;
end Child;
----------
-- Text --
----------
function Text (Node : Abstract_Node) return Text_Type is
begin
case Node.Kind is
when From_Parsing =>
return Text (Node.Parsing_Node);
when From_Rewriting =>
return Text (Node.Rewriting_Node);
end case;
end Text;
--------------------
-- Rewritten_Node --
--------------------
function Rewritten_Node
(Node : Abstract_Node) return Bare_Gpr_Node is
begin
case Node.Kind is
when From_Parsing =>
return Node.Parsing_Node;
when From_Rewriting =>
return Node.Rewriting_Node.Node;
end case;
end Rewritten_Node;
---------------------------
-- Create_Token_Sequence --
---------------------------
function Create_Token_Sequence
(Unparser : Token_Sequence_Access;
First_Token : in out Token_Reference)
return Present_Token_Sequence_Template
is
Result : Present_Token_Sequence_Template;
begin
if Unparser'Length = 0 then
return (Present => True, First => No_Token, Last => No_Token);
else
Result.First := First_Token;
Result.Last := Relative_Token (First_Token, Unparser'Length - 1);
First_Token := Relative_Token (Result.Last, 1);
return Result;
end if;
end Create_Token_Sequence;
-----------------------------------
-- Extract_Regular_Node_Template --
-----------------------------------
function Extract_Regular_Node_Template
(Unparser : Regular_Node_Unparser;
Rewritten_Node : Bare_Gpr_Node) return Regular_Node_Template
is
Result : Regular_Node_Template (True, Unparser.Field_Unparsers.N);
Next_Token : Token_Reference;
begin
if Rewritten_Node = null then
return (Present => False, Count => 0);
end if;
Next_Token := Token_Start (Rewritten_Node);
-- Recover tokens that precede the first field from the rewritten node
Result.Pre_Tokens := Create_Token_Sequence
(Unparser.Pre_Tokens, Next_Token);
-- For each field, recover the tokens that surround the field itself,
-- but only if both the original node and the one to unparse are
-- present.
for I in 1 .. Children_Count (Rewritten_Node) loop
declare
U : Field_Unparser_List renames Unparser.Field_Unparsers.all;
F : Field_Unparser renames U.Field_Unparsers (I);
T : Token_Sequence_Access renames U.Inter_Tokens (I);
FT : Field_Template renames Result.Fields (I);
Rewritten_Child : constant Bare_Gpr_Node :=
Child (Rewritten_Node, I);
R_Child : constant Abstract_Node :=
Create_Abstract_Node (Rewritten_Child);
begin
Result.Inter_Tokens (I) :=
(if I = 1
then Empty_Token_Sequence_Template
else Create_Token_Sequence (T, Next_Token));
if Field_Present (R_Child, F) then
FT := (Present => True, others => <>);
-- Pre_Tokens is the sequence that starts at Next_Token and
-- whose length is the one the unparser gives.
FT.Pre_Tokens :=
Create_Token_Sequence (F.Pre_Tokens, Next_Token);
-- Post_Tokens is the sequence that starts right after the last
-- token of the node field, also sized from the unparser.
-- Beware of ghost nodes, which own no token.
Next_Token :=
(if Is_Ghost (Rewritten_Child)
then Token_Start (Rewritten_Child)
else Relative_Token (Token_End (Rewritten_Child), 1));
FT.Post_Tokens :=
Create_Token_Sequence (F.Post_Tokens, Next_Token);
else
FT := (Present => False);
end if;
end;
end loop;
-- Recover tokens that succeed to the first field from the rewritten
-- node.
Result.Post_Tokens :=
Create_Token_Sequence (Unparser.Post_Tokens, Next_Token);
return Result;
end Extract_Regular_Node_Template;
-------------------
-- Field_Present --
-------------------
function Field_Present
(Node : Abstract_Node;
Unparser : Field_Unparser) return Boolean is
begin
return (not Is_Null (Node)
and then (not Unparser.Empty_List_Is_Absent
or else Children_Count (Node) > 0));
end Field_Present;
-----------------
-- Update_Sloc --
-----------------
procedure Update_Sloc
(Sloc : in out Source_Location; Char : Wide_Wide_Character) is
begin
-- TODO??? Handle tabs
if Wide_Wide_Character'Pos (Char) = Character'Pos (ASCII.LF) then
Sloc.Line := Sloc.Line + 1;
Sloc.Column := 1;
else
Sloc.Column := Sloc.Column + 1;
end if;
end Update_Sloc;
------------
-- Append --
------------
procedure Append
(Buffer : in out Unparsing_Buffer; Char : Wide_Wide_Character) is
begin
Update_Sloc (Buffer.Last_Sloc, Char);
Append (Buffer.Content, Char);
end Append;
------------
-- Append --
------------
procedure Append
(Buffer : in out Unparsing_Buffer;
Kind : Token_Kind;
Text : Text_Type) is
begin
for C of Text loop
Update_Sloc (Buffer.Last_Sloc, C);
end loop;
Append (Buffer.Content, Text);
Buffer.Last_Token := Kind;
end Append;
-------------------------
-- Apply_Spacing_Rules --
-------------------------
procedure Apply_Spacing_Rules
(Buffer : in out Unparsing_Buffer;
Next_Token : Token_Kind) is
begin
if Length (Buffer.Content) = 0 then
null;
elsif Token_Newline_Table (Buffer.Last_Token) then
Append (Buffer, Chars.LF);
elsif Token_Spacing_Table
(Token_Kind_To_Family (Buffer.Last_Token),
Token_Kind_To_Family (Next_Token))
then
Append (Buffer, ' ');
end if;
end Apply_Spacing_Rules;
-------------
-- Unparse --
-------------
procedure Unparse
(Node : Abstract_Node;
Unit : Internal_Unit;
Preserve_Formatting : Boolean;
As_Unit : Boolean;
Result : out Unparsing_Buffer) is
begin
-- Unparse Node, and the leading trivia if we are unparsing the unit as
-- a whole.
if As_Unit then
declare
First : constant Token_Reference := First_Token (Unit);
begin
if Is_Trivia (First) then
Append_Tokens (Result, First, Last_Trivia (First),
With_Trailing_Trivia => False);
end if;
end;
end if;
Unparse_Node (Node, Preserve_Formatting, Result);
end Unparse;
-------------
-- Unparse --
-------------
function Unparse
(Node : Abstract_Node;
Unit : Internal_Unit;
Preserve_Formatting : Boolean;
As_Unit : Boolean) return String
is
Result : String_Access :=
Unparse (Node, Unit, Preserve_Formatting, As_Unit);
R : constant String := Result.all;
begin
Free (Result);
return R;
end Unparse;
-------------
-- Unparse --
-------------
function Unparse
(Node : Abstract_Node;
Unit : Internal_Unit;
Preserve_Formatting : Boolean;
As_Unit : Boolean) return String_Access
is
use Ada.Strings.Wide_Wide_Unbounded.Aux;
Buffer : Unparsing_Buffer;
-- Buffer to store the result of unparsing as text
Buffer_Access : Big_Wide_Wide_String_Access;
Length : Natural;
-- Buffer internals, to avoid costly buffer copies
begin
Unparse (Node, Unit, Preserve_Formatting, As_Unit, Buffer);
Get_Wide_Wide_String (Buffer.Content, Buffer_Access, Length);
-- GNATCOLL.Iconv raises a Constraint_Error for empty strings: handle
-- them here.
if Length = 0 then
return new String'("");
end if;
declare
use GNATCOLL.Iconv;
State : Iconv_T := Iconv_Open
(To_Code => Get_Charset (Unit),
From_Code => Text_Charset);
Status : Iconv_Result;
To_Convert_String : constant String (1 .. 4 * Length)
with Import => True,
Convention => Ada,
Address => Buffer_Access.all'Address;
Output_Buffer : String_Access :=
new String (1 .. 4 * To_Convert_String'Length);
-- Encodings should not take more than 4 bytes per code point, so
-- this should be enough to hold the conversion.
Input_Index : Positive := To_Convert_String'First;
Output_Index : Positive := Output_Buffer'First;
begin
-- TODO??? Use GNATCOLL.Iconv to properly encode this wide wide
-- string into a mere string using this unit's charset.
Iconv
(State, To_Convert_String, Input_Index, Output_Buffer.all,
Output_Index, Status);
Iconv_Close (State);
case Status is
when Success => null;
when others => raise Program_Error with "cannot encode result";
end case;
declare
Result_Slice : String renames
Output_Buffer (Output_Buffer'First .. Output_Index - 1);
Result : constant String_Access :=
new String (Result_Slice'Range);
begin
Result.all := Result_Slice;
Free (Output_Buffer);
return Result;
end;
end;
end Unparse;
-------------
-- Unparse --
-------------
function Unparse
(Node : Abstract_Node;
Unit : Internal_Unit;
Preserve_Formatting : Boolean;
As_Unit : Boolean) return Unbounded_Text_Type
is
Buffer : Unparsing_Buffer;
begin
if Is_Null (Node) then
return (raise Program_Error with "cannot unparse null node");
elsif As_Unit and then Unit = null then
return (raise Program_Error
with "cannot unparse node as unit without a unit");
end if;
Unparse (Node, Unit, Preserve_Formatting, As_Unit, Buffer);
return Buffer.Content;
end Unparse;
------------------
-- Unparse_Node --
------------------
procedure Unparse_Node
(Node : Abstract_Node;
Preserve_Formatting : Boolean;
Result : in out Unparsing_Buffer)
is
Kind : constant Gpr_Node_Kind_Type :=
Unparsing_Implementation.Kind (Node);
Unparser : Node_Unparser renames Node_Unparsers (Kind);
Rewritten_Node : constant Bare_Gpr_Node :=
(if Preserve_Formatting
then Unparsing_Implementation.Rewritten_Node (Node)
else null);
begin
case Unparser.Kind is
when Regular =>
Unparse_Regular_Node
(Node, Unparser, Rewritten_Node, Preserve_Formatting, Result);
when List =>
Unparse_List_Node
(Node, Unparser, Rewritten_Node, Preserve_Formatting, Result);
when Token =>
declare
Tok_Kind : constant Token_Kind := Token_Node_Kind (Kind);
begin
-- Add the single token that materialize Node itself
Apply_Spacing_Rules (Result, Tok_Kind);
Append (Result, Tok_Kind, Text (Node));
-- If Node comes from an original node, also append the trivia
-- that comes after.
if Rewritten_Node /= null then
declare
Token : constant Token_Reference :=
Token_End (Rewritten_Node);
Last_Triv : constant Token_Reference :=
Last_Trivia (Token);
begin
Append_Tokens (Result, Next (Token), Last_Triv,
With_Trailing_Trivia => False);
end;
end if;
end;
end case;
end Unparse_Node;
--------------------------
-- Unparse_Regular_Node --
--------------------------
procedure Unparse_Regular_Node
(Node : Abstract_Node;
Unparser : Regular_Node_Unparser;
Rewritten_Node : Bare_Gpr_Node;
Preserve_Formatting : Boolean;
Result : in out Unparsing_Buffer)
is
Template : constant Regular_Node_Template :=
Extract_Regular_Node_Template (Unparser, Rewritten_Node);
begin
-- Unparse tokens that precede the first field. Re-use original ones if
-- available.
if Template.Present then
Append_Tokens (Result, Template.Pre_Tokens);
else
Unparse_Token_Sequence (Unparser.Pre_Tokens, Result);
end if;
-- Unparse Node's fields, and the tokens between them
declare
U : Field_Unparser_List renames Unparser.Field_Unparsers.all;
begin
for I in 1 .. U.N loop
declare
F : Field_Unparser renames U.Field_Unparsers (I);
Child : constant Abstract_Node :=
Unparsing_Implementation.Child (Node, I);
begin
-- First unparse tokens that appear unconditionally between
-- fields.
if Template.Present then
Append_Tokens (Result, Template.Inter_Tokens (I));
else
Unparse_Token_Sequence (U.Inter_Tokens (I), Result);
end if;
-- Then unparse the field itself
if Field_Present (Child, F) then
if Template.Present and then Template.Fields (I).Present then
Append_Tokens (Result, Template.Fields (I).Pre_Tokens);
Unparse_Node (Child, Preserve_Formatting, Result);
Append_Tokens (Result, Template.Fields (I).Post_Tokens);
else
Unparse_Token_Sequence (F.Pre_Tokens, Result);
Unparse_Node (Child, Preserve_Formatting, Result);
Unparse_Token_Sequence (F.Post_Tokens, Result);
end if;
end if;
end;
end loop;
end;
-- Unparse tokens that suceed to the last field. Re-use original ones if
-- available.
if Template.Present then
Append_Tokens (Result, Template.Post_Tokens);
else
Unparse_Token_Sequence (Unparser.Post_Tokens, Result);
end if;
end Unparse_Regular_Node;
-----------------------
-- Unparse_List_Node --
-----------------------
procedure Unparse_List_Node
(Node : Abstract_Node;
Unparser : List_Node_Unparser;
Rewritten_Node : Bare_Gpr_Node;
Preserve_Formatting : Boolean;
Result : in out Unparsing_Buffer)
is
AN_Child : Abstract_Node;
begin
for I in 1 .. Children_Count (Node) loop
AN_Child := Child (Node, I);
if Is_Null (AN_Child) then
raise Malformed_Tree_Error with "null node found in a list";
end if;
-- For all elements but the first one, emit the separator. If
-- possible, preserve original formatting for the corresponding
-- separator in the original source.
if I > 1 and then Unparser.Has_Separator then
if Rewritten_Node /= null
and then Children_Count (Rewritten_Node) >= I
then
declare
BN_Child : constant Bare_Gpr_Node :=
Child (Rewritten_Node, I);
Tok : constant Token_Reference :=
Relative_Token (Token_Start (BN_Child), -1);
begin
Append_Tokens (Result, Tok, Tok);
end;
else
Unparse_Token (Unparser.Separator, Result);
end if;
end if;
Unparse_Node (AN_Child, Preserve_Formatting, Result);
end loop;
end Unparse_List_Node;
-------------------
-- Unparse_Token --
-------------------
procedure Unparse_Token
(Unparser : Token_Unparser;
Result : in out Unparsing_Buffer) is
begin
Apply_Spacing_Rules (Result, Unparser.Kind);
if Unparser.Text /= null then
Append (Result, Unparser.Kind, Unparser.Text.all);
else
declare
Literal : constant Text_Type := Token_Kind_Literal (Unparser.Kind);
begin
pragma Assert (Literal'Length > 0);
Append (Result, Unparser.Kind, Literal);
end;
end if;
end Unparse_Token;
----------------------------
-- Unparse_Token_Sequence --
----------------------------
procedure Unparse_Token_Sequence
(Unparser : Token_Sequence_Access;
Result : in out Unparsing_Buffer) is
begin
for U of Unparser.all loop
Unparse_Token (U, Result);
end loop;
end Unparse_Token_Sequence;
--------------------
-- Relative_Token --
--------------------
function Relative_Token
(Token : Token_Reference; Offset : Integer) return Token_Reference
is
Current_Token : Token_Reference := Token;
Current_Offset : Integer := 0;
begin
if Offset < 0 then
while Current_Offset > Offset loop
Current_Token := Previous (Current_Token);
if not Is_Trivia (Current_Token) then
Current_Offset := Current_Offset - 1;
end if;
end loop;
else
while Current_Offset < Offset loop
Current_Token := Next (Current_Token);
if not Is_Trivia (Current_Token) then
Current_Offset := Current_Offset + 1;
end if;
end loop;
end if;
return Current_Token;
end Relative_Token;
-----------------
-- Last_Trivia --
-----------------
function Last_Trivia (Token : Token_Reference) return Token_Reference is
Result : Token_Reference := Token;
Cur : Token_Reference := Next (Token);
begin
-- Move Last to the last trivia that comes before the next token
while Cur /= No_Token and then Is_Trivia (Cur) loop
Result := Cur;
Cur := Next (Cur);
end loop;
return Result;
end Last_Trivia;
-------------------
-- Append_Tokens --
-------------------
procedure Append_Tokens
(Result : in out Unparsing_Buffer;
First_Token, Last_Token : Token_Reference;
With_Trailing_Trivia : Boolean := True) is
begin
if (First_Token = No_Token and then Last_Token = No_Token)
or else Last_Token < First_Token
then
return;
end if;
pragma Assert (First_Token /= No_Token and then Last_Token /= No_Token);
Apply_Spacing_Rules (Result, Kind (Data (First_Token)));
declare
Last : constant Token_Reference := (if With_Trailing_Trivia
then Last_Trivia (Last_Token)
else Last_Token);
begin
Append (Result, Kind (Data (Last)), Text (First_Token, Last));
end;
end Append_Tokens;
-------------------
-- Append_Tokens --
-------------------
procedure Append_Tokens
(Result : in out Unparsing_Buffer;
Template : Token_Sequence_Template)
is
begin
if Template.Present then
Append_Tokens (Result, Template.First, Template.Last);
end if;
end Append_Tokens;
Token_Unparser_0 : aliased constant Token_Unparser := (Gpr_Amp, null);
Token_Unparser_1 : aliased constant Token_Unparser := (Gpr_Tick, null);
Token_Unparser_2 : aliased constant Token_Unparser := (Gpr_Par_Open, null);
Token_Unparser_3 : aliased constant Token_Unparser := (Gpr_Par_Close, null);
Token_Unparser_4 : aliased constant Token_Unparser := (Gpr_Comma, null);
Token_Unparser_5 : aliased constant Token_Unparser := (Gpr_Dot, null);
Token_Unparser_6 : aliased constant Token_Unparser := (Gpr_Colon, null);
Token_Unparser_7 : aliased constant Token_Unparser := (Gpr_Assign, null);
Token_Unparser_8 : aliased constant Token_Unparser := (Gpr_Semicolon, null);
Token_Unparser_9 : aliased constant Token_Unparser := (Gpr_Arrow, null);
Token_Unparser_10 : aliased constant Token_Unparser := (Gpr_Abstract, null);
Token_Unparser_11 : aliased constant Token_Unparser := (Gpr_Identifier, new Text_Type'("aggregate"));
Token_Unparser_12 : aliased constant Token_Unparser := (Gpr_All, null);
Token_Unparser_13 : aliased constant Token_Unparser := (Gpr_At, null);
Token_Unparser_14 : aliased constant Token_Unparser := (Gpr_Case, null);
Token_Unparser_15 : aliased constant Token_Unparser := (Gpr_Identifier, new Text_Type'("configuration"));
Token_Unparser_16 : aliased constant Token_Unparser := (Gpr_End, null);
Token_Unparser_17 : aliased constant Token_Unparser := (Gpr_Extends, null);
Token_Unparser_18 : aliased constant Token_Unparser := (Gpr_For, null);
Token_Unparser_19 : aliased constant Token_Unparser := (Gpr_Is, null);
Token_Unparser_20 : aliased constant Token_Unparser := (Gpr_Identifier, new Text_Type'("library"));
Token_Unparser_21 : aliased constant Token_Unparser := (Gpr_Limited, null);
Token_Unparser_22 : aliased constant Token_Unparser := (Gpr_Null, null);
Token_Unparser_23 : aliased constant Token_Unparser := (Gpr_Others, null);
Token_Unparser_24 : aliased constant Token_Unparser := (Gpr_Package, null);
Token_Unparser_25 : aliased constant Token_Unparser := (Gpr_Identifier, new Text_Type'("project"));
Token_Unparser_26 : aliased constant Token_Unparser := (Gpr_Renames, null);
Token_Unparser_27 : aliased constant Token_Unparser := (Gpr_Identifier, new Text_Type'("standard"));
Token_Unparser_28 : aliased constant Token_Unparser := (Gpr_Type, null);
Token_Unparser_29 : aliased constant Token_Unparser := (Gpr_Use, null);
Token_Unparser_30 : aliased constant Token_Unparser := (Gpr_When, null);
Token_Unparser_31 : aliased constant Token_Unparser := (Gpr_With, null);
Token_Unparser_32 : aliased constant Token_Unparser := (Gpr_Pipe, null);
Token_Sequence_1 : aliased constant Token_Sequence := (1 => Token_Unparser_1);
Token_Sequence_2 : aliased constant Token_Sequence := (1 => Token_Unparser_2);
Token_Sequence_3 : aliased constant Token_Sequence := (1 => Token_Unparser_3);
Token_Sequence_4 : aliased constant Token_Sequence := (1 => Token_Unparser_3, 2 => Token_Unparser_8);
Token_Sequence_5 : aliased constant Token_Sequence := (1 => Token_Unparser_5);
Token_Sequence_6 : aliased constant Token_Sequence := (1 => Token_Unparser_6);
Token_Sequence_7 : aliased constant Token_Sequence := (1 => Token_Unparser_7);
Token_Sequence_8 : aliased constant Token_Sequence := (1 => Token_Unparser_8);
Token_Sequence_9 : aliased constant Token_Sequence := (1 => Token_Unparser_9);
Token_Sequence_10 : aliased constant Token_Sequence := (1 => Token_Unparser_10);
Token_Sequence_11 : aliased constant Token_Sequence := (1 => Token_Unparser_11);
Token_Sequence_12 : aliased constant Token_Sequence := (1 => Token_Unparser_11, 2 => Token_Unparser_20);
Token_Sequence_13 : aliased constant Token_Sequence := (1 => Token_Unparser_12);
Token_Sequence_14 : aliased constant Token_Sequence := (1 => Token_Unparser_13);
Token_Sequence_15 : aliased constant Token_Sequence := (1 => Token_Unparser_14);
Token_Sequence_16 : aliased constant Token_Sequence := (1 => Token_Unparser_15);
Token_Sequence_17 : aliased constant Token_Sequence := (1 => Token_Unparser_16);
Token_Sequence_18 : aliased constant Token_Sequence := (1 => Token_Unparser_16, 2 => Token_Unparser_14, 3 => Token_Unparser_8);
Token_Sequence_19 : aliased constant Token_Sequence := (1 => Token_Unparser_17);
Token_Sequence_20 : aliased constant Token_Sequence := (1 => Token_Unparser_18);
Token_Sequence_21 : aliased constant Token_Sequence := (1 => Token_Unparser_19);
Token_Sequence_22 : aliased constant Token_Sequence := (1 => Token_Unparser_19, 2 => Token_Unparser_2);
Token_Sequence_23 : aliased constant Token_Sequence := (1 => Token_Unparser_20);
Token_Sequence_24 : aliased constant Token_Sequence := (1 => Token_Unparser_21);
Token_Sequence_25 : aliased constant Token_Sequence := (1 => Token_Unparser_22, 2 => Token_Unparser_8);
Token_Sequence_26 : aliased constant Token_Sequence := (1 => Token_Unparser_23);
Token_Sequence_27 : aliased constant Token_Sequence := (1 => Token_Unparser_24);
Token_Sequence_28 : aliased constant Token_Sequence := (1 => Token_Unparser_25);
Token_Sequence_29 : aliased constant Token_Sequence := (1 => Token_Unparser_26);
Token_Sequence_30 : aliased constant Token_Sequence := (1 => Token_Unparser_27);
Token_Sequence_31 : aliased constant Token_Sequence := (1 => Token_Unparser_28);
Token_Sequence_32 : aliased constant Token_Sequence := (1 => Token_Unparser_29);
Token_Sequence_33 : aliased constant Token_Sequence := (1 => Token_Unparser_30);
Token_Sequence_34 : aliased constant Token_Sequence := (1 => Token_Unparser_31);
Bare_Attribute_Decl_Fields_Unparser_List : aliased constant Field_Unparser_List := (N => 3,
Field_Unparsers => (1 => Empty_Field_Unparser, 2 => (Token_Sequence_2'Access, Token_Sequence_3'Access, False), 3 => Empty_Field_Unparser),
Inter_Tokens => (1 => Empty_Token_Sequence'Access, 2 => Empty_Token_Sequence'Access, 3 => Token_Sequence_32'Access));
Bare_Attribute_Reference_Fields_Unparser_List : aliased constant Field_Unparser_List := (N => 2,
Field_Unparsers => (1 => Empty_Field_Unparser, 2 => (Token_Sequence_2'Access, Token_Sequence_3'Access, False)),
Inter_Tokens => (1 => Empty_Token_Sequence'Access, 2 => Empty_Token_Sequence'Access));
Bare_Builtin_Function_Call_Fields_Unparser_List : aliased constant Field_Unparser_List := (N => 2,
Field_Unparsers => (1 => Empty_Field_Unparser, 2 => Empty_Field_Unparser),
Inter_Tokens => (1 => Empty_Token_Sequence'Access, 2 => Empty_Token_Sequence'Access));
Bare_Case_Construction_Fields_Unparser_List : aliased constant Field_Unparser_List := (N => 2,
Field_Unparsers => (1 => Empty_Field_Unparser, 2 => Empty_Field_Unparser),
Inter_Tokens => (1 => Empty_Token_Sequence'Access, 2 => Token_Sequence_21'Access));
Bare_Case_Item_Fields_Unparser_List : aliased constant Field_Unparser_List := (N => 2,
Field_Unparsers => (1 => Empty_Field_Unparser, 2 => Empty_Field_Unparser),
Inter_Tokens => (1 => Empty_Token_Sequence'Access, 2 => Token_Sequence_9'Access));
Bare_Compilation_Unit_Fields_Unparser_List : aliased constant Field_Unparser_List := (N => 1,
Field_Unparsers => (1 => Empty_Field_Unparser),
Inter_Tokens => (1 => Empty_Token_Sequence'Access));
Bare_Prefix_Fields_Unparser_List : aliased constant Field_Unparser_List := (N => 2,
Field_Unparsers => (1 => Empty_Field_Unparser, 2 => Empty_Field_Unparser),
Inter_Tokens => (1 => Empty_Token_Sequence'Access, 2 => Token_Sequence_5'Access));
Bare_Package_Decl_Fields_Unparser_List : aliased constant Field_Unparser_List := (N => 2,
Field_Unparsers => (1 => Empty_Field_Unparser, 2 => Empty_Field_Unparser),
Inter_Tokens => (1 => Empty_Token_Sequence'Access, 2 => Empty_Token_Sequence'Access));
Bare_Package_Extension_Fields_Unparser_List : aliased constant Field_Unparser_List := (N => 1,
Field_Unparsers => (1 => Empty_Field_Unparser),
Inter_Tokens => (1 => Empty_Token_Sequence'Access));
Bare_Package_Renaming_Fields_Unparser_List : aliased constant Field_Unparser_List := (N => 1,
Field_Unparsers => (1 => Empty_Field_Unparser),
Inter_Tokens => (1 => Empty_Token_Sequence'Access));
Bare_Package_Spec_Fields_Unparser_List : aliased constant Field_Unparser_List := (N => 3,
Field_Unparsers => (1 => Empty_Field_Unparser, 2 => Empty_Field_Unparser, 3 => Empty_Field_Unparser),
Inter_Tokens => (1 => Empty_Token_Sequence'Access, 2 => Token_Sequence_21'Access, 3 => Token_Sequence_17'Access));
Bare_Project_Fields_Unparser_List : aliased constant Field_Unparser_List := (N => 2,
Field_Unparsers => (1 => Empty_Field_Unparser, 2 => Empty_Field_Unparser),
Inter_Tokens => (1 => Empty_Token_Sequence'Access, 2 => Empty_Token_Sequence'Access));
Bare_Project_Declaration_Fields_Unparser_List : aliased constant Field_Unparser_List := (N => 5,
Field_Unparsers => (1 => Empty_Field_Unparser, 2 => Empty_Field_Unparser, 3 => Empty_Field_Unparser, 4 => Empty_Field_Unparser, 5 => Empty_Field_Unparser),
Inter_Tokens => (1 => Empty_Token_Sequence'Access, 2 => Token_Sequence_28'Access, 3 => Empty_Token_Sequence'Access, 4 => Token_Sequence_21'Access, 5 => Token_Sequence_17'Access));
Bare_Project_Extension_Fields_Unparser_List : aliased constant Field_Unparser_List := (N => 2,
Field_Unparsers => (1 => Empty_Field_Unparser, 2 => Empty_Field_Unparser),
Inter_Tokens => (1 => Empty_Token_Sequence'Access, 2 => Empty_Token_Sequence'Access));
Bare_String_Literal_At_Fields_Unparser_List : aliased constant Field_Unparser_List := (N => 2,
Field_Unparsers => (1 => Empty_Field_Unparser, 2 => (Token_Sequence_14'Access, Empty_Token_Sequence'Access, False)),
Inter_Tokens => (1 => Empty_Token_Sequence'Access, 2 => Empty_Token_Sequence'Access));
Bare_Terms_Fields_Unparser_List : aliased constant Field_Unparser_List := (N => 1,
Field_Unparsers => (1 => Empty_Field_Unparser),
Inter_Tokens => (1 => Empty_Token_Sequence'Access));
Bare_Type_Reference_Fields_Unparser_List : aliased constant Field_Unparser_List := (N => 1,
Field_Unparsers => (1 => Empty_Field_Unparser),
Inter_Tokens => (1 => Empty_Token_Sequence'Access));
Bare_Typed_String_Decl_Fields_Unparser_List : aliased constant Field_Unparser_List := (N => 2,
Field_Unparsers => (1 => Empty_Field_Unparser, 2 => Empty_Field_Unparser),
Inter_Tokens => (1 => Empty_Token_Sequence'Access, 2 => Token_Sequence_22'Access));
Bare_Variable_Decl_Fields_Unparser_List : aliased constant Field_Unparser_List := (N => 3,
Field_Unparsers => (1 => Empty_Field_Unparser, 2 => (Token_Sequence_6'Access, Empty_Token_Sequence'Access, False), 3 => Empty_Field_Unparser),
Inter_Tokens => (1 => Empty_Token_Sequence'Access, 2 => Empty_Token_Sequence'Access, 3 => Token_Sequence_7'Access));
Bare_Variable_Reference_Fields_Unparser_List : aliased constant Field_Unparser_List := (N => 2,
Field_Unparsers => (1 => Empty_Field_Unparser, 2 => (Token_Sequence_1'Access, Empty_Token_Sequence'Access, False)),
Inter_Tokens => (1 => Empty_Token_Sequence'Access, 2 => Empty_Token_Sequence'Access));
Bare_With_Decl_Fields_Unparser_List : aliased constant Field_Unparser_List := (N => 2,
Field_Unparsers => (1 => Empty_Field_Unparser, 2 => Empty_Field_Unparser),
Inter_Tokens => (1 => Empty_Token_Sequence'Access, 2 => Token_Sequence_34'Access));
Node_Unparsers_Array : aliased constant Node_Unparser_Map := (
Gpr_All_Qualifier_Absent => (Kind => Regular, Pre_Tokens => Empty_Token_Sequence'Access, Field_Unparsers => Empty_Field_Unparser_List'Access, Post_Tokens => Empty_Token_Sequence'Access),
Gpr_All_Qualifier_Present => (Kind => Regular, Pre_Tokens => Token_Sequence_13'Access, Field_Unparsers => Empty_Field_Unparser_List'Access, Post_Tokens => Empty_Token_Sequence'Access),
Gpr_Attribute_Decl => (Kind => Regular, Pre_Tokens => Token_Sequence_20'Access, Field_Unparsers => Bare_Attribute_Decl_Fields_Unparser_List'Access, Post_Tokens => Token_Sequence_8'Access),
Gpr_Attribute_Reference => (Kind => Regular, Pre_Tokens => Empty_Token_Sequence'Access, Field_Unparsers => Bare_Attribute_Reference_Fields_Unparser_List'Access, Post_Tokens => Empty_Token_Sequence'Access),
Gpr_Case_Item_List => (Kind => List, Has_Separator => False, Separator => <>),
Gpr_Gpr_Node_List => (Kind => List, Has_Separator => False, Separator => <>),
Gpr_Choices => (Kind => List, Has_Separator => True, Separator => Token_Unparser_32),
Gpr_Term_List => (Kind => List, Has_Separator => True, Separator => Token_Unparser_0),
Gpr_Identifier_List => (Kind => List, Has_Separator => True, Separator => Token_Unparser_5),
Gpr_String_Literal_List => (Kind => List, Has_Separator => True, Separator => Token_Unparser_4),
Gpr_Term_List_List => (Kind => List, Has_Separator => True, Separator => Token_Unparser_4),
Gpr_With_Decl_List => (Kind => List, Has_Separator => False, Separator => <>),
Gpr_Builtin_Function_Call => (Kind => Regular, Pre_Tokens => Empty_Token_Sequence'Access, Field_Unparsers => Bare_Builtin_Function_Call_Fields_Unparser_List'Access, Post_Tokens => Empty_Token_Sequence'Access),
Gpr_Case_Construction => (Kind => Regular, Pre_Tokens => Token_Sequence_15'Access, Field_Unparsers => Bare_Case_Construction_Fields_Unparser_List'Access, Post_Tokens => Token_Sequence_18'Access),
Gpr_Case_Item => (Kind => Regular, Pre_Tokens => Token_Sequence_33'Access, Field_Unparsers => Bare_Case_Item_Fields_Unparser_List'Access, Post_Tokens => Empty_Token_Sequence'Access),
Gpr_Compilation_Unit => (Kind => Regular, Pre_Tokens => Empty_Token_Sequence'Access, Field_Unparsers => Bare_Compilation_Unit_Fields_Unparser_List'Access, Post_Tokens => Empty_Token_Sequence'Access),
Gpr_Empty_Decl => (Kind => Regular, Pre_Tokens => Token_Sequence_25'Access, Field_Unparsers => Empty_Field_Unparser_List'Access, Post_Tokens => Empty_Token_Sequence'Access),
Gpr_Prefix => (Kind => Regular, Pre_Tokens => Empty_Token_Sequence'Access, Field_Unparsers => Bare_Prefix_Fields_Unparser_List'Access, Post_Tokens => Empty_Token_Sequence'Access),
Gpr_Identifier => (Kind => Token),
Gpr_Num_Literal => (Kind => Token),
Gpr_String_Literal => (Kind => Token),
Gpr_Limited_Absent => (Kind => Regular, Pre_Tokens => Empty_Token_Sequence'Access, Field_Unparsers => Empty_Field_Unparser_List'Access, Post_Tokens => Empty_Token_Sequence'Access),
Gpr_Limited_Present => (Kind => Regular, Pre_Tokens => Token_Sequence_24'Access, Field_Unparsers => Empty_Field_Unparser_List'Access, Post_Tokens => Empty_Token_Sequence'Access),
Gpr_Others_Designator => (Kind => Regular, Pre_Tokens => Token_Sequence_26'Access, Field_Unparsers => Empty_Field_Unparser_List'Access, Post_Tokens => Empty_Token_Sequence'Access),
Gpr_Package_Decl => (Kind => Regular, Pre_Tokens => Token_Sequence_27'Access, Field_Unparsers => Bare_Package_Decl_Fields_Unparser_List'Access, Post_Tokens => Token_Sequence_8'Access),
Gpr_Package_Extension => (Kind => Regular, Pre_Tokens => Token_Sequence_19'Access, Field_Unparsers => Bare_Package_Extension_Fields_Unparser_List'Access, Post_Tokens => Empty_Token_Sequence'Access),
Gpr_Package_Renaming => (Kind => Regular, Pre_Tokens => Token_Sequence_29'Access, Field_Unparsers => Bare_Package_Renaming_Fields_Unparser_List'Access, Post_Tokens => Empty_Token_Sequence'Access),
Gpr_Package_Spec => (Kind => Regular, Pre_Tokens => Empty_Token_Sequence'Access, Field_Unparsers => Bare_Package_Spec_Fields_Unparser_List'Access, Post_Tokens => Empty_Token_Sequence'Access),
Gpr_Project => (Kind => Regular, Pre_Tokens => Empty_Token_Sequence'Access, Field_Unparsers => Bare_Project_Fields_Unparser_List'Access, Post_Tokens => Empty_Token_Sequence'Access),
Gpr_Project_Declaration => (Kind => Regular, Pre_Tokens => Empty_Token_Sequence'Access, Field_Unparsers => Bare_Project_Declaration_Fields_Unparser_List'Access, Post_Tokens => Token_Sequence_8'Access),
Gpr_Project_Extension => (Kind => Regular, Pre_Tokens => Token_Sequence_19'Access, Field_Unparsers => Bare_Project_Extension_Fields_Unparser_List'Access, Post_Tokens => Empty_Token_Sequence'Access),
Gpr_Project_Qualifier_Abstract => (Kind => Regular, Pre_Tokens => Token_Sequence_10'Access, Field_Unparsers => Empty_Field_Unparser_List'Access, Post_Tokens => Empty_Token_Sequence'Access),
Gpr_Project_Qualifier_Aggregate => (Kind => Regular, Pre_Tokens => Token_Sequence_11'Access, Field_Unparsers => Empty_Field_Unparser_List'Access, Post_Tokens => Empty_Token_Sequence'Access),
Gpr_Project_Qualifier_Aggregate_Library => (Kind => Regular, Pre_Tokens => Token_Sequence_12'Access, Field_Unparsers => Empty_Field_Unparser_List'Access, Post_Tokens => Empty_Token_Sequence'Access),
Gpr_Project_Qualifier_Configuration => (Kind => Regular, Pre_Tokens => Token_Sequence_16'Access, Field_Unparsers => Empty_Field_Unparser_List'Access, Post_Tokens => Empty_Token_Sequence'Access),
Gpr_Project_Qualifier_Library => (Kind => Regular, Pre_Tokens => Token_Sequence_23'Access, Field_Unparsers => Empty_Field_Unparser_List'Access, Post_Tokens => Empty_Token_Sequence'Access),
Gpr_Project_Qualifier_Standard => (Kind => Regular, Pre_Tokens => Token_Sequence_30'Access, Field_Unparsers => Empty_Field_Unparser_List'Access, Post_Tokens => Empty_Token_Sequence'Access),
Gpr_String_Literal_At => (Kind => Regular, Pre_Tokens => Empty_Token_Sequence'Access, Field_Unparsers => Bare_String_Literal_At_Fields_Unparser_List'Access, Post_Tokens => Empty_Token_Sequence'Access),
Gpr_Terms => (Kind => Regular, Pre_Tokens => Token_Sequence_2'Access, Field_Unparsers => Bare_Terms_Fields_Unparser_List'Access, Post_Tokens => Token_Sequence_3'Access),
Gpr_Type_Reference => (Kind => Regular, Pre_Tokens => Empty_Token_Sequence'Access, Field_Unparsers => Bare_Type_Reference_Fields_Unparser_List'Access, Post_Tokens => Empty_Token_Sequence'Access),
Gpr_Typed_String_Decl => (Kind => Regular, Pre_Tokens => Token_Sequence_31'Access, Field_Unparsers => Bare_Typed_String_Decl_Fields_Unparser_List'Access, Post_Tokens => Token_Sequence_4'Access),
Gpr_Variable_Decl => (Kind => Regular, Pre_Tokens => Empty_Token_Sequence'Access, Field_Unparsers => Bare_Variable_Decl_Fields_Unparser_List'Access, Post_Tokens => Token_Sequence_8'Access),
Gpr_Variable_Reference => (Kind => Regular, Pre_Tokens => Empty_Token_Sequence'Access, Field_Unparsers => Bare_Variable_Reference_Fields_Unparser_List'Access, Post_Tokens => Empty_Token_Sequence'Access),
Gpr_With_Decl => (Kind => Regular, Pre_Tokens => Empty_Token_Sequence'Access, Field_Unparsers => Bare_With_Decl_Fields_Unparser_List'Access, Post_Tokens => Token_Sequence_8'Access)
);
begin
Node_Unparsers := Node_Unparsers_Array'Access;
end Gpr_Parser.Unparsing_Implementation;
|
1Crazymoney/LearnAda | Ada | 338 | adb | with Ada.Integer_Text_IO;
procedure Lnko is
A, B : Positive;
begin
Ada.Integer_Text_IO.Get( A ); -- Constraint_Error!
Ada.Integer_Text_IO.Get( B );
while A /= B loop
if A > B then
A := A - B;
else
B := B - A;
end if;
end loop;
Ada.Integer_Text_IO.Put( A );
end Lnko;
|
zhmu/ananas | Ada | 287 | ads | -- { dg-do compile }
package Discr7 is
type Enum is (One, Two, Three);
for Enum use (One => 1, Two => 2, Three => 3);
type Arr is array (Integer range <>, Enum range <>) of Boolean;
type Rec (D : Integer) is record
A: Arr (1 .. D, Enum'Range);
end record;
end Discr7;
|
reznikmm/matreshka | Ada | 3,704 | ads | ------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- Open Document Toolkit --
-- --
-- Runtime Library Component --
-- --
------------------------------------------------------------------------------
-- --
-- Copyright © 2014, Vadim Godunko <[email protected]> --
-- All rights reserved. --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions --
-- are met: --
-- --
-- * Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- --
-- * Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in the --
-- documentation and/or other materials provided with the distribution. --
-- --
-- * Neither the name of the Vadim Godunko, IE nor the names of its --
-- contributors may be used to endorse or promote products derived from --
-- this software without specific prior written permission. --
-- --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR --
-- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
-- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED --
-- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR --
-- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF --
-- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING --
-- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS --
-- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
-- --
------------------------------------------------------------------------------
-- $Revision$ $Date$
------------------------------------------------------------------------------
with XML.DOM.Attributes;
package ODF.DOM.Draw_Contrast_Attributes is
pragma Preelaborate;
type ODF_Draw_Contrast_Attribute is limited interface
and XML.DOM.Attributes.DOM_Attribute;
type ODF_Draw_Contrast_Attribute_Access is
access all ODF_Draw_Contrast_Attribute'Class
with Storage_Size => 0;
end ODF.DOM.Draw_Contrast_Attributes;
|
onox/sdlada | Ada | 3,563 | adb | --------------------------------------------------------------------------------------------------------------------
-- Copyright (c) 2013-2018 Luke A. Guest
--
-- This software is provided 'as-is', without any express or implied
-- warranty. In no event will the authors be held liable for any damages
-- arising from the use of this software.
--
-- Permission is granted to anyone to use this software for any purpose,
-- including commercial applications, and to alter it and redistribute it
-- freely, subject to the following restrictions:
--
-- 1. The origin of this software must not be misrepresented; you must not
-- claim that you wrote the original software. If you use this software
-- in a product, an acknowledgment in the product documentation would be
-- appreciated but is not required.
--
-- 2. Altered source versions must be plainly marked as such, and must not be
-- misrepresented as being the original software.
--
-- 3. This notice may not be removed or altered from any source
-- distribution.
--------------------------------------------------------------------------------------------------------------------
with Interfaces.C;
private with SDL.C_Pointers;
with SDL.Error;
package body SDL.Video.Renderers.Makers is
package C renames Interfaces.C;
use type C.int;
use type SDL.C_Pointers.Texture_Pointer;
function Get_Internal_Window (Self : in SDL.Video.Windows.Window) return SDL.C_Pointers.Windows_Pointer with
Convention => Ada,
Import => True;
function Get_Internal_Surface (Self : in SDL.Video.Surfaces.Surface)
return SDL.Video.Surfaces.Internal_Surface_Pointer with
Import => True,
Convention => Ada;
procedure Create
(Rend : in out Renderer;
Window : in out SDL.Video.Windows.Window;
Driver : in Positive;
Flags : in Renderer_Flags := Default_Renderer_Flags) is
function SDL_Create_Renderer (W : in SDL.C_Pointers.Windows_Pointer; Index : in C.int; Flags : in Renderer_Flags)
return SDL.C_Pointers.Renderer_Pointer with
Import => True,
Convention => C,
External_Name => "SDL_CreateRenderer";
begin
Rend.Internal := SDL_Create_Renderer (Get_Internal_Window (Window), C.int (Driver), Flags);
end Create;
procedure Create
(Rend : in out Renderer;
Window : in out SDL.Video.Windows.Window;
Flags : in Renderer_Flags := Default_Renderer_Flags) is
function SDL_Create_Renderer (W : in SDL.C_Pointers.Windows_Pointer; Index : in C.int; Flags : in Renderer_Flags)
return SDL.C_Pointers.Renderer_Pointer with
Import => True,
Convention => C,
External_Name => "SDL_CreateRenderer";
begin
Rend.Internal := SDL_Create_Renderer (Get_Internal_Window (Window), -1, Flags);
Rend.Owns := True;
end Create;
procedure Create
(Rend : in out Renderer;
Surface : in SDL.Video.Surfaces.Surface) is
function SDL_Create_Software_Renderer (S : in SDL.Video.Surfaces.Internal_Surface_Pointer)
return SDL.C_Pointers.Renderer_Pointer with
Import => True,
Convention => C,
External_Name => "SDL_CreateSoftwareRenderer";
begin
Rend.Internal := SDL_Create_Software_Renderer (Get_Internal_Surface (Surface));
Rend.Owns := True;
end Create;
end SDL.Video.Renderers.Makers;
|
PThierry/ewok-kernel | Ada | 37 | ads | ../stm32f439/soc-usart-interfaces.ads |
reznikmm/matreshka | Ada | 3,769 | ads | ------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- Open Document Toolkit --
-- --
-- Runtime Library Component --
-- --
------------------------------------------------------------------------------
-- --
-- Copyright © 2014, Vadim Godunko <[email protected]> --
-- All rights reserved. --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions --
-- are met: --
-- --
-- * Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- --
-- * Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in the --
-- documentation and/or other materials provided with the distribution. --
-- --
-- * Neither the name of the Vadim Godunko, IE nor the names of its --
-- contributors may be used to endorse or promote products derived from --
-- this software without specific prior written permission. --
-- --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR --
-- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
-- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED --
-- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR --
-- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF --
-- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING --
-- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS --
-- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
-- --
------------------------------------------------------------------------------
-- $Revision$ $Date$
------------------------------------------------------------------------------
with XML.DOM.Attributes;
package ODF.DOM.Text_String_Value_Phonetic_Attributes is
pragma Preelaborate;
type ODF_Text_String_Value_Phonetic_Attribute is limited interface
and XML.DOM.Attributes.DOM_Attribute;
type ODF_Text_String_Value_Phonetic_Attribute_Access is
access all ODF_Text_String_Value_Phonetic_Attribute'Class
with Storage_Size => 0;
end ODF.DOM.Text_String_Value_Phonetic_Attributes;
|
optikos/oasis | Ada | 5,250 | ads | -- Copyright (c) 2019 Maxim Reznik <[email protected]>
--
-- SPDX-License-Identifier: MIT
-- License-Filename: LICENSE
-------------------------------------------------------------
with Program.Elements.Defining_Identifiers;
with Program.Lexical_Elements;
with Program.Elements.Discrete_Ranges;
with Program.Elements.Loop_Parameter_Specifications;
with Program.Element_Visitors;
package Program.Nodes.Loop_Parameter_Specifications is
pragma Preelaborate;
type Loop_Parameter_Specification is
new Program.Nodes.Node
and Program.Elements.Loop_Parameter_Specifications
.Loop_Parameter_Specification
and Program.Elements.Loop_Parameter_Specifications
.Loop_Parameter_Specification_Text
with private;
function Create
(Name : not null Program.Elements.Defining_Identifiers
.Defining_Identifier_Access;
In_Token : not null Program.Lexical_Elements.Lexical_Element_Access;
Reverse_Token : Program.Lexical_Elements.Lexical_Element_Access;
Definition : not null Program.Elements.Discrete_Ranges
.Discrete_Range_Access)
return Loop_Parameter_Specification;
type Implicit_Loop_Parameter_Specification is
new Program.Nodes.Node
and Program.Elements.Loop_Parameter_Specifications
.Loop_Parameter_Specification
with private;
function Create
(Name : not null Program.Elements.Defining_Identifiers
.Defining_Identifier_Access;
Definition : not null Program.Elements.Discrete_Ranges
.Discrete_Range_Access;
Is_Part_Of_Implicit : Boolean := False;
Is_Part_Of_Inherited : Boolean := False;
Is_Part_Of_Instance : Boolean := False;
Has_Reverse : Boolean := False)
return Implicit_Loop_Parameter_Specification
with Pre =>
Is_Part_Of_Implicit or Is_Part_Of_Inherited or Is_Part_Of_Instance;
private
type Base_Loop_Parameter_Specification is
abstract new Program.Nodes.Node
and Program.Elements.Loop_Parameter_Specifications
.Loop_Parameter_Specification
with record
Name : not null Program.Elements.Defining_Identifiers
.Defining_Identifier_Access;
Definition : not null Program.Elements.Discrete_Ranges
.Discrete_Range_Access;
end record;
procedure Initialize
(Self : aliased in out Base_Loop_Parameter_Specification'Class);
overriding procedure Visit
(Self : not null access Base_Loop_Parameter_Specification;
Visitor : in out Program.Element_Visitors.Element_Visitor'Class);
overriding function Name
(Self : Base_Loop_Parameter_Specification)
return not null Program.Elements.Defining_Identifiers
.Defining_Identifier_Access;
overriding function Definition
(Self : Base_Loop_Parameter_Specification)
return not null Program.Elements.Discrete_Ranges.Discrete_Range_Access;
overriding function Is_Loop_Parameter_Specification_Element
(Self : Base_Loop_Parameter_Specification)
return Boolean;
overriding function Is_Declaration_Element
(Self : Base_Loop_Parameter_Specification)
return Boolean;
type Loop_Parameter_Specification is
new Base_Loop_Parameter_Specification
and Program.Elements.Loop_Parameter_Specifications
.Loop_Parameter_Specification_Text
with record
In_Token : not null Program.Lexical_Elements
.Lexical_Element_Access;
Reverse_Token : Program.Lexical_Elements.Lexical_Element_Access;
end record;
overriding function To_Loop_Parameter_Specification_Text
(Self : aliased in out Loop_Parameter_Specification)
return Program.Elements.Loop_Parameter_Specifications
.Loop_Parameter_Specification_Text_Access;
overriding function In_Token
(Self : Loop_Parameter_Specification)
return not null Program.Lexical_Elements.Lexical_Element_Access;
overriding function Reverse_Token
(Self : Loop_Parameter_Specification)
return Program.Lexical_Elements.Lexical_Element_Access;
overriding function Has_Reverse
(Self : Loop_Parameter_Specification)
return Boolean;
type Implicit_Loop_Parameter_Specification is
new Base_Loop_Parameter_Specification
with record
Is_Part_Of_Implicit : Boolean;
Is_Part_Of_Inherited : Boolean;
Is_Part_Of_Instance : Boolean;
Has_Reverse : Boolean;
end record;
overriding function To_Loop_Parameter_Specification_Text
(Self : aliased in out Implicit_Loop_Parameter_Specification)
return Program.Elements.Loop_Parameter_Specifications
.Loop_Parameter_Specification_Text_Access;
overriding function Is_Part_Of_Implicit
(Self : Implicit_Loop_Parameter_Specification)
return Boolean;
overriding function Is_Part_Of_Inherited
(Self : Implicit_Loop_Parameter_Specification)
return Boolean;
overriding function Is_Part_Of_Instance
(Self : Implicit_Loop_Parameter_Specification)
return Boolean;
overriding function Has_Reverse
(Self : Implicit_Loop_Parameter_Specification)
return Boolean;
end Program.Nodes.Loop_Parameter_Specifications;
|
AdaCore/gpr | Ada | 2,178 | adb |
--
-- Copyright (C) 2019-2023, AdaCore
-- SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
--
pragma Warnings (Off, "is an internal GNAT unit");
with Ada.Strings.Unbounded.Aux; use Ada.Strings.Unbounded.Aux;
with Ada.Strings.Wide_Wide_Unbounded.Aux;
use Ada.Strings.Wide_Wide_Unbounded.Aux;
pragma Warnings (On, "is an internal GNAT unit");
with Gpr_Parser.Lexer_Implementation;
use Gpr_Parser.Lexer_Implementation;
pragma Warnings (Off, "referenced");
with Gpr_Parser_Support.Symbols;
pragma Warnings (On, "referenced");
package body Gpr_Parser.Lexer is
--------------------
-- Extract_Tokens --
--------------------
procedure Extract_Tokens
(Input : Lexer_Input;
With_Trivia : Boolean;
TDH : in out Token_Data_Handler;
Diagnostics : in out Diagnostics_Vectors.Vector)
is
Internal_Input : Internal_Lexer_Input (Input.Kind);
begin
case Input.Kind is
when File | Bytes_Buffer =>
Internal_Input.Charset := Input.Charset;
Internal_Input.Read_BOM := Input.Read_BOM;
case Input.Kind is
when File =>
Internal_Input.Filename := Input.Filename;
when Bytes_Buffer =>
declare
Bytes : Big_String_Access;
begin
Get_String
(Input.Bytes, Bytes, Internal_Input.Bytes_Count);
Internal_Input.Bytes := Bytes.all'Address;
end;
when others =>
raise Program_Error;
end case;
when Text_Buffer =>
declare
Text : Big_Wide_Wide_String_Access;
begin
Get_Wide_Wide_String
(Input.Text, Text, Internal_Input.Text_Count);
Internal_Input.Text := Text.all'Address;
end;
end case;
Extract_Tokens
(Input => Internal_Input,
With_Trivia => With_Trivia,
File_Reader => null,
TDH => TDH,
Diagnostics => Diagnostics);
end Extract_Tokens;
end Gpr_Parser.Lexer;
|
reznikmm/matreshka | Ada | 6,972 | ads | ------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- Localization, Internationalization, Globalization for Ada --
-- --
-- Runtime Library Component --
-- --
------------------------------------------------------------------------------
-- --
-- Copyright © 2013-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$
------------------------------------------------------------------------------
pragma Ada_2012;
private with Ada.Finalization;
limited with League.JSON.Documents;
limited with League.JSON.Values;
with League.Holders;
private with Matreshka.JSON_Types;
package League.JSON.Arrays is
pragma Preelaborate;
type JSON_Array is tagged private
with Iterator_Element => League.JSON.Values.JSON_Value,
Constant_Indexing => Element;
pragma Preelaborable_Initialization (JSON_Array);
Empty_JSON_Array : constant JSON_Array;
procedure Append
(Self : in out JSON_Array'Class; Value : League.JSON.Values.JSON_Value);
-- Inserts value at the end of the array.
procedure Delete (Self : in out JSON_Array'Class; Index : Positive);
-- Removes the value at index position Index. Index must be a valid index
-- position in the array.
procedure Delete_First (Self : in out JSON_Array'Class);
-- Removes the first item in the array.
procedure Delete_Last (Self : in out JSON_Array'Class);
-- Removes the last item in the array.
function Element
(Self : JSON_Array'Class;
Index : Positive) return League.JSON.Values.JSON_Value;
-- Returns a JSON_Value representing the value for index Index.
function First_Element
(Self : JSON_Array'Class) return League.JSON.Values.JSON_Value;
-- Returns the first value stored in the array.
procedure Insert
(Self : in out JSON_Array'Class;
Index : Positive;
Value : League.JSON.Values.JSON_Value);
-- Inserts value at index position Index in the array. If Index is 1, the
-- value is prepended to the array. If Index is large when Length, the
-- value is appended to the array.
function Is_Empty (Self : JSON_Array'Class) return Boolean;
-- Returns true if the object is empty.
function Last_Element
(Self : JSON_Array'Class) return League.JSON.Values.JSON_Value;
-- Returns the last value stored in the array.
function Length (Self : JSON_Array'Class) return Natural;
-- Returns the number of values stored in the array.
procedure Prepend
(Self : in out JSON_Array'Class; Value : League.JSON.Values.JSON_Value);
-- Inserts value at the beginning of the array.
procedure Replace
(Self : in out JSON_Array'Class;
Index : Positive;
Value : League.JSON.Values.JSON_Value);
-- Replaces the item at index position Index with Value. Index must be a
-- valid index position in the array.
function Take
(Self : in out JSON_Array'Class;
Index : Positive) return League.JSON.Values.JSON_Value;
-- Removes the item at index position Index and returns it. Index must be a
-- valid index position in the array.
function To_JSON_Value
(Self : JSON_Array'Class) return League.JSON.Values.JSON_Value;
-- Converts JSON_Array into JSON_Value.
function To_JSON_Document
(Self : JSON_Array'Class) return League.JSON.Documents.JSON_Document;
-- Converts JSON_Array into JSON_Document.
function First
(Self : aliased JSON_Array)
return League.Holders.Iterable_Holder_Cursors.Cursor'Class;
-- Return cursor used in iterable holders
private
type JSON_Array is new Ada.Finalization.Controlled with record
Data : Matreshka.JSON_Types.Shared_JSON_Array_Access
:= Matreshka.JSON_Types.Empty_Shared_JSON_Array'Access;
end record;
overriding procedure Adjust (Self : in out JSON_Array);
overriding procedure Finalize (Self : in out JSON_Array);
Empty_JSON_Array : constant JSON_Array
:= (Ada.Finalization.Controlled with
Data => Matreshka.JSON_Types.Empty_Shared_JSON_Array'Access);
end League.JSON.Arrays;
|
albertklee/AdaFractalCPP | Ada | 632 | adb | with Ada.Real_Time;
with Ada.Text_IO;
with AWS.Default;
with AWS.Server;
with Router_Cb;
procedure Main
is
WS : AWS.Server.HTTP;
Port : constant Natural := AWS.Default.Server_Port;
begin
Ada.Text_IO.Put_Line
("Serving on 127.0.0.1:" & Port'Img);
Router_Cb.Init;
AWS.Server.Start (WS,
"Hello World",
Max_Connection => 1,
Callback => Router_Cb.Router'Access,
Port => Port);
while Router_Cb.Server_Alive loop
delay until Ada.Real_Time.Time_Last;
end loop;
AWS.Server.Shutdown (WS);
end Main;
|
onox/orka | Ada | 2,948 | ads | -- SPDX-License-Identifier: Apache-2.0
--
-- Copyright (c) 2016 onox <[email protected]>
--
-- Licensed under the Apache License, Version 2.0 (the "License");
-- you may not use this file except in compliance with the License.
-- You may obtain a copy of the License at
--
-- http://www.apache.org/licenses/LICENSE-2.0
--
-- Unless required by applicable law or agreed to in writing, software
-- distributed under the License is distributed on an "AS IS" BASIS,
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-- See the License for the specific language governing permissions and
-- limitations under the License.
package Orka.SIMD.AVX.Singles.Arithmetic is
pragma Pure;
function "*" (Left, Right : m256) return m256
with Import, Convention => Intrinsic, External_Name => "__builtin_ia32_mulps256";
function "/" (Left, Right : m256) return m256
with Import, Convention => Intrinsic, External_Name => "__builtin_ia32_divps256";
function Divide_Or_Zero (Left, Right : m256) return m256
with Inline_Always;
function "+" (Left, Right : m256) return m256
with Import, Convention => Intrinsic, External_Name => "__builtin_ia32_addps256";
function "-" (Left, Right : m256) return m256
with Import, Convention => Intrinsic, External_Name => "__builtin_ia32_subps256";
function "-" (Elements : m256) return m256 is
((0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0) - Elements);
function "abs" (Elements : m256) return m256
with Inline_Always;
function Sum (Elements : m256) return Float_32
with Inline_Always;
function Add_Subtract (Left, Right : m256) return m256
with Import, Convention => Intrinsic, External_Name => "__builtin_ia32_addsubps256";
-- Subtract and add 32-bit floats from Left and Right
function Horizontal_Add (Left, Right : m256) return m256
with Import, Convention => Intrinsic, External_Name => "__builtin_ia32_haddps256";
-- Compute the sums of adjacent 32-bit floats in Left and Right.
-- The four sums (eight elements gives four pairs) of elements
-- from Left are stored in the four floats in the first, second, fifth,
-- and sixth position, sums from Right in the third, fourth,
-- seventh, and eight.
function Horizontal_Subtract (Left, Right : m256) return m256
with Import, Convention => Intrinsic, External_Name => "__builtin_ia32_hsubps256";
-- Compute the differences of adjacent 32-bit floats in Left and Right.
-- The four differences (eight elements gives four pairs) of elements
-- from Left are stored in the four floats in the first, second, fifth,
-- and sixth position, differences from Right in the third, fourth,
-- seventh, and eight.
function Dot (Left, Right : m256; Mask : Integer_32) return m256
with Import, Convention => Intrinsic, External_Name => "__builtin_ia32_dpps256";
end Orka.SIMD.AVX.Singles.Arithmetic;
|
jscparker/math_packages | Ada | 1,013 | ads |
-- PACKAGE Factorial
--
-- Natural logarithm of Factorial for arguments 0 and greater.
--
-- Uses Stieltjes' Continued Fraction method arg > 32, and
-- table for 0 <= arg <= 32.
--
-- Meant to be good to (much much) better than 30 digits (if you
-- can instantiate with a 30+ digit Real). That's why the
-- order of the Stieltjes' Continued Fraction is so high.
-- But ordinarily you use a 15 or 18 digit Real.
--
generic
type Real is digits <>;
package Factorial is
pragma Pure (Factorial);
function Log_Factorial (N : in Natural) return Real;
-- For N >= 0. Natural logarithm of N!
--
-- Uses Stieltjes' Continued Fraction method above N=20.
-- Probably good to a lot better than 32 digits (if you can find
-- that many digits).
procedure Test_Stieltjes_Coefficients;
procedure Test_Log_Factorial_Table;
-- Should call these sometime. The test routine will do it for you.
-- They raise Program_Error if the tables of constants have mutated.
end Factorial;
|
reznikmm/matreshka | Ada | 3,854 | ads | ------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- Open Document Toolkit --
-- --
-- Runtime Library Component --
-- --
------------------------------------------------------------------------------
-- --
-- Copyright © 2014, Vadim Godunko <[email protected]> --
-- All rights reserved. --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions --
-- are met: --
-- --
-- * Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- --
-- * Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in the --
-- documentation and/or other materials provided with the distribution. --
-- --
-- * Neither the name of the Vadim Godunko, IE nor the names of its --
-- contributors may be used to endorse or promote products derived from --
-- this software without specific prior written permission. --
-- --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR --
-- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
-- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED --
-- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR --
-- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF --
-- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING --
-- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS --
-- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
-- --
------------------------------------------------------------------------------
-- $Revision$ $Date$
------------------------------------------------------------------------------
with XML.DOM.Attributes;
package ODF.DOM.Presentation_Show_End_Of_Presentation_Slide_Attributes is
pragma Preelaborate;
type ODF_Presentation_Show_End_Of_Presentation_Slide_Attribute is limited interface
and XML.DOM.Attributes.DOM_Attribute;
type ODF_Presentation_Show_End_Of_Presentation_Slide_Attribute_Access is
access all ODF_Presentation_Show_End_Of_Presentation_Slide_Attribute'Class
with Storage_Size => 0;
end ODF.DOM.Presentation_Show_End_Of_Presentation_Slide_Attributes;
|
charlie5/lace | Ada | 1,200 | ads | with
openGL.Geometry,
openGL.Palette;
package openGL.Model.hex_grid
--
-- Models a regular hexagon grid.
--
is
type Item is new Model.item with private;
type View is access all Item'Class;
type height_Map_view is access all height_Map;
---------
--- Forge
--
function new_Grid (heights_Asset : in asset_Name;
Heights : in height_Map_view;
Color : in lucid_Color := (palette.White,
Opaque)) return View;
overriding
procedure destroy (Self : in out Item);
--------------
--- Attributes
--
overriding
function to_GL_Geometries (Self : access Item; Textures : access Texture.name_Map_of_texture'Class;
Fonts : in Font.font_id_Map_of_font) return Geometry.views;
private
type Item is new Model.item with
record
heights_Asset : asset_Name := null_Asset;
Heights : height_Map_view;
Color : rgba_Color;
end record;
overriding
procedure set_Bounds (Self : in out Item);
end openGL.Model.hex_grid;
|
optikos/oasis | Ada | 3,737 | ads | -- Copyright (c) 2019 Maxim Reznik <[email protected]>
--
-- SPDX-License-Identifier: MIT
-- License-Filename: LICENSE
-------------------------------------------------------------
with Program.Lexical_Elements;
with Program.Element_Vectors;
with Program.Elements.Variants;
with Program.Element_Visitors;
package Program.Nodes.Variants is
pragma Preelaborate;
type Variant is
new Program.Nodes.Node and Program.Elements.Variants.Variant
and Program.Elements.Variants.Variant_Text
with private;
function Create
(When_Token : not null Program.Lexical_Elements.Lexical_Element_Access;
Choices : not null Program.Element_Vectors.Element_Vector_Access;
Arrow_Token : not null Program.Lexical_Elements.Lexical_Element_Access;
Components : not null Program.Element_Vectors.Element_Vector_Access)
return Variant;
type Implicit_Variant is
new Program.Nodes.Node and Program.Elements.Variants.Variant
with private;
function Create
(Choices : not null Program.Element_Vectors
.Element_Vector_Access;
Components : not null Program.Element_Vectors
.Element_Vector_Access;
Is_Part_Of_Implicit : Boolean := False;
Is_Part_Of_Inherited : Boolean := False;
Is_Part_Of_Instance : Boolean := False)
return Implicit_Variant
with Pre =>
Is_Part_Of_Implicit or Is_Part_Of_Inherited or Is_Part_Of_Instance;
private
type Base_Variant is
abstract new Program.Nodes.Node and Program.Elements.Variants.Variant
with record
Choices : not null Program.Element_Vectors.Element_Vector_Access;
Components : not null Program.Element_Vectors.Element_Vector_Access;
end record;
procedure Initialize (Self : aliased in out Base_Variant'Class);
overriding procedure Visit
(Self : not null access Base_Variant;
Visitor : in out Program.Element_Visitors.Element_Visitor'Class);
overriding function Choices
(Self : Base_Variant)
return not null Program.Element_Vectors.Element_Vector_Access;
overriding function Components
(Self : Base_Variant)
return not null Program.Element_Vectors.Element_Vector_Access;
overriding function Is_Variant_Element (Self : Base_Variant) return Boolean;
overriding function Is_Definition_Element
(Self : Base_Variant)
return Boolean;
type Variant is
new Base_Variant and Program.Elements.Variants.Variant_Text
with record
When_Token : not null Program.Lexical_Elements.Lexical_Element_Access;
Arrow_Token : not null Program.Lexical_Elements.Lexical_Element_Access;
end record;
overriding function To_Variant_Text
(Self : aliased in out Variant)
return Program.Elements.Variants.Variant_Text_Access;
overriding function When_Token
(Self : Variant)
return not null Program.Lexical_Elements.Lexical_Element_Access;
overriding function Arrow_Token
(Self : Variant)
return not null Program.Lexical_Elements.Lexical_Element_Access;
type Implicit_Variant is
new Base_Variant
with record
Is_Part_Of_Implicit : Boolean;
Is_Part_Of_Inherited : Boolean;
Is_Part_Of_Instance : Boolean;
end record;
overriding function To_Variant_Text
(Self : aliased in out Implicit_Variant)
return Program.Elements.Variants.Variant_Text_Access;
overriding function Is_Part_Of_Implicit
(Self : Implicit_Variant)
return Boolean;
overriding function Is_Part_Of_Inherited
(Self : Implicit_Variant)
return Boolean;
overriding function Is_Part_Of_Instance
(Self : Implicit_Variant)
return Boolean;
end Program.Nodes.Variants;
|
MinimSecure/unum-sdk | Ada | 926 | adb | -- Copyright 2010-2016 Free Software Foundation, Inc.
--
-- This program is free software; you can redistribute it and/or modify
-- it under the terms of the GNU General Public License as published by
-- the Free Software Foundation; either version 3 of the License, or
-- (at your option) any later version.
--
-- This program is distributed in the hope that it will be useful,
-- but WITHOUT ANY WARRANTY; without even the implied warranty of
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-- GNU General Public License for more details.
--
-- You should have received a copy of the GNU General Public License
-- along with this program. If not, see <http://www.gnu.org/licenses/>.
package body Pck is
function Bar return Rec is
begin
return (X => 42, S => "ABCDEFGH");
end Bar;
procedure Do_Nothing (A : System.Address) is
begin
null;
end Do_Nothing;
end Pck;
|
vpodzime/ada-util | Ada | 2,929 | ads | -----------------------------------------------------------------------
-- events-channel -- Event Channels
-- Copyright (C) 2001, 2002, 2003, 2009, 2010 Stephane Carrez
-- Written by Stephane Carrez ([email protected])
--
-- Licensed under the Apache License, Version 2.0 (the "License");
-- you may not use this file except in compliance with the License.
-- You may obtain a copy of the License at
--
-- http://www.apache.org/licenses/LICENSE-2.0
--
-- Unless required by applicable law or agreed to in writing, software
-- distributed under the License is distributed on an "AS IS" BASIS,
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-- See the License for the specific language governing permissions and
-- limitations under the License.
-----------------------------------------------------------------------
with Ada.Strings.Unbounded;
with Ada.Containers.Doubly_Linked_Lists;
-- The <b>Util.Events.Channels</b> package implements a publish/subscribe event
-- channel. It is inspired from Event pattern and CosEvent service.
package Util.Events.Channels is
type Subscriber is limited interface;
type Subscriber_Access is access all Subscriber'Class;
procedure Receive_Event (Sub : in out Subscriber;
Item : in Event'Class) is abstract;
----------------------
-- Event Channel
----------------------
-- Channel on which events are pushed.
type Channel is tagged limited private;
type Channel_Access is access all Channel'Class;
-- Get the name of this event channel.
function Get_Name (C : Channel) return String;
-- Post an event (may be asynchronous)
procedure Post (To : in out Channel;
Item : in Event'Class);
-- Subscribe to events sent on the event channel.
procedure Subscribe (To : in out Channel;
Client : in Subscriber_Access);
-- Unsubscribe to events sent on the event channel.
procedure Unsubscribe (To : in out Channel;
Client : in Subscriber_Access);
type Channel_Creator is access
function (Name : String) return Channel_Access;
-- Create an event channel with the given name. The type of channel
-- is controlled by <b>Kind</b>.
function Create (Name : String;
Kind : String) return Channel_Access;
-- Create an event channel that post the event immediately.
-- This is similar to calling <b>Create</b> with <b>"direct"</b> as kind.
function Create_Direct_Channel (Name : String) return Channel_Access;
private
package Containers is new Ada.Containers.Doubly_Linked_Lists
(Element_Type => Subscriber_Access);
subtype List is Containers.List;
type Channel is tagged limited record
Name : Ada.Strings.Unbounded.Unbounded_String;
Clients : List;
end record;
end Util.Events.Channels;
|
zhmu/ananas | Ada | 468 | adb | -- { dg-do compile }
-- { dg-options "-O" }
with Loop_Optimization11_Pkg; use Loop_Optimization11_Pkg;
procedure Loop_Optimization11 is
Arr : array (Prot, Mem) of Integer := (others => (others => 0));
begin
Put_Line (Img (0) & " ");
for I in Arr'Range (1) loop
for J in Arr'Range (2) loop
declare
Elem : Integer renames Arr (I, J);
begin
Put_Line (Img (Elem));
end;
end loop;
end loop;
end;
|
pat-rogers/LmcpGen | Ada | 534 | adb | package body AVTAS.LMCP.Object is
procedure XML_Output (this : Object'Class;
S : access Ada.Streams.Root_Stream_Type'Class;
Level : Natural := 0) is
begin
String'Write (S, LeftPad ("<" & this.getLmcpTypeName & " Series=""" & this.getSeriesName & """>" & ASCII.LF, Level));
this.XML_Write (S, Level + 1); -- dynamically dispatch
String'Write (S, LeftPad ("</" & this.getLmcpTypeName & ">" & ASCII.LF, Level));
end XML_Output;
end AVTAS.LMCP.Object;
|
DerickEddington/tarmi | Ada | 1,638 | adb | -- TODO: Think about memory management issues w.r.t. strings
-- and symbols used in the symbol table. What about string
-- pointers given as arguments to Interned?
-- Newly-allocated strings in other version of Interned?
-- Newly-allocated symbols when a name not already
-- interned? What is the portable semantics w.r.t. master
-- completion and finalization and ownership?
with Ada.Strings.Hash;
package body Tarmi.Symbols is
function Hash_String (Key : String_Type_A) return Hash_Type is
begin
return Ada.Strings.Hash (Key.all) ;
end Hash_String ;
function Keys_Equal (Left, Right : String_Type_A) return Boolean is
begin
return Left.all = Right.all ;
end Keys_Equal ;
function Interned (Name : String_Type_A) return Symbol is
use type Hashed_Maps.Cursor ;
C : Hashed_Maps.Cursor := Hashed_Maps.Find (Symbol_Table, Name) ;
begin
if C = Hashed_Maps.No_Element then
declare
S : Symbol := new Symbol_R'(Name'Length, Name.all) ;
begin
Hashed_Maps.Insert (Symbol_Table, Name, S) ;
return S ;
end ;
else
return Hashed_Maps.Element (C) ;
end if ;
-- TODO: Could this be faster by using 4-arg Hashed_Maps.Insert ?
-- I think that would do only one hash, whereas now it's doing two.
end Interned ;
function Interned (Name : String_Type) return Symbol is
S : String_Type_A := new String_Type'(Name) ;
begin
return Interned (S) ;
end Interned ;
--begin
--Hashed_Maps.Reserve_Capacity (Symbol_Table, 1000) ; -- TODO: best size
end Tarmi.Symbols ;
|
jrmarino/AdaBase | Ada | 1,489 | adb | with AdaBase;
with Connect;
with CommonText;
with Ada.Text_IO;
with Ada.Wide_Text_IO;
with Ada.Wide_Wide_Text_IO;
with AdaBase.Results.Sets;
procedure UTF8 is
package CON renames Connect;
package TIO renames Ada.Text_IO;
package WIO renames Ada.Wide_Text_IO;
package WWO renames Ada.Wide_Wide_Text_IO;
package ARS renames AdaBase.Results.Sets;
package CT renames CommonText;
begin
CON.connect_database;
TIO.Put_Line ("Use terminal encoding UTF-8 or ISO8859-1");
TIO.Put_Line ("Either UTF8 fields or string fields will look right, " &
"but not both");
declare
sql : constant String := "SELECT * FROM funny_names";
stmt : CON.Stmt_Type := CON.DR.query (sql);
row : ARS.Datarow;
begin
loop
row := stmt.fetch_next;
exit when row.data_exhausted;
TIO.Put_Line ("");
TIO.Put_Line (" UTF8: " & row.column ("first_name").as_utf8 &
" " & row.column ("surname").as_utf8);
TIO.Put_Line (" STRING: " & row.column ("first_name").as_string &
" " & row.column ("surname").as_string);
WIO.Put_Line (" WSTRING: " & row.column ("first_name").as_wstring &
" " & row.column ("surname").as_wstring);
WWO.Put_Line ("WWSTRING: " & row.column ("first_name").as_wwstring &
" " & row.column ("surname").as_wwstring);
end loop;
end;
CON.DR.disconnect;
end UTF8;
|
reznikmm/matreshka | Ada | 11,340 | 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_Element_Imports is
-------------------
-- Enter_Element --
-------------------
overriding procedure Enter_Element
(Self : not null access constant UML_Element_Import_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_Element_Import
(AMF.UML.Element_Imports.UML_Element_Import_Access (Self),
Control);
end if;
end Enter_Element;
-------------------
-- Leave_Element --
-------------------
overriding procedure Leave_Element
(Self : not null access constant UML_Element_Import_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_Element_Import
(AMF.UML.Element_Imports.UML_Element_Import_Access (Self),
Control);
end if;
end Leave_Element;
-------------------
-- Visit_Element --
-------------------
overriding procedure Visit_Element
(Self : not null access constant UML_Element_Import_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_Element_Import
(Visitor,
AMF.UML.Element_Imports.UML_Element_Import_Access (Self),
Control);
end if;
end Visit_Element;
---------------
-- Get_Alias --
---------------
overriding function Get_Alias
(Self : not null access constant UML_Element_Import_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_Alias (Self.Element);
begin
if Aux = null then
return (Is_Empty => True);
else
return (False, League.Strings.Internals.Create (Aux));
end if;
end;
end Get_Alias;
---------------
-- Set_Alias --
---------------
overriding procedure Set_Alias
(Self : not null access UML_Element_Import_Proxy;
To : AMF.Optional_String) is
begin
if To.Is_Empty then
AMF.Internals.Tables.UML_Attributes.Internal_Set_Alias
(Self.Element, null);
else
AMF.Internals.Tables.UML_Attributes.Internal_Set_Alias
(Self.Element,
League.Strings.Internals.Internal (To.Value));
end if;
end Set_Alias;
--------------------------
-- Get_Imported_Element --
--------------------------
overriding function Get_Imported_Element
(Self : not null access constant UML_Element_Import_Proxy)
return AMF.UML.Packageable_Elements.UML_Packageable_Element_Access is
begin
return
AMF.UML.Packageable_Elements.UML_Packageable_Element_Access
(AMF.Internals.Helpers.To_Element
(AMF.Internals.Tables.UML_Attributes.Internal_Get_Imported_Element
(Self.Element)));
end Get_Imported_Element;
--------------------------
-- Set_Imported_Element --
--------------------------
overriding procedure Set_Imported_Element
(Self : not null access UML_Element_Import_Proxy;
To : AMF.UML.Packageable_Elements.UML_Packageable_Element_Access) is
begin
AMF.Internals.Tables.UML_Attributes.Internal_Set_Imported_Element
(Self.Element,
AMF.Internals.Helpers.To_Element
(AMF.Elements.Element_Access (To)));
end Set_Imported_Element;
-----------------------------
-- Get_Importing_Namespace --
-----------------------------
overriding function Get_Importing_Namespace
(Self : not null access constant UML_Element_Import_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_Importing_Namespace
(Self.Element)));
end Get_Importing_Namespace;
-----------------------------
-- Set_Importing_Namespace --
-----------------------------
overriding procedure Set_Importing_Namespace
(Self : not null access UML_Element_Import_Proxy;
To : AMF.UML.Namespaces.UML_Namespace_Access) is
begin
AMF.Internals.Tables.UML_Attributes.Internal_Set_Importing_Namespace
(Self.Element,
AMF.Internals.Helpers.To_Element
(AMF.Elements.Element_Access (To)));
end Set_Importing_Namespace;
--------------------
-- Get_Visibility --
--------------------
overriding function Get_Visibility
(Self : not null access constant UML_Element_Import_Proxy)
return AMF.UML.UML_Visibility_Kind is
begin
return
AMF.Internals.Tables.UML_Attributes.Internal_Get_Visibility
(Self.Element);
end Get_Visibility;
--------------------
-- Set_Visibility --
--------------------
overriding procedure Set_Visibility
(Self : not null access UML_Element_Import_Proxy;
To : AMF.UML.UML_Visibility_Kind) is
begin
AMF.Internals.Tables.UML_Attributes.Internal_Set_Visibility
(Self.Element, To);
end Set_Visibility;
----------------
-- Get_Source --
----------------
overriding function Get_Source
(Self : not null access constant UML_Element_Import_Proxy)
return AMF.UML.Elements.Collections.Set_Of_UML_Element is
begin
return
AMF.UML.Elements.Collections.Wrap
(AMF.Internals.Element_Collections.Wrap
(AMF.Internals.Tables.UML_Attributes.Internal_Get_Source
(Self.Element)));
end Get_Source;
----------------
-- Get_Target --
----------------
overriding function Get_Target
(Self : not null access constant UML_Element_Import_Proxy)
return AMF.UML.Elements.Collections.Set_Of_UML_Element is
begin
return
AMF.UML.Elements.Collections.Wrap
(AMF.Internals.Element_Collections.Wrap
(AMF.Internals.Tables.UML_Attributes.Internal_Get_Target
(Self.Element)));
end Get_Target;
-------------------------
-- Get_Related_Element --
-------------------------
overriding function Get_Related_Element
(Self : not null access constant UML_Element_Import_Proxy)
return AMF.UML.Elements.Collections.Set_Of_UML_Element is
begin
return
AMF.UML.Elements.Collections.Wrap
(AMF.Internals.Element_Collections.Wrap
(AMF.Internals.Tables.UML_Attributes.Internal_Get_Related_Element
(Self.Element)));
end Get_Related_Element;
--------------
-- Get_Name --
--------------
overriding function Get_Name
(Self : not null access constant UML_Element_Import_Proxy)
return League.Strings.Universal_String is
begin
-- Generated stub: replace with real body!
pragma Compile_Time_Warning (Standard.True, "Get_Name unimplemented");
raise Program_Error with "Unimplemented procedure UML_Element_Import_Proxy.Get_Name";
return Get_Name (Self);
end Get_Name;
end AMF.Internals.UML_Element_Imports;
|
optikos/oasis | Ada | 7,339 | adb | -- Copyright (c) 2019 Maxim Reznik <[email protected]>
--
-- SPDX-License-Identifier: MIT
-- License-Filename: LICENSE
-------------------------------------------------------------
package body Program.Nodes.Anonymous_Access_To_Procedures 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 Anonymous_Access_To_Procedure is
begin
return Result : Anonymous_Access_To_Procedure :=
(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_Anonymous_Access_To_Procedure is
begin
return Result : Implicit_Anonymous_Access_To_Procedure :=
(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_Anonymous_Access_To_Procedure)
return Program.Elements.Parameter_Specifications
.Parameter_Specification_Vector_Access is
begin
return Self.Parameters;
end Parameters;
overriding function Not_Token
(Self : Anonymous_Access_To_Procedure)
return Program.Lexical_Elements.Lexical_Element_Access is
begin
return Self.Not_Token;
end Not_Token;
overriding function Null_Token
(Self : Anonymous_Access_To_Procedure)
return Program.Lexical_Elements.Lexical_Element_Access is
begin
return Self.Null_Token;
end Null_Token;
overriding function Access_Token
(Self : Anonymous_Access_To_Procedure)
return not null Program.Lexical_Elements.Lexical_Element_Access is
begin
return Self.Access_Token;
end Access_Token;
overriding function Protected_Token
(Self : Anonymous_Access_To_Procedure)
return Program.Lexical_Elements.Lexical_Element_Access is
begin
return Self.Protected_Token;
end Protected_Token;
overriding function Procedure_Token
(Self : Anonymous_Access_To_Procedure)
return not null Program.Lexical_Elements.Lexical_Element_Access is
begin
return Self.Procedure_Token;
end Procedure_Token;
overriding function Left_Bracket_Token
(Self : Anonymous_Access_To_Procedure)
return Program.Lexical_Elements.Lexical_Element_Access is
begin
return Self.Left_Bracket_Token;
end Left_Bracket_Token;
overriding function Right_Bracket_Token
(Self : Anonymous_Access_To_Procedure)
return Program.Lexical_Elements.Lexical_Element_Access is
begin
return Self.Right_Bracket_Token;
end Right_Bracket_Token;
overriding function Has_Not_Null
(Self : Anonymous_Access_To_Procedure)
return Boolean is
begin
return Self.Null_Token.Assigned;
end Has_Not_Null;
overriding function Has_Protected
(Self : Anonymous_Access_To_Procedure)
return Boolean is
begin
return Self.Protected_Token.Assigned;
end Has_Protected;
overriding function Is_Part_Of_Implicit
(Self : Implicit_Anonymous_Access_To_Procedure)
return Boolean is
begin
return Self.Is_Part_Of_Implicit;
end Is_Part_Of_Implicit;
overriding function Is_Part_Of_Inherited
(Self : Implicit_Anonymous_Access_To_Procedure)
return Boolean is
begin
return Self.Is_Part_Of_Inherited;
end Is_Part_Of_Inherited;
overriding function Is_Part_Of_Instance
(Self : Implicit_Anonymous_Access_To_Procedure)
return Boolean is
begin
return Self.Is_Part_Of_Instance;
end Is_Part_Of_Instance;
overriding function Has_Not_Null
(Self : Implicit_Anonymous_Access_To_Procedure)
return Boolean is
begin
return Self.Has_Not_Null;
end Has_Not_Null;
overriding function Has_Protected
(Self : Implicit_Anonymous_Access_To_Procedure)
return Boolean is
begin
return Self.Has_Protected;
end Has_Protected;
procedure Initialize
(Self : aliased in out Base_Anonymous_Access_To_Procedure'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_Anonymous_Access_To_Procedure_Element
(Self : Base_Anonymous_Access_To_Procedure)
return Boolean is
pragma Unreferenced (Self);
begin
return True;
end Is_Anonymous_Access_To_Procedure_Element;
overriding function Is_Anonymous_Access_Definition_Element
(Self : Base_Anonymous_Access_To_Procedure)
return Boolean is
pragma Unreferenced (Self);
begin
return True;
end Is_Anonymous_Access_Definition_Element;
overriding function Is_Definition_Element
(Self : Base_Anonymous_Access_To_Procedure)
return Boolean is
pragma Unreferenced (Self);
begin
return True;
end Is_Definition_Element;
overriding procedure Visit
(Self : not null access Base_Anonymous_Access_To_Procedure;
Visitor : in out Program.Element_Visitors.Element_Visitor'Class) is
begin
Visitor.Anonymous_Access_To_Procedure (Self);
end Visit;
overriding function To_Anonymous_Access_To_Procedure_Text
(Self : aliased in out Anonymous_Access_To_Procedure)
return Program.Elements.Anonymous_Access_To_Procedures
.Anonymous_Access_To_Procedure_Text_Access is
begin
return Self'Unchecked_Access;
end To_Anonymous_Access_To_Procedure_Text;
overriding function To_Anonymous_Access_To_Procedure_Text
(Self : aliased in out Implicit_Anonymous_Access_To_Procedure)
return Program.Elements.Anonymous_Access_To_Procedures
.Anonymous_Access_To_Procedure_Text_Access is
pragma Unreferenced (Self);
begin
return null;
end To_Anonymous_Access_To_Procedure_Text;
end Program.Nodes.Anonymous_Access_To_Procedures;
|
Subsets and Splits
No saved queries yet
Save your SQL queries to embed, download, and access them later. Queries will appear here once saved.