repo_name
stringlengths
9
74
language
stringclasses
1 value
length_bytes
int64
11
9.34M
extension
stringclasses
2 values
content
stringlengths
11
9.34M
wiremoons/AdbT
Ada
881
ads
------------------------------------------------------------------------------- -- Package : DB_File_Stats -- -- Description : Find the acronyms database file for use with the program. -- -- Author : Simon Rowe <[email protected]> -- -- License : MIT Open Source. -- ------------------------------------------------------------------------------- package DB_File_Stats is function Get_Full_Directory (Dbfile : String) return String; -- Get the full directory path of a filename function Get_File_Size (Dbfile : String) return String; -- Get the size in bytes of a file name provided function Get_File_Mod_Time (Dbfile : String) return String; -- Get the modification time for the file name provided end DB_File_Stats;
reznikmm/matreshka
Ada
3,714
ads
------------------------------------------------------------------------------ -- -- -- Matreshka Project -- -- -- -- Open Document Toolkit -- -- -- -- Runtime Library Component -- -- -- ------------------------------------------------------------------------------ -- -- -- Copyright © 2014, Vadim Godunko <[email protected]> -- -- All rights reserved. -- -- -- -- Redistribution and use in source and binary forms, with or without -- -- modification, are permitted provided that the following conditions -- -- are met: -- -- -- -- * Redistributions of source code must retain the above copyright -- -- notice, this list of conditions and the following disclaimer. -- -- -- -- * Redistributions in binary form must reproduce the above copyright -- -- notice, this list of conditions and the following disclaimer in the -- -- documentation and/or other materials provided with the distribution. -- -- -- -- * Neither the name of the Vadim Godunko, IE nor the names of its -- -- contributors may be used to endorse or promote products derived from -- -- this software without specific prior written permission. -- -- -- -- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -- -- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -- -- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -- -- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -- -- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -- -- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED -- -- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -- -- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -- -- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -- -- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -- -- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- -- -- ------------------------------------------------------------------------------ -- $Revision$ $Date$ ------------------------------------------------------------------------------ with XML.DOM.Attributes; package ODF.DOM.Chart_Hole_Size_Attributes is pragma Preelaborate; type ODF_Chart_Hole_Size_Attribute is limited interface and XML.DOM.Attributes.DOM_Attribute; type ODF_Chart_Hole_Size_Attribute_Access is access all ODF_Chart_Hole_Size_Attribute'Class with Storage_Size => 0; end ODF.DOM.Chart_Hole_Size_Attributes;
reznikmm/matreshka
Ada
4,827
ads
------------------------------------------------------------------------------ -- -- -- Matreshka Project -- -- -- -- Open Document Toolkit -- -- -- -- Runtime Library Component -- -- -- ------------------------------------------------------------------------------ -- -- -- Copyright © 2014, Vadim Godunko <[email protected]> -- -- All rights reserved. -- -- -- -- Redistribution and use in source and binary forms, with or without -- -- modification, are permitted provided that the following conditions -- -- are met: -- -- -- -- * Redistributions of source code must retain the above copyright -- -- notice, this list of conditions and the following disclaimer. -- -- -- -- * Redistributions in binary form must reproduce the above copyright -- -- notice, this list of conditions and the following disclaimer in the -- -- documentation and/or other materials provided with the distribution. -- -- -- -- * Neither the name of the Vadim Godunko, IE nor the names of its -- -- contributors may be used to endorse or promote products derived from -- -- this software without specific prior written permission. -- -- -- -- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -- -- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -- -- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -- -- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -- -- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -- -- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED -- -- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -- -- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -- -- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -- -- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -- -- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- -- -- ------------------------------------------------------------------------------ -- $Revision$ $Date$ ------------------------------------------------------------------------------ with XML.DOM.Visitors; with ODF.DOM.Text_Sender_Phone_Private_Elements; package Matreshka.ODF_Text.Sender_Phone_Private_Elements is type Text_Sender_Phone_Private_Element_Node is new Matreshka.ODF_Text.Abstract_Text_Element_Node and ODF.DOM.Text_Sender_Phone_Private_Elements.ODF_Text_Sender_Phone_Private with null record; overriding function Create (Parameters : not null access Matreshka.DOM_Elements.Element_L2_Parameters) return Text_Sender_Phone_Private_Element_Node; overriding function Get_Local_Name (Self : not null access constant Text_Sender_Phone_Private_Element_Node) return League.Strings.Universal_String; overriding procedure Enter_Node (Self : not null access Text_Sender_Phone_Private_Element_Node; Visitor : in out XML.DOM.Visitors.Abstract_Visitor'Class; Control : in out XML.DOM.Visitors.Traverse_Control); overriding procedure Leave_Node (Self : not null access Text_Sender_Phone_Private_Element_Node; Visitor : in out XML.DOM.Visitors.Abstract_Visitor'Class; Control : in out XML.DOM.Visitors.Traverse_Control); overriding procedure Visit_Node (Self : not null access Text_Sender_Phone_Private_Element_Node; Iterator : in out XML.DOM.Visitors.Abstract_Iterator'Class; Visitor : in out XML.DOM.Visitors.Abstract_Visitor'Class; Control : in out XML.DOM.Visitors.Traverse_Control); end Matreshka.ODF_Text.Sender_Phone_Private_Elements;
reznikmm/matreshka
Ada
3,764
ads
------------------------------------------------------------------------------ -- -- -- Matreshka Project -- -- -- -- Open Document Toolkit -- -- -- -- Runtime Library Component -- -- -- ------------------------------------------------------------------------------ -- -- -- Copyright © 2014, Vadim Godunko <[email protected]> -- -- All rights reserved. -- -- -- -- Redistribution and use in source and binary forms, with or without -- -- modification, are permitted provided that the following conditions -- -- are met: -- -- -- -- * Redistributions of source code must retain the above copyright -- -- notice, this list of conditions and the following disclaimer. -- -- -- -- * Redistributions in binary form must reproduce the above copyright -- -- notice, this list of conditions and the following disclaimer in the -- -- documentation and/or other materials provided with the distribution. -- -- -- -- * Neither the name of the Vadim Godunko, IE nor the names of its -- -- contributors may be used to endorse or promote products derived from -- -- this software without specific prior written permission. -- -- -- -- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -- -- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -- -- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -- -- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -- -- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -- -- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED -- -- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -- -- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -- -- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -- -- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -- -- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- -- -- ------------------------------------------------------------------------------ -- $Revision$ $Date$ ------------------------------------------------------------------------------ with XML.DOM.Attributes; package ODF.DOM.Table_Last_Column_Spanned_Attributes is pragma Preelaborate; type ODF_Table_Last_Column_Spanned_Attribute is limited interface and XML.DOM.Attributes.DOM_Attribute; type ODF_Table_Last_Column_Spanned_Attribute_Access is access all ODF_Table_Last_Column_Spanned_Attribute'Class with Storage_Size => 0; end ODF.DOM.Table_Last_Column_Spanned_Attributes;
reznikmm/matreshka
Ada
3,935
ads
------------------------------------------------------------------------------ -- -- -- Matreshka Project -- -- -- -- Open Document Toolkit -- -- -- -- Runtime Library Component -- -- -- ------------------------------------------------------------------------------ -- -- -- Copyright © 2013, Vadim Godunko <[email protected]> -- -- All rights reserved. -- -- -- -- Redistribution and use in source and binary forms, with or without -- -- modification, are permitted provided that the following conditions -- -- are met: -- -- -- -- * Redistributions of source code must retain the above copyright -- -- notice, this list of conditions and the following disclaimer. -- -- -- -- * Redistributions in binary form must reproduce the above copyright -- -- notice, this list of conditions and the following disclaimer in the -- -- documentation and/or other materials provided with the distribution. -- -- -- -- * Neither the name of the Vadim Godunko, IE nor the names of its -- -- contributors may be used to endorse or promote products derived from -- -- this software without specific prior written permission. -- -- -- -- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -- -- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -- -- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -- -- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -- -- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -- -- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED -- -- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -- -- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -- -- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -- -- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -- -- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- -- -- ------------------------------------------------------------------------------ -- $Revision$ $Date$ ------------------------------------------------------------------------------ with Matreshka.ODF_Elements.Style.Table_Row_Properties; package ODF.DOM.Elements.Style.Table_Row_Properties.Internals is function Create (Node : Matreshka.ODF_Elements.Style.Table_Row_Properties.Style_Table_Row_Properties_Access) return ODF.DOM.Elements.Style.Table_Row_Properties.ODF_Style_Table_Row_Properties; function Wrap (Node : Matreshka.ODF_Elements.Style.Table_Row_Properties.Style_Table_Row_Properties_Access) return ODF.DOM.Elements.Style.Table_Row_Properties.ODF_Style_Table_Row_Properties; end ODF.DOM.Elements.Style.Table_Row_Properties.Internals;
AdaCore/gpr
Ada
156
adb
with GNAT.IO; use GNAT.IO; procedure main is procedure Test; pragma Import (C, Test, "test"); begin Test; Put_Line ("Hello World!"); end main;
onox/orka
Ada
1,852
ads
-- SPDX-License-Identifier: Apache-2.0 -- -- Copyright (c) 2021 onox <[email protected]> -- -- Licensed under the Apache License, Version 2.0 (the "License"); -- you may not use this file except in compliance with the License. -- You may obtain a copy of the License at -- -- http://www.apache.org/licenses/LICENSE-2.0 -- -- Unless required by applicable law or agreed to in writing, software -- distributed under the License is distributed on an "AS IS" BASIS, -- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -- See the License for the specific language governing permissions and -- limitations under the License. package Orka.Integrators is pragma Preelaborate; generic type Value is private; type Derivative is private; type Duration_Type is digits <>; with function "*" (Left : Duration_Type; Right : Derivative) return Derivative is <>; with function "+" (Left : Value; Right : Derivative) return Value is <>; with function "+" (Left : Derivative; Right : Derivative) return Derivative is <>; function RK4 (Y : Value; DT : Duration_Type; F : not null access function (Y : Value; DT : Duration_Type) return Derivative) return Derivative; -- Return the change to Y for the given DT time step using -- the Runge-Kutta 4th order method -- -- If F represent a time-variant system, that is, F depends on a time T, -- then you must compute the derivative at time T + DT. In this case you -- must keep track of T yourself and add it to the given DT. -- -- The returned value must be added to Y to perform the numerical integration. -- -- For example, to numerically integrate a position 10 times per second: -- -- X := X + RK4 (X, 0.1, DX'Access); end Orka.Integrators;
twdroeger/ada-awa
Ada
1,357
ads
----------------------------------------------------------------------- -- awa-wikis -- Wiki module -- Copyright (C) 2011, 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. ----------------------------------------------------------------------- -- = Wikis Module = -- The `Wikis` module provides a complete wiki system which allows users to create -- their own wiki environment with their wiki pages. -- -- @include awa-wikis-modules.ads -- -- @include awa-wikis-beans.ads -- -- == Queries == -- @include-query wiki-page.xml -- @include-query wiki-pages.xml -- @include-query wiki-history.xml -- @include-query wiki-list.xml -- -- == Data model == -- [images/awa_wikis_model.png] -- package AWA.Wikis is pragma Preelaborate; end AWA.Wikis;
reznikmm/matreshka
Ada
4,647
adb
------------------------------------------------------------------------------ -- -- -- Matreshka Project -- -- -- -- Open Document Toolkit -- -- -- -- Runtime Library Component -- -- -- ------------------------------------------------------------------------------ -- -- -- Copyright © 2014, Vadim Godunko <[email protected]> -- -- All rights reserved. -- -- -- -- Redistribution and use in source and binary forms, with or without -- -- modification, are permitted provided that the following conditions -- -- are met: -- -- -- -- * Redistributions of source code must retain the above copyright -- -- notice, this list of conditions and the following disclaimer. -- -- -- -- * Redistributions in binary form must reproduce the above copyright -- -- notice, this list of conditions and the following disclaimer in the -- -- documentation and/or other materials provided with the distribution. -- -- -- -- * Neither the name of the Vadim Godunko, IE nor the names of its -- -- contributors may be used to endorse or promote products derived from -- -- this software without specific prior written permission. -- -- -- -- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -- -- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -- -- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -- -- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -- -- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -- -- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED -- -- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -- -- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -- -- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -- -- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -- -- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- -- -- ------------------------------------------------------------------------------ -- $Revision$ $Date$ ------------------------------------------------------------------------------ with Matreshka.DOM_Documents; with Matreshka.ODF_String_Constants; with ODF.DOM.Iterators; with ODF.DOM.Visitors; package body Matreshka.ODF_Draw.Handle_Position_Attributes is ------------ -- Create -- ------------ overriding function Create (Parameters : not null access Matreshka.DOM_Attributes.Attribute_L2_Parameters) return Draw_Handle_Position_Attribute_Node is begin return Self : Draw_Handle_Position_Attribute_Node do Matreshka.ODF_Draw.Constructors.Initialize (Self'Unchecked_Access, Parameters.Document, Matreshka.ODF_String_Constants.Draw_Prefix); end return; end Create; -------------------- -- Get_Local_Name -- -------------------- overriding function Get_Local_Name (Self : not null access constant Draw_Handle_Position_Attribute_Node) return League.Strings.Universal_String is pragma Unreferenced (Self); begin return Matreshka.ODF_String_Constants.Handle_Position_Attribute; end Get_Local_Name; begin Matreshka.DOM_Documents.Register_Attribute (Matreshka.ODF_String_Constants.Draw_URI, Matreshka.ODF_String_Constants.Handle_Position_Attribute, Draw_Handle_Position_Attribute_Node'Tag); end Matreshka.ODF_Draw.Handle_Position_Attributes;
reznikmm/matreshka
Ada
4,899
ads
------------------------------------------------------------------------------ -- -- -- Matreshka Project -- -- -- -- Ada Modeling Framework -- -- -- -- Runtime Library Component -- -- -- ------------------------------------------------------------------------------ -- -- -- Copyright © 2012-2013, Vadim Godunko <[email protected]> -- -- All rights reserved. -- -- -- -- Redistribution and use in source and binary forms, with or without -- -- modification, are permitted provided that the following conditions -- -- are met: -- -- -- -- * Redistributions of source code must retain the above copyright -- -- notice, this list of conditions and the following disclaimer. -- -- -- -- * Redistributions in binary form must reproduce the above copyright -- -- notice, this list of conditions and the following disclaimer in the -- -- documentation and/or other materials provided with the distribution. -- -- -- -- * Neither the name of the Vadim Godunko, IE nor the names of its -- -- contributors may be used to endorse or promote products derived from -- -- this software without specific prior written permission. -- -- -- -- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -- -- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -- -- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -- -- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -- -- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -- -- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED -- -- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -- -- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -- -- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -- -- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -- -- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- -- -- ------------------------------------------------------------------------------ -- $Revision$ $Date$ ------------------------------------------------------------------------------ -- This file is generated, don't edit it. ------------------------------------------------------------------------------ with AMF.Generic_Collections; package AMF.OCL.Bag_Types.Collections is pragma Preelaborate; package OCL_Bag_Type_Collections is new AMF.Generic_Collections (OCL_Bag_Type, OCL_Bag_Type_Access); type Set_Of_OCL_Bag_Type is new OCL_Bag_Type_Collections.Set with null record; Empty_Set_Of_OCL_Bag_Type : constant Set_Of_OCL_Bag_Type; type Ordered_Set_Of_OCL_Bag_Type is new OCL_Bag_Type_Collections.Ordered_Set with null record; Empty_Ordered_Set_Of_OCL_Bag_Type : constant Ordered_Set_Of_OCL_Bag_Type; type Bag_Of_OCL_Bag_Type is new OCL_Bag_Type_Collections.Bag with null record; Empty_Bag_Of_OCL_Bag_Type : constant Bag_Of_OCL_Bag_Type; type Sequence_Of_OCL_Bag_Type is new OCL_Bag_Type_Collections.Sequence with null record; Empty_Sequence_Of_OCL_Bag_Type : constant Sequence_Of_OCL_Bag_Type; private Empty_Set_Of_OCL_Bag_Type : constant Set_Of_OCL_Bag_Type := (OCL_Bag_Type_Collections.Set with null record); Empty_Ordered_Set_Of_OCL_Bag_Type : constant Ordered_Set_Of_OCL_Bag_Type := (OCL_Bag_Type_Collections.Ordered_Set with null record); Empty_Bag_Of_OCL_Bag_Type : constant Bag_Of_OCL_Bag_Type := (OCL_Bag_Type_Collections.Bag with null record); Empty_Sequence_Of_OCL_Bag_Type : constant Sequence_Of_OCL_Bag_Type := (OCL_Bag_Type_Collections.Sequence with null record); end AMF.OCL.Bag_Types.Collections;
zhmu/ananas
Ada
56,063
ads
------------------------------------------------------------------------------ -- -- -- GNAT LIBRARY COMPONENTS -- -- -- -- G N A T . S P I T B O L . P A T T E R N S -- -- -- -- S p e c -- -- -- -- Copyright (C) 1997-2022, AdaCore -- -- -- -- GNAT is free software; you can redistribute it and/or modify it under -- -- terms of the GNU General Public License as published by the Free Soft- -- -- ware Foundation; either version 3, or (at your option) any later ver- -- -- sion. GNAT is distributed in the hope that it will be useful, but WITH- -- -- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY -- -- or FITNESS FOR A PARTICULAR PURPOSE. -- -- -- -- As a special exception under Section 7 of GPL version 3, you are granted -- -- additional permissions described in the GCC Runtime Library Exception, -- -- version 3.1, as published by the Free Software Foundation. -- -- -- -- You should have received a copy of the GNU General Public License and -- -- a copy of the GCC Runtime Library Exception along with this program; -- -- see the files COPYING3 and COPYING.RUNTIME respectively. If not, see -- -- <http://www.gnu.org/licenses/>. -- -- -- -- GNAT was originally developed by the GNAT team at New York University. -- -- Extensive contributions were provided by Ada Core Technologies Inc. -- -- -- ------------------------------------------------------------------------------ -- SPITBOL-like pattern construction and matching -- This child package of GNAT.SPITBOL provides a complete implementation -- of the SPITBOL-like pattern construction and matching operations. This -- package is based on Macro-SPITBOL created by Robert Dewar. ------------------------------------------------------------ -- Summary of Pattern Matching Packages in GNAT Hierarchy -- ------------------------------------------------------------ -- There are three related packages that perform pattern matching functions. -- the following is an outline of these packages, to help you determine -- which is best for your needs. -- GNAT.Regexp (files g-regexp.ads/g-regexp.adb) -- This is a simple package providing Unix-style regular expression -- matching with the restriction that it matches entire strings. It -- is particularly useful for file name matching, and in particular -- it provides "globbing patterns" that are useful in implementing -- unix or DOS style wildcard matching for file names. -- GNAT.Regpat (files g-regpat.ads/g-regpat.adb) -- This is a more complete implementation of Unix-style regular -- expressions, copied from the original V7 style regular expression -- library written in C by Henry Spencer. It is functionally the -- same as this library, and uses the same internal data structures -- stored in a binary compatible manner. -- GNAT.Spitbol.Patterns (files g-spipat.ads/g-spipat.adb) -- This is a completely general patterm matching package based on the -- pattern language of SNOBOL4, as implemented in SPITBOL. The pattern -- language is modeled on context free grammars, with context sensitive -- extensions that provide full (type 0) computational capabilities. with Ada.Strings.Maps; use Ada.Strings.Maps; with Ada.Text_IO; use Ada.Text_IO; package GNAT.Spitbol.Patterns is pragma Elaborate_Body; ------------------------------- -- Pattern Matching Tutorial -- ------------------------------- -- A pattern matching operation (a call to one of the Match subprograms) -- takes a subject string and a pattern, and optionally a replacement -- string. The replacement string option is only allowed if the subject -- is a variable. -- The pattern is matched against the subject string, and either the -- match fails, or it succeeds matching a contiguous substring. If a -- replacement string is specified, then the subject string is modified -- by replacing the matched substring with the given replacement. -- Concatenation and Alternation -- ============================= -- A pattern consists of a series of pattern elements. The pattern is -- built up using either the concatenation operator: -- A & B -- which means match A followed immediately by matching B, or the -- alternation operator: -- A or B -- which means first attempt to match A, and then if that does not -- succeed, match B. -- There is full backtracking, which means that if a given pattern -- element fails to match, then previous alternatives are matched. -- For example if we have the pattern: -- (A or B) & (C or D) & (E or F) -- First we attempt to match A, if that succeeds, then we go on to try -- to match C, and if that succeeds, we go on to try to match E. If E -- fails, then we try F. If F fails, then we go back and try matching -- D instead of C. Let's make this explicit using a specific example, -- and introducing the simplest kind of pattern element, which is a -- literal string. The meaning of this pattern element is simply to -- match the characters that correspond to the string characters. Now -- let's rewrite the above pattern form with specific string literals -- as the pattern elements: -- ("ABC" or "AB") & ("DEF" or "CDE") & ("GH" or "IJ") -- The following strings will be attempted in sequence: -- ABC . DEF . GH -- ABC . DEF . IJ -- ABC . CDE . GH -- ABC . CDE . IJ -- AB . DEF . GH -- AB . DEF . IJ -- AB . CDE . GH -- AB . CDE . IJ -- Here we use the dot simply to separate the pieces of the string -- matched by the three separate elements. -- Moving the Start Point -- ====================== -- A pattern is not required to match starting at the first character -- of the string, and is not required to match to the end of the string. -- The first attempt does indeed attempt to match starting at the first -- character of the string, trying all the possible alternatives. But -- if all alternatives fail, then the starting point of the match is -- moved one character, and all possible alternatives are attempted at -- the new anchor point. -- The entire match fails only when every possible starting point has -- been attempted. As an example, suppose that we had the subject -- string -- "ABABCDEIJKL" -- matched using the pattern in the previous example: -- ("ABC" or "AB") & ("DEF" or "CDE") & ("GH" or "IJ") -- would succeed, after two anchor point moves: -- "ABABCDEIJKL" -- ^^^^^^^ -- matched -- section -- This mode of pattern matching is called the unanchored mode. It is -- also possible to put the pattern matcher into anchored mode by -- setting the global variable Anchored_Mode to True. This will cause -- all subsequent matches to be performed in anchored mode, where the -- match is required to start at the first character. -- We will also see later how the effect of an anchored match can be -- obtained for a single specified anchor point if this is desired. -- Other Pattern Elements -- ====================== -- In addition to strings (or single characters), there are many special -- pattern elements that correspond to special predefined alternations: -- Arb Matches any string. First it matches the null string, and -- then on a subsequent failure, matches one character, and -- then two characters, and so on. It only fails if the -- entire remaining string is matched. -- Bal Matches a non-empty string that is parentheses balanced -- with respect to ordinary () characters. Examples of -- balanced strings are "ABC", "A((B)C)", and "A(B)C(D)E". -- Bal matches the shortest possible balanced string on the -- first attempt, and if there is a subsequent failure, -- attempts to extend the string. -- Cancel Immediately aborts the entire pattern match, signalling -- failure. This is a specialized pattern element, which is -- useful in conjunction with some of the special pattern -- elements that have side effects. -- Fail The null alternation. Matches no possible strings, so it -- always signals failure. This is a specialized pattern -- element, which is useful in conjunction with some of the -- special pattern elements that have side effects. -- Fence Matches the null string at first, and then if a failure -- causes alternatives to be sought, aborts the match (like -- a Cancel). Note that using Fence at the start of a pattern -- has the same effect as matching in anchored mode. -- Rest Matches from the current point to the last character in -- the string. This is a specialized pattern element, which -- is useful in conjunction with some of the special pattern -- elements that have side effects. -- Succeed Repeatedly matches the null string (it is equivalent to -- the alternation ("" or "" or "" ....). This is a special -- pattern element, which is useful in conjunction with some -- of the special pattern elements that have side effects. -- Pattern Construction Functions -- ============================== -- The following functions construct additional pattern elements -- Any(S) Where S is a string, matches a single character that is -- any one of the characters in S. Fails if the current -- character is not one of the given set of characters. -- Arbno(P) Where P is any pattern, matches any number of instances -- of the pattern, starting with zero occurrences. It is -- thus equivalent to ("" or (P & ("" or (P & ("" ....)))). -- The pattern P may contain any number of pattern elements -- including the use of alternation and concatenation. -- Break(S) Where S is a string, matches a string of zero or more -- characters up to but not including a break character -- that is one of the characters given in the string S. -- Can match the null string, but cannot match the last -- character in the string, since a break character is -- required to be present. -- BreakX(S) Where S is a string, behaves exactly like Break(S) when -- it first matches, but if a string is successfully matched, -- then a subsequent failure causes an attempt to extend the -- matched string. -- Fence(P) Where P is a pattern, attempts to match the pattern P -- including trying all possible alternatives of P. If none -- of these alternatives succeeds, then the Fence pattern -- fails. If one alternative succeeds, then the pattern -- match proceeds, but on a subsequent failure, no attempt -- is made to search for alternative matches of P. The -- pattern P may contain any number of pattern elements -- including the use of alternation and concatenation. -- Len(N) Where N is a natural number, matches the given number of -- characters. For example, Len(10) matches any string that -- is exactly ten characters long. -- NotAny(S) Where S is a string, matches a single character that is -- not one of the characters of S. Fails if the current -- character is one of the given set of characters. -- NSpan(S) Where S is a string, matches a string of zero or more -- characters that is among the characters given in the -- string. Always matches the longest possible such string. -- Always succeeds, since it can match the null string. -- Pos(N) Where N is a natural number, matches the null string -- if exactly N characters have been matched so far, and -- otherwise fails. -- Rpos(N) Where N is a natural number, matches the null string -- if exactly N characters remain to be matched, and -- otherwise fails. -- Rtab(N) Where N is a natural number, matches characters from -- the current position until exactly N characters remain -- to be matched in the string. Fails if fewer than N -- unmatched characters remain in the string. -- Tab(N) Where N is a natural number, matches characters from -- the current position until exactly N characters have -- been matched in all. Fails if more than N characters -- have already been matched. -- Span(S) Where S is a string, matches a string of one or more -- characters that is among the characters given in the -- string. Always matches the longest possible such string. -- Fails if the current character is not one of the given -- set of characters. -- Recursive Pattern Matching -- ========================== -- The plus operator (+P) where P is a pattern variable, creates -- a recursive pattern that will, at pattern matching time, follow -- the pointer to obtain the referenced pattern, and then match this -- pattern. This may be used to construct recursive patterns. Consider -- for example: -- P := ("A" or ("B" & (+P))) -- On the first attempt, this pattern attempts to match the string "A". -- If this fails, then the alternative matches a "B", followed by an -- attempt to match P again. This second attempt first attempts to -- match "A", and so on. The result is a pattern that will match a -- string of B's followed by a single A. -- This particular example could simply be written as NSpan('B') & 'A', -- but the use of recursive patterns in the general case can construct -- complex patterns which could not otherwise be built. -- Pattern Assignment Operations -- ============================= -- In addition to the overall result of a pattern match, which indicates -- success or failure, it is often useful to be able to keep track of -- the pieces of the subject string that are matched by individual -- pattern elements, or subsections of the pattern. -- The pattern assignment operators allow this capability. The first -- form is the immediate assignment: -- P * S -- Here P is an arbitrary pattern, and S is a variable of type VString -- that will be set to the substring matched by P. This assignment -- happens during pattern matching, so if P matches more than once, -- then the assignment happens more than once. -- The deferred assignment operation: -- P ** S -- avoids these multiple assignments by deferring the assignment to the -- end of the match. If the entire match is successful, and if the -- pattern P was part of the successful match, then at the end of the -- matching operation the assignment to S of the string matching P is -- performed. -- The cursor assignment operation: -- Setcur(N'Access) -- assigns the current cursor position to the natural variable N. The -- cursor position is defined as the count of characters that have been -- matched so far (including any start point moves). -- Finally the operations * and ** may be used with values of type -- Text_IO.File_Access. The effect is to do a Put_Line operation of -- the matched substring. These are particularly useful in debugging -- pattern matches. -- Deferred Matching -- ================= -- The pattern construction functions (such as Len and Any) all permit -- the use of pointers to natural or string values, or functions that -- return natural or string values. These forms cause the actual value -- to be obtained at pattern matching time. This allows interesting -- possibilities for constructing dynamic patterns as illustrated in -- the examples section. -- In addition the (+S) operator may be used where S is a pointer to -- string or function returning string, with a similar deferred effect. -- A special use of deferred matching is the construction of predicate -- functions. The element (+P) where P is an access to a function that -- returns a Boolean value, causes the function to be called at the -- time the element is matched. If the function returns True, then the -- null string is matched, if the function returns False, then failure -- is signalled and previous alternatives are sought. -- Deferred Replacement -- ==================== -- The simple model given for pattern replacement (where the matched -- substring is replaced by the string given as the third argument to -- Match) works fine in simple cases, but this approach does not work -- in the case where the expression used as the replacement string is -- dependent on values set by the match. -- For example, suppose we want to find an instance of a parenthesized -- character, and replace the parentheses with square brackets. At first -- glance it would seem that: -- Match (Subject, '(' & Len (1) * Char & ')', '[' & Char & ']'); -- would do the trick, but that does not work, because the third -- argument to Match gets evaluated too early, before the call to -- Match, and before the pattern match has had a chance to set Char. -- To solve this problem we provide the deferred replacement capability. -- With this approach, which of course is only needed if the pattern -- involved has side effects, is to do the match in two stages. The -- call to Match sets a pattern result in a variable of the private -- type Match_Result, and then a subsequent Replace operation uses -- this Match_Result object to perform the required replacement. -- Using this approach, we can now write the above operation properly -- in a manner that will work: -- M : Match_Result; -- ... -- Match (Subject, '(' & Len (1) * Char & ')', M); -- Replace (M, '[' & Char & ']'); -- As with other Match cases, there is a function and procedure form -- of this match call. A call to Replace after a failed match has no -- effect. Note that Subject should not be modified between the calls. -- Examples of Pattern Matching -- ============================ -- First a simple example of the use of pattern replacement to remove -- a line number from the start of a string. We assume that the line -- number has the form of a string of decimal digits followed by a -- period, followed by one or more spaces. -- Digs : constant Pattern := Span("0123456789"); -- Lnum : constant Pattern := Pos(0) & Digs & '.' & Span(' '); -- Now to use this pattern we simply do a match with a replacement: -- Match (Line, Lnum, ""); -- which replaces the line number by the null string. Note that it is -- also possible to use an Ada.Strings.Maps.Character_Set value as an -- argument to Span and similar functions, and in particular all the -- useful constants 'in Ada.Strings.Maps.Constants are available. This -- means that we could define Digs as: -- Digs : constant Pattern := Span(Decimal_Digit_Set); -- The style we use here, of defining constant patterns and then using -- them is typical. It is possible to build up patterns dynamically, -- but it is usually more efficient to build them in pieces in advance -- using constant declarations. Note in particular that although it is -- possible to construct a pattern directly as an argument for the -- Match routine, it is much more efficient to preconstruct the pattern -- as we did in this example. -- Now let's look at the use of pattern assignment to break a -- string into sections. Suppose that the input string has two -- unsigned decimal integers, separated by spaces or a comma, -- with spaces allowed anywhere. Then we can isolate the two -- numbers with the following pattern: -- Num1, Num2 : aliased VString; -- B : constant Pattern := NSpan(' '); -- N : constant Pattern := Span("0123456789"); -- T : constant Pattern := -- NSpan(' ') & N * Num1 & Span(" ,") & N * Num2; -- The match operation Match (" 124, 257 ", T) would assign the -- string 124 to Num1 and the string 257 to Num2. -- Now let's see how more complex elements can be built from the -- set of primitive elements. The following pattern matches strings -- that have the syntax of Ada 95 based literals: -- Digs : constant Pattern := Span(Decimal_Digit_Set); -- UDigs : constant Pattern := Digs & Arbno('_' & Digs); -- Edig : constant Pattern := Span(Hexadecimal_Digit_Set); -- UEdig : constant Pattern := Edig & Arbno('_' & Edig); -- Bnum : constant Pattern := Udigs & '#' & UEdig & '#'; -- A match against Bnum will now match the desired strings, e.g. -- it will match 16#123_abc#, but not a#b#. However, this pattern -- is not quite complete, since it does not allow colons to replace -- the pound signs. The following is more complete: -- Bchar : constant Pattern := Any("#:"); -- Bnum : constant Pattern := Udigs & Bchar & UEdig & Bchar; -- but that is still not quite right, since it allows # and : to be -- mixed, and they are supposed to be used consistently. We solve -- this by using a deferred match. -- Temp : aliased VString; -- Bnum : constant Pattern := -- Udigs & Bchar * Temp & UEdig & (+Temp) -- Here the first instance of the base character is stored in Temp, and -- then later in the pattern we rematch the value that was assigned. -- For an example of a recursive pattern, let's define a pattern -- that is like the built in Bal, but the string matched is balanced -- with respect to square brackets or curly brackets. -- The language for such strings might be defined in extended BNF as -- ELEMENT ::= <any character other than [] or {}> -- | '[' BALANCED_STRING ']' -- | '{' BALANCED_STRING '}' -- BALANCED_STRING ::= ELEMENT {ELEMENT} -- Here we use {} to indicate zero or more occurrences of a term, as -- is common practice in extended BNF. Now we can translate the above -- BNF into recursive patterns as follows: -- Element, Balanced_String : aliased Pattern; -- . -- . -- . -- Element := NotAny ("[]{}") -- or -- ('[' & (+Balanced_String) & ']') -- or -- ('{' & (+Balanced_String) & '}'); -- Balanced_String := Element & Arbno (Element); -- Note the important use of + here to refer to a pattern not yet -- defined. Note also that we use assignments precisely because we -- cannot refer to as yet undeclared variables in initializations. -- Now that this pattern is constructed, we can use it as though it -- were a new primitive pattern element, and for example, the match: -- Match ("xy[ab{cd}]", Balanced_String * Current_Output & Fail); -- will generate the output: -- x -- xy -- xy[ab{cd}] -- y -- y[ab{cd}] -- [ab{cd}] -- a -- ab -- ab{cd} -- b -- b{cd} -- {cd} -- c -- cd -- d -- Note that the function of the fail here is simply to force the -- pattern Balanced_String to match all possible alternatives. Studying -- the operation of this pattern in detail is highly instructive. -- Finally we give a rather elaborate example of the use of deferred -- matching. The following declarations build up a pattern which will -- find the longest string of decimal digits in the subject string. -- Max, Cur : VString; -- Loc : Natural; -- function GtS return Boolean is -- begin -- return Length (Cur) > Length (Max); -- end GtS; -- Digit : constant Character_Set := Decimal_Digit_Set; -- Digs : constant Pattern := Span(Digit); -- Find : constant Pattern := -- "" * Max & Fence & -- initialize Max to null -- BreakX (Digit) & -- scan looking for digits -- ((Span(Digit) * Cur & -- assign next string to Cur -- (+GtS'Unrestricted_Access) & -- check size(Cur) > Size(Max) -- Setcur(Loc'Access)) -- if so, save location -- * Max) & -- and assign to Max -- Fail; -- seek all alternatives -- As we see from the comments here, complex patterns like this take -- on aspects of sequential programs. In fact they are sequential -- programs with general backtracking. In this pattern, we first use -- a pattern assignment that matches null and assigns it to Max, so -- that it is initialized for the new match. Now BreakX scans to the -- next digit. Arb would do here, but BreakX will be more efficient. -- Once we have found a digit, we scan out the longest string of -- digits with Span, and assign it to Cur. The deferred call to GtS -- tests if the string we assigned to Cur is the longest so far. If -- not, then failure is signalled, and we seek alternatives (this -- means that BreakX will extend and look for the next digit string). -- If the call to GtS succeeds then the matched string is assigned -- as the largest string so far into Max and its location is saved -- in Loc. Finally Fail forces the match to fail and seek alternatives, -- so that the entire string is searched. -- If the pattern Find is matched against a string, the variable Max -- at the end of the pattern will have the longest string of digits, -- and Loc will be the starting character location of the string. For -- example, Match("ab123cd4657ef23", Find) will assign "4657" to Max -- and 11 to Loc (indicating that the string ends with the eleventh -- character of the string). -- Note: the use of Unrestricted_Access to reference GtS will not -- be needed if GtS is defined at the outer level, but definitely -- will be necessary if GtS is a nested function (in which case of -- course the scope of the pattern Find will be restricted to this -- nested scope, and this cannot be checked, i.e. use of the pattern -- outside this scope is erroneous). Generally it is a good idea to -- define patterns and the functions they call at the outer level -- where possible, to avoid such problems. -- Correspondence with Pattern Matching in SPITBOL -- =============================================== -- Generally the Ada syntax and names correspond closely to SPITBOL -- syntax for pattern matching construction. -- The basic pattern construction operators are renamed as follows: -- Spitbol Ada -- (space) & -- | or -- $ * -- . ** -- The Ada operators were chosen so that the relative precedences of -- these operators corresponds to that of the Spitbol operators, but -- as always, the use of parentheses is advisable to clarify. -- The pattern construction operators all have similar names except for -- Spitbol Ada -- Abort Cancel -- Rem Rest -- where we have clashes with Ada reserved names -- Ada requires the use of 'Access to refer to functions used in the -- pattern match, and often the use of 'Unrestricted_Access may be -- necessary to get around the scope restrictions if the functions -- are not declared at the outer level. -- The actual pattern matching syntax is modified in Ada as follows: -- Spitbol Ada -- X Y Match (X, Y); -- X Y = Z Match (X, Y, Z); -- and pattern failure is indicated by returning a Boolean result from -- the Match function (True for success, False for failure). ----------------------- -- Type Declarations -- ----------------------- type Pattern is private; -- Type representing a pattern. This package provides a complete set of -- operations for constructing patterns that can be used in the pattern -- matching operations provided. type Boolean_Func is access function return Boolean with Favor_Top_Level; -- General Boolean function type. When this type is used as a formal -- parameter type in this package, it indicates a deferred predicate -- pattern. The function will be called when the pattern element is -- matched and failure signalled if False is returned. type Natural_Func is access function return Natural with Favor_Top_Level; -- General Natural function type. When this type is used as a formal -- parameter type in this package, it indicates a deferred pattern. -- The function will be called when the pattern element is matched -- to obtain the currently referenced Natural value. type VString_Func is access function return VString with Favor_Top_Level; -- General VString function type. When this type is used as a formal -- parameter type in this package, it indicates a deferred pattern. -- The function will be called when the pattern element is matched -- to obtain the currently referenced string value. subtype PString is String; -- This subtype is used in the remainder of the package to indicate a -- formal parameter that is converted to its corresponding pattern, -- i.e. a pattern that matches the characters of the string. subtype PChar is Character; -- Similarly, this subtype is used in the remainder of the package to -- indicate a formal parameter that is converted to its corresponding -- pattern, i.e. a pattern that matches this one character. subtype VString_Var is VString; subtype Pattern_Var is Pattern; -- These synonyms are used as formal parameter types to a function where, -- if the language allowed, we would use in out parameters, but we are -- not allowed to have in out parameters for functions. Instead we pass -- actuals which must be variables, and with a bit of trickery in the -- body, manage to interpret them properly as though they were indeed -- in out parameters. pragma Warnings (Off, VString_Var); pragma Warnings (Off, Pattern_Var); -- We turn off warnings for these two types so that when variables are used -- as arguments in this context, warnings about them not being assigned in -- the source program will be suppressed. -------------------------------- -- Basic Pattern Construction -- -------------------------------- function "&" (L : Pattern; R : Pattern) return Pattern; function "&" (L : PString; R : Pattern) return Pattern; function "&" (L : Pattern; R : PString) return Pattern; function "&" (L : PChar; R : Pattern) return Pattern; function "&" (L : Pattern; R : PChar) return Pattern; -- Pattern concatenation. Matches L followed by R function "or" (L : Pattern; R : Pattern) return Pattern; function "or" (L : PString; R : Pattern) return Pattern; function "or" (L : Pattern; R : PString) return Pattern; function "or" (L : PString; R : PString) return Pattern; function "or" (L : PChar; R : Pattern) return Pattern; function "or" (L : Pattern; R : PChar) return Pattern; function "or" (L : PChar; R : PChar) return Pattern; function "or" (L : PString; R : PChar) return Pattern; function "or" (L : PChar; R : PString) return Pattern; -- Pattern alternation. Creates a pattern that will first try to match -- L and then on a subsequent failure, attempts to match R instead. ---------------------------------- -- Pattern Assignment Functions -- ---------------------------------- function "*" (P : Pattern; Var : VString_Var) return Pattern; function "*" (P : PString; Var : VString_Var) return Pattern; function "*" (P : PChar; Var : VString_Var) return Pattern; -- Matches P, and if the match succeeds, assigns the matched substring -- to the given VString variable Var. This assignment happens as soon as -- the substring is matched, and if the pattern P1 is matched more than -- once during the course of the match, then the assignment will occur -- more than once. function "**" (P : Pattern; Var : VString_Var) return Pattern; function "**" (P : PString; Var : VString_Var) return Pattern; function "**" (P : PChar; Var : VString_Var) return Pattern; -- Like "*" above, except that the assignment happens at most once -- after the entire match is completed successfully. If the match -- fails, then no assignment takes place. ---------------------------------- -- Deferred Matching Operations -- ---------------------------------- function "+" (Str : VString_Var) return Pattern; -- Here Str must be a VString variable. This function constructs a -- pattern which at pattern matching time will access the current -- value of this variable, and match against these characters. function "+" (Str : VString_Func) return Pattern; -- Constructs a pattern which at pattern matching time calls the given -- function, and then matches against the string or character value -- that is returned by the call. function "+" (P : Pattern_Var) return Pattern; -- Here P must be a Pattern variable. This function constructs a -- pattern which at pattern matching time will access the current -- value of this variable, and match against the pattern value. function "+" (P : Boolean_Func) return Pattern; -- Constructs a predicate pattern function that at pattern matching time -- calls the given function. If True is returned, then the pattern matches. -- If False is returned, then failure is signalled. -------------------------------- -- Pattern Building Functions -- -------------------------------- function Arb return Pattern; -- Constructs a pattern that will match any string. On the first attempt, -- the pattern matches a null string, then on each successive failure, it -- matches one more character, and only fails if matching the entire rest -- of the string. function Arbno (P : Pattern) return Pattern; function Arbno (P : PString) return Pattern; function Arbno (P : PChar) return Pattern; -- Pattern repetition. First matches null, then on a subsequent failure -- attempts to match an additional instance of the given pattern. -- Equivalent to (but more efficient than) P & ("" or (P & ("" or ... function Any (Str : String) return Pattern; function Any (Str : VString) return Pattern; function Any (Str : Character) return Pattern; function Any (Str : Character_Set) return Pattern; function Any (Str : not null access VString) return Pattern; function Any (Str : VString_Func) return Pattern; -- Constructs a pattern that matches a single character that is one of -- the characters in the given argument. The pattern fails if the current -- character is not in Str. function Bal return Pattern; -- Constructs a pattern that will match any non-empty string that is -- parentheses balanced with respect to the normal parentheses characters. -- Attempts to extend the string if a subsequent failure occurs. function Break (Str : String) return Pattern; function Break (Str : VString) return Pattern; function Break (Str : Character) return Pattern; function Break (Str : Character_Set) return Pattern; function Break (Str : not null access VString) return Pattern; function Break (Str : VString_Func) return Pattern; -- Constructs a pattern that matches a (possibly null) string which -- is immediately followed by a character in the given argument. This -- character is not part of the matched string. The pattern fails if -- the remaining characters to be matched do not include any of the -- characters in Str. function BreakX (Str : String) return Pattern; function BreakX (Str : VString) return Pattern; function BreakX (Str : Character) return Pattern; function BreakX (Str : Character_Set) return Pattern; function BreakX (Str : not null access VString) return Pattern; function BreakX (Str : VString_Func) return Pattern; -- Like Break, but the pattern attempts to extend on a failure to find -- the next occurrence of a character in Str, and only fails when the -- last such instance causes a failure. function Cancel return Pattern; -- Constructs a pattern that immediately aborts the entire match function Fail return Pattern; -- Constructs a pattern that always fails function Fence return Pattern; -- Constructs a pattern that matches null on the first attempt, and then -- causes the entire match to be aborted if a subsequent failure occurs. function Fence (P : Pattern) return Pattern; -- Constructs a pattern that first matches P. If P fails, then the -- constructed pattern fails. If P succeeds, then the match proceeds, -- but if subsequent failure occurs, alternatives in P are not sought. -- The idea of Fence is that each time the pattern is matched, just -- one attempt is made to match P, without trying alternatives. function Len (Count : Natural) return Pattern; function Len (Count : not null access Natural) return Pattern; function Len (Count : Natural_Func) return Pattern; -- Constructs a pattern that matches exactly the given number of -- characters. The pattern fails if fewer than this number of characters -- remain to be matched in the string. function NotAny (Str : String) return Pattern; function NotAny (Str : VString) return Pattern; function NotAny (Str : Character) return Pattern; function NotAny (Str : Character_Set) return Pattern; function NotAny (Str : not null access VString) return Pattern; function NotAny (Str : VString_Func) return Pattern; -- Constructs a pattern that matches a single character that is not -- one of the characters in the given argument. The pattern Fails if -- the current character is in Str. function NSpan (Str : String) return Pattern; function NSpan (Str : VString) return Pattern; function NSpan (Str : Character) return Pattern; function NSpan (Str : Character_Set) return Pattern; function NSpan (Str : not null access VString) return Pattern; function NSpan (Str : VString_Func) return Pattern; -- Constructs a pattern that matches the longest possible string -- consisting entirely of characters from the given argument. The -- string may be empty, so this pattern always succeeds. function Pos (Count : Natural) return Pattern; function Pos (Count : not null access Natural) return Pattern; function Pos (Count : Natural_Func) return Pattern; -- Constructs a pattern that matches the null string if exactly Count -- characters have already been matched, and otherwise fails. function Rest return Pattern; -- Constructs a pattern that always succeeds, matching the remaining -- unmatched characters in the pattern. function Rpos (Count : Natural) return Pattern; function Rpos (Count : not null access Natural) return Pattern; function Rpos (Count : Natural_Func) return Pattern; -- Constructs a pattern that matches the null string if exactly Count -- characters remain to be matched in the string, and otherwise fails. function Rtab (Count : Natural) return Pattern; function Rtab (Count : not null access Natural) return Pattern; function Rtab (Count : Natural_Func) return Pattern; -- Constructs a pattern that matches from the current location until -- exactly Count characters remain to be matched in the string. The -- pattern fails if fewer than Count characters remain to be matched. function Setcur (Var : not null access Natural) return Pattern; -- Constructs a pattern that matches the null string, and assigns the -- current cursor position in the string. This value is the number of -- characters matched so far. So it is zero at the start of the match. function Span (Str : String) return Pattern; function Span (Str : VString) return Pattern; function Span (Str : Character) return Pattern; function Span (Str : Character_Set) return Pattern; function Span (Str : not null access VString) return Pattern; function Span (Str : VString_Func) return Pattern; -- Constructs a pattern that matches the longest possible string -- consisting entirely of characters from the given argument. The -- string cannot be empty, so the pattern fails if the current -- character is not one of the characters in Str. function Succeed return Pattern; -- Constructs a pattern that succeeds matching null, both on the first -- attempt, and on any rematch attempt, i.e. it is equivalent to an -- infinite alternation of null strings. function Tab (Count : Natural) return Pattern; function Tab (Count : not null access Natural) return Pattern; function Tab (Count : Natural_Func) return Pattern; -- Constructs a pattern that from the current location until Count -- characters have been matched. The pattern fails if more than Count -- characters have already been matched. --------------------------------- -- Pattern Matching Operations -- --------------------------------- -- The Match function performs an actual pattern matching operation. -- The versions with three parameters perform a match without modifying -- the subject string and return a Boolean result indicating if the -- match is successful or not. The Anchor parameter is set to True to -- obtain an anchored match in which the pattern is required to match -- the first character of the string. In an unanchored match, which is -- the default, successive attempts are made to match the given pattern -- at each character of the subject string until a match succeeds, or -- until all possibilities have failed. -- Note that pattern assignment functions in the pattern may generate -- side effects, so these functions are not necessarily pure. Anchored_Mode : Boolean := False; -- This global variable can be set True to cause all subsequent pattern -- matches to operate in anchored mode. In anchored mode, no attempt is -- made to move the anchor point, so that if the match succeeds it must -- succeed starting at the first character. Note that the effect of -- anchored mode may be achieved in individual pattern matches by using -- Fence or Pos(0) at the start of the pattern. Pattern_Stack_Overflow : exception; -- Exception raised if internal pattern matching stack overflows. This -- is typically the result of runaway pattern recursion. If there is a -- genuine case of stack overflow, then either the match must be broken -- down into simpler steps, or the stack limit must be reset. Stack_Size : constant Positive := 2000; -- Size used for internal pattern matching stack. Increase this size if -- complex patterns cause Pattern_Stack_Overflow to be raised. -- Simple match functions. The subject is matched against the pattern. -- Any immediate or deferred assignments or writes are executed, and -- the returned value indicates whether or not the match succeeded. function Match (Subject : VString; Pat : Pattern) return Boolean; function Match (Subject : VString; Pat : PString) return Boolean; function Match (Subject : String; Pat : Pattern) return Boolean; function Match (Subject : String; Pat : PString) return Boolean; -- Replacement functions. The subject is matched against the pattern. -- Any immediate or deferred assignments or writes are executed, and -- the returned value indicates whether or not the match succeeded. -- If the match succeeds, then the matched part of the subject string -- is replaced by the given Replace string. function Match (Subject : VString_Var; Pat : Pattern; Replace : VString) return Boolean; function Match (Subject : VString_Var; Pat : PString; Replace : VString) return Boolean; function Match (Subject : VString_Var; Pat : Pattern; Replace : String) return Boolean; function Match (Subject : VString_Var; Pat : PString; Replace : String) return Boolean; -- Simple match procedures. The subject is matched against the pattern. -- Any immediate or deferred assignments or writes are executed. No -- indication of success or failure is returned. procedure Match (Subject : VString; Pat : Pattern); procedure Match (Subject : VString; Pat : PString); procedure Match (Subject : String; Pat : Pattern); procedure Match (Subject : String; Pat : PString); -- Replacement procedures. The subject is matched against the pattern. -- Any immediate or deferred assignments or writes are executed. No -- indication of success or failure is returned. If the match succeeds, -- then the matched part of the subject string is replaced by the given -- Replace string. procedure Match (Subject : in out VString; Pat : Pattern; Replace : VString); procedure Match (Subject : in out VString; Pat : PString; Replace : VString); procedure Match (Subject : in out VString; Pat : Pattern; Replace : String); procedure Match (Subject : in out VString; Pat : PString; Replace : String); -- Deferred Replacement type Match_Result is private; -- Type used to record result of pattern match subtype Match_Result_Var is Match_Result; -- This synonyms is used as a formal parameter type to a function where, -- if the language allowed, we would use an in out parameter, but we are -- not allowed to have in out parameters for functions. Instead we pass -- actuals which must be variables, and with a bit of trickery in the -- body, manage to interpret them properly as though they were indeed -- in out parameters. function Match (Subject : VString_Var; Pat : Pattern; Result : Match_Result_Var) return Boolean; procedure Match (Subject : in out VString; Pat : Pattern; Result : out Match_Result); procedure Replace (Result : in out Match_Result; Replace : VString); -- Given a previous call to Match which set Result, performs a pattern -- replacement if the match was successful. Has no effect if the match -- failed. This call should immediately follow the Match call. ------------------------ -- Debugging Routines -- ------------------------ -- Debugging pattern matching operations can often be quite complex, -- since there is no obvious way to trace the progress of the match. -- The declarations in this section provide some debugging assistance. Debug_Mode : Boolean := False; -- This global variable can be set True to generate debugging on all -- subsequent calls to Match. The debugging output is a full trace of -- the actions of the pattern matcher, written to Standard_Output. The -- level of this information is intended to be comprehensible at the -- abstract level of this package declaration. However, note that the -- use of this switch often generates large amounts of output. function "*" (P : Pattern; Fil : File_Access) return Pattern; function "*" (P : PString; Fil : File_Access) return Pattern; function "*" (P : PChar; Fil : File_Access) return Pattern; function "**" (P : Pattern; Fil : File_Access) return Pattern; function "**" (P : PString; Fil : File_Access) return Pattern; function "**" (P : PChar; Fil : File_Access) return Pattern; -- These are similar to the corresponding pattern assignment operations -- except that instead of setting the value of a variable, the matched -- substring is written to the appropriate file. This can be useful in -- following the progress of a match without generating the full amount -- of information obtained by setting Debug_Mode to True. Terminal : constant File_Access := Standard_Error; Output : constant File_Access := Standard_Output; -- Two handy synonyms for use with the above pattern write operations -- Finally we have some routines that are useful for determining what -- patterns are in use, particularly if they are constructed dynamically. function Image (P : Pattern) return String; function Image (P : Pattern) return VString; -- This procedures yield strings that corresponds to the syntax needed -- to create the given pattern using the functions in this package. The -- form of this string is such that it could actually be compiled and -- evaluated to yield the required pattern except for references to -- variables and functions, which are output using one of the following -- forms: -- -- access Natural NP(16#...#) -- access Pattern PP(16#...#) -- access VString VP(16#...#) -- -- Natural_Func NF(16#...#) -- VString_Func VF(16#...#) -- -- where 16#...# is the hex representation of the integer address that -- corresponds to the given access value procedure Dump (P : Pattern); -- This procedure writes information about the pattern to Standard_Out. -- The format of this information is keyed to the internal data structures -- used to implement patterns. The information provided by Dump is thus -- more precise than that yielded by Image, but is also a bit more obscure -- (i.e. it cannot be interpreted solely in terms of this spec, you have -- to know something about the data structures). ------------------ -- Private Part -- ------------------ private type PE; -- Pattern element, a pattern is a complex structure of PE's. This type -- is defined and described in the body of this package. type PE_Ptr is access all PE; -- Pattern reference. PE's use PE_Ptr values to reference other PE's type Pattern is new Controlled with record Stk : Natural := 0; -- Maximum number of stack entries required for matching this -- pattern. See description of pattern history stack in body. P : PE_Ptr := null; -- Pointer to initial pattern element for pattern end record; pragma Finalize_Storage_Only (Pattern); procedure Adjust (Object : in out Pattern); -- Adjust routine used to copy pattern objects procedure Finalize (Object : in out Pattern); -- Finalization routine used to release storage allocated for a pattern type VString_Ptr is access all VString; type Match_Result is record Var : VString_Ptr; -- Pointer to subject string. Set to null if match failed Start : Natural := 1; -- Starting index position (1's origin) of matched section of -- subject string. Only valid if Var is non-null. Stop : Natural := 0; -- Ending index position (1's origin) of matched section of -- subject string. Only valid if Var is non-null. end record; pragma Volatile (Match_Result); -- This ensures that the Result parameter is passed by reference, so -- that we can play our games with the bogus Match_Result_Var parameter -- in the function case to treat it as though it were an in out parameter. end GNAT.Spitbol.Patterns;
sungyeon/drake
Ada
9,450
ads
pragma License (Unrestricted); -- extended unit with Ada.Iterator_Interfaces; -- diff (Copy_On_Write) private with Ada.Containers.Naked_Doubly_Linked_Lists; private with Ada.Finalization; private with Ada.Streams; generic type Element_Type (<>) is limited private; -- diff ("=") package Ada.Containers.Limited_Doubly_Linked_Lists is pragma Preelaborate; pragma Remote_Types; type List is tagged limited private with Constant_Indexing => Constant_Reference, Variable_Indexing => Reference, Default_Iterator => Iterate, Iterator_Element => Element_Type; pragma Preelaborable_Initialization (List); type Cursor is private; pragma Preelaborable_Initialization (Cursor); -- modified -- Empty_List : constant List; function Empty_List return List; No_Element : constant Cursor; function Has_Element (Position : Cursor) return Boolean; package List_Iterator_Interfaces is new Iterator_Interfaces (Cursor, Has_Element); -- diff ("=") function Length (Container : List) return Count_Type; function Is_Empty (Container : List) return Boolean; procedure Clear (Container : in out List); -- diff (Element) -- diff (Replace_Element) -- -- -- procedure Query_Element ( Position : Cursor; Process : not null access procedure (Element : Element_Type)); -- modified procedure Update_Element ( Container : in out List'Class; -- not primitive Position : Cursor; Process : not null access procedure (Element : in out Element_Type)); type Constant_Reference_Type ( Element : not null access constant Element_Type) is private with Implicit_Dereference => Element; type Reference_Type (Element : not null access Element_Type) is private with Implicit_Dereference => Element; function Constant_Reference (Container : aliased List; Position : Cursor) return Constant_Reference_Type; function Reference (Container : aliased in out List; Position : Cursor) return Reference_Type; -- diff (Assign) -- diff (Copy) procedure Move (Target : in out List; Source : in out List); procedure Insert ( Container : in out List'Class; Before : Cursor; New_Item : not null access function return Element_Type; Count : Count_Type := 1); procedure Insert ( Container : in out List'Class; Before : Cursor; New_Item : not null access function return Element_Type; Position : out Cursor; Count : Count_Type := 1); -- diff (Insert) -- -- -- -- procedure Prepend ( Container : in out List'Class; New_Item : not null access function return Element_Type; Count : Count_Type := 1); procedure Append ( Container : in out List'Class; New_Item : not null access function return Element_Type; Count : Count_Type := 1); procedure Delete ( Container : in out List; Position : in out Cursor; Count : Count_Type := 1); -- modified procedure Delete_First ( Container : in out List'Class; -- not primitive Count : Count_Type := 1); -- modified procedure Delete_Last ( Container : in out List'Class; -- not primitive Count : Count_Type := 1); procedure Reverse_Elements (Container : in out List); procedure Swap (Container : in out List; I, J : Cursor); procedure Swap_Links (Container : in out List; I, J : Cursor); procedure Splice ( Target : in out List; Before : Cursor; Source : in out List); procedure Splice ( Target : in out List; Before : Cursor; Source : in out List; Position : in out Cursor); procedure Splice ( Container : in out List; Before : Cursor; Position : Cursor); function First (Container : List) return Cursor; -- diff (First_Element) -- -- function Last (Container : List) return Cursor; -- diff (Last_Element) -- -- function Next (Position : Cursor) return Cursor; function Previous (Position : Cursor) return Cursor; procedure Next (Position : in out Cursor); procedure Previous (Position : in out Cursor); -- diff (Find) -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- diff (Reverse_Find) -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- diff (Contains) -- extended function "<" (Left, Right : Cursor) return Boolean; -- modified procedure Iterate ( Container : List'Class; -- not primitive Process : not null access procedure (Position : Cursor)); -- modified procedure Reverse_Iterate ( Container : List; -- not primitive Process : not null access procedure (Position : Cursor)); -- modified function Iterate (Container : List'Class) -- not primitive return List_Iterator_Interfaces.Reversible_Iterator'Class; -- function Iterate (Container : List; Start : Cursor) -- return List_Iterator_Interfaces.Reversible_Iterator'Class; -- extended function Iterate (Container : List'Class; First, Last : Cursor) return List_Iterator_Interfaces.Reversible_Iterator'Class; generic with function "<" (Left, Right : Element_Type) return Boolean is <>; package Generic_Sorting is function Is_Sorted (Container : List) return Boolean; procedure Sort (Container : in out List); procedure Merge (Target : in out List; Source : in out List); end Generic_Sorting; -- extended generic with function "=" (Left, Right : Element_Type) return Boolean is <>; package Equivalents is function "=" (Left, Right : List) return Boolean; function Find (Container : List; Item : Element_Type) return Cursor; function Find (Container : List; Item : Element_Type; Position : Cursor) return Cursor; function Reverse_Find ( Container : List; Item : Element_Type) return Cursor; function Reverse_Find ( Container : List; Item : Element_Type; Position : Cursor) return Cursor; function Contains (Container : List; Item : Element_Type) return Boolean; end Equivalents; private package Base renames Naked_Doubly_Linked_Lists; type Element_Access is access Element_Type; type Node is limited record Super : aliased Base.Node; Element : Element_Access; end record; -- place Super at first whether Element_Type is controlled-type for Node use record Super at 0 range 0 .. Base.Node_Size - 1; end record; -- diff (Data) -- -- -- -- -- -- diff (Data_Access) type List is limited new Finalization.Limited_Controlled with record First : Base.Node_Access := null; Last : Base.Node_Access := null; Length : Count_Type := 0; end record; -- diff (Adjust) overriding procedure Finalize (Object : in out List) renames Clear; type Cursor is access Node; type Constant_Reference_Type ( Element : not null access constant Element_Type) is null record; type Reference_Type (Element : not null access Element_Type) is null record; type List_Iterator is new List_Iterator_Interfaces.Reversible_Iterator with record First : Cursor; Last : Cursor; end record; overriding function First (Object : List_Iterator) return Cursor; overriding function Next (Object : List_Iterator; Position : Cursor) return Cursor; overriding function Last (Object : List_Iterator) return Cursor; overriding function Previous (Object : List_Iterator; Position : Cursor) return Cursor; package Streaming is -- diff (Read) -- -- -- diff (Write) -- -- procedure Missing_Read ( Stream : access Streams.Root_Stream_Type'Class; Item : out Cursor) with Import, Convention => Ada, External_Name => "__drake_program_error"; procedure Missing_Write ( Stream : access Streams.Root_Stream_Type'Class; Item : Cursor) with Import, Convention => Ada, External_Name => "__drake_program_error"; procedure Missing_Read ( Stream : access Streams.Root_Stream_Type'Class; Item : out Constant_Reference_Type) with Import, Convention => Ada, External_Name => "__drake_program_error"; procedure Missing_Write ( Stream : access Streams.Root_Stream_Type'Class; Item : Constant_Reference_Type) with Import, Convention => Ada, External_Name => "__drake_program_error"; procedure Missing_Read ( Stream : access Streams.Root_Stream_Type'Class; Item : out Reference_Type) with Import, Convention => Ada, External_Name => "__drake_program_error"; procedure Missing_Write ( Stream : access Streams.Root_Stream_Type'Class; Item : Reference_Type) with Import, Convention => Ada, External_Name => "__drake_program_error"; end Streaming; -- diff ('Read) -- diff ('Write) for Cursor'Read use Streaming.Missing_Read; for Cursor'Write use Streaming.Missing_Write; for Constant_Reference_Type'Read use Streaming.Missing_Read; for Constant_Reference_Type'Write use Streaming.Missing_Write; for Reference_Type'Read use Streaming.Missing_Read; for Reference_Type'Write use Streaming.Missing_Write; No_Element : constant Cursor := null; end Ada.Containers.Limited_Doubly_Linked_Lists;
stcarrez/ada-awa
Ada
4,560
ads
----------------------------------------------------------------------- -- awa-mail -- Mail module -- Copyright (C) 2011, 2012, 2017, 2018, 2020 Stephane Carrez -- Written by Stephane Carrez ([email protected]) -- -- Licensed under the Apache License, Version 2.0 (the "License"); -- you may not use this file except in compliance with the License. -- You may obtain a copy of the License at -- -- http://www.apache.org/licenses/LICENSE-2.0 -- -- Unless required by applicable law or agreed to in writing, software -- distributed under the License is distributed on an "AS IS" BASIS, -- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -- See the License for the specific language governing permissions and -- limitations under the License. ----------------------------------------------------------------------- with Util.Beans.Objects.Maps; with ASF.Applications; with AWA.Modules; with AWA.Events; with AWA.Mail.Clients; -- == Integration == -- To be able to use the `mail` module, you will need to add the following -- line in your GNAT project file: -- -- with "awa_mail"; -- -- The `Mail_Module` type represents the mail module. An instance -- of the mail module must be declared and registered when the application -- is created and initialized. The module instance can be defined -- as follows: -- -- type Application is new AWA.Applications.Application with record -- Mail_Module : aliased AWA.Mail.Modules.Mail_Module; -- end record; -- -- And registered in the `Initialize_Modules` procedure by using: -- -- Register (App => App.Self.all'Access, -- Name => AWA.Mail.Modules.NAME, -- Module => App.Mail_Module'Access); -- -- == Configuration == -- The `mail` module needs some properties to configure the SMTP -- server. -- -- |Configuration | Default | Description | -- | --------------- | --------- | ----------------------------------------------- | -- |mail.smtp.host | localhost | Defines the SMTP server host name | -- |mail.smtp.port | 25 | Defines the SMTP connection port | -- |mail.smtp.enable | 1 | Defines whether sending email is enabled or not | -- -- == Sending an email == -- Sending an email when an event is posted can be done by using -- an XML configuration. Basically, the `mail` module uses the event -- framework provided by AWA. The XML definition looks like: -- -- <on-event name="user-register"> -- <action>#{userMail.send}</action> -- <property name="template">/mail/register-user-message.xhtml</property> -- </on-event> -- -- With this definition, the mail template `/mail/register-user-message.xhtml` -- is formatted by using the event and application context when the -- `user-register` event is posted. -- -- @include awa-mail-components.ads -- @include awa-mail-components-recipients.ads -- @include awa-mail-components-messages.ads -- @include awa-mail-components-attachments.ads -- -- == Ada Beans == -- @include-bean mail.xml -- package AWA.Mail.Modules is NAME : constant String := "mail"; type Mail_Module is new AWA.Modules.Module with private; type Mail_Module_Access is access all Mail_Module'Class; -- Initialize the mail module. overriding procedure Initialize (Plugin : in out Mail_Module; App : in AWA.Modules.Application_Access; Props : in ASF.Applications.Config); -- Configures the module after its initialization and after having -- read its XML configuration. overriding procedure Configure (Plugin : in out Mail_Module; Props : in ASF.Applications.Config); -- Create a new mail message. function Create_Message (Plugin : in Mail_Module) return AWA.Mail.Clients.Mail_Message_Access; -- Format and send an email. procedure Send_Mail (Plugin : in Mail_Module; Template : in String; Props : in Util.Beans.Objects.Maps.Map; Params : in Util.Beans.Objects.Maps.Map; Content : in AWA.Events.Module_Event'Class); -- Get the mail module instance associated with the current application. function Get_Mail_Module return Mail_Module_Access; private type Mail_Module is new AWA.Modules.Module with record Mailer : AWA.Mail.Clients.Mail_Manager_Access; end record; end AWA.Mail.Modules;
guillaume-lin/tsc
Ada
23,992
ads
------------------------------------------------------------------------------ -- -- -- GNAT ncurses Binding -- -- -- -- Terminal_Interface.Curses.Menu -- -- -- -- S P E C -- -- -- ------------------------------------------------------------------------------ -- Copyright (c) 1998 Free Software Foundation, Inc. -- -- -- -- Permission is hereby granted, free of charge, to any person obtaining a -- -- copy of this software and associated documentation files (the -- -- "Software"), to deal in the Software without restriction, including -- -- without limitation the rights to use, copy, modify, merge, publish, -- -- distribute, distribute with modifications, sublicense, and/or sell -- -- copies of the Software, and to permit persons to whom the Software is -- -- furnished to do so, subject to the following conditions: -- -- -- -- The above copyright notice and this permission notice shall be included -- -- in all copies or substantial portions of the Software. -- -- -- -- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS -- -- OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -- -- MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. -- -- IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, -- -- DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR -- -- OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR -- -- THE USE OR OTHER DEALINGS IN THE SOFTWARE. -- -- -- -- Except as contained in this notice, the name(s) of the above copyright -- -- holders shall not be used in advertising or otherwise to promote the -- -- sale, use or other dealings in this Software without prior written -- -- authorization. -- ------------------------------------------------------------------------------ -- Author: Juergen Pfeifer, 1996 -- Version Control: -- $Revision: 1.24 $ -- Binding Version 01.00 ------------------------------------------------------------------------------ -- menu binding. -- This module is generated. Please don't change it manually! -- Run the generator instead. -- | with System; with Ada.Characters.Latin_1; package Terminal_Interface.Curses.Menus is pragma Preelaborate (Terminal_Interface.Curses.Menus); pragma Linker_Options ("-lmenu"); pragma Linker_Options ("-lncurses"); Space : Character renames Ada.Characters.Latin_1.Space; type Item is private; type Menu is private; --------------------------- -- Interface constants -- --------------------------- Null_Item : constant Item; Null_Menu : constant Menu; subtype Menu_Request_Code is Key_Code range (Key_Max + 1) .. (Key_Max + 17); -- The prefix M_ stands for "Menu Request" M_Left_Item : constant Menu_Request_Code := Key_Max + 1; M_Right_Item : constant Menu_Request_Code := Key_Max + 2; M_Up_Item : constant Menu_Request_Code := Key_Max + 3; M_Down_Item : constant Menu_Request_Code := Key_Max + 4; M_ScrollUp_Line : constant Menu_Request_Code := Key_Max + 5; M_ScrollDown_Line : constant Menu_Request_Code := Key_Max + 6; M_ScrollDown_Page : constant Menu_Request_Code := Key_Max + 7; M_ScrollUp_Page : constant Menu_Request_Code := Key_Max + 8; M_First_Item : constant Menu_Request_Code := Key_Max + 9; M_Last_Item : constant Menu_Request_Code := Key_Max + 10; M_Next_Item : constant Menu_Request_Code := Key_Max + 11; M_Previous_Item : constant Menu_Request_Code := Key_Max + 12; M_Toggle_Item : constant Menu_Request_Code := Key_Max + 13; M_Clear_Pattern : constant Menu_Request_Code := Key_Max + 14; M_Back_Pattern : constant Menu_Request_Code := Key_Max + 15; M_Next_Match : constant Menu_Request_Code := Key_Max + 16; M_Previous_Match : constant Menu_Request_Code := Key_Max + 17; -- For those who like the old 'C' names for the request codes REQ_LEFT_ITEM : Menu_Request_Code renames M_Left_Item; REQ_RIGHT_ITEM : Menu_Request_Code renames M_Right_Item; REQ_UP_ITEM : Menu_Request_Code renames M_Up_Item; REQ_DOWN_ITEM : Menu_Request_Code renames M_Down_Item; REQ_SCR_ULINE : Menu_Request_Code renames M_ScrollUp_Line; REQ_SCR_DLINE : Menu_Request_Code renames M_ScrollDown_Line; REQ_SCR_DPAGE : Menu_Request_Code renames M_ScrollDown_Page; REQ_SCR_UPAGE : Menu_Request_Code renames M_ScrollUp_Page; REQ_FIRST_ITEM : Menu_Request_Code renames M_First_Item; REQ_LAST_ITEM : Menu_Request_Code renames M_Last_Item; REQ_NEXT_ITEM : Menu_Request_Code renames M_Next_Item; REQ_PREV_ITEM : Menu_Request_Code renames M_Previous_Item; REQ_TOGGLE_ITEM : Menu_Request_Code renames M_Toggle_Item; REQ_CLEAR_PATTERN : Menu_Request_Code renames M_Clear_Pattern; REQ_BACK_PATTERN : Menu_Request_Code renames M_Back_Pattern; REQ_NEXT_MATCH : Menu_Request_Code renames M_Next_Match; REQ_PREV_MATCH : Menu_Request_Code renames M_Previous_Match; procedure Request_Name (Key : in Menu_Request_Code; Name : out String); function Request_Name (Key : Menu_Request_Code) return String; -- Same as function ------------------ -- Exceptions -- ------------------ Menu_Exception : exception; -- -- Menu options -- pragma Warnings (Off); type Menu_Option_Set is record One_Valued : Boolean; Show_Descriptions : Boolean; Row_Major_Order : Boolean; Ignore_Case : Boolean; Show_Matches : Boolean; Non_Cyclic : Boolean; end record; pragma Pack (Menu_Option_Set); pragma Convention (C, Menu_Option_Set); for Menu_Option_Set use record One_Valued at 0 range 0 .. 0; Show_Descriptions at 0 range 1 .. 1; Row_Major_Order at 0 range 2 .. 2; Ignore_Case at 0 range 3 .. 3; Show_Matches at 0 range 4 .. 4; Non_Cyclic at 0 range 5 .. 5; end record; for Menu_Option_Set'Size use 32; -- Please note: this rep. clause is generated and may be -- different on your system. pragma Warnings (On); function Default_Menu_Options return Menu_Option_Set; -- Initial default options for a menu. pragma Inline (Default_Menu_Options); -- -- Item options -- pragma Warnings (Off); type Item_Option_Set is record Selectable : Boolean; end record; pragma Pack (Item_Option_Set); pragma Convention (C, Item_Option_Set); for Item_Option_Set use record Selectable at 0 range 0 .. 0; end record; for Item_Option_Set'Size use 32; -- Please note: this rep. clause is generated and may be -- different on your system. pragma Warnings (On); function Default_Item_Options return Item_Option_Set; -- Initial default options for an item. pragma Inline (Default_Item_Options); -- -- Item Array -- type Item_Array is array (Positive range <>) of aliased Item; pragma Convention (C, Item_Array); type Item_Array_Access is access Item_Array; procedure Free (IA : in out Item_Array_Access; Free_Items : Boolean := False); -- Release the memory for an allocated item array -- If Free_Items is True, call Delete() for all the items in -- the array. -- |===================================================================== -- | Man page mitem_new.3x -- |===================================================================== -- | function Create (Name : String; Description : String := "") return Item; -- AKA: new_item() -- Not inlined. -- | function New_Item (Name : String; Description : String := "") return Item renames Create; -- AKA: new_item() -- | procedure Delete (Itm : in out Item); -- AKA: free_item() -- Resets Itm to Null_Item -- |===================================================================== -- | Man page mitem_value.3x -- |===================================================================== -- | procedure Set_Value (Itm : in Item; Value : in Boolean := True); -- AKA: set_item_value() pragma Inline (Set_Value); -- | function Value (Itm : Item) return Boolean; -- AKA: item_value() pragma Inline (Value); -- |===================================================================== -- | Man page mitem_visible.3x -- |===================================================================== -- | function Visible (Itm : Item) return Boolean; -- AKA: item_visible() pragma Inline (Visible); -- |===================================================================== -- | Man page mitem_opts.3x -- |===================================================================== -- | procedure Set_Options (Itm : in Item; Options : in Item_Option_Set); -- AKA: set_item_opts() -- An overloaded Set_Options is defined later. Pragma Inline appears there -- | procedure Switch_Options (Itm : in Item; Options : in Item_Option_Set; On : Boolean := True); -- AKA: item_opts_on() -- AKA: item_opts_off() -- An overloaded Switch_Options is defined later. -- Pragma Inline appears there -- | procedure Get_Options (Itm : in Item; Options : out Item_Option_Set); -- AKA: item_opts() -- | function Get_Options (Itm : Item := Null_Item) return Item_Option_Set; -- AKA: item_opts() -- An overloaded Get_Options is defined later. Pragma Inline appears there -- |===================================================================== -- | Man page mitem_name.3x -- |===================================================================== -- | procedure Name (Itm : in Item; Name : out String); -- AKA: item_name() function Name (Itm : Item) return String; -- AKA: item_name() -- Implemented as function pragma Inline (Name); -- | procedure Description (Itm : in Item; Description : out String); -- AKA: item_description(); function Description (Itm : Item) return String; -- AKA: item_description(); -- Implemented as function pragma Inline (Description); -- |===================================================================== -- | Man page mitem_current.3x -- |===================================================================== -- | procedure Set_Current (Men : in Menu; Itm : in Item); -- AKA: set_current_item() pragma Inline (Set_Current); -- | function Current (Men : Menu) return Item; -- AKA: current_item() pragma Inline (Current); -- | procedure Set_Top_Row (Men : in Menu; Line : in Line_Position); -- AKA: set_top_row() pragma Inline (Set_Top_Row); -- | function Top_Row (Men : Menu) return Line_Position; -- AKA: top_row() pragma Inline (Top_Row); -- | function Get_Index (Itm : Item) return Positive; -- AKA: item_index() -- Please note that in this binding we start the numbering of items -- with 1. So this is number is one more than you get from the low -- level call. pragma Inline (Get_Index); -- |===================================================================== -- | Man page menu_post.3x -- |===================================================================== -- | procedure Post (Men : in Menu; Post : in Boolean := True); -- AKA: post_menu() -- AKA: unpost_menu() pragma Inline (Post); -- |===================================================================== -- | Man page menu_opts.3x -- |===================================================================== -- | procedure Set_Options (Men : in Menu; Options : in Menu_Option_Set); -- AKA: set_menu_opts() pragma Inline (Set_Options); -- | procedure Switch_Options (Men : in Menu; Options : in Menu_Option_Set; On : Boolean := True); -- AKA: menu_opts_on() -- AKA: menu_opts_off() pragma Inline (Switch_Options); -- | procedure Get_Options (Men : in Menu; Options : out Menu_Option_Set); -- AKA: menu_opts() -- | function Get_Options (Men : Menu := Null_Menu) return Menu_Option_Set; -- AKA: menu_opts() pragma Inline (Get_Options); -- |===================================================================== -- | Man page menu_win.3x -- |===================================================================== -- | procedure Set_Window (Men : in Menu; Win : in Window); -- AKA: set_menu_win() pragma Inline (Set_Window); -- | function Get_Window (Men : Menu) return Window; -- AKA: menu_win() pragma Inline (Get_Window); -- | procedure Set_Sub_Window (Men : in Menu; Win : in Window); -- AKA: set_menu_sub() pragma Inline (Set_Sub_Window); -- | function Get_Sub_Window (Men : Menu) return Window; -- AKA: menu_sub() pragma Inline (Get_Sub_Window); -- | procedure Scale (Men : in Menu; Lines : out Line_Count; Columns : out Column_Count); -- AKA: scale_menu() pragma Inline (Scale); -- |===================================================================== -- | Man page menu_cursor.3x -- |===================================================================== -- | procedure Position_Cursor (Men : Menu); -- AKA: pos_menu_cursor() pragma Inline (Position_Cursor); -- |===================================================================== -- | Man page menu_mark.3x -- |===================================================================== -- | procedure Set_Mark (Men : in Menu; Mark : in String); -- AKA: set_menu_mark() pragma Inline (Set_Mark); -- | procedure Mark (Men : in Menu; Mark : out String); -- AKA: menu_mark() function Mark (Men : Menu) return String; -- AKA: menu_mark() -- Implemented as function pragma Inline (Mark); -- |===================================================================== -- | Man page menu_attribs.3x -- |===================================================================== -- | procedure Set_Foreground (Men : in Menu; Fore : in Character_Attribute_Set := Normal_Video; Color : in Color_Pair := Color_Pair'First); -- AKA: set_menu_fore() pragma Inline (Set_Foreground); -- | procedure Foreground (Men : in Menu; Fore : out Character_Attribute_Set); -- AKA: menu_fore() -- | procedure Foreground (Men : in Menu; Fore : out Character_Attribute_Set; Color : out Color_Pair); -- AKA: menu_fore() pragma Inline (Foreground); -- | procedure Set_Background (Men : in Menu; Back : in Character_Attribute_Set := Normal_Video; Color : in Color_Pair := Color_Pair'First); -- AKA: set_menu_back() pragma Inline (Set_Background); -- | procedure Background (Men : in Menu; Back : out Character_Attribute_Set); -- AKA: menu_back() -- | procedure Background (Men : in Menu; Back : out Character_Attribute_Set; Color : out Color_Pair); -- AKA: menu_back() pragma Inline (Background); -- | procedure Set_Grey (Men : in Menu; Grey : in Character_Attribute_Set := Normal_Video; Color : in Color_Pair := Color_Pair'First); -- AKA: set_menu_grey() pragma Inline (Set_Grey); -- | procedure Grey (Men : in Menu; Grey : out Character_Attribute_Set); -- AKA: menu_grey() -- | procedure Grey (Men : in Menu; Grey : out Character_Attribute_Set; Color : out Color_Pair); -- AKA: menu_grey() pragma Inline (Grey); -- | procedure Set_Pad_Character (Men : in Menu; Pad : in Character := Space); -- AKA: set_menu_pad() pragma Inline (Set_Pad_Character); -- | procedure Pad_Character (Men : in Menu; Pad : out Character); -- AKA: menu_pad() pragma Inline (Pad_Character); -- |===================================================================== -- | Man page menu_spacing.3x -- |===================================================================== -- | procedure Set_Spacing (Men : in Menu; Descr : in Column_Position := 0; Row : in Line_Position := 0; Col : in Column_Position := 0); -- AKA: set_menu_spacing() pragma Inline (Set_Spacing); -- | procedure Spacing (Men : in Menu; Descr : out Column_Position; Row : out Line_Position; Col : out Column_Position); -- AKA: menu_spacing() pragma Inline (Spacing); -- |===================================================================== -- | Man page menu_pattern.3x -- |===================================================================== -- | function Set_Pattern (Men : Menu; Text : String) return Boolean; -- AKA: set_menu_pattern() -- Return TRUE if the pattern matches, FALSE otherwise pragma Inline (Set_Pattern); -- | procedure Pattern (Men : in Menu; Text : out String); -- AKA: menu_pattern() pragma Inline (Pattern); -- |===================================================================== -- | Man page menu_format.3x -- |===================================================================== -- | procedure Set_Format (Men : in Menu; Lines : in Line_Count; Columns : in Column_Count); -- Not implemented: 0 argument for Lines or Columns; -- instead use Format to get the current sizes -- The default is 16 rows, 1 column. Calling -- set_menu_format with a null menu pointer will change this -- default. A zero row or column argument to set_menu_format -- is interpreted as a request not to change the current -- value. -- AKA: set_menu_format() pragma Inline (Set_Format); -- | procedure Format (Men : in Menu; Lines : out Line_Count; Columns : out Column_Count); -- AKA: menu_format() pragma Inline (Format); -- |===================================================================== -- | Man page menu_hook.3x -- |===================================================================== type Menu_Hook_Function is access procedure (Men : in Menu); pragma Convention (C, Menu_Hook_Function); -- | procedure Set_Item_Init_Hook (Men : in Menu; Proc : in Menu_Hook_Function); -- AKA: set_item_init() pragma Inline (Set_Item_Init_Hook); -- | procedure Set_Item_Term_Hook (Men : in Menu; Proc : in Menu_Hook_Function); -- AKA: set_item_term() pragma Inline (Set_Item_Term_Hook); -- | procedure Set_Menu_Init_Hook (Men : in Menu; Proc : in Menu_Hook_Function); -- AKA: set_menu_init() pragma Inline (Set_Menu_Init_Hook); -- | procedure Set_Menu_Term_Hook (Men : in Menu; Proc : in Menu_Hook_Function); -- AKA: set_menu_term() pragma Inline (Set_Menu_Term_Hook); -- | function Get_Item_Init_Hook (Men : Menu) return Menu_Hook_Function; -- AKA: item_init() pragma Inline (Get_Item_Init_Hook); -- | function Get_Item_Term_Hook (Men : Menu) return Menu_Hook_Function; -- AKA: item_term() pragma Inline (Get_Item_Term_Hook); -- | function Get_Menu_Init_Hook (Men : Menu) return Menu_Hook_Function; -- AKA: menu_init() pragma Inline (Get_Menu_Init_Hook); -- | function Get_Menu_Term_Hook (Men : Menu) return Menu_Hook_Function; -- AKA: menu_term() pragma Inline (Get_Menu_Term_Hook); -- |===================================================================== -- | Man page menu_items.3x -- |===================================================================== -- | procedure Redefine (Men : in Menu; Items : in Item_Array_Access); -- AKA: set_menu_items() pragma Inline (Redefine); procedure Set_Items (Men : in Menu; Items : in Item_Array_Access) renames Redefine; pragma Inline (Set_Items); -- | function Items (Men : Menu; Index : Positive) return Item; -- AKA: menu_items() pragma Inline (Items); -- | function Item_Count (Men : Menu) return Natural; -- AKA: item_count() pragma Inline (Item_Count); -- |===================================================================== -- | Man page menu_new.3x -- |===================================================================== -- | function Create (Items : Item_Array_Access) return Menu; -- AKA: new_menu() -- Not inlined function New_Menu (Items : Item_Array_Access) return Menu renames Create; -- | procedure Delete (Men : in out Menu); -- AKA: free_menu() -- Reset Men to Null_Menu -- Not inlined -- |===================================================================== -- | Man page menu_driver.3x -- |===================================================================== type Driver_Result is (Menu_Ok, Request_Denied, Unknown_Request, No_Match); -- | function Driver (Men : Menu; Key : Key_Code) return Driver_Result; -- AKA: menu_driver() -- Driver is not inlined -- | -- Not Implemented: menu_request_name, menu_request_by_name ------------------------------------------------------------------------------- private type Item is new System.Storage_Elements.Integer_Address; type Menu is new System.Storage_Elements.Integer_Address; Null_Item : constant Item := 0; Null_Menu : constant Menu := 0; end Terminal_Interface.Curses.Menus;
reznikmm/matreshka
Ada
3,779
ads
------------------------------------------------------------------------------ -- -- -- Matreshka Project -- -- -- -- Open Document Toolkit -- -- -- -- Runtime Library Component -- -- -- ------------------------------------------------------------------------------ -- -- -- Copyright © 2014, Vadim Godunko <[email protected]> -- -- All rights reserved. -- -- -- -- Redistribution and use in source and binary forms, with or without -- -- modification, are permitted provided that the following conditions -- -- are met: -- -- -- -- * Redistributions of source code must retain the above copyright -- -- notice, this list of conditions and the following disclaimer. -- -- -- -- * Redistributions in binary form must reproduce the above copyright -- -- notice, this list of conditions and the following disclaimer in the -- -- documentation and/or other materials provided with the distribution. -- -- -- -- * Neither the name of the Vadim Godunko, IE nor the names of its -- -- contributors may be used to endorse or promote products derived from -- -- this software without specific prior written permission. -- -- -- -- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -- -- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -- -- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -- -- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -- -- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -- -- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED -- -- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -- -- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -- -- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -- -- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -- -- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- -- -- ------------------------------------------------------------------------------ -- $Revision$ $Date$ ------------------------------------------------------------------------------ with XML.DOM.Attributes; package ODF.DOM.Text_Use_Index_Source_Styles_Attributes is pragma Preelaborate; type ODF_Text_Use_Index_Source_Styles_Attribute is limited interface and XML.DOM.Attributes.DOM_Attribute; type ODF_Text_Use_Index_Source_Styles_Attribute_Access is access all ODF_Text_Use_Index_Source_Styles_Attribute'Class with Storage_Size => 0; end ODF.DOM.Text_Use_Index_Source_Styles_Attributes;
Fabien-Chouteau/AGATE
Ada
9,012
adb
------------------------------------------------------------------------------ -- -- -- Copyright (C) 2018, Fabien Chouteau -- -- -- -- Redistribution and use in source and binary forms, with or without -- -- modification, are permitted provided that the following conditions are -- -- met: -- -- 1. Redistributions of source code must retain the above copyright -- -- notice, this list of conditions and the following disclaimer. -- -- 2. Redistributions in binary form must reproduce the above copyright -- -- notice, this list of conditions and the following disclaimer in -- -- the documentation and/or other materials provided with the -- -- distribution. -- -- 3. Neither the name of the copyright holder nor the names of its -- -- contributors may be used to endorse or promote products derived -- -- from this software without specific prior written permission. -- -- -- -- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -- -- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -- -- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -- -- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -- -- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -- -- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -- -- LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -- -- DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -- -- THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -- -- (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -- -- OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- -- -- ------------------------------------------------------------------------------ pragma Warnings (Off, "is an internal GNAT unit"); with System.Machine_Reset; pragma Warnings (On, "is an internal GNAT unit"); with AGATE.SysCalls; use AGATE.SysCalls; with AGATE.Scheduler; with AGATE.Timer; with AGATE.Traces; with AGATE.Semaphores; with AGATE.Mutexes; with AGATE.Console; package body AGATE.API is procedure Initialize; function Do_Yield (Arg1, Arg2, Arg3 : Word) return UInt64; function Do_Clock (Arg1, Arg2, Arg3 : Word) return UInt64; function Do_Delay_Until (Arg1, Arg2, Arg3 : Word) return UInt64; function Do_Sem_Wait (Arg1, Arg2, Arg3 : Word) return UInt64; function Do_Sem_Signal (Arg1, Arg2, Arg3 : Word) return UInt64; function Do_Shutdown (Arg1, Arg2, Arg3 : Word) return UInt64; function Do_Wait_Lock (Arg1, Arg2, Arg3 : Word) return UInt64; function Do_Try_Lock (Arg1, Arg2, Arg3 : Word) return UInt64; function Do_Release (Arg1, Arg2, Arg3 : Word) return UInt64; function Do_Print (Arg1, Arg2, Arg3 : Word) return UInt64; ---------------- -- Initialize -- ---------------- procedure Initialize is begin Register (Yield, Do_Yield'Access); Register (Clock, Do_Clock'Access); Register (Delay_Until, Do_Delay_Until'Access); Register (Sem_Signal, Do_Sem_Signal'Access); Register (Sem_Wait, Do_Sem_Wait'Access); Register (Shutdown, Do_Shutdown'Access); Register (Mutex_Wait_Lock, Do_Wait_Lock'Access); Register (Mutex_Try_Lock, Do_Try_Lock'Access); Register (Mutex_Release, Do_Release'Access); Register (Print, Do_Print'Access); end Initialize; ----------- -- Start -- ----------- procedure Start renames Scheduler.Start; -------------- -- Do_Yield -- -------------- function Do_Yield (Arg1, Arg2, Arg3 : Word) return UInt64 is pragma Unreferenced (Arg3, Arg2, Arg1); begin AGATE.Scheduler.Yield; return 0; end Do_Yield; -------------- -- Do_Clock -- -------------- function Do_Clock (Arg1, Arg2, Arg3 : Word) return UInt64 is pragma Unreferenced (Arg3, Arg2, Arg1); begin return UInt64 (AGATE.Timer.Clock); end Do_Clock; -------------------- -- Do_Delay_Until -- -------------------- function Do_Delay_Until (Arg1, Arg2, Arg3 : Word) return UInt64 is pragma Unreferenced (Arg2, Arg3); begin Scheduler.Delay_Until (Time (Arg1)); return 0; end Do_Delay_Until; ----------------- -- Do_Sem_Wait -- ----------------- function Do_Sem_Wait (Arg1, Arg2, Arg3 : Word) return UInt64 is pragma Unreferenced (Arg3, Arg2); begin AGATE.Semaphores.Wait_For_Signal (To_ID (Arg1)); return 0; end Do_Sem_Wait; ------------------- -- Do_Sem_Signal -- ------------------- function Do_Sem_Signal (Arg1, Arg2, Arg3 : Word) return UInt64 is pragma Unreferenced (Arg3, Arg2); begin Semaphores.Signal (To_ID (Arg1)); return 0; end Do_Sem_Signal; ----------------- -- Do_Shutdown -- ----------------- function Do_Shutdown (Arg1, Arg2, Arg3 : Word) return UInt64 is pragma Unreferenced (Arg3, Arg2, Arg1); begin Traces.Shutdown; System.Machine_Reset.Stop; return 0; end Do_Shutdown; ------------------ -- Do_Wait_Lock -- ------------------ function Do_Wait_Lock (Arg1, Arg2, Arg3 : Word) return UInt64 is pragma Unreferenced (Arg3, Arg2); begin AGATE.Mutexes.Wait_Lock (To_ID (Arg1)); return 0; end Do_Wait_Lock; ----------------- -- Do_Try_Lock -- ----------------- function Do_Try_Lock (Arg1, Arg2, Arg3 : Word) return UInt64 is pragma Unreferenced (Arg3, Arg2); begin return (if Mutexes.Try_Lock (To_ID (Arg1)) then 1 else 0); end Do_Try_Lock; ---------------- -- Do_Release -- ---------------- function Do_Release (Arg1, Arg2, Arg3 : Word) return UInt64 is pragma Unreferenced (Arg3, Arg2); begin Mutexes.Release (To_ID (Arg1)); return 0; end Do_Release; -------------- -- Do_Print -- -------------- function Do_Print (Arg1, Arg2, Arg3 : Word) return UInt64 is pragma Unreferenced (Arg3); Addr : constant System.Address := To_Address (Integer_Address (Arg1)); Len : Word renames Arg2; Str : array (1 .. Len) of Character with Address => Addr; begin for C of Str loop AGATE.Console.Print (C); end loop; return 0; end Do_Print; ----------- -- Yield -- ----------- procedure Yield is begin Call (Yield); end Yield; ----------- -- Clock -- ----------- function Clock return Time is (Time (Call (Clock))); ----------------- -- Delay_Until -- ----------------- procedure Delay_Until (Wakeup_Time : Time) is Unref : UInt64 with Unreferenced; begin Unref := Call (Delay_Until, Word (Wakeup_Time)); end Delay_Until; --------------------- -- Wait_For_Signal -- --------------------- procedure Wait_For_Signal (ID : Semaphore_ID) is begin Call (Sem_Wait, To_Word (ID)); end Wait_For_Signal; ------------ -- Signal -- ------------ procedure Signal (ID : Semaphore_ID) is begin Call (Sem_Signal, To_Word (ID)); end Signal; --------------- -- Wait_Lock -- --------------- procedure Wait_Lock (ID : Mutex_ID) is begin Call (Mutex_Wait_Lock, To_Word (ID)); end Wait_Lock; -------------- -- Try_Lock -- -------------- function Try_Lock (ID : Mutex_ID) return Boolean is Ret : UInt64; begin Ret := Call (Mutex_Try_Lock, To_Word (ID)); return Ret /= 0; end Try_Lock; ------------- -- Release -- ------------- procedure Release (ID : Mutex_ID) is begin Call (Mutex_Release, To_Word (ID)); end Release; --------------------- -- Shutdown_System -- --------------------- procedure Shutdown_System is begin Call (Shutdown); end Shutdown_System; ----------- -- Print -- ----------- procedure Print (Str : String) is begin Call (Print, Word (To_Integer (Str (Str'First)'Address)), Word (Str'Length)); end Print; ---------------- -- Print_Line -- ---------------- procedure Print_Line (Str : String) is begin Print (Str & ASCII.CR & ASCII.LF); end Print_Line; begin Initialize; end AGATE.API;
reznikmm/matreshka
Ada
6,980
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.Database_Display_Elements is ------------ -- Create -- ------------ overriding function Create (Parameters : not null access Matreshka.DOM_Elements.Element_L2_Parameters) return Text_Database_Display_Element_Node is begin return Self : Text_Database_Display_Element_Node do Matreshka.ODF_Text.Constructors.Initialize (Self'Unchecked_Access, Parameters.Document, Matreshka.ODF_String_Constants.Text_Prefix); end return; end Create; ---------------- -- Enter_Node -- ---------------- overriding procedure Enter_Node (Self : not null access Text_Database_Display_Element_Node; Visitor : in out XML.DOM.Visitors.Abstract_Visitor'Class; Control : in out XML.DOM.Visitors.Traverse_Control) is begin if Visitor in ODF.DOM.Visitors.Abstract_ODF_Visitor'Class then ODF.DOM.Visitors.Abstract_ODF_Visitor'Class (Visitor).Enter_Text_Database_Display (ODF.DOM.Text_Database_Display_Elements.ODF_Text_Database_Display_Access (Self), Control); else Matreshka.DOM_Elements.Abstract_Element_Node (Self.all).Enter_Node (Visitor, Control); end if; end Enter_Node; -------------------- -- Get_Local_Name -- -------------------- overriding function Get_Local_Name (Self : not null access constant Text_Database_Display_Element_Node) return League.Strings.Universal_String is pragma Unreferenced (Self); begin return Matreshka.ODF_String_Constants.Database_Display_Element; end Get_Local_Name; ---------------- -- Leave_Node -- ---------------- overriding procedure Leave_Node (Self : not null access Text_Database_Display_Element_Node; Visitor : in out XML.DOM.Visitors.Abstract_Visitor'Class; Control : in out XML.DOM.Visitors.Traverse_Control) is begin if Visitor in ODF.DOM.Visitors.Abstract_ODF_Visitor'Class then ODF.DOM.Visitors.Abstract_ODF_Visitor'Class (Visitor).Leave_Text_Database_Display (ODF.DOM.Text_Database_Display_Elements.ODF_Text_Database_Display_Access (Self), Control); else Matreshka.DOM_Elements.Abstract_Element_Node (Self.all).Leave_Node (Visitor, Control); end if; end Leave_Node; ---------------- -- Visit_Node -- ---------------- overriding procedure Visit_Node (Self : not null access Text_Database_Display_Element_Node; Iterator : in out XML.DOM.Visitors.Abstract_Iterator'Class; Visitor : in out XML.DOM.Visitors.Abstract_Visitor'Class; Control : in out XML.DOM.Visitors.Traverse_Control) is begin if Iterator in ODF.DOM.Iterators.Abstract_ODF_Iterator'Class then ODF.DOM.Iterators.Abstract_ODF_Iterator'Class (Iterator).Visit_Text_Database_Display (Visitor, ODF.DOM.Text_Database_Display_Elements.ODF_Text_Database_Display_Access (Self), Control); else Matreshka.DOM_Elements.Abstract_Element_Node (Self.all).Visit_Node (Iterator, Visitor, Control); end if; end Visit_Node; begin Matreshka.DOM_Documents.Register_Element (Matreshka.ODF_String_Constants.Text_URI, Matreshka.ODF_String_Constants.Database_Display_Element, Text_Database_Display_Element_Node'Tag); end Matreshka.ODF_Text.Database_Display_Elements;
charlie5/lace
Ada
520
adb
with ada.Text_IO; package body openGL.frame_Counter is procedure increment (Self : in out Item) is use ada.Text_IO; use type ada.Calendar.Time; begin if ada.Calendar.Clock >= Self.next_FPS_Time then put_Line ("FPS:" & Integer'Image (Self.frame_Count)); Self.next_FPS_Time := Self.next_FPS_Time + 1.0; Self.frame_Count := 0; else Self.frame_Count := Self.frame_Count + 1; end if; end increment; end openGL.frame_Counter;
wookey-project/ewok-legacy
Ada
743
ads
package types.c with spark_mode => off is type t_retval is (SUCCESS, FAILURE) with size => 8; for t_retval use (SUCCESS => 0, FAILURE => 1); -- -- C string -- type c_string is array (positive range <>) of aliased character; for c_string'component_size use character'size; -- C_string length (without nul character) function len (s : c_string) return natural; -- String conversion procedure to_c (dst : out c_string; src : in string); procedure to_ada (dst : out string; src : in c_string); -- -- C buffer -- subtype c_buffer is byte_array; -- -- Boolean -- type bool is new boolean with size => 8; for bool use (true => 1, false => 0); end types.c;
io7m/coreland-posix-ada
Ada
3,326
adb
-- -- Copyright (c) 2009, <[email protected]> -- -- Permission to use, copy, modify, and/or distribute this software for any -- purpose with or without fee is hereby granted, provided that the above -- copyright notice and this permission notice appear in all copies. -- -- THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES -- WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF -- MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR -- ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES -- WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN -- ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF -- OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -- with Ada.Text_IO; with System; procedure spark_config is package IO renames Ada.Text_IO; type Discrete_Type is range System.Min_Int .. System.Max_Int; type Modulo_Type is mod System.Max_Binary_Modulus; type Float_Type is digits System.Max_Base_Digits range -1.0 .. 1.0; begin IO.Put_Line ("-- Auto generated, do not edit."); IO.Put_Line ("-- " & System.Name'Image (System.System_Name)); IO.New_Line; IO.Put_Line ("package Standard is"); IO.New_Line; IO.Put_Line (" type Integer is range " & Discrete_Type'Image (Discrete_Type (Integer'First)) & " .." & Discrete_Type'Image (Discrete_Type (Integer'Last)) & ";"); IO.New_Line; IO.Put_Line ("end Standard;"); IO.New_Line; IO.Put_Line ("package System is"); IO.Put_Line (" type Address is private;"); IO.New_Line; IO.Put_Line (" Min_Int : constant := " & Discrete_Type'Image (System.Min_Int) & ";"); IO.Put_Line (" Max_Int : constant := " & Discrete_Type'Image (System.Max_Int) & ";"); IO.Put_Line (" Max_Binary_Modulus : constant := " & Modulo_Type'Image (Modulo_Type'Last) & " + 1;"); IO.Put_Line (" Max_Digits : constant := " & Discrete_Type'Image (System.Max_Digits) & ";"); IO.Put_Line (" Max_Base_Digits : constant := " & Discrete_Type'Image (System.Max_Base_Digits) & ";"); IO.Put_Line (" Max_Mantissa : constant := " & Discrete_Type'Image (System.Max_Mantissa) & ";"); IO.Put_Line (" Storage_Unit : constant := " & Discrete_Type'Image (System.Storage_Unit) & ";"); IO.Put_Line (" Word_Size : constant := " & Discrete_Type'Image (System.Word_Size) & ";"); IO.Put_Line (" Fine_Delta : constant := " & Float_Type'Image (System.Fine_Delta) & ";"); IO.New_Line; IO.Put_Line (" subtype Any_Priority is Integer range " & Integer'Image (System.Any_Priority'First) & " .. " & Integer'Image (System.Any_Priority'Last) & ";"); IO.Put_Line (" subtype Priority is Any_Priority range " & Integer'Image (System.Priority'First) & " .. " & Integer'Image (System.Priority'Last) & ";"); IO.Put_Line (" subtype Interrupt_Priority is Any_Priority range " & Integer'Image (System.Interrupt_Priority'First) & " .. " & Integer'Image (System.Interrupt_Priority'Last) & ";"); IO.Put_Line (" Default_Bit_Order : constant Bit_Order := " & System.Bit_Order'Image (System.Default_Bit_Order) & ";"); IO.New_Line; IO.Put_Line ("end System;"); end spark_config;
zhmu/ananas
Ada
4,132
ads
------------------------------------------------------------------------------ -- -- -- GNAT RUN-TIME COMPONENTS -- -- -- -- S Y S T E M . W I D _ E N U M -- -- -- -- S p e c -- -- -- -- Copyright (C) 1992-2022, Free Software Foundation, Inc. -- -- -- -- GNAT is free software; you can redistribute it and/or modify it under -- -- terms of the GNU General Public License as published by the Free Soft- -- -- ware Foundation; either version 3, or (at your option) any later ver- -- -- sion. GNAT is distributed in the hope that it will be useful, but WITH- -- -- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY -- -- or FITNESS FOR A PARTICULAR PURPOSE. -- -- -- -- As a special exception under Section 7 of GPL version 3, you are granted -- -- additional permissions described in the GCC Runtime Library Exception, -- -- version 3.1, as published by the Free Software Foundation. -- -- -- -- You should have received a copy of the GNU General Public License and -- -- a copy of the GCC Runtime Library Exception along with this program; -- -- see the files COPYING3 and COPYING.RUNTIME respectively. If not, see -- -- <http://www.gnu.org/licenses/>. -- -- -- -- GNAT was originally developed by the GNAT team at New York University. -- -- Extensive contributions were provided by Ada Core Technologies Inc. -- -- -- ------------------------------------------------------------------------------ -- This package contains the routine used for Enumeration_Type'Width package System.Wid_Enum is pragma Pure; function Width_Enumeration_8 (Names : String; Indexes : System.Address; Lo, Hi : Natural) return Natural; -- Used to compute Enum'Width where Enum is some enumeration subtype -- other than those defined in package Standard. Names is a string with -- a lower bound of 1 containing the characters of all the enumeration -- literals concatenated together in sequence. Indexes is the address -- of an array of type array (0 .. N) of Natural_8, where N is the -- number of enumeration literals in the type. The Indexes values are -- the starting subscript of each enumeration literal, indexed by Pos -- values, with an extra entry at the end containing Names'Length + 1. -- The reason that Indexes is passed by address is that the actual type -- is created on the fly by the expander. -- -- Lo and Hi are the Pos values of the lower and upper bounds of the -- subtype. The result is the value of Width, i.e. the maximum value -- of the length of any enumeration literal in the given range. function Width_Enumeration_16 (Names : String; Indexes : System.Address; Lo, Hi : Natural) return Natural; -- Identical to Width_Enumeration_8 except that it handles types -- using array (0 .. Num) of Natural_16 for the Indexes table. function Width_Enumeration_32 (Names : String; Indexes : System.Address; Lo, Hi : Natural) return Natural; -- Identical to Width_Enumeration_8 except that it handles types -- using array (0 .. Num) of Natural_32 for the Indexes table. end System.Wid_Enum;
mfkiwl/ewok-kernel-security-OS
Ada
10,231
adb
-- -- Copyright 2018 The wookey project team <[email protected]> -- - Ryad Benadjila -- - Arnauld Michelizza -- - Mathieu Renard -- - Philippe Thierry -- - Philippe Trebuchet -- -- Licensed under the Apache License, Version 2.0 (the "License"); -- you may not use this file except in compliance with the License. -- You may obtain a copy of the License at -- -- http://www.apache.org/licenses/LICENSE-2.0 -- -- Unless required by applicable law or agreed to in writing, software -- distributed under the License is distributed on an "AS IS" BASIS, -- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -- See the License for the specific language governing permissions and -- limitations under the License. -- -- with ewok.tasks; use ewok.tasks; with ewok.tasks_shared; use ewok.tasks_shared; with ewok.devices_shared; use ewok.devices_shared; with ewok.exported.devices; use ewok.exported.devices; with ewok.devices; with ewok.sanitize; with ewok.dma; with ewok.memory; with ewok.perm; with ewok.sched; with ewok.debug; package body ewok.syscalls.init with spark_mode => off is package TSK renames ewok.tasks; procedure svc_register_device (caller_id : in ewok.tasks_shared.t_task_id; params : in t_parameters; mode : in ewok.tasks_shared.t_task_mode) is udev_address : constant system_address := params(1); descriptor_address : constant system_address := params(2); dev_id : ewok.devices_shared.t_device_id; ok : boolean; begin -- Forbidden after end of task initialization if TSK.is_init_done (caller_id) then goto ret_denied; end if; -- Does &udev and &descriptor fit in caller's address space? -- NOTE: The kernel might also use this syscall if TSK.is_real_user (caller_id) then -- Device_t structure may be stored in user data or in user code if not ewok.sanitize.is_range_in_any_region (udev_address, ewok.exported.devices.t_user_device'size/8, caller_id, mode) then pragma DEBUG (debug.log (debug.ERROR, "svc_register_device(): udev not in task's memory space")); goto ret_denied; end if; if not ewok.sanitize.is_word_in_data_region (descriptor_address, caller_id, mode) then pragma DEBUG (debug.log (debug.ERROR, "svc_register_device(): descriptor not in task's memory space")); goto ret_denied; end if; end if; declare -- Device descriptor transmitted to userspace -- FIXME: use a proper type for descriptors descriptor : unsigned_8 range 0 .. ewok.tasks.MAX_DEVS_PER_TASK with address => to_address (descriptor_address); udev : aliased ewok.exported.devices.t_user_device with import, address => to_address (udev_address); begin -- Ada based sanitization if not udev'valid_scalars then pragma DEBUG (debug.log (debug.ERROR, "svc_register_device(): invalid udev scalars")); goto ret_inval; end if; if TSK.is_real_user (caller_id) and then not ewok.devices.sanitize_user_defined_device (udev'unchecked_access, caller_id) then pragma DEBUG (debug.log (debug.ERROR, "svc_register_device(): invalid udev")); goto ret_inval; end if; if TSK.tasks_list(caller_id).num_devs = TSK.MAX_DEVS_PER_TASK then pragma DEBUG (debug.log (debug.ERROR, "svc_register_device(): no space left to register the device")); goto ret_busy; end if; -- Device should be automatically mapped... if (udev.map_mode = DEV_MAP_AUTO and udev.size > 0) -- ...but no free memory available! and then not ewok.memory.device_can_be_mapped then pragma DEBUG (debug.log (debug.ERROR, "svc_register_device(): no free region left to map the device")); goto ret_busy; end if; -- -- Registering the device -- ewok.devices.register_device (caller_id, udev'unchecked_access, dev_id, ok); if not ok then pragma DEBUG (debug.log (debug.ERROR, "svc_register_device(): failed to register the device")); goto ret_denied; end if; -- -- Recording registered devices in the task record -- TSK.append_device (caller_id, dev_id, descriptor, ok); if not ok then raise program_error; -- Should never happen here end if; -- Mount DEV_MAP_AUTO devices in memory if udev.size > 0 and udev.map_mode = DEV_MAP_AUTO then TSK.mount_device (caller_id, descriptor, ok); if not ok then raise program_error; -- Should never happen here end if; end if; set_return_value (caller_id, mode, SYS_E_DONE); ewok.tasks.set_state (caller_id, mode, TASK_STATE_RUNNABLE); return; end; <<ret_busy>> set_return_value (caller_id, mode, SYS_E_BUSY); ewok.tasks.set_state (caller_id, mode, TASK_STATE_RUNNABLE); return; <<ret_inval>> set_return_value (caller_id, mode, SYS_E_INVAL); ewok.tasks.set_state (caller_id, mode, TASK_STATE_RUNNABLE); return; <<ret_denied>> set_return_value (caller_id, mode, SYS_E_DENIED); ewok.tasks.set_state (caller_id, mode, TASK_STATE_RUNNABLE); return; end svc_register_device; procedure svc_init_done (caller_id : in ewok.tasks_shared.t_task_id; mode : in ewok.tasks_shared.t_task_mode) is ok : boolean; udev : ewok.devices.t_checked_user_device_access; dev_id : ewok.devices_shared.t_device_id; begin -- Forbidden after end of task initialization if TSK.is_init_done (caller_id) then goto ret_denied; end if; -- We enable auto mapped devices (MAP_AUTO) for i in TSK.tasks_list(caller_id).devices'range loop dev_id := TSK.tasks_list(caller_id).devices(i).device_id; if dev_id /= ID_DEV_UNUSED then udev := ewok.devices.get_user_device (dev_id); if udev.all.map_mode = DEV_MAP_AUTO then -- FIXME - Create new syscalls for enabling/disabling devices? ewok.devices.enable_device (dev_id, ok); if not ok then goto ret_denied; end if; end if; end if; end loop; for i in 1 .. TSK.tasks_list(caller_id).num_dma_id loop ewok.dma.enable_dma_irq (TSK.tasks_list(caller_id).dma_id(i)); end loop; TSK.tasks_list(caller_id).init_done := true; set_return_value (caller_id, mode, SYS_E_DONE); ewok.tasks.set_state (caller_id, mode, TASK_STATE_RUNNABLE); -- Request a schedule to ensure that the task has its devices mapped -- afterward -- FIXME - has to be changed when device mapping will be synchronously done ewok.sched.request_schedule; return; <<ret_denied>> set_return_value (caller_id, mode, SYS_E_DENIED); ewok.tasks.set_state (caller_id, mode, TASK_STATE_RUNNABLE); return; end svc_init_done; procedure svc_get_taskid (caller_id : in ewok.tasks_shared.t_task_id; params : in t_parameters; mode : in ewok.tasks_shared.t_task_mode) is target_name_address : constant system_address := params(1); target_id_address : constant system_address := params(2); tmp_id : ewok.tasks_shared.t_task_id; begin -- -- Early sanitization -- -- Forbidden after end of task initialization if TSK.is_init_done (caller_id) then goto ret_denied; end if; -- Does &target_name is in the caller address space ? if not ewok.sanitize.is_word_in_any_region (target_name_address, caller_id, mode) then goto ret_denied; end if; -- Does &target_id is in the caller address space ? if not ewok.sanitize.is_word_in_data_region (target_id_address, caller_id, mode) then goto ret_denied; end if; -- -- Main -- declare target_name : constant TSK.t_task_name with import, address => to_address (target_name_address); target_id : ewok.tasks_shared.t_task_id with address => to_address (target_id_address); begin -- We retrieve the 'id' related to the target name. Before updating the -- parameter passed by the user, we must check that the 2 tasked are -- allowed to communicate tmp_id := TSK.get_task_id (target_name); if tmp_id = ID_UNUSED then goto ret_inval; end if; #if CONFIG_KERNEL_DOMAIN if TSK.get_domain (tmp_id) /= TSK.get_domain (caller_id) then goto ret_inval; end if; #end if; -- Are tasks allowed to communicate through IPCs or DMA_SHM ? if not ewok.perm.ipc_is_granted (caller_id, tmp_id) and not ewok.perm.dmashm_is_granted (caller_id, tmp_id) then goto ret_inval; end if; -- We may update the target_id target_id := tmp_id; end; set_return_value (caller_id, mode, SYS_E_DONE); ewok.tasks.set_state (caller_id, mode, TASK_STATE_RUNNABLE); return; <<ret_inval>> set_return_value (caller_id, mode, SYS_E_INVAL); ewok.tasks.set_state (caller_id, mode, TASK_STATE_RUNNABLE); return; <<ret_denied>> set_return_value (caller_id, mode, SYS_E_DENIED); ewok.tasks.set_state (caller_id, mode, TASK_STATE_RUNNABLE); return; end svc_get_taskid; end ewok.syscalls.init;
afrl-rq/OpenUxAS
Ada
3,985
ads
with LMCP_Messages; with AFRL.CMASI.AutomationRequest; use AFRL.CMASI.AutomationRequest; with AFRL.CMASI.EntityState; use AFRL.CMASI.EntityState; with AFRL.CMASI.KeyValuePair; use AFRL.CMASI.KeyValuePair; with AFRL.CMASI.Location3D; use AFRL.CMASI.Location3D; with AFRL.CMASI.MissionCommand; use AFRL.CMASI.MissionCommand; with AFRL.CMASI.VehicleAction; use AFRL.CMASI.VehicleAction; with AFRL.CMASI.Waypoint; use AFRL.CMASI.Waypoint; with AFRL.Impact.ImpactAutomationRequest; use AFRL.Impact.ImpactAutomationRequest; with AVTAS.LMCP.Object; with UxAS.Messages.lmcptask.AssignmentCostMatrix; use UxAS.Messages.lmcptask.AssignmentCostMatrix; with UxAS.Messages.lmcptask.TaskAutomationRequest; use UxAS.Messages.lmcptask.TaskAutomationRequest; with UxAS.Messages.lmcptask.TaskPlanOptions; use UxAS.Messages.lmcptask.TaskPlanOptions; with UxAS.Messages.lmcptask.UniqueAutomationRequest; use UxAS.Messages.lmcptask.UniqueAutomationRequest; with UxAS.Messages.lmcptask.UniqueAutomationResponse; use UxAS.Messages.lmcptask.UniqueAutomationResponse; with UxAS.Messages.Route.RouteConstraints; use UxAS.Messages.Route.RouteConstraints; with UxAS.Messages.Route.RoutePlan; use UxAS.Messages.Route.RoutePlan; with UxAS.Messages.Route.RoutePlanRequest; use UxAS.Messages.Route.RoutePlanRequest; with UxAS.Messages.Route.RoutePlanResponse; use UxAS.Messages.Route.RoutePlanResponse; with UxAS.Messages.Route.RouteRequest; use UxAS.Messages.Route.RouteRequest; package LMCP_Message_Conversions is function As_AssignmentCostMatrix_Message (Msg : not null AssignmentCostMatrix_Any) return LMCP_Messages.AssignmentCostMatrix; function As_RouteConstraints_Message (Msg : not null RouteConstraints_Any) return LMCP_Messages.RouteConstraints; function As_Location3D_Message (Msg : not null Location3D_Any) return LMCP_Messages.Location3D; function As_VehicleAction_Message (Msg : not null VehicleAction_Any) return LMCP_Messages.VehicleAction; function As_KeyValuePair_Message (Msg : not null KeyValuePair_Acc) return LMCP_Messages.KeyValuePair; function As_Waypoint_Message (Msg : not null Waypoint_Any) return LMCP_Messages.Waypoint; function As_RoutePlan_Message (Msg : not null RoutePlan_Any) return LMCP_Messages.RoutePlan; function As_RoutePlanResponse_Message (Msg : not null RoutePlanResponse_Any) return LMCP_Messages.RoutePlanResponse; function As_RouteRequest_Message (Msg : not null RouteRequest_Any) return LMCP_Messages.RouteRequest; function As_RoutePlanRequest_Message (Msg : not null RoutePlanRequest_Any) return LMCP_Messages.RoutePlanRequest; function As_AutomationRequest_Message (Msg : not null AutomationRequest_Any) return LMCP_Messages.AutomationRequest; function As_TaskAutomationRequest_Message (Msg : not null TaskAutomationRequest_Any) return LMCP_Messages.TaskAutomationRequest; function As_ImpactAutomationRequest_Message (Msg : not null ImpactAutomationRequest_Any) return LMCP_Messages.ImpactAutomationRequest; function As_UniqueAutomationRequest_Message (Msg : not null UniqueAutomationRequest_Any) return LMCP_Messages.UniqueAutomationRequest; function As_UniqueAutomationResponse_Message (Msg : not null UniqueAutomationResponse_Any) return LMCP_Messages.UniqueAutomationResponse; function As_TaskPlanOption_Message (Msg : not null TaskPlanOptions_Any) return LMCP_Messages.TaskPlanOptions; function As_EntityState_Message (Msg : not null EntityState_Any) return LMCP_Messages.EntityState; function As_MissionCommand_Message (Msg : not null MissionCommand_Acc) return LMCP_Messages.MissionCommand; function As_Object_Any (Msg : LMCP_Messages.Message_Root'Class) return AVTAS.LMCP.Object.Object_Any; end LMCP_Message_Conversions;
reznikmm/matreshka
Ada
3,709
ads
------------------------------------------------------------------------------ -- -- -- Matreshka Project -- -- -- -- Open Document Toolkit -- -- -- -- Runtime Library Component -- -- -- ------------------------------------------------------------------------------ -- -- -- Copyright © 2014, Vadim Godunko <[email protected]> -- -- All rights reserved. -- -- -- -- Redistribution and use in source and binary forms, with or without -- -- modification, are permitted provided that the following conditions -- -- are met: -- -- -- -- * Redistributions of source code must retain the above copyright -- -- notice, this list of conditions and the following disclaimer. -- -- -- -- * Redistributions in binary form must reproduce the above copyright -- -- notice, this list of conditions and the following disclaimer in the -- -- documentation and/or other materials provided with the distribution. -- -- -- -- * Neither the name of the Vadim Godunko, IE nor the names of its -- -- contributors may be used to endorse or promote products derived from -- -- this software without specific prior written permission. -- -- -- -- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -- -- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -- -- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -- -- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -- -- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -- -- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED -- -- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -- -- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -- -- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -- -- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -- -- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- -- -- ------------------------------------------------------------------------------ -- $Revision$ $Date$ ------------------------------------------------------------------------------ with XML.DOM.Attributes; package ODF.DOM.Text_Booktitle_Attributes is pragma Preelaborate; type ODF_Text_Booktitle_Attribute is limited interface and XML.DOM.Attributes.DOM_Attribute; type ODF_Text_Booktitle_Attribute_Access is access all ODF_Text_Booktitle_Attribute'Class with Storage_Size => 0; end ODF.DOM.Text_Booktitle_Attributes;
AdaCore/libadalang
Ada
57
adb
package body Foo is procedure Baz is null; end Foo;
VMika/DES_Ada
Ada
2,338
adb
with P_StructuralTypes; use P_StructuralTypes; with Ada.Integer_Text_IO; with Ada.Sequential_IO; with Ada.Strings.Unbounded.Text_IO; with Ada.Text_IO; package body P_StepHandler.OutputHandler is ------------------------------------------------------------------------- ------------------------- CONSTRUCTOR ----------------------------------- ------------------------------------------------------------------------- function Make (Self : in out OutputHandler) return OutputHandler is begin Self.Ptr_BinaryContainer := null; Self.NextHandler := null; return Self; end; --------------------------------------------------------------- --- HANDLE PROCEDURE : OVERRIDEN FROM PARENT ABSTRACT CLASS --- --------------------------------------------------------------- overriding procedure Handle (Self : in out OutputHandler) is package Char_IO is new Ada.Sequential_IO (Character); use Char_IO; Output : File_Type; Byte : T_Byte; CharCode : Integer; begin ------------------------------------------------------------------------- -- This handler has two tasks : -- => Loop through the coded data in the binary container -- => Convert these blocks into character before inserting them into the -- output file ------------------------------------------------------------------------- Create (Output, Out_File, To_String(Self.Output_Name)); for i in Self.Ptr_BinaryContainer.all'Range loop for j in 1..8 loop Byte := Self.Ptr_BinaryContainer.all(i)(8*(j-1)+1..8*j); CharCode := Byte_To_CharacterCode(Byte); Write (Output,Character'Val(CharCode)); end loop; end loop; Close (Output); if Self.NextHandler /= null then Self.NextHandler.Handle; end if; end Handle; procedure Set_PaddingBitNumber (Self : in out OutputHandler ; Number : in Integer) is begin Self.PaddingBitNumber := Number; end; procedure Set_Output_Name (Self : in out OutputHandler; Name : Unbounded_String) is begin Self.Output_Name := Name; end; end P_StepHandler.OutputHandler;
shintakezou/adaplayground
Ada
4,817
adb
-- -- for the Mandelbrot part, see -- https://github.com/shintakezou/adaplayground/blob/master/src/mandel_utf.adb -- -- Usage example: -- ./mandelpng -2 -2 2 2 -- -- To build, gprbuild. It works on my machine! You need libpng lib and -- headers. -- -- Messy withs and uses; no idea if there's a better more idiomatic -- way. -- with Ada.Numerics.Elementary_Functions, Ada.Numerics.Generic_Complex_Types, Ada.Unchecked_Deallocation; use Ada.Numerics.Elementary_Functions; with Interfaces.C, Interfaces.C.Strings, Interfaces.C.Pointers; with PNGFunc_C; with stdint_h; use stdint_h; with Ada.Text_IO; use Ada.Text_IO; with Ada.Command_Line; procedure MandelPNG is package C renames Interfaces.C; package Complex_Types is new Ada.Numerics.Generic_Complex_Types (Float); use Complex_Types; -- Configuration constants. Width : constant := 800; Height : constant := 600; Max_Iterations : constant := 32; -- Returns the intensity of a single point in the Mandelbrot set. function Render_Pixel (C : Complex) return Float is Z : Complex := Complex'(0.0, 0.0); begin for N in Integer range 0 .. Max_Iterations loop Z := Z*Z + C; if (abs Z > 2.0) then return Float (N) / Float (Max_Iterations); end if; end loop; return 0.0; end; type Bitmap is array(Integer range <>, Integer range <>) of Float; type Bitmap_Ref is access Bitmap; procedure Free_Bitmap is new Ada.Unchecked_Deallocation (Object => Bitmap, Name => Bitmap_Ref); procedure Mandelbrot (Data : Bitmap_Ref; R1, I1, R2, I2 : Float) is Width : Integer := Data'Length (1); Height : Integer := Data'Length (2); Xdelta : Float := (R2-R1) / Float (Width); Ydelta : Float := (I2-I1) / Float (Height); I : Float; C : Complex; begin Put_Line ("Width: " & Integer'Image (Width)); Put_Line ("Height: " & Integer'Image (Height)); Put_Line ("Xdelta: " & Float'Image (Xdelta)); Put_Line ("Ydelta: " & Float'Image (Ydelta)); for Y in Data'Range (2) loop I := I1 + Float (Y) * Ydelta; for X in Data'Range (1) loop C := Complex'(R1 + Float (X) * Xdelta, I); Data (X, Y) := Render_Pixel (C); end loop; end loop; end; procedure Dump_Bitmap(Data : Bitmap_Ref) is subtype Buffer_Index is Integer range 0 .. 3 * Width * Height - 1; type Buffer is array (Buffer_Index range <>) of aliased uint8_t with Component_Size => 8, Convention => C; type Buffer_Access is access all Buffer; type RGB is record Red, Green, Blue : uint8_t; end record; procedure To_RGB (V : in Float; D : out RGB) is RR, GG, BB : Float; begin RR := 255.0 * V; GG := 255.0 * V; BB := 255.0 * V; D.Red := uint8_t (RR); D.Green := uint8_t (GG); D.Blue := uint8_t (BB); end To_RGB; package Im is new C.Pointers (Index => Buffer_Index, Element => uint8_t, Element_Array => Buffer, Default_Terminator => uint8_t'First); R : C.int; Image : aliased Buffer (Buffer_Index'Range); The_Image : Im.Pointer := Image (0)'Access; Vals : RGB; begin for Y in Data'Range (2) loop for X in Data'Range (1) loop To_RGB (Data (X, Y), Vals); Image (3 * (Y * Width + X) + 0) := Vals.Red; Image (3 * (Y * Width + X) + 1) := Vals.Green; Image (3 * (Y * Width + X) + 2) := Vals.Blue; end loop; end loop; R := PNGFunc_C.create_image (C.Strings.New_String ("out.png"), Width, Height, The_Image); if Integer (R) < 0 then Put_Line (Standard_Error, "error writing image to file"); else Put_Line ("file written"); end if; end; Image : Bitmap_Ref; use Ada.Command_Line; begin if Argument_Count < 4 then Put_Line (Standard_Error, "Usage: " & Command_Name & " R1 I1 R2 I2"); else declare R1 : Float := Float'Value (Argument (1)); R2 : Float := Float'Value (Argument (3)); I1 : Float := Float'Value (Argument (2)); I2 : Float := Float'Value (Argument (4)); begin Image := new Bitmap (0 .. Width - 1, 0 .. Height - 1); Mandelbrot (Image, R1, I1, R2, I2); Dump_Bitmap (Image); Free_Bitmap (Image); end; end if; end;
reznikmm/matreshka
Ada
5,349
ads
------------------------------------------------------------------------------ -- -- -- Matreshka Project -- -- -- -- Ada Modeling Framework -- -- -- -- Runtime Library Component -- -- -- ------------------------------------------------------------------------------ -- -- -- Copyright © 2012-2013, Vadim Godunko <[email protected]> -- -- All rights reserved. -- -- -- -- Redistribution and use in source and binary forms, with or without -- -- modification, are permitted provided that the following conditions -- -- are met: -- -- -- -- * Redistributions of source code must retain the above copyright -- -- notice, this list of conditions and the following disclaimer. -- -- -- -- * Redistributions in binary form must reproduce the above copyright -- -- notice, this list of conditions and the following disclaimer in the -- -- documentation and/or other materials provided with the distribution. -- -- -- -- * Neither the name of the Vadim Godunko, IE nor the names of its -- -- contributors may be used to endorse or promote products derived from -- -- this software without specific prior written permission. -- -- -- -- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -- -- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -- -- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -- -- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -- -- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -- -- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED -- -- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -- -- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -- -- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -- -- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -- -- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- -- -- ------------------------------------------------------------------------------ -- $Revision$ $Date$ ------------------------------------------------------------------------------ -- This file is generated, don't edit it. ------------------------------------------------------------------------------ with AMF.Internals.Tables.MOFEXT_Types; package AMF.Internals.Tables.MOFEXT_Attribute_Mappings is pragma Preelaborate; MOF_Collection_Offset : constant array (AMF.Internals.Tables.MOFEXT_Types.Element_Kinds, AMF.Internals.CMOF_Element range 2 .. 2) of AMF.Internals.AMF_Collection_Of_Element := (AMF.Internals.Tables.MOFEXT_Types.E_None => (others => 0), AMF.Internals.Tables.MOFEXT_Types.E_MOF_Tag => (2 => 3, -- Tag::element others => 0)); MOF_Member_Offset : constant array (AMF.Internals.Tables.MOFEXT_Types.Element_Kinds, AMF.Internals.CMOF_Element range 3 .. 5) of Natural := (AMF.Internals.Tables.MOFEXT_Types.E_None => (others => 0), AMF.Internals.Tables.MOFEXT_Types.E_MOF_Tag => (3 => 2, -- Tag::name 4 => 4, -- Tag::tagOwner 5 => 3, -- Tag::value others => 0)); UML_Collection_Offset : constant array (AMF.Internals.Tables.MOFEXT_Types.Element_Kinds, AMF.Internals.CMOF_Element range 243 .. 482) of AMF.Internals.AMF_Collection_Of_Element := (AMF.Internals.Tables.MOFEXT_Types.E_None => (others => 0), AMF.Internals.Tables.MOFEXT_Types.E_MOF_Tag => (347 => 1, -- Element::ownedComment 348 => 2, -- Element::ownedElement others => 0)); UML_Member_Offset : constant array (AMF.Internals.Tables.MOFEXT_Types.Element_Kinds, AMF.Internals.CMOF_Element range 483 .. 866) of Natural := (AMF.Internals.Tables.MOFEXT_Types.E_None => (others => 0), AMF.Internals.Tables.MOFEXT_Types.E_MOF_Tag => (577 => 1, -- Element::owner others => 0)); end AMF.Internals.Tables.MOFEXT_Attribute_Mappings;
tum-ei-rcs/StratoX
Ada
9,088
ads
------------------------------------------------------------------------------ -- -- -- Copyright (C) 2015, AdaCore -- -- -- -- Redistribution and use in source and binary forms, with or without -- -- modification, are permitted provided that the following conditions are -- -- met: -- -- 1. Redistributions of source code must retain the above copyright -- -- notice, this list of conditions and the following disclaimer. -- -- 2. Redistributions in binary form must reproduce the above copyright -- -- notice, this list of conditions and the following disclaimer in -- -- the documentation and/or other materials provided with the -- -- distribution. -- -- 3. Neither the name of STMicroelectronics nor the names of its -- -- contributors may be used to endorse or promote products derived -- -- from this software without specific prior written permission. -- -- -- -- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -- -- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -- -- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -- -- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -- -- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -- -- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -- -- LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -- -- DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -- -- THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -- -- (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -- -- OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- -- -- -- -- -- This file is based on: -- -- -- -- @file stm32f4xx_hal_dsi.h -- -- @author MCD Application Team -- -- @version V1.4.2 -- -- @date 10-November-2015 -- -- -- -- COPYRIGHT(c) 2015 STMicroelectronics -- ------------------------------------------------------------------------------ with STM32_SVD.DSIHOST; with HAL.DSI; package STM32.DSI is package SVD_DSI renames STM32_SVD.DSIHOST; type DSI_Number_Of_Lanes is (One_Data_Lane, Two_Data_Lanes) with Size => 2; -- Values 2#10# and 2#11# are reserved subtype DSI_PLLN_Div is UInt7 range 10 .. 125; subtype DSI_PLL_IDF is UInt4 range 0 .. 7; PLL_IN_DIV1 : constant DSI_PLL_IDF := 1; PLL_IN_DIV2 : constant DSI_PLL_IDF := 2; PLL_IN_DIV3 : constant DSI_PLL_IDF := 3; PLL_IN_DIV4 : constant DSI_PLL_IDF := 4; PLL_IN_DIV5 : constant DSI_PLL_IDF := 5; PLL_IN_DIV6 : constant DSI_PLL_IDF := 6; PLL_IN_DIV7 : constant DSI_PLL_IDF := 7; type DSI_PLL_ODF is (PLL_OUT_DIV1, PLL_OUT_DIV2, PLL_OUT_DIV4, PLL_OUT_DIV8) with Size => 2; type DSI_Color_Mode is (RGB565, RGB666, RGB888) with Size => 3; for DSI_Color_Mode use (RGB565 => 0, -- 1 and 2 can also be used for this mode RGB666 => 3, -- 4 can also be used for this mode RGB888 => 5); type DSI_Video_Mode is (Video_Mode_NB_Pulses, Video_Mode_NB_Events, Video_Mode_Burst); type DSI_Polarity is (Active_High, Active_Low) with Size => 1; type DSI_Edge is (Falling_Edge, Rising_Edge) with Size => 1; type DSI_TE_Polarity is (Rising_Edge, Falling_Edge) with size => 1; type DSI_Tearing_Effect_Source is (TE_DSI_Link, TE_External) with Size => 1; type DSI_Flow_Control is (Flow_Control_CRC_RX, Flow_Control_ECC_RX, Flow_Control_BTA, Flow_Control_EOTP_RX, Flow_Control_EOTP_TX); type DSI_Host (Periph : not null access SVD_DSI.DSIHOST_Peripheral) is limited new HAL.DSI.DSI_Port with private; procedure DSI_Initialize (This : in out DSI_Host; PLL_N_Div : DSI_PLLN_Div; PLL_IN_Div : DSI_PLL_IDF; PLL_OUT_Div : DSI_PLL_ODF; Auto_Clock_Lane_Control : Boolean; TX_Escape_Clock_Division : Byte; -- The TX_ESC clock division. 0 or 1 stops the clock. Number_Of_Lanes : DSI_Number_Of_Lanes); procedure DSI_Deinit (This : in out DSI_Host); procedure DSI_Setup_Video_Mode (This : in out DSI_Host; Virtual_Channel : HAL.DSI.DSI_Virtual_Channel_ID; Color_Coding : DSI_Color_Mode; Loosely_Packed : Boolean; Video_Mode : DSI_Video_Mode; Packet_Size : UInt15; Number_Of_Chunks : UInt14; Null_Packet_Size : UInt14; HSync_Polarity : DSI_Polarity; VSync_Polarity : DSI_Polarity; DataEn_Polarity : DSI_Polarity; HSync_Active_Duration : UInt13; Horizontal_BackPorch : UInt13; Horizontal_Line : UInt15; VSync_Active_Duration : UInt10; Vertical_BackPorch : UInt10; Vertical_FrontPorch : UInt10; Vertical_Active : UInt14; LP_Command_Enabled : Boolean; LP_Largest_Packet_Size : Byte; LP_VACT_Largest_Packet_Size : Byte; LP_H_Front_Porch_Enable : Boolean; LP_H_Back_Porch_Enable : Boolean; LP_V_Active_Enable : Boolean; LP_V_Front_Porch_Enable : Boolean; LP_V_Back_Porch_Enable : Boolean; LP_V_Sync_Active_Enable : Boolean; Frame_BTA_Ack_Enable : Boolean); procedure DSI_Setup_Adapted_Command_Mode (This : in out DSI_Host; Virtual_Channel : HAL.DSI.DSI_Virtual_Channel_ID; Color_Coding : DSI_Color_Mode; Command_Size : Short; Tearing_Effect_Source : DSI_Tearing_Effect_Source; Tearing_Effect_Polarity : DSI_TE_Polarity; HSync_Polarity : DSI_Polarity; VSync_Polarity : DSI_Polarity; DataEn_Polarity : DSI_Polarity; VSync_Edge : DSI_Edge; Automatic_Refresh : Boolean; TE_Acknowledge_Request : Boolean); procedure DSI_Setup_Command (This : in out DSI_Host; LP_Gen_Short_Write_No_P : Boolean := True; LP_Gen_Short_Write_One_P : Boolean := True; LP_Gen_Short_Write_Two_P : Boolean := True; LP_Gen_Short_Read_No_P : Boolean := True; LP_Gen_Short_Read_One_P : Boolean := True; LP_Gen_Short_Read_Two_P : Boolean := True; LP_Gen_Long_Write : Boolean := True; LP_DCS_Short_Write_No_P : Boolean := True; LP_DCS_Short_Write_One_P : Boolean := True; LP_DCS_Short_Read_No_P : Boolean := True; LP_DCS_Long_Write : Boolean := True; LP_Max_Read_Packet : Boolean := False; Acknowledge_Request : Boolean := False); procedure DSI_Setup_Flow_Control (This : in out DSI_Host; Flow_Control : DSI_Flow_Control); procedure DSI_Start (This : in out DSI_Host); procedure DSI_Stop (This : in out DSI_Host); procedure DSI_Refresh (This : in out DSI_Host); procedure DSI_Wrapper_Disable (This : in out DSI_Host); procedure DSI_Wrapper_Enable (This : in out DSI_Host); overriding procedure DSI_Short_Write (This : in out DSI_Host; Channel_ID : HAL.DSI.DSI_Virtual_Channel_ID; Mode : HAL.DSI.DSI_Short_Write_Packet_Data_Type; Param1 : Byte; Param2 : Byte); overriding procedure DSI_Long_Write (This : in out DSI_Host; Channel_Id : HAL.DSI.DSI_Virtual_Channel_ID; Mode : HAL.DSI.DSI_Long_Write_Packet_Data_Type; Param1 : Byte; Parameters : HAL.DSI.DSI_Data); private type DSI_Host (Periph : not null access SVD_DSI.DSIHOST_Peripheral) is limited new HAL.DSI.DSI_Port with null record; end STM32.DSI;
AaronC98/PlaneSystem
Ada
4,470
ads
------------------------------------------------------------------------------ -- Ada Web Server -- -- -- -- Copyright (C) 2012-2014, AdaCore -- -- -- -- This library is free software; you can redistribute it and/or modify -- -- it under terms of the GNU General Public License as published by the -- -- Free Software Foundation; either version 3, or (at your option) any -- -- later version. This library is distributed in the hope that it will be -- -- useful, but WITHOUT ANY WARRANTY; without even the implied warranty of -- -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. -- -- -- -- -- -- -- -- -- -- -- -- You should have received a copy of the GNU General Public License and -- -- a copy of the GCC Runtime Library Exception along with this program; -- -- see the files COPYING3 and COPYING.RUNTIME respectively. If not, see -- -- <http://www.gnu.org/licenses/>. -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- ------------------------------------------------------------------------------ -- This implements the WebSocket protocol as defined in RFC-6455 package AWS.Net.WebSocket.Protocol.RFC6455 is type State is new Protocol.State with private; overriding procedure Send (Protocol : in out State; Socket : Object; Data : Stream_Element_Array; From_Client : Boolean := False); -- Encode and send data to the WebSocket. overriding procedure Send (Protocol : in out State; Socket : Object; Data : Unbounded_String; From_Client : Boolean := False); -- Same as above but for an Unbounded_String. This version supports large -- messages possibly sent fragmented. overriding procedure Close (Protocol : in out State; Socket : Object; Data : String; Error : Status_Code); -- Send a close frame overriding procedure Receive (Protocol : in out State; Socket : Object; Data : out Stream_Element_Array; Last : out Stream_Element_Offset); -- Receive and decode WebSocket data overriding function End_Of_Message (Protocol : State) return Boolean; -- Returns True if we have read a whole message procedure Send_Header (Sock : Net.Socket_Type'Class; Request : AWS.Status.Data); -- Send specific header for this protocol overriding procedure Add_Connect_Headers (Protocol : State; Host : String; Headers : in out AWS.Headers.List); overriding function Check_Connect_Response (Protocol : State; Request : AWS.Headers.List; Response : AWS.Response.Data) return Boolean; -- See inherited documentation private -- Protocol specific status type Masking_Key_Index is mod 4; type Masking_Key is new Stream_Element_Array (0 .. 3); for Masking_Key'Size use 32; type Opcode is mod 16; for Opcode'Size use 4; type State is new Protocol.State with record Remaining : Stream_Element_Offset := 0; Read : Stream_Element_Offset := 0; Opcd : Opcode := 0; Has_Mask : Boolean; Mask : Masking_Key; Close_Sent : Boolean := False; Last_Fragment : Boolean := True; end record; end AWS.Net.WebSocket.Protocol.RFC6455;
reznikmm/matreshka
Ada
10,786
adb
------------------------------------------------------------------------------ -- -- -- Matreshka Project -- -- -- -- Ada Modeling Framework -- -- -- -- Runtime Library Component -- -- -- ------------------------------------------------------------------------------ -- -- -- Copyright © 2012, Vadim Godunko <[email protected]> -- -- All rights reserved. -- -- -- -- Redistribution and use in source and binary forms, with or without -- -- modification, are permitted provided that the following conditions -- -- are met: -- -- -- -- * Redistributions of source code must retain the above copyright -- -- notice, this list of conditions and the following disclaimer. -- -- -- -- * Redistributions in binary form must reproduce the above copyright -- -- notice, this list of conditions and the following disclaimer in the -- -- documentation and/or other materials provided with the distribution. -- -- -- -- * Neither the name of the Vadim Godunko, IE nor the names of its -- -- contributors may be used to endorse or promote products derived from -- -- this software without specific prior written permission. -- -- -- -- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -- -- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -- -- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -- -- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -- -- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -- -- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED -- -- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -- -- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -- -- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -- -- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -- -- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- -- -- ------------------------------------------------------------------------------ -- $Revision$ $Date$ ------------------------------------------------------------------------------ with AMF.Elements; with AMF.Internals.Helpers; with AMF.Internals.Tables.UML_Attributes; with AMF.Visitors.UMLDI_Iterators; with AMF.Visitors.UMLDI_Visitors; with League.Strings.Internals; package body AMF.Internals.UMLDI_UML_Interaction_Table_Labels is -------------- -- Get_Kind -- -------------- overriding function Get_Kind (Self : not null access constant UMLDI_UML_Interaction_Table_Label_Proxy) return AMF.UMLDI.UMLDI_UML_Interaction_Table_Label_Kind is begin return AMF.Internals.Tables.UML_Attributes.Internal_Get_Kind (Self.Element); end Get_Kind; -------------- -- Set_Kind -- -------------- overriding procedure Set_Kind (Self : not null access UMLDI_UML_Interaction_Table_Label_Proxy; To : AMF.UMLDI.UMLDI_UML_Interaction_Table_Label_Kind) is begin AMF.Internals.Tables.UML_Attributes.Internal_Set_Kind (Self.Element, To); end Set_Kind; -------------- -- Get_Text -- -------------- overriding function Get_Text (Self : not null access constant UMLDI_UML_Interaction_Table_Label_Proxy) return League.Strings.Universal_String is begin null; return League.Strings.Internals.Create (AMF.Internals.Tables.UML_Attributes.Internal_Get_Text (Self.Element)); end Get_Text; -------------- -- Set_Text -- -------------- overriding procedure Set_Text (Self : not null access UMLDI_UML_Interaction_Table_Label_Proxy; To : League.Strings.Universal_String) is begin AMF.Internals.Tables.UML_Attributes.Internal_Set_Text (Self.Element, League.Strings.Internals.Internal (To)); end Set_Text; ----------------- -- Get_Is_Icon -- ----------------- overriding function Get_Is_Icon (Self : not null access constant UMLDI_UML_Interaction_Table_Label_Proxy) return Boolean is begin return AMF.Internals.Tables.UML_Attributes.Internal_Get_Is_Icon (Self.Element); end Get_Is_Icon; ----------------- -- Set_Is_Icon -- ----------------- overriding procedure Set_Is_Icon (Self : not null access UMLDI_UML_Interaction_Table_Label_Proxy; To : Boolean) is begin AMF.Internals.Tables.UML_Attributes.Internal_Set_Is_Icon (Self.Element, To); end Set_Is_Icon; --------------------- -- Get_Local_Style -- --------------------- overriding function Get_Local_Style (Self : not null access constant UMLDI_UML_Interaction_Table_Label_Proxy) return AMF.UMLDI.UML_Styles.UMLDI_UML_Style_Access is begin return AMF.UMLDI.UML_Styles.UMLDI_UML_Style_Access (AMF.Internals.Helpers.To_Element (AMF.Internals.Tables.UML_Attributes.Internal_Get_Local_Style (Self.Element))); end Get_Local_Style; --------------------- -- Set_Local_Style -- --------------------- overriding procedure Set_Local_Style (Self : not null access UMLDI_UML_Interaction_Table_Label_Proxy; To : AMF.UMLDI.UML_Styles.UMLDI_UML_Style_Access) is begin AMF.Internals.Tables.UML_Attributes.Internal_Set_Local_Style (Self.Element, AMF.Internals.Helpers.To_Element (AMF.Elements.Element_Access (To))); end Set_Local_Style; ----------------------- -- Get_Model_Element -- ----------------------- overriding function Get_Model_Element (Self : not null access constant UMLDI_UML_Interaction_Table_Label_Proxy) return AMF.UML.Elements.Collections.Set_Of_UML_Element is begin raise Program_Error; return X : AMF.UML.Elements.Collections.Set_Of_UML_Element; -- return -- AMF.UML.Elements.Collections.Wrap -- (AMF.Internals.Element_Collections.Wrap -- (AMF.Internals.Tables.UML_Attributes.Internal_Get_Model_Element -- (Self.Element))); end Get_Model_Element; ----------------------- -- Get_Model_Element -- ----------------------- overriding function Get_Model_Element (Self : not null access constant UMLDI_UML_Interaction_Table_Label_Proxy) return AMF.CMOF.Elements.CMOF_Element_Access is begin return AMF.CMOF.Elements.CMOF_Element_Access (AMF.Internals.Helpers.To_Element (AMF.Internals.Tables.UML_Attributes.Internal_Get_Model_Element (Self.Element))); end Get_Model_Element; --------------------- -- Get_Local_Style -- --------------------- overriding function Get_Local_Style (Self : not null access constant UMLDI_UML_Interaction_Table_Label_Proxy) return AMF.DI.Styles.DI_Style_Access is begin return AMF.DI.Styles.DI_Style_Access (AMF.Internals.Helpers.To_Element (AMF.Internals.Tables.UML_Attributes.Internal_Get_Local_Style (Self.Element))); end Get_Local_Style; --------------------- -- Set_Local_Style -- --------------------- overriding procedure Set_Local_Style (Self : not null access UMLDI_UML_Interaction_Table_Label_Proxy; To : AMF.DI.Styles.DI_Style_Access) is begin AMF.Internals.Tables.UML_Attributes.Internal_Set_Local_Style (Self.Element, AMF.Internals.Helpers.To_Element (AMF.Elements.Element_Access (To))); end Set_Local_Style; ------------------- -- Enter_Element -- ------------------- overriding procedure Enter_Element (Self : not null access constant UMLDI_UML_Interaction_Table_Label_Proxy; Visitor : in out AMF.Visitors.Abstract_Visitor'Class; Control : in out AMF.Visitors.Traverse_Control) is begin if Visitor in AMF.Visitors.UMLDI_Visitors.UMLDI_Visitor'Class then AMF.Visitors.UMLDI_Visitors.UMLDI_Visitor'Class (Visitor).Enter_UML_Interaction_Table_Label (AMF.UMLDI.UML_Interaction_Table_Labels.UMLDI_UML_Interaction_Table_Label_Access (Self), Control); end if; end Enter_Element; ------------------- -- Leave_Element -- ------------------- overriding procedure Leave_Element (Self : not null access constant UMLDI_UML_Interaction_Table_Label_Proxy; Visitor : in out AMF.Visitors.Abstract_Visitor'Class; Control : in out AMF.Visitors.Traverse_Control) is begin if Visitor in AMF.Visitors.UMLDI_Visitors.UMLDI_Visitor'Class then AMF.Visitors.UMLDI_Visitors.UMLDI_Visitor'Class (Visitor).Leave_UML_Interaction_Table_Label (AMF.UMLDI.UML_Interaction_Table_Labels.UMLDI_UML_Interaction_Table_Label_Access (Self), Control); end if; end Leave_Element; ------------------- -- Visit_Element -- ------------------- overriding procedure Visit_Element (Self : not null access constant UMLDI_UML_Interaction_Table_Label_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.UMLDI_Iterators.UMLDI_Iterator'Class then AMF.Visitors.UMLDI_Iterators.UMLDI_Iterator'Class (Iterator).Visit_UML_Interaction_Table_Label (Visitor, AMF.UMLDI.UML_Interaction_Table_Labels.UMLDI_UML_Interaction_Table_Label_Access (Self), Control); end if; end Visit_Element; end AMF.Internals.UMLDI_UML_Interaction_Table_Labels;
AdaCore/gpr
Ada
907
ads
-- -- Copyright (C) 2014-2022, AdaCore -- SPDX-License-Identifier: Apache-2.0 -- -- This package provides string formatting helpers related to 'Image attribute -- references. package Gpr_Parser_Support.Images is function Stripped_Image (I : Integer) return String; -- Return the same as Integer'Image (I), but without any leading space generic type T is private; type Idx is (<>); type Array_Type is array (Idx range <>) of T; with function Image (Self : T) return String is <>; function Array_Image (Self : Array_Type; Limit : Positive := 80) return String; -- Return an image for the array, given an image function for elements. The -- array will be represented enclosed in brackets, and elements will be -- separated by colons. If the image is longer than ``Limit``, then some -- wrapping will be applied. end Gpr_Parser_Support.Images;
szpaku80/wixel-yDrip
Ada
34,790
adb
M:ydrip F:G$sleepInit$0$0({2}DF,SV:S),C,0,0,0,0,0 F:G$ISR_ST$0$0({2}DF,SV:S),C,0,0,1,5,1 F:G$switchToRCOSC$0$0({2}DF,SV:S),C,0,0,0,0,0 F:G$uartEnable$0$0({2}DF,SV:S),C,0,0,0,0,0 F:G$uartDisable$0$0({2}DF,SV:S),C,0,0,0,0,0 F:G$blink_yellow_led$0$0({2}DF,SV:S),C,0,0,0,0,0 F:G$blink_red_led$0$0({2}DF,SV:S),C,0,0,0,0,0 F:G$getPacketPassedChecksum$0$0({2}DF,SC:U),C,0,0,0,0,0 F:G$bit_reverse_byte$0$0({2}DF,SC:U),C,0,0,0,0,0 F:G$min8$0$0({2}DF,SC:U),C,0,0,0,0,0 F:G$bit_reverse_bytes$0$0({2}DF,SV:S),C,0,0,0,0,0 F:G$dex_num_decoder$0$0({2}DF,SL:U),C,0,0,0,0,0 F:G$dexcom_src_to_ascii$0$0({2}DF,SV:S),C,0,0,0,0,0 F:G$clearRxErrors$0$0({2}DF,SV:S),C,0,0,0,0,0 F:G$doServices$0$0({2}DF,SV:S),C,0,0,0,0,0 F:G$initUart1$0$0({2}DF,SV:S),C,0,0,0,0,0 F:G$getSrcValue$0$0({2}DF,SL:U),Z,0,0,0,0,0 F:G$getESPString$0$0({2}DF,DX,SC:S),C,0,0,0,0,0 F:G$sendAT$0$0({2}DF,SV:S),C,0,0,0,0,0 F:G$enableESP$0$0({2}DF,SV:S),C,0,0,0,0,0 F:G$enableESP$0$0({2}DF,SV:S),C,0,0,0,0,0 F:G$getWifiStatus$0$0({2}DF,SI:S),C,0,0,0,0,0 F:G$getWifiStatus$0$0({2}DF,SI:S),C,0,0,0,0,0 F:G$wifiFlash$0$0({2}DF,SV:S),C,0,0,0,0,0 F:G$wifiConnect$0$0({2}DF,SB0$1:U),C,0,0,0,0,0 F:G$getTimeBytes$0$0({2}DF,SV:S),C,0,0,0,0,0 F:G$ESPsleep$0$0({2}DF,SV:S),C,0,0,0,0,0 F:G$print_packet$0$0({2}DF,SV:S),C,0,0,0,0,0 F:G$makeAllOutputs$0$0({2}DF,SV:S),C,0,0,0,0,0 F:G$makeAllOutputsLow$0$0({2}DF,SV:S),C,0,0,0,0,0 F:G$reset_offsets$0$0({2}DF,SV:S),C,0,0,0,0,0 F:G$killWithWatchdog$0$0({2}DF,SV:S),C,0,0,0,0,0 F:G$goToSleep$0$0({2}DF,SV:S),C,0,0,0,0,0 F:G$putchar$0$0({2}DF,SV:S),Z,0,0,0,0,0 F:G$printfUSB$0$0({2}DF,SV:S),C,0,0,0,0,0 F:G$swap_channel$0$0({2}DF,SV:S),C,0,0,0,0,0 F:G$strobe_radio$0$0({2}DF,SV:S),C,0,0,0,0,0 F:G$WaitForPacket$0$0({2}DF,SI:S),C,0,0,0,0,0 F:G$delayFor$0$0({2}DF,SL:U),C,0,0,0,0,0 F:G$get_packet$0$0({2}DF,SB0$1:U),C,0,0,0,0,0 F:G$setADCInputs$0$0({2}DF,SV:S),C,0,0,0,0,0 F:G$main$0$0({2}DF,SV:S),C,0,0,0,0,0 T:Fydrip$USB_DESCRIPTOR_ENDPOINT[({0}S:S$bLength$0$0({1}SC:U),Z,0,0)({1}S:S$bDescriptorType$0$0({1}SC:U),Z,0,0)({2}S:S$bEndpointAddress$0$0({1}SC:U),Z,0,0)({3}S:S$bmAttributes$0$0({1}SC:U),Z,0,0)({4}S:S$wMaxPacketSize$0$0({2}SI:U),Z,0,0)({6}S:S$bInterval$0$0({1}SC:U),Z,0,0)] T:Fydrip$USB_DESCRIPTOR_INTERFACE[({0}S:S$bLength$0$0({1}SC:U),Z,0,0)({1}S:S$bDescriptorType$0$0({1}SC:U),Z,0,0)({2}S:S$bInterfaceNumber$0$0({1}SC:U),Z,0,0)({3}S:S$bAlternateSetting$0$0({1}SC:U),Z,0,0)({4}S:S$bNumEndpoints$0$0({1}SC:U),Z,0,0)({5}S:S$bInterfaceClass$0$0({1}SC:U),Z,0,0)({6}S:S$bInterfaceSubClass$0$0({1}SC:U),Z,0,0)({7}S:S$bInterfaceProtocol$0$0({1}SC:U),Z,0,0)({8}S:S$iInterface$0$0({1}SC:U),Z,0,0)] T:Fydrip$__00010000[({0}S:S$SRCADDRH$0$0({1}SC:U),Z,0,0)({1}S:S$SRCADDRL$0$0({1}SC:U),Z,0,0)({2}S:S$DESTADDRH$0$0({1}SC:U),Z,0,0)({3}S:S$DESTADDRL$0$0({1}SC:U),Z,0,0)({4}S:S$VLEN_LENH$0$0({1}SC:U),Z,0,0)({5}S:S$LENL$0$0({1}SC:U),Z,0,0)({6}S:S$DC6$0$0({1}SC:U),Z,0,0)({7}S:S$DC7$0$0({1}SC:U),Z,0,0)] T:Fydrip$__00010001[({0}S:S$bmRequestType$1$0({1}SC:U),Z,0,0)({1}S:S$bRequest$1$0({1}SC:U),Z,0,0)({2}S:S$wValue$1$0({2}SI:U),Z,0,0)({4}S:S$wIndex$1$0({2}SI:U),Z,0,0)({6}S:S$wLength$1$0({2}SI:U),Z,0,0)({0}S:S$recipient$1$0({1}SB0$5:U),Z,0,0)({0}S:S$requestType$1$0({1}SB5$2:U),Z,0,0)({0}S:S$direction$1$0({1}SB7$1:U),Z,0,0)] T:Fydrip$__00020002[({0}S:S$bmRequestType$1$0({1}SC:U),Z,0,0)({1}S:S$bRequest$1$0({1}SC:U),Z,0,0)({2}S:S$wValue$1$0({2}SI:U),Z,0,0)({4}S:S$wIndex$1$0({2}SI:U),Z,0,0)({6}S:S$wLength$1$0({2}SI:U),Z,0,0)] T:Fydrip$__00020003[({0}S:S$recipient$1$0({1}SB0$5:U),Z,0,0)({0}S:S$requestType$1$0({1}SB5$2:U),Z,0,0)({0}S:S$direction$1$0({1}SB7$1:U),Z,0,0)] T:Fydrip$USB_DESCRIPTOR_DEVICE[({0}S:S$bLength$0$0({1}SC:U),Z,0,0)({1}S:S$bDescriptorType$0$0({1}SC:U),Z,0,0)({2}S:S$bcdUSB$0$0({2}SI:U),Z,0,0)({4}S:S$bDeviceClass$0$0({1}SC:U),Z,0,0)({5}S:S$bDeviceSubClass$0$0({1}SC:U),Z,0,0)({6}S:S$bDeviceProtocol$0$0({1}SC:U),Z,0,0)({7}S:S$bMaxPacketSize0$0$0({1}SC:U),Z,0,0)({8}S:S$idVendor$0$0({2}SI:U),Z,0,0)({10}S:S$idProduct$0$0({2}SI:U),Z,0,0)({12}S:S$bcdDevice$0$0({2}SI:U),Z,0,0)({14}S:S$iManufacturer$0$0({1}SC:U),Z,0,0)({15}S:S$iProduct$0$0({1}SC:U),Z,0,0)({16}S:S$iSerialNumber$0$0({1}SC:U),Z,0,0)({17}S:S$bNumConfigurations$0$0({1}SC:U),Z,0,0)] T:Fydrip$ACM_LINE_CODING[({0}S:S$dwDTERate$0$0({4}SL:U),Z,0,0)({4}S:S$bCharFormat$0$0({1}SC:U),Z,0,0)({5}S:S$bParityType$0$0({1}SC:U),Z,0,0)({6}S:S$bDataBits$0$0({1}SC:U),Z,0,0)] T:Fydrip$USB_DESCRIPTOR_CONFIGURATION[({0}S:S$bLength$0$0({1}SC:U),Z,0,0)({1}S:S$bDescriptorType$0$0({1}SC:U),Z,0,0)({2}S:S$wTotalLength$0$0({2}SI:U),Z,0,0)({4}S:S$bNumInterfaces$0$0({1}SC:U),Z,0,0)({5}S:S$bConfigurationValue$0$0({1}SC:U),Z,0,0)({6}S:S$iConfiguration$0$0({1}SC:U),Z,0,0)({7}S:S$bmAttributes$0$0({1}SC:U),Z,0,0)({8}S:S$bMaxPower$0$0({1}SC:U),Z,0,0)] T:Fydrip$_InitVect[({0}S:S$iv$0$0({16}DA16,SC:U),Z,0,0)({16}S:S$returncode$0$0({1}SC:U),Z,0,0)] T:Fydrip$_Dexcom_packet[({0}S:S$len$0$0({1}SC:U),Z,0,0)({1}S:S$dest_addr$0$0({4}SL:U),Z,0,0)({5}S:S$src_addr$0$0({4}SL:U),Z,0,0)({9}S:S$port$0$0({1}SC:U),Z,0,0)({10}S:S$device_info$0$0({1}SC:U),Z,0,0)({11}S:S$txId$0$0({1}SC:U),Z,0,0)({12}S:S$raw$0$0({2}SI:U),Z,0,0)({14}S:S$filtered$0$0({2}SI:U),Z,0,0)({16}S:S$battery$0$0({1}SC:U),Z,0,0)({17}S:S$unknown$0$0({1}SC:U),Z,0,0)({18}S:S$checksum$0$0({1}SC:U),Z,0,0)({19}S:S$RSSI$0$0({1}SC:S),Z,0,0)({20}S:S$LQI$0$0({1}SC:U),Z,0,0)] T:Fydrip$USB_DESCRIPTOR_INTERFACE_ASSOCIATION[({0}S:S$bLength$0$0({1}SC:U),Z,0,0)({1}S:S$bDescriptorType$0$0({1}SC:U),Z,0,0)({2}S:S$bFirstInterface$0$0({1}SC:U),Z,0,0)({3}S:S$bInterfaceCount$0$0({1}SC:U),Z,0,0)({4}S:S$bFunctionClass$0$0({1}SC:U),Z,0,0)({5}S:S$bFunctionSubClass$0$0({1}SC:U),Z,0,0)({6}S:S$bFunctionProtocol$0$0({1}SC:U),Z,0,0)({7}S:S$iFunction$0$0({1}SC:U),Z,0,0)] F:G$main$0$0({2}DF,SV:S),C,0,0,0,0,0 F:G$main$0$0({2}DF,SV:S),C,0,0,0,0,0 F:G$main$0$0({2}DF,SV:S),C,0,0,0,0,0 F:G$main$0$0({2}DF,SV:S),C,0,0,0,0,0 F:G$main$0$0({2}DF,SV:S),C,0,0,0,0,0 F:G$main$0$0({2}DF,SV:S),C,0,0,0,0,0 F:G$main$0$0({2}DF,SV:S),C,0,0,0,0,0 F:G$main$0$0({2}DF,SV:S),C,0,0,0,0,0 F:G$main$0$0({2}DF,SV:S),C,0,0,0,0,0 F:G$main$0$0({2}DF,SV:S),C,0,0,0,0,0 F:G$main$0$0({2}DF,SV:S),C,0,0,0,0,0 F:G$main$0$0({2}DF,SV:S),C,0,0,0,0,0 F:G$main$0$0({2}DF,SV:S),C,0,0,0,0,0 F:G$main$0$0({2}DF,SV:S),C,0,0,0,0,0 F:G$main$0$0({2}DF,SV:S),C,0,0,0,0,0 F:G$main$0$0({2}DF,SV:S),C,0,0,0,0,0 F:G$main$0$0({2}DF,SV:S),C,0,0,0,0,0 S:Lydrip.print_packet$sloc0$1$0({2}SI:S),E,0,0 S:Lydrip.print_packet$sloc1$1$0({2}SI:S),E,0,0 S:Lydrip.print_packet$sloc2$1$0({4}SL:U),E,0,0 S:Lydrip.goToSleep$sloc0$1$0({2}SI:S),E,0,0 S:Lydrip.goToSleep$sloc1$1$0({4}SL:U),E,0,0 S:Lydrip.WaitForPacket$sloc0$1$0({1}SC:U),E,0,0 S:Lydrip.WaitForPacket$sloc1$1$0({4}SL:U),E,0,0 S:Lydrip.WaitForPacket$sloc2$1$0({2}SI:U),E,0,0 S:Lydrip.WaitForPacket$sloc3$1$0({4}SL:U),E,0,0 S:Lydrip.WaitForPacket$sloc4$1$0({4}SL:U),E,0,0 S:Lydrip.WaitForPacket$sloc5$1$0({4}SL:U),E,0,0 S:Lydrip.delayFor$sloc0$1$0({4}SL:U),E,0,0 S:G$usbSuspendMode$0$0({1}SB0$1:U),H,0,0 S:G$usbActivityFlag$0$0({1}SB0$1:U),H,0,0 S:G$radioRxOverflowOccurred$0$0({1}SB0$1:U),H,0,0 S:G$radioTxUnderflowOccurred$0$0({1}SB0$1:U),H,0,0 S:G$radioQueueAllowCrcErrors$0$0({1}SB0$1:U),H,0,0 S:G$uart1RxParityErrorOccurred$0$0({1}SB0$1:U),H,0,0 S:G$uart1RxFramingErrorOccurred$0$0({1}SB0$1:U),H,0,0 S:G$uart1RxBufferFullOccurred$0$0({1}SB0$1:U),H,0,0 S:Fydrip$only_listen_for_my_transmitter$0$0({1}SB0$1:U),H,0,0 S:Fydrip$status_lights$0$0({1}SB0$1:U),H,0,0 S:Fydrip$allow_alternate_usb_protocol$0$0({1}SB0$1:U),H,0,0 S:Fydrip$debug_mode$0$0({1}SB0$1:U),H,0,0 S:Fydrip$encrypt_output$0$0({1}SB0$1:U),H,0,0 S:G$needsTimingCalibration$0$0({1}SB0$1:U),H,0,0 S:G$usbEnabled$0$0({1}SB0$1:U),H,0,0 S:Lydrip.goToSleep$storedDma0Armed$3$3({1}SB0$1:U),H,0,0 S:Lydrip.goToSleep$savedP0IE$3$3({1}SB0$1:U),H,0,0 S:G$usbComLineCodingChangeHandler$0$0({2}DC,DF,SV:S),P,0,0 S:Fydrip$wake_earlier_for_next_miss$0$0({1}SC:U),P,0,0 S:Fydrip$misses_until_failure$0$0({1}SC:U),P,0,0 S:Fydrip$fOffset$0$0({4}DA4,SC:S),P,0,0 S:Fydrip$nChannels$0$0({4}DA4,SC:U),P,0,0 S:Fydrip$waitTimes$0$0({16}DA4,SL:U),P,0,0 S:Fydrip$delayedWaitTimes$0$0({16}DA4,SL:U),P,0,0 S:Fydrip$catch_offsets$0$0({16}DA4,SL:U),P,0,0 S:Fydrip$last_catch_channel$0$0({1}SC:U),P,0,0 S:Fydrip$save_IEN0$0$0({1}SC:U),P,0,0 S:Fydrip$save_IEN1$0$0({1}SC:U),P,0,0 S:Fydrip$save_IEN2$0$0({1}SC:U),P,0,0 S:G$sequential_missed_packets$0$0({1}SC:U),P,0,0 S:G$intMaxStrLen$0$0({1}SC:U),P,0,0 S:Lydrip.getPacketPassedChecksum$p$1$1({2}DX,ST_Dexcom_packet:S),R,0,0,[r6,r7] S:Lydrip.bit_reverse_byte$in$1$1({1}SC:U),R,0,0,[r7] S:Lydrip.min8$b$1$1({1}SC:U),P,0,0 S:Lydrip.min8$a$1$1({1}SC:U),R,0,0,[r7] S:Lydrip.bit_reverse_bytes$nLen$1$1({1}SC:U),P,0,0 S:Lydrip.bit_reverse_bytes$buf$1$1({3}DG,SC:U),P,0,0 S:Lydrip.dex_num_decoder$usShortFloat$1$1({2}SI:U),R,0,0,[r6,r7] S:Lydrip.enableESP$point$1$1({3}DG,SC:S),R,0,0,[r5,r6,r7] S:Lydrip.getTimeBytes$tVector$1$1({2}DX,ST_InitVect:S),P,0,0 S:Lydrip.print_packet$pPkt$1$1({2}DX,ST_Dexcom_packet:S),P,0,0 S:Lydrip.goToSleep$temp$3$3({1}SC:U),R,0,0,[r2] S:Lydrip.goToSleep$storedDescHigh$3$3({1}SC:U),P,0,0 S:Lydrip.goToSleep$storedDescLow$3$3({1}SC:U),P,0,0 S:Lydrip.goToSleep$storedIEN0$3$3({1}SC:U),R,0,0,[r3] S:Lydrip.goToSleep$storedIEN1$3$3({1}SC:U),P,0,0 S:Lydrip.goToSleep$storedIEN2$3$3({1}SC:U),P,0,0 S:Lydrip.goToSleep$savedPICTL$3$3({1}SC:U),R,0,0,[r7] S:Lydrip.goToSleep$savedP0SEL$3$3({1}SC:U),R,0,0,[r6] S:Lydrip.goToSleep$savedP0DIR$3$3({1}SC:U),R,0,0,[r5] S:Lydrip.goToSleep$savedP1SEL$3$3({1}SC:U),P,0,0 S:Lydrip.goToSleep$savedP1DIR$3$3({1}SC:U),P,0,0 S:Lydrip.goToSleep$start_waiting$3$8({4}SL:U),P,0,0 S:Lydrip.printfUSB$stringForUSB$1$1({3}DG,SC:S),R,0,0,[r5,r6,r7] S:Lydrip.strobe_radio$radio_chan$1$1({2}SI:S),R,0,0,[r6,r7] S:Lydrip.WaitForPacket$pkt$1$1({2}DX,ST_Dexcom_packet:S),P,0,0 S:Lydrip.WaitForPacket$packet$1$1({2}DX,SC:U),R,0,0,[r4,r5] S:Lydrip.WaitForPacket$len$3$6({1}SC:U),R,0,0,[r7] S:Lydrip.get_packet$pPkt$1$1({2}DX,ST_Dexcom_packet:S),P,0,0 S:Lydrip.get_packet$nChannel$1$1({2}SI:S),R,0,0,[r4,r5] S:Lydrip.main$first_square$3$7({2}SI:S),R,0,0,[r6,r7] S:Lydrip.main$second_square$3$7({2}SI:S),R,0,0,[r4,r5] S:Lydrip.main$sleep_time$3$7({2}SI:S),R,0,0,[] S:Fydrip$SYNC1$0$0({1}SC:U),F,0,0 S:Fydrip$SYNC0$0$0({1}SC:U),F,0,0 S:Fydrip$PKTLEN$0$0({1}SC:U),F,0,0 S:Fydrip$PKTCTRL1$0$0({1}SC:U),F,0,0 S:Fydrip$PKTCTRL0$0$0({1}SC:U),F,0,0 S:Fydrip$ADDR$0$0({1}SC:U),F,0,0 S:Fydrip$CHANNR$0$0({1}SC:U),F,0,0 S:Fydrip$FSCTRL1$0$0({1}SC:U),F,0,0 S:Fydrip$FSCTRL0$0$0({1}SC:U),F,0,0 S:Fydrip$FREQ2$0$0({1}SC:U),F,0,0 S:Fydrip$FREQ1$0$0({1}SC:U),F,0,0 S:Fydrip$FREQ0$0$0({1}SC:U),F,0,0 S:Fydrip$MDMCFG4$0$0({1}SC:U),F,0,0 S:Fydrip$MDMCFG3$0$0({1}SC:U),F,0,0 S:Fydrip$MDMCFG2$0$0({1}SC:U),F,0,0 S:Fydrip$MDMCFG1$0$0({1}SC:U),F,0,0 S:Fydrip$MDMCFG0$0$0({1}SC:U),F,0,0 S:Fydrip$DEVIATN$0$0({1}SC:U),F,0,0 S:Fydrip$MCSM2$0$0({1}SC:U),F,0,0 S:Fydrip$MCSM1$0$0({1}SC:U),F,0,0 S:Fydrip$MCSM0$0$0({1}SC:U),F,0,0 S:Fydrip$FOCCFG$0$0({1}SC:U),F,0,0 S:Fydrip$BSCFG$0$0({1}SC:U),F,0,0 S:Fydrip$AGCCTRL2$0$0({1}SC:U),F,0,0 S:Fydrip$AGCCTRL1$0$0({1}SC:U),F,0,0 S:Fydrip$AGCCTRL0$0$0({1}SC:U),F,0,0 S:Fydrip$FREND1$0$0({1}SC:U),F,0,0 S:Fydrip$FREND0$0$0({1}SC:U),F,0,0 S:Fydrip$FSCAL3$0$0({1}SC:U),F,0,0 S:Fydrip$FSCAL2$0$0({1}SC:U),F,0,0 S:Fydrip$FSCAL1$0$0({1}SC:U),F,0,0 S:Fydrip$FSCAL0$0$0({1}SC:U),F,0,0 S:Fydrip$TEST2$0$0({1}SC:U),F,0,0 S:Fydrip$TEST1$0$0({1}SC:U),F,0,0 S:Fydrip$TEST0$0$0({1}SC:U),F,0,0 S:Fydrip$PA_TABLE0$0$0({1}SC:U),F,0,0 S:Fydrip$IOCFG2$0$0({1}SC:U),F,0,0 S:Fydrip$IOCFG1$0$0({1}SC:U),F,0,0 S:Fydrip$IOCFG0$0$0({1}SC:U),F,0,0 S:Fydrip$PARTNUM$0$0({1}SC:U),F,0,0 S:Fydrip$VERSION$0$0({1}SC:U),F,0,0 S:Fydrip$FREQEST$0$0({1}SC:U),F,0,0 S:Fydrip$LQI$0$0({1}SC:U),F,0,0 S:Fydrip$RSSI$0$0({1}SC:U),F,0,0 S:Fydrip$MARCSTATE$0$0({1}SC:U),F,0,0 S:Fydrip$PKTSTATUS$0$0({1}SC:U),F,0,0 S:Fydrip$VCO_VC_DAC$0$0({1}SC:U),F,0,0 S:Fydrip$I2SCFG0$0$0({1}SC:U),F,0,0 S:Fydrip$I2SCFG1$0$0({1}SC:U),F,0,0 S:Fydrip$I2SDATL$0$0({1}SC:U),F,0,0 S:Fydrip$I2SDATH$0$0({1}SC:U),F,0,0 S:Fydrip$I2SWCNT$0$0({1}SC:U),F,0,0 S:Fydrip$I2SSTAT$0$0({1}SC:U),F,0,0 S:Fydrip$I2SCLKF0$0$0({1}SC:U),F,0,0 S:Fydrip$I2SCLKF1$0$0({1}SC:U),F,0,0 S:Fydrip$I2SCLKF2$0$0({1}SC:U),F,0,0 S:Fydrip$USBADDR$0$0({1}SC:U),F,0,0 S:Fydrip$USBPOW$0$0({1}SC:U),F,0,0 S:Fydrip$USBIIF$0$0({1}SC:U),F,0,0 S:Fydrip$USBOIF$0$0({1}SC:U),F,0,0 S:Fydrip$USBCIF$0$0({1}SC:U),F,0,0 S:Fydrip$USBIIE$0$0({1}SC:U),F,0,0 S:Fydrip$USBOIE$0$0({1}SC:U),F,0,0 S:Fydrip$USBCIE$0$0({1}SC:U),F,0,0 S:Fydrip$USBFRML$0$0({1}SC:U),F,0,0 S:Fydrip$USBFRMH$0$0({1}SC:U),F,0,0 S:Fydrip$USBINDEX$0$0({1}SC:U),F,0,0 S:Fydrip$USBMAXI$0$0({1}SC:U),F,0,0 S:Fydrip$USBCSIL$0$0({1}SC:U),F,0,0 S:Fydrip$USBCSIH$0$0({1}SC:U),F,0,0 S:Fydrip$USBMAXO$0$0({1}SC:U),F,0,0 S:Fydrip$USBCSOL$0$0({1}SC:U),F,0,0 S:Fydrip$USBCSOH$0$0({1}SC:U),F,0,0 S:Fydrip$USBCNTL$0$0({1}SC:U),F,0,0 S:Fydrip$USBCNTH$0$0({1}SC:U),F,0,0 S:Fydrip$USBF0$0$0({1}SC:U),F,0,0 S:Fydrip$USBF1$0$0({1}SC:U),F,0,0 S:Fydrip$USBF2$0$0({1}SC:U),F,0,0 S:Fydrip$USBF3$0$0({1}SC:U),F,0,0 S:Fydrip$USBF4$0$0({1}SC:U),F,0,0 S:Fydrip$USBF5$0$0({1}SC:U),F,0,0 S:G$usbDeviceState$0$0({1}SC:U),F,0,0 S:G$usbSetupPacket$0$0({8}ST__00010001:S),F,0,0 S:G$usbComLineCoding$0$0({7}STACM_LINE_CODING:S),F,0,0 S:Lydrip.bit_reverse_byte$bRet$1$1({1}SC:U),F,0,0 S:Lydrip.bit_reverse_bytes$i$1$1({1}SC:U),F,0,0 S:Lydrip.dex_num_decoder$usReversed$1$1({2}SI:U),F,0,0 S:Lydrip.dex_num_decoder$usExponent$1$1({1}SC:U),F,0,0 S:Lydrip.dex_num_decoder$usMantissa$1$1({4}SL:U),F,0,0 S:Lydrip.dexcom_src_to_ascii$addr$1$1({2}DX,SC:S),F,0,0 S:Lydrip.dexcom_src_to_ascii$src$1$1({4}SL:U),F,0,0 S:Lydrip.getSrcValue$srcVal$1$1({1}SC:S),F,0,0 S:Lydrip.getSrcValue$i$1$1({1}SC:U),F,0,0 S:Lydrip.getESPString$uartCharacters$1$1({80}DA80,SC:S),F,0,0 S:Lydrip.getESPString$i$1$1({1}SC:S),F,0,0 S:Lydrip.getESPString$stop$1$1({4}SL:S),F,0,0 S:Lydrip.getESPString$now$1$1({4}SL:S),F,0,0 S:Lydrip.sendAT$atString$1$1({2}DX,SC:S),F,0,0 S:Lydrip.sendAT$ATresponse$1$1({80}DA80,SC:S),F,0,0 S:Lydrip.enableESP$c$1$1({80}DA80,SC:S),F,0,0 S:Lydrip.enableESP$nofile$1$1({7}DA7,SC:S),F,0,0 S:Lydrip.enableESP$clen$1$1({2}SI:S),F,0,0 S:Lydrip.getWifiStatus$i$1$1({2}SI:S),F,0,0 S:Lydrip.getWifiStatus$intStatus$1$1({2}SI:S),F,0,0 S:Lydrip.getWifiStatus$c$1$1({80}DA80,SC:S),F,0,0 S:Lydrip.wifiFlash$i$1$1({1}SC:U),F,0,0 S:Lydrip.wifiFlash$intWifiStatus$1$1({2}SI:S),F,0,0 S:Lydrip.wifiConnect$atString$1$1({40}DA40,SC:S),F,0,0 S:Lydrip.wifiConnect$intWifiStatus$1$1({2}SI:S),F,0,0 S:Lydrip.getTimeBytes$c$1$1({80}DA80,SC:S),F,0,0 S:Lydrip.getTimeBytes$lenC$1$1({2}SI:S),F,0,0 S:Lydrip.getTimeBytes$i$1$1({1}SC:S),F,0,0 S:Lydrip.getTimeBytes$strMMM$1$1({4}DA4,SC:S),F,0,0 S:Lydrip.print_packet$transID$1$1({6}DA6,SC:S),F,0,0 S:Lydrip.print_packet$iv$1$1({16}DA16,SC:U),F,0,0 S:Lydrip.print_packet$i$1$1({1}SC:U),F,0,0 S:Lydrip.print_packet$sprintfBuffer$1$1({64}DA64,SC:U),F,0,0 S:Lydrip.print_packet$AESBuffer$1$1({64}DA64,SC:U),F,0,0 S:Lydrip.print_packet$prtlen$1$1({2}SI:S),F,0,0 S:Lydrip.print_packet$getTimeResponse$1$1({17}ST_InitVect:S),F,0,0 S:Lydrip.makeAllOutputs$i$1$1({2}SI:S),F,0,0 S:Lydrip.makeAllOutputsLow$i$1$1({2}SI:S),F,0,0 S:Lydrip.reset_offsets$i$1$1({2}SI:S),F,0,0 S:Lydrip.goToSleep$seconds$1$1({2}SI:S),F,0,0 S:Lydrip.putchar$c$1$1({1}SC:S),F,0,0 S:Lydrip.printfUSB$length$1$1({1}SC:U),F,0,0 S:Lydrip.printfUSB$i$1$1({1}SC:U),F,0,0 S:Lydrip.swap_channel$newFSCTRL0$1$1({1}SC:U),F,0,0 S:Lydrip.swap_channel$channel$1$1({1}SC:U),F,0,0 S:Lydrip.WaitForPacket$channel$1$1({1}SC:U),F,0,0 S:Lydrip.WaitForPacket$milliseconds$1$1({2}SI:U),F,0,0 S:Lydrip.WaitForPacket$start$1$1({4}SL:U),F,0,0 S:Lydrip.WaitForPacket$i$1$1({4}SL:U),F,0,0 S:Lydrip.WaitForPacket$six_minutes$1$1({4}SL:U),F,0,0 S:Lydrip.WaitForPacket$nRet$1$1({2}SI:S),F,0,0 S:Lydrip.WaitForPacket$transID$1$1({6}DA6,SC:S),F,0,0 S:Lydrip.delayFor$wait_chan$1$1({2}SI:S),F,0,0 S:Lydrip.main$Pkt$2$2({21}ST_Dexcom_packet:S),F,0,0 S:Fydrip$transmitter_id$0$0({6}DA6,SC:S),F,0,0 S:Fydrip$dexie_host_address$0$0({22}DA22,SC:S),F,0,0 S:Fydrip$dexie_host_port$0$0({6}DA6,SC:S),F,0,0 S:G$wixFone_ID$0$0({8}DA8,SC:S),F,0,0 S:Fydrip$key$0$0({16}DA16,SC:U),F,0,0 S:Fydrip$start_channel$0$0({1}SC:S),F,0,0 S:Fydrip$defaultfOffset$0$0({4}DA4,SC:S),F,0,0 S:G$PM2_BUF$0$0({7}DA7,SC:U),F,0,0 S:G$dmaDesc$0$0({8}DA8,SC:U),F,0,0 S:G$AT_TIMEOUT$0$0({1}SC:U),F,0,0 S:Fydrip$defaultWaitTime$0$0({4}SL:U),F,0,0 S:G$SrcNameTable$0$0({32}DA32,SC:S),F,0,0 S:Fydrip$P0$0$0({1}SC:U),I,0,0 S:Fydrip$SP$0$0({1}SC:U),I,0,0 S:Fydrip$DPL0$0$0({1}SC:U),I,0,0 S:Fydrip$DPH0$0$0({1}SC:U),I,0,0 S:Fydrip$DPL1$0$0({1}SC:U),I,0,0 S:Fydrip$DPH1$0$0({1}SC:U),I,0,0 S:Fydrip$U0CSR$0$0({1}SC:U),I,0,0 S:Fydrip$PCON$0$0({1}SC:U),I,0,0 S:Fydrip$TCON$0$0({1}SC:U),I,0,0 S:Fydrip$P0IFG$0$0({1}SC:U),I,0,0 S:Fydrip$P1IFG$0$0({1}SC:U),I,0,0 S:Fydrip$P2IFG$0$0({1}SC:U),I,0,0 S:Fydrip$PICTL$0$0({1}SC:U),I,0,0 S:Fydrip$P1IEN$0$0({1}SC:U),I,0,0 S:Fydrip$P0INP$0$0({1}SC:U),I,0,0 S:Fydrip$P1$0$0({1}SC:U),I,0,0 S:Fydrip$RFIM$0$0({1}SC:U),I,0,0 S:Fydrip$DPS$0$0({1}SC:U),I,0,0 S:Fydrip$MPAGE$0$0({1}SC:U),I,0,0 S:Fydrip$ENDIAN$0$0({1}SC:U),I,0,0 S:Fydrip$S0CON$0$0({1}SC:U),I,0,0 S:Fydrip$IEN2$0$0({1}SC:U),I,0,0 S:Fydrip$S1CON$0$0({1}SC:U),I,0,0 S:Fydrip$T2CT$0$0({1}SC:U),I,0,0 S:Fydrip$T2PR$0$0({1}SC:U),I,0,0 S:Fydrip$T2CTL$0$0({1}SC:U),I,0,0 S:Fydrip$P2$0$0({1}SC:U),I,0,0 S:Fydrip$WORIRQ$0$0({1}SC:U),I,0,0 S:Fydrip$WORCTRL$0$0({1}SC:U),I,0,0 S:Fydrip$WOREVT0$0$0({1}SC:U),I,0,0 S:Fydrip$WOREVT1$0$0({1}SC:U),I,0,0 S:Fydrip$WORTIME0$0$0({1}SC:U),I,0,0 S:Fydrip$WORTIME1$0$0({1}SC:U),I,0,0 S:Fydrip$IEN0$0$0({1}SC:U),I,0,0 S:Fydrip$IP0$0$0({1}SC:U),I,0,0 S:Fydrip$FWT$0$0({1}SC:U),I,0,0 S:Fydrip$FADDRL$0$0({1}SC:U),I,0,0 S:Fydrip$FADDRH$0$0({1}SC:U),I,0,0 S:Fydrip$FCTL$0$0({1}SC:U),I,0,0 S:Fydrip$FWDATA$0$0({1}SC:U),I,0,0 S:Fydrip$ENCDI$0$0({1}SC:U),I,0,0 S:Fydrip$ENCDO$0$0({1}SC:U),I,0,0 S:Fydrip$ENCCS$0$0({1}SC:U),I,0,0 S:Fydrip$ADCCON1$0$0({1}SC:U),I,0,0 S:Fydrip$ADCCON2$0$0({1}SC:U),I,0,0 S:Fydrip$ADCCON3$0$0({1}SC:U),I,0,0 S:Fydrip$IEN1$0$0({1}SC:U),I,0,0 S:Fydrip$IP1$0$0({1}SC:U),I,0,0 S:Fydrip$ADCL$0$0({1}SC:U),I,0,0 S:Fydrip$ADCH$0$0({1}SC:U),I,0,0 S:Fydrip$RNDL$0$0({1}SC:U),I,0,0 S:Fydrip$RNDH$0$0({1}SC:U),I,0,0 S:Fydrip$SLEEP$0$0({1}SC:U),I,0,0 S:Fydrip$IRCON$0$0({1}SC:U),I,0,0 S:Fydrip$U0DBUF$0$0({1}SC:U),I,0,0 S:Fydrip$U0BAUD$0$0({1}SC:U),I,0,0 S:Fydrip$U0UCR$0$0({1}SC:U),I,0,0 S:Fydrip$U0GCR$0$0({1}SC:U),I,0,0 S:Fydrip$CLKCON$0$0({1}SC:U),I,0,0 S:Fydrip$MEMCTR$0$0({1}SC:U),I,0,0 S:Fydrip$WDCTL$0$0({1}SC:U),I,0,0 S:Fydrip$T3CNT$0$0({1}SC:U),I,0,0 S:Fydrip$T3CTL$0$0({1}SC:U),I,0,0 S:Fydrip$T3CCTL0$0$0({1}SC:U),I,0,0 S:Fydrip$T3CC0$0$0({1}SC:U),I,0,0 S:Fydrip$T3CCTL1$0$0({1}SC:U),I,0,0 S:Fydrip$T3CC1$0$0({1}SC:U),I,0,0 S:Fydrip$PSW$0$0({1}SC:U),I,0,0 S:Fydrip$DMAIRQ$0$0({1}SC:U),I,0,0 S:Fydrip$DMA1CFGL$0$0({1}SC:U),I,0,0 S:Fydrip$DMA1CFGH$0$0({1}SC:U),I,0,0 S:Fydrip$DMA0CFGL$0$0({1}SC:U),I,0,0 S:Fydrip$DMA0CFGH$0$0({1}SC:U),I,0,0 S:Fydrip$DMAARM$0$0({1}SC:U),I,0,0 S:Fydrip$DMAREQ$0$0({1}SC:U),I,0,0 S:Fydrip$TIMIF$0$0({1}SC:U),I,0,0 S:Fydrip$RFD$0$0({1}SC:U),I,0,0 S:Fydrip$T1CC0L$0$0({1}SC:U),I,0,0 S:Fydrip$T1CC0H$0$0({1}SC:U),I,0,0 S:Fydrip$T1CC1L$0$0({1}SC:U),I,0,0 S:Fydrip$T1CC1H$0$0({1}SC:U),I,0,0 S:Fydrip$T1CC2L$0$0({1}SC:U),I,0,0 S:Fydrip$T1CC2H$0$0({1}SC:U),I,0,0 S:Fydrip$ACC$0$0({1}SC:U),I,0,0 S:Fydrip$RFST$0$0({1}SC:U),I,0,0 S:Fydrip$T1CNTL$0$0({1}SC:U),I,0,0 S:Fydrip$T1CNTH$0$0({1}SC:U),I,0,0 S:Fydrip$T1CTL$0$0({1}SC:U),I,0,0 S:Fydrip$T1CCTL0$0$0({1}SC:U),I,0,0 S:Fydrip$T1CCTL1$0$0({1}SC:U),I,0,0 S:Fydrip$T1CCTL2$0$0({1}SC:U),I,0,0 S:Fydrip$IRCON2$0$0({1}SC:U),I,0,0 S:Fydrip$RFIF$0$0({1}SC:U),I,0,0 S:Fydrip$T4CNT$0$0({1}SC:U),I,0,0 S:Fydrip$T4CTL$0$0({1}SC:U),I,0,0 S:Fydrip$T4CCTL0$0$0({1}SC:U),I,0,0 S:Fydrip$T4CC0$0$0({1}SC:U),I,0,0 S:Fydrip$T4CCTL1$0$0({1}SC:U),I,0,0 S:Fydrip$T4CC1$0$0({1}SC:U),I,0,0 S:Fydrip$B$0$0({1}SC:U),I,0,0 S:Fydrip$PERCFG$0$0({1}SC:U),I,0,0 S:Fydrip$ADCCFG$0$0({1}SC:U),I,0,0 S:Fydrip$P0SEL$0$0({1}SC:U),I,0,0 S:Fydrip$P1SEL$0$0({1}SC:U),I,0,0 S:Fydrip$P2SEL$0$0({1}SC:U),I,0,0 S:Fydrip$P1INP$0$0({1}SC:U),I,0,0 S:Fydrip$P2INP$0$0({1}SC:U),I,0,0 S:Fydrip$U1CSR$0$0({1}SC:U),I,0,0 S:Fydrip$U1DBUF$0$0({1}SC:U),I,0,0 S:Fydrip$U1BAUD$0$0({1}SC:U),I,0,0 S:Fydrip$U1UCR$0$0({1}SC:U),I,0,0 S:Fydrip$U1GCR$0$0({1}SC:U),I,0,0 S:Fydrip$P0DIR$0$0({1}SC:U),I,0,0 S:Fydrip$P1DIR$0$0({1}SC:U),I,0,0 S:Fydrip$P2DIR$0$0({1}SC:U),I,0,0 S:Fydrip$DMA0CFG$0$0({2}SI:U),I,0,0 S:Fydrip$DMA1CFG$0$0({2}SI:U),I,0,0 S:Fydrip$FADDR$0$0({2}SI:U),I,0,0 S:Fydrip$ADC$0$0({2}SI:U),I,0,0 S:Fydrip$T1CC0$0$0({2}SI:U),I,0,0 S:Fydrip$T1CC1$0$0({2}SI:U),I,0,0 S:Fydrip$T1CC2$0$0({2}SI:U),I,0,0 S:Fydrip$P0_0$0$0({1}SX:U),J,0,0 S:Fydrip$P0_1$0$0({1}SX:U),J,0,0 S:Fydrip$P0_2$0$0({1}SX:U),J,0,0 S:Fydrip$P0_3$0$0({1}SX:U),J,0,0 S:Fydrip$P0_4$0$0({1}SX:U),J,0,0 S:Fydrip$P0_5$0$0({1}SX:U),J,0,0 S:Fydrip$P0_6$0$0({1}SX:U),J,0,0 S:Fydrip$P0_7$0$0({1}SX:U),J,0,0 S:Fydrip$_TCON_0$0$0({1}SX:U),J,0,0 S:Fydrip$RFTXRXIF$0$0({1}SX:U),J,0,0 S:Fydrip$_TCON_2$0$0({1}SX:U),J,0,0 S:Fydrip$URX0IF$0$0({1}SX:U),J,0,0 S:Fydrip$_TCON_4$0$0({1}SX:U),J,0,0 S:Fydrip$ADCIF$0$0({1}SX:U),J,0,0 S:Fydrip$_TCON_6$0$0({1}SX:U),J,0,0 S:Fydrip$URX1IF$0$0({1}SX:U),J,0,0 S:Fydrip$P1_0$0$0({1}SX:U),J,0,0 S:Fydrip$P1_1$0$0({1}SX:U),J,0,0 S:Fydrip$P1_2$0$0({1}SX:U),J,0,0 S:Fydrip$P1_3$0$0({1}SX:U),J,0,0 S:Fydrip$P1_4$0$0({1}SX:U),J,0,0 S:Fydrip$P1_5$0$0({1}SX:U),J,0,0 S:Fydrip$P1_6$0$0({1}SX:U),J,0,0 S:Fydrip$P1_7$0$0({1}SX:U),J,0,0 S:Fydrip$ENCIF_0$0$0({1}SX:U),J,0,0 S:Fydrip$ENCIF_1$0$0({1}SX:U),J,0,0 S:Fydrip$_SOCON2$0$0({1}SX:U),J,0,0 S:Fydrip$_SOCON3$0$0({1}SX:U),J,0,0 S:Fydrip$_SOCON4$0$0({1}SX:U),J,0,0 S:Fydrip$_SOCON5$0$0({1}SX:U),J,0,0 S:Fydrip$_SOCON6$0$0({1}SX:U),J,0,0 S:Fydrip$_SOCON7$0$0({1}SX:U),J,0,0 S:Fydrip$P2_0$0$0({1}SX:U),J,0,0 S:Fydrip$P2_1$0$0({1}SX:U),J,0,0 S:Fydrip$P2_2$0$0({1}SX:U),J,0,0 S:Fydrip$P2_3$0$0({1}SX:U),J,0,0 S:Fydrip$P2_4$0$0({1}SX:U),J,0,0 S:Fydrip$P2_5$0$0({1}SX:U),J,0,0 S:Fydrip$P2_6$0$0({1}SX:U),J,0,0 S:Fydrip$P2_7$0$0({1}SX:U),J,0,0 S:Fydrip$RFTXRXIE$0$0({1}SX:U),J,0,0 S:Fydrip$ADCIE$0$0({1}SX:U),J,0,0 S:Fydrip$URX0IE$0$0({1}SX:U),J,0,0 S:Fydrip$URX1IE$0$0({1}SX:U),J,0,0 S:Fydrip$ENCIE$0$0({1}SX:U),J,0,0 S:Fydrip$STIE$0$0({1}SX:U),J,0,0 S:Fydrip$_IEN06$0$0({1}SX:U),J,0,0 S:Fydrip$EA$0$0({1}SX:U),J,0,0 S:Fydrip$DMAIE$0$0({1}SX:U),J,0,0 S:Fydrip$T1IE$0$0({1}SX:U),J,0,0 S:Fydrip$T2IE$0$0({1}SX:U),J,0,0 S:Fydrip$T3IE$0$0({1}SX:U),J,0,0 S:Fydrip$T4IE$0$0({1}SX:U),J,0,0 S:Fydrip$P0IE$0$0({1}SX:U),J,0,0 S:Fydrip$_IEN16$0$0({1}SX:U),J,0,0 S:Fydrip$_IEN17$0$0({1}SX:U),J,0,0 S:Fydrip$DMAIF$0$0({1}SX:U),J,0,0 S:Fydrip$T1IF$0$0({1}SX:U),J,0,0 S:Fydrip$T2IF$0$0({1}SX:U),J,0,0 S:Fydrip$T3IF$0$0({1}SX:U),J,0,0 S:Fydrip$T4IF$0$0({1}SX:U),J,0,0 S:Fydrip$P0IF$0$0({1}SX:U),J,0,0 S:Fydrip$_IRCON6$0$0({1}SX:U),J,0,0 S:Fydrip$STIF$0$0({1}SX:U),J,0,0 S:Fydrip$P$0$0({1}SX:U),J,0,0 S:Fydrip$F1$0$0({1}SX:U),J,0,0 S:Fydrip$OV$0$0({1}SX:U),J,0,0 S:Fydrip$RS0$0$0({1}SX:U),J,0,0 S:Fydrip$RS1$0$0({1}SX:U),J,0,0 S:Fydrip$F0$0$0({1}SX:U),J,0,0 S:Fydrip$AC$0$0({1}SX:U),J,0,0 S:Fydrip$CY$0$0({1}SX:U),J,0,0 S:Fydrip$T3OVFIF$0$0({1}SX:U),J,0,0 S:Fydrip$T3CH0IF$0$0({1}SX:U),J,0,0 S:Fydrip$T3CH1IF$0$0({1}SX:U),J,0,0 S:Fydrip$T4OVFIF$0$0({1}SX:U),J,0,0 S:Fydrip$T4CH0IF$0$0({1}SX:U),J,0,0 S:Fydrip$T4CH1IF$0$0({1}SX:U),J,0,0 S:Fydrip$OVFIM$0$0({1}SX:U),J,0,0 S:Fydrip$_TIMIF7$0$0({1}SX:U),J,0,0 S:Fydrip$ACC_0$0$0({1}SX:U),J,0,0 S:Fydrip$ACC_1$0$0({1}SX:U),J,0,0 S:Fydrip$ACC_2$0$0({1}SX:U),J,0,0 S:Fydrip$ACC_3$0$0({1}SX:U),J,0,0 S:Fydrip$ACC_4$0$0({1}SX:U),J,0,0 S:Fydrip$ACC_5$0$0({1}SX:U),J,0,0 S:Fydrip$ACC_6$0$0({1}SX:U),J,0,0 S:Fydrip$ACC_7$0$0({1}SX:U),J,0,0 S:Fydrip$P2IF$0$0({1}SX:U),J,0,0 S:Fydrip$UTX0IF$0$0({1}SX:U),J,0,0 S:Fydrip$UTX1IF$0$0({1}SX:U),J,0,0 S:Fydrip$P1IF$0$0({1}SX:U),J,0,0 S:Fydrip$WDTIF$0$0({1}SX:U),J,0,0 S:Fydrip$_IRCON25$0$0({1}SX:U),J,0,0 S:Fydrip$_IRCON26$0$0({1}SX:U),J,0,0 S:Fydrip$_IRCON27$0$0({1}SX:U),J,0,0 S:Fydrip$B_0$0$0({1}SX:U),J,0,0 S:Fydrip$B_1$0$0({1}SX:U),J,0,0 S:Fydrip$B_2$0$0({1}SX:U),J,0,0 S:Fydrip$B_3$0$0({1}SX:U),J,0,0 S:Fydrip$B_4$0$0({1}SX:U),J,0,0 S:Fydrip$B_5$0$0({1}SX:U),J,0,0 S:Fydrip$B_6$0$0({1}SX:U),J,0,0 S:Fydrip$B_7$0$0({1}SX:U),J,0,0 S:Fydrip$U1ACTIVE$0$0({1}SX:U),J,0,0 S:Fydrip$U1TX_BYTE$0$0({1}SX:U),J,0,0 S:Fydrip$U1RX_BYTE$0$0({1}SX:U),J,0,0 S:Fydrip$U1ERR$0$0({1}SX:U),J,0,0 S:Fydrip$U1FE$0$0({1}SX:U),J,0,0 S:Fydrip$U1SLAVE$0$0({1}SX:U),J,0,0 S:Fydrip$U1RE$0$0({1}SX:U),J,0,0 S:Fydrip$U1MODE$0$0({1}SX:U),J,0,0 S:G$systemInit$0$0({2}DF,SV:S),C,0,0 S:G$boardIoInit$0$0({2}DF,SV:S),C,0,0 S:G$boardClockInit$0$0({2}DF,SV:S),C,0,0 S:G$boardService$0$0({2}DF,SV:S),C,0,0 S:G$boardStartBootloaderIfNeeded$0$0({2}DF,SV:S),C,0,0 S:G$boardStartBootloader$0$0({2}DF,SV:S),C,0,0 S:G$usbPowerPresent$0$0({2}DF,SB0$1:U),C,0,0 S:G$vinPowerPresent$0$0({2}DF,SB0$1:U),C,0,0 S:G$enableUsbPullup$0$0({2}DF,SV:S),C,0,0 S:G$disableUsbPullup$0$0({2}DF,SV:S),C,0,0 S:G$randomSeedFromAdc$0$0({2}DF,SV:S),C,0,0 S:G$randomSeedFromSerialNumber$0$0({2}DF,SV:S),C,0,0 S:G$randomNumber$0$0({2}DF,SC:U),C,0,0 S:G$randomSeed$0$0({2}DF,SV:S),C,0,0 S:G$timeInit$0$0({2}DF,SV:S),C,0,0 S:G$getMs$0$0({2}DF,SL:U),C,0,0 S:G$ISR_T4$0$0({2}DF,SV:S),C,0,0 S:G$delayMicroseconds$0$0({2}DF,SV:S),C,0,0 S:G$delayMs$0$0({2}DF,SV:S),C,0,0 S:G$usbInit$0$0({2}DF,SV:S),C,0,0 S:G$usbPoll$0$0({2}DF,SV:S),C,0,0 S:G$usbControlRead$0$0({2}DF,SV:S),C,0,0 S:G$usbControlWrite$0$0({2}DF,SV:S),C,0,0 S:G$usbControlAcknowledge$0$0({2}DF,SV:S),C,0,0 S:G$usbControlStall$0$0({2}DF,SV:S),C,0,0 S:G$usbInitEndpointIn$0$0({2}DF,SV:S),C,0,0 S:G$usbInitEndpointOut$0$0({2}DF,SV:S),C,0,0 S:G$usbWriteFifo$0$0({2}DF,SV:S),C,0,0 S:G$usbReadFifo$0$0({2}DF,SV:S),C,0,0 S:G$usbSuspended$0$0({2}DF,SB0$1:U),C,0,0 S:G$usbSleep$0$0({2}DF,SV:S),C,0,0 S:G$usbShowStatusWithGreenLed$0$0({2}DF,SV:S),C,0,0 S:G$usbCallbackSetupHandler$0$0({2}DF,SV:S),C,0,0 S:G$usbCallbackClassDescriptorHandler$0$0({2}DF,SV:S),C,0,0 S:G$usbCallbackInitEndpoints$0$0({2}DF,SV:S),C,0,0 S:G$usbCallbackControlWriteHandler$0$0({2}DF,SV:S),C,0,0 S:G$usbComRxControlSignals$0$0({2}DF,SC:U),C,0,0 S:G$usbComTxControlSignals$0$0({2}DF,SV:S),C,0,0 S:G$usbComTxControlSignalEvents$0$0({2}DF,SV:S),C,0,0 S:G$usbComService$0$0({2}DF,SV:S),C,0,0 S:G$usbComRxAvailable$0$0({2}DF,SC:U),C,0,0 S:G$usbComRxReceiveByte$0$0({2}DF,SC:U),C,0,0 S:G$usbComRxReceive$0$0({2}DF,SV:S),C,0,0 S:G$usbComTxAvailable$0$0({2}DF,SC:U),C,0,0 S:G$usbComTxSendByte$0$0({2}DF,SV:S),C,0,0 S:G$usbComTxSend$0$0({2}DF,SV:S),C,0,0 S:G$radioRegistersInit$0$0({2}DF,SV:S),C,0,0 S:G$radioLqi$0$0({2}DF,SC:U),C,0,0 S:G$radioRssi$0$0({2}DF,SC:S),C,0,0 S:G$radioCrcPassed$0$0({2}DF,SB0$1:U),C,0,0 S:G$radioMacInit$0$0({2}DF,SV:S),C,0,0 S:G$radioMacStrobe$0$0({2}DF,SV:S),C,0,0 S:G$radioMacSleep$0$0({2}DF,SV:S),C,0,0 S:G$radioMacResume$0$0({2}DF,SV:S),C,0,0 S:G$radioMacTx$0$0({2}DF,SV:S),C,0,0 S:G$radioMacRx$0$0({2}DF,SV:S),C,0,0 S:G$radioMacEventHandler$0$0({2}DF,SV:S),C,0,0 S:G$ISR_RF$0$0({2}DF,SV:S),C,0,0 S:G$radioQueueInit$0$0({2}DF,SV:S),C,0,0 S:G$radioQueueTxAvailable$0$0({2}DF,SC:U),C,0,0 S:G$radioQueueTxQueued$0$0({2}DF,SC:U),C,0,0 S:G$radioQueueTxCurrentPacket$0$0({2}DF,DX,SC:U),C,0,0 S:G$radioQueueTxSendPacket$0$0({2}DF,SV:S),C,0,0 S:G$radioQueueRxCurrentPacket$0$0({2}DF,DX,SC:U),C,0,0 S:G$radioQueueRxDoneWithPacket$0$0({2}DF,SV:S),C,0,0 S:G$setDigitalOutput$0$0({2}DF,SV:S),C,0,0 S:G$setDigitalInput$0$0({2}DF,SV:S),C,0,0 S:G$isPinHigh$0$0({2}DF,SB0$1:U),C,0,0 S:G$setPort0PullType$0$0({2}DF,SV:S),C,0,0 S:G$setPort1PullType$0$0({2}DF,SV:S),C,0,0 S:G$setPort2PullType$0$0({2}DF,SV:S),C,0,0 S:G$uart1Init$0$0({2}DF,SV:S),C,0,0 S:G$uart1SetBaudRate$0$0({2}DF,SV:S),C,0,0 S:G$uart1SetParity$0$0({2}DF,SV:S),C,0,0 S:G$uart1SetStopBits$0$0({2}DF,SV:S),C,0,0 S:G$uart1TxAvailable$0$0({2}DF,SC:U),C,0,0 S:G$uart1TxSendByte$0$0({2}DF,SV:S),C,0,0 S:G$uart1TxSend$0$0({2}DF,SV:S),C,0,0 S:G$uart1RxAvailable$0$0({2}DF,SC:U),C,0,0 S:G$uart1RxReceiveByte$0$0({2}DF,SC:U),C,0,0 S:G$ISR_UTX1$0$0({2}DF,SV:S),C,0,0 S:G$ISR_URX1$0$0({2}DF,SV:S),C,0,0 S:G$_print_format$0$0({2}DF,SI:S),C,0,0 S:G$printf_small$0$0({2}DF,SV:S),C,0,0 S:G$printf$0$0({2}DF,SI:S),C,0,0 S:G$vprintf$0$0({2}DF,SI:S),C,0,0 S:G$sprintf$0$0({2}DF,SI:S),C,0,0 S:G$vsprintf$0$0({2}DF,SI:S),C,0,0 S:G$puts$0$0({2}DF,SI:S),C,0,0 S:G$gets$0$0({2}DF,DG,SC:S),C,0,0 S:G$getchar$0$0({2}DF,SC:S),C,0,0 S:G$printf_fast$0$0({2}DF,SV:S),C,0,0 S:G$printf_fast_f$0$0({2}DF,SV:S),C,0,0 S:G$printf_tiny$0$0({2}DF,SV:S),C,0,0 S:G$memcpy$0$0({2}DF,DG,SV:S),C,0,0 S:G$memmove$0$0({2}DF,DG,SV:S),C,0,0 S:G$strcpy$0$0({2}DF,DG,SC:S),C,0,0 S:G$strncpy$0$0({2}DF,DG,SC:S),C,0,0 S:G$strcat$0$0({2}DF,DG,SC:S),C,0,0 S:G$strncat$0$0({2}DF,DG,SC:S),C,0,0 S:G$memcmp$0$0({2}DF,SI:S),C,0,0 S:G$strcmp$0$0({2}DF,SI:S),C,0,0 S:G$strncmp$0$0({2}DF,SI:S),C,0,0 S:G$strxfrm$0$0({2}DF,SI:U),C,0,0 S:G$memchr$0$0({2}DF,DG,SV:S),C,0,0 S:G$strchr$0$0({2}DF,DG,SC:S),C,0,0 S:G$strcspn$0$0({2}DF,SI:U),C,0,0 S:G$strpbrk$0$0({2}DF,DG,SC:S),C,0,0 S:G$strrchr$0$0({2}DF,DG,SC:S),C,0,0 S:G$strspn$0$0({2}DF,SI:U),C,0,0 S:G$strstr$0$0({2}DF,DG,SC:S),C,0,0 S:G$strtok$0$0({2}DF,DG,SC:S),C,0,0 S:G$memset$0$0({2}DF,DG,SV:S),C,0,0 S:G$strlen$0$0({2}DF,SI:U),C,0,0 S:G$iscntrl$0$0({2}DF,SC:S),C,0,0 S:G$isdigit$0$0({2}DF,SC:S),C,0,0 S:G$isgraph$0$0({2}DF,SC:S),C,0,0 S:G$islower$0$0({2}DF,SC:S),C,0,0 S:G$isupper$0$0({2}DF,SC:S),C,0,0 S:G$isprint$0$0({2}DF,SC:S),C,0,0 S:G$ispunct$0$0({2}DF,SC:S),C,0,0 S:G$isspace$0$0({2}DF,SC:S),C,0,0 S:G$isxdigit$0$0({2}DF,SC:S),C,0,0 S:G$adcRead$0$0({2}DF,SI:U),C,0,0 S:G$adcReadDifferential$0$0({2}DF,SI:S),C,0,0 S:G$adcReadVddMillivolts$0$0({2}DF,SI:U),C,0,0 S:G$adcSetMillivoltCalibration$0$0({2}DF,SV:S),C,0,0 S:G$adcConvertToMillivolts$0$0({2}DF,SI:S),C,0,0 S:G$AES128_CBC_encrypt_buffer$0$0({2}DF,SV:S),C,0,0 S:G$sleepInit$0$0({2}DF,SV:S),C,0,0 S:G$ISR_ST$0$0({2}DF,SV:S),C,0,0 S:G$switchToRCOSC$0$0({2}DF,SV:S),C,0,0 S:G$uartEnable$0$0({2}DF,SV:S),C,0,0 S:G$uartDisable$0$0({2}DF,SV:S),C,0,0 S:G$blink_yellow_led$0$0({2}DF,SV:S),C,0,0 S:G$blink_red_led$0$0({2}DF,SV:S),C,0,0 S:G$getPacketPassedChecksum$0$0({2}DF,SC:U),C,0,0 S:G$bit_reverse_byte$0$0({2}DF,SC:U),C,0,0 S:G$min8$0$0({2}DF,SC:U),C,0,0 S:G$bit_reverse_bytes$0$0({2}DF,SV:S),C,0,0 S:G$dex_num_decoder$0$0({2}DF,SL:U),C,0,0 S:G$dexcom_src_to_ascii$0$0({2}DF,SV:S),C,0,0 S:G$clearRxErrors$0$0({2}DF,SV:S),C,0,0 S:G$doServices$0$0({2}DF,SV:S),C,0,0 S:G$initUart1$0$0({2}DF,SV:S),C,0,0 S:G$getESPString$0$0({2}DF,DX,SC:S),C,0,0 S:G$sendAT$0$0({2}DF,SV:S),C,0,0 S:G$enableESP$0$0({2}DF,SV:S),C,0,0 S:G$getWifiStatus$0$0({2}DF,SI:S),C,0,0 S:G$wifiFlash$0$0({2}DF,SV:S),C,0,0 S:G$wifiConnect$0$0({2}DF,SB0$1:U),C,0,0 S:G$getTimeBytes$0$0({2}DF,SV:S),C,0,0 S:G$ESPsleep$0$0({2}DF,SV:S),C,0,0 S:G$print_packet$0$0({2}DF,SV:S),C,0,0 S:G$makeAllOutputs$0$0({2}DF,SV:S),C,0,0 S:G$makeAllOutputsLow$0$0({2}DF,SV:S),C,0,0 S:G$reset_offsets$0$0({2}DF,SV:S),C,0,0 S:G$killWithWatchdog$0$0({2}DF,SV:S),C,0,0 S:G$goToSleep$0$0({2}DF,SV:S),C,0,0 S:G$printfUSB$0$0({2}DF,SV:S),C,0,0 S:G$swap_channel$0$0({2}DF,SV:S),C,0,0 S:G$strobe_radio$0$0({2}DF,SV:S),C,0,0 S:G$WaitForPacket$0$0({2}DF,SI:S),C,0,0 S:G$delayFor$0$0({2}DF,SL:U),C,0,0 S:G$get_packet$0$0({2}DF,SB0$1:U),C,0,0 S:G$setADCInputs$0$0({2}DF,SV:S),C,0,0 S:G$main$0$0({2}DF,SV:S),C,0,0 S:G$serialNumber$0$0({4}DA4,SC:U),D,0,0 S:G$serialNumberStringDescriptor$0$0({0}DA0,SI:U),D,0,0 S:G$usbDeviceDescriptor$0$0({18}STUSB_DESCRIPTOR_DEVICE:S),D,0,0 S:G$usbStringDescriptorCount$0$0({1}SC:U),D,0,0 S:G$usbStringDescriptors$0$0({0}DA0,DC,SI:U),D,0,0 S:G$param_radio_channel$0$0({4}SL:S),D,0,0 S:Fydrip$_str_1$0$0({21}DA21,SC:S),D,0,0 S:Fydrip$_str_2$0$0({70}DA70,SC:S),D,0,0 S:Fydrip$_str_3$0$0({55}DA55,SC:S),D,0,0 S:Fydrip$_str_4$0$0({18}DA18,SC:S),D,0,0 S:Fydrip$_str_5$0$0({29}DA29,SC:S),D,0,0 S:Fydrip$_str_6$0$0({48}DA48,SC:S),D,0,0 S:Fydrip$_str_7$0$0({46}DA46,SC:S),D,0,0 S:Fydrip$_str_8$0$0({48}DA48,SC:S),D,0,0 S:Fydrip$_str_9$0$0({46}DA46,SC:S),D,0,0 S:Fydrip$_str_10$0$0({48}DA48,SC:S),D,0,0 S:Fydrip$_str_11$0$0({15}DA15,SC:S),D,0,0 S:Fydrip$_str_12$0$0({32}DA32,SC:S),D,0,0 S:Fydrip$_str_13$0$0({35}DA35,SC:S),D,0,0 S:Fydrip$_str_14$0$0({61}DA61,SC:S),D,0,0 S:Fydrip$_str_15$0$0({68}DA68,SC:S),D,0,0 S:Fydrip$_str_16$0$0({92}DA92,SC:S),D,0,0 S:Fydrip$_str_17$0$0({89}DA89,SC:S),D,0,0 S:Fydrip$_str_18$0$0({67}DA67,SC:S),D,0,0 S:Fydrip$_str_19$0$0({116}DA116,SC:S),D,0,0 S:Fydrip$_str_20$0$0({110}DA110,SC:S),D,0,0 S:Fydrip$_str_21$0$0({110}DA110,SC:S),D,0,0 S:Fydrip$_str_22$0$0({110}DA110,SC:S),D,0,0 S:Fydrip$_str_23$0$0({110}DA110,SC:S),D,0,0 S:Fydrip$_str_24$0$0({110}DA110,SC:S),D,0,0 S:Fydrip$_str_25$0$0({121}DA121,SC:S),D,0,0 S:Fydrip$_str_26$0$0({34}DA34,SC:S),D,0,0 S:Fydrip$_str_27$0$0({25}DA25,SC:S),D,0,0 S:Fydrip$_str_28$0$0({53}DA53,SC:S),D,0,0 S:Fydrip$_str_29$0$0({27}DA27,SC:S),D,0,0 S:Fydrip$_str_30$0$0({27}DA27,SC:S),D,0,0 S:Fydrip$_str_31$0$0({27}DA27,SC:S),D,0,0 S:Fydrip$_str_32$0$0({26}DA26,SC:S),D,0,0 S:Fydrip$_str_33$0$0({21}DA21,SC:S),D,0,0 S:Fydrip$_str_34$0$0({68}DA68,SC:S),D,0,0 S:Fydrip$_str_35$0$0({80}DA80,SC:S),D,0,0 S:Fydrip$_str_36$0$0({73}DA73,SC:S),D,0,0 S:Fydrip$_str_37$0$0({64}DA64,SC:S),D,0,0 S:Fydrip$_str_38$0$0({69}DA69,SC:S),D,0,0 S:Fydrip$_str_39$0$0({38}DA38,SC:S),D,0,0 S:Fydrip$_str_40$0$0({51}DA51,SC:S),D,0,0 S:Fydrip$_str_41$0$0({12}DA12,SC:S),D,0,0 S:Fydrip$_str_42$0$0({3}DA3,SC:S),D,0,0 S:Fydrip$_str_43$0$0({5}DA5,SC:S),D,0,0 S:Fydrip$_str_44$0$0({27}DA27,SC:S),D,0,0 S:Fydrip$_str_45$0$0({33}DA33,SC:S),D,0,0 S:Fydrip$_str_46$0$0({3}DA3,SC:S),D,0,0 S:Fydrip$_str_47$0$0({4}DA4,SC:S),D,0,0 S:Fydrip$_str_48$0$0({4}DA4,SC:S),D,0,0 S:Fydrip$_str_49$0$0({4}DA4,SC:S),D,0,0 S:Fydrip$_str_50$0$0({4}DA4,SC:S),D,0,0 S:Fydrip$_str_51$0$0({4}DA4,SC:S),D,0,0 S:Fydrip$_str_52$0$0({4}DA4,SC:S),D,0,0 S:Fydrip$_str_53$0$0({4}DA4,SC:S),D,0,0 S:Fydrip$_str_54$0$0({4}DA4,SC:S),D,0,0 S:Fydrip$_str_55$0$0({4}DA4,SC:S),D,0,0 S:Fydrip$_str_56$0$0({4}DA4,SC:S),D,0,0 S:Fydrip$_str_57$0$0({4}DA4,SC:S),D,0,0 S:Fydrip$_str_58$0$0({4}DA4,SC:S),D,0,0 S:Fydrip$_str_59$0$0({13}DA13,SC:S),D,0,0 S:Fydrip$_str_60$0$0({25}DA25,SC:S),D,0,0 S:Fydrip$_str_62$0$0({24}DA24,SC:S),D,0,0 S:Fydrip$_str_63$0$0({49}DA49,SC:S),D,0,0 S:Fydrip$_str_64$0$0({22}DA22,SC:S),D,0,0 S:Fydrip$_str_65$0$0({5}DA5,SC:S),D,0,0 S:Fydrip$_str_66$0$0({2}DA2,SC:S),D,0,0 S:Fydrip$_str_67$0$0({17}DA17,SC:S),D,0,0 S:Fydrip$_str_68$0$0({9}DA9,SC:S),D,0,0 S:Fydrip$_str_70$0$0({6}DA6,SC:S),D,0,0 S:Fydrip$_str_71$0$0({22}DA22,SC:S),D,0,0 S:Fydrip$_str_72$0$0({6}DA6,SC:S),D,0,0 S:Fydrip$_str_73$0$0({8}DA8,SC:S),D,0,0 S:Fydrip$__xinit_transmitter_id$0$0({6}DA6,SC:S),C,0,0 S:Fydrip$__xinit_dexie_host_address$0$0({22}DA22,SC:S),C,0,0 S:Fydrip$__xinit_dexie_host_port$0$0({6}DA6,SC:S),C,0,0 S:Fydrip$__xinit_wixFone_ID$0$0({8}DA8,SC:S),C,0,0 S:Fydrip$__xinit_key$0$0({16}DA16,SC:U),C,0,0 S:Fydrip$__xinit_start_channel$0$0({1}SC:S),C,0,0 S:Fydrip$__xinit_defaultfOffset$0$0({4}DA4,SC:S),C,0,0 S:Fydrip$__xinit_PM2_BUF$0$0({7}DA7,SC:U),C,0,0 S:Fydrip$__xinit_dmaDesc$0$0({8}DA8,SC:U),C,0,0 S:Fydrip$__xinit_AT_TIMEOUT$0$0({1}SC:U),C,0,0 S:Fydrip$__xinit_defaultWaitTime$0$0({4}SL:U),C,0,0 S:Fydrip$__xinit_SrcNameTable$0$0({32}DA32,SC:S),C,0,0
mirror/ncurses
Ada
7,090
adb
------------------------------------------------------------------------------ -- -- -- GNAT ncurses Binding Samples -- -- -- -- ncurses -- -- -- -- B O D Y -- -- -- ------------------------------------------------------------------------------ -- Copyright 2020 Thomas E. Dickey -- -- Copyright 2000-2008,2011 Free Software Foundation, Inc. -- -- -- -- Permission is hereby granted, free of charge, to any person obtaining a -- -- copy of this software and associated documentation files (the -- -- "Software"), to deal in the Software without restriction, including -- -- without limitation the rights to use, copy, modify, merge, publish, -- -- distribute, distribute with modifications, sublicense, and/or sell -- -- copies of the Software, and to permit persons to whom the Software is -- -- furnished to do so, subject to the following conditions: -- -- -- -- The above copyright notice and this permission notice shall be included -- -- in all copies or substantial portions of the Software. -- -- -- -- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS -- -- OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -- -- MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. -- -- IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, -- -- DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR -- -- OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR -- -- THE USE OR OTHER DEALINGS IN THE SOFTWARE. -- -- -- -- Except as contained in this notice, the name(s) of the above copyright -- -- holders shall not be used in advertising or otherwise to promote the -- -- sale, use or other dealings in this Software without prior written -- -- authorization. -- ------------------------------------------------------------------------------ -- Author: Eugene V. Melaragno <[email protected]> 2000 -- Version Control -- $Revision: 1.9 $ -- $Date: 2020/02/02 23:34:34 $ -- Binding Version 01.00 ------------------------------------------------------------------------------ -- A simplified version of the GNU getopt function -- copyright Free Software Foundtion with Ada.Strings.Fixed; with Ada.Strings.Bounded; with Ada.Text_IO; use Ada.Text_IO; package body ncurses2.getopt is nextchar : Natural := 0; -- Ncurses doesn't use the non option elements so we are spared -- the job of computing those. -- also the user is not allowed to modify argv or argc -- Doing so is Erroneous execution. -- long options are not handled. procedure Qgetopt (retval : out Integer; argc : Integer; argv : stringfunc; -- argv will be the Argument function. optstring : String; optind : in out Integer; -- ignored for ncurses, must be initialized to 1 by -- the caller Optarg : out stringa -- a garbage collector would be useful here. ) is package BS is new Ada.Strings.Bounded.Generic_Bounded_Length (200); use BS; optargx : Bounded_String; begin if argc < optind then retval := -1; return; end if; optargx := To_Bounded_String (""); if nextchar = 0 then if argv (optind) = "--" then -- the rest are non-options, we ignore them retval := -1; return; end if; if argv (optind)(1) /= '-' or argv (optind)'Length = 1 then optind := optind + 1; Optarg := new String'(argv (optind)); retval := 1; return; end if; nextchar := 2; -- skip the one hyphen. end if; -- Look at and handle the next short option-character. declare c : Character := argv (optind) (nextchar); temp : constant Natural := Ada.Strings.Fixed.Index (optstring, String'(1 => c)); begin if temp = 0 or c = ':' then Put_Line (Standard_Error, argv (optind) & ": invalid option -- " & c); c := '?'; return; end if; if optstring (temp + 1) = ':' then if optstring (temp + 2) = ':' then -- This is an option that accepts an argument optionally. if nextchar /= argv (optind)'Length then optargx := To_Bounded_String (argv (optind) (nextchar .. argv (optind)'Length)); else Optarg := null; end if; else -- This is an option that requires an argument. if nextchar /= argv (optind)'Length then optargx := To_Bounded_String (argv (optind) (nextchar .. argv (optind)'Length)); optind := optind + 1; elsif optind = argc then Put_Line (Standard_Error, argv (optind) & ": option requires an argument -- " & c); if optstring (optstring'First) = ':' then c := ':'; else c := '?'; end if; else -- increment it again when taking next ARGV-elt as argument. optind := optind + 1; optargx := To_Bounded_String (argv (optind)); optind := optind + 1; end if; end if; nextchar := 0; else -- no argument for the option if nextchar = argv (optind)'Length then optind := optind + 1; nextchar := 0; else nextchar := nextchar + 1; end if; end if; retval := Character'Pos (c); Optarg := new String'(To_String (optargx)); return; end; end Qgetopt; end ncurses2.getopt;
optikos/oasis
Ada
4,723
ads
-- Copyright (c) 2019 Maxim Reznik <[email protected]> -- -- SPDX-License-Identifier: MIT -- License-Filename: LICENSE ------------------------------------------------------------- with Program.Lexical_Elements; with Program.Elements.Expressions; with Program.Elements.Requeue_Statements; with Program.Element_Visitors; package Program.Nodes.Requeue_Statements is pragma Preelaborate; type Requeue_Statement is new Program.Nodes.Node and Program.Elements.Requeue_Statements.Requeue_Statement and Program.Elements.Requeue_Statements.Requeue_Statement_Text with private; function Create (Requeue_Token : not null Program.Lexical_Elements .Lexical_Element_Access; Entry_Name : not null Program.Elements.Expressions.Expression_Access; With_Token : Program.Lexical_Elements.Lexical_Element_Access; Abort_Token : Program.Lexical_Elements.Lexical_Element_Access; Semicolon_Token : not null Program.Lexical_Elements .Lexical_Element_Access) return Requeue_Statement; type Implicit_Requeue_Statement is new Program.Nodes.Node and Program.Elements.Requeue_Statements.Requeue_Statement with private; function Create (Entry_Name : not null Program.Elements.Expressions .Expression_Access; Is_Part_Of_Implicit : Boolean := False; Is_Part_Of_Inherited : Boolean := False; Is_Part_Of_Instance : Boolean := False; Has_With_Abort : Boolean := False) return Implicit_Requeue_Statement with Pre => Is_Part_Of_Implicit or Is_Part_Of_Inherited or Is_Part_Of_Instance; private type Base_Requeue_Statement is abstract new Program.Nodes.Node and Program.Elements.Requeue_Statements.Requeue_Statement with record Entry_Name : not null Program.Elements.Expressions.Expression_Access; end record; procedure Initialize (Self : aliased in out Base_Requeue_Statement'Class); overriding procedure Visit (Self : not null access Base_Requeue_Statement; Visitor : in out Program.Element_Visitors.Element_Visitor'Class); overriding function Entry_Name (Self : Base_Requeue_Statement) return not null Program.Elements.Expressions.Expression_Access; overriding function Is_Requeue_Statement_Element (Self : Base_Requeue_Statement) return Boolean; overriding function Is_Statement_Element (Self : Base_Requeue_Statement) return Boolean; type Requeue_Statement is new Base_Requeue_Statement and Program.Elements.Requeue_Statements.Requeue_Statement_Text with record Requeue_Token : not null Program.Lexical_Elements .Lexical_Element_Access; With_Token : Program.Lexical_Elements.Lexical_Element_Access; Abort_Token : Program.Lexical_Elements.Lexical_Element_Access; Semicolon_Token : not null Program.Lexical_Elements .Lexical_Element_Access; end record; overriding function To_Requeue_Statement_Text (Self : aliased in out Requeue_Statement) return Program.Elements.Requeue_Statements.Requeue_Statement_Text_Access; overriding function Requeue_Token (Self : Requeue_Statement) return not null Program.Lexical_Elements.Lexical_Element_Access; overriding function With_Token (Self : Requeue_Statement) return Program.Lexical_Elements.Lexical_Element_Access; overriding function Abort_Token (Self : Requeue_Statement) return Program.Lexical_Elements.Lexical_Element_Access; overriding function Semicolon_Token (Self : Requeue_Statement) return not null Program.Lexical_Elements.Lexical_Element_Access; overriding function Has_With_Abort (Self : Requeue_Statement) return Boolean; type Implicit_Requeue_Statement is new Base_Requeue_Statement with record Is_Part_Of_Implicit : Boolean; Is_Part_Of_Inherited : Boolean; Is_Part_Of_Instance : Boolean; Has_With_Abort : Boolean; end record; overriding function To_Requeue_Statement_Text (Self : aliased in out Implicit_Requeue_Statement) return Program.Elements.Requeue_Statements.Requeue_Statement_Text_Access; overriding function Is_Part_Of_Implicit (Self : Implicit_Requeue_Statement) return Boolean; overriding function Is_Part_Of_Inherited (Self : Implicit_Requeue_Statement) return Boolean; overriding function Is_Part_Of_Instance (Self : Implicit_Requeue_Statement) return Boolean; overriding function Has_With_Abort (Self : Implicit_Requeue_Statement) return Boolean; end Program.Nodes.Requeue_Statements;
stcarrez/ada-awa
Ada
9,138
adb
----------------------------------------------------------------------- -- awa-services -- Services -- Copyright (C) 2011, 2012, 2013, 2014, 2016, 2017, 2022 Stephane Carrez -- Written by Stephane Carrez ([email protected]) -- -- Licensed under the Apache License, Version 2.0 (the "License"); -- you may not use this file except in compliance with the License. -- You may obtain a copy of the License at -- -- http://www.apache.org/licenses/LICENSE-2.0 -- -- Unless required by applicable law or agreed to in writing, software -- distributed under the License is distributed on an "AS IS" BASIS, -- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -- See the License for the specific language governing permissions and -- limitations under the License. ----------------------------------------------------------------------- with Ada.Task_Attributes; with Util.Log.Loggers; with Security.Contexts; package body AWA.Services.Contexts is use type ADO.Sessions.Connection_Status; use type AWA.Users.Principals.Principal_Access; package Task_Context is new Ada.Task_Attributes (Service_Context_Access, null); Log : constant Util.Log.Loggers.Logger := Util.Log.Loggers.Create ("AWA.Services.Contexts"); -- ------------------------------ -- Get the application associated with the current service operation. -- ------------------------------ function Get_Application (Ctx : in Service_Context) return AWA.Applications.Application_Access is begin return Ctx.Application; end Get_Application; -- ------------------------------ -- Get the current database connection for reading. -- ------------------------------ function Get_Session (Ctx : in Service_Context_Access) return ADO.Sessions.Session is begin if Ctx = null then Log.Error ("No AWA service context: may be a 'filter-mapping'" & " is missing to activate the 'service' filter in the request path"); end if; -- If a master database session was created, use it. if Ctx.Master.Get_Status = ADO.Sessions.OPEN then return ADO.Sessions.Session (Ctx.Master); elsif Ctx.Slave.Get_Status /= ADO.Sessions.OPEN then Ctx.Slave := Ctx.Application.Get_Session; end if; return Ctx.Slave; end Get_Session; -- ------------------------------ -- Get the current database connection for reading and writing. -- ------------------------------ function Get_Master_Session (Ctx : in Service_Context_Access) return ADO.Sessions.Master_Session is begin if Ctx.Master.Get_Status /= ADO.Sessions.OPEN then Ctx.Master := Ctx.Application.Get_Master_Session; end if; return Ctx.Master; end Get_Master_Session; -- ------------------------------ -- Get the current user invoking the service operation. -- Returns a null user if there is none. -- ------------------------------ function Get_User (Ctx : in Service_Context) return AWA.Users.Models.User_Ref is begin if Ctx.Principal = null then return AWA.Users.Models.Null_User; else return Ctx.Principal.Get_User; end if; end Get_User; -- ------------------------------ -- Get the current user identifier invoking the service operation. -- Returns NO_IDENTIFIER if there is none. -- ------------------------------ function Get_User_Identifier (Ctx : in Service_Context) return ADO.Identifier is begin if Ctx.Principal = null then return ADO.NO_IDENTIFIER; else return Ctx.Principal.Get_User_Identifier; end if; end Get_User_Identifier; -- ------------------------------ -- Get the current user session from the user invoking the service operation. -- Returns a null session if there is none. -- ------------------------------ function Get_User_Session (Ctx : in Service_Context) return AWA.Users.Models.Session_Ref is begin if Ctx.Principal = null then return AWA.Users.Models.Null_Session; else return Ctx.Principal.Get_Session; end if; end Get_User_Session; -- ------------------------------ -- Starts a transaction. -- ------------------------------ procedure Start (Ctx : in out Service_Context) is begin if Ctx.Transaction = 0 and then not Ctx.Active_Transaction then Ctx.Master.Begin_Transaction; Ctx.Active_Transaction := True; end if; Ctx.Transaction := Ctx.Transaction + 1; end Start; -- ------------------------------ -- Commits the current transaction. The database transaction is really committed by the -- last <b>Commit</b> called. -- ------------------------------ procedure Commit (Ctx : in out Service_Context) is begin Ctx.Transaction := Ctx.Transaction - 1; if Ctx.Transaction = 0 and then Ctx.Active_Transaction then Ctx.Master.Commit; Ctx.Active_Transaction := False; end if; end Commit; -- ------------------------------ -- Rollback the current transaction. The database transaction is rollback at the first -- call to <b>Rollback</b>. -- ------------------------------ procedure Rollback (Ctx : in out Service_Context) is begin null; end Rollback; -- ------------------------------ -- Get the attribute registered under the given name in the HTTP session. -- ------------------------------ function Get_Session_Attribute (Ctx : in Service_Context; Name : in String) return Util.Beans.Objects.Object is pragma Unreferenced (Ctx, Name); begin return Util.Beans.Objects.Null_Object; end Get_Session_Attribute; -- ------------------------------ -- Set the attribute registered under the given name in the HTTP session. -- ------------------------------ procedure Set_Session_Attribute (Ctx : in out Service_Context; Name : in String; Value : in Util.Beans.Objects.Object) is begin null; end Set_Session_Attribute; -- ------------------------------ -- Set the current application and user context. -- ------------------------------ procedure Set_Context (Ctx : in out Service_Context; Application : in AWA.Applications.Application_Access; Principal : in AWA.Users.Principals.Principal_Access) is begin Ctx.Application := Application; Ctx.Principal := Principal; end Set_Context; -- ------------------------------ -- Initializes the service context. -- ------------------------------ overriding procedure Initialize (Ctx : in out Service_Context) is use type AWA.Applications.Application_Access; begin Ctx.Previous := Task_Context.Value; Task_Context.Set_Value (Ctx'Unchecked_Access); if Ctx.Previous /= null and then Ctx.Application = null then Ctx.Application := Ctx.Previous.Application; end if; end Initialize; -- ------------------------------ -- Finalize the service context, rollback non-committed transaction, releases any object. -- ------------------------------ overriding procedure Finalize (Ctx : in out Service_Context) is begin -- When the service context is released, we must not have any active transaction. -- This means we are leaving the service in an abnormal way such as when an -- exception is raised. If this is the case, rollback the transaction. if Ctx.Active_Transaction then begin Ctx.Master.Rollback; exception when E : others => Log.Error ("Transaction rollback failed: {0}", E); end; end if; Task_Context.Set_Value (Ctx.Previous); end Finalize; -- ------------------------------ -- Get the current service context. -- Returns null if the current thread is not associated with any service context. -- ------------------------------ function Current return Service_Context_Access is begin return Task_Context.Value; end Current; -- ------------------------------ -- Run the process procedure on behalf of the specific user and session. -- This operation changes temporarily the identity of the current user principal and -- executes the <tt>Process</tt> procedure. -- ------------------------------ procedure Run_As (User : in AWA.Users.Models.User_Ref; Session : in AWA.Users.Models.Session_Ref) is Ctx : Service_Context; Sec : Security.Contexts.Security_Context; Principal : aliased AWA.Users.Principals.Principal := AWA.Users.Principals.Create (User, Session); begin Ctx.Principal := Principal'Unchecked_Access; Sec.Set_Context (Ctx.Application.Get_Security_Manager, Principal'Unchecked_Access); Process; end Run_As; end AWA.Services.Contexts;
persan/AdaYaml
Ada
730
ads
-- part of AdaYaml, (c) 2017 Felix Krause -- released under the terms of the MIT license, see the file "copying.txt" with AUnit; use AUnit; with AUnit.Test_Cases; use AUnit.Test_Cases; package Yaml.Dom.Dumping.Test is type TC is new Test_Cases.Test_Case with record Pool : Text.Pool.Reference; end record; overriding procedure Register_Tests (T : in out TC); overriding procedure Set_Up (T : in out TC); function Name (T : TC) return Message_String; procedure Plain_Scalar_Document (T : in out Test_Cases.Test_Case'Class); procedure Quoted_Scalar_Document (T : in out Test_Cases.Test_Case'Class); procedure Explicit_Document (T : in out Test_Cases.Test_Case'Class); end Yaml.Dom.Dumping.Test;
reznikmm/matreshka
Ada
4,682
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. ------------------------------------------------------------------------------ -- An interval constraint is a constraint that refers to an interval. ------------------------------------------------------------------------------ with AMF.UML.Constraints; limited with AMF.UML.Intervals; package AMF.UML.Interval_Constraints is pragma Preelaborate; type UML_Interval_Constraint is limited interface and AMF.UML.Constraints.UML_Constraint; type UML_Interval_Constraint_Access is access all UML_Interval_Constraint'Class; for UML_Interval_Constraint_Access'Storage_Size use 0; not overriding function Get_Specification (Self : not null access constant UML_Interval_Constraint) return AMF.UML.Intervals.UML_Interval_Access is abstract; -- Getter of IntervalConstraint::specification. -- -- A condition that must be true when evaluated in order for the -- constraint to be satisfied. not overriding procedure Set_Specification (Self : not null access UML_Interval_Constraint; To : AMF.UML.Intervals.UML_Interval_Access) is abstract; -- Setter of IntervalConstraint::specification. -- -- A condition that must be true when evaluated in order for the -- constraint to be satisfied. end AMF.UML.Interval_Constraints;
AdaCore/training_material
Ada
2,833
adb
------------------------------------------------------------------------------ -- -- -- GNAT EXAMPLE -- -- -- -- Copyright (C) 2014, Free Software Foundation, Inc. -- -- -- -- GNAT is free software; you can redistribute it and/or modify it under -- -- terms of the GNU General Public License as published by the Free Soft- -- -- ware Foundation; either version 3, or (at your option) any later ver- -- -- sion. GNAT is distributed in the hope that it will be useful, but WITH- -- -- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY -- -- or FITNESS FOR A PARTICULAR PURPOSE. -- -- -- -- As a special exception under Section 7 of GPL version 3, you are granted -- -- additional permissions described in the GCC Runtime Library Exception, -- -- version 3.1, as published by the Free Software Foundation. -- -- -- -- You should have received a copy of the GNU General Public License and -- -- a copy of the GCC Runtime Library Exception along with this program; -- -- see the files COPYING3 and COPYING.RUNTIME respectively. If not, see -- -- <http://www.gnu.org/licenses/>. -- -- -- -- GNAT was originally developed by the GNAT team at New York University. -- -- Extensive contributions were provided by Ada Core Technologies Inc. -- -- -- ------------------------------------------------------------------------------ -- The file declares the main procedure for the demonstration. with Driver; pragma Unreferenced (Driver); -- The Driver package contains the task that actually controls the app so -- although it is not referenced directly in the main procedure, we need it -- in the closure of the context clauses so that it will be included in the -- executable. with Last_Chance_Handler; pragma Unreferenced (Last_Chance_Handler); -- The "last chance handler" is the user-defined routine that is called when -- an exception is propagated. We need it in the executable, therefore it -- must be somewhere in the closure of the context clauses. with System; procedure Demo is pragma Priority (System.Priority'First); begin loop null; end loop; end Demo;
sungyeon/drake
Ada
4,780
ads
pragma License (Unrestricted); -- implementation unit private package Ada.Containers.Copy_On_Write is pragma Preelaborate; type Container; type Container_Access is access all Container; for Container_Access'Storage_Size use 0; Data_Size : constant := Standard'Address_Size; type Data is limited record Follower : Container_Access; -- first container is owner pragma Atomic (Follower); end record; for Data'Size use Data_Size; type Data_Access is access Data; function Shared (Data : Data_Access) return Boolean; type Container is record Data : Data_Access; pragma Atomic (Data); Next_Follower : Container_Access; pragma Atomic (Next_Follower); end record; procedure Adjust ( Target : not null access Container); procedure Assign ( Target : not null access Container; Source : not null access constant Container; Free : not null access procedure (Object : in out Data_Access)); procedure Clear ( Target : not null access Container; Free : not null access procedure (Object : in out Data_Access)); procedure Copy ( Target : not null access Container; Source : not null access constant Container; Allocate : not null access procedure ( Target : out not null Data_Access; New_Length : Count_Type; Capacity : Count_Type); Copy : not null access procedure ( Target : out not null Data_Access; Source : not null Data_Access; Length : Count_Type; -- copying length New_Length : Count_Type; Capacity : Count_Type)); procedure Copy ( Target : not null access Container; Source : not null access constant Container; Length : Count_Type; New_Capacity : Count_Type; Allocate : not null access procedure ( Target : out not null Data_Access; New_Length : Count_Type; Capacity : Count_Type); Copy : not null access procedure ( Target : out not null Data_Access; Source : not null Data_Access; Length : Count_Type; -- copying length New_Length : Count_Type; Capacity : Count_Type)); procedure Move ( Target : not null access Container; Source : not null access Container; Free : not null access procedure (Object : in out Data_Access)); procedure Unique ( Target : not null access Container; To_Update : Boolean; Allocate : not null access procedure ( Target : out not null Data_Access; New_Length : Count_Type; Capacity : Count_Type); Move : not null access procedure ( Target : out not null Data_Access; Source : not null Data_Access; Length : Count_Type; -- copying length New_Length : Count_Type; Capacity : Count_Type); Copy : not null access procedure ( Target : out not null Data_Access; Source : not null Data_Access; Length : Count_Type; -- copying length New_Length : Count_Type; Capacity : Count_Type); Free : not null access procedure (Object : in out Data_Access)); procedure Unique ( Target : not null access Container; Target_Length : Count_Type; Target_Capacity : Count_Type; New_Length : Count_Type; New_Capacity : Count_Type; To_Update : Boolean; Allocate : not null access procedure ( Target : out not null Data_Access; New_Length : Count_Type; Capacity : Count_Type); Move : not null access procedure ( Target : out not null Data_Access; Source : not null Data_Access; Length : Count_Type; -- copying length New_Length : Count_Type; Capacity : Count_Type); Copy : not null access procedure ( Target : out not null Data_Access; Source : not null Data_Access; Length : Count_Type; -- copying length New_Length : Count_Type; Capacity : Count_Type); Free : not null access procedure (Object : in out Data_Access); Max_Length : not null access function (Data : not null Data_Access) return not null access Count_Type); -- Note: Copy and Reserve_Capacity also make a container unique. procedure In_Place_Set_Length ( Target : not null access Container; Target_Length : Count_Type; Target_Capacity : Count_Type; New_Length : Count_Type; Failure : out Boolean; -- reallocation is needed Max_Length : not null access function (Data : not null Data_Access) return not null access Count_Type); function Zero (Data : not null Data_Access) return not null access Count_Type; end Ada.Containers.Copy_On_Write;
kontena/ruby-packer
Ada
3,738
ads
------------------------------------------------------------------------------ -- -- -- GNAT ncurses Binding Samples -- -- -- -- Sample.Form_Demo.Handler -- -- -- -- S P E C -- -- -- ------------------------------------------------------------------------------ -- Copyright (c) 1998-2003,2009 Free Software Foundation, Inc. -- -- -- -- Permission is hereby granted, free of charge, to any person obtaining a -- -- copy of this software and associated documentation files (the -- -- "Software"), to deal in the Software without restriction, including -- -- without limitation the rights to use, copy, modify, merge, publish, -- -- distribute, distribute with modifications, sublicense, and/or sell -- -- copies of the Software, and to permit persons to whom the Software is -- -- furnished to do so, subject to the following conditions: -- -- -- -- The above copyright notice and this permission notice shall be included -- -- in all copies or substantial portions of the Software. -- -- -- -- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS -- -- OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -- -- MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. -- -- IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, -- -- DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR -- -- OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR -- -- THE USE OR OTHER DEALINGS IN THE SOFTWARE. -- -- -- -- Except as contained in this notice, the name(s) of the above copyright -- -- holders shall not be used in advertising or otherwise to promote the -- -- sale, use or other dealings in this Software without prior written -- -- authorization. -- ------------------------------------------------------------------------------ -- Author: Juergen Pfeifer, 1996 -- Version Control -- $Revision: 1.10 $ -- Binding Version 01.00 ------------------------------------------------------------------------------ with Terminal_Interface.Curses; use Terminal_Interface.Curses; with Terminal_Interface.Curses.Panels; use Terminal_Interface.Curses.Panels; with Terminal_Interface.Curses.Forms; use Terminal_Interface.Curses.Forms; generic with function My_Driver (Frm : Form; K : Key_Code; Pan : Panel) return Boolean; package Sample.Form_Demo.Handler is procedure Drive_Me (F : Form; Lin : Line_Position; Col : Column_Position; Title : String := ""); -- Position the menu at the given point and drive it. procedure Drive_Me (F : Form; Title : String := ""); -- Center menu and drive it. end Sample.Form_Demo.Handler;
jrcarter/Lined
Ada
3,001
ads
-- The buffer of lines being edited -- Lines are numbered from 1 (the first line) to Last -- Line numbers are relative: when lines are added or deleted, the numbering of the other lines may change package Lined.Buffer is procedure Clear with Post => Last = 0; -- Makes the buffer empty -- The buffer is initially empty procedure Mark (Number : in Positive; Status : in Boolean) with Pre => Number in 1 .. Last, Post => Marked (Number) = Status; -- Marks (Status True) or unmarks (Status False) line Number function Marked (Number : Positive) return Boolean; -- Returns the mark status of line Number procedure Clear_Marks with Post => (for all I in 1 .. Last => not Marked (I) ); -- Sets the marks for all lines in the buffer to False procedure Insert (Line : in String; Before : in Positive) with Pre => Before in 1 .. Last + 1, Post => Buffer.Line (Before) = Line; -- Adds Line to the buffer before line number Before procedure Delete (Number : in Positive) with Pre => Number in 1 .. Last, Post => Last = Last'Old - 1; -- Deletes line number Number from the buffer procedure Replace (Number : in Positive; Line : in String) with Pre => Number in 1 .. Last, Post => Buffer.Line (Number) = Line; -- Makes line Number in the buffer have the value Line function Default_File return String; -- Initially returns "" procedure Set_File (Name : in String) with Pre => Name /= "", Post => Default_File = Name; procedure Load (File_Name : in String) with Post => Default_File = File_Name; -- Makes Default_File return File_Name -- Then, if a file named File_Name exists, clears the buffer, opens File_Name, reads it into the buffer, and closes it -- Otherwise, has no effect on the buffer procedure Write (File_Name : in String := ""); -- If File_Name /= "", creates File_Name, writes the lines in the buffer to it, and closes it -- If File_Name = "" and Default_File /= "", creates Default_File, writes the lines in the buffer to it, and closes it -- If File_Name = "" and Default_File = "", has no effect function Last return Natural with Post => Last'Result < Integer'Last; -- Returns the number of the last line in the buffer = number of lines in the buffer -- Last = 0 means the buffer is empty function Line (Number : Positive) return String with Pre => Number in 1 .. Last; -- Returns line number Number in the buffer function Next (Number : Natural) return Positive with Post => (if Number < Last then Next'Result = Number + 1 else Next'Result = 1); -- Increments line number Number with wrap around function Prev (Number : Natural) return Positive with Pre => Number in 0 .. Last, Post => (if Number > 1 then Prev'Result = Number - 1 else Prev'Result = Last); -- Decrements line number Number with wrap around end Lined.Buffer;
sungyeon/drake
Ada
657
ads
pragma License (Unrestricted); -- runtime unit specialized for Linux with C.pthread; with C.signal; package System.Stack is pragma Preelaborate; procedure Get ( Thread : C.pthread.pthread_t := C.pthread.pthread_self; Top, Bottom : out Address); procedure Fake_Return_From_Signal_Handler is null; -- Linux does not have UC_RESET_ALT_STACK, -- and 64bit Linux does not have SYS_sigreturn. pragma Inline (Fake_Return_From_Signal_Handler); -- [gcc-7] can not skip calling null procedure function Fault_Address (Info : C.signal.siginfo_t) return Address; pragma Inline (Fault_Address); end System.Stack;
ohenley/awt
Ada
5,992
adb
-- SPDX-License-Identifier: Apache-2.0 -- -- Copyright (c) 2021 onox <[email protected]> -- -- Licensed under the Apache License, Version 2.0 (the "License"); -- you may not use this file except in compliance with the License. -- You may obtain a copy of the License at -- -- http://www.apache.org/licenses/LICENSE-2.0 -- -- Unless required by applicable law or agreed to in writing, software -- distributed under the License is distributed on an "AS IS" BASIS, -- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -- See the License for the specific language governing permissions and -- limitations under the License. with Ada.Unchecked_Conversion; package body AWT.OS is use all type AWT.Inputs.Pointer_Button; use all type AWT.Inputs.Keyboard_Button; function Code_To_Button (Code : Unsigned_32) return AWT.Inputs.Pointer_Button is (case Code is when 272 => Left, when 273 => Right, when 274 => Middle, when others => Unknown); function Code_To_Button (Code : Unsigned_32) return AWT.Inputs.Keyboard_Button is (case Code is when 1 => Key_Escape, when 2 => Key_1, when 3 => Key_2, when 4 => Key_3, when 5 => Key_4, when 6 => Key_5, when 7 => Key_6, when 8 => Key_7, when 9 => Key_8, when 10 => Key_9, when 11 => Key_0, when 12 => Key_Minus, when 13 => Key_Equal, when 14 => Key_Backspace, when 15 => Key_Tab, when 16 => Key_Q, when 17 => Key_W, when 18 => Key_E, when 19 => Key_R, when 20 => Key_T, when 21 => Key_Y, when 22 => Key_U, when 23 => Key_I, when 24 => Key_O, when 25 => Key_P, when 26 => Key_Left_Bracket, when 27 => Key_Right_Bracket, when 28 => Key_Enter, when 29 => Key_Left_Ctrl, when 30 => Key_A, when 31 => Key_S, when 32 => Key_D, when 33 => Key_F, when 34 => Key_G, when 35 => Key_H, when 36 => Key_J, when 37 => Key_K, when 38 => Key_L, when 39 => Key_Semicolon, when 40 => Key_Apostrophe, when 41 => Key_Backtick, when 42 => Key_Left_Shift, when 43 => Key_Backslash, when 44 => Key_Z, when 45 => Key_X, when 46 => Key_C, when 47 => Key_V, when 48 => Key_B, when 49 => Key_N, when 50 => Key_M, when 51 => Key_Comma, when 52 => Key_Period, when 53 => Key_Slash, when 54 => Key_Right_Shift, when 55 => Key_Numpad_Asterisk, when 56 => Key_Left_Alt, when 57 => Key_Space, when 58 => Key_Caps_Lock, when 59 => Key_F1, when 60 => Key_F2, when 61 => Key_F3, when 62 => Key_F4, when 63 => Key_F5, when 64 => Key_F6, when 65 => Key_F7, when 66 => Key_F8, when 67 => Key_F9, when 68 => Key_F10, when 69 => Key_Num_Lock, when 70 => Key_Scroll_Lock, when 71 => Key_Numpad_7, when 72 => Key_Numpad_8, when 73 => Key_Numpad_9, when 74 => Key_Numpad_Minus, when 75 => Key_Numpad_4, when 76 => Key_Numpad_5, when 77 => Key_Numpad_6, when 78 => Key_Numpad_Plus, when 79 => Key_Numpad_1, when 80 => Key_Numpad_2, when 81 => Key_Numpad_3, when 82 => Key_Numpad_0, when 83 => Key_Numpad_Period, -- 84 .. 86 when 87 => Key_F11, when 88 => Key_F12, -- 89 .. 95 when 96 => Key_Numpad_Enter, when 97 => Key_Right_Ctrl, when 98 => Key_Numpad_Slash, when 99 => Key_Print_Screen, when 100 => Key_Right_Alt, -- 101 when 102 => Key_Home, when 103 => Key_Arrow_Up, when 104 => Key_Page_Up, when 105 => Key_Arrow_Left, when 106 => Key_Arrow_Right, when 107 => Key_End, when 108 => Key_Arrow_Down, when 109 => Key_Page_Down, when 110 => Key_Insert, when 111 => Key_Delete, -- 112 .. 118 when 119 => Key_Pause, -- 120 .. 124 when 125 => Key_Left_Logo, when 126 => Key_Right_Logo, when others => Key_Unknown); procedure Create_Pipe (Result : out Pipe) is type File_Descriptor_Array is array (1 .. 2) of Standard.Wayland.File_Descriptor with Convention => C; function C_Pipe (File_Descriptors : in out File_Descriptor_Array) return Integer with Import, Convention => C, External_Name => "pipe"; File_Descriptors : File_Descriptor_Array; begin if C_Pipe (File_Descriptors) = 0 then Result := (Read => File_Descriptors (1), Write => File_Descriptors (2)); else raise Constraint_Error; end if; end Create_Pipe; function Read (Object : in out File) return Ada.Streams.Stream_Element_Array is Content : Ada.Streams.Stream_Element_Array (1 .. 1024); Result : constant C_Binding.Read_Result := C_Binding.Read (Object.Handle, Content); use all type C_Binding.Read_Result_Kind_Id; begin case Result.Kind_Id is when Read_Success => return Content (1 .. Result.Element_Count); when End_Of_File_Reached => return Content (1 .. 0); when Read_Failure => raise Constraint_Error; end case; end Read; procedure Write (Object : in out File; Value : String) is subtype Byte_Array is Ada.Streams.Stream_Element_Array (1 .. Value'Length); function Convert is new Ada.Unchecked_Conversion (Source => String, Target => Byte_Array); begin C_Binding.Write (Object.Handle, Convert (Value)); end Write; procedure Close (Object : in out File) is begin C_Binding.Close (Object.Handle); end Close; end AWT.OS;
guillaume-lin/tsc
Ada
10,528
adb
------------------------------------------------------------------------------ -- -- -- GNAT ncurses Binding Samples -- -- -- -- ncurses -- -- -- -- B O D Y -- -- -- ------------------------------------------------------------------------------ -- Copyright (c) 2000 Free Software Foundation, Inc. -- -- -- -- Permission is hereby granted, free of charge, to any person obtaining a -- -- copy of this software and associated documentation files (the -- -- "Software"), to deal in the Software without restriction, including -- -- without limitation the rights to use, copy, modify, merge, publish, -- -- distribute, distribute with modifications, sublicense, and/or sell -- -- copies of the Software, and to permit persons to whom the Software is -- -- furnished to do so, subject to the following conditions: -- -- -- -- The above copyright notice and this permission notice shall be included -- -- in all copies or substantial portions of the Software. -- -- -- -- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS -- -- OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -- -- MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. -- -- IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, -- -- DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR -- -- OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR -- -- THE USE OR OTHER DEALINGS IN THE SOFTWARE. -- -- -- -- Except as contained in this notice, the name(s) of the above copyright -- -- holders shall not be used in advertising or otherwise to promote the -- -- sale, use or other dealings in this Software without prior written -- -- authorization. -- ------------------------------------------------------------------------------ -- Author: Eugene V. Melaragno <[email protected]> 2000 -- Version Control -- $Revision: 1.1 $ -- Binding Version 01.00 ------------------------------------------------------------------------------ with ncurses2.util; use ncurses2.util; with ncurses2.genericPuts; with Terminal_Interface.Curses; use Terminal_Interface.Curses; with Ada.Strings.Unbounded; with Ada.Strings.Fixed; procedure ncurses2.acs_display is use Int_IO; procedure show_upper_chars (first : Integer); function show_1_acs (N : Integer; name : String; code : Attributed_Character) return Integer; procedure show_acs_chars; procedure show_upper_chars (first : Integer) is C1 : Boolean := (first = 128); last : Integer := first + 31; package p is new ncurses2.genericPuts (200); use p; use p.BS; use Ada.Strings.Unbounded; tmpa : Unbounded_String; tmpb : BS.Bounded_String; begin Erase; Switch_Character_Attribute (Attr => (Bold_Character => True, others => False)); Move_Cursor (Line => 0, Column => 20); tmpa := To_Unbounded_String ("Display of "); if C1 then tmpa := tmpa & "C1"; else tmpa := tmpa & "GR"; end if; tmpa := tmpa & " Character Codes "; myPut (tmpb, first); Append (tmpa, To_String (tmpb)); Append (tmpa, " to "); myPut (tmpb, last); Append (tmpa, To_String (tmpb)); Add (Str => To_String (tmpa)); Switch_Character_Attribute (On => False, Attr => (Bold_Character => True, others => False)); Refresh; for code in first .. last loop declare row : Line_Position := Line_Position (4 + ((code - first) mod 16)); col : Column_Position := Column_Position (((code - first) / 16) * Integer (Columns) / 2); tmp3 : String (1 .. 3); tmpx : String (1 .. Integer (Columns / 4)); reply : Key_Code; begin Put (tmp3, code); myPut (tmpb, code, 16); tmpa := To_Unbounded_String (tmp3 & " (" & To_String (tmpb) & ')'); Ada.Strings.Fixed.Move (To_String (tmpa), tmpx, Justify => Ada.Strings.Right); Add (Line => row, Column => col, Str => tmpx & ' ' & ':' & ' '); if C1 then Set_NoDelay_Mode (Mode => True); end if; Add_With_Immediate_Echo (Ch => Code_To_Char (Key_Code (code))); -- TODO check this if C1 then reply := Getchar; while reply /= Key_None loop Add (Ch => Code_To_Char (reply)); Nap_Milli_Seconds (10); reply := Getchar; end loop; Set_NoDelay_Mode (Mode => False); end if; end; end loop; end show_upper_chars; function show_1_acs (N : Integer; name : String; code : Attributed_Character) return Integer is height : constant Integer := 16; row : Line_Position := Line_Position (4 + (N mod height)); col : Column_Position := Column_Position ((N / height) * Integer (Columns) / 2); tmpx : String (1 .. Integer (Columns) / 3); begin Ada.Strings.Fixed.Move (name, tmpx, Justify => Ada.Strings.Right, Drop => Ada.Strings.Left); Add (Line => row, Column => col, Str => tmpx & ' ' & ':' & ' '); -- we need more room than C because our identifiers are longer -- 22 chars actually Add (Ch => code); return N + 1; end show_1_acs; procedure show_acs_chars is n : Integer; begin Erase; Switch_Character_Attribute (Attr => (Bold_Character => True, others => False)); Add (Line => 0, Column => 20, Str => "Display of the ACS Character Set"); Switch_Character_Attribute (On => False, Attr => (Bold_Character => True, others => False)); Refresh; -- the following is useful to generate the below -- grep '^[ ]*ACS_' ../src/terminal_interface-curses.ads | -- awk '{print "n := show_1_acs(n, \""$1"\", ACS_Map("$1"));"}' n := show_1_acs (0, "ACS_Upper_Left_Corner", ACS_Map (ACS_Upper_Left_Corner)); n := show_1_acs (n, "ACS_Lower_Left_Corner", ACS_Map (ACS_Lower_Left_Corner)); n := show_1_acs (n, "ACS_Upper_Right_Corner", ACS_Map (ACS_Upper_Right_Corner)); n := show_1_acs (n, "ACS_Lower_Right_Corner", ACS_Map (ACS_Lower_Right_Corner)); n := show_1_acs (n, "ACS_Left_Tee", ACS_Map (ACS_Left_Tee)); n := show_1_acs (n, "ACS_Right_Tee", ACS_Map (ACS_Right_Tee)); n := show_1_acs (n, "ACS_Bottom_Tee", ACS_Map (ACS_Bottom_Tee)); n := show_1_acs (n, "ACS_Top_Tee", ACS_Map (ACS_Top_Tee)); n := show_1_acs (n, "ACS_Horizontal_Line", ACS_Map (ACS_Horizontal_Line)); n := show_1_acs (n, "ACS_Vertical_Line", ACS_Map (ACS_Vertical_Line)); n := show_1_acs (n, "ACS_Plus_Symbol", ACS_Map (ACS_Plus_Symbol)); n := show_1_acs (n, "ACS_Scan_Line_1", ACS_Map (ACS_Scan_Line_1)); n := show_1_acs (n, "ACS_Scan_Line_9", ACS_Map (ACS_Scan_Line_9)); n := show_1_acs (n, "ACS_Diamond", ACS_Map (ACS_Diamond)); n := show_1_acs (n, "ACS_Checker_Board", ACS_Map (ACS_Checker_Board)); n := show_1_acs (n, "ACS_Degree", ACS_Map (ACS_Degree)); n := show_1_acs (n, "ACS_Plus_Minus", ACS_Map (ACS_Plus_Minus)); n := show_1_acs (n, "ACS_Bullet", ACS_Map (ACS_Bullet)); n := show_1_acs (n, "ACS_Left_Arrow", ACS_Map (ACS_Left_Arrow)); n := show_1_acs (n, "ACS_Right_Arrow", ACS_Map (ACS_Right_Arrow)); n := show_1_acs (n, "ACS_Down_Arrow", ACS_Map (ACS_Down_Arrow)); n := show_1_acs (n, "ACS_Up_Arrow", ACS_Map (ACS_Up_Arrow)); n := show_1_acs (n, "ACS_Board_Of_Squares", ACS_Map (ACS_Board_Of_Squares)); n := show_1_acs (n, "ACS_Lantern", ACS_Map (ACS_Lantern)); n := show_1_acs (n, "ACS_Solid_Block", ACS_Map (ACS_Solid_Block)); n := show_1_acs (n, "ACS_Scan_Line_3", ACS_Map (ACS_Scan_Line_3)); n := show_1_acs (n, "ACS_Scan_Line_7", ACS_Map (ACS_Scan_Line_7)); n := show_1_acs (n, "ACS_Less_Or_Equal", ACS_Map (ACS_Less_Or_Equal)); n := show_1_acs (n, "ACS_Greater_Or_Equal", ACS_Map (ACS_Greater_Or_Equal)); n := show_1_acs (n, "ACS_PI", ACS_Map (ACS_PI)); n := show_1_acs (n, "ACS_Not_Equal", ACS_Map (ACS_Not_Equal)); n := show_1_acs (n, "ACS_Sterling", ACS_Map (ACS_Sterling)); end show_acs_chars; c1 : Key_Code; c : Character := 'a'; begin loop case c is when 'a' => show_acs_chars; when '0' | '1' | '2' | '3' => show_upper_chars (ctoi (c) * 32 + 128); when others => null; end case; Add (Line => Lines - 3, Column => 0, Str => "Note: ANSI terminals may not display C1 characters."); Add (Line => Lines - 2, Column => 0, Str => "Select: a=ACS, 0=C1, 1,2,3=GR characters, q=quit"); Refresh; c1 := Getchar; c := Code_To_Char (c1); exit when c = 'q' or c = 'x'; end loop; Pause; Erase; End_Windows; end ncurses2.acs_display;
sungyeon/drake
Ada
3,151
adb
with Ada.Colors; with Ada.Numerics; procedure Color is use type Ada.Colors.RGB; P : constant := 16#0.0001#; -- 1/65536 begin -- distances in HSV pragma Assert ( abs ( Ada.Colors.HSV_Distance ( (Hue => 0.0, Saturation => 0.0, Value => 1.0), (Hue => Ada.Numerics.Pi / 2.0, Saturation => 0.0, Value => 1.0)) - 0.0) < P); pragma Assert ( abs ( Ada.Colors.HSV_Distance ( (Hue => 0.0, Saturation => 1.0, Value => 1.0), (Hue => Ada.Numerics.Pi / 2.0, Saturation => 1.0, Value => 1.0)) - 0.5) < P); -- Sqrt (2.0) ** 2 / 2.0 = 0.5 pragma Assert ( abs ( Ada.Colors.HSV_Distance ( (Hue => 0.0, Saturation => 1.0, Value => 1.0), (Hue => Ada.Numerics.Pi, Saturation => 1.0, Value => 1.0)) - 1.0) < P); -- distances in HSL pragma Assert ( abs ( Ada.Colors.HSL_Distance ( (Hue => 0.0, Saturation => 1.0, Lightness => 1.0), (Hue => Ada.Numerics.Pi / 2.0, Saturation => 1.0, Lightness => 1.0)) - 0.0) < P); pragma Assert ( abs ( Ada.Colors.HSL_Distance ( (Hue => 0.0, Saturation => 1.0, Lightness => 0.5), (Hue => Ada.Numerics.Pi / 2.0, Saturation => 1.0, Lightness => 0.5)) - 0.5) < P); -- Sqrt (2.0) ** 2 / 2.0 = 0.5 pragma Assert ( abs ( Ada.Colors.HSL_Distance ( (Hue => 0.0, Saturation => 1.0, Lightness => 0.0), (Hue => Ada.Numerics.Pi / 2.0, Saturation => 1.0, Lightness => 0.0)) - 0.0) < P); -- conversions for R in 0 .. 4 loop for G in 0 .. 4 loop for B in 0 .. 4 loop declare Original_RGB : constant Ada.Colors.RGB := ( Red => Ada.Colors.Brightness'Base (R) / 4.0, Green => Ada.Colors.Brightness'Base (G) / 4.0, Blue => Ada.Colors.Brightness'Base (B) / 4.0); HSV : constant Ada.Colors.HSV := Ada.Colors.To_HSV (Original_RGB); HSV_RGB : constant Ada.Colors.RGB := Ada.Colors.To_RGB (HSV); HSV_HSL : constant Ada.Colors.HSL := Ada.Colors.To_HSL (HSV); HSL : constant Ada.Colors.HSL := Ada.Colors.To_HSL (Original_RGB); HSL_RGB : constant Ada.Colors.RGB := Ada.Colors.To_RGB (HSL); HSL_HSV : constant Ada.Colors.HSV := Ada.Colors.To_HSV (HSL); begin -- RGB / HSV pragma Assert ( abs (HSV_RGB.Red - Original_RGB.Red) < P and then abs (HSV_RGB.Green - Original_RGB.Green) < P and then abs (HSV_RGB.Blue - Original_RGB.Blue) < P); pragma Assert (Ada.Colors.RGB_Distance (HSV_RGB, Original_RGB) < P); -- RGB / HSL pragma Assert ( abs (HSL_RGB.Red - Original_RGB.Red) < P and then abs (HSL_RGB.Green - Original_RGB.Green) < P and then abs (HSL_RGB.Blue - Original_RGB.Blue) < P); pragma Assert (Ada.Colors.RGB_Distance (HSL_RGB, Original_RGB) < P); -- HSV / HSL pragma Assert ( abs (HSL_HSV.Hue - HSV.Hue) < P and then abs (HSL_HSV.Saturation - HSV.Saturation) < P and then abs (HSL_HSV.Value - HSV.Value) < P); pragma Assert ( abs (HSV_HSL.Hue - HSL.Hue) < P and then abs (HSV_HSL.Saturation - HSL.Saturation) < P and then abs (HSV_HSL.Lightness - HSL.Lightness) < P); null; end; end loop; end loop; end loop; pragma Debug (Ada.Debug.Put ("OK")); end Color;
reznikmm/matreshka
Ada
3,764
ads
------------------------------------------------------------------------------ -- -- -- Matreshka Project -- -- -- -- Open Document Toolkit -- -- -- -- Runtime Library Component -- -- -- ------------------------------------------------------------------------------ -- -- -- Copyright © 2014, Vadim Godunko <[email protected]> -- -- All rights reserved. -- -- -- -- Redistribution and use in source and binary forms, with or without -- -- modification, are permitted provided that the following conditions -- -- are met: -- -- -- -- * Redistributions of source code must retain the above copyright -- -- notice, this list of conditions and the following disclaimer. -- -- -- -- * Redistributions in binary form must reproduce the above copyright -- -- notice, this list of conditions and the following disclaimer in the -- -- documentation and/or other materials provided with the distribution. -- -- -- -- * Neither the name of the Vadim Godunko, IE nor the names of its -- -- contributors may be used to endorse or promote products derived from -- -- this software without specific prior written permission. -- -- -- -- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -- -- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -- -- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -- -- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -- -- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -- -- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED -- -- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -- -- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -- -- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -- -- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -- -- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- -- -- ------------------------------------------------------------------------------ -- $Revision$ $Date$ ------------------------------------------------------------------------------ with XML.DOM.Attributes; package ODF.DOM.Style_Text_Overline_Color_Attributes is pragma Preelaborate; type ODF_Style_Text_Overline_Color_Attribute is limited interface and XML.DOM.Attributes.DOM_Attribute; type ODF_Style_Text_Overline_Color_Attribute_Access is access all ODF_Style_Text_Overline_Color_Attribute'Class with Storage_Size => 0; end ODF.DOM.Style_Text_Overline_Color_Attributes;
reznikmm/matreshka
Ada
3,674
ads
------------------------------------------------------------------------------ -- -- -- Matreshka Project -- -- -- -- Open Document Toolkit -- -- -- -- Runtime Library Component -- -- -- ------------------------------------------------------------------------------ -- -- -- Copyright © 2014, Vadim Godunko <[email protected]> -- -- All rights reserved. -- -- -- -- Redistribution and use in source and binary forms, with or without -- -- modification, are permitted provided that the following conditions -- -- are met: -- -- -- -- * Redistributions of source code must retain the above copyright -- -- notice, this list of conditions and the following disclaimer. -- -- -- -- * Redistributions in binary form must reproduce the above copyright -- -- notice, this list of conditions and the following disclaimer in the -- -- documentation and/or other materials provided with the distribution. -- -- -- -- * Neither the name of the Vadim Godunko, IE nor the names of its -- -- contributors may be used to endorse or promote products derived from -- -- this software without specific prior written permission. -- -- -- -- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -- -- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -- -- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -- -- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -- -- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -- -- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED -- -- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -- -- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -- -- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -- -- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -- -- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- -- -- ------------------------------------------------------------------------------ -- $Revision$ $Date$ ------------------------------------------------------------------------------ with XML.DOM.Elements; package ODF.DOM.Text_List_Style_Elements is pragma Preelaborate; type ODF_Text_List_Style is limited interface and XML.DOM.Elements.DOM_Element; type ODF_Text_List_Style_Access is access all ODF_Text_List_Style'Class with Storage_Size => 0; end ODF.DOM.Text_List_Style_Elements;
AdaCore/Ada_Drivers_Library
Ada
14,710
ads
-- This spec has been automatically generated from FE310.svd pragma Restrictions (No_Elaboration_Code); pragma Ada_2012; pragma Style_Checks (Off); with HAL; with System; package FE310_SVD.GPIO is pragma Preelaborate; --------------- -- Registers -- --------------- -- VALUE_PIN array type VALUE_PIN_Field_Array is array (0 .. 31) of Boolean with Component_Size => 1, Size => 32; -- Pin value. type VALUE_Register (As_Array : Boolean := False) is record case As_Array is when False => -- PIN as a value Val : HAL.UInt32; when True => -- PIN as an array Arr : VALUE_PIN_Field_Array; end case; end record with Unchecked_Union, Size => 32, Volatile_Full_Access, Bit_Order => System.Low_Order_First; for VALUE_Register use record Val at 0 range 0 .. 31; Arr at 0 range 0 .. 31; end record; -- INPUT_EN_PIN array type INPUT_EN_PIN_Field_Array is array (0 .. 31) of Boolean with Component_Size => 1, Size => 32; -- Pin input enable. type INPUT_EN_Register (As_Array : Boolean := False) is record case As_Array is when False => -- PIN as a value Val : HAL.UInt32; when True => -- PIN as an array Arr : INPUT_EN_PIN_Field_Array; end case; end record with Unchecked_Union, Size => 32, Volatile_Full_Access, Bit_Order => System.Low_Order_First; for INPUT_EN_Register use record Val at 0 range 0 .. 31; Arr at 0 range 0 .. 31; end record; -- OUTPUT_EN_PIN array type OUTPUT_EN_PIN_Field_Array is array (0 .. 31) of Boolean with Component_Size => 1, Size => 32; -- Pin output enable. type OUTPUT_EN_Register (As_Array : Boolean := False) is record case As_Array is when False => -- PIN as a value Val : HAL.UInt32; when True => -- PIN as an array Arr : OUTPUT_EN_PIN_Field_Array; end case; end record with Unchecked_Union, Size => 32, Volatile_Full_Access, Bit_Order => System.Low_Order_First; for OUTPUT_EN_Register use record Val at 0 range 0 .. 31; Arr at 0 range 0 .. 31; end record; -- PORT_PIN array type PORT_PIN_Field_Array is array (0 .. 31) of Boolean with Component_Size => 1, Size => 32; -- Output port value. type PORT_Register (As_Array : Boolean := False) is record case As_Array is when False => -- PIN as a value Val : HAL.UInt32; when True => -- PIN as an array Arr : PORT_PIN_Field_Array; end case; end record with Unchecked_Union, Size => 32, Volatile_Full_Access, Bit_Order => System.Low_Order_First; for PORT_Register use record Val at 0 range 0 .. 31; Arr at 0 range 0 .. 31; end record; -- PULLUP_PIN array type PULLUP_PIN_Field_Array is array (0 .. 31) of Boolean with Component_Size => 1, Size => 32; -- Internal Pull-Up enable. type PULLUP_Register (As_Array : Boolean := False) is record case As_Array is when False => -- PIN as a value Val : HAL.UInt32; when True => -- PIN as an array Arr : PULLUP_PIN_Field_Array; end case; end record with Unchecked_Union, Size => 32, Volatile_Full_Access, Bit_Order => System.Low_Order_First; for PULLUP_Register use record Val at 0 range 0 .. 31; Arr at 0 range 0 .. 31; end record; -- DRIVE_PIN array type DRIVE_PIN_Field_Array is array (0 .. 31) of Boolean with Component_Size => 1, Size => 32; -- Drive Strength. type DRIVE_Register (As_Array : Boolean := False) is record case As_Array is when False => -- PIN as a value Val : HAL.UInt32; when True => -- PIN as an array Arr : DRIVE_PIN_Field_Array; end case; end record with Unchecked_Union, Size => 32, Volatile_Full_Access, Bit_Order => System.Low_Order_First; for DRIVE_Register use record Val at 0 range 0 .. 31; Arr at 0 range 0 .. 31; end record; -- RISE_INT_EN_PIN array type RISE_INT_EN_PIN_Field_Array is array (0 .. 31) of Boolean with Component_Size => 1, Size => 32; -- Rise interrupt enable. type RISE_INT_EN_Register (As_Array : Boolean := False) is record case As_Array is when False => -- PIN as a value Val : HAL.UInt32; when True => -- PIN as an array Arr : RISE_INT_EN_PIN_Field_Array; end case; end record with Unchecked_Union, Size => 32, Volatile_Full_Access, Bit_Order => System.Low_Order_First; for RISE_INT_EN_Register use record Val at 0 range 0 .. 31; Arr at 0 range 0 .. 31; end record; -- RISE_INT_PEMD_PIN array type RISE_INT_PEMD_PIN_Field_Array is array (0 .. 31) of Boolean with Component_Size => 1, Size => 32; -- Rise interrupt pending. type RISE_INT_PEMD_Register (As_Array : Boolean := False) is record case As_Array is when False => -- PIN as a value Val : HAL.UInt32; when True => -- PIN as an array Arr : RISE_INT_PEMD_PIN_Field_Array; end case; end record with Unchecked_Union, Size => 32, Volatile_Full_Access, Bit_Order => System.Low_Order_First; for RISE_INT_PEMD_Register use record Val at 0 range 0 .. 31; Arr at 0 range 0 .. 31; end record; -- FALL_INT_EN_PIN array type FALL_INT_EN_PIN_Field_Array is array (0 .. 31) of Boolean with Component_Size => 1, Size => 32; -- Fall interrupt enable. type FALL_INT_EN_Register (As_Array : Boolean := False) is record case As_Array is when False => -- PIN as a value Val : HAL.UInt32; when True => -- PIN as an array Arr : FALL_INT_EN_PIN_Field_Array; end case; end record with Unchecked_Union, Size => 32, Volatile_Full_Access, Bit_Order => System.Low_Order_First; for FALL_INT_EN_Register use record Val at 0 range 0 .. 31; Arr at 0 range 0 .. 31; end record; -- FALL_INT_PEND_PIN array type FALL_INT_PEND_PIN_Field_Array is array (0 .. 31) of Boolean with Component_Size => 1, Size => 32; -- Fall interrupt pending. type FALL_INT_PEND_Register (As_Array : Boolean := False) is record case As_Array is when False => -- PIN as a value Val : HAL.UInt32; when True => -- PIN as an array Arr : FALL_INT_PEND_PIN_Field_Array; end case; end record with Unchecked_Union, Size => 32, Volatile_Full_Access, Bit_Order => System.Low_Order_First; for FALL_INT_PEND_Register use record Val at 0 range 0 .. 31; Arr at 0 range 0 .. 31; end record; -- HIGH_INT_EN_PIN array type HIGH_INT_EN_PIN_Field_Array is array (0 .. 31) of Boolean with Component_Size => 1, Size => 32; -- High interrupt enable. type HIGH_INT_EN_Register (As_Array : Boolean := False) is record case As_Array is when False => -- PIN as a value Val : HAL.UInt32; when True => -- PIN as an array Arr : HIGH_INT_EN_PIN_Field_Array; end case; end record with Unchecked_Union, Size => 32, Volatile_Full_Access, Bit_Order => System.Low_Order_First; for HIGH_INT_EN_Register use record Val at 0 range 0 .. 31; Arr at 0 range 0 .. 31; end record; -- HIGH_INT_PEND_PIN array type HIGH_INT_PEND_PIN_Field_Array is array (0 .. 31) of Boolean with Component_Size => 1, Size => 32; -- High interrupt pending. type HIGH_INT_PEND_Register (As_Array : Boolean := False) is record case As_Array is when False => -- PIN as a value Val : HAL.UInt32; when True => -- PIN as an array Arr : HIGH_INT_PEND_PIN_Field_Array; end case; end record with Unchecked_Union, Size => 32, Volatile_Full_Access, Bit_Order => System.Low_Order_First; for HIGH_INT_PEND_Register use record Val at 0 range 0 .. 31; Arr at 0 range 0 .. 31; end record; -- LOW_INT_EN_PIN array type LOW_INT_EN_PIN_Field_Array is array (0 .. 31) of Boolean with Component_Size => 1, Size => 32; -- Low interrupt enable. type LOW_INT_EN_Register (As_Array : Boolean := False) is record case As_Array is when False => -- PIN as a value Val : HAL.UInt32; when True => -- PIN as an array Arr : LOW_INT_EN_PIN_Field_Array; end case; end record with Unchecked_Union, Size => 32, Volatile_Full_Access, Bit_Order => System.Low_Order_First; for LOW_INT_EN_Register use record Val at 0 range 0 .. 31; Arr at 0 range 0 .. 31; end record; -- LOW_INT_PEND_PIN array type LOW_INT_PEND_PIN_Field_Array is array (0 .. 31) of Boolean with Component_Size => 1, Size => 32; -- Low interrupt pending. type LOW_INT_PEND_Register (As_Array : Boolean := False) is record case As_Array is when False => -- PIN as a value Val : HAL.UInt32; when True => -- PIN as an array Arr : LOW_INT_PEND_PIN_Field_Array; end case; end record with Unchecked_Union, Size => 32, Volatile_Full_Access, Bit_Order => System.Low_Order_First; for LOW_INT_PEND_Register use record Val at 0 range 0 .. 31; Arr at 0 range 0 .. 31; end record; -- IO_FUNC_EN_PIN array type IO_FUNC_EN_PIN_Field_Array is array (0 .. 31) of Boolean with Component_Size => 1, Size => 32; -- HW I/O function enable. type IO_FUNC_EN_Register (As_Array : Boolean := False) is record case As_Array is when False => -- PIN as a value Val : HAL.UInt32; when True => -- PIN as an array Arr : IO_FUNC_EN_PIN_Field_Array; end case; end record with Unchecked_Union, Size => 32, Volatile_Full_Access, Bit_Order => System.Low_Order_First; for IO_FUNC_EN_Register use record Val at 0 range 0 .. 31; Arr at 0 range 0 .. 31; end record; -- IO_FUNC_SEL_PIN array type IO_FUNC_SEL_PIN_Field_Array is array (0 .. 31) of Boolean with Component_Size => 1, Size => 32; -- HW I/O function select. type IO_FUNC_SEL_Register (As_Array : Boolean := False) is record case As_Array is when False => -- PIN as a value Val : HAL.UInt32; when True => -- PIN as an array Arr : IO_FUNC_SEL_PIN_Field_Array; end case; end record with Unchecked_Union, Size => 32, Volatile_Full_Access, Bit_Order => System.Low_Order_First; for IO_FUNC_SEL_Register use record Val at 0 range 0 .. 31; Arr at 0 range 0 .. 31; end record; -- OUT_XOR_PIN array type OUT_XOR_PIN_Field_Array is array (0 .. 31) of Boolean with Component_Size => 1, Size => 32; -- Output XOR (invert). type OUT_XOR_Register (As_Array : Boolean := False) is record case As_Array is when False => -- PIN as a value Val : HAL.UInt32; when True => -- PIN as an array Arr : OUT_XOR_PIN_Field_Array; end case; end record with Unchecked_Union, Size => 32, Volatile_Full_Access, Bit_Order => System.Low_Order_First; for OUT_XOR_Register use record Val at 0 range 0 .. 31; Arr at 0 range 0 .. 31; end record; ----------------- -- Peripherals -- ----------------- -- General purpose input/output controller. type GPIO0_Peripheral is record -- Pin value. VALUE : aliased VALUE_Register; -- Pin input enable. INPUT_EN : aliased INPUT_EN_Register; -- Pin output enable. OUTPUT_EN : aliased OUTPUT_EN_Register; -- Output port value. PORT : aliased PORT_Register; -- Internal Pull-Up enable. PULLUP : aliased PULLUP_Register; -- Drive Strength. DRIVE : aliased DRIVE_Register; -- Rise interrupt enable. RISE_INT_EN : aliased RISE_INT_EN_Register; -- Rise interrupt pending. RISE_INT_PEMD : aliased RISE_INT_PEMD_Register; -- Fall interrupt enable. FALL_INT_EN : aliased FALL_INT_EN_Register; -- Fall interrupt pending. FALL_INT_PEND : aliased FALL_INT_PEND_Register; -- High interrupt enable. HIGH_INT_EN : aliased HIGH_INT_EN_Register; -- High interrupt pending. HIGH_INT_PEND : aliased HIGH_INT_PEND_Register; -- Low interrupt enable. LOW_INT_EN : aliased LOW_INT_EN_Register; -- Low interrupt pending. LOW_INT_PEND : aliased LOW_INT_PEND_Register; -- HW I/O function enable. IO_FUNC_EN : aliased IO_FUNC_EN_Register; -- HW I/O function select. IO_FUNC_SEL : aliased IO_FUNC_SEL_Register; -- Output XOR (invert). OUT_XOR : aliased OUT_XOR_Register; end record with Volatile; for GPIO0_Peripheral use record VALUE at 16#0# range 0 .. 31; INPUT_EN at 16#4# range 0 .. 31; OUTPUT_EN at 16#8# range 0 .. 31; PORT at 16#C# range 0 .. 31; PULLUP at 16#10# range 0 .. 31; DRIVE at 16#14# range 0 .. 31; RISE_INT_EN at 16#18# range 0 .. 31; RISE_INT_PEMD at 16#1C# range 0 .. 31; FALL_INT_EN at 16#20# range 0 .. 31; FALL_INT_PEND at 16#24# range 0 .. 31; HIGH_INT_EN at 16#28# range 0 .. 31; HIGH_INT_PEND at 16#2C# range 0 .. 31; LOW_INT_EN at 16#30# range 0 .. 31; LOW_INT_PEND at 16#34# range 0 .. 31; IO_FUNC_EN at 16#38# range 0 .. 31; IO_FUNC_SEL at 16#3C# range 0 .. 31; OUT_XOR at 16#40# range 0 .. 31; end record; -- General purpose input/output controller. GPIO0_Periph : aliased GPIO0_Peripheral with Import, Address => System'To_Address (16#10012000#); end FE310_SVD.GPIO;
stcarrez/ada-ado
Ada
15,372
adb
----------------------------------------------------------------------- -- ado-sessions -- Sessions Management -- Copyright (C) 2009 - 2022 Stephane Carrez -- Written by Stephane Carrez ([email protected]) -- -- Licensed under the Apache License, Version 2.0 (the "License"); -- you may not use this file except in compliance with the License. -- You may obtain a copy of the License at -- -- http://www.apache.org/licenses/LICENSE-2.0 -- -- Unless required by applicable law or agreed to in writing, software -- distributed under the License is distributed on an "AS IS" BASIS, -- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -- See the License for the specific language governing permissions and -- limitations under the License. ----------------------------------------------------------------------- with Util.Log; with Util.Log.Loggers; with Ada.Unchecked_Deallocation; with ADO.Sequences; with ADO.Statements.Create; package body ADO.Sessions is Log : constant Util.Log.Loggers.Logger := Util.Log.Loggers.Create ("ADO.Sessions"); procedure Check_Session (Database : in Session'Class; Message : in String := "") is begin if Database.Impl = null then Log.Error ("Session is closed or not initialized"); raise Session_Error; end if; if Message'Length > 0 then Log.Info (Message, Database.Impl.Database.Value.Ident); end if; end Check_Session; -- --------- -- Session -- --------- -- ------------------------------ -- Get the session status. -- ------------------------------ function Get_Status (Database : in Session) return Connection_Status is begin if Database.Impl = null or else Database.Impl.Database.Is_Null then return CLOSED; else return OPEN; end if; end Get_Status; -- ------------------------------ -- Get the database driver which manages this connection. -- ------------------------------ function Get_Driver (Database : in Session) return ADO.Connections.Driver_Access is begin if Database.Impl = null or else Database.Impl.Database.Is_Null then return null; else return Database.Impl.Database.Value.Get_Driver; end if; end Get_Driver; -- ------------------------------ -- Close the session. -- ------------------------------ procedure Close (Database : in out Session) is procedure Free is new Ada.Unchecked_Deallocation (Object => Session_Record, Name => Session_Record_Access); Is_Zero : Boolean; begin Log.Info ("Closing session"); if Database.Impl /= null then ADO.Objects.Release_Proxy (Database.Impl.Proxy); Database.Impl.Database.Value.Close; Util.Concurrent.Counters.Decrement (Database.Impl.Counter, Is_Zero); if Is_Zero then Free (Database.Impl); end if; Database.Impl := null; end if; end Close; -- ------------------------------ -- Insert a new cache in the manager. The cache is identified by the given name. -- ------------------------------ procedure Add_Cache (Database : in out Session; Name : in String; Cache : in ADO.Caches.Cache_Type_Access) is begin Check_Session (Database); Database.Impl.Values.Add_Cache (Name, Cache); end Add_Cache; -- ------------------------------ -- Attach the object to the session. -- ------------------------------ procedure Attach (Database : in out Session; Object : in ADO.Objects.Object_Ref'Class) is pragma Unreferenced (Object); begin Check_Session (Database); end Attach; -- ------------------------------ -- Check if the session contains the object identified by the given key. -- ------------------------------ function Contains (Database : in Session; Item : in ADO.Objects.Object_Key) return Boolean is begin Check_Session (Database); return ADO.Objects.Cache.Contains (Database.Impl.Cache, Item); end Contains; -- ------------------------------ -- Remove the object from the session cache. -- ------------------------------ procedure Evict (Database : in out Session; Item : in ADO.Objects.Object_Key) is begin Check_Session (Database); ADO.Objects.Cache.Remove (Database.Impl.Cache, Item); end Evict; -- ------------------------------ -- Create a query statement. The statement is not prepared -- ------------------------------ function Create_Statement (Database : in Session; Table : in ADO.Schemas.Class_Mapping_Access) return Query_Statement is begin Check_Session (Database); declare Query : constant Query_Statement_Access := Database.Impl.Database.Value.Create_Statement (Table); begin return ADO.Statements.Create.Create_Statement (Query, Database.Impl.Values.all'Access); end; end Create_Statement; -- ------------------------------ -- Create a query statement. The statement is not prepared -- ------------------------------ function Create_Statement (Database : in Session; Query : in String) return Query_Statement is begin Check_Session (Database); declare Stmt : constant Query_Statement_Access := Database.Impl.Database.Value.Create_Statement (Query); begin return ADO.Statements.Create.Create_Statement (Stmt, Database.Impl.Values.all'Access); end; end Create_Statement; -- ------------------------------ -- Create a query statement. The statement is not prepared -- ------------------------------ function Create_Statement (Database : in Session; Query : in ADO.Queries.Context'Class) return Query_Statement is begin Check_Session (Database); declare SQL : constant String := Query.Get_SQL (Database.Impl.Queries.all); Stmt : Query_Statement := Database.Create_Statement (SQL); begin Stmt.Set_Parameters (Query); return Stmt; end; end Create_Statement; -- ------------------------------ -- Create a query statement and initialize the SQL statement with the query definition. -- ------------------------------ function Create_Statement (Database : in Session; Query : in ADO.Queries.Query_Definition_Access) return Query_Statement is begin Check_Session (Database); declare SQL : constant String := ADO.Queries.Get_SQL (Query, Database.Impl.Queries.all, False); begin return Database.Create_Statement (SQL); end; end Create_Statement; -- ------------------------------ -- Create a query statement. The statement is not prepared -- ------------------------------ function Create_Statement (Database : in Session; Query : in ADO.SQL.Query'Class; Table : in ADO.Schemas.Class_Mapping_Access) return Query_Statement is begin Check_Session (Database); declare Stmt : Query_Statement := Database.Create_Statement (Table); begin if Query in ADO.Queries.Context'Class then declare SQL : constant String := ADO.Queries.Context'Class (Query).Get_SQL (Database.Impl.Queries.all); begin ADO.SQL.Append (Stmt.Get_Query.SQL, SQL); end; end if; Stmt.Set_Parameters (Query); return Stmt; end; end Create_Statement; -- ------------------------------ -- Execute the SQL statement. -- ------------------------------ procedure Execute (Database : in Session'Class; SQL : in String) is Stmt : ADO.Statements.Query_Statement := Database.Create_Statement (SQL); begin Stmt.Execute; end Execute; -- ------------------------------ -- Load the database schema definition for the current database. -- ------------------------------ procedure Load_Schema (Database : in Session; Schema : out ADO.Schemas.Schema_Definition) is begin Check_Session (Database, "Loading schema {0}"); Database.Impl.Database.Value.Load_Schema (Schema); end Load_Schema; -- ------------------------------ -- Check if the table with the given name exists in the database. -- ------------------------------ function Has_Table (Database : in Session; Name : in String) return Boolean is begin Check_Session (Database, "Has_Table {0}"); return Database.Impl.Database.Value.Has_Table (Name); end Has_Table; -- --------- -- Master Session -- --------- -- ------------------------------ -- Start a transaction. -- ------------------------------ procedure Begin_Transaction (Database : in out Master_Session) is begin Check_Session (Database, "Begin transaction {0}"); Database.Impl.Database.Value.Begin_Transaction; end Begin_Transaction; -- ------------------------------ -- Commit the current transaction. -- ------------------------------ procedure Commit (Database : in out Master_Session) is begin Check_Session (Database, "Commit transaction {0}"); Database.Impl.Database.Value.Commit; end Commit; -- ------------------------------ -- Rollback the current transaction. -- ------------------------------ procedure Rollback (Database : in out Master_Session) is begin Check_Session (Database, "Rollback transaction {0}"); Database.Impl.Database.Value.Rollback; end Rollback; -- ------------------------------ -- Allocate an identifier for the table. -- ------------------------------ procedure Allocate (Database : in out Master_Session; Id : in out ADO.Objects.Object_Record'Class) is begin Check_Session (Database); ADO.Sequences.Allocate (Database.Sequences.all, Database, Id); end Allocate; -- ------------------------------ -- Flush the objects that were modified. -- ------------------------------ procedure Flush (Database : in out Master_Session) is begin Check_Session (Database); end Flush; overriding procedure Adjust (Object : in out Session) is begin if Object.Impl /= null then Util.Concurrent.Counters.Increment (Object.Impl.Counter); end if; end Adjust; overriding procedure Finalize (Object : in out Session) is procedure Free is new Ada.Unchecked_Deallocation (Object => Session_Record, Name => Session_Record_Access); Is_Zero : Boolean; begin if Object.Impl /= null then Util.Concurrent.Counters.Decrement (Object.Impl.Counter, Is_Zero); if Is_Zero then ADO.Objects.Release_Proxy (Object.Impl.Proxy, Detach => True); if not Object.Impl.Database.Is_Null then Object.Impl.Database.Value.Close; end if; Free (Object.Impl); end if; Object.Impl := null; end if; end Finalize; -- ------------------------------ -- Create a delete statement -- ------------------------------ function Create_Statement (Database : in Master_Session; Table : in ADO.Schemas.Class_Mapping_Access) return Delete_Statement is begin Check_Session (Database); declare Stmt : constant Delete_Statement_Access := Database.Impl.Database.Value.Create_Statement (Table); begin return ADO.Statements.Create.Create_Statement (Stmt.all'Access, Database.Impl.Values.all'Access); end; end Create_Statement; -- ------------------------------ -- Create an update statement -- ------------------------------ function Create_Statement (Database : in Master_Session; Table : in ADO.Schemas.Class_Mapping_Access) return Update_Statement is begin Check_Session (Database); declare Stmt : constant Update_Statement_Access := Database.Impl.Database.Value.Create_Statement (Table); begin return ADO.Statements.Create.Create_Statement (Stmt.all'Access, Database.Impl.Values.all'Access); end; end Create_Statement; -- ------------------------------ -- Create an insert statement -- ------------------------------ function Create_Statement (Database : in Master_Session; Table : in ADO.Schemas.Class_Mapping_Access) return Insert_Statement is begin Check_Session (Database); declare Stmt : constant Insert_Statement_Access := Database.Impl.Database.Value.Create_Statement (Table); begin return ADO.Statements.Create.Create_Statement (Stmt.all'Access, Database.Impl.Values.all'Access); end; end Create_Statement; -- ------------------------------ -- Get the audit manager. -- ------------------------------ function Get_Audit_Manager (Database : in Master_Session) return access Audits.Audit_Manager'Class is begin return Database.Audit; end Get_Audit_Manager; -- ------------------------------ -- Internal operation to get access to the database connection. -- ------------------------------ procedure Access_Connection (Database : in out Master_Session; Process : not null access procedure (Connection : in out Database_Connection'Class)) is begin Check_Session (Database); Process (Database.Impl.Database.Value); end Access_Connection; -- ------------------------------ -- Internal method to get the session proxy associated with the given database session. -- The session proxy is associated with some ADO objects to be able to retrieve the database -- session for the implementation of lazy loading. The session proxy is kept until the -- session exist and at least one ADO object is refering to it. -- ------------------------------ function Get_Session_Proxy (Database : in Session) return ADO.Objects.Session_Proxy_Access is use type ADO.Objects.Session_Proxy_Access; begin Check_Session (Database); if Database.Impl.Proxy = null then Database.Impl.Proxy := ADO.Objects.Create_Session_Proxy (Database.Impl); end if; return Database.Impl.Proxy; end Get_Session_Proxy; end ADO.Sessions;
onox/orka
Ada
1,479
adb
-- SPDX-License-Identifier: Apache-2.0 -- -- Copyright (c) 2018 onox <[email protected]> -- -- Licensed under the Apache License, Version 2.0 (the "License"); -- you may not use this file except in compliance with the License. -- You may obtain a copy of the License at -- -- http://www.apache.org/licenses/LICENSE-2.0 -- -- Unless required by applicable law or agreed to in writing, software -- distributed under the License is distributed on an "AS IS" BASIS, -- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -- See the License for the specific language governing permissions and -- limitations under the License. package body Orka.Resources.Managers is function Contains (Object : Manager; Name : String) return Boolean is (Object.Resources.Contains (Name)); function Resource (Object : Manager; Name : String) return Resource_Ptr is (Object.Resources.Element (Name)); procedure Add_Resource (Object : in out Manager; Name : String; Resource : Resource_Ptr) is begin Resource_Maps.Insert (Object.Resources, Name, Resource); end Add_Resource; procedure Remove_Resource (Object : in out Manager; Name : String) is begin Resource_Maps.Delete (Object.Resources, Name); -- TODO Free the resource (Batch, other GL objects etc.) in a GPU job end Remove_Resource; function Create_Manager return Manager_Ptr is (new Manager); end Orka.Resources.Managers;
optikos/ada-lsp
Ada
2,829
ads
-- Copyright (c) 2017 Maxim Reznik <[email protected]> -- -- SPDX-License-Identifier: MIT -- License-Filename: LICENSE ------------------------------------------------------------- with Ada.Containers.Hashed_Maps; with Ada.Containers.Doubly_Linked_Lists; with League.Strings.Hash; with LSP.Messages; with Incr.Lexers.Incremental; with Incr.Nodes; with Incr.Parsers.Incremental; with Ada_LSP.Ada_Lexers; with Ada_LSP.Ada_Parser_Data; with Ada_LSP.Completions; with Ada_LSP.Documents; package Ada_LSP.Contexts is type Context is tagged limited private; not overriding procedure Initialize (Self : in out Context; Root : League.Strings.Universal_String); not overriding procedure Load_Document (Self : in out Context; Item : LSP.Messages.TextDocumentItem); not overriding function Get_Document (Self : Context; URI : LSP.Messages.DocumentUri) return Ada_LSP.Documents.Document_Access; not overriding procedure Update_Document (Self : in out Context; Item : not null Ada_LSP.Documents.Document_Access); -- Reparse document after changes not overriding procedure Add_Completion_Handler (Self : in out Context; Value : not null Ada_LSP.Completions.Handler_Access); not overriding procedure Fill_Completions (Self : Context; Context : Ada_LSP.Completions.Context'Class; Result : in out LSP.Messages.CompletionList); not overriding function Get_Parser_Data_Provider (Self : Context) return Ada_LSP.Ada_Parser_Data.Provider_Access; private package Document_Maps is new Ada.Containers.Hashed_Maps (Key_Type => LSP.Messages.DocumentUri, Element_Type => Ada_LSP.Documents.Document_Access, Hash => League.Strings.Hash, Equivalent_Keys => League.Strings."=", "=" => Ada_LSP.Documents."="); type Kind_Map is array (Incr.Nodes.Node_Kind range <>) of Boolean; type Provider is new Ada_LSP.Ada_Parser_Data.Provider with record Is_Defining_Name : Kind_Map (108 .. 120); end record; overriding function Is_Defining_Name (Self : Provider; Kind : Incr.Nodes.Node_Kind) return Boolean; package Completion_Handler_Lists is new Ada.Containers.Doubly_Linked_Lists (Ada_LSP.Completions.Handler_Access, Ada_LSP.Completions."="); type Context is tagged limited record Root : League.Strings.Universal_String; Documents : Document_Maps.Map; Batch_Lexer : aliased Ada_LSP.Ada_Lexers.Batch_Lexer; Incr_Lexer : aliased Incr.Lexers.Incremental.Incremental_Lexer; Incr_Parser : aliased Incr.Parsers.Incremental.Incremental_Parser; Provider : aliased Ada_LSP.Contexts.Provider; Completions : Completion_Handler_Lists.List; end record; end Ada_LSP.Contexts;
AdaCore/gpr
Ada
2,228
adb
-- -- Copyright (C) 2019-2023, AdaCore -- -- SPDX-License-Identifier: Apache-2.0 -- with Ada.Text_IO; with Ada.Strings.Fixed; with GPR2.Unit; with GPR2.Context; with GPR2.Path_Name; with GPR2.Project.Source.Set; with GPR2.Project.View; with GPR2.Project.Tree; with GPR2.Source; with GPR2.Source_Info.Parser.Ada_Language; procedure Main is use Ada; use GPR2; procedure Display (Prj : Project.View.Object; Full : Boolean := True); procedure Output_Filename (Filename : Path_Name.Full_Name); -- Remove the leading tmp directory ------------- -- Display -- ------------- procedure Display (Prj : Project.View.Object; Full : Boolean := True) is begin Text_IO.Put (String (Prj.Name) & " "); Text_IO.Set_Col (10); Text_IO.Put_Line (Prj.Qualifier'Img); for Source of Prj.Sources loop declare U : constant Optional_Name_Type := Source.Unit_Name; begin Output_Filename (Source.Path_Name.Value); Text_IO.Set_Col (16); Text_IO.Put (" language: " & Image (Source.Language)); Text_IO.Set_Col (33); Text_IO.Put (" Kind: " & GPR2.Unit.Library_Unit_Type'Image (Source.Kind)); if U /= "" then Text_IO.Put (" unit: " & String (U)); end if; Text_IO.New_Line; end; end loop; end Display; --------------------- -- Output_Filename -- --------------------- procedure Output_Filename (Filename : Path_Name.Full_Name) is I : constant Positive := Strings.Fixed.Index (Filename, "extended-replace"); begin Text_IO.Put (" > " & Filename (I + 16 .. Filename'Last)); end Output_Filename; Prj1, Prj2 : Project.Tree.Object; Ctx : Context.Object; begin Project.Tree.Load (Prj1, Project.Create ("prj1.gpr"), Ctx); Project.Tree.Load (Prj2, Project.Create ("prj2.gpr"), Ctx); Text_IO.Put_Line ("**************** Iterator Prj1"); for P of Prj1 loop Display (P, Full => False); end loop; Text_IO.Put_Line ("**************** Iterator Prj2"); for P of Prj2 loop Display (P, Full => False); end loop; end Main;
jscparker/math_packages
Ada
24,631
adb
----------------------------------------------------------------------- -- package body Extended_Real.IO, translations between extended precision and text -- Copyright (C) 2008-2018 Jonathan S. Parker -- -- 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. --------------------------------------------------------------------------- -- Test for E_Real_Machine_Emax etc package body Extended_Real.IO is -- The following are some global constant sets for ASCII to e_Real -- Translation. Is_Numeral : constant Set := Set'('0'..'9' => True, others => False); Is_Sign : constant Set := Set'('-' | '+' => True, others => False); Is_Decimal_Pt : constant Set := Set'('.' => True, others => False); -- A Chunk is a digit in Radix 10**6, which is the radix of decimal -- number we're translating the binary number into..6 decimal digits -- at a time. The following are used by both the ASCII to e_Real -- and e_Real to ASCII routines. type Chunk_Integer is range -2**31+1 .. 2**31-1; Chunk : Chunk_Integer; Chunk_Width : constant := No_Of_Decimal_Digits_Per_Chunk; -- up in spec. Ten_To_The_Chunk_Width : constant E_Digit := Make_E_Digit (10.0**Chunk_Width); -- The following are for translating the exponent to a string. -- Exp_String is used by both "e_Real_Image" and "Exp_Image" Exp_String_Width : constant Positive := E_Integer'Width; -- Should include space for the sign. subtype Exp_String is String (1..Exp_String_Width); Exp_Full_Text : Exp_String := (others => ' '); Log_Base_10_Of_2 : constant := 0.3010299956639812; Zero : constant e_Real := +0.0; Ten : constant e_Real := +10.0; --------------- -- Exp_Image -- --------------- -- Also returns the sign of Exp_Val: either '+' or '-'. -- Uses fact that first char of E_Integer'Image is ' ' or '-'. -- Left justifies the digits of the Exp in a field of blanks. -- Another option is to right justify in a field of 0's. function Exp_Image (Exp_Val : E_Integer) return Exp_String is Result : Exp_String := (others => ' '); E_String : constant String := E_Integer'Image (Exp_Val); begin Result (1..E_String'Length) := E_String; if Result(1) = ' ' then Result(1) := '+'; end if; return Result; end Exp_Image; ------------------------------ -- Count_of_Trailing_Blanks -- ------------------------------ function Count_of_Trailing_Blanks (Exp : Exp_String) return Integer is cnt : Integer := 0; begin for i in reverse 1..Exp_String'Length loop if Exp(i) = ' ' then cnt := cnt + 1; else exit; end if; end loop; return cnt; end Count_of_Trailing_Blanks; ------------------ -- e_Real_Image -- ------------------ -- Extended Real (e_Real) to Text translation function e_Real_Image (X : in e_Real; Aft : in Positive := Positive'Last) return String is -- Make strings that are large enough to return any desired -- result that is inside the bounds stated in the spec. The -- extra chunk is there to fill in for lost digits due to leading -- zeros. Max_Result_Length : constant Positive := Max_Practical_String_Length + 2*Chunk_Width + Exp_String_Width + 3; subtype Result_String is String(1..Max_Result_Length); Result : Result_String := (others => ' '); Mantissa_String : Result_String := (others => '0'); Sign : Character := ' '; -- init important. Mantissa_Length : Positive; Result_Length : Positive; Exp_Stripped_Length : Integer; -- Types for translating from extended e_Real to Decimal. Exp_Base_2 : Real; Exp_Base_10_Shift : Real; Exp_Shift, Exp_Val : E_Integer; I_Exp_Shift : Integer; Leading_Zeros : Natural; Y : e_Real := Abs (X); Leading_Chunk, Trailing_Chunks : e_Real; Stage_Last : Positive; -- Initialized in Step 0. -- Read global memory Mantissa_Length. -- Update global memory "Mantissa_String". Right justify -- Chunk_Integer'Image(Chunk). Use fact that Mantissa_String is -- initialized all '0', so no need to add '0's to the left of the -- right justified Chunk_Integer'Image(Chunk). Recall Mantissa_.. -- allows an extra chunk at the end to adjust for removal of leading -- zeros. procedure Add_To_Mantissa_String (Chunk : Chunk_Integer; Stage : Positive) is Ascii_Chunk : constant String := Chunk_Integer'Image (Chunk); Len : constant Integer := Ascii_Chunk'Length; Start, Ending : Integer; begin Start := (Stage - Positive'First + 1)*Chunk_Width - Len + 2; Ending := (Stage - Positive'First + 1)*Chunk_Width; -- Right justifies digits in a field of '0's. if Start > Mantissa_Length + 2*Chunk_Width then return; end if; if Ending > Mantissa_Length + 2*Chunk_Width then Ending := Mantissa_Length + 2*Chunk_Width; end if; Mantissa_String (Start..Ending) := Ascii_Chunk(2..Ending-Start+2); -- Ascii_Chunk always starts with ' ' or '-'. Here it's always positive. -- Its min length (Len) is always 2, even if chunk = '0'. end Add_To_Mantissa_String; begin -- STEP 0-. Special cases. Zero and Infinity. if Are_Equal (X, Zero) then return "0.0"; end if; if Are_Equal (X, Positive_Infinity) then return "+inf"; end if; if Are_Equal (X, Negative_Infinity) then return "-inf"; end if; -- STEP 0. Determine number of decimal digits in Mantissa. -- Its Min (Aft+1, Max_No_Of_Digits, and Max_Practical_String_Length). -- It may not be less than 12. if Aft = Positive'Last then Mantissa_Length := Aft; -- Positive'Last is the upper limit. else Mantissa_Length := Aft + 1; -- the usual case. end if; if Mantissa_Length < 13 then Mantissa_Length := 13; end if; if Mantissa_Length > Max_No_Of_Digits then Mantissa_Length := Max_No_Of_Digits; end if; if Mantissa_Length > Max_Practical_String_Length then Mantissa_Length := Max_Practical_String_Length; end if; Stage_Last := (Mantissa_Length - 1) / Chunk_Width + 3; -- This is ceiling (Mantissa_Length / Chunk_Width) + 1. (+ 2 really) -- This is the number of steps required to strip digits of number -- Mantissa_Length from the e_Real in chunks of Chunk_Width. The -- extra 2 chunk2 are usually required to fill in for digits lost due -- to leading zeros in the first chunk. (Normalization of the decimal -- representation.) -- STEP 1. Multiply Item by a power of 10.0 to make it less than 1.0. -- Why a power of ten? Cause then we can shift the final Radix 10 exp -- by exactly the value of the exponent. The formula is -- Shift = -Ceiling (Log_Base_10_Of_2 * Exp_Base_2) -- Exp_Base_2 is the normalized exp: i.e. 2**(-Exp_Base_2) * Item -- is slightly less than 1. But we want a power of 10 with this property, -- not a power of 2. 10**(-N) = 2**(-Exp_Base_2) implies -- N = Log_Base_10_Of_2 * Exp_Base_2, except that we must make N the -- appropriate nearest integer. If we do that by rounding N up (taking -- the ceiling) then 10**(-N) < 2**(-Exp_Base_2) which implies that -- 10**(-N) * X < 2**(-Exp_Base_2) * X, so 10**(-N) * X < 1.0, -- as required. Exp_Base_2 := Real (No_Of_Bits_In_Radix) * Real (Exponent (X)); Exp_Base_10_Shift := -Real'Ceiling (Log_Base_10_Of_2 * Exp_Base_2); I_Exp_Shift := Integer (Exp_Base_10_Shift); Exp_Shift := E_Integer (Exp_Base_10_Shift); -- STEP 2. Multiplying X by 10**Shift will make it less than 1. -- Want to multiply Item by 10**(6 + Shift) to get no more than 6 decimal -- digits sticking out to the left of the decimal point (and often 0), -- because we're stripping 6 decimal digits at a time from the left of the -- decimal point with the truncate function. Remember Y := Abs(X). -- Loop translates Y into Radix 10**6. -- Each Chunk is a digit in Radix 10**6. Y := Ten ** (No_Of_Decimal_Digits_Per_Chunk + I_Exp_Shift) * Y; -- Y := Machine(Y); -- Machine would round away all guard digits. for Stage in 1..Stage_Last loop Leading_Chunk := Truncation (Y); Trailing_Chunks := Y - Leading_Chunk; Chunk := Chunk_Integer (Make_Real (Leading_Chunk)); Add_To_Mantissa_String (Chunk, Stage); Y := Ten_To_The_Chunk_Width * Trailing_Chunks; -- Shift another 6 decimal digits to the left of the decimal point. end loop; -- STEP 3. Construct the string. Get leading sign. Strip away leading -- Zeros. Exp is the amount we shifted by above, adjusted for stripped -- leading zeros. (ie, move decimal point to right of leading zeros -- and 1st non-zero digit; decrement Exp by 1 for each leading zero etc.) if X < Zero then Sign := '-'; end if; -- Set the sign. Sign is initialized ' '. Recall Y = Abs(X). -- Count leading zeros: Leading_Zeros := 0; for I in 1..20 loop -- Should be no more than 8 if digit 1..10^9. if Mantissa_String (I) /= '0' then exit; else Leading_Zeros := Leading_Zeros + 1; end if; end loop; -- Right now the virtual decimal point sits to the left of every digit -- in Mantissa_String, and the Exponent is given by -Shift. We want -- to shift the decimal point to the right of each leading zero, and to -- the right of the first non-zero digit. Then DECREASE the exponent -- by that shift. Exp_Val := -Exp_Shift - (1 + E_Integer(Leading_Zeros)); -- the 1 accounts for the 1st non-zero digit to the left of decimal point. Exp_Full_Text := Exp_Image (Exp_Val); Exp_Stripped_Length := Exp_String_Width - Count_of_Trailing_Blanks (Exp_Full_Text); Result_Length := Mantissa_Length + Exp_Stripped_Length + 3; Result(1..Result_Length) := Sign & Mantissa_String (1+Leading_Zeros) & '.' & Mantissa_String (2+Leading_Zeros..Mantissa_Length+Leading_Zeros) & 'E' & Exp_Full_Text (1..Exp_Stripped_Length); return Result(1..Result_Length); end e_Real_Image; ---------------------- -- Integer_Value_Of -- ---------------------- -- Assumes that a decimal point is immediately to the right of the last digit. -- Translate each chunk (Digit_n) of 8 decimal digits into e_Real, and sum -- the polynomial in powers of 10**8. (Do it this way because we can then -- use E_Digit*e_Real operations for efficiency.) Horner's rule is -- -- Digit_0 + 10**8*(Digit_1 + 10**8*(Digit_2 + ... + 10**8*(Digit_n))))) -- -- Below, the 10**8 is called Ten_To_The_Chunk_Width. It's a Global constant. -- IMPORTANT to return ZERO if string has 0 length. e_Real_Val requires it. function Integer_Value_Of (F : String) return e_Real is Result, Digit_i : e_Real; -- initialized to zero. (Important). No_Of_Full_Chunk_Iterations : Natural; First_Partial_Chunk_Width : Natural; Start, Ending : Integer; begin if F'Length = 0 then return Zero; end if; No_Of_Full_Chunk_Iterations := F'Length / Chunk_Width; First_Partial_Chunk_Width := F'Length MOD Chunk_Width; -- Special case for highest order Digit_i, the one of width -- First_Partial_Chunk_Width. If this partial chunk is the only -- chunk (ie., No_Of_Full_Chunk_Iterations = 0) then there is no -- multiplication of the result by 10**8. (See formula above.) if First_Partial_Chunk_Width > 0 then Start := F'First; Ending := F'First + First_Partial_Chunk_Width - 1; Digit_i := +Real (Chunk_Integer'Value (F(Start..Ending))); if No_Of_Full_Chunk_Iterations > 0 then Result := Ten_To_The_Chunk_Width * Digit_i; else Result := Digit_i; end if; end if; -- Do the lower order Digits_i's. The lowest order Digit_i has no -- 10**8 multiplied by it. for i in 0..No_Of_Full_Chunk_Iterations-1 loop Start := F'First + First_Partial_Chunk_Width + i * Chunk_Width; Ending := Start + Chunk_Width - 1; Digit_i := +Real (Chunk_Integer'Value (F(Start..Ending))); if i < No_Of_Full_Chunk_Iterations-1 then Result := Ten_To_The_Chunk_Width * (Result + Digit_i); else Result := Result + Digit_i; end if; end loop; return Result; end Integer_Value_Of; ------------------------- -- Fractional_Value_Of -- ------------------------- -- Assumes that a decimal point is immediately to the left of the 1st digit. -- IMPORTANT to return ZERO if string has 0 length. e_Real_Val requires it. -- function Fractional_Value_Of (F : String) return e_Real is Result : e_Real; begin if F'Length = 0 then return Zero; end if; Result := Integer_Value_Of(F); -- We have Val as though decimal point were to the right of all digits. -- Want it to the left of all digits: just multiply by Ten**(-F'Length) -- We do it this way so can use efficiency of E_Digit*e_Real in routine -- Integer_Value_Of. But many possible optimizations are neglected. -- If performance is an issue, then maybe try e_Real / E_Digit method -- where E_Digit = 10**8. Result := Result * Ten**(-F'Length); return Result; end Fractional_Value_Of; ---------------- -- e_Real_Val -- ---------------- -- Accepts the following formats: -- INTEGER : 1234567 -- DECIMAL : 12.34567 or -.1234567 or 1234567. -- EXPONENTIAL : 1234.567E+002 or .1234567E2 or 123467.E-03 -- NON_DECIMAL_EXPONENTIAL : -1234567E-003 -- -- Notice that -- 1) The Decimal point may be anywhere to the left of the E. -- 2) The Leading sign is optional if it's '+'. -- 3) The sign of the exponent is optional if it's '+'. -- -- Start_Of_Num is the first non-white space. If the first char of the -- string is not white-space, then this will be Start_Of_Num. End_Of_Num -- is the non-white char just before the start of more white-space. BUT if -- the string comes to an end before any white-space re-appears, then the -- end of the string is taken as End_Of_Num. -- procedure e_Real_Val (X : in String; Y : out e_Real; Last : out Natural) is No_Of_Decimal_Pts, No_Of_Exp_Symbols, No_Of_Exp_Signs : Natural := 0; Decimal_Pt_Exists, Exp_Symbol_Exists, Exp_Sign_Exists : Boolean := False; Leading_Sign_Exists : Boolean := False; Decimal_Pt_Pos, Exp_Symbol_Pos, Exp_Sign_Pos : Positive; Start_Of_Aft : Positive; Num_Is_Positive : Boolean; Char : Character; type Format is (Int, Decimal_Pt_Only, Exponential, No_Decimal_Pt_Exponential); The_Format : Format; Start_Of_Num, End_Of_Num, Start_Of_Exp : Natural := 0; Fore_Width, Aft_Width, Exp_Width : Natural := 0; Exp_Str : Exp_String := (others => ' '); Exp_Val : Integer := 0; Fore, Aft, Result : e_Real; begin -- Handle null strings: if X'Length = 0 then raise E_Format_Error; end if; -- STEP 1. Strip away leading whitespace and sign. Start_Of_Num is the -- first non-white space character. If it's '-' or '+', then increment -- Start_Of_Num by 1. for I in X'Range loop if not Is_White_Space (X(I)) then Start_Of_Num := I; exit; end if; end loop; if Start_Of_Num = 0 then -- The string is all white-space, so: raise E_Format_Error; end if; -- If there is a leading sign, make a note of it, and then bypass it. Num_Is_Positive := True; -- No sign means positive Char := X(Start_Of_Num); if Is_Sign (Char) then Start_Of_Num := Start_Of_Num + 1; Leading_Sign_Exists := True; if Char = '+' then Num_Is_Positive := True; elsif Char = '-' then Num_Is_Positive := False; end if; end if; if Leading_Sign_Exists and then Start_Of_Num > X'Last then raise E_Format_Error; end if; -- when we incremented Start_Of_Num, we went beyond X'Last. So only char -- is the Sign. -- STEP 2. Scan everything beyond the leading sign. End_Of_Num is -- initialized to 0. Here is where we update it. for I in Start_Of_Num..X'Last loop Char := X(I); if Is_White_Space (Char) then -- we know Start.. points to non-whitespace End_Of_Num := I-1; exit; end if; if Is_Decimal_Pt (Char) then Decimal_Pt_Exists := True; Decimal_Pt_Pos := I; No_Of_Decimal_Pts := No_Of_Decimal_Pts + 1; elsif Is_Exp_Symbol (Char) then Exp_Symbol_Exists := True; Exp_Symbol_Pos := I; No_Of_Exp_Symbols := No_Of_Exp_Symbols + 1; elsif Is_Sign (Char) then Exp_Sign_Exists := True; Exp_Sign_Pos := I; No_Of_Exp_Signs := No_Of_Exp_Signs + 1; elsif not Is_Numeral (Char) then raise E_Format_Error; end if; end loop; if End_Of_Num = 0 then -- Reached the end of string w/o detecting whitespace End_Of_Num := X'Last; end if; -- Do some error checking: if No_Of_Decimal_Pts > 1 then raise E_Format_Error; end if; if No_Of_Exp_Signs > 1 then raise E_Format_Error; end if; if No_Of_Exp_Symbols > 1 then raise E_Format_Error; end if; if Decimal_Pt_Exists and Exp_Symbol_Exists then if Decimal_Pt_Pos >= Exp_Symbol_Pos then raise E_Format_Error; end if; end if; -- if there's an 'E' and a '+', then the sign must directly follow the -- the 'E'. Neither can be at the beginning or end of the num. if the -- sign exists, then 'E' must exist, but not vice-versa. if Exp_Sign_Exists then if Exp_Sign_Pos = End_Of_Num or else Exp_Sign_Pos = Start_Of_Num then raise E_Format_Error; end if; end if; if Exp_Symbol_Exists then if Exp_Symbol_Pos = End_Of_Num or else Exp_Symbol_Pos = Start_Of_Num then raise E_Format_Error; end if; end if; if Exp_Sign_Exists and Exp_Symbol_Exists then if not (Exp_Sign_Pos = Exp_Symbol_Pos + 1) then raise E_Format_Error; end if; end if; if Exp_Sign_Exists and not Exp_Symbol_Exists then raise E_Format_Error; end if; -- Diagnose the format of the number: if (not Decimal_Pt_Exists) and (not Exp_Symbol_Exists) then The_Format := Int; elsif Decimal_Pt_Exists and (not Exp_Symbol_Exists) then The_Format := Decimal_Pt_Only; elsif Decimal_Pt_Exists and Exp_Symbol_Exists then The_Format := Exponential; else The_Format := No_Decimal_Pt_Exponential; end if; -- STEP 3. Do the arithmetic. The string goes like Fore . Aft E Exp, -- in the most general case. The following is not really optimized -- for speed. case The_Format is when Int => Fore_Width := End_Of_Num - Start_Of_Num + 1; if Fore_Width = 0 then raise E_Format_Error; end if; Result := Integer_Value_Of(X (Start_Of_Num..End_Of_Num)); when Decimal_Pt_Only => Fore_Width := Decimal_Pt_Pos - Start_Of_Num; Aft_Width := End_Of_Num - Decimal_Pt_Pos; Start_Of_Aft := Decimal_Pt_Pos + 1; if Fore_Width = 0 and Aft_Width = 0 then raise E_Format_Error; end if; -- Notice that Fore or Aft may be 0. The funcs below return -- 0.0 in that case. Fore := Integer_Value_Of (X (Start_Of_Num..Start_Of_Num + Fore_Width - 1)); Aft := Fractional_Value_Of (X (Start_Of_Aft..Start_Of_Aft + Aft_Width - 1)); Result := Fore + Aft; when Exponential => if Exp_Sign_Exists then Start_Of_Exp := Exp_Sign_Pos + 1; else Start_Of_Exp := Exp_Symbol_Pos + 1; end if; Start_Of_Aft := Decimal_Pt_Pos + 1; Fore_Width := Decimal_Pt_Pos - Start_Of_Num; Aft_Width := Exp_Symbol_Pos - Start_Of_Aft; Exp_Width := End_Of_Num - Start_Of_Exp + 1; if Exp_Width = 0 then raise E_Format_Error; end if; if Exp_Width > Integer'Width then -- E_Integer is derived Integer. Both Integer and E_Integer are much -- wider than the allowed range of Exponents, so Contraint-Error will -- be raised in the arithmetic package, not here. raise E_Format_Error; end if; if Fore_Width = 0 and Aft_Width = 0 then raise E_Format_Error; end if; -- Notice that Fore or Aft may be 0. The funcs below return -- 0.0 in that case. Fore := Integer_Value_Of (X (Start_Of_Num..Start_Of_Num + Fore_Width - 1)); Aft := Fractional_Value_Of (X (Start_Of_Aft..Start_Of_Aft + Aft_Width - 1)); Exp_Str(1..Exp_Width) := X (Start_Of_Exp..Start_Of_Exp + Exp_Width - 1); Exp_Val := Integer'Value(Exp_Str); if Exp_Sign_Exists and then X(Exp_Sign_Pos) = '-' then Exp_Val := -Exp_Val; end if; Result := (Fore + Aft) * Ten**Exp_Val; when No_Decimal_Pt_Exponential => -- unusual case. Say there's no Aft, only Fore if Exp_Sign_Exists then Start_Of_Exp := Exp_Sign_Pos + 1; else Start_Of_Exp := Exp_Symbol_Pos + 1; end if; Fore_Width := Exp_Symbol_Pos - Start_Of_Num; Exp_Width := End_Of_Num - Start_Of_Exp + 1; if Fore_Width = 0 then raise E_Format_Error; end if; if Exp_Width = 0 then raise E_Format_Error; end if; if Exp_Width > Integer'Width then raise E_Format_Error; end if; Fore := Integer_Value_Of (X (Start_Of_Num..Start_Of_Num + Fore_Width - 1)); Exp_Str(1..Exp_Width) := X (Start_Of_Exp..Start_Of_Exp + Exp_Width - 1); Exp_Val := Integer'Value(Exp_Str); if Exp_Sign_Exists and then X(Exp_Sign_Pos) = '-' then Exp_Val := -Exp_Val; end if; Result := Fore * Ten**Exp_Val; end case; -- update the 2 out parameters: if Num_Is_Positive then Y := Result; else Y := -Result; end if; Last := End_Of_Num; end e_Real_Val; end Extended_Real.IO;
tum-ei-rcs/StratoX
Ada
47,843
adb
------------------------------------------------------------------------------ -- -- -- GNAT COMPILER COMPONENTS -- -- -- -- ADA.NUMERICS.GENERIC_COMPLEX_ARRAYS -- -- -- -- B o d y -- -- -- -- Copyright (C) 2006-2016, Free Software Foundation, Inc. -- -- -- -- GNAT is free software; you can redistribute it and/or modify it under -- -- terms of the GNU General Public License as published by the Free Soft- -- -- ware Foundation; either version 3, or (at your option) any later ver- -- -- sion. GNAT is distributed in the hope that it will be useful, but WITH- -- -- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY -- -- or FITNESS FOR A PARTICULAR PURPOSE. -- -- -- -- -- -- -- -- -- -- -- -- You should have received a copy of the GNU General Public License and -- -- a copy of the GCC Runtime Library Exception along with this program; -- -- see the files COPYING3 and COPYING.RUNTIME respectively. If not, see -- -- <http://www.gnu.org/licenses/>. -- -- -- -- GNAT was originally developed by the GNAT team at New York University. -- -- Extensive contributions were provided by Ada Core Technologies Inc. -- -- -- ------------------------------------------------------------------------------ with System.Generic_Array_Operations; use System.Generic_Array_Operations; package body Ada.Numerics.Generic_Complex_Arrays is -- Operations that are defined in terms of operations on the type Real, -- such as addition, subtraction and scaling, are computed in the canonical -- way looping over all elements. package Ops renames System.Generic_Array_Operations; subtype Real is Real_Arrays.Real; -- Work around visibility bug ??? function Is_Non_Zero (X : Complex) return Boolean is (X /= (0.0, 0.0)); -- Needed by Back_Substitute procedure Back_Substitute is new Ops.Back_Substitute (Scalar => Complex, Matrix => Complex_Matrix, Is_Non_Zero => Is_Non_Zero); procedure Forward_Eliminate is new Ops.Forward_Eliminate (Scalar => Complex, Real => Real'Base, Matrix => Complex_Matrix, Zero => (0.0, 0.0), One => (1.0, 0.0)); procedure Transpose is new Ops.Transpose (Scalar => Complex, Matrix => Complex_Matrix); -- Helper function that raises a Constraint_Error is the argument is -- not a square matrix, and otherwise returns its length. function Length is new Square_Matrix_Length (Complex, Complex_Matrix); -- Instant a generic square root implementation here, in order to avoid -- instantiating a complete copy of Generic_Elementary_Functions. -- Speed of the square root is not a big concern here. function Sqrt is new Ops.Sqrt (Real'Base); -- Instantiating the following subprograms directly would lead to -- name clashes, so use a local package. package Instantiations is --------- -- "*" -- --------- function "*" is new Vector_Scalar_Elementwise_Operation (Left_Scalar => Complex, Right_Scalar => Complex, Result_Scalar => Complex, Left_Vector => Complex_Vector, Result_Vector => Complex_Vector, Operation => "*"); function "*" is new Vector_Scalar_Elementwise_Operation (Left_Scalar => Complex, Right_Scalar => Real'Base, Result_Scalar => Complex, Left_Vector => Complex_Vector, Result_Vector => Complex_Vector, Operation => "*"); function "*" is new Scalar_Vector_Elementwise_Operation (Left_Scalar => Complex, Right_Scalar => Complex, Result_Scalar => Complex, Right_Vector => Complex_Vector, Result_Vector => Complex_Vector, Operation => "*"); function "*" is new Scalar_Vector_Elementwise_Operation (Left_Scalar => Real'Base, Right_Scalar => Complex, Result_Scalar => Complex, Right_Vector => Complex_Vector, Result_Vector => Complex_Vector, Operation => "*"); function "*" is new Inner_Product (Left_Scalar => Complex, Right_Scalar => Real'Base, Result_Scalar => Complex, Left_Vector => Complex_Vector, Right_Vector => Real_Vector, Zero => (0.0, 0.0)); function "*" is new Inner_Product (Left_Scalar => Real'Base, Right_Scalar => Complex, Result_Scalar => Complex, Left_Vector => Real_Vector, Right_Vector => Complex_Vector, Zero => (0.0, 0.0)); function "*" is new Inner_Product (Left_Scalar => Complex, Right_Scalar => Complex, Result_Scalar => Complex, Left_Vector => Complex_Vector, Right_Vector => Complex_Vector, Zero => (0.0, 0.0)); function "*" is new Outer_Product (Left_Scalar => Complex, Right_Scalar => Complex, Result_Scalar => Complex, Left_Vector => Complex_Vector, Right_Vector => Complex_Vector, Matrix => Complex_Matrix); function "*" is new Outer_Product (Left_Scalar => Real'Base, Right_Scalar => Complex, Result_Scalar => Complex, Left_Vector => Real_Vector, Right_Vector => Complex_Vector, Matrix => Complex_Matrix); function "*" is new Outer_Product (Left_Scalar => Complex, Right_Scalar => Real'Base, Result_Scalar => Complex, Left_Vector => Complex_Vector, Right_Vector => Real_Vector, Matrix => Complex_Matrix); function "*" is new Matrix_Scalar_Elementwise_Operation (Left_Scalar => Complex, Right_Scalar => Complex, Result_Scalar => Complex, Left_Matrix => Complex_Matrix, Result_Matrix => Complex_Matrix, Operation => "*"); function "*" is new Matrix_Scalar_Elementwise_Operation (Left_Scalar => Complex, Right_Scalar => Real'Base, Result_Scalar => Complex, Left_Matrix => Complex_Matrix, Result_Matrix => Complex_Matrix, Operation => "*"); function "*" is new Scalar_Matrix_Elementwise_Operation (Left_Scalar => Complex, Right_Scalar => Complex, Result_Scalar => Complex, Right_Matrix => Complex_Matrix, Result_Matrix => Complex_Matrix, Operation => "*"); function "*" is new Scalar_Matrix_Elementwise_Operation (Left_Scalar => Real'Base, Right_Scalar => Complex, Result_Scalar => Complex, Right_Matrix => Complex_Matrix, Result_Matrix => Complex_Matrix, Operation => "*"); function "*" is new Matrix_Vector_Product (Left_Scalar => Real'Base, Right_Scalar => Complex, Result_Scalar => Complex, Matrix => Real_Matrix, Right_Vector => Complex_Vector, Result_Vector => Complex_Vector, Zero => (0.0, 0.0)); function "*" is new Matrix_Vector_Product (Left_Scalar => Complex, Right_Scalar => Real'Base, Result_Scalar => Complex, Matrix => Complex_Matrix, Right_Vector => Real_Vector, Result_Vector => Complex_Vector, Zero => (0.0, 0.0)); function "*" is new Matrix_Vector_Product (Left_Scalar => Complex, Right_Scalar => Complex, Result_Scalar => Complex, Matrix => Complex_Matrix, Right_Vector => Complex_Vector, Result_Vector => Complex_Vector, Zero => (0.0, 0.0)); function "*" is new Vector_Matrix_Product (Left_Scalar => Real'Base, Right_Scalar => Complex, Result_Scalar => Complex, Left_Vector => Real_Vector, Matrix => Complex_Matrix, Result_Vector => Complex_Vector, Zero => (0.0, 0.0)); function "*" is new Vector_Matrix_Product (Left_Scalar => Complex, Right_Scalar => Real'Base, Result_Scalar => Complex, Left_Vector => Complex_Vector, Matrix => Real_Matrix, Result_Vector => Complex_Vector, Zero => (0.0, 0.0)); function "*" is new Vector_Matrix_Product (Left_Scalar => Complex, Right_Scalar => Complex, Result_Scalar => Complex, Left_Vector => Complex_Vector, Matrix => Complex_Matrix, Result_Vector => Complex_Vector, Zero => (0.0, 0.0)); function "*" is new Matrix_Matrix_Product (Left_Scalar => Complex, Right_Scalar => Complex, Result_Scalar => Complex, Left_Matrix => Complex_Matrix, Right_Matrix => Complex_Matrix, Result_Matrix => Complex_Matrix, Zero => (0.0, 0.0)); function "*" is new Matrix_Matrix_Product (Left_Scalar => Real'Base, Right_Scalar => Complex, Result_Scalar => Complex, Left_Matrix => Real_Matrix, Right_Matrix => Complex_Matrix, Result_Matrix => Complex_Matrix, Zero => (0.0, 0.0)); function "*" is new Matrix_Matrix_Product (Left_Scalar => Complex, Right_Scalar => Real'Base, Result_Scalar => Complex, Left_Matrix => Complex_Matrix, Right_Matrix => Real_Matrix, Result_Matrix => Complex_Matrix, Zero => (0.0, 0.0)); --------- -- "+" -- --------- function "+" is new Vector_Elementwise_Operation (X_Scalar => Complex, Result_Scalar => Complex, X_Vector => Complex_Vector, Result_Vector => Complex_Vector, Operation => "+"); function "+" is new Vector_Vector_Elementwise_Operation (Left_Scalar => Complex, Right_Scalar => Complex, Result_Scalar => Complex, Left_Vector => Complex_Vector, Right_Vector => Complex_Vector, Result_Vector => Complex_Vector, Operation => "+"); function "+" is new Vector_Vector_Elementwise_Operation (Left_Scalar => Real'Base, Right_Scalar => Complex, Result_Scalar => Complex, Left_Vector => Real_Vector, Right_Vector => Complex_Vector, Result_Vector => Complex_Vector, Operation => "+"); function "+" is new Vector_Vector_Elementwise_Operation (Left_Scalar => Complex, Right_Scalar => Real'Base, Result_Scalar => Complex, Left_Vector => Complex_Vector, Right_Vector => Real_Vector, Result_Vector => Complex_Vector, Operation => "+"); function "+" is new Matrix_Elementwise_Operation (X_Scalar => Complex, Result_Scalar => Complex, X_Matrix => Complex_Matrix, Result_Matrix => Complex_Matrix, Operation => "+"); function "+" is new Matrix_Matrix_Elementwise_Operation (Left_Scalar => Complex, Right_Scalar => Complex, Result_Scalar => Complex, Left_Matrix => Complex_Matrix, Right_Matrix => Complex_Matrix, Result_Matrix => Complex_Matrix, Operation => "+"); function "+" is new Matrix_Matrix_Elementwise_Operation (Left_Scalar => Real'Base, Right_Scalar => Complex, Result_Scalar => Complex, Left_Matrix => Real_Matrix, Right_Matrix => Complex_Matrix, Result_Matrix => Complex_Matrix, Operation => "+"); function "+" is new Matrix_Matrix_Elementwise_Operation (Left_Scalar => Complex, Right_Scalar => Real'Base, Result_Scalar => Complex, Left_Matrix => Complex_Matrix, Right_Matrix => Real_Matrix, Result_Matrix => Complex_Matrix, Operation => "+"); --------- -- "-" -- --------- function "-" is new Vector_Elementwise_Operation (X_Scalar => Complex, Result_Scalar => Complex, X_Vector => Complex_Vector, Result_Vector => Complex_Vector, Operation => "-"); function "-" is new Vector_Vector_Elementwise_Operation (Left_Scalar => Complex, Right_Scalar => Complex, Result_Scalar => Complex, Left_Vector => Complex_Vector, Right_Vector => Complex_Vector, Result_Vector => Complex_Vector, Operation => "-"); function "-" is new Vector_Vector_Elementwise_Operation (Left_Scalar => Real'Base, Right_Scalar => Complex, Result_Scalar => Complex, Left_Vector => Real_Vector, Right_Vector => Complex_Vector, Result_Vector => Complex_Vector, Operation => "-"); function "-" is new Vector_Vector_Elementwise_Operation (Left_Scalar => Complex, Right_Scalar => Real'Base, Result_Scalar => Complex, Left_Vector => Complex_Vector, Right_Vector => Real_Vector, Result_Vector => Complex_Vector, Operation => "-"); function "-" is new Matrix_Elementwise_Operation (X_Scalar => Complex, Result_Scalar => Complex, X_Matrix => Complex_Matrix, Result_Matrix => Complex_Matrix, Operation => "-"); function "-" is new Matrix_Matrix_Elementwise_Operation (Left_Scalar => Complex, Right_Scalar => Complex, Result_Scalar => Complex, Left_Matrix => Complex_Matrix, Right_Matrix => Complex_Matrix, Result_Matrix => Complex_Matrix, Operation => "-"); function "-" is new Matrix_Matrix_Elementwise_Operation (Left_Scalar => Real'Base, Right_Scalar => Complex, Result_Scalar => Complex, Left_Matrix => Real_Matrix, Right_Matrix => Complex_Matrix, Result_Matrix => Complex_Matrix, Operation => "-"); function "-" is new Matrix_Matrix_Elementwise_Operation (Left_Scalar => Complex, Right_Scalar => Real'Base, Result_Scalar => Complex, Left_Matrix => Complex_Matrix, Right_Matrix => Real_Matrix, Result_Matrix => Complex_Matrix, Operation => "-"); --------- -- "/" -- --------- function "/" is new Vector_Scalar_Elementwise_Operation (Left_Scalar => Complex, Right_Scalar => Complex, Result_Scalar => Complex, Left_Vector => Complex_Vector, Result_Vector => Complex_Vector, Operation => "/"); function "/" is new Vector_Scalar_Elementwise_Operation (Left_Scalar => Complex, Right_Scalar => Real'Base, Result_Scalar => Complex, Left_Vector => Complex_Vector, Result_Vector => Complex_Vector, Operation => "/"); function "/" is new Matrix_Scalar_Elementwise_Operation (Left_Scalar => Complex, Right_Scalar => Complex, Result_Scalar => Complex, Left_Matrix => Complex_Matrix, Result_Matrix => Complex_Matrix, Operation => "/"); function "/" is new Matrix_Scalar_Elementwise_Operation (Left_Scalar => Complex, Right_Scalar => Real'Base, Result_Scalar => Complex, Left_Matrix => Complex_Matrix, Result_Matrix => Complex_Matrix, Operation => "/"); ----------- -- "abs" -- ----------- function "abs" is new L2_Norm (X_Scalar => Complex, Result_Real => Real'Base, X_Vector => Complex_Vector); -------------- -- Argument -- -------------- function Argument is new Vector_Elementwise_Operation (X_Scalar => Complex, Result_Scalar => Real'Base, X_Vector => Complex_Vector, Result_Vector => Real_Vector, Operation => Argument); function Argument is new Vector_Scalar_Elementwise_Operation (Left_Scalar => Complex, Right_Scalar => Real'Base, Result_Scalar => Real'Base, Left_Vector => Complex_Vector, Result_Vector => Real_Vector, Operation => Argument); function Argument is new Matrix_Elementwise_Operation (X_Scalar => Complex, Result_Scalar => Real'Base, X_Matrix => Complex_Matrix, Result_Matrix => Real_Matrix, Operation => Argument); function Argument is new Matrix_Scalar_Elementwise_Operation (Left_Scalar => Complex, Right_Scalar => Real'Base, Result_Scalar => Real'Base, Left_Matrix => Complex_Matrix, Result_Matrix => Real_Matrix, Operation => Argument); ---------------------------- -- Compose_From_Cartesian -- ---------------------------- function Compose_From_Cartesian is new Vector_Elementwise_Operation (X_Scalar => Real'Base, Result_Scalar => Complex, X_Vector => Real_Vector, Result_Vector => Complex_Vector, Operation => Compose_From_Cartesian); function Compose_From_Cartesian is new Vector_Vector_Elementwise_Operation (Left_Scalar => Real'Base, Right_Scalar => Real'Base, Result_Scalar => Complex, Left_Vector => Real_Vector, Right_Vector => Real_Vector, Result_Vector => Complex_Vector, Operation => Compose_From_Cartesian); function Compose_From_Cartesian is new Matrix_Elementwise_Operation (X_Scalar => Real'Base, Result_Scalar => Complex, X_Matrix => Real_Matrix, Result_Matrix => Complex_Matrix, Operation => Compose_From_Cartesian); function Compose_From_Cartesian is new Matrix_Matrix_Elementwise_Operation (Left_Scalar => Real'Base, Right_Scalar => Real'Base, Result_Scalar => Complex, Left_Matrix => Real_Matrix, Right_Matrix => Real_Matrix, Result_Matrix => Complex_Matrix, Operation => Compose_From_Cartesian); ------------------------ -- Compose_From_Polar -- ------------------------ function Compose_From_Polar is new Vector_Vector_Elementwise_Operation (Left_Scalar => Real'Base, Right_Scalar => Real'Base, Result_Scalar => Complex, Left_Vector => Real_Vector, Right_Vector => Real_Vector, Result_Vector => Complex_Vector, Operation => Compose_From_Polar); function Compose_From_Polar is new Vector_Vector_Scalar_Elementwise_Operation (X_Scalar => Real'Base, Y_Scalar => Real'Base, Z_Scalar => Real'Base, Result_Scalar => Complex, X_Vector => Real_Vector, Y_Vector => Real_Vector, Result_Vector => Complex_Vector, Operation => Compose_From_Polar); function Compose_From_Polar is new Matrix_Matrix_Elementwise_Operation (Left_Scalar => Real'Base, Right_Scalar => Real'Base, Result_Scalar => Complex, Left_Matrix => Real_Matrix, Right_Matrix => Real_Matrix, Result_Matrix => Complex_Matrix, Operation => Compose_From_Polar); function Compose_From_Polar is new Matrix_Matrix_Scalar_Elementwise_Operation (X_Scalar => Real'Base, Y_Scalar => Real'Base, Z_Scalar => Real'Base, Result_Scalar => Complex, X_Matrix => Real_Matrix, Y_Matrix => Real_Matrix, Result_Matrix => Complex_Matrix, Operation => Compose_From_Polar); --------------- -- Conjugate -- --------------- function Conjugate is new Vector_Elementwise_Operation (X_Scalar => Complex, Result_Scalar => Complex, X_Vector => Complex_Vector, Result_Vector => Complex_Vector, Operation => Conjugate); function Conjugate is new Matrix_Elementwise_Operation (X_Scalar => Complex, Result_Scalar => Complex, X_Matrix => Complex_Matrix, Result_Matrix => Complex_Matrix, Operation => Conjugate); -------- -- Im -- -------- function Im is new Vector_Elementwise_Operation (X_Scalar => Complex, Result_Scalar => Real'Base, X_Vector => Complex_Vector, Result_Vector => Real_Vector, Operation => Im); function Im is new Matrix_Elementwise_Operation (X_Scalar => Complex, Result_Scalar => Real'Base, X_Matrix => Complex_Matrix, Result_Matrix => Real_Matrix, Operation => Im); ------------- -- Modulus -- ------------- function Modulus is new Vector_Elementwise_Operation (X_Scalar => Complex, Result_Scalar => Real'Base, X_Vector => Complex_Vector, Result_Vector => Real_Vector, Operation => Modulus); function Modulus is new Matrix_Elementwise_Operation (X_Scalar => Complex, Result_Scalar => Real'Base, X_Matrix => Complex_Matrix, Result_Matrix => Real_Matrix, Operation => Modulus); -------- -- Re -- -------- function Re is new Vector_Elementwise_Operation (X_Scalar => Complex, Result_Scalar => Real'Base, X_Vector => Complex_Vector, Result_Vector => Real_Vector, Operation => Re); function Re is new Matrix_Elementwise_Operation (X_Scalar => Complex, Result_Scalar => Real'Base, X_Matrix => Complex_Matrix, Result_Matrix => Real_Matrix, Operation => Re); ------------ -- Set_Im -- ------------ procedure Set_Im is new Update_Vector_With_Vector (X_Scalar => Complex, Y_Scalar => Real'Base, X_Vector => Complex_Vector, Y_Vector => Real_Vector, Update => Set_Im); procedure Set_Im is new Update_Matrix_With_Matrix (X_Scalar => Complex, Y_Scalar => Real'Base, X_Matrix => Complex_Matrix, Y_Matrix => Real_Matrix, Update => Set_Im); ------------ -- Set_Re -- ------------ procedure Set_Re is new Update_Vector_With_Vector (X_Scalar => Complex, Y_Scalar => Real'Base, X_Vector => Complex_Vector, Y_Vector => Real_Vector, Update => Set_Re); procedure Set_Re is new Update_Matrix_With_Matrix (X_Scalar => Complex, Y_Scalar => Real'Base, X_Matrix => Complex_Matrix, Y_Matrix => Real_Matrix, Update => Set_Re); ----------- -- Solve -- ----------- function Solve is new Matrix_Vector_Solution (Complex, (0.0, 0.0), Complex_Vector, Complex_Matrix); function Solve is new Matrix_Matrix_Solution (Complex, (0.0, 0.0), Complex_Matrix); ----------------- -- Unit_Matrix -- ----------------- function Unit_Matrix is new System.Generic_Array_Operations.Unit_Matrix (Scalar => Complex, Matrix => Complex_Matrix, Zero => (0.0, 0.0), One => (1.0, 0.0)); function Unit_Vector is new System.Generic_Array_Operations.Unit_Vector (Scalar => Complex, Vector => Complex_Vector, Zero => (0.0, 0.0), One => (1.0, 0.0)); end Instantiations; --------- -- "*" -- --------- function "*" (Left : Complex_Vector; Right : Complex_Vector) return Complex renames Instantiations."*"; function "*" (Left : Real_Vector; Right : Complex_Vector) return Complex renames Instantiations."*"; function "*" (Left : Complex_Vector; Right : Real_Vector) return Complex renames Instantiations."*"; function "*" (Left : Complex; Right : Complex_Vector) return Complex_Vector renames Instantiations."*"; function "*" (Left : Complex_Vector; Right : Complex) return Complex_Vector renames Instantiations."*"; function "*" (Left : Real'Base; Right : Complex_Vector) return Complex_Vector renames Instantiations."*"; function "*" (Left : Complex_Vector; Right : Real'Base) return Complex_Vector renames Instantiations."*"; function "*" (Left : Complex_Matrix; Right : Complex_Matrix) return Complex_Matrix renames Instantiations."*"; function "*" (Left : Complex_Vector; Right : Complex_Vector) return Complex_Matrix renames Instantiations."*"; function "*" (Left : Complex_Vector; Right : Complex_Matrix) return Complex_Vector renames Instantiations."*"; function "*" (Left : Complex_Matrix; Right : Complex_Vector) return Complex_Vector renames Instantiations."*"; function "*" (Left : Real_Matrix; Right : Complex_Matrix) return Complex_Matrix renames Instantiations."*"; function "*" (Left : Complex_Matrix; Right : Real_Matrix) return Complex_Matrix renames Instantiations."*"; function "*" (Left : Real_Vector; Right : Complex_Vector) return Complex_Matrix renames Instantiations."*"; function "*" (Left : Complex_Vector; Right : Real_Vector) return Complex_Matrix renames Instantiations."*"; function "*" (Left : Real_Vector; Right : Complex_Matrix) return Complex_Vector renames Instantiations."*"; function "*" (Left : Complex_Vector; Right : Real_Matrix) return Complex_Vector renames Instantiations."*"; function "*" (Left : Real_Matrix; Right : Complex_Vector) return Complex_Vector renames Instantiations."*"; function "*" (Left : Complex_Matrix; Right : Real_Vector) return Complex_Vector renames Instantiations."*"; function "*" (Left : Complex; Right : Complex_Matrix) return Complex_Matrix renames Instantiations."*"; function "*" (Left : Complex_Matrix; Right : Complex) return Complex_Matrix renames Instantiations."*"; function "*" (Left : Real'Base; Right : Complex_Matrix) return Complex_Matrix renames Instantiations."*"; function "*" (Left : Complex_Matrix; Right : Real'Base) return Complex_Matrix renames Instantiations."*"; --------- -- "+" -- --------- function "+" (Right : Complex_Vector) return Complex_Vector renames Instantiations."+"; function "+" (Left : Complex_Vector; Right : Complex_Vector) return Complex_Vector renames Instantiations."+"; function "+" (Left : Real_Vector; Right : Complex_Vector) return Complex_Vector renames Instantiations."+"; function "+" (Left : Complex_Vector; Right : Real_Vector) return Complex_Vector renames Instantiations."+"; function "+" (Right : Complex_Matrix) return Complex_Matrix renames Instantiations."+"; function "+" (Left : Complex_Matrix; Right : Complex_Matrix) return Complex_Matrix renames Instantiations."+"; function "+" (Left : Real_Matrix; Right : Complex_Matrix) return Complex_Matrix renames Instantiations."+"; function "+" (Left : Complex_Matrix; Right : Real_Matrix) return Complex_Matrix renames Instantiations."+"; --------- -- "-" -- --------- function "-" (Right : Complex_Vector) return Complex_Vector renames Instantiations."-"; function "-" (Left : Complex_Vector; Right : Complex_Vector) return Complex_Vector renames Instantiations."-"; function "-" (Left : Real_Vector; Right : Complex_Vector) return Complex_Vector renames Instantiations."-"; function "-" (Left : Complex_Vector; Right : Real_Vector) return Complex_Vector renames Instantiations."-"; function "-" (Right : Complex_Matrix) return Complex_Matrix renames Instantiations."-"; function "-" (Left : Complex_Matrix; Right : Complex_Matrix) return Complex_Matrix renames Instantiations."-"; function "-" (Left : Real_Matrix; Right : Complex_Matrix) return Complex_Matrix renames Instantiations."-"; function "-" (Left : Complex_Matrix; Right : Real_Matrix) return Complex_Matrix renames Instantiations."-"; --------- -- "/" -- --------- function "/" (Left : Complex_Vector; Right : Complex) return Complex_Vector renames Instantiations."/"; function "/" (Left : Complex_Vector; Right : Real'Base) return Complex_Vector renames Instantiations."/"; function "/" (Left : Complex_Matrix; Right : Complex) return Complex_Matrix renames Instantiations."/"; function "/" (Left : Complex_Matrix; Right : Real'Base) return Complex_Matrix renames Instantiations."/"; ----------- -- "abs" -- ----------- function "abs" (Right : Complex_Vector) return Real'Base renames Instantiations."abs"; -------------- -- Argument -- -------------- function Argument (X : Complex_Vector) return Real_Vector renames Instantiations.Argument; function Argument (X : Complex_Vector; Cycle : Real'Base) return Real_Vector renames Instantiations.Argument; function Argument (X : Complex_Matrix) return Real_Matrix renames Instantiations.Argument; function Argument (X : Complex_Matrix; Cycle : Real'Base) return Real_Matrix renames Instantiations.Argument; ---------------------------- -- Compose_From_Cartesian -- ---------------------------- function Compose_From_Cartesian (Re : Real_Vector) return Complex_Vector renames Instantiations.Compose_From_Cartesian; function Compose_From_Cartesian (Re : Real_Vector; Im : Real_Vector) return Complex_Vector renames Instantiations.Compose_From_Cartesian; function Compose_From_Cartesian (Re : Real_Matrix) return Complex_Matrix renames Instantiations.Compose_From_Cartesian; function Compose_From_Cartesian (Re : Real_Matrix; Im : Real_Matrix) return Complex_Matrix renames Instantiations.Compose_From_Cartesian; ------------------------ -- Compose_From_Polar -- ------------------------ function Compose_From_Polar (Modulus : Real_Vector; Argument : Real_Vector) return Complex_Vector renames Instantiations.Compose_From_Polar; function Compose_From_Polar (Modulus : Real_Vector; Argument : Real_Vector; Cycle : Real'Base) return Complex_Vector renames Instantiations.Compose_From_Polar; function Compose_From_Polar (Modulus : Real_Matrix; Argument : Real_Matrix) return Complex_Matrix renames Instantiations.Compose_From_Polar; function Compose_From_Polar (Modulus : Real_Matrix; Argument : Real_Matrix; Cycle : Real'Base) return Complex_Matrix renames Instantiations.Compose_From_Polar; --------------- -- Conjugate -- --------------- function Conjugate (X : Complex_Vector) return Complex_Vector renames Instantiations.Conjugate; function Conjugate (X : Complex_Matrix) return Complex_Matrix renames Instantiations.Conjugate; ----------------- -- Determinant -- ----------------- function Determinant (A : Complex_Matrix) return Complex is M : Complex_Matrix := A; B : Complex_Matrix (A'Range (1), 1 .. 0); R : Complex; begin Forward_Eliminate (M, B, R); return R; end Determinant; ----------------- -- Eigensystem -- ----------------- procedure Eigensystem (A : Complex_Matrix; Values : out Real_Vector; Vectors : out Complex_Matrix) is N : constant Natural := Length (A); -- For a Hermitian matrix C, we convert the eigenvalue problem to a -- real symmetric one: if C = A + i * B, then the (N, N) complex -- eigenvalue problem: -- (A + i * B) * (u + i * v) = Lambda * (u + i * v) -- -- is equivalent to the (2 * N, 2 * N) real eigenvalue problem: -- [ A, B ] [ u ] = Lambda * [ u ] -- [ -B, A ] [ v ] [ v ] -- -- Note that the (2 * N, 2 * N) matrix above is symmetric, as -- Transpose (A) = A and Transpose (B) = -B if C is Hermitian. -- We solve this eigensystem using the real-valued algorithms. The final -- result will have every eigenvalue twice, so in the sorted output we -- just pick every second value, with associated eigenvector u + i * v. M : Real_Matrix (1 .. 2 * N, 1 .. 2 * N); Vals : Real_Vector (1 .. 2 * N); Vecs : Real_Matrix (1 .. 2 * N, 1 .. 2 * N); begin for J in 1 .. N loop for K in 1 .. N loop declare C : constant Complex := (A (A'First (1) + (J - 1), A'First (2) + (K - 1))); begin M (J, K) := Re (C); M (J + N, K + N) := Re (C); M (J + N, K) := Im (C); M (J, K + N) := -Im (C); end; end loop; end loop; Eigensystem (M, Vals, Vecs); for J in 1 .. N loop declare Col : constant Integer := Values'First + (J - 1); begin Values (Col) := Vals (2 * J); for K in 1 .. N loop declare Row : constant Integer := Vectors'First (2) + (K - 1); begin Vectors (Row, Col) := (Vecs (J * 2, Col), Vecs (J * 2, Col + N)); end; end loop; end; end loop; end Eigensystem; ----------------- -- Eigenvalues -- ----------------- function Eigenvalues (A : Complex_Matrix) return Real_Vector is -- See Eigensystem for a description of the algorithm N : constant Natural := Length (A); R : Real_Vector (A'Range (1)); M : Real_Matrix (1 .. 2 * N, 1 .. 2 * N); Vals : Real_Vector (1 .. 2 * N); begin for J in 1 .. N loop for K in 1 .. N loop declare C : constant Complex := (A (A'First (1) + (J - 1), A'First (2) + (K - 1))); begin M (J, K) := Re (C); M (J + N, K + N) := Re (C); M (J + N, K) := Im (C); M (J, K + N) := -Im (C); end; end loop; end loop; Vals := Eigenvalues (M); for J in 1 .. N loop R (A'First (1) + (J - 1)) := Vals (2 * J); end loop; return R; end Eigenvalues; -------- -- Im -- -------- function Im (X : Complex_Vector) return Real_Vector renames Instantiations.Im; function Im (X : Complex_Matrix) return Real_Matrix renames Instantiations.Im; ------------- -- Inverse -- ------------- function Inverse (A : Complex_Matrix) return Complex_Matrix is (Solve (A, Unit_Matrix (Length (A)))); ------------- -- Modulus -- ------------- function Modulus (X : Complex_Vector) return Real_Vector renames Instantiations.Modulus; function Modulus (X : Complex_Matrix) return Real_Matrix renames Instantiations.Modulus; -------- -- Re -- -------- function Re (X : Complex_Vector) return Real_Vector renames Instantiations.Re; function Re (X : Complex_Matrix) return Real_Matrix renames Instantiations.Re; ------------ -- Set_Im -- ------------ procedure Set_Im (X : in out Complex_Matrix; Im : Real_Matrix) renames Instantiations.Set_Im; procedure Set_Im (X : in out Complex_Vector; Im : Real_Vector) renames Instantiations.Set_Im; ------------ -- Set_Re -- ------------ procedure Set_Re (X : in out Complex_Matrix; Re : Real_Matrix) renames Instantiations.Set_Re; procedure Set_Re (X : in out Complex_Vector; Re : Real_Vector) renames Instantiations.Set_Re; ----------- -- Solve -- ----------- function Solve (A : Complex_Matrix; X : Complex_Vector) return Complex_Vector renames Instantiations.Solve; function Solve (A : Complex_Matrix; X : Complex_Matrix) return Complex_Matrix renames Instantiations.Solve; --------------- -- Transpose -- --------------- function Transpose (X : Complex_Matrix) return Complex_Matrix is R : Complex_Matrix (X'Range (2), X'Range (1)); begin Transpose (X, R); return R; end Transpose; ----------------- -- Unit_Matrix -- ----------------- function Unit_Matrix (Order : Positive; First_1 : Integer := 1; First_2 : Integer := 1) return Complex_Matrix renames Instantiations.Unit_Matrix; ----------------- -- Unit_Vector -- ----------------- function Unit_Vector (Index : Integer; Order : Positive; First : Integer := 1) return Complex_Vector renames Instantiations.Unit_Vector; end Ada.Numerics.Generic_Complex_Arrays;
AdaCore/Ada_Drivers_Library
Ada
3,676
ads
------------------------------------------------------------------------------ -- -- -- Copyright (C) 2021, AdaCore -- -- -- -- Redistribution and use in source and binary forms, with or without -- -- modification, are permitted provided that the following conditions are -- -- met: -- -- 1. Redistributions of source code must retain the above copyright -- -- notice, this list of conditions and the following disclaimer. -- -- 2. Redistributions in binary form must reproduce the above copyright -- -- notice, this list of conditions and the following disclaimer in -- -- the documentation and/or other materials provided with the -- -- distribution. -- -- 3. Neither the name of the copyright holder nor the names of its -- -- contributors may be used to endorse or promote products derived -- -- from this software without specific prior written permission. -- -- -- -- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -- -- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -- -- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -- -- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -- -- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -- -- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -- -- LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -- -- DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -- -- THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -- -- (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -- -- OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- -- -- ------------------------------------------------------------------------------ -- See LPS25H Datasheet DocID023722 Rev 6 with HAL.I2C; with HAL.Time; package LPS25H.I2C is type LPS25H_Barometric_Sensor_I2C (Port : not null HAL.I2C.Any_I2C_Port; Slave_Address_Odd : Boolean; Timing : not null HAL.Time.Any_Delays) is new LPS25H_Barometric_Sensor with private; -- See Datasheet section 5.2.1 for slave address adjustment. The -- address is given as 2#101_1101# if Slave_Address_Odd is true -- (SDO is high), 2#101_1100# if false. Using the Ada Drivers -- Library convention, where the 7 bits of the address used on the -- wire are in bits 1 .. 7, this is 16#BA#, 16#B8# respectively. overriding procedure Initialize (This : in out LPS25H_Barometric_Sensor_I2C); overriding procedure Get_Data (This : in out LPS25H_Barometric_Sensor_I2C; Press : out Pressure; Temp : out Temperature; Asl : out Altitude; Status : out Boolean); private type LPS25H_Barometric_Sensor_I2C (Port : not null HAL.I2C.Any_I2C_Port; Slave_Address_Odd : Boolean; Timing : not null HAL.Time.Any_Delays) is new LPS25H_Barometric_Sensor with record I2C_Address : HAL.I2C.I2C_Address; end record; end LPS25H.I2C;
LionelDraghi/smk
Ada
6,363
adb
-- ----------------------------------------------------------------------------- -- smk, the smart make (http://lionel.draghi.free.fr/smk/) -- © 2018, 2019 Lionel Draghi <[email protected]> -- SPDX-License-Identifier: APSL-2.0 -- ----------------------------------------------------------------------------- -- Licensed under the Apache License, Version 2.0 (the "License"); -- you may not use this file except in compliance with the License. -- You may obtain a copy of the License at -- http://www.apache.org/licenses/LICENSE-2.0 -- Unless required by applicable law or agreed to in writing, software -- distributed under the License is distributed on an "AS IS" BASIS, -- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -- See the License for the specific language governing permissions and -- limitations under the License. -- ----------------------------------------------------------------------------- with Ada.Directories; with Ada.Strings.Unbounded; use Ada.Strings.Unbounded; package body Smk.Settings is -- -------------------------------------------------------------------------- -- Most of the variable here are "write once, read more". -- To avoid the cost of Unbounded strings manipulation, -- they are implemented as access to String Smkfl_Name : access String := null; Runfl_Name : access String := null; Current_Section : access String := null; Current_Target : access String := null; Cmd_Line : Unbounded_String := Null_Unbounded_String; WD : constant access String := new String'(Ada.Directories.Current_Directory); Ignored : constant Filter_List := (new String'("/sys/*"), new String'("/proc/*"), new String'("/dev/*"), new String'("/tmp/*"), new String'("/etc/ld.so.cache")); System_Dir : constant Filter_List := (new String'("/usr/*"), new String'("/lib/*"), new String'("/etc/*"), new String'("/opt/*")); -- -------------------------------------------------------------------------- function Is_File_In (File, Dir : String) return Boolean is Compared_Length : constant Natural := (if Dir (Dir'Last) = '*' then Dir'Length - 1 else Dir'Length); -- return True if File is in Dir, supposing that both are full name. -- e.g. (Dir => /usr/*, File => /usr/lib/locale) return True -- e.g. (Dir => /usr/*, File => locale) return False begin return (File'Length >= Compared_Length and then File (File'First .. File'First - 1 + Compared_Length) = Dir (Dir'First .. Dir'First - 1 + Compared_Length)); end Is_File_In; -- -------------------------------------------------------------------------- function In_Ignore_List (File_Name : in String) return Boolean is begin for D of Ignored loop if Is_File_In (File => File_Name, Dir => D.all) then return True; end if; end loop; if File_Name = Settings.Smkfile_Name or else File_Name = Settings.Runfile_Name then return True; end if; return False; end In_Ignore_List; -- -------------------------------------------------------------------------- function Is_System (File_Name : in String) return Boolean is (for some D of System_Dir => Is_File_In (File => File_Name, Dir => D.all)); -- -------------------------------------------------------------------------- function System_Files return Filter_List is (System_Dir); function Ignore_List return Filter_List is (Ignored); -- -------------------------------------------------------------------------- function Initial_Directory return String is (WD.all); -- -------------------------------------------------------------------------- procedure Set_Smkfile_Name (Name : in String) is begin Smkfl_Name := new String'(Name); Runfl_Name := new String'(To_Runfile_Name (Name)); end Set_Smkfile_Name; function Smkfile_Name return String is (if Smkfl_Name = null then "" else Smkfl_Name.all); function Is_Smkfile_Name_Set return Boolean is (Smkfl_Name /= null); function Run_Dir_Name return String is (Ada.Directories.Containing_Directory (Smkfile_Name)); function Strace_Outfile_Name return String is (if Is_Smkfile_Name_Set then Strace_Outfile_Prefix & Ada.Directories.Simple_Name (Smkfile_Name) & Strace_Outfile_Suffix else ""); -- -------------------------------------------------------------------------- procedure Set_Runfile_Name (Name : in String) is begin Runfl_Name := new String'(Name); end Set_Runfile_Name; function Runfile_Name return String is (if Runfl_Name = null then "" else Runfl_Name.all); function To_Runfile_Name (Smkfile_Name : in String) return String is (Smk_File_Prefix & Ada.Directories.Simple_Name (Smkfile_Name)); -- -------------------------------------------------------------------------- procedure Set_Section_Name (Name : in String) is begin Current_Section := new String'(Name); end Set_Section_Name; function Section_Name return String is (if Current_Section = null then "" else Current_Section.all); -- -------------------------------------------------------------------------- procedure Add_To_Command_Line (Text : in String) is begin if Cmd_Line = "" then Cmd_Line := To_Unbounded_String (Text); else Cmd_Line := Cmd_Line & " " & Text; end if; end Add_To_Command_Line; function Command_Line return String is (To_String (Cmd_Line)); -- -------------------------------------------------------------------------- procedure Set_Target_Name (Target : in String) is begin Current_Target := new String'(Target); end Set_Target_Name; function Target_Name return String is (if Current_Target = null then "" else Current_Target.all); end Smk.Settings;
jscparker/math_packages
Ada
8,079
adb
-- Test Eigendecomposition of Real valued square matrices. with Test_Matrices; with QR_Symmetric_Eigen; with Text_IO; use Text_IO; procedure qr_symmetric_eigen_tst_1 is type Real is digits 15; --type Real is digits 18; --Matrix_Size : constant := 7000; --Matrix_Size : constant := 1303; Matrix_Size : constant := 137; --Matrix_Size : constant := 57; Padding : constant := 1; subtype Index is Integer range 1 .. Matrix_Size + Padding; -- the test matrix is square-shaped matrix on: Index x Index. -- Can't change: Starting_Col : constant Index := Index'First; Final_Col : constant Index := Index'Last - Padding; subtype Submatrix_Range is Index range Starting_Col .. Final_Col; type Matrix is array(Index, Index) of Real; pragma Convention (fortran, Matrix); package QR_Method is new QR_Symmetric_Eigen (Real, Index, Matrix); use QR_Method; A : Matrix; Eigvals : Col_Vector; package Make_Square_Matrix is new Test_Matrices (Real, Index, Matrix); use Make_Square_Matrix; package rio is new Float_IO(Real); use rio; --subtype Real_e is Real; -- general case, works fine type Real_e is digits 18; -- 18 ok on intel type Col_Vector_e is array (Index) of Real_e; Min_Exp : constant Integer := Real'Machine_Emin - Real'Machine_Emin/4; Min_Allowed_Real : constant Real := 2.0**Min_Exp; ------------- -- Product -- ------------- function Product (A : in Matrix; Vector : in Col_Vector_e; Starting_Col : in Index; Final_Col : in Index) return Col_Vector_e is Result : Col_Vector_e := (others => 0.0); Sum : Real_e; begin for Row in Starting_Col .. Final_Col loop Sum := +0.0; for c in Starting_Col .. Final_Col loop Sum := Sum + Real_e (A(Row, c)) * Vector(c); end loop; Result (Row) := Sum; end loop; return Result; end Product; ---------------------------- -- Error_in_Decomposition -- ---------------------------- -- rough estimate, relative err. -- most of this only works for A'Range, not sub range. procedure Error_in_Decomposition (A : in Matrix; W_r : in Col_Vector; Q : in Matrix; Starting_Col : in Index; Final_Col : in Index; Max_Err : out Real; Max_id : out Index) is Err, Max_Eig, Vec_Norm, tst : Real; A_times_Eig_r : Col_Vector_e := (others => 0.0); Eigvec_r : Col_Vector_e := (others => 0.0); Err_Vec_r : Col_Vector := (others => 0.0); W_times_EigVec_r : Col_Vector_e := (others => 0.0); begin Max_id := Submatrix_Range'First; Max_Err := 0.0; Max_Eig := 0.0; for Col_id in Submatrix_Range loop tst := Abs (W_r(Col_id)); if tst > Max_Eig then Max_Eig := tst; end if; end loop; for Col_id in Submatrix_Range loop for j in Submatrix_Range loop Eigvec_r(j) := Real_e (Q(j, Col_id)); end loop; A_times_Eig_r := Product (A, Eigvec_r, Starting_Col, Final_Col); for j in Submatrix_Range loop W_times_EigVec_r(j) := Real_e(W_r(Col_id)) * Eigvec_r(j); Err_Vec_r(j) := Real (A_times_Eig_r(j) - W_times_EigVec_r(j)); end loop; -- The vectors Eigvec are already normalized Vec_Norm := Norm (Err_Vec_r, Starting_Col, Final_Col); if Max_Eig > 2.0**(-Real'Machine_Emax) * Vec_Norm then Err := Vec_Norm / (Max_Eig + Min_Allowed_Real); else Err := 0.0; end if; -- ||A*v - lambda*v|| / ||lambda_max|| over all normalized v if Err > Max_Err then Max_Err := Err; Max_id := Col_id; end if; end loop; end Error_in_Decomposition; ----------- -- Pause -- ----------- procedure Pause (s0,s1,s2,s3,s4,s5,s6,s7 : string := "") is Continue : Character := ' '; begin new_line; if S0 /= "" then put_line (S0); end if; if S1 /= "" then put_line (S1); end if; if S2 /= "" then put_line (S2); end if; if S3 /= "" then put_line (S3); end if; if S4 /= "" then put_line (S4); end if; if S5 /= "" then put_line (S5); end if; if S6 /= "" then put_line (S6); end if; if S7 /= "" then put_line (S7); end if; new_line; begin put ("Type a character to continue: "); get_immediate (Continue); exception when others => null; end; end pause; Q : Matrix; A_true : Matrix; x, Max_Error : Real := 0.0; Max_Id : Index; begin Pause( "Test1: Eigen-decomposition of matrix A.", "Error is estimated by measuring Max value of", " ", " |A*v - lambda*v| / |max_eigenvalue_of_A|", " ", "over all normalized eigenvectors v. If 15 digit Reals are used, then", "if all goes well, expect the error to be a few parts per 10**15." ); new_line(2); put ("Testing QR_Symmetric_Eigen on the following"); put (Integer'Image (Matrix_Size)); put (" x"); put (Integer'Image (Matrix_Size)); put (" matrices:"); new_line(2); for Chosen_Matrix in Matrix_Id loop --for Chosen_Matrix in Ding_Dong .. Ding_Dong loop --for Chosen_Matrix in All_Ones .. All_Ones loop --for Chosen_Matrix in Lower_Ones .. Lower_Ones loop --for Chosen_Matrix in vandermonde .. vandermonde loop --for Chosen_Matrix in Companion_2 .. Companion_2 loop --for Chosen_Matrix in hilbert .. hilbert loop --for Chosen_Matrix in random_32_bit .. random_32_bit loop --for Chosen_Matrix in Pas_Fib .. Pascal loop Init_Matrix (A, Chosen_Matrix, Submatrix_Range'First, Submatrix_Range'Last); -- Want to reuse (unchanged) the error calculation used for Peters_Eigen. -- So now we have 2 types of matrices: type Matrix, and type Real_Matrix. -- for c in Submatrix_Range'First .. Submatrix_Range'Last-1 loop -- for r in c+1 .. Submatrix_Range'Last loop -- --A(r, c) := A(c, r); -- A(c, r) := A(r, c); -- end loop; -- end loop; -- MUST be symmetric for c in Submatrix_Range loop for r in Submatrix_Range loop A_true(r, c) := 0.5 * (A(c, r) + A(r, c)); end loop; end loop; A := A_true; --for i in 1..100 loop QR_Method.Eigen_Decompose (A => A, Q => Q, Eigenvals => Eigvals, Start_Col => Starting_Col, Final_Col => Final_Col, Eigenvectors_Desired => True); --A := A_true; --end loop; x := x + Q(2,2) + A(2,2); if true then Error_in_Decomposition (A_true, Eigvals, Q, Starting_Col, Final_Col, Max_Error, Max_id); put ("Error in decomposition ~"); put (Real'Image(Max_Error)); put (" for matrix "); put (Matrix_id'Image(Chosen_Matrix)); new_line; end if; if false then put (0.0); put (A(Starting_Col, Starting_Col)); new_line(1); for r in Submatrix_Range'First .. Submatrix_Range'Last-1 loop put (A(r+1, r)); put (A(r+1, r+1)); new_line(1); end loop; end if; if false then New_Line; for I in Submatrix_Range loop put (Eigvals(I)); New_Line(1); end loop; end if; if true then declare Sum : Real_e := +0.0; --Product : Real := +1.0; begin for I in Submatrix_Range loop Sum := Sum + Real_e (Eigvals(I)); --Product := Product * Eigvals(I); end loop; put ("Eigval sum:"); put (Real (Sum)); New_Line; --put (Product); end; end if; end loop; put (x); end qr_symmetric_eigen_tst_1;
mapcode-foundation/mapcode-ada
Ada
69,883
adb
-- ----------------------------------------------------------------------------- -- Copyright (C) 2003-2019 Stichting Mapcode Foundation (http://www.mapcode.com) -- -- 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.Characters.Handling; with Mapcode_Utils.Str_Tools, Mapcode_Utils.Bits; use Mapcode_Utils; with Mapcodes.Languages; with Ndata; package body Mapcodes is subtype Lint is Long_Long_Integer; -- All functions returning a Integer return a natural or Error Error : constant Integer := -1; -- All functions returning a string may return Undefined, on error Undefined : constant String := ""; subtype Country_Range is Positive range Countries.Territories_Def'Range; function Iso3166Alpha_Of (Index : Natural) return String is begin if Index + 1 <= Country_Range'Last then return Countries.Territories_Def(Index + 1).Code.Image; else return Undefined; end if; end Iso3166Alpha_Of; Aliases : constant String := "2UK=2UT,2CG=2CT,1GU=GUM,1UM=UMI,1VI=VIR,1AS=ASM,1MP=MNP,4CX=CXR,4CC=CCK," & "4NF=NFK,4HM=HMD,COL=5CL,5ME=5MX,MEX=5MX,5AG=AGU,5BC=BCN,5BS=BCS,5CM=CAM," & "5CS=CHP,5CH=CHH,5CO=COA,5DF=DIF,5DG=DUR,5GT=GUA,5GR=GRO,5HG=HID,5JA=JAL," & "5MI=MIC,5MO=MOR,5NA=NAY,5NL=NLE,5OA=OAX,5PB=PUE,5QE=QUE,5QR=ROO,5SL=SLP," & "5SI=SIN,5SO=SON,5TB=TAB,5TL=TLA,5VE=VER,5YU=YUC,5ZA=ZAC,811=8BJ,812=8TJ," & "813=8HE,814=8SX,815=8NM,821=8LN,822=8JL,823=8HL,831=8SH,832=8JS,833=8ZJ," & "834=8AH,835=8FJ,836=8JX,837=8SD,841=8HA,842=8HB,843=8HN,844=8GD,845=8GX," & "846=8HI,850=8CQ,851=8SC,852=8GZ,853=8YN,854=8XZ,861=8SN,862=8GS,863=8QH," & "864=8NX,865=8XJ,871=TWN,891=HKG,892=MAC,8TW=TWN,8HK=HKG,8MC=MAC,BEL=7BE," & "KIR=7KI,PRI=7PO,CHE=7CH,KHM=7KM,PER=7PM,TAM=7TT,0US=USA,0AU=AUS,0RU=RUS," & "0CN=CHN,TAA=SHN,ASC=SHN,DGA=IOT,WAK=MHL,JTN=UMI,MID=1HI,1PR=PRI,5TM=TAM," & "TAM=TAM,2OD=2OR,"; Usa_From : constant := 343; Usa_Upto : constant := 393; Ccode_Usa : constant := 410; Ind_From : constant := 271; Ind_Upto : constant := 306; Ccode_Ind : constant := 407; Can_From : constant := 394; Can_Upto : constant := 406; Ccode_Can : constant := 495; Aus_From : constant := 307; Aus_Upto : constant := 315; Ccode_Aus : constant := 408; Mex_From : constant := 233; Mex_Upto : constant := 264; Ccode_Mex : constant := 411; Bra_From : constant := 316; Bra_Upto : constant := 342; Ccode_Bra : constant := 409; Chn_From : constant := 497; Chn_Upto : constant := 527; Ccode_Chn : constant := 528; Rus_From : constant := 412; Rus_Upto : constant := 494; Ccode_Rus : constant := 496; Ccode_Earth : constant := 532; -- Parent territories Parent_Length : constant := 8; subtype String3 is String (1 .. 3); Parents3 : constant array (1 .. Parent_Length) of String3 := ("USA", "IND", "CAN", "AUS", "MEX", "BRA", "RUS", "CHN"); subtype String2 is String (1 .. 2); Parents2 : constant array (1 .. Parent_Length) of String2 := ("US", "IN", "CA", "AU", "MX", "BR", "RU", "CN"); -- Returns 2-letter parent country abbreviation (disam in range 1..8) function Parent_Name2 (Disam : Positive) return String is (Parents2 (Disam)); -- Given a parent country abbreviation, return disam (in range 1-8) or -- Error function Parent_Letter (Territory_Alpha_Code : String) return Integer is Srch : constant String := Str_Tools.Upper_Str (Territory_Alpha_Code); begin if Srch'Length = 2 then for I in Parents2'Range loop if Srch = Parents2(I) then return I; end if; end loop; elsif Srch'Length = 3 then for I in Parents3'Range loop if Srch = Parents3(I) then return I; end if; end loop; end if; return Error; end Parent_Letter; function Image (I : Integer) return String is Str : constant String := I'Img; begin return (if Str(Str'First) /= ' ' then Str else Str (Integer'Succ(Str'First) .. Str'Last)); end Image; -- Returns alias of ISO abbreviation (if any), or empty function Alias2Iso (Territory_Alpha_Code : String) return String is -- Look for "DigitCrit=" function Match (Crit, Within : String) return Natural is Occ : Positive := 1; I : Natural; begin loop I := Str_Tools.Locate (Within, Crit, Occurence => Occ); exit when I = 0; if I > 1 and then Within(I - 1) >= '0' and then Within(I - 1) <= '9' then return I - 1; end if; Occ := Occ + 1; end loop; return 0; end Match; Index : Natural; begin Index := (if Territory_Alpha_Code'Length = 2 then Match (Territory_Alpha_Code & "=", Aliases) else Str_Tools.Locate (Aliases, Territory_Alpha_Code & "=")); if Index /= 0 then return Aliases (Index + 4 .. Index + 6); else return Undefined; end if; end Alias2Iso; -- Given ISO code, return Territory_Number or Error function Find_Iso (Territory_Alpha_Code : String) return Integer is begin for I in Country_Range loop if Countries.Territories_Def(I).Code.Image = Territory_Alpha_Code then return I - 1; end if; end loop; return Error; end Find_Iso; -- Given ISO code, return territoryNumber or Error function Iso2Ccode (Alpha_Code : String; Context : in String) return Integer is function Is_Digit (Char : Character) return Boolean is (Char >= '0' and then Char <= '9'); function Is_Digits (Str : String) return Boolean is begin for I in Str'Range loop if not Is_Digit (Str(I)) then return False; end if; end loop; return Str /= ""; end Is_Digits; N, Sep : Natural; P, Tmpp : Integer; Result, Index : Integer; Isoa : As_U.Asu_Us; Code2Search, Context2Search : As_U.Asu_Us; Hyphenated : As_U.Asu_Us; use all type As_U.Asu_Us; begin if Alpha_Code = Undefined then return Error; end if; P := Parent_Letter (Context); if P = Error and then Context /= "" and then Context /= "AAA" then return Error; end if; Sep := Str_Tools.Locate (Alpha_Code, "-"); Code2Search := Tus (Str_Tools.Upper_Str (Alpha_Code)); if P /= Error and then Sep /= 0 then -- Cannot provide a context together with territory-subdivision return Error; end if; -- Optims: direct number or code if P = Error and then Sep = 0 then -- Direct territory number if Is_Digits (Code2Search.Image) then N := Natural'Value (Code2Search.Image); if N <= Ccode_Earth then return N; end if; end if; -- Check if a simple territory if Code2Search.Length = 3 then Index := Find_Iso (Code2Search.Image); if Index /= Error then return Index; end if; end if; -- Find unique occurence of subdivision in ANY context if Code2Search.Length >= 2 then Hyphenated := Tus ("-") & Code2Search; Result := Error; for I in Country_Range loop Index := Str_Tools.Locate (Countries.Territories_Def(I).Code.Image, Hyphenated.Image); if Index > 0 and then Index = Countries.Territories_Def(I).Code.Length - Hyphenated.Length + 1 then -- iso3166alpha ends by Hyphenated if Result /= Error then -- Not unique return Error; else Result := I - 1; end if; end if; end loop; if Result /= Error then return Result; end if; end if; end if; -- Set Context and Code for search if Context /= "" then -- Context provided Context2Search.Set (Context); elsif Sep /= 0 then -- Code contains a prefix Context2Search := Code2Search.Uslice (1, Sep - 1); Code2Search.Delete (1, Sep); P := Parent_Letter (Context2Search.Image); if P = Error and then Context2Search.Image /= "AAA" then return Error; end if; end if; -- Sanity check if Code2Search.Length /= 2 and then Code2Search.Length /= 3 then return Error; end if; -- Optim: search this prefix and code if P /= Error then Index := Find_Iso (Parent_Name2 (P) & "-" & Code2Search.Image); if Index /= Error then return Index; end if; end if; -- Resolve alias if P /= Error then -- Alias for a subdivision with context Isoa := Tus (Alias2Iso (Image (P) & Code2Search.Image)); end if; if Isoa.Is_Null and then Code2Search.Length = 3 then -- Alias for a territory or subdivision without context Isoa := Tus (Alias2Iso (Code2Search.Image)); end if; if Isoa.Is_Null then Index := Error; else if Is_Digit (Isoa.Element (1)) then -- Alias is a subdivision Code2Search := Isoa.Uslice (2, Isoa.Length); Tmpp := Integer'Value (Isoa.Slice (1, 1)); if P /= Error and then Tmpp /= P then -- Cannot change territory through aliasing return Error; end if; P := Tmpp; Index := Find_Iso (Parent_Name2 (P) & "-" & Code2Search.Image); else -- Alias is a subdivision or territory Code2Search := Isoa; -- Search for a territory Index := Find_Iso (Code2Search.Image); if Index = Error and then P /= Error then -- Search for a subdivision Index := Find_Iso (Parent_Name2 (P) & "-" & Code2Search.Image); end if; end if; end if; -- Return valid result if Index /= Error then return Index; end if; if P /= Error then -- With a context, the search shall have succeded return Error; end if; -- All else failed, try non-disambiguated alphacode Isoa := Tus (Alias2Iso (Code2Search.Image)); if not Isoa.Is_Null then if Is_Digit (Isoa.Element (1)) then -- Starts with digit Code2Search := Tus (Parent_Name2 (Natural'Value (Isoa.Slice (1, 1))) & "-" & Isoa.Slice (2, Isoa.Length)); else Code2Search := Isoa; end if; return Iso2Ccode (Code2Search.Image, Context); end if; return Error; end Iso2Ccode; -- Image of a territory (index starting at 0 for VAT) function Get_Territory_Number (Territory : Territories) return String is (Image (Integer (Territory))); -- Given an alphacode (such As_US-AL), returns the territory number -- or Error. -- A context_Territory number helps to interpret ambiguous (abbreviated) -- AlphaCodes, such as "AL" function Get_Territory (Territory_Code : String; Context : in String := "") return Territories is Num : Integer; begin Num := Iso2Ccode (Territory_Code, Context); if Num = Error then raise Unknown_Territory; end if; return Territories (Num); end Get_Territory; -- Return full name of territory function Get_Territory_Fullname (Territory: in Territories) return String is Name : As_U.Asu_Us; Index : Natural; begin Name := Countries.Territories_Def(Positive (Territory) + 1).Name; Index := Str_Tools.Locate (Name.Image, " ("); if Index > 0 then return Name.Slice (1, Index - 1); else return Name.Image; end if; end Get_Territory_Fullname; -- Return the AlphaCode (usually an ISO 3166 code) of a territory -- Format: Local (often ambiguous), International (full and unambiguous, -- DEFAULT), or Shortest function Get_Territory_Alpha_Code ( Territory : Territories; Format : Territory_Formats := International) return String is Full : constant String := Iso3166Alpha_Of (Natural (Territory)); Iso : As_U.Asu_Us; Hyphen, Index : Natural; Short : As_U.Asu_Us; Count : Natural; begin Hyphen := Str_Tools.Locate (Full, "-"); if Format = International or else Hyphen = 0 then -- Format full or no hyphen return Full; end if; Short := As_U.Tus (Full(Hyphen + 1 .. Full'Last)); if Format = Local then -- Format local return Short.Image; end if; -- Shortest possible -- Keep parent if it has aliases or if territory occurs multiple times Count := 0; if Str_Tools.Locate (Aliases, Short.Image & "=") > 0 then Count := 2; else for I in Country_Range loop Iso := As_U.Tus (Iso3166Alpha_Of (I)); Index := Str_Tools.Locate (Iso.Image, "-" & Short.Image); if Index > 0 and then Index + Short.Length = Iso.Length then Count := Count + 1; exit when Count = 2; end if; end loop; end if; return (if Count = 1 then Short.Image else Full); end Get_Territory_Alpha_Code; -- Return parent country of subdivision or error (if territory is not a -- subdivision) function Get_Parent (Territory : Territories) return Integer is begin return (case Territory is when Usa_From .. Usa_Upto => Ccode_Usa, when Ind_From .. Ind_Upto => Ccode_Ind, when Can_From .. Can_Upto => Ccode_Can, when Aus_From .. Aus_Upto => Ccode_Aus, when Mex_From .. Mex_Upto => Ccode_Mex, when Bra_From .. Bra_Upto => Ccode_Bra, when Rus_From .. Rus_Upto => Ccode_Rus, when Chn_From .. Chn_Upto => Ccode_Chn, when others => Error); end Get_Parent; function Get_Parent_Of (Territory : Territories) return Territories is Code : constant Integer := Get_Parent (Territory); begin if Code = Error then raise Not_A_Subdivision; else return Territories (Code); end if; end Get_Parent_Of; -- Return True if Territory is a state function Is_Subdivision (Territory : Territories) return Boolean is (Get_Parent (Territory) /= Error); -- Return True if Territory is a country that has states function Has_Subdivision (Territory : Territories) return Boolean is Code : constant String := Get_Territory_Alpha_Code (Territory); begin for Parent of Parents3 loop if Code = Parent then return True; end if; end loop; return False; end Has_Subdivision; -- Given a subdivision, return the array of subdivisions with same name -- with various parents function Get_Subdivisions_With (Subdivision : String) return Territories_Array is Upper_Subd : constant String := Str_Tools.Upper_Str (Subdivision); Ccodes : array (1 .. Parent_Length) of Integer; Nb_Ok : Natural := 0; begin -- Count and store valid combinations of a Parent and this subdivision for I in Parents2'Range loop Ccodes(I) := Iso2Ccode (Upper_Subd, Parents2(I)); if Ccodes(I) /= Error then Nb_Ok := Nb_Ok + 1; end if; end loop; -- Return array of valid combinations return Result : Territories_Array (1 .. Nb_Ok) do Nb_Ok := 0; for Ccode of Ccodes loop if Ccode /= Error then Nb_Ok := Nb_Ok + 1; Result(Nb_Ok) := Territories (Ccode); end if; end loop; end return; end Get_Subdivisions_With; -- Low-level routines for data access type Min_Max_Rec is record Minx, Miny, Maxx, Maxy : Lint; end record; function Data_First_Record (Territory_Number : Natural) return Integer is begin return Ndata.Data_Start(Territory_Number + 1); exception when others => return Error; end Data_First_Record; function Data_Last_Record (Territory_Number : Natural) return Integer is begin return Ndata.Data_Start(Territory_Number + 2) - 1; exception when others => return Error; end Data_Last_Record; function Min_Max_Setup (I : Natural) return Min_Max_Rec is Short_Maxy : constant array (Positive range <>) of Natural := (0, 122309, 27539, 27449, 149759, 2681190, 60119, 62099, 491040, 86489); D : Natural; begin D := Ndata.Data_Maxy(I + 1); if D < Short_Maxy'Last then D := Short_Maxy(D + 1); end if; return (Minx => Lint (Ndata.Data_Minx(I + 1)), Miny => Lint (Ndata.Data_Miny(I + 1)), Maxx => Lint (Ndata.Data_Minx(I + 1) + Ndata.Data_Maxx(I + 1)), Maxy => Lint (Ndata.Data_Miny(I + 1) + D)); end Min_Max_Setup; Xdivider19 : constant array (Positive range <>) of Natural := ( 360, 360, 360, 360, 360, 360, 361, 361, 361, 361, -- 5.2429 degrees 362, 362, 362, 363, 363, 363, 364, 364, 365, 366, -- 10.4858 degrees 366, 367, 367, 368, 369, 370, 370, 371, 372, 373, -- 15.7286 degrees 374, 375, 376, 377, 378, 379, 380, 382, 383, 384, -- 20.9715 degrees 386, 387, 388, 390, 391, 393, 394, 396, 398, 399, -- 26.2144 degrees 401, 403, 405, 407, 409, 411, 413, 415, 417, 420, -- 31.4573 degrees 422, 424, 427, 429, 432, 435, 437, 440, 443, 446, -- 36.7002 degrees 449, 452, 455, 459, 462, 465, 469, 473, 476, 480, -- 41.9430 degrees 484, 488, 492, 496, 501, 505, 510, 515, 520, 525, -- 47.1859 degrees 530, 535, 540, 546, 552, 558, 564, 570, 577, 583, -- 52.4288 degrees 590, 598, 605, 612, 620, 628, 637, 645, 654, 664, -- 57.6717 degrees 673, 683, 693, 704, 715, 726, 738, 751, 763, 777, -- 62.9146 degrees 791, 805, 820, 836, 852, 869, 887, 906, 925, 946, -- 68.1574 degrees -- 73.4003 degrees 968, 990, 1014, 1039, 1066, 1094, 1123, 1154, 1187, 1223, -- 78.6432 degrees 1260, 1300, 1343, 1389, 1438, 1490, 1547, 1609, 1676, 1749, -- 83.8861 degrees 1828, 1916, 2012, 2118, 2237, 2370, 2521, 2691, 2887, 3114, -- 89.1290 degrees 3380, 3696, 4077, 4547, 5139, 5910, 6952, 8443, 10747, 14784, 23681, 59485); Nc : constant array (Positive range <>) of Natural := ( 1, 31, 961, 29791, 923521, 28629151, 887503681); X_Side : constant array (Positive range <>) of Natural := ( 0, 5, 31, 168, 961, 168 * 31, 29791, 165869, 923521, 5141947, 28629151); Y_Side : constant array (Positive range <>) of Natural := ( 0, 6, 31, 176, 961, 176 * 31, 29791, 165869, 923521, 5141947, 28629151); Decode_Char : constant array (Positive range <>) of Integer := ( -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, -1, -1, -1, -1, -1, -1, -1, -2, 10, 11, 12, -3, 13, 14, 15, 1, 16, 17, 18, 19, 20, 0, 21, 22, 23, 24, 25, -4, 26, 27, 28, 29, 30, -1, -1, -1, -1, -1, -1, -2, 10, 11, 12, -3, 13, 14, 15, 1, 16, 17, 18, 19, 20, 0, 21, 22, 23, 24, 25, -4, 26, 27, 28, 29, 30, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1); Encode_Char : constant array (Positive range <>) of Character := ( '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'B', 'C', 'D', 'F', 'G', 'H', 'J', 'K', 'L', 'M', 'N', 'P', 'Q', 'R', 'S', 'T', 'V', 'W', 'X', 'Y', 'Z', 'A', 'E', 'U'); function Decode_A_Char (C : Natural) return Integer is (Decode_Char(C + 1)); function Encode_A_Char (C : Natural) return Character is (Encode_Char(C + 1)); -- Given a minimum and maximum latitude, returns a relative stretch factor -- (in 360th) for the longitud function Xdivider4 (Miny, Maxy : Lint) return Natural is use Bits; begin if Miny >= 0 then return Xdivider19(Integer (Shr (Miny, 19)) + 1); end if; if Maxy >= 0 then return Xdivider19(1); end if; return Xdivider19(Integer (Shr (-Maxy, 19)) + 1); end Xdivider4; type Coord_Rec is record X, Y : Lint; end record; type Frac_Rec is record Fraclon, Fraclat : Integer; Coord32 : Coord_Rec; end record; -- Return True if x in range (all values in millionths) function Is_In_Range_X (X, Minx, Maxx : Lint) return Boolean is Lx : Lint; begin if Minx <= X and then X < Maxx then return True; end if; Lx := X; if Lx < Minx then Lx := Lx + 360000000; else Lx := Lx - 360000000; end if; return Minx <= Lx and then Lx < Maxx; end Is_In_Range_X; -- Return True if coordinate inside rectangle (all values in millionths) function Fits_Inside (Coord : Coord_Rec; Min_Max : Min_Max_Rec) return Boolean is (Min_Max.Miny <= Coord.Y and then Coord.Y < Min_Max.Maxy and then Is_In_Range_X (Coord.X, Min_Max.Minx, Min_Max.Maxx)); -- Mapcodezone type Mapcode_Zone_Rec is record Fminx, Fmaxx, Fminy, Fmaxy : Lint := 0; end record; -- Empty Mapcode_Zone Mz_Empty : constant Mapcode_Zone_Rec := (others => <>); function Mz_Is_Empty (Zone : Mapcode_Zone_Rec) return Boolean is (Zone.Fmaxx <= Zone.Fminx or else Zone.Fmaxy <= Zone.Fminy); -- Construct MapcodeZone based on coordinate and deltas (in Fractions) function Mz_Set_From_Fractions (Y, X, Ydelta, Xdelta : Lint) return Mapcode_Zone_Rec is (if Ydelta < 0 then (Fminx => X, Fmaxx => X + Xdelta, Fminy => Y + 1 + Ydelta, -- y+yDelta can NOT be represented Fmaxy => Y + 1) -- y CAN be represented else (Fminx => X, Fmaxx => X + Xdelta, Fminy => Y, Fmaxy => Y + Ydelta)); function Mz_Mid_Point_Fractions (Zone : Mapcode_Zone_Rec) return Coord_Rec is ( (Y => (Zone.Fminy + Zone.Fmaxy) / 2, X => (Zone.Fminx + Zone.Fmaxx) / 2)); function Convert_Fractions_To_Coord32 (P : Coord_Rec) return Coord_Rec is ( (Y => P.Y / 810000, X => P.X / 3240000) ); function Wrap (P : Coord_Rec) return Coord_Rec is Res : Coord_Rec := P; begin if Res.X >= 180 * 3240000 * 1000000 then Res.X := Res.X - 360 * 3240000 * 1000000; end if; if Res.X < -180 * 3240000 * 1000000 then Res.X := Res.X + 360 * 3240000 * 1000000; end if; return Res; end Wrap; function Round (Val, Max : Real) return Real is Epsilon : constant Real := 0.0000005; begin if Val < 0.0 then if Val < -Max and then Val >= -Max - Epsilon then return -Max; end if; else if Val > Max and then Val <= Max + Epsilon then return Max; end if; end if; return Val; end Round; function Convert_Fractions_To_Degrees (P : Coord_Rec) return Coordinate is begin return (Lat => Round (Real (P.Y) / 810000.0 / 1000000.0, 90.0), Lon => Round (Real (P.X) / 3240000.0 / 1000000.0, 180.0) ); end Convert_Fractions_To_Degrees; function Mz_Restrict_Zone_To (Zone : Mapcode_Zone_Rec; Mm : Min_Max_Rec) return Mapcode_Zone_Rec is Z : Mapcode_Zone_Rec := Zone; Miny : constant Lint := Mm.Miny * 810000; Maxy : constant Lint := Mm.Maxy * 810000; Minx : Lint; Maxx : Lint; begin if Z.Fminy < Miny then Z.Fminy := Miny; end if; if Z.Fmaxy > Maxy then Z.Fmaxy := Maxy; end if; if Z.Fminy < Z.Fmaxy then Minx := Mm.Minx * 3240000; Maxx := Mm.Maxx * 3240000; if Maxx < 0 and then Z.Fminx > 0 then Minx := Minx + 360000000 * 3240000; Maxx := Maxx + 360000000 * 3240000; elsif Minx > 1 and then Z.Fmaxx < 0 then Minx := Minx - 360000000 * 3240000; Maxx := Maxx - 360000000 * 3240000; end if; if Z.Fminx < Minx then Z.Fminx := Minx; end if; if Z.Fmaxx > Maxx then Z.Fmaxx := Maxx; end if; end if; return Z; end Mz_Restrict_Zone_To; -- High-precision extension routines function Max_Mapcode_Precision return Natural is (8); -- PRIVATE lowest-level data access function Header_Letter (I : Natural) return String is Flags : constant Integer := Ndata.Data_Flags(I + 1); use Bits; begin if (Shr (Flags, 7) and 3) = 1 then return Encode_Char((Shr (Flags, 11) and 31) + 1) & ""; end if; return ""; end Header_Letter; function Smart_Div (I : Natural) return Integer is (Ndata.Data_Special1(I + 1)); function Is_Restricted (I : Natural) return Boolean is use Bits; begin return (Ndata.Data_Flags(I + 1) and 512) /= 0; end Is_Restricted; function Is_Nameless (I : Natural) return Boolean is use Bits; begin return (Ndata.Data_Flags(I + 1) and 64) /= 0; end Is_Nameless; function Is_Auto_Header (I : Natural) return Boolean is use Bits; begin return (Ndata.Data_Flags(I + 1) and Shl (8, 5)) /= 0; end Is_Auto_Header; function Codex_Len (I : Natural) return Integer is use Bits; Flags : constant Integer := Ndata.Data_Flags (I + 1) and 31; begin return Flags / 5 + Flags rem 5 + 1; end Codex_Len; function Co_Dex (I : Natural) return Integer is use Bits; Flags : constant Integer := Ndata.Data_Flags (I + 1) and 31; begin return 10 * (Flags / 5) + Flags rem 5 + 1; end Co_Dex; function Is_Special_Shape (I : Natural) return Boolean is use Bits; begin return (Ndata.Data_Flags(I + 1) and 1024) /= 0; end Is_Special_Shape; -- 1=pipe 2=plus 3=star function Rec_Type (I : Natural) return Integer is use Bits; begin return Shr (Ndata.Data_Flags(I + 1), 7) and 3; end Rec_Type; function First_Nameless_Record (Index : Natural; First_Code : Natural) return Natural is I : Integer := Index; Codex : constant Natural := Co_Dex (I); begin while I >= First_Code and then Co_Dex (I) = Codex and then Is_Nameless (I) loop I := I - 1; end loop; return I + 1; end First_Nameless_Record; function Count_Nameless_Records (Index : Natural; First_Code : Natural) return Natural is I : constant Natural := First_Nameless_Record (Index, First_Code); E : Natural := Index; Codex : constant Natural := Co_Dex (I); begin while Co_Dex(E) = Codex loop E := E + 1; end loop; return E - I; end Count_Nameless_Records; -- Return Lint immediately smaller than Real function Floor (X : Real) return Lint is Int : Lint; begin Int := Lint(X); if Real(Int) > X then Int := Int - 1; end if; return Int; end Floor; function Get_Encode_Rec(Lat, Lon : in Real) return Frac_Rec is Ilat : Real := Lat; Ilon : Real := Lon; D : Real; Fraclat, Fraclon : Lint; Lat32, Lon32 : Lint; begin if Ilat < -90.0 then Ilat := -90.0; elsif Ilat > 90.0 then Ilat := 90.0; end if; Ilat := Ilat + 90.0; -- Ilat now [0..180] Ilat := Ilat * 810000000000.0; Fraclat := Floor (Ilat + 0.1); D := Real (Fraclat) / 810000.0; Lat32 := Floor (D); Fraclat := Fraclat - Lat32 * 810000; Lat32 := Lat32 - 90000000; Ilon := Ilon - 360.0 * Real (Floor (Ilon / 360.0)); -- Lon now in [0..360> Ilon := Ilon * 3240000000000.0; Fraclon := Floor (Ilon + 0.1); D := Real (Fraclon) / 3240000.0; Lon32 := Floor (D); Fraclon := Fraclon - Lon32 * 3240000; if Lon32 >= 180000000 then Lon32 := Lon32 - 360000000; end if; return (Coord32 => (Y => Lat32, X => Lon32), Fraclat => Integer (Fraclat), Fraclon => Integer (Fraclon) ); end Get_Encode_Rec; function Encode_Base31 (Value : Lint; Nrchars : Natural) return String is Result : As_U.Asu_Us; Lv : Lint := Value; Ln : Natural := Nrchars; use type As_U.Asu_Us; begin while Ln > 0 loop Ln := Ln - 1; Result := Encode_Char(Integer (Lv rem 31) + 1) & Result; Lv := Lv / 31; end loop; return Result.Image; end Encode_Base31; -- Lowest level encode/decode routines function Decode_Base31 (Str : String) return Integer is Value : Integer := 0; C : Natural; begin for I in Str'Range loop C := Character'Pos (Str(I)); if C = 46 then -- Dot! return Value; end if; if Decode_Char(C + 1) < 0 then return Error; end if; Value := Value * 31 + Decode_Char(C + 1); end loop; return Value; end Decode_Base31; function Encode_Triple (Difx, Dify : Lint) return String is Rx, Ry, Cx, Cy : Lint; begin if Dify < 4 * 34 then Rx := Difx / 28; Ry := Dify / 34; Cx := Difx rem 28; Cy := Dify rem 34; return Encode_Char(Integer (Rx + 6 * Ry + 1)) & Encode_Base31 (Cx * 34 + Cy, 2); else Rx := Difx / 24; Cx := Difx rem 24; return Encode_Char(Integer (Rx + 25)) & Encode_Base31 (Cx * 40 + (Dify - 136), 2); end if; end Encode_Triple; function Decode_Triple (Input : String) return Coord_Rec is Triplex, Tripley : Integer; C1 : constant Character := Input(Input'First); I1 : constant Integer := Decode_Char(Character'Pos(C1) + 1); X : constant Integer := Decode_Base31 (Input(Positive'Succ(Input'First) .. Input'Last)); begin if I1 < 24 then Triplex := (I1 rem 6) * 28 + X / 34; Tripley := (I1 / 6) * 34 + X rem 34; else Tripley := X rem 40 + 136; Triplex := X / 40 + 24 * (I1 - 24); end if; return (Y => Lint (Tripley), X => Lint (Triplex)); end Decode_Triple; function Encode_Six_Wide (X, Y, Width, Height : in Integer) return Integer is D : Integer := 6; Col : Integer := X / 6; Maxcol : constant Integer := (Width - 4) / 6; begin if Col >= Maxcol then Col := Maxcol; D := Width - Maxcol * 6; end if; return Height * 6 * Col + (Height - 1 - Y) * D + X - Col * 6; end Encode_Six_Wide; function Decode_Six_Wide (V, Width, Height : in Integer) return Coord_Rec is D : Integer := 6; Col : Integer := V / (Height * 6); Maxcol : constant Integer := (Width - 4) / 6; W, X6, Y6 : Integer; begin if Col >= Maxcol then Col := Maxcol; D := Width - Maxcol * 6; end if; W := V - Col * Height * 6; X6 := Col * 6 + W rem D; Y6 := Height - 1 - W / D; return (Y => Lint (Y6), X => Lint (X6)); end Decode_Six_Wide; function Encode_Extension ( Input : String; Enc : Frac_Rec; Extrax4, Extray, Dividerx4, Dividery : Lint; Extradigits, Ydirection : Integer) return String is Factorx, Factory, Valx, Valy : Lint; Gx, Gy, Column1, Column2, Row1, Row2 : Integer; Digit : Integer := Extradigits; Result : As_U.Asu_Us; begin if Extradigits = 0 then return Input; end if; if Digit > Max_Mapcode_Precision then Digit := Max_Mapcode_Precision; end if; Result := As_U.Tus (Input); -- The following are all perfect integers -- 810000 = 30^4 Factorx := 810000 * Dividerx4; Factory := 810000 * Dividery; Valx := 810000 * Extrax4 + Lint (Enc.Fraclon); Valy := 810000 * Extray + Lint (Enc.Fraclat) * Lint (Ydirection); -- Protect against floating point errors if Valx < 0 then Valx := 0; elsif Valx >= Factorx then Valx := Factorx - 1; end if; if Valy < 0 then Valy := 0; elsif Valy >= Factory then Valy := Factory - 1; end if; Result.Append ('-'); loop Factorx := Factorx / 30; Gx := Integer (Valx / Factorx); Factory := Factory / 30; Gy := Integer (Valy / Factory); Column1 := Gx / 6; Row1 := Gy / 5; Result.Append (Encode_Char(Row1 * 5 + Column1 + 1)); Digit := Digit - 1; exit when Digit = 0; Column2 := Gx rem 6; Row2 := Gy rem 5; Result.Append (Encode_Char(Row2 * 6 + Column2 + 1)); Digit := Digit - 1; exit when Digit = 0; Valx := Valx - Factorx * Lint (Gx); Valy := Valy - Factory * Lint (Gy); end loop; return Result.Image; end Encode_Extension; -- Returns (possibly empty) MapcodeZone function Decode_Extension ( Extension_Chars : String; Coord32 : Coord_Rec; Dividerx4, Dividery, Lon_Offset4, Extremelatmicrodeg, Maxlonmicrodeg : Lint) return Mapcode_Zone_Rec is Processor : Lint := 1; Lon32, Lat32 : Lint := 0; Odd : Boolean := False; Idx : Positive; Column1, Row1, Column2, Row2 : Lint; C1, C2 : Character; N1, N2 : Integer; Ldivx4, Ldivy : Lint; Lon4, Lat1: Lint; Mapcode_Zone : Mapcode_Zone_Rec; begin if Extension_Chars'Length > 8 then -- Too many digits return Mz_Empty; end if; Idx := Extension_Chars'First; while Idx <= Extension_Chars'Length loop C1 := Extension_Chars(Idx); N1 := Decode_Char(Character'Pos(C1) + 1); Idx := Idx + 1; if N1 < 0 or else N1 = 30 then return Mz_Empty; end if; Row1 := Lint (N1 / 5); Column1 := Lint (N1 rem 5); if Idx <= Extension_Chars'Length then C2 := Extension_Chars(Idx); N2 := Decode_Char(Character'Pos(C2) + 1); Idx := Idx + 1; if N2 < 0 or else N2 = 30 then return Mz_Empty; end if; Row2 := Lint (N2 / 6); Column2 := Lint (N2 rem 6); else Row2 := 0; Column2 := 0; Odd := True; end if; Processor := Processor * 30; Lon32 := Lon32 * 30 + Column1 * 6 + Column2; Lat32 := Lat32 * 30 + Row1 * 5 + Row2; end loop; Ldivx4 := Dividerx4; Ldivy := Dividery; while Processor < 810000 loop Ldivx4 := Ldivx4 * 30; Ldivy := Ldivy * 30; Processor := Processor * 30; end loop; Lon4 := Coord32.X * 3240000 + Lon32 * Ldivx4 + Lon_Offset4 * 810000; Lat1 := Coord32.Y * 810000 + Lat32 * Ldivy; if Odd then Mapcode_Zone := Mz_Set_From_Fractions (Lat1, Lon4, 5 * Ldivy, 6 * Ldivx4); else Mapcode_Zone := Mz_Set_From_Fractions (Lat1, Lon4, Ldivy, Ldivx4); end if; -- FORCE_RECODE: restrict the coordinate range to the extremes that were -- provided if Mapcode_Zone.Fmaxx > Maxlonmicrodeg * 3240000 then Mapcode_Zone.Fmaxx := Maxlonmicrodeg * 3240000; end if; if Ldivy >= 0 then if Mapcode_Zone.Fmaxy > Extremelatmicrodeg * 810000 then Mapcode_Zone.Fmaxy := Extremelatmicrodeg * 810000; end if; else if Mapcode_Zone.Fminy < Extremelatmicrodeg * 810000 then Mapcode_Zone.Fminy := Extremelatmicrodeg * 810000; end if; end if; return Mapcode_Zone; end Decode_Extension; -- Add vowels to prevent a mapcode r from being all-digit function Aeu_Pack (R : As_U.Asu_Us; Short : Boolean) return String is Dotpos : Natural := 0; Result : As_U.Asu_Us := R; Rlen : Natural := Result.Length; Rest : As_U.Asu_Us; V : Integer; use type As_U.Asu_Us; begin for D in 1 .. Rlen loop if Result.Element (D) < '0' or else Result.Element (D) > '9' then -- Not digit? if Result.Element (D) = '.' and then Dotpos = 0 then -- First dot? Dotpos := D; elsif R.Element (D) = '-' then Rest := Result.Uslice (D, Result.Length); Result := Result.Uslice (1, D - 1); Rlen := D - 1; exit; else return Result.Image; end if; end if; end loop; -- Does Result have a dot, AND at least 2 chars before and after the dot? if Dotpos >= 3 and then Rlen - 2 >= Dotpos then if Short then -- v1.50 new way: use only A V := (Character'Pos(Result.Element (1)) - 48) * 100 + (Character'Pos(Result.Element (Rlen - 1)) - 48) * 10 + Character'Pos(Result.Element (Rlen)) - 48; Result := 'A' & Result.Uslice (2, Rlen - 2) & Encode_Char(V / 32 + 1) & Encode_Char(V rem 32 + 1); else -- Old way: use A, E and U */ V := (Character'Pos(Result.Element(Rlen - 1)) - 48) * 10 + Character'Pos(Result.Element(Rlen)) - 48; Result := Result.Uslice(1, Rlen - 2) & Encode_Char(V / 34 + 32) & Encode_Char(V rem 34 + 1); end if; end if; Result.Append (Rest); return Result.Image; end Aeu_Pack; -- Remove vowels from mapcode str into an all-digit mapcode -- (Assumes str is already uppercase!) function Aeu_Unpack (Str : String) return String is Voweled, Has_Letters : Boolean := False; Lastpos : constant Natural := Str'Length; Result : As_U.Asu_Us := As_U.Tus (Str); Dotpos : Natural := Result.Locate ("."); V, V1, V2 : Integer; S : String (1 .. 4); C : Character; use type As_U.Asu_Us; begin if Dotpos < 3 or else Lastpos < Dotpos + 2 then -- No dot, or less than 2 letters before dot, or less than 2 letters -- after dot return Str; end if; if Result.Element(1) = 'A' then -- V1.50 V1 := Decode_Char(Character'Pos(Result.Element(Lastpos)) + 1); if V1 < 0 then V1 := 31; end if; V2 := Decode_Char(Character'Pos(Result.Element(Lastpos - 1)) + 1); if V2 < 0 then V2 := 31; end if; S := Image (1000 + V1 + 32 * V2); Result := S(2) & Result.Uslice(2, Lastpos - 2) & S(3 .. 4); Voweled := True; elsif Result.Element(1) = 'U' then Result.Delete (1, 1); Dotpos := Dotpos - 1; Voweled := True; else C := Result.Element(Lastpos - 1); V := Character'Pos(C); if C = 'A' then V := 0; elsif C = 'E'then V := 34; elsif C = 'U' then V := 68; else V := -1; end if; if V >= 0 then C := Result.Element (Lastpos); if C = 'A' then V := V + 31; elsif C = 'E' then V := V + 32; elsif C = 'U' then V := V + 33; else V1 := Decode_Char(Character'Pos(Result.Element(Lastpos)) + 1); if V1 < 0 then return Undefined; end if; V := V + V1; end if; if V >= 100 then return Undefined; end if; Voweled := True; Result := Result.Uslice (1, Lastpos - 2) & Encode_Char(V / 10 + 1) & Encode_Char(V rem 10 + 1); end if; end if; if Dotpos < 3 or else Dotpos > 6 then return Undefined; end if; for I in 1 .. Lastpos loop if I /= Dotpos then V := Decode_Char(Character'Pos(Result.Element(I)) + 1); if V < 0 then -- Bad char! return Undefined; elsif V > 9 then Has_Letters := True; end if; end if; end loop; if Voweled and then Has_Letters then return Undefined; end if; if not Voweled and then not Has_Letters then return Undefined; end if; return Result.Image; end Aeu_Unpack; -- Mid-level encode/decode function Encode_Nameless (Enc : Frac_Rec; M : Natural; First_Code : Natural; Extra_Digits : Integer) return String is A : constant Natural := Count_Nameless_Records (M, First_Code); P : constant Natural := 31 / A; R : constant Natural := 31 rem A; Codex : constant Natural := Co_Dex (M); Codexlen : constant Natural := Codex_Len(M); X : Integer; Storage_Offset, Base_Power, Base_Power_A : Lint; begin if A < 1 then return Undefined; end if; X := M - First_Nameless_Record (M, First_Code); if Codex /= 21 and then A <= 31 then Storage_Offset := Lint (X * P + (if X < R then X else R)) * 961 * 961; elsif Codex /= 21 and then A < 62 then if X < 62 - A then Storage_Offset := Lint (X) * (961 * 961); else Storage_Offset := Lint (62 - A + (X - 62 + A) / 2) * 961 * 961; if (X + A) rem 2 = 1 then Storage_Offset := Storage_Offset + 16 * 961 * 31; end if; end if; else Base_Power := (if Codex = 21 then 961 * 961 else 961 * 961 * 31); Base_Power_A := Base_Power / Lint (A); if A = 62 then Base_Power_A := Base_Power_A + 1; else Base_Power_A := 961 * (Base_Power_A / 961); end if; Storage_Offset := Lint (X) * Base_Power_A; end if; declare Mm : constant Min_Max_Rec := Min_Max_Setup (M); Side : Integer := Smart_Div (M); Org_Side : constant Integer := Side; X_Side : Integer := Side; -- Note that xDivider4 is 4 times too large Dividerx4 : constant Lint := Lint (Xdivider4 (Mm.Miny, Mm.Maxy)); Xfracture : constant Lint := Lint (Enc.Fraclon) / 810000; -- Dx is in millionths Dx : constant Lint := (4 * (Enc.Coord32.X - Mm.Minx) + Xfracture) / Dividerx4; -- Extrax4 is in quarter-millionths Extrax4 : constant Lint := (Enc.Coord32.X - Mm.Minx) * 4 - Dx * Dividerx4; Dividery : constant Lint := 90; Dy : Lint := (Mm.Maxy - Enc.Coord32.Y) / Dividery; Extray : Lint := (Mm.Maxy - Enc.Coord32.Y) rem Dividery; V : Lint; Result : As_U.Asu_Us; use type As_U.Asu_Us; begin if Extray = 0 and then Enc.Fraclat > 0 then Dy := Dy - 1; Extray := Extray + Dividery; end if; V := Storage_Offset; if Is_Special_Shape (M) then X_Side := X_Side * Side; Side := Integer (1 + (Mm.Maxy - Mm.Miny) / 90); X_Side := X_Side / Side; V := V + Lint (Encode_Six_Wide (Integer (Dx), Side - 1 - Integer(Dy), X_Side, Side)); else V := V + (Dx * Lint (Side) + Dy); end if; Result := As_U.Tus (Encode_Base31 (V, Codexlen + 1)); if Codexlen = 3 then Result := Result.Uslice (1, 2) & '.' & Result.Uslice (3, Result.Length); elsif Codexlen = 4 then if Codex = 22 and then Org_Side = 961 and then not Is_Special_Shape (M) then Result := As_U.Tus (Result.Element (1) & Result.Element (2) & Result.Element (4) & '.' & Result.Element (3) & Result.Element (5)); elsif Codex = 13 then Result := Result.Uslice (1, 2) & '.' & Result.Uslice (3, Result.Length); else Result := Result.Uslice (1, 3) & '.' & Result.Uslice (4, Result.Length); end if; end if; return Encode_Extension (Result.Image, Enc, Extrax4, Extray, Dividerx4, Dividery, Extra_Digits, -1); end; end Encode_Nameless; function Decode_Nameless (Input : String; Extension_Chars : String; M : Natural; First_Index : Natural) return Mapcode_Zone_Rec is Codex : constant Natural := Co_Dex (M); Result : As_U.Asu_Us; A : constant Natural := Count_Nameless_Records (M, First_Index); F : constant Natural := First_Nameless_Record (M, First_Index); P : constant Natural := 31 / A; R : constant Natural := 31 rem A; X, V, Offset : Integer; Swap_Letters : Boolean := False; Base_Power, Base_Power_A : Integer; use type As_U.Asu_Us; begin Result := As_U.Tus (Input); if Codex = 22 then Result := Result.Uslice (1, 3) & Result.Uslice (5, Result.Length); else Result := Result.Uslice (1, 2) & Result.Uslice (4, Result.Length); end if; if Codex /= 21 and then A <= 31 then Offset := Decode_Char(Character'Pos (Result.Element(1)) + 1); if Offset < R * (P + 1) then X := Offset / (P + 1); else Swap_Letters := P = 1 and then Codex = 22; X := R + (Offset - R * (P + 1)) / P; end if; elsif Codex /= 21 and then A < 62 then X := Decode_Char(Character'Pos (Result.Element(1)) + 1); if X < 62 - A then Swap_Letters := Codex = 22; else X := X + X - (62 - A); end if; else -- codex = 21 or else A >= 62 Base_Power := (if Codex = 21 then 961 * 961 else 961 * 961 * 31); Base_Power_A := Base_Power / A; if A = 62 then Base_Power_A := Base_Power_A + 1; else Base_Power_A := 961 * (Base_Power_A / 961); end if; -- Decode V := Decode_Base31 (Result.Image); X := V / Base_Power_A; V := V rem Base_Power_A; end if; if Swap_Letters then if not Is_Special_Shape (M + X) then Result := As_U.Tus (Result.Element (1) & Result.Element (2) & Result.Element (4) & Result.Element (3) & Result.Element (5)); end if; end if; if Codex /= 21 and then A <= 31 then V := Decode_Base31 (Result.Image); if X > 0 then V := V - (X * P + (if X < R then X else R)) * (961 * 961); end if; elsif Codex /= 21 and then A < 62 then V := Decode_Base31 (Result.Slice (2, Result.Length)); if X >= 62 - A then if V >= 16 * 961 * 31 then V := V - 16 * 961 * 31; X := X + 1; end if; end if; end if; if X > A then -- past end! return Mz_Empty; end if; declare Lm : constant Natural := F + X; Mm : constant Min_Max_Rec := Min_Max_Setup (Lm); Side : Integer := Smart_Div (Lm); X_Side : Integer := Side; D : Coord_Rec; Dividerx4 : constant Lint := Lint (Xdivider4 (Mm.Miny, Mm.Maxy)); Dividery : constant Lint := 90; Corner : Coord_Rec; begin X_Side := Side; if Is_Special_Shape(Lm) then X_Side := X_Side * Side; Side := Integer (1 + (Mm.Maxy - Mm.Miny) / 90); X_Side := X_Side / Side; D := Decode_Six_Wide(V, X_Side, Side); D.Y := Lint (Side) - 1 - D.Y; else D.X := Lint (V / Side); D.Y := Lint (V rem Side); end if; if D.X >= Lint (X_Side) then -- Out-of-range! return Mz_Empty; end if; Corner := ( Y => Mm.Maxy - D.Y * Dividery, X => Mm.Minx + (D.X * Dividerx4) / 4); return Decode_Extension(Extension_Chars, Corner, Dividerx4, -Dividery, (D.X * Dividerx4) rem 4, Mm.Miny, Mm.Maxx); end; end Decode_Nameless; function Encode_Auto_Header (Enc : Frac_Rec; M : Natural; Extradigits : in Natural) return String is Codex : constant Integer := Co_Dex(M); Codexlen : constant Integer := Codex_Len (M); First_Index : Integer := M; I : Integer; Mm : Min_Max_Rec; H : Lint; Xdiv : Natural; W : Lint; Product : Lint; Good_Rounder : Lint; Storage_Start : Lint := 0; Dividerx, Dividery, Vx, Vy, Extrax, Extray, Spx, Spy, Value : Lint; Mapc : As_U.Asu_Us; use Bits; begin while Is_Auto_Header (First_Index - 1) and then Co_Dex (First_Index - 1) = Codex loop First_Index := First_Index - 1; end loop; I := First_Index; while Co_Dex (I) = Codex loop Mm := Min_Max_Setup (I); H := (Mm.Maxy - Mm.Miny + 89) / 90; Xdiv := Xdivider4 (Mm.Miny, Mm.Maxy); W := ((Mm.Maxx - Mm.Minx) * 4 + Lint (Xdiv) - 1) / Lint (Xdiv); H := 176 * ((H + 176 - 1) / 176); W := 168 * ((W + 168 - 1) / 168); Product := (W / 168) * (H / 176) * 961 * 31; if Rec_Type (I) = 2 then -- *+ Good_Rounder := (if Codex >= 23 then 961 * 961 * 31 else 961 * 961); Product := (Storage_Start + Product + Good_Rounder - 1) / Good_Rounder * Good_Rounder - Storage_Start; end if; if I = M and then Fits_Inside (Enc.Coord32, Mm) then Dividerx := (Mm.Maxx - Mm.Minx + W - 1) / W; Vx := (Enc.Coord32.X - Mm.Minx) / Dividerx; Extrax := (Enc.Coord32.X - Mm.Minx) rem Dividerx; Dividery := (Mm.Maxy - Mm.Miny + H - 1) / H; Vy := (Mm.Maxy - Enc.Coord32.Y) / Dividery; Extray := (Mm.Maxy - Enc.Coord32.Y) rem Dividery; Spx := Vx rem 168; Vx := Vx / 168; Value := Vx * (H / 176); if Extray = 0 and then Enc.Fraclat > 0 then Vy := Vy - 1; Extray := Extray + Dividery; end if; Spy := Vy rem 176; Vy := Vy / 176; Value := Value + Vy; Mapc := As_U.Tus ( Encode_Base31 (Storage_Start / (961 * 31) + Value, Codexlen - 2) & "." & Encode_Triple (Spx, Spy)); return Encode_Extension (Mapc.Image, Enc, Shl (Extrax, 2), Extray, Shl( Dividerx, 2), Dividery, Extradigits, -1); end if; Storage_Start := Storage_Start + Product; I := I + 1; end loop; return Undefined; end Encode_Auto_Header; function Decode_Auto_Header (Input : String; Extension_Chars : String; M : Natural) return Mapcode_Zone_Rec is Storage_Start : Lint := 0; Codex : constant Integer := Co_Dex(M); -- Decode (before dot) Value : Lint := Lint (Decode_Base31 (Input)); Triple : Coord_Rec; Lm : Natural; Mm : Min_Max_Rec; H : Lint; Xdiv : Lint; W : Lint; Product : Lint; Good_Rounder : Lint; Dividerx, Dividery, Vx, Vy : Lint; Corner : Coord_Rec; use Bits; begin Value := Value * (961 * 31); -- Decode bottom Triple := Decode_Triple (Input (Input'Last - 2 .. Input'Last)); Lm := M; while Co_Dex (Lm) = Codex and then Rec_Type (Lm) > 1 loop Mm := Min_Max_Setup (Lm); H := (Mm.Maxy - Mm.Miny + 89) / 90; Xdiv := Lint (Xdivider4 (Mm.Miny, Mm.Maxy)); W := ((Mm.Maxx - Mm.Minx) * 4 + (Xdiv - 1)) / Xdiv; H := 176 * ((H + 176 - 1) / 176); W := 168 * ((W + 168 - 1) / 168); Product := (W / 168) * (H / 176) * 961 * 31; if Rec_Type (Lm) = 2 then Good_Rounder := (if Codex >= 23 then 961 * 961 * 31 else 961 * 961); Product := ((Storage_Start + Product + Good_Rounder - 1) / Good_Rounder) * Good_Rounder - Storage_Start; end if; if Value >= Storage_Start and then Value < Storage_Start + Product then -- Code belongs here? Dividerx := (Mm.Maxx - Mm.Minx + W - 1) / W; Dividery := (Mm.Maxy - Mm.Miny + H - 1) / H; Value := Value - Storage_Start; Value := Value / (961 * 31); Vx := Triple.X + 168 * (Value / (H / 176)); Vy := Triple.Y + 176 * (Value rem (H / 176)); Corner := ( -- In microdegrees Y => Mm.Maxy - Vy * Dividery, X => Mm.Minx + Vx * Dividerx); if Corner.Y /= Mm.Maxy and then not Fits_Inside (Corner, Mm) then return Mz_Empty; end if; return Decode_Extension (Extension_Chars, Corner, Shl (Dividerx, 2), -Dividery, 0, Mm.Miny, Mm.Maxx); -- autoheader end if; Storage_Start := Storage_Start + Product; Lm := Lm + 1; end loop; return Mz_Empty; end Decode_Auto_Header; function Encode_Grid (Enc : Frac_Rec; M : Natural; Mm : Min_Max_Rec; Headerletter : in String; Extradigits : in Natural) return String is Orgcodex : constant Integer := Co_Dex(M); Codex : Integer := Orgcodex; Prefixlength, Postfixlength : Integer; Divx, Divy : Integer; Xgridsize, Ygridsize, X, Relx, Rely : Lint; V : Integer; Result, Postfix : As_U.Asu_Us; Dividery, Dividerx : Lint; Difx, Dify, Extrax, Extray : Lint; use Bits; use type As_U.Asu_Us; begin if Codex = 21 then Codex := 22; end if; if Codex = 14 then Codex := 23; end if; Prefixlength := Codex / 10; Postfixlength := Codex rem 10; Divy := Smart_Div(M); if Divy = 1 then Divx := X_Side(Prefixlength + 1); Divy := Y_Side(Prefixlength + 1); else Divx := Nc(Prefixlength + 1) / Divy; end if; Ygridsize := (Mm.Maxy - Mm.Miny + Lint (Divy) - 1) / Lint (Divy); Rely := Enc.Coord32.Y - Mm.Miny; Rely := Rely / Ygridsize; Xgridsize := (Mm.Maxx - Mm.Minx + Lint (Divx) - 1) / Lint (Divx); X := Enc.Coord32.X; Relx := X - Mm.Minx; if Relx < 0 then X := X + 360000000; Relx := Relx + 360000000; elsif Relx >= 360000000 then X := X - 360000000; Relx := Relx - 360000000; end if; -- 1.32 fix FIJI edge case if Relx < 0 then return ""; end if; Relx := Relx / Xgridsize; if Relx >= Lint (Divx) then return ""; end if; if Divx /= Divy and then Prefixlength > 2 then -- D = 6 V := Encode_Six_Wide (Integer (Relx), Integer (Rely), Divx, Divy); else V := Integer (Relx) * Divy + (Divy - 1 - Integer (Rely)); end if; Result := As_U.Tus (Encode_Base31 (Lint (V), Prefixlength)); if Prefixlength = 4 and then Divx = 961 and then Divy = 961 then Result := As_U.Tus (Result.Element(1) & Result.Element(3) & Result.Element(2) & Result.Element(4)); end if; Rely := Mm.Miny + Rely * Ygridsize; Relx := Mm.Minx + Relx * Xgridsize; Dividery := (Ygridsize + Lint (Y_Side(Postfixlength + 1)) - 1) / Lint (Y_Side(Postfixlength + 1)); Dividerx := (Xgridsize + Lint (X_Side(Postfixlength + 1)) - 1) / Lint (X_Side(Postfixlength + 1)); Result.Append ("."); -- Encoderelative Difx := X - Relx; Dify := Enc.Coord32.Y - Rely; Extrax := Difx rem Dividerx; Extray := Dify rem Dividery; Difx := Difx / Dividerx; Dify := Dify / Dividery; Dify := Lint (Y_Side(Postfixlength + 1)) - 1 - Dify; if Postfixlength = 3 then Result.Append (Encode_Triple (Difx, Dify)); else Postfix := As_U.Tus (Encode_Base31 ( Difx * Lint (Y_Side(Postfixlength + 1)) + Dify, Postfixlength)); if Postfixlength = 4 then Postfix := As_U.Tus (Postfix.Element(1) & Postfix.Element(3) & Postfix.Element(2) & Postfix.Element(4)); end if; Result.Append (Postfix); end if; if Orgcodex = 14 then Result := Result.Element(1) & '.' & Result.Element(2) & Result.Uslice (4, Result.Length); end if; return Encode_Extension (Headerletter & Result.Image, Enc, Shl (Extrax, 2), Extray, Shl (Dividerx, 2), Dividery, Extradigits, 1); end Encode_Grid; function Decode_Grid (Input, Extension_Chars : String; M : Natural) return Mapcode_Zone_Rec is Linput : As_U.Asu_Us := As_U.Tus (Input); Prefixlength, Postfixlength : Natural; Divx, Divy : Integer; V : Integer; Rel : Coord_Rec; Mm : Min_Max_Rec; Xgridsize, Ygridsize : Lint; Xp, Yp, Dividerx, Dividery : Lint; Rest : As_U.Asu_Us; Dif : Coord_Rec; Corner : Coord_Rec; Decodemaxx, Decodemaxy : Lint; use Bits; use type As_U.Asu_Us; begin Prefixlength := Linput.Locate (".") - 1; Postfixlength := Linput.Length - 1 - Prefixlength; if Prefixlength = 1 and then Postfixlength = 4 then Prefixlength := Prefixlength + 1; Postfixlength:= Postfixlength - 1; Linput := Linput.Element(1) & Linput.Element(3) & '.' & Linput.Uslice (4, Linput.Length); end if; Divy := Smart_Div(M); if Divy = 1 then Divx := X_Side(Prefixlength + 1); Divy := Y_Side(Prefixlength + 1); else Divx := Nc(Prefixlength + 1) / Divy; end if; if Prefixlength = 4 and then Divx = 961 and then Divy = 961 then Linput := Linput.Element(1) & Linput.Element(3) & Linput.Element(2) & Linput.Uslice (4, Linput.Length); end if; V := Decode_Base31 (Linput.Image); if Divx /= Divy and then Prefixlength > 2 then -- D = 6 Rel := Decode_Six_Wide (V, Divx, Divy); else Rel.X := Lint (V / Divy); Rel.Y := Lint (Divy - 1 - V rem Divy); end if; Mm := Min_Max_Setup (M); Ygridsize := (Mm.Maxy - Mm.Miny + Lint (Divy) - 1) / Lint (Divy); Xgridsize := (Mm.Maxx - Mm.Minx + Lint (Divx) - 1) / Lint (Divx); Rel.Y := Mm.Miny + Rel.Y * Ygridsize; Rel.X := Mm.Minx + Rel.X * Xgridsize; Xp := Lint (X_Side(Postfixlength + 1)); Dividerx := (Xgridsize + Xp - 1) / Xp; Yp := Lint (Y_Side(Postfixlength + 1)); Dividery := (Ygridsize + Yp - 1) / Yp; Rest := Linput.Uslice(Prefixlength + 2, Linput.Length); if Postfixlength = 3 then Dif := Decode_Triple (Rest.Image); else if Postfixlength = 4 then Rest := As_U.Tus (Rest.Element (1) & Rest.Element(3) & Rest.Element(2) & Rest.Element(4)); end if; V := Decode_Base31 (Rest.Image); Dif.X := Lint (V) / Yp; Dif.Y := Lint (V) rem Yp; end if; Dif.Y := Yp - 1 - Dif.Y; Corner := (Y => Rel.Y + Dif.Y * Dividery, X => Rel.X + Dif.X * Dividerx); if not Fits_Inside (Corner, Mm) then return Mz_Empty; end if; Decodemaxx := (if Rel.X + Xgridsize < Mm.Maxx then Rel.X + Xgridsize else Mm.Maxx); Decodemaxy := (if Rel.Y + Ygridsize < Mm.Maxy then Rel.Y + Ygridsize else Mm.Maxy); return Decode_Extension (Extension_Chars, Corner, Shl (Dividerx, 2), Dividery, 0, Decodemaxy, Decodemaxx); end Decode_Grid; -- Mapcoder engine Max_Nr_Of_Mapcode_Results : constant := 22; function Mapcoder_Engine (Enc : Frac_Rec; Tn : in Integer; Get_Shortest : Boolean; State_Override : Integer; Extra_Digits : Integer) return Mapcode_Infos is Results : Mapcode_Infos (1 .. Max_Nr_Of_Mapcode_Results); Nb_Results : Natural := 0; From_Territory : Integer := 0; Upto_Territory : Integer := Ccode_Earth; Original_Length : Natural; From, Upto : Integer; Store_Code : Integer; Mc_Info : Mapcode_Info; Go_On : Boolean; -- Scan a range of territories procedure Scan (Territory_Number : Integer) is Mm : Min_Max_Rec; R : As_U.Asu_Us; use type As_U.Asu_Us; begin for I in From .. Upto loop -- Exlude 54 and 55 if Co_Dex(I) < 54 then Mm := Min_Max_Setup (I); if Fits_Inside (Enc.Coord32, Mm) then if Is_Nameless (I) then R := As_U.Tus (Encode_Nameless (Enc, I, From, Extra_Digits)); elsif Rec_Type(I) > 1 then R := As_U.Tus (Encode_Auto_Header (Enc, I, Extra_Digits)); elsif I = Upto and then Get_Parent (Territories (Territory_Number)) >= 0 then declare More_Results : constant Mapcode_Infos := Mapcoder_Engine (Enc, Get_Parent (Territories (Territory_Number)), Get_Shortest, Territory_Number, Extra_Digits); T : constant Natural := Nb_Results; N : constant Natural := More_Results'Length; begin if N > 0 then Nb_Results := Nb_Results + N; if Nb_Results > Max_Nr_Of_Mapcode_Results then Nb_Results := Max_Nr_Of_Mapcode_Results; end if; Results (T + 1 .. Nb_Results) := More_Results; end if; R.Set_Null; end; else if Is_Restricted (I) and then Nb_Results = Original_Length then -- Restricted, and no shorter mapcodes exist: -- do not generate mapcodes R.Set_Null; else R := As_U.Tus (Encode_Grid (Enc, I, Mm, Header_Letter(I), Extra_Digits)); end if; end if; if R.Length > 4 then R := As_U.Tus (Aeu_Pack (R, False)); Store_Code := Territory_Number; if State_Override >= 0 then Store_Code := State_Override; end if; Mc_Info.Mapcode := R; Mc_Info.Territory_Alpha_Code := As_U.Tus (Get_Territory_Alpha_Code (Territories (Store_Code))); Mc_Info.Full_Mapcode := (if Store_Code = Ccode_Earth then As_U.Asu_Null else Mc_Info.Territory_Alpha_Code & " ") & R; Mc_Info.Territory := Territories (Store_Code); Nb_Results := Nb_Results + 1; Results (Nb_Results) := Mc_Info; exit when Get_Shortest; end if; end if; end if; end loop; end Scan; begin if Tn in From_Territory .. Upto_Territory then From_Territory := Tn; Upto_Territory := Tn; end if; for Territory_Number in From_Territory .. Upto_Territory loop Go_On := True; Original_Length := Nb_Results; From := Data_First_Record (Territory_Number); if Ndata.Data_Flags(From + 1) = 0 then Go_On := False; end if; if Go_On then Upto := Data_Last_Record (Territory_Number); if Territory_Number /= Ccode_Earth and then not Fits_Inside (Enc.Coord32, Min_Max_Setup (Upto)) then Go_On := False; end if; end if; if Go_On then Scan (Territory_Number); end if; end loop; return Results (1 .. Nb_Results); end Mapcoder_Engine; function Master_Decode (Mapcode : String; Territory_Number : Natural) return Coordinate is Map_Code : As_U.Asu_Us := As_U.Tus (Mapcode); Extensionchars : As_U.Asu_Us; Minpos : constant Natural := Map_Code.Locate ("-"); Mclen : Positive; Number : Natural; Parent : Integer; From, Upto : Integer; Prefixlength, Postfixlength, Incodex : Integer; Zone : Mapcode_Zone_Rec; Codex : Integer; Nr_Zone_Overlaps : Natural; Coord32 : Coord_Rec; Zfound, Z : Mapcode_Zone_Rec; procedure Try_Smaller (M : in Integer) is begin for J in From .. M - 1 loop -- Try all smaller rectangles j if not Is_Restricted (J) then Z := Mz_Restrict_Zone_To (Zone, Min_Max_Setup (J)); if not Mz_Is_Empty (Z) then Nr_Zone_Overlaps := Nr_Zone_Overlaps + 1; if Nr_Zone_Overlaps = 1 then -- First fit! remember... Zfound := Z; else -- More than one hit, give up exit; end if; end if; end if; end loop; end Try_Smaller; begin if Minpos > 1 then Extensionchars := Map_Code.Uslice (Minpos + 1, Map_Code.Length); Map_Code := Map_Code.Uslice (1, Minpos - 1); end if; Map_Code := As_U.Tus (Aeu_Unpack (Map_Code.Image)); if Map_Code.Is_Null then -- Failed to decode! raise Decode_Error; end if; Mclen := Map_Code.Length; Number := Territory_Number; if Mclen >= 10 then Number := Ccode_Earth; end if; -- Long codes in states are handled by the country Parent := Get_Parent (Territories (Number)); if Parent >= 0 then if Mclen >= 9 or else (Mclen >= 8 and then (Parent = Ccode_Ind or else Parent = Ccode_Mex)) then Number := Parent; end if; end if; From := Data_First_Record (Number); if From < 0 or else Ndata.Data_Flags(From + 1) = 0 then raise Decode_Error; end if; Upto := Data_Last_Record (Number); Prefixlength := Map_Code.Locate (".") - 1; Postfixlength := Mclen - 1 - Prefixlength; Incodex := Prefixlength * 10 + Postfixlength; Zone := Mz_Empty; for M in From .. Upto loop Codex := Co_Dex (M); if Rec_Type (M) = 0 and then not Is_Nameless(M) and then (Incodex = Codex or else (Incodex = 22 and then Codex = 21)) then Zone := Decode_Grid (Map_Code.Image, Extensionchars.Image, M); -- First of all, make sure the zone fits the country Zone := Mz_Restrict_Zone_To (Zone, Min_Max_Setup (Upto)); if not Mz_Is_Empty (Zone) and then Is_Restricted (M) then Nr_Zone_Overlaps := 0; -- Get midpoint in microdegrees Coord32 := Convert_Fractions_To_Coord32 ( Mz_Mid_Point_Fractions (Zone)); for J in reverse M - 1 .. From loop -- Look in previous rects if not Is_Restricted (J) then if Fits_Inside (Coord32, Min_Max_Setup (J)) then Nr_Zone_Overlaps := Nr_Zone_Overlaps + 1; exit; end if; end if; end loop; if Nr_Zone_Overlaps = 0 then -- See if mapcode zone OVERLAPS any sub-area... Try_Smaller (M); if Nr_Zone_Overlaps = 1 then -- Intersected exactly ONE sub-area? -- Use the intersection found... Zone := Zfound; end if; end if; if Nr_Zone_Overlaps = 0 then Zone := Mz_Empty; end if; end if; exit; elsif Rec_Type(M) = 1 and then Codex + 10 = Incodex and then Header_Letter(M)'Length = 1 and then Header_Letter(M)(1) = Map_Code.Element (1) then Zone := Decode_Grid (Map_Code.Slice(2, Map_Code.Length), Extensionchars.Image, M); exit; elsif Is_Nameless (M) and then ((Codex = 21 and then Incodex = 22) or else (Codex = 22 and then Incodex = 32) or else (Codex = 13 and then Incodex = 23)) then Zone := Decode_Nameless (Map_Code.Image, Extensionchars.Image, M, From); exit; elsif Rec_Type(M) > 1 and then Postfixlength = 3 and then Codex_Len(M) = Prefixlength + 2 then Zone := Decode_Auto_Header (Map_Code.Image, Extensionchars.Image, M); exit; end if; end loop; Zone := Mz_Restrict_Zone_To (Zone, Min_Max_Setup (Upto)); if Mz_Is_Empty(Zone) then raise Decode_Error; end if; return Convert_Fractions_To_Degrees (Wrap (Mz_Mid_Point_Fractions (Zone))); end Master_Decode; -- Legacy interface function Encode (Coord : Coordinate; Territory_Code : String := ""; Shortest : Boolean := False; Precision : Precisions := 0; Sort : Boolean := False) return Mapcode_Infos is Result : Mapcode_Infos := Mapcoder_Engine ( Enc => Get_Encode_Rec (Coord.Lat, Coord.Lon), Tn => (if Territory_Code = "" then Error else Integer (Get_Territory (Territory_Code))), Get_Shortest => Shortest, State_Override => -1, Extra_Digits => Precision); -- First and last index of the mapcodes, of the same territory, -- producing the shortest mapcode First, Last : Natural := 0; Len : Positive := Positive'Last; use type As_U.Asu_Us; begin if not Sort then return Result; end if; -- Search shortest mapcode (First) and the last mapcode for the -- same territory as First for I in Result'Range loop if Result(I).Mapcode.Length < Len then First := I; Len := Result(I).Mapcode.Length; end if; if Result(I).Territory_Alpha_Code = Result(First).Territory_Alpha_Code then Last := I; end if; end loop; -- Move First .. Last at beginning of list if First /= Result'First then declare Slice : constant Mapcode_Infos := Result(First .. Last); begin Result(Last-First+2 .. Last) := Result(Result'First .. First-1); Result(Result'First .. Result'First+Last-First) := Slice; end; end if; return Result; end Encode; function Decode (Mapcode, Context : String) return Coordinate is Contextterritorynumber : Integer; begin -- Raise Decode error if Mapcode or Context is not in Roman declare Lm, Lc : Mapcodes.Languages.Language_List; use type Mapcodes.Languages.Language_List; begin Lm := Mapcodes.Languages.Get_Language ( Ada.Characters.Handling.To_Wide_String (Mapcode)); if Context /= "" then Lc := Mapcodes.Languages.Get_Language ( Ada.Characters.Handling.To_Wide_String (Context)); else Lc := Mapcodes.Languages.Default_Language; end if; if Lm /= Mapcodes.Languages.Default_Language or else Lc /= Mapcodes.Languages.Default_Language then raise Decode_Error; end if; exception when Mapcodes.Languages.Invalid_Text => raise Decode_Error; end; -- Set context number if Context = Undefined then Contextterritorynumber := Ccode_Earth; else Contextterritorynumber := Integer (Get_Territory (Context)); end if; -- Decode return Master_Decode (Mapcode, Contextterritorynumber); end Decode; end Mapcodes;
reznikmm/matreshka
Ada
4,117
ads
------------------------------------------------------------------------------ -- -- -- Matreshka Project -- -- -- -- Open Document Toolkit -- -- -- -- Runtime Library Component -- -- -- ------------------------------------------------------------------------------ -- -- -- Copyright © 2014, Vadim Godunko <[email protected]> -- -- All rights reserved. -- -- -- -- Redistribution and use in source and binary forms, with or without -- -- modification, are permitted provided that the following conditions -- -- are met: -- -- -- -- * Redistributions of source code must retain the above copyright -- -- notice, this list of conditions and the following disclaimer. -- -- -- -- * Redistributions in binary form must reproduce the above copyright -- -- notice, this list of conditions and the following disclaimer in the -- -- documentation and/or other materials provided with the distribution. -- -- -- -- * Neither the name of the Vadim Godunko, IE nor the names of its -- -- contributors may be used to endorse or promote products derived from -- -- this software without specific prior written permission. -- -- -- -- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -- -- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -- -- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -- -- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -- -- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -- -- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED -- -- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -- -- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -- -- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -- -- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -- -- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- -- -- ------------------------------------------------------------------------------ -- $Revision$ $Date$ ------------------------------------------------------------------------------ with ODF.DOM.Fo_Hyphenation_Push_Char_Count_Attributes; package Matreshka.ODF_Fo.Hyphenation_Push_Char_Count_Attributes is type Fo_Hyphenation_Push_Char_Count_Attribute_Node is new Matreshka.ODF_Fo.Abstract_Fo_Attribute_Node and ODF.DOM.Fo_Hyphenation_Push_Char_Count_Attributes.ODF_Fo_Hyphenation_Push_Char_Count_Attribute with null record; overriding function Create (Parameters : not null access Matreshka.DOM_Attributes.Attribute_L2_Parameters) return Fo_Hyphenation_Push_Char_Count_Attribute_Node; overriding function Get_Local_Name (Self : not null access constant Fo_Hyphenation_Push_Char_Count_Attribute_Node) return League.Strings.Universal_String; end Matreshka.ODF_Fo.Hyphenation_Push_Char_Count_Attributes;
STR-UPM/ToyGS
Ada
2,994
adb
------------------------------------------------------------------------------ -- -- -- Copyright (C) 2017, Universidad Politécnica de Madrid -- -- -- -- Redistribution and use in source and binary forms, with or without -- -- modification, are permitted provided that the following conditions are -- -- met: -- -- 1. Redistributions of source code must retain the above copyright -- -- notice, this list of conditions and the following disclaimer. -- -- 2. Redistributions in binary form must reproduce the above copyright -- -- notice, this list of conditions and the following disclaimer in -- -- the documentation and/or other materials provided with the -- -- distribution. -- -- 3. Neither the name of the copyright holder nor the names of its -- -- contributors may be used to endorse or promote products derived -- -- from this software without specific prior written permission. -- -- -- -- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -- -- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -- -- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -- -- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -- -- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -- -- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -- -- LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -- -- DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -- -- THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -- -- (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -- -- OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- -- -- ------------------------------------------------------------------------------ -- Main procedure of toy ground station system - text terminal version with TM_Receiver; -- TheTM_Receiver package contains the telemetry reception subsystem with TC_Sender; -- The GS_TC package contains the telecommand transmission subsystem with User_Interface; use User_Interface; -- Graphic usser interface - based on gtkada pragma Warnings(Off); with System.IO; -- for debugging purposes pragma Warnings(On); procedure GS is begin pragma Debug(System.IO.Put_Line("--- GS start ---")); -- initialize components TM_Receiver.Init; TC_Sender.Init; User_Interface.Init; end GS;
NCommander/dnscatcher
Ada
1,201
ads
-- 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. package DNSCatcher.Network.UDP is end DNSCatcher.Network.UDP;
jscparker/math_packages
Ada
2,424
ads
--------------------------------------------------------------------------- -- package Tridiagonal, symmetric matrix tridiagonalization -- Copyright (C) 2018 Jonathan S. Parker -- -- 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. --------------------------------------------------------------------------- -- package Tridiagonal -- -- Tridiagonalization of symmetric matrices, using Givens rotations. generic type Real is digits <>; type Index is range <>; type A_Matrix is array(Index, Index) of Real; package Tridiagonal is subtype C_Index is Index; subtype R_Index is Index; function Identity return A_Matrix; -- The symmetric input matrix A is transformed with similarity transformations: -- -- A_tridiagonal = Q_transpose * A * Q. -- -- The Q's are orthogonal matrices constructed from the products of -- 2 x 2 Givens matrices. -- Q matrix has the same shape as A. procedure Tridiagonalize (A : in out A_Matrix; Q : out A_Matrix; Starting_Col : in C_Index := C_Index'First; Final_Col : in C_Index := C_Index'Last; Initial_Q : in A_Matrix := Identity; Q_Matrix_Desired : in Boolean := True); -- Works only on Tridiagonal matrices, and returns silently if Mat_Size<3: procedure Lower_Diagonal_QR_Iteration (A : in out A_Matrix; Q : in out A_Matrix; Shift : in Real; Final_Shift_Col : in C_Index := C_Index'Last; Starting_Col : in C_Index := C_Index'First; Final_Col : in C_Index := C_Index'Last; Q_Matrix_Desired : in Boolean := True); end Tridiagonal;
seipy/ada-voxel-space-demo
Ada
181
ads
package Keyboard is type Key_Kind is (Up, Down, Left, Right, Forward, Backward, Esc); procedure Update; function Pressed (Key : Key_Kind) return Boolean; end Keyboard;
MinimSecure/unum-sdk
Ada
834
adb
-- Copyright 2008-2019 Free Software Foundation, Inc. -- -- This program is free software; you can redistribute it and/or modify -- it under the terms of the GNU General Public License as published by -- the Free Software Foundation; either version 3 of the License, or -- (at your option) any later version. -- -- This program is distributed in the hope that it will be useful, -- but WITHOUT ANY WARRANTY; without even the implied warranty of -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -- GNU General Public License for more details. -- -- You should have received a copy of the GNU General Public License -- along with this program. If not, see <http://www.gnu.org/licenses/>. package body Pck is procedure Do_Nothing (A : System.Address) is begin null; end Do_Nothing; end Pck;
stcarrez/ada-servlet
Ada
7,977
adb
----------------------------------------------------------------------- -- upload_servlet -- Servlet example to upload files on the server -- Copyright (C) 2012, 2015, 2018, 2022 Stephane Carrez -- Written by Stephane Carrez ([email protected]) -- -- Licensed under the Apache License, Version 2.0 (the "License"); -- you may not use this file except in compliance with the License. -- You may obtain a copy of the License at -- -- http://www.apache.org/licenses/LICENSE-2.0 -- -- Unless required by applicable law or agreed to in writing, software -- distributed under the License is distributed on an "AS IS" BASIS, -- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -- See the License for the specific language governing permissions and -- limitations under the License. ----------------------------------------------------------------------- with Ada.Streams; with Util.Streams.Pipes; with Util.Strings; with Servlet.Parts; package body Upload_Servlet is -- ------------------------------ -- Write the upload form page with an optional response message. -- ------------------------------ procedure Write (Response : in out Responses.Response'Class; Message : in String) is Output : Streams.Print_Stream := Response.Get_Output_Stream; begin Output.Write ("<html><head><title>Upload servlet example</title></head>" & "<style></style>" & "<body>" & "<h1>Upload files to identify them</h1>"); -- Display the response or some error. if Message /= "" then Output.Write ("<h2>" & Message & "</h2>"); end if; -- Render the form. If we have some existing Radius or Height -- use them to set the initial values. Output.Write ("<p>Identifies images, PDF, tar, tar.gz, zip</p>" & "<form method='post' enctype='multipart/form-data'>" & "<table>" & "<tr><td>File 1</td>" & "<td><input type='file' size='50' name='file1' maxlength='100000'/></td>" & "</tr><tr><td>File 2</td>" & "<td><input type='file' size='50' name='file2' maxlength='100000'/></td>" & "</tr><tr><td>File 3</td>" & "<td><input type='file' size='50' name='file3' maxlength='100000'/></td>" & "</tr>" & "<tr><td></td><td><input type='submit' value='Identify'></input></td></tr>" & "</table></form>" & "</body></html>"); Response.Set_Status (Responses.SC_OK); end Write; -- ------------------------------ -- Called by the servlet container when a GET request is received. -- Display the volume form page. -- ------------------------------ overriding procedure Do_Get (Server : in Servlet; Request : in out Requests.Request'Class; Response : in out Responses.Response'Class) is pragma Unreferenced (Server, Request); begin Write (Response, ""); end Do_Get; -- ------------------------------ -- Execute a command and write the result to the output stream. -- ------------------------------ procedure Execute (Command : in String; Output : in out Streams.Print_Stream) is use type Ada.Streams.Stream_Element_Offset; Proc : Util.Streams.Pipes.Pipe_Stream; Content : Ada.Streams.Stream_Element_Array (0 .. 1024); Pos : Ada.Streams.Stream_Element_Offset; begin Proc.Open (Command); loop Proc.Read (Into => Content, Last => Pos); exit when Pos < 0; Output.Write (Content (0 .. Pos)); end loop; Proc.Close; if Proc.Get_Exit_Status /= 0 then Output.Write ("Command '" & Command & "' exited with code " & Integer'Image (Proc.Get_Exit_Status)); end if; end Execute; -- ------------------------------ -- Guess a file type depending on a content type or a file name. -- ------------------------------ function Get_File_Type (Content_Type : in String; Name : in String) return File_Type is begin if Content_Type = "application/pdf" then return PDF; elsif Content_Type = "image/png" or else Content_Type = "image/jpeg" then return IMAGE; elsif Content_Type = "image/gif" then return IMAGE; elsif Content_Type = "application/zip" then return ZIP; end if; declare Ext_Pos : constant Natural := Util.Strings.Rindex (Name, '.'); begin if Ext_Pos > 0 then if Name (Ext_Pos .. Name'Last) = ".gz" or else Name (Ext_Pos .. Name'Last) = ".tgz" then return TAR_GZ; elsif Name (Ext_Pos .. Name'Last) = ".tar" then return TAR; elsif Name (Ext_Pos .. Name'Last) = ".jpg" or else Name (Ext_Pos .. Name'Last) = ".gif" or else Name (Ext_Pos .. Name'Last) = ".xbm" or else Name (Ext_Pos .. Name'Last) = ".png" then return IMAGE; elsif Name (Ext_Pos .. Name'Last) = ".zip" or else Name (Ext_Pos .. Name'Last) = ".jar" then return ZIP; elsif Name (Ext_Pos .. Name'Last) = ".pdf" then return PDF; end if; end if; return UNKNOWN; end; end Get_File_Type; -- ------------------------------ -- Called by the servlet container when a POST request is received. -- Receives the uploaded files and identify them using some external command. -- ------------------------------ overriding procedure Do_Post (Server : in Servlet; Request : in out Requests.Request'Class; Response : in out Responses.Response'Class) is pragma Unreferenced (Server); procedure Process_Part (Part : in Parts.Part'Class); Output : Streams.Print_Stream := Response.Get_Output_Stream; procedure Process_Part (Part : in Parts.Part'Class) is Name : constant String := Part.Get_Name; Content_Type : constant String := Part.Get_Content_Type; Path : constant String := Part.Get_Local_Filename; Kind : constant File_Type := Get_File_Type (Content_Type, Name); begin Output.Write ("<tr><td>Name: " & Name); Output.Write ("</td><td>Content_Type: " & Content_Type & "</td>"); Output.Write ("<td>Path: " & Path & "</td>"); Output.Write ("<td>Length: " & Natural'Image (Part.Get_Size) & "</td>"); Output.Write ("</tr><tr><td></td><td colspan='3'><pre>"); case Kind is when TAR_GZ => Execute ("tar tvzf " & Path, Output); when TAR => Execute ("tar tvf " & Path, Output); when IMAGE => Execute ("identify " & Path, Output); when ZIP => Execute ("zipinfo " & Path, Output); when PDF => Execute ("pdfinfo " & Path, Output); when others => Output.Write ("Unknown file type"); end case; Output.Write ("</pre></td></tr>"); end Process_Part; begin Response.Set_Content_Type ("text/html"); Output.Write ("<html><body>"); Output.Write ("<table style='width: 100%;'>"); for I in 1 .. Request.Get_Part_Count loop Request.Process_Part (I, Process_Part'Access); end loop; Output.Write ("<tr><td colspan='5'><a href='upload.html'>Upload new files</a></td></tr>"); Output.Write ("</table>"); Output.Write ("</body></html>"); end Do_Post; end Upload_Servlet;
reznikmm/matreshka
Ada
4,833
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.Extends.Collections is pragma Preelaborate; package UML_Extend_Collections is new AMF.Generic_Collections (UML_Extend, UML_Extend_Access); type Set_Of_UML_Extend is new UML_Extend_Collections.Set with null record; Empty_Set_Of_UML_Extend : constant Set_Of_UML_Extend; type Ordered_Set_Of_UML_Extend is new UML_Extend_Collections.Ordered_Set with null record; Empty_Ordered_Set_Of_UML_Extend : constant Ordered_Set_Of_UML_Extend; type Bag_Of_UML_Extend is new UML_Extend_Collections.Bag with null record; Empty_Bag_Of_UML_Extend : constant Bag_Of_UML_Extend; type Sequence_Of_UML_Extend is new UML_Extend_Collections.Sequence with null record; Empty_Sequence_Of_UML_Extend : constant Sequence_Of_UML_Extend; private Empty_Set_Of_UML_Extend : constant Set_Of_UML_Extend := (UML_Extend_Collections.Set with null record); Empty_Ordered_Set_Of_UML_Extend : constant Ordered_Set_Of_UML_Extend := (UML_Extend_Collections.Ordered_Set with null record); Empty_Bag_Of_UML_Extend : constant Bag_Of_UML_Extend := (UML_Extend_Collections.Bag with null record); Empty_Sequence_Of_UML_Extend : constant Sequence_Of_UML_Extend := (UML_Extend_Collections.Sequence with null record); end AMF.UML.Extends.Collections;
charlie5/aIDE
Ada
1,598
ads
with Ada.Streams; package AdaM.a_Type.floating_point_type is type Item is new a_Type.real_Type with private; type View is access all Item'Class; -- Forge -- function new_Type (Name : in String := "") return floating_point_type.view; overriding procedure destruct (Self : in out Item); procedure free (Self : in out floating_point_type.view); -- Attributes -- overriding function Id (Self : access Item) return AdaM.Id; overriding function to_Source (Self : in Item) return text_Vectors.Vector; function my_Digits (Self : in Item) return Positive; procedure Digits_are (Self : in out Item; Now : in Positive); function First (Self : in Item) return long_long_Float; procedure First_is (Self : in out Item; Now : in long_long_Float); function Last (Self : in Item) return long_long_Float; procedure Last_is (Self : in out Item; Now : in long_long_Float); private type Item is new a_Type.real_Type with record my_Digits : Positive := 1; First : long_long_Float; Last : long_long_Float; end record; -- Streams -- procedure View_write (Stream : not null access Ada.Streams.Root_Stream_Type'Class; Self : in View); procedure View_read (Stream : not null access Ada.Streams.Root_Stream_Type'Class; Self : out View); for View'write use View_write; for View'read use View_read; end AdaM.a_Type.floating_point_type;
reznikmm/matreshka
Ada
3,973
ads
------------------------------------------------------------------------------ -- -- -- Matreshka Project -- -- -- -- Open Document Toolkit -- -- -- -- Runtime Library Component -- -- -- ------------------------------------------------------------------------------ -- -- -- Copyright © 2014, Vadim Godunko <[email protected]> -- -- All rights reserved. -- -- -- -- Redistribution and use in source and binary forms, with or without -- -- modification, are permitted provided that the following conditions -- -- are met: -- -- -- -- * Redistributions of source code must retain the above copyright -- -- notice, this list of conditions and the following disclaimer. -- -- -- -- * Redistributions in binary form must reproduce the above copyright -- -- notice, this list of conditions and the following disclaimer in the -- -- documentation and/or other materials provided with the distribution. -- -- -- -- * Neither the name of the Vadim Godunko, IE nor the names of its -- -- contributors may be used to endorse or promote products derived from -- -- this software without specific prior written permission. -- -- -- -- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -- -- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -- -- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -- -- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -- -- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -- -- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED -- -- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -- -- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -- -- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -- -- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -- -- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- -- -- ------------------------------------------------------------------------------ -- $Revision$ $Date$ ------------------------------------------------------------------------------ with ODF.DOM.Db_Precision_Attributes; package Matreshka.ODF_Db.Precision_Attributes is type Db_Precision_Attribute_Node is new Matreshka.ODF_Db.Abstract_Db_Attribute_Node and ODF.DOM.Db_Precision_Attributes.ODF_Db_Precision_Attribute with null record; overriding function Create (Parameters : not null access Matreshka.DOM_Attributes.Attribute_L2_Parameters) return Db_Precision_Attribute_Node; overriding function Get_Local_Name (Self : not null access constant Db_Precision_Attribute_Node) return League.Strings.Universal_String; end Matreshka.ODF_Db.Precision_Attributes;
clairvoyant/anagram
Ada
2,392
ads
-- Copyright (c) 2010-2017 Maxim Reznik <[email protected]> -- -- SPDX-License-Identifier: MIT -- License-Filename: LICENSE ------------------------------------------------------------- with Anagram.Abstract_Sources; with League.Strings; with Anagram.Grammars.Scanner_Handlers; with Ag_Tokens; with Anagram.Grammars.Scanner_Types; use Anagram.Grammars.Scanner_Types; package Anagram.Grammars.Scanners is subtype Token is Ag_Tokens.Token; type Scanner is tagged limited private; procedure Set_Source (Self : in out Scanner'Class; Source : not null Anagram.Abstract_Sources.Source_Access); procedure Set_Handler (Self : in out Scanner'Class; Handler : not null Anagram.Grammars.Scanner_Handlers.Handler_Access); subtype Start_Condition is State; procedure Set_Start_Condition (Self : in out Scanner'Class; Condition : Start_Condition); function Get_Start_Condition (Self : Scanner'Class) return Start_Condition; procedure Get_Token (Self : access Scanner'Class; Result : out Token); function Get_Text (Self : Scanner'Class) return League.Strings.Universal_String; function Get_Token_Length (Self : Scanner'Class) return Positive; function Get_Token_Position (Self : Scanner'Class) return Positive; private Buffer_Half_Size : constant := 2048; subtype Buffer_Index is Positive range 1 .. 2 * Buffer_Half_Size; type Character_Class_Array is array (Buffer_Index) of Character_Class; Error_Character : constant Character_Class := 0; Error_State : constant State := State'Last; type Buffer_Half is (Low, High); type Buffer_Offset is array (Buffer_Half) of Natural; type Scanner is tagged limited record Handler : Anagram.Grammars.Scanner_Handlers.Handler_Access; Source : Anagram.Abstract_Sources.Source_Access; Start : State := INITIAL; Next : Buffer_Index := 1; From : Buffer_Index := 1; To : Natural := 0; Rule : Scanner_Types.Rule_Index; Offset : Buffer_Offset := (0, 0); Buffer : Wide_Wide_String (Buffer_Index) := (1 => Wide_Wide_Character'Val (Anagram.Abstract_Sources.End_Of_Buffer), others => <>); Classes : Character_Class_Array := (1 => Error_Character, others => <>); end record; procedure Read_Buffer (Self : in out Scanner'Class); end Anagram.Grammars.Scanners;
dan76/Amass
Ada
3,079
ads
-- Copyright © by Jeff Foley 2017-2023. All rights reserved. -- Use of this source code is governed by Apache 2 LICENSE that can be found in the LICENSE file. -- SPDX-License-Identifier: Apache-2.0 local json = require("json") name = "IPinfo" type = "api" function start() set_rate_limit(1) end function check() local c local cfg = datasrc_config() if (cfg ~= nil) then c = cfg.credentials end if (c ~= nil and c.key ~= nil and c.key ~= "") then return true end return false end function asn(ctx, addr, asn) local c local cfg = datasrc_config() if (cfg ~= nil) then c = cfg.credentials end if (c == nil or c.key == nil or c.key == "") then return end local prefix if (asn == 0) then if (addr == "") then return end asn, prefix = get_asn(ctx, addr, cfg.ttl, c.key) if (asn == 0) then return end end local a = as_info(ctx, asn, cfg.ttl, c.key) if (a == nil) then return end new_asn(ctx, { ['addr']=addr, ['asn']=asn, ['prefix']=prefix, ['cc']=a.cc, ['registry']=a.registry, ['desc']=a.desc, ['netblocks']=a.netblocks, }) end function get_asn(ctx, addr, ttl, token) local u = "https://ipinfo.io/" .. addr .. "/asn?token=" .. token local resp, err = request(ctx, {['url']=u}) if (err ~= nil and err ~= "") then log(ctx, "get_asn request to service failed: " .. err) return 0, "" elseif (resp.status_code < 200 or resp.status_code >= 400) then log(ctx, "get_asn request to service returned with status: " .. resp.status) return 0, "" end local d = json.decode(resp.body) if (d == nil) then log(ctx, "failed to decode the JSON response") return 0, "" elseif (d.error ~= nil or d.asn == nil) then return 0, "" end return tonumber(string.sub(d.asn, 3)), d.route end function as_info(ctx, asn, ttl, token) local strasn = "AS" .. tostring(asn) local u = "https://ipinfo.io/" .. strasn .. "/json?token=" .. token local resp, err = request(ctx, {['url']=u}) if (err ~= nil and err ~= "") then log(ctx, "as_info request to service failed: " .. err) return nil elseif (resp.status_code < 200 or resp.status_code >= 400) then log(ctx, "as_info request to service returned with status: " .. resp.status) return nil end local d = json.decode(resp.body) if (d == nil) then log(ctx, "failed to decode the JSON response") return nil elseif (d.asn == nil or d.asn ~= strasn) then return nil end local netblocks = {} for _, p in pairs(d.prefixes) do table.insert(netblocks, p.netblock) end for _, p in pairs(d.prefixes6) do table.insert(netblocks, p.netblock) end return { ['desc']=d.name, ['cc']=d.country, ['registry']=d.registry, ['netblocks']=netblocks, } end
strenkml/EE368
Ada
340
adb
with Memory.Trace; separate (Parser) procedure Parse_Trace(parser : in out Parser_Type; result : out Memory_Pointer) is mem : Memory_Pointer := null; begin if Get_Type(parser) = Open then Parse_Memory(parser, mem); end if; result := Memory_Pointer(Trace.Create_Trace(mem)); end Parse_Trace;
io7m/coreland-postgres-ada
Ada
3,561
adb
------------------------------------------------------------------------------ -- -- -- P G A D A . S Y N T A X -- -- -- -- B o d y -- -- -- -- Copyright (c) Samuel Tardieu 2000 -- -- All rights reserved. -- -- -- -- Redistribution and use in source and binary forms, with or without -- -- modification, are permitted provided that the following conditions -- -- are met: -- -- 1. Redistributions of source code must retain the above copyright -- -- notice, this list of conditions and the following disclaimer. -- -- 2. Redistributions in binary form must reproduce the above copyright -- -- notice, this list of conditions and the following disclaimer in -- -- the documentation and/or other materials provided with the -- -- distribution. -- -- 3. Neither the name of Samuel Tardieu 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 SAMUEL TARDIEU 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 SAMUEL -- -- TARDIEU 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. -- -- -- ------------------------------------------------------------------------------ package body PGAda.Syntax is ------------ -- Escape -- ------------ function Escape (S : String) return String is Result : String (1 .. S'Length * 2); Last : Natural := 0; begin for I in S'Range loop if S (I) = ''' then Last := Last + 1; Result (Last) := '''; end if; Last := Last + 1; Result (Last) := S (I); end loop; return ''' & Result (1 .. Last) & '''; end Escape; ----------- -- Image -- ----------- function Image (I : Integer) return String is S : constant String := Integer'Image (I); begin if S (1) = ' ' then return S (1 .. S'Last); else return S; end if; end Image; end PGAda.Syntax;
tum-ei-rcs/StratoX
Ada
14,524
adb
------------------------------------------------------------------------------ -- -- -- GNAT RUN-TIME LIBRARY (GNARL) COMPONENTS -- -- -- -- S Y S T E M . B B . T I M I N G _ E V E N T S -- -- -- -- B o d y -- -- -- -- Copyright (C) 2011-2016, AdaCore -- -- -- -- GNARL is free software; you can redistribute it and/or modify it under -- -- terms of the GNU General Public License as published by the Free Soft- -- -- ware Foundation; either version 3, or (at your option) any later ver- -- -- sion. GNARL is distributed in the hope that it will be useful, but WITH- -- -- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY -- -- or FITNESS FOR A PARTICULAR PURPOSE. -- -- -- -- -- -- -- -- -- -- -- -- You should have received a copy of the GNU General Public License and -- -- a copy of the GCC Runtime Library Exception along with this program; -- -- see the files COPYING3 and COPYING.RUNTIME respectively. If not, see -- -- <http://www.gnu.org/licenses/>. -- -- -- ------------------------------------------------------------------------------ with System.BB.CPU_Primitives.Multiprocessors; with System.BB.Parameters; with System.BB.Protection; with System.BB.Threads; with System.BB.Threads.Queues; package body System.BB.Timing_Events is use type System.BB.Time.Time; use System.Multiprocessors; use System.BB.CPU_Primitives.Multiprocessors; use System.BB.Threads; Events_Table : array (CPU) of Timing_Event_Access := (others => null); -- One event list for each CPU procedure Insert (Event : not null Timing_Event_Access; Is_First : out Boolean) with -- Insert an event in the event list of the current CPU (Timeout order -- then FIFO). Is_First is set to True when Event becomes the next timing -- event to serve, False otherwise. Pre => -- The first element in the list (if it exists) cannot have a previous -- element. (if Events_Table (Current_CPU) /= null then Events_Table (Current_CPU).Prev = null) -- The event should be set and then Event.Handler /= null -- The event should not be already inserted in a list and then Event.Next = null and then Event.Prev = null -- Timing Events must always be handled by the same CPU and then (not System.BB.Parameters.Multiprocessor or else Event.CPU = Current_CPU), Post => -- Is_First is set to True when Event becomes the next timing event to -- serve (because the list was empty or the list contained only events -- with a later expiration time). (if Events_Table (Current_CPU) = Event then Is_First and then Event.all.Prev = null and then Event.all.Next = Events_Table'Old (Current_CPU) -- If the event is not first then the head of queue does not change else Events_Table (Current_CPU) = Events_Table'Old (Current_CPU) and then Event.all.Prev /= null) -- The queue cannot be empty after insertion and then Events_Table (Current_CPU) /= null -- The first element in the list can never have a previous element and then Events_Table (Current_CPU).Prev = null -- The queue is always ordered by expiration time and then FIFO and then (Event.all.Next = null or else Event.all.Next.Timeout > Event.Timeout) and then (Event.all.Prev = null or else Event.all.Prev.Timeout <= Event.Timeout); procedure Extract (Event : not null Timing_Event_Access; Was_First : out Boolean) with -- Extract an event from the event list of the current CPU. Was_First is -- True when we extract the event that was first in the queue, else False. Pre => -- There must be at least one element in the queue Events_Table (Current_CPU) /= null -- The first element in the list can never have a previous element and then Events_Table (Current_CPU).Prev = null -- The first element has Prev equal to null, but the others have Prev -- pointing to another timing event. and then (if Event /= Events_Table (Current_CPU) then Event.Prev /= null) -- The queue is always ordered by expiration time and then FIFO and then (Event.Next = null or else Event.Next.Timeout >= Event.Timeout) and then (Event.Prev = null or else Event.Prev.Timeout <= Event.Timeout) -- Timing Events must always be handled by the same CPU and then (not System.BB.Parameters.Multiprocessor or else Event.CPU = Current_CPU), Post => -- Was_First is set to True when we extract the event that was first -- in the queue. (if Events_Table'Old (Current_CPU) = Event then Events_Table (Current_CPU) /= Events_Table'Old (Current_CPU) and then Was_First) -- The first element in the list (if it exists) cannot have a -- previous element. and then (if Events_Table (Current_CPU) /= null then Events_Table (Current_CPU).Prev = null) -- The Prev and Next pointers are set to null to indicate that the -- event is no longer in the list. and then Event.all.Prev = null and then Event.all.Next = null; ----------------- -- Set_Handler -- ----------------- procedure Set_Handler (Event : in out Timing_Event; At_Time : System.BB.Time.Time; Handler : Timing_Event_Handler) is Next_Alarm : System.BB.Time.Time; CPU_Id : constant CPU := Current_CPU; Was_First : Boolean := False; Is_First : Boolean := False; begin if Event.Handler /= null then -- Extract if the event is already set Extract (Event'Unchecked_Access, Was_First); end if; Event.Handler := Handler; if Handler /= null then -- Update event fields Event.Timeout := At_Time; Event.CPU := CPU_Id; -- Insert event in the list Insert (Event'Unchecked_Access, Is_First); end if; if Was_First or else Is_First then -- Set the timer for the next alarm Next_Alarm := Time.Get_Next_Timeout (CPU_Id); Time.Update_Alarm (Next_Alarm); end if; -- The following pragma cannot be transformed into a post-condition -- because the call to Leave_Kernel is a dispatching operation and the -- status of the timing event handler may change (if may expire, for -- example). pragma Assert ((if Handler = null then -- If Handler is null the event is cleared Event.Handler = null else -- If Handler is not null then the timing event handler is set, -- and the execution time for the event is set to At_Time in the -- current CPU. Next timeout events can never be later than the -- event that we have just inserted. Event.Handler = Handler and then Event.Timeout = At_Time and then Time.Get_Next_Timeout (CPU_Id) <= At_Time)); end Set_Handler; --------------------- -- Current_Handler -- --------------------- function Current_Handler (Event : Timing_Event) return Timing_Event_Handler is begin return Event.Handler; end Current_Handler; -------------------- -- Cancel_Handler -- -------------------- procedure Cancel_Handler (Event : in out Timing_Event; Cancelled : out Boolean) is Next_Alarm : System.BB.Time.Time; CPU_Id : constant CPU := Current_CPU; Was_First : Boolean; begin if Event.Handler /= null then -- Extract if the event is already set Extract (Event'Unchecked_Access, Was_First); Cancelled := True; Event.Handler := null; if Was_First then Next_Alarm := Time.Get_Next_Timeout (CPU_Id); Time.Update_Alarm (Next_Alarm); end if; else Cancelled := False; end if; pragma Assert (Event.Handler = null); end Cancel_Handler; ----------------------------------- -- Execute_Expired_Timing_Events -- ----------------------------------- procedure Execute_Expired_Timing_Events (Now : System.BB.Time.Time) is CPU_Id : constant CPU := Current_CPU; Event : Timing_Event_Access := Events_Table (CPU_Id); Handler : Timing_Event_Handler; Was_First : Boolean; Self_Id : Thread_Id; Caller_Priority : Integer; begin -- Fast path: no timing event if Event = null then return; end if; -- As required by RM D.15 (14/2), timing events must be executed at -- the highest priority (Interrupt_Priority'Last). This is ensured by -- executing this part at the highest interrupt priority (and not at the -- one corresponding to the timer hardware interrupt). At the end of the -- execution of any timing event handler the priority that is restored -- is that of the alarm handler. If this part of the alarm handler -- executes at a priority lower than Interrupt_Priority'Last then -- the protection of the queues would not be guaranteed. Self_Id := Thread_Self; Caller_Priority := Get_Priority (Self_Id); Queues.Change_Priority (Self_Id, Interrupt_Priority'Last); -- Extract and execute all the expired timing events while Event /= null and then Event.Timeout <= Now loop -- Get handler Handler := Event.Handler; pragma Assert (Handler /= null); -- Extract first event from the list Extract (Event, Was_First); pragma Assert (Was_First); -- Clear the event. Do it before executing the handler before the -- timing event can be reinserted in the handler. Event.Handler := null; -- Execute the handler Handler (Event.all); Event := Events_Table (CPU_Id); end loop; Queues.Change_Priority (Self_Id, Caller_Priority); -- No more events to handle with an expiration time before Now pragma Assert (Events_Table (CPU_Id) = null or else Events_Table (CPU_Id).Timeout > Now); end Execute_Expired_Timing_Events; ---------------------- -- Get_Next_Timeout -- ---------------------- function Get_Next_Timeout (CPU_Id : System.Multiprocessors.CPU) return System.BB.Time.Time is Event : constant Timing_Event_Access := Events_Table (CPU_Id); begin if Event = null then return System.BB.Time.Time'Last; else return Event.all.Timeout; end if; end Get_Next_Timeout; ------------------- -- Time_Of_Event -- ------------------- function Time_Of_Event (Event : Timing_Event) return System.BB.Time.Time is begin if Event.Handler = null then return System.BB.Time.Time'First; else return Event.Timeout; end if; end Time_Of_Event; ------------- -- Extract -- ------------- procedure Extract (Event : not null Timing_Event_Access; Was_First : out Boolean) is CPU_Id : constant CPU := Current_CPU; begin -- Head extraction if Events_Table (CPU_Id) = Event then Was_First := True; Events_Table (CPU_Id) := Event.Next; -- Middle or tail extraction else pragma Assert (Event.Prev /= null); Was_First := False; Event.Prev.Next := Event.Next; end if; if Event.Next /= null then Event.Next.Prev := Event.Prev; end if; Event.Next := null; Event.Prev := null; end Extract; ------------- -- Insert -- ------------- procedure Insert (Event : not null Timing_Event_Access; Is_First : out Boolean) is CPU_Id : constant CPU := Current_CPU; Aux_Pointer : Timing_Event_Access; begin -- Insert at the head if there is no other events with a smaller timeout if Events_Table (CPU_Id) = null or else Events_Table (CPU_Id).Timeout > Event.Timeout then Is_First := True; Event.Next := Events_Table (CPU_Id); if Events_Table (CPU_Id) /= null then Events_Table (CPU_Id).Prev := Event; end if; Events_Table (CPU_Id) := Event; -- Middle or tail insertion else pragma Assert (Events_Table (CPU_Id) /= null); Is_First := False; Aux_Pointer := Events_Table (CPU_Id); while Aux_Pointer.Next /= null and then Aux_Pointer.Next.Timeout <= Event.Timeout loop Aux_Pointer := Aux_Pointer.Next; end loop; -- Insert after the Aux_Pointer Event.Next := Aux_Pointer.Next; Event.Prev := Aux_Pointer; if Aux_Pointer.Next /= null then Aux_Pointer.Next.Prev := Event; end if; Aux_Pointer.Next := Event; end if; end Insert; end System.BB.Timing_Events;
zenharris/ada-bbs
Ada
8,538
ads
-- This package implements the main object used by the library, as -- well as several functions to manipulate it. with GNAT.Sockets; with GNAT.Regpat; with Ada.Strings.Unbounded; with Ada.Containers.Vectors; with Irc.Message; private with Ada.Streams; private with Ada.Characters.Latin_1; private with Ada.Characters.Handling; package Irc.Bot is package SU renames Ada.Strings.Unbounded; use type SU.Unbounded_String; use Ada.Containers; package Unbounded_Vector is new Vectors (Natural, SU.Unbounded_String); -- Irc.Bot.Connection is the main record that is used for the -- creation of bots. type Connection is tagged private; -- Contains various attributes of the Connection's current nick. type Nick_Attributes is record Nick : SU.Unbounded_String := SU.To_Unbounded_String ("adairc"); Realname : SU.Unbounded_String := SU.To_Unbounded_String ("adairc"); Password : SU.Unbounded_String; end record; -- Used for bot command callbacks type Command_Proc is access procedure (Conn : in out Connection; Msg : Message.Message); ----------------------------------- -- Irc.Bot.Connection Creation -- ----------------------------------- function Create (Server : String; Port : GNAT.Sockets.Port_Type; Nick : String := "adairc") return Connection; procedure Connect (Conn : in out Connection); procedure Disconnect (Conn : in out Connection); ---------------------------- -- Sending IRC commands -- ---------------------------- -- Any function or procedure that sends or receives from the IRC -- server will raise an Irc.Bot.Not_Connected error if the -- Connection is not currently active. -- Sends a standard start-up identify sequence (specifically, NICK -- followed by USER). This may be expanded in the future to -- auto-identify with Nickserv, but for now, when this is desired, -- run Command with the proper arguments. procedure Identify (This : Connection); -- Sends a PRIVMSG command to the specified nick or channel with -- the given message. procedure Privmsg (This : Connection; Chan_Or_Nick, Message : String); -- Joins the specified channel. No error checking is done to make -- sure the channel name is valid, so if you want to guarantee -- that the bot successfully joins, add a handler for the IRC -- protocol's "no such channel" error. procedure Join (This : Connection; Channel : String); -- Generic method of sending a command to the IRC server. Sends to -- the server the command and args joined by a single space procedure Command (This : Connection; Cmd, Args : String); -- Given a string, this function will append a CRLF and send the -- line to the server as-is. In most cases, the Command procedure -- would be better for this, but could potentially be used in -- special cases. procedure Send_Line (This : Connection; Line : String); -- Like the Send_Line procedure, but does not append a CRLF to the -- message. procedure Send_Raw (This : Connection; Raw : String); ----------------------------------- -- Reading from the IRC server -- ----------------------------------- procedure Read_Line (This : Connection; Buffer : out SU.Unbounded_String); ------------------------------- -- Adding command handlers -- ------------------------------- -- Irc.Bot.Connection's main functionality and extensibility comes -- from the callbacks given to it, which can either be strings or -- regular expressions. Commands are evaluated in sequence, -- meaning that if multiple commands match a specified string or -- regular expression, they will each be run in the order they are -- given. -- Adds a command that will be called whenever the provided -- message is received. For PRIVMSG commands, see On_Privmsg. procedure On_Message (This : in out Connection; OnMsg : String; Func : Command_Proc); -- Allows the creation of a command triggered by a regular -- expression, the given string is interpreted as a regular -- expression and added. procedure On_Regexp (This : in out Connection; OnRegexp : String; Func : Command_Proc); -- Allows a more customized regular expression to be used for a -- command (using case insensitivity, for example) procedure On_Regexp (This : in out Connection; OnRegexp : GNAT.Regpat.Pattern_Matcher; Func : Command_Proc); -- Add a callback to be Called whenever a PRIVMSG content matches -- the regular expression "^OnMsg". procedure On_Privmsg (This : in out Connection; OnMsg : String; Func : Command_Proc); ---------------------- -- Other commands -- ---------------------- -- Loops through commands, calling ones that apply to the given -- message. procedure Do_Message (This : in out Connection; Msg : Message.Message); -- Checks if a given nick or hostname is considered an admin by -- the admins set through the Add_Administrator procedure. function Is_Admin (Conn : in Connection; Sender : SU.Unbounded_String) return Boolean; ----------------------------------------------- -- Attribute accessors procedures/functions -- ----------------------------------------------- function Get_Attributes (Conn : in Connection) return Nick_Attributes; pragma Inline (Get_Attributes); procedure Set_Attributes (Conn : in out Connection; Nick : Nick_Attributes); function Get_Administrators (Conn : in Connection) return Unbounded_Vector.Vector; function Get_Default_Channels (Conn : in Connection) return Unbounded_Vector.Vector; -- Adds a new administrator to check against (for use with the -- Is_Admin function) procedure Add_Administrator (Conn : in out Connection; Admin : String); procedure Add_Administrator (Conn : in out Connection; Admin : SU.Unbounded_String); -- Adds a channel to be joined when a 001 is received from the -- server (when the default command set from Irc.Commands has been -- installed on the bot) procedure Add_Default_Channel (Conn : in out Connection; Channel : String); procedure Add_Default_Channel (Conn : in out Connection; Channel : SU.Unbounded_String); ------------------ -- Exceptions -- ------------------ Socket_Read_Error : exception; Not_Connected : exception; --------------------------- -- Private declarations -- --------------------------- private package Regexp renames GNAT.Regpat; CRLF : constant String := Ada.Characters.Latin_1.CR & Ada.Characters.Latin_1.LF; -- Provides a simple runtime check to guarantee that the -- given Connection is active before trying to send / receive. -- raises Not_Connected unless the connection is active. procedure Should_Be_Connected (This : Connection); procedure Privmsg_Command_Hook (This : in out Connection; Msg : Message.Message); type Command_Pair is record Func : Command_Proc; Regex : Regexp.Pattern_Matcher (1024); end record; package Command_Vector is new Vectors (Natural, Command_Pair); type Connection is tagged record Sock : GNAT.Sockets.Socket_Type; Address : GNAT.Sockets.Sock_Addr_Type; Connected : Boolean := False; Nick : Nick_Attributes; Commands : Command_Vector.Vector; Privmsg_Commands : Command_Vector.Vector; Administrators : Unbounded_Vector.Vector; Default_Channels : Unbounded_Vector.Vector; end record; end Irc.Bot;
reznikmm/matreshka
Ada
7,824
ads
------------------------------------------------------------------------------ -- -- -- Matreshka Project -- -- -- -- Web Framework -- -- -- -- Runtime Library Component -- -- -- ------------------------------------------------------------------------------ -- -- -- Copyright © 2014-2018, Vadim Godunko <[email protected]> -- -- All rights reserved. -- -- -- -- Redistribution and use in source and binary forms, with or without -- -- modification, are permitted provided that the following conditions -- -- are met: -- -- -- -- * Redistributions of source code must retain the above copyright -- -- notice, this list of conditions and the following disclaimer. -- -- -- -- * Redistributions in binary form must reproduce the above copyright -- -- notice, this list of conditions and the following disclaimer in the -- -- documentation and/or other materials provided with the distribution. -- -- -- -- * Neither the name of the Vadim Godunko, IE nor the names of its -- -- contributors may be used to endorse or promote products derived from -- -- this software without specific prior written permission. -- -- -- -- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -- -- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -- -- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -- -- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -- -- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -- -- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED -- -- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -- -- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -- -- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -- -- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -- -- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- -- -- ------------------------------------------------------------------------------ -- $Revision$ $Date$ ------------------------------------------------------------------------------ private with Ada.Containers.Hashed_Maps; private with Ada.Containers.Vectors; private with League.Strings.Hash; private with Servlet.Context_Listeners; with Servlet.Contexts; private with Servlet.Event_Listeners; private with Servlet.Servlets; private with Servlet.Servlet_Registrations; with Spikedog.Servlet_Contexts; private with Spikedog.HTTP_Session_Managers; with Matreshka.Servlet_Dispatchers; with Matreshka.Servlet_HTTP_Requests; with Matreshka.Servlet_HTTP_Responses; with Matreshka.Servlet_Registrations; with Matreshka.Servlet_Servers; private with Matreshka.Spikedog_Deployment_Descriptors; package Matreshka.Servlet_Containers is type Servlet_Container is new Matreshka.Servlet_Dispatchers.Context_Dispatcher and Spikedog.Servlet_Contexts.Spikedog_Servlet_Context and Servlet.Contexts.Servlet_Context with private; type Servlet_Container_Access is access all Servlet_Container'Class; procedure Initialize (Self : not null access Servlet_Container'Class; Server : not null Matreshka.Servlet_Servers.Server_Access; Success : out Boolean); -- Initializes servlet container. Specified server object must be -- initialized. Sets Success to False on error during application -- loading/startup. procedure Finalize (Self : not null access Servlet_Container'Class); -- Finalizes servlet container. procedure Dispatch (Self : not null access Servlet_Container'Class; Request : not null Matreshka.Servlet_HTTP_Requests.HTTP_Servlet_Request_Access; Response : not null Matreshka.Servlet_HTTP_Responses.HTTP_Servlet_Response_Access); -- Dispatch request to filters/servlet. private type Container_States is (Uninitialized, Initialization, Initialized); package Servlet_Context_Listener_Vectors is new Ada.Containers.Vectors (Positive, Servlet.Context_Listeners.Servlet_Context_Listener_Access, Servlet.Context_Listeners."="); package Servlet_Registration_Maps is new Ada.Containers.Hashed_Maps (League.Strings.Universal_String, Matreshka.Servlet_Registrations.Servlet_Registration_Access, League.Strings.Hash, League.Strings."=", Matreshka.Servlet_Registrations."="); type Servlet_Container is new Matreshka.Servlet_Dispatchers.Context_Dispatcher and Spikedog.Servlet_Contexts.Spikedog_Servlet_Context and Servlet.Contexts.Servlet_Context with record Descriptor : Matreshka.Spikedog_Deployment_Descriptors.Deployment_Descriptor_Access; State : Container_States := Uninitialized; Context_Listeners : Servlet_Context_Listener_Vectors.Vector; Servlets : Servlet_Registration_Maps.Map; Session_Manager : Spikedog.HTTP_Session_Managers.HTTP_Session_Manager_Access; end record; overriding procedure Add_Listener (Self : not null access Servlet_Container; Listener : not null Servlet.Event_Listeners.Event_Listener_Access); overriding function Add_Servlet (Self : not null access Servlet_Container; Name : League.Strings.Universal_String; Instance : not null access Servlet.Servlets.Servlet'Class) return access Servlet.Servlet_Registrations.Servlet_Registration'Class; overriding function Get_MIME_Type (Self : Servlet_Container; Path : League.Strings.Universal_String) return League.Strings.Universal_String; -- Returns the MIME type of the specified file, or null if the MIME type is -- not known. The MIME type is determined by the configuration of the -- servlet container, and may be specified in a web application deployment -- descriptor. Common MIME types include text/html and image/gif. overriding function Get_Real_Path (Self : Servlet_Container; Path : League.Strings.Universal_String) return League.Strings.Universal_String; -- Gets the real path corresponding to the given virtual path. overriding function Get_Servlet_Registration (Self : not null access Servlet_Container; Servlet_Name : League.Strings.Universal_String) return access Servlet.Servlet_Registrations.Servlet_Registration'Class; overriding procedure Set_Session_Manager (Self : in out Servlet_Container; Manager : not null Spikedog.HTTP_Session_Managers.HTTP_Session_Manager_Access); end Matreshka.Servlet_Containers;
zhmu/ananas
Ada
246
adb
-- { dg-do run } -- { dg-options "-O" } procedure Opt89 is type Rec is record I : Integer := 3; end record; subtype Index is Natural range 0..0; type Arr is array (Index range <>) of Rec; X : Arr (0 .. -1); begin null; end;
1Crazymoney/LearnAda
Ada
14,046
ads
pragma Ada_95; with System; package ada_main is pragma Warnings (Off); gnat_argc : Integer; gnat_argv : System.Address; gnat_envp : System.Address; pragma Import (C, gnat_argc); pragma Import (C, gnat_argv); pragma Import (C, gnat_envp); gnat_exit_status : Integer; pragma Import (C, gnat_exit_status); GNAT_Version : constant String := "GNAT Version: GPL 2015 (20150428-49)" & ASCII.NUL; pragma Export (C, GNAT_Version, "__gnat_version"); Ada_Main_Program_Name : constant String := "_ada_lnko" & ASCII.NUL; pragma Export (C, Ada_Main_Program_Name, "__gnat_ada_main_program_name"); procedure adainit; pragma Export (C, adainit, "adainit"); procedure adafinal; pragma Export (C, adafinal, "adafinal"); function main (argc : Integer; argv : System.Address; envp : System.Address) return Integer; pragma Export (C, main, "main"); type Version_32 is mod 2 ** 32; u00001 : constant Version_32 := 16#b3735695#; pragma Export (C, u00001, "lnkoB"); u00002 : constant Version_32 := 16#fbff4c67#; pragma Export (C, u00002, "system__standard_libraryB"); u00003 : constant Version_32 := 16#f72f352b#; pragma Export (C, u00003, "system__standard_libraryS"); u00004 : constant Version_32 := 16#3ffc8e18#; pragma Export (C, u00004, "adaS"); u00005 : constant Version_32 := 16#f64b89a4#; pragma Export (C, u00005, "ada__integer_text_ioB"); u00006 : constant Version_32 := 16#f1daf268#; pragma Export (C, u00006, "ada__integer_text_ioS"); u00007 : constant Version_32 := 16#b612ca65#; pragma Export (C, u00007, "ada__exceptionsB"); u00008 : constant Version_32 := 16#1d190453#; pragma Export (C, u00008, "ada__exceptionsS"); u00009 : constant Version_32 := 16#a46739c0#; pragma Export (C, u00009, "ada__exceptions__last_chance_handlerB"); u00010 : constant Version_32 := 16#3aac8c92#; pragma Export (C, u00010, "ada__exceptions__last_chance_handlerS"); u00011 : constant Version_32 := 16#f4ce8c3a#; pragma Export (C, u00011, "systemS"); u00012 : constant Version_32 := 16#a207fefe#; pragma Export (C, u00012, "system__soft_linksB"); u00013 : constant Version_32 := 16#af945ded#; pragma Export (C, u00013, "system__soft_linksS"); u00014 : constant Version_32 := 16#b01dad17#; pragma Export (C, u00014, "system__parametersB"); u00015 : constant Version_32 := 16#8ae48145#; pragma Export (C, u00015, "system__parametersS"); u00016 : constant Version_32 := 16#b19b6653#; pragma Export (C, u00016, "system__secondary_stackB"); u00017 : constant Version_32 := 16#5faf4353#; pragma Export (C, u00017, "system__secondary_stackS"); u00018 : constant Version_32 := 16#39a03df9#; pragma Export (C, u00018, "system__storage_elementsB"); u00019 : constant Version_32 := 16#d90dc63e#; pragma Export (C, u00019, "system__storage_elementsS"); u00020 : constant Version_32 := 16#41837d1e#; pragma Export (C, u00020, "system__stack_checkingB"); u00021 : constant Version_32 := 16#7a71e7d2#; pragma Export (C, u00021, "system__stack_checkingS"); u00022 : constant Version_32 := 16#393398c1#; pragma Export (C, u00022, "system__exception_tableB"); u00023 : constant Version_32 := 16#5ad7ea2f#; pragma Export (C, u00023, "system__exception_tableS"); u00024 : constant Version_32 := 16#ce4af020#; pragma Export (C, u00024, "system__exceptionsB"); u00025 : constant Version_32 := 16#9cade1cc#; pragma Export (C, u00025, "system__exceptionsS"); u00026 : constant Version_32 := 16#37d758f1#; pragma Export (C, u00026, "system__exceptions__machineS"); u00027 : constant Version_32 := 16#b895431d#; pragma Export (C, u00027, "system__exceptions_debugB"); u00028 : constant Version_32 := 16#472c9584#; pragma Export (C, u00028, "system__exceptions_debugS"); u00029 : constant Version_32 := 16#570325c8#; pragma Export (C, u00029, "system__img_intB"); u00030 : constant Version_32 := 16#f6156cf8#; pragma Export (C, u00030, "system__img_intS"); u00031 : constant Version_32 := 16#b98c3e16#; pragma Export (C, u00031, "system__tracebackB"); u00032 : constant Version_32 := 16#6af355e1#; pragma Export (C, u00032, "system__tracebackS"); u00033 : constant Version_32 := 16#9ed49525#; pragma Export (C, u00033, "system__traceback_entriesB"); u00034 : constant Version_32 := 16#f4957a4a#; pragma Export (C, u00034, "system__traceback_entriesS"); u00035 : constant Version_32 := 16#8c33a517#; pragma Export (C, u00035, "system__wch_conB"); u00036 : constant Version_32 := 16#efb3aee8#; pragma Export (C, u00036, "system__wch_conS"); u00037 : constant Version_32 := 16#9721e840#; pragma Export (C, u00037, "system__wch_stwB"); u00038 : constant Version_32 := 16#c2a282e9#; pragma Export (C, u00038, "system__wch_stwS"); u00039 : constant Version_32 := 16#92b797cb#; pragma Export (C, u00039, "system__wch_cnvB"); u00040 : constant Version_32 := 16#e004141b#; pragma Export (C, u00040, "system__wch_cnvS"); u00041 : constant Version_32 := 16#6033a23f#; pragma Export (C, u00041, "interfacesS"); u00042 : constant Version_32 := 16#ece6fdb6#; pragma Export (C, u00042, "system__wch_jisB"); u00043 : constant Version_32 := 16#60740d3a#; pragma Export (C, u00043, "system__wch_jisS"); u00044 : constant Version_32 := 16#28f088c2#; pragma Export (C, u00044, "ada__text_ioB"); u00045 : constant Version_32 := 16#1a9b0017#; pragma Export (C, u00045, "ada__text_ioS"); u00046 : constant Version_32 := 16#10558b11#; pragma Export (C, u00046, "ada__streamsB"); u00047 : constant Version_32 := 16#2e6701ab#; pragma Export (C, u00047, "ada__streamsS"); u00048 : constant Version_32 := 16#db5c917c#; pragma Export (C, u00048, "ada__io_exceptionsS"); u00049 : constant Version_32 := 16#12c8cd7d#; pragma Export (C, u00049, "ada__tagsB"); u00050 : constant Version_32 := 16#ce72c228#; pragma Export (C, u00050, "ada__tagsS"); u00051 : constant Version_32 := 16#c3335bfd#; pragma Export (C, u00051, "system__htableB"); u00052 : constant Version_32 := 16#700c3fd0#; pragma Export (C, u00052, "system__htableS"); u00053 : constant Version_32 := 16#089f5cd0#; pragma Export (C, u00053, "system__string_hashB"); u00054 : constant Version_32 := 16#d25254ae#; pragma Export (C, u00054, "system__string_hashS"); u00055 : constant Version_32 := 16#699628fa#; pragma Export (C, u00055, "system__unsigned_typesS"); u00056 : constant Version_32 := 16#b44f9ae7#; pragma Export (C, u00056, "system__val_unsB"); u00057 : constant Version_32 := 16#793ec5c1#; pragma Export (C, u00057, "system__val_unsS"); u00058 : constant Version_32 := 16#27b600b2#; pragma Export (C, u00058, "system__val_utilB"); u00059 : constant Version_32 := 16#586e3ac4#; pragma Export (C, u00059, "system__val_utilS"); u00060 : constant Version_32 := 16#d1060688#; pragma Export (C, u00060, "system__case_utilB"); u00061 : constant Version_32 := 16#d0c7e5ed#; pragma Export (C, u00061, "system__case_utilS"); u00062 : constant Version_32 := 16#84a27f0d#; pragma Export (C, u00062, "interfaces__c_streamsB"); u00063 : constant Version_32 := 16#8bb5f2c0#; pragma Export (C, u00063, "interfaces__c_streamsS"); u00064 : constant Version_32 := 16#845f5a34#; pragma Export (C, u00064, "system__crtlS"); u00065 : constant Version_32 := 16#431faf3c#; pragma Export (C, u00065, "system__file_ioB"); u00066 : constant Version_32 := 16#53bf6d5f#; pragma Export (C, u00066, "system__file_ioS"); u00067 : constant Version_32 := 16#b7ab275c#; pragma Export (C, u00067, "ada__finalizationB"); u00068 : constant Version_32 := 16#19f764ca#; pragma Export (C, u00068, "ada__finalizationS"); u00069 : constant Version_32 := 16#95817ed8#; pragma Export (C, u00069, "system__finalization_rootB"); u00070 : constant Version_32 := 16#bb3cffaa#; pragma Export (C, u00070, "system__finalization_rootS"); u00071 : constant Version_32 := 16#769e25e6#; pragma Export (C, u00071, "interfaces__cB"); u00072 : constant Version_32 := 16#4a38bedb#; pragma Export (C, u00072, "interfaces__cS"); u00073 : constant Version_32 := 16#ee0f26dd#; pragma Export (C, u00073, "system__os_libB"); u00074 : constant Version_32 := 16#d7b69782#; pragma Export (C, u00074, "system__os_libS"); u00075 : constant Version_32 := 16#1a817b8e#; pragma Export (C, u00075, "system__stringsB"); u00076 : constant Version_32 := 16#8a719d5c#; pragma Export (C, u00076, "system__stringsS"); u00077 : constant Version_32 := 16#09511692#; pragma Export (C, u00077, "system__file_control_blockS"); u00078 : constant Version_32 := 16#f6fdca1c#; pragma Export (C, u00078, "ada__text_io__integer_auxB"); u00079 : constant Version_32 := 16#b9793d30#; pragma Export (C, u00079, "ada__text_io__integer_auxS"); u00080 : constant Version_32 := 16#181dc502#; pragma Export (C, u00080, "ada__text_io__generic_auxB"); u00081 : constant Version_32 := 16#a6c327d3#; pragma Export (C, u00081, "ada__text_io__generic_auxS"); u00082 : constant Version_32 := 16#18d57884#; pragma Export (C, u00082, "system__img_biuB"); u00083 : constant Version_32 := 16#afb4a0b7#; pragma Export (C, u00083, "system__img_biuS"); u00084 : constant Version_32 := 16#e7d8734f#; pragma Export (C, u00084, "system__img_llbB"); u00085 : constant Version_32 := 16#ee73b049#; pragma Export (C, u00085, "system__img_llbS"); u00086 : constant Version_32 := 16#9777733a#; pragma Export (C, u00086, "system__img_lliB"); u00087 : constant Version_32 := 16#e581d9eb#; pragma Export (C, u00087, "system__img_lliS"); u00088 : constant Version_32 := 16#0e8808d4#; pragma Export (C, u00088, "system__img_llwB"); u00089 : constant Version_32 := 16#471f93df#; pragma Export (C, u00089, "system__img_llwS"); u00090 : constant Version_32 := 16#428b07f8#; pragma Export (C, u00090, "system__img_wiuB"); u00091 : constant Version_32 := 16#c1f52725#; pragma Export (C, u00091, "system__img_wiuS"); u00092 : constant Version_32 := 16#7ebd8839#; pragma Export (C, u00092, "system__val_intB"); u00093 : constant Version_32 := 16#bc6ba605#; pragma Export (C, u00093, "system__val_intS"); u00094 : constant Version_32 := 16#b3aa7b17#; pragma Export (C, u00094, "system__val_lliB"); u00095 : constant Version_32 := 16#6eea6a9a#; pragma Export (C, u00095, "system__val_lliS"); u00096 : constant Version_32 := 16#06052bd0#; pragma Export (C, u00096, "system__val_lluB"); u00097 : constant Version_32 := 16#13647f88#; pragma Export (C, u00097, "system__val_lluS"); u00098 : constant Version_32 := 16#2bce1226#; pragma Export (C, u00098, "system__memoryB"); u00099 : constant Version_32 := 16#adb3ea0e#; pragma Export (C, u00099, "system__memoryS"); -- BEGIN ELABORATION ORDER -- ada%s -- interfaces%s -- system%s -- system.case_util%s -- system.case_util%b -- system.htable%s -- system.img_int%s -- system.img_int%b -- system.img_lli%s -- system.img_lli%b -- system.parameters%s -- system.parameters%b -- system.crtl%s -- interfaces.c_streams%s -- interfaces.c_streams%b -- system.standard_library%s -- system.exceptions_debug%s -- system.exceptions_debug%b -- system.storage_elements%s -- system.storage_elements%b -- system.stack_checking%s -- system.stack_checking%b -- system.string_hash%s -- system.string_hash%b -- system.htable%b -- system.strings%s -- system.strings%b -- system.os_lib%s -- system.traceback_entries%s -- system.traceback_entries%b -- ada.exceptions%s -- system.soft_links%s -- system.unsigned_types%s -- system.img_biu%s -- system.img_biu%b -- system.img_llb%s -- system.img_llb%b -- system.img_llw%s -- system.img_llw%b -- system.img_wiu%s -- system.img_wiu%b -- system.val_int%s -- system.val_lli%s -- system.val_llu%s -- system.val_uns%s -- system.val_util%s -- system.val_util%b -- system.val_uns%b -- system.val_llu%b -- system.val_lli%b -- system.val_int%b -- system.wch_con%s -- system.wch_con%b -- system.wch_cnv%s -- system.wch_jis%s -- system.wch_jis%b -- system.wch_cnv%b -- system.wch_stw%s -- system.wch_stw%b -- ada.exceptions.last_chance_handler%s -- ada.exceptions.last_chance_handler%b -- system.exception_table%s -- system.exception_table%b -- ada.io_exceptions%s -- ada.tags%s -- ada.streams%s -- ada.streams%b -- interfaces.c%s -- system.exceptions%s -- system.exceptions%b -- system.exceptions.machine%s -- system.file_control_block%s -- system.file_io%s -- system.finalization_root%s -- system.finalization_root%b -- ada.finalization%s -- ada.finalization%b -- system.memory%s -- system.memory%b -- system.standard_library%b -- system.secondary_stack%s -- system.file_io%b -- interfaces.c%b -- ada.tags%b -- system.soft_links%b -- system.os_lib%b -- system.secondary_stack%b -- system.traceback%s -- ada.exceptions%b -- system.traceback%b -- ada.text_io%s -- ada.text_io%b -- ada.text_io.generic_aux%s -- ada.text_io.generic_aux%b -- ada.text_io.integer_aux%s -- ada.text_io.integer_aux%b -- ada.integer_text_io%s -- ada.integer_text_io%b -- lnko%b -- END ELABORATION ORDER end ada_main;
sungyeon/drake
Ada
9,198
adb
with System.Formatting; with System.Long_Long_Integer_Types; with System.Random_Initiators; with System.Storage_Elements; package body Ada.Numerics.MT19937 is use type Interfaces.Unsigned_32; use type System.Storage_Elements.Storage_Count; subtype Word_Unsigned is System.Long_Long_Integer_Types.Word_Unsigned; MATRIX_A : constant := 16#9908b0df#; UPPER_MASK : constant := 16#80000000#; -- 2 ** (32 - 1) LOWER_MASK : constant := 16#7fffffff#; -- not UPPER_MASK -- implementation function Random_32 (Gen : aliased in out Generator) return Unsigned_32 is pragma Suppress (Index_Check); pragma Suppress (Range_Check); mag01 : constant array (Unsigned_32 range 0 .. 1) of Unsigned_32 := (0, MATRIX_A); y : Unsigned_32; S : State renames Gen.State; begin if S.Condition >= N then for kk in 0 .. (N - M - 1) loop y := (S.Vector (kk) and UPPER_MASK) or (S.Vector (kk + 1) and LOWER_MASK); S.Vector (kk) := S.Vector (kk + M) xor Interfaces.Shift_Right (y, 1) xor mag01 (y and 1); end loop; for kk in (N - M) .. (N - 2) loop y := (S.Vector (kk) and UPPER_MASK) or (S.Vector (kk + 1) and LOWER_MASK); S.Vector (kk) := S.Vector (kk + (M - N)) xor Interfaces.Shift_Right (y, 1) xor mag01 (y and 1); end loop; y := (S.Vector (N - 1) and UPPER_MASK) or (S.Vector (0) and LOWER_MASK); S.Vector (N - 1) := S.Vector (M - 1) xor Interfaces.Shift_Right (y, 1) xor mag01 (y and 1); S.Condition := 0; end if; y := S.Vector (Integer (S.Condition)); S.Condition := S.Condition + 1; y := y xor Interfaces.Shift_Right (y, 11); y := y xor (Interfaces.Shift_Left (y, 7) and 16#9d2c5680#); y := y xor (Interfaces.Shift_Left (y, 15) and 16#efc60000#); y := y xor Interfaces.Shift_Right (y, 18); return y; end Random_32; function Initialize return Generator is begin return (State => Initialize); end Initialize; function Initialize (Initiator : Unsigned_32) return Generator is begin return (State => Initialize (Initiator)); end Initialize; function Initialize (Initiator : Unsigned_32_Array) return Generator is begin return (State => Initialize (Initiator)); end Initialize; procedure Reset (Gen : in out Generator) is begin Gen.State := Initialize; end Reset; procedure Reset (Gen : in out Generator; Initiator : Integer) is begin Gen.State := Initialize (Unsigned_32'Mod (Initiator)); end Reset; function Initialize return State is Init : aliased Unsigned_32_Array_N; begin System.Random_Initiators.Get ( Init'Address, Init'Size / Standard'Storage_Unit); return Initialize (Init); end Initialize; function Initialize (Initiator : Unsigned_32) return State is V : Unsigned_32 := Initiator; begin return Result : State do Result.Vector (0) := V; for I in 1 .. (N - 1) loop V := 1812433253 * (V xor Interfaces.Shift_Right (V, 30)) + Unsigned_32 (I); Result.Vector (I) := V; end loop; Result.Condition := N; end return; end Initialize; function Initialize (Initiator : Unsigned_32_Array) return State is Initiator_Length : constant Natural := Initiator'Length; i : Integer := 1; j : Integer := 0; begin return Result : State := Initialize (19650218) do if Initiator_Length > 0 then for K in reverse 1 .. Integer'Max (N, Initiator_Length) loop declare P : constant Unsigned_32 := Result.Vector (i - 1); begin Result.Vector (i) := (Result.Vector (i) xor ((P xor Interfaces.Shift_Right (P, 30)) * 1664525)) + Initiator (Initiator'First + j) + Unsigned_32 (j); end; i := i + 1; if i >= N then Result.Vector (0) := Result.Vector (N - 1); i := 1; end if; j := (j + 1) rem Positive'(Initiator_Length); end loop; for K in reverse 1 .. (N - 1) loop declare P : constant Unsigned_32 := Result.Vector (i - 1); begin Result.Vector (i) := (Result.Vector (i) xor ((P xor Interfaces.Shift_Right (P, 30)) * 1566083941)) - Unsigned_32 (i); end; i := i + 1; if i >= N then Result.Vector (0) := Result.Vector (N - 1); i := 1; end if; end loop; Result.Vector (0) := 16#80000000#; end if; end return; end Initialize; procedure Save (Gen : Generator; To_State : out State) is begin To_State := Gen.State; end Save; procedure Reset (Gen : in out Generator; From_State : State) is begin Gen.State := From_State; end Reset; function Reset (From_State : State) return Generator is begin return (State => From_State); end Reset; function Image (Of_State : State) return String is procedure Hex (Result : in out String; Value : Unsigned_32); procedure Hex (Result : in out String; Value : Unsigned_32) is Error : Boolean; Last : Natural; begin pragma Compile_Time_Error (Standard'Word_Size < 32, "word size < 32"); System.Formatting.Image ( Word_Unsigned (Value), Result, Last, Base => 16, Width => 32 / 4, Error => Error); pragma Assert (not Error and then Last = Result'Last); end Hex; Last : Natural := 0; begin return Result : String (1 .. Max_Image_Width) do for I in Unsigned_32_Array_N'Range loop declare Previous_Last : constant Natural := Last; begin Last := Last + 32 / 4; Hex (Result (Previous_Last + 1 .. Last), Of_State.Vector (I)); Last := Last + 1; Result (Last) := ':'; end; end loop; Hex (Result (Last + 1 .. Result'Last), Of_State.Condition); end return; end Image; function Value (Coded_State : String) return State is procedure Hex (Item : String; Value : out Unsigned_32); procedure Hex (Item : String; Value : out Unsigned_32) is Last : Positive; Error : Boolean; begin System.Formatting.Value ( Item, Last, Word_Unsigned (Value), Base => 16, Error => Error); if Error or else Last /= Item'Last then raise Constraint_Error; end if; end Hex; Last : Natural := Coded_State'First - 1; begin if Coded_State'Length /= Max_Image_Width then raise Constraint_Error; end if; return Result : State do for I in Unsigned_32_Array_N'Range loop declare Previous_Last : constant Natural := Last; begin Last := Last + 32 / 4; Hex ( Coded_State (Previous_Last + 1 .. Last), Result.Vector (I)); Last := Last + 1; if Coded_State (Last) /= ':' then raise Constraint_Error; end if; end; end loop; Hex (Coded_State (Last + 1 .. Coded_State'Last), Result.Condition); end return; end Value; function Random_0_To_1 (Gen : aliased in out Generator) return Uniformly_Distributed is begin return Uniformly_Distributed'Base (Random_32 (Gen)) * (1.0 / 4294967295.0); end Random_0_To_1; function Random_0_To_Less_Than_1 (Gen : aliased in out Generator) return Uniformly_Distributed is begin return Uniformly_Distributed'Base (Random_32 (Gen)) * (1.0 / 4294967296.0); end Random_0_To_Less_Than_1; function Random_Greater_Than_0_To_Less_Than_1 ( Gen : aliased in out Generator) return Uniformly_Distributed is begin return (Uniformly_Distributed'Base (Random_32 (Gen)) + 0.5) * (1.0 / 4294967296.0); end Random_Greater_Than_0_To_Less_Than_1; function Random_53_0_To_Less_Than_1 (Gen : aliased in out Generator) return Uniformly_Distributed is A : constant Unsigned_32 := Interfaces.Shift_Right (Random_32 (Gen), 5); B : constant Unsigned_32 := Interfaces.Shift_Right (Random_32 (Gen), 6); Float_A : constant Long_Long_Float := Uniformly_Distributed'Base (A); Float_B : constant Long_Long_Float := Uniformly_Distributed'Base (B); begin return (Float_A * 67108864.0 + Float_B) * (1.0 / 9007199254740992.0); end Random_53_0_To_Less_Than_1; end Ada.Numerics.MT19937;
annexi-strayline/ASAP-UUIDs
Ada
6,533
adb
------------------------------------------------------------------------------ -- -- -- Common UUID Handling Package -- -- - RFC 4122 Implementation - -- -- -- -- ------------------------------------------------------------------------ -- -- -- -- Version 4 (Random) UUID Generation Package -- -- -- -- ------------------------------------------------------------------------ -- -- -- -- Copyright (C) 2021 ANNEXI-STRAYLINE Trans-Human Ltd. -- -- All rights reserved. -- -- -- -- Original Contributors: -- -- * Richard Wai (ANNEXI-STRAYLINE) -- -- -- -- -- -- Redistribution and use in source and binary forms, with or without -- -- modification, are permitted provided that the following conditions are -- -- met: -- -- * Redistributions of source code must retain the above copyright -- -- notice, this list of conditions and the following disclaimer. -- -- -- -- * Redistributions in binary form must reproduce the above copyright -- -- notice, this list of conditions and the following disclaimer in -- -- the documentation and/or other materials provided with the -- -- distribution. -- -- -- -- * Neither the name of ANNEXI-STRAYLINE 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 ANNEXI-STRAYLINE -- -- 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 body UUIDs.Version_4 is -- State Management -- ---------------- -- Initialize -- ---------------- function Initialize (Seed: Natural) return Generator is begin return Gen: Generator do Gen_64.Reset (Gen => Gen.Gen, Initiator => Seed); end return; end; ---------------------------------------------------------------------- function Initialize (From_State: State) return Generator is begin return Gen: Generator do Gen_64.Reset (Gen => Gen.Gen, From_State => From_State.Gen_State); end return; end; ---------- -- Save -- ---------- procedure Save (Gen: in Generator; To_State: out State) is begin Gen_64.Save (Gen => Gen.Gen, To_State => To_State.Gen_State); end; ----------- -- Reset -- ----------- procedure Reset (Gen: in out Generator; Seed: in Integer) is begin Gen_64.Reset (Gen => Gen.Gen, Initiator => Seed); end; ---------------------------------------------------------------------- procedure Reset (Gen: in out Generator; From_State: in State) is begin Gen_64.Reset (Gen => Gen.Gen, From_State => From_State.Gen_State); end; ----------------- -- Random_UUID -- ----------------- function Random_UUID (Gen: Generator) return UUID is use Interfaces; Rand_Hi: Unsigned_64 := Gen_64.Random (Gen.Gen); Rand_Lo: Unsigned_64 := Gen_64.Random (Gen.Gen); ID: UUID; begin -- The basic strategy is to generate two 64-bit values, and them overlay -- them onto the UUID value, before editing the specific bits we need to -- as per RFC 4122 ID.time_low := Bitfield_32 (Rand_Hi and 16#ffff_ffff#); Rand_Hi := Shift_Right (Rand_Hi, 32); ID.time_mid := Bitfield_16 (Rand_Hi and 16#ffff#); Rand_Hi := Shift_Right (Rand_Hi, 16); -- Set the four most significant bits (bits 12 through 15) of the -- time_hi_and_version field to the 4-bit version number from -- Section 4.1.3. (2#0100# i.e. 4) ID.time_hi_and_version := Bitfield_16 (Rand_Hi and 16#0fff#); ID.time_hi_and_version := ID.time_hi_and_version or 16#4000#; -- RFC4122: "Set the two most significant bits (bits 6 and 7) of the -- clock_seq_hi_and_reserved to zero and one, respectively. ID.clock_seq_hi_and_reserved := Bitfield_8 (Rand_Lo and 2#0011_1111#); ID.clock_seq_hi_and_reserved := ID.clock_seq_hi_and_reserved or 2#1000_0000#; Rand_Lo := Shift_Right (Rand_Lo, 8); ID.clock_seq_low := Bitfield_8 (Rand_Lo and 16#ff#); Rand_Lo := Shift_Right (Rand_Lo, 8); ID.node := Bitfield_48 (Rand_Lo and 16#ffff_ffff_ffff#); return ID; end Random_UUID; end UUIDs.Version_4;
reznikmm/matreshka
Ada
4,075
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.Style_Font_Charset_Asian_Attributes; package Matreshka.ODF_Style.Font_Charset_Asian_Attributes is type Style_Font_Charset_Asian_Attribute_Node is new Matreshka.ODF_Style.Abstract_Style_Attribute_Node and ODF.DOM.Style_Font_Charset_Asian_Attributes.ODF_Style_Font_Charset_Asian_Attribute with null record; overriding function Create (Parameters : not null access Matreshka.DOM_Attributes.Attribute_L2_Parameters) return Style_Font_Charset_Asian_Attribute_Node; overriding function Get_Local_Name (Self : not null access constant Style_Font_Charset_Asian_Attribute_Node) return League.Strings.Universal_String; end Matreshka.ODF_Style.Font_Charset_Asian_Attributes;
ekoeppen/STM32_Generic_Ada_Drivers
Ada
214
ads
with STM32_SVD; use STM32_SVD; package STM32GD.USART is pragma Preelaborate; type USART_Instance is (USART_1, USART_2, USART_3); type USART_Data is array (Natural range <>) of Byte; end STM32GD.USART;
charlie5/aIDE
Ada
2,863
ads
with AdaM.Any, AdaM.Entity, AdaM.Context, AdaM.library_Item, AdaM.Subunit, Ada.Containers.Vectors, Ada.Streams; package AdaM.compilation_Unit is type Item is new AdaM.Any.item with private; -- View -- type View is access all Item'Class; procedure View_write (Stream : not null access Ada.Streams.Root_Stream_Type'Class; Self : in View); procedure View_read (Stream : not null access Ada.Streams.Root_Stream_Type'Class; Self : out View); for View'write use View_write; for View'read use View_read; -- Vector -- package Vectors is new ada.Containers.Vectors (Positive, View); subtype Vector is Vectors.Vector; -- Forge -- function new_compilation_Unit (Name : in String := "") return compilation_Unit.view; type unit_Kind is (library_unit_Kind, subunit_Kind); function new_library_Unit (Name : in String := ""; the_Item : in library_Item.view) return compilation_Unit.view; function new_Subunit (Name : in String := ""; the_Unit : in Subunit.view) return compilation_Unit.view; procedure free (Self : in out compilation_Unit.view); procedure destruct (Self : in out Item); -- Attributes -- overriding function Id (Self : access Item) return AdaM.Id; function Kind (Self : in Item) return unit_Kind; function library_Item (Self : in Item) return AdaM.library_Item.view; function Name (Self : in Item) return String; procedure Name_is (Self : in out Item; Now : in String); function Entity (Self : in Item) return AdaM.Entity.view; procedure Entity_is (Self : in out Item; Now : in AdaM.Entity.view); private type library_Item_or_Subunit (Kind : unit_Kind := library_unit_Kind) is record case Kind is when library_unit_Kind => library_Item : AdaM.library_Item.view; when subunit_Kind => Subunit : AdaM.Subunit.view; end case; end record; type Item is new AdaM.Any.item with record Name : Text; Context : AdaM.Context.view; library_Item : library_Item_or_Subunit; Entity : AdaM.Entity.view; end record; -- Streams -- procedure Item_write (Stream : not null access Ada.Streams.Root_Stream_Type'Class; Self : in Item); procedure Item_read (Stream : not null access Ada.Streams.Root_Stream_Type'Class; Self : out Item); for Item'write use Item_write; for Item'read use Item_read; end AdaM.compilation_Unit;
AdaCore/libadalang
Ada
182
adb
procedure Test is procedure Foo is null; procedure Bar is null; procedure Baz is null; pragma Inline (Foo, Bar, Baz); pragma Test_Statement; begin null; end Test;
zhmu/ananas
Ada
278
ads
with Gen_Formal_Pkg_A, Gen_Formal_Pkg_B; generic with package Ai is new Gen_Formal_Pkg_A (<>); package Gen_Formal_Pkg_W is procedure P1 (T : Ai.T1) is null; package Bi is new Gen_Formal_Pkg_B (Ai.T1, Ai); procedure P2 (T : Ai.T1) is null; end Gen_Formal_Pkg_W;
pombredanne/ravenadm
Ada
1,289
ads
-- This file is covered by the Internet Software Consortium (ISC) License -- Reference: ../License.txt with Definitions; use Definitions; with Ada.Text_IO; package Port_Specification.Json is package TIO renames Ada.Text_IO; -- Describes the port using standard parameters formatted in JSON -- Used for Repology index procedure describe_port (specs : Portspecs; dossier : TIO.File_Type; bucket : String; index : Positive); private pad : constant Natural := 4; -- returns "generated" instead of raw value when generated is true function fpc_value (is_generated : Boolean; raw_value : String) return String; -- returns Keyword array function describe_keywords (specs : Portspecs) return String; -- returns array of distfiles function describe_distfiles (specs : Portspecs) return String; -- return array of subpackages function describe_subpackages (specs : Portspecs; variant : String) return String; -- Escape certain characters to result in valid json function escape_tagline (raw : String) return String; -- When the homepage is set to "none", return an empty string, otherwise return a json string function homepage_line (specs : Portspecs) return String; end Port_Specification.Json;
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_Consecutive_Numbering_Attributes is pragma Preelaborate; type ODF_Text_Consecutive_Numbering_Attribute is limited interface and XML.DOM.Attributes.DOM_Attribute; type ODF_Text_Consecutive_Numbering_Attribute_Access is access all ODF_Text_Consecutive_Numbering_Attribute'Class with Storage_Size => 0; end ODF.DOM.Text_Consecutive_Numbering_Attributes;
zhmu/ananas
Ada
5,421
ads
------------------------------------------------------------------------------ -- -- -- GNAT COMPILER COMPONENTS -- -- -- -- S Y S T E M . S T O R A G E _ P O O L S -- -- -- -- S p e c -- -- -- -- Copyright (C) 1992-2022, Free Software Foundation, Inc. -- -- -- -- This specification is derived from the Ada Reference Manual for use with -- -- GNAT. The copyright notice above, and the license provisions that follow -- -- apply solely to the contents of the part following the private keyword. -- -- -- -- GNAT is free software; you can redistribute it and/or modify it under -- -- terms of the GNU General Public License as published by the Free Soft- -- -- ware Foundation; either version 3, or (at your option) any later ver- -- -- sion. GNAT is distributed in the hope that it will be useful, but WITH- -- -- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY -- -- or FITNESS FOR A PARTICULAR PURPOSE. -- -- -- -- As a special exception under Section 7 of GPL version 3, you are granted -- -- additional permissions described in the GCC Runtime Library Exception, -- -- version 3.1, as published by the Free Software Foundation. -- -- -- -- You should have received a copy of the GNU General Public License and -- -- a copy of the GCC Runtime Library Exception along with this program; -- -- see the files COPYING3 and COPYING.RUNTIME respectively. If not, see -- -- <http://www.gnu.org/licenses/>. -- -- -- -- GNAT was originally developed by the GNAT team at New York University. -- -- Extensive contributions were provided by Ada Core Technologies Inc. -- -- -- ------------------------------------------------------------------------------ with Ada.Finalization; with System.Storage_Elements; package System.Storage_Pools with Pure is type Root_Storage_Pool is abstract new Ada.Finalization.Limited_Controlled with private; pragma Preelaborable_Initialization (Root_Storage_Pool); procedure Allocate (Pool : in out Root_Storage_Pool; Storage_Address : out System.Address; Size_In_Storage_Elements : System.Storage_Elements.Storage_Count; Alignment : System.Storage_Elements.Storage_Count) is abstract; procedure Deallocate (Pool : in out Root_Storage_Pool; Storage_Address : System.Address; Size_In_Storage_Elements : System.Storage_Elements.Storage_Count; Alignment : System.Storage_Elements.Storage_Count) is abstract; function Storage_Size (Pool : Root_Storage_Pool) return System.Storage_Elements.Storage_Count is abstract; private type Root_Storage_Pool is abstract new Ada.Finalization.Limited_Controlled with null record; type Root_Storage_Pool_Ptr is access all Root_Storage_Pool'Class; for Root_Storage_Pool_Ptr'Storage_Size use 0; -- Type of the BIP_Storage_Pool extra parameter (see Exp_Ch6). The -- Storage_Size clause is necessary, because otherwise we have a -- chicken&egg problem; we can't be creating collection finalization code -- in this low-level package, because that involves Pool_Global, which -- imports this package. -- ??? Are these two still needed? It might be possible to use Subpools. -- Allocate_Any_Controlled / Deallocate_Any_Controlled for non-controlled -- objects. -- The following two procedures support the use of class-wide pool -- objects in storage pools. When a local type is given a class-wide -- storage pool, allocation and deallocation for the type must dispatch -- to the operation of the specific pool, which is achieved by a call -- to these procedures. (When the pool type is specific, the back-end -- generates a call to the statically identified operation of the type). procedure Allocate_Any (Pool : in out Root_Storage_Pool'Class; Storage_Address : out System.Address; Size_In_Storage_Elements : System.Storage_Elements.Storage_Count; Alignment : System.Storage_Elements.Storage_Count); procedure Deallocate_Any (Pool : in out Root_Storage_Pool'Class; Storage_Address : System.Address; Size_In_Storage_Elements : System.Storage_Elements.Storage_Count; Alignment : System.Storage_Elements.Storage_Count); end System.Storage_Pools;
zhmu/ananas
Ada
17,994
adb
------------------------------------------------------------------------------ -- -- -- GNAT RUN-TIME COMPONENTS -- -- -- -- A D A . W I D E _ W I D E _ T E X T _ I O . G E N E R I C _ A U X -- -- -- -- 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 Interfaces.C_Streams; use Interfaces.C_Streams; with System.File_IO; with System.File_Control_Block; package body Ada.Wide_Wide_Text_IO.Generic_Aux is package FIO renames System.File_IO; package FCB renames System.File_Control_Block; subtype AP is FCB.AFCB_Ptr; ------------------------ -- Check_End_Of_Field -- ------------------------ procedure Check_End_Of_Field (Buf : String; Stop : Integer; Ptr : Integer; Width : Field) is begin if Ptr > Stop then return; elsif Width = 0 then raise Data_Error; else for J in Ptr .. Stop loop if not Is_Blank (Buf (J)) then raise Data_Error; end if; end loop; end if; end Check_End_Of_Field; ----------------------- -- Check_On_One_Line -- ----------------------- procedure Check_On_One_Line (File : File_Type; Length : Integer) is begin FIO.Check_Write_Status (AP (File)); if File.Line_Length /= 0 then if Count (Length) > File.Line_Length then raise Layout_Error; elsif File.Col + Count (Length) > File.Line_Length + 1 then New_Line (File); end if; end if; end Check_On_One_Line; -------------- -- Is_Blank -- -------------- function Is_Blank (C : Character) return Boolean is begin return C = ' ' or else C = ASCII.HT; end Is_Blank; ---------- -- Load -- ---------- procedure Load (File : File_Type; Buf : out String; Ptr : in out Integer; Char : Character; Loaded : out Boolean) is ch : int; begin if File.Before_Wide_Wide_Character then Loaded := False; return; else ch := Getc (File); if ch = Character'Pos (Char) then Store_Char (File, ch, Buf, Ptr); Loaded := True; else Ungetc (ch, File); Loaded := False; end if; end if; end Load; procedure Load (File : File_Type; Buf : out String; Ptr : in out Integer; Char : Character) is ch : int; begin if File.Before_Wide_Wide_Character then null; else ch := Getc (File); if ch = Character'Pos (Char) then Store_Char (File, ch, Buf, Ptr); else Ungetc (ch, File); end if; end if; end Load; procedure Load (File : File_Type; Buf : out String; Ptr : in out Integer; Char1 : Character; Char2 : Character; Loaded : out Boolean) is ch : int; begin if File.Before_Wide_Wide_Character then Loaded := False; return; else ch := Getc (File); if ch = Character'Pos (Char1) or else ch = Character'Pos (Char2) then Store_Char (File, ch, Buf, Ptr); Loaded := True; else Ungetc (ch, File); Loaded := False; end if; end if; end Load; procedure Load (File : File_Type; Buf : out String; Ptr : in out Integer; Char1 : Character; Char2 : Character) is ch : int; begin if File.Before_Wide_Wide_Character then null; else ch := Getc (File); if ch = Character'Pos (Char1) or else ch = Character'Pos (Char2) then Store_Char (File, ch, Buf, Ptr); else Ungetc (ch, File); end if; end if; end Load; ----------------- -- Load_Digits -- ----------------- procedure Load_Digits (File : File_Type; Buf : out String; Ptr : in out Integer; Loaded : out Boolean) is ch : int; After_Digit : Boolean; begin if File.Before_Wide_Wide_Character then Loaded := False; return; else ch := Getc (File); if ch not in Character'Pos ('0') .. Character'Pos ('9') then Loaded := False; else Loaded := True; After_Digit := True; loop Store_Char (File, ch, Buf, Ptr); ch := Getc (File); if ch in Character'Pos ('0') .. Character'Pos ('9') then After_Digit := True; elsif ch = Character'Pos ('_') and then After_Digit then After_Digit := False; else exit; end if; end loop; end if; Ungetc (ch, File); end if; end Load_Digits; procedure Load_Digits (File : File_Type; Buf : out String; Ptr : in out Integer) is ch : int; After_Digit : Boolean; begin if File.Before_Wide_Wide_Character then return; else ch := Getc (File); if ch in Character'Pos ('0') .. Character'Pos ('9') then After_Digit := True; loop Store_Char (File, ch, Buf, Ptr); ch := Getc (File); if ch in Character'Pos ('0') .. Character'Pos ('9') then After_Digit := True; elsif ch = Character'Pos ('_') and then After_Digit then After_Digit := False; else exit; end if; end loop; end if; Ungetc (ch, File); end if; end Load_Digits; -------------------------- -- Load_Extended_Digits -- -------------------------- procedure Load_Extended_Digits (File : File_Type; Buf : out String; Ptr : in out Integer; Loaded : out Boolean) is ch : int; After_Digit : Boolean := False; begin if File.Before_Wide_Wide_Character then Loaded := False; return; else Loaded := False; loop ch := Getc (File); if ch in Character'Pos ('0') .. Character'Pos ('9') or else ch in Character'Pos ('a') .. Character'Pos ('f') or else ch in Character'Pos ('A') .. Character'Pos ('F') then After_Digit := True; elsif ch = Character'Pos ('_') and then After_Digit then After_Digit := False; else exit; end if; Store_Char (File, ch, Buf, Ptr); Loaded := True; end loop; Ungetc (ch, File); end if; end Load_Extended_Digits; procedure Load_Extended_Digits (File : File_Type; Buf : out String; Ptr : in out Integer) is Junk : Boolean; begin Load_Extended_Digits (File, Buf, Ptr, Junk); end Load_Extended_Digits; ------------------ -- Load_Integer -- ------------------ procedure Load_Integer (File : File_Type; Buf : out String; Ptr : in out Natural) is Hash_Loc : Natural; Loaded : Boolean; begin Load_Skip (File); -- Note: it is a bit strange to allow a minus sign here, but it seems -- consistent with the general behavior expected by the ACVC tests -- which is to scan past junk and then signal data error, see ACVC -- test CE3704F, case (6), which is for signed integer exponents, -- which seems a similar case. Load (File, Buf, Ptr, '+', '-'); Load_Digits (File, Buf, Ptr, Loaded); if Loaded then -- Deal with based literal. We recognize either the standard '#' or -- the allowed alternative replacement ':' (see RM J.2(3)). Load (File, Buf, Ptr, '#', ':', Loaded); if Loaded then Hash_Loc := Ptr; Load_Extended_Digits (File, Buf, Ptr); Load (File, Buf, Ptr, Buf (Hash_Loc)); end if; -- Deal with exponent Load (File, Buf, Ptr, 'E', 'e', Loaded); if Loaded then -- Note: it is strange to allow a minus sign, since the syntax -- does not, but that is what ACVC test CE3704F, case (6) wants -- for the signed case, and there seems no good reason to treat -- exponents differently for the signed and unsigned cases. Load (File, Buf, Ptr, '+', '-'); Load_Digits (File, Buf, Ptr); end if; end if; end Load_Integer; --------------- -- Load_Real -- --------------- procedure Load_Real (File : File_Type; Buf : out String; Ptr : in out Natural) is Loaded : Boolean; begin -- Skip initial blanks and load possible sign Load_Skip (File); Load (File, Buf, Ptr, '+', '-'); -- Case of .nnnn Load (File, Buf, Ptr, '.', Loaded); if Loaded then Load_Digits (File, Buf, Ptr, Loaded); -- Hopeless junk if no digits loaded if not Loaded then return; end if; -- Otherwise must have digits to start else Load_Digits (File, Buf, Ptr, Loaded); -- Hopeless junk if no digits loaded if not Loaded then return; end if; -- Deal with based case. We recognize either the standard '#' or the -- allowed alternative replacement ':' (see RM J.2(3)). Load (File, Buf, Ptr, '#', ':', Loaded); if Loaded then -- Case of nnn#.xxx# Load (File, Buf, Ptr, '.', Loaded); if Loaded then Load_Extended_Digits (File, Buf, Ptr); Load (File, Buf, Ptr, '#', ':'); -- Case of nnn#xxx.[xxx]# or nnn#xxx# else Load_Extended_Digits (File, Buf, Ptr); Load (File, Buf, Ptr, '.', Loaded); if Loaded then Load_Extended_Digits (File, Buf, Ptr); end if; -- As usual, it seems strange to allow mixed base characters, -- but that is what ACVC tests expect, see CE3804M, case (3). Load (File, Buf, Ptr, '#', ':'); end if; -- Case of nnn.[nnn] or nnn else -- Prevent the potential processing of '.' in cases where the -- initial digits have a trailing underscore. if Buf (Ptr) = '_' then return; end if; Load (File, Buf, Ptr, '.', Loaded); if Loaded then Load_Digits (File, Buf, Ptr); end if; end if; end if; -- Deal with exponent Load (File, Buf, Ptr, 'E', 'e', Loaded); if Loaded then Load (File, Buf, Ptr, '+', '-'); Load_Digits (File, Buf, Ptr); end if; end Load_Real; --------------- -- Load_Skip -- --------------- procedure Load_Skip (File : File_Type) is C : Character; begin FIO.Check_Read_Status (AP (File)); -- We need to explicitly test for the case of being before a wide -- character (greater than 16#7F#). Since no such character can -- ever legitimately be a valid numeric character, we can -- immediately signal Data_Error. if File.Before_Wide_Wide_Character then raise Data_Error; end if; -- Otherwise loop till we find a non-blank character (note that as -- usual in Wide_Wide_Text_IO, blank includes horizontal tab). Note that -- Get_Character deals with Before_LM/Before_LM_PM flags appropriately. loop Get_Character (File, C); exit when not Is_Blank (C); end loop; Ungetc (Character'Pos (C), File); File.Col := File.Col - 1; end Load_Skip; ---------------- -- Load_Width -- ---------------- procedure Load_Width (File : File_Type; Width : Field; Buf : out String; Ptr : in out Integer) is ch : int; WC : Wide_Wide_Character; Bad_Wide_Wide_C : Boolean := False; -- Set True if one of the characters read is not in range of type -- Character. This is always a Data_Error, but we do not signal it -- right away, since we have to read the full number of characters. begin FIO.Check_Read_Status (AP (File)); -- If we are immediately before a line mark, then we have no characters. -- This is always a data error, so we may as well raise it right away. if File.Before_LM then raise Data_Error; else for J in 1 .. Width loop if File.Before_Wide_Wide_Character then Bad_Wide_Wide_C := True; Store_Char (File, 0, Buf, Ptr); File.Before_Wide_Wide_Character := False; else ch := Getc (File); if ch = EOF then exit; elsif ch = LM then Ungetc (ch, File); exit; else WC := Get_Wide_Wide_Char (Character'Val (ch), File); ch := Wide_Wide_Character'Pos (WC); if ch > 255 then Bad_Wide_Wide_C := True; ch := 0; end if; Store_Char (File, ch, Buf, Ptr); end if; end if; end loop; if Bad_Wide_Wide_C then raise Data_Error; end if; end if; end Load_Width; -------------- -- Put_Item -- -------------- procedure Put_Item (File : File_Type; Str : String) is begin Check_On_One_Line (File, Str'Length); for J in Str'Range loop Put (File, Wide_Wide_Character'Val (Character'Pos (Str (J)))); end loop; end Put_Item; ---------------- -- Store_Char -- ---------------- procedure Store_Char (File : File_Type; ch : Integer; Buf : out String; Ptr : in out Integer) is begin File.Col := File.Col + 1; if Ptr = Buf'Last then raise Data_Error; else Ptr := Ptr + 1; Buf (Ptr) := Character'Val (ch); end if; end Store_Char; ----------------- -- String_Skip -- ----------------- procedure String_Skip (Str : String; Ptr : out Integer) is begin -- Routines calling String_Skip malfunction if Str'Last = Positive'Last. -- It's too much trouble to make this silly case work, so we just raise -- Program_Error with an appropriate message. We raise Program_Error -- rather than Constraint_Error because we don't want this case to be -- converted to Data_Error. if Str'Last = Positive'Last then raise Program_Error with "string upper bound is Positive'Last, not supported"; end if; -- Normal case where Str'Last < Positive'Last Ptr := Str'First; loop if Ptr > Str'Last then raise End_Error; elsif not Is_Blank (Str (Ptr)) then return; else Ptr := Ptr + 1; end if; end loop; end String_Skip; ------------ -- Ungetc -- ------------ procedure Ungetc (ch : int; File : File_Type) is begin if ch /= EOF then if ungetc (ch, File.Stream) = EOF then raise Device_Error; end if; end if; end Ungetc; end Ada.Wide_Wide_Text_IO.Generic_Aux;
stcarrez/ada-enet
Ada
8,131
ads
------------------------------------------------------------------------------ -- -- -- Copyright (C) 2015, AdaCore -- -- -- -- Redistribution and use in source and binary forms, with or without -- -- modification, are permitted provided that the following conditions are -- -- met: -- -- 1. Redistributions of source code must retain the above copyright -- -- notice, this list of conditions and the following disclaimer. -- -- 2. Redistributions in binary form must reproduce the above copyright -- -- notice, this list of conditions and the following disclaimer in -- -- the documentation and/or other materials provided with the -- -- distribution. -- -- 3. Neither the name of STMicroelectronics nor the names of its -- -- contributors may be used to endorse or promote products derived -- -- from this software without specific prior written permission. -- -- -- -- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -- -- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -- -- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -- -- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -- -- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -- -- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -- -- LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -- -- DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -- -- THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -- -- (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -- -- OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- -- -- ------------------------------------------------------------------------------ with System; use System; -- SCz 2016-09-27: this is a stripped down version of stm32-eth.adb where the TX/RX -- ring initialization is removed as well as the interrupt handler with the Wait_Packet -- operation. The interrupt handler conflicts with the Net.Interfaces.STM32 driver. -- I've just re-used the MII initialization as well as the Ethernet descriptor types. package STM32.Eth is procedure Initialize_RMII; -- Initialize the driver using RMII configuration. procedure Read_MMI (Reg : UInt5; Val : out Unsigned_16); -- Read an MMI register. type TDES0_Type is record Own : Bit; Ic : Bit; Ls : Bit; Fs : Bit; Dc : Bit; Dp : Bit; Ttse : Bit; Reserved_1 : Bit; Cic : UInt2; Ter : Bit; Tch : Bit; Reserved_2 : UInt2; Ttss : Bit; Ihe : Bit; Es : Bit; Jt : Bit; Ff : Bit; Ipe : Bit; Lca : Bit; Nc : Bit; Lco : Bit; Ec : Bit; Vf : Bit; Cc : UInt4; Ed : Bit; Uf : Bit; Db : Bit; end record; for TDES0_Type use record Own at 0 range 31 .. 31; Ic at 0 range 30 .. 30; Ls at 0 range 29 .. 29; Fs at 0 range 28 .. 28; Dc at 0 range 27 .. 27; Dp at 0 range 26 .. 26; Ttse at 0 range 25 .. 25; Reserved_1 at 0 range 24 .. 24; Cic at 0 range 22 .. 23; Ter at 0 range 21 .. 21; Tch at 0 range 20 .. 20; Reserved_2 at 0 range 18 .. 19; Ttss at 0 range 17 .. 17; Ihe at 0 range 16 .. 16; Es at 0 range 15 .. 15; Jt at 0 range 14 .. 14; Ff at 0 range 13 .. 13; Ipe at 0 range 12 .. 12; Lca at 0 range 11 .. 11; Nc at 0 range 10 .. 10; Lco at 0 range 9 .. 9; Ec at 0 range 8 .. 8; Vf at 0 range 7 .. 7; Cc at 0 range 3 .. 6; Ed at 0 range 2 .. 2; Uf at 0 range 1 .. 1; Db at 0 range 0 .. 0; end record; type TDES1_Type is record Tbs1 : UInt13; Reserved_13_15 : UInt3; Tbs2 : UInt13; Reserved_29_31 : UInt3; end record; for TDES1_Type use record Tbs1 at 0 range 0 .. 12; Reserved_13_15 at 0 range 13 .. 15; Tbs2 at 0 range 16 .. 28; Reserved_29_31 at 0 range 29 .. 31; end record; type Tx_Desc_Type is record Tdes0 : TDES0_Type; Tdes1 : TDES1_Type; Tdes2 : Address; Tdes3 : Address; Tdes4 : UInt32; Tdes5 : UInt32; Tdes6 : UInt32; Tdes7 : UInt32; end record; for Tx_Desc_Type use record Tdes0 at 0 range 0 .. 31; Tdes1 at 4 range 0 .. 31; Tdes2 at 8 range 0 .. 31; Tdes3 at 12 range 0 .. 31; Tdes4 at 16 range 0 .. 31; Tdes5 at 20 range 0 .. 31; Tdes6 at 24 range 0 .. 31; Tdes7 at 28 range 0 .. 31; end record; type Rdes0_Type is record Pce_Esa : Bit; Ce : Bit; Dre : Bit; Re : Bit; Rwt : Bit; Ft : Bit; Lco : Bit; Iphce : Bit; Ls : Bit; Fs : Bit; Vlan : Bit; Oe : Bit; Le : Bit; Saf : Bit; De : Bit; Es : Bit; Fl : UInt14; Afm : Bit; Own : Bit; end record; for Rdes0_Type use record Pce_Esa at 0 range 0 .. 0; Ce at 0 range 1 .. 1; Dre at 0 range 2 .. 2; Re at 0 range 3 .. 3; Rwt at 0 range 4 .. 4; Ft at 0 range 5 .. 5; Lco at 0 range 6 .. 6; Iphce at 0 range 7 .. 7; Ls at 0 range 8 .. 8; Fs at 0 range 9 .. 9; Vlan at 0 range 10 .. 10; Oe at 0 range 11 .. 11; Le at 0 range 12 .. 12; Saf at 0 range 13 .. 13; De at 0 range 14 .. 14; Es at 0 range 15 .. 15; Fl at 0 range 16 .. 29; Afm at 0 range 30 .. 30; Own at 0 range 31 .. 31; end record; type Rdes1_Type is record Rbs : UInt13; Reserved_13 : Bit; Rch : Bit; Rer : Bit; Rbs2 : UInt13; Reserved_29_30 : UInt2; Dic : Bit; end record; for Rdes1_Type use record Rbs at 0 range 0 .. 12; Reserved_13 at 0 range 13 .. 13; Rch at 0 range 14 .. 14; Rer at 0 range 15 .. 15; Rbs2 at 0 range 16 .. 28; Reserved_29_30 at 0 range 29 .. 30; Dic at 0 range 31 .. 31; end record; type Rdes4_Type is record Reserved_31_14 : UInt18; Pv : Bit; Pft : Bit; Pmt : UInt4; Ipv6pr : Bit; Ipv4pr : Bit; Ipcb : Bit; Ippe : Bit; Iphe : Bit; Ippt : UInt3; end record; for Rdes4_Type use record Ippt at 0 range 0 .. 2; Iphe at 3 range 3 .. 3; Ippe at 4 range 4 .. 4; Ipcb at 5 range 5 .. 5; Ipv4pr at 6 range 6 .. 6; Ipv6pr at 7 range 7 .. 7; Pmt at 8 range 8 .. 11; Pft at 12 range 12 .. 12; Pv at 13 range 13 .. 13; Reserved_31_14 at 14 range 14 .. 31; end record; type Rx_Desc_Type is record Rdes0 : Rdes0_Type; Rdes1 : Rdes1_Type; Rdes2 : UInt32; Rdes3 : UInt32; Rdes4 : Rdes4_Type; Rdes5 : UInt32; Rdes6 : UInt32; Rdes7 : UInt32; end record; for Rx_Desc_Type use record Rdes0 at 0 range 0 .. 31; Rdes1 at 4 range 0 .. 31; Rdes2 at 8 range 0 .. 31; Rdes3 at 12 range 0 .. 31; end record; end STM32.Eth;
sungyeon/drake
Ada
2,763
adb
with Ada.Unchecked_Conversion; with C.winbase; with C.winnt; with C.winternl; package body System.Storage_Map is pragma Suppress (All_Checks); use type C.char_array; use type C.size_t; use type C.windef.ULONG; NTDLL_DLL : aliased constant C.winnt.WCHAR_array (0 .. 9) := ( C.winnt.WCHAR'Val (Wide_Character'Pos ('N')), C.winnt.WCHAR'Val (Wide_Character'Pos ('T')), C.winnt.WCHAR'Val (Wide_Character'Pos ('D')), C.winnt.WCHAR'Val (Wide_Character'Pos ('L')), C.winnt.WCHAR'Val (Wide_Character'Pos ('L')), C.winnt.WCHAR'Val (Wide_Character'Pos ('.')), C.winnt.WCHAR'Val (Wide_Character'Pos ('D')), C.winnt.WCHAR'Val (Wide_Character'Pos ('L')), C.winnt.WCHAR'Val (Wide_Character'Pos ('L')), C.winnt.WCHAR'Val (0)); type NtQueryInformationProcess_Type is access function ( ProcessHandle : C.winnt.HANDLE; ProcessInformationClass : C.winternl.PROCESSINFOCLASS; ProcessInformation : C.winnt.PVOID; ProcessInformationLength : C.windef.ULONG; ReturnLength : access C.windef.ULONG) return C.winternl.NTSTATUS with Convention => WINAPI; NtQueryInformationProcess_Name : constant C.char_array (0 .. 25) := "NtQueryInformationProcess" & C.char'Val (0); -- implementation function Load_Address return Address is function To_NtQueryInformationProcess_Type is new Ada.Unchecked_Conversion ( C.windef.FARPROC, NtQueryInformationProcess_Type); NtQueryInformationProcess : NtQueryInformationProcess_Type; begin NtQueryInformationProcess := To_NtQueryInformationProcess_Type ( C.winbase.GetProcAddress ( NTDLL, NtQueryInformationProcess_Name (0)'Access)); if NtQueryInformationProcess = null then return Null_Address; -- ??? else declare PBI : aliased C.winternl.PROCESS_BASIC_INFORMATION; ReturnLength : aliased C.windef.ULONG; Dummy_Status : C.winternl.NTSTATUS; PEB : C.winternl.PPEB; begin Dummy_Status := NtQueryInformationProcess ( C.winbase.GetCurrentProcess, C.winternl.ProcessBasicInformation, C.windef.LPVOID (PBI'Address), C.winternl.PROCESS_BASIC_INFORMATION'Size / Standard'Storage_Unit, ReturnLength'Access); PEB := PBI.PebBaseAddress; -- process environment block return Address (PEB.Reserved3 (1)); end; end if; end Load_Address; function NTDLL return C.windef.HMODULE is begin return C.winbase.GetModuleHandle (NTDLL_DLL (0)'Access); end NTDLL; end System.Storage_Map;
BrickBot/Bound-T-H8-300
Ada
5,169
ads
-- Options.Groups (decl) -- -- Common, but distributed, groups of options. -- -- A component of the Bound-T Worst-Case Execution Time Tool. -- ------------------------------------------------------------------------------- -- Copyright (c) 1999 .. 2015 Tidorum Ltd -- All rights reserved. -- -- Redistribution and use in source and binary forms, with or without -- modification, are permitted provided that the following conditions are met: -- -- 1. Redistributions of source code must retain the above copyright notice, this -- list of conditions and the following disclaimer. -- 2. Redistributions in binary form must reproduce the above copyright notice, -- this list of conditions and the following disclaimer in the documentation -- and/or other materials provided with the distribution. -- -- This software is provided by the copyright holders and contributors "as is" and -- any express or implied warranties, including, but not limited to, the implied -- warranties of merchantability and fitness for a particular purpose are -- disclaimed. In no event shall the copyright owner or contributors be liable for -- any direct, indirect, incidental, special, exemplary, or consequential damages -- (including, but not limited to, procurement of substitute goods or services; -- loss of use, data, or profits; or business interruption) however caused and -- on any theory of liability, whether in contract, strict liability, or tort -- (including negligence or otherwise) arising in any way out of the use of this -- software, even if advised of the possibility of such damage. -- -- Other modules (files) of this software composition should contain their -- own copyright statements, which may have different copyright and usage -- conditions. The above conditions apply to this file. ------------------------------------------------------------------------------- -- -- $Revision: 1.4 $ -- $Date: 2015/10/24 19:36:50 $ -- -- $Log: options-groups.ads,v $ -- Revision 1.4 2015/10/24 19:36:50 niklas -- Moved to free licence. -- -- Revision 1.3 2012-01-28 12:56:14 niklas -- BT-CH-0226: Options update for AVR. -- -- Revision 1.2 2011-09-01 13:04:38 niklas -- Added the Timing group. -- -- Revision 1.1 2011-08-31 04:17:13 niklas -- Added for BT-CH-0222: Option registry. Option -dump. External help files. -- package Options.Groups is pragma Elaborate_Body; -- -- To define the priority ordering of the groups here defined. Inputs : constant Group_Name_T := Group ("inputs"); -- -- Options to define the inputs for the analysis. Outputs : constant Group_Name_T := Group ("outputs"); -- -- Options to define the output (files) from the analysis. Analysis : constant Group_Name_T := Group ("analysis"); -- -- Options to define what should be analysed, and which -- analyses to do. Assertions : constant Group_Name_T := Group ("assertions"); -- -- Options relating to assertions. Control_Flow : constant Group_Name_T := Options.Group ("control_flow"); -- -- Options relating to control-flow analysis. Loops : constant Group_Name_T := Options.Group ("loops"); -- -- Options relating to the detection and analysis of loops. Calls : constant Group_Name_T := Options.Group ("calls"); -- -- Options relating to the modelling and analysis of calls. Const_Prop : constant Group_Name_T := Options.Group ("const_prop"); -- -- Options that control details of the constant-propagation analysis. Arithmetic : constant Group_Name_T := Options.Group ("arithmetic"); -- -- Options that control details of the arithmetic analysis. Timing : constant Group_Name_T := Options.Group ("timing"); -- -- Options relating to the execution-time modelling and analysis. Stack_Usage : constant Group_Name_T := Options.Group ("stack"); -- -- Options relating to the stack-usage analysis. Trace : constant Group_Name_T := Group ("trace"); -- -- Options to trace significant events during analysis. -- On the command line, these Boolean options are defined as -- -trace <item> -- where the option-name is "trace-<item>". Warn : constant Group_Name_T := Group ("warn"); -- -- Options to warn about potential problems found during analysis. -- On the command line, these Boolean options are defined as -- -warn [no_]<item> -- where the option-name is "warn-<item>". Imp : constant Group_Name_T := Group ("imp"); -- -- Options that control internal implementation choices. -- On the command line, these options are defined as -- -imp [no_]<item> -- where the option-name is "imp-item". Host_Memory : constant Group_Name_T := Group ("host_memory"); -- -- Options (typically implementation choices) that control the -- memory management of Bound-T itself, on the host computer. Resource_Limits : constant Group_Name_T := Group ("rlimit"); -- -- Options that control or limit the amount of computational -- resources (processing time, memory, error messages, etc.) -- that an analysis can use, before the analysis is stopped. end Options.Groups;
MinimSecure/unum-sdk
Ada
922
adb
-- Copyright 2012-2019 Free Software Foundation, Inc. -- -- This program is free software; you can redistribute it and/or modify -- it under the terms of the GNU General Public License as published by -- the Free Software Foundation; either version 3 of the License, or -- (at your option) any later version. -- -- This program is distributed in the hope that it will be useful, -- but WITHOUT ANY WARRANTY; without even the implied warranty of -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -- GNU General Public License for more details. -- -- You should have received a copy of the GNU General Public License -- along with this program. If not, see <http://www.gnu.org/licenses/>. package body Pck is function Ident (I : Integer) return Integer is begin return I; end Ident; procedure Do_Nothing (A : System.Address) is begin null; end Do_Nothing; end Pck;
stcarrez/ada-util
Ada
2,912
adb
----------------------------------------------------------------------- -- Util-texts-formats -- Text Format ala Java MessageFormat -- Copyright (C) 2001, 2002, 2003, 2009, 2010, 2022 Stephane Carrez -- Written by Stephane Carrez ([email protected]) -- -- Licensed under the Apache License, Version 2.0 (the "License"); -- you may not use this file except in compliance with the License. -- You may obtain a copy of the License at -- -- http://www.apache.org/licenses/LICENSE-2.0 -- -- Unless required by applicable law or agreed to in writing, software -- distributed under the License is distributed on an "AS IS" BASIS, -- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -- See the License for the specific language governing permissions and -- limitations under the License. ----------------------------------------------------------------------- package body Util.Texts.Formats is type Code is mod 2**32; -- ------------------------------ -- Format the message and replace occurrences of argument patterns by -- their associated value. -- Returns the formatted message in the stream -- ------------------------------ procedure Format (Message : in Input; Arguments : in Value_List; Into : in out Stream) is C : Code; Old_Pos : Natural; N : Natural; Pos : Natural := Message'First; begin while Pos <= Message'Last loop C := Char'Pos (Message (Pos)); if C = Character'Pos ('{') then N := 0; Pos := Pos + 1; Old_Pos := Pos; while Pos <= Message'Last loop C := Char'Pos (Message (Pos)); if C >= Character'Pos ('0') and then C <= Character'Pos ('9') then N := N * 10 + Natural (C - Character'Pos ('0')); Pos := Pos + 1; elsif C = Character'Pos ('}') then if N >= Arguments'Length then Put (Into, '{'); Pos := Old_Pos; else Format (Arguments (N + Arguments'First), Into); Pos := Pos + 1; end if; exit; else Put (Into, '{'); Pos := Old_Pos; exit; end if; end loop; else Put (Into, Character'Val (C)); Pos := Pos + 1; end if; end loop; end Format; procedure Format (Argument : in Value; Into : in out Stream) is Content : constant Input := To_Input (Argument); C : Code; begin for I in Content'Range loop C := Char'Pos (Content (I)); Put (Into, Character'Val (C)); end loop; end Format; end Util.Texts.Formats;
AdaCore/libadalang
Ada
8,739
adb
with Ada.Characters.Handling; with Ada.Text_IO; use Ada.Text_IO; with GNATCOLL.Opt_Parse; with GNATCOLL.Strings; with GNATCOLL.VFS; with Langkit_Support.Text; with Libadalang.Analysis; with Libadalang.Common; with Libadalang.Helpers; with Libadalang.Iterators; with Put_Title; procedure Navigate is package LAL renames Libadalang.Analysis; package LALCO renames Libadalang.Common; package LALIT renames Libadalang.Iterators; package X renames GNATCOLL.Strings; type Enabled_Kinds_Type is array (LALCO.Ada_Node_Kind_Type) of Boolean; All_Kinds : constant Enabled_Kinds_Type := (others => True); function String_To_Kinds (List : String) return Enabled_Kinds_Type; procedure Process_File (Context : Libadalang.Helpers.App_Job_Context; Unit : LAL.Analysis_Unit); package App is new Libadalang.Helpers.App (Name => "navigate", Description => "Navigate between AST nodes (spec/body/...).", Process_Unit => Process_File); package Args is use GNATCOLL.Opt_Parse; package Kinds is new Parse_Option (App.Args.Parser, "-K", "--kinds", "Comma-separated list of AST node kind names, like" & " ""Ada_Subp_Body,Ada_Package_Decl"". This will filter the" & " nodes on which we navigate.", Enabled_Kinds_Type, Default_Val => All_Kinds, Convert => String_To_Kinds); end Args; function To_Lower (S : String) return String renames Ada.Characters.Handling.To_Lower; function Is_Navigation_Disabled (N : LAL.Ada_Node) return Boolean; procedure Print_Navigation (Part_Name : String; Orig, Dest : LAL.Ada_Node'Class); function Basename (Filename : String) return String; -- Return the base name of the Filename path -------------- -- Basename -- -------------- function Basename (Filename : String) return String is use GNATCOLL.VFS; begin return +Create (+Filename).Base_Name; end Basename; ------------------ -- Process_File -- ------------------ procedure Process_File (Context : Libadalang.Helpers.App_Job_Context; Unit : LAL.Analysis_Unit) is pragma Unreferenced (Context); use GNATCOLL.VFS; At_Least_Once : Boolean := False; function Filter (N : LAL.Ada_Node) return Boolean is (Args.Kinds.Get (N.Kind) and then not Is_Navigation_Disabled (N)); begin Put_Title ('#', +Create (+Unit.Get_Filename).Base_Name); if Unit.Has_Diagnostics then for D of Unit.Diagnostics loop Put_Line (Unit.Format_GNU_Diagnostic (D)); end loop; New_Line; return; end if; for Node of LALIT.Find (Unit.Root, Filter'Access).Consume loop declare Processed_Something : Boolean := True; begin case Node.Kind is -- Bodies when LALCO.Ada_Body_Node => Print_Navigation ("Body previous part", Node, Node.As_Body_Node.P_Previous_Part); Print_Navigation ("Decl", Node, Node.As_Body_Node.P_Decl_Part); case Node.Kind is when LALCO.Ada_Package_Body_Stub => Print_Navigation ("Body", Node, Node.As_Package_Body_Stub.P_Body_Part_For_Decl); when others => null; end case; -- Packages when LALCO.Ada_Base_Type_Decl => Print_Navigation ("Type previous part", Node, Node.As_Base_Type_Decl.P_Previous_Part); case Node.Kind is when LALCO.Ada_Protected_Type_Decl => Print_Navigation ("Protected decl next part", Node, Node.As_Basic_Decl.P_Next_Part_For_Decl); Print_Navigation ("Protected decl body part", Node, Node.As_Basic_Decl.P_Body_Part_For_Decl); when others => -- Protected type decls don't have a type next part Print_Navigation ("Type next part", Node, Node.As_Base_Type_Decl.P_Next_Part); end case; when LALCO.Ada_Base_Package_Decl => Print_Navigation ("Body", Node, Node.As_Base_Package_Decl.P_Body_Part); when LALCO.Ada_Generic_Package_Decl => Print_Navigation ("Body", Node, Node.As_Generic_Package_Decl.P_Body_Part); -- Subprograms when LALCO.Ada_Classic_Subp_Decl => Print_Navigation ("Body", Node, Node.As_Classic_Subp_Decl.P_Body_Part); when LALCO.Ada_Generic_Subp_Decl => Print_Navigation ("Body", Node, Node.As_Generic_Subp_Decl.P_Body_Part); when others => Processed_Something := False; end case; At_Least_Once := At_Least_Once or else Processed_Something; exception when LALCO.Property_Error => Put_Line ("Error when processing " & Node.Image); At_Least_Once := True; end; end loop; if not At_Least_Once then Put_Line ("<no node to process>"); end if; New_Line; end Process_File; ---------------------- -- Print_Navigation -- ---------------------- procedure Print_Navigation (Part_Name : String; Orig, Dest : LAL.Ada_Node'Class) is begin if Dest.Is_Null then Put_Line (Orig.Image & " has no " & To_Lower (Part_Name)); else Put_Line (Part_Name & " of " & Orig.Image & " is " & Dest.Image & " [" & Basename (Dest.Unit.Get_Filename) & "]"); end if; end Print_Navigation; ------------------ -- Decode_Kinds -- ------------------ function String_To_Kinds (List : String) return Enabled_Kinds_Type is Enabled_Kinds : Enabled_Kinds_Type := (others => False); Names : constant X.XString_Array := X.To_XString (List).Split (","); begin for Name of Names loop if Name.Length /= 0 then begin declare Kind : constant LALCO.Ada_Node_Kind_Type := LALCO.Ada_Node_Kind_Type'Value (X.To_String (Name)); begin Enabled_Kinds (Kind) := True; end; exception when Constraint_Error => raise GNATCOLL.Opt_Parse.Opt_Parse_Error with "invalid kind name: " & X.To_String (Name); end; end if; end loop; return Enabled_Kinds; end String_To_Kinds; ---------------------------- -- Is_Navigation_Disabled -- ---------------------------- function Is_Navigation_Disabled (N : LAL.Ada_Node) return Boolean is function Lowercase_Name (Id : LAL.Identifier) return String is (To_Lower (Langkit_Support.Text.Image (Id.Text))); function Has_Disable_Navigation (Aspects : LAL.Aspect_Spec) return Boolean; ---------------------------- -- Has_Disable_Navigation -- ---------------------------- function Has_Disable_Navigation (Aspects : LAL.Aspect_Spec) return Boolean is use type LALCO.Ada_Node_Kind_Type; begin if Aspects.Is_Null then return False; end if; for Child of LAL.Ada_Node_Array'(Aspects.F_Aspect_Assocs.Children) loop declare Assoc : constant LAL.Aspect_Assoc := Child.As_Aspect_Assoc; begin if Assoc.F_Id.Kind = LALCO.Ada_Identifier then declare Id : constant LAL.Identifier := Assoc.F_Id.As_Identifier; begin return Lowercase_Name (Id) = "disable_navigation"; end; end if; end; end loop; return False; end Has_Disable_Navigation; begin case N.Kind is when LALCO.Ada_Base_Package_Decl => return Has_Disable_Navigation (N.As_Base_Package_Decl.F_Aspects); when others => return False; end case; end Is_Navigation_Disabled; begin App.Run; Put_Line ("Done."); end Navigate;
onox/orka
Ada
3,651
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. private with Ada.Containers.Indefinite_Holders; private with Orka.Instances; private with Orka.Rendering.Buffers.MDI; private with Orka.Scenes.Singles.Trees; private with Orka.Transforms.Singles.Matrices; private with Orka.Types; with Orka.Behaviors; with Orka.Culling; package Orka.Resources.Models is pragma Preelaborate; type Model_Instance is abstract limited new Behaviors.Behavior with private; type Model_Instance_Ptr is not null access all Model_Instance'Class; procedure Update_Transforms (Object : in out Model_Instance; View_Position : Behaviors.Vector4); ----------------------------------------------------------------------------- type Model_Group is tagged limited private; type Group_Access is access Model_Group; procedure Add_Instance (Object : access Model_Group; Instance : in out Model_Instance_Ptr); procedure Remove_Instance (Object : in out Model_Group; Instance : in out Model_Instance_Ptr); procedure Cull (Object : in out Model_Group); procedure Render (Object : in out Model_Group); procedure After_Render (Object : in out Model_Group); ----------------------------------------------------------------------------- type Model is limited new Resource with private; type Model_Ptr is not null access all Model; function Create_Group (Object : aliased in out Model; Culler : Culling.Culler_Ptr; Capacity : Positive) return Group_Access; Model_Load_Error : exception renames Resource_Load_Error; private package Trees renames Scenes.Singles.Trees; package Transforms renames Orka.Transforms.Singles.Matrices; type Cursor_Array is array (Positive range <>) of Trees.Cursor; package Cursor_Array_Holder is new Ada.Containers.Indefinite_Holders (Element_Type => Cursor_Array); type Model_Scene is limited record Scene : Trees.Tree; Shapes : Cursor_Array_Holder.Holder; end record; type Model_Scene_Ptr is not null access Model_Scene; type Model is limited new Resource with record Scene : Model_Scene_Ptr; Batch : Rendering.Buffers.MDI.Batch (Types.Half_Type, Types.UInt_Type); Bounds : Rendering.Buffers.Buffer (Types.Single_Vector_Type); end record; type Partition_Index_Type is mod 4; package Model_Instances is new Orka.Instances (Partition_Index_Type); type Model_Group is tagged limited record Model : access Orka.Resources.Models.Model; Instances : Model_Instances.Manager; Cull_Instance : Culling.Cull_Instance; Compacted_Transforms : Rendering.Buffers.Buffer (Types.Single_Matrix_Type); Compacted_Commands : Rendering.Buffers.Buffer (Types.Elements_Command_Type); end record; type Model_Instance is abstract limited new Behaviors.Behavior with record Group : access Model_Group; Scene : Trees.Tree; Instance : Model_Instances.Cursor; end record; end Orka.Resources.Models;
RREE/ada-util
Ada
31,399
adb
----------------------------------------------------------------------- -- util-serialize-io-json -- JSON Serialization Driver -- Copyright (C) 2010, 2011, 2012, 2016, 2017, 2020, 2021 Stephane Carrez -- Written by Stephane Carrez ([email protected]) -- -- Licensed under the Apache License, Version 2.0 (the "License"); -- you may not use this file except in compliance with the License. -- You may obtain a copy of the License at -- -- http://www.apache.org/licenses/LICENSE-2.0 -- -- Unless required by applicable law or agreed to in writing, software -- distributed under the License is distributed on an "AS IS" BASIS, -- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -- See the License for the specific language governing permissions and -- limitations under the License. ----------------------------------------------------------------------- with Interfaces; with Ada.Characters.Latin_1; with Ada.Characters.Wide_Wide_Latin_1; with Ada.IO_Exceptions; with Util.Strings; with Util.Streams; with Util.Streams.Buffered; with Util.Streams.Texts.TR; with Util.Streams.Texts.WTR; with Util.Dates.ISO8601; with Util.Beans.Objects.Maps; with Util.Beans.Objects.Readers; package body Util.Serialize.IO.JSON is use Ada.Strings.Unbounded; -- ----------------------- -- Set the target output stream. -- ----------------------- procedure Initialize (Stream : in out Output_Stream; Output : in Util.Streams.Texts.Print_Stream_Access) is begin Stream.Stream := Output; end Initialize; -- ----------------------- -- Flush the buffer (if any) to the sink. -- ----------------------- overriding procedure Flush (Stream : in out Output_Stream) is begin Stream.Stream.Flush; end Flush; -- ----------------------- -- Close the sink. -- ----------------------- overriding procedure Close (Stream : in out Output_Stream) is begin Stream.Stream.Close; end Close; -- ----------------------- -- Write the buffer array to the output stream. -- ----------------------- overriding procedure Write (Stream : in out Output_Stream; Buffer : in Ada.Streams.Stream_Element_Array) is begin Stream.Stream.Write (Buffer); end Write; -- ----------------------- -- Write a wide character on the stream doing some conversion if necessary. -- The default implementation translates the wide character to a UTF-8 sequence. -- ----------------------- procedure Write_Wide (Stream : in out Output_Stream; Item : in Wide_Wide_Character) is begin Stream.Stream.Write_Wide (Item); end Write_Wide; -- ----------------------- -- Start a JSON document. This operation writes the initial JSON marker ('{'). -- ----------------------- procedure Start_Document (Stream : in out Output_Stream) is Current : access Node_Info; begin Node_Info_Stack.Push (Stream.Stack); Current := Node_Info_Stack.Current (Stream.Stack); Current.Is_Root := True; end Start_Document; -- ----------------------- -- Finish a JSON document by writing the final JSON marker ('}'). -- ----------------------- procedure End_Document (Stream : in out Output_Stream) is Current : constant access Node_Info := Node_Info_Stack.Current (Stream.Stack); begin if Current /= null and then Current.Has_Fields and then not Current.Is_Array then Stream.Write ('}'); end if; Node_Info_Stack.Pop (Stream.Stack); end End_Document; -- ----------------------- -- Write the string as a quoted JSON string -- ----------------------- procedure Write_String (Stream : in out Output_Stream; Value : in String) is begin Stream.Write ('"'); for I in Value'Range loop declare C : constant Character := Value (I); begin if C = '"' then Stream.Write ("\"""); elsif C = '\' then Stream.Write ("\\"); elsif Character'Pos (C) >= 16#20# then Stream.Write (C); else case C is when Ada.Characters.Latin_1.BS => Stream.Write ("\b"); when Ada.Characters.Latin_1.VT => Stream.Write ("\f"); when Ada.Characters.Latin_1.LF => Stream.Write ("\n"); when Ada.Characters.Latin_1.CR => Stream.Write ("\r"); when Ada.Characters.Latin_1.HT => Stream.Write ("\t"); when others => Util.Streams.Texts.TR.To_Hex (Stream.Stream.all, C); end case; end if; end; end loop; Stream.Write ('"'); end Write_String; -- ----------------------- -- Write the value as a JSON string. Special characters are escaped using the JSON -- escape rules. -- ----------------------- procedure Write_Wide_String (Stream : in out Output_Stream; Value : in Wide_Wide_String) is begin Stream.Write ('"'); for I in Value'Range loop declare C : constant Wide_Wide_Character := Value (I); begin if C = '"' then Stream.Write ("\"""); elsif C = '\' then Stream.Write ("\\"); elsif Wide_Wide_Character'Pos (C) >= 16#20# then Util.Streams.Texts.Write_Char (Stream.Stream.all, C); else case C is when Ada.Characters.Wide_Wide_Latin_1.BS => Stream.Write ("\b"); when Ada.Characters.Wide_Wide_Latin_1.VT => Stream.Write ("\f"); when Ada.Characters.Wide_Wide_Latin_1.LF => Stream.Write ("\n"); when Ada.Characters.Wide_Wide_Latin_1.CR => Stream.Write ("\r"); when Ada.Characters.Wide_Wide_Latin_1.HT => Stream.Write ("\t"); when others => Util.Streams.Texts.WTR.To_Hex (Stream.Stream.all, C); end case; end if; end; end loop; Stream.Write ('"'); end Write_Wide_String; procedure Write_Field_Name (Stream : in out Output_Stream; Name : in String) is Current : constant access Node_Info := Node_Info_Stack.Current (Stream.Stack); begin if Current /= null then if Current.Has_Fields then Stream.Write (','); elsif Name'Length > 0 or else not Current.Is_Root then Current.Has_Fields := True; end if; end if; if Name'Length > 0 and then (Current = null or else not Current.Is_Array) then Stream.Write_String (Name); Stream.Write (':'); end if; end Write_Field_Name; -- ----------------------- -- Start writing an object identified by the given name -- ----------------------- procedure Start_Entity (Stream : in out Output_Stream; Name : in String) is Current : access Node_Info := Node_Info_Stack.Current (Stream.Stack); begin if Current /= null and then Current.Is_Root then if Name'Length > 0 then Stream.Write ('{'); Stream.Write_Field_Name (Name); Current.Has_Fields := True; end if; else Stream.Write_Field_Name (Name); end if; Node_Info_Stack.Push (Stream.Stack); Current := Node_Info_Stack.Current (Stream.Stack); Current.Has_Fields := False; Current.Is_Array := False; Current.Is_Root := False; Stream.Write ('{'); end Start_Entity; -- ----------------------- -- Finish writing an object identified by the given name -- ----------------------- procedure End_Entity (Stream : in out Output_Stream; Name : in String) is pragma Unreferenced (Name); begin Node_Info_Stack.Pop (Stream.Stack); Stream.Write ('}'); end End_Entity; -- ----------------------- -- Write the attribute name/value pair. -- ----------------------- overriding procedure Write_Attribute (Stream : in out Output_Stream; Name : in String; Value : in String) is begin Stream.Write_Field_Name (Name); Stream.Write_String (Value); end Write_Attribute; overriding procedure Write_Wide_Attribute (Stream : in out Output_Stream; Name : in String; Value : in Wide_Wide_String) is begin Stream.Write_Field_Name (Name); Stream.Write_Wide_String (Value); end Write_Wide_Attribute; overriding procedure Write_Attribute (Stream : in out Output_Stream; Name : in String; Value : in Integer) is begin Stream.Write_Field_Name (Name); Stream.Write (Integer'Image (Value)); end Write_Attribute; overriding procedure Write_Attribute (Stream : in out Output_Stream; Name : in String; Value : in Boolean) is begin Stream.Write_Field_Name (Name); if Value then Stream.Write ("true"); else Stream.Write ("false"); end if; end Write_Attribute; -- ----------------------- -- Write an attribute member from the current object -- ----------------------- procedure Write_Attribute (Stream : in out Output_Stream; Name : in String; Value : in Util.Beans.Objects.Object) is use Util.Beans.Objects; begin Stream.Write_Field_Name (Name); case Util.Beans.Objects.Get_Type (Value) is when TYPE_NULL => Stream.Write ("null"); when TYPE_BOOLEAN => if Util.Beans.Objects.To_Boolean (Value) then Stream.Write ("true"); else Stream.Write ("false"); end if; when TYPE_INTEGER => Stream.Stream.Write (Util.Beans.Objects.To_Long_Long_Integer (Value)); when others => Stream.Write_String (Util.Beans.Objects.To_String (Value)); end case; end Write_Attribute; -- ----------------------- -- Write the attribute with a null value. -- ----------------------- overriding procedure Write_Null_Attribute (Stream : in out Output_Stream; Name : in String) is begin Stream.Write_Field_Name (Name); Stream.Write ("null"); end Write_Null_Attribute; -- ----------------------- -- Write an object value as an entity -- ----------------------- procedure Write_Entity (Stream : in out Output_Stream; Name : in String; Value : in Util.Beans.Objects.Object) is use Util.Beans.Objects; begin case Util.Beans.Objects.Get_Type (Value) is when TYPE_NULL => Stream.Write_Field_Name (Name); Stream.Write ("null"); when TYPE_BOOLEAN => Stream.Write_Field_Name (Name); if Util.Beans.Objects.To_Boolean (Value) then Stream.Write ("true"); else Stream.Write ("false"); end if; when TYPE_INTEGER => Stream.Write_Field_Name (Name); Stream.Stream.Write (Util.Beans.Objects.To_Long_Long_Integer (Value)); when TYPE_FLOAT => Stream.Write_Field_Name (Name); Stream.Stream.Write (Long_Long_Float'Image (Util.Beans.Objects.To_Long_Long_Float (Value))); when TYPE_BEAN | TYPE_ARRAY => if Is_Array (Value) then Stream.Start_Array (Name); declare Count : constant Natural := Util.Beans.Objects.Get_Count (Value); begin for I in 1 .. Count loop Stream.Write_Entity ("", Util.Beans.Objects.Get_Value (Value, I)); end loop; end; Stream.End_Array (Name); else declare procedure Process (Name : in String; Item : in Object); procedure Process (Name : in String; Item : in Object) is begin Stream.Write (ASCII.LF); if Name'Length = 0 then Stream.Write (""""":"); end if; Stream.Write_Entity (Name, Item); end Process; begin Stream.Start_Entity (Name); Util.Beans.Objects.Maps.Iterate (Value, Process'Access); Stream.End_Entity (Name); end; end if; when others => Stream.Write_Field_Name (Name); Stream.Write_String (Util.Beans.Objects.To_String (Value)); end case; end Write_Entity; -- ----------------------- -- Write a JSON name/value pair (see Write_Attribute). -- ----------------------- overriding procedure Write_Entity (Stream : in out Output_Stream; Name : in String; Value : in String) is begin Stream.Write_Attribute (Name, Value); end Write_Entity; overriding procedure Write_Wide_Entity (Stream : in out Output_Stream; Name : in String; Value : in Wide_Wide_String) is begin Stream.Write_Wide_Attribute (Name, Value); end Write_Wide_Entity; -- ----------------------- -- Write a JSON name/value pair (see Write_Attribute). -- ----------------------- overriding procedure Write_Entity (Stream : in out Output_Stream; Name : in String; Value : in Integer) is begin Stream.Write_Attribute (Name, Value); end Write_Entity; overriding procedure Write_Entity (Stream : in out Output_Stream; Name : in String; Value : in Ada.Calendar.Time) is begin Stream.Write_Entity (Name, Util.Dates.ISO8601.Image (Value, Util.Dates.ISO8601.SUBSECOND)); end Write_Entity; -- ----------------------- -- Write an entity with a null value. -- ----------------------- overriding procedure Write_Null_Entity (Stream : in out Output_Stream; Name : in String) is begin Stream.Write_Null_Attribute (Name); end Write_Null_Entity; overriding procedure Write_Entity (Stream : in out Output_Stream; Name : in String; Value : in Boolean) is begin Stream.Write_Attribute (Name, Value); end Write_Entity; overriding procedure Write_Long_Entity (Stream : in out Output_Stream; Name : in String; Value : in Long_Long_Integer) is begin Stream.Write_Field_Name (Name); Stream.Write (Long_Long_Integer'Image (Value)); end Write_Long_Entity; overriding procedure Write_Enum_Entity (Stream : in out Output_Stream; Name : in String; Value : in String) is begin Stream.Write_Entity (Name, Value); end Write_Enum_Entity; -- ----------------------- -- Start an array that will contain the specified number of elements -- Example: "list": [ -- ----------------------- overriding procedure Start_Array (Stream : in out Output_Stream; Name : in String) is Current : access Node_Info := Node_Info_Stack.Current (Stream.Stack); begin if Current /= null then if Current.Has_Fields then Stream.Write (','); elsif not Current.Is_Root then Current.Has_Fields := True; elsif Name'Length > 0 then Stream.Write ('{'); Current.Has_Fields := True; else Current.Is_Array := True; Current.Has_Fields := True; end if; end if; Node_Info_Stack.Push (Stream.Stack); Current := Node_Info_Stack.Current (Stream.Stack); Current.Has_Fields := False; Current.Is_Array := True; Current.Is_Root := False; if Name'Length > 0 then Stream.Write_String (Name); Stream.Write (':'); end if; Stream.Write ('['); end Start_Array; -- ----------------------- -- Finishes an array -- ----------------------- overriding procedure End_Array (Stream : in out Output_Stream; Name : in String) is pragma Unreferenced (Name); begin Node_Info_Stack.Pop (Stream.Stack); Stream.Write (']'); end End_Array; -- ----------------------- -- Get the current location (file and line) to report an error message. -- ----------------------- function Get_Location (Handler : in Parser) return String is begin return Util.Strings.Image (Handler.Line_Number); end Get_Location; procedure Parse (Handler : in out Parser; Stream : in out Util.Streams.Buffered.Input_Buffer_Stream'Class; Sink : in out Reader'Class) is -- Put back a token in the buffer. procedure Put_Back (P : in out Parser'Class; Token : in Token_Type); -- Parse the expression buffer to find the next token. procedure Peek (P : in out Parser'Class; Token : out Token_Type); function Hexdigit (C : in Character) return Interfaces.Unsigned_32; -- Parse a list of members -- members ::= pair | pair ',' members -- pair ::= string ':' value -- value ::= string | number | object | array | true | false | null procedure Parse_Pairs (P : in out Parser'Class); -- Parse a value -- value ::= string | number | object | array | true | false | null procedure Parse_Value (P : in out Parser'Class; Name : in String); -- ------------------------------ -- Parse a list of members -- members ::= pair | pair ',' members -- pair ::= string ':' value -- value ::= string | number | object | array | true | false | null -- ------------------------------ procedure Parse_Pairs (P : in out Parser'Class) is Current_Name : Unbounded_String; Token : Token_Type; begin loop Peek (P, Token); if Token /= T_STRING then Put_Back (P, Token); return; end if; Current_Name := P.Token; Peek (P, Token); if Token /= T_COLON then P.Error ("Missing ':'"); end if; Parse_Value (P, To_String (Current_Name)); Peek (P, Token); if Token /= T_COMMA then Put_Back (P, Token); return; end if; end loop; end Parse_Pairs; function Hexdigit (C : in Character) return Interfaces.Unsigned_32 is use type Interfaces.Unsigned_32; begin if C >= '0' and C <= '9' then return Character'Pos (C) - Character'Pos ('0'); elsif C >= 'a' and C <= 'f' then return Character'Pos (C) - Character'Pos ('a') + 10; elsif C >= 'A' and C <= 'F' then return Character'Pos (C) - Character'Pos ('A') + 10; else raise Constraint_Error with "Invalid hexdigit: " & C; end if; end Hexdigit; -- ------------------------------ -- Parse a value -- value ::= string | number | object | array | true | false | null -- ------------------------------ procedure Parse_Value (P : in out Parser'Class; Name : in String) is Token : Token_Type; Index : Natural; begin Peek (P, Token); case Token is when T_LEFT_BRACE => Sink.Start_Object (Name, P); Parse_Pairs (P); Peek (P, Token); if Token /= T_RIGHT_BRACE then P.Error ("Missing '}'"); end if; Sink.Finish_Object (Name, P); -- when T_LEFT_BRACKET => Sink.Start_Array (Name, P); Peek (P, Token); Index := 0; if Token /= T_RIGHT_BRACKET then Put_Back (P, Token); loop Parse_Value (P, Util.Strings.Image (Index)); Peek (P, Token); exit when Token = T_RIGHT_BRACKET; if Token /= T_COMMA then P.Error ("Missing ']'"); exit when Token = T_EOF; end if; Index := Index + 1; end loop; end if; Sink.Finish_Array (Name, Index, P); when T_NULL => Sink.Set_Member (Name, Util.Beans.Objects.Null_Object, P); when T_NUMBER => declare Value : Long_Long_Integer; begin Value := Long_Long_Integer'Value (To_String (P.Token)); Sink.Set_Member (Name, Util.Beans.Objects.To_Object (Value), P); end; when T_FLOAT => declare Value : Long_Long_Float; begin Value := Long_Long_Float'Value (To_String (P.Token)); Sink.Set_Member (Name, Util.Beans.Objects.To_Object (Value), P); exception when Constraint_Error => P.Error ("Invalid number"); end; when T_STRING => Sink.Set_Member (Name, Util.Beans.Objects.To_Object (P.Token), P); when T_TRUE => Sink.Set_Member (Name, Util.Beans.Objects.To_Object (True), P); when T_FALSE => Sink.Set_Member (Name, Util.Beans.Objects.To_Object (False), P); when T_EOF => P.Error ("End of stream reached"); return; when others => P.Error ("Invalid token"); end case; end Parse_Value; -- ------------------------------ -- Put back a token in the buffer. -- ------------------------------ procedure Put_Back (P : in out Parser'Class; Token : in Token_Type) is begin P.Pending_Token := Token; end Put_Back; -- ------------------------------ -- Parse the expression buffer to find the next token. -- ------------------------------ procedure Peek (P : in out Parser'Class; Token : out Token_Type) is use Ada.Characters; C, C1 : Character; begin -- If a token was put back, return it. if P.Pending_Token /= T_EOF then Token := P.Pending_Token; P.Pending_Token := T_EOF; return; end if; if P.Has_Pending_Char then C := P.Pending_Char; else -- Skip white spaces loop Stream.Read (Char => C); if C = Ada.Characters.Latin_1.LF then P.Line_Number := P.Line_Number + 1; else exit when C /= ' ' and C /= Ada.Characters.Latin_1.CR and C /= Ada.Characters.Latin_1.HT; end if; end loop; end if; P.Has_Pending_Char := False; -- See what we have and continue parsing. case C is -- Literal string using double quotes -- Collect up to the end of the string and put -- the result in the parser token result. when '"' => Delete (P.Token, 1, Length (P.Token)); loop Stream.Read (Char => C1); if C1 = '\' then Stream.Read (Char => C1); case C1 is when '"' | '\' | '/' => null; when 'b' => C1 := Ada.Characters.Latin_1.BS; when 'f' => C1 := Ada.Characters.Latin_1.VT; when 'n' => C1 := Ada.Characters.Latin_1.LF; when 'r' => C1 := Ada.Characters.Latin_1.CR; when 't' => C1 := Ada.Characters.Latin_1.HT; when 'u' => declare use Interfaces; C2, C3, C4 : Character; Val : Interfaces.Unsigned_32; begin Stream.Read (Char => C1); Stream.Read (Char => C2); Stream.Read (Char => C3); Stream.Read (Char => C4); Val := Interfaces.Shift_Left (Hexdigit (C1), 12); Val := Val + Interfaces.Shift_Left (Hexdigit (C2), 8); Val := Val + Interfaces.Shift_Left (Hexdigit (C3), 4); Val := Val + Hexdigit (C4); -- Encode the value as an UTF-8 string. if Val >= 16#1000# then Append (P.Token, Character'Val (16#E0# or Shift_Right (Val, 12))); Val := Val and 16#0fff#; Append (P.Token, Character'Val (16#80# or Shift_Right (Val, 6))); Val := Val and 16#03f#; C1 := Character'Val (16#80# or Val); elsif Val >= 16#80# then Append (P.Token, Character'Val (16#C0# or Shift_Right (Val, 6))); Val := Val and 16#03f#; C1 := Character'Val (16#80# or Val); else C1 := Character'Val (Val); end if; end; when others => P.Error ("Invalid character '" & C1 & "' in \x sequence"); end case; elsif C1 = C then Token := T_STRING; return; end if; Append (P.Token, C1); end loop; -- Number when '-' | '0' .. '9' => Delete (P.Token, 1, Length (P.Token)); Append (P.Token, C); Token := T_NUMBER; begin loop Stream.Read (Char => C); exit when C not in '0' .. '9'; Append (P.Token, C); end loop; if C = '.' then Token := T_FLOAT; Append (P.Token, C); loop Stream.Read (Char => C); exit when C not in '0' .. '9'; Append (P.Token, C); end loop; end if; if C = 'e' or C = 'E' then Token := T_FLOAT; Append (P.Token, C); Stream.Read (Char => C); if C = '+' or C = '-' then Append (P.Token, C); Stream.Read (Char => C); end if; while C in '0' .. '9' loop Append (P.Token, C); Stream.Read (Char => C); end loop; end if; if not (C in ' ' | Latin_1.HT | Latin_1.LF | Latin_1.CR) then P.Has_Pending_Char := True; P.Pending_Char := C; end if; exception when Ada.IO_Exceptions.Data_Error => null; end; return; -- Parse a name composed of letters or digits. when 'a' .. 'z' | 'A' .. 'Z' => Delete (P.Token, 1, Length (P.Token)); Append (P.Token, C); loop Stream.Read (Char => C); exit when not (C in 'a' .. 'z' or C in 'A' .. 'Z' or C in '0' .. '9' or C = '_'); Append (P.Token, C); end loop; -- Putback the last character unless we can ignore it. if not (C in ' ' | Latin_1.HT | Latin_1.LF | Latin_1.CR) then P.Has_Pending_Char := True; P.Pending_Char := C; end if; -- and empty eq false ge gt le lt ne not null true case Element (P.Token, 1) is when 'n' | 'N' => if P.Token = "null" then Token := T_NULL; return; end if; when 'f' | 'F' => if P.Token = "false" then Token := T_FALSE; return; end if; when 't' | 'T' => if P.Token = "true" then Token := T_TRUE; return; end if; when others => null; end case; Token := T_UNKNOWN; return; when '{' => Token := T_LEFT_BRACE; return; when '}' => Token := T_RIGHT_BRACE; return; when '[' => Token := T_LEFT_BRACKET; return; when ']' => Token := T_RIGHT_BRACKET; return; when ':' => Token := T_COLON; return; when ',' => Token := T_COMMA; return; when others => Token := T_UNKNOWN; return; end case; exception when Ada.IO_Exceptions.Data_Error => Token := T_EOF; return; end Peek; begin Parse_Value (Handler, ""); end Parse; -- Read a JSON file and return an object. function Read (Path : in String) return Util.Beans.Objects.Object is P : Parser; R : Util.Beans.Objects.Readers.Reader; begin P.Parse (Path, R); if P.Has_Error then return Util.Beans.Objects.Null_Object; else return R.Get_Root; end if; end Read; end Util.Serialize.IO.JSON;
Heziode/lsystem-editor
Ada
2,811
ads
------------------------------------------------------------------------------- -- LSE -- L-System Editor -- Author: Heziode -- -- License: -- MIT License -- -- Copyright (c) 2018 Quentin Dauprat (Heziode) <[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. ------------------------------------------------------------------------------- -- @description -- This package provide a abstract error system. -- package LSE.Model.L_System.Error is type Instance is abstract tagged private; package Error_Type is -- Type of errors supported for the L-System type Instance is ( -- Input contains unexpected character Unexpected_Character, -- Angle not found Missing_Angle, -- Value for angle is not in range Not_A_Angle, -- Axiom not found Missing_Axiom, -- Rule not found Missing_Rule, -- Ununderstandable rule found Invalid_Rule, -- Save character as missing Missing_Save, -- Restore character as missing Missing_Restore ); end Error_Type; -- Getting the error function Get_Error (This : Instance) return String is abstract; -- Getting the type of this error function Get_Error_Type (This : Instance) return Error_Type.Instance; private type Instance is abstract tagged record -- Type of this error Error : Error_Type.Instance; end record; end LSE.Model.L_System.Error;
persan/gprTools
Ada
22
ads
package p3 is end p3;
reznikmm/matreshka
Ada
4,631
adb
------------------------------------------------------------------------------ -- -- -- Matreshka Project -- -- -- -- Open Document Toolkit -- -- -- -- Runtime Library Component -- -- -- ------------------------------------------------------------------------------ -- -- -- Copyright © 2014, Vadim Godunko <[email protected]> -- -- All rights reserved. -- -- -- -- Redistribution and use in source and binary forms, with or without -- -- modification, are permitted provided that the following conditions -- -- are met: -- -- -- -- * Redistributions of source code must retain the above copyright -- -- notice, this list of conditions and the following disclaimer. -- -- -- -- * Redistributions in binary form must reproduce the above copyright -- -- notice, this list of conditions and the following disclaimer in the -- -- documentation and/or other materials provided with the distribution. -- -- -- -- * Neither the name of the Vadim Godunko, IE nor the names of its -- -- contributors may be used to endorse or promote products derived from -- -- this software without specific prior written permission. -- -- -- -- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -- -- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -- -- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -- -- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -- -- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -- -- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED -- -- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -- -- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -- -- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -- -- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -- -- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- -- -- ------------------------------------------------------------------------------ -- $Revision$ $Date$ ------------------------------------------------------------------------------ with Matreshka.DOM_Documents; with Matreshka.ODF_String_Constants; with ODF.DOM.Iterators; with ODF.DOM.Visitors; package body Matreshka.ODF_Form.Ignore_Result_Attributes is ------------ -- Create -- ------------ overriding function Create (Parameters : not null access Matreshka.DOM_Attributes.Attribute_L2_Parameters) return Form_Ignore_Result_Attribute_Node is begin return Self : Form_Ignore_Result_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_Ignore_Result_Attribute_Node) return League.Strings.Universal_String is pragma Unreferenced (Self); begin return Matreshka.ODF_String_Constants.Ignore_Result_Attribute; end Get_Local_Name; begin Matreshka.DOM_Documents.Register_Attribute (Matreshka.ODF_String_Constants.Form_URI, Matreshka.ODF_String_Constants.Ignore_Result_Attribute, Form_Ignore_Result_Attribute_Node'Tag); end Matreshka.ODF_Form.Ignore_Result_Attributes;