repo_name
stringlengths
9
74
language
stringclasses
1 value
length_bytes
int64
11
9.34M
extension
stringclasses
2 values
content
stringlengths
11
9.34M
reznikmm/matreshka
Ada
3,612
ads
------------------------------------------------------------------------------ -- -- -- Matreshka Project -- -- -- -- Ada Modeling Framework -- -- -- -- Runtime Library Component -- -- -- ------------------------------------------------------------------------------ -- -- -- Copyright © 2011, Vadim Godunko <[email protected]> -- -- All rights reserved. -- -- -- -- Redistribution and use in source and binary forms, with or without -- -- modification, are permitted provided that the following conditions -- -- are met: -- -- -- -- * Redistributions of source code must retain the above copyright -- -- notice, this list of conditions and the following disclaimer. -- -- -- -- * Redistributions in binary form must reproduce the above copyright -- -- notice, this list of conditions and the following disclaimer in the -- -- documentation and/or other materials provided with the distribution. -- -- -- -- * Neither the name of the Vadim Godunko, IE nor the names of its -- -- contributors may be used to endorse or promote products derived from -- -- this software without specific prior written permission. -- -- -- -- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -- -- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -- -- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -- -- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -- -- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -- -- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED -- -- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -- -- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -- -- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -- -- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -- -- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- -- -- ------------------------------------------------------------------------------ -- $Revision$ $Date$ ------------------------------------------------------------------------------ with AMF.Reflective_Collections; with League.Holders.Generic_Holders; package AMF.Holders.Reflective_Collections is new League.Holders.Generic_Holders (AMF.Reflective_Collections.Reflective_Collection); pragma Preelaborate (AMF.Holders.Reflective_Collections);
reznikmm/matreshka
Ada
4,705
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_Number.Truncate_On_Overflow_Attributes is ------------ -- Create -- ------------ overriding function Create (Parameters : not null access Matreshka.DOM_Attributes.Attribute_L2_Parameters) return Number_Truncate_On_Overflow_Attribute_Node is begin return Self : Number_Truncate_On_Overflow_Attribute_Node do Matreshka.ODF_Number.Constructors.Initialize (Self'Unchecked_Access, Parameters.Document, Matreshka.ODF_String_Constants.Number_Prefix); end return; end Create; -------------------- -- Get_Local_Name -- -------------------- overriding function Get_Local_Name (Self : not null access constant Number_Truncate_On_Overflow_Attribute_Node) return League.Strings.Universal_String is pragma Unreferenced (Self); begin return Matreshka.ODF_String_Constants.Truncate_On_Overflow_Attribute; end Get_Local_Name; begin Matreshka.DOM_Documents.Register_Attribute (Matreshka.ODF_String_Constants.Number_URI, Matreshka.ODF_String_Constants.Truncate_On_Overflow_Attribute, Number_Truncate_On_Overflow_Attribute_Node'Tag); end Matreshka.ODF_Number.Truncate_On_Overflow_Attributes;
reznikmm/matreshka
Ada
4,257
adb
------------------------------------------------------------------------------ -- -- -- Matreshka Project -- -- -- -- Open Document Toolkit -- -- -- -- Runtime Library Component -- -- -- ------------------------------------------------------------------------------ -- -- -- Copyright © 2013, Vadim Godunko <[email protected]> -- -- All rights reserved. -- -- -- -- Redistribution and use in source and binary forms, with or without -- -- modification, are permitted provided that the following conditions -- -- are met: -- -- -- -- * Redistributions of source code must retain the above copyright -- -- notice, this list of conditions and the following disclaimer. -- -- -- -- * Redistributions in binary form must reproduce the above copyright -- -- notice, this list of conditions and the following disclaimer in the -- -- documentation and/or other materials provided with the distribution. -- -- -- -- * Neither the name of the Vadim Godunko, IE nor the names of its -- -- contributors may be used to endorse or promote products derived from -- -- this software without specific prior written permission. -- -- -- -- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -- -- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -- -- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -- -- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -- -- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -- -- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED -- -- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -- -- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -- -- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -- -- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -- -- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- -- -- ------------------------------------------------------------------------------ -- $Revision$ $Date$ ------------------------------------------------------------------------------ with Matreshka.DOM_Nodes; with XML.DOM.Elements.Internals; package body ODF.DOM.Elements.Style.Footnote_Sep.Internals is ------------ -- Create -- ------------ function Create (Node : Matreshka.ODF_Elements.Style.Footnote_Sep.Style_Footnote_Sep_Access) return ODF.DOM.Elements.Style.Footnote_Sep.ODF_Style_Footnote_Sep is begin return (XML.DOM.Elements.Internals.Create (Matreshka.DOM_Nodes.Element_Access (Node)) with null record); end Create; ---------- -- Wrap -- ---------- function Wrap (Node : Matreshka.ODF_Elements.Style.Footnote_Sep.Style_Footnote_Sep_Access) return ODF.DOM.Elements.Style.Footnote_Sep.ODF_Style_Footnote_Sep is begin return (XML.DOM.Elements.Internals.Wrap (Matreshka.DOM_Nodes.Element_Access (Node)) with null record); end Wrap; end ODF.DOM.Elements.Style.Footnote_Sep.Internals;
AdaCore/ada-traits-containers
Ada
538
adb
-- -- Copyright (C) 2016, AdaCore -- -- SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -- pragma Ada_2012; with Conts.Lists.Definite_Bounded; with Support; procedure Main is package Int_Lists is new Conts.Lists.Definite_Bounded (Integer); package Tests is new Support (Image => Integer'Image, Elements => Int_Lists.Elements.Traits, Storage => Int_Lists.Storage.Traits, Lists => Int_Lists.Lists); L1, L2 : Int_Lists.List (20); begin Tests.Test (L1, L2); end Main;
MinimSecure/unum-sdk
Ada
930
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 function Ident (P : Parameter) return Parameter is begin return P; end Ident; procedure Do_Nothing (P : in out Parameter) is begin null; end Do_Nothing; end Pck;
stcarrez/dynamo
Ada
8,401
ads
------------------------------------------------------------------------------ -- -- -- GNAT COMPILER COMPONENTS -- -- -- -- D E B U G -- -- -- -- S p e c -- -- -- -- Copyright (C) 1992-2009, 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 global flags used to control the inclusion -- of debugging code in various phases of the compiler. Some of these -- flags are also used by the binder and gnatmake. package Debug is pragma Preelaborate; ------------------------- -- Dynamic Debug Flags -- ------------------------- -- Flags that can be used to active various specialized debugging output -- information. The flags are preset to False, which corresponds to the -- given output being suppressed. The individual flags can be turned on -- using the undocumented switch dxxx where xxx is a string of letters for -- flags to be turned on. Documentation on the current usage of these flags -- is contained in the body of Debug rather than the spec, so that we don't -- have to recompile the world when a new debug flag is added. Debug_Flag_A : Boolean := False; Debug_Flag_B : Boolean := False; Debug_Flag_C : Boolean := False; Debug_Flag_D : Boolean := False; Debug_Flag_E : Boolean := False; Debug_Flag_F : Boolean := False; Debug_Flag_G : Boolean := False; Debug_Flag_H : Boolean := False; Debug_Flag_I : Boolean := False; Debug_Flag_J : Boolean := False; Debug_Flag_K : Boolean := False; Debug_Flag_L : Boolean := False; Debug_Flag_M : Boolean := False; Debug_Flag_N : Boolean := False; Debug_Flag_O : Boolean := False; Debug_Flag_P : Boolean := False; Debug_Flag_Q : Boolean := False; Debug_Flag_R : Boolean := False; Debug_Flag_S : Boolean := False; Debug_Flag_T : Boolean := False; Debug_Flag_U : Boolean := False; Debug_Flag_V : Boolean := False; Debug_Flag_W : Boolean := False; Debug_Flag_X : Boolean := False; Debug_Flag_Y : Boolean := False; Debug_Flag_Z : Boolean := False; Debug_Flag_AA : Boolean := False; Debug_Flag_BB : Boolean := False; Debug_Flag_CC : Boolean := False; Debug_Flag_DD : Boolean := False; Debug_Flag_EE : Boolean := False; Debug_Flag_FF : Boolean := False; Debug_Flag_GG : Boolean := False; Debug_Flag_HH : Boolean := False; Debug_Flag_II : Boolean := False; Debug_Flag_JJ : Boolean := False; Debug_Flag_KK : Boolean := False; Debug_Flag_LL : Boolean := False; Debug_Flag_MM : Boolean := False; Debug_Flag_NN : Boolean := False; Debug_Flag_OO : Boolean := False; Debug_Flag_PP : Boolean := False; Debug_Flag_QQ : Boolean := False; Debug_Flag_RR : Boolean := False; Debug_Flag_SS : Boolean := False; Debug_Flag_TT : Boolean := False; Debug_Flag_UU : Boolean := False; Debug_Flag_VV : Boolean := False; Debug_Flag_WW : Boolean := False; Debug_Flag_XX : Boolean := False; Debug_Flag_YY : Boolean := False; Debug_Flag_ZZ : Boolean := False; Debug_Flag_1 : Boolean := False; Debug_Flag_2 : Boolean := False; Debug_Flag_3 : Boolean := False; Debug_Flag_4 : Boolean := False; Debug_Flag_5 : Boolean := False; Debug_Flag_6 : Boolean := False; Debug_Flag_7 : Boolean := False; Debug_Flag_8 : Boolean := False; Debug_Flag_9 : Boolean := False; Debug_Flag_Dot_A : Boolean := False; Debug_Flag_Dot_B : Boolean := False; Debug_Flag_Dot_C : Boolean := False; Debug_Flag_Dot_D : Boolean := False; Debug_Flag_Dot_E : Boolean := False; Debug_Flag_Dot_F : Boolean := False; Debug_Flag_Dot_G : Boolean := False; Debug_Flag_Dot_H : Boolean := False; Debug_Flag_Dot_I : Boolean := False; Debug_Flag_Dot_J : Boolean := False; Debug_Flag_Dot_K : Boolean := False; Debug_Flag_Dot_L : Boolean := False; Debug_Flag_Dot_M : Boolean := False; Debug_Flag_Dot_N : Boolean := False; Debug_Flag_Dot_O : Boolean := False; Debug_Flag_Dot_P : Boolean := False; Debug_Flag_Dot_Q : Boolean := False; Debug_Flag_Dot_R : Boolean := False; Debug_Flag_Dot_S : Boolean := False; Debug_Flag_Dot_T : Boolean := False; Debug_Flag_Dot_U : Boolean := False; Debug_Flag_Dot_V : Boolean := False; Debug_Flag_Dot_W : Boolean := False; Debug_Flag_Dot_X : Boolean := False; Debug_Flag_Dot_Y : Boolean := False; Debug_Flag_Dot_Z : Boolean := False; Debug_Flag_Dot_AA : Boolean := False; Debug_Flag_Dot_BB : Boolean := False; Debug_Flag_Dot_CC : Boolean := False; Debug_Flag_Dot_DD : Boolean := False; Debug_Flag_Dot_EE : Boolean := False; Debug_Flag_Dot_FF : Boolean := False; Debug_Flag_Dot_GG : Boolean := False; Debug_Flag_Dot_HH : Boolean := False; Debug_Flag_Dot_II : Boolean := False; Debug_Flag_Dot_JJ : Boolean := False; Debug_Flag_Dot_KK : Boolean := False; Debug_Flag_Dot_LL : Boolean := False; Debug_Flag_Dot_MM : Boolean := False; Debug_Flag_Dot_NN : Boolean := False; Debug_Flag_Dot_OO : Boolean := False; Debug_Flag_Dot_PP : Boolean := False; Debug_Flag_Dot_QQ : Boolean := False; Debug_Flag_Dot_RR : Boolean := False; Debug_Flag_Dot_SS : Boolean := False; Debug_Flag_Dot_TT : Boolean := False; Debug_Flag_Dot_UU : Boolean := False; Debug_Flag_Dot_VV : Boolean := False; Debug_Flag_Dot_WW : Boolean := False; Debug_Flag_Dot_XX : Boolean := False; Debug_Flag_Dot_YY : Boolean := False; Debug_Flag_Dot_ZZ : Boolean := False; Debug_Flag_Dot_1 : Boolean := False; Debug_Flag_Dot_2 : Boolean := False; Debug_Flag_Dot_3 : Boolean := False; Debug_Flag_Dot_4 : Boolean := False; Debug_Flag_Dot_5 : Boolean := False; Debug_Flag_Dot_6 : Boolean := False; Debug_Flag_Dot_7 : Boolean := False; Debug_Flag_Dot_8 : Boolean := False; Debug_Flag_Dot_9 : Boolean := False; procedure Set_Debug_Flag (C : Character; Val : Boolean := True); -- Where C is 0-9, A-Z, or a-z, sets the corresponding debug flag to -- the given value. In the checks off version of debug, the call to -- Set_Debug_Flag is always a null operation. procedure Set_Dotted_Debug_Flag (C : Character; Val : Boolean := True); -- Where C is 0-9, A-Z, or a-z, sets the corresponding dotted debug -- flag (e.g. call with C = 'a' for the .a flag). end Debug;
reznikmm/matreshka
Ada
3,907
ads
------------------------------------------------------------------------------ -- -- -- Matreshka Project -- -- -- -- Ada Modeling Framework -- -- -- -- Runtime Library Component -- -- -- ------------------------------------------------------------------------------ -- -- -- Copyright © 2012, Vadim Godunko <[email protected]> -- -- All rights reserved. -- -- -- -- Redistribution and use in source and binary forms, with or without -- -- modification, are permitted provided that the following conditions -- -- are met: -- -- -- -- * Redistributions of source code must retain the above copyright -- -- notice, this list of conditions and the following disclaimer. -- -- -- -- * Redistributions in binary form must reproduce the above copyright -- -- notice, this list of conditions and the following disclaimer in the -- -- documentation and/or other materials provided with the distribution. -- -- -- -- * Neither the name of the Vadim Godunko, IE nor the names of its -- -- contributors may be used to endorse or promote products derived from -- -- this software without specific prior written permission. -- -- -- -- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -- -- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -- -- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -- -- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -- -- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -- -- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED -- -- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -- -- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -- -- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -- -- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -- -- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- -- -- ------------------------------------------------------------------------------ -- $Revision$ $Date$ ------------------------------------------------------------------------------ -- This file is generated, don't edit it. ------------------------------------------------------------------------------ with AMF.MOF.Tags; package AMF.Visitors.MOF_Iterators is pragma Preelaborate; type MOF_Iterator is limited interface and AMF.Visitors.Abstract_Iterator; not overriding procedure Visit_Tag (Self : in out MOF_Iterator; Visitor : in out AMF.Visitors.Abstract_Visitor'Class; Element : not null AMF.MOF.Tags.MOF_Tag_Access; Control : in out AMF.Visitors.Traverse_Control) is null; end AMF.Visitors.MOF_Iterators;
jscparker/math_packages
Ada
2,409
ads
-- -- The following is based on John Maddock's extended precision -- (Boost Library) gamma function. It uses the gamma rational -- poly functions (for the range x = 1 to 3) worked out by John Maddock, -- so his Copyright will be retained. -- -------------------------------------------------------------------------- -- (C) Copyright John Maddock 2006. -- Use, modification and distribution are subject to the -- Boost Software License, Version 1.0. (See accompanying file -- LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) -- --Boost Software License - Version 1.0 - August 17th, 2003 -- --Permission is hereby granted, free of charge, to any person or organization --obtaining a copy of the software and accompanying documentation covered by --this license (the "Software") to use, reproduce, display, distribute, --execute, and transmit the Software, and to prepare derivative works of the --Software, and to permit third-parties to whom the Software is furnished to --do so, all subject to the following: -- --The copyright notices in the Software and this entire statement, including --the above license grant, this restriction and the following disclaimer, --must be included in all copies of the Software, in whole or in part, and --all derivative works of the Software, unless such copies or derivative --works are solely in the form of machine-executable object code generated by --a source language processor. -- --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, TITLE AND NON-INFRINGEMENT. IN NO EVENT --SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE --FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE, --ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER --DEALINGS IN THE SOFTWARE. -------------------------------------------------------------------------- -- -- Natural logarithm of Gamma function for positive real arguments. -- generic type Real is digits <>; package Gamma_1_to_3 is pragma Pure(Gamma_1_to_3); function Log_Gamma_1_to_3 (x : in Real) return Real; -- Only good for 1 < x < 3 private Real_Epsilon : constant Real := (+0.125) * Real'Epsilon; -- have to modify this if Real is abstract end Gamma_1_to_3;
reznikmm/matreshka
Ada
3,689
ads
------------------------------------------------------------------------------ -- -- -- Matreshka Project -- -- -- -- Open Document Toolkit -- -- -- -- Runtime Library Component -- -- -- ------------------------------------------------------------------------------ -- -- -- Copyright © 2014, Vadim Godunko <[email protected]> -- -- All rights reserved. -- -- -- -- Redistribution and use in source and binary forms, with or without -- -- modification, are permitted provided that the following conditions -- -- are met: -- -- -- -- * Redistributions of source code must retain the above copyright -- -- notice, this list of conditions and the following disclaimer. -- -- -- -- * Redistributions in binary form must reproduce the above copyright -- -- notice, this list of conditions and the following disclaimer in the -- -- documentation and/or other materials provided with the distribution. -- -- -- -- * Neither the name of the Vadim Godunko, IE nor the names of its -- -- contributors may be used to endorse or promote products derived from -- -- this software without specific prior written permission. -- -- -- -- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -- -- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -- -- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -- -- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -- -- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -- -- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED -- -- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -- -- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -- -- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -- -- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -- -- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- -- -- ------------------------------------------------------------------------------ -- $Revision$ $Date$ ------------------------------------------------------------------------------ with XML.DOM.Elements; package ODF.DOM.Presentation_Notes_Elements is pragma Preelaborate; type ODF_Presentation_Notes is limited interface and XML.DOM.Elements.DOM_Element; type ODF_Presentation_Notes_Access is access all ODF_Presentation_Notes'Class with Storage_Size => 0; end ODF.DOM.Presentation_Notes_Elements;
reznikmm/matreshka
Ada
3,749
ads
------------------------------------------------------------------------------ -- -- -- Matreshka Project -- -- -- -- Open Document Toolkit -- -- -- -- Runtime Library Component -- -- -- ------------------------------------------------------------------------------ -- -- -- Copyright © 2014, Vadim Godunko <[email protected]> -- -- All rights reserved. -- -- -- -- Redistribution and use in source and binary forms, with or without -- -- modification, are permitted provided that the following conditions -- -- are met: -- -- -- -- * Redistributions of source code must retain the above copyright -- -- notice, this list of conditions and the following disclaimer. -- -- -- -- * Redistributions in binary form must reproduce the above copyright -- -- notice, this list of conditions and the following disclaimer in the -- -- documentation and/or other materials provided with the distribution. -- -- -- -- * Neither the name of the Vadim Godunko, IE nor the names of its -- -- contributors may be used to endorse or promote products derived from -- -- this software without specific prior written permission. -- -- -- -- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -- -- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -- -- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -- -- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -- -- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -- -- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED -- -- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -- -- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -- -- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -- -- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -- -- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- -- -- ------------------------------------------------------------------------------ -- $Revision$ $Date$ ------------------------------------------------------------------------------ with XML.DOM.Attributes; package ODF.DOM.Table_Last_Row_Spanned_Attributes is pragma Preelaborate; type ODF_Table_Last_Row_Spanned_Attribute is limited interface and XML.DOM.Attributes.DOM_Attribute; type ODF_Table_Last_Row_Spanned_Attribute_Access is access all ODF_Table_Last_Row_Spanned_Attribute'Class with Storage_Size => 0; end ODF.DOM.Table_Last_Row_Spanned_Attributes;
reznikmm/matreshka
Ada
4,597
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_Fo.Border_Left_Attributes is ------------ -- Create -- ------------ overriding function Create (Parameters : not null access Matreshka.DOM_Attributes.Attribute_L2_Parameters) return Fo_Border_Left_Attribute_Node is begin return Self : Fo_Border_Left_Attribute_Node do Matreshka.ODF_Fo.Constructors.Initialize (Self'Unchecked_Access, Parameters.Document, Matreshka.ODF_String_Constants.Fo_Prefix); end return; end Create; -------------------- -- Get_Local_Name -- -------------------- overriding function Get_Local_Name (Self : not null access constant Fo_Border_Left_Attribute_Node) return League.Strings.Universal_String is pragma Unreferenced (Self); begin return Matreshka.ODF_String_Constants.Border_Left_Attribute; end Get_Local_Name; begin Matreshka.DOM_Documents.Register_Attribute (Matreshka.ODF_String_Constants.Fo_URI, Matreshka.ODF_String_Constants.Border_Left_Attribute, Fo_Border_Left_Attribute_Node'Tag); end Matreshka.ODF_Fo.Border_Left_Attributes;
zhmu/ananas
Ada
4,663
ads
------------------------------------------------------------------------------ -- -- -- GNAT COMPILER COMPONENTS -- -- -- -- I N T E R F A C E S . C . P O I N T E R S -- -- -- -- S p e c -- -- -- -- Copyright (C) 1993-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 System.Parameters; generic type Index is (<>); type Element is private; type Element_Array is array (Index range <>) of aliased Element; Default_Terminator : Element; package Interfaces.C.Pointers is pragma Preelaborate; type Pointer is access all Element; for Pointer'Size use System.Parameters.ptr_bits; pragma No_Strict_Aliasing (Pointer); -- We turn off any strict aliasing assumptions for the pointer type, -- since it is possible to create "improperly" aliased values. function Value (Ref : Pointer; Terminator : Element := Default_Terminator) return Element_Array; function Value (Ref : Pointer; Length : ptrdiff_t) return Element_Array; Pointer_Error : exception; -------------------------------- -- C-style Pointer Arithmetic -- -------------------------------- function "+" (Left : Pointer; Right : ptrdiff_t) return Pointer; function "+" (Left : ptrdiff_t; Right : Pointer) return Pointer; function "-" (Left : Pointer; Right : ptrdiff_t) return Pointer; function "-" (Left : Pointer; Right : Pointer) return ptrdiff_t; procedure Increment (Ref : in out Pointer); procedure Decrement (Ref : in out Pointer); pragma Convention (Intrinsic, "+"); pragma Convention (Intrinsic, "-"); pragma Convention (Intrinsic, Increment); pragma Convention (Intrinsic, Decrement); function Virtual_Length (Ref : Pointer; Terminator : Element := Default_Terminator) return ptrdiff_t; procedure Copy_Terminated_Array (Source : Pointer; Target : Pointer; Limit : ptrdiff_t := ptrdiff_t'Last; Terminator : Element := Default_Terminator); procedure Copy_Array (Source : Pointer; Target : Pointer; Length : ptrdiff_t); private pragma Inline ("+"); pragma Inline ("-"); pragma Inline (Decrement); pragma Inline (Increment); end Interfaces.C.Pointers;
zhmu/ananas
Ada
24,943
adb
------------------------------------------------------------------------------ -- -- -- GNAT COMPILER COMPONENTS -- -- -- -- ADA.EXCEPTIONS.EXCEPTION_DATA -- -- -- -- B o d y -- -- -- -- Copyright (C) 1992-2022, Free Software Foundation, Inc. -- -- -- -- GNAT is free software; you can redistribute it and/or modify it under -- -- terms of the GNU General Public License as published by the Free Soft- -- -- ware Foundation; either version 3, or (at your option) any later ver- -- -- sion. GNAT is distributed in the hope that it will be useful, but WITH- -- -- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY -- -- or FITNESS FOR A PARTICULAR PURPOSE. -- -- -- -- As a special exception under Section 7 of GPL version 3, you are granted -- -- additional permissions described in the GCC Runtime Library Exception, -- -- version 3.1, as published by the Free Software Foundation. -- -- -- -- You should have received a copy of the GNU General Public License and -- -- a copy of the GCC Runtime Library Exception along with this program; -- -- see the files COPYING3 and COPYING.RUNTIME respectively. If not, see -- -- <http://www.gnu.org/licenses/>. -- -- -- -- GNAT was originally developed by the GNAT team at New York University. -- -- Extensive contributions were provided by Ada Core Technologies Inc. -- -- -- ------------------------------------------------------------------------------ with System.Storage_Elements; use System.Storage_Elements; separate (Ada.Exceptions) package body Exception_Data is -- This unit implements the Exception_Information related services for -- both the Ada standard requirements and the GNAT.Exception_Traces -- facility. This is also used by the implementation of the stream -- attributes of types Exception_Id and Exception_Occurrence. -- There are common parts between the contents of Exception_Information -- (the regular Ada interface) and Untailored_Exception_Information (used -- for streaming, and when there is no symbolic traceback available) The -- overall structure is sketched below: -- -- Untailored_Exception_Information -- | -- +-------+--------+ -- | | -- Basic_Exc_Info & Untailored_Exc_Tback -- (B_E_I) (U_E_TB) -- o-- -- (B_E_I) | Exception_Name: <exception name> (as in Exception_Name) -- | Message: <message> (or a null line if no message) -- | PID=nnnn (if nonzero) -- o-- -- (U_E_TB) | Call stack traceback locations: -- | <0xyyyyyyyy 0xyyyyyyyy ...> -- o-- -- Exception_Information -- | -- +----------+----------+ -- | | -- Basic_Exc_Info & traceback -- | -- +-----------+------------+ -- | | -- Untailored_Exc_Tback Or Tback_Decorator -- if no decorator set otherwise -- Functions returning String imply secondary stack use, which is a heavy -- mechanism requiring run-time support. Besides, some of the routines we -- provide here are to be used by the default Last_Chance_Handler, at the -- critical point where the runtime is about to be finalized. Since most -- of the items we have at hand are of bounded length, we also provide a -- procedural interface able to incrementally append the necessary bits to -- a preallocated buffer or output them straight to stderr. -- The procedural interface is composed of two major sections: a neutral -- section for basic types like Address, Character, Natural or String, and -- an exception oriented section for the exception names, messages, and -- information. This is the Append_Info family of procedures below. -- Output to stderr is commanded by passing an empty buffer to update, and -- care is taken not to overflow otherwise. -------------------------------------------- -- Procedural Interface - Neutral section -- -------------------------------------------- procedure Append_Info_Address (A : Address; Info : in out String; Ptr : in out Natural); procedure Append_Info_Character (C : Character; Info : in out String; Ptr : in out Natural); procedure Append_Info_Nat (N : Natural; Info : in out String; Ptr : in out Natural); procedure Append_Info_NL (Info : in out String; Ptr : in out Natural); pragma Inline (Append_Info_NL); procedure Append_Info_String (S : String; Info : in out String; Ptr : in out Natural); ------------------------------------------------------- -- Procedural Interface - Exception oriented section -- ------------------------------------------------------- procedure Append_Info_Exception_Name (Id : Exception_Id; Info : in out String; Ptr : in out Natural); procedure Append_Info_Exception_Name (X : Exception_Occurrence; Info : in out String; Ptr : in out Natural); procedure Append_Info_Exception_Message (X : Exception_Occurrence; Info : in out String; Ptr : in out Natural); procedure Append_Info_Basic_Exception_Information (X : Exception_Occurrence; Info : in out String; Ptr : in out Natural); procedure Append_Info_Untailored_Exception_Traceback (X : Exception_Occurrence; Info : in out String; Ptr : in out Natural); procedure Append_Info_Untailored_Exception_Information (X : Exception_Occurrence; Info : in out String; Ptr : in out Natural); -- The "functional" interface to the exception information not involving -- a traceback decorator uses preallocated intermediate buffers to avoid -- the use of secondary stack. Preallocation requires preliminary length -- computation, for which a series of functions are introduced: --------------------------------- -- Length evaluation utilities -- --------------------------------- function Basic_Exception_Info_Maxlength (X : Exception_Occurrence) return Natural; function Untailored_Exception_Traceback_Maxlength (X : Exception_Occurrence) return Natural; function Exception_Info_Maxlength (X : Exception_Occurrence) return Natural; function Exception_Name_Length (Id : Exception_Id) return Natural; function Exception_Name_Length (X : Exception_Occurrence) return Natural; function Exception_Message_Length (X : Exception_Occurrence) return Natural; -------------------------- -- Functional Interface -- -------------------------- function Untailored_Exception_Traceback (X : Exception_Occurrence) return String; -- Returns an image of the complete call chain associated with an -- exception occurrence in its most basic form, that is as a raw sequence -- of hexadecimal addresses. function Tailored_Exception_Traceback (X : Exception_Occurrence) return String; -- Returns an image of the complete call chain associated with an -- exception occurrence, either in its basic form if no decorator is -- in place, or as formatted by the decorator otherwise. ----------------------------------------------------------------------- -- Services for the default Last_Chance_Handler and the task wrapper -- ----------------------------------------------------------------------- pragma Export (Ada, Append_Info_Exception_Message, "__gnat_append_info_e_msg"); pragma Export (Ada, Append_Info_Untailored_Exception_Information, "__gnat_append_info_u_e_info"); pragma Export (Ada, Exception_Message_Length, "__gnat_exception_msg_len"); function Get_Executable_Load_Address return System.Address; pragma Import (C, Get_Executable_Load_Address, "__gnat_get_executable_load_address"); -- Get the load address of the executable, or Null_Address if not known ------------------------- -- Append_Info_Address -- ------------------------- procedure Append_Info_Address (A : Address; Info : in out String; Ptr : in out Natural) is S : String (1 .. 18); P : Natural; N : Integer_Address; H : constant array (Integer range 0 .. 15) of Character := "0123456789abcdef"; begin P := S'Last; N := To_Integer (A); loop S (P) := H (Integer (N mod 16)); P := P - 1; N := N / 16; exit when N = 0; end loop; S (P - 1) := '0'; S (P) := 'x'; Append_Info_String (S (P - 1 .. S'Last), Info, Ptr); end Append_Info_Address; --------------------------------------------- -- Append_Info_Basic_Exception_Information -- --------------------------------------------- -- To ease the maximum length computation, we define and pull out some -- string constants: BEI_Name_Header : constant String := "raised "; BEI_Msg_Header : constant String := " : "; BEI_PID_Header : constant String := "PID: "; procedure Append_Info_Basic_Exception_Information (X : Exception_Occurrence; Info : in out String; Ptr : in out Natural) is Name : String (1 .. Exception_Name_Length (X)); -- Buffer in which to fetch the exception name, in order to check -- whether this is an internal _ABORT_SIGNAL or a regular occurrence. Name_Ptr : Natural := Name'First - 1; begin -- Output exception name and message except for _ABORT_SIGNAL, where -- these two lines are omitted. Append_Info_Exception_Name (X, Name, Name_Ptr); if Name (Name'First) /= '_' then Append_Info_String (BEI_Name_Header, Info, Ptr); Append_Info_String (Name, Info, Ptr); if Exception_Message_Length (X) /= 0 then Append_Info_String (BEI_Msg_Header, Info, Ptr); Append_Info_Exception_Message (X, Info, Ptr); end if; Append_Info_NL (Info, Ptr); end if; -- Output PID line if nonzero if X.Pid /= 0 then Append_Info_String (BEI_PID_Header, Info, Ptr); Append_Info_Nat (X.Pid, Info, Ptr); Append_Info_NL (Info, Ptr); end if; end Append_Info_Basic_Exception_Information; --------------------------- -- Append_Info_Character -- --------------------------- procedure Append_Info_Character (C : Character; Info : in out String; Ptr : in out Natural) is begin if Info'Length = 0 then To_Stderr (C); elsif Ptr < Info'Last then Ptr := Ptr + 1; Info (Ptr) := C; end if; end Append_Info_Character; ----------------------------------- -- Append_Info_Exception_Message -- ----------------------------------- procedure Append_Info_Exception_Message (X : Exception_Occurrence; Info : in out String; Ptr : in out Natural) is begin if X.Id = Null_Id then raise Constraint_Error; end if; declare Len : constant Natural := Exception_Message_Length (X); Msg : constant String (1 .. Len) := X.Msg (1 .. Len); begin Append_Info_String (Msg, Info, Ptr); end; end Append_Info_Exception_Message; -------------------------------- -- Append_Info_Exception_Name -- -------------------------------- procedure Append_Info_Exception_Name (Id : Exception_Id; Info : in out String; Ptr : in out Natural) is begin if Id = Null_Id then raise Constraint_Error; end if; declare Len : constant Natural := Exception_Name_Length (Id); Name : constant String (1 .. Len) := To_Ptr (Id.Full_Name) (1 .. Len); begin Append_Info_String (Name, Info, Ptr); end; end Append_Info_Exception_Name; procedure Append_Info_Exception_Name (X : Exception_Occurrence; Info : in out String; Ptr : in out Natural) is begin Append_Info_Exception_Name (X.Id, Info, Ptr); end Append_Info_Exception_Name; ------------------------------ -- Exception_Info_Maxlength -- ------------------------------ function Exception_Info_Maxlength (X : Exception_Occurrence) return Natural is begin return Basic_Exception_Info_Maxlength (X) + Untailored_Exception_Traceback_Maxlength (X); end Exception_Info_Maxlength; --------------------- -- Append_Info_Nat -- --------------------- procedure Append_Info_Nat (N : Natural; Info : in out String; Ptr : in out Natural) is begin if N > 9 then Append_Info_Nat (N / 10, Info, Ptr); end if; Append_Info_Character (Character'Val (Character'Pos ('0') + N mod 10), Info, Ptr); end Append_Info_Nat; -------------------- -- Append_Info_NL -- -------------------- procedure Append_Info_NL (Info : in out String; Ptr : in out Natural) is begin Append_Info_Character (ASCII.LF, Info, Ptr); end Append_Info_NL; ------------------------ -- Append_Info_String -- ------------------------ procedure Append_Info_String (S : String; Info : in out String; Ptr : in out Natural) is begin if Info'Length = 0 then To_Stderr (S); else declare Last : constant Natural := Integer'Min (Ptr + S'Length, Info'Last); begin Info (Ptr + 1 .. Last) := S; Ptr := Last; end; end if; end Append_Info_String; -------------------------------------------------- -- Append_Info_Untailored_Exception_Information -- -------------------------------------------------- procedure Append_Info_Untailored_Exception_Information (X : Exception_Occurrence; Info : in out String; Ptr : in out Natural) is begin Append_Info_Basic_Exception_Information (X, Info, Ptr); Append_Info_Untailored_Exception_Traceback (X, Info, Ptr); end Append_Info_Untailored_Exception_Information; ------------------------------------------------ -- Append_Info_Untailored_Exception_Traceback -- ------------------------------------------------ -- As for Basic_Exception_Information: BETB_Header : constant String := "Call stack traceback locations:"; LDAD_Header : constant String := "Load address: "; procedure Append_Info_Untailored_Exception_Traceback (X : Exception_Occurrence; Info : in out String; Ptr : in out Natural) is Load_Address : Address; begin if X.Num_Tracebacks = 0 then return; end if; -- The executable load address line Load_Address := Get_Executable_Load_Address; if Load_Address /= Null_Address then Append_Info_String (LDAD_Header, Info, Ptr); Append_Info_Address (Load_Address, Info, Ptr); Append_Info_NL (Info, Ptr); end if; -- The traceback lines Append_Info_String (BETB_Header, Info, Ptr); Append_Info_NL (Info, Ptr); for J in 1 .. X.Num_Tracebacks loop Append_Info_Address (TBE.PC_For (X.Tracebacks (J)), Info, Ptr); exit when J = X.Num_Tracebacks; Append_Info_Character (' ', Info, Ptr); end loop; Append_Info_NL (Info, Ptr); end Append_Info_Untailored_Exception_Traceback; ------------------------------------ -- Basic_Exception_Info_Maxlength -- ------------------------------------ function Basic_Exception_Info_Maxlength (X : Exception_Occurrence) return Natural is begin return BEI_Name_Header'Length + Exception_Name_Length (X) + BEI_Msg_Header'Length + Exception_Message_Length (X) + 1 + BEI_PID_Header'Length + 15; end Basic_Exception_Info_Maxlength; --------------------------- -- Exception_Information -- --------------------------- function Exception_Information (X : Exception_Occurrence) return String is -- The tailored exception information is the basic information -- associated with the tailored call chain backtrace. Tback_Info : constant String := Tailored_Exception_Traceback (X); Tback_Len : constant Natural := Tback_Info'Length; Info : String (1 .. Basic_Exception_Info_Maxlength (X) + Tback_Len); Ptr : Natural := Info'First - 1; begin Append_Info_Basic_Exception_Information (X, Info, Ptr); Append_Info_String (Tback_Info, Info, Ptr); return Info (Info'First .. Ptr); end Exception_Information; ------------------------------ -- Exception_Message_Length -- ------------------------------ function Exception_Message_Length (X : Exception_Occurrence) return Natural is begin return X.Msg_Length; end Exception_Message_Length; --------------------------- -- Exception_Name_Length -- --------------------------- function Exception_Name_Length (Id : Exception_Id) return Natural is begin -- What is stored in the internal Name buffer includes a terminating -- null character that we never care about. return Id.Name_Length - 1; end Exception_Name_Length; function Exception_Name_Length (X : Exception_Occurrence) return Natural is begin return Exception_Name_Length (X.Id); end Exception_Name_Length; ------------------------------- -- Untailored_Exception_Traceback -- ------------------------------- function Untailored_Exception_Traceback (X : Exception_Occurrence) return String is Info : aliased String (1 .. Untailored_Exception_Traceback_Maxlength (X)); Ptr : Natural := Info'First - 1; begin Append_Info_Untailored_Exception_Traceback (X, Info, Ptr); return Info (Info'First .. Ptr); end Untailored_Exception_Traceback; -------------------------------------- -- Untailored_Exception_Information -- -------------------------------------- function Untailored_Exception_Information (X : Exception_Occurrence) return String is Info : String (1 .. Exception_Info_Maxlength (X)); Ptr : Natural := Info'First - 1; begin Append_Info_Untailored_Exception_Information (X, Info, Ptr); return Info (Info'First .. Ptr); end Untailored_Exception_Information; ------------------------- -- Set_Exception_C_Msg -- ------------------------- procedure Set_Exception_C_Msg (Excep : EOA; Id : Exception_Id; Msg1 : System.Address; Line : Integer := 0; Column : Integer := 0; Msg2 : System.Address := System.Null_Address) is Remind : Integer; Ptr : Natural; procedure Append_Number (Number : Integer); -- Append given number to Excep.Msg ------------------- -- Append_Number -- ------------------- procedure Append_Number (Number : Integer) is Val : Integer; Size : Integer; begin if Number <= 0 then return; end if; -- Compute the number of needed characters Size := 1; Val := Number; while Val > 0 loop Val := Val / 10; Size := Size + 1; end loop; -- If enough characters are available, put the line number if Excep.Msg_Length <= Exception_Msg_Max_Length - Size then Excep.Msg (Excep.Msg_Length + 1) := ':'; Excep.Msg_Length := Excep.Msg_Length + Size; Val := Number; Size := 0; while Val > 0 loop Remind := Val rem 10; Val := Val / 10; Excep.Msg (Excep.Msg_Length - Size) := Character'Val (Remind + Character'Pos ('0')); Size := Size + 1; end loop; end if; end Append_Number; -- Start of processing for Set_Exception_C_Msg begin Excep.Exception_Raised := False; Excep.Id := Id; Excep.Num_Tracebacks := 0; Excep.Pid := Local_Partition_ID; Excep.Msg_Length := 0; while To_Ptr (Msg1) (Excep.Msg_Length + 1) /= ASCII.NUL and then Excep.Msg_Length < Exception_Msg_Max_Length loop Excep.Msg_Length := Excep.Msg_Length + 1; Excep.Msg (Excep.Msg_Length) := To_Ptr (Msg1) (Excep.Msg_Length); end loop; Append_Number (Line); Append_Number (Column); -- Append second message if present if Msg2 /= System.Null_Address and then Excep.Msg_Length + 1 < Exception_Msg_Max_Length then Excep.Msg_Length := Excep.Msg_Length + 1; Excep.Msg (Excep.Msg_Length) := ' '; Ptr := 1; while To_Ptr (Msg2) (Ptr) /= ASCII.NUL and then Excep.Msg_Length < Exception_Msg_Max_Length loop Excep.Msg_Length := Excep.Msg_Length + 1; Excep.Msg (Excep.Msg_Length) := To_Ptr (Msg2) (Ptr); Ptr := Ptr + 1; end loop; end if; end Set_Exception_C_Msg; ----------------------- -- Set_Exception_Msg -- ----------------------- procedure Set_Exception_Msg (Excep : EOA; Id : Exception_Id; Message : String) is Len : constant Natural := Natural'Min (Message'Length, Exception_Msg_Max_Length); First : constant Integer := Message'First; begin Excep.Exception_Raised := False; Excep.Msg_Length := Len; Excep.Msg (1 .. Len) := Message (First .. First + Len - 1); Excep.Id := Id; Excep.Num_Tracebacks := 0; Excep.Pid := Local_Partition_ID; end Set_Exception_Msg; ---------------------------------- -- Tailored_Exception_Traceback -- ---------------------------------- function Tailored_Exception_Traceback (X : Exception_Occurrence) return String is -- We reference the decorator *wrapper* here and not the decorator -- itself. The purpose of the local variable Wrapper is to prevent a -- potential race condition in the code below. The atomicity of this -- assignment is enforced by pragma Atomic in System.Soft_Links. -- The potential race condition here, if no local variable was used, -- relates to the test upon the wrapper's value and the call, which -- are not performed atomically. With the local variable, potential -- changes of the wrapper's global value between the test and the -- call become inoffensive. Wrapper : constant Traceback_Decorator_Wrapper_Call := Traceback_Decorator_Wrapper; begin if Wrapper = null then return Untailored_Exception_Traceback (X); else return Wrapper.all (X.Tracebacks'Address, X.Num_Tracebacks); end if; end Tailored_Exception_Traceback; ---------------------------------------------- -- Untailored_Exception_Traceback_Maxlength -- ---------------------------------------------- function Untailored_Exception_Traceback_Maxlength (X : Exception_Occurrence) return Natural is Space_Per_Address : constant := 2 + 16 + 1; -- Space for "0x" + HHHHHHHHHHHHHHHH + " " begin return LDAD_Header'Length + Space_Per_Address + BETB_Header'Length + 1 + X.Num_Tracebacks * Space_Per_Address + 1; end Untailored_Exception_Traceback_Maxlength; end Exception_Data;
zhmu/ananas
Ada
116
ads
package Opt87_Pkg is procedure Print (Msg : String; Location : String); pragma Inline (Print); end Opt87_Pkg;
stcarrez/ada-util
Ada
7,422
adb
----------------------------------------------------------------------- -- util-streams-buffered-lzma-tests -- Unit tests for encoding buffered streams -- Copyright (C) 2018, 2019, 2021 Stephane Carrez -- Written by Stephane Carrez ([email protected]) -- -- Licensed under the Apache License, Version 2.0 (the "License"); -- you may not use this file except in compliance with the License. -- You may obtain a copy of the License at -- -- http://www.apache.org/licenses/LICENSE-2.0 -- -- Unless required by applicable law or agreed to in writing, software -- distributed under the License is distributed on an "AS IS" BASIS, -- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -- See the License for the specific language governing permissions and -- limitations under the License. ----------------------------------------------------------------------- with Util.Test_Caller; with Util.Streams.Files; with Util.Streams.Texts; with Util.Streams.AES; with Util.Encoders.AES; with Ada.Streams.Stream_IO; package body Util.Streams.Buffered.Lzma.Tests is use Util.Streams.Files; use Ada.Streams.Stream_IO; procedure Test_Stream_File (T : in out Test; Item : in String; Count : in Positive; Encrypt : in Boolean; Mode : in Util.Encoders.AES.AES_Mode; Label : in String); package Caller is new Util.Test_Caller (Test, "Streams.Buffered.Lzma"); procedure Add_Tests (Suite : in Util.Tests.Access_Test_Suite) is begin Caller.Add_Test (Suite, "Test Util.Streams.Buffered.Lzma.Write", Test_Compress_Stream'Access); Caller.Add_Test (Suite, "Test Util.Streams.Buffered.Lzma.Write (2)", Test_Compress_File_Stream'Access); Caller.Add_Test (Suite, "Test Util.Streams.Buffered.Lzma.Read+Write", Test_Compress_Decompress_Stream'Access); Caller.Add_Test (Suite, "Test Util.Streams.Buffered.Lzma.Read+Write+AES-CBC", Test_Compress_Encrypt_Decompress_Decrypt_Stream'Access); end Add_Tests; procedure Test_Compress_Stream (T : in out Test) is Stream : aliased File_Stream; Buffer : aliased Util.Streams.Buffered.Lzma.Compress_Stream; Print : Util.Streams.Texts.Print_Stream; Path : constant String := Util.Tests.Get_Test_Path ("test-stream.lzma"); Expect : constant String := Util.Tests.Get_Path ("regtests/expect/test-stream.lzma"); begin Stream.Create (Mode => Out_File, Name => Path); Buffer.Initialize (Output => Stream'Unchecked_Access, Size => 1024); Print.Initialize (Output => Buffer'Unchecked_Access, Size => 5); for I in 1 .. 32 loop Print.Write ("abcd"); Print.Write (" fghij"); Print.Write (ASCII.LF); end loop; Print.Flush; Stream.Close; Util.Tests.Assert_Equal_Files (T => T, Expect => Expect, Test => Path, Message => "LZMA stream"); end Test_Compress_Stream; procedure Test_Compress_File_Stream (T : in out Test) is Stream : aliased File_Stream; In_Stream : aliased File_Stream; Buffer : aliased Util.Streams.Buffered.Lzma.Compress_Stream; Path : constant String := Util.Tests.Get_Test_Path ("test-big-stream.lzma"); Expect : constant String := Util.Tests.Get_Path ("regtests/expect/test-big-stream.lzma"); begin In_Stream.Open (Ada.Streams.Stream_IO.In_File, Util.Tests.Get_Path ("regtests/files/test-big-stream.bin")); Stream.Create (Mode => Out_File, Name => Path); Buffer.Initialize (Output => Stream'Unchecked_Access, Size => 32768); Util.Streams.Copy (From => In_Stream, Into => Buffer); Buffer.Flush; Buffer.Close; Util.Tests.Assert_Equal_Files (T => T, Expect => Expect, Test => Path, Message => "LZMA stream"); end Test_Compress_File_Stream; procedure Test_Stream_File (T : in out Test; Item : in String; Count : in Positive; Encrypt : in Boolean; Mode : in Util.Encoders.AES.AES_Mode; Label : in String) is use Ada.Strings.Unbounded; Path : constant String := Util.Tests.Get_Test_Path ("stream-lzma-aes-" & Label & ".aes"); Key : constant Util.Encoders.Secret_Key := Util.Encoders.Create ("0123456789abcdef0123456789abcdef"); File : aliased File_Stream; Decipher : aliased Util.Streams.AES.Decoding_Stream; Cipher : aliased Util.Streams.AES.Encoding_Stream; Compress : aliased Util.Streams.Buffered.Lzma.Compress_Stream; Decompress : aliased Util.Streams.Buffered.Lzma.Decompress_Stream; Print : Util.Streams.Texts.Print_Stream; Reader : Util.Streams.Texts.Reader_Stream; begin -- Print -> Compress -> Cipher -> File File.Create (Mode => Out_File, Name => Path); if Encrypt then Cipher.Produces (File'Unchecked_Access, 64); Cipher.Set_Key (Key, Mode); Compress.Initialize (Cipher'Unchecked_Access, 1024); else Compress.Initialize (File'Unchecked_Access, 1024); end if; Print.Initialize (Compress'Unchecked_Access); for I in 1 .. Count loop Print.Write (Item & ASCII.LF); end loop; Print.Close; -- File -> Decipher -> Decompress -> Reader File.Open (Mode => In_File, Name => Path); if Encrypt then Decipher.Consumes (File'Unchecked_Access, 128); Decipher.Set_Key (Key, Mode); Decompress.Initialize (Decipher'Unchecked_Access, 1024); else Decompress.Initialize (File'Unchecked_Access, 1024); end if; Reader.Initialize (From => Decompress'Unchecked_Access); declare Line_Count : Natural := 0; begin while not Reader.Is_Eof loop declare Line : Unbounded_String; begin Reader.Read_Line (Line); exit when Length (Line) = 0; if Item & ASCII.LF /= Line then Util.Tests.Assert_Equals (T, Item & ASCII.LF, To_String (Line)); end if; Line_Count := Line_Count + 1; end; end loop; File.Close; Util.Tests.Assert_Equals (T, Count, Line_Count); end; end Test_Stream_File; procedure Test_Compress_Decompress_Stream (T : in out Test) is begin Test_Stream_File (T, "abcdefgh", 1000, False, Util.Encoders.AES.CBC, "NONE"); end Test_Compress_Decompress_Stream; procedure Test_Compress_Encrypt_Decompress_Decrypt_Stream (T : in out Test) is begin Test_Stream_File (T, "abcdefgh", 1000, True, Util.Encoders.AES.CBC, "AES-CBC"); end Test_Compress_Encrypt_Decompress_Decrypt_Stream; end Util.Streams.Buffered.Lzma.Tests;
AdaDoom3/wayland_ada_binding
Ada
2,018
adb
------------------------------------------------------------------------------ -- Copyright (C) 2016, 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 MERCHAN- -- -- TABILITY 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/>. -- -- -- ------------------------------------------------------------------------------ pragma Ada_2012; package body Conts.Maps.Indef_Indef_Unbounded_SPARK with SPARK_Mode => Off is pragma Assertion_Policy (Pre => Suppressible, Ghost => Suppressible, Post => Ignore); ---------- -- Copy -- ---------- function Copy (Self : Map'Class) return Map'Class is begin return Result : Map do Result.Assign (Self); end return; end Copy; end Conts.Maps.Indef_Indef_Unbounded_SPARK;
zhmu/ananas
Ada
246
adb
package body Opt91_Pkg is package body Pure_Relation is overriding function Custom_Image (Self : Rel) return String is begin return Custom_Image (Self.Rel); end Custom_Image; end Pure_Relation; end Opt91_Pkg;
faelys/natools
Ada
3,004
ads
------------------------------------------------------------------------------ -- Copyright (c) 2016, Natacha Porté -- -- -- -- Permission to use, copy, modify, and distribute this software for any -- -- purpose with or without fee is hereby granted, provided that the above -- -- copyright notice and this permission notice appear in all copies. -- -- -- -- THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES -- -- WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF -- -- MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR -- -- ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES -- -- WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN -- -- ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF -- -- OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -- ------------------------------------------------------------------------------ ------------------------------------------------------------------------------ -- Natools.Smaz_Implementations.Base_256 provides the subprograms needed to -- -- instantiate Natools.Smaz_Generic into the original Smaz compression -- -- algorithm, with byte-based output stream. -- ------------------------------------------------------------------------------ with Ada.Streams; package Natools.Smaz_Implementations.Base_256 is pragma Pure; procedure Read_Code (Input : in Ada.Streams.Stream_Element_Array; Offset : in out Ada.Streams.Stream_Element_Offset; Code : out Ada.Streams.Stream_Element; Verbatim_Length : out Natural; Last_Code : in Ada.Streams.Stream_Element; Variable_Length_Verbatim : in Boolean); procedure Read_Verbatim (Input : in Ada.Streams.Stream_Element_Array; Offset : in out Ada.Streams.Stream_Element_Offset; Output : out String); procedure Skip_Verbatim (Input : in Ada.Streams.Stream_Element_Array; Offset : in out Ada.Streams.Stream_Element_Offset; Verbatim_Length : in Positive); function Verbatim_Size (Input_Length : in Positive; Last_Code : in Ada.Streams.Stream_Element; Variable_Length_Verbatim : in Boolean) return Ada.Streams.Stream_Element_Count; procedure Write_Code (Output : in out Ada.Streams.Stream_Element_Array; Offset : in out Ada.Streams.Stream_Element_Offset; Code : in Ada.Streams.Stream_Element); procedure Write_Verbatim (Output : in out Ada.Streams.Stream_Element_Array; Offset : in out Ada.Streams.Stream_Element_Offset; Input : in String; Last_Code : in Ada.Streams.Stream_Element; Variable_Length_Verbatim : in Boolean); end Natools.Smaz_Implementations.Base_256;
reznikmm/matreshka
Ada
4,033
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.Dr3d_Emissive_Color_Attributes; package Matreshka.ODF_Dr3d.Emissive_Color_Attributes is type Dr3d_Emissive_Color_Attribute_Node is new Matreshka.ODF_Dr3d.Abstract_Dr3d_Attribute_Node and ODF.DOM.Dr3d_Emissive_Color_Attributes.ODF_Dr3d_Emissive_Color_Attribute with null record; overriding function Create (Parameters : not null access Matreshka.DOM_Attributes.Attribute_L2_Parameters) return Dr3d_Emissive_Color_Attribute_Node; overriding function Get_Local_Name (Self : not null access constant Dr3d_Emissive_Color_Attribute_Node) return League.Strings.Universal_String; end Matreshka.ODF_Dr3d.Emissive_Color_Attributes;
vikasbidhuri1995/DW1000
Ada
11,214
ads
------------------------------------------------------------------------------- -- Copyright (c) 2016 Daniel King -- -- Permission is hereby granted, free of charge, to any person obtaining a -- copy of this software and associated documentation files (the "Software"), -- to deal in the Software without restriction, including without limitation -- the rights to use, copy, modify, merge, publish, distribute, sublicense, -- and/or sell copies of the Software, and to permit persons to whom the -- Software is furnished to do so, subject to the following conditions: -- -- The above copyright notice and this permission notice shall be included in -- all copies or substantial portions of the Software. -- -- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -- FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER -- DEALINGS IN THE SOFTWARE. ------------------------------------------------------------------------------- with DW1000.Driver; use DW1000.Driver; with DW1000.Register_Types; use DW1000.Register_Types; -- @summary -- Reference transmit power gain tables for both smart transmit power and -- manual transmit power modes for the EVB1000 hardware. -- -- @description -- These tables are targeted for the EVB1000 evaluation boards, and can serve -- as a starting point for calibrating the transmit power for different -- hardware targets and antennas. -- -- Below is an example of using this package to configure the DW1000 -- transmitter to operate in the smart tx power mode, when using UWB channel -- 4 and a PRF of 64 MHz: -- -- DecaDriver.Transmitter.Configure_Tx_Power -- (Smart_Tx_Power_Table (4, PRF_64MHz)); -- -- Note that if the channel number has the type DW1000.Driver.Channel_Number -- then it is necessary to cast the Channel_Number variable to the type -- Positive when indexing these tables. An example of this is shown below: -- -- DecaDriver.Transmitter.Configure_Tx_Power -- (Smart_Tx_Power_Table (Positive (Channel), PRF_64MHz)); -- -- The values in this package were calculated from Section 7.2.31.4 in the -- DW1000 User Manual. package Tx_Power with SPARK_Mode => On is -- Values for the smart tx power mode Smart_Tx_Power_Table : constant Tx_Power_Config_Table := (1 | 2 => (PRF_16MHz => (Smart_Tx_Power_Enabled => True, Boost_Normal => (Fine_Gain => 10.5, Coarse_Gain => Gain_7_5_dB), Boost_500us => (Fine_Gain => 10.5, Coarse_Gain => Gain_10_dB), Boost_250us => (Fine_Gain => 10.5, Coarse_Gain => Gain_12_5_dB), Boost_125us => (Fine_Gain => 10.5, Coarse_Gain => Gain_15_dB)), PRF_64MHz => (Smart_Tx_Power_Enabled => True, Boost_Normal => (Fine_Gain => 3.5, Coarse_Gain => Gain_7_5_dB), Boost_500us => (Fine_Gain => 3.5, Coarse_Gain => Gain_10_dB), Boost_250us => (Fine_Gain => 3.5, Coarse_Gain => Gain_12_5_dB), Boost_125us => (Fine_Gain => 3.5, Coarse_Gain => Gain_15_dB))), 3 => (PRF_16MHz => (Smart_Tx_Power_Enabled => True, Boost_Normal => (Fine_Gain => 7.5, Coarse_Gain => Gain_7_5_dB), Boost_500us => (Fine_Gain => 7.5, Coarse_Gain => Gain_10_dB), Boost_250us => (Fine_Gain => 7.5, Coarse_Gain => Gain_12_5_dB), Boost_125us => (Fine_Gain => 7.5, Coarse_Gain => Gain_15_dB)), PRF_64MHz => (Smart_Tx_Power_Enabled => True, Boost_Normal => (Fine_Gain => 5.5, Coarse_Gain => Gain_5_dB), Boost_500us => (Fine_Gain => 5.5, Coarse_Gain => Gain_7_5_dB), Boost_250us => (Fine_Gain => 5.5, Coarse_Gain => Gain_10_dB), Boost_125us => (Fine_Gain => 5.5, Coarse_Gain => Gain_12_5_dB))), 4 => (PRF_16MHz => (Smart_Tx_Power_Enabled => True, Boost_Normal => (Fine_Gain => 15.5, Coarse_Gain => Gain_10_dB), Boost_500us => (Fine_Gain => 15.5, Coarse_Gain => Gain_12_5_dB), Boost_250us => (Fine_Gain => 15.5, Coarse_Gain => Gain_15_dB), Boost_125us => (Fine_Gain => 15.5, Coarse_Gain => Gain_15_dB)), PRF_64MHz => (Smart_Tx_Power_Enabled => True, Boost_Normal => (Fine_Gain => 13.0, Coarse_Gain => Gain_5_dB), Boost_500us => (Fine_Gain => 13.0, Coarse_Gain => Gain_7_5_dB), Boost_250us => (Fine_Gain => 13.0, Coarse_Gain => Gain_10_dB), Boost_125us => (Fine_Gain => 13.0, Coarse_Gain => Gain_12_5_dB))), 5 | 6 => (PRF_16MHz => (Smart_Tx_Power_Enabled => True, Boost_Normal => (Fine_Gain => 4.0, Coarse_Gain => Gain_10_dB), Boost_500us => (Fine_Gain => 4.0, Coarse_Gain => Gain_12_5_dB), Boost_250us => (Fine_Gain => 4.0, Coarse_Gain => Gain_15_dB), Boost_125us => (Fine_Gain => 7.0, Coarse_Gain => Gain_15_dB)), PRF_64MHz => (Smart_Tx_Power_Enabled => True, Boost_Normal => (Fine_Gain => 2.5, Coarse_Gain => Gain_5_dB), Boost_500us => (Fine_Gain => 2.5, Coarse_Gain => Gain_7_5_dB), Boost_250us => (Fine_Gain => 2.5, Coarse_Gain => Gain_10_dB), Boost_125us => (Fine_Gain => 2.5, Coarse_Gain => Gain_12_5_dB))), 7 => (PRF_16MHz => (Smart_Tx_Power_Enabled => True, Boost_Normal => (Fine_Gain => 9.0, Coarse_Gain => Gain_5_dB), Boost_500us => (Fine_Gain => 9.0, Coarse_Gain => Gain_7_5_dB), Boost_250us => (Fine_Gain => 9.0, Coarse_Gain => Gain_10_dB), Boost_125us => (Fine_Gain => 9.0, Coarse_Gain => Gain_12_5_dB)), PRF_64MHz => (Smart_Tx_Power_Enabled => True, Boost_Normal => (Fine_Gain => 8.5, Coarse_Gain => Gain_0_dB), Boost_500us => (Fine_Gain => 8.5, Coarse_Gain => Gain_2_5_dB), Boost_250us => (Fine_Gain => 8.5, Coarse_Gain => Gain_7_5_dB), Boost_125us => (Fine_Gain => 8.5, Coarse_Gain => Gain_10_dB)))); -- Values for the manual tx power mode Manual_Tx_Power_Table : constant Tx_Power_Config_Table := (1 | 2 => (PRF_16MHz => (Smart_Tx_Power_Enabled => False, Boost_SHR | Boost_PhR => (Fine_Gain => 10.5, Coarse_Gain => Gain_7_5_dB)), PRF_64MHz => (Smart_Tx_Power_Enabled => False, Boost_SHR | Boost_PHR => (Fine_Gain => 3.5, Coarse_Gain => Gain_7_5_dB))), 3 => (PRF_16MHz => (Smart_Tx_Power_Enabled => False, Boost_SHR | Boost_PHR => (Fine_Gain => 7.5, Coarse_Gain => Gain_7_5_dB)), PRF_64MHz => (Smart_Tx_Power_Enabled => False, Boost_SHR | Boost_PHR => (Fine_Gain => 5.5, Coarse_Gain => Gain_5_dB))), 4 => (PRF_16MHz => (Smart_Tx_Power_Enabled => False, Boost_SHR | Boost_PHR => (Fine_Gain => 15.5, Coarse_Gain => Gain_10_dB)), PRF_64MHz => (Smart_Tx_Power_Enabled => False, Boost_SHR | Boost_PHR => (Fine_Gain => 13.0, Coarse_Gain => Gain_5_dB))), 5 | 6 => (PRF_16MHz => (Smart_Tx_Power_Enabled => False, Boost_SHR | Boost_PHR => (Fine_Gain => 4.0, Coarse_Gain => Gain_10_dB)), PRF_64MHz => (Smart_Tx_Power_Enabled => False, Boost_SHR | Boost_PHR => (Fine_Gain => 2.5, Coarse_Gain => Gain_5_dB))), 7 => (PRF_16MHz => (Smart_Tx_Power_Enabled => False, Boost_SHR | Boost_PHR => (Fine_Gain => 9.0, Coarse_Gain => Gain_5_dB)), PRF_64MHz => (Smart_Tx_Power_Enabled => False, Boost_SHR | Boost_PHR => (Fine_Gain => 8.5, Coarse_Gain => Gain_0_dB)))); end Tx_Power;
stcarrez/ada-enet
Ada
3,719
ads
----------------------------------------------------------------------- -- net-protos-arp -- ARP Network protocol -- Copyright (C) 2016 Stephane Carrez -- Written by Stephane Carrez ([email protected]) -- -- Licensed under the Apache License, Version 2.0 (the "License"); -- you may not use this file except in compliance with the License. -- You may obtain a copy of the License at -- -- http://www.apache.org/licenses/LICENSE-2.0 -- -- Unless required by applicable law or agreed to in writing, software -- distributed under the License is distributed on an "AS IS" BASIS, -- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -- See the License for the specific language governing permissions and -- limitations under the License. ----------------------------------------------------------------------- with Net.Interfaces; with Net.Buffers; -- == ARP Protocol == -- The <b>Net.Protos.Arp</b> package implements the support for the ARP protocol used for the -- resolution of IPv4 addresses. The package maintains a ARP database within an Ada protected -- object. -- -- The <b>Resolve</b> procedure is the main entry point for the resolution of the IPv4 address. -- Given a target IP address, it first looks in the ARP database for the associated Ethernet -- address. When the Ethernet address is known, it updates the Ethernet header so that the -- packet can be sent to the network interface. -- -- When the Ethernet address is now known, the <b>Resolve</b> procedure puts the packet in a -- queue and it makes an ARP request. -- -- The <b>Receive</b> procedure should be called when a ARP packet is received. It is responsible -- for replying to ARP requests from other hosts on the network and handling ARP response for -- our requests. It updates the ARP database only when we receive a ARP response from one of -- our ARP query. -- package Net.Protos.Arp is ARPHRD_ETHER : constant Uint16 := 1; ARPOP_REQUEST : constant Uint16 := 1; ARPOP_REPLY : constant Uint16 := 2; ARPOP_REVREQUEST : constant Uint16 := 3; ARPOP_REVREPLY : constant Uint16 := 4; ARPOP_INVREQUEST : constant Uint16 := 8; ARPOP_INVREPLY : constant Uint16 := 8; type Arp_Status is (ARP_FOUND, ARP_PENDING, ARP_NEEDED, ARP_QUEUE_FULL, ARP_UNREACHABLE); procedure Request (Ifnet : in out Net.Interfaces.Ifnet_Type'Class; Source_Ip : in Ip_Addr; Target_Ip : in Ip_Addr; Mac : in Ether_Addr); -- Proceed to the ARP database timeouts, cleaning entries and re-sending pending -- ARP requests. The procedure should be called once every second. procedure Timeout (Ifnet : in out Net.Interfaces.Ifnet_Type'Class); -- Resolve the target IP address to obtain the associated Ethernet address -- from the ARP table. The Status indicates whether the IP address is -- found, or a pending ARP resolution is in progress or it was unreachable. procedure Resolve (Ifnet : in out Net.Interfaces.Ifnet_Type'Class; Target_Ip : in Ip_Addr; Mac : out Ether_Addr; Packet : in out Net.Buffers.Buffer_Type; Status : out Arp_Status); procedure Receive (Ifnet : in out Net.Interfaces.Ifnet_Type'Class; Packet : in out Net.Buffers.Buffer_Type); -- Update the arp table with the IP address and the associated Ethernet address. procedure Update (Ifnet : in out Net.Interfaces.Ifnet_Type'Class; Target_Ip : in Ip_Addr; Mac : in Ether_Addr); end Net.Protos.Arp;
Tim-Tom/project-euler
Ada
58
ads
package Problem_64 is procedure Solve; end Problem_64;
optikos/oasis
Ada
7,742
adb
-- Copyright (c) 2019 Maxim Reznik <[email protected]> -- -- SPDX-License-Identifier: MIT -- License-Filename: LICENSE ------------------------------------------------------------- package body Program.Nodes.Quantified_Expressions is function Create (For_Token : not null Program.Lexical_Elements .Lexical_Element_Access; All_Token : Program.Lexical_Elements.Lexical_Element_Access; Some_Token : Program.Lexical_Elements.Lexical_Element_Access; Parameter : Program.Elements.Loop_Parameter_Specifications .Loop_Parameter_Specification_Access; Generalized_Iterator : Program.Elements .Generalized_Iterator_Specifications .Generalized_Iterator_Specification_Access; Element_Iterator : Program.Elements.Element_Iterator_Specifications .Element_Iterator_Specification_Access; Arrow_Token : not null Program.Lexical_Elements .Lexical_Element_Access; Predicate : not null Program.Elements.Expressions .Expression_Access) return Quantified_Expression is begin return Result : Quantified_Expression := (For_Token => For_Token, All_Token => All_Token, Some_Token => Some_Token, Parameter => Parameter, Generalized_Iterator => Generalized_Iterator, Element_Iterator => Element_Iterator, Arrow_Token => Arrow_Token, Predicate => Predicate, Enclosing_Element => null) do Initialize (Result); end return; end Create; function Create (Parameter : Program.Elements.Loop_Parameter_Specifications .Loop_Parameter_Specification_Access; Generalized_Iterator : Program.Elements .Generalized_Iterator_Specifications .Generalized_Iterator_Specification_Access; Element_Iterator : Program.Elements.Element_Iterator_Specifications .Element_Iterator_Specification_Access; Predicate : 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_All : Boolean := False; Has_Some : Boolean := False) return Implicit_Quantified_Expression is begin return Result : Implicit_Quantified_Expression := (Parameter => Parameter, Generalized_Iterator => Generalized_Iterator, Element_Iterator => Element_Iterator, Predicate => Predicate, Is_Part_Of_Implicit => Is_Part_Of_Implicit, Is_Part_Of_Inherited => Is_Part_Of_Inherited, Is_Part_Of_Instance => Is_Part_Of_Instance, Has_All => Has_All, Has_Some => Has_Some, Enclosing_Element => null) do Initialize (Result); end return; end Create; overriding function Parameter (Self : Base_Quantified_Expression) return Program.Elements.Loop_Parameter_Specifications .Loop_Parameter_Specification_Access is begin return Self.Parameter; end Parameter; overriding function Generalized_Iterator (Self : Base_Quantified_Expression) return Program.Elements.Generalized_Iterator_Specifications .Generalized_Iterator_Specification_Access is begin return Self.Generalized_Iterator; end Generalized_Iterator; overriding function Element_Iterator (Self : Base_Quantified_Expression) return Program.Elements.Element_Iterator_Specifications .Element_Iterator_Specification_Access is begin return Self.Element_Iterator; end Element_Iterator; overriding function Predicate (Self : Base_Quantified_Expression) return not null Program.Elements.Expressions.Expression_Access is begin return Self.Predicate; end Predicate; overriding function For_Token (Self : Quantified_Expression) return not null Program.Lexical_Elements.Lexical_Element_Access is begin return Self.For_Token; end For_Token; overriding function All_Token (Self : Quantified_Expression) return Program.Lexical_Elements.Lexical_Element_Access is begin return Self.All_Token; end All_Token; overriding function Some_Token (Self : Quantified_Expression) return Program.Lexical_Elements.Lexical_Element_Access is begin return Self.Some_Token; end Some_Token; overriding function Arrow_Token (Self : Quantified_Expression) return not null Program.Lexical_Elements.Lexical_Element_Access is begin return Self.Arrow_Token; end Arrow_Token; overriding function Has_All (Self : Quantified_Expression) return Boolean is begin return Self.All_Token.Assigned; end Has_All; overriding function Has_Some (Self : Quantified_Expression) return Boolean is begin return Self.Some_Token.Assigned; end Has_Some; overriding function Is_Part_Of_Implicit (Self : Implicit_Quantified_Expression) return Boolean is begin return Self.Is_Part_Of_Implicit; end Is_Part_Of_Implicit; overriding function Is_Part_Of_Inherited (Self : Implicit_Quantified_Expression) return Boolean is begin return Self.Is_Part_Of_Inherited; end Is_Part_Of_Inherited; overriding function Is_Part_Of_Instance (Self : Implicit_Quantified_Expression) return Boolean is begin return Self.Is_Part_Of_Instance; end Is_Part_Of_Instance; overriding function Has_All (Self : Implicit_Quantified_Expression) return Boolean is begin return Self.Has_All; end Has_All; overriding function Has_Some (Self : Implicit_Quantified_Expression) return Boolean is begin return Self.Has_Some; end Has_Some; procedure Initialize (Self : aliased in out Base_Quantified_Expression'Class) is begin if Self.Parameter.Assigned then Set_Enclosing_Element (Self.Parameter, Self'Unchecked_Access); end if; if Self.Generalized_Iterator.Assigned then Set_Enclosing_Element (Self.Generalized_Iterator, Self'Unchecked_Access); end if; if Self.Element_Iterator.Assigned then Set_Enclosing_Element (Self.Element_Iterator, Self'Unchecked_Access); end if; Set_Enclosing_Element (Self.Predicate, Self'Unchecked_Access); null; end Initialize; overriding function Is_Quantified_Expression_Element (Self : Base_Quantified_Expression) return Boolean is pragma Unreferenced (Self); begin return True; end Is_Quantified_Expression_Element; overriding function Is_Expression_Element (Self : Base_Quantified_Expression) return Boolean is pragma Unreferenced (Self); begin return True; end Is_Expression_Element; overriding procedure Visit (Self : not null access Base_Quantified_Expression; Visitor : in out Program.Element_Visitors.Element_Visitor'Class) is begin Visitor.Quantified_Expression (Self); end Visit; overriding function To_Quantified_Expression_Text (Self : aliased in out Quantified_Expression) return Program.Elements.Quantified_Expressions .Quantified_Expression_Text_Access is begin return Self'Unchecked_Access; end To_Quantified_Expression_Text; overriding function To_Quantified_Expression_Text (Self : aliased in out Implicit_Quantified_Expression) return Program.Elements.Quantified_Expressions .Quantified_Expression_Text_Access is pragma Unreferenced (Self); begin return null; end To_Quantified_Expression_Text; end Program.Nodes.Quantified_Expressions;
Heziode/lsystem-editor
Ada
6,296
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. ------------------------------------------------------------------------------- with Ada.Strings.Unbounded; with Cairo; with Gdk.RGBA; with Glib; with Gtk.Builder; with Gtk.Color_Button; with Gtk.Drawing_Area; with Gtk.Handlers; with Gtk.Spin_Button; with Gtk.Text_Buffer; with Gtk.Widget; with Gtk.Window; with LSE.Presenter.Presenter; with LSE.Utils.Utils; use Ada.Strings.Unbounded; use Cairo; use Gdk.RGBA; use Glib; use Gtk.Builder; use Gtk.Color_Button; use Gtk.Drawing_Area; use Gtk.Spin_Button; use Gtk.Text_Buffer; use Gtk.Widget; use Gtk.Window; use LSE.Presenter.Presenter; use LSE.Utils.Utils.US_Ptr; -- @description -- This package provide a GUI make with Glade. -- package LSE.View.View is -- Location of galde view Main_UI : constant String := "ressources/view.glade"; -- Default app name App_Name : constant String := "Lindenmayer system editor"; -- Default file name when save a L-System Default_File_Name : constant String := "Untitled"; -- Default extension of L-System Default_LS_Extension : constant String := ".ls"; -- Location of the icon of the app App_Icon_Location : constant String := "ressources/icon.png"; -- Raise when app icon cannot be loaded ICON_NOT_LOADED : exception; -- Contains pointers of widget of the view type Instance is tagged private; -- Pointer of Instance (View) type Ptr is access all Instance; -- Constructor procedure Initialize (This : in out Instance; Builder : Gtk_Builder; Presenter : access LSE.Presenter.Presenter.Instance); -- Constructor function Initialize (Builder : Gtk_Builder; Presenter : access LSE.Presenter.Presenter.Instance) return Instance; -- Launch the GUI procedure Start (This : Instance); -- Mutator of presenter procedure Set_Presenter (This : in out Instance; Value : LSE.Presenter.Presenter.Instance); -- Close the program procedure Stop_Program (This : Instance); -- Empty the text editor and create a new instance procedure New_File (This : Instance); -- Save content of text editor into a file -- @param Save_As True to force save as new file, False otherwise procedure Save (This : Instance; Save_As : Boolean := False); -- Validate the L-System procedure Validate (This : Instance); -- Open L-System from file procedure Open (This : Instance); -- Show about dialog procedure About (This : Instance); -- Change level of development of the L-System procedure LS_Level (This : Instance; Value : Integer); -- Change background color procedure Background_Color (This : Instance); -- Change foreground color procedure Foreground_Color (This : Instance); -- Export the L-System procedure Export (This : Instance; Format : String); -- Draw the L-System into the GUI procedure Draw (This : Instance; Cr : Cairo.Cairo_Context); -- Resize the drawing area procedure Size_Allocate (This : Instance); private type Instance is tagged record Presenter : access LSE.Presenter.Presenter.Instance; Window : Gtk_Window; Level_Selector : Gtk_Spin_Button; Text_Error : Gtk_Text_Buffer; Text_Editor : Gtk_Text_Buffer; Render_Area : Gtk_Drawing_Area; end record; -- Loaction to store the file File_Path : LSE.Utils.Utils.US_Ptr.Holder := To_Holder (To_Unbounded_String ("")); -- Used to check if need a first develop before render First_Run : Boolean := True; -- Get the content of the text editor function Get_Text_Editor_Content (This : Instance) return String; -- Render the L-System procedure Render (This : Instance); -- Display modal to get param export (width, height, etc.) procedure Get_Export_Param (This : Instance; Width, Height, Margin_Top, Margin_Right, Margin_Bottom, Margin_Left : in out Gint; Bg_Rgba, Fg_Rgba : in out Gdk_RGBA; Have_Bg : in out Boolean; Export : out Boolean); package P_Handlers_Widget is new Gtk.Handlers.Callback (Gtk_Widget_Record); package P_Handlers_User_Callback_String is new Gtk.Handlers.User_Callback (Gtk_Widget_Record, String); package P_Handlers_User_Callback_Color is new Gtk.Handlers.User_Callback (Gtk_Widget_Record, Gtk_Color_Button); package P_Handlers_User_Callback_Cairo is new Gtk.Handlers.User_Callback (Gtk_Widget_Record, Cairo.Cairo_Context); use P_Handlers_Widget; use P_Handlers_User_Callback_String; use P_Handlers_User_Callback_Color; end LSE.View.View;
reznikmm/matreshka
Ada
3,673
ads
------------------------------------------------------------------------------ -- -- -- Matreshka Project -- -- -- -- Web Framework -- -- -- -- Tools Component -- -- -- ------------------------------------------------------------------------------ -- -- -- Copyright © 2015, Vadim Godunko <[email protected]> -- -- All rights reserved. -- -- -- -- Redistribution and use in source and binary forms, with or without -- -- modification, are permitted provided that the following conditions -- -- are met: -- -- -- -- * Redistributions of source code must retain the above copyright -- -- notice, this list of conditions and the following disclaimer. -- -- -- -- * Redistributions in binary form must reproduce the above copyright -- -- notice, this list of conditions and the following disclaimer in the -- -- documentation and/or other materials provided with the distribution. -- -- -- -- * Neither the name of the Vadim Godunko, IE nor the names of its -- -- contributors may be used to endorse or promote products derived from -- -- this software without specific prior written permission. -- -- -- -- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -- -- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -- -- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -- -- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -- -- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -- -- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED -- -- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -- -- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -- -- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -- -- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -- -- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- -- -- ------------------------------------------------------------------------------ -- $Revision$ $Date$ ------------------------------------------------------------------------------ with Asis; with Engines.Contexts; with League.Strings; package Properties.Expressions.Membership_Test is function Code (Engine : access Engines.Contexts.Context; Element : Asis.Expression; Name : Engines.Text_Property) return League.Strings.Universal_String; end Properties.Expressions.Membership_Test;
zhmu/ananas
Ada
52,736
adb
------------------------------------------------------------------------------ -- -- -- GNAT RUN-TIME LIBRARY (GNARL) COMPONENTS -- -- -- -- S Y S T E M . T A S K I N G . R E N D E Z V O U S -- -- -- -- B o d y -- -- -- -- Copyright (C) 1992-2022, Free Software Foundation, Inc. -- -- -- -- GNARL is free software; you can redistribute it and/or modify it under -- -- terms of the GNU General Public License as published by the Free Soft- -- -- ware Foundation; either version 3, or (at your option) any later ver- -- -- sion. GNAT is distributed in the hope that it will be useful, but WITH- -- -- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY -- -- or FITNESS FOR A PARTICULAR PURPOSE. -- -- -- -- As a special exception under Section 7 of GPL version 3, you are granted -- -- additional permissions described in the GCC Runtime Library Exception, -- -- version 3.1, as published by the Free Software Foundation. -- -- -- -- You should have received a copy of the GNU General Public License and -- -- a copy of the GCC Runtime Library Exception along with this program; -- -- see the files COPYING3 and COPYING.RUNTIME respectively. If not, see -- -- <http://www.gnu.org/licenses/>. -- -- -- -- GNARL was developed by the GNARL team at Florida State University. -- -- Extensive contributions were provided by Ada Core Technologies, Inc. -- -- -- ------------------------------------------------------------------------------ with System.Task_Primitives.Operations; with System.Tasking.Entry_Calls; with System.Tasking.Initialization; with System.Tasking.Queuing; with System.Tasking.Utilities; with System.Tasking.Protected_Objects.Operations; with System.Tasking.Debug; with System.Restrictions; package body System.Tasking.Rendezvous is package STPO renames System.Task_Primitives.Operations; package POO renames Protected_Objects.Operations; package POE renames Protected_Objects.Entries; use Task_Primitives.Operations; type Select_Treatment is ( Accept_Alternative_Selected, -- alternative with non-null body Accept_Alternative_Completed, -- alternative with null body Else_Selected, Terminate_Selected, Accept_Alternative_Open, No_Alternative_Open); ---------------- -- Local Data -- ---------------- Default_Treatment : constant array (Select_Modes) of Select_Treatment := [Simple_Mode => No_Alternative_Open, Else_Mode => Else_Selected, Terminate_Mode => Terminate_Selected, Delay_Mode => No_Alternative_Open]; New_State : constant array (Boolean, Entry_Call_State) of Entry_Call_State := [True => [Never_Abortable => Never_Abortable, Not_Yet_Abortable => Now_Abortable, Was_Abortable => Now_Abortable, Now_Abortable => Now_Abortable, Done => Done, Cancelled => Cancelled], False => [Never_Abortable => Never_Abortable, Not_Yet_Abortable => Not_Yet_Abortable, Was_Abortable => Was_Abortable, Now_Abortable => Now_Abortable, Done => Done, Cancelled => Cancelled] ]; ----------------------- -- Local Subprograms -- ----------------------- procedure Local_Defer_Abort (Self_Id : Task_Id) renames System.Tasking.Initialization.Defer_Abort_Nestable; procedure Local_Undefer_Abort (Self_Id : Task_Id) renames System.Tasking.Initialization.Undefer_Abort_Nestable; -- Florist defers abort around critical sections that make entry calls -- to the Interrupt_Manager task, which violates the general rule about -- top-level runtime system calls from abort-deferred regions. It is not -- that this is unsafe, but when it occurs in "normal" programs it usually -- means either the user is trying to do a potentially blocking operation -- from within a protected object, or there is a runtime system/compiler -- error that has failed to undefer an earlier abort deferral. Thus, for -- debugging it may be wise to modify the above renamings to the -- non-nestable forms. procedure Local_Complete_Rendezvous (Ex : Ada.Exceptions.Exception_Id); -- Internal version of Complete_Rendezvous, used to implement -- Complete_Rendezvous and Exceptional_Complete_Rendezvous. -- Should be called holding no locks, generally with abort -- not yet deferred. procedure Boost_Priority (Call : Entry_Call_Link; Acceptor : Task_Id); pragma Inline (Boost_Priority); -- Call this only with abort deferred and holding lock of Acceptor procedure Call_Synchronous (Acceptor : Task_Id; E : Task_Entry_Index; Uninterpreted_Data : System.Address; Mode : Call_Modes; Rendezvous_Successful : out Boolean); pragma Inline (Call_Synchronous); -- This call is used to make a simple or conditional entry call. -- Called from Call_Simple and Task_Entry_Call. procedure Setup_For_Rendezvous_With_Body (Entry_Call : Entry_Call_Link; Acceptor : Task_Id); pragma Inline (Setup_For_Rendezvous_With_Body); -- Call this only with abort deferred and holding lock of Acceptor. When -- a rendezvous selected (ready for rendezvous) we need to save previous -- caller and adjust the priority. Also we need to make this call not -- Abortable (Cancellable) since the rendezvous has already been started. procedure Wait_For_Call (Self_Id : Task_Id); pragma Inline (Wait_For_Call); -- Call this only with abort deferred and holding lock of Self_Id. An -- accepting task goes into Sleep by calling this routine waiting for a -- call from the caller or waiting for an abort. Make sure Self_Id is -- locked before calling this routine. ----------------- -- Accept_Call -- ----------------- procedure Accept_Call (E : Task_Entry_Index; Uninterpreted_Data : out System.Address) is Self_Id : constant Task_Id := STPO.Self; Caller : Task_Id := null; Open_Accepts : aliased Accept_List (1 .. 1); Entry_Call : Entry_Call_Link; begin Initialization.Defer_Abort (Self_Id); STPO.Write_Lock (Self_Id); if not Self_Id.Callable then pragma Assert (Self_Id.Pending_ATC_Level = Level_Completed_Task); pragma Assert (Self_Id.Pending_Action); STPO.Unlock (Self_Id); Initialization.Undefer_Abort (Self_Id); -- Should never get here ??? pragma Assert (Standard.False); raise Standard'Abort_Signal; end if; Queuing.Dequeue_Head (Self_Id.Entry_Queues (E), Entry_Call); if Entry_Call /= null then Caller := Entry_Call.Self; Setup_For_Rendezvous_With_Body (Entry_Call, Self_Id); Uninterpreted_Data := Entry_Call.Uninterpreted_Data; else -- Wait for a caller Open_Accepts (1).Null_Body := False; Open_Accepts (1).S := E; Self_Id.Open_Accepts := Open_Accepts'Unrestricted_Access; -- Wait for normal call pragma Debug (Debug.Trace (Self_Id, "Accept_Call: wait", 'R')); Wait_For_Call (Self_Id); pragma Assert (Self_Id.Open_Accepts = null); if Self_Id.Common.Call /= null then Caller := Self_Id.Common.Call.Self; pragma Assert (Caller.ATC_Nesting_Level > Level_No_ATC_Occurring); Uninterpreted_Data := Caller.Entry_Calls (Caller.ATC_Nesting_Level).Uninterpreted_Data; else -- Case of an aborted task Uninterpreted_Data := System.Null_Address; end if; end if; -- Self_Id.Common.Call should already be updated by the Caller. On -- return, we will start the rendezvous. STPO.Unlock (Self_Id); Initialization.Undefer_Abort (Self_Id); end Accept_Call; -------------------- -- Accept_Trivial -- -------------------- procedure Accept_Trivial (E : Task_Entry_Index) is Self_Id : constant Task_Id := STPO.Self; Caller : Task_Id := null; Open_Accepts : aliased Accept_List (1 .. 1); Entry_Call : Entry_Call_Link; begin Initialization.Defer_Abort_Nestable (Self_Id); STPO.Write_Lock (Self_Id); if not Self_Id.Callable then pragma Assert (Self_Id.Pending_ATC_Level = Level_Completed_Task); pragma Assert (Self_Id.Pending_Action); STPO.Unlock (Self_Id); Initialization.Undefer_Abort_Nestable (Self_Id); -- Should never get here ??? pragma Assert (Standard.False); raise Standard'Abort_Signal; end if; Queuing.Dequeue_Head (Self_Id.Entry_Queues (E), Entry_Call); if Entry_Call = null then -- Need to wait for entry call Open_Accepts (1).Null_Body := True; Open_Accepts (1).S := E; Self_Id.Open_Accepts := Open_Accepts'Unrestricted_Access; pragma Debug (Debug.Trace (Self_Id, "Accept_Trivial: wait", 'R')); Wait_For_Call (Self_Id); pragma Assert (Self_Id.Open_Accepts = null); -- No need to do anything special here for pending abort. -- Abort_Signal will be raised by Undefer on exit. STPO.Unlock (Self_Id); -- Found caller already waiting else pragma Assert (Entry_Call.State < Done); STPO.Unlock (Self_Id); Caller := Entry_Call.Self; STPO.Write_Lock (Caller); Initialization.Wakeup_Entry_Caller (Self_Id, Entry_Call, Done); STPO.Unlock (Caller); end if; Initialization.Undefer_Abort_Nestable (Self_Id); end Accept_Trivial; -------------------- -- Boost_Priority -- -------------------- procedure Boost_Priority (Call : Entry_Call_Link; Acceptor : Task_Id) is Caller : constant Task_Id := Call.Self; Caller_Prio : constant System.Any_Priority := Get_Priority (Caller); Acceptor_Prio : constant System.Any_Priority := Get_Priority (Acceptor); begin if Caller_Prio > Acceptor_Prio then Call.Acceptor_Prev_Priority := Acceptor_Prio; Set_Priority (Acceptor, Caller_Prio); else Call.Acceptor_Prev_Priority := Priority_Not_Boosted; end if; end Boost_Priority; ----------------- -- Call_Simple -- ----------------- procedure Call_Simple (Acceptor : Task_Id; E : Task_Entry_Index; Uninterpreted_Data : System.Address) is Rendezvous_Successful : Boolean; begin -- If pragma Detect_Blocking is active then Program_Error must be -- raised if this potentially blocking operation is called from a -- protected action. if System.Tasking.Detect_Blocking and then STPO.Self.Common.Protected_Action_Nesting > 0 then raise Program_Error with "potentially blocking operation"; end if; Call_Synchronous (Acceptor, E, Uninterpreted_Data, Simple_Call, Rendezvous_Successful); end Call_Simple; ---------------------- -- Call_Synchronous -- ---------------------- procedure Call_Synchronous (Acceptor : Task_Id; E : Task_Entry_Index; Uninterpreted_Data : System.Address; Mode : Call_Modes; Rendezvous_Successful : out Boolean) is Self_Id : constant Task_Id := STPO.Self; Level : ATC_Level; Entry_Call : Entry_Call_Link; begin pragma Assert (Mode /= Asynchronous_Call); Local_Defer_Abort (Self_Id); Self_Id.ATC_Nesting_Level := Self_Id.ATC_Nesting_Level + 1; pragma Debug (Debug.Trace (Self_Id, "CS: entered ATC level: " & ATC_Level'Image (Self_Id.ATC_Nesting_Level), 'A')); Level := Self_Id.ATC_Nesting_Level; Entry_Call := Self_Id.Entry_Calls (Level)'Access; Entry_Call.Next := null; Entry_Call.Mode := Mode; Entry_Call.Cancellation_Attempted := False; -- If this is a call made inside of an abort deferred region, -- the call should be never abortable. Entry_Call.State := (if Self_Id.Deferral_Level > 1 then Never_Abortable else Now_Abortable); Entry_Call.E := Entry_Index (E); Entry_Call.Prio := Get_Priority (Self_Id); Entry_Call.Uninterpreted_Data := Uninterpreted_Data; Entry_Call.Called_Task := Acceptor; Entry_Call.Exception_To_Raise := Ada.Exceptions.Null_Id; Entry_Call.With_Abort := True; -- Note: the caller will undefer abort on return (see WARNING above) if not Task_Do_Or_Queue (Self_Id, Entry_Call) then STPO.Write_Lock (Self_Id); Utilities.Exit_One_ATC_Level (Self_Id); STPO.Unlock (Self_Id); Local_Undefer_Abort (Self_Id); raise Tasking_Error; end if; STPO.Write_Lock (Self_Id); pragma Debug (Debug.Trace (Self_Id, "Call_Synchronous: wait", 'R')); Entry_Calls.Wait_For_Completion (Entry_Call); pragma Debug (Debug.Trace (Self_Id, "Call_Synchronous: done waiting", 'R')); Rendezvous_Successful := Entry_Call.State = Done; STPO.Unlock (Self_Id); Local_Undefer_Abort (Self_Id); Entry_Calls.Check_Exception (Self_Id, Entry_Call); end Call_Synchronous; -------------- -- Callable -- -------------- function Callable (T : Task_Id) return Boolean is Result : Boolean; Self_Id : constant Task_Id := STPO.Self; begin Initialization.Defer_Abort_Nestable (Self_Id); STPO.Write_Lock (T); Result := T.Callable; STPO.Unlock (T); Initialization.Undefer_Abort_Nestable (Self_Id); return Result; end Callable; ---------------------------- -- Cancel_Task_Entry_Call -- ---------------------------- procedure Cancel_Task_Entry_Call (Cancelled : out Boolean) is begin Entry_Calls.Try_To_Cancel_Entry_Call (Cancelled); end Cancel_Task_Entry_Call; ------------------------- -- Complete_Rendezvous -- ------------------------- procedure Complete_Rendezvous is begin Local_Complete_Rendezvous (Ada.Exceptions.Null_Id); end Complete_Rendezvous; ------------------------------------- -- Exceptional_Complete_Rendezvous -- ------------------------------------- procedure Exceptional_Complete_Rendezvous (Ex : Ada.Exceptions.Exception_Id) is procedure Internal_Reraise; pragma No_Return (Internal_Reraise); pragma Import (C, Internal_Reraise, "__gnat_reraise"); begin Local_Complete_Rendezvous (Ex); Internal_Reraise; -- ??? Do we need to give precedence to Program_Error that might be -- raised due to failure of finalization, over Tasking_Error from -- failure of requeue? end Exceptional_Complete_Rendezvous; ------------------------------- -- Local_Complete_Rendezvous -- ------------------------------- procedure Local_Complete_Rendezvous (Ex : Ada.Exceptions.Exception_Id) is Self_Id : constant Task_Id := STPO.Self; Entry_Call : Entry_Call_Link := Self_Id.Common.Call; Caller : Task_Id; Called_PO : STPE.Protection_Entries_Access; Acceptor_Prev_Priority : Integer; Ceiling_Violation : Boolean; use type Ada.Exceptions.Exception_Id; procedure Transfer_Occurrence (Target : Ada.Exceptions.Exception_Occurrence_Access; Source : Ada.Exceptions.Exception_Occurrence); pragma Import (C, Transfer_Occurrence, "__gnat_transfer_occurrence"); begin -- The deferral level is critical here, since we want to raise an -- exception or allow abort to take place, if there is an exception or -- abort pending. pragma Debug (Debug.Trace (Self_Id, "Local_Complete_Rendezvous", 'R')); Initialization.Defer_Abort (Self_Id); -- We need to clean up any accepts which Self may have been serving when -- it was aborted. if Ex = Standard'Abort_Signal'Identity then while Entry_Call /= null loop Entry_Call.Exception_To_Raise := Tasking_Error'Identity; -- All forms of accept make sure that the acceptor is not -- completed, before accepting further calls, so that we -- can be sure that no further calls are made after the -- current calls are purged. Caller := Entry_Call.Self; -- Take write lock. This follows the lock precedence rule that -- Caller may be locked while holding lock of Acceptor. Complete -- the call abnormally, with exception. STPO.Write_Lock (Caller); Initialization.Wakeup_Entry_Caller (Self_Id, Entry_Call, Done); STPO.Unlock (Caller); Entry_Call := Entry_Call.Acceptor_Prev_Call; end loop; else Caller := Entry_Call.Self; if Entry_Call.Needs_Requeue then -- We dare not lock Self_Id at the same time as Caller, for fear -- of deadlock. Entry_Call.Needs_Requeue := False; Self_Id.Common.Call := Entry_Call.Acceptor_Prev_Call; if Entry_Call.Called_Task /= null then -- Requeue to another task entry if not Task_Do_Or_Queue (Self_Id, Entry_Call) then Initialization.Undefer_Abort (Self_Id); raise Tasking_Error; end if; else -- Requeue to a protected entry Called_PO := POE.To_Protection (Entry_Call.Called_PO); STPE.Lock_Entries_With_Status (Called_PO, Ceiling_Violation); if Ceiling_Violation then pragma Assert (Ex = Ada.Exceptions.Null_Id); Entry_Call.Exception_To_Raise := Program_Error'Identity; STPO.Write_Lock (Caller); Initialization.Wakeup_Entry_Caller (Self_Id, Entry_Call, Done); STPO.Unlock (Caller); else POO.PO_Do_Or_Queue (Self_Id, Called_PO, Entry_Call); POO.PO_Service_Entries (Self_Id, Called_PO); end if; end if; Entry_Calls.Reset_Priority (Self_Id, Entry_Call.Acceptor_Prev_Priority); else -- The call does not need to be requeued Self_Id.Common.Call := Entry_Call.Acceptor_Prev_Call; Entry_Call.Exception_To_Raise := Ex; STPO.Write_Lock (Caller); -- Done with Caller locked to make sure that Wakeup is not lost if Ex /= Ada.Exceptions.Null_Id then Transfer_Occurrence (Caller.Common.Compiler_Data.Current_Excep'Access, Self_Id.Common.Compiler_Data.Current_Excep); end if; Acceptor_Prev_Priority := Entry_Call.Acceptor_Prev_Priority; Initialization.Wakeup_Entry_Caller (Self_Id, Entry_Call, Done); STPO.Unlock (Caller); Entry_Calls.Reset_Priority (Self_Id, Acceptor_Prev_Priority); end if; end if; Initialization.Undefer_Abort (Self_Id); end Local_Complete_Rendezvous; ------------------------------------- -- Requeue_Protected_To_Task_Entry -- ------------------------------------- procedure Requeue_Protected_To_Task_Entry (Object : STPE.Protection_Entries_Access; Acceptor : Task_Id; E : Task_Entry_Index; With_Abort : Boolean) is Entry_Call : constant Entry_Call_Link := Object.Call_In_Progress; begin pragma Assert (STPO.Self.Deferral_Level > 0); Entry_Call.E := Entry_Index (E); Entry_Call.Called_Task := Acceptor; Entry_Call.Called_PO := Null_Address; Entry_Call.With_Abort := With_Abort; Object.Call_In_Progress := null; end Requeue_Protected_To_Task_Entry; ------------------------ -- Requeue_Task_Entry -- ------------------------ procedure Requeue_Task_Entry (Acceptor : Task_Id; E : Task_Entry_Index; With_Abort : Boolean) is Self_Id : constant Task_Id := STPO.Self; Entry_Call : constant Entry_Call_Link := Self_Id.Common.Call; begin Initialization.Defer_Abort (Self_Id); Entry_Call.Needs_Requeue := True; Entry_Call.With_Abort := With_Abort; Entry_Call.E := Entry_Index (E); Entry_Call.Called_Task := Acceptor; Initialization.Undefer_Abort (Self_Id); end Requeue_Task_Entry; -------------------- -- Selective_Wait -- -------------------- procedure Selective_Wait (Open_Accepts : Accept_List_Access; Select_Mode : Select_Modes; Uninterpreted_Data : out System.Address; Index : out Select_Index) is Self_Id : constant Task_Id := STPO.Self; Entry_Call : Entry_Call_Link; Treatment : Select_Treatment; Caller : Task_Id; Selection : Select_Index; Open_Alternative : Boolean; begin Initialization.Defer_Abort (Self_Id); STPO.Write_Lock (Self_Id); if not Self_Id.Callable then pragma Assert (Self_Id.Pending_ATC_Level = Level_Completed_Task); pragma Assert (Self_Id.Pending_Action); STPO.Unlock (Self_Id); -- ??? In some cases abort is deferred more than once. Need to -- figure out why this happens. if Self_Id.Deferral_Level > 1 then Self_Id.Deferral_Level := 1; end if; Initialization.Undefer_Abort (Self_Id); -- Should never get here ??? pragma Assert (Standard.False); raise Standard'Abort_Signal; end if; pragma Assert (Open_Accepts /= null); Uninterpreted_Data := Null_Address; Queuing.Select_Task_Entry_Call (Self_Id, Open_Accepts, Entry_Call, Selection, Open_Alternative); -- Determine the kind and disposition of the select Treatment := Default_Treatment (Select_Mode); Self_Id.Chosen_Index := No_Rendezvous; if Open_Alternative then if Entry_Call /= null then if Open_Accepts (Selection).Null_Body then Treatment := Accept_Alternative_Completed; else Setup_For_Rendezvous_With_Body (Entry_Call, Self_Id); Treatment := Accept_Alternative_Selected; end if; Self_Id.Chosen_Index := Selection; elsif Treatment = No_Alternative_Open then Treatment := Accept_Alternative_Open; end if; end if; -- Handle the select according to the disposition selected above case Treatment is when Accept_Alternative_Selected => -- Ready to rendezvous Uninterpreted_Data := Self_Id.Common.Call.Uninterpreted_Data; -- In this case the accept body is not Null_Body. Defer abort -- until it gets into the accept body. The compiler has inserted -- a call to Abort_Undefer as part of the entry expansion. pragma Assert (Self_Id.Deferral_Level = 1); Initialization.Defer_Abort_Nestable (Self_Id); STPO.Unlock (Self_Id); when Accept_Alternative_Completed => -- Accept body is null, so rendezvous is over immediately STPO.Unlock (Self_Id); Caller := Entry_Call.Self; STPO.Write_Lock (Caller); Initialization.Wakeup_Entry_Caller (Self_Id, Entry_Call, Done); STPO.Unlock (Caller); when Accept_Alternative_Open => -- Wait for caller Self_Id.Open_Accepts := Open_Accepts; pragma Debug (Debug.Trace (Self_Id, "Selective_Wait: wait", 'R')); Wait_For_Call (Self_Id); pragma Assert (Self_Id.Open_Accepts = null); -- Self_Id.Common.Call should already be updated by the Caller if -- not aborted. It might also be ready to do rendezvous even if -- this wakes up due to an abort. Therefore, if the call is not -- empty we need to do the rendezvous if the accept body is not -- Null_Body. -- Aren't the first two conditions below redundant??? if Self_Id.Chosen_Index /= No_Rendezvous and then Self_Id.Common.Call /= null and then not Open_Accepts (Self_Id.Chosen_Index).Null_Body then Uninterpreted_Data := Self_Id.Common.Call.Uninterpreted_Data; pragma Assert (Self_Id.Deferral_Level = 1 or else (Self_Id.Deferral_Level = 0 and then not Restrictions.Abort_Allowed)); Initialization.Defer_Abort_Nestable (Self_Id); -- Leave abort deferred until the accept body -- The compiler has inserted a call to Abort_Undefer as part of -- the entry expansion. end if; STPO.Unlock (Self_Id); when Else_Selected => pragma Assert (Self_Id.Open_Accepts = null); STPO.Unlock (Self_Id); when Terminate_Selected => -- Terminate alternative is open Self_Id.Open_Accepts := Open_Accepts; Self_Id.Common.State := Acceptor_Sleep; -- Notify ancestors that this task is on a terminate alternative STPO.Unlock (Self_Id); Utilities.Make_Passive (Self_Id, Task_Completed => False); STPO.Write_Lock (Self_Id); -- Wait for normal entry call or termination Wait_For_Call (Self_Id); pragma Assert (Self_Id.Open_Accepts = null); if Self_Id.Terminate_Alternative then -- An entry call should have reset this to False, so we must be -- aborted. We cannot be in an async. select, since that is not -- legal, so the abort must be of the entire task. Therefore, -- we do not need to cancel the terminate alternative. The -- cleanup will be done in Complete_Master. pragma Assert (Self_Id.Pending_ATC_Level = Level_Completed_Task); pragma Assert (Self_Id.Awake_Count = 0); STPO.Unlock (Self_Id); Index := Self_Id.Chosen_Index; Initialization.Undefer_Abort_Nestable (Self_Id); if Self_Id.Pending_Action then Initialization.Do_Pending_Action (Self_Id); end if; return; else -- Self_Id.Common.Call and Self_Id.Chosen_Index -- should already be updated by the Caller. if Self_Id.Chosen_Index /= No_Rendezvous and then not Open_Accepts (Self_Id.Chosen_Index).Null_Body then Uninterpreted_Data := Self_Id.Common.Call.Uninterpreted_Data; pragma Assert (Self_Id.Deferral_Level = 1); -- We need an extra defer here, to keep abort -- deferred until we get into the accept body -- The compiler has inserted a call to Abort_Undefer as part -- of the entry expansion. Initialization.Defer_Abort_Nestable (Self_Id); end if; end if; STPO.Unlock (Self_Id); when No_Alternative_Open => -- In this case, Index will be No_Rendezvous on return, which -- should cause a Program_Error if it is not a Delay_Mode. -- If delay alternative exists (Delay_Mode) we should suspend -- until the delay expires. Self_Id.Open_Accepts := null; if Select_Mode = Delay_Mode then Self_Id.Common.State := Delay_Sleep; loop exit when Self_Id.Pending_ATC_Level < Self_Id.ATC_Nesting_Level; Sleep (Self_Id, Delay_Sleep); end loop; Self_Id.Common.State := Runnable; STPO.Unlock (Self_Id); else STPO.Unlock (Self_Id); Initialization.Undefer_Abort (Self_Id); raise Program_Error with "entry call not a delay mode"; end if; end case; -- Caller has been chosen -- Self_Id.Common.Call should already be updated by the Caller. -- Self_Id.Chosen_Index should either be updated by the Caller -- or by Test_Selective_Wait. -- On return, we sill start rendezvous unless the accept body is -- null. In the latter case, we will have already completed the RV. Index := Self_Id.Chosen_Index; Initialization.Undefer_Abort_Nestable (Self_Id); end Selective_Wait; ------------------------------------ -- Setup_For_Rendezvous_With_Body -- ------------------------------------ procedure Setup_For_Rendezvous_With_Body (Entry_Call : Entry_Call_Link; Acceptor : Task_Id) is begin Entry_Call.Acceptor_Prev_Call := Acceptor.Common.Call; Acceptor.Common.Call := Entry_Call; if Entry_Call.State = Now_Abortable then Entry_Call.State := Was_Abortable; end if; Boost_Priority (Entry_Call, Acceptor); end Setup_For_Rendezvous_With_Body; ---------------- -- Task_Count -- ---------------- function Task_Count (E : Task_Entry_Index) return Natural is Self_Id : constant Task_Id := STPO.Self; Return_Count : Natural; begin Initialization.Defer_Abort (Self_Id); STPO.Write_Lock (Self_Id); Return_Count := Queuing.Count_Waiting (Self_Id.Entry_Queues (E)); STPO.Unlock (Self_Id); Initialization.Undefer_Abort (Self_Id); return Return_Count; end Task_Count; ---------------------- -- Task_Do_Or_Queue -- ---------------------- function Task_Do_Or_Queue (Self_ID : Task_Id; Entry_Call : Entry_Call_Link) return Boolean is E : constant Task_Entry_Index := Task_Entry_Index (Entry_Call.E); Old_State : constant Entry_Call_State := Entry_Call.State; Acceptor : constant Task_Id := Entry_Call.Called_Task; Parent : constant Task_Id := Acceptor.Common.Parent; Null_Body : Boolean; begin -- Find out whether Entry_Call can be accepted immediately -- If the Acceptor is not callable, return False. -- If the rendezvous can start, initiate it. -- If the accept-body is trivial, also complete the rendezvous. -- If the acceptor is not ready, enqueue the call. -- This should have a special case for Accept_Call and Accept_Trivial, -- so that we don't have the loop setup overhead, below. -- The call state Done is used here and elsewhere to include both the -- case of normal successful completion, and the case of an exception -- being raised. The difference is that if an exception is raised no one -- will pay attention to the fact that State = Done. Instead the -- exception will be raised in Undefer_Abort, and control will skip past -- the place where we normally would resume from an entry call. pragma Assert (not Queuing.Onqueue (Entry_Call)); -- We rely that the call is off-queue for protection, that the caller -- will not exit the Entry_Caller_Sleep, and so will not reuse the call -- record for another call. We rely on the Caller's lock for call State -- mod's. -- If Acceptor.Terminate_Alternative is True, we need to lock Parent and -- Acceptor, in that order; otherwise, we only need a lock on Acceptor. -- However, we can't check Acceptor.Terminate_Alternative until Acceptor -- is locked. Therefore, we need to lock both. Attempts to avoid locking -- Parent tend to result in race conditions. It would work to unlock -- Parent immediately upon finding Acceptor.Terminate_Alternative to be -- False, but that violates the rule of properly nested locking (see -- System.Tasking). STPO.Write_Lock (Parent); STPO.Write_Lock (Acceptor); -- If the acceptor is not callable, abort the call and return False if not Acceptor.Callable then STPO.Unlock (Acceptor); STPO.Unlock (Parent); pragma Assert (Entry_Call.State < Done); -- In case we are not the caller, set up the caller -- to raise Tasking_Error when it wakes up. STPO.Write_Lock (Entry_Call.Self); Entry_Call.Exception_To_Raise := Tasking_Error'Identity; Initialization.Wakeup_Entry_Caller (Self_ID, Entry_Call, Done); STPO.Unlock (Entry_Call.Self); return False; end if; -- Try to serve the call immediately if Acceptor.Open_Accepts /= null then for J in Acceptor.Open_Accepts'Range loop if Entry_Call.E = Entry_Index (Acceptor.Open_Accepts (J).S) then -- Commit acceptor to rendezvous with us Acceptor.Chosen_Index := J; Null_Body := Acceptor.Open_Accepts (J).Null_Body; Acceptor.Open_Accepts := null; -- Prevent abort while call is being served if Entry_Call.State = Now_Abortable then Entry_Call.State := Was_Abortable; end if; if Acceptor.Terminate_Alternative then -- Cancel terminate alternative. See matching code in -- Selective_Wait and Vulnerable_Complete_Master. Acceptor.Terminate_Alternative := False; Acceptor.Awake_Count := Acceptor.Awake_Count + 1; if Acceptor.Awake_Count = 1 then -- Notify parent that acceptor is awake pragma Assert (Parent.Awake_Count > 0); Parent.Awake_Count := Parent.Awake_Count + 1; if Parent.Common.State = Master_Completion_Sleep and then Acceptor.Master_Of_Task = Parent.Master_Within then Parent.Common.Wait_Count := Parent.Common.Wait_Count + 1; end if; end if; end if; if Null_Body then -- Rendezvous is over immediately STPO.Wakeup (Acceptor, Acceptor_Sleep); STPO.Unlock (Acceptor); STPO.Unlock (Parent); STPO.Write_Lock (Entry_Call.Self); Initialization.Wakeup_Entry_Caller (Self_ID, Entry_Call, Done); STPO.Unlock (Entry_Call.Self); else Setup_For_Rendezvous_With_Body (Entry_Call, Acceptor); -- For terminate_alternative, acceptor may not be asleep -- yet, so we skip the wakeup if Acceptor.Common.State /= Runnable then STPO.Wakeup (Acceptor, Acceptor_Sleep); end if; STPO.Unlock (Acceptor); STPO.Unlock (Parent); end if; return True; end if; end loop; -- The acceptor is accepting, but not this entry end if; -- If the acceptor was ready to accept this call, -- we would not have gotten this far, so now we should -- (re)enqueue the call, if the mode permits that. -- If the call is timed, it may have timed out before the requeue, -- in the unusual case where the current accept has taken longer than -- the given delay. In that case the requeue is cancelled, and the -- outer timed call will be aborted. if Entry_Call.Mode = Conditional_Call or else (Entry_Call.Mode = Timed_Call and then Entry_Call.With_Abort and then Entry_Call.Cancellation_Attempted) then STPO.Unlock (Acceptor); STPO.Unlock (Parent); STPO.Write_Lock (Entry_Call.Self); pragma Assert (Entry_Call.State >= Was_Abortable); Initialization.Wakeup_Entry_Caller (Self_ID, Entry_Call, Cancelled); STPO.Unlock (Entry_Call.Self); else -- Timed_Call, Simple_Call, or Asynchronous_Call Queuing.Enqueue (Acceptor.Entry_Queues (E), Entry_Call); -- Update abortability of call pragma Assert (Old_State < Done); Entry_Call.State := New_State (Entry_Call.With_Abort, Entry_Call.State); STPO.Unlock (Acceptor); STPO.Unlock (Parent); if Old_State /= Entry_Call.State and then Entry_Call.State = Now_Abortable and then Entry_Call.Mode /= Simple_Call and then Entry_Call.Self /= Self_ID -- Asynchronous_Call or Conditional_Call then -- Because of ATCB lock ordering rule STPO.Write_Lock (Entry_Call.Self); if Entry_Call.Self.Common.State = Async_Select_Sleep then -- Caller may not yet have reached wait-point STPO.Wakeup (Entry_Call.Self, Async_Select_Sleep); end if; STPO.Unlock (Entry_Call.Self); end if; end if; return True; end Task_Do_Or_Queue; --------------------- -- Task_Entry_Call -- --------------------- procedure Task_Entry_Call (Acceptor : Task_Id; E : Task_Entry_Index; Uninterpreted_Data : System.Address; Mode : Call_Modes; Rendezvous_Successful : out Boolean) is Self_Id : constant Task_Id := STPO.Self; Entry_Call : Entry_Call_Link; begin -- If pragma Detect_Blocking is active then Program_Error must be -- raised if this potentially blocking operation is called from a -- protected action. if System.Tasking.Detect_Blocking and then Self_Id.Common.Protected_Action_Nesting > 0 then raise Program_Error with "potentially blocking operation"; end if; if Mode = Simple_Call or else Mode = Conditional_Call then Call_Synchronous (Acceptor, E, Uninterpreted_Data, Mode, Rendezvous_Successful); else -- This is an asynchronous call -- Abort must already be deferred by the compiler-generated code. -- Without this, an abort that occurs between the time that this -- call is made and the time that the abortable part's cleanup -- handler is set up might miss the cleanup handler and leave the -- call pending. Self_Id.ATC_Nesting_Level := Self_Id.ATC_Nesting_Level + 1; pragma Debug (Debug.Trace (Self_Id, "TEC: entered ATC level: " & ATC_Level'Image (Self_Id.ATC_Nesting_Level), 'A')); Entry_Call := Self_Id.Entry_Calls (Self_Id.ATC_Nesting_Level)'Access; Entry_Call.Next := null; Entry_Call.Mode := Mode; Entry_Call.Cancellation_Attempted := False; Entry_Call.State := Not_Yet_Abortable; Entry_Call.E := Entry_Index (E); Entry_Call.Prio := Get_Priority (Self_Id); Entry_Call.Uninterpreted_Data := Uninterpreted_Data; Entry_Call.Called_Task := Acceptor; Entry_Call.Called_PO := Null_Address; Entry_Call.Exception_To_Raise := Ada.Exceptions.Null_Id; Entry_Call.With_Abort := True; if not Task_Do_Or_Queue (Self_Id, Entry_Call) then STPO.Write_Lock (Self_Id); Utilities.Exit_One_ATC_Level (Self_Id); STPO.Unlock (Self_Id); Initialization.Undefer_Abort (Self_Id); raise Tasking_Error; end if; -- The following is special for async. entry calls. If the call was -- not queued abortably, we need to wait until it is before -- proceeding with the abortable part. -- Wait_Until_Abortable can be called unconditionally here, but it is -- expensive. if Entry_Call.State < Was_Abortable then Entry_Calls.Wait_Until_Abortable (Self_Id, Entry_Call); end if; -- Note: following assignment needs to be atomic Rendezvous_Successful := Entry_Call.State = Done; end if; end Task_Entry_Call; ----------------------- -- Task_Entry_Caller -- ----------------------- function Task_Entry_Caller (D : Task_Entry_Nesting_Depth) return Task_Id is Self_Id : constant Task_Id := STPO.Self; Entry_Call : Entry_Call_Link; begin Entry_Call := Self_Id.Common.Call; for Depth in 1 .. D loop Entry_Call := Entry_Call.Acceptor_Prev_Call; pragma Assert (Entry_Call /= null); end loop; return Entry_Call.Self; end Task_Entry_Caller; -------------------------- -- Timed_Selective_Wait -- -------------------------- procedure Timed_Selective_Wait (Open_Accepts : Accept_List_Access; Select_Mode : Select_Modes; Uninterpreted_Data : out System.Address; Timeout : Duration; Mode : Delay_Modes; Index : out Select_Index) is Self_Id : constant Task_Id := STPO.Self; Treatment : Select_Treatment; Entry_Call : Entry_Call_Link; Caller : Task_Id; Selection : Select_Index; Open_Alternative : Boolean; Timedout : Boolean := False; Yielded : Boolean := True; begin pragma Assert (Select_Mode = Delay_Mode); Initialization.Defer_Abort (Self_Id); -- If we are aborted here, the effect will be pending STPO.Write_Lock (Self_Id); if not Self_Id.Callable then pragma Assert (Self_Id.Pending_ATC_Level = Level_Completed_Task); pragma Assert (Self_Id.Pending_Action); STPO.Unlock (Self_Id); Initialization.Undefer_Abort (Self_Id); -- Should never get here ??? pragma Assert (Standard.False); raise Standard'Abort_Signal; end if; Uninterpreted_Data := Null_Address; pragma Assert (Open_Accepts /= null); Queuing.Select_Task_Entry_Call (Self_Id, Open_Accepts, Entry_Call, Selection, Open_Alternative); -- Determine the kind and disposition of the select Treatment := Default_Treatment (Select_Mode); Self_Id.Chosen_Index := No_Rendezvous; if Open_Alternative then if Entry_Call /= null then if Open_Accepts (Selection).Null_Body then Treatment := Accept_Alternative_Completed; else Setup_For_Rendezvous_With_Body (Entry_Call, Self_Id); Treatment := Accept_Alternative_Selected; end if; Self_Id.Chosen_Index := Selection; elsif Treatment = No_Alternative_Open then Treatment := Accept_Alternative_Open; end if; end if; -- Handle the select according to the disposition selected above case Treatment is when Accept_Alternative_Selected => -- Ready to rendezvous. In this case the accept body is not -- Null_Body. Defer abort until it gets into the accept body. Uninterpreted_Data := Self_Id.Common.Call.Uninterpreted_Data; Initialization.Defer_Abort_Nestable (Self_Id); STPO.Unlock (Self_Id); when Accept_Alternative_Completed => -- Rendezvous is over STPO.Unlock (Self_Id); Caller := Entry_Call.Self; STPO.Write_Lock (Caller); Initialization.Wakeup_Entry_Caller (Self_Id, Entry_Call, Done); STPO.Unlock (Caller); when Accept_Alternative_Open => -- Wait for caller Self_Id.Open_Accepts := Open_Accepts; -- Wait for a normal call and a pending action until the -- Wakeup_Time is reached. Self_Id.Common.State := Acceptor_Delay_Sleep; -- Try to remove calls to Sleep in the loop below by letting the -- caller a chance of getting ready immediately, using Unlock -- Yield. See similar action in Wait_For_Completion/Wait_For_Call. Unlock (Self_Id); if Self_Id.Open_Accepts /= null then Yield; end if; Write_Lock (Self_Id); -- Check if this task has been aborted while the lock was released if Self_Id.Pending_ATC_Level < Self_Id.ATC_Nesting_Level then Self_Id.Open_Accepts := null; end if; loop exit when Self_Id.Open_Accepts = null; if Timedout then Sleep (Self_Id, Acceptor_Delay_Sleep); else STPO.Timed_Sleep (Self_Id, Timeout, Mode, Acceptor_Delay_Sleep, Timedout, Yielded); end if; if Timedout then Self_Id.Open_Accepts := null; end if; end loop; Self_Id.Common.State := Runnable; -- Self_Id.Common.Call should already be updated by the Caller if -- not aborted. It might also be ready to do rendezvous even if -- this wakes up due to an abort. Therefore, if the call is not -- empty we need to do the rendezvous if the accept body is not -- Null_Body. if Self_Id.Chosen_Index /= No_Rendezvous and then Self_Id.Common.Call /= null and then not Open_Accepts (Self_Id.Chosen_Index).Null_Body then Uninterpreted_Data := Self_Id.Common.Call.Uninterpreted_Data; pragma Assert (Self_Id.Deferral_Level = 1); Initialization.Defer_Abort_Nestable (Self_Id); -- Leave abort deferred until the accept body end if; STPO.Unlock (Self_Id); when No_Alternative_Open => -- In this case, Index will be No_Rendezvous on return. We sleep -- for the time we need to. -- Wait for a signal or timeout. A wakeup can be made -- for several reasons: -- 1) Delay is expired -- 2) Pending_Action needs to be checked -- (Abort, Priority change) -- 3) Spurious wakeup Self_Id.Open_Accepts := null; Self_Id.Common.State := Acceptor_Delay_Sleep; STPO.Timed_Sleep (Self_Id, Timeout, Mode, Acceptor_Delay_Sleep, Timedout, Yielded); Self_Id.Common.State := Runnable; STPO.Unlock (Self_Id); when others => -- Should never get here pragma Assert (Standard.False); null; end case; if not Yielded then Yield; end if; -- Caller has been chosen -- Self_Id.Common.Call should already be updated by the Caller -- Self_Id.Chosen_Index should either be updated by the Caller -- or by Test_Selective_Wait Index := Self_Id.Chosen_Index; Initialization.Undefer_Abort_Nestable (Self_Id); -- Start rendezvous, if not already completed end Timed_Selective_Wait; --------------------------- -- Timed_Task_Entry_Call -- --------------------------- procedure Timed_Task_Entry_Call (Acceptor : Task_Id; E : Task_Entry_Index; Uninterpreted_Data : System.Address; Timeout : Duration; Mode : Delay_Modes; Rendezvous_Successful : out Boolean) is Self_Id : constant Task_Id := STPO.Self; Level : ATC_Level; Entry_Call : Entry_Call_Link; Yielded : Boolean; begin -- If pragma Detect_Blocking is active then Program_Error must be -- raised if this potentially blocking operation is called from a -- protected action. if System.Tasking.Detect_Blocking and then Self_Id.Common.Protected_Action_Nesting > 0 then raise Program_Error with "potentially blocking operation"; end if; Initialization.Defer_Abort_Nestable (Self_Id); Self_Id.ATC_Nesting_Level := Self_Id.ATC_Nesting_Level + 1; pragma Debug (Debug.Trace (Self_Id, "TTEC: entered ATC level: " & ATC_Level'Image (Self_Id.ATC_Nesting_Level), 'A')); Level := Self_Id.ATC_Nesting_Level; Entry_Call := Self_Id.Entry_Calls (Level)'Access; Entry_Call.Next := null; Entry_Call.Mode := Timed_Call; Entry_Call.Cancellation_Attempted := False; -- If this is a call made inside of an abort deferred region, -- the call should be never abortable. Entry_Call.State := (if Self_Id.Deferral_Level > 1 then Never_Abortable else Now_Abortable); Entry_Call.E := Entry_Index (E); Entry_Call.Prio := Get_Priority (Self_Id); Entry_Call.Uninterpreted_Data := Uninterpreted_Data; Entry_Call.Called_Task := Acceptor; Entry_Call.Called_PO := Null_Address; Entry_Call.Exception_To_Raise := Ada.Exceptions.Null_Id; Entry_Call.With_Abort := True; -- Note: the caller will undefer abort on return (see WARNING above) if not Task_Do_Or_Queue (Self_Id, Entry_Call) then STPO.Write_Lock (Self_Id); Utilities.Exit_One_ATC_Level (Self_Id); STPO.Unlock (Self_Id); Initialization.Undefer_Abort_Nestable (Self_Id); raise Tasking_Error; end if; Write_Lock (Self_Id); Entry_Calls.Wait_For_Completion_With_Timeout (Entry_Call, Timeout, Mode, Yielded); Unlock (Self_Id); -- ??? Do we need to yield in case Yielded is False Rendezvous_Successful := Entry_Call.State = Done; Initialization.Undefer_Abort_Nestable (Self_Id); Entry_Calls.Check_Exception (Self_Id, Entry_Call); end Timed_Task_Entry_Call; ------------------- -- Wait_For_Call -- ------------------- procedure Wait_For_Call (Self_Id : Task_Id) is begin Self_Id.Common.State := Acceptor_Sleep; -- Try to remove calls to Sleep in the loop below by letting the caller -- a chance of getting ready immediately, using Unlock & Yield. -- See similar action in Wait_For_Completion & Timed_Selective_Wait. Unlock (Self_Id); if Self_Id.Open_Accepts /= null then Yield; end if; Write_Lock (Self_Id); -- Check if this task has been aborted while the lock was released if Self_Id.Pending_ATC_Level < Self_Id.ATC_Nesting_Level then Self_Id.Open_Accepts := null; end if; loop exit when Self_Id.Open_Accepts = null; Sleep (Self_Id, Acceptor_Sleep); end loop; Self_Id.Common.State := Runnable; end Wait_For_Call; end System.Tasking.Rendezvous;
optikos/oasis
Ada
6,947
adb
-- Copyright (c) 2019 Maxim Reznik <[email protected]> -- -- SPDX-License-Identifier: MIT -- License-Filename: LICENSE ------------------------------------------------------------- package body Program.Nodes.Extended_Return_Statements is function Create (Return_Token : not null Program.Lexical_Elements .Lexical_Element_Access; Return_Object : not null Program.Elements .Return_Object_Specifications.Return_Object_Specification_Access; Do_Token : Program.Lexical_Elements.Lexical_Element_Access; Statements : Program.Element_Vectors.Element_Vector_Access; Exception_Token : Program.Lexical_Elements.Lexical_Element_Access; Exception_Handlers : Program.Elements.Exception_Handlers .Exception_Handler_Vector_Access; End_Token : Program.Lexical_Elements.Lexical_Element_Access; Return_Token_2 : Program.Lexical_Elements.Lexical_Element_Access; Semicolon_Token : not null Program.Lexical_Elements .Lexical_Element_Access) return Extended_Return_Statement is begin return Result : Extended_Return_Statement := (Return_Token => Return_Token, Return_Object => Return_Object, Do_Token => Do_Token, Statements => Statements, Exception_Token => Exception_Token, Exception_Handlers => Exception_Handlers, End_Token => End_Token, Return_Token_2 => Return_Token_2, Semicolon_Token => Semicolon_Token, Enclosing_Element => null) do Initialize (Result); end return; end Create; function Create (Return_Object : not null Program.Elements .Return_Object_Specifications.Return_Object_Specification_Access; Statements : Program.Element_Vectors.Element_Vector_Access; Exception_Handlers : Program.Elements.Exception_Handlers .Exception_Handler_Vector_Access; Is_Part_Of_Implicit : Boolean := False; Is_Part_Of_Inherited : Boolean := False; Is_Part_Of_Instance : Boolean := False) return Implicit_Extended_Return_Statement is begin return Result : Implicit_Extended_Return_Statement := (Return_Object => Return_Object, Statements => Statements, Exception_Handlers => Exception_Handlers, Is_Part_Of_Implicit => Is_Part_Of_Implicit, Is_Part_Of_Inherited => Is_Part_Of_Inherited, Is_Part_Of_Instance => Is_Part_Of_Instance, Enclosing_Element => null) do Initialize (Result); end return; end Create; overriding function Return_Object (Self : Base_Extended_Return_Statement) return not null Program.Elements.Return_Object_Specifications .Return_Object_Specification_Access is begin return Self.Return_Object; end Return_Object; overriding function Statements (Self : Base_Extended_Return_Statement) return Program.Element_Vectors.Element_Vector_Access is begin return Self.Statements; end Statements; overriding function Exception_Handlers (Self : Base_Extended_Return_Statement) return Program.Elements.Exception_Handlers .Exception_Handler_Vector_Access is begin return Self.Exception_Handlers; end Exception_Handlers; overriding function Return_Token (Self : Extended_Return_Statement) return not null Program.Lexical_Elements.Lexical_Element_Access is begin return Self.Return_Token; end Return_Token; overriding function Do_Token (Self : Extended_Return_Statement) return Program.Lexical_Elements.Lexical_Element_Access is begin return Self.Do_Token; end Do_Token; overriding function Exception_Token (Self : Extended_Return_Statement) return Program.Lexical_Elements.Lexical_Element_Access is begin return Self.Exception_Token; end Exception_Token; overriding function End_Token (Self : Extended_Return_Statement) return Program.Lexical_Elements.Lexical_Element_Access is begin return Self.End_Token; end End_Token; overriding function Return_Token_2 (Self : Extended_Return_Statement) return Program.Lexical_Elements.Lexical_Element_Access is begin return Self.Return_Token_2; end Return_Token_2; overriding function Semicolon_Token (Self : Extended_Return_Statement) return not null Program.Lexical_Elements.Lexical_Element_Access is begin return Self.Semicolon_Token; end Semicolon_Token; overriding function Is_Part_Of_Implicit (Self : Implicit_Extended_Return_Statement) return Boolean is begin return Self.Is_Part_Of_Implicit; end Is_Part_Of_Implicit; overriding function Is_Part_Of_Inherited (Self : Implicit_Extended_Return_Statement) return Boolean is begin return Self.Is_Part_Of_Inherited; end Is_Part_Of_Inherited; overriding function Is_Part_Of_Instance (Self : Implicit_Extended_Return_Statement) return Boolean is begin return Self.Is_Part_Of_Instance; end Is_Part_Of_Instance; procedure Initialize (Self : aliased in out Base_Extended_Return_Statement'Class) is begin Set_Enclosing_Element (Self.Return_Object, Self'Unchecked_Access); for Item in Self.Statements.Each_Element loop Set_Enclosing_Element (Item.Element, Self'Unchecked_Access); end loop; for Item in Self.Exception_Handlers.Each_Element loop Set_Enclosing_Element (Item.Element, Self'Unchecked_Access); end loop; null; end Initialize; overriding function Is_Extended_Return_Statement_Element (Self : Base_Extended_Return_Statement) return Boolean is pragma Unreferenced (Self); begin return True; end Is_Extended_Return_Statement_Element; overriding function Is_Statement_Element (Self : Base_Extended_Return_Statement) return Boolean is pragma Unreferenced (Self); begin return True; end Is_Statement_Element; overriding procedure Visit (Self : not null access Base_Extended_Return_Statement; Visitor : in out Program.Element_Visitors.Element_Visitor'Class) is begin Visitor.Extended_Return_Statement (Self); end Visit; overriding function To_Extended_Return_Statement_Text (Self : aliased in out Extended_Return_Statement) return Program.Elements.Extended_Return_Statements .Extended_Return_Statement_Text_Access is begin return Self'Unchecked_Access; end To_Extended_Return_Statement_Text; overriding function To_Extended_Return_Statement_Text (Self : aliased in out Implicit_Extended_Return_Statement) return Program.Elements.Extended_Return_Statements .Extended_Return_Statement_Text_Access is pragma Unreferenced (Self); begin return null; end To_Extended_Return_Statement_Text; end Program.Nodes.Extended_Return_Statements;
BrickBot/Bound-T-H8-300
Ada
2,954
adb
-- Programs.Execution.Opt (body) -- -- A component of the Bound-T Worst-Case Execution Time Tool. -- ------------------------------------------------------------------------------- -- Copyright (c) 1999 .. 2015 Tidorum Ltd -- All rights reserved. -- -- Redistribution and use in source and binary forms, with or without -- modification, are permitted provided that the following conditions are met: -- -- 1. Redistributions of source code must retain the above copyright notice, this -- list of conditions and the following disclaimer. -- 2. Redistributions in binary form must reproduce the above copyright notice, -- this list of conditions and the following disclaimer in the documentation -- and/or other materials provided with the distribution. -- -- This software is provided by the copyright holders and contributors "as is" and -- any express or implied warranties, including, but not limited to, the implied -- warranties of merchantability and fitness for a particular purpose are -- disclaimed. In no event shall the copyright owner or contributors be liable for -- any direct, indirect, incidental, special, exemplary, or consequential damages -- (including, but not limited to, procurement of substitute goods or services; -- loss of use, data, or profits; or business interruption) however caused and -- on any theory of liability, whether in contract, strict liability, or tort -- (including negligence or otherwise) arising in any way out of the use of this -- software, even if advised of the possibility of such damage. -- -- Other modules (files) of this software composition should contain their -- own copyright statements, which may have different copyright and usage -- conditions. The above conditions apply to this file. ------------------------------------------------------------------------------- -- -- $Revision: 1.2 $ -- $Date: 2015/10/24 20:05:50 $ -- -- $Log: programs-execution-opt.adb,v $ -- Revision 1.2 2015/10/24 20:05:50 niklas -- Moved to free licence. -- -- Revision 1.1 2011-08-31 04:17:14 niklas -- Added for BT-CH-0222: Option registry. Option -dump. External help files. -- with Options.Groups; package body Programs.Execution.Opt is begin Options.Register ( Option => Trace_Bounds_Opt'access, Name => Options.Trace_Item ("bounds"), Group => Options.Groups.Trace); Options.Register ( Option => Trace_Stack_Bounds_Opt'access, Name => Options.Trace_Item ("stack" ), Synonym => Options.Trace_Item ("stacks"), Groups => (Options.Groups.Trace, Options.Groups.Stack_Usage)); Options.Register ( Option => Trace_Call_Input_Bounds_Opt'access, Name => Options.Trace_Item ("inbounds"), Group => Options.Groups.Trace); Options.Register ( Option => Warn_Unbounded_Call_Opt'access, Name => Options.Warn_Item ("call"), Group => Options.Groups.Warn); end Programs.Execution.Opt;
EvilNuff/buildtools
Ada
15,824
ads
------------------------------------------------------------------------------ -- -- -- GNAT COMPILER COMPONENTS -- -- -- -- S Y S T E M . O S _ C O N S T A N T S -- -- -- -- S p e c -- -- -- -- Copyright (C) 2000-2013, 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. -- -- -- ------------------------------------------------------------------------------ pragma Style_Checks ("M32766"); -- Allow long lines -- This package provides target dependent definitions of constant for use -- by the GNAT runtime library. This package should not be directly with'd -- by an application program. -- This file is generated automatically, do not modify it by hand! Instead, -- make changes to s-oscons-tmplt.c and rebuild the GNAT runtime library. -- This is the version for i686-w64-mingw32 with Interfaces.C; package System.OS_Constants is pragma Pure; --------------------------------- -- General platform parameters -- --------------------------------- type OS_Type is (Windows, VMS, Other_OS); Target_OS : constant OS_Type := Windows; pragma Warnings (Off, Target_OS); -- Suppress warnings on Target_OS since it is in general tested for -- equality with a constant value to implement conditional compilation, -- which normally generates a constant condition warning. Target_Name : constant String := "i686-w64-mingw32"; SIZEOF_unsigned_int : constant := 4; -- Size of unsigned int ------------------- -- System limits -- ------------------- IOV_MAX : constant := 2147483647; -- Maximum writev iovcnt NAME_MAX : constant := 255; -- Maximum file name length FILENAME_MAX : constant := 260; -- Maximum file path length --------------------- -- File open modes -- --------------------- O_RDWR : constant := 2; -- Read/write O_NOCTTY : constant := -1; -- Don't change ctrl tty O_NDELAY : constant := -1; -- Nonblocking ---------------------- -- Fcntl operations -- ---------------------- F_GETFL : constant := -1; -- Get flags F_SETFL : constant := -1; -- Set flags ----------------- -- Fcntl flags -- ----------------- FNDELAY : constant := -1; -- Nonblocking ---------------------- -- Ioctl operations -- ---------------------- subtype IOCTL_Req_T is Interfaces.C.int; FIONBIO : constant := -2147195266; -- Set/clear non-blocking io FIONREAD : constant := 1074030207; -- How many bytes to read ------------------ -- Errno values -- ------------------ -- The following constants are defined from <errno.h> EAGAIN : constant := 11; -- Try again ENOENT : constant := 2; -- File not found ENOMEM : constant := 12; -- Out of memory -- The following constants are defined from <winsock2.h> (WSA*) EACCES : constant := 10013; -- Permission denied EADDRINUSE : constant := 10048; -- Address already in use EADDRNOTAVAIL : constant := 10049; -- Cannot assign address EAFNOSUPPORT : constant := 10047; -- Addr family not supported EALREADY : constant := 10037; -- Operation in progress EBADF : constant := 10009; -- Bad file descriptor ECONNABORTED : constant := 10053; -- Connection aborted ECONNREFUSED : constant := 10061; -- Connection refused ECONNRESET : constant := 10054; -- Connection reset by peer EDESTADDRREQ : constant := 10039; -- Destination addr required EFAULT : constant := 10014; -- Bad address EHOSTDOWN : constant := 10064; -- Host is down EHOSTUNREACH : constant := 10065; -- No route to host EINPROGRESS : constant := 10036; -- Operation now in progress EINTR : constant := 10004; -- Interrupted system call EINVAL : constant := 10022; -- Invalid argument EIO : constant := 10101; -- Input output error EISCONN : constant := 10056; -- Socket already connected ELOOP : constant := 10062; -- Too many symbolic links EMFILE : constant := 10024; -- Too many open files EMSGSIZE : constant := 10040; -- Message too long ENAMETOOLONG : constant := 10063; -- Name too long ENETDOWN : constant := 10050; -- Network is down ENETRESET : constant := 10052; -- Disconn. on network reset ENETUNREACH : constant := 10051; -- Network is unreachable ENOBUFS : constant := 10055; -- No buffer space available ENOPROTOOPT : constant := 10042; -- Protocol not available ENOTCONN : constant := 10057; -- Socket not connected ENOTSOCK : constant := 10038; -- Operation on non socket EOPNOTSUPP : constant := 10045; -- Operation not supported EPIPE : constant := 32; -- Broken pipe EPFNOSUPPORT : constant := 10046; -- Unknown protocol family EPROTONOSUPPORT : constant := 10043; -- Unknown protocol EPROTOTYPE : constant := 10041; -- Unknown protocol type ERANGE : constant := 34; -- Result too large ESHUTDOWN : constant := 10058; -- Cannot send once shutdown ESOCKTNOSUPPORT : constant := 10044; -- Socket type not supported ETIMEDOUT : constant := 10060; -- Connection timed out ETOOMANYREFS : constant := 10059; -- Too many references EWOULDBLOCK : constant := 10035; -- Operation would block E2BIG : constant := 7; -- Argument list too long EILSEQ : constant := 42; -- Illegal byte sequence ---------------------- -- Terminal control -- ---------------------- DTR_CONTROL_ENABLE : constant := 1; -- Enable DTR flow ctrl RTS_CONTROL_ENABLE : constant := 1; -- Enable RTS flow ctrl ----------------------------- -- Pseudo terminal library -- ----------------------------- PTY_Library : constant String := ""; -- for g-exptty -------------- -- Families -- -------------- AF_INET : constant := 2; -- IPv4 address family AF_INET6 : constant := 23; -- IPv6 address family ------------------ -- Socket modes -- ------------------ SOCK_STREAM : constant := 1; -- Stream socket SOCK_DGRAM : constant := 2; -- Datagram socket ----------------- -- Host errors -- ----------------- HOST_NOT_FOUND : constant := 11001; -- Unknown host TRY_AGAIN : constant := 11002; -- Host name lookup failure NO_DATA : constant := 11004; -- No data record for name NO_RECOVERY : constant := 11003; -- Non recoverable errors -------------------- -- Shutdown modes -- -------------------- SHUT_RD : constant := 0; -- No more recv SHUT_WR : constant := 1; -- No more send SHUT_RDWR : constant := 2; -- No more recv/send --------------------- -- Protocol levels -- --------------------- SOL_SOCKET : constant := 65535; -- Options for socket level IPPROTO_IP : constant := 0; -- Dummy protocol for IP IPPROTO_UDP : constant := 17; -- UDP IPPROTO_TCP : constant := 6; -- TCP ------------------- -- Request flags -- ------------------- MSG_OOB : constant := 1; -- Process out-of-band data MSG_PEEK : constant := 2; -- Peek at incoming data MSG_EOR : constant := -1; -- Send end of record MSG_WAITALL : constant := 8; -- Wait for full reception MSG_NOSIGNAL : constant := -1; -- No SIGPIPE on send MSG_Forced_Flags : constant := 0; -- Flags set on all send(2) calls -------------------- -- Socket options -- -------------------- TCP_NODELAY : constant := 1; -- Do not coalesce packets SO_REUSEADDR : constant := 4; -- Bind reuse local address SO_REUSEPORT : constant := -1; -- Bind reuse port number SO_KEEPALIVE : constant := 8; -- Enable keep-alive msgs SO_LINGER : constant := 128; -- Defer close to flush data SO_BROADCAST : constant := 32; -- Can send broadcast msgs SO_SNDBUF : constant := 4097; -- Set/get send buffer size SO_RCVBUF : constant := 4098; -- Set/get recv buffer size SO_SNDTIMEO : constant := 4101; -- Emission timeout SO_RCVTIMEO : constant := 4102; -- Reception timeout SO_ERROR : constant := 4103; -- Get/clear error status IP_MULTICAST_IF : constant := 9; -- Set/get mcast interface IP_MULTICAST_TTL : constant := 10; -- Set/get multicast TTL IP_MULTICAST_LOOP : constant := 11; -- Set/get mcast loopback IP_ADD_MEMBERSHIP : constant := 12; -- Join a multicast group IP_DROP_MEMBERSHIP : constant := 13; -- Leave a multicast group IP_PKTINFO : constant := 19; -- Get datagram info ---------------------- -- Type definitions -- ---------------------- -- Sizes (in bytes) of the components of struct timeval SIZEOF_tv_sec : constant := 4; -- tv_sec SIZEOF_tv_usec : constant := 4; -- tv_usec -- Maximum allowed value for tv_sec MAX_tv_sec : constant := 2 ** (SIZEOF_tv_sec * 8 - 1) - 1; -- Sizes of various data types SIZEOF_sockaddr_in : constant := 16; -- struct sockaddr_in SIZEOF_sockaddr_in6 : constant := 28; -- struct sockaddr_in6 SIZEOF_fd_set : constant := 8200; -- fd_set FD_SETSIZE : constant := 1024; -- Max fd value SIZEOF_struct_hostent : constant := 32; -- struct hostent SIZEOF_struct_servent : constant := 32; -- struct servent -- Fields of struct msghdr subtype Msg_Iovlen_T is Interfaces.C.size_t; ---------------------------------------- -- Properties of supported interfaces -- ---------------------------------------- Need_Netdb_Buffer : constant := 0; -- Need buffer for Netdb ops Need_Netdb_Lock : constant := 0; -- Need lock for Netdb ops Has_Sockaddr_Len : constant := 0; -- Sockaddr has sa_len field Thread_Blocking_IO : constant Boolean := True; -- Set False for contexts where socket i/o are process blocking Inet_Pton_Linkname : constant String := "__gnat_inet_pton"; --------------------- -- Threads support -- --------------------- -- Clock identifier definitions CLOCK_REALTIME : constant := 0; -- System realtime clock CLOCK_MONOTONIC : constant := 1; -- System monotonic clock CLOCK_THREAD_CPUTIME_ID : constant := 3; -- Thread CPU clock CLOCK_RT_Ada : constant := CLOCK_REALTIME; -------------------------------- -- File and directory support -- -------------------------------- SIZEOF_struct_file_attributes : constant := 32; -- struct file_attributes SIZEOF_struct_dirent_alloc : constant := 264; -- struct dirent allocation ------------------------------ -- MinGW-specific constants -- ------------------------------ -- These constants may be used only within the MinGW version of -- GNAT.Sockets.Thin. WSASYSNOTREADY : constant := 10091; -- System not ready WSAVERNOTSUPPORTED : constant := 10092; -- Version not supported WSANOTINITIALISED : constant := 10093; -- Winsock not initialized WSAEDISCON : constant := 10101; -- Disconnected end System.OS_Constants;
io7m/coreland-plexlog-ada
Ada
538
adb
with Ada.Text_IO; package body test is procedure sys_exit (ecode : in Integer); pragma Import (C, sys_exit, "exit"); procedure assert (check : in Boolean; pass_message : in String := "assertion passed"; fail_message : in String := "assertion failed") is begin if check then Ada.Text_IO.Put_Line (Ada.Text_IO.Current_Error, "pass: " & pass_message); else Ada.Text_IO.Put_Line (Ada.Text_IO.Current_Error, "fail: " & fail_message); sys_exit (1); end if; end assert; end test;
AdaCore/libadalang
Ada
347
ads
generic type Element_T is private; package Vector is type Vector is tagged null record; function Create return Vector'Class; function Element (Self : Vector; Index : Integer) return Element_T; procedure Append (Self : Vector; Element: Element_T); function Append (Self : Vector; Element: Element_T) return Integer; end Vector;
stcarrez/dynamo
Ada
64,767
adb
------------------------------------------------------------------------------ -- -- -- GNAT COMPILER COMPONENTS -- -- -- -- P R J -- -- -- -- B o d y -- -- -- -- Copyright (C) 2001-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. See the GNU General Public License -- -- for more details. You should have received a copy of the GNU General -- -- Public License distributed with GNAT; see file COPYING3. If not, go to -- -- http://www.gnu.org/licenses for a complete copy of the license. -- -- -- -- GNAT was originally developed by the GNAT team at New York University. -- -- Extensive contributions were provided by Ada Core Technologies Inc. -- -- -- ------------------------------------------------------------------------------ with Opt; with Osint; use Osint; with Output; use Output; with Prj.Attr; with Prj.Com; with Prj.Err; use Prj.Err; with Snames; use Snames; with Uintp; with Ada.Characters.Handling; use Ada.Characters.Handling; with Ada.Containers.Ordered_Sets; with Ada.Unchecked_Deallocation; with GNAT.Case_Util; use GNAT.Case_Util; with GNAT.Directory_Operations; use GNAT.Directory_Operations; with GNAT.HTable; package body Prj is type Restricted_Lang; type Restricted_Lang_Access is access Restricted_Lang; type Restricted_Lang is record Name : Name_Id; Next : Restricted_Lang_Access; end record; Restricted_Languages : Restricted_Lang_Access := null; -- When null, all languages are allowed, otherwise only the languages in -- the list are allowed. Object_Suffix : constant String := Get_Target_Object_Suffix.all; -- File suffix for object files Initial_Buffer_Size : constant := 100; -- Initial size for extensible buffer used in Add_To_Buffer The_Empty_String : Name_Id := No_Name; The_Dot_String : Name_Id := No_Name; Debug_Level : Integer := 0; -- Current indentation level for debug traces type Cst_String_Access is access constant String; All_Lower_Case_Image : aliased constant String := "lowercase"; All_Upper_Case_Image : aliased constant String := "UPPERCASE"; Mixed_Case_Image : aliased constant String := "MixedCase"; The_Casing_Images : constant array (Known_Casing) of Cst_String_Access := (All_Lower_Case => All_Lower_Case_Image'Access, All_Upper_Case => All_Upper_Case_Image'Access, Mixed_Case => Mixed_Case_Image'Access); procedure Free (Project : in out Project_Id); -- Free memory allocated for Project procedure Free_List (Languages : in out Language_Ptr); procedure Free_List (Source : in out Source_Id); procedure Free_List (Languages : in out Language_List); -- Free memory allocated for the list of languages or sources procedure Reset_Units_In_Table (Table : in out Units_Htable.Instance); -- Resets all Units to No_Unit_Index Unit.File_Names (Spec).Unit & -- Unit.File_Names (Impl).Unit in the given table. procedure Free_Units (Table : in out Units_Htable.Instance); -- Free memory allocated for unit information in the project procedure Language_Changed (Iter : in out Source_Iterator); procedure Project_Changed (Iter : in out Source_Iterator); -- Called when a new project or language was selected for this iterator function Contains_ALI_Files (Dir : Path_Name_Type) return Boolean; -- Return True if there is at least one ALI file in the directory Dir ----------------------------- -- Add_Restricted_Language -- ----------------------------- procedure Add_Restricted_Language (Name : String) is N : String (1 .. Name'Length) := Name; begin To_Lower (N); Name_Len := 0; Add_Str_To_Name_Buffer (N); Restricted_Languages := new Restricted_Lang'(Name => Name_Find, Next => Restricted_Languages); end Add_Restricted_Language; ------------------------------------- -- Remove_All_Restricted_Languages -- ------------------------------------- procedure Remove_All_Restricted_Languages is begin Restricted_Languages := null; end Remove_All_Restricted_Languages; ------------------- -- Add_To_Buffer -- ------------------- procedure Add_To_Buffer (S : String; To : in out String_Access; Last : in out Natural) is begin if To = null then To := new String (1 .. Initial_Buffer_Size); Last := 0; end if; -- If Buffer is too small, double its size while Last + S'Length > To'Last loop declare New_Buffer : constant String_Access := new String (1 .. 2 * To'Length); begin New_Buffer (1 .. Last) := To (1 .. Last); Free (To); To := New_Buffer; end; end loop; To (Last + 1 .. Last + S'Length) := S; Last := Last + S'Length; end Add_To_Buffer; --------------------------------- -- Current_Object_Path_File_Of -- --------------------------------- function Current_Object_Path_File_Of (Shared : Shared_Project_Tree_Data_Access) return Path_Name_Type is begin return Shared.Private_Part.Current_Object_Path_File; end Current_Object_Path_File_Of; --------------------------------- -- Current_Source_Path_File_Of -- --------------------------------- function Current_Source_Path_File_Of (Shared : Shared_Project_Tree_Data_Access) return Path_Name_Type is begin return Shared.Private_Part.Current_Source_Path_File; end Current_Source_Path_File_Of; --------------------------- -- Delete_Temporary_File -- --------------------------- procedure Delete_Temporary_File (Shared : Shared_Project_Tree_Data_Access := null; Path : Path_Name_Type) is Dont_Care : Boolean; pragma Warnings (Off, Dont_Care); begin if not Opt.Keep_Temporary_Files then if Current_Verbosity = High then Write_Line ("Removing temp file: " & Get_Name_String (Path)); end if; Delete_File (Get_Name_String (Path), Dont_Care); if Shared /= null then for Index in 1 .. Temp_Files_Table.Last (Shared.Private_Part.Temp_Files) loop if Shared.Private_Part.Temp_Files.Table (Index) = Path then Shared.Private_Part.Temp_Files.Table (Index) := No_Path; end if; end loop; end if; end if; end Delete_Temporary_File; ------------------------------ -- Delete_Temp_Config_Files -- ------------------------------ procedure Delete_Temp_Config_Files (Project_Tree : Project_Tree_Ref) is Success : Boolean; pragma Warnings (Off, Success); Proj : Project_List; begin if not Opt.Keep_Temporary_Files then if Project_Tree /= null then Proj := Project_Tree.Projects; while Proj /= null loop if Proj.Project.Config_File_Temp then Delete_Temporary_File (Project_Tree.Shared, Proj.Project.Config_File_Name); -- Make sure that we don't have a config file for this -- project, in case there are several mains. In this case, -- we will recreate another config file: we cannot reuse the -- one that we just deleted. Proj.Project.Config_Checked := False; Proj.Project.Config_File_Name := No_Path; Proj.Project.Config_File_Temp := False; end if; Proj := Proj.Next; end loop; end if; end if; end Delete_Temp_Config_Files; --------------------------- -- Delete_All_Temp_Files -- --------------------------- procedure Delete_All_Temp_Files (Shared : Shared_Project_Tree_Data_Access) is Dont_Care : Boolean; pragma Warnings (Off, Dont_Care); Path : Path_Name_Type; begin if not Opt.Keep_Temporary_Files then for Index in 1 .. Temp_Files_Table.Last (Shared.Private_Part.Temp_Files) loop Path := Shared.Private_Part.Temp_Files.Table (Index); if Path /= No_Path then if Current_Verbosity = High then Write_Line ("Removing temp file: " & Get_Name_String (Path)); end if; Delete_File (Get_Name_String (Path), Dont_Care); end if; end loop; Temp_Files_Table.Free (Shared.Private_Part.Temp_Files); Temp_Files_Table.Init (Shared.Private_Part.Temp_Files); end if; -- If any of the environment variables ADA_PRJ_INCLUDE_FILE or -- ADA_PRJ_OBJECTS_FILE has been set, then reset their value to -- the empty string. if Shared.Private_Part.Current_Source_Path_File /= No_Path then Setenv (Project_Include_Path_File, ""); end if; if Shared.Private_Part.Current_Object_Path_File /= No_Path then Setenv (Project_Objects_Path_File, ""); end if; end Delete_All_Temp_Files; --------------------- -- Dependency_Name -- --------------------- function Dependency_Name (Source_File_Name : File_Name_Type; Dependency : Dependency_File_Kind) return File_Name_Type is begin case Dependency is when None => return No_File; when Makefile => return Extend_Name (Source_File_Name, Makefile_Dependency_Suffix); when ALI_File | ALI_Closure => return Extend_Name (Source_File_Name, ALI_Dependency_Suffix); end case; end Dependency_Name; ---------------- -- Dot_String -- ---------------- function Dot_String return Name_Id is begin return The_Dot_String; end Dot_String; ---------------- -- Empty_File -- ---------------- function Empty_File return File_Name_Type is begin return File_Name_Type (The_Empty_String); end Empty_File; ------------------- -- Empty_Project -- ------------------- function Empty_Project (Qualifier : Project_Qualifier) return Project_Data is begin Prj.Initialize (Tree => No_Project_Tree); declare Data : Project_Data (Qualifier => Qualifier); begin -- Only the fields for which no default value could be provided in -- prj.ads are initialized below. Data.Config := Default_Project_Config; return Data; end; end Empty_Project; ------------------ -- Empty_String -- ------------------ function Empty_String return Name_Id is begin return The_Empty_String; end Empty_String; ------------ -- Expect -- ------------ procedure Expect (The_Token : Token_Type; Token_Image : String) is begin if Token /= The_Token then -- ??? Should pass user flags here instead Error_Msg (Gnatmake_Flags, Token_Image & " expected", Token_Ptr); end if; end Expect; ----------------- -- Extend_Name -- ----------------- function Extend_Name (File : File_Name_Type; With_Suffix : String) return File_Name_Type is Last : Positive; begin Get_Name_String (File); Last := Name_Len + 1; while Name_Len /= 0 and then Name_Buffer (Name_Len) /= '.' loop Name_Len := Name_Len - 1; end loop; if Name_Len <= 1 then Name_Len := Last; end if; for J in With_Suffix'Range loop Name_Buffer (Name_Len) := With_Suffix (J); Name_Len := Name_Len + 1; end loop; Name_Len := Name_Len - 1; return Name_Find; end Extend_Name; ------------------------- -- Is_Allowed_Language -- ------------------------- function Is_Allowed_Language (Name : Name_Id) return Boolean is R : Restricted_Lang_Access := Restricted_Languages; Lang : constant String := Get_Name_String (Name); begin if R = null then return True; else while R /= null loop if Get_Name_String (R.Name) = Lang then return True; end if; R := R.Next; end loop; return False; end if; end Is_Allowed_Language; --------------------- -- Project_Changed -- --------------------- procedure Project_Changed (Iter : in out Source_Iterator) is begin if Iter.Project /= null then Iter.Language := Iter.Project.Project.Languages; Language_Changed (Iter); end if; end Project_Changed; ---------------------- -- Language_Changed -- ---------------------- procedure Language_Changed (Iter : in out Source_Iterator) is begin Iter.Current := No_Source; if Iter.Language_Name /= No_Name then while Iter.Language /= null and then Iter.Language.Name /= Iter.Language_Name loop Iter.Language := Iter.Language.Next; end loop; end if; -- If there is no matching language in this project, move to next if Iter.Language = No_Language_Index then if Iter.All_Projects then loop Iter.Project := Iter.Project.Next; exit when Iter.Project = null or else Iter.Encapsulated_Libs or else not Iter.Project.From_Encapsulated_Lib; end loop; Project_Changed (Iter); else Iter.Project := null; end if; else Iter.Current := Iter.Language.First_Source; if Iter.Current = No_Source then Iter.Language := Iter.Language.Next; Language_Changed (Iter); elsif not Iter.Locally_Removed and then Iter.Current.Locally_Removed then Next (Iter); end if; end if; end Language_Changed; --------------------- -- For_Each_Source -- --------------------- function For_Each_Source (In_Tree : Project_Tree_Ref; Project : Project_Id := No_Project; Language : Name_Id := No_Name; Encapsulated_Libs : Boolean := True; Locally_Removed : Boolean := True) return Source_Iterator is Iter : Source_Iterator; begin Iter := Source_Iterator' (In_Tree => In_Tree, Project => In_Tree.Projects, All_Projects => Project = No_Project, Language_Name => Language, Language => No_Language_Index, Current => No_Source, Encapsulated_Libs => Encapsulated_Libs, Locally_Removed => Locally_Removed); if Project /= null then while Iter.Project /= null and then Iter.Project.Project /= Project loop Iter.Project := Iter.Project.Next; end loop; else while not Iter.Encapsulated_Libs and then Iter.Project.From_Encapsulated_Lib loop Iter.Project := Iter.Project.Next; end loop; end if; Project_Changed (Iter); return Iter; end For_Each_Source; ------------- -- Element -- ------------- function Element (Iter : Source_Iterator) return Source_Id is begin return Iter.Current; end Element; ---------- -- Next -- ---------- procedure Next (Iter : in out Source_Iterator) is begin loop Iter.Current := Iter.Current.Next_In_Lang; exit when Iter.Locally_Removed or else Iter.Current = No_Source or else not Iter.Current.Locally_Removed; end loop; if Iter.Current = No_Source then Iter.Language := Iter.Language.Next; Language_Changed (Iter); end if; end Next; -------------------------------- -- For_Every_Project_Imported -- -------------------------------- procedure For_Every_Project_Imported_Context (By : Project_Id; Tree : Project_Tree_Ref; With_State : in out State; Include_Aggregated : Boolean := True; Imported_First : Boolean := False) is -- use Project_Boolean_Htable; procedure Recursive_Check_Context (Project : Project_Id; Tree : Project_Tree_Ref; In_Aggregate_Lib : Boolean; From_Encapsulated_Lib : Boolean); -- Recursively handle the project tree creating a new context for -- keeping track about already handled projects. ----------------------------- -- Recursive_Check_Context -- ----------------------------- procedure Recursive_Check_Context (Project : Project_Id; Tree : Project_Tree_Ref; In_Aggregate_Lib : Boolean; From_Encapsulated_Lib : Boolean) is package Name_Id_Set is new Ada.Containers.Ordered_Sets (Element_Type => Name_Id); Seen_Name : Name_Id_Set.Set; -- This set is needed to ensure that we do not handle the same -- project twice in the context of aggregate libraries. procedure Recursive_Check (Project : Project_Id; Tree : Project_Tree_Ref; In_Aggregate_Lib : Boolean; From_Encapsulated_Lib : Boolean); -- Check if project has already been seen. If not, mark it as Seen, -- Call Action, and check all its imported and aggregated projects. --------------------- -- Recursive_Check -- --------------------- procedure Recursive_Check (Project : Project_Id; Tree : Project_Tree_Ref; In_Aggregate_Lib : Boolean; From_Encapsulated_Lib : Boolean) is function Has_Sources (P : Project_Id) return Boolean; -- Returns True if P has sources function Get_From_Tree (P : Project_Id) return Project_Id; -- Get project P from Tree. If P has no sources get another -- instance of this project with sources. If P has sources, -- returns it. ----------------- -- Has_Sources -- ----------------- function Has_Sources (P : Project_Id) return Boolean is Lang : Language_Ptr; begin Lang := P.Languages; while Lang /= No_Language_Index loop if Lang.First_Source /= No_Source then return True; end if; Lang := Lang.Next; end loop; return False; end Has_Sources; ------------------- -- Get_From_Tree -- ------------------- function Get_From_Tree (P : Project_Id) return Project_Id is List : Project_List := Tree.Projects; begin if not Has_Sources (P) then while List /= null loop if List.Project.Name = P.Name and then Has_Sources (List.Project) then return List.Project; end if; List := List.Next; end loop; end if; return P; end Get_From_Tree; -- Local variables List : Project_List; -- Start of processing for Recursive_Check begin if not Seen_Name.Contains (Project.Name) then -- Even if a project is aggregated multiple times in an -- aggregated library, we will only return it once. Seen_Name.Include (Project.Name); if not Imported_First then Action (Get_From_Tree (Project), Tree, Project_Context'(In_Aggregate_Lib, From_Encapsulated_Lib), With_State); end if; -- Visit all extended projects if Project.Extends /= No_Project then Recursive_Check (Project.Extends, Tree, In_Aggregate_Lib, From_Encapsulated_Lib); end if; -- Visit all imported projects List := Project.Imported_Projects; while List /= null loop Recursive_Check (List.Project, Tree, In_Aggregate_Lib, From_Encapsulated_Lib or else Project.Standalone_Library = Encapsulated); List := List.Next; end loop; -- Visit all aggregated projects if Include_Aggregated and then Project.Qualifier in Aggregate_Project then declare Agg : Aggregated_Project_List; begin Agg := Project.Aggregated_Projects; while Agg /= null loop pragma Assert (Agg.Project /= No_Project); -- For aggregated libraries, the tree must be the one -- of the aggregate library. if Project.Qualifier = Aggregate_Library then Recursive_Check (Agg.Project, Tree, True, From_Encapsulated_Lib or else Project.Standalone_Library = Encapsulated); else -- Use a new context as we want to returns the same -- project in different project tree for aggregated -- projects. Recursive_Check_Context (Agg.Project, Agg.Tree, False, False); end if; Agg := Agg.Next; end loop; end; end if; if Imported_First then Action (Get_From_Tree (Project), Tree, Project_Context'(In_Aggregate_Lib, From_Encapsulated_Lib), With_State); end if; end if; end Recursive_Check; -- Start of processing for Recursive_Check_Context begin Recursive_Check (Project, Tree, In_Aggregate_Lib, From_Encapsulated_Lib); end Recursive_Check_Context; -- Start of processing for For_Every_Project_Imported begin Recursive_Check_Context (Project => By, Tree => Tree, In_Aggregate_Lib => False, From_Encapsulated_Lib => False); end For_Every_Project_Imported_Context; procedure For_Every_Project_Imported (By : Project_Id; Tree : Project_Tree_Ref; With_State : in out State; Include_Aggregated : Boolean := True; Imported_First : Boolean := False) is procedure Internal (Project : Project_Id; Tree : Project_Tree_Ref; Context : Project_Context; With_State : in out State); -- Action wrapper for handling the context -------------- -- Internal -- -------------- procedure Internal (Project : Project_Id; Tree : Project_Tree_Ref; Context : Project_Context; With_State : in out State) is pragma Unreferenced (Context); begin Action (Project, Tree, With_State); end Internal; procedure For_Projects is new For_Every_Project_Imported_Context (State, Internal); begin For_Projects (By, Tree, With_State, Include_Aggregated, Imported_First); end For_Every_Project_Imported; ----------------- -- Find_Source -- ----------------- function Find_Source (In_Tree : Project_Tree_Ref; Project : Project_Id; In_Imported_Only : Boolean := False; In_Extended_Only : Boolean := False; Base_Name : File_Name_Type; Index : Int := 0) return Source_Id is Result : Source_Id := No_Source; procedure Look_For_Sources (Proj : Project_Id; Tree : Project_Tree_Ref; Src : in out Source_Id); -- Look for Base_Name in the sources of Proj ---------------------- -- Look_For_Sources -- ---------------------- procedure Look_For_Sources (Proj : Project_Id; Tree : Project_Tree_Ref; Src : in out Source_Id) is Iterator : Source_Iterator; begin Iterator := For_Each_Source (In_Tree => Tree, Project => Proj); while Element (Iterator) /= No_Source loop if Element (Iterator).File = Base_Name and then (Index = 0 or else Element (Iterator).Index = Index) then Src := Element (Iterator); -- If the source has been excluded, continue looking. We will -- get the excluded source only if there is no other source -- with the same base name that is not locally removed. if not Element (Iterator).Locally_Removed then return; end if; end if; Next (Iterator); end loop; end Look_For_Sources; procedure For_Imported_Projects is new For_Every_Project_Imported (State => Source_Id, Action => Look_For_Sources); Proj : Project_Id; -- Start of processing for Find_Source begin if In_Extended_Only then Proj := Project; while Proj /= No_Project loop Look_For_Sources (Proj, In_Tree, Result); exit when Result /= No_Source; Proj := Proj.Extends; end loop; elsif In_Imported_Only then Look_For_Sources (Project, In_Tree, Result); if Result = No_Source then For_Imported_Projects (By => Project, Tree => In_Tree, Include_Aggregated => False, With_State => Result); end if; else Look_For_Sources (No_Project, In_Tree, Result); end if; return Result; end Find_Source; ---------------------- -- Find_All_Sources -- ---------------------- function Find_All_Sources (In_Tree : Project_Tree_Ref; Project : Project_Id; In_Imported_Only : Boolean := False; In_Extended_Only : Boolean := False; Base_Name : File_Name_Type; Index : Int := 0) return Source_Ids is Result : Source_Ids (1 .. 1_000); Last : Natural := 0; type Empty_State is null record; No_State : Empty_State; -- This is needed for the State parameter of procedure Look_For_Sources -- below, because of the instantiation For_Imported_Projects of generic -- procedure For_Every_Project_Imported. As procedure Look_For_Sources -- does not modify parameter State, there is no need to give its type -- more than one value. procedure Look_For_Sources (Proj : Project_Id; Tree : Project_Tree_Ref; State : in out Empty_State); -- Look for Base_Name in the sources of Proj ---------------------- -- Look_For_Sources -- ---------------------- procedure Look_For_Sources (Proj : Project_Id; Tree : Project_Tree_Ref; State : in out Empty_State) is Iterator : Source_Iterator; Src : Source_Id; begin State := No_State; Iterator := For_Each_Source (In_Tree => Tree, Project => Proj); while Element (Iterator) /= No_Source loop if Element (Iterator).File = Base_Name and then (Index = 0 or else (Element (Iterator).Unit /= No_Unit_Index and then Element (Iterator).Index = Index)) then Src := Element (Iterator); -- If the source has been excluded, continue looking. We will -- get the excluded source only if there is no other source -- with the same base name that is not locally removed. if not Element (Iterator).Locally_Removed then Last := Last + 1; Result (Last) := Src; end if; end if; Next (Iterator); end loop; end Look_For_Sources; procedure For_Imported_Projects is new For_Every_Project_Imported (State => Empty_State, Action => Look_For_Sources); Proj : Project_Id; -- Start of processing for Find_All_Sources begin if In_Extended_Only then Proj := Project; while Proj /= No_Project loop Look_For_Sources (Proj, In_Tree, No_State); exit when Last > 0; Proj := Proj.Extends; end loop; elsif In_Imported_Only then Look_For_Sources (Project, In_Tree, No_State); if Last = 0 then For_Imported_Projects (By => Project, Tree => In_Tree, Include_Aggregated => False, With_State => No_State); end if; else Look_For_Sources (No_Project, In_Tree, No_State); end if; return Result (1 .. Last); end Find_All_Sources; ---------- -- Hash -- ---------- function Hash is new GNAT.HTable.Hash (Header_Num => Header_Num); -- Used in implementation of other functions Hash below ---------- -- Hash -- ---------- function Hash (Name : File_Name_Type) return Header_Num is begin return Hash (Get_Name_String (Name)); end Hash; function Hash (Name : Name_Id) return Header_Num is begin return Hash (Get_Name_String (Name)); end Hash; function Hash (Name : Path_Name_Type) return Header_Num is begin return Hash (Get_Name_String (Name)); end Hash; function Hash (Project : Project_Id) return Header_Num is begin if Project = No_Project then return Header_Num'First; else return Hash (Get_Name_String (Project.Name)); end if; end Hash; ----------- -- Image -- ----------- function Image (The_Casing : Casing_Type) return String is begin return The_Casing_Images (The_Casing).all; end Image; ----------------------------- -- Is_Standard_GNAT_Naming -- ----------------------------- function Is_Standard_GNAT_Naming (Naming : Lang_Naming_Data) return Boolean is begin return Get_Name_String (Naming.Spec_Suffix) = ".ads" and then Get_Name_String (Naming.Body_Suffix) = ".adb" and then Get_Name_String (Naming.Dot_Replacement) = "-"; end Is_Standard_GNAT_Naming; ---------------- -- Initialize -- ---------------- procedure Initialize (Tree : Project_Tree_Ref) is begin if The_Empty_String = No_Name then Uintp.Initialize; Name_Len := 0; The_Empty_String := Name_Find; Name_Len := 1; Name_Buffer (1) := '.'; The_Dot_String := Name_Find; Prj.Attr.Initialize; -- Make sure that new reserved words after Ada 95 may be used as -- identifiers. Opt.Ada_Version := Opt.Ada_95; Opt.Ada_Version_Pragma := Empty; Set_Name_Table_Byte (Name_Project, Token_Type'Pos (Tok_Project)); Set_Name_Table_Byte (Name_Extends, Token_Type'Pos (Tok_Extends)); Set_Name_Table_Byte (Name_External, Token_Type'Pos (Tok_External)); Set_Name_Table_Byte (Name_External_As_List, Token_Type'Pos (Tok_External_As_List)); end if; if Tree /= No_Project_Tree then Reset (Tree); end if; end Initialize; ------------------ -- Is_Extending -- ------------------ function Is_Extending (Extending : Project_Id; Extended : Project_Id) return Boolean is Proj : Project_Id; begin Proj := Extending; while Proj /= No_Project loop if Proj = Extended then return True; end if; Proj := Proj.Extends; end loop; return False; end Is_Extending; ----------------- -- Object_Name -- ----------------- function Object_Name (Source_File_Name : File_Name_Type; Object_File_Suffix : Name_Id := No_Name) return File_Name_Type is begin if Object_File_Suffix = No_Name then return Extend_Name (Source_File_Name, Object_Suffix); else return Extend_Name (Source_File_Name, Get_Name_String (Object_File_Suffix)); end if; end Object_Name; function Object_Name (Source_File_Name : File_Name_Type; Source_Index : Int; Index_Separator : Character; Object_File_Suffix : Name_Id := No_Name) return File_Name_Type is Index_Img : constant String := Source_Index'Img; Last : Natural; begin Get_Name_String (Source_File_Name); Last := Name_Len; while Last > 1 and then Name_Buffer (Last) /= '.' loop Last := Last - 1; end loop; if Last > 1 then Name_Len := Last - 1; end if; Add_Char_To_Name_Buffer (Index_Separator); Add_Str_To_Name_Buffer (Index_Img (2 .. Index_Img'Last)); if Object_File_Suffix = No_Name then Add_Str_To_Name_Buffer (Object_Suffix); else Add_Str_To_Name_Buffer (Get_Name_String (Object_File_Suffix)); end if; return Name_Find; end Object_Name; ---------------------- -- Record_Temp_File -- ---------------------- procedure Record_Temp_File (Shared : Shared_Project_Tree_Data_Access; Path : Path_Name_Type) is begin Temp_Files_Table.Append (Shared.Private_Part.Temp_Files, Path); end Record_Temp_File; ---------- -- Free -- ---------- procedure Free (List : in out Aggregated_Project_List) is procedure Unchecked_Free is new Ada.Unchecked_Deallocation (Aggregated_Project, Aggregated_Project_List); Tmp : Aggregated_Project_List; begin while List /= null loop Tmp := List.Next; Free (List.Tree); Unchecked_Free (List); List := Tmp; end loop; end Free; ---------------------------- -- Add_Aggregated_Project -- ---------------------------- procedure Add_Aggregated_Project (Project : Project_Id; Path : Path_Name_Type) is Aggregated : Aggregated_Project_List; begin -- Check if the project is already in the aggregated project list. If it -- is, do not add it again. Aggregated := Project.Aggregated_Projects; while Aggregated /= null loop if Path = Aggregated.Path then return; else Aggregated := Aggregated.Next; end if; end loop; Project.Aggregated_Projects := new Aggregated_Project' (Path => Path, Project => No_Project, Tree => null, Next => Project.Aggregated_Projects); end Add_Aggregated_Project; ---------- -- Free -- ---------- procedure Free (Project : in out Project_Id) is procedure Unchecked_Free is new Ada.Unchecked_Deallocation (Project_Data, Project_Id); begin if Project /= null then Free (Project.Ada_Include_Path); Free (Project.Objects_Path); Free (Project.Ada_Objects_Path); Free (Project.Ada_Objects_Path_No_Libs); Free_List (Project.Imported_Projects, Free_Project => False); Free_List (Project.All_Imported_Projects, Free_Project => False); Free_List (Project.Languages); case Project.Qualifier is when Aggregate | Aggregate_Library => Free (Project.Aggregated_Projects); when others => null; end case; Unchecked_Free (Project); end if; end Free; --------------- -- Free_List -- --------------- procedure Free_List (Languages : in out Language_List) is procedure Unchecked_Free is new Ada.Unchecked_Deallocation (Language_List_Element, Language_List); Tmp : Language_List; begin while Languages /= null loop Tmp := Languages.Next; Unchecked_Free (Languages); Languages := Tmp; end loop; end Free_List; --------------- -- Free_List -- --------------- procedure Free_List (Source : in out Source_Id) is procedure Unchecked_Free is new Ada.Unchecked_Deallocation (Source_Data, Source_Id); Tmp : Source_Id; begin while Source /= No_Source loop Tmp := Source.Next_In_Lang; Free_List (Source.Alternate_Languages); if Source.Unit /= null and then Source.Kind in Spec_Or_Body then Source.Unit.File_Names (Source.Kind) := null; end if; Unchecked_Free (Source); Source := Tmp; end loop; end Free_List; --------------- -- Free_List -- --------------- procedure Free_List (List : in out Project_List; Free_Project : Boolean) is procedure Unchecked_Free is new Ada.Unchecked_Deallocation (Project_List_Element, Project_List); Tmp : Project_List; begin while List /= null loop Tmp := List.Next; if Free_Project then Free (List.Project); end if; Unchecked_Free (List); List := Tmp; end loop; end Free_List; --------------- -- Free_List -- --------------- procedure Free_List (Languages : in out Language_Ptr) is procedure Unchecked_Free is new Ada.Unchecked_Deallocation (Language_Data, Language_Ptr); Tmp : Language_Ptr; begin while Languages /= null loop Tmp := Languages.Next; Free_List (Languages.First_Source); Unchecked_Free (Languages); Languages := Tmp; end loop; end Free_List; -------------------------- -- Reset_Units_In_Table -- -------------------------- procedure Reset_Units_In_Table (Table : in out Units_Htable.Instance) is Unit : Unit_Index; begin Unit := Units_Htable.Get_First (Table); while Unit /= No_Unit_Index loop if Unit.File_Names (Spec) /= null then Unit.File_Names (Spec).Unit := No_Unit_Index; end if; if Unit.File_Names (Impl) /= null then Unit.File_Names (Impl).Unit := No_Unit_Index; end if; Unit := Units_Htable.Get_Next (Table); end loop; end Reset_Units_In_Table; ---------------- -- Free_Units -- ---------------- procedure Free_Units (Table : in out Units_Htable.Instance) is procedure Unchecked_Free is new Ada.Unchecked_Deallocation (Unit_Data, Unit_Index); Unit : Unit_Index; begin Unit := Units_Htable.Get_First (Table); while Unit /= No_Unit_Index loop -- We cannot reset Unit.File_Names (Impl or Spec).Unit here as -- Source_Data buffer is freed by the following instruction -- Free_List (Tree.Projects, Free_Project => True); Unchecked_Free (Unit); Unit := Units_Htable.Get_Next (Table); end loop; Units_Htable.Reset (Table); end Free_Units; ---------- -- Free -- ---------- procedure Free (Tree : in out Project_Tree_Ref) is procedure Unchecked_Free is new Ada.Unchecked_Deallocation (Project_Tree_Data, Project_Tree_Ref); procedure Unchecked_Free is new Ada.Unchecked_Deallocation (Project_Tree_Appdata'Class, Project_Tree_Appdata_Access); begin if Tree /= null then if Tree.Is_Root_Tree then Name_List_Table.Free (Tree.Shared.Name_Lists); Number_List_Table.Free (Tree.Shared.Number_Lists); String_Element_Table.Free (Tree.Shared.String_Elements); Variable_Element_Table.Free (Tree.Shared.Variable_Elements); Array_Element_Table.Free (Tree.Shared.Array_Elements); Array_Table.Free (Tree.Shared.Arrays); Package_Table.Free (Tree.Shared.Packages); Temp_Files_Table.Free (Tree.Shared.Private_Part.Temp_Files); end if; if Tree.Appdata /= null then Free (Tree.Appdata.all); Unchecked_Free (Tree.Appdata); end if; Source_Paths_Htable.Reset (Tree.Source_Paths_HT); Source_Files_Htable.Reset (Tree.Source_Files_HT); Reset_Units_In_Table (Tree.Units_HT); Free_List (Tree.Projects, Free_Project => True); Free_Units (Tree.Units_HT); Unchecked_Free (Tree); end if; end Free; ----------- -- Reset -- ----------- procedure Reset (Tree : Project_Tree_Ref) is begin -- Visible tables if Tree.Is_Root_Tree then -- We cannot use 'Access here: -- "illegal attribute for discriminant-dependent component" -- However, we know this is valid since Shared and Shared_Data have -- the same lifetime and will always exist concurrently. Tree.Shared := Tree.Shared_Data'Unrestricted_Access; Name_List_Table.Init (Tree.Shared.Name_Lists); Number_List_Table.Init (Tree.Shared.Number_Lists); String_Element_Table.Init (Tree.Shared.String_Elements); Variable_Element_Table.Init (Tree.Shared.Variable_Elements); Array_Element_Table.Init (Tree.Shared.Array_Elements); Array_Table.Init (Tree.Shared.Arrays); Package_Table.Init (Tree.Shared.Packages); -- Create Dot_String_List String_Element_Table.Append (Tree.Shared.String_Elements, String_Element' (Value => The_Dot_String, Index => 0, Display_Value => The_Dot_String, Location => No_Location, Flag => False, Next => Nil_String)); Tree.Shared.Dot_String_List := String_Element_Table.Last (Tree.Shared.String_Elements); -- Private part table Temp_Files_Table.Init (Tree.Shared.Private_Part.Temp_Files); Tree.Shared.Private_Part.Current_Source_Path_File := No_Path; Tree.Shared.Private_Part.Current_Object_Path_File := No_Path; end if; Source_Paths_Htable.Reset (Tree.Source_Paths_HT); Source_Files_Htable.Reset (Tree.Source_Files_HT); Replaced_Source_HTable.Reset (Tree.Replaced_Sources); Tree.Replaced_Source_Number := 0; Reset_Units_In_Table (Tree.Units_HT); Free_List (Tree.Projects, Free_Project => True); Free_Units (Tree.Units_HT); end Reset; ------------------------------------- -- Set_Current_Object_Path_File_Of -- ------------------------------------- procedure Set_Current_Object_Path_File_Of (Shared : Shared_Project_Tree_Data_Access; To : Path_Name_Type) is begin Shared.Private_Part.Current_Object_Path_File := To; end Set_Current_Object_Path_File_Of; ------------------------------------- -- Set_Current_Source_Path_File_Of -- ------------------------------------- procedure Set_Current_Source_Path_File_Of (Shared : Shared_Project_Tree_Data_Access; To : Path_Name_Type) is begin Shared.Private_Part.Current_Source_Path_File := To; end Set_Current_Source_Path_File_Of; ----------------------- -- Set_Path_File_Var -- ----------------------- procedure Set_Path_File_Var (Name : String; Value : String) is Host_Spec : String_Access := To_Host_File_Spec (Value); begin if Host_Spec = null then Prj.Com.Fail ("could not convert file name """ & Value & """ to host spec"); else Setenv (Name, Host_Spec.all); Free (Host_Spec); end if; end Set_Path_File_Var; ------------------- -- Switches_Name -- ------------------- function Switches_Name (Source_File_Name : File_Name_Type) return File_Name_Type is begin return Extend_Name (Source_File_Name, Switches_Dependency_Suffix); end Switches_Name; ----------- -- Value -- ----------- function Value (Image : String) return Casing_Type is -- SCz 2022-03-26: some version of GNAT fail to see the To_Lower function, -- and some other GNAT version report a warning that To_Lower is already visible. -- let's use another name to keep all these compiler versions happy! function To_Lower_Case (S : in String) return String renames Ada.Characters.Handling.To_Lower; begin for Casing in The_Casing_Images'Range loop if To_Lower_Case (Image) = To_Lower_Case (The_Casing_Images (Casing).all) then return Casing; end if; end loop; raise Constraint_Error; end Value; --------------------- -- Has_Ada_Sources -- --------------------- function Has_Ada_Sources (Data : Project_Id) return Boolean is Lang : Language_Ptr; begin Lang := Data.Languages; while Lang /= No_Language_Index loop if Lang.Name = Name_Ada then return Lang.First_Source /= No_Source; end if; Lang := Lang.Next; end loop; return False; end Has_Ada_Sources; ------------------------ -- Contains_ALI_Files -- ------------------------ function Contains_ALI_Files (Dir : Path_Name_Type) return Boolean is Dir_Name : constant String := Get_Name_String (Dir); Direct : Dir_Type; Name : String (1 .. 1_000); Last : Natural; Result : Boolean := False; begin Open (Direct, Dir_Name); -- For each file in the directory, check if it is an ALI file loop Read (Direct, Name, Last); exit when Last = 0; Canonical_Case_File_Name (Name (1 .. Last)); Result := Last >= 5 and then Name (Last - 3 .. Last) = ".ali"; exit when Result; end loop; Close (Direct); return Result; exception -- If there is any problem, close the directory if open and return True. -- The library directory will be added to the path. when others => if Is_Open (Direct) then Close (Direct); end if; return True; end Contains_ALI_Files; -------------------------- -- Get_Object_Directory -- -------------------------- function Get_Object_Directory (Project : Project_Id; Including_Libraries : Boolean; Only_If_Ada : Boolean := False) return Path_Name_Type is begin if (Project.Library and then Including_Libraries) or else (Project.Object_Directory /= No_Path_Information and then (not Including_Libraries or else not Project.Library)) then -- For a library project, add the library ALI directory if there is -- no object directory or if the library ALI directory contains ALI -- files; otherwise add the object directory. if Project.Library then if Project.Object_Directory = No_Path_Information or else (Including_Libraries and then Contains_ALI_Files (Project.Library_ALI_Dir.Display_Name)) then return Project.Library_ALI_Dir.Display_Name; else return Project.Object_Directory.Display_Name; end if; -- For a non-library project, add object directory if it is not a -- virtual project, and if there are Ada sources in the project or -- one of the projects it extends. If there are no Ada sources, -- adding the object directory could disrupt the order of the -- object dirs in the path. elsif not Project.Virtual then declare Add_Object_Dir : Boolean; Prj : Project_Id; begin Add_Object_Dir := not Only_If_Ada; Prj := Project; while not Add_Object_Dir and then Prj /= No_Project loop if Has_Ada_Sources (Prj) then Add_Object_Dir := True; else Prj := Prj.Extends; end if; end loop; if Add_Object_Dir then return Project.Object_Directory.Display_Name; end if; end; end if; end if; return No_Path; end Get_Object_Directory; ----------------------------------- -- Ultimate_Extending_Project_Of -- ----------------------------------- function Ultimate_Extending_Project_Of (Proj : Project_Id) return Project_Id is Prj : Project_Id; begin Prj := Proj; while Prj /= null and then Prj.Extended_By /= No_Project loop Prj := Prj.Extended_By; end loop; return Prj; end Ultimate_Extending_Project_Of; ----------------------------------- -- Compute_All_Imported_Projects -- ----------------------------------- procedure Compute_All_Imported_Projects (Root_Project : Project_Id; Tree : Project_Tree_Ref) is procedure Analyze_Tree (Local_Root : Project_Id; Local_Tree : Project_Tree_Ref; Context : Project_Context); -- Process Project and all its aggregated project to analyze their own -- imported projects. ------------------ -- Analyze_Tree -- ------------------ procedure Analyze_Tree (Local_Root : Project_Id; Local_Tree : Project_Tree_Ref; Context : Project_Context) is pragma Unreferenced (Local_Root); Project : Project_Id; procedure Recursive_Add (Prj : Project_Id; Tree : Project_Tree_Ref; Context : Project_Context; Dummy : in out Boolean); -- Recursively add the projects imported by project Project, but not -- those that are extended. ------------------- -- Recursive_Add -- ------------------- procedure Recursive_Add (Prj : Project_Id; Tree : Project_Tree_Ref; Context : Project_Context; Dummy : in out Boolean) is pragma Unreferenced (Tree); List : Project_List; Prj2 : Project_Id; begin -- A project is not importing itself Prj2 := Ultimate_Extending_Project_Of (Prj); if Project /= Prj2 then -- Check that the project is not already in the list. We know -- the one passed to Recursive_Add have never been visited -- before, but the one passed it are the extended projects. List := Project.All_Imported_Projects; while List /= null loop if List.Project = Prj2 then return; end if; List := List.Next; end loop; -- Add it to the list Project.All_Imported_Projects := new Project_List_Element' (Project => Prj2, From_Encapsulated_Lib => Context.From_Encapsulated_Lib or else Analyze_Tree.Context.From_Encapsulated_Lib, Next => Project.All_Imported_Projects); end if; end Recursive_Add; procedure For_All_Projects is new For_Every_Project_Imported_Context (Boolean, Recursive_Add); Dummy : Boolean := False; List : Project_List; begin List := Local_Tree.Projects; while List /= null loop Project := List.Project; Free_List (Project.All_Imported_Projects, Free_Project => False); For_All_Projects (Project, Local_Tree, Dummy, Include_Aggregated => False); List := List.Next; end loop; end Analyze_Tree; procedure For_Aggregates is new For_Project_And_Aggregated_Context (Analyze_Tree); -- Start of processing for Compute_All_Imported_Projects begin For_Aggregates (Root_Project, Tree); end Compute_All_Imported_Projects; ------------------- -- Is_Compilable -- ------------------- function Is_Compilable (Source : Source_Id) return Boolean is begin case Source.Compilable is when Unknown => if Source.Language.Config.Compiler_Driver /= No_File and then Length_Of_Name (Source.Language.Config.Compiler_Driver) /= 0 and then not Source.Locally_Removed and then (Source.Language.Config.Kind /= File_Based or else Source.Kind /= Spec) then -- Do not modify Source.Compilable before the source record -- has been initialized. if Source.Source_TS /= Empty_Time_Stamp then Source.Compilable := Yes; end if; return True; else if Source.Source_TS /= Empty_Time_Stamp then Source.Compilable := No; end if; return False; end if; when Yes => return True; when No => return False; end case; end Is_Compilable; ------------------------------ -- Object_To_Global_Archive -- ------------------------------ function Object_To_Global_Archive (Source : Source_Id) return Boolean is begin return Source.Language.Config.Kind = File_Based and then Source.Kind = Impl and then Source.Language.Config.Objects_Linked and then Is_Compilable (Source) and then Source.Language.Config.Object_Generated; end Object_To_Global_Archive; ---------------------------- -- Get_Language_From_Name -- ---------------------------- function Get_Language_From_Name (Project : Project_Id; Name : String) return Language_Ptr is N : Name_Id; Result : Language_Ptr; begin Name_Len := Name'Length; Name_Buffer (1 .. Name_Len) := Name; To_Lower (Name_Buffer (1 .. Name_Len)); N := Name_Find; Result := Project.Languages; while Result /= No_Language_Index loop if Result.Name = N then return Result; end if; Result := Result.Next; end loop; return No_Language_Index; end Get_Language_From_Name; ---------------- -- Other_Part -- ---------------- function Other_Part (Source : Source_Id) return Source_Id is begin if Source.Unit /= No_Unit_Index then case Source.Kind is when Impl => return Source.Unit.File_Names (Spec); when Spec => return Source.Unit.File_Names (Impl); when Sep => return No_Source; end case; else return No_Source; end if; end Other_Part; ------------------ -- Create_Flags -- ------------------ function Create_Flags (Report_Error : Error_Handler; When_No_Sources : Error_Warning; Require_Sources_Other_Lang : Boolean := True; Allow_Duplicate_Basenames : Boolean := True; Compiler_Driver_Mandatory : Boolean := False; Error_On_Unknown_Language : Boolean := True; Require_Obj_Dirs : Error_Warning := Error; Allow_Invalid_External : Error_Warning := Error; Missing_Source_Files : Error_Warning := Error; Ignore_Missing_With : Boolean := False) return Processing_Flags is begin return Processing_Flags' (Report_Error => Report_Error, When_No_Sources => When_No_Sources, Require_Sources_Other_Lang => Require_Sources_Other_Lang, Allow_Duplicate_Basenames => Allow_Duplicate_Basenames, Error_On_Unknown_Language => Error_On_Unknown_Language, Compiler_Driver_Mandatory => Compiler_Driver_Mandatory, Require_Obj_Dirs => Require_Obj_Dirs, Allow_Invalid_External => Allow_Invalid_External, Missing_Source_Files => Missing_Source_Files, Ignore_Missing_With => Ignore_Missing_With, Incomplete_Withs => False); end Create_Flags; ------------ -- Length -- ------------ function Length (Table : Name_List_Table.Instance; List : Name_List_Index) return Natural is Count : Natural := 0; Tmp : Name_List_Index; begin Tmp := List; while Tmp /= No_Name_List loop Count := Count + 1; Tmp := Table.Table (Tmp).Next; end loop; return Count; end Length; ------------------ -- Debug_Output -- ------------------ procedure Debug_Output (Str : String) is begin if Current_Verbosity > Default then Set_Standard_Error; Write_Line ((1 .. Debug_Level * 2 => ' ') & Str); Set_Standard_Output; end if; end Debug_Output; ------------------ -- Debug_Indent -- ------------------ procedure Debug_Indent is begin if Current_Verbosity = High then Set_Standard_Error; Write_Str ((1 .. Debug_Level * 2 => ' ')); Set_Standard_Output; end if; end Debug_Indent; ------------------ -- Debug_Output -- ------------------ procedure Debug_Output (Str : String; Str2 : Name_Id) is begin if Current_Verbosity > Default then Debug_Indent; Set_Standard_Error; Write_Str (Str); if Str2 = No_Name then Write_Line (" <no_name>"); else Write_Line (" """ & Get_Name_String (Str2) & '"'); end if; Set_Standard_Output; end if; end Debug_Output; --------------------------- -- Debug_Increase_Indent -- --------------------------- procedure Debug_Increase_Indent (Str : String := ""; Str2 : Name_Id := No_Name) is begin if Str2 /= No_Name then Debug_Output (Str, Str2); else Debug_Output (Str); end if; Debug_Level := Debug_Level + 1; end Debug_Increase_Indent; --------------------------- -- Debug_Decrease_Indent -- --------------------------- procedure Debug_Decrease_Indent (Str : String := "") is begin if Debug_Level > 0 then Debug_Level := Debug_Level - 1; end if; if Str /= "" then Debug_Output (Str); end if; end Debug_Decrease_Indent; ---------------- -- Debug_Name -- ---------------- function Debug_Name (Tree : Project_Tree_Ref) return Name_Id is P : Project_List; begin Name_Len := 0; Add_Str_To_Name_Buffer ("Tree ["); P := Tree.Projects; while P /= null loop if P /= Tree.Projects then Add_Char_To_Name_Buffer (','); end if; Add_Str_To_Name_Buffer (Get_Name_String (P.Project.Name)); P := P.Next; end loop; Add_Char_To_Name_Buffer (']'); return Name_Find; end Debug_Name; ---------- -- Free -- ---------- procedure Free (Tree : in out Project_Tree_Appdata) is pragma Unreferenced (Tree); begin null; end Free; -------------------------------- -- For_Project_And_Aggregated -- -------------------------------- procedure For_Project_And_Aggregated (Root_Project : Project_Id; Root_Tree : Project_Tree_Ref) is Agg : Aggregated_Project_List; begin Action (Root_Project, Root_Tree); if Root_Project.Qualifier in Aggregate_Project then Agg := Root_Project.Aggregated_Projects; while Agg /= null loop For_Project_And_Aggregated (Agg.Project, Agg.Tree); Agg := Agg.Next; end loop; end if; end For_Project_And_Aggregated; ---------------------------------------- -- For_Project_And_Aggregated_Context -- ---------------------------------------- procedure For_Project_And_Aggregated_Context (Root_Project : Project_Id; Root_Tree : Project_Tree_Ref) is procedure Recursive_Process (Project : Project_Id; Tree : Project_Tree_Ref; Context : Project_Context); -- Process Project and all aggregated projects recursively ----------------------- -- Recursive_Process -- ----------------------- procedure Recursive_Process (Project : Project_Id; Tree : Project_Tree_Ref; Context : Project_Context) is Agg : Aggregated_Project_List; Ctx : Project_Context; begin Action (Project, Tree, Context); if Project.Qualifier in Aggregate_Project then Ctx := (In_Aggregate_Lib => Project.Qualifier = Aggregate_Library, From_Encapsulated_Lib => Context.From_Encapsulated_Lib or else Project.Standalone_Library = Encapsulated); Agg := Project.Aggregated_Projects; while Agg /= null loop Recursive_Process (Agg.Project, Agg.Tree, Ctx); Agg := Agg.Next; end loop; end if; end Recursive_Process; -- Start of processing for For_Project_And_Aggregated_Context begin Recursive_Process (Root_Project, Root_Tree, Project_Context'(False, False)); end For_Project_And_Aggregated_Context; ----------------------------- -- Set_Ignore_Missing_With -- ----------------------------- procedure Set_Ignore_Missing_With (Flags : in out Processing_Flags; Value : Boolean) is begin Flags.Ignore_Missing_With := Value; end Set_Ignore_Missing_With; -- Package initialization for Prj begin -- Make sure that the standard config and user project file extensions are -- compatible with canonical case file naming. Canonical_Case_File_Name (Config_Project_File_Extension); Canonical_Case_File_Name (Project_File_Extension); end Prj;
zhmu/ananas
Ada
423
ads
with Interfaces; package Aggr30 is type Data_Type is array (1 .. 4) of Interfaces.Unsigned_8; type Padding_Type is array (5 .. 4096) of Interfaces.Unsigned_8; type Rec is record Data : Data_Type; Padding : Padding_Type; end record; procedure Init; procedure Init_Volatile; private Instance : Rec; Instance_Volatile : Rec; pragma Volatile (Instance_Volatile); end Aggr30;
cborao/Ada-P2
Ada
4,245
adb
--PRÁCTICA 2: César Borao Moratinos (client_collections) with Ada.Text_IO; with Chat_Messages; with Ada.Exceptions; with Lower_Layer_UDP; with Ada.Command_Line; with Ada.Strings.Unbounded; with Ada.Unchecked_Deallocation; package body Client_Collections is package ATI renames Ada.Text_IO; package CM renames Chat_Messages; use ASU; procedure Add_Client (Collection: in out Collection_Type; EP: in LLU.End_Point_Type; Nick: in ASU.Unbounded_String; Unique: in Boolean) is Aux: Cell_A; Included: Boolean; begin Included := False; if Collection.P_First = null then Collection.P_First := new Cell'(EP, Nick, null); Collection.Total := Collection.Total + 1; Aux := Collection.P_First; Included := True; else Aux := Collection.P_First; while Aux /= null and not Included loop if ASU.To_String(Aux.Nick) = ASU.To_String(Nick) and Unique then Included := True; raise Client_Collection_Error; end if; Aux := Aux.Next; end loop; Aux := new Cell'(EP, Nick, null); Aux.Next := Collection.P_First; Collection.P_First := Aux; Collection.Total := Collection.Total + 1; end if; end Add_Client; procedure Delete_Client (Collection: in out Collection_Type; Nick: in ASU.Unbounded_String) is Aux: Cell_A := Collection.P_First; Prev: Cell_A := Aux; Found: Boolean; procedure Free is new Ada.Unchecked_Deallocation (Cell, Cell_A); begin Found := False; while Aux /= null loop if ASU.To_String(Prev.Nick) = ASU.To_String(Nick) then Collection.P_First := Collection.P_First.Next; Free(Aux); Collection.Total := Collection.Total - 1; Found := True; elsif ASU.To_String(Aux.Nick) = ASU.To_String(Nick) then Prev.Next := Aux.Next; Collection.Total := Collection.Total - 1; Free(Aux); Found := True; else Prev := Aux; Aux := Aux.Next; end if; end loop; if not Found then raise Client_Collection_Error; end if; end Delete_Client; function Search_Client (Collection: in Collection_Type; EP: in LLU.End_Point_Type) return ASU.Unbounded_String is Finder: Cell_A := Collection.P_First; Found: Boolean; Result: ASU.Unbounded_String; begin Found := False; while Finder /= null loop if LLU."="(Finder.Client_EP, EP) then Found := True; Result := Finder.Nick; end if; Finder := Finder.Next; end loop; if not Found then raise Client_Collection_Error; end if; return Result; end Search_Client; procedure Send_To_All (Collection: in Collection_Type; P_Buffer: access LLU.Buffer_Type) is Aux: Cell_A := Collection.P_First; begin while Aux /= null loop LLU.Send (Aux.Client_EP, P_Buffer); Aux := Aux.Next; end loop; end Send_To_All; procedure Divide_EP (EP_Image: in out ASU.Unbounded_String; Nick: in ASU.Unbounded_String; Add_EP: out Unbounded_String) is IP_Image: Unbounded_String; Port_Image: Unbounded_String; Position: Integer; Delimiter: String := " "; begin for I in 1..2 loop Position := ASU.Index(EP_Image, Delimiter); ASU.Tail(EP_Image, ASU.Length(EP_Image) - Position); end loop; Position := ASU.Index(EP_Image, Delimiter); IP_Image := ASU.Head (EP_Image, Position - 2); ASU.Tail(EP_Image, ASU.Length(EP_Image) - Position); Position := ASU.Index(EP_Image, Delimiter); Port_Image := ASU.Tail(EP_Image, ASU.Length(EP_Image) - Position - 1); Add_EP := IP_Image & ":" & Port_Image & " " & ASU.To_String(Nick); end Divide_EP; function Collection_Image (Collection: in Collection_Type) return String is Aux: Cell_A := Collection.P_First; EP_Image: ASU.Unbounded_String; Add_EP: Unbounded_String; Result: ASU.Unbounded_String; begin Aux := Collection.P_First; while Aux /= null loop EP_Image := ASU.To_Unbounded_String(LLU.Image(Aux.Client_EP)); Divide_EP (EP_Image, Aux.Nick, Add_EP); Result := Result & ASCII.LF & Add_EP; Aux := Aux.Next; end loop; return ASU.To_String(Result); end Collection_Image; end Client_Collections;
PThierry/ewok-kernel
Ada
1,447
ads
-- -- Copyright 2018 The wookey project team <[email protected]> -- - Ryad Benadjila -- - Arnauld Michelizza -- - Mathieu Renard -- - Philippe Thierry -- - Philippe Trebuchet -- -- Licensed under the Apache License, Version 2.0 (the "License"); -- you may not use this file except in compliance with the License. -- You may obtain a copy of the License at -- -- http://www.apache.org/licenses/LICENSE-2.0 -- -- Unless required by applicable law or agreed to in writing, software -- distributed under the License is distributed on an "AS IS" BASIS, -- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -- See the License for the specific language governing permissions and -- limitations under the License. -- -- with ewok.tasks_shared; package ewok.syscalls.cfg.gpio with spark_mode => off is procedure svc_gpio_set (caller_id : in ewok.tasks_shared.t_task_id; params : in out t_parameters; mode : in ewok.tasks_shared.t_task_mode); procedure svc_gpio_get (caller_id : in ewok.tasks_shared.t_task_id; params : in out t_parameters; mode : in ewok.tasks_shared.t_task_mode); procedure svc_gpio_unlock_exti (caller_id : in ewok.tasks_shared.t_task_id; params : in out t_parameters; mode : in ewok.tasks_shared.t_task_mode); end ewok.syscalls.cfg.gpio;
zhmu/ananas
Ada
4,206
ads
------------------------------------------------------------------------------ -- -- -- GNAT COMPILER COMPONENTS -- -- -- -- S Y S T E M . E X C E P T I O N S _ D E B U G -- -- -- -- S p e c -- -- -- -- Copyright (C) 2006-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 internal routines used as debugger helpers. -- It should be compiled without optimization to let debuggers inspect -- parameter values reliably from breakpoints on the routines. with System.Standard_Library; package System.Exceptions_Debug is pragma Preelaborate; -- To let Ada.Exceptions "with" us and let us "with" Standard_Library package SSL renames System.Standard_Library; -- To let some of the hooks below have formal parameters typed in -- accordance with what GDB expects. procedure Debug_Raise_Exception (E : SSL.Exception_Data_Ptr; Message : String); pragma Export (Ada, Debug_Raise_Exception, "__gnat_debug_raise_exception"); -- Hook called at a "raise" point for an exception E, when it is -- just about to be propagated. procedure Debug_Unhandled_Exception (E : SSL.Exception_Data_Ptr); pragma Export (Ada, Debug_Unhandled_Exception, "__gnat_unhandled_exception"); -- Hook called during the propagation process of an exception E, as soon -- as it is known to be unhandled. procedure Debug_Raise_Assert_Failure; pragma Export (Ada, Debug_Raise_Assert_Failure, "__gnat_debug_raise_assert_failure"); -- Hook called when an assertion failed. This is used by the debugger to -- intercept assertion failures, and treat them specially. procedure Local_Raise (Excep : System.Address); pragma Export (Ada, Local_Raise); -- This is a dummy routine, used only by the debugger for the purpose of -- logging local raise statements that were transformed into a direct goto -- to the handler code. The compiler in this case generates: -- -- Local_Raise (exception_data'address); -- goto Handler -- -- The argument is the address of the exception data end System.Exceptions_Debug;
aogrcs/etherscope
Ada
3,884
adb
----------------------------------------------------------------------- -- ui-texts -- Utilities to draw text strings -- Copyright (C) 2016 Stephane Carrez -- Written by Stephane Carrez ([email protected]) -- -- Licensed under the Apache License, Version 2.0 (the "License"); -- you may not use this file except in compliance with the License. -- You may obtain a copy of the License at -- -- http://www.apache.org/licenses/LICENSE-2.0 -- -- Unless required by applicable law or agreed to in writing, software -- distributed under the License is distributed on an "AS IS" BASIS, -- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -- See the License for the specific language governing permissions and -- limitations under the License. ----------------------------------------------------------------------- with Interfaces; package body UI.Texts is function Char_Width (C : in Character) return Natural is use type BMP_Fonts.BMP_Font; begin if Current_Font /= BMP_Fonts.Font12x12 then return BMP_Fonts.Char_Width (Current_Font); end if; return BMP_Fonts.Char_Width (Current_Font) - 2; end Char_Width; -- ------------------------------ -- Get the width of the string in pixels after rendering with the current font. -- ------------------------------ function Get_Width (S : in String) return Natural is W : constant Natural := Char_Width ('a'); begin return W * S'Length; end Get_Width; -- ------------------------------ -- Draw the string at the given position and using the justification so that we don't -- span more than the width. The current font, foreground and background are used -- to draw the string. -- ------------------------------ procedure Draw_String (Buffer : in HAL.Bitmap.Bitmap_Buffer'Class; Start : in Bitmapped_Drawing.Point; Width : in Natural; Msg : in String; Justify : in Justify_Type := LEFT) is X : Natural := Start.X; Y : Natural := Start.Y; Last : Natural := Start.X + Width; FG : constant Interfaces.Unsigned_32 := HAL.Bitmap.Bitmap_Color_To_Word (Buffer.Color_Mode, Foreground); BG : constant Interfaces.Unsigned_32 := HAL.Bitmap.Bitmap_Color_To_Word (Buffer.Color_Mode, Background); begin if Last > Buffer.Width then Last := Buffer.Width; end if; case Justify is when LEFT => for C of Msg loop exit when X > Last; Bitmapped_Drawing.Draw_Char (Buffer => Buffer, Start => (X, Y), Char => C, Font => Current_Font, Foreground => FG, Background => BG); X := X + Char_Width (C); end loop; when RIGHT => X := X + Width; for C of reverse Msg loop exit when X - Char_Width (C) < Start.X; X := X - Char_Width (C); Bitmapped_Drawing.Draw_Char (Buffer => Buffer, Start => (X, Y), Char => C, Font => Current_Font, Foreground => FG, Background => BG); end loop; end case; end Draw_String; end UI.Texts;
ohenley/black
Ada
3,547
adb
with Ada.IO_Exceptions, Ada.Strings, Ada.Strings.Fixed; with Black.Text_IO; package body Black.Parsing is function End_Of_Header (Item : in Header) return Boolean is begin return Ada.Strings.Unbounded.Length (Item.Current_Line) = 0; end End_Of_Header; function Get (Stream : not null access Ada.Streams.Root_Stream_Type'Class) return Header is begin return (Previous_Line => <>, Current_Line => Text_IO.Get_Line (Stream)); end Get; function Key (Item : in Header_Line) return HTTP.Header_Key is use Ada.Strings.Unbounded; begin return HTTP.Header_Key (Slice (Item.Line, 1, Item.Split_Position - 1)); end Key; function Parse (Line : in Ada.Strings.Unbounded.Unbounded_String) return Header_Line is use Ada.Strings.Unbounded; Split_Position : constant Natural := Index (Line, ": "); begin if Split_Position = 0 then raise Protocol_Error with "Can not split """ & To_String (Line) & """ in key and value."; else return (Line => Line, Split_Position => Split_Position); end if; end Parse; function Parse (Line : Ada.Strings.Unbounded.Unbounded_String) return HTTP.Statuses is use Ada.Strings.Unbounded; Head : constant String := HTTP.Version & " ### "; Compare : constant String := Slice (Line, 1, Head'Length); begin for Status in HTTP.Statuses loop if Compare = HTTP.Status_Line (Status) (1 .. Compare'Length) then return Status; end if; end loop; raise Protocol_Error with "Unexpected " & HTTP.Version & " response: " & To_String (Line); end Parse; procedure Read (Stream : not null access Ada.Streams.Root_Stream_Type'Class; From : in out Header; Item : out Header_Line) is use Ada.Strings.Unbounded; begin if End_Of_Header (From) then raise Ada.IO_Exceptions.End_Error; else From.Previous_Line := From.Current_Line; loop From.Current_Line := Text_IO.Get_Line (Stream); exit when End_Of_Header (From); if Element (From.Current_Line, 1) = ' ' then From.Previous_Line := From.Previous_Line & From.Current_Line; else exit; end if; end loop; Item := Parse (From.Previous_Line); end if; end Read; function Value (Item : in Header_Line) return String is use Ada.Strings, Ada.Strings.Fixed, Ada.Strings.Unbounded; begin return Trim (Slice (Item.Line, Item.Split_Position + 2, Length (Item.Line)), Both); end Value; function Value (Item : in Header_Line) return Ada.Strings.Unbounded.Unbounded_String is use Ada.Strings, Ada.Strings.Unbounded; begin return Trim (Unbounded_Slice (Item.Line, Item.Split_Position + 2, Length (Item.Line)), Both); end Value; function Value (Item : in Header_Line) return Integer is begin return Integer'Value (Item.Value); end Value; function Value (Item : in Header_Line) return Boolean is begin return Boolean'Value (Item.Value); end Value; function Value (Item : in Header_Line) return Duration is begin return Duration'Value (Item.Value); end Value; end Black.Parsing;
jrmarino/AdaBase
Ada
486
ads
-- This file is covered by the Internet Software Consortium (ISC) License -- Reference: ../../License.txt package AdaBase.Logger.Base.Screen is type Screen_Logger is new Base_Logger and AIL.iLogger with private; type Screen_Logger_access is access all Screen_Logger; overriding procedure reaction (listener : Screen_Logger); private type Screen_Logger is new Base_Logger and AIL.iLogger with record null; end record; end AdaBase.Logger.Base.Screen;
persan/A-gst
Ada
14,477
ads
pragma Ada_2005; pragma Style_Checks (Off); pragma Warnings (Off); with Interfaces.C; use Interfaces.C; with GStreamer.GST_Low_Level.gstreamer_0_10_gst_rtsp_gstrtspdefs_h; with glib; with glib.Values; with System; with GLIB; -- with GStreamer.GST_Low_Level.glibconfig_h; -- limited with GStreamer.GST_Low_Level.glib_2_0_glib_garray_h; with System; -- limited with GStreamer.GST_Low_Level.glib_2_0_glib_gstring_h; package GStreamer.GST_Low_Level.gstreamer_0_10_gst_rtsp_gstrtspmessage_h is -- GStreamer -- * Copyright (C) <2005,2006> Wim Taymans <[email protected]> -- * -- * This library is free software; you can redistribute it and/or -- * modify it under the terms of the GNU Library General Public -- * License as published by the Free Software Foundation; either -- * version 2 of the License, or (at your option) any later version. -- * -- * This library is distributed in the hope that it will be useful, -- * but WITHOUT ANY WARRANTY; without even the implied warranty of -- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -- * Library General Public License for more details. -- * -- * You should have received a copy of the GNU Library General Public -- * License along with this library; if not, write to the -- * Free Software Foundation, Inc., 59 Temple Place - Suite 330, -- * Boston, MA 02111-1307, USA. -- -- * Unless otherwise indicated, Source Code is licensed under MIT license. -- * See further explanation attached in License Statement (distributed in the file -- * LICENSE). -- * -- * 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. -- --* -- * GstRTSPMsgType: -- * @GST_RTSP_MESSAGE_INVALID: invalid message type -- * @GST_RTSP_MESSAGE_REQUEST: RTSP request message -- * @GST_RTSP_MESSAGE_RESPONSE: RTSP response message -- * @GST_RTSP_MESSAGE_HTTP_REQUEST: HTTP request message. Since 0.10.25 -- * @GST_RTSP_MESSAGE_HTTP_RESPONSE: HTTP response message. Since 0.10.25 -- * @GST_RTSP_MESSAGE_DATA: data message -- * -- * The type of a message. -- type GstRTSPMsgType is (GST_RTSP_MESSAGE_INVALID, GST_RTSP_MESSAGE_REQUEST, GST_RTSP_MESSAGE_RESPONSE, GST_RTSP_MESSAGE_HTTP_REQUEST, GST_RTSP_MESSAGE_HTTP_RESPONSE, GST_RTSP_MESSAGE_DATA); pragma Convention (C, GstRTSPMsgType); -- gst/rtsp/gstrtspmessage.h:71 type GstRTSPMessage; type anon_410; type anon_411 is record method : aliased GStreamer.GST_Low_Level.gstreamer_0_10_gst_rtsp_gstrtspdefs_h.GstRTSPMethod; -- gst/rtsp/gstrtspmessage.h:88 uri : access GLIB.gchar; -- gst/rtsp/gstrtspmessage.h:89 version : aliased GStreamer.GST_Low_Level.gstreamer_0_10_gst_rtsp_gstrtspdefs_h.GstRTSPVersion; -- gst/rtsp/gstrtspmessage.h:90 end record; pragma Convention (C_Pass_By_Copy, anon_411); type anon_412 is record code : aliased GStreamer.GST_Low_Level.gstreamer_0_10_gst_rtsp_gstrtspdefs_h.GstRTSPStatusCode; -- gst/rtsp/gstrtspmessage.h:93 reason : access GLIB.gchar; -- gst/rtsp/gstrtspmessage.h:94 version : aliased GStreamer.GST_Low_Level.gstreamer_0_10_gst_rtsp_gstrtspdefs_h.GstRTSPVersion; -- gst/rtsp/gstrtspmessage.h:95 end record; pragma Convention (C_Pass_By_Copy, anon_412); type anon_413 is record channel : aliased GLIB.guint8; -- gst/rtsp/gstrtspmessage.h:98 end record; pragma Convention (C_Pass_By_Copy, anon_413); type anon_410 (discr : unsigned := 0) is record case discr is when 0 => request : aliased anon_411; -- gst/rtsp/gstrtspmessage.h:91 when 1 => response : aliased anon_412; -- gst/rtsp/gstrtspmessage.h:96 when others => data : aliased anon_413; -- gst/rtsp/gstrtspmessage.h:99 end case; end record; pragma Convention (C_Pass_By_Copy, anon_410); pragma Unchecked_Union (anon_410);--subtype GstRTSPMessage is u_GstRTSPMessage; -- gst/rtsp/gstrtspmessage.h:73 --* -- * GstRTSPMessage: -- * @type: the message type -- * -- * An RTSP message containing request, response or data messages. Depending on -- * the @type, the appropriate structure may be accessed. -- type GstRTSPMessage is record c_type : aliased GstRTSPMsgType; -- gst/rtsp/gstrtspmessage.h:84 type_data : aliased anon_410; -- gst/rtsp/gstrtspmessage.h:100 hdr_fields : System.Address; -- access GStreamer.GST_Low_Level.glib_2_0_glib_garray_h.GArray -- gst/rtsp/gstrtspmessage.h:103 c_body : access GLIB.guint8; -- gst/rtsp/gstrtspmessage.h:105 body_size : aliased GLIB.guint; -- gst/rtsp/gstrtspmessage.h:106 end record; pragma Convention (C_Pass_By_Copy, GstRTSPMessage); -- gst/rtsp/gstrtspmessage.h:82 --< private > -- memory management function gst_rtsp_message_new (msg : System.Address) return GStreamer.GST_Low_Level.gstreamer_0_10_gst_rtsp_gstrtspdefs_h.GstRTSPResult; -- gst/rtsp/gstrtspmessage.h:110 pragma Import (C, gst_rtsp_message_new, "gst_rtsp_message_new"); function gst_rtsp_message_init (msg : access GstRTSPMessage) return GStreamer.GST_Low_Level.gstreamer_0_10_gst_rtsp_gstrtspdefs_h.GstRTSPResult; -- gst/rtsp/gstrtspmessage.h:111 pragma Import (C, gst_rtsp_message_init, "gst_rtsp_message_init"); function gst_rtsp_message_unset (msg : access GstRTSPMessage) return GStreamer.GST_Low_Level.gstreamer_0_10_gst_rtsp_gstrtspdefs_h.GstRTSPResult; -- gst/rtsp/gstrtspmessage.h:112 pragma Import (C, gst_rtsp_message_unset, "gst_rtsp_message_unset"); function gst_rtsp_message_free (msg : access GstRTSPMessage) return GStreamer.GST_Low_Level.gstreamer_0_10_gst_rtsp_gstrtspdefs_h.GstRTSPResult; -- gst/rtsp/gstrtspmessage.h:113 pragma Import (C, gst_rtsp_message_free, "gst_rtsp_message_free"); function gst_rtsp_message_get_type (msg : access GstRTSPMessage) return GstRTSPMsgType; -- gst/rtsp/gstrtspmessage.h:115 pragma Import (C, gst_rtsp_message_get_type, "gst_rtsp_message_get_type"); -- request function gst_rtsp_message_new_request (msg : System.Address; method : GStreamer.GST_Low_Level.gstreamer_0_10_gst_rtsp_gstrtspdefs_h.GstRTSPMethod; uri : access GLIB.gchar) return GStreamer.GST_Low_Level.gstreamer_0_10_gst_rtsp_gstrtspdefs_h.GstRTSPResult; -- gst/rtsp/gstrtspmessage.h:118 pragma Import (C, gst_rtsp_message_new_request, "gst_rtsp_message_new_request"); function gst_rtsp_message_init_request (msg : access GstRTSPMessage; method : GStreamer.GST_Low_Level.gstreamer_0_10_gst_rtsp_gstrtspdefs_h.GstRTSPMethod; uri : access GLIB.gchar) return GStreamer.GST_Low_Level.gstreamer_0_10_gst_rtsp_gstrtspdefs_h.GstRTSPResult; -- gst/rtsp/gstrtspmessage.h:121 pragma Import (C, gst_rtsp_message_init_request, "gst_rtsp_message_init_request"); function gst_rtsp_message_parse_request (msg : access GstRTSPMessage; method : access GStreamer.GST_Low_Level.gstreamer_0_10_gst_rtsp_gstrtspdefs_h.GstRTSPMethod; uri : System.Address; version : access GStreamer.GST_Low_Level.gstreamer_0_10_gst_rtsp_gstrtspdefs_h.GstRTSPVersion) return GStreamer.GST_Low_Level.gstreamer_0_10_gst_rtsp_gstrtspdefs_h.GstRTSPResult; -- gst/rtsp/gstrtspmessage.h:124 pragma Import (C, gst_rtsp_message_parse_request, "gst_rtsp_message_parse_request"); -- response function gst_rtsp_message_new_response (msg : System.Address; code : GStreamer.GST_Low_Level.gstreamer_0_10_gst_rtsp_gstrtspdefs_h.GstRTSPStatusCode; reason : access GLIB.gchar; request : access constant GstRTSPMessage) return GStreamer.GST_Low_Level.gstreamer_0_10_gst_rtsp_gstrtspdefs_h.GstRTSPResult; -- gst/rtsp/gstrtspmessage.h:130 pragma Import (C, gst_rtsp_message_new_response, "gst_rtsp_message_new_response"); function gst_rtsp_message_init_response (msg : access GstRTSPMessage; code : GStreamer.GST_Low_Level.gstreamer_0_10_gst_rtsp_gstrtspdefs_h.GstRTSPStatusCode; reason : access GLIB.gchar; request : access constant GstRTSPMessage) return GStreamer.GST_Low_Level.gstreamer_0_10_gst_rtsp_gstrtspdefs_h.GstRTSPResult; -- gst/rtsp/gstrtspmessage.h:134 pragma Import (C, gst_rtsp_message_init_response, "gst_rtsp_message_init_response"); function gst_rtsp_message_parse_response (msg : access GstRTSPMessage; code : access GStreamer.GST_Low_Level.gstreamer_0_10_gst_rtsp_gstrtspdefs_h.GstRTSPStatusCode; reason : System.Address; version : access GStreamer.GST_Low_Level.gstreamer_0_10_gst_rtsp_gstrtspdefs_h.GstRTSPVersion) return GStreamer.GST_Low_Level.gstreamer_0_10_gst_rtsp_gstrtspdefs_h.GstRTSPResult; -- gst/rtsp/gstrtspmessage.h:138 pragma Import (C, gst_rtsp_message_parse_response, "gst_rtsp_message_parse_response"); -- data function gst_rtsp_message_new_data (msg : System.Address; channel : GLIB.guint8) return GStreamer.GST_Low_Level.gstreamer_0_10_gst_rtsp_gstrtspdefs_h.GstRTSPResult; -- gst/rtsp/gstrtspmessage.h:144 pragma Import (C, gst_rtsp_message_new_data, "gst_rtsp_message_new_data"); function gst_rtsp_message_init_data (msg : access GstRTSPMessage; channel : GLIB.guint8) return GStreamer.GST_Low_Level.gstreamer_0_10_gst_rtsp_gstrtspdefs_h.GstRTSPResult; -- gst/rtsp/gstrtspmessage.h:146 pragma Import (C, gst_rtsp_message_init_data, "gst_rtsp_message_init_data"); function gst_rtsp_message_parse_data (msg : access GstRTSPMessage; channel : access GLIB.guint8) return GStreamer.GST_Low_Level.gstreamer_0_10_gst_rtsp_gstrtspdefs_h.GstRTSPResult; -- gst/rtsp/gstrtspmessage.h:148 pragma Import (C, gst_rtsp_message_parse_data, "gst_rtsp_message_parse_data"); -- headers function gst_rtsp_message_add_header (msg : access GstRTSPMessage; field : GStreamer.GST_Low_Level.gstreamer_0_10_gst_rtsp_gstrtspdefs_h.GstRTSPHeaderField; value : access GLIB.gchar) return GStreamer.GST_Low_Level.gstreamer_0_10_gst_rtsp_gstrtspdefs_h.GstRTSPResult; -- gst/rtsp/gstrtspmessage.h:152 pragma Import (C, gst_rtsp_message_add_header, "gst_rtsp_message_add_header"); function gst_rtsp_message_take_header (msg : access GstRTSPMessage; field : GStreamer.GST_Low_Level.gstreamer_0_10_gst_rtsp_gstrtspdefs_h.GstRTSPHeaderField; value : access GLIB.gchar) return GStreamer.GST_Low_Level.gstreamer_0_10_gst_rtsp_gstrtspdefs_h.GstRTSPResult; -- gst/rtsp/gstrtspmessage.h:155 pragma Import (C, gst_rtsp_message_take_header, "gst_rtsp_message_take_header"); function gst_rtsp_message_remove_header (msg : access GstRTSPMessage; field : GStreamer.GST_Low_Level.gstreamer_0_10_gst_rtsp_gstrtspdefs_h.GstRTSPHeaderField; indx : GLIB.gint) return GStreamer.GST_Low_Level.gstreamer_0_10_gst_rtsp_gstrtspdefs_h.GstRTSPResult; -- gst/rtsp/gstrtspmessage.h:158 pragma Import (C, gst_rtsp_message_remove_header, "gst_rtsp_message_remove_header"); function gst_rtsp_message_get_header (msg : access constant GstRTSPMessage; field : GStreamer.GST_Low_Level.gstreamer_0_10_gst_rtsp_gstrtspdefs_h.GstRTSPHeaderField; value : System.Address; indx : GLIB.gint) return GStreamer.GST_Low_Level.gstreamer_0_10_gst_rtsp_gstrtspdefs_h.GstRTSPResult; -- gst/rtsp/gstrtspmessage.h:161 pragma Import (C, gst_rtsp_message_get_header, "gst_rtsp_message_get_header"); function gst_rtsp_message_append_headers (msg : access constant GstRTSPMessage; str : access GStreamer.GST_Low_Level.glib_2_0_glib_gstring_h.GString) return GStreamer.GST_Low_Level.gstreamer_0_10_gst_rtsp_gstrtspdefs_h.GstRTSPResult; -- gst/rtsp/gstrtspmessage.h:165 pragma Import (C, gst_rtsp_message_append_headers, "gst_rtsp_message_append_headers"); -- handling the body function gst_rtsp_message_set_body (msg : access GstRTSPMessage; data : access GLIB.guint8; size : GLIB.guint) return GStreamer.GST_Low_Level.gstreamer_0_10_gst_rtsp_gstrtspdefs_h.GstRTSPResult; -- gst/rtsp/gstrtspmessage.h:169 pragma Import (C, gst_rtsp_message_set_body, "gst_rtsp_message_set_body"); function gst_rtsp_message_take_body (msg : access GstRTSPMessage; data : access GLIB.guint8; size : GLIB.guint) return GStreamer.GST_Low_Level.gstreamer_0_10_gst_rtsp_gstrtspdefs_h.GstRTSPResult; -- gst/rtsp/gstrtspmessage.h:172 pragma Import (C, gst_rtsp_message_take_body, "gst_rtsp_message_take_body"); function gst_rtsp_message_get_body (msg : access constant GstRTSPMessage; data : System.Address; size : access GLIB.guint) return GStreamer.GST_Low_Level.gstreamer_0_10_gst_rtsp_gstrtspdefs_h.GstRTSPResult; -- gst/rtsp/gstrtspmessage.h:175 pragma Import (C, gst_rtsp_message_get_body, "gst_rtsp_message_get_body"); function gst_rtsp_message_steal_body (msg : access GstRTSPMessage; data : System.Address; size : access GLIB.guint) return GStreamer.GST_Low_Level.gstreamer_0_10_gst_rtsp_gstrtspdefs_h.GstRTSPResult; -- gst/rtsp/gstrtspmessage.h:178 pragma Import (C, gst_rtsp_message_steal_body, "gst_rtsp_message_steal_body"); -- debug function gst_rtsp_message_dump (msg : access GstRTSPMessage) return GStreamer.GST_Low_Level.gstreamer_0_10_gst_rtsp_gstrtspdefs_h.GstRTSPResult; -- gst/rtsp/gstrtspmessage.h:183 pragma Import (C, gst_rtsp_message_dump, "gst_rtsp_message_dump"); end GStreamer.GST_Low_Level.gstreamer_0_10_gst_rtsp_gstrtspmessage_h;
vpodzime/ada-util
Ada
16,550
adb
----------------------------------------------------------------------- -- util-serialize-io-csv -- CSV Serialization Driver -- Copyright (C) 2011, 2015, 2016, 2017 Stephane Carrez -- Written by Stephane Carrez ([email protected]) -- -- Licensed under the Apache License, Version 2.0 (the "License"); -- you may not use this file except in compliance with the License. -- You may obtain a copy of the License at -- -- http://www.apache.org/licenses/LICENSE-2.0 -- -- Unless required by applicable law or agreed to in writing, software -- distributed under the License is distributed on an "AS IS" BASIS, -- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -- See the License for the specific language governing permissions and -- limitations under the License. ----------------------------------------------------------------------- with Ada.Strings.Unbounded; with Ada.Characters.Latin_1; with Ada.IO_Exceptions; with Util.Strings; with Util.Dates.ISO8601; package body Util.Serialize.IO.CSV is -- ------------------------------ -- Set the field separator. The default field separator is the comma (','). -- ------------------------------ procedure Set_Field_Separator (Stream : in out Output_Stream; Separator : in Character) is begin Stream.Separator := Separator; end Set_Field_Separator; -- ------------------------------ -- Enable or disable the double quotes by default for strings. -- ------------------------------ procedure Set_Quotes (Stream : in out Output_Stream; Enable : in Boolean) is begin Stream.Quote := Enable; end Set_Quotes; -- ------------------------------ -- Write the value as a CSV cell. Special characters are escaped using the CSV -- escape rules. -- ------------------------------ procedure Write_Cell (Stream : in out Output_Stream; Value : in String) is begin if Stream.Column > 1 then Stream.Write (Stream.Separator); end if; Stream.Column := Stream.Column + 1; if Stream.Quote then Stream.Write ('"'); end if; for I in Value'Range loop if Value (I) = '"' then Stream.Write (""""""); else Stream.Write (Value (I)); end if; end loop; if Stream.Quote then Stream.Write ('"'); end if; end Write_Cell; procedure Write_Cell (Stream : in out Output_Stream; Value : in Integer) is begin if Stream.Column > 1 then Stream.Write (Stream.Separator); end if; Stream.Column := Stream.Column + 1; Stream.Write (Util.Strings.Image (Value)); end Write_Cell; procedure Write_Cell (Stream : in out Output_Stream; Value : in Boolean) is begin if Stream.Column > 1 then Stream.Write (Stream.Separator); end if; Stream.Column := Stream.Column + 1; if Value then Stream.Write ("true"); else Stream.Write ("false"); end if; end Write_Cell; procedure Write_Cell (Stream : in out Output_Stream; Value : in Util.Beans.Objects.Object) is use Util.Beans.Objects; begin case Util.Beans.Objects.Get_Type (Value) is when TYPE_NULL => if Stream.Column > 1 then Stream.Write (Stream.Separator); end if; Stream.Column := Stream.Column + 1; if Stream.Quote then Stream.Write ("""null"""); else Stream.Write ("null"); end if; when TYPE_BOOLEAN => if Stream.Column > 1 then Stream.Write (Stream.Separator); end if; Stream.Column := Stream.Column + 1; if Util.Beans.Objects.To_Boolean (Value) then Stream.Write ("true"); else Stream.Write ("false"); end if; when TYPE_INTEGER => if Stream.Column > 1 then Stream.Write (Stream.Separator); end if; Stream.Column := Stream.Column + 1; -- Stream.Write ('"'); Stream.Write (Util.Beans.Objects.To_Long_Long_Integer (Value)); -- Stream.Write ('"'); when others => Stream.Write_Cell (Util.Beans.Objects.To_String (Value)); end case; end Write_Cell; -- ------------------------------ -- Start a new row. -- ------------------------------ procedure New_Row (Stream : in out Output_Stream) is begin while Stream.Column < Stream.Max_Columns loop Stream.Write (Stream.Separator); Stream.Column := Stream.Column + 1; end loop; Stream.Write (ASCII.CR); Stream.Write (ASCII.LF); Stream.Column := 1; Stream.Row := Stream.Row + 1; end New_Row; -- ----------------------- -- Write the attribute name/value pair. -- ----------------------- overriding procedure Write_Attribute (Stream : in out Output_Stream; Name : in String; Value : in String) is pragma Unreferenced (Name); begin Stream.Write_Cell (Value); end Write_Attribute; overriding procedure Write_Wide_Attribute (Stream : in out Output_Stream; Name : in String; Value : in Wide_Wide_String) is begin null; end Write_Wide_Attribute; overriding procedure Write_Attribute (Stream : in out Output_Stream; Name : in String; Value : in Integer) is pragma Unreferenced (Name); begin Stream.Write_Cell (Value); end Write_Attribute; overriding procedure Write_Attribute (Stream : in out Output_Stream; Name : in String; Value : in Boolean) is pragma Unreferenced (Name); begin Stream.Write_Cell (Value); end Write_Attribute; overriding procedure Write_Attribute (Stream : in out Output_Stream; Name : in String; Value : in Util.Beans.Objects.Object) is pragma Unreferenced (Name); begin Stream.Write_Cell (Value); end Write_Attribute; procedure Write_Entity (Stream : in out Output_Stream; Name : in String; Value : in Util.Beans.Objects.Object) is pragma Unreferenced (Name); begin Stream.Write_Cell (Value); end Write_Entity; -- ----------------------- -- Write the entity value. -- ----------------------- overriding procedure Write_Entity (Stream : in out Output_Stream; Name : in String; Value : in String) is pragma Unreferenced (Name); begin Stream.Write_Cell (Value); end Write_Entity; overriding procedure Write_Wide_Entity (Stream : in out Output_Stream; Name : in String; Value : in Wide_Wide_String) is begin null; end Write_Wide_Entity; overriding procedure Write_Entity (Stream : in out Output_Stream; Name : in String; Value : in Boolean) is pragma Unreferenced (Name); begin Stream.Write_Cell (Value); end Write_Entity; overriding procedure Write_Entity (Stream : in out Output_Stream; Name : in String; Value : in Integer) is pragma Unreferenced (Name); begin Stream.Write_Cell (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; overriding procedure Write_Long_Entity (Stream : in out Output_Stream; Name : in String; Value : in Long_Long_Integer) is begin null; 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; -- ------------------------------ -- Get the header name for the given column. -- If there was no header line, build a default header for the column. -- ------------------------------ function Get_Header_Name (Handler : in Parser; Column : in Column_Type) return String is use type Ada.Containers.Count_Type; Default_Header : constant String := "ABCDEFGHIJKLMNOPQRSTUVWXYZ"; Result : String (1 .. 10); N, R : Natural; Pos : Positive := Result'Last; begin if Handler.Headers.Length >= Ada.Containers.Count_Type (Column) then return Handler.Headers.Element (Positive (Column)); end if; N := Natural (Column - 1); loop R := N mod 26; N := N / 26; Result (Pos) := Default_Header (R + 1); exit when N = 0; Pos := Pos - 1; end loop; return Result (Pos .. Result'Last); end Get_Header_Name; -- ------------------------------ -- Set the cell value at the given row and column. -- The default implementation finds the column header name and -- invokes <b>Write_Entity</b> with the header name and the value. -- ------------------------------ procedure Set_Cell (Handler : in out Parser; Value : in String; Row : in Row_Type; Column : in Column_Type) is use Ada.Containers; begin if Row = 0 then -- Build the headers table. declare Missing : constant Integer := Integer (Column) - Integer (Handler.Headers.Length); begin if Missing > 0 then Handler.Headers.Set_Length (Handler.Headers.Length + Count_Type (Missing)); end if; Handler.Headers.Replace_Element (Positive (Column), Value); end; else declare Name : constant String := Handler.Get_Header_Name (Column); begin -- Detect a new row. Close the current object and start a new one. if Handler.Row /= Row then if Row > 1 then Handler.Sink.Finish_Object ("", Handler); else Handler.Sink.Start_Array ("", Handler); end if; Handler.Sink.Start_Object ("", Handler); end if; Handler.Row := Row; Handler.Sink.Set_Member (Name, Util.Beans.Objects.To_Object (Value), Handler); end; end if; end Set_Cell; -- ------------------------------ -- Set the field separator. The default field separator is the comma (','). -- ------------------------------ procedure Set_Field_Separator (Handler : in out Parser; Separator : in Character) is begin Handler.Separator := Separator; end Set_Field_Separator; -- ------------------------------ -- Get the field separator. -- ------------------------------ function Get_Field_Separator (Handler : in Parser) return Character is begin return Handler.Separator; end Get_Field_Separator; -- ------------------------------ -- Set the comment separator. When a comment separator is defined, a line which starts -- with the comment separator will be ignored. The row number will not be incremented. -- ------------------------------ procedure Set_Comment_Separator (Handler : in out Parser; Separator : in Character) is begin Handler.Comment := Separator; end Set_Comment_Separator; -- ------------------------------ -- Get the comment separator. Returns ASCII.NUL if comments are not supported. -- ------------------------------ function Get_Comment_Separator (Handler : in Parser) return Character is begin return Handler.Comment; end Get_Comment_Separator; -- ------------------------------ -- Setup the CSV parser and mapper to use the default column header names. -- When activated, the first row is assumed to contain the first item to de-serialize. -- ------------------------------ procedure Set_Default_Headers (Handler : in out Parser; Mode : in Boolean := True) is begin Handler.Use_Default_Headers := Mode; end Set_Default_Headers; -- ------------------------------ -- Parse the stream using the CSV parser. -- Call <b>Set_Cell</b> for each cell that has been parsed indicating the row and -- column numbers as well as the cell value. -- ------------------------------ overriding procedure Parse (Handler : in out Parser; Stream : in out Util.Streams.Buffered.Buffered_Stream'Class; Sink : in out Reader'Class) is use Ada.Strings.Unbounded; C : Character; Token : Unbounded_String; Column : Column_Type := 1; Row : Row_Type := 0; In_Quote_Token : Boolean := False; In_Escape : Boolean := False; Ignore_Row : Boolean := False; begin if Handler.Use_Default_Headers then Row := 1; end if; Handler.Headers.Clear; Handler.Sink := Sink'Unchecked_Access; loop Stream.Read (Char => C); if C = Ada.Characters.Latin_1.CR or C = Ada.Characters.Latin_1.LF then if C = Ada.Characters.Latin_1.LF then Handler.Line_Number := Handler.Line_Number + 1; end if; if not Ignore_Row then if In_Quote_Token and not In_Escape then Append (Token, C); elsif Column > 1 or else Length (Token) > 0 then Parser'Class (Handler).Set_Cell (To_String (Token), Row, Column); Set_Unbounded_String (Token, ""); Row := Row + 1; Column := 1; In_Quote_Token := False; In_Escape := False; end if; else Ignore_Row := False; end if; elsif C = Handler.Separator and not Ignore_Row then if In_Quote_Token and not In_Escape then Append (Token, C); else Parser'Class (Handler).Set_Cell (To_String (Token), Row, Column); Set_Unbounded_String (Token, ""); Column := Column + 1; In_Quote_Token := False; In_Escape := False; end if; elsif C = '"' and not Ignore_Row then if In_Quote_Token then In_Escape := True; elsif In_Escape then Append (Token, C); In_Escape := False; elsif Ada.Strings.Unbounded.Length (Token) = 0 then In_Quote_Token := True; else Append (Token, C); end if; elsif C = Handler.Comment and Handler.Comment /= ASCII.NUL and Column = 1 and Length (Token) = 0 then Ignore_Row := True; elsif not Ignore_Row then Append (Token, C); In_Escape := False; end if; end loop; exception when Ada.IO_Exceptions.Data_Error => Parser'Class (Handler).Set_Cell (To_String (Token), Row, Column); Handler.Sink := null; return; end Parse; -- ------------------------------ -- Get the current location (file and line) to report an error message. -- ------------------------------ overriding function Get_Location (Handler : in Parser) return String is begin return Util.Strings.Image (Handler.Line_Number); end Get_Location; end Util.Serialize.IO.CSV;
reznikmm/matreshka
Ada
3,710
ads
------------------------------------------------------------------------------ -- -- -- Matreshka Project -- -- -- -- XML Processor -- -- -- -- 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.DOM_Nodes; package XML.DOM.Nodes.Elements.Internals is pragma Preelaborate; function Create (Node : Matreshka.DOM_Nodes.Element_Access) return XML.DOM.Nodes.Elements.DOM_Element; function Wrap (Node : Matreshka.DOM_Nodes.Element_Access) return XML.DOM.Nodes.Elements.DOM_Element; end XML.DOM.Nodes.Elements.Internals;
AdaCore/training_material
Ada
624
adb
package body Solar_System.Graphics is procedure Draw_Body(Object : Body_T; Canvas : Canvas_ID) is begin if Object.Visible then Draw_Sphere(Canvas => Canvas, Position => (Object.X, Object.Y, 0.0), Radius => Object.Radius, Color => Object.Color); end if; end Draw_Body; procedure Draw_All (Bodies : Bodies_Array_T; Canvas : Canvas_ID) is begin for Obj of Bodies loop if Obj.Visible then Draw_Body(Obj, Canvas); end if; end loop; end Draw_All; end Solar_System.Graphics;
zhmu/ananas
Ada
293
adb
package body Generic_Inst7_Pkg is use type Generic_Inst7_Types.Index; procedure Process (List : in out Generic_Inst7_Types.List) is begin for I in Generic_Inst7_Types.Index range 1 .. List.Arr'length loop null; end loop; end Process; end Generic_Inst7_Pkg;
onox/orka
Ada
3,229
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.SIMD.AVX2.Longs.Shift is pragma Pure; function Shift_Bits_Left_Zeros (Elements : m256l; Bits : m128l) return m256l with Import, Convention => Intrinsic, External_Name => "__builtin_ia32_psllq256"; -- Shift each element to the left by the given amount of bits from the -- first Double of the Bits register function Shift_Bits_Right_Zeros (Elements : m256l; Bits : m128l) return m256l with Import, Convention => Intrinsic, External_Name => "__builtin_ia32_psrlq256"; -- Shift each element to the right by the given amount of bits from the -- first Double of the Bits register, shifting in zeros ---------------------------------------------------------------------------- function Shift_Bits_Left_Zeros (Elements, Bits : m256l) return m256l with Import, Convention => Intrinsic, External_Name => "__builtin_ia32_psllv4di"; -- Shift each element to the right by the given amount of bits from the -- corresponding element in Bits, shifting in zero bits -- -- If the element in Bits is > 31, then the elements will be 0. function Shift_Bits_Right_Zeros (Elements, Bits : m256l) return m256l with Import, Convention => Intrinsic, External_Name => "__builtin_ia32_psrlv4di"; -- Shift each element to the right by the given amount of bits from the -- corresponding element in Bits, shifting in zero bits -- -- If the element in Bits is > 31, then the elements will be 0. ---------------------------------------------------------------------------- type Bits_Count is new Integer range 1 .. 64; function Shift_Bits_Left_Zeros (Elements : m256l; Bits : Bits_Count) return m256l with Import, Convention => Intrinsic, External_Name => "__builtin_ia32_psllqi256"; -- Shift each element to the left by the given amount of bits, shifting in zeros function Shift_Bits_Right_Zeros (Elements : m256l; Bits : Bits_Count) return m256l with Import, Convention => Intrinsic, External_Name => "__builtin_ia32_psrlqi256"; -- Shift each element to the right by the given amount of bits, shifting in zeros ---------------------------------------------------------------------------- function Shift_Elements_Left_Zeros (Elements : m256l) return m256l with Inline_Always; -- Shift each element to the left by one element, shifting in zeros function Shift_Elements_Right_Zeros (Elements : m256l) return m256l with Inline_Always; -- Shift each element to the right by one element, shifting in zeros end Orka.SIMD.AVX2.Longs.Shift;
NCommander/dnscatcher
Ada
20,050
adb
-- Copyright 2019 Michael Casadevall <[email protected]> -- -- Permission is hereby granted, free of charge, to any person obtaining a copy -- of this software and associated documentation files (the "Software"), to -- deal in the Software without restriction, including without limitation the -- rights to use, copy, modify, merge, publish, distribute, sublicense, and/or -- sell copies of the Software, and to permit persons to whom the Software is -- furnished to do so, subject to the following conditions: -- -- The above copyright notice and this permission notice shall be included in -- all copies or substantial portions of the Software. -- -- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL -- THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -- FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER -- DEALINGS IN THE SOFTWARE. pragma Ada_2012; with Ada.Text_IO; use Ada.Text_IO; with AUnit.Assertions; with Ada.Directories; use Ada.Directories; with Ada.Streams; use Ada.Streams; with Ada.Streams.Stream_IO; use Ada.Streams.Stream_IO; with Ada.Strings.Unbounded; use Ada.Strings.Unbounded; with Ada.Unchecked_Conversion; with DNSCatcher.DNS; use DNSCatcher.DNS; with DNSCatcher.Types; use DNSCatcher.Types; with DNSCatcher.Utils; use DNSCatcher.Utils; with DNSCatcher.DNS.Processor.Packet; use DNSCatcher.DNS.Processor.Packet; with DNSCatcher.DNS.Processor.RData; use DNSCatcher.DNS.Processor.RData; with DNSCatcher.DNS.Processor.RData.SOA_Parser; use DNSCatcher.DNS.Processor.RData.SOA_Parser; with Interfaces.C.Extensions; use Interfaces.C.Extensions; package body Test_Packet_Parser is procedure Set_Up_Case (T : in out Packet_Parser_Test) is begin T.Capture_Config.Local_Listen_Port := 53; T.Capture_Config.Upstream_DNS_Server := To_Unbounded_String ("4.2.2.2"); T.Capture_Config.Upstream_DNS_Server_Port := 53; -- Configure the logger T.Capture_Config.Logger_Config.Log_Level := DEBUG; T.Capture_Config.Logger_Config.Use_Color := True; T.Logger_Task.Initialize (T.Capture_Config.Logger_Config); T.Logger_Task.Start; end Set_Up_Case; procedure Tear_Down_Case (T : in out Packet_Parser_Test) is begin T.Logger_Task.Stop; end Tear_Down_Case; -------------------- -- Register_Tests -- -------------------- procedure Register_Tests (T : in out Packet_Parser_Test) is use AUnit.Test_Cases.Registration; begin Register_Routine (T, Test_Parse_A_Record'Access, "Parse A Record"); Register_Routine (T, Test_Parse_SOA_Record'Access, "Parse SOA Record"); Register_Routine (T, Test_Parse_CNAME_Record'Access, "Parse CName Record"); Register_Routine (T, Test_Parse_NS_Record'Access, "Parse NS Record"); Register_Routine (T, Test_Parse_PTR_Record'Access, "Parse PTR Record"); Register_Routine (T, Test_Parse_OPT_Record'Access, "Parse OPT Record"); end Register_Tests; ---------- -- Name -- ---------- pragma Warnings (Off, "formal parameter ""T"" is not referenced"); function Name (T : Packet_Parser_Test) return Message_String is begin return Format ("Packet Parser Test"); end Name; --------------------- -- Test_Simple_Add -- --------------------- function Load_Binary_DNS_Dump (File : String) return Raw_Packet_Record_Ptr is Input_File : Stream_IO.File_Type; Input_Stream : Stream_Access; Packet_Size : Stream_Element_Offset; Read_Packet : Stream_Element_Offset; Full_Packet : Stream_Element_Array_Ptr; Inbound_Packet : constant Raw_Packet_Record_Ptr := new Raw_Packet_Record; begin Ada.Streams.Stream_IO.Open (Input_File, In_File, File); -- We need to load and convert the header seperately because Ada sizing -- doesn't account for Pack correct. Input_Stream := Ada.Streams.Stream_IO.Stream (Input_File); -- Load in the A record and try to parse it Packet_Size := Stream_Element_Offset (Size (File)); Full_Packet := new Stream_Element_Array (1 .. Packet_Size); Input_Stream.Read (Full_Packet.all, Read_Packet); Inbound_Packet.Raw_Data.Header := SEA_To_DNS_Packet_Header (Full_Packet (Full_Packet'First .. DNS_PACKET_HEADER_SIZE)); Inbound_Packet.Raw_Data.Data := new Stream_Element_Array (1 .. Packet_Size - DNS_PACKET_HEADER_SIZE); Inbound_Packet.Raw_Data.Data.all := Full_Packet (DNS_PACKET_HEADER_SIZE + 1 .. Packet_Size); Free_Stream_Element_Array_Ptr (Full_Packet); Close (Input_File); return Inbound_Packet; end Load_Binary_DNS_Dump; procedure Test_Parse_A_Record (T : in out Test_Cases.Test_Case'Class) is Logger_Packet : DNSCatcher.Utils.Logger.Logger_Message_Packet_Ptr; Parsed_Packet : Parsed_DNS_Packet_Ptr; Inbound_Packet : Raw_Packet_Record_Ptr := new Raw_Packet_Record; Question : Parsed_DNS_Question; Answer : Parsed_RData_Access; begin Logger_Packet := new Logger_Message_Packet; Inbound_Packet := Load_Binary_DNS_Dump ("./tests/data/udp_a_record.bin"); Parsed_Packet := Packet_Parser (Logger_Packet, Inbound_Packet); Logger_Queue.Add_Packet (Logger_Packet); -- Verify the data we got from the packet matches what we expect AUnit.Assertions.Assert ((Integer (Parsed_Packet.Header.Question_Count) = Integer (Parsed_Packet.Questions.Length)), "Question Count Mismatch!"); -- Verify the question section Question := Parsed_Packet.Questions (1); AUnit.Assertions.Assert (To_String (Question.QName), "apple.com", "Incorrect QNAME on decode!"); AUnit.Assertions.Assert ((Question.QType = DNSCatcher.DNS.A), "Incorrect QTYPE on decode!"); AUnit.Assertions.Assert ((Question.QClass = DNSCatcher.DNS.INternet), "Incorrect QCLASS on decode!"); -- Verify the response section AUnit.Assertions.Assert ((Integer (Parsed_Packet.Header.Answer_Record_Count) = Integer (Parsed_Packet.Answer.Length)), "Answer Count Mismatch!"); Answer := Parsed_Packet.Answer.Element (1); AUnit.Assertions.Assert (To_String (Answer.RName), "apple.com", "Incorrect RName!"); AUnit.Assertions.Assert ((Answer.RType = DNSCatcher.DNS.A), "Incorrect RName!"); AUnit.Assertions.Assert ((Answer.TTL = 3190), "Incorrect TTL!"); AUnit.Assertions.Assert (Answer.RData_To_String, "17.172.224.47", "RData is incorrect"); Answer := Parsed_Packet.Answer.Element (2); AUnit.Assertions.Assert (To_String (Answer.RName), "apple.com", "Incorrect RName!"); AUnit.Assertions.Assert ((Answer.RType = DNSCatcher.DNS.A), "Incorrect RName!"); AUnit.Assertions.Assert ((Answer.TTL = 3190), "Incorrect TTL!"); AUnit.Assertions.Assert (Answer.RData_To_String, "17.178.96.59", "RData is incorrect"); Answer := Parsed_Packet.Answer.Element (3); AUnit.Assertions.Assert (To_String (Answer.RName), "apple.com", "Incorrect RName!"); AUnit.Assertions.Assert ((Answer.RType = DNSCatcher.DNS.A), "Incorrect RName!"); AUnit.Assertions.Assert ((Answer.TTL = 3190), "Incorrect TTL!"); AUnit.Assertions.Assert (Answer.RData_To_String, "17.142.160.59", "RData is incorrect"); Free_Raw_Packet_Record_Ptr (Inbound_Packet); Free_Parsed_DNS_Packet (Parsed_Packet); end Test_Parse_A_Record; -- Tests if we can parse an SOA record procedure Test_Parse_SOA_Record (T : in out Test_Cases.Test_Case'Class) is Logger_Packet : DNSCatcher.Utils.Logger.Logger_Message_Packet_Ptr; Parsed_Packet : Parsed_DNS_Packet_Ptr; Inbound_Packet : Raw_Packet_Record_Ptr := new Raw_Packet_Record; Question : Parsed_DNS_Question; Answer : Parsed_RData_Access; SOA_Record : Parsed_SOA_RData_Access; function To_Parsed_SOA_RData is new Ada.Unchecked_Conversion (Source => Parsed_RData_Access, Target => Parsed_SOA_RData_Access); begin Logger_Packet := new Logger_Message_Packet; Inbound_Packet := Load_Binary_DNS_Dump ("./tests/data/udp_soa_record.bin"); Parsed_Packet := Packet_Parser (Logger_Packet, Inbound_Packet); Logger_Queue.Add_Packet (Logger_Packet); -- Verify the question section Question := Parsed_Packet.Questions (1); AUnit.Assertions.Assert (To_String (Question.QName), "casadevall.pro", "Incorrect QNAME on decode!"); AUnit.Assertions.Assert ((Question.QType = DNSCatcher.DNS.SOA), "Incorrect QTYPE on decode!"); AUnit.Assertions.Assert ((Question.QClass = DNSCatcher.DNS.INternet), "Incorrect QCLASS on decode!"); -- Verify the response section AUnit.Assertions.Assert ((Integer (Parsed_Packet.Header.Answer_Record_Count) = Integer (Parsed_Packet.Answer.Length)), "Answer Count Mismatch!"); Answer := Parsed_Packet.Answer.Element (1); SOA_Record := To_Parsed_SOA_RData (Answer); AUnit.Assertions.Assert (To_String (SOA_Record.Primary_Nameserver), "ns1.casadevall.pro", "Incorrect decode on primary nameserver"); AUnit.Assertions.Assert (To_String (SOA_Record.Responsible_Contact), "casadevall.pro", "Incorrect decode on responsible contact"); AUnit.Assertions.Assert ((Integer (SOA_Record.Serial) = 2018082638), "Incorrect Serial"); AUnit.Assertions.Assert ((Integer (SOA_Record.Refresh) = 300), "Incorrect Refresh"); AUnit.Assertions.Assert ((Integer (SOA_Record.Retry) = 14400), "Incorrect Refresh"); AUnit.Assertions.Assert ((Integer (SOA_Record.Expire) = 2419200), "Incorrect Expire"); AUnit.Assertions.Assert ((Integer (SOA_Record.Minimum) = 1800), "Incorrect Expire"); Free_Raw_Packet_Record_Ptr (Inbound_Packet); Free_Parsed_DNS_Packet (Parsed_Packet); end Test_Parse_SOA_Record; -- Tests if we can parse an CNAME record procedure Test_Parse_CNAME_Record (T : in out Test_Cases.Test_Case'Class) is Logger_Packet : DNSCatcher.Utils.Logger.Logger_Message_Packet_Ptr; Parsed_Packet : Parsed_DNS_Packet_Ptr; Inbound_Packet : Raw_Packet_Record_Ptr := new Raw_Packet_Record; Question : Parsed_DNS_Question; Answer : Parsed_RData_Access; begin Logger_Packet := new Logger_Message_Packet; Inbound_Packet := Load_Binary_DNS_Dump ("./tests/data/udp_cname_record.bin"); Parsed_Packet := Packet_Parser (Logger_Packet, Inbound_Packet); Logger_Queue.Add_Packet (Logger_Packet); -- Verify the question section Question := Parsed_Packet.Questions (1); AUnit.Assertions.Assert (To_String (Question.QName), "mail.casadevall.pro", "Incorrect QNAME on decode!"); AUnit.Assertions.Assert ((Question.QType = DNSCatcher.DNS.CNAME), "Incorrect QTYPE on decode!"); AUnit.Assertions.Assert ((Question.QClass = DNSCatcher.DNS.INternet), "Incorrect QCLASS on decode!"); AUnit.Assertions.Assert ((Integer (Parsed_Packet.Header.Answer_Record_Count) = Integer (Parsed_Packet.Answer.Length)), "Answer Count Mismatch!"); Answer := Parsed_Packet.Answer.Element (1); AUnit.Assertions.Assert (To_String (Answer.RName), "mail.casadevall.pro", "Incorrect RName!"); AUnit.Assertions.Assert ((Answer.RType = DNSCatcher.DNS.CNAME), "Incorrect RName!"); AUnit.Assertions.Assert ((Answer.TTL = 3600), "Incorrect TTL!"); AUnit.Assertions.Assert (Answer.RData_To_String, "pathfinder.casadevall.pro", "RData is incorrect"); Free_Raw_Packet_Record_Ptr (Inbound_Packet); Free_Parsed_DNS_Packet (Parsed_Packet); end Test_Parse_CNAME_Record; procedure Test_Parse_NS_Record (T : in out Test_Cases.Test_Case'Class) is Logger_Packet : DNSCatcher.Utils.Logger.Logger_Message_Packet_Ptr; Parsed_Packet : Parsed_DNS_Packet_Ptr; Inbound_Packet : Raw_Packet_Record_Ptr := new Raw_Packet_Record; Question : Parsed_DNS_Question; Answer : Parsed_RData_Access; begin Logger_Packet := new Logger_Message_Packet; Inbound_Packet := Load_Binary_DNS_Dump ("./tests/data/udp_ns_record.bin"); Parsed_Packet := Packet_Parser (Logger_Packet, Inbound_Packet); Logger_Queue.Add_Packet (Logger_Packet); -- Verify the question section Question := Parsed_Packet.Questions (1); AUnit.Assertions.Assert (To_String (Question.QName), "casadevall.pro", "Incorrect QNAME on decode!"); AUnit.Assertions.Assert ((Question.QType = DNSCatcher.DNS.NS), "Incorrect QTYPE on decode!"); AUnit.Assertions.Assert ((Question.QClass = DNSCatcher.DNS.INternet), "Incorrect QCLASS on decode!"); AUnit.Assertions.Assert ((Integer (Parsed_Packet.Header.Answer_Record_Count) = Integer (Parsed_Packet.Answer.Length)), "Answer Count Mismatch!"); Answer := Parsed_Packet.Answer.Element (1); AUnit.Assertions.Assert (To_String (Answer.RName), "casadevall.pro", "Incorrect RName!"); AUnit.Assertions.Assert ((Answer.RType = DNSCatcher.DNS.NS), "Incorrect RName!"); AUnit.Assertions.Assert ((Answer.TTL = 3600), "Incorrect TTL!"); AUnit.Assertions.Assert (Answer.RData_To_String, "ns5.linode.com", "RData is incorrect"); Answer := Parsed_Packet.Answer.Element (2); AUnit.Assertions.Assert (To_String (Answer.RName), "casadevall.pro", "Incorrect RName!"); AUnit.Assertions.Assert ((Answer.RType = DNSCatcher.DNS.NS), "Incorrect RName!"); AUnit.Assertions.Assert ((Answer.TTL = 3600), "Incorrect TTL!"); AUnit.Assertions.Assert (Answer.RData_To_String, "ns2.linode.com", "RData is incorrect"); Answer := Parsed_Packet.Answer.Element (3); AUnit.Assertions.Assert (To_String (Answer.RName), "casadevall.pro", "Incorrect RName!"); AUnit.Assertions.Assert ((Answer.RType = DNSCatcher.DNS.NS), "Incorrect RName!"); AUnit.Assertions.Assert ((Answer.TTL = 3600), "Incorrect TTL!"); AUnit.Assertions.Assert (Answer.RData_To_String, "ns1.casadevall.pro", "RData is incorrect"); Answer := Parsed_Packet.Answer.Element (4); AUnit.Assertions.Assert (To_String (Answer.RName), "casadevall.pro", "Incorrect RName!"); AUnit.Assertions.Assert ((Answer.RType = DNSCatcher.DNS.NS), "Incorrect RName!"); AUnit.Assertions.Assert ((Answer.TTL = 3600), "Incorrect TTL!"); AUnit.Assertions.Assert (Answer.RData_To_String, "ns3.linode.com", "RData is incorrect"); Answer := Parsed_Packet.Answer.Element (5); AUnit.Assertions.Assert (To_String (Answer.RName), "casadevall.pro", "Incorrect RName!"); AUnit.Assertions.Assert ((Answer.RType = DNSCatcher.DNS.NS), "Incorrect RName!"); AUnit.Assertions.Assert ((Answer.TTL = 3600), "Incorrect TTL!"); AUnit.Assertions.Assert (Answer.RData_To_String, "ns1.linode.com", "RData is incorrect"); Answer := Parsed_Packet.Answer.Element (6); AUnit.Assertions.Assert (To_String (Answer.RName), "casadevall.pro", "Incorrect RName!"); AUnit.Assertions.Assert ((Answer.RType = DNSCatcher.DNS.NS), "Incorrect RName!"); AUnit.Assertions.Assert ((Answer.TTL = 3600), "Incorrect TTL!"); AUnit.Assertions.Assert (Answer.RData_To_String, "ns4.linode.com", "RData is incorrect"); Free_Raw_Packet_Record_Ptr (Inbound_Packet); Free_Parsed_DNS_Packet (Parsed_Packet); end Test_Parse_NS_Record; -- Tests if we can parse an PTR record procedure Test_Parse_PTR_Record (T : in out Test_Cases.Test_Case'Class) is Logger_Packet : DNSCatcher.Utils.Logger.Logger_Message_Packet_Ptr; Parsed_Packet : Parsed_DNS_Packet_Ptr; Inbound_Packet : Raw_Packet_Record_Ptr := new Raw_Packet_Record; Question : Parsed_DNS_Question; Answer : Parsed_RData_Access; begin Logger_Packet := new Logger_Message_Packet; Inbound_Packet := Load_Binary_DNS_Dump ("./tests/data/udp_ptr_record.bin"); Parsed_Packet := Packet_Parser (Logger_Packet, Inbound_Packet); Logger_Queue.Add_Packet (Logger_Packet); -- Verify the question section Question := Parsed_Packet.Questions (1); AUnit.Assertions.Assert (To_String (Question.QName), "193.112.33.45.in-addr.arpa", "Incorrect QNAME on decode!"); AUnit.Assertions.Assert ((Question.QType = DNSCatcher.DNS.PTR), "Incorrect QTYPE on decode!"); AUnit.Assertions.Assert ((Question.QClass = DNSCatcher.DNS.INternet), "Incorrect QCLASS on decode!"); AUnit.Assertions.Assert ((Integer (Parsed_Packet.Header.Answer_Record_Count) = Integer (Parsed_Packet.Answer.Length)), "Answer Count Mismatch!"); Answer := Parsed_Packet.Answer.Element (1); AUnit.Assertions.Assert (To_String (Answer.RName), "193.112.33.45.in-addr.arpa", "Incorrect RName!"); AUnit.Assertions.Assert ((Answer.RType = DNSCatcher.DNS.PTR), "Incorrect RName!"); AUnit.Assertions.Assert ((Answer.TTL = 86400), "Incorrect TTL!"); AUnit.Assertions.Assert (Answer.RData_To_String, "pathfinder.casadevall.pro", "RData is incorrect"); Free_Raw_Packet_Record_Ptr (Inbound_Packet); Free_Parsed_DNS_Packet (Parsed_Packet); end Test_Parse_PTR_Record; -- Tests if we can parse an OPT record procedure Test_Parse_OPT_Record (T : in out Test_Cases.Test_Case'Class) is Logger_Packet : DNSCatcher.Utils.Logger.Logger_Message_Packet_Ptr; Parsed_Packet : Parsed_DNS_Packet_Ptr; Inbound_Packet : Raw_Packet_Record_Ptr := new Raw_Packet_Record; Question : Parsed_DNS_Question; Answer : Parsed_RData_Access; begin Logger_Packet := new Logger_Message_Packet; Inbound_Packet := Load_Binary_DNS_Dump ("./tests/data/udp_client_opt_record.bin"); Parsed_Packet := Packet_Parser (Logger_Packet, Inbound_Packet); Logger_Queue.Add_Packet (Logger_Packet); -- Verify the question section (this was a request for a DNSKEY on the -- root) Question := Parsed_Packet.Questions (1); AUnit.Assertions.Assert (To_String (Question.QName), "", "Incorrect QNAME on decode!"); AUnit.Assertions.Assert ((Question.QType = DNSCatcher.DNS.DNSKEY), "Incorrect QTYPE on decode!"); AUnit.Assertions.Assert ((Question.QClass = DNSCatcher.DNS.INternet), "Incorrect QCLASS on decode!"); Put_Line (Parsed_Packet.Header.Additional_Record_Count'Image); Put_Line (Parsed_Packet.Additional.Length'Image); AUnit.Assertions.Assert ((Integer (Parsed_Packet.Header.Additional_Record_Count) = Integer (Parsed_Packet.Additional.Length)), "Additional Count Mismatch!"); Answer := Parsed_Packet.Additional.Element (1); AUnit.Assertions.Assert (To_String (Answer.RName), "", "Incorrect RName!"); AUnit.Assertions.Assert ((Answer.RType = DNSCatcher.DNS.OPT), "Incorrect RName!"); AUnit.Assertions.Assert ((Answer.TTL = 0), "Incorrect TTL!"); Free_Raw_Packet_Record_Ptr (Inbound_Packet); Free_Parsed_DNS_Packet (Parsed_Packet); end Test_Parse_OPT_Record; end Test_Packet_Parser;
stcarrez/dynamo
Ada
16,669
adb
------------------------------------------------------------------------------ -- -- -- ASIS-for-GNAT IMPLEMENTATION COMPONENTS -- -- -- -- A S I S . D A T A _ D E C O M P O S I T I O N . E X T E N S I O N S -- -- -- -- B o d y -- -- -- -- Copyright (C) 1995-2010, Free Software Foundation, Inc. -- -- -- -- ASIS-for-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 -- -- Software Foundation; either version 2, or (at your option) any later -- -- version. ASIS-for-GNAT is distributed in the hope that it will be use- -- -- ful, but WITHOUT ANY WARRANTY; without even the implied warranty of MER- -- -- CHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General -- -- Public License for more details. You should have received a copy of the -- -- GNU General Public License distributed with ASIS-for-GNAT; see file -- -- COPYING. If not, write to the Free Software Foundation, 59 Temple Place -- -- - Suite 330, Boston, MA 02111-1307, USA. -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- ASIS-for-GNAT was originally developed by the ASIS-for-GNAT team at the -- -- Software Engineering Laboratory of the Swiss Federal Institute of -- -- Technology (LGL-EPFL) in Lausanne, Switzerland, in cooperation with the -- -- Scientific Research Computer Center of Moscow State University (SRCC -- -- MSU), Russia, with funding partially provided by grants from the Swiss -- -- National Science Foundation and the Swiss Academy of Engineering -- -- Sciences. ASIS-for-GNAT is now maintained by Ada Core Technologies Inc -- -- (http://www.gnat.com). -- -- -- ------------------------------------------------------------------------------ with Ada.Unchecked_Conversion; with System; use System; with Asis.Data_Decomposition.Vcheck; use Asis.Data_Decomposition.Vcheck; with Asis.Data_Decomposition.Set_Get; use Asis.Data_Decomposition.Set_Get; with Asis.Errors; use Asis.Errors; with Asis.Exceptions; use Asis.Exceptions; with Asis.Set_Get; use Asis.Set_Get; with A4G.DDA_Aux; use A4G.DDA_Aux; with A4G.Vcheck; use A4G.Vcheck; with Einfo; use Einfo; with Namet; use Namet; with Uintp; use Uintp; with Urealp; use Urealp; package body Asis.Data_Decomposition.Extensions is Package_Name : constant String := "Asis.Data_Decomposition.Extensions."; ----------------------- -- Local subprograms -- ----------------------- procedure Write_Real_To_Buffer (U : Ureal); -- Puts nnn/ddd to Name_Buffer, where nnn and ddd are integer values of -- the normalized numerator and denominator of the given real value. -- This procedure is supposed to be used to output images of positive -- real values only, so it assumes, that nnn is always positive. procedure Add_Uint_To_Buffer (U : Uint); -- Add image of universal integer to Name_Buffer, updating Name_Len -- (This procedure is the simplified version of the local procedure -- Exp_Dbug.Add_Uint_To_Buffer - it always consider its argument -- being positive) ------------------------ -- Add_Uint_To_Buffer -- ------------------------ procedure Add_Uint_To_Buffer (U : Uint) is begin UI_Image (U, Decimal); Add_Str_To_Name_Buffer (UI_Image_Buffer (1 .. UI_Image_Length)); end Add_Uint_To_Buffer; ------------------------------- -- Component_Name_Definition -- ------------------------------- function Component_Name_Definition (Component : Record_Component) return Asis.Declaration is Result : Asis.Element; begin Check_Validity (Component, Package_Name & "Component_Name_Definition"); if Is_Nil (Component) then Raise_ASIS_Inappropriate_Component (Diagnosis => Package_Name & "Component_Name_Definition", Component_Kind => Rec); end if; Result := Component_Name (Component); return Result; exception when ASIS_Inappropriate_Element => raise; when ASIS_Failed => if Status_Indicator = Unhandled_Exception_Error then Add_Call_Information (Outer_Call => Package_Name & "Component_Name_Definition"); end if; raise; when Ex : others => Report_ASIS_Bug (Query_Name => Package_Name & "Component_Name_Definition", Ex => Ex); end Component_Name_Definition; -------------------------- -- Delta_Value (String) -- -------------------------- function Delta_Value (Fixed_Point_Subtype : Asis.Element) return String is Arg_Node : Node_Id; Res_Ureal : Ureal; begin Check_Validity (Fixed_Point_Subtype, Package_Name & "Delta_Value (String)"); Arg_Node := R_Node (Fixed_Point_Subtype); if not (Int_Kind (Fixed_Point_Subtype) = A_Defining_Identifier and then Is_Fixed_Point_Type (Arg_Node)) then Raise_ASIS_Inappropriate_Element (Diagnosis => Package_Name & "Delta_Value (String)", Wrong_Kind => Int_Kind (Fixed_Point_Subtype)); end if; Res_Ureal := Einfo.Delta_Value (Arg_Node); Write_Real_To_Buffer (Res_Ureal); return Namet.Name_Buffer (1 .. Namet.Name_Len); exception when ASIS_Inappropriate_Element => raise; when ASIS_Failed => if Status_Indicator = Unhandled_Exception_Error then Add_Call_Information (Outer_Call => Package_Name & "Delta_Value (String)", Argument => Fixed_Point_Subtype); end if; raise; when Ex : others => Report_ASIS_Bug (Query_Name => Package_Name & "Delta_Value (String)", Ex => Ex, Arg_Element => Fixed_Point_Subtype); end Delta_Value; ---------------------------- -- Delta_Value (Fraction) -- ---------------------------- function Delta_Value (Fixed_Point_Subtype : Asis.Element) return Fraction is Arg_Node : Node_Id; Res_Ureal : Ureal; Result : Fraction; begin Check_Validity (Fixed_Point_Subtype, Package_Name & "Delta_Value (Fraction)"); Arg_Node := R_Node (Fixed_Point_Subtype); if not (Int_Kind (Fixed_Point_Subtype) = A_Defining_Identifier and then Is_Fixed_Point_Type (Arg_Node)) then Raise_ASIS_Inappropriate_Element (Diagnosis => Package_Name & "Delta_Value (Fraction)", Wrong_Kind => Int_Kind (Fixed_Point_Subtype)); end if; Res_Ureal := Einfo.Delta_Value (Arg_Node); Result.Num := UI_To_Aint (Norm_Num (Res_Ureal)); Result.Denum := UI_To_Aint (Norm_Den (Res_Ureal)); return Result; exception when ASIS_Inappropriate_Element => raise; when ASIS_Failed => if Status_Indicator = Unhandled_Exception_Error then Add_Call_Information (Outer_Call => Package_Name & "Delta_Value (Fraction)", Argument => Fixed_Point_Subtype); end if; raise; when Invalid_Data => Raise_ASIS_Inappropriate_Element (Diagnosis => Package_Name & "Delta_Value (Fraction)", Wrong_Kind => Int_Kind (Fixed_Point_Subtype), Status => Data_Error); when Ex : others => Report_ASIS_Bug (Query_Name => Package_Name & "Delta_Value (Fraction)", Ex => Ex, Arg_Element => Fixed_Point_Subtype); end Delta_Value; ------------------ -- Digits_Value -- ------------------ function Digits_Value (Floating_Point_Subtype : Asis.Element) return ASIS_Natural is Arg_Node : Node_Id; begin Check_Validity (Floating_Point_Subtype, Package_Name & "Digits_Value"); Arg_Node := R_Node (Floating_Point_Subtype); if not (Int_Kind (Floating_Point_Subtype) = A_Defining_Identifier and then (Is_Decimal_Fixed_Point_Type (Arg_Node) or else Is_Floating_Point_Type (Arg_Node))) then Raise_ASIS_Inappropriate_Element (Package_Name & "Digits_Value", Wrong_Kind => Int_Kind (Floating_Point_Subtype)); end if; return ASIS_Natural (UI_To_Int (Einfo.Digits_Value (Arg_Node))); exception when ASIS_Inappropriate_Element => raise; when ASIS_Failed => if Status_Indicator = Unhandled_Exception_Error then Add_Call_Information (Outer_Call => Package_Name & "Digits_Value", Argument => Floating_Point_Subtype); end if; raise; when Ex : others => Report_ASIS_Bug (Query_Name => Package_Name & "Digits_Value", Ex => Ex, Arg_Element => Floating_Point_Subtype); end Digits_Value; -------------------------- -- Portable_Data_Value -- -------------------------- function Portable_Data_Value (Value : Constrained_Subtype) return Portable_Data is Local_Value : aliased constant Constrained_Subtype := Value; for Local_Value'Alignment use Standard'Maximum_Alignment; -- We force the maximum alignment for Local_Value to make it -- compatible with maximum alignment set for Portable_Data -- in the spec of Asis.Data_Decomposition subtype Result_Portable_Data is Portable_Data (1 .. (Constrained_Subtype'Object_Size + 7) / 8); type Result_Portable_Data_Access is access Result_Portable_Data; function To_Result_Portable_Data_Access is new Ada.Unchecked_Conversion (Address, Result_Portable_Data_Access); Result : constant Result_Portable_Data_Access := To_Result_Portable_Data_Access (Local_Value'Address); begin return Result.all; exception when ASIS_Failed => if Status_Indicator = Unhandled_Exception_Error then Add_Call_Information (Outer_Call => Package_Name & "Portable_Data_Value"); end if; raise; when Ex : others => Report_ASIS_Bug (Query_Name => Package_Name & "Portable_Data_Value", Ex => Ex); end Portable_Data_Value; ----------------- -- Scale_Value -- ----------------- function Scale_Value (Desimal_Fixed_Point_Subtype : Asis.Element) return ASIS_Natural is Arg_Node : Node_Id; begin Check_Validity (Desimal_Fixed_Point_Subtype, Package_Name & "Scale_Value"); Arg_Node := R_Node (Desimal_Fixed_Point_Subtype); if not (Int_Kind (Desimal_Fixed_Point_Subtype) = A_Defining_Identifier and then Is_Decimal_Fixed_Point_Type (Arg_Node)) then Raise_ASIS_Inappropriate_Element (Package_Name & "Scale_Value", Wrong_Kind => Int_Kind (Desimal_Fixed_Point_Subtype)); end if; return ASIS_Natural (UI_To_Int (Einfo.Scale_Value (Arg_Node))); exception when ASIS_Inappropriate_Element => raise; when ASIS_Failed => if Status_Indicator = Unhandled_Exception_Error then Add_Call_Information (Outer_Call => Package_Name & "Scale_Value", Argument => Desimal_Fixed_Point_Subtype); end if; raise; when Ex : others => Report_ASIS_Bug (Query_Name => Package_Name & "Scale_Value", Ex => Ex, Arg_Element => Desimal_Fixed_Point_Subtype); end Scale_Value; -------------------------- -- Small_Value (String) -- -------------------------- function Small_Value (Fixed_Point_Subtype : Asis.Element) return String is Arg_Node : Node_Id; Res_Ureal : Ureal; begin Check_Validity (Fixed_Point_Subtype, Package_Name & "Small_Value (String)"); Arg_Node := R_Node (Fixed_Point_Subtype); if not (Int_Kind (Fixed_Point_Subtype) = A_Defining_Identifier and then Is_Fixed_Point_Type (Arg_Node)) then Raise_ASIS_Inappropriate_Element (Package_Name & "Small_Value (String)", Wrong_Kind => Int_Kind (Fixed_Point_Subtype)); end if; Res_Ureal := Einfo.Small_Value (Arg_Node); Write_Real_To_Buffer (Res_Ureal); return Namet.Name_Buffer (1 .. Namet.Name_Len); exception when ASIS_Inappropriate_Element => raise; when ASIS_Failed => if Status_Indicator = Unhandled_Exception_Error then Add_Call_Information (Outer_Call => Package_Name & "Small_Value (String)", Argument => Fixed_Point_Subtype); end if; raise; when Ex : others => Report_ASIS_Bug (Query_Name => Package_Name & "Small_Value (String)", Ex => Ex, Arg_Element => Fixed_Point_Subtype); end Small_Value; ---------------------------- -- Small_Value (Fraction) -- ---------------------------- function Small_Value (Fixed_Point_Subtype : Asis.Element) return Fraction is Arg_Node : Node_Id; Res_Ureal : Ureal; Result : Fraction; begin Check_Validity (Fixed_Point_Subtype, Package_Name & "Small_Value (Fraction)"); Arg_Node := R_Node (Fixed_Point_Subtype); if not (Int_Kind (Fixed_Point_Subtype) = A_Defining_Identifier and then Is_Fixed_Point_Type (Arg_Node)) then Raise_ASIS_Inappropriate_Element (Package_Name & "Small_Value (Fraction)", Wrong_Kind => Int_Kind (Fixed_Point_Subtype)); end if; Res_Ureal := Einfo.Small_Value (Arg_Node); Result.Num := UI_To_Aint (Norm_Num (Res_Ureal)); Result.Denum := UI_To_Aint (Norm_Den (Res_Ureal)); return Result; exception when ASIS_Inappropriate_Element => raise; when ASIS_Failed => if Status_Indicator = Unhandled_Exception_Error then Add_Call_Information (Outer_Call => Package_Name & "Small_Value (Fraction)", Argument => Fixed_Point_Subtype); end if; raise; when Invalid_Data => Raise_ASIS_Inappropriate_Element (Diagnosis => Package_Name & "Small_Value (Fraction)", Wrong_Kind => Int_Kind (Fixed_Point_Subtype), Status => Data_Error); when Ex : others => Report_ASIS_Bug (Query_Name => Package_Name & "Small_Value (Fraction)", Ex => Ex, Arg_Element => Fixed_Point_Subtype); end Small_Value; -------------------------- -- Write_Real_To_Buffer -- -------------------------- procedure Write_Real_To_Buffer (U : Ureal) is begin Namet.Name_Len := 0; Add_Uint_To_Buffer (Norm_Num (U)); Add_Str_To_Name_Buffer ("/"); Add_Uint_To_Buffer (Norm_Den (U)); end Write_Real_To_Buffer; end Asis.Data_Decomposition.Extensions;
sparre/Ada-2012-Examples
Ada
1,084
ads
private with Ada.Unchecked_Conversion; generic type Element_Type is (<>); type Numeric_Type is mod <>; package Set_With_Modular_Representation is type Instance is array (Element_Type) of Boolean with Pack; Empty_Set : constant Numeric_Type := 0; Ø : Numeric_Type renames Empty_Set; function "&" (Left : in Instance; Right : in Instance) return Numeric_Type; function "&" (Left : in Numeric_Type; Right : in Instance) return Numeric_Type; function "&" (Left : in Element_Type; Right : in Element_Type) return Numeric_Type; function "&" (Left : in Numeric_Type; Right : in Element_Type) return Numeric_Type; private pragma Assert (Numeric_Type'Modulus = 2 ** Instance'Size); pragma Assert (Numeric_Type'Size = Instance'Size); function Numeric is new Ada.Unchecked_Conversion (Source => Instance, Target => Numeric_Type); function Numeric (Item : in Element_Type) return Numeric_Type; end Set_With_Modular_Representation;
SayCV/rtems-addon-packages
Ada
3,852
adb
------------------------------------------------------------------------------ -- -- -- GNAT ncurses Binding -- -- -- -- Terminal_Interface.Curses.Text_IO.Fixed_IO -- -- -- -- B O D Y -- -- -- ------------------------------------------------------------------------------ -- 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$ -- Binding Version 01.00 ------------------------------------------------------------------------------ with Ada.Text_IO; with Terminal_Interface.Curses.Text_IO.Aux; package body Terminal_Interface.Curses.Text_IO.Fixed_IO is package Aux renames Terminal_Interface.Curses.Text_IO.Aux; package FIXIO is new Ada.Text_IO.Fixed_IO (Num); procedure Put (Win : Window; Item : Num; Fore : Field := Default_Fore; Aft : Field := Default_Aft; Exp : Field := Default_Exp) is Buf : String (1 .. Field'Last); Len : Field := Fore + 1 + Aft; begin if Exp > 0 then Len := Len + 1 + Exp; end if; FIXIO.Put (Buf, Item, Aft, Exp); Aux.Put_Buf (Win, Buf, Len, False); end Put; procedure Put (Item : Num; Fore : Field := Default_Fore; Aft : Field := Default_Aft; Exp : Field := Default_Exp) is begin Put (Get_Window, Item, Fore, Aft, Exp); end Put; end Terminal_Interface.Curses.Text_IO.Fixed_IO;
M1nified/Ada-Samples
Ada
337
ads
with System; use System; package Qsort is type vector is array (Integer range <>) of Integer; type vector_ptr is access vector; task type SortTask is entry PortIn(ValIn : in vector_ptr); entry PortOut(ValOut : out vector); end SortTask; type Sort_access is access SortTask; procedure Sort (List : in out vector_ptr); end Qsort;
kimtg/euler-ada
Ada
1,352
adb
with Ada.Text_IO; use Ada.Text_IO; with Ada.Strings.Unbounded; use Ada.Strings.Unbounded; procedure Euler16 is function To_Integer(C : Character) return Integer is (Character'Pos(C) - Character'Pos('0')); function To_String(I : Integer) return String is S : String := Integer'Image(I); begin if I >= 0 then return S(2 .. S'Length); else return S(1 .. S'Length); end if; end; function Digit(A : Unbounded_String; D : Positive) return Natural is begin if D in 1 .. Length(A) then return To_Integer(Element(A, Length(A) - D + 1)); else return 0; end if; end Digit; function "*"(A : Unbounded_String; B : Natural) return Unbounded_String is R : Unbounded_String; Carry : Natural := 0; S : Natural; begin for D in 1 .. Length(A) loop S := Carry + Digit(A, D) * B; R := To_String(S mod 10) & R; Carry := S / 10; end loop; if Carry > 0 then R := To_String(Carry) & R; end if; return R; end "*"; P : Unbounded_String := To_Unbounded_String("2"); Sum : Natural := 0; begin for I in 2 .. 1000 loop P := P * 2; Put_Line(To_String(I) & ": " & To_String(P)); end loop; for I in 1 .. Length(P) loop Sum := Sum + Digit(P, I); end loop; Put_Line(To_String(Sum)); end Euler16;
charlie5/lace
Ada
285
adb
package body openGL.Variable is --------- -- Forge -- procedure define (Self : in out Item) -- TODO: Rid these ? is begin null; end define; procedure destroy (Self : in out Item) is begin null; end destroy; end openGL.Variable;
clairvoyant/anagram
Ada
7,913
ads
-- Copyright (c) 2010-2017 Maxim Reznik <[email protected]> -- -- SPDX-License-Identifier: MIT -- License-Filename: LICENSE ------------------------------------------------------------- with League.Strings; with League.String_Vectors; with Ada.Containers.Ordered_Maps; with Ada.Containers.Vectors; with Ada.Containers.Doubly_Linked_Lists; with Anagram.Grammars.Constructors; package Anagram.Grammars.Parser_Utils is type Production_List; type Production_List_Access is access all Production_List; type Part_Kind is (Reference_Kind, List_Reference_Kind, Option_Kind, List_Kind); subtype Named_Part_Kind is Part_Kind range Reference_Kind .. Option_Kind; type Part (Kind : Part_Kind := List_Kind) is record case Kind is when Reference_Kind | List_Reference_Kind => Reference : League.Strings.Universal_String; when List_Kind | Option_Kind => List : Production_List_Access; end case; end record; type Part_Access is access all Part; function "<" (L, R : Part_Access) return Boolean; type Named_Part is record Name : League.Strings.Universal_String; Data : Part_Access; end record; package Named_Part_Vectors is new Ada.Containers.Vectors (Positive, Named_Part); type Production is record Parts : Named_Part_Vectors.Vector; end record; type Production_Access is access all Production; type Named_Production is record Name : League.Strings.Universal_String; Data : Production_Access; end record; package Named_Production_Vectors is new Ada.Containers.Vectors (Positive, Named_Production); type Production_List is record Productions : Named_Production_Vectors.Vector; end record; type List is record Data : Production_List_Access; end record; type Context_Node is tagged private; procedure Error (Self : in out Context_Node; Text : Wide_Wide_String); procedure Add_Token (Self : in out Context_Node; Image : League.Strings.Universal_String); procedure Add_Token (Self : in out Context_Node; Image : League.Strings.Universal_String; Prio : League.Strings.Universal_String; Assoc : League.Strings.Universal_String); procedure Add_With (Self : in out Context_Node; Image : League.Strings.Universal_String); function Add_Reference (Self : in out Context_Node; Text : League.Strings.Universal_String) return Part_Access; function Add_List_Reference (Self : in out Context_Node; Text : League.Strings.Universal_String) return Part_Access; function Add_List (Self : in out Context_Node; List : Production_List_Access) return Part_Access; function Add_Option (Self : in out Context_Node; Option : Production_List_Access) return Part_Access; function To_Named_Part (Self : in out Context_Node; Data : Part_Access; Name : League.Strings.Universal_String := League.Strings.Empty_Universal_String) return Named_Part; function New_Production (Self : in out Context_Node; Item : Named_Part) return Production_Access; function Add_Part (Self : in out Context_Node; List : Production_Access; Item : Named_Part) return Production_Access; function To_Named_Production (Self : in out Context_Node; Data : Production_Access; Name : League.Strings.Universal_String := League.Strings.Empty_Universal_String) return Named_Production; function New_Production_List (Self : in out Context_Node; Item : Named_Production) return Production_List_Access; function New_Production_List (Self : in out Context_Node; Item : Production_Access) return Production_List_Access; function Add_Production (Self : in out Context_Node; List : Production_List_Access; Item : Named_Production) return Production_List_Access; procedure Add_Non_Terminal (Self : in out Context_Node; Name : League.Strings.Universal_String; List : Production_List_Access); procedure Add_Inherited_Attr (Self : in out Context_Node; Target : League.String_Vectors.Universal_String_Vector; Names : League.String_Vectors.Universal_String_Vector; Tipe : League.Strings.Universal_String); procedure Add_Synthesized_Attr (Self : in out Context_Node; Target : League.String_Vectors.Universal_String_Vector; Names : League.String_Vectors.Universal_String_Vector; Tipe : League.Strings.Universal_String); procedure Add_Local_Attr (Self : in out Context_Node; Target : League.String_Vectors.Universal_String_Vector; Names : League.String_Vectors.Universal_String_Vector; Tipe : League.Strings.Universal_String); procedure Add_Rule (Self : in out Context_Node; Target : League.String_Vectors.Universal_String_Vector; Text : League.Strings.Universal_String); procedure Add_Priority (Self : in out Context_Node; Name : League.Strings.Universal_String; Prio : League.Strings.Universal_String; Assoc : League.Strings.Universal_String); procedure Complete (Self : in out Context_Node; Constructor : in out Anagram.Grammars.Constructors.Constructor; Tail_List : Boolean := False); private use type League.Strings.Universal_String; type Attribute_Declaration is record Target : League.String_Vectors.Universal_String_Vector; Names : League.String_Vectors.Universal_String_Vector; Tipe : League.Strings.Universal_String; end record; package Attribute_Declaration_Lists is new Ada.Containers.Doubly_Linked_Lists (Attribute_Declaration); function Less (Left, Right : Production_List_Access) return Boolean; package List_Part_Maps is new Ada.Containers.Ordered_Maps (Production_List_Access, Part_Access, Less); package Reference_Part_Maps is new Ada.Containers.Ordered_Maps (League.Strings.Universal_String, Part_Access); package Non_Terminal_Maps is new Ada.Containers.Ordered_Maps (League.Strings.Universal_String, Production_List_Access); function Less (Left, Right : Named_Part_Vectors.Vector) return Boolean; package Production_Maps is new Ada.Containers.Ordered_Maps (Named_Part_Vectors.Vector, Production_Access, Less); function Less (L, R : Named_Production_Vectors.Vector) return Boolean; package Production_List_Maps is new Ada.Containers.Ordered_Maps (Named_Production_Vectors.Vector, Production_List_Access, Less); type Rule is record Target : League.String_Vectors.Universal_String_Vector; Text : League.Strings.Universal_String; end record; package Rule_Lists is new Ada.Containers.Doubly_Linked_Lists (Rule); package Token_Maps is new Ada.Containers.Ordered_Maps (League.Strings.Universal_String, Precedence_Value); package List_Maps is new Ada.Containers.Ordered_Maps (League.Strings.Universal_String, Production_List_Access); type Context_Node is tagged record Non_Terminals : Non_Terminal_Maps.Map; Productions : Production_Maps.Map; Prod_Lists : Production_List_Maps.Map; Inherited : Attribute_Declaration_Lists.List; Synthesized : Attribute_Declaration_Lists.List; Local : Attribute_Declaration_Lists.List; List_Parts : List_Part_Maps.Map; Option_Parts : List_Part_Maps.Map; Reference_Parts : Reference_Part_Maps.Map; Rules : Rule_Lists.List; Tokens : Token_Maps.Map; Lists : List_Maps.Map; With_List : League.String_Vectors.Universal_String_Vector; Priorities : Token_Maps.Map; end record; end Anagram.Grammars.Parser_Utils;
ytomino/vampire
Ada
3,497
ads
-- The Village of Vampire by YT, このソースコードはNYSLです with Ada.Calendar; with Ada.Strings.Unbounded; with Tabula.Casts; package Tabula.Villages is -- 村のID subtype Village_Id is String (1 .. 4); Invalid_Village_Id : constant Village_Id := "****"; -- 村の状態 type Village_Term is (Short, Long); -- 短期 or 長期 type Village_State is (Prologue, Playing, Epilogue, Closed); -- 参加者 type Person_Type is new Casts.Person with record Id : aliased Ada.Strings.Unbounded.Unbounded_String; end record; subtype Person_Index is Natural; No_Person : constant Person_Index'Base := -1; function Same_Id_And_Figure (Left, Right : Person_Type'Class) return Boolean; -- メッセージ subtype Message_Index is Natural; subtype Speech_Index is Natural; -- count only speeches type Speech_Range_Type is record First : Speech_Index; Last : Speech_Index'Base; end record; subtype Speech_Positive_Count is Speech_Index range 1 .. Speech_Index'Last; -- オプション type Village_Type is tagged; type Root_Option_Item is abstract tagged limited null record; function Available (Item : Root_Option_Item) return Boolean is abstract; function Name (Item : Root_Option_Item) return String is abstract; function Changed (Item : Root_Option_Item) return Boolean is abstract; procedure Iterate ( Item : in Root_Option_Item; Process : not null access procedure ( Value : in String; Selected : in Boolean; Message : in String; Unrecommended : in Boolean)) is abstract; procedure Change ( Village : in out Village_Type'Class; Item : in Root_Option_Item; Value : in String) is abstract; -- 村 type Village_Type is abstract tagged limited record Name : aliased Ada.Strings.Unbounded.Unbounded_String; By : aliased Ada.Strings.Unbounded.Unbounded_String; -- 作成者 Face_Group : Integer := 0; -- 顔絵セット Face_Width : Integer := 0; Face_Height : Integer := 0; end record; function Term (Village : Village_Type) return Village_Term is abstract; procedure Get_State ( Village : in Village_Type; State : out Village_State; Today : out Natural) is abstract; -- Prologue = 0 procedure Iterate_People ( Village : in Village_Type; Process : not null access procedure ( Index : Person_Index; Item : in Person_Type'Class)) is abstract; procedure Iterate_Escaped_People ( Village : in Village_Type; Process : not null access procedure ( Index : Person_Index; Item : in Person_Type'Class)) is abstract; function Speech_Range ( Village : Village_Type; Day : Natural) return Speech_Range_Type is abstract; function Recent_Only_Speech_Range ( Village : Village_Type; Day : Natural; Now : Ada.Calendar.Time) return Speech_Range_Type is abstract; procedure Iterate_Options ( Village : in Village_Type; Process : not null access procedure (Item : in Root_Option_Item'Class)) is abstract; function Option_Changed (Village : Village_Type) return Boolean; -- 参加状況 function Joined (Village : Village_Type; User_Id : String) return Person_Index'Base; function Already_Joined_As_Another_Sex ( Village : Village_Type; User_Id : String; Sex : Casts.Person_Sex) return Boolean; function Male_And_Female (Village : Village_Type) return Boolean; -- 既に取られているものを除外 procedure Exclude_Taken ( Cast : in out Casts.Cast_Collection; Village : in Village_Type); end Tabula.Villages;
Jellix/virtual_clocks
Ada
849
adb
------------------------------------------------------------------------ -- Copyright (C) 2010-2020 by <[email protected]> -- -- -- -- This work is free. You can redistribute it and/or modify it under -- -- the terms of the Do What The Fuck You Want To Public License, -- -- Version 2, as published by Sam Hocevar. See the LICENSE file for -- -- more details. -- ------------------------------------------------------------------------ pragma License (Unrestricted); with Test_Clocks; ------------------------------------------------------------------------ -- Tests ------------------------------------------------------------------------ procedure Tests is begin Test_Clocks.Run; end Tests;
AdaCore/Ada_Drivers_Library
Ada
3,018
ads
-- This spec has been automatically generated from STM32F429x.svd pragma Restrictions (No_Elaboration_Code); pragma Ada_2012; pragma Style_Checks (Off); with HAL; with System; package STM32_SVD.IWDG is pragma Preelaborate; --------------- -- Registers -- --------------- subtype KR_KEY_Field is HAL.UInt16; -- Key register type KR_Register is record -- Write-only. Key value (write only, read 0000h) KEY : KR_KEY_Field := 16#0#; -- unspecified Reserved_16_31 : HAL.UInt16 := 16#0#; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for KR_Register use record KEY at 0 range 0 .. 15; Reserved_16_31 at 0 range 16 .. 31; end record; subtype PR_PR_Field is HAL.UInt3; -- Prescaler register type PR_Register is record -- Prescaler divider PR : PR_PR_Field := 16#0#; -- unspecified Reserved_3_31 : HAL.UInt29 := 16#0#; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for PR_Register use record PR at 0 range 0 .. 2; Reserved_3_31 at 0 range 3 .. 31; end record; subtype RLR_RL_Field is HAL.UInt12; -- Reload register type RLR_Register is record -- Watchdog counter reload value RL : RLR_RL_Field := 16#FFF#; -- unspecified Reserved_12_31 : HAL.UInt20 := 16#0#; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for RLR_Register use record RL at 0 range 0 .. 11; Reserved_12_31 at 0 range 12 .. 31; end record; -- Status register type SR_Register is record -- Read-only. Watchdog prescaler value update PVU : Boolean; -- Read-only. Watchdog counter reload value update RVU : Boolean; -- unspecified Reserved_2_31 : HAL.UInt30; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for SR_Register use record PVU at 0 range 0 .. 0; RVU at 0 range 1 .. 1; Reserved_2_31 at 0 range 2 .. 31; end record; ----------------- -- Peripherals -- ----------------- -- Independent watchdog type IWDG_Peripheral is record -- Key register KR : aliased KR_Register; -- Prescaler register PR : aliased PR_Register; -- Reload register RLR : aliased RLR_Register; -- Status register SR : aliased SR_Register; end record with Volatile; for IWDG_Peripheral use record KR at 16#0# range 0 .. 31; PR at 16#4# range 0 .. 31; RLR at 16#8# range 0 .. 31; SR at 16#C# range 0 .. 31; end record; -- Independent watchdog IWDG_Periph : aliased IWDG_Peripheral with Import, Address => System'To_Address (16#40003000#); end STM32_SVD.IWDG;
reznikmm/matreshka
Ada
4,910
adb
------------------------------------------------------------------------------ -- -- -- Matreshka Project -- -- -- -- XML Processor -- -- -- -- Runtime Library Component -- -- -- ------------------------------------------------------------------------------ -- -- -- Copyright © 2012, Vadim Godunko <[email protected]> -- -- All rights reserved. -- -- -- -- Redistribution and use in source and binary forms, with or without -- -- modification, are permitted provided that the following conditions -- -- are met: -- -- -- -- * Redistributions of source code must retain the above copyright -- -- notice, this list of conditions and the following disclaimer. -- -- -- -- * Redistributions in binary form must reproduce the above copyright -- -- notice, this list of conditions and the following disclaimer in the -- -- documentation and/or other materials provided with the distribution. -- -- -- -- * Neither the name of the Vadim Godunko, IE nor the names of its -- -- contributors may be used to endorse or promote products derived from -- -- this software without specific prior written permission. -- -- -- -- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -- -- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -- -- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -- -- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -- -- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -- -- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED -- -- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -- -- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -- -- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -- -- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -- -- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- -- -- ------------------------------------------------------------------------------ -- $Revision$ $Date$ ------------------------------------------------------------------------------ with Ada.Exceptions; with Ada.Text_IO; with League.Application; with Matreshka.XML_Catalogs.Entry_Files; with Matreshka.XML_Catalogs.Loader; with Matreshka.XML_Catalogs.Resolver; package body Matreshka.XML_Schema.URI_Rewriter is use type League.Strings.Universal_String; function "+" (Item : Wide_Wide_String) return League.Strings.Universal_String renames League.Strings.To_Universal_String; Rules : aliased Matreshka.XML_Catalogs.Entry_Files.Catalog_Entry_File_List; ---------------- -- Initialize -- ---------------- procedure Initialize is begin -- Load schemas mappings. begin Rules.Catalog_Entry_Files.Append (Matreshka.XML_Catalogs.Loader.Load_By_File_Name (League.Application.Environment.Value (+"AMF_DATA_DIR", +".") & "/schemas/namespaces.xml", Matreshka.XML_Catalogs.Entry_Files.Public)); exception when E : others => Ada.Text_IO.Put_Line (Ada.Text_IO.Standard_Error, Ada.Exceptions.Exception_Information (E)); end; end Initialize; ----------------- -- Rewrite_URI -- ----------------- function Rewrite_URI (URI : League.Strings.Universal_String) return League.Strings.Universal_String is Resolved : League.Strings.Universal_String; Success : Boolean; begin Matreshka.XML_Catalogs.Resolver.Resolve_URI (Rules'Access, URI, Resolved, Success); return Resolved; end Rewrite_URI; end Matreshka.XML_Schema.URI_Rewriter;
zhmu/ananas
Ada
5,415
adb
------------------------------------------------------------------------------ -- -- -- GNAT RUN-TIME COMPONENTS -- -- -- -- A D A . T E X T _ I O . B O U N D E D _ I O -- -- -- -- B o d y -- -- -- -- Copyright (C) 1997-2022, Free Software Foundation, Inc. -- -- -- -- GNAT is free software; you can redistribute it and/or modify it under -- -- terms of the GNU General Public License as published by the Free Soft- -- -- ware Foundation; either version 3, or (at your option) any later ver- -- -- sion. GNAT is distributed in the hope that it will be useful, but WITH- -- -- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY -- -- or FITNESS FOR A PARTICULAR PURPOSE. -- -- -- -- As a special exception under Section 7 of GPL version 3, you are granted -- -- additional permissions described in the GCC Runtime Library Exception, -- -- version 3.1, as published by the Free Software Foundation. -- -- -- -- You should have received a copy of the GNU General Public License and -- -- a copy of the GCC Runtime Library Exception along with this program; -- -- see the files COPYING3 and COPYING.RUNTIME respectively. If not, see -- -- <http://www.gnu.org/licenses/>. -- -- -- -- GNAT was originally developed by the GNAT team at New York University. -- -- Extensive contributions were provided by Ada Core Technologies Inc. -- -- -- ------------------------------------------------------------------------------ with Ada.Unchecked_Deallocation; package body Ada.Text_IO.Bounded_IO is type String_Access is access all String; procedure Free (SA : in out String_Access); -- Perform an unchecked deallocation of a non-null string ---------- -- Free -- ---------- procedure Free (SA : in out String_Access) is Null_String : constant String := ""; procedure Deallocate is new Ada.Unchecked_Deallocation (String, String_Access); begin -- Do not try to free statically allocated null string if SA.all /= Null_String then Deallocate (SA); end if; end Free; -------------- -- Get_Line -- -------------- function Get_Line return Bounded.Bounded_String is begin return Bounded.To_Bounded_String (Get_Line); end Get_Line; -------------- -- Get_Line -- -------------- function Get_Line (File : File_Type) return Bounded.Bounded_String is begin return Bounded.To_Bounded_String (Get_Line (File)); end Get_Line; -------------- -- Get_Line -- -------------- procedure Get_Line (Item : out Bounded.Bounded_String) is Buffer : String (1 .. 1000); Last : Natural; Str1 : String_Access; Str2 : String_Access; begin Get_Line (Buffer, Last); Str1 := new String'(Buffer (1 .. Last)); while Last = Buffer'Last loop Get_Line (Buffer, Last); Str2 := new String'(Str1.all & Buffer (1 .. Last)); Free (Str1); Str1 := Str2; end loop; Item := Bounded.To_Bounded_String (Str1.all); end Get_Line; -------------- -- Get_Line -- -------------- procedure Get_Line (File : File_Type; Item : out Bounded.Bounded_String) is Buffer : String (1 .. 1000); Last : Natural; Str1 : String_Access; Str2 : String_Access; begin Get_Line (File, Buffer, Last); Str1 := new String'(Buffer (1 .. Last)); while Last = Buffer'Last loop Get_Line (File, Buffer, Last); Str2 := new String'(Str1.all & Buffer (1 .. Last)); Free (Str1); Str1 := Str2; end loop; Item := Bounded.To_Bounded_String (Str1.all); end Get_Line; --------- -- Put -- --------- procedure Put (Item : Bounded.Bounded_String) is begin Put (Bounded.To_String (Item)); end Put; --------- -- Put -- --------- procedure Put (File : File_Type; Item : Bounded.Bounded_String) is begin Put (File, Bounded.To_String (Item)); end Put; -------------- -- Put_Line -- -------------- procedure Put_Line (Item : Bounded.Bounded_String) is begin Put_Line (Bounded.To_String (Item)); end Put_Line; -------------- -- Put_Line -- -------------- procedure Put_Line (File : File_Type; Item : Bounded.Bounded_String) is begin Put_Line (File, Bounded.To_String (Item)); end Put_Line; end Ada.Text_IO.Bounded_IO;
reznikmm/matreshka
Ada
4,599
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.Transform_Attributes is ------------ -- Create -- ------------ overriding function Create (Parameters : not null access Matreshka.DOM_Attributes.Attribute_L2_Parameters) return Draw_Transform_Attribute_Node is begin return Self : Draw_Transform_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_Transform_Attribute_Node) return League.Strings.Universal_String is pragma Unreferenced (Self); begin return Matreshka.ODF_String_Constants.Transform_Attribute; end Get_Local_Name; begin Matreshka.DOM_Documents.Register_Attribute (Matreshka.ODF_String_Constants.Draw_URI, Matreshka.ODF_String_Constants.Transform_Attribute, Draw_Transform_Attribute_Node'Tag); end Matreshka.ODF_Draw.Transform_Attributes;
reznikmm/matreshka
Ada
4,720
adb
------------------------------------------------------------------------------ -- -- -- Matreshka Project -- -- -- -- Open Document Toolkit -- -- -- -- Runtime Library Component -- -- -- ------------------------------------------------------------------------------ -- -- -- Copyright © 2014, Vadim Godunko <[email protected]> -- -- All rights reserved. -- -- -- -- Redistribution and use in source and binary forms, with or without -- -- modification, are permitted provided that the following conditions -- -- are met: -- -- -- -- * Redistributions of source code must retain the above copyright -- -- notice, this list of conditions and the following disclaimer. -- -- -- -- * Redistributions in binary form must reproduce the above copyright -- -- notice, this list of conditions and the following disclaimer in the -- -- documentation and/or other materials provided with the distribution. -- -- -- -- * Neither the name of the Vadim Godunko, IE nor the names of its -- -- contributors may be used to endorse or promote products derived from -- -- this software without specific prior written permission. -- -- -- -- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -- -- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -- -- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -- -- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -- -- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -- -- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED -- -- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -- -- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -- -- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -- -- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -- -- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- -- -- ------------------------------------------------------------------------------ -- $Revision$ $Date$ ------------------------------------------------------------------------------ with Matreshka.DOM_Documents; with Matreshka.ODF_String_Constants; with ODF.DOM.Iterators; with ODF.DOM.Visitors; package body Matreshka.ODF_Style.Background_Transparency_Attributes is ------------ -- Create -- ------------ overriding function Create (Parameters : not null access Matreshka.DOM_Attributes.Attribute_L2_Parameters) return Style_Background_Transparency_Attribute_Node is begin return Self : Style_Background_Transparency_Attribute_Node do Matreshka.ODF_Style.Constructors.Initialize (Self'Unchecked_Access, Parameters.Document, Matreshka.ODF_String_Constants.Style_Prefix); end return; end Create; -------------------- -- Get_Local_Name -- -------------------- overriding function Get_Local_Name (Self : not null access constant Style_Background_Transparency_Attribute_Node) return League.Strings.Universal_String is pragma Unreferenced (Self); begin return Matreshka.ODF_String_Constants.Background_Transparency_Attribute; end Get_Local_Name; begin Matreshka.DOM_Documents.Register_Attribute (Matreshka.ODF_String_Constants.Style_URI, Matreshka.ODF_String_Constants.Background_Transparency_Attribute, Style_Background_Transparency_Attribute_Node'Tag); end Matreshka.ODF_Style.Background_Transparency_Attributes;
reznikmm/matreshka
Ada
4,557
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_Fo.Widows_Attributes is ------------ -- Create -- ------------ overriding function Create (Parameters : not null access Matreshka.DOM_Attributes.Attribute_L2_Parameters) return Fo_Widows_Attribute_Node is begin return Self : Fo_Widows_Attribute_Node do Matreshka.ODF_Fo.Constructors.Initialize (Self'Unchecked_Access, Parameters.Document, Matreshka.ODF_String_Constants.Fo_Prefix); end return; end Create; -------------------- -- Get_Local_Name -- -------------------- overriding function Get_Local_Name (Self : not null access constant Fo_Widows_Attribute_Node) return League.Strings.Universal_String is pragma Unreferenced (Self); begin return Matreshka.ODF_String_Constants.Widows_Attribute; end Get_Local_Name; begin Matreshka.DOM_Documents.Register_Attribute (Matreshka.ODF_String_Constants.Fo_URI, Matreshka.ODF_String_Constants.Widows_Attribute, Fo_Widows_Attribute_Node'Tag); end Matreshka.ODF_Fo.Widows_Attributes;
reznikmm/matreshka
Ada
7,238
adb
------------------------------------------------------------------------------ -- -- -- Matreshka Project -- -- -- -- Open Document Toolkit -- -- -- -- Runtime Library Component -- -- -- ------------------------------------------------------------------------------ -- -- -- Copyright © 2014, Vadim Godunko <[email protected]> -- -- All rights reserved. -- -- -- -- Redistribution and use in source and binary forms, with or without -- -- modification, are permitted provided that the following conditions -- -- are met: -- -- -- -- * Redistributions of source code must retain the above copyright -- -- notice, this list of conditions and the following disclaimer. -- -- -- -- * Redistributions in binary form must reproduce the above copyright -- -- notice, this list of conditions and the following disclaimer in the -- -- documentation and/or other materials provided with the distribution. -- -- -- -- * Neither the name of the Vadim Godunko, IE nor the names of its -- -- contributors may be used to endorse or promote products derived from -- -- this software without specific prior written permission. -- -- -- -- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -- -- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -- -- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -- -- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -- -- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -- -- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED -- -- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -- -- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -- -- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -- -- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -- -- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- -- -- ------------------------------------------------------------------------------ -- $Revision$ $Date$ ------------------------------------------------------------------------------ with Matreshka.DOM_Documents; with Matreshka.ODF_String_Constants; with ODF.DOM.Iterators; with ODF.DOM.Visitors; package body Matreshka.ODF_Db.Application_Connection_Settings_Elements is ------------ -- Create -- ------------ overriding function Create (Parameters : not null access Matreshka.DOM_Elements.Element_L2_Parameters) return Db_Application_Connection_Settings_Element_Node is begin return Self : Db_Application_Connection_Settings_Element_Node do Matreshka.ODF_Db.Constructors.Initialize (Self'Unchecked_Access, Parameters.Document, Matreshka.ODF_String_Constants.Db_Prefix); end return; end Create; ---------------- -- Enter_Node -- ---------------- overriding procedure Enter_Node (Self : not null access Db_Application_Connection_Settings_Element_Node; Visitor : in out XML.DOM.Visitors.Abstract_Visitor'Class; Control : in out XML.DOM.Visitors.Traverse_Control) is begin if Visitor in ODF.DOM.Visitors.Abstract_ODF_Visitor'Class then ODF.DOM.Visitors.Abstract_ODF_Visitor'Class (Visitor).Enter_Db_Application_Connection_Settings (ODF.DOM.Db_Application_Connection_Settings_Elements.ODF_Db_Application_Connection_Settings_Access (Self), Control); else Matreshka.DOM_Elements.Abstract_Element_Node (Self.all).Enter_Node (Visitor, Control); end if; end Enter_Node; -------------------- -- Get_Local_Name -- -------------------- overriding function Get_Local_Name (Self : not null access constant Db_Application_Connection_Settings_Element_Node) return League.Strings.Universal_String is pragma Unreferenced (Self); begin return Matreshka.ODF_String_Constants.Application_Connection_Settings_Element; end Get_Local_Name; ---------------- -- Leave_Node -- ---------------- overriding procedure Leave_Node (Self : not null access Db_Application_Connection_Settings_Element_Node; Visitor : in out XML.DOM.Visitors.Abstract_Visitor'Class; Control : in out XML.DOM.Visitors.Traverse_Control) is begin if Visitor in ODF.DOM.Visitors.Abstract_ODF_Visitor'Class then ODF.DOM.Visitors.Abstract_ODF_Visitor'Class (Visitor).Leave_Db_Application_Connection_Settings (ODF.DOM.Db_Application_Connection_Settings_Elements.ODF_Db_Application_Connection_Settings_Access (Self), Control); else Matreshka.DOM_Elements.Abstract_Element_Node (Self.all).Leave_Node (Visitor, Control); end if; end Leave_Node; ---------------- -- Visit_Node -- ---------------- overriding procedure Visit_Node (Self : not null access Db_Application_Connection_Settings_Element_Node; Iterator : in out XML.DOM.Visitors.Abstract_Iterator'Class; Visitor : in out XML.DOM.Visitors.Abstract_Visitor'Class; Control : in out XML.DOM.Visitors.Traverse_Control) is begin if Iterator in ODF.DOM.Iterators.Abstract_ODF_Iterator'Class then ODF.DOM.Iterators.Abstract_ODF_Iterator'Class (Iterator).Visit_Db_Application_Connection_Settings (Visitor, ODF.DOM.Db_Application_Connection_Settings_Elements.ODF_Db_Application_Connection_Settings_Access (Self), Control); else Matreshka.DOM_Elements.Abstract_Element_Node (Self.all).Visit_Node (Iterator, Visitor, Control); end if; end Visit_Node; begin Matreshka.DOM_Documents.Register_Element (Matreshka.ODF_String_Constants.Db_URI, Matreshka.ODF_String_Constants.Application_Connection_Settings_Element, Db_Application_Connection_Settings_Element_Node'Tag); end Matreshka.ODF_Db.Application_Connection_Settings_Elements;
reznikmm/matreshka
Ada
4,637
adb
------------------------------------------------------------------------------ -- -- -- Matreshka Project -- -- -- -- Open Document Toolkit -- -- -- -- Runtime Library Component -- -- -- ------------------------------------------------------------------------------ -- -- -- Copyright © 2014, Vadim Godunko <[email protected]> -- -- All rights reserved. -- -- -- -- Redistribution and use in source and binary forms, with or without -- -- modification, are permitted provided that the following conditions -- -- are met: -- -- -- -- * Redistributions of source code must retain the above copyright -- -- notice, this list of conditions and the following disclaimer. -- -- -- -- * Redistributions in binary form must reproduce the above copyright -- -- notice, this list of conditions and the following disclaimer in the -- -- documentation and/or other materials provided with the distribution. -- -- -- -- * Neither the name of the Vadim Godunko, IE nor the names of its -- -- contributors may be used to endorse or promote products derived from -- -- this software without specific prior written permission. -- -- -- -- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -- -- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -- -- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -- -- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -- -- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -- -- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED -- -- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -- -- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -- -- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -- -- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -- -- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- -- -- ------------------------------------------------------------------------------ -- $Revision$ $Date$ ------------------------------------------------------------------------------ with Matreshka.DOM_Documents; with Matreshka.ODF_String_Constants; with ODF.DOM.Iterators; with ODF.DOM.Visitors; package body Matreshka.ODF_Db.Is_Empty_Allowed_Attributes is ------------ -- Create -- ------------ overriding function Create (Parameters : not null access Matreshka.DOM_Attributes.Attribute_L2_Parameters) return Db_Is_Empty_Allowed_Attribute_Node is begin return Self : Db_Is_Empty_Allowed_Attribute_Node do Matreshka.ODF_Db.Constructors.Initialize (Self'Unchecked_Access, Parameters.Document, Matreshka.ODF_String_Constants.Db_Prefix); end return; end Create; -------------------- -- Get_Local_Name -- -------------------- overriding function Get_Local_Name (Self : not null access constant Db_Is_Empty_Allowed_Attribute_Node) return League.Strings.Universal_String is pragma Unreferenced (Self); begin return Matreshka.ODF_String_Constants.Is_Empty_Allowed_Attribute; end Get_Local_Name; begin Matreshka.DOM_Documents.Register_Attribute (Matreshka.ODF_String_Constants.Db_URI, Matreshka.ODF_String_Constants.Is_Empty_Allowed_Attribute, Db_Is_Empty_Allowed_Attribute_Node'Tag); end Matreshka.ODF_Db.Is_Empty_Allowed_Attributes;
reznikmm/matreshka
Ada
3,766
adb
------------------------------------------------------------------------------ -- -- -- Matreshka Project -- -- -- -- Open Document Toolkit -- -- -- -- Runtime Library Component -- -- -- ------------------------------------------------------------------------------ -- -- -- Copyright © 2013, Vadim Godunko <[email protected]> -- -- All rights reserved. -- -- -- -- Redistribution and use in source and binary forms, with or without -- -- modification, are permitted provided that the following conditions -- -- are met: -- -- -- -- * Redistributions of source code must retain the above copyright -- -- notice, this list of conditions and the following disclaimer. -- -- -- -- * Redistributions in binary form must reproduce the above copyright -- -- notice, this list of conditions and the following disclaimer in the -- -- documentation and/or other materials provided with the distribution. -- -- -- -- * Neither the name of the Vadim Godunko, IE nor the names of its -- -- contributors may be used to endorse or promote products derived from -- -- this software without specific prior written permission. -- -- -- -- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -- -- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -- -- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -- -- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -- -- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -- -- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED -- -- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -- -- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -- -- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -- -- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -- -- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- -- -- ------------------------------------------------------------------------------ -- $Revision$ $Date$ ------------------------------------------------------------------------------ with ODF.Constants; package body Matreshka.ODF_Attributes.Text.Start_Value is -------------------- -- Get_Local_Name -- -------------------- overriding function Get_Local_Name (Self : not null access constant Text_Start_Value_Node) return League.Strings.Universal_String is begin return ODF.Constants.Start_Value_Name; end Get_Local_Name; end Matreshka.ODF_Attributes.Text.Start_Value;
AdaCore/Ada_Drivers_Library
Ada
3,556
adb
------------------------------------------------------------------------------ -- -- -- Copyright (C) 2022, AdaCore -- -- -- -- Redistribution and use in source and binary forms, with or without -- -- modification, are permitted provided that the following conditions are -- -- met: -- -- 1. Redistributions of source code must retain the above copyright -- -- notice, this list of conditions and the following disclaimer. -- -- 2. Redistributions in binary form must reproduce the above copyright -- -- notice, this list of conditions and the following disclaimer in -- -- the documentation and/or other materials provided with the -- -- distribution. -- -- 3. Neither the name of the copyright holder nor the names of its -- -- contributors may be used to endorse or promote products derived -- -- from this software without specific prior written permission. -- -- -- -- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -- -- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -- -- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -- -- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -- -- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -- -- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -- -- LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -- -- DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -- -- THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -- -- (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -- -- OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- -- -- ------------------------------------------------------------------------------ with HAL.I2C; use HAL.I2C; package body MCP23x17.I2C is -------------- -- IO_Write -- -------------- overriding procedure IO_Write (This : in out MCP23017_IO_Expander; Addr : Register_Address; Value : UInt8) is Status : I2C_Status; begin This.Port.Mem_Write (Base_Address or I2C_Address (This.Addr), UInt16 (Addr), Memory_Size_8b, (1 => Value), Status, 1000); if Status /= Ok then -- No error handling... raise Program_Error; end if; end IO_Write; ------------- -- IO_Read -- ------------- overriding procedure IO_Read (This : MCP23017_IO_Expander; Addr : Register_Address; Value : out UInt8) is Ret : I2C_Data (1 .. 1); Status : I2C_Status; begin This.Port.Mem_Read (Base_Address or I2C_Address (This.Addr), UInt16 (Addr), Memory_Size_8b, Ret, Status, 1000); if Status /= Ok then -- No error handling... raise Program_Error; end if; Value := Ret (1); end IO_Read; end MCP23x17.I2C;
reznikmm/matreshka
Ada
4,142
ads
------------------------------------------------------------------------------ -- -- -- Matreshka Project -- -- -- -- Web Framework -- -- -- -- Testsuite Component -- -- -- ------------------------------------------------------------------------------ -- -- -- Copyright © 2012, Vadim Godunko <[email protected]> -- -- All rights reserved. -- -- -- -- Redistribution and use in source and binary forms, with or without -- -- modification, are permitted provided that the following conditions -- -- are met: -- -- -- -- * Redistributions of source code must retain the above copyright -- -- notice, this list of conditions and the following disclaimer. -- -- -- -- * Redistributions in binary form must reproduce the above copyright -- -- notice, this list of conditions and the following disclaimer in the -- -- documentation and/or other materials provided with the distribution. -- -- -- -- * Neither the name of the Vadim Godunko, IE nor the names of its -- -- contributors may be used to endorse or promote products derived from -- -- this software without specific prior written permission. -- -- -- -- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -- -- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -- -- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -- -- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -- -- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -- -- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED -- -- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -- -- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -- -- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -- -- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -- -- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- -- -- ------------------------------------------------------------------------------ -- $Revision$ $Date$ ------------------------------------------------------------------------------ with League.Stream_Element_Vectors; with Web_Services.SOAP.Reply_Streams; package SOAPConf.Reply_Streams is type Reply_Stream is new Web_Services.SOAP.Reply_Streams.Abstract_Reply_Stream with record Output_Data : League.Stream_Element_Vectors.Stream_Element_Vector; end record; overriding procedure Enable_Multipart_Content (Self : in out Reply_Stream); overriding procedure Send_Reply (Self : in out Reply_Stream; Status : Web_Services.SOAP.Reply_Streams.Status_Type; Content_Type : League.Stream_Element_Vectors.Stream_Element_Vector; Output_Data : League.Stream_Element_Vectors.Stream_Element_Vector; Success : out Boolean); overriding procedure Finalyze (Self : in out Reply_Stream) is null; end SOAPConf.Reply_Streams;
gerr135/gnat_bugs
Ada
343
ads
package root is type Real is new Float; type Base_Interface is limited interface; procedure Primitive1 (B : in out Base_Interface) is abstract; -- builds procedure Primitive2 (B : in out Base_Interface) is null; -- causes bug type Derived_Interface is limited interface and Base_Interface; end root;
reznikmm/matreshka
Ada
4,655
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.Master_Page_Name_Attributes is ------------ -- Create -- ------------ overriding function Create (Parameters : not null access Matreshka.DOM_Attributes.Attribute_L2_Parameters) return Text_Master_Page_Name_Attribute_Node is begin return Self : Text_Master_Page_Name_Attribute_Node do Matreshka.ODF_Text.Constructors.Initialize (Self'Unchecked_Access, Parameters.Document, Matreshka.ODF_String_Constants.Text_Prefix); end return; end Create; -------------------- -- Get_Local_Name -- -------------------- overriding function Get_Local_Name (Self : not null access constant Text_Master_Page_Name_Attribute_Node) return League.Strings.Universal_String is pragma Unreferenced (Self); begin return Matreshka.ODF_String_Constants.Master_Page_Name_Attribute; end Get_Local_Name; begin Matreshka.DOM_Documents.Register_Attribute (Matreshka.ODF_String_Constants.Text_URI, Matreshka.ODF_String_Constants.Master_Page_Name_Attribute, Text_Master_Page_Name_Attribute_Node'Tag); end Matreshka.ODF_Text.Master_Page_Name_Attributes;
reznikmm/matreshka
Ada
3,699
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_User_Field_Decl_Elements is pragma Preelaborate; type ODF_Text_User_Field_Decl is limited interface and XML.DOM.Elements.DOM_Element; type ODF_Text_User_Field_Decl_Access is access all ODF_Text_User_Field_Decl'Class with Storage_Size => 0; end ODF.DOM.Text_User_Field_Decl_Elements;
reznikmm/matreshka
Ada
3,704
ads
------------------------------------------------------------------------------ -- -- -- Matreshka Project -- -- -- -- Open Document Toolkit -- -- -- -- Runtime Library Component -- -- -- ------------------------------------------------------------------------------ -- -- -- Copyright © 2014, Vadim Godunko <[email protected]> -- -- All rights reserved. -- -- -- -- Redistribution and use in source and binary forms, with or without -- -- modification, are permitted provided that the following conditions -- -- are met: -- -- -- -- * Redistributions of source code must retain the above copyright -- -- notice, this list of conditions and the following disclaimer. -- -- -- -- * Redistributions in binary form must reproduce the above copyright -- -- notice, this list of conditions and the following disclaimer in the -- -- documentation and/or other materials provided with the distribution. -- -- -- -- * Neither the name of the Vadim Godunko, IE nor the names of its -- -- contributors may be used to endorse or promote products derived from -- -- this software without specific prior written permission. -- -- -- -- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -- -- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -- -- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -- -- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -- -- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -- -- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED -- -- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -- -- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -- -- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -- -- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -- -- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- -- -- ------------------------------------------------------------------------------ -- $Revision$ $Date$ ------------------------------------------------------------------------------ with XML.DOM.Elements; package ODF.DOM.Text_Table_Of_Content_Elements is pragma Preelaborate; type ODF_Text_Table_Of_Content is limited interface and XML.DOM.Elements.DOM_Element; type ODF_Text_Table_Of_Content_Access is access all ODF_Text_Table_Of_Content'Class with Storage_Size => 0; end ODF.DOM.Text_Table_Of_Content_Elements;
AdaCore/Ada_Drivers_Library
Ada
3,387
adb
------------------------------------------------------------------------------ -- -- -- Copyright (C) 2016, AdaCore -- -- -- -- Redistribution and use in source and binary forms, with or without -- -- modification, are permitted provided that the following conditions are -- -- met: -- -- 1. Redistributions of source code must retain the above copyright -- -- notice, this list of conditions and the following disclaimer. -- -- 2. Redistributions in binary form must reproduce the above copyright -- -- notice, this list of conditions and the following disclaimer in -- -- the documentation and/or other materials provided with the -- -- distribution. -- -- 3. Neither the name of the copyright holder nor the names of its -- -- contributors may be used to endorse or promote products derived -- -- from this software without specific prior written permission. -- -- -- -- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -- -- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -- -- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -- -- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -- -- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -- -- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -- -- LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -- -- DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -- -- THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -- -- (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -- -- OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- -- -- ------------------------------------------------------------------------------ package body Bluetooth_Low_Energy.Beacon is function Make_Beacon_Packet (MAC : UInt8_Array; UUID : BLE_UUID; Major, Minor : UInt16; Power : Integer_8) return BLE_Packet is Pck : BLE_Packet; begin Set_Header (Pck, 16#42#); -- MAC Push (Pck, MAC); -- Flag length Push (Pck, UInt8 (2)); -- Flag type Push (Pck, UInt8 (1)); -- Flag Content Push (Pck, UInt8 (6)); -- Data length Push (Pck, UInt8 (16#1A#)); -- Data type Push (Pck, UInt8 (16#FF#)); -- Data header Push (Pck, (16#4C#, 16#00#, 16#02#, 16#15#)); -- UUID Push_UUID (Pck, UUID); -- Major Push (Pck, Major); -- Minor Push (Pck, Minor); -- Power Push (Pck, Power); return Pck; end Make_Beacon_Packet; end Bluetooth_Low_Energy.Beacon;
reznikmm/slimp
Ada
930
ads
-- Copyright (c) 2019 Maxim Reznik <[email protected]> -- -- SPDX-License-Identifier: MIT -- License-Filename: LICENSE ------------------------------------------------------------- package Slim.Messages.ANIC is type ANIC_Message is new Message with private; private subtype Byte is Ada.Streams.Stream_Element; type ANIC_Message is new Base_Message (Max_8 => 1, Max_16 => 0, Max_32 => 0, Max_64 => 0) with null record; overriding function Read (Data : not null access League.Stream_Element_Vectors.Stream_Element_Vector) return ANIC_Message; overriding procedure Write (Self : ANIC_Message; Tag : out Message_Tag; Data : out League.Stream_Element_Vectors.Stream_Element_Vector); overriding procedure Visit (Self : not null access ANIC_Message; Visiter : in out Slim.Message_Visiters.Visiter'Class); end Slim.Messages.ANIC;
reznikmm/matreshka
Ada
7,476
ads
------------------------------------------------------------------------------ -- -- -- Matreshka Project -- -- -- -- XML Processor -- -- -- -- Runtime Library Component -- -- -- ------------------------------------------------------------------------------ -- -- -- Copyright © 2012, Vadim Godunko <[email protected]> -- -- All rights reserved. -- -- -- -- Redistribution and use in source and binary forms, with or without -- -- modification, are permitted provided that the following conditions -- -- are met: -- -- -- -- * Redistributions of source code must retain the above copyright -- -- notice, this list of conditions and the following disclaimer. -- -- -- -- * Redistributions in binary form must reproduce the above copyright -- -- notice, this list of conditions and the following disclaimer in the -- -- documentation and/or other materials provided with the distribution. -- -- -- -- * Neither the name of the Vadim Godunko, IE nor the names of its -- -- contributors may be used to endorse or promote products derived from -- -- this software without specific prior written permission. -- -- -- -- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -- -- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -- -- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -- -- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -- -- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -- -- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED -- -- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -- -- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -- -- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -- -- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -- -- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- -- -- ------------------------------------------------------------------------------ -- $Revision$ $Date$ ------------------------------------------------------------------------------ with League.Strings; with Matreshka.XML_Schema.AST.Types; with XML.Schema; package Matreshka.XML_Schema.AST.Element_Declarations is pragma Preelaborate; type Type_Table (Is_Null : Boolean := True) is record case Is_Null is when False => Alternatives : Types.Type_Alternative_Lists.List; -- {alternatives} -- A sequence of Type Alternative components. Default_Type_Definition : Matreshka.XML_Schema.AST.Type_Alternative_Access; -- {default type definition} -- A Type Alternative component. Required. when True => null; end case; end record; type Element_Declaration_Node is new Matreshka.XML_Schema.AST.Types.Term_Node with record -- Properties: -- Annotations : Types.Annotation_Lists.List; -- {annotations} -- A sequence of Annotation components. Name : League.Strings.Universal_String; -- {name} -- An xs:NCName value. Required. Target_Namespace : League.Strings.Universal_String; -- {target namespace} -- An xs:anyURI value. Optional. Type_Definition : Matreshka.XML_Schema.AST.Type_Definition_Access; -- {type definition} -- A Type Definition component. Required. Type_Table : Element_Declarations.Type_Table; -- {type table} -- A Type Table property record. Optional. Scope : Types.Scope; -- {scope} -- A Scope property record. Required. Value_Constraint : Types.Value_Constraint; -- {value constraint} -- A Value Constraint property record. Optional. Nillable : Boolean; -- {nillable} -- An xs:boolean value. Required. Identity_Constraint_Definitions : Types.Identity_Constraint_Definition_Sets.List; -- {identity-constraint definitions} -- A set of Identity-Constraint Definition components. Substitution_Group_Affiliations : Types.Element_Declaration_Maps.Map; -- {substitution group affiliations} -- A set of Element Declaration components. Substitution_Group_Exclusions : XML.Schema.Derivation_Set; -- {substitution group exclusions} -- A subset of {extension, restriction}. Disallowed_Substitutions : XML.Schema.Derivation_Set; -- {disallowed substitutions} -- A subset of {substitution, extension, restriction}. Is_Abstract : Boolean; -- {abstract} -- An xs:boolean value. Required. -- Internal data. Type_Name : Matreshka.XML_Schema.AST.Qualified_Name; -- @type end record; overriding function Get_Type (Self : not null access Element_Declaration_Node) return XML.Schema.Component_Type; overriding function Get_Name (Self : not null access Element_Declaration_Node) return League.Strings.Universal_String; overriding function Get_Target_Namespace (Self : not null access Element_Declaration_Node) return League.Strings.Universal_String; overriding procedure Enter_Node (Self : not null access Element_Declaration_Node; Visitor : in out Matreshka.XML_Schema.Visitors.Abstract_Visitor'Class; Control : in out Matreshka.XML_Schema.Visitors.Traverse_Control); -- Dispatch call to corresponding subprogram of visitor interface. overriding procedure Leave_Node (Self : not null access Element_Declaration_Node; Visitor : in out Matreshka.XML_Schema.Visitors.Abstract_Visitor'Class; Control : in out Matreshka.XML_Schema.Visitors.Traverse_Control); -- Dispatch call to corresponding subprogram of visitor interface. overriding procedure Visit_Node (Self : not null access Element_Declaration_Node; Iterator : in out Matreshka.XML_Schema.Visitors.Abstract_Iterator'Class; Visitor : in out Matreshka.XML_Schema.Visitors.Abstract_Visitor'Class; Control : in out Matreshka.XML_Schema.Visitors.Traverse_Control); -- Dispatch call to corresponding subprogram of iterator interface. end Matreshka.XML_Schema.AST.Element_Declarations;
Rodeo-McCabe/orka
Ada
2,841
ads
-- SPDX-License-Identifier: Apache-2.0 -- -- Copyright (c) 2013 Felix Krause <[email protected]> -- -- Licensed under the Apache License, Version 2.0 (the "License"); -- you may not use this file except in compliance with the License. -- You may obtain a copy of the License at -- -- http://www.apache.org/licenses/LICENSE-2.0 -- -- Unless required by applicable law or agreed to in writing, software -- distributed under the License is distributed on an "AS IS" BASIS, -- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -- See the License for the specific language governing permissions and -- limitations under the License. with Glfw.Windows.Context; package Glfw.Windows.Hints is pragma Preelaborate; procedure Reset_To_Defaults; ----------------------------------------------------------------------------- -- Window related ----------------------------------------------------------------------------- procedure Set_Focused (Value : Boolean); procedure Set_Floating (Value : Boolean); procedure Set_Maximized (Value : Boolean); procedure Set_Resizable (Value : Boolean); procedure Set_Visible (Value : Boolean); procedure Set_Decorated (Value : Boolean); procedure Set_Focus_On_Show (Value : Boolean); procedure Set_Auto_Iconify (Value : Boolean); procedure Set_Center_On_Cursor (Value : Boolean); procedure Set_Scale_To_Monitor (Value : Boolean); procedure Set_Transparent_Framebuffer (Value : Boolean); ----------------------------------------------------------------------------- -- Framebuffer related ----------------------------------------------------------------------------- procedure Set_Color_Bits (Red, Green, Blue, Alpha : Natural); procedure Set_Depth_Bits (Value : Natural); procedure Set_Stencil_Bits (Value : Natural); procedure Set_Stereo (Value : Boolean); procedure Set_Samples (Value : Natural); procedure Set_SRGB_Capable (Value : Boolean); procedure Set_Refresh_Rate (Value : Natural); ----------------------------------------------------------------------------- -- Context related ----------------------------------------------------------------------------- procedure Set_Client_API (Value : Context.API_Kind); procedure Set_Minimum_OpenGL_Version (Major : Positive; Minor : Natural); procedure Set_Robustness (Value : Context.Robustness_Kind); procedure Set_Forward_Compat (Value : Boolean); procedure Set_Debug_Context (Value : Boolean); procedure Set_Profile (Value : Context.OpenGL_Profile_Kind); procedure Set_Release_Behavior (Value : Context.Release_Behavior); procedure Set_No_Error_Context (Value : Boolean); private -- To be able to use renames pragma Convention (C, Reset_To_Defaults); end Glfw.Windows.Hints;
zhmu/ananas
Ada
725
adb
-- { dg-do compile } -- { dg-options "-gnatwa" } package body Warn28 is function Id (X : Integer) return Integer is (2 * X); procedure TheProcedure1 (TheParameter : in Integer) is X : Integer; begin X := Id (TheParameter); if X < 3 then X := X ** 3; end if; end TheProcedure1; procedure Junk (It : Integer) is -- { dg-warning "formal parameter \"It\" is not referenced" } X : Integer := Id (34); begin if X < 3 then X := X ** 3; end if; end; procedure TheProcedure (TheParameter : in Integer) -- { dg-warning "formal parameter \"TheParameter\" is not referenced" } is begin null; end TheProcedure; end Warn28;
reznikmm/matreshka
Ada
16,969
adb
------------------------------------------------------------------------------ -- -- -- Matreshka Project -- -- -- -- Localization, Internationalization, Globalization for Ada -- -- -- -- Runtime Library Component -- -- -- ------------------------------------------------------------------------------ -- -- -- Copyright © 2009-2012, Vadim Godunko <[email protected]> -- -- All rights reserved. -- -- -- -- Redistribution and use in source and binary forms, with or without -- -- modification, are permitted provided that the following conditions -- -- are met: -- -- -- -- * Redistributions of source code must retain the above copyright -- -- notice, this list of conditions and the following disclaimer. -- -- -- -- * Redistributions in binary form must reproduce the above copyright -- -- notice, this list of conditions and the following disclaimer in the -- -- documentation and/or other materials provided with the distribution. -- -- -- -- * Neither the name of the Vadim Godunko, IE nor the names of its -- -- contributors may be used to endorse or promote products derived from -- -- this software without specific prior written permission. -- -- -- -- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -- -- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -- -- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -- -- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -- -- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -- -- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED -- -- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -- -- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -- -- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -- -- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -- -- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- -- -- ------------------------------------------------------------------------------ -- $Revision$ $Date$ ------------------------------------------------------------------------------ package body Matreshka.Internals.Utf16 is use Matreshka.Internals.Unicode; Utf16_Fixup : constant array (Utf16_Code_Unit range 0 .. 31) of Utf16_Code_Unit := (0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 16#2000#, 16#F800#, 16#F800#, 16#F800#, 16#F800#); -- Fixups for change order of Utf16 code units to compare in Unicode code -- point order. Surrogate_Kind_Mask : constant := 16#FC00#; Masked_High_Surrogate : constant := 16#D800#; Masked_Low_Surrogate : constant := 16#DC00#; -- Mask to fast detection of surrogates and masked values for high and low -- surrogates. UCS4_Fixup : constant := High_Surrogate_First * 16#400# + Low_Surrogate_First - 16#1_0000#; -- When code point is encoded as pair of surrogates its value computed as: -- -- C := (S (J) - HB) << 10 + S (J + 1) - LB + 0x10000 -- -- to optimize number of computations this expression is transformed to -- -- C := S (J) << 10 + S (J + 1) - (HB << 10 + LB - 0x10000) -- ^^^^^^^^^^^^^^^^^^^^^^^^^ -- This constant represents constant part of the expression. High_Surrogate_First_Store : constant := High_Surrogate_First - 16#1_0000# / 16#400#; -- Code point is converted to surrogate pair as: -- -- S (J) := HB + (C - 0x10000) >> 10 -- S (J + 1) := LB + (C - 0x10000) & 0x3FF -- -- to optimize implementation they are rewritten as: -- -- S (J + 1) := LB + C & 0x3FF -- S (J) := (HB - 0x10000 >> 10) + C >> 10 -- ^^^^^^^^^^^^^^^^^^^^ -- This constant represents constant part of the expression. ------------------- -- Compare_Order -- ------------------- function Compare_Order (Item : Utf16_Code_Unit) return Utf16_Code_Unit is begin return Item + Utf16_Fixup (Item / 16#800#); end Compare_Order; ---------------- -- Is_Greater -- ---------------- function Is_Greater (Left : Code_Unit_16; Right : Code_Unit_16) return Boolean is begin return Left + Utf16_Fixup (Left / 16#800#) > Right + Utf16_Fixup (Right / 16#800#); end Is_Greater; ------------- -- Is_Less -- ------------- function Is_Less (Left : Code_Unit_16; Right : Code_Unit_16) return Boolean is begin return Left + Utf16_Fixup (Left / 16#800#) < Right + Utf16_Fixup (Right / 16#800#); end Is_Less; -------------------- -- Unchecked_Next -- -------------------- procedure Unchecked_Next (Item : Utf16_String; Position : in out Utf16_String_Index; Code : out Matreshka.Internals.Unicode.Code_Point) is pragma Assert ((Position <= Item'Last and then Item (Position) not in High_Surrogate_First .. High_Surrogate_Last) or (Position + 1 <= Item'Last and then Item (Position) in High_Surrogate_First .. High_Surrogate_Last and then Item (Position + 1) in Low_Surrogate_First .. Low_Surrogate_Last)); pragma Suppress (Index_Check); pragma Suppress (Range_Check); -- Assertion checks both range and validity of source data; this check -- is stronger then run time checks. begin Code := Code_Point (Item (Position)); Position := Position + 1; if (Code and Surrogate_Kind_Mask) = Masked_High_Surrogate then Code := Code * 16#400# + Code_Point (Item (Position)) - UCS4_Fixup; Position := Position + 1; end if; end Unchecked_Next; -------------------- -- Unchecked_Next -- -------------------- procedure Unchecked_Next (Item : Unaligned_Utf16_String; Position : in out Utf16_String_Index; Code : out Matreshka.Internals.Unicode.Code_Point) is pragma Assert ((Position <= Item'Last and then Item (Position) not in High_Surrogate_First .. High_Surrogate_Last) or (Position + 1 <= Item'Last and then Item (Position) in High_Surrogate_First .. High_Surrogate_Last and then Item (Position + 1) in Low_Surrogate_First .. Low_Surrogate_Last)); pragma Suppress (Index_Check); pragma Suppress (Range_Check); -- Assertion checks both range and validity of source data; this check -- is stronger then run time checks. begin Code := Code_Point (Item (Position)); Position := Position + 1; if (Code and Surrogate_Kind_Mask) = Masked_High_Surrogate then Code := Code * 16#400# + Code_Point (Item (Position)) - UCS4_Fixup; Position := Position + 1; end if; end Unchecked_Next; -------------------- -- Unchecked_Next -- -------------------- procedure Unchecked_Next (Item : Utf16_String; Position : in out Utf16_String_Index) is pragma Assert ((Position <= Item'Last and then Item (Position) not in High_Surrogate_First .. High_Surrogate_Last) or (Position + 1 <= Item'Last and then Item (Position) in High_Surrogate_First .. High_Surrogate_Last and then Item (Position + 1) in Low_Surrogate_First .. Low_Surrogate_Last)); pragma Suppress (Index_Check); -- Assertion checks both range and validity of source data; this check -- is stronger then run time checks. Code : constant Code_Point := Code_Point (Item (Position)); begin Position := Position + 1; if (Code and Surrogate_Kind_Mask) = Masked_High_Surrogate then Position := Position + 1; end if; end Unchecked_Next; ------------------------ -- Unchecked_Previous -- ------------------------ procedure Unchecked_Previous (Item : Utf16_String; Position : in out Utf16_String_Index; Code : out Matreshka.Internals.Unicode.Code_Point) is pragma Assert ((Position in 1 .. Item'Last + 1 and then Item (Position - 1) not in Low_Surrogate_First .. Low_Surrogate_Last) or (Position in 2 .. Item'Last + 1 and then Item (Position - 1) in Low_Surrogate_First .. Low_Surrogate_Last and then Item (Position - 2) in High_Surrogate_First .. High_Surrogate_Last)); pragma Suppress (Index_Check); pragma Suppress (Range_Check); -- Assertion checks both range and validity of source data; this check -- is stronger then run time checks. begin Position := Position - 1; Code := Code_Point (Item (Position)); if (Code and Surrogate_Kind_Mask) = Masked_Low_Surrogate then Position := Position - 1; Code := Code_Point (Item (Position)) * 16#400# + Code - UCS4_Fixup; end if; end Unchecked_Previous; ------------------------ -- Unchecked_Previous -- ------------------------ procedure Unchecked_Previous (Item : Utf16_String; Position : in out Utf16_String_Index) is pragma Assert ((Position in 1 .. Item'Last + 1 and then Item (Position - 1) not in Low_Surrogate_First .. Low_Surrogate_Last) or (Position in 2 .. Item'Last + 1 and then Item (Position - 1) in Low_Surrogate_First .. Low_Surrogate_Last and then Item (Position - 2) in High_Surrogate_First .. High_Surrogate_Last)); pragma Suppress (Index_Check); -- Assertion checks both range and validity of source data; this check -- is stronger then run time checks. Code : Code_Point; begin Position := Position - 1; Code := Code_Point (Item (Position)); if (Code and Surrogate_Kind_Mask) = Masked_Low_Surrogate then Position := Position - 1; end if; end Unchecked_Previous; --------------------- -- Unchecked_Store -- --------------------- procedure Unchecked_Store (Item : in out Utf16_String; Position : in out Utf16_String_Index; Code : Code_Point) is pragma Assert ((Code <= 16#FFFF# and Position <= Item'Last) or (Code > 16#FFFF# and Position + 1 <= Item'Last)); pragma Suppress (Index_Check); pragma Suppress (Range_Check); -- Assertion checks both range and validity of source data; this check -- is stronger then run time checks. begin if Code <= 16#FFFF# then Item (Position) := Utf16_Code_Unit (Code); Position := Position + 1; else Item (Position) := Utf16_Code_Unit (High_Surrogate_First_Store + Code / 16#400#); Item (Position + 1) := Utf16_Code_Unit (Low_Surrogate_First + Code mod 16#400#); Position := Position + 2; end if; end Unchecked_Store; -------------------------------------------- -- Unchecked_Surrogate_Pair_To_Code_Point -- -------------------------------------------- function Unchecked_Surrogate_Pair_To_Code_Point (High : Utf16_Code_Unit; Low : Utf16_Code_Unit) return Matreshka.Internals.Unicode.Code_Point is pragma Assert (High in High_Surrogate_First .. High_Surrogate_Last); pragma Assert (Low in Low_Surrogate_First .. Low_Surrogate_Last); pragma Suppress (Range_Check); begin return Code_Unit_32 (High) * 16#400# + Code_Unit_32 (Low) - UCS4_Fixup; end Unchecked_Surrogate_Pair_To_Code_Point; ----------------------------- -- Unchecked_To_Code_Point -- ----------------------------- function Unchecked_To_Code_Point (Item : Utf16_String; Position : Utf16_String_Index) return Matreshka.Internals.Unicode.Code_Point is pragma Assert ((Position <= Item'Last and then Item (Position) not in High_Surrogate_First .. High_Surrogate_Last) or (Position + 1 <= Item'Last and then Item (Position) in High_Surrogate_First .. High_Surrogate_Last and then Item (Position + 1) in Low_Surrogate_First .. Low_Surrogate_Last)); pragma Suppress (Index_Check); pragma Suppress (Range_Check); -- Assertion checks both range and validity of source data; this check -- is stronger then run time checks. Code : constant Code_Point := Code_Point (Item (Position)); begin if (Code and Surrogate_Kind_Mask) = Masked_High_Surrogate then return Code * 16#400# + Code_Point (Item (Position + 1)) - UCS4_Fixup; else return Code; end if; end Unchecked_To_Code_Point; ----------------------------- -- Unchecked_Validate_Next -- ----------------------------- procedure Unchecked_Validate_Next (Item : Utf16_String; Position : in out Utf16_String_Index; Valid : out Boolean) is pragma Assert ((Position <= Item'Last and then Item (Position) not in High_Surrogate_First .. High_Surrogate_Last) or (Position + 1 <= Item'Last and then Item (Position) in High_Surrogate_First .. High_Surrogate_Last)); pragma Suppress (Index_Check); -- Assertion checks range. Code : constant Code_Point := Code_Point (Item (Position)); begin if (Code and Surrogate_Kind_Mask) = Masked_High_Surrogate then if (Item (Position + 1) and Surrogate_Kind_Mask) = Masked_Low_Surrogate then Valid := True; Position := Position + 2; else Valid := False; end if; elsif (Code and Surrogate_Kind_Mask) = Masked_Low_Surrogate then Valid := False; else Valid := True; Position := Position + 1; end if; end Unchecked_Validate_Next; ----------------------------- -- Unchecked_Validate_Next -- ----------------------------- procedure Unchecked_Validate_Next (Item : Unaligned_Utf16_String; Position : in out Utf16_String_Index; Code : out Matreshka.Internals.Unicode.Code_Point; Valid : out Boolean) is pragma Assert ((Position <= Item'Last and then Item (Position) not in High_Surrogate_First .. High_Surrogate_Last) or (Position + 1 <= Item'Last and then Item (Position) in High_Surrogate_First .. High_Surrogate_Last)); pragma Suppress (Index_Check); -- Assertion checks range. begin Code := Code_Point (Item (Position)); if (Code and Surrogate_Kind_Mask) = Masked_High_Surrogate then if (Item (Position + 1) and Surrogate_Kind_Mask) = Masked_Low_Surrogate then Code := Code * 16#400# + Code_Point (Item (Position + 1)) - UCS4_Fixup; Valid := True; Position := Position + 2; else Valid := False; end if; elsif (Code and Surrogate_Kind_Mask) = Masked_Low_Surrogate then Valid := False; else Valid := True; Position := Position + 1; end if; end Unchecked_Validate_Next; end Matreshka.Internals.Utf16;
damaki/libkeccak
Ada
3,628
ads
------------------------------------------------------------------------------- -- Copyright (c) 2019, Daniel King -- All rights reserved. -- -- Redistribution and use in source and binary forms, with or without -- modification, are permitted provided that the following conditions are met: -- * Redistributions of source code must retain the above copyright -- notice, this list of conditions and the following disclaimer. -- * Redistributions in binary form must reproduce the above copyright -- notice, this list of conditions and the following disclaimer in the -- documentation and/or other materials provided with the distribution. -- * The name of the copyright holder may not be used to endorse or promote -- Products derived from this software without specific prior written -- permission. -- -- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -- AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -- IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -- ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE FOR ANY -- DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -- (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -- LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND -- ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -- (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -- THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ------------------------------------------------------------------------------- -- @summary -- A reference implementation of the Keccak-f permutation. -- -- @description -- This package implements Keccak-p for an arbitrary lane size by following -- the Keccak specification for each operation (Theta, Rho, Pi, Chi, and Iota) -- as separate functions. -- -- This isn't the fastest implementation of Keccak, but is easier to verify -- against the specification and provides a reference implementation to which -- optimised implementations can be tested against for correctness. -- -- @group Keccak-f generic -- Bit-wise left rotate for Lane_Type. with function Rotate_Left (Value : in Lane_Type; Amount : in Natural) return Lane_Type; package Keccak.Generic_KeccakF.Reference_Permutation is generic -- Number of rounds. -- -- By default, the definition from The Keccak Reference is used. Num_Rounds : Round_Count := 12 + (2 * Lane_Size_Log); procedure Permute (A : in out State) with Global => null, Depends => (A => A); -- Permute the Keccak state. -- -- @param A The Keccak state to permute. private procedure Theta (A : in State; AR : out State) with Global => null, Depends => (AR => A), Inline; procedure Rho (A : in State; AR : out State) with Global => null, Depends => (AR => A), Inline; procedure Pi (A : in State; AR : out State) with Global => null, Depends => (AR => A), Inline; procedure Rho_Pi (A : in out State) with Global => null, Depends => (A => A), Inline; procedure Chi_Iota (A : in State; AR : out State; RI : in Round_Index) with Global => null, Depends => (AR => (A, RI)), Inline; end Keccak.Generic_KeccakF.Reference_Permutation;
burratoo/Acton
Ada
4,635
ads
------------------------------------------------------------------------------------------ -- -- -- OAK COMPONENTS -- -- -- -- OAK.AGENT.INTERRUPTS -- -- -- -- Copyright (C) 2013-2021, Patrick Bernardi -- -- -- ------------------------------------------------------------------------------------------ -- This package provides Oak's Interrupt Agents, the agent that executes -- interrupt handlers in Oak. An Interrupt Agent exists for each interrupt -- priority. The Agent extends the Oak Agent data structure to include -- interrupt specific components. with Oak.Agent.Storage; with Oak.Processor_Support_Package.Interrupts; use Oak.Processor_Support_Package.Interrupts; with Oak.Timers; use Oak.Timers; with System; use System; package Oak.Agent.Interrupts with Preelaborate is ----------- -- Types -- ----------- type Interrupt_Type is (External, Timer_Action); -- An interrupt agent runs handlers two form of interrupts: External -- interrupts that come from an interrupt controller (or on a simpler µC -- the processor) and the handler response for Timers. ---------------- -- Subprograms -- ----------------- procedure Interrupt_Done (Kernel : in Kernel_Id; Current_Agent : in Interrupt_Id); -- Handles an interrupt agent's completion, including the servicing of any -- open entries. function Interrupt_Kind (Agent : in Interrupt_Id) return Interrupt_Type; -- Returns the type of interrupt the Agent is handling. procedure New_Interrupt_Agent (Agent : out Interrupt_Id; Priority : in Any_Priority); -- Creates a new Interrupt Agent with the given parameters. Allocates the -- storage for the Task Agent data structure and any dependents. procedure Set_External_Id (For_Agent : in Interrupt_Id; Id : in External_Interrupt_Id) with Inline; -- Sets the external id of the external interrupt that the Agent will -- handle. procedure Set_Interrupt_Kind (For_Agent : in Interrupt_Id; Kind : in Interrupt_Type) with Inline; -- Sets the kind of interrupt that the Agent will handle. See the -- Interrupt_Type for the kinds of interrupts that the Agent can handle. procedure Set_Timer_To_Handle (Agent : in Interrupt_Id; Timer : in Oak_Timer_Id) with Inline; -- If the Agent will run the handler of a timer, it is specified here. function Timer_To_Handle (Agent : in Interrupt_Id) return Oak_Timer_Id; -- Return the Timer that will be handled by the Agent. private ------------------- -- Private Types -- ------------------- type Interrupt_Agent_Record is record -- Interrupt Agent components Interrupt_Kind : Interrupt_Type; -- The type of interrupt that will be handled. There are different -- handling for different type of interrupts. See the type for more -- details. External_Id : External_Interrupt_Id; -- The id associated with a given external interrupt. External -- interrupts come from outside the processor core and are tagged with -- an id to identify the source. Timer_To_Handle : Oak_Timer_Id; -- The timer that has an associated handler that needs running. end record; ----------------------------- -- Interrupt Agent Storage -- ----------------------------- package Interrupt_Pool is new Oak.Agent.Storage (Agent_Record_Type => Interrupt_Agent_Record, Agent_Id_Type => Interrupt_Id); use Interrupt_Pool; ------------------------- -- Private Subprograms -- ------------------------- procedure Interrupt_Run_Loop with No_Return; -- The run loop of the interrupt agent. -------------------------- -- Function Expressions -- -------------------------- function Interrupt_Kind (Agent : in Interrupt_Id) return Interrupt_Type is (Agent_Pool (Agent).Interrupt_Kind); function Timer_To_Handle (Agent : in Interrupt_Id) return Oak_Timer_Id is (Agent_Pool (Agent).Timer_To_Handle); end Oak.Agent.Interrupts;
reznikmm/matreshka
Ada
4,599
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.Tab_Index_Attributes is ------------ -- Create -- ------------ overriding function Create (Parameters : not null access Matreshka.DOM_Attributes.Attribute_L2_Parameters) return Form_Tab_Index_Attribute_Node is begin return Self : Form_Tab_Index_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_Tab_Index_Attribute_Node) return League.Strings.Universal_String is pragma Unreferenced (Self); begin return Matreshka.ODF_String_Constants.Tab_Index_Attribute; end Get_Local_Name; begin Matreshka.DOM_Documents.Register_Attribute (Matreshka.ODF_String_Constants.Form_URI, Matreshka.ODF_String_Constants.Tab_Index_Attribute, Form_Tab_Index_Attribute_Node'Tag); end Matreshka.ODF_Form.Tab_Index_Attributes;
reznikmm/matreshka
Ada
4,794
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_Page_Continuation_Elements; package Matreshka.ODF_Text.Page_Continuation_Elements is type Text_Page_Continuation_Element_Node is new Matreshka.ODF_Text.Abstract_Text_Element_Node and ODF.DOM.Text_Page_Continuation_Elements.ODF_Text_Page_Continuation with null record; overriding function Create (Parameters : not null access Matreshka.DOM_Elements.Element_L2_Parameters) return Text_Page_Continuation_Element_Node; overriding function Get_Local_Name (Self : not null access constant Text_Page_Continuation_Element_Node) return League.Strings.Universal_String; overriding procedure Enter_Node (Self : not null access Text_Page_Continuation_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_Page_Continuation_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_Page_Continuation_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.Page_Continuation_Elements;
tum-ei-rcs/StratoX
Ada
2,192
adb
-- Project: Strato -- System: Stratosphere Balloon Flight Controller -- Author: Martin Becker ([email protected]) -- @summary String functions package body MyStrings with SPARK_Mode is procedure StrCpySpace (outstring : out String; instring : String) is begin if instring'Length >= outstring'Length then -- trim outstring := instring (instring'First .. instring'First - 1 + outstring'Length); else -- pad declare lastidx : constant Natural := outstring'First + instring'Length - 1; begin outstring := (others => ' '); outstring (outstring'First .. lastidx) := instring; end; end if; end StrCpySpace; function RTrim (S : String) return String is begin for J in reverse S'Range loop if S (J) /= ' ' then return S (S'First .. J); end if; end loop; return ""; end RTrim; function LTrim (S : String) return String is begin for J in S'Range loop if S (J) /= ' ' then return S (J .. S'Last); end if; end loop; return ""; end LTrim; function Trim (S : String) return String is begin return LTrim (RTrim (S)); end Trim; function StrChr (S : String; C : Character) return Integer is begin for idx in S'Range loop if S (idx) = C then return idx; end if; end loop; return S'Last + 1; end StrChr; function Is_AlNum (c : Character) return Boolean is begin return (c in 'a' .. 'z') or (c in 'A' .. 'Z') or (c in '0' .. '9'); end Is_AlNum; function Strip_Non_Alphanum (s : String) return String with SPARK_Mode => Off is tmp : String (1 .. s'Length) := s; len : Integer := 0; begin for c in s'Range loop if Is_AlNum (s (c)) then len := len + 1; tmp (len) := s (c); end if; end loop; declare ret : constant String (1 .. len) := tmp (1 .. len); -- SPARK: "subtype constraint cannot depend on len" begin return ret; end; end Strip_Non_Alphanum; end MyStrings;
reznikmm/matreshka
Ada
41,127
adb
------------------------------------------------------------------------------ -- -- -- Matreshka Project -- -- -- -- Web Framework -- -- -- -- Tools Component -- -- -- ------------------------------------------------------------------------------ -- -- -- Copyright © 2015-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$ ------------------------------------------------------------------------------ with Asis.Clauses; with Asis.Compilation_Units; with Asis.Declarations; with Asis.Definitions; with Asis.Elements; with Asis.Expressions; with Asis.Iterator; with Asis.Statements; with League.String_Vectors; package body Properties.Tools is function Name_Image (Name : Asis.Name) return League.Strings.Universal_String; function Full_Type_View (Type_Definition : Asis.Type_Definition) return Asis.Type_Definition; -------------------------- -- Attribute_Definition -- -------------------------- function Attribute_Definition (Decl : Asis.Declaration; Attr : Wide_String) return Asis.Expression is Parent : constant Asis.Declaration := Enclosing_Declaration (Decl); Name : Asis.Name := Asis.Declarations.Names (Decl) (1); Image : constant Wide_String := Asis.Declarations.Defining_Name_Image (Name); begin case Asis.Elements.Declaration_Kind (Parent) is when Asis.A_Package_Declaration => declare use type Asis.Expression_Kinds; use type Asis.Representation_Clause_Kinds; use type Asis.Declaration_List; List : constant Asis.Declaration_List := Asis.Declarations.Visible_Part_Declarative_Items (Parent) & Asis.Declarations.Private_Part_Declarative_Items (Parent); begin for Item in List'Range loop if Asis.Elements.Representation_Clause_Kind (List (Item)) = Asis.An_Attribute_Definition_Clause then Name := Asis.Clauses.Representation_Clause_Name (List (Item)); if Asis.Elements.Expression_Kind (Name) = Asis.An_Attribute_Reference and then Asis.Expressions.Name_Image (Asis.Expressions.Prefix (Name)) = Image and then Asis.Expressions.Name_Image (Asis.Expressions.Attribute_Designator_Identifier (Name)) = Attr then return Asis.Clauses.Representation_Clause_Expression (List (Item)); end if; end if; end loop; end; when others => null; end case; return Asis.Nil_Element; end Attribute_Definition; -------------------------------- -- Array_Component_Definition -- -------------------------------- function Array_Component_Definition (Type_Definition : Asis.Type_Definition) return Asis.Component_Definition is Subtipe_Indication : Asis.Subtype_Indication; Mark : Asis.Expression; Decl : Asis.Declaration; View : Asis.Type_Definition := Type_Declaration_View (Asis.Elements.Enclosing_Element (Type_Definition)); begin if Asis.Elements.Type_Kind (View) in Asis.An_Access_Type_Definition then Subtipe_Indication := Asis.Definitions.Access_To_Object_Definition (View); Mark := Asis.Definitions.Subtype_Mark (Subtipe_Indication); Decl := Corresponding_Declaration (Mark); View := Asis.Declarations.Type_Declaration_View (Decl); end if; return Asis.Definitions.Array_Component_Definition (View); end Array_Component_Definition; ----------- -- Comma -- ----------- function Comma (Left, Right : League.Strings.Universal_String) return League.Strings.Universal_String is use type League.Strings.Universal_String; begin if Left.Is_Empty then return Right; elsif Right.Is_Empty then return Left; else return Left & "," & Right; end if; end Comma; ------------------------------- -- Corresponding_Declaration -- ------------------------------- function Corresponding_Declaration (Name : Asis.Expression) return Asis.Declaration is Mark : Asis.Subtype_Mark := Name; begin case Asis.Elements.Expression_Kind (Mark) is when Asis.A_Selected_Component => Mark := Asis.Expressions.Selector (Mark); when others => null; end case; return Asis.Expressions.Corresponding_Name_Declaration (Mark); end Corresponding_Declaration; ------------------------ -- Corresponding_Type -- ------------------------ function Corresponding_Type (Declaration : Asis.Declaration) return Asis.Declaration is List : constant Asis.Declaration_List := Asis.Declarations.Parameter_Profile (Declaration); View : constant Asis.Element := Asis.Declarations.Object_Declaration_View (List (List'First)); Mark : Asis.Subtype_Mark; begin case Asis.Elements.Access_Definition_Kind (View) is when Asis.An_Anonymous_Access_To_Variable | Asis.An_Anonymous_Access_To_Constant => Mark := Asis.Definitions.Anonymous_Access_To_Object_Subtype_Mark (View); when others => Mark := View; end case; return Corresponding_Declaration (Mark); end Corresponding_Type; ----------------------------------- -- Corresponding_Type_Components -- ----------------------------------- function Corresponding_Type_Components (Definition : Asis.Definition) return Asis.Declaration_List is function Filter (List : Asis.Record_Component_List) return Asis.Declaration_List; -- Filter out anything except component declaration, flatten variants. function Flatten_Variant_List (List : Asis.Variant_List) return Asis.Declaration_List; -- The same for given Variant_List ------------ -- Filter -- ------------ function Filter (List : Asis.Record_Component_List) return Asis.Declaration_List is use type Asis.Record_Component_List; begin for J in List'Range loop case Asis.Elements.Element_Kind (List (J)) is when Asis.A_Declaration => null; when Asis.A_Clause => return List (List'First .. J - 1) & Filter (List (J + 1 .. List'Last)); when Asis.A_Definition => case Asis.Elements.Definition_Kind (List (J)) is when Asis.A_Variant_Part => return List (List'First .. J - 1) & Corresponding_Type_Components (List (J)) & Filter (List (J + 1 .. List'Last)); when others => return List (List'First .. J - 1) & Filter (List (J + 1 .. List'Last)); end case; when others => raise Constraint_Error; end case; end loop; return List; end Filter; -------------------------- -- Flatten_Variant_List -- -------------------------- function Flatten_Variant_List (List : Asis.Variant_List) return Asis.Declaration_List is Length : Natural := 0; begin for J in List'Range loop declare X : constant Asis.Declaration_List := Asis.Definitions.Record_Components (List (J)); begin Length := Length + X'Length; end; end loop; declare Result : Asis.Declaration_List (1 .. Length); begin Length := 0; for J in List'Range loop declare X : constant Asis.Declaration_List := Asis.Definitions.Record_Components (List (J)); begin Result (Length + 1 .. Length + X'Length) := X; Length := Length + X'Length; end; end loop; return Filter (Result); end; end Flatten_Variant_List; Def_Kind : constant Asis.Definition_Kinds := Asis.Elements.Definition_Kind (Definition); Type_Kind : constant Asis.Type_Kinds := Asis.Elements.Type_Kind (Definition); begin case Def_Kind is when Asis.A_Null_Record_Definition => return Asis.Nil_Element_List; when Asis.A_Private_Type_Definition | Asis.A_Tagged_Private_Type_Definition => return Corresponding_Type_Components (Full_Type_View (Definition)); when Asis.A_Record_Definition => return Filter (Asis.Definitions.Record_Components (Definition)); when Asis.A_Type_Definition => case Type_Kind is when Asis.A_Derived_Record_Extension_Definition | Asis.A_Record_Type_Definition | Asis.A_Tagged_Record_Type_Definition => return Corresponding_Type_Components (Asis.Definitions.Record_Definition (Definition)); when Asis.An_Interface_Type_Definition => return Asis.Nil_Element_List; when Asis.A_Derived_Type_Definition => return Corresponding_Type_Components (Type_Declaration_View (Asis.Elements.Enclosing_Element (Definition))); when others => raise Program_Error; end case; when Asis.A_Variant_Part => return Flatten_Variant_List (Asis.Definitions.Variants (Definition)); when others => raise Program_Error; end case; end Corresponding_Type_Components; -------------------------------------- -- Corresponding_Type_Discriminants -- -------------------------------------- function Corresponding_Type_Discriminants (Definition : Asis.Definition) return Asis.Declaration_List is function Discriminants (Decl : Asis.Declaration) return Asis.Declaration_List; function Parent_Discriminants (Parent : Asis.Subtype_Indication) return Asis.Declaration_List; ------------------- -- Discriminants -- ------------------- function Discriminants (Decl : Asis.Declaration) return Asis.Declaration_List is Kind : constant Asis.Declaration_Kinds := Asis.Elements.Declaration_Kind (Decl); begin case Kind is when Asis.A_Full_Type_Declaration | Asis.A_Private_Extension_Declaration => declare Part : constant Asis.Element := Asis.Declarations.Discriminant_Part (Decl); View : constant Asis.Element := Asis.Declarations.Type_Declaration_View (Decl); View_Kind : constant Asis.Type_Kinds := Asis.Elements.Type_Kind (View); Parent : Asis.Subtype_Indication; Constr : Asis.Constraint; begin case Asis.Elements.Definition_Kind (Part) is when Asis.A_Known_Discriminant_Part => return Asis.Definitions.Discriminants (Part); when others => null; end case; case View_Kind is when Asis.A_Derived_Type_Definition | Asis.A_Derived_Record_Extension_Definition => Parent := Asis.Definitions.Parent_Subtype_Indication (View); Constr := Asis.Definitions.Subtype_Constraint (Parent); if Asis.Elements.Is_Nil (Constr) then return Parent_Discriminants (Parent); else return Asis.Nil_Element_List; end if; when others => null; end case; end; when others => null; end case; return Asis.Nil_Element_List; end Discriminants; -------------------------- -- Parent_Discriminants -- -------------------------- function Parent_Discriminants (Parent : Asis.Subtype_Indication) return Asis.Declaration_List is Mark : constant Asis.Subtype_Mark := Asis.Definitions.Subtype_Mark (Parent); Decl : constant Asis.Declaration := Corresponding_Declaration (Mark); begin return Discriminants (Decl); end Parent_Discriminants; Decl : constant Asis.Declaration := Asis.Elements.Enclosing_Element (Definition); begin return Discriminants (Decl); end Corresponding_Type_Discriminants; ------------------------------------ -- Corresponding_Type_Subprograms -- ------------------------------------ function Corresponding_Type_Subprograms (Definition : Asis.Definition) return Asis.Declaration_List is use type Asis.Declaration_Kinds; Decl : constant Asis.Declaration := Asis.Elements.Enclosing_Element (Definition); Pkg : constant Asis.Element := Asis.Elements.Enclosing_Element (Decl); begin if Asis.Elements.Declaration_Kind (Pkg) = Asis.A_Package_Declaration then declare use type Asis.Element_List; List : Asis.Element_List := Asis.Declarations.Visible_Part_Declarative_Items (Pkg) & Asis.Declarations.Private_Part_Declarative_Items (Pkg); Last : Natural := 0; begin for J in List'Range loop if Asis.Elements.Declaration_Kind (List (J)) in Asis.A_Procedure_Declaration | Asis.A_Null_Procedure_Declaration | Asis.A_Function_Declaration | Asis.An_Expression_Function_Declaration and then Is_Primitive_Subprogram (Definition, List (J)) then Last := Last + 1; List (Last) := List (J); end if; end loop; return List (1 .. Last); end; else return Asis.Nil_Element_List; end if; end Corresponding_Type_Subprograms; --------------------------- -- Enclosing_Declaration -- --------------------------- function Enclosing_Declaration (X : Asis.Element) return Asis.Declaration is use type Asis.Element_Kinds; Parent : Asis.Element := Asis.Elements.Enclosing_Element (X); begin while not Asis.Elements.Is_Nil (Parent) and then Asis.Elements.Element_Kind (Parent) /= Asis.A_Declaration loop Parent := Asis.Elements.Enclosing_Element (Parent); end loop; return Parent; end Enclosing_Declaration; -------------------- -- Full_Type_View -- -------------------- function Full_Type_View (Type_Definition : Asis.Type_Definition) return Asis.Type_Definition is Decl : Asis.Declaration := Asis.Elements.Enclosing_Element (Type_Definition); begin while Asis.Elements.Declaration_Kind (Decl) in Asis.An_Incomplete_Type_Declaration | Asis.A_Tagged_Incomplete_Type_Declaration | Asis.A_Private_Type_Declaration | Asis.A_Private_Extension_Declaration loop Decl := Asis.Declarations.Corresponding_Type_Completion (Decl); end loop; return Asis.Declarations.Type_Declaration_View (Decl); end Full_Type_View; ---------------- -- Get_Aspect -- ---------------- function Get_Aspect (Element : Asis.Declaration; Name : Wide_String) return Wide_String is Mark : Asis.Expression; List : constant Asis.Declaration_List := Asis.Declarations.Aspect_Specifications (Element); begin for J in List'Range loop Mark := Asis.Definitions.Aspect_Mark (List (J)); if Asis.Expressions.Name_Image (Mark) = Name then declare Exp : constant Asis.Expression := Asis.Definitions.Aspect_Definition (List (J)); begin case Asis.Elements.Expression_Kind (Exp) is when Asis.An_Integer_Literal | Asis.A_Real_Literal => return Asis.Expressions.Value_Image (Exp); when Asis.A_String_Literal => declare Result : constant Wide_String := Asis.Expressions.Value_Image (Exp); begin return Result (2 .. Result'Last - 1); end; when others => return Asis.Expressions.Name_Image (Exp); end case; end; end if; end loop; return ""; end Get_Aspect; ------------------- -- Get_Dimension -- ------------------- function Get_Dimension (Exp : Asis.Expression) return Natural is Tipe : Asis.Declaration := Asis.Expressions.Corresponding_Expression_Type (Exp); View : Asis.Definition; begin if Asis.Elements.Declaration_Kind (Tipe) in Asis.A_Private_Type_Declaration then Tipe := Asis.Declarations.Corresponding_Type_Completion (Tipe); end if; if Asis.Elements.Is_Nil (Tipe) then declare Enclosing : constant Asis.Declaration := Asis.Elements.Enclosing_Element (Exp); begin if Asis.Elements.Declaration_Kind (Enclosing) in Asis.An_Object_Declaration then View := Asis.Declarations.Object_Declaration_View (Enclosing); else return 0; end if; end; else View := Asis.Declarations.Type_Declaration_View (Tipe); end if; if Asis.Elements.Definition_Kind (View) in Asis.A_Subtype_Indication then declare Constraint : constant Asis.Constraint := Asis.Definitions.Subtype_Constraint (View); begin if Asis.Elements.Is_Nil (Constraint) then raise Constraint_Error; else declare Ranges : constant Asis.Discrete_Range_List := Asis.Definitions.Discrete_Ranges (Constraint); begin return Ranges'Length; end; end if; end; end if; loop case Asis.Elements.Type_Kind (View) is when Asis.A_Constrained_Array_Definition => return Asis.Definitions .Discrete_Subtype_Definitions (View)'Length; when Asis.An_Unconstrained_Array_Definition => return Asis.Definitions.Index_Subtype_Definitions (View)'Length; when Asis.A_Derived_Type_Definition => declare SI : constant Asis.Subtype_Indication := Asis.Definitions.Parent_Subtype_Indication (View); Mark : Asis.Subtype_Mark := Asis.Definitions.Subtype_Mark (SI); Decl : Asis.Declaration; begin if Asis.Elements.Expression_Kind (Mark) in Asis.A_Selected_Component then Mark := Asis.Expressions.Selector (Mark); end if; Decl := Asis.Expressions.Corresponding_Name_Declaration (Mark); View := Asis.Declarations.Type_Declaration_View (Decl); end; when others => raise Constraint_Error; end case; end loop; end Get_Dimension; ---------------------------- -- Has_Controlling_Result -- ---------------------------- function Has_Controlling_Result (Func : Asis.Declaration) return Boolean is Result_Type : Asis.Element; Type_Decl : Asis.Declaration; Type_Def : Asis.Type_Definition; begin if Asis.Elements.Declaration_Kind (Func) not in Asis.A_Function_Declaration then return False; end if; Result_Type := Asis.Declarations.Result_Profile (Func); if Asis.Elements.Expression_Kind (Result_Type) not in Asis.An_Identifier then -- TODO: Check others cases return False; end if; Type_Decl := Asis.Expressions.Corresponding_Name_Declaration (Result_Type); if Asis.Elements.Declaration_Kind (Type_Decl) not in Asis.An_Ordinary_Type_Declaration | Asis.A_Private_Type_Declaration then return False; end if; Type_Def := Asis.Declarations.Type_Declaration_View (Type_Decl); if Asis.Elements.Definition_Kind (Type_Def) not in Asis.A_Tagged_Private_Type_Definition then return False; end if; return Asis.Elements.Is_Equal (Asis.Elements.Enclosing_Element (Func), Asis.Elements.Enclosing_Element (Type_Decl)); end Has_Controlling_Result; -------------- -- Is_Array -- -------------- function Is_Array (Exp : Asis.Expression) return Boolean is Decl : constant Asis.Declaration := Asis.Expressions.Corresponding_Expression_Type (Exp); View : Asis.Definition; Kind : Asis.Type_Kinds := Asis.Not_A_Type_Definition; begin if not Asis.Elements.Is_Nil (Decl) then View := Type_Declaration_View (Decl); Kind := Asis.Elements.Type_Kind (View); end if; return Kind in Asis.An_Unconstrained_Array_Definition | Asis.A_Constrained_Array_Definition; end Is_Array; ------------------- -- Is_Equal_Type -- ------------------- function Is_Equal_Type (Left : Asis.Declaration; Right : Asis.Declaration) return Boolean is function Up (X : Asis.Declaration) return Asis.Declaration; -------- -- Up -- -------- function Up (X : Asis.Declaration) return Asis.Declaration is begin case Asis.Elements.Declaration_Kind (X) is when Asis.An_Ordinary_Type_Declaration | Asis.A_Task_Type_Declaration | Asis.A_Protected_Type_Declaration => declare CT : constant Asis.Declaration := Asis.Declarations.Corresponding_Type_Declaration (X); begin case Asis.Elements.Declaration_Kind (CT) is when Asis.An_Incomplete_Type_Declaration | Asis.A_Tagged_Incomplete_Type_Declaration => return X; when Asis.A_Private_Type_Declaration | Asis.A_Private_Extension_Declaration => return CT; when others => return X; end case; end; when Asis.An_Incomplete_Type_Declaration | Asis.A_Tagged_Incomplete_Type_Declaration => declare CT : constant Asis.Declaration := Asis.Declarations.Corresponding_Type_Declaration (X); begin case Asis.Elements.Declaration_Kind (CT) is when Asis.A_Private_Type_Declaration | Asis.A_Private_Extension_Declaration => return CT; when others => return Up (CT); end case; end; when others => return X; end case; end Up; Left_Up : constant Asis.Declaration := Up (Left); Right_Up : constant Asis.Declaration := Up (Right); begin return Asis.Elements.Is_Equal (Left_Up, Right_Up); end Is_Equal_Type; ----------------------------- -- Is_Primitive_Subprogram -- ----------------------------- function Is_Primitive_Subprogram (Definition : Asis.Definition; Subprogram : Asis.Declaration) return Boolean is List : constant Asis.Declaration_List := Asis.Declarations.Parameter_Profile (Subprogram); begin if List'Length >= 1 then declare use type Asis.Expression_Kinds; Decl : Asis.Declaration; First : constant Asis.Element := Asis.Declarations.Object_Declaration_View (List (List'First)); begin if Asis.Elements.Expression_Kind (First) = Asis.An_Identifier then Decl := Asis.Expressions.Corresponding_Name_Declaration (First); return Is_Equal_Type (Asis.Elements.Enclosing_Element (Definition), Decl); end if; end; end if; return False; end Is_Primitive_Subprogram; --------------------- -- Is_Array_Buffer -- --------------------- function Is_Array_Buffer (Element : Asis.Declaration) return Boolean is Env : constant Asis.Element := Asis.Elements.Enclosing_Element (Element); Name : constant Asis.Program_Text := Asis.Declarations.Defining_Name_Image (Asis.Declarations.Names (Element) (1)); procedure Pre_Operation (Element : Asis.Element; Control : in out Asis.Traverse_Control; State : in out Boolean); procedure Post_Operation (Element : Asis.Element; Control : in out Asis.Traverse_Control; State : in out Boolean) is null; ------------------- -- Pre_Operation -- ------------------- procedure Pre_Operation (Element : Asis.Element; Control : in out Asis.Traverse_Control; State : in out Boolean) is use type Asis.Pragma_Kinds; begin if Asis.Elements.Pragma_Kind (Element) = Asis.An_Unknown_Pragma then declare Image : constant Asis.Program_Text := Asis.Elements.Pragma_Name_Image (Element); begin if Image = "JavaScript_Array_Buffer" then declare Args : constant Asis.Association_List := Asis.Elements.Pragma_Argument_Associations (Element); Arg : Asis.Expression; begin pragma Assert (Args'Length = 1, "Expected one argument in pragma" &" JavaScript_Array_Buffer"); Arg := Asis.Expressions.Actual_Parameter (Args (1)); if Name = Asis.Expressions.Name_Image (Arg) then State := True; Control := Asis.Terminate_Immediately; end if; end; end if; end; elsif not Asis.Elements.Is_Identical (Element, Env) then Control := Asis.Abandon_Children; end if; end Pre_Operation; procedure Search_Array_Buffer_Pragma is new Asis.Iterator.Traverse_Element (State_Information => Boolean, Pre_Operation => Pre_Operation, Post_Operation => Post_Operation); Control : Asis.Traverse_Control := Asis.Continue; Found : Boolean := False; begin Search_Array_Buffer_Pragma (Env, Control, Found); return Found; end Is_Array_Buffer; ---------- -- Join -- ---------- function Join (Left, Right : League.Strings.Universal_String) return League.Strings.Universal_String is use type League.Strings.Universal_String; begin return Left & Right; end Join; -------------------------- -- Library_Level_Header -- -------------------------- function Library_Level_Header (Unit : Asis.Compilation_Unit) return League.Strings.Universal_String is procedure Append_Dependencies (Unit : Asis.Compilation_Unit); procedure Append (Unit : Asis.Compilation_Unit); procedure Check_And_Append (Name : Asis.Name); function Body_Context_Clause_Elements (Unit : Asis.Compilation_Unit) return Asis.Context_Clause_List; function To_Module_Name (Unit : Asis.Compilation_Unit) return League.Strings.Universal_String; function To_Unit (Name : Asis.Name) return Asis.Compilation_Unit; Text : League.Strings.Universal_String; Deps : League.String_Vectors.Universal_String_Vector; ------------ -- Append -- ------------ procedure Append (Unit : Asis.Compilation_Unit) is Name : constant League.Strings.Universal_String := To_Module_Name (Unit); begin if Deps.Index (Name) = 0 then Deps.Append (Name); end if; end Append; ------------------------- -- Append_Dependencies -- ------------------------- procedure Append_Dependencies (Unit : Asis.Compilation_Unit) is use type Asis.Context_Clause_List; Parent : constant Asis.Compilation_Unit := Asis.Compilation_Units.Corresponding_Parent_Declaration (Unit); List : constant Asis.Context_Clause_List := Asis.Elements.Context_Clause_Elements (Unit) & Body_Context_Clause_Elements (Unit); begin Append (Parent); for Clause of List loop case Asis.Elements.Clause_Kind (Clause) is when Asis.A_With_Clause => declare Names : constant Asis.Name_List := Asis.Clauses.Clause_Names (Clause); begin if not Asis.Elements.Has_Limited (Clause) then for Name of Names loop Check_And_Append (Name); end loop; end if; end; when others => null; end case; end loop; end Append_Dependencies; ---------------------------------- -- Body_Context_Clause_Elements -- ---------------------------------- function Body_Context_Clause_Elements (Unit : Asis.Compilation_Unit) return Asis.Context_Clause_List is Impl : constant Asis.Compilation_Unit := Asis.Compilation_Units.Corresponding_Body (Unit); begin if Asis.Compilation_Units.Is_Nil (Impl) then return Asis.Nil_Element_List; else return Asis.Elements.Context_Clause_Elements (Impl); end if; end Body_Context_Clause_Elements; --------------------- -- Is_Ada_Numerics -- --------------------- function Is_Ada_Numerics (Name : Asis.Name) return Boolean is begin return Name_Image (Name).Starts_With ("Ada.Numerics"); end Is_Ada_Numerics; --------------- -- Is_WebAPI -- --------------- function Is_WebAPI (Name : Asis.Name) return Boolean is begin return Name_Image (Name).Starts_With ("WebAPI"); end Is_WebAPI; ---------------- -- Is_Generic -- ---------------- function Is_Generic (Unit : Asis.Compilation_Unit) return Boolean is begin return Asis.Compilation_Units.Unit_Kind (Unit) in Asis.A_Generic_Unit_Declaration; end Is_Generic; ----------------- -- Is_Renaming -- ----------------- function Is_Renaming (Unit : Asis.Compilation_Unit) return Boolean is begin return Asis.Compilation_Units.Unit_Kind (Unit) in Asis.A_Renaming; end Is_Renaming; ---------------------- -- Check_And_Append -- ---------------------- procedure Check_And_Append (Name : Asis.Name) is Unit : constant Asis.Compilation_Unit := To_Unit (Name); begin if Is_Generic (Unit) or else Is_WebAPI (Name) or else Is_Ada_Numerics (Name) then return; elsif Is_Renaming (Unit) then Append_Dependencies (Unit); return; end if; Append (Unit); end Check_And_Append; -------------------- -- To_Module_Name -- -------------------- function To_Module_Name (Unit : Asis.Compilation_Unit) return League.Strings.Universal_String is Full_Name : constant League.Strings.Universal_String := League.Strings.From_UTF_16_Wide_String (Asis.Compilation_Units.Unit_Full_Name (Unit)).To_Lowercase; List : constant League.String_Vectors.Universal_String_Vector := Full_Name.Split ('.'); begin return List.Join ('-'); end To_Module_Name; ------------- -- To_Unit -- ------------- function To_Unit (Name : Asis.Name) return Asis.Compilation_Unit is Decl : Asis.Declaration; begin case Asis.Elements.Expression_Kind (Name) is when Asis.A_Selected_Component => Decl := Asis.Expressions.Corresponding_Name_Declaration (Asis.Expressions.Selector (Name)); when Asis.An_Identifier => Decl := Asis.Expressions.Corresponding_Name_Declaration (Name); when others => raise Constraint_Error; end case; return Asis.Elements.Enclosing_Compilation_Unit (Decl); end To_Unit; begin Text.Append ("define(['"); Append_Dependencies (Unit); Text.Append (Deps.Join ("', '")); Text.Append ("'], function(_ec) {"); return Text; end Library_Level_Header; ---------------- -- Name_Image -- ---------------- function Name_Image (Name : Asis.Name) return League.Strings.Universal_String is procedure Prepend (Text : Asis.Program_Text); Item : Asis.Name := Name; Result : League.Strings.Universal_String; ------------- -- Prepend -- ------------- procedure Prepend (Text : Asis.Program_Text) is begin Result.Prepend (League.Strings.From_UTF_16_Wide_String (Text)); end Prepend; begin loop case Asis.Elements.Expression_Kind (Item) is when Asis.An_Identifier => Prepend (Asis.Expressions.Name_Image (Item)); return Result; when Asis.A_Selected_Component => Prepend (Asis.Expressions.Name_Image (Asis.Expressions.Selector (Item))); Prepend ("."); Item := Asis.Expressions.Prefix (Item); when others => raise Program_Error; end case; end loop; end Name_Image; ----------------------- -- Parameter_Profile -- ----------------------- function Parameter_Profile (Prefix : Asis.Expression) return Asis.Parameter_Specification_List is Tipe : Asis.Declaration; Stmt : constant Asis.Statement := Asis.Elements.Enclosing_Element (Prefix); Entity : Asis.Declaration := Asis.Statements.Corresponding_Called_Entity (Stmt); begin loop if Asis.Elements.Is_Nil (Entity) then exit; else if Asis.Elements.Declaration_Kind (Entity) in Asis.A_Generic_Instantiation then Entity := Asis.Declarations.Corresponding_Declaration (Entity); else return Asis.Declarations.Parameter_Profile (Entity); end if; end if; end loop; Tipe := Asis.Expressions.Corresponding_Expression_Type_Definition (Prefix); if Asis.Elements.Is_Nil (Tipe) then raise Constraint_Error; else return Asis.Definitions.Access_To_Subprogram_Parameter_Profile (Tipe); end if; end Parameter_Profile; --------------------------- -- Type_Declaration_View -- --------------------------- function Type_Declaration_View (Declaration : Asis.Declaration) return Asis.Definition is First : constant Asis.Declaration := Asis.Declarations.Corresponding_First_Subtype (Declaration); View : Asis.Element := Asis.Declarations.Type_Declaration_View (First); begin loop View := Full_Type_View (View); case Asis.Elements.Type_Kind (View) is when Asis.A_Derived_Type_Definition => declare SI : constant Asis.Subtype_Indication := Asis.Definitions.Parent_Subtype_Indication (View); Mark : Asis.Subtype_Mark := Asis.Definitions.Subtype_Mark (SI); Decl : Asis.Declaration; begin if Asis.Elements.Expression_Kind (Mark) in Asis.A_Selected_Component then Mark := Asis.Expressions.Selector (Mark); end if; Decl := Asis.Expressions.Corresponding_Name_Declaration (Mark); View := Asis.Declarations.Type_Declaration_View (Decl); end; when others => return View; end case; end loop; end Type_Declaration_View; end Properties.Tools;
reznikmm/matreshka
Ada
5,031
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.Literal_Reals.Collections is pragma Preelaborate; package UML_Literal_Real_Collections is new AMF.Generic_Collections (UML_Literal_Real, UML_Literal_Real_Access); type Set_Of_UML_Literal_Real is new UML_Literal_Real_Collections.Set with null record; Empty_Set_Of_UML_Literal_Real : constant Set_Of_UML_Literal_Real; type Ordered_Set_Of_UML_Literal_Real is new UML_Literal_Real_Collections.Ordered_Set with null record; Empty_Ordered_Set_Of_UML_Literal_Real : constant Ordered_Set_Of_UML_Literal_Real; type Bag_Of_UML_Literal_Real is new UML_Literal_Real_Collections.Bag with null record; Empty_Bag_Of_UML_Literal_Real : constant Bag_Of_UML_Literal_Real; type Sequence_Of_UML_Literal_Real is new UML_Literal_Real_Collections.Sequence with null record; Empty_Sequence_Of_UML_Literal_Real : constant Sequence_Of_UML_Literal_Real; private Empty_Set_Of_UML_Literal_Real : constant Set_Of_UML_Literal_Real := (UML_Literal_Real_Collections.Set with null record); Empty_Ordered_Set_Of_UML_Literal_Real : constant Ordered_Set_Of_UML_Literal_Real := (UML_Literal_Real_Collections.Ordered_Set with null record); Empty_Bag_Of_UML_Literal_Real : constant Bag_Of_UML_Literal_Real := (UML_Literal_Real_Collections.Bag with null record); Empty_Sequence_Of_UML_Literal_Real : constant Sequence_Of_UML_Literal_Real := (UML_Literal_Real_Collections.Sequence with null record); end AMF.UML.Literal_Reals.Collections;
reznikmm/matreshka
Ada
1,675
adb
with Ada.Text_IO; with Ada.Streams.Stream_IO.C_Streams; with Interfaces.C_Streams; with GNAT.Sockets; with League.Strings; with Styx.Debug; with Styx.Request_Decoders; with Styx.Reply_Encoders; with Styx.Request_Visiters; with Styx.Messages.Attaches; with Styx.Messages.Authes; with Styx.Messages.Clunks; with Styx.Messages.Opens; with Styx.Messages.Reads; with Styx.Messages.Stats; with Styx.Messages.Versions; with Styx.Messages.Walks; with Hello_World; procedure Main is Address : GNAT.Sockets.Sock_Addr_Type; Server : GNAT.Sockets.Socket_Type; Socket : GNAT.Sockets.Socket_Type; Input : GNAT.Sockets.Stream_Access; Decoder : Styx.Request_Decoders.Decoder; Debug : Styx.Debug.Request_Debuger; Cmd : Styx.Messages.Request_Access; Ok : Boolean; begin Ada.Text_IO.Put_Line (Ada.Text_IO.Standard_Error, "Started. Try:"); Ada.Text_IO.Put_Line (Ada.Text_IO.Standard_Error, "mount -t 9p 127.0.0.1 /mnt/bt/ -oport=11111"); Decoder.Initialize; GNAT.Sockets.Create_Socket (Server); -- Address.Port := 564; Address.Port := 11111; GNAT.Sockets.Bind_Socket (Server, Address); GNAT.Sockets.Listen_Socket (Server); GNAT.Sockets.Accept_Socket (Server, Socket, Address); Ada.Text_IO.Put_Line (Ada.Text_IO.Standard_Error, "Accept_Socket"); Input := GNAT.Sockets.Stream (Socket); declare Handler : Hello_World.Request_Handler (Input); begin Handler.Initialize; loop Decoder.Decode (Input, Cmd, Ok); exit when not Ok; Styx.Messages.Visit (Debug, Cmd.all); Styx.Messages.Visit (Handler, Cmd.all); end loop; end; end Main;
zhmu/ananas
Ada
15,267
ads
------------------------------------------------------------------------------ -- -- -- GNAT LIBRARY COMPONENTS -- -- -- -- A D A . C O N T A I N E R S . B O U N D E D _ O R D E R E D _ S E T S -- -- -- -- S p e c -- -- -- -- Copyright (C) 2004-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/>. -- -- -- -- This unit was originally developed by Matthew J Heaney. -- ------------------------------------------------------------------------------ with Ada.Iterator_Interfaces; with Ada.Containers.Helpers; private with Ada.Containers.Red_Black_Trees; private with Ada.Streams; private with Ada.Finalization; private with Ada.Strings.Text_Buffers; generic type Element_Type is private; with function "<" (Left, Right : Element_Type) return Boolean is <>; with function "=" (Left, Right : Element_Type) return Boolean is <>; package Ada.Containers.Bounded_Ordered_Sets with SPARK_Mode => Off is pragma Annotate (CodePeer, Skip_Analysis); pragma Pure; pragma Remote_Types; function Equivalent_Elements (Left, Right : Element_Type) return Boolean; type Set (Capacity : Count_Type) is tagged private with Constant_Indexing => Constant_Reference, Default_Iterator => Iterate, Iterator_Element => Element_Type, Aggregate => (Empty => Empty, Add_Unnamed => Include), Preelaborable_Initialization => Element_Type'Preelaborable_Initialization; type Cursor is private with Preelaborable_Initialization; Empty_Set : constant Set; function Empty (Capacity : Count_Type := 10) return Set; No_Element : constant Cursor; function Has_Element (Position : Cursor) return Boolean; package Set_Iterator_Interfaces is new Ada.Iterator_Interfaces (Cursor, Has_Element); function "=" (Left, Right : Set) return Boolean; function Equivalent_Sets (Left, Right : Set) return Boolean; function To_Set (New_Item : Element_Type) return Set; function Length (Container : Set) return Count_Type; function Is_Empty (Container : Set) return Boolean; procedure Clear (Container : in out Set); function Element (Position : Cursor) return Element_Type; procedure Replace_Element (Container : in out Set; Position : Cursor; New_Item : Element_Type); procedure Query_Element (Position : Cursor; Process : not null access procedure (Element : Element_Type)); type Constant_Reference_Type (Element : not null access constant Element_Type) is private with Implicit_Dereference => Element; function Constant_Reference (Container : aliased Set; Position : Cursor) return Constant_Reference_Type; procedure Assign (Target : in out Set; Source : Set); function Copy (Source : Set; Capacity : Count_Type := 0) return Set; procedure Move (Target : in out Set; Source : in out Set); procedure Insert (Container : in out Set; New_Item : Element_Type; Position : out Cursor; Inserted : out Boolean); procedure Insert (Container : in out Set; New_Item : Element_Type); procedure Include (Container : in out Set; New_Item : Element_Type); procedure Replace (Container : in out Set; New_Item : Element_Type); procedure Exclude (Container : in out Set; Item : Element_Type); procedure Delete (Container : in out Set; Item : Element_Type); procedure Delete (Container : in out Set; Position : in out Cursor); procedure Delete_First (Container : in out Set); procedure Delete_Last (Container : in out Set); procedure Union (Target : in out Set; Source : Set); function Union (Left, Right : Set) return Set; function "or" (Left, Right : Set) return Set renames Union; procedure Intersection (Target : in out Set; Source : Set); function Intersection (Left, Right : Set) return Set; function "and" (Left, Right : Set) return Set renames Intersection; procedure Difference (Target : in out Set; Source : Set); function Difference (Left, Right : Set) return Set; function "-" (Left, Right : Set) return Set renames Difference; procedure Symmetric_Difference (Target : in out Set; Source : Set); function Symmetric_Difference (Left, Right : Set) return Set; function "xor" (Left, Right : Set) return Set renames Symmetric_Difference; function Overlap (Left, Right : Set) return Boolean; function Is_Subset (Subset : Set; Of_Set : Set) return Boolean; function First (Container : Set) return Cursor; function First_Element (Container : Set) return Element_Type; function Last (Container : Set) return Cursor; function Last_Element (Container : Set) return Element_Type; function Next (Position : Cursor) return Cursor; procedure Next (Position : in out Cursor); function Previous (Position : Cursor) return Cursor; procedure Previous (Position : in out Cursor); function Find (Container : Set; Item : Element_Type) return Cursor; function Floor (Container : Set; Item : Element_Type) return Cursor; function Ceiling (Container : Set; Item : Element_Type) return Cursor; function Contains (Container : Set; Item : Element_Type) return Boolean; function "<" (Left, Right : Cursor) return Boolean; function ">" (Left, Right : Cursor) return Boolean; function "<" (Left : Cursor; Right : Element_Type) return Boolean; function ">" (Left : Cursor; Right : Element_Type) return Boolean; function "<" (Left : Element_Type; Right : Cursor) return Boolean; function ">" (Left : Element_Type; Right : Cursor) return Boolean; procedure Iterate (Container : Set; Process : not null access procedure (Position : Cursor)); procedure Reverse_Iterate (Container : Set; Process : not null access procedure (Position : Cursor)); function Iterate (Container : Set) return Set_Iterator_Interfaces.Reversible_Iterator'class; function Iterate (Container : Set; Start : Cursor) return Set_Iterator_Interfaces.Reversible_Iterator'class; generic type Key_Type (<>) is private; with function Key (Element : Element_Type) return Key_Type; with function "<" (Left, Right : Key_Type) return Boolean is <>; package Generic_Keys is function Equivalent_Keys (Left, Right : Key_Type) return Boolean; function Key (Position : Cursor) return Key_Type; function Element (Container : Set; Key : Key_Type) return Element_Type; procedure Replace (Container : in out Set; Key : Key_Type; New_Item : Element_Type); procedure Exclude (Container : in out Set; Key : Key_Type); procedure Delete (Container : in out Set; Key : Key_Type); function Find (Container : Set; Key : Key_Type) return Cursor; function Floor (Container : Set; Key : Key_Type) return Cursor; function Ceiling (Container : Set; Key : Key_Type) return Cursor; function Contains (Container : Set; Key : Key_Type) return Boolean; procedure Update_Element_Preserving_Key (Container : in out Set; Position : Cursor; Process : not null access procedure (Element : in out Element_Type)); type Reference_Type (Element : not null access Element_Type) is private with Implicit_Dereference => Element; function Reference_Preserving_Key (Container : aliased in out Set; Position : Cursor) return Reference_Type; function Constant_Reference (Container : aliased Set; Key : Key_Type) return Constant_Reference_Type; function Reference_Preserving_Key (Container : aliased in out Set; Key : Key_Type) return Reference_Type; private type Set_Access is access all Set; for Set_Access'Storage_Size use 0; type Key_Access is access all Key_Type; use Ada.Streams; package Impl is new Helpers.Generic_Implementation; type Reference_Control_Type is new Impl.Reference_Control_Type with record Container : Set_Access; Pos : Cursor; Old_Key : Key_Access; end record; overriding procedure Finalize (Control : in out Reference_Control_Type); pragma Inline (Finalize); type Reference_Type (Element : not null access Element_Type) is record Control : Reference_Control_Type; end record; procedure Read (Stream : not null access Root_Stream_Type'Class; Item : out Reference_Type); for Reference_Type'Read use Read; procedure Write (Stream : not null access Root_Stream_Type'Class; Item : Reference_Type); for Reference_Type'Write use Write; end Generic_Keys; private pragma Inline (Next); pragma Inline (Previous); type Node_Type is record Parent : Count_Type; Left : Count_Type; Right : Count_Type; Color : Red_Black_Trees.Color_Type := Red_Black_Trees.Red; Element : aliased Element_Type; end record; package Tree_Types is new Red_Black_Trees.Generic_Bounded_Tree_Types (Node_Type); type Set (Capacity : Count_Type) is new Tree_Types.Tree_Type (Capacity) with null record with Put_Image => Put_Image; procedure Put_Image (S : in out Ada.Strings.Text_Buffers.Root_Buffer_Type'Class; V : Set); use Tree_Types, Tree_Types.Implementation; use Ada.Finalization; use Ada.Streams; procedure Write (Stream : not null access Root_Stream_Type'Class; Container : Set); for Set'Write use Write; procedure Read (Stream : not null access Root_Stream_Type'Class; Container : out Set); for Set'Read use Read; type Set_Access is access all Set; for Set_Access'Storage_Size use 0; -- Note: If a Cursor object has no explicit initialization expression, -- it must default initialize to the same value as constant No_Element. -- The Node component of type Cursor has scalar type Count_Type, so it -- requires an explicit initialization expression of its own declaration, -- in order for objects of record type Cursor to properly initialize. type Cursor is record Container : Set_Access; Node : Count_Type := 0; end record; procedure Write (Stream : not null access Root_Stream_Type'Class; Item : Cursor); for Cursor'Write use Write; procedure Read (Stream : not null access Root_Stream_Type'Class; Item : out Cursor); for Cursor'Read use Read; subtype Reference_Control_Type is Implementation.Reference_Control_Type; -- It is necessary to rename this here, so that the compiler can find it type Constant_Reference_Type (Element : not null access constant Element_Type) is record Control : Reference_Control_Type := raise Program_Error with "uninitialized reference"; -- The RM says, "The default initialization of an object of -- type Constant_Reference_Type or Reference_Type propagates -- Program_Error." end record; procedure Read (Stream : not null access Root_Stream_Type'Class; Item : out Constant_Reference_Type); for Constant_Reference_Type'Read use Read; procedure Write (Stream : not null access Root_Stream_Type'Class; Item : Constant_Reference_Type); for Constant_Reference_Type'Write use Write; -- Three operations are used to optimize in the expansion of "for ... of" -- loops: the Next(Cursor) procedure in the visible part, and the following -- Pseudo_Reference and Get_Element_Access functions. See Sem_Ch5 for -- details. function Pseudo_Reference (Container : aliased Set'Class) return Reference_Control_Type; pragma Inline (Pseudo_Reference); -- Creates an object of type Reference_Control_Type pointing to the -- container, and increments the Lock. Finalization of this object will -- decrement the Lock. type Element_Access is access all Element_Type with Storage_Size => 0; function Get_Element_Access (Position : Cursor) return not null Element_Access; -- Returns a pointer to the element designated by Position. Empty_Set : constant Set := Set'(Tree_Type with Capacity => 0); No_Element : constant Cursor := Cursor'(null, 0); type Iterator is new Limited_Controlled and Set_Iterator_Interfaces.Reversible_Iterator with record Container : Set_Access; Node : Count_Type; end record with Disable_Controlled => not T_Check; overriding procedure Finalize (Object : in out Iterator); overriding function First (Object : Iterator) return Cursor; overriding function Last (Object : Iterator) return Cursor; overriding function Next (Object : Iterator; Position : Cursor) return Cursor; overriding function Previous (Object : Iterator; Position : Cursor) return Cursor; end Ada.Containers.Bounded_Ordered_Sets;
optikos/oasis
Ada
2,935
adb
-- Copyright (c) 2019 Maxim Reznik <[email protected]> -- -- SPDX-License-Identifier: MIT -- License-Filename: LICENSE ------------------------------------------------------------- package body Program.Element_Vectors is procedure Skip_Elements (Self : Iterator; Pos : in out Element_Cursor; Step : Integer); -- Find a good Element starting from Pos.Index and set other fields of Pos ------------------ -- Each_Element -- ------------------ function Each_Element (Self : access Element_Vector'Class; When_Element : Element_Checker := null) return Iterator is begin return (Vector => Self, Condition => When_Element); end Each_Element; ----------- -- First -- ----------- overriding function First (Self : Iterator) return Program.Element_Vectors.Element_Cursor is begin return Result : Element_Cursor := (Index => 1, others => <>) do Self.Skip_Elements (Result, Step => 1); end return; end First; ---------- -- Last -- ---------- overriding function Last (Self : Iterator) return Program.Element_Vectors.Element_Cursor is begin return Result : Element_Cursor := (Index => Self.Vector.Length, others => <>) do Self.Skip_Elements (Result, Step => -1); end return; end Last; ---------- -- Next -- ---------- overriding function Next (Self : Iterator; Cursor : Program.Element_Vectors.Element_Cursor) return Program.Element_Vectors.Element_Cursor is begin return Result : Element_Cursor := Cursor do Result.Index := Result.Index + 1; Self.Skip_Elements (Result, Step => 1); end return; end Next; -------------- -- Previous -- -------------- overriding function Previous (Self : Iterator; Cursor : Program.Element_Vectors.Element_Cursor) return Program.Element_Vectors.Element_Cursor is begin return Result : Element_Cursor := Cursor do Result.Index := Result.Index - 1; Self.Skip_Elements (Result, Step => -1); end return; end Previous; ------------------- -- Skip_Elements -- ------------------- procedure Skip_Elements (Self : Iterator; Pos : in out Element_Cursor; Step : Integer) is begin while Pos.Index in 1 .. Self.Vector.Length and then Self.Condition /= null and then not Self.Condition (Self.Vector.Element (Pos.Index).all) loop Pos.Index := Pos.Index + Step; end loop; if Pos.Index in 1 .. Self.Vector.Length then Pos := (Self.Vector.Element (Pos.Index), Self.Vector.Delimiter (Pos.Index), Pos.Index, Pos.Index = Self.Vector.Length); else Pos := (null, null, 0, False); end if; end Skip_Elements; end Program.Element_Vectors;
kontena/ruby-packer
Ada
3,497
ads
------------------------------------------------------------------------------ -- -- -- GNAT ncurses Binding Samples -- -- -- -- Sample.Keyboard_Handler -- -- -- -- S P E C -- -- -- ------------------------------------------------------------------------------ -- Copyright (c) 1998,2003 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; -- This package contains a centralized keyboard handler used throughout -- this example. The handler establishes a timeout mechanism that provides -- periodical updates of the common header lines used in this example. -- package Sample.Keyboard_Handler is function Get_Key (Win : Window := Standard_Window) return Real_Key_Code; -- The central routine for handling keystrokes. procedure Init_Keyboard_Handler; -- Initialize the keyboard end Sample.Keyboard_Handler;
AdaCore/Ada_Drivers_Library
Ada
10,450
adb
------------------------------------------------------------------------------ -- -- -- Copyright (C) 2020, AdaCore -- -- -- -- Redistribution and use in source and binary forms, with or without -- -- modification, are permitted provided that the following conditions are -- -- met: -- -- 1. Redistributions of source code must retain the above copyright -- -- notice, this list of conditions and the following disclaimer. -- -- 2. Redistributions in binary form must reproduce the above copyright -- -- notice, this list of conditions and the following disclaimer in -- -- the documentation and/or other materials provided with the -- -- distribution. -- -- 3. Neither the name of the copyright holder nor the names of its -- -- contributors may be used to endorse or promote products derived -- -- from this software without specific prior written permission. -- -- -- -- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -- -- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -- -- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -- -- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -- -- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -- -- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -- -- LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -- -- DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -- -- THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -- -- (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -- -- OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- -- -- ------------------------------------------------------------------------------ with System; with HAL; use HAL; with Cortex_M_SVD.Debug; use Cortex_M_SVD.Debug; with NRF_SVD.CLOCK; use NRF_SVD.CLOCK; with NRF_SVD.FICR; use NRF_SVD.FICR; with NRF_SVD.POWER; use NRF_SVD.POWER; with NRF_SVD.TEMP; use NRF_SVD.TEMP; package body nRF.Device is Undocumented_Reg_FE0 : UInt32 with Address => System'To_Address (16#F0000FE0#); Undocumented_Reg_FE4 : UInt32 with Address => System'To_Address (16#F0000FE4#); Undocumented_Reg_FE8 : UInt32 with Address => System'To_Address (16#F0000FE8#); FE0_Is_Six : constant Boolean := (Undocumented_Reg_FE0 and 16#FF#) = 6; FE4_Is_Zero : constant Boolean := (Undocumented_Reg_FE0 and 16#0F#) = 0; function Errata_12 return Boolean; function Errata_16 return Boolean; function Errata_31 return Boolean; function Errata_32 return Boolean; function Errata_36 return Boolean; function Errata_37 return Boolean; function Errata_57 return Boolean; function Errata_66 return Boolean; function Errata_136 return Boolean; function Errata_182 return Boolean; function Errata_108 return Boolean; --------------- -- Errata_12 -- --------------- function Errata_12 return Boolean is begin if FE0_Is_Six and FE4_Is_Zero then case Undocumented_Reg_FE8 and 16#F0# is when 16#30# => return True; when 16#40# => return True; when 16#50# => return True; when others => return False; end case; end if; return False; end Errata_12; E12_Undocumented_COMP_Reg_540 : UInt32 with Address => System'To_Address (16#40013540#); E12_Undocumented_FICR_Reg_324 : UInt32 with Address => System'To_Address (16#10000324#); --------------- -- Errata_16 -- --------------- function Errata_16 return Boolean is begin if FE0_Is_Six and FE4_Is_Zero and Undocumented_Reg_FE8 = 16#30# then return True; end if; return False; end Errata_16; E16_Undocumented_Reg_074 : UInt32 with Address => System'To_Address (16#4007C074#); --------------- -- Errata_31 -- --------------- function Errata_31 return Boolean is begin return Errata_12; end Errata_31; E31_Undocumented_CLOCK_Reg_53C : UInt32 with Address => System'To_Address (16#4000053C#); E31_Undocumented_FICR_Reg_244 : UInt32 with Address => System'To_Address (16#10000244#); --------------- -- Errata_32 -- --------------- function Errata_32 return Boolean is begin return Errata_16; end Errata_32; --------------- -- Errata_36 -- --------------- function Errata_36 return Boolean is begin return Errata_12; end Errata_36; --------------- -- Errata_37 -- --------------- function Errata_37 return Boolean is begin return Errata_16; end Errata_37; E37_Undocumented_Reg_5A0 : UInt32 with Address => System'To_Address (16#400005A0#); --------------- -- Errata_57 -- --------------- function Errata_57 return Boolean is begin return Errata_16; end Errata_57; E57_Undocumented_NFCT_Reg_610 : UInt32 with Address => System'To_Address (16#40005610#); E57_Undocumented_NFCT_Reg_614 : UInt32 with Address => System'To_Address (16#40005614#); E57_Undocumented_NFCT_Reg_618 : UInt32 with Address => System'To_Address (16#40005618#); E57_Undocumented_NFCT_Reg_688 : UInt32 with Address => System'To_Address (16#40005688#); --------------- -- Errata_66 -- --------------- function Errata_66 return Boolean is begin if FE0_Is_Six and FE4_Is_Zero and Undocumented_Reg_FE8 = 16#50# then return True; end if; return False; end Errata_66; ---------------- -- Errata_108 -- ---------------- function Errata_108 return Boolean is begin return Errata_12; end Errata_108; E108_Undocumented_Reg_EE4 : UInt32 with Address => System'To_Address (16#40000EE4#); E108_Undocumented_FICR_Reg_258 : UInt32 with Address => System'To_Address (16#10000258#); ---------------- -- Errata_136 -- ---------------- function Errata_136 return Boolean is begin return Errata_12; end Errata_136; ---------------- -- Errata_182 -- ---------------- function Errata_182 return Boolean is Undocumented_FICR_Reg_130 : UInt32 with Address => System'To_Address (16#10000130#); Undocumented_FICR_Reg_134 : UInt32 with Address => System'To_Address (16#10000130#); begin return Undocumented_FICR_Reg_130 = 6 and Undocumented_FICR_Reg_134 = 6; end Errata_182; E182_Undocumented_Reg_73C : UInt32 with Address => System'To_Address (16#4000173C#); begin if Errata_12 then -- Workaround for Errata 12 "COMP: Reference ladder not correctly -- calibrated" E12_Undocumented_COMP_Reg_540 := Shift_Right (E12_Undocumented_FICR_Reg_324 and 16#1F00#, 8); end if; if Errata_16 then -- Workaround for Errata 16 "System: RAM may be corrupt on wakeup from CPU -- IDLE" E16_Undocumented_Reg_074 := 3131961357; end if; if Errata_31 then -- Workaround for Errata 31 "CLOCK: Calibration values are not correctly -- loaded from FICR at reset" E31_Undocumented_CLOCK_Reg_53C := Shift_Right (E31_Undocumented_FICR_Reg_244 and 16#E000#, 13); end if; if Errata_32 then -- Workaround for Errata 32 "DIF: Debug session automatically enables -- TracePort pins" Debug_Periph.DEMCR.TRCENA := False; end if; if Errata_36 then -- Workaround for Errata 36 "CLOCK: Some registers are not reset when -- expected" CLOCK_Periph.EVENTS_DONE := 0; CLOCK_Periph.EVENTS_CTTO := 0; CLOCK_Periph.CTIV.CTIV := 0; end if; if Errata_37 then -- Workaround for Errata 37 "RADIO: Encryption engine is slow by default" E37_Undocumented_Reg_5A0 := 3; end if; if Errata_57 then -- Workaround for Errata 57 "NFCT: NFC Modulation amplitude" E57_Undocumented_NFCT_Reg_610 := 5; E57_Undocumented_NFCT_Reg_688 := 1; E57_Undocumented_NFCT_Reg_618 := 0; E57_Undocumented_NFCT_Reg_614 := 16#3F#; end if; if Errata_66 then -- Workaround for Errata 66 "TEMP: Linearity specification not met with -- default settings" TEMP_Periph.A0.A0 := FICR_Periph.TEMP.A0.A; TEMP_Periph.A1.A1 := FICR_Periph.TEMP.A1.A; TEMP_Periph.A2.A2 := FICR_Periph.TEMP.A2.A; TEMP_Periph.A3.A3 := FICR_Periph.TEMP.A3.A; TEMP_Periph.A4.A4 := FICR_Periph.TEMP.A4.A; TEMP_Periph.A5.A5 := FICR_Periph.TEMP.A5.A; TEMP_Periph.B0.B0 := FICR_Periph.TEMP.B0.B; TEMP_Periph.B1.B1 := FICR_Periph.TEMP.B1.B; TEMP_Periph.B2.B2 := FICR_Periph.TEMP.B2.B; TEMP_Periph.B3.B3 := FICR_Periph.TEMP.B3.B; TEMP_Periph.B4.B4 := FICR_Periph.TEMP.B4.B; TEMP_Periph.B5.B5 := FICR_Periph.TEMP.B5.B; TEMP_Periph.T0.T0 := FICR_Periph.TEMP.T0.T; TEMP_Periph.T1.T1 := FICR_Periph.TEMP.T1.T; TEMP_Periph.T2.T2 := FICR_Periph.TEMP.T2.T; TEMP_Periph.T3.T3 := FICR_Periph.TEMP.T3.T; TEMP_Periph.T4.T4 := FICR_Periph.TEMP.T4.T; end if; if Errata_108 then -- Workaround for Errata 108 "RAM: RAM content cannot be trusted upon -- waking up from System ON Idle or System OFF mode" E108_Undocumented_Reg_EE4 := E108_Undocumented_FICR_Reg_258 and 16#4F#; end if; if Errata_136 then -- Workaround for Errata 136 "System: Bits in RESETREAS are set when they -- should not be" if POWER_Periph.RESETREAS.RESETPIN = Detected then POWER_Periph.RESETREAS.RESETPIN := Notdetected; end if; end if; if Errata_182 then -- Workaround for Errata 182 "RADIO: Fixes for anomalies #102, #106, and -- #107 do not take effect" E182_Undocumented_Reg_73C := E182_Undocumented_Reg_73C or Shift_Left (1, 10); end if; end nRF.Device;
RREE/ada-util
Ada
5,266
ads
----------------------------------------------------------------------- -- util-nullables -- Basic types that can hold a null value -- Copyright (C) 2017, 2021 Stephane Carrez -- Written by Stephane Carrez ([email protected]) -- -- Licensed under the Apache License, Version 2.0 (the "License"); -- you may not use this file except in compliance with the License. -- You may obtain a copy of the License at -- -- http://www.apache.org/licenses/LICENSE-2.0 -- -- Unless required by applicable law or agreed to in writing, software -- distributed under the License is distributed on an "AS IS" BASIS, -- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -- See the License for the specific language governing permissions and -- limitations under the License. ----------------------------------------------------------------------- with Ada.Calendar; with Ada.Strings.Unbounded; -- === Nullable types === -- Sometimes it is necessary to represent a simple data type with an optional boolean information -- that indicates whether the value is valid or just null. The concept of nullable type is often -- used in databases but also in JSON data representation. The <tt>Util.Nullables</tt> package -- provides several standard type to express the null capability of a value. -- -- By default a nullable instance is created with the null flag set. package Util.Nullables is use type Ada.Strings.Unbounded.Unbounded_String; use type Ada.Calendar.Time; DEFAULT_TIME : constant Ada.Calendar.Time; -- ------------------------------ -- A boolean which can be null. -- ------------------------------ type Nullable_Boolean is record Value : Boolean := False; Is_Null : Boolean := True; end record; Null_Boolean : constant Nullable_Boolean; -- Return True if the two nullable times are identical (both null or both same value). function "=" (Left, Right : in Nullable_Boolean) return Boolean is ((Left.Is_Null = Right.Is_Null) and (Left.Is_Null or else Left.Value = Right.Value)); -- ------------------------------ -- An integer which can be null. -- ------------------------------ type Nullable_Integer is record Value : Integer := 0; Is_Null : Boolean := True; end record; Null_Integer : constant Nullable_Integer; -- Return True if the two nullable times are identical (both null or both same value). function "=" (Left, Right : in Nullable_Integer) return Boolean is ((Left.Is_Null = Right.Is_Null) and (Left.Is_Null or else Left.Value = Right.Value)); -- ------------------------------ -- A long which can be null. -- ------------------------------ type Nullable_Long is record Value : Long_Long_Integer := 0; Is_Null : Boolean := True; end record; Null_Long : constant Nullable_Long; -- Return True if the two nullable times are identical (both null or both same value). function "=" (Left, Right : in Nullable_Long) return Boolean is ((Left.Is_Null = Right.Is_Null) and (Left.Is_Null or else Left.Value = Right.Value)); -- ------------------------------ -- A string which can be null. -- ------------------------------ type Nullable_String is record Value : Ada.Strings.Unbounded.Unbounded_String; Is_Null : Boolean := True; end record; Null_String : constant Nullable_String; -- Return True if the two nullable times are identical (both null or both same value). function "=" (Left, Right : in Nullable_String) return Boolean is ((Left.Is_Null = Right.Is_Null) and (Left.Is_Null or else Left.Value = Right.Value)); -- ------------------------------ -- A date which can be null. -- ------------------------------ type Nullable_Time is record Value : Ada.Calendar.Time := DEFAULT_TIME; Is_Null : Boolean := True; end record; Null_Time : constant Nullable_Time; -- Return True if the two nullable times are identical (both null or both same time). function "=" (Left, Right : in Nullable_Time) return Boolean is ((Left.Is_Null = Right.Is_Null) and (Left.Is_Null or else Left.Value = Right.Value)); private DEFAULT_TIME : constant Ada.Calendar.Time := Ada.Calendar.Time_Of (Year => 1901, Month => 1, Day => 2, Seconds => 0.0); Null_Boolean : constant Nullable_Boolean := Nullable_Boolean '(Is_Null => True, Value => False); Null_Integer : constant Nullable_Integer := Nullable_Integer '(Is_Null => True, Value => 0); Null_Long : constant Nullable_Long := Nullable_Long '(Is_Null => True, Value => 0); Null_String : constant Nullable_String := Nullable_String '(Is_Null => True, Value => Ada.Strings.Unbounded.Null_Unbounded_String); Null_Time : constant Nullable_Time := Nullable_Time '(Is_Null => True, Value => DEFAULT_TIME); end Util.Nullables;
pombredanne/ravenadm
Ada
8,415
ads
-- This file is covered by the Internet Software Consortium (ISC) License -- Reference: ../License.txt private with Ada.Calendar; package PortScan.Scan is missing_index : exception; bad_index_data : exception; bsheet_parsing : exception; populate_error : exception; -- Scan the entire conspiracy and unkindness directories in order with a single, -- non-recursive pass using up to 32 parallel scanners. Return True on success function scan_entire_ports_tree (sysrootver : sysroot_characteristics) return Boolean; -- Scan entire conspiracy and unkindness directories using parallel scanners in order -- to compile a complete unique set of distribution files. Used for distfile purging. -- Return True on success. function gather_distfile_set (sysrootver : sysroot_characteristics) return Boolean; -- Starting with a single port, recurse to determine a limited but complete -- dependency tree. Repeated calls will augment already existing data. -- Return True on success function scan_single_port (namebase : String; variant : String; always_build : Boolean; sysrootver : sysroot_characteristics; fatal : out Boolean) return Boolean; -- This procedure causes the reverse dependencies to be calculated, and -- then the extended (recursive) reverse dependencies. The former is -- used progressively to determine when a port is free to build and the -- latter sets the build priority. procedure set_build_priority; -- Iterate through portlist and scan each individual port recursively. -- May be interrupted with a a singal. Returns False if any port fails scan or if -- the process was interrupted by a signal. function scan_provided_list_of_ports (always_build : Boolean; sysrootver : sysroot_characteristics) return Boolean; -- Linearly scan through entire conspiracy directory and generate a new index procedure generate_conspiracy_index (sysrootver : sysroot_characteristics); -- List every port to be built and the final tally. procedure display_results_of_dry_run; -- Scan distfiles directory, then purge all obsolete distfiles. procedure purge_obsolete_distfiles; -- Scan directory that contains the packages (*.txz) and stores the -- file names in the container. Returns False if no packages are found. function scan_repository (repository : String) return Boolean; -- Scans conspiracy + unkindness and generates a website at the given directory -- Generate a web page for every single active port -- Obsolete web pages are not removed, but no links will reference them function generate_entire_website (www_site : String; sysrootver : sysroot_characteristics) return Boolean; private package CAL renames Ada.Calendar; type dependency_type is (build, buildrun, runtime, extra_runtime); subtype LR_set is dependency_type range buildrun .. extra_runtime; type verdiff is (newbuild, rebuild, change); subtype AF is Integer range 0 .. 15; type disktype is mod 2**64; conspindex : constant String := "/Mk/Misc/conspiracy_variants"; port_dates : constant String := "/Mk/Misc/port_dates"; type port_dates_record is record creation : CAL.Time; lastmod : CAL.Time; end record; package dates_crate is new CON.Hashed_Maps (Key_Type => HT.Text, Element_Type => port_dates_record, Hash => port_hash, Equivalent_Keys => HT.equivalent); type catalog_record is record lastmod64 : disktype; origin : HT.Text; end record; function "<" (L, R : catalog_record) return Boolean; package catalog_crate is new CON.Ordered_Sets (Element_Type => catalog_record); -- subroutines for populate_port_data procedure prescan_ports_tree (conspiracy : String; unkindness : String; sysrootver : sysroot_characteristics); procedure prescan_conspiracy_index_for_distfiles (conspiracy : String; unkindness : String; sysrootver : sysroot_characteristics); procedure prescan_unkindness (unkindness : String); procedure prescan_custom (unkindness : String; bucket : bucket_code; namebase : String; max_lots : scanners); procedure populate_port_data (conspiracy : String; unkindness : String; target : port_index; always_build : Boolean; sysrootver : sysroot_characteristics); procedure parallel_deep_scan (conspiracy : String; unkindness : String; sysrootver : sysroot_characteristics; success : out Boolean; show_progress : Boolean); procedure populate_set_depends (target : port_index; tuple : String; dtype : dependency_type); procedure populate_option (target : port_index; option_name : String; setting : Boolean); procedure skeleton_compiler_data (conspiracy : String; unkindness : String; target : port_index; sysrootver : sysroot_characteristics); procedure iterate_reverse_deps; procedure iterate_drill_down; procedure drill_down (next_target : port_index; circular_flag : in out Boolean); -- some helper routines function get_max_lots return scanners; function convert_tuple_to_portkey (tuple : String) return String; function extract_subpackage (tuple : String) return String; function tohex (value : AF) return Character; function display_kmg (number : disktype) return String; -- Given a port ID, search for existing package in the packages directory -- If the exact package exists, return " (rebuild <version>)" -- If no package exists, return " (new)" -- If previous package exists, return " (<oldversion> => <version>)" function version_difference (id : port_id; kind : out verdiff) return String; -- Don't bother with parallel scan on unkindness, just get the distfiles now. procedure linear_scan_unkindness_for_distfiles (unkindness : String); -- Split conspiracy up equally between available scanners looking for distfiles procedure parallel_distfile_scan (conspiracy : String; sysrootver : sysroot_characteristics; success : out Boolean; show_progress : Boolean); -- Set the portlist as if the user provided a list of every port via command line procedure set_portlist_to_everything; -- create a block of upstream ports. Each line is semi-colon delimited. -- The first field is namebase-variant -- The second field is the relative link -- The third field is the tagline function blocked_text_block (port : port_index) return String; -- create an index block of all ravenports, sorted by last-modified order function catalog_row_block (crate : dates_crate.Map; catcrate : catalog_crate.Set) return String; -- Loop to generate all webpages (includes custom ports) procedure serially_generate_web_pages (www_site : String; sysrootver : sysroot_characteristics; success : out Boolean); -- Single web page generator (called by parent loop) -- Returns true if web page generation was successful function generate_single_page (port : port_index; workzone : String; www_site : String; conspiracy : String; unkindness : String; cdatetime : CAL.Time; mdatetime : CAL.Time; sysrootver : sysroot_characteristics) return Boolean; -- Generates searchable catalog index -- Returns true if web page generation was successful function generate_catalog_index (www_site : String; crate : dates_crate.Map; catcrate : catalog_crate.Set) return Boolean; -- Extract dependencies, store them -- Web site generation requires two complete passes procedure store_port_dependencies (port : port_index; conspiracy : String; unkindness : String; sysrootver : sysroot_characteristics); -- Slurp creation and last-modification timestamp of each port procedure scan_port_dates (conspiracy : String; crate : in out dates_crate.Map; catcrate : in out catalog_crate.Set); end PortScan.Scan;
AdaCore/libadalang
Ada
41
ads
package a.b is procedure pb; end a.b;
damaki/libkeccak
Ada
1,933
ads
------------------------------------------------------------------------------- -- Copyright (c) 2016, Daniel King -- All rights reserved. -- -- Redistribution and use in source and binary forms, with or without -- modification, are permitted provided that the following conditions are met: -- * Redistributions of source code must retain the above copyright -- notice, this list of conditions and the following disclaimer. -- * Redistributions in binary form must reproduce the above copyright -- notice, this list of conditions and the following disclaimer in the -- documentation and/or other materials provided with the distribution. -- * The name of the copyright holder may not be used to endorse or promote -- Products derived from this software without specific prior written -- permission. -- -- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -- AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -- IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -- ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE FOR ANY -- DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -- (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -- LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND -- ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -- (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -- THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ------------------------------------------------------------------------------- with AUnit.Test_Suites; use AUnit.Test_Suites; -- This package is a composite suite for combining all test suites into one. package Keccak_Suites is function Suite return Access_Test_Suite; end Keccak_Suites;
eqcola/ada-ado
Ada
5,428
adb
----------------------------------------------------------------------- -- userdb -- Example to find/create an object from the database -- Copyright (C) 2010, 2011, 2012, 2013 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 ADO; with ADO.Drivers; with ADO.Sessions; with ADO.SQL; with ADO.Sessions.Factory; with Samples.User.Model; with Ada.Text_IO; with Ada.Strings.Unbounded; with ADO.Statements; with ADO.Queries; with Util.Log.Loggers; with GNAT.Command_Line; procedure Userdb is use ADO; use Ada; use Ada.Strings.Unbounded; use Samples.User.Model; use ADO.Statements; use GNAT.Command_Line; Factory : ADO.Sessions.Factory.Session_Factory; User : User_Ref; Users : User_Vector; procedure List_Users (Filter : in String); procedure List_User_Info; procedure Initialize (File : in String); -- ------------------------------ -- List users -- ------------------------------ procedure List_Users (Filter : in String) is use User_Vectors; DB : ADO.Sessions.Session := Factory.Get_Session; Statement : ADO.Statements.Query_Statement := DB.Create_Statement (Filter); Query : ADO.SQL.Query; begin List (Object => Users, Session => DB, Query => Query); if Users.Is_Empty then Text_IO.Put_Line ("List is empty"); else declare Iter : User_Vectors.Cursor := First (Users); begin while Has_Element (Iter) loop User := Element (Iter); Text_IO.Put_Line (Identifier'Image (User.Get_Id) & " " & To_String (User.Get_Name) & " " & To_String (User.Get_Email)); User_Vectors.Next (Iter); end loop; end; end if; Statement := DB.Create_Statement ("select count(*) from user"); Statement.Execute; if not Statement.Has_Elements then Text_IO.Put_Line ("Count query failed..."); end if; declare Count : constant Integer := Statement.Get_Integer (0); begin Text_IO.Put_Line ("Count: " & Integer'Image (Count)); end; end List_Users; -- ------------------------------ -- List users -- ------------------------------ procedure List_User_Info is use Samples.User.Model.User_Info_Vectors; DB : ADO.Sessions.Session := Factory.Get_Session; Users : Samples.User.Model.User_Info_Vector; Context : ADO.Queries.Context; begin Context.Set_Query (Samples.User.Model.Query_User_List); List (Object => Users, Session => DB, Context => Context); if Users.Is_Empty then Text_IO.Put_Line ("User info list is empty"); else declare Iter : Cursor := First (Users); User : Samples.User.Model.User_Info; begin while Has_Element (Iter) loop User := Element (Iter); Text_IO.Put_Line (Identifier'Image (User.Id) & " " & To_String (User.Name) & " " & To_String (User.Email)); Next (Iter); end loop; end; end if; end List_User_Info; procedure Initialize (File : in String) is begin Util.Log.Loggers.Initialize (File); ADO.Drivers.Initialize (File); end Initialize; begin Initialize ("samples.properties"); Factory.Create (ADO.Drivers.Get_Config ("ado.database")); declare DB : ADO.Sessions.Master_Session := Factory.Get_Master_Session; Query : ADO.SQL.Query; Found : Boolean; begin DB.Begin_Transaction; List_User_Info; List_Users (Filter => ""); loop declare Name : constant String := Get_Argument; begin exit when Name = ""; Query.Bind_Param (1, Name); Query.Set_Filter ("name = ?"); User.Find (Session => DB, Query => Query, Found => Found); if User.Is_Null or not Found then User.Set_Name (Name); User.Set_Email (Name & "@gmail.com"); User.Set_Description ("My friend " & Name); -- User.Set_Password ("my password"); User.Set_Status (0); User.Save (DB); Text_IO.Put_Line ("User created: " & Identifier'Image (User.Get_Id)); else Text_IO.Put_Line ("User " & Name & ": " & Identifier'Image (User.Get_Id)); end if; end; end loop; DB.Rollback; exception when ADO.Sessions.NOT_FOUND => Text_IO.Put_Line ("User 23 does not exist"); end; Text_IO.Put_Line ("Exiting"); end Userdb;
AdaCore/gpr
Ada
27,596
ads
-- -- Copyright (C) 2019-2023, AdaCore -- SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -- with GNATCOLL.GMP.Integers; with Gpr_Parser_Support.Errors; private with Gpr_Parser_Support.Internal.Analysis; with Gpr_Parser_Support.Symbols; use Gpr_Parser_Support.Symbols; with Gpr_Parser_Support.Token_Data_Handlers; use Gpr_Parser_Support.Token_Data_Handlers; with Gpr_Parser_Support.Types; use Gpr_Parser_Support.Types; -- This package provides types and functions used in the whole Gpr_Parser -- package tree. package Gpr_Parser.Common is use Support.Slocs, Support.Text; subtype Big_Integer is GNATCOLL.GMP.Integers.Big_Integer; -- Shortcut for ``GNATCOLL.GMP.Integers.Big_Integer`` Default_Charset : constant String := "iso-8859-1"; -- Default charset to use when creating analysis contexts ---------------- -- Exceptions -- ---------------- File_Read_Error : exception renames Gpr_Parser_Support.Errors.File_Read_Error; -- Subprograms may raise this when they cannot open a source file. Note -- that this does *not* concern analysis unit getters, which create -- diagnostic vectors for such errors. Invalid_Input : exception renames Gpr_Parser_Support.Errors.Invalid_Input; -- Raised by lexing functions (``Gpr_Parser.Lexer``) when the input -- contains an invalid byte sequence. Invalid_Symbol_Error : exception renames Gpr_Parser_Support.Errors.Invalid_Symbol_Error; -- Exception raise when an invalid symbol is passed to a subprogram. Invalid_Unit_Name_Error : exception renames Gpr_Parser_Support.Errors.Invalid_Unit_Name_Error; -- Raised when an invalid unit name is provided. Native_Exception : exception renames Gpr_Parser_Support.Errors.Native_Exception; -- Exception raised in language bindings when the underlying C API reports -- an unexpected error that occurred in the library. -- -- This kind of exception is raised for internal errors: they should never -- happen in normal situations and if they are raised at some point, it -- means the library state is potentially corrupted. -- -- Nevertheless, the library does its best not to crash the program, -- materializing internal errors using this kind of exception. Precondition_Failure : exception renames Gpr_Parser_Support.Errors.Precondition_Failure; -- Exception raised when an API is called while its preconditions are not -- satisfied. Property_Error : exception renames Gpr_Parser_Support.Errors.Property_Error; -- Exception that is raised when an error occurs while evaluating any -- function whose name starts with ``P_``. This is the only exceptions that -- such functions can raise. Stale_Reference_Error : exception renames Gpr_Parser_Support.Errors.Stale_Reference_Error; -- Exception raised while trying to access data that was deallocated. This -- happens when one tries to use a node whose unit has been reparsed, for -- instance. Syntax_Error : exception renames Gpr_Parser_Support.Errors.Syntax_Error; -- Subprograms may raise this when they try to parse invalid syntax. Note -- that this does *not* concern analysis unit getters, which create -- diagnostic vectors for such errors. Unknown_Charset : exception renames Gpr_Parser_Support.Errors.Unknown_Charset; -- Raised by lexing functions (``Gpr_Parser.Lexer``) when the input charset -- is not supported. ------------------- -- Introspection -- ------------------- Bad_Type_Error : exception renames Gpr_Parser_Support.Errors.Introspection.Bad_Type_Error; -- Raised when introspection functions (``Gpr_Parser.Introspection``) are -- provided mismatching types/values. Out_Of_Bounds_Error : exception renames Gpr_Parser_Support.Errors.Introspection.Out_Of_Bounds_Error; -- Raised when introspection functions (``Gpr_Parser.Introspection``) are -- passed an out of bounds index. --------------- -- Rewriting -- --------------- Template_Args_Error : exception renames Gpr_Parser_Support.Errors.Rewriting.Template_Args_Error; -- Exception raised when the provided arguments for a template don't match -- what the template expects. Template_Format_Error : exception renames Gpr_Parser_Support.Errors.Rewriting.Template_Format_Error; -- Exception raised when a template has an invalid syntax, such as badly -- formatted placeholders. Template_Instantiation_Error : exception renames Gpr_Parser_Support.Errors.Rewriting.Template_Instantiation_Error; -- Exception raised when the instantiation of a template cannot be parsed. --------------- -- Unparsing -- --------------- Malformed_Tree_Error : exception renames Gpr_Parser_Support.Errors.Unparsing.Malformed_Tree_Error; -- Raised when unparsing functions working on rewritten trees -- (``Gpr_Parser.Rewriting``) are called on malformed trees. ---------------------------- -- Misc enumeration types -- ---------------------------- type Analysis_Unit_Kind is (Unit_Specification, Unit_Body) with Convention => C; -- Specify a kind of analysis unit. Specification units provide an -- interface to the outer world while body units provide an -- implementation for the corresponding interface. function Trace_Image (Self : Analysis_Unit_Kind) return String is (Self'Image); type Lookup_Kind is (Recursive, Flat, Minimal) with Convention => C; function Trace_Image (Self : Lookup_Kind) return String is (Self'Image); type Designated_Env_Kind is (None, Current_Env, Named_Env, Direct_Env) with Convention => C; -- Discriminant for DesignatedEnv structures. function Trace_Image (Self : Designated_Env_Kind) return String is (Self'Image); type Grammar_Rule is (Project_Qualifier_Rule, Project_Extension_Rule, Project_Declaration_Rule, Project_Rule, Declarative_Items_Rule, Declarative_Item_Rule, Simple_Declarative_Items_Rule, Simple_Declarative_Item_Rule, Variable_Decl_Rule, Attribute_Decl_Rule, Associative_Array_Index_Rule, Package_Decl_Rule, Package_Renaming_Rule, Package_Extension_Rule, Package_Spec_Rule, Empty_Declaration_Rule, Case_Construction_Rule, Case_Item_Rule, Others_Designator_Rule, Choice_Rule, Discrete_Choice_List_Rule, With_Decl_Rule, Context_Clauses_Rule, Typed_String_Decl_Rule, Identifier_Rule, String_Literal_Rule, Num_Literal_Rule, Static_Name_Rule, Attribute_Reference_Rule, Variable_Reference_Rule, Type_Reference_Rule, Builtin_Function_Call_Rule, Expression_Rule, Expression_List_Rule, String_Literal_At_Rule, Term_Rule, Compilation_Unit_Rule) with Convention => C; -- Gramar rule to use for parsing. function Trace_Image (Self : Grammar_Rule) return String is (Self'Image); ----------- -- Nodes -- ----------- type Gpr_Node_Kind_Type is (Gpr_All_Qualifier_Absent, Gpr_All_Qualifier_Present, Gpr_Attribute_Decl, Gpr_Attribute_Reference, Gpr_Case_Item_List, Gpr_Gpr_Node_List, Gpr_Choices, Gpr_Term_List, Gpr_Identifier_List, Gpr_String_Literal_List, Gpr_Term_List_List, Gpr_With_Decl_List, Gpr_Builtin_Function_Call, Gpr_Case_Construction, Gpr_Case_Item, Gpr_Compilation_Unit, Gpr_Empty_Decl, Gpr_Prefix, Gpr_Identifier, Gpr_Num_Literal, Gpr_String_Literal, Gpr_Limited_Absent, Gpr_Limited_Present, Gpr_Others_Designator, Gpr_Package_Decl, Gpr_Package_Extension, Gpr_Package_Renaming, Gpr_Package_Spec, Gpr_Project, Gpr_Project_Declaration, Gpr_Project_Extension, Gpr_Project_Qualifier_Abstract, Gpr_Project_Qualifier_Aggregate, Gpr_Project_Qualifier_Aggregate_Library, Gpr_Project_Qualifier_Configuration, Gpr_Project_Qualifier_Library, Gpr_Project_Qualifier_Standard, Gpr_String_Literal_At, Gpr_Terms, Gpr_Type_Reference, Gpr_Typed_String_Decl, Gpr_Variable_Decl, Gpr_Variable_Reference, Gpr_With_Decl); -- Type for concrete nodes for Gpr_Node_Kind_Type use (Gpr_All_Qualifier_Absent => 1, Gpr_All_Qualifier_Present => 2, Gpr_Attribute_Decl => 3, Gpr_Attribute_Reference => 4, Gpr_Case_Item_List => 5, Gpr_Gpr_Node_List => 6, Gpr_Choices => 7, Gpr_Term_List => 8, Gpr_Identifier_List => 9, Gpr_String_Literal_List => 10, Gpr_Term_List_List => 11, Gpr_With_Decl_List => 12, Gpr_Builtin_Function_Call => 13, Gpr_Case_Construction => 14, Gpr_Case_Item => 15, Gpr_Compilation_Unit => 16, Gpr_Empty_Decl => 17, Gpr_Prefix => 18, Gpr_Identifier => 19, Gpr_Num_Literal => 20, Gpr_String_Literal => 21, Gpr_Limited_Absent => 22, Gpr_Limited_Present => 23, Gpr_Others_Designator => 24, Gpr_Package_Decl => 25, Gpr_Package_Extension => 26, Gpr_Package_Renaming => 27, Gpr_Package_Spec => 28, Gpr_Project => 29, Gpr_Project_Declaration => 30, Gpr_Project_Extension => 31, Gpr_Project_Qualifier_Abstract => 32, Gpr_Project_Qualifier_Aggregate => 33, Gpr_Project_Qualifier_Aggregate_Library => 34, Gpr_Project_Qualifier_Configuration => 35, Gpr_Project_Qualifier_Library => 36, Gpr_Project_Qualifier_Standard => 37, Gpr_String_Literal_At => 38, Gpr_Terms => 39, Gpr_Type_Reference => 40, Gpr_Typed_String_Decl => 41, Gpr_Variable_Decl => 42, Gpr_Variable_Reference => 43, Gpr_With_Decl => 44); subtype Gpr_Gpr_Node is Gpr_Node_Kind_Type range Gpr_All_Qualifier_Absent .. Gpr_With_Decl; --% no-document: True subtype Gpr_All_Qualifier is Gpr_Node_Kind_Type range Gpr_All_Qualifier_Absent .. Gpr_All_Qualifier_Present; --% no-document: True subtype Gpr_All_Qualifier_Absent_Range is Gpr_Node_Kind_Type range Gpr_All_Qualifier_Absent .. Gpr_All_Qualifier_Absent; --% no-document: True subtype Gpr_All_Qualifier_Present_Range is Gpr_Node_Kind_Type range Gpr_All_Qualifier_Present .. Gpr_All_Qualifier_Present; --% no-document: True subtype Gpr_Attribute_Decl_Range is Gpr_Node_Kind_Type range Gpr_Attribute_Decl .. Gpr_Attribute_Decl; --% no-document: True subtype Gpr_Attribute_Reference_Range is Gpr_Node_Kind_Type range Gpr_Attribute_Reference .. Gpr_Attribute_Reference; --% no-document: True subtype Gpr_Base_List is Gpr_Node_Kind_Type range Gpr_Case_Item_List .. Gpr_With_Decl_List; --% no-document: True subtype Gpr_Case_Item_List_Range is Gpr_Node_Kind_Type range Gpr_Case_Item_List .. Gpr_Case_Item_List; --% no-document: True subtype Gpr_Gpr_Node_List_Range is Gpr_Node_Kind_Type range Gpr_Gpr_Node_List .. Gpr_Term_List; --% no-document: True subtype Gpr_Choices_Range is Gpr_Node_Kind_Type range Gpr_Choices .. Gpr_Choices; --% no-document: True subtype Gpr_Term_List_Range is Gpr_Node_Kind_Type range Gpr_Term_List .. Gpr_Term_List; --% no-document: True subtype Gpr_Identifier_List_Range is Gpr_Node_Kind_Type range Gpr_Identifier_List .. Gpr_Identifier_List; --% no-document: True subtype Gpr_String_Literal_List_Range is Gpr_Node_Kind_Type range Gpr_String_Literal_List .. Gpr_String_Literal_List; --% no-document: True subtype Gpr_Term_List_List_Range is Gpr_Node_Kind_Type range Gpr_Term_List_List .. Gpr_Term_List_List; --% no-document: True subtype Gpr_With_Decl_List_Range is Gpr_Node_Kind_Type range Gpr_With_Decl_List .. Gpr_With_Decl_List; --% no-document: True subtype Gpr_Builtin_Function_Call_Range is Gpr_Node_Kind_Type range Gpr_Builtin_Function_Call .. Gpr_Builtin_Function_Call; --% no-document: True subtype Gpr_Case_Construction_Range is Gpr_Node_Kind_Type range Gpr_Case_Construction .. Gpr_Case_Construction; --% no-document: True subtype Gpr_Case_Item_Range is Gpr_Node_Kind_Type range Gpr_Case_Item .. Gpr_Case_Item; --% no-document: True subtype Gpr_Compilation_Unit_Range is Gpr_Node_Kind_Type range Gpr_Compilation_Unit .. Gpr_Compilation_Unit; --% no-document: True subtype Gpr_Empty_Decl_Range is Gpr_Node_Kind_Type range Gpr_Empty_Decl .. Gpr_Empty_Decl; --% no-document: True subtype Gpr_Expr is Gpr_Node_Kind_Type range Gpr_Prefix .. Gpr_String_Literal; --% no-document: True subtype Gpr_Prefix_Range is Gpr_Node_Kind_Type range Gpr_Prefix .. Gpr_Prefix; --% no-document: True subtype Gpr_Single_Tok_Node is Gpr_Node_Kind_Type range Gpr_Identifier .. Gpr_String_Literal; --% no-document: True subtype Gpr_Identifier_Range is Gpr_Node_Kind_Type range Gpr_Identifier .. Gpr_Identifier; --% no-document: True subtype Gpr_Num_Literal_Range is Gpr_Node_Kind_Type range Gpr_Num_Literal .. Gpr_Num_Literal; --% no-document: True subtype Gpr_String_Literal_Range is Gpr_Node_Kind_Type range Gpr_String_Literal .. Gpr_String_Literal; --% no-document: True subtype Gpr_Limited_Node is Gpr_Node_Kind_Type range Gpr_Limited_Absent .. Gpr_Limited_Present; --% no-document: True subtype Gpr_Limited_Absent_Range is Gpr_Node_Kind_Type range Gpr_Limited_Absent .. Gpr_Limited_Absent; --% no-document: True subtype Gpr_Limited_Present_Range is Gpr_Node_Kind_Type range Gpr_Limited_Present .. Gpr_Limited_Present; --% no-document: True subtype Gpr_Others_Designator_Range is Gpr_Node_Kind_Type range Gpr_Others_Designator .. Gpr_Others_Designator; --% no-document: True subtype Gpr_Package_Decl_Range is Gpr_Node_Kind_Type range Gpr_Package_Decl .. Gpr_Package_Decl; --% no-document: True subtype Gpr_Package_Extension_Range is Gpr_Node_Kind_Type range Gpr_Package_Extension .. Gpr_Package_Extension; --% no-document: True subtype Gpr_Package_Renaming_Range is Gpr_Node_Kind_Type range Gpr_Package_Renaming .. Gpr_Package_Renaming; --% no-document: True subtype Gpr_Package_Spec_Range is Gpr_Node_Kind_Type range Gpr_Package_Spec .. Gpr_Package_Spec; --% no-document: True subtype Gpr_Project_Range is Gpr_Node_Kind_Type range Gpr_Project .. Gpr_Project; --% no-document: True subtype Gpr_Project_Declaration_Range is Gpr_Node_Kind_Type range Gpr_Project_Declaration .. Gpr_Project_Declaration; --% no-document: True subtype Gpr_Project_Extension_Range is Gpr_Node_Kind_Type range Gpr_Project_Extension .. Gpr_Project_Extension; --% no-document: True subtype Gpr_Project_Qualifier is Gpr_Node_Kind_Type range Gpr_Project_Qualifier_Abstract .. Gpr_Project_Qualifier_Standard; --% no-document: True subtype Gpr_Project_Qualifier_Abstract_Range is Gpr_Node_Kind_Type range Gpr_Project_Qualifier_Abstract .. Gpr_Project_Qualifier_Abstract; --% no-document: True subtype Gpr_Project_Qualifier_Aggregate_Range is Gpr_Node_Kind_Type range Gpr_Project_Qualifier_Aggregate .. Gpr_Project_Qualifier_Aggregate; --% no-document: True subtype Gpr_Project_Qualifier_Aggregate_Library_Range is Gpr_Node_Kind_Type range Gpr_Project_Qualifier_Aggregate_Library .. Gpr_Project_Qualifier_Aggregate_Library; --% no-document: True subtype Gpr_Project_Qualifier_Configuration_Range is Gpr_Node_Kind_Type range Gpr_Project_Qualifier_Configuration .. Gpr_Project_Qualifier_Configuration; --% no-document: True subtype Gpr_Project_Qualifier_Library_Range is Gpr_Node_Kind_Type range Gpr_Project_Qualifier_Library .. Gpr_Project_Qualifier_Library; --% no-document: True subtype Gpr_Project_Qualifier_Standard_Range is Gpr_Node_Kind_Type range Gpr_Project_Qualifier_Standard .. Gpr_Project_Qualifier_Standard; --% no-document: True subtype Gpr_String_Literal_At_Range is Gpr_Node_Kind_Type range Gpr_String_Literal_At .. Gpr_String_Literal_At; --% no-document: True subtype Gpr_Terms_Range is Gpr_Node_Kind_Type range Gpr_Terms .. Gpr_Terms; --% no-document: True subtype Gpr_Type_Reference_Range is Gpr_Node_Kind_Type range Gpr_Type_Reference .. Gpr_Type_Reference; --% no-document: True subtype Gpr_Typed_String_Decl_Range is Gpr_Node_Kind_Type range Gpr_Typed_String_Decl .. Gpr_Typed_String_Decl; --% no-document: True subtype Gpr_Variable_Decl_Range is Gpr_Node_Kind_Type range Gpr_Variable_Decl .. Gpr_Variable_Decl; --% no-document: True subtype Gpr_Variable_Reference_Range is Gpr_Node_Kind_Type range Gpr_Variable_Reference .. Gpr_Variable_Reference; --% no-document: True subtype Gpr_With_Decl_Range is Gpr_Node_Kind_Type range Gpr_With_Decl .. Gpr_With_Decl; --% no-document: True subtype Synthetic_Nodes is Gpr_Node_Kind_Type with Static_Predicate => False ; -- Set of nodes that are synthetic. -- -- Parsers cannot create synthetic nodes, so these correspond to no -- source text. These nodes are created dynamically for convenience -- during semantic analysis. Default_Grammar_Rule : constant Grammar_Rule := Compilation_Unit_Rule; -- Default grammar rule to use when parsing analysis units ------------------ -- Lexer inputs -- ------------------ type Lexer_Input_Kind is (File, -- Readable source file Bytes_Buffer, -- Buffer of undecoded bytes Text_Buffer -- Buffer of decoded bytes ); -- Kind of lexer input subtype Undecoded_Lexer_Input is Lexer_Input_Kind range File .. Bytes_Buffer; ------------ -- Tokens -- ------------ type Token_Kind is ( Gpr_Termination, Gpr_Lexing_Failure, Gpr_Identifier, Gpr_All, Gpr_Abstract, Gpr_At, Gpr_Case, Gpr_End, Gpr_For, Gpr_Is, Gpr_Limited, Gpr_Private, Gpr_Null, Gpr_Others, Gpr_Package, Gpr_Renames, Gpr_Type, Gpr_Use, Gpr_Pragma, Gpr_When, Gpr_With, Gpr_Extends, Gpr_Par_Open, Gpr_Par_Close, Gpr_Semicolon, Gpr_Colon, Gpr_Comma, Gpr_Dot, Gpr_Amp, Gpr_Tick, Gpr_Pipe, Gpr_Assign, Gpr_Arrow, Gpr_String, Gpr_Number, Gpr_Label, Gpr_Char, Gpr_Comment, Gpr_Whitespace ); -- Kind of token: indentifier, string literal, ... type Token_Family is (Alphanumericals, Default_Family); -- Groups of token kinds, to make the processing of some groups of token -- uniform. Token_Kind_To_Family : array (Token_Kind) of Token_Family := (Gpr_Termination => Default_Family, Gpr_Lexing_Failure => Default_Family, Gpr_Identifier => Alphanumericals, Gpr_All => Alphanumericals, Gpr_Abstract => Alphanumericals, Gpr_At => Alphanumericals, Gpr_Case => Alphanumericals, Gpr_End => Alphanumericals, Gpr_For => Alphanumericals, Gpr_Is => Alphanumericals, Gpr_Limited => Alphanumericals, Gpr_Private => Default_Family, Gpr_Null => Alphanumericals, Gpr_Others => Alphanumericals, Gpr_Package => Alphanumericals, Gpr_Renames => Alphanumericals, Gpr_Type => Alphanumericals, Gpr_Use => Alphanumericals, Gpr_Pragma => Alphanumericals, Gpr_When => Alphanumericals, Gpr_With => Alphanumericals, Gpr_Extends => Alphanumericals, Gpr_Par_Open => Default_Family, Gpr_Par_Close => Default_Family, Gpr_Semicolon => Default_Family, Gpr_Colon => Default_Family, Gpr_Comma => Default_Family, Gpr_Dot => Default_Family, Gpr_Amp => Default_Family, Gpr_Tick => Default_Family, Gpr_Pipe => Default_Family, Gpr_Assign => Default_Family, Gpr_Arrow => Default_Family, Gpr_String => Alphanumericals, Gpr_Number => Alphanumericals, Gpr_Label => Alphanumericals, Gpr_Char => Alphanumericals, Gpr_Comment => Default_Family, Gpr_Whitespace => Default_Family); -- Associate a token family to all token kinds -- --% document-value: False function Token_Kind_Name (Token_Id : Token_Kind) return String; -- Return a human-readable name for a token kind. function Token_Kind_Literal (Token_Id : Token_Kind) return Text_Type; -- Return the canonical literal corresponding to this token kind, or an -- empty string if this token has no literal. function Token_Error_Image (Token_Id : Token_Kind) return String; -- Return a string representation of ``Token_Id`` that is suitable in error -- messages. function To_Token_Kind (Raw : Raw_Token_Kind) return Token_Kind with Inline; function From_Token_Kind (Kind : Token_Kind) return Raw_Token_Kind with Inline; function Is_Token_Node (Kind : Gpr_Node_Kind_Type) return Boolean; -- Return whether Kind corresponds to a token node function Is_List_Node (Kind : Gpr_Node_Kind_Type) return Boolean; -- Return whether Kind corresponds to a list node function Is_Error_Node (Kind : Gpr_Node_Kind_Type) return Boolean; -- Return whether Kind corresponds to an error node type Visit_Status is (Into, Over, Stop); -- Helper type to control the node traversal process. See the -- ``Gpr_Parser.Analysis.Traverse`` function. ----------------------- -- Lexical utilities -- ----------------------- type Token_Reference is private; -- Reference to a token in an analysis unit. No_Token : constant Token_Reference; type Token_Data_Type is private; function "<" (Left, Right : Token_Reference) return Boolean; -- Assuming ``Left`` and ``Right`` belong to the same analysis unit, return -- whether ``Left`` came before ``Right`` in the source file. function Next (Token : Token_Reference; Exclude_Trivia : Boolean := False) return Token_Reference; -- Return a reference to the next token in the corresponding analysis unit. function Previous (Token : Token_Reference; Exclude_Trivia : Boolean := False) return Token_Reference; -- Return a reference to the previous token in the corresponding analysis -- unit. function Data (Token : Token_Reference) return Token_Data_Type; -- Return the data associated to ``Token`` function Is_Equivalent (L, R : Token_Reference) return Boolean; -- Return whether ``L`` and ``R`` are structurally equivalent tokens. This -- means that their position in the stream won't be taken into account, -- only the kind and text of the token. function Image (Token : Token_Reference) return String; -- Debug helper: return a human-readable text to represent a token function Text (Token : Token_Reference) return Text_Type; -- Return the text of the token as ``Text_Type`` function Text (First, Last : Token_Reference) return Text_Type; -- Compute the source buffer slice corresponding to the text that spans -- between the ``First`` and ``Last`` tokens (both included). This yields -- an empty slice if ``Last`` actually appears before ``First``. -- -- This raises a ``Constraint_Error`` if ``First`` and ``Last`` don't -- belong to the same analysis unit. function Get_Symbol (Token : Token_Reference) return Symbol_Type; -- Assuming that ``Token`` refers to a token that contains a symbol, return -- the corresponding symbol. function Kind (Token_Data : Token_Data_Type) return Token_Kind; -- Kind for this token. function Is_Trivia (Token : Token_Reference) return Boolean; -- Return whether this token is a trivia. If it's not, it's a regular -- token. function Is_Trivia (Token_Data : Token_Data_Type) return Boolean; -- Return whether this token is a trivia. If it's not, it's a regular -- token. function Index (Token : Token_Reference) return Token_Index; -- One-based index for this token/trivia. Tokens and trivias get their own -- index space. function Index (Token_Data : Token_Data_Type) return Token_Index; -- One-based index for this token/trivia. Tokens and trivias get their own -- index space. function Sloc_Range (Token_Data : Token_Data_Type) return Source_Location_Range; -- Source location range for this token. Note that the end bound is -- exclusive. function Origin_Filename (Token : Token_Reference) return String; -- Return the name of the file whose content was scanned to create Token. -- Return an empty string if the source comes from a memory buffer instead -- of a file. function Origin_Charset (Token : Token_Reference) return String; -- Return the charset used to decode the source that was scanned to create -- Token. Return an empty string if the source was already decoded during -- the scan. function Convert (TDH : Token_Data_Handler; Token : Token_Reference; Raw_Data : Stored_Token_Data) return Token_Data_Type; -- Turn data from ``TDH`` and ``Raw_Data`` into a user-ready token data -- record. type Child_Or_Trivia is (Child, Trivia); -- Discriminator for the ``Child_Record`` type function Raw_Data (T : Token_Reference) return Stored_Token_Data; -- Return the raw token data for ``T`` function Token_Node_Kind (Kind : Gpr_Node_Kind_Type) return Token_Kind with Pre => Is_Token_Node (Kind); -- Return the token kind corresponding to the given token node kind private type Token_Safety_Net is record Context : Gpr_Parser_Support.Internal.Analysis.Internal_Context; Context_Version : Version_Number; -- Analysis context and version number at the time this safety net was -- produced. -- -- TODO: it is not possible to refer to -- $.Implementation.Internal_Context from this spec (otherwise we get a -- circular dependency). For now, use the generic pointer from -- Gpr_Parser_Support (hack), but in the future the Token_Reference type -- (and this this safety net type) will go to the generic API, so we -- will get rid of this hack. TDH_Version : Version_Number; -- Version of the token data handler at the time this safety net was -- produced. end record; -- Information to embed in public APIs with token references, used to check -- before using the references that they are not stale. No_Token_Safety_Net : constant Token_Safety_Net := (Gpr_Parser_Support.Internal.Analysis.No_Internal_Context, 0, 0); type Token_Reference is record TDH : Token_Data_Handler_Access; -- Token data handler that owns this token Index : Token_Or_Trivia_Index; -- Identifier for the trivia or the token this refers to Safety_Net : Token_Safety_Net; end record; procedure Check_Safety_Net (Self : Token_Reference); -- If ``Self`` is a stale token reference, raise a -- ``Stale_Reference_Error`` error. No_Token : constant Token_Reference := (null, No_Token_Or_Trivia_Index, No_Token_Safety_Net); type Token_Data_Type is record Kind : Token_Kind; -- See documentation for the Kind accessor Is_Trivia : Boolean; -- See documentation for the Is_Trivia accessor Index : Token_Index; -- See documentation for the Index accessor Source_Buffer : Text_Cst_Access; -- Text for the original source file Source_First : Positive; Source_Last : Natural; -- Bounds in Source_Buffer for the text corresponding to this token Sloc_Range : Source_Location_Range; -- See documenation for the Sloc_Range accessor end record; end Gpr_Parser.Common;
charlie5/lace
Ada
2,463
adb
with gel.Sprite, gel.World, ada.unchecked_Deallocation; package body gel.Joint is function to_GEL (the_Joint : standard.physics.Joint.view) return gel.Joint.view is begin return gel.Joint.view (the_Joint.user_Data); end to_GEL; --------- --- Forge -- procedure define (Self : access Item; Sprite_A, Sprite_B : access gel.Sprite.item'class) is begin Self.Sprite_A := Sprite_A; Self.Sprite_B := Sprite_B; end define; procedure free (Self : in out View) is procedure deallocate is new ada.unchecked_Deallocation (Joint.item'Class, Joint.view); begin if Self /= null then Self.destroy; end if; deallocate (Self); end free; -------------- --- Attributes -- function Sprite_A (Self : in Item'Class) return access gel.Sprite.item'class is begin return Self.Sprite_A; end Sprite_A; function Sprite_B (Self : in Item'Class) return access gel.Sprite.item'class is begin return Self.Sprite_B; end Sprite_B; ---------- --- Hinges -- function local_Anchor_on_A (Self : in Item) return Vector_3 is begin return Self.local_Anchor_on_A; end local_Anchor_on_A; function local_Anchor_on_B (Self : in Item) return Vector_3 is begin return Self.local_Anchor_on_B; end local_Anchor_on_B; procedure local_Anchor_on_A_is (Self : out Item; Now : in Vector_3) is begin Self.local_Anchor_on_A := Now; if Self.Sprite_A.World /= null then Self.Sprite_A.World.set_local_Anchor_on_A (for_Joint => Self'unchecked_Access, To => Now); end if; end local_Anchor_on_A_is; procedure local_Anchor_on_B_is (Self : out Item; Now : in Vector_3) is begin Self.local_Anchor_on_B := Now; if Self.Sprite_B.World /= null then Self.Sprite_B.World.set_local_Anchor_on_B (for_Joint => Self'unchecked_Access, To => Now); end if; end local_Anchor_on_B_is; function reaction_Force (Self : in Item'Class) return Vector_3 is begin return Self.Physics.reaction_Force; end reaction_Force; function reaction_Torque (Self : in Item'Class) return Real is begin return Self.Physics.reaction_Torque; end reaction_Torque; end gel.Joint;
mmarx/lovelace
Ada
972
ads
with Ada.Text_IO; with Interfaces.C; package Timings is type Usage_Who is (Self, Children, Thread); type IO_Operations_Type is new Interfaces.C.long; type Context_Switches_Type is new Interfaces.C.long; type Time_Type is delta 10.0 ** (-6) digits 18 range 0.0 .. 10.0 ** 7; type Usage_Type is record User_Time : Time_Type; System_Time : Time_Type; In_IO : IO_Operations_Type; Out_IO : IO_Operations_Type; Voluntary_Context_Switches : Context_Switches_Type; Involuntary_Context_Switches : Context_Switches_Type; end record; function "-" (Left, Right : in Usage_Type) return Usage_Type; function Resource_Usage (Who : in Usage_Who) return Usage_Type; procedure Put (Item : in Time_Type); procedure Put (File : in Ada.Text_IO.File_Type; Item : in Time_Type); procedure Put (Item : in Usage_Type); procedure Put (File : in Ada.Text_IO.File_Type; Item : in Usage_Type); end Timings;
reznikmm/matreshka
Ada
3,739
ads
------------------------------------------------------------------------------ -- -- -- Matreshka Project -- -- -- -- Open Document Toolkit -- -- -- -- Runtime Library Component -- -- -- ------------------------------------------------------------------------------ -- -- -- Copyright © 2014, Vadim Godunko <[email protected]> -- -- All rights reserved. -- -- -- -- Redistribution and use in source and binary forms, with or without -- -- modification, are permitted provided that the following conditions -- -- are met: -- -- -- -- * Redistributions of source code must retain the above copyright -- -- notice, this list of conditions and the following disclaimer. -- -- -- -- * Redistributions in binary form must reproduce the above copyright -- -- notice, this list of conditions and the following disclaimer in the -- -- documentation and/or other materials provided with the distribution. -- -- -- -- * Neither the name of the Vadim Godunko, IE nor the names of its -- -- contributors may be used to endorse or promote products derived from -- -- this software without specific prior written permission. -- -- -- -- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -- -- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -- -- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -- -- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -- -- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -- -- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED -- -- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -- -- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -- -- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -- -- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -- -- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- -- -- ------------------------------------------------------------------------------ -- $Revision$ $Date$ ------------------------------------------------------------------------------ with XML.DOM.Attributes; package ODF.DOM.Draw_Background_Size_Attributes is pragma Preelaborate; type ODF_Draw_Background_Size_Attribute is limited interface and XML.DOM.Attributes.DOM_Attribute; type ODF_Draw_Background_Size_Attribute_Access is access all ODF_Draw_Background_Size_Attribute'Class with Storage_Size => 0; end ODF.DOM.Draw_Background_Size_Attributes;
charlie5/cBound
Ada
1,647
ads
-- This file is generated by SWIG. Please do not modify by hand. -- with Interfaces; with Interfaces.C; with Interfaces.C.Pointers; package xcb.xcb_glx_get_mapdv_request_t is -- Item -- type Item is record major_opcode : aliased Interfaces.Unsigned_8; minor_opcode : aliased Interfaces.Unsigned_8; length : aliased Interfaces.Unsigned_16; context_tag : aliased xcb.xcb_glx_context_tag_t; target : aliased Interfaces.Unsigned_32; query : aliased Interfaces.Unsigned_32; end record; -- Item_Array -- type Item_Array is array (Interfaces.C .size_t range <>) of aliased xcb.xcb_glx_get_mapdv_request_t .Item; -- Pointer -- package C_Pointers is new Interfaces.C.Pointers (Index => Interfaces.C.size_t, Element => xcb.xcb_glx_get_mapdv_request_t.Item, Element_Array => xcb.xcb_glx_get_mapdv_request_t.Item_Array, Default_Terminator => (others => <>)); subtype Pointer is C_Pointers.Pointer; -- Pointer_Array -- type Pointer_Array is array (Interfaces.C .size_t range <>) of aliased xcb.xcb_glx_get_mapdv_request_t .Pointer; -- Pointer_Pointer -- package C_Pointer_Pointers is new Interfaces.C.Pointers (Index => Interfaces.C.size_t, Element => xcb.xcb_glx_get_mapdv_request_t.Pointer, Element_Array => xcb.xcb_glx_get_mapdv_request_t.Pointer_Array, Default_Terminator => null); subtype Pointer_Pointer is C_Pointer_Pointers.Pointer; end xcb.xcb_glx_get_mapdv_request_t;
CiscoM31/openapi-generator
Ada
12,920
adb
-- OpenAPI Petstore -- This is a sample server Petstore server. For this sample, you can use the api key `special_key` to test the authorization filters. -- -- The version of the OpenAPI document: 1.0.0 -- -- -- NOTE: This package is auto generated by OpenAPI-Generator 7.0.0-SNAPSHOT. -- https://openapi-generator.tech -- Do not edit the class manually. pragma Warnings (Off, "*is not referenced"); with Swagger.Streams; package body Samples.Petstore.Clients is pragma Style_Checks ("-bmrIu"); Mime_1 : aliased constant String := "multipart/form-data"; Media_List_1 : constant Swagger.Mime_List := ( 1 => Swagger.Mime_Json, 2 => Swagger.Mime_Xml ); Media_List_2 : constant Swagger.Mime_List := ( 1 => Swagger.Mime_Json ); Media_List_3 : constant Swagger.Mime_List := ( 1 => Swagger.Mime_Form ); Media_List_4 : constant Swagger.Mime_List := ( 1 => Mime_1'Access ); -- parameter name mapping test procedure Get_Parameter_Name_Mapping (Client : in out Client_Type; UnderscoreType : in Swagger.Long; P_Type : in Swagger.UString; TypeWithUnderscore : in Swagger.UString; Http_Debug_Option : in Swagger.UString) is URI : Swagger.Clients.URI_Type; begin URI.Add_Param ("type", P_Type); URI.Add_Param ("http_debug_option", Http_Debug_Option); URI.Set_Path ("/fake/parameter-name-mapping"); Client.Call (Swagger.Clients.GET, URI); end Get_Parameter_Name_Mapping; -- Add a new pet to the store procedure Add_Pet (Client : in out Client_Type; Pet_Type : in Samples.Petstore.Models.Pet_Type; Result : out Samples.Petstore.Models.Pet_Type) is URI : Swagger.Clients.URI_Type; Req : Swagger.Clients.Request_Type; Reply : Swagger.Value_Type; begin Client.Set_Accept (Media_List_1); Client.Initialize (Req, Media_List_1); Samples.Petstore.Models.Serialize (Req.Stream, "", Pet_Type); URI.Set_Path ("/pet"); Client.Call (Swagger.Clients.POST, URI, Req, Reply); Samples.Petstore.Models.Deserialize (Reply, "", Result); end Add_Pet; -- Deletes a pet procedure Delete_Pet (Client : in out Client_Type; Pet_Id : in Swagger.Long; Api_Key : in Swagger.Nullable_UString) is URI : Swagger.Clients.URI_Type; begin URI.Set_Path ("/pet/{petId}"); URI.Set_Path_Param ("petId", Swagger.To_String (Pet_Id)); Client.Call (Swagger.Clients.DELETE, URI); end Delete_Pet; -- Finds Pets by status -- Multiple status values can be provided with comma separated strings procedure Find_Pets_By_Status (Client : in out Client_Type; Status : in Swagger.UString_Vectors.Vector; Result : out Samples.Petstore.Models.Pet_Type_Vectors.Vector) is URI : Swagger.Clients.URI_Type; Reply : Swagger.Value_Type; begin Client.Set_Accept (Media_List_1); URI.Add_Param ("status", Status); URI.Set_Path ("/pet/findByStatus"); Client.Call (Swagger.Clients.GET, URI, Reply); Samples.Petstore.Models.Deserialize (Reply, "", Result); end Find_Pets_By_Status; -- Finds Pets by tags -- Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing. procedure Find_Pets_By_Tags (Client : in out Client_Type; Tags : in Swagger.UString_Vectors.Vector; Result : out Samples.Petstore.Models.Pet_Type_Vectors.Vector) is URI : Swagger.Clients.URI_Type; Reply : Swagger.Value_Type; begin Client.Set_Accept (Media_List_1); URI.Add_Param ("tags", Tags); URI.Set_Path ("/pet/findByTags"); Client.Call (Swagger.Clients.GET, URI, Reply); Samples.Petstore.Models.Deserialize (Reply, "", Result); end Find_Pets_By_Tags; -- Find pet by ID -- Returns a single pet procedure Get_Pet_By_Id (Client : in out Client_Type; Pet_Id : in Swagger.Long; Result : out Samples.Petstore.Models.Pet_Type) is URI : Swagger.Clients.URI_Type; Reply : Swagger.Value_Type; begin Client.Set_Accept (Media_List_1); URI.Set_Path ("/pet/{petId}"); URI.Set_Path_Param ("petId", Swagger.To_String (Pet_Id)); Client.Call (Swagger.Clients.GET, URI, Reply); Samples.Petstore.Models.Deserialize (Reply, "", Result); end Get_Pet_By_Id; -- Update an existing pet procedure Update_Pet (Client : in out Client_Type; Pet_Type : in Samples.Petstore.Models.Pet_Type; Result : out Samples.Petstore.Models.Pet_Type) is URI : Swagger.Clients.URI_Type; Req : Swagger.Clients.Request_Type; Reply : Swagger.Value_Type; begin Client.Set_Accept (Media_List_1); Client.Initialize (Req, Media_List_1); Samples.Petstore.Models.Serialize (Req.Stream, "", Pet_Type); URI.Set_Path ("/pet"); Client.Call (Swagger.Clients.PUT, URI, Req, Reply); Samples.Petstore.Models.Deserialize (Reply, "", Result); end Update_Pet; -- Updates a pet in the store with form data procedure Update_Pet_With_Form (Client : in out Client_Type; Pet_Id : in Swagger.Long; Name : in Swagger.Nullable_UString; Status : in Swagger.Nullable_UString) is URI : Swagger.Clients.URI_Type; Req : Swagger.Clients.Request_Type; begin Client.Initialize (Req, Media_List_3); Req.Stream.Write_Entity ("name", Name); Req.Stream.Write_Entity ("status", Status); URI.Set_Path ("/pet/{petId}"); URI.Set_Path_Param ("petId", Swagger.To_String (Pet_Id)); Client.Call (Swagger.Clients.POST, URI, Req); end Update_Pet_With_Form; -- uploads an image procedure Upload_File (Client : in out Client_Type; Pet_Id : in Swagger.Long; Additional_Metadata : in Swagger.Nullable_UString; File : in Swagger.File_Part_Type; Result : out Samples.Petstore.Models.ApiResponse_Type) is URI : Swagger.Clients.URI_Type; Req : Swagger.Clients.Request_Type; Reply : Swagger.Value_Type; begin Client.Set_Accept (Media_List_2); Client.Initialize (Req, Media_List_4); Req.Stream.Write_Entity ("additionalMetadata", Additional_Metadata); Req.Stream.Write_Entity ("file", File); URI.Set_Path ("/pet/{petId}/uploadImage"); URI.Set_Path_Param ("petId", Swagger.To_String (Pet_Id)); Client.Call (Swagger.Clients.POST, URI, Req, Reply); Samples.Petstore.Models.Deserialize (Reply, "", Result); end Upload_File; -- Delete purchase order by ID -- For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors procedure Delete_Order (Client : in out Client_Type; Order_Id : in Swagger.UString) is URI : Swagger.Clients.URI_Type; begin URI.Set_Path ("/store/order/{orderId}"); URI.Set_Path_Param ("orderId", Order_Id); Client.Call (Swagger.Clients.DELETE, URI); end Delete_Order; -- Returns pet inventories by status -- Returns a map of status codes to quantities procedure Get_Inventory (Client : in out Client_Type; Result : out Swagger.Integer_Map) is URI : Swagger.Clients.URI_Type; Reply : Swagger.Value_Type; begin Client.Set_Accept (Media_List_2); URI.Set_Path ("/store/inventory"); Client.Call (Swagger.Clients.GET, URI, Reply); Swagger.Streams.Deserialize (Reply, "", Result); end Get_Inventory; -- Find purchase order by ID -- For valid response try integer IDs with value <= 5 or > 10. Other values will generate exceptions procedure Get_Order_By_Id (Client : in out Client_Type; Order_Id : in Swagger.Long; Result : out Samples.Petstore.Models.Order_Type) is URI : Swagger.Clients.URI_Type; Reply : Swagger.Value_Type; begin Client.Set_Accept (Media_List_1); URI.Set_Path ("/store/order/{orderId}"); URI.Set_Path_Param ("orderId", Swagger.To_String (Order_Id)); Client.Call (Swagger.Clients.GET, URI, Reply); Samples.Petstore.Models.Deserialize (Reply, "", Result); end Get_Order_By_Id; -- Place an order for a pet procedure Place_Order (Client : in out Client_Type; Order_Type : in Samples.Petstore.Models.Order_Type; Result : out Samples.Petstore.Models.Order_Type) is URI : Swagger.Clients.URI_Type; Req : Swagger.Clients.Request_Type; Reply : Swagger.Value_Type; begin Client.Set_Accept (Media_List_1); Client.Initialize (Req, Media_List_2); Samples.Petstore.Models.Serialize (Req.Stream, "", Order_Type); URI.Set_Path ("/store/order"); Client.Call (Swagger.Clients.POST, URI, Req, Reply); Samples.Petstore.Models.Deserialize (Reply, "", Result); end Place_Order; -- Create user -- This can only be done by the logged in user. procedure Create_User (Client : in out Client_Type; User_Type : in Samples.Petstore.Models.User_Type) is URI : Swagger.Clients.URI_Type; Req : Swagger.Clients.Request_Type; begin Client.Initialize (Req, Media_List_2); Samples.Petstore.Models.Serialize (Req.Stream, "", User_Type); URI.Set_Path ("/user"); Client.Call (Swagger.Clients.POST, URI, Req); end Create_User; -- Creates list of users with given input array procedure Create_Users_With_Array_Input (Client : in out Client_Type; User : in Samples.Petstore.Models.User_Type_Vectors.Vector) is URI : Swagger.Clients.URI_Type; Req : Swagger.Clients.Request_Type; begin Client.Initialize (Req, Media_List_2); Samples.Petstore.Models.Serialize (Req.Stream, "", User); URI.Set_Path ("/user/createWithArray"); Client.Call (Swagger.Clients.POST, URI, Req); end Create_Users_With_Array_Input; -- Creates list of users with given input array procedure Create_Users_With_List_Input (Client : in out Client_Type; User : in Samples.Petstore.Models.User_Type_Vectors.Vector) is URI : Swagger.Clients.URI_Type; Req : Swagger.Clients.Request_Type; begin Client.Initialize (Req, Media_List_2); Samples.Petstore.Models.Serialize (Req.Stream, "", User); URI.Set_Path ("/user/createWithList"); Client.Call (Swagger.Clients.POST, URI, Req); end Create_Users_With_List_Input; -- Delete user -- This can only be done by the logged in user. procedure Delete_User (Client : in out Client_Type; Username : in Swagger.UString) is URI : Swagger.Clients.URI_Type; begin URI.Set_Path ("/user/{username}"); URI.Set_Path_Param ("username", Username); Client.Call (Swagger.Clients.DELETE, URI); end Delete_User; -- Get user by user name procedure Get_User_By_Name (Client : in out Client_Type; Username : in Swagger.UString; Result : out Samples.Petstore.Models.User_Type) is URI : Swagger.Clients.URI_Type; Reply : Swagger.Value_Type; begin Client.Set_Accept (Media_List_1); URI.Set_Path ("/user/{username}"); URI.Set_Path_Param ("username", Username); Client.Call (Swagger.Clients.GET, URI, Reply); Samples.Petstore.Models.Deserialize (Reply, "", Result); end Get_User_By_Name; -- Logs user into the system procedure Login_User (Client : in out Client_Type; Username : in Swagger.UString; Password : in Swagger.UString; Result : out Swagger.UString) is URI : Swagger.Clients.URI_Type; Reply : Swagger.Value_Type; begin Client.Set_Accept (Media_List_1); URI.Add_Param ("username", Username); URI.Add_Param ("password", Password); URI.Set_Path ("/user/login"); Client.Call (Swagger.Clients.GET, URI, Reply); Swagger.Streams.Deserialize (Reply, "", Result); end Login_User; -- Logs out current logged in user session procedure Logout_User (Client : in out Client_Type) is URI : Swagger.Clients.URI_Type; begin URI.Set_Path ("/user/logout"); Client.Call (Swagger.Clients.GET, URI); end Logout_User; -- Updated user -- This can only be done by the logged in user. procedure Update_User (Client : in out Client_Type; Username : in Swagger.UString; User_Type : in Samples.Petstore.Models.User_Type) is URI : Swagger.Clients.URI_Type; Req : Swagger.Clients.Request_Type; begin Client.Initialize (Req, Media_List_2); Samples.Petstore.Models.Serialize (Req.Stream, "", User_Type); URI.Set_Path ("/user/{username}"); URI.Set_Path_Param ("username", Username); Client.Call (Swagger.Clients.PUT, URI, Req); end Update_User; end Samples.Petstore.Clients;
apple-oss-distributions/old_ncurses
Ada
3,783
ads
------------------------------------------------------------------------------ -- -- -- GNAT ncurses Binding Samples -- -- -- -- Sample.Menu_Demo.Handler -- -- -- -- S P E C -- -- -- ------------------------------------------------------------------------------ -- Copyright (c) 1998 Free Software Foundation, Inc. -- -- -- -- Permission is hereby granted, free of charge, to any person obtaining a -- -- copy of this software and associated documentation files (the -- -- "Software"), to deal in the Software without restriction, including -- -- without limitation the rights to use, copy, modify, merge, publish, -- -- distribute, distribute with modifications, sublicense, and/or sell -- -- copies of the Software, and to permit persons to whom the Software is -- -- furnished to do so, subject to the following conditions: -- -- -- -- The above copyright notice and this permission notice shall be included -- -- in all copies or substantial portions of the Software. -- -- -- -- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS -- -- OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -- -- MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. -- -- IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, -- -- DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR -- -- OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR -- -- THE USE OR OTHER DEALINGS IN THE SOFTWARE. -- -- -- -- Except as contained in this notice, the name(s) of the above copyright -- -- holders shall not be used in advertising or otherwise to promote the -- -- sale, use or other dealings in this Software without prior written -- -- authorization. -- ------------------------------------------------------------------------------ -- Author: Juergen Pfeifer <[email protected]> 1996 -- Version Control -- $Revision: 1.1.1.1 $ -- 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.Menus; use Terminal_Interface.Curses.Menus; generic with function My_Driver (Men : Menu; K : Key_Code; Pan : Panel) return Boolean; package Sample.Menu_Demo.Handler is procedure Drive_Me (M : in Menu; Lin : in Line_Position; Col : in Column_Position; Title : in String := ""); -- Position the menu at the given point and drive it. procedure Drive_Me (M : in Menu; Title : in String := ""); -- Center menu and drive it. end Sample.Menu_Demo.Handler;