repo_name
stringlengths
9
74
language
stringclasses
1 value
length_bytes
int64
11
9.34M
extension
stringclasses
2 values
content
stringlengths
11
9.34M
1Crazymoney/LearnAda
Ada
5,586
adb
with hauntedhouse, tools; use hauntedhouse, tools; procedure GhostSurvivor is -- procedure Print(pos: Position) is -- begin -- Output.Puts("("&Positive'Image(pos.x) &","&Positive'Image(pos.y)&")"); -- end Print; task Joe is entry Help; end Joe; task body Joe is helps: Natural:=0; -- eddigi segítségek száma begin loop select when helps<3 => accept Help do -- csak ha még 3-nál kevesebbszer segítettünk helps:=helps+1; -- ++segítségek OutPut.Puts("*************Joe "&Natural'Image(helps) &". alkalommal segit.********************",1); -- helyzetjelentés end Help; or terminate; -- ha 3-nál többször segítettünk, akkor "felszabadulunk" a fénybe :) end select; delay 3.0; -- Joe takarítja büntetésből a kastélyt, amiért segített end loop; end Joe; -- királylány taszk task Princess is entry Frightens(pos: Position; num:Positive); -- "meghall" egy ijesztést egy helyről, és azt, hogy kitől jött end Princess; task body Princess is current_pos: Position:=(1,3); -- pozíció a kastélyban life: Natural:= 3; -- életerő type Direction is (left,right,up,down); -- irányok package Dir_Generator is new tools.Random_Generator(Direction); -- irány-randomgenerátor procedure Step is -- ellépteti a királylányt egy következő legális pozícióba (folyósó vagy szoba) tmp_pos:Position; dir: Direction; begin loop tmp_pos:=current_pos; dir:=Dir_Generator.GetRandom; case dir is when up => tmp_pos.y:=current_pos.y-1; when right => tmp_pos.x:=current_pos.x+1; when down => tmp_pos.y:=current_pos.y+1; when left => tmp_pos.x:=current_pos.x-1; end case; exit when hauntedhouse.IsCorrect(tmp_pos); -- amíg nem egy megléphető helyre mennénk end loop; current_pos:=tmp_pos; end step; procedure Startled(num:Positive) is -- "begyullad" begin life:=life-1; -- életerőt veszít Output.Puts("***Jaj! Megijesztett a Szellem_"&Positive'Image(num)&"! *** Eleterom: "&Natural'Image(life)&" ***",1); -- jelentés :) end Startled; begin loop Output.Puts("Kiralylany: ("&Positive'Image(current_pos.x) &","&Positive'Image(current_pos.y)&") helyiseg: "&Fields'Image(GetField(current_pos)),1); -- helyzetjelentés :) select when GetField(current_pos)/=R => accept Frightens(pos:Position; num:Positive) -- szobában nem ijeszthetnek meg do if pos=current_pos then -- ha onnan jött az ijesztgetés, ahol épp vagyunk if Joe'Callable then -- ha Joe még "él"... select Joe.Help; -- ... akkor segítséget próbálunk kérni else Startled(num); -- ha nem sikerül "begyulladunk" end select; else -- pláne, ha Joe már nem is "él" Startled(num); end if; end if; end Frightens; or delay 1.0; -- eddig maradunk egy helyen end select; Step; -- tovább haladunk a kastélyban exit when life<1 or GetField(current_pos)=E; -- "meghal" a királylány, vagy kijut end loop; if life<1 then Output.Puts("Halalra remultem. Beadom a kulcsot.",1); else Output.Puts("Kijutottam!",1); end if; exception when others => Output.Puts("Error with Princess.",1); end Princess; type Dur_Ptr is access Duration; -- szellem taszk típus task type Ghost(my_num:Positive; wait: Dur_Ptr) is end Ghost; task body Ghost is current_pos: Position; -- pozíció a kastélyban begin while Princess'Callable loop -- amíg a királylány él és még a kastélyban van current_pos:=hauntedhouse.GetRandPos; -- átugrunk egy random helyre (fal is lehet) if Princess'Callable then Output.Puts("Szellem_"&Positive'Image(my_num)&": ("&Positive'Image(current_pos.x) &","&Positive'Image(current_pos.y)&") Huh!!!",1); -- helyzetjelentés select Princess.Frightens(current_pos,my_num); -- ijesztünk egyet or delay wait.all; end select; end if; --delay wait.all; -- kipihenjük magunkat end loop; exception when others => Output.Puts("Szellem_"&Positive'Image(my_num)&" kiszall.",1); end Ghost; -- varázsló taszk típus task type Wizard(ghost_num: Positive; wait: access Duration) is end Wizard; task body Wizard is type Ghost_Ptr is access Ghost; -- szellem-taszk pointer típus ptr: Ghost_Ptr; -- szellem-taszk pointer dur: Dur_Ptr; -- várakozási idő begin for I in 1..ghost_num loop -- létrehozunk ghost_num-nyi szellemet delay wait.all; -- felkészül a szellemidézésre dur:= new Duration'(Duration(I)*wait.all); -- sorszám*dur lesz a szellem szusszanási ideje ptr:=new Ghost(I,dur); -- új szellem megidézése end loop; end Wizard; --tmp: array(1..2) of Ghost; -- statikus szellemek :) dur: Dur_Ptr:=new Duration'(0.2); Count_Kartoffel: Wizard(9,dur); begin -- főprogram null; exception when others => Output.Puts("Catched an exception in main."); end GhostSurvivor;
zhmu/ananas
Ada
4,933
ads
------------------------------------------------------------------------------ -- -- -- GNAT LIBRARY COMPONENTS -- -- -- -- G N A T . B O U N D E D _ B U F F E R S -- -- -- -- S p e c -- -- -- -- Copyright (C) 2003-2022, AdaCore -- -- -- -- GNAT is free software; you can redistribute it and/or modify it under -- -- terms of the GNU General Public License as published by the Free Soft- -- -- ware Foundation; either version 3, or (at your option) any later ver- -- -- sion. GNAT is distributed in the hope that it will be useful, but WITH- -- -- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY -- -- or FITNESS FOR A PARTICULAR PURPOSE. -- -- -- -- As a special exception under Section 7 of GPL version 3, you are granted -- -- additional permissions described in the GCC Runtime Library Exception, -- -- version 3.1, as published by the Free Software Foundation. -- -- -- -- You should have received a copy of the GNU General Public License and -- -- a copy of the GCC Runtime Library Exception along with this program; -- -- see the files COPYING3 and COPYING.RUNTIME respectively. If not, see -- -- <http://www.gnu.org/licenses/>. -- -- -- -- GNAT was originally developed by the GNAT team at New York University. -- -- It is now maintained by Ada Core Technologies Inc (http://www.gnat.com). -- -- -- ------------------------------------------------------------------------------ -- This package provides a thread-safe generic bounded buffer abstraction. -- Instances are useful directly or as parts of the implementations of other -- abstractions, such as mailboxes. -- Bounded_Buffer is declared explicitly as a protected type, rather than as -- a simple limited private type completed as a protected type, so that -- clients may make calls accordingly (i.e., conditional/timed entry calls). with System; generic type Element is private; -- The type of the values contained within buffer objects package GNAT.Bounded_Buffers is pragma Pure; type Content is array (Positive range <>) of Element; -- Content is an internal artefact that cannot be hidden because protected -- types cannot contain type declarations. Default_Ceiling : constant System.Priority := System.Default_Priority; -- A convenience value for the Ceiling discriminant protected type Bounded_Buffer (Capacity : Positive; -- Objects of type Bounded_Buffer specify the maximum number of Element -- values they can hold via the discriminant Capacity. Ceiling : System.Priority) -- Users must specify the ceiling priority for the object. If the -- Real-Time Systems Annex is not in use this value is not important. is pragma Priority (Ceiling); entry Insert (Item : Element); -- Insert Item into the buffer, blocks caller until space is available entry Remove (Item : out Element); -- Remove next available Element from buffer. Blocks caller until an -- Element is available. function Empty return Boolean; -- Returns whether the instance contains any Elements. -- Note: State may change immediately after call returns. function Full return Boolean; -- Returns whether any space remains within the instance. -- Note: State may change immediately after call returns. function Extent return Natural; -- Returns the number of Element values currently held -- within the instance. -- Note: State may change immediately after call returns. private Values : Content (1 .. Capacity); -- The container for the values held by the buffer instance Next_In : Positive := 1; -- The index of the next Element inserted. Wraps around Next_Out : Positive := 1; -- The index of the next Element removed. Wraps around Count : Natural := 0; -- The number of Elements currently held end Bounded_Buffer; end GNAT.Bounded_Buffers;
zrmyers/GLFWAda
Ada
3,527
adb
-------------------------------------------------------------------------------- -- MIT License -- -- Copyright (c) 2020 Zane Myers -- -- 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.Text_IO; With Glfw; procedure Glfw_Test.Environment is -- The default window configuration is used, with no client API specified. window_hints : Glfw.Record_Window_Hints := ( Client_Api => Glfw.NO_API, others => <> ); window_handle : Glfw.Glfw_Window := Glfw.No_Window; required_extension_names : Glfw.Glfw_String_Vector; begin Ada.Text_IO.Put_Line("Initializing GLFW"); -- Initialize GLFW Glfw.Platform_Init; Ada.Text_IO.Put_Line("Initializing Window"); -- Set window hints Glfw.Window_Set_Hints( hints => window_hints); -- Initialize a GLFW Window window_handle := Glfw.Window_Create( width => 1024, height => 768, title => "Hello World!"); Ada.Text_IO.Put_Line("Running GLFW Main Loop"); Glfw.Get_Required_Instance_Extensions(required_extension_names); for name of required_extension_names loop Ada.Text_IO.Put_Line("Required_Extension: " & Glfw.To_String(name)); end loop; -- Main Loop loop ------------------------------------------------------------------------ -- This loop will run forever until the user closes the window or some -- kind of exception occurs, which causes the program to begin handling -- the exception. ------------------------------------------------------------------------ pragma Warnings (Off, "variable ""window_handle"" is not modified in loop body"); pragma Warnings (Off, "possible infinite loop"); exit when Glfw.Window_Should_Close(window_handle => window_handle); pragma Warnings (On, "variable ""window_handle"" is not modified in loop body"); pragma Warnings (On, "possible infinite loop"); -- Poll for Glfw events Glfw.Platform_Process_Events; end loop; Ada.Text_IO.Put_Line("Destroying Window"); Glfw.Window_Destroy(window_handle => window_handle); Ada.Text_IO.Put_Line("Shutting Down GLFW"); -- Shut down the GLFW instance Glfw.Platform_Shutdown; end Glfw_Test.Environment;
zhmu/ananas
Ada
6,896
ads
------------------------------------------------------------------------------ -- -- -- GNAT COMPILER COMPONENTS -- -- -- -- S Y S T E M . R E G E X P -- -- -- -- S p e c -- -- -- -- Copyright (C) 1998-2022, AdaCore -- -- -- -- GNAT is free software; you can redistribute it and/or modify it under -- -- terms of the GNU General Public License as published by the Free Soft- -- -- ware Foundation; either version 3, or (at your option) any later ver- -- -- sion. GNAT is distributed in the hope that it will be useful, but WITH- -- -- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY -- -- or FITNESS FOR A PARTICULAR PURPOSE. -- -- -- -- As a special exception under Section 7 of GPL version 3, you are granted -- -- additional permissions described in the GCC Runtime Library Exception, -- -- version 3.1, as published by the Free Software Foundation. -- -- -- -- You should have received a copy of the GNU General Public License and -- -- a copy of the GCC Runtime Library Exception along with this program; -- -- see the files COPYING3 and COPYING.RUNTIME respectively. If not, see -- -- <http://www.gnu.org/licenses/>. -- -- -- -- GNAT was originally developed by the GNAT team at New York University. -- -- Extensive contributions were provided by Ada Core Technologies Inc. -- -- -- ------------------------------------------------------------------------------ -- Simple Regular expression matching -- This package provides a simple implementation of a regular expression -- pattern matching algorithm, using a subset of the syntax of regular -- expressions copied from familiar Unix style utilities. -- Note: this package is in the System hierarchy so that it can be directly -- be used by other predefined packages. User access to this package is via -- a renaming of this package in GNAT.Regexp (file g-regexp.ads). with Ada.Finalization; package System.Regexp is -- The regular expression must first be compiled, using the Compile -- function, which creates a finite state matching table, allowing -- very fast matching once the expression has been compiled. -- The following is the form of a regular expression, expressed in Ada -- reference manual style BNF is as follows -- regexp ::= term -- regexp ::= term | term -- alternation (term or term ...) -- term ::= item -- term ::= item item ... -- concatenation (item then item) -- item ::= elmt -- match elmt -- item ::= elmt * -- zero or more elmt's -- item ::= elmt + -- one or more elmt's -- item ::= elmt ? -- matches elmt or nothing -- elmt ::= nchr -- matches given character -- elmt ::= [nchr nchr ...] -- matches any character listed -- elmt ::= [^ nchr nchr ...] -- matches any character not listed -- elmt ::= [char - char] -- matches chars in given range -- elmt ::= . -- matches any single character -- elmt ::= ( regexp ) -- parens used for grouping -- char ::= any character, including special characters -- nchr ::= any character except \()[].*+?^ or \char to match char -- ... is used to indication repetition (one or more terms) -- See also regexp(1) man page on Unix systems for further details -- A second kind of regular expressions is provided. This one is more -- like the wildcard patterns used in file names by the Unix shell (or -- DOS prompt) command lines. The grammar is the following: -- regexp ::= term -- term ::= elmt -- term ::= seq -- term ::= {seq, seq, ...} -- alternation (matches any of seq) -- seq ::= elmt elmt ... -- concatenation (sequence of elmts) -- elmt ::= * -- any string of 0 or more characters -- elmt ::= ? -- matches any character -- elmt ::= char -- elmt ::= [^ char char ...] -- matches any character not listed -- elmt ::= [char char ...] -- matches any character listed -- elmt ::= [char - char] -- matches any character in given range -- \char is also supported by this grammar. -- Important note : This package was mainly intended to match regular -- expressions against file names. The whole string has to match the -- regular expression. If only a substring matches, then the function -- Match will return False. type Regexp is private; -- Private type used to represent a regular expression Error_In_Regexp : exception; -- Exception raised when an error is found in the regular expression function Compile (Pattern : String; Glob : Boolean := False; Case_Sensitive : Boolean := True) return Regexp; -- Compiles a regular expression S. If the syntax of the given -- expression is invalid (does not match above grammar), Error_In_Regexp -- is raised. If Glob is True, the pattern is considered as a 'globbing -- pattern', that is a pattern as given by the second grammar above. -- As a special case, if Pattern is the empty string it will always -- match. function Match (S : String; R : Regexp) return Boolean; -- True if S matches R, otherwise False. Raises Constraint_Error if -- R is an uninitialized regular expression value. private type Regexp_Value; type Regexp_Access is access Regexp_Value; type Regexp is new Ada.Finalization.Controlled with record R : Regexp_Access := null; end record; pragma Finalize_Storage_Only (Regexp); procedure Finalize (R : in out Regexp); -- Free the memory occupied by R procedure Adjust (R : in out Regexp); -- Called after an assignment (do a copy of the Regexp_Access.all) end System.Regexp;
reznikmm/matreshka
Ada
5,131
ads
------------------------------------------------------------------------------ -- -- -- Matreshka Project -- -- -- -- Ada Modeling Framework -- -- -- -- Runtime Library Component -- -- -- ------------------------------------------------------------------------------ -- -- -- Copyright © 2011-2012, Vadim Godunko <[email protected]> -- -- All rights reserved. -- -- -- -- Redistribution and use in source and binary forms, with or without -- -- modification, are permitted provided that the following conditions -- -- are met: -- -- -- -- * Redistributions of source code must retain the above copyright -- -- notice, this list of conditions and the following disclaimer. -- -- -- -- * Redistributions in binary form must reproduce the above copyright -- -- notice, this list of conditions and the following disclaimer in the -- -- documentation and/or other materials provided with the distribution. -- -- -- -- * Neither the name of the Vadim Godunko, IE nor the names of its -- -- contributors may be used to endorse or promote products derived from -- -- this software without specific prior written permission. -- -- -- -- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -- -- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -- -- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -- -- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -- -- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -- -- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED -- -- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -- -- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -- -- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -- -- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -- -- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- -- -- ------------------------------------------------------------------------------ -- $Revision$ $Date$ ------------------------------------------------------------------------------ -- This file is generated, don't edit it. ------------------------------------------------------------------------------ -- An interval defines the range between two value specifications. ------------------------------------------------------------------------------ with AMF.UML.Value_Specifications; package AMF.UML.Intervals is pragma Preelaborate; type UML_Interval is limited interface and AMF.UML.Value_Specifications.UML_Value_Specification; type UML_Interval_Access is access all UML_Interval'Class; for UML_Interval_Access'Storage_Size use 0; not overriding function Get_Max (Self : not null access constant UML_Interval) return AMF.UML.Value_Specifications.UML_Value_Specification_Access is abstract; -- Getter of Interval::max. -- -- Refers to the ValueSpecification denoting the maximum value of the -- range. not overriding procedure Set_Max (Self : not null access UML_Interval; To : AMF.UML.Value_Specifications.UML_Value_Specification_Access) is abstract; -- Setter of Interval::max. -- -- Refers to the ValueSpecification denoting the maximum value of the -- range. not overriding function Get_Min (Self : not null access constant UML_Interval) return AMF.UML.Value_Specifications.UML_Value_Specification_Access is abstract; -- Getter of Interval::min. -- -- Refers to the ValueSpecification denoting the minimum value of the -- range. not overriding procedure Set_Min (Self : not null access UML_Interval; To : AMF.UML.Value_Specifications.UML_Value_Specification_Access) is abstract; -- Setter of Interval::min. -- -- Refers to the ValueSpecification denoting the minimum value of the -- range. end AMF.UML.Intervals;
tum-ei-rcs/StratoX
Ada
3,291
ads
------------------------------------------------------------------------------ -- -- -- Copyright (C) 2015-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 STMicroelectronics nor the names of its -- -- contributors may be used to endorse or promote products derived -- -- from this software without specific prior written permission. -- -- -- -- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -- -- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -- -- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -- -- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -- -- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -- -- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -- -- LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -- -- DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -- -- THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -- -- (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -- -- OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- -- -- ------------------------------------------------------------------------------ with HAL.Touch_Panel; with HAL.Framebuffer; private with STMPE811; private with STM32.Device; private with STM32.I2C; package Touch_Panel_STMPE811 is type Touch_Panel is limited new HAL.Touch_Panel.Touch_Panel_Device with private; function Initialize (This : in out Touch_Panel; Orientation : HAL.Framebuffer.Display_Orientation := HAL.Framebuffer.Default) return Boolean; procedure Initialize (This : in out Touch_Panel; Orientation : HAL.Framebuffer.Display_Orientation := HAL.Framebuffer.Default); procedure Set_Orientation (This : in out Touch_Panel; Orientation : HAL.Framebuffer.Display_Orientation); private TP_I2C : STM32.I2C.I2C_Port renames STM32.Device.I2C_3; type Touch_Panel is limited new STMPE811.STMPE811_Device (Port => TP_I2C'Access, I2C_Addr => 16#82#) with null record; end Touch_Panel_STMPE811;
reznikmm/matreshka
Ada
8,730
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$ ------------------------------------------------------------------------------ -- This file is generated, don't edit it. ------------------------------------------------------------------------------ -- A namespace is an element in a model that contains a set of named elements -- that can be identified by name. ------------------------------------------------------------------------------ limited with AMF.CMOF.Constraints.Collections; limited with AMF.CMOF.Element_Imports.Collections; with AMF.CMOF.Named_Elements; limited with AMF.CMOF.Named_Elements.Collections; limited with AMF.CMOF.Package_Imports.Collections; limited with AMF.CMOF.Packageable_Elements.Collections; with AMF.String_Collections; package AMF.CMOF.Namespaces is pragma Preelaborate; type CMOF_Namespace is limited interface and AMF.CMOF.Named_Elements.CMOF_Named_Element; type CMOF_Namespace_Access is access all CMOF_Namespace'Class; for CMOF_Namespace_Access'Storage_Size use 0; not overriding function Get_Imported_Member (Self : not null access constant CMOF_Namespace) return AMF.CMOF.Packageable_Elements.Collections.Set_Of_CMOF_Packageable_Element is abstract; -- Getter of Namespace::importedMember. -- -- References the PackageableElements that are members of this Namespace -- as a result of either PackageImports or ElementImports. not overriding function Get_Element_Import (Self : not null access constant CMOF_Namespace) return AMF.CMOF.Element_Imports.Collections.Set_Of_CMOF_Element_Import is abstract; -- Getter of Namespace::elementImport. -- -- References the ElementImports owned by the Namespace. not overriding function Get_Package_Import (Self : not null access constant CMOF_Namespace) return AMF.CMOF.Package_Imports.Collections.Set_Of_CMOF_Package_Import is abstract; -- Getter of Namespace::packageImport. -- -- References the PackageImports owned by the Namespace. not overriding function Get_Owned_Member (Self : not null access constant CMOF_Namespace) return AMF.CMOF.Named_Elements.Collections.Set_Of_CMOF_Named_Element is abstract; -- Getter of Namespace::ownedMember. -- -- A collection of NamedElements owned by the Namespace. not overriding function Get_Member (Self : not null access constant CMOF_Namespace) return AMF.CMOF.Named_Elements.Collections.Set_Of_CMOF_Named_Element is abstract; -- Getter of Namespace::member. -- -- A collection of NamedElements identifiable within the Namespace, either -- by being owned or by being introduced by importing or inheritance. not overriding function Get_Owned_Rule (Self : not null access constant CMOF_Namespace) return AMF.CMOF.Constraints.Collections.Set_Of_CMOF_Constraint is abstract; -- Getter of Namespace::ownedRule. -- not overriding function Imported_Member (Self : not null access constant CMOF_Namespace) return AMF.CMOF.Packageable_Elements.Collections.Set_Of_CMOF_Packageable_Element is abstract; -- Operation Namespace::importedMember. -- -- The importedMember property is derived from the ElementImports and the -- PackageImports. References the PackageableElements that are members of -- this Namespace as a result of either PackageImports or ElementImports. not overriding function Get_Names_Of_Member (Self : not null access constant CMOF_Namespace; Element : AMF.CMOF.Named_Elements.CMOF_Named_Element_Access) return AMF.String_Collections.Set_Of_String is abstract; -- Operation Namespace::getNamesOfMember. -- -- The query getNamesOfMember() takes importing into account. It gives -- back the set of names that an element would have in an importing -- namespace, either because it is owned, or if not owned then imported -- individually, or if not individually then from a package. not overriding function Import_Members (Self : not null access constant CMOF_Namespace; Imps : AMF.CMOF.Packageable_Elements.Collections.Set_Of_CMOF_Packageable_Element) return AMF.CMOF.Packageable_Elements.Collections.Set_Of_CMOF_Packageable_Element is abstract; -- Operation Namespace::importMembers. -- -- The query importMembers() defines which of a set of PackageableElements -- are actually imported into the namespace. This excludes hidden ones, -- i.e., those which have names that conflict with names of owned members, -- and also excludes elements which would have the same name when imported. not overriding function Exclude_Collisions (Self : not null access constant CMOF_Namespace; Imps : AMF.CMOF.Packageable_Elements.Collections.Set_Of_CMOF_Packageable_Element) return AMF.CMOF.Packageable_Elements.Collections.Set_Of_CMOF_Packageable_Element is abstract; -- Operation Namespace::excludeCollisions. -- -- The query excludeCollisions() excludes from a set of -- PackageableElements any that would not be distinguishable from each -- other in this namespace. not overriding function Members_Are_Distinguishable (Self : not null access constant CMOF_Namespace) return Boolean is abstract; -- Operation Namespace::membersAreDistinguishable. -- -- The Boolean query membersAreDistinguishable() determines whether all of -- the namespace's members are distinguishable within it. end AMF.CMOF.Namespaces;
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.Office_Dde_Application_Attributes is pragma Preelaborate; type ODF_Office_Dde_Application_Attribute is limited interface and XML.DOM.Attributes.DOM_Attribute; type ODF_Office_Dde_Application_Attribute_Access is access all ODF_Office_Dde_Application_Attribute'Class with Storage_Size => 0; end ODF.DOM.Office_Dde_Application_Attributes;
reznikmm/matreshka
Ada
24,105
adb
------------------------------------------------------------------------------ -- -- -- Matreshka Project -- -- -- -- Localization, Internationalization, Globalization for Ada -- -- -- -- Tools 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$ ------------------------------------------------------------------------------ -- This program generates timezone information from TZDATA. ------------------------------------------------------------------------------ with Ada.Characters.Wide_Wide_Latin_1; with Ada.Containers.Vectors; with Ada.Strings.Wide_Wide_Fixed; with Ada.Unchecked_Deallocation; with Ada.Wide_Wide_Text_IO; with League.Application; with League.Strings; with Matreshka.Internals.Calendars.Gregorian; with Matreshka.Internals.Calendars.Times; procedure Gen_TZ is use Matreshka.Internals.Calendars; use Matreshka.Internals.Calendars.Gregorian; use Matreshka.Internals.Calendars.Times; type Time_Kinds is (Wall, Standard, UTC); type Day_Kinds is (Number, Last_Sunday, Last_Saturday); type TZ_Zone_Record is record GMT_Offset : Relative_Time; Rules : League.Strings.Universal_String; Year : Year_Number; Month : Month_Number := 1; Day_Kind : Day_Kinds := Number; Day : Day_Number := 1; Hour : Hour_Number := 0; Minute : Minute_Number := 0; Second : Second_Number := 0; Time_Kind : Time_Kinds := Wall; end record; type Time_Zone_Access is access all Internal_Time_Zone; package TZ_Zone_Vectors is new Ada.Containers.Vectors (Positive, TZ_Zone_Record); type TZ_Zone_Info is record Name : League.Strings.Universal_String; Records : TZ_Zone_Vectors.Vector; end record; X_Open_Epoch : constant := 2_299_161; Ticks_In_Day : constant := 24 * 60 * 60 * 10_000_000; Ticks_In_Hour : constant := 60 * 60 * 10_000_000; Ticks_In_Minute : constant := 60 * 10_000_000; Ticks_In_Second : constant := 10_000_000; procedure Load_TZ_File (File_Name : League.Strings.Universal_String); function To_Absolute_Time (Year : Year_Number; Month : Month_Number; Day : Day_Number; Hour : Hour_Number; Minute : Minute_Number; Second : Second_Number) return Absolute_Time; function To_Relative_Time (Hour : Hour_Number; Minute : Minute_Number; Second : Second_Number) return Relative_Time; function Image (Item : Absolute_Time) return Wide_Wide_String; function Image (Item : Relative_Time) return Wide_Wide_String; TZ : TZ_Zone_Info; procedure Prepend (Item : in out Time_Zone_Access; Value : Zone_Record); ----------- -- Image -- ----------- function Image (Item : Absolute_Time) return Wide_Wide_String is Digit : constant array (Absolute_Time range 0 .. 9) of Wide_Wide_Character := "0123456789"; Image : Wide_Wide_String := "000_000_000_000_0000000"; First : Natural := Image'Last + 1; Aux : Absolute_Time := Item; begin while Aux /= 0 loop First := First - 1; if Image (First) = '_' then First := First - 1; end if; Image (First) := Digit (Aux mod 10); Aux := Aux / 10; end loop; return Image; end Image; ----------- -- Image -- ----------- function Image (Item : Relative_Time) return Wide_Wide_String is Digit : constant array (Relative_Time range 0 .. 9) of Wide_Wide_Character := "0123456789"; Image : Wide_Wide_String := "000_000_000_000_0000000"; First : Natural := Image'Last + 1; Aux : Relative_Time := Item; begin while Aux /= 0 loop First := First - 1; if Image (First) = '_' then First := First - 1; end if; Image (First) := Digit (Aux mod 10); Aux := Aux / 10; end loop; return Image; end Image; ------------------ -- Load_TZ_File -- ------------------ procedure Load_TZ_File (File_Name : League.Strings.Universal_String) is File : Ada.Wide_Wide_Text_IO.File_Type; Buffer : Wide_Wide_String (1 .. 1024); First : Positive; Last : Natural; Field_First : Positive; Field_Last : Natural; procedure Parse_Field; -- Parses field. Sets Field_First and Field_Last to the first and last -- characters of the field, excluding heading and traling spaces. Update -- First to track current position. procedure Parse_GMTOFF (Value : out Relative_Time); -- Parses GMTOFF field of Zone record. procedure Parse_Month (Value : out Month_Number); -- Parses month name. procedure Parse_Time (Hour : out Hour_Number; Minute : out Minute_Number; Second : out Second_Number; Kind : out Time_Kinds); -- Parses time component with modifiers ('s'). procedure Parse_Zone_Common (Value : in out TZ_Zone_Record); -- Parses common fields of Zone record. ----------------- -- Parse_Field -- ----------------- procedure Parse_Field is begin -- Skip leading whitespaces. for J in First .. Last loop First := J; exit when Buffer (J) /= ' ' and Buffer (J) /= Ada.Characters.Wide_Wide_Latin_1.HT; end loop; Field_First := First; if Buffer (Field_First) = '"' then -- Use of quatation mark is not supported. raise Program_Error; end if; for J in First .. Last loop if Buffer (J) = ' ' or Buffer (J) = Ada.Characters.Wide_Wide_Latin_1.HT then Field_Last := J - 1; First := J + 1; exit; elsif J = Last then Field_Last := Last; First := Last + 1; end if; end loop; Ada.Wide_Wide_Text_IO.Put_Line (''' & Buffer (Field_First .. Field_Last) & '''); end Parse_Field; ------------------ -- Parse_GMTOFF -- ------------------ procedure Parse_GMTOFF (Value : out Relative_Time) is Hour : Hour_Number := 0; Minute : Minute_Number := 0; Second : Second_Number := 0; First : Positive := Field_First; Last : Natural := Field_Last; Minus : Boolean := False; begin -- Look for minus sign. if Buffer (First) = '-' then Minus := True; First := First + 1; end if; -- Lookup for hour separator. for J in First .. Field_Last loop if Buffer (J) = ':' then Last := J - 1; exit; end if; end loop; if First <= Last then Hour := Hour_Number'Wide_Wide_Value (Buffer (First .. Last)); First := Last + 2; Last := Field_Last; end if; -- Lookup for minute separator. for J in First .. Field_Last loop if Buffer (J) = ':' then Last := J - 1; exit; end if; end loop; if First <= Last then Minute := Minute_Number'Wide_Wide_Value (Buffer (First .. Last)); First := Last + 2; Last := Field_Last; end if; -- Process second if any. if First <= Last then Second := Second_Number'Wide_Wide_Value (Buffer (First .. Last)); end if; Value := To_Relative_Time (Hour, Minute, Second); if Minus then Value := -Value; end if; end Parse_GMTOFF; ----------------- -- Parse_Month -- ----------------- procedure Parse_Month (Value : out Month_Number) is Image : constant Wide_Wide_String := Buffer (Field_First .. Field_Last); begin if Image = "Jan" then Value := 1; elsif Image = "Feb" then Value := 2; elsif Image = "Mar" then Value := 3; elsif Image = "Apr" then Value := 4; elsif Image = "May" then Value := 5; elsif Image = "Jun" then Value := 6; elsif Image = "Jul" then Value := 7; elsif Image = "Aug" then Value := 8; elsif Image = "Sep" then Value := 9; elsif Image = "Oct" then Value := 10; elsif Image = "Nov" then Value := 11; elsif Image = "Dec" then Value := 12; else raise Constraint_Error; end if; end Parse_Month; ---------------- -- Parse_Time -- ---------------- procedure Parse_Time (Hour : out Hour_Number; Minute : out Minute_Number; Second : out Second_Number; Kind : out Time_Kinds) is First : Positive := Field_First; Last : Natural := Field_Last; begin -- Set default values. Hour := 0; Minute := 0; Second := 0; Kind := Wall; -- Lookup for hour separator. for J in First .. Last loop if Buffer (J) not in '0' .. '9' then Last := J - 1; exit; end if; end loop; if First <= Last then Hour := Hour_Number'Wide_Wide_Value (Buffer (First .. Last)); if Last = Field_Last then First := Field_Last + 1; elsif Buffer (Last + 1) = ':' then First := Last + 2; else First := Last + 1; end if; end if; -- Lookup for minute separator. Last := Field_Last; for J in First .. Field_Last loop if Buffer (J) not in '0' .. '9' then Last := J - 1; exit; end if; end loop; if First <= Last then Minute := Minute_Number'Wide_Wide_Value (Buffer (First .. Last)); if Last = Field_Last then First := Field_Last + 1; elsif Buffer (Last + 1) = ':' then First := Last + 2; else First := Last + 1; end if; end if; -- Lookup for second separator. Last := Field_Last; for J in First .. Field_Last loop if Buffer (J) not in '0' .. '9' then Last := J - 1; exit; end if; end loop; if First <= Last then Second := Second_Number'Wide_Wide_Value (Buffer (First .. Last)); if Last = Field_Last then First := Field_Last + 1; elsif Buffer (Last + 1) = ':' then First := Last + 2; else First := Last + 1; end if; end if; Last := Field_Last; -- Parse modifier if any. if First <= Last then if Buffer (First .. Last) = "s" then Kind := Standard; elsif Buffer (First .. Last) = "u" then Kind := UTC; else raise Constraint_Error; end if; end if; end Parse_Time; ------------------------ -- Parse_Zone_Commmon -- ------------------------ procedure Parse_Zone_Common (Value : in out TZ_Zone_Record) is begin -- Parse GMTOFF field. Parse_Field; Parse_GMTOFF (Value.GMT_Offset); -- Process RULES field. Parse_Field; if Buffer (Field_First .. Field_Last) /= "-" then Value.Rules := League.Strings.To_Universal_String (Buffer (Field_First .. Field_Last)); end if; -- Skip FORMAT field. Parse_Field; -- Process components of [UNTIL] field. -- Year component. Parse_Field; if Field_First <= Field_Last then Value.Year := Year_Number'Wide_Wide_Value (Buffer (Field_First .. Field_Last)); else Ada.Wide_Wide_Text_IO.Put_Line (">>> END OF TIME <<<"); Value.Year := Year_Number'Last; end if; -- Month component. Parse_Field; if Field_First <= Field_Last then Parse_Month (Value.Month); end if; -- Day component. Parse_Field; if Field_First <= Field_Last then -- Special values. if Buffer (Field_First .. Field_Last) = "lastSun" then Value.Day_Kind := Last_Sunday; elsif Buffer (Field_First .. Field_Last) = "lastSat" then Value.Day_Kind := Last_Saturday; -- Simple numeric value. else Value.Day := Day_Number'Wide_Wide_Value (Buffer (Field_First .. Field_Last)); end if; end if; -- Time component. Parse_Field; if Field_First <= Field_Last then Parse_Time (Value.Hour, Value.Minute, Value.Second, Value.Time_Kind); end if; end Parse_Zone_Common; begin Ada.Wide_Wide_Text_IO.Open (File, Ada.Wide_Wide_Text_IO.In_File, File_Name.To_UTF_8_String, "wcem=8"); while not Ada.Wide_Wide_Text_IO.End_Of_File (File) loop Ada.Wide_Wide_Text_IO.Get_Line (File, Buffer, Last); -- Remove comments for J in Buffer'First .. Last loop if Buffer (J) = '#' then Last := J - 1; -- Remove trailing spaces and horizontal tabulations. for J in reverse Buffer'First .. Last loop exit when Buffer (J) /= ' ' and Buffer (J) /= Ada.Characters.Wide_Wide_Latin_1.HT; Last := J - 1; end loop; exit; end if; end loop; -- Process non-empty line. if Last >= Buffer'First then First := Buffer'First; if Buffer (1 .. 4) = "Rule" then -- Rule line. null; elsif Buffer (1 .. 4) = "Link" then Ada.Wide_Wide_Text_IO.Put_Line (Buffer (First .. Last)); elsif Buffer (1 .. 4) = "Zone" then Ada.Wide_Wide_Text_IO.Put_Line (Buffer (First .. Last)); -- Zone primary line. declare D : TZ_Zone_Record; begin -- Skip record kind. Parse_Field; -- Parse name of timezone. Parse_Field; TZ.Name := League.Strings.To_Universal_String (Buffer (Field_First .. Field_Last)); -- Parse common fields. Parse_Zone_Common (D); TZ.Records.Append (D); end; else Ada.Wide_Wide_Text_IO.Put_Line (Buffer (First .. Last)); -- Zone continuation line. declare D : TZ_Zone_Record; begin -- Parse common fields. Parse_Zone_Common (D); TZ.Records.Append (D); end; end if; end if; end loop; Ada.Wide_Wide_Text_IO.Close (File); end Load_TZ_File; ------------- -- Prepend -- ------------- procedure Prepend (Item : in out Time_Zone_Access; Value : Zone_Record) is procedure Free is new Ada.Unchecked_Deallocation (Internal_Time_Zone, Time_Zone_Access); Aux : Time_Zone_Access := Item; begin if Aux = null then Item := new Internal_Time_Zone (1); else Item := new Internal_Time_Zone (Aux.Length + 1); Item.Data (Aux.Data'First + 1 .. Aux.Data'Last + 1) := Aux.Data; end if; Item.Data (Item.Data'First) := Value; Free (Aux); end Prepend; ---------------------- -- To_Absolute_Time -- ---------------------- function To_Absolute_Time (Year : Year_Number; Month : Month_Number; Day : Day_Number; Hour : Hour_Number; Minute : Minute_Number; Second : Second_Number) return Absolute_Time is begin return Absolute_Time (Julian_Day (Year, Month, Day) - X_Open_Epoch) * Ticks_In_Day + Absolute_Time (Hour) * Ticks_In_Hour + Absolute_Time (Minute) * Ticks_In_Minute + Absolute_Time (Second) * Ticks_In_Second; end To_Absolute_Time; ---------------------- -- To_Relative_Time -- ---------------------- function To_Relative_Time (Hour : Hour_Number; Minute : Minute_Number; Second : Second_Number) return Relative_Time is begin return Relative_Time (Hour) * Ticks_In_Hour + Relative_Time (Minute) * Ticks_In_Minute + Relative_Time (Second) * Ticks_In_Second; end To_Relative_Time; procedure Test (Z : not null Time_Zone_Access; Y : Year_Number; M : Month_Number; D : Day_Number; H : Hour_Number; N : Minute_Number; S : Second_Number) is Year : Year_Number; Month : Month_Number; Day : Day_Number; Hour : Hour_Number; Minute : Minute_Number; Second : Second_Number; Fraction : Nano_Second_100_Number; JDay : Julian_Day_Number; Stamp : Absolute_Time; begin Stamp := Create (UTC_Time_Zone'Access, Julian_Day (Y, M, D), H, N, S, 0); Split (UTC_Time_Zone'Access, Stamp, JDay, Hour, Minute, Second, Fraction); Split (JDay, Year, Month, Day); Ada.Wide_Wide_Text_IO.Put (Ada.Strings.Wide_Wide_Fixed.Trim (Year_Number'Wide_Wide_Image (Year), Ada.Strings.Both) & "-" & Ada.Strings.Wide_Wide_Fixed.Trim (Month_Number'Wide_Wide_Image (Month), Ada.Strings.Both) & "-" & Ada.Strings.Wide_Wide_Fixed.Trim (Day_Number'Wide_Wide_Image (Day), Ada.Strings.Both) & " " & Ada.Strings.Wide_Wide_Fixed.Trim (Hour_Number'Wide_Wide_Image (Hour), Ada.Strings.Both) & ":" & Ada.Strings.Wide_Wide_Fixed.Trim (Minute_Number'Wide_Wide_Image (Minute), Ada.Strings.Both) & ":" & Ada.Strings.Wide_Wide_Fixed.Trim (Second_Number'Wide_Wide_Image (Second), Ada.Strings.Both) & " => "); Split (Z.all'Unchecked_Access, Stamp, JDay, Hour, Minute, Second, Fraction); Split (JDay, Year, Month, Day); Ada.Wide_Wide_Text_IO.Put_Line (Ada.Strings.Wide_Wide_Fixed.Trim (Year_Number'Wide_Wide_Image (Year), Ada.Strings.Both) & "-" & Ada.Strings.Wide_Wide_Fixed.Trim (Month_Number'Wide_Wide_Image (Month), Ada.Strings.Both) & "-" & Ada.Strings.Wide_Wide_Fixed.Trim (Day_Number'Wide_Wide_Image (Day), Ada.Strings.Both) & " " & Ada.Strings.Wide_Wide_Fixed.Trim (Hour_Number'Wide_Wide_Image (Hour), Ada.Strings.Both) & ":" & Ada.Strings.Wide_Wide_Fixed.Trim (Minute_Number'Wide_Wide_Image (Minute), Ada.Strings.Both) & ":" & Ada.Strings.Wide_Wide_Fixed.Trim (Second_Number'Wide_Wide_Image (Second), Ada.Strings.Both)); end Test; From : Absolute_Time := 0; Z : Time_Zone_Access; begin Load_TZ_File (League.Application.Arguments.Element (1)); -- Generate zone information. for R of TZ.Records loop Prepend (Z, (From, R.GMT_Offset)); Ada.Wide_Wide_Text_IO.Put_Line (Image (From) & ", " & Image (R.GMT_Offset)); if R.Year /= Year_Number'Last then From := To_Absolute_Time (R.Year, R.Month, R.Day, R.Hour, R.Minute, R.Second); case R.Time_Kind is when Wall => From := From - Absolute_Time (R.GMT_Offset); -- XXX Note: this time must be corrected according to modifier. when Standard => From := From - Absolute_Time (R.GMT_Offset); when UTC => null; end case; else From := Absolute_Time'Last; end if; end loop; -- Some tests. Test (Z, 1879, 12, 31, 21, 29, 39); Test (Z, 1879, 12, 31, 21, 29, 40); Test (Z, 1916, 7, 2, 21, 29, 59); Test (Z, 1916, 7, 2, 21, 30, 00); Test (Z, 1917, 7, 1, 20, 29, 11); Test (Z, 1917, 7, 1, 20, 29, 12); Test (Z, 2011, 3, 26, 22, 59, 59); Test (Z, 2011, 3, 26, 23, 0, 0); end Gen_TZ;
reznikmm/matreshka
Ada
3,744
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_Master_Page_Name_Attributes is pragma Preelaborate; type ODF_Draw_Master_Page_Name_Attribute is limited interface and XML.DOM.Attributes.DOM_Attribute; type ODF_Draw_Master_Page_Name_Attribute_Access is access all ODF_Draw_Master_Page_Name_Attribute'Class with Storage_Size => 0; end ODF.DOM.Draw_Master_Page_Name_Attributes;
eqcola/ada-ado
Ada
2,541
adb
----------------------------------------------------------------------- -- ADO Databases -- Database Connections -- Copyright (C) 2010, 2011, 2012, 2013, 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. ----------------------------------------------------------------------- package body ADO.Sessions.Sources is use ADO.Drivers; use type ADO.Drivers.Connections.Database_Connection_Access; -- ------------------------------ -- Set the master data source -- ------------------------------ procedure Set_Master (Controller : in out Replicated_DataSource; Master : in Data_Source_Access) is begin Controller.Master := Master; end Set_Master; -- ------------------------------ -- Get the master data source -- ------------------------------ function Get_Master (Controller : in Replicated_DataSource) return Data_Source_Access is begin return Controller.Master; end Get_Master; -- ------------------------------ -- Set the slave data source -- ------------------------------ procedure Set_Slave (Controller : in out Replicated_DataSource; Slave : in Data_Source_Access) is begin Controller.Slave := Slave; end Set_Slave; -- ------------------------------ -- Get the slave data source -- ------------------------------ function Get_Slave (Controller : in Replicated_DataSource) return Data_Source_Access is begin return Controller.Slave; end Get_Slave; -- ------------------------------ -- Get a slave database connection -- ------------------------------ -- function Get_Slave_Connection (Controller : in Replicated_DataSource) -- return Connection'Class is -- begin -- return Controller.Slave.Get_Connection; -- end Get_Slave_Connection; end ADO.Sessions.Sources;
onox/orka
Ada
868
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.AVX.Integers is pragma Pure; type m256i is array (Index_8D) of Integer_32 with Alignment => 32; pragma Machine_Attribute (m256i, "vector_type"); end Orka.SIMD.AVX.Integers;
charlie5/aIDE
Ada
1,131
ads
with AdaM.Declaration.of_object, gtk.Widget; private with gtk.gEntry, gtk.Box, gtk.Label, gtk.Button; package aIDE.Editor.of_object is type Item is new Editor.item with private; type View is access all Item'Class; package Forge is function new_Editor (the_Target : in AdaM.Declaration.of_object.view) return View; end Forge; overriding function top_Widget (Self : in Item) return gtk.Widget.Gtk_Widget; private use gtk.Button, gtk.gEntry, gtk.Label, gtk.Box; type Item is new Editor.item with record Target : AdaM.Declaration.of_object.view; top_Box : gtk_Box; name_Entry : Gtk_Entry; type_Button : gtk_Button; colon_Label : gtk_Label; aliased_Label : gtk_Label; constant_Label : gtk_Label; initializer_Label : gtk_Label; initializer_Entry : Gtk_Entry; rid_Button : gtk_Button; end record; overriding procedure freshen (Self : in out Item); end aIDE.Editor.of_object;
AdaCore/libadalang
Ada
58
ads
package P1 is type Record_Type is null record; end P1;
burratoo/Acton
Ada
27,610
ads
------------------------------------------------------------------------------ -- -- -- GNAT RUN-TIME COMPONENTS -- -- -- -- A D A . T A G S -- -- -- -- S p e c -- -- -- -- Copyright (C) 1992-2014, 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. -- -- -- ------------------------------------------------------------------------------ -- The operations in this package provide the guarantee that all dispatching -- calls on primitive operations of tagged types and interfaces take constant -- time (in terms of source lines executed), that is to say, the cost of these -- calls is independent of the number of primitives of the type or interface, -- and independent of the number of ancestors or interface progenitors that a -- tagged type may have. -- The following subprograms of the public part of this package take constant -- time (in terms of source lines executed): -- Expanded_Name, Wide_Expanded_Name, Wide_Wide_Expanded_Name, External_Tag, -- Is_Descendant_At_Same_Level, Parent_Tag -- Descendant_Tag (when used with a library-level tagged type), -- Internal_Tag (when used with a library-level tagged type). -- The following subprograms of the public part of this package take non -- constant time (in terms of sources line executed): -- Descendant_Tag (when used with a locally defined tagged type) -- Internal_Tag (when used with a locally defined tagged type) -- Interface_Ancestor_Tagswith System with System.Storage_Elements; package Ada.Tags is pragma Preelaborate; -- In accordance with Ada 2005 AI-362 type Tag is private; pragma Preelaborable_Initialization (Tag); No_Tag : constant Tag; -- function Expanded_Name (T : Tag) return String; -- -- function Wide_Expanded_Name (T : Tag) return Wide_String; -- pragma Ada_05 (Wide_Expanded_Name); -- -- function Wide_Wide_Expanded_Name (T : Tag) return Wide_Wide_String; -- pragma Ada_05 (Wide_Wide_Expanded_Name); -- -- function External_Tag (T : Tag) return String; function Internal_Tag (External : String) return Tag; function Descendant_Tag (External : String; Ancestor : Tag) return Tag; pragma Ada_05 (Descendant_Tag); function Is_Descendant_At_Same_Level (Descendant : Tag; Ancestor : Tag) return Boolean; pragma Ada_05 (Is_Descendant_At_Same_Level); function Parent_Tag (T : Tag) return Tag; pragma Ada_05 (Parent_Tag); type Tag_Array is array (Positive range <>) of Tag; -- function Interface_Ancestor_Tags (T : Tag) return Tag_Array; -- pragma Ada_05 (Interface_Ancestor_Tags); function Type_Is_Abstract (T : Tag) return Boolean; pragma Ada_2012 (Type_Is_Abstract); Tag_Error : exception; private -- Structure of the GNAT Primary Dispatch Table -- +--------------------+ -- | Signature | -- +--------------------+ -- | Tagged_Kind | -- +--------------------+ Predef Prims -- | Predef_Prims -----------------------------> +------------+ -- +--------------------+ | table of | -- | Offset_To_Top | | predefined | -- +--------------------+ | primitives | -- |Typeinfo_Ptr/TSD_Ptr---> Type Specific Data +------------+ -- Tag ---> +--------------------+ +-------------------+ -- | table of | | inheritance depth | -- : primitive ops : +-------------------+ -- | pointers | | access level | -- +--------------------+ +-------------------+ -- | alignment | -- +-------------------+ -- | expanded name | -- +-------------------+ -- | external tag | -- +-------------------+ -- | hash table link | -- +-------------------+ -- | transportable | -- +-------------------+ -- | type_is_abstract | -- +-------------------+ -- | needs finalization| -- +-------------------+ -- | Ifaces_Table ---> Interface Data -- +-------------------+ +------------+ -- Select Specific Data <---- SSD | | Nb_Ifaces | -- +------------------+ +-------------------+ +------------+ -- |table of primitive| | table of | | table | -- : operation : : ancestor : : of : -- | kinds | | tags | | interfaces | -- +------------------+ +-------------------+ +------------+ -- |table of | -- : entry : -- | indexes | -- +------------------+ -- Structure of the GNAT Secondary Dispatch Table -- +--------------------+ -- | Signature | -- +--------------------+ -- | Tagged_Kind | -- +--------------------+ Predef Prims -- | Predef_Prims -----------------------------> +------------+ -- +--------------------+ | table of | -- | Offset_To_Top | | predefined | -- +--------------------+ | primitives | -- | OSD_Ptr |---> Object Specific Data | thunks | -- Tag ---> +--------------------+ +---------------+ +------------+ -- | table of | | num prim ops | -- : primitive op : +---------------+ -- | thunk pointers | | table of | -- +--------------------+ + primitive | -- | op offsets | -- +---------------+ -- The runtime information kept for each tagged type is separated into two -- objects: the Dispatch Table and the Type Specific Data record. package SSE renames System.Storage_Elements; subtype Cstring is String (Positive); type Cstring_Ptr is access all Cstring; pragma No_Strict_Aliasing (Cstring_Ptr); -- Declarations for the table of interfaces type Offset_To_Top_Function_Ptr is access function (This : System.Address) return SSE.Storage_Offset; -- Type definition used to call the function that is generated by the -- expander in case of tagged types with discriminants that have secondary -- dispatch tables. This function provides the Offset_To_Top value in this -- specific case. type Interface_Data_Element is record Iface_Tag : Tag; Static_Offset_To_Top : Boolean; Offset_To_Top_Value : SSE.Storage_Offset; Offset_To_Top_Func : Offset_To_Top_Function_Ptr; Secondary_DT : Tag; end record; -- If some ancestor of the tagged type has discriminants the field -- Static_Offset_To_Top is False and the field Offset_To_Top_Func -- is used to store the access to the function generated by the -- expander which provides this value; otherwise Static_Offset_To_Top -- is True and such value is stored in the Offset_To_Top_Value field. -- Secondary_DT references a secondary dispatch table whose contents -- are pointers to the primitives of the tagged type that cover the -- interface primitives. Secondary_DT gives support to dispatching -- calls through interface types associated with Generic Dispatching -- Constructors. type Interfaces_Array is array (Natural range <>) of Interface_Data_Element; type Interface_Data (Nb_Ifaces : Positive) is record Ifaces_Table : Interfaces_Array (1 .. Nb_Ifaces); end record; type Interface_Data_Ptr is access all Interface_Data; -- Table of abstract interfaces used to give support to backward interface -- conversions and also to IW_Membership. -- Primitive operation kinds. These values differentiate the kinds of -- callable entities stored in the dispatch table. Certain kinds may -- not be used, but are added for completeness. type Prim_Op_Kind is (POK_Function, POK_Procedure, POK_Protected_Entry, POK_Protected_Function, POK_Protected_Procedure, POK_Task_Entry, POK_Task_Function, POK_Task_Procedure); -- Select specific data types type Select_Specific_Data_Element is record Index : Positive; Kind : Prim_Op_Kind; end record; type Select_Specific_Data_Array is array (Positive range <>) of Select_Specific_Data_Element; type Select_Specific_Data (Nb_Prim : Positive) is record SSD_Table : Select_Specific_Data_Array (1 .. Nb_Prim); -- NOTE: Nb_Prim is the number of non-predefined primitive operations end record; type Select_Specific_Data_Ptr is access all Select_Specific_Data; -- A table used to store the primitive operation kind and entry index of -- primitive subprograms of a type that implements a limited interface. -- The Select Specific Data table resides in the Type Specific Data of a -- type. This construct is used in the handling of dispatching triggers -- in select statements. type Prim_Ptr is access procedure; type Address_Array is array (Positive range <>) of Prim_Ptr; subtype Dispatch_Table is Address_Array (1 .. 1); -- Used by GDB to identify the _tags and traverse the run-time structure -- associated with tagged types. For compatibility with older versions of -- gdb, its name must not be changed. type Tag is access all Dispatch_Table; pragma No_Strict_Aliasing (Tag); type Interface_Tag is access all Dispatch_Table; No_Tag : constant Tag := null; -- The expander ensures that Tag objects reference the Prims_Ptr component -- of the wrapper. type Tag_Ptr is access all Tag; pragma No_Strict_Aliasing (Tag_Ptr); type Offset_To_Top_Ptr is access all SSE.Storage_Offset; pragma No_Strict_Aliasing (Offset_To_Top_Ptr); type Tag_Table is array (Natural range <>) of Tag; type Size_Ptr is access function (A : System.Address) return Long_Long_Integer; type Type_Specific_Data (Idepth : Natural) is record -- The discriminant Idepth is the Inheritance Depth Level: Used to -- implement the membership test associated with single inheritance of -- tagged types in constant-time. It also indicates the size of the -- Tags_Table component. Access_Level : Natural; -- Accessibility level required to give support to Ada 2005 nested type -- extensions. This feature allows safe nested type extensions by -- shifting the accessibility checks to certain operations, rather than -- being enforced at the type declaration. In particular, by performing -- run-time accessibility checks on class-wide allocators, class-wide -- function return, and class-wide stream I/O, the danger of objects -- outliving their type declaration can be eliminated (Ada 2005: AI-344) Alignment : Natural; Expanded_Name : Cstring_Ptr; External_Tag : Cstring_Ptr; HT_Link : Tag_Ptr; -- Components used to support to the Ada.Tags subprograms in RM 3.9 -- Note: Expanded_Name is referenced by GDB to determine the actual name -- of the tagged type. Its requirements are: 1) it must have this exact -- name, and 2) its contents must point to a C-style Nul terminated -- string containing its expanded name. GDB has no requirement on a -- given position inside the record. Transportable : Boolean; -- Used to check RM E.4(18), set for types that satisfy the requirements -- for being used in remote calls as actuals for classwide formals or as -- return values for classwide functions. Type_Is_Abstract : Boolean; -- True if the type is abstract (Ada 2012: AI05-0173) Needs_Finalization : Boolean; -- Used to dynamically check whether an object is controlled or not Size_Func : Size_Ptr; -- Pointer to the subprogram computing the _size of the object. Used by -- the run-time whenever a call to the 'size primitive is required. We -- cannot assume that the contents of dispatch tables are addresses -- because in some architectures the ABI allows descriptors. Interfaces_Table : Interface_Data_Ptr; -- Pointer to the table of interface tags. It is used to implement the -- membership test associated with interfaces and also for backward -- abstract interface type conversions (Ada 2005:AI-251) SSD : Select_Specific_Data_Ptr; -- Pointer to a table of records used in dispatching selects. This field -- has a meaningful value for all tagged types that implement a limited, -- protected, synchronized or task interfaces and have non-predefined -- primitive operations. Tags_Table : Tag_Table (0 .. Idepth); -- Table of ancestor tags. Its size actually depends on the inheritance -- depth level of the tagged type. end record; type Type_Specific_Data_Ptr is access all Type_Specific_Data; pragma No_Strict_Aliasing (Type_Specific_Data_Ptr); -- Declarations for the dispatch table record type Signature_Kind is (Unknown, Primary_DT, Secondary_DT); -- Tagged type kinds with respect to concurrency and limitedness type Tagged_Kind is (TK_Abstract_Limited_Tagged, TK_Abstract_Tagged, TK_Limited_Tagged, TK_Protected, TK_Tagged, TK_Task); type Dispatch_Table_Wrapper (Num_Prims : Natural) is record Signature : Signature_Kind; Tag_Kind : Tagged_Kind; Predef_Prims : System.Address; -- Pointer to the dispatch table of predefined Ada primitives -- According to the C++ ABI the components Offset_To_Top and TSD are -- stored just "before" the dispatch table, and they are referenced with -- negative offsets referring to the base of the dispatch table. The -- _Tag (or the VTable_Ptr in C++ terminology) must point to the base -- of the virtual table, just after these components, to point to the -- Prims_Ptr table. Offset_To_Top : SSE.Storage_Offset; TSD : System.Address; Prims_Ptr : aliased Address_Array (1 .. Num_Prims); -- The size of the Prims_Ptr array actually depends on the tagged type -- to which it applies. For each tagged type, the expander computes the -- actual array size, allocates the Dispatch_Table record accordingly. end record; type Dispatch_Table_Ptr is access all Dispatch_Table_Wrapper; pragma No_Strict_Aliasing (Dispatch_Table_Ptr); -- The following type declaration is used by the compiler when the program -- is compiled with restriction No_Dispatching_Calls. It is also used with -- interface types to generate the tag and run-time information associated -- with them. type No_Dispatch_Table_Wrapper is record NDT_TSD : System.Address; NDT_Prims_Ptr : Natural; end record; DT_Predef_Prims_Size : constant SSE.Storage_Count := SSE.Storage_Count (1 * (Standard'Address_Size / System.Storage_Unit)); -- Size of the Predef_Prims field of the Dispatch_Table DT_Offset_To_Top_Size : constant SSE.Storage_Count := SSE.Storage_Count (1 * (Standard'Address_Size / System.Storage_Unit)); -- Size of the Offset_To_Top field of the Dispatch Table DT_Typeinfo_Ptr_Size : constant SSE.Storage_Count := SSE.Storage_Count (1 * (Standard'Address_Size / System.Storage_Unit)); -- Size of the Typeinfo_Ptr field of the Dispatch Table use type System.Storage_Elements.Storage_Offset; DT_Offset_To_Top_Offset : constant SSE.Storage_Count := DT_Typeinfo_Ptr_Size + DT_Offset_To_Top_Size; DT_Predef_Prims_Offset : constant SSE.Storage_Count := DT_Typeinfo_Ptr_Size + DT_Offset_To_Top_Size + DT_Predef_Prims_Size; -- Offset from Prims_Ptr to Predef_Prims component -- Object Specific Data record of secondary dispatch tables type Object_Specific_Data_Array is array (Positive range <>) of Positive; type Object_Specific_Data (OSD_Num_Prims : Positive) is record OSD_Table : Object_Specific_Data_Array (1 .. OSD_Num_Prims); -- Table used in secondary DT to reference their counterpart in the -- select specific data (in the TSD of the primary DT). This construct -- is used in the handling of dispatching triggers in select statements. -- Nb_Prim is the number of non-predefined primitive operations. end record; type Object_Specific_Data_Ptr is access all Object_Specific_Data; pragma No_Strict_Aliasing (Object_Specific_Data_Ptr); -- The following subprogram specifications are placed here instead of the -- package body to see them from the frontend through rtsfind. function Base_Address (This : System.Address) return System.Address; -- Ada 2005 (AI-251): Displace "This" to point to the base address of the -- object (that is, the address of the primary tag of the object). procedure Check_TSD (TSD : Type_Specific_Data_Ptr); -- Ada 2012 (AI-113): Raise Program_Error if the external tag of this TSD -- is the same as the external tag for some other tagged type declaration. function Displace (This : System.Address; T : Tag) return System.Address; -- Ada 2005 (AI-251): Displace "This" to point to the secondary dispatch -- table of T. function Secondary_Tag (T, Iface : Tag) return Tag; -- Ada 2005 (AI-251): Given a primary tag T associated with a tagged type -- Typ, search for the secondary tag of the interface type Iface covered -- by Typ. function DT (T : Tag) return Dispatch_Table_Ptr; -- Return the pointer to the TSD record associated with T function Get_Entry_Index (T : Tag; Position : Positive) return Positive; -- Ada 2005 (AI-251): Return a primitive operation's entry index (if entry) -- given a dispatch table T and a position of a primitive operation in T. function Get_Offset_Index (T : Tag; Position : Positive) return Positive; -- Ada 2005 (AI-251): Given a pointer to a secondary dispatch table (T) -- and a position of an operation in the DT, retrieve the corresponding -- operation's position in the primary dispatch table from the Offset -- Specific Data table of T. function Get_Prim_Op_Kind (T : Tag; Position : Positive) return Prim_Op_Kind; -- Ada 2005 (AI-251): Return a primitive operation's kind given a dispatch -- table T and a position of a primitive operation in T. function Get_Tagged_Kind (T : Tag) return Tagged_Kind; -- Ada 2005 (AI-345): Given a pointer to either a primary or a secondary -- dispatch table, return the tagged kind of a type in the context of -- concurrency and limitedness. function IW_Membership (This : System.Address; T : Tag) return Boolean; -- Ada 2005 (AI-251): General routine that checks if a given object -- implements a tagged type. Its common usage is to check if Obj is in -- Iface'Class, but it is also used to check if a class-wide interface -- implements a given type (Iface_CW_Typ in T'Class). For example: -- -- type I is interface; -- type T is tagged ... -- -- function Test (O : I'Class) is -- begin -- return O in T'Class. -- end Test; function Offset_To_Top (This : System.Address) return SSE.Storage_Offset; -- Ada 2005 (AI-251): Returns the current value of the Offset_To_Top -- component available in the prologue of the dispatch table. If the parent -- of the tagged type has discriminants this value is stored in a record -- component just immediately after the tag component. function Needs_Finalization (T : Tag) return Boolean; -- A helper routine used in conjunction with finalization collections which -- service class-wide types. The function dynamically determines whether an -- object is controlled or has controlled components. function Parent_Size (Obj : System.Address; T : Tag) return SSE.Storage_Count; -- Computes the size the ancestor part of a tagged extension object whose -- address is 'obj' by calling indirectly the ancestor _size function. The -- ancestor is the parent of the type represented by tag T. This function -- assumes that _size is always in slot one of the dispatch table. pragma Export (Ada, Parent_Size, "ada__tags__parent_size"); -- This procedure is used in s-finimp and is thus exported manually procedure Register_Interface_Offset (This : System.Address; Interface_T : Tag; Is_Static : Boolean; Offset_Value : SSE.Storage_Offset; Offset_Func : Offset_To_Top_Function_Ptr); -- Register in the table of interfaces of the tagged type associated with -- "This" object the offset of the record component associated with the -- progenitor Interface_T (that is, the distance from "This" to the object -- component containing the tag of the secondary dispatch table). In case -- of constant offset, Is_Static is true and Offset_Value has such value. -- In case of variable offset, Is_Static is false and Offset_Func is an -- access to function that must be called to evaluate the offset. procedure Register_Tag (T : Tag); -- Insert the Tag and its associated external_tag in a table for the sake -- of Internal_Tag. procedure Set_Dynamic_Offset_To_Top (This : System.Address; Interface_T : Tag; Offset_Value : SSE.Storage_Offset; Offset_Func : Offset_To_Top_Function_Ptr); -- Ada 2005 (AI-251): The compiler generates calls to this routine only -- when initializing the Offset_To_Top field of dispatch tables associated -- with tagged type whose parent has variable size components. "This" is -- the object whose dispatch table is being initialized. Interface_T is the -- interface for which the secondary dispatch table is being initialized, -- and Offset_Value is the distance from "This" to the object component -- containing the tag of the secondary dispatch table (a zero value means -- that this interface shares the primary dispatch table). Offset_Func -- references a function that must be called to evaluate the offset at -- runtime. This routine also takes care of registering these values in -- the table of interfaces of the type. procedure Set_Entry_Index (T : Tag; Position : Positive; Value : Positive); -- Ada 2005 (AI-345): Set the entry index of a primitive operation in T's -- TSD table indexed by Position. procedure Set_Prim_Op_Kind (T : Tag; Position : Positive; Value : Prim_Op_Kind); -- Ada 2005 (AI-251): Set the kind of a primitive operation in T's TSD -- table indexed by Position. procedure Unregister_Tag (T : Tag); -- Remove a particular tag from the external tag hash table Max_Predef_Prims : constant Positive := 15; -- Number of reserved slots for the following predefined ada primitives: -- -- 1. Size -- 2. Read -- 3. Write -- 4. Input -- 5. Output -- 6. "=" -- 7. assignment -- 8. deep adjust -- 9. deep finalize -- 10. async select -- 11. conditional select -- 12. prim_op kind -- 13. task_id -- 14. dispatching requeue -- 15. timed select -- -- The compiler checks that the value here is correct subtype Predef_Prims_Table is Address_Array (1 .. Max_Predef_Prims); type Predef_Prims_Table_Ptr is access Predef_Prims_Table; pragma No_Strict_Aliasing (Predef_Prims_Table_Ptr); type Addr_Ptr is access System.Address; pragma No_Strict_Aliasing (Addr_Ptr); -- This type is used by the frontend to generate the code that handles -- dispatch table slots of types declared at the local level. end Ada.Tags;
reznikmm/matreshka
Ada
3,688
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.Declarations.Package_Instantiation is function Code (Engine : access Engines.Contexts.Context; Element : Asis.Declaration; Name : Engines.Text_Property) return League.Strings.Universal_String; end Properties.Declarations.Package_Instantiation;
AdaCore/libadalang
Ada
92
adb
with Ada; dummyyy; with Pkg; procedure Syntax_Error is begin Pkg.Foo; end Syntax_Error;
pombredanne/ravenadm
Ada
3,949
ads
-- This file is covered by the Internet Software Consortium (ISC) License -- Reference: ../License.txt with Interfaces.C; with Interfaces.C_Streams; with Interfaces.C.Strings; with HelperText; package Unix is package HT renames HelperText; package IC renames Interfaces.C; package ICS renames Interfaces.C.Strings; package CSM renames Interfaces.C_Streams; type process_exit is (still_running, exited_normally, exited_with_error); type Int32 is private; subtype pid_t is Int32; -- check if process identified by pid has exited or keeps going function process_status (pid : pid_t) return process_exit; -- Kill everything with the identified process group procedure kill_process_tree (process_group : pid_t); -- Allows other packages to call external commands (e.g. Pilot) -- Returns "True" on success function external_command (command : String) return Boolean; -- wrapper for nonblocking spawn function launch_process (command : String) return pid_t; -- Returns True if pid is less than zero function fork_failed (pid : pid_t) return Boolean; -- Returns True if "variable" is defined in the environment. The -- value of variable is irrelevant function env_variable_defined (variable : String) return Boolean; -- Return value of "variable" defined in environment. If it's not -- defined than an empty string is returned; function env_variable_value (variable : String) return String; -- Execute popen and return stdout+stderr combined -- Also the result status is returned as an "out" variable function piped_command (command : String; status : out Integer) return HT.Text; -- Run external command that is expected to have no output to standard -- out, but catch stdout anyway. Don't return any output, but do return -- True of the command returns status of zero. function piped_mute_command (command : String; abnormal : out HT.Text) return Boolean; -- When the cone of silence is deployed, the terminal does not echo -- and Control-Q/S keystrokes are not captured (and vice-versa) procedure cone_of_silence (deploy : Boolean); -- Returns True if a TTY device is detected function screen_attached return Boolean; -- Equivalent of libc's realpath() function -- It resolves symlinks and relative directories to get the true path function true_path (provided_path : String) return String; -- Ignore SIGTTOU signal (background process trying to write to terminal) -- If that happens, synth will suspend and ultimately fail. procedure ignore_background_tty; private type uInt8 is mod 2 ** 16; type Int32 is range -(2 ** 31) .. +(2 ** 31) - 1; function popen (Command, Mode : IC.char_array) return CSM.FILEs; pragma Import (C, popen); function pclose (FileStream : CSM.FILEs) return CSM.int; pragma Import (C, pclose); function realpath (pathname, resolved_path : IC.char_array) return ICS.chars_ptr; pragma Import (C, realpath, "realpath"); function nohang_waitpid (pid : pid_t) return uInt8; pragma Import (C, nohang_waitpid, "__nohang_waitpid"); function silent_control return uInt8; pragma Import (C, silent_control, "__silent_control"); function chatty_control return uInt8; pragma Import (C, chatty_control, "__chatty_control"); function signal_runaway (pid : pid_t) return IC.int; pragma Import (C, signal_runaway, "__shut_it_down"); function ignore_tty_write return uInt8; pragma Import (C, ignore_tty_write, "__ignore_background_tty_writes"); function ignore_tty_read return uInt8; pragma Import (C, ignore_tty_read, "__ignore_background_tty_reads"); -- internal pipe close command function pipe_close (OpenFile : CSM.FILEs) return Integer; -- internal pipe read command function pipe_read (OpenFile : CSM.FILEs) return HT.Text; end Unix;
Rodeo-McCabe/orka
Ada
6,611
ads
-- SPDX-License-Identifier: Apache-2.0 -- -- Copyright (c) 2012 Felix Krause <[email protected]> -- -- Licensed under the Apache License, Version 2.0 (the "License"); -- you may not use this file except in compliance with the License. -- You may obtain a copy of the License at -- -- http://www.apache.org/licenses/LICENSE-2.0 -- -- Unless required by applicable law or agreed to in writing, software -- distributed under the License is distributed on an "AS IS" BASIS, -- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -- See the License for the specific language governing permissions and -- limitations under the License. with GL.Algebra; package GL.Types is pragma Pure; -- These are the types you can and should use with OpenGL functions -- (particularly when dealing with buffer objects). -- Types that are only used internally, but may be needed when interfacing -- with OpenGL-related library APIs can be found in GL.Low_Level. type long_long_int is range -(2 ** 63) .. +(2 ** 63 - 1); -- Based on C99 long long int type unsigned_long_long is mod 2 ** 64; -- Based on C99 unsigned long long int subtype UInt64 is unsigned_long_long; -- Signed integer types type Byte is new C.signed_char; type Short is new C.short; type Int is new C.int; type Long is new long_long_int; subtype Size is Int range 0 .. Int'Last; subtype Long_Size is Long range 0 .. Long'Last; subtype Positive_Size is Size range 1 .. Size'Last; -- Unsigned integer types type UByte is new C.unsigned_char; type UShort is new C.unsigned_short; type UInt is new C.unsigned; -- Floating point types ("Single" is used to avoid conflicts with Float) subtype Half is Short; -- F16C extension can be used to convert from/to Single type Single is new C.C_float; type Double is new C.double; subtype Normalized_Single is Single range 0.0 .. 1.0; -- Array types type Byte_Array is array (Size range <>) of aliased Byte; type Short_Array is array (Size range <>) of aliased Short; type Int_Array is array (Size range <>) of aliased Int; type UByte_Array is array (Size range <>) of aliased UByte; type UShort_Array is array (Size range <>) of aliased UShort; type UInt_Array is array (Size range <>) of aliased UInt; type Half_Array is array (Size range <>) of aliased Half; type Single_Array is array (Size range <>) of aliased Single; type Double_Array is array (Size range <>) of aliased Double; type Size_Array is array (Size range <>) of aliased Size; pragma Convention (C, Byte_Array); pragma Convention (C, Short_Array); pragma Convention (C, Int_Array); pragma Convention (C, UByte_Array); pragma Convention (C, UShort_Array); pragma Convention (C, UInt_Array); pragma Convention (C, Half_Array); pragma Convention (C, Single_Array); pragma Convention (C, Double_Array); pragma Convention (C, Size_Array); -- Type descriptors type Numeric_Type is (Byte_Type, UByte_Type, Short_Type, UShort_Type, Int_Type, UInt_Type, Single_Type, Double_Type, Half_Type); type Index_Type is (UShort_Type, UInt_Type); type Connection_Mode is (Points, Lines, Line_Loop, Line_Strip, Triangles, Triangle_Strip, Triangle_Fan, Lines_Adjacency, Line_Strip_Adjacency, Triangles_Adjacency, Triangle_Strip_Adjacency, Patches); type Compare_Function is (Never, Less, Equal, LEqual, Greater, Not_Equal, GEqual, Always); subtype Component_Count is Int range 1 .. 4; -- Counts the number of components for vertex attributes subtype Byte_Count is Int range 1 .. 4 with Static_Predicate => Byte_Count in 1 | 2 | 4; -- Number of bytes of a component package Bytes is new GL.Algebra (Element_Type => Byte, Index_Type => Size); package Shorts is new GL.Algebra (Element_Type => Short, Index_Type => Size); package Ints is new GL.Algebra (Element_Type => Int, Index_Type => Size); package Longs is new GL.Algebra (Element_Type => Long, Index_Type => Size); package UBytes is new GL.Algebra (Element_Type => UByte, Index_Type => Size); package UShorts is new GL.Algebra (Element_Type => UShort, Index_Type => Size); package UInts is new GL.Algebra (Element_Type => UInt, Index_Type => Size); package Singles is new GL.Algebra (Element_Type => Single, Index_Type => Size); package Doubles is new GL.Algebra (Element_Type => Double, Index_Type => Size); private for Numeric_Type use (Byte_Type => 16#1400#, UByte_Type => 16#1401#, Short_Type => 16#1402#, UShort_Type => 16#1403#, Int_Type => 16#1404#, UInt_Type => 16#1405#, Single_Type => 16#1406#, Double_Type => 16#140A#, Half_Type => 16#140B#); for Numeric_Type'Size use UInt'Size; for Index_Type use (UShort_Type => 16#1403#, UInt_Type => 16#1405#); for Index_Type'Size use UInt'Size; for Connection_Mode use (Points => 16#0000#, Lines => 16#0001#, Line_Loop => 16#0002#, Line_Strip => 16#0003#, Triangles => 16#0004#, Triangle_Strip => 16#0005#, Triangle_Fan => 16#0006#, Lines_Adjacency => 16#000A#, Line_Strip_Adjacency => 16#000B#, Triangles_Adjacency => 16#000C#, Triangle_Strip_Adjacency => 16#000D#, Patches => 16#000E#); for Connection_Mode'Size use UInt'Size; for Compare_Function use (Never => 16#0200#, Less => 16#0201#, Equal => 16#0202#, LEqual => 16#0203#, Greater => 16#0204#, Not_Equal => 16#0205#, GEqual => 16#0206#, Always => 16#0207#); for Compare_Function'Size use UInt'Size; end GL.Types;
Fabien-Chouteau/GESTE
Ada
2,028
adb
with Ada.Real_Time; with Render; with Keyboard; with Levels; with Player; with GESTE.Text; with GESTE_Config; with GESTE_Fonts.FreeMono5pt7b; package body Game is package RT renames Ada.Real_Time; use type RT.Time; use type RT.Time_Span; Text : aliased GESTE.Text.Instance (GESTE_Fonts.FreeMono5pt7b.Font, 15, 1, Render.Black, GESTE_Config.Transparent); Frame_Counter : Natural := 0; Next_FPS_Update : RT.Time := RT.Clock + RT.Seconds (1); Period : constant RT.Time_Span := RT.Seconds (1) / 60; Next_Release : RT.Time := RT.Clock + Period; --------------- -- Game_Loop -- --------------- procedure Game_Loop is begin loop Keyboard.Update; if Keyboard.Pressed (Keyboard.Up) then Player.Move_Up; end if; if Keyboard.Pressed (Keyboard.Down) then Player.Move_Down; end if; if Keyboard.Pressed (Keyboard.Left) then Player.Move_Left; end if; if Keyboard.Pressed (Keyboard.Right) then Player.Move_Right; end if; if Keyboard.Pressed (Keyboard.Esc) then return; end if; Player.Update; Levels.Update; Frame_Counter := Frame_Counter + 1; if Next_FPS_Update <= RT.Clock then Next_FPS_Update := RT.Clock + RT.Seconds (1); Text.Clear; Text.Cursor (1, 1); Text.Put ("FPS:" & Frame_Counter'Img); Frame_Counter := 0; end if; Render.Render_Dirty (Render.Black); delay until Next_Release; Next_Release := Next_Release + Period; end loop; end Game_Loop; -------------------- -- Set_Screen_Pos -- -------------------- procedure Set_Screen_Pos (Pt : GESTE.Pix_Point) is begin Render.Set_Screen_Offset (Pt); end Set_Screen_Pos; begin Text.Move ((0, 0)); GESTE.Add (Text'Access, 10); Render.Render_All (Render.Black); end Game;
coopht/axmpp
Ada
6,804
adb
------------------------------------------------------------------------------ -- -- -- AXMPP Project -- -- -- -- XMPP Library for Ada -- -- -- ------------------------------------------------------------------------------ -- -- -- Copyright © 2011, Alexander Basov <[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 Alexander Basov, 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.Wide_Wide_Text_IO; with Con_Cli; with XMPP.IQS; pragma Warnings (Off, XMPP.IQS); -- XXX : Gnat gpl 2010 bug with XMPP.Objects; pragma Warnings (Off, XMPP.Objects); -- XXX : Gnat gpl 2010 bug package body Con_Cli_Handlers is use XMPP.IQS; use XMPP.Objects; use type XMPP.Bind_State; use type XMPP.Session_State; --------------------------- -- Bind_Resource_State -- --------------------------- overriding procedure Bind_Resource_State (Self : in out Con_Cli_Handler; JID : League.Strings.Universal_String; Status : XMPP.Bind_State) is begin if Status = XMPP.Success then Ada.Wide_Wide_Text_IO.Put_Line ("Resource Binded Success: " & JID.To_Wide_Wide_String); -- After resource binded successfull establishing session Self.Object.Establish_IQ_Session; end if; end Bind_Resource_State; ----------------- -- Connected -- ----------------- overriding procedure Connected (Self : in out Con_Cli_Handler; Object : XMPP.Stream_Features.XMPP_Stream_Feature'Class) is pragma Unreferenced (Object); pragma Unreferenced (Self); begin Ada.Wide_Wide_Text_IO.Put_Line ("Yeah, we are connected"); end Connected; ---------------- -- Presence -- ---------------- overriding procedure Presence (Self : in out Con_Cli_Handler; Data : XMPP.Presences.XMPP_Presence'Class) is pragma Unreferenced (Self); begin Ada.Wide_Wide_Text_IO.Put_Line ("Presence Arrived: "); Ada.Wide_Wide_Text_IO.Put_Line ("User " & Data.Get_From.To_Wide_Wide_String & " is " & XMPP.Show_Kind'Wide_Wide_Image (Data.Get_Show) & "(" & Data.Get_Status.To_Wide_Wide_String & ")"); end Presence; --------------------- -- Session_State -- --------------------- overriding procedure Session_State (Self : in out Con_Cli_Handler; Status : XMPP.Session_State) is begin if Status = XMPP.Established then Ada.Wide_Wide_Text_IO.Put_Line ("Session established !!!"); Self.Object.Request_Roster; -- After session successfully established, -- sending presence Self.Set_Presence; end if; end Session_State; -------------------- -- Set_Presence -- -------------------- procedure Set_Presence (Self : in out Con_Cli_Handler) is P : XMPP.Presences.XMPP_Presence; begin Self.Object.Send_Object (P); end Set_Presence; -------------------------- -- Set_Session_Object -- -------------------------- procedure Set_Session_Object (Self : in out Con_Cli_Handler; Object : not null access Con_Cli.Session'Class) is begin Self.Object := Object; end Set_Session_Object; -------------------- -- Start_Stream -- -------------------- overriding procedure Start_Stream (Self : in out Con_Cli_Handler; Object : XMPP.Streams.XMPP_Stream'Class) is pragma Unreferenced (Self); pragma Unreferenced (Object); begin Ada.Wide_Wide_Text_IO.Put_Line ("Start_Stream called"); end Start_Stream; ----------------------- -- Stream_Features -- ----------------------- overriding procedure Stream_Features (Self : in out Con_Cli_Handler; Object : XMPP.Stream_Features.XMPP_Stream_Feature'Class) is pragma Unreferenced (Self); pragma Unreferenced (Object); begin Ada.Wide_Wide_Text_IO.Put_Line ("Stream_Features called"); end Stream_Features; end Con_Cli_Handlers;
stcarrez/ada-asf
Ada
3,922
ads
----------------------------------------------------------------------- -- components-widgets-likes -- Social Likes Components -- Copyright (C) 2013, 2019 Stephane Carrez -- Written by Stephane Carrez ([email protected]) -- -- Licensed under the Apache License, Version 2.0 (the "License"); -- you may not use this file except in compliance with the License. -- You may obtain a copy of the License at -- -- http://www.apache.org/licenses/LICENSE-2.0 -- -- Unless required by applicable law or agreed to in writing, software -- distributed under the License is distributed on an "AS IS" BASIS, -- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -- See the License for the specific language governing permissions and -- limitations under the License. ----------------------------------------------------------------------- with Util.Strings; with ASF.Applications; with ASF.Components.Html; with ASF.Contexts.Faces; package ASF.Components.Widgets.Likes is -- ------------------------------ -- UILike -- ------------------------------ -- The <b>UILike</b> component displays a social like button to recommend a page. type UILike is new ASF.Components.Html.UIHtmlComponent with null record; -- Get the link to submit in the like action. function Get_Link (UI : in UILike; Context : in ASF.Contexts.Faces.Faces_Context'Class) return String; -- Render the like button for Facebook or Google+. overriding procedure Encode_Begin (UI : in UILike; Context : in out ASF.Contexts.Faces.Faces_Context'Class); -- ------------------------------ -- Like Generator -- ------------------------------ -- The <tt>Like_Generator</tt> represents the specific method for the generation of -- a social like generator. A generator is registered under a given name with the -- <tt>Register_Like</tt> operation. The current implementation provides a Facebook -- like generator. type Like_Generator is limited interface; type Like_Generator_Access is access all Like_Generator'Class; -- Render the like button according to the generator and the component attributes. procedure Render_Like (Generator : in Like_Generator; UI : in UILike'Class; Href : in String; Context : in out ASF.Contexts.Faces.Faces_Context'Class) is abstract; -- Maximum number of generators that can be registered. MAX_LIKE_GENERATOR : constant Positive := 5; -- Register the like generator under the given name. procedure Register_Like (Name : in Util.Strings.Name_Access; Generator : in Like_Generator_Access); -- ------------------------------ -- Facebook like generator -- ------------------------------ type Facebook_Like_Generator is new Like_Generator with null record; overriding procedure Render_Like (Generator : in Facebook_Like_Generator; UI : in UILike'Class; Href : in String; Context : in out ASF.Contexts.Faces.Faces_Context'Class); -- The application configuration parameter that defines which Facebook client ID must be used. package P_Facebook_App_Id is new ASF.Applications.Parameter ("facebook.client_id", ""); -- ------------------------------ -- Twitter like generator -- ------------------------------ type Twitter_Like_Generator is new Like_Generator with null record; overriding procedure Render_Like (Generator : in Twitter_Like_Generator; UI : in UILike'Class; Href : in String; Context : in out ASF.Contexts.Faces.Faces_Context'Class); end ASF.Components.Widgets.Likes;
stcarrez/ada-keystore
Ada
4,249
ads
----------------------------------------------------------------------- -- akt-callbacks -- Callbacks for Ada Keystore GTK application -- Copyright (C) 2019 Stephane Carrez -- Written by Stephane Carrez ([email protected]) -- -- Licensed under the Apache License, Version 2.0 (the "License"); -- you may not use this file except in compliance with the License. -- You may obtain a copy of the License at -- -- http://www.apache.org/licenses/LICENSE-2.0 -- -- Unless required by applicable law or agreed to in writing, software -- distributed under the License is distributed on an "AS IS" BASIS, -- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -- See the License for the specific language governing permissions and -- limitations under the License. ----------------------------------------------------------------------- with Gtkada.Builder; with AKT.Windows; package AKT.Callbacks is -- Initialize and register the callbacks. procedure Initialize (Application : in AKT.Windows.Application_Access; Builder : in Gtkada.Builder.Gtkada_Builder); -- Callback executed when the "quit" action is executed from the menu. procedure On_Menu_Quit (Object : access Gtkada.Builder.Gtkada_Builder_Record'Class); -- Callback executed when the "about" action is executed from the menu. procedure On_Menu_About (Object : access Gtkada.Builder.Gtkada_Builder_Record'Class); -- Callback executed when the "menu-new" action is executed from the file menu. procedure On_Menu_New (Object : access Gtkada.Builder.Gtkada_Builder_Record'Class); -- Callback executed when the "menu-open" action is executed from the file menu. procedure On_Menu_Open (Object : access Gtkada.Builder.Gtkada_Builder_Record'Class); -- Callback executed when the "tool-add" action is executed from the toolbar. procedure On_Tool_Add (Object : access Gtkada.Builder.Gtkada_Builder_Record'Class); -- Callback executed when the "tool-save" action is executed from the toolbar. procedure On_Tool_Save (Object : access Gtkada.Builder.Gtkada_Builder_Record'Class); -- Callback executed when the "tool-edit" action is executed from the toolbar. procedure On_Tool_Edit (Object : access Gtkada.Builder.Gtkada_Builder_Record'Class); -- Callback executed when the "tool-lock" action is executed from the toolbar. procedure On_Tool_Lock (Object : access Gtkada.Builder.Gtkada_Builder_Record'Class); -- Callback executed when the "tool-unlock" action is executed from the toolbar. procedure On_Tool_Unlock (Object : access Gtkada.Builder.Gtkada_Builder_Record'Class); -- Callback executed when the "open-file" action is executed from the open_file dialog. procedure On_Open_File (Object : access Gtkada.Builder.Gtkada_Builder_Record'Class); -- Callback executed when the "cancel-open-file" action is executed from the open_file dialog. procedure On_Cancel_Open_File (Object : access Gtkada.Builder.Gtkada_Builder_Record'Class); -- Callback executed when the "create-file" action is executed from the open_file dialog. procedure On_Create_File (Object : access Gtkada.Builder.Gtkada_Builder_Record'Class); -- Callback executed when the "cancel-create-file" action is executed -- from the open_file dialog. procedure On_Cancel_Create_File (Object : access Gtkada.Builder.Gtkada_Builder_Record'Class); -- Callback executed when the "delete-event" action is executed from the main window. function On_Close_Window (Object : access Gtkada.Builder.Gtkada_Builder_Record'Class) return Boolean; -- Callback executed when the "close-about" action is executed from the about box. procedure On_Close_About (Object : access Gtkada.Builder.Gtkada_Builder_Record'Class); -- Callback executed when the "close-password" action is executed from the password dialog. procedure On_Close_Password (Object : access Gtkada.Builder.Gtkada_Builder_Record'Class); -- Callback executed when the "dialog-password-ok" action is executed from the password dialog. procedure On_Dialog_Password_Ok (Object : access Gtkada.Builder.Gtkada_Builder_Record'Class); end AKT.Callbacks;
zhmu/ananas
Ada
4,682
adb
------------------------------------------------------------------------------ -- -- -- GNAT COMPILER COMPONENTS -- -- -- -- G N A T . S E R I A L _ C O M M U N I C A T I O N S -- -- -- -- B o d y -- -- -- -- Copyright (C) 2007-2022, AdaCore -- -- -- -- GNAT is free software; you can redistribute it and/or modify it under -- -- terms of the GNU General Public License as published by the Free Soft- -- -- ware Foundation; either version 3, or (at your option) any later ver- -- -- sion. GNAT is distributed in the hope that it will be useful, but WITH- -- -- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY -- -- or FITNESS FOR A PARTICULAR PURPOSE. -- -- -- -- As a special exception under Section 7 of GPL version 3, you are granted -- -- additional permissions described in the GCC Runtime Library Exception, -- -- version 3.1, as published by the Free Software Foundation. -- -- -- -- You should have received a copy of the GNU General Public License and -- -- a copy of the GCC Runtime Library Exception along with this program; -- -- see the files COPYING3 and COPYING.RUNTIME respectively. If not, see -- -- <http://www.gnu.org/licenses/>. -- -- -- -- GNAT was originally developed by the GNAT team at New York University. -- -- Extensive contributions were provided by Ada Core Technologies Inc. -- -- -- ------------------------------------------------------------------------------ -- Default version of this package with Ada.Streams; use Ada.Streams; package body GNAT.Serial_Communications is pragma Warnings (Off); -- Kill warnings on unreferenced formals type Port_Data is new Integer; ----------------------- -- Local Subprograms -- ----------------------- procedure Unimplemented; pragma No_Return (Unimplemented); -- This procedure raises a Program_Error with an appropriate message -- indicating that an unimplemented feature has been used. ---------- -- Name -- ---------- function Name (Number : Positive) return Port_Name is begin Unimplemented; return ""; end Name; ---------- -- Open -- ---------- procedure Open (Port : out Serial_Port; Name : Port_Name) is begin Unimplemented; end Open; --------- -- Set -- --------- procedure Set (Port : Serial_Port; Rate : Data_Rate := B9600; Bits : Data_Bits := CS8; Stop_Bits : Stop_Bits_Number := One; Parity : Parity_Check := None; Block : Boolean := True; Local : Boolean := True; Flow : Flow_Control := None; Timeout : Duration := 10.0) is begin Unimplemented; end Set; ---------- -- Read -- ---------- overriding procedure Read (Port : in out Serial_Port; Buffer : out Stream_Element_Array; Last : out Stream_Element_Offset) is begin Unimplemented; end Read; ------------ -- To_Ada -- ------------ procedure To_Ada (Port : out Serial_Port; Fd : Serial_Port_Descriptor) is begin Unimplemented; end To_Ada; ----------- -- Write -- ----------- overriding procedure Write (Port : in out Serial_Port; Buffer : Stream_Element_Array) is begin Unimplemented; end Write; ----------- -- Close -- ----------- procedure Close (Port : in out Serial_Port) is begin Unimplemented; end Close; ------------------- -- Unimplemented; -- ------------------- procedure Unimplemented is begin raise Program_Error with "Serial_Communications not implemented"; end Unimplemented; end GNAT.Serial_Communications;
xeenta/learning-ada
Ada
4,094
adb
with Ada.Text_IO; use Ada.Text_IO; procedure Pre_Post is package P is type Int_Array is array (Integer range <>) of Integer; -- Increment the input (obvious) procedure Increment (A : in out Integer) with Post => A = A'Old + 1; -- A "limited" negate (nonsense...) procedure Limited_Negate (A : in out Integer; B : in Integer) with Post => (if A < B then A = -A'Old else A = -B); -- just to show the attribute Result function Sum_Minus_One (A, B : Integer) return Integer with Post => Sum_Minus_One'Result = A + B - 1; -- 5, 2 give 3; -2, -5 give 3, but -5, -2... fails pre function Positive_Diff (A, B : Integer) return Integer with Pre => A > B, Post => Positive_Diff'Result = A - B; -- a sort... the precondition is rather odd: the caller must -- call this subprogram only when she knows the array isn't -- sorted; for a more "realistic" case, remove the Pre. procedure Sort (A : in out Int_Array) with Pre => (for some I in A'First .. A'Last - 1 => A (I) > A (I+1)), Post => (for all I in A'First .. A'Last - 1 => A (I) <= A (I+1)); end P; package body P is -- bubble sort procedure Sort (A : in out Int_Array) is App : Integer; Swapped : Boolean := True; begin while Swapped loop Swapped := False; for I in A'First .. A'Last - 1 loop if A (I) > A (I + 1) then App := A (I); A (I) := A (I + 1); A (I + 1) := App; Swapped := True; end if; end loop; end loop; end Sort; procedure Increment (A : in out Integer) is begin A := A + 1; end Increment; procedure Limited_Negate (A : in out Integer; B : in Integer) is begin -- correct implementation... -- if A < B then -- A := -A; -- else -- A := -B; -- end if; A := -A + B; -- wrong implementation... end Limited_Negate; function Sum_Minus_One (A, B : Integer) return Integer is begin -- for such a short function I prefer the other syntax... return A + B - 1; end Sum_Minus_One; function Positive_Diff (A, B : Integer) return Integer is begin return A - B; end Positive_Diff; end P; A : constant Integer := 1; B : Integer := 2; package IO is new Ada.Text_IO.Integer_IO (Integer); procedure O (X : Integer) with Inline; procedure O (X : Integer) is begin IO.Put (X); New_Line; end O; use P; -- an unsorted array Un_Arr : Int_Array := (10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0); -- a sorted array Ord_Arr : Int_Array := (1, 4, 8, 10, 11, 100, 200); begin O (A); O (B); Increment (B); O (B); O (Sum_Minus_One (A, B)); -- compiler warn: "actuals for this call may be in wrong order", -- this is why I've used named parameters O (Positive_Diff (A => B, B => A)); Put_Line ("everything's alright?"); -- Pre requires A > B, but B = 3 and A = 1... => runtime exception -- telling us "failed precondition from pre_post.adb" (followed by -- the line in the source code, which I removed because I'm -- modifying this source adding lines) --O (Positive_Diff (A, B)); -- and this at runtime gives "failed postcondition from -- pre_post.adb", because the guy who implemented the code hasn't -- understood the specifications... --Limited_Negate (A, B); O (A); O (B); for I in Un_Arr'Range loop IO.Put (Un_Arr (I)); end loop; New_Line; Sort (Un_Arr); for I in Un_Arr'Range loop IO.Put (Un_Arr (I)); end loop; New_Line; -- calling this violates the preconditions: our sort assumes that -- the array isn't already sorted... --Sort (Ord_Arr); end Pre_Post;
eqcola/ada-ado
Ada
1,947
ads
----------------------------------------------------------------------- -- ado-c -- Support for driver implementation -- Copyright (C) 2009, 2010, 2011, 2012 Stephane Carrez -- Written by Stephane Carrez ([email protected]) -- -- Licensed under the Apache License, Version 2.0 (the "License"); -- you may not use this file except in compliance with the License. -- You may obtain a copy of the License at -- -- http://www.apache.org/licenses/LICENSE-2.0 -- -- Unless required by applicable law or agreed to in writing, software -- distributed under the License is distributed on an "AS IS" BASIS, -- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -- See the License for the specific language governing permissions and -- limitations under the License. ----------------------------------------------------------------------- with Interfaces.C; with Interfaces.C.Strings; with Ada.Finalization; with Ada.Strings.Unbounded; with Ada.Unchecked_Conversion; with System; package ADO.C is type String_Ptr is limited private; -- Convert a string to a C string. function To_String_Ptr (S : String) return String_Ptr; -- Convert an unbounded string to a C string. function To_String_Ptr (S : Ada.Strings.Unbounded.Unbounded_String) return String_Ptr; -- Get the C string pointer. function To_C (S : String_Ptr) return Interfaces.C.Strings.chars_ptr; -- Set the string procedure Set_String (S : in out String_Ptr; Value : in String); function To_chars_ptr is new Ada.Unchecked_Conversion (System.Address, Interfaces.C.Strings.chars_ptr); private use Interfaces.C; type String_Ptr is new Ada.Finalization.Limited_Controlled with record Ptr : Strings.chars_ptr := Interfaces.C.Strings.Null_Ptr; end record; -- Reclaim the storage held by the C string. procedure Finalize (S : in out String_Ptr); end ADO.C;
jquorning/iNow
Ada
3,744
adb
-- -- The author disclaims copyright to this source code. In place of -- a legal notice, here is a blessing: -- -- May you do good and not evil. -- May you find forgiveness for yourself and forgive others. -- May you share freely, not taking more than you give. -- ----------------------------------------------------------------------------- -- Navigate body -- Todo lists are hieracial. -- with Ada.Strings.Unbounded; with Ada.Text_IO; with Database.Jobs; package body Navigate is type Level_Index is new Positive; use type Types.Job_Id; package Path_Vectors is new Ada.Containers.Vectors (Level_Index, Types.Job_Id); Path : Path_Vectors.Vector; procedure Top is begin Path := Path_Vectors.Empty_Vector; Path_Vectors.Append (Path, Types.Job_Id'(0)); end Top; procedure Parent is begin Path.Delete_Last; end Parent; function Path_Image return String is use Ada.Strings.Unbounded; A : Unbounded_String; begin for Level of Path loop Append (A, " >>" & Level'Img); end loop; return To_String (A); end Path_Image; procedure Build_Path (Job : in Types.Job_Id) is Iter : Types.Job_Id := Job; Info : Types.Job_Info; begin Ada.Text_IO.Put_Line ("Build_Path" & Job'Img); Path := Path_Vectors.Empty_Vector; while Iter /= 0 loop Path_Vectors.Prepend (Path, Iter); Info := Database.Jobs.Get_Job_Info (Iter); Iter := Info.Parent; end loop; Path_Vectors.Prepend (Path, 0); end Build_Path; function Current_Job return Types.Job_Id is begin return Path.Last_Element; end Current_Job; procedure Refresh_List is subtype S2 is String (1 .. 2); function To_S2 (A : Natural) return S2; function To_S2 (A : Natural) return S2 is package Natural_IO is new Ada.Text_IO.Integer_IO (Positive); Image : S2; begin Natural_IO.Default_Width := 2; Natural_IO.Put (Image, A); if Image (1) = ' ' then Image (1) := '0'; end if; return Image; end To_S2; use Database.Jobs; Set : constant Types.Job_Sets.Vector := Get_Jobs (Top_Level); begin List.Set.Clear; List.Refs.Clear; List.Current := Get_Current_Job; -- Build references for top level. for Job in Set.First_Index .. Set.Last_Index loop List.Set.Append (Set (Job)); List.Refs.Append (Ref_Pair'("J" & To_S2 (Natural (Job)), 0)); if List.Set (Job).Id = List.Current then declare Subset : constant Types.Job_Sets.Vector := Get_Jobs (List.Current); subtype Index_Range is Types.Job_Index range Subset.First_Index .. Subset.Last_Index; Refs : Ref_Vectors.Vector; begin for Index in Index_Range loop Refs.Append (("T" & To_S2 (Integer (Index)), 1)); end loop; List.Set .Append (Subset); List.Refs.Append (Refs); end; end if; end loop; end Refresh_List; procedure Lookup_Job (Text : in String; Job : out Types.Job_Id; Success : out Boolean) is begin for Index in List.Set.First_Index .. List.Set.Last_Index loop if List.Refs (Index).Ref = Text then Job := List.Set (Index).Id; Success := True; return; end if; end loop; Success := False; end Lookup_Job; begin Top; end Navigate;
Fabien-Chouteau/lvgl-ada
Ada
1,928
ads
with System; package Lv.Mem is -- Allocate a memory dynamically -- @param size size of the memory to allocate in bytes -- @return pointer to the allocated memory function Alloc (Size : Uint32_T) return System.Address; -- Free an allocated data -- @param data pointer to an allocated memory procedure Free (Addr : System.Address); -- Reallocate a memory with a new size. The old content will be kept. -- @param data pointer to an allocated memory. -- Its content will be copied to the new memory block and freed -- @param new_size the desired new size in byte -- @return pointer to the new memory function Realloc (Addr : System.Address; New_Size : Uint32_T) return System.Address; -- Join the adjacent free memory blocks procedure Defrag; -- Give the size of an allocated memory -- @param data pointer to an allocated memory -- @return the size of data memory in bytes function Get_Size (Addr : System.Address) return Uint32_T; type Monitor_T is record Total_Size : Uint32_T; Free_Cnt : Uint32_T; Free_Size : Uint32_T; Free_Biggest_Size : Uint32_T; Used_Pct : Uint8_T; Frag_Pct : Uint8_T; end record; pragma Convention (C_Pass_By_Copy, Monitor_T); -- Give information about the work memory of dynamic allocation -- @param mon_p pointer to a dm_mon_p variable, -- the result of the analysis will be stored here procedure Monitor (Mon : not null access Monitor_T); ------------- -- Imports -- ------------- pragma Import (C, Alloc, "lv_mem_alloc"); pragma Import (C, Free, "lv_mem_free"); pragma Import (C, Realloc, "lv_mem_realloc"); pragma Import (C, Defrag, "lv_mem_defrag"); pragma Import (C, Get_Size, "lv_mem_get_size"); pragma Import (C, Monitor, "lv_mem_monitor"); end Lv.Mem;
stcarrez/atlas
Ada
4,179
adb
----------------------------------------------------------------------- -- atlas-reviews-modules -- Module reviews -- Copyright (C) 2014 Stephane.Carrez -- Written by Stephane.Carrez ([email protected]) -- -- Licensed under the Apache License, Version 2.0 (the "License"); -- you may not use this file except in compliance with the License. -- You may obtain a copy of the License at -- -- http://www.apache.org/licenses/LICENSE-2.0 -- -- Unless required by applicable law or agreed to in writing, software -- distributed under the License is distributed on an "AS IS" BASIS, -- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -- See the License for the specific language governing permissions and -- limitations under the License. ----------------------------------------------------------------------- with Ada.Calendar; with AWA.Modules.Beans; with AWA.Modules.Get; with Util.Log.Loggers; with Atlas.Reviews.Beans; with ADO.Sessions; with AWA.Services.Contexts; with AWA.Permissions; package body Atlas.Reviews.Modules is package ASC renames AWA.Services.Contexts; Log : constant Util.Log.Loggers.Logger := Util.Log.Loggers.Create ("Atlas.Reviews.Module"); package Register is new AWA.Modules.Beans (Module => Review_Module, Module_Access => Review_Module_Access); -- ------------------------------ -- Initialize the reviews module. -- ------------------------------ overriding procedure Initialize (Plugin : in out Review_Module; App : in AWA.Modules.Application_Access; Props : in ASF.Applications.Config) is begin Log.Info ("Initializing the reviews module"); -- Register here any bean class, servlet, filter. Register.Register (Plugin => Plugin, Name => "Atlas.Reviews.Beans.Reviews_Bean", Handler => Atlas.Reviews.Beans.Create_Review_Bean'Access); Register.Register (Plugin => Plugin, Name => "Atlas.Reviews.Beans.Review_List_Bean", Handler => Atlas.Reviews.Beans.Create_Review_List_Bean'Access); AWA.Modules.Module (Plugin).Initialize (App, Props); -- Add here the creation of manager instances. end Initialize; -- ------------------------------ -- Get the reviews module. -- ------------------------------ function Get_Review_Module return Review_Module_Access is function Get is new AWA.Modules.Get (Review_Module, Review_Module_Access, NAME); begin return Get; end Get_Review_Module; -- ------------------------------ -- Save the review. -- ------------------------------ procedure Save (Model : in Review_Module; Entity : in out Atlas.Reviews.Models.Review_Ref'Class) is pragma Unreferenced (Model); Ctx : constant ASC.Service_Context_Access := ASC.Current; DB : ADO.Sessions.Master_Session := AWA.Services.Contexts.Get_Master_Session (Ctx); begin Ctx.Start; if not Entity.Is_Inserted then AWA.Permissions.Check (Permission => ACL_Create_Reviews.Permission); Entity.Set_Reviewer (Ctx.Get_User); Entity.Set_Create_Date (Ada.Calendar.Clock); else AWA.Permissions.Check (Permission => ACL_Update_Reviews.Permission, Entity => Entity); end if; Entity.Save (DB); Ctx.Commit; end Save; -- ------------------------------ -- Delete the review. -- ------------------------------ procedure Delete (Model : in Review_Module; Entity : in out Atlas.Reviews.Models.Review_Ref'Class) is pragma Unreferenced (Model); Ctx : constant ASC.Service_Context_Access := ASC.Current; DB : ADO.Sessions.Master_Session := ASC.Get_Master_Session (Ctx); begin AWA.Permissions.Check (Permission => ACL_Delete_Reviews.Permission, Entity => Entity); Ctx.Start; Entity.Delete (DB); Ctx.Commit; end Delete; end Atlas.Reviews.Modules;
reznikmm/matreshka
Ada
6,829
adb
------------------------------------------------------------------------------ -- -- -- Matreshka Project -- -- -- -- Ada Modeling Framework -- -- -- -- Runtime Library Component -- -- -- ------------------------------------------------------------------------------ -- -- -- Copyright © 2011-2012, Vadim Godunko <[email protected]> -- -- All rights reserved. -- -- -- -- Redistribution and use in source and binary forms, with or without -- -- modification, are permitted provided that the following conditions -- -- are met: -- -- -- -- * Redistributions of source code must retain the above copyright -- -- notice, this list of conditions and the following disclaimer. -- -- -- -- * Redistributions in binary form must reproduce the above copyright -- -- notice, this list of conditions and the following disclaimer in the -- -- documentation and/or other materials provided with the distribution. -- -- -- -- * Neither the name of the Vadim Godunko, IE nor the names of its -- -- contributors may be used to endorse or promote products derived from -- -- this software without specific prior written permission. -- -- -- -- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -- -- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -- -- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -- -- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -- -- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -- -- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED -- -- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -- -- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -- -- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -- -- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -- -- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- -- -- ------------------------------------------------------------------------------ -- $Revision$ $Date$ ------------------------------------------------------------------------------ -- This file is generated, don't edit it. ------------------------------------------------------------------------------ with AMF.Elements; with AMF.Internals.Helpers; with AMF.Internals.Tables.UML_Attributes; with AMF.UML.Classes; with AMF.Visitors.Standard_Profile_L2_Iterators; with AMF.Visitors.Standard_Profile_L2_Visitors; package body AMF.Internals.Standard_Profile_L2_Metaclasses is -------------------- -- Get_Base_Class -- -------------------- overriding function Get_Base_Class (Self : not null access constant Standard_Profile_L2_Metaclass_Proxy) return AMF.UML.Classes.UML_Class_Access is begin return AMF.UML.Classes.UML_Class_Access (AMF.Internals.Helpers.To_Element (AMF.Internals.Tables.UML_Attributes.Internal_Get_Base_Class (Self.Element))); end Get_Base_Class; -------------------- -- Set_Base_Class -- -------------------- overriding procedure Set_Base_Class (Self : not null access Standard_Profile_L2_Metaclass_Proxy; To : AMF.UML.Classes.UML_Class_Access) is begin AMF.Internals.Tables.UML_Attributes.Internal_Set_Base_Class (Self.Element, AMF.Internals.Helpers.To_Element (AMF.Elements.Element_Access (To))); end Set_Base_Class; ------------------- -- Enter_Element -- ------------------- overriding procedure Enter_Element (Self : not null access constant Standard_Profile_L2_Metaclass_Proxy; Visitor : in out AMF.Visitors.Abstract_Visitor'Class; Control : in out AMF.Visitors.Traverse_Control) is begin if Visitor in AMF.Visitors.Standard_Profile_L2_Visitors.Standard_Profile_L2_Visitor'Class then AMF.Visitors.Standard_Profile_L2_Visitors.Standard_Profile_L2_Visitor'Class (Visitor).Enter_Metaclass (AMF.Standard_Profile_L2.Metaclasses.Standard_Profile_L2_Metaclass_Access (Self), Control); end if; end Enter_Element; ------------------- -- Leave_Element -- ------------------- overriding procedure Leave_Element (Self : not null access constant Standard_Profile_L2_Metaclass_Proxy; Visitor : in out AMF.Visitors.Abstract_Visitor'Class; Control : in out AMF.Visitors.Traverse_Control) is begin if Visitor in AMF.Visitors.Standard_Profile_L2_Visitors.Standard_Profile_L2_Visitor'Class then AMF.Visitors.Standard_Profile_L2_Visitors.Standard_Profile_L2_Visitor'Class (Visitor).Leave_Metaclass (AMF.Standard_Profile_L2.Metaclasses.Standard_Profile_L2_Metaclass_Access (Self), Control); end if; end Leave_Element; ------------------- -- Visit_Element -- ------------------- overriding procedure Visit_Element (Self : not null access constant Standard_Profile_L2_Metaclass_Proxy; Iterator : in out AMF.Visitors.Abstract_Iterator'Class; Visitor : in out AMF.Visitors.Abstract_Visitor'Class; Control : in out AMF.Visitors.Traverse_Control) is begin if Iterator in AMF.Visitors.Standard_Profile_L2_Iterators.Standard_Profile_L2_Iterator'Class then AMF.Visitors.Standard_Profile_L2_Iterators.Standard_Profile_L2_Iterator'Class (Iterator).Visit_Metaclass (Visitor, AMF.Standard_Profile_L2.Metaclasses.Standard_Profile_L2_Metaclass_Access (Self), Control); end if; end Visit_Element; end AMF.Internals.Standard_Profile_L2_Metaclasses;
mitchelhaan/ncurses
Ada
4,129
adb
------------------------------------------------------------------------------ -- -- -- GNAT ncurses Binding -- -- -- -- Terminal_Interface.Curses.Panels.User_Data -- -- -- -- B O D Y -- -- -- ------------------------------------------------------------------------------ -- 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.7 $ -- Binding Version 00.93 ------------------------------------------------------------------------------ with Interfaces.C; with Terminal_Interface.Curses.Aux; use Terminal_Interface.Curses.Aux; with Terminal_Interface.Curses.Panels; use Terminal_Interface.Curses.Panels; package body Terminal_Interface.Curses.Panels.User_Data is use type Interfaces.C.int; procedure Set_User_Data (Pan : in Panel; Data : in User_Access) is function Set_Panel_Userptr (Pan : Panel; Addr : User_Access) return C_Int; pragma Import (C, Set_Panel_Userptr, "set_panel_userptr"); begin if Set_Panel_Userptr (Pan, Data) = Curses_Err then raise Panel_Exception; end if; end Set_User_Data; function Get_User_Data (Pan : in Panel) return User_Access is function Panel_Userptr (Pan : Panel) return User_Access; pragma Import (C, Panel_Userptr, "panel_userptr"); begin return Panel_Userptr (Pan); end Get_User_Data; procedure Get_User_Data (Pan : in Panel; Data : out User_Access) is begin Data := Get_User_Data (Pan); end Get_User_Data; end Terminal_Interface.Curses.Panels.User_Data;
zhmu/ananas
Ada
123
ads
PACKAGE Entry1 IS FUNCTION pt (t : IN Float) RETURN Natural; FUNCTION pt2 (t : IN Float) RETURN Natural; END Entry1;
jscparker/math_packages
Ada
4,147
ads
----------------------------------------------------------------------- -- package body Crout_LU, LU decomposition, with equation solving -- Copyright (C) 2008-2018 Jonathan S. Parker. -- -- Permission to use, copy, modify, and/or distribute this software for any -- purpose with or without fee is hereby granted, provided that the above -- copyright notice and this permission notice appear in all copies. -- THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES -- WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF -- MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR -- ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES -- WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN -- ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF -- OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. ----------------------------------------------------------------------- -- PACKAGE runge_pc_2 -- -- Exclusively for initializing Predictor-Corrector arrays. -- -- The 8th order Runge Kutta formula of Prince and Dormand -- (Journal of Computational and Applied Math. -- vol. 7, p. 67 (1981)). -- -- The program integrates (d/dt)**2 Y = F (t, Y) where t is the -- independent variable (e.g. time), vector Y is the -- dependent variable, and F is some function. generic type Real is digits <>; -- The independent variable. It's called Time -- throughout the package as though the differential -- equation dY/dt = F (t, Y) were time dependent. Of cource -- it can have any meaning. type Dyn_Index is range <>; type Dynamical_Variable is array(Dyn_Index) of Real; -- The dependent variable. -- We require its exact form here so that some inner loop -- optimizations can be performed below. -- A two dimension array makes this package useful -- for a very wide range of problems. If your Dynamical -- variable is really just a one-dimensional array, then you can still -- use it here (and with almost no loss in performance.) -- Just give the Dyn_Index a range 0..0. ( It's best to do -- this to the Vector_Range_1 rather than Vector_Range_2.) -- -- To use this routine one must reduce higher order differential -- Equations to 1st order. -- For example a 3rd order equation in X becomes a first order -- equation in the vector Y = (X, dX/dt, d/dt(dX/dt)). with function F (Time : Real; Y : Dynamical_Variable) return Dynamical_Variable is <>; -- Defines the equation to be integrated as -- dY/dt = F (t, Y). Even if the equation is t or Y -- independent, it must be entered in this form. with function "*" (Left : Real; Right : Dynamical_Variable) return Dynamical_Variable is <>; -- Defines multiplication of the independent by the -- dependent variable. An operation of this sort must exist by -- definition of the derivative, dY/dt = (Y(t+dt) - Y(t)) / dt, -- which requires multiplication of the (inverse) independent -- variable t, by the Dynamical variable Y (the dependent variable). with function "+" (Left : Dynamical_Variable; Right : Dynamical_Variable) return Dynamical_Variable is <>; -- Defines summation of the dependent variable. Again, this -- operation must exist by the definition of the derivative, -- dY/dt = (Y(t+dt) - Y(t)) / dt = (Y(t+dt) + (-1)*Y(t)) / dt. with function "-" (Left : Dynamical_Variable; Right : Dynamical_Variable) return Dynamical_Variable is <>; -- operation must exist by the definition of the derivative, -- dY/dt = (Y(t+dt) - Y(t)) / dt package runge_pc_2 is procedure Integrate (Final_Y : out Dynamical_Variable; Final_deriv_Of_Y : out Dynamical_Variable; Final_Time : in Real; Initial_Y : in Dynamical_Variable; Initial_deriv_Of_Y : in Dynamical_Variable; Initial_Time : in Real; No_Of_Steps : in Real); end runge_pc_2;
reznikmm/matreshka
Ada
9,833
adb
------------------------------------------------------------------------------ -- -- -- Matreshka Project -- -- -- -- Web Framework -- -- -- -- Runtime Library Component -- -- -- ------------------------------------------------------------------------------ -- -- -- Copyright © 2015, Vadim Godunko <[email protected]> -- -- All rights reserved. -- -- -- -- Redistribution and use in source and binary forms, with or without -- -- modification, are permitted provided that the following conditions -- -- are met: -- -- -- -- * Redistributions of source code must retain the above copyright -- -- notice, this list of conditions and the following disclaimer. -- -- -- -- * Redistributions in binary form must reproduce the above copyright -- -- notice, this list of conditions and the following disclaimer in the -- -- documentation and/or other materials provided with the distribution. -- -- -- -- * Neither the name of the Vadim Godunko, IE nor the names of its -- -- contributors may be used to endorse or promote products derived from -- -- this software without specific prior written permission. -- -- -- -- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -- -- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -- -- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -- -- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -- -- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -- -- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED -- -- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -- -- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -- -- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -- -- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -- -- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- -- -- ------------------------------------------------------------------------------ -- $Revision$ $Date$ ------------------------------------------------------------------------------ with Ada.Unchecked_Deallocation; with League.Holders; with League.Holders.Integers; with SQL.Queries; with OPM.Engines; with Forum.Categories.Category_Identifier_Holders; with Forum.Categories.References; with Forum.Topics.References; with Forum.Topics.Objects.Stores; package body Forum.Categories.Objects.Stores is procedure Free is new Ada.Unchecked_Deallocation (Category_Object'Class, Category_Access); function Get_Topic_Store is new OPM.Engines.Generic_Get_Store (Object => Standard.Forum.Topics.Objects.Topic_Object, Store => Standard.Forum.Topics.Objects.Stores.Topic_Store); ------------ -- Create -- ------------ not overriding function Create (Self : in out Category_Store; Title : League.Strings.Universal_String; Description : League.Strings.Universal_String) return Forum.Categories.References.Category is Q : SQL.Queries.SQL_Query := Self.Engine.Get_Database.Query (League.Strings.To_Universal_String ("INSERT INTO categories (title, description)" & " VALUES (:title, :description)" & " RETURNING category_identifier")); R : Forum.Categories.References.Category; begin Q.Bind_Value (League.Strings.To_Universal_String (":title"), League.Holders.To_Holder (Title)); Q.Bind_Value (League.Strings.To_Universal_String (":description"), League.Holders.To_Holder (Description)); Q.Execute; if Q.Next then R.Initialize (Self'Unchecked_Access, Forum.Categories.Category_Identifier_Holders.Element (Q.Value (1))); end if; return R; end Create; --------- -- Get -- --------- not overriding function Get (Self : in out Category_Store; Identifier : Category_Identifier) return Category_Access is Q : SQL.Queries.SQL_Query := Self.Engine.Get_Database.Query (League.Strings.To_Universal_String ("SELECT title, description, topic_count FROM categories c," & " (select count(*) topic_count FROM topics t" & " WHERE t.category_identifier = :category_identifier) s" & " WHERE category_identifier = :category_identifier")); begin Q.Bind_Value (League.Strings.To_Universal_String (":category_identifier"), Category_Identifier_Holders.To_Holder (Identifier)); Q.Execute; if not Q.Next then return null; else return new Category_Object' (Store => Self'Unchecked_Access, Identifier => Identifier, Title => League.Holders.Element (Q.Value (1)), Description => League.Holders.Element (Q.Value (2)), Topic_Count => Natural'Wide_Wide_Value -- FIXME after #425 (League.Holders.Element (Q.Value (3)).To_Wide_Wide_String)); end if; end Get; ---------------- -- Initialize -- ---------------- overriding procedure Initialize (Self : in out Category_Store) is begin Self.Engine.Register_Store (Forum.Categories.Objects.Category_Object'Tag, Self'Unchecked_Access); end Initialize; --------------------- -- Get_Topic_Count -- --------------------- function Get_Topic_Count (Self : in out Category_Store; Identifier : Category_Identifier) return Natural is Q : SQL.Queries.SQL_Query := Self.Engine.Get_Database.Query (League.Strings.To_Universal_String ("SELECT count(*) FROM topics" & " WHERE category_identifier = :category_identifier")); Result : League.Holders.Universal_Integer; begin Q.Bind_Value (League.Strings.To_Universal_String (":category_identifier"), Category_Identifier_Holders.To_Holder (Identifier)); Q.Execute; if not Q.Next then Result := 0; else -- FIXME after #425 -- Result := League.Holders.Element (Q.Value (1)); Result := League.Holders.Universal_Integer'Wide_Wide_Value (League.Strings.To_Wide_Wide_String (League.Holders.Element (Q.Value (1)))); end if; return Natural (Result); end Get_Topic_Count; ---------------- -- Get_Topics -- ---------------- function Get_Topics (Self : in out Category_Store; Identifier : Category_Identifier; From : Positive; To : Positive) return Forum.Topics.References.Topic_Vector is Q : SQL.Queries.SQL_Query := Self.Engine.Get_Database.Query (League.Strings.To_Universal_String ("SELECT t.topic_identifier FROM topics t LEFT JOIN posts p" & " ON t.topic_identifier = p.topic_identifier" & " WHERE category_identifier = :category_identifier" & " GROUP BY t.topic_identifier" & " ORDER BY max (p.creation_time) DESC" & " LIMIT :limit OFFSET :offset")); Result : Forum.Topics.References.Topic_Vector; Limit : Positive := To - From + 1; Offset : Natural := From - 1; begin Q.Bind_Value (League.Strings.To_Universal_String (":category_identifier"), Category_Identifier_Holders.To_Holder (Identifier)); Q.Bind_Value (League.Strings.To_Universal_String (":limit"), League.Holders.Integers.To_Holder (Limit)); Q.Bind_Value (League.Strings.To_Universal_String (":offset"), League.Holders.Integers.To_Holder (Offset)); Q.Execute; for J in From .. To loop if Q.Next then declare Ref : Forum.Topics.References.Topic; begin Ref.Initialize (Get_Topic_Store (Self.Engine.all), Topics.Topic_Identifier_Holders.Element (Q.Value (1))); Result.Append (Ref); end; end if; end loop; return Result; end Get_Topics; ------------- -- Release -- ------------- not overriding procedure Release (Self : in out Category_Store; Object : not null Category_Access) is Aux : Category_Access; begin if Object /= null then Aux := Object; Free (Aux); end if; end Release; end Forum.Categories.Objects.Stores;
onox/orka
Ada
1,858
adb
-- SPDX-License-Identifier: Apache-2.0 -- -- Copyright (c) 2017 onox <[email protected]> -- -- Licensed under the Apache License, Version 2.0 (the "License"); -- you may not use this file except in compliance with the License. -- You may obtain a copy of the License at -- -- http://www.apache.org/licenses/LICENSE-2.0 -- -- Unless required by applicable law or agreed to in writing, software -- distributed under the License is distributed on an "AS IS" BASIS, -- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -- See the License for the specific language governing permissions and -- limitations under the License. with Orka.Transforms.Doubles.Matrix_Conversions; package body Orka.Cameras.Look_At_Cameras is overriding procedure Look_At (Object : in out Look_At_Camera; Target : Behaviors.Behavior_Ptr) is begin Object.Target := Target; end Look_At; -- Look_At camera does not need to implement Update because the -- view matrix does not depend on the pointer (it is computed using -- the camera's and target's positions) use Orka.Transforms.Doubles.Matrix_Conversions; overriding function View_Matrix (Object : Look_At_Camera) return Transforms.Matrix4 is (Convert (Look_At (Object.Target.Position, Object.Position, Object.Up))); overriding function View_Matrix_Inverse (Object : Look_At_Camera) return Transforms.Matrix4 is use Transforms; begin return Transpose (Object.View_Matrix); end View_Matrix_Inverse; overriding function Target_Position (Object : Look_At_Camera) return Vector4 is (Object.Target.Position); overriding function Create_Camera (Lens : Camera_Lens) return Look_At_Camera is begin return (Lens => Lens, others => <>); end Create_Camera; end Orka.Cameras.Look_At_Cameras;
AdaCore/libadalang
Ada
145
adb
separate (B.C) package body D is procedure Bar is A : Pouet := A2; pragma Test_Statement; begin null; end Bar; end D;
AdaCore/libadalang
Ada
225
ads
package Main_Package is procedure Bar (A : Integer := 1); pragma Find_All_References (Any, "Bar", Follow_Renamings => True); procedure Baz (A : Integer); procedure Foo (A : Integer) renames Bar; end Main_Package;
AdaCore/libadalang
Ada
174
adb
procedure Test is package Foo is I : Integer := 0; procedure Bar; end Foo; J : Integer := 0; package body Foo is separate; begin null; end Test;
tum-ei-rcs/StratoX
Ada
3,107
ads
------------------------------------------------------------------------------ -- -- -- GNAT RUN-TIME LIBRARY (GNARL) COMPONENTS -- -- -- -- S Y S T E M . M U L T I P R O C E S S O R S . S P I N _ L O C K S -- -- -- -- S p e c -- -- -- -- Copyright (C) 2010-2016, AdaCore -- -- -- -- GNARL is free software; you can redistribute it and/or modify it under -- -- terms of the GNU General Public License as published by the Free Soft- -- -- ware Foundation; either version 3, or (at your option) any later ver- -- -- sion. GNARL is distributed in the hope that it will be useful, but WITH- -- -- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY -- -- or FITNESS FOR A PARTICULAR PURPOSE. -- -- -- -- -- -- -- -- -- -- -- -- You should have received a copy of the GNU General Public License and -- -- a copy of the GCC Runtime Library Exception along with this program; -- -- see the files COPYING3 and COPYING.RUNTIME respectively. If not, see -- -- <http://www.gnu.org/licenses/>. -- -- -- ------------------------------------------------------------------------------ package System.Multiprocessors.Spin_Locks is pragma Preelaborate; --------------- -- Spin lock -- --------------- type Atomic_Flag is mod 2**8; pragma Atomic (Atomic_Flag); Unlocked : constant Atomic_Flag := 0; type Spin_Lock is limited record Flag : aliased Atomic_Flag := Unlocked; end record; -- The default value of a Spin_Lock is unlocked procedure Lock (Slock : in out Spin_Lock); pragma Inline (Lock); -- Loop until lock is acquired function Locked (Slock : Spin_Lock) return Boolean; pragma Inline (Locked); -- Return the current state of the lock procedure Try_Lock (Slock : in out Spin_Lock; Succeeded : out Boolean); pragma Inline (Try_Lock); -- Return True if the lock has been acquired, otherwise don't wait for the -- lock and return False. procedure Unlock (Slock : in out Spin_Lock); pragma Inline (Unlock); -- Release the lock end System.Multiprocessors.Spin_Locks;
reznikmm/matreshka
Ada
3,674
ads
------------------------------------------------------------------------------ -- -- -- Matreshka Project -- -- -- -- Open Document Toolkit -- -- -- -- Runtime Library Component -- -- -- ------------------------------------------------------------------------------ -- -- -- Copyright © 2014, Vadim Godunko <[email protected]> -- -- All rights reserved. -- -- -- -- Redistribution and use in source and binary forms, with or without -- -- modification, are permitted provided that the following conditions -- -- are met: -- -- -- -- * Redistributions of source code must retain the above copyright -- -- notice, this list of conditions and the following disclaimer. -- -- -- -- * Redistributions in binary form must reproduce the above copyright -- -- notice, this list of conditions and the following disclaimer in the -- -- documentation and/or other materials provided with the distribution. -- -- -- -- * Neither the name of the Vadim Godunko, IE nor the names of its -- -- contributors may be used to endorse or promote products derived from -- -- this software without specific prior written permission. -- -- -- -- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -- -- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -- -- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -- -- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -- -- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -- -- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED -- -- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -- -- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -- -- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -- -- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -- -- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- -- -- ------------------------------------------------------------------------------ -- $Revision$ $Date$ ------------------------------------------------------------------------------ with XML.DOM.Elements; package ODF.DOM.Table_Insertion_Elements is pragma Preelaborate; type ODF_Table_Insertion is limited interface and XML.DOM.Elements.DOM_Element; type ODF_Table_Insertion_Access is access all ODF_Table_Insertion'Class with Storage_Size => 0; end ODF.DOM.Table_Insertion_Elements;
riccardo-bernardini/eugen
Ada
6,931
ads
with EU_Projects.Nodes.Timed_Nodes; with EU_Projects.Nodes.Action_Nodes.Tasks; with EU_Projects.Node_Tables; package EU_Projects.Nodes.Timed_Nodes.Deliverables is subtype Deliverable_Index is Node_Index; No_Deliverable : constant Extended_Node_Index := No_Index; type Deliverable_Label is new Node_Label; type Deliverable is new Nodes.Timed_Nodes.Timed_Node with private; type Deliverable_Access is access all Deliverable; type Deliverable_Type is (Report, Demo, Dissemination, Other); type Dissemination_Level is (Public, Confidential, Classified); type Deliverable_Status is (Parent, Clone, Stand_Alone); overriding function Dependency_Ready_Var (Item : Deliverable) return String is ("end"); function Status (Item : Deliverable) return Deliverable_Status; function Create (Label : Deliverable_Label; Name : String; Description : String; Short_Name : String; Delivered_By : Node_Label_Lists.Vector; Due_On : String; Node_Dir : in out Node_Tables.Node_Table; Parent_WP : Node_Access; Linked_Milestones : Nodes.Node_Label_Lists.Vector; Deliv_Type : Deliverable_Type; Dissemination : Dissemination_Level) return Deliverable_Access with Post => Create'Result.Status = Stand_Alone; overriding function Variables (Item : Deliverable) return Variable_List is ((if Item.Status = Parent then Empty_List else (1 => Event_Names.Event_Time_Name))); overriding function Is_Variable (Item : Deliverable; Var : Simple_Identifier) return Boolean is (if Item.Status = Parent then False else Var = Event_Names.Event_Time_Name); procedure Clone (Item : in out Deliverable; Due_On : in String; Node_Dir : in out Node_Tables.Node_Table) with Pre => not Item.Is_Clone and Item.Index = No_Deliverable, Post => Item.Status = Parent and Item.Max_Clone = Item.Max_Clone'Old + (if Item.Status'Old = Stand_Alone then 2 else 1); function Clone_Sub_Label (Item : Deliverable) return String; function Clone (Item : Deliverable; Idx : Positive) return Deliverable_Access; function Is_Clone (Item : Deliverable) return Boolean is (Item.Status = Clone); overriding function Due_On (Item : Deliverable) return Times.Instant with Pre => Item.Time_Fixed and Item.Status /= Parent; use type Times.Instant; package Instant_Vectors is new Ada.Containers.Vectors (Index_Type => Positive, Element_Type => Times.Instant); function Due_On (Item : Deliverable; Sorted : Boolean := True) return Instant_Vectors.Vector; function Image (Item : Instant_Vectors.Vector; Separator : String := ", ") return String; procedure Set_Index (Item : in out Deliverable; Idx : Deliverable_Index) with Pre => Item.Index = No_Deliverable; overriding function Full_Index (Item : Deliverable; Prefixed : Boolean) return String; function Max_Clone (Item : Deliverable) return Natural; function Delivered_By (Item : Deliverable) return Nodes.Node_Label_Lists.Vector; function Dependency_List (Item : Deliverable) return Node_Label_Lists.Vector is (Item.Delivered_By); function Linked_Milestones (Item : Deliverable) return Nodes.Node_Label_Lists.Vector; function Parent_Wp (Item : Deliverable) return Node_Access; function Nature (Item : Deliverable) return Deliverable_Type; function Dissemination (Item : Deliverable) return Dissemination_Level; private -- use Tasks; -- -- package Task_Lists is -- new Ada.Containers.Vectors (Index_Type => Positive, -- Element_Type => Project_Task_Access); subtype Clone_Index_Type is Integer range 0 .. Character'Pos ('z')-Character'Pos ('a'); No_Clone : constant Clone_Index_Type := 0; package Deliverable_Arrays is new Ada.Containers.Vectors (Index_Type => Positive, Element_Type => Deliverable_Access); type Deliverable is new Nodes.Timed_Nodes.Timed_Node with record Deliverer : Node_Label_Lists.Vector; Linked_Milestones : Nodes.Node_Label_Lists.Vector; Parent_WP : Node_Access; Deliv_Type : Deliverable_Type; Dissemination : Dissemination_Level; Status : Deliverable_Status; Clone_List : Deliverable_Arrays.Vector; Clone_Index : Clone_Index_Type; end record with Dynamic_Predicate => (if Deliverable.Status /= Parent then Deliverable.Clone_List.Is_Empty else (for all X of Deliverable.Clone_List => X.Status = Clone)); function Status (Item : Deliverable) return Deliverable_Status is (Item.Status); function Clone (Item : Deliverable; Idx : Positive) return Deliverable_Access is (Item.Clone_List (Idx)); function Max_Clone (Item : Deliverable) return Natural is (if Item.Clone_List.Is_Empty then 0 else Item.Clone_List.Last_Index); function Delivered_By (Item : Deliverable) return Nodes.Node_Label_Lists.Vector is (Item.Deliverer); function Parent_Wp (Item : Deliverable) return Node_Access is (Item.Parent_Wp); function Clone_Sub_Label (Item : Deliverable) return String is (if Item.Status = Clone then "." & Character'Val (Character'Pos ('a')-1 + Item.Clone_Index) else ""); overriding function Full_Index (Item : Deliverable; Prefixed : Boolean) return String is ((if Prefixed then "D" else "") & Chop (Node_Index'Image (Item.Parent_WP.Index)) & "." & Chop (Node_Index'Image (Item.Index)) & Item.Clone_Sub_Label); function Linked_Milestones (Item : Deliverable) return Nodes.Node_Label_Lists.Vector is (Item.Linked_Milestones); function Nature (Item : Deliverable) return Deliverable_Type is (Item.Deliv_Type); function Dissemination (Item : Deliverable) return Dissemination_Level is (Item.Dissemination); -- function Index (Item : Deliverable) return Deliverable_Index -- is (Deliverable_Index (Item.Index)); end EU_Projects.Nodes.Timed_Nodes.Deliverables;
albinjal/ada_basic
Ada
805
adb
with Ada.Text_IO; use Ada.Text_IO; with Ada.Integer_Text_IO; use Ada.Integer_Text_IO; with Ada.Float_Text_IO; use Ada.Float_Text_IO; procedure In_Och_Utmatningar is I: Integer; F: Float; C: Character; S: String(1..6); begin Put("Skriv in en sträng med 3 tecken: "); Get_Line(S, I); Put(S(1..3)); New_Line(1); Put("Skriv in ett heltal och en sträng med 5 tecken: "); Get(I); Put("Du skrev in talet |"); Put(I,1); Put("| och strängen |"); Get_Line(S, I); Put(S(2..6)); Put("|."); New_Line(1); Put("Skriv in en sträng med 3 tecken och ett flyttal: "); --Skip_Line; Get_Line(S, I); --Get(F); Put_Line(S); --Put("Du skrev in """); Put(F, 3, 3, 0); Put(""" "); Put(S); end In_Och_Utmatningar;
jwarwick/aoc_2020
Ada
2,261
adb
-- AoC 2020, Day 3 with Ada.Text_IO; package body Day is package TIO renames Ada.Text_IO; function "<"(left, right : in Position) return Boolean is begin if left.y < right.y then return true; elsif left.y = right.y and left.x < right.x then return true; else return false; end if; end "<"; procedure parse_line(line : in String; y : in Natural; trees : in out Tree_Sets.Set) is x : Natural := 0; begin for c of line loop if c = '#' then trees.insert(Position'(X => x, Y => y)); end if; x := x + 1; end loop; end parse_line; function load_map(filename : in String) return Forest is file : TIO.File_Type; trees : Tree_Sets.Set; height : Natural := 0; width : Natural := 0; begin TIO.open(File => file, Mode => TIO.In_File, Name => filename); while not TIO.end_of_file(file) loop declare l : constant String := TIO.get_line(file); begin parse_line(l, height, trees); width := l'Length; end; height := height + 1; end loop; TIO.close(file); return Forest'(Trees => trees, Width => width, Height => height); end load_map; function hit_tree(pos : in Position; trees : in Tree_Sets.Set) return Boolean is begin return trees.contains(pos); end hit_tree; function trees_hit_slope(f : in Forest; slope_x : in Natural; slope_y : in Natural) return Natural is x : Natural := 0; y : Natural := 0; hits : Natural := 0; begin while y < f.height loop if hit_tree(Position'(X => x, Y => y), f.trees) then hits := hits + 1; end if; x := (x + slope_x) mod f.width; y := y + slope_y; end loop; return hits; end trees_hit_slope; function trees_hit(f : in Forest; slope : in Natural) return Natural is begin return trees_hit_slope(f, slope, 1); end trees_hit; function many_trees_hit(f : in Forest) return Natural is mult : Natural := 1; begin mult := trees_hit_slope(f, 1, 1); mult := mult * trees_hit_slope(f, 3, 1); mult := mult * trees_hit_slope(f, 5, 1); mult := mult * trees_hit_slope(f, 7, 1); mult := mult * trees_hit_slope(f, 1, 2); return mult; end many_trees_hit; end Day;
onox/orka
Ada
910
ads
-- SPDX-License-Identifier: Apache-2.0 -- -- Copyright (c) 2020 onox <[email protected]> -- -- Licensed under the Apache License, Version 2.0 (the "License"); -- you may not use this file except in compliance with the License. -- You may obtain a copy of the License at -- -- http://www.apache.org/licenses/LICENSE-2.0 -- -- Unless required by applicable law or agreed to in writing, software -- distributed under the License is distributed on an "AS IS" BASIS, -- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -- See the License for the specific language governing permissions and -- limitations under the License. with AUnit.Test_Suites; package Test_SIMD_FMA_Doubles_Arithmetic is Test_Suite : aliased AUnit.Test_Suites.Test_Suite; function Suite return AUnit.Test_Suites.Access_Test_Suite is (Test_Suite'Access); end Test_SIMD_FMA_Doubles_Arithmetic;
reznikmm/matreshka
Ada
3,786
ads
------------------------------------------------------------------------------ -- -- -- Matreshka Project -- -- -- -- Ada Modeling Framework -- -- -- -- Runtime Library Component -- -- -- ------------------------------------------------------------------------------ -- -- -- Copyright © 2012-2013, Vadim Godunko <[email protected]> -- -- All rights reserved. -- -- -- -- Redistribution and use in source and binary forms, with or without -- -- modification, are permitted provided that the following conditions -- -- are met: -- -- -- -- * Redistributions of source code must retain the above copyright -- -- notice, this list of conditions and the following disclaimer. -- -- -- -- * Redistributions in binary form must reproduce the above copyright -- -- notice, this list of conditions and the following disclaimer in the -- -- documentation and/or other materials provided with the distribution. -- -- -- -- * Neither the name of the Vadim Godunko, IE nor the names of its -- -- contributors may be used to endorse or promote products derived from -- -- this software without specific prior written permission. -- -- -- -- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -- -- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -- -- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -- -- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -- -- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -- -- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED -- -- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -- -- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -- -- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -- -- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -- -- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- -- -- ------------------------------------------------------------------------------ -- $Revision$ $Date$ ------------------------------------------------------------------------------ -- This file is generated, don't edit it. ------------------------------------------------------------------------------ with AMF.OCL.Collection_Types; package AMF.OCL.Bag_Types is pragma Preelaborate; type OCL_Bag_Type is limited interface and AMF.OCL.Collection_Types.OCL_Collection_Type; type OCL_Bag_Type_Access is access all OCL_Bag_Type'Class; for OCL_Bag_Type_Access'Storage_Size use 0; end AMF.OCL.Bag_Types;
reznikmm/matreshka
Ada
3,704
ads
------------------------------------------------------------------------------ -- -- -- Matreshka Project -- -- -- -- Open Document Toolkit -- -- -- -- Runtime Library Component -- -- -- ------------------------------------------------------------------------------ -- -- -- Copyright © 2014, Vadim Godunko <[email protected]> -- -- All rights reserved. -- -- -- -- Redistribution and use in source and binary forms, with or without -- -- modification, are permitted provided that the following conditions -- -- are met: -- -- -- -- * Redistributions of source code must retain the above copyright -- -- notice, this list of conditions and the following disclaimer. -- -- -- -- * Redistributions in binary form must reproduce the above copyright -- -- notice, this list of conditions and the following disclaimer in the -- -- documentation and/or other materials provided with the distribution. -- -- -- -- * Neither the name of the Vadim Godunko, IE nor the names of its -- -- contributors may be used to endorse or promote products derived from -- -- this software without specific prior written permission. -- -- -- -- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -- -- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -- -- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -- -- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -- -- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -- -- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED -- -- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -- -- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -- -- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -- -- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -- -- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- -- -- ------------------------------------------------------------------------------ -- $Revision$ $Date$ ------------------------------------------------------------------------------ with XML.DOM.Attributes; package ODF.DOM.Db_Style_Name_Attributes is pragma Preelaborate; type ODF_Db_Style_Name_Attribute is limited interface and XML.DOM.Attributes.DOM_Attribute; type ODF_Db_Style_Name_Attribute_Access is access all ODF_Db_Style_Name_Attribute'Class with Storage_Size => 0; end ODF.DOM.Db_Style_Name_Attributes;
oresat/oresat-c3-rf
Ada
34,069
adb
M:main F:Fmain$pwrmgmt_irq$0$0({2}DF,SV:S),C,0,0,1,6,0 F:Fmain$correct_ber$0$0({2}DF,SV:S),C,0,0,0,0,0 F:Fmain$process_ber$0$0({2}DF,SV:S),C,0,0,0,0,0 F:Fmain$dump_pkt$0$0({2}DF,SV:S),C,0,0,0,0,0 F:Fmain$display_ber$0$0({2}DF,SV:S),C,0,0,0,0,0 F:G$axradio_statuschange$0$0({2}DF,SV:S),Z,0,0,0,0,0 F:G$set_cw$0$0({2}DF,SV:S),C,0,0,0,0,0 F:G$set_transmit$0$0({2}DF,SV:S),C,0,0,0,0,0 F:G$set_receiveber$0$0({2}DF,SV:S),C,0,0,0,0,0 F:G$enable_radio_interrupt_in_mcu_pin$0$0({2}DF,SV:S),Z,0,0,0,0,0 F:G$disable_radio_interrupt_in_mcu_pin$0$0({2}DF,SV:S),Z,0,0,0,0,0 F:G$_sdcc_external_startup$0$0({2}DF,SC:U),C,0,0,0,0,0 F:Fmain$si_write_reg$0$0({2}DF,SV:S),C,0,0,0,0,0 F:Fmain$synth_init$0$0({2}DF,SV:S),C,0,0,0,0,0 F:G$main$0$0({2}DF,SI:S),C,0,0,0,0,0 T:Fmain$wtimer_callback[({0}S:S$next$0$0({2}DX,STwtimer_callback:S),Z,0,0)({2}S:S$handler$0$0({2}DC,DF,SV:S),Z,0,0)] T:Fmain$axradio_status_receive[({0}S:S$phy$0$0({10}STaxradio_status_receive_phy:S),Z,0,0)({10}S:S$mac$0$0({12}STaxradio_status_receive_mac:S),Z,0,0)({22}S:S$pktdata$0$0({2}DX,SC:U),Z,0,0)({24}S:S$pktlen$0$0({2}SI:U),Z,0,0)] T:Fmain$axradio_address[({0}S:S$addr$0$0({5}DA5d,SC:U),Z,0,0)] T:Fmain$axradio_address_mask[({0}S:S$addr$0$0({5}DA5d,SC:U),Z,0,0)({5}S:S$mask$0$0({5}DA5d,SC:U),Z,0,0)] T:Fmain$__00000000[({0}S:S$rx$0$0({26}STaxradio_status_receive:S),Z,0,0)({0}S:S$cs$0$0({3}STaxradio_status_channelstate:S),Z,0,0)] T:Fmain$__00000001[({0}S:S$w$0$0({2}SI:U),Z,0,0)({0}S:S$l$0$0({4}SL:U),Z,0,0)({0}S:S$b$0$0({4}STu32endian:S),Z,0,0)] T:Fmain$axradio_status_channelstate[({0}S:S$rssi$0$0({2}SI:S),Z,0,0)({2}S:S$busy$0$0({1}SC:U),Z,0,0)] T:Fmain$u32endian[({0}S:S$b0$0$0({1}SC:U),Z,0,0)({1}S:S$b1$0$0({1}SC:U),Z,0,0)({2}S:S$b2$0$0({1}SC:U),Z,0,0)({3}S:S$b3$0$0({1}SC:U),Z,0,0)] T:Fmain$u16endian[({0}S:S$b0$0$0({1}SC:U),Z,0,0)({1}S:S$b1$0$0({1}SC:U),Z,0,0)] T:Fmain$wtimer_desc[({0}S:S$next$0$0({2}DX,STwtimer_desc:S),Z,0,0)({2}S:S$handler$0$0({2}DC,DF,SV:S),Z,0,0)({4}S:S$time$0$0({4}SL:U),Z,0,0)] T:Fmain$axradio_status_receive_mac[({0}S:S$remoteaddr$0$0({5}DA5d,SC:U),Z,0,0)({5}S:S$localaddr$0$0({5}DA5d,SC:U),Z,0,0)({10}S:S$raw$0$0({2}DX,SC:U),Z,0,0)] T:Fmain$calsector[({0}S:S$id$0$0({5}DA5d,SC:U),Z,0,0)({5}S:S$len$0$0({1}SC:U),Z,0,0)({6}S:S$devid$0$0({6}DA6d,SC:U),Z,0,0)({12}S:S$calg00gain$0$0({2}DA2d,SC:U),Z,0,0)({14}S:S$calg01gain$0$0({2}DA2d,SC:U),Z,0,0)({16}S:S$calg10gain$0$0({2}DA2d,SC:U),Z,0,0)({18}S:S$caltempgain$0$0({2}DA2d,SC:U),Z,0,0)({20}S:S$caltempoffs$0$0({2}DA2d,SC:U),Z,0,0)({22}S:S$frcoscfreq$0$0({2}DA2d,SC:U),Z,0,0)({24}S:S$lposcfreq$0$0({2}DA2d,SC:U),Z,0,0)({26}S:S$lposcfreq_fast$0$0({2}DA2d,SC:U),Z,0,0)({28}S:S$powctrl0$0$0({1}SC:U),Z,0,0)({29}S:S$powctrl1$0$0({1}SC:U),Z,0,0)({30}S:S$ref$0$0({1}SC:U),Z,0,0)] T:Fmain$axradio_status_receive_phy[({0}S:S$rssi$0$0({2}SI:S),Z,0,0)({2}S:S$offset$0$0({4}SL:S),Z,0,0)({6}S:S$timeoffset$0$0({2}SI:S),Z,0,0)({8}S:S$period$0$0({2}SI:S),Z,0,0)] T:Fmain$axradio_status[({0}S:S$status$0$0({1}SC:U),Z,0,0)({1}S:S$error$0$0({1}SC:U),Z,0,0)({2}S:S$time$0$0({4}SL:U),Z,0,0)({6}S:S$u$0$0({26}ST__00000000:S),Z,0,0)] S:G$random_seed$0$0({2}SI:U),E,0,0 S:G$_start__stack$0$0({0}DA0d,SC:U),E,0,0 S:G$coldstart$0$0({1}SC:U),E,0,0 S:G$BER_TEST$0$0({1}SC:U),E,0,0 S:G$scr$0$0({4}ST__00000001:S),E,0,0 S:G$bytes$0$0({4}SL:U),E,0,0 S:G$errors$0$0({4}SL:U),E,0,0 S:G$errors2$0$0({4}SL:U),E,0,0 S:G$acquire_agc$0$0({1}SC:U),E,0,0 S:Lmain.enter_critical$crit$1$29({1}SC:U),E,0,0 S:Lmain.exit_critical$crit$1$30({1}SC:U),E,0,0 S:Lmain.pwrmgmt_irq$pc$1$337({1}SC:U),R,0,0,[r7] S:Lmain.process_ber$st$1$342({2}DX,STaxradio_status:S),R,0,0,[r6,r7] S:Lmain.process_ber$fourfsk$1$343({1}SC:U),R,0,0,[r5] S:Lmain.process_ber$i$2$344({1}SC:U),R,0,0,[r3] S:Lmain.process_ber$p$3$346({2}DX,SC:U),R,0,0,[r6,r7] S:Lmain.process_ber$databyte$6$349({1}SC:U),E,0,0 S:Lmain.process_ber$databyte$5$350({1}SC:U),R,0,0,[r4] S:Lmain.process_ber$databyte$5$351({1}SC:U),R,0,0,[] S:Lmain.process_ber$databyte$5$352({1}SC:U),R,0,0,[] S:Lmain.process_ber$databyte$5$353({1}SC:U),R,0,0,[] S:Lmain.process_ber$sloc0$1$0({1}SC:U),E,0,0 S:Lmain.process_ber$sloc1$1$0({2}DX,SC:U),E,0,0 S:Lmain.display_ber$st$1$357({2}DX,STaxradio_status:S),R,0,0,[r6,r7] S:Lmain.display_ber$freqoffs$1$358({4}SL:S),R,0,0,[r2,r3,r4,r5] S:Lmain.axradio_statuschange$st$1$359({2}DX,STaxradio_status:S),R,0,0,[r6,r7] S:Lmain.axradio_statuschange$fourfsk$1$360({1}SC:U),R,0,0,[] S:Lmain.axradio_statuschange$i$4$368({1}SC:U),R,0,0,[] S:Lmain.axradio_statuschange$i$4$370({1}SC:U),R,0,0,[] S:Lmain.axradio_statuschange$i$6$379({1}SC:U),R,0,0,[] S:Lmain.axradio_statuschange$p$7$380({2}DX,SC:U),R,0,0,[] S:Lmain.set_cw$i$1$384({1}SC:U),R,0,0,[r6] S:Lmain.set_transmit$i$1$387({1}SC:U),R,0,0,[r6] S:Lmain.set_receiveber$i$1$392({1}SC:U),R,0,0,[r6] S:Lmain._sdcc_external_startup$c$2$401({1}SC:U),R,0,0,[] S:Lmain._sdcc_external_startup$p$2$401({1}SC:U),R,0,0,[] S:Lmain._sdcc_external_startup$c$2$402({1}SC:U),R,0,0,[] S:Lmain._sdcc_external_startup$p$2$402({1}SC:U),R,0,0,[] S:Lmain.si_write_reg$data$1$403({4}SL:U),E,0,0 S:Lmain.si_write_reg$address$1$403({1}SC:U),R,0,0,[r7] S:Lmain.si_write_reg$i$1$404({2}SI:S),R,0,0,[r6,r7] S:Lmain.si_write_reg$sdata$1$404({4}SL:U),R,0,0,[] S:Lmain.si_write_reg$mask$1$404({4}SL:U),R,0,0,[] S:Lmain.synth_init$freq$1$421({4}SL:U),R,0,0,[] S:Lmain.synth_init$phase$1$421({2}SI:U),R,0,0,[] S:Lmain.synth_init$pllref$1$421({1}SC:U),R,0,0,[] S:Lmain.synth_init$ndiv$1$421({4}SL:U),R,0,0,[] S:Lmain.synth_init$rdiv$1$421({4}SL:U),R,0,0,[] S:Lmain.main$i$1$435({1}SC:U),R,0,0,[r6] S:Lmain.main$crit$1$435({1}SC:U),E,0,0 S:Lmain.main$x$3$447({1}SC:U),R,0,0,[r7] S:Lmain.main$flg$3$452({1}SC:U),R,0,0,[r7] S:Lmain.main$flg$3$454({1}SC:U),R,0,0,[r7] S:Lmain._sdcc_external_startup$sloc0$1$0({1}SB0$0:S),H,0,0 S:G$ADCCH0VAL0$0$0({1}SC:U),F,0,0 S:G$ADCCH0VAL1$0$0({1}SC:U),F,0,0 S:G$ADCCH0VAL$0$0({2}SI:U),F,0,0 S:G$ADCCH1VAL0$0$0({1}SC:U),F,0,0 S:G$ADCCH1VAL1$0$0({1}SC:U),F,0,0 S:G$ADCCH1VAL$0$0({2}SI:U),F,0,0 S:G$ADCCH2VAL0$0$0({1}SC:U),F,0,0 S:G$ADCCH2VAL1$0$0({1}SC:U),F,0,0 S:G$ADCCH2VAL$0$0({2}SI:U),F,0,0 S:G$ADCCH3VAL0$0$0({1}SC:U),F,0,0 S:G$ADCCH3VAL1$0$0({1}SC:U),F,0,0 S:G$ADCCH3VAL$0$0({2}SI:U),F,0,0 S:G$ADCTUNE0$0$0({1}SC:U),F,0,0 S:G$ADCTUNE1$0$0({1}SC:U),F,0,0 S:G$ADCTUNE2$0$0({1}SC:U),F,0,0 S:G$DMA0ADDR0$0$0({1}SC:U),F,0,0 S:G$DMA0ADDR1$0$0({1}SC:U),F,0,0 S:G$DMA0ADDR$0$0({2}SI:U),F,0,0 S:G$DMA0CONFIG$0$0({1}SC:U),F,0,0 S:G$DMA1ADDR0$0$0({1}SC:U),F,0,0 S:G$DMA1ADDR1$0$0({1}SC:U),F,0,0 S:G$DMA1ADDR$0$0({2}SI:U),F,0,0 S:G$DMA1CONFIG$0$0({1}SC:U),F,0,0 S:G$FRCOSCCONFIG$0$0({1}SC:U),F,0,0 S:G$FRCOSCCTRL$0$0({1}SC:U),F,0,0 S:G$FRCOSCFREQ0$0$0({1}SC:U),F,0,0 S:G$FRCOSCFREQ1$0$0({1}SC:U),F,0,0 S:G$FRCOSCFREQ$0$0({2}SI:U),F,0,0 S:G$FRCOSCKFILT0$0$0({1}SC:U),F,0,0 S:G$FRCOSCKFILT1$0$0({1}SC:U),F,0,0 S:G$FRCOSCKFILT$0$0({2}SI:U),F,0,0 S:G$FRCOSCPER0$0$0({1}SC:U),F,0,0 S:G$FRCOSCPER1$0$0({1}SC:U),F,0,0 S:G$FRCOSCPER$0$0({2}SI:U),F,0,0 S:G$FRCOSCREF0$0$0({1}SC:U),F,0,0 S:G$FRCOSCREF1$0$0({1}SC:U),F,0,0 S:G$FRCOSCREF$0$0({2}SI:U),F,0,0 S:G$ANALOGA$0$0({1}SC:U),F,0,0 S:G$GPIOENABLE$0$0({1}SC:U),F,0,0 S:G$EXTIRQ$0$0({1}SC:U),F,0,0 S:G$INTCHGA$0$0({1}SC:U),F,0,0 S:G$INTCHGB$0$0({1}SC:U),F,0,0 S:G$INTCHGC$0$0({1}SC:U),F,0,0 S:G$PALTA$0$0({1}SC:U),F,0,0 S:G$PALTB$0$0({1}SC:U),F,0,0 S:G$PALTC$0$0({1}SC:U),F,0,0 S:G$PALTRADIO$0$0({1}SC:U),F,0,0 S:G$PINCHGA$0$0({1}SC:U),F,0,0 S:G$PINCHGB$0$0({1}SC:U),F,0,0 S:G$PINCHGC$0$0({1}SC:U),F,0,0 S:G$PINSEL$0$0({1}SC:U),F,0,0 S:G$LPOSCCONFIG$0$0({1}SC:U),F,0,0 S:G$LPOSCFREQ0$0$0({1}SC:U),F,0,0 S:G$LPOSCFREQ1$0$0({1}SC:U),F,0,0 S:G$LPOSCFREQ$0$0({2}SI:U),F,0,0 S:G$LPOSCKFILT0$0$0({1}SC:U),F,0,0 S:G$LPOSCKFILT1$0$0({1}SC:U),F,0,0 S:G$LPOSCKFILT$0$0({2}SI:U),F,0,0 S:G$LPOSCPER0$0$0({1}SC:U),F,0,0 S:G$LPOSCPER1$0$0({1}SC:U),F,0,0 S:G$LPOSCPER$0$0({2}SI:U),F,0,0 S:G$LPOSCREF0$0$0({1}SC:U),F,0,0 S:G$LPOSCREF1$0$0({1}SC:U),F,0,0 S:G$LPOSCREF$0$0({2}SI:U),F,0,0 S:G$LPXOSCGM$0$0({1}SC:U),F,0,0 S:G$MISCCTRL$0$0({1}SC:U),F,0,0 S:G$OSCCALIB$0$0({1}SC:U),F,0,0 S:G$OSCFORCERUN$0$0({1}SC:U),F,0,0 S:G$OSCREADY$0$0({1}SC:U),F,0,0 S:G$OSCRUN$0$0({1}SC:U),F,0,0 S:G$RADIOFDATAADDR0$0$0({1}SC:U),F,0,0 S:G$RADIOFDATAADDR1$0$0({1}SC:U),F,0,0 S:G$RADIOFDATAADDR$0$0({2}SI:U),F,0,0 S:G$RADIOFSTATADDR0$0$0({1}SC:U),F,0,0 S:G$RADIOFSTATADDR1$0$0({1}SC:U),F,0,0 S:G$RADIOFSTATADDR$0$0({2}SI:U),F,0,0 S:G$RADIOMUX$0$0({1}SC:U),F,0,0 S:G$SCRATCH0$0$0({1}SC:U),F,0,0 S:G$SCRATCH1$0$0({1}SC:U),F,0,0 S:G$SCRATCH2$0$0({1}SC:U),F,0,0 S:G$SCRATCH3$0$0({1}SC:U),F,0,0 S:G$SILICONREV$0$0({1}SC:U),F,0,0 S:G$XTALAMPL$0$0({1}SC:U),F,0,0 S:G$XTALOSC$0$0({1}SC:U),F,0,0 S:G$XTALREADY$0$0({1}SC:U),F,0,0 S:Fmain$flash_deviceid$0$0({6}DA6d,SC:U),F,0,0 S:Fmain$flash_calsector$0$0({31}STcalsector:S),F,0,0 S:G$radio_lcd_display$0$0({0}DA0d,SC:U),F,0,0 S:G$radio_not_found_lcd_display$0$0({0}DA0d,SC:U),F,0,0 S:G$txdata$0$0({8}DA8d,SC:U),F,0,0 S:G$ACC$0$0({1}SC:U),I,0,0 S:G$B$0$0({1}SC:U),I,0,0 S:G$DPH$0$0({1}SC:U),I,0,0 S:G$DPH1$0$0({1}SC:U),I,0,0 S:G$DPL$0$0({1}SC:U),I,0,0 S:G$DPL1$0$0({1}SC:U),I,0,0 S:G$DPTR0$0$0({2}SI:U),I,0,0 S:G$DPTR1$0$0({2}SI:U),I,0,0 S:G$DPS$0$0({1}SC:U),I,0,0 S:G$E2IE$0$0({1}SC:U),I,0,0 S:G$E2IP$0$0({1}SC:U),I,0,0 S:G$EIE$0$0({1}SC:U),I,0,0 S:G$EIP$0$0({1}SC:U),I,0,0 S:G$IE$0$0({1}SC:U),I,0,0 S:G$IP$0$0({1}SC:U),I,0,0 S:G$PCON$0$0({1}SC:U),I,0,0 S:G$PSW$0$0({1}SC:U),I,0,0 S:G$SP$0$0({1}SC:U),I,0,0 S:G$XPAGE$0$0({1}SC:U),I,0,0 S:G$_XPAGE$0$0({1}SC:U),I,0,0 S:G$ADCCH0CONFIG$0$0({1}SC:U),I,0,0 S:G$ADCCH1CONFIG$0$0({1}SC:U),I,0,0 S:G$ADCCH2CONFIG$0$0({1}SC:U),I,0,0 S:G$ADCCH3CONFIG$0$0({1}SC:U),I,0,0 S:G$ADCCLKSRC$0$0({1}SC:U),I,0,0 S:G$ADCCONV$0$0({1}SC:U),I,0,0 S:G$ANALOGCOMP$0$0({1}SC:U),I,0,0 S:G$CLKCON$0$0({1}SC:U),I,0,0 S:G$CLKSTAT$0$0({1}SC:U),I,0,0 S:G$CODECONFIG$0$0({1}SC:U),I,0,0 S:G$DBGLNKBUF$0$0({1}SC:U),I,0,0 S:G$DBGLNKSTAT$0$0({1}SC:U),I,0,0 S:G$DIRA$0$0({1}SC:U),I,0,0 S:G$DIRB$0$0({1}SC:U),I,0,0 S:G$DIRC$0$0({1}SC:U),I,0,0 S:G$DIRR$0$0({1}SC:U),I,0,0 S:G$PINA$0$0({1}SC:U),I,0,0 S:G$PINB$0$0({1}SC:U),I,0,0 S:G$PINC$0$0({1}SC:U),I,0,0 S:G$PINR$0$0({1}SC:U),I,0,0 S:G$PORTA$0$0({1}SC:U),I,0,0 S:G$PORTB$0$0({1}SC:U),I,0,0 S:G$PORTC$0$0({1}SC:U),I,0,0 S:G$PORTR$0$0({1}SC:U),I,0,0 S:G$IC0CAPT0$0$0({1}SC:U),I,0,0 S:G$IC0CAPT1$0$0({1}SC:U),I,0,0 S:G$IC0CAPT$0$0({2}SI:U),I,0,0 S:G$IC0MODE$0$0({1}SC:U),I,0,0 S:G$IC0STATUS$0$0({1}SC:U),I,0,0 S:G$IC1CAPT0$0$0({1}SC:U),I,0,0 S:G$IC1CAPT1$0$0({1}SC:U),I,0,0 S:G$IC1CAPT$0$0({2}SI:U),I,0,0 S:G$IC1MODE$0$0({1}SC:U),I,0,0 S:G$IC1STATUS$0$0({1}SC:U),I,0,0 S:G$NVADDR0$0$0({1}SC:U),I,0,0 S:G$NVADDR1$0$0({1}SC:U),I,0,0 S:G$NVADDR$0$0({2}SI:U),I,0,0 S:G$NVDATA0$0$0({1}SC:U),I,0,0 S:G$NVDATA1$0$0({1}SC:U),I,0,0 S:G$NVDATA$0$0({2}SI:U),I,0,0 S:G$NVKEY$0$0({1}SC:U),I,0,0 S:G$NVSTATUS$0$0({1}SC:U),I,0,0 S:G$OC0COMP0$0$0({1}SC:U),I,0,0 S:G$OC0COMP1$0$0({1}SC:U),I,0,0 S:G$OC0COMP$0$0({2}SI:U),I,0,0 S:G$OC0MODE$0$0({1}SC:U),I,0,0 S:G$OC0PIN$0$0({1}SC:U),I,0,0 S:G$OC0STATUS$0$0({1}SC:U),I,0,0 S:G$OC1COMP0$0$0({1}SC:U),I,0,0 S:G$OC1COMP1$0$0({1}SC:U),I,0,0 S:G$OC1COMP$0$0({2}SI:U),I,0,0 S:G$OC1MODE$0$0({1}SC:U),I,0,0 S:G$OC1PIN$0$0({1}SC:U),I,0,0 S:G$OC1STATUS$0$0({1}SC:U),I,0,0 S:G$RADIOACC$0$0({1}SC:U),I,0,0 S:G$RADIOADDR0$0$0({1}SC:U),I,0,0 S:G$RADIOADDR1$0$0({1}SC:U),I,0,0 S:G$RADIOADDR$0$0({2}SI:U),I,0,0 S:G$RADIODATA0$0$0({1}SC:U),I,0,0 S:G$RADIODATA1$0$0({1}SC:U),I,0,0 S:G$RADIODATA2$0$0({1}SC:U),I,0,0 S:G$RADIODATA3$0$0({1}SC:U),I,0,0 S:G$RADIODATA$0$0({4}SL:U),I,0,0 S:G$RADIOSTAT0$0$0({1}SC:U),I,0,0 S:G$RADIOSTAT1$0$0({1}SC:U),I,0,0 S:G$RADIOSTAT$0$0({2}SI:U),I,0,0 S:G$SPCLKSRC$0$0({1}SC:U),I,0,0 S:G$SPMODE$0$0({1}SC:U),I,0,0 S:G$SPSHREG$0$0({1}SC:U),I,0,0 S:G$SPSTATUS$0$0({1}SC:U),I,0,0 S:G$T0CLKSRC$0$0({1}SC:U),I,0,0 S:G$T0CNT0$0$0({1}SC:U),I,0,0 S:G$T0CNT1$0$0({1}SC:U),I,0,0 S:G$T0CNT$0$0({2}SI:U),I,0,0 S:G$T0MODE$0$0({1}SC:U),I,0,0 S:G$T0PERIOD0$0$0({1}SC:U),I,0,0 S:G$T0PERIOD1$0$0({1}SC:U),I,0,0 S:G$T0PERIOD$0$0({2}SI:U),I,0,0 S:G$T0STATUS$0$0({1}SC:U),I,0,0 S:G$T1CLKSRC$0$0({1}SC:U),I,0,0 S:G$T1CNT0$0$0({1}SC:U),I,0,0 S:G$T1CNT1$0$0({1}SC:U),I,0,0 S:G$T1CNT$0$0({2}SI:U),I,0,0 S:G$T1MODE$0$0({1}SC:U),I,0,0 S:G$T1PERIOD0$0$0({1}SC:U),I,0,0 S:G$T1PERIOD1$0$0({1}SC:U),I,0,0 S:G$T1PERIOD$0$0({2}SI:U),I,0,0 S:G$T1STATUS$0$0({1}SC:U),I,0,0 S:G$T2CLKSRC$0$0({1}SC:U),I,0,0 S:G$T2CNT0$0$0({1}SC:U),I,0,0 S:G$T2CNT1$0$0({1}SC:U),I,0,0 S:G$T2CNT$0$0({2}SI:U),I,0,0 S:G$T2MODE$0$0({1}SC:U),I,0,0 S:G$T2PERIOD0$0$0({1}SC:U),I,0,0 S:G$T2PERIOD1$0$0({1}SC:U),I,0,0 S:G$T2PERIOD$0$0({2}SI:U),I,0,0 S:G$T2STATUS$0$0({1}SC:U),I,0,0 S:G$U0CTRL$0$0({1}SC:U),I,0,0 S:G$U0MODE$0$0({1}SC:U),I,0,0 S:G$U0SHREG$0$0({1}SC:U),I,0,0 S:G$U0STATUS$0$0({1}SC:U),I,0,0 S:G$U1CTRL$0$0({1}SC:U),I,0,0 S:G$U1MODE$0$0({1}SC:U),I,0,0 S:G$U1SHREG$0$0({1}SC:U),I,0,0 S:G$U1STATUS$0$0({1}SC:U),I,0,0 S:G$WDTCFG$0$0({1}SC:U),I,0,0 S:G$WDTRESET$0$0({1}SC:U),I,0,0 S:G$WTCFGA$0$0({1}SC:U),I,0,0 S:G$WTCFGB$0$0({1}SC:U),I,0,0 S:G$WTCNTA0$0$0({1}SC:U),I,0,0 S:G$WTCNTA1$0$0({1}SC:U),I,0,0 S:G$WTCNTA$0$0({2}SI:U),I,0,0 S:G$WTCNTB0$0$0({1}SC:U),I,0,0 S:G$WTCNTB1$0$0({1}SC:U),I,0,0 S:G$WTCNTB$0$0({2}SI:U),I,0,0 S:G$WTCNTR1$0$0({1}SC:U),I,0,0 S:G$WTEVTA0$0$0({1}SC:U),I,0,0 S:G$WTEVTA1$0$0({1}SC:U),I,0,0 S:G$WTEVTA$0$0({2}SI:U),I,0,0 S:G$WTEVTB0$0$0({1}SC:U),I,0,0 S:G$WTEVTB1$0$0({1}SC:U),I,0,0 S:G$WTEVTB$0$0({2}SI:U),I,0,0 S:G$WTEVTC0$0$0({1}SC:U),I,0,0 S:G$WTEVTC1$0$0({1}SC:U),I,0,0 S:G$WTEVTC$0$0({2}SI:U),I,0,0 S:G$WTEVTD0$0$0({1}SC:U),I,0,0 S:G$WTEVTD1$0$0({1}SC:U),I,0,0 S:G$WTEVTD$0$0({2}SI:U),I,0,0 S:G$WTIRQEN$0$0({1}SC:U),I,0,0 S:G$WTSTAT$0$0({1}SC:U),I,0,0 S:G$ACC_0$0$0({1}SX:U),J,0,0 S:G$ACC_1$0$0({1}SX:U),J,0,0 S:G$ACC_2$0$0({1}SX:U),J,0,0 S:G$ACC_3$0$0({1}SX:U),J,0,0 S:G$ACC_4$0$0({1}SX:U),J,0,0 S:G$ACC_5$0$0({1}SX:U),J,0,0 S:G$ACC_6$0$0({1}SX:U),J,0,0 S:G$ACC_7$0$0({1}SX:U),J,0,0 S:G$B_0$0$0({1}SX:U),J,0,0 S:G$B_1$0$0({1}SX:U),J,0,0 S:G$B_2$0$0({1}SX:U),J,0,0 S:G$B_3$0$0({1}SX:U),J,0,0 S:G$B_4$0$0({1}SX:U),J,0,0 S:G$B_5$0$0({1}SX:U),J,0,0 S:G$B_6$0$0({1}SX:U),J,0,0 S:G$B_7$0$0({1}SX:U),J,0,0 S:G$E2IE_0$0$0({1}SX:U),J,0,0 S:G$E2IE_1$0$0({1}SX:U),J,0,0 S:G$E2IE_2$0$0({1}SX:U),J,0,0 S:G$E2IE_3$0$0({1}SX:U),J,0,0 S:G$E2IE_4$0$0({1}SX:U),J,0,0 S:G$E2IE_5$0$0({1}SX:U),J,0,0 S:G$E2IE_6$0$0({1}SX:U),J,0,0 S:G$E2IE_7$0$0({1}SX:U),J,0,0 S:G$E2IP_0$0$0({1}SX:U),J,0,0 S:G$E2IP_1$0$0({1}SX:U),J,0,0 S:G$E2IP_2$0$0({1}SX:U),J,0,0 S:G$E2IP_3$0$0({1}SX:U),J,0,0 S:G$E2IP_4$0$0({1}SX:U),J,0,0 S:G$E2IP_5$0$0({1}SX:U),J,0,0 S:G$E2IP_6$0$0({1}SX:U),J,0,0 S:G$E2IP_7$0$0({1}SX:U),J,0,0 S:G$EIE_0$0$0({1}SX:U),J,0,0 S:G$EIE_1$0$0({1}SX:U),J,0,0 S:G$EIE_2$0$0({1}SX:U),J,0,0 S:G$EIE_3$0$0({1}SX:U),J,0,0 S:G$EIE_4$0$0({1}SX:U),J,0,0 S:G$EIE_5$0$0({1}SX:U),J,0,0 S:G$EIE_6$0$0({1}SX:U),J,0,0 S:G$EIE_7$0$0({1}SX:U),J,0,0 S:G$EIP_0$0$0({1}SX:U),J,0,0 S:G$EIP_1$0$0({1}SX:U),J,0,0 S:G$EIP_2$0$0({1}SX:U),J,0,0 S:G$EIP_3$0$0({1}SX:U),J,0,0 S:G$EIP_4$0$0({1}SX:U),J,0,0 S:G$EIP_5$0$0({1}SX:U),J,0,0 S:G$EIP_6$0$0({1}SX:U),J,0,0 S:G$EIP_7$0$0({1}SX:U),J,0,0 S:G$IE_0$0$0({1}SX:U),J,0,0 S:G$IE_1$0$0({1}SX:U),J,0,0 S:G$IE_2$0$0({1}SX:U),J,0,0 S:G$IE_3$0$0({1}SX:U),J,0,0 S:G$IE_4$0$0({1}SX:U),J,0,0 S:G$IE_5$0$0({1}SX:U),J,0,0 S:G$IE_6$0$0({1}SX:U),J,0,0 S:G$IE_7$0$0({1}SX:U),J,0,0 S:G$EA$0$0({1}SX:U),J,0,0 S:G$IP_0$0$0({1}SX:U),J,0,0 S:G$IP_1$0$0({1}SX:U),J,0,0 S:G$IP_2$0$0({1}SX:U),J,0,0 S:G$IP_3$0$0({1}SX:U),J,0,0 S:G$IP_4$0$0({1}SX:U),J,0,0 S:G$IP_5$0$0({1}SX:U),J,0,0 S:G$IP_6$0$0({1}SX:U),J,0,0 S:G$IP_7$0$0({1}SX:U),J,0,0 S:G$P$0$0({1}SX:U),J,0,0 S:G$F1$0$0({1}SX:U),J,0,0 S:G$OV$0$0({1}SX:U),J,0,0 S:G$RS0$0$0({1}SX:U),J,0,0 S:G$RS1$0$0({1}SX:U),J,0,0 S:G$F0$0$0({1}SX:U),J,0,0 S:G$AC$0$0({1}SX:U),J,0,0 S:G$CY$0$0({1}SX:U),J,0,0 S:G$PINA_0$0$0({1}SX:U),J,0,0 S:G$PINA_1$0$0({1}SX:U),J,0,0 S:G$PINA_2$0$0({1}SX:U),J,0,0 S:G$PINA_3$0$0({1}SX:U),J,0,0 S:G$PINA_4$0$0({1}SX:U),J,0,0 S:G$PINA_5$0$0({1}SX:U),J,0,0 S:G$PINA_6$0$0({1}SX:U),J,0,0 S:G$PINA_7$0$0({1}SX:U),J,0,0 S:G$PINB_0$0$0({1}SX:U),J,0,0 S:G$PINB_1$0$0({1}SX:U),J,0,0 S:G$PINB_2$0$0({1}SX:U),J,0,0 S:G$PINB_3$0$0({1}SX:U),J,0,0 S:G$PINB_4$0$0({1}SX:U),J,0,0 S:G$PINB_5$0$0({1}SX:U),J,0,0 S:G$PINB_6$0$0({1}SX:U),J,0,0 S:G$PINB_7$0$0({1}SX:U),J,0,0 S:G$PINC_0$0$0({1}SX:U),J,0,0 S:G$PINC_1$0$0({1}SX:U),J,0,0 S:G$PINC_2$0$0({1}SX:U),J,0,0 S:G$PINC_3$0$0({1}SX:U),J,0,0 S:G$PINC_4$0$0({1}SX:U),J,0,0 S:G$PINC_5$0$0({1}SX:U),J,0,0 S:G$PINC_6$0$0({1}SX:U),J,0,0 S:G$PINC_7$0$0({1}SX:U),J,0,0 S:G$PORTA_0$0$0({1}SX:U),J,0,0 S:G$PORTA_1$0$0({1}SX:U),J,0,0 S:G$PORTA_2$0$0({1}SX:U),J,0,0 S:G$PORTA_3$0$0({1}SX:U),J,0,0 S:G$PORTA_4$0$0({1}SX:U),J,0,0 S:G$PORTA_5$0$0({1}SX:U),J,0,0 S:G$PORTA_6$0$0({1}SX:U),J,0,0 S:G$PORTA_7$0$0({1}SX:U),J,0,0 S:G$PORTB_0$0$0({1}SX:U),J,0,0 S:G$PORTB_1$0$0({1}SX:U),J,0,0 S:G$PORTB_2$0$0({1}SX:U),J,0,0 S:G$PORTB_3$0$0({1}SX:U),J,0,0 S:G$PORTB_4$0$0({1}SX:U),J,0,0 S:G$PORTB_5$0$0({1}SX:U),J,0,0 S:G$PORTB_6$0$0({1}SX:U),J,0,0 S:G$PORTB_7$0$0({1}SX:U),J,0,0 S:G$PORTC_0$0$0({1}SX:U),J,0,0 S:G$PORTC_1$0$0({1}SX:U),J,0,0 S:G$PORTC_2$0$0({1}SX:U),J,0,0 S:G$PORTC_3$0$0({1}SX:U),J,0,0 S:G$PORTC_4$0$0({1}SX:U),J,0,0 S:G$PORTC_5$0$0({1}SX:U),J,0,0 S:G$PORTC_6$0$0({1}SX:U),J,0,0 S:G$PORTC_7$0$0({1}SX:U),J,0,0 S:G$delay$0$0({2}DF,SV:S),C,0,0 S:G$random$0$0({2}DF,SI:U),C,0,0 S:G$signextend12$0$0({2}DF,SL:S),C,0,0 S:G$signextend16$0$0({2}DF,SL:S),C,0,0 S:G$signextend20$0$0({2}DF,SL:S),C,0,0 S:G$signextend24$0$0({2}DF,SL:S),C,0,0 S:G$hweight8$0$0({2}DF,SC:U),C,0,0 S:G$hweight16$0$0({2}DF,SC:U),C,0,0 S:G$hweight32$0$0({2}DF,SC:U),C,0,0 S:G$signedlimit16$0$0({2}DF,SI:S),C,0,0 S:G$checksignedlimit16$0$0({2}DF,SC:U),C,0,0 S:G$signedlimit32$0$0({2}DF,SL:S),C,0,0 S:G$checksignedlimit32$0$0({2}DF,SC:U),C,0,0 S:G$gray_encode8$0$0({2}DF,SC:U),C,0,0 S:G$gray_decode8$0$0({2}DF,SC:U),C,0,0 S:G$rev8$0$0({2}DF,SC:U),C,0,0 S:G$fmemset$0$0({2}DF,SV:S),C,0,0 S:G$fmemcpy$0$0({2}DF,SV:S),C,0,0 S:G$get_startcause$0$0({2}DF,SC:U),C,0,0 S:G$wtimer_standby$0$0({2}DF,SV:S),C,0,0 S:G$enter_standby$0$0({2}DF,SV:S),C,0,0 S:G$enter_deepsleep$0$0({2}DF,SV:S),C,0,0 S:G$enter_sleep$0$0({2}DF,SV:S),C,0,0 S:G$enter_sleep_cont$0$0({2}DF,SV:S),C,0,0 S:G$reset_cpu$0$0({2}DF,SV:S),C,0,0 S:G$turn_off_xosc$0$0({2}DF,SV:S),C,0,0 S:G$turn_off_lpxosc$0$0({2}DF,SV:S),C,0,0 S:G$enter_critical$0$0({2}DF,SC:U),C,0,0 S:G$exit_critical$0$0({2}DF,SV:S),C,0,0 S:G$reenter_critical$0$0({2}DF,SV:S),C,0,0 S:G$__enable_irq$0$0({2}DF,SV:S),C,0,0 S:G$__disable_irq$0$0({2}DF,SV:S),C,0,0 S:G$radio_read16$0$0({2}DF,SI:U),C,0,0 S:G$radio_read24$0$0({2}DF,SL:U),C,0,0 S:G$radio_read32$0$0({2}DF,SL:U),C,0,0 S:G$radio_write16$0$0({2}DF,SV:S),C,0,0 S:G$radio_write24$0$0({2}DF,SV:S),C,0,0 S:G$radio_write32$0$0({2}DF,SV:S),C,0,0 S:G$ax5031_comminit$0$0({2}DF,SV:S),C,0,0 S:G$ax5031_commsleepexit$0$0({2}DF,SV:S),C,0,0 S:G$ax5031_reset$0$0({2}DF,SC:U),C,0,0 S:G$ax5031_rclk_enable$0$0({2}DF,SV:S),C,0,0 S:G$ax5031_rclk_disable$0$0({2}DF,SV:S),C,0,0 S:G$ax5031_readfifo$0$0({2}DF,SV:S),C,0,0 S:G$ax5031_writefifo$0$0({2}DF,SV:S),C,0,0 S:G$ax5042_comminit$0$0({2}DF,SV:S),C,0,0 S:G$ax5042_commsleepexit$0$0({2}DF,SV:S),C,0,0 S:G$ax5042_reset$0$0({2}DF,SC:U),C,0,0 S:G$ax5042_rclk_enable$0$0({2}DF,SV:S),C,0,0 S:G$ax5042_rclk_disable$0$0({2}DF,SV:S),C,0,0 S:G$ax5042_readfifo$0$0({2}DF,SV:S),C,0,0 S:G$ax5042_writefifo$0$0({2}DF,SV:S),C,0,0 S:G$ax5043_comminit$0$0({2}DF,SV:S),C,0,0 S:G$ax5043_commsleepexit$0$0({2}DF,SV:S),C,0,0 S:G$ax5043_reset$0$0({2}DF,SC:U),C,0,0 S:G$ax5043_enter_deepsleep$0$0({2}DF,SV:S),C,0,0 S:G$ax5043_wakeup_deepsleep$0$0({2}DF,SC:U),C,0,0 S:G$ax5043_rclk_enable$0$0({2}DF,SV:S),C,0,0 S:G$ax5043_rclk_disable$0$0({2}DF,SV:S),C,0,0 S:G$ax5043_rclk_wait_stable$0$0({2}DF,SV:S),C,0,0 S:G$ax5043_readfifo$0$0({2}DF,SV:S),C,0,0 S:G$ax5043_writefifo$0$0({2}DF,SV:S),C,0,0 S:G$ax5043_set_pwramp_pin$0$0({2}DF,SV:S),C,0,0 S:G$ax5043_get_pwramp_pin$0$0({2}DF,SC:U),C,0,0 S:G$ax5043_set_antsel_pin$0$0({2}DF,SV:S),C,0,0 S:G$ax5043_get_antsel_pin$0$0({2}DF,SC:U),C,0,0 S:G$ax5044_45_comminit$0$0({2}DF,SV:S),C,0,0 S:G$ax5044_45_commsleepexit$0$0({2}DF,SV:S),C,0,0 S:G$ax5044_45_reset$0$0({2}DF,SC:U),C,0,0 S:G$ax5044_45_enter_deepsleep$0$0({2}DF,SV:S),C,0,0 S:G$ax5044_45_wakeup_deepsleep$0$0({2}DF,SC:U),C,0,0 S:G$ax5044_45_rclk_enable$0$0({2}DF,SV:S),C,0,0 S:G$ax5044_45_rclk_disable$0$0({2}DF,SV:S),C,0,0 S:G$ax5044_45_rclk_wait_stable$0$0({2}DF,SV:S),C,0,0 S:G$ax5044_45_readfifo$0$0({2}DF,SV:S),C,0,0 S:G$ax5044_45_writefifo$0$0({2}DF,SV:S),C,0,0 S:G$ax5044_45_set_pwramp_pin$0$0({2}DF,SV:S),C,0,0 S:G$ax5044_45_get_pwramp_pin$0$0({2}DF,SC:U),C,0,0 S:G$ax5044_45_set_antsel_pin$0$0({2}DF,SV:S),C,0,0 S:G$ax5044_45_get_antsel_pin$0$0({2}DF,SC:U),C,0,0 S:G$ax5051_comminit$0$0({2}DF,SV:S),C,0,0 S:G$ax5051_commsleepexit$0$0({2}DF,SV:S),C,0,0 S:G$ax5051_reset$0$0({2}DF,SC:U),C,0,0 S:G$ax5051_rclk_enable$0$0({2}DF,SV:S),C,0,0 S:G$ax5051_rclk_disable$0$0({2}DF,SV:S),C,0,0 S:G$ax5051_readfifo$0$0({2}DF,SV:S),C,0,0 S:G$ax5051_writefifo$0$0({2}DF,SV:S),C,0,0 S:G$flash_unlock$0$0({2}DF,SV:S),C,0,0 S:G$flash_lock$0$0({2}DF,SV:S),C,0,0 S:G$flash_wait$0$0({2}DF,SC:S),C,0,0 S:G$flash_pageerase$0$0({2}DF,SC:S),C,0,0 S:G$flash_write$0$0({2}DF,SC:S),C,0,0 S:G$flash_read$0$0({2}DF,SI:U),C,0,0 S:G$flash_apply_calibration$0$0({2}DF,SC:U),C,0,0 S:G$wtimer0_setconfig$0$0({2}DF,SV:S),C,0,0 S:G$wtimer1_setconfig$0$0({2}DF,SV:S),C,0,0 S:G$wtimer_init$0$0({2}DF,SV:S),C,0,0 S:G$wtimer_init_deepsleep$0$0({2}DF,SV:S),C,0,0 S:G$wtimer_idle$0$0({2}DF,SC:U),C,0,0 S:G$wtimer_runcallbacks$0$0({2}DF,SC:U),C,0,0 S:G$wtimer0_curtime$0$0({2}DF,SL:U),C,0,0 S:G$wtimer1_curtime$0$0({2}DF,SL:U),C,0,0 S:G$wtimer0_addabsolute$0$0({2}DF,SV:S),C,0,0 S:G$wtimer1_addabsolute$0$0({2}DF,SV:S),C,0,0 S:G$wtimer0_addrelative$0$0({2}DF,SV:S),C,0,0 S:G$wtimer1_addrelative$0$0({2}DF,SV:S),C,0,0 S:G$wtimer_remove$0$0({2}DF,SC:U),C,0,0 S:G$wtimer0_remove$0$0({2}DF,SC:U),C,0,0 S:G$wtimer1_remove$0$0({2}DF,SC:U),C,0,0 S:G$wtimer_add_callback$0$0({2}DF,SV:S),C,0,0 S:G$wtimer_remove_callback$0$0({2}DF,SC:U),C,0,0 S:G$wtimer_cansleep$0$0({2}DF,SC:U),C,0,0 S:G$wtimer_irq$0$0({2}DF,SV:S),C,0,0 S:G$crc_ccitt_byte$0$0({2}DF,SI:U),C,0,0 S:G$crc_ccitt_msb_byte$0$0({2}DF,SI:U),C,0,0 S:G$crc_ccitt$0$0({2}DF,SI:U),C,0,0 S:G$crc_ccitt_msb$0$0({2}DF,SI:U),C,0,0 S:G$crc_crc16_byte$0$0({2}DF,SI:U),C,0,0 S:G$crc_crc16_msb_byte$0$0({2}DF,SI:U),C,0,0 S:G$crc_crc16$0$0({2}DF,SI:U),C,0,0 S:G$crc_crc16_msb$0$0({2}DF,SI:U),C,0,0 S:G$crc_crc16dnp_byte$0$0({2}DF,SI:U),C,0,0 S:G$crc_crc16dnp_msb_byte$0$0({2}DF,SI:U),C,0,0 S:G$crc_crc16dnp$0$0({2}DF,SI:U),C,0,0 S:G$crc_crc16dnp_msb$0$0({2}DF,SI:U),C,0,0 S:G$crc_crc32_byte$0$0({2}DF,SL:U),C,0,0 S:G$crc_crc32_msb_byte$0$0({2}DF,SL:U),C,0,0 S:G$crc_crc32$0$0({2}DF,SL:U),C,0,0 S:G$crc_crc32_msb$0$0({2}DF,SL:U),C,0,0 S:G$crc_crc8ccitt_byte$0$0({2}DF,SC:U),C,0,0 S:G$crc_crc8ccitt_msb_byte$0$0({2}DF,SC:U),C,0,0 S:G$crc_crc8ccitt$0$0({2}DF,SC:U),C,0,0 S:G$crc_crc8ccitt_msb$0$0({2}DF,SC:U),C,0,0 S:G$crc_crc8onewire_byte$0$0({2}DF,SC:U),C,0,0 S:G$crc_crc8onewire_msb_byte$0$0({2}DF,SC:U),C,0,0 S:G$crc_crc8onewire$0$0({2}DF,SC:U),C,0,0 S:G$crc_crc8onewire_msb$0$0({2}DF,SC:U),C,0,0 S:G$crc8_ccitt_byte$0$0({2}DF,SC:U),C,0,0 S:G$crc8_ccitt$0$0({2}DF,SC:U),C,0,0 S:G$crc8_onewire_byte$0$0({2}DF,SC:U),C,0,0 S:G$crc8_onewire$0$0({2}DF,SC:U),C,0,0 S:G$pn9_advance$0$0({2}DF,SI:U),C,0,0 S:G$pn9_advance_bit$0$0({2}DF,SI:U),C,0,0 S:G$pn9_advance_bits$0$0({2}DF,SI:U),C,0,0 S:G$pn9_advance_byte$0$0({2}DF,SI:U),C,0,0 S:G$pn9_buffer$0$0({2}DF,SI:U),C,0,0 S:G$pn15_advance$0$0({2}DF,SI:U),C,0,0 S:G$pn15_output$0$0({2}DF,SC:U),C,0,0 S:G$lcd2_irq$0$0({2}DF,SV:S),C,0,0 S:G$lcd2_poll$0$0({2}DF,SC:U),C,0,0 S:G$lcd2_txbufptr$0$0({2}DF,DX,SC:U),C,0,0 S:G$lcd2_txfreelinear$0$0({2}DF,SC:U),C,0,0 S:G$lcd2_txidle$0$0({2}DF,SC:U),C,0,0 S:G$lcd2_txfree$0$0({2}DF,SC:U),C,0,0 S:G$lcd2_txbuffersize$0$0({2}DF,SC:U),C,0,0 S:G$lcd2_txpokecmd$0$0({2}DF,SV:S),C,0,0 S:G$lcd2_txpoke$0$0({2}DF,SV:S),C,0,0 S:G$lcd2_txpokehex$0$0({2}DF,SV:S),C,0,0 S:G$lcd2_txadvance$0$0({2}DF,SV:S),C,0,0 S:G$lcd2_init$0$0({2}DF,SV:S),C,0,0 S:G$lcd2_portinit$0$0({2}DF,SV:S),C,0,0 S:G$lcd2_wait_txdone$0$0({2}DF,SV:S),C,0,0 S:G$lcd2_wait_txfree$0$0({2}DF,SV:S),C,0,0 S:G$lcd2_tx$0$0({2}DF,SV:S),C,0,0 S:G$lcd2_txcmdshort$0$0({2}DF,SV:S),C,0,0 S:G$lcd2_txcmdlong$0$0({2}DF,SV:S),C,0,0 S:G$lcd2_setpos$0$0({2}DF,SV:S),C,0,0 S:G$lcd2_cleardisplay$0$0({2}DF,SV:S),C,0,0 S:G$lcd2_clear$0$0({2}DF,SV:S),C,0,0 S:G$lcd2_writestr$0$0({2}DF,SV:S),C,0,0 S:G$lcd2_writenum16$0$0({2}DF,SC:U),C,0,0 S:G$lcd2_writehex16$0$0({2}DF,SC:U),C,0,0 S:G$lcd2_writenum32$0$0({2}DF,SC:U),C,0,0 S:G$lcd2_writehex32$0$0({2}DF,SC:U),C,0,0 S:G$dbglink_irq$0$0({2}DF,SV:S),C,0,0 S:G$dbglink_poll$0$0({2}DF,SC:U),C,0,0 S:G$dbglink_txbufptr$0$0({2}DF,DX,SC:U),C,0,0 S:G$dbglink_txfreelinear$0$0({2}DF,SC:U),C,0,0 S:G$dbglink_txidle$0$0({2}DF,SC:U),C,0,0 S:G$dbglink_txfree$0$0({2}DF,SC:U),C,0,0 S:G$dbglink_rxbufptr$0$0({2}DF,DX,SC:U),C,0,0 S:G$dbglink_rxcountlinear$0$0({2}DF,SC:U),C,0,0 S:G$dbglink_rxcount$0$0({2}DF,SC:U),C,0,0 S:G$dbglink_txbuffersize$0$0({2}DF,SC:U),C,0,0 S:G$dbglink_rxbuffersize$0$0({2}DF,SC:U),C,0,0 S:G$dbglink_rxpeek$0$0({2}DF,SC:U),C,0,0 S:G$dbglink_txpoke$0$0({2}DF,SV:S),C,0,0 S:G$dbglink_txpokehex$0$0({2}DF,SV:S),C,0,0 S:G$dbglink_rxadvance$0$0({2}DF,SV:S),C,0,0 S:G$dbglink_txadvance$0$0({2}DF,SV:S),C,0,0 S:G$dbglink_init$0$0({2}DF,SV:S),C,0,0 S:G$dbglink_wait_txdone$0$0({2}DF,SV:S),C,0,0 S:G$dbglink_wait_txfree$0$0({2}DF,SV:S),C,0,0 S:G$dbglink_wait_rxcount$0$0({2}DF,SV:S),C,0,0 S:G$dbglink_rx$0$0({2}DF,SC:U),C,0,0 S:G$dbglink_tx$0$0({2}DF,SV:S),C,0,0 S:G$dbglink_writestr$0$0({2}DF,SV:S),C,0,0 S:G$dbglink_writenum16$0$0({2}DF,SC:U),C,0,0 S:G$dbglink_writehex16$0$0({2}DF,SC:U),C,0,0 S:G$dbglink_writenum32$0$0({2}DF,SC:U),C,0,0 S:G$dbglink_writehex32$0$0({2}DF,SC:U),C,0,0 S:G$dbglink_writehexu16$0$0({2}DF,SV:S),C,0,0 S:G$dbglink_writehexu32$0$0({2}DF,SV:S),C,0,0 S:G$dbglink_writeu16$0$0({2}DF,SV:S),C,0,0 S:G$dbglink_writeu32$0$0({2}DF,SV:S),C,0,0 S:G$uart_timer0_baud$0$0({2}DF,SV:S),C,0,0 S:G$uart_timer1_baud$0$0({2}DF,SV:S),C,0,0 S:G$uart_timer2_baud$0$0({2}DF,SV:S),C,0,0 S:G$adc_measure_temperature$0$0({2}DF,SI:S),C,0,0 S:G$adc_calibrate_gain$0$0({2}DF,SV:S),C,0,0 S:G$adc_calibrate_temp$0$0({2}DF,SV:S),C,0,0 S:G$adc_calibrate$0$0({2}DF,SV:S),C,0,0 S:G$adc_uncalibrate$0$0({2}DF,SV:S),C,0,0 S:G$adc_singleended_offset_x01$0$0({2}DF,SI:U),C,0,0 S:G$adc_singleended_offset_x1$0$0({2}DF,SI:U),C,0,0 S:G$adc_singleended_offset_x10$0$0({2}DF,SI:U),C,0,0 S:G$bch3121_syndrome$0$0({2}DF,SI:U),C,0,0 S:G$bch3121_encode$0$0({2}DF,SL:U),C,0,0 S:G$bch3121_encode_parity$0$0({2}DF,SL:U),C,0,0 S:G$bch3121_decode$0$0({2}DF,SL:U),C,0,0 S:G$bch3121_decode_parity$0$0({2}DF,SL:U),C,0,0 S:G$uart0_irq$0$0({2}DF,SV:S),C,0,0 S:G$uart0_poll$0$0({2}DF,SC:U),C,0,0 S:G$uart0_txbufptr$0$0({2}DF,DX,SC:U),C,0,0 S:G$uart0_txfreelinear$0$0({2}DF,SC:U),C,0,0 S:G$uart0_txidle$0$0({2}DF,SC:U),C,0,0 S:G$uart0_txbusy$0$0({2}DF,SC:U),C,0,0 S:G$uart0_txfree$0$0({2}DF,SC:U),C,0,0 S:G$uart0_rxbufptr$0$0({2}DF,DX,SC:U),C,0,0 S:G$uart0_rxcountlinear$0$0({2}DF,SC:U),C,0,0 S:G$uart0_rxcount$0$0({2}DF,SC:U),C,0,0 S:G$uart0_txbuffersize$0$0({2}DF,SC:U),C,0,0 S:G$uart0_rxbuffersize$0$0({2}DF,SC:U),C,0,0 S:G$uart0_rxpeek$0$0({2}DF,SC:U),C,0,0 S:G$uart0_txpoke$0$0({2}DF,SV:S),C,0,0 S:G$uart0_txpokehex$0$0({2}DF,SV:S),C,0,0 S:G$uart0_rxadvance$0$0({2}DF,SV:S),C,0,0 S:G$uart0_txadvance$0$0({2}DF,SV:S),C,0,0 S:G$uart0_init$0$0({2}DF,SV:S),C,0,0 S:G$uart0_stop$0$0({2}DF,SV:S),C,0,0 S:G$uart0_wait_txdone$0$0({2}DF,SV:S),C,0,0 S:G$uart0_wait_txfree$0$0({2}DF,SV:S),C,0,0 S:G$uart0_wait_rxcount$0$0({2}DF,SV:S),C,0,0 S:G$uart0_rx$0$0({2}DF,SC:U),C,0,0 S:G$uart0_tx$0$0({2}DF,SV:S),C,0,0 S:G$uart0_writestr$0$0({2}DF,SV:S),C,0,0 S:G$uart0_writenum16$0$0({2}DF,SC:U),C,0,0 S:G$uart0_writehex16$0$0({2}DF,SC:U),C,0,0 S:G$uart0_writenum32$0$0({2}DF,SC:U),C,0,0 S:G$uart0_writehex32$0$0({2}DF,SC:U),C,0,0 S:G$uart0_writehexu16$0$0({2}DF,SV:S),C,0,0 S:G$uart0_writehexu32$0$0({2}DF,SV:S),C,0,0 S:G$uart0_writeu16$0$0({2}DF,SV:S),C,0,0 S:G$uart0_writeu32$0$0({2}DF,SV:S),C,0,0 S:G$uart1_irq$0$0({2}DF,SV:S),C,0,0 S:G$uart1_poll$0$0({2}DF,SC:U),C,0,0 S:G$uart1_txbufptr$0$0({2}DF,DX,SC:U),C,0,0 S:G$uart1_txfreelinear$0$0({2}DF,SC:U),C,0,0 S:G$uart1_txidle$0$0({2}DF,SC:U),C,0,0 S:G$uart1_txbusy$0$0({2}DF,SC:U),C,0,0 S:G$uart1_txfree$0$0({2}DF,SC:U),C,0,0 S:G$uart1_rxbufptr$0$0({2}DF,DX,SC:U),C,0,0 S:G$uart1_rxcountlinear$0$0({2}DF,SC:U),C,0,0 S:G$uart1_rxcount$0$0({2}DF,SC:U),C,0,0 S:G$uart1_txbuffersize$0$0({2}DF,SC:U),C,0,0 S:G$uart1_rxbuffersize$0$0({2}DF,SC:U),C,0,0 S:G$uart1_rxpeek$0$0({2}DF,SC:U),C,0,0 S:G$uart1_txpoke$0$0({2}DF,SV:S),C,0,0 S:G$uart1_txpokehex$0$0({2}DF,SV:S),C,0,0 S:G$uart1_rxadvance$0$0({2}DF,SV:S),C,0,0 S:G$uart1_txadvance$0$0({2}DF,SV:S),C,0,0 S:G$uart1_init$0$0({2}DF,SV:S),C,0,0 S:G$uart1_stop$0$0({2}DF,SV:S),C,0,0 S:G$uart1_wait_txdone$0$0({2}DF,SV:S),C,0,0 S:G$uart1_wait_txfree$0$0({2}DF,SV:S),C,0,0 S:G$uart1_wait_rxcount$0$0({2}DF,SV:S),C,0,0 S:G$uart1_rx$0$0({2}DF,SC:U),C,0,0 S:G$uart1_tx$0$0({2}DF,SV:S),C,0,0 S:G$uart1_writestr$0$0({2}DF,SV:S),C,0,0 S:G$uart1_writenum16$0$0({2}DF,SC:U),C,0,0 S:G$uart1_writehex16$0$0({2}DF,SC:U),C,0,0 S:G$uart1_writenum32$0$0({2}DF,SC:U),C,0,0 S:G$uart1_writehex32$0$0({2}DF,SC:U),C,0,0 S:G$uart1_writehexu16$0$0({2}DF,SV:S),C,0,0 S:G$uart1_writehexu32$0$0({2}DF,SV:S),C,0,0 S:G$uart1_writeu16$0$0({2}DF,SV:S),C,0,0 S:G$uart1_writeu32$0$0({2}DF,SV:S),C,0,0 S:G$com0_inituart0$0$0({2}DF,SV:S),C,0,0 S:G$com0_portinit$0$0({2}DF,SV:S),C,0,0 S:G$com0_init$0$0({2}DF,SV:S),C,0,0 S:G$com0_setpos$0$0({2}DF,SV:S),C,0,0 S:G$com0_writestr$0$0({2}DF,SV:S),C,0,0 S:G$com0_tx$0$0({2}DF,SV:S),C,0,0 S:G$com0_clear$0$0({2}DF,SV:S),C,0,0 S:G$axradio_init$0$0({2}DF,SC:U),C,0,0 S:G$axradio_cansleep$0$0({2}DF,SC:U),C,0,0 S:G$axradio_set_mode$0$0({2}DF,SC:U),C,0,0 S:G$axradio_get_mode$0$0({2}DF,SC:U),C,0,0 S:G$axradio_set_channel$0$0({2}DF,SC:U),C,0,0 S:G$axradio_get_channel$0$0({2}DF,SC:U),C,0,0 S:G$axradio_get_pllrange$0$0({2}DF,SI:U),C,0,0 S:G$axradio_get_pllvcoi$0$0({2}DF,SC:U),C,0,0 S:G$axradio_set_local_address$0$0({2}DF,SV:S),C,0,0 S:G$axradio_get_local_address$0$0({2}DF,SV:S),C,0,0 S:G$axradio_set_default_remote_address$0$0({2}DF,SV:S),C,0,0 S:G$axradio_get_default_remote_address$0$0({2}DF,SV:S),C,0,0 S:G$axradio_transmit$0$0({2}DF,SC:U),C,0,0 S:G$axradio_set_freqoffset$0$0({2}DF,SC:U),C,0,0 S:G$axradio_get_freqoffset$0$0({2}DF,SL:S),C,0,0 S:G$axradio_conv_freq_tohz$0$0({2}DF,SL:S),C,0,0 S:G$axradio_conv_freq_fromhz$0$0({2}DF,SL:S),C,0,0 S:G$axradio_conv_timeinterval_totimer0$0$0({2}DF,SL:S),C,0,0 S:G$axradio_conv_time_totimer0$0$0({2}DF,SL:U),C,0,0 S:G$axradio_agc_freeze$0$0({2}DF,SC:U),C,0,0 S:G$axradio_agc_thaw$0$0({2}DF,SC:U),C,0,0 S:G$axradio_calibrate_lposc$0$0({2}DF,SV:S),C,0,0 S:G$axradio_check_fourfsk_modulation$0$0({2}DF,SC:U),C,0,0 S:G$axradio_get_transmitter_pa_type$0$0({2}DF,SC:U),C,0,0 S:G$axradio_setup_pincfg1$0$0({2}DF,SV:S),C,0,0 S:G$axradio_setup_pincfg2$0$0({2}DF,SV:S),C,0,0 S:G$axradio_commsleepexit$0$0({2}DF,SV:S),C,0,0 S:G$axradio_dbgpkt_enableIRQ$0$0({2}DF,SV:S),C,0,0 S:G$axradio_isr$0$0({2}DF,SV:S),C,0,0 S:G$display_received_packet$0$0({2}DF,SC:U),C,0,0 S:G$dbglink_received_packet$0$0({2}DF,SV:S),C,0,0 S:G$delay_ms$0$0({2}DF,SV:S),C,0,0 S:G$lcd2_display_radio_error$0$0({2}DF,SV:S),C,0,0 S:G$com0_display_radio_error$0$0({2}DF,SV:S),C,0,0 S:G$dbglink_display_radio_error$0$0({2}DF,SV:S),C,0,0 S:Fmain$pwrmgmt_irq$0$0({2}DF,SV:S),C,0,0 S:Fmain$correct_ber$0$0({2}DF,SV:S),C,0,0 S:Fmain$process_ber$0$0({2}DF,SV:S),C,0,0 S:Fmain$dump_pkt$0$0({2}DF,SV:S),C,0,0 S:Fmain$display_ber$0$0({2}DF,SV:S),C,0,0 S:G$set_cw$0$0({2}DF,SV:S),C,0,0 S:G$set_transmit$0$0({2}DF,SV:S),C,0,0 S:G$set_receiveber$0$0({2}DF,SV:S),C,0,0 S:G$_sdcc_external_startup$0$0({2}DF,SC:U),C,0,0 S:Fmain$si_write_reg$0$0({2}DF,SV:S),C,0,0 S:Fmain$synth_init$0$0({2}DF,SV:S),C,0,0 S:G$main$0$0({2}DF,SI:S),C,0,0 S:G$crc_ccitt_table$0$0({512}DA256d,SI:U),D,0,0 S:G$crc_ccitt_msbtable$0$0({512}DA256d,SI:U),D,0,0 S:G$crc_crc16_table$0$0({512}DA256d,SI:U),D,0,0 S:G$crc_crc16_msbtable$0$0({512}DA256d,SI:U),D,0,0 S:G$crc_crc16dnp_table$0$0({512}DA256d,SI:U),D,0,0 S:G$crc_crc16dnp_msbtable$0$0({512}DA256d,SI:U),D,0,0 S:G$crc_crc32_table$0$0({1024}DA256d,SL:U),D,0,0 S:G$crc_crc32_msbtable$0$0({1024}DA256d,SL:U),D,0,0 S:G$crc_crc8ccitt_table$0$0({256}DA256d,SC:U),D,0,0 S:G$crc_crc8ccitt_msbtable$0$0({256}DA256d,SC:U),D,0,0 S:G$crc_crc8onewire_table$0$0({256}DA256d,SC:U),D,0,0 S:G$crc_crc8onewire_msbtable$0$0({256}DA256d,SC:U),D,0,0 S:G$pn9_table$0$0({512}DA512d,SC:U),D,0,0 S:G$pn15_adv_table$0$0({512}DA256d,SI:U),D,0,0 S:G$pn15_out_table$0$0({256}DA256d,SC:U),D,0,0 S:G$bch3121_syndrometable$0$0({2048}DA1024d,SI:U),D,0,0 S:G$axradio_framing_maclen$0$0({1}SC:U),D,0,0 S:G$axradio_framing_addrlen$0$0({1}SC:U),D,0,0 S:G$txpattern$0$0({8}DA8d,SC:U),D,0,0 S:G$onepattern$0$0({16}DA16d,SC:U),D,0,0 S:G$fourfsk_tx1010_pattern$0$0({8}DA8d,SC:U),D,0,0 S:G$non_fourfsk_tx1010_pattern$0$0({8}DA8d,SC:U),D,0,0 S:Fmain$__str_0$0$0({3}DA3d,SC:S),D,0,0 S:Fmain$__str_1$0$0({3}DA3d,SC:S),D,0,0 S:Fmain$__str_2$0$0({11}DA11d,SC:S),D,0,0 S:Fmain$__str_3$0$0({4}DA4d,SC:S),D,0,0 S:Fmain$__str_4$0$0({4}DA4d,SC:S),D,0,0 S:Fmain$__str_5$0$0({12}DA12d,SC:S),D,0,0 S:Fmain$__str_6$0$0({13}DA13d,SC:S),D,0,0 S:Fmain$__str_7$0$0({13}DA13d,SC:S),D,0,0 S:Fmain$__str_8$0$0({12}DA12d,SC:S),D,0,0 S:Fmain$__str_9$0$0({12}DA12d,SC:S),D,0,0 S:Fmain$__str_10$0$0({3}DA3d,SC:S),D,0,0 S:Fmain$__str_11$0$0({6}DA6d,SC:S),D,0,0 S:Fmain$__str_12$0$0({3}DA3d,SC:S),D,0,0 S:Fmain$__str_13$0$0({5}DA5d,SC:S),D,0,0 S:Fmain$__str_14$0$0({7}DA7d,SC:S),D,0,0
vasil-sd/ada-tlsf
Ada
6,720
adb
pragma Ada_2012; with Bits; with BitOperations.Search.Axiom; with BitOperations.Search.Axiom.Most_Significant_Bit; package body TLSF.Block.Types with SPARK_Mode, Pure, Preelaborate is package Bits_Size is new Bits(Size_Bits); use Bits_Size; function To_Size_Bits (S : Size) return Size_Bits is Result : constant Size_Bits := Size_Bits(S); begin pragma Assert (Natural(Size_Bits'Last) = Natural(Size'Last)); pragma Assert (Natural(S) in 0 .. Natural(Size_Bits'Last)); pragma Assert (Size(Result) = S); return Result; end To_Size_Bits; function To_Address_Bits (A : Address) return Address_Bits is Result : constant Address_Bits := Address_Bits(A); begin pragma Assert (Natural(Address_Bits'Last) = Natural(Address'Last)); pragma Assert (Natural(A) in 0 .. Natural(Address_Bits'Last)); pragma Assert (Address(Result) = A); return Result; end To_Address_Bits; generic type Value_Type is range <>; type Value_Type_Mod is mod <>; function Is_Aligned_Generic(Val : Value_Type_Mod) return Boolean with Pre => Integer(Value_Type_Mod'First) = Integer(Value_Type'First) and then Integer(Value_Type_Mod'Last) = Integer(Value_Type'Last) and then Integer(Val) in 0 .. Integer(Value_Type'Last), Contract_Cases => ( (Val and Align_Mask) = 0 => Is_Aligned_Generic'Result = True, (Val and Align_Mask) /= 0 => Is_Aligned_Generic'Result = False); function Is_Aligned_Generic(Val : Value_Type_Mod) return Boolean is Result : constant Boolean := (Val and Align_Mask) = 0; begin return Result; end Is_Aligned_Generic; function Is_Aligned(Val : Size) return Boolean is function Is_Aligned_Size is new Is_Aligned_Generic(Size, Size_Bits); begin return Is_Aligned_Size(Size_Bits(Val)); end Is_Aligned; function Is_Aligned(Val : Address) return Boolean is function Is_Aligned_Addr is new Is_Aligned_Generic(Address, Address_Bits); begin return Is_Aligned_Addr(Address_Bits(Val)); end Is_Aligned; ---------------- -- Round_Size -- ---------------- generic type Value_Type is range <>; type Value_Type_Mod is mod <>; with function Is_Aligned (Val : Value_Type_Mod) return Boolean; function Round_Generic (V : Value_Type) return Value_Type with Pre => V <= Value_Type'Last - Align_Mask and then Integer(Value_Type_Mod'First) = Integer(Value_Type'First) and then Integer(Value_Type_Mod'Last) = Integer(Value_Type'Last) and then Integer(V) in 0 .. Integer(Value_Type'Last), Post => Is_Aligned(Value_Type_Mod(Round_Generic'Result)) and then (Value_Type_Mod(Round_Generic'Result) and Align_Mask) = 0; function Round_Generic (V : Value_Type) return Value_Type is pragma Assert (V <= Value_Type'Last - Align_Mask); USize : constant Value_Type_Mod := Value_Type_Mod(V); pragma Assert (USize <= Value_Type_Mod(Size'Last - Align_Mask)); Adj_Size : constant Value_Type_Mod := USize + Align_Mask; Masked_Size : constant Value_Type_Mod := Adj_Size and (not Align_Mask); pragma Assert (Natural(Value_Type_Mod'Last) = Natural(Value_Type'Last)); Result_Size : constant Value_Type := Value_Type(Masked_Size); begin pragma Assert (Is_Aligned(Masked_Size)); return Result_Size; end Round_Generic; function Round_Size_Up (S : Size) return Aligned_Size is function Is_Aligned_Val is new Is_Aligned_Generic(Size, Size_Bits); function Round is new Round_Generic(Size, Size_Bits, Is_Aligned_Val); begin return Round(S); end Round_Size_Up; function Round_Address_Up (A : Address) return Aligned_Address is function Is_Aligned_Val is new Is_Aligned_Generic(Address, Address_Bits); function Round is new Round_Generic(Address, Address_Bits, Is_Aligned_Val); begin return Round(A); end Round_Address_Up; function "+" (A: Aligned_Address; S: Aligned_Size) return Aligned_Address is Addr : constant Natural := Natural(A) + Natural(S); pragma Assert (Addr in 0 .. Natural (Address'Last)); -- TODO add lemma: -- Aligned + Aligned = Aligned -- or more common case: preservation of aligment by +,-,* operations pragma Assume (Is_Aligned(Address(Addr))); Result : constant Aligned_Address := Address(Addr); begin return Result; end "+"; function "+" (L, R : Aligned_Size) return Aligned_Size is Sz : constant Natural := Natural (L) + Natural (R); pragma Assert (Sz in 0 .. Natural (Size'Last)); pragma Assume (Is_Aligned (Size (Sz))); Result : constant Aligned_Size := Size (Sz); begin return Result; end "+"; function "-" (To, From : Aligned_Address) return Aligned_Size is Sz : constant Natural := Natural(To) - Natural(From); pragma Assert (Sz in 0.. Natural(Size'Last)); -- TODO add lemma: -- Aligned + Aligned = Aligned -- or more common case: preservation of aligment by +,-,* operations pragma Assume (Is_Aligned(Size(Sz))); Result : constant Aligned_Size := Size(Sz); begin return Result; end "-"; function Calculate_Levels_Indices (S : Size_Bits) return Level_Index is package Search_Axiom_Pkg is new Bits_Size.Search.Axiom; package MSB_Axiom is new Search_Axiom_Pkg.Most_Significant_Bit; First_Bit : constant Bits_Size.Bit_Position := Bits_Size.Most_Significant_Bit(S); Second_Level_Bits : Size_Bits; MSB_Small_Block_Size : constant Bits_Size.Bit_Position := Bits_Size.Most_Significant_Bit(Small_Block_Size) with Ghost; Result : Level_Index; begin MSB_Axiom.Result_Is_Correct(S, First_Bit); MSB_Axiom.Result_Is_Correct(Small_Block_Size, MSB_Small_Block_Size); MSB_Axiom.Order_Preservation_Value_To_Index (Value1 => S, Value2 => Small_Block_Size, Index1 => First_Bit, Index2 => FL_Index_Shift); pragma Assert (First_Bit >= FL_Index_Shift); Second_Level_Bits := Bits_Size.Extract(S, First_Bit - SL_Index_Count_Log2, First_Bit - 1); Result.First_Level := First_Level_Index (First_Bit); Result.Second_Level := Second_Level_Index (Second_Level_Bits); return Result; end Calculate_Levels_Indices; function Is_Same_Size_Class(S1, S2: Size) return Boolean is (Calculate_Levels_Indices(Size_Bits(S1)) = Calculate_Levels_Indices(Size_Bits(S2))); end TLSF.Block.Types;
reznikmm/matreshka
Ada
3,670
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.Definitions.Others_Choice is function Code (Engine : access Engines.Contexts.Context; Element : Asis.Association; Name : Engines.Text_Property) return League.Strings.Universal_String; end Properties.Definitions.Others_Choice;
zhmu/ananas
Ada
29,881
ads
------------------------------------------------------------------------------ -- -- -- GNAT COMPILER COMPONENTS -- -- -- -- N A M E T -- -- -- -- S p e c -- -- -- -- Copyright (C) 1992-2022, Free Software Foundation, Inc. -- -- -- -- GNAT is free software; you can redistribute it and/or modify it under -- -- terms of the GNU General Public License as published by the Free Soft- -- -- ware Foundation; either version 3, or (at your option) any later ver- -- -- sion. GNAT is distributed in the hope that it will be useful, but WITH- -- -- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY -- -- or FITNESS FOR A PARTICULAR PURPOSE. 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 Alloc; with Hostparm; use Hostparm; with Table; with Types; use Types; package Namet is -- WARNING: There is a C version of this package. Any changes to this -- source file must be properly reflected in the C header file namet.h -- This package contains routines for handling the names table. The table -- is used to store character strings for identifiers and operator symbols, -- as well as other string values such as unit names and file names. -- The forms of the entries are as follows: -- Identifiers Stored with upper case letters folded to lower case. -- Upper half (16#80# bit set) and wide characters are -- stored in an encoded form (Uhh for upper half char, -- Whhhh for wide characters, WWhhhhhhhh as provided by -- the routine Append_Encoded, where hh are hex -- digits for the character code using lower case a-f). -- Normally the use of U or W in other internal names is -- avoided, but these letters may be used in internal -- names (without this special meaning), if they appear -- as the last character of the name, or they are -- followed by an upper case letter (other than the WW -- sequence), or an underscore. -- Operator symbols Stored with an initial letter O, and the remainder -- of the name is the lower case characters XXX where -- the name is Name_Op_XXX, see Snames spec for a full -- list of the operator names. Normally the use of O -- in other internal names is avoided, but it may be -- used in internal names (without this special meaning) -- if it is the last character of the name, or if it is -- followed by an upper case letter or an underscore. -- Character literals Character literals have names that are used only for -- debugging and error message purposes. The form is an -- upper case Q followed by a single lower case letter, -- or by a Uxx/Wxxxx/WWxxxxxxx encoding as described for -- identifiers. The Set_Character_Literal_Name procedure -- should be used to construct these encodings. Normally -- the use of O in other internal names is avoided, but -- it may be used in internal names (without this special -- meaning) if it is the last character of the name, or -- if it is followed by an upper case letter or an -- underscore. -- Unit names Stored with upper case letters folded to lower case, -- using Uhh/Whhhh/WWhhhhhhhh encoding as described for -- identifiers, and a %s or %b suffix for specs/bodies. -- See package Uname for further details. -- File names Are stored in the form provided by Osint. Typically -- they may include wide character escape sequences and -- upper case characters (in non-encoded form). Casing -- is also derived from the external environment. Note -- that file names provided by Osint must generally be -- consistent with the names from Fname.Get_File_Name. -- Other strings The names table is also used as a convenient storage -- location for other variable length strings such as -- error messages etc. There are no restrictions on what -- characters may appear for such entries. -- Note: the encodings Uhh (upper half characters), Whhhh (wide characters), -- WWhhhhhhhh (wide wide characters) and Qx (character literal names) are -- described in the spec, since they are visible throughout the system (e.g. -- in debugging output). However, no code should depend on these particular -- encodings, so it should be possible to change the encodings by making -- changes only to the Namet specification (to change these comments) and the -- body (which actually implements the encodings). -- The names are hashed so that a given name appears only once in the table, -- except that names entered with Name_Enter as opposed to Name_Find are -- omitted from the hash table. -- The first 26 entries in the names table (with Name_Id values in the range -- First_Name_Id .. First_Name_Id + 25) represent names which are the one -- character lower case letters in the range a-z, and these names are created -- and initialized by the Initialize procedure. -- Five values, one of type Int, one of type Byte, and three of type Boolean, -- are stored with each names table entry and subprograms are provided for -- setting and retrieving these associated values. The usage of these values -- is up to the client: -- In the compiler we have the following uses: -- The Int field is used to point to a chain of potentially visible -- entities (see Sem.Ch8 for details). -- The Byte field is used to hold the Token_Type value for reserved words -- (see Sem for details). -- The Boolean1 field is used to mark address clauses to optimize the -- performance of the Exp_Util.Following_Address_Clause function. -- The Boolean2 field is used to mark simple names that appear in -- Restriction[_Warning]s pragmas for No_Use_Of_Entity. This avoids most -- unnecessary searches of the No_Use_Of_Entity table. -- The Boolean3 field is set for names of pragmas that are to be ignored -- because of the occurrence of a corresponding pragma Ignore_Pragma. -- In the binder, we have the following uses: -- The Int field is used in various ways depending on the name involved, -- see binder documentation for details. -- The Byte and Boolean fields are unused. -- Note that the value of the Int and Byte fields are initialized to zero, -- and the Boolean field is initialized to False, when a new Name table entry -- is created. type Bounded_String (Max_Length : Natural := 2**12) is limited -- It's unlikely to have names longer than this. But we don't want to make -- it too big, because we declare these on the stack in recursive routines. record Length : Natural := 0; Chars : String (1 .. Max_Length); end record; -- To create a Name_Id, you can declare a Bounded_String as a local -- variable, and Append things onto it, and finally call Name_Find. -- You can also use a String, as in: -- X := Name_Find (Some_String & "_some_suffix"); -- For historical reasons, we also have the Global_Name_Buffer below, -- which is used by most of the code via the renamings. New code ought -- to avoid the global. Global_Name_Buffer : Bounded_String (Max_Length => 4 * Max_Line_Length); Name_Buffer : String renames Global_Name_Buffer.Chars; Name_Len : Natural renames Global_Name_Buffer.Length; -- Note that there is some circuitry (e.g. Osint.Write_Program_Name) that -- does a save/restore on Name_Len and Name_Buffer (1 .. Name_Len). This -- works in part because Name_Len is default-initialized to 0. ----------------------------- -- Types for Namet Package -- ----------------------------- -- Name_Id values are used to identify entries in the names table. Except -- for the special values No_Name and Error_Name, they are subscript values -- for the Names table defined in this package. -- Note that with only a few exceptions, which are clearly documented, the -- type Name_Id should be regarded as a private type. In particular it is -- never appropriate to perform arithmetic operations using this type. type Name_Id is range Names_Low_Bound .. Names_High_Bound; for Name_Id'Size use 32; -- Type used to identify entries in the names table No_Name : constant Name_Id := Names_Low_Bound; -- The special Name_Id value No_Name is used in the parser to indicate -- a situation where no name is present (e.g. on a loop or block). Error_Name : constant Name_Id := Names_Low_Bound + 1; -- The special Name_Id value Error_Name is used in the parser to -- indicate that some kind of error was encountered in scanning out -- the relevant name, so it does not have a representable label. First_Name_Id : constant Name_Id := Names_Low_Bound + 2; -- Subscript of first entry in names table subtype Valid_Name_Id is Name_Id range First_Name_Id .. Name_Id'Last; -- All but No_Name and Error_Name function Present (Nam : Name_Id) return Boolean; pragma Inline (Present); -- Determine whether name Nam exists ----------------- -- Subprograms -- ----------------- function To_String (Buf : Bounded_String) return String; pragma Inline (To_String); function "+" (Buf : Bounded_String) return String renames To_String; function Name_Find (Buf : Bounded_String := Global_Name_Buffer) return Valid_Name_Id; function Name_Find (S : String) return Valid_Name_Id; -- Name_Find searches the names table to see if the string has already been -- stored. If so, the Id of the existing entry is returned. Otherwise a new -- entry is created with its Name_Table_Int fields set to zero/false. Note -- that it is permissible for Buf.Length to be zero to lookup the empty -- name string. function Name_Enter (Buf : Bounded_String := Global_Name_Buffer) return Valid_Name_Id; function Name_Enter (S : String) return Valid_Name_Id; -- Name_Enter is similar to Name_Find. The difference is that it does not -- search the table for an existing match, and also subsequent Name_Find -- calls using the same name will not locate the entry created by this -- call. Thus multiple calls to Name_Enter with the same name will create -- multiple entries in the name table with different Name_Id values. This -- is useful in the case of created names, which are never expected to be -- looked up. Note: Name_Enter should never be used for one character -- names, since these are efficiently located without hashing by Name_Find -- in any case. function Name_Equals (N1 : Valid_Name_Id; N2 : Valid_Name_Id) return Boolean; -- Return whether N1 and N2 denote the same character sequence function Get_Name_String (Id : Valid_Name_Id) return String; -- Returns the characters of Id as a String. The lower bound is 1. -- The following Append procedures ignore any characters that don't fit in -- Buf. procedure Append (Buf : in out Bounded_String; C : Character); -- Append C onto Buf pragma Inline (Append); procedure Append (Buf : in out Bounded_String; V : Nat); -- Append decimal representation of V onto Buf procedure Append (Buf : in out Bounded_String; S : String); -- Append S onto Buf procedure Append (Buf : in out Bounded_String; Buf2 : Bounded_String); -- Append Buf2 onto Buf procedure Append (Buf : in out Bounded_String; Id : Valid_Name_Id); -- Append the characters of Id onto Buf. It is an error to call this with -- one of the special name Id values (No_Name or Error_Name). procedure Append_Decoded (Buf : in out Bounded_String; Id : Valid_Name_Id); -- Same as Append, except that the result is decoded, so that upper half -- characters and wide characters appear as originally found in the source -- program text, operators have their source forms (special characters and -- enclosed in quotes), and character literals appear surrounded by -- apostrophes. procedure Append_Decoded_With_Brackets (Buf : in out Bounded_String; Id : Valid_Name_Id); -- Same as Append_Decoded, except that the brackets notation (Uhh -- replaced by ["hh"], Whhhh replaced by ["hhhh"], WWhhhhhhhh replaced by -- ["hhhhhhhh"]) is used for all non-lower half characters, regardless of -- how Opt.Wide_Character_Encoding_Method is set, and also in that -- characters in the range 16#80# .. 16#FF# are converted to brackets -- notation in all cases. This routine can be used when there is a -- requirement for a canonical representation not affected by the -- character set options (e.g. in the binder generation of symbols). procedure Append_Unqualified (Buf : in out Bounded_String; Id : Valid_Name_Id); -- Same as Append, except that qualification (as defined in unit -- Exp_Dbug) is removed (including both preceding __ delimited names, and -- also the suffixes used to indicate package body entities and to -- distinguish between overloaded entities). Note that names are not -- qualified until just before the call to gigi, so this routine is only -- needed by processing that occurs after gigi has been called. procedure Append_Unqualified_Decoded (Buf : in out Bounded_String; Id : Valid_Name_Id); -- Same as Append_Unqualified, but decoded as for Append_Decoded procedure Append_Encoded (Buf : in out Bounded_String; C : Char_Code); -- Appends given character code at the end of Buf. Lower case letters and -- digits are stored unchanged. Other 8-bit characters are stored using the -- Uhh encoding (hh = hex code), other 16-bit wide character values are -- stored using the Whhhh (hhhh = hex code) encoding, and other 32-bit wide -- wide character values are stored using the WWhhhhhhhh (hhhhhhhh = hex -- code). Note that this procedure does not fold upper case letters (they -- are stored using the Uhh encoding). procedure Set_Character_Literal_Name (Buf : in out Bounded_String; C : Char_Code); -- This procedure sets the proper encoded name for the character literal -- for the given character code. procedure Insert_Str (Buf : in out Bounded_String; S : String; Index : Positive); -- Inserts S in Buf, starting at Index. Any existing characters at or past -- this location get moved beyond the inserted string. function Is_Internal_Name (Buf : Bounded_String) return Boolean; procedure Get_Last_Two_Chars (N : Valid_Name_Id; C1 : out Character; C2 : out Character); -- Obtains last two characters of a name. C1 is last but one character and -- C2 is last character. If name is less than two characters long then both -- C1 and C2 are set to ASCII.NUL on return. function Get_Name_Table_Boolean1 (Id : Valid_Name_Id) return Boolean; function Get_Name_Table_Boolean2 (Id : Valid_Name_Id) return Boolean; function Get_Name_Table_Boolean3 (Id : Valid_Name_Id) return Boolean; -- Fetches the Boolean values associated with the given name function Get_Name_Table_Byte (Id : Valid_Name_Id) return Byte; pragma Inline (Get_Name_Table_Byte); -- Fetches the Byte value associated with the given name function Get_Name_Table_Int (Id : Valid_Name_Id) return Int; pragma Inline (Get_Name_Table_Int); -- Fetches the Int value associated with the given name procedure Set_Name_Table_Boolean1 (Id : Valid_Name_Id; Val : Boolean); procedure Set_Name_Table_Boolean2 (Id : Valid_Name_Id; Val : Boolean); procedure Set_Name_Table_Boolean3 (Id : Valid_Name_Id; Val : Boolean); -- Sets the Boolean value associated with the given name procedure Set_Name_Table_Byte (Id : Valid_Name_Id; Val : Byte); pragma Inline (Set_Name_Table_Byte); -- Sets the Byte value associated with the given name procedure Set_Name_Table_Int (Id : Valid_Name_Id; Val : Int); pragma Inline (Set_Name_Table_Int); -- Sets the Int value associated with the given name function Is_Internal_Name (Id : Valid_Name_Id) return Boolean; -- Returns True if the name is an internal name, i.e. contains a character -- for which Is_OK_Internal_Letter is true, or if the name starts or ends -- with an underscore. -- -- Note: if the name is qualified (has a double underscore), then only the -- final entity name is considered, not the qualifying names. Consider for -- example that the name: -- -- pkg__B_1__xyz -- -- is not an internal name, because the B comes from the internal name of -- a qualifying block, but the xyz means that this was indeed a declared -- identifier called "xyz" within this block and there is nothing internal -- about that name. function Is_OK_Internal_Letter (C : Character) return Boolean; pragma Inline (Is_OK_Internal_Letter); -- Returns true if C is a suitable character for using as a prefix or a -- suffix of an internally generated name, i.e. it is an upper case letter -- other than one of the ones used for encoding source names (currently the -- set of reserved letters is O, Q, U, W) and also returns False for the -- letter X, which is reserved for debug output (see Exp_Dbug). function Is_Operator_Name (Id : Valid_Name_Id) return Boolean; -- Returns True if name given is of the form of an operator (that is, it -- starts with an upper case O). function Is_Valid_Name (Id : Name_Id) return Boolean; -- True if Id is a valid name - points to a valid entry in the Name_Entries -- table. function Length_Of_Name (Id : Valid_Name_Id) return Nat; pragma Inline (Length_Of_Name); -- Returns length of given name in characters. This is the length of the -- encoded name, as stored in the names table. procedure Initialize; -- This is a dummy procedure. It is retained for easy compatibility with -- clients who used to call Initialize when this call was required. Now -- initialization is performed automatically during package elaboration. -- Note that this change fixes problems which existed prior to the change -- of Initialize being called more than once. See also Reinitialize which -- allows reinitialization of the tables. procedure Reinitialize; -- Clears the name tables and removes all existing entries from the table. procedure Reset_Name_Table; -- This procedure is used when there are multiple source files to reset the -- name table info entries associated with current entries in the names -- table. There is no harm in keeping the names entries themselves from one -- compilation to another, but we can't keep the entity info, since this -- refers to tree nodes, which are destroyed between each main source file. procedure Finalize; -- Called at the end of a use of the Namet package (before a subsequent -- call to Initialize). Currently this routine is only used to generate -- debugging output. procedure Lock; -- Lock name tables before calling back end. We reserve some extra space -- before locking to avoid unnecessary inefficiencies when we unlock. procedure Unlock; -- Unlocks the name table to allow use of the extra space reserved by the -- call to Lock. See gnat1drv for details of the need for this. procedure Write_Name (Id : Valid_Name_Id); -- Write_Name writes the characters of the specified name using the -- standard output procedures in package Output. The name is written -- in encoded form (i.e. including Uhh, Whhh, Qx, _op as they appear in -- the name table). If Id is Error_Name, or No_Name, no text is output. procedure Write_Name_Decoded (Id : Valid_Name_Id); -- Like Write_Name, except that the name written is the decoded name, as -- described for Append_Decoded. function Name_Entries_Count return Nat; -- Return current number of entries in the names table function Last_Name_Id return Name_Id; -- Return the last Name_Id in the table. This information is valid until -- new names have been added. -------------------------- -- Obsolete Subprograms -- -------------------------- -- The following routines operate on Global_Name_Buffer. New code should -- use the routines above, and declare Bounded_Strings as local -- variables. Existing code can be improved incrementally by removing calls -- to the following. If we eliminate all of these, we can remove -- Global_Name_Buffer. But be sure to look at namet.h first. -- To see what these do, look at the bodies. They are all trivially defined -- in terms of routines above. procedure Add_Char_To_Name_Buffer (C : Character); pragma Inline (Add_Char_To_Name_Buffer); procedure Add_Nat_To_Name_Buffer (V : Nat); procedure Add_Str_To_Name_Buffer (S : String); procedure Get_Decoded_Name_String (Id : Valid_Name_Id); procedure Get_Decoded_Name_String_With_Brackets (Id : Valid_Name_Id); procedure Get_Name_String (Id : Valid_Name_Id); procedure Get_Name_String_And_Append (Id : Valid_Name_Id); procedure Get_Unqualified_Decoded_Name_String (Id : Valid_Name_Id); procedure Get_Unqualified_Name_String (Id : Valid_Name_Id); procedure Insert_Str_In_Name_Buffer (S : String; Index : Positive); function Is_Internal_Name return Boolean; procedure Set_Character_Literal_Name (C : Char_Code); procedure Store_Encoded_Character (C : Char_Code); ------------------------------ -- File and Unit Name Types -- ------------------------------ -- These are defined here in Namet rather than Fname and Uname to avoid -- problems with dependencies, and to avoid dragging in Fname and Uname -- into many more files, but it would be cleaner to move to Fname/Uname. type File_Name_Type is new Name_Id; -- File names are stored in the names table and this type is used to -- indicate that a Name_Id value is being used to hold a simple file name -- (which does not include any directory information). No_File : constant File_Name_Type := File_Name_Type (No_Name); -- Constant used to indicate no file is present (this is used for example -- when a search for a file indicates that no file of the name exists). function Present (Nam : File_Name_Type) return Boolean; pragma Inline (Present); -- Determine whether file name Nam exists Error_File_Name : constant File_Name_Type := File_Name_Type (Error_Name); -- The special File_Name_Type value Error_File_Name is used to indicate -- a unit name where some previous processing has found an error. subtype Error_File_Name_Or_No_File is File_Name_Type range No_File .. Error_File_Name; -- Used to test for either error file name or no file type Path_Name_Type is new Name_Id; -- Path names are stored in the names table and this type is used to -- indicate that a Name_Id value is being used to hold a path name (that -- may contain directory information). No_Path : constant Path_Name_Type := Path_Name_Type (No_Name); -- Constant used to indicate no path name is present type Unit_Name_Type is new Name_Id; -- Unit names are stored in the names table and this type is used to -- indicate that a Name_Id value is being used to hold a unit name, which -- terminates in %b for a body or %s for a spec. No_Unit_Name : constant Unit_Name_Type := Unit_Name_Type (No_Name); -- Constant used to indicate no file name present function Present (Nam : Unit_Name_Type) return Boolean; pragma Inline (Present); -- Determine whether unit name Nam exists Error_Unit_Name : constant Unit_Name_Type := Unit_Name_Type (Error_Name); -- The special Unit_Name_Type value Error_Unit_Name is used to indicate -- a unit name where some previous processing has found an error. subtype Error_Unit_Name_Or_No_Unit_Name is Unit_Name_Type range No_Unit_Name .. Error_Unit_Name; ------------------------ -- Debugging Routines -- ------------------------ procedure wn (Id : Name_Id); pragma Export (Ada, wn); -- This routine is intended for debugging use only (i.e. it is intended to -- be called from the debugger). It writes the characters of the specified -- name using the standard output procedures in package Output, followed by -- a new line. The name is written in encoded form (i.e. including Uhh, -- Whhh, Qx, _op as they appear in the name table). If Id is Error_Name, -- No_Name, or invalid an appropriate string is written (<Error_Name>, -- <No_Name>, <invalid name>). Unlike Write_Name, this call does not affect -- the contents of Name_Buffer or Name_Len. private --------------------------- -- Table Data Structures -- --------------------------- -- The following declarations define the data structures used to store -- names. The definitions are in the private part of the package spec, -- rather than the body, since they are referenced directly by gigi. -- This table stores the actual string names. Although logically there is -- no need for a terminating character (since the length is stored in the -- name entry table), we still store a NUL character at the end of every -- name (for convenience in interfacing to the C world). package Name_Chars is new Table.Table ( Table_Component_Type => Character, Table_Index_Type => Int, Table_Low_Bound => 0, Table_Initial => Alloc.Name_Chars_Initial, Table_Increment => Alloc.Name_Chars_Increment, Table_Name => "Name_Chars"); type Name_Entry is record Name_Chars_Index : aliased Int; -- Starting location of characters in the Name_Chars table minus one -- (i.e. pointer to character just before first character). The reason -- for the bias of one is that indexes in Name_Buffer are one's origin, -- so this avoids unnecessary adds and subtracts of 1. Name_Len : aliased Short; -- Length of this name in characters Byte_Info : aliased Byte; -- Byte value associated with this name Name_Has_No_Encodings : Boolean; -- This flag is set True if the name entry is known not to contain any -- special character encodings. This is used to speed up repeated calls -- to Append_Decoded. A value of False means that it is not known -- whether the name contains any such encodings. Boolean1_Info : Boolean; Boolean2_Info : Boolean; Boolean3_Info : Boolean; -- Boolean values associated with the name Spare : Boolean; -- Four remaining bits in the current byte Hash_Link : aliased Name_Id; -- Link to next entry in names table for same hash code Int_Info : aliased Int; -- Int Value associated with this name end record; for Name_Entry use record Name_Chars_Index at 0 range 0 .. 31; Name_Len at 4 range 0 .. 15; Byte_Info at 6 range 0 .. 7; Name_Has_No_Encodings at 7 range 0 .. 0; Boolean1_Info at 7 range 1 .. 1; Boolean2_Info at 7 range 2 .. 2; Boolean3_Info at 7 range 3 .. 3; Spare at 7 range 4 .. 7; Hash_Link at 8 range 0 .. 31; Int_Info at 12 range 0 .. 31; end record; for Name_Entry'Size use 16 * 8; -- This ensures that we did not leave out any fields -- This is the table that is referenced by Valid_Name_Id entries. -- It contains one entry for each unique name in the table. package Name_Entries is new Table.Table ( Table_Component_Type => Name_Entry, Table_Index_Type => Valid_Name_Id'Base, Table_Low_Bound => First_Name_Id, Table_Initial => Alloc.Names_Initial, Table_Increment => Alloc.Names_Increment, Table_Name => "Name_Entries"); end Namet;
reznikmm/matreshka
Ada
5,919
ads
------------------------------------------------------------------------------ -- -- -- Matreshka Project -- -- -- -- Ada Modeling Framework -- -- -- -- Runtime Library Component -- -- -- ------------------------------------------------------------------------------ -- -- -- Copyright © 2011-2012, Vadim Godunko <[email protected]> -- -- All rights reserved. -- -- -- -- Redistribution and use in source and binary forms, with or without -- -- modification, are permitted provided that the following conditions -- -- are met: -- -- -- -- * Redistributions of source code must retain the above copyright -- -- notice, this list of conditions and the following disclaimer. -- -- -- -- * Redistributions in binary form must reproduce the above copyright -- -- notice, this list of conditions and the following disclaimer in the -- -- documentation and/or other materials provided with the distribution. -- -- -- -- * Neither the name of the Vadim Godunko, IE nor the names of its -- -- contributors may be used to endorse or promote products derived from -- -- this software without specific prior written permission. -- -- -- -- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -- -- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -- -- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -- -- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -- -- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -- -- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED -- -- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -- -- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -- -- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -- -- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -- -- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- -- -- ------------------------------------------------------------------------------ -- $Revision$ $Date$ ------------------------------------------------------------------------------ -- This file is generated, don't edit it. ------------------------------------------------------------------------------ -- An extension end is used to tie an extension to a stereotype when -- extending a metaclass. -- -- The default multiplicity of an extension end is 0..1. ------------------------------------------------------------------------------ with AMF.UML.Properties; limited with AMF.UML.Stereotypes; package AMF.UML.Extension_Ends is pragma Preelaborate; type UML_Extension_End is limited interface and AMF.UML.Properties.UML_Property; type UML_Extension_End_Access is access all UML_Extension_End'Class; for UML_Extension_End_Access'Storage_Size use 0; overriding function Get_Lower (Self : not null access constant UML_Extension_End) return AMF.Optional_Integer is abstract; -- Getter of ExtensionEnd::lower. -- -- This redefinition changes the default multiplicity of association ends, -- since model elements are usually extended by 0 or 1 instance of the -- extension stereotype. overriding procedure Set_Lower (Self : not null access UML_Extension_End; To : AMF.Optional_Integer) is abstract; -- Setter of ExtensionEnd::lower. -- -- This redefinition changes the default multiplicity of association ends, -- since model elements are usually extended by 0 or 1 instance of the -- extension stereotype. not overriding function Get_Type (Self : not null access constant UML_Extension_End) return AMF.UML.Stereotypes.UML_Stereotype_Access is abstract; -- Getter of ExtensionEnd::type. -- -- References the type of the ExtensionEnd. Note that this association -- restricts the possible types of an ExtensionEnd to only be Stereotypes. not overriding procedure Set_Type (Self : not null access UML_Extension_End; To : AMF.UML.Stereotypes.UML_Stereotype_Access) is abstract; -- Setter of ExtensionEnd::type. -- -- References the type of the ExtensionEnd. Note that this association -- restricts the possible types of an ExtensionEnd to only be Stereotypes. overriding function Lower_Bound (Self : not null access constant UML_Extension_End) return AMF.Optional_Integer is abstract; -- Operation ExtensionEnd::lowerBound. -- -- The query lowerBound() returns the lower bound of the multiplicity as -- an Integer. This is a redefinition of the default lower bound, which -- normally, for MultiplicityElements, evaluates to 1 if empty. end AMF.UML.Extension_Ends;
AdaCore/training_material
Ada
4,318
adb
------------------------------------------------------------------------------ -- -- -- Hardware Abstraction Layer for STM32 Targets -- -- -- -- Copyright (C) 2014, Free Software Foundation, Inc. -- -- -- -- GNAT is free software; you can redistribute it and/or modify it under -- -- terms of the GNU General Public License as published by the Free Soft- -- -- ware Foundation; either version 3, or (at your option) any later ver- -- -- sion. GNAT is distributed in the hope that it will be useful, but WITH- -- -- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY -- -- or FITNESS FOR A PARTICULAR PURPOSE. -- -- -- -- As a special exception under Section 7 of GPL version 3, you are granted -- -- additional permissions described in the GCC Runtime Library Exception, -- -- version 3.1, as published by the Free Software Foundation. -- -- -- -- You should have received a copy of the GNU General Public License and -- -- a copy of the GCC Runtime Library Exception along with this program; -- -- see the files COPYING3 and COPYING.RUNTIME respectively. If not, see -- -- <http://www.gnu.org/licenses/>. -- -- -- -- GNAT was originally developed by the GNAT team at New York University. -- -- Extensive contributions were provided by Ada Core Technologies Inc. -- -- -- ------------------------------------------------------------------------------ with STM32F429_Discovery; use STM32F429_Discovery; with Ada.Real_Time; use Ada.Real_Time; with Fonts; with Screen_Interface; with STM32F4.LCD; with Interfaces.C; with System.Address_To_Access_Conversions; with Unchecked_Conversion; with System.Storage_Elements; use System.Storage_Elements; package body Last_Chance_Handler is function Null_Terminated_To_String (Msg : System.Address) return String is package Addr_2_Char is new System.Address_To_Access_Conversions (Character); Max_Len : constant := 255; S : String (1 .. Max_Len) := (others => 'x'); Len : Integer := 0; begin for I in 1 .. Max_Len loop declare C : Character; begin C := Character (Addr_2_Char.To_Pointer (System.Storage_Elements.To_Address (System.Storage_Elements.To_Integer (Msg) + Integer_Address (I-1))).all); if Character'Pos(C) /= 0 then --C >= 'a' and C <= 'z' then S (I) := C; else exit; end if; end; Len := Len + 1; end loop; declare R : String (1 .. Len) := S (1 .. Len); begin return R; end; end Null_Terminated_To_String; function Exception_To_String (Msg : System.Address; Line : Integer) return String is begin return "Err:" & Null_Terminated_To_String (Msg) & ":" & Integer'Image (Line); end Exception_To_String; ------------------------- -- Last_Chance_Handler -- ------------------------- procedure Last_Chance_Handler (Msg : System.Address; Line : Integer) is begin Screen_Interface.Fill_Screen (Col => Screen_Interface.Black); Fonts.Draw_String (0, 0, Exception_To_String (Msg, Line), Fonts.Font12x12, Screen_Interface.Red, Screen_Interface.Black, True); STM32F4.LCD.Flip_Buffers; Initialize_LEDs; -- TODO: write the message and line number to the display Off (Green); -- No-return procedure... loop On (Red); delay until Clock + Milliseconds (500); Off (Red); delay until Clock + Milliseconds (500); end loop; end Last_Chance_Handler; end Last_Chance_Handler;
onox/orka
Ada
7,717
adb
-- SPDX-License-Identifier: Apache-2.0 -- -- Copyright (c) 2022 onox <[email protected]> -- -- Licensed under the Apache License, Version 2.0 (the "License"); -- you may not use this file except in compliance with the License. -- You may obtain a copy of the License at -- -- http://www.apache.org/licenses/LICENSE-2.0 -- -- Unless required by applicable law or agreed to in writing, software -- distributed under the License is distributed on an "AS IS" BASIS, -- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -- See the License for the specific language governing permissions and -- limitations under the License. with Ada.Numerics.Generic_Elementary_Functions; with Orka.Transforms.Doubles.Matrices; package body AWT.IMUs is use type Orka.Float_64; use all type Orka.Index_4D; use Kalman.Tensors; O_Variance : constant := (1.0e-4) ** 2; B_Variance : constant := (8.0e-6) ** 2; Z_Variance : constant := (6.0e-3) ** 2; P_Scale : constant := 1.0e-3; Unit_Norm_Convergence_Rate : constant := 0.3; Acceleration_Threshold : constant := 0.01; Velocity_Threshold : constant := 0.008; package EF is new Ada.Numerics.Generic_Elementary_Functions (Orka.Float_64); procedure Update_Bias (Object : in out IMU) is Measurement_X, Measurement_Y, Measurement_Z : Kalman.Vector := Empty ((1 => Object.Velocity_Measurements'Length)); begin for Index in Object.Velocity_Measurements'Range loop Measurement_X.Set ((1 => Index), Object.Velocity_Measurements (Index) (X)); Measurement_Y.Set ((1 => Index), Object.Velocity_Measurements (Index) (Y)); Measurement_Z.Set ((1 => Index), Object.Velocity_Measurements (Index) (Z)); end loop; declare State : Kalman.Vector := Object.Filter.State; Bias : constant Kalman.Vector := To_Tensor ((Measurement_X.Mean, Measurement_Y.Mean, Measurement_Z.Mean)); begin State.Set (Range_Type'(5, 7), Bias); Object.Filter.Set_State (State); end; end Update_Bias; function Get_New_Orientation (Orientation : Kalman.Vector; Velocity : Kalman.Vector; DT : Orka.Float_64) return Kalman.Vector is W : constant Kalman.Vector := Velocity * DT; -- [1] "Sigma-Point Kalman Filters for Probabilistic Inference in -- Dynamic State-Space Models", van der Merwe R., -- Oregon Health & Science University, 2004 -- Similar to equation 5.28 from [1], except the 3x3 skew-symmetric -- matrix has been moved from the lower right to the upper left -- because the scalar component of Quaternion is at the 4th position Omega : constant Kalman.Matrix := To_Tensor ((0.0, -W (3), W (2), -W (1), W (3), 0.0, -W (1), -W (2), -W (2), W (1), 0.0, -W (3), W (1), W (2), W (3), 0.0), Shape => (4, 4)); Y : constant Orka.Float_64 := 1.0 - Orka.Float_64'(Orientation * Orientation); J : constant Orka.Float_64 := Unit_Norm_Convergence_Rate / DT; -- J is convergence speed of numerical error with J * DT < 1.0 [1] -- Equation 5.30 from [1] S : constant Orka.Float_64 := 0.5 * W.Norm; -- Equation 5.31 from [1] Delta_Orientation : constant Kalman.Vector := Identity (4) * (EF.Cos (S) + J * DT * Y) - 0.5 * Omega * (EF.Sin (S) / S); begin return Delta_Orientation * Orientation; end Get_New_Orientation; procedure Integrate (Object : in out IMU; Velocity : Vectors.Direction; Acceleration : Vectors.Vector4; DT : Duration; State : out Estimated_State; Calibrated : out Boolean) is Measured_Velocity : constant Kalman.Vector := To_Tensor ((Velocity (X), Velocity (Y), Velocity (Z))); Measured_Acceleration : constant Kalman.Vector := To_Tensor ((Acceleration (X), Acceleration (Y), Acceleration (Z))); No_Acceleration : constant Boolean := abs (1.0 - Measured_Acceleration.Norm) < Acceleration_Threshold; function F (Point : Kalman.Vector; DT : Orka.Float_64) return Kalman.Vector is Old_Orientation : constant Kalman.Vector := Point (Range_Type'(1, 4)); Bias : constant Kalman.Vector := Point (Range_Type'(5, 7)); begin return Get_New_Orientation (Old_Orientation, Measured_Velocity - Bias, DT) & Bias; end F; function H (Point : Kalman.Vector) return Kalman.Vector is Orientation : constant Quaternions.Quaternion := (Point (1), Point (2), Point (3), Point (4)); use Orka.Transforms.Doubles.Matrices; Gravity_NED : constant Vectors.Vector4 := (0.0, -1.0, 0.0, 0.0); Gravity_Body : constant Vectors.Vector4 := R (Quaternion => Vectors.Vector4 (Quaternions.Normalize (Orientation))) * Gravity_NED; Predicted_Acceleration : constant Kalman.Vector := To_Tensor ((Gravity_Body (X), Gravity_Body (Y), Gravity_Body (Z))); begin -- Returning the measurement fools the filter into thinking the predicted -- state (prior) is already equal to the measurement, thus no information -- from the measurement will be added to the prior when computing the posterior. -- It is an alternative for having an infinite variance in the measurement noise matrix. return (if No_Acceleration then Predicted_Acceleration else Measured_Acceleration); end H; begin if Object.Velocity_Index < Object.Velocity_Measurements'Last then if No_Acceleration and then Measured_Velocity.Norm <= Velocity_Threshold then Object.Velocity_Index := Object.Velocity_Index + 1; Object.Velocity_Measurements (Object.Velocity_Index) := Velocity; end if; Calibrated := False; else Object.Update_Bias; Object.Velocity_Index := 0; Calibrated := True; end if; CDKF.Predict_Update (Object.Filter, F'Access, H'Access, DT, Measured_Acceleration); declare S : constant Kalman.Vector := Object.Filter.State; Orientation : constant Quaternions.Quaternion := (S (1), S (2), S (3), S (4)); Bias : constant Vectors.Direction := (S (5), S (6), S (7), 0.0); use type Vectors.Direction; begin State.Orientation := Quaternions.Normalize (Orientation); State.Angular_Velocity := Velocity - Bias; end; end Integrate; procedure Initialize (Object : in out IMU; Orientation : Quaternions.Quaternion := Quaternions.Identity) is begin Object.Filter := CDKF.Create_Filter (X => To_Tensor ((Orientation (X), Orientation (Y), Orientation (Z), Orientation (W), 0.0, 0.0, 0.0)), P => P_Scale * Identity (7), Q => Diagonal ((1 .. 4 => O_Variance, 5 .. 7 => B_Variance)), R => Diagonal ((1 .. 3 => Z_Variance)), Weights => CDKF.Weights (N => 7, H2 => 3.0)); Object.Velocity_Index := 0; end Initialize; procedure Reset (Object : in out IMU; Orientation : Quaternions.Quaternion := Quaternions.Identity) is State : Kalman.Vector := Object.Filter.State; Tensor_Orientation : constant Kalman.Vector := To_Tensor ((Orientation (X), Orientation (Y), Orientation (Z), Orientation (W))); begin State.Set (Range_Type'(1, 4), Tensor_Orientation); Object.Filter.Set_State (State); end Reset; end AWT.IMUs;
reznikmm/matreshka
Ada
3,660
ads
------------------------------------------------------------------------------ -- -- -- Matreshka Project -- -- -- -- Ada Modeling Framework -- -- -- -- Runtime Library Component -- -- -- ------------------------------------------------------------------------------ -- -- -- Copyright © 2011-2012, Vadim Godunko <[email protected]> -- -- All rights reserved. -- -- -- -- Redistribution and use in source and binary forms, with or without -- -- modification, are permitted provided that the following conditions -- -- are met: -- -- -- -- * Redistributions of source code must retain the above copyright -- -- notice, this list of conditions and the following disclaimer. -- -- -- -- * Redistributions in binary form must reproduce the above copyright -- -- notice, this list of conditions and the following disclaimer in the -- -- documentation and/or other materials provided with the distribution. -- -- -- -- * Neither the name of the Vadim Godunko, IE nor the names of its -- -- contributors may be used to endorse or promote products derived from -- -- this software without specific prior written permission. -- -- -- -- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -- -- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -- -- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -- -- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -- -- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -- -- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED -- -- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -- -- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -- -- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -- -- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -- -- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- -- -- ------------------------------------------------------------------------------ -- $Revision$ $Date$ ------------------------------------------------------------------------------ -- This file is generated, don't edit it. ------------------------------------------------------------------------------ with AMF.Elements.Generic_Hash; function AMF.UML.Remove_Variable_Value_Actions.Hash is new AMF.Elements.Generic_Hash (UML_Remove_Variable_Value_Action, UML_Remove_Variable_Value_Action_Access);
AdaCore/libadalang
Ada
162
ads
generic type Counter is private; package Bar is generic Init : Counter; package Gen is Count : Counter := Counter (Init); end; end Bar;
AdaCore/libadalang
Ada
108
ads
package Pkg is type T is private; private type T is record X : Integer; end record; end Pkg;
AdaCore/Ada_Drivers_Library
Ada
1,925
ads
-- This package was generated by the Ada_Drivers_Library project wizard script package ADL_Config is Architecture : constant String := "ARM"; -- From board definition Board : constant String := "Crazyflie"; -- From command line CPU_Core : constant String := "ARM Cortex-M4F"; -- From mcu definition Device_Family : constant String := "STM32F4"; -- From board definition Device_Name : constant String := "STM32F405RGTx"; -- From board definition Has_Ravenscar_Full_Runtime : constant String := "True"; -- From board definition Has_Ravenscar_SFP_Runtime : constant String := "True"; -- From board definition Has_ZFP_Runtime : constant String := "False"; -- From board definition High_Speed_External_Clock : constant := 8000000; -- From board definition Max_Mount_Name_Length : constant := 128; -- From default value Max_Mount_Points : constant := 2; -- From default value Max_Path_Length : constant := 1024; -- From default value Number_Of_Interrupts : constant := 0; -- From default value Runtime_Name : constant String := "embedded-stm32f4"; -- From default value Runtime_Name_Suffix : constant String := "stm32f4"; -- From board definition Runtime_Profile : constant String := "embedded"; -- From command line Use_Startup_Gen : constant Boolean := False; -- From command line Vendor : constant String := "STMicro"; -- From board definition end ADL_Config;
mgrojo/smk
Ada
1,194
ads
-- ----------------------------------------------------------------------------- -- smk, the smart make -- © 2018 Lionel Draghi <[email protected]> -- SPDX-License-Identifier: APSL-2.0 -- ----------------------------------------------------------------------------- -- Licensed under the Apache License, Version 2.0 (the "License"); -- you may not use this file except in compliance with the License. -- You may obtain a copy of the License at -- http://www.apache.org/licenses/LICENSE-2.0 -- Unless required by applicable law or agreed to in writing, software -- distributed under the License is distributed on an "AS IS" BASIS, -- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -- See the License for the specific language governing permissions and -- limitations under the License. -- ----------------------------------------------------------------------------- -- ----------------------------------------------------------------------------- -- Procedure: Smk.Main specification -- -- Purpose: -- -- Effects: -- -- Limitations: -- -- Performance: -- ----------------------------------------------------------------------------- private procedure Smk.Main;
wookey-project/ewok-legacy
Ada
34
adb
../../stm32f439/Ada/soc-syscfg.adb
reznikmm/matreshka
Ada
6,761
adb
------------------------------------------------------------------------------ -- -- -- Matreshka Project -- -- -- -- Open Document Toolkit -- -- -- -- Runtime Library Component -- -- -- ------------------------------------------------------------------------------ -- -- -- Copyright © 2014, Vadim Godunko <[email protected]> -- -- All rights reserved. -- -- -- -- Redistribution and use in source and binary forms, with or without -- -- modification, are permitted provided that the following conditions -- -- are met: -- -- -- -- * Redistributions of source code must retain the above copyright -- -- notice, this list of conditions and the following disclaimer. -- -- -- -- * Redistributions in binary form must reproduce the above copyright -- -- notice, this list of conditions and the following disclaimer in the -- -- documentation and/or other materials provided with the distribution. -- -- -- -- * Neither the name of the Vadim Godunko, IE nor the names of its -- -- contributors may be used to endorse or promote products derived from -- -- this software without specific prior written permission. -- -- -- -- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -- -- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -- -- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -- -- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -- -- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -- -- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED -- -- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -- -- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -- -- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -- -- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -- -- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- -- -- ------------------------------------------------------------------------------ -- $Revision$ $Date$ ------------------------------------------------------------------------------ with Matreshka.DOM_Documents; with Matreshka.ODF_String_Constants; with ODF.DOM.Iterators; with ODF.DOM.Visitors; package body Matreshka.ODF_Table.Desc_Elements is ------------ -- Create -- ------------ overriding function Create (Parameters : not null access Matreshka.DOM_Elements.Element_L2_Parameters) return Table_Desc_Element_Node is begin return Self : Table_Desc_Element_Node do Matreshka.ODF_Table.Constructors.Initialize (Self'Unchecked_Access, Parameters.Document, Matreshka.ODF_String_Constants.Table_Prefix); end return; end Create; ---------------- -- Enter_Node -- ---------------- overriding procedure Enter_Node (Self : not null access Table_Desc_Element_Node; Visitor : in out XML.DOM.Visitors.Abstract_Visitor'Class; Control : in out XML.DOM.Visitors.Traverse_Control) is begin if Visitor in ODF.DOM.Visitors.Abstract_ODF_Visitor'Class then ODF.DOM.Visitors.Abstract_ODF_Visitor'Class (Visitor).Enter_Table_Desc (ODF.DOM.Table_Desc_Elements.ODF_Table_Desc_Access (Self), Control); else Matreshka.DOM_Elements.Abstract_Element_Node (Self.all).Enter_Node (Visitor, Control); end if; end Enter_Node; -------------------- -- Get_Local_Name -- -------------------- overriding function Get_Local_Name (Self : not null access constant Table_Desc_Element_Node) return League.Strings.Universal_String is pragma Unreferenced (Self); begin return Matreshka.ODF_String_Constants.Desc_Element; end Get_Local_Name; ---------------- -- Leave_Node -- ---------------- overriding procedure Leave_Node (Self : not null access Table_Desc_Element_Node; Visitor : in out XML.DOM.Visitors.Abstract_Visitor'Class; Control : in out XML.DOM.Visitors.Traverse_Control) is begin if Visitor in ODF.DOM.Visitors.Abstract_ODF_Visitor'Class then ODF.DOM.Visitors.Abstract_ODF_Visitor'Class (Visitor).Leave_Table_Desc (ODF.DOM.Table_Desc_Elements.ODF_Table_Desc_Access (Self), Control); else Matreshka.DOM_Elements.Abstract_Element_Node (Self.all).Leave_Node (Visitor, Control); end if; end Leave_Node; ---------------- -- Visit_Node -- ---------------- overriding procedure Visit_Node (Self : not null access Table_Desc_Element_Node; Iterator : in out XML.DOM.Visitors.Abstract_Iterator'Class; Visitor : in out XML.DOM.Visitors.Abstract_Visitor'Class; Control : in out XML.DOM.Visitors.Traverse_Control) is begin if Iterator in ODF.DOM.Iterators.Abstract_ODF_Iterator'Class then ODF.DOM.Iterators.Abstract_ODF_Iterator'Class (Iterator).Visit_Table_Desc (Visitor, ODF.DOM.Table_Desc_Elements.ODF_Table_Desc_Access (Self), Control); else Matreshka.DOM_Elements.Abstract_Element_Node (Self.all).Visit_Node (Iterator, Visitor, Control); end if; end Visit_Node; begin Matreshka.DOM_Documents.Register_Element (Matreshka.ODF_String_Constants.Table_URI, Matreshka.ODF_String_Constants.Desc_Element, Table_Desc_Element_Node'Tag); end Matreshka.ODF_Table.Desc_Elements;
reznikmm/matreshka
Ada
4,876
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.Presentation_Animation_Group_Elements; package Matreshka.ODF_Presentation.Animation_Group_Elements is type Presentation_Animation_Group_Element_Node is new Matreshka.ODF_Presentation.Abstract_Presentation_Element_Node and ODF.DOM.Presentation_Animation_Group_Elements.ODF_Presentation_Animation_Group with null record; overriding function Create (Parameters : not null access Matreshka.DOM_Elements.Element_L2_Parameters) return Presentation_Animation_Group_Element_Node; overriding function Get_Local_Name (Self : not null access constant Presentation_Animation_Group_Element_Node) return League.Strings.Universal_String; overriding procedure Enter_Node (Self : not null access Presentation_Animation_Group_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 Presentation_Animation_Group_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 Presentation_Animation_Group_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_Presentation.Animation_Group_Elements;
AdaCore/gpr
Ada
36,403
adb
------------------------------------------------------------------------------ -- -- -- GPR2 PROJECT MANAGER -- -- -- -- Copyright (C) 2019-2023, AdaCore -- -- -- -- This is free software; you can redistribute it and/or modify it under -- -- terms of the GNU General Public License as published by the Free Soft- -- -- ware Foundation; either version 3, or (at your option) any later ver- -- -- sion. This software 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. 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 COPYING. If not, -- -- see <http://www.gnu.org/licenses/>. -- -- -- ------------------------------------------------------------------------------ with Ada.Characters.Conversions; with Ada.Containers.Indefinite_Hashed_Maps; with Ada.Directories; with Ada.Exceptions; with Ada.Strings.Unbounded; with Ada.Strings.Wide_Wide_Unbounded; with Ada.Streams.Stream_IO; with Ada.Text_IO; with Ada.Wide_Wide_Text_IO; with GNAT.Case_Util; with GNAT.Directory_Operations; with GNAT.OS_Lib; with GNAT.Regpat; with GNATCOLL.OS.Constants; with Gpr_Parser.Analysis; with Gpr_Parser.Common; with Gpr_Parser.Rewriting; with GPR2.Containers; with GPR2.Context; with GPR2.Log; with GPR2.Path_Name; with GPR2.Path_Name.Set; with GPR2.Project; with GPR2.Project.Attribute; with GPR2.Project.Attribute_Index; with GPR2.Project.Configuration; with GPR2.Project.Pretty_Printer; with GPR2.Project.Registry.Attribute; with GPR2.Project.Registry.Pack; with GPR2.Project.Tree; with GPR2.Project.View; with GPRname.Common; with GPRname.Options; with GPRname.Section; with GPRname.Source.Set; with GPRname.Unit; with GPRtools.Util; with Langkit_Support.Text; procedure GPRname.Process (Opt : GPRname.Options.Object) is use Ada; use Ada.Exceptions; use Ada.Streams; use Ada.Strings.Unbounded; use GNAT; use Gpr_Parser.Analysis; use Gpr_Parser.Common; use Gpr_Parser.Rewriting; use GPR2; use GPR2.Project; use GPR2.Project.Attribute; use GPRname.Common; use GPRname.Section; use GPRname.Source; use GPRname.Options; use Langkit_Support.Text; package PRA renames GPR2.Project.Registry.Attribute; package PRP renames GPR2.Project.Registry.Pack; package Language_Sources_Map is new Ada.Containers.Indefinite_Hashed_Maps (Language_Type, Source.Set.Object, Str_Hash_Case_Insensitive, "=", Source.Set."="); use type GNATCOLL.OS.OS_Type; Is_Windows_Host : constant Boolean := GNATCOLL.OS.Constants.OS = GNATCOLL.OS.Windows with Warnings => Off; procedure Search_Directory (Dir_Path : Path_Name.Object; Sect : Section.Object; Processed_Dirs : in out Path_Name_Set.Set; Recursively : Boolean; Compiler_Args : OS_Lib.Argument_List_Access); -- Process stage that searches a directory (recursively or not) for sources -- matching the patterns in section Sect. procedure Put (Str : String; Lvl : Verbosity_Level_Type); -- Call Ada.Text_IO.Put (Str) if Opt.Verbosity is at least Lvl procedure Put_Line (Str : String; Lvl : Verbosity_Level_Type); -- Call Ada.Text_IO.Put_Line (Str) if Opt.Verbosity is at least Lvl procedure Show_Tree_Load_Errors (Tree : GPR2.Project.Tree.Object); -- Print errors/warnings following a project tree load --------- -- Put -- --------- procedure Put (Str : String; Lvl : Verbosity_Level_Type) is begin if Opt.Verbosity >= Lvl then Text_IO.Put (Str); end if; end Put; -------------- -- Put_Line -- -------------- procedure Put_Line (Str : String; Lvl : Verbosity_Level_Type) is begin if Opt.Verbosity >= Lvl then Text_IO.Put_Line (Str); end if; end Put_Line; --------------------------- -- Show_Tree_Load_Errors -- --------------------------- procedure Show_Tree_Load_Errors (Tree : GPR2.Project.Tree.Object) is begin if Opt.Verbosity > None then for M of Tree.Log_Messages.all loop M.Output; end loop; else for C in Tree.Log_Messages.Iterate (False, False, True, True, True) loop GPR2.Log.Element (C).Output; end loop; end if; end Show_Tree_Load_Errors; Tree : GPR2.Project.Tree.Object; Context : GPR2.Context.Object; Project_Path : GPR2.Path_Name.Object := GPR2.Project.Create (Filename_Type (Opt.Project_File)); From_Scratch : constant Boolean := not Project_Path.Exists; -- Indicates that we need to create the project from scratch Project_Dir : constant GPR2.Path_Name.Object := GPR2.Path_Name.Create_Directory (Filename_Optional (Project_Path.Dir_Name)); Naming_Project_Basename : constant String := String (Project_Path.Base_Name) & "_naming.gpr"; Naming_Project_Path : constant Path_Name.Object := Project_Dir.Compose (Filename_Optional (Naming_Project_Basename)); Naming_Project_Name : String := String (Naming_Project_Path.Base_Name); Source_List_File_Basename : constant String := String (Project_Path.Base_Name) & "_source_list.txt"; Source_List_File_Path : constant Path_Name.Object := Project_Dir.Compose (Filename_Optional (Source_List_File_Basename)); Compiler_Path : GPR2.Path_Name.Object; -- Some containers used throughout the process Lang_Sources_Map : Language_Sources_Map.Map; Lang_With_Sources : Language_Vector.Vector; Source_Names : Source.Set.Object; -- Strings used in the GPR node templates for project rewriting Lang_With_Sources_List : Unbounded_String; -- attribute Languages Dir_List : Unbounded_String; -- attribute Source_Dirs function Int_Image (X : Integer) return String is (if X < 0 then Integer'Image (X) else Integer'Image (X) (2 .. Integer'Image (X)'Length)); -- Integer image, removing the leading whitespace for positive integers ---------------------- -- Search_Directory -- ---------------------- procedure Search_Directory (Dir_Path : Path_Name.Object; Sect : Section.Object; Processed_Dirs : in out Path_Name_Set.Set; Recursively : Boolean; Compiler_Args : OS_Lib.Argument_List_Access) is separate; begin -- Properly set the naming project's name (use mixed case) Case_Util.To_Mixed (Naming_Project_Name); -- -- If the project file doesn't exist, create it with the minimum content, -- i.e. an empty project with the expected name. -- if From_Scratch then declare File : Text_IO.File_Type; Project_Name : String := String (Project_Path.Base_Name); begin -- Properly set the main project's name (use mixed case) Case_Util.To_Mixed (Project_Name); Text_IO.Create (File, Text_IO.Out_File, String (Project_Path.Name)); -- Write the bare minimum to be able to parse the project Text_IO.Put_Line (File, "project " & Project_Name & " is"); Text_IO.Put (File, "end " & Project_Name & ";"); Text_IO.Close (File); -- Re-create the object, otherwise the Value field will be wrong Project_Path := GPR2.Project.Create (Filename_Type (Opt.Project_File)); exception when others => raise GPRname_Exception with "could not create project file " & Project_Path.Value; end; else Put_Line ("parsing already existing project file " & Project_Path.Value, Low); end if; -- -- Load the project and its configuration -- -- Load the raw project, as it may define config-relevant attributes declare use GPR2.Containers; RTS_Map : Lang_Value_Map := Lang_Value_Maps.Empty_Map; begin if Opt.RTS /= No_String then RTS_Map.Insert (Ada_Language, Value_Type (Opt.RTS)); end if; Tree.Load_Autoconf (Project_Path, Context, Check_Shared_Lib => False, Target => (if Opt.Target = No_String then No_Name else Name_Type (Opt.Target)), Language_Runtimes => RTS_Map); exception when Project_Error | Processing_Error => Show_Tree_Load_Errors (Tree); raise GPRname_Exception with "failed to load project tree"; when E : others => Show_Tree_Load_Errors (Tree); raise GPRname_Exception with Exception_Information (E); end; -- Some project kinds are not supported in gprname if Tree.Root_Project.Qualifier = K_Aggregate then raise GPRname_Exception with "aggregate projects are not supported"; elsif Tree.Root_Project.Qualifier = K_Aggregate_Library then raise GPRname_Exception with "aggregate library projects are not supported"; end if; if not Tree.Has_Configuration then raise GPRname_Exception with "no configuration loaded for the project"; end if; -- -- Get the compiler path from the project: either a user-defined Compiler -- Driver or the one provided by the configuration project. -- declare Ada_I : constant Attribute_Index.Object := Attribute_Index.Create ("ada"); Proj : constant View.Object := Tree.Root_Project; Conf : constant View.Object := Tree.Configuration.Corresponding_View; Driver_Attr : GPR2.Project.Attribute.Object := GPR2.Project.Attribute.Undefined; Default_Compiler : constant String := GPRtools.Util.Locate_Exec_On_Path ("gcc"); begin if Proj.Has_Attribute (PRA.Compiler.Driver, Ada_I) then -- Use the main project's driver if it is defined Driver_Attr := Proj.Attribute (PRA.Compiler.Driver, Ada_I); elsif Conf.Has_Attribute (PRA.Compiler.Driver, Ada_I) then -- Otherwise, we expect to have a configuration-defined driver Driver_Attr := Conf.Attribute (PRA.Compiler.Driver, Ada_I); else raise GPRname_Exception with "no compiler driver found in configuration project"; end if; Compiler_Path := Path_Name.Create_File (Filename_Type (Driver_Attr.Value.Text)); if Is_Windows_Host and then not Compiler_Path.Exists then pragma Warnings (Off, "this code can never be executed and has been deleted"); Compiler_Path := Compiler_Path.Change_Extension (".exe"); pragma Warnings (On); end if; if not Compiler_Path.Exists then Put_Line ("warning: invalid compiler path from configuration (" & Compiler_Path.Value & ")", Low); if Default_Compiler /= "" then Compiler_Path := Path_Name.Create_File (Filename_Type (Default_Compiler)); Put_Line ("trying default gcc (" & Compiler_Path.Value & ")", Low); else raise GPRname_Exception with "no gcc found on PATH"; end if; end if; end; Put_Line ("compiler path = " & Compiler_Path.Value, Low); -- -- Process the section's directories to get the sources that match the -- naming patterns. Ada sources are checked by the compiler to get details -- of the unit(s) they contain. -- declare Processed_Dirs : Path_Name_Set.Set; Compiler_Args : OS_Lib.Argument_List_Access; begin -- Fill the compiler arguments used to check ada sources Compiler_Args := new OS_Lib.Argument_List (1 .. Natural (Opt.Prep_Switches.Length) + 6); Compiler_Args (1) := new String'("-c"); Compiler_Args (2) := new String'("-gnats"); Compiler_Args (3) := new String'("-gnatu"); for J in 1 .. Opt.Prep_Switches.Last_Index loop Compiler_Args (3 + J) := new String'(Opt.Prep_Switches.Element (J)); end loop; Compiler_Args (4 + Opt.Prep_Switches.Last_Index) := new String'("-x"); Compiler_Args (5 + Opt.Prep_Switches.Last_Index) := new String'("ada"); -- Process sections for Section of Opt.Sections loop Processed_Dirs.Clear; -- Process directories in the section for D of Section.Directories loop Search_Directory (D.Value, Section, Processed_Dirs, D.Is_Recursive, Compiler_Args); Append (Dir_List, Quote (D.Orig) & ','); end loop; end loop; -- Remove the trailing comma in the Source_Dirs template if Length (Dir_List) > 0 then Head (Dir_List, Length (Dir_List) - 1); end if; -- Fill the list of languages for which we have found some sources for Curs in Lang_Sources_Map.Iterate loop declare use type Ada.Containers.Count_Type; Lang : constant Language_Type := Language_Sources_Map.Key (Curs); Sources : constant Source.Set.Object := Language_Sources_Map.Element (Curs); begin if Sources.Length > 0 then Lang_With_Sources.Append (Lang); Append (Lang_With_Sources_List, Quote (String (Lang)) & ","); end if; end; end loop; -- Remove the trailing comma in the Languages template if Length (Lang_With_Sources_List) > 0 then Head (Lang_With_Sources_List, Length (Lang_With_Sources_List) - 1); end if; OS_Lib.Free (Compiler_Args); end; -- -- Rewrite the main project -- declare use Characters.Conversions; function Get_Name_Type (Node : Single_Tok_Node'Class) return Name_Type is (Name_Type (To_UTF8 (Node.Text))); -- Get the string (as a Name_Type) associated with a single-token node function Get_Dir_List return Unbounded_String; -- return Source_Dirs list handling --minimal-dirs switches ------------------ -- Get_Dir_List -- ------------------ function Get_Dir_List return Unbounded_String is begin if not Opt.Minimal_Dirs then return Dir_List; end if; declare Current_Dir : constant GPR2.Path_Name.Object := GPR2.Path_Name.Create_Directory (Filename_Optional (Ada.Directories. Current_Directory)); Dirs : GPR2.Path_Name.Set.Object; -- directories containing sources Added_Dirs : GPR2.Path_Name.Set.Object; -- directories already appended to New_Dir_List New_Dir_List : Unbounded_String; -- value returned if minimal-dirs requested procedure Add_Dir (Dir : GPR2.Path_Name.Object; Recursive : Boolean); -- If Dir part of Dirs, add it to Added_Dirs & New_Dir_List procedure Append_Dir (Dir : GPR2.Path_Name.Object; Use_New_List : Boolean := False); -- If not already done append Dir to Dirs -- If Use_New_List is True, use Added_Dirs & New_Dir_List ------------- -- Add_Dir -- ------------- procedure Add_Dir (Dir : GPR2.Path_Name.Object; Recursive : Boolean) is begin if Dirs.Contains (Dir) then Append_Dir (Dir, True); end if; -- If recursive mode add subdirs in an order equivalent to -- dir/** if Recursive then declare use all type Ada.Directories.File_Kind; D_Search : Ada.Directories.Search_Type; D_Entry : Ada.Directories.Directory_Entry_Type; begin Ada.Directories.Start_Search (D_Search, String (Dir.Value), "", Filter => (Directory => True, Ordinary_File => False, Special_File => False)); while Ada.Directories.More_Entries (D_Search) loop Ada.Directories.Get_Next_Entry (D_Search, D_Entry); case Ada.Directories.Kind (D_Entry) is when Directory => if Ada.Directories.Simple_Name (D_Entry) not in "." | ".." then Add_Dir (GPR2.Path_Name.Create_Directory (Filename_Optional (Ada.Directories.Full_Name (D_Entry))), True); end if; when others => raise Program_Error; end case; end loop; Ada.Directories.End_Search (D_Search); end; end if; end Add_Dir; ---------------- -- Append_Dir -- ---------------- procedure Append_Dir (Dir : GPR2.Path_Name.Object; Use_New_List : Boolean := False) is New_Dir : constant GPR2.Path_Name.Object := GPR2.Path_Name.Relative_Path (Dir, Current_Dir); begin if Dirs.Contains (New_Dir) then if Use_New_List and then not Added_Dirs.Contains (New_Dir) then declare Dir_Name : constant Filename_Optional := New_Dir.Name; begin if not Added_Dirs.Is_Empty then New_Dir_List := New_Dir_List & To_Unbounded_String (", "); end if; -- remove trailing path separator if Dir_Name'Length > 1 then New_Dir_List := New_Dir_List & Quote (String (Dir_Name (Dir_Name'First .. Dir_Name'Last - 1))); end if; end; Added_Dirs.Append (New_Dir); end if; elsif not Use_New_List then Dirs.Append (New_Dir); end if; end Append_Dir; begin for Curs in Lang_Sources_Map.Iterate loop declare Sources : constant Source.Set.Object := Language_Sources_Map.Element (Curs); begin for S_Curs in Sources.Iterate loop Append_Dir (GPR2.Path_Name.Create_Directory (Filename_Optional (GPR2.Path_Name.Relative_Path (Sources (S_Curs).File.Containing_Directory, Current_Dir).Name))); end loop; end; end loop; -- Let New_Dir_List minimal-dirs have an equivalent order for Section of Opt.Sections loop for D of Section.Directories loop Add_Dir (D.Value, D.Is_Recursive); end loop; end loop; return New_Dir_List; end; end Get_Dir_List; Ctx : constant Analysis_Context := Create_Context; Unit : constant Analysis_Unit := Get_From_File (Ctx, Project_Path.Value); Hand : Rewriting_Handle := Start_Rewriting (Ctx); -- The rewriting handles that we will use: -- Note that it may be better to use the Create_* utils if we move -- this to a rewriting package (more efficient). With_H : constant Node_Rewriting_Handle := Create_From_Template (Hand, "with " & To_Wide_Wide_String (Quote (Naming_Project_Basename)) & ";", (1 .. 0 => <>), With_Decl_Rule); Pkg_H : constant Node_Rewriting_Handle := Create_From_Template (Hand, "package Naming renames " & To_Wide_Wide_String (Naming_Project_Name) & ".Naming;", (1 .. 0 => <>), Package_Decl_Rule); Lang_H : constant Node_Rewriting_Handle := Create_From_Template (Hand, "for Languages use (" & To_Wide_Wide_String (To_String (Lang_With_Sources_List)) & ");", (1 .. 0 => <>), Attribute_Decl_Rule); Src_Dirs_H : constant Node_Rewriting_Handle := Create_From_Template (Hand, "for Source_Dirs use (" & To_Wide_Wide_String (To_String (Get_Dir_List)) & ");", (1 .. 0 => <>), Attribute_Decl_Rule); Src_List_File_H : constant Node_Rewriting_Handle := Create_From_Template (Hand, "for Source_List_File use " & To_Wide_Wide_String (Quote (Source_List_File_Basename)) & ";", (1 .. 0 => <>), Attribute_Decl_Rule); function Rewrite_Main (N : Gpr_Node'Class) return Visit_Status; -- Our rewriting callback for the main project: -- - Add a with clause for the naming project, if not already present -- - Add the attributes: Source_List_File, Source_Dirs, Languages. -- - Add the Naming package declaration which renames the one from -- our naming project. ------------------ -- Rewrite_Main -- ------------------ function Rewrite_Main (N : Gpr_Node'Class) return Visit_Status is begin case Kind (N) is when Gpr_With_Decl_List => if not Tree.Root_Project.Has_Imports or else not (for some Imported of Tree.Root_Project.Imports => String (Imported.Path_Name.Base_Name) = String (Naming_Project_Path.Base_Name)) -- ??? -- Base_Name comparisons should not be case insensitive. -- We must cast to String to work around this. then declare Children_Handle : constant Node_Rewriting_Handle := Handle (N); begin Insert_Child (Children_Handle, 1, With_H); end; end if; return Into; when Gpr_Project_Declaration => declare Children : constant Gpr_Node_List := F_Decls (As_Project_Declaration (N)); Children_Handle : constant Node_Rewriting_Handle := Handle (Children); Child : Gpr_Node; In_Bounds : Boolean; begin for I in reverse 1 .. Children_Count (Children_Handle) loop Get_Child (F_Decls (As_Project_Declaration (N)), I, In_Bounds, Child); if not Child.Is_Null then if Kind (Child) = Gpr_Attribute_Decl then declare Attr_Name : constant Attribute_Id := +Get_Name_Type (F_Attr_Name (Child.As_Attribute_Decl). As_Single_Tok_Node); begin if Attr_Name = PRA.Languages.Attr or else Attr_Name = PRA.Source_Dirs.Attr or else Attr_Name = PRA.Source_List_File.Attr or else Attr_Name = PRA.Source_Files.Attr then Remove_Child (Children_Handle, I); end if; end; elsif Kind (Child) = Gpr_Package_Decl then declare Pack_Name : constant Package_Id := +Get_Name_Type (F_Pkg_Name (Child.As_Package_Decl). As_Single_Tok_Node); begin if Pack_Name = PRP.Naming then Remove_Child (Children_Handle, I); end if; end; end if; end if; end loop; Insert_Child (Children_Handle, 1, Src_List_File_H); Insert_Child (Children_Handle, 2, Src_Dirs_H); Insert_Child (Children_Handle, 3, Lang_H); Insert_Child (Children_Handle, 4, Pkg_H); end; return Stop; when others => return Into; end case; end Rewrite_Main; begin Traverse (Root (Unit), Rewrite_Main'Access); declare Result : constant Apply_Result := Apply (Hand); begin if not Result.Success then for D of Result.Diagnostics loop Put_Line (Format_GNU_Diagnostic (Result.Unit, D), Low); end loop; raise GPRname_Exception with "rewriting of main project failed"; end if; end; -- Do a backup if required and there is something to back up (i.e. we -- didn't create the project from scratch) if not Opt.No_Backup and then not From_Scratch then -- Find the files with name <orig_proj_filename>.saved_<0..N> and -- use <orig_proj_filename>.saved_<N+1> as backup file. declare use Regpat; Bkp_Reg : constant String := "^" & String (Project_Path.Simple_Name) & "\.saved_(\d+)$"; Bkp_Matcher : constant Pattern_Matcher := Compile (Bkp_Reg); Matches : Match_Array (0 .. 1); Str : String (1 .. 2_000); Last : Natural; Dir : Directory_Operations.Dir_Type; File : GPR2.Path_Name.Object; Bkp_Number : Natural; New_Bkp_Number : Natural := 0; Success : Boolean; begin begin Directory_Operations.Open (Dir, Project_Path.Dir_Name); exception when Directory_Operations.Directory_Error => raise GPRname_Exception with "cannot open directory " & String (Project_Path.Dir_Name); end; loop Directory_Operations.Read (Dir, Str, Last); exit when Last = 0; File := GPR2.Path_Name.Create_File (Filename_Type (Str (1 .. Last)), Filename_Optional (Project_Path.Dir_Name)); if File.Exists then Match (Bkp_Matcher, Str (1 .. Last), Matches); if Matches (0) /= No_Match then Bkp_Number := Natural'Value (Str (Matches (1).First .. Matches (1).Last)); if Bkp_Number >= New_Bkp_Number then New_Bkp_Number := Bkp_Number + 1; end if; end if; end if; end loop; -- We have found the correct <N> to use, now copy the original -- project file to the backup. declare Bkp_Filename : constant String := String (Project_Path.Value) & ".saved_" & Int_Image (New_Bkp_Number); begin Put_Line ("copying file " & String (Project_Path.Value) & " to file " & Bkp_Filename, Low); OS_Lib.Copy_File (String (Project_Path.Value), Bkp_Filename, Success); end; Directory_Operations.Close (Dir); if not Success then raise GPRname_Exception with "could not copy project file for backup"; end if; end; end if; -- Finally, rewrite the project file declare File : Stream_IO.File_Type; PP : GPR2.Project.Pretty_Printer.Object; begin PP.Pretty_Print (Analysis_Unit => Unit); Stream_IO.Create (File, Stream_IO.Out_File, String (Project_Path.Value)); String'Write (Stream_IO.Stream (File), PP.Result); Stream_IO.Close (File); end; end; -- -- Create the naming project and the source list file -- -- (this code will change once we have the full pretty-printer) declare use GPRname.Unit; Naming_Project_Buffer : Unbounded_String; Implementation_Except : Unbounded_String; File_Src_List : Text_IO.File_Type; Listed_Source_Files : Source.Set.Object; begin Text_IO.Create (File_Src_List, Text_IO.Out_File, String (Source_List_File_Path.Name)); Naming_Project_Buffer := To_Unbounded_String ("abstract project " & Naming_Project_Name & " is " & "package Naming is "); -- Sources for none Ada languages for Curs in Lang_Sources_Map.Iterate loop declare use type Source.Set.Cursor; Lang : constant Language_Type := Language_Sources_Map.Key (Curs); Sources : constant Source.Set.Object := Language_Sources_Map.Element (Curs); begin if Lang /= Ada_Lang then Implementation_Except := To_Unbounded_String ("for Implementation_Exceptions (" & Quote (String (Lang)) & ") use ("); for S_Curs in Sources.Iterate loop Append (Implementation_Except, Quote (String (Sources (S_Curs).File.Simple_Name)) & (if S_Curs = Sources.Last then ");" else ", ")); Listed_Source_Files.Insert (New_Item => Source.Create (File => Sources (S_Curs).File, Language => "", Unit_Based => False) ); -- Write the source to the source list file Text_IO.Put_Line (File_Src_List, String (Sources (S_Curs).File.Simple_Name)); end loop; end if; end; end loop; -- Spec/Body attributes for Ada sources if Lang_Sources_Map.Contains (Ada_Lang) then for S of Lang_Sources_Map (Ada_Lang) loop for U of S.Units loop Append (Naming_Project_Buffer, "for " & (if U.Kind = K_Spec then "Spec" else "Body") & " (" & Quote (String (U.Name)) & ") use " & Quote (String (S.File.Simple_Name)) & (if U.Index_In_Source > 0 then " at " & Int_Image (U.Index_In_Source) & ";" else ";")); end loop; Listed_Source_Files.Insert (New_Item => Source.Create (File => S.File, Language => "", Unit_Based => False) ); -- Write the source to the source list file Text_IO.Put_Line (File_Src_List, String (S.File.Simple_Name)); end loop; end if; -- Adding explicitly added files to the source list if not present yet. -- If the file is already present, verify if the file is not hidden -- by another file found from Source_Dirs search. for Section of Opt.Sections loop for File of Section.Files loop if (for some Listed_File of Listed_Source_Files => Listed_File.File.Value = File.File.Value) then for Listed_File of Listed_Source_Files loop if File.File.Value = Listed_File.File.Value then exit; elsif File.File.Simple_Name = Listed_File.File.Simple_Name then Text_IO.Put_Line (Item => "warning: " & File.File.Value & " hidden by " & Listed_File.File.Value & " found through source dirs"); exit; end if; end loop; else Text_IO.Put_Line (File_Src_List, String (File.File.Simple_Name)); end if; end loop; end loop; Append (Naming_Project_Buffer, Implementation_Except); Append (Naming_Project_Buffer, "end Naming; end " & Naming_Project_Name & ";"); -- We are done with the source list file Text_IO.Close (File_Src_List); -- Parse the naming project buffer and pretty-print the resulting AST -- to the actual naming project file. declare File : Stream_IO.File_Type; PP : GPR2.Project.Pretty_Printer.Object; Ctx : constant Analysis_Context := Create_Context; Unit : constant Analysis_Unit := Get_From_Buffer (Context => Ctx, Filename => "<buffer>", Charset => "ASCII", Buffer => To_String (Naming_Project_Buffer), Rule => Compilation_Unit_Rule); begin if Has_Diagnostics (Unit) then for D of Diagnostics (Unit) loop Ada.Wide_Wide_Text_IO.Put_Line (Ada.Strings.Wide_Wide_Unbounded.To_Wide_Wide_String (D.Message)); end loop; raise GPRname_Exception with "could not create naming project file " & Naming_Project_Path.Value; end if; PP.Pretty_Print (Analysis_Unit => Unit); Stream_IO.Create (File, Stream_IO.Out_File, String (Naming_Project_Path.Name)); String'Write (Stream_IO.Stream (File), PP.Result); Stream_IO.Close (File); end; exception when others => raise GPRname_Exception with "could not create naming project file " & Naming_Project_Path.Value; end; end GPRname.Process;
jscparker/math_packages
Ada
3,388
adb
------------------------------------------------------------------------------- -- package body Text_Utilities; for Random and Basic_Rand. -- Copyright (C) 1995-2018 Jonathan S. Parker -- -- Permission to use, copy, modify, and/or distribute this software for any -- purpose with or without fee is hereby granted, provided that the above -- copyright notice and this permission notice appear in all copies. -- THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES -- WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF -- MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR -- ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES -- WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN -- ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF -- OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. ------------------------------------------------------------------------------- package body Text_Utilities with Spark_Mode => On is subtype Integer_Digit is Parent_Random_Int range 0 .. 9; Digit_Image : constant array(Integer_Digit) of Character_Digit := ('0', '1', '2', '3', '4', '5', '6', '7', '8', '9'); Digit_Value : constant array(Character_Digit) of Integer_Digit := (0, 1, 2, 3, 4, 5, 6, 7, 8, 9); subtype Log_Range is Natural range 0 .. 19; Ten_to_the : constant array(Log_Range) of Parent_Random_Int := (10**00, 10**01, 10**02, 10**03, 10**04, 10**05, 10**06, 10**07, 10**08, 10**09, 10**10, 10**11, 10**12, 10**13, 10**14, 10**15, 10**16, 10**17, 10**18, 10**19); ----------- -- Value -- ----------- -- Random_Int_String contains a 20 digit unsigned integer. -- Every Parent_Random_Int (0 .. 2**64-1) can be represented in 20 decimal digits. -- -- All state values satisfy State.X(i) < 2^64. -- -- The calculation uses the modular arithmetic of modular type Parent_Random_Int. -- If the image string encodes a number > 2^64-1, then of course the calculation -- won't return that value, but all State.X(i) values are in a range that -- is correctly evaluated by this function. -- -- For more general use, one may want to check if the string is out-of-range -- of Parent_Random_Int (i.e. > 2^64-1). To do that, sum the least significant 19 -- digits first. Then check if the most significant digit is '0', '1', or greater. -- If greater the string is out of range, if '1' it might be out of range, and if -- '0' then it's in range. function Value (Random_Int_Image : in Random_Int_String) return Parent_Random_Int is Val : Parent_Random_Int := 0; begin for j in Random_Int_String_Index loop Val := Val + Digit_Value (Random_Int_Image(j))*Ten_to_the(Random_Int_String_Index'Last - j); end loop; return Val; end Value; ----------- -- Image -- ----------- -- Every 64 bit Parent_Random_Int can be represented by a 20 decimal digit -- number. function Image (X : in Parent_Random_Int) return Random_Int_String is Ten : constant Parent_Random_Int := 10; Y : Parent_Random_Int := X; Result : Random_Int_String; begin for j in reverse Random_Int_String_Index loop Result(j) := Digit_Image (Y mod Ten); Y := Y / Ten; end loop; return Result; end Image; end Text_Utilities;
yannickmoy/spat
Ada
8,283
adb
------------------------------------------------------------------------------ -- Copyright (C) 2020 by Heisenbug Ltd. ([email protected]) -- -- This work is free. You can redistribute it and/or modify it under the -- terms of the Do What The Fuck You Want To Public License, Version 2, -- as published by Sam Hocevar. See the LICENSE file for more details. ------------------------------------------------------------------------------ pragma License (Unrestricted); with Ada.Directories; with Ada.Real_Time; with GNATCOLL.Projects; with SI_Units.Metric; with SI_Units.Names; with SPAT.Strings; with SPAT.Log; package body SPAT.GPR_Support is --------------------------------------------------------------------------- -- Image --------------------------------------------------------------------------- function Image is new SI_Units.Metric.Fixed_Image (Item => Duration, Default_Aft => 0, Unit => SI_Units.Names.Second); --------------------------------------------------------------------------- -- SPARK_Name --------------------------------------------------------------------------- function SPARK_Name (Project_Tree : in GNATCOLL.Projects.Project_Tree; Source_File : in GNATCOLL.VFS.Virtual_File) return String; --------------------------------------------------------------------------- -- Get_SPARK_Files --------------------------------------------------------------------------- function Get_SPARK_Files (GPR_File : GNATCOLL.VFS.Filesystem_String) return Strings.File_Names is Start_Time : Ada.Real_Time.Time; use type Ada.Real_Time.Time; begin Load_Project_Files : declare Project_Tree : GNATCOLL.Projects.Project_Tree; begin Start_Time := Ada.Real_Time.Clock; -- Load project tree from command line argument. -- An exception Invalid_Projects may be raised by this call, this is -- handled below. Project_Tree.Load (Root_Project_Path => GNATCOLL.VFS.Create (Full_Filename => GPR_File)); Log.Debug (Message => "GNAT project loaded in " & Image (Value => Ada.Real_Time.To_Duration (TS => Ada.Real_Time.Clock - Start_Time)) & "."); Start_Time := Ada.Real_Time.Clock; declare -- Retrieve all project files recursively. Project_Files : GNATCOLL.VFS.File_Array_Access := Project_Tree.Root_Project.Source_Files (Recursive => True); Capacity : constant Ada.Containers.Count_Type := Project_Files.all'Length; Raw_List : Strings.File_Names (Capacity => Capacity); -- Stores candidate .spark files. Result_List : Strings.File_Names (Capacity => Capacity); -- Filtered list of files. begin Load_Source_Files : begin for F of Project_Files.all loop -- TODO: We should probably check the language of the file -- here, if it's not Ada, we can likely skip it. Add_SPARK_File : declare -- Translate source file name into it's .spark -- counterpart. SPARK_Name : constant String := GPR_Support.SPARK_Name (Project_Tree => Project_Tree, Source_File => F); begin Log.Debug (Message => "Found """ & F.Display_Base_Name & """, checking for """ & SPARK_Name & """...", New_Line => False); declare File_Name : constant SPAT.File_Name := SPAT.File_Name (SPAT.To_Name (SPARK_Name)); begin -- Prevent adding the same file twice. Above we -- retrieve all files from the project, hence in most -- cases we will encounter both a spec and a body file -- which will still result in the same .spark file. if not Raw_List.Contains (Item => File_Name) then Raw_List.Append (New_Item => File_Name); -- This was a new file, so if it exists on disk, add -- it to the result list. if Ada.Directories.Exists (Name => SPARK_Name) then Result_List.Append (New_Item => File_Name); Log.Debug (Message => "added to index."); else Log.Debug (Message => "not found on disk, skipped."); end if; else Log.Debug (Message => "already in index."); end if; end; end Add_SPARK_File; end loop; GNATCOLL.VFS.Unchecked_Free (Arr => Project_Files); end Load_Source_Files; Project_Tree.Unload; Report_Timing : declare Num_Files : constant Ada.Containers.Count_Type := Result_List.Length; use type Ada.Containers.Count_Type; begin Log.Debug (Message => "Search completed in " & Image (Value => Ada.Real_Time.To_Duration (TS => Ada.Real_Time.Clock - Start_Time)) & "," & Num_Files'Image & " file" & (if Num_Files /= 1 then "s" else "") & " found so far."); end Report_Timing; return Result_List; end; exception when GNATCOLL.Projects.Invalid_Project => Log.Error (Message => "Could not load """ & GNATCOLL.VFS."+" (GPR_File) & """!"); end Load_Project_Files; -- If we come here, we had an error. return Result : Strings.File_Names (Capacity => 0) do null; end return; end Get_SPARK_Files; --------------------------------------------------------------------------- -- SPARK_Name --------------------------------------------------------------------------- function SPARK_Name (Project_Tree : in GNATCOLL.Projects.Project_Tree; Source_File : in GNATCOLL.VFS.Virtual_File) return String is use type GNATCOLL.VFS.Filesystem_String; File_Info : constant GNATCOLL.Projects.File_Info := Project_Tree.Info (File => Source_File); Object_Directory : constant String := +GNATCOLL.Projects.Object_Dir (Project => File_Info.Project).Full_Name.all; begin -- .spark files seem to reside in the "gnatprove" subdirectory of the -- object directory defined by the project. As files might come from -- different projects, we query the project associated to the file and -- then use this project's object directory instead of using the object -- directory from the root project. -- This is untested, so maybe we should create some dummy projects to -- test this assumption. -- TODO: Also, aggregate projects -- (GNATCOLL.Projects.Is_Aggregate_Project) do not support the -- File_Info call, so there's still something to be done here... return Ada.Directories.Compose (Containing_Directory => Ada.Directories.Compose (Containing_Directory => Object_Directory, Name => "gnatprove"), Name => Ada.Directories.Base_Name (Name => Source_File.Display_Full_Name), Extension => "spark"); end SPARK_Name; end SPAT.GPR_Support;
zhmu/ananas
Ada
6,927
ads
------------------------------------------------------------------------------ -- GNAT COMPILER COMPONENTS -- -- -- -- G N A T . R E W R I T E _ D A T A -- -- -- -- S p e c -- -- -- -- Copyright (C) 2014-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 can be used to rewrite data on the fly. All occurrences of a -- string (named pattern) will be replaced by another string. -- It is not necessary to load all data in memory and so this package can be -- used for large data chunks like disk files for example. The pattern is -- a standard string and not a regular expression. -- There is no dynamic allocation in the implementation. -- For example, to replace all occurrences of "Gnat" with "GNAT": -- Rewriter : Buffer := Create (Pattern => "Gnat", Value => "GNAT"); -- The output procedure that will receive the rewritten data: -- procedure Do (Data : Stream_Element_Array) is -- begin -- <implementation to handle Data> -- end Do; -- Then: -- Write (Rewriter, "Let's talk about Gnat compiler", Do'Access); -- Write (Rewriter, "Gnat is an Ada compiler", Do'Access); -- Flush (Rewriter, Do'Access); -- Another possible usage is to specify a method to get the input data: -- procedure Get -- (Buffer : out Stream_Element_Array; -- Last : out Stream_Element_Offset) -- is -- begin -- <get some data from a file, a socket, etc...> -- Last := ... -- Buffer := ... -- end Get; -- Then we can rewrite the whole file with: -- Rewrite (Rewriter, Input => Get'Access, Output => Do'Access); with Ada.Streams; use Ada.Streams; package GNAT.Rewrite_Data is type Buffer (<>) is limited private; type Buffer_Ref is access all Buffer; function Create (Pattern, Value : String; Size : Stream_Element_Offset := 1_024) return Buffer; -- Create a rewrite buffer. Pattern is the string to be rewritten as Value. -- Size represents the size of the internal buffer used to store the data -- ready to be output. A larger buffer may improve the performance, as the -- Output routine (see Write, Rewrite below) will be called only when this -- buffer is full. Note that Size cannot be lower than Pattern'Length, and -- if this is the case, then Size value is set to Pattern'Length. function Size (B : Buffer) return Natural; -- Returns the current size of the buffer (count of Stream_Array_Element) procedure Flush (B : in out Buffer; Output : not null access procedure (Data : Stream_Element_Array)); -- Call Output for all remaining data in the buffer. The buffer is -- reset and ready for another use after this call. procedure Reset (B : in out Buffer); pragma Inline (Reset); -- Clear all data in buffer, B is ready for another use. Note that this is -- not needed after a Flush. Note: all data remaining in Buffer is lost. procedure Write (B : in out Buffer; Data : Stream_Element_Array; Output : not null access procedure (Data : Stream_Element_Array)); -- Write Data into the buffer, call Output for any prepared data. Flush -- must be called when the last piece of Data as been sent in the Buffer. procedure Rewrite (B : in out Buffer; Input : not null access procedure (Buffer : out Stream_Element_Array; Last : out Stream_Element_Offset); Output : not null access procedure (Data : Stream_Element_Array)); -- Read data from Input, rewrite it, and then call Output. When there is -- no more data to be read from Input, Last must be set to 0. Before -- leaving this routine, call Flush above to send all remaining data to -- Output. procedure Link (From : in out Buffer; To : Buffer_Ref); -- Link two rewrite buffers. That is, all data sent to From buffer will be -- rewritten and then passed to the To rewrite buffer. private type Buffer (Size, Size_Pattern, Size_Value : Stream_Element_Offset) is limited record Pos_C : Stream_Element_Offset; -- last valid element in Current Pos_B : Stream_Element_Offset; -- last valid element in Buffer Next : Buffer_Ref; -- A link to another rewriter if any Buffer : Stream_Element_Array (1 .. Size); -- Fully prepared/rewritten data waiting to be output Current : Stream_Element_Array (1 .. Size_Pattern); -- Current data checked, this buffer contains every piece of data -- starting with the pattern. It means that at any point: -- Current (1 .. Pos_C) = Pattern (1 .. Pos_C). Pattern : Stream_Element_Array (1 .. Size_Pattern); -- The pattern to look for Value : Stream_Element_Array (1 .. Size_Value); -- The value the pattern is replaced by end record; end GNAT.Rewrite_Data;
rbkmoney/swagger-codegen
Ada
7,711
ads
-- Swagger Petstore -- This is a sample server Petstore server. You can find out more about Swagger at [http://swagger.io](http://swagger.io) or on [irc.freenode.net, #swagger](http://swagger.io/irc/). For this sample, you can use the api key `special-key` to test the authorization filters. -- -- OpenAPI spec version: 1.0.0 -- Contact: [email protected] -- -- NOTE: This package is auto generated by the swagger code generator 2.3.0-SNAPSHOT. -- https://github.com/swagger-api/swagger-codegen.git -- Do not edit the class manually. with Swagger.Streams; with Ada.Containers.Vectors; package Samples.Petstore.Models is -- ------------------------------ -- An uploaded response -- Describes the result of uploading an image resource -- ------------------------------ type ApiResponse_Type is record Code : Integer; P_Type : Swagger.UString; Message : Swagger.UString; end record; package ApiResponse_Type_Vectors is new Ada.Containers.Vectors (Index_Type => Positive, Element_Type => ApiResponse_Type); procedure Serialize (Into : in out Swagger.Streams.Output_Stream'Class; Name : in String; Value : in ApiResponse_Type); procedure Serialize (Into : in out Swagger.Streams.Output_Stream'Class; Name : in String; Value : in ApiResponse_Type_Vectors.Vector); procedure Deserialize (From : in Swagger.Value_Type; Name : in String; Value : out ApiResponse_Type); procedure Deserialize (From : in Swagger.Value_Type; Name : in String; Value : out ApiResponse_Type_Vectors.Vector); -- ------------------------------ -- Pet catehgry -- A category for a pet -- ------------------------------ type Category_Type is record Id : Swagger.Long; Name : Swagger.UString; end record; package Category_Type_Vectors is new Ada.Containers.Vectors (Index_Type => Positive, Element_Type => Category_Type); procedure Serialize (Into : in out Swagger.Streams.Output_Stream'Class; Name : in String; Value : in Category_Type); procedure Serialize (Into : in out Swagger.Streams.Output_Stream'Class; Name : in String; Value : in Category_Type_Vectors.Vector); procedure Deserialize (From : in Swagger.Value_Type; Name : in String; Value : out Category_Type); procedure Deserialize (From : in Swagger.Value_Type; Name : in String; Value : out Category_Type_Vectors.Vector); -- ------------------------------ -- Pet Tag -- A tag for a pet -- ------------------------------ type Tag_Type is record Id : Swagger.Long; Name : Swagger.UString; end record; package Tag_Type_Vectors is new Ada.Containers.Vectors (Index_Type => Positive, Element_Type => Tag_Type); procedure Serialize (Into : in out Swagger.Streams.Output_Stream'Class; Name : in String; Value : in Tag_Type); procedure Serialize (Into : in out Swagger.Streams.Output_Stream'Class; Name : in String; Value : in Tag_Type_Vectors.Vector); procedure Deserialize (From : in Swagger.Value_Type; Name : in String; Value : out Tag_Type); procedure Deserialize (From : in Swagger.Value_Type; Name : in String; Value : out Tag_Type_Vectors.Vector); -- ------------------------------ -- a User -- A User who is purchasing from the pet store -- ------------------------------ type User_Type is record Id : Swagger.Long; Username : Swagger.UString; First_Name : Swagger.UString; Last_Name : Swagger.UString; Email : Swagger.UString; Password : Swagger.UString; Phone : Swagger.UString; User_Status : Integer; end record; package User_Type_Vectors is new Ada.Containers.Vectors (Index_Type => Positive, Element_Type => User_Type); procedure Serialize (Into : in out Swagger.Streams.Output_Stream'Class; Name : in String; Value : in User_Type); procedure Serialize (Into : in out Swagger.Streams.Output_Stream'Class; Name : in String; Value : in User_Type_Vectors.Vector); procedure Deserialize (From : in Swagger.Value_Type; Name : in String; Value : out User_Type); procedure Deserialize (From : in Swagger.Value_Type; Name : in String; Value : out User_Type_Vectors.Vector); -- ------------------------------ -- Pet Order -- An order for a pets from the pet store -- ------------------------------ type Order_Type is record Id : Swagger.Long; Pet_Id : Swagger.Long; Quantity : Integer; Ship_Date : Swagger.Datetime; Status : Swagger.UString; Complete : Boolean; end record; package Order_Type_Vectors is new Ada.Containers.Vectors (Index_Type => Positive, Element_Type => Order_Type); procedure Serialize (Into : in out Swagger.Streams.Output_Stream'Class; Name : in String; Value : in Order_Type); procedure Serialize (Into : in out Swagger.Streams.Output_Stream'Class; Name : in String; Value : in Order_Type_Vectors.Vector); procedure Deserialize (From : in Swagger.Value_Type; Name : in String; Value : out Order_Type); procedure Deserialize (From : in Swagger.Value_Type; Name : in String; Value : out Order_Type_Vectors.Vector); -- ------------------------------ -- a Pet -- A pet for sale in the pet store -- ------------------------------ type Pet_Type is record Id : Swagger.Long; Category : Samples.Petstore.Models.Category_Type; Name : Swagger.UString; Photo_Urls : Swagger.UString_Vectors.Vector; Tags : Samples.Petstore.Models.Tag_Type_Vectors.Vector; Status : Swagger.UString; end record; package Pet_Type_Vectors is new Ada.Containers.Vectors (Index_Type => Positive, Element_Type => Pet_Type); procedure Serialize (Into : in out Swagger.Streams.Output_Stream'Class; Name : in String; Value : in Pet_Type); procedure Serialize (Into : in out Swagger.Streams.Output_Stream'Class; Name : in String; Value : in Pet_Type_Vectors.Vector); procedure Deserialize (From : in Swagger.Value_Type; Name : in String; Value : out Pet_Type); procedure Deserialize (From : in Swagger.Value_Type; Name : in String; Value : out Pet_Type_Vectors.Vector); end Samples.Petstore.Models;
sparre/Ada-2012-Examples
Ada
897
adb
package body Mixed_Enumeration_And_Integer is function "+" (Item : Integer_Values) return Object is begin return (State => Integer, I => Item); end "+"; function "+" (Item : Enumeration_Values) return Object is begin return (State => Enumeration, E => Item); end "+"; function "+" (Item : Object) return Integer_Values is begin return Item.I; end "+"; function "+" (Item : Object) return Enumeration_Values is begin return Item.E; end "+"; function "=" (Left : Integer_Values; Right : Object) return Boolean is begin return Right.State = Integer and then Left = Right.I; end "="; function "=" (Left : Enumeration_Values; Right : Object) return Boolean is begin return Right.State = Enumeration and then Left = Right.E; end "="; end Mixed_Enumeration_And_Integer;
ohenley/ada-util
Ada
1,525
ads
----------------------------------------------------------------------- -- streams.buffered.tests -- Unit tests for buffered streams -- Copyright (C) 2010, 2011 Stephane Carrez -- Written by Stephane Carrez ([email protected]) -- -- Licensed under the Apache License, Version 2.0 (the "License"); -- you may not use this file except in compliance with the License. -- You may obtain a copy of the License at -- -- http://www.apache.org/licenses/LICENSE-2.0 -- -- Unless required by applicable law or agreed to in writing, software -- distributed under the License is distributed on an "AS IS" BASIS, -- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -- See the License for the specific language governing permissions and -- limitations under the License. ----------------------------------------------------------------------- with Util.Tests; package Util.Streams.Buffered.Tests is procedure Add_Tests (Suite : in Util.Tests.Access_Test_Suite); type Test is new Util.Tests.Test with null record; procedure Test_Read_Write (T : in out Test); procedure Test_Write (T : in out Test); -- procedure Test_Read_File_Missing (T : in out Test); -- procedure Test_Read_File_Truncate (T : in out Test); -- procedure Test_Write_File (T : in out Test); -- procedure Test_Find_File_Path (T : in out Test); -- Write on a buffer and force regular flush on a larger buffer procedure Test_Write_Stream (T : in out Test); end Util.Streams.Buffered.Tests;
reznikmm/matreshka
Ada
3,694
ads
------------------------------------------------------------------------------ -- -- -- Matreshka Project -- -- -- -- Open Document Toolkit -- -- -- -- Runtime Library Component -- -- -- ------------------------------------------------------------------------------ -- -- -- Copyright © 2014, Vadim Godunko <[email protected]> -- -- All rights reserved. -- -- -- -- Redistribution and use in source and binary forms, with or without -- -- modification, are permitted provided that the following conditions -- -- are met: -- -- -- -- * Redistributions of source code must retain the above copyright -- -- notice, this list of conditions and the following disclaimer. -- -- -- -- * Redistributions in binary form must reproduce the above copyright -- -- notice, this list of conditions and the following disclaimer in the -- -- documentation and/or other materials provided with the distribution. -- -- -- -- * Neither the name of the Vadim Godunko, IE nor the names of its -- -- contributors may be used to endorse or promote products derived from -- -- this software without specific prior written permission. -- -- -- -- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -- -- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -- -- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -- -- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -- -- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -- -- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED -- -- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -- -- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -- -- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -- -- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -- -- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- -- -- ------------------------------------------------------------------------------ -- $Revision$ $Date$ ------------------------------------------------------------------------------ with XML.DOM.Attributes; package ODF.DOM.Text_Prefix_Attributes is pragma Preelaborate; type ODF_Text_Prefix_Attribute is limited interface and XML.DOM.Attributes.DOM_Attribute; type ODF_Text_Prefix_Attribute_Access is access all ODF_Text_Prefix_Attribute'Class with Storage_Size => 0; end ODF.DOM.Text_Prefix_Attributes;
zhmu/ananas
Ada
8,703
adb
------------------------------------------------------------------------------ -- -- -- GNAT COMPILER COMPONENTS -- -- -- -- S Y S T E M . V A L U E _ D -- -- -- -- B o d y -- -- -- -- Copyright (C) 2020-2022, Free Software Foundation, Inc. -- -- -- -- GNAT is free software; you can redistribute it and/or modify it under -- -- terms of the GNU General Public License as published by the Free Soft- -- -- ware Foundation; either version 3, or (at your option) any later ver- -- -- sion. GNAT is distributed in the hope that it will be useful, but WITH- -- -- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY -- -- or FITNESS FOR A PARTICULAR PURPOSE. -- -- -- -- As a special exception under Section 7 of GPL version 3, you are granted -- -- additional permissions described in the GCC Runtime Library Exception, -- -- version 3.1, as published by the Free Software Foundation. -- -- -- -- You should have received a copy of the GNU General Public License and -- -- a copy of the GCC Runtime Library Exception along with this program; -- -- see the files COPYING3 and COPYING.RUNTIME respectively. If not, see -- -- <http://www.gnu.org/licenses/>. -- -- -- -- GNAT was originally developed by the GNAT team at New York University. -- -- Extensive contributions were provided by Ada Core Technologies Inc. -- -- -- ------------------------------------------------------------------------------ with System.Unsigned_Types; use System.Unsigned_Types; with System.Val_Util; use System.Val_Util; with System.Value_R; package body System.Value_D is pragma Assert (Int'Size <= Uns'Size); -- We need an unsigned type large enough to represent the mantissa package Impl is new Value_R (Uns, 2**(Int'Size - 1), Round => False); -- We do not use the Extra digit for decimal fixed-point types function Integer_to_Decimal (Str : String; Val : Uns; Base : Unsigned; ScaleB : Integer; Minus : Boolean; Scale : Integer) return Int; -- Convert the real value from integer to decimal representation ------------------------ -- Integer_to_Decimal -- ------------------------ function Integer_to_Decimal (Str : String; Val : Uns; Base : Unsigned; ScaleB : Integer; Minus : Boolean; Scale : Integer) return Int is function Safe_Expont (Base : Int; Exp : in out Natural; Factor : Int) return Int; -- Return (Base ** Exp) * Factor if the computation does not overflow, -- or else the number of the form (Base ** K) * Factor with the largest -- magnitude if the former computation overflows. In both cases, Exp is -- updated to contain the remaining power in the computation. Note that -- Factor is expected to be positive in this context. function Unsigned_To_Signed (Val : Uns) return Int; -- Convert an integer value from unsigned to signed representation ----------------- -- Safe_Expont -- ----------------- function Safe_Expont (Base : Int; Exp : in out Natural; Factor : Int) return Int is pragma Assert (Base /= 0 and then Factor > 0); Max : constant Int := Int'Last / Base; Result : Int := Factor; begin while Exp > 0 and then Result <= Max loop Result := Result * Base; Exp := Exp - 1; end loop; return Result; end Safe_Expont; ------------------------ -- Unsigned_To_Signed -- ------------------------ function Unsigned_To_Signed (Val : Uns) return Int is begin -- Deal with overflow cases, and also with largest negative number if Val > Uns (Int'Last) then if Minus and then Val = Uns (-(Int'First)) then return Int'First; else Bad_Value (Str); end if; -- Negative values elsif Minus then return -(Int (Val)); -- Positive values else return Int (Val); end if; end Unsigned_To_Signed; begin -- If the base of the value is 10 or its scaling factor is zero, then -- add the scales (they are defined in the opposite sense) and apply -- the result to the value, checking for overflow in the process. if Base = 10 or else ScaleB = 0 then declare S : Integer := ScaleB + Scale; V : Uns := Val; begin while S < 0 loop V := V / 10; S := S + 1; end loop; while S > 0 loop if V <= Uns'Last / 10 then V := V * 10; S := S - 1; else Bad_Value (Str); end if; end loop; return Unsigned_To_Signed (V); end; -- If the base of the value is not 10, use a scaled divide operation -- to compute Val * (Base ** ScaleB) * (10 ** Scale). else declare B : constant Int := Int (Base); S : constant Integer := ScaleB; V : Uns := Val; Y, Z, Q, R : Int; begin -- If S is too negative, then drop trailing digits if S < 0 then declare LS : Integer := -S; begin Y := 10 ** Integer'Max (0, Scale); Z := Safe_Expont (B, LS, 10 ** Integer'Max (0, -Scale)); for J in 1 .. LS loop V := V / Uns (B); end loop; end; -- If S is too positive, then scale V up, which may then overflow elsif S > 0 then declare LS : Integer := S; begin Y := Safe_Expont (B, LS, 10 ** Integer'Max (0, Scale)); Z := 10 ** Integer'Max (0, -Scale); for J in 1 .. LS loop if V <= Uns'Last / Uns (B) then V := V * Uns (B); else Bad_Value (Str); end if; end loop; end; -- The case S equal to zero should have been handled earlier else raise Program_Error; end if; -- Perform a scale divide operation with rounding to match 'Image Scaled_Divide (Unsigned_To_Signed (V), Y, Z, Q, R, Round => True); return Q; end; end if; exception when Constraint_Error => Bad_Value (Str); end Integer_to_Decimal; ------------------ -- Scan_Decimal -- ------------------ function Scan_Decimal (Str : String; Ptr : not null access Integer; Max : Integer; Scale : Integer) return Int is Base : Unsigned; ScaleB : Integer; Extra : Unsigned; Minus : Boolean; Val : Uns; begin Val := Impl.Scan_Raw_Real (Str, Ptr, Max, Base, ScaleB, Extra, Minus); return Integer_to_Decimal (Str, Val, Base, ScaleB, Minus, Scale); end Scan_Decimal; ------------------- -- Value_Decimal -- ------------------- function Value_Decimal (Str : String; Scale : Integer) return Int is Base : Unsigned; ScaleB : Integer; Extra : Unsigned; Minus : Boolean; Val : Uns; begin Val := Impl.Value_Raw_Real (Str, Base, ScaleB, Extra, Minus); return Integer_to_Decimal (Str, Val, Base, ScaleB, Minus, Scale); end Value_Decimal; end System.Value_D;
KHYehor/Parallel-Programming
Ada
2,331
adb
----------------Main programm------------------------ --Parallel and distributed computing. --Labwork 1. Ada. Subprograms and packages --Khilchenko Yehor --IP-74 --02.10.2019 --Func1: d = A*((B+C)*(MA*ME)); --Func2: h = MAX(MF + MG*(MH*ML)); --Func3: s = MIN(A*TRANS(MB*MM) + B*SORT(C)); with Data, Text_IO, Ada.Integer_Text_IO, System.Multiprocessors; use Text_IO, Ada.Integer_Text_IO, System.Multiprocessors; procedure Main_Lab1 is n: Integer := 5 ; package data1 is new data (n); use data1; CPU0: CPU_Range :=0; CPU1: CPU_Range :=1; CPU2: CPU_Range :=2; f1, f2, f3:Integer; procedure tasks is task T1 is pragma Priority(1); pragma CPU(CPU0); end; task body T1 is A, B, C: Vector; MA, ME: Matrix; begin Put_Line("T1 started"); Vector_Filling_Ones(A); Vector_Filling_Ones(B); Vector_Filling_Ones(C); Matrix_Filling_Ones(MA); Matrix_Filling_Ones(ME); f1:=Func1(A, B, C, MA, ME); --delay(1.0); end T1; task T2 is pragma Priority(1); pragma CPU(CPU1); end; task body T2 is MF, MG, MH, ML: Matrix; begin Put_Line("T2 started"); Matrix_Filling_Ones(MF); Matrix_Filling_Ones(MG); Matrix_Filling_Ones(MH); Matrix_Filling_Ones(ML); f2:=Func2(MF, MG, MH, ML); --delay(1.0); end T2; task T3 is pragma Priority(1); pragma CPU(CPU2); end; task body T3 is MB, MM : Matrix; A, B, C: Vector; begin Put_Line("T3 started"); Vector_Filling_Ones(A); Vector_Filling_Ones(B); Vector_Filling_Ones(C); Matrix_Filling_Ones(MB); Matrix_Filling_Ones(MM); f3:=Func3(A, B, C, MB, MM); --delay(1.0); end T3; begin null; end tasks; Begin tasks; Put_Line("Func1: d = A*((B+C)*(MA*ME))"); Put(f1); New_Line; New_Line; Put_Line("T1 finished"); Put_Line("Func2: h = MAX(MF + MG*(MH*ML))"); Put(f2); New_Line; New_Line; Put_Line("T2 finished"); Put_Line("Func3: s = MIN(A*TRANS(MB*MM) + B*SORT(C))"); Put(f3); New_Line; New_Line; Put_Line("T3 finished"); End Main_Lab1;
docandrew/sdlada
Ada
21,664
adb
-------------------------------------------------------------------------------------------------------------------- -- Copyright (c) 2013-2020, Luke A. Guest -- -- This software is provided 'as-is', without any express or implied -- warranty. In no event will the authors be held liable for any damages -- arising from the use of this software. -- -- Permission is granted to anyone to use this software for any purpose, -- including commercial applications, and to alter it and redistribute it -- freely, subject to the following restrictions: -- -- 1. The origin of this software must not be misrepresented; you must not -- claim that you wrote the original software. If you use this software -- in a product, an acknowledgment in the product documentation would be -- appreciated but is not required. -- -- 2. Altered source versions must be plainly marked as such, and must not be -- misrepresented as being the original software. -- -- 3. This notice may not be removed or altered from any source -- distribution. -------------------------------------------------------------------------------------------------------------------- with Ada.Unchecked_Conversion; with Interfaces; with Interfaces.C; with Interfaces.C.Strings; with SDL.Error; -- with SDL.Video.Surfaces.Makers; -- with SDL.Log; package body SDL.Video.Windows is package C renames Interfaces.C; use type Interfaces.Unsigned_32; use type C.int; use type SDL.C_Pointers.Windows_Pointer; use type System.Address; function Undefined_Window_Position (Display : Natural := 0) return SDL.Natural_Coordinate is Mask : constant Interfaces.Unsigned_32 := 16#1FFF_0000#; begin return C.int (Interfaces.Unsigned_32 (Display) or Mask); end Undefined_Window_Position; function Centered_Window_Position (Display : Natural := 0) return SDL.Natural_Coordinate is Mask : constant Interfaces.Unsigned_32 := 16#2FFF_0000#; begin return C.int (Interfaces.Unsigned_32 (Display) or Mask); end Centered_Window_Position; procedure Increment_Windows is begin Total_Windows_Created := Total_Windows_Created + 1; end Increment_Windows; procedure Decrement_Windows is begin Total_Windows_Created := Total_Windows_Created - 1; end Decrement_Windows; overriding procedure Finalize (Self : in out Window) is procedure SDL_Destroy (W : in SDL.C_Pointers.Windows_Pointer) with Import => True, Convention => C, External_Name => "SDL_DestroyWindow"; begin -- SDL.Log.Put_Debug ("Windows.Finalize: " & (if Self.Internal = null then "null" else "not null") & -- " " & (if Self.Owns = True then "owns" else "Doesn't own")); -- Make sure we don't delete this twice! if Self.Internal /= null and then Self.Owns then -- SDL.Log.Put_Debug ("Windows.Finalize: Deleting"); SDL_Destroy (Self.Internal); Self.Internal := null; Decrement_Windows; end if; end Finalize; function Get_Brightness (Self : in Window) return Brightness is function SDL_Get_Brightness (W : in SDL.C_Pointers.Windows_Pointer) return C.C_float with Import => True, Convention => C, External_Name => "SDL_GetWindowBrightness"; begin return Brightness (SDL_Get_Brightness (Self.Internal)); end Get_Brightness; procedure Set_Brightness (Self : in out Window; How_Bright : in Brightness) is function SDL_Set_Brightness (W : in SDL.C_Pointers.Windows_Pointer; B : in C.C_float) return C.int with Import => True, Convention => C, External_Name => "SDL_SetWindowBrightness"; Result : C.int := SDL_Set_Brightness (Self.Internal, C.C_float (How_Bright)); begin if Result /= Success then raise Window_Error with SDL.Error.Get; end if; end Set_Brightness; -- TODO: Try to see if we can just see User_Data_Access as the return type from the C function. function To_Data_Access is new Ada.Unchecked_Conversion (Source => System.Address, Target => User_Data_Access); function To_Address is new Ada.Unchecked_Conversion (Source => User_Data_Access, Target => System.Address); -- TODO: Make this and Set_Data generic. function Get_Data (Self : in Window; Name : in String) return User_Data_Access is function SDL_Get_Window_Data (W : in SDL.C_Pointers.Windows_Pointer; Name : in C.Strings.chars_ptr) return System.Address with Import => True, Convention => C, External_Name => "SDL_GetWindowData"; C_Name_Str : C.Strings.chars_ptr := C.Strings.New_String (Name); Item : User_Data_Access := To_Data_Access (SDL_Get_Window_Data (Self.Internal, C_Name_Str)); begin C.Strings.Free (C_Name_Str); return Item; end Get_Data; function Set_Data (Self : in out Window; Name : in String; Item : in User_Data_Access) return User_Data_Access is function SDL_Set_Window_Data (W : in SDL.C_Pointers.Windows_Pointer; Name : in C.Strings.chars_ptr; User_Data : in System.Address) return System.Address with Import => True, Convention => C, External_Name => "SDL_SetWindowData"; C_Name_Str : C.Strings.chars_ptr := C.Strings.New_String (Name); Previous_Data : User_Data_Access := To_Data_Access (SDL_Set_Window_Data (Self.Internal, C_Name_Str, To_Address (Item))); begin C.Strings.Free (C_Name_Str); return Previous_Data; end Set_Data; function Display_Index (Self : in Window) return SDL.Video.Displays.Display_Indices is function SDL_Get_Window_Display_Index (W : in SDL.C_Pointers.Windows_Pointer) return C.int with Import => True, Convention => C, External_Name => "SDL_GetWindowDisplayIndex"; Total : C.int := SDL_Get_Window_Display_Index (Self.Internal); begin if Total < 0 then raise Window_Error with SDL.Error.Get; end if; return SDL.Video.Displays.Display_Indices (Total + 1); end Display_Index; procedure Get_Display_Mode (Self : in Window; Mode : out SDL.Video.Displays.Mode) is function SDL_Get_Window_Display_Mode (W : in SDL.C_Pointers.Windows_Pointer; M : out SDL.Video.Displays.Mode) return C.int with Import => True, Convention => C, External_Name => "SDL_GetWindowDisplayMode"; Result : C.int := SDL_Get_Window_Display_Mode (Self.Internal, Mode); begin if Result /= Success then raise Window_Error with SDL.Error.Get; end if; end Get_Display_Mode; procedure Set_Display_Mode (Self : in out Window; Mode : in SDL.Video.Displays.Mode) is function SDL_Set_Window_Display_Mode (W : in SDL.C_Pointers.Windows_Pointer; M : in SDL.Video.Displays.Mode) return C.int with Import => True, Convention => C, External_Name => "SDL_SetWindowDisplayMode"; Result : C.int := SDL_Set_Window_Display_Mode (Self.Internal, Mode); begin if Result /= Success then raise Window_Error with SDL.Error.Get; end if; end Set_Display_Mode; function Get_Flags (Self : in Window) return Window_Flags is function SDL_Get_Window_Flags (W : in SDL.C_Pointers.Windows_Pointer) return Window_Flags with Import => True, Convention => C, External_Name => "SDL_GetWindowFlags"; begin return SDL_Get_Window_Flags (Self.Internal); end Get_Flags; function From_ID (Window_ID : in ID) return Window is function SDL_Get_Window_From_ID (W : in ID) return SDL.C_Pointers.Windows_Pointer with Import => True, Convention => C, External_Name => "SDL_GetWindowFromID"; begin return W : constant Window := (Ada.Finalization.Limited_Controlled with Internal => SDL_Get_Window_From_ID (Window_ID), Owns => False) do null; end return; end From_ID; procedure Get_Gamma_Ramp (Self : in Window; Red, Green, Blue : out SDL.Video.Pixel_Formats.Gamma_Ramp) is function SDL_Get_Window_Gamma_Ramp (W : in SDL.C_Pointers.Windows_Pointer; R, G, B : out SDL.Video.Pixel_Formats.Gamma_Ramp) return C.int with Import => True, Convention => C, External_Name => "SDL_GetWindowGammaRamp"; Result : C.int := SDL_Get_Window_Gamma_Ramp (Self.Internal, Red, Green, Blue); begin if Result /= Success then raise Window_Error with SDL.Error.Get; end if; end Get_Gamma_Ramp; procedure Set_Gamma_Ramp (Self : in out Window; Red, Green, Blue : in SDL.Video.Pixel_Formats.Gamma_Ramp) is function SDL_Set_Window_Gamma_Ramp (W : in SDL.C_Pointers.Windows_Pointer; R, G, B : in SDL.Video.Pixel_Formats.Gamma_Ramp) return C.int with Import => True, Convention => C, External_Name => "SDL_SetWindowGammaRamp"; Result : C.int := SDL_Set_Window_Gamma_Ramp (Self.Internal, Red, Green, Blue); begin if Result /= Success then raise Window_Error with SDL.Error.Get; end if; end Set_Gamma_Ramp; function Is_Grabbed (Self : in Window) return Boolean is function SDL_Get_Window_Grab (W : in SDL.C_Pointers.Windows_Pointer) return SDL_Bool with Import => True, Convention => C, External_Name => "SDL_GetWindowGrab"; begin return (SDL_Get_Window_Grab (Self.Internal) = SDL_True); end Is_Grabbed; procedure Set_Grabbed (Self : in out Window; Grabbed : in Boolean := True) is procedure SDL_Set_Window_Grab (W : in SDL.C_Pointers.Windows_Pointer; G : in SDL_Bool) with Import => True, Convention => C, External_Name => "SDL_SetWindowGrab"; begin SDL_Set_Window_Grab (Self.Internal, (if Grabbed = True then SDL_True else SDL_False)); end Set_Grabbed; function Get_ID (Self : in Window) return ID is function SDL_Get_Window_ID (W : in SDL.C_Pointers.Windows_Pointer) return ID with Import => True, Convention => C, External_Name => "SDL_GetWindowID"; begin return SDL_Get_Window_ID (Self.Internal); end Get_ID; function Get_Maximum_Size (Self : in Window) return SDL.Sizes is procedure SDL_Get_Window_Maximum_Size (Win : in SDL.C_Pointers.Windows_Pointer; W, H : out SDL.Dimension) with Import => True, Convention => C, External_Name => "SDL_GetWindowMaximumSize"; W, H : C.int := 0; begin SDL_Get_Window_Maximum_Size (Self.Internal, W, H); return SDL.Sizes'(Width => W, Height => H); end Get_Maximum_Size; procedure Set_Maximum_Size (Self : in out Window; Size : in SDL.Sizes) is procedure SDL_Get_Window_Maximum_Size (Win : in SDL.C_Pointers.Windows_Pointer; W, H : in C.int) with Import => True, Convention => C, External_Name => "SDL_SetWindowMaximumSize"; begin SDL_Get_Window_Maximum_Size (Self.Internal, C.int (Size.Width), C.int (Size.Height)); end Set_Maximum_Size; function Get_Minimum_Size (Self : in Window) return SDL.Sizes is procedure SDL_Get_Window_Minimum_Size (Win : in SDL.C_Pointers.Windows_Pointer; W, H : out SDL.Dimension) with Import => True, Convention => C, External_Name => "SDL_GetWindowMinimumSize"; W, H : C.int := 0; begin SDL_Get_Window_Minimum_Size (Self.Internal, W, H); return SDL.Sizes'(Width => W, Height => H); end Get_Minimum_Size; procedure Set_Minimum_Size (Self : in out Window; Size : in SDL.Sizes) is procedure SDL_Get_Window_Minimum_Size (Win : in SDL.C_Pointers.Windows_Pointer; W, H : in C.int) with Import => True, Convention => C, External_Name => "SDL_SetWindowMinimumSize"; begin SDL_Get_Window_Minimum_Size (Self.Internal, C.int (Size.Width), C.int (Size.Height)); end Set_Minimum_Size; function Pixel_Format (Self : in Window) return SDL.Video.Pixel_Formats.Pixel_Format is function SDL_Get_Window_Pixel_Format (W : in SDL.C_Pointers.Windows_Pointer) return SDL.Video.Pixel_Formats.Pixel_Format with Import => True, Convention => C, External_Name => "SDL_GetWindowPixelFormat"; begin return SDL_Get_Window_Pixel_Format (Self.Internal); end Pixel_Format; function Get_Position (Self : in Window) return SDL.Natural_Coordinates is procedure SDL_Get_Window_Position (W : in SDL.C_Pointers.Windows_Pointer; X, Y : out C.int) with Import => True, Convention => C, External_Name => "SDL_GetWindowPosition"; Position : SDL.Natural_Coordinates := SDL.Zero_Coordinate; begin SDL_Get_Window_Position (Self.Internal, Position.X, Position.Y); return Position; end Get_Position; procedure Set_Position (Self : in out Window; Position : SDL.Natural_Coordinates) is procedure SDL_Set_Window_Position (W : in SDL.C_Pointers.Windows_Pointer; X, Y : in C.int) with Import => True, Convention => C, External_Name => "SDL_SetWindowPosition"; begin SDL_Set_Window_Position (Self.Internal, Position.X, Position.Y); end Set_Position; function Get_Size (Self : in Window) return SDL.Sizes is procedure SDL_Get_Window_Size (Win : in SDL.C_Pointers.Windows_Pointer; W, H : out SDL.Dimension) with Import => True, Convention => C, External_Name => "SDL_GetWindowSize"; W, H : C.int := 0; begin SDL_Get_Window_Size (Self.Internal, W, H); return SDL.Sizes'(Width => W, Height => H); end Get_Size; procedure Set_Size (Self : in out Window; Size : in SDL.Sizes) is procedure SDL_Get_Window_Size (Win : in SDL.C_Pointers.Windows_Pointer; W, H : in C.int) with Import => True, Convention => C, External_Name => "SDL_SetWindowSize"; begin SDL_Get_Window_Size (Self.Internal, C.int (Size.Width), C.int (Size.Height)); end Set_Size; function Get_Surface (Self : in Window) return SDL.Video.Surfaces.Surface is function SDL_Get_Window_Surface (W : in SDL.C_Pointers.Windows_Pointer) return SDL.Video.Surfaces.Internal_Surface_Pointer with Import => True, Convention => C, External_Name => "SDL_GetWindowSurface"; use type SDL.Video.Surfaces.Internal_Surface_Pointer; S : SDL.Video.Surfaces.Internal_Surface_Pointer := SDL_Get_Window_Surface (Self.Internal); function Make_Surface_From_Pointer (S : in SDL.Video.Surfaces.Internal_Surface_Pointer) return SDL.Video.Surfaces.Surface with Convention => Ada, Import => True; begin if S = null then raise Window_Error with SDL.Error.Get; end if; return Make_Surface_From_Pointer (S); end Get_Surface; function Get_Title (Self : in Window) return Ada.Strings.UTF_Encoding.UTF_8_String is function SDL_Get_Window_Title (W : in SDL.C_Pointers.Windows_Pointer) return C.Strings.chars_ptr with Import => True, Convention => C, External_Name => "SDL_GetWindowTitle"; begin return C.Strings.Value (SDL_Get_Window_Title (Self.Internal)); end Get_Title; procedure Set_Title (Self : in Window; Title : in Ada.Strings.UTF_Encoding.UTF_8_String) is procedure SDL_Set_Window_Title (W : in SDL.C_Pointers.Windows_Pointer; C_Str : in C.char_array) with Import => True, Convention => C, External_Name => "SDL_SetWindowTitle"; begin SDL_Set_Window_Title (Self.Internal, C.To_C (Title)); end Set_Title; procedure Hide (Self : in Window) is procedure SDL_Hide_Window (W : in SDL.C_Pointers.Windows_Pointer) with Import => True, Convention => C, External_Name => "SDL_HideWindow"; begin SDL_Hide_Window (Self.Internal); end Hide; procedure Show (Self : in Window) is procedure SDL_Show_Window (W : in SDL.C_Pointers.Windows_Pointer) with Import => True, Convention => C, External_Name => "SDL_ShowWindow"; begin SDL_Show_Window (Self.Internal); end Show; procedure Maximise (Self : in Window) is procedure SDL_Maximise_Window (W : in SDL.C_Pointers.Windows_Pointer) with Import => True, Convention => C, External_Name => "SDL_MaximizeWindow"; begin SDL_Maximise_Window (Self.Internal); end Maximise; procedure Minimise (Self : in Window) is procedure SDL_Minimise_Window (W : in SDL.C_Pointers.Windows_Pointer) with Import => True, Convention => C, External_Name => "SDL_MinimizeWindow"; begin SDL_Minimise_Window (Self.Internal); end Minimise; procedure Raise_And_Focus (Self : in Window) is procedure SDL_Raise_Window (W : in SDL.C_Pointers.Windows_Pointer) with Import => True, Convention => C, External_Name => "SDL_RaiseWindow"; begin SDL_Raise_Window (Self.Internal); end Raise_And_Focus; procedure Restore (Self : in Window) is procedure SDL_Restore_Window (W : in SDL.C_Pointers.Windows_Pointer) with Import => True, Convention => C, External_Name => "SDL_RestoreWindow"; begin SDL_Restore_Window (Self.Internal); end Restore; procedure Set_Mode (Self : in out Window; Flags : in Full_Screen_Flags) is function SDL_Window_Full_Screen (W : in SDL.C_Pointers.Windows_Pointer; F : in Full_Screen_Flags) return C.int with Import => True, Convention => C, External_Name => "SDL_SetWindowFullscreen"; Result : C.int := SDL_Window_Full_Screen (Self.Internal, Flags); begin if Result /= Success then raise Window_Error with SDL.Error.Get; end if; end Set_Mode; procedure Set_Icon (Self : in out Window; Icon : in SDL.Video.Surfaces.Surface) is procedure SDL_Set_Window_Icon (W : in SDL.C_Pointers.Windows_Pointer; S : SDL.Video.Surfaces.Internal_Surface_Pointer) with Import => True, Convention => C, External_Name => "SDL_SetWindowIcon"; function Get_Internal_Surface (Self : in SDL.Video.Surfaces.Surface) return SDL.Video.Surfaces.Internal_Surface_Pointer with Import => True, Convention => Ada; begin SDL_Set_Window_Icon (Self.Internal, Get_Internal_Surface (Icon)); end Set_Icon; procedure Update_Surface (Self : in Window) is function SDL_Update_Window_Surface (W : in SDL.C_Pointers.Windows_Pointer) return C.int with Import => True, Convention => C, External_Name => "SDL_UpdateWindowSurface"; Result : C.int := SDL_Update_Window_Surface (Self.Internal); begin if Result /= Success then raise Window_Error with SDL.Error.Get; end if; end Update_Surface; procedure Update_Surface_Rectangle (Self : in Window; Rectangle : in SDL.Video.Rectangles.Rectangle) is function SDL_Update_Window_Surface_Rects (W : in SDL.C_Pointers.Windows_Pointer; R : in SDL.Video.Rectangles.Rectangle; L : in C.int) return C.int with Import => True, Convention => C, External_Name => "SDL_UpdateWindowSurfaceRects"; Result : C.int := SDL_Update_Window_Surface_Rects (Self.Internal, Rectangle, 1); begin if Result /= Success then raise Window_Error with SDL.Error.Get; end if; end Update_Surface_Rectangle; procedure Update_Surface_Rectangles (Self : in Window; Rectangles : SDL.Video.Rectangles.Rectangle_Arrays) is function SDL_Update_Window_Surface_Rects (W : in SDL.C_Pointers.Windows_Pointer; R : in SDL.Video.Rectangles.Rectangle_Arrays; L : in C.int) return C.int with Import => True, Convention => C, External_Name => "SDL_UpdateWindowSurfaceRects"; Result : C.int := SDL_Update_Window_Surface_Rects (Self.Internal, Rectangles, Rectangles'Length); begin if Result /= Success then raise Window_Error with SDL.Error.Get; end if; end Update_Surface_Rectangles; function Exist return Boolean is begin return Total_Windows_Created /= Natural'First; end Exist; function Get_Internal_Window (Self : in Window) return SDL.C_Pointers.Windows_Pointer is begin return Self.Internal; end Get_Internal_Window; end SDL.Video.Windows;
mapcode-foundation/mapcode-ada
Ada
15,071
adb
-- ----------------------------------------------------------------------------- -- Copyright (C) 2003-2019 Stichting Mapcode Foundation (http://www.mapcode.com) -- -- Licensed under the Apache License, Version 2.0 (the "License"); -- you may not use this file except in compliance with the License. -- You may obtain a copy of the License at -- -- http://www.apache.org/licenses/LICENSE-2.0 -- -- Unless required by applicable law or agreed to in writing, software -- distributed under the License is distributed on an "AS IS" BASIS, -- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -- See the License for the specific language governing permissions and -- limitations under the License. -- ----------------------------------------------------------------------------- with Ada.Characters.Handling; package body Mapcodes.Languages is use Mapcode_Utils; -- Get the Language from its name in its language -- Raises, if the output language is not known: -- Unknown_Language : exception; function Get_Language (Name : Unicode_Sequence) return Language_List is use type Language_Utils.Unicode_Sequence; Roman : Boolean := True; Str : String (Name'Range); begin -- Try a name in Roman for I in Name'Range loop if Name(I) < Character'Pos ('0') or else Name(I) > Character'Pos ('z') then Roman := False; exit; else Str(I) := Character'Val(Name(I)); end if; end loop; if Roman then begin return Language_List'Value (Str); exception when Constraint_Error => raise Unknown_Language; end; end if; -- Try each language in its alphabet for L in Language_Defs.Langs'Range loop if Language_Defs.Langs(L).Name.Txt = Name then -- Name is the name of language L return Language_List (L); end if; end loop; raise Unknown_Language; end Get_Language; -- Get the language of a text (territory name or mapcode) -- All the characters must be of the same language, otherwise raises -- Invalid_Text : exception; function Get_Language (Input : Wide_String) return Language_List is First : Natural; Found : Boolean; Lang : Language_Defs.Language_List; function Is_Shared (C : Wide_Character) return Boolean is (C <= '9' or else C = 'I' or else C = 'O'); begin -- Discard empty string if Input'Length = 0 then raise Invalid_Text; end if; -- Find first non shared character First := 0; for I in Input'Range loop if not Is_Shared (Input(I)) then First := I; exit; end if; end loop; if First = 0 then -- All characters are shared => Roman Lang := Language_Defs.Language_List (Default_Language); else -- Find language of first character Found := False; for L in Language_Defs.Langs'Range loop if not Is_Shared (Input(First)) and then Input(First) >= Language_Defs.Langs(L).First and then Input(First) <= Language_Defs.Langs(L).Last then Found := True; Lang := L; exit; end if; end loop; if not Found then raise Invalid_Text; end if; end if; -- Check that all characters belong to this language for W of Input loop if W /= '.' and then W /= '-' and then not Is_Shared (W) and then (W < Language_Defs.Langs(Lang).First or else W > Language_Defs.Langs(Lang).Last) then raise Invalid_Text; end if; end loop; return Language_List (Lang); end Get_Language; -- Does a language use Abjad conversion function Is_Abjad (Language : Language_List) return Boolean is begin return Language = Greek or else Language = Hebrew or else Language = Arabic or else Language = Korean; end Is_Abjad; -- Convert From Abjad procedure Convert_From_Abjad (Str : in out As_U.Asu_Us) is Lstr, Tail : As_U.Asu_Us; Index, Form : Natural; Code : Integer; use type As_U.Asu_Us; -- Character code at a given index ( '4' -> 4) function Str_At (P : Positive) return Natural is (Character'Pos (Lstr.Element (P)) - Character'Pos ('0')); begin -- Save precision tail, including '-' Lstr := Str; Index := Lstr.Locate ("-"); if Index /= 0 then Tail := Lstr.Uslice (Index, Lstr.Length); Lstr.Delete (Index, Lstr.Length); end if; Lstr := As_U.Tus (Aeu_Unpack (Lstr.Image)); Index := Lstr.Locate ("."); if Index < 3 or else Index > 6 then return; end if; Form := 10 * (Index - 1) + (Lstr.Length - Index); if Form = 23 then Code := Str_At (4) * 8 + Str_At (5) - 18; Lstr := Lstr.Uslice (1, 2) & '.' & Encode_A_Char (Code) & Lstr.Element (6); elsif Form = 24 then Code := Str_At (4) * 8 + Str_At (5) - 18; if Code >= 32 then Lstr := Lstr.Uslice (1, 2) & Encode_A_Char (Code - 32) & '.' & Lstr.Element (6) & Lstr.Element (7); else Lstr := Lstr.Uslice (1, 2) & '.' & Encode_A_Char (Code) & Lstr.Element (6) & Lstr.Element (7); end if; elsif Form = 34 then Code := Str_At (3) * 10 + Str_At (6) - 7; if Code < 31 then Lstr := Lstr.Uslice (1, 2) & '.' & Encode_A_Char (Code) & Lstr.Element (5) & Lstr.Element (7) & Lstr.Element (8); elsif Code < 62 then Lstr := Lstr.Uslice (1, 2) & Encode_A_Char (Code - 31) & '.' & Lstr.Element (5) & Lstr.Element (7) & Lstr.Element (8); else Lstr := Lstr.Uslice (1, 2) & Encode_A_Char (Code - 62) & Lstr.Element (5) & '.' & Lstr.Element (7) & Lstr.Element (8); end if; elsif Form = 35 then Code := Str_At (3) * 8 + Str_At (7) - 18; if Code >= 32 then Lstr := Lstr.Uslice (1, 2) & Encode_A_Char (Code - 32) & Lstr.Element (5) & '.' & Lstr.Element (6) & Lstr.Element (8) & Lstr.Element (9); else Lstr := Lstr.Uslice (1, 2) & Encode_A_Char (Code) & '.' & Lstr.Element (5) & Lstr.Element (6) & Lstr.Element (8) & Lstr.Element (9); end if; elsif Form = 45 then Code := Str_At (3) * 100 + Str_At (6) * 10 + Str_At (9) - 39; Lstr := Lstr.Uslice (1, 2) & Encode_A_Char (Code / 31) & Lstr.Element (4) & '.' & Lstr.Element (7) & Lstr.Element (8) & Lstr.Element (10) & Encode_A_Char (Code rem 31); elsif Form = 55 then Code := Str_At (3) * 100 + Str_At (7) * 10 + Str_At (10) - 39; Lstr := Lstr.Uslice (1, 2) & Encode_A_Char (Code / 31) & Lstr.Element (4) & Lstr.Element (5) & '.' & Lstr.Element (8) & Lstr.Element (9) & Lstr.Element (11) & Encode_A_Char (Code rem 31); else return; end if; Str := As_U.Tus (Aeu_Pack (Lstr, False)) & Tail; end Convert_From_Abjad; -- Convert into Abjad procedure Convert_Into_Abjad (Str : in out As_U.Asu_Us) is Lstr, Tail : As_U.Asu_Us; Index, Form : Natural; Code : Integer; C1, C2, C3 : Integer := 0; use type As_U.Asu_Us; -- Character pos at a given index function Str_At (P : Positive) return Natural is (Character'Pos (Lstr.Element (P))); function Char_Of (P : Natural) return Character is (Character'Val (P + Character'Pos('0'))); begin -- Save precision tail, including '-' Lstr := Str; Index := Str.Locate ("-"); if Index /= 0 then Tail := Lstr.Uslice (Index, Str.Length); Lstr.Delete (Index, Lstr.Length); end if; Lstr := As_U.Tus (Aeu_Unpack (Lstr.Image)); Index := Lstr.Locate ("."); if Index < 3 or else Index > 6 then return; end if; Form := 10 * (Index - 1) + (Lstr.Length - Index); -- See if more than 2 non-digits in a row Index := 0; for I in 1 .. Lstr.Length loop Code := Str_At (I); -- Skip the dot if Code /= 46 then Index := Index + 1; if Decode_A_Char (Code) <= 9 then -- A digit Index := 0; elsif Index > 2 then exit; end if; end if; end loop; -- No need to convert if Index < 3 and then (Form = 22 or else Form = 32 or else Form = 33 or else Form = 42 or else Form = 43 or else Form = 44 or else Form = 54) then return; end if; Code := Decode_A_Char (Str_At (3)); if Code < 0 then Code := Decode_A_Char (Str_At (4)); if Code < 0 then return; end if; end if; -- Convert if Form >= 44 then Code := Code * 31 + Decode_A_Char (Str_At (Lstr.Length)) + 39; if Code < 39 or else Code > 999 then return; end if; C1 := Code / 100; C2 := (Code rem 100) / 10; C3 := Code rem 10; elsif Lstr.Length = 7 then if Form = 24 then Code := Code + 7; elsif Form = 33 then Code := Code + 38; elsif Form = 42 then Code := Code + 69; end if; C1 := Code / 10; C2 := Code rem 10; else C1 := 2 + Code / 8; C2 := 2 + Code rem 8; end if; if Form = 22 then Lstr := Lstr.Uslice (1, 2) & '.' & Char_Of (C1) & Char_Of (C2) & Lstr.Element (5); elsif Form = 23 then Lstr := Lstr.Uslice (1, 2) & '.' & Char_Of (C1) & Char_Of (C2) & Lstr.Element (5) & Lstr.Element (6); elsif Form = 32 then Lstr := Lstr.Uslice (1, 2) & '.' & Char_Of (C1 + 4) & Char_Of (C2) & Lstr.Element (5) & Lstr.Element (6); elsif Form = 24 or else Form = 33 then Lstr := Lstr.Uslice (1, 2) & Char_Of (C1) & '.' & Lstr.Element (5) & Char_Of (C2) & Lstr.Element (6) & Lstr.Element (7); elsif Form = 42 then Lstr := Lstr.Uslice (1, 2) & Char_Of (C1) & '.' & Lstr.Element (4) & Char_Of (C2) & Lstr.Element (6) & Lstr.Element (7); elsif Form = 43 then Lstr := Lstr.Uslice (1, 2) & Char_Of (C1 + 4) & '.' & Lstr.Element (4) & Lstr.Element (6) & Char_Of (C2) & Lstr.Element (7) & Lstr.Element (8); elsif Form = 34 then Lstr := Lstr.Uslice (1, 2) & Char_Of (C1) & '.' & Lstr.Element (5) & Lstr.Element (6) & Char_Of (C2) & Lstr.Element (7) & Lstr.Element (8); elsif Form = 44 then Lstr := Lstr.Uslice (1, 2) & Char_Of (C1) & Lstr.Element (4) & '.' & Char_Of (C2) & Lstr.Element (6) & Lstr.Element (7) & Char_Of (C3) & Lstr.Element (8); elsif Form = 54 then Lstr := Lstr.Uslice (1, 2) & Char_Of (C1) & Lstr.Element (4) & Lstr.Element (5) & '.' & Char_Of (C2) & Lstr.Element (7) & Lstr.Element (8) & Char_Of (C3) & Lstr.Element (9); else return; end if; Str := As_U.Tus (Aeu_Pack (Lstr, False)) & Tail; end Convert_Into_Abjad; --Conversion of a text (territory name or mapcode) into a given language -- The language of the input is detected automatically -- Raises Invalid_Text if the input is not valid function Convert (Input : Wide_String; Output_Language : Language_List := Default_Language) return Wide_String is Input_Language : constant Language_List := Get_Language (Input); Def_Input : constant Language_Defs.Language_List := Language_Defs.Language_List (Input_Language); Def_Output : constant Language_Defs.Language_List := Language_Defs.Language_List (Output_Language); Tmp_Wide : Wide_String (1 .. Input'Length); Found : Boolean; Tmp_Str, Tail : As_U.Asu_Us; Index : Natural; Code : Positive; use type As_U.Asu_Us; begin -- Optim: nothing to do if Output_Language = Input_Language then return Input; end if; -- Convert Input into Roman --------------------------- if Input_Language = Roman then Tmp_Str := As_U.Tus (Ada.Characters.Handling.To_String (Input)); else Index := 0; -- Replace each wide char for W of Input loop Index := Index + 1; if W = '-' or else W = '.' then Tmp_Wide(Index) := W; else Found := False; for J in Language_Defs.Langs(Def_Input).Set'Range loop if W = Language_Defs.Langs(Def_Input).Set(J) then -- Found W in Set of Input_Language -- => Replace by corresponding Romain Found := True; Tmp_Wide(Index) := Language_Defs.Langs(Language_Defs.Roman).Set(J); exit; end if; end loop; if not Found then raise Invalid_Text; end if; end if; end loop; -- Roman string Tmp_Str := As_U.Tus (Ada.Characters.Handling.To_String (Tmp_Wide)); -- Repack if Tmp_Str.Element (1) = 'A' then Index := Tmp_Str.Locate ("-"); if Index /= 0 then -- Save precision tail, including '-' Tail := Tmp_Str.Uslice (Index, Tmp_Str.Length); Tmp_Str.Delete (Index, Tmp_Str.Length); end if; Tmp_Str := Mapcodes.Aeu_Pack ( As_U.Tus (Aeu_Unpack (Tmp_Str.Image)), False) & Tail; end if; -- Abjad conversion if Is_Abjad (Input_Language) then Convert_From_Abjad (Tmp_Str); end if; end if; if Output_Language = Roman then return Ada.Characters.Handling.To_Wide_String (Tmp_Str.Image); end if; -- Convert Roman into output language ------------------------------------- if Is_Abjad (Output_Language) then -- Abjad conversion Convert_Into_Abjad (Tmp_Str); end if; -- Unpack for languages that do not support E and U if Output_Language = Greek then Index := Tmp_Str.Locate ("-"); Tail.Set_Null; if Index /= 0 then -- Save precision tail, including '-' Tail := Tmp_Str.Uslice (Index, Tmp_Str.Length); Tmp_Str.Delete (Index, Tmp_Str.Length); end if; if Tmp_Str.Locate ("E") /= 0 or else Tmp_Str.Locate ("U") /= 0 then Tmp_Str := As_U.Tus (Aeu_Pack (As_U.Tus (Aeu_Unpack (Tmp_Str.Image)), True)); end if; Tmp_Str := Tmp_Str & Tail; end if; -- Substitute declare Result : Wide_String (1 .. Tmp_Str.Length); begin for I in 1 .. Tmp_Str.Length loop Code := Character'Pos (Tmp_Str.Element (I)); if Code >= 65 and then Code <= 90 then Result(I) := Language_Defs.Langs(Def_Output).Set(Code - 64); elsif Code >= 48 and then Code <= 57 then Result(I) := Language_Defs.Langs(Def_Output).Set(Code + 26 - 47); else Result(I) := Wide_Character'Val (Code); end if; end loop; return Result; end; end Convert; end Mapcodes.Languages;
RREE/ada-util
Ada
1,024
ads
-- Generated by utildgen.c from system includes with Interfaces.C; package Util.Systems.Constants is pragma Pure; -- Flags used when opening a file with open/creat. O_RDONLY : constant Interfaces.C.int := 8#000000#; O_WRONLY : constant Interfaces.C.int := 8#000001#; O_RDWR : constant Interfaces.C.int := 8#000002#; O_CREAT : constant Interfaces.C.int := 8#000400#; O_EXCL : constant Interfaces.C.int := 8#002000#; O_TRUNC : constant Interfaces.C.int := 8#001000#; O_APPEND : constant Interfaces.C.int := 8#000010#; O_CLOEXEC : constant Interfaces.C.int := 8#100000#; O_SYNC : constant Interfaces.C.int := 0; O_DIRECT : constant Interfaces.C.int := 0; DLL_OPTIONS : constant String := ""; SYMBOL_PREFIX : constant String := ""; end Util.Systems.Constants;
HackInvent/Ada_Drivers_Library
Ada
8,892
adb
------------------------------------------------------------------------------ -- -- -- Copyright (C) 2015-2017, AdaCore -- -- -- -- Redistribution and use in source and binary forms, with or without -- -- modification, are permitted provided that the following conditions are -- -- met: -- -- 1. Redistributions of source code must retain the above copyright -- -- notice, this list of conditions and the following disclaimer. -- -- 2. Redistributions in binary form must reproduce the above copyright -- -- notice, this list of conditions and the following disclaimer in -- -- the documentation and/or other materials provided with the -- -- distribution. -- -- 3. Neither the name of the copyright holder nor the names of its -- -- contributors may be used to endorse or promote products derived -- -- from this software without specific prior written permission. -- -- -- -- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -- -- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -- -- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -- -- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -- -- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -- -- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -- -- LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -- -- DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -- -- THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -- -- (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -- -- OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- -- -- ------------------------------------------------------------------------------ -- A simple example that blinks all the LEDs simultaneously, w/o tasking. -- It does not use the various convenience functions defined elsewhere, but -- instead works directly with the GPIO driver to configure and control the -- LEDs. -- Note that this code is independent of the specific MCU device and board -- in use because we use names and constants that are common across all of -- them. For example, "All_LEDs" refers to different GPIO pins on different -- boards, and indeed defines a different number of LEDs on different boards. -- The gpr file determines which board is actually used. with Last_Chance_Handler; pragma Unreferenced (Last_Chance_Handler); -- The "last chance handler" is the user-defined routine that is called when -- an exception is propagated. We need it in the executable, therefore it -- must be somewhere in the closure of the context clauses. with STM32.Board; use STM32.Board; with STM32.Device; use STM32.Device; with STM32.GPIO; use STM32.GPIO; with Ada.Real_Time; use Ada.Real_Time; with BMI088; use BMI088; with HAL; use HAL; with HAL.SPI; use HAL.SPI; with HAL.UART; use HAL.UART; with Ada.Unchecked_Conversion; with Ada.Numerics.Elementary_Functions; procedure Blinky is Bmi_1 : BMI088.Six_Axis_Imu; AccelRates : Sensor_Accel_Data; GyroRates : Sensor_Gyro_Data; -- Received : SPI_Data_8b (1 .. 6); -- 2 bytes per axis -- AccelRates : BMI088.IMU_Rates;-- todo create AccelRate type -- GyroRates : BMI088.IMU_Rates;-- todo create AccelRate type -- Result : Sensor_Data; status : UART_Status; -- data_4B : UART_Data_8b (0 .. 3); -- contains a float data_1B : UART_Data_8b (0 .. 0); -- contains a byte -- type UART_Data_8b_4 is new UART_Data_8b (0 .. 3); -- function To_UART_Data_8b_4 is -- new Ada.Unchecked_Conversion (Source => Float, -- Target => UART_Data_8b_4); type FixedFloat is delta 0.00001 digits 18; -- IMUs filter -- Estimator startTime : Time; -- start time of the main loop dt : constant Float := 0.0005; -- sampling in second (ex. 0.01 = 10ms) dt_micros : constant Integer := Integer(dt*1000000.0); -- sampling in microseconds estimatedPitch : Float := 0.0; -- in deg estimatedRoll : Float := 0.0; -- in deg procedure ComplementaryFilter(accelData : Sensor_Accel_Data; gyroData : Sensor_Gyro_Data) is pitchAccel : Float := 0.0; -- pitch computed from the accel rollAccel : Float := 0.0; -- roll computed from the accel begin -- integrate the gyroscope data estimatedPitch := estimatedPitch + gyroData(X)*dt; estimatedRoll := estimatedRoll + gyroData(Y)*dt; -- compensate the drift using the acceleration pitchAccel := Ada.Numerics.Elementary_Functions.Arctan(accelData(Y),accelData(Z))*RadToDeg; estimatedPitch := estimatedPitch * 0.98 + pitchAccel * 0.02; rollAccel := Ada.Numerics.Elementary_Functions.Arctan(accelData(X),accelData(Z))*RadToDeg; estimatedRoll := estimatedRoll * 0.98 + rollAccel * 0.02; null; end ComplementaryFilter; begin -- init the leds STM32.Board.Initialize_LEDs; -- init the SPIs STM32.Board.Initialize_SPI1_For_BMI088; -- init the UART OUT Initialize_UART_OUT; -- Unselect IMUIsGyroDeviceIdOk Turn_ON(IMU1_SPI1_SELC); -- disable the accel Turn_ON(IMU1_SPI1_SELG); -- disable the Gyro -- init the BMI1 Bmi_1.Initialize_Spi (Port => IMU_SPI1'Access, Accel_Chip_Select => IMU1_SPI1_SELC'Access, Gyro_Chip_Select => IMU1_SPI1_SELG'Access); --- inifinit loop test --Bmi_1.test; --- init the BMI088.accel Bmi_1.Initialize_Accel; --- init the BMI088.gyro Bmi_1.Initialize_Gyro; -- read the accel value ---- read the value loop startTime := Clock; -- PG1.Set; Bmi_1.ReadAccelRates(AccelRates); Bmi_1.ReadGyroRates(GyroRates); Bmi_1.ReadAccelRates(AccelRates); Bmi_1.ReadGyroRates(GyroRates); Bmi_1.ReadAccelRates(AccelRates); Bmi_1.ReadGyroRates(GyroRates); Bmi_1.ReadAccelRates(AccelRates); Bmi_1.ReadGyroRates(GyroRates); Bmi_1.ReadAccelRates(AccelRates); Bmi_1.ReadGyroRates(GyroRates); Bmi_1.ReadAccelRates(AccelRates); Bmi_1.ReadGyroRates(GyroRates); Bmi_1.ReadAccelRates(AccelRates); Bmi_1.ReadGyroRates(GyroRates); Bmi_1.ReadAccelRates(AccelRates); Bmi_1.ReadGyroRates(GyroRates); Bmi_1.ReadAccelRates(AccelRates); Bmi_1.ReadGyroRates(GyroRates); Bmi_1.ReadAccelRates(AccelRates); Bmi_1.ReadGyroRates(GyroRates); Bmi_1.ReadAccelRates(AccelRates); Bmi_1.ReadGyroRates(GyroRates); Bmi_1.ReadAccelRates(AccelRates); Bmi_1.ReadGyroRates(GyroRates); Bmi_1.ReadAccelRates(AccelRates); Bmi_1.ReadGyroRates(GyroRates); -- estimate the pitch and the roll ComplementaryFilter(AccelRates, GyroRates); PG1.Clear; Blue_LED.Toggle; -- data_1B(0) := UInt8(36); -- '$' -- UART_OUT.Transmit(data_1B,status); -- data_1B(0) := UInt8(102); -- 'f' -- UART_OUT.Transmit(data_1B,status); -- -- data_4B := UART_Data_8b(To_UART_Data_8b_4(AccelRates(X))); -- UART_OUT.Transmit(Data => data_4B,Status => status); -- -- data_1B(0) := UInt8(59); -- ';' -- UART_OUT.Transmit(data_1B,status); -- visualize the pitch data_1B(0) := UInt8(36); -- '$' UART_OUT.Transmit(data_1B,status); for ch of FixedFloat(estimatedPitch)'Img loop data_1B(0) := Character'Pos(ch); if data_1B(0) /= 32 then -- we don't send " " UART_OUT.Transmit(data_1B,status); end if; end loop; data_1B(0) := UInt8(32); -- ' ' UART_OUT.Transmit(data_1B,status); -- visualize the roll for ch of FixedFloat(estimatedRoll)'Img loop data_1B(0) := Character'Pos(ch); if data_1B(0) /= 32 then -- we don't send " " UART_OUT.Transmit(data_1B,status); end if; end loop; data_1B(0) := UInt8(59); -- ';' UART_OUT.Transmit(data_1B,status); -- while True loop -- startTime := Clock; -- PG1.Set; -- delay until startTime + Microseconds (1); -- PG1.Clear; -- end loop; delay until startTime + Microseconds (dt_micros); end loop; end Blinky;
reznikmm/matreshka
Ada
8,709
ads
------------------------------------------------------------------------------ -- -- -- Matreshka Project -- -- -- -- XML Processor -- -- -- -- Runtime Library Component -- -- -- ------------------------------------------------------------------------------ -- -- -- Copyright © 2011-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$ ------------------------------------------------------------------------------ -- The CharacterData interface extends Node with a set of attributes and -- methods for accessing character data in the DOM. For clarity this set is -- defined here rather than on each object that uses these attributes and -- methods. No DOM objects correspond directly to CharacterData, though Text -- and others do inherit the interface from it. All offsets in this interface -- start from 0. ------------------------------------------------------------------------------ package XML.DOM.Nodes.Character_Datas is pragma Preelaborate; type DOM_Character_Data is new XML.DOM.Nodes.DOM_Node with private; Null_DOM_Character_Data : constant DOM_Character_Data; function Get_Data (Self : DOM_Character_Data'Class) return League.Strings.Universal_String; -- The character data of the node that implements this interface. The DOM -- implementation may not put arbitrary limits on the amount of data that -- may be stored in a CharacterData node. However, implementation limits -- may mean that the entirety of a node's data may not fit into a single -- DOMString. In such cases, the user may call substringData to retrieve -- the data in appropriately sized pieces. -- procedure Set_Data -- (Self : in out DOM_Character_Data'Class; To : DOM_String); -- -- The character data of the node that implements this interface. The DOM -- -- implementation may not put arbitrary limits on the amount of data that -- -- may be stored in a CharacterData node. However, implementation limits -- -- may mean that the entirety of a node's data may not fit into a single -- -- DOMString. In such cases, the user may call substringData to retrieve -- -- the data in appropriately sized pieces. -- -- -- -- Raises DOM_Exception: -- -- -- -- - NO_MODIFICATION_ALLOWED_ERR: Raised when the node is readonly. -- -- function Length (Self : DOM_Character_Data'Class) return Natural; -- -- The number of Unicode characters that are available through data and the -- -- substringData method below. This may have the value zero, i.e., -- -- CharacterData nodes may be empty. -- -- function Substring_Data -- (Self : DOM_Character_Data'Class; -- Offset : Natural; -- Count : Natural) return DOM_String; -- -- Extracts a range of data from the node. Returns specified substring. If -- -- the sum of offset and count exceeds the length, then all Unicode -- -- characters to the end of the data are returned. -- -- -- -- Raises DOM_Exception: -- -- -- -- - INDEX_SIZE_ERR: Raised if the specified offset is negative or greater -- -- than the number Unicode characters in data, or if the specified count -- -- is negative. -- -- -- -- - DOMSTRING_SIZE_ERR: Raised if the specified range of text does not -- -- fit into a DOMString. -- -- procedure Append_Data -- (Self : in out DOM_Character_Data'Class; Arg : DOM_String); -- -- Append the string to the end of the character data of the node. Upon -- -- success, data provides access to the concatenation of data and the -- -- DOMString specified. -- -- -- -- Raises DOM_Exception: -- -- -- -- - NO_MODIFICATION_ALLOWED_ERR: Raised if this node is readonly. -- -- procedure Insert_Data -- (Self : in out DOM_Character_Data'Class; -- Offset : Natural; -- Arg : DOM_String); -- -- Insert a string at the specified Unicode character offset. -- -- -- -- Raises DOM_Exception: -- -- -- -- - INDEX_SIZE_ERR: Raised if the specified offset is negative or greater -- -- than the number of Unicode characters in data. -- -- -- -- - NO_MODIFICATION_ALLOWED_ERR: Raised if this node is readonly. -- -- procedure Delete_Data -- (Self : in out DOM_Character_Data'Class; -- Offset : Natural; -- Count : Natural); -- -- Remove a range of Unicode characters from the node. Upon success, data -- -- and length reflect the change. -- -- -- -- Raises DOM_Exception: -- -- -- -- - INDEX_SIZE_ERR: Raised if the specified offset is negative or greater -- -- than the number of Unicode characters in data, or if the specified -- -- count is negative. -- -- -- -- - NO_MODIFICATION_ALLOWED_ERR: Raised if this node is readonly. procedure Replace_Data (Self : in out DOM_Character_Data'Class; Offset : Positive; Count : Natural; Arg : League.Strings.Universal_String); -- Replace the characters starting at the specified position with the -- specified string. -- -- If the sum of offset and count exceeds length, then all Unicode -- characters to the end of the data are replaced; (i.e., the effect is the -- same as a remove method call with the same range, followed by an append -- method invocation). -- -- Raises DOMException: -- -- - INDEX_SIZE_ERR: Raised if the specified offset is negative or greater -- than the number of Unicode characters in data, or if the specified -- count is negative. -- -- - NO_MODIFICATION_ALLOWED_ERR: Raised if this node is readonly. private type DOM_Character_Data is new XML.DOM.Nodes.DOM_Node with null record; Null_DOM_Character_Data : constant DOM_Character_Data := (Ada.Finalization.Controlled with Node => null); end XML.DOM.Nodes.Character_Datas;
reznikmm/gela
Ada
5,609
ads
with Ada.Iterator_Interfaces; with Gela.Elements.Defining_Names; with Gela.Lexical_Types; with Gela.Semantic_Types; with Gela.Types; package Gela.Plain_Int_Sets.Cursors is pragma Preelaborate; generic type Cursor is interface; with procedure Next (Self : in out Cursor) is abstract; type Some_Cursor is new Cursor with private; with package Iterators is new Ada.Iterator_Interfaces (Cursor'Class, Has_Element => <>); package Generic_Iterators is type Iterator is new Iterators.Forward_Iterator with record Cursor : Some_Cursor; end record; overriding function First (Self : Iterator) return Cursor'Class; overriding function Next (Self : Iterator; Position : Cursor'Class) return Cursor'Class; end Generic_Iterators; type Category_Cursor is new Gela.Interpretations.Category_Cursor with private; not overriding procedure Initialize (Self : out Category_Cursor; Set : access Interpretation_Set; Index : Gela.Interpretations.Interpretation_Set_Index); overriding procedure Next (Self : in out Category_Cursor); type Defining_Name_Cursor is new Gela.Interpretations.Defining_Name_Cursor with private; not overriding procedure Initialize (Self : out Defining_Name_Cursor; Set : access Interpretation_Set; Index : Gela.Interpretations.Interpretation_Set_Index); overriding procedure Next (Self : in out Defining_Name_Cursor); overriding function Defining_Name (Self : Defining_Name_Cursor) return Gela.Elements.Defining_Names.Defining_Name_Access; type Expression_Cursor is new Gela.Interpretations.Expression_Cursor with private; not overriding procedure Initialize (Self : out Expression_Cursor; Set : access Interpretation_Set; Index : Gela.Interpretations.Interpretation_Set_Index); overriding function Expression_Type (Self : Expression_Cursor) return Gela.Semantic_Types.Type_View_Index; overriding procedure Next (Self : in out Expression_Cursor); type Symbol_Cursor is new Gela.Interpretations.Symbol_Cursor with private; not overriding procedure Initialize (Self : out Symbol_Cursor; Set : access Interpretation_Set; Index : Gela.Interpretations.Interpretation_Set_Index); overriding procedure Next (Self : in out Symbol_Cursor); type Profile_Cursor is new Gela.Interpretations.Profile_Cursor with private; not overriding procedure Initialize (Self : out Profile_Cursor; Set : access Interpretation_Set; Index : Gela.Interpretations.Interpretation_Set_Index); overriding procedure Next (Self : in out Profile_Cursor); type Any_Cursor is new Gela.Interpretations.Any_Cursor with private; not overriding procedure Initialize (Self : out Any_Cursor; Set : access Interpretation_Set; Index : Gela.Interpretations.Interpretation_Set_Index); overriding procedure Next (Self : in out Any_Cursor); private type Base_Cursor is abstract new Gela.Interpretations.Abstract_Cursor with record Set : access Interpretation_Set; Pos : Int_Lists.Cursor := Int_Lists.No_Element; end record; overriding function Has_Element (Self : Base_Cursor) return Boolean; overriding function Get_Index (Self : Base_Cursor) return Gela.Interpretations.Interpretation_Index; type Category_Cursor is new Base_Cursor and Gela.Interpretations.Category_Cursor with null record; overriding function Matcher (Self : Category_Cursor) return Gela.Interpretations.Type_Matcher_Access; type Defining_Name_Cursor is new Base_Cursor and Gela.Interpretations.Defining_Name_Cursor with null record; type Expression_Cursor is new Base_Cursor and Gela.Interpretations.Expression_Cursor with null record; type Symbol_Cursor is new Base_Cursor and Gela.Interpretations.Symbol_Cursor with null record; overriding function Symbol (Self : Symbol_Cursor) return Gela.Lexical_Types.Symbol; type Profile_Cursor is new Base_Cursor and Gela.Interpretations.Profile_Cursor with null record; overriding function Corresponding_Type (Self : Profile_Cursor) return Gela.Types.Type_View_Access; overriding function Attribute_Kind (Self : Profile_Cursor) return Gela.Lexical_Types.Predefined_Symbols.Attribute; type Any_Cursor is new Base_Cursor and Gela.Interpretations.Any_Cursor with null record; overriding function Is_Symbol (Self : Any_Cursor) return Boolean; overriding function Is_Defining_Name (Self : Any_Cursor) return Boolean; overriding function Is_Expression (Self : Any_Cursor) return Boolean; overriding function Is_Expression_Category (Self : Any_Cursor) return Boolean; overriding function Is_Profile (Self : Any_Cursor) return Boolean; overriding function Symbol (Self : Any_Cursor) return Gela.Lexical_Types.Symbol; overriding function Defining_Name (Self : Any_Cursor) return Gela.Elements.Defining_Names.Defining_Name_Access; overriding function Expression_Type (Self : Any_Cursor) return Gela.Semantic_Types.Type_View_Index; overriding function Matcher (Self : Any_Cursor) return Gela.Interpretations.Type_Matcher_Access; overriding function Corresponding_Type (Self : Any_Cursor) return Gela.Types.Type_View_Access; overriding function Attribute_Kind (Self : Any_Cursor) return Gela.Lexical_Types.Predefined_Symbols.Attribute; end Gela.Plain_Int_Sets.Cursors;
google-code/ada-util
Ada
1,178
ads
----------------------------------------------------------------------- -- serialize-io-json-tests -- Unit tests for JSON parser -- Copyright (C) 2011 Stephane Carrez -- Written by Stephane Carrez ([email protected]) -- -- Licensed under the Apache License, Version 2.0 (the "License"); -- you may not use this file except in compliance with the License. -- You may obtain a copy of the License at -- -- http://www.apache.org/licenses/LICENSE-2.0 -- -- Unless required by applicable law or agreed to in writing, software -- distributed under the License is distributed on an "AS IS" BASIS, -- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -- See the License for the specific language governing permissions and -- limitations under the License. ----------------------------------------------------------------------- with Util.Tests; package Util.Serialize.IO.JSON.Tests is procedure Add_Tests (Suite : in Util.Tests.Access_Test_Suite); type Test is new Util.Tests.Test with null record; procedure Test_Parse_Error (T : in out Test); procedure Test_Parser (T : in out Test); end Util.Serialize.IO.JSON.Tests;
zhmu/ananas
Ada
57,306
adb
------------------------------------------------------------------------------ -- -- -- GNAT RUN-TIME COMPONENTS -- -- -- -- A D A . S T R I N G S . U N B O U N D E D -- -- -- -- B o d y -- -- -- -- Copyright (C) 1992-2022, Free Software Foundation, Inc. -- -- -- -- GNAT is free software; you can redistribute it and/or modify it under -- -- terms of the GNU General Public License as published by the Free Soft- -- -- ware Foundation; either version 3, or (at your option) any later ver- -- -- sion. GNAT is distributed in the hope that it will be useful, but WITH- -- -- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY -- -- or FITNESS FOR A PARTICULAR PURPOSE. -- -- -- -- As a special exception under Section 7 of GPL version 3, you are granted -- -- additional permissions described in the GCC Runtime Library Exception, -- -- version 3.1, as published by the Free Software Foundation. -- -- -- -- You should have received a copy of the GNU General Public License and -- -- a copy of the GCC Runtime Library Exception along with this program; -- -- see the files COPYING3 and COPYING.RUNTIME respectively. If not, see -- -- <http://www.gnu.org/licenses/>. -- -- -- -- GNAT was originally developed by the GNAT team at New York University. -- -- Extensive contributions were provided by Ada Core Technologies Inc. -- -- -- ------------------------------------------------------------------------------ with Ada.Strings.Search; with Ada.Unchecked_Deallocation; package body Ada.Strings.Unbounded is use Ada.Strings.Maps; Growth_Factor : constant := 2; -- The growth factor controls how much extra space is allocated when -- we have to increase the size of an allocated unbounded string. By -- allocating extra space, we avoid the need to reallocate on every -- append, particularly important when a string is built up by repeated -- append operations of small pieces. This is expressed as a factor so -- 2 means add 1/2 of the length of the string as growth space. Min_Mul_Alloc : constant := Standard'Maximum_Alignment; -- Allocation will be done by a multiple of Min_Mul_Alloc. This causes -- no memory loss as most (all?) malloc implementations are obliged to -- align the returned memory on the maximum alignment as malloc does not -- know the target alignment. function Aligned_Max_Length (Required_Length : Natural; Reserved_Length : Natural) return Natural; -- Returns recommended length of the shared string which is greater or -- equal to specified required length and desired reserved length. -- Calculation takes into account alignment of the allocated memory -- segments to use memory effectively by Append/Insert/etc operations. function Sum (Left : Natural; Right : Integer) return Natural with Inline; -- Returns summary of Left and Right, raise Constraint_Error on overflow function Mul (Left, Right : Natural) return Natural with Inline; -- Returns multiplication of Left and Right, raise Constraint_Error on -- overflow --------- -- "&" -- --------- function "&" (Left : Unbounded_String; Right : Unbounded_String) return Unbounded_String is LR : constant Shared_String_Access := Left.Reference; RR : constant Shared_String_Access := Right.Reference; DL : constant Natural := Sum (LR.Last, RR.Last); DR : Shared_String_Access; begin -- Result is an empty string, reuse shared empty string if DL = 0 then DR := Empty_Shared_String'Access; -- Left string is empty, return Right string elsif LR.Last = 0 then Reference (RR); DR := RR; -- Right string is empty, return Left string elsif RR.Last = 0 then Reference (LR); DR := LR; -- Otherwise, allocate new shared string and fill data else DR := Allocate (DL); DR.Data (1 .. LR.Last) := LR.Data (1 .. LR.Last); DR.Data (LR.Last + 1 .. DL) := RR.Data (1 .. RR.Last); DR.Last := DL; end if; return (AF.Controlled with Reference => DR); end "&"; function "&" (Left : Unbounded_String; Right : String) return Unbounded_String is LR : constant Shared_String_Access := Left.Reference; DL : constant Natural := Sum (LR.Last, Right'Length); DR : Shared_String_Access; begin -- Result is an empty string, reuse shared empty string if DL = 0 then DR := Empty_Shared_String'Access; -- Right is an empty string, return Left string elsif Right'Length = 0 then Reference (LR); DR := LR; -- Otherwise, allocate new shared string and fill it else DR := Allocate (DL); DR.Data (1 .. LR.Last) := LR.Data (1 .. LR.Last); DR.Data (LR.Last + 1 .. DL) := Right; DR.Last := DL; end if; return (AF.Controlled with Reference => DR); end "&"; function "&" (Left : String; Right : Unbounded_String) return Unbounded_String is RR : constant Shared_String_Access := Right.Reference; DL : constant Natural := Sum (Left'Length, RR.Last); DR : Shared_String_Access; begin -- Result is an empty string, reuse shared one if DL = 0 then DR := Empty_Shared_String'Access; -- Left is empty string, return Right string elsif Left'Length = 0 then Reference (RR); DR := RR; -- Otherwise, allocate new shared string and fill it else DR := Allocate (DL); DR.Data (1 .. Left'Length) := Left; DR.Data (Left'Length + 1 .. DL) := RR.Data (1 .. RR.Last); DR.Last := DL; end if; return (AF.Controlled with Reference => DR); end "&"; function "&" (Left : Unbounded_String; Right : Character) return Unbounded_String is LR : constant Shared_String_Access := Left.Reference; DL : constant Natural := Sum (LR.Last, 1); DR : Shared_String_Access; begin DR := Allocate (DL); DR.Data (1 .. LR.Last) := LR.Data (1 .. LR.Last); DR.Data (DL) := Right; DR.Last := DL; return (AF.Controlled with Reference => DR); end "&"; function "&" (Left : Character; Right : Unbounded_String) return Unbounded_String is RR : constant Shared_String_Access := Right.Reference; DL : constant Natural := Sum (1, RR.Last); DR : Shared_String_Access; begin DR := Allocate (DL); DR.Data (1) := Left; DR.Data (2 .. DL) := RR.Data (1 .. RR.Last); DR.Last := DL; return (AF.Controlled with Reference => DR); end "&"; --------- -- "*" -- --------- function "*" (Left : Natural; Right : Character) return Unbounded_String is DR : Shared_String_Access; begin -- Result is an empty string, reuse shared empty string if Left = 0 then DR := Empty_Shared_String'Access; -- Otherwise, allocate new shared string and fill it else DR := Allocate (Left); for J in 1 .. Left loop DR.Data (J) := Right; end loop; DR.Last := Left; end if; return (AF.Controlled with Reference => DR); end "*"; function "*" (Left : Natural; Right : String) return Unbounded_String is DL : constant Natural := Mul (Left, Right'Length); DR : Shared_String_Access; K : Positive; begin -- Result is an empty string, reuse shared empty string if DL = 0 then DR := Empty_Shared_String'Access; -- Otherwise, allocate new shared string and fill it else DR := Allocate (DL); K := 1; for J in 1 .. Left loop DR.Data (K .. K + Right'Length - 1) := Right; K := K + Right'Length; end loop; DR.Last := DL; end if; return (AF.Controlled with Reference => DR); end "*"; function "*" (Left : Natural; Right : Unbounded_String) return Unbounded_String is RR : constant Shared_String_Access := Right.Reference; DL : constant Natural := Mul (Left, RR.Last); DR : Shared_String_Access; K : Positive; begin -- Result is an empty string, reuse shared empty string if DL = 0 then DR := Empty_Shared_String'Access; -- Coefficient is one, just return string itself elsif Left = 1 then Reference (RR); DR := RR; -- Otherwise, allocate new shared string and fill it else DR := Allocate (DL); K := 1; for J in 1 .. Left loop DR.Data (K .. K + RR.Last - 1) := RR.Data (1 .. RR.Last); K := K + RR.Last; end loop; DR.Last := DL; end if; return (AF.Controlled with Reference => DR); end "*"; --------- -- "<" -- --------- function "<" (Left : Unbounded_String; Right : Unbounded_String) return Boolean is LR : constant Shared_String_Access := Left.Reference; RR : constant Shared_String_Access := Right.Reference; begin return LR.Data (1 .. LR.Last) < RR.Data (1 .. RR.Last); end "<"; function "<" (Left : Unbounded_String; Right : String) return Boolean is LR : constant Shared_String_Access := Left.Reference; begin return LR.Data (1 .. LR.Last) < Right; end "<"; function "<" (Left : String; Right : Unbounded_String) return Boolean is RR : constant Shared_String_Access := Right.Reference; begin return Left < RR.Data (1 .. RR.Last); end "<"; ---------- -- "<=" -- ---------- function "<=" (Left : Unbounded_String; Right : Unbounded_String) return Boolean is LR : constant Shared_String_Access := Left.Reference; RR : constant Shared_String_Access := Right.Reference; begin -- LR = RR means two strings shares shared string, thus they are equal return LR = RR or else LR.Data (1 .. LR.Last) <= RR.Data (1 .. RR.Last); end "<="; function "<=" (Left : Unbounded_String; Right : String) return Boolean is LR : constant Shared_String_Access := Left.Reference; begin return LR.Data (1 .. LR.Last) <= Right; end "<="; function "<=" (Left : String; Right : Unbounded_String) return Boolean is RR : constant Shared_String_Access := Right.Reference; begin return Left <= RR.Data (1 .. RR.Last); end "<="; --------- -- "=" -- --------- function "=" (Left : Unbounded_String; Right : Unbounded_String) return Boolean is LR : constant Shared_String_Access := Left.Reference; RR : constant Shared_String_Access := Right.Reference; begin return LR = RR or else LR.Data (1 .. LR.Last) = RR.Data (1 .. RR.Last); -- LR = RR means two strings shares shared string, thus they are equal end "="; function "=" (Left : Unbounded_String; Right : String) return Boolean is LR : constant Shared_String_Access := Left.Reference; begin return LR.Data (1 .. LR.Last) = Right; end "="; function "=" (Left : String; Right : Unbounded_String) return Boolean is RR : constant Shared_String_Access := Right.Reference; begin return Left = RR.Data (1 .. RR.Last); end "="; --------- -- ">" -- --------- function ">" (Left : Unbounded_String; Right : Unbounded_String) return Boolean is LR : constant Shared_String_Access := Left.Reference; RR : constant Shared_String_Access := Right.Reference; begin return LR.Data (1 .. LR.Last) > RR.Data (1 .. RR.Last); end ">"; function ">" (Left : Unbounded_String; Right : String) return Boolean is LR : constant Shared_String_Access := Left.Reference; begin return LR.Data (1 .. LR.Last) > Right; end ">"; function ">" (Left : String; Right : Unbounded_String) return Boolean is RR : constant Shared_String_Access := Right.Reference; begin return Left > RR.Data (1 .. RR.Last); end ">"; ---------- -- ">=" -- ---------- function ">=" (Left : Unbounded_String; Right : Unbounded_String) return Boolean is LR : constant Shared_String_Access := Left.Reference; RR : constant Shared_String_Access := Right.Reference; begin -- LR = RR means two strings shares shared string, thus they are equal return LR = RR or else LR.Data (1 .. LR.Last) >= RR.Data (1 .. RR.Last); end ">="; function ">=" (Left : Unbounded_String; Right : String) return Boolean is LR : constant Shared_String_Access := Left.Reference; begin return LR.Data (1 .. LR.Last) >= Right; end ">="; function ">=" (Left : String; Right : Unbounded_String) return Boolean is RR : constant Shared_String_Access := Right.Reference; begin return Left >= RR.Data (1 .. RR.Last); end ">="; ------------ -- Adjust -- ------------ procedure Adjust (Object : in out Unbounded_String) is begin Reference (Object.Reference); end Adjust; ------------------------ -- Aligned_Max_Length -- ------------------------ function Aligned_Max_Length (Required_Length : Natural; Reserved_Length : Natural) return Natural is Static_Size : constant Natural := Empty_Shared_String'Size / Standard'Storage_Unit; -- Total size of all Shared_String static components begin if Required_Length > Natural'Last - Static_Size - Reserved_Length then -- Total requested length is larger than maximum possible length. -- Use of Static_Size needed to avoid overflows in expression to -- compute aligned length. return Natural'Last; else return ((Static_Size + Required_Length + Reserved_Length - 1) / Min_Mul_Alloc + 2) * Min_Mul_Alloc - Static_Size; end if; end Aligned_Max_Length; -------------- -- Allocate -- -------------- function Allocate (Required_Length : Natural; Reserved_Length : Natural := 0) return not null Shared_String_Access is begin -- Empty string requested, return shared empty string if Required_Length = 0 then return Empty_Shared_String'Access; -- Otherwise, allocate requested space (and probably some more room) else return new Shared_String (Aligned_Max_Length (Required_Length, Reserved_Length)); end if; end Allocate; ------------ -- Append -- ------------ procedure Append (Source : in out Unbounded_String; New_Item : Unbounded_String) is SR : constant Shared_String_Access := Source.Reference; NR : constant Shared_String_Access := New_Item.Reference; DL : constant Natural := Sum (SR.Last, NR.Last); DR : Shared_String_Access; begin -- Source is an empty string, reuse New_Item data if SR.Last = 0 then Reference (NR); Source.Reference := NR; Unreference (SR); -- New_Item is empty string, nothing to do elsif NR.Last = 0 then null; -- Try to reuse existing shared string elsif Can_Be_Reused (SR, DL) then SR.Data (SR.Last + 1 .. DL) := NR.Data (1 .. NR.Last); SR.Last := DL; -- Otherwise, allocate new one and fill it else DR := Allocate (DL, DL / Growth_Factor); DR.Data (1 .. SR.Last) := SR.Data (1 .. SR.Last); DR.Data (SR.Last + 1 .. DL) := NR.Data (1 .. NR.Last); DR.Last := DL; Source.Reference := DR; Unreference (SR); end if; end Append; procedure Append (Source : in out Unbounded_String; New_Item : String) is SR : constant Shared_String_Access := Source.Reference; DL : constant Natural := Sum (SR.Last, New_Item'Length); DR : Shared_String_Access; begin -- New_Item is an empty string, nothing to do if New_Item'Length = 0 then null; -- Try to reuse existing shared string elsif Can_Be_Reused (SR, DL) then SR.Data (SR.Last + 1 .. DL) := New_Item; SR.Last := DL; -- Otherwise, allocate new one and fill it else DR := Allocate (DL, DL / Growth_Factor); DR.Data (1 .. SR.Last) := SR.Data (1 .. SR.Last); DR.Data (SR.Last + 1 .. DL) := New_Item; DR.Last := DL; Source.Reference := DR; Unreference (SR); end if; end Append; procedure Append (Source : in out Unbounded_String; New_Item : Character) is SR : constant Shared_String_Access := Source.Reference; DL : constant Natural := Sum (SR.Last, 1); DR : Shared_String_Access; begin -- Try to reuse existing shared string if Can_Be_Reused (SR, DL) then SR.Data (SR.Last + 1) := New_Item; SR.Last := SR.Last + 1; -- Otherwise, allocate new one and fill it else DR := Allocate (DL, DL / Growth_Factor); DR.Data (1 .. SR.Last) := SR.Data (1 .. SR.Last); DR.Data (DL) := New_Item; DR.Last := DL; Source.Reference := DR; Unreference (SR); end if; end Append; ------------------- -- Can_Be_Reused -- ------------------- function Can_Be_Reused (Item : not null Shared_String_Access; Length : Natural) return Boolean is begin return System.Atomic_Counters.Is_One (Item.Counter) and then Item.Max_Length >= Length and then Item.Max_Length <= Aligned_Max_Length (Length, Length / Growth_Factor); end Can_Be_Reused; ----------- -- Count -- ----------- function Count (Source : Unbounded_String; Pattern : String; Mapping : Maps.Character_Mapping := Maps.Identity) return Natural is SR : constant Shared_String_Access := Source.Reference; begin return Search.Count (SR.Data (1 .. SR.Last), Pattern, Mapping); end Count; function Count (Source : Unbounded_String; Pattern : String; Mapping : Maps.Character_Mapping_Function) return Natural is SR : constant Shared_String_Access := Source.Reference; begin return Search.Count (SR.Data (1 .. SR.Last), Pattern, Mapping); end Count; function Count (Source : Unbounded_String; Set : Maps.Character_Set) return Natural is SR : constant Shared_String_Access := Source.Reference; begin return Search.Count (SR.Data (1 .. SR.Last), Set); end Count; ------------ -- Delete -- ------------ function Delete (Source : Unbounded_String; From : Positive; Through : Natural) return Unbounded_String is SR : constant Shared_String_Access := Source.Reference; DL : Natural; DR : Shared_String_Access; begin -- Empty slice is deleted, use the same shared string if From > Through then Reference (SR); DR := SR; -- Index is out of range elsif Through > SR.Last then raise Index_Error; -- Compute size of the result else DL := SR.Last - (Through - From + 1); -- Result is an empty string, reuse shared empty string if DL = 0 then DR := Empty_Shared_String'Access; -- Otherwise, allocate new shared string and fill it else DR := Allocate (DL); DR.Data (1 .. From - 1) := SR.Data (1 .. From - 1); DR.Data (From .. DL) := SR.Data (Through + 1 .. SR.Last); DR.Last := DL; end if; end if; return (AF.Controlled with Reference => DR); end Delete; procedure Delete (Source : in out Unbounded_String; From : Positive; Through : Natural) is SR : constant Shared_String_Access := Source.Reference; DL : Natural; DR : Shared_String_Access; begin -- Nothing changed, return if From > Through then null; -- Through is outside of the range elsif Through > SR.Last then raise Index_Error; else DL := SR.Last - (Through - From + 1); -- Result is empty, reuse shared empty string if DL = 0 then Source.Reference := Empty_Shared_String'Access; Unreference (SR); -- Try to reuse existing shared string elsif Can_Be_Reused (SR, DL) then SR.Data (From .. DL) := SR.Data (Through + 1 .. SR.Last); SR.Last := DL; -- Otherwise, allocate new shared string else DR := Allocate (DL); DR.Data (1 .. From - 1) := SR.Data (1 .. From - 1); DR.Data (From .. DL) := SR.Data (Through + 1 .. SR.Last); DR.Last := DL; Source.Reference := DR; Unreference (SR); end if; end if; end Delete; ------------- -- Element -- ------------- function Element (Source : Unbounded_String; Index : Positive) return Character is SR : constant Shared_String_Access := Source.Reference; begin if Index <= SR.Last then return SR.Data (Index); else raise Index_Error; end if; end Element; -------------- -- Finalize -- -------------- procedure Finalize (Object : in out Unbounded_String) is SR : constant not null Shared_String_Access := Object.Reference; begin if SR /= Null_Unbounded_String.Reference then -- The same controlled object can be finalized several times for -- some reason. As per 7.6.1(24) this should have no ill effect, -- so we need to add a guard for the case of finalizing the same -- object twice. -- We set the Object to the empty string so there will be no ill -- effects if a program references an already-finalized object. Object.Reference := Null_Unbounded_String.Reference; Unreference (SR); end if; end Finalize; ---------------- -- Find_Token -- ---------------- procedure Find_Token (Source : Unbounded_String; Set : Maps.Character_Set; From : Positive; Test : Strings.Membership; First : out Positive; Last : out Natural) is SR : constant Shared_String_Access := Source.Reference; begin Search.Find_Token (SR.Data (From .. SR.Last), Set, Test, First, Last); end Find_Token; procedure Find_Token (Source : Unbounded_String; Set : Maps.Character_Set; Test : Strings.Membership; First : out Positive; Last : out Natural) is SR : constant Shared_String_Access := Source.Reference; begin Search.Find_Token (SR.Data (1 .. SR.Last), Set, Test, First, Last); end Find_Token; ---------- -- Free -- ---------- procedure Free (X : in out String_Access) is procedure Deallocate is new Ada.Unchecked_Deallocation (String, String_Access); begin Deallocate (X); end Free; ---------- -- Head -- ---------- function Head (Source : Unbounded_String; Count : Natural; Pad : Character := Space) return Unbounded_String is SR : constant Shared_String_Access := Source.Reference; DR : Shared_String_Access; begin -- Result is empty, reuse shared empty string if Count = 0 then DR := Empty_Shared_String'Access; -- Length of the string is the same as requested, reuse source shared -- string. elsif Count = SR.Last then Reference (SR); DR := SR; -- Otherwise, allocate new shared string and fill it else DR := Allocate (Count); -- Length of the source string is more than requested, copy -- corresponding slice. if Count < SR.Last then DR.Data (1 .. Count) := SR.Data (1 .. Count); -- Length of the source string is less than requested, copy all -- contents and fill others by Pad character. else DR.Data (1 .. SR.Last) := SR.Data (1 .. SR.Last); for J in SR.Last + 1 .. Count loop DR.Data (J) := Pad; end loop; end if; DR.Last := Count; end if; return (AF.Controlled with Reference => DR); end Head; procedure Head (Source : in out Unbounded_String; Count : Natural; Pad : Character := Space) is SR : constant Shared_String_Access := Source.Reference; DR : Shared_String_Access; begin -- Result is empty, reuse empty shared string if Count = 0 then Source.Reference := Empty_Shared_String'Access; Unreference (SR); -- Result is same as source string, reuse source shared string elsif Count = SR.Last then null; -- Try to reuse existing shared string elsif Can_Be_Reused (SR, Count) then if Count > SR.Last then for J in SR.Last + 1 .. Count loop SR.Data (J) := Pad; end loop; end if; SR.Last := Count; -- Otherwise, allocate new shared string and fill it else DR := Allocate (Count); -- Length of the source string is greater than requested, copy -- corresponding slice. if Count < SR.Last then DR.Data (1 .. Count) := SR.Data (1 .. Count); -- Length of the source string is less than requested, copy all -- existing data and fill remaining positions with Pad characters. else DR.Data (1 .. SR.Last) := SR.Data (1 .. SR.Last); for J in SR.Last + 1 .. Count loop DR.Data (J) := Pad; end loop; end if; DR.Last := Count; Source.Reference := DR; Unreference (SR); end if; end Head; ----------- -- Index -- ----------- function Index (Source : Unbounded_String; Pattern : String; Going : Strings.Direction := Strings.Forward; Mapping : Maps.Character_Mapping := Maps.Identity) return Natural is SR : constant Shared_String_Access := Source.Reference; begin return Search.Index (SR.Data (1 .. SR.Last), Pattern, Going, Mapping); end Index; function Index (Source : Unbounded_String; Pattern : String; Going : Direction := Forward; Mapping : Maps.Character_Mapping_Function) return Natural is SR : constant Shared_String_Access := Source.Reference; begin return Search.Index (SR.Data (1 .. SR.Last), Pattern, Going, Mapping); end Index; function Index (Source : Unbounded_String; Set : Maps.Character_Set; Test : Strings.Membership := Strings.Inside; Going : Strings.Direction := Strings.Forward) return Natural is SR : constant Shared_String_Access := Source.Reference; begin return Search.Index (SR.Data (1 .. SR.Last), Set, Test, Going); end Index; function Index (Source : Unbounded_String; Pattern : String; From : Positive; Going : Direction := Forward; Mapping : Maps.Character_Mapping := Maps.Identity) return Natural is SR : constant Shared_String_Access := Source.Reference; begin return Search.Index (SR.Data (1 .. SR.Last), Pattern, From, Going, Mapping); end Index; function Index (Source : Unbounded_String; Pattern : String; From : Positive; Going : Direction := Forward; Mapping : Maps.Character_Mapping_Function) return Natural is SR : constant Shared_String_Access := Source.Reference; begin return Search.Index (SR.Data (1 .. SR.Last), Pattern, From, Going, Mapping); end Index; function Index (Source : Unbounded_String; Set : Maps.Character_Set; From : Positive; Test : Membership := Inside; Going : Direction := Forward) return Natural is SR : constant Shared_String_Access := Source.Reference; begin return Search.Index (SR.Data (1 .. SR.Last), Set, From, Test, Going); end Index; --------------------- -- Index_Non_Blank -- --------------------- function Index_Non_Blank (Source : Unbounded_String; Going : Strings.Direction := Strings.Forward) return Natural is SR : constant Shared_String_Access := Source.Reference; begin return Search.Index_Non_Blank (SR.Data (1 .. SR.Last), Going); end Index_Non_Blank; function Index_Non_Blank (Source : Unbounded_String; From : Positive; Going : Direction := Forward) return Natural is SR : constant Shared_String_Access := Source.Reference; begin return Search.Index_Non_Blank (SR.Data (1 .. SR.Last), From, Going); end Index_Non_Blank; ---------------- -- Initialize -- ---------------- procedure Initialize (Object : in out Unbounded_String) is begin Reference (Object.Reference); end Initialize; ------------ -- Insert -- ------------ function Insert (Source : Unbounded_String; Before : Positive; New_Item : String) return Unbounded_String is SR : constant Shared_String_Access := Source.Reference; DL : constant Natural := SR.Last + New_Item'Length; DR : Shared_String_Access; begin -- Check index first if Before > SR.Last + 1 then raise Index_Error; end if; -- Result is empty, reuse empty shared string if DL = 0 then DR := Empty_Shared_String'Access; -- Inserted string is empty, reuse source shared string elsif New_Item'Length = 0 then Reference (SR); DR := SR; -- Otherwise, allocate new shared string and fill it else DR := Allocate (DL, DL / Growth_Factor); DR.Data (1 .. Before - 1) := SR.Data (1 .. Before - 1); DR.Data (Before .. Before + New_Item'Length - 1) := New_Item; DR.Data (Before + New_Item'Length .. DL) := SR.Data (Before .. SR.Last); DR.Last := DL; end if; return (AF.Controlled with Reference => DR); end Insert; procedure Insert (Source : in out Unbounded_String; Before : Positive; New_Item : String) is SR : constant Shared_String_Access := Source.Reference; DL : constant Natural := SR.Last + New_Item'Length; DR : Shared_String_Access; begin -- Check bounds if Before > SR.Last + 1 then raise Index_Error; end if; -- Result is empty string, reuse empty shared string if DL = 0 then Source.Reference := Empty_Shared_String'Access; Unreference (SR); -- Inserted string is empty, nothing to do elsif New_Item'Length = 0 then null; -- Try to reuse existing shared string first elsif Can_Be_Reused (SR, DL) then SR.Data (Before + New_Item'Length .. DL) := SR.Data (Before .. SR.Last); SR.Data (Before .. Before + New_Item'Length - 1) := New_Item; SR.Last := DL; -- Otherwise, allocate new shared string and fill it else DR := Allocate (DL, DL / Growth_Factor); DR.Data (1 .. Before - 1) := SR.Data (1 .. Before - 1); DR.Data (Before .. Before + New_Item'Length - 1) := New_Item; DR.Data (Before + New_Item'Length .. DL) := SR.Data (Before .. SR.Last); DR.Last := DL; Source.Reference := DR; Unreference (SR); end if; end Insert; ------------ -- Length -- ------------ function Length (Source : Unbounded_String) return Natural is begin return Source.Reference.Last; end Length; --------- -- Mul -- --------- function Mul (Left, Right : Natural) return Natural is pragma Unsuppress (Overflow_Check); begin return Left * Right; end Mul; --------------- -- Overwrite -- --------------- function Overwrite (Source : Unbounded_String; Position : Positive; New_Item : String) return Unbounded_String is SR : constant Shared_String_Access := Source.Reference; DL : Natural; DR : Shared_String_Access; begin -- Check bounds if Position > SR.Last + 1 then raise Index_Error; end if; DL := Integer'Max (SR.Last, Sum (Position - 1, New_Item'Length)); -- Result is empty string, reuse empty shared string if DL = 0 then DR := Empty_Shared_String'Access; -- Result is same as source string, reuse source shared string elsif New_Item'Length = 0 then Reference (SR); DR := SR; -- Otherwise, allocate new shared string and fill it else DR := Allocate (DL); DR.Data (1 .. Position - 1) := SR.Data (1 .. Position - 1); DR.Data (Position .. Position + New_Item'Length - 1) := New_Item; DR.Data (Position + New_Item'Length .. DL) := SR.Data (Position + New_Item'Length .. SR.Last); DR.Last := DL; end if; return (AF.Controlled with Reference => DR); end Overwrite; procedure Overwrite (Source : in out Unbounded_String; Position : Positive; New_Item : String) is SR : constant Shared_String_Access := Source.Reference; DL : Natural; DR : Shared_String_Access; begin -- Bounds check if Position > SR.Last + 1 then raise Index_Error; end if; DL := Integer'Max (SR.Last, Position + New_Item'Length - 1); -- Result is empty string, reuse empty shared string if DL = 0 then Source.Reference := Empty_Shared_String'Access; Unreference (SR); -- String unchanged, nothing to do elsif New_Item'Length = 0 then null; -- Try to reuse existing shared string elsif Can_Be_Reused (SR, DL) then SR.Data (Position .. Position + New_Item'Length - 1) := New_Item; SR.Last := DL; -- Otherwise allocate new shared string and fill it else DR := Allocate (DL); DR.Data (1 .. Position - 1) := SR.Data (1 .. Position - 1); DR.Data (Position .. Position + New_Item'Length - 1) := New_Item; DR.Data (Position + New_Item'Length .. DL) := SR.Data (Position + New_Item'Length .. SR.Last); DR.Last := DL; Source.Reference := DR; Unreference (SR); end if; end Overwrite; --------------- -- Put_Image -- --------------- procedure Put_Image (S : in out Ada.Strings.Text_Buffers.Root_Buffer_Type'Class; V : Unbounded_String) is begin String'Put_Image (S, To_String (V)); end Put_Image; --------------- -- Reference -- --------------- procedure Reference (Item : not null Shared_String_Access) is begin if Item = Empty_Shared_String'Access then return; end if; System.Atomic_Counters.Increment (Item.Counter); end Reference; --------------------- -- Replace_Element -- --------------------- procedure Replace_Element (Source : in out Unbounded_String; Index : Positive; By : Character) is SR : constant Shared_String_Access := Source.Reference; DR : Shared_String_Access; begin -- Bounds check if Index <= SR.Last then -- Try to reuse existing shared string if Can_Be_Reused (SR, SR.Last) then SR.Data (Index) := By; -- Otherwise allocate new shared string and fill it else DR := Allocate (SR.Last); DR.Data (1 .. SR.Last) := SR.Data (1 .. SR.Last); DR.Data (Index) := By; DR.Last := SR.Last; Source.Reference := DR; Unreference (SR); end if; else raise Index_Error; end if; end Replace_Element; ------------------- -- Replace_Slice -- ------------------- function Replace_Slice (Source : Unbounded_String; Low : Positive; High : Natural; By : String) return Unbounded_String is SR : constant Shared_String_Access := Source.Reference; DL : Natural; DR : Shared_String_Access; begin -- Check bounds if Low > SR.Last + 1 then raise Index_Error; end if; -- Do replace operation when removed slice is not empty if High >= Low then DL := Sum (SR.Last, By'Length + Low - Integer'Min (High, SR.Last) - 1); -- This is the number of characters remaining in the string after -- replacing the slice. -- Result is empty string, reuse empty shared string if DL = 0 then DR := Empty_Shared_String'Access; -- Otherwise allocate new shared string and fill it else DR := Allocate (DL); DR.Data (1 .. Low - 1) := SR.Data (1 .. Low - 1); DR.Data (Low .. Low + By'Length - 1) := By; DR.Data (Low + By'Length .. DL) := SR.Data (High + 1 .. SR.Last); DR.Last := DL; end if; return (AF.Controlled with Reference => DR); -- Otherwise just insert string else return Insert (Source, Low, By); end if; end Replace_Slice; procedure Replace_Slice (Source : in out Unbounded_String; Low : Positive; High : Natural; By : String) is SR : constant Shared_String_Access := Source.Reference; DL : Natural; DR : Shared_String_Access; begin -- Bounds check if Low > SR.Last + 1 then raise Index_Error; end if; -- Do replace operation only when replaced slice is not empty if High >= Low then DL := By'Length + SR.Last + Low - Integer'Min (High, SR.Last) - 1; -- This is the number of characters remaining in the string after -- replacing the slice. -- Result is empty string, reuse empty shared string if DL = 0 then Source.Reference := Empty_Shared_String'Access; Unreference (SR); -- Try to reuse existing shared string elsif Can_Be_Reused (SR, DL) then SR.Data (Low + By'Length .. DL) := SR.Data (High + 1 .. SR.Last); SR.Data (Low .. Low + By'Length - 1) := By; SR.Last := DL; -- Otherwise allocate new shared string and fill it else DR := Allocate (DL); DR.Data (1 .. Low - 1) := SR.Data (1 .. Low - 1); DR.Data (Low .. Low + By'Length - 1) := By; DR.Data (Low + By'Length .. DL) := SR.Data (High + 1 .. SR.Last); DR.Last := DL; Source.Reference := DR; Unreference (SR); end if; -- Otherwise just insert item else Insert (Source, Low, By); end if; end Replace_Slice; -------------------------- -- Set_Unbounded_String -- -------------------------- procedure Set_Unbounded_String (Target : out Unbounded_String; Source : String) is TR : constant Shared_String_Access := Target.Reference; DR : Shared_String_Access; begin -- In case of empty string, reuse empty shared string if Source'Length = 0 then Target.Reference := Empty_Shared_String'Access; else -- Try to reuse existing shared string if Can_Be_Reused (TR, Source'Length) then Reference (TR); DR := TR; -- Otherwise allocate new shared string else DR := Allocate (Source'Length); Target.Reference := DR; end if; DR.Data (1 .. Source'Length) := Source; DR.Last := Source'Length; end if; Unreference (TR); end Set_Unbounded_String; ----------- -- Slice -- ----------- function Slice (Source : Unbounded_String; Low : Positive; High : Natural) return String is SR : constant Shared_String_Access := Source.Reference; begin -- Note: test of High > Length is in accordance with AI95-00128 if Low > SR.Last + 1 or else High > SR.Last then raise Index_Error; else return SR.Data (Low .. High); end if; end Slice; --------- -- Sum -- --------- function Sum (Left : Natural; Right : Integer) return Natural is pragma Unsuppress (Overflow_Check); begin return Left + Right; end Sum; ---------- -- Tail -- ---------- function Tail (Source : Unbounded_String; Count : Natural; Pad : Character := Space) return Unbounded_String is SR : constant Shared_String_Access := Source.Reference; DR : Shared_String_Access; begin -- For empty result reuse empty shared string if Count = 0 then DR := Empty_Shared_String'Access; -- Result is whole source string, reuse source shared string elsif Count = SR.Last then Reference (SR); DR := SR; -- Otherwise allocate new shared string and fill it else DR := Allocate (Count); if Count < SR.Last then DR.Data (1 .. Count) := SR.Data (SR.Last - Count + 1 .. SR.Last); else for J in 1 .. Count - SR.Last loop DR.Data (J) := Pad; end loop; DR.Data (Count - SR.Last + 1 .. Count) := SR.Data (1 .. SR.Last); end if; DR.Last := Count; end if; return (AF.Controlled with Reference => DR); end Tail; procedure Tail (Source : in out Unbounded_String; Count : Natural; Pad : Character := Space) is SR : constant Shared_String_Access := Source.Reference; DR : Shared_String_Access; procedure Common (SR : Shared_String_Access; DR : Shared_String_Access; Count : Natural); -- Common code of tail computation. SR/DR can point to the same object ------------ -- Common -- ------------ procedure Common (SR : Shared_String_Access; DR : Shared_String_Access; Count : Natural) is begin if Count < SR.Last then DR.Data (1 .. Count) := SR.Data (SR.Last - Count + 1 .. SR.Last); else DR.Data (Count - SR.Last + 1 .. Count) := SR.Data (1 .. SR.Last); for J in 1 .. Count - SR.Last loop DR.Data (J) := Pad; end loop; end if; DR.Last := Count; end Common; begin -- Result is empty string, reuse empty shared string if Count = 0 then Source.Reference := Empty_Shared_String'Access; Unreference (SR); -- Length of the result is the same as length of the source string, -- reuse source shared string. elsif Count = SR.Last then null; -- Try to reuse existing shared string elsif Can_Be_Reused (SR, Count) then Common (SR, SR, Count); -- Otherwise allocate new shared string and fill it else DR := Allocate (Count); Common (SR, DR, Count); Source.Reference := DR; Unreference (SR); end if; end Tail; --------------- -- To_String -- --------------- function To_String (Source : Unbounded_String) return String is begin return Source.Reference.Data (1 .. Source.Reference.Last); end To_String; ------------------------- -- To_Unbounded_String -- ------------------------- function To_Unbounded_String (Source : String) return Unbounded_String is DR : Shared_String_Access; begin if Source'Length = 0 then DR := Empty_Shared_String'Access; else DR := Allocate (Source'Length); DR.Data (1 .. Source'Length) := Source; DR.Last := Source'Length; end if; return (AF.Controlled with Reference => DR); end To_Unbounded_String; function To_Unbounded_String (Length : Natural) return Unbounded_String is DR : Shared_String_Access; begin if Length = 0 then DR := Empty_Shared_String'Access; else DR := Allocate (Length); DR.Last := Length; end if; return (AF.Controlled with Reference => DR); end To_Unbounded_String; --------------- -- Translate -- --------------- function Translate (Source : Unbounded_String; Mapping : Maps.Character_Mapping) return Unbounded_String is SR : constant Shared_String_Access := Source.Reference; DR : Shared_String_Access; begin -- Nothing to translate, reuse empty shared string if SR.Last = 0 then DR := Empty_Shared_String'Access; -- Otherwise, allocate new shared string and fill it else DR := Allocate (SR.Last); for J in 1 .. SR.Last loop DR.Data (J) := Value (Mapping, SR.Data (J)); end loop; DR.Last := SR.Last; end if; return (AF.Controlled with Reference => DR); end Translate; procedure Translate (Source : in out Unbounded_String; Mapping : Maps.Character_Mapping) is SR : constant Shared_String_Access := Source.Reference; DR : Shared_String_Access; begin -- Nothing to translate if SR.Last = 0 then null; -- Try to reuse shared string elsif Can_Be_Reused (SR, SR.Last) then for J in 1 .. SR.Last loop SR.Data (J) := Value (Mapping, SR.Data (J)); end loop; -- Otherwise, allocate new shared string else DR := Allocate (SR.Last); for J in 1 .. SR.Last loop DR.Data (J) := Value (Mapping, SR.Data (J)); end loop; DR.Last := SR.Last; Source.Reference := DR; Unreference (SR); end if; end Translate; function Translate (Source : Unbounded_String; Mapping : Maps.Character_Mapping_Function) return Unbounded_String is SR : constant Shared_String_Access := Source.Reference; DR : Shared_String_Access; begin -- Nothing to translate, reuse empty shared string if SR.Last = 0 then DR := Empty_Shared_String'Access; -- Otherwise, allocate new shared string and fill it else DR := Allocate (SR.Last); for J in 1 .. SR.Last loop DR.Data (J) := Mapping.all (SR.Data (J)); end loop; DR.Last := SR.Last; end if; return (AF.Controlled with Reference => DR); exception when others => Unreference (DR); raise; end Translate; procedure Translate (Source : in out Unbounded_String; Mapping : Maps.Character_Mapping_Function) is SR : constant Shared_String_Access := Source.Reference; DR : Shared_String_Access; begin -- Nothing to translate if SR.Last = 0 then null; -- Try to reuse shared string elsif Can_Be_Reused (SR, SR.Last) then for J in 1 .. SR.Last loop SR.Data (J) := Mapping.all (SR.Data (J)); end loop; -- Otherwise allocate new shared string and fill it else DR := Allocate (SR.Last); for J in 1 .. SR.Last loop DR.Data (J) := Mapping.all (SR.Data (J)); end loop; DR.Last := SR.Last; Source.Reference := DR; Unreference (SR); end if; exception when others => if DR /= null then Unreference (DR); end if; raise; end Translate; ---------- -- Trim -- ---------- function Trim (Source : Unbounded_String; Side : Trim_End) return Unbounded_String is SR : constant Shared_String_Access := Source.Reference; DL : Natural; DR : Shared_String_Access; Low : Natural; High : Natural; begin Low := Index_Non_Blank (Source, Forward); -- All blanks, reuse empty shared string if Low = 0 then DR := Empty_Shared_String'Access; else case Side is when Left => High := SR.Last; DL := SR.Last - Low + 1; when Right => Low := 1; High := Index_Non_Blank (Source, Backward); DL := High; when Both => High := Index_Non_Blank (Source, Backward); DL := High - Low + 1; end case; -- Length of the result is the same as length of the source string, -- reuse source shared string. if DL = SR.Last then Reference (SR); DR := SR; -- Otherwise, allocate new shared string else DR := Allocate (DL); DR.Data (1 .. DL) := SR.Data (Low .. High); DR.Last := DL; end if; end if; return (AF.Controlled with Reference => DR); end Trim; procedure Trim (Source : in out Unbounded_String; Side : Trim_End) is SR : constant Shared_String_Access := Source.Reference; DL : Natural; DR : Shared_String_Access; Low : Natural; High : Natural; begin Low := Index_Non_Blank (Source, Forward); -- All blanks, reuse empty shared string if Low = 0 then Source.Reference := Empty_Shared_String'Access; Unreference (SR); else case Side is when Left => High := SR.Last; DL := SR.Last - Low + 1; when Right => Low := 1; High := Index_Non_Blank (Source, Backward); DL := High; when Both => High := Index_Non_Blank (Source, Backward); DL := High - Low + 1; end case; -- Length of the result is the same as length of the source string, -- nothing to do. if DL = SR.Last then null; -- Try to reuse existing shared string elsif Can_Be_Reused (SR, DL) then SR.Data (1 .. DL) := SR.Data (Low .. High); SR.Last := DL; -- Otherwise, allocate new shared string else DR := Allocate (DL); DR.Data (1 .. DL) := SR.Data (Low .. High); DR.Last := DL; Source.Reference := DR; Unreference (SR); end if; end if; end Trim; function Trim (Source : Unbounded_String; Left : Maps.Character_Set; Right : Maps.Character_Set) return Unbounded_String is SR : constant Shared_String_Access := Source.Reference; DL : Natural; DR : Shared_String_Access; Low : Natural; High : Natural; begin Low := Index (Source, Left, Outside, Forward); -- Source includes only characters from Left set, reuse empty shared -- string. if Low = 0 then DR := Empty_Shared_String'Access; else High := Index (Source, Right, Outside, Backward); DL := Integer'Max (0, High - Low + 1); -- Source includes only characters from Right set or result string -- is empty, reuse empty shared string. if High = 0 or else DL = 0 then DR := Empty_Shared_String'Access; -- Otherwise, allocate new shared string and fill it else DR := Allocate (DL); DR.Data (1 .. DL) := SR.Data (Low .. High); DR.Last := DL; end if; end if; return (AF.Controlled with Reference => DR); end Trim; procedure Trim (Source : in out Unbounded_String; Left : Maps.Character_Set; Right : Maps.Character_Set) is SR : constant Shared_String_Access := Source.Reference; DL : Natural; DR : Shared_String_Access; Low : Natural; High : Natural; begin Low := Index (Source, Left, Outside, Forward); -- Source includes only characters from Left set, reuse empty shared -- string. if Low = 0 then Source.Reference := Empty_Shared_String'Access; Unreference (SR); else High := Index (Source, Right, Outside, Backward); DL := Integer'Max (0, High - Low + 1); -- Source includes only characters from Right set or result string -- is empty, reuse empty shared string. if High = 0 or else DL = 0 then Source.Reference := Empty_Shared_String'Access; Unreference (SR); -- Try to reuse existing shared string elsif Can_Be_Reused (SR, DL) then SR.Data (1 .. DL) := SR.Data (Low .. High); SR.Last := DL; -- Otherwise, allocate new shared string and fill it else DR := Allocate (DL); DR.Data (1 .. DL) := SR.Data (Low .. High); DR.Last := DL; Source.Reference := DR; Unreference (SR); end if; end if; end Trim; --------------------- -- Unbounded_Slice -- --------------------- function Unbounded_Slice (Source : Unbounded_String; Low : Positive; High : Natural) return Unbounded_String is SR : constant Shared_String_Access := Source.Reference; DL : Natural; DR : Shared_String_Access; begin -- Check bounds if Low - 1 > SR.Last or else High > SR.Last then raise Index_Error; -- Result is empty slice, reuse empty shared string elsif Low > High then DR := Empty_Shared_String'Access; -- Otherwise, allocate new shared string and fill it else DL := High - Low + 1; DR := Allocate (DL); DR.Data (1 .. DL) := SR.Data (Low .. High); DR.Last := DL; end if; return (AF.Controlled with Reference => DR); end Unbounded_Slice; procedure Unbounded_Slice (Source : Unbounded_String; Target : out Unbounded_String; Low : Positive; High : Natural) is SR : constant Shared_String_Access := Source.Reference; TR : constant Shared_String_Access := Target.Reference; DL : Natural; DR : Shared_String_Access; begin -- Check bounds if Low - 1 > SR.Last or else High > SR.Last then raise Index_Error; -- Result is empty slice, reuse empty shared string elsif Low > High then Target.Reference := Empty_Shared_String'Access; Unreference (TR); else DL := High - Low + 1; -- Try to reuse existing shared string if Can_Be_Reused (TR, DL) then TR.Data (1 .. DL) := SR.Data (Low .. High); TR.Last := DL; -- Otherwise, allocate new shared string and fill it else DR := Allocate (DL); DR.Data (1 .. DL) := SR.Data (Low .. High); DR.Last := DL; Target.Reference := DR; Unreference (TR); end if; end if; end Unbounded_Slice; ----------------- -- Unreference -- ----------------- procedure Unreference (Item : not null Shared_String_Access) is procedure Free is new Ada.Unchecked_Deallocation (Shared_String, Shared_String_Access); Aux : Shared_String_Access := Item; begin if Aux = Empty_Shared_String'Access then return; end if; if System.Atomic_Counters.Decrement (Aux.Counter) then Free (Aux); end if; end Unreference; end Ada.Strings.Unbounded;
reznikmm/matreshka
Ada
5,163
ads
------------------------------------------------------------------------------ -- -- -- Matreshka Project -- -- -- -- Ada Modeling Framework -- -- -- -- Runtime Library Component -- -- -- ------------------------------------------------------------------------------ -- -- -- Copyright © 2012-2013, Vadim Godunko <[email protected]> -- -- All rights reserved. -- -- -- -- Redistribution and use in source and binary forms, with or without -- -- modification, are permitted provided that the following conditions -- -- are met: -- -- -- -- * Redistributions of source code must retain the above copyright -- -- notice, this list of conditions and the following disclaimer. -- -- -- -- * Redistributions in binary form must reproduce the above copyright -- -- notice, this list of conditions and the following disclaimer in the -- -- documentation and/or other materials provided with the distribution. -- -- -- -- * Neither the name of the Vadim Godunko, IE nor the names of its -- -- contributors may be used to endorse or promote products derived from -- -- this software without specific prior written permission. -- -- -- -- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -- -- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -- -- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -- -- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -- -- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -- -- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED -- -- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -- -- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -- -- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -- -- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -- -- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- -- -- ------------------------------------------------------------------------------ -- $Revision$ $Date$ ------------------------------------------------------------------------------ -- This file is generated, don't edit it. ------------------------------------------------------------------------------ with AMF.Generic_Collections; package AMF.OCL.Null_Literal_Exps.Collections is pragma Preelaborate; package OCL_Null_Literal_Exp_Collections is new AMF.Generic_Collections (OCL_Null_Literal_Exp, OCL_Null_Literal_Exp_Access); type Set_Of_OCL_Null_Literal_Exp is new OCL_Null_Literal_Exp_Collections.Set with null record; Empty_Set_Of_OCL_Null_Literal_Exp : constant Set_Of_OCL_Null_Literal_Exp; type Ordered_Set_Of_OCL_Null_Literal_Exp is new OCL_Null_Literal_Exp_Collections.Ordered_Set with null record; Empty_Ordered_Set_Of_OCL_Null_Literal_Exp : constant Ordered_Set_Of_OCL_Null_Literal_Exp; type Bag_Of_OCL_Null_Literal_Exp is new OCL_Null_Literal_Exp_Collections.Bag with null record; Empty_Bag_Of_OCL_Null_Literal_Exp : constant Bag_Of_OCL_Null_Literal_Exp; type Sequence_Of_OCL_Null_Literal_Exp is new OCL_Null_Literal_Exp_Collections.Sequence with null record; Empty_Sequence_Of_OCL_Null_Literal_Exp : constant Sequence_Of_OCL_Null_Literal_Exp; private Empty_Set_Of_OCL_Null_Literal_Exp : constant Set_Of_OCL_Null_Literal_Exp := (OCL_Null_Literal_Exp_Collections.Set with null record); Empty_Ordered_Set_Of_OCL_Null_Literal_Exp : constant Ordered_Set_Of_OCL_Null_Literal_Exp := (OCL_Null_Literal_Exp_Collections.Ordered_Set with null record); Empty_Bag_Of_OCL_Null_Literal_Exp : constant Bag_Of_OCL_Null_Literal_Exp := (OCL_Null_Literal_Exp_Collections.Bag with null record); Empty_Sequence_Of_OCL_Null_Literal_Exp : constant Sequence_Of_OCL_Null_Literal_Exp := (OCL_Null_Literal_Exp_Collections.Sequence with null record); end AMF.OCL.Null_Literal_Exps.Collections;
stcarrez/ada-util
Ada
3,327
adb
----------------------------------------------------------------------- -- util-mail -- Mail Utility Library -- Copyright (C) 2017, 2018, 2022 Stephane Carrez -- Written by Stephane Carrez ([email protected]) -- -- Licensed under the Apache License, Version 2.0 (the "License"); -- you may not use this file except in compliance with the License. -- You may obtain a copy of the License at -- -- http://www.apache.org/licenses/LICENSE-2.0 -- -- Unless required by applicable law or agreed to in writing, software -- distributed under the License is distributed on an "AS IS" BASIS, -- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -- See the License for the specific language governing permissions and -- limitations under the License. ----------------------------------------------------------------------- with Ada.Strings.Fixed; package body Util.Mail is use Ada.Strings.Unbounded; use Ada.Strings.Fixed; use Ada.Strings; -- ------------------------------ -- Parse the email address and separate the name from the address. -- ------------------------------ function Parse_Address (E_Mail : in String) return Email_Address is Result : Email_Address; First_Pos : constant Natural := Index (E_Mail, "<"); Last_Pos : constant Natural := Index (E_Mail, ">"); At_Pos : constant Natural := Index (E_Mail, "@"); begin if First_Pos > 0 and then Last_Pos > 0 then Result.Name := To_Unbounded_String (Trim (E_Mail (E_Mail'First .. First_Pos - 1), Both)); Result.Address := To_Unbounded_String (Trim (E_Mail (First_Pos + 1 .. Last_Pos - 1), Both)); if Length (Result.Name) = 0 and then At_Pos < Last_Pos then Result.Name := To_Unbounded_String (Trim (E_Mail (First_Pos + 1 .. At_Pos - 1), Both)); end if; else Result.Address := To_Unbounded_String (Trim (E_Mail, Both)); Result.Name := To_Unbounded_String (Trim (E_Mail (E_Mail'First .. At_Pos - 1), Both)); end if; return Result; end Parse_Address; -- ------------------------------ -- Extract a first name from the email address. -- ------------------------------ function Get_First_Name (From : in Email_Address) return String is Name : constant String := To_String (From.Name); Pos : Natural := Index (Name, " "); begin if Pos > 0 then return Name (Name'First .. Pos - 1); end if; Pos := Index (Name, "."); if Pos > 0 then return Name (Name'First .. Pos - 1); else return ""; end if; end Get_First_Name; -- ------------------------------ -- Extract a last name from the email address. -- ------------------------------ function Get_Last_Name (From : in Email_Address) return String is Name : constant String := To_String (From.Name); Pos : Natural := Index (Name, " "); begin if Pos > 0 then return Trim (Name (Pos + 1 .. Name'Last), Both); end if; Pos := Index (Name, "."); if Pos > 0 then return Name (Pos + 1 .. Name'Last); else return Name; end if; end Get_Last_Name; end Util.Mail;
zhmu/ananas
Ada
5,364
ads
------------------------------------------------------------------------------ -- -- -- GNAT COMPILER COMPONENTS -- -- -- -- G N A T . B Y T E _ O R D E R _ M A R K -- -- -- -- S p e c -- -- -- -- Copyright (C) 2006-2022, AdaCore -- -- -- -- GNAT is free software; you can redistribute it and/or modify it under -- -- terms of the GNU General Public License as published by the Free Soft- -- -- ware Foundation; either version 3, or (at your option) any later ver- -- -- sion. GNAT is distributed in the hope that it will be useful, but WITH- -- -- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY -- -- or FITNESS FOR A PARTICULAR PURPOSE. -- -- -- -- As a special exception under Section 7 of GPL version 3, you are granted -- -- additional permissions described in the GCC Runtime Library Exception, -- -- version 3.1, as published by the Free Software Foundation. -- -- -- -- You should have received a copy of the GNU General Public License and -- -- a copy of the GCC Runtime Library Exception along with this program; -- -- see the files COPYING3 and COPYING.RUNTIME respectively. If not, see -- -- <http://www.gnu.org/licenses/>. -- -- -- -- GNAT was originally developed by the GNAT team at New York University. -- -- Extensive contributions were provided by Ada Core Technologies Inc. -- -- -- ------------------------------------------------------------------------------ -- This package provides a procedure for reading and interpreting the BOM -- (byte order mark) used to publish the encoding method for a string (for -- example, a UTF-8 encoded file in windows will start with the appropriate -- BOM sequence to signal UTF-8 encoding). -- There are two cases -- Case 1. UTF encodings for Unicode files -- Here the convention is to have the first character of the file be a -- non-breaking zero width space character (16#0000_FEFF#). For the UTF -- encodings, the representation of this character can be used to uniquely -- determine the encoding. Furthermore, the possibility of any confusion -- with unencoded files is minimal, since for example the UTF-8 encoding -- of this character looks like the sequence: -- LC_I_Diaeresis -- Right_Angle_Quotation -- Fraction_One_Half -- which is so unlikely to occur legitimately in normal use that it can -- safely be ignored in most cases (for example, no legitimate Ada source -- file could start with this sequence of characters). -- Case 2. Specialized XML encodings -- The XML standard defines a number of other possible encodings and also -- defines standardized sequences for marking these encodings. This package -- can also optionally handle these XML defined BOM sequences. These XML -- cases depend on the first character of the XML file being < so that the -- encoding of this character can be recognized. package GNAT.Byte_Order_Mark is type BOM_Kind is (UTF8_All, -- UTF8-encoding UTF16_LE, -- UTF16 little-endian encoding UTF16_BE, -- UTF16 big-endian encoding UTF32_LE, -- UTF32 little-endian encoding UTF32_BE, -- UTF32 big-endian encoding -- The following cases are for XML only UCS4_BE, -- UCS-4, big endian machine (1234 order) UCS4_LE, -- UCS-4, little endian machine (4321 order) UCS4_2143, -- UCS-4, unusual byte order (2143 order) UCS4_3412, -- UCS-4, unusual byte order (3412 order) -- Value returned if no BOM recognized Unknown); -- Unknown, assumed to be ASCII compatible procedure Read_BOM (Str : String; Len : out Natural; BOM : out BOM_Kind; XML_Support : Boolean := False); -- This is the routine to read the BOM from the start of the given string -- Str. On return BOM is set to the appropriate BOM_Kind and Len is set to -- its length. The caller will typically skip the first Len characters in -- the string to ignore the BOM sequence. The special XML possibilities are -- recognized only if flag XML_Support is set to True. Note that for the -- XML cases, Len is always set to zero on return (not to the length of the -- relevant sequence) since in the XML cases, the sequence recognized is -- for the first real character in the file (<) which is not to be skipped. end GNAT.Byte_Order_Mark;
AaronC98/PlaneSystem
Ada
47,859
adb
------------------------------------------------------------------------------ -- Ada Web Server -- -- -- -- Copyright (C) 2012-2019, AdaCore -- -- -- -- This library is free software; you can redistribute it and/or modify -- -- it under terms of the GNU General Public License as published by the -- -- Free Software Foundation; either version 3, or (at your option) any -- -- later version. This library is distributed in the hope that it will be -- -- useful, but WITHOUT ANY WARRANTY; without even the implied warranty of -- -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. -- -- -- -- -- -- -- -- -- -- -- -- You should have received a copy of the GNU General Public License and -- -- a copy of the GCC Runtime Library Exception along with this program; -- -- see the files COPYING3 and COPYING.RUNTIME respectively. If not, see -- -- <http://www.gnu.org/licenses/>. -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- ------------------------------------------------------------------------------ pragma Ada_2012; with Ada.Containers.Indefinite_Ordered_Maps; with Ada.Containers.Indefinite_Vectors; with Ada.Containers.Ordered_Maps; with Ada.Containers.Ordered_Sets; pragma Warnings (Off, "is an internal GNAT unit"); with Ada.Strings.Unbounded.Aux; pragma Warnings (On, "is an internal GNAT unit"); with Ada.Unchecked_Deallocation; with GNAT.Regpat; with AWS.Config; with AWS.Net.Generic_Sets; with AWS.Net.Memory; with AWS.Net.Poll_Events; with AWS.Net.Std; with AWS.Net.WebSocket; with AWS.Translator; with AWS.Utils; package body AWS.Net.WebSocket.Registry is use GNAT; use GNAT.Regpat; use type Containers.Count_Type; -- Container for URI based registered constructors package Constructors is new Containers.Indefinite_Ordered_Maps (String, Factory); Factories : Constructors.Map; -- Container for Pattern based registered constructors type P_Data (Size : Regpat.Program_Size) is record Pattern : Regpat.Pattern_Matcher (Size); Factory : Registry.Factory; end record; package Pattern_Constructors is new Containers.Indefinite_Vectors (Positive, P_Data); Pattern_Factories : Pattern_Constructors.Vector; -- A queue for WebSocket with pending messages to be read package WebSocket_Queue is new Utils.Mailbox_G (Object_Class); type Queue_Ref is access WebSocket_Queue.Mailbox; -- A list of all WebSockets in the registry, this list is used to send or -- broadcast messages. procedure Unchecked_Free is new Ada.Unchecked_Deallocation (Object'Class, Object_Class); function Same_WS (Left, Right : Object_Class) return Boolean is (Left.Id = Right.Id); -- Equality is based on the unique id package WebSocket_Map is new Containers.Ordered_Maps (UID, Object_Class, "=" => Same_WS); package WebSocket_Set is new Containers.Ordered_Sets (UID); package WebSocket_List is new Containers.Doubly_Linked_Lists (UID); -- The socket set with all sockets to wait for data package FD_Set is new Net.Generic_Sets (Object_Class); use type FD_Set.Socket_Count; task type Watcher with Priority => Config.WebSocket_Priority is end Watcher; task type Message_Sender with Priority => Config.WebSocket_Priority is end Message_Sender; type Message_Sender_Set is array (Positive range <>) of Message_Sender; type Message_Sender_Set_Ref is access all Message_Sender_Set; type Watcher_Ref is access all Watcher; -- This task is in charge of watching the WebSocket for incoming messages. -- It then places the WebSocket into a job queue to be processed by the -- reader tasks. task type Message_Reader with Priority => Config.WebSocket_Priority is end Message_Reader; -- Wait for WebSocket message to be ready, read them and call the Received -- callback. The a message has been read, the WebSocket is added back into -- the list of watched sockets. type Message_Reader_Set is array (Positive range <>) of Message_Reader; type Message_Reader_Set_Ref is access all Message_Reader_Set; -- Task objects Message_Queue : Queue_Ref; Message_Watcher : Watcher_Ref; Message_Readers : Message_Reader_Set_Ref; Message_Senders : Message_Sender_Set_Ref; Shutdown_Signal : Boolean := False; -- Concurrent access to Set above protected DB is procedure Initialize; -- Initialize the socket set by inserting a signaling socket procedure Finalize; -- Close signaling socket function Create_Set return FD_Set.Socket_Set_Type; -- Returns the set of watched WebSockets procedure Watch (WebSocket : Object_Class) with Pre => WebSocket /= null; -- Add a new Websocket into the set, release the current FD_Set.Wait -- call if any to ensure this new WebSocket will be watched too. procedure Remove (WebSocket : not null access Object'Class); -- Remove WebSocket from the watched list entry Get_Socket (WebSocket : out Object_Class); -- Get a WebSocket having some data to be sent procedure Release_Socket (WebSocket : Object_Class); -- Release a socket retrieved with Get_Socket above, this socket will be -- then available again. entry Not_Empty; -- Returns if the Set is not empty procedure Send (To : Recipient; Message : String; Except_Peer : String; Timeout : Duration := Forever; Asynchronous : Boolean := False; Error : access procedure (Socket : Object'Class; Action : out Action_Kind) := null); -- Send the given message to all matching WebSockets procedure Send (Socket : in out Object'Class; Message : String; Is_Binary : Boolean := False; Timeout : Duration := Forever; Asynchronous : Boolean := False); procedure Send (Socket : in out Object'Class; Message : Unbounded_String; Is_Binary : Boolean := False; Timeout : Duration := Forever; Asynchronous : Boolean := False); -- Same as above but can be used for large messages. The message is -- possibly sent fragmented. procedure Send (Socket : in out Object'Class; Message : Stream_Element_Array; Is_Binary : Boolean := True; Timeout : Duration := Forever; Asynchronous : Boolean := False); procedure Close (To : Recipient; Message : String; Except_Peer : String; Timeout : Duration := Forever; Error : Error_Type := Normal_Closure); -- Close all matching Webockets procedure Close (Socket : in out Object'Class; Message : String; Timeout : Duration := Forever; Error : Error_Type := Normal_Closure); procedure Register (WebSocket : Object_Class; Success : out Boolean) with Pre => WebSocket /= null; -- Register a new WebSocket procedure Unregister (WebSocket : not null access Object'Class); -- Unregister a WebSocket function Is_Registered (Id : UID) return Boolean; -- Returns True if the WebSocket Id is registered and False otherwise procedure Signal_Socket; -- Send a signal to the wait call procedure Shutdown_Signal; -- Signal when a shutdown is requested procedure Receive (WebSocket : not null access Object'Class; Data : out Stream_Element_Array; Last : out Stream_Element_Offset); -- Get data from WebSocket private Sig1, Sig2 : Net.Std.Socket_Type; -- Signaling sockets Signal : Boolean := False; -- Transient signal, release Not_Emtpy S_Signal : Boolean := False; -- Shutdown is in progress New_Pending : Boolean := False; -- New pending socket Count : Natural := 0; -- Not counting signaling socket Registered : WebSocket_Map.Map; -- Contains all the WebSocket ref Sending : WebSocket_Set.Set; -- Socket being handed to Sender task Pending : WebSocket_List.List; -- Pending messages to be sent Watched : WebSocket_Set.Set; -- All WebSockets are registered into this set to check for incoming -- messages. When a message is ready the WebSocket is placed into the -- Message_Queue for being handled. When the message has been read -- and handled the WebSocket is put back into this set. end DB; ------------- -- Watcher -- ------------- task body Watcher is Count : FD_Set.Socket_Count; WS : Object_Class; begin loop DB.Not_Empty; exit when Shutdown_Signal; declare Set : FD_Set.Socket_Set_Type := DB.Create_Set; -- Note that the very first one is a signaling socket used to -- release the wait call. This first entry is not a WebSocket and -- should be ignored in most code below. begin -- Wait indefinitely, this call will be released either by an -- incoming message in a WebSocket or because the signaling socket -- has been used due to a new WebSocket registered. In this later -- case no message will be read, but on the next iteration the new -- WebSockets will be watched. FD_Set.Wait (Set, Duration'Last, Count); -- Queue all WebSocket having some data to read, skip the -- signaling socket. declare -- Skip first entry as it is not a websocket K : FD_Set.Socket_Count := 2; begin while K <= FD_Set.Count (Set) loop if FD_Set.Is_Read_Ready (Set, K) then WS := FD_Set.Get_Data (Set, K); DB.Remove (WS); Message_Queue.Add (WS); end if; K := K + 1; end loop; end; exception when E : others => -- Send a On_Error message to all registered clients for K in 2 .. FD_Set.Count (Set) loop WS := FD_Set.Get_Data (Set, K); WS.State.Errno := Error_Code (Internal_Server_Error); WS.On_Error ("WebSocket Watcher server error, " & Exception_Message (E)); end loop; end; end loop; end Watcher; -------------------- -- Message_Reader -- -------------------- task body Message_Reader is procedure Do_Free (WebSocket : in out Object_Class); procedure Do_Register (WebSocket : Object_Class); procedure Do_Unregister (WebSocket : Object_Class); ------------- -- Do_Free -- ------------- procedure Do_Free (WebSocket : in out Object_Class) is begin Unchecked_Free (WebSocket); end Do_Free; ----------------- -- Do_Register -- ----------------- procedure Do_Register (WebSocket : Object_Class) is begin DB.Watch (WebSocket); end Do_Register; ------------------- -- Do_Unregister -- ------------------- procedure Do_Unregister (WebSocket : Object_Class) is begin DB.Unregister (WebSocket); end Do_Unregister; function Read_Message is new AWS.Net.WebSocket.Read_Message (Receive => DB.Receive, On_Success => Do_Register, On_Error => Do_Unregister, On_Free => Do_Free); begin Handle_Message : loop declare WebSocket : Object_Class; Message : Unbounded_String; begin Message := Null_Unbounded_String; Message_Queue.Get (WebSocket); -- A WebSocket is null when termination is requested exit Handle_Message when WebSocket = null; -- A message can be sent in multiple chunks and/or multiple -- frames with possibly some control frames in between text or -- binary ones. This loop handles those cases. loop exit when Read_Message (WebSocket, Message); end loop; exception when E : others => DB.Unregister (WebSocket); WebSocket_Exception (WebSocket, Exception_Message (E), Protocol_Error); Unchecked_Free (WebSocket); end; end loop Handle_Message; end Message_Reader; -------- -- DB -- -------- protected body DB is ---------- -- Close -- ---------- procedure Close (To : Recipient; Message : String; Except_Peer : String; Timeout : Duration := Forever; Error : Error_Type := Normal_Closure) is procedure Close_To (Position : WebSocket_Map.Cursor); ------------- -- Close_To -- ------------- procedure Close_To (Position : WebSocket_Map.Cursor) is WebSocket : Object_Class := WebSocket_Map.Element (Position); begin if (Except_Peer = "" or else WebSocket.Peer_Addr /= Except_Peer) and then (not To.URI_Set or else GNAT.Regexp.Match (WebSocket.URI, To.URI)) and then (not To.Origin_Set or else GNAT.Regexp.Match (WebSocket.Origin, To.Origin)) then DB.Unregister (WebSocket); WebSocket.State.Errno := Error_Code (Error); -- If an error occurs, we don't want to fail, shutdown the -- socket silently. begin WebSocket.Set_Timeout (Timeout); WebSocket.Close (Message, Error); WebSocket.On_Close (Message); exception when others => null; end; WebSocket.Shutdown; Unchecked_Free (WebSocket); end if; end Close_To; Registered_Before : constant WebSocket_Map.Map := Registered; begin case To.Kind is when K_UID => if Registered.Contains (To.WS_Id) then declare WebSocket : constant not null access Object'Class := Registered (To.WS_Id); begin WebSocket.Set_Timeout (Timeout); WebSocket.Close (Message, Error); WebSocket.On_Close (Message); exception when others => null; end; else -- This WebSocket is not registered anymore raise Socket_Error with "WebSocket " & Utils.Image (Natural (To.WS_Id)) & " is not registered"; end if; when K_URI => Registered_Before.Iterate (Close_To'Access); end case; end Close; procedure Close (Socket : in out Object'Class; Message : String; Timeout : Duration := Forever; Error : Error_Type := Normal_Closure) is W : Object_Class; begin -- Look for WebSocket into the registered set, unregisted it if -- present. if Registered.Contains (Socket.Id) then W := Registered (Socket.Id); Unregister (W); end if; Socket.State.Errno := Error_Code (Error); Socket.Set_Timeout (Timeout); Socket.Close (Message, Error); Socket.On_Close (Message); Socket.Shutdown; Unchecked_Free (W); end Close; ---------------- -- Create_Set -- ---------------- function Create_Set return FD_Set.Socket_Set_Type is begin return Result : FD_Set.Socket_Set_Type do -- Add the signaling socket FD_Set.Add (Result, Sig1, null, FD_Set.Input); -- Add watched sockets for Id of Watched loop FD_Set.Add (Result, Registered (Id).all, Registered (Id), FD_Set.Input); end loop; end return; end Create_Set; -------------- -- Finalize -- -------------- procedure Finalize is procedure On_Close (Position : WebSocket_Map.Cursor); -------------- -- On_Close -- -------------- procedure On_Close (Position : WebSocket_Map.Cursor) is WebSocket : Object_Class := WebSocket_Map.Element (Position); begin WebSocket.State.Errno := Error_Code (Going_Away); -- We do not want to block if the peer is not responding, just -- allow 10 seconds for the close message to be accepted. -- In any case, we do not want to raise an exception. If an -- error occurs just close the socket silently. begin WebSocket.Set_Timeout (10.0); WebSocket.On_Close ("AWS server going down"); exception when others => null; end; WebSocket.Shutdown; Unchecked_Free (WebSocket); end On_Close; begin Net.Std.Shutdown (Sig1); Net.Std.Shutdown (Sig2); -- Finally send a On_Close message to all registered WebSocket Registered.Iterate (On_Close'Access); Registered.Clear; end Finalize; ---------------- -- Get_Socket -- ---------------- entry Get_Socket (WebSocket : out Object_Class) when New_Pending or else S_Signal is begin WebSocket := null; -- Shutdown requested, just return now if S_Signal then return; end if; -- No pending message on the queue, this can happen because -- New_Pending is set when giving back a WebSocket into the -- registry. See Release_Socket. if Pending.Length = 0 then New_Pending := False; requeue Get_Socket; end if; -- Look for a socket not yet being handled declare use type WebSocket_List.Cursor; Pos : WebSocket_List.Cursor := Pending.First; Id : UID; WS : Object_Class; begin while Pos /= WebSocket_List.No_Element loop Id := Pending (Pos); -- Check if this socket is not yet being used by a sender task if not Sending.Contains (Id) then WS := Registered (Id); -- Check that some messages are to be sent. This is needed -- as some messages could have been dropped if the list was -- too long to avoid congestion. if WS.Messages.Length > 0 then Pending.Delete (Pos); WebSocket := WS; Sending.Insert (Id); return; end if; end if; Pos := WebSocket_List.Next (Pos); end loop; -- Finally no more socket found to be handled, wait for new to -- arrive. New_Pending := False; requeue Get_Socket; end; end Get_Socket; ---------------- -- Initialize -- ---------------- procedure Initialize is begin -- Create a signaling socket that will be used to exit from the -- infinite wait when a new WebSocket arrives. Net.Std.Socket_Pair (Sig1, Sig2); end Initialize; ------------------- -- Is_Registered -- ------------------- function Is_Registered (Id : UID) return Boolean is begin return Registered.Contains (Id); end Is_Registered; --------------- -- Not_Empty -- --------------- entry Not_Empty when Count > 0 or else Signal or else S_Signal is begin -- If shutdown is in process, return now if S_Signal then return; end if; -- It was a signal, consume the one by sent if Signal then Signal := False; declare Data : Stream_Element_Array (1 .. 1); Last : Stream_Element_Offset; begin AWS.Net.Std.Receive (Sig1, Data, Last); end; end if; end Not_Empty; ------------- -- Receive -- ------------- procedure Receive (WebSocket : not null access Object'Class; Data : out Stream_Element_Array; Last : out Stream_Element_Offset) is begin WebSocket.Receive (Data, Last); end Receive; -------------- -- Register -- -------------- procedure Register (WebSocket : Object_Class; Success : out Boolean) is begin -- Check if maximum number of WebSocket has been reached if Natural (Registered.Length) = Config.Max_WebSocket then -- Let's try to close a WebSocket for which the activity has -- timedout. declare use type Calendar.Time; Timeout : constant Calendar.Time := Calendar.Clock - Config.WebSocket_Timeout; W : Object_Class; begin for WS of Registered loop if WS.State.Last_Activity < Timeout then W := WS; exit; end if; end loop; -- If no WebSocket can be closed if W = null then Success := False; return; else Close (Socket => W.all, Message => "activity timeout reached", Timeout => 1.0, Error => Abnormal_Closure); end if; end; end if; Registered.Insert (WebSocket.Id, WebSocket); Success := True; end Register; -------------------- -- Release_Socket -- -------------------- procedure Release_Socket (WebSocket : Object_Class) is begin Sending.Exclude (WebSocket.Id); New_Pending := True; end Release_Socket; ------------ -- Remove -- ------------ procedure Remove (WebSocket : not null access Object'Class) is begin if Watched.Contains (WebSocket.Id) then Watched.Exclude (WebSocket.Id); Count := Count - 1; end if; end Remove; ---------- -- Send -- ---------- procedure Send (To : Recipient; Message : String; Except_Peer : String; Timeout : Duration := Forever; Asynchronous : Boolean := False; Error : access procedure (Socket : Object'Class; Action : out Action_Kind) := null) is procedure Initialize_Recipients (Position : WebSocket_Map.Cursor); -- Count recipients and initialize the message's raw data procedure Send_To_Recipients (Recipients : Socket_Set); -- Send message to all recipients Recipients : Socket_Set (1 .. Natural (Registered.Length)); Last : Natural := 0; --------------------------- -- Initialize_Recipients -- --------------------------- procedure Initialize_Recipients (Position : WebSocket_Map.Cursor) is WebSocket : constant not null access Object'Class := WebSocket_Map.Element (Position); begin if (Except_Peer = "" or else WebSocket.Peer_Addr /= Except_Peer) and then (not To.URI_Set or else GNAT.Regexp.Match (WebSocket.URI, To.URI)) and then (not To.Origin_Set or else GNAT.Regexp.Match (WebSocket.Origin, To.Origin)) then -- Send all data to a memory socket. This is a special -- circuitry where all sent data are actually stored into -- a buffer. This is necessary to be able to get raw data -- depending on the protocol. -- -- ??? for supporting a large set of WebSocket it would be -- good to share the memory buffer. There is actually one -- for each WebSocket format. WebSocket.Mem_Sock := new Memory.Socket_Type; WebSocket.In_Mem := True; WebSocket.Send (Message); WebSocket.In_Mem := False; -- Not that it is not possible to honor the synchronous -- sending if the socket is already being handled by a -- send task (Asynchronously). if Asynchronous or else Sending.Contains (WebSocket.Id) then declare M : constant Message_Data := (WebSocket.Mem_Sock, Timeout); begin WebSocket.Messages.Append (M); WebSocket.Mem_Sock := null; Pending.Append (WebSocket.Id); New_Pending := True; end; else Last := Last + 1; Recipients (Last) := Socket_Access (WebSocket); Recipients (Last).Set_Timeout (Timeout); end if; end if; end Initialize_Recipients; ------------------------ -- Send_To_Recipients -- ------------------------ procedure Send_To_Recipients (Recipients : Socket_Set) is Wait_Events : constant Wait_Event_Set := (Input => False, Output => True); Set : Poll_Events.Set (Recipients'Length); Socks : Socket_Set (1 .. Recipients'Length) := Recipients; Sock_Index : Positive; Count : Natural; Pending : Stream_Element_Count; begin -- Register the sockets to be handled for S of Socks loop Set.Add (S.Get_FD, Wait_Events); end loop; -- Send actual data to the WebSocket depending on their status Send_Message : loop Set.Wait (Timeout, Count); -- Timeout reached, some sockets are not responding if Count = 0 then for K in 1 .. Set.Length loop declare W : Object_Class := Object_Class (Socks (K)); A : Action_Kind := None; begin if Error = null then DB.Unregister (W); Unchecked_Free (W); else Error (W.all, A); case A is when Close => DB.Unregister (W); Unchecked_Free (W); when None => null; end case; end if; end; end loop; exit Send_Message; end if; Sock_Index := 1; for K in 1 .. Count loop Set.Next (Sock_Index); declare WS : Object_Class := Object_Class (Socks (Sock_Index)); Chunk_Size : Stream_Element_Offset := WS.Output_Space; begin if Chunk_Size = -1 then Chunk_Size := 100 * 1_024; end if; Pending := WS.Mem_Sock.Pending; Chunk_Size := Stream_Element_Offset'Min (Chunk_Size, Pending); Read_Send : declare Data : Stream_Element_Array (1 .. Chunk_Size); Last : Stream_Element_Offset; begin WS.Mem_Sock.Receive (Data, Last); pragma Assert (Last = Data'Last); WS.Send (Data, Last); Pending := Pending - Chunk_Size; exception when E : others => Unregister (WS); WebSocket_Exception (WS, Exception_Message (E), Protocol_Error); Unchecked_Free (WS); -- No more data to send from this socket Pending := 0; end Read_Send; end; if Pending = 0 then -- No more data for this socket, first free memory Free (Object_Class (Socks (Sock_Index)).Mem_Sock); -- Then the Set.Remove (on the socket set) move the last -- socket in the set to the location of the removed -- one. Do the same for the local data to keep data -- consistency. -- -- Note that in this case we do not want to increment the -- socket index. The new loop will check the socket at -- the same position which is now the previous last in -- the set. if Sock_Index /= Set.Length then Socks (Sock_Index) := Socks (Set.Length); end if; Set.Remove (Sock_Index); else -- In this case, and only in this case we move to next -- socket position for next iteration. Sock_Index := Sock_Index + 1; end if; end loop; exit Send_Message when Set.Length = 0; end loop Send_Message; end Send_To_Recipients; begin case To.Kind is when K_UID => if Registered.Contains (To.WS_Id) then declare WebSocket : Object_Class := Registered (To.WS_Id); begin WebSocket.Set_Timeout (Timeout); WebSocket.Send (Message); exception when E : others => Unregister (WebSocket); WebSocket_Exception (WebSocket, Exception_Message (E), Protocol_Error); Unchecked_Free (WebSocket); end; else -- This WebSocket is not registered anymore raise Socket_Error with "WebSocket " & Utils.Image (Natural (To.WS_Id)) & " is not registered"; end if; when K_URI => Registered.Iterate (Initialize_Recipients'Access); if Last > 0 then Send_To_Recipients (Recipients (1 .. Last)); end if; end case; end Send; procedure Send (Socket : in out Object'Class; Message : String; Is_Binary : Boolean := False; Timeout : Duration := Forever; Asynchronous : Boolean := False) is begin DB.Send (Socket, To_Unbounded_String (Message), Is_Binary, Timeout, Asynchronous); end Send; procedure Send (Socket : in out Object'Class; Message : Unbounded_String; Is_Binary : Boolean := False; Timeout : Duration := Forever; Asynchronous : Boolean := False) is begin if Asynchronous then Socket.In_Mem := True; Socket.Send (Message, Is_Binary); Socket.In_Mem := False; declare M : constant Message_Data := (Socket.Mem_Sock, Timeout); begin Socket.Messages.Append (M); Socket.Mem_Sock := null; Pending.Append (Socket.Id); New_Pending := True; end; else Socket.Set_Timeout (Timeout); Socket.Send (Message, Is_Binary); end if; end Send; procedure Send (Socket : in out Object'Class; Message : Stream_Element_Array; Is_Binary : Boolean := True; Timeout : Duration := Forever; Asynchronous : Boolean := False) is begin DB.Send (Socket, Translator.To_Unbounded_String (Message), Is_Binary, Timeout, Asynchronous); end Send; --------------------- -- Shutdown_Signal -- --------------------- procedure Shutdown_Signal is begin S_Signal := True; Signal_Socket; end Shutdown_Signal; ------------------- -- Signal_Socket -- ------------------- procedure Signal_Socket is begin -- If a signal is pending no need to signal again the socket if not Signal then Net.Send (Sig2, Stream_Element_Array'(1 => 0)); -- Also activate the signal to release Not_Empty for proper -- termination when there is no remaining socket. Signal := True; end if; end Signal_Socket; ---------------- -- Unregister -- ---------------- procedure Unregister (WebSocket : not null access Object'Class) is begin Registered.Exclude (WebSocket.Id); Sending.Exclude (WebSocket.Id); Remove (WebSocket); Signal_Socket; end Unregister; ----------- -- Watch -- ----------- procedure Watch (WebSocket : Object_Class) is begin if Is_Registered (WebSocket.Id) and then not Watched.Contains (WebSocket.Id) then Watched.Insert (WebSocket.Id); Count := Count + 1; Signal_Socket; end if; exception when others => Unregister (WebSocket); raise; end Watch; end DB; ----------- -- Close -- ----------- procedure Close (To : Recipient; Message : String; Except_Peer : String := ""; Timeout : Duration := Forever; Error : Error_Type := Normal_Closure) is begin DB.Close (To, Message, Except_Peer, Timeout, Error); exception when others => -- Should never fails even if the WebSocket is closed by peer null; end Close; procedure Close (Socket : in out Object'Class; Message : String; Timeout : Duration := Forever; Error : Error_Type := Normal_Closure) is begin DB.Close (Socket, Message, Timeout, Error); exception when others => -- Should never fails even if the WebSocket is closed by peer null; end Close; ----------------- -- Constructor -- ----------------- function Constructor (URI : String) return Registry.Factory is Position : constant Constructors.Cursor := Factories.Find (URI); begin if Constructors.Has_Element (Position) then return Constructors.Element (Position); else for Data of Pattern_Factories loop declare Count : constant Natural := Paren_Count (Data.Pattern); Matches : Match_Array (0 .. Count); begin Match (Data.Pattern, URI, Matches); if Matches (0) /= No_Match then return Data.Factory; end if; end; end loop; end if; return Create'Access; end Constructor; ------------ -- Create -- ------------ function Create (URI : String; Origin : String := "") return Recipient is Result : Recipient (K_URI); begin if URI /= "" then Result.URI_Set := True; Result.URI := GNAT.Regexp.Compile (URI); end if; if Origin /= "" then Result.Origin_Set := True; Result.Origin := GNAT.Regexp.Compile (Origin); end if; return Result; end Create; function Create (Id : UID) return Recipient is begin return Result : Recipient (K_UID) do Result.WS_Id := Id; end return; end Create; ------------------- -- Is_Registered -- ------------------- function Is_Registered (Id : UID) return Boolean is begin return DB.Is_Registered (Id); end Is_Registered; -------------------- -- Message_Sender -- -------------------- task body Message_Sender is procedure Send (WS : in out Object_Class; Message : Message_Data); ---------- -- Send -- ---------- procedure Send (WS : in out Object_Class; Message : Message_Data) is Chunk_Size : Stream_Element_Offset := WS.Output_Space; Pending : Stream_Element_Count; begin if Chunk_Size = -1 then Chunk_Size := 100 * 1_024; end if; loop Pending := Message.Mem_Sock.Pending; exit when Pending = 0; Chunk_Size := Stream_Element_Offset'Min (Chunk_Size, Pending); Read_Send : declare Data : Stream_Element_Array (1 .. Chunk_Size); Last : Stream_Element_Offset; begin Message.Mem_Sock.Receive (Data, Last); pragma Assert (Last = Data'Last); WS.Send (Data, Last); Pending := Pending - Chunk_Size; exception when E : others => DB.Unregister (WS); WebSocket_Exception (WS, Exception_Message (E), Protocol_Error); Unchecked_Free (WS); -- No more data to send from this socket Pending := 0; end Read_Send; end loop; end Send; WS : Object_Class; begin loop DB.Get_Socket (WS); exit when Shutdown_Signal; -- This WebSocket has a message to be sent -- First let's remove too old messages while Positive (WS.Messages.Length) > Config.WebSocket_Send_Message_Queue_Size loop WS.Messages.Delete_First; end loop; -- Then send the oldest message on the list declare Message : constant Message_Data := WS.Messages.First_Element; begin Send (WS, Message); WS.Messages.Delete_First; DB.Release_Socket (WS); end; end loop; end Message_Sender; -------------- -- Register -- -------------- procedure Register (URI : String; Factory : Registry.Factory) is begin Factories.Insert (URI, Factory); end Register; function Register (WebSocket : Object'Class) return Object_Class is WS : Object_Class := new Object'Class'(WebSocket); Success : Boolean; begin DB.Register (WS, Success); if not Success then Unchecked_Free (WS); end if; return WS; end Register; ---------------------- -- Register_Pattern -- ---------------------- procedure Register_Pattern (Pattern : String; Factory : Registry.Factory) is M : constant Regpat.Pattern_Matcher := Regpat.Compile (Pattern, GNAT.Regpat.Case_Insensitive); begin Pattern_Factories.Append (P_Data'(M.Size, M, Factory)); end Register_Pattern; ---------- -- Send -- ---------- procedure Send (To : Recipient; Message : Unbounded_String; Except_Peer : String := ""; Timeout : Duration := Forever; Asynchronous : Boolean := False; Error : access procedure (Socket : Object'Class; Action : out Action_Kind) := null) is use Ada.Strings.Unbounded.Aux; S : Big_String_Access; L : Natural; begin Get_String (Message, S, L); DB.Send (To, S (1 .. L), Except_Peer, Timeout, Asynchronous, Error); exception when others => -- Should never fails even if the WebSocket is closed by peer null; end Send; procedure Send (To : Recipient; Message : String; Except_Peer : String := ""; Timeout : Duration := Forever; Asynchronous : Boolean := False; Error : access procedure (Socket : Object'Class; Action : out Action_Kind) := null) is begin DB.Send (To, Message, Except_Peer, Timeout, Asynchronous, Error); end Send; procedure Send (To : Recipient; Message : Unbounded_String; Request : AWS.Status.Data; Timeout : Duration := Forever; Asynchronous : Boolean := False; Error : access procedure (Socket : Object'Class; Action : out Action_Kind) := null) is use Ada.Strings.Unbounded.Aux; S : Big_String_Access; L : Natural; begin Get_String (Message, S, L); Send (To, S (1 .. L), Except_Peer => AWS.Status.Socket (Request).Peer_Addr, Timeout => Timeout, Asynchronous => Asynchronous, Error => Error); end Send; procedure Send (To : Recipient; Message : String; Request : AWS.Status.Data; Timeout : Duration := Forever; Asynchronous : Boolean := False; Error : access procedure (Socket : Object'Class; Action : out Action_Kind) := null) is begin Send (To, Message, Except_Peer => AWS.Status.Socket (Request).Peer_Addr, Timeout => Timeout, Asynchronous => Asynchronous, Error => Error); end Send; procedure Send (Socket : in out Object'Class; Message : String; Is_Binary : Boolean := False; Timeout : Duration := Forever; Asynchronous : Boolean := False) is begin DB.Send (Socket, Message, Is_Binary, Timeout, Asynchronous); end Send; procedure Send (Socket : in out Object'Class; Message : Unbounded_String; Is_Binary : Boolean := False; Timeout : Duration := Forever; Asynchronous : Boolean := False) is begin DB.Send (Socket, Message, Is_Binary, Timeout, Asynchronous); end Send; procedure Send (Socket : in out Object'Class; Message : Stream_Element_Array; Is_Binary : Boolean := True; Timeout : Duration := Forever; Asynchronous : Boolean := False) is begin DB.Send (Socket, Message, Is_Binary, Timeout, Asynchronous); end Send; -------------- -- Shutdown -- -------------- procedure Shutdown is procedure Unchecked_Free is new Unchecked_Deallocation (Watcher, Watcher_Ref); procedure Unchecked_Free is new Unchecked_Deallocation (Message_Reader_Set, Message_Reader_Set_Ref); procedure Unchecked_Free is new Unchecked_Deallocation (Message_Sender_Set, Message_Sender_Set_Ref); procedure Unchecked_Free is new Unchecked_Deallocation (WebSocket_Queue.Mailbox, Queue_Ref); begin -- Check if a shutdown if not already in progress or if the servers have -- not been initialized. if Shutdown_Signal or else (Message_Watcher = null and then Message_Readers = null) then return; end if; -- First shutdown the watcher Shutdown_Signal := True; DB.Shutdown_Signal; -- Wait for proper termination to be able to free the task object while not Message_Watcher'Terminated loop delay 0.5; end loop; -- Now shutdown all the message readers for K in Message_Readers'Range loop Message_Queue.Add (null); end loop; for K in Message_Readers'Range loop while not Message_Readers (K)'Terminated loop delay 0.5; end loop; end loop; for K in Message_Senders'Range loop while not Message_Senders (K)'Terminated loop delay 0.5; end loop; end loop; -- Now we can deallocate the task objects Unchecked_Free (Message_Readers); Unchecked_Free (Message_Senders); Unchecked_Free (Message_Watcher); Unchecked_Free (Message_Queue); DB.Finalize; end Shutdown; ----------- -- Start -- ----------- procedure Start is begin DB.Initialize; Message_Queue := new WebSocket_Queue.Mailbox (Config.WebSocket_Message_Queue_Size); Message_Watcher := new Watcher; Message_Readers := new Message_Reader_Set (1 .. Config.Max_WebSocket_Handler); Message_Senders := new Message_Sender_Set (1 .. Config.Max_WebSocket_Handler); end Start; ----------- -- Watch -- ----------- procedure Watch (WebSocket : in out Object_Class) is begin -- Send a Connection_Open message WebSocket.State.Kind := Connection_Open; WebSocket.On_Open ("AWS WebSocket connection open"); DB.Watch (WebSocket); exception when others => Unchecked_Free (WebSocket); raise; end Watch; end AWS.Net.WebSocket.Registry;
Feqzz/RSA
Ada
6,717
adb
with Ada.Text_IO; with Ada.Integer_Text_IO; with Ada.Strings.Unbounded; with Ada.Strings.Fixed; with Ada.Command_Line; procedure Main is p : Long_Long_Integer; q : Long_Long_Integer; phi : Long_Long_Integer; n : Long_Long_Integer; e : Long_Long_Integer; d : Long_Long_Integer; message : Long_Long_Integer; encryptedMessage : Long_Long_Integer; decryptedMessage : Long_Long_Integer; ------------------- -- IsPrimeNumber -- ------------------- function IsPrimeNumber (N : Long_Long_Integer) return Boolean is isPrime : Boolean := true; begin if N = 0 or N = 1 then return false; end if; for i in 1 .. N / 2 loop if (N mod (i + 1)) = 0 then isPrime := false; exit; end if; end loop; return isPrime; end IsPrimeNumber; ----------- -- IsOdd -- ----------- function IsOdd (N : Long_Long_Integer) return Boolean is begin return (N mod 2 = 1); end IsOdd; --------- -- gcd -- --------- function gcd (A, B : Long_Long_Integer) return Long_Long_Integer is begin if A = 0 then return B; end if; return gcd(B mod A, A); end gcd; ------------------------ -- GetPrivateExponent -- ------------------------ function GetPrivateExponent (Phi, E : Long_Long_Integer) return Long_Long_Integer is K : Long_Long_Integer := 1; ans : Float; begin loop ans := ((Float(K)*Float(Phi)) + 1.0) / Float(E); if not (ans = Float(Integer(ans))) then K := K + 1; else return ((K*Phi) + 1) / E; end if; end loop; end GetPrivateExponent; --------------------- -- DecimalToBinary -- --------------------- function DecimalToBinary (N : Natural) return String is ret : Ada.Strings.Unbounded.Unbounded_String; begin if N < 2 then return "1"; else Ada.Strings.Unbounded.Append(ret, Ada.Strings.Unbounded.To_Unbounded_String(decimalToBinary (N / 2))); Ada.Strings.Unbounded.Append(ret, Ada.Strings.Fixed.Trim(Integer'Image(N mod 2), Ada.Strings.Left)); end if; return Ada.Strings.Unbounded.To_String(ret); end decimalToBinary; ------------------------------- -- FastModularExponentiation -- ------------------------------- function FastModularExponentiation (b, exp, m : Long_Long_Integer) return Long_Long_Integer is x : Long_Long_Integer := 1; power : Long_Long_Integer; str : String := DecimalToBinary (Integer(exp)); begin power := b mod m; for i in 0 .. (str'Length - 1) loop if str(str'Last - i) = '1' then x := (x * power) mod m; end if; power := (power*power) mod m; --power := FastModularExponentiation(power, power, m); end loop; return x; end FastModularExponentiation; ------------- -- Encrypt -- ------------- function Encrypt (M, N, E : Long_Long_Integer) return Long_Long_Integer is begin return FastModularExponentiation(M, E, N); end Encrypt; ------------- -- Decrypt -- ------------- function Decrypt (C, D, N : Long_Long_Integer) return Long_Long_Integer is begin return FastModularExponentiation(C, D, N); end Decrypt; begin if Ada.Command_Line.Argument_Count < 1 then Ada.Text_IO.Put_Line("You forgot to pass in all the arguments! Try --help."); return; end if; if Ada.Command_Line.Argument(1) = "--help" then Ada.Text_IO.Put_Line("A simple CLI RSA program."); Ada.Text_IO.New_Line; Ada.Text_IO.Put_Line("Usage: "); Ada.Text_IO.Put_Line(" rsa <p> <q> <e> <message>"); Ada.Text_IO.Put_Line(" rsa encrypt <n> <e> <message>"); Ada.Text_IO.Put_Line(" rsa decrypt <d> <n> <message>"); return; end if; if Ada.Command_Line.Argument(1) = "encrypt" then n := Long_Long_Integer'Value(Ada.Command_Line.Argument(2)); e := Long_Long_Integer'Value(Ada.Command_Line.Argument(3)); message := Long_Long_Integer'Value(Ada.Command_Line.Argument(4)); encryptedMessage := Encrypt(message, n, e); Ada.Text_IO.Put("encrypted message = "); Ada.Text_IO.Put_Line(Long_Long_Integer'Image(encryptedMessage)); return; end if; if Ada.Command_Line.Argument(1) = "decrypt" then d := Long_Long_Integer'Value(Ada.Command_Line.Argument(2)); n := Long_Long_Integer'Value(Ada.Command_Line.Argument(3)); encryptedMessage := Long_Long_Integer'Value(Ada.Command_Line.Argument(4)); decryptedMessage := Decrypt(encryptedMessage, d, n); Ada.Text_IO.Put("decrypted message = "); Ada.Text_IO.Put_Line(Long_Long_Integer'Image(decryptedMessage)); return; end if; if Ada.Command_Line.Argument_Count < 4 then Ada.Text_IO.Put_Line("You forgot to pass in all the arguments! Try --help."); return; end if; p := Long_Long_Integer'Value(Ada.Command_Line.Argument(1)); q := Long_Long_Integer'Value(Ada.Command_Line.Argument(2)); e := Long_Long_Integer'Value(Ada.Command_Line.Argument(3)); message := Long_Long_Integer'Value(Ada.Command_Line.Argument(4)); if not (IsPrimeNumber(p) and IsPrimeNumber(q)) then Ada.Text_IO.Put_Line("p and q has to be prime numbers."); return; end if; n := p * q; if message >= n - 1 then Ada.Text_IO.Put_Line("The message has to be smaller than n"); return; end if; phi := (p - 1) * (q - 1); if not (IsOdd(e) and (gcd(e, phi) = 1) and e > 1) then Ada.Text_IO.Put_Line("e has to be 1 < e < λ(n) and gcd(e, λ(n)) = 1"); return; end if; d := GetPrivateExponent(phi, e); encryptedMessage := Encrypt(message, n, e); decryptedMessage := Decrypt(encryptedMessage, d, n); Ada.Text_IO.Put("p ="); Ada.Text_IO.Put_Line(Long_Long_Integer'Image(p)); Ada.Text_IO.Put("q ="); Ada.Text_IO.Put_Line(Long_Long_Integer'Image(q)); Ada.Text_IO.Put("e ="); Ada.Text_IO.Put_Line(Long_Long_Integer'Image(e)); Ada.Text_IO.Put("n ="); Ada.Text_IO.Put_Line(Long_Long_Integer'Image(n)); Ada.Text_IO.Put("phi ="); Ada.Text_IO.Put_Line(Long_Long_Integer'Image(phi)); Ada.Text_IO.Put("d ="); Ada.Text_IO.Put_Line(Long_Long_Integer'Image(d)); Ada.Text_IO.Put("message = "); Ada.Text_IO.Put_Line(Long_Long_Integer'Image(message)); Ada.Text_IO.Put("encrypted message = "); Ada.Text_IO.Put_Line(Long_Long_Integer'Image(encryptedMessage)); Ada.Text_IO.Put("decrypted message = "); Ada.Text_IO.Put_Line(Long_Long_Integer'Image(decryptedMessage)); null; end Main;
PThierry/ewok-kernel
Ada
688
adb
package body types with spark_mode => off is function to_bit (u : unsigned_8) return types.bit is pragma warnings (off); function conv is new ada.unchecked_conversion (unsigned_8, bit); pragma warnings (on); begin if u > 1 then raise program_error; end if; return conv (u); end to_bit; function to_bit (u : unsigned_32) return types.bit is pragma warnings (off); function conv is new ada.unchecked_conversion (unsigned_32, bit); pragma warnings (on); begin if u > 1 then raise program_error; end if; return conv (u); end to_bit; end types;
AdaCore/Ada_Drivers_Library
Ada
10,207
ads
------------------------------------------------------------------------------ -- -- -- Copyright (C) 2015-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 STMicroelectronics nor the names of its -- -- contributors may be used to endorse or promote products derived -- -- from this software without specific prior written permission. -- -- -- -- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -- -- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -- -- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -- -- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -- -- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -- -- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -- -- LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -- -- DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -- -- THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -- -- (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -- -- OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- -- -- -- -- -- This file is based on: -- -- -- -- @file stm32f4xx_hal_usart.h -- -- @author MCD Application Team -- -- @version V1.1.0 -- -- @date 19-June-2014 -- -- @brief Header file of USARTS HAL module. -- -- -- -- COPYRIGHT(c) 2014 STMicroelectronics -- ------------------------------------------------------------------------------ -- This file provides register definitions for the STM32F4 (ARM Cortex M4F) -- USART from ST Microelectronics. -- Note that there are board implementation assumptions represented by the -- private function APB_Clock. with System; with HAL.UART; use HAL.UART; private with STM32_SVD.USART; package STM32.USARTs is type Internal_USART is limited private; type USART (Periph : not null access Internal_USART) is limited new HAL.UART.UART_Port with private; procedure Enable (This : in out USART) with Post => Enabled (This), Inline; procedure Disable (This : in out USART) with Post => not Enabled (This), Inline; function Enabled (This : USART) return Boolean with Inline; procedure Receive (This : USART; Data : out UInt9) with Inline; -- reads Device.DR into Data function Current_Input (This : USART) return UInt9 with Inline; -- returns Device.DR procedure Transmit (This : in out USART; Data : UInt9) with Inline; function Tx_Ready (This : USART) return Boolean with Inline; function Rx_Ready (This : USART) return Boolean with Inline; type Stop_Bits is (Stopbits_1, Stopbits_2) with Size => 2; for Stop_Bits use (Stopbits_1 => 0, Stopbits_2 => 2#10#); procedure Set_Stop_Bits (This : in out USART; To : Stop_Bits); type Word_Lengths is (Word_Length_8, Word_Length_9); procedure Set_Word_Length (This : in out USART; To : Word_Lengths); type Parities is (No_Parity, Even_Parity, Odd_Parity); procedure Set_Parity (This : in out USART; To : Parities); subtype Baud_Rates is UInt32; procedure Set_Baud_Rate (This : in out USART; To : Baud_Rates); type Oversampling_Modes is (Oversampling_By_8, Oversampling_By_16); -- oversampling by 16 is the default procedure Set_Oversampling_Mode (This : in out USART; To : Oversampling_Modes); type UART_Modes is (Rx_Mode, Tx_Mode, Tx_Rx_Mode); procedure Set_Mode (This : in out USART; To : UART_Modes); type Flow_Control is (No_Flow_Control, RTS_Flow_Control, CTS_Flow_Control, RTS_CTS_Flow_Control); procedure Set_Flow_Control (This : in out USART; To : Flow_Control); type USART_Interrupt is (Parity_Error, Transmit_Data_Register_Empty, Transmission_Complete, Received_Data_Not_Empty, Idle_Line_Detection, Line_Break_Detection, Clear_To_Send, Error); procedure Enable_Interrupts (This : in out USART; Source : USART_Interrupt) with Post => Interrupt_Enabled (This, Source), Inline; procedure Disable_Interrupts (This : in out USART; Source : USART_Interrupt) with Post => not Interrupt_Enabled (This, Source), Inline; function Interrupt_Enabled (This : USART; Source : USART_Interrupt) return Boolean with Inline; type USART_Status_Flag is (Parity_Error_Indicated, Framing_Error_Indicated, USART_Noise_Error_Indicated, Overrun_Error_Indicated, Idle_Line_Detection_Indicated, Read_Data_Register_Not_Empty, Transmission_Complete_Indicated, Transmit_Data_Register_Empty, Line_Break_Detection_Indicated, Clear_To_Send_Indicated); function Status (This : USART; Flag : USART_Status_Flag) return Boolean with Inline; procedure Clear_Status (This : in out USART; Flag : USART_Status_Flag) with Inline; procedure Enable_DMA_Transmit_Requests (This : in out USART) with Inline, Post => DMA_Transmit_Requests_Enabled (This); procedure Disable_DMA_Transmit_Requests (This : in out USART) with Inline, Post => not DMA_Transmit_Requests_Enabled (This); function DMA_Transmit_Requests_Enabled (This : USART) return Boolean with Inline; procedure Enable_DMA_Receive_Requests (This : in out USART) with Inline, Post => DMA_Receive_Requests_Enabled (This); procedure Disable_DMA_Receive_Requests (This : in out USART) with Inline, Post => not DMA_Receive_Requests_Enabled (This); function DMA_Receive_Requests_Enabled (This : USART) return Boolean with Inline; procedure Pause_DMA_Transmission (This : in out USART) renames Disable_DMA_Transmit_Requests; procedure Resume_DMA_Transmission (This : in out USART) with Inline, Post => DMA_Transmit_Requests_Enabled (This) and Enabled (This); procedure Pause_DMA_Reception (This : in out USART) renames Disable_DMA_Receive_Requests; procedure Resume_DMA_Reception (This : in out USART) with Inline, Post => DMA_Receive_Requests_Enabled (This) and Enabled (This); function Data_Register_Address (This : USART) return System.Address with Inline; -- Returns the address of the USART Data Register. This is exported -- STRICTLY for the sake of clients driving a USART via DMA. All other -- clients of this package should use the procedural interfaces Transmit -- and Receive instead of directly accessing the Data Register! -- Seriously, don't use this function otherwise. ----------------------------- -- HAL.UART implementation -- ----------------------------- overriding function Data_Size (This : USART) return HAL.UART.UART_Data_Size; overriding procedure Transmit (This : in out USART; Data : UART_Data_8b; Status : out UART_Status; Timeout : Natural := 1000) with Pre'Class => Data_Size (This) = Data_Size_8b; overriding procedure Transmit (This : in out USART; Data : UART_Data_9b; Status : out UART_Status; Timeout : Natural := 1000) with Pre'Class => Data_Size (This) = Data_Size_9b; overriding procedure Receive (This : in out USART; Data : out UART_Data_8b; Status : out UART_Status; Timeout : Natural := 1000) with Pre'Class => Data_Size (This) = Data_Size_8b; overriding procedure Receive (This : in out USART; Data : out UART_Data_9b; Status : out UART_Status; Timeout : Natural := 1000) with Pre'Class => Data_Size (This) = Data_Size_9b; private function APB_Clock (This : USART) return UInt32 with Inline; -- Returns either APB1 or APB2 clock rate, in Hertz, depending on the -- USART. For the sake of not making this package board-specific, we assume -- that we are given a valid USART object at a valid address, AND that the -- USART devices really are configured such that only 1 and 6 are on APB2. -- Therefore, if a board has additional USARTs beyond USART6, eg USART8 on -- the F429I Discovery board, they better conform to that assumption. -- See Note # 2 in each of Tables 139-141 of the RM on pages 970 - 972. type Internal_USART is new STM32_SVD.USART.USART1_Peripheral; type USART (Periph : not null access Internal_USART) is limited new HAL.UART.UART_Port with null record; end STM32.USARTs;
AdaCore/libadalang
Ada
935
ads
-- -- Copyright (C) 2014-2022, AdaCore -- SPDX-License-Identifier: Apache-2.0 -- -- Helper for ``Libadalang.Preprocessing``, implementing the preprocessing -- itself, i.e. Ada source code transformation given a preprocessing -- configuration. with Langkit_Support.Diagnostics; use Langkit_Support.Diagnostics; with Libadalang.Analysis; use Libadalang.Analysis; with Libadalang.Preprocessing; use Libadalang.Preprocessing; private package Libadalang.PP_Impl is procedure Preprocess (Cfg : File_Config; Context : Analysis_Context; Input : String; Contents : out Preprocessed_Source; Diagnostics : in out Diagnostics_Vectors.Vector); -- Preprocess the ``Input`` source buffer using the given ``Cfg`` file -- configuration. Put the result in ``Contents`` and ``Diagnostics``. -- ``Context`` is used to parse preprocessing directives. end Libadalang.PP_Impl;
jamiepg1/sdlada
Ada
1,993
ads
-------------------------------------------------------------------------------------------------------------------- -- Copyright (c) 2014 Luke A. Guest -- -- This software is provided 'as-is', without any express or implied -- warranty. In no event will the authors be held liable for any damages -- arising from the use of this software. -- -- Permission is granted to anyone to use this software for any purpose, -- including commercial applications, and to alter it and redistribute it -- freely, subject to the following restrictions: -- -- 1. The origin of this software must not be misrepresented; you must not -- claim that you wrote the original software. If you use this software -- in a product, an acknowledgment in the product documentation would be -- appreciated but is not required. -- -- 2. Altered source versions must be plainly marked as such, and must not be -- misrepresented as being the original software. -- -- 3. This notice may not be removed or altered from any source -- distribution. -------------------------------------------------------------------------------------------------------------------- -- SDL.Video.Pixels -- -- Access to pixel data. -------------------------------------------------------------------------------------------------------------------- with Ada.Finalization; with Interfaces.C.Pointers; package SDL.Video.Pixels is -- Define pixel data access. Each pixel can be of any pixel format type. -- A bitmap returned, say from Textures.Lock is an array of pixels. -- This package wraps a C pointer to pixel data with an access mechanism. type Kinds is (Read, Write, Any) with Convention => C; type Pixel is new Ada.Finalization.Limited_Controlled with private; private type Pixel is new Ada.Finalization.Limited_Controlled with record -- Data : Interfaces.C.Pointers.Pointer; Access_Method : Kinds; end record; end SDL.Video.Pixels;
reznikmm/slimp
Ada
990
ads
-- Copyright (c) 2019 Maxim Reznik <[email protected]> -- -- SPDX-License-Identifier: MIT -- License-Filename: LICENSE ------------------------------------------------------------- package Slim.Messages.audp is type Audp_Message is new Message with private; -- Tell the client to enable/disable the audio outputs. private subtype Byte is Ada.Streams.Stream_Element; type Audp_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 Audp_Message; overriding procedure Write (Self : Audp_Message; Tag : out Message_Tag; Data : out League.Stream_Element_Vectors.Stream_Element_Vector); overriding procedure Visit (Self : not null access Audp_Message; Visiter : in out Slim.Message_Visiters.Visiter'Class); end Slim.Messages.audp;
zhmu/ananas
Ada
96
adb
-- { dg-do compile } package body Expr_Func6 is procedure Dummy is null; end Expr_Func6;
reznikmm/matreshka
Ada
4,672
adb
------------------------------------------------------------------------------ -- -- -- Matreshka Project -- -- -- -- Open Document Toolkit -- -- -- -- Runtime Library Component -- -- -- ------------------------------------------------------------------------------ -- -- -- Copyright © 2014, Vadim Godunko <[email protected]> -- -- All rights reserved. -- -- -- -- Redistribution and use in source and binary forms, with or without -- -- modification, are permitted provided that the following conditions -- -- are met: -- -- -- -- * Redistributions of source code must retain the above copyright -- -- notice, this list of conditions and the following disclaimer. -- -- -- -- * Redistributions in binary form must reproduce the above copyright -- -- notice, this list of conditions and the following disclaimer in the -- -- documentation and/or other materials provided with the distribution. -- -- -- -- * Neither the name of the Vadim Godunko, IE nor the names of its -- -- contributors may be used to endorse or promote products derived from -- -- this software without specific prior written permission. -- -- -- -- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -- -- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -- -- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -- -- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -- -- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -- -- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED -- -- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -- -- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -- -- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -- -- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -- -- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- -- -- ------------------------------------------------------------------------------ -- $Revision$ $Date$ ------------------------------------------------------------------------------ with Matreshka.DOM_Documents; with Matreshka.ODF_String_Constants; with ODF.DOM.Iterators; with ODF.DOM.Visitors; package body Matreshka.ODF_Style.Font_Size_Complex_Attributes is ------------ -- Create -- ------------ overriding function Create (Parameters : not null access Matreshka.DOM_Attributes.Attribute_L2_Parameters) return Style_Font_Size_Complex_Attribute_Node is begin return Self : Style_Font_Size_Complex_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_Font_Size_Complex_Attribute_Node) return League.Strings.Universal_String is pragma Unreferenced (Self); begin return Matreshka.ODF_String_Constants.Font_Size_Complex_Attribute; end Get_Local_Name; begin Matreshka.DOM_Documents.Register_Attribute (Matreshka.ODF_String_Constants.Style_URI, Matreshka.ODF_String_Constants.Font_Size_Complex_Attribute, Style_Font_Size_Complex_Attribute_Node'Tag); end Matreshka.ODF_Style.Font_Size_Complex_Attributes;
persan/A-gst
Ada
288
ads
with AUnit.Test_Cases; package GStreamer.Rtsp.url.Tests is use AUnit; type Test_Case is new AUnit.Test_Cases.Test_Case with null record; function Name (Test : Test_Case) return Message_String; procedure Register_Tests (Test : in out Test_Case); end GStreamer.Rtsp.url.Tests;
strenkml/EE368
Ada
5,951
adb
with Ada.Assertions; use Ada.Assertions; with Device; use Device; package body Memory.RAM is function Create_RAM(latency : Time_Type := 1; burst : Time_Type := 0; word_size : Positive := 8; word_count : Natural := 65536) return RAM_Pointer is result : constant RAM_Pointer := new RAM_Type; begin result.latency := latency; result.burst := burst; result.word_size := word_size; result.word_count := word_count; return result; end Create_RAM; function Clone(mem : RAM_Type) return Memory_Pointer is result : constant RAM_Pointer := new RAM_Type'(mem); begin return Memory_Pointer(result); end Clone; procedure Reset(mem : in out RAM_Type; context : in Natural) is begin Reset(Memory_Type(mem), context); mem.writes := 0; end Reset; procedure Read(mem : in out RAM_Type; address : in Address_Type; size : in Positive) is word : constant Address_Type := Address_Type(mem.word_size); offset : constant Natural := Natural(address mod word); count : constant Natural := (size + mem.word_size + offset - 1) / mem.word_size; begin Assert(address < Address_Type(2) ** Get_Address_Bits, "invalid address in Memory.RAM.Read"); if mem.burst = 0 then Advance(mem, mem.latency * Time_Type(count)); else Advance(mem, mem.latency); Advance(mem, mem.burst * Time_Type(count - 1)); end if; end Read; procedure Write(mem : in out RAM_Type; address : in Address_Type; size : in Positive) is word : constant Address_Type := Address_Type(mem.word_size); offset : constant Natural := Natural(address mod word); count : constant Natural := (size + mem.word_size + offset - 1) / mem.word_size; begin Assert(address < Address_Type(2) ** Get_Address_Bits, "invalid address in Memory.RAM.Write"); if mem.burst = 0 then Advance(mem, mem.latency * Time_Type(count)); else Advance(mem, mem.latency); Advance(mem, mem.burst * Time_Type(count - 1)); end if; mem.writes := mem.writes + 1; end Write; function To_String(mem : RAM_Type) return Unbounded_String is result : Unbounded_String; begin Append(result, "(ram "); Append(result, "(latency" & Time_Type'Image(mem.latency) & ")"); if mem.burst /= 0 then Append(result, "(burst" & Time_Type'Image(mem.burst) & ")"); end if; Append(result, "(word_size" & Positive'Image(mem.word_size) & ")"); Append(result, "(word_count" & Natural'Image(mem.word_count) & ")"); Append(result, ")"); return result; end To_String; function Get_Cost(mem : RAM_Type) return Cost_Type is begin return 0; end Get_Cost; function Get_Writes(mem : RAM_Type) return Long_Integer is begin return mem.writes; end Get_Writes; function Get_Word_Size(mem : RAM_Type) return Positive is begin return mem.word_size; end Get_Word_Size; function Get_Ports(mem : RAM_Type) return Port_Vector_Type is result : Port_Vector_Type; port : constant Port_Type := Get_Port(mem); begin -- Emit a port if we aren't creating a model. if mem.word_count = 0 then result.Append(port); end if; return result; end Get_Ports; procedure Generate(mem : in RAM_Type; sigs : in out Unbounded_String; code : in out Unbounded_String) is name : constant String := "m" & To_String(Get_ID(mem)); pname : constant String := "p" & To_String(Get_ID(mem)); words : constant Natural := mem.word_count; word_bits : constant Natural := 8 * Get_Word_Size(mem); latency : constant Time_Type := mem.latency; burst : constant Time_Type := mem.burst; begin Declare_Signals(sigs, name, word_bits); if words > 0 then -- Emit a memory model. Line(code, name & "_inst : entity work.ram"); Line(code, " generic map ("); Line(code, " ADDR_WIDTH => ADDR_WIDTH,"); Line(code, " WORD_WIDTH => " & To_String(word_bits) & ","); Line(code, " SIZE => " & To_String(words) & ","); Line(code, " LATENCY => " & To_String(latency) & ","); Line(code, " BURST => " & To_String(burst)); Line(code, " )"); Line(code, " port map ("); Line(code, " clk => clk,"); Line(code, " rst => rst,"); Line(code, " addr => " & name & "_addr,"); Line(code, " din => " & name & "_din,"); Line(code, " dout => " & name & "_dout,"); Line(code, " re => " & name & "_re,"); Line(code, " we => " & name & "_we,"); Line(code, " mask => " & name & "_mask,"); Line(code, " ready => " & name & "_ready"); Line(code, " );"); else -- No model; wire up a port. Declare_Signals(sigs, pname, word_bits); Line(code, pname & "_addr <= " & name & "_addr;"); Line(code, pname & "_din <= " & name & "_din;"); Line(code, name & "_dout <= " & pname & "_dout;"); Line(code, pname & "_re <= " & name & "_re;"); Line(code, pname & "_we <= " & name & "_we;"); Line(code, pname & "_mask <= " & name & "_mask;"); Line(code, name & "_ready <= " & pname & "_ready;"); end if; end Generate; end Memory.RAM;
GLADORG/glad-cli
Ada
55
adb
procedure @_APPNAME_@ is begin null; end @_APPNAME_@;
reznikmm/matreshka
Ada
3,665
ads
------------------------------------------------------------------------------ -- -- -- Matreshka Project -- -- -- -- Open Document Toolkit -- -- -- -- Runtime Library Component -- -- -- ------------------------------------------------------------------------------ -- -- -- Copyright © 2013, Vadim Godunko <[email protected]> -- -- All rights reserved. -- -- -- -- Redistribution and use in source and binary forms, with or without -- -- modification, are permitted provided that the following conditions -- -- are met: -- -- -- -- * Redistributions of source code must retain the above copyright -- -- notice, this list of conditions and the following disclaimer. -- -- -- -- * Redistributions in binary form must reproduce the above copyright -- -- notice, this list of conditions and the following disclaimer in the -- -- documentation and/or other materials provided with the distribution. -- -- -- -- * Neither the name of the Vadim Godunko, IE nor the names of its -- -- contributors may be used to endorse or promote products derived from -- -- this software without specific prior written permission. -- -- -- -- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -- -- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -- -- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -- -- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -- -- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -- -- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED -- -- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -- -- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -- -- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -- -- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -- -- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- -- -- ------------------------------------------------------------------------------ -- $Revision$ $Date$ ------------------------------------------------------------------------------ with XML.DOM.Elements; package ODF.DOM.Elements.Style.Graphic_Properties is type ODF_Style_Graphic_Properties is new XML.DOM.Elements.DOM_Element with private; private type ODF_Style_Graphic_Properties is new XML.DOM.Elements.DOM_Element with null record; end ODF.DOM.Elements.Style.Graphic_Properties;
riccardo-bernardini/eugen
Ada
7,928
ads
with Ada.Containers.Indefinite_Ordered_Maps; generic with procedure Read_Scalar (Input : in String; Success : out Boolean; Consumed : out Natural; Result : out Scalar_Type); -- If Input begins with a valid scalar value, set Success to True, -- Result to the corresponding scalar value and Consumed to the -- number of chars that make the text representation of the scalar. -- This procedure is used by parse. with procedure Read_Identifier (Input : in String; Success : out Boolean; Consumed : out Natural; Result : out Identifier); with function Join (Prefix, Name : Identifier) return Identifier; package Symbolic_Expressions.Parsing is type ID_Table_Type is private; -- The parsing function accepts, as an optional parameter, an "ID -- table" that specifies if an ID is a variable or a function and, -- in the latter case, how many parameters it accepts. -- -- The behaviour of the Parse function in the presence of an ID that -- is not in the ID table can be one of the following -- -- * Always accept -- (This is default) The ID is considered a variable or a -- function according to the presence of a '(' following the ID. -- -- * Always raise an error -- -- * Accept undefined variables, but not undefined functions. -- -- Note that "Always accept" means "Always accept *undefined* IDs." If, -- for example, the ID is registered as a function, but a '(' does not -- follow an error is raised. -- Empty_ID_Table : constant ID_Table_Type; type Parameter_Count is private; -- A Parameter_Count stores the spec of a function in terms of number -- of accepted parameters. All the combinations are possible: no -- parameter, an exact number of parameters, a range or any number of -- parameters. To create a Parameter_Count you can use the constructors -- Exactly, At_Least and Between or use the constants Any_Number or -- No_Parameter. -- function Exactly (N : Natural) return Parameter_Count; function At_Least (N : Natural) return Parameter_Count; function Between (Min, Max : Natural) return Parameter_Count; Any_Number : constant Parameter_Count; No_Parameter : constant Parameter_Count; procedure Define_Variable (Container : in out ID_Table_Type; Name : Variable_Name); -- Declare a variable with the given name procedure Define_Function (Container : in out ID_Table_Type; Name : Function_Name; N_Params : Parameter_Count); -- Declare a function with the given name, accepting the given number -- of parameters. Examples: -- -- Define_Function(Table, "sin", Exactly(1)); -- Define_Function(Table, "max", Any_Number); -- Define_Function(Table, "rnd", No_Parameter); -- function Is_Acceptable (N_Param : Natural; Limits : Parameter_Count) return Boolean; -- Return True if N_Param lies in Limits -- What to do when the parser finds an ID that is not in the -- ID_Table given to the parser type Unknown_ID_Action_Type is (OK, -- Always accept the ID Accept_As_Var, -- Accept it, only if used as a variable Die); -- Never accept it Parsing_Error : exception; type Multiple_Match_Action is (Die, Allow, Allow_Unprefixed); function Parse (Input : String; ID_Table : ID_Table_Type := Empty_ID_Table; On_Unknown_ID : Unknown_ID_Action_Type := OK; Prefixes : String := ""; Prefix_Separator : String := "."; On_Multiple_Match : Multiple_Match_Action := Allow_Unprefixed) return Symbolic_Expression; -- Parse a string with an expression and return the result. The grammar -- of the expression is the usual one -- -- Expr = Term *(('+' | '-') Term) -- Term = Fact *(('*' | '/') Fact) -- Fact = [('+' | '-')] Simple -- Simple = Id [ '(' List ')' ] | Scalar | '(' Expr ')' -- List = Expr *(',' Expr) -- -- As usual, [...] denote an optional part, *(...) means -- one or more repetition of something and '|' means -- alternatives. -- -- Note that -- -- * In the production for Simple a single Id (without a -- following list) represents a variabile, while an Id with a following -- list represents a function call. -- -- (Yes, folks, a call without arguments is something like foo(), -- C-like .. . I know, I know, but with this convention parsing is -- a bit easier since the difference is implicit in the syntax) -- -- * Id follows the usual name syntax: letters, digits, -- underscores and (in addition) the '.', so that "foo.end" is a -- valid identifier. The first char must be a letter. -- -- * The syntax of Scalar is implicitely defined by the function -- Read_Scalar used in the instantiation. In order to avoid the risk -- that the grammar above becomes ambiguous, a scalar should not begin -- with a letter, a '(' or a sign. -- -- * If Prefixes is not empty, it is expected to be a sequence of -- identifiers separated by spaces. If an identifier is not found -- "as it is," it is searched by prefixing it with the prefixes -- in the order given. For example, if -- -- Prefixes="Ada.Strings Ada.Foo Ada" -- -- and the identifier is "bar," the following strings are searched -- in order -- -- Bar -- Ada.Strings.Bar -- Ada.Foo.Bar -- Ada.Bar -- -- It is possible to change the separator used between the identifier -- and the prefix by specifyint Prefix_Separator. For example, if -- Prefix_Separator = "::" the following identifiers are searched -- for -- -- Bar -- Ada.Strings::Bar -- Ada.Foo::Bar -- Ada::Bar -- -- * If Prefixes is not empty, all prefixes are tried. The behaviour -- used when more than one prefix matches depends on -- On_Multiple_Match -- -- - if On_Multiple_Match = Die, -- an exception is always raised -- -- - if On_Multiple_Match = Allow, -- the first match is taken -- -- - if On_Multiple_Match = Allow_Unprefixed, -- if the unprefixed name matches, the unprefixed name -- is taken, otherwise an exception is raised private type Parameter_Count is record Min : Natural; Max : Natural; end record; Any_Number : constant Parameter_Count := (Natural'First, Natural'Last); No_Parameter : constant Parameter_Count := (0, 0); type ID_Class is (Funct, Var); type ID_Descriptor (Class : ID_Class) is record case Class is when Funct => N_Param : Parameter_Count; when Var => null; end case; end record; package ID_Tables is new Ada.Containers.Indefinite_Ordered_Maps (Key_Type => Identifier, Element_Type => ID_Descriptor); type ID_Table_Type is record T : ID_Tables.Map := ID_Tables.Empty_Map; end record; Empty_ID_Table : constant ID_Table_Type := (T => ID_Tables.Empty_Map); end Symbolic_Expressions.Parsing;
gerr135/gnat_bugs
Ada
1,002
adb
pragma Ada_2012; with Ada.Text_IO; package body issue is procedure Set_Smth (AB : in out Abstract_Base'Class; smth : Integer) is use Ada.Text_IO; begin Put_Line(" Set_smth(" & smth'img & ")"); -- never gets here declare R : Repr := AB.ToRepr; begin R.smth := smth; AB.FromRepr(R); end; end Set_Smth; overriding function ToRepr (B : Base) return Repr is R : Repr(Natural(B.sv.Length)); use Ada.Text_IO; begin Put_Line(" ToRepr"); R.smth := B.smth; for i in 1 .. Integer(B.sv.Length) loop R.sa(i) := B.sv(i); end loop; return R; end ToRepr; overriding procedure FromRepr (B : in out Base; R : Repr) is use Ada.Text_IO; begin Put_Line(" FromRepr"); B.smth := R.smth; for i in 1 .. R.sa'Length loop B.sv(i) := R.sa(i); end loop; end FromRepr; end issue;
AdaCore/gpr
Ada
1,072
adb
with Ada.Text_IO; with GPR2.Project.Tree; with GPR2.Context; with GPR2.Path_Name; with Ada.Containers.Doubly_Linked_Lists; with Ada.Strings.Unbounded; use Ada.Strings.Unbounded; procedure Main is Ctx : GPR2.Context.Object; Tree : GPR2.Project.Tree.Object; package Set is new Ada.Containers.Doubly_Linked_Lists (Unbounded_String); package Sort is new Set.Generic_Sorting; List : Set.List; procedure Print_And_Clean_List; procedure Print_And_Clean_List is begin Sort.Sort (List); for S of List loop Ada.Text_IO.Put_Line (To_String (S)); end loop; List.Clear; end Print_And_Clean_List; begin Tree.Load_Autoconf (GPR2.Path_Name.Create_File ("default.gpr"), Ctx); Tree.Update_Sources; for Source of Tree.Root_Project.Sources loop List.Append (To_Unbounded_String (String (Source.Path_Name.Name))); end loop; Print_And_Clean_List; for Unit of Tree.Root_Project.Units loop List.Append (To_Unbounded_String (String (Unit.Name))); end loop; Print_And_Clean_List; end Main;
stcarrez/mat
Ada
52,812
adb
----------------------------------------------------------------------- -- mat-interp -- Command interpreter -- Copyright (C) 2014, 2015, 2021, 2023 Stephane Carrez -- Written by Stephane Carrez ([email protected]) -- -- Licensed under the Apache License, Version 2.0 (the "License"); -- you may not use this file except in compliance with the License. -- You may obtain a copy of the License at -- -- http://www.apache.org/licenses/LICENSE-2.0 -- -- Unless required by applicable law or agreed to in writing, software -- distributed under the License is distributed on an "AS IS" BASIS, -- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -- See the License for the specific language governing permissions and -- limitations under the License. ----------------------------------------------------------------------- with Util.Strings; with Util.Strings.Tokenizers; with Util.Log.Loggers; with Ada.Containers.Indefinite_Hashed_Maps; with Ada.Strings.Hash; with Ada.Strings.Fixed; with Ada.Exceptions; with Ada.IO_Exceptions; with Ada.Strings.Unbounded; with GNAT.Command_Line; with Bfd; with ELF; with MAT.Types; with MAT.Readers.Streams.Files; with MAT.Memory.Tools; with MAT.Memory.Targets; with MAT.Symbols.Targets; with MAT.Expressions; with MAT.Expressions.Parser_Tokens; with MAT.Frames; with MAT.Consoles; with MAT.Formats; with MAT.Events.Tools; with MAT.Events.Timelines; package body MAT.Commands is use type MAT.Types.Target_Size; -- The logger Log : constant Util.Log.Loggers.Logger := Util.Log.Loggers.Create ("MAT.Commands"); procedure Get_Arguments (Process : in MAT.Targets.Target_Process_Type_Access; Args : in String; Long_Flag : out Boolean; Count_Flag : out Boolean; Filter : in out MAT.Expressions.Expression_Type); function Get_Command (Line : in String) return String; procedure Slot_Command (Target : in out MAT.Targets.Target_Type'Class; Args : in String); procedure Frames_Command (Target : in out MAT.Targets.Target_Type'Class; Args : in String); procedure Exit_Command (Target : in out MAT.Targets.Target_Type'Class; Args : in String); procedure Set_Command (Target : in out MAT.Targets.Target_Type'Class; Args : in String); procedure Open_Command (Target : in out MAT.Targets.Target_Type'Class; Args : in String); procedure Help_Command (Target : in out MAT.Targets.Target_Type'Class; Args : in String); procedure Event_Sizes_Command (Target : in out MAT.Targets.Target_Type'Class; Args : in String); procedure Event_Frames_Command (Target : in out MAT.Targets.Target_Type'Class; Args : in String); -- Maps command to dump the memory maps of the program. procedure Maps_Command (Target : in out MAT.Targets.Target_Type'Class; Args : in String); -- Print the stack frame description in the console. procedure Print_Frame (Console : in MAT.Consoles.Console_Access; Frame : in MAT.Frames.Frame_Type; Symbols : in MAT.Symbols.Targets.Target_Symbols_Ref); -- Print the memory regions described by the Regions map. procedure Print_Regions (Console : in MAT.Consoles.Console_Access; Regions : in MAT.Memory.Region_Info_Map); -- Print the events with a short description. procedure Print_Events (Console : in MAT.Consoles.Console_Access; Events : in MAT.Events.Tools.Target_Event_Vector; Start : in MAT.Types.Target_Tick_Ref); -- Print the full description of a memory slot that is currently allocated. procedure Print_Slot (Console : in MAT.Consoles.Console_Access; Addr : in MAT.Types.Target_Addr; Slot : in MAT.Memory.Allocation; Symbols : in MAT.Symbols.Targets.Target_Symbols_Ref; Start : in MAT.Types.Target_Tick_Ref); package Command_Map is new Ada.Containers.Indefinite_Hashed_Maps (Key_Type => String, Element_Type => Command_Handler, Equivalent_Keys => "=", Hash => Ada.Strings.Hash); Commands : Command_Map.Map; -- ------------------------------ -- Print the stack frame description in the console. -- ------------------------------ procedure Print_Frame (Console : in MAT.Consoles.Console_Access; Frame : in MAT.Frames.Frame_Type; Symbols : in MAT.Symbols.Targets.Target_Symbols_Ref) is Backtrace : constant MAT.Frames.Frame_Table := MAT.Frames.Backtrace (Frame); Symbol : MAT.Symbols.Targets.Symbol_Info; begin for I in Backtrace'Range loop Console.Start_Row; Console.Print_Field (MAT.Consoles.F_FRAME_ID, I, MAT.Consoles.J_RIGHT); Console.Print_Field (MAT.Consoles.F_FRAME_ADDR, Backtrace (I)); MAT.Symbols.Targets.Find_Nearest_Line (Symbols => Symbols.Value, Addr => Backtrace (I), Symbol => Symbol); Console.Print_Field (MAT.Consoles.F_FUNCTION_NAME, MAT.Formats.Location (Symbol.File, Symbol.Line, Symbol.Name), MAT.Consoles.J_RIGHT_NO_FILL); Console.End_Row; end loop; end Print_Frame; -- ------------------------------ -- Print the memory regions described by the Regions map. -- ------------------------------ procedure Print_Regions (Console : in MAT.Consoles.Console_Access; Regions : in MAT.Memory.Region_Info_Map) is use type ELF.Elf32_Word; Iter : MAT.Memory.Region_Info_Cursor; Region : MAT.Memory.Region_Info; begin Console.Start_Title; Console.Print_Title (MAT.Consoles.F_RANGE_ADDR, "Address range", 39); Console.Print_Title (MAT.Consoles.F_MODE, "Flags", 6); Console.Print_Title (MAT.Consoles.F_FILE_NAME, "Path", 40); Console.End_Title; Iter := Regions.First; while MAT.Memory.Region_Info_Maps.Has_Element (Iter) loop Region := MAT.Memory.Region_Info_Maps.Element (Iter); declare Flags : String (1 .. 3) := "---"; begin if (Region.Flags and ELF.PF_R) /= 0 then Flags (1) := 'r'; end if; if (Region.Flags and ELF.PF_W) /= 0 then Flags (2) := 'w'; end if; if (Region.Flags and ELF.PF_X) /= 0 then Flags (3) := 'x'; end if; Console.Start_Row; Console.Print_Field (MAT.Consoles.F_RANGE_ADDR, Region.Start_Addr, Region.End_Addr); Console.Print_Field (MAT.Consoles.F_MODE, Flags); Console.Print_Field (MAT.Consoles.F_FILE_NAME, Region.Path); Console.End_Row; end; MAT.Memory.Region_Info_Maps.Next (Iter); end loop; end Print_Regions; -- ------------------------------ -- Print the events with a short description. -- ------------------------------ procedure Print_Events (Console : in MAT.Consoles.Console_Access; Events : in MAT.Events.Tools.Target_Event_Vector; Start : in MAT.Types.Target_Tick_Ref) is Iter : MAT.Events.Tools.Target_Event_Cursor; begin Console.Start_Title; Console.Print_Title (MAT.Consoles.F_PREVIOUS, "Previous", 10); Console.Print_Title (MAT.Consoles.F_ID, "Id", 10); Console.Print_Title (MAT.Consoles.F_NEXT, "Next", 10); Console.Print_Title (MAT.Consoles.F_TIME, "Time", 10); Console.Print_Title (MAT.Consoles.F_EVENT, "Event", 60); Console.End_Title; Iter := Events.First; while MAT.Events.Tools.Target_Event_Vectors.Has_Element (Iter) loop declare use type MAT.Types.Target_Tick_Ref; Event : constant MAT.Events.Target_Event_Type := MAT.Events.Tools.Target_Event_Vectors.Element (Iter); Time : constant MAT.Types.Target_Tick_Ref := Event.Time - Start; begin Console.Start_Row; Console.Print_Field (MAT.Consoles.F_PREVIOUS, MAT.Formats.Offset (Event.Prev_Id, Event.Id)); Console.Print_Field (MAT.Consoles.F_ID, MAT.Events.Event_Id_Type'Image (Event.Id)); Console.Print_Field (MAT.Consoles.F_NEXT, MAT.Formats.Offset (Event.Next_Id, Event.Id)); Console.Print_Duration (MAT.Consoles.F_TIME, Time); Console.Print_Field (MAT.Consoles.F_EVENT, MAT.Formats.Event (Event)); Console.End_Row; end; MAT.Events.Tools.Target_Event_Vectors.Next (Iter); end loop; end Print_Events; -- ------------------------------ -- Print the full description of a memory slot that is currently allocated. -- ------------------------------ procedure Print_Slot (Console : in MAT.Consoles.Console_Access; Addr : in MAT.Types.Target_Addr; Slot : in MAT.Memory.Allocation; Symbols : in MAT.Symbols.Targets.Target_Symbols_Ref; Start : in MAT.Types.Target_Tick_Ref) is Backtrace : constant MAT.Frames.Frame_Table := MAT.Frames.Backtrace (Slot.Frame); Symbol : MAT.Symbols.Targets.Symbol_Info; begin if Console.Get_Field_Count = 0 then Console.Start_Title; Console.Print_Title (MAT.Consoles.F_ID, "Id", 4); Console.Print_Title (MAT.Consoles.F_ADDR, "Address", 22); Console.Print_Title (MAT.Consoles.F_FUNCTION_NAME, "Function", 80); Console.End_Title; end if; Console.Start_Row; Console.Notice (Consoles.N_EVENT_ID, MAT.Formats.Slot (Addr, Slot, Start)); for I in Backtrace'Range loop Console.Start_Row; Console.Print_Field (Consoles.F_ID, I); Console.Print_Field (Consoles.F_ADDR, MAT.Formats.Addr (Backtrace (I))); MAT.Symbols.Targets.Find_Nearest_Line (Symbols => Symbols.Value, Addr => Backtrace (I), Symbol => Symbol); Console.Print_Field (Consoles.F_FUNCTION_NAME, MAT.Formats.Location (Symbol.File, Symbol.Line, Symbol.Name)); Console.End_Row; end loop; Console.End_Row; end Print_Slot; procedure Get_Arguments (Process : in MAT.Targets.Target_Process_Type_Access; Args : in String; Long_Flag : out Boolean; Count_Flag : out Boolean; Filter : in out MAT.Expressions.Expression_Type) is procedure Check_Argument (Token : in String; Done : out Boolean); Pos : Natural := Args'First; procedure Check_Argument (Token : in String; Done : out Boolean) is begin if Token'Length = 0 or else Token (Token'First) /= '-' then Done := True; elsif Token = "-l" then Long_Flag := True; Done := False; Pos := Pos + Token'Length + 1; elsif Token = "-c" then Count_Flag := True; Done := False; Pos := Pos + Token'Length + 1; else raise Usage_Error; end if; end Check_Argument; begin Long_Flag := False; Count_Flag := False; Pos := Args'First; Util.Strings.Tokenizers.Iterate_Tokens (Content => Args, Pattern => " ", Process => Check_Argument'Access); if Pos < Args'Last then Filter := MAT.Expressions.Parse (Args (Pos .. Args'Last), Process.all'Access); end if; exception when MAT.Expressions.Parser_Tokens.Syntax_Error => raise Filter_Error with Args (Pos .. Args'Last); end Get_Arguments; -- ------------------------------ -- Sizes command. -- Collect statistics about the used memory slots and report the different slot -- sizes with count. -- ------------------------------ procedure Slot_Command (Target : in out MAT.Targets.Target_Type'Class; Args : in String) is Slots : MAT.Memory.Allocation_Map; Iter : MAT.Memory.Allocation_Cursor; Symbols : constant MAT.Symbols.Targets.Target_Symbols_Ref := Target.Process.Symbols; Console : constant MAT.Consoles.Console_Access := Target.Console; Process : constant MAT.Targets.Target_Process_Type_Access := Target.Process; Start, Finish : MAT.Types.Target_Tick_Ref; Filter : MAT.Expressions.Expression_Type; Long_Flag : Boolean; Count_Flag : Boolean; begin Get_Arguments (Process, Args, Long_Flag, Count_Flag, Filter); Process.Memory.Find (From => MAT.Types.Target_Addr'First, To => MAT.Types.Target_Addr'Last, Filter => Filter, Into => Slots); if Count_Flag then Console.Notice (Consoles.N_INFO, "Found" & Natural'Image (Natural (Slots.Length)) & " memory slots"); return; end if; Process.Events.Get_Time_Range (Start, Finish); Iter := Slots.First; while MAT.Memory.Allocation_Maps.Has_Element (Iter) loop declare Addr : constant MAT.Types.Target_Addr := MAT.Memory.Allocation_Maps.Key (Iter); Slot : constant MAT.Memory.Allocation := MAT.Memory.Allocation_Maps.Element (Iter); begin if not Long_Flag then Console.Notice (Consoles.N_EVENT_ID, MAT.Formats.Slot (Addr, Slot, Start)); else Print_Slot (Console, Addr, Slot, Symbols, Start); end if; end; MAT.Memory.Allocation_Maps.Next (Iter); end loop; end Slot_Command; -- ------------------------------ -- Sizes command. -- Collect statistics about the used memory slots and report the different slot -- sizes with count. -- ------------------------------ procedure Sizes_Command (Target : in out MAT.Targets.Target_Type'Class; Args : in String) is pragma Unreferenced (Args); Sizes : MAT.Memory.Tools.Size_Info_Map; Console : constant MAT.Consoles.Console_Access := Target.Console; Process : constant MAT.Targets.Target_Process_Type_Access := Target.Process; Iter : MAT.Memory.Tools.Size_Info_Cursor; begin Console.Start_Title; Console.Print_Title (MAT.Consoles.F_SIZE, "Slot size", 25); Console.Print_Title (MAT.Consoles.F_COUNT, "Count", 15); Console.Print_Title (MAT.Consoles.F_TOTAL_SIZE, "Total size", 15); Console.End_Title; MAT.Memory.Targets.Size_Information (Memory => Process.Memory, Sizes => Sizes); Iter := Sizes.First; while MAT.Memory.Tools.Size_Info_Maps.Has_Element (Iter) loop declare use MAT.Memory.Tools; Size : constant MAT.Types.Target_Size := MAT.Memory.Tools.Size_Info_Maps.Key (Iter); Info : constant Size_Info_Type := Memory.Tools.Size_Info_Maps.Element (Iter); Total : constant MAT.Types.Target_Size := Size * MAT.Types.Target_Size (Info.Count); begin Console.Start_Row; Console.Print_Size (MAT.Consoles.F_SIZE, Size); Console.Print_Field (MAT.Consoles.F_COUNT, Info.Count); Console.Print_Size (MAT.Consoles.F_TOTAL_SIZE, Total); Console.End_Row; end; MAT.Memory.Tools.Size_Info_Maps.Next (Iter); end loop; end Sizes_Command; -- ------------------------------ -- Threads command. -- Collect statistics about the threads and their allocation. -- ------------------------------ procedure Threads_Command (Target : in out MAT.Targets.Target_Type'Class; Args : in String) is pragma Unreferenced (Args); Threads : MAT.Memory.Memory_Info_Map; Console : constant MAT.Consoles.Console_Access := Target.Console; Process : constant MAT.Targets.Target_Process_Type_Access := Target.Process; Iter : MAT.Memory.Memory_Info_Cursor; begin Console.Start_Title; Console.Print_Title (MAT.Consoles.F_THREAD, "Thread", 10); Console.Print_Title (MAT.Consoles.F_COUNT, "# Allocation", 13); Console.Print_Title (MAT.Consoles.F_TOTAL_SIZE, "Total size", 15); Console.Print_Title (MAT.Consoles.F_MIN_SIZE, "Min slot size", 15); Console.Print_Title (MAT.Consoles.F_MAX_SIZE, "Max slot size", 15); Console.Print_Title (MAT.Consoles.F_MIN_ADDR, "Low address", 17); Console.Print_Title (MAT.Consoles.F_MAX_ADDR, "High address", 17); Console.End_Title; MAT.Memory.Targets.Thread_Information (Memory => Process.Memory, Threads => Threads); Iter := Threads.First; while MAT.Memory.Memory_Info_Maps.Has_Element (Iter) loop declare Thread : constant Types.Target_Thread_Ref := MAT.Memory.Memory_Info_Maps.Key (Iter); Info : constant Memory.Memory_Info := MAT.Memory.Memory_Info_Maps.Element (Iter); begin Console.Start_Row; Console.Print_Thread (MAT.Consoles.F_THREAD, Thread); Console.Print_Field (MAT.Consoles.F_COUNT, Info.Alloc_Count); Console.Print_Size (MAT.Consoles.F_TOTAL_SIZE, Info.Total_Size); Console.Print_Size (MAT.Consoles.F_MIN_SIZE, Info.Min_Slot_Size); Console.Print_Size (MAT.Consoles.F_MAX_SIZE, Info.Max_Slot_Size); Console.Print_Field (MAT.Consoles.F_MIN_ADDR, Info.Min_Addr); Console.Print_Field (MAT.Consoles.F_MAX_ADDR, Info.Max_Addr); Console.End_Row; end; MAT.Memory.Memory_Info_Maps.Next (Iter); end loop; end Threads_Command; -- ------------------------------ -- Frames command. -- Collect statistics about the frames and their allocation. -- ------------------------------ procedure Frames_Command (Target : in out MAT.Targets.Target_Type'Class; Args : in String) is Frames : MAT.Memory.Frame_Info_Map; Level : Positive := 3; Console : constant MAT.Consoles.Console_Access := Target.Console; Process : constant MAT.Targets.Target_Process_Type_Access := Target.Process; Iter : MAT.Memory.Frame_Info_Cursor; begin if Args'Length > 0 then Level := Positive'Value (Args); end if; Console.Start_Title; Console.Print_Title (MAT.Consoles.F_FUNCTION_NAME, "Function", 20); Console.Print_Title (MAT.Consoles.F_COUNT, "# Slots", 10); Console.Print_Title (MAT.Consoles.F_TOTAL_SIZE, "Total size", 12); Console.Print_Title (MAT.Consoles.F_MIN_SIZE, "Min size", 10); Console.Print_Title (MAT.Consoles.F_MAX_SIZE, "Max size", 10); Console.Print_Title (MAT.Consoles.F_MIN_ADDR, "Low addr", 10); Console.Print_Title (MAT.Consoles.F_MAX_ADDR, "High addr", 10); Console.End_Title; MAT.Memory.Targets.Frame_Information (Memory => Process.Memory, Level => Level, Frames => Frames); Iter := Frames.First; while MAT.Memory.Frame_Info_Maps.Has_Element (Iter) loop declare Func : constant Types.Target_Addr := MAT.Memory.Frame_Info_Maps.Key (Iter); Info : constant Memory.Frame_Info := MAT.Memory.Frame_Info_Maps.Element (Iter); Symbol : MAT.Symbols.Targets.Symbol_Info; begin MAT.Symbols.Targets.Find_Nearest_Line (Symbols => Process.Symbols.Value, Addr => Func, Symbol => Symbol); Console.Start_Row; Console.Print_Field (MAT.Consoles.F_FUNCTION_NAME, MAT.Formats.Location (Symbol.File, Symbol.Line, Symbol.Name)); Console.Print_Field (MAT.Consoles.F_COUNT, Info.Memory.Alloc_Count); Console.Print_Size (MAT.Consoles.F_TOTAL_SIZE, Info.Memory.Total_Size); Console.Print_Size (MAT.Consoles.F_MIN_SIZE, Info.Memory.Min_Slot_Size); Console.Print_Size (MAT.Consoles.F_MAX_SIZE, Info.Memory.Max_Slot_Size); Console.Print_Field (MAT.Consoles.F_MIN_ADDR, Info.Memory.Min_Addr); Console.Print_Field (MAT.Consoles.F_MAX_ADDR, Info.Memory.Max_Addr); Console.End_Row; end; MAT.Memory.Frame_Info_Maps.Next (Iter); end loop; end Frames_Command; -- ------------------------------ -- Event size command. -- Print the size used by malloc/realloc events. -- ------------------------------ procedure Event_Frames_Command (Target : in out MAT.Targets.Target_Type'Class; Args : in String) is Console : constant MAT.Consoles.Console_Access := Target.Console; Process : constant MAT.Targets.Target_Process_Type_Access := Target.Process; Frames : MAT.Events.Tools.Frame_Event_Info_Map; List : MAT.Events.Tools.Frame_Info_Vector; Iter : MAT.Events.Tools.Frame_Info_Cursor; Filter : MAT.Expressions.Expression_Type; Depth : Natural := 3; Symbol : MAT.Symbols.Targets.Symbol_Info; Info : MAT.Events.Tools.Frame_Info_Type; Exact_Depth : Boolean := False; Pos : Natural := Util.Strings.Index (Args, ' '); begin if Pos = 0 then Pos := Args'Last; end if; if Pos < Args'Last then -- Parse the number that identifies the frame depth to print. -- When that number is preceeded by '=', only that frame depth is reported. begin if Args (Args'First) = '=' then Exact_Depth := True; Depth := Positive'Value (Args (Args'First + 1 .. Pos - 1)); else Depth := Positive'Value (Args (Args'First .. Pos - 1)); end if; exception when Constraint_Error => Target.Console.Error ("Invalid frame depth '" & Args (Args'First .. Pos - 1)); return; end; -- Skip spaces before the optional filter expression. while Pos < Args'Last loop exit when Args (Pos) /= ' '; Pos := Pos + 1; end loop; if Pos < Args'Last then Filter := MAT.Expressions.Parse (Args (Pos .. Args'Last), Process.all'Access); end if; end if; Console.Start_Title; Console.Print_Title (MAT.Consoles.F_LEVEL, "Level", 6); Console.Print_Title (MAT.Consoles.F_SIZE, "Size", 10); Console.Print_Title (MAT.Consoles.F_COUNT, "Count", 8); Console.Print_Title (MAT.Consoles.F_FUNCTION_NAME, "Function", 90); Console.End_Title; MAT.Events.Timelines.Find_Frames (Target => Process.Events.all, Filter => Filter, Depth => Depth, Exact => Exact_Depth, Frames => Frames); MAT.Events.Tools.Build_Frame_Info (Frames, List); Iter := List.First; while MAT.Events.Tools.Frame_Info_Vectors.Has_Element (Iter) loop Info := MAT.Events.Tools.Frame_Info_Vectors.Element (Iter); MAT.Symbols.Targets.Find_Nearest_Line (Symbols => Process.Symbols.Value, Addr => Info.Key.Addr, Symbol => Symbol); Console.Start_Row; Console.Print_Field (MAT.Consoles.F_LEVEL, Natural'Image (Info.Key.Level)); Console.Print_Field (MAT.Consoles.F_SIZE, MAT.Formats.Size (Info.Info.Alloc_Size, Info.Info.Free_Size)); Console.Print_Field (MAT.Consoles.F_COUNT, Info.Info.Count); Console.Print_Field (MAT.Consoles.F_FUNCTION_NAME, MAT.Formats.Location (Symbol.File, Symbol.Line, Symbol.Name)); Console.End_Row; MAT.Events.Tools.Frame_Info_Vectors.Next (Iter); end loop; end Event_Frames_Command; -- ------------------------------ -- Event size command. -- Print the size used by malloc/realloc events. -- ------------------------------ procedure Event_Sizes_Command (Target : in out MAT.Targets.Target_Type'Class; Args : in String) is use type MAT.Types.Target_Tick_Ref; Console : constant MAT.Consoles.Console_Access := Target.Console; Process : constant MAT.Targets.Target_Process_Type_Access := Target.Process; Start, Finish : MAT.Types.Target_Tick_Ref; Sizes : MAT.Events.Tools.Size_Event_Info_Map; Filter : MAT.Expressions.Expression_Type; Iter : MAT.Events.Tools.Size_Event_Info_Cursor; Long_Flag : Boolean; Count_Flag : Boolean; Total : MAT.Events.Tools.Event_Info_Type; Info : MAT.Events.Tools.Event_Info_Type; Size : MAT.Types.Target_Size; Time : MAT.Types.Target_Tick_Ref; begin Get_Arguments (Process, Args, Long_Flag, Count_Flag, Filter); if not Count_Flag then Console.Start_Title; Console.Print_Title (MAT.Consoles.F_ID, "Event Id range", 30); Console.Print_Title (MAT.Consoles.F_TIME, "Time", 10); Console.Print_Title (MAT.Consoles.F_EVENT, "Event", 20); Console.Print_Title (MAT.Consoles.F_SIZE, "Size", 12); Console.Print_Title (MAT.Consoles.F_COUNT, "Count", 8); Console.Print_Title (MAT.Consoles.F_TOTAL_SIZE, "Total size", 12); Console.Print_Title (MAT.Consoles.F_GROW_SIZE, "Memory", 12); Console.End_Title; end if; Process.Events.Get_Time_Range (Start, Finish); MAT.Events.Timelines.Find_Sizes (Target => Process.Events.all, Filter => Filter, Sizes => Sizes); Total.Count := Natural (Sizes.Length); Iter := Sizes.First; while MAT.Events.Tools.Size_Event_Info_Maps.Has_Element (Iter) loop Size := MAT.Events.Tools.Size_Event_Info_Maps.Key (Iter); Info := MAT.Events.Tools.Size_Event_Info_Maps.Element (Iter); Time := Info.First_Event.Time - Start; Total.Malloc_Count := Total.Malloc_Count + Info.Malloc_Count; Total.Realloc_Count := Total.Realloc_Count + Info.Realloc_Count; Total.Free_Count := Total.Free_Count + Info.Free_Count; Total.Alloc_Size := Total.Alloc_Size + Info.Alloc_Size; Total.Free_Size := Total.Free_Size + Info.Free_Size; if not Count_Flag then Console.Start_Row; Console.Print_Field (MAT.Consoles.F_ID, MAT.Formats.Event (Info.First_Event, Info.Last_Event)); Console.Print_Duration (MAT.Consoles.F_TIME, Time); Console.Print_Field (MAT.Consoles.F_EVENT, MAT.Formats.Event (Info.First_Event, MAT.Formats.BRIEF)); Console.Print_Size (MAT.Consoles.F_SIZE, Size); Console.Print_Field (MAT.Consoles.F_COUNT, Natural'Image (Info.Count)); Console.Print_Field (MAT.Consoles.F_TOTAL_SIZE, MAT.Formats.Size (MAT.Types.Target_Size (Info.Count) * Size)); if Info.Alloc_Size > Info.Free_Size then Console.Print_Field (MAT.Consoles.F_GROW_SIZE, "+" & MAT.Formats.Size (Info.Alloc_Size - Info.Free_Size)); elsif Info.Alloc_Size < Info.Free_Size then Console.Print_Field (MAT.Consoles.F_GROW_SIZE, "-" & MAT.Formats.Size (Info.Free_Size - Info.Alloc_Size)); end if; Console.End_Row; end if; MAT.Events.Tools.Size_Event_Info_Maps.Next (Iter); end loop; if Total.Count = 0 then Console.Notice (Consoles.N_INFO, "Found no event"); else Console.Notice (Consoles.N_INFO, "Found" & Natural'Image (Total.Count) & " different sizes, " & MAT.Formats.Size (Total.Alloc_Size, Total.Free_Size) & " bytes, with" & Natural'Image (Total.Malloc_Count) & " malloc," & Natural'Image (Total.Realloc_Count) & " realloc," & Natural'Image (Total.Free_Count) & " free"); end if; end Event_Sizes_Command; -- ------------------------------ -- Events command. -- Print the probe events. -- ------------------------------ procedure Events_Command (Target : in out MAT.Targets.Target_Type'Class; Args : in String) is Console : constant MAT.Consoles.Console_Access := Target.Console; Process : constant MAT.Targets.Target_Process_Type_Access := Target.Process; Start, Finish : MAT.Types.Target_Tick_Ref; Events : MAT.Events.Tools.Target_Event_Vector; Filter : MAT.Expressions.Expression_Type; Long_Flag : Boolean; Count_Flag : Boolean; begin Get_Arguments (Process, Args, Long_Flag, Count_Flag, Filter); MAT.Events.Timelines.Filter_Events (Process.Events.all, Filter, Events); if Count_Flag then Console.Notice (Consoles.N_INFO, "Found" & Natural'Image (Natural (Events.Length)) & " events"); return; end if; Process.Events.Get_Time_Range (Start, Finish); Print_Events (Console, Events, Start); end Events_Command; -- ------------------------------ -- Event command. -- Print the probe event with the stack frame. -- ------------------------------ procedure Event_Command (Target : in out MAT.Targets.Target_Type'Class; Args : in String) is use Consoles; Console : constant MAT.Consoles.Console_Access := Target.Console; Process : constant MAT.Targets.Target_Process_Type_Access := Target.Process; Id : MAT.Events.Event_Id_Type; Event : MAT.Events.Target_Event_Type; Start, Finish : MAT.Types.Target_Tick_Ref; Related : MAT.Events.Tools.Target_Event_Vector; begin Id := MAT.Events.Event_Id_Type'Value (Args); Event := Process.Events.Get_Event (Id); MAT.Events.Timelines.Find_Related (Process.Events.all, Event, 10, Related); Process.Events.Get_Time_Range (Start, Finish); Console.Notice (N_EVENT_ID, MAT.Formats.Event (Event, Related, Start)); Console.Start_Title; Console.Print_Title (MAT.Consoles.F_FRAME_ID, "Id", 3); Console.Print_Title (MAT.Consoles.F_FRAME_ADDR, "Frame Address", 22); Console.Print_Title (MAT.Consoles.F_FUNCTION_NAME, "Function", 90); Console.End_Title; Print_Frame (Console, Event.Frame, Process.Symbols); exception when Constraint_Error => Console.Error ("Invalid event '" & Args & "'"); when MAT.Events.Tools.Not_Found => Console.Error ("Event " & Args & " not found"); end Event_Command; -- ------------------------------ -- Timeline command. -- Identify the interesting timeline groups in the events and display them. -- ------------------------------ procedure Timeline_Command (Target : in out MAT.Targets.Target_Type'Class; Args : in String) is use type MAT.Types.Target_Tick_Ref; Console : constant MAT.Consoles.Console_Access := Target.Console; Process : constant MAT.Targets.Target_Process_Type_Access := Target.Process; Start, Finish : MAT.Types.Target_Tick_Ref; Groups : MAT.Events.Timelines.Timeline_Info_Vector; Iter : MAT.Events.Timelines.Timeline_Info_Cursor; Level : Positive := 1; begin if Args'Length > 0 then begin Level := Positive'Value (Args); exception when Constraint_Error => Console.Error ("Invalid level '" & Args & "'"); return; end; end if; MAT.Events.Timelines.Extract (Process.Events.all, Level, Groups); Process.Events.Get_Time_Range (Start, Finish); Console.Start_Title; Console.Print_Title (MAT.Consoles.F_START_TIME, "Start", 10); Console.Print_Title (MAT.Consoles.F_END_TIME, "End time", 10); Console.Print_Title (MAT.Consoles.F_DURATION, "Duration", 10); Console.Print_Title (MAT.Consoles.F_EVENT_RANGE, "Event range", 20); Console.Print_Title (MAT.Consoles.F_MALLOC_COUNT, "# malloc", 10); Console.Print_Title (MAT.Consoles.F_REALLOC_COUNT, "# realloc", 10); Console.Print_Title (MAT.Consoles.F_FREE_COUNT, "# free", 10); Console.Print_Title (MAT.Consoles.F_TOTAL_SIZE, "Memory", 10); Console.End_Title; Iter := Groups.First; while MAT.Events.Timelines.Timeline_Info_Vectors.Has_Element (Iter) loop declare Info : constant MAT.Events.Timelines.Timeline_Info := MAT.Events.Timelines.Timeline_Info_Vectors.Element (Iter); begin Console.Start_Row; Console.Print_Duration (MAT.Consoles.F_START_TIME, Info.First_Event.Time - Start); Console.Print_Duration (MAT.Consoles.F_END_TIME, Info.Last_Event.Time - Start); Console.Print_Duration (MAT.Consoles.F_DURATION, Info.Last_Event.Time - Info.First_Event.Time); Console.Print_Field (MAT.Consoles.F_EVENT_RANGE, MAT.Formats.Event (Info.First_Event, Info.Last_Event)); Console.Print_Field (MAT.Consoles.F_MALLOC_COUNT, Info.Malloc_Count); Console.Print_Field (MAT.Consoles.F_REALLOC_COUNT, Info.Realloc_Count); Console.Print_Field (MAT.Consoles.F_FREE_COUNT, Info.Free_Count); if Info.Alloc_Size = Info.Free_Size then Console.Print_Field (MAT.Consoles.F_TOTAL_SIZE, ""); elsif Info.Alloc_Size > Info.Free_Size then Console.Print_Field (MAT.Consoles.F_TOTAL_SIZE, "+" & MAT.Formats.Size (Info.Alloc_Size - Info.Free_Size)); else Console.Print_Field (MAT.Consoles.F_TOTAL_SIZE, "-" & MAT.Formats.Size (Info.Free_Size - Info.Alloc_Size)); end if; Console.End_Row; end; MAT.Events.Timelines.Timeline_Info_Vectors.Next (Iter); end loop; end Timeline_Command; -- ------------------------------ -- Addr command to print a description of an address. -- ------------------------------ procedure Addr_Command (Target : in out MAT.Targets.Target_Type'Class; Args : in String) is use type ELF.Elf32_Word; Console : constant MAT.Consoles.Console_Access := Target.Console; Process : constant MAT.Targets.Target_Process_Type_Access := Target.Process; Addr : MAT.Types.Target_Addr; Maps : MAT.Memory.Region_Info_Map; Region : MAT.Memory.Region_Info; begin if Args'Length >= 3 and then Args (Args'First .. Args'First + 1) = "0x" then Addr := MAT.Types.Hex_Value (Args (Args'First + 2 .. Args'Last)); else Addr := MAT.Types.Hex_Value (Args); end if; -- Find out the memory regions for that address. MAT.Memory.Targets.Find (Memory => Process.Memory, From => Addr, To => Addr, Into => Maps); if Maps.Is_Empty then Console.Error ("Address '" & Args & "' is not in any memory region."); else -- Print the memory region. Print_Regions (Target.Console, Maps); Region := Maps.First_Element; end if; -- If this is an executable region, find the symbol and print it. if (Region.Flags and ELF.PF_X) /= 0 then declare Symbol : MAT.Symbols.Targets.Symbol_Info; begin MAT.Symbols.Targets.Find_Nearest_Line (Symbols => Process.Symbols.Value, Addr => Addr, Symbol => Symbol); if Ada.Strings.Unbounded.Length (Symbol.File) /= 0 then Console.Notice (MAT.Consoles.N_INFO, MAT.Formats.Location (Symbol.File, Symbol.Line, Symbol.Name)); end if; end; else declare Filter : MAT.Expressions.Expression_Type; Start, Finish : MAT.Types.Target_Tick_Ref; Events : MAT.Events.Tools.Target_Event_Vector; Slots : MAT.Memory.Allocation_Map; begin Filter := MAT.Expressions.Create_Addr (Addr, Addr); Process.Events.Get_Time_Range (Start, Finish); MAT.Events.Timelines.Filter_Events (Process.Events.all, Filter, Events); if Events.Is_Empty then Console.Error ("No event references address " & Args); else Print_Events (Console, Events, Start); end if; Process.Memory.Find (From => Addr, To => Addr, Filter => Filter, Into => Slots); if Slots.Is_Empty then Console.Notice (Consoles.N_INFO, "Address " & Args & " does not match any allocated memory slot"); else Console.Clear_Fields; Print_Slot (Console, Slots.First_Key, Slots.First_Element, Process.Symbols, Start); end if; end; end if; exception when Constraint_Error => Console.Error ("Invalid address '" & Args & "'"); end Addr_Command; -- ------------------------------ -- Maps command to dump the memory maps of the program. -- ------------------------------ procedure Maps_Command (Target : in out MAT.Targets.Target_Type'Class; Args : in String) is pragma Unreferenced (Args); Process : constant MAT.Targets.Target_Process_Type_Access := Target.Process; Maps : MAT.Memory.Region_Info_Map; begin MAT.Memory.Targets.Find (Memory => Process.Memory, From => MAT.Types.Target_Addr'First, To => MAT.Types.Target_Addr'Last, Into => Maps); Print_Regions (Target.Console, Maps); end Maps_Command; -- ------------------------------ -- Info command to print symmary information about the program. -- ------------------------------ procedure Info_Command (Target : in out MAT.Targets.Target_Type'Class; Args : in String) is pragma Unreferenced (Args); use type MAT.Targets.Target_Process_Type_Access; use type MAT.Types.Target_Tick_Ref; use Ada.Strings.Unbounded; Console : constant MAT.Consoles.Console_Access := Target.Console; Process : constant MAT.Targets.Target_Process_Type_Access := Target.Process; Start : MAT.Events.Target_Event_Type; Finish : MAT.Events.Target_Event_Type; Maps : MAT.Memory.Region_Info_Map; Stats : MAT.Memory.Targets.Memory_Stat; begin if Process = null then Console.Notice (Consoles.N_EVENT_ID, "There is no process"); return; end if; Process.Memory.Stat_Information (Stats); Process.Events.Get_Limits (Start, Finish); -- Print number of memory regions. MAT.Memory.Targets.Find (Memory => Process.Memory, From => MAT.Types.Target_Addr'First, To => MAT.Types.Target_Addr'Last, Into => Maps); Console.Notice (Consoles.N_INFO, "Pid : " & MAT.Formats.Pid (Process.Pid)); Console.Notice (Consoles.N_INFO, "Path : " & To_String (Process.Path)); Console.Notice (Consoles.N_INFO, "Endianness : " & MAT.Readers.Endian_Type'Image (Process.Endian)); Console.Notice (Consoles.N_INFO, "Memory regions : " & Util.Strings.Image (Natural (Maps.Length))); Console.Notice (Consoles.N_INFO, "Events : " & MAT.Formats.Event (Start, Finish)); Console.Notice (Consoles.N_INFO, "Duration : " & MAT.Formats.Duration (Finish.Time - Start.Time)); Console.Notice (Consoles.N_INFO, "Stack frames : " & Natural'Image (Process.Frames.Get_Frame_Count)); Console.Notice (Consoles.N_INFO, "Malloc count : " & Natural'Image (Stats.Malloc_Count)); Console.Notice (Consoles.N_INFO, "Realloc count : " & Natural'Image (Stats.Realloc_Count)); Console.Notice (Consoles.N_INFO, "Free count : " & Natural'Image (Stats.Free_Count)); Console.Notice (Consoles.N_INFO, "Memory allocated : " & MAT.Formats.Size (Stats.Total_Alloc)); Console.Notice (Consoles.N_INFO, "Memory slots : " & Natural'Image (Stats.Used_Count)); end Info_Command; -- ------------------------------ -- Symbol command. -- Load the symbols from the binary file. -- ------------------------------ procedure Symbol_Command (Target : in out MAT.Targets.Target_Type'Class; Args : in String) is Process : constant MAT.Targets.Target_Process_Type_Access := Target.Process; Console : constant MAT.Consoles.Console_Access := Target.Console; Maps : MAT.Memory.Region_Info_Map; begin MAT.Memory.Targets.Find (Memory => Process.Memory, From => MAT.Types.Target_Addr'First, To => MAT.Types.Target_Addr'Last, Into => Maps); MAT.Symbols.Targets.Load_Symbols (Process.Symbols.Value, Maps); MAT.Symbols.Targets.Open (Process.Symbols.Value, Args); exception when Bfd.OPEN_ERROR => Console.Error ("Cannot open symbol file '" & Args & "'"); end Symbol_Command; -- ------------------------------ -- Set command. -- ------------------------------ procedure Set_Command (Target : in out MAT.Targets.Target_Type'Class; Args : in String) is use Ada.Strings; Process : constant MAT.Targets.Target_Process_Type_Access := Target.Process; Console : constant MAT.Consoles.Console_Access := Target.Console; Trimmed_Args : constant String := Fixed.Trim (Args, Both); Pos : constant Natural := Util.Strings.Index (Trimmed_Args, ' '); begin if Pos = 0 then Console.Error ("Usage: set <name> <value>"); return; end if; declare Name : constant String := Trimmed_Args (Trimmed_Args'First .. Pos - 1); Value : constant String := Trimmed_Args (Pos + 1 .. Trimmed_Args'Last); begin if Name = "demangle" then Process.Symbols.Value.Use_Demangle := Value = "on"; return; end if; if Name = "colors" then Target.Color_Mode (Value = "on"); return; end if; end; end Set_Command; -- ------------------------------ -- Exit command. -- ------------------------------ procedure Exit_Command (Target : in out MAT.Targets.Target_Type'Class; Args : in String) is begin raise Stop_Interp; end Exit_Command; -- ------------------------------ -- Open a MAT file and read the events. -- ------------------------------ procedure Open_Command (Target : in out MAT.Targets.Target_Type'Class; Args : in String) is use type MAT.Types.Target_Tick_Ref; Reader : MAT.Readers.Streams.Files.File_Reader_Type; Start, Finish : MAT.Types.Target_Tick_Ref; Duration : MAT.Types.Target_Tick_Ref; Count : Integer; begin Target.Initialize (Reader); Reader.Open (Args); Reader.Read_All; Target.Process.Events.Get_Time_Range (Start, Finish); Count := Target.Process.Events.Get_Event_Counter; Duration := Finish - Start; Target.Console.Notice (MAT.Consoles.N_DURATION, "Loaded" & Integer'Image (Count) & " events, duration " & MAT.Formats.Duration (Duration)); exception when E : Ada.IO_Exceptions.Name_Error => Log.Error ("Cannot open {0}: {1}", Args, Ada.Exceptions.Exception_Message (E)); when E : others => Log.Error ("Invalid format for " & Args, E, True); end Open_Command; -- ------------------------------ -- Print some help for available commands. -- ------------------------------ procedure Help_Command (Target : in out MAT.Targets.Target_Type'Class; Args : in String) is pragma Unreferenced (Args); use MAT.Consoles; Console : constant MAT.Consoles.Console_Access := Target.Console; begin Console.Notice (N_HELP, "Available commands"); Console.Notice (N_HELP, "exit Exit the tool"); Console.Notice (N_HELP, "addr <address> Give information about an address"); Console.Notice (N_HELP, "event <id> Print the event ID"); Console.Notice (N_HELP, "events [-c] [-l] <selection> List the events filtered by the selection"); Console.Notice (N_HELP, "threads List the threads"); Console.Notice (N_HELP, "slots [-c] [-l] <selection> List the memory slots" & " filtered by the selection"); Console.Notice (N_HELP, "sizes [-c] [-l] <selection> Print a summary of sizes " & "filtered by the selection"); Console.Notice (N_HELP, "frames <level> [-c] [-l] [<filter>] Print the stack frames up" & " to the given level"); Console.Notice (N_HELP, "open <file> Load the mat file to analyze"); Console.Notice (N_HELP, "symbol <file> Load the executable symbol file"); Console.Notice (N_HELP, "info Print some information about the program"); Console.Notice (N_HELP, "maps Print the program memory maps"); Console.Notice (N_HELP, "set option {on|off} Set the option 'demangle' or 'colors'"); Console.Notice (N_HELP, "timeline <duration> Analyze and report groups of allocations in timeline"); Console.Notice (N_HELP, "Selection examples:"); Console.Notice (N_HELP, " size > 100 and size < 1000 " & "Selection on the allocation size"); Console.Notice (N_HELP, " after 1.0 " & "Report only events after the relative time"); Console.Notice (N_HELP, " before 0.01 " & "Report only events before the relative time"); Console.Notice (N_HELP, " from 0.01 to 0.06 " & "Report only events between the relative times"); Console.Notice (N_HELP, " has 0x4a7281 " & "Allocations with the given address"); Console.Notice (N_HELP, " event >= 200 and event <= 300 " & "Event range selection"); Console.Notice (N_HELP, " malloc or realloc " & "Malloc or realloc events"); Console.Notice (N_HELP, " by printf and not by foo " & "Event produced by a function"); Console.Notice (N_HELP, " in libz.so.1 " & "Event produced by a shared library"); end Help_Command; function Get_Command (Line : in String) return String is Pos : constant Natural := Util.Strings.Index (Line, ' '); begin if Pos = 0 then return Line; else return Line (Line'First .. Pos - 1); end if; end Get_Command; -- ------------------------------ -- Execute the command given in the line. -- ------------------------------ procedure Execute (Target : in out MAT.Targets.Target_Type'Class; Line : in String) is Command : constant String := Get_Command (Line); Index : Natural := Util.Strings.Index (Line, ' '); Pos : constant Command_Map.Cursor := Commands.Find (Command); begin Log.Info ("Execute '{0}'", Line); Target.Console.Set_Color (Target.Color_Mode); if Command_Map.Has_Element (Pos) then if Index = 0 then Index := Line'Last + 1; end if; Target.Console.Clear_Fields; Command_Map.Element (Pos) (Target, Line (Index + 1 .. Line'Last)); elsif Command'Length > 0 then Target.Console.Error ("Command '" & Command & "' not found. Type 'help' for available commands"); end if; exception when Stop_Interp => raise; when Stop_Command => Target.Console.Error ("Command was stopped!"); when Usage_Error => Target.Console.Error ("Invalid argument '" & Line (Index + 1 .. Line'Last) & "' for command " & Command); when E : Filter_Error => Target.Console.Error ("Invalid filter '" & Ada.Exceptions.Exception_Message (E) & "'"); when E : others => Log.Error ("Exception: ", E, True); Target.Console.Error ("Exception while processing command"); end Execute; -- ------------------------------ -- Initialize the process targets by loading the MAT files. -- ------------------------------ procedure Initialize_Files (Target : in out MAT.Targets.Target_Type'Class) is begin loop declare Path : constant String := GNAT.Command_Line.Get_Argument; begin exit when Path'Length = 0; Open_Command (Target, Path); end; end loop; end Initialize_Files; begin Commands.Insert ("exit", Exit_Command'Access); Commands.Insert ("quit", Exit_Command'Access); Commands.Insert ("open", Open_Command'Access); Commands.Insert ("malloc-sizes", Sizes_Command'Access); Commands.Insert ("symbol", Symbol_Command'Access); Commands.Insert ("slots", Slot_Command'Access); Commands.Insert ("threads", Threads_Command'Access); Commands.Insert ("malloc-frames", Frames_Command'Access); Commands.Insert ("events", Events_Command'Access); Commands.Insert ("event", Event_Command'Access); Commands.Insert ("sizes", Event_Sizes_Command'Access); Commands.Insert ("frames", Event_Frames_Command'Access); Commands.Insert ("timeline", Timeline_Command'Access); Commands.Insert ("help", Help_Command'Access); Commands.Insert ("maps", Maps_Command'Access); Commands.Insert ("info", Info_Command'Access); Commands.Insert ("addr", Addr_Command'Access); Commands.Insert ("set", Set_Command'Access); end MAT.Commands;
reznikmm/matreshka
Ada
4,860
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_Alphabetical_Index_Mark_Elements; package Matreshka.ODF_Text.Alphabetical_Index_Mark_Elements is type Text_Alphabetical_Index_Mark_Element_Node is new Matreshka.ODF_Text.Abstract_Text_Element_Node and ODF.DOM.Text_Alphabetical_Index_Mark_Elements.ODF_Text_Alphabetical_Index_Mark with null record; overriding function Create (Parameters : not null access Matreshka.DOM_Elements.Element_L2_Parameters) return Text_Alphabetical_Index_Mark_Element_Node; overriding function Get_Local_Name (Self : not null access constant Text_Alphabetical_Index_Mark_Element_Node) return League.Strings.Universal_String; overriding procedure Enter_Node (Self : not null access Text_Alphabetical_Index_Mark_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_Alphabetical_Index_Mark_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_Alphabetical_Index_Mark_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.Alphabetical_Index_Mark_Elements;