repo_name
stringlengths
9
74
language
stringclasses
1 value
length_bytes
int64
11
9.34M
extension
stringclasses
2 values
content
stringlengths
11
9.34M
zhmu/ananas
Ada
264
ads
package Range_Check3_Pkg is type Array_Type is array (Positive range <>) of Integer; type Array_Access is access Array_Type; function One return Positive; function Zero return Natural; function Allocate return Array_Access; end Range_Check3_Pkg;
MinimSecure/unum-sdk
Ada
916
ads
-- Copyright 2014-2016 Free Software Foundation, Inc. -- -- This program is free software; you can redistribute it and/or modify -- it under the terms of the GNU General Public License as published by -- the Free Software Foundation; either version 3 of the License, or -- (at your option) any later version. -- -- This program is distributed in the hope that it will be useful, -- but WITHOUT ANY WARRANTY; without even the implied warranty of -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -- GNU General Public License for more details. -- -- You should have received a copy of the GNU General Public License -- along with this program. If not, see <http://www.gnu.org/licenses/>. with System; package Pck is type Bounded is array (Integer range <>) of Integer; function New_Bounded (Low, High : Integer) return Bounded; procedure Do_Nothing (A : System.Address); end Pck;
micahwelf/FLTK-Ada
Ada
5,537
adb
with Interfaces.C.Strings, System; use type System.Address; package body FLTK.Widgets.Valuators.Sliders.Scrollbars is procedure scrollbar_set_draw_hook (W, D : in System.Address); pragma Import (C, scrollbar_set_draw_hook, "scrollbar_set_draw_hook"); pragma Inline (scrollbar_set_draw_hook); procedure scrollbar_set_handle_hook (W, H : in System.Address); pragma Import (C, scrollbar_set_handle_hook, "scrollbar_set_handle_hook"); pragma Inline (scrollbar_set_handle_hook); function new_fl_scrollbar (X, Y, W, H : in Interfaces.C.int; Text : in Interfaces.C.char_array) return System.Address; pragma Import (C, new_fl_scrollbar, "new_fl_scrollbar"); pragma Inline (new_fl_scrollbar); procedure free_fl_scrollbar (D : in System.Address); pragma Import (C, free_fl_scrollbar, "free_fl_scrollbar"); pragma Inline (free_fl_scrollbar); function fl_scrollbar_get_linesize (S : in System.Address) return Interfaces.C.int; pragma Import (C, fl_scrollbar_get_linesize, "fl_scrollbar_get_linesize"); pragma Inline (fl_scrollbar_get_linesize); procedure fl_scrollbar_set_linesize (S : in System.Address; T : in Interfaces.C.int); pragma Import (C, fl_scrollbar_set_linesize, "fl_scrollbar_set_linesize"); pragma Inline (fl_scrollbar_set_linesize); function fl_scrollbar_get_value (S : in System.Address) return Interfaces.C.int; pragma Import (C, fl_scrollbar_get_value, "fl_scrollbar_get_value"); pragma Inline (fl_scrollbar_get_value); procedure fl_scrollbar_set_value (S : in System.Address; T : in Interfaces.C.int); pragma Import (C, fl_scrollbar_set_value, "fl_scrollbar_set_value"); pragma Inline (fl_scrollbar_set_value); procedure fl_scrollbar_set_value2 (S : in System.Address; P, W, F, T : in Interfaces.C.int); pragma Import (C, fl_scrollbar_set_value2, "fl_scrollbar_set_value2"); pragma Inline (fl_scrollbar_set_value2); procedure fl_scrollbar_draw (W : in System.Address); pragma Import (C, fl_scrollbar_draw, "fl_scrollbar_draw"); pragma Inline (fl_scrollbar_draw); function fl_scrollbar_handle (W : in System.Address; E : in Interfaces.C.int) return Interfaces.C.int; pragma Import (C, fl_scrollbar_handle, "fl_scrollbar_handle"); pragma Inline (fl_scrollbar_handle); procedure Finalize (This : in out Scrollbar) is begin if This.Void_Ptr /= System.Null_Address and then This in Scrollbar'Class then free_fl_scrollbar (This.Void_Ptr); This.Void_Ptr := System.Null_Address; end if; Finalize (Slider (This)); end Finalize; package body Forge is function Create (X, Y, W, H : in Integer; Text : in String) return Scrollbar is begin return This : Scrollbar do This.Void_Ptr := new_fl_scrollbar (Interfaces.C.int (X), Interfaces.C.int (Y), Interfaces.C.int (W), Interfaces.C.int (H), Interfaces.C.To_C (Text)); fl_widget_set_user_data (This.Void_Ptr, Widget_Convert.To_Address (This'Unchecked_Access)); scrollbar_set_draw_hook (This.Void_Ptr, Draw_Hook'Address); scrollbar_set_handle_hook (This.Void_Ptr, Handle_Hook'Address); end return; end Create; end Forge; function Get_Line_Size (This : in Scrollbar) return Natural is begin return Natural (fl_scrollbar_get_linesize (This.Void_Ptr)); end Get_Line_Size; procedure Set_Line_Size (This : in out Scrollbar; To : in Natural) is begin fl_scrollbar_set_linesize (This.Void_Ptr, Interfaces.C.int (To)); end Set_Line_Size; function Get_Position (This : in Scrollbar) return Natural is begin return Natural (fl_scrollbar_get_value (This.Void_Ptr)); end Get_Position; procedure Set_Position (This : in out Scrollbar; To : in Natural) is begin fl_scrollbar_set_value (This.Void_Ptr, Interfaces.C.int (To)); end Set_Position; procedure Set_All (This : in out Scrollbar; Position : in Natural; Win_Size : in Natural; First_Line : in Natural; Total_Lines : in Natural) is begin fl_scrollbar_set_value2 (This.Void_Ptr, Interfaces.C.int (Position), Interfaces.C.int (Win_Size), Interfaces.C.int (First_Line), Interfaces.C.int (Total_Lines)); end Set_All; procedure Draw (This : in out Scrollbar) is begin fl_scrollbar_draw (This.Void_Ptr); end Draw; function Handle (This : in out Scrollbar; Event : in Event_Kind) return Event_Outcome is begin return Event_Outcome'Val (fl_scrollbar_handle (This.Void_Ptr, Event_Kind'Pos (Event))); end Handle; end FLTK.Widgets.Valuators.Sliders.Scrollbars;
AdaCore/langkit
Ada
2,946
ads
-- -- Copyright (C) 2014-2022, AdaCore -- SPDX-License-Identifier: Apache-2.0 -- private with Ada.Containers.Hashed_Maps; private with Ada.Strings.Unbounded.Hash; -- This package provides a generic map type, mapping keys of type -- Langkit_Support.Names.Name to any value (see Element_Type below). generic type Element_Type is private; package Langkit_Support.Names.Maps is type Map (Casing : Casing_Convention := Camel_With_Underscores) is tagged limited private; type Lookup_Result (Present : Boolean := False) is record case Present is when False => null; when True => Element : Element_Type; end case; end record; Absent_Lookup_Result : constant Lookup_Result := (Present => False); function Create_Name_Map (Casing : Casing_Convention) return Map; -- Create an empty mapping from names using the given convention to -- ``Element_Type`` values. procedure Insert (Self : in out Map; Name : Name_Type; Element : Element_Type); -- Insert the ``Name``/``Element`` association into ``Self``. -- -- Raise a ``Constraint_Error`` if there is already an entry for ``Name``. procedure Include (Self : in out Map; Name : Name_Type; Element : Element_Type); -- Insert the ``Name``/``Element`` association into ``Self``. -- -- If there is already an entry for ``Name``, just replace its element with -- ``Element``. function Lookup (Self : Map; Name : Name_Type) return Lookup_Result; -- Look for the association corresponding to ``Name`` in ``Self``. If there -- is one, return the corresponding element, otherwise return -- ``Absent_Lookup_Result``. function Get (Self : Map; Name : Name_Type) return Element_Type; -- Like ``Lookup``, but return the element directly instead. Raise a -- ``Constraint_Error`` if there is no association. -- The following overloads take string names instead of ``Name_Type`` -- values: they work similarly to the overloads accepting ``Name_Type`` -- values, except that they first try to decode the string into a name -- according to the map convention, raising an ``Invalid_Name_Error`` if -- the name is invalid according to the casing convention. procedure Insert (Self : in out Map; Name : Text_Type; Element : Element_Type); procedure Include (Self : in out Map; Name : Text_Type; Element : Element_Type); function Lookup (Self : Map; Name : Text_Type) return Lookup_Result; function Get (Self : Map; Name : Text_Type) return Element_Type; private package Helper_Maps is new Ada.Containers.Hashed_Maps (Key_Type => Unbounded_String, Element_Type => Element_Type, Hash => Hash, Equivalent_Keys => "="); type Map (Casing : Casing_Convention := Camel_With_Underscores) is tagged limited record Map : Helper_Maps.Map; end record; end Langkit_Support.Names.Maps;
Fabien-Chouteau/shoot-n-loot
Ada
4,161
adb
-- Shoot'n'loot -- Copyright (c) 2020 Fabien Chouteau with Game_Assets.Tileset; with Game_Assets.Tileset_Collisions; with Game_Assets.Misc_Objects; with GESTE_Config; use GESTE_Config; with GESTE.Tile_Bank; with GESTE.Sprite.Animated; with Sound; package body Monsters is package Item renames Game_Assets.Misc_Objects.Item; Tile_Bank : aliased GESTE.Tile_Bank.Instance (Game_Assets.Tileset.Tiles'Access, Game_Assets.Tileset_Collisions.Tiles'Access, Game_Assets.Palette'Access); Empty_Tile : constant GESTE_Config.Tile_Index := Item.Empty_Tile.Tile_Id; type Monster_Rec is record Sprite : aliased GESTE.Sprite.Animated.Instance (Tile_Bank'Access, GESTE_Config.No_Tile); Origin : GESTE.Pix_Point; Pos : GESTE.Pix_Point; Alive : Boolean := False; Going_Right : Boolean := True; Offset : Natural := 0; end record; Monster_Array : array (1 .. Max_Nbr_Of_Monsters) of Monster_Rec; Last_Monster : Natural := 0; Nbr_Killed : Natural := 0; Anim_Step_Duration : constant := 10; Monster_Animation : aliased constant GESTE.Sprite.Animated.Animation_Array := ((Item.M1.Tile_Id, Anim_Step_Duration), (Item.M2.Tile_Id, Anim_Step_Duration), (Item.M3.Tile_Id, Anim_Step_Duration), (Item.M4.Tile_Id, Anim_Step_Duration), (Item.M5.Tile_Id, Anim_Step_Duration), (Item.M6.Tile_Id, Anim_Step_Duration), (Item.M7.Tile_Id, Anim_Step_Duration)); ---------- -- Init -- ---------- procedure Init (Objects : Object_Array) is begin Last_Monster := 0; Nbr_Killed := 0; for Monster of Objects loop Last_Monster := Last_Monster + 1; declare M : Monster_Rec renames Monster_Array (Last_Monster); begin M.Sprite.Set_Animation (Monster_Animation'Access, Looping => True); M.Alive := True; M.Origin := (Integer (Monster.X), Integer (Monster.Y) - 8); M.Pos := M.Origin; M.Sprite.Move (M.Origin); GESTE.Add (M.Sprite'Access, 2); end; end loop; end Init; --------------- -- Check_Hit -- --------------- function Check_Hit (Pt : GESTE.Pix_Point; Lethal : Boolean) return Boolean is begin for M of Monster_Array (Monster_Array'First .. Last_Monster) loop if M.Alive and then Pt.X in M.Pos.X .. M.Pos.X + Tile_Size and then Pt.Y in M.Pos.Y .. M.Pos.Y + Tile_Size then if Lethal then -- Replace the monster by an empty tile to erase it from the -- screen. M.Sprite.Set_Animation (GESTE.Sprite.Animated.No_Animation, Looping => False); M.Sprite.Set_Tile (Empty_Tile); M.Alive := False; Nbr_Killed := Nbr_Killed + 1; Sound.Play_Monster_Dead; end if; return True; end if; end loop; return False; end Check_Hit; ---------------- -- All_Killed -- ---------------- function All_Killed return Boolean is (Nbr_Killed = Last_Monster); ------------ -- Update -- ------------ procedure Update is begin for M of Monster_Array (Monster_Array'First .. Last_Monster) loop if M.Alive then M.Sprite.Signal_Frame; M.Pos := (M.Origin.X + M.Offset / 5, M.Origin.Y); M.Sprite.Move (M.Pos); if M.Going_Right then if M.Offset >= GESTE_Config.Tile_Size * 2 * 5 then M.Going_Right := False; else M.Offset := M.Offset + 1; end if; else if M.Offset = 0 then M.Going_Right := True; else M.Offset := M.Offset - 1; end if; end if; end if; end loop; end Update; end Monsters;
stcarrez/ada-awa
Ada
2,774
ads
----------------------------------------------------------------------- -- awa-events-configs -- Event configuration -- Copyright (C) 2012, 2013, 2017, 2018 Stephane Carrez -- Written by Stephane Carrez ([email protected]) -- -- Licensed under the Apache License, Version 2.0 (the "License"); -- you may not use this file except in compliance with the License. -- You may obtain a copy of the License at -- -- http://www.apache.org/licenses/LICENSE-2.0 -- -- Unless required by applicable law or agreed to in writing, software -- distributed under the License is distributed on an "AS IS" BASIS, -- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -- See the License for the specific language governing permissions and -- limitations under the License. ----------------------------------------------------------------------- with Ada.Strings.Unbounded; with Util.Beans.Objects; with Util.Serialize.Mappers; with EL.Expressions; with EL.Beans; with EL.Contexts; with ADO.Sessions; with AWA.Events.Queues; with AWA.Events.Services; package AWA.Events.Configs is -- ------------------------------ -- Event Config Controller -- ------------------------------ type Controller_Config is record Name : Util.Beans.Objects.Object; Queue : AWA.Events.Queues.Queue_Ref; Queue_Type : Util.Beans.Objects.Object; Prop_Name : Util.Beans.Objects.Object; Params : EL.Beans.Param_Vectors.Vector; Priority : Integer; Count : Integer; Manager : AWA.Events.Services.Event_Manager_Access; Action : EL.Expressions.Method_Expression; Properties : EL.Beans.Param_Vectors.Vector; Context : EL.Contexts.ELContext_Access; Session : ADO.Sessions.Session; Match : Ada.Strings.Unbounded.Unbounded_String; end record; type Controller_Config_Access is access all Controller_Config; type Config_Fields is (FIELD_ON_EVENT, FIELD_NAME, FIELD_QUEUE_NAME, FIELD_ACTION, FIELD_PROPERTY_NAME, FIELD_QUEUE, FIELD_TYPE, FIELD_PROPERTY_VALUE, FIELD_DISPATCHER, FIELD_DISPATCHER_QUEUE, FIELD_DISPATCHER_PRIORITY, FIELD_DISPATCHER_COUNT); -- Set the configuration value identified by <b>Value</b> after having parsed -- the element identified by <b>Field</b>. procedure Set_Member (Into : in out Controller_Config; Field : in Config_Fields; Value : in Util.Beans.Objects.Object); private procedure Add_Mapping (Mapper : in out Util.Serialize.Mappers.Processing; Config : in Controller_Config_Access); end AWA.Events.Configs;
twdroeger/ada-awa
Ada
2,105
ads
----------------------------------------------------------------------- -- awa-blogs-servlets -- Serve files saved in the storage service -- Copyright (C) 2017, 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 Ada.Strings.Unbounded; with Ada.Calendar; with ADO; with ASF.Requests; with AWA.Storages.Servlets; package AWA.Blogs.Servlets is -- The <b>Storage_Servlet</b> represents the component that will handle -- an HTTP request received by the server. type Image_Servlet is new AWA.Storages.Servlets.Storage_Servlet with private; -- Load the data content that correspond to the GET request and get the name as well -- as mime-type and date. procedure Load (Server : in Image_Servlet; Request : in out ASF.Requests.Request'Class; Name : out Ada.Strings.Unbounded.Unbounded_String; Mime : out Ada.Strings.Unbounded.Unbounded_String; Date : out Ada.Calendar.Time; Data : out ADO.Blob_Ref); -- Get the expected return mode (content disposition for download or inline). overriding function Get_Format (Server : in Image_Servlet; Request : in ASF.Requests.Request'Class) return AWA.Storages.Servlets.Get_Type; private type Image_Servlet is new AWA.Storages.Servlets.Storage_Servlet with null record; end AWA.Blogs.Servlets;
BrickBot/Bound-T-H8-300
Ada
3,331
ads
-- Options.May_Modular_Integer (decl) -- -- Options with modular integer values that may be undefined (unset) -- or defined (set), -- -- A component of the Bound-T Worst-Case Execution Time Tool. -- ------------------------------------------------------------------------------- -- Copyright (c) 1999 .. 2015 Tidorum Ltd -- All rights reserved. -- -- Redistribution and use in source and binary forms, with or without -- modification, are permitted provided that the following conditions are met: -- -- 1. Redistributions of source code must retain the above copyright notice, this -- list of conditions and the following disclaimer. -- 2. Redistributions in binary form must reproduce the above copyright notice, -- this list of conditions and the following disclaimer in the documentation -- and/or other materials provided with the distribution. -- -- This software is provided by the copyright holders and contributors "as is" and -- any express or implied warranties, including, but not limited to, the implied -- warranties of merchantability and fitness for a particular purpose are -- disclaimed. In no event shall the copyright owner or contributors be liable for -- any direct, indirect, incidental, special, exemplary, or consequential damages -- (including, but not limited to, procurement of substitute goods or services; -- loss of use, data, or profits; or business interruption) however caused and -- on any theory of liability, whether in contract, strict liability, or tort -- (including negligence or otherwise) arising in any way out of the use of this -- software, even if advised of the possibility of such damage. -- -- Other modules (files) of this software composition should contain their -- own copyright statements, which may have different copyright and usage -- conditions. The above conditions apply to this file. ------------------------------------------------------------------------------- -- -- $Revision: 1.2 $ -- $Date: 2015/10/24 19:36:51 $ -- -- $Log: options-may_modular_integer.ads,v $ -- Revision 1.2 2015/10/24 19:36:51 niklas -- Moved to free licence. -- -- Revision 1.1 2014/06/01 10:36:39 niklas -- First version. -- with Options; generic type Value_Type is mod <>; Base : in Options.Number_Base_T := 10; package Options.May_Modular_Integer is package Number_Valued is new Modular_Valued (Value_Type, Base); -- -- Options with (defined) values of Value_Type. type Option_T is new Number_Valued.Option_T (Default => Value_Type'First) with record Set : Boolean := False; end record; -- -- An option that initially has no value, but can be Set -- to some value of Value_Type. (There is a Default component, -- but it is not used.) -- -- Options of this kind are not enumerable. overriding function Type_And_Default (Option : access Option_T) return String; overriding procedure Reset (Option : access Option_T); -- -- Option.Set := False. overriding procedure Set ( Option : access Option_T; Value : in String); -- -- Option.Set := True; Option.Value := Value. function Set (Value : Value_Type) return Option_T; -- -- Constructs an option that is Set to the given Value, -- which is also the Default value. end Options.May_Modular_Integer;
OneWingedShark/Risi
Ada
868
ads
Pragma Ada_2012; Pragma Wide_Character_Encoding( UTF8 ); with Risi_Script.Types.Identifier.Scope_Package; Package Risi_Script.Types.Identifier.Scope is use Risi_Script.Types.Identifier.Scope_Package; Type Scope is new Vector with null record; Function "+"( Right : Scope ) Return Vector; Function "+"( Right : Vector ) Return Scope; Function Image( Input : Scope ) return String; Function Value( Input : String ) return Scope with Pre => Input(Input'First) /= '.' and Input(Input'Last) /= '.'; ----------------- -- Constants -- ----------------- Global : Constant Scope; Private Function "+"( Right : Scope ) Return Vector is ( Vector(Right) ); Function "+"( Right : Vector ) Return Scope is ( Right with null record ); Global : Constant Scope:= +Empty_Vector; End Risi_Script.Types.Identifier.Scope;
AdaCore/libadalang
Ada
67
adb
with Bar; procedure Foo is begin pragma Test (Bar.I); end Foo;
stcarrez/ada-awa
Ada
6,226
ads
----------------------------------------------------------------------- -- awa-permissions-services -- Permissions controller -- Copyright (C) 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. ----------------------------------------------------------------------- with Util.Beans.Objects; with EL.Functions; with ADO; with ADO.Sessions; with ADO.Objects; with Security.Policies; with Security.Contexts; with Security.Policies.Roles; with AWA.Applications; with AWA.Services.Contexts; package AWA.Permissions.Services is package ASC renames AWA.Services.Contexts; -- Register the security EL functions in the EL mapper. procedure Set_Functions (Mapper : in out EL.Functions.Function_Mapper'Class); type Permission_Manager is new Security.Policies.Policy_Manager with private; type Permission_Manager_Access is access all Permission_Manager'Class; -- Get the permission manager associated with the security context. -- Returns null if there is none. function Get_Permission_Manager (Context : in Security.Contexts.Security_Context'Class) return Permission_Manager_Access; -- Get the permission manager associated with the security context. -- Returns null if there is none. function Get_Permission_Manager (Context : in ASC.Service_Context_Access) return Permission_Manager_Access; -- Get the application instance. function Get_Application (Manager : in Permission_Manager) return AWA.Applications.Application_Access; -- Set the application instance. procedure Set_Application (Manager : in out Permission_Manager; App : in AWA.Applications.Application_Access); -- Initialize the permissions. procedure Start (Manager : in out Permission_Manager); -- Add a permission for the current user to access the entity identified by -- <b>Entity</b> and <b>Kind</b> in the <b>Workspace</b>. procedure Add_Permission (Manager : in Permission_Manager; Entity : in ADO.Identifier; Kind : in ADO.Entity_Type; Workspace : in ADO.Identifier; Permission : in Security.Permissions.Permission_Index); -- Check that the current user has the specified permission. -- Raise NO_PERMISSION exception if the user does not have the permission. procedure Check_Permission (Manager : in Permission_Manager; Entity : in ADO.Identifier; Kind : in ADO.Entity_Type; Permission : in Permission_Type); -- Get the role names that grant the given permission. function Get_Role_Names (Manager : in Permission_Manager; Permission : in Security.Permissions.Permission_Index) return Security.Policies.Roles.Role_Name_Array; -- Add a permission for the user <b>User</b> to access the entity identified by -- <b>Entity</b> which is of type <b>Kind</b>. procedure Add_Permission (Manager : in Permission_Manager; Session : in out ADO.Sessions.Master_Session; User : in ADO.Identifier; Entity : in ADO.Identifier; Kind : in ADO.Entity_Type; Workspace : in ADO.Identifier; Permission : in Security.Permissions.Permission_Index); -- Add a permission for the user <b>User</b> to access the entity identified by -- <b>Entity</b>. procedure Add_Permission (Manager : in Permission_Manager; Session : in out ADO.Sessions.Master_Session; User : in ADO.Identifier; Entity : in ADO.Objects.Object_Ref'Class; Workspace : in ADO.Identifier; Permission : in Security.Permissions.Permission_Index); -- Create a permission manager for the given application. function Create_Permission_Manager (App : in AWA.Applications.Application_Access) return Security.Policies.Policy_Manager_Access; -- Check if the permission with the name <tt>Name</tt> is granted for the current user. -- If the <tt>Entity</tt> is defined, an <tt>Entity_Permission</tt> is created and verified. -- Returns True if the user is granted the given permission. function Has_Permission (Name : in Util.Beans.Objects.Object; Entity : in Util.Beans.Objects.Object) return Util.Beans.Objects.Object; -- Delete all the permissions for a user and on the given workspace. procedure Delete_Permissions (Session : in out ADO.Sessions.Master_Session; User : in ADO.Identifier; Workspace : in ADO.Identifier); private type Permission_Array is array (Security.Permissions.Permission_Index) of ADO.Identifier; type Permission_Manager is new Security.Policies.Policy_Manager with record App : AWA.Applications.Application_Access; Roles : Security.Policies.Roles.Role_Policy_Access; -- Mapping between the application permission index and the database permission identifier. Map : Permission_Array := (others => 0); end record; end AWA.Permissions.Services;
reznikmm/matreshka
Ada
4,279
adb
------------------------------------------------------------------------------ -- -- -- Matreshka Project -- -- -- -- Open Document Toolkit -- -- -- -- Runtime Library Component -- -- -- ------------------------------------------------------------------------------ -- -- -- Copyright © 2013, Vadim Godunko <[email protected]> -- -- All rights reserved. -- -- -- -- Redistribution and use in source and binary forms, with or without -- -- modification, are permitted provided that the following conditions -- -- are met: -- -- -- -- * Redistributions of source code must retain the above copyright -- -- notice, this list of conditions and the following disclaimer. -- -- -- -- * Redistributions in binary form must reproduce the above copyright -- -- notice, this list of conditions and the following disclaimer in the -- -- documentation and/or other materials provided with the distribution. -- -- -- -- * Neither the name of the Vadim Godunko, IE nor the names of its -- -- contributors may be used to endorse or promote products derived from -- -- this software without specific prior written permission. -- -- -- -- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -- -- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -- -- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -- -- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -- -- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -- -- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED -- -- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -- -- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -- -- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -- -- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -- -- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- -- -- ------------------------------------------------------------------------------ -- $Revision$ $Date$ ------------------------------------------------------------------------------ with Matreshka.DOM_Nodes; with XML.DOM.Attributes.Internals; package body ODF.DOM.Attributes.Text.Outline_Level.Internals is ------------ -- Create -- ------------ function Create (Node : Matreshka.ODF_Attributes.Text.Outline_Level.Text_Outline_Level_Access) return ODF.DOM.Attributes.Text.Outline_Level.ODF_Text_Outline_Level is begin return (XML.DOM.Attributes.Internals.Create (Matreshka.DOM_Nodes.Attribute_Access (Node)) with null record); end Create; ---------- -- Wrap -- ---------- function Wrap (Node : Matreshka.ODF_Attributes.Text.Outline_Level.Text_Outline_Level_Access) return ODF.DOM.Attributes.Text.Outline_Level.ODF_Text_Outline_Level is begin return (XML.DOM.Attributes.Internals.Wrap (Matreshka.DOM_Nodes.Attribute_Access (Node)) with null record); end Wrap; end ODF.DOM.Attributes.Text.Outline_Level.Internals;
reznikmm/matreshka
Ada
4,920
ads
------------------------------------------------------------------------------ -- -- -- Matreshka Project -- -- -- -- Ada Modeling Framework -- -- -- -- Runtime Library Component -- -- -- ------------------------------------------------------------------------------ -- -- -- Copyright © 2011-2012, Vadim Godunko <[email protected]> -- -- All rights reserved. -- -- -- -- Redistribution and use in source and binary forms, with or without -- -- modification, are permitted provided that the following conditions -- -- are met: -- -- -- -- * Redistributions of source code must retain the above copyright -- -- notice, this list of conditions and the following disclaimer. -- -- -- -- * Redistributions in binary form must reproduce the above copyright -- -- notice, this list of conditions and the following disclaimer in the -- -- documentation and/or other materials provided with the distribution. -- -- -- -- * Neither the name of the Vadim Godunko, IE nor the names of its -- -- contributors may be used to endorse or promote products derived from -- -- this software without specific prior written permission. -- -- -- -- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -- -- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -- -- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -- -- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -- -- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -- -- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED -- -- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -- -- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -- -- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -- -- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -- -- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- -- -- ------------------------------------------------------------------------------ -- $Revision$ $Date$ ------------------------------------------------------------------------------ with AMF.Internals.UML_Elements; with AMF.Standard_Profile_L3.Metamodels; with AMF.UML.Models; with AMF.Visitors; package AMF.Internals.Standard_Profile_L3_Metamodels is type Standard_Profile_L3_Metamodel_Proxy is limited new AMF.Internals.UML_Elements.UML_Element_Base and AMF.Standard_Profile_L3.Metamodels.Standard_Profile_L3_Metamodel with null record; overriding function Get_Base_Model (Self : not null access constant Standard_Profile_L3_Metamodel_Proxy) return AMF.UML.Models.UML_Model_Access; -- Getter of Metamodel::base_Model. -- overriding procedure Set_Base_Model (Self : not null access Standard_Profile_L3_Metamodel_Proxy; To : AMF.UML.Models.UML_Model_Access); -- Setter of Metamodel::base_Model. -- overriding procedure Enter_Element (Self : not null access constant Standard_Profile_L3_Metamodel_Proxy; Visitor : in out AMF.Visitors.Abstract_Visitor'Class; Control : in out AMF.Visitors.Traverse_Control); overriding procedure Leave_Element (Self : not null access constant Standard_Profile_L3_Metamodel_Proxy; Visitor : in out AMF.Visitors.Abstract_Visitor'Class; Control : in out AMF.Visitors.Traverse_Control); overriding procedure Visit_Element (Self : not null access constant Standard_Profile_L3_Metamodel_Proxy; Iterator : in out AMF.Visitors.Abstract_Iterator'Class; Visitor : in out AMF.Visitors.Abstract_Visitor'Class; Control : in out AMF.Visitors.Traverse_Control); end AMF.Internals.Standard_Profile_L3_Metamodels;
AaronC98/PlaneSystem
Ada
35,112
adb
------------------------------------------------------------------------------ -- Templates Parser -- -- -- -- Copyright (C) 2004-2017, 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/>. -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- ------------------------------------------------------------------------------ with Ada.Strings.Fixed; with Ada.Text_IO; with DOM.Core.Nodes; with DOM.Readers; with Input_Sources.File; with Input_Sources.Strings; with Sax.Readers; with Unicode.CES.Basic_8bit; with Unicode.CES.Utf8; with Templates_Parser.Utils; package body Templates_Parser.XML is Labels_Suffix : constant String := "_LABELS"; Description_Suffix : constant String := "_DESCRIPTION"; package Str_Map is new Containers.Indefinite_Hashed_Maps (String, Unbounded_String, Strings.Hash, "=", "="); function Parse_Document (Doc : DOM.Core.Node) return Translate_Set; -- Parse a document node and return the corresponding Translate_Set ----------- -- Image -- ----------- function Image (Translations : Translate_Set) return Unbounded_String is Result : Unbounded_String; procedure Process (Cursor : Association_Map.Cursor); -- Iterator procedure Add (Str : String) with Inline; -- Add a new line (str) into Result, a LF is added at the end of Str function To_Utf8 (Str : Unbounded_String) return String; -- Convert Str to UTF8 --------- -- Add -- --------- procedure Add (Str : String) is begin Append (Result, Str & ASCII.LF); end Add; ------------- -- Process -- ------------- procedure Process (Cursor : Association_Map.Cursor) is Item : constant Association := Association_Map.Element (Cursor); -- Current item Var : constant String := To_Utf8 (Item.Variable); -- Item variable name procedure Process_Std; -- Handles standard variables procedure Process_Composite; -- Handles composite variables procedure Add_Description (Var : String); -- Add var description for Var if found in the translation set function Is_Labels return Boolean; -- Returns True if Item is a Label entry function Is_Description return Boolean; -- Returns True if Item is a Description entry --------------------- -- Add_Description -- --------------------- procedure Add_Description (Var : String) is Var_Description : constant String := Var & Description_Suffix; begin if Translations.Set.Contains (Var_Description) then -- There is probably a label encoded into this set declare Description : constant Association := Translations.Set.Element (Var_Description); begin if Description.Kind = Std and then Description.Value /= "" then -- Definitly a label for this variable Add (" <Description>" & To_Utf8 (Description.Value) & "</Description>"); end if; end; end if; end Add_Description; -------------------- -- Is_Description -- -------------------- function Is_Description return Boolean is N, L : Natural; begin if Var'Length > Description_Suffix'Length and then Var (Var'Last - Description_Suffix'Length + 1 .. Var'Last) = Description_Suffix and then Translations.Set.Contains (Var (Var'First .. Var'Last - Description_Suffix'Length)) then return True; end if; -- Nested tag description N := Strings.Fixed.Index (Var, "_DIM"); if N = 0 or else Var (N + 4) not in '0' .. '9' then return False; else L := N - 1; -- Last character for the tag name N := N + 4; -- First character after _DIM loop N := N + 1; exit when Var (N) = '_' or else N = Var'Last; if Var (N) not in '0' .. '9' then -- Not a digit here, this is not a label return False; end if; end loop; return Var (N .. Var'Last) = Description_Suffix and then Translations.Set.Contains (Var (Var'First .. L)); end if; end Is_Description; --------------- -- Is_Labels -- --------------- function Is_Labels return Boolean is N, L : Natural; begin N := Strings.Fixed.Index (Var, "_DIM"); if N = 0 or else Var (N + 4) not in '0' .. '9' then return False; else L := N - 1; -- Last character for the tag name N := N + 4; -- First character after _DIM loop N := N + 1; exit when Var (N) = '_' or else N = Var'Last; if Var (N) not in '0' .. '9' then -- Not a digit here, this is not a label return False; end if; end loop; return Var (N .. Var'Last) = Labels_Suffix and then Translations.Set.Contains (Var (Var'First .. L)); end if; end Is_Labels; ----------------------- -- Process_Composite -- ----------------------- procedure Process_Composite is Null_Indice : constant Indices := (2 .. 1 => 0); procedure Output_Tag (T : Tag; Pos : Indices := Null_Indice); -- Output recursively tag T, Pos is the current indices for the -- parsed items. procedure Output_Axis (N : Positive; T : Tag); -- Output labels and description for axis number N. Labels are -- found in tag T. T must be a vector tag (Nested_Level = 1). ----------------- -- Output_Axis -- ----------------- procedure Output_Axis (N : Positive; T : Tag) is P : Tag_Node_Access := T.Data.Head; K : Positive := 1; begin pragma Assert (T.Data.Nested_Level = 1); Add (" <Dim n=""" & Utils.Image (N) & """>"); Add_Description (Var & "_DIM" & Utils.Image (N)); Add (" <Labels>"); while P /= null loop Add (" <Label ind=""" & Utils.Image (K) & """>" & To_Utf8 (P.V) & "</Label>"); K := K + 1; P := P.Next; end loop; Add (" </Labels>"); Add (" </Dim>"); end Output_Axis; ---------------- -- Output_Tag -- ---------------- procedure Output_Tag (T : Tag; Pos : Indices := Null_Indice) is use type Indices; procedure Output_Value (Pos : Indices; Value : String); -- Output value whose Tag indices is given by Pos ------------------ -- Output_Value -- ------------------ procedure Output_Value (Pos : Indices; Value : String) is V : Unbounded_String; begin Append (V, " <Entry>"); for K in Pos'Range loop Append (V, "<Ind n=""" & Utils.Image (K) & """>" & Utils.Image (Pos (K)) & "</Ind>"); end loop; Append (V, "<V>" & Value & "</V></Entry>"); Add (To_Utf8 (V)); end Output_Value; N : Tag_Node_Access := T.Data.Head; P : Positive := 1; begin while N /= null loop if N.Kind = Value then Output_Value (Pos & Indices'(1 => P), To_Utf8 (N.V)); else Output_Tag (N.VS.all, Pos & Indices'(1 => P)); end if; P := P + 1; N := N.Next; end loop; end Output_Tag; begin Add (" <CompositeTag>"); Add (" <Tag>"); Add (" <Name>" & Var & "</Name>"); Add_Description (Var); Add (" </Tag>"); -- Output axis labels for K in 1 .. Item.Comp_Value.Data.Nested_Level loop declare Label_Var : constant String := Var & "_DIM" & Utils.Image (K) & Labels_Suffix; begin if Translations.Set.Contains (Label_Var) then declare Item : constant Association := Translations.Set.Element (Label_Var); begin if Item.Kind = Composite and then Item.Comp_Value.Data.Nested_Level = 1 then -- This is a vector tag, labels are expected to -- be found on this vector. Output_Axis (K, Item.Comp_Value); end if; end; end if; end; end loop; -- Output values Output_Tag (Item.Comp_Value); Add (" </CompositeTag>"); end Process_Composite; ----------------- -- Process_Std -- ----------------- procedure Process_Std is begin Add (" <SimpleTag>"); Add (" <Tag>"); Add (" <Name>" & Var & "</Name>"); Add_Description (Var); Add (" </Tag>"); Add (" <V>" & To_Utf8 (Item.Value) & "</V>"); Add (" </SimpleTag>"); end Process_Std; begin -- Do not process labels encoded for another variable if not Is_Labels and then not Is_Description then case Item.Kind is when Std => Process_Std; when Composite => Process_Composite; end case; end if; end Process; ------------- -- To_Utf8 -- ------------- function To_Utf8 (Str : Unbounded_String) return String is use Unicode.CES; begin return Utf8.From_Utf32 (Basic_8bit.To_Utf32 (To_String (Str))); end To_Utf8; begin -- XML header Add ("<?xml version=""1.0"" encoding=""UTF-8"" ?>"); Add ("<Tagged xmlns:xsi=""http://www.w3.org/2001/XMLSchema-instance"">"); Translations.Set.Iterate (Process'Access); -- XML footer Add ("</Tagged>"); return Result; end Image; ---------- -- Load -- ---------- function Load (Filename : String) return Translate_Set is use DOM.Core; use DOM.Core.Nodes; use DOM.Readers; use Input_Sources; Reader : Tree_Reader; Input : File.File_Input; Doc : DOM.Core.Document; Result : Translate_Set; begin File.Open (Filename, Input); Set_Feature (Reader, Sax.Readers.Namespace_Prefixes_Feature, True); Parse (Reader, Input); File.Close (Input); Doc := Get_Tree (Reader); Result := Parse_Document (Doc); Free (Doc); return Result; end Load; -------------------- -- Parse_Document -- -------------------- function Parse_Document (Doc : DOM.Core.Node) return Translate_Set is use DOM.Core; use DOM.Core.Nodes; procedure Error (Node : DOM.Core.Node; Message : String) with No_Return; -- Raises Constraint_Error with the Message as exception message function First_Child (Parent : DOM.Core.Node) return DOM.Core.Node; -- Returns first child, skips #text node function Next_Sibling (N : DOM.Core.Node) return DOM.Core.Node; -- Returns next sibling, skip #text nodes function Parse_Tagged (N : DOM.Core.Node) return Translate_Set; -- Parse tagged entity function Parse_SimpleTag (N : DOM.Core.Node) return Translate_Set; -- Parse a SimpleTag entity function Parse_CompositeTag (N : DOM.Core.Node) return Translate_Set; -- Parse CompositeTag entity procedure Parse_Tag (N : DOM.Core.Node; Name, Description : out Unbounded_String); -- Parse a Tag node, set Name and Description function Get_Value (N : DOM.Core.Node) return String; -- Returns N value or the empty string if N is null ----------- -- Error -- ----------- procedure Error (Node : DOM.Core.Node; Message : String) is Name : constant String := Local_Name (Node); begin raise Constraint_Error with Name & " - " & Message; end Error; ----------------- -- First_Child -- ----------------- function First_Child (Parent : DOM.Core.Node) return DOM.Core.Node is N : DOM.Core.Node; begin N := DOM.Core.Nodes.First_Child (Parent); while N /= null and then DOM.Core.Nodes.Node_Name (N) = "#text" loop N := DOM.Core.Nodes.Next_Sibling (N); end loop; return N; end First_Child; --------------- -- Get_Value -- --------------- function Get_Value (N : DOM.Core.Node) return String is use Unicode.CES; begin if N = null then return ""; else return Basic_8bit.From_Utf32 (Utf8.To_Utf32 (Node_Value (N))); end if; end Get_Value; ------------------ -- Next_Sibling -- ------------------ function Next_Sibling (N : DOM.Core.Node) return DOM.Core.Node is M : DOM.Core.Node := N; begin loop M := DOM.Core.Nodes.Next_Sibling (M); exit when M = null or else DOM.Core.Nodes.Node_Name (M) /= "#text"; end loop; return M; end Next_Sibling; ------------------------ -- Parse_CompositeTag -- ------------------------ function Parse_CompositeTag (N : DOM.Core.Node) return Translate_Set is function Parse_Dim (N : DOM.Core.Node) return Translate_Set; -- Parse a Dim node procedure Parse_Entry (N : DOM.Core.Node); -- Parse an Entry node function Build_Tag return Tag; -- Build tag from Data map Name : Unbounded_String; -- current tag name Description : Unbounded_String; -- current tag description Data : Str_Map.Map; -- All data inserted into this map from Entry nodes, the key is the -- indexes separated with '_'. Level : Natural := 0; -- Number of nested level for the data --------------- -- Build_Tag -- --------------- function Build_Tag return Tag is function B_Tag (Key : String; N : Positive) return Tag; -- Recursive routine, will build the Tag in the right order with -- the right nested levels. ----------- -- B_Tag -- ----------- function B_Tag (Key : String; N : Positive) return Tag is use type Str_Map.Cursor; Max_Key : constant String := Utils.Image (N) & "_MAX"; Cursor : Str_Map.Cursor; Max : Natural; T : Tag; begin Cursor := Data.Find (Max_Key); Max := Natural'Value (To_String (Str_Map.Element (Cursor))); if N = Level then -- We have reached the last level for K in 1 .. Max loop Cursor := Data.Find (Key & "_" & Utils.Image (K)); exit when Cursor = Str_Map.No_Element; T := T & Str_Map.Element (Cursor); end loop; else for K in 1 .. Max loop T := T & B_Tag ("_" & Utils.Image (K), N + 1); end loop; end if; return T; end B_Tag; begin return B_Tag ("", 1); end Build_Tag; --------------- -- Parse_Dim -- --------------- function Parse_Dim (N : DOM.Core.Node) return Translate_Set is function Parse_Labels (N : DOM.Core.Node) return Translate_Set; -- Parse Labels node D : Positive; -- current Dim level ------------------ -- Parse_Labels -- ------------------ function Parse_Labels (N : DOM.Core.Node) return Translate_Set is use Str_Map; C : DOM.Core.Node := First_Child (N); Result : Translate_Set; T : Tag; Max : Natural := 0; Map : Str_Map.Map; K : Positive; Cursor : Str_Map.Cursor; Success : Boolean; begin while C /= null loop declare N_Name : constant String := Local_Name (C); Atts : constant DOM.Core.Named_Node_Map := DOM.Core.Nodes.Attributes (C); begin if N_Name = "Label" then if Length (Atts) = 1 and then Local_Name (Item (Atts, 0)) = "ind" then K := Positive'Value (Node_Value (Item (Atts, 0))); Max := Natural'Max (Max, K); Map.Insert (Node_Value (Item (Atts, 0)), To_Unbounded_String (Get_Value (DOM.Core.Nodes.First_Child (C))), Cursor, Success); if not Success then Error (C, "Duplicate label for ind " & Node_Value (Item (Atts, 0))); end if; else Error (C, "A single attribute ind expected"); end if; else Error (C, "Entity Label expected, found " & N_Name); end if; end; C := Next_Sibling (C); end loop; -- Now we have all labels indexed into the Map (key being the -- order number. Place them in the right order into T. for K in 1 .. Max loop declare K_Img : constant String := Utils.Image (K); begin Cursor := Map.Find (K_Img); if Str_Map.Has_Element (Cursor) then T := T & Str_Map.Element (Cursor); else T := T & ""; end if; end; end loop; -- The vector tag is now ready, build the association Insert (Result, Assoc (To_String (Name) & "_DIM" & Utils.Image (D) & "_LABELS", T)); return Result; end Parse_Labels; Atts : constant DOM.Core.Named_Node_Map := DOM.Core.Nodes.Attributes (N); Result : Translate_Set; C : DOM.Core.Node; begin if Length (Atts) /= 1 then Error (N, "A Dim node can have a single attribute"); end if; declare A : constant DOM.Core.Node := Item (Atts, 0); Name : constant String := Local_Name (A); Value : constant String := Node_Value (A); begin if Name = "n" then D := Positive'Value (Value); else Error (A, "Attribute name n expected, found " & Name); end if; end; -- Now look for all nodes C := First_Child (N); while C /= null loop declare N_Name : constant String := Local_Name (C); begin if N_Name = "Description" then Insert (Result, Assoc (To_String (Name) & "_DIM" & Utils.Image (D) & "_DESCRIPTION", Get_Value (DOM.Core.Nodes.First_Child (C)))); elsif N_Name = "Labels" then Insert (Result, Parse_Labels (C)); end if; end; C := Next_Sibling (C); end loop; return Result; end Parse_Dim; ----------------- -- Parse_Entry -- ----------------- procedure Parse_Entry (N : DOM.Core.Node) is procedure Insert (Key, Value : String); -- Insert key/value into Map and keep Max value found for this -- key inside Data map. C : DOM.Core.Node; Map : Str_Map.Map; V : Unbounded_String; Max : Natural := 0; Count : Natural := 0; ------------ -- Insert -- ------------ procedure Insert (Key, Value : String) is Max_Key : constant String := Key & "_MAX"; Cursor : Str_Map.Cursor; Success : Boolean; begin Map.Insert (Key, To_Unbounded_String (Value), Cursor, Success); if not Success then Error (C, "Duplicate attribute found for n " & Key); end if; -- Set Max Cursor := Data.Find (Max_Key); if Str_Map.Has_Element (Cursor) then declare Item : constant Natural := Natural'Value (To_String (Str_Map.Element (Cursor))); begin Data.Replace_Element (Cursor, To_Unbounded_String (Utils.Image (Natural'Max (Item, Natural'Value (Value))))); end; else Data.Insert (Max_Key, To_Unbounded_String (Value), Cursor, Success); end if; end Insert; begin -- We need first to set V, value for this entry C := First_Child (N); declare Found : Boolean := False; begin while C /= null loop declare N_Name : constant String := Local_Name (C); begin if N_Name = "V" then V := To_Unbounded_String (Get_Value (DOM.Core.Nodes.First_Child (C))); Found := True; end if; end; C := Next_Sibling (C); end loop; if not Found then Error (N, "Entity V not found"); end if; end; -- Now check for the indexes C := First_Child (N); while C /= null loop declare N_Name : constant String := Local_Name (C); begin if N_Name = "Ind" then Count := Count + 1; declare Atts : constant DOM.Core.Named_Node_Map := DOM.Core.Nodes.Attributes (C); K : Natural; begin if Length (Atts) = 1 and then Local_Name (Item (Atts, 0)) = "n" then K := Positive'Value (Node_Value (Item (Atts, 0))); Max := Natural'Max (Max, K); Insert (Node_Value (Item (Atts, 0)), Get_Value (DOM.Core.Nodes.First_Child (C))); else Error (C, "A single attribute named n expected"); end if; end; elsif N_Name = "V" then null; else Error (C, "Entity Ind or V expected, found " & N_Name); end if; end; C := Next_Sibling (C); end loop; -- Check validity if Level = 0 and then Max = Count then Level := Max; elsif Level /= Max or else Max /= Count then Error (N, "This entity has a wrong number of indices"); end if; -- Insert corresponding entry into Data declare Key : Unbounded_String; Cursor : Str_Map.Cursor; Success : Boolean; begin for K in 1 .. Level loop Cursor := Map.Find (Utils.Image (K)); Append (Key, "_" & To_String (Str_Map.Element (Cursor))); end loop; Data.Insert (To_String (Key), V, Cursor, Success); if not Success then Error (N, "Duplicate entry found"); end if; end; end Parse_Entry; C : DOM.Core.Node; Result : Translate_Set; begin -- First we need to look for the Tag entity C := First_Child (N); while C /= null loop declare N_Name : constant String := Local_Name (C); begin if N_Name = "Tag" then Parse_Tag (C, Name, Description); end if; end; C := Next_Sibling (C); end loop; if Name = Null_Unbounded_String then Error (N, "Missing entity Tag"); end if; -- Add tag description Insert (Result, Assoc (To_String (Name) & "_DESCRIPTION", To_String (Description))); -- Now handles other nodes C := First_Child (N); while C /= null loop declare N_Name : constant String := Local_Name (C); begin if N_Name = "Tag" then -- Already parsed above null; elsif N_Name = "Dim" then Insert (Result, Parse_Dim (C)); elsif N_Name = "Entry" then Parse_Entry (C); else Error (C, "Entity Tag, Dim or Entry expected, found " & N_Name); end if; end; C := Next_Sibling (C); end loop; -- Now we have all entities in the Data map Insert (Result, Assoc (To_String (Name), Build_Tag)); return Result; end Parse_CompositeTag; --------------------- -- Parse_SimpleTag -- --------------------- function Parse_SimpleTag (N : DOM.Core.Node) return Translate_Set is C : DOM.Core.Node; Name : Unbounded_String; Description : Unbounded_String; Value : Unbounded_String; Result : Translate_Set; begin C := First_Child (N); while C /= null loop declare N_Name : constant String := Local_Name (C); begin if N_Name = "Tag" then Parse_Tag (C, Name, Description); elsif N_Name = "V" then Value := To_Unbounded_String (Get_Value (DOM.Core.Nodes.First_Child (C))); else Error (C, "Entity Tag or V expected, found " & N_Name); end if; end; C := Next_Sibling (C); end loop; Insert (Result, Assoc (To_String (Name), To_String (Value))); if Description /= Null_Unbounded_String then Insert (Result, Assoc (To_String (Name) & "_DESCRIPTION", To_String (Description))); end if; return Result; end Parse_SimpleTag; --------------- -- Parse_Tag -- --------------- procedure Parse_Tag (N : DOM.Core.Node; Name, Description : out Unbounded_String) is C : DOM.Core.Node := First_Child (N); begin while C /= null loop declare N_Name : constant String := Local_Name (C); N_Value : constant String := Get_Value (DOM.Core.Nodes.First_Child (C)); begin if N_Name = "Name" then Name := To_Unbounded_String (N_Value); elsif N_Name = "Description" then Description := To_Unbounded_String (N_Value); else Error (N, "Entity Name or Description expected, found " & N_Name); end if; end; C := Next_Sibling (C); end loop; end Parse_Tag; ------------------ -- Parse_Tagged -- ------------------ function Parse_Tagged (N : DOM.Core.Node) return Translate_Set is C : DOM.Core.Node; T : Translate_Set; begin C := First_Child (N); while C /= null loop declare Name : constant String := Local_Name (C); begin if Name = "SimpleTag" then Insert (T, Parse_SimpleTag (C)); elsif Name = "CompositeTag" then Insert (T, Parse_CompositeTag (C)); else Error (C, "SimpleTag or CompositeTag expected, found" & Name); end if; end; C := Next_Sibling (C); end loop; return T; end Parse_Tagged; NL : constant DOM.Core.Node_List := Child_Nodes (Doc); begin if Length (NL) = 1 then return Parse_Tagged (First_Child (Doc)); else Error (Doc, "Document must have a single node, found " & Natural'Image (Length (NL))); end if; end Parse_Document; ---------- -- Save -- ---------- procedure Save (Filename : String; Translations : Translate_Set) is File : Text_IO.File_Type; begin Text_IO.Create (File, Text_IO.Out_File, Filename); Text_IO.Put (File, To_String (Image (Translations))); Text_IO.Close (File); end Save; ----------- -- Value -- ----------- function Value (Translations : String) return Translate_Set is use DOM.Core.Nodes; use DOM.Readers; Reader : Tree_Reader; Input : Input_Sources.Strings.String_Input; Doc : DOM.Core.Document; Result : Translate_Set; begin Input_Sources.Strings.Open (Translations'Unrestricted_Access, Unicode.CES.Utf8.Utf8_Encoding, Input); Set_Feature (Reader, Sax.Readers.Namespace_Prefixes_Feature, True); Parse (Reader, Input); Input_Sources.Strings.Close (Input); Doc := Get_Tree (Reader); Result := Parse_Document (Doc); Free (Doc); return Result; end Value; function Value (Translations : Unbounded_String) return Translate_Set is S : String_Access := new String (1 .. Length (Translations)); begin -- Copy XML content to local S string for I in 1 .. Length (Translations) loop S (I) := Element (Translations, I); end loop; declare Result : constant Translate_Set := Value (S.all); begin Free (S); return Result; end; end Value; end Templates_Parser.XML;
reznikmm/matreshka
Ada
41,219
ads
------------------------------------------------------------------------------ -- -- -- Matreshka Project -- -- -- -- Ada Modeling Framework -- -- -- -- Runtime Library Component -- -- -- ------------------------------------------------------------------------------ -- -- -- Copyright © 2011-2012, Vadim Godunko <[email protected]> -- -- All rights reserved. -- -- -- -- Redistribution and use in source and binary forms, with or without -- -- modification, are permitted provided that the following conditions -- -- are met: -- -- -- -- * Redistributions of source code must retain the above copyright -- -- notice, this list of conditions and the following disclaimer. -- -- -- -- * Redistributions in binary form must reproduce the above copyright -- -- notice, this list of conditions and the following disclaimer in the -- -- documentation and/or other materials provided with the distribution. -- -- -- -- * Neither the name of the Vadim Godunko, IE nor the names of its -- -- contributors may be used to endorse or promote products derived from -- -- this software without specific prior written permission. -- -- -- -- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -- -- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -- -- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -- -- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -- -- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -- -- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED -- -- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -- -- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -- -- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -- -- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -- -- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- -- -- ------------------------------------------------------------------------------ -- $Revision$ $Date$ ------------------------------------------------------------------------------ with AMF.Internals.UML_Classes; with AMF.String_Collections; with AMF.UML.Behaviors.Collections; with AMF.UML.Classes.Collections; with AMF.UML.Classifier_Template_Parameters; with AMF.UML.Classifiers.Collections; with AMF.UML.Collaboration_Uses.Collections; with AMF.UML.Connectable_Elements.Collections; with AMF.UML.Connectors.Collections; with AMF.UML.Constraints.Collections; with AMF.UML.Dependencies.Collections; with AMF.UML.Element_Imports.Collections; with AMF.UML.Extensions.Collections; with AMF.UML.Features.Collections; with AMF.UML.Generalization_Sets.Collections; with AMF.UML.Generalizations.Collections; with AMF.UML.Images.Collections; with AMF.UML.Interface_Realizations.Collections; with AMF.UML.Named_Elements.Collections; with AMF.UML.Namespaces; with AMF.UML.Operations.Collections; with AMF.UML.Package_Imports.Collections; with AMF.UML.Packageable_Elements.Collections; with AMF.UML.Packages.Collections; with AMF.UML.Parameterable_Elements.Collections; with AMF.UML.Ports.Collections; with AMF.UML.Profiles; with AMF.UML.Properties.Collections; with AMF.UML.Receptions.Collections; with AMF.UML.Redefinable_Elements.Collections; with AMF.UML.Redefinable_Template_Signatures; with AMF.UML.Stereotypes; with AMF.UML.String_Expressions; with AMF.UML.Substitutions.Collections; with AMF.UML.Template_Bindings.Collections; with AMF.UML.Template_Parameters; with AMF.UML.Template_Signatures; with AMF.UML.Types; with AMF.UML.Use_Cases.Collections; with AMF.Visitors; package AMF.Internals.UML_Stereotypes is type UML_Stereotype_Proxy is limited new AMF.Internals.UML_Classes.UML_Class_Proxy and AMF.UML.Stereotypes.UML_Stereotype with null record; overriding function Get_Icon (Self : not null access constant UML_Stereotype_Proxy) return AMF.UML.Images.Collections.Set_Of_UML_Image; -- Getter of Stereotype::icon. -- -- Stereotype can change the graphical appearance of the extended model -- element by using attached icons. When this association is not null, it -- references the location of the icon content to be displayed within -- diagrams presenting the extended model elements. overriding function Get_Profile (Self : not null access constant UML_Stereotype_Proxy) return AMF.UML.Profiles.UML_Profile_Access; -- Getter of Stereotype::profile. -- -- The profile that directly or indirectly contains this stereotype. overriding function Get_Extension (Self : not null access constant UML_Stereotype_Proxy) return AMF.UML.Extensions.Collections.Set_Of_UML_Extension; -- Getter of Class::extension. -- -- References the Extensions that specify additional properties of the -- metaclass. The property is derived from the extensions whose memberEnds -- are typed by the Class. overriding function Get_Is_Abstract (Self : not null access constant UML_Stereotype_Proxy) return Boolean; -- Getter of Class::isAbstract. -- -- True when a class is abstract. -- If true, the Classifier does not provide a complete declaration and can -- typically not be instantiated. An abstract classifier is intended to be -- used by other classifiers e.g. as the target of general -- metarelationships or generalization relationships. overriding function Get_Is_Active (Self : not null access constant UML_Stereotype_Proxy) return Boolean; -- Getter of Class::isActive. -- -- Determines whether an object specified by this class is active or not. -- If true, then the owning class is referred to as an active class. If -- false, then such a class is referred to as a passive class. overriding procedure Set_Is_Active (Self : not null access UML_Stereotype_Proxy; To : Boolean); -- Setter of Class::isActive. -- -- Determines whether an object specified by this class is active or not. -- If true, then the owning class is referred to as an active class. If -- false, then such a class is referred to as a passive class. overriding function Get_Nested_Classifier (Self : not null access constant UML_Stereotype_Proxy) return AMF.UML.Classifiers.Collections.Ordered_Set_Of_UML_Classifier; -- Getter of Class::nestedClassifier. -- -- References all the Classifiers that are defined (nested) within the -- Class. overriding function Get_Owned_Attribute (Self : not null access constant UML_Stereotype_Proxy) return AMF.UML.Properties.Collections.Ordered_Set_Of_UML_Property; -- Getter of Class::ownedAttribute. -- -- The attributes (i.e. the properties) owned by the class. overriding function Get_Owned_Operation (Self : not null access constant UML_Stereotype_Proxy) return AMF.UML.Operations.Collections.Ordered_Set_Of_UML_Operation; -- Getter of Class::ownedOperation. -- -- The operations owned by the class. overriding function Get_Owned_Reception (Self : not null access constant UML_Stereotype_Proxy) return AMF.UML.Receptions.Collections.Set_Of_UML_Reception; -- Getter of Class::ownedReception. -- -- Receptions that objects of this class are willing to accept. overriding function Get_Super_Class (Self : not null access constant UML_Stereotype_Proxy) return AMF.UML.Classes.Collections.Set_Of_UML_Class; -- Getter of Class::superClass. -- -- This gives the superclasses of a class. overriding function Get_Classifier_Behavior (Self : not null access constant UML_Stereotype_Proxy) return AMF.UML.Behaviors.UML_Behavior_Access; -- Getter of BehavioredClassifier::classifierBehavior. -- -- A behavior specification that specifies the behavior of the classifier -- itself. overriding procedure Set_Classifier_Behavior (Self : not null access UML_Stereotype_Proxy; To : AMF.UML.Behaviors.UML_Behavior_Access); -- Setter of BehavioredClassifier::classifierBehavior. -- -- A behavior specification that specifies the behavior of the classifier -- itself. overriding function Get_Interface_Realization (Self : not null access constant UML_Stereotype_Proxy) return AMF.UML.Interface_Realizations.Collections.Set_Of_UML_Interface_Realization; -- Getter of BehavioredClassifier::interfaceRealization. -- -- The set of InterfaceRealizations owned by the BehavioredClassifier. -- Interface realizations reference the Interfaces of which the -- BehavioredClassifier is an implementation. overriding function Get_Owned_Behavior (Self : not null access constant UML_Stereotype_Proxy) return AMF.UML.Behaviors.Collections.Set_Of_UML_Behavior; -- Getter of BehavioredClassifier::ownedBehavior. -- -- References behavior specifications owned by a classifier. overriding function Get_Attribute (Self : not null access constant UML_Stereotype_Proxy) return AMF.UML.Properties.Collections.Set_Of_UML_Property; -- Getter of Classifier::attribute. -- -- Refers to all of the Properties that are direct (i.e. not inherited or -- imported) attributes of the classifier. overriding function Get_Collaboration_Use (Self : not null access constant UML_Stereotype_Proxy) return AMF.UML.Collaboration_Uses.Collections.Set_Of_UML_Collaboration_Use; -- Getter of Classifier::collaborationUse. -- -- References the collaboration uses owned by the classifier. overriding function Get_Feature (Self : not null access constant UML_Stereotype_Proxy) return AMF.UML.Features.Collections.Set_Of_UML_Feature; -- Getter of Classifier::feature. -- -- Specifies each feature defined in the classifier. -- Note that there may be members of the Classifier that are of the type -- Feature but are not included in this association, e.g. inherited -- features. overriding function Get_General (Self : not null access constant UML_Stereotype_Proxy) return AMF.UML.Classifiers.Collections.Set_Of_UML_Classifier; -- Getter of Classifier::general. -- -- Specifies the general Classifiers for this Classifier. -- References the general classifier in the Generalization relationship. overriding function Get_Generalization (Self : not null access constant UML_Stereotype_Proxy) return AMF.UML.Generalizations.Collections.Set_Of_UML_Generalization; -- Getter of Classifier::generalization. -- -- Specifies the Generalization relationships for this Classifier. These -- Generalizations navigaten to more general classifiers in the -- generalization hierarchy. overriding function Get_Inherited_Member (Self : not null access constant UML_Stereotype_Proxy) return AMF.UML.Named_Elements.Collections.Set_Of_UML_Named_Element; -- Getter of Classifier::inheritedMember. -- -- Specifies all elements inherited by this classifier from the general -- classifiers. overriding function Get_Is_Final_Specialization (Self : not null access constant UML_Stereotype_Proxy) return Boolean; -- Getter of Classifier::isFinalSpecialization. -- -- If true, the Classifier cannot be specialized by generalization. Note -- that this property is preserved through package merge operations; that -- is, the capability to specialize a Classifier (i.e., -- isFinalSpecialization =false) must be preserved in the resulting -- Classifier of a package merge operation where a Classifier with -- isFinalSpecialization =false is merged with a matching Classifier with -- isFinalSpecialization =true: the resulting Classifier will have -- isFinalSpecialization =false. overriding procedure Set_Is_Final_Specialization (Self : not null access UML_Stereotype_Proxy; To : Boolean); -- Setter of Classifier::isFinalSpecialization. -- -- If true, the Classifier cannot be specialized by generalization. Note -- that this property is preserved through package merge operations; that -- is, the capability to specialize a Classifier (i.e., -- isFinalSpecialization =false) must be preserved in the resulting -- Classifier of a package merge operation where a Classifier with -- isFinalSpecialization =false is merged with a matching Classifier with -- isFinalSpecialization =true: the resulting Classifier will have -- isFinalSpecialization =false. overriding function Get_Owned_Template_Signature (Self : not null access constant UML_Stereotype_Proxy) return AMF.UML.Redefinable_Template_Signatures.UML_Redefinable_Template_Signature_Access; -- Getter of Classifier::ownedTemplateSignature. -- -- The optional template signature specifying the formal template -- parameters. overriding procedure Set_Owned_Template_Signature (Self : not null access UML_Stereotype_Proxy; To : AMF.UML.Redefinable_Template_Signatures.UML_Redefinable_Template_Signature_Access); -- Setter of Classifier::ownedTemplateSignature. -- -- The optional template signature specifying the formal template -- parameters. overriding function Get_Owned_Use_Case (Self : not null access constant UML_Stereotype_Proxy) return AMF.UML.Use_Cases.Collections.Set_Of_UML_Use_Case; -- Getter of Classifier::ownedUseCase. -- -- References the use cases owned by this classifier. overriding function Get_Powertype_Extent (Self : not null access constant UML_Stereotype_Proxy) return AMF.UML.Generalization_Sets.Collections.Set_Of_UML_Generalization_Set; -- Getter of Classifier::powertypeExtent. -- -- Designates the GeneralizationSet of which the associated Classifier is -- a power type. overriding function Get_Redefined_Classifier (Self : not null access constant UML_Stereotype_Proxy) return AMF.UML.Classifiers.Collections.Set_Of_UML_Classifier; -- Getter of Classifier::redefinedClassifier. -- -- References the Classifiers that are redefined by this Classifier. overriding function Get_Representation (Self : not null access constant UML_Stereotype_Proxy) return AMF.UML.Collaboration_Uses.UML_Collaboration_Use_Access; -- Getter of Classifier::representation. -- -- References a collaboration use which indicates the collaboration that -- represents this classifier. overriding procedure Set_Representation (Self : not null access UML_Stereotype_Proxy; To : AMF.UML.Collaboration_Uses.UML_Collaboration_Use_Access); -- Setter of Classifier::representation. -- -- References a collaboration use which indicates the collaboration that -- represents this classifier. overriding function Get_Substitution (Self : not null access constant UML_Stereotype_Proxy) return AMF.UML.Substitutions.Collections.Set_Of_UML_Substitution; -- Getter of Classifier::substitution. -- -- References the substitutions that are owned by this Classifier. overriding function Get_Template_Parameter (Self : not null access constant UML_Stereotype_Proxy) return AMF.UML.Classifier_Template_Parameters.UML_Classifier_Template_Parameter_Access; -- Getter of Classifier::templateParameter. -- -- The template parameter that exposes this element as a formal parameter. overriding procedure Set_Template_Parameter (Self : not null access UML_Stereotype_Proxy; To : AMF.UML.Classifier_Template_Parameters.UML_Classifier_Template_Parameter_Access); -- Setter of Classifier::templateParameter. -- -- The template parameter that exposes this element as a formal parameter. overriding function Get_Use_Case (Self : not null access constant UML_Stereotype_Proxy) return AMF.UML.Use_Cases.Collections.Set_Of_UML_Use_Case; -- Getter of Classifier::useCase. -- -- The set of use cases for which this Classifier is the subject. overriding function Get_Element_Import (Self : not null access constant UML_Stereotype_Proxy) return AMF.UML.Element_Imports.Collections.Set_Of_UML_Element_Import; -- Getter of Namespace::elementImport. -- -- References the ElementImports owned by the Namespace. overriding function Get_Imported_Member (Self : not null access constant UML_Stereotype_Proxy) return AMF.UML.Packageable_Elements.Collections.Set_Of_UML_Packageable_Element; -- Getter of Namespace::importedMember. -- -- References the PackageableElements that are members of this Namespace -- as a result of either PackageImports or ElementImports. overriding function Get_Member (Self : not null access constant UML_Stereotype_Proxy) return AMF.UML.Named_Elements.Collections.Set_Of_UML_Named_Element; -- Getter of Namespace::member. -- -- A collection of NamedElements identifiable within the Namespace, either -- by being owned or by being introduced by importing or inheritance. overriding function Get_Owned_Member (Self : not null access constant UML_Stereotype_Proxy) return AMF.UML.Named_Elements.Collections.Set_Of_UML_Named_Element; -- Getter of Namespace::ownedMember. -- -- A collection of NamedElements owned by the Namespace. overriding function Get_Owned_Rule (Self : not null access constant UML_Stereotype_Proxy) return AMF.UML.Constraints.Collections.Set_Of_UML_Constraint; -- Getter of Namespace::ownedRule. -- -- Specifies a set of Constraints owned by this Namespace. overriding function Get_Package_Import (Self : not null access constant UML_Stereotype_Proxy) return AMF.UML.Package_Imports.Collections.Set_Of_UML_Package_Import; -- Getter of Namespace::packageImport. -- -- References the PackageImports owned by the Namespace. overriding function Get_Client_Dependency (Self : not null access constant UML_Stereotype_Proxy) return AMF.UML.Dependencies.Collections.Set_Of_UML_Dependency; -- Getter of NamedElement::clientDependency. -- -- Indicates the dependencies that reference the client. overriding function Get_Name_Expression (Self : not null access constant UML_Stereotype_Proxy) return AMF.UML.String_Expressions.UML_String_Expression_Access; -- Getter of NamedElement::nameExpression. -- -- The string expression used to define the name of this named element. overriding procedure Set_Name_Expression (Self : not null access UML_Stereotype_Proxy; To : AMF.UML.String_Expressions.UML_String_Expression_Access); -- Setter of NamedElement::nameExpression. -- -- The string expression used to define the name of this named element. overriding function Get_Namespace (Self : not null access constant UML_Stereotype_Proxy) return AMF.UML.Namespaces.UML_Namespace_Access; -- Getter of NamedElement::namespace. -- -- Specifies the namespace that owns the NamedElement. overriding function Get_Qualified_Name (Self : not null access constant UML_Stereotype_Proxy) return AMF.Optional_String; -- Getter of NamedElement::qualifiedName. -- -- A name which allows the NamedElement to be identified within a -- hierarchy of nested Namespaces. It is constructed from the names of the -- containing namespaces starting at the root of the hierarchy and ending -- with the name of the NamedElement itself. overriding function Get_Package (Self : not null access constant UML_Stereotype_Proxy) return AMF.UML.Packages.UML_Package_Access; -- Getter of Type::package. -- -- Specifies the owning package of this classifier, if any. overriding procedure Set_Package (Self : not null access UML_Stereotype_Proxy; To : AMF.UML.Packages.UML_Package_Access); -- Setter of Type::package. -- -- Specifies the owning package of this classifier, if any. overriding function Get_Owning_Template_Parameter (Self : not null access constant UML_Stereotype_Proxy) return AMF.UML.Template_Parameters.UML_Template_Parameter_Access; -- Getter of ParameterableElement::owningTemplateParameter. -- -- The formal template parameter that owns this element. overriding procedure Set_Owning_Template_Parameter (Self : not null access UML_Stereotype_Proxy; To : AMF.UML.Template_Parameters.UML_Template_Parameter_Access); -- Setter of ParameterableElement::owningTemplateParameter. -- -- The formal template parameter that owns this element. overriding function Get_Template_Parameter (Self : not null access constant UML_Stereotype_Proxy) return AMF.UML.Template_Parameters.UML_Template_Parameter_Access; -- Getter of ParameterableElement::templateParameter. -- -- The template parameter that exposes this element as a formal parameter. overriding procedure Set_Template_Parameter (Self : not null access UML_Stereotype_Proxy; To : AMF.UML.Template_Parameters.UML_Template_Parameter_Access); -- Setter of ParameterableElement::templateParameter. -- -- The template parameter that exposes this element as a formal parameter. overriding function Get_Owned_Template_Signature (Self : not null access constant UML_Stereotype_Proxy) return AMF.UML.Template_Signatures.UML_Template_Signature_Access; -- Getter of TemplateableElement::ownedTemplateSignature. -- -- The optional template signature specifying the formal template -- parameters. overriding procedure Set_Owned_Template_Signature (Self : not null access UML_Stereotype_Proxy; To : AMF.UML.Template_Signatures.UML_Template_Signature_Access); -- Setter of TemplateableElement::ownedTemplateSignature. -- -- The optional template signature specifying the formal template -- parameters. overriding function Get_Template_Binding (Self : not null access constant UML_Stereotype_Proxy) return AMF.UML.Template_Bindings.Collections.Set_Of_UML_Template_Binding; -- Getter of TemplateableElement::templateBinding. -- -- The optional bindings from this element to templates. overriding function Get_Is_Leaf (Self : not null access constant UML_Stereotype_Proxy) return Boolean; -- Getter of RedefinableElement::isLeaf. -- -- Indicates whether it is possible to further redefine a -- RedefinableElement. If the value is true, then it is not possible to -- further redefine the RedefinableElement. Note that this property is -- preserved through package merge operations; that is, the capability to -- redefine a RedefinableElement (i.e., isLeaf=false) must be preserved in -- the resulting RedefinableElement of a package merge operation where a -- RedefinableElement with isLeaf=false is merged with a matching -- RedefinableElement with isLeaf=true: the resulting RedefinableElement -- will have isLeaf=false. Default value is false. overriding procedure Set_Is_Leaf (Self : not null access UML_Stereotype_Proxy; To : Boolean); -- Setter of RedefinableElement::isLeaf. -- -- Indicates whether it is possible to further redefine a -- RedefinableElement. If the value is true, then it is not possible to -- further redefine the RedefinableElement. Note that this property is -- preserved through package merge operations; that is, the capability to -- redefine a RedefinableElement (i.e., isLeaf=false) must be preserved in -- the resulting RedefinableElement of a package merge operation where a -- RedefinableElement with isLeaf=false is merged with a matching -- RedefinableElement with isLeaf=true: the resulting RedefinableElement -- will have isLeaf=false. Default value is false. overriding function Get_Redefined_Element (Self : not null access constant UML_Stereotype_Proxy) return AMF.UML.Redefinable_Elements.Collections.Set_Of_UML_Redefinable_Element; -- Getter of RedefinableElement::redefinedElement. -- -- The redefinable element that is being redefined by this element. overriding function Get_Redefinition_Context (Self : not null access constant UML_Stereotype_Proxy) return AMF.UML.Classifiers.Collections.Set_Of_UML_Classifier; -- Getter of RedefinableElement::redefinitionContext. -- -- References the contexts that this element may be redefined from. overriding function Get_Owned_Port (Self : not null access constant UML_Stereotype_Proxy) return AMF.UML.Ports.Collections.Set_Of_UML_Port; -- Getter of EncapsulatedClassifier::ownedPort. -- -- References a set of ports that an encapsulated classifier owns. overriding function Get_Owned_Connector (Self : not null access constant UML_Stereotype_Proxy) return AMF.UML.Connectors.Collections.Set_Of_UML_Connector; -- Getter of StructuredClassifier::ownedConnector. -- -- References the connectors owned by the classifier. overriding function Get_Part (Self : not null access constant UML_Stereotype_Proxy) return AMF.UML.Properties.Collections.Set_Of_UML_Property; -- Getter of StructuredClassifier::part. -- -- References the properties specifying instances that the classifier owns -- by composition. This association is derived, selecting those owned -- properties where isComposite is true. overriding function Get_Role (Self : not null access constant UML_Stereotype_Proxy) return AMF.UML.Connectable_Elements.Collections.Set_Of_UML_Connectable_Element; -- Getter of StructuredClassifier::role. -- -- References the roles that instances may play in this classifier. overriding function Containing_Profile (Self : not null access constant UML_Stereotype_Proxy) return AMF.UML.Profiles.UML_Profile_Access; -- Operation Stereotype::containingProfile. -- -- The query containingProfile returns the closest profile directly or -- indirectly containing this stereotype. overriding function Profile (Self : not null access constant UML_Stereotype_Proxy) return AMF.UML.Profiles.UML_Profile_Access; -- Operation Stereotype::profile. -- -- A stereotype must be contained, directly or indirectly, in a profile. overriding function Extension (Self : not null access constant UML_Stereotype_Proxy) return AMF.UML.Extensions.Collections.Set_Of_UML_Extension; -- Operation Class::extension. -- -- Missing derivation for Class::/extension : Extension overriding function Inherit (Self : not null access constant UML_Stereotype_Proxy; Inhs : AMF.UML.Named_Elements.Collections.Set_Of_UML_Named_Element) return AMF.UML.Named_Elements.Collections.Set_Of_UML_Named_Element; -- Operation Class::inherit. -- -- The inherit operation is overridden to exclude redefined properties. overriding function Super_Class (Self : not null access constant UML_Stereotype_Proxy) return AMF.UML.Classes.Collections.Set_Of_UML_Class; -- Operation Class::superClass. -- -- Missing derivation for Class::/superClass : Class overriding function All_Features (Self : not null access constant UML_Stereotype_Proxy) return AMF.UML.Features.Collections.Set_Of_UML_Feature; -- Operation Classifier::allFeatures. -- -- The query allFeatures() gives all of the features in the namespace of -- the classifier. In general, through mechanisms such as inheritance, -- this will be a larger set than feature. overriding function Conforms_To (Self : not null access constant UML_Stereotype_Proxy; Other : AMF.UML.Classifiers.UML_Classifier_Access) return Boolean; -- Operation Classifier::conformsTo. -- -- The query conformsTo() gives true for a classifier that defines a type -- that conforms to another. This is used, for example, in the -- specification of signature conformance for operations. overriding function General (Self : not null access constant UML_Stereotype_Proxy) return AMF.UML.Classifiers.Collections.Set_Of_UML_Classifier; -- Operation Classifier::general. -- -- The general classifiers are the classifiers referenced by the -- generalization relationships. overriding function Has_Visibility_Of (Self : not null access constant UML_Stereotype_Proxy; N : AMF.UML.Named_Elements.UML_Named_Element_Access) return Boolean; -- Operation Classifier::hasVisibilityOf. -- -- The query hasVisibilityOf() determines whether a named element is -- visible in the classifier. By default all are visible. It is only -- called when the argument is something owned by a parent. overriding function Inheritable_Members (Self : not null access constant UML_Stereotype_Proxy; C : AMF.UML.Classifiers.UML_Classifier_Access) return AMF.UML.Named_Elements.Collections.Set_Of_UML_Named_Element; -- Operation Classifier::inheritableMembers. -- -- The query inheritableMembers() gives all of the members of a classifier -- that may be inherited in one of its descendants, subject to whatever -- visibility restrictions apply. overriding function Inherited_Member (Self : not null access constant UML_Stereotype_Proxy) return AMF.UML.Named_Elements.Collections.Set_Of_UML_Named_Element; -- Operation Classifier::inheritedMember. -- -- The inheritedMember association is derived by inheriting the -- inheritable members of the parents. -- The inheritedMember association is derived by inheriting the -- inheritable members of the parents. overriding function Is_Template (Self : not null access constant UML_Stereotype_Proxy) return Boolean; -- Operation Classifier::isTemplate. -- -- The query isTemplate() returns whether this templateable element is -- actually a template. overriding function May_Specialize_Type (Self : not null access constant UML_Stereotype_Proxy; C : AMF.UML.Classifiers.UML_Classifier_Access) return Boolean; -- Operation Classifier::maySpecializeType. -- -- The query maySpecializeType() determines whether this classifier may -- have a generalization relationship to classifiers of the specified -- type. By default a classifier may specialize classifiers of the same or -- a more general type. It is intended to be redefined by classifiers that -- have different specialization constraints. overriding function Exclude_Collisions (Self : not null access constant UML_Stereotype_Proxy; Imps : AMF.UML.Packageable_Elements.Collections.Set_Of_UML_Packageable_Element) return AMF.UML.Packageable_Elements.Collections.Set_Of_UML_Packageable_Element; -- Operation Namespace::excludeCollisions. -- -- The query excludeCollisions() excludes from a set of -- PackageableElements any that would not be distinguishable from each -- other in this namespace. overriding function Get_Names_Of_Member (Self : not null access constant UML_Stereotype_Proxy; Element : AMF.UML.Named_Elements.UML_Named_Element_Access) return AMF.String_Collections.Set_Of_String; -- Operation Namespace::getNamesOfMember. -- -- The query getNamesOfMember() takes importing into account. It gives -- back the set of names that an element would have in an importing -- namespace, either because it is owned, or if not owned then imported -- individually, or if not individually then from a package. -- The query getNamesOfMember() gives a set of all of the names that a -- member would have in a Namespace. In general a member can have multiple -- names in a Namespace if it is imported more than once with different -- aliases. The query takes account of importing. It gives back the set of -- names that an element would have in an importing namespace, either -- because it is owned, or if not owned then imported individually, or if -- not individually then from a package. overriding function Import_Members (Self : not null access constant UML_Stereotype_Proxy; Imps : AMF.UML.Packageable_Elements.Collections.Set_Of_UML_Packageable_Element) return AMF.UML.Packageable_Elements.Collections.Set_Of_UML_Packageable_Element; -- Operation Namespace::importMembers. -- -- The query importMembers() defines which of a set of PackageableElements -- are actually imported into the namespace. This excludes hidden ones, -- i.e., those which have names that conflict with names of owned members, -- and also excludes elements which would have the same name when imported. overriding function Imported_Member (Self : not null access constant UML_Stereotype_Proxy) return AMF.UML.Packageable_Elements.Collections.Set_Of_UML_Packageable_Element; -- Operation Namespace::importedMember. -- -- The importedMember property is derived from the ElementImports and the -- PackageImports. References the PackageableElements that are members of -- this Namespace as a result of either PackageImports or ElementImports. overriding function Members_Are_Distinguishable (Self : not null access constant UML_Stereotype_Proxy) return Boolean; -- Operation Namespace::membersAreDistinguishable. -- -- The Boolean query membersAreDistinguishable() determines whether all of -- the namespace's members are distinguishable within it. overriding function Owned_Member (Self : not null access constant UML_Stereotype_Proxy) return AMF.UML.Named_Elements.Collections.Set_Of_UML_Named_Element; -- Operation Namespace::ownedMember. -- -- Missing derivation for Namespace::/ownedMember : NamedElement overriding function All_Owning_Packages (Self : not null access constant UML_Stereotype_Proxy) return AMF.UML.Packages.Collections.Set_Of_UML_Package; -- Operation NamedElement::allOwningPackages. -- -- The query allOwningPackages() returns all the directly or indirectly -- owning packages. overriding function Is_Distinguishable_From (Self : not null access constant UML_Stereotype_Proxy; N : AMF.UML.Named_Elements.UML_Named_Element_Access; Ns : AMF.UML.Namespaces.UML_Namespace_Access) return Boolean; -- Operation NamedElement::isDistinguishableFrom. -- -- The query isDistinguishableFrom() determines whether two NamedElements -- may logically co-exist within a Namespace. By default, two named -- elements are distinguishable if (a) they have unrelated types or (b) -- they have related types but different names. overriding function Namespace (Self : not null access constant UML_Stereotype_Proxy) return AMF.UML.Namespaces.UML_Namespace_Access; -- Operation NamedElement::namespace. -- -- Missing derivation for NamedElement::/namespace : Namespace overriding function Conforms_To (Self : not null access constant UML_Stereotype_Proxy; Other : AMF.UML.Types.UML_Type_Access) return Boolean; -- Operation Type::conformsTo. -- -- The query conformsTo() gives true for a type that conforms to another. -- By default, two types do not conform to each other. This query is -- intended to be redefined for specific conformance situations. overriding function Is_Compatible_With (Self : not null access constant UML_Stereotype_Proxy; P : AMF.UML.Parameterable_Elements.UML_Parameterable_Element_Access) return Boolean; -- Operation ParameterableElement::isCompatibleWith. -- -- The query isCompatibleWith() determines if this parameterable element -- is compatible with the specified parameterable element. By default -- parameterable element P is compatible with parameterable element Q if -- the kind of P is the same or a subtype as the kind of Q. Subclasses -- should override this operation to specify different compatibility -- constraints. overriding function Is_Template_Parameter (Self : not null access constant UML_Stereotype_Proxy) return Boolean; -- Operation ParameterableElement::isTemplateParameter. -- -- The query isTemplateParameter() determines if this parameterable -- element is exposed as a formal template parameter. overriding function Parameterable_Elements (Self : not null access constant UML_Stereotype_Proxy) return AMF.UML.Parameterable_Elements.Collections.Set_Of_UML_Parameterable_Element; -- Operation TemplateableElement::parameterableElements. -- -- The query parameterableElements() returns the set of elements that may -- be used as the parametered elements for a template parameter of this -- templateable element. By default, this set includes all the owned -- elements. Subclasses may override this operation if they choose to -- restrict the set of parameterable elements. overriding function Is_Consistent_With (Self : not null access constant UML_Stereotype_Proxy; Redefinee : AMF.UML.Redefinable_Elements.UML_Redefinable_Element_Access) return Boolean; -- Operation RedefinableElement::isConsistentWith. -- -- The query isConsistentWith() specifies, for any two RedefinableElements -- in a context in which redefinition is possible, whether redefinition -- would be logically consistent. By default, this is false; this -- operation must be overridden for subclasses of RedefinableElement to -- define the consistency conditions. overriding function Is_Redefinition_Context_Valid (Self : not null access constant UML_Stereotype_Proxy; Redefined : AMF.UML.Redefinable_Elements.UML_Redefinable_Element_Access) return Boolean; -- Operation RedefinableElement::isRedefinitionContextValid. -- -- The query isRedefinitionContextValid() specifies whether the -- redefinition contexts of this RedefinableElement are properly related -- to the redefinition contexts of the specified RedefinableElement to -- allow this element to redefine the other. By default at least one of -- the redefinition contexts of this element must be a specialization of -- at least one of the redefinition contexts of the specified element. overriding function Owned_Port (Self : not null access constant UML_Stereotype_Proxy) return AMF.UML.Ports.Collections.Set_Of_UML_Port; -- Operation EncapsulatedClassifier::ownedPort. -- -- Missing derivation for EncapsulatedClassifier::/ownedPort : Port overriding function Part (Self : not null access constant UML_Stereotype_Proxy) return AMF.UML.Properties.Collections.Set_Of_UML_Property; -- Operation StructuredClassifier::part. -- -- Missing derivation for StructuredClassifier::/part : Property overriding procedure Enter_Element (Self : not null access constant UML_Stereotype_Proxy; Visitor : in out AMF.Visitors.Abstract_Visitor'Class; Control : in out AMF.Visitors.Traverse_Control); -- Dispatch call to corresponding subprogram of visitor interface. overriding procedure Leave_Element (Self : not null access constant UML_Stereotype_Proxy; Visitor : in out AMF.Visitors.Abstract_Visitor'Class; Control : in out AMF.Visitors.Traverse_Control); -- Dispatch call to corresponding subprogram of visitor interface. overriding procedure Visit_Element (Self : not null access constant UML_Stereotype_Proxy; Iterator : in out AMF.Visitors.Abstract_Iterator'Class; Visitor : in out AMF.Visitors.Abstract_Visitor'Class; Control : in out AMF.Visitors.Traverse_Control); -- Dispatch call to corresponding subprogram of iterator interface. end AMF.Internals.UML_Stereotypes;
reznikmm/matreshka
Ada
26,601
adb
------------------------------------------------------------------------------ -- -- -- Matreshka Project -- -- -- -- Ada Modeling Framework -- -- -- -- Runtime Library Component -- -- -- ------------------------------------------------------------------------------ -- -- -- Copyright © 2011-2012, Vadim Godunko <[email protected]> -- -- All rights reserved. -- -- -- -- Redistribution and use in source and binary forms, with or without -- -- modification, are permitted provided that the following conditions -- -- are met: -- -- -- -- * Redistributions of source code must retain the above copyright -- -- notice, this list of conditions and the following disclaimer. -- -- -- -- * Redistributions in binary form must reproduce the above copyright -- -- notice, this list of conditions and the following disclaimer in the -- -- documentation and/or other materials provided with the distribution. -- -- -- -- * Neither the name of the Vadim Godunko, IE nor the names of its -- -- contributors may be used to endorse or promote products derived from -- -- this software without specific prior written permission. -- -- -- -- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -- -- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -- -- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -- -- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -- -- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -- -- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED -- -- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -- -- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -- -- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -- -- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -- -- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- -- -- ------------------------------------------------------------------------------ -- $Revision$ $Date$ ------------------------------------------------------------------------------ with AMF.Elements; with AMF.Internals.Element_Collections; with AMF.Internals.Helpers; with AMF.Internals.Tables.UML_Attributes; with AMF.Visitors.UML_Iterators; with AMF.Visitors.UML_Visitors; with League.Strings.Internals; with Matreshka.Internals.Strings; package body AMF.Internals.UML_Remove_Variable_Value_Actions is ------------------- -- Enter_Element -- ------------------- overriding procedure Enter_Element (Self : not null access constant UML_Remove_Variable_Value_Action_Proxy; Visitor : in out AMF.Visitors.Abstract_Visitor'Class; Control : in out AMF.Visitors.Traverse_Control) is begin if Visitor in AMF.Visitors.UML_Visitors.UML_Visitor'Class then AMF.Visitors.UML_Visitors.UML_Visitor'Class (Visitor).Enter_Remove_Variable_Value_Action (AMF.UML.Remove_Variable_Value_Actions.UML_Remove_Variable_Value_Action_Access (Self), Control); end if; end Enter_Element; ------------------- -- Leave_Element -- ------------------- overriding procedure Leave_Element (Self : not null access constant UML_Remove_Variable_Value_Action_Proxy; Visitor : in out AMF.Visitors.Abstract_Visitor'Class; Control : in out AMF.Visitors.Traverse_Control) is begin if Visitor in AMF.Visitors.UML_Visitors.UML_Visitor'Class then AMF.Visitors.UML_Visitors.UML_Visitor'Class (Visitor).Leave_Remove_Variable_Value_Action (AMF.UML.Remove_Variable_Value_Actions.UML_Remove_Variable_Value_Action_Access (Self), Control); end if; end Leave_Element; ------------------- -- Visit_Element -- ------------------- overriding procedure Visit_Element (Self : not null access constant UML_Remove_Variable_Value_Action_Proxy; Iterator : in out AMF.Visitors.Abstract_Iterator'Class; Visitor : in out AMF.Visitors.Abstract_Visitor'Class; Control : in out AMF.Visitors.Traverse_Control) is begin if Iterator in AMF.Visitors.UML_Iterators.UML_Iterator'Class then AMF.Visitors.UML_Iterators.UML_Iterator'Class (Iterator).Visit_Remove_Variable_Value_Action (Visitor, AMF.UML.Remove_Variable_Value_Actions.UML_Remove_Variable_Value_Action_Access (Self), Control); end if; end Visit_Element; ------------------------------ -- Get_Is_Remove_Duplicates -- ------------------------------ overriding function Get_Is_Remove_Duplicates (Self : not null access constant UML_Remove_Variable_Value_Action_Proxy) return Boolean is begin return AMF.Internals.Tables.UML_Attributes.Internal_Get_Is_Remove_Duplicates (Self.Element); end Get_Is_Remove_Duplicates; ------------------------------ -- Set_Is_Remove_Duplicates -- ------------------------------ overriding procedure Set_Is_Remove_Duplicates (Self : not null access UML_Remove_Variable_Value_Action_Proxy; To : Boolean) is begin AMF.Internals.Tables.UML_Attributes.Internal_Set_Is_Remove_Duplicates (Self.Element, To); end Set_Is_Remove_Duplicates; ------------------- -- Get_Remove_At -- ------------------- overriding function Get_Remove_At (Self : not null access constant UML_Remove_Variable_Value_Action_Proxy) return AMF.UML.Input_Pins.UML_Input_Pin_Access is begin return AMF.UML.Input_Pins.UML_Input_Pin_Access (AMF.Internals.Helpers.To_Element (AMF.Internals.Tables.UML_Attributes.Internal_Get_Remove_At (Self.Element))); end Get_Remove_At; ------------------- -- Set_Remove_At -- ------------------- overriding procedure Set_Remove_At (Self : not null access UML_Remove_Variable_Value_Action_Proxy; To : AMF.UML.Input_Pins.UML_Input_Pin_Access) is begin AMF.Internals.Tables.UML_Attributes.Internal_Set_Remove_At (Self.Element, AMF.Internals.Helpers.To_Element (AMF.Elements.Element_Access (To))); end Set_Remove_At; --------------- -- Get_Value -- --------------- overriding function Get_Value (Self : not null access constant UML_Remove_Variable_Value_Action_Proxy) return AMF.UML.Input_Pins.UML_Input_Pin_Access is begin return AMF.UML.Input_Pins.UML_Input_Pin_Access (AMF.Internals.Helpers.To_Element (AMF.Internals.Tables.UML_Attributes.Internal_Get_Value (Self.Element))); end Get_Value; --------------- -- Set_Value -- --------------- overriding procedure Set_Value (Self : not null access UML_Remove_Variable_Value_Action_Proxy; To : AMF.UML.Input_Pins.UML_Input_Pin_Access) is begin AMF.Internals.Tables.UML_Attributes.Internal_Set_Value (Self.Element, AMF.Internals.Helpers.To_Element (AMF.Elements.Element_Access (To))); end Set_Value; ------------------ -- Get_Variable -- ------------------ overriding function Get_Variable (Self : not null access constant UML_Remove_Variable_Value_Action_Proxy) return AMF.UML.Variables.UML_Variable_Access is begin return AMF.UML.Variables.UML_Variable_Access (AMF.Internals.Helpers.To_Element (AMF.Internals.Tables.UML_Attributes.Internal_Get_Variable (Self.Element))); end Get_Variable; ------------------ -- Set_Variable -- ------------------ overriding procedure Set_Variable (Self : not null access UML_Remove_Variable_Value_Action_Proxy; To : AMF.UML.Variables.UML_Variable_Access) is begin AMF.Internals.Tables.UML_Attributes.Internal_Set_Variable (Self.Element, AMF.Internals.Helpers.To_Element (AMF.Elements.Element_Access (To))); end Set_Variable; ----------------- -- Get_Context -- ----------------- overriding function Get_Context (Self : not null access constant UML_Remove_Variable_Value_Action_Proxy) return AMF.UML.Classifiers.UML_Classifier_Access is begin return AMF.UML.Classifiers.UML_Classifier_Access (AMF.Internals.Helpers.To_Element (AMF.Internals.Tables.UML_Attributes.Internal_Get_Context (Self.Element))); end Get_Context; --------------- -- Get_Input -- --------------- overriding function Get_Input (Self : not null access constant UML_Remove_Variable_Value_Action_Proxy) return AMF.UML.Input_Pins.Collections.Ordered_Set_Of_UML_Input_Pin is begin return AMF.UML.Input_Pins.Collections.Wrap (AMF.Internals.Element_Collections.Wrap (AMF.Internals.Tables.UML_Attributes.Internal_Get_Input (Self.Element))); end Get_Input; ------------------------------ -- Get_Is_Locally_Reentrant -- ------------------------------ overriding function Get_Is_Locally_Reentrant (Self : not null access constant UML_Remove_Variable_Value_Action_Proxy) return Boolean is begin return AMF.Internals.Tables.UML_Attributes.Internal_Get_Is_Locally_Reentrant (Self.Element); end Get_Is_Locally_Reentrant; ------------------------------ -- Set_Is_Locally_Reentrant -- ------------------------------ overriding procedure Set_Is_Locally_Reentrant (Self : not null access UML_Remove_Variable_Value_Action_Proxy; To : Boolean) is begin AMF.Internals.Tables.UML_Attributes.Internal_Set_Is_Locally_Reentrant (Self.Element, To); end Set_Is_Locally_Reentrant; ----------------------------- -- Get_Local_Postcondition -- ----------------------------- overriding function Get_Local_Postcondition (Self : not null access constant UML_Remove_Variable_Value_Action_Proxy) return AMF.UML.Constraints.Collections.Set_Of_UML_Constraint is begin return AMF.UML.Constraints.Collections.Wrap (AMF.Internals.Element_Collections.Wrap (AMF.Internals.Tables.UML_Attributes.Internal_Get_Local_Postcondition (Self.Element))); end Get_Local_Postcondition; ---------------------------- -- Get_Local_Precondition -- ---------------------------- overriding function Get_Local_Precondition (Self : not null access constant UML_Remove_Variable_Value_Action_Proxy) return AMF.UML.Constraints.Collections.Set_Of_UML_Constraint is begin return AMF.UML.Constraints.Collections.Wrap (AMF.Internals.Element_Collections.Wrap (AMF.Internals.Tables.UML_Attributes.Internal_Get_Local_Precondition (Self.Element))); end Get_Local_Precondition; ---------------- -- Get_Output -- ---------------- overriding function Get_Output (Self : not null access constant UML_Remove_Variable_Value_Action_Proxy) return AMF.UML.Output_Pins.Collections.Ordered_Set_Of_UML_Output_Pin is begin return AMF.UML.Output_Pins.Collections.Wrap (AMF.Internals.Element_Collections.Wrap (AMF.Internals.Tables.UML_Attributes.Internal_Get_Output (Self.Element))); end Get_Output; ----------------- -- Get_Handler -- ----------------- overriding function Get_Handler (Self : not null access constant UML_Remove_Variable_Value_Action_Proxy) return AMF.UML.Exception_Handlers.Collections.Set_Of_UML_Exception_Handler is begin return AMF.UML.Exception_Handlers.Collections.Wrap (AMF.Internals.Element_Collections.Wrap (AMF.Internals.Tables.UML_Attributes.Internal_Get_Handler (Self.Element))); end Get_Handler; ------------------ -- Get_Activity -- ------------------ overriding function Get_Activity (Self : not null access constant UML_Remove_Variable_Value_Action_Proxy) return AMF.UML.Activities.UML_Activity_Access is begin return AMF.UML.Activities.UML_Activity_Access (AMF.Internals.Helpers.To_Element (AMF.Internals.Tables.UML_Attributes.Internal_Get_Activity (Self.Element))); end Get_Activity; ------------------ -- Set_Activity -- ------------------ overriding procedure Set_Activity (Self : not null access UML_Remove_Variable_Value_Action_Proxy; To : AMF.UML.Activities.UML_Activity_Access) is begin AMF.Internals.Tables.UML_Attributes.Internal_Set_Activity (Self.Element, AMF.Internals.Helpers.To_Element (AMF.Elements.Element_Access (To))); end Set_Activity; ------------------ -- Get_In_Group -- ------------------ overriding function Get_In_Group (Self : not null access constant UML_Remove_Variable_Value_Action_Proxy) return AMF.UML.Activity_Groups.Collections.Set_Of_UML_Activity_Group is begin return AMF.UML.Activity_Groups.Collections.Wrap (AMF.Internals.Element_Collections.Wrap (AMF.Internals.Tables.UML_Attributes.Internal_Get_In_Group (Self.Element))); end Get_In_Group; --------------------------------- -- Get_In_Interruptible_Region -- --------------------------------- overriding function Get_In_Interruptible_Region (Self : not null access constant UML_Remove_Variable_Value_Action_Proxy) return AMF.UML.Interruptible_Activity_Regions.Collections.Set_Of_UML_Interruptible_Activity_Region is begin return AMF.UML.Interruptible_Activity_Regions.Collections.Wrap (AMF.Internals.Element_Collections.Wrap (AMF.Internals.Tables.UML_Attributes.Internal_Get_In_Interruptible_Region (Self.Element))); end Get_In_Interruptible_Region; ---------------------- -- Get_In_Partition -- ---------------------- overriding function Get_In_Partition (Self : not null access constant UML_Remove_Variable_Value_Action_Proxy) return AMF.UML.Activity_Partitions.Collections.Set_Of_UML_Activity_Partition is begin return AMF.UML.Activity_Partitions.Collections.Wrap (AMF.Internals.Element_Collections.Wrap (AMF.Internals.Tables.UML_Attributes.Internal_Get_In_Partition (Self.Element))); end Get_In_Partition; ---------------------------- -- Get_In_Structured_Node -- ---------------------------- overriding function Get_In_Structured_Node (Self : not null access constant UML_Remove_Variable_Value_Action_Proxy) return AMF.UML.Structured_Activity_Nodes.UML_Structured_Activity_Node_Access is begin return AMF.UML.Structured_Activity_Nodes.UML_Structured_Activity_Node_Access (AMF.Internals.Helpers.To_Element (AMF.Internals.Tables.UML_Attributes.Internal_Get_In_Structured_Node (Self.Element))); end Get_In_Structured_Node; ---------------------------- -- Set_In_Structured_Node -- ---------------------------- overriding procedure Set_In_Structured_Node (Self : not null access UML_Remove_Variable_Value_Action_Proxy; To : AMF.UML.Structured_Activity_Nodes.UML_Structured_Activity_Node_Access) is begin AMF.Internals.Tables.UML_Attributes.Internal_Set_In_Structured_Node (Self.Element, AMF.Internals.Helpers.To_Element (AMF.Elements.Element_Access (To))); end Set_In_Structured_Node; ------------------ -- Get_Incoming -- ------------------ overriding function Get_Incoming (Self : not null access constant UML_Remove_Variable_Value_Action_Proxy) return AMF.UML.Activity_Edges.Collections.Set_Of_UML_Activity_Edge is begin return AMF.UML.Activity_Edges.Collections.Wrap (AMF.Internals.Element_Collections.Wrap (AMF.Internals.Tables.UML_Attributes.Internal_Get_Incoming (Self.Element))); end Get_Incoming; ------------------ -- Get_Outgoing -- ------------------ overriding function Get_Outgoing (Self : not null access constant UML_Remove_Variable_Value_Action_Proxy) return AMF.UML.Activity_Edges.Collections.Set_Of_UML_Activity_Edge is begin return AMF.UML.Activity_Edges.Collections.Wrap (AMF.Internals.Element_Collections.Wrap (AMF.Internals.Tables.UML_Attributes.Internal_Get_Outgoing (Self.Element))); end Get_Outgoing; ------------------------ -- Get_Redefined_Node -- ------------------------ overriding function Get_Redefined_Node (Self : not null access constant UML_Remove_Variable_Value_Action_Proxy) return AMF.UML.Activity_Nodes.Collections.Set_Of_UML_Activity_Node is begin return AMF.UML.Activity_Nodes.Collections.Wrap (AMF.Internals.Element_Collections.Wrap (AMF.Internals.Tables.UML_Attributes.Internal_Get_Redefined_Node (Self.Element))); end Get_Redefined_Node; ----------------- -- Get_Is_Leaf -- ----------------- overriding function Get_Is_Leaf (Self : not null access constant UML_Remove_Variable_Value_Action_Proxy) return Boolean is begin return AMF.Internals.Tables.UML_Attributes.Internal_Get_Is_Leaf (Self.Element); end Get_Is_Leaf; ----------------- -- Set_Is_Leaf -- ----------------- overriding procedure Set_Is_Leaf (Self : not null access UML_Remove_Variable_Value_Action_Proxy; To : Boolean) is begin AMF.Internals.Tables.UML_Attributes.Internal_Set_Is_Leaf (Self.Element, To); end Set_Is_Leaf; --------------------------- -- Get_Redefined_Element -- --------------------------- overriding function Get_Redefined_Element (Self : not null access constant UML_Remove_Variable_Value_Action_Proxy) return AMF.UML.Redefinable_Elements.Collections.Set_Of_UML_Redefinable_Element is begin return AMF.UML.Redefinable_Elements.Collections.Wrap (AMF.Internals.Element_Collections.Wrap (AMF.Internals.Tables.UML_Attributes.Internal_Get_Redefined_Element (Self.Element))); end Get_Redefined_Element; ------------------------------ -- Get_Redefinition_Context -- ------------------------------ overriding function Get_Redefinition_Context (Self : not null access constant UML_Remove_Variable_Value_Action_Proxy) return AMF.UML.Classifiers.Collections.Set_Of_UML_Classifier is begin return AMF.UML.Classifiers.Collections.Wrap (AMF.Internals.Element_Collections.Wrap (AMF.Internals.Tables.UML_Attributes.Internal_Get_Redefinition_Context (Self.Element))); end Get_Redefinition_Context; --------------------------- -- Get_Client_Dependency -- --------------------------- overriding function Get_Client_Dependency (Self : not null access constant UML_Remove_Variable_Value_Action_Proxy) return AMF.UML.Dependencies.Collections.Set_Of_UML_Dependency is begin return AMF.UML.Dependencies.Collections.Wrap (AMF.Internals.Element_Collections.Wrap (AMF.Internals.Tables.UML_Attributes.Internal_Get_Client_Dependency (Self.Element))); end Get_Client_Dependency; ------------------------- -- Get_Name_Expression -- ------------------------- overriding function Get_Name_Expression (Self : not null access constant UML_Remove_Variable_Value_Action_Proxy) return AMF.UML.String_Expressions.UML_String_Expression_Access is begin return AMF.UML.String_Expressions.UML_String_Expression_Access (AMF.Internals.Helpers.To_Element (AMF.Internals.Tables.UML_Attributes.Internal_Get_Name_Expression (Self.Element))); end Get_Name_Expression; ------------------------- -- Set_Name_Expression -- ------------------------- overriding procedure Set_Name_Expression (Self : not null access UML_Remove_Variable_Value_Action_Proxy; To : AMF.UML.String_Expressions.UML_String_Expression_Access) is begin AMF.Internals.Tables.UML_Attributes.Internal_Set_Name_Expression (Self.Element, AMF.Internals.Helpers.To_Element (AMF.Elements.Element_Access (To))); end Set_Name_Expression; ------------------- -- Get_Namespace -- ------------------- overriding function Get_Namespace (Self : not null access constant UML_Remove_Variable_Value_Action_Proxy) return AMF.UML.Namespaces.UML_Namespace_Access is begin return AMF.UML.Namespaces.UML_Namespace_Access (AMF.Internals.Helpers.To_Element (AMF.Internals.Tables.UML_Attributes.Internal_Get_Namespace (Self.Element))); end Get_Namespace; ------------------------ -- Get_Qualified_Name -- ------------------------ overriding function Get_Qualified_Name (Self : not null access constant UML_Remove_Variable_Value_Action_Proxy) return AMF.Optional_String is begin declare use type Matreshka.Internals.Strings.Shared_String_Access; Aux : constant Matreshka.Internals.Strings.Shared_String_Access := AMF.Internals.Tables.UML_Attributes.Internal_Get_Qualified_Name (Self.Element); begin if Aux = null then return (Is_Empty => True); else return (False, League.Strings.Internals.Create (Aux)); end if; end; end Get_Qualified_Name; ------------- -- Context -- ------------- overriding function Context (Self : not null access constant UML_Remove_Variable_Value_Action_Proxy) return AMF.UML.Classifiers.UML_Classifier_Access is begin -- Generated stub: replace with real body! pragma Compile_Time_Warning (Standard.True, "Context unimplemented"); raise Program_Error with "Unimplemented procedure UML_Remove_Variable_Value_Action_Proxy.Context"; return Context (Self); end Context; ------------------------ -- Is_Consistent_With -- ------------------------ overriding function Is_Consistent_With (Self : not null access constant UML_Remove_Variable_Value_Action_Proxy; Redefinee : AMF.UML.Redefinable_Elements.UML_Redefinable_Element_Access) return Boolean is begin -- Generated stub: replace with real body! pragma Compile_Time_Warning (Standard.True, "Is_Consistent_With unimplemented"); raise Program_Error with "Unimplemented procedure UML_Remove_Variable_Value_Action_Proxy.Is_Consistent_With"; return Is_Consistent_With (Self, Redefinee); end Is_Consistent_With; ----------------------------------- -- Is_Redefinition_Context_Valid -- ----------------------------------- overriding function Is_Redefinition_Context_Valid (Self : not null access constant UML_Remove_Variable_Value_Action_Proxy; Redefined : AMF.UML.Redefinable_Elements.UML_Redefinable_Element_Access) return Boolean is begin -- Generated stub: replace with real body! pragma Compile_Time_Warning (Standard.True, "Is_Redefinition_Context_Valid unimplemented"); raise Program_Error with "Unimplemented procedure UML_Remove_Variable_Value_Action_Proxy.Is_Redefinition_Context_Valid"; return Is_Redefinition_Context_Valid (Self, Redefined); end Is_Redefinition_Context_Valid; ------------------------- -- All_Owning_Packages -- ------------------------- overriding function All_Owning_Packages (Self : not null access constant UML_Remove_Variable_Value_Action_Proxy) return AMF.UML.Packages.Collections.Set_Of_UML_Package is begin -- Generated stub: replace with real body! pragma Compile_Time_Warning (Standard.True, "All_Owning_Packages unimplemented"); raise Program_Error with "Unimplemented procedure UML_Remove_Variable_Value_Action_Proxy.All_Owning_Packages"; return All_Owning_Packages (Self); end All_Owning_Packages; ----------------------------- -- Is_Distinguishable_From -- ----------------------------- overriding function Is_Distinguishable_From (Self : not null access constant UML_Remove_Variable_Value_Action_Proxy; N : AMF.UML.Named_Elements.UML_Named_Element_Access; Ns : AMF.UML.Namespaces.UML_Namespace_Access) return Boolean is begin -- Generated stub: replace with real body! pragma Compile_Time_Warning (Standard.True, "Is_Distinguishable_From unimplemented"); raise Program_Error with "Unimplemented procedure UML_Remove_Variable_Value_Action_Proxy.Is_Distinguishable_From"; return Is_Distinguishable_From (Self, N, Ns); end Is_Distinguishable_From; --------------- -- Namespace -- --------------- overriding function Namespace (Self : not null access constant UML_Remove_Variable_Value_Action_Proxy) return AMF.UML.Namespaces.UML_Namespace_Access is begin -- Generated stub: replace with real body! pragma Compile_Time_Warning (Standard.True, "Namespace unimplemented"); raise Program_Error with "Unimplemented procedure UML_Remove_Variable_Value_Action_Proxy.Namespace"; return Namespace (Self); end Namespace; end AMF.Internals.UML_Remove_Variable_Value_Actions;
reznikmm/matreshka
Ada
3,699
ads
------------------------------------------------------------------------------ -- -- -- Matreshka Project -- -- -- -- Open Document Toolkit -- -- -- -- Runtime Library Component -- -- -- ------------------------------------------------------------------------------ -- -- -- Copyright © 2014, Vadim Godunko <[email protected]> -- -- All rights reserved. -- -- -- -- Redistribution and use in source and binary forms, with or without -- -- modification, are permitted provided that the following conditions -- -- are met: -- -- -- -- * Redistributions of source code must retain the above copyright -- -- notice, this list of conditions and the following disclaimer. -- -- -- -- * Redistributions in binary form must reproduce the above copyright -- -- notice, this list of conditions and the following disclaimer in the -- -- documentation and/or other materials provided with the distribution. -- -- -- -- * Neither the name of the Vadim Godunko, IE nor the names of its -- -- contributors may be used to endorse or promote products derived from -- -- this software without specific prior written permission. -- -- -- -- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -- -- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -- -- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -- -- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -- -- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -- -- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED -- -- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -- -- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -- -- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -- -- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -- -- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- -- -- ------------------------------------------------------------------------------ -- $Revision$ $Date$ ------------------------------------------------------------------------------ with XML.DOM.Attributes; package ODF.DOM.Text_Custom1_Attributes is pragma Preelaborate; type ODF_Text_Custom1_Attribute is limited interface and XML.DOM.Attributes.DOM_Attribute; type ODF_Text_Custom1_Attribute_Access is access all ODF_Text_Custom1_Attribute'Class with Storage_Size => 0; end ODF.DOM.Text_Custom1_Attributes;
AaronC98/PlaneSystem
Ada
16,022
ads
------------------------------------------------------------------------------ -- 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; -- This implements the WebSocket protocol as defined in RFC-6455 with Ada.Strings.Unbounded; with AWS.Status; private with Ada.Calendar; private with Ada.Containers.Doubly_Linked_Lists; private with AWS.Client; private with Interfaces; package AWS.Net.WebSocket is use Ada.Strings.Unbounded; type Object is new Net.Socket_Type with private; type Object_Class is access all Object'Class; No_Object : constant Object'Class; type Kind_Type is (Unknown, Connection_Open, Text, Binary, Ping, Pong, Connection_Close); -- Data Frame Kind type Error_Type is (Normal_Closure, Going_Away, Protocol_Error, Unsupported_Data, No_Status_Received, Abnormal_Closure, Invalid_Frame_Payload_Data, Policy_Violation, Message_Too_Big, Mandatory_Extension, Internal_Server_Error, TLS_Handshake, Cannot_Resolve_Error, User_01, -- User's defined error code User_02, User_03, User_04, User_05); -- -- The following three methods are the one to override or redefine. In fact -- the default Send implementation should be ok for most usages. -- function Create (Socket : Socket_Access; Request : AWS.Status.Data) return Object'Class with Pre => Socket /= null; -- Create a new instance of the WebSocket, this is used by AWS internal -- server to create a default WebSocket if no other constructor are -- provided. It is also needed when deriving from WebSocket. -- -- This function must be registered via AWS.Net.WebSocket.Registry.Register procedure On_Message (Socket : in out Object; Message : String) is null; -- Default implementation does nothing, it needs to be overriden by the -- end-user. This is the callback that will get activated for every server -- incoming data. It is also important to keep in mind that the thread -- handling this WebSocket won't be released until the procedure returns. -- So the code inside this routine should be small and most importantly not -- wait for an event to occur otherwise other requests won't be served. procedure On_Message (Socket : in out Object; Message : Unbounded_String); -- Same a above but takes an Unbounded_String. This is supposed to be -- overriden when handling large messages otherwise a stack-overflow could -- be raised. The default implementation of this procedure to to call the -- On_Message above with a string. -- -- So either this version is overriden to handle the incoming messages or -- the one above if the messages are known to be small. procedure On_Open (Socket : in out Object; Message : String) is null; -- As above but activated when a WebSocket is opened procedure On_Close (Socket : in out Object; Message : String) is null; -- As above but activated when a WebSocket is closed procedure On_Error (Socket : in out Object; Message : String) is null; -- As above but activated when a WebSocket error is detected procedure Send (Socket : in out Object; Message : String; Is_Binary : Boolean := False); -- This default implementation just send a message to the client. The -- message is sent in a single chunk (not fragmented). procedure Send (Socket : in out Object; Message : Unbounded_String; Is_Binary : Boolean := False); -- Same as above but can be used for large messages. The message is -- possibly sent fragmented. procedure Send (Socket : in out Object; Message : Stream_Element_Array; Is_Binary : Boolean := True); -- As above but default is a binary message procedure Close (Socket : in out Object; Message : String; Error : Error_Type := Normal_Closure); -- Send a close frame to the WebSocket -- -- Client side -- procedure Connect (Socket : in out Object'Class; URI : String); -- Connect to a remote server using websockets. -- Socket can then be used to Send messages to the server. It will -- also receive data from the server, via the On_Message, when you call -- Poll function Poll (Socket : in out Object'Class; Timeout : Duration) return Boolean; -- Wait for up to Timeout seconds for some message. -- -- In the websockets protocol, a message can be split (by the server) -- onto several frames, so that for instance the server doesn't have to -- store the whole message in its memory. -- The size of those frames, however, is not limited, and they will -- therefore possibly be split into several chunks by the transport -- layer. -- -- These function waits until it either receives a close or an error, or -- the beginning of a message frame. In the latter case, the function -- will then block until it has receives all chunks of that frame, which -- might take longer than Timeout. -- -- The function will return early if it doesn't receive the beginning -- of a frame within Timeout seconds. -- -- When a full frame has been received, it will be sent to the -- Socket.On_Message primitive operation. Remember this might not be the -- whole message however, and you should check Socket.End_Of_Message to -- check. -- -- Return True if a message was processed, False if nothing happened during -- Timeout. -- -- Simple accessors to WebSocket state -- function Kind (Socket : Object) return Kind_Type; -- Returns the message kind of the current read data function Protocol_Version (Socket : Object) return Natural; -- Returns the version of the protocol for this WebSocket function URI (Socket : Object) return String; -- Returns the URI for the WebSocket function Origin (Socket : Object) return String; -- Returns the Origin of the WebSocket. That is the value of the Origin -- header of the client which has opened the socket. function Request (Socket : Object) return AWS.Status.Data; -- Returns Request of the WebSocket. That is the HTTP-request -- of the client which has opened the socket. function Error (Socket : Object) return Error_Type; -- Returns the current error type function End_Of_Message (Socket : Object) return Boolean; -- Returns True if we have read a whole message -- -- Socket's methods that must be overriden -- overriding procedure Shutdown (Socket : Object; How : Shutmode_Type := Shut_Read_Write); -- Shutdown the socket overriding function Get_FD (Socket : Object) return FD_Type; -- Returns the file descriptor associated with the socket overriding function Peer_Addr (Socket : Object) return String; -- Returns the peer name/address overriding function Peer_Port (Socket : Object) return Positive; -- Returns the port of the peer socket overriding function Get_Addr (Socket : Object) return String; -- Returns the name/address of the socket overriding function Get_Port (Socket : Object) return Positive; -- Returns the port of the socket overriding function Errno (Socket : Object) return Integer; -- Returns and clears error state in socket overriding function Get_Send_Buffer_Size (Socket : Object) return Natural; -- Returns the internal socket send buffer size. -- Do not confuse with buffers for the AWS.Net.Buffered operations. overriding function Get_Receive_Buffer_Size (Socket : Object) return Natural; -- Returns the internal socket receive buffer size. -- Do not confuse with buffers for the AWS.Net.Buffered operations. -- -- Socket reference -- type UID is range 0 .. 2**31; No_UID : constant UID; -- Not an UID, this is a WebSocket not yet initialized function Get_UID (Socket : Object) return UID; -- Returns a unique id for the given socket. The uniqueness for this socket -- is guaranteed during the lifetime of the application. private type Internal_State is record Kind : Kind_Type := Unknown; Errno : Interfaces.Unsigned_16 := Interfaces.Unsigned_16'Last; Last_Activity : Calendar.Time; end record; type Internal_State_Access is access Internal_State; type Protocol_State; type Protocol_State_Access is access Protocol_State; type Message_Data is record Mem_Sock : Net.Socket_Access; Timeout : Duration; end record; package Message_List is new Containers.Doubly_Linked_Lists (Message_Data); type Object is new Net.Socket_Type with record Socket : Net.Socket_Access; Id : UID; Request : AWS.Status.Data; Version : Natural; State : Internal_State_Access; P_State : Protocol_State_Access; Messages : Message_List.List; Mem_Sock : Net.Socket_Access; In_Mem : Boolean := False; Connection : AWS.Client.HTTP_Connection_Access; -- Only set when the web socket is initialized as a client. -- It is used to keep the connection open while the socket -- exists. end record; function Is_Client_Side (Socket : Object'Class) return Boolean is (AWS.Client."/=" (Socket.Connection, null)); -- True if this is a socket from client to server. Its messages -- then need to be masked. -- Routines read/write from a WebSocket, this handles the WebSocket -- protocol. overriding procedure Send (Socket : Object; Data : Stream_Element_Array; Last : out Stream_Element_Offset); overriding procedure Receive (Socket : Object; Data : out Stream_Element_Array; Last : out Stream_Element_Offset); -- Routine without implementation for a WebSocket overriding procedure Bind (Socket : in out Object; Port : Natural; Host : String := ""; Reuse_Address : Boolean := False; IPv6_Only : Boolean := False; Family : Family_Type := Family_Unspec) is null; overriding procedure Listen (Socket : Object; Queue_Size : Positive := 5) is null; overriding procedure Accept_Socket (Socket : Socket_Type'Class; New_Socket : in out Object) is null; overriding procedure Connect (Socket : in out Object; Host : String; Port : Positive; Wait : Boolean := True; Family : Family_Type := Family_Unspec) is null; overriding procedure Socket_Pair (S1, S2 : out Object) is null; overriding function Pending (Socket : Object) return Stream_Element_Count; overriding function Is_Listening (Socket : Object) return Boolean; overriding procedure Set_Send_Buffer_Size (Socket : Object; Size : Natural) is null; overriding procedure Set_Receive_Buffer_Size (Socket : Object; Size : Natural) is null; overriding procedure Free (Socket : in out Object); No_UID : constant UID := 0; No_Object : constant Object'Class := Object' (Net.Socket_Type with Socket => null, Id => No_UID, Request => <>, Version => 0, State => null, P_State => null, Messages => Message_List.Empty_List, Mem_Sock => null, Connection => null, In_Mem => False); -- Error codes corresponding to all errors Error_Code : constant array (Error_Type) of Interfaces.Unsigned_16 := (Normal_Closure => 1000, Going_Away => 1001, Protocol_Error => 1002, Unsupported_Data => 1003, No_Status_Received => 1005, Abnormal_Closure => 1006, Invalid_Frame_Payload_Data => 1007, Policy_Violation => 1008, Message_Too_Big => 1009, Mandatory_Extension => 1010, Internal_Server_Error => 1011, TLS_Handshake => 1015, Cannot_Resolve_Error => 0000, User_01 => 3000, User_02 => 3001, User_03 => 3002, User_04 => 3003, User_05 => 3004); procedure WebSocket_Exception (WebSocket : not null access Object'Class; Message : String; Error : Error_Type); -- Call when an exception is caught. In this case we want to send the -- error message, the close message and shutdown the socket. generic with procedure Receive (Socket : not null access Object'Class; Data : out Ada.Streams.Stream_Element_Array; Last : out Ada.Streams.Stream_Element_Offset); with procedure On_Success (Socket : Object_Class) is null; with procedure On_Error (Socket : Object_Class) is null; with procedure On_Free (Socket : in out Object_Class) is null; function Read_Message (WebSocket : in out Object_Class; Message : in out Ada.Strings.Unbounded.Unbounded_String) return Boolean; -- Process the current message on the socket. -- Return True if a complete message was read. -- Data is accumulated in Message, until the message is complete. At this -- stage, Socket.On_Message will be called. -- In case of error, other callbacks will be used as appropriate. end AWS.Net.WebSocket;
srunr/Continued-Fractions
Ada
9,949
adb
with Ada.Text_IO; with Ada.Real_Time; use Ada.Real_Time; with Extended_Real; with Extended_Real.IO; procedure Contfrac6 is type Real is digits 15; Start_time, End_time : Time; Exec_time : Time_Span; generic type Scalar is digits <>; nr_of_digits : Integer; with function A (N : in Natural) return Scalar; with function B (N : in Positive) return Scalar; with package Ext_Real is new Extended_Real(Scalar,nr_of_digits); Package Generic_Continued_Fraction is function Estimate (Steps : in Natural) return Ext_Real.e_Real; function e_Real_Value( str : in String) return Ext_Real.e_Real; package Generic_Continued_Fraction_IO is new Ext_Real.IO; end Generic_Continued_Fraction; Package body Generic_Continued_Fraction is function Estimate (Steps : in Natural) return Ext_Real.e_Real is use Ext_Real; function A (N : in Natural) return e_Real is (Make_Extended(A(N))); function B (N : in Positive) return e_Real is (Make_Extended(B(N))); Fraction : e_Real := Make_Extended(0.0); begin for N in reverse Natural range 1 .. Steps loop Fraction := B(N) / (A(N) + Fraction); end loop; return A (0) + Fraction; end Estimate; function e_Real_Value( str : in String) return Ext_Real.e_Real is rval : Ext_Real.e_Real := Ext_Real."+"(0); Last : Natural := 0; begin Generic_Continued_Fraction_IO.e_Real_Val(str, rval, Last); return rval; end e_Real_Value; end Generic_Continued_Fraction; generic type Scalar is digits <>; nr_of_digits : Integer; with package Ext_Real is new Extended_Real(Scalar, nr_of_digits); package Square_Root_Of_2 is function A (N : in Natural) return Scalar is (Scalar((if N = 0 then 1 else 2))); function B (N : in Positive) return Scalar is (Scalar(1)); package Ext_Real_Continued_Fraction is new Generic_Continued_Fraction(Scalar, nr_of_digits, A, B, Ext_Real); end Square_Root_Of_2; generic type Scalar is digits <>; nr_of_digits : Integer; with package Ext_Real is new Extended_Real(Scalar, nr_of_digits); package Napiers_Constant is function A (N : in Natural) return Scalar is (Scalar(if N = 0 then 2 else N)); function B (N : in Positive) return Scalar is (Scalar(if N = 1 then 1 else N-1)); package Ext_Real_Continued_Fraction is new Generic_Continued_Fraction(Scalar, nr_of_digits, A, B, Ext_Real); end Napiers_Constant; generic type Scalar is digits <>; nr_of_digits : Integer; with package Ext_Real is new Extended_Real(Scalar,nr_of_digits); package Pi is function A (N : in Natural) return Scalar is (Scalar(if N = 0 then 3 else 6)); function B (N : in Positive) return Scalar is (Scalar(((2 * N - 1) ** 2))); package Ext_Real_Continued_Fraction is new Generic_Continued_Fraction(Scalar, nr_of_digits, A, B, Ext_Real); end Pi; generic type Scalar is digits <>; nr_of_digits : Integer; with package Ext_Real is new Extended_Real(Scalar,nr_of_digits); package Pi2 is -- See https://en.wikipedia.org/wiki/Generalized_continued_fraction function A (N : in Natural) return Scalar is (Scalar((if N = 0 then 0 else 2 * N - 1))); function B (N : in Positive) return Scalar is (Scalar(if N = 0 then 0 else (if N = 1 then 4 else (N - 1)**2))); package Ext_Real_Continued_Fraction is new Generic_Continued_Fraction(Scalar, nr_of_digits, A, B, Ext_Real); end Pi2; generic type Scalar is digits <>; nr_of_digits : Integer; with package Ext_Real is new Extended_Real(Scalar,nr_of_digits); package Golden_Ratio is function A (N : in Natural) return Scalar is (Scalar(1)); function B (N : in Positive) return Scalar is (Scalar(1)); package Ext_Real_Continued_Fraction is new Generic_Continued_Fraction(Scalar, nr_of_digits, A, B, Ext_Real); end Golden_Ratio; use Ada.Text_IO; begin -- Contfrac declare package Ext_Real_Square_Root_Of_2 is new Extended_Real(Real,30); use Ext_Real_Square_Root_Of_2; package Ext_Real_Square_Root_Of_2_IO is new Ext_Real_Square_Root_Of_2.IO; use Ext_Real_Square_Root_Of_2_IO; package Ext_Square_Root_Of_2 is new Square_Root_Of_2(Real, 30, Ext_Real_Square_Root_Of_2); use Ext_Square_Root_Of_2; SquareRootOf2_30 : constant String := "1.41421356237309504880168872421"; -- source : https://www.wolframalpha.com/input/?i=sqr%282%29+30+digits begin Put("Square_Root_Of_2(digits: " & Ext_Real_Square_Root_Of_2.Desired_Decimal_Digit_Precision'Image & ") = "); Start_time := clock; Put(e_Real_Image(Ext_Square_Root_Of_2.Ext_Real_Continued_Fraction.Estimate(200))); End_time := clock; Exec_Time := End_Time - Start_Time; Put_Line(" Execution time : " & Duration'Image (To_Duration(Exec_Time)) & " seconds "); Put_line("SquareRootOf2 constant = " & SquareRootOf2_30); Put_Line("SquareRootOf2_30error : " & Ext_Real_Square_Root_Of_2_IO.e_Real_Image(Ext_Square_Root_Of_2.Ext_Real_Continued_Fraction.Estimate(200) - Ext_Square_Root_Of_2.Ext_Real_Continued_Fraction.e_Real_Value(SquareRootOf2_30))); new_line; end; declare package Ext_Real_Napiers_Constant is new Extended_Real(Real, 60); use Ext_Real_Napiers_Constant; package Ext_Real_Napiers_Constant_IO is new Ext_Real_Napiers_Constant.IO; use Ext_Real_Napiers_Constant_IO; package Ext_Napiers_Constant is new Napiers_Constant(Real, 60, Ext_Real_Napiers_Constant); use Ext_Napiers_Constant; NapiersConstant60 : constant String := "2.71828182845904523536028747135266249775724709369995957496697"; -- source : https://www.wolframalpha.com/input/?i=exp%281%29+60+digits begin Put("Napiers_Constant(digits: " & Ext_Real_Napiers_Constant.Desired_Decimal_Digit_Precision'Image & ") = "); Start_time := clock; Put (e_Real_Image(Ext_Napiers_Constant.Ext_Real_Continued_Fraction.Estimate(10000))); End_time := clock; Exec_Time := End_Time - Start_Time; Put_Line (" Execution time : " & Duration'Image (To_Duration(Exec_Time)) & " seconds "); Put_line("NapiersConstant constant = " & NapiersConstant60); Put_Line("NapiersConstant60error : " & Ext_Real_Napiers_Constant_IO.e_Real_Image(Ext_Napiers_Constant.Ext_Real_Continued_Fraction.Estimate(10000) - Ext_Napiers_Constant.Ext_Real_Continued_Fraction.e_Real_Value(NapiersConstant60))); new_line; end; declare package Ext_Real_Pi is new Extended_Real(Real,90); use Ext_Real_Pi; package Ext_Real_Pi_IO is new Ext_Real_Pi.IO; use Ext_Real_Pi_IO; package Ext_Pi is new Pi(Real, 90, Ext_Real_Pi); use Ext_Pi; Pi90 : constant String := "3.14159265358979323846264338327950288419716939937510582097494459230781640628620899862803483"; -- source : https://www.wolframalpha.com/input/?i=N%5BPi%2C+90%5D begin Put("Pi(digits: " & Ext_Real_Pi.Desired_Decimal_Digit_Precision'Image & ") = "); Start_time := clock; Put (e_Real_Image(Ext_Pi.Ext_Real_Continued_Fraction.Estimate (10000))); End_time := clock; Exec_Time := End_Time - Start_Time; Put_Line (" Execution time : " & Duration'Image (To_Duration(Exec_Time)) & " seconds "); Put_line("Pi constant = " & Pi90); Put_Line("Pi90error : " & Ext_Real_Pi_IO.e_Real_Image(Ext_Pi.Ext_Real_Continued_Fraction.Estimate(10000) - Ext_Pi.Ext_Real_Continued_Fraction.e_Real_Value(Pi90))); new_line; end; declare package Ext_Real_Pi2 is new Extended_Real(Real,90); use Ext_Real_Pi2; package Ext_Real_Pi2_IO is new Ext_Real_Pi2.IO; use Ext_Real_Pi2_IO; package Ext_Pi2 is new Pi2(Real, 90, Ext_Real_Pi2); use Ext_Pi2; Pi90 : constant String := "3.14159265358979323846264338327950288419716939937510582097494459230781640628620899862803483"; -- source : https://www.wolframalpha.com/input/?i=N%5BPi%2C+90%5D begin Put("Pi2(digits: " & Ext_Real_Pi2.Desired_Decimal_Digit_Precision'Image & ") = "); Start_time := clock; Put (e_Real_Image(Ext_Pi2.Ext_Real_Continued_Fraction.Estimate(10000))); End_time := clock; Exec_Time := End_Time - Start_Time; Put_Line (" Execution time : " & Duration'Image (To_Duration(Exec_Time)) & " seconds "); Put_line("Pi constant = " & Pi90); Put_Line("Pi290error : " & Ext_Real_Pi2_IO.e_Real_Image(Ext_Pi2.Ext_Real_Continued_Fraction.Estimate(10000) - Ext_Pi2.Ext_Real_Continued_Fraction.e_Real_Value(Pi90))); new_line; end; declare package Ext_Real_Golden_Ratio is new Extended_Real(Real,50); use Ext_Real_Golden_Ratio; package Ext_Real_Golden_Ratio_IO is new Ext_Real_Golden_Ratio.IO; use Ext_Real_Golden_Ratio_IO; package Ext_Golden_Ratio is new Golden_Ratio(Real, 50, Ext_Real_Golden_Ratio); use Ext_Golden_Ratio; GoldenRatio50 : constant String := "1.6180339887498948482045868343656381177203091798058"; -- source: https://www.wolframalpha.com/input/?i=N%5BGoldenRatio%2C+50%5D begin Put("Golden_Ratio(digits: " & Ext_Real_Golden_Ratio.Desired_Decimal_Digit_Precision'Image & ") = "); Start_time := clock; Put (e_Real_Image(Ext_Golden_Ratio.Ext_Real_Continued_Fraction.Estimate(20000))); End_time := clock; Exec_Time := End_Time - Start_Time; Put_Line (" Execution time : " & Duration'Image (To_Duration(Exec_Time)) & " seconds "); Put_line("Golden_Ratio constant = " & GoldenRatio50); Put_Line("GoldenRatio50error : " & Ext_Real_Golden_Ratio_IO.e_Real_Image(Ext_Golden_Ratio.Ext_Real_Continued_Fraction.Estimate(20000) - Ext_Golden_Ratio.Ext_Real_Continued_Fraction.e_Real_Value(GoldenRatio50))); end; end Contfrac6;
docandrew/troodon
Ada
2,526
ads
pragma Ada_2012; pragma Style_Checks (Off); with Interfaces.C; use Interfaces.C; with sys_types_h; limited with bits_types_struct_iovec_h; package bits_uio_ext_h is RWF_HIPRI : constant := 16#00000001#; -- /usr/include/bits/uio-ext.h:45 RWF_DSYNC : constant := 16#00000002#; -- /usr/include/bits/uio-ext.h:46 RWF_SYNC : constant := 16#00000004#; -- /usr/include/bits/uio-ext.h:47 RWF_NOWAIT : constant := 16#00000008#; -- /usr/include/bits/uio-ext.h:48 RWF_APPEND : constant := 16#00000010#; -- /usr/include/bits/uio-ext.h:49 -- Operating system-specific extensions to sys/uio.h - Linux version. -- Copyright (C) 1996-2021 Free Software Foundation, Inc. -- This file is part of the GNU C Library. -- The GNU C Library is free software; you can redistribute it and/or -- modify it under the terms of the GNU Lesser General Public -- License as published by the Free Software Foundation; either -- version 2.1 of the License, or (at your option) any later version. -- The GNU C Library is distributed in the hope that it will be useful, -- but WITHOUT ANY WARRANTY; without even the implied warranty of -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -- Lesser General Public License for more details. -- You should have received a copy of the GNU Lesser General Public -- License along with the GNU C Library; if not, see -- <https://www.gnu.org/licenses/>. -- Read from another process' address space. function process_vm_readv (uu_pid : sys_types_h.pid_t; uu_lvec : access constant bits_types_struct_iovec_h.iovec; uu_liovcnt : unsigned_long; uu_rvec : access constant bits_types_struct_iovec_h.iovec; uu_riovcnt : unsigned_long; uu_flags : unsigned_long) return sys_types_h.ssize_t -- /usr/include/bits/uio-ext.h:29 with Import => True, Convention => C, External_Name => "process_vm_readv"; -- Write to another process' address space. function process_vm_writev (uu_pid : sys_types_h.pid_t; uu_lvec : access constant bits_types_struct_iovec_h.iovec; uu_liovcnt : unsigned_long; uu_rvec : access constant bits_types_struct_iovec_h.iovec; uu_riovcnt : unsigned_long; uu_flags : unsigned_long) return sys_types_h.ssize_t -- /usr/include/bits/uio-ext.h:37 with Import => True, Convention => C, External_Name => "process_vm_writev"; -- Flags for preadv2/pwritev2. end bits_uio_ext_h;
reznikmm/matreshka
Ada
4,675
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.Chart_Title_Elements; package Matreshka.ODF_Chart.Title_Elements is type Chart_Title_Element_Node is new Matreshka.ODF_Chart.Abstract_Chart_Element_Node and ODF.DOM.Chart_Title_Elements.ODF_Chart_Title with null record; overriding function Create (Parameters : not null access Matreshka.DOM_Elements.Element_L2_Parameters) return Chart_Title_Element_Node; overriding function Get_Local_Name (Self : not null access constant Chart_Title_Element_Node) return League.Strings.Universal_String; overriding procedure Enter_Node (Self : not null access Chart_Title_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 Chart_Title_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 Chart_Title_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_Chart.Title_Elements;
jscparker/math_packages
Ada
31,677
ads
-- PACKAGE Extended_Real -- -- package Extended_Real provides: -- An arbitrary precision floating-point data type: e_Real. -- -- Lower limit on precision is 28 decimals. No upper limit is -- enforced. All internal arithmetic is done on 64-bit Integers, -- so it's most efficient on 64-bit CPU's. The package is Pure. -- Floating point attributes (Ada 95) are implemented as function -- calls. The package exports standard floating point operators: -- "*", "+", "/", "**", "Abs", "<", ">", "<=" , ">=", etc. -- The standard operators make it easy to modify existing code to -- use extended precision arithmetic. Procedure calls Mult(X,Y) and -- Square(X) are also provided. They do multiplication "in-place", -- (overwrite X with the result) and are somewhat faster than the -- equivalent X := X*Y, and X := X*X. -- -- To set the precision search below for: -- -- Desired_Decimal_Digit_Precision -- -- package Extended_Real.Elementary_Functions provides: -- Sin, Cos, Sqrt, Arcsin, Arccos, Arctan, Log, Exp, Reciprocal (1/x), -- Reciprocal_Nth_Root (x to the power of -1/N), Divide, and "**" for -- e_Real arguments and e_Real exponents. Routines are Ada 95'ish. -- -- package e_Derivs provides: -- Extended precision routines for taking high order derivatives of -- functions. Functions made from "*", "+", "/", "**", Sin, Cos, -- Sqrt, Arcsin, Arccos, Arctan, Log, Exp, Compose = f(g(x)), -- and Reciprocal can be differentiated to order specified by user. -- -- package Extended_Real.IO provides: -- Text to extended-precision e_Real translation routines, and -- e_Real to Text translation routines. -- -- package Extended_Real.Rand provides: -- a (very) basic Random Number Generator. Really just for making -- test vectors. -- -- procedure e_real_demo_1.adb is: -- an introductory routine that demonstrates use of Extended_Real. -- -- procedure e_function_demo_1.adb is: -- an introductory routine that demonstrates use of -- Extended_Real.Elementary_Functions. -- -- procedure e_jacobi_eigen_demo_1.adb demonstrates: -- extended-precision eigen-decomposition on Hilbert's matrix using -- package e_Jacobi_Eigen. -- -- package e_Jacobi_Eigen is: -- a Jabobi iterative eigen-decomposition routine -- that shows how easy it is to upgrade a floating point routine -- to extended precision. e_Jacobi_Eigen uses package Extended_Real. -- -- good optimization on gcc/GNAT: -- -gnatNp -O3 -march="your machine architecture" -funroll-loops -ffast-math -- (sometimes:-ftree-vectorize -funroll-all-loops -falign-loops=4, -- -falign-loops=3, or -frename-registers are worth trying.) -- -- latest GNAT (gcc 4.3) try -- gnatmake -gnatNp -O3 -march=native -mtune=native -funroll-loops -ffast-math -- -- Always do a preliminary run which exercizes Assertions, and other Checks: -- -gnato -gnatV -gnata -- -- -- Because precision is arbitrary, Extended_Real is not specially -- optimized for any particular precision. The chosen design works best -- in the limit of 100's of decimal digits. If the package had been -- designed for 32 decimal digits of precision, then almost every feature -- of the design would have been different. On the other hand, performance -- seems to be respectable on 64-bit CPU's even at the lower limit (eg -- 28 or 38 decimal digits). (Comparison is with Intel's machine-optimized -- 32 decimal-digit floating point: i.e. Intel Fortran Real*16 on an Intel -- 64-bit CPU.) 32 digit floating point is probably the most often used -- (and most often needed) extended precision floating point. -- Most Fortrans (including the gcc Fortran) don't offer anything higher -- than 18 digit floating point. -- -- Common applications: -- 0. Estimation of error in lower precision floating-point calculations. -- 1. Evaluation of constants for math routines and Table-driven algorithms. -- 2. Evaluation of series solutions of special function, especially when -- the terms are constructed of large factorials and exponentials. -- 3. Evaluation of recurrance relations for special functions. -- -- Generics greatly reduce the work you have to do in modifying programs -- to use extended floating point: -- -- 1. place generic formal declarations -- of the required extended arithmetic functions at the the top of the -- package or subprogram to be modified. -- -- 2. use the unary "-" and "+" routines that convert Real to Extended: -- -- so that declarations -- Number : Generic_Formal_Type := +1.234; -- and statements like -- Z := (+4.567834E+012) * X; -- will be acceptible to both Real and Extended types. -- -- Underflows to Zero. Overflows to Positive or Negative infinity. I am -- still trying to decide if the Infinities are worth the trouble, but the -- trouble isn't great and there seem to be benefits. Sometimes you can -- put off worrying about overflow in intermediate calculation and test -- for it at the end by testing for Positive_Infinity. There are no NaNs. -- -- At the expense of purity, error messages using text_io can be -- re-enabled in the body - see top of body of Extended_Real. -- --*************************************************************************** -- -- SECTION I. -- -- Constants and overflow/underflow/constraint_error conventions. -- -- To test an arbitrary X : e_Real to see if X is Zero or infinity use the -- function Are_Equal (X, Zero) etc. It's written to make the test efficient. -- -- Underflows are to (unsigned) Zero; overflows to (signed) infinity: -- -- Infinity here means a finite number that is too large to represent -- in the floating point, and whose inverse is too small to represent in -- floating point. The following conventions seemed sensible. Treat inf's -- as Constraint Errors if uneasy with them. Assuming X is a positive e_Real: -- 0*inf = 0, inf * inf = inf, X / inf = 0, |X| * -inf = -inf, -- inf + inf = inf, X + inf = inf, -inf * inf = -inf, X - inf = -inf, -- inf > X = True, -inf < X = True, inf > -inf = True, -- (inf = -inf) = False -- -- Constraint_Error: -- -- The following ops have no sensible meaning, so Constraint_Error (ce) is -- raised. -- inf - inf => ce, inf / inf => ce, X / 0 => ce, inf / 0 => ce, -- inf < inf => ce. -- --*************************************************************************** -- SECTION II. -- -- Standard arithmetic operators. -- -- The arithmetic performed by these routines is supposed to be correct out -- to the number of decimals specified by Desired_Decimal_Digit_Precision, -- which you type in at the beginning of the spec. But the arithmetic is -- actually performed on digits well beyond this limit in order to guarantee -- this level of accuracy. The values -- held by these extra digits (guard digits) are usually almost correct. -- None of the following operators rounds away these guard digits. -- Rounding is done explicitly by calling Round_Away_Smallest_Guard_Digit(). -- In particular, none of the following comparison operators ("<", ">=", etc.) -- rounds away guard digits of operands before performing the comparison. -- All of them perform their comparisons out to the final guard digit. -- To reduce much confusion, I decided to leave rounding entirely up to the -- user, with Round_Away_.... Whether it's best to round or not -- depends on the algorithm. In a lot of algorithms it's better to -- round before you use the "Are_Equal" operator, and better not to round -- when you use the "<" and ">" operators. -- -- "=" or Are_Equal(X, Zero) is the most efficient way to find out if X -- is Zero. Same for Infinity. X < Zero is the efficient way find Sign of X. -- X > Zero is efficient way to test positivity of X. Zero < X and -- Zero > X are also handled efficiently. -- --*************************************************************************** -- SECTION III. -- -- Routines for conversion from Real to e_Real and back again. -- -- Makes it easy to write generics that can be instantiated with either -- conventional floating point of this extended floating point. -- The unary + and - are here to make it easier to convert programs from -- ordinary floating point to extended, by making it easy to replace -- -- X : Generic_Float_Type := 1.2345; --here instantiate w/ Float. -- X := 4.5678 * Y; --here instantiate w/ Float. -- -- with -- -- X : Generic_Float_Type := +1.2345; --here instantiate w/ e_Real or Float. -- X := (+4.5678) * Y; --same here. -- -- Now you can instantiate the generic with either e_Real or Float, -- (but you have to add the unary "+" to the list of generic formals.) -- --*************************************************************************** -- SECTION V. -- -- Real * Extended operations. -- -- More efficient operations. The "Real" is not your ordinary real, but -- something in the range 0.0 .. Radix-1, and integer valued, though it -- can have an negative or positive exponent. So it's not very appropriate -- for general use; -- -- The Real * Extended operations can be particularly efficient if -- the Real number is in the same range as a Digit, ie, 0..Radix-1. -- So we define a type e_Digit, a single real number with an -- exponent. These mixed multiplication "*" and "/" ops are used by the -- ascii to real_extended and real_extended to ascii translators, -- and by Newton's method calculations of elementary functions. -- This efficiency only comes if the real number can be represented by -- a single digit: integer values in the range 0..Radix-1, (times -- an exponent in a power-of-2 Radix. e.g. 0.5 is OK, 1.0/3.0 is not.) -- Make_e_Digit will raise a constraint error if the range of the -- intended real number is wrong. -- --********************************************************************** -- INTERNAL FORMAT OF e_Real -- -- Internally the extended numbers are stored in such a way that the -- value of e_Real number X is -- -- Max -- X = Radix**Exp * SUM {Radix**(-I) * Digit(I)}. -- I=0 -- -- Externally, the user sees e_Real (via the Exponent, and Fraction -- attribute functions) as tho' it were normalized. In other words, the -- value of X is -- -- Max -- X = Radix**Exp * SUM {Radix**(-I-1) * Digit(I)} -- I=0 -- -- Exp is called the "normalized" exponent. If Exp is the normalized exponent -- then, say, a binary number would be written: -- -- 0.111011010001 * 2**(Exp). -- -- In other words the first binary digit in the mantissa is of power 2**(-1). -- It is important to know this because the function Real'Exponent(x) returns -- the *normalized* exponent, and the function Real'Fraction(x) returns -- x * 2**(-Exp) where Exp is the normalized exponent. So in the above case, -- 'Fraction would return 0.111011010001. -- Also, in normalized form, the first binary digit of the mantissa is always -- non-zero. --*************************************************************************** generic type Real is digits <>; -- Make it 15 digits or greater. This is checked. -- This is usually the type you are going to replace with e_Real. package Extended_Real is pragma Pure (Extended_Real); pragma Assert (Real'Digits >= 15); type e_Real is private; -- The extended precision floating pt type. -- Instructions: -- The only things that need to be adjusted by the user are -- -- Desired_Decimal_Digit_Precision -- and -- Desired_No_Of_Bits_In_Radix -- -- The 2 parameters follow next, along with instructions. Desired_Decimal_Digit_Precision : constant := 28; -- If you request 28 Decimal Digits, you usually get 29 or more. -- If you request 29 to 37 Decimal Digits, you usually get 38 or more. -- If you request 38 to 46 Decimal Digits, you usually get 47 or more. -- If you request 47 to 55 Decimal Digits, you usually get 56 or more. -- (And so on, in jumps of 9. Assumes Desired_No_Of_Bits_In_Radix = 30.) -- -- The simple operators "*", "+", "/" usually give the best precision. -- They should get the 1st guard digit right, and by themselves: -- If you request 28 Decimal Digits, they're good to about 37 Decimal Digits. -- If you request 37 Decimal Digits, they're good to about 46 Decimal Digits. -- -- Large complicated floating point computations will usually get both -- guard digits wrong and additional error will accumulate, so: -- If you request 28 Decimal Digits, ultimately expect <28 Decimal Digits. -- -- Lower limit on Desired_Decimal_Digit_Precision is 28. pragma Assert (Desired_Decimal_Digit_Precision >= 28); Desired_No_Of_Bits_In_Radix : constant := 30; -- Anything under 31 works, but should be adjusted for best performance: -- 30 is good if Desired_Decimal_Digit_Precision is 28 to 55. -- 29 is good standard setting (use it when Desired_Decimal_Digit_Precision > 55). -- 28 is good if Desired_Decimal_Digit_Precision >> 200. (But experiment.) -- -- 30 is necessary if you want the minimum decimal digits setting: 28. -- (If you choose 29 bits in Radix, you will get more decimals than you expect.) pragma Assert (Desired_No_Of_Bits_In_Radix <= 30); type e_Int is range -2**31+1 .. 2**31-1; subtype e_Integer is e_Int'Base; -- Type of Exponent. Also takes the place of Universal_Integer in the -- "attribute" functions defined below for e_Real. -- Keep it 32-bit. Smallest usually fastest. pragma Assert (e_Integer'Size <= 32); -- try fit e_Reals into small space; not essential, but Larger is slower. Zero : constant e_Real; One : constant e_Real; Positive_Infinity : constant e_Real; Negative_Infinity : constant e_Real; -- To test an arbitrary X : e_Real to see if X is Zero or infinity use the -- function: Are_Equal (X, Zero), or X = Zero etc. Testing for Zero is fast. -- Infinity here means a finite number that is too large to represent in the -- floating point, and whose inverse is too small to represent in floating -- point Zero is positive. -- SECTION II. Standard operators. -- -- To reduce much confusion, rounding is entirely up to the -- user, with Round_Away_Guard_Digits(). Whether it's best to round or not -- depends on the algorithm. For example, in some cases it is better to -- round before you use the "Are_Equal" operator, and better not to round -- when you use the "<" and ">" operators. (see intro.) function "*" (X, Y : e_Real) return e_Real; -- inline can slow it down. function "+" (X, Y : e_Real) return e_Real; -- inline can slow it down. function "-" (X, Y : e_Real) return e_Real; function "+" (X : e_Real) return e_Real; function "-" (X : e_Real) return e_Real; function "/" (X, Y : e_Real) return e_Real; function "**"(X : e_Real; N : Integer) return e_Real; procedure Square (X : in out e_Real); -- Same as X := X * X; (but usually faster if < 120 decimal digits.) procedure Mult (X : in out e_Real; Y : in e_Real); -- Same as X := X * Y; (but usually faster if < 120 decimal digits.) function "Abs" (X : e_Real) return e_Real; function Are_Equal (X, Y : e_Real) return Boolean; -- Return true only if -- equality is exact in the cases of Zero and the 2 infinities. -- Are_Equal(X, Zero) is the most efficient way to find out if X is Zero. -- Same for Infinity. X < Zero is the efficient way find Sign of X. -- X > Zero is efficient way to test positivity of X. Zero < X etc. OK too. function "<" (X, Y : e_Real) return Boolean; function "<=" (X, Y : e_Real) return Boolean; function ">" (X, Y : e_Real) return Boolean; function ">=" (X, Y : e_Real) return Boolean; function "=" (X, Y : e_Real) return Boolean renames Are_Equal; function Are_Not_Equal (X, Y : e_Real) return Boolean; -- not Are_Equal -- SECTION III. Conversions between Real to e_Real. (see intro.) function Make_Real (X : e_Real) return Real; function Make_Extended (X : Real) return e_Real; function "+" (X : Real) return e_Real renames Make_Extended; function "-" (X : Real) return e_Real; -- The above 3 functions are identical, except "-" changes sign of X. -- Makes it easy to write generics that can be instantiated with either -- conventional floating point of this extended floating point, via: -- X : Generic_Float_Type := +1.2345; function "+" (X : Integer) return e_Real; -- Only works in range of Real (15 digits usually). -- -- raises Constraint_Error -- -- if X is greater than about 10**Real'Digits. -- So X = 2**62 raises Constraint_Error if Real'Digits = 15. -- It's really just for making e_Reals out of small ints: +7. -- SECTION IV. Ada9X oriented attributes. -- -- Below: Machine attributes and the function calls (like Truncation). -- More information on the machine model is given in the introduction. -- The machine model is static, so none of the Machine oriented attributes, -- and none of the functions reflect varying precision. (see intro.) -- -- Written in the spirit of the Ada attributes, but the fit is never -- perfect. function Remainder (X, Y : e_Real) return e_Real; function Copy_Sign (Value, Sign : e_Real) return e_Real; function e_Real_Machine_Rounds return Boolean; function e_Real_Machine_Overflows return Boolean; function e_Real_Signed_Zeros return Boolean; function e_Real_Denorm return Boolean; -- These functions always return False. function e_Real_Machine_Emax return e_Integer; function e_Real_Machine_Emin return e_Integer; function e_Real_Machine_Mantissa return e_Integer; -- Always returns Mantissa'Length: all the digits including guards. -- -- NOT binary digits, NOT decimal digits. function e_Real_Machine_Radix return Real; -- Usually 2.0**29 or 2.0**30 for Integer digits; 2.0**24 for Flt pt digits. -- Returns: No_of_Bits_in_Radix (as a Real type). function Leading_Part (X : e_Real; Radix_Digits : e_Integer) return e_Real; -- Example: to set to zero all but the first digit of X use -- First_Digit := Leading_Part (X, 1); function Exponent (X : e_Real) return e_Integer; -- By convention return 0 for Zero. Else return nomalized Expon. -- Returns Max_Exponent+2 for the 2 infinities. -- NOT decimal, and NOT binary Exponent. function Fraction (X : e_Real) return e_Real; function Compose (Fraction : e_Real; Exponent : e_Integer) return e_Real; function Scaling ( X : e_Real; Adjustment : e_Integer) return e_Real; -- Chop off fractional parts. -- -- Rounding, Unbiased_Rounding, Ceiling, Floor return e_Real -- with Zero fractions. function Rounding (X : e_Real) return e_Real; function Unbiased_Rounding (X : e_Real) return e_Real; function Truncation (X : e_Real) return e_Real; function Ceiling (X : e_Real) return e_Real; function Floor (X : e_Real) return e_Real; -- Round away guard digits. -- -- function Machine rounds away the smallest Guard digit. -- There's no one right way to round away Guard Digits or choose -- Model_Epsilon's. Doesn't follow the Ada95 model for rounding -- 64-bit floats. That model doesn't seem to fit very well. function e_Real_Model_Epsilon return e_Real; -- At present this calls: e_Real_Model_Epsilon_2 which is -- 1 unit in the 3rd smallest digit. (The 3rd smallest digit -- is the 1st digit that is larger than the 2 guard digits.) function e_Real_Machine_Epsilon return e_Real; -- At present this calls: e_Real_Model_Epsilon_1 which is -- 1 unit in the 2nd smallest digit. (The 2nd smallest digit -- is the larger of the 2 guard digits.) function Machine (X : e_Real) return e_Real; -- This calls: -- Round_Away_Smallest_Guard_Digit -- function Round_Away_Smallest_Guard_Digit (X : e_Real) return e_Real; function e_Real_Model_Epsilon_1 return e_Real; -- One unit in the 2nd smallest digit. function e_Real_Model_Epsilon_2 return e_Real; -- One unit in the 3rd smallest digit. (The smallest digit that -- is *not* a Guard_Digit. -- -- Guard_Digits = 2 always; assume neither of them is correct: -- if there's 3 digits of Radix 2^30 then eps_2 is 2^(-30). -- if there's 4 digits of Radix 2^30 then eps_2 is 2^(-60). -- if there's 5 digits of Radix 2^30 then eps_2 is 2^(-90) or about 10**-27. -- -- So Eps_2 is the smallest number s/t eps_2+.999999999999 /= .999999999999 -- when you remove both guard digits. -- SECTION V. Digit * Extended operations. -- -- More efficient operations. "Digit" is not your ordinary real, but -- something in the range 0.0 .. Radix-1.0, and integral valued, though it -- can have a negative exponent. So the following is not very appropriate -- for general use; in the '83 version we export it so that it can be used by -- elementary function packages. type e_Digit is private; function "*" (X : e_Digit; Y : e_Real) return e_Real; function "/" (X : e_Real; Y : e_Digit) return e_Real; function Sum_Of (X : e_Digit; Y : e_Real) return e_Real; function "+" (X : e_Digit; Y : e_Real) return e_Real renames Sum_Of; function Scaling (X : e_Digit; Adjustment : e_Integer) return e_Digit; -- Multiply X by Radix**N where N = Adjustment. function Make_Extended (X : e_Digit) return e_Real; function Make_e_Digit (X : Real) return e_Digit; -- X must be a whole number: 0.0, 1.0, 2.0 etc. in the range 0..Radix-1, -- times some integer power of the Radix. So 0.5 is OK, but not 1/3. function Number_Of_Guard_Digits return e_Integer; -- Constant. To get number of digits that are being correctly calculated -- (by conservative estimates) use -- No_Correct_Digits = Present_Precision - Number_Of_Guard_Digits. function Minimum_No_Of_Digits_Allowed return e_Integer; -- Constant. Includes guard digits. private -- -- SECTION VII. Make the Data structure for e_Real. -- -- Using 32-bit ints for the Digits: (don't do it) --No_Of_Usable_Bits_In_Digit : constant := 31; -- bad idea; lots of trouble. --No_Of_Bits_In_Radix : constant := 13; -- can't use 14 or > -- Using 64-bit floats for the Digits: (don't bother) --No_Of_Usable_Bits_In_Digit : constant := 53; -- if using flt pt Mantissa (slow) --No_Of_Bits_In_Radix : constant := 24; -- Using 64-bit ints for the Digits: No_Of_Usable_Bits_In_Digit : constant := 63; -- Integer; must allow neg. vals No_Of_Bits_In_Radix : constant := Desired_No_Of_Bits_In_Radix; -- 30 is good if Desired_Decimal_Digit_Precision is 28 to 55. -- 29 is good standard setting (especially: Desired_Decimal_Digit_Precision > 55). -- 28 is good if Desired_Decimal_Digit_Precision is in the 100's. (But experiment.) Sums_Per_Carry : constant := 2**(No_Of_Usable_Bits_In_Digit-2*No_Of_Bits_In_Radix)-1; -- Sums_Per_Carry : This is number of sums you can accumulate during -- multiplication before the carrys need to be performed. -- -- You can do a large number of X*Y < Radix*Radix products, and then sum -- (Sums_Per_Carry+1) of them before a Carry is necessary in multiplication. -- a implies b is same as not (a) or b: pragma Assert (not (No_Of_Bits_In_Radix = 30) or Sums_Per_Carry <= 8-1); pragma Assert (not (No_Of_Bits_In_Radix = 29) or Sums_Per_Carry <= 32-1); pragma Assert (not (No_Of_Bits_In_Radix = 28) or Sums_Per_Carry <= 128-1); pragma Assert (not (No_Of_Bits_In_Radix = 27) or Sums_Per_Carry <= 512-1); pragma Assert (not (No_Of_Bits_In_Radix = 26) or Sums_Per_Carry <= 2048-1); -- -- Now that we know: No_Of_Bits_In_Radix, -- -- get number of binary digits and extended digits needed to make e_Real. -- Use the following formula for the number of Binary digits needed -- to meet Desired Decimal Digit precision D: -- -- Binary_Digits >= Ceiling (D * Log_Base_2_Of_10) + 1 -- -- where D = Desired_Decimal_Digit_Precision, and -- where Log_Base_2_Of_10 = 3.321928094887362. -- Ceiling of Real numbers with static declarations? -- -- Ceiling (3.321928094887 * D) <= Ceiling (3.322 * D) -- = Ceiling((3322.0 * D) / 1000.0) -- = (3322 * D - 1) / 1000 + 1 -- D is integer valued, so use integer Ceiling (A / B) = (A - 1) / B + 1. -- (for positive A). The above -- steps give us the number of binary digits required: No_Of_B_Digits. -- Next: min number of Radix 2.0**No_Of_Bits_In_Radix digits: No_Of_e_Digits. -- To get No_Of_e_Digits divide by No_Of_Bits_In_Radix and take the Ceiling. -- -- B is for binary, E for extended: ILog_Base_2_Of_10_x_1000 : constant := 3322; -- Round UP. D : constant := Desired_Decimal_Digit_Precision - 2; No_Of_B_Digits : constant := (ILog_Base_2_Of_10_x_1000 * D - 1) / 1000 + 2; No_Of_e_Digits : constant := (No_Of_B_Digits - 1) / No_Of_Bits_In_Radix + 1; -- -- The following parameter settings give us 2 more words in the Mantissa -- than required. These two are essential in getting the full desired -- precision in extensive floating pt calculation, and also in IO, and in -- functions that are evaluated by Newton's method. -- (At least one such guard digit is essential anyway, to compensate for -- leftward shift of the mantissa during normalization.) -- The index of the digits is a subtype of the Exponent type because -- there are frequent conversions between the two. -- -- An assertion verifies that there are 2 guard digits. -- -- e_Integer is used as the type of the index of the extended digits -- because e_Integer is the type of the exponent (defined below). -- There's a close relationship between the exponent of the number and the -- index of the digits of the number. (They are often scaled -- simultaneously, there is a relationship between their ultimate ranges, -- so they are given the same type here.) -- Log_Base_2_Of_10 : constant := 3.321928094887362; -- No_Of_Guard_Digits : constant := 2; -- Guard_Digits are extra digits of precision at the end of the mantissa. -- -- The 2nd Guard_Digit makes -- the Elementary Math Functions full precision (or almost full). -- Also the IO routines need 2 Guard_Digits. pragma Assert (No_Of_Guard_Digits = 2); -- The following are not decimal digits. Ultimate_Correct_Digit : constant e_Integer := No_Of_e_Digits - 1; Ultimate_Digit : constant e_Integer := No_Of_Guard_Digits + Ultimate_Correct_Digit; subtype Digits_Base is e_Integer range 0..Ultimate_Digit+1; subtype Digit_Index is Digits_Base range 0..Ultimate_Digit; pragma Assert (Digit_Index'First = 0); -- some of the arithmetic in "+" assumes this. -- The following are not decimal digits. Min_No_Of_Correct_Digits : constant := 3; -- Things stop working if this is less than 3. Min_No_Of_Digits : constant := Min_No_Of_Correct_Digits + 2; -- The 2 is the min number of guard digits. pragma Assert (Ultimate_Digit >= Min_No_Of_Digits - 1); pragma Assert (Ultimate_Digit >= Min_No_Of_Correct_Digits+No_Of_Guard_Digits-1); -- Digits go from 0..Ultimate_Digit Max_Exponent : constant e_Integer := 2 ** (e_Integer'Size - 5); Min_Exponent : constant e_Integer := -Max_Exponent; -- The exponent is usually 16 or 32 bit int. Limits on its range are set -- below what the base type allows: no more than 1/4 the dynamic range -- of the base type. If we use 1/8 of that limit, it allows us to delay -- overflow check to end of most routines (except "**"). If we use 1/32 -- of that limit, it allows us to do IO more simply. So to make -- IO work, at present the requirement is 2 ** (e_Integer'Size - 5). pragma Assert (Max_Exponent <= 2 ** (e_Integer'Size - 5)); -- function e_Real_Machine_Emin returns Min_Exponent -- function e_Real_Machine_Emax returns Max_Exponent --subtype Digit_Type is Real; -- Can use Floats with 53 bit mantissas as Digit_Type. Make 2 changes -- above (search for No_Of_Usable_Bits_In_Digit and follow instructions) -- and 2 changes in body (compiler will tell you where). Also comment -- out next 3 statements. Amazingly, it worked nicely last time I did it. -- It's slow, and it only makes sense when 64 bit ints are bad or missing. type D_Type is range -2**63+1 .. 2**63-1; subtype Digit_Type is D_Type'Base; -- Must allow negative digits. Use 64 bit Integer. pragma Assert (Digit_Type'Last = 2**(Digit_Type'Size-1)-1); pragma Assert (Digit_Type'Size-1 >= No_Of_Usable_Bits_In_Digit); Digit_Zero : constant Digit_Type := Digit_Type (0); Digit_One : constant Digit_Type := Digit_Type (1); Digit_Two : constant Digit_Type := Digit_Type (2); Digit_Radix : constant Digit_Type := Digit_Two**No_Of_Bits_In_Radix; Half_Radix : constant Digit_Type := Digit_Two**(No_Of_Bits_In_Radix-1); Digit_Radix_Squared : constant Digit_Type := Digit_Radix * Digit_Radix; Digit_Radix_Minus_1 : constant Digit_Type := Digit_Radix - Digit_One; type Mantissa is array (Digit_Index) of Digit_Type; type e_Real is record Digit : Mantissa := (others => Digit_Zero); Exp : e_Integer := 0; Is_Zero : Boolean := True; Is_Positive : Boolean := True; Is_Infinite : Boolean := False; end record; --for e_Real'Size use (Digit_Type'Size*Mantissa'Length + e_Integer'Size*2); -- Make e_Real'Size Integer number of 64-bit words. Usually doesn't matter. -- Only for integer Digit_Type. Comment out for Float. pt. Digit types. Zero : constant e_Real := e_Real' ((others => Digit_Zero), 0, True, True, False); One : constant e_Real := e_Real' ((0 => Digit_One, others => Digit_Zero), 0, False, True, False); Positive_Infinity : constant e_Real := e_Real' ((others => Digit_Zero), Max_Exponent+4, False, True, True); Negative_Infinity : constant e_Real := e_Real' ((others => Digit_Zero), Max_Exponent+4, False, False, True); -- For efficiency, we need an optimized (Real * Extended) -- operation. So define type e_Digit, a single real number with -- an exponent. It's a real number that's restricted to integral values -- in the range to 0..Radix-1. type e_Digit is record Digit : Digit_Type := Digit_Zero; Exp : e_Integer := 0; Is_Zero : Boolean := True; Is_Positive : Boolean := True; end record; -- Constants used in body. Real is used for easy communication with e_Real. Real_Zero : constant Real := Real (0.0); Real_One : constant Real := Real (1.0); Real_Radix : constant Real := 2.0**No_Of_Bits_In_Radix; Radix_Minus_1 : constant Real := 2.0**No_Of_Bits_In_Radix - 1.0; Radix_Squared : constant Real := 2.0**(2*No_Of_Bits_In_Radix); Inverse_Radix : constant Real := 2.0**(-No_Of_Bits_In_Radix); Inverse_Radix_Squared : constant Real := Inverse_Radix * Inverse_Radix; end Extended_Real;
stcarrez/ada-util
Ada
2,881
ads
----------------------------------------------------------------------- -- util-listeners-lifecycles -- Listeners -- Copyright (C) 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. ----------------------------------------------------------------------- -- The `Lifecycles` package provides a listener interface dedicated to -- track lifecycle managements on objects. It defines a set of procedures to be -- notified when an object is created, updated or deleted. -- -- Notes: another implementation can be made by using three different listener lists -- that use the simple observer pattern. generic type Element_Type (<>) is limited private; package Util.Listeners.Lifecycles is -- ------------------------------ -- Lifecycle listener -- ------------------------------ type Listener is limited interface and Util.Listeners.Listener; -- The `On_Create` procedure is called by `Notify_Create` to notify the creation of the item. procedure On_Create (Instance : in Listener; Item : in Element_Type) is abstract; -- The `On_Update` procedure is called by `Notify_Update` to notify the update of the item. procedure On_Update (Instance : in Listener; Item : in Element_Type) is abstract; -- The `On_Delete` procedure is called by `Notify_Delete` to notify the deletion of the item. procedure On_Delete (Instance : in Listener; Item : in Element_Type) is abstract; -- Inform the the lifecycle listeners registered in `List` that the item passed in `Item` -- has been created (calls `On_Create`). procedure Notify_Create (List : in Util.Listeners.List; Item : in Element_Type); -- Inform the the lifecycle listeners registered in `List` that the item passed in `Item` -- has been updated (calls `On_Update`). procedure Notify_Update (List : in Util.Listeners.List; Item : in Element_Type); -- Inform the the lifecycle listeners registered in `List` that the item passed in `Item` -- has been deleted (calls `On_Delete`). procedure Notify_Delete (List : in Util.Listeners.List; Item : in Element_Type); end Util.Listeners.Lifecycles;
francesco-bongiovanni/ewok-kernel
Ada
4,142
ads
with m4.mpu; with types; package soc.layout with spark_mode => on is FLASH_BASE : constant system_address := 16#0800_0000#; -- this specific SoC has two flash bank mapped consecutively, giving access -- to 2MB of flash FLASH_SIZE : constant := 2 * MBYTE; SRAM_BASE : constant system_address := 16#1000_0000#; SRAM_SIZE : constant := 64 * KBYTE; BOOTROM_BASE : constant system_address := 16#1FFF_0000#; RAM_BASE : constant system_address := 16#2000_0000#; -- SRAM RAM_SIZE : constant := 128 * KBYTE; PERIPH_BASE : constant system_address := 16#4000_0000#; MEMORY_BANK1_BASE : constant system_address := 16#6000_0000#; MEMORY_BANK2_BASE : constant system_address := MEMORY_BANK1_BASE; APB1PERIPH_BASE : constant system_address := PERIPH_BASE; APB2PERIPH_BASE : constant system_address := PERIPH_BASE + 16#0001_0000#; AHB1PERIPH_BASE : constant system_address := PERIPH_BASE + 16#0002_0000#; AHB2PERIPH_BASE : constant system_address := PERIPH_BASE + 16#1000_0000#; -- -- AHB1 peripherals -- GPIOA_BASE : constant system_address := AHB1PERIPH_BASE + 16#0000#; GPIOB_BASE : constant system_address := AHB1PERIPH_BASE + 16#0400#; GPIOC_BASE : constant system_address := AHB1PERIPH_BASE + 16#0800#; GPIOD_BASE : constant system_address := AHB1PERIPH_BASE + 16#0C00#; GPIOE_BASE : constant system_address := AHB1PERIPH_BASE + 16#1000#; GPIOF_BASE : constant system_address := AHB1PERIPH_BASE + 16#1400#; GPIOG_BASE : constant system_address := AHB1PERIPH_BASE + 16#1800#; GPIOH_BASE : constant system_address := AHB1PERIPH_BASE + 16#1C00#; GPIOI_BASE : constant system_address := AHB1PERIPH_BASE + 16#2000#; DMA1_BASE : constant system_address := AHB1PERIPH_BASE + 16#6000#; DMA2_BASE : constant system_address := AHB1PERIPH_BASE + 16#6400#; -- -- APB2 peripherals -- SYSCFG_BASE : constant system_address := APB2PERIPH_BASE + 16#3800#; -- -- Flash and firmware structure -- -- -- Flip bank FW1_SIZE : constant unsigned_32 := 576*1024; FW1_KERN_BASE : constant unsigned_32 := 16#08020000#; FW1_KERN_SIZE : constant unsigned_32 := 64*1024; FW1_KERN_REGION_SIZE : constant m4.mpu.t_region_size := m4.mpu.REGION_SIZE_64KB; FW1_USER_BASE : constant unsigned_32 := 16#08080000#; FW1_USER_SIZE : constant unsigned_32 := 512*1024; FW1_USER_REGION_SIZE : constant m4.mpu.t_region_size := m4.mpu.REGION_SIZE_512KB; -- DFU 1 DFU1_SIZE : constant unsigned_32 := 320*1024; DFU1_KERN_BASE : constant unsigned_32 := 16#08030000#; DFU1_USER_BASE : constant unsigned_32 := 16#08040000#; DFU1_KERN_SIZE : constant unsigned_32 := 64*1024; DFU1_KERN_REGION_SIZE: constant m4.mpu.t_region_size := m4.mpu.REGION_SIZE_64KB; DFU1_USER_SIZE : constant unsigned_32 := 256*1024; DFU1_USER_REGION_SIZE: constant m4.mpu.t_region_size := m4.mpu.REGION_SIZE_256KB; -- Flop bank FW2_SIZE : constant unsigned_32 := 576*1024; FW2_KERN_SIZE : constant unsigned_32 := 64*1024; FW2_KERN_BASE : constant unsigned_32 := 16#09020000#; FW2_KERN_REGION_SIZE : constant m4.mpu.t_region_size := m4.mpu.REGION_SIZE_64KB; FW2_USER_BASE : constant unsigned_32 := 16#09080000#; FW2_USER_SIZE : constant unsigned_32 := 512*1024; FW2_USER_REGION_SIZE : constant m4.mpu.t_region_size := m4.mpu.REGION_SIZE_512KB; -- FW2_USER_REGION_SIZE : constant m4.mpu.t_region_size := m4.mpu.REGION_SIZE_512KB; -- DFU 2 DFU2_SIZE : constant unsigned_32 := 320*1024; DFU2_KERN_BASE : constant unsigned_32 := 16#09030000#; DFU2_KERN_SIZE : constant unsigned_32 := 64*1024; DFU2_KERN_REGION_SIZE: constant m4.mpu.t_region_size := m4.mpu.REGION_SIZE_256KB; DFU2_USER_BASE : constant unsigned_32 := 16#09040000#; DFU2_USER_SIZE : constant unsigned_32 := 256*1024; DFU2_USER_REGION_SIZE: constant m4.mpu.t_region_size := m4.mpu.REGION_SIZE_256KB; end soc.layout;
AaronC98/PlaneSystem
Ada
48,855
adb
------------------------------------------------------------------------------ -- Ada Web Server -- -- -- -- Copyright (C) 2005-2018, 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.Characters.Handling; with Ada.Exceptions; with Ada.Strings.Fixed; with AWS.Digest; with AWS.Headers.Values; with AWS.Messages; with AWS.MIME; with AWS.Net.Buffered; with AWS.Net.SSL; with AWS.Response.Set; with AWS.Translator; with AWS.Utils; package body AWS.Client.HTTP_Utils is function Image (Data_Range : Content_Range) return String; -- Returns the partial content range parameter to be passed to the Range -- header. function "+" (Left : Real_Time.Time; Right : Real_Time.Time_Span) return Real_Time.Time; -- Returns Real_Time.Time_Last if Right is Real_Time.Time_Span_Last, -- otherwise returns Left + Right. --------- -- "+" -- --------- function "+" (Left : Real_Time.Time; Right : Real_Time.Time_Span) return Real_Time.Time is use Real_Time; begin if Right = Time_Span_Last then return Time_Last; else return Real_Time."+" (Left, Right); end if; end "+"; ------------- -- Connect -- ------------- procedure Connect (Connection : in out HTTP_Connection) is use type Net.Socket_Access; use type Net.SSL.Session_Type; Connect_URL : AWS.URL.Object renames Connection.Connect_URL; Security : constant Boolean := AWS.URL.Security (Connect_URL); Sock : Net.Socket_Access; procedure Get_SSL_Session; -- Get SSL session data from connectio socket and store it into -- connection record. procedure Set_SSL_Session; -- Set SSL session data from connection record to connection socket --------------------- -- Get_SSL_Session -- --------------------- procedure Get_SSL_Session is begin if Connection.SSL_Session /= Net.SSL.Null_Session then Net.SSL.Free (Connection.SSL_Session); end if; Connection.SSL_Session := Net.SSL.Socket_Type (Connection.Socket.all).Session_Data; end Get_SSL_Session; --------------------- -- Set_SSL_Session -- --------------------- procedure Set_SSL_Session is begin if Connection.SSL_Session /= Net.SSL.Null_Session then -- Try to reuse SSL session to speedup handshake Net.SSL.Socket_Type (Connection.Socket.all).Set_Session_Data (Connection.SSL_Session); end if; end Set_SSL_Session; begin pragma Assert (not Connection.Opened); -- This should never be called with an open connection -- Keep-alive reconnection will be with old socket. We cannot reuse it, -- and have to free it. if Connection.Socket /= null then Net.Free (Connection.Socket); end if; Sock := Net.Socket (Security); Connection.Socket := Sock; if Security then -- This is a secure connection, set the SSL config for this socket Net.SSL.Socket_Type (Sock.all).Set_Config (Connection.SSL_Config); Set_SSL_Session; end if; Sock.Set_Timeout (Connection.Timeouts.Connect); Sock.Connect (AWS.URL.Host (Connect_URL), AWS.URL.Port (Connect_URL)); if Security then -- Save SSL session to be able to reuse it later Get_SSL_Session; end if; Connection.Opened := True; if AWS.URL.Security (Connection.Host_URL) and then Connection.Proxy /= Client.No_Data then -- We want to connect to the host using HTTPS, this can only be -- done by opening a tunnel through the proxy. -- -- CONNECT <host> HTTP/1.1 -- Host: <host> -- [Proxy-Authorization: xxxx] -- <other headers> -- <empty line> Sock.Set_Timeout (Connection.Timeouts.Send); declare use AWS.URL; Host_Address : constant String := Host (Connection.Host_URL, IPv6_Brackets => True) & ':' & Port (Connection.Host_URL); begin Send_Header (Sock.all, "CONNECT " & Host_Address & ' ' & HTTP_Version); Send_Header (Sock.all, Messages.Host (Host_Address)); end; -- Proxy Authentication Send_Authentication_Header (Connection, Messages.Proxy_Authorization_Token, Connection.Auth (Proxy), URI => "/", Method => "CONNECT"); declare User_Agent : constant String := To_String (Connection.User_Agent); begin if User_Agent /= "" then Send_Header (Sock.all, Messages.User_Agent (User_Agent)); end if; end; -- Empty line to terminate the connect Net.Buffered.New_Line (Sock.all); -- Wait for reply from the proxy, and check status Sock.Set_Timeout (Connection.Timeouts.Receive); declare use type Messages.Status_Code; Line : constant String := Net.Buffered.Get_Line (Sock.all); Status : Messages.Status_Code; begin Debug_Message ("< ", Line); Status := Messages.Status_Code'Value ('S' & Line (Messages.HTTP_Token'Length + 5 .. Messages.HTTP_Token'Length + 7)); if Status >= Messages.S400 then raise Connection_Error with "Can't connect to proxy, status " & Messages.Image (Status); end if; end; -- Ignore all remainings lines loop declare Line : constant String := Net.Buffered.Get_Line (Sock.all); begin Debug_Message ("< ", Line); exit when Line = ""; end; end loop; -- Now the tunnel is open, we need to create an SSL connection -- around this tunnel. declare SS : Net.SSL.Socket_Type := Net.SSL.Secure_Client (Sock.all, Connection.SSL_Config, Host => URL.Host (Connection.Host_URL)); begin Net.Free (Sock); Connection.Socket := new Net.SSL.Socket_Type'(SS); Set_SSL_Session; -- Do explicit handshake to be able to get server certificate -- and SSL session after. SS.Do_Handshake; Get_SSL_Session; end; end if; exception when E : Net.Socket_Error => raise Connection_Error with Exceptions.Exception_Message (E); end Connect; -------------------------------------- -- Decrement_Authentication_Attempt -- -------------------------------------- procedure Decrement_Authentication_Attempt (Connection : in out HTTP_Connection; Counter : in out Auth_Attempts_Count; Over : out Boolean) is type Over_Data is array (Authentication_Level) of Boolean; Is_Over : constant Over_Data := (others => True); Over_Level : Over_Data := (others => True); begin for Level in Authentication_Level'Range loop if Connection.Auth (Level).Requested then Counter (Level) := Counter (Level) - 1; Over_Level (Level) := Counter (Level) = 0; end if; end loop; Over := Over_Level = Is_Over; end Decrement_Authentication_Attempt; ---------------- -- Disconnect -- ---------------- procedure Disconnect (Connection : in out HTTP_Connection) is use type Net.Socket_Access; begin if Connection.Opened then Connection.Opened := False; if Connection.Socket /= null then Connection.Socket.Shutdown; end if; end if; if Connection.Socket /= null then Net.Free (Connection.Socket); end if; end Disconnect; ------------------ -- Get_Response -- ------------------ procedure Get_Response (Connection : in out HTTP_Connection; Result : out Response.Data; Get_Body : Boolean := True) is procedure Disconnect; -- close connection socket Sock : Net.Socket_Type'Class renames Connection.Socket.all; Keep_Alive : Boolean; ---------------- -- Disconnect -- ---------------- procedure Disconnect is begin if not Keep_Alive and then not Connection.Streaming then Disconnect (Connection); end if; end Disconnect; begin Sock.Set_Timeout (Connection.Timeouts.Receive); -- Clear the data in the response Response.Set.Clear (Result); Parse_Header (Connection, Result, Keep_Alive); declare TE : constant String := Response.Header (Result, Messages.Transfer_Encoding_Token); CT_Len : constant Response.Content_Length_Type := Response.Content_Length (Result); begin if not Messages.With_Body (Response.Status_Code (Result)) then -- RFC-2616 4.4 -- ... -- Any response message which "MUST NOT" include a message-body -- (such as the 1xx, 204, and 304 responses and any response to a -- HEAD request) is always terminated by the first empty line -- after the header fields, regardless of the entity-header fields -- present in the message. Connection.Transfer := Content_Length; Connection.Length := 0; elsif TE = "chunked" then -- A chuncked message is written on the stream as list of data -- chunk. Each chunk has the following format: -- -- <N : the chunk size in hexadecimal> CRLF -- <N * BYTES : the data> CRLF -- -- The termination chunk is: -- -- 0 CRLF -- CRLF -- Connection.Transfer := Chunked; Connection.Length := 0; elsif CT_Len = Response.Undefined_Length then Connection.Transfer := Until_Close; else Connection.Transfer := Content_Length; Connection.Length := CT_Len; end if; end; -- If we get an Unauthorized response we want to get the body. This is -- needed as in Digest mode the body will gets read by the next request -- and will raise a protocol error. if Get_Body then Read_Body (Connection, Result, Store => True); Connection.Transfer := None; end if; Disconnect; end Get_Response; ----------- -- Image -- ----------- function Image (Data_Range : Content_Range) return String is Result : Unbounded_String; begin Append (Result, "bytes="); if Data_Range.First /= Undefined then Append (Result, Utils.Image (Natural (Data_Range.First))); end if; Append (Result, "-"); if Data_Range.Last /= Undefined then Append (Result, Utils.Image (Natural (Data_Range.Last))); end if; return To_String (Result); end Image; ------------------- -- Internal_Post -- ------------------- procedure Internal_Post (Connection : in out HTTP_Connection; Result : out Response.Data; Data : Stream_Element_Array; URI : String; SOAPAction : String; Content_Type : String; Attachments : Attachment_List; Headers : Header_List := Empty_Header_List) is use type AWS.Attachments.List; begin if Attachments = AWS.Attachments.Empty_List then Internal_Post_Without_Attachment (Connection => Connection, Result => Result, Data => Data, URI => URI, SOAPAction => SOAPAction, Content_Type => Content_Type, Headers => Headers); else Internal_Post_With_Attachment (Connection => Connection, Result => Result, Data => Data, URI => URI, SOAPAction => SOAPAction, Content_Type => Content_Type, Attachments => Attachments, Headers => Headers); end if; end Internal_Post; -------------------------------------- -- Internal_Post_With_Attachment -- -------------------------------------- procedure Internal_Post_With_Attachment (Connection : in out HTTP_Connection; Result : out Response.Data; Data : Stream_Element_Array; URI : String; SOAPAction : String; Content_Type : String; Attachments : Attachment_List; Headers : Header_List := Empty_Header_List) is use Real_Time; Stamp : constant Time := Clock; Pref_Suf : constant String := "--"; Boundary : constant String := "AWS_Attachment-" & Utils.Random_String (8); Root_Content_Id : constant String := "<rootpart>"; Root_Part_Header : AWS.Headers.List; Try_Count : Natural := Connection.Retry; Auth_Attempts : Auth_Attempts_Count := (others => 2); Auth_Is_Over : Boolean; procedure Build_Root_Part_Header; -- Builds the rootpart header and calculates its size function Content_Length return Stream_Element_Offset; -- Returns the total message content length ---------------------------- -- Build_Root_Part_Header -- ---------------------------- procedure Build_Root_Part_Header is begin Root_Part_Header.Add (Name => AWS.Messages.Content_Type_Token, Value => Content_Type); Root_Part_Header.Add (Name => AWS.Messages.Content_Id_Token, Value => Root_Content_Id); end Build_Root_Part_Header; -------------------- -- Content_Length -- -------------------- function Content_Length return Stream_Element_Offset is begin return 2 + Boundary'Length + 2 -- Root part boundary + CR+LF + Stream_Element_Offset (AWS.Headers.Length (Root_Part_Header)) + Data'Length -- Root part data length + Stream_Element_Offset (AWS.Attachments.Length (Attachments, Boundary)); end Content_Length; begin -- Internal_Post_With_Attachment Build_Root_Part_Header; Retry : loop begin Open_Send_Common_Header (Connection, "POST", URI, Headers); declare Sock : Net.Socket_Type'Class renames Connection.Socket.all; begin -- Send message Content-Type (multipart/related) if Content_Type = "" then Send_Header (Sock, Messages.Content_Type (MIME.Multipart_Related & "; type=" & Content_Type & "; start=""" & Root_Content_Id & '"', Boundary)); else Send_Header (Sock, Messages.Content_Type (MIME.Multipart_Form_Data, Boundary)); end if; if SOAPAction /= Client.No_Data then -- SOAP header if SOAPAction = """""" then -- An empty SOAPAction Send_Header (Sock, Messages.SOAPAction ("")); else Send_Header (Sock, Messages.SOAPAction (SOAPAction)); end if; end if; -- Send message Content-Length Send_Header (Sock, Messages.Content_Length (Content_Length)); Net.Buffered.New_Line (Sock); -- Send multipart message start boundary Net.Buffered.Put_Line (Sock, Pref_Suf & Boundary); -- Send root part header AWS.Headers.Send_Header (Sock, Root_Part_Header); Net.Buffered.New_Line (Sock); -- Send root part data if Data'Length /= 0 then Net.Buffered.Write (Sock, Data); Net.Buffered.New_Line (Sock); end if; -- Send the attachments AWS.Attachments.Send (Sock, Attachments, Boundary); end; -- Get answer from server Get_Response (Connection, Result, Get_Body => not Connection.Streaming); Decrement_Authentication_Attempt (Connection, Auth_Attempts, Auth_Is_Over); if Auth_Is_Over then return; elsif Connection.Streaming then Read_Body (Connection, Result, Store => False); end if; exception when E : Net.Socket_Error | Connection_Error => Error_Processing (Connection, Try_Count, Result, "UPLOAD", E, Stamp); exit Retry when not Response.Is_Empty (Result); end; end loop Retry; end Internal_Post_With_Attachment; -------------------------------------- -- Internal_Post_Without_Attachment -- -------------------------------------- procedure Internal_Post_Without_Attachment (Connection : in out HTTP_Connection; Result : out Response.Data; Data : Stream_Element_Array; URI : String; SOAPAction : String; Content_Type : String; Headers : Header_List := Empty_Header_List) is use Real_Time; Stamp : constant Time := Clock; Try_Count : Natural := Connection.Retry; Auth_Attempts : Auth_Attempts_Count := (others => 2); Auth_Is_Over : Boolean; begin Retry : loop begin -- Post Data with headers Send_Common_Post (Connection, Data, URI, SOAPAction, Content_Type, Headers); -- Get answer from server Get_Response (Connection, Result, Get_Body => not Connection.Streaming); Decrement_Authentication_Attempt (Connection, Auth_Attempts, Auth_Is_Over); if Auth_Is_Over then return; elsif Connection.Streaming then Read_Body (Connection, Result, Store => False); end if; exception when E : Net.Socket_Error | Connection_Error => Error_Processing (Connection, Try_Count, Result, "POST", E, Stamp); exit Retry when not Response.Is_Empty (Result); end; end loop Retry; end Internal_Post_Without_Attachment; ----------------------------- -- Open_Send_Common_Header -- ----------------------------- procedure Open_Send_Common_Header (Connection : in out HTTP_Connection; Method : String; URI : String; Headers : Header_List := Empty_Header_List) is Sock : Net.Socket_Access := Connection.Socket; No_Data : Unbounded_String renames Null_Unbounded_String; Header : constant Header_List := Headers.Union (Connection.Headers, Unique => True); function Persistence return String with Inline; -- Returns "Keep-Alive" is we have a persistent connection and "Close" -- otherwise. function Encoded_URI return String; -- Returns URI encoded (' ' -> '+') ----------------- -- Encoded_URI -- ----------------- function Encoded_URI return String is E_URI : String := URI; begin for K in E_URI'Range loop if E_URI (K) = ' ' then E_URI (K) := '+'; end if; end loop; return E_URI; end Encoded_URI; ----------------- -- Persistence -- ----------------- function Persistence return String is begin if Connection.Persistent then return "Keep-Alive"; else return "Close"; end if; end Persistence; Host_Address : constant String := AWS.URL.Host (Connection.Host_URL, IPv6_Brackets => True) & AWS.URL.Port_Not_Default (Connection.Host_URL); begin -- Open_Send_Common_Header -- Open connection if needed if not Connection.Opened then Connect (Connection); Sock := Connection.Socket; end if; Sock.Set_Timeout (Connection.Timeouts.Send); -- Header command if Connection.Proxy = No_Data or else AWS.URL.Security (Connection.Host_URL) then -- Without proxy or over proxy tunneling. -- In both cases we want to send the pathname only, we are not -- required to send the absolute path. if URI = "" then Send_Header (Sock.all, Method & ' ' & AWS.URL.Pathname_And_Parameters (Connection.Host_URL, False) & ' ' & HTTP_Version); else Send_Header (Sock.all, Method & ' ' & Encoded_URI & ' ' & HTTP_Version); end if; -- Unless Header already contains connection info (like would be -- the case for web sockets for instance) if not Header.Exist (Messages.Connection_Token) then Send_Header (Sock.all, Messages.Connection (Persistence)); end if; else -- We have a proxy configured, in thoses case we want to send the -- absolute path and parameters. if URI = "" then Send_Header (Sock.all, Method & ' ' & AWS.URL.URL (Connection.Host_URL) & ' ' & HTTP_Version); else -- Send GET http://<host>[:port]/URI HTTP/1.1 Send_Header (Sock.all, Method & ' ' & URL.Protocol_Name (Connection.Host_URL) & "://" & Host_Address & Encoded_URI & ' ' & HTTP_Version); end if; Send_Header (Sock.all, Messages.Proxy_Connection (Persistence)); -- Proxy Authentication Send_Authentication_Header (Connection, Messages.Proxy_Authorization_Token, Connection.Auth (Proxy), URI, Method); end if; -- Send specific headers AWS.Headers.Send_Header (Sock.all, Header); if Debug_On then for J in 1 .. Header.Count loop Debug_Message ("> ", Header.Get_Line (J)); end loop; end if; -- Cookie if Connection.Cookie /= No_Data then Send_Header (Sock.all, Messages.Cookie_Token, Messages.Cookie'Access, To_String (Connection.Cookie), Header); end if; Send_Header (Sock.all, Messages.Host_Token, Messages.Host'Access, Host_Address, Header); Send_Header (Sock.all, Messages.Accept_Token, Messages.Accept_Type'Access, "text/html, */*", Header); Send_Header (Sock.all, Messages.Accept_Encoding_Token, Messages.Accept_Encoding'Access, "gzip, deflate", Header); Send_Header (Sock.all, Messages.Accept_Language_Token, Messages.Accept_Language'Access, "fr, ru, us", Header); declare User_Agent : constant String := To_String (Connection.User_Agent); begin if User_Agent /= "" then Send_Header (Sock.all, Messages.User_Agent_Token, Messages.User_Agent'Access, User_Agent, Header); end if; end; if Connection.Data_Range /= No_Range then Send_Header (Sock.all, Messages.Range_Token, Messages.Data_Range'Access, Image (Connection.Data_Range), Header); end if; -- User Authentication Send_Authentication_Header (Connection, Messages.Authorization_Token, Connection.Auth (WWW), URI, Method); end Open_Send_Common_Header; ------------------ -- Parse_Header -- ------------------ procedure Parse_Header (Connection : in out HTTP_Connection; Answer : out Response.Data; Keep_Alive : out Boolean) is Sock : Net.Socket_Type'Class renames Connection.Socket.all; Status : Messages.Status_Code; Request_Auth_Mode : array (Authentication_Level) of Authentication_Mode := (others => Any); procedure Parse_Authenticate_Line (Level : Authentication_Level; Auth_Line : String); -- Parses Authentication request line and fill Connection.Auth (Level) -- field with the information read on the line. Handle WWW and Proxy -- authentication. procedure Read_Status_Line; -- Read the status line procedure Set_Keep_Alive (Data : String); -- Set the Parse_Header.Keep_Alive depending on data from the -- Proxy-Connection or Connection header line. function "+" (S : String) return Unbounded_String renames To_Unbounded_String; ----------------------------- -- Parse_Authenticate_Line -- ----------------------------- procedure Parse_Authenticate_Line (Level : Authentication_Level; Auth_Line : String) is use Ada.Characters.Handling; Basic_Token : constant String := "BASIC"; Digest_Token : constant String := "DIGEST"; Auth : Authentication_Type renames Connection.Auth (Level); Request_Mode : Authentication_Mode; Read_Params : Boolean := False; -- Set it to true when the authentication mode is stronger -- then before. procedure Value (Item : String; Quit : in out Boolean); -- Routine receiving unnamed value during parsing of -- authentication line. procedure Named_Value (Name : String; Value : String; Quit : in out Boolean); -- Routine receiving name/value pairs during parsing of -- authentication line. ----------------- -- Named_Value -- ----------------- procedure Named_Value (Name : String; Value : String; Quit : in out Boolean) is pragma Warnings (Off, Quit); U_Name : constant String := To_Upper (Name); begin if not Read_Params then return; end if; if U_Name = "REALM" then Auth.Realm := +Value; elsif U_Name = "NONCE" then Auth.Nonce := +Value; elsif U_Name = "QOP" then Auth.QOP := +Value; elsif U_Name = "ALGORITHM" then if Value /= "MD5" then raise Constraint_Error with "Only MD5 algorithm is supported."; end if; -- The parameter Stale is true when the Digest value is correct -- but the nonce value is too old or incorrect. -- -- This mean that an interactive HTTP client should not ask -- name/password from the user, and try to use name/password from -- the previous successful authentication attempt. -- We do not need to check Stale authentication parameter -- for now, because our client is not interactive, so we are not -- going to ask user to input the name/password anyway. We could -- uncomment it later, when we would provide some interactive -- behavior to AWS.Client or interface to the interactive -- programs by callback to the AWS.Client. -- -- elsif U_Name = "STALE" then -- null; end if; end Named_Value; ----------- -- Value -- ----------- procedure Value (Item : String; Quit : in out Boolean) is pragma Warnings (Off, Quit); Mode_Image : constant String := To_Upper (Item); begin if Mode_Image = Digest_Token then Request_Mode := Digest; elsif Mode_Image = Basic_Token then Request_Mode := Basic; else Request_Mode := Unknown; end if; Read_Params := Request_Mode > Request_Auth_Mode (Level); if Read_Params then Request_Auth_Mode (Level) := Request_Mode; Auth.Requested := True; Auth.Work_Mode := Request_Mode; Auth.NC := 0; end if; end Value; ----------- -- Parse -- ----------- procedure Parse is new Headers.Values.Parse (Value, Named_Value); begin Parse (Auth_Line); end Parse_Authenticate_Line; ----------------------- -- Read_Status_Line -- ----------------------- procedure Read_Status_Line is function Get_Full_Line return String; -- Returns a full HTTP line (handle continuation line) -- -- ??? This is non-standard and as been implemented because some -- Lotus Domino servers do send a Reason-Phrase with continuation -- line. This is clearly not valid see [RFC 2616 - 6.1]. ------------------- -- Get_Full_Line -- ------------------- function Get_Full_Line return String is Line : constant String := Net.Buffered.Get_Line (Sock); N_Char : constant Character := Net.Buffered.Peek_Char (Sock); begin if N_Char = ' ' or else N_Char = ASCII.HT then -- Next line is a continuation line [RFC 2616 - 2.2], but -- again this is non standard here, see comment above. return Line & Get_Full_Line; else return Line; end if; end Get_Full_Line; Line : constant String := Get_Full_Line; begin Debug_Message ("< ", Line); -- Checking the first line in the HTTP header. -- It must match Messages.HTTP_Token. if Utils.Match (Line, Messages.HTTP_Token) then Status := Messages.Status_Code'Value ('S' & Line (Messages.HTTP_Token'Length + Line'First + 4 .. Messages.HTTP_Token'Length + Line'First + 6)); Response.Set.Status_Code (Answer, Status); -- By default HTTP/1.0 connection is not keep-alive but -- HTTP/1.1 is keep-alive. Keep_Alive := Line (Messages.HTTP_Token'Length + Line'First .. Messages.HTTP_Token'Length + Line'First + 2) >= "1.1"; else -- or else it is wrong answer from server raise Protocol_Error with Line; end if; end Read_Status_Line; -------------------- -- Set_Keep_Alive -- -------------------- procedure Set_Keep_Alive (Data : String) is begin if Utils.Match (Data, "Close") then Keep_Alive := False; elsif Utils.Match (Data, "Keep-Alive") then Keep_Alive := True; end if; end Set_Keep_Alive; use type Messages.Status_Code; begin -- Parse_Header for Level in Authentication_Level'Range loop Connection.Auth (Level).Requested := False; end loop; Read_Status_Line; -- By default we have at least some headers. This value will be -- updated if a message body is read. Response.Set.Mode (Answer, Response.Header); Response.Set.Read_Header (Sock, Answer); declare use AWS.Response; Content_Encoding : constant String := Characters.Handling.To_Lower (Header (Answer, Messages.Content_Encoding_Token)); procedure Decode_Init (Header : ZLib.Header_Type); ----------------- -- Decode_Init -- ----------------- procedure Decode_Init (Header : ZLib.Header_Type) is use type Utils.Stream_Element_Array_Access; begin ZLib.Inflate_Init (Connection.Decode_Filter, Header => Header); if Connection.Decode_Buffer = null then Connection.Decode_Buffer := new Stream_Element_Array (1 .. 8096); end if; Connection.Decode_First := Connection.Decode_Buffer'Last + 1; Connection.Decode_Last := Connection.Decode_Buffer'Last; end Decode_Init; begin if ZLib.Is_Open (Connection.Decode_Filter) then ZLib.Close (Connection.Decode_Filter, Ignore_Error => True); end if; if Content_Encoding = "gzip" then Decode_Init (ZLib.GZip); elsif Content_Encoding = "deflate" then Decode_Init (ZLib.Default); end if; end; -- ??? we should not expect 100 response message after the body sent. -- This code needs to be fixed. -- We should expect 100 status line only before sending the message -- body to server. -- And we should send Expect: header line in the header if we could -- deal with 100 status code. -- See [RFC 2616 - 8.2.3] use of the 100 (Continue) Status. if Status = Messages.S100 then Read_Status_Line; Response.Set.Read_Header (Sock, Answer); end if; Set_Keep_Alive (Response.Header (Answer, Messages.Connection_Token)); Set_Keep_Alive (Response.Header (Answer, Messages.Proxy_Connection_Token)); -- Read and store all cookies from response header declare Set_Cookies : constant Headers.VString_Array := Response.Header (Answer) .Get_Values (Messages.Set_Cookie_Token); Cookie : Unbounded_String; I : Natural; begin for K in Set_Cookies'Range loop if Set_Cookies (K) /= Null_Unbounded_String then I := Strings.Unbounded.Index (Set_Cookies (K), ";"); if Cookie /= Null_Unbounded_String then Append (Cookie, "; "); end if; -- We found a cookie NAME=VALUE, record it if I = 0 then Append (Cookie, Set_Cookies (K)); else Append (Cookie, Slice (Set_Cookies (K), 1, I - 1)); end if; end if; end loop; -- If we have some value, update the connection status if Cookie /= Null_Unbounded_String then Connection.Cookie := Cookie; end if; end; Parse_Authenticate_Line (WWW, Response.Header (Answer, Messages.WWW_Authenticate_Token)); Parse_Authenticate_Line (Proxy, Response.Header (Answer, Messages.Proxy_Authenticate_Token)); end Parse_Header; --------------- -- Read_Body -- --------------- procedure Read_Body (Connection : in out HTTP_Connection; Result : out Response.Data; Store : Boolean) is use Ada.Real_Time; Expire : constant Time := Clock + Connection.Timeouts.Response; begin loop declare Buffer : Stream_Element_Array (1 .. 8192); Last : Stream_Element_Offset; begin Read_Some (Connection, Buffer, Last); exit when Last < Buffer'First; if Store then Response.Set.Append_Body (Result, Buffer (Buffer'First .. Last)); end if; end; if Clock > Expire then if Store then Response.Set.Append_Body (Result, "..." & ASCII.LF & " Response Timeout"); end if; Response.Set.Status_Code (Result, Messages.S408); exit; end if; end loop; end Read_Body; -------------------------------- -- Send_Authentication_Header -- -------------------------------- procedure Send_Authentication_Header (Connection : in out HTTP_Connection; Token : String; Data : in out Authentication_Type; URI : String; Method : String) is User : constant String := To_String (Data.User); Pwd : constant String := To_String (Data.Pwd); begin if User /= Client.No_Data and then Pwd /= Client.No_Data then if Data.Work_Mode = Basic then Send_Header (Connection.Socket.all, Token & ": Basic " & AWS.Translator.Base64_Encode (User & ':' & Pwd)); elsif Data.Work_Mode = Digest then declare Nonce : constant String := To_String (Data.Nonce); Realm : constant String := To_String (Data.Realm); QOP : constant String := To_String (Data.QOP); function Get_URI return String; -- Returns the real URI where the request is going to be -- sent. It is either Open_Send_Common_Header.URI parameter -- if it exists (without the HTTP parameters part), or URI -- part of the Connection.Connect_URL field. function QOP_Data return String; -- Returns string with qop, cnonce and nc parameters -- if qop parameter exists in the server auth request, -- or empty string if not [RFC 2617 - 3.2.2]. Response : AWS.Digest.Digest_String; ------------- -- Get_URI -- ------------- function Get_URI return String is URI_Last : Natural; begin if URI = "" then return URL.Path (Connection.Connect_URL) & URL.File (Connection.Connect_URL); else URI_Last := Strings.Fixed.Index (URI, "?"); if URI_Last = 0 then URI_Last := URI'Last; else URI_Last := URI_Last - 1; end if; return URI (URI'First .. URI_Last); end if; end Get_URI; URI : constant String := Get_URI; -------------- -- QOP_Data -- -------------- function QOP_Data return String is CNonce : constant AWS.Digest.Nonce := AWS.Digest.Create_Nonce; begin if QOP = Client.No_Data then Response := AWS.Digest.Create (Username => User, Realm => Realm, Password => Pwd, Nonce => Nonce, Method => Method, URI => URI); return ""; else Data.NC := Data.NC + 1; declare NC : constant String := Utils.Hex (Data.NC, 8); begin Response := AWS.Digest.Create (Username => User, Realm => Realm, Password => Pwd, Nonce => Nonce, CNonce => String (CNonce), NC => NC, QOP => QOP, Method => Method, URI => URI); return "qop=""" & QOP & """, cnonce=""" & String (CNonce) & """, nc=" & NC & ", "; end; end if; end QOP_Data; begin Send_Header (Connection.Socket.all, Token & ": Digest " & QOP_Data & "nonce=""" & Nonce & """, username=""" & User & """, realm=""" & Realm & """, uri=""" & URI & """, response=""" & Response & """"); end; end if; end if; end Send_Authentication_Header; ---------------------- -- Send_Common_Post -- ---------------------- procedure Send_Common_Post (Connection : in out HTTP_Connection; Data : Stream_Element_Array; URI : String; SOAPAction : String; Content_Type : String; Headers : Header_List := Empty_Header_List) is begin Open_Send_Common_Header (Connection, "POST", URI, Headers); declare Sock : Net.Socket_Type'Class renames Connection.Socket.all; begin if Content_Type /= Client.No_Data then Send_Header (Sock, Messages.Content_Type_Token, Messages.Content_Type'Access, Content_Type, Headers); end if; if SOAPAction /= Client.No_Data then -- SOAP header if SOAPAction = """""" then -- An empty SOAPAction Send_Header (Sock, Messages.SOAPAction ("")); else Send_Header (Sock, Messages.SOAPAction (SOAPAction)); end if; end if; -- Send message Content_Length Send_Header (Sock, Messages.Content_Length (Data'Length)); Net.Buffered.New_Line (Sock); -- Send message body Net.Buffered.Write (Sock, Data); end; end Send_Common_Post; ----------------- -- Send_Header -- ----------------- procedure Send_Header (Sock : Net.Socket_Type'Class; Data : String) is begin Net.Buffered.Put_Line (Sock, Data); Debug_Message ("> ", Data); end Send_Header; procedure Send_Header (Sock : Net.Socket_Type'Class; Header : String; Constructor : not null access function (Value : String) return String; Value : String; Headers : Header_List) is begin if not Headers.Exist (Header) then Send_Header (Sock, Constructor (Value)); end if; end Send_Header; ------------------ -- Send_Request -- ------------------ procedure Send_Request (Connection : in out HTTP_Connection; Kind : Method_Kind; Result : out Response.Data; URI : String; Data : Stream_Element_Array := No_Data; Headers : Header_List := Empty_Header_List) is use Ada.Real_Time; Stamp : constant Time := Clock; Try_Count : Natural := Connection.Retry; Auth_Attempts : Auth_Attempts_Count := (others => 2); Auth_Is_Over : Boolean; begin Retry : loop begin Open_Send_Common_Header (Connection, Method_Kind'Image (Kind), URI, Headers); -- If there is some data to send if Data'Length > 0 then Send_Header (Connection.Socket.all, Messages.Content_Length (Data'Length)); Net.Buffered.New_Line (Connection.Socket.all); -- Send message body Net.Buffered.Write (Connection.Socket.all, Data); else Net.Buffered.New_Line (Connection.Socket.all); end if; Get_Response (Connection, Result, Get_Body => Kind /= HEAD and then not Connection.Streaming); Decrement_Authentication_Attempt (Connection, Auth_Attempts, Auth_Is_Over); if Auth_Is_Over then return; elsif Kind /= HEAD and then Connection.Streaming then Read_Body (Connection, Result, Store => False); end if; exception when E : Net.Socket_Error | Connection_Error => Error_Processing (Connection, Try_Count, Result, Method_Kind'Image (Kind), E, Stamp); exit Retry when not Response.Is_Empty (Result); end; end loop Retry; end Send_Request; ------------------------ -- Set_Authentication -- ------------------------ procedure Set_Authentication (Auth : out Authentication_Type; User : String; Pwd : String; Mode : Authentication_Mode) is begin Auth.User := To_Unbounded_String (User); Auth.Pwd := To_Unbounded_String (Pwd); Auth.Init_Mode := Mode; -- The Digest authentication could not be send without -- server authentication request, because client have to have nonce -- value, so in the Digest and Any authentication modes we are not -- setting up Work_Mode to the exact value. -- But for Basic authentication we are sending just username/password, -- and do not need any information from server to do it. -- So if the client want to authenticate "Basic", we are setting up -- Work_Mode right now. if Mode = Basic then Auth.Work_Mode := Basic; end if; end Set_Authentication; ------------------------- -- Set_HTTP_Connection -- ------------------------- procedure Set_HTTP_Connection (HTTP_Client : in out HTTP_Connection; Sock_Ptr : Net.Socket_Access) is begin HTTP_Client.Socket := Sock_Ptr; HTTP_Client.Opened := True; end Set_HTTP_Connection; ----------- -- Value -- ----------- function Value (V : String) return Unbounded_String is begin if V = Client.No_Data then return Null_Unbounded_String; else return To_Unbounded_String (V); end if; end Value; end AWS.Client.HTTP_Utils;
Rodeo-McCabe/orka
Ada
2,006
adb
-- 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 Orka.SIMD.SSE.Singles.Arithmetic; with Orka.SIMD.SSE.Singles.Swizzle; package body Orka.SIMD.FMA.Singles.Arithmetic is function "*" (Left, Right : m128_Array) return m128_Array is Result : m128_Array; begin for I in Index_Homogeneous'Range loop Result (I) := Left * Right (I); end loop; return Result; end "*"; function "*" (Left : m128_Array; Right : m128) return m128 is use SIMD.SSE.Singles.Arithmetic; use SIMD.SSE.Singles.Swizzle; Mask_0_0_0_0 : constant Unsigned_32 := 0 or 0 * 4 or 0 * 16 or 0 * 64; Mask_1_1_1_1 : constant Unsigned_32 := 1 or 1 * 4 or 1 * 16 or 1 * 64; Mask_2_2_2_2 : constant Unsigned_32 := 2 or 2 * 4 or 2 * 16 or 2 * 64; Mask_3_3_3_3 : constant Unsigned_32 := 3 or 3 * 4 or 3 * 16 or 3 * 64; XXXX, YYYY, ZZZZ, WWWW, Result : m128; begin XXXX := Shuffle (Right, Right, Mask_0_0_0_0); YYYY := Shuffle (Right, Right, Mask_1_1_1_1); ZZZZ := Shuffle (Right, Right, Mask_2_2_2_2); WWWW := Shuffle (Right, Right, Mask_3_3_3_3); Result := XXXX * Left (X); Result := Multiply_Add (YYYY, Left (Y), Result); Result := Multiply_Add (ZZZZ, Left (Z), Result); Result := Multiply_Add (WWWW, Left (W), Result); return Result; end "*"; end Orka.SIMD.FMA.Singles.Arithmetic;
AdaCore/gpr
Ada
5,126
ads
------------------------------------------------------------------------------ -- -- -- 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 GPR2; with GPR2.Containers; with GPR2.Context; with GPR2.Path_Name; with GPRtools.Options; package GPRls.Options is use GPR2; type Object is new GPRtools.Options.Base_Options with private; -- Options for gprls function Build_From_Command_Line (Self : in out Object) return Boolean; -- Fill out a gprls options object from the command line function Files (Self : Object) return Containers.Value_Set; function Project_Context (Self : Object) return GPR2.Context.Object; function List_File (Self : Object) return Path_Name.Object; function With_Predefined_Units (Self : Object) return Boolean; function Hide_Runtime_Directory (Self : Object) return Boolean; function Print_Units (Self : Object) return Boolean; function Print_Sources (Self : Object) return Boolean; function Print_Object_Files (Self : Object) return Boolean; function Source_Parser (Self : Object) return Boolean; function Dependency_Mode (Self : Object) return Boolean; function Closure_Mode (Self : Object) return Boolean; function All_Projects (Self : Object) return Boolean; function Selective_Output (Self : Object) return Boolean; function Only_Display_Paths (Self : Object) return Boolean; function Gnatdist (Self : Object) return Boolean; procedure Print (Self : Object); private type Output_Type is (Units, Sources, Objects); type Selective_Output_Type is array (Output_Type) of Boolean; -- All_Outputs is the default, and corresponds to all values set to False All_Outputs : constant Selective_Output_Type := (others => False); type Object is new GPRtools.Options.Base_Options with record List_File : Path_Name.Object; With_Predefined_Units : Boolean := False; Hide_Predefined_Path : Boolean := False; Selective_Output : Selective_Output_Type := All_Outputs; Dependency_Mode : Boolean := False; Closure_Mode : Boolean := False; All_Projects : Boolean := False; Only_Display_Paths : Boolean := False; Source_Parser : Boolean := False; Gnatdist : Boolean := False; end record; function Files (Self : Object) return GPR2.Containers.Value_Set is (Self.Args); function Only_Display_Paths (Self : Object) return Boolean is (Self.Only_Display_Paths); function Project_Context (Self : Object) return GPR2.Context.Object is (Self.Context); function List_File (Self : Object) return Path_Name.Object is (Self.List_File); function With_Predefined_Units (Self : Object) return Boolean is (Self.With_Predefined_Units); function Hide_Runtime_Directory (Self : Object) return Boolean is (Self.Hide_Predefined_Path); function Print_Units (Self : Object) return Boolean is (Self.Selective_Output = All_Outputs or else Self.Selective_Output (Units)); function Print_Sources (Self : Object) return Boolean is (Self.Selective_Output = All_Outputs or else Self.Selective_Output (Sources)); function Print_Object_Files (Self : Object) return Boolean is (Self.Selective_Output = All_Outputs or else Self.Selective_Output (Objects)); function Source_Parser (Self : Object) return Boolean is (Self.Source_Parser); function Dependency_Mode (Self : Object) return Boolean is (Self.Dependency_Mode); function Closure_Mode (Self : Object) return Boolean is (Self.Closure_Mode); function All_Projects (Self : Object) return Boolean is (Self.All_Projects); function Selective_Output (Self : Object) return Boolean is (Self.Selective_Output /= All_Outputs); function Gnatdist (Self : Object) return Boolean is (Self.Gnatdist); end GPRls.Options;
ytomino/gnat4drake
Ada
1,610
ads
pragma License (Unrestricted); package GNAT.Regpat is pragma Preelaborate; -- Constants Expression_Error : exception; type Regexp_Bit is ( Case_Insensitive_Bit, Single_Line_Bit, Multiple_Lines_Bit); -- representation type Regexp_Flags is array (Regexp_Bit) of Boolean; pragma Pack (Regexp_Flags); No_Flags : constant Regexp_Flags := (others => False); Case_Insensitive : constant Regexp_Flags := (Case_Insensitive_Bit => True, others => False); Single_Line : constant Regexp_Flags := (Single_Line_Bit => True, others => False); Multiple_Lines : constant Regexp_Flags := (Multiple_Lines_Bit => True, others => False); -- Match_Array subtype Match_Count is Natural; type Match_Location is record First : Natural := 0; Last : Natural := 0; end record; type Match_Array is array (Match_Count range <>) of Match_Location; No_Match : constant Match_Location := (First => 0, Last => 0); -- Pattern_Matcher Compilation type Pattern_Matcher is null record; function Compile (Expression : String; Flags : Regexp_Flags := No_Flags) return Pattern_Matcher; -- Matching a Pre-Compiled Regular Expression function Match ( Self : Pattern_Matcher; Data : String; Data_First : Integer := -1; Data_Last : Positive := Positive'Last) return Boolean; procedure Match ( Self : Pattern_Matcher; Data : String; Matches : out Match_Array; Data_First : Integer := -1; Data_Last : Positive := Positive'Last); end GNAT.Regpat;
onox/orka
Ada
1,111
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.SSE2.Integers.Compare is pragma Pure; function "=" (Left, Right : m128i) return m128i with Import, Convention => Intrinsic, External_Name => "__builtin_ia32_pcmpeqd128"; function ">" (Left, Right : m128i) return m128i with Import, Convention => Intrinsic, External_Name => "__builtin_ia32_pcmpgtd128"; function "<" (Left, Right : m128i) return m128i is (Right > Left); end Orka.SIMD.SSE2.Integers.Compare;
zrmyers/GLFWAda
Ada
1,351
ads
-------------------------------------------------------------------------------- -- 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. -------------------------------------------------------------------------------- package Glfw_Test is end Glfw_Test;
sungyeon/drake
Ada
3,546
adb
with Ada.Exceptions.Finally; with Ada.Unchecked_Conversion; with Ada.Unchecked_Deallocation; with System.Address_To_Named_Access_Conversions; with System.Tasks; package body Ada.Task_Attributes is use type System.Address; package Holder is new Exceptions.Finally.Scoped_Holder ( System.Tasks.Attribute_Index, System.Tasks.Free); Index : aliased System.Tasks.Attribute_Index; function Cast is new Unchecked_Conversion ( Task_Identification.Task_Id, System.Tasks.Task_Id); package Attribute_Handle_Conv is new System.Address_To_Named_Access_Conversions ( Attribute, Attribute_Handle); procedure Free is new Unchecked_Deallocation (Attribute, Attribute_Handle); procedure Finalize (Item : System.Address); procedure Finalize (Item : System.Address) is P : Attribute_Handle := Attribute_Handle_Conv.To_Pointer (Item); begin Free (P); end Finalize; -- implementation function Value ( T : Task_Identification.Task_Id := Task_Identification.Current_Task) return Attribute is begin if Task_Identification.Is_Terminated (T) then raise Tasking_Error; end if; return Result : Attribute do declare procedure Process (Item : System.Address); procedure Process (Item : System.Address) is begin if Item = System.Null_Address then Result := Initial_Value; else Result := Attribute_Handle_Conv.To_Pointer (Item).all; end if; end Process; begin System.Tasks.Query (Cast (T), Index, Process'Access); end; end return; end Value; function Reference ( T : Task_Identification.Task_Id := Task_Identification.Current_Task) return not null Attribute_Handle is begin if Task_Identification.Is_Terminated (T) then raise Tasking_Error; end if; declare function New_Item return System.Address; function New_Item return System.Address is begin return Attribute_Handle_Conv.To_Address ( new Attribute'(Initial_Value)); end New_Item; Result : System.Address; begin System.Tasks.Reference ( Cast (T), Index, New_Item'Access, Finalize'Access, Result); return Attribute_Handle_Conv.To_Pointer (Result); end; end Reference; procedure Set_Value ( Val : Attribute; T : Task_Identification.Task_Id := Task_Identification.Current_Task) is begin if Task_Identification.Is_Terminated (T) then raise Tasking_Error; end if; declare function New_Item return System.Address; function New_Item return System.Address is begin return Attribute_Handle_Conv.To_Address (new Attribute'(Val)); end New_Item; begin System.Tasks.Set ( Cast (T), Index, New_Item'Access, Finalize'Access); end; end Set_Value; procedure Reinitialize ( T : Task_Identification.Task_Id := Task_Identification.Current_Task) is begin if Task_Identification.Is_Terminated (T) then raise Tasking_Error; end if; System.Tasks.Clear (Cast (T), Index); end Reinitialize; begin System.Tasks.Allocate (Index); Holder.Assign (Index); end Ada.Task_Attributes;
stcarrez/helios
Ada
1,389
ads
----------------------------------------------------------------------- -- helios-reports -- Produce reports for the agent -- Copyright (C) 2017 Stephane Carrez -- Written by Stephane Carrez ([email protected]) -- -- Licensed under the Apache License, Version 2.0 (the "License"); -- you may not use this file except in compliance with the License. -- You may obtain a copy of the License at -- -- http://www.apache.org/licenses/LICENSE-2.0 -- -- Unless required by applicable law or agreed to in writing, software -- distributed under the License is distributed on an "AS IS" BASIS, -- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -- See the License for the specific language governing permissions and -- limitations under the License. ----------------------------------------------------------------------- with Util.Serialize.IO; with Helios.Datas; with Helios.Schemas; package Helios.Reports is -- Write the collected snapshot in the IO stream. The output stream can be an XML -- or a JSON stream. The node definition is used for the structure of the output content. procedure Write_Snapshot (Stream : in out Util.Serialize.IO.Output_Stream'Class; Data : in Helios.Datas.Snapshot_Type; Node : in Helios.Schemas.Definition_Type_Access); end Helios.Reports;
charlie5/cBound
Ada
1,749
ads
-- This file is generated by SWIG. Please do not modify by hand. -- with Interfaces; with Interfaces.C; with Interfaces.C.Pointers; package xcb.xcb_convert_selection_request_t is -- Item -- type Item is record major_opcode : aliased Interfaces.Unsigned_8; pad0 : aliased Interfaces.Unsigned_8; length : aliased Interfaces.Unsigned_16; requestor : aliased xcb.xcb_window_t; selection : aliased xcb.xcb_atom_t; target : aliased xcb.xcb_atom_t; property : aliased xcb.xcb_atom_t; time : aliased xcb.xcb_timestamp_t; end record; -- Item_Array -- type Item_Array is array (Interfaces.C .size_t range <>) of aliased xcb.xcb_convert_selection_request_t .Item; -- Pointer -- package C_Pointers is new Interfaces.C.Pointers (Index => Interfaces.C.size_t, Element => xcb.xcb_convert_selection_request_t.Item, Element_Array => xcb.xcb_convert_selection_request_t.Item_Array, Default_Terminator => (others => <>)); subtype Pointer is C_Pointers.Pointer; -- Pointer_Array -- type Pointer_Array is array (Interfaces.C .size_t range <>) of aliased xcb.xcb_convert_selection_request_t .Pointer; -- Pointer_Pointer -- package C_Pointer_Pointers is new Interfaces.C.Pointers (Index => Interfaces.C.size_t, Element => xcb.xcb_convert_selection_request_t.Pointer, Element_Array => xcb.xcb_convert_selection_request_t.Pointer_Array, Default_Terminator => null); subtype Pointer_Pointer is C_Pointer_Pointers.Pointer; end xcb.xcb_convert_selection_request_t;
Componolit/libsparkcrypto
Ada
20,908
adb
------------------------------------------------------------------------------- -- This file is part of libsparkcrypto. -- -- Copyright (C) 2010, Alexander Senier -- Copyright (C) 2010, secunet Security Networks AG -- 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 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. ------------------------------------------------------------------------------- ------------------------------------------------------------------------------- -- ATTENTION: READ THE WARNING IN THE HEADER OF THE SPEC FILE! ------------------------------------------------------------------------------- package body OpenSSL is ---------------------------------------------------------------------------- -- AES ---------------------------------------------------------------------------- function Create_AES128_Enc_Context (Key : LSC.Internal.AES.AES128_Key_Type) return AES_Enc_Context_Type is Result : C_Context_Type; begin C_AES_set_encrypt_key (UserKey => Key'Unrestricted_Access, Bits => 128, AESKey => Result'Unrestricted_Access); return AES_Enc_Context_Type'(C_Context => Result); end Create_AES128_Enc_Context; ---------------------------------------------------------------------------- function Create_AES192_Enc_Context (Key : LSC.Internal.AES.AES192_Key_Type) return AES_Enc_Context_Type is Result : C_Context_Type; begin C_AES_set_encrypt_key (UserKey => Key'Unrestricted_Access, Bits => 192, AESKey => Result'Unrestricted_Access); return AES_Enc_Context_Type'(C_Context => Result); end Create_AES192_Enc_Context; ---------------------------------------------------------------------------- function Create_AES256_Enc_Context (Key : LSC.Internal.AES.AES256_Key_Type) return AES_Enc_Context_Type is Result : C_Context_Type; begin C_AES_set_encrypt_key (UserKey => Key'Unrestricted_Access, Bits => 256, AESKey => Result'Unrestricted_Access); return AES_Enc_Context_Type'(C_Context => Result); end Create_AES256_Enc_Context; ---------------------------------------------------------------------------- function Encrypt (Context : AES_Enc_Context_Type; Plaintext : LSC.Internal.AES.Block_Type) return LSC.Internal.AES.Block_Type is Result : LSC.Internal.AES.Block_Type; begin C_AES_encrypt (In_Block => Plaintext'Unrestricted_Access, Out_Block => Result'Unrestricted_Access, AESKey => Context.C_Context'Unrestricted_Access); return Result; end Encrypt; ---------------------------------------------------------------------------- procedure CBC_Encrypt (Plaintext : in LSC.Internal.AES.Message_Type; Ciphertext : out LSC.Internal.AES.Message_Type; Context : in AES_Enc_Context_Type; IV : in LSC.Internal.AES.Block_Type) is Tmp_IV : LSC.Internal.AES.Block_Type := IV; begin C_AES_CBC_Encrypt (Input => Plaintext'Address, Output => Ciphertext'Address, Length => 16 * Plaintext'Length, AESKey => Context.C_Context'Unrestricted_Access, IV => Tmp_IV'Unrestricted_Access, Enc => 1); end CBC_Encrypt; ---------------------------------------------------------------------------- function Create_AES128_Dec_Context (Key : LSC.Internal.AES.AES128_Key_Type) return AES_Dec_Context_Type is Result : C_Context_Type; begin C_AES_set_decrypt_key (UserKey => Key'Unrestricted_Access, Bits => 128, AESKey => Result'Unrestricted_Access); return AES_Dec_Context_Type'(C_Context => Result); end Create_AES128_Dec_Context; ---------------------------------------------------------------------------- function Create_AES192_Dec_Context (Key : LSC.Internal.AES.AES192_Key_Type) return AES_Dec_Context_Type is Result : C_Context_Type; begin C_AES_set_decrypt_key (UserKey => Key'Unrestricted_Access, Bits => 192, AESKey => Result'Unrestricted_Access); return AES_Dec_Context_Type'(C_Context => Result); end Create_AES192_Dec_Context; ---------------------------------------------------------------------------- function Create_AES256_Dec_Context (Key : LSC.Internal.AES.AES256_Key_Type) return AES_Dec_Context_Type is Result : C_Context_Type; begin C_AES_set_decrypt_key (UserKey => Key'Unrestricted_Access, Bits => 256, AESKey => Result'Unrestricted_Access); return AES_Dec_Context_Type'(C_Context => Result); end Create_AES256_Dec_Context; ---------------------------------------------------------------------------- function Decrypt (Context : AES_Dec_Context_Type; Ciphertext : LSC.Internal.AES.Block_Type) return LSC.Internal.AES.Block_Type is Result : LSC.Internal.AES.Block_Type; begin C_AES_decrypt (In_Block => Ciphertext'Unrestricted_Access, Out_Block => Result'Unrestricted_Access, AESKey => Context.C_Context'Unrestricted_Access); return Result; end Decrypt; ---------------------------------------------------------------------------- procedure CBC_Decrypt (Ciphertext : in LSC.Internal.AES.Message_Type; Plaintext : out LSC.Internal.AES.Message_Type; Context : in AES_Dec_Context_Type; IV : in LSC.Internal.AES.Block_Type) is Tmp_IV : LSC.Internal.AES.Block_Type := IV; begin C_AES_CBC_Encrypt (Input => Ciphertext'Address, Output => Plaintext'Address, Length => 16 * Ciphertext'Length, AESKey => Context.C_Context'Unrestricted_Access, IV => Tmp_IV'Unrestricted_Access, Enc => 0); end CBC_Decrypt; ---------------------------------------------------------------------------- -- SHA-1 ---------------------------------------------------------------------------- procedure SHA1_Context_Init (Context : out SHA1_Context_Type) is begin OpenSSL.C_SHA1_Init (Context.C_Context'Unrestricted_Access); end SHA1_Context_Init; ---------------------------------------------------------------------------- procedure SHA1_Context_Update (Context : in out SHA1_Context_Type; Block : in LSC.Internal.SHA1.Block_Type) is begin OpenSSL.C_SHA1_Update (Context.C_Context'Unrestricted_Access, Block'Unrestricted_Access, 64); end SHA1_Context_Update; ---------------------------------------------------------------------------- procedure SHA1_Context_Finalize (Context : in out SHA1_Context_Type; Block : in LSC.Internal.SHA1.Block_Type; Length : in LSC.Internal.SHA1.Block_Length_Type) is begin OpenSSL.C_SHA1_Update (Context.C_Context'Unrestricted_Access, Block'Unrestricted_Access, Interfaces.C.size_t (Length / 8)); OpenSSL.C_SHA1_Final (Context.Hash'Unrestricted_Access, Context.C_Context'Unrestricted_Access); end SHA1_Context_Finalize; ---------------------------------------------------------------------------- function SHA1_Get_Hash (Context : in SHA1_Context_Type) return LSC.Internal.SHA1.Hash_Type is begin return Context.Hash; end SHA1_Get_Hash; ---------------------------------------------------------------------------- -- SHA-256 ---------------------------------------------------------------------------- procedure SHA256_Context_Init (Context : out SHA256_Context_Type) is begin OpenSSL.C_SHA256_Init (Context.C_Context'Unrestricted_Access); end SHA256_Context_Init; ---------------------------------------------------------------------------- procedure SHA256_Context_Update (Context : in out SHA256_Context_Type; Block : in LSC.Internal.SHA256.Block_Type) is begin OpenSSL.C_SHA256_Update (Context.C_Context'Unrestricted_Access, Block'Unrestricted_Access, 64); end SHA256_Context_Update; ---------------------------------------------------------------------------- procedure SHA256_Context_Finalize (Context : in out SHA256_Context_Type; Block : in LSC.Internal.SHA256.Block_Type; Length : in LSC.Internal.SHA256.Block_Length_Type) is begin OpenSSL.C_SHA256_Update (Context.C_Context'Unrestricted_Access, Block'Unrestricted_Access, Interfaces.C.size_t (Length / 8)); OpenSSL.C_SHA256_Final (Context.Hash'Unrestricted_Access, Context.C_Context'Unrestricted_Access); end SHA256_Context_Finalize; ---------------------------------------------------------------------------- function SHA256_Get_Hash (Context : in SHA256_Context_Type) return LSC.Internal.SHA256.SHA256_Hash_Type is begin return Context.Hash; end SHA256_Get_Hash; ---------------------------------------------------------------------------- -- SHA-384 ---------------------------------------------------------------------------- procedure SHA384_Context_Init (Context : out SHA384_Context_Type) is begin OpenSSL.C_SHA384_Init (Context.C_Context'Unrestricted_Access); end SHA384_Context_Init; ---------------------------------------------------------------------------- procedure SHA384_Context_Update (Context : in out SHA384_Context_Type; Block : in LSC.Internal.SHA512.Block_Type) is begin OpenSSL.C_SHA384_Update (Context.C_Context'Unrestricted_Access, Block'Unrestricted_Access, 128); end SHA384_Context_Update; ---------------------------------------------------------------------------- procedure SHA384_Context_Finalize (Context : in out SHA384_Context_Type; Block : in LSC.Internal.SHA512.Block_Type; Length : in LSC.Internal.SHA512.Block_Length_Type) is begin OpenSSL.C_SHA384_Update (Context.C_Context'Unrestricted_Access, Block'Unrestricted_Access, Interfaces.C.size_t (Length / 8)); OpenSSL.C_SHA384_Final (Context.Hash'Unrestricted_Access, Context.C_Context'Unrestricted_Access); end SHA384_Context_Finalize; ---------------------------------------------------------------------------- function SHA384_Get_Hash (Context : in SHA384_Context_Type) return LSC.Internal.SHA512.SHA384_Hash_Type is begin return Context.Hash; end SHA384_Get_Hash; ---------------------------------------------------------------------------- -- SHA-512 ---------------------------------------------------------------------------- procedure SHA512_Context_Init (Context : out SHA512_Context_Type) is begin OpenSSL.C_SHA512_Init (Context.C_Context'Unrestricted_Access); end SHA512_Context_Init; ---------------------------------------------------------------------------- procedure SHA512_Context_Update (Context : in out SHA512_Context_Type; Block : in LSC.Internal.SHA512.Block_Type) is begin OpenSSL.C_SHA512_Update (Context.C_Context'Unrestricted_Access, Block'Unrestricted_Access, 128); end SHA512_Context_Update; ---------------------------------------------------------------------------- procedure SHA512_Context_Finalize (Context : in out SHA512_Context_Type; Block : in LSC.Internal.SHA512.Block_Type; Length : in LSC.Internal.SHA512.Block_Length_Type) is begin OpenSSL.C_SHA512_Update (Context.C_Context'Unrestricted_Access, Block'Unrestricted_Access, Interfaces.C.size_t (Length / 8)); OpenSSL.C_SHA512_Final (Context.Hash'Unrestricted_Access, Context.C_Context'Unrestricted_Access); end SHA512_Context_Finalize; ---------------------------------------------------------------------------- function SHA512_Get_Hash (Context : in SHA512_Context_Type) return LSC.Internal.SHA512.SHA512_Hash_Type is begin return Context.Hash; end SHA512_Get_Hash; ---------------------------------------------------------------------------- -- RIPEMD-160 ---------------------------------------------------------------------------- procedure RIPEMD160_Context_Init (Context : out RIPEMD160_Context_Type) is begin OpenSSL.C_RIPEMD160_Init (Context.C_Context'Unrestricted_Access); end RIPEMD160_Context_Init; ---------------------------------------------------------------------------- procedure RIPEMD160_Context_Update (Context : in out RIPEMD160_Context_Type; Block : in LSC.Internal.RIPEMD160.Block_Type) is begin OpenSSL.C_RIPEMD160_Update (Context.C_Context'Unrestricted_Access, Block'Unrestricted_Access, 64); end RIPEMD160_Context_Update; ---------------------------------------------------------------------------- procedure RIPEMD160_Context_Finalize (Context : in out RIPEMD160_Context_Type; Block : in LSC.Internal.RIPEMD160.Block_Type; Length : in LSC.Internal.RIPEMD160.Block_Length_Type) is begin OpenSSL.C_RIPEMD160_Update (Context.C_Context'Unrestricted_Access, Block'Unrestricted_Access, Interfaces.C.size_t (Length / 8)); OpenSSL.C_RIPEMD160_Final (Context.Hash'Unrestricted_Access, Context.C_Context'Unrestricted_Access); end RIPEMD160_Context_Finalize; ---------------------------------------------------------------------------- function RIPEMD160_Get_Hash (Context : in RIPEMD160_Context_Type) return LSC.Internal.RIPEMD160.Hash_Type is begin return Context.Hash; end RIPEMD160_Get_Hash; ---------------------------------------------------------------------------- function Authenticate_SHA1 (Key : LSC.Internal.SHA1.Block_Type; Message : SHA1_Message_Type; Length : LSC.Internal.Types.Word64) return LSC.Internal.SHA1.Hash_Type is Temp_Digest : LSC.Internal.SHA1.Hash_Type; begin C_Authenticate_SHA1 (Key'Unrestricted_Access, Message'Unrestricted_Access, Length, Temp_Digest'Unrestricted_Access); return Temp_Digest; end Authenticate_SHA1; ---------------------------------------------------------------------------- function Authenticate_SHA256 (Key : LSC.Internal.SHA256.Block_Type; Message : SHA256_Message_Type; Length : LSC.Internal.Types.Word64) return LSC.Internal.HMAC_SHA256.Auth_Type is Temp_Digest : LSC.Internal.HMAC_SHA256.Auth_Type; begin C_Authenticate_SHA256 (Key'Unrestricted_Access, Message'Unrestricted_Access, Length, Temp_Digest'Unrestricted_Access); return Temp_Digest; end Authenticate_SHA256; ---------------------------------------------------------------------------- function Authenticate_SHA384 (Key : LSC.Internal.SHA512.Block_Type; Message : SHA512_Message_Type; Length : LSC.Internal.Types.Word64) return LSC.Internal.HMAC_SHA384.Auth_Type is Temp_Digest : LSC.Internal.HMAC_SHA384.Auth_Type; begin C_Authenticate_SHA384 (Key'Unrestricted_Access, Message'Unrestricted_Access, Length, Temp_Digest'Unrestricted_Access); return Temp_Digest; end Authenticate_SHA384; ---------------------------------------------------------------------------- function Authenticate_SHA512 (Key : LSC.Internal.SHA512.Block_Type; Message : SHA512_Message_Type; Length : LSC.Internal.Types.Word64) return LSC.Internal.HMAC_SHA512.Auth_Type is Temp_Digest : LSC.Internal.HMAC_SHA512.Auth_Type; begin C_Authenticate_SHA512 (Key'Unrestricted_Access, Message'Unrestricted_Access, Length, Temp_Digest'Unrestricted_Access); return Temp_Digest; end Authenticate_SHA512; ---------------------------------------------------------------------------- function Authenticate_RMD160 (Key : LSC.Internal.RIPEMD160.Block_Type; Message : RMD160_Message_Type; Length : LSC.Internal.Types.Word64) return LSC.Internal.RIPEMD160.Hash_Type is Temp_Digest : LSC.Internal.RIPEMD160.Hash_Type; begin C_Authenticate_RMD160 (Key'Unrestricted_Access, Message'Unrestricted_Access, Length, Temp_Digest'Unrestricted_Access); return Temp_Digest; end Authenticate_RMD160; ---------------------------------------------------------------------------- procedure RSA_Public_Encrypt (M : in LSC.Internal.Bignum.Big_Int; E : in LSC.Internal.Bignum.Big_Int; P : in LSC.Internal.Bignum.Big_Int; C : out LSC.Internal.Bignum.Big_Int; Success : out Boolean) is Result : LSC.Internal.Types.Word64; begin C := (others => 0); C_RSA_Public_Encrypt (M => M'Address, M_Length => LSC.Internal.Types.Word64 (4 * M'Length), E => E'Address, E_Length => LSC.Internal.Types.Word64 (4 * E'Length), P => P'Address, C => C'Address, Result => Result'Address); Success := Result = 0; end RSA_Public_Encrypt; ---------------------------------------------------------------------------- procedure RSA_Private_Decrypt (M : in LSC.Internal.Bignum.Big_Int; E : in LSC.Internal.Bignum.Big_Int; D : in LSC.Internal.Bignum.Big_Int; C : in LSC.Internal.Bignum.Big_Int; P : out LSC.Internal.Bignum.Big_Int; Success : out Boolean) is Result : LSC.Internal.Types.Word64; begin P := (others => 0); C_RSA_Private_Decrypt (M => M'Address, M_Length => LSC.Internal.Types.Word64 (4 * M'Length), E => E'Address, E_Length => LSC.Internal.Types.Word64 (4 * E'Length), D => D'Address, D_Length => LSC.Internal.Types.Word64 (4 * D'Length), C => C'Address, P => P'Address, Result => Result'Address); Success := Result = 0; end RSA_Private_Decrypt; end OpenSSL;
AdaCore/Ada_Drivers_Library
Ada
3,676
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.GPIO; use STM32.GPIO; with Ada.Real_Time; use Ada.Real_Time; procedure Blinky is Period : constant Time_Span := Milliseconds (200); -- arbitrary Next_Release : Time := Clock; begin STM32.Board.Initialize_LEDs; loop Toggle (All_LEDs); Next_Release := Next_Release + Period; delay until Next_Release; end loop; end Blinky;
zhmu/ananas
Ada
450
adb
package body Valid4_Pkg is procedure Inner_Proc (B : in out Boolean); pragma Export_Procedure (Inner_Proc, External => "Inner_Proc", Parameter_Types => (Boolean), Mechanism => Reference); procedure Inner_Proc (B : in out Boolean) is begin B := True; Global := False; end Inner_Proc; procedure Proc (B : in out Boolean) is begin Inner_Proc (B); end Proc; end Valid4_Pkg;
egustafson/sandbox
Ada
701
ads
generic type Element_Type is private; package Generic_Stack is type T is limited private; procedure Push( Stack: in out T; Element: in Element_Type ); procedure Pop( Stack: in out T; Element: out Element_Type ); procedure Peek( Stack: in out T; Element: out Element_Type ); function Empty( Stack: in T ) return Boolean; procedure Reset( Stack: in out T ); Underflow : exception; private type Stack_Node; type Stack_Node_Ptr is access Stack_Node; type Stack_Node is record Data : Element_Type; Next : Stack_Node_Ptr; end record; type T is record Head : Stack_Node_Ptr; end record; end Generic_Stack;
burratoo/Acton
Ada
5,560
ads
------------------------------------------------------------------------------------------ -- -- -- OAK PROCESSOR SUPPORT PACKAGE -- -- ATMEL ATMEGA128P -- -- -- -- OAK.PROCESSOR_SUPPORT_PACKAGE.INTERRUPTS -- -- -- -- Copyright (C) 2012-2021, Patrick Bernardi -- -- -- ------------------------------------------------------------------------------------------ with System; use System; with Oak.Agent.Tasks.Protected_Objects; use Oak.Agent.Tasks.Protected_Objects; package Oak.Processor_Support_Package.Interrupts with Preelaborate is type Oak_Interrupt_Id is range 1 .. 35; Default_Interrupt_Priority : constant Interrupt_Priority := Interrupt_Priority'Last; type Parameterless_Handler is access protected procedure; procedure Initialise_Interrupts; procedure Complete_Interrupt_Initialisation; procedure Attach_Handler (Interrupt : Oak_Interrupt_Id; Handler : Parameterless_Handler; Priority : Interrupt_Priority); procedure Get_Resource (PO : access Agent.Tasks.Protected_Objects.Protected_Agent'Class); procedure Release_Resource (PO : access Agent.Tasks.Protected_Objects.Protected_Agent'Class); private procedure Interrupt_Handler (Id : Oak_Interrupt_Id); Interrupt_Vector_Table : array (Oak_Interrupt_Id) of Parameterless_Handler := (null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null); procedure Vector_1 with Export, Convention => Ada, External_Name => "__PSP_Vector_1"; procedure Vector_2 with Export, Convention => Ada, External_Name => "__PSP_Vector_2"; procedure Vector_3 with Export, Convention => Ada, External_Name => "__PSP_Vector_3"; procedure Vector_4 with Export, Convention => Ada, External_Name => "__PSP_Vector_4"; procedure Vector_5 with Export, Convention => Ada, External_Name => "__PSP_Vector_5"; procedure Vector_6 with Export, Convention => Ada, External_Name => "__PSP_Vector_6"; procedure Vector_7 with Export, Convention => Ada, External_Name => "__PSP_Vector_7"; procedure Vector_8 with Export, Convention => Ada, External_Name => "__PSP_Vector_8"; procedure Vector_9 with Export, Convention => Ada, External_Name => "__PSP_Vector_9"; procedure Vector_10 with Export, Convention => Ada, External_Name => "__PSP_Vector_10"; procedure Vector_11 with Export, Convention => Ada, External_Name => "__PSP_Vector_11"; procedure Vector_12 with Export, Convention => Ada, External_Name => "__PSP_Vector_12"; procedure Vector_13 with Export, Convention => Ada, External_Name => "__PSP_Vector_13"; procedure Vector_14 with Export, Convention => Ada, External_Name => "__PSP_Vector_14"; procedure Vector_15 with Export, Convention => Ada, External_Name => "__PSP_Vector_15"; procedure Vector_16 with Export, Convention => Ada, External_Name => "__PSP_Vector_16"; procedure Vector_17 with Export, Convention => Ada, External_Name => "__PSP_Vector_17"; procedure Vector_18 with Export, Convention => Ada, External_Name => "__PSP_Vector_18"; procedure Vector_19 with Export, Convention => Ada, External_Name => "__PSP_Vector_19"; procedure Vector_20 with Export, Convention => Ada, External_Name => "__PSP_Vector_20"; procedure Vector_21 with Export, Convention => Ada, External_Name => "__PSP_Vector_21"; procedure Vector_22 with Export, Convention => Ada, External_Name => "__PSP_Vector_22"; procedure Vector_23 with Export, Convention => Ada, External_Name => "__PSP_Vector_23"; procedure Vector_24 with Export, Convention => Ada, External_Name => "__PSP_Vector_24"; procedure Vector_25 with Export, Convention => Ada, External_Name => "__PSP_Vector_25"; procedure Vector_26 with Export, Convention => Ada, External_Name => "__PSP_Vector_26"; procedure Vector_27 with Export, Convention => Ada, External_Name => "__PSP_Vector_27"; procedure Vector_28 with Export, Convention => Ada, External_Name => "__PSP_Vector_28"; procedure Vector_29 with Export, Convention => Ada, External_Name => "__PSP_Vector_29"; procedure Vector_30 with Export, Convention => Ada, External_Name => "__PSP_Vector_30"; procedure Vector_31 with Export, Convention => Ada, External_Name => "__PSP_Vector_31"; procedure Vector_32 with Export, Convention => Ada, External_Name => "__PSP_Vector_32"; procedure Vector_33 with Export, Convention => Ada, External_Name => "__PSP_Vector_33"; procedure Vector_34 with Export, Convention => Ada, External_Name => "__PSP_Vector_34"; procedure Vector_35 with Export, Convention => Ada, External_Name => "__PSP_Vector_35"; end Oak.Processor_Support_Package.Interrupts;
stcarrez/ada-servlet
Ada
4,783
ads
----------------------------------------------------------------------- -- servlet-streams-json -- JSON Print streams for servlets -- Copyright (C) 2016, 2018, 2022, 2023 Stephane Carrez -- Written by Stephane Carrez ([email protected]) -- -- Licensed under the Apache License, Version 2.0 (the "License"); -- you may not use this file except in compliance with the License. -- You may obtain a copy of the License at -- -- http://www.apache.org/licenses/LICENSE-2.0 -- -- Unless required by applicable law or agreed to in writing, software -- distributed under the License is distributed on an "AS IS" BASIS, -- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -- See the License for the specific language governing permissions and -- limitations under the License. ----------------------------------------------------------------------- with Ada.Calendar; with Util.Beans.Objects; with Util.Serialize.IO; package Servlet.Streams.Raw is type Print_Stream is limited new Util.Serialize.IO.Output_Stream with private; -- Initialize the stream procedure Initialize (Stream : in out Print_Stream; To : in Servlet.Streams.Print_Stream'Class); -- Flush the buffer (if any) to the sink. overriding procedure Flush (Stream : in out Print_Stream); -- Close the sink. overriding procedure Close (Stream : in out Print_Stream); -- Write the buffer array to the output stream. overriding procedure Write (Stream : in out Print_Stream; Buffer : in Ada.Streams.Stream_Element_Array); -- Write the attribute name/value pair. overriding procedure Write_Attribute (Stream : in out Print_Stream; Name : in String; Value : in String); overriding procedure Write_Wide_Attribute (Stream : in out Print_Stream; Name : in String; Value : in Wide_Wide_String); overriding procedure Write_Attribute (Stream : in out Print_Stream; Name : in String; Value : in Integer); overriding procedure Write_Attribute (Stream : in out Print_Stream; Name : in String; Value : in Boolean); overriding procedure Write_Attribute (Stream : in out Print_Stream; Name : in String; Value : in Util.Beans.Objects.Object); -- Write the attribute with a null value. overriding procedure Write_Null_Attribute (Stream : in out Print_Stream; Name : in String); -- Write the entity value. overriding procedure Write_Entity (Stream : in out Print_Stream; Name : in String; Value : in String); overriding procedure Write_Wide_Entity (Stream : in out Print_Stream; Name : in String; Value : in Wide_Wide_String); overriding procedure Write_Entity (Stream : in out Print_Stream; Name : in String; Value : in Boolean); overriding procedure Write_Entity (Stream : in out Print_Stream; Name : in String; Value : in Integer); overriding procedure Write_Entity (Stream : in out Print_Stream; Name : in String; Value : in Ada.Calendar.Time); overriding procedure Write_Long_Entity (Stream : in out Print_Stream; Name : in String; Value : in Long_Long_Integer); overriding procedure Write_Long_Entity (Stream : in out Print_Stream; Name : in String; Value : in Long_Long_Float); overriding procedure Write_Enum_Entity (Stream : in out Print_Stream; Name : in String; Value : in String); overriding procedure Write_Entity (Stream : in out Print_Stream; Name : in String; Value : in Util.Beans.Objects.Object); -- Write an entity with a null value. overriding procedure Write_Null_Entity (Stream : in out Print_Stream; Name : in String); private type Print_Stream is limited new Util.Serialize.IO.Output_Stream with record Stream : Util.Streams.Texts.Print_Stream_Access; end record; end Servlet.Streams.Raw;
tum-ei-rcs/StratoX
Ada
6,230
ads
-- Institution: Technische Universität München -- Department: Realtime Computer Systems (RCS) -- Project: StratoX -- Module: Units -- -- Authors: Emanuel Regnath ([email protected]) -- -- Description: Additional units for navigation -- with Units.Vectors; use Units.Vectors; with Units.Numerics; use Units.Numerics; with Interfaces; pragma Elaborate_All(Units.Numerics); package Units.Navigation with SPARK_Mode is -- Date subtype Month_Type is Integer range 1 .. 12;-- with Default_Value => 1; subtype Day_Of_Month_Type is Integer range 1 .. 31;-- with Default_Value => 1; subtype Year_Type is Natural; -- absolute year number subtype Week_Type is Integer; subtype GPS_Time_Of_Week_Type is Interfaces.Unsigned_32; -- milliseconds of the GPS week nav epoch type Hour_Type is mod 24 with Default_Value => 0; type Minute_Type is mod 60 with Default_Value => 0; type Second_Type is mod 60 with Default_Value => 0; -- GPS Position subtype Longitude_Type is Units.Angle_Type range -180.0 * Degree .. 180.0 * Degree; subtype Latitude_Type is Units.Angle_Type range -90.0 * Degree .. 90.0 * Degree; subtype Altitude_Type is Units.Length_Type range -10_000.0 * Meter .. 40_000.0 * Meter; type GPS_Loacation_Type is record Longitude : Longitude_Type := 0.0 * Degree; Latitude : Latitude_Type := 0.0 * Degree; Altitude : Altitude_Type := 0.0 * Meter; end record; subtype GPS_Translation_Type is GPS_Loacation_Type; -- FIXME: Δ Altitude could be negative type NED_Coordinates_Type is (DIM_NORTH, DIM_EAST, DIM_DOWN); type NED_Translation_Vector is array(NED_Coordinates_Type) of Length_Type; type Longitude_Array is array (Natural range <>) of Longitude_Type; type Latitude_Array is array (Natural range <>) of Latitude_Type; type Altitude_Array is array (Natural range <>) of Altitude_Type; type GPS_Fix_Type is (NO_FIX, FIX_2D, FIX_3D); -- Orientation subtype Roll_Type is Units.Angle_Type range -180.0 * Degree .. 180.0 * Degree; subtype Pitch_Type is Units.Angle_Type range -90.0 * Degree .. 90.0 * Degree; subtype Yaw_Type is Units.Angle_Type range 0.0 * Degree .. 360.0 * Degree; type Orientation_Type is record Roll : Roll_Type; Pitch : Pitch_Type; Yaw : Yaw_Type; end record; -- Compass Heading -- Route: goal, track: real, course: direction of route, heading: pointing direction of the nose subtype Heading_Type is Angle_Type range 0.0 * Degree .. DEGREE_360; NORTH : constant Heading_Type := 0.0 * Degree; EAST : constant Heading_Type := 90.0 * Degree; SOUTH : constant Heading_Type := 180.0 * Degree; WEST : constant Heading_Type := 270.0 * Degree; EARTH_RADIUS : constant Length_Type := 6378.137 * Kilo * Meter; METER_PER_LAT_DEGREE : constant Length_Angle_Ratio_Type := 111.111 * Kilo * Meter / Degree; -- average lat type Body_Type is record mass : Mass_Type; position : GPS_Loacation_Type; orientation : Orientation_Type; linear_velocity : Linear_Velocity_Vector; angular_velocity : Angular_Velocity_Vector; end record; function Heading(mag_vector : Magnetic_Flux_Density_Vector; orientation : Orientation_Type) return Heading_Type; function Distance (source : GPS_Loacation_Type; target: GPS_Loacation_Type) return Length_Type with Post => Distance'Result in 0.0 * Meter .. 2.0*EARTH_RADIUS*180.0*Degree; -- compute great-circle distance between to Lat/Lon function Bearing (source_location : GPS_Loacation_Type; target_location : GPS_Loacation_Type) return Heading_Type with Post => Bearing'Result in 0.0 * Degree .. 360.0 * Degree; -- compute course (initial bearing, forward azimuth) from source to target location function To_Orientation( rotation : Rotation_Vector ) return Orientation_Type is ( wrap_Angle( rotation(X), Roll_Type'First, Roll_Type'Last ), wrap_Angle( rotation(Y), Pitch_Type'First, Pitch_Type'Last ), wrap_Angle( rotation(Z), Yaw_Type'First, Yaw_Type'Last ) ); function To_NED_Translation( value : GPS_Translation_Type) return NED_Translation_Vector is ( DIM_NORTH => Unit_Type(Cos(value.Latitude)) * value.Longitude * METER_PER_LAT_DEGREE, DIM_EAST => value.Latitude * METER_PER_LAT_DEGREE, DIM_DOWN => -(value.Altitude) ); function Wrap_Add_Lat is new Units.Wrapped_Addition (T => Latitude_Type); function Wrap_Add_Lon is new Units.Wrapped_Addition (T => Longitude_Type); function Sat_Add_Alt is new Units.Saturated_Addition (T => Altitude_Type); function "-" (Left, Right : GPS_Loacation_Type) return GPS_Translation_Type is ( Wrap_Add_Lon (Left.Longitude, - Right.Longitude), Wrap_Add_Lat (Left.Latitude, - Right.Latitude), Sat_Add_Alt (Left.Altitude, - Right.Altitude)); -- subtract two GPS positions, wrapping the Lat/Long and limiting the Altitude -- function "+" (Left : GPS_Loacation_Type; Right : Translation_Vector) return GPS_Loacation_Type is -- ( Longitude => Left.Longitude + Right(X) , Altitude => Left.Altitude - Right(Z) function "+" (Left : Orientation_Type; Right : Rotation_Vector) return Orientation_Type is ( wrap_Angle( Angle_Type( Left.Roll ) + Right(X), Roll_Type'First, Roll_Type'Last ), mirror_Angle( Angle_Type( Left.Pitch) + Right(Y), Pitch_Type'First, Pitch_Type'Last ), wrap_Angle( Angle_Type( Left.Yaw) + Right(Z), Yaw_Type'First, Yaw_Type'Last ) ) with pre => Angle_Type( Left.Roll ) + Right(X) < Angle_Type'Last and Angle_Type( Left.Pitch) + Right(Y) < Angle_Type'Last and Angle_Type( Left.Yaw) + Right(Z) < Angle_Type'Last; function "-" (Left : Orientation_Type; Right : Rotation_Vector) return Orientation_Type is ( wrap_Angle( Left.Roll - Right(X), Roll_Type'First, Roll_Type'Last ), mirror_Angle( Left.Pitch - Right(Y), Pitch_Type'First, Pitch_Type'Last ), wrap_Angle( Left.Yaw - Right(Z), Yaw_Type'First, Yaw_Type'Last ) ); function "-" (Left, Right : Orientation_Type) return Rotation_Vector is ( delta_Angle(Right.Roll, Left.Roll), Left.Pitch - Right.Pitch, delta_Angle(Right.Yaw, Left.Yaw) ); end Units.Navigation;
stcarrez/ada-util
Ada
1,320
ads
----------------------------------------------------------------------- -- util-locales-tests -- Unit tests for Locales -- Copyright (C) 2009, 2010, 2011, 2022 Stephane Carrez -- Written by Stephane Carrez ([email protected]) -- -- Licensed under the Apache License, Version 2.0 (the "License"); -- you may not use this file except in compliance with the License. -- You may obtain a copy of the License at -- -- http://www.apache.org/licenses/LICENSE-2.0 -- -- Unless required by applicable law or agreed to in writing, software -- distributed under the License is distributed on an "AS IS" BASIS, -- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -- See the License for the specific language governing permissions and -- limitations under the License. ----------------------------------------------------------------------- with Util.Tests; package Util.Locales.Tests is procedure Add_Tests (Suite : in Util.Tests.Access_Test_Suite); type Test is new Util.Tests.Test with null record; procedure Test_Get_Locale (T : in out Test); procedure Test_Hash_Locale (T : in out Test); procedure Test_Compare_Locale (T : in out Test); procedure Test_Get_Locales (T : in out Test); procedure Test_Null_Locale (T : in out Test); end Util.Locales.Tests;
zhmu/ananas
Ada
44
ads
package Inline18_Pkg2 is end Inline18_Pkg2;
AdaCore/libadalang
Ada
197
ads
package Foo is function "+" (S : String; I : Integer) return String; function "-" (S : String; I : Integer) return String; function "and" (S : String; I : Integer) return String; end Foo;
ekoeppen/STM32_Generic_Ada_Drivers
Ada
1,778
adb
with System; with STM32_SVD; use STM32_SVD; with STM32_SVD.Flash; use STM32_SVD.Flash; with STM32_SVD.PWR; use STM32_SVD.PWR; with STM32_SVD.SCB; use STM32_SVD.SCB; with STM32_SVD.ADC; use STM32_SVD.ADC; package body STM32GD.Power is procedure Enable_Sleep is begin Flash_Periph.ACR.SLEEP_PD := 1; PWR_Periph.CR.LPDS := 0; PWR_Periph.CR.PDDS := 0; PWR_Periph.CR.ULP := 0; SCB_Periph.SCR.SLEEPDEEP := 0; end Enable_Sleep; procedure Enable_Stop is begin Flash_Periph.ACR.SLEEP_PD := 1; PWR_Periph.CR.LPDS := 1; PWR_Periph.CR.PDDS := 0; PWR_Periph.CR.ULP := 1; SCB_Periph.SCR.SLEEPDEEP := 1; end Enable_Stop; procedure Enable_Standby is begin Flash_Periph.ACR.SLEEP_PD := 1; PWR_Periph.CR.LPDS := 1; PWR_Periph.CR.PDDS := 1; PWR_Periph.CR.ULP := 1; SCB_Periph.SCR.SLEEPDEEP := 1; end Enable_Standby; function Supply_Voltage return Millivolts is V : Millivolts; VREFINT_CAL : aliased STM32_SVD.UInt16 with Address => System'To_Address (16#1FF8_0078#); begin ADC_Periph.CFGR2.CKMODE := 1; ADC_Periph.CR.ADCAL := 1; while ADC_Periph.CR.ADCAL = 1 loop null; end loop; ADC_Periph.CCR.VREFEN := 1; ADC_Periph.ISR.ADRDY := 1; ADC_Periph.CR.ADEN := 1; while ADC_Periph.ISR.ADRDY = 0 loop null; end loop; ADC_Periph.CHSELR.CHSEL.Arr (17) := 1; ADC_Periph.CR.ADSTART := 1; while ADC_Periph.ISR.EOC = 0 loop null; end loop; V := 3000 * Standard.Integer (VREFINT_CAL) / Standard.Integer (ADC_Periph.DR.Data); ADC_Periph.CR.ADDIS := 1; ADC_Periph.CCR.VREFEN := 0; return V; end Supply_Voltage; end STM32GD.Power;
reznikmm/matreshka
Ada
16,916
ads
------------------------------------------------------------------------------ -- -- -- Matreshka Project -- -- -- -- Ada Modeling Framework -- -- -- -- Runtime Library Component -- -- -- ------------------------------------------------------------------------------ -- -- -- Copyright © 2010-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. ------------------------------------------------------------------------------ package AMF.Internals.Tables.Standard_Profile_L2_Metamodel is pragma Preelaborate; function MM_Standard_Profile_L2_Standard_Profile_L2 return AMF.Internals.CMOF_Element; function MC_Standard_Profile_L2_Auxiliary return AMF.Internals.CMOF_Element; function MC_Standard_Profile_L2_Call return AMF.Internals.CMOF_Element; function MC_Standard_Profile_L2_Create return AMF.Internals.CMOF_Element; function MC_Standard_Profile_L2_Derive return AMF.Internals.CMOF_Element; function MC_Standard_Profile_L2_Destroy return AMF.Internals.CMOF_Element; function MC_Standard_Profile_L2_Document return AMF.Internals.CMOF_Element; function MC_Standard_Profile_L2_Entity return AMF.Internals.CMOF_Element; function MC_Standard_Profile_L2_Executable return AMF.Internals.CMOF_Element; function MC_Standard_Profile_L2_File return AMF.Internals.CMOF_Element; function MC_Standard_Profile_L2_Focus return AMF.Internals.CMOF_Element; function MC_Standard_Profile_L2_Framework return AMF.Internals.CMOF_Element; function MC_Standard_Profile_L2_Implement return AMF.Internals.CMOF_Element; function MC_Standard_Profile_L2_Implementation_Class return AMF.Internals.CMOF_Element; function MC_Standard_Profile_L2_Instantiate return AMF.Internals.CMOF_Element; function MC_Standard_Profile_L2_Library return AMF.Internals.CMOF_Element; function MC_Standard_Profile_L2_Metaclass return AMF.Internals.CMOF_Element; function MC_Standard_Profile_L2_Model_Library return AMF.Internals.CMOF_Element; function MC_Standard_Profile_L2_Process return AMF.Internals.CMOF_Element; function MC_Standard_Profile_L2_Realization return AMF.Internals.CMOF_Element; function MC_Standard_Profile_L2_Refine return AMF.Internals.CMOF_Element; function MC_Standard_Profile_L2_Responsibility return AMF.Internals.CMOF_Element; function MC_Standard_Profile_L2_Script return AMF.Internals.CMOF_Element; function MC_Standard_Profile_L2_Send return AMF.Internals.CMOF_Element; function MC_Standard_Profile_L2_Service return AMF.Internals.CMOF_Element; function MC_Standard_Profile_L2_Source return AMF.Internals.CMOF_Element; function MC_Standard_Profile_L2_Specification return AMF.Internals.CMOF_Element; function MC_Standard_Profile_L2_Subsystem return AMF.Internals.CMOF_Element; function MC_Standard_Profile_L2_Trace return AMF.Internals.CMOF_Element; function MC_Standard_Profile_L2_Type return AMF.Internals.CMOF_Element; function MC_Standard_Profile_L2_Utility return AMF.Internals.CMOF_Element; function MP_Standard_Profile_L2_Auxiliary_Base_Class_A_Extension_Auxiliary return AMF.Internals.CMOF_Element; function MP_Standard_Profile_L2_Call_Base_Usage_A_Extension_Call return AMF.Internals.CMOF_Element; function MP_Standard_Profile_L2_Create_Base_Behavioral_Feature_A_Extension_Create return AMF.Internals.CMOF_Element; function MP_Standard_Profile_L2_Create_Base_Usage_A_Extension_Create return AMF.Internals.CMOF_Element; function MP_Standard_Profile_L2_Derive_Base_Abstraction_A_Extension_Derive return AMF.Internals.CMOF_Element; function MP_Standard_Profile_L2_Derive_Computation_A_Extension_Derive return AMF.Internals.CMOF_Element; function MP_Standard_Profile_L2_Destroy_Base_Behavioral_Feature_A_Extension_Destroy return AMF.Internals.CMOF_Element; function MP_Standard_Profile_L2_Document_Base_Artifact_A_Extension_Document return AMF.Internals.CMOF_Element; function MP_Standard_Profile_L2_Entity_Base_Component_A_Extension_Entity return AMF.Internals.CMOF_Element; function MP_Standard_Profile_L2_Executable_Base_Artifact_A_Extension_Executable return AMF.Internals.CMOF_Element; function MP_Standard_Profile_L2_File_Base_Artifact_A_Extension_File return AMF.Internals.CMOF_Element; function MP_Standard_Profile_L2_Focus_Base_Class_A_Extension_Focus return AMF.Internals.CMOF_Element; function MP_Standard_Profile_L2_Framework_Base_Package_A_Extension_Framework return AMF.Internals.CMOF_Element; function MP_Standard_Profile_L2_Implement_Base_Component_A_Extension_Implement return AMF.Internals.CMOF_Element; function MP_Standard_Profile_L2_Implementation_Class_Base_Class_A_Extension_Implementation_Class return AMF.Internals.CMOF_Element; function MP_Standard_Profile_L2_Instantiate_Base_Usage_A_Extension_Instantiate return AMF.Internals.CMOF_Element; function MP_Standard_Profile_L2_Library_Base_Artifact_A_Extension_Library return AMF.Internals.CMOF_Element; function MP_Standard_Profile_L2_Metaclass_Base_Class_A_Extension_Metaclass return AMF.Internals.CMOF_Element; function MP_Standard_Profile_L2_Model_Library_Base_Package_A_Extension_Model_Library return AMF.Internals.CMOF_Element; function MP_Standard_Profile_L2_Process_Base_Component_A_Extension_Process return AMF.Internals.CMOF_Element; function MP_Standard_Profile_L2_Realization_Base_Classifier_A_Extension_Realization return AMF.Internals.CMOF_Element; function MP_Standard_Profile_L2_Refine_Base_Abstraction_A_Extension_Refine return AMF.Internals.CMOF_Element; function MP_Standard_Profile_L2_Responsibility_Base_Usage_A_Extension_Responsibility return AMF.Internals.CMOF_Element; function MP_Standard_Profile_L2_Script_Base_Artifact_A_Extension_Script return AMF.Internals.CMOF_Element; function MP_Standard_Profile_L2_Send_Base_Usage_A_Extension_Send return AMF.Internals.CMOF_Element; function MP_Standard_Profile_L2_Service_Base_Component_A_Extension_Service return AMF.Internals.CMOF_Element; function MP_Standard_Profile_L2_Source_Base_Artifact_A_Extension_Source return AMF.Internals.CMOF_Element; function MP_Standard_Profile_L2_Specification_Base_Classifier_A_Extension_Specification return AMF.Internals.CMOF_Element; function MP_Standard_Profile_L2_Subsystem_Base_Component_A_Extension_Subsystem return AMF.Internals.CMOF_Element; function MP_Standard_Profile_L2_Trace_Base_Abstraction_A_Extension_Trace return AMF.Internals.CMOF_Element; function MP_Standard_Profile_L2_Type_Base_Class_A_Extension_Type return AMF.Internals.CMOF_Element; function MP_Standard_Profile_L2_Utility_Base_Class_A_Extension_Utility return AMF.Internals.CMOF_Element; function MP_Standard_Profile_L2_A_Extension_Focus_Focus_Base_Class return AMF.Internals.CMOF_Element; function MP_Standard_Profile_L2_A_Extension_Implementation_Class_Implementation_Class_Base_Class return AMF.Internals.CMOF_Element; function MP_Standard_Profile_L2_A_Extension_Metaclass_Metaclass_Base_Class return AMF.Internals.CMOF_Element; function MP_Standard_Profile_L2_A_Extension_Type_Type_Base_Class return AMF.Internals.CMOF_Element; function MP_Standard_Profile_L2_A_Extension_Utility_Utility_Base_Class return AMF.Internals.CMOF_Element; function MP_Standard_Profile_L2_A_Extension_Realization_Realization_Base_Classifier return AMF.Internals.CMOF_Element; function MP_Standard_Profile_L2_A_Extension_Specification_Specification_Base_Classifier return AMF.Internals.CMOF_Element; function MP_Standard_Profile_L2_A_Extension_Entity_Entity_Base_Component return AMF.Internals.CMOF_Element; function MP_Standard_Profile_L2_A_Extension_Implement_Implement_Base_Component return AMF.Internals.CMOF_Element; function MP_Standard_Profile_L2_A_Extension_Process_Process_Base_Component return AMF.Internals.CMOF_Element; function MP_Standard_Profile_L2_A_Extension_Service_Service_Base_Component return AMF.Internals.CMOF_Element; function MP_Standard_Profile_L2_A_Extension_Subsystem_Subsystem_Base_Component return AMF.Internals.CMOF_Element; function MP_Standard_Profile_L2_A_Extension_Framework_Framework_Base_Package return AMF.Internals.CMOF_Element; function MP_Standard_Profile_L2_A_Extension_Model_Library_Model_Library_Base_Package return AMF.Internals.CMOF_Element; function MP_Standard_Profile_L2_A_Extension_Call_Call_Base_Usage return AMF.Internals.CMOF_Element; function MP_Standard_Profile_L2_A_Extension_Derive_Derive_Base_Abstraction return AMF.Internals.CMOF_Element; function MP_Standard_Profile_L2_A_Extension_Create_Create_Base_Usage return AMF.Internals.CMOF_Element; function MP_Standard_Profile_L2_A_Extension_Refine_Refine_Base_Abstraction return AMF.Internals.CMOF_Element; function MP_Standard_Profile_L2_A_Extension_Derive_Derive_Computation return AMF.Internals.CMOF_Element; function MP_Standard_Profile_L2_A_Extension_Trace_Trace_Base_Abstraction return AMF.Internals.CMOF_Element; function MP_Standard_Profile_L2_A_Extension_Instantiate_Instantiate_Base_Usage return AMF.Internals.CMOF_Element; function MP_Standard_Profile_L2_A_Extension_Document_Document_Base_Artifact return AMF.Internals.CMOF_Element; function MP_Standard_Profile_L2_A_Extension_Responsibility_Responsibility_Base_Usage return AMF.Internals.CMOF_Element; function MP_Standard_Profile_L2_A_Extension_Executable_Executable_Base_Artifact return AMF.Internals.CMOF_Element; function MP_Standard_Profile_L2_A_Extension_Send_Send_Base_Usage return AMF.Internals.CMOF_Element; function MP_Standard_Profile_L2_A_Extension_File_File_Base_Artifact return AMF.Internals.CMOF_Element; function MP_Standard_Profile_L2_A_Extension_Library_Library_Base_Artifact return AMF.Internals.CMOF_Element; function MP_Standard_Profile_L2_A_Extension_Script_Script_Base_Artifact return AMF.Internals.CMOF_Element; function MP_Standard_Profile_L2_A_Extension_Source_Source_Base_Artifact return AMF.Internals.CMOF_Element; function MP_Standard_Profile_L2_A_Extension_Create_Create_Base_Behavioral_Feature return AMF.Internals.CMOF_Element; function MP_Standard_Profile_L2_A_Extension_Destroy_Destroy_Base_Behavioral_Feature return AMF.Internals.CMOF_Element; function MP_Standard_Profile_L2_A_Extension_Auxiliary_Auxiliary_Base_Class return AMF.Internals.CMOF_Element; function MA_Standard_Profile_L2_A_Extension_Focus_Base_Class return AMF.Internals.CMOF_Element; function MA_Standard_Profile_L2_A_Extension_Implementation_Class_Base_Class return AMF.Internals.CMOF_Element; function MA_Standard_Profile_L2_A_Extension_Metaclass_Base_Class return AMF.Internals.CMOF_Element; function MA_Standard_Profile_L2_A_Extension_Type_Base_Class return AMF.Internals.CMOF_Element; function MA_Standard_Profile_L2_A_Extension_Utility_Base_Class return AMF.Internals.CMOF_Element; function MA_Standard_Profile_L2_A_Extension_Realization_Base_Classifier return AMF.Internals.CMOF_Element; function MA_Standard_Profile_L2_A_Extension_Specification_Base_Classifier return AMF.Internals.CMOF_Element; function MA_Standard_Profile_L2_A_Extension_Entity_Base_Component return AMF.Internals.CMOF_Element; function MA_Standard_Profile_L2_A_Extension_Implement_Base_Component return AMF.Internals.CMOF_Element; function MA_Standard_Profile_L2_A_Extension_Process_Base_Component return AMF.Internals.CMOF_Element; function MA_Standard_Profile_L2_A_Extension_Service_Base_Component return AMF.Internals.CMOF_Element; function MA_Standard_Profile_L2_A_Extension_Subsystem_Base_Component return AMF.Internals.CMOF_Element; function MA_Standard_Profile_L2_A_Extension_Framework_Base_Package return AMF.Internals.CMOF_Element; function MA_Standard_Profile_L2_A_Extension_Model_Library_Base_Package return AMF.Internals.CMOF_Element; function MA_Standard_Profile_L2_A_Extension_Call_Base_Usage return AMF.Internals.CMOF_Element; function MA_Standard_Profile_L2_A_Extension_Derive_Base_Abstraction return AMF.Internals.CMOF_Element; function MA_Standard_Profile_L2_A_Extension_Create_Base_Usage return AMF.Internals.CMOF_Element; function MA_Standard_Profile_L2_A_Extension_Refine_Base_Abstraction return AMF.Internals.CMOF_Element; function MA_Standard_Profile_L2_A_Extension_Derive_Computation return AMF.Internals.CMOF_Element; function MA_Standard_Profile_L2_A_Extension_Trace_Base_Abstraction return AMF.Internals.CMOF_Element; function MA_Standard_Profile_L2_A_Extension_Instantiate_Base_Usage return AMF.Internals.CMOF_Element; function MA_Standard_Profile_L2_A_Extension_Document_Base_Artifact return AMF.Internals.CMOF_Element; function MA_Standard_Profile_L2_A_Extension_Responsibility_Base_Usage return AMF.Internals.CMOF_Element; function MA_Standard_Profile_L2_A_Extension_Executable_Base_Artifact return AMF.Internals.CMOF_Element; function MA_Standard_Profile_L2_A_Extension_Send_Base_Usage return AMF.Internals.CMOF_Element; function MA_Standard_Profile_L2_A_Extension_File_Base_Artifact return AMF.Internals.CMOF_Element; function MA_Standard_Profile_L2_A_Extension_Library_Base_Artifact return AMF.Internals.CMOF_Element; function MA_Standard_Profile_L2_A_Extension_Script_Base_Artifact return AMF.Internals.CMOF_Element; function MA_Standard_Profile_L2_A_Extension_Source_Base_Artifact return AMF.Internals.CMOF_Element; function MA_Standard_Profile_L2_A_Extension_Create_Base_Behavioral_Feature return AMF.Internals.CMOF_Element; function MA_Standard_Profile_L2_A_Extension_Destroy_Base_Behavioral_Feature return AMF.Internals.CMOF_Element; function MA_Standard_Profile_L2_A_Extension_Auxiliary_Base_Class return AMF.Internals.CMOF_Element; function MB_Standard_Profile_L2 return AMF.Internals.AMF_Element; function ML_Standard_Profile_L2 return AMF.Internals.AMF_Element; private Base : AMF.Internals.CMOF_Element := 0; end AMF.Internals.Tables.Standard_Profile_L2_Metamodel;
Intelligente-sanntidssystemer/Ada-prosjekt
Ada
3,905
adb
pragma Warnings (Off); pragma Ada_95; pragma Source_File_Name (ada_main, Spec_File_Name => "b__main.ads"); pragma Source_File_Name (ada_main, Body_File_Name => "b__main.adb"); pragma Suppress (Overflow_Check); package body ada_main is E78 : Short_Integer; pragma Import (Ada, E78, "memory_barriers_E"); E76 : Short_Integer; pragma Import (Ada, E76, "cortex_m__nvic_E"); E68 : Short_Integer; pragma Import (Ada, E68, "nrf__events_E"); E28 : Short_Integer; pragma Import (Ada, E28, "nrf__gpio_E"); E70 : Short_Integer; pragma Import (Ada, E70, "nrf__gpio__tasks_and_events_E"); E72 : Short_Integer; pragma Import (Ada, E72, "nrf__interrupts_E"); E34 : Short_Integer; pragma Import (Ada, E34, "nrf__rtc_E"); E37 : Short_Integer; pragma Import (Ada, E37, "nrf__spi_master_E"); E56 : Short_Integer; pragma Import (Ada, E56, "nrf__tasks_E"); E54 : Short_Integer; pragma Import (Ada, E54, "nrf__adc_E"); E84 : Short_Integer; pragma Import (Ada, E84, "nrf__clock_E"); E80 : Short_Integer; pragma Import (Ada, E80, "nrf__ppi_E"); E41 : Short_Integer; pragma Import (Ada, E41, "nrf__timers_E"); E44 : Short_Integer; pragma Import (Ada, E44, "nrf__twi_E"); E48 : Short_Integer; pragma Import (Ada, E48, "nrf__uart_E"); E06 : Short_Integer; pragma Import (Ada, E06, "nrf__device_E"); E52 : Short_Integer; pragma Import (Ada, E52, "nrf52_dk__ios_E"); E82 : Short_Integer; pragma Import (Ada, E82, "nrf52_dk__time_E"); E87 : Short_Integer; pragma Import (Ada, E87, "sensor_E"); Sec_Default_Sized_Stacks : array (1 .. 1) of aliased System.Secondary_Stack.SS_Stack (System.Parameters.Runtime_Default_Sec_Stack_Size); procedure adainit is Binder_Sec_Stacks_Count : Natural; pragma Import (Ada, Binder_Sec_Stacks_Count, "__gnat_binder_ss_count"); Default_Secondary_Stack_Size : System.Parameters.Size_Type; pragma Import (C, Default_Secondary_Stack_Size, "__gnat_default_ss_size"); Default_Sized_SS_Pool : System.Address; pragma Import (Ada, Default_Sized_SS_Pool, "__gnat_default_ss_pool"); begin null; ada_main'Elab_Body; Default_Secondary_Stack_Size := System.Parameters.Runtime_Default_Sec_Stack_Size; Binder_Sec_Stacks_Count := 1; Default_Sized_SS_Pool := Sec_Default_Sized_Stacks'Address; E78 := E78 + 1; Cortex_M.Nvic'Elab_Spec; E76 := E76 + 1; E68 := E68 + 1; E28 := E28 + 1; E70 := E70 + 1; Nrf.Interrupts'Elab_Body; E72 := E72 + 1; E34 := E34 + 1; E37 := E37 + 1; E56 := E56 + 1; E54 := E54 + 1; E84 := E84 + 1; E80 := E80 + 1; E41 := E41 + 1; E44 := E44 + 1; E48 := E48 + 1; Nrf.Device'Elab_Spec; Nrf.Device'Elab_Body; E06 := E06 + 1; NRF52_DK.IOS'ELAB_SPEC; NRF52_DK.IOS'ELAB_BODY; E52 := E52 + 1; NRF52_DK.TIME'ELAB_BODY; E82 := E82 + 1; E87 := E87 + 1; end adainit; procedure Ada_Main_Program; pragma Import (Ada, Ada_Main_Program, "_ada_main"); procedure main is Ensure_Reference : aliased System.Address := Ada_Main_Program_Name'Address; pragma Volatile (Ensure_Reference); begin adainit; Ada_Main_Program; end; -- BEGIN Object file/option list -- C:\GNAT\Ada_Drivers_Library\examples\NRF52_DK\project2\obj\sensor.o -- C:\GNAT\Ada_Drivers_Library\examples\NRF52_DK\project2\obj\main.o -- -LC:\GNAT\Ada_Drivers_Library\examples\NRF52_DK\project2\obj\ -- -LC:\GNAT\Ada_Drivers_Library\examples\NRF52_DK\project2\obj\ -- -LC:\GNAT\Ada_Drivers_Library\boards\NRF52_DK\obj\zfp_lib_Debug\ -- -LC:\gnat\2020-arm-elf\arm-eabi\lib\gnat\zfp-cortex-m4f\adalib\ -- -static -- -lgnat -- END Object file/option list end ada_main;
twdroeger/ada-awa
Ada
2,398
ads
----------------------------------------------------------------------- -- awa-counters-components -- Counter UI component -- Copyright (C) 2015, 2018 Stephane Carrez -- Written by Stephane Carrez ([email protected]) -- -- Licensed under the Apache License, Version 2.0 (the "License"); -- you may not use this file except in compliance with the License. -- You may obtain a copy of the License at -- -- http://www.apache.org/licenses/LICENSE-2.0 -- -- Unless required by applicable law or agreed to in writing, software -- distributed under the License is distributed on an "AS IS" BASIS, -- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -- See the License for the specific language governing permissions and -- limitations under the License. ----------------------------------------------------------------------- with ASF.Factory; with ASF.Contexts.Faces; with ASF.Components.Html; -- == HTML components == -- The counter component is an Ada Server Faces component that allows to increment -- and display easily the counter. The component works by using the `Counter_Bean` -- Ada bean object which describes the counter in terms of counter definition, the -- associated database entity, and the current counter value. -- -- <awa:counter value="#{wikiPage.counter}"/> -- -- When the component is included in a page the `Counter_Bean` instance associated -- with the EL `value` attribute is used to increment the counter. This is similar -- to calling the `AWA.Counters.Increment` operation from the Ada code. package AWA.Counters.Components is type UICounter is new ASF.Components.Html.UIHtmlComponent with private; -- Check if the counter value is hidden. function Is_Hidden (UI : in UICounter; Context : in ASF.Contexts.Faces.Faces_Context'Class) return Boolean; -- Render the counter component. Starts the DL/DD list and write the input -- component with the possible associated error message. overriding procedure Encode_Begin (UI : in UICounter; Context : in out ASF.Contexts.Faces.Faces_Context'Class); -- Get the AWA Counter component factory. function Definition return ASF.Factory.Factory_Bindings_Access; private type UICounter is new ASF.Components.Html.UIHtmlComponent with null record; end AWA.Counters.Components;
reznikmm/gela
Ada
3,386
ads
------------------------------------------------------------------------------ -- G E L A G R A M M A R S -- -- Library for dealing with grammars for Gela project, -- -- a portable Ada compiler -- -- http://gela.ada-ru.org/ -- -- - - - - - - - - - - - - - - - -- -- Read copyright and license in gela.ads file -- ------------------------------------------------------------------------------ with AG_Tools.Contexts; with AG_Tools.Visit_Generators; with Anagram.Grammars.Rule_Templates; package AG_Tools.Part_Generators is type Generator (Context : AG_Tools.Contexts.Context_Access) is new AG_Tools.Visit_Generators.Part_Generator with null record; overriding procedure Make_Descent (Self : access Generator; Part : Anagram.Grammars.Part_Index; Pass : Positive); overriding procedure Make_Local_Variable (Self : access Generator; Origin : League.Strings.Universal_String; Attribute : Anagram.Grammars.Attribute_Declaration); overriding procedure Make_Local_Variable (Self : access Generator; Part : Anagram.Grammars.Part_Index); overriding procedure Make_Get (Self : access Generator; Attribute : Anagram.Grammars.Attribute; Template : Anagram.Grammars.Rule_Templates.Rule_Template); overriding procedure Make_Set (Self : access Generator; Attribute : Anagram.Grammars.Attribute); type List_Generator (Context : AG_Tools.Contexts.Context_Access) is new Generator (Context) with null record; overriding procedure Make_Descent (Self : access List_Generator; Part : Anagram.Grammars.Part_Index; Pass : Positive); overriding procedure Make_Get (Self : access List_Generator; Attribute : Anagram.Grammars.Attribute; Template : Anagram.Grammars.Rule_Templates.Rule_Template); overriding procedure Make_Set (Self : access List_Generator; Attribute : Anagram.Grammars.Attribute); type Option_Generator (Context : AG_Tools.Contexts.Context_Access) is new Generator (Context) with null record; overriding procedure Make_Descent (Self : access Option_Generator; Part : Anagram.Grammars.Part_Index; Pass : Positive); overriding procedure Make_Get (Self : access Option_Generator; Attribute : Anagram.Grammars.Attribute; Template : Anagram.Grammars.Rule_Templates.Rule_Template); overriding procedure Make_Set (Self : access Option_Generator; Attribute : Anagram.Grammars.Attribute); type Head_Generator (Context : AG_Tools.Contexts.Context_Access) is new Generator (Context) with null record; overriding procedure Make_Descent (Self : access Head_Generator; Part : Anagram.Grammars.Part_Index; Pass : Positive); overriding procedure Make_Set (Self : access Head_Generator; Attribute : Anagram.Grammars.Attribute); overriding procedure Make_Get (Self : access Head_Generator; Attribute : Anagram.Grammars.Attribute; Template : Anagram.Grammars.Rule_Templates.Rule_Template); end AG_Tools.Part_Generators;
mirror/ncurses
Ada
5,287
adb
------------------------------------------------------------------------------ -- -- -- GNAT ncurses Binding -- -- -- -- Terminal_Interface.Curses.Aux -- -- -- -- B O D Y -- -- -- ------------------------------------------------------------------------------ -- Copyright 2020 Thomas E. Dickey -- -- Copyright 1999-2003,2009 Free Software Foundation, Inc. -- -- -- -- Permission is hereby granted, free of charge, to any person obtaining a -- -- copy of this software and associated documentation files (the -- -- "Software"), to deal in the Software without restriction, including -- -- without limitation the rights to use, copy, modify, merge, publish, -- -- distribute, distribute with modifications, sublicense, and/or sell -- -- copies of the Software, and to permit persons to whom the Software is -- -- furnished to do so, subject to the following conditions: -- -- -- -- The above copyright notice and this permission notice shall be included -- -- in all copies or substantial portions of the Software. -- -- -- -- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS -- -- OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -- -- MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. -- -- IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, -- -- DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR -- -- OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR -- -- THE USE OR OTHER DEALINGS IN THE SOFTWARE. -- -- -- -- Except as contained in this notice, the name(s) of the above copyright -- -- holders shall not be used in advertising or otherwise to promote the -- -- sale, use or other dealings in this Software without prior written -- -- authorization. -- ------------------------------------------------------------------------------ -- Author: Juergen Pfeifer, 1996 -- Version Control: -- $Revision: 1.12 $ -- Binding Version 01.00 ------------------------------------------------------------------------------ package body Terminal_Interface.Curses.Aux is -- -- Some helpers procedure Fill_String (Cp : chars_ptr; Str : out String) is -- Fill the string with the characters referenced by the -- chars_ptr. -- Len : Natural; begin if Cp /= Null_Ptr then Len := Natural (Strlen (Cp)); if Str'Length < Len then raise Constraint_Error; end if; declare S : String (1 .. Len); begin S := Value (Cp); Str (Str'First .. (Str'First + Len - 1)) := S (S'Range); end; else Len := 0; end if; if Len < Str'Length then Str ((Str'First + Len) .. Str'Last) := (others => ' '); end if; end Fill_String; function Fill_String (Cp : chars_ptr) return String is Len : Natural; begin if Cp /= Null_Ptr then Len := Natural (Strlen (Cp)); if Len = 0 then return ""; else declare S : String (1 .. Len); begin Fill_String (Cp, S); return S; end; end if; else return ""; end if; end Fill_String; procedure Eti_Exception (Code : Eti_Error) is begin case Code is when E_Ok => null; when E_System_Error => raise Eti_System_Error; when E_Bad_Argument => raise Eti_Bad_Argument; when E_Posted => raise Eti_Posted; when E_Connected => raise Eti_Connected; when E_Bad_State => raise Eti_Bad_State; when E_No_Room => raise Eti_No_Room; when E_Not_Posted => raise Eti_Not_Posted; when E_Unknown_Command => raise Eti_Unknown_Command; when E_No_Match => raise Eti_No_Match; when E_Not_Selectable => raise Eti_Not_Selectable; when E_Not_Connected => raise Eti_Not_Connected; when E_Request_Denied => raise Eti_Request_Denied; when E_Invalid_Field => raise Eti_Invalid_Field; when E_Current => raise Eti_Current; end case; end Eti_Exception; end Terminal_Interface.Curses.Aux;
alvaromb/Compilemon
Ada
42,683
adb
with U_Lexica; use U_Lexica; package body Semantica.Ctipus is procedure Mt_Atom (L, C : in Natural; A : out Atribut) is begin A := (Atom, L, C); end Mt_Atom; procedure Mt_Identificador (L, C : in Natural; S : in String; A : out Atribut) is Id : Id_Nom; begin Id := Id_Nul; Posa_Id(Tn, Id, S); A := (A_Ident, L, C, Id); end Mt_Identificador; procedure Mt_String (L, C : in Natural; S : in String; A : out Atribut) is Id : Rang_Tcar; begin Posa_Str(Tn, Id, S); A := (A_Lit_S, L, C, Valor(Id)); end Mt_String; procedure Mt_Caracter (L, C : in Natural; Car : in String; A : out Atribut) is begin A := (A_Lit_C, L, C, Valor(Character'Pos(Car(Car'First+1)))); end Mt_Caracter; procedure Mt_Numero (L, C : in Natural; S : in String; A : out Atribut) is begin A := (A_Lit_N, L, C, Valor(Integer'Value(S))); end Mt_Numero; -- Taula de simbols procedure Inicia_Enter is D : Descrip; Dt : Descriptipus; Idn, Ida, Idint : Id_Nom; E : Boolean; Ipr : Info_Proc; Idpr : Num_Proc; Iv : Info_Var; Idv : Num_Var; begin -- Constants inicials Posa_Id(Tn, Idn, "_zero"); Iv := (Idn, Tp.Np, Integer'Size/8, 0, Tsent, False, True, 0); Nv := Nv + 1; Posa(Tv, Iv, Zero); Posa_Id(Tn, Idn, "_menysu"); Iv := (Idn, Tp.Np, Integer'Size/8, 0, Tsent, False, True, -1); Posa(Tv, Iv, Menysu); Nv := Nv + 1; -- "Integer" Posa_Id(Tn, Idint, "integer"); Dt := (Tsent, Integer'Size/8, Valor(Integer'First), Valor(Integer'Last)); D := (Dtipus, Dt); Posa(Ts, Idint, D, E); -- "puti" Posa_Id(Tn, Idn, "puti"); Ipr := (Extern, 4, Idn); Posa(Tp, Ipr, Idpr); Np := Np + 1; D := (Dproc, Idpr); Posa(Ts, Idn, D, E); Posa_Id(Tn, Ida, "_arg_puti"); Iv := (Ida, Idpr, Integer'Size/8, Ipr.Ocup_Param, Tsent, True, False, 0); Posa(Tv, Iv, Idv); Nv := Nv + 1; D := (Dargc, Idv, Idint); Posa(Ts, Ida, D, E); Posa_Arg(Ts, Idn, Ida, D, E); Ipr.Ocup_Param := Ipr.Ocup_Param + Iv.Ocup; -- "geti" Posa_Id(Tn, Idn, "geti"); Ipr := (Extern, 4, Idn); Posa(Tp, Ipr, Idpr); Np := Np + 1; D := (Dproc, Idpr); Posa(Ts, Idn, D, E); Posa_Id(Tn, Ida, "_arg_geti"); Iv := (Ida, Idpr, Integer'Size/8, Ipr.Ocup_Param, Tsent, True, False, 0); Posa(Tv, Iv, Idv); Nv := Nv + 1; D := (Dargc, Idv, Idint); Posa(Ts, Ida, D, E); Posa_Arg(Ts, Idn, Ida, D, E); Ipr.Ocup_Param := Ipr.Ocup_Param + Iv.Ocup; end Inicia_Enter; procedure Inicia_Boolea is D : Descrip; Dt : Descriptipus; Idb, Idt, Idf : Id_Nom; E : Boolean; Iv : Info_Var; Idv : Num_Var; begin Posa_Id(Tn, Idb, "boolean"); Dt := (Tsbool, Integer'Size/8, -1, 0); D := (Dtipus, Dt); Posa(Ts, Idb, D, E); Posa_Id(Tn, Idt, "true"); Iv := (Idt, 0, Integer'Size/8, 0, Tsbool, False, True, -1); Posa(Tv, Iv, Idv); Nv := Nv+1; D := (Dconst, Idb, -1, Nv); Posa(Ts, Idt, D, E); Posa_Id(Tn, Idf, "false"); Iv.Id := Idf; Iv.Valconst := 0; Posa(Tv, Iv, Idv); Nv := Nv+1; D := (Dconst, Idb, 0, Nv); Posa(Ts, Idf, D, E); end Inicia_Boolea; procedure Inicia_Caracter is D : Descrip; Dt : Descriptipus; Idn, Idstring, Ida, Idchar : Id_Nom; E : Boolean; Ipr : Info_Proc; Idpr : Num_Proc; Iv : Info_Var; Idv : Num_Var; begin -- "character" Posa_Id(Tn, Idchar, "character"); Dt := (Tscar, 4, Valor(Character'Pos(Character'First)), Valor(Character'Pos(Character'Last))); D := (Dtipus, Dt); Posa(Ts, Idchar, D, E); -- "string" Posa_Id(Tn, Idstring, "string"); Dt := (Tsstr, 4, Idchar, 0); --0 es la base D := (Dtipus, Dt); Posa(Ts, Idstring, D, E); -- putc Posa_Id(Tn, Idn, "putc"); Ipr := (Extern, 4, Idn); Posa(Tp, Ipr, Idpr); Np := Np + 1; D := (Dproc, Idpr); Posa(Ts, Idn, D, E); Posa_Id(Tn, Ida, "_arg_putc"); Iv := (Ida, Idpr, Integer'Size/8, Ipr.Ocup_Param, Tscar, True, False, 0); Posa(Tv, Iv, Idv); nv:= nv +1; D := (Dargc, Idv, Idchar); Posa(Ts, Ida, D, E); Posa_Arg(Ts, Idn, Ida, D, E); Ipr.Ocup_Param := Ipr.Ocup_Param + Iv.Ocup; -- getc Posa_Id(Tn, Idn, "getc"); Ipr := (Extern, 4, Idn); Posa(Tp, Ipr, Idpr); Np := Np + 1; D := (Dproc, Idpr); Posa(Ts, Idn, D, E); Posa_Id(Tn, Ida, "_arg_getc"); Iv := (Ida, Idpr, Integer'Size/8, Ipr.Ocup_Param, Tscar, True, False, 0); Posa(Tv, Iv, Idv); nv:= nv +1; D := (Dargc, Idv, Idchar); Posa(Ts, Ida, D, E); Posa_Arg(Ts, Idn, Ida, D, E); Ipr.Ocup_Param := Ipr.Ocup_Param + Iv.Ocup; -- getcc Posa_Id(Tn, Idn, "getcc"); Ipr := (Extern, 4, Idn); Posa(Tp, Ipr, Idpr); Np := Np + 1; D := (Dproc, Idpr); Posa(Ts, Idn, D, E); Posa_Id(Tn, Ida, "_arg_getcc"); Iv := (Ida, Idpr, 1, Ipr.Ocup_Param, Tscar, True, False, 0); Posa(Tv, Iv, Idv); nv:= nv +1; D := (Dargc, Idv, Idchar); Posa(Ts, Ida, D, E); Posa_Arg(Ts, Idn, Ida, D, E); -- puts Posa_Id(Tn, Idn, "puts"); Ipr := (Extern, 4, Idn); Posa(Tp, Ipr, Idpr); Np := Np + 1; Id_Puts := Idpr; D := (Dproc, Idpr); Posa(Ts, Idn, D, E); --arg_puts Posa_Id(Tn, Ida, "_arg_puts"); Iv := (Ida, Idpr, 4, Ipr.Ocup_Param, Tsstr, True, False, 0);--16 * Integer'Size Posa(Tv, Iv, Idv); nv:= nv +1; D := (Dargc, Idv, Idstring); Posa(Ts, Ida, D, E); Posa_Arg(Ts, Idn, Ida, D, E); Ipr.Ocup_Param := Ipr.Ocup_Param + Iv.Ocup; -- gets Posa_Id(Tn, Idn, "gets"); Ipr := (Extern, 4, Idn); Posa(Tp, Ipr, Idpr); Np := Np + 1; Id_Gets := Idpr; D := (Dproc, Idpr); Posa(Ts, Idn, D, E); --arg_gets Posa_Id(Tn, Ida, "_arg_gets"); Iv := (Ida, Idpr, 4, Ipr.Ocup_Param, Tsstr, True, False, 0); Posa(Tv, Iv, Idv); Nv := Nv +1; D := (Dargc, Idv, Idstring); Posa(Ts, Ida, D, E); Posa_Arg(Ts, Idn, Ida, D, E); Ipr.Ocup_Param := Ipr.Ocup_Param + Iv.Ocup; -- nova linea Posa_Id(Tn, Idn, "new_line"); Ipr := (Extern, 0, Idn); Posa(Tp, Ipr, Idpr); Np := Np + 1; D := (Dproc, Idpr); Posa(Ts, Idn, D, E); end Inicia_Caracter; procedure Inicia_Analisi (Nomfitxer : in String) is begin Nv := 0; Np := 0; Tbuida(Tn); Tbuida(Ts); -- Iniciam les Taules Noves_Taules(Tp, Tv); Inicia_Enter; Inicia_Boolea; Inicia_Caracter; Obre_Fitxer(nomFitxer); end Inicia_analisi; -- Procediments interns procedure Posa_Idvar (Idvar : in Id_Nom; Idtipus : in Id_Nom; L, C : in Natural; E : out Boolean) is Tassig : Descrip; begin Nv := Nv + 1; Tassig := (Dvar, Idtipus, Nv); Posa(Ts, Idvar, Tassig, E); if E then Error(Id_Existent, L, C, Cons_Nom(Tn, Idvar)); Esem := True; end if; end Posa_Idvar; -- Comprovacio de tipus procedure Ct_Programa (A : in Pnode) is D : Descrip; Idproc : Id_nom renames A.Fid5.Id12; Ida : Cursor_Arg; begin Ct_Decprocediment(A); Ida := Primer_Arg(Ts, Idproc); if (Arg_Valid(Ida)) then Error(Paramspprincipal, Cons_Nom(Tn, Idproc)); Esem := True; end if; Tts(Proc_Nul) := Ts; Tanca_Fitxer; end Ct_Programa; procedure Ct_Decprocediment (A : in Pnode) is Encap : Pnode renames A.Fe5; Decls : Pnode renames A.Fc5; Bloc : Pnode renames A.Fd5; Id : Pnode renames A.Fid5; Id_Inf : Id_Nom renames A.Fid5.Id12; Id_Sup : Id_Nom; Tdecls : Tipusnode; np_propi : num_proc; begin Ct_Encap(Encap, Id_Sup); Np_Propi := Np; if Id_Inf /= Id_Sup then Error(Idprogdiferents, A.Fid5.l1, A.Fid5.c1, Cons_Nom(Tn, Id_Sup)); Esem := True; end if; Cons_Tnode(Decls, Tdecls); if Tdecls /= Tnul then Ct_Declaracions(Decls); end if; Ct_Bloc(Bloc); Tts(Np_Propi) := Ts; Surtbloc(Ts,tn); end Ct_Decprocediment; procedure Ct_Encap (A : in Pnode; I : out Id_Nom) is Tproc : Descrip; E : Boolean; Idx_Arg : Cursor_Arg; Ida : Id_Nom; Dn : Descrip; begin if A.Tipus = Pencap then Ct_Pencap(A, I); Idx_Arg := Primer_Arg(Ts, I); while Arg_Valid(Idx_Arg) loop Cons_Arg(Ts, Idx_Arg, Ida, Dn); Posa(Ts, Ida, Dn, E); if E then Error(Enregarg, 3, 3, Cons_Nom(Tn, Ida)); Esem := True; end if; Idx_Arg := Succ_Arg(Ts, Idx_Arg); end loop; else I := A.Id12; Np := Np + 1; Tproc := (Dproc, Np); Posa(Ts, I, Tproc, E); Entrabloc(Ts); if E then Error(Id_Existent, A.l1, A.C1, Cons_Nom(Tn, I)); Esem := True; end if; end if; end Ct_Encap; procedure Ct_Pencap (A : in Pnode; I : out Id_Nom) is Param : Pnode renames A.Fd1; Fesq : Pnode renames A.Fe1; Tproc : Descrip; E : Boolean; begin if Fesq.Tipus = Identificador then Np := Np + 1; Tproc := (Dproc, Np); Posa(Ts, Fesq.Id12, Tproc, E); if E then Error(Id_Existent, Fesq.L1, Fesq.C1, Cons_Nom(Tn, Fesq.Id12)); Esem := True; end if; Entrabloc(Ts); I := Fesq.Id12; else Ct_Pencap(Fesq, I); end if; Ct_Param(Param, I); end Ct_Pencap; procedure Ct_Param (A : in Pnode; I : in Id_Nom) is Idpar : Id_Nom renames A.Fe2.id12; Marg : Mmode renames A.Fc2.M12; Idtipus : Id_Nom renames A.Fd2.id12; D : Descrip; Darg : Descrip; E : Boolean; begin D := Cons(Ts, Idtipus); if D.Td /= Dtipus then Error(Tipusparam, A.Fd2.l1, A.Fd2.c1, Cons_Nom(Tn, Idtipus)); Esem := True; end if; case Marg is when Surt | Entrasurt => Nv := Nv + 1; Darg := (Dvar, Idtipus, Nv); when Entra => Nv := Nv + 1; Darg := (Dargc, Nv, Idtipus); when others => null; end case; Posa_Arg(Ts, I, Idpar, Darg, E); if E then Error(Enregarg, A.Fe2.l1, A.Fe2.c1, Cons_Nom(Tn, IdPar)); Esem := True; end if; end Ct_Param; procedure Ct_Declaracions (A : in Pnode) is Decl : Pnode renames A.Fd1; Decls : Pnode renames A.Fe1; Tnode : Tipusnode; Idrec : Id_Nom; Ocup : Despl; begin if Decls.Tipus = Declaracions then Ct_Declaracions(Decls); end if; Cons_Tnode(Decl, Tnode); case Tnode is when Dvariable => Ct_Decvar(Decl); when Dconstant => Ct_Decconst(Decl); when Dcoleccio => Ct_Deccol(Decl); when Dregistre | Dencapregistre | Firecord => Ocup := 0; Ct_Decregistre(Decl, Idrec,Ocup); when Dsubrang => Ct_Decsubrang(Decl); when Procediment => Ct_Decprocediment(Decl); when others => Esem := True; null; end case; end Ct_Declaracions; procedure Ct_Decvar (A : in Pnode) is Dvariable : Pnode renames A.Fd1; Id : Id_Nom renames A.Fe1.Id12; L : Natural renames A.Fe1.L1; C : Natural renames A.Fe1.C1; Tassig : Descrip; Idtipus : Id_nom; E : Boolean; begin Ct_Declsvar(Dvariable, Idtipus); Posa_Idvar(Id, Idtipus, L, C, E); end Ct_Decvar; procedure Ct_Declsvar (A : in Pnode; Idtipus : out Id_Nom) is Tnode : Tipusnode renames A.Tipus; E : Boolean; Tdecl : Descrip; begin if Tnode = Identificador then Tdecl := Cons(Ts, A.Id12); if (Tdecl.Td /= Dtipus) then Error(Tipusinexistent, A.L1, A.C1, Cons_Nom(Tn, A.Id12)); Esem := True; end if; Idtipus := A.Id12; elsif Tnode = Declmultvar then Ct_Declsvar(A.Fd1, Idtipus); Posa_Idvar(A.Fe1.Id12, Idtipus, A.Fe1.L1, A.Fe1.C1, E); end if; end Ct_Declsvar; procedure Ct_Decconst (A : in Pnode) is Id : Id_Nom renames A.Fe2.Id12; Idtipus : Id_Nom renames A.Fc2.Id12; Val : Pnode renames A.Fd2; E : Boolean; Tdecl : Descrip; Tconst : Descrip; Tsubj : Tipussubjacent; Ids : Id_Nom; L, C : Natural := 0; begin Tdecl := Cons(Ts, Idtipus); if (Tdecl.Td /= Dtipus) then Error(Tipusinexistent, A.Fc2.L1, A.Fc2.C1, Cons_Nom(Tn, Idtipus)); Esem := True; else Ct_Constant(Val, Tsubj, Ids, L, C); if (Tsubj /= Tdecl.Dt.Tt) then Error(Tipussubdiferents, A.Fc2.L1, A.Fc2.C1, Cons_Nom(Tn, Idtipus)); Esem := True; end if; if (Tdecl.Dt.Tt > Tsent) then Error(Tsub_No_Escalar, A.Fc2.L1, A.Fc2.C1, Cons_Nom(Tn, Idtipus)); Esem := True; end if; if (Tsubj = Tsent or Tsubj = Tsbool or Tsubj = Tscar) then if (Val.Val < Tdecl.Dt.Linf) or (Val.Val > Tdecl.Dt.Lsup) then Error(Rang_Sobrepassat, A.Fe2.L1, A.Fe2.C1, Cons_Nom(Tn, Id)); Esem := True; end if; end if; Nv := Nv + 1; Tconst := (Dconst, Idtipus, Val.Val, Nv); Posa(Ts, Id, Tconst, E); if E then Error(Id_Existent, A.Fe2.L1, A.Fe2.C1, Cons_Nom(Tn, Id)); Esem := True; end if; end if; end Ct_Decconst; procedure Ct_Deccol (A : in Pnode) is Darray : Descrip; Dtarray : Descrip; Fesq : Pnode renames A.Fe1; Idtipus_Array : Id_Nom renames A.Fd1.Id12; Idarray : Id_Nom; Ncomponents : Despl; begin Dtarray := Cons(Ts, Idtipus_Array); if (Dtarray.Td /= Dtipus) then Error(Tipusinexistent, A.Fd1.L1, A.Fd1.C1, Cons_Nom(Tn, Idtipus_Array)); Esem := True; else Ct_Pcoleccio(Fesq, Idtipus_Array, Idarray, Ncomponents); Darray := Cons(Ts, Idarray); Darray.Dt.Tcamp := Idtipus_Array; Darray.Dt.Ocup := Ncomponents * Dtarray.Dt.Ocup; Actualitza(Ts, Idarray, Darray); end if; end Ct_Deccol; procedure Ct_Pcoleccio (A : in Pnode; Idtipus_Array : in Id_Nom; Idarray : out Id_Nom; Ncomponents : out Despl) is Fesq : Pnode renames A.Fe1; Idrang : Id_Nom renames A.Fd1.Id12; E : Boolean; Dtarray : Descriptipus; Darray : Descrip; Di : Descrip; begin if (A.Tipus = Pcoleccio) then Ct_Pcoleccio(Fesq, Idtipus_Array, Idarray, Ncomponents); Posa_Idx(Ts, Idarray, Idrang, E); if E then Error(Posaidxarray, A.Fd1.L1, A.Fd1.C1, Cons_Nom(Tn, Idrang)); Esem := True; else Di := Cons(Ts, Idrang); if Di.Td = Dtipus then Ncomponents := Ncomponents * Despl(Di.Dt.Lsup - Di.Dt.Linf + 1); else Error(Tipusidxerroniarray, A.Fd1.L1, A.Fd1.C1, Cons_Nom(Tn, Idrang)); Esem := True; end if; end if; elsif (A.Tipus = Pdimcoleccio) then Dtarray := (Tsarr, 0, Idtipus_Array, 0); Darray := (Dtipus, Dtarray); Idarray := Fesq.Id12; Posa(Ts, Idarray, Darray, E); if E then Error(Tipusinexistent, Fesq.L1, Fesq.C1, Cons_Nom(Tn, Idtipus_Array)); Esem := True; Ncomponents := 0; end if; Di := Cons(Ts, Idrang); if not (Di.Td = Dtipus and then Di.Dt.Tt <= Tsent) then Error(Tipusidxerroniarray, A.Fd1.L1, A.Fd1.C1, Cons_Nom(Tn, Idrang)); Esem := True; Ncomponents := 0; else Posa_Idx(Ts, Idarray, Idrang, E); if E then Put_Line("ERROR CT-pdimcoleccio (DEBUG): "& "error al posa_idx, error "& "del compilador, array no creat,"& " idarr: "&Idarray'Img); Esem := True; end if; Ncomponents := Despl(Di.Dt.Lsup - Di.Dt.Linf + 1); end if; end if; end Ct_Pcoleccio; procedure Ct_Decregistre (A : in Pnode; Idrecord : out Id_Nom; Ocup: in out despl) is Drecord : Descrip; Dtrecord : Descriptipus; E : Boolean; begin if (A.Tipus = Dregistre) then Dtrecord := (Tsrec, 0); Drecord := (Dtipus, Dtrecord); Posa(Ts, A.Fe2.Id12, Drecord, E); Idrecord := A.Fe2.Id12; if E then Error(Id_Existent, A.Fe2.L1, A.Fe2.C1, Cons_Nom(Tn, Idrecord)); Esem := True; end if; Ct_Dregistre_Camp(A.Fe2.Id12, A.Fc2, A.Fd2, Ocup); elsif (A.Tipus = Dencapregistre) then Ct_Decregistre(A.Fe2, Idrecord, Ocup); Ct_Dregistre_Camp(Idrecord, A.Fc2, A.Fd2, Ocup); elsif (A.Tipus = Firecord) then Ct_Decregistre(A.F6, Idrecord, Ocup); Drecord := Cons(Ts, Idrecord); Drecord.Dt.Ocup := Ocup; Actualitza(Ts, Idrecord, Drecord); end if; end Ct_Decregistre; procedure Ct_Dregistre_Camp (Idrecord : in Id_Nom; Camp : in Pnode; Tcamp : in Pnode; Ocup: in out Despl) is Idtcamp : Id_Nom renames Tcamp.Id12; Dtcamp : Descrip; Idcamp : Id_Nom renames Camp.Id12; Desc_Camp : Descrip; E : Boolean; begin Dtcamp := Cons(Ts, Idtcamp); if (Dtcamp.Td /= Dtipus) then Error(Tipusinexistent, Camp.L1, Camp.C1, Cons_Nom(Tn, Idtcamp)); Esem := True; else Desc_Camp := (Dcamp, Idtcamp, Ocup); Posacamp(Ts, Idrecord, Idcamp, Desc_Camp, E); Ocup := Ocup + Dtcamp.Dt.Ocup; if E then Error(IdCampRecordExistent, Camp.L1, Camp.C1, Cons_Nom(Tn, Idcamp)); Esem := True; end if; end if; end Ct_Dregistre_Camp; procedure Ct_Decsubrang (A : in Pnode) is Idsubrang : Id_Nom renames A.Fe5.Id12; Idtsubrang : Id_Nom renames A.Fc5.Id12; Rang_Esq : Pnode renames A.Fd5; Rang_Dret : Pnode renames A.Fid5; Tsub : Tipussubjacent; Tsesq : Tipussubjacent; Tsdret : Tipussubjacent; Idesq : Id_Nom; Iddret : Id_Nom; Valesq : Valor; Valdret : Valor; Tdecl : Descrip; Tdescrip_decl : Descrip; Tdescript_decl : Descriptipus; L, C : Natural := 0; E : Boolean; begin Tdecl := Cons(Ts, Idtsubrang); if(Tdecl.Td /= Dtipus) then Error(TipusInexistent, A.Fc5.L1, A.Fc5.C1, Cons_Nom(Tn, Idtsubrang)); Esem := True; else --Miram el fill esquerra Ct_Constant(Rang_Esq, Tsesq, Idesq, L, C); Valesq := Rang_Esq.Val; --Miram el fill dret Ct_Constant(Rang_Dret, Tsdret, Iddret, L, C); Valdret := Rang_Dret.Val; -- Comparam els tipus if (Tsesq /= Tsdret) then Error(Tipussubdiferents, A.Fc5.L1, A.Fc5.C1, ""&Tsesq'Img&"/"&Tsdret'Img); Esem := True; end if; Tsub := Tsesq; if (Tsub /= Tdecl.Dt.Tt) then Error(Tipussubdiferents, A.Fc5.L1, A.Fc5.C1, ""&Tsub'Img&"/"&Tdecl.Dt.Tt'Img); Esem := True; end if; if (Valesq > Valdret) then Error(ValEsqMajorDret, A.Fc5.L1, A.Fc5.C1, ""&Valesq'Img&" >"&Valdret'Img); Esem := True; end if; if (Valesq < Tdecl.Dt.Linf) then Error(ValEsqMenor, A.Fc5.L1, A.Fc5.C1, Cons_Nom(Tn, Idtsubrang)); Esem := True; end if; if (Valdret > Tdecl.Dt.Lsup) then Error(ValDretMajor, A.Fc5.L1, A.Fc5.C1, Cons_Nom(Tn, Idtsubrang)); Esem := True; end if; case Tsub is when Tsent => Tdescript_Decl := (Tsent, 4, Valesq, Valdret); when Tscar => Tdescript_Decl := (Tscar, 4, Valesq, Valdret); when others => Put_Line("ERROR Ct_subrang: (Sub)Tipus no "& "valid per a un subrang"); Esem := True; end case; Tdescrip_Decl := (Dtipus, Tdescript_Decl); Posa(Ts, Idsubrang, Tdescrip_Decl, E); if E then Error(Id_Existent, A.Fe5.L1, A.Fe5.C1, Cons_Nom(Tn, Idsubrang)); Esem := True; end if; end if; end Ct_Decsubrang; procedure Ct_Expressio (A : in Pnode; T : out Tipussubjacent; Idtipus : out Id_Nom; L, C : in out Natural) is Tipus : Tipusnode renames A.Tipus; Tps : Tipussubjacent; Id : Id_Nom; begin case Tipus is when Expressio => Ct_Expressioc(A, Tps, Id, L, C); when ExpressioUnaria => Ct_Expressiou(A, Tps, Id, L, C); when Identificador => Ct_Identificador(A, Tps, Id, L, C); when Const => Ct_Constant(A, Tps, Id, L, C); when Fireferencia | Referencia => Ct_Referencia_Var(A, Tps, Id); when others => Put_Line("ERROR CT-exp: tipus expressio no "& "trobat :S "&Tipus'Img); Esem := True; end case; T := Tps; Idtipus := Id; end Ct_Expressio; procedure Ct_Operand_Exp (A : in Pnode; T : out Tipussubjacent; Idtipus : out Id_Nom; L, C : in out Natural) is Tipus : Tipusnode renames A.Tipus; begin case Tipus is when Expressio => Ct_Expressioc(A, T, Idtipus, L, C); when ExpressioUnaria => Ct_Expressiou(A, T, Idtipus, L, C); when Referencia | Fireferencia=> Ct_Referencia_var(A, T, IdTipus); when Const => Ct_Constant(A, T, Idtipus, L, C); when Identificador => Ct_Identificador(A, T, Idtipus, L, C); when others => Esem := True; null; end case; end Ct_Operand_Exp; procedure Ct_Expressioc (A : in Pnode; T : out Tipussubjacent; Idtipus : out Id_Nom; L, C : in out Natural) is Fesq : Pnode renames A.Fe3; Fdret : Pnode renames A.Fd3; Op : Operacio renames A.Op3; Tesq : Tipussubjacent; Idesq : Id_Nom; Tdret : Tipussubjacent; Iddret : Id_Nom; begin --Analitzam l'operand esquerra Ct_Operand_Exp(Fesq, Tesq, Idesq, L, C); --Analitzam l'operand dret Ct_Operand_Exp(Fdret, Tdret, Iddret, L, C); -- Comparam els tipus case Op is when Unio | Interseccio => Ct_Exp_Logica(Tesq, Tdret, Idesq, Iddret, T, Idtipus, L, C); when Menor | Menorig | Major | Majorig | Igual | Distint => Ct_Exp_Relacional(Tesq, Tdret, Idesq, Iddret, T, Idtipus, L, C); when Suma | Resta | Mult | Div | Modul => Ct_Exp_Aritmetica(Tesq, Tdret, Idesq, Iddret, T, Idtipus, L, C); when others => Esem := True; null; end case; end Ct_Expressioc; procedure Ct_Exp_Logica (Tesq, Tdret : in Tipussubjacent; Idesq, Iddret : in Id_Nom; T : out Tipussubjacent; Idtipus : out Id_Nom; L, C : in out Natural) is begin if Tesq /= Tsbool then Error(Tsub_No_Bool, L, C, "esquerra"); Esem := True; end if; if Tdret /= Tsbool then Error(Tsub_No_Bool, L, C, "dret"); Esem := True; end if; if Idesq /= Id_Nul and Iddret /= Id_Nul then if Idesq /= Iddret then Error(Tops_Diferents, L, C, ""); Esem := True; end if; end if; if Idesq = Id_Nul then Idtipus := Iddret; else Idtipus := Idesq; end if; T := Tsbool; end Ct_Exp_Logica; procedure Ct_Exp_Relacional (Tesq, Tdret : in Tipussubjacent; Idesq, Iddret : in Id_Nom; T : out Tipussubjacent; Idtipus : out Id_Nom; L, C : in out Natural) is begin if Tesq /= Tdret then Error(Tsubs_Diferents, L, C, ""); Esem := True; end if; if Tesq > Tsent then Error(Tsub_No_Escalar, L, C, "esquerra"); Esem := True; end if; if Tdret > Tsent then Error(Tsub_No_Escalar, L, C, "dret"); Esem := True; end if; if Idesq /= Id_Nul and Iddret /= Id_Nul then if Idesq /= Iddret then Error(Tops_Diferents, L, C, ""); Esem := True; end if; end if; T := Tsbool; Idtipus := Id_Nul; end Ct_Exp_Relacional; procedure Ct_Exp_Aritmetica (Tesq, Tdret : in Tipussubjacent; Idesq, Iddret : in Id_Nom; T : out Tipussubjacent; Idtipus : out Id_Nom; L, C : in out Natural) is begin if Tesq /= Tsent then Error(Tsub_No_Sencer, L, C, "esquerra"); Esem := True; end if; if Tdret /= Tsent then Error(Tsub_No_Sencer, L, C, "dret"); Esem := True; end if; if Idesq /= Id_Nul and Iddret /= Id_Nul then if Idesq /= Iddret then Error(Tops_Diferents, L, C, ""); Esem := True; end if; end if; T := Tsent; if Idesq = Id_Nul then Idtipus := Iddret; else Idtipus := Idesq; end if; end Ct_Exp_Aritmetica; procedure Ct_Expressiou (A : in Pnode; T : out Tipussubjacent; Idtipus : out Id_Nom; L, C : in out Natural) is Fdret : Pnode renames A.F4; Op : Operacio renames A.Op4; Tdret : Tipussubjacent; Iddret : Id_Nom; begin Ct_Operand_Exp(Fdret, Tdret, Iddret, L, C); case Op is when Resta => Ct_Exp_Negacio(Tdret, Iddret, T, Idtipus, L, C); when Negacio => Ct_Exp_Neglogica(Tdret, Iddret, T, Idtipus, L, C); when others => Esem := True; null; end case; end Ct_Expressiou; procedure Ct_Exp_Negacio (Ts : in Tipussubjacent; Id : in Id_Nom; T : out Tipussubjacent; Idtipus : out Id_Nom; L, C : in out Natural) is begin if Ts /= Tsent then Error(Tsub_No_Sencer, L, C, ""); Esem := True; end if; Idtipus := Id; T := Tsent; end Ct_Exp_Negacio; procedure Ct_Exp_Neglogica (Ts : in Tipussubjacent; Id : in Id_Nom; T : out Tipussubjacent; Idtipus : out Id_Nom; L, C: in out Natural) is begin if Ts /= Tsbool then Error(Tsub_No_Bool, L, C, ""); Esem := True; end if; Idtipus := Id; T := Tsbool; end Ct_Exp_Neglogica; procedure Ct_Constant (A : in Pnode; T : out Tipussubjacent; Idtipus : out Id_Nom; L, C : in out Natural) is Tatr : Tipus_Atribut renames A.Tconst; Lin : Natural renames A.L2; Col : Natural renames A.C2; D : Descrip; begin Idtipus := Id_Nul; case (Tatr) is when A_Lit_C => T := Tscar; when A_Lit_N => T := Tsent; when A_Lit_S => T := Tsstr; when others => Put_Line("ERROR CT-constant: tipus constant "& "erroni"); Esem := True; end case; L := Lin; C := Col; end Ct_Constant; procedure Ct_Identificador (A : in Pnode; T : out Tipussubjacent; Idtipus : out Id_Nom; L, C : in out Natural) is Id : Id_Nom renames A.Id12; D : Descrip; Desc : Tdescrip renames D.Td; Lin : Natural renames A.L1; Col : Natural renames A.C1; Carg : Cursor_Arg; begin D := Cons(Ts, Id); case Desc is when Dvar => Idtipus := D.Tr; D := Cons(Ts, Idtipus); if (D.Td = Dtipus) then T := D.Dt.Tt; else Error(Tipus_No_Desc, L, C, D.Td'Img); Esem := True; end if; when Dconst => Idtipus := D.Tc; D := Cons(Ts, Idtipus); if (D.Td = Dtipus) then T := D.Dt.Tt; else Error(Tipus_No_Desc, L, C, D.Td'Img); Esem := True; end if; when Dproc => Carg := Primer_Arg(Ts, Id); if Arg_Valid(Carg) then T := Tsarr; else T := Tsnul; end if; Idtipus := Id; when Dargc => Idtipus := D.Targ; D := Cons(Ts, Idtipus); if (D.Td = Dtipus) then T := D.Dt.Tt; else Error(Tipus_No_Desc, L, C, D.Td'Img); Esem := True; end if; when others => Error(Id_No_Reconegut, L, C, Desc'Img); Esem := True; Idtipus := Id; T := tsnul; end case; L := Lin; C := Col; end Ct_Identificador; procedure Ct_Bloc (A : in Pnode) is D : Descrip; T : Tipussubjacent; Idbase : Id_Nom; Idtipus : Id_Nom; Tsexp : Tipussubjacent; Idexp : Id_Nom; Tsvar : Tipussubjacent; Idvar : Id_Nom; L, C : Natural := 0; begin case (A.Tipus) is when Bloc => Ct_Bloc(A.Fe1); Ct_Bloc(A.Fd1); when Repeticio => Ct_Srep(A); when Identificador => Ct_Identificador(A, T, Idtipus, L, C); if T /= Tsnul then Error(Id_No_Cridaproc, L, C, Cons_Nom(Tn, A.Id12)); Esem := True; end if; when Fireferencia => Ct_Referencia_Proc(A, T, Idbase); when condicionalS => Ct_Sconds(A); when condicionalC => Ct_Scondc(A); when Assignacio => Ct_Referencia_Var(A.Fe1, Tsvar, Idvar); Ct_Expressio(A.Fd1, Tsexp, Idexp, L, C); if Tsvar /= Tsexp then Error(Assig_Tipus_Diferents, L, C, ""); Esem := True; end if; if Idexp /= Id_Nul and Idexp /= Idvar then Error(Assig_Tipus_Diferents, L, C, ""); Esem := True; end if; when others => Esem := True; end case; end Ct_Bloc; procedure Ct_Srep (A : in Pnode) is Tsexp : Tipussubjacent; Idtipus_exp : Id_Nom; Exp : Pnode renames A.Fe1; Bloc : Pnode renames A.fd1; L, C : Natural := 0; begin Ct_Expressio(Exp, Tsexp, Idtipus_Exp, L, C); if tsexp /= tsbool then Error(Exp_No_Bool, L, C, "bucle"); Esem := True; end if; Ct_Bloc(Bloc); end Ct_Srep; procedure Ct_Sconds (A : in Pnode) is Tsexp : Tipussubjacent; Idtipus_exp : Id_Nom; Cond : Pnode renames A.Fe1; Bloc : Pnode renames A.fd1; L, C : Natural := 0; begin Ct_Expressio(Cond, Tsexp, Idtipus_Exp, L, C); if tsexp /= tsbool then Error(Exp_No_Bool, L, C, "condicional"); Esem := True; end if; Ct_Bloc(Bloc); end Ct_Sconds; procedure Ct_Scondc (A : in Pnode) is Tsexp : Tipussubjacent; Idtipus_exp : Id_Nom; Cond : Pnode renames A.Fe2; Bloc : Pnode renames A.fc2; Blocelse : Pnode renames A.fd2; L, C : Natural := 0; begin Ct_Expressio(Cond, Tsexp, Idtipus_Exp, L, C); if tsexp /= tsbool then Error(Exp_No_Bool, L, C, "condicional compost"); Esem := True; end if; Ct_Bloc(Bloc); Ct_Bloc(Blocelse); end Ct_Scondc; procedure Ct_Referencia_Proc (A : in Pnode; T : out Tipussubjacent; Id : out Id_Nom) is Tipus : Tipusnode renames A.Tipus; It_Arg : Cursor_Arg; L, C : Natural := 0; begin case Tipus is when Identificador => Ct_Identificador(A, T, Id, L, C); when Referencia => Error(Rec_No_Cridaproc, L, C, ""); Esem := True; when Fireferencia => Ct_Ref_Pri(A.F6, T, It_Arg); if Arg_Valid(It_Arg) then Error(Falta_Param_Proc, L, C, ""); Esem := True; end if; when others => Put_Line("ERROR CT-referencia: node "& "no reconegut"); Esem := True; end case; end Ct_Referencia_Proc; procedure Ct_Referencia_Var (A : in Pnode; T : out Tipussubjacent; Id : out Id_Nom) is Tipus : Tipusnode renames A.Tipus; Idtipus : Id_Nom; It_Idx : Cursor_Idx; D : Descrip; L, C : Natural := 0; begin case Tipus is when Identificador => Ct_Identificador(A, T, Id, L, C); D := Cons(Ts, Id); if D.Td = Dproc then Error(Refvar_No_Proc, L, C, ""); Esem := True; end if; when Referencia => Ct_Ref_Rec(A, T, Id, Idtipus); when Fireferencia => Ct_Ref_Pri(A.F6, T, Id, It_Idx); if Idx_Valid(It_Idx) then Error(Falta_Param_Array, L, C, ""); Esem := True; end if; if T = Tsarr then D := Cons(Ts, Id); Id := D.Dt.Tcamp; D := Cons(Ts, Id); T := D.Dt.Tt; end if; when others => Esem := True; null; end case; end Ct_Referencia_Var; procedure Ct_Ref_Rec (A : in Pnode; T : out Tipussubjacent; Idtipus : out Id_Nom; Idbase : out Id_Nom) is Fesq : Pnode renames A.Fe1; Tesq : Tipussubjacent; Idbase_Esq : Id_Nom; Dcamp : Descrip; Dtcamp : Descrip; Idcamp : Id_Nom renames A.Fd1.Id12; L, C : Natural := 0; begin Ct_Referencia_Var(Fesq, Tesq, Idbase_Esq); if Tesq /= Tsrec then Error(Reccamp_No_Valid, L, C, ""); Esem := True; end if; Dcamp := Conscamp(Ts, Idbase_Esq, Idcamp); if Dcamp.Td = Dnula then Error(Idrec_No_Valid, L, C, Cons_Nom(Tn, Idcamp)); Esem := True; end if; Idtipus := Dcamp.Tcamp; Dtcamp := Cons(Ts, Dcamp.Tcamp); T := Dtcamp.Dt.Tt; Idbase := Idbase_Esq; end Ct_Ref_Rec; procedure Ct_Ref_Pri (A : in Pnode; T : out Tipussubjacent; Id : out Id_Nom; It_Idx : out Cursor_Idx) is Tipus : Tipusnode renames A.Tipus; Fesq : Pnode renames A.Fe1; Fdret : Pnode renames A.Fd1; Tsub : Tipussubjacent; Idvar : Id_Nom; Tsref : Tipussubjacent; Idref : Id_Nom; Id_Cursor : Id_Nom; Dtipoarg : Descrip; Dbase : Descrip; L, C : Natural := 0; begin case Tipus is when Pri => Ct_Ref_Pri(Fesq, T, Id, It_Idx); Ct_Expressio(Fdret, Tsref, Idref, L, C); if not Idx_Valid(It_Idx) then Error(Sobren_Parametres, L, C, ""); Esem := True; else Id_Cursor := Cons_Idx(Ts, It_Idx); Dtipoarg := Cons(Ts, Id_Cursor); if Idref = Id_Nul then if Dtipoarg.Dt.Tt /= Tsref then Error(Tparam_No_Coincident, L, C, ""); Esem := True; end if; elsif Idref /= Id_cursor then Error(Tparam_No_Coincident, L, C, Cons_Nom(Tn, Idref)&"/"& Cons_Nom(Tn, Id_Cursor)); Esem := True; end if; It_Idx := Succ_Idx(Ts, It_Idx); end if; when Encappri => Ct_Referencia_Var(Fesq, Tsub, Idvar); Ct_Expressio(Fdret, Tsref, Idref, L, C); Dbase := Cons (Ts, Idvar); if Tsub = Tsarr then It_Idx := Primer_Idx(Ts, Idvar); if Idx_Valid(It_Idx) then Id_Cursor := Cons_Idx(Ts, It_Idx); Dtipoarg := Cons(Ts, Id_Cursor); if Idref = Id_Nul then if Dtipoarg.Dt.Tt /= Tsref then Error(Tparam_No_Coincident, L, C, ""); Esem := True; end if; elsif Idref /= Id_Cursor then Error(Tparam_No_Coincident, L, C, Cons_Nom(Tn, Idref)&"/"& Cons_Nom(Tn, Id_Cursor)); Esem := True; end if; end if; else Error(Tipus_No_Array, L, C, Tsub'Img); Esem := True; end if; It_Idx := Succ_Idx(Ts, It_Idx); T := Tsub; Id := Idvar; when others => Esem := True; null; end case; end Ct_Ref_Pri; procedure Ct_Ref_Pri (A : in Pnode; T : out Tipussubjacent; It_Arg : out Cursor_Arg) is Tipus : Tipusnode renames A.Tipus; Fesq : Pnode renames A.Fe1; Fdret : Pnode renames A.Fd1; Tsub : Tipussubjacent; Id : Id_Nom; Tsref : Tipussubjacent; Idref : Id_Nom; Id_Cursor : Id_Nom; Dparam : Descrip; Dtipoarg : Descrip; Dbase : Descrip; L, C : Natural := 0; begin case Tipus is when Pri => -- pri , E Ct_Ref_Pri(Fesq, T, It_Arg); Ct_Expressio(Fdret, Tsref, Idref, L, C); if not Arg_Valid(It_Arg) then Error(Sobren_Parametres, L, C, ""); Esem := True; else Cons_Arg(Ts, It_Arg, Id_Cursor, Dparam); if Idref = Id_Nul then Dtipoarg := Cons(ts, Dparam.targ); if Dtipoarg.Dt.Tt /= Tsref then Error(Tparam_No_Coincident, L, C, Dtipoarg.Dt.Tt'Img); Esem := True; end if; elsif Dparam.td = Dargc then if Idref /= Dparam.targ then Error(Tparam_No_Coincident, L, C, Cons_Nom(Tn, Idref)&"/"& Cons_Nom(Tn, Id_Cursor)); Esem := True; end if; elsif Dparam.td = Dvar then if Idref /= Dparam.Tr then Error(Tparam_No_Coincident, L, C, Cons_Nom(Tn, Idref)&"/"& Cons_Nom(Tn, Id_Cursor)); Esem := True; end if; end if; It_Arg := Succ_Arg(Ts, It_Arg); end if; when Encappri => -- r(E Ct_Referencia_Proc(Fesq, Tsub, Id); Ct_Expressio(Fdret, Tsref, Idref, L, C); Dbase := Cons (Ts, Id); if Tsub = Tsarr and Dbase.td = Dproc then It_Arg := Primer_Arg(Ts, Id); if Arg_Valid(It_Arg) then Cons_Arg(Ts, It_Arg, Id_Cursor, Dparam); if Idref = Id_Nul then if(Dtipoarg.Td /= Dnula) then Dtipoarg := Cons(Ts, Dparam.Targ); if Dtipoarg.Dt.Tt /= Tsref then Error(Tparam_No_Coincident, L, C, ""); Esem := True; end if; end if; elsif Dparam.Td = Dargc then if Idref /= Dparam.Targ then Error(Tparam_No_Coincident, L, C, Cons_Nom(Tn, Idref)&"/"& Cons_Nom(Tn, Id_Cursor)); Esem := True; end if; elsif Dparam.Td = Dvar then if Idref /= Dparam.Tr then Error(Tparam_No_Coincident, L, C, Cons_Nom(Tn, Idref)&"/"& Cons_Nom(Tn, Id_Cursor)); Esem := True; end if; end if; end if; It_Arg := Succ_Arg(Ts, It_Arg); else Error(Tproc_No_Param, L, C, Tsub'Img); Esem := True; end if; T := Tsub; when others => Esem := True; end case; end Ct_Ref_Pri; end Semantica.Ctipus;
michalkonecny/polypaver
Ada
24
ads
procedure PP_Ada_FPops;
cborao/Ada-P1-words
Ada
3,593
adb
with Ada.Text_IO; with Ada.Unchecked_Deallocation; package body Word_Lists is procedure Add_Word (List: in out Word_List_Type; Word: in ASU.Unbounded_String) is Aux: Word_List_Type; Included: Boolean; begin Included := False; if List = null then List := new Cell; List.Word := Word; List.Count := List.Count + 1; Aux := List; Included := True; else Aux := List; -- La segunda palabra es igual a la primera if ASU.To_String(List.Word) = ASU.To_String(Word) then List.Count := List.Count + 1; Included := True; end if; --Recorre la lista while Aux.Next /= null and not Included loop --Ada.Text_IO.Put_Line ("entra en bucle"); if ASU.To_String(Aux.Word) = ASU.To_String(Word) then Aux.Count := Aux.Count + 1; Included := True; end if; Aux := Aux.Next; end loop; --Recorre la última celda de la lista if Aux.Next = null and not Included then if ASU.To_String(Aux.Word) = ASU.To_String(Word) then Aux.Count := Aux.Count + 1; Included := True; end if; end if; --Si no está en la lista, añade una celda if not Included then Aux.Next := new Cell; Aux := Aux.Next; Aux.Word := Word; Aux.Count := Aux.Count + 1; end if; end if; end Add_Word; procedure Delete_Word (List: in out Word_List_Type; Word: in ASU.Unbounded_String) is Aux: Word_List_Type; Previous: Word_List_Type; Found: Boolean; procedure Free is new Ada.Unchecked_Deallocation (Cell, Word_List_Type); begin Found := False; Aux := List; Previous := Aux; while Aux /= null loop if ASU.To_String(Previous.Word) = ASU.To_String(Word) then List := List.Next; Free(Aux); Found := True; elsif ASU.To_String(Aux.Word) = ASU.To_String(Word) then Previous.Next := Aux.Next; Free(Aux); Found := True; else Previous := Aux; Aux := Aux.Next; end if; end loop; if not Found then raise Word_List_Error; end if; end Delete_Word; procedure Search_Word (List: in Word_List_Type; Word: in ASU.Unbounded_String; Count: out Natural) is Finder: Word_List_Type; Found: Boolean; begin Finder := List; Count := 0; Found := False; while Finder /= null loop if ASU.To_String(Finder.Word) = ASU.To_String(Word) then Count := Finder.Count; Found := True; end if; Finder := Finder.Next; end loop; if not Found then raise Word_List_Error; end if; end Search_Word; procedure Max_Word (List: in Word_List_Type; Word: out ASU.Unbounded_String; Count: out Natural) is Maxim: Word_List_Type; begin Maxim := List; Count := 0; while Maxim.next /= null loop if Maxim.Count > Count then Count := Maxim.Count; Word := Maxim.Word; end if; Maxim := Maxim.Next; end loop; if Maxim.Next = null and Maxim.Count > Count then Count := Maxim.Count; Word := Maxim.Word; end if; exception --Si no hay ninguna palabra when Constraint_Error => Ada.Text_IO.Put_Line("No words."); end Max_Word; procedure Print_All (List: in Word_List_Type) is Printer : Word_List_Type; Printed : Boolean; begin Printer := List; Printed := False; Ada.Text_IO.New_Line; while Printer /= null loop Ada.Text_IO.Put("|" & ASU.To_String(Printer.Word) & "| - " ); Ada.Text_IO.Put_Line(Integer'Image(Printer.Count)); Printed := True; Printer := Printer.Next; end loop; if not Printed then Ada.Text_IO.Put_Line("No words."); end if; end Print_All; end Word_Lists;
Fabien-Chouteau/shoot-n-loot
Ada
3,466
adb
-- Shoot'n'loot -- Copyright (c) 2020 Fabien Chouteau with Sound; with Game_Assets.Tileset; with Game_Assets.Tileset_Collisions; with Game_Assets.Misc_Objects; use Game_Assets.Misc_Objects; with GESTE_Config; use GESTE_Config; with GESTE.Tile_Bank; with GESTE.Sprite; package body Chests is Closed_Tile : constant GESTE_Config.Tile_Index := Item.Chest_Closed.Tile_Id; Open_Tile : constant GESTE_Config.Tile_Index := Item.Chest_Open.Tile_Id; Coin_Tile : constant GESTE_Config.Tile_Index := Item.Coin.Tile_Id; Empty_Tile : constant GESTE_Config.Tile_Index := Item.Empty_Tile.Tile_Id; Tile_Bank : aliased GESTE.Tile_Bank.Instance (Game_Assets.Tileset.Tiles'Access, Game_Assets.Tileset_Collisions.Tiles'Access, Game_Assets.Palette'Access); type Chest_Rec is record Sprite : aliased GESTE.Sprite.Instance (Tile_Bank'Access, Closed_Tile); Coin : aliased GESTE.Sprite.Instance (Tile_Bank'Access, Empty_Tile); Coin_TTL : Natural := 0; Pos : GESTE.Pix_Point; Open : Boolean := False; end record; Chest_Array : array (1 .. Max_Nbr_Of_Chests) of Chest_Rec; Last_Chest : Natural := 0; Nbr_Open : Natural := 0; ---------- -- Init -- ---------- procedure Init (Objects : Object_Array) is begin Last_Chest := 0; Nbr_Open := 0; for Chest of Objects loop Last_Chest := Last_Chest + 1; declare C : Chest_Rec renames Chest_Array (Last_Chest); begin C.Pos := (Integer (Chest.X), Integer (Chest.Y) - 8); C.Sprite.Move (C.Pos); C.Sprite.Set_Tile (Closed_Tile); C.Open := False; C.Sprite.Flip_Horizontal (Chest.Flip_Horizontal); C.Coin_TTL := 0; GESTE.Add (Chest_Array (Last_Chest).Sprite'Access, 2); end; end loop; end Init; ----------------------- -- Check_Chest_Found -- ----------------------- procedure Check_Chest_Found (Pt : GESTE.Pix_Point) is begin for Chest of Chest_Array (Chest_Array'First .. Last_Chest) loop if not Chest.Open and then Pt.X in Chest.Pos.X .. Chest.Pos.X + Tile_Size and then Pt.Y in Chest.Pos.Y .. Chest.Pos.Y + Tile_Size then Chest.Sprite.Set_Tile (Open_Tile); Chest.Open := True; Chest.Coin.Set_Tile (Coin_Tile); Chest.Coin.Move ((Chest.Pos.X, Chest.Pos.Y - 8)); Chest.Coin_TTL := 60; GESTE.Add (Chest.Coin'Access, 4); Sound.Play_Coin; Nbr_Open := Nbr_Open + 1; -- Don't try to open more than one chest as they shouldn't be on -- the same tile. return; end if; end loop; end Check_Chest_Found; -------------- -- All_Open -- -------------- function All_Open return Boolean is (Nbr_Open = Last_Chest); ------------ -- Update -- ------------ procedure Update is begin for Chest of Chest_Array (Chest_Array'First .. Last_Chest) loop if Chest.Coin_TTL > 0 then Chest.Coin_TTL := Chest.Coin_TTL - 1; if Chest.Coin_TTL = 1 then Chest.Coin.Set_Tile (Empty_Tile); elsif Chest.Coin_TTL = 0 then GESTE.Remove (Chest.Coin'Access); end if; end if; end loop; end Update; end Chests;
faelys/natools
Ada
32,328
adb
------------------------------------------------------------------------------ -- Copyright (c) 2014-2017, Natacha Porté -- -- -- -- Permission to use, copy, modify, and distribute this software for any -- -- purpose with or without fee is hereby granted, provided that the above -- -- copyright notice and this permission notice appear in all copies. -- -- -- -- THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES -- -- WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF -- -- MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR -- -- ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES -- -- WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN -- -- ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF -- -- OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -- ------------------------------------------------------------------------------ package body Natools.Constant_Indefinite_Ordered_Maps is -------------------------- -- Sorted Array Backend -- -------------------------- function Create (Size : Index_Type; Key_Factory : not null access function (Index : Index_Type) return Key_Type; Element_Factory : not null access function (Index : Index_Type) return Element_Type) return Backend_Array is function Node_Factory (Index : Index_Type) return Node with Inline; function Node_Factory (Index : Index_Type) return Node is begin return (Key => new Key_Type'(Key_Factory (Index)), Element => new Element_Type'(Element_Factory (Index))); end Node_Factory; First_Node : constant Node := Node_Factory (1); begin return Result : Backend_Array := (Ada.Finalization.Limited_Controlled with Size => Size, Nodes => (others => First_Node), Finalized => False) do if Size >= 2 then for I in 2 .. Size loop Result.Nodes (I) := Node_Factory (I); end loop; end if; end return; end Create; function Make_Backend (Size : Count_Type; Key_Factory : not null access function (Index : Index_Type) return Key_Type; Element_Factory : not null access function (Index : Index_Type) return Element_Type) return Backend_Refs.Immutable_Reference is function Create return Backend_Array; function Create return Backend_Array is begin return Create (Size, Key_Factory, Element_Factory); end Create; begin if Size = 0 then return Backend_Refs.Null_Immutable_Reference; else return Backend_Refs.Create (Create'Access); end if; end Make_Backend; function Make_Backend (Map : Unsafe_Maps.Map) return Backend_Refs.Immutable_Reference is function Create return Backend_Array; function Element (Index : Index_Type) return Element_Type; function Key (Index : Index_Type) return Key_Type; procedure Update_Cursor (Index : in Index_Type); function Is_Valid (Nodes : Node_Array) return Boolean; Length : constant Count_Type := Map.Length; Cursor : Unsafe_Maps.Cursor := Map.First; I : Index_Type := 1; function Create return Backend_Array is begin return Create (Length, Key'Access, Element'Access); end Create; function Element (Index : Index_Type) return Element_Type is begin Update_Cursor (Index); return Unsafe_Maps.Element (Cursor); end Element; function Is_Valid (Nodes : Node_Array) return Boolean is begin return (for all J in Nodes'First + 1 .. Nodes'Last => Nodes (J - 1).Key.all < Nodes (J).Key.all); end Is_Valid; function Key (Index : Index_Type) return Key_Type is begin Update_Cursor (Index); pragma Assert (Unsafe_Maps.Has_Element (Cursor)); return Unsafe_Maps.Key (Cursor); end Key; procedure Update_Cursor (Index : in Index_Type) is begin if Index = I + 1 then Unsafe_Maps.Next (Cursor); I := I + 1; elsif Index /= I then raise Program_Error with "Unexpected index value" & Index_Type'Image (Index) & " (previous value" & Index_Type'Image (I) & ')'; end if; end Update_Cursor; Result : Backend_Refs.Immutable_Reference; begin if Length = 0 then return Backend_Refs.Null_Immutable_Reference; end if; Result := Backend_Refs.Create (Create'Access); pragma Assert (I = Length); pragma Assert (Unsafe_Maps."=" (Cursor, Map.Last)); pragma Assert (Is_Valid (Result.Query.Data.Nodes)); return Result; end Make_Backend; overriding procedure Finalize (Object : in out Backend_Array) is Key : Key_Access; Element : Element_Access; begin if not Object.Finalized then for I in Object.Nodes'Range loop Key := Object.Nodes (I).Key; Element := Object.Nodes (I).Element; Free (Key); Free (Element); end loop; Object.Finalized := True; end if; end Finalize; procedure Search (Nodes : in Node_Array; Key : in Key_Type; Floor : out Count_Type; Ceiling : out Count_Type) is Middle : Index_Type; begin Floor := 0; Ceiling := 0; if Nodes'Length = 0 then return; end if; Floor := Nodes'First; if Key < Nodes (Floor).Key.all then Ceiling := Floor; Floor := 0; return; elsif not (Nodes (Floor).Key.all < Key) then Ceiling := Floor; return; end if; Ceiling := Nodes'Last; if Nodes (Ceiling).Key.all < Key then Floor := Ceiling; Ceiling := 0; return; elsif not (Key < Nodes (Ceiling).Key.all) then Floor := Ceiling; return; end if; while Ceiling - Floor >= 2 loop Middle := Floor + (Ceiling - Floor) / 2; if Nodes (Middle).Key.all < Key then Floor := Middle; elsif Key < Nodes (Middle).Key.all then Ceiling := Middle; else Floor := Middle; Ceiling := Middle; return; end if; end loop; return; end Search; ----------------------- -- Cursor Operations -- ----------------------- function "<" (Left, Right : Cursor) return Boolean is begin return Key (Left) < Key (Right); end "<"; function ">" (Left, Right : Cursor) return Boolean is begin return Key (Right) < Key (Left); end ">"; function "<" (Left : Cursor; Right : Key_Type) return Boolean is begin return Key (Left) < Right; end "<"; function ">" (Left : Cursor; Right : Key_Type) return Boolean is begin return Right < Key (Left); end ">"; function "<" (Left : Key_Type; Right : Cursor) return Boolean is begin return Left < Key (Right); end "<"; function ">" (Left : Key_Type; Right : Cursor) return Boolean is begin return Key (Right) < Left; end ">"; procedure Clear (Position : in out Cursor) is begin Position := No_Element; end Clear; function Element (Position : Cursor) return Element_Type is begin return Position.Backend.Query.Data.Nodes (Position.Index).Element.all; end Element; function Key (Position : Cursor) return Key_Type is begin return Position.Backend.Query.Data.Nodes (Position.Index).Key.all; end Key; function Next (Position : Cursor) return Cursor is begin if Position.Is_Empty or else Position.Index >= Position.Backend.Query.Data.Size then return No_Element; else return (Is_Empty => False, Backend => Position.Backend, Index => Position.Index + 1); end if; end Next; procedure Next (Position : in out Cursor) is begin if Position.Is_Empty then null; elsif Position.Index >= Position.Backend.Query.Data.Size then Position := No_Element; else Position.Index := Position.Index + 1; end if; end Next; function Previous (Position : Cursor) return Cursor is begin if Position.Is_Empty or else Position.Index = 1 then return No_Element; else return (Is_Empty => False, Backend => Position.Backend, Index => Position.Index - 1); end if; end Previous; procedure Previous (Position : in out Cursor) is begin if Position.Is_Empty then null; elsif Position.Index = 1 then Position := No_Element; else Position.Index := Position.Index - 1; end if; end Previous; procedure Query_Element (Position : in Cursor; Process : not null access procedure (Key : in Key_Type; Element : in Element_Type)) is Accessor : constant Backend_Refs.Accessor := Position.Backend.Query; begin Process.all (Accessor.Data.Nodes (Position.Index).Key.all, Accessor.Data.Nodes (Position.Index).Element.all); end Query_Element; function Rank (Position : Cursor) return Ada.Containers.Count_Type is begin case Position.Is_Empty is when True => return 0; when False => return Position.Index; end case; end Rank; ----------------------------- -- Non-Standard Operations -- ----------------------------- function Create (Source : Unsafe_Maps.Map) return Constant_Map is begin return (Backend => Make_Backend (Source)); end Create; procedure Replace (Container : in out Constant_Map; New_Items : in Unsafe_Maps.Map) is begin Container.Backend := Make_Backend (New_Items); end Replace; function To_Unsafe_Map (Container : Constant_Map) return Unsafe_Maps.Map is Result : Unsafe_Maps.Map; begin if Container.Backend.Is_Empty then return Result; end if; declare Accessor : constant Backend_Refs.Accessor := Container.Backend.Query; begin for I in Accessor.Data.Nodes'Range loop Result.Insert (Accessor.Data.Nodes (I).Key.all, Accessor.Data.Nodes (I).Element.all); end loop; end; return Result; end To_Unsafe_Map; ----------------------------- -- Constant Map Operations -- ----------------------------- function "=" (Left, Right : Constant_Map) return Boolean is use type Backend_Refs.Immutable_Reference; begin return Left.Backend = Right.Backend; end "="; function Ceiling (Container : Constant_Map; Key : Key_Type) return Cursor is Floor, Ceiling : Count_Type; begin if Container.Is_Empty then return No_Element; end if; Search (Container.Backend.Query.Data.Nodes, Key, Floor, Ceiling); if Ceiling > 0 then return (Is_Empty => False, Backend => Container.Backend, Index => Ceiling); else return No_Element; end if; end Ceiling; procedure Clear (Container : in out Constant_Map) is begin Container.Backend.Reset; end Clear; function Constant_Reference (Container : aliased in Constant_Map; Position : in Cursor) return Constant_Reference_Type is use type Backend_Refs.Immutable_Reference; begin if Position.Is_Empty then raise Constraint_Error with "Constant_Reference called with empty Position"; end if; if Container.Backend /= Position.Backend then raise Program_Error with "Constant_Reference called" & " with unrelated Container and Position"; end if; return (Backend => Container.Backend, Element => Container.Backend.Query.Data.all.Nodes (Position.Index).Element); end Constant_Reference; function Constant_Reference (Container : aliased in Constant_Map; Key : in Key_Type) return Constant_Reference_Type is Position : constant Cursor := Container.Find (Key); begin if Position.Is_Empty then raise Constraint_Error with "Constant_Reference called with Key not in map"; end if; return (Backend => Container.Backend, Element => Container.Backend.Query.Data.Nodes (Position.Index).Element); end Constant_Reference; function Contains (Container : Constant_Map; Key : Key_Type) return Boolean is Floor, Ceiling : Count_Type; begin if Container.Is_Empty then return False; end if; Search (Container.Backend.Query.Data.Nodes, Key, Floor, Ceiling); return Floor = Ceiling; end Contains; function Element (Container : Constant_Map; Key : Key_Type) return Element_Type is begin return Element (Find (Container, Key)); end Element; function Find (Container : Constant_Map; Key : Key_Type) return Cursor is Floor, Ceiling : Count_Type; begin if Container.Is_Empty then return No_Element; end if; Search (Container.Backend.Query.Data.Nodes, Key, Floor, Ceiling); if Floor = Ceiling then return (Is_Empty => False, Backend => Container.Backend, Index => Floor); else return No_Element; end if; end Find; function First (Container : Constant_Map) return Cursor is begin if Container.Is_Empty then return No_Element; else return (Is_Empty => False, Backend => Container.Backend, Index => 1); end if; end First; function First_Element (Container : Constant_Map) return Element_Type is Accessor : constant Backend_Refs.Accessor := Container.Backend.Query; begin return Accessor.Data.Nodes (1).Element.all; end First_Element; function First_Key (Container : Constant_Map) return Key_Type is Accessor : constant Backend_Refs.Accessor := Container.Backend.Query; begin return Accessor.Data.Nodes (1).Key.all; end First_Key; function Floor (Container : Constant_Map; Key : Key_Type) return Cursor is Floor, Ceiling : Count_Type; begin if Container.Is_Empty then return No_Element; end if; Search (Container.Backend.Query.Data.Nodes, Key, Floor, Ceiling); if Floor > 0 then return (Is_Empty => False, Backend => Container.Backend, Index => Floor); else return No_Element; end if; end Floor; procedure Iterate (Container : in Constant_Map; Process : not null access procedure (Position : in Cursor)) is Position : Cursor := (Is_Empty => False, Backend => Container.Backend, Index => 1); begin if Container.Backend.Is_Empty then return; end if; for I in Container.Backend.Query.Data.Nodes'Range loop Position.Index := I; Process.all (Position); end loop; end Iterate; function Iterate (Container : in Constant_Map) return Map_Iterator_Interfaces.Reversible_Iterator'Class is begin return Iterator'(Backend => Container.Backend, Start => No_Element); end Iterate; function Iterate (Container : in Constant_Map; Start : in Cursor) return Map_Iterator_Interfaces.Reversible_Iterator'Class is begin return Iterator'(Backend => Container.Backend, Start => Start); end Iterate; function Iterate (Container : in Constant_Map; First, Last : in Cursor) return Map_Iterator_Interfaces.Reversible_Iterator'Class is begin if Is_Empty (Container) or else not Has_Element (First) or else not Has_Element (Last) or else First > Last then return Iterator'(Backend => Backend_Refs.Null_Immutable_Reference, Start => No_Element); else return Range_Iterator'(Backend => Container.Backend, First_Position => First, Last_Position => Last); end if; end Iterate; function Last (Container : Constant_Map) return Cursor is begin if Container.Is_Empty then return No_Element; else return (Is_Empty => False, Backend => Container.Backend, Index => Container.Backend.Query.Data.Size); end if; end Last; function Last_Element (Container : Constant_Map) return Element_Type is Accessor : constant Backend_Refs.Accessor := Container.Backend.Query; begin return Accessor.Data.Nodes (Accessor.Data.Size).Element.all; end Last_Element; function Last_Key (Container : Constant_Map) return Key_Type is Accessor : constant Backend_Refs.Accessor := Container.Backend.Query; begin return Accessor.Data.Nodes (Accessor.Data.Size).Key.all; end Last_Key; function Length (Container : Constant_Map) return Ada.Containers.Count_Type is begin if Container.Backend.Is_Empty then return 0; else return Container.Backend.Query.Data.Size; end if; end Length; procedure Move (Target, Source : in out Constant_Map) is begin Target.Backend := Source.Backend; Source.Backend.Reset; end Move; procedure Reverse_Iterate (Container : in Constant_Map; Process : not null access procedure (Position : in Cursor)) is Position : Cursor := (Is_Empty => False, Backend => Container.Backend, Index => 1); begin if Container.Backend.Is_Empty then return; end if; for I in reverse Container.Backend.Query.Data.Nodes'Range loop Position.Index := I; Process.all (Position); end loop; end Reverse_Iterate; ---------------------------------------- -- Constant Map "Update" Constructors -- ---------------------------------------- function Insert (Source : in Constant_Map; Key : in Key_Type; New_Item : in Element_Type; Position : out Cursor; Inserted : out Boolean) return Constant_Map is Floor, Ceiling : Count_Type; begin if Source.Is_Empty then declare Backend : constant Backend_Refs.Data_Access := new Backend_Array' (Ada.Finalization.Limited_Controlled with Size => 1, Nodes => (1 => (Key => new Key_Type'(Key), Element => new Element_Type'(New_Item))), Finalized => False); Result : constant Constant_Map := (Backend => Backend_Refs.Create (Backend)); begin Position := (Is_Empty => False, Backend => Result.Backend, Index => 1); Inserted := True; return Result; end; end if; Search (Source.Backend.Query.Data.Nodes, Key, Floor, Ceiling); if Floor = Ceiling then Position := (Is_Empty => False, Backend => Source.Backend, Index => Floor); Inserted := False; return Source; end if; declare function Key_Factory (Index : Index_Type) return Key_Type; function Element_Factory (Index : Index_Type) return Element_Type; Accessor : constant Backend_Refs.Accessor := Source.Backend.Query; function Key_Factory (Index : Index_Type) return Key_Type is begin if Index <= Floor then return Accessor.Nodes (Index).Key.all; elsif Index = Floor + 1 then return Key; else return Accessor.Nodes (Index - 1).Key.all; end if; end Key_Factory; function Element_Factory (Index : Index_Type) return Element_Type is begin if Index <= Floor then return Accessor.Nodes (Index).Element.all; elsif Index = Floor + 1 then return New_Item; else return Accessor.Nodes (Index - 1).Element.all; end if; end Element_Factory; Result : constant Constant_Map := (Backend => Make_Backend (Accessor.Size + 1, Key_Factory'Access, Element_Factory'Access)); begin Position := (Is_Empty => False, Backend => Result.Backend, Index => Floor + 1); Inserted := True; return Result; end; end Insert; function Insert (Source : in Constant_Map; Key : in Key_Type; New_Item : in Element_Type) return Constant_Map is Position : Cursor; Inserted : Boolean; Result : constant Constant_Map := Insert (Source, Key, New_Item, Position, Inserted); begin if not Inserted then raise Constraint_Error with "Inserted key already in Constant_Map"; end if; return Result; end Insert; function Include (Source : in Constant_Map; Key : in Key_Type; New_Item : in Element_Type) return Constant_Map is Position : Cursor; Inserted : Boolean; Result : constant Constant_Map := Insert (Source, Key, New_Item, Position, Inserted); begin if Inserted then return Result; end if; declare function Key_Factory (Index : Index_Type) return Key_Type; function Element_Factory (Index : Index_Type) return Element_Type; Accessor : constant Backend_Refs.Accessor := Source.Backend.Query; function Key_Factory (Index : Index_Type) return Key_Type is begin if Index = Position.Index then return Key; else return Accessor.Nodes (Index).Key.all; end if; end Key_Factory; function Element_Factory (Index : Index_Type) return Element_Type is begin if Index = Position.Index then return New_Item; else return Accessor.Nodes (Index).Element.all; end if; end Element_Factory; Result : constant Constant_Map := (Backend => Make_Backend (Accessor.Size, Key_Factory'Access, Element_Factory'Access)); begin return Result; end; end Include; function Replace (Source : in Constant_Map; Key : in Key_Type; New_Item : in Element_Type) return Constant_Map is Floor, Ceiling : Count_Type; begin if Source.Is_Empty then raise Constraint_Error with "Replace called on empty Constant_Map"; end if; Search (Source.Backend.Query.Data.Nodes, Key, Floor, Ceiling); if Floor /= Ceiling then raise Constraint_Error with "Replace called with key not in Constant_Map"; end if; return Replace_Element (Source => Source, Position => (Is_Empty => False, Backend => Source.Backend, Index => Floor), New_Item => New_Item); end Replace; function Replace_Element (Source : in Constant_Map; Position : in Cursor; New_Item : in Element_Type) return Constant_Map is use type Backend_Refs.Immutable_Reference; begin if Position.Is_Empty then raise Constraint_Error with "Constant_Map.Replace_Element called with empty cursor"; end if; if Source.Backend /= Position.Backend then raise Program_Error with "Constant_Map.Replace_Element " & "with unrelated container and cursor"; end if; declare function Key_Factory (Index : Index_Type) return Key_Type; function Element_Factory (Index : Index_Type) return Element_Type; Accessor : constant Backend_Refs.Accessor := Source.Backend.Query; function Key_Factory (Index : Index_Type) return Key_Type is begin return Accessor.Nodes (Index).Key.all; end Key_Factory; function Element_Factory (Index : Index_Type) return Element_Type is begin if Index = Position.Index then return New_Item; else return Accessor.Nodes (Index).Element.all; end if; end Element_Factory; Result : constant Constant_Map := (Backend => Make_Backend (Accessor.Size, Key_Factory'Access, Element_Factory'Access)); begin return Result; end; end Replace_Element; function Replace_Element (Source : in Constant_Map; Position : in Cursor; New_Item : in Element_Type; New_Position : out Cursor) return Constant_Map is Result : constant Constant_Map := Replace_Element (Source, Position, New_Item); begin New_Position := (Is_Empty => False, Backend => Result.Backend, Index => Position.Index); return Result; end Replace_Element; function Exclude (Source : in Constant_Map; Key : in Key_Type) return Constant_Map is Floor, Ceiling : Count_Type; begin if Source.Is_Empty then return Source; end if; Search (Source.Backend.Query.Data.Nodes, Key, Floor, Ceiling); if Floor = Ceiling then return Delete (Source, Cursor'(Is_Empty => False, Backend => Source.Backend, Index => Floor)); else return Source; end if; end Exclude; function Delete (Source : in Constant_Map; Key : in Key_Type) return Constant_Map is Floor, Ceiling : Count_Type; begin if Source.Is_Empty then raise Constraint_Error with "Delete called on empty Constant_Map"; end if; Search (Source.Backend.Query.Data.Nodes, Key, Floor, Ceiling); if Floor /= Ceiling then raise Constraint_Error with "Deleted key not in Constant_Map"; end if; return Delete (Source, (Is_Empty => False, Backend => Source.Backend, Index => Floor)); end Delete; function Delete (Source : in Constant_Map; Position : in Cursor) return Constant_Map is use type Backend_Refs.Immutable_Reference; begin if Position.Is_Empty then raise Constraint_Error with "Constant_Map.Delete with empty cursor"; end if; if Source.Backend /= Position.Backend then raise Program_Error with "Constant_Map.Delete with unrelated container and cursor"; end if; declare function Key_Factory (Index : Index_Type) return Key_Type; function Element_Factory (Index : Index_Type) return Element_Type; Accessor : constant Backend_Refs.Accessor := Source.Backend.Query; function Key_Factory (Index : Index_Type) return Key_Type is begin if Index < Position.Index then return Accessor.Nodes (Index).Key.all; else return Accessor.Nodes (Index + 1).Key.all; end if; end Key_Factory; function Element_Factory (Index : Index_Type) return Element_Type is begin if Index < Position.Index then return Accessor.Nodes (Index).Element.all; else return Accessor.Nodes (Index + 1).Element.all; end if; end Element_Factory; Result : constant Constant_Map := (Backend => Make_Backend (Accessor.Size - 1, Key_Factory'Access, Element_Factory'Access)); begin return Result; end; end Delete; ------------------------------ -- Updatable Map Operations -- ------------------------------ function Constant_Reference_For_Bugged_GNAT (Container : aliased in Updatable_Map; Position : in Cursor) return Constant_Reference_Type is begin return Constant_Reference (Constant_Map (Container), Position); end Constant_Reference_For_Bugged_GNAT; function Constant_Reference_For_Bugged_GNAT (Container : aliased in Updatable_Map; Key : in Key_Type) return Constant_Reference_Type is begin return Constant_Reference (Constant_Map (Container), Key); end Constant_Reference_For_Bugged_GNAT; function Reference (Container : aliased in out Updatable_Map; Position : in Cursor) return Reference_Type is use type Backend_Refs.Immutable_Reference; begin if Position.Is_Empty then raise Constraint_Error with "Reference called with empty Position"; end if; if Container.Backend /= Position.Backend then raise Program_Error with "Reference called with unrelated Container and Position"; end if; return (Backend => Container.Backend, Element => Container.Backend.Query.Data.Nodes (Position.Index).Element); end Reference; function Reference (Container : aliased in out Updatable_Map; Key : in Key_Type) return Reference_Type is Position : constant Cursor := Container.Find (Key); begin if Position.Is_Empty then raise Constraint_Error with "Reference called with Key not in map"; end if; return (Backend => Container.Backend, Element => Container.Backend.Query.Data.Nodes (Position.Index).Element); end Reference; procedure Update_Element (Container : in out Updatable_Map; Position : in Cursor; Process : not null access procedure (Key : in Key_Type; Element : in out Element_Type)) is pragma Unreferenced (Container); Accessor : constant Backend_Refs.Accessor := Position.Backend.Query; begin Process.all (Accessor.Data.Nodes (Position.Index).Key.all, Accessor.Data.Nodes (Position.Index).Element.all); end Update_Element; ------------------------- -- Iterator Operations -- ------------------------- overriding function First (Object : Iterator) return Cursor is begin if Has_Element (Object.Start) then return Object.Start; elsif Object.Backend.Is_Empty then return No_Element; else return (Is_Empty => False, Backend => Object.Backend, Index => 1); end if; end First; overriding function Last (Object : Iterator) return Cursor is begin if Has_Element (Object.Start) then return Object.Start; elsif Object.Backend.Is_Empty then return No_Element; else return (Is_Empty => False, Backend => Object.Backend, Index => Object.Backend.Query.Data.Size); end if; end Last; overriding function First (Object : Range_Iterator) return Cursor is begin return Object.First_Position; end First; overriding function Last (Object : Range_Iterator) return Cursor is begin return Object.Last_Position; end Last; overriding function Next (Object : Range_Iterator; Position : Cursor) return Cursor is begin if Has_Element (Position) and then Position < Object.Last_Position then return Next (Position); else return No_Element; end if; end Next; overriding function Previous (Object : Range_Iterator; Position : Cursor) return Cursor is begin if Has_Element (Position) and then Position > Object.First_Position then return Previous (Position); else return No_Element; end if; end Previous; end Natools.Constant_Indefinite_Ordered_Maps;
mfkiwl/ewok-kernel-security-OS
Ada
3,847
ads
-- -- Copyright 2018 The wookey project team <[email protected]> -- - Ryad Benadjila -- - Arnauld Michelizza -- - Mathieu Renard -- - Philippe Thierry -- - Philippe Trebuchet -- -- Licensed under the Apache License, Version 2.0 (the "License"); -- you may not use this file except in compliance with the License. -- You may obtain a copy of the License at -- -- http://www.apache.org/licenses/LICENSE-2.0 -- -- Unless required by applicable law or agreed to in writing, software -- distributed under the License is distributed on an "AS IS" BASIS, -- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -- See the License for the specific language governing permissions and -- limitations under the License. -- -- with m4.mpu; with m4.scb; with ewok.interrupts; package ewok.mpu with spark_mode => on is type t_region_type is (REGION_TYPE_KERN_CODE, REGION_TYPE_KERN_DATA, REGION_TYPE_KERN_DEVICES, REGION_TYPE_USER_CODE, REGION_TYPE_USER_DATA, REGION_TYPE_USER_DEV, REGION_TYPE_USER_DEV_RO, REGION_TYPE_ISR_STACK) with size => 32; KERN_CODE_REGION : constant m4.mpu.t_region_number := 0; KERN_DEVICES_REGION : constant m4.mpu.t_region_number := 1; KERN_DATA_REGION : constant m4.mpu.t_region_number := 2; USER_CODE_REGION : constant m4.mpu.t_region_number := 3; -- USER_TXT USER_DATA_REGION : constant m4.mpu.t_region_number := 4; -- USER_RAM USER_DATA_SHARED_REGION : constant m4.mpu.t_region_number := 5; USER_FREE_1_REGION : constant m4.mpu.t_region_number := 6; USER_FREE_2_REGION : constant m4.mpu.t_region_number := 7; --------------- -- Functions -- --------------- pragma assertion_policy (pre => IGNORE, post => IGNORE, assert => IGNORE); -- Initialize the MPU procedure init (success : out boolean) with global => (in_out => (m4.mpu.MPU, m4.scb.SCB, ewok.interrupts.interrupt_table)); -- Allows the kernel to access the whole memory procedure enable_unrestricted_kernel_access with global => (in_out => (m4.mpu.MPU)); procedure disable_unrestricted_kernel_access with global => (in_out => (m4.mpu.MPU)); -- Used by SPARK function get_region_size_mask (size : m4.mpu.t_region_size) return unsigned_32 is (2**(natural (size) + 1) - 1) with ghost; pragma warnings (off, "condition can only be False if invalid values present"); procedure set_region (region_number : in m4.mpu.t_region_number; addr : in system_address; size : in m4.mpu.t_region_size; region_type : in t_region_type; subregion_mask : in m4.mpu.t_subregion_mask) with global => (in_out => (m4.mpu.MPU)), pre => (region_number < 8 and (addr and 2#11111#) = 0 and size >= 4 and (addr and get_region_size_mask(size)) = 0); pragma warnings (on); procedure update_subregions (region_number : in m4.mpu.t_region_number; subregion_mask : in m4.mpu.t_subregion_mask) with global => (in_out => (m4.mpu.MPU)); procedure bytes_to_region_size (bytes : in unsigned_32; region_size : out m4.mpu.t_region_size) with global => null, -- Bytes (region size) is a power of 2 -- 4GB region size is not considered by this function pre => ((bytes and (bytes - 1)) = 0 and bytes >= 32 and bytes <= 2*GBYTE), post => region_size < 31 and (2**(natural (region_size) + 1) = bytes); end ewok.mpu;
reznikmm/matreshka
Ada
4,624
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.Leader_Char_Attributes is ------------ -- Create -- ------------ overriding function Create (Parameters : not null access Matreshka.DOM_Attributes.Attribute_L2_Parameters) return Style_Leader_Char_Attribute_Node is begin return Self : Style_Leader_Char_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_Leader_Char_Attribute_Node) return League.Strings.Universal_String is pragma Unreferenced (Self); begin return Matreshka.ODF_String_Constants.Leader_Char_Attribute; end Get_Local_Name; begin Matreshka.DOM_Documents.Register_Attribute (Matreshka.ODF_String_Constants.Style_URI, Matreshka.ODF_String_Constants.Leader_Char_Attribute, Style_Leader_Char_Attribute_Node'Tag); end Matreshka.ODF_Style.Leader_Char_Attributes;
reznikmm/matreshka
Ada
4,025
ads
------------------------------------------------------------------------------ -- -- -- 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$ ------------------------------------------------------------------------------ package UI.Commands.Undoable is pragma Preelaborate; type Abstract_Undoable_Command is abstract new Abstract_Command with private; type Undoable_Command_Access is access all Abstract_Undoable_Command'Class; not overriding procedure Undo (Self : in out Abstract_Undoable_Command) is abstract; -- Undo command. not overriding procedure Redo (Self : in out Abstract_Undoable_Command) is abstract; -- Redo command. This subprogram do same as Execute subprogram usually, but -- called by Undo_Stack on redo request. private type Abstract_Undoable_Command is abstract new Abstract_Command with null record; end UI.Commands.Undoable;
skill-lang/adaCommon
Ada
16,949
adb
-- ___ _ ___ _ _ -- -- / __| |/ (_) | | Common SKilL implementation -- -- \__ \ ' <| | | |__ type handling in skill -- -- |___/_|\_\_|_|____| by: Timm Felden -- -- -- pragma Ada_2012; with Ada.Containers.Vectors; with Ada.Unchecked_Conversion; with Skill.Field_Types; with Skill.Internal.Parts; with Ada.Unchecked_Deallocation; with Skill.Field_Declarations; with Skill.Streams.Reader; with Skill.Iterators.Dynamic_New_Instances; with Skill.Iterators.Static_Data; with Skill.Iterators.Type_Hierarchy_Iterator; with Skill.Iterators.Type_Order; -- pool realizations are moved to the pools.adb, because this way we can work -- around several restrictions of the (generic) ada type system. package body Skill.Types.Pools is function Dynamic (This : access Pool_T) return Pool_Dyn is type P is access all Pool_T; function Convert is new Ada.Unchecked_Conversion (P, Pool_Dyn); begin return Convert (P (This)); end Dynamic; function To_Pool (This : access Pool_T'Class) return Pool is type T is access all Pool_T; function Convert is new Ada.Unchecked_Conversion (T, Pool); begin return Convert (T (This)); end To_Pool; -- pool properties function To_String (This : Pool_T) return String is (This.Name.all); function Skill_Name (This : access Pool_T) return String_Access is (This.Name); function ID (This : access Pool_T) return Natural is (This.Type_Id); function Base (This : access Pool_T'Class) return Base_Pool is (This.Base); function Super (This : access Pool_T) return Pool is (This.Super); function Next (This : access Pool_T'Class) return Pool is (This.Next); procedure Establish_Next (This : access Base_Pool_T'Class) is procedure Set_Next_Pool (This : access Pool_T'Class; Nx : Pool) is begin if This.Sub_Pools.Is_Empty then This.Next := Nx; else This.Next := This.Sub_Pools.First_Element.To_Pool; for I in 0 .. This.Sub_Pools.Length - 2 loop Set_Next_Pool (This.Sub_Pools.Element (I).To_Pool, This.Sub_Pools.Element (I + 1).To_Pool); end loop; Set_Next_Pool (This.Sub_Pools.Last_Element, Nx); end if; end Set_Next_Pool; begin Set_Next_Pool (This, null); end Establish_Next; function Type_Hierarchy_Height (This : access Pool_T'Class) return Natural is (This.Super_Type_Count); function Size (This : access Pool_T'Class) return Natural is begin if This.Fixed then return This.Cached_Size; end if; declare Size : Natural := 0; Iter : aliased Skill.Iterators.Type_Hierarchy_Iterator.Iterator; begin Iter.Init (This.To_Pool); while Iter.Has_Next loop Size := Size + Iter.Next.Static_Size; end loop; return Size; end; end Size; function Static_Size (This : access Pool_T'Class) return Natural is begin return This.Static_Data_Instances + Natural (This.New_Objects.Length); end Static_Size; function Static_Size_With_Deleted (This : access Pool_T'Class) return Natural is begin return This.Static_Data_Instances + Natural (This.New_Objects.Length) - This.Deleted_Count; end Static_Size_With_Deleted; function New_Objects_Size (This : access Pool_T'Class) return Natural is (This.New_Objects.Length); function New_Objects_Element (This : access Pool_T'Class; Idx : Natural) return Annotation is (This.New_Objects.Element (Idx)); procedure Fixed (This : access Pool_T'Class; Fix : Boolean) is procedure Set (P : Sub_Pool) is begin Fixed (P, True); This.Cached_Size := This.Cached_Size + P.Cached_Size; end Set; begin if This.Fixed = Fix then return; end if; This.Fixed := Fix; if Fix then This.Cached_Size := This.Static_Size_With_Deleted; This.Sub_Pools.Foreach (Set'Access); elsif This.Super /= null then Fixed (This.Super, False); end if; end Fixed; procedure Do_In_Type_Order (This : access Pool_T'Class; F : not null access procedure (I : Annotation)) is Iter : aliased Skill.Iterators.Type_Order.Iterator; begin Iter.Init (This.To_Pool); while Iter.Has_Next loop F (Iter.Next); end loop; end Do_In_Type_Order; procedure Do_For_Static_Instances (This : access Pool_T'Class; F : not null access procedure (I : Annotation)) is Iter : aliased Skill.Iterators.Static_Data.Iterator := Skill.Iterators.Static_Data.Make (This.To_Pool); begin while Iter.Has_Next loop F (Iter.Next); end loop; end Do_For_Static_Instances; function First_Dynamic_New_Instance (This : access Pool_T'Class) return Annotation is P : Pool := This.To_Pool; begin while P /= null loop if P.New_Objects.Length > 0 then return P.New_Objects.First_Element; end if; P := P.Next; end loop; return null; end First_Dynamic_New_Instance; function Blocks (This : access Pool_T) return Skill.Internal.Parts.Blocks is (This.Blocks); function Data_Fields (This : access Pool_T) return Skill.Field_Declarations.Field_Vector is (This.Data_Fields_F); -- internal use only function Add_Field (This : access Pool_T; ID : Natural; T : Field_Types.Field_Type; Name : String_Access; Restrictions : Field_Restrictions.Vector) return Skill.Field_Declarations.Field_Declaration is function Convert is new Ada.Unchecked_Conversion (Field_Declarations.Lazy_Field, Field_Declarations.Field_Declaration); type P is access all Pool_T; function Convert is new Ada.Unchecked_Conversion (P, Field_Declarations.Owner_T); F : Field_Declarations.Field_Declaration := Convert (Skill.Field_Declarations.Make_Lazy_Field (Convert (P (This)), ID, T, Name, Restrictions)); begin F.Restrictions := Restrictions; This.Data_Fields.Append (F); return F; end Add_Field; function Add_Field (This : access Base_Pool_T; ID : Natural; T : Field_Types.Field_Type; Name : String_Access; Restrictions : Field_Restrictions.Vector) return Skill.Field_Declarations.Field_Declaration is type P is access all Pool_T; function Convert is new Ada.Unchecked_Conversion (P, Pool); begin return Convert (P (This)).Add_Field (ID, T, Name, Restrictions); end Add_Field; function Add_Field (This : access Sub_Pool_T; ID : Natural; T : Field_Types.Field_Type; Name : String_Access; Restrictions : Field_Restrictions.Vector) return Skill.Field_Declarations.Field_Declaration is type P is access all Pool_T; function Convert is new Ada.Unchecked_Conversion (P, Pool); begin return Convert (P (This)).Add_Field (ID, T, Name, Restrictions); end Add_Field; function Pool_Offset (This : access Pool_T'Class) return Integer is begin return This.Type_Id - 32; end Pool_Offset; function Sub_Pools (This : access Pool_T'Class) return Sub_Pool_Vector is (This.Sub_Pools); function Known_Fields (This : access Pool_T'Class) return String_Access_Array_Access is (This.Known_Fields); -- base pool properties -- internal use only function Data (This : access Base_Pool_T) return Skill.Types.Annotation_Array is (This.Data); procedure Compress (This : access Base_Pool_T'Class; Lbpo_Map : Skill.Internal.Lbpo_Map_T) is D : Annotation_Array := new Annotation_Array_T (1 .. This.Size); P : Skill_ID_T := 1; procedure Update (I : Annotation) is begin if 0 /= I.Skill_ID then D (P) := I; I.Skill_ID := P; P := P + 1; end if; end Update; begin This.Do_In_Type_Order (Update'Access); This.Data := D; This.Update_After_Compress (Lbpo_Map); end Compress; procedure Update_After_Compress (This : access Pool_T'Class; Lbpo_Map : Skill.Internal.Lbpo_Map_T) is procedure Reset (D : Field_Declarations.Field_Declaration) is use type Interfaces.Integer_64; begin D.Data_Chunks.Clear; D.Add_Chunk (new Internal.Parts.Bulk_Chunk'(-1, -1, This.Cached_Size, 1)); end Reset; begin This.Static_Data_Instances := This.Static_Data_Instances + This.New_Objects.Length - This.Deleted_Count; This.New_Objects.Clear; This.Deleted_Count := 0; This.Blocks.Clear; This.Blocks.Append (Skill.Internal.Parts.Block' (Lbpo_Map (This.Pool_Offset), This.Static_Data_Instances, This.Size)); -- reset Data chunks This.Data_Fields_F.Foreach (Reset'Access); for I in 0 .. This.Sub_Pools.Length - 1 loop This.Sub_Pools.Element (I).Dynamic.Update_After_Compress (Lbpo_Map); end loop; end Update_After_Compress; -- invoked by resize pool (from base pool implementation) procedure Resize_Data (This : access Base_Pool_T'Class) is Count : Types.Skill_ID_T := This.Blocks.Last_Element.Dynamic_Count; D : Annotation_Array := new Annotation_Array_T (This.Data'First .. (This.Data'Last + Count)); procedure Free is new Ada.Unchecked_Deallocation (Object => Annotation_Array_T, Name => Annotation_Array); begin D (This.Data'First .. This.Data'Last) := This.Data.all; if This.Data /= Empty_Data then Free (This.Data); end if; This.Data := D; end Resize_Data; -- Called after a prepare append operation to write empty the new objects -- buffer and to set blocks correctly procedure Update_After_Prepare_Append (This : access Pool_T'Class; Chunk_Map : Skill.Field_Declarations.Chunk_Map) is New_Instances : constant Boolean := null /= This.Dynamic.First_Dynamic_New_Instance; New_Pool : constant Boolean := This.Blocks.Is_Empty; New_Field : Boolean := False; procedure Find_New_Field (F : Field_Declarations.Field_Declaration) is begin if not New_Field and then F.Data_Chunks.Is_Empty then New_Field := True; end if; end Find_New_Field; begin This.Data_Fields_F.Foreach (Find_New_Field'Access); if New_Pool or else New_Instances or else New_Field then declare -- build block chunk Lcount : Natural := This.New_Objects_Size; procedure Dynamic_Lcount (P : Sub_Pool) is begin Lcount := Lcount + P.To_Pool.Dynamic.New_Objects_Size; P.Sub_Pools.Foreach (Dynamic_Lcount'Access); end Dynamic_Lcount; Lbpo : Natural; begin This.Sub_Pools.Foreach (Dynamic_Lcount'Access); if 0 = Lcount then Lbpo := 0; else Lbpo := This.Dynamic.First_Dynamic_New_Instance.Skill_ID - 1; end if; This.Blocks.Append (Skill.Internal.Parts.Block' (BPO => Lbpo, Static_Count => Lcount, Dynamic_Count => Lcount)); -- @note: if this does not hold for p; then it will not hold for -- p.subPools either! if New_Instances or else not New_Pool then -- build field chunks for I in 1 .. This.Data_Fields_F.Length loop declare F : Field_Declarations.Field_Declaration := This.Data_Fields_F.Element (I); CE : Skill.Field_Declarations.Chunk_Entry; begin if F.Data_Chunks.Is_Empty then CE := new Skill.Field_Declarations.Chunk_Entry_T' (C => new Skill.Internal.Parts.Bulk_Chunk' (First => Types.v64 (-1), Last => Types.v64 (-1), Count => This.Size, Block_Count => This.Blocks.Length), Input => Skill.Streams.Reader.Empty_Sub_Stream); F.Data_Chunks.Append (CE); Chunk_Map.Include (F, CE.C); elsif New_Instances then CE := new Skill.Field_Declarations.Chunk_Entry_T' (C => new Skill.Internal.Parts.Simple_Chunk' (First => Types.v64 (-1), Last => Types.v64 (-1), Count => Lcount, BPO => Lbpo), Input => Skill.Streams.Reader.Empty_Sub_Stream); F.Data_Chunks.Append (CE); Chunk_Map.Include (F, CE.C); end if; end; end loop; end if; end; end if; -- notify sub pools declare procedure Update (P : Sub_Pool) is begin Update_After_Prepare_Append (P, Chunk_Map); end Update; begin This.Sub_Pools.Foreach (Update'Access); end; -- remove new objects, because they are regular objects by now -- TODO if we ever want to get rid of Destroyed mode -- staticData.addAll(newObjects); -- newObjects.clear(); -- newObjects.trimToSize(); end Update_After_Prepare_Append; procedure Prepare_Append (This : access Base_Pool_T'Class; Chunk_Map : Skill.Field_Declarations.Chunk_Map) is New_Instances : constant Boolean := null /= This.Dynamic.First_Dynamic_New_Instance; begin -- check if we have to append at all if not New_Instances and then not This.Blocks.Is_Empty and then not This.Data_Fields.Is_Empty then declare Done : Boolean := True; procedure Check (F : Field_Declarations.Field_Declaration) is begin if F.Data_Chunks.Is_Empty then Done := False; end if; end Check; begin This.Data_Fields_F.Foreach (Check'Access); if Done then return; end if; end; end if; if New_Instances then -- we have to resize declare Count : Natural := This.Size; D : Annotation_Array := new Annotation_Array_T (This.Data'First .. Count); procedure Free is new Ada.Unchecked_Deallocation (Object => Annotation_Array_T, Name => Annotation_Array); I : Natural := This.Data'Last + 1; Iter : aliased Skill.Iterators.Dynamic_New_Instances.Iterator; Inst : Annotation; begin Iter.Init (This.To_Pool); D (This.Data'First .. This.Data'Last) := This.Data.all; while Iter.Has_Next loop Inst := Iter.Next; D (I) := Inst; Inst.Skill_ID := I; I := I + 1; end loop; if This.Data /= Empty_Data then Free (This.Data); end if; This.Data := D; end; end if; Update_After_Prepare_Append (This, Chunk_Map); end Prepare_Append; procedure Set_Owner (This : access Base_Pool_T'Class; Owner : access Skill.Files.File_T'Class) is type P is access all Skill.Files.File_T'Class; function Convert is new Ada.Unchecked_Conversion (P, Owner_T); begin This.Owner := Convert (P (Owner)); end Set_Owner; procedure Delete (This : access Pool_T'Class; Target : access Skill_Object'Class) is begin Target.Skill_ID := 0; This.Deleted_Count := This.Deleted_Count + 1; end Delete; end Skill.Types.Pools;
reznikmm/matreshka
Ada
6,858
adb
------------------------------------------------------------------------------ -- -- -- Matreshka Project -- -- -- -- Open Document Toolkit -- -- -- -- Runtime Library Component -- -- -- ------------------------------------------------------------------------------ -- -- -- Copyright © 2014, Vadim Godunko <[email protected]> -- -- All rights reserved. -- -- -- -- Redistribution and use in source and binary forms, with or without -- -- modification, are permitted provided that the following conditions -- -- are met: -- -- -- -- * Redistributions of source code must retain the above copyright -- -- notice, this list of conditions and the following disclaimer. -- -- -- -- * Redistributions in binary form must reproduce the above copyright -- -- notice, this list of conditions and the following disclaimer in the -- -- documentation and/or other materials provided with the distribution. -- -- -- -- * Neither the name of the Vadim Godunko, IE nor the names of its -- -- contributors may be used to endorse or promote products derived from -- -- this software without specific prior written permission. -- -- -- -- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -- -- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -- -- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -- -- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -- -- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -- -- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED -- -- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -- -- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -- -- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -- -- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -- -- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- -- -- ------------------------------------------------------------------------------ -- $Revision$ $Date$ ------------------------------------------------------------------------------ with Matreshka.DOM_Documents; with Matreshka.ODF_String_Constants; with ODF.DOM.Iterators; with ODF.DOM.Visitors; package body Matreshka.ODF_Db.Index_Column_Elements is ------------ -- Create -- ------------ overriding function Create (Parameters : not null access Matreshka.DOM_Elements.Element_L2_Parameters) return Db_Index_Column_Element_Node is begin return Self : Db_Index_Column_Element_Node do Matreshka.ODF_Db.Constructors.Initialize (Self'Unchecked_Access, Parameters.Document, Matreshka.ODF_String_Constants.Db_Prefix); end return; end Create; ---------------- -- Enter_Node -- ---------------- overriding procedure Enter_Node (Self : not null access Db_Index_Column_Element_Node; Visitor : in out XML.DOM.Visitors.Abstract_Visitor'Class; Control : in out XML.DOM.Visitors.Traverse_Control) is begin if Visitor in ODF.DOM.Visitors.Abstract_ODF_Visitor'Class then ODF.DOM.Visitors.Abstract_ODF_Visitor'Class (Visitor).Enter_Db_Index_Column (ODF.DOM.Db_Index_Column_Elements.ODF_Db_Index_Column_Access (Self), Control); else Matreshka.DOM_Elements.Abstract_Element_Node (Self.all).Enter_Node (Visitor, Control); end if; end Enter_Node; -------------------- -- Get_Local_Name -- -------------------- overriding function Get_Local_Name (Self : not null access constant Db_Index_Column_Element_Node) return League.Strings.Universal_String is pragma Unreferenced (Self); begin return Matreshka.ODF_String_Constants.Index_Column_Element; end Get_Local_Name; ---------------- -- Leave_Node -- ---------------- overriding procedure Leave_Node (Self : not null access Db_Index_Column_Element_Node; Visitor : in out XML.DOM.Visitors.Abstract_Visitor'Class; Control : in out XML.DOM.Visitors.Traverse_Control) is begin if Visitor in ODF.DOM.Visitors.Abstract_ODF_Visitor'Class then ODF.DOM.Visitors.Abstract_ODF_Visitor'Class (Visitor).Leave_Db_Index_Column (ODF.DOM.Db_Index_Column_Elements.ODF_Db_Index_Column_Access (Self), Control); else Matreshka.DOM_Elements.Abstract_Element_Node (Self.all).Leave_Node (Visitor, Control); end if; end Leave_Node; ---------------- -- Visit_Node -- ---------------- overriding procedure Visit_Node (Self : not null access Db_Index_Column_Element_Node; Iterator : in out XML.DOM.Visitors.Abstract_Iterator'Class; Visitor : in out XML.DOM.Visitors.Abstract_Visitor'Class; Control : in out XML.DOM.Visitors.Traverse_Control) is begin if Iterator in ODF.DOM.Iterators.Abstract_ODF_Iterator'Class then ODF.DOM.Iterators.Abstract_ODF_Iterator'Class (Iterator).Visit_Db_Index_Column (Visitor, ODF.DOM.Db_Index_Column_Elements.ODF_Db_Index_Column_Access (Self), Control); else Matreshka.DOM_Elements.Abstract_Element_Node (Self.all).Visit_Node (Iterator, Visitor, Control); end if; end Visit_Node; begin Matreshka.DOM_Documents.Register_Element (Matreshka.ODF_String_Constants.Db_URI, Matreshka.ODF_String_Constants.Index_Column_Element, Db_Index_Column_Element_Node'Tag); end Matreshka.ODF_Db.Index_Column_Elements;
reznikmm/matreshka
Ada
4,970
ads
------------------------------------------------------------------------------ -- -- -- Matreshka Project -- -- -- -- Open Document Toolkit -- -- -- -- Runtime Library Component -- -- -- ------------------------------------------------------------------------------ -- -- -- Copyright © 2014, Vadim Godunko <[email protected]> -- -- All rights reserved. -- -- -- -- Redistribution and use in source and binary forms, with or without -- -- modification, are permitted provided that the following conditions -- -- are met: -- -- -- -- * Redistributions of source code must retain the above copyright -- -- notice, this list of conditions and the following disclaimer. -- -- -- -- * Redistributions in binary form must reproduce the above copyright -- -- notice, this list of conditions and the following disclaimer in the -- -- documentation and/or other materials provided with the distribution. -- -- -- -- * Neither the name of the Vadim Godunko, IE nor the names of its -- -- contributors may be used to endorse or promote products derived from -- -- this software without specific prior written permission. -- -- -- -- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -- -- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -- -- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -- -- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -- -- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -- -- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED -- -- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -- -- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -- -- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -- -- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -- -- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- -- -- ------------------------------------------------------------------------------ -- $Revision$ $Date$ ------------------------------------------------------------------------------ with XML.DOM.Visitors; with ODF.DOM.Text_Illustration_Index_Entry_Template_Elements; package Matreshka.ODF_Text.Illustration_Index_Entry_Template_Elements is type Text_Illustration_Index_Entry_Template_Element_Node is new Matreshka.ODF_Text.Abstract_Text_Element_Node and ODF.DOM.Text_Illustration_Index_Entry_Template_Elements.ODF_Text_Illustration_Index_Entry_Template with null record; overriding function Create (Parameters : not null access Matreshka.DOM_Elements.Element_L2_Parameters) return Text_Illustration_Index_Entry_Template_Element_Node; overriding function Get_Local_Name (Self : not null access constant Text_Illustration_Index_Entry_Template_Element_Node) return League.Strings.Universal_String; overriding procedure Enter_Node (Self : not null access Text_Illustration_Index_Entry_Template_Element_Node; Visitor : in out XML.DOM.Visitors.Abstract_Visitor'Class; Control : in out XML.DOM.Visitors.Traverse_Control); overriding procedure Leave_Node (Self : not null access Text_Illustration_Index_Entry_Template_Element_Node; Visitor : in out XML.DOM.Visitors.Abstract_Visitor'Class; Control : in out XML.DOM.Visitors.Traverse_Control); overriding procedure Visit_Node (Self : not null access Text_Illustration_Index_Entry_Template_Element_Node; Iterator : in out XML.DOM.Visitors.Abstract_Iterator'Class; Visitor : in out XML.DOM.Visitors.Abstract_Visitor'Class; Control : in out XML.DOM.Visitors.Traverse_Control); end Matreshka.ODF_Text.Illustration_Index_Entry_Template_Elements;
sf17k/sdlada
Ada
3,149
adb
-------------------------------------------------------------------------------------------------------------------- -- Copyright (c) 2014-2015 Luke A. Guest -- -- This software is provided 'as-is', without any express or implied -- warranty. In no event will the authors be held liable for any damages -- arising from the use of this software. -- -- Permission is granted to anyone to use this software for any purpose, -- including commercial applications, and to alter it and redistribute it -- freely, subject to the following restrictions: -- -- 1. The origin of this software must not be misrepresented; you must not -- claim that you wrote the original software. If you use this software -- in a product, an acknowledgment in the product documentation would be -- appreciated but is not required. -- -- 2. Altered source versions must be plainly marked as such, and must not be -- misrepresented as being the original software. -- -- 3. This notice may not be removed or altered from any source -- distribution. -------------------------------------------------------------------------------------------------------------------- with Interfaces.C; with Interfaces.C.Strings; package body SDL.Video.Pixel_Formats is use type C.int; function Image (Format : in Pixel_Format_Names) return String is function SDL_Get_Pixel_Format_Name (Format : in Pixel_Format_Names) return C.Strings.chars_ptr with Import => True, Convention => C, External_Name => "SDL_GetPixelFormatName"; C_Str : C.Strings.chars_ptr := SDL_Get_Pixel_Format_Name (Format); begin return C.Strings.Value (C_Str); end Image; function To_Masks (Format : in Pixel_Format_Names; Bits : out Bits_Per_Pixels; Red_Mask : out Colour_Mask; Green_Mask : out Colour_Mask; Blue_Mask : out Colour_Mask; Alpha_Mask : out Colour_Mask) return Boolean is function SDL_Pixel_Format_Enum_To_Masks (Format : in Pixel_Format_Names; Bits : out Bits_Per_Pixels; Red_Mask : out Colour_Mask; Green_Mask : out Colour_Mask; Blue_Mask : out Colour_Mask; Alpha_Mask : out Colour_Mask) return C.int with Import => True, Convention => C, External_Name => "SDL_PixelFormatEnumToMasks"; Error : C.int := SDL_Pixel_Format_Enum_To_Masks (Format, Bits, Red_Mask, Green_Mask, Blue_Mask, Alpha_Mask); begin return Error = 1; -- TODO: This causes http://gcc.gnu.org/bugzilla/show_bug.cgi?id=58573 -- -- return (if SDL_Pixel_Format_Enum_To_Masks -- (Format, -- Bits, -- Red_Mask, -- Green_Mask, -- Blue_Mask, -- Alpha_Mask) = 1 then True else False); -- or: -- return (SDL_Pixel_Format_Enum_To_Masks -- (Format, -- Bits, -- Red_Mask, -- Green_Mask, -- Blue_Mask, -- Alpha_Mask) = 1); end To_Masks; end SDL.Video.Pixel_Formats;
reznikmm/matreshka
Ada
18,439
ads
------------------------------------------------------------------------------ -- -- -- Matreshka Project -- -- -- -- Ada Modeling Framework -- -- -- -- Runtime Library Component -- -- -- ------------------------------------------------------------------------------ -- -- -- Copyright © 2011-2012, Vadim Godunko <[email protected]> -- -- All rights reserved. -- -- -- -- Redistribution and use in source and binary forms, with or without -- -- modification, are permitted provided that the following conditions -- -- are met: -- -- -- -- * Redistributions of source code must retain the above copyright -- -- notice, this list of conditions and the following disclaimer. -- -- -- -- * Redistributions in binary form must reproduce the above copyright -- -- notice, this list of conditions and the following disclaimer in the -- -- documentation and/or other materials provided with the distribution. -- -- -- -- * Neither the name of the Vadim Godunko, IE nor the names of its -- -- contributors may be used to endorse or promote products derived from -- -- this software without specific prior written permission. -- -- -- -- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -- -- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -- -- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -- -- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -- -- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -- -- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED -- -- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -- -- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -- -- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -- -- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -- -- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- -- -- ------------------------------------------------------------------------------ -- $Revision$ $Date$ ------------------------------------------------------------------------------ with AMF.Internals.UML_Named_Elements; with AMF.UML.Activities; with AMF.UML.Activity_Edges.Collections; with AMF.UML.Activity_Groups.Collections; with AMF.UML.Activity_Nodes.Collections; with AMF.UML.Activity_Partitions.Collections; with AMF.UML.Classifiers.Collections; with AMF.UML.Constraints.Collections; with AMF.UML.Dependencies.Collections; with AMF.UML.Exception_Handlers.Collections; with AMF.UML.Input_Pins.Collections; with AMF.UML.Interruptible_Activity_Regions.Collections; with AMF.UML.Named_Elements; with AMF.UML.Namespaces; with AMF.UML.Output_Pins.Collections; with AMF.UML.Packages.Collections; with AMF.UML.Raise_Exception_Actions; with AMF.UML.Redefinable_Elements.Collections; with AMF.UML.String_Expressions; with AMF.UML.Structured_Activity_Nodes; with AMF.Visitors; package AMF.Internals.UML_Raise_Exception_Actions is type UML_Raise_Exception_Action_Proxy is limited new AMF.Internals.UML_Named_Elements.UML_Named_Element_Proxy and AMF.UML.Raise_Exception_Actions.UML_Raise_Exception_Action with null record; overriding function Get_Exception (Self : not null access constant UML_Raise_Exception_Action_Proxy) return AMF.UML.Input_Pins.UML_Input_Pin_Access; -- Getter of RaiseExceptionAction::exception. -- -- An input pin whose value becomes an exception object. overriding procedure Set_Exception (Self : not null access UML_Raise_Exception_Action_Proxy; To : AMF.UML.Input_Pins.UML_Input_Pin_Access); -- Setter of RaiseExceptionAction::exception. -- -- An input pin whose value becomes an exception object. overriding function Get_Context (Self : not null access constant UML_Raise_Exception_Action_Proxy) return AMF.UML.Classifiers.UML_Classifier_Access; -- Getter of Action::context. -- -- The classifier that owns the behavior of which this action is a part. overriding function Get_Input (Self : not null access constant UML_Raise_Exception_Action_Proxy) return AMF.UML.Input_Pins.Collections.Ordered_Set_Of_UML_Input_Pin; -- Getter of Action::input. -- -- The ordered set of input pins connected to the Action. These are among -- the total set of inputs. overriding function Get_Is_Locally_Reentrant (Self : not null access constant UML_Raise_Exception_Action_Proxy) return Boolean; -- Getter of Action::isLocallyReentrant. -- -- If true, the action can begin a new, concurrent execution, even if -- there is already another execution of the action ongoing. If false, the -- action cannot begin a new execution until any previous execution has -- completed. overriding procedure Set_Is_Locally_Reentrant (Self : not null access UML_Raise_Exception_Action_Proxy; To : Boolean); -- Setter of Action::isLocallyReentrant. -- -- If true, the action can begin a new, concurrent execution, even if -- there is already another execution of the action ongoing. If false, the -- action cannot begin a new execution until any previous execution has -- completed. overriding function Get_Local_Postcondition (Self : not null access constant UML_Raise_Exception_Action_Proxy) return AMF.UML.Constraints.Collections.Set_Of_UML_Constraint; -- Getter of Action::localPostcondition. -- -- Constraint that must be satisfied when executed is completed. overriding function Get_Local_Precondition (Self : not null access constant UML_Raise_Exception_Action_Proxy) return AMF.UML.Constraints.Collections.Set_Of_UML_Constraint; -- Getter of Action::localPrecondition. -- -- Constraint that must be satisfied when execution is started. overriding function Get_Output (Self : not null access constant UML_Raise_Exception_Action_Proxy) return AMF.UML.Output_Pins.Collections.Ordered_Set_Of_UML_Output_Pin; -- Getter of Action::output. -- -- The ordered set of output pins connected to the Action. The action -- places its results onto pins in this set. overriding function Get_Handler (Self : not null access constant UML_Raise_Exception_Action_Proxy) return AMF.UML.Exception_Handlers.Collections.Set_Of_UML_Exception_Handler; -- Getter of ExecutableNode::handler. -- -- A set of exception handlers that are examined if an uncaught exception -- propagates to the outer level of the executable node. overriding function Get_Activity (Self : not null access constant UML_Raise_Exception_Action_Proxy) return AMF.UML.Activities.UML_Activity_Access; -- Getter of ActivityNode::activity. -- -- Activity containing the node. overriding procedure Set_Activity (Self : not null access UML_Raise_Exception_Action_Proxy; To : AMF.UML.Activities.UML_Activity_Access); -- Setter of ActivityNode::activity. -- -- Activity containing the node. overriding function Get_In_Group (Self : not null access constant UML_Raise_Exception_Action_Proxy) return AMF.UML.Activity_Groups.Collections.Set_Of_UML_Activity_Group; -- Getter of ActivityNode::inGroup. -- -- Groups containing the node. overriding function Get_In_Interruptible_Region (Self : not null access constant UML_Raise_Exception_Action_Proxy) return AMF.UML.Interruptible_Activity_Regions.Collections.Set_Of_UML_Interruptible_Activity_Region; -- Getter of ActivityNode::inInterruptibleRegion. -- -- Interruptible regions containing the node. overriding function Get_In_Partition (Self : not null access constant UML_Raise_Exception_Action_Proxy) return AMF.UML.Activity_Partitions.Collections.Set_Of_UML_Activity_Partition; -- Getter of ActivityNode::inPartition. -- -- Partitions containing the node. overriding function Get_In_Structured_Node (Self : not null access constant UML_Raise_Exception_Action_Proxy) return AMF.UML.Structured_Activity_Nodes.UML_Structured_Activity_Node_Access; -- Getter of ActivityNode::inStructuredNode. -- -- Structured activity node containing the node. overriding procedure Set_In_Structured_Node (Self : not null access UML_Raise_Exception_Action_Proxy; To : AMF.UML.Structured_Activity_Nodes.UML_Structured_Activity_Node_Access); -- Setter of ActivityNode::inStructuredNode. -- -- Structured activity node containing the node. overriding function Get_Incoming (Self : not null access constant UML_Raise_Exception_Action_Proxy) return AMF.UML.Activity_Edges.Collections.Set_Of_UML_Activity_Edge; -- Getter of ActivityNode::incoming. -- -- Edges that have the node as target. overriding function Get_Outgoing (Self : not null access constant UML_Raise_Exception_Action_Proxy) return AMF.UML.Activity_Edges.Collections.Set_Of_UML_Activity_Edge; -- Getter of ActivityNode::outgoing. -- -- Edges that have the node as source. overriding function Get_Redefined_Node (Self : not null access constant UML_Raise_Exception_Action_Proxy) return AMF.UML.Activity_Nodes.Collections.Set_Of_UML_Activity_Node; -- Getter of ActivityNode::redefinedNode. -- -- Inherited nodes replaced by this node in a specialization of the -- activity. overriding function Get_Is_Leaf (Self : not null access constant UML_Raise_Exception_Action_Proxy) return Boolean; -- Getter of RedefinableElement::isLeaf. -- -- Indicates whether it is possible to further redefine a -- RedefinableElement. If the value is true, then it is not possible to -- further redefine the RedefinableElement. Note that this property is -- preserved through package merge operations; that is, the capability to -- redefine a RedefinableElement (i.e., isLeaf=false) must be preserved in -- the resulting RedefinableElement of a package merge operation where a -- RedefinableElement with isLeaf=false is merged with a matching -- RedefinableElement with isLeaf=true: the resulting RedefinableElement -- will have isLeaf=false. Default value is false. overriding procedure Set_Is_Leaf (Self : not null access UML_Raise_Exception_Action_Proxy; To : Boolean); -- Setter of RedefinableElement::isLeaf. -- -- Indicates whether it is possible to further redefine a -- RedefinableElement. If the value is true, then it is not possible to -- further redefine the RedefinableElement. Note that this property is -- preserved through package merge operations; that is, the capability to -- redefine a RedefinableElement (i.e., isLeaf=false) must be preserved in -- the resulting RedefinableElement of a package merge operation where a -- RedefinableElement with isLeaf=false is merged with a matching -- RedefinableElement with isLeaf=true: the resulting RedefinableElement -- will have isLeaf=false. Default value is false. overriding function Get_Redefined_Element (Self : not null access constant UML_Raise_Exception_Action_Proxy) return AMF.UML.Redefinable_Elements.Collections.Set_Of_UML_Redefinable_Element; -- Getter of RedefinableElement::redefinedElement. -- -- The redefinable element that is being redefined by this element. overriding function Get_Redefinition_Context (Self : not null access constant UML_Raise_Exception_Action_Proxy) return AMF.UML.Classifiers.Collections.Set_Of_UML_Classifier; -- Getter of RedefinableElement::redefinitionContext. -- -- References the contexts that this element may be redefined from. overriding function Get_Client_Dependency (Self : not null access constant UML_Raise_Exception_Action_Proxy) return AMF.UML.Dependencies.Collections.Set_Of_UML_Dependency; -- Getter of NamedElement::clientDependency. -- -- Indicates the dependencies that reference the client. overriding function Get_Name_Expression (Self : not null access constant UML_Raise_Exception_Action_Proxy) return AMF.UML.String_Expressions.UML_String_Expression_Access; -- Getter of NamedElement::nameExpression. -- -- The string expression used to define the name of this named element. overriding procedure Set_Name_Expression (Self : not null access UML_Raise_Exception_Action_Proxy; To : AMF.UML.String_Expressions.UML_String_Expression_Access); -- Setter of NamedElement::nameExpression. -- -- The string expression used to define the name of this named element. overriding function Get_Namespace (Self : not null access constant UML_Raise_Exception_Action_Proxy) return AMF.UML.Namespaces.UML_Namespace_Access; -- Getter of NamedElement::namespace. -- -- Specifies the namespace that owns the NamedElement. overriding function Get_Qualified_Name (Self : not null access constant UML_Raise_Exception_Action_Proxy) return AMF.Optional_String; -- Getter of NamedElement::qualifiedName. -- -- A name which allows the NamedElement to be identified within a -- hierarchy of nested Namespaces. It is constructed from the names of the -- containing namespaces starting at the root of the hierarchy and ending -- with the name of the NamedElement itself. overriding function Context (Self : not null access constant UML_Raise_Exception_Action_Proxy) return AMF.UML.Classifiers.UML_Classifier_Access; -- Operation Action::context. -- -- Missing derivation for Action::/context : Classifier overriding function Is_Consistent_With (Self : not null access constant UML_Raise_Exception_Action_Proxy; Redefinee : AMF.UML.Redefinable_Elements.UML_Redefinable_Element_Access) return Boolean; -- Operation RedefinableElement::isConsistentWith. -- -- The query isConsistentWith() specifies, for any two RedefinableElements -- in a context in which redefinition is possible, whether redefinition -- would be logically consistent. By default, this is false; this -- operation must be overridden for subclasses of RedefinableElement to -- define the consistency conditions. overriding function Is_Redefinition_Context_Valid (Self : not null access constant UML_Raise_Exception_Action_Proxy; Redefined : AMF.UML.Redefinable_Elements.UML_Redefinable_Element_Access) return Boolean; -- Operation RedefinableElement::isRedefinitionContextValid. -- -- The query isRedefinitionContextValid() specifies whether the -- redefinition contexts of this RedefinableElement are properly related -- to the redefinition contexts of the specified RedefinableElement to -- allow this element to redefine the other. By default at least one of -- the redefinition contexts of this element must be a specialization of -- at least one of the redefinition contexts of the specified element. overriding function All_Owning_Packages (Self : not null access constant UML_Raise_Exception_Action_Proxy) return AMF.UML.Packages.Collections.Set_Of_UML_Package; -- Operation NamedElement::allOwningPackages. -- -- The query allOwningPackages() returns all the directly or indirectly -- owning packages. overriding function Is_Distinguishable_From (Self : not null access constant UML_Raise_Exception_Action_Proxy; N : AMF.UML.Named_Elements.UML_Named_Element_Access; Ns : AMF.UML.Namespaces.UML_Namespace_Access) return Boolean; -- Operation NamedElement::isDistinguishableFrom. -- -- The query isDistinguishableFrom() determines whether two NamedElements -- may logically co-exist within a Namespace. By default, two named -- elements are distinguishable if (a) they have unrelated types or (b) -- they have related types but different names. overriding function Namespace (Self : not null access constant UML_Raise_Exception_Action_Proxy) return AMF.UML.Namespaces.UML_Namespace_Access; -- Operation NamedElement::namespace. -- -- Missing derivation for NamedElement::/namespace : Namespace overriding procedure Enter_Element (Self : not null access constant UML_Raise_Exception_Action_Proxy; Visitor : in out AMF.Visitors.Abstract_Visitor'Class; Control : in out AMF.Visitors.Traverse_Control); -- Dispatch call to corresponding subprogram of visitor interface. overriding procedure Leave_Element (Self : not null access constant UML_Raise_Exception_Action_Proxy; Visitor : in out AMF.Visitors.Abstract_Visitor'Class; Control : in out AMF.Visitors.Traverse_Control); -- Dispatch call to corresponding subprogram of visitor interface. overriding procedure Visit_Element (Self : not null access constant UML_Raise_Exception_Action_Proxy; Iterator : in out AMF.Visitors.Abstract_Iterator'Class; Visitor : in out AMF.Visitors.Abstract_Visitor'Class; Control : in out AMF.Visitors.Traverse_Control); -- Dispatch call to corresponding subprogram of iterator interface. end AMF.Internals.UML_Raise_Exception_Actions;
dilawar/ahir
Ada
361
adb
-- RUN: %llvmgcc -c %s with System; procedure Negative_Field_Offset (N : Integer) is type String_Pointer is access String; -- Force use of a thin pointer. for String_Pointer'Size use System.Word_Size; P : String_Pointer; procedure Q (P : String_Pointer) is begin P (1) := 'Z'; end; begin P := new String (1 .. N); Q (P); end;
charlie5/cBound
Ada
1,443
ads
-- This file is generated by SWIG. Please do not modify by hand. -- with Interfaces.C; with xcb.xcb_rectangle_t; with Interfaces.C; with Interfaces.C.Pointers; package xcb.xcb_rectangle_iterator_t is -- Item -- type Item is record data : access xcb.xcb_rectangle_t.Item; the_rem : aliased Interfaces.C.int; index : aliased Interfaces.C.int; end record; -- Item_Array -- type Item_Array is array (Interfaces.C.size_t range <>) of aliased xcb.xcb_rectangle_iterator_t .Item; -- Pointer -- package C_Pointers is new Interfaces.C.Pointers (Index => Interfaces.C.size_t, Element => xcb.xcb_rectangle_iterator_t.Item, Element_Array => xcb.xcb_rectangle_iterator_t.Item_Array, Default_Terminator => (others => <>)); subtype Pointer is C_Pointers.Pointer; -- Pointer_Array -- type Pointer_Array is array (Interfaces.C.size_t range <>) of aliased xcb.xcb_rectangle_iterator_t .Pointer; -- Pointer_Pointer -- package C_Pointer_Pointers is new Interfaces.C.Pointers (Index => Interfaces.C.size_t, Element => xcb.xcb_rectangle_iterator_t.Pointer, Element_Array => xcb.xcb_rectangle_iterator_t.Pointer_Array, Default_Terminator => null); subtype Pointer_Pointer is C_Pointer_Pointers.Pointer; end xcb.xcb_rectangle_iterator_t;
AdaDoom3/wayland_ada_binding
Ada
3,311
ads
------------------------------------------------------------------------------ -- Copyright (C) 2016, AdaCore -- -- -- -- This library is free software; you can redistribute it and/or modify it -- -- under terms of the GNU General Public License as published by the Free -- -- Software Foundation; either version 3, or (at your option) any later -- -- version. This library is distributed in the hope that it will be useful, -- -- but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHAN- -- -- TABILITY or FITNESS FOR A PARTICULAR PURPOSE. -- -- -- -- As a special exception under Section 7 of GPL version 3, you are granted -- -- additional permissions described in the GCC Runtime Library Exception, -- -- version 3.1, as published by the Free Software Foundation. -- -- -- -- You should have received a copy of the GNU General Public License and -- -- a copy of the GCC Runtime Library Exception along with this program; -- -- see the files COPYING3 and COPYING.RUNTIME respectively. If not, see -- -- <http://www.gnu.org/licenses/>. -- -- -- ------------------------------------------------------------------------------ pragma Ada_2012; package Conts.Vectors with SPARK_Mode => On is generic with function Grow (Current_Size, Min_Expected_Size : Count_Type) return Count_Type; with function Shrink (Current_Size, Min_Expected_Size : Count_Type) return Count_Type; package Resize_Strategy is end Resize_Strategy; -- This package is used whenever a vector needs to be resized, and -- must return the new size. There are two cases: -- Grow: -- Space for more elements must be added to the vector. A common -- strategy is to double the size, although it is also possible to -- chose to add a fixed number of elements. -- Shrink: -- The vector is too big for what it needs. In general, it should -- not immediately resize and free memory, in case elements are -- added just afterwards. -- -- Current_Size might be 0, so simply multiplying is not enough. function Grow_1_5 (Current_Size, Min_Expected : Count_Type) return Count_Type with Inline; function Shrink_1_5 (Current_Size, Min_Expected : Count_Type) return Count_Type with Inline; package Resize_1_5 is new Resize_Strategy (Grow => Grow_1_5, Shrink => Shrink_1_5); -- A package that multiplies the size by 1.5 every time some more space -- is needed. private function Grow_1_5 (Current_Size, Min_Expected : Count_Type) return Count_Type is (if Current_Size < Min_Expected then Count_Type'Max (Min_Expected, Count_Type'Max (4, Current_Size * 3 / 2)) else Current_Size); function Shrink_1_5 (Current_Size, Min_Expected : Count_Type) return Count_Type is (Min_Expected); end Conts.Vectors;
stcarrez/ada-util
Ada
11,676
adb
----------------------------------------------------------------------- -- util-commands-tests - Test for commands -- Copyright (C) 2018, 2019, 2020, 2022 Stephane Carrez -- Written by Stephane Carrez ([email protected]) -- -- Licensed under the Apache License, Version 2.0 (the "License"); -- you may not use this file except in compliance with the License. -- You may obtain a copy of the License at -- -- http://www.apache.org/licenses/LICENSE-2.0 -- -- Unless required by applicable law or agreed to in writing, software -- distributed under the License is distributed on an "AS IS" BASIS, -- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -- See the License for the specific language governing permissions and -- limitations under the License. ----------------------------------------------------------------------- with GNAT.Command_Line; with Util.Test_Caller; with Util.Log; with Util.Commands.Parsers.GNAT_Parser; with Util.Commands.Drivers; with Util.Commands.Text_IO; package body Util.Commands.Tests is package Caller is new Util.Test_Caller (Test, "Commands"); type Test_Context_Type is record Number : Integer := 0; Success : Boolean := False; end record; procedure Simple (Name : in String; Args : in Argument_List'Class; Ctx : in out Test_Context_Type); package Test_Command is new Util.Commands.Drivers (Context_Type => Test_Context_Type, Config_Parser => Util.Commands.Parsers.GNAT_Parser.Config_Parser, IO => Util.Commands.Text_IO, Driver_Name => "test"); package Simple_Command is new Util.Commands.Drivers (Context_Type => Test_Context_Type, Config_Parser => Util.Commands.Parsers.No_Parser, IO => Util.Commands.Text_IO, Driver_Name => "simple"); type Test_Command_Type is new Test_Command.Command_Type with record Opt_Count : aliased Integer := 0; Opt_V : aliased Boolean := False; Opt_N : aliased Boolean := False; Expect_V : Boolean := False; Expect_N : Boolean := False; Expect_C : Integer := 0; Expect_A : Integer := 0; Expect_Help : Boolean := False; end record; overriding procedure Execute (Command : in out Test_Command_Type; Name : in String; Args : in Argument_List'Class; Context : in out Test_Context_Type); -- Setup the command before parsing the arguments and executing it. overriding procedure Setup (Command : in out Test_Command_Type; Config : in out GNAT.Command_Line.Command_Line_Configuration; Context : in out Test_Context_Type); -- Write the help associated with the command. overriding procedure Help (Command : in out Test_Command_Type; Name : in String; Context : in out Test_Context_Type); procedure Add_Tests (Suite : in Util.Tests.Access_Test_Suite) is begin Caller.Add_Test (Suite, "Test Util.Commands.Driver.Execute", Test_Execute'Access); Caller.Add_Test (Suite, "Test Util.Commands.Driver.Help", Test_Help'Access); Caller.Add_Test (Suite, "Test Util.Commands.Driver.Usage", Test_Usage'Access); Caller.Add_Test (Suite, "Test Util.Commands.Driver.Add_Command", Test_Simple_Command'Access); end Add_Tests; overriding procedure Execute (Command : in out Test_Command_Type; Name : in String; Args : in Argument_List'Class; Context : in out Test_Context_Type) is pragma Unreferenced (Name); begin Command.Log (Util.Log.ERROR_LEVEL, "command", "execute command message"); Context.Success := Command.Opt_Count = Command.Expect_C and then Command.Opt_V = Command.Expect_V and then Command.Opt_N = Command.Expect_N and then Args.Get_Count = Command.Expect_A and then not Command.Expect_Help; end Execute; -- ------------------------------ -- Setup the command before parsing the arguments and executing it. -- ------------------------------ overriding procedure Setup (Command : in out Test_Command_Type; Config : in out GNAT.Command_Line.Command_Line_Configuration; Context : in out Test_Context_Type) is pragma Unreferenced (Context); begin GNAT.Command_Line.Define_Switch (Config => Config, Switch => "-c:", Long_Switch => "--count=", Help => "Number option", Section => "", Initial => Integer (0), Default => Integer (10), Output => Command.Opt_Count'Access); GNAT.Command_Line.Define_Switch (Config => Config, Switch => "-v", Long_Switch => "--verbose", Help => "Verbose option", Section => "", Output => Command.Opt_V'Access); GNAT.Command_Line.Define_Switch (Config => Config, Switch => "-n", Long_Switch => "--not", Help => "Not option", Section => "", Output => Command.Opt_N'Access); end Setup; -- ------------------------------ -- Write the help associated with the command. -- ------------------------------ overriding procedure Help (Command : in out Test_Command_Type; Name : in String; Context : in out Test_Context_Type) is pragma Unreferenced (Name); begin Context.Success := Command.Expect_Help; end Help; -- ------------------------------ -- Tests when the execution of commands. -- ------------------------------ procedure Test_Execute (T : in out Test) is C1 : aliased Test_Command_Type; C2 : aliased Test_Command_Type; D : Test_Command.Driver_Type; Args : String_Argument_List (500, 30); begin D.Set_Description ("Test command"); D.Add_Command ("list", C1'Unchecked_Access); D.Add_Command ("print", C2'Unchecked_Access); declare Ctx : Test_Context_Type; begin C1.Expect_V := True; C1.Expect_N := True; C1.Expect_C := 4; C1.Expect_A := 2; Initialize (Args, "list --count=4 -v -n test titi"); D.Execute ("list", Args, Ctx); T.Assert (Ctx.Success, "Some arguments not parsed correctly"); end; declare Ctx : Test_Context_Type; begin C1.Expect_V := False; C1.Expect_N := True; C1.Expect_C := 8; C1.Expect_A := 3; Initialize (Args, "list -c 8 -n test titi last"); D.Execute ("list", Args, Ctx); T.Assert (Ctx.Success, "Some arguments not parsed correctly"); end; declare Ctx : Test_Context_Type; begin C1.Expect_V := False; C1.Expect_N := True; C1.Expect_C := 8; C1.Expect_A := 3; Initialize (Args, "bad -c 8 -n test titi last"); D.Execute ("bad", Args, Ctx); T.Fail ("No exception raised for missing command"); exception when Not_Found => null; end; end Test_Execute; -- ------------------------------ -- Test execution of help. -- ------------------------------ procedure Test_Help (T : in out Test) is C1 : aliased Test_Command_Type; C2 : aliased Test_Command_Type; H : aliased Test_Command.Help_Command_Type; D : Test_Command.Driver_Type; Args : String_Argument_List (500, 30); begin D.Set_Description ("Test command"); D.Add_Command ("list", C1'Unchecked_Access); D.Add_Command ("print", C2'Unchecked_Access); D.Add_Command ("help", H'Unchecked_Access); declare Ctx : Test_Context_Type; begin C1.Expect_Help := True; Initialize (Args, "help list"); D.Execute ("help", Args, Ctx); T.Assert (Ctx.Success, "Some arguments not parsed correctly"); end; declare Ctx : Test_Context_Type; begin C2.Expect_Help := True; Initialize (Args, "help print"); D.Execute ("help", Args, Ctx); T.Assert (Ctx.Success, "Some arguments not parsed correctly"); end; declare Ctx : Test_Context_Type; begin C1.Expect_Help := False; C2.Expect_Help := False; Initialize (Args, "help"); D.Execute ("help", Args, Ctx); T.Assert (not Ctx.Success, "Some arguments not parsed correctly"); end; declare Ctx : Test_Context_Type; begin Initialize (Args, "help missing"); D.Execute ("help", Args, Ctx); T.Fail ("No exception raised for missing command"); exception when Not_Found => null; end; end Test_Help; -- ------------------------------ -- Test usage operation. -- ------------------------------ procedure Test_Usage (T : in out Test) is C1 : aliased Test_Command_Type; C2 : aliased Test_Command_Type; H : aliased Test_Command.Help_Command_Type; D : Test_Command.Driver_Type; Args : String_Argument_List (500, 30); begin D.Set_Description ("Test command"); D.Add_Command ("list", C1'Unchecked_Access); D.Add_Command ("print", C2'Unchecked_Access); D.Add_Command ("help", H'Unchecked_Access); Args.Initialize (Line => "cmd list"); declare Ctx : Test_Context_Type; begin D.Usage (Args, Ctx); C1.Expect_Help := True; Initialize (Args, "help list"); D.Execute ("help", Args, Ctx); T.Assert (Ctx.Success, "Some arguments not parsed correctly"); D.Usage (Args, Ctx, "list"); end; end Test_Usage; procedure Simple (Name : in String; Args : in Argument_List'Class; Ctx : in out Test_Context_Type) is pragma Unreferenced (Name, Args); begin Ctx.Number := 1; Ctx.Success := True; end Simple; -- Test command based on the No_Parser. procedure Test_Simple_Command (T : in out Test) is D : Simple_Command.Driver_Type; Args : String_Argument_List (500, 30); begin D.Add_Command ("list", "list command", Simple'Access); declare Ctx : Test_Context_Type; begin Initialize (Args, "list --count=4 -v -n test titi"); D.Execute ("list", Args, Ctx); T.Assert (Ctx.Success, "Some arguments not parsed correctly"); Util.Tests.Assert_Equals (T, 1, Ctx.Number, "Invalid context number"); D.Usage (Args, Ctx, "list"); end; end Test_Simple_Command; end Util.Commands.Tests;
zhmu/ananas
Ada
236
ads
-- { dg-do compile } package Variant_Part is type T1(b: boolean) is record case (b) is -- { dg-error "discriminant name may not be parenthesized" } when others => null; end case; end record; end Variant_Part;
reznikmm/matreshka
Ada
3,615
ads
------------------------------------------------------------------------------ -- -- -- Matreshka Project -- -- -- -- Ada Modeling Framework -- -- -- -- Runtime Library Component -- -- -- ------------------------------------------------------------------------------ -- -- -- Copyright © 2012, Vadim Godunko <[email protected]> -- -- All rights reserved. -- -- -- -- Redistribution and use in source and binary forms, with or without -- -- modification, are permitted provided that the following conditions -- -- are met: -- -- -- -- * Redistributions of source code must retain the above copyright -- -- notice, this list of conditions and the following disclaimer. -- -- -- -- * Redistributions in binary form must reproduce the above copyright -- -- notice, this list of conditions and the following disclaimer in the -- -- documentation and/or other materials provided with the distribution. -- -- -- -- * Neither the name of the Vadim Godunko, IE nor the names of its -- -- contributors may be used to endorse or promote products derived from -- -- this software without specific prior written permission. -- -- -- -- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -- -- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -- -- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -- -- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -- -- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -- -- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED -- -- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -- -- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -- -- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -- -- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -- -- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- -- -- ------------------------------------------------------------------------------ -- $Revision$ $Date$ ------------------------------------------------------------------------------ -- This file is generated, don't edit it. ------------------------------------------------------------------------------ with AMF.Elements.Generic_Hash; function AMF.Utp.Data_Selectors.Hash is new AMF.Elements.Generic_Hash (Utp_Data_Selector, Utp_Data_Selector_Access);
sungyeon/drake
Ada
2,058
adb
with Ada.Containers; with Ada.Strings.Equal_Case_Insensitive; with Ada.Strings.Less_Case_Insensitive; with Ada.Strings.Hash_Case_Insensitive; with Ada.Strings.Wide_Hash_Case_Insensitive; with Ada.Strings.Wide_Wide_Hash_Case_Insensitive; procedure casing is use type Ada.Containers.Hash_Type; package AS renames Ada.Strings; subtype C is Character; Full_Width_Upper_A : constant String := ( C'Val (16#ef#), C'Val (16#bc#), C'Val (16#a1#)); Full_Width_Lower_A : constant String := ( C'Val (16#ef#), C'Val (16#bd#), C'Val (16#81#)); begin pragma Assert (AS.Equal_Case_Insensitive ("a", "a")); pragma Assert (not AS.Equal_Case_Insensitive ("a", "b")); pragma Assert (not AS.Equal_Case_Insensitive ("a", "aa")); pragma Assert (not AS.Equal_Case_Insensitive ("aa", "a")); pragma Assert (AS.Equal_Case_Insensitive ("a", "A")); pragma Assert (AS.Equal_Case_Insensitive ("aA", "Aa")); pragma Assert (AS.Equal_Case_Insensitive (Full_Width_Lower_A, Full_Width_Upper_A)); pragma Assert (AS.Less_Case_Insensitive ("a", "B")); pragma Assert (not AS.Less_Case_Insensitive ("b", "A")); pragma Assert (AS.Less_Case_Insensitive ("a", "AA")); pragma Assert (not AS.Less_Case_Insensitive ("aa", "A")); pragma Assert (not AS.Less_Case_Insensitive (Full_Width_Lower_A, Full_Width_Upper_A)); pragma Assert (AS.Hash_Case_Insensitive ("aAa") = AS.Hash_Case_Insensitive ("AaA")); -- Hash = Wide_Hash = Wide_Wide_Hash pragma Assert (AS.Hash_Case_Insensitive ("Hash") = AS.Wide_Hash_Case_Insensitive ("hASH")); pragma Assert (AS.Hash_Case_Insensitive ("HasH") = AS.Wide_Wide_Hash_Case_Insensitive ("hASh")); -- illegal sequence pragma Assert (AS.Less_Case_Insensitive ("", (1 => C'Val (16#80#)))); pragma Assert (AS.Less_Case_Insensitive (Full_Width_Upper_A, (1 => C'Val (16#80#)))); pragma Assert (AS.Less_Case_Insensitive (Full_Width_Upper_A, (C'Val (16#ef#), C'Val (16#bd#)))); pragma Assert (AS.Equal_Case_Insensitive (C'Val (16#80#) & Full_Width_Lower_A, C'Val (16#80#) & Full_Width_Upper_A)); pragma Debug (Ada.Debug.Put ("OK")); null; end casing;
reznikmm/matreshka
Ada
3,812
ads
------------------------------------------------------------------------------ -- -- -- Matreshka Project -- -- -- -- Open Document Toolkit -- -- -- -- Runtime Library Component -- -- -- ------------------------------------------------------------------------------ -- -- -- Copyright © 2013, Vadim Godunko <[email protected]> -- -- All rights reserved. -- -- -- -- Redistribution and use in source and binary forms, with or without -- -- modification, are permitted provided that the following conditions -- -- are met: -- -- -- -- * Redistributions of source code must retain the above copyright -- -- notice, this list of conditions and the following disclaimer. -- -- -- -- * Redistributions in binary form must reproduce the above copyright -- -- notice, this list of conditions and the following disclaimer in the -- -- documentation and/or other materials provided with the distribution. -- -- -- -- * Neither the name of the Vadim Godunko, IE nor the names of its -- -- contributors may be used to endorse or promote products derived from -- -- this software without specific prior written permission. -- -- -- -- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -- -- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -- -- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -- -- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -- -- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -- -- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED -- -- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -- -- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -- -- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -- -- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -- -- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- -- -- ------------------------------------------------------------------------------ -- $Revision$ $Date$ ------------------------------------------------------------------------------ with Matreshka.ODF_Documents; package ODF.DOM.Documents.Internals is function Create (Node : Matreshka.ODF_Documents.Document_Access) return ODF.DOM.Documents.ODF_Document; function Wrap (Node : Matreshka.ODF_Documents.Document_Access) return ODF.DOM.Documents.ODF_Document; function Internal (Document : ODF.DOM.Documents.ODF_Document'Class) return Matreshka.ODF_Documents.Document_Access; end ODF.DOM.Documents.Internals;
riccardo-bernardini/eugen
Ada
1,780
adb
package body EU_Projects.Nodes.Timed_Nodes is procedure Due_On (Item : in out Timed_Node; Time : in String) is begin Item.Expected_Raw := To_Unbounded_String (Time); -- Times.Time_Expressions.Symbolic (Time); end Due_On; procedure Parse_Raw_Expressions (Item : in out Timed_Node; Vars : Times.Time_Expressions.Parsing.Symbol_Table) is use Times.Time_Expressions.Parsing; To_Parse : constant String := (if Item.Expected_Raw = Event_Names.Default_Time then After (Timed_Node'Class (Item).Dependency_List, Timed_Node'Class (Item).Dependency_Ready_Var) else To_String (Item.Expected_Raw)); begin Item.Expected_Symbolic := Parse (Input => To_Parse, Symbols => Vars); end Parse_Raw_Expressions; overriding procedure Fix_Instant (Item : in out Timed_Node; Var : Simple_Identifier; Value : Times.Instant) is begin if Var = Event_Names.Event_Time_Name then Item.Expected_On := Value; else raise Unknown_Instant_Var with To_String (Var); end if; Item.Fixed := True; end Fix_Instant; -------------- -- Is_Fixed -- -------------- overriding function Is_Fixed (Item : Timed_Node; Var : Simple_Identifier) return Boolean is begin if Var = Event_Names.Event_Time_Name then return Item.Fixed; else raise Unknown_Var with To_String (Var); end if; end Is_Fixed; end EU_Projects.Nodes.Timed_Nodes;
sungyeon/drake
Ada
440
adb
with System.Formatting.Decimal; package body System.Img_Dec is procedure Image_Decimal ( V : Integer; S : in out String; P : out Natural; Scale : Integer) is Fore_Last : Natural; begin Formatting.Decimal.Image ( Long_Long_Integer (V), S, Fore_Last, P, Scale, Aft_Width => Integer'Max (1, Scale)); end Image_Decimal; end System.Img_Dec;
reznikmm/matreshka
Ada
4,739
ads
------------------------------------------------------------------------------ -- -- -- Matreshka Project -- -- -- -- Open Document Toolkit -- -- -- -- Runtime Library Component -- -- -- ------------------------------------------------------------------------------ -- -- -- Copyright © 2014, Vadim Godunko <[email protected]> -- -- All rights reserved. -- -- -- -- Redistribution and use in source and binary forms, with or without -- -- modification, are permitted provided that the following conditions -- -- are met: -- -- -- -- * Redistributions of source code must retain the above copyright -- -- notice, this list of conditions and the following disclaimer. -- -- -- -- * Redistributions in binary form must reproduce the above copyright -- -- notice, this list of conditions and the following disclaimer in the -- -- documentation and/or other materials provided with the distribution. -- -- -- -- * Neither the name of the Vadim Godunko, IE nor the names of its -- -- contributors may be used to endorse or promote products derived from -- -- this software without specific prior written permission. -- -- -- -- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -- -- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -- -- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -- -- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -- -- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -- -- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED -- -- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -- -- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -- -- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -- -- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -- -- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- -- -- ------------------------------------------------------------------------------ -- $Revision$ $Date$ ------------------------------------------------------------------------------ with XML.DOM.Visitors; with ODF.DOM.Text_Sender_Title_Elements; package Matreshka.ODF_Text.Sender_Title_Elements is type Text_Sender_Title_Element_Node is new Matreshka.ODF_Text.Abstract_Text_Element_Node and ODF.DOM.Text_Sender_Title_Elements.ODF_Text_Sender_Title with null record; overriding function Create (Parameters : not null access Matreshka.DOM_Elements.Element_L2_Parameters) return Text_Sender_Title_Element_Node; overriding function Get_Local_Name (Self : not null access constant Text_Sender_Title_Element_Node) return League.Strings.Universal_String; overriding procedure Enter_Node (Self : not null access Text_Sender_Title_Element_Node; Visitor : in out XML.DOM.Visitors.Abstract_Visitor'Class; Control : in out XML.DOM.Visitors.Traverse_Control); overriding procedure Leave_Node (Self : not null access Text_Sender_Title_Element_Node; Visitor : in out XML.DOM.Visitors.Abstract_Visitor'Class; Control : in out XML.DOM.Visitors.Traverse_Control); overriding procedure Visit_Node (Self : not null access Text_Sender_Title_Element_Node; Iterator : in out XML.DOM.Visitors.Abstract_Iterator'Class; Visitor : in out XML.DOM.Visitors.Abstract_Visitor'Class; Control : in out XML.DOM.Visitors.Traverse_Control); end Matreshka.ODF_Text.Sender_Title_Elements;
reznikmm/webidl
Ada
618
ads
-- SPDX-FileCopyrightText: 2021 Max Reznik <[email protected]> -- -- SPDX-License-Identifier: MIT ------------------------------------------------------------- with WebIDL.Arguments; with WebIDL.Interface_Members; package WebIDL.Constructors is pragma Preelaborate; type Constructor is limited interface and WebIDL.Interface_Members.Interface_Member; type Constructor_Access is access all Constructor'Class with Storage_Size => 0; not overriding function Arguments (Self : Constructor) return not null WebIDL.Arguments.Argument_Iterator_Access is abstract; end WebIDL.Constructors;
reznikmm/matreshka
Ada
4,656
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.Num_Letter_Sync_Attributes is ------------ -- Create -- ------------ overriding function Create (Parameters : not null access Matreshka.DOM_Attributes.Attribute_L2_Parameters) return Style_Num_Letter_Sync_Attribute_Node is begin return Self : Style_Num_Letter_Sync_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_Num_Letter_Sync_Attribute_Node) return League.Strings.Universal_String is pragma Unreferenced (Self); begin return Matreshka.ODF_String_Constants.Num_Letter_Sync_Attribute; end Get_Local_Name; begin Matreshka.DOM_Documents.Register_Attribute (Matreshka.ODF_String_Constants.Style_URI, Matreshka.ODF_String_Constants.Num_Letter_Sync_Attribute, Style_Num_Letter_Sync_Attribute_Node'Tag); end Matreshka.ODF_Style.Num_Letter_Sync_Attributes;
reznikmm/matreshka
Ada
15,329
ads
------------------------------------------------------------------------------ -- -- -- Matreshka Project -- -- -- -- Ada Modeling Framework -- -- -- -- Runtime Library Component -- -- -- ------------------------------------------------------------------------------ -- -- -- Copyright © 2011-2012, Vadim Godunko <[email protected]> -- -- All rights reserved. -- -- -- -- Redistribution and use in source and binary forms, with or without -- -- modification, are permitted provided that the following conditions -- -- are met: -- -- -- -- * Redistributions of source code must retain the above copyright -- -- notice, this list of conditions and the following disclaimer. -- -- -- -- * Redistributions in binary form must reproduce the above copyright -- -- notice, this list of conditions and the following disclaimer in the -- -- documentation and/or other materials provided with the distribution. -- -- -- -- * Neither the name of the Vadim Godunko, IE nor the names of its -- -- contributors may be used to endorse or promote products derived from -- -- this software without specific prior written permission. -- -- -- -- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -- -- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -- -- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -- -- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -- -- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -- -- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED -- -- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -- -- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -- -- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -- -- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -- -- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- -- -- ------------------------------------------------------------------------------ -- $Revision$ $Date$ ------------------------------------------------------------------------------ with AMF.Internals.UML_Packageable_Elements; with AMF.UML.Dependencies.Collections; with AMF.UML.Duration_Intervals; with AMF.UML.Durations; with AMF.UML.Named_Elements; with AMF.UML.Namespaces; with AMF.UML.Packages.Collections; with AMF.UML.Parameterable_Elements; with AMF.UML.String_Expressions; with AMF.UML.Template_Parameters; with AMF.UML.Types; with AMF.UML.Value_Specifications; with AMF.Visitors; package AMF.Internals.UML_Duration_Intervals is type UML_Duration_Interval_Proxy is limited new AMF.Internals.UML_Packageable_Elements.UML_Packageable_Element_Proxy and AMF.UML.Duration_Intervals.UML_Duration_Interval with null record; overriding function Get_Max (Self : not null access constant UML_Duration_Interval_Proxy) return AMF.UML.Durations.UML_Duration_Access; -- Getter of DurationInterval::max. -- -- Refers to the Duration denoting the maximum value of the range. overriding procedure Set_Max (Self : not null access UML_Duration_Interval_Proxy; To : AMF.UML.Durations.UML_Duration_Access); -- Setter of DurationInterval::max. -- -- Refers to the Duration denoting the maximum value of the range. overriding function Get_Min (Self : not null access constant UML_Duration_Interval_Proxy) return AMF.UML.Durations.UML_Duration_Access; -- Getter of DurationInterval::min. -- -- Refers to the Duration denoting the minimum value of the range. overriding procedure Set_Min (Self : not null access UML_Duration_Interval_Proxy; To : AMF.UML.Durations.UML_Duration_Access); -- Setter of DurationInterval::min. -- -- Refers to the Duration denoting the minimum value of the range. overriding function Get_Max (Self : not null access constant UML_Duration_Interval_Proxy) return AMF.UML.Value_Specifications.UML_Value_Specification_Access; -- Getter of Interval::max. -- -- Refers to the ValueSpecification denoting the maximum value of the -- range. overriding procedure Set_Max (Self : not null access UML_Duration_Interval_Proxy; To : AMF.UML.Value_Specifications.UML_Value_Specification_Access); -- Setter of Interval::max. -- -- Refers to the ValueSpecification denoting the maximum value of the -- range. overriding function Get_Min (Self : not null access constant UML_Duration_Interval_Proxy) return AMF.UML.Value_Specifications.UML_Value_Specification_Access; -- Getter of Interval::min. -- -- Refers to the ValueSpecification denoting the minimum value of the -- range. overriding procedure Set_Min (Self : not null access UML_Duration_Interval_Proxy; To : AMF.UML.Value_Specifications.UML_Value_Specification_Access); -- Setter of Interval::min. -- -- Refers to the ValueSpecification denoting the minimum value of the -- range. overriding function Get_Type (Self : not null access constant UML_Duration_Interval_Proxy) return AMF.UML.Types.UML_Type_Access; -- Getter of TypedElement::type. -- -- The type of the TypedElement. -- This information is derived from the return result for this Operation. overriding procedure Set_Type (Self : not null access UML_Duration_Interval_Proxy; To : AMF.UML.Types.UML_Type_Access); -- Setter of TypedElement::type. -- -- The type of the TypedElement. -- This information is derived from the return result for this Operation. overriding function Get_Client_Dependency (Self : not null access constant UML_Duration_Interval_Proxy) return AMF.UML.Dependencies.Collections.Set_Of_UML_Dependency; -- Getter of NamedElement::clientDependency. -- -- Indicates the dependencies that reference the client. overriding function Get_Name_Expression (Self : not null access constant UML_Duration_Interval_Proxy) return AMF.UML.String_Expressions.UML_String_Expression_Access; -- Getter of NamedElement::nameExpression. -- -- The string expression used to define the name of this named element. overriding procedure Set_Name_Expression (Self : not null access UML_Duration_Interval_Proxy; To : AMF.UML.String_Expressions.UML_String_Expression_Access); -- Setter of NamedElement::nameExpression. -- -- The string expression used to define the name of this named element. overriding function Get_Namespace (Self : not null access constant UML_Duration_Interval_Proxy) return AMF.UML.Namespaces.UML_Namespace_Access; -- Getter of NamedElement::namespace. -- -- Specifies the namespace that owns the NamedElement. overriding function Get_Qualified_Name (Self : not null access constant UML_Duration_Interval_Proxy) return AMF.Optional_String; -- Getter of NamedElement::qualifiedName. -- -- A name which allows the NamedElement to be identified within a -- hierarchy of nested Namespaces. It is constructed from the names of the -- containing namespaces starting at the root of the hierarchy and ending -- with the name of the NamedElement itself. overriding function Get_Owning_Template_Parameter (Self : not null access constant UML_Duration_Interval_Proxy) return AMF.UML.Template_Parameters.UML_Template_Parameter_Access; -- Getter of ParameterableElement::owningTemplateParameter. -- -- The formal template parameter that owns this element. overriding procedure Set_Owning_Template_Parameter (Self : not null access UML_Duration_Interval_Proxy; To : AMF.UML.Template_Parameters.UML_Template_Parameter_Access); -- Setter of ParameterableElement::owningTemplateParameter. -- -- The formal template parameter that owns this element. overriding function Get_Template_Parameter (Self : not null access constant UML_Duration_Interval_Proxy) return AMF.UML.Template_Parameters.UML_Template_Parameter_Access; -- Getter of ParameterableElement::templateParameter. -- -- The template parameter that exposes this element as a formal parameter. overriding procedure Set_Template_Parameter (Self : not null access UML_Duration_Interval_Proxy; To : AMF.UML.Template_Parameters.UML_Template_Parameter_Access); -- Setter of ParameterableElement::templateParameter. -- -- The template parameter that exposes this element as a formal parameter. overriding function Boolean_Value (Self : not null access constant UML_Duration_Interval_Proxy) return AMF.Optional_Boolean; -- Operation ValueSpecification::booleanValue. -- -- The query booleanValue() gives a single Boolean value when one can be -- computed. overriding function Integer_Value (Self : not null access constant UML_Duration_Interval_Proxy) return AMF.Optional_Integer; -- Operation ValueSpecification::integerValue. -- -- The query integerValue() gives a single Integer value when one can be -- computed. overriding function Is_Compatible_With (Self : not null access constant UML_Duration_Interval_Proxy; P : AMF.UML.Parameterable_Elements.UML_Parameterable_Element_Access) return Boolean; -- Operation ValueSpecification::isCompatibleWith. -- -- The query isCompatibleWith() determines if this parameterable element -- is compatible with the specified parameterable element. By default -- parameterable element P is compatible with parameterable element Q if -- the kind of P is the same or a subtype as the kind of Q. In addition, -- for ValueSpecification, the type must be conformant with the type of -- the specified parameterable element. overriding function Is_Computable (Self : not null access constant UML_Duration_Interval_Proxy) return Boolean; -- Operation ValueSpecification::isComputable. -- -- The query isComputable() determines whether a value specification can -- be computed in a model. This operation cannot be fully defined in OCL. -- A conforming implementation is expected to deliver true for this -- operation for all value specifications that it can compute, and to -- compute all of those for which the operation is true. A conforming -- implementation is expected to be able to compute the value of all -- literals. overriding function Is_Null (Self : not null access constant UML_Duration_Interval_Proxy) return Boolean; -- Operation ValueSpecification::isNull. -- -- The query isNull() returns true when it can be computed that the value -- is null. overriding function Real_Value (Self : not null access constant UML_Duration_Interval_Proxy) return AMF.Optional_Real; -- Operation ValueSpecification::realValue. -- -- The query realValue() gives a single Real value when one can be -- computed. overriding function String_Value (Self : not null access constant UML_Duration_Interval_Proxy) return AMF.Optional_String; -- Operation ValueSpecification::stringValue. -- -- The query stringValue() gives a single String value when one can be -- computed. overriding function Unlimited_Value (Self : not null access constant UML_Duration_Interval_Proxy) return AMF.Optional_Unlimited_Natural; -- Operation ValueSpecification::unlimitedValue. -- -- The query unlimitedValue() gives a single UnlimitedNatural value when -- one can be computed. overriding function All_Owning_Packages (Self : not null access constant UML_Duration_Interval_Proxy) return AMF.UML.Packages.Collections.Set_Of_UML_Package; -- Operation NamedElement::allOwningPackages. -- -- The query allOwningPackages() returns all the directly or indirectly -- owning packages. overriding function Is_Distinguishable_From (Self : not null access constant UML_Duration_Interval_Proxy; N : AMF.UML.Named_Elements.UML_Named_Element_Access; Ns : AMF.UML.Namespaces.UML_Namespace_Access) return Boolean; -- Operation NamedElement::isDistinguishableFrom. -- -- The query isDistinguishableFrom() determines whether two NamedElements -- may logically co-exist within a Namespace. By default, two named -- elements are distinguishable if (a) they have unrelated types or (b) -- they have related types but different names. overriding function Namespace (Self : not null access constant UML_Duration_Interval_Proxy) return AMF.UML.Namespaces.UML_Namespace_Access; -- Operation NamedElement::namespace. -- -- Missing derivation for NamedElement::/namespace : Namespace overriding function Is_Template_Parameter (Self : not null access constant UML_Duration_Interval_Proxy) return Boolean; -- Operation ParameterableElement::isTemplateParameter. -- -- The query isTemplateParameter() determines if this parameterable -- element is exposed as a formal template parameter. overriding procedure Enter_Element (Self : not null access constant UML_Duration_Interval_Proxy; Visitor : in out AMF.Visitors.Abstract_Visitor'Class; Control : in out AMF.Visitors.Traverse_Control); -- Dispatch call to corresponding subprogram of visitor interface. overriding procedure Leave_Element (Self : not null access constant UML_Duration_Interval_Proxy; Visitor : in out AMF.Visitors.Abstract_Visitor'Class; Control : in out AMF.Visitors.Traverse_Control); -- Dispatch call to corresponding subprogram of visitor interface. overriding procedure Visit_Element (Self : not null access constant UML_Duration_Interval_Proxy; Iterator : in out AMF.Visitors.Abstract_Iterator'Class; Visitor : in out AMF.Visitors.Abstract_Visitor'Class; Control : in out AMF.Visitors.Traverse_Control); -- Dispatch call to corresponding subprogram of iterator interface. end AMF.Internals.UML_Duration_Intervals;
reznikmm/matreshka
Ada
3,779
ads
------------------------------------------------------------------------------ -- -- -- Matreshka Project -- -- -- -- Open Document Toolkit -- -- -- -- Runtime Library Component -- -- -- ------------------------------------------------------------------------------ -- -- -- Copyright © 2014, Vadim Godunko <[email protected]> -- -- All rights reserved. -- -- -- -- Redistribution and use in source and binary forms, with or without -- -- modification, are permitted provided that the following conditions -- -- are met: -- -- -- -- * Redistributions of source code must retain the above copyright -- -- notice, this list of conditions and the following disclaimer. -- -- -- -- * Redistributions in binary form must reproduce the above copyright -- -- notice, this list of conditions and the following disclaimer in the -- -- documentation and/or other materials provided with the distribution. -- -- -- -- * Neither the name of the Vadim Godunko, IE nor the names of its -- -- contributors may be used to endorse or promote products derived from -- -- this software without specific prior written permission. -- -- -- -- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -- -- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -- -- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -- -- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -- -- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -- -- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED -- -- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -- -- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -- -- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -- -- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -- -- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- -- -- ------------------------------------------------------------------------------ -- $Revision$ $Date$ ------------------------------------------------------------------------------ with XML.DOM.Attributes; package ODF.DOM.Chart_Data_Source_Has_Labels_Attributes is pragma Preelaborate; type ODF_Chart_Data_Source_Has_Labels_Attribute is limited interface and XML.DOM.Attributes.DOM_Attribute; type ODF_Chart_Data_Source_Has_Labels_Attribute_Access is access all ODF_Chart_Data_Source_Has_Labels_Attribute'Class with Storage_Size => 0; end ODF.DOM.Chart_Data_Source_Has_Labels_Attributes;
reznikmm/matreshka
Ada
3,664
ads
------------------------------------------------------------------------------ -- -- -- Matreshka Project -- -- -- -- Open Document Toolkit -- -- -- -- Runtime Library Component -- -- -- ------------------------------------------------------------------------------ -- -- -- Copyright © 2014, Vadim Godunko <[email protected]> -- -- All rights reserved. -- -- -- -- Redistribution and use in source and binary forms, with or without -- -- modification, are permitted provided that the following conditions -- -- are met: -- -- -- -- * Redistributions of source code must retain the above copyright -- -- notice, this list of conditions and the following disclaimer. -- -- -- -- * Redistributions in binary form must reproduce the above copyright -- -- notice, this list of conditions and the following disclaimer in the -- -- documentation and/or other materials provided with the distribution. -- -- -- -- * Neither the name of the Vadim Godunko, IE nor the names of its -- -- contributors may be used to endorse or promote products derived from -- -- this software without specific prior written permission. -- -- -- -- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -- -- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -- -- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -- -- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -- -- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -- -- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED -- -- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -- -- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -- -- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -- -- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -- -- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- -- -- ------------------------------------------------------------------------------ -- $Revision$ $Date$ ------------------------------------------------------------------------------ with XML.DOM.Elements; package ODF.DOM.Text_Note_Ref_Elements is pragma Preelaborate; type ODF_Text_Note_Ref is limited interface and XML.DOM.Elements.DOM_Element; type ODF_Text_Note_Ref_Access is access all ODF_Text_Note_Ref'Class with Storage_Size => 0; end ODF.DOM.Text_Note_Ref_Elements;
rogermc2/GA_Ada
Ada
3,238
ads
with GL.Types; with GL.Types.Colors; use GL.Types.Colors; with Geosphere; package Palet is use GL.Types; type Draw_Mode_Type is (OD_Shade, OD_Wireframe ,OD_Magnitude, OD_Orientation); type Draw_Mode is record Shade : Boolean := False; Wireframe : Boolean := False; Magnitude : Boolean := False; Orientation : Boolean := False; end record ; type Draw_State is private; type Colour_Palet is private; function Background_Colour (Palet_Data : Colour_Palet) return Color; function Background_Red (Palet_Data : Colour_Palet) return Single; function Background_Green (Palet_Data : Colour_Palet) return Single; function Background_Blue (Palet_Data : Colour_Palet) return Single; function Current_Sphere return Geosphere.Geosphere; function Foreground_Alpha (Palet_Data : Colour_Palet) return Single; function Foreground_Blue (Palet_Data : Colour_Palet) return Single; function Foreground_Colour (Palet_Data : Colour_Palet) return Color; function Foreground_Green (Palet_Data : Colour_Palet) return Single; function Foreground_Red (Palet_Data : Colour_Palet) return Single; function Get_Draw_Mode return Draw_Mode; function Get_Plane_Size return Float; function Is_Null return Colour_Palet; function Line_Length return Float; function Orientation return Boolean; function Magnitude return Boolean; function Outline_Colour (Palet_Data : Colour_Palet) return Color; function Point_Size return Float; function Shade return Boolean; procedure Set_Background_Alpa (Palet_Data : in out Colour_Palet; Alpa : Float); procedure Set_Background_Colour (Palet_Data : in out Colour_Palet; Back_Colour : Color); procedure Set_Background_Colour (Palet_Data : Colour_Palet); procedure Set_Current_Sphere (aSphere : Geosphere.Geosphere); procedure Set_Draw_Mode_Off (Mode : Draw_Mode_Type); procedure Set_Draw_Mode_On (Mode : Draw_Mode_Type); procedure Set_Foreground_Alpa (Palet_Data : in out Colour_Palet; Alpa : Float); procedure Set_Foreground_Colour (Palet_Data : in out Colour_Palet; Fore_Colour : Color); procedure Set_Foreground_Colour (Palet_Data : Colour_Palet); procedure Set_Outline_Alpa (Palet_Data : in out Colour_Palet; Alpa : Float); procedure Set_Outline_Colour (Palet_Data : in out Colour_Palet; Outline_Colour : Color); procedure Set_Outline_Colour (Palet_Data : Colour_Palet); procedure Set_Point_Size (Point_Size : Float); function Wireframe return Boolean; private type Colour_Palet is record Off : Boolean := False; Foreground_Colour : Color := (1.0, 0.0, 0.0, 1.0); Background_Colour : Color := (0.0, 1.0, 0.0, 1.0); Outline_Colour : Color := (0.0, 0.0, 0.0, 1.0); end record; type Draw_State is record Ambient : Float := 1.0; Diffuse : Float := 0.0; Point_Size : Float := 0.2; Line_Length : Float := 6.0; Plane_Size : Float := 6.0; M_Draw_Mode : Draw_Mode; M_Sphere : Geosphere.Geosphere; -- M_Sphere_GL_List : GL.Types.UInt; end record; end Palet;
reznikmm/matreshka
Ada
5,876
ads
------------------------------------------------------------------------------ -- -- -- Matreshka Project -- -- -- -- Ada Modeling Framework -- -- -- -- Runtime Library Component -- -- -- ------------------------------------------------------------------------------ -- -- -- Copyright © 2010-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.CMOF; with AMF.Elements; with Matreshka.Internals.Strings; package AMF.Internals.Tables.CMOF_Types is pragma Preelaborate; type Element_Kinds is (E_None, E_CMOF_Association, E_CMOF_Class, E_CMOF_Comment, E_CMOF_Constraint, E_CMOF_Data_Type, E_CMOF_Element_Import, E_CMOF_Enumeration, E_CMOF_Enumeration_Literal, E_CMOF_Expression, E_CMOF_Opaque_Expression, E_CMOF_Operation, E_CMOF_Package, E_CMOF_Package_Import, E_CMOF_Package_Merge, E_CMOF_Parameter, E_CMOF_Primitive_Type, E_CMOF_Property, E_CMOF_Tag); type Member_Kinds is (M_None, M_Boolean, M_Collection_Of_Element, M_Collection_Of_String, M_Element, M_Holder_Of_Integer, M_Holder_Of_Unlimited_Natural, M_Holder_Of_Visibility_Kind, M_Parameter_Direction_Kind, M_String, M_Visibility_Kind); type Member_Record (Kind : Member_Kinds := M_None) is record case Kind is when M_None => null; when M_Boolean => Boolean_Value : Boolean; when M_Collection_Of_Element => Collection : AMF.Internals.AMF_Collection_Of_Element; when M_Collection_Of_String => String_Collection : AMF.Internals.AMF_Collection_Of_String; when M_Element => Link : AMF.Internals.AMF_Link; when M_Holder_Of_Integer => Integer_Holder : AMF.Optional_Integer; when M_Holder_Of_Unlimited_Natural => Unlimited_Natural_Holder : AMF.Optional_Unlimited_Natural; when M_Holder_Of_Visibility_Kind => Visibility_Kind_Holder : AMF.CMOF.Optional_CMOF_Visibility_Kind; when M_Parameter_Direction_Kind => Parameter_Direction_Kind_Value : AMF.CMOF.CMOF_Parameter_Direction_Kind; when M_String => String_Value : Matreshka.Internals.Strings.Shared_String_Access; when M_Visibility_Kind => Visibility_Kind_Value : AMF.CMOF.CMOF_Visibility_Kind; end case; end record; type Member_Array is array (Natural range 0 .. 21) of Member_Record; type Element_Record is record Kind : Element_Kinds := E_None; Extent : AMF.Internals.AMF_Extent; Proxy : AMF.Elements.Element_Access; Member : Member_Array; end record; end AMF.Internals.Tables.CMOF_Types;
stcarrez/ada-awa
Ada
15,661
ads
----------------------------------------------------------------------- -- AWA.Permissions.Models -- AWA.Permissions.Models ----------------------------------------------------------------------- -- File generated by Dynamo DO NOT MODIFY -- Template used: templates/model/package-spec.xhtml -- Ada Generator: https://github.com/stcarrez/dynamo Version 1.4.0 ----------------------------------------------------------------------- -- Copyright (C) 2023 Stephane Carrez -- Written by Stephane Carrez ([email protected]) -- -- Licensed under the Apache License, Version 2.0 (the "License"); -- you may not use this file except in compliance with the License. -- You may obtain a copy of the License at -- -- http://www.apache.org/licenses/LICENSE-2.0 -- -- Unless required by applicable law or agreed to in writing, software -- distributed under the License is distributed on an "AS IS" BASIS, -- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -- See the License for the specific language governing permissions and -- limitations under the License. ----------------------------------------------------------------------- pragma Warnings (Off); with ADO.Sessions; with ADO.Objects; with ADO.Statements; with ADO.SQL; with ADO.Schemas; with ADO.Queries; with ADO.Queries.Loaders; with Ada.Containers.Vectors; with Ada.Strings.Unbounded; with Util.Beans.Objects; with Util.Beans.Basic.Lists; pragma Warnings (On); package AWA.Permissions.Models is pragma Style_Checks ("-mrIu"); type ACL_Ref is new ADO.Objects.Object_Ref with null record; type Permission_Ref is new ADO.Objects.Object_Ref with null record; -- -------------------- -- The ACL table records permissions which are granted for a user to access a given database entity. -- -------------------- -- Create an object key for ACL. function ACL_Key (Id : in ADO.Identifier) return ADO.Objects.Object_Key; -- Create an object key for ACL from a string. -- Raises Constraint_Error if the string cannot be converted into the object key. function ACL_Key (Id : in String) return ADO.Objects.Object_Key; Null_ACL : constant ACL_Ref; function "=" (Left, Right : ACL_Ref'Class) return Boolean; -- Set the ACL identifier procedure Set_Id (Object : in out Acl_Ref; Value : in ADO.Identifier); -- Get the ACL identifier function Get_Id (Object : in Acl_Ref) return ADO.Identifier; -- Set the entity identifier to which the ACL applies procedure Set_Entity_Id (Object : in out Acl_Ref; Value : in ADO.Identifier); -- Get the entity identifier to which the ACL applies function Get_Entity_Id (Object : in Acl_Ref) return ADO.Identifier; -- Set the writeable flag procedure Set_Writeable (Object : in out Acl_Ref; Value : in Boolean); -- Get the writeable flag function Get_Writeable (Object : in Acl_Ref) return Boolean; -- procedure Set_User_Id (Object : in out Acl_Ref; Value : in ADO.Identifier); -- function Get_User_Id (Object : in Acl_Ref) return ADO.Identifier; -- procedure Set_Workspace_Id (Object : in out Acl_Ref; Value : in ADO.Identifier); -- function Get_Workspace_Id (Object : in Acl_Ref) return ADO.Identifier; -- Set the entity type concerned by the ACL. procedure Set_Entity_Type (Object : in out Acl_Ref; Value : in ADO.Entity_Type); -- Get the entity type concerned by the ACL. function Get_Entity_Type (Object : in Acl_Ref) return ADO.Entity_Type; -- Set the permission that is granted. procedure Set_Permission (Object : in out Acl_Ref; Value : in ADO.Identifier); -- Get the permission that is granted. function Get_Permission (Object : in Acl_Ref) return ADO.Identifier; -- Load the entity identified by 'Id'. -- Raises the NOT_FOUND exception if it does not exist. procedure Load (Object : in out Acl_Ref; Session : in out ADO.Sessions.Session'Class; Id : in ADO.Identifier); -- Load the entity identified by 'Id'. -- Returns True in <b>Found</b> if the object was found and False if it does not exist. procedure Load (Object : in out Acl_Ref; Session : in out ADO.Sessions.Session'Class; Id : in ADO.Identifier; Found : out Boolean); -- Find and load the entity. overriding procedure Find (Object : in out Acl_Ref; Session : in out ADO.Sessions.Session'Class; Query : in ADO.SQL.Query'Class; Found : out Boolean); -- Save the entity. If the entity does not have an identifier, an identifier is allocated -- and it is inserted in the table. Otherwise, only data fields which have been changed -- are updated. overriding procedure Save (Object : in out Acl_Ref; Session : in out ADO.Sessions.Master_Session'Class); -- Delete the entity. overriding procedure Delete (Object : in out Acl_Ref; Session : in out ADO.Sessions.Master_Session'Class); overriding function Get_Value (From : in Acl_Ref; Name : in String) return Util.Beans.Objects.Object; -- Table definition ACL_TABLE : constant ADO.Schemas.Class_Mapping_Access; -- Internal method to allocate the Object_Record instance overriding procedure Allocate (Object : in out Acl_Ref); -- Copy of the object. procedure Copy (Object : in Acl_Ref; Into : in out Acl_Ref); -- -------------------- -- The permission table lists all the application permissions that are defined. -- This is a system table shared by every user and workspace. -- The list of permission is fixed and never changes. -- -------------------- -- Create an object key for Permission. function Permission_Key (Id : in ADO.Identifier) return ADO.Objects.Object_Key; -- Create an object key for Permission from a string. -- Raises Constraint_Error if the string cannot be converted into the object key. function Permission_Key (Id : in String) return ADO.Objects.Object_Key; Null_Permission : constant Permission_Ref; function "=" (Left, Right : Permission_Ref'Class) return Boolean; -- Set the permission database identifier. procedure Set_Id (Object : in out Permission_Ref; Value : in ADO.Identifier); -- Get the permission database identifier. function Get_Id (Object : in Permission_Ref) return ADO.Identifier; -- Set the permission name procedure Set_Name (Object : in out Permission_Ref; Value : in Ada.Strings.Unbounded.Unbounded_String); procedure Set_Name (Object : in out Permission_Ref; Value : in String); -- Get the permission name function Get_Name (Object : in Permission_Ref) return Ada.Strings.Unbounded.Unbounded_String; function Get_Name (Object : in Permission_Ref) return String; -- Load the entity identified by 'Id'. -- Raises the NOT_FOUND exception if it does not exist. procedure Load (Object : in out Permission_Ref; Session : in out ADO.Sessions.Session'Class; Id : in ADO.Identifier); -- Load the entity identified by 'Id'. -- Returns True in <b>Found</b> if the object was found and False if it does not exist. procedure Load (Object : in out Permission_Ref; Session : in out ADO.Sessions.Session'Class; Id : in ADO.Identifier; Found : out Boolean); -- Find and load the entity. overriding procedure Find (Object : in out Permission_Ref; Session : in out ADO.Sessions.Session'Class; Query : in ADO.SQL.Query'Class; Found : out Boolean); -- Save the entity. If the entity does not have an identifier, an identifier is allocated -- and it is inserted in the table. Otherwise, only data fields which have been changed -- are updated. overriding procedure Save (Object : in out Permission_Ref; Session : in out ADO.Sessions.Master_Session'Class); -- Delete the entity. overriding procedure Delete (Object : in out Permission_Ref; Session : in out ADO.Sessions.Master_Session'Class); overriding function Get_Value (From : in Permission_Ref; Name : in String) return Util.Beans.Objects.Object; -- Table definition PERMISSION_TABLE : constant ADO.Schemas.Class_Mapping_Access; -- Internal method to allocate the Object_Record instance overriding procedure Allocate (Object : in out Permission_Ref); -- Copy of the object. procedure Copy (Object : in Permission_Ref; Into : in out Permission_Ref); Query_Check_Entity_Permission : constant ADO.Queries.Query_Definition_Access; Query_Remove_Permission : constant ADO.Queries.Query_Definition_Access; Query_Remove_Entity_Permission : constant ADO.Queries.Query_Definition_Access; Query_Remove_User_Permission : constant ADO.Queries.Query_Definition_Access; private ACL_NAME : aliased constant String := "awa_acl"; COL_0_1_NAME : aliased constant String := "id"; COL_1_1_NAME : aliased constant String := "entity_id"; COL_2_1_NAME : aliased constant String := "writeable"; COL_3_1_NAME : aliased constant String := "user_id"; COL_4_1_NAME : aliased constant String := "workspace_id"; COL_5_1_NAME : aliased constant String := "entity_type"; COL_6_1_NAME : aliased constant String := "permission"; ACL_DEF : aliased constant ADO.Schemas.Class_Mapping := (Count => 7, Table => ACL_NAME'Access, Members => ( 1 => COL_0_1_NAME'Access, 2 => COL_1_1_NAME'Access, 3 => COL_2_1_NAME'Access, 4 => COL_3_1_NAME'Access, 5 => COL_4_1_NAME'Access, 6 => COL_5_1_NAME'Access, 7 => COL_6_1_NAME'Access) ); ACL_TABLE : constant ADO.Schemas.Class_Mapping_Access := ACL_DEF'Access; Null_ACL : constant ACL_Ref := ACL_Ref'(ADO.Objects.Object_Ref with null record); type Acl_Impl is new ADO.Objects.Object_Record (Key_Type => ADO.Objects.KEY_INTEGER, Of_Class => ACL_DEF'Access) with record Entity_Id : ADO.Identifier; Writeable : Boolean; User_Id : ADO.Identifier; Workspace_Id : ADO.Identifier; Entity_Type : ADO.Entity_Type; Permission : ADO.Identifier; end record; type Acl_Access is access all Acl_Impl; overriding procedure Destroy (Object : access Acl_Impl); overriding procedure Find (Object : in out Acl_Impl; Session : in out ADO.Sessions.Session'Class; Query : in ADO.SQL.Query'Class; Found : out Boolean); overriding procedure Load (Object : in out Acl_Impl; Session : in out ADO.Sessions.Session'Class); procedure Load (Object : in out Acl_Impl; Stmt : in out ADO.Statements.Query_Statement'Class; Session : in out ADO.Sessions.Session'Class); overriding procedure Save (Object : in out Acl_Impl; Session : in out ADO.Sessions.Master_Session'Class); overriding procedure Create (Object : in out Acl_Impl; Session : in out ADO.Sessions.Master_Session'Class); overriding procedure Delete (Object : in out Acl_Impl; Session : in out ADO.Sessions.Master_Session'Class); procedure Set_Field (Object : in out Acl_Ref'Class; Impl : out Acl_Access); PERMISSION_NAME : aliased constant String := "awa_permission"; COL_0_2_NAME : aliased constant String := "id"; COL_1_2_NAME : aliased constant String := "name"; PERMISSION_DEF : aliased constant ADO.Schemas.Class_Mapping := (Count => 2, Table => PERMISSION_NAME'Access, Members => ( 1 => COL_0_2_NAME'Access, 2 => COL_1_2_NAME'Access) ); PERMISSION_TABLE : constant ADO.Schemas.Class_Mapping_Access := PERMISSION_DEF'Access; Null_Permission : constant Permission_Ref := Permission_Ref'(ADO.Objects.Object_Ref with null record); type Permission_Impl is new ADO.Objects.Object_Record (Key_Type => ADO.Objects.KEY_INTEGER, Of_Class => PERMISSION_DEF'Access) with record Name : Ada.Strings.Unbounded.Unbounded_String; end record; type Permission_Access is access all Permission_Impl; overriding procedure Destroy (Object : access Permission_Impl); overriding procedure Find (Object : in out Permission_Impl; Session : in out ADO.Sessions.Session'Class; Query : in ADO.SQL.Query'Class; Found : out Boolean); overriding procedure Load (Object : in out Permission_Impl; Session : in out ADO.Sessions.Session'Class); procedure Load (Object : in out Permission_Impl; Stmt : in out ADO.Statements.Query_Statement'Class; Session : in out ADO.Sessions.Session'Class); overriding procedure Save (Object : in out Permission_Impl; Session : in out ADO.Sessions.Master_Session'Class); overriding procedure Create (Object : in out Permission_Impl; Session : in out ADO.Sessions.Master_Session'Class); overriding procedure Delete (Object : in out Permission_Impl; Session : in out ADO.Sessions.Master_Session'Class); procedure Set_Field (Object : in out Permission_Ref'Class; Impl : out Permission_Access); package File_1 is new ADO.Queries.Loaders.File (Path => "permissions.xml", Sha1 => "9B2B599473F75F92CB5AB5045675E4CCEF926543"); package Def_Check_Entity_Permission is new ADO.Queries.Loaders.Query (Name => "check-entity-permission", File => File_1.File'Access); Query_Check_Entity_Permission : constant ADO.Queries.Query_Definition_Access := Def_Check_Entity_Permission.Query'Access; package Def_Remove_Permission is new ADO.Queries.Loaders.Query (Name => "remove-permission", File => File_1.File'Access); Query_Remove_Permission : constant ADO.Queries.Query_Definition_Access := Def_Remove_Permission.Query'Access; package Def_Remove_Entity_Permission is new ADO.Queries.Loaders.Query (Name => "remove-entity-permission", File => File_1.File'Access); Query_Remove_Entity_Permission : constant ADO.Queries.Query_Definition_Access := Def_Remove_Entity_Permission.Query'Access; package Def_Remove_User_Permission is new ADO.Queries.Loaders.Query (Name => "remove-user-permission", File => File_1.File'Access); Query_Remove_User_Permission : constant ADO.Queries.Query_Definition_Access := Def_Remove_User_Permission.Query'Access; end AWA.Permissions.Models;
tum-ei-rcs/StratoX
Ada
1,249
adb
package body Generic_Types with SPARK_Mode is ------------------------ -- Saturated_Cast_Int ------------------------ function Saturated_Cast_Int (f : Float) return T is ret : T; ff : constant Float := Float'Floor (f); begin if ff >= Float (T'Last) then ret := T'Last; elsif ff < Float (T'First) then ret := T'First; else ret := T (ff); end if; return ret; end Saturated_Cast_Int; ------------------------ -- Saturated_Cast_Mod ------------------------ function Saturated_Cast_Mod (f : Float) return T is ret : T; ff : constant Float := Float'Floor (f); begin if ff >= Float (T'Last) then ret := T'Last; elsif ff < Float (T'First) then ret := T'First; else ret := T (ff); end if; return ret; end Saturated_Cast_Mod; ------------------ -- Saturate_Mod ------------------ function Saturate_Mod (val : T; min : T; max : T) return T is ret : T; begin if val < min then ret := min; elsif val > max then ret := max; else ret := val; end if; return ret; end Saturate_Mod; end Generic_Types;
reznikmm/matreshka
Ada
3,993
ads
------------------------------------------------------------------------------ -- -- -- Matreshka Project -- -- -- -- Open Document Toolkit -- -- -- -- Runtime Library Component -- -- -- ------------------------------------------------------------------------------ -- -- -- Copyright © 2014, Vadim Godunko <[email protected]> -- -- All rights reserved. -- -- -- -- Redistribution and use in source and binary forms, with or without -- -- modification, are permitted provided that the following conditions -- -- are met: -- -- -- -- * Redistributions of source code must retain the above copyright -- -- notice, this list of conditions and the following disclaimer. -- -- -- -- * Redistributions in binary form must reproduce the above copyright -- -- notice, this list of conditions and the following disclaimer in the -- -- documentation and/or other materials provided with the distribution. -- -- -- -- * Neither the name of the Vadim Godunko, IE nor the names of its -- -- contributors may be used to endorse or promote products derived from -- -- this software without specific prior written permission. -- -- -- -- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -- -- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -- -- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -- -- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -- -- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -- -- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED -- -- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -- -- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -- -- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -- -- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -- -- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- -- -- ------------------------------------------------------------------------------ -- $Revision$ $Date$ ------------------------------------------------------------------------------ with ODF.DOM.Draw_End_Shape_Attributes; package Matreshka.ODF_Draw.End_Shape_Attributes is type Draw_End_Shape_Attribute_Node is new Matreshka.ODF_Draw.Abstract_Draw_Attribute_Node and ODF.DOM.Draw_End_Shape_Attributes.ODF_Draw_End_Shape_Attribute with null record; overriding function Create (Parameters : not null access Matreshka.DOM_Attributes.Attribute_L2_Parameters) return Draw_End_Shape_Attribute_Node; overriding function Get_Local_Name (Self : not null access constant Draw_End_Shape_Attribute_Node) return League.Strings.Universal_String; end Matreshka.ODF_Draw.End_Shape_Attributes;
Rodeo-McCabe/orka
Ada
792
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. package body Orka.OS is procedure Set_Task_Name (Name : in String) is begin null; end Set_Task_Name; end Orka.OS;
sungyeon/drake
Ada
3,475
ads
pragma License (Unrestricted); with Ada.Text_IO.Editing; package Ada.Wide_Wide_Text_IO.Editing is -- modified -- type Picture is private; subtype Picture is Text_IO.Editing.Picture; function Valid ( Pic_String : String; Blank_When_Zero : Boolean := False) return Boolean renames Text_IO.Editing.Valid; function To_Picture ( Pic_String : String; Blank_When_Zero : Boolean := False) return Picture renames Text_IO.Editing.To_Picture; function Pic_String (Pic : Picture) return String renames Text_IO.Editing.Pic_String; function Blank_When_Zero (Pic : Picture) return Boolean renames Text_IO.Editing.Blank_When_Zero; Max_Picture_Length : constant := 30; -- implementation_defined Picture_Error : exception renames Text_IO.Editing.Picture_Error; Default_Currency : constant Wide_Wide_String := "$"; Default_Fill : constant Wide_Wide_Character := '*'; Default_Separator : constant Wide_Wide_Character := ','; Default_Radix_Mark : constant Wide_Wide_Character := '.'; generic type Num is delta <> digits <>; Default_Currency : Wide_Wide_String := Editing.Default_Currency; Default_Fill : Wide_Wide_Character := Editing.Default_Fill; Default_Separator : Wide_Wide_Character := Editing.Default_Separator; Default_Radix_Mark : Wide_Wide_Character := Editing.Default_Radix_Mark; package Decimal_Output is -- for renaming package Strings is new Text_IO.Editing.Decimal_Output (Num); function Length ( Pic : Picture; Currency : Wide_Wide_String := Default_Currency) return Natural renames Strings.Overloaded_Length; function Valid ( Item : Num; Pic : Picture; Currency : Wide_Wide_String := Default_Currency) return Boolean renames Strings.Overloaded_Valid; function Image ( Item : Num; Pic : Picture; Currency : Wide_Wide_String := Default_Currency; Fill : Wide_Wide_Character := Default_Fill; Separator : Wide_Wide_Character := Default_Separator; Radix_Mark : Wide_Wide_Character := Default_Radix_Mark) return Wide_Wide_String renames Strings.Overloaded_Image; procedure Put ( File : File_Type; -- Output_File_Type Item : Num; Pic : Picture; Currency : Wide_Wide_String := Default_Currency; Fill : Wide_Wide_Character := Default_Fill; Separator : Wide_Wide_Character := Default_Separator; Radix_Mark : Wide_Wide_Character := Default_Radix_Mark) renames Strings.Overloaded_Put; procedure Put ( Item : Num; Pic : Picture; Currency : Wide_Wide_String := Default_Currency; Fill : Wide_Wide_Character := Default_Fill; Separator : Wide_Wide_Character := Default_Separator; Radix_Mark : Wide_Wide_Character := Default_Radix_Mark) renames Strings.Overloaded_Put; procedure Put ( To : out Wide_Wide_String; Item : Num; Pic : Picture; Currency : Wide_Wide_String := Default_Currency; Fill : Wide_Wide_Character := Default_Fill; Separator : Wide_Wide_Character := Default_Separator; Radix_Mark : Wide_Wide_Character := Default_Radix_Mark) renames Strings.Overloaded_Put; end Decimal_Output; end Ada.Wide_Wide_Text_IO.Editing;
AdaCore/Ada_Drivers_Library
Ada
5,443
adb
------------------------------------------------------------------------------ -- -- -- Copyright (C) 2016-2020, AdaCore -- -- -- -- Redistribution and use in source and binary forms, with or without -- -- modification, are permitted provided that the following conditions are -- -- met: -- -- 1. Redistributions of source code must retain the above copyright -- -- notice, this list of conditions and the following disclaimer. -- -- 2. Redistributions in binary form must reproduce the above copyright -- -- notice, this list of conditions and the following disclaimer in -- -- the documentation and/or other materials provided with the -- -- distribution. -- -- 3. Neither the name of the copyright holder nor the names of its -- -- contributors may be used to endorse or promote products derived -- -- from this software without specific prior written permission. -- -- -- -- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -- -- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -- -- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -- -- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -- -- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -- -- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -- -- LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -- -- DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -- -- THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -- -- (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -- -- OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- -- -- ------------------------------------------------------------------------------ with nRF.Tasks; with nRF.Events; with nRF.Radio; use nRF.Radio; with nRF.Clock; use nRF.Clock; with Bluetooth_Low_Energy.Packets; use Bluetooth_Low_Energy.Packets; with Bluetooth_Low_Energy; use Bluetooth_Low_Energy; with Bluetooth_Low_Energy.Beacon; use Bluetooth_Low_Energy.Beacon; with HAL; use HAL; package body Beacon is Current_Adv_Channel : BLE_Advertising_Channel_Number := 37; Beacon_Packet : BLE_Packet; ---------------------- -- Initialize_Radio -- ---------------------- procedure Initialize_Radio is Beacon_UUID : constant BLE_UUID := Make_UUID ((1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16)); begin Beacon_Packet := Make_Beacon_Packet (MAC => (16#A1#, 16#AD#, 16#A1#, 16#AD#, 16#A1#, 16#AD#), UUID => Beacon_UUID, Major => 0, Minor => 0, Power => 0); -- Setup high frequency clock for BLE transmission Set_High_Freq_Source (HFCLK_RC); Start_High_Freq; while not High_Freq_Running loop null; end loop; -- Setup radio module for BLE Setup_For_Bluetooth_Low_Energy; -- Set BLE advertising address Set_Logic_Addresses (Base0 => 16#89_BE_D6_00#, Base1 => 16#00_00_00_00#, Base_Length_In_Byte => 3, AP0 => 16#8E#, AP1 => 16#00#, AP2 => 16#00#, AP3 => 16#00#, AP4 => 16#00#, AP5 => 16#00#, AP6 => 16#00#, AP7 => 16#00#); -- Select logic address Set_TX_Address (0); -- Transmission power Set_Power (Zero_Dbm); -- Enable shortcuts for easier radio operation Enable_Shortcut (Ready_To_Start); Enable_Shortcut (End_To_Disable); end Initialize_Radio; ------------------------ -- Send_Beacon_Packet -- ------------------------ procedure Send_Beacon_Packet is begin Configure_Whitening (True, UInt6 (Current_Adv_Channel)); Set_Frequency (Radio_Frequency_MHz (Channel_Frequency (Current_Adv_Channel))); if Current_Adv_Channel /= BLE_Advertising_Channel_Number'Last then Current_Adv_Channel := Current_Adv_Channel + 1; else Current_Adv_Channel := BLE_Advertising_Channel_Number'First; end if; -- Set TX packet address Set_Packet (Memory_Address (Beacon_Packet)); -- Clear all events nRF.Events.Clear (nRF.Events.Radio_DISABLED); nRF.Events.Clear (nRF.Events.Radio_ADDRESS); nRF.Events.Clear (nRF.Events.Radio_PAYLOAD); nRF.Events.Clear (nRF.Events.Radio_END); -- Start transmission nRF.Tasks.Trigger (nRF.Tasks.Radio_TXEN); -- Wait for end of transmission while not nRF.Events.Triggered (nRF.Events.Radio_DISABLED) loop null; end loop; end Send_Beacon_Packet; end Beacon;
righthalfplane/SdrGlut
Ada
4,342
adb
---------------------------------------------------------------- -- ZLib for Ada thick binding. -- -- -- -- Copyright (C) 2002-2003 Dmitriy Anisimkov -- -- -- -- Open source license information is in the zlib.ads file. -- ---------------------------------------------------------------- -- $Id: zlib-thin.adb,v 1.6 2003/01/21 15:26:37 vagul Exp $ package body ZLib.Thin is ZLIB_VERSION : constant Chars_Ptr := Interfaces.C.Strings.New_String ("1.1.4"); Z_Stream_Size : constant Int := Z_Stream'Size / System.Storage_Unit; -------------- -- Avail_In -- -------------- function Avail_In (Strm : in Z_Stream) return UInt is begin return Strm.Avail_In; end Avail_In; --------------- -- Avail_Out -- --------------- function Avail_Out (Strm : in Z_Stream) return UInt is begin return Strm.Avail_Out; end Avail_Out; ------------------ -- Deflate_Init -- ------------------ function Deflate_Init (strm : in Z_Streamp; level : in Int := Z_DEFAULT_COMPRESSION) return Int is begin return deflateInit (strm, level, ZLIB_VERSION, Z_Stream_Size); end Deflate_Init; function Deflate_Init (strm : Z_Streamp; level : Int; method : Int; windowBits : Int; memLevel : Int; strategy : Int) return Int is begin return deflateInit2 (strm, level, method, windowBits, memLevel, strategy, ZLIB_VERSION, Z_Stream_Size); end Deflate_Init; ------------------ -- Inflate_Init -- ------------------ function Inflate_Init (strm : Z_Streamp) return Int is begin return inflateInit (strm, ZLIB_VERSION, Z_Stream_Size); end Inflate_Init; function Inflate_Init (strm : Z_Streamp; windowBits : Int) return Int is begin return inflateInit2 (strm, windowBits, ZLIB_VERSION, Z_Stream_Size); end Inflate_Init; function Last_Error_Message (Strm : in Z_Stream) return String is use Interfaces.C.Strings; begin if Strm.msg = Null_Ptr then return ""; else return Value (Strm.msg); end if; end Last_Error_Message; ------------- -- Need_In -- ------------- function Need_In (strm : Z_Stream) return Boolean is begin return strm.Avail_In = 0; end Need_In; -------------- -- Need_Out -- -------------- function Need_Out (strm : Z_Stream) return Boolean is begin return strm.Avail_Out = 0; end Need_Out; ------------ -- Set_In -- ------------ procedure Set_In (Strm : in out Z_Stream; Buffer : in Byte_Access; Size : in UInt) is begin Strm.Next_In := Buffer; Strm.Avail_In := Size; end Set_In; procedure Set_In (Strm : in out Z_Stream; Buffer : in Voidp; Size : in UInt) is begin Set_In (Strm, Bytes.To_Pointer (Buffer), Size); end Set_In; ------------------ -- Set_Mem_Func -- ------------------ procedure Set_Mem_Func (Strm : in out Z_Stream; Opaque : in Voidp; Alloc : in alloc_func; Free : in free_func) is begin Strm.opaque := Opaque; Strm.zalloc := Alloc; Strm.zfree := Free; end Set_Mem_Func; ------------- -- Set_Out -- ------------- procedure Set_Out (Strm : in out Z_Stream; Buffer : in Byte_Access; Size : in UInt) is begin Strm.Next_Out := Buffer; Strm.Avail_Out := Size; end Set_Out; procedure Set_Out (Strm : in out Z_Stream; Buffer : in Voidp; Size : in UInt) is begin Set_Out (Strm, Bytes.To_Pointer (Buffer), Size); end Set_Out; -------------- -- Total_In -- -------------- function Total_In (Strm : in Z_Stream) return ULong is begin return Strm.Total_In; end Total_In; --------------- -- Total_Out -- --------------- function Total_Out (Strm : in Z_Stream) return ULong is begin return Strm.Total_Out; end Total_Out; end ZLib.Thin;
AdaCore/libadalang
Ada
1,454
adb
with Pkg_G; procedure Test is function Foo return Integer is begin return 42; end Foo; package Base is type T is tagged null record; procedure Bar (Self : T) is null; procedure Baz (Self : access T) is null; end Base; package Derived is type T is new Base.T with null record; overriding procedure Bar (Self : T) is null; end Derived; package Derived_2 is type T is new Derived.T with null record; end Derived_2; package Derived_3 is type T is new Derived_2.T with null record; overriding procedure Bar (Self : T) is null; overriding procedure Baz (Self : access T) is null; end Derived_3; package Pkg_Interface is type I is interface; procedure Bar (X : I) is abstract; end Pkg_Interface; package Derived_4 is type T is new Base.T and Pkg_Interface.I with null record; overriding procedure Bar (X : T) is null; end Derived_4; type F_T is access function return Integer; package Pkg_I is new Pkg_G (F => Foo); My_T : Base.T; X : Integer; Y : Base.T'Class := My_T; Z : F_T := Foo'Access; YY : Derived.T'Class := Derived.T' (null record); ZZ : Pkg_Interface.I'Class := Derived_4.T' (null record); Acc : access Base.T'Class := null; begin X := Foo; X := Z.all; X := Pkg_I.Baz; Y.Bar; Derived.Bar (YY); ZZ.Bar; Acc.Baz; end Test; pragma Find_All_References (Calls);
LionelDraghi/smk
Ada
2,951
ads
-- ----------------------------------------------------------------------------- -- smk, the smart make (http://lionel.draghi.free.fr/smk/) -- © 2018, 2019 Lionel Draghi <[email protected]> -- SPDX-License-Identifier: APSL-2.0 -- ----------------------------------------------------------------------------- -- Licensed under the Apache License, Version 2.0 (the "License"); -- you may not use this file except in compliance with the License. -- You may obtain a copy of the License at -- http://www.apache.org/licenses/LICENSE-2.0 -- Unless required by applicable law or agreed to in writing, software -- distributed under the License is distributed on an "AS IS" BASIS, -- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -- See the License for the specific language governing permissions and -- limitations under the License. -- ----------------------------------------------------------------------------- with Smk.Files; use Smk.Files; private package Smk.Runs.Strace_Analyzer is -- -------------------------------------------------------------------------- type Line_Type is (Read_Call, Write_Call, Read_Write_Call, Exec_Call, Ignored); -- -------------------------------------------------------------------------- type Operation_Kind is (None, Read, Write, Delete, Move); -- -------------------------------------------------------------------------- type Operation_Type (Kind : Operation_Kind := None) is record case Kind is when None => null; when Read | Write | Delete => Name : File_Name; File : File_Type; when Move => Source_Name : File_Name; Source : File_Type; Target_Name : File_Name; Target : File_Type; end case; end record; -- -------------------------------------------------------------------------- procedure Analyze_Line (Line : in String; Operation : out Operation_Type); -- Here is the kind of output from strace that we process here: -- -- 19171 rename("x.mp3", "Luke-Sentinelle.mp3") = 0 -- 4372 openat(AT_FDCWD, "/tmp/ccHKHv8W.s", O_RDWR|O_CREAT ... -- 12345 open("xyzzy", O_WRONLY|O_APPEND|O_CREAT, 0666) = 3 -- 15165 unlinkat(5</home/lionel/.slocdata/top_dir>, "filelist", 0) = 0 -- 15168 openat(AT_FDCWD, "/home/lionel/.sl", O_RDONLY <unfinished ...> -- 15167 <... stat resumed> {st_mode=S_IFREG|0755, st_size=122224, ...}) = 0 -- 15232 renameat2(AT_FDCWD, "all.filect.new", AT_FDCWD, "all.filect"... -- 15214 --- SIGCHLD {si_signo=SIGCHLD, si_code=CLD_EXITED, ... -- 7120 mkdir("dir1", 0777) = 0 end Smk.Runs.Strace_Analyzer;
Fabien-Chouteau/tiled-code-gen
Ada
3,534
ads
------------------------------------------------------------------------------ -- -- -- tiled-code-gen -- -- -- -- Copyright (C) 2018 Fabien Chouteau -- -- -- -- -- -- Redistribution and use in source and binary forms, with or without -- -- modification, are permitted provided that the following conditions are -- -- met: -- -- 1. Redistributions of source code must retain the above copyright -- -- notice, this list of conditions and the following disclaimer. -- -- 2. Redistributions in binary form must reproduce the above copyright -- -- notice, this list of conditions and the following disclaimer in -- -- the documentation and/or other materials provided with the -- -- distribution. -- -- 3. Neither the name of the copyright holder nor the names of its -- -- contributors may be used to endorse or promote products derived -- -- from this software without specific prior written permission. -- -- -- -- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -- -- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -- -- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -- -- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -- -- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -- -- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -- -- LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -- -- DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -- -- THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -- -- (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -- -- OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- -- -- ------------------------------------------------------------------------------ with DOM.Core; use DOM.Core; with Interfaces; use Interfaces; package TCG.Utils is function Item_Exists (N : Node; Item : DOM_String) return Boolean; function Item_As_Natural (N : Node; Item : DOM_String) return Natural; function Item_As_UInt32 (N : Node; Item : DOM_String) return Unsigned_32; function Item_As_String (N : Node; Item : DOM_String) return String; function Item_As_Float (N : Node; Item : DOM_String) return Float; function To_Ada_Identifier (Str : String) return String; function To_Ada_Filename (Str : String; Is_Spec : Boolean := True) return String; function To_Rust_Identifier (Str : String) return String; function To_Rust_Static_Identifier (Str : String) return String; function To_Rust_Filename (Str : String) return String; function Make_Dir (Dirpath : String) return Boolean; end TCG.Utils;
zhmu/ananas
Ada
164
ads
-- { dg-do compile } package Access2 is type Priv; type Inc is access Priv; type Priv is access Inc; C : constant Priv := new Inc; end Access2;
PThierry/ewok-kernel
Ada
1,020
ads
-- -- Copyright 2018 The wookey project team <[email protected]> -- - Ryad Benadjila -- - Arnauld Michelizza -- - Mathieu Renard -- - Philippe Thierry -- - Philippe Trebuchet -- -- Licensed under the Apache License, Version 2.0 (the "License"); -- you may not use this file except in compliance with the License. -- You may obtain a copy of the License at -- -- http://www.apache.org/licenses/LICENSE-2.0 -- -- Unless required by applicable law or agreed to in writing, software -- distributed under the License is distributed on an "AS IS" BASIS, -- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -- See the License for the specific language governing permissions and -- limitations under the License. -- -- package processor with spark_mode => on is procedure processor_init with convention => c, export => true, external_name => "processor_init", global => null, inline; end processor;
reznikmm/matreshka
Ada
23,673
ads
-- Module : string_scanner_.ada -- Component of : common_library -- Version : 1.2 -- Date : 11/21/86 16:37:08 -- SCCS File : disk21~/rschm/hasee/sccs/common_library/sccs/sxstring_scanner_.ada with String_Pkg; use String_Pkg; package String_Scanner is --| Functions for scanning tokens from strings. pragma Page; --| Overview --| This package provides a set of functions used to scan tokens from --| strings. After the function make_Scanner is called to convert a string --| into a string Scanner, the following functions may be called to scan --| various tokens from the string: --|- --| Make_Scanner Given a string returns a Scanner --| Destroy_Scanner Free storage used by Scanner --| More Return TRUE iff unscanned characters remain --| Forward Bump the Scanner --| Backward Bump back the Scanner --| Get Return character --| Next Return character and bump the Scanner --| Get_String Return String_Type in Scanner --| Get_Remainder Return String_Type in Scanner from current Index --| Mark Mark the current Index for Restore --| Restore Restore the previously marked Index --| Position Return the current position of the Scanner --| Is_Word Return TRUE iff Scanner is at a non-blank character --| Scan_Word Return sequence of non blank characters --| Is_Number Return TRUE iff Scanner is at a digit --| Scan_Number (2) Return sequence of decimal digits --| Is_Signed_Number Return TRUE iff Scanner is at a digit or sign --| Scan_Signed_Number (2) --| sequence of decimal digits with optional sign (+/-) --| Is_Space Return TRUE iff Scanner is at a space or tab --| Scan_Space Return sequence of spaces or tabs --| Skip_Space Advance Scanner past white space --| Is_Ada_Id Return TRUE iff Scanner is at first character of ada id --| Scan_Ada_Id Scan an Ada identifier --| Is_Quoted Return TRUE iff Scanner is at a double quote --| Scan_Quoted Scan quoted string, embedded quotes doubled --| Is_Enclosed Return TRUE iff Scanner is at an enclosing character --| Scan_Enclosed Scan enclosed string, embedded enclosing character doubled --| Is_Sequence Return TRUE iff Scanner is at some character in sequence --| Scan_Sequence Scan user specified sequence of chars --| Is_Not_Sequence Return TRUE iff Scanner is not at the characters in sequence --| Scan_Not_Sequence Scan string up to but not including a given sequence of chars --| Is_Literal Return TRUE iff Scanner is at literal --| Scan_Literal Scan user specified literal --| Is_Not_Literal Return TRUE iff Scanner is not a given literal --| Scan_Not_Literal Scan string up to but not including a given literal --|+ ---------------------------------------------------------------- Out_Of_Bounds : exception; --| Raised when a operation is attempted on a --| Scanner that has passed the end Scanner_Already_Marked : exception; --| Raised when a Mark is attemped on a Scanner --| that has already been marked ---------------------------------------------------------------- type Scanner is private; --| Scanner type ---------------------------------------------------------------- pragma Page; function Make_Scanner( --| Construct a Scanner from S. S : in String_Type --| String to be scanned. ) return Scanner; --| Effects: Construct a Scanner from S. --| N/A: Raises, Modifies, Errors ---------------------------------------------------------------- procedure Destroy_Scanner( --| Free Scanner storage T : in out Scanner --| Scanner to be freed ); --| Effects: Free space occupied by the Scanner. --| N/A: Raises, Modifies, Errors ---------------------------------------------------------------- function More( --| Check if Scanner is exhausted T : in Scanner --| Scanner to check ) return boolean; --| Effects: Return TRUE iff additional characters remain to be scanned. --| N/A: Raises, Modifies, Errors ---------------------------------------------------------------- procedure Forward( --| Bump scanner T : in Scanner --| Scanner ); --| Effects: Update the scanner position. --| N/A: Raises, Modifies, Errors ---------------------------------------------------------------- procedure Backward( --| Bump back scanner T : in Scanner --| Scanner ); --| Effects: Update the scanner position. --| N/A: Raises, Modifies, Errors ---------------------------------------------------------------- function Get( --| Return character T : in Scanner --| Scanner to check ) return character; --| Raises: Out_Of_Bounds --| Effects: Return character at the current Scanner position. --| The scanner position remains unchanged. --| N/A: Modifies, Errors ---------------------------------------------------------------- procedure Next( --| Return character and bump scanner T : in Scanner; --| Scanner to check C : out character --| Character to be returned ); --| Raises: Out_Of_Bounds --| Effects: Return character at the current Scanner position and update --| the position. --| N/A: Modifies, Errors ---------------------------------------------------------------- function Position( --| Return current Scanner position T : in Scanner --| Scanner to check ) return positive; --| Raises: Out_Of_Bounds --| Effects: Return a positive integer indicating the current Scanner position, --| N/A: Modifies, Errors ---------------------------------------------------------------- function Get_String( --| Return contents of Scanner T : in Scanner --| Scanner ) return String_Type; --| Effects: Return a String_Type corresponding to the contents of the Scanner --| N/A: Raises, Modifies, Errors ---------------------------------------------------------------- function Get_Remainder( --| Return contents of Scanner from index T : in Scanner ) return String_Type; --| Effects: Return a String_Type starting at the current index of the Scanner --| N/A: Raises, Modifies, Errors ---------------------------------------------------------------- procedure Mark( T : in Scanner ); --| Raises: Scanner_Already_Marked --| Effects: Mark the current index for possible future use --| N/A: Modifies, Errors ---------------------------------------------------------------- procedure Restore( T : in Scanner ); --| Effects: Restore the index to the previously marked value --| N/A: Raises, Modifies, Errors ---------------------------------------------------------------- pragma Page; function Is_Word( --| Check if Scanner is at the start of a word. T : in Scanner --| Scanner to check ) return boolean; --| Effects: Return TRUE iff Scanner is at the start of a word. --| N/A: Raises, Modifies, Errors ---------------------------------------------------------------- procedure Scan_word( --| Scan sequence of non blank characters T : in Scanner; --| String to be scanned Found : out boolean; --| TRUE iff a word found Result : out String_Type;--| Word scanned from string Skip : in boolean := false --| Skip white spaces before scan ); --| Effects: Scan T for a sequence of non blank --| characters. If at least one is found, return Found => TRUE, --| Result => <the characters>. --| Otherwise return Found => FALSE and Result is unpredictable. --| N/A: Raises, Modifies, Errors pragma Page; function Is_Number( --| Return TRUE iff Scanner is at a decimal digit T : in Scanner --| The string being scanned ) return boolean; --| Effects: Return TRUE iff Scan_Number would return a non-null string. --| N/A: Raises, Modifies, Errors ---------------------------------------------------------------- procedure Scan_Number( --| Scan sequence of digits T : in Scanner; --| String to be scanned Found : out boolean; --| TRUE iff one or more digits found Result : out String_Type;--| Number scanned from string Skip : in boolean := false --| Skip white spaces before scan ); --| Effects: Scan T for a sequence of digits. --| If at least one is found, return Found => TRUE, Result => <the digits>. --| Otherwise return Found => FALSE and Result is unpredictable. --| Modifies: Raises, Modifies, Errors ---------------------------------------------------------------- procedure Scan_Number( --| Scan sequence of digits T : in Scanner; --| String to be scanned Found : out boolean; --| TRUE iff one or more digits found Result : out integer; --| Number scanned from string Skip : in boolean := false --| Skip white spaces before scan ); --| Effects: Scan T for a sequence of digits. --| If at least one is found, return Found => TRUE, Result => <the digits>. --| Otherwise return Found => FALSE and Result is unpredictable. --| Modifies: Raises, Modifies, Errors pragma Page; function Is_Signed_Number( --| Check if Scanner is at a decimal digit or --| sign (+/-) T : in Scanner --| The string being scanned ) return boolean; --| Effects: Return TRUE iff Scan_Signed_Number would return a non-null --| string. --| N/A: Raises, Modifies, Errors ---------------------------------------------------------------- procedure Scan_Signed_Number( --| Scan signed sequence of digits T : in Scanner; --| String to be scanned Found : out boolean; --| TRUE iff one or more digits found Result : out String_Type;--| Number scanned from string Skip : in boolean := false --| Skip white spaces before scan ); --| Effects: Scan T for a sequence of digits preceeded with optional sign. --| If at least one digit is found, return Found => TRUE, --| Result => <the digits>. --| Otherwise return Found => FALSE and Result is unpredictable. --| Modifies: Raises, Modifies, Errors ---------------------------------------------------------------- procedure Scan_Signed_Number( --| Scan signed sequence of digits T : in Scanner; --| String to be scanned Found : out boolean; --| TRUE iff one or more digits found Result : out integer; --| Number scanned from string Skip : in boolean := false --| Skip white spaces before scan ); --| Effects: Scan T for a sequence of digits preceeded with optional sign. --| If at least one digit is found, return Found => TRUE, --| Result => <the digits>. --| Otherwise return Found => FALSE and Result is unpredictable. --| Modifies: Raises, Modifies, Errors pragma Page; function Is_Space( --| Check if T is at a space or tab T : in Scanner --| The string being scanned ) return boolean; --| Effects: Return TRUE iff Scan_Space would return a non-null string. --| Modifies: Raises, Modifies, Errors ---------------------------------------------------------------- procedure Scan_Space( --| Scan sequence of white space characters T : in Scanner; --| String to be scanned Found : out boolean; --| TRUE iff space found Result : out String_Type --| Spaces scanned from string ); --| Effects: Scan T past all white space (spaces --| and tabs. If at least one is found, return Found => TRUE, --| Result => <the characters>. --| Otherwise return Found => FALSE and Result is unpredictable. --| Modifies: Raises, Modifies, Errors ---------------------------------------------------------------- procedure Skip_Space( --| Skip white space T : in Scanner --| String to be scanned ); --| Effects: Scan T past all white space (spaces and tabs). --| Modifies: Raises, Modifies, Errors pragma Page; function Is_Ada_Id( --| Check if T is at an Ada identifier T : in Scanner --| The string being scanned ) return boolean; --| Effects: Return TRUE iff Scan_Ada_Id would return a non-null string. --| Modifies: Raises, Modifies, Errors ---------------------------------------------------------------- procedure Scan_Ada_Id( --| Scan Ada identifier T : in Scanner; --| String to be scanned Found : out boolean; --| TRUE iff an Ada identifier found Result : out String_Type;--| Identifier scanned from string Skip : in boolean := false --| Skip white spaces before scan ); --| Effects: Scan T for a valid Ada identifier. --| If one is found, return Found => TRUE, Result => <the characters>. --| Otherwise return Found => FALSE and Result is unpredictable. --| Modifies: Raises, Modifies, Errors pragma Page; function Is_Quoted( --| Check if T is at a double quote T : in Scanner --| The string being scanned ) return boolean; --| Effects: Return TRUE iff T is at a quoted string (eg. ... "Hello" ...). --| Modifies: Raises, Modifies, Errors ---------------------------------------------------------------- procedure Scan_Quoted( --| Scan a quoted string T : in Scanner; --| String to be scanned Found : out boolean; --| TRUE iff a quoted string found Result : out String_Type;--| Quoted string scanned from string Skip : in boolean := false --| Skip white spaces before scan ); --| Effects: Scan at T for an opening quote --| followed by a sequence of characters and ending with a closing --| quote. If successful, return Found => TRUE, Result => <the characters>. --| Otherwise return Found => FALSE and Result is unpredictable. --| A pair of quotes within the quoted string is converted to a single quote. --| The outer quotes are stripped. --| Modifies: Raises, Modifies, Errors pragma Page; function Is_Enclosed( --| Check if T is at an enclosing character B : in character; --| Enclosing open character E : in character; --| Enclosing close character T : in Scanner --| The string being scanned ) return boolean; --| Effects: Return TRUE iff T as encosed by B and E (eg. ... [ABC] ...). --| Modifies: Raises, Modifies, Errors ---------------------------------------------------------------- procedure Scan_Enclosed( --| Scan an enclosed string B : in character; --| Enclosing open character E : in character; --| Enclosing close character T : in Scanner; --| String to be scanned Found : out boolean; --| TRUE iff a quoted string found Result : out String_Type;--| Quoted string scanned from string Skip : in boolean := false --| Skip white spaces before scan ); --| Effects: Scan at T for an enclosing character --| followed by a sequence of characters and ending with an enclosing character. --| If successful, return Found => TRUE, Result => <the characters>. --| Otherwise return Found => FALSE and Result is unpredictable. --| The enclosing characters are stripped. --| Modifies: Raises, Modifies, Errors pragma Page; function Is_Sequence( --| Check if T is at some sequence characters Chars : in String_Type; --| Characters to be scanned T : in Scanner --| The string being scanned ) return boolean; --| Effects: Return TRUE iff T is at some character of Chars. --| Modifies: Raises, Modifies, Errors ---------------------------------------------------------------- function Is_Sequence( --| Check if T is at some sequence characters Chars : in string; --| Characters to be scanned T : in Scanner --| The string being scanned ) return boolean; --| Effects: Return TRUE iff T is at some character of Chars. --| Modifies: Raises, Modifies, Errors ---------------------------------------------------------------- procedure Scan_Sequence( --| Scan arbitrary sequence of characters Chars : in String_Type;--| Characters that should be scanned T : in Scanner; --| String to be scanned Found : out boolean; --| TRUE iff a sequence found Result : out String_Type;--| Sequence scanned from string Skip : in boolean := false --| Skip white spaces before scan ); --| Effects: Scan T for a sequence of characters C such that C appears in --| Char. If at least one is found, return Found => TRUE, --| Result => <the characters>. --| Otherwise return Found => FALSE and Result is unpredictable. --| Modifies: Raises, Modifies, Errors --| Notes: --| Scan_Sequence("0123456789", S, Index, Found, Result) --| is equivalent to Scan_Number(S, Index, Found, Result) --| but is less efficient. ---------------------------------------------------------------- procedure Scan_Sequence( --| Scan arbitrary sequence of characters Chars : in string; --| Characters that should be scanned T : in Scanner; --| String to be scanned Found : out boolean; --| TRUE iff a sequence found Result : out String_Type;--| Sequence scanned from string Skip : in boolean := false --| Skip white spaces before scan ); --| Effects: Scan T for a sequence of characters C such that C appears in --| Char. If at least one is found, return Found => TRUE, --| Result => <the characters>. --| Otherwise return Found => FALSE and Result is unpredictable. --| Modifies: Raises, Modifies, Errors --| Notes: --| Scan_Sequence("0123456789", S, Index, Found, Result) --| is equivalent to Scan_Number(S, Index, Found, Result) --| but is less efficient. pragma Page; function Is_Not_Sequence( --| Check if T is not at some seuqnce of character Chars : in String_Type; --| Characters to be scanned T : in Scanner --| The string being scanned ) return boolean; --| Effects: Return TRUE iff T is not at some character of Chars. --| Modifies: Raises, Modifies, Errors ---------------------------------------------------------------- function Is_Not_Sequence( --| Check if T is at some sequence of characters Chars : in string; --| Characters to be scanned T : in Scanner --| The string being scanned ) return boolean; --| Effects: Return TRUE iff T is not at some character of Chars. --| Modifies: Raises, Modifies, Errors ---------------------------------------------------------------- procedure Scan_Not_Sequence( --| Scan arbitrary sequence of characters Chars : in String_Type;--| Characters that should be scanned T : in Scanner; --| String to be scanned Found : out boolean; --| TRUE iff a sequence found Result : out String_Type;--| Sequence scanned from string Skip : in boolean := false --| Skip white spaces before scan ); --| Effects: Scan T for a sequence of characters C such that C does not appear --| in Chars. If at least one such C is found, return Found => TRUE, --| Result => <the characters>. --| Otherwise return Found => FALSE and Result is unpredictable. --| Modifies: Raises, Modifies, Errors ---------------------------------------------------------------- procedure Scan_Not_Sequence( --| Scan arbitrary sequence of characters Chars : in string; --| Characters that should be scanned T : in Scanner; --| String to be scanned Found : out boolean; --| TRUE iff a sequence found Result : out String_Type;--| Sequence scanned from string Skip : in boolean := false --| Skip white spaces before scan ); --| Effects: Scan T for a sequence of characters C such that C does not appear --| in Chars. If at least one such C is found, return Found => TRUE, --| Result => <the characters>. --| Otherwise return Found => FALSE and Result is unpredictable. --| Modifies: Raises, Modifies, Errors pragma Page; function Is_Literal( --| Check if T is at literal Chars Chars : in String_Type; --| Characters to be scanned T : in Scanner --| The string being scanned ) return boolean; --| Effects: Return TRUE iff T is at literal Chars. --| Modifies: Raises, Modifies, Errors ---------------------------------------------------------------- function Is_Literal( --| Check if T is at literal Chars Chars : in string; --| Characters to be scanned T : in Scanner --| The string being scanned ) return boolean; --| Effects: Return TRUE iff T is at literal Chars. --| Modifies: Raises, Modifies, Errors ---------------------------------------------------------------- procedure Scan_Literal( --| Scan arbitrary literal Chars : in String_Type;--| Literal that should be scanned T : in Scanner; --| String to be scanned Found : out boolean; --| TRUE iff a sequence found Skip : in boolean := false --| Skip white spaces before scan ); --| Effects: Scan T for a litral Chars such that Char matches the sequence --| of characters in T. If found, return Found => TRUE, --| Otherwise return Found => FALSE --| Modifies: Raises, Modifies, Errors ---------------------------------------------------------------- procedure Scan_Literal( --| Scan arbitrary literal Chars : in string; --| Literal that should be scanned T : in Scanner; --| String to be scanned Found : out boolean; --| TRUE iff a sequence found Skip : in boolean := false --| Skip white spaces before scan ); --| Effects: Scan T for a litral Chars such that Char matches the sequence --| of characters in T. If found, return Found => TRUE, --| Otherwise return Found => FALSE --| Modifies: Raises, Modifies, Errors pragma Page; function Is_Not_Literal( --| Check if T is not at literal Chars Chars : in string; --| Characters to be scanned T : in Scanner --| The string being scanned ) return boolean; --| Effects: Return TRUE iff T is not at literal Chars --| Modifies: Raises, Modifies, Errors ---------------------------------------------------------------- function Is_Not_Literal( --| Check if T is not at literal Chars Chars : in String_Type; --| Characters to be scanned T : in Scanner --| The string being scanned ) return boolean; --| Effects: Return TRUE iff T is not at literal Chars --| Modifies: Raises, Modifies, Errors ---------------------------------------------------------------- procedure Scan_Not_Literal( --| Scan arbitrary literal Chars : in string; --| Literal that should be scanned T : in Scanner; --| String to be scanned Found : out boolean; --| TRUE iff a sequence found Result : out String_Type;--| String up to literal Skip : in boolean := false --| Skip white spaces before scan ); --| Effects: Scan T for a litral Chars such that Char does not match the --| sequence of characters in T. If found, return Found => TRUE, --| Otherwise return Found => FALSE --| Modifies: Raises, Modifies, Errors ---------------------------------------------------------------- procedure Scan_Not_Literal( --| Scan arbitrary literal Chars : in String_Type;--| Literal that should be scanned T : in Scanner; --| String to be scanned Found : out boolean; --| TRUE iff a sequence found Result : out String_Type;--| String up to literal Skip : in boolean := false --| Skip white spaces before scan ); --| Effects: Scan T for a litral Chars such that Char does not match the --| sequence of characters in T. If found, return Found => TRUE, --| Otherwise return Found => FALSE --| Modifies: Raises, Modifies, Errors pragma Page; private pragma List(off); type Scan_Record is record text : String_Type; --| Copy of string being scanned index : positive := 1; --| Current position of Scanner mark : natural := 0; --| Mark end record; type Scanner is access Scan_Record; pragma List(on); end String_Scanner; pragma Page;
AdaCore/training_material
Ada
887
ads
pragma Ada_2005; pragma Style_Checks (Off); with Interfaces.C; use Interfaces.C; package umingw_off_t_h is subtype u_off_t is long; -- c:\home\ochem\install\bin\../lib/gcc/i686-pc-mingw32/4.7.3/../../../../i686-pc-mingw32/include/_mingw_off_t.h:5 subtype off32_t is long; -- c:\home\ochem\install\bin\../lib/gcc/i686-pc-mingw32/4.7.3/../../../../i686-pc-mingw32/include/_mingw_off_t.h:7 subtype u_off64_t is Long_Long_Integer; -- c:\home\ochem\install\bin\../lib/gcc/i686-pc-mingw32/4.7.3/../../../../i686-pc-mingw32/include/_mingw_off_t.h:13 subtype off64_t is Long_Long_Integer; -- c:\home\ochem\install\bin\../lib/gcc/i686-pc-mingw32/4.7.3/../../../../i686-pc-mingw32/include/_mingw_off_t.h:15 subtype off_t is off32_t; -- c:\home\ochem\install\bin\../lib/gcc/i686-pc-mingw32/4.7.3/../../../../i686-pc-mingw32/include/_mingw_off_t.h:26 end umingw_off_t_h;
faelys/natools
Ada
4,008
ads
-- Generated at 2014-10-01 17:18:35 +0000 by Natools.Static_Hash_Maps -- from src/natools-s_expressions-templates-generic_integers-maps.sx package Natools.Static_Maps.S_Expressions.Templates.Integers is pragma Pure; type Main_Command is (Error, Align, Align_Center, Align_Left, Align_Right, Base, Image_Range, Images, Padding, Padding_Left, Padding_Right, Prefix, Sign, Suffix, Width, Width_Max, Width_Min); type Align_Command is (Unknown_Align, Set_Left, Set_Center, Set_Right); function Main (Key : String) return Main_Command; function To_Align_Command (Key : String) return Align_Command; private Map_1_Key_0 : aliased constant String := "align"; Map_1_Key_1 : aliased constant String := "align-center"; Map_1_Key_2 : aliased constant String := "centered"; Map_1_Key_3 : aliased constant String := "align-left"; Map_1_Key_4 : aliased constant String := "left-align"; Map_1_Key_5 : aliased constant String := "align-right"; Map_1_Key_6 : aliased constant String := "right-align"; Map_1_Key_7 : aliased constant String := "base"; Map_1_Key_8 : aliased constant String := "image-range"; Map_1_Key_9 : aliased constant String := "image"; Map_1_Key_10 : aliased constant String := "images"; Map_1_Key_11 : aliased constant String := "padding"; Map_1_Key_12 : aliased constant String := "padding-left"; Map_1_Key_13 : aliased constant String := "left-padding"; Map_1_Key_14 : aliased constant String := "padding-right"; Map_1_Key_15 : aliased constant String := "right-padding"; Map_1_Key_16 : aliased constant String := "prefix"; Map_1_Key_17 : aliased constant String := "sign"; Map_1_Key_18 : aliased constant String := "signs"; Map_1_Key_19 : aliased constant String := "suffix"; Map_1_Key_20 : aliased constant String := "width"; Map_1_Key_21 : aliased constant String := "width-max"; Map_1_Key_22 : aliased constant String := "max-width"; Map_1_Key_23 : aliased constant String := "width-min"; Map_1_Key_24 : aliased constant String := "min-width"; Map_1_Keys : constant array (0 .. 24) of access constant String := (Map_1_Key_0'Access, Map_1_Key_1'Access, Map_1_Key_2'Access, Map_1_Key_3'Access, Map_1_Key_4'Access, Map_1_Key_5'Access, Map_1_Key_6'Access, Map_1_Key_7'Access, Map_1_Key_8'Access, Map_1_Key_9'Access, Map_1_Key_10'Access, Map_1_Key_11'Access, Map_1_Key_12'Access, Map_1_Key_13'Access, Map_1_Key_14'Access, Map_1_Key_15'Access, Map_1_Key_16'Access, Map_1_Key_17'Access, Map_1_Key_18'Access, Map_1_Key_19'Access, Map_1_Key_20'Access, Map_1_Key_21'Access, Map_1_Key_22'Access, Map_1_Key_23'Access, Map_1_Key_24'Access); Map_1_Elements : constant array (0 .. 24) of Main_Command := (Align, Align_Center, Align_Center, Align_Left, Align_Left, Align_Right, Align_Right, Base, Image_Range, Images, Images, Padding, Padding_Left, Padding_Left, Padding_Right, Padding_Right, Prefix, Sign, Sign, Suffix, Width, Width_Max, Width_Max, Width_Min, Width_Min); Map_2_Key_0 : aliased constant String := "left"; Map_2_Key_1 : aliased constant String := "center"; Map_2_Key_2 : aliased constant String := "right"; Map_2_Keys : constant array (0 .. 2) of access constant String := (Map_2_Key_0'Access, Map_2_Key_1'Access, Map_2_Key_2'Access); Map_2_Elements : constant array (0 .. 2) of Align_Command := (Set_Left, Set_Center, Set_Right); end Natools.Static_Maps.S_Expressions.Templates.Integers;
pchapin/augusta
Ada
316
adb
procedure Hello is type T is range 1 .. 10; A : T; -- A is an integer. procedure P1 is subtype Index_Type is Integer range 1 .. 5; type T is array(Index_Type) of Integer; B : T; -- B is an array. begin A := B; -- Type error. Can't put an array into an integer. end; begin null; end;
reznikmm/gela
Ada
18,619
adb
-- G E L A G R A M M A R S -- -- Library for dealing with grammars for Gela project, -- -- a portable Ada compiler -- -- http://gela.ada-ru.org/ -- -- - - - - - - - - - - - - - - - -- -- Read copyright and license in gela.ads file -- ------------------------------------------------------------------------------ with Ada.Command_Line; with Ada.Text_IO; with Anagram.Grammars; with Anagram.Grammars.Reader; with Anagram.Grammars_Convertors; with Anagram.Grammars.Rule_Templates; with Anagram.Grammars_Debug; with Anagram.Grammars.LR_Tables; with Anagram.Grammars.LR.LALR; with Anagram.Grammars.Constructors; with Anagram.Grammars.Conflicts; with AG_Tools.Writers; use AG_Tools.Writers; with League.String_Vectors; with League.Strings; procedure YACC_Driver is use type Anagram.Grammars.Rule_Count; use type Anagram.Grammars.LR.State_Count; procedure Put_Proc_Decl (Output : in out Writer; Suffix : Wide_Wide_String); procedure Put_Piece (Piece : in out Writer; From : Anagram.Grammars.Production_Index; To : Anagram.Grammars.Production_Index); procedure Put_Rule (Output : in out Writer; Prod : Anagram.Grammars.Production; Rule : Anagram.Grammars.Rule); function Image (X : Integer) return Wide_Wide_String; procedure Print_Go_To; procedure Print_Action; File : constant String := Ada.Command_Line.Argument (1); G : constant Anagram.Grammars.Grammar := Anagram.Grammars.Reader.Read (File); Plain : constant Anagram.Grammars.Grammar := Anagram.Grammars_Convertors.Convert (G, Left => False); AG : constant Anagram.Grammars.Grammar := Anagram.Grammars.Constructors.To_Augmented (Plain); Table : constant Anagram.Grammars.LR_Tables.Table_Access := Anagram.Grammars.LR.LALR.Build (Input => AG, Right_Nulled => False); Resolver : Anagram.Grammars.Conflicts.Resolver; Output : Writer; ----------- -- Image -- ----------- function Image (X : Integer) return Wide_Wide_String is Img : constant Wide_Wide_String := Integer'Wide_Wide_Image (X); begin return Img (2 .. Img'Last); end Image; ------------------ -- Print_Action -- ------------------ procedure Print_Action is use type Anagram.Grammars.Production_Count; use type Anagram.Grammars.Part_Count; type Action_Code is mod 2 ** 16; Count : Natural; Code : Action_Code; begin Output.P (" type Action_Code is mod 2 ** 16;"); Output.P (" for Action_Code'Size use 16;"); Output.P; Output.P (" Action_Table : constant array"); Output.N (" (State_Index range 1 .. "); Output.N (Natural (Anagram.Grammars.LR_Tables.Last_State (Table.all))); Output.P (","); Output.N (" Anagram.Grammars.Terminal_Count range 0 .. "); Output.N (Natural (Plain.Last_Terminal)); Output.P (") of Action_Code :="); for State in 1 .. Anagram.Grammars.LR_Tables.Last_State (Table.all) loop if State = 1 then Output.N (" ("); else Output.P (","); Output.N (" "); end if; Output.N (Natural (State)); Output.P (" =>"); Output.N (" ("); Count := 0; for T in 0 .. Plain.Last_Terminal loop declare use Anagram.Grammars.LR_Tables; S : constant Anagram.Grammars.LR.State_Count := Shift (Table.all, State, T); R : constant Reduce_Iterator := Reduce (Table.all, State, T); begin if S /= 0 then Code := Action_Code (S) + 16#80_00#; elsif not Is_Empty (R) then Code := Action_Code (Production (R)); else Code := 0; end if; if Code /= 0 then Output.N (Natural (T)); Output.N (" => "); Output.N (Natural (Code)); Count := Count + 1; if Count < 4 then Output.N (", "); else Count := 0; Output.P (","); Output.N (" "); end if; end if; end; end loop; Output.N ("others => 0)"); end loop; Output.P (");"); Output.P; Output.P (" type Production_Record is record"); Output.P (" NT : Anagram.Grammars.Non_Terminal_Index;"); Output.P (" Parts : Natural;"); Output.P (" end record;"); Output.P; Output.N (" Prods : constant array (Action_Code range 1 .. "); Output.N (Natural (Plain.Last_Production)); Output.P (") of"); Output.P (" Production_Record :="); Count := 0; for J in 1 .. Plain.Last_Production loop if J = 1 then Output.N (" ("); elsif Count > 5 then Count := 0; Output.P (","); Output.N (" "); else Output.N (", "); end if; Output.N ("("); Output.N (Natural (Plain.Production (J).Parent)); Output.N (", "); Output.N (Natural (Plain.Production (J).Last - Plain.Production (J).First + 1)); Output.N (")"); Count := Count + 1; end loop; Output.P (");"); Output.P; Output.P (" procedure Next_Action"); Output.P (" (State : Anagram.Grammars.LR_Parsers.State_Index;"); Output.P (" Token : Anagram.Grammars.Terminal_Count;"); Output.P (" Value : out Anagram.Grammars.LR_Parsers.Action)"); Output.P (" is"); Output.P (" Code : constant Action_Code := " & "Action_Table (State, Token);"); Output.P (" begin"); Output.P (" if (Code and 16#80_00#) /= 0 then"); Output.P (" Value := (Kind => Shift, " & "State => State_Index (Code and 16#7F_FF#));"); Output.P (" elsif Code /= 0 then"); Output.P (" Value := (Kind => Reduce,"); Output.P (" Prod => " & "Anagram.Grammars.Production_Index (Code),"); Output.P (" NT => Prods (Code).NT,"); Output.P (" Parts => Prods (Code).Parts);"); for State in 1 .. Anagram.Grammars.LR_Tables.Last_State (Table.all) loop if Anagram.Grammars.LR_Tables.Finish (Table.all, State) then Output.N (" elsif State = "); Output.N (Natural (State)); Output.P (" then"); Output.P (" Value := (Kind => Finish);"); end if; end loop; Output.P (" else"); Output.P (" Value := (Kind => Error);"); Output.P (" end if;"); Output.P (" end Next_Action;"); Output.P; end Print_Action; ----------------- -- Print_Go_To -- ----------------- procedure Print_Go_To is Count : Natural; begin Output.P (" Go_To_Table : constant array"); Output.N (" (Anagram.Grammars.LR_Parsers.State_Index range 1 .. "); Output.N (Natural (Anagram.Grammars.LR_Tables.Last_State (Table.all))); Output.P (","); Output.N (" Anagram.Grammars.Non_Terminal_Index range 1 .. "); Output.N (Natural (Plain.Last_Non_Terminal)); Output.P (") of State_Index :="); for State in 1 .. Anagram.Grammars.LR_Tables.Last_State (Table.all) loop if State = 1 then Output.N (" ("); else Output.P (","); Output.N (" "); end if; Output.N (Natural (State)); Output.P (" =>"); Output.N (" ("); Count := 0; for NT in 1 .. Plain.Last_Non_Terminal loop declare use Anagram.Grammars.LR; Next : constant State_Count := Anagram.Grammars.LR_Tables.Shift (Table.all, State, NT); begin if Next /= 0 then Output.N (Natural (NT)); Output.N (" => "); Output.N (Natural (Next)); Count := Count + 1; if Count < 4 then Output.N (", "); else Count := 0; Output.P (","); Output.N (" "); end if; end if; end; end loop; Output.N ("others => 0)"); end loop; Output.P (");"); Output.P; Output.P (" function Go_To"); Output.P (" (State : Anagram.Grammars.LR_Parsers.State_Index;"); Output.P (" NT : Anagram.Grammars.Non_Terminal_Index)"); Output.P (" return Anagram.Grammars.LR_Parsers.State_Index"); Output.P (" is"); Output.P (" begin"); Output.P (" return Go_To_Table (State, NT);"); Output.P (" end Go_To;"); Output.P; end Print_Go_To; -------------- -- Put_Rule -- -------------- procedure Put_Rule (Output : in out Writer; Prod : Anagram.Grammars.Production; Rule : Anagram.Grammars.Rule) is use Anagram.Grammars.Rule_Templates; use type League.Strings.Universal_String; Template : constant Rule_Template := Create (Rule.Text); Args : League.String_Vectors.Universal_String_Vector; Value : League.Strings.Universal_String; begin for J in 1 .. Template.Count loop Value.Clear; if Plain.Non_Terminal (Prod.Parent).Name = Template.Part_Name (J) then Value.Append ("Nodes (1)"); else declare Index : Positive := 1; begin for Part of Plain.Part (Prod.First .. Prod.Last) loop if Part.Name = Template.Part_Name (J) then Value.Append ("Nodes ("); Value.Append (Image (Index)); Value.Append (")"); end if; Index := Index + 1; end loop; if Value.Is_Empty then if Template.Has_Default (J) then Value := Template.Default (J); else Ada.Text_IO.Put_Line ("Wrong part " & Template.Part_Name (J).To_UTF_8_String & " in rule for production " & Plain.Non_Terminal (Prod.Parent).Name.To_UTF_8_String & "." & Prod.Name.To_UTF_8_String); Ada.Text_IO.Put_Line (Rule.Text.To_UTF_8_String); raise Constraint_Error; end if; end if; end; end if; Args.Append (Value); end loop; Output.P (Template.Substitute (Args)); end Put_Rule; procedure Put_Proc_Decl (Output : in out Writer; Suffix : Wide_Wide_String) is begin Output.N ("procedure Gela.LARL_Parsers.On_Reduce"); Output.P (Suffix); Output.P (" (Self : access Parser_Context;"); Output.P (" Prod : Anagram.Grammars.Production_Index;"); Output.N (" Nodes : in out " & "Gela.LARL_Parsers_Nodes.Node_Array)"); end Put_Proc_Decl; procedure Put_Piece (Piece : in out Writer; From : Anagram.Grammars.Production_Index; To : Anagram.Grammars.Production_Index) is Suffix : Wide_Wide_String := Anagram.Grammars.Production_Index'Wide_Wide_Image (From); begin Suffix (1) := '_'; Piece.P ("with Anagram.Grammars;"); Piece.P ("with Gela.LARL_Parsers_Nodes;"); Piece.N ("private "); Put_Proc_Decl (Piece, Suffix); Piece.P (";"); Piece.N ("pragma Preelaborate (Gela.LARL_Parsers.On_Reduce"); Piece.N (Suffix); Piece.P (");"); Piece.P; Piece.P ("pragma Warnings (""U"");"); Piece.P ("with Gela.Elements.Aspect_Specifications;"); Piece.P ("with Gela.Elements.Associations;"); Piece.P ("with Gela.Elements.Basic_Declarative_Items;"); Piece.P ("with Gela.Elements.Case_Expression_Paths;"); Piece.P ("with Gela.Elements.Case_Paths;"); Piece.P ("with Gela.Elements.Clause_Or_Pragmas;"); Piece.P ("with Gela.Elements.Compilation_Units;"); Piece.P ("with Gela.Elements.Component_Items;"); Piece.P ("with Gela.Elements.Context_Items;"); Piece.P ("with Gela.Elements.Declarative_Items;"); Piece.P ("with Gela.Elements.Defining_Identifiers;"); Piece.P ("with Gela.Elements.Discrete_Choices;"); Piece.P ("with Gela.Elements.Discrete_Subtype_Definitions;"); Piece.P ("with Gela.Elements.Discriminant_Specifications;"); Piece.P ("with Gela.Elements.Enumeration_Literal_Specifications;"); Piece.P ("with Gela.Elements.Exception_Choices;"); Piece.P ("with Gela.Elements.Exception_Handlers;"); Piece.P ("with Gela.Elements.Generic_Associations;"); Piece.P ("with Gela.Elements.Generic_Formals;"); Piece.P ("with Gela.Elements.If_Else_Expression_Paths;"); Piece.P ("with Gela.Elements.If_Elsif_Else_Paths;"); Piece.P ("with Gela.Elements.Membership_Choices;"); Piece.P ("with Gela.Elements.Names;"); Piece.P ("with Gela.Elements.Parameter_Specifications;"); Piece.P ("with Gela.Elements.Pragma_Argument_Associations;"); Piece.P ("with Gela.Elements.Program_Unit_Names;"); Piece.P ("with Gela.Elements.Protected_Element_Declarations;"); Piece.P ("with Gela.Elements.Protected_Operation_Declarations;"); Piece.P ("with Gela.Elements.Protected_Operation_Items;"); Piece.P ("with Gela.Elements.Select_Or_Else_Paths;"); Piece.P ("with Gela.Elements.Select_Then_Abort_Paths;"); Piece.P ("with Gela.Elements.Statements;"); Piece.P ("with Gela.Elements.Subtype_Marks;"); Piece.P ("with Gela.Elements.Task_Items;"); Piece.P ("with Gela.Elements.Variants;"); Piece.P ("with Gela.LARL_Parsers_Nodes;"); Piece.P ("use Gela.LARL_Parsers_Nodes;"); Piece.P ("pragma Style_Checks (""N"");"); Put_Proc_Decl (Piece, Suffix); Piece.P (" is"); Piece.P ("begin"); Piece.P (" case Prod is"); for Prod of Plain.Production (From .. To) loop Piece.N (" when"); Piece.N (Anagram.Grammars.Production_Index'Wide_Wide_Image (Prod.Index)); Piece.P (" =>"); for Rule of Plain.Rule (Prod.First_Rule .. Prod.Last_Rule) loop Put_Rule (Piece, Prod, Rule); end loop; if Prod.First_Rule > Prod.Last_Rule then Piece.P (" null;"); end if; end loop; Piece.P (" when others =>"); Piece.P (" raise Constraint_Error;"); Piece.P (" end case;"); Piece.N ("end Gela.LARL_Parsers.On_Reduce"); Piece.N (Suffix); Piece.P (";"); end Put_Piece; use type Anagram.Grammars.Production_Count; Piece_Length : constant Anagram.Grammars.Production_Count := 500; Piece : Writer; begin Resolver.Resolve (AG, Table.all); Output.P ("with Anagram.Grammars;"); Output.P ("with Anagram.Grammars.LR_Parsers;"); Output.P; Output.P ("package Gela.LARL_Parsers.Data is"); Output.P (" pragma Preelaborate;"); Output.P; Output.P (" procedure Next_Action"); Output.P (" (State : Anagram.Grammars.LR_Parsers.State_Index;"); Output.P (" Token : Anagram.Grammars.Terminal_Count;"); Output.P (" Value : out Anagram.Grammars.LR_Parsers.Action);"); Output.P; Output.P (" function Go_To"); Output.P (" (State : Anagram.Grammars.LR_Parsers.State_Index;"); Output.P (" NT : Anagram.Grammars.Non_Terminal_Index)"); Output.P (" return Anagram.Grammars.LR_Parsers.State_Index;"); Output.P; Output.P ("end Gela.LARL_Parsers.Data;"); Output.P; Output.P ("package body Gela.LARL_Parsers.Data is"); Output.P (" use Anagram.Grammars.LR_Parsers;"); Output.P; Print_Go_To; Print_Action; Output.P ("end Gela.LARL_Parsers.Data;"); Output.P; Output.P ("with Anagram.Grammars;"); Output.P ("with Gela.LARL_Parsers_Nodes;"); Output.N ("private "); Put_Proc_Decl (Output, ""); Output.P (";"); Output.P ("pragma Preelaborate (Gela.LARL_Parsers.On_Reduce);"); Output.P; for Piece_Index in 0 .. (Plain.Last_Production - 1) / Piece_Length loop declare From : constant Anagram.Grammars.Production_Index := Piece_Index * Piece_Length + 1; begin Output.N ("with Gela.LARL_Parsers.On_Reduce_"); Output.N (Natural (From)); Output.P (";"); end; end loop; Put_Proc_Decl (Output, ""); Output.P (" is"); Output.P ("begin"); Output.P (" case Prod is"); for Piece_Index in 0 .. (Plain.Last_Production - 1) / Piece_Length loop declare From : constant Anagram.Grammars.Production_Index := Piece_Index * Piece_Length + 1; To : constant Anagram.Grammars.Production_Index := Anagram.Grammars.Production_Index'Min (Plain.Last_Production, (Piece_Index + 1) * Piece_Length); begin Output.N (" when "); Output.N (Natural (From)); Output.N (" .. "); Output.N (Natural (To)); Output.P (" =>"); Output.N (" On_Reduce_"); Output.N (Natural (From)); Output.P (" (Self, Prod, Nodes);"); Put_Piece (Piece => Piece, From => From, To => To); end; end loop; Output.P (" when others =>"); Output.P (" raise Constraint_Error;"); Output.P (" end case;"); Output.P ("end Gela.LARL_Parsers.On_Reduce;"); Ada.Text_IO.Put_Line (Output.Text.To_UTF_8_String); Ada.Text_IO.Put_Line (Piece.Text.To_UTF_8_String); Anagram.Grammars_Debug.Print_Conflicts (AG, Table.all); if Ada.Command_Line.Argument_Count > 1 then Anagram.Grammars_Debug.Print (G); end if; end YACC_Driver;
reznikmm/matreshka
Ada
4,007
ads
------------------------------------------------------------------------------ -- -- -- Matreshka Project -- -- -- -- Open Document Toolkit -- -- -- -- Runtime Library Component -- -- -- ------------------------------------------------------------------------------ -- -- -- Copyright © 2014, Vadim Godunko <[email protected]> -- -- All rights reserved. -- -- -- -- Redistribution and use in source and binary forms, with or without -- -- modification, are permitted provided that the following conditions -- -- are met: -- -- -- -- * Redistributions of source code must retain the above copyright -- -- notice, this list of conditions and the following disclaimer. -- -- -- -- * Redistributions in binary form must reproduce the above copyright -- -- notice, this list of conditions and the following disclaimer in the -- -- documentation and/or other materials provided with the distribution. -- -- -- -- * Neither the name of the Vadim Godunko, IE nor the names of its -- -- contributors may be used to endorse or promote products derived from -- -- this software without specific prior written permission. -- -- -- -- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -- -- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -- -- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -- -- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -- -- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -- -- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED -- -- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -- -- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -- -- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -- -- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -- -- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- -- -- ------------------------------------------------------------------------------ -- $Revision$ $Date$ ------------------------------------------------------------------------------ with ODF.DOM.Svg_SpreadMethod_Attributes; package Matreshka.ODF_Svg.SpreadMethod_Attributes is type Svg_SpreadMethod_Attribute_Node is new Matreshka.ODF_Svg.Abstract_Svg_Attribute_Node and ODF.DOM.Svg_SpreadMethod_Attributes.ODF_Svg_SpreadMethod_Attribute with null record; overriding function Create (Parameters : not null access Matreshka.DOM_Attributes.Attribute_L2_Parameters) return Svg_SpreadMethod_Attribute_Node; overriding function Get_Local_Name (Self : not null access constant Svg_SpreadMethod_Attribute_Node) return League.Strings.Universal_String; end Matreshka.ODF_Svg.SpreadMethod_Attributes;
reznikmm/matreshka
Ada
3,754
ads
------------------------------------------------------------------------------ -- -- -- Matreshka Project -- -- -- -- Open Document Toolkit -- -- -- -- Runtime Library Component -- -- -- ------------------------------------------------------------------------------ -- -- -- Copyright © 2014, Vadim Godunko <[email protected]> -- -- All rights reserved. -- -- -- -- Redistribution and use in source and binary forms, with or without -- -- modification, are permitted provided that the following conditions -- -- are met: -- -- -- -- * Redistributions of source code must retain the above copyright -- -- notice, this list of conditions and the following disclaimer. -- -- -- -- * Redistributions in binary form must reproduce the above copyright -- -- notice, this list of conditions and the following disclaimer in the -- -- documentation and/or other materials provided with the distribution. -- -- -- -- * Neither the name of the Vadim Godunko, IE nor the names of its -- -- contributors may be used to endorse or promote products derived from -- -- this software without specific prior written permission. -- -- -- -- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -- -- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -- -- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -- -- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -- -- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -- -- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED -- -- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -- -- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -- -- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -- -- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -- -- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- -- -- ------------------------------------------------------------------------------ -- $Revision$ $Date$ ------------------------------------------------------------------------------ with XML.DOM.Attributes; package ODF.DOM.Style_Font_Name_Complex_Attributes is pragma Preelaborate; type ODF_Style_Font_Name_Complex_Attribute is limited interface and XML.DOM.Attributes.DOM_Attribute; type ODF_Style_Font_Name_Complex_Attribute_Access is access all ODF_Style_Font_Name_Complex_Attribute'Class with Storage_Size => 0; end ODF.DOM.Style_Font_Name_Complex_Attributes;
davidkristola/vole
Ada
259
ads
with kv.avm.Line_Parser; generic type Reader is new kv.avm.Line_Parser.Parse_Line_Interface with private; package kv.avm.File_Reader is procedure Parse_Input_File (Self : in out Reader; File_In : in String); end kv.avm.File_Reader;