repo_name
stringlengths 9
74
| language
stringclasses 1
value | length_bytes
int64 11
9.34M
| extension
stringclasses 2
values | content
stringlengths 11
9.34M
|
---|---|---|---|---|
reznikmm/matreshka | Ada | 4,607 | adb | ------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- Open Document Toolkit --
-- --
-- Runtime Library Component --
-- --
------------------------------------------------------------------------------
-- --
-- Copyright © 2014, Vadim Godunko <[email protected]> --
-- All rights reserved. --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions --
-- are met: --
-- --
-- * Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- --
-- * Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in the --
-- documentation and/or other materials provided with the distribution. --
-- --
-- * Neither the name of the Vadim Godunko, IE nor the names of its --
-- contributors may be used to endorse or promote products derived from --
-- this software without specific prior written permission. --
-- --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR --
-- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
-- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED --
-- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR --
-- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF --
-- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING --
-- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS --
-- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
-- --
------------------------------------------------------------------------------
-- $Revision$ $Date$
------------------------------------------------------------------------------
with Matreshka.DOM_Documents;
with Matreshka.ODF_String_Constants;
with ODF.DOM.Iterators;
with ODF.DOM.Visitors;
package body Matreshka.ODF_Text.Main_Entry_Attributes is
------------
-- Create --
------------
overriding function Create
(Parameters : not null access Matreshka.DOM_Attributes.Attribute_L2_Parameters)
return Text_Main_Entry_Attribute_Node is
begin
return Self : Text_Main_Entry_Attribute_Node do
Matreshka.ODF_Text.Constructors.Initialize
(Self'Unchecked_Access,
Parameters.Document,
Matreshka.ODF_String_Constants.Text_Prefix);
end return;
end Create;
--------------------
-- Get_Local_Name --
--------------------
overriding function Get_Local_Name
(Self : not null access constant Text_Main_Entry_Attribute_Node)
return League.Strings.Universal_String
is
pragma Unreferenced (Self);
begin
return Matreshka.ODF_String_Constants.Main_Entry_Attribute;
end Get_Local_Name;
begin
Matreshka.DOM_Documents.Register_Attribute
(Matreshka.ODF_String_Constants.Text_URI,
Matreshka.ODF_String_Constants.Main_Entry_Attribute,
Text_Main_Entry_Attribute_Node'Tag);
end Matreshka.ODF_Text.Main_Entry_Attributes;
|
gitter-badger/libAnne | Ada | 1,000 | adb | package body Containers.Decimal_Stacks is
procedure Add(Self : in out Stack) is
begin
Self.Push(Self.Pop + Self.Pop);
end Add;
procedure Add(Self : in out Stack; Value : in Decimal_Type) is
begin
Self.Push(Self.Pop + Value);
end Add;
procedure Subtract(Self : in out Stack) is
Top : Decimal_Type := Self.Pop;
begin
Self.Push(Self.Pop - Top);
end Subtract;
procedure Subtract(Self : in out Stack; Value : in Decimal_Type) is
begin
Self.Push(Self.Pop - Value);
end Subtract;
procedure Multiply(Self : in out Stack) is
begin
Self.Push(Self.Pop * Self.Pop);
end Multiply;
procedure Multiply(Self : in out Stack; Value : in Decimal_Type) is
begin
Self.Push(Self.Pop * Value);
end Multiply;
procedure Divide(Self : in out Stack) is
Top : Decimal_Type := Self.Pop;
begin
Self.Push(Self.Pop / Top);
end Divide;
procedure Divide(Self : in out Stack; Value : in Decimal_Type) is
begin
Self.Push(Self.Pop / Value);
end Divide;
end Containers.Decimal_Stacks;
|
kraileth/ravensource | Ada | 452 | adb | --- src/gprbuild-link.adb.orig 2022-09-22 17:08:57 UTC
+++ src/gprbuild-link.adb
@@ -3159,8 +3159,6 @@ package body Gprbuild.Link is
if Opt.Run_Path_Option
and then Main_Proj.Config.Run_Path_Option /= No_Name_List
then
- Add_Rpath_From_Arguments (Rpaths, Arguments, Main_Proj);
- Add_Rpath_From_Arguments (Rpaths, Other_Arguments, Main_Proj);
Add_Run_Path_Options;
end if;
|
DrenfongWong/tkm-rpc | Ada | 47 | ads | package Tkmrpc.Servers is
end Tkmrpc.Servers;
|
Rodeo-McCabe/orka | Ada | 12,393 | adb | -- SPDX-License-Identifier: Apache-2.0
--
-- Copyright (c) 2013 Felix Krause <[email protected]>
--
-- Licensed under the Apache License, Version 2.0 (the "License");
-- you may not use this file except in compliance with the License.
-- You may obtain a copy of the License at
--
-- http://www.apache.org/licenses/LICENSE-2.0
--
-- Unless required by applicable law or agreed to in writing, software
-- distributed under the License is distributed on an "AS IS" BASIS,
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-- See the License for the specific language governing permissions and
-- limitations under the License.
with Ada.Unchecked_Conversion;
with GL.API;
with GL.Enums.Getter;
with GL.Pixels.Queries;
package body GL.Objects.Framebuffers is
function Valid_Attachment
(Attachment : Attachment_Point;
Texture : Textures.Texture) return Boolean
is
Format : GL.Pixels.Internal_Format renames Texture.Internal_Format;
begin
case Attachment is
when Depth_Stencil_Attachment =>
return GL.Pixels.Extensions.Depth_Stencil_Format (Format);
when Depth_Attachment =>
return GL.Pixels.Extensions.Depth_Format (Format);
when Stencil_Attachment =>
return GL.Pixels.Extensions.Stencil_Format (Format);
when others =>
return GL.Pixels.Queries.Color_Renderable (Format, Texture.Kind);
end case;
end Valid_Attachment;
function Status
(Object : Framebuffer;
Target : Framebuffer_Target'Class) return Framebuffer_Status is
begin
return API.Check_Named_Framebuffer_Status.Ref (Object.Reference.GL_Id, Target.Kind);
end Status;
procedure Set_Draw_Buffer
(Object : Framebuffer;
Selector : Buffers.Color_Buffer_Selector)
is
subtype Index_Type is Buffers.Draw_Buffer_Index;
begin
Object.Set_Draw_Buffers
((Index_Type'First => Selector,
Index_Type'First + 1 .. Index_Type'Last => Buffers.None));
end Set_Draw_Buffer;
procedure Set_Draw_Buffers
(Object : Framebuffer;
List : Buffers.Color_Buffer_List) is
begin
API.Named_Framebuffer_Draw_Buffers.Ref (Object.Reference.GL_Id, List'Length, List);
end Set_Draw_Buffers;
procedure Set_Read_Buffer (Object : Framebuffer; Selector : Buffers.Color_Buffer_Selector) is
begin
API.Named_Framebuffer_Read_Buffer.Ref (Object.Reference.GL_Id, Selector);
end Set_Read_Buffer;
procedure Attach_Texture
(Object : Framebuffer;
Attachment : Attachment_Point;
Texture : Textures.Texture;
Level : Textures.Mipmap_Level) is
begin
API.Named_Framebuffer_Texture.Ref (Object.Reference.GL_Id, Attachment,
Texture.Raw_Id, Level);
end Attach_Texture;
procedure Attach_Texture_Layer
(Object : Framebuffer;
Attachment : Attachment_Point;
Texture : Textures.Texture;
Level : Textures.Mipmap_Level;
Layer : Natural) is
begin
API.Named_Framebuffer_Texture_Layer.Ref (Object.Reference.GL_Id, Attachment,
Texture.Raw_Id, Level, Int (Layer));
end Attach_Texture_Layer;
procedure Detach (Object : Framebuffer; Attachment : Attachment_Point) is
begin
API.Named_Framebuffer_Texture.Ref (Object.Reference.GL_Id, Attachment, 0, 0);
end Detach;
procedure Invalidate_Data
(Object : Framebuffer;
Attachments : Attachment_List) is
begin
API.Invalidate_Named_Framebuffer_Data.Ref
(Object.Reference.GL_Id, Attachments'Length, Attachments);
end Invalidate_Data;
procedure Invalidate_Sub_Data
(Object : Framebuffer;
Attachments : Attachment_List;
X, Y : Int;
Width, Height : Size) is
begin
API.Invalidate_Named_Framebuffer_Sub_Data.Ref
(Object.Reference.GL_Id, Attachments'Length, Attachments, X, Y, Width, Height);
end Invalidate_Sub_Data;
procedure Invalidate_Data
(Object : Framebuffer;
Attachments : Default_Attachment_List) is
begin
API.Invalidate_Named_Framebuffer_Data_Default.Ref
(Object.Reference.GL_Id, Attachments'Length, Attachments);
end Invalidate_Data;
procedure Invalidate_Sub_Data
(Object : Framebuffer;
Attachments : Default_Attachment_List;
X, Y : Int;
Width, Height : Size) is
begin
API.Invalidate_Named_Framebuffer_Sub_Data_Default.Ref
(Object.Reference.GL_Id, Attachments'Length, Attachments, X, Y, Width, Height);
end Invalidate_Sub_Data;
procedure Blit (Read_Object, Draw_Object : Framebuffer;
Src_X0, Src_Y0, Src_X1, Src_Y1,
Dst_X0, Dst_Y0, Dst_X1, Dst_Y1 : Int;
Mask : Buffers.Buffer_Bits;
Filter : Textures.Magnifying_Function)
is
use type Low_Level.Bitfield;
function Convert is new Ada.Unchecked_Conversion
(Buffers.Buffer_Bits, Low_Level.Bitfield);
Raw_Bits : constant Low_Level.Bitfield
:= Convert (Mask) and 2#0100010100000000#;
begin
API.Blit_Named_Framebuffer.Ref (Read_Object.Reference.GL_Id,
Draw_Object.Reference.GL_Id,
Src_X0, Src_Y0, Src_X1, Src_Y1,
Dst_X0, Dst_Y0, Dst_X1, Dst_Y1,
Raw_Bits, Filter);
end Blit;
procedure Set_Default_Width (Object : Framebuffer; Value : Size) is
begin
API.Named_Framebuffer_Parameter_Size.Ref (Object.Reference.GL_Id,
Enums.Default_Width, Value);
end Set_Default_Width;
function Default_Width (Object : Framebuffer) return Size is
Ret : aliased Size;
begin
API.Get_Named_Framebuffer_Parameter_Size.Ref
(Object.Reference.GL_Id, Enums.Default_Width, Ret'Unchecked_Access);
return Ret;
end Default_Width;
function Max_Framebuffer_Width return Size is
Ret : Size := 16_384;
begin
API.Get_Size.Ref (Enums.Getter.Max_Framebuffer_Width, Ret);
return Ret;
end Max_Framebuffer_Width;
procedure Set_Default_Height (Object : Framebuffer; Value : Size) is
begin
API.Named_Framebuffer_Parameter_Size.Ref (Object.Reference.GL_Id,
Enums.Default_Height,
Value);
end Set_Default_Height;
function Default_Height (Object : Framebuffer) return Size is
Ret : aliased Size;
begin
API.Get_Named_Framebuffer_Parameter_Size.Ref
(Object.Reference.GL_Id, Enums.Default_Height, Ret'Unchecked_Access);
return Ret;
end Default_Height;
function Max_Framebuffer_Height return Size is
Ret : Size := 16_384;
begin
API.Get_Size.Ref (Enums.Getter.Max_Framebuffer_Height, Ret);
return Ret;
end Max_Framebuffer_Height;
procedure Set_Default_Layers (Object : Framebuffer; Value : Size) is
begin
API.Named_Framebuffer_Parameter_Size.Ref (Object.Reference.GL_Id,
Enums.Default_Layers, Value);
end Set_Default_Layers;
function Default_Layers (Object : Framebuffer) return Size is
Ret : aliased Size;
begin
API.Get_Named_Framebuffer_Parameter_Size.Ref
(Object.Reference.GL_Id, Enums.Default_Layers, Ret'Unchecked_Access);
return Ret;
end Default_Layers;
function Max_Framebuffer_Layers return Size is
Ret : Size := 2_048;
begin
API.Get_Size.Ref (Enums.Getter.Max_Framebuffer_Layers, Ret);
return Ret;
end Max_Framebuffer_Layers;
procedure Set_Default_Samples (Object : Framebuffer; Value : Size) is
begin
API.Named_Framebuffer_Parameter_Size.Ref (Object.Reference.GL_Id,
Enums.Default_Samples,
Value);
end Set_Default_Samples;
function Default_Samples (Object : Framebuffer) return Size is
Ret : aliased Size;
begin
API.Get_Named_Framebuffer_Parameter_Size.Ref
(Object.Reference.GL_Id, Enums.Default_Samples, Ret'Unchecked_Access);
return Ret;
end Default_Samples;
function Max_Framebuffer_Samples return Size is
Ret : Size := 4;
begin
API.Get_Size.Ref (Enums.Getter.Max_Framebuffer_Samples, Ret);
return Ret;
end Max_Framebuffer_Samples;
procedure Set_Default_Fixed_Sample_Locations (Object : Framebuffer; Value : Boolean) is
begin
API.Named_Framebuffer_Parameter_Bool.Ref (Object.Reference.GL_Id,
Enums.Default_Fixed_Sample_Locations,
Low_Level.Bool (Value));
end Set_Default_Fixed_Sample_Locations;
function Default_Fixed_Sample_Locations (Object : Framebuffer) return Boolean is
Ret : aliased Low_Level.Bool;
begin
API.Get_Named_Framebuffer_Parameter_Bool.Ref
(Object.Reference.GL_Id, Enums.Default_Fixed_Sample_Locations,
Ret'Unchecked_Access);
return Boolean (Ret);
end Default_Fixed_Sample_Locations;
overriding
procedure Initialize_Id (Object : in out Framebuffer) is
New_Id : UInt := 0;
begin
API.Create_Framebuffers.Ref (1, New_Id);
Object.Reference.GL_Id := New_Id;
end Initialize_Id;
overriding
procedure Delete_Id (Object : in out Framebuffer) is
Arr : constant Low_Level.UInt_Array := (1 => Object.Reference.GL_Id);
begin
API.Delete_Framebuffers.Ref (1, Arr);
Object.Reference.GL_Id := 0;
end Delete_Id;
procedure Bind (Target : Framebuffer_Target;
Object : Framebuffer'Class) is
begin
API.Bind_Framebuffer.Ref (Target.Kind, Object.Reference.GL_Id);
end Bind;
procedure Clear_Color_Buffer
(Object : Framebuffer;
Index : Buffers.Draw_Buffer_Index;
Format_Type : Pixels.Extensions.Format_Type;
Value : Colors.Color)
is
use all type GL.Pixels.Extensions.Format_Type;
begin
case Format_Type is
when Float_Or_Normalized_Type =>
API.Clear_Named_Framebuffer_Color_Real.Ref
(Object.Reference.GL_Id, Enums.Color_Buffer, Index, Value);
when Int_Type =>
API.Clear_Named_Framebuffer_Color_Signed_Int.Ref
(Object.Reference.GL_Id, Enums.Color_Buffer, Index, Value);
when Unsigned_Int_Type =>
API.Clear_Named_Framebuffer_Color_Unsigned_Int.Ref
(Object.Reference.GL_Id, Enums.Color_Buffer, Index, Value);
when Depth_Type =>
raise Constraint_Error;
end case;
end Clear_Color_Buffer;
procedure Clear_Depth_Buffer (Object : Framebuffer; Value : Buffers.Depth) is
Aliased_Value : aliased Buffers.Depth := Value;
begin
API.Clear_Named_Framebuffer_Depth.Ref
(Object.Reference.GL_Id, Enums.Depth_Buffer, 0, Aliased_Value);
end Clear_Depth_Buffer;
procedure Clear_Stencil_Buffer (Object : Framebuffer; Value : Buffers.Stencil_Index) is
Aliased_Value : aliased Buffers.Stencil_Index := Value;
begin
API.Clear_Named_Framebuffer_Stencil.Ref
(Object.Reference.GL_Id, Enums.Stencil_Buffer, 0, Aliased_Value);
end Clear_Stencil_Buffer;
procedure Clear_Depth_And_Stencil_Buffer (Object : Framebuffer;
Depth_Value : Buffers.Depth;
Stencil_Value : Buffers.Stencil_Index) is
begin
API.Clear_Named_Framebuffer_Depth_Stencil.Ref
(Object.Reference.GL_Id, Enums.Depth_Stencil_Buffer, 0, Depth_Value, Stencil_Value);
end Clear_Depth_And_Stencil_Buffer;
-----------------------------------------------------------------------------
type Default_Framebuffer_Type is new Framebuffer with null record;
overriding
procedure Initialize_Id (Object : in out Default_Framebuffer_Type) is null;
overriding
procedure Delete_Id (Object : in out Default_Framebuffer_Type) is null;
Default_FB : constant Default_Framebuffer_Type
:= Default_Framebuffer_Type'(GL_Object with null record);
function Default_Framebuffer return Framebuffer is (Framebuffer (Default_FB));
end GL.Objects.Framebuffers;
|
reznikmm/matreshka | Ada | 6,678 | 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.Key_Elements is
------------
-- Create --
------------
overriding function Create
(Parameters : not null access Matreshka.DOM_Elements.Element_L2_Parameters)
return Db_Key_Element_Node is
begin
return Self : Db_Key_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_Key_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_Key
(ODF.DOM.Db_Key_Elements.ODF_Db_Key_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_Key_Element_Node)
return League.Strings.Universal_String
is
pragma Unreferenced (Self);
begin
return Matreshka.ODF_String_Constants.Key_Element;
end Get_Local_Name;
----------------
-- Leave_Node --
----------------
overriding procedure Leave_Node
(Self : not null access Db_Key_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_Key
(ODF.DOM.Db_Key_Elements.ODF_Db_Key_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_Key_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_Key
(Visitor,
ODF.DOM.Db_Key_Elements.ODF_Db_Key_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.Key_Element,
Db_Key_Element_Node'Tag);
end Matreshka.ODF_Db.Key_Elements;
|
jscparker/math_packages | Ada | 1,018 | ads |
-- F defines a differential equation whose solution is Exp (i*t).
-- dY/dt = F(Y).
-- For testing.
generic
type Real is digits <>;
package Sinu is
type Dyn_Index is range 0..1;
type Dynamical_Variable is array(Dyn_Index) of Real;
DynZero : constant Dynamical_Variable := (others => 0.0);
function F
(Time : Real;
Y : Dynamical_Variable)
return Dynamical_Variable;
-- Defines the equation to be integrated,
-- dY/dt = F (t, Y). Even if the equation is t or Y
-- independent, it must be entered in this form.
function "*"
(Left : Real;
Right : Dynamical_Variable)
return Dynamical_Variable;
function "+"
(Left : Dynamical_Variable;
Right : Dynamical_Variable)
return Dynamical_Variable;
function "-"
(Left : Dynamical_Variable;
Right : Dynamical_Variable)
return Dynamical_Variable;
function Norm (Y : Dynamical_Variable) return Real;
pragma Inline (F, "*", "+", "-", Norm);
end Sinu;
|
pmderodat/sdlada | Ada | 12,374 | adb | --------------------------------------------------------------------------------------------------------------------
-- Copyright (c) 2013-2018 Luke A. Guest
--
-- This software is provided 'as-is', without any express or implied
-- warranty. In no event will the authors be held liable for any damages
-- arising from the use of this software.
--
-- Permission is granted to anyone to use this software for any purpose,
-- including commercial applications, and to alter it and redistribute it
-- freely, subject to the following restrictions:
--
-- 1. The origin of this software must not be misrepresented; you must not
-- claim that you wrote the original software. If you use this software
-- in a product, an acknowledgment in the product documentation would be
-- appreciated but is not required.
--
-- 2. Altered source versions must be plainly marked as such, and must not be
-- misrepresented as being the original software.
--
-- 3. This notice may not be removed or altered from any source
-- distribution.
--------------------------------------------------------------------------------------------------------------------
with Interfaces.C.Strings;
with SDL.Error;
package body SDL.Inputs.Joysticks.Game_Controllers is
package C renames Interfaces.C;
use type C.int;
use type C.Strings.chars_ptr;
procedure Add_Mapping (Data : in String; Updated_Existing : out Boolean) is
function SDL_Game_Controller_Add_Mapping (Buffer : in C.char_array) return C.int with
Convention => C,
Import => True,
External_Name => "SDL_GameControllerAddMapping";
Result : C.int := SDL_Game_Controller_Add_Mapping (C.To_C (Data));
begin
if Result = 0 then
-- An existing mapping was updated.
Updated_Existing := True;
elsif Result = -1 then
raise Mapping_Error with SDL.Error.Get;
end if;
-- Result should be 1 and therefore mapping was added ok.
end Add_Mapping;
function Add_Mapping (Database_Filename : in String) return Natural is
function SDL_Game_Controller_Add_Mapping (Buffer : in C.char_array) return C.int with
Convention => C,
Import => True,
External_Name => "SDL_GameControllerAddMapping";
Result : C.int := SDL_Game_Controller_Add_Mapping (C.To_C (Database_Filename));
begin
if Result = -1 then
raise Mapping_Error with SDL.Error.Get;
end if;
-- Return the total number of entries added.
return Natural (Result);
end Add_Mapping;
function Axis_Value (Self : in Game_Controller;
Axis : in SDL.Events.Joysticks.Game_Controllers.LR_Axes)
return SDL.Events.Joysticks.Game_Controllers.LR_Axes_Values is
function SDL_Game_Controller_Get_Axis (Controller : in SDL.C_Pointers.Game_Controller_Pointer;
Axis : in SDL.Events.Joysticks.Game_Controllers.LR_Axes)
return SDL.Events.Joysticks.Game_Controllers.LR_Axes_Values with
Import => True,
Convention => C,
External_Name => "SDL_GameControllerGetAxis";
begin
return SDL_Game_Controller_Get_Axis (Self.Internal, Axis);
end Axis_Value;
function Axis_Value (Self : in Game_Controller;
Axis : in SDL.Events.Joysticks.Game_Controllers.Trigger_Axes)
return SDL.Events.Joysticks.Game_Controllers.Trigger_Axes_Values is
function SDL_Game_Controller_Get_Axis (Controller : in SDL.C_Pointers.Game_Controller_Pointer;
Axis : in SDL.Events.Joysticks.Game_Controllers.Trigger_Axes)
return SDL.Events.Joysticks.Game_Controllers.Trigger_Axes_Values with
Import => True,
Convention => C,
External_Name => "SDL_GameControllerGetAxis";
begin
return SDL_Game_Controller_Get_Axis (Self.Internal, Axis);
end Axis_Value;
procedure Close (Self : in out Game_Controller) is
procedure SDL_Game_Controller_Close (Controller : in SDL.C_Pointers.Game_Controller_Pointer) with
Import => True,
Convention => C,
External_Name => "SDL_GameControllerClose";
begin
SDL_Game_Controller_Close (Self.Internal);
-- Reinitialise the object so it's actually a Null_Game_Controller.
Self.Internal := null;
Self.Owns := True;
end Close;
function Get_Axis (Axis : in String) return SDL.Events.Joysticks.Game_Controllers.Axes is
function SDL_Game_Controller_Get_Axis_From_String (Axis : in C.char_array)
return SDL.Events.Joysticks.Game_Controllers.Axes with
Import => True,
Convention => C,
External_Name => "SDL_GameControllerGetAxisFromString";
begin
return SDL_Game_Controller_Get_Axis_From_String (C.To_C (Axis));
end Get_Axis;
function Get_Binding (Self : in Game_Controller; Axis : in SDL.Events.Joysticks.Game_Controllers.Axes)
return Bindings is
function SDL_Game_Controller_Get_Bind_For_Axis
(Controller : in SDL.C_Pointers.Game_Controller_Pointer;
Axis : in SDL.Events.Joysticks.Game_Controllers.Axes) return Bindings with
Import => True,
Convention => C,
External_Name => "SDL_GameControllerGetBindForAxis";
begin
return SDL_Game_Controller_Get_Bind_For_Axis (Self.Internal, Axis);
end Get_Binding;
function Get_Binding (Self : in Game_Controller; Button : in SDL.Events.Joysticks.Game_Controllers.Buttons)
return Bindings is
function SDL_Game_Controller_Get_Bind_For_Button
(Controller : in SDL.C_Pointers.Game_Controller_Pointer;
Button : in SDL.Events.Joysticks.Game_Controllers.Buttons) return Bindings with
Import => True,
Convention => C,
External_Name => "SDL_GameControllerGetBindForButton";
begin
return SDL_Game_Controller_Get_Bind_For_Button (Self.Internal, Button);
end Get_Binding;
function Get_Button (Button_Name : in String) return SDL.Events.Joysticks.Game_Controllers.Buttons is
function SDL_Game_Controller_Get_Button_From_String
(Buffer : in C.char_array) return SDL.Events.Joysticks.Game_Controllers.Buttons with
Convention => C,
Import => True,
External_Name => "SDL_GameControllerGetButtonFromString";
begin
return SDL.Events.Joysticks.Game_Controllers.Buttons
(SDL_Game_Controller_Get_Button_From_String (C.To_C (Button_Name)));
end Get_Button;
function Get_Joystick (Self : in Game_Controller) return Joystick is
function SDL_Game_Controller_Get_Joystick
(Controller : in SDL.C_Pointers.Game_Controller_Pointer)
return SDL.C_Pointers.Joystick_Pointer with
Convention => C,
Import => True,
External_Name => "SDL_GameControllerGetJoystick";
begin
return J : Joystick := (Ada.Finalization.Limited_Controlled with
Internal => SDL_Game_Controller_Get_Joystick (Self.Internal), Owns => False) do
null;
end return;
end Get_Joystick;
function Get_Mapping (Self : in Game_Controller) return String is
function SDL_Game_Controller_Mapping
(Controller : in SDL.C_Pointers.Game_Controller_Pointer) return C.Strings.chars_ptr with
Convention => C,
Import => True,
External_Name => "SDL_GameControllerMapping";
Result : C.Strings.chars_ptr := SDL_Game_Controller_Mapping (Self.Internal);
begin
if Result = C.Strings.Null_Ptr then
return "";
end if;
return C.Strings.Value (Result);
end Get_Mapping;
function Get_Mapping (Controller : in GUIDs) return String is
function SDL_Game_Controller_Mapping_For_GUID (Controller : in GUIDs) return C.Strings.chars_ptr with
Convention => C,
Import => True,
External_Name => "SDL_GameControllerMappingForGUID";
Result : C.Strings.chars_ptr := SDL_Game_Controller_Mapping_For_GUID (Controller);
begin
if Result = C.Strings.Null_Ptr then
return "";
end if;
return C.Strings.Value (Result);
end Get_Mapping;
function Get_Name (Self : in Game_Controller) return String is
function SDL_Game_Controller_Name
(Controller : in SDL.C_Pointers.Game_Controller_Pointer) return C.Strings.chars_ptr with
Convention => C,
Import => True,
External_Name => "SDL_GameControllerName";
Result : C.Strings.chars_ptr := SDL_Game_Controller_Name (Self.Internal);
begin
if Result = C.Strings.Null_Ptr then
return "";
end if;
return C.Strings.Value (Result);
end Get_Name;
function Get_Name (Device : in Devices) return String is
function SDL_Game_Controller_Name_For_Index (Index : in C.int) return C.Strings.chars_ptr with
Convention => C,
Import => True,
External_Name => "SDL_GameControllerNameForIndex";
Result : C.Strings.chars_ptr := SDL_Game_Controller_Name_For_Index (C.int (Device) - 1);
begin
if Result = C.Strings.Null_Ptr then
return "";
end if;
return C.Strings.Value (Result);
end Get_Name;
function Image (Axis : in SDL.Events.Joysticks.Game_Controllers.Axes) return String is
function SDL_Game_Controller_Get_String_For_Axis
(Axis : in SDL.Events.Joysticks.Game_Controllers.Axes) return C.Strings.chars_ptr with
Convention => C,
Import => True,
External_Name => "SDL_GameControllerGetStringForAxis";
Result : C.Strings.chars_ptr := SDL_Game_Controller_Get_String_For_Axis (Axis);
begin
if Result = C.Strings.Null_Ptr then
return "";
end if;
return C.Strings.Value (Result);
end Image;
function Image (Button : in SDL.Events.Joysticks.Game_Controllers.Buttons) return String is
function SDL_Game_Controller_Get_String_For_Button
(Button : in SDL.Events.Joysticks.Game_Controllers.Buttons) return C.Strings.chars_ptr with
Convention => C,
Import => True,
External_Name => "SDL_GameControllerGetStringForButton";
Result : C.Strings.chars_ptr := SDL_Game_Controller_Get_String_For_Button (Button);
begin
if Result = C.Strings.Null_Ptr then
return "";
end if;
return C.Strings.Value (Result);
end Image;
function Is_Attached (Self : in Game_Controller) return Boolean is
function SDL_Game_Controller_Is_Attached (Controller : in SDL.C_Pointers.Game_Controller_Pointer)
return SDL_Bool with
Import => True,
Convention => C,
External_Name => "SDL_GameControllerGetAttached";
begin
if SDL_Game_Controller_Is_Attached (Self.Internal) = SDL_True then
return True;
end if;
return False;
end Is_Attached;
function Is_Button_Pressed (Self : in Game_Controller; Button : in SDL.Events.Joysticks.Buttons)
return SDL.Events.Button_State is
function SDL_Game_Controller_Get_Button
(Controller : in SDL.C_Pointers.Game_Controller_Pointer;
Button : in SDL.Events.Joysticks.Buttons)
return SDL.Events.Button_State with
Import => True,
Convention => C,
External_Name => "SDL_GameControllerGetButton";
begin
return SDL_Game_Controller_Get_Button (Self.Internal, Button);
end Is_Button_Pressed;
function Is_Game_Controller (Device : in Devices) return Boolean is
function SDL_Is_Game_Controller (Device : in C.int) return SDL_Bool with
Import => True,
Convention => C,
External_Name => "SDL_IsGameController";
begin
if SDL_Is_Game_Controller (C.int (Device) - 1) = SDL_True then
return True;
end if;
return False;
end Is_Game_Controller;
end SDL.Inputs.Joysticks.Game_Controllers;
|
faelys/natools | Ada | 190 | ads | package Natools.Static_Maps.S_Expressions.Templates.Dates.Zones is
pragma Pure;
function Hash (S : String) return Natural;
end Natools.Static_Maps.S_Expressions.Templates.Dates.Zones;
|
damaki/SPARKNaCl | Ada | 666 | adb | with Ada.Numerics.Discrete_Random;
package body Random
with SPARK_Mode => Off
is
pragma Compile_Time_Warning
(True, "This PRNG is not cryptographically secure.");
package PRNG is new Ada.Numerics.Discrete_Random (Interfaces.Unsigned_8);
Gen : PRNG.Generator;
function Random_Byte return Interfaces.Unsigned_8
is
begin
return PRNG.Random (Gen);
end Random_Byte;
procedure Random_Bytes (R : out SPARKNaCl.Byte_Seq)
is
begin
for I in R'Range loop
pragma Loop_Optimize (No_Unroll);
R (I) := Random_Byte;
end loop;
end Random_Bytes;
begin
PRNG.Reset (Gen); -- time dependent
end Random;
|
nerilex/ada-util | Ada | 1,432 | ads | -----------------------------------------------------------------------
-- Util -- Utilities
-- Copyright (C) 2009, 2010, 2011, 2014 Stephane Carrez
-- Written by Stephane Carrez ([email protected])
--
-- Licensed under the Apache License, Version 2.0 (the "License");
-- you may not use this file except in compliance with the License.
-- You may obtain a copy of the License at
--
-- http://www.apache.org/licenses/LICENSE-2.0
--
-- Unless required by applicable law or agreed to in writing, software
-- distributed under the License is distributed on an "AS IS" BASIS,
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-- See the License for the specific language governing permissions and
-- limitations under the License.
-----------------------------------------------------------------------
with Util.Tests;
package Util.Properties.Tests is
procedure Add_Tests (Suite : in Util.Tests.Access_Test_Suite);
type Test is new Util.Tests.Test with null record;
procedure Test_Property (T : in out Test);
procedure Test_Integer_Property (T : in out Test);
procedure Test_Load_Property (T : in out Test);
procedure Test_Load_Strip_Property (T : in out Test);
procedure Test_Copy_Property (T : in out Test);
procedure Test_Set_Preserve_Original (T : in out Test);
procedure Test_Remove_Preserve_Original (T : in out Test);
end Util.Properties.Tests;
|
reznikmm/matreshka | Ada | 3,769 | ads | ------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- Open Document Toolkit --
-- --
-- Runtime Library Component --
-- --
------------------------------------------------------------------------------
-- --
-- Copyright © 2014, Vadim Godunko <[email protected]> --
-- All rights reserved. --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions --
-- are met: --
-- --
-- * Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- --
-- * Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in the --
-- documentation and/or other materials provided with the distribution. --
-- --
-- * Neither the name of the Vadim Godunko, IE nor the names of its --
-- contributors may be used to endorse or promote products derived from --
-- this software without specific prior written permission. --
-- --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR --
-- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
-- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED --
-- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR --
-- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF --
-- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING --
-- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS --
-- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
-- --
------------------------------------------------------------------------------
-- $Revision$ $Date$
------------------------------------------------------------------------------
with XML.DOM.Attributes;
package ODF.DOM.Table_Is_Data_Layout_Field_Attributes is
pragma Preelaborate;
type ODF_Table_Is_Data_Layout_Field_Attribute is limited interface
and XML.DOM.Attributes.DOM_Attribute;
type ODF_Table_Is_Data_Layout_Field_Attribute_Access is
access all ODF_Table_Is_Data_Layout_Field_Attribute'Class
with Storage_Size => 0;
end ODF.DOM.Table_Is_Data_Layout_Field_Attributes;
|
reznikmm/gela | Ada | 1,971 | ads | -- This package provides special Element_Factory to create elements from
-- Gela.Nodes.Fixed_* packages.
with Gela.Compilations;
with Gela.Elements.Expressions;
with Gela.Elements.Identifiers;
with Gela.Elements.Names;
with Gela.Elements.Operator_Symbols;
with Gela.Elements.Procedure_Call_Statements;
with Gela.Elements.Qualified_Expressions;
with Gela.Elements.Subtype_Marks;
with Gela.Lexical_Types;
with Gela.Node_Factories;
package Gela.Fix_Node_Factories is
pragma Preelaborate;
type Element_Factory (Comp : Gela.Compilations.Compilation_Access) is
limited new Gela.Node_Factories.Element_Factory (Comp) with null record;
type Element_Factory_Access is access all Element_Factory'Class;
overriding function Identifier
(Self : in out Element_Factory;
Identifier_Token : Gela.Lexical_Types.Token_Count)
return Gela.Elements.Identifiers.Identifier_Access;
overriding function Operator_Symbol
(Self : in out Element_Factory;
Operator_Symbol_Token : Gela.Lexical_Types.Token_Count)
return Gela.Elements.Operator_Symbols.Operator_Symbol_Access;
overriding function Procedure_Call_Statement
(Self : in out Element_Factory;
Function_Call : Gela.Elements.Names.Name_Access;
Semicolon_Token : Gela.Lexical_Types.Token_Count)
return Gela.Elements.Procedure_Call_Statements.
Procedure_Call_Statement_Access;
overriding function Qualified_Expression
(Self : in out Element_Factory;
Converted_Or_Qualified_Subtype_Mark : Gela.Elements.Subtype_Marks.
Subtype_Mark_Access;
Apostrophe_Token : Gela.Lexical_Types.Token_Count;
Left_Parenthesis_Token : Gela.Lexical_Types.Token_Count;
Converted_Or_Qualified_Expression : Gela.Elements.Expressions.
Expression_Access;
Right_Parenthesis_Token : Gela.Lexical_Types.Token_Count)
return Gela.Elements.Qualified_Expressions.Qualified_Expression_Access;
end Gela.Fix_Node_Factories;
|
reznikmm/matreshka | Ada | 4,075 | ads | ------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- Open Document Toolkit --
-- --
-- Runtime Library Component --
-- --
------------------------------------------------------------------------------
-- --
-- Copyright © 2014, Vadim Godunko <[email protected]> --
-- All rights reserved. --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions --
-- are met: --
-- --
-- * Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- --
-- * Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in the --
-- documentation and/or other materials provided with the distribution. --
-- --
-- * Neither the name of the Vadim Godunko, IE nor the names of its --
-- contributors may be used to endorse or promote products derived from --
-- this software without specific prior written permission. --
-- --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR --
-- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
-- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED --
-- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR --
-- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF --
-- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING --
-- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS --
-- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
-- --
------------------------------------------------------------------------------
-- $Revision$ $Date$
------------------------------------------------------------------------------
with ODF.DOM.Table_Precision_As_Shown_Attributes;
package Matreshka.ODF_Table.Precision_As_Shown_Attributes is
type Table_Precision_As_Shown_Attribute_Node is
new Matreshka.ODF_Table.Abstract_Table_Attribute_Node
and ODF.DOM.Table_Precision_As_Shown_Attributes.ODF_Table_Precision_As_Shown_Attribute
with null record;
overriding function Create
(Parameters : not null access Matreshka.DOM_Attributes.Attribute_L2_Parameters)
return Table_Precision_As_Shown_Attribute_Node;
overriding function Get_Local_Name
(Self : not null access constant Table_Precision_As_Shown_Attribute_Node)
return League.Strings.Universal_String;
end Matreshka.ODF_Table.Precision_As_Shown_Attributes;
|
reznikmm/matreshka | Ada | 12,604 | adb | ------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- Ada Modeling Framework --
-- --
-- Runtime Library Component --
-- --
------------------------------------------------------------------------------
-- --
-- Copyright © 2012, Vadim Godunko <[email protected]> --
-- All rights reserved. --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions --
-- are met: --
-- --
-- * Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- --
-- * Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in the --
-- documentation and/or other materials provided with the distribution. --
-- --
-- * Neither the name of the Vadim Godunko, IE nor the names of its --
-- contributors may be used to endorse or promote products derived from --
-- this software without specific prior written permission. --
-- --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR --
-- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
-- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED --
-- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR --
-- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF --
-- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING --
-- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS --
-- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
-- --
------------------------------------------------------------------------------
-- $Revision$ $Date$
------------------------------------------------------------------------------
with AMF.CMOF.Enumeration_Literals.Collections;
with AMF.CMOF.Packageable_Elements.Collections;
with AMF.CMOF.Primitive_Types;
with AMF.CMOF.Properties.Collections;
with AMF.CMOF.Tags;
package body AMF.Transformations.UML_Profile_To_CMOF.Stage_1 is
use type AMF.UML.UML_Aggregation_Kind;
-----------------------
-- Enter_Enumeration --
-----------------------
overriding procedure Enter_Enumeration
(Self : in out Transformer;
Element : not null AMF.UML.Enumerations.UML_Enumeration_Access;
Control : in out AMF.Visitors.Traverse_Control)
is
pragma Unreferenced (Control);
Collection :
AMF.CMOF.Packageable_Elements.Collections.Set_Of_CMOF_Packageable_Element;
begin
-- Create Enumeration and set its attributes.
Self.The_Enumeration := Self.Context.Create_CMOF_Enumeration (Element);
Self.The_Enumeration.Set_Name (Element.Get_Name);
Collection := Self.The_Package.Get_Packaged_Element;
Collection.Add (Self.The_Enumeration);
end Enter_Enumeration;
-------------------------------
-- Enter_Enumeration_Literal --
-------------------------------
overriding procedure Enter_Enumeration_Literal
(Self : in out Transformer;
Element : not null AMF.UML.Enumeration_Literals.UML_Enumeration_Literal_Access;
Control : in out AMF.Visitors.Traverse_Control)
is
pragma Unreferenced (Control);
The_Enumeration_Literal :
AMF.CMOF.Enumeration_Literals.CMOF_Enumeration_Literal_Access;
Collection :
AMF.CMOF.Enumeration_Literals.Collections.Ordered_Set_Of_CMOF_Enumeration_Literal;
begin
-- Create EnumerationLiteral and set its attributes.
The_Enumeration_Literal :=
Self.Context.Create_CMOF_Enumeration_Literal (Element);
The_Enumeration_Literal.Set_Name (Element.Get_Name);
Collection := Self.The_Enumeration.Get_Owned_Literal;
Collection.Add (The_Enumeration_Literal);
end Enter_Enumeration_Literal;
---------------------
-- Enter_Extension --
---------------------
overriding procedure Enter_Extension
(Self : in out Transformer;
Element : not null AMF.UML.Extensions.UML_Extension_Access;
Control : in out AMF.Visitors.Traverse_Control)
is
pragma Unreferenced (Control);
Collection :
AMF.CMOF.Packageable_Elements.Collections.Set_Of_CMOF_Packageable_Element;
begin
-- Create association and set its attributes.
Self.The_Association := Self.Context.Create_CMOF_Association (Element);
Self.The_Association.Set_Name (Element.Get_Name);
Collection := Self.The_Package.Get_Packaged_Element;
Collection.Add (Self.The_Association);
end Enter_Extension;
-------------------------
-- Enter_Extension_End --
-------------------------
overriding procedure Enter_Extension_End
(Self : in out Transformer;
Element : not null AMF.UML.Extension_Ends.UML_Extension_End_Access;
Control : in out AMF.Visitors.Traverse_Control)
is
pragma Unreferenced (Control);
The_Property : AMF.CMOF.Properties.CMOF_Property_Access;
Collection : AMF.CMOF.Properties.Collections.Ordered_Set_Of_CMOF_Property;
begin
-- Create instance of CMOF::Property and set its attributes.
The_Property := Self.Context.Create_CMOF_Property (Element);
The_Property.Set_Name (Element.Get_Name);
The_Property.Set_Lower (Element.Lower_Bound);
The_Property.Set_Upper (Element.Upper_Bound);
The_Property.Set_Is_Composite
(Element.Get_Aggregation = AMF.UML.Composite);
Collection := Self.The_Association.Get_Owned_End;
Collection.Add (The_Property);
end Enter_Extension_End;
--------------------------
-- Enter_Primitive_Type --
--------------------------
overriding procedure Enter_Primitive_Type
(Self : in out Transformer;
Element : not null AMF.UML.Primitive_Types.UML_Primitive_Type_Access;
Control : in out AMF.Visitors.Traverse_Control)
is
pragma Unreferenced (Control);
The_Primitive_Type : AMF.CMOF.Primitive_Types.CMOF_Primitive_Type_Access;
Collection :
AMF.CMOF.Packageable_Elements.Collections.Set_Of_CMOF_Packageable_Element;
begin
-- Create instance of CMOF::PrimitiveType and set its attributes.
The_Primitive_Type := Self.Context.Create_CMOF_Primitive_Type (Element);
The_Primitive_Type.Set_Name (Element.Get_Name);
Collection := Self.The_Package.Get_Packaged_Element;
Collection.Add (The_Primitive_Type);
end Enter_Primitive_Type;
-------------------
-- Enter_Profile --
-------------------
overriding procedure Enter_Profile
(Self : in out Transformer;
Element : not null AMF.UML.Profiles.UML_Profile_Access;
Control : in out AMF.Visitors.Traverse_Control)
is
pragma Unreferenced (Control);
begin
-- Create instance of CMOF::Package and set its attributes.
Self.The_Package := Self.Context.Create_CMOF_Package (Element);
Self.The_Package.Set_Name (Element.Get_Name);
Self.The_Package.Set_URI (Element.Get_URI);
end Enter_Profile;
--------------------
-- Enter_Property --
--------------------
overriding procedure Enter_Property
(Self : in out Transformer;
Element : not null AMF.UML.Properties.UML_Property_Access;
Control : in out AMF.Visitors.Traverse_Control)
is
pragma Unreferenced (Control);
The_Property : AMF.CMOF.Properties.CMOF_Property_Access;
Collection : AMF.CMOF.Properties.Collections.Ordered_Set_Of_CMOF_Property;
begin
-- Create instance of CMOF::Property and set its attributes.
The_Property := Self.Context.Create_CMOF_Property (Element);
The_Property.Set_Name (Element.Get_Name);
The_Property.Set_Lower (Element.Lower_Bound);
The_Property.Set_Upper (Element.Upper_Bound);
The_Property.Set_Is_Composite
(Element.Get_Aggregation = AMF.UML.Composite);
Collection := Self.The_Class.Get_Owned_Attribute;
Collection.Add (The_Property);
end Enter_Property;
----------------------
-- Enter_Stereotype --
----------------------
overriding procedure Enter_Stereotype
(Self : in out Transformer;
Element : not null AMF.UML.Stereotypes.UML_Stereotype_Access;
Control : in out AMF.Visitors.Traverse_Control)
is
pragma Unreferenced (Control);
Collection :
AMF.CMOF.Packageable_Elements.Collections.Set_Of_CMOF_Packageable_Element;
begin
-- Create instance of CMOF::Class and set its attributes.
Self.The_Class := Self.Context.Create_CMOF_Class (Element);
Self.The_Class.Set_Name (Element.Get_Name);
Self.The_Class.Set_Is_Abstract (Element.Get_Is_Abstract);
Collection := Self.The_Package.Get_Packaged_Element;
Collection.Add (Self.The_Class);
end Enter_Stereotype;
---------------
-- Enter_Tag --
---------------
overriding procedure Enter_Tag
(Self : in out Transformer;
Element : not null AMF.MOF.Tags.MOF_Tag_Access;
Control : in out AMF.Visitors.Traverse_Control)
is
pragma Unreferenced (Control);
The_Tag : AMF.CMOF.Tags.CMOF_Tag_Access;
begin
-- Create instance of CMOF::Tag and set its attributes.
The_Tag := Self.Context.Create_CMOF_Tag (Element);
The_Tag.Set_Name (Element.Get_Name);
The_Tag.Set_Value (Element.Get_Value);
end Enter_Tag;
-----------------------
-- Leave_Enumeration --
-----------------------
overriding procedure Leave_Enumeration
(Self : in out Transformer;
Element : not null AMF.UML.Enumerations.UML_Enumeration_Access;
Control : in out AMF.Visitors.Traverse_Control)
is
pragma Unreferenced (Element);
pragma Unreferenced (Control);
begin
Self.The_Enumeration := null;
end Leave_Enumeration;
---------------------
-- Leave_Extension --
---------------------
overriding procedure Leave_Extension
(Self : in out Transformer;
Element : not null AMF.UML.Extensions.UML_Extension_Access;
Control : in out AMF.Visitors.Traverse_Control)
is
pragma Unreferenced (Element);
pragma Unreferenced (Control);
begin
Self.The_Association := null;
end Leave_Extension;
-------------------
-- Leave_Profile --
-------------------
overriding procedure Leave_Profile
(Self : in out Transformer;
Element : not null AMF.UML.Profiles.UML_Profile_Access;
Control : in out AMF.Visitors.Traverse_Control)
is
pragma Unreferenced (Element);
pragma Unreferenced (Control);
begin
Self.The_Package := null;
end Leave_Profile;
----------------------
-- Leave_Stereotype --
----------------------
overriding procedure Leave_Stereotype
(Self : in out Transformer;
Element : not null AMF.UML.Stereotypes.UML_Stereotype_Access;
Control : in out AMF.Visitors.Traverse_Control)
is
pragma Unreferenced (Element);
pragma Unreferenced (Control);
begin
Self.The_Class := null;
end Leave_Stereotype;
end AMF.Transformations.UML_Profile_To_CMOF.Stage_1;
|
reznikmm/matreshka | Ada | 3,709 | ads | ------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- Open Document Toolkit --
-- --
-- Runtime Library Component --
-- --
------------------------------------------------------------------------------
-- --
-- Copyright © 2014, Vadim Godunko <[email protected]> --
-- All rights reserved. --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions --
-- are met: --
-- --
-- * Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- --
-- * Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in the --
-- documentation and/or other materials provided with the distribution. --
-- --
-- * Neither the name of the Vadim Godunko, IE nor the names of its --
-- contributors may be used to endorse or promote products derived from --
-- this software without specific prior written permission. --
-- --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR --
-- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
-- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED --
-- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR --
-- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF --
-- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING --
-- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS --
-- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
-- --
------------------------------------------------------------------------------
-- $Revision$ $Date$
------------------------------------------------------------------------------
with XML.DOM.Attributes;
package ODF.DOM.Number_Textual_Attributes is
pragma Preelaborate;
type ODF_Number_Textual_Attribute is limited interface
and XML.DOM.Attributes.DOM_Attribute;
type ODF_Number_Textual_Attribute_Access is
access all ODF_Number_Textual_Attribute'Class
with Storage_Size => 0;
end ODF.DOM.Number_Textual_Attributes;
|
PhiTheta/ADLAS_Ada_System | Ada | 144 | adb | package body Output is
procedure Write_File
(Output : in out File_Type;
file_name : in String)
is separate;
end Output;
|
reznikmm/matreshka | Ada | 3,724 | ads | ------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- Open Document Toolkit --
-- --
-- Runtime Library Component --
-- --
------------------------------------------------------------------------------
-- --
-- Copyright © 2014, Vadim Godunko <[email protected]> --
-- All rights reserved. --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions --
-- are met: --
-- --
-- * Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- --
-- * Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in the --
-- documentation and/or other materials provided with the distribution. --
-- --
-- * Neither the name of the Vadim Godunko, IE nor the names of its --
-- contributors may be used to endorse or promote products derived from --
-- this software without specific prior written permission. --
-- --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR --
-- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
-- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED --
-- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR --
-- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF --
-- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING --
-- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS --
-- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
-- --
------------------------------------------------------------------------------
-- $Revision$ $Date$
------------------------------------------------------------------------------
with XML.DOM.Attributes;
package ODF.DOM.Text_String_Value_Attributes is
pragma Preelaborate;
type ODF_Text_String_Value_Attribute is limited interface
and XML.DOM.Attributes.DOM_Attribute;
type ODF_Text_String_Value_Attribute_Access is
access all ODF_Text_String_Value_Attribute'Class
with Storage_Size => 0;
end ODF.DOM.Text_String_Value_Attributes;
|
reznikmm/matreshka | Ada | 4,403 | ads | ------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- Web Framework --
-- --
-- Tools Component --
-- --
------------------------------------------------------------------------------
-- --
-- Copyright © 2015, Vadim Godunko <[email protected]> --
-- All rights reserved. --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions --
-- are met: --
-- --
-- * Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- --
-- * Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in the --
-- documentation and/or other materials provided with the distribution. --
-- --
-- * Neither the name of the Vadim Godunko, IE nor the names of its --
-- contributors may be used to endorse or promote products derived from --
-- this software without specific prior written permission. --
-- --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR --
-- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
-- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED --
-- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR --
-- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF --
-- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING --
-- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS --
-- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
-- --
------------------------------------------------------------------------------
-- $Revision$ $Date$
------------------------------------------------------------------------------
with Asis;
with Engines.Contexts;
with League.Strings;
package Properties.Definitions.Component_Definition is
function Initialize
(Engine : access Engines.Contexts.Context;
Element : Asis.Definition;
Name : Engines.Text_Property) return League.Strings.Universal_String;
function Bounds
(Engine : access Engines.Contexts.Context;
Element : Asis.Definition;
Name : Engines.Text_Property) return League.Strings.Universal_String;
function Size
(Engine : access Engines.Contexts.Context;
Element : Asis.Definition;
Name : Engines.Text_Property) return League.Strings.Universal_String
renames Bounds;
function Alignment
(Engine : access Engines.Contexts.Context;
Element : Asis.Definition;
Name : Engines.Integer_Property) return Integer;
function Is_Simple_Ref
(Engine : access Engines.Contexts.Context;
Element : Asis.Declaration;
Name : Engines.Boolean_Property) return Boolean;
end Properties.Definitions.Component_Definition;
|
mirror/ncurses | Ada | 10,443 | adb | ------------------------------------------------------------------------------
-- --
-- GNAT ncurses Binding Samples --
-- --
-- ncurses --
-- --
-- B O D Y --
-- --
------------------------------------------------------------------------------
-- Copyright 2020 Thomas E. Dickey --
-- Copyright 2000-2006,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: Eugene V. Melaragno <[email protected]> 2000
-- Version Control
-- $Revision: 1.7 $
-- $Date: 2020/02/02 23:34:34 $
-- Binding Version 01.00
------------------------------------------------------------------------------
with ncurses2.util; use ncurses2.util;
with ncurses2.genericPuts;
with Terminal_Interface.Curses; use Terminal_Interface.Curses;
procedure ncurses2.color_edit is
use Int_IO;
type RGB_Enum is (Redx, Greenx, Bluex);
procedure change_color (current : Color_Number;
field : RGB_Enum;
value : RGB_Value;
usebase : Boolean);
procedure change_color (current : Color_Number;
field : RGB_Enum;
value : RGB_Value;
usebase : Boolean) is
red, green, blue : RGB_Value;
begin
if usebase then
Color_Content (current, red, green, blue);
else
red := 0;
green := 0;
blue := 0;
end if;
case field is
when Redx => red := red + value;
when Greenx => green := green + value;
when Bluex => blue := blue + value;
end case;
declare
begin
Init_Color (current, red, green, blue);
exception
when Curses_Exception => Beep;
end;
end change_color;
package x is new ncurses2.genericPuts (100); use x;
tmpb : x.BS.Bounded_String;
tmp4 : String (1 .. 4);
tmp6 : String (1 .. 6);
tmp8 : String (1 .. 8);
-- This would be easier if Ada had a Bounded_String
-- defined as a class instead of the inferior generic package,
-- then I could define Put, Add, and Get for them. Blech.
value : RGB_Value := 0;
red, green, blue : RGB_Value;
max_colors : constant Natural := Number_Of_Colors;
current : Color_Number := 0;
field : RGB_Enum := Redx;
this_c : Key_Code := 0;
begin
Refresh;
for i in Color_Number'(0) .. Color_Number (Number_Of_Colors) loop
Init_Pair (Color_Pair (i), White, i);
end loop;
Move_Cursor (Line => Lines - 2, Column => 0);
Add (Str => "Number: ");
myPut (tmpb, Integer (value));
myAdd (Str => tmpb);
loop
Switch_Character_Attribute (On => False,
Attr => (Bold_Character => True,
others => False));
Add (Line => 0, Column => 20, Str => "Color RGB Value Editing");
Switch_Character_Attribute (On => False,
Attr => (Bold_Character => True,
others => False));
for i in Color_Number'(0) .. Color_Number (Number_Of_Colors) loop
Move_Cursor (Line => 2 + Line_Position (i), Column => 0);
if current = i then
Add (Ch => '>');
else
Add (Ch => ' ');
end if;
-- TODO if i <= color_names'Max then
Put (tmp8, Integer (i));
Set_Character_Attributes (Color => Color_Pair (i));
Add (Str => " ");
Set_Character_Attributes;
Refresh;
Color_Content (i, red, green, blue);
Add (Str => " R = ");
if current = i and field = Redx then
Switch_Character_Attribute (On => True,
Attr => (Stand_Out => True,
others => False));
end if;
Put (tmp4, Integer (red));
Add (Str => tmp4);
if current = i and field = Redx then
Set_Character_Attributes;
end if;
Add (Str => " G = ");
if current = i and field = Greenx then
Switch_Character_Attribute (On => True,
Attr => (Stand_Out => True,
others => False));
end if;
Put (tmp4, Integer (green));
Add (Str => tmp4);
if current = i and field = Greenx then
Set_Character_Attributes;
end if;
Add (Str => " B = ");
if current = i and field = Bluex then
Switch_Character_Attribute (On => True,
Attr => (Stand_Out => True,
others => False));
end if;
Put (tmp4, Integer (blue));
Add (Str => tmp4);
if current = i and field = Bluex then
Set_Character_Attributes;
end if;
Set_Character_Attributes;
Add (Ch => ')');
end loop;
Add (Line => Line_Position (Number_Of_Colors + 3), Column => 0,
Str => "Use up/down to select a color, left/right to change " &
"fields.");
Add (Line => Line_Position (Number_Of_Colors + 4), Column => 0,
Str => "Modify field by typing nnn=, nnn-, or nnn+. ? for help.");
Move_Cursor (Line => 2 + Line_Position (current), Column => 0);
this_c := Getchar;
if Is_Digit (this_c) then
value := 0;
end if;
case this_c is
when KEY_UP =>
current := (current - 1) mod Color_Number (max_colors);
when KEY_DOWN =>
current := (current + 1) mod Color_Number (max_colors);
when KEY_RIGHT =>
field := RGB_Enum'Val ((RGB_Enum'Pos (field) + 1) mod 3);
when KEY_LEFT =>
field := RGB_Enum'Val ((RGB_Enum'Pos (field) - 1) mod 3);
when
Character'Pos ('0') |
Character'Pos ('1') |
Character'Pos ('2') |
Character'Pos ('3') |
Character'Pos ('4') |
Character'Pos ('5') |
Character'Pos ('6') |
Character'Pos ('7') |
Character'Pos ('8') |
Character'Pos ('9') =>
value := value * 10 + RGB_Value (ctoi (Code_To_Char (this_c)));
when Character'Pos ('+') =>
change_color (current, field, value, True);
when Character'Pos ('-') =>
change_color (current, field, -value, True);
when Character'Pos ('=') =>
change_color (current, field, value, False);
when Character'Pos ('?') =>
Erase;
P (" RGB Value Editing Help");
P ("");
P ("You are in the RGB value editor. Use the arrow keys to " &
"select one of");
P ("the fields in one of the RGB triples of the current colors;" &
" the one");
P ("currently selected will be reverse-video highlighted.");
P ("");
P ("To change a field, enter the digits of the new value; they" &
" are echoed");
P ("as entered. Finish by typing `='. The change will take" &
" effect instantly.");
P ("To increment or decrement a value, use the same procedure," &
" but finish");
P ("with a `+' or `-'.");
P ("");
P ("To quit, do `x' or 'q'");
Pause;
Erase;
when Character'Pos ('q') |
Character'Pos ('x') =>
null;
when others =>
Beep;
end case;
Move_Cursor (Line => Lines - 2, Column => 0);
Put (tmp6, Integer (value));
Add (Str => "Number: " & tmp6);
Clear_To_End_Of_Line;
exit when this_c = Character'Pos ('x') or
this_c = Character'Pos ('q');
end loop;
Erase;
End_Windows;
end ncurses2.color_edit;
|
AdaCore/gpr | Ada | 6,105 | adb | ------------------------------------------------------------------------------
-- --
-- GPR2 PROJECT MANAGER --
-- --
-- Copyright (C) 2019-2023, AdaCore --
-- --
-- This is free software; you can redistribute it and/or modify it under --
-- terms of the GNU General Public License as published by the Free Soft- --
-- ware Foundation; either version 3, or (at your option) any later ver- --
-- sion. This software is distributed in the hope that it will be useful, --
-- but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHAN- --
-- TABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public --
-- License for more details. You should have received a copy of the GNU --
-- General Public License distributed with GNAT; see file COPYING. If not, --
-- see <http://www.gnu.org/licenses/>. --
-- --
------------------------------------------------------------------------------
with Ada.Strings.Unbounded;
with Ada.Text_IO;
with GPR2.Compilation.Registry;
with GPR2.Options;
with GPR2.Project.Registry.Pack;
with GPRtools.Command_Line;
package body GPRclean.Options is
procedure On_Switch
(Parser : GPRtools.Command_Line.Command_Line_Parser'Class;
Res : not null access GPRtools.Command_Line.Command_Line_Result'Class;
Arg : GPRtools.Command_Line.Switch_Type;
Index : String;
Param : String);
---------------
-- On_Switch --
---------------
procedure On_Switch
(Parser : GPRtools.Command_Line.Command_Line_Parser'Class;
Res : not null access GPRtools.Command_Line.Command_Line_Result'Class;
Arg : GPRtools.Command_Line.Switch_Type;
Index : String;
Param : String)
is
pragma Unreferenced (Parser, Index);
use type GPRtools.Command_Line.Switch_Type;
Result : constant access Object := Object (Res.all)'Access;
begin
if Arg = "-r" then
Result.All_Projects := True;
elsif Arg = "-n" then
Result.Dry_Run := True;
elsif Arg = "--autoconf" then
Result.Add_Switch
(Switch => GPR2.Options.Autoconf,
Param => Param,
Index => "");
Result.Remove_Config := True;
elsif Arg = "-c" then
Result.Remain_Useful := True;
elsif Arg = "-p" then
Result.Remove_Empty_Dirs := True;
elsif Arg = "-f" then
Result.Force_Deletions := True;
end if;
end On_Switch;
------------------------------
-- Parse_Attribute_Switches --
------------------------------
procedure Parse_Attribute_Switches
(Parser : GPRtools.Options.Command_Line_Parser;
Options : in out Object;
Values : GPR2.Containers.Source_Value_List)
is
package PRP renames GPR2.Project.Registry.Pack;
begin
Parser.Get_Opt
(From_Pack => PRP.Clean, Values => Values, Result => Options);
end Parse_Attribute_Switches;
------------------------
-- Parse_Command_Line --
------------------------
procedure Parse_Command_Line
(Parser : GPRtools.Options.Command_Line_Parser;
Options : in out Object)
is
use Ada.Strings.Unbounded;
begin
Parser.Get_Opt (Options);
-- Now read arguments
for Arg of Options.Args loop
Options.Mains.Insert (Filename_Type (Arg));
end loop;
Options.Arg_Mains := not Options.Mains.Is_Empty;
if Options.Slave_Env = Null_Unbounded_String
and then Options.Distributed_Mode
then
Options.Slave_Env := To_Unbounded_String
(GPR2.Compilation.Registry.Compute_Env
(Options.Tree.all, Options.Slave_Env_Auto));
if Options.Slave_Env_Auto and then Options.Verbose then
Ada.Text_IO.Put_Line
("slave environment is " & To_String (Options.Slave_Env));
end if;
end if;
end Parse_Command_Line;
-----------
-- Setup --
-----------
procedure Setup
(Parser : out GPRtools.Options.Command_Line_Parser)
is
use GPRtools.Command_Line;
Clean_Group : GPRtools.Command_Line.Argument_Group;
begin
GPRtools.Options.Setup (GPRtools.Clean);
Parser := GPRtools.Options.Create
("2018",
Cmd_Line => "[-P<proj>|<proj.gpr>] [opts] [mains]",
Help => "'mains' being zero or more file names",
Allow_Distributed => True,
Allow_Autoconf => False);
Clean_Group := Parser.Add_Argument_Group
("clean",
Callback => On_Switch'Access,
Help => "gprclean specific switches.");
Parser.Add_Argument
(Clean_Group,
Create
("-r",
Help => "Clean all projects recursively"));
Parser.Add_Argument
(Clean_Group,
Create
("-n",
Help => "Nothing to do: only list files to delete"));
Parser.Add_Argument
(Clean_Group,
Create
(Name => "--autoconf",
Help => "Specify generated config project file name",
In_Switch_Attr => False,
Delimiter => Equal,
Parameter => "file.cgpr"));
Parser.Add_Argument
(Clean_Group,
Create
("-c",
Help => "Only delete compiler generated files"));
Parser.Add_Argument
(Clean_Group,
Create
("-p",
Help => "Remove empty build directories"));
Parser.Add_Argument
(Clean_Group,
Create
("-f",
Help => "Force deletions of unwritable files"));
end Setup;
end GPRclean.Options;
|
AdaCore/langkit | Ada | 1,158 | adb | -- Check that the solver correctly handles an equation that involve a cycle in
-- variable definitions, when that cycle cannot be resolved.
with Langkit_Support.Adalog.Main_Support;
use Langkit_Support.Adalog.Main_Support;
procedure Main is
use T_Solver, Refs, Solver_Ifc;
function Add (Vals : Value_Array) return Integer
is (Vals (1) + Vals (2));
X : constant Refs.Logic_Var := Create ("X");
Y : constant Refs.Logic_Var := Create ("Y");
Z : constant Refs.Logic_Var := Create ("Z");
-- Simple case: a N_Propagate relation depends on two variables defined by
-- two separate relations.
R1 : constant Relation :=
R_All ((N_Propagate (Z, Combiner (Add'Access, 2, "Add"), (X, Y)),
Assign (X, 1),
Assign (Y, 2)));
-- More complex case: the N_Propagate relation depends on itself, but an
-- assignment allows the scheduler to break the cycle.
R2 : constant Relation :=
R_All ((N_Propagate (Z, Combiner (Add'Access, 2, "Add"), (X, Y)),
Propagate (Z, Y),
Assign (Z, 1),
Assign (X, 0)));
begin
Solve_All (R1);
Solve_All (R2);
end Main;
|
AdaCore/libadalang | Ada | 72 | ads | package Root_Pack is
type Root is tagged null record;
end Root_Pack;
|
reznikmm/matreshka | Ada | 19,050 | 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_Intervals is
-------------------
-- Enter_Element --
-------------------
overriding procedure Enter_Element
(Self : not null access constant UML_Interval_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_Interval
(AMF.UML.Intervals.UML_Interval_Access (Self),
Control);
end if;
end Enter_Element;
-------------------
-- Leave_Element --
-------------------
overriding procedure Leave_Element
(Self : not null access constant UML_Interval_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_Interval
(AMF.UML.Intervals.UML_Interval_Access (Self),
Control);
end if;
end Leave_Element;
-------------------
-- Visit_Element --
-------------------
overriding procedure Visit_Element
(Self : not null access constant UML_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) is
begin
if Iterator in AMF.Visitors.UML_Iterators.UML_Iterator'Class then
AMF.Visitors.UML_Iterators.UML_Iterator'Class
(Iterator).Visit_Interval
(Visitor,
AMF.UML.Intervals.UML_Interval_Access (Self),
Control);
end if;
end Visit_Element;
-------------
-- Get_Max --
-------------
overriding function Get_Max
(Self : not null access constant UML_Interval_Proxy)
return AMF.UML.Value_Specifications.UML_Value_Specification_Access is
begin
return
AMF.UML.Value_Specifications.UML_Value_Specification_Access
(AMF.Internals.Helpers.To_Element
(AMF.Internals.Tables.UML_Attributes.Internal_Get_Max
(Self.Element)));
end Get_Max;
-------------
-- Set_Max --
-------------
overriding procedure Set_Max
(Self : not null access UML_Interval_Proxy;
To : AMF.UML.Value_Specifications.UML_Value_Specification_Access) is
begin
AMF.Internals.Tables.UML_Attributes.Internal_Set_Max
(Self.Element,
AMF.Internals.Helpers.To_Element
(AMF.Elements.Element_Access (To)));
end Set_Max;
-------------
-- Get_Min --
-------------
overriding function Get_Min
(Self : not null access constant UML_Interval_Proxy)
return AMF.UML.Value_Specifications.UML_Value_Specification_Access is
begin
return
AMF.UML.Value_Specifications.UML_Value_Specification_Access
(AMF.Internals.Helpers.To_Element
(AMF.Internals.Tables.UML_Attributes.Internal_Get_Min
(Self.Element)));
end Get_Min;
-------------
-- Set_Min --
-------------
overriding procedure Set_Min
(Self : not null access UML_Interval_Proxy;
To : AMF.UML.Value_Specifications.UML_Value_Specification_Access) is
begin
AMF.Internals.Tables.UML_Attributes.Internal_Set_Min
(Self.Element,
AMF.Internals.Helpers.To_Element
(AMF.Elements.Element_Access (To)));
end Set_Min;
--------------
-- Get_Type --
--------------
overriding function Get_Type
(Self : not null access constant UML_Interval_Proxy)
return AMF.UML.Types.UML_Type_Access is
begin
return
AMF.UML.Types.UML_Type_Access
(AMF.Internals.Helpers.To_Element
(AMF.Internals.Tables.UML_Attributes.Internal_Get_Type
(Self.Element)));
end Get_Type;
--------------
-- Set_Type --
--------------
overriding procedure Set_Type
(Self : not null access UML_Interval_Proxy;
To : AMF.UML.Types.UML_Type_Access) is
begin
AMF.Internals.Tables.UML_Attributes.Internal_Set_Type
(Self.Element,
AMF.Internals.Helpers.To_Element
(AMF.Elements.Element_Access (To)));
end Set_Type;
---------------------------
-- Get_Client_Dependency --
---------------------------
overriding function Get_Client_Dependency
(Self : not null access constant UML_Interval_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_Interval_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_Interval_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_Interval_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_Interval_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;
-----------------------------------
-- Get_Owning_Template_Parameter --
-----------------------------------
overriding function Get_Owning_Template_Parameter
(Self : not null access constant UML_Interval_Proxy)
return AMF.UML.Template_Parameters.UML_Template_Parameter_Access is
begin
return
AMF.UML.Template_Parameters.UML_Template_Parameter_Access
(AMF.Internals.Helpers.To_Element
(AMF.Internals.Tables.UML_Attributes.Internal_Get_Owning_Template_Parameter
(Self.Element)));
end Get_Owning_Template_Parameter;
-----------------------------------
-- Set_Owning_Template_Parameter --
-----------------------------------
overriding procedure Set_Owning_Template_Parameter
(Self : not null access UML_Interval_Proxy;
To : AMF.UML.Template_Parameters.UML_Template_Parameter_Access) is
begin
AMF.Internals.Tables.UML_Attributes.Internal_Set_Owning_Template_Parameter
(Self.Element,
AMF.Internals.Helpers.To_Element
(AMF.Elements.Element_Access (To)));
end Set_Owning_Template_Parameter;
----------------------------
-- Get_Template_Parameter --
----------------------------
overriding function Get_Template_Parameter
(Self : not null access constant UML_Interval_Proxy)
return AMF.UML.Template_Parameters.UML_Template_Parameter_Access is
begin
return
AMF.UML.Template_Parameters.UML_Template_Parameter_Access
(AMF.Internals.Helpers.To_Element
(AMF.Internals.Tables.UML_Attributes.Internal_Get_Template_Parameter
(Self.Element)));
end Get_Template_Parameter;
----------------------------
-- Set_Template_Parameter --
----------------------------
overriding procedure Set_Template_Parameter
(Self : not null access UML_Interval_Proxy;
To : AMF.UML.Template_Parameters.UML_Template_Parameter_Access) is
begin
AMF.Internals.Tables.UML_Attributes.Internal_Set_Template_Parameter
(Self.Element,
AMF.Internals.Helpers.To_Element
(AMF.Elements.Element_Access (To)));
end Set_Template_Parameter;
-------------------
-- Boolean_Value --
-------------------
overriding function Boolean_Value
(Self : not null access constant UML_Interval_Proxy)
return AMF.Optional_Boolean is
begin
-- Generated stub: replace with real body!
pragma Compile_Time_Warning (Standard.True, "Boolean_Value unimplemented");
raise Program_Error with "Unimplemented procedure UML_Interval_Proxy.Boolean_Value";
return Boolean_Value (Self);
end Boolean_Value;
-------------------
-- Integer_Value --
-------------------
overriding function Integer_Value
(Self : not null access constant UML_Interval_Proxy)
return AMF.Optional_Integer is
begin
-- Generated stub: replace with real body!
pragma Compile_Time_Warning (Standard.True, "Integer_Value unimplemented");
raise Program_Error with "Unimplemented procedure UML_Interval_Proxy.Integer_Value";
return Integer_Value (Self);
end Integer_Value;
------------------------
-- Is_Compatible_With --
------------------------
overriding function Is_Compatible_With
(Self : not null access constant UML_Interval_Proxy;
P : AMF.UML.Parameterable_Elements.UML_Parameterable_Element_Access)
return Boolean is
begin
-- Generated stub: replace with real body!
pragma Compile_Time_Warning (Standard.True, "Is_Compatible_With unimplemented");
raise Program_Error with "Unimplemented procedure UML_Interval_Proxy.Is_Compatible_With";
return Is_Compatible_With (Self, P);
end Is_Compatible_With;
-------------------
-- Is_Computable --
-------------------
overriding function Is_Computable
(Self : not null access constant UML_Interval_Proxy)
return Boolean is
begin
-- Generated stub: replace with real body!
pragma Compile_Time_Warning (Standard.True, "Is_Computable unimplemented");
raise Program_Error with "Unimplemented procedure UML_Interval_Proxy.Is_Computable";
return Is_Computable (Self);
end Is_Computable;
-------------
-- Is_Null --
-------------
overriding function Is_Null
(Self : not null access constant UML_Interval_Proxy)
return Boolean is
begin
-- Generated stub: replace with real body!
pragma Compile_Time_Warning (Standard.True, "Is_Null unimplemented");
raise Program_Error with "Unimplemented procedure UML_Interval_Proxy.Is_Null";
return Is_Null (Self);
end Is_Null;
----------------
-- Real_Value --
----------------
overriding function Real_Value
(Self : not null access constant UML_Interval_Proxy)
return AMF.Optional_Real is
begin
-- Generated stub: replace with real body!
pragma Compile_Time_Warning (Standard.True, "Real_Value unimplemented");
raise Program_Error with "Unimplemented procedure UML_Interval_Proxy.Real_Value";
return Real_Value (Self);
end Real_Value;
------------------
-- String_Value --
------------------
overriding function String_Value
(Self : not null access constant UML_Interval_Proxy)
return AMF.Optional_String is
begin
-- Generated stub: replace with real body!
pragma Compile_Time_Warning (Standard.True, "String_Value unimplemented");
raise Program_Error with "Unimplemented procedure UML_Interval_Proxy.String_Value";
return String_Value (Self);
end String_Value;
---------------------
-- Unlimited_Value --
---------------------
overriding function Unlimited_Value
(Self : not null access constant UML_Interval_Proxy)
return AMF.Optional_Unlimited_Natural is
begin
-- Generated stub: replace with real body!
pragma Compile_Time_Warning (Standard.True, "Unlimited_Value unimplemented");
raise Program_Error with "Unimplemented procedure UML_Interval_Proxy.Unlimited_Value";
return Unlimited_Value (Self);
end Unlimited_Value;
-------------------------
-- All_Owning_Packages --
-------------------------
overriding function All_Owning_Packages
(Self : not null access constant UML_Interval_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_Interval_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_Interval_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_Interval_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_Interval_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_Interval_Proxy.Namespace";
return Namespace (Self);
end Namespace;
---------------------------
-- Is_Template_Parameter --
---------------------------
overriding function Is_Template_Parameter
(Self : not null access constant UML_Interval_Proxy)
return Boolean is
begin
-- Generated stub: replace with real body!
pragma Compile_Time_Warning (Standard.True, "Is_Template_Parameter unimplemented");
raise Program_Error with "Unimplemented procedure UML_Interval_Proxy.Is_Template_Parameter";
return Is_Template_Parameter (Self);
end Is_Template_Parameter;
end AMF.Internals.UML_Intervals;
|
reznikmm/spawn | Ada | 5,899 | ads | --
-- Copyright (C) 2018-2022, AdaCore
--
-- SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
--
with Ada.Streams;
with Interfaces.C.Strings;
package Spawn.Posix is
function open
(pathname : Interfaces.C.char_array;
flags : Interfaces.C.int;
mode : Interfaces.C.int) return Interfaces.C.int
with Import, Convention => C, External_Name => "open";
function close (fd : Interfaces.C.int) return Interfaces.C.int
with Import, Convention => C, External_Name => "close";
function read
(fd : Interfaces.C.int;
buf : out Ada.Streams.Stream_Element_Array;
count : Interfaces.C.size_t)
return Interfaces.C.size_t
with Import, Convention => C, External_Name => "read";
function write
(fd : Interfaces.C.int;
buf : Ada.Streams.Stream_Element_Array;
count : Interfaces.C.size_t)
return Interfaces.C.size_t
with Import, Convention => C, External_Name => "write";
type Pipe_Ends is (Read_End, Write_End);
type Fd_Pair is array (Pipe_Ends) of Interfaces.C.int
with Convention => C;
function pipe2 (pipefd : out Fd_Pair; flags : Interfaces.C.int)
return Interfaces.C.int
with Import, Convention => C, External_Name => "pipe2";
O_CLOEXEC : constant Interfaces.C.int
with Import, Convention => C, External_Name => "SPAWN_O_CLOEXEC";
O_NONBLOCK : constant Interfaces.C.int
with Import, Convention => C, External_Name => "SPAWN_O_NONBLOCK";
O_RDWR : constant Interfaces.C.int
with Import, Convention => C, External_Name => "SPAWN_O_RDWR";
O_NOCTTY : constant Interfaces.C.int
with Import, Convention => C, External_Name => "SPAWN_O_NOCTTY";
POLLIN : constant Interfaces.C.unsigned_short
with Import, Convention => C, External_Name => "SPAWN_POLLIN";
POLLOUT : constant Interfaces.C.unsigned_short
with Import, Convention => C, External_Name => "SPAWN_POLLOUT";
POLLHUP : constant Interfaces.C.unsigned_short
with Import, Convention => C, External_Name => "SPAWN_POLLHUP";
--
function fork return Interfaces.C.int
with Import, Convention => C, External_Name => "fork";
function kill
(pid : Interfaces.C.int;
sig : Interfaces.C.int) return Interfaces.C.int
with Import, Convention => C, External_Name => "kill";
function dup2
(oldfd : Interfaces.C.int;
newfd : Interfaces.C.int)
return Interfaces.C.int
with Import, Convention => C, External_Name => "dup2";
function chdir (path : Interfaces.C.Strings.chars_ptr)
return Interfaces.C.int
with Import, Convention => C, External_Name => "chdir";
type chars_ptr_array is array (Natural range <>) of
aliased Interfaces.C.Strings.chars_ptr;
function execve
(file : Interfaces.C.Strings.chars_ptr;
argv : chars_ptr_array;
anvp : chars_ptr_array)
return Interfaces.C.int
with Import, Convention => C, External_Name => "execve";
type pollfd is record
fd : Interfaces.C.int;
events : Interfaces.C.unsigned_short;
revents : Interfaces.C.unsigned_short;
end record with Convention => C;
type pollfd_array is array (Positive range <>) of pollfd;
function poll
(fds : in out pollfd_array;
nfds : Interfaces.C.unsigned_long;
timeout : Interfaces.C.int) return Interfaces.C.int
with Import, Convention => C, External_Name => "poll";
function waitpid
(pid : Interfaces.C.int;
wstatus : access Interfaces.C.unsigned;
options : Interfaces.C.int) return Interfaces.C.int
with Import, Convention => C, External_Name => "waitpid";
WNOHANG : constant Interfaces.C.int
with Import, Convention => C, External_Name => "SPAWN_WNOHANG";
function fcntl
(fd : Interfaces.C.int;
cmd : Interfaces.C.int;
flags : Interfaces.C.int) return Interfaces.C.int
with Import, Convention => C, External_Name => "__spawn_fcntli";
F_SETFD : constant Interfaces.C.int
with Import, Convention => C, External_Name => "SPAWN_F_SETFD";
F_SETFL : constant Interfaces.C.int
with Import, Convention => C, External_Name => "SPAWN_F_SETFL";
FD_CLOEXEC : constant Interfaces.C.int
with Import, Convention => C, External_Name => "SPAWN_FD_CLOEXEC";
function ioctl
(fd : Interfaces.C.int;
cmd : Interfaces.C.int;
arg : Interfaces.C.int) return Interfaces.C.int
with Import, Convention => C, External_Name => "__spawn_ioctli";
TIOCSCTTY : constant Interfaces.C.int
with Import, Convention => C, External_Name => "SPAWN_TIOCSCTTY";
subtype constrained_chars_ptr_array is
Interfaces.C.Strings.chars_ptr_array (1 .. Interfaces.C.size_t'Last);
environ : constrained_chars_ptr_array
with Import, Convention => C, External_Name => "environ";
-- Errno values
EINTR : constant Interfaces.C.int
with Import, Convention => C, External_Name => "SPAWN_EINTR";
EAGAIN : constant Interfaces.C.int
with Import, Convention => C, External_Name => "SPAWN_EAGAIN";
function posix_openpt
(flags : Interfaces.C.int) return Interfaces.C.int
with Import, Convention => C, External_Name => "posix_openpt";
function grantpt (fd : Interfaces.C.int) return Interfaces.C.int
with Import, Convention => C, External_Name => "grantpt";
function unlockpt (fd : Interfaces.C.int) return Interfaces.C.int
with Import, Convention => C, External_Name => "unlockpt";
function ptsname_r
(fd : Interfaces.C.int;
buf : out Interfaces.C.char_array;
buflen : Interfaces.C.size_t) return Interfaces.C.int
with Import, Convention => C, External_Name => "ptsname_r";
function setsid return Interfaces.C.int
with Import, Convention => C, External_Name => "setsid";
end Spawn.Posix;
|
melwyncarlo/ProjectEuler | Ada | 1,946 | adb | with Ada.Text_IO;
with Ada.Integer_Text_IO;
-- Copyright 2021 Melwyn Francis Carlo
procedure A047 is
use Ada.Text_IO;
use Ada.Integer_Text_IO;
-- File Reference: http://www.naturalnumbers.org/primes.html
Max_N : constant Integer := 5E5;
Array_Range : constant Integer := Integer (Float'Floor (
Float (Max_N) / 10.0));
FT : File_Type;
Last_Index : Natural;
Prime_Num : String (1 .. 10);
File_Name : constant String := "problems/003/PrimeNumbers_Upto_1000000";
I : Integer := 1;
Main_Count : Integer := 0;
Primes_List : array (Integer range 1 .. Array_Range) of
Integer := (others => 0);
J, Temp_I, I_By_5, Sub_Count : Integer;
begin
Open (FT, In_File, File_Name);
while not End_Of_File (FT) loop
Get_Line (FT, Prime_Num, Last_Index);
if (Integer'Value (Prime_Num (1 .. Last_Index)) > Max_N) then
exit;
end if;
Primes_List (I) := Integer'Value (Prime_Num (1 .. Last_Index));
I := I + 1;
end loop;
Close (FT);
I := 1000;
while I <= Max_N loop
J := 1;
Temp_I := I;
I_By_5 := Integer (Float'Floor (Float (I) / 5.0));
Sub_Count := 0;
while Primes_List (J) < I_By_5 loop
if (Temp_I mod Primes_List (J)) = 0 then
while (Temp_I mod Primes_List (J)) = 0 loop
Temp_I := Temp_I / Primes_List (J);
end loop;
Sub_Count := Sub_Count + 1;
if Sub_Count = 4 then
exit;
end if;
end if;
J := J + 1;
end loop;
if Sub_Count /= 4 then
Main_Count := 0;
else
Main_Count := Main_Count + 1;
if Main_Count = 4 then
exit;
end if;
end if;
I := I + 1;
end loop;
Put (I - 3, Width => 0);
end A047;
|
twdroeger/ada-awa | Ada | 7,150 | adb | -----------------------------------------------------------------------
-- awa-commands-tests -- Test the AWA.Commands
-- Copyright (C) 2020 Stephane Carrez
-- Written by Stephane Carrez ([email protected])
--
-- Licensed under the Apache License, Version 2.0 (the "License");
-- you may not use this file except in compliance with the License.
-- You may obtain a copy of the License at
--
-- http://www.apache.org/licenses/LICENSE-2.0
--
-- Unless required by applicable law or agreed to in writing, software
-- distributed under the License is distributed on an "AS IS" BASIS,
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-- See the License for the specific language governing permissions and
-- limitations under the License.
-----------------------------------------------------------------------
with Ada.Text_IO;
with Util.Processes;
with Util.Streams.Pipes;
with Util.Streams.Buffered;
with Util.Test_Caller;
with Util.Log.Loggers;
package body AWA.Commands.Tests is
Log : constant Util.Log.Loggers.Logger := Util.Log.Loggers.Create ("AWA.Commands.Tests");
package Caller is new Util.Test_Caller (Test, "Commands");
procedure Add_Tests (Suite : in Util.Tests.Access_Test_Suite) is
begin
Caller.Add_Test (Suite, "Test AWA.Commands.Start_Stop",
Test_Start_Stop'Access);
Caller.Add_Test (Suite, "Test AWA.Commands.List (tables)",
Test_List_Tables'Access);
Caller.Add_Test (Suite, "Test AWA.Commands.List (users)",
Test_List_Users'Access);
Caller.Add_Test (Suite, "Test AWA.Commands.List (sessions)",
Test_List_Sessions'Access);
Caller.Add_Test (Suite, "Test AWA.Commands.List (jobs)",
Test_List_Jobs'Access);
end Add_Tests;
-- ------------------------------
-- Execute the command and get the output in a string.
-- ------------------------------
procedure Execute (T : in out Test;
Command : in String;
Input : in String;
Output : in String;
Result : out Ada.Strings.Unbounded.Unbounded_String;
Status : in Natural := 0) is
P : aliased Util.Streams.Pipes.Pipe_Stream;
Buffer : Util.Streams.Buffered.Input_Buffer_Stream;
begin
if Input'Length > 0 then
Log.Info ("Execute: {0} < {1}", Command, Input);
elsif Output'Length > 0 then
Log.Info ("Execute: {0} > {1}", Command, Output);
else
Log.Info ("Execute: {0}", Command);
end if;
P.Set_Input_Stream (Input);
P.Set_Output_Stream (Output);
P.Open (Command, Util.Processes.READ_ALL);
-- Write on the process input stream.
Result := Ada.Strings.Unbounded.Null_Unbounded_String;
Buffer.Initialize (P'Unchecked_Access, 8192);
Buffer.Read (Result);
P.Close;
Ada.Text_IO.Put_Line (Ada.Strings.Unbounded.To_String (Result));
Log.Info ("Command result: {0}", Result);
Util.Tests.Assert_Equals (T, Status, P.Get_Exit_Status, "Command '" & Command & "' failed");
end Execute;
-- ------------------------------
-- Test start and stop command.
-- ------------------------------
procedure Test_Start_Stop (T : in out Test) is
Config : constant String := Util.Tests.Get_Parameter ("test_config_path");
task Start_Server is
entry Start;
entry Wait (Result : out Ada.Strings.Unbounded.Unbounded_String);
end Start_Server;
task body Start_Server is
Output : Ada.Strings.Unbounded.Unbounded_String;
begin
accept Start do
null;
end Start;
begin
T.Execute ("bin/awa_command -c " & Config & " start -m 26123",
"", "", Output, 0);
exception
when others =>
Output := Ada.Strings.Unbounded.To_Unbounded_String ("* exception *");
end;
accept Wait (Result : out Ada.Strings.Unbounded.Unbounded_String) do
Result := Output;
end Wait;
end Start_Server;
Result : Ada.Strings.Unbounded.Unbounded_String;
begin
-- Launch the 'start' command in a separate task because the command will hang.
Start_Server.Start;
delay 5.0;
-- Launch the 'stop' command, this should terminate the 'start' command.
T.Execute ("bin/awa_command -c " & Config & " stop -m 26123",
"", "", Result, 0);
-- Wait for the task result.
Start_Server.Wait (Result);
Util.Tests.Assert_Matches (T, "Starting...", Result, "AWA start command output");
end Test_Start_Stop;
procedure Test_List_Tables (T : in out Test) is
Config : constant String := Util.Tests.Get_Parameter ("test_config_path");
Result : Ada.Strings.Unbounded.Unbounded_String;
begin
T.Execute ("bin/awa_command -c " & Config & " list -t",
"", "", Result, 0);
Util.Tests.Assert_Matches (T, "awa_audit *[0-9]+", Result, "Missing awa_audit");
Util.Tests.Assert_Matches (T, "awa_session *[0-9]+", Result, "Missing awa_session");
Util.Tests.Assert_Matches (T, "entity_type *[0-9]+", Result, "Missing entity_type");
Util.Tests.Assert_Matches (T, "awa_wiki_page *[0-9]+", Result, "Missing awa_wiki_page");
end Test_List_Tables;
-- ------------------------------
-- Test the list -u command.
-- ------------------------------
procedure Test_List_Users (T : in out Test) is
Config : constant String := Util.Tests.Get_Parameter ("test_config_path");
Result : Ada.Strings.Unbounded.Unbounded_String;
begin
T.Execute ("bin/awa_command -c " & Config & " list -u",
"", "", Result, 0);
Util.Tests.Assert_Matches (T, "Joe Pot", Result, "Missing user");
Util.Tests.Assert_Matches (T, "[email protected]", Result, "Missing email");
end Test_List_Users;
-- ------------------------------
-- Test the list -s command.
-- ------------------------------
procedure Test_List_Sessions (T : in out Test) is
Config : constant String := Util.Tests.Get_Parameter ("test_config_path");
Result : Ada.Strings.Unbounded.Unbounded_String;
begin
T.Execute ("bin/awa_command -c " & Config & " list -s",
"", "", Result, 0);
Util.Tests.Assert_Matches (T, "Joe Pot", Result, "Missing user");
end Test_List_Sessions;
-- ------------------------------
-- Test the list -j command.
-- ------------------------------
procedure Test_List_Jobs (T : in out Test) is
Config : constant String := Util.Tests.Get_Parameter ("test_config_path");
Result : Ada.Strings.Unbounded.Unbounded_String;
begin
T.Execute ("bin/awa_command -c " & Config & " list -j",
"", "", Result, 0);
Util.Tests.Assert_Matches (T, "S_FACTORY", Result, "Missing factory");
Util.Tests.Assert_Matches (T, "Joe Pot", Result, "Missing user");
end Test_List_Jobs;
end AWA.Commands.Tests;
|
stcarrez/ada-enet | Ada | 2,186 | adb | -----------------------------------------------------------------------
-- echo_server -- A simple UDP echo server
-- Copyright (C) 2016 Stephane Carrez
-- Written by Stephane Carrez ([email protected])
--
-- Licensed under the Apache License, Version 2.0 (the "License");
-- you may not use this file except in compliance with the License.
-- You may obtain a copy of the License at
--
-- http://www.apache.org/licenses/LICENSE-2.0
--
-- Unless required by applicable law or agreed to in writing, software
-- distributed under the License is distributed on an "AS IS" BASIS,
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-- See the License for the specific language governing permissions and
-- limitations under the License.
-----------------------------------------------------------------------
package body Echo_Server is
protected body Logger is
procedure Echo (Content : in Message) is
begin
Id := Id + 1;
if Id <= List'Last then
List (Id).Id := Id;
List (Id).Content := Content.Content;
else
List (1 .. List'Last - 1) := List (2 .. List'Last);
List (List'Last).Id := Id;
List (List'Last).Content := Content.Content;
end if;
end Echo;
function Get return Message_List is
begin
return List;
end Get;
end Logger;
overriding
procedure Receive (Endpoint : in out Echo_Server;
From : in Net.Sockets.Sockaddr_In;
Packet : in out Net.Buffers.Buffer_Type) is
use type Net.Uint16;
Size : constant Net.Uint16 := Packet.Get_Data_Size (Net.Buffers.UDP_PACKET);
Status : Net.Error_Code;
Msg : Message;
Len : constant Natural
:= (if Size > Msg.Content'Length then Msg.Content'Length else Natural (Size));
begin
Packet.Get_String (Msg.Content (1 .. Len));
Packet.Set_Data_Size (Size);
Endpoint.Count := Endpoint.Count + 1;
Endpoint.Messages.Echo (Msg);
Endpoint.Send (To => From, Packet => Packet, Status => Status);
end Receive;
end Echo_Server;
|
AdaCore/libadalang | Ada | 487 | adb | package body Test is
function F(A : R) return R is
(A);
procedure P(A : R) is
begin
Put_Line("P of R");
end P;
function F(A : S) return S is
(A);
procedure P(A : S) is
begin
Put_Line("P of S");
end P;
procedure Test is
O1 : S;
O2 : R'Class := O1;
begin
O2
.
F
--% node.p_is_dispatching_call()
.
P
--% node.p_is_dispatching_call()
;
end Test;
end Test;
|
LaplaceKorea/curve25519-spark2014 | Ada | 12,973 | adb | package body Multiply_Proof with
SPARK_Mode
is
----------------------
-- Array_Diff_Lemma --
----------------------
procedure Array_Diff_Lemma
(Previous, Conversion : Big_Integer;
X, Y : Integer_255;
J, K : Index_Type)
is
begin
Partial_Product_Def (X, Y, J, K);
if K = 9 then
Diff_Step_J_Def (X, Y, J, K);
pragma Assert (Partial_Product (X, Y, J, 9)
= (if J mod 2 = 1 then 2 else 1) * X (J) * Y (9));
-- Stop case of Partial_Product (K = 9)
pragma Assert (To_Big_Integer (Array_Step_J (X, Y, J) (J + 9))
= (+(if J mod 2 = 1 and then 9 mod 2 = 1 then 2 else 1))
* (+X (J) * Y (9)));
pragma Assert (Diff_Step_J (X, Y, J, 9)
= Diff_Step_J (X, Y, J, 8)
+ (+(if J mod 2 = 1 and then 9 mod 2 = 1 then 2 else 1))
* (+X (J) * Y (9))
* Conversion_Array (J + 9));
-- Definition of Diff_Step_J
pragma Assert (Conversion
= Partial_Conversion (Array_Step_J (X, Y, J - 1), J + 8)
+ Diff_Step_J (X, Y, J, 9));
-- Proved thanks to the two assertions above
else
Diff_Step_J_Def (X, Y, J, K);
pragma Assert (X (J) in Min_Multiply .. Max_Multiply
and then
Y (K) in Min_Multiply .. Max_Multiply);
pragma Assert (Array_Step_J (X, Y, J - 1) (J + K) in
(-2) * Long_Long_Integer (J) * (2**27 - 1)**2
..
2 * Long_Long_Integer (J) * (2**27 - 1)**2);
-- Two assertions necessary to prove overflow checks in the
-- next assertion.
pragma Assert (Array_Step_J (X, Y, J) (J + K)
= Array_Step_J (X, Y, J - 1) (J + K)
+ (if J mod 2 = 1 and then K mod 2 = 1 then 2 else 1)
* X (J) * Y (K));
-- Definition of Partial_Product
pragma Assert ((+Array_Step_J (X, Y, J) (J + K)) * Conversion_Array (J + K)
= (+Array_Step_J (X, Y, J - 1) (J + K)
+ (+(if J mod 2 = 1 and then K mod 2 = 1 then 2 else 1))
* (+X (J)) * (+Y (K)))
* Conversion_Array (J + K));
pragma Assert (Diff_Step_J (X, Y, J, K)
= (if K = 0 then Zero else Diff_Step_J (X, Y, J, K - 1))
+ (+(if J mod 2 = 1 and then K mod 2 = 1 then 2 else 1))
* (+X (J)) * (+Y (K))
* Conversion_Array (J + K));
-- Definition of Diff_Step_J
end if;
end Array_Diff_Lemma;
------------------
-- Array_Step_J --
------------------
-- Construction of the array is very simple, it matches the postcondition
function Array_Step_J
(X, Y : Integer_255;
J : Index_Type)
return Integer_Curve25519
is
Result : Integer_Curve25519 (0 .. J + 9) := (others => 0);
begin
for K in 0 .. J loop
Result (K) := Partial_Product (X, Y, K);
pragma Loop_Invariant (for all L in 0 .. K =>
Result (L) = Partial_Product (X, Y, L));
end loop;
for K in J + 1 .. J + 9 loop
Result (K) := Partial_Product (X, Y, J, K - J);
pragma Loop_Invariant (for all L in J + 1 .. K =>
Result (L) = Partial_Product (X, Y, J, L - J));
end loop;
return Result;
end Array_Step_J;
--------------------------
-- Array_Step_J_To_Next --
--------------------------
procedure Array_Step_J_To_Next
(Product_Conversion : Big_Integer;
X, Y : Integer_255;
J : Index_Type)
is
Conversion, Previous : Big_Integer :=
(if J = 0
then Zero
else Partial_Conversion (Array_Step_J (X, Y, J), J - 1));
begin
if J > 0 then
Equal_To_Conversion
(Array_Step_J (X, Y, J), Array_Step_J (X, Y, J - 1), J - 1);
pragma Assert (Partial_Conversion (Array_Step_J (X, Y, J), J - 1)
= Partial_Conversion (Array_Step_J (X, Y, J - 1), J - 1));
-- By definition, Array_Step_J (X, Y, J) (0 .. J - 1)
-- = Array_Step_J (X, Y, J - 1) (0 .. J - 1),
-- so Equal_To_Conversion is applied to prove that their
-- partial conversions until J - 1 are equal.
end if;
for K in Index_Type loop
Previous := Conversion;
Conversion := Conversion
+ (+Array_Step_J (X, Y, J) (J + K))
* Conversion_Array (J + K);
if J = 0 then
Diff_Step_J_Def (X, Y, 0, K);
Partial_Product_Def (X, Y, 0, K);
-- Instantiating the definitions
if K = 0 then
pragma Assert (Conversion
= Partial_Conversion (Array_Step_J (X, Y, J), J + K));
-- The assertion is needed, otherwise the solvers cannot
-- prove first loop invariant in first iteration.
else
pragma Assert (Diff_Step_J (X, Y, J, K)
= Diff_Step_J (X, Y, J, K - 1)
+ (+X (0)) * (+Y (K))
* Conversion_Array (K));
-- Definition of Diff_Step_J
pragma Assert (Conversion
= Diff_Step_J (X, Y, J, K));
-- Discharges the provers to prove it afterwards
end if;
else
Array_Diff_Lemma (Previous, Conversion, X, Y, J, K);
-- To prove third and fourth loop invariants
end if;
pragma Loop_Invariant (Conversion
= Partial_Conversion (Array_Step_J (X, Y, J), J + K));
-- Conversion is increasingly equal to Partial_Conversion (Array_Step_J)
pragma Loop_Invariant (if J = 0 then Conversion = Diff_Step_J (X, Y, J, K));
pragma Loop_Invariant (if J > 0 and then K < 9
then
Conversion
= Partial_Conversion (Array_Step_J (X, Y, J - 1), J + K)
+ Diff_Step_J (X, Y, J, K));
pragma Loop_Invariant (if J > 0 and then K = 9
then
Conversion
= Partial_Conversion (Array_Step_J (X, Y, J - 1), J + 8)
+ Diff_Step_J (X, Y, J, 9));
-- The three loop invariants above are the same loop invariant,
-- split for different cases. It states that Conversion is equal
-- to something + Diff_Step_J (X, Y, J, K).
end loop;
end Array_Step_J_To_Next;
--------------------
-- Prove_Multiply --
--------------------
procedure Prove_Multiply (X, Y : Integer_255; Product : Product_Integer) is
X_Conversion, Product_Conversion : Big_Integer := Zero;
Old_X, Old_Product : Big_Integer;
begin
for J in Index_Type loop
Old_X := X_Conversion;
X_Conversion := X_Conversion + (+X (J)) * Conversion_Array (J);
-- X_Conversion = Partial_Conversion (X, J)
-- is partially increased to To_Big_Integer (X).
for K in Index_Type loop
Old_Product := Product_Conversion;
pragma Assert (Old_Product = Old_X * (+Y)
+ (if K = 0 then Zero else (+X (J)) * Conversion_Array (J)
* Partial_Conversion (Y, K - 1)));
-- Asserting loop invariants on Old_Product
Product_Conversion := Add_Factor (Product_Conversion, X, Y, J, K);
-- Using the function is necessary to provr precondition
-- of Split_Product.
Split_Product (Old_Product, Old_X, Product_Conversion, X, Y, J, K);
-- To prove second loop invariant
Diff_Step_J_Def (X, Y, J, K);
-- To prove first loop invariant
pragma Loop_Invariant (Product_Conversion
= Product_Conversion'Loop_Entry
+ Diff_Step_J (X, Y, J, K));
-- This loop invariant is used to prove that Product_Conversion
-- will be equal to Partial_Conversion (Array_Step_J (...))
-- at the end of the loop.
pragma Loop_Invariant (Product_Conversion
= Old_X * (+Y)
+ (+X (J)) * Conversion_Array (J)
* Partial_Conversion (Y, K));
-- Product_Conversion is equal to the product of the partial
-- conversion of X until J, and the partial conversion of Y
-- until K.
end loop;
Array_Step_J_To_Next (Product_Conversion, X, Y, J);
-- To prove first loop invariant
pragma Assert (Product_Conversion
= Old_X * (+Y)
+ (+X (J)) * Conversion_Array (J)
* Partial_Conversion (Y, 9));
pragma Assert (Partial_Conversion (Y, 9) = (+Y));
pragma Assert (Product_Conversion
= Old_X * (+Y)
+ (+X (J)) * Conversion_Array (J) * (+Y));
-- To prove third loop invariant
pragma Loop_Invariant (Product_Conversion
= Partial_Conversion (Array_Step_J (X, Y, J), J + 9));
-- At the end of this loop, will prove that Product_Conversion is
-- equal to (+Final_Array).
pragma Loop_Invariant (X_Conversion
= Partial_Conversion (X, J));
pragma Loop_Invariant (Product_Conversion
= X_Conversion * (+Y));
-- Distributivity of multiplication over addition.
end loop;
pragma Assert ((+X) = Partial_Conversion (X, 9));
Equal_To_Conversion (Array_Step_J (X, Y, 9), Product, 18);
end Prove_Multiply;
-------------------
-- Split_Product --
-------------------
procedure Split_Product
(Old_Product, Old_X, Product_Conversion : Big_Integer;
X, Y : Integer_255;
J, K : Index_Type)
is
begin
if J mod 2 = 1 and then K mod 2 = 1 then
pragma Assert (Product_Conversion
= Old_Product
+ (+X (J)) * (+Y (K))
* Conversion_Array (J + K) * (+2));
pragma Assert ((+2) * Conversion_Array (J + K)
= Conversion_Array (J) * Conversion_Array (K));
-- Case where Conversion_Array (J + K) * 2
-- = Conversion_Array (J) * Conversion_Array (K).
else
pragma Assert (Conversion_Array (J + K)
= Conversion_Array (J) * Conversion_Array (K));
-- Other case
end if;
if K > 0 then
pragma Assert (Product_Conversion
= Old_X * (+Y)
+ (+X (J))
* Conversion_Array (J) * Partial_Conversion (Y, K - 1)
+ (+X (J)) * (+Y (K))
* (+(if J mod 2 = 1 and then K mod 2 = 1 then 2 else 1))
* Conversion_Array (J + K));
-- Preconditions
pragma Assert ((+(if J mod 2 = 1 and then K mod 2 = 1 then 2 else 1))
* Conversion_Array (J + K)
= Conversion_Array (J) * Conversion_Array (K));
-- What was proved previously with case disjunction
pragma Assert (Partial_Conversion (Y, K)
= Partial_Conversion (Y, K - 1)
+ (+Y (K)) * Conversion_Array (K));
-- Definition of Partial_Conversion, needed for proof
pragma Assert ((+X (J))
* Conversion_Array (J) * Partial_Conversion (Y, K - 1)
+ (+X (J)) * (+Y (K))
* Conversion_Array (J) * Conversion_Array (K)
= (+X (J)) * Conversion_Array (J) * Partial_Conversion (Y, K));
-- Rearranging the expression using definition of Partial_Conversion
pragma Assert (Product_Conversion
= Old_X * (+Y)
+ (+X (J)) * Conversion_Array (J)
* Partial_Conversion (Y, K));
-- Proving the postcondition
end if;
end Split_Product;
end Multiply_Proof;
|
RREE/build-avr-ada-toolchain | Ada | 7,627 | adb | -- Copyright (C) 2016-2017, 2019 Free Software Foundation, Inc.
--
-- This file is part of the Cortex GNAT RTS project. This file 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 file 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.
--
-- As a special exception under Section 7 of GPL version 3, you are
-- granted additional permissions described in the GCC Runtime
-- Library Exception, version 3.1, as published by the Free Software
-- Foundation.
--
-- You should have received a copy of the GNU General Public License
-- and a copy of the GCC Runtime Library Exception along with this
-- program; see the files COPYING3 and COPYING.RUNTIME respectively.
-- If not, see <http://www.gnu.org/licenses/>.
-- This is the AVR version
with Ada.Unchecked_Conversion;
package body System.Secondary_Stack is
use type System.Parameters.Size_Type;
function Get_Sec_Stack return SS_Stack_Ptr;
-- pragma Import (C, Get_Sec_Stack, "__gnat_get_secondary_stack");
-- Return the pointer to the secondary stack of the current task.
-- We provide our own implementation for AVR-Ada
-----------------
-- SS_Allocate --
-----------------
procedure SS_Allocate
(Addr : out System.Address;
Storage_Size : SSE.Storage_Count)
is
use type System.Storage_Elements.Storage_Count;
Max_Align : constant SS_Ptr := SS_Ptr (Standard'Maximum_Alignment);
Mem_Request : SS_Ptr;
Stack : constant SS_Stack_Ptr := Get_Sec_Stack;
begin
-- Round up Storage_Size to the nearest multiple of the max alignment
-- value for the target. This ensures efficient stack access. First
-- perform a check to ensure that the rounding operation does not
-- overflow SS_Ptr.
if SSE.Storage_Count (SS_Ptr'Last) - Standard'Maximum_Alignment <
Storage_Size
then
raise Storage_Error;
end if;
Mem_Request := ((SS_Ptr (Storage_Size) + Max_Align - 1) / Max_Align) *
Max_Align;
-- Check if max stack usage is increasing
if Stack.Max - Stack.Top - Mem_Request < 0 then
-- If so, check if the stack is exceeded, noting Stack.Top points to
-- the first free byte (so the value of Stack.Top on a fully
-- allocated stack will be Stack.Size + 1). The comparison is formed
-- to prevent integer overflows.
if Stack.Size - Stack.Top - Mem_Request < -1 then
raise Storage_Error;
end if;
-- Record new max usage
Stack.Max := Stack.Top + Mem_Request;
end if;
-- Set resulting address and update top of stack pointer
Addr := Stack.Internal_Chunk (Stack.Top)'Address;
Stack.Top := Stack.Top + Mem_Request;
end SS_Allocate;
----------------
-- SS_Get_Max --
----------------
function SS_Get_Max return Long_Long_Integer is
begin
-- Stack.Max points to the first untouched byte in the stack, thus the
-- maximum number of bytes that have been allocated on the stack is one
-- less the value of Stack.Max.
return Long_Long_Integer (Get_Sec_Stack.Max - 1);
end SS_Get_Max;
-------------
-- SS_Init --
-------------
procedure SS_Init
(Stack : in out SS_Stack_Ptr;
Size : SP.Size_Type := SP.Unspecified_Size)
is
use Parameters;
begin
-- If the size of the secondary stack for a task has been specified via
-- the Secondary_Stack_Size aspect, then the compiler has allocated the
-- stack at compile time and the task create call will provide a pointer
-- to this stack. Otherwise, the task will be allocated a secondary
-- stack from the pool of default-sized secondary stacks created by the
-- binder.
if Stack = null then
-- Allocate a default-sized stack for the task.
if Size = Unspecified_Size
and then Binder_SS_Count > 0
and then Num_Of_Assigned_Stacks < Binder_SS_Count
then
-- The default-sized secondary stack pool is passed from the
-- binder to this package as an Address since it is not possible
-- to have a pointer to an array of unconstrained objects. A
-- pointer to the pool is obtainable via an unchecked conversion
-- to a constrained array of SS_Stacks that mirrors the one used
-- by the binder.
-- However, Ada understandably does not allow a local pointer to
-- a stack in the pool to be stored in a pointer outside of this
-- scope. While the conversion is safe in this case, since a view
-- of a global object is being used, using Unchecked_Access
-- would prevent users from specifying the restriction
-- No_Unchecked_Access whenever the secondary stack is used. As
-- a workaround, the local stack pointer is converted to a global
-- pointer via System.Address.
declare
type Stk_Pool_Array is array (1 .. Binder_SS_Count) of
aliased SS_Stack (Default_SS_Size);
type Stk_Pool_Access is access Stk_Pool_Array;
function To_Stack_Pool is new
Ada.Unchecked_Conversion (Address, Stk_Pool_Access);
pragma Warnings (Off);
function To_Global_Ptr is new
Ada.Unchecked_Conversion (Address, SS_Stack_Ptr);
pragma Warnings (On);
-- Suppress aliasing warning since the pointer we return will
-- be the only access to the stack.
Local_Stk_Address : System.Address;
begin
Num_Of_Assigned_Stacks := Num_Of_Assigned_Stacks + 1;
Local_Stk_Address :=
To_Stack_Pool
(Default_Sized_SS_Pool) (Num_Of_Assigned_Stacks)'Address;
Stack := To_Global_Ptr (Local_Stk_Address);
end;
-- Many run-times unconditionally bring in this package and call
-- SS_Init even though the secondary stack is not used by the
-- program. In this case return without assigning a stack as it will
-- never be used.
elsif Binder_SS_Count = 0 then
return;
else
raise Program_Error;
end if;
end if;
Stack.Top := 1;
Stack.Max := 1;
end SS_Init;
-------------
-- SS_Mark --
-------------
function SS_Mark return Mark_Id is
begin
return Mark_Id (Get_Sec_Stack.Top);
end SS_Mark;
procedure SS_Release (M : Mark_Id) is
begin
Get_Sec_Stack.Top := SS_Ptr (M);
end SS_Release;
-- this is the AVR version of a single threaded secondary stack
Secondary_Stack : SS_Stack_Ptr := null;
-- Pointer to the assigned secondary stack
function Get_Sec_Stack return SS_Stack_Ptr is
begin
-- If the pointer to the secondary stack is null then a stack has not
-- been allocated. A call to SS_Init will assign the binder generated
-- stack and will initialize it.
if Secondary_Stack = null then
SS_Init (Secondary_Stack);
end if;
return Secondary_Stack;
end Get_Sec_Stack;
end System.Secondary_Stack;
|
zhmu/ananas | Ada | 248 | ads | with Varsize3_Pkg2;
with Varsize3_Pkg3;
package Varsize3_Pkg1 is
type Arr is array (Positive range 1 .. Varsize3_Pkg2.Last_Index) of Boolean;
package My_G is new Varsize3_Pkg3 (Arr);
type Object is new My_G.Object;
end Varsize3_Pkg1;
|
reznikmm/matreshka | Ada | 4,077 | 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.Office_Target_Frame_Name_Attributes;
package Matreshka.ODF_Office.Target_Frame_Name_Attributes is
type Office_Target_Frame_Name_Attribute_Node is
new Matreshka.ODF_Office.Abstract_Office_Attribute_Node
and ODF.DOM.Office_Target_Frame_Name_Attributes.ODF_Office_Target_Frame_Name_Attribute
with null record;
overriding function Create
(Parameters : not null access Matreshka.DOM_Attributes.Attribute_L2_Parameters)
return Office_Target_Frame_Name_Attribute_Node;
overriding function Get_Local_Name
(Self : not null access constant Office_Target_Frame_Name_Attribute_Node)
return League.Strings.Universal_String;
end Matreshka.ODF_Office.Target_Frame_Name_Attributes;
|
jrmarino/zstd-ada | Ada | 4,544 | adb | -- This file is covered by the Internet Software Consortium (ISC) License
-- Reference: ../License.txt
package body Zstandard.Functions.Streaming_Decompression is
------------------
-- Initialize --
------------------
procedure Initialize
(mechanism : out Decompressor;
input_stream : not null access STR.Root_Stream_Type'Class)
is
use type Thin.ZSTD_DStream_ptr;
initResult : Thin.IC.size_t;
begin
mechanism.source_stream := input_stream;
mechanism.zstd_stream := Thin.ZSTD_createDStream;
if mechanism.zstd_stream = Thin.Null_DStream_pointer then
raise streaming_decompression_initialization with "ZSTD_createDStream failure";
end if;
initResult := Thin.ZSTD_initDStream (zds => mechanism.zstd_stream);
if Natural (Thin.ZSTD_isError (code => initResult)) /= 0 then
raise streaming_decompression_initialization with "ZSTD_initDStream failure";
end if;
end Initialize;
-----------------------
-- Decompress_Data --
-----------------------
procedure Decompress_Data
(mechanism : Decompressor;
complete : out Boolean;
output_data : out Output_Data_Container;
last_element : out Natural)
is
use type Thin.ZSTD_DStream_ptr;
sin_last : STR.Stream_Element_Offset := STR.Stream_Element_Offset (Recommended_Chunk_Size);
Last : STR.Stream_Element_Offset;
data_in : aliased Thin.IC.char_array := (1 .. Recommended_Chunk_Size => Thin.IC.nul);
data_out : aliased Thin.IC.char_array := (1 .. Output_container_size => Thin.IC.nul);
data_sin : STR.Stream_Element_Array (1 .. sin_last);
index : Thin.IC.size_t := data_in'First;
size_hint : Thin.IC.size_t;
inbuffer : aliased Thin.ZSTD_inBuffer_s :=
(src => Thin.ICS.To_Chars_Ptr (data_in'Unchecked_Access),
size => Recommended_Chunk_Size,
pos => 0);
outbuffer : aliased Thin.ZSTD_outBuffer_s :=
(dst => Thin.ICS.To_Chars_Ptr (data_out'Unchecked_Access),
size => Output_container_size,
pos => 0);
begin
if mechanism.zstd_stream = Thin.Null_DStream_pointer then
raise streaming_decompression_error with "Run initialize procedure first";
end if;
mechanism.source_stream.Read (Item => data_sin, Last => Last);
if Natural (Last) = 0 then
last_element := 0;
complete := True;
return;
end if;
data_in := convert_to_char_array (data_sin (1 .. Last), Recommended_Chunk_Size);
complete := (Natural (Last) /= Natural (Recommended_Chunk_Size));
size_hint := Thin.ZSTD_decompressStream (zds => mechanism.zstd_stream,
output => outbuffer'Unchecked_Access,
input => inbuffer'Unchecked_Access);
last_element := Natural (outbuffer.pos);
output_data (1 .. STR.Stream_Element_Offset (last_element)) :=
convert_to_stream_array (data_out, outbuffer.pos);
end Decompress_Data;
-------------------------------
-- convert_to_stream_array --
-------------------------------
function convert_to_stream_array
(char_data : Thin.IC.char_array;
number_characters : Thin.IC.size_t) return STR.Stream_Element_Array
is
product : STR.Stream_Element_Array (1 .. STR.Stream_Element_Offset (number_characters));
dondx : Thin.IC.size_t;
begin
for z in product'Range loop
dondx := Thin.IC.size_t (z);
product (z) := STR.Stream_Element (Character'Pos (Thin.IC.To_Ada (char_data (dondx))));
end loop;
return product;
end convert_to_stream_array;
-----------------------------
-- convert_to_char_array --
-----------------------------
function convert_to_char_array
(stream_data : STR.Stream_Element_Array;
output_array_size : Thin.IC.size_t) return Thin.IC.char_array
is
use type Thin.IC.size_t;
product : Thin.IC.char_array := (1 .. output_array_size => Thin.IC.nul);
dondx : Thin.IC.size_t := 1;
begin
for z in stream_data'Range loop
product (dondx) := Thin.IC.To_C (Character'Val (stream_data (z)));
dondx := dondx + 1;
end loop;
return product;
end convert_to_char_array;
end Zstandard.Functions.Streaming_Decompression;
|
onox/orka | Ada | 1,286 | ads | -- SPDX-License-Identifier: Apache-2.0
--
-- Copyright (c) 2016 onox <[email protected]>
--
-- Licensed under the Apache License, Version 2.0 (the "License");
-- you may not use this file except in compliance with the License.
-- You may obtain a copy of the License at
--
-- http://www.apache.org/licenses/LICENSE-2.0
--
-- Unless required by applicable law or agreed to in writing, software
-- distributed under the License is distributed on an "AS IS" BASIS,
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-- See the License for the specific language governing permissions and
-- limitations under the License.
with Orka.SIMD.SSE2.Doubles;
package Orka.SIMD.SSE4_1.Doubles.Swizzle is
pragma Pure;
use Orka.SIMD.SSE2.Doubles;
function Blend (Left, Right : m128d; Mask : Integer_32) return m128d
with Import, Convention => Intrinsic, External_Name => "__builtin_ia32_blendpd";
-- Select elements from two sources (Left and Right) using a constant mask
function Blend (Left, Right, Mask : m128d) return m128d
with Import, Convention => Intrinsic, External_Name => "__builtin_ia32_blendvpd";
-- Select elements from two sources (Left and Right) using a variable mask
end Orka.SIMD.SSE4_1.Doubles.Swizzle;
|
stcarrez/ada-util | Ada | 2,095 | ads | -----------------------------------------------------------------------
-- util-systems-dlls -- Windows shared library support
-- Copyright (C) 2013 Stephane Carrez
-- Written by Stephane Carrez ([email protected])
--
-- Licensed under the Apache License, Version 2.0 (the "License");
-- you may not use this file except in compliance with the License.
-- You may obtain a copy of the License at
--
-- http://www.apache.org/licenses/LICENSE-2.0
--
-- Unless required by applicable law or agreed to in writing, software
-- distributed under the License is distributed on an "AS IS" BASIS,
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-- See the License for the specific language governing permissions and
-- limitations under the License.
-----------------------------------------------------------------------
with System;
with Interfaces.C;
package Util.Systems.DLLs is
-- The shared library handle.
type Handle is private;
Null_Handle : constant Handle;
-- Exception raised when there is a problem loading a shared library.
Load_Error : exception;
-- Exception raised when a symbol cannot be found in a shared library.
Not_Found : exception;
Extension : constant String := ".dll";
subtype Flags is Interfaces.C.int;
-- Load the shared library with the given name or path and return a library handle.
-- Raises the <tt>Load_Error</tt> exception if the library cannot be loaded.
function Load (Path : in String;
Mode : in Flags := 0) return Handle;
-- Unload the shared library.
procedure Unload (Lib : in Handle);
-- Get a global symbol with the given name in the library.
-- Raises the <tt>Not_Found</tt> exception if the symbol does not exist.
function Get_Symbol (Lib : in Handle;
Name : in String) return System.Address;
private
type Handle is new System.Address;
Null_Handle : constant Handle := Handle (System.Null_Address);
end Util.Systems.DLLs;
|
sudoadminservices/bugbountyservices | Ada | 1,328 | ads | -- Copyright 2017 Jeff Foley. All rights reserved.
-- Use of this source code is governed by Apache 2 LICENSE that can be found in the LICENSE file.
name = "Wayback"
type = "archive"
function start()
setratelimit(1)
end
function vertical(ctx, domain)
local resp
local vurl = buildurl(domain)
local cfg = datasrc_config()
-- Check if the response data is in the graph database
if (cfg.ttl ~= nil and cfg.ttl > 0) then
resp = obtain_response(vurl, cfg.ttl)
end
if (resp == nil or resp == "") then
local err
resp, err = request({
url=vurl,
headers={['Content-Type']="application/json"},
})
if (err ~= nil and err ~= "") then
return
end
if (cfg.ttl ~= nil and cfg.ttl > 0) then
cache_response(vurl, resp)
end
end
sendnames(ctx, resp)
end
function buildurl(domain)
return "http://web.archive.org/cdx/search/cdx?url=*." .. domain .. "&output=json&collapse=urlkey"
end
function sendnames(ctx, content)
local names = find(content, subdomainre)
if names == nil then
return
end
local found = {}
for i, v in pairs(names) do
if found[v] == nil then
newname(ctx, v)
found[v] = true
end
end
end
|
Letractively/ada-ado | Ada | 10,677 | adb | -----------------------------------------------------------------------
-- ADO Objects Tests -- Tests for ADO.Objects
-- Copyright (C) 2011, 2012, 2013, 2014 Stephane Carrez
-- Written by Stephane Carrez ([email protected])
--
-- Licensed under the Apache License, Version 2.0 (the "License");
-- you may not use this file except in compliance with the License.
-- You may obtain a copy of the License at
--
-- http://www.apache.org/licenses/LICENSE-2.0
--
-- Unless required by applicable law or agreed to in writing, software
-- distributed under the License is distributed on an "AS IS" BASIS,
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-- See the License for the specific language governing permissions and
-- limitations under the License.
-----------------------------------------------------------------------
with Util.Test_Caller;
with ADO.Sessions;
with Regtests.Simple.Model;
with Regtests.Comments;
package body ADO.Objects.Tests is
use Util.Tests;
use type Ada.Containers.Hash_Type;
function Get_Allocate_Key (N : Identifier) return Object_Key;
function Get_Allocate_Key (N : Identifier) return Object_Key is
Result : Object_Key (Of_Type => KEY_INTEGER,
Of_Class => Regtests.Simple.Model.ALLOCATE_TABLE'Access);
begin
Set_Value (Result, N);
return Result;
end Get_Allocate_Key;
-- ------------------------------
-- Various tests on Hash and key comparison
-- ------------------------------
procedure Test_Key (T : in out Test) is
K1 : constant Object_Key := Get_Allocate_Key (1);
K2 : Object_Key (Of_Type => KEY_STRING,
Of_Class => Regtests.Simple.Model.USER_TABLE'Access);
K3 : Object_Key := K1;
K4 : Object_Key (Of_Type => KEY_INTEGER,
Of_Class => Regtests.Simple.Model.USER_TABLE'Access);
begin
T.Assert (not (K1 = K2), "Key on different tables must be different");
T.Assert (not (K2 = K4), "Key with different type must be different");
T.Assert (K1 = K3, "Keys are identical");
T.Assert (Equivalent_Elements (K1, K3), "Keys are identical");
T.Assert (Equivalent_Elements (K3, K1), "Keys are identical");
T.Assert (Hash (K1) = Hash (K3), "Hash of identical keys should be identical");
Set_Value (K3, 2);
T.Assert (not (K1 = K3), "Keys should be different");
T.Assert (Hash (K1) /= Hash (K3), "Hash should be different");
T.Assert (Hash (K1) /= Hash (K2), "Hash should be different");
Set_Value (K4, 1);
T.Assert (Hash (K1) /= Hash (K4),
"Hash on key with same value and different tables should be different");
T.Assert (not (K4 = K1), "Key on different tables should be different");
Set_Value (K2, 1);
T.Assert (Hash (K1) /= Hash (K2), "Hash should be different");
end Test_Key;
-- ------------------------------
-- Check:
-- Object_Ref := (reference counting)
-- Object_Ref.Copy
-- Object_Ref.Get_xxx generated method
-- Object_Ref.Set_xxx generated method
-- Object_Ref.=
-- ------------------------------
procedure Test_Object_Ref (T : in out Test) is
use type Regtests.Simple.Model.User_Ref;
Obj1 : Regtests.Simple.Model.User_Ref;
Null_Obj : Regtests.Simple.Model.User_Ref;
begin
T.Assert (Obj1 = Null_Obj, "Two null objects are identical");
for I in 1 .. 10 loop
Obj1.Set_Name ("User name");
T.Assert (Obj1.Get_Name = "User name", "User_Ref.Set_Name invalid result");
T.Assert (Obj1 /= Null_Obj, "Object is not identical as the null object");
declare
Obj2 : constant Regtests.Simple.Model.User_Ref := Obj1;
Obj3 : Regtests.Simple.Model.User_Ref;
begin
Obj1.Copy (Obj3);
Obj3.Set_Id (2);
-- Check the copy
T.Assert (Obj2.Get_Name = "User name", "Object_Ref.Copy invalid copy");
T.Assert (Obj3.Get_Name = "User name", "Object_Ref.Copy invalid copy");
T.Assert (Obj2 = Obj1, "Object_Ref.'=' invalid comparison after assignment");
T.Assert (Obj3 /= Obj1, "Object_Ref.'=' invalid comparison after copy");
-- Change original, make sure it's the same of Obj2.
Obj1.Set_Name ("Second name");
T.Assert (Obj2.Get_Name = "Second name", "Object_Ref.Copy invalid copy");
T.Assert (Obj2 = Obj1, "Object_Ref.'=' invalid comparison after assignment");
-- The copy is not modified
T.Assert (Obj3.Get_Name = "User name", "Object_Ref.Copy invalid copy");
end;
end loop;
end Test_Object_Ref;
-- ------------------------------
-- Test creation of an object with lazy loading.
-- ------------------------------
procedure Test_Create_Object (T : in out Test) is
User : Regtests.Simple.Model.User_Ref;
Cmt : Regtests.Comments.Comment_Ref;
begin
-- Create an object within a transaction.
declare
S : ADO.Sessions.Master_Session := Regtests.Get_Master_Database;
begin
S.Begin_Transaction;
User.Set_Name ("Joe");
User.Set_Value (0);
User.Save (S);
S.Commit;
end;
-- Load it from another session.
declare
S : ADO.Sessions.Master_Session := Regtests.Get_Master_Database;
U2 : Regtests.Simple.Model.User_Ref;
begin
U2.Load (S, User.Get_Id);
Assert_Equals (T, "Joe", Ada.Strings.Unbounded.To_String (U2.Get_Name),
"Cannot load created object");
Assert_Equals (T, Integer (0), Integer (U2.Get_Value), "Invalid load");
T.Assert (User.Get_Key = U2.Get_Key, "Invalid key after load");
end;
-- Create a comment for the user.
declare
S : ADO.Sessions.Master_Session := Regtests.Get_Master_Database;
begin
S.Begin_Transaction;
Cmt.Set_Message (Ada.Strings.Unbounded.To_Unbounded_String ("A comment from Joe"));
Cmt.Set_User (User);
Cmt.Set_Entity_Id (2);
Cmt.Set_Entity_Type (1);
-- Cmt.Set_Date (ADO.DEFAULT_TIME);
Cmt.Set_Date (Ada.Calendar.Clock);
Cmt.Save (S);
S.Commit;
end;
-- Load that comment.
declare
S : ADO.Sessions.Master_Session := Regtests.Get_Master_Database;
C2 : Regtests.Comments.Comment_Ref;
begin
C2.Load (S, Cmt.Get_Id);
T.Assert (not C2.Is_Null, "Loading of object failed");
T.Assert (Cmt.Get_Key = C2.Get_Key, "Invalid key after load");
T.Assert_Equals ("A comment from Joe", Ada.Strings.Unbounded.To_String (C2.Get_Message),
"Invalid message");
T.Assert (not C2.Get_User.Is_Null, "User associated with the comment should not be null");
-- T.Assert (not C2.Get_Entity_Type.Is_Null, "Entity type was not set");
-- Check that we can access the user name (lazy load)
Assert_Equals (T, "Joe", Ada.Strings.Unbounded.To_String (C2.Get_User.Get_Name),
"Cannot load created object");
end;
end Test_Create_Object;
-- ------------------------------
-- Test creation and deletion of an object record
-- ------------------------------
procedure Test_Delete_Object (T : in out Test) is
User : Regtests.Simple.Model.User_Ref;
begin
-- Create an object within a transaction.
declare
S : ADO.Sessions.Master_Session := Regtests.Get_Master_Database;
begin
S.Begin_Transaction;
User.Set_Name ("Joe (delete)");
User.Set_Value (0);
User.Save (S);
S.Commit;
end;
-- Load it and delete it from another session.
declare
S : ADO.Sessions.Master_Session := Regtests.Get_Master_Database;
U2 : Regtests.Simple.Model.User_Ref;
begin
U2.Load (S, User.Get_Id);
S.Begin_Transaction;
U2.Delete (S);
S.Commit;
end;
-- Try to load the deleted object.
declare
S : ADO.Sessions.Master_Session := Regtests.Get_Master_Database;
U2 : Regtests.Simple.Model.User_Ref;
begin
U2.Load (S, User.Get_Id);
T.Assert (False, "Load of a deleted object should raise NOT_FOUND");
exception
when ADO.Objects.NOT_FOUND =>
null;
end;
end Test_Delete_Object;
-- ------------------------------
-- Test Is_Inserted and Is_Null
-- ------------------------------
procedure Test_Is_Inserted (T : in out Test) is
User : Regtests.Simple.Model.User_Ref;
begin
T.Assert (not User.Is_Inserted, "A null object should not be marked as INSERTED");
T.Assert (User.Is_Null, "A null object should be marked as NULL");
-- Create an object within a transaction.
declare
S : ADO.Sessions.Master_Session := Regtests.Get_Master_Database;
begin
S.Begin_Transaction;
User.Set_Name ("John");
T.Assert (not User.Is_Null, "User should not be NULL");
T.Assert (not User.Is_Inserted, "User was not saved and not yet inserted in database");
User.Set_Value (1);
User.Save (S);
S.Commit;
T.Assert (User.Is_Inserted, "After a save operation, the user should be marked INSERTED");
T.Assert (not User.Is_Null, "User should not be NULL");
end;
declare
S : ADO.Sessions.Master_Session := Regtests.Get_Master_Database;
John : Regtests.Simple.Model.User_Ref;
begin
John.Load (S, User.Get_Id);
T.Assert (John.Is_Inserted, "After a load, the object should be marked INSERTED");
T.Assert (not John.Is_Null, "After a load, the object should not be NULL");
end;
end Test_Is_Inserted;
package Caller is new Util.Test_Caller (Test, "ADO.Objects");
-- ------------------------------
-- Add the tests in the test suite
-- ------------------------------
procedure Add_Tests (Suite : in Util.Tests.Access_Test_Suite) is
begin
Caller.Add_Test (Suite, "Test ADO.Objects.Hash", Test_Key'Access);
Caller.Add_Test (Suite, "Test Object_Ref.Get/Set", Test_Object_Ref'Access);
Caller.Add_Test (Suite, "Test ADO.Objects.Create", Test_Create_Object'Access);
Caller.Add_Test (Suite, "Test ADO.Objects.Delete", Test_Delete_Object'Access);
Caller.Add_Test (Suite, "Test ADO.Objects.Is_Created", Test_Is_Inserted'Access);
end Add_Tests;
end ADO.Objects.Tests;
|
reznikmm/matreshka | Ada | 3,692 | 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 League.Holders.Integers;
separate (AMF.Internals.Factories.Primitive_Types_Factories)
function Create_Integer_From_String
(Image : League.Strings.Universal_String) return League.Holders.Holder is
begin
return
League.Holders.Integers.To_Holder
(Integer'Wide_Wide_Value (Image.To_Wide_Wide_String));
end Create_Integer_From_String;
|
reznikmm/matreshka | Ada | 3,945 | 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.Form_For_Attributes;
package Matreshka.ODF_Form.For_Attributes is
type Form_For_Attribute_Node is
new Matreshka.ODF_Form.Abstract_Form_Attribute_Node
and ODF.DOM.Form_For_Attributes.ODF_Form_For_Attribute
with null record;
overriding function Create
(Parameters : not null access Matreshka.DOM_Attributes.Attribute_L2_Parameters)
return Form_For_Attribute_Node;
overriding function Get_Local_Name
(Self : not null access constant Form_For_Attribute_Node)
return League.Strings.Universal_String;
end Matreshka.ODF_Form.For_Attributes;
|
tum-ei-rcs/StratoX | Ada | 99 | ads | with Units; use Units;
with Units.Navigation; use Units.Navigation;
package config is
end config;
|
AdaCore/libadalang | Ada | 3,746 | adb | with Ada.Command_Line; use Ada.Command_Line;
with Ada.Text_IO; use Ada.Text_IO;
with Langkit_Support.Text; use Langkit_Support.Text;
with Libadalang.Analysis; use Libadalang.Analysis;
with Libadalang.Common; use Libadalang.Common;
with Libadalang.Rewriting; use Libadalang.Rewriting;
procedure Generate_Stubs is
Input_File : constant String := Argument (1);
Charset : constant String := "ISO-8859-1";
Ctx : Analysis_Context := Create_Context (Charset);
Spec_Unit : constant Analysis_Unit := Get_From_File (Ctx, Input_File);
-- Unit to contain the package specification for which we will generate
-- stubs subprogram bodies.
Spec_List : Ada_Node_List;
-- List to contain the declaration for which we will generate stubs
RH : Rewriting_Handle := Start_Rewriting (Ctx);
-- Rewriting handle, owning all rewriting data
function Extract_Spec_List return Ada_Node_List;
-- If Spec_Unit contains a package specification, return the list of nodes
-- thata constitutes its public part. Oterwise, return No_Ada_Node_List.
-----------------------
-- Extract_Spec_List --
-----------------------
function Extract_Spec_List return Ada_Node_List is
N : Ada_Node := Root (Spec_Unit);
begin
if N.Kind /= Ada_Compilation_Unit then
return No_Ada_Node_List;
end if;
N := N.As_Compilation_Unit.F_Body;
if N.Kind /= Ada_Library_Item then
return No_Ada_Node_List;
end if;
N := N.As_Library_Item.F_Item.As_Ada_Node;
if N.Kind /= Ada_Package_Decl then
return No_Ada_Node_List;
end if;
return N.As_Package_Decl.F_Public_Part.F_Decls;
end Extract_Spec_List;
begin
-- Make sure we could parse the input source file and get the list of
-- declarations for which we will generate stubs.
if Has_Diagnostics (Spec_Unit) then
for D of Diagnostics (Spec_Unit) loop
Put_Line (Format_GNU_Diagnostic (Spec_Unit, D));
end loop;
return;
end if;
Spec_List := Extract_Spec_List;
if Spec_List = No_Ada_Node_List then
Put_Line (Input_File & ": package spec expected");
return;
end if;
-- Walk through this list, generating stubs for the subprogram declarations
-- we wind on the way.
for Decl of Spec_List.Children loop
if Decl.Kind = Ada_Subp_Decl then
declare
SD : constant Subp_Decl := Decl.As_Subp_Decl;
SS : constant Subp_Spec := SD.F_Subp_Spec;
Name : constant Defining_Name := SS.F_Subp_Name;
Template : constant Text_Type :=
(if SS.F_Subp_Kind.Kind = Ada_Subp_Kind_Function
then "{} {} is begin return (raise Program_Error); end {};"
else "{} {} is begin null; end {};");
Body_Stub : constant Node_Rewriting_Handle := Create_From_Template
(Handle => RH,
Template => Template,
Arguments =>
(Handle (SD.F_Overriding), Handle (SS), Handle (Name)),
Rule => Subp_Body_Rule);
-- Create the tree of nodes that will constitute the body stub.
-- Instead of creating all nodes manually, one by one, we just
-- give a string template, several nodes to fill in holes, and let
-- the rewriting machinery do its magic.
begin
Put_Line ("===");
Put_Line (Encode (Unparse (Body_Stub), Charset));
New_Line;
end;
end if;
end loop;
-- Free resources: data for rewriting session, and then the whole analysis
-- context.
Abort_Rewriting (RH);
Put_Line ("generate_stubs.adb: Done.");
end Generate_Stubs;
|
reznikmm/matreshka | Ada | 3,969 | ads | ------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- Open Document Toolkit --
-- --
-- Runtime Library Component --
-- --
------------------------------------------------------------------------------
-- --
-- Copyright © 2014, Vadim Godunko <[email protected]> --
-- All rights reserved. --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions --
-- are met: --
-- --
-- * Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- --
-- * Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in the --
-- documentation and/or other materials provided with the distribution. --
-- --
-- * Neither the name of the Vadim Godunko, IE nor the names of its --
-- contributors may be used to endorse or promote products derived from --
-- this software without specific prior written permission. --
-- --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR --
-- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
-- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED --
-- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR --
-- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF --
-- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING --
-- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS --
-- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
-- --
------------------------------------------------------------------------------
-- $Revision$ $Date$
------------------------------------------------------------------------------
with ODF.DOM.Dr3d_Shadow_Attributes;
package Matreshka.ODF_Dr3d.Shadow_Attributes is
type Dr3d_Shadow_Attribute_Node is
new Matreshka.ODF_Dr3d.Abstract_Dr3d_Attribute_Node
and ODF.DOM.Dr3d_Shadow_Attributes.ODF_Dr3d_Shadow_Attribute
with null record;
overriding function Create
(Parameters : not null access Matreshka.DOM_Attributes.Attribute_L2_Parameters)
return Dr3d_Shadow_Attribute_Node;
overriding function Get_Local_Name
(Self : not null access constant Dr3d_Shadow_Attribute_Node)
return League.Strings.Universal_String;
end Matreshka.ODF_Dr3d.Shadow_Attributes;
|
pdaxrom/Kino2 | Ada | 4,141 | ads | ------------------------------------------------------------------------------
-- --
-- GNAT ncurses Binding Samples --
-- --
-- Sample.Manifest --
-- --
-- S P E C --
-- --
------------------------------------------------------------------------------
-- Copyright (c) 1998 Free Software Foundation, Inc. --
-- --
-- Permission is hereby granted, free of charge, to any person obtaining a --
-- copy of this software and associated documentation files (the --
-- "Software"), to deal in the Software without restriction, including --
-- without limitation the rights to use, copy, modify, merge, publish, --
-- distribute, distribute with modifications, sublicense, and/or sell --
-- copies of the Software, and to permit persons to whom the Software is --
-- furnished to do so, subject to the following conditions: --
-- --
-- The above copyright notice and this permission notice shall be included --
-- in all copies or substantial portions of the Software. --
-- --
-- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS --
-- OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF --
-- MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. --
-- IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, --
-- DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR --
-- OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR --
-- THE USE OR OTHER DEALINGS IN THE SOFTWARE. --
-- --
-- Except as contained in this notice, the name(s) of the above copyright --
-- holders shall not be used in advertising or otherwise to promote the --
-- sale, use or other dealings in this Software without prior written --
-- authorization. --
------------------------------------------------------------------------------
-- Author: Juergen Pfeifer, 1996
-- Contact: http://www.familiepfeifer.de/Contact.aspx?Lang=en
-- Version Control
-- $Revision: 1.10 $
-- Binding Version 01.00
------------------------------------------------------------------------------
with Terminal_Interface.Curses; use Terminal_Interface.Curses;
package Sample.Manifest is
QUIT : constant User_Key_Code := User_Key_Code'First;
SELECT_ITEM : constant User_Key_Code := QUIT + 1;
FKEY_HELP : constant Label_Number := 1;
HELP_CODE : constant Special_Key_Code := Key_F1;
FKEY_EXPLAIN : constant Label_Number := 2;
EXPLAIN_CODE : constant Special_Key_Code := Key_F2;
FKEY_QUIT : constant Label_Number := 3;
QUIT_CODE : constant Special_Key_Code := Key_F3;
Menu_Marker : constant String := "=> ";
Default_Colors : constant Redefinable_Color_Pair := 1;
Menu_Fore_Color : constant Redefinable_Color_Pair := 2;
Menu_Back_Color : constant Redefinable_Color_Pair := 3;
Menu_Grey_Color : constant Redefinable_Color_Pair := 4;
Form_Fore_Color : constant Redefinable_Color_Pair := 5;
Form_Back_Color : constant Redefinable_Color_Pair := 6;
Notepad_Color : constant Redefinable_Color_Pair := 7;
Help_Color : constant Redefinable_Color_Pair := 8;
Header_Color : constant Redefinable_Color_Pair := 9;
end Sample.Manifest;
|
reznikmm/matreshka | Ada | 5,328 | ads | ------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- Ada Modeling Framework --
-- --
-- Runtime Library Component --
-- --
------------------------------------------------------------------------------
-- --
-- Copyright © 2011-2012, Vadim Godunko <[email protected]> --
-- All rights reserved. --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions --
-- are met: --
-- --
-- * Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- --
-- * Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in the --
-- documentation and/or other materials provided with the distribution. --
-- --
-- * Neither the name of the Vadim Godunko, IE nor the names of its --
-- contributors may be used to endorse or promote products derived from --
-- this software without specific prior written permission. --
-- --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR --
-- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
-- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED --
-- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR --
-- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF --
-- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING --
-- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS --
-- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
-- --
------------------------------------------------------------------------------
-- $Revision$ $Date$
------------------------------------------------------------------------------
-- This file is generated, don't edit it.
------------------------------------------------------------------------------
with AMF.Generic_Collections;
package AMF.UML.Call_Operation_Actions.Collections is
pragma Preelaborate;
package UML_Call_Operation_Action_Collections is
new AMF.Generic_Collections
(UML_Call_Operation_Action,
UML_Call_Operation_Action_Access);
type Set_Of_UML_Call_Operation_Action is
new UML_Call_Operation_Action_Collections.Set with null record;
Empty_Set_Of_UML_Call_Operation_Action : constant Set_Of_UML_Call_Operation_Action;
type Ordered_Set_Of_UML_Call_Operation_Action is
new UML_Call_Operation_Action_Collections.Ordered_Set with null record;
Empty_Ordered_Set_Of_UML_Call_Operation_Action : constant Ordered_Set_Of_UML_Call_Operation_Action;
type Bag_Of_UML_Call_Operation_Action is
new UML_Call_Operation_Action_Collections.Bag with null record;
Empty_Bag_Of_UML_Call_Operation_Action : constant Bag_Of_UML_Call_Operation_Action;
type Sequence_Of_UML_Call_Operation_Action is
new UML_Call_Operation_Action_Collections.Sequence with null record;
Empty_Sequence_Of_UML_Call_Operation_Action : constant Sequence_Of_UML_Call_Operation_Action;
private
Empty_Set_Of_UML_Call_Operation_Action : constant Set_Of_UML_Call_Operation_Action
:= (UML_Call_Operation_Action_Collections.Set with null record);
Empty_Ordered_Set_Of_UML_Call_Operation_Action : constant Ordered_Set_Of_UML_Call_Operation_Action
:= (UML_Call_Operation_Action_Collections.Ordered_Set with null record);
Empty_Bag_Of_UML_Call_Operation_Action : constant Bag_Of_UML_Call_Operation_Action
:= (UML_Call_Operation_Action_Collections.Bag with null record);
Empty_Sequence_Of_UML_Call_Operation_Action : constant Sequence_Of_UML_Call_Operation_Action
:= (UML_Call_Operation_Action_Collections.Sequence with null record);
end AMF.UML.Call_Operation_Actions.Collections;
|
AdaCore/Ada_Drivers_Library | Ada | 2,753 | adb | ------------------------------------------------------------------------------
-- --
-- Copyright (C) 2018, 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 MicroBit.Music; use MicroBit.Music;
procedure Main is
My_Little_Melody : constant MicroBit.Music.Melody :=
((C4, 400),
(G3, 800),
(B3, 400),
(Rest, 400),
(A3, 400),
(G3, 400));
begin
-- Loop forever
loop
-- Play the little melody on pin 0
MicroBit.Music.Play (0, My_Little_Melody);
end loop;
end Main;
|
msrLi/portingSources | Ada | 858 | adb | -- Copyright 2008-2014 Free Software Foundation, Inc.
--
-- This program is free software; you can redistribute it and/or modify
-- it under the terms of the GNU General Public License as published by
-- the Free Software Foundation; either version 3 of the License, or
-- (at your option) any later version.
--
-- This program is distributed in the hope that it will be useful,
-- but WITHOUT ANY WARRANTY; without even the implied warranty of
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-- GNU General Public License for more details.
--
-- You should have received a copy of the GNU General Public License
-- along with this program. If not, see <http://www.gnu.org/licenses/>.
with Pck; use Pck;
procedure Foo is
My_Circle : Circle := (Pos => (1, 2), Radius => 3);
begin
Do_Nothing (My_Circle); -- STOP
end Foo;
|
jscparker/math_packages | Ada | 1,428 | adb |
-- gamma(1+x) = x! for x=0,1,2 ...
-- gamma(0.5) = sqrt(pi)
-- ln (sqrt(pi)) = 0.57236494292470008707171367567652935582354993281988
-- sqrt(pi) = 1.77245385090551602729816748334114518279737668859774
with Gamma;
with text_io; use text_io;
with ada.numerics.generic_elementary_functions;
procedure gamma_tst_1 is
type Real is digits 15;
x : real;
package G is new Gamma (Real); use G;
package math is new ada.numerics.generic_elementary_functions(Real); use math;
--for exp
function Factorial (n : in Natural) return Real is
Prod : Real := 1.0;
begin
if n < 2 then
return 1.0;
end if;
for j in 2 .. n loop
Prod := Prod * Real(j);
end loop;
return Prod;
end;
begin
Test_Stieltjes_Coefficients;
for j in 0 .. 159 loop
x := 0.1 + Real(j) * 0.1;
new_line;
put(Real'image(x));
put(real'image(log_gamma(x)-log_gamma_0_to_16(x)));
end loop;
new_line;
put(real'image(log_gamma(0.5)-0.57236494292470008707171367567652935582355));
new_line;
put(real'image(Exp (log_gamma(0.5))-1.7724538509055160272981674833411451828));
new_line;
new_line; put(real'image( (log_gamma(7.0) - Log (Factorial(6)) )));
new_line; put(real'image( (log_gamma(11.0) - Log (Factorial(10)) )));
new_line; put(real'image( (log_gamma(15.0) - Log (Factorial(14)) )));
new_line; put(real'image( (log_gamma(28.0) - Log (Factorial(27)) )));
end;
|
AdaCore/Ada-IntelliJ | Ada | 3,449 | adb | ------------------------------------------------------------------------------
-- --
-- GNAT EXAMPLE --
-- --
-- Copyright (C) 2014, Free Software Foundation, Inc. --
-- --
-- GNAT is free software; you can redistribute it and/or modify it under --
-- terms of the GNU General Public License as published by the Free Soft- --
-- ware Foundation; either version 3, or (at your option) any later ver- --
-- sion. GNAT is distributed in the hope that it will be useful, but WITH- --
-- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY --
-- or FITNESS FOR A PARTICULAR PURPOSE. --
-- --
-- As a special exception under Section 7 of GPL version 3, you are granted --
-- additional permissions described in the GCC Runtime Library Exception, --
-- version 3.1, as published by the Free Software Foundation. --
-- --
-- You should have received a copy of the GNU General Public License and --
-- a copy of the GCC Runtime Library Exception along with this program; --
-- see the files COPYING3 and COPYING.RUNTIME respectively. If not, see --
-- <http://www.gnu.org/licenses/>. --
-- --
-- GNAT was originally developed by the GNAT team at New York University. --
-- Extensive contributions were provided by Ada Core Technologies Inc. --
-- --
------------------------------------------------------------------------------
with Ada.Unchecked_Conversion;
with Registers; use Registers;
with STM32F4.GPIO; use STM32F4.GPIO;
package body LEDs is
function As_Word is new Ada.Unchecked_Conversion
(Source => User_LED, Target => Word);
procedure On (This : User_LED) is
begin
GPIOD.BSRR := As_Word (This);
end On;
procedure Off (This : User_LED) is
begin
GPIOD.BSRR := Shift_Left (As_Word (This), 16);
end Off;
All_LEDs_On : constant Word := Green'Enum_Rep or Red'Enum_Rep or
Blue'Enum_Rep or Orange'Enum_Rep;
pragma Compile_Time_Error
(All_LEDs_On /= 16#F000#,
"Invalid representation for All_LEDs_On");
All_LEDs_Off : constant Word := Shift_Left (All_LEDs_On, 16);
procedure All_Off is
begin
GPIOD.BSRR := All_LEDs_Off;
end All_Off;
procedure All_On is
begin
GPIOD.BSRR := All_LEDs_On;
end All_On;
procedure Initialize is
RCC_AHB1ENR_GPIOD : constant Word := 16#08#;
begin
-- Enable clock for GPIO-D
RCC.AHB1ENR := RCC.AHB1ENR or RCC_AHB1ENR_GPIOD;
-- Configure PD12-15
GPIOD.MODER (12 .. 15) := (others => Mode_OUT);
GPIOD.OTYPER (12 .. 15) := (others => Type_PP);
GPIOD.OSPEEDR (12 .. 15) := (others => Speed_100MHz);
GPIOD.PUPDR (12 .. 15) := (others => No_Pull);
end Initialize;
begin
Initialize;
end LEDs;
|
stcarrez/ada-awa | Ada | 1,360 | adb | -----------------------------------------------------------------------
-- awa-helpers -- Helpers for AWA applications
-- Copyright (C) 2011, 2013 Stephane Carrez
-- Written by Stephane Carrez ([email protected])
--
-- Licensed under the Apache License, Version 2.0 (the "License");
-- you may not use this file except in compliance with the License.
-- You may obtain a copy of the License at
--
-- http://www.apache.org/licenses/LICENSE-2.0
--
-- Unless required by applicable law or agreed to in writing, software
-- distributed under the License is distributed on an "AS IS" BASIS,
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-- See the License for the specific language governing permissions and
-- limitations under the License.
-----------------------------------------------------------------------
package body AWA.Helpers is
-- ------------------------------
-- Get the value as an identifier.
-- Returns NO_IDENTIFIER if the value is invalid.
-- ------------------------------
function To_Identifier (Value : in Util.Beans.Objects.Object) return ADO.Identifier is
begin
return ADO.Identifier (Util.Beans.Objects.To_Long_Long_Integer (Value));
exception
when Constraint_Error =>
return ADO.NO_IDENTIFIER;
end To_Identifier;
end AWA.Helpers;
|
AaronC98/PlaneSystem | Ada | 9,183 | ads | ------------------------------------------------------------------------------
-- Ada Web Server --
-- --
-- Copyright (C) 2005-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/>. --
-- --
-- --
-- --
-- --
-- --
-- --
-- --
------------------------------------------------------------------------------
pragma Ada_2012;
-- Waiting on a group of sockets for reading and accept new connections
with Ada.Containers.Doubly_Linked_Lists;
with AWS.Net;
with AWS.Net.Generic_Sets;
with AWS.Utils;
private with Ada.Real_Time;
package AWS.Net.Acceptors is
type Acceptor_Type is limited private;
package Socket_Lists is new Containers.Doubly_Linked_Lists (Socket_Access);
subtype Socket_List is Socket_Lists.List;
procedure Listen
(Acceptor : in out Acceptor_Type;
Host : String;
Port : Natural;
Queue_Size : Positive;
Family : Family_Type := Family_Unspec;
Timeout : Duration := Forever;
First_Timeout : Duration := Forever;
Force_Timeout : Duration := Forever;
Force_First_Timeout : Duration := Forever;
Force_Length : Positive := Positive'Last;
Close_Length : Positive := Positive'Last;
Reuse_Address : Boolean := False;
IPv6_Only : Boolean := False);
-- Prepare Acceptor to accept sockets and wait for incoming data from the
-- given Host and Port. Use Queue_Size for the Listen call.
-- Timeout is to wait for the next data from the socket, should be longer
-- than First_Timeout for HTTP protocol handlers. First_Timeout is the
-- time to wait for data just after a socket is accepted. Force_Timeout
-- used when the number of sockets exceed Force_Length (generally this
-- timeout is shorter than the others).
-- If number of sockets became more then Close_Length, closest to timeout
-- socket would be closed without timeout condition.
procedure Add_Listening
(Acceptor : in out Acceptor_Type;
Host : String;
Port : Natural;
Family : Family_Type := Family_Unspec;
Reuse_Address : Boolean := False;
IPv6_Only : Boolean := False);
-- Add the binded/listening socket on host, port and protocol family. To be
-- able to connect web enabled application with others in the internal
-- network, and then give access for external clients by listening on
-- externally available address. Generally this is called from a different
-- task while the Get routine is blocked waiting for a socket.
procedure Set_Socket_Constructor
(Acceptor : in out Acceptor_Type; Constructor : Socket_Constructor);
procedure Get
(Acceptor : in out Acceptor_Type;
Socket : out Socket_Access;
On_Error : access procedure (E : Exception_Occurrence) := null);
-- Returns a socket from the internal socket set which has data to read.
-- Should not be called simultaneously from different tasks.
-- On_Error needs to be able to catch Socket_Error on Accept_Socket or
-- on the Wait on the sockets. Accept_Socket and Wait on sockets could fail
-- if the server is processing too many keep-alive connections
-- simultaneously. Acceptor switched into Force timeouts in case of
-- Accept_Socket or Wait fail. The server could also use the On_Error
-- callback to decrease the number of simultaneous keep-alive connections.
-- If On_Error is null, the exception on error is propagated.
procedure Get
(Acceptor : in out Acceptor_Type;
Socket : out Socket_Access;
To_Close : out Socket_List;
On_Error : access procedure (E : Exception_Occurrence) := null);
-- Idem but with output socket list which have to be shutdowned and freed.
-- It should be done out of critical section if any.
procedure Shutdown_And_Free (Set : Socket_List);
-- Use this routine to shutdown and free list of sockets returned from Get
-- routine above.
function Server_Socket (Acceptor : Acceptor_Type) return Socket_Type'Class
with Inline;
-- Returns main server accepting socket
function Server_Sockets (Acceptor : Acceptor_Type) return Socket_List;
-- Returns all listening server sockets
procedure Give_Back
(Acceptor : in out Acceptor_Type;
Socket : not null access Socket_Type'Class;
Success : out Boolean);
-- Give back socket which has been taken from Get routine above. Generally
-- this is called from a different task while the Get routine is blocked
-- waiting for a socket. Socket would not be given back in case of socket
-- queue size exceed Queue_Size Acceptor property and Success parameter
-- would return False value in this case.
procedure Give_Back
(Acceptor : in out Acceptor_Type;
Socket : not null access Socket_Type'Class);
-- Idem but do not check sockets queue length
procedure Shutdown (Acceptor : in out Acceptor_Type);
-- Shutdown all internal sockets. Generally this is called from a
-- different task while the Get routine is blocked waiting for a
-- socket.
function Length (Acceptor : Acceptor_Type) return Natural with Inline;
-- Return number of sockets in the internal socket set.
-- Note that this number include server accepting socket
-- and one service signaling socket.
-- If the number of socket is 0, it mean that Acceptor either
-- not initialized or already shutdowned.
private
protected type Socket_Box (Acceptor : not null access Acceptor_Type) is
procedure Add
(S : not null access Socket_Type'Class;
Max_Size : Positive;
Success : out Boolean);
entry Get (S : out Socket_Access);
function Size return Natural;
procedure Clear;
private
Buffer : Socket_List;
end Socket_Box;
protected type Server_Sockets_Set is
procedure Add (S : not null access Socket_Type'Class);
function Get return Socket_List;
procedure Clear;
entry Wait_Empty;
private
Sockets : Socket_List;
end Server_Sockets_Set;
type Socket_Data_Type is record
Time : Real_Time.Time;
First : Boolean;
end record;
package Sets is new Generic_Sets (Socket_Data_Type);
type Acceptor_Type is tagged limited record
Set : Sets.Socket_Set_Type;
W_Signal : access Socket_Type'Class;
R_Signal : access Socket_Type'Class;
Servers : Server_Sockets_Set;
Box : Socket_Box (Acceptor_Type'Access);
Index : Sets.Socket_Count;
Last : Sets.Socket_Count;
Timeout : Real_Time.Time_Span;
First_Timeout : Real_Time.Time_Span;
Force_Timeout : Real_Time.Time_Span;
Force_First_Timeout : Real_Time.Time_Span;
Force_Length : Sets.Socket_Count;
Close_Length : Sets.Socket_Count;
Back_Queue_Size : Positive;
Semaphore : Utils.Semaphore;
Constructor : Socket_Constructor := Socket'Access;
end record;
end AWS.Net.Acceptors;
|
johnperry-math/hac | Ada | 6,161 | adb | with HAC_Sys.PCode.Interpreter.Tasking;
with Ada.Calendar;
package body HAC_Sys.PCode.Interpreter.Calls is
procedure Do_Calling_Operation (CD : Compiler_Data; ND : in out Interpreter_Data) is
Curr_TCB : Task_Control_Block renames ND.TCB (ND.CurTask);
IR : Order renames ND.IR;
use Defs;
use type HAC_Integer;
procedure Do_Mark_Stack is
VSize : constant Integer :=
Integer (CD.Blocks_Table (CD.IdTab (Integer (IR.Y)).Block_Ref).VSize);
begin
if Curr_TCB.T + VSize > Curr_TCB.STACKSIZE then
raise VM_Stack_Overflow;
else
Curr_TCB.T := Curr_TCB.T + 5; -- Make room for fixed area
ND.S (Curr_TCB.T - 1).I := HAC_Integer (VSize - 1);
ND.S (Curr_TCB.T).I := IR.Y; -- CD.IdTab index of called procedure/entry
end if;
end Do_Mark_Stack;
procedure Do_Call is
use Ada.Calendar;
F1 : HAC_Float; -- Internal float registers
H1, H2, H4 : Index;
H3 : Nesting_level;
H5 : Integer;
begin
-- procedure and task entry CALL
-- Cramer
if IR.X = Defs.Timed_Entry_Call then
-- Timed entry call
F1 := ND.S (Curr_TCB.T).R; -- Pop delay time
Pop (ND);
end if;
H1 := Curr_TCB.T - Integer (IR.Y); -- base of activation record
H2 := Index (ND.S (H1 + 4).I); -- CD.IdTab index of called procedure/entry
H3 := CD.IdTab (Integer (H2)).LEV;
Curr_TCB.DISPLAY (H3 + 1) := Integer (H1);
ND.S (H1 + 1).I := HAC_Integer (Curr_TCB.PC); -- return address
H4 := Index (ND.S (H1 + 3).I) + H1; -- new top of stack
ND.S (H1 + 2).I := HAC_Integer (Curr_TCB.DISPLAY (H3)); -- static link
ND.S (H1 + 3).I := HAC_Integer (Curr_TCB.B); -- dynamic link
Curr_TCB.B := H1;
Curr_TCB.T := H4;
case IR.X is -- Call type
when Defs.Normal_Procedure_Call =>
Curr_TCB.PC := CD.IdTab (H2).Adr_or_Sz;
when Defs.Normal_Entry_Call =>
Tasking.Queue (CD, ND, H2, ND.CurTask); -- put self on entry queue
Curr_TCB.TS := WaitRendzv;
H5 := CD.IdTab (H2).Adr_or_Sz; -- Task being entered
if ((ND.TCB (H5).TS = WaitRendzv) and (ND.TCB (H5).SUSPEND = H2)) or
(ND.TCB (H5).TS = TimedWait)
then
-- wake accepting task if necessary
ND.TCB (H5).TS := Ready;
ND.TCB (H5).SUSPEND := 0;
end if;
ND.SWITCH := True; -- give up control
when Defs.Timed_Entry_Call =>
Tasking.Queue (CD, ND, H2, ND.CurTask); -- put self on entry queue
H5 := CD.IdTab (H2).Adr_or_Sz; -- Task being entered
--
if ((ND.TCB (H5).TS = WaitRendzv) and (ND.TCB (H5).SUSPEND = H2)) or
(ND.TCB (H5).TS = TimedWait)
then
-- wake accepting task if necessary
Curr_TCB.TS := WaitRendzv; -- suspend self
ND.TCB (H5).TS := Ready; -- wake accepting task
ND.TCB (H5).SUSPEND := 0;
else
Curr_TCB.TS := TimedRendz; -- Timed Wait For Rendezvous
Curr_TCB.R1.I := 1; -- Init R1 to specify NO timeout
Curr_TCB.R2.I := HAC_Integer (H2); -- Save address of queue for purge
ND.SYSCLOCK := Clock; -- update System Clock
Curr_TCB.WAKETIME := ND.SYSCLOCK + Duration (F1);
end if;
ND.SWITCH := True; -- give up control
when Defs.Conditional_Entry_Call =>
H5 := CD.IdTab (H2).Adr_or_Sz; -- Task being entered
if ((ND.TCB (H5).TS = WaitRendzv) and (ND.TCB (H5).SUSPEND = H2)) or
(ND.TCB (H5).TS = TimedWait)
then
Tasking.Queue (CD, ND, H2, ND.CurTask); -- put self on entry queue
Curr_TCB.R1.I := 1; -- Indicate entry successful
Curr_TCB.TS := WaitRendzv;
ND.TCB (H5).TS := Ready; -- wake accepting task if required
ND.TCB (H5).SUSPEND := 0;
ND.SWITCH := True; -- give up control
else
-- can't wait, forget about entry call
Curr_TCB.R1.I := 0; -- Indicate entry failed in R1 1
-- failure will be acknowledged by next instruction, 32
end if;
when others =>
null; -- [P2Ada]: no otherwise / else in Pascal
end case;
end Do_Call;
procedure Do_Exit_Call is
begin
-- EXIT entry call or procedure call
-- Cramer
Curr_TCB.T := Curr_TCB.B - 1;
if IR.Y = Defs.Normal_Procedure_Call then
Curr_TCB.PC := Integer (ND.S (Curr_TCB.B + 1).I); -- Standard proc call return
end if;
if Curr_TCB.PC /= 0 then
Curr_TCB.B := Integer (ND.S (Curr_TCB.B + 3).I);
if IR.Y = Defs.Timed_Entry_Call or IR.Y = Defs.Conditional_Entry_Call then
if IR.Y = Defs.Timed_Entry_Call and Curr_TCB.R1.I = 0 then
Push (ND);
end if;
-- A JMPC instruction always follows (?)
-- timed and conditional entry call
-- returns (32). Push entry call
ND.S (Curr_TCB.T).I := Curr_TCB.R1.I; -- success indicator for JMPC.
end if;
else
ND.TActive := ND.TActive - 1;
Curr_TCB.TS := Completed;
ND.SWITCH := True;
end if;
end Do_Exit_Call;
procedure Do_Exit_Function is
begin
Curr_TCB.T := Curr_TCB.B;
Curr_TCB.PC := Integer (ND.S (Curr_TCB.B + 1).I);
Curr_TCB.B := Integer (ND.S (Curr_TCB.B + 3).I);
if IR.Y = Defs.End_Function_without_Return and then ND.PS /= Exception_Raised then
raise VM_Function_End_without_Return;
end if;
end Do_Exit_Function;
begin
case Calling_Opcode (ND.IR.F) is
when k_Mark_Stack => Do_Mark_Stack;
when k_Call => Do_Call;
when k_Exit_Call => Do_Exit_Call;
when k_Exit_Function => Do_Exit_Function;
end case;
end Do_Calling_Operation;
end HAC_Sys.PCode.Interpreter.Calls;
|
reznikmm/slimp | Ada | 3,566 | adb | -- Copyright (c) 2019 Maxim Reznik <[email protected]>
--
-- SPDX-License-Identifier: MIT
-- License-Filename: LICENSE
-------------------------------------------------------------
with Ada.Exceptions;
with Ada.Streams;
with Ada.Text_IO;
with GNAT.Sockets;
with League.Application;
with League.Strings;
with Slim.Players;
procedure Slim.Run is
use GNAT.Sockets;
function "+" (X : Wide_Wide_String) return League.Strings.Universal_String
renames League.Strings.To_Universal_String;
task Discovery is
entry Start;
end Discovery;
task type Server is
entry Start (Value : Socket_Type);
end Server;
type Server_Access is access all Server;
--------------
-- Visiters --
--------------
---------------
-- Discovery --
---------------
task body Discovery is
use type Ada.Streams.Stream_Element;
use type Ada.Streams.Stream_Element_Offset;
Address : Sock_Addr_Type;
Listener : Socket_Type;
From : Sock_Addr_Type;
Last : Ada.Streams.Stream_Element_Offset;
Request : Ada.Streams.Stream_Element_Array (1 .. 128);
begin
accept Start;
Address.Addr := Any_Inet_Addr;
Address.Port := 3483;
Create_Socket (Listener, Mode => Socket_Datagram);
Bind_Socket (Listener, Address);
loop
Receive_Socket (Listener, Request, Last, From);
if Last = 18 and then Request (1) = Character'Pos ('d') then
-- Discovery request
declare
Reply : constant Ada.Streams.Stream_Element_Array (1 .. 18) :=
(Character'Pos ('D'),
Character'Pos ('O'),
Character'Pos ('p'),
Character'Pos ('e'),
Character'Pos ('n'),
Character'Pos ('W'),
Character'Pos ('R'),
Character'Pos ('T'),
others => 0);
begin
Send_Socket (Listener, Reply, Last, To => From);
end;
end if;
end loop;
end Discovery;
------------
-- Server --
------------
task body Server is
Player : aliased Slim.Players.Player;
begin
accept Start (Value : Socket_Type) do
Player.Initialize
(Socket => Value,
Font => +"10x20-ISO8859-5",
Splash => +"data/splash.dat",
Menu => +"data/menu.json");
end Start;
loop
Player.Process_Message;
-- Read and process one message from socket if any
end loop;
exception
when E : others =>
Ada.Text_IO.Put_Line
(Ada.Exceptions.Exception_Name (E) & ": "
& Ada.Exceptions.Exception_Message (E));
end Server;
Address : Sock_Addr_Type;
Listener : Socket_Type;
Client : Socket_Type;
begin
League.Application.Set_Application_Name (+"SlimProto Player");
League.Application.Set_Application_Version (+"0.1");
League.Application.Set_Organization_Name (+"Matreshka Project");
League.Application.Set_Organization_Domain (+"forge.ada-ru.org");
Address.Addr := Any_Inet_Addr;
Address.Port := 3483;
Create_Socket (Listener);
Bind_Socket (Listener, Address);
Listen_Socket (Listener);
Discovery.Start;
loop
declare
Next : Server_Access;
begin
Accept_Socket (Listener, Client, Address);
Next := new Server;
Next.Start (Client);
end;
end loop;
-- Close_Socket (Client);
-- Close_Socket (Listener);
end Slim.Run;
|
tum-ei-rcs/StratoX | Ada | 986 | ads | -- Institution: Technische Universitaet Muenchen
-- Department: Realtime Computer Systems (RCS)
-- Project: StratoX
-- Module: Software Configuration
--
-- Authors: Martin Becker ([email protected])
with STM32.Timers;
with STm32.Device;
-- @summary Target-specific types for the hardware timers in Pixhawk.
package HIL.Devices.Timers with SPARK_Mode is
subtype HIL_Timer is STM32.Timers.Timer;
subtype HIL_Timer_Channel is STM32.Timers.Timer_Channel;
-- the buzzer is routed to Timer 2 channel 1 (STM32.Device.PA15)
Timer_Buzzer_Port : STM32.Timers.Timer renames STM32.Device.Timer_2; -- Buuzer port
Timerchannel_Buzzer_Port : STM32.Timers.Timer_Channel renames STM32.Timers.Channel_1;
-- alternatively, we can use FMU AUX5 at the Servo pins (Timer 4 channel 2):
Timer_Buzzer_Aux : STM32.Timers.Timer renames STM32.Device.Timer_4;
Timerchannel_Buzzer_Aux : STM32.Timers.Timer_Channel renames STM32.Timers.Channel_2;
end HIL.Devices.Timers;
|
AdaCore/Ada_Drivers_Library | Ada | 21,673 | ads | -- Copyright (c) 2010 - 2018, Nordic Semiconductor ASA
--
-- 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, except as embedded into a Nordic
-- Semiconductor ASA integrated circuit in a product or a software update for
-- such product, 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 Nordic Semiconductor ASA nor the names of its
-- contributors may be used to endorse or promote products derived from this
-- software without specific prior written permission.
--
-- 4. This software, with or without modification, must only be used with a
-- Nordic Semiconductor ASA integrated circuit.
--
-- 5. Any software provided in binary form under this license must not be reverse
-- engineered, decompiled, modified and/or disassembled.
--
-- THIS SOFTWARE IS PROVIDED BY NORDIC SEMICONDUCTOR ASA "AS IS" AND ANY EXPRESS
-- OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
-- OF MERCHANTABILITY, NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE ARE
-- DISCLAIMED. IN NO EVENT SHALL NORDIC SEMICONDUCTOR ASA OR CONTRIBUTORS BE
-- LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
-- CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
-- GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
-- HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
-- LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
-- OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
--
-- This spec has been automatically generated from nrf52.svd
pragma Restrictions (No_Elaboration_Code);
pragma Ada_2012;
pragma Style_Checks (Off);
with HAL;
with System;
package NRF_SVD.UART is
pragma Preelaborate;
---------------
-- Registers --
---------------
-- Shortcut between CTS event and STARTRX task
type SHORTS_CTS_STARTRX_Field is
(-- Disable shortcut
Disabled,
-- Enable shortcut
Enabled)
with Size => 1;
for SHORTS_CTS_STARTRX_Field use
(Disabled => 0,
Enabled => 1);
-- Shortcut between NCTS event and STOPRX task
type SHORTS_NCTS_STOPRX_Field is
(-- Disable shortcut
Disabled,
-- Enable shortcut
Enabled)
with Size => 1;
for SHORTS_NCTS_STOPRX_Field use
(Disabled => 0,
Enabled => 1);
-- Shortcut register
type SHORTS_Register is record
-- unspecified
Reserved_0_2 : HAL.UInt3 := 16#0#;
-- Shortcut between CTS event and STARTRX task
CTS_STARTRX : SHORTS_CTS_STARTRX_Field := NRF_SVD.UART.Disabled;
-- Shortcut between NCTS event and STOPRX task
NCTS_STOPRX : SHORTS_NCTS_STOPRX_Field := NRF_SVD.UART.Disabled;
-- unspecified
Reserved_5_31 : HAL.UInt27 := 16#0#;
end record
with Volatile_Full_Access, Object_Size => 32,
Bit_Order => System.Low_Order_First;
for SHORTS_Register use record
Reserved_0_2 at 0 range 0 .. 2;
CTS_STARTRX at 0 range 3 .. 3;
NCTS_STOPRX at 0 range 4 .. 4;
Reserved_5_31 at 0 range 5 .. 31;
end record;
-- Write '1' to Enable interrupt for CTS event
type INTENSET_CTS_Field is
(-- Read: Disabled
Disabled,
-- Read: Enabled
Enabled)
with Size => 1;
for INTENSET_CTS_Field use
(Disabled => 0,
Enabled => 1);
-- Write '1' to Enable interrupt for CTS event
type INTENSET_CTS_Field_1 is
(-- Reset value for the field
Intenset_Cts_Field_Reset,
-- Enable
Set)
with Size => 1;
for INTENSET_CTS_Field_1 use
(Intenset_Cts_Field_Reset => 0,
Set => 1);
-- Write '1' to Enable interrupt for NCTS event
type INTENSET_NCTS_Field is
(-- Read: Disabled
Disabled,
-- Read: Enabled
Enabled)
with Size => 1;
for INTENSET_NCTS_Field use
(Disabled => 0,
Enabled => 1);
-- Write '1' to Enable interrupt for NCTS event
type INTENSET_NCTS_Field_1 is
(-- Reset value for the field
Intenset_Ncts_Field_Reset,
-- Enable
Set)
with Size => 1;
for INTENSET_NCTS_Field_1 use
(Intenset_Ncts_Field_Reset => 0,
Set => 1);
-- Write '1' to Enable interrupt for RXDRDY event
type INTENSET_RXDRDY_Field is
(-- Read: Disabled
Disabled,
-- Read: Enabled
Enabled)
with Size => 1;
for INTENSET_RXDRDY_Field use
(Disabled => 0,
Enabled => 1);
-- Write '1' to Enable interrupt for RXDRDY event
type INTENSET_RXDRDY_Field_1 is
(-- Reset value for the field
Intenset_Rxdrdy_Field_Reset,
-- Enable
Set)
with Size => 1;
for INTENSET_RXDRDY_Field_1 use
(Intenset_Rxdrdy_Field_Reset => 0,
Set => 1);
-- Write '1' to Enable interrupt for TXDRDY event
type INTENSET_TXDRDY_Field is
(-- Read: Disabled
Disabled,
-- Read: Enabled
Enabled)
with Size => 1;
for INTENSET_TXDRDY_Field use
(Disabled => 0,
Enabled => 1);
-- Write '1' to Enable interrupt for TXDRDY event
type INTENSET_TXDRDY_Field_1 is
(-- Reset value for the field
Intenset_Txdrdy_Field_Reset,
-- Enable
Set)
with Size => 1;
for INTENSET_TXDRDY_Field_1 use
(Intenset_Txdrdy_Field_Reset => 0,
Set => 1);
-- Write '1' to Enable interrupt for ERROR event
type INTENSET_ERROR_Field is
(-- Read: Disabled
Disabled,
-- Read: Enabled
Enabled)
with Size => 1;
for INTENSET_ERROR_Field use
(Disabled => 0,
Enabled => 1);
-- Write '1' to Enable interrupt for ERROR event
type INTENSET_ERROR_Field_1 is
(-- Reset value for the field
Intenset_Error_Field_Reset,
-- Enable
Set)
with Size => 1;
for INTENSET_ERROR_Field_1 use
(Intenset_Error_Field_Reset => 0,
Set => 1);
-- Write '1' to Enable interrupt for RXTO event
type INTENSET_RXTO_Field is
(-- Read: Disabled
Disabled,
-- Read: Enabled
Enabled)
with Size => 1;
for INTENSET_RXTO_Field use
(Disabled => 0,
Enabled => 1);
-- Write '1' to Enable interrupt for RXTO event
type INTENSET_RXTO_Field_1 is
(-- Reset value for the field
Intenset_Rxto_Field_Reset,
-- Enable
Set)
with Size => 1;
for INTENSET_RXTO_Field_1 use
(Intenset_Rxto_Field_Reset => 0,
Set => 1);
-- Enable interrupt
type INTENSET_Register is record
-- Write '1' to Enable interrupt for CTS event
CTS : INTENSET_CTS_Field_1 := Intenset_Cts_Field_Reset;
-- Write '1' to Enable interrupt for NCTS event
NCTS : INTENSET_NCTS_Field_1 := Intenset_Ncts_Field_Reset;
-- Write '1' to Enable interrupt for RXDRDY event
RXDRDY : INTENSET_RXDRDY_Field_1 := Intenset_Rxdrdy_Field_Reset;
-- unspecified
Reserved_3_6 : HAL.UInt4 := 16#0#;
-- Write '1' to Enable interrupt for TXDRDY event
TXDRDY : INTENSET_TXDRDY_Field_1 := Intenset_Txdrdy_Field_Reset;
-- unspecified
Reserved_8_8 : HAL.Bit := 16#0#;
-- Write '1' to Enable interrupt for ERROR event
ERROR : INTENSET_ERROR_Field_1 := Intenset_Error_Field_Reset;
-- unspecified
Reserved_10_16 : HAL.UInt7 := 16#0#;
-- Write '1' to Enable interrupt for RXTO event
RXTO : INTENSET_RXTO_Field_1 := Intenset_Rxto_Field_Reset;
-- unspecified
Reserved_18_31 : HAL.UInt14 := 16#0#;
end record
with Volatile_Full_Access, Object_Size => 32,
Bit_Order => System.Low_Order_First;
for INTENSET_Register use record
CTS at 0 range 0 .. 0;
NCTS at 0 range 1 .. 1;
RXDRDY at 0 range 2 .. 2;
Reserved_3_6 at 0 range 3 .. 6;
TXDRDY at 0 range 7 .. 7;
Reserved_8_8 at 0 range 8 .. 8;
ERROR at 0 range 9 .. 9;
Reserved_10_16 at 0 range 10 .. 16;
RXTO at 0 range 17 .. 17;
Reserved_18_31 at 0 range 18 .. 31;
end record;
-- Write '1' to Disable interrupt for CTS event
type INTENCLR_CTS_Field is
(-- Read: Disabled
Disabled,
-- Read: Enabled
Enabled)
with Size => 1;
for INTENCLR_CTS_Field use
(Disabled => 0,
Enabled => 1);
-- Write '1' to Disable interrupt for CTS event
type INTENCLR_CTS_Field_1 is
(-- Reset value for the field
Intenclr_Cts_Field_Reset,
-- Disable
Clear)
with Size => 1;
for INTENCLR_CTS_Field_1 use
(Intenclr_Cts_Field_Reset => 0,
Clear => 1);
-- Write '1' to Disable interrupt for NCTS event
type INTENCLR_NCTS_Field is
(-- Read: Disabled
Disabled,
-- Read: Enabled
Enabled)
with Size => 1;
for INTENCLR_NCTS_Field use
(Disabled => 0,
Enabled => 1);
-- Write '1' to Disable interrupt for NCTS event
type INTENCLR_NCTS_Field_1 is
(-- Reset value for the field
Intenclr_Ncts_Field_Reset,
-- Disable
Clear)
with Size => 1;
for INTENCLR_NCTS_Field_1 use
(Intenclr_Ncts_Field_Reset => 0,
Clear => 1);
-- Write '1' to Disable interrupt for RXDRDY event
type INTENCLR_RXDRDY_Field is
(-- Read: Disabled
Disabled,
-- Read: Enabled
Enabled)
with Size => 1;
for INTENCLR_RXDRDY_Field use
(Disabled => 0,
Enabled => 1);
-- Write '1' to Disable interrupt for RXDRDY event
type INTENCLR_RXDRDY_Field_1 is
(-- Reset value for the field
Intenclr_Rxdrdy_Field_Reset,
-- Disable
Clear)
with Size => 1;
for INTENCLR_RXDRDY_Field_1 use
(Intenclr_Rxdrdy_Field_Reset => 0,
Clear => 1);
-- Write '1' to Disable interrupt for TXDRDY event
type INTENCLR_TXDRDY_Field is
(-- Read: Disabled
Disabled,
-- Read: Enabled
Enabled)
with Size => 1;
for INTENCLR_TXDRDY_Field use
(Disabled => 0,
Enabled => 1);
-- Write '1' to Disable interrupt for TXDRDY event
type INTENCLR_TXDRDY_Field_1 is
(-- Reset value for the field
Intenclr_Txdrdy_Field_Reset,
-- Disable
Clear)
with Size => 1;
for INTENCLR_TXDRDY_Field_1 use
(Intenclr_Txdrdy_Field_Reset => 0,
Clear => 1);
-- Write '1' to Disable interrupt for ERROR event
type INTENCLR_ERROR_Field is
(-- Read: Disabled
Disabled,
-- Read: Enabled
Enabled)
with Size => 1;
for INTENCLR_ERROR_Field use
(Disabled => 0,
Enabled => 1);
-- Write '1' to Disable interrupt for ERROR event
type INTENCLR_ERROR_Field_1 is
(-- Reset value for the field
Intenclr_Error_Field_Reset,
-- Disable
Clear)
with Size => 1;
for INTENCLR_ERROR_Field_1 use
(Intenclr_Error_Field_Reset => 0,
Clear => 1);
-- Write '1' to Disable interrupt for RXTO event
type INTENCLR_RXTO_Field is
(-- Read: Disabled
Disabled,
-- Read: Enabled
Enabled)
with Size => 1;
for INTENCLR_RXTO_Field use
(Disabled => 0,
Enabled => 1);
-- Write '1' to Disable interrupt for RXTO event
type INTENCLR_RXTO_Field_1 is
(-- Reset value for the field
Intenclr_Rxto_Field_Reset,
-- Disable
Clear)
with Size => 1;
for INTENCLR_RXTO_Field_1 use
(Intenclr_Rxto_Field_Reset => 0,
Clear => 1);
-- Disable interrupt
type INTENCLR_Register is record
-- Write '1' to Disable interrupt for CTS event
CTS : INTENCLR_CTS_Field_1 := Intenclr_Cts_Field_Reset;
-- Write '1' to Disable interrupt for NCTS event
NCTS : INTENCLR_NCTS_Field_1 := Intenclr_Ncts_Field_Reset;
-- Write '1' to Disable interrupt for RXDRDY event
RXDRDY : INTENCLR_RXDRDY_Field_1 := Intenclr_Rxdrdy_Field_Reset;
-- unspecified
Reserved_3_6 : HAL.UInt4 := 16#0#;
-- Write '1' to Disable interrupt for TXDRDY event
TXDRDY : INTENCLR_TXDRDY_Field_1 := Intenclr_Txdrdy_Field_Reset;
-- unspecified
Reserved_8_8 : HAL.Bit := 16#0#;
-- Write '1' to Disable interrupt for ERROR event
ERROR : INTENCLR_ERROR_Field_1 := Intenclr_Error_Field_Reset;
-- unspecified
Reserved_10_16 : HAL.UInt7 := 16#0#;
-- Write '1' to Disable interrupt for RXTO event
RXTO : INTENCLR_RXTO_Field_1 := Intenclr_Rxto_Field_Reset;
-- unspecified
Reserved_18_31 : HAL.UInt14 := 16#0#;
end record
with Volatile_Full_Access, Object_Size => 32,
Bit_Order => System.Low_Order_First;
for INTENCLR_Register use record
CTS at 0 range 0 .. 0;
NCTS at 0 range 1 .. 1;
RXDRDY at 0 range 2 .. 2;
Reserved_3_6 at 0 range 3 .. 6;
TXDRDY at 0 range 7 .. 7;
Reserved_8_8 at 0 range 8 .. 8;
ERROR at 0 range 9 .. 9;
Reserved_10_16 at 0 range 10 .. 16;
RXTO at 0 range 17 .. 17;
Reserved_18_31 at 0 range 18 .. 31;
end record;
-- Overrun error
type ERRORSRC_OVERRUN_Field is
(-- Read: error not present
Notpresent,
-- Read: error present
Present)
with Size => 1;
for ERRORSRC_OVERRUN_Field use
(Notpresent => 0,
Present => 1);
-- Parity error
type ERRORSRC_PARITY_Field is
(-- Read: error not present
Notpresent,
-- Read: error present
Present)
with Size => 1;
for ERRORSRC_PARITY_Field use
(Notpresent => 0,
Present => 1);
-- Framing error occurred
type ERRORSRC_FRAMING_Field is
(-- Read: error not present
Notpresent,
-- Read: error present
Present)
with Size => 1;
for ERRORSRC_FRAMING_Field use
(Notpresent => 0,
Present => 1);
-- Break condition
type ERRORSRC_BREAK_Field is
(-- Read: error not present
Notpresent,
-- Read: error present
Present)
with Size => 1;
for ERRORSRC_BREAK_Field use
(Notpresent => 0,
Present => 1);
-- Error source
type ERRORSRC_Register is record
-- Overrun error
OVERRUN : ERRORSRC_OVERRUN_Field := NRF_SVD.UART.Notpresent;
-- Parity error
PARITY : ERRORSRC_PARITY_Field := NRF_SVD.UART.Notpresent;
-- Framing error occurred
FRAMING : ERRORSRC_FRAMING_Field := NRF_SVD.UART.Notpresent;
-- Break condition
BREAK : ERRORSRC_BREAK_Field := NRF_SVD.UART.Notpresent;
-- unspecified
Reserved_4_31 : HAL.UInt28 := 16#0#;
end record
with Volatile_Full_Access, Object_Size => 32,
Bit_Order => System.Low_Order_First;
for ERRORSRC_Register use record
OVERRUN at 0 range 0 .. 0;
PARITY at 0 range 1 .. 1;
FRAMING at 0 range 2 .. 2;
BREAK at 0 range 3 .. 3;
Reserved_4_31 at 0 range 4 .. 31;
end record;
-- Enable or disable UART
type ENABLE_ENABLE_Field is
(-- Disable UART
Disabled,
-- Enable UART
Enabled)
with Size => 4;
for ENABLE_ENABLE_Field use
(Disabled => 0,
Enabled => 4);
-- Enable UART
type ENABLE_Register is record
-- Enable or disable UART
ENABLE : ENABLE_ENABLE_Field := NRF_SVD.UART.Disabled;
-- unspecified
Reserved_4_31 : HAL.UInt28 := 16#0#;
end record
with Volatile_Full_Access, Object_Size => 32,
Bit_Order => System.Low_Order_First;
for ENABLE_Register use record
ENABLE at 0 range 0 .. 3;
Reserved_4_31 at 0 range 4 .. 31;
end record;
subtype RXD_RXD_Field is HAL.UInt8;
-- RXD register
type RXD_Register is record
-- Read-only. *** Reading this field has side effects on other resources
-- ***. RX data received in previous transfers, double buffered
RXD : RXD_RXD_Field;
-- unspecified
Reserved_8_31 : HAL.UInt24;
end record
with Volatile_Full_Access, Object_Size => 32,
Bit_Order => System.Low_Order_First;
for RXD_Register use record
RXD at 0 range 0 .. 7;
Reserved_8_31 at 0 range 8 .. 31;
end record;
subtype TXD_TXD_Field is HAL.UInt8;
-- TXD register
type TXD_Register is record
-- Write-only. TX data to be transferred
TXD : TXD_TXD_Field := 16#0#;
-- unspecified
Reserved_8_31 : HAL.UInt24 := 16#0#;
end record
with Volatile_Full_Access, Object_Size => 32,
Bit_Order => System.Low_Order_First;
for TXD_Register use record
TXD at 0 range 0 .. 7;
Reserved_8_31 at 0 range 8 .. 31;
end record;
-- Hardware flow control
type CONFIG_HWFC_Field is
(-- Disabled
Disabled,
-- Enabled
Enabled)
with Size => 1;
for CONFIG_HWFC_Field use
(Disabled => 0,
Enabled => 1);
-- Parity
type CONFIG_PARITY_Field is
(-- Exclude parity bit
Excluded,
-- Include parity bit
Included)
with Size => 3;
for CONFIG_PARITY_Field use
(Excluded => 0,
Included => 7);
-- Configuration of parity and hardware flow control
type CONFIG_Register is record
-- Hardware flow control
HWFC : CONFIG_HWFC_Field := NRF_SVD.UART.Disabled;
-- Parity
PARITY : CONFIG_PARITY_Field := NRF_SVD.UART.Excluded;
-- unspecified
Reserved_4_31 : HAL.UInt28 := 16#0#;
end record
with Volatile_Full_Access, Object_Size => 32,
Bit_Order => System.Low_Order_First;
for CONFIG_Register use record
HWFC at 0 range 0 .. 0;
PARITY at 0 range 1 .. 3;
Reserved_4_31 at 0 range 4 .. 31;
end record;
-----------------
-- Peripherals --
-----------------
-- Universal Asynchronous Receiver/Transmitter
type UART_Peripheral is record
-- Start UART receiver
TASKS_STARTRX : aliased HAL.UInt32;
-- Stop UART receiver
TASKS_STOPRX : aliased HAL.UInt32;
-- Start UART transmitter
TASKS_STARTTX : aliased HAL.UInt32;
-- Stop UART transmitter
TASKS_STOPTX : aliased HAL.UInt32;
-- Suspend UART
TASKS_SUSPEND : aliased HAL.UInt32;
-- CTS is activated (set low). Clear To Send.
EVENTS_CTS : aliased HAL.UInt32;
-- CTS is deactivated (set high). Not Clear To Send.
EVENTS_NCTS : aliased HAL.UInt32;
-- Data received in RXD
EVENTS_RXDRDY : aliased HAL.UInt32;
-- Data sent from TXD
EVENTS_TXDRDY : aliased HAL.UInt32;
-- Error detected
EVENTS_ERROR : aliased HAL.UInt32;
-- Receiver timeout
EVENTS_RXTO : aliased HAL.UInt32;
-- Shortcut register
SHORTS : aliased SHORTS_Register;
-- Enable interrupt
INTENSET : aliased INTENSET_Register;
-- Disable interrupt
INTENCLR : aliased INTENCLR_Register;
-- Error source
ERRORSRC : aliased ERRORSRC_Register;
-- Enable UART
ENABLE : aliased ENABLE_Register;
-- Pin select for RTS
PSELRTS : aliased HAL.UInt32;
-- Pin select for TXD
PSELTXD : aliased HAL.UInt32;
-- Pin select for CTS
PSELCTS : aliased HAL.UInt32;
-- Pin select for RXD
PSELRXD : aliased HAL.UInt32;
-- RXD register
RXD : aliased RXD_Register;
-- TXD register
TXD : aliased TXD_Register;
-- Baud rate
BAUDRATE : aliased HAL.UInt32;
-- Configuration of parity and hardware flow control
CONFIG : aliased CONFIG_Register;
end record
with Volatile;
for UART_Peripheral use record
TASKS_STARTRX at 16#0# range 0 .. 31;
TASKS_STOPRX at 16#4# range 0 .. 31;
TASKS_STARTTX at 16#8# range 0 .. 31;
TASKS_STOPTX at 16#C# range 0 .. 31;
TASKS_SUSPEND at 16#1C# range 0 .. 31;
EVENTS_CTS at 16#100# range 0 .. 31;
EVENTS_NCTS at 16#104# range 0 .. 31;
EVENTS_RXDRDY at 16#108# range 0 .. 31;
EVENTS_TXDRDY at 16#11C# range 0 .. 31;
EVENTS_ERROR at 16#124# range 0 .. 31;
EVENTS_RXTO at 16#144# range 0 .. 31;
SHORTS at 16#200# range 0 .. 31;
INTENSET at 16#304# range 0 .. 31;
INTENCLR at 16#308# range 0 .. 31;
ERRORSRC at 16#480# range 0 .. 31;
ENABLE at 16#500# range 0 .. 31;
PSELRTS at 16#508# range 0 .. 31;
PSELTXD at 16#50C# range 0 .. 31;
PSELCTS at 16#510# range 0 .. 31;
PSELRXD at 16#514# range 0 .. 31;
RXD at 16#518# range 0 .. 31;
TXD at 16#51C# range 0 .. 31;
BAUDRATE at 16#524# range 0 .. 31;
CONFIG at 16#56C# range 0 .. 31;
end record;
-- Universal Asynchronous Receiver/Transmitter
UART0_Periph : aliased UART_Peripheral
with Import, Address => UART0_Base;
end NRF_SVD.UART;
|
zhmu/ananas | Ada | 2,561 | ads | ------------------------------------------------------------------------------
-- --
-- GNAT RUN-TIME COMPONENTS --
-- --
-- S Y S T E M . E X N _ F L T --
-- --
-- S p e c --
-- --
-- Copyright (C) 2021-2022, Free Software Foundation, Inc. --
-- --
-- GNAT is free software; you can redistribute it and/or modify it under --
-- terms of the GNU General Public License as published by the Free Soft- --
-- ware Foundation; either version 3, or (at your option) any later ver- --
-- sion. GNAT is distributed in the hope that it will be useful, but WITH- --
-- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY --
-- or FITNESS FOR A PARTICULAR PURPOSE. --
-- --
-- As a special exception under Section 7 of GPL version 3, you are granted --
-- additional permissions described in the GCC Runtime Library Exception, --
-- version 3.1, as published by the Free Software Foundation. --
-- --
-- You should have received a copy of the GNU General Public License and --
-- a copy of the GCC Runtime Library Exception along with this program; --
-- see the files COPYING3 and COPYING.RUNTIME respectively. If not, see --
-- <http://www.gnu.org/licenses/>. --
-- --
-- GNAT was originally developed by the GNAT team at New York University. --
-- Extensive contributions were provided by Ada Core Technologies Inc. --
-- --
------------------------------------------------------------------------------
-- Float exponentiation (checks off)
with System.Exponr;
package System.Exn_Flt is
function Exn_Float is new Exponr (Float);
pragma Pure_Function (Exn_Float);
end System.Exn_Flt;
|
stcarrez/dynamo | Ada | 12,484 | ads | ------------------------------------------------------------------------------
-- --
-- ASIS-for-GNAT INTERFACE COMPONENTS --
-- --
-- A S I S . I M P L E M E N T A T I O N . P E R M I S S I O N S --
-- --
-- S p e c --
-- --
-- $Revision: 14416 $
-- --
-- This specification is adapted from the Ada Semantic Interface --
-- Specification Standard (ISO/IEC 15291) for use with GNAT. In accordance --
-- with the copyright of that document, you can freely copy and modify this --
-- specification, provided that if you redistribute a modified version, any --
-- changes that you have made are clearly indicated. --
-- --
------------------------------------------------------------------------------
------------------------------------------------------------------------------
-- 7 package Asis.Implementation.Permissions
------------------------------------------------------------------------------
package Asis.Implementation.Permissions is
------------------------------------------------------------------------------
-- 7.1 function Is_Formal_Parameter_Named_Notation_Supported
------------------------------------------------------------------------------
function Is_Formal_Parameter_Named_Notation_Supported return Boolean;
------------------------------------------------------------------------------
-- Returns True if it is possible to detect usage of named notation.
--
-- Returns False if this implementation will always change parameter lists
-- using named notation to positional lists in function, subprogram, and
-- entry calls. In that case, the Formal_Parameter query will always return
-- a Nil_Element unless the parameter list is obtained with Normalized = True.
--
-- This function affects association lists for aggregates, instantiations,
-- discriminant lists, entry calls, and subprogram calls.
--
------------------------------------------------------------------------------
-- 7.2 function Default_In_Mode_Supported
------------------------------------------------------------------------------
function Default_In_Mode_Supported return Boolean;
------------------------------------------------------------------------------
-- Returns True if the A_Default_In_Mode kind is supported by this
-- implementation.
--
------------------------------------------------------------------------------
-- 7.3 function Generic_Actual_Part_Normalized
------------------------------------------------------------------------------
function Generic_Actual_Part_Normalized return Boolean;
------------------------------------------------------------------------------
-- Returns True if the query Generic_Actual_Part will always return artificial
-- Is_Normalized associations using the defining_identifier instead of the
-- generic_formal_parameter_selector_name, and using default_expression or
-- default_name.
--
-- if Generic_Actual_Part_Normalized then the query Generic_Actual_Part will
-- always behave as if called with Normalized => True.
--
------------------------------------------------------------------------------
-- 7.4 function Record_Component_Associations_Normalized
------------------------------------------------------------------------------
function Record_Component_Associations_Normalized return Boolean;
------------------------------------------------------------------------------
-- Returns True if the query Record_Component_Associations will always return
-- artificial Is_Normalized associations using the defining_identifier instead
-- of the component_selector_name.
--
-- if Record_Component_Associations_Normalized then the query
-- Record_Component_Associations will always behave as if called with
-- Normalized => True.
--
------------------------------------------------------------------------------
-- 7.5 function Is_Prefix_Call_Supported
------------------------------------------------------------------------------
function Is_Prefix_Call_Supported return Boolean;
------------------------------------------------------------------------------
-- Returns True if the ASIS implementation has the ability to determine
-- whether calls are in prefix form.
--
------------------------------------------------------------------------------
-- 7.6 function Function_Call_Parameters_Normalized
------------------------------------------------------------------------------
function Function_Call_Parameters_Normalized return Boolean;
------------------------------------------------------------------------------
-- Returns True if the query Function_Call_Parameters will always return
-- artificial Is_Normalized associations using the defining_identifier instead
-- of the formal_parameter_selector_name, and using the default_expression.
--
-- if Function_Call_Parameters_Normalized then the query
-- Function_Call_Parameters will always behave as if called with
-- Normalized => True.
--
------------------------------------------------------------------------------
-- 7.7 function Call_Statement_Parameters_Normalized
------------------------------------------------------------------------------
function Call_Statement_Parameters_Normalized return Boolean;
------------------------------------------------------------------------------
-- Returns True if the query Call_Statement_Parameters will always return
-- artificial Is_Normalized associations using the defining_identifier instead
-- of the formal_parameter_selector_name, and using the default_expression.
--
-- if Call_Statement_Parameters_Normalized then the query
-- Call_Statement_Parameters will always behave as if called with
-- Normalized => True.
--
------------------------------------------------------------------------------
-- It is not possible to obtain either a normalized or
-- unnormalized Discriminant_Association list for an unconstrained record
-- or derived subtype_indication where the discriminant_association is
-- supplied by default; there is no constraint to query, and a Nil_Element
-- is returned from the query Subtype_Constraint.
--
------------------------------------------------------------------------------
-- 7.8 function Discriminant_Associations_Normalized
------------------------------------------------------------------------------
function Discriminant_Associations_Normalized return Boolean;
------------------------------------------------------------------------------
-- Returns True if the query Discriminant_Associations will always return
-- artificial Is_Normalized associations using the defining_identifier instead
-- of the discriminant_selector_name.
--
-- if Discriminant_Associations_Normalized then the query
-- Discriminant_Associations will always behave as if called with
-- Normalized => True.
--
------------------------------------------------------------------------------
-- 7.9 function Is_Line_Number_Supported
------------------------------------------------------------------------------
function Is_Line_Number_Supported return Boolean;
------------------------------------------------------------------------------
-- Returns True if the implementation can return valid line numbers for
-- Elements.
--
-- An implementation may choose to ignore line number values in which case
-- this function returns False.
--
------------------------------------------------------------------------------
-- 7.10 function Is_Span_Column_Position_Supported
------------------------------------------------------------------------------
function Is_Span_Column_Position_Supported return Boolean;
------------------------------------------------------------------------------
-- Returns True if the implementation can return valid character positions for
-- elements.
--
-- An implementation may choose to ignore column character position values
-- within spans in which case this function returns False. This function will
-- be False if Is_Line_Number_Supported = False.
--
------------------------------------------------------------------------------
-- 7.11 function Is_Commentary_Supported
------------------------------------------------------------------------------
function Is_Commentary_Supported return Boolean;
------------------------------------------------------------------------------
-- Returns True if the implementation can return comments.
--
-- An implementation may choose to ignore comments in the text in which case
-- the function Is_Commentary_Supported returns False.
--
------------------------------------------------------------------------------
-- 7.12 function Attributes_Are_Supported
------------------------------------------------------------------------------
function Attributes_Are_Supported return Boolean;
------------------------------------------------------------------------------
-- Returns True if an implementation supports compilation unit attributes.
-- Returns False if all attributes will return Has_Attribute() = False.
--
------------------------------------------------------------------------------
-- 7.13 function Implicit_Components_Supported
------------------------------------------------------------------------------
function Implicit_Components_Supported return Boolean;
------------------------------------------------------------------------------
-- Returns True if the implementation provides elements representing
-- implicit implementation-defined record components.
--
------------------------------------------------------------------------------
-- 7.14 function Object_Declarations_Normalized
------------------------------------------------------------------------------
function Object_Declarations_Normalized return Boolean;
------------------------------------------------------------------------------
-- Returns True if the implementation normalizes multiple object declarations
-- to an equivalent sequence of single declarations.
--
------------------------------------------------------------------------------
-- 7.15 function Predefined_Operations_Supported
------------------------------------------------------------------------------
function Predefined_Operations_Supported return Boolean;
------------------------------------------------------------------------------
-- Returns True if the implementation supports queries of predefined
-- operations.
--
------------------------------------------------------------------------------
-- 7.16 function Inherited_Declarations_Supported
------------------------------------------------------------------------------
function Inherited_Declarations_Supported return Boolean;
------------------------------------------------------------------------------
-- Returns True if the implementation supports queries of inherited
-- declarations.
--
------------------------------------------------------------------------------
-- 7.17 function Inherited_Subprograms_Supported
------------------------------------------------------------------------------
function Inherited_Subprograms_Supported return Boolean;
------------------------------------------------------------------------------
-- Returns True if the implementation supports queries of inherited
-- subprograms.
--
------------------------------------------------------------------------------
-- 7.18 function Generic_Macro_Expansion_Supported
------------------------------------------------------------------------------
function Generic_Macro_Expansion_Supported return Boolean;
------------------------------------------------------------------------------
-- Returns True if the implementation expands generics using macros to
-- supports queries.
------------------------------------------------------------------------------
end Asis.Implementation.Permissions;
|
zhmu/ananas | Ada | 76,066 | adb | ------------------------------------------------------------------------------
-- --
-- GNAT COMPILER COMPONENTS --
-- --
-- R E P I N F O --
-- --
-- B o d y --
-- --
-- Copyright (C) 1999-2022, Free Software Foundation, Inc. --
-- --
-- GNAT is free software; you can redistribute it and/or modify it under --
-- terms of the GNU General Public License as published by the Free Soft- --
-- ware Foundation; either version 3, or (at your option) any later ver- --
-- sion. GNAT is distributed in the hope that it will be useful, but WITH- --
-- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY --
-- or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License --
-- for more details. You should have received a copy of the GNU General --
-- Public License distributed with GNAT; see file COPYING3. If not, go to --
-- http://www.gnu.org/licenses for a complete copy of the license. --
-- --
-- GNAT was originally developed by the GNAT team at New York University. --
-- Extensive contributions were provided by Ada Core Technologies Inc. --
-- --
------------------------------------------------------------------------------
with Alloc;
with Atree; use Atree;
with Casing; use Casing;
with Debug; use Debug;
with Einfo; use Einfo;
with Einfo.Entities; use Einfo.Entities;
with Einfo.Utils; use Einfo.Utils;
with Lib; use Lib;
with Namet; use Namet;
with Nlists; use Nlists;
with Opt; use Opt;
with Output; use Output;
with Osint.C; use Osint.C;
with Sem_Aux; use Sem_Aux;
with Sem_Eval; use Sem_Eval;
with Sem_Util;
with Sinfo; use Sinfo;
with Sinfo.Nodes; use Sinfo.Nodes;
with Sinfo.Utils; use Sinfo.Utils;
with Sinput; use Sinput;
with Snames; use Snames;
with Stringt; use Stringt;
with Table;
with Ttypes;
with Uname; use Uname;
with Urealp; use Urealp;
with Ada.Unchecked_Conversion;
with GNAT.HTable;
package body Repinfo is
SSU : Pos renames Ttypes.System_Storage_Unit;
-- Value for Storage_Unit
---------------------------------------
-- Representation of GCC Expressions --
---------------------------------------
-- A table internal to this unit is used to hold the values of back
-- annotated expressions.
-- Node values are stored as Uint values using the negative of the node
-- index in this table. Constants appear as non-negative Uint values.
type Exp_Node is record
Expr : TCode;
Op1 : Node_Ref_Or_Val;
Op2 : Node_Ref_Or_Val;
Op3 : Node_Ref_Or_Val;
end record;
-- The following representation clause ensures that the above record
-- has no holes. We do this so that when instances of this record are
-- written, we do not write uninitialized values to the file.
for Exp_Node use record
Expr at 0 range 0 .. 31;
Op1 at 4 range 0 .. 31;
Op2 at 8 range 0 .. 31;
Op3 at 12 range 0 .. 31;
end record;
for Exp_Node'Size use 16 * 8;
-- This ensures that we did not leave out any fields
package Rep_Table is new Table.Table (
Table_Component_Type => Exp_Node,
Table_Index_Type => Nat,
Table_Low_Bound => 1,
Table_Initial => Alloc.Rep_Table_Initial,
Table_Increment => Alloc.Rep_Table_Increment,
Table_Name => "BE_Rep_Table");
--------------------------------------------------------------
-- Representation of Front-End Dynamic Size/Offset Entities --
--------------------------------------------------------------
package Dynamic_SO_Entity_Table is new Table.Table (
Table_Component_Type => Entity_Id,
Table_Index_Type => Nat,
Table_Low_Bound => 1,
Table_Initial => Alloc.Rep_Table_Initial,
Table_Increment => Alloc.Rep_Table_Increment,
Table_Name => "FE_Rep_Table");
Unit_Casing : Casing_Type;
-- Identifier casing for current unit. This is set by List_Rep_Info for
-- each unit, before calling subprograms which may read it.
Need_Separator : Boolean;
-- Set True if a separator is needed before outputting any information for
-- the current entity.
------------------------------
-- Set of Relevant Entities --
------------------------------
Relevant_Entities_Size : constant := 4093;
-- Number of headers in hash table
subtype Entity_Header_Num is Integer range 0 .. Relevant_Entities_Size - 1;
-- Range of headers in hash table
function Entity_Hash (Id : Entity_Id) return Entity_Header_Num;
-- Simple hash function for Entity_Ids
package Relevant_Entities is new GNAT.Htable.Simple_HTable
(Header_Num => Entity_Header_Num,
Element => Boolean,
No_Element => False,
Key => Entity_Id,
Hash => Entity_Hash,
Equal => "=");
-- Hash table to record which compiler-generated entities are relevant
-----------------------
-- Local Subprograms --
-----------------------
procedure List_Entities
(Ent : Entity_Id;
Bytes_Big_Endian : Boolean;
In_Subprogram : Boolean := False);
-- This procedure lists the entities associated with the entity E, starting
-- with the First_Entity and using the Next_Entity link. If a nested
-- package is found, entities within the package are recursively processed.
-- When recursing within a subprogram body, Is_Subprogram suppresses
-- duplicate information about signature.
procedure List_Name (Ent : Entity_Id);
-- List name of entity Ent in appropriate case. The name is listed with
-- full qualification up to but not including the compilation unit name.
procedure List_Array_Info (Ent : Entity_Id; Bytes_Big_Endian : Boolean);
-- List representation info for array type Ent
procedure List_Common_Type_Info (Ent : Entity_Id);
-- List common type info (name, size, alignment) for type Ent
procedure List_Linker_Section (Ent : Entity_Id);
-- List linker section for Ent (caller has checked that Ent is an entity
-- for which the Linker_Section_Pragma field is defined).
procedure List_Location (Ent : Entity_Id);
-- List location information for Ent
procedure List_Object_Info (Ent : Entity_Id);
-- List representation info for object Ent
procedure List_Record_Info (Ent : Entity_Id; Bytes_Big_Endian : Boolean);
-- List representation info for record type Ent
procedure List_Scalar_Storage_Order
(Ent : Entity_Id;
Bytes_Big_Endian : Boolean);
-- List scalar storage order information for record or array type Ent.
-- Also includes bit order information for record types, if necessary.
procedure List_Subprogram_Info (Ent : Entity_Id);
-- List subprogram info for subprogram Ent
procedure List_Type_Info (Ent : Entity_Id);
-- List type info for type Ent
function Rep_Not_Constant (Val : Node_Ref_Or_Val) return Boolean;
-- Returns True if Val represents a variable value, and False if it
-- represents a value that is fixed at compile time.
procedure Spaces (N : Natural);
-- Output given number of spaces
procedure Write_Info_Line (S : String);
-- Routine to write a line to Repinfo output file. This routine is passed
-- as a special output procedure to Output.Set_Special_Output. Note that
-- Write_Info_Line is called with an EOL character at the end of each line,
-- as per the Output spec, but the internal call to the appropriate routine
-- in Osint requires that the end of line sequence be stripped off.
procedure Write_Mechanism (M : Mechanism_Type);
-- Writes symbolic string for mechanism represented by M
procedure Write_Separator;
-- Called before outputting anything for an entity. Ensures that
-- a separator precedes the output for a particular entity.
procedure Write_Unknown_Val;
-- Writes symbolic string for an unknown or non-representable value
procedure Write_Val (Val : Node_Ref_Or_Val; Paren : Boolean := False);
-- Given a representation value, write it out. No_Uint values or values
-- dependent on discriminants are written as two question marks. If the
-- flag Paren is set, then the output is surrounded in parentheses if it is
-- other than a simple value.
------------------------
-- Create_Discrim_Ref --
------------------------
function Create_Discrim_Ref (Discr : Entity_Id) return Node_Ref is
begin
return Create_Node
(Expr => Discrim_Val,
Op1 => Discriminant_Number (Discr));
end Create_Discrim_Ref;
---------------------------
-- Create_Dynamic_SO_Ref --
---------------------------
function Create_Dynamic_SO_Ref (E : Entity_Id) return Dynamic_SO_Ref is
begin
Dynamic_SO_Entity_Table.Append (E);
return UI_From_Int (-Dynamic_SO_Entity_Table.Last);
end Create_Dynamic_SO_Ref;
-----------------
-- Create_Node --
-----------------
function Create_Node
(Expr : TCode;
Op1 : Node_Ref_Or_Val;
Op2 : Node_Ref_Or_Val := No_Uint;
Op3 : Node_Ref_Or_Val := No_Uint) return Node_Ref
is
begin
Rep_Table.Append (
(Expr => Expr,
Op1 => Op1,
Op2 => Op2,
Op3 => Op3));
return UI_From_Int (-Rep_Table.Last);
end Create_Node;
-----------------
-- Entity_Hash --
-----------------
function Entity_Hash (Id : Entity_Id) return Entity_Header_Num is
begin
return Entity_Header_Num (Id mod Relevant_Entities_Size);
end Entity_Hash;
---------------------------
-- Get_Dynamic_SO_Entity --
---------------------------
function Get_Dynamic_SO_Entity (U : Dynamic_SO_Ref) return Entity_Id is
begin
return Dynamic_SO_Entity_Table.Table (-UI_To_Int (U));
end Get_Dynamic_SO_Entity;
-----------------------
-- Is_Dynamic_SO_Ref --
-----------------------
function Is_Dynamic_SO_Ref (U : SO_Ref) return Boolean is
begin
return U < Uint_0;
end Is_Dynamic_SO_Ref;
----------------------
-- Is_Static_SO_Ref --
----------------------
function Is_Static_SO_Ref (U : SO_Ref) return Boolean is
begin
return U >= Uint_0;
end Is_Static_SO_Ref;
---------
-- lgx --
---------
procedure lgx (U : Node_Ref_Or_Val) is
begin
List_GCC_Expression (U);
Write_Eol;
end lgx;
----------------------
-- List_Array_Info --
----------------------
procedure List_Array_Info (Ent : Entity_Id; Bytes_Big_Endian : Boolean) is
begin
Write_Separator;
if List_Representation_Info_To_JSON then
Write_Line ("{");
end if;
List_Common_Type_Info (Ent);
if List_Representation_Info_To_JSON then
Write_Line (",");
Write_Str (" ""Component_Size"": ");
Write_Val (Component_Size (Ent));
else
Write_Str ("for ");
List_Name (Ent);
Write_Str ("'Component_Size use ");
Write_Val (Component_Size (Ent));
Write_Line (";");
end if;
List_Scalar_Storage_Order (Ent, Bytes_Big_Endian);
List_Linker_Section (Ent);
if List_Representation_Info_To_JSON then
Write_Eol;
Write_Line ("}");
end if;
-- The component type is relevant for an array
if List_Representation_Info = 4
and then Is_Itype (Component_Type (Base_Type (Ent)))
then
Relevant_Entities.Set (Component_Type (Base_Type (Ent)), True);
end if;
end List_Array_Info;
---------------------------
-- List_Common_Type_Info --
---------------------------
procedure List_Common_Type_Info (Ent : Entity_Id) is
begin
if List_Representation_Info_To_JSON then
Write_Str (" ""name"": """);
List_Name (Ent);
Write_Line (""",");
List_Location (Ent);
end if;
-- Do not list size info for unconstrained arrays, not meaningful
if Is_Array_Type (Ent) and then not Is_Constrained (Ent) then
null;
else
if Known_Esize (Ent) and then Known_RM_Size (Ent) then
-- If Esize and RM_Size are the same, list as Size. This is a
-- common case, which we may as well list in simple form.
if Esize (Ent) = RM_Size (Ent) then
if List_Representation_Info_To_JSON then
Write_Str (" ""Size"": ");
Write_Val (Esize (Ent));
Write_Line (",");
else
Write_Str ("for ");
List_Name (Ent);
Write_Str ("'Size use ");
Write_Val (Esize (Ent));
Write_Line (";");
end if;
-- Otherwise list size values separately
else
if List_Representation_Info_To_JSON then
Write_Str (" ""Object_Size"": ");
Write_Val (Esize (Ent));
Write_Line (",");
Write_Str (" ""Value_Size"": ");
Write_Val (RM_Size (Ent));
Write_Line (",");
else
Write_Str ("for ");
List_Name (Ent);
Write_Str ("'Object_Size use ");
Write_Val (Esize (Ent));
Write_Line (";");
Write_Str ("for ");
List_Name (Ent);
Write_Str ("'Value_Size use ");
Write_Val (RM_Size (Ent));
Write_Line (";");
end if;
end if;
end if;
end if;
if Known_Alignment (Ent) then
if List_Representation_Info_To_JSON then
Write_Str (" ""Alignment"": ");
Write_Val (Alignment (Ent));
else
Write_Str ("for ");
List_Name (Ent);
Write_Str ("'Alignment use ");
Write_Val (Alignment (Ent));
Write_Line (";");
end if;
-- Alignment is not always set for task, protected, and class-wide
-- types. Representation aspects are not computed for types in a
-- generic unit.
else
pragma Assert
(Is_Concurrent_Type (Ent) or else
Is_Class_Wide_Type (Ent) or else
Sem_Util.In_Generic_Scope (Ent));
end if;
end List_Common_Type_Info;
-------------------
-- List_Entities --
-------------------
procedure List_Entities
(Ent : Entity_Id;
Bytes_Big_Endian : Boolean;
In_Subprogram : Boolean := False)
is
Body_E : Entity_Id;
E : Entity_Id;
function Find_Declaration (E : Entity_Id) return Node_Id;
-- Utility to retrieve declaration node for entity in the
-- case of package bodies and subprograms.
----------------------
-- Find_Declaration --
----------------------
function Find_Declaration (E : Entity_Id) return Node_Id is
Decl : Node_Id;
begin
Decl := Parent (E);
while Present (Decl)
and then Nkind (Decl) /= N_Package_Body
and then Nkind (Decl) /= N_Subprogram_Declaration
and then Nkind (Decl) /= N_Subprogram_Body
loop
Decl := Parent (Decl);
end loop;
return Decl;
end Find_Declaration;
-- Start of processing for List_Entities
begin
-- List entity if we have one, and it is not a renaming declaration.
-- For renamings, we don't get proper information, and really it makes
-- sense to restrict the output to the renamed entity.
if Present (Ent)
and then Nkind (Declaration_Node (Ent)) not in N_Renaming_Declaration
and then not Is_Ignored_Ghost_Entity (Ent)
then
-- If entity is a subprogram and we are listing mechanisms,
-- then we need to list mechanisms for this entity. We skip this
-- if it is a nested subprogram, as the information has already
-- been produced when listing the enclosing scope.
if List_Representation_Info_Mechanisms
and then Is_Subprogram_Or_Entry (Ent)
and then not In_Subprogram
then
List_Subprogram_Info (Ent);
end if;
E := First_Entity (Ent);
while Present (E) loop
-- We list entities that come from source (excluding private or
-- incomplete types or deferred constants, for which we will list
-- the information for the full view). If requested, we also list
-- relevant entities that have been generated when processing the
-- original entities coming from source. But if debug flag A is
-- set, then all entities are listed.
if ((Comes_From_Source (E)
or else (Ekind (E) = E_Block
and then
Nkind (Parent (E)) = N_Implicit_Label_Declaration
and then
Comes_From_Source (Label_Construct (Parent (E)))))
and then not Is_Incomplete_Or_Private_Type (E)
and then not (Ekind (E) = E_Constant
and then Present (Full_View (E))))
or else (List_Representation_Info = 4
and then Relevant_Entities.Get (E))
or else Debug_Flag_AA
then
if Is_Subprogram (E) then
if List_Representation_Info_Mechanisms then
List_Subprogram_Info (E);
end if;
-- Recurse into entities local to subprogram
List_Entities (E, Bytes_Big_Endian, True);
elsif Ekind (E) in E_Entry
| E_Entry_Family
| E_Subprogram_Type
then
if List_Representation_Info_Mechanisms then
List_Subprogram_Info (E);
end if;
elsif Is_Record_Type (E) then
if List_Representation_Info >= 1 then
List_Record_Info (E, Bytes_Big_Endian);
-- Recurse into entities local to a record type
if List_Representation_Info = 4 then
List_Entities (E, Bytes_Big_Endian, False);
end if;
end if;
elsif Is_Array_Type (E) then
if List_Representation_Info >= 1 then
List_Array_Info (E, Bytes_Big_Endian);
end if;
elsif Is_Type (E) then
if List_Representation_Info >= 2 then
List_Type_Info (E);
end if;
-- Note that formals are not annotated so we skip them here
elsif Ekind (E) in E_Constant
| E_Loop_Parameter
| E_Variable
then
if List_Representation_Info >= 2 then
List_Object_Info (E);
end if;
end if;
-- Recurse into nested package, but not child packages, and not
-- nested package renamings (in particular renamings of the
-- enclosing package, as for some Java bindings and for generic
-- instances).
if Ekind (E) = E_Package then
if No (Renamed_Entity (E)) and then not Is_Child_Unit (E)
then
List_Entities (E, Bytes_Big_Endian);
end if;
-- Recurse into bodies
elsif Ekind (E) in E_Package_Body
| E_Protected_Body
| E_Protected_Type
| E_Subprogram_Body
| E_Task_Body
| E_Task_Type
then
List_Entities (E, Bytes_Big_Endian);
-- Recurse into blocks
elsif Ekind (E) = E_Block then
List_Entities (E, Bytes_Big_Endian);
end if;
end if;
Next_Entity (E);
end loop;
-- For a package body, the entities of the visible subprograms are
-- declared in the corresponding spec. Iterate over its entities in
-- order to handle properly the subprogram bodies. Skip bodies in
-- subunits, which are listed independently.
if Ekind (Ent) = E_Package_Body
and then Present (Corresponding_Spec (Find_Declaration (Ent)))
then
E := First_Entity (Corresponding_Spec (Find_Declaration (Ent)));
while Present (E) loop
if Is_Subprogram (E)
and then
Nkind (Find_Declaration (E)) = N_Subprogram_Declaration
then
Body_E := Corresponding_Body (Find_Declaration (E));
if Present (Body_E)
and then
Nkind (Parent (Find_Declaration (Body_E))) /= N_Subunit
then
List_Entities (Body_E, Bytes_Big_Endian);
end if;
end if;
Next_Entity (E);
end loop;
end if;
end if;
end List_Entities;
-------------------------
-- List_GCC_Expression --
-------------------------
procedure List_GCC_Expression (U : Node_Ref_Or_Val) is
procedure Print_Expr (Val : Node_Ref_Or_Val);
-- Internal recursive procedure to print expression
----------------
-- Print_Expr --
----------------
procedure Print_Expr (Val : Node_Ref_Or_Val) is
begin
if Val >= 0 then
UI_Write (Val, Decimal);
else
declare
Node : Exp_Node renames Rep_Table.Table (-UI_To_Int (Val));
procedure Unop (S : String);
-- Output text for unary operator with S being operator name
procedure Binop (S : String);
-- Output text for binary operator with S being operator name
----------
-- Unop --
----------
procedure Unop (S : String) is
begin
if List_Representation_Info_To_JSON then
Write_Str ("{ ""code"": """);
if S (S'Last) = ' ' then
Write_Str (S (S'First .. S'Last - 1));
else
Write_Str (S);
end if;
Write_Str (""", ""operands"": [ ");
Print_Expr (Node.Op1);
Write_Str (" ] }");
else
Write_Str (S);
Print_Expr (Node.Op1);
end if;
end Unop;
-----------
-- Binop --
-----------
procedure Binop (S : String) is
begin
if List_Representation_Info_To_JSON then
Write_Str ("{ ""code"": """);
Write_Str (S (S'First + 1 .. S'Last - 1));
Write_Str (""", ""operands"": [ ");
Print_Expr (Node.Op1);
Write_Str (", ");
Print_Expr (Node.Op2);
Write_Str (" ] }");
else
Write_Char ('(');
Print_Expr (Node.Op1);
Write_Str (S);
Print_Expr (Node.Op2);
Write_Char (')');
end if;
end Binop;
-- Start of processing for Print_Expr
begin
case Node.Expr is
when Cond_Expr =>
if List_Representation_Info_To_JSON then
Write_Str ("{ ""code"": ""?<>""");
Write_Str (", ""operands"": [ ");
Print_Expr (Node.Op1);
Write_Str (", ");
Print_Expr (Node.Op2);
Write_Str (", ");
Print_Expr (Node.Op3);
Write_Str (" ] }");
else
Write_Str ("(if ");
Print_Expr (Node.Op1);
Write_Str (" then ");
Print_Expr (Node.Op2);
Write_Str (" else ");
Print_Expr (Node.Op3);
Write_Str (" end)");
end if;
when Plus_Expr =>
Binop (" + ");
when Minus_Expr =>
Binop (" - ");
when Mult_Expr =>
Binop (" * ");
when Trunc_Div_Expr =>
Binop (" /t ");
when Ceil_Div_Expr =>
Binop (" /c ");
when Floor_Div_Expr =>
Binop (" /f ");
when Trunc_Mod_Expr =>
Binop (" modt ");
when Ceil_Mod_Expr =>
Binop (" modc ");
when Floor_Mod_Expr =>
Binop (" modf ");
when Exact_Div_Expr =>
Binop (" /e ");
when Negate_Expr =>
Unop ("-");
when Min_Expr =>
Binop (" min ");
when Max_Expr =>
Binop (" max ");
when Abs_Expr =>
Unop ("abs ");
when Truth_And_Expr =>
Binop (" and ");
when Truth_Or_Expr =>
Binop (" or ");
when Truth_Xor_Expr =>
Binop (" xor ");
when Truth_Not_Expr =>
Unop ("not ");
when Lt_Expr =>
Binop (" < ");
when Le_Expr =>
Binop (" <= ");
when Gt_Expr =>
Binop (" > ");
when Ge_Expr =>
Binop (" >= ");
when Eq_Expr =>
Binop (" == ");
when Ne_Expr =>
Binop (" != ");
when Bit_And_Expr =>
Binop (" & ");
when Discrim_Val =>
Unop ("#");
when Dynamic_Val =>
Unop ("var");
end case;
end;
end if;
end Print_Expr;
-- Start of processing for List_GCC_Expression
begin
if No (U) then
Write_Unknown_Val;
else
Print_Expr (U);
end if;
end List_GCC_Expression;
-------------------------
-- List_Linker_Section --
-------------------------
procedure List_Linker_Section (Ent : Entity_Id) is
Args : List_Id;
Sect : Node_Id;
begin
if Present (Linker_Section_Pragma (Ent)) then
Args := Pragma_Argument_Associations (Linker_Section_Pragma (Ent));
Sect := Expr_Value_S (Get_Pragma_Arg (Last (Args)));
if List_Representation_Info_To_JSON then
Write_Line (",");
Write_Str (" ""Linker_Section"": """);
else
Write_Str ("pragma Linker_Section (");
List_Name (Ent);
Write_Str (", """);
end if;
pragma Assert (Nkind (Sect) = N_String_Literal);
String_To_Name_Buffer (Strval (Sect));
Write_Str (Name_Buffer (1 .. Name_Len));
Write_Str ("""");
if not List_Representation_Info_To_JSON then
Write_Line (");");
end if;
end if;
end List_Linker_Section;
-------------------
-- List_Location --
-------------------
procedure List_Location (Ent : Entity_Id) is
begin
pragma Assert (List_Representation_Info_To_JSON);
Write_Str (" ""location"": """);
Write_Location (Sloc (Ent));
Write_Line (""",");
end List_Location;
---------------
-- List_Name --
---------------
procedure List_Name (Ent : Entity_Id) is
C : Character;
begin
-- List the qualified name recursively, except
-- at compilation unit level in default mode.
if Is_Compilation_Unit (Ent) then
null;
elsif not Is_Compilation_Unit (Scope (Ent))
or else List_Representation_Info_To_JSON
then
List_Name (Scope (Ent));
Write_Char ('.');
end if;
Get_Unqualified_Decoded_Name_String (Chars (Ent));
Set_Casing (Unit_Casing);
-- The name of operators needs to be properly escaped for JSON
for J in 1 .. Name_Len loop
C := Name_Buffer (J);
if C = '"' and then List_Representation_Info_To_JSON then
Write_Char ('\');
end if;
Write_Char (C);
end loop;
end List_Name;
---------------------
-- List_Object_Info --
---------------------
procedure List_Object_Info (Ent : Entity_Id) is
begin
-- The information has not been computed in a generic unit, so don't try
-- to print it.
if Sem_Util.In_Generic_Scope (Ent) then
return;
end if;
Write_Separator;
if List_Representation_Info_To_JSON then
Write_Line ("{");
Write_Str (" ""name"": """);
List_Name (Ent);
Write_Line (""",");
List_Location (Ent);
Write_Str (" ""Size"": ");
Write_Val (Esize (Ent));
Write_Line (",");
Write_Str (" ""Alignment"": ");
Write_Val (Alignment (Ent));
List_Linker_Section (Ent);
Write_Eol;
Write_Line ("}");
else
Write_Str ("for ");
List_Name (Ent);
Write_Str ("'Size use ");
Write_Val (Esize (Ent));
Write_Line (";");
Write_Str ("for ");
List_Name (Ent);
Write_Str ("'Alignment use ");
Write_Val (Alignment (Ent));
Write_Line (";");
List_Linker_Section (Ent);
end if;
-- The type is relevant for an object
if List_Representation_Info = 4 and then Is_Itype (Etype (Ent)) then
Relevant_Entities.Set (Etype (Ent), True);
end if;
end List_Object_Info;
----------------------
-- List_Record_Info --
----------------------
procedure List_Record_Info (Ent : Entity_Id; Bytes_Big_Endian : Boolean) is
procedure Compute_Max_Length
(Ent : Entity_Id;
Starting_Position : Uint := Uint_0;
Starting_First_Bit : Uint := Uint_0;
Prefix_Length : Natural := 0);
-- Internal recursive procedure to compute the max length
procedure List_Component_Layout
(Ent : Entity_Id;
Starting_Position : Uint := Uint_0;
Starting_First_Bit : Uint := Uint_0;
Prefix : String := "";
Indent : Natural := 0);
-- Procedure to display the layout of a single component
procedure List_Record_Layout
(Ent : Entity_Id;
Starting_Position : Uint := Uint_0;
Starting_First_Bit : Uint := Uint_0;
Prefix : String := "");
-- Internal recursive procedure to display the layout
procedure List_Structural_Record_Layout
(Ent : Entity_Id;
Ext_Ent : Entity_Id;
Ext_Level : Nat := 0;
Variant : Node_Id := Empty;
Indent : Natural := 0);
-- Internal recursive procedure to display the structural layout.
-- If Ext_Ent is not equal to Ent, it is an extension of Ent and
-- Ext_Level is the number of successive extensions between them.
-- If Variant is present, it's for a variant in the variant part
-- instead of the common part of Ent. Indent is the indentation.
Incomplete_Layout : exception;
-- Exception raised if the layout is incomplete in -gnatc mode
Not_In_Extended_Main : exception;
-- Exception raised when an ancestor is not declared in the main unit
Max_Name_Length : Natural := 0;
Max_Spos_Length : Natural := 0;
------------------------
-- Compute_Max_Length --
------------------------
procedure Compute_Max_Length
(Ent : Entity_Id;
Starting_Position : Uint := Uint_0;
Starting_First_Bit : Uint := Uint_0;
Prefix_Length : Natural := 0)
is
Comp : Entity_Id;
begin
Comp := First_Component_Or_Discriminant (Ent);
while Present (Comp) loop
-- Skip a completely hidden discriminant or a discriminant in an
-- unchecked union (since it is not there).
if Ekind (Comp) = E_Discriminant
and then (Is_Completely_Hidden (Comp)
or else Is_Unchecked_Union (Ent))
then
goto Continue;
end if;
-- Skip _Parent component in extension (to avoid overlap)
if Chars (Comp) = Name_uParent then
goto Continue;
end if;
-- All other cases
declare
Ctyp : constant Entity_Id := Underlying_Type (Etype (Comp));
Bofs : constant Uint := Component_Bit_Offset (Comp);
Npos : Uint;
Fbit : Uint;
Spos : Uint;
Sbit : Uint;
Name_Length : Natural;
begin
Get_Decoded_Name_String (Chars (Comp));
Name_Length := Prefix_Length + Name_Len;
if Rep_Not_Constant (Bofs) then
-- If the record is not packed, then we know that all fields
-- whose position is not specified have starting normalized
-- bit position of zero.
if not Known_Normalized_First_Bit (Comp)
and then not Is_Packed (Ent)
then
Set_Normalized_First_Bit (Comp, Uint_0);
end if;
UI_Image_Length := 2; -- For "??" marker
else
Npos := Bofs / SSU;
Fbit := Bofs mod SSU;
-- Complete annotation in case not done
if not Known_Normalized_First_Bit (Comp) then
Set_Normalized_Position (Comp, Npos);
Set_Normalized_First_Bit (Comp, Fbit);
end if;
Spos := Starting_Position + Npos;
Sbit := Starting_First_Bit + Fbit;
if Sbit >= SSU then
Spos := Spos + 1;
Sbit := Sbit - SSU;
end if;
-- If extended information is requested, recurse fully into
-- record components, i.e. skip the outer level.
if List_Representation_Info_Extended
and then Is_Record_Type (Ctyp)
then
Compute_Max_Length (Ctyp, Spos, Sbit, Name_Length + 1);
goto Continue;
end if;
UI_Image (Spos);
end if;
Max_Name_Length := Natural'Max (Max_Name_Length, Name_Length);
Max_Spos_Length :=
Natural'Max (Max_Spos_Length, UI_Image_Length);
end;
<<Continue>>
Next_Component_Or_Discriminant (Comp);
end loop;
end Compute_Max_Length;
---------------------------
-- List_Component_Layout --
---------------------------
procedure List_Component_Layout
(Ent : Entity_Id;
Starting_Position : Uint := Uint_0;
Starting_First_Bit : Uint := Uint_0;
Prefix : String := "";
Indent : Natural := 0)
is
Esiz : constant Uint := Esize (Ent);
Npos : constant Uint := Normalized_Position (Ent);
Fbit : constant Uint := Normalized_First_Bit (Ent);
Spos : Uint;
Sbit : Uint := No_Uint;
Lbit : Uint;
begin
if List_Representation_Info_To_JSON then
Spaces (Indent);
Write_Line (" {");
Spaces (Indent);
Write_Str (" ""name"": """);
Write_Str (Prefix);
Write_Str (Name_Buffer (1 .. Name_Len));
Write_Line (""",");
if Ekind (Ent) = E_Discriminant then
Spaces (Indent);
Write_Str (" ""discriminant"": ");
UI_Write (Discriminant_Number (Ent), Decimal);
Write_Line (",");
end if;
Spaces (Indent);
Write_Str (" ""Position"": ");
else
Write_Str (" ");
Write_Str (Prefix);
Write_Str (Name_Buffer (1 .. Name_Len));
Spaces (Max_Name_Length - Prefix'Length - Name_Len);
Write_Str (" at ");
end if;
if Known_Static_Normalized_Position (Ent) then
Spos := Starting_Position + Npos;
Sbit := Starting_First_Bit + Fbit;
if Sbit >= SSU then
Spos := Spos + 1;
end if;
UI_Image (Spos);
Spaces (Max_Spos_Length - UI_Image_Length);
Write_Str (UI_Image_Buffer (1 .. UI_Image_Length));
elsif Known_Normalized_Position (Ent)
and then List_Representation_Info >= 3
then
Spaces (Max_Spos_Length - 2);
if Starting_Position /= Uint_0 then
UI_Write (Starting_Position, Decimal);
Write_Str (" + ");
end if;
Write_Val (Npos);
else
Write_Unknown_Val;
end if;
if List_Representation_Info_To_JSON then
Write_Line (",");
Spaces (Indent);
Write_Str (" ""First_Bit"": ");
else
Write_Str (" range ");
end if;
if Known_Static_Normalized_First_Bit (Ent) then
Sbit := Starting_First_Bit + Fbit;
if Sbit >= SSU then
Sbit := Sbit - SSU;
end if;
UI_Write (Sbit, Decimal);
else
Write_Unknown_Val;
end if;
if List_Representation_Info_To_JSON then
Write_Line (", ");
Spaces (Indent);
Write_Str (" ""Size"": ");
else
Write_Str (" .. ");
end if;
if Known_Static_Esize (Ent)
and then Known_Static_Normalized_First_Bit (Ent)
then
Lbit := Sbit + Esiz - 1;
if List_Representation_Info_To_JSON then
UI_Write (Esiz, Decimal);
else
if Lbit >= 0 and then Lbit < 10 then
Write_Char (' ');
end if;
UI_Write (Lbit, Decimal);
end if;
elsif List_Representation_Info < 3 or else not Known_Esize (Ent) then
Write_Unknown_Val;
-- List_Representation >= 3 and Known_Esize (Ent)
else
Write_Val (Esiz, Paren => not List_Representation_Info_To_JSON);
-- Add appropriate first bit offset
if not List_Representation_Info_To_JSON then
if Sbit = 0 then
Write_Str (" - 1");
elsif Sbit = 1 then
null;
else
Write_Str (" + ");
Write_Int (UI_To_Int (Sbit) - 1);
end if;
end if;
end if;
if List_Representation_Info_To_JSON then
Write_Eol;
Spaces (Indent);
Write_Str (" }");
else
Write_Line (";");
end if;
-- The type is relevant for a component
if List_Representation_Info = 4 and then Is_Itype (Etype (Ent)) then
Relevant_Entities.Set (Etype (Ent), True);
end if;
end List_Component_Layout;
------------------------
-- List_Record_Layout --
------------------------
procedure List_Record_Layout
(Ent : Entity_Id;
Starting_Position : Uint := Uint_0;
Starting_First_Bit : Uint := Uint_0;
Prefix : String := "")
is
Comp : Entity_Id;
First : Boolean := True;
begin
Comp := First_Component_Or_Discriminant (Ent);
while Present (Comp) loop
-- Skip a completely hidden discriminant or a discriminant in an
-- unchecked union (since it is not there).
if Ekind (Comp) = E_Discriminant
and then (Is_Completely_Hidden (Comp)
or else Is_Unchecked_Union (Ent))
then
goto Continue;
end if;
-- Skip _Parent component in extension (to avoid overlap)
if Chars (Comp) = Name_uParent then
goto Continue;
end if;
-- All other cases
declare
Ctyp : constant Entity_Id := Underlying_Type (Etype (Comp));
Npos : constant Uint := Normalized_Position (Comp);
Fbit : constant Uint := Normalized_First_Bit (Comp);
Spos : Uint;
Sbit : Uint;
begin
Get_Decoded_Name_String (Chars (Comp));
Set_Casing (Unit_Casing);
-- If extended information is requested, recurse fully into
-- record components, i.e. skip the outer level.
if List_Representation_Info_Extended
and then Is_Record_Type (Ctyp)
and then Known_Static_Normalized_Position (Comp)
and then Known_Static_Normalized_First_Bit (Comp)
then
Spos := Starting_Position + Npos;
Sbit := Starting_First_Bit + Fbit;
if Sbit >= SSU then
Spos := Spos + 1;
Sbit := Sbit - SSU;
end if;
List_Record_Layout (Ctyp,
Spos, Sbit, Prefix & Name_Buffer (1 .. Name_Len) & ".");
goto Continue;
end if;
if List_Representation_Info_To_JSON then
if First then
Write_Eol;
First := False;
else
Write_Line (",");
end if;
end if;
-- The Parent_Subtype in an extension is not back-annotated
List_Component_Layout (
(if Known_Normalized_Position (Comp)
then Comp
else Original_Record_Component (Comp)),
Starting_Position, Starting_First_Bit, Prefix);
end;
<<Continue>>
Next_Component_Or_Discriminant (Comp);
end loop;
end List_Record_Layout;
-----------------------------------
-- List_Structural_Record_Layout --
-----------------------------------
procedure List_Structural_Record_Layout
(Ent : Entity_Id;
Ext_Ent : Entity_Id;
Ext_Level : Nat := 0;
Variant : Node_Id := Empty;
Indent : Natural := 0)
is
function Derived_Discriminant (Disc : Entity_Id) return Entity_Id;
-- This function assumes that Ext_Ent is an extension of Ent.
-- Disc is a discriminant of Ent that does not itself constrain a
-- discriminant of the parent type of Ent. Return the discriminant
-- of Ext_Ent that ultimately constrains Disc, if any.
----------------------------
-- Derived_Discriminant --
----------------------------
function Derived_Discriminant (Disc : Entity_Id) return Entity_Id is
Corr_Disc : Entity_Id;
Derived_Disc : Entity_Id;
begin
Derived_Disc := First_Discriminant (Ext_Ent);
-- Loop over the discriminants of the extension
while Present (Derived_Disc) loop
-- Check if this discriminant constrains another discriminant.
-- If so, find the ultimately constrained discriminant and
-- compare with the original components in the base type.
if Present (Corresponding_Discriminant (Derived_Disc)) then
Corr_Disc := Corresponding_Discriminant (Derived_Disc);
while Present (Corresponding_Discriminant (Corr_Disc)) loop
Corr_Disc := Corresponding_Discriminant (Corr_Disc);
end loop;
if Original_Record_Component (Corr_Disc) =
Original_Record_Component (Disc)
then
return Derived_Disc;
end if;
end if;
Next_Discriminant (Derived_Disc);
end loop;
-- Disc is not constrained by a discriminant of Ext_Ent
return Empty;
end Derived_Discriminant;
-- Local declarations
Comp : Node_Id;
Comp_List : Node_Id;
First : Boolean := True;
Var : Node_Id;
-- Start of processing for List_Structural_Record_Layout
begin
-- If we are dealing with a variant, just process the components
if Present (Variant) then
Comp_List := Component_List (Variant);
-- Otherwise, we are dealing with the full record and need to get
-- to its definition in order to retrieve its structural layout.
else
declare
Definition : Node_Id :=
Type_Definition (Declaration_Node (Ent));
Is_Extension : constant Boolean :=
Is_Tagged_Type (Ent)
and then Nkind (Definition) =
N_Derived_Type_Definition;
Disc : Entity_Id;
Listed_Disc : Entity_Id;
Parent_Type : Entity_Id;
begin
-- If this is an extension, first list the layout of the parent
-- and then proceed to the extension part, if any.
if Is_Extension then
Parent_Type := Parent_Subtype (Ent);
if No (Parent_Type) then
raise Incomplete_Layout;
end if;
if Is_Private_Type (Parent_Type) then
Parent_Type := Full_View (Parent_Type);
pragma Assert (Present (Parent_Type));
end if;
-- Do not list variants if one of them has been selected
if Has_Static_Discriminants (Parent_Type) then
List_Record_Layout (Parent_Type);
else
Parent_Type := Base_Type (Parent_Type);
if not In_Extended_Main_Source_Unit (Parent_Type) then
raise Not_In_Extended_Main;
end if;
List_Structural_Record_Layout
(Parent_Type, Ext_Ent, Ext_Level + 1);
end if;
First := False;
if Present (Record_Extension_Part (Definition)) then
Definition := Record_Extension_Part (Definition);
end if;
end if;
-- If the record has discriminants and is not an unchecked
-- union, then display them now. Note that, even if this is
-- a structural layout, we list the visible discriminants.
if Has_Discriminants (Ent)
and then not Is_Unchecked_Union (Ent)
then
Disc := First_Discriminant (Ent);
while Present (Disc) loop
-- If this is a record extension and the discriminant is
-- the renaming of another discriminant, skip it.
if Is_Extension
and then Present (Corresponding_Discriminant (Disc))
then
goto Continue_Disc;
end if;
-- If this is the parent type of an extension, retrieve
-- the derived discriminant from the extension, if any.
if Ent /= Ext_Ent then
Listed_Disc := Derived_Discriminant (Disc);
if No (Listed_Disc) then
goto Continue_Disc;
end if;
else
Listed_Disc := Disc;
end if;
Get_Decoded_Name_String (Chars (Listed_Disc));
Set_Casing (Unit_Casing);
if First then
Write_Eol;
First := False;
else
Write_Line (",");
end if;
List_Component_Layout (Listed_Disc, Indent => Indent);
<<Continue_Disc>>
Next_Discriminant (Disc);
end loop;
end if;
Comp_List := Component_List (Definition);
end;
end if;
-- Bail out for the null record
if No (Comp_List) then
return;
end if;
-- Now deal with the regular components, if any
if Present (Component_Items (Comp_List)) then
Comp := First_Non_Pragma (Component_Items (Comp_List));
while Present (Comp) loop
-- Skip _Parent component in extension (to avoid overlap)
if Chars (Defining_Identifier (Comp)) = Name_uParent then
goto Continue_Comp;
end if;
Get_Decoded_Name_String (Chars (Defining_Identifier (Comp)));
Set_Casing (Unit_Casing);
if First then
Write_Eol;
First := False;
else
Write_Line (",");
end if;
List_Component_Layout
(Defining_Identifier (Comp), Indent => Indent);
<<Continue_Comp>>
Next_Non_Pragma (Comp);
end loop;
end if;
-- We are done if there is no variant part
if No (Variant_Part (Comp_List)) then
return;
end if;
Write_Eol;
Spaces (Indent);
Write_Line (" ],");
Spaces (Indent);
Write_Str (" """);
for J in 1 .. Ext_Level loop
Write_Str ("parent_");
end loop;
Write_Str ("variant"" : [");
-- Otherwise we recurse on each variant
Var := First_Non_Pragma (Variants (Variant_Part (Comp_List)));
First := True;
while Present (Var) loop
if First then
Write_Eol;
First := False;
else
Write_Line (",");
end if;
Spaces (Indent);
Write_Line (" {");
Spaces (Indent);
Write_Str (" ""present"": ");
Write_Val (Present_Expr (Var));
Write_Line (",");
Spaces (Indent);
Write_Str (" ""record"": [");
List_Structural_Record_Layout
(Ent, Ext_Ent, Ext_Level, Var, Indent + 4);
Write_Eol;
Spaces (Indent);
Write_Line (" ]");
Spaces (Indent);
Write_Str (" }");
Next_Non_Pragma (Var);
end loop;
end List_Structural_Record_Layout;
-- Start of processing for List_Record_Info
begin
Write_Separator;
if List_Representation_Info_To_JSON then
Write_Line ("{");
end if;
List_Common_Type_Info (Ent);
-- First find out max line length and max starting position
-- length, for the purpose of lining things up nicely.
Compute_Max_Length (Ent);
-- Then do actual output based on those values
if List_Representation_Info_To_JSON then
Write_Line (",");
Write_Str (" ""record"": [");
-- ??? We can output structural layout only for base types fully
-- declared in the extended main source unit for the time being,
-- because otherwise declarations might not be processed at all.
if Is_Base_Type (Ent) then
begin
List_Structural_Record_Layout (Ent, Ent);
exception
when Incomplete_Layout
| Not_In_Extended_Main
=>
List_Record_Layout (Ent);
when others =>
raise Program_Error;
end;
else
List_Record_Layout (Ent);
end if;
Write_Eol;
Write_Str (" ]");
else
Write_Str ("for ");
List_Name (Ent);
Write_Line (" use record");
List_Record_Layout (Ent);
Write_Line ("end record;");
end if;
List_Scalar_Storage_Order (Ent, Bytes_Big_Endian);
List_Linker_Section (Ent);
if List_Representation_Info_To_JSON then
Write_Eol;
Write_Line ("}");
end if;
-- The type is relevant for a record subtype
if List_Representation_Info = 4
and then not Is_Base_Type (Ent)
and then Is_Itype (Etype (Ent))
then
Relevant_Entities.Set (Etype (Ent), True);
end if;
end List_Record_Info;
-------------------
-- List_Rep_Info --
-------------------
procedure List_Rep_Info (Bytes_Big_Endian : Boolean) is
Col : Nat;
begin
if List_Representation_Info /= 0
or else List_Representation_Info_Mechanisms
then
-- For the normal case, we output a single JSON stream
if not List_Representation_Info_To_File
and then List_Representation_Info_To_JSON
then
Write_Line ("[");
Need_Separator := False;
end if;
for U in Main_Unit .. Last_Unit loop
if In_Extended_Main_Source_Unit (Cunit_Entity (U)) then
Unit_Casing := Identifier_Casing (Source_Index (U));
if List_Representation_Info = 4 then
Relevant_Entities.Reset;
end if;
-- Normal case, list to standard output
if not List_Representation_Info_To_File then
if not List_Representation_Info_To_JSON then
Write_Eol;
Write_Str ("Representation information for unit ");
Write_Unit_Name (Unit_Name (U));
Col := Column;
Write_Eol;
for J in 1 .. Col - 1 loop
Write_Char ('-');
end loop;
Write_Eol;
Need_Separator := True;
end if;
List_Entities (Cunit_Entity (U), Bytes_Big_Endian);
-- List representation information to file
else
Create_Repinfo_File
(Get_Name_String (File_Name (Source_Index (U))));
Set_Special_Output (Write_Info_Line'Access);
if List_Representation_Info_To_JSON then
Write_Line ("[");
end if;
Need_Separator := False;
List_Entities (Cunit_Entity (U), Bytes_Big_Endian);
if List_Representation_Info_To_JSON then
Write_Line ("]");
end if;
Cancel_Special_Output;
Close_Repinfo_File;
end if;
end if;
end loop;
if not List_Representation_Info_To_File
and then List_Representation_Info_To_JSON
then
Write_Line ("]");
end if;
end if;
end List_Rep_Info;
-------------------------------
-- List_Scalar_Storage_Order --
-------------------------------
procedure List_Scalar_Storage_Order
(Ent : Entity_Id;
Bytes_Big_Endian : Boolean)
is
procedure List_Attr (Attr_Name : String; Is_Reversed : Boolean);
-- Show attribute definition clause for Attr_Name (an endianness
-- attribute), depending on whether or not the endianness is reversed
-- compared to native endianness.
---------------
-- List_Attr --
---------------
procedure List_Attr (Attr_Name : String; Is_Reversed : Boolean) is
begin
if List_Representation_Info_To_JSON then
Write_Line (",");
Write_Str (" """);
Write_Str (Attr_Name);
Write_Str (""": ""System.");
else
Write_Str ("for ");
List_Name (Ent);
Write_Char (''');
Write_Str (Attr_Name);
Write_Str (" use System.");
end if;
if Bytes_Big_Endian xor Is_Reversed then
Write_Str ("High");
else
Write_Str ("Low");
end if;
Write_Str ("_Order_First");
if List_Representation_Info_To_JSON then
Write_Str ("""");
else
Write_Line (";");
end if;
end List_Attr;
List_SSO : constant Boolean :=
Has_Rep_Item (Ent, Name_Scalar_Storage_Order)
or else SSO_Set_Low_By_Default (Ent)
or else SSO_Set_High_By_Default (Ent);
-- Scalar_Storage_Order is displayed if specified explicitly or set by
-- Default_Scalar_Storage_Order.
-- Start of processing for List_Scalar_Storage_Order
begin
-- For record types, list Bit_Order if not default, or if SSO is shown
-- Also, when -gnatR4 is in effect always list bit order and scalar
-- storage order explicitly, so that you don't need to know the native
-- endianness of the target for which the output was produced in order
-- to interpret it.
if Is_Record_Type (Ent)
and then (List_SSO
or else Reverse_Bit_Order (Ent)
or else List_Representation_Info = 4)
then
List_Attr ("Bit_Order", Reverse_Bit_Order (Ent));
end if;
-- List SSO if required. If not, then storage is supposed to be in
-- native order.
if List_SSO or else List_Representation_Info = 4 then
List_Attr ("Scalar_Storage_Order", Reverse_Storage_Order (Ent));
else
pragma Assert (not Reverse_Storage_Order (Ent));
null;
end if;
end List_Scalar_Storage_Order;
--------------------------
-- List_Subprogram_Info --
--------------------------
procedure List_Subprogram_Info (Ent : Entity_Id) is
First : Boolean := True;
Plen : Natural;
Form : Entity_Id;
begin
Write_Separator;
if List_Representation_Info_To_JSON then
Write_Line ("{");
Write_Str (" ""name"": """);
List_Name (Ent);
Write_Line (""",");
List_Location (Ent);
Write_Str (" ""Convention"": """);
else
case Ekind (Ent) is
when E_Function =>
Write_Str ("function ");
when E_Operator =>
Write_Str ("operator ");
when E_Procedure =>
Write_Str ("procedure ");
when E_Subprogram_Type =>
Write_Str ("type ");
when E_Entry
| E_Entry_Family
=>
Write_Str ("entry ");
when others =>
raise Program_Error;
end case;
List_Name (Ent);
Write_Str (" declared at ");
Write_Location (Sloc (Ent));
Write_Eol;
Write_Str ("convention : ");
end if;
case Convention (Ent) is
when Convention_Ada =>
Write_Str ("Ada");
when Convention_Ada_Pass_By_Copy =>
Write_Str ("Ada_Pass_By_Copy");
when Convention_Ada_Pass_By_Reference =>
Write_Str ("Ada_Pass_By_Reference");
when Convention_Intrinsic =>
Write_Str ("Intrinsic");
when Convention_Entry =>
Write_Str ("Entry");
when Convention_Protected =>
Write_Str ("Protected");
when Convention_Assembler =>
Write_Str ("Assembler");
when Convention_C =>
Write_Str ("C");
when Convention_C_Variadic =>
declare
N : Nat :=
Convention_Id'Pos (Convention (Ent)) -
Convention_Id'Pos (Convention_C_Variadic_0);
begin
Write_Str ("C_Variadic_");
if N >= 10 then
Write_Char ('1');
N := N - 10;
end if;
pragma Assert (N < 10);
Write_Char (Character'Val (Character'Pos ('0') + N));
end;
when Convention_COBOL =>
Write_Str ("COBOL");
when Convention_CPP =>
Write_Str ("C++");
when Convention_Fortran =>
Write_Str ("Fortran");
when Convention_Stdcall =>
Write_Str ("Stdcall");
when Convention_Stubbed =>
Write_Str ("Stubbed");
end case;
if List_Representation_Info_To_JSON then
Write_Line (""",");
Write_Str (" ""formal"": [");
else
Write_Eol;
end if;
-- Find max length of formal name
Plen := 0;
Form := First_Formal (Ent);
while Present (Form) loop
Get_Unqualified_Decoded_Name_String (Chars (Form));
if Name_Len > Plen then
Plen := Name_Len;
end if;
Next_Formal (Form);
end loop;
-- Output formals and mechanisms
Form := First_Formal (Ent);
while Present (Form) loop
Get_Unqualified_Decoded_Name_String (Chars (Form));
Set_Casing (Unit_Casing);
if List_Representation_Info_To_JSON then
if First then
Write_Eol;
First := False;
else
Write_Line (",");
end if;
Write_Line (" {");
Write_Str (" ""name"": """);
Write_Str (Name_Buffer (1 .. Name_Len));
Write_Line (""",");
Write_Str (" ""mechanism"": """);
Write_Mechanism (Mechanism (Form));
Write_Line ("""");
Write_Str (" }");
else
while Name_Len <= Plen loop
Name_Len := Name_Len + 1;
Name_Buffer (Name_Len) := ' ';
end loop;
Write_Str (" ");
Write_Str (Name_Buffer (1 .. Plen + 1));
Write_Str (": passed by ");
Write_Mechanism (Mechanism (Form));
Write_Eol;
end if;
Next_Formal (Form);
end loop;
if List_Representation_Info_To_JSON then
Write_Eol;
Write_Str (" ]");
end if;
if Ekind (Ent) = E_Function then
if List_Representation_Info_To_JSON then
Write_Line (",");
Write_Str (" ""mechanism"": """);
Write_Mechanism (Mechanism (Ent));
Write_Str ("""");
else
Write_Str ("returns by ");
Write_Mechanism (Mechanism (Ent));
Write_Eol;
end if;
end if;
if not Is_Entry (Ent) then
List_Linker_Section (Ent);
end if;
if List_Representation_Info_To_JSON then
Write_Eol;
Write_Line ("}");
end if;
end List_Subprogram_Info;
--------------------
-- List_Type_Info --
--------------------
procedure List_Type_Info (Ent : Entity_Id) is
begin
Write_Separator;
if List_Representation_Info_To_JSON then
Write_Line ("{");
end if;
List_Common_Type_Info (Ent);
-- Special stuff for fixed-point
if Is_Fixed_Point_Type (Ent) then
-- Write small (always a static constant)
if List_Representation_Info_To_JSON then
Write_Line (",");
Write_Str (" ""Small"": ");
UR_Write_To_JSON (Small_Value (Ent));
else
Write_Str ("for ");
List_Name (Ent);
Write_Str ("'Small use ");
UR_Write (Small_Value (Ent));
Write_Line (";");
end if;
-- Write range if static
declare
R : constant Node_Id := Scalar_Range (Ent);
begin
if Nkind (Low_Bound (R)) = N_Real_Literal
and then
Nkind (High_Bound (R)) = N_Real_Literal
then
if List_Representation_Info_To_JSON then
Write_Line (",");
Write_Str (" ""Range"": [ ");
UR_Write_To_JSON (Realval (Low_Bound (R)));
Write_Str (", ");
UR_Write_To_JSON (Realval (High_Bound (R)));
Write_Str (" ]");
else
Write_Str ("for ");
List_Name (Ent);
Write_Str ("'Range use ");
UR_Write (Realval (Low_Bound (R)));
Write_Str (" .. ");
UR_Write (Realval (High_Bound (R)));
Write_Line (";");
end if;
end if;
end;
end if;
List_Linker_Section (Ent);
if List_Representation_Info_To_JSON then
Write_Eol;
Write_Line ("}");
end if;
end List_Type_Info;
----------------------
-- Rep_Not_Constant --
----------------------
function Rep_Not_Constant (Val : Node_Ref_Or_Val) return Boolean is
begin
if No (Val) or else Val < 0 then
return True;
else
return False;
end if;
end Rep_Not_Constant;
---------------
-- Rep_Value --
---------------
function Rep_Value (Val : Node_Ref_Or_Val; D : Discrim_List) return Uint is
function B (Val : Boolean) return Ubool;
-- Returns Uint_0 for False, Uint_1 for True
function T (Val : Node_Ref_Or_Val) return Boolean;
-- Returns True for 0, False for any non-zero (i.e. True)
function V (Val : Node_Ref_Or_Val) return Uint;
-- Internal recursive routine to evaluate tree
function W (Val : Uint) return Word;
-- Convert Val to Word, assuming Val is always in the Int range. This
-- is a helper function for the evaluation of bitwise expressions like
-- Bit_And_Expr, for which there is no direct support in uintp. Uint
-- values out of the Int range are expected to be seen in such
-- expressions only with overflowing byte sizes around, introducing
-- inherent unreliabilities in computations anyway.
-------
-- B --
-------
function B (Val : Boolean) return Ubool is
begin
if Val then
return Uint_1;
else
return Uint_0;
end if;
end B;
-------
-- T --
-------
function T (Val : Node_Ref_Or_Val) return Boolean is
begin
if V (Val) = 0 then
return False;
else
return True;
end if;
end T;
-------
-- V --
-------
function V (Val : Node_Ref_Or_Val) return Uint is
L, R, Q : Uint;
begin
if Val >= 0 then
return Val;
else
declare
Node : Exp_Node renames Rep_Table.Table (-UI_To_Int (Val));
begin
case Node.Expr is
when Cond_Expr =>
if T (Node.Op1) then
return V (Node.Op2);
else
return V (Node.Op3);
end if;
when Plus_Expr =>
return V (Node.Op1) + V (Node.Op2);
when Minus_Expr =>
return V (Node.Op1) - V (Node.Op2);
when Mult_Expr =>
return V (Node.Op1) * V (Node.Op2);
when Trunc_Div_Expr =>
return V (Node.Op1) / V (Node.Op2);
when Ceil_Div_Expr =>
return
UR_Ceiling
(V (Node.Op1) / UR_From_Uint (V (Node.Op2)));
when Floor_Div_Expr =>
return
UR_Floor
(V (Node.Op1) / UR_From_Uint (V (Node.Op2)));
when Trunc_Mod_Expr =>
return V (Node.Op1) rem V (Node.Op2);
when Floor_Mod_Expr =>
return V (Node.Op1) mod V (Node.Op2);
when Ceil_Mod_Expr =>
L := V (Node.Op1);
R := V (Node.Op2);
Q := UR_Ceiling (L / UR_From_Uint (R));
return L - R * Q;
when Exact_Div_Expr =>
return V (Node.Op1) / V (Node.Op2);
when Negate_Expr =>
return -V (Node.Op1);
when Min_Expr =>
return UI_Min (V (Node.Op1), V (Node.Op2));
when Max_Expr =>
return UI_Max (V (Node.Op1), V (Node.Op2));
when Abs_Expr =>
return UI_Abs (V (Node.Op1));
when Truth_And_Expr =>
return B (T (Node.Op1) and then T (Node.Op2));
when Truth_Or_Expr =>
return B (T (Node.Op1) or else T (Node.Op2));
when Truth_Xor_Expr =>
return B (T (Node.Op1) xor T (Node.Op2));
when Truth_Not_Expr =>
return B (not T (Node.Op1));
when Bit_And_Expr =>
L := V (Node.Op1);
R := V (Node.Op2);
return UI_From_Int (Int (W (L) and W (R)));
when Lt_Expr =>
return B (V (Node.Op1) < V (Node.Op2));
when Le_Expr =>
return B (V (Node.Op1) <= V (Node.Op2));
when Gt_Expr =>
return B (V (Node.Op1) > V (Node.Op2));
when Ge_Expr =>
return B (V (Node.Op1) >= V (Node.Op2));
when Eq_Expr =>
return B (V (Node.Op1) = V (Node.Op2));
when Ne_Expr =>
return B (V (Node.Op1) /= V (Node.Op2));
when Discrim_Val =>
declare
Sub : constant Int := UI_To_Int (Node.Op1);
begin
pragma Assert (Sub in D'Range);
return D (Sub);
end;
when Dynamic_Val =>
return No_Uint;
end case;
end;
end if;
end V;
-------
-- W --
-------
-- We use an unchecked conversion to map Int values to their Word
-- bitwise equivalent, which we could not achieve with a normal type
-- conversion for negative Ints. We want bitwise equivalents because W
-- is used as a helper for bit operators like Bit_And_Expr, and can be
-- called for negative Ints in the context of aligning expressions like
-- X+Align & -Align.
function W (Val : Uint) return Word is
function To_Word is new Ada.Unchecked_Conversion (Int, Word);
begin
return To_Word (UI_To_Int (Val));
end W;
-- Start of processing for Rep_Value
begin
if No (Val) then
return No_Uint;
else
return V (Val);
end if;
end Rep_Value;
------------
-- Spaces --
------------
procedure Spaces (N : Natural) is
begin
for J in 1 .. N loop
Write_Char (' ');
end loop;
end Spaces;
---------------------
-- Write_Info_Line --
---------------------
procedure Write_Info_Line (S : String) is
begin
Write_Repinfo_Line (S (S'First .. S'Last - 1));
end Write_Info_Line;
---------------------
-- Write_Mechanism --
---------------------
procedure Write_Mechanism (M : Mechanism_Type) is
begin
case M is
when 0 =>
Write_Str ("default");
when -1 =>
Write_Str ("copy");
when -2 =>
Write_Str ("reference");
when others =>
raise Program_Error;
end case;
end Write_Mechanism;
---------------------
-- Write_Separator --
---------------------
procedure Write_Separator is
begin
if Need_Separator then
if List_Representation_Info_To_JSON then
Write_Line (",");
else
Write_Eol;
end if;
else
Need_Separator := True;
end if;
end Write_Separator;
-----------------------
-- Write_Unknown_Val --
-----------------------
procedure Write_Unknown_Val is
begin
if List_Representation_Info_To_JSON then
Write_Str ("""??""");
else
Write_Str ("??");
end if;
end Write_Unknown_Val;
---------------
-- Write_Val --
---------------
procedure Write_Val (Val : Node_Ref_Or_Val; Paren : Boolean := False) is
begin
if Rep_Not_Constant (Val) then
if List_Representation_Info < 3 or else No (Val) then
Write_Unknown_Val;
else
if Paren then
Write_Char ('(');
end if;
List_GCC_Expression (Val);
if Paren then
Write_Char (')');
end if;
end if;
else
UI_Write (Val, Decimal);
end if;
end Write_Val;
end Repinfo;
|
godunko/adawebui | Ada | 4,276 | ads | ------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- Web Framework --
-- --
-- Runtime Library Component --
-- --
------------------------------------------------------------------------------
-- --
-- Copyright © 2017-2020, Vadim Godunko <[email protected]> --
-- All rights reserved. --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions --
-- are met: --
-- --
-- * Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- --
-- * Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in the --
-- documentation and/or other materials provided with the distribution. --
-- --
-- * Neither the name of the Vadim Godunko, IE nor the names of its --
-- contributors may be used to endorse or promote products derived from --
-- this software without specific prior written permission. --
-- --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR --
-- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
-- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED --
-- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR --
-- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF --
-- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING --
-- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS --
-- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
-- --
------------------------------------------------------------------------------
-- $Revision: 5720 $ $Date: 2017-01-24 19:41:12 +0300 (Tue, 24 Jan 2017) $
------------------------------------------------------------------------------
with Web.Strings;
package Web.UI.Widgets.Labels is
type Label is new Web.UI.Widgets.Abstract_Widget with private;
type Label_Access is access all Label'Class
with Storage_Size => 0;
procedure Set_Text
(Self : in out Label'Class;
To : Web.Strings.Web_String);
package Constructors is
function Create
(Element : Web.HTML.Elements.HTML_Element'Class)
return not null Label_Access;
function Create
(Id : Web.Strings.Web_String) return not null Label_Access;
procedure Initialize
(Self : in out Label'Class;
Element : Web.HTML.Elements.HTML_Element'Class);
end Constructors;
private
type Label is new Web.UI.Widgets.Abstract_Widget with null record;
overriding procedure Set_Disabled
(Self : in out Label;
Disabled : Boolean := True);
end Web.UI.Widgets.Labels;
|
stcarrez/ada-awa | Ada | 2,120 | ads | -----------------------------------------------------------------------
-- awa-changelogs-modules -- Module changelogs
-- Copyright (C) 2014 Stephane Carrez
-- Written by Stephane Carrez ([email protected])
--
-- Licensed under the Apache License, Version 2.0 (the "License");
-- you may not use this file except in compliance with the License.
-- You may obtain a copy of the License at
--
-- http://www.apache.org/licenses/LICENSE-2.0
--
-- Unless required by applicable law or agreed to in writing, software
-- distributed under the License is distributed on an "AS IS" BASIS,
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-- See the License for the specific language governing permissions and
-- limitations under the License.
-----------------------------------------------------------------------
with ASF.Applications;
with ADO;
with AWA.Modules;
package AWA.Changelogs.Modules is
-- The name under which the module is registered.
NAME : constant String := "changelogs";
-- ------------------------------
-- Module changelogs
-- ------------------------------
type Changelog_Module is new AWA.Modules.Module with private;
type Changelog_Module_Access is access all Changelog_Module'Class;
-- Initialize the changelogs module.
overriding
procedure Initialize (Plugin : in out Changelog_Module;
App : in AWA.Modules.Application_Access;
Props : in ASF.Applications.Config);
-- Get the changelogs module.
function Get_Changelog_Module return Changelog_Module_Access;
-- Add the log message and associate it with the database entity identified by
-- the given id and the entity type. The log message is associated with the current user.
procedure Add_Log (Model : in Changelog_Module;
Id : in ADO.Identifier;
Entity_Type : in String;
Message : in String);
private
type Changelog_Module is new AWA.Modules.Module with null record;
end AWA.Changelogs.Modules;
|
reznikmm/matreshka | Ada | 4,312 | ads | ------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- Web Framework --
-- --
-- Runtime Library Component --
-- --
------------------------------------------------------------------------------
-- --
-- Copyright © 2016-2017, 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$
------------------------------------------------------------------------------
generic
-- type Abstract_Object is limited interface;
-- type Abstract_Object is abstract tagged limited private;
type Abstract_Object is
abstract new Core.Connectables.Connectable_Object with private;
with procedure Subprogram (Self : in out Abstract_Object) is abstract;
package Core.Connectables.Slots_0.Generic_Slots is
pragma Preelaborate;
function To_Slot
(Self : in out Abstract_Object'Class) return Slots_0.Slot'Class;
private
type Slot (Object : not null access Abstract_Object'Class) is
new Slots_0.Slot with null record;
overriding function Create_Slot_End
(Self : Slot) return not null Slot_End_Access;
type Slot_End (Object : not null access Abstract_Object'Class) is
new Slot_End_0 with null record;
overriding procedure Invoke (Self : in out Slot_End);
overriding function Owner
(Self : Slot_End) return not null Connectables.Object_Access;
end Core.Connectables.Slots_0.Generic_Slots;
|
AdaCore/gpr | Ada | 182 | ads | package p8_2 is
function p8_2_0 (Item : Integer) return Integer;
function p8_2_1 (Item : Integer) return Integer;
function p8_2_2 (Item : Integer) return Integer;
end p8_2;
|
reznikmm/slimp | Ada | 915 | ads | -- Copyright (c) 2019 Maxim Reznik <[email protected]>
--
-- SPDX-License-Identifier: MIT
-- License-Filename: LICENSE
-------------------------------------------------------------
package Slim.Messages.IR is
type IR_Message is new Message with private;
private
subtype Byte is Ada.Streams.Stream_Element;
type IR_Message is new Base_Message
(Max_8 => 2,
Max_16 => 0,
Max_32 => 2,
Max_64 => 0)
with null record;
overriding function Read
(Data : not null access
League.Stream_Element_Vectors.Stream_Element_Vector)
return IR_Message;
overriding procedure Write
(Self : IR_Message;
Tag : out Message_Tag;
Data : out League.Stream_Element_Vectors.Stream_Element_Vector);
overriding procedure Visit
(Self : not null access IR_Message;
Visiter : in out Slim.Message_Visiters.Visiter'Class);
end Slim.Messages.IR;
|
reznikmm/matreshka | Ada | 3,919 | adb | ------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- Open Document Toolkit --
-- --
-- Tools 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 League.Application;
with XML.SAX.Input_Sources.Streams.Files;
with XML.SAX.Simple_Readers;
with ODFGen.Generator;
with ODFGen.Parsers;
procedure ODFGen.Driver is
Reader : aliased XML.SAX.Simple_Readers.SAX_Simple_Reader;
Parser : aliased ODFGen.Parsers.Parser;
Source : aliased XML.SAX.Input_Sources.Streams.Files.File_Input_Source;
begin
Source.Open_By_File_Name (League.Application.Arguments.Element (1));
Reader.Set_Content_Handler (Parser'Unchecked_Access);
Reader.Parse (Source'Unchecked_Access);
ODFGen.Generator.Generate;
end ODFGen.Driver;
|
reznikmm/matreshka | Ada | 4,083 | ads | ------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- Open Document Toolkit --
-- --
-- Runtime Library Component --
-- --
------------------------------------------------------------------------------
-- --
-- Copyright © 2014, Vadim Godunko <[email protected]> --
-- All rights reserved. --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions --
-- are met: --
-- --
-- * Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- --
-- * Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in the --
-- documentation and/or other materials provided with the distribution. --
-- --
-- * Neither the name of the Vadim Godunko, IE nor the names of its --
-- contributors may be used to endorse or promote products derived from --
-- this software without specific prior written permission. --
-- --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR --
-- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
-- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED --
-- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR --
-- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF --
-- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING --
-- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS --
-- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
-- --
------------------------------------------------------------------------------
-- $Revision$ $Date$
------------------------------------------------------------------------------
with ODF.DOM.Style_Font_Family_Complex_Attributes;
package Matreshka.ODF_Style.Font_Family_Complex_Attributes is
type Style_Font_Family_Complex_Attribute_Node is
new Matreshka.ODF_Style.Abstract_Style_Attribute_Node
and ODF.DOM.Style_Font_Family_Complex_Attributes.ODF_Style_Font_Family_Complex_Attribute
with null record;
overriding function Create
(Parameters : not null access Matreshka.DOM_Attributes.Attribute_L2_Parameters)
return Style_Font_Family_Complex_Attribute_Node;
overriding function Get_Local_Name
(Self : not null access constant Style_Font_Family_Complex_Attribute_Node)
return League.Strings.Universal_String;
end Matreshka.ODF_Style.Font_Family_Complex_Attributes;
|
charlie5/lace | Ada | 357 | ads | with
eGL.Pointers;
package eGL.NativeDisplayType
is
subtype Item is eGL.Pointers.Display_Pointer;
type Item_array is array (C.size_t range <>) of aliased Item;
type Pointer is access all eGL.NativeDisplayType.Item;
type Pointer_array is array (C.size_t range <>) of aliased Pointer;
end eGL.NativeDisplayType;
|
reznikmm/matreshka | Ada | 4,028 | ads | ------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- Ada Modeling Framework --
-- --
-- Runtime Library Component --
-- --
------------------------------------------------------------------------------
-- --
-- Copyright © 2011-2012, Vadim Godunko <[email protected]> --
-- All rights reserved. --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions --
-- are met: --
-- --
-- * Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- --
-- * Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in the --
-- documentation and/or other materials provided with the distribution. --
-- --
-- * Neither the name of the Vadim Godunko, IE nor the names of its --
-- contributors may be used to endorse or promote products derived from --
-- this software without specific prior written permission. --
-- --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR --
-- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
-- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED --
-- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR --
-- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF --
-- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING --
-- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS --
-- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
-- --
------------------------------------------------------------------------------
-- $Revision$ $Date$
------------------------------------------------------------------------------
-- This file is generated, don't edit it.
------------------------------------------------------------------------------
-- A literal specification identifies a literal constant being modeled.
------------------------------------------------------------------------------
with AMF.UML.Value_Specifications;
package AMF.UML.Literal_Specifications is
pragma Preelaborate;
type UML_Literal_Specification is limited interface
and AMF.UML.Value_Specifications.UML_Value_Specification;
type UML_Literal_Specification_Access is
access all UML_Literal_Specification'Class;
for UML_Literal_Specification_Access'Storage_Size use 0;
end AMF.UML.Literal_Specifications;
|
HackInvent/Ada_Drivers_Library | Ada | 4,422 | ads | ------------------------------------------------------------------------------
-- --
-- GNAT RUN-TIME COMPONENTS --
-- --
-- A D A . T E X T _ I O . F L O A T _ I O --
-- --
-- S p e c --
-- --
-- $Revision: 24601 $ --
-- --
-- Copyright (C) 1992-1997 Free Software Foundation, Inc. --
-- --
-- This specification is derived from the Ada Reference Manual for use with --
-- GNAT. The copyright notice above, and the license provisions that follow --
-- apply solely to the contents of the part following the private keyword. --
-- --
-- GNAT is free software; you can redistribute it and/or modify it under --
-- terms of the GNU General Public License as published by the Free Soft- --
-- ware Foundation; either version 2, or (at your option) any later ver- --
-- sion. GNAT is distributed in the hope that it will be useful, but WITH- --
-- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY --
-- or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License --
-- for more details. You should have received a copy of the GNU General --
-- Public License distributed with GNAT; see file COPYING. If not, write --
-- to the Free Software Foundation, 59 Temple Place - Suite 330, Boston, --
-- MA 02111-1307, USA. --
-- --
-- As a special exception, if other files instantiate generics from this --
-- unit, or you link this unit with other files to produce an executable, --
-- this unit does not by itself cause the resulting executable to be --
-- covered by the GNU General Public License. This exception does not --
-- however invalidate any other reasons why the executable file might be --
-- covered by the GNU Public License. --
-- --
-- GNAT was originally developed by the GNAT team at New York University. --
-- It is now maintained by Ada Core Technologies Inc (http://www.gnat.com). --
-- --
------------------------------------------------------------------------------
-- In Ada 95, the package Ada.Text_IO.Float_IO is a subpackage of Text_IO.
-- This is for compatibility with Ada 83. In GNAT we make it a child package
-- to avoid loading the necessary code if Float_IO is not instantiated. See
-- routine Rtsfind.Text_IO_Kludge for a description of how we patch up the
-- difference in semantics so that it is invisible to the Ada programmer.
private generic
type Num is digits <>;
package Ada.Text_IO.Float_IO is
Default_Fore : Field := 2;
Default_Aft : Field := Num'Digits - 1;
Default_Exp : Field := 3;
procedure Get
(File : in File_Type;
Item : out Num;
Width : in Field := 0);
procedure Get
(Item : out Num;
Width : in Field := 0);
procedure Put
(File : in File_Type;
Item : in Num;
Fore : in Field := Default_Fore;
Aft : in Field := Default_Aft;
Exp : in Field := Default_Exp);
procedure Put
(Item : in Num;
Fore : in Field := Default_Fore;
Aft : in Field := Default_Aft;
Exp : in Field := Default_Exp);
procedure Get
(From : in String;
Item : out Num;
Last : out Positive);
procedure Put
(To : out String;
Item : in Num;
Aft : in Field := Default_Aft;
Exp : in Field := Default_Exp);
private
pragma Inline (Get);
pragma Inline (Put);
end Ada.Text_IO.Float_IO;
|
reznikmm/matreshka | Ada | 6,001 | ads | ------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- Ada Modeling Framework --
-- --
-- Runtime Library Component --
-- --
------------------------------------------------------------------------------
-- --
-- Copyright © 2011-2012, Vadim Godunko <[email protected]> --
-- All rights reserved. --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions --
-- are met: --
-- --
-- * Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- --
-- * Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in the --
-- documentation and/or other materials provided with the distribution. --
-- --
-- * Neither the name of the Vadim Godunko, IE nor the names of its --
-- contributors may be used to endorse or promote products derived from --
-- this software without specific prior written permission. --
-- --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR --
-- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
-- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED --
-- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR --
-- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF --
-- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING --
-- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS --
-- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
-- --
------------------------------------------------------------------------------
-- $Revision$ $Date$
------------------------------------------------------------------------------
-- This file is generated, don't edit it.
------------------------------------------------------------------------------
-- A vertex is an abstraction of a node in a state machine graph. In general,
-- it can be the source or destination of any number of transitions.
------------------------------------------------------------------------------
with AMF.UML.Named_Elements;
limited with AMF.UML.Regions;
limited with AMF.UML.State_Machines;
limited with AMF.UML.Transitions.Collections;
package AMF.UML.Vertexs is
pragma Preelaborate;
type UML_Vertex is limited interface
and AMF.UML.Named_Elements.UML_Named_Element;
type UML_Vertex_Access is
access all UML_Vertex'Class;
for UML_Vertex_Access'Storage_Size use 0;
not overriding function Get_Container
(Self : not null access constant UML_Vertex)
return AMF.UML.Regions.UML_Region_Access is abstract;
-- Getter of Vertex::container.
--
-- The region that contains this vertex.
not overriding procedure Set_Container
(Self : not null access UML_Vertex;
To : AMF.UML.Regions.UML_Region_Access) is abstract;
-- Setter of Vertex::container.
--
-- The region that contains this vertex.
not overriding function Get_Incoming
(Self : not null access constant UML_Vertex)
return AMF.UML.Transitions.Collections.Set_Of_UML_Transition is abstract;
-- Getter of Vertex::incoming.
--
-- Specifies the transitions entering this vertex.
not overriding function Get_Outgoing
(Self : not null access constant UML_Vertex)
return AMF.UML.Transitions.Collections.Set_Of_UML_Transition is abstract;
-- Getter of Vertex::outgoing.
--
-- Specifies the transitions departing from this vertex.
not overriding function Containing_State_Machine
(Self : not null access constant UML_Vertex)
return AMF.UML.State_Machines.UML_State_Machine_Access is abstract;
-- Operation Vertex::containingStateMachine.
--
-- The operation containingStateMachine() returns the state machine in
-- which this Vertex is defined
not overriding function Incoming
(Self : not null access constant UML_Vertex)
return AMF.UML.Transitions.Collections.Set_Of_UML_Transition is abstract;
-- Operation Vertex::incoming.
--
-- Missing derivation for Vertex::/incoming : Transition
not overriding function Outgoing
(Self : not null access constant UML_Vertex)
return AMF.UML.Transitions.Collections.Set_Of_UML_Transition is abstract;
-- Operation Vertex::outgoing.
--
-- Missing derivation for Vertex::/outgoing : Transition
end AMF.UML.Vertexs;
|
Hamster-Furtif/JeremyPlusPlus | Ada | 5,369 | ads | with Ada.Strings.Unbounded;
use Ada.Strings.Unbounded;
package utils is
type T_colour is (empty, spades, hearts, diamonds, clovers);
type T_move is (check, fold, call, bet, none);
type T_set is private;
type T_combination_type is (none, paire, paire_2, paire_3, brelan, suite, couleur, full, carre, quinte_f, quinte_f_r);
type T_combination is record
comb_type : T_combination_type;
lenght : Integer;
cards: T_set;
end record;
type T_card is private;
type T_game is private;
type T_settings is private;
--Permet de comparer des combinaisons par superiorite selon les regles du poker
function ">"(L : T_combination ; R : T_combination) return boolean;
--Permet de sommer deux T_Set
function "+"(L : T_set; R : T_set) return T_set;
function "+"(L : T_card; R: T_card) return T_set;
function "+"(L : T_set; R: T_card) return T_set;
function "+"(L : T_card; R: T_set) return T_set;
--Permet d'ajouter une carte a un enssemble
procedure addToSet(card : in T_card ; set : in out T_set);
--Permet de vider ou d'initialiser un enssemble
procedure emptySet(set : in out T_set);
--Trie un enssemble par valeurs de cartes decroissantes
procedure sortSet(set : in out T_set);
--Trouve la meilleur combinaison possible avec les cartes de deux enssembles
function getBestCombination(set : in T_set) return T_combination;
--Initialise un t_game
procedure initGame(game : in out T_game);
--E/ card : T_card
--E/ set : T_set
--Necessite : None
--S/ : Boolean
--Entraine :Verifie qu'un ensemble contient une carte en particulier
function cardInSet(card : in T_card; set : in T_set) return Boolean;
--Accesseurs generes en python
function get_settings (game : in T_game) return T_settings;
procedure set_settings(game : in out T_game; val : in T_settings);
function get_round(game : in T_game) return Integer;
procedure set_round(game : in out T_game; val : in Integer);
function get_pot(game : in T_game) return Integer;
procedure set_pot(game : in out T_game; val : in Integer);
function get_table(game : in T_game) return T_set;
procedure set_table(game : in out T_game; val : in T_set);
function get_hand(game : in T_game) return T_set;
procedure set_hand(game : in out T_game; val : in T_set);
function get_op_hand(game : in T_game) return T_set;
procedure set_op_hand(game : in out T_game; val : in T_set);
function get_my_money(game : in T_game) return Integer;
procedure set_my_money(game : in out T_game; val : in Integer);
function get_op_money(game : in T_game) return Integer;
procedure set_op_money(game : in out T_game; val : in Integer);
function get_button_is_mine(game : in T_game) return Boolean;
procedure set_button_is_mine(game : in out T_game; val : in Boolean);
function get_small_blind(game : in T_game) return Integer;
procedure set_small_blind(game : in out T_game; val : in Integer);
function get_big_blind(game : in T_game) return Integer;
procedure set_big_blind(game : in out T_game; val : in Integer);
function get_amount_to_call(game : in T_game) return Integer;
procedure set_amount_to_call(game : in out T_game; val : in Integer);
function get_min_bet(game : in T_game) return Integer;
procedure set_min_bet(game : in out T_game; val : in Integer);
function get_size (set : in T_set) return Natural;
function get_card(set : in T_set; i : in Natural) return T_card;
procedure set_card(set : in out T_set; i : in Natural; card : in T_card);
function get_rank(card : in T_card) return Integer;
procedure set_rank(card : in out T_card; val : in Integer);
function get_colour(card : in T_card) return T_colour;
procedure set_colour(card : in out T_card; val : in T_colour);
function get_timebank_max (settings : in T_settings) return Integer;
procedure set_timebank_max (settings : in out T_settings; val : in Integer);
function get_timebank_sup (settings : in T_settings) return Integer;
procedure set_timebank_sup (settings : in out T_settings; val : in Integer);
function get_hands_per_lvl(settings : in T_settings) return Integer;
procedure set_hands_per_lvl(settings : in out T_settings; val : in Integer);
private
type T_card is
record
rank : Integer; --0 => 2, 13 => Ace
colour : T_colour;
end record;
type T_card_list is Array(0..52) of T_card;
type T_set is
record
set : T_card_list;
size : Integer := 0;
end record;
type T_settings is
record
timebank_max : Integer;
timebank_sup : Integer; --temps gagné par coup
hands_per_lvl : Integer;
end record;
type T_game is
record
settings : T_settings;
round : Integer;
pot : Integer;
table : T_set;
hand : T_set;
op_hand : T_set;
my_money : Integer; --Mon argent
op_money : Integer; --L'argent de mon opposant
button_is_mine : Boolean;
small_blind : Integer;
big_blind : Integer;
amount_to_call : Integer;
min_bet : Integer;
end record;
end utils;
|
reznikmm/slimp | Ada | 1,447 | adb | -- Copyright (c) 2019 Maxim Reznik <[email protected]>
--
-- SPDX-License-Identifier: MIT
-- License-Filename: LICENSE
-------------------------------------------------------------
with Slim.Message_Visiters;
package body Slim.Messages.aude is
List : constant Field_Description_Array :=
((Uint_8_Field, 1), -- Register
(Uint_8_Field, 1)); -- Mode or Hours BCD
-------------------
-- Enable_Output --
-------------------
procedure Enable_Output (Self : in out Aude_Message) is
begin
Self.Data_8 := (1, 1);
end Enable_Output;
----------
-- Read --
----------
overriding function Read
(Data : not null access
League.Stream_Element_Vectors.Stream_Element_Vector)
return Aude_Message is
begin
return Result : Aude_Message do
Read_Fields (Result, List, Data.all);
end return;
end Read;
-----------
-- Visit --
-----------
overriding procedure Visit
(Self : not null access Aude_Message;
Visiter : in out Slim.Message_Visiters.Visiter'Class) is
begin
Visiter.aude (Self);
end Visit;
-----------
-- Write --
-----------
overriding procedure Write
(Self : Aude_Message;
Tag : out Message_Tag;
Data : out League.Stream_Element_Vectors.Stream_Element_Vector) is
begin
Tag := "aude";
Write_Fields (Self, List, Data);
end Write;
end Slim.Messages.aude;
|
reznikmm/matreshka | Ada | 4,011 | ads | ------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- Open Document Toolkit --
-- --
-- Runtime Library Component --
-- --
------------------------------------------------------------------------------
-- --
-- Copyright © 2014, Vadim Godunko <[email protected]> --
-- All rights reserved. --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions --
-- are met: --
-- --
-- * Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- --
-- * Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in the --
-- documentation and/or other materials provided with the distribution. --
-- --
-- * Neither the name of the Vadim Godunko, IE nor the names of its --
-- contributors may be used to endorse or promote products derived from --
-- this software without specific prior written permission. --
-- --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR --
-- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
-- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED --
-- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR --
-- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF --
-- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING --
-- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS --
-- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
-- --
------------------------------------------------------------------------------
-- $Revision$ $Date$
------------------------------------------------------------------------------
with ODF.DOM.Table_Show_Empty_Attributes;
package Matreshka.ODF_Table.Show_Empty_Attributes is
type Table_Show_Empty_Attribute_Node is
new Matreshka.ODF_Table.Abstract_Table_Attribute_Node
and ODF.DOM.Table_Show_Empty_Attributes.ODF_Table_Show_Empty_Attribute
with null record;
overriding function Create
(Parameters : not null access Matreshka.DOM_Attributes.Attribute_L2_Parameters)
return Table_Show_Empty_Attribute_Node;
overriding function Get_Local_Name
(Self : not null access constant Table_Show_Empty_Attribute_Node)
return League.Strings.Universal_String;
end Matreshka.ODF_Table.Show_Empty_Attributes;
|
reznikmm/matreshka | Ada | 6,992 | adb | ------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- Ada Modeling Framework --
-- --
-- Runtime Library Component --
-- --
------------------------------------------------------------------------------
-- --
-- Copyright © 2011-2012, Vadim Godunko <[email protected]> --
-- All rights reserved. --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions --
-- are met: --
-- --
-- * Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- --
-- * Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in the --
-- documentation and/or other materials provided with the distribution. --
-- --
-- * Neither the name of the Vadim Godunko, IE nor the names of its --
-- contributors may be used to endorse or promote products derived from --
-- this software without specific prior written permission. --
-- --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR --
-- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
-- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED --
-- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR --
-- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF --
-- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING --
-- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS --
-- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
-- --
------------------------------------------------------------------------------
-- $Revision$ $Date$
------------------------------------------------------------------------------
-- This file is generated, don't edit it.
------------------------------------------------------------------------------
with AMF.Elements;
with AMF.Internals.Helpers;
with AMF.Internals.Tables.UML_Attributes;
with AMF.UML.Components;
with AMF.Visitors.Standard_Profile_L3_Iterators;
with AMF.Visitors.Standard_Profile_L3_Visitors;
package body AMF.Internals.Standard_Profile_L3_Build_Components is
------------------------
-- Get_Base_Component --
------------------------
overriding function Get_Base_Component
(Self : not null access constant Standard_Profile_L3_Build_Component_Proxy)
return AMF.UML.Components.UML_Component_Access is
begin
return
AMF.UML.Components.UML_Component_Access
(AMF.Internals.Helpers.To_Element
(AMF.Internals.Tables.UML_Attributes.Internal_Get_Base_Component
(Self.Element)));
end Get_Base_Component;
------------------------
-- Set_Base_Component --
------------------------
overriding procedure Set_Base_Component
(Self : not null access Standard_Profile_L3_Build_Component_Proxy;
To : AMF.UML.Components.UML_Component_Access) is
begin
AMF.Internals.Tables.UML_Attributes.Internal_Set_Base_Component
(Self.Element,
AMF.Internals.Helpers.To_Element
(AMF.Elements.Element_Access (To)));
end Set_Base_Component;
-------------------
-- Enter_Element --
-------------------
overriding procedure Enter_Element
(Self : not null access constant Standard_Profile_L3_Build_Component_Proxy;
Visitor : in out AMF.Visitors.Abstract_Visitor'Class;
Control : in out AMF.Visitors.Traverse_Control) is
begin
if Visitor in AMF.Visitors.Standard_Profile_L3_Visitors.Standard_Profile_L3_Visitor'Class then
AMF.Visitors.Standard_Profile_L3_Visitors.Standard_Profile_L3_Visitor'Class
(Visitor).Enter_Build_Component
(AMF.Standard_Profile_L3.Build_Components.Standard_Profile_L3_Build_Component_Access (Self),
Control);
end if;
end Enter_Element;
-------------------
-- Leave_Element --
-------------------
overriding procedure Leave_Element
(Self : not null access constant Standard_Profile_L3_Build_Component_Proxy;
Visitor : in out AMF.Visitors.Abstract_Visitor'Class;
Control : in out AMF.Visitors.Traverse_Control) is
begin
if Visitor in AMF.Visitors.Standard_Profile_L3_Visitors.Standard_Profile_L3_Visitor'Class then
AMF.Visitors.Standard_Profile_L3_Visitors.Standard_Profile_L3_Visitor'Class
(Visitor).Leave_Build_Component
(AMF.Standard_Profile_L3.Build_Components.Standard_Profile_L3_Build_Component_Access (Self),
Control);
end if;
end Leave_Element;
-------------------
-- Visit_Element --
-------------------
overriding procedure Visit_Element
(Self : not null access constant Standard_Profile_L3_Build_Component_Proxy;
Iterator : in out AMF.Visitors.Abstract_Iterator'Class;
Visitor : in out AMF.Visitors.Abstract_Visitor'Class;
Control : in out AMF.Visitors.Traverse_Control) is
begin
if Iterator in AMF.Visitors.Standard_Profile_L3_Iterators.Standard_Profile_L3_Iterator'Class then
AMF.Visitors.Standard_Profile_L3_Iterators.Standard_Profile_L3_Iterator'Class
(Iterator).Visit_Build_Component
(Visitor,
AMF.Standard_Profile_L3.Build_Components.Standard_Profile_L3_Build_Component_Access (Self),
Control);
end if;
end Visit_Element;
end AMF.Internals.Standard_Profile_L3_Build_Components;
|
reznikmm/matreshka | Ada | 24,417 | adb | ------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- Localization, Internationalization, Globalization for Ada --
-- --
-- Tools Component --
-- --
------------------------------------------------------------------------------
-- --
-- Copyright © 2009-2015, Vadim Godunko <[email protected]> --
-- All rights reserved. --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions --
-- are met: --
-- --
-- * Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- --
-- * Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in the --
-- documentation and/or other materials provided with the distribution. --
-- --
-- * Neither the name of the Vadim Godunko, IE nor the names of its --
-- contributors may be used to endorse or promote products derived from --
-- this software without specific prior written permission. --
-- --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR --
-- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
-- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED --
-- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR --
-- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF --
-- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING --
-- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS --
-- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
-- --
------------------------------------------------------------------------------
-- $Revision$ $Date$
------------------------------------------------------------------------------
with Ada.Text_IO;
with Matreshka.Internals.Unicode.Ucd;
with Put_File_Header;
with Ucd_Data;
with Utils;
procedure Gen_Norms is
use Matreshka.Internals.Unicode;
use Matreshka.Internals.Unicode.Ucd;
use Ucd_Data;
use Utils;
procedure Append_Mapping
(Mapping : Code_Point_Sequence;
First : out Sequence_Index;
Last : out Sequence_Count);
type Group_Info is record
Share : First_Stage_Index;
Count : Natural;
end record;
type Composition_Mapping_Access is access all Composition_Mapping;
Decomposition_Data : Code_Point_Sequence (Sequence_Index);
Decomposition_Data_Last : Sequence_Count := 0;
Composition_Data : Composition_Mapping_Access;
First_Index_Last : Sequence_Count := 0;
Last_Index_Last : Sequence_Count := 0;
Normalization : array (Code_Point) of Normalization_Mapping
:= (others =>
((others => (0, 0)),
(0, 0),
0,
(others => Yes),
None,
(others => False)));
Groups : array (First_Stage_Index) of Group_Info
:= (others => (0, 0));
Generated : array (First_Stage_Index) of Boolean := (others => False);
type Constant_String_Access is access constant String;
DT_Canonical_Image : aliased constant String := "Canonical";
DT_Compat_Image : aliased constant String := "Compat";
DT_Circle_Image : aliased constant String := "Circle";
DT_Final_Image : aliased constant String := "Final";
DT_Font_Image : aliased constant String := "Font";
DT_Fraction_Image : aliased constant String := "Fraction";
DT_Initial_Image : aliased constant String := "Initial";
DT_Isolated_Image : aliased constant String := "Isolated";
DT_Medial_Image : aliased constant String := "Medial";
DT_Narrow_Image : aliased constant String := "Narrow";
DT_No_Break_Image : aliased constant String := "No_Break";
DT_None_Image : aliased constant String := "None";
DT_Small_Image : aliased constant String := "Small";
DT_Square_Image : aliased constant String := "Square";
DT_Sub_Image : aliased constant String := "Sub";
DT_Super_Image : aliased constant String := "Super";
DT_Vertical_Image : aliased constant String := "Vertical";
DT_Wide_Image : aliased constant String := "Wide";
Decomposition_Type_Image : constant
array (Decomposition_Type) of Constant_String_Access
:= (Canonical => DT_Canonical_Image'Access,
Compat => DT_Compat_Image'Access,
Circle => DT_Circle_Image'Access,
Final => DT_Final_Image'Access,
Font => DT_Font_Image'Access,
Fraction => DT_Fraction_Image'Access,
Initial => DT_Initial_Image'Access,
Isolated => DT_Isolated_Image'Access,
Medial => DT_Medial_Image'Access,
Narrow => DT_Narrow_Image'Access,
No_Break => DT_No_Break_Image'Access,
None => DT_None_Image'Access,
Small => DT_Small_Image'Access,
Square => DT_Square_Image'Access,
Sub => DT_Sub_Image'Access,
Super => DT_Super_Image'Access,
Vertical => DT_Vertical_Image'Access,
Wide => DT_Wide_Image'Access);
NQC_No_Image : aliased constant String := "No";
NQC_Maybe_Image : aliased constant String := "Maybe";
NQC_Yes_Image : aliased constant String := "Yes";
Normalization_Quick_Check_Image : constant
array (Normalization_Quick_Check) of Constant_String_Access
:= (No => NQC_No_Image'Access,
Maybe => NQC_Maybe_Image'Access,
Yes => NQC_Yes_Image'Access);
BP_Composition_Exclusion_Image :
aliased constant String := "Composition_Exclusion";
BP_Full_Composition_Exclusion_Image :
aliased constant String := "Full_Composition_Exclusion";
BP_Expands_On_NFC_Image : aliased constant String := "Expands_On_NFC";
BP_Expands_On_NFD_Image : aliased constant String := "Expands_On_NFD";
BP_Expands_On_NFKC_Image : aliased constant String := "Expands_On_NFKC";
BP_Expands_On_NFKD_Image : aliased constant String := "Expands_On_NFKD";
Boolean_Properties_Image : constant
array (Not_Overridable_Boolean_Properties) of Constant_String_Access
:= (Composition_Exclusion => BP_Composition_Exclusion_Image'Access,
Expands_On_NFC => BP_Expands_On_NFC_Image'Access,
Expands_On_NFD => BP_Expands_On_NFD_Image'Access,
Expands_On_NFKC => BP_Expands_On_NFKC_Image'Access,
Expands_On_NFKD => BP_Expands_On_NFKD_Image'Access,
Full_Composition_Exclusion =>
BP_Full_Composition_Exclusion_Image'Access);
--------------------
-- Append_Mapping --
--------------------
procedure Append_Mapping
(Mapping : Code_Point_Sequence;
First : out Sequence_Index;
Last : out Sequence_Count)
is
begin
if Mapping'Length = 0 then
First := 1;
Last := 0;
end if;
for J in 1 .. Decomposition_Data_Last - Mapping'Length + 1 loop
if Decomposition_Data (J .. J + Mapping'Length - 1) = Mapping then
First := J;
Last := J + Mapping'Length - 1;
return;
end if;
end loop;
First := Decomposition_Data_Last + 1;
for J in Mapping'Range loop
Decomposition_Data_Last := Decomposition_Data_Last + 1;
Decomposition_Data (Decomposition_Data_Last) := Mapping (J);
end loop;
Last := Decomposition_Data_Last;
end Append_Mapping;
---------
-- Put --
---------
procedure Put (Item : Normalization_Mapping) is
use type Ada.Text_IO.Count;
Indent : Ada.Text_IO.Count := Ada.Text_IO.Col + 1;
Counts : array (Boolean) of Natural := (0, 0);
Default : Boolean;
N : Natural := 0;
begin
Ada.Text_IO.Put
("((("
& Sequence_Count_Image (Item.Decomposition (Canonical).First)
& ", "
& Sequence_Count_Image (Item.Decomposition (Canonical).Last)
& "), ("
& Sequence_Count_Image (Item.Decomposition (Compatibility).First)
& ", "
& Sequence_Count_Image (Item.Decomposition (Compatibility).Last)
& ")), ("
& Sequence_Count_Image (Item.Composition.First)
& ", "
& Sequence_Count_Image (Item.Composition.Last)
& "),"
& Canonical_Combining_Class'Image (Item.CCC)
& ", ("
& Normalization_Quick_Check_Image (Item.NQC (NFC)).all
& ", "
& Normalization_Quick_Check_Image (Item.NQC (NFD)).all
& ", "
& Normalization_Quick_Check_Image (Item.NQC (NFKC)).all
& ", "
& Normalization_Quick_Check_Image (Item.NQC (NFKD)).all
& "), "
& Decomposition_Type_Image (Item.DT).all
& ",");
Ada.Text_IO.Set_Col (Indent);
Ada.Text_IO.Put ('(');
for J in Item.B'Range loop
Counts (Item.B (J)) := Counts (Item.B (J)) + 1;
end loop;
Default := Counts (False) < Counts (True);
for J in Item.B'Range loop
if Item.B (J) /= Default then
N := N + 1;
if N = 1 then
Ada.Text_IO.Put (Boolean_Properties_Image (J).all);
else
Ada.Text_IO.Set_Col (Indent + 3);
Ada.Text_IO.Put ("| " & Boolean_Properties_Image (J).all);
end if;
end if;
end loop;
if N /= 0 then
if Ada.Text_IO.Col > 68 then
Ada.Text_IO.Set_Col (Indent + 6);
end if;
if not Default then
Ada.Text_IO.Put (" => True,");
else
Ada.Text_IO.Put (" => False,");
end if;
Ada.Text_IO.Set_Col (Indent + 1);
end if;
if Default then
Ada.Text_IO.Put ("others => True))");
else
Ada.Text_IO.Put ("others => False))");
end if;
end Put;
begin
Ada.Text_IO.Put_Line (Ada.Text_IO.Standard_Error, " ... norms");
-- Copy properties
for J in Code_Point loop
Normalization (J).CCC := Norms (J).CCC;
Normalization (J).NQC := Norms (J).NQC;
Normalization (J).DT := Norms (J).DT;
Normalization (J).B := Norms (J).B;
end loop;
-- Construct decomposition information.
for J in Code_Point loop
-- Hangul Syllables are decomposed algorithmically, thus they are
-- excluded from data construction here.
if Norms (J).DT /= None
and then J not in Hangul_Syllable_First .. Hangul_Syllable_Last
then
Append_Mapping
(Norms (J).Values (Compatibility).all,
Normalization (J).Decomposition (Compatibility).First,
Normalization (J).Decomposition (Compatibility).Last);
if Norms (J).DT = Canonical then
Append_Mapping
(Norms (J).Values (Canonical).all,
Normalization (J).Decomposition (Canonical).First,
Normalization (J).Decomposition (Canonical).Last);
end if;
end if;
end loop;
-- Construct composition information.
for J in Code_Point loop
if Norms (J).DT = Canonical
and then J not in Hangul_Syllable_First .. Hangul_Syllable_Last
and then not Norms (J).B (Full_Composition_Exclusion)
then
declare
M : Code_Point_Sequence := Norms (J).Values (Canonical_Mapping).all;
begin
if Normalization (M (1)).Composition.First = 0 then
First_Index_Last := First_Index_Last + 1;
Normalization (M (1)).Composition.First := First_Index_Last;
end if;
if Normalization (M (2)).Composition.Last = 0 then
Last_Index_Last := Last_Index_Last + 1;
Normalization (M (2)).Composition.Last := Last_Index_Last;
end if;
end;
end if;
end loop;
Composition_Data :=
new Composition_Mapping'
(1 .. First_Index_Last => (1 .. Last_Index_Last => 16#FFFF#));
for J in Code_Point loop
if Norms (J).DT = Canonical
and then J not in Hangul_Syllable_First .. Hangul_Syllable_Last
and then not Norms (J).B (Full_Composition_Exclusion)
then
declare
M : Code_Point_Sequence
:= Norms (J).Values (Canonical_Mapping).all;
begin
Composition_Data
(Normalization (M (1)).Composition.First,
Normalization (M (2)).Composition.Last) := J;
end;
end if;
end loop;
-- Pack groups: reuse groups with the same values.
for J in Groups'Range loop
for K in 0 .. J loop
if Normalization
(Code_Unit_32 (K) * 256 .. Code_Unit_32 (K) * 256 + 255)
= Normalization
(Code_Unit_32 (J) * 256 .. Code_Unit_32 (J) * 256 + 255)
then
Groups (J).Share := K;
Groups (K).Count := Groups (K).Count + 1;
exit;
end if;
end loop;
end loop;
-- Generate source code.
Put_File_Header
("Localization, Internationalization, Globalization for Ada",
2009,
2015);
Ada.Text_IO.New_Line;
-- GNAT GPL 2011: disabling of generation of elaboration code causes incorrect
-- code generation for normalization
--
-- Ada.Text_IO.Put_Line ("pragma Restrictions (No_Elaboration_Code);");
-- Ada.Text_IO.Put_Line
-- ("-- GNAT: enforce generation of preinitialized data section instead of");
-- Ada.Text_IO.Put_Line ("-- generation of elaboration code.");
-- Ada.Text_IO.New_Line;
Ada.Text_IO.Put_Line ("package Matreshka.Internals.Unicode.Ucd.Norms is");
Ada.Text_IO.New_Line;
Ada.Text_IO.Put_Line (" pragma Preelaborate;");
Ada.Text_IO.New_Line;
Ada.Text_IO.Put_Line
(" Decomposition_Data : aliased constant Code_Point_Sequence");
for J in 1 .. Decomposition_Data_Last loop
if J = 1 then
Ada.Text_IO.Put (" := (");
elsif (J - 1) mod 5 = 0 then
Ada.Text_IO.Put_Line (",");
Ada.Text_IO.Put (" ");
else
Ada.Text_IO.Put (", ");
end if;
Ada.Text_IO.Put (Code_Point_Ada_Image (Decomposition_Data (J)));
end loop;
Ada.Text_IO.Put_Line (");");
Ada.Text_IO.New_Line;
Ada.Text_IO.Put_Line
(" Composition_Data : aliased constant Composition_Mapping (1 .. "
& Sequence_Count_Image (Composition_Data'Length (1))
& ", 1 .. "
& Sequence_Count_Image (Composition_Data'Length (2))
& ")");
for J in Composition_Data'Range (1) loop
if J = 1 then
Ada.Text_IO.Put (" := (");
else
Ada.Text_IO.Put_Line (",");
Ada.Text_IO.Put (" ");
end if;
Ada.Text_IO.Put (Sequence_Count_Image (J) & " => (");
declare
N : Natural := 0;
begin
for K in Composition_Data'Range (2) loop
if Composition_Data (J, K) /= 16#FFFF# then
Ada.Text_IO.Put
(Sequence_Count_Image (K)
& " => "
& Code_Point_Ada_Image (Composition_Data (J, K))
& ",");
case N mod 3 is
when 0 | 1 =>
Ada.Text_IO.Put (" ");
when 2 =>
Ada.Text_IO.Set_Col (16);
when others =>
raise Program_Error;
end case;
N := N + 1;
end if;
end loop;
Ada.Text_IO.Put ("others => 16#00FFFF#)");
end;
end loop;
Ada.Text_IO.Put_Line (");");
for J in Groups'Range loop
if not Generated (Groups (J).Share) then
declare
Default : Normalization_Mapping;
Current : Normalization_Mapping;
First : Second_Stage_Index;
Last : Second_Stage_Index;
First_Code : Code_Point;
Last_Code : Code_Point;
begin
-- Looking for most useful set of values, it will be used for
-- others selector for generate more compact code.
declare
type Value_Count_Pair is record
V : Normalization_Mapping;
C : Natural;
end record;
Counts : array (Positive range 1 .. 256) of Value_Count_Pair
:= (others => <>);
Last : Natural := 0;
Maximum : Natural := 0;
begin
for K in Second_Stage_Index loop
declare
C : constant Code_Point
:= Code_Unit_32 (J) * 256 + Code_Unit_32 (K);
R : Normalization_Mapping renames Normalization (C);
F : Boolean := False;
begin
-- Go throught known values and try to find the same
-- value.
for L in 1 .. Last loop
if Counts (L).V = R then
F := True;
Counts (L).C := Counts (L).C + 1;
if Maximum < Counts (L).C then
Maximum := Counts (L).C;
Default := Counts (L).V;
end if;
exit;
end if;
end loop;
-- If value is not found, then add it to the end of list.
if not F then
Last := Last + 1;
Counts (Last) := (R, 1);
end if;
end;
end loop;
end;
Ada.Text_IO.New_Line;
Ada.Text_IO.Put_Line
(" Group_"
& First_Stage_Image (Groups (J).Share)
& " : aliased constant Normalization_Mapping_Second_Stage");
Ada.Text_IO.Put (" := (");
for K in Second_Stage_Index loop
declare
Code : constant Code_Point
:= Code_Unit_32 (J) * 256 + Code_Unit_32 (K);
begin
if K = Second_Stage_Index'First then
Current := Normalization (Code);
First := K;
Last := First;
First_Code := Code;
Last_Code := Code;
elsif Normalization (Code) = Current then
Last := K;
Last_Code := Code;
else
if Current /= Default then
if First /= Last then
Ada.Text_IO.Put_Line
("16#"
& Second_Stage_Image (First)
& "# .. 16#"
& Second_Stage_Image (Last)
& "# => -- "
& Code_Point_Image (First_Code)
& " .. "
& Code_Point_Image (Last_Code));
Ada.Text_IO.Set_Col (11);
Put (Current);
Ada.Text_IO.Put (',');
else
Ada.Text_IO.Put_Line
("16#"
& Second_Stage_Image (First)
& "# => -- "
& Code_Point_Image (First_Code));
Ada.Text_IO.Set_Col (11);
Put (Current);
Ada.Text_IO.Put (',');
end if;
Ada.Text_IO.New_Line;
Ada.Text_IO.Set_Col (10);
end if;
Current := Normalization (Code);
First := K;
Last := First;
First_Code := Code;
Last_Code := First_Code;
end if;
end;
end loop;
if Current /= Default then
if First /= Last then
Ada.Text_IO.Put_Line
("16#"
& Second_Stage_Image (First)
& "# .. 16#"
& Second_Stage_Image (Last)
& "# => -- "
& Code_Point_Image (First_Code)
& " .. "
& Code_Point_Image (Last_Code));
Ada.Text_IO.Set_Col (11);
Put (Current);
Ada.Text_IO.Put (',');
else
Ada.Text_IO.Put_Line
("16#"
& Second_Stage_Image (First)
& "# => -- "
& Code_Point_Image (First_Code));
Ada.Text_IO.Set_Col (11);
Put (Current);
Ada.Text_IO.Put (',');
end if;
Ada.Text_IO.New_Line;
Ada.Text_IO.Set_Col (10);
end if;
Ada.Text_IO.Put_Line ("others =>");
Ada.Text_IO.Set_Col (11);
Put (Default);
Ada.Text_IO.Put_Line (");");
Generated (J) := True;
end;
end if;
end loop;
declare
Default : First_Stage_Index := 0;
Maximum : Natural := 0;
N : Natural := 0;
begin
for J in Groups'Range loop
if Maximum < Groups (J).Count then
Maximum := Groups (J).Count;
Default := J;
end if;
end loop;
Ada.Text_IO.New_Line;
Ada.Text_IO.Put_Line
(" Mapping : aliased constant Normalization_Mapping_First_Stage");
Ada.Text_IO.Put (" := (");
for J in Groups'Range loop
if Groups (J).Share /= Default then
Ada.Text_IO.Put
("16#"
& First_Stage_Image (J)
& "# => Group_"
& First_Stage_Image (Groups (J).Share)
& "'Access,");
case N mod 2 is
when 0 =>
Ada.Text_IO.Set_Col (41);
when 1 =>
Ada.Text_IO.New_Line;
Ada.Text_IO.Set_Col (10);
when others =>
raise Program_Error;
end case;
N := N + 1;
end if;
end loop;
Ada.Text_IO.Put_Line
("others => Group_" & First_Stage_Image (Default) & "'Access);");
end;
Ada.Text_IO.New_Line;
Ada.Text_IO.Put_Line ("end Matreshka.Internals.Unicode.Ucd.Norms;");
end Gen_Norms;
|
zhmu/ananas | Ada | 38,083 | ads | ------------------------------------------------------------------------------
-- --
-- GNAT LIBRARY COMPONENTS --
-- --
-- A D A . C O N T A I N E R S . V E C T O R S --
-- --
-- S p e c --
-- --
-- Copyright (C) 2004-2022, Free Software Foundation, Inc. --
-- --
-- This specification is derived from the Ada Reference Manual for use with --
-- GNAT. The copyright notice above, and the license provisions that follow --
-- apply solely to the contents of the part following the private keyword. --
-- --
-- GNAT is free software; you can redistribute it and/or modify it under --
-- terms of the GNU General Public License as published by the Free Soft- --
-- ware Foundation; either version 3, or (at your option) any later ver- --
-- sion. GNAT is distributed in the hope that it will be useful, but WITH- --
-- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY --
-- or FITNESS FOR A PARTICULAR PURPOSE. --
-- --
-- As a special exception under Section 7 of GPL version 3, you are granted --
-- additional permissions described in the GCC Runtime Library Exception, --
-- version 3.1, as published by the Free Software Foundation. --
-- --
-- You should have received a copy of the GNU General Public License and --
-- a copy of the GCC Runtime Library Exception along with this program; --
-- see the files COPYING3 and COPYING.RUNTIME respectively. If not, see --
-- <http://www.gnu.org/licenses/>. --
-- --
-- This unit was originally developed by Matthew J Heaney. --
------------------------------------------------------------------------------
with Ada.Iterator_Interfaces;
with Ada.Containers.Helpers;
private with Ada.Finalization;
private with Ada.Streams;
private with Ada.Strings.Text_Buffers;
-- The language-defined generic package Containers.Vectors provides private
-- types Vector and Cursor, and a set of operations for each type. A vector
-- container allows insertion and deletion at any position, but it is
-- specifically optimized for insertion and deletion at the high end (the end
-- with the higher index) of the container. A vector container also provides
-- random access to its elements.
--
-- A vector container behaves conceptually as an array that expands as
-- necessary as items are inserted. The length of a vector is the number of
-- elements that the vector contains. The capacity of a vector is the maximum
-- number of elements that can be inserted into the vector prior to it being
-- automatically expanded.
--
-- Elements in a vector container can be referred to by an index value of a
-- generic formal type. The first element of a vector always has its index
-- value equal to the lower bound of the formal type.
--
-- A vector container may contain empty elements. Empty elements do not have a
-- specified value.
generic
type Index_Type is range <>;
type Element_Type is private;
with function "=" (Left, Right : Element_Type) return Boolean is <>;
-- The actual function for the generic formal function "=" on Element_Type
-- values is expected to define a reflexive and symmetric relationship and
-- return the same result value each time it is called with a particular
-- pair of values. If it behaves in some other manner, the functions
-- defined to use it return an unspecified value. The exact arguments and
-- number of calls of this generic formal function by the functions defined
-- to use it are unspecified.
package Ada.Containers.Vectors with
SPARK_Mode => Off
is
pragma Annotate (CodePeer, Skip_Analysis);
pragma Preelaborate;
pragma Remote_Types;
subtype Extended_Index is Index_Type'Base
range Index_Type'First - 1 ..
Index_Type'Min (Index_Type'Base'Last - 1, Index_Type'Last) + 1;
-- The subtype Extended_Index includes the indices covered by Index_Type
-- plus the value No_Index and, if it exists, the successor to the
-- Index_Type'Last.
No_Index : constant Extended_Index := Extended_Index'First;
-- No_Index represents a position that does not correspond to any element.
type Vector is tagged private
with
Constant_Indexing => Constant_Reference,
Variable_Indexing => Reference,
Default_Iterator => Iterate,
Iterator_Element => Element_Type,
Aggregate => (Empty => Empty,
Add_Unnamed => Append,
New_Indexed => New_Vector,
Assign_Indexed => Replace_Element);
pragma Preelaborable_Initialization (Vector);
-- Vector type, to be instantiated by users of this package. If an object
-- of type Vector is not otherwise initialized, it is initialized to
-- Empty_Vector.
type Cursor is private;
pragma Preelaborable_Initialization (Cursor);
-- Cursor pointing into an instance of vector. If an object of type Cursor
-- is not otherwise initialized, it is initialized to No_Element
No_Element : constant Cursor;
-- No_Element represents a cursor that designates no element.
function Has_Element (Position : Cursor) return Boolean;
-- Returns True if Position designates an element, and returns False
-- otherwise.
package Vector_Iterator_Interfaces is new
Ada.Iterator_Interfaces (Cursor, Has_Element);
Empty_Vector : constant Vector;
-- Empty_Vector represents the empty vector object. It has a length of 0.
function Empty (Capacity : Count_Type := 10) return Vector;
overriding function "=" (Left, Right : Vector) return Boolean;
-- If Left and Right denote the same vector object, then the function
-- returns True. If Left and Right have different lengths, then the
-- function returns False. Otherwise, it compares each element in Left to
-- the corresponding element in Right using the generic formal equality
-- operator. If any such comparison returns False, the function returns
-- False; otherwise it returns True. Any exception raised during evaluation
-- of element equality is propagated.
function To_Vector (Length : Count_Type) return Vector;
-- Returns a vector with a length of Length, filled with empty elements.
function To_Vector
(New_Item : Element_Type;
Length : Count_Type) return Vector;
-- Returns a vector with a length of Length, filled with elements
-- initialized to the value New_Item.
function "&" (Left, Right : Vector) return Vector;
-- Returns a vector comprising the elements of Left followed by the
-- elements of Right.
function "&" (Left : Vector; Right : Element_Type) return Vector;
-- Returns a vector comprising the elements of Left followed by the element
-- Right.
function "&" (Left : Element_Type; Right : Vector) return Vector;
-- Returns a vector comprising the element Left followed by the elements of
-- Right.
function "&" (Left, Right : Element_Type) return Vector;
-- Returns a vector comprising the element Left followed by the element
-- Right.
function Capacity (Container : Vector) return Count_Type;
-- Returns the capacity of Container.
procedure Reserve_Capacity
(Container : in out Vector;
Capacity : Count_Type);
-- Reserve_Capacity allocates new internal data structures such that the
-- length of the resulting vector can become at least the value Capacity
-- without requiring an additional call to Reserve_Capacity, and is large
-- enough to hold the current length of Container. Reserve_Capacity then
-- copies the elements into the new data structures and deallocates the old
-- data structures. Any exception raised during allocation is propagated
-- and Container is not modified.
function Length (Container : Vector) return Count_Type;
-- Returns the number of elements in Container.
procedure Set_Length
(Container : in out Vector;
Length : Count_Type);
-- If Length is larger than the capacity of Container, Set_Length calls
-- Reserve_Capacity (Container, Length), then sets the length of the
-- Container to Length. If Length is greater than the original length of
-- Container, empty elements are added to Container; otherwise elements are
-- removed from Container.
function Is_Empty (Container : Vector) return Boolean;
-- Equivalent to Length (Container) = 0.
procedure Clear (Container : in out Vector);
-- Removes all the elements from Container. The capacity of Container does
-- not change.
function To_Cursor
(Container : Vector;
Index : Extended_Index) return Cursor;
-- If Index is not in the range First_Index (Container) .. Last_Index
-- (Container), then No_Element is returned. Otherwise, a cursor
-- designating the element at position Index in Container is returned.
function To_Index (Position : Cursor) return Extended_Index;
-- If Position is No_Element, No_Index is returned. Otherwise, the index
-- (within its containing vector) of the element designated by Position is
-- returned.
function Element
(Container : Vector;
Index : Index_Type) return Element_Type;
-- If Index is not in the range First_Index (Container) .. Last_Index
-- (Container), then Constraint_Error is propagated. Otherwise, Element
-- returns the element at position Index.
function Element (Position : Cursor) return Element_Type;
-- If Position equals No_Element, then Constraint_Error is propagated.
-- Otherwise, Element returns the element designated by Position.
procedure Replace_Element
(Container : in out Vector;
Index : Index_Type;
New_Item : Element_Type);
-- If Index is not in the range First_Index (Container) .. Last_Index
-- (Container), then Constraint_Error is propagated. Otherwise
-- Replace_Element assigns the value New_Item to the element at position
-- Index. Any exception raised during the assignment is propagated. The
-- element at position Index is not an empty element after successful call
-- to Replace_Element.
procedure Replace_Element
(Container : in out Vector;
Position : Cursor;
New_Item : Element_Type);
-- If Position equals No_Element, then Constraint_Error is propagated; if
-- Position does not designate an element in Container, then Program_Error
-- is propagated. Otherwise Replace_Element assigns New_Item to the element
-- designated by Position. Any exception raised during the assignment is
-- propagated. The element at Position is not an empty element after
-- successful call to Replace_Element.
procedure Query_Element
(Container : Vector;
Index : Index_Type;
Process : not null access procedure (Element : Element_Type));
-- If Index is not in the range First_Index (Container) .. Last_Index
-- (Container), then Constraint_Error is propagated. Otherwise,
-- Query_Element calls Process.all with the element at position Index as
-- the argument. Program_Error is propagated if Process.all tampers with
-- the elements of Container. Any exception raised by Process.all is
-- propagated.
procedure Query_Element
(Position : Cursor;
Process : not null access procedure (Element : Element_Type));
-- If Position equals No_Element, then Constraint_Error is propagated.
-- Otherwise, Query_Element calls Process.all with the element designated
-- by Position as the argument. Program_Error is propagated if Process.all
-- tampers with the elements of Container. Any exception raised by
-- Process.all is propagated.
procedure Update_Element
(Container : in out Vector;
Index : Index_Type;
Process : not null access procedure (Element : in out Element_Type));
-- If Index is not in the range First_Index (Container) .. Last_Index
-- (Container), then Constraint_Error is propagated. Otherwise,
-- Update_Element calls Process.all with the element at position Index as
-- the argument. Program_Error is propagated if Process.all tampers with
-- the elements of Container. Any exception raised by Process.all is
-- propagated.
--
-- If Element_Type is unconstrained and definite, then the actual Element
-- parameter of Process.all shall be unconstrained.
--
-- The element at position Index is not an empty element after successful
-- completion of this operation.
procedure Update_Element
(Container : in out Vector;
Position : Cursor;
Process : not null access procedure (Element : in out Element_Type));
-- If Position equals No_Element, then Constraint_Error is propagated; if
-- Position does not designate an element in Container, then Program_Error
-- is propagated. Otherwise Update_Element calls Process.all with the
-- element designated by Position as the argument. Program_Error is
-- propagated if Process.all tampers with the elements of Container. Any
-- exception raised by Process.all is propagated.
--
-- If Element_Type is unconstrained and definite, then the actual Element
-- parameter of Process.all shall be unconstrained.
--
-- The element designated by Position is not an empty element after
-- successful completion of this operation.
type Constant_Reference_Type
(Element : not null access constant Element_Type) is
private
with
Implicit_Dereference => Element;
type Reference_Type (Element : not null access Element_Type) is private
with
Implicit_Dereference => Element;
function Constant_Reference
(Container : aliased Vector;
Position : Cursor) return Constant_Reference_Type;
pragma Inline (Constant_Reference);
function Reference
(Container : aliased in out Vector;
Position : Cursor) return Reference_Type;
pragma Inline (Reference);
function Constant_Reference
(Container : aliased Vector;
Index : Index_Type) return Constant_Reference_Type;
pragma Inline (Constant_Reference);
function Reference
(Container : aliased in out Vector;
Index : Index_Type) return Reference_Type;
pragma Inline (Reference);
procedure Assign (Target : in out Vector; Source : Vector);
function Copy (Source : Vector; Capacity : Count_Type := 0) return Vector;
procedure Move (Target : in out Vector; Source : in out Vector);
-- If Target denotes the same object as Source, then Move has no effect.
-- Otherwise, Move first calls Clear (Target); then, each element from
-- Source is removed from Source and inserted into Target in the original
-- order. The length of Source is 0 after a successful call to Move.
function New_Vector (First, Last : Index_Type) return Vector
with Pre => First = Index_Type'First;
-- Ada 2022 aggregate operation.
procedure Insert_Vector
(Container : in out Vector;
Before : Extended_Index;
New_Item : Vector);
-- If Before is not in the range First_Index (Container) .. Last_Index
-- (Container) + 1, then Constraint_Error is propagated. If
-- Length(New_Item) is 0, then Insert_Vector does nothing. Otherwise, it
-- computes the new length NL as the sum of the current length and Length
-- (New_Item); if the value of Last appropriate for length NL would be
-- greater than Index_Type'Last then Constraint_Error is propagated.
--
-- If the current vector capacity is less than NL, Reserve_Capacity
-- (Container, NL) is called to increase the vector capacity. Then
-- Insert_Vector slides the elements in the range Before .. Last_Index
-- (Container) up by Length(New_Item) positions, and then copies the
-- elements of New_Item to the positions starting at Before. Any exception
-- raised during the copying is propagated.
procedure Insert
(Container : in out Vector;
Before : Extended_Index;
New_Item : Vector) renames Insert_Vector;
-- Retained for now for compatibility; AI12-0400 will remove this.
procedure Insert_Vector
(Container : in out Vector;
Before : Cursor;
New_Item : Vector);
-- If Before is not No_Element, and does not designate an element in
-- Container, then Program_Error is propagated. Otherwise, if
-- Length(New_Item) is 0, then Insert_Vector does nothing. If Before is
-- No_Element, then the call is equivalent to Insert_Vector (Container,
-- Last_Index (Container) + 1, New_Item); otherwise the call is equivalent
-- to Insert_Vector (Container, To_Index (Before), New_Item);
procedure Insert
(Container : in out Vector;
Before : Cursor;
New_Item : Vector) renames Insert_Vector;
-- Retained for now for compatibility; AI12-0400 will remove this.
procedure Insert_Vector
(Container : in out Vector;
Before : Cursor;
New_Item : Vector;
Position : out Cursor);
-- If Before is not No_Element, and does not designate an element in
-- Container, then Program_Error is propagated. If Before equals
-- No_Element, then let T be Last_Index (Container) + 1; otherwise, let T
-- be To_Index (Before). Insert_Vector (Container, T, New_Item) is called,
-- and then Position is set to To_Cursor (Container, T).
procedure Insert
(Container : in out Vector;
Before : Cursor;
New_Item : Vector;
Position : out Cursor) renames Insert_Vector;
-- Retained for now for compatibility; AI12-0400 will remove this.
procedure Insert
(Container : in out Vector;
Before : Extended_Index;
New_Item : Element_Type;
Count : Count_Type := 1);
-- Equivalent to:
-- Insert_Vector (Container, Before, To_Vector (New_Item, Count));
procedure Insert
(Container : in out Vector;
Before : Cursor;
New_Item : Element_Type;
Count : Count_Type := 1);
-- Equivalent to:
-- Insert_Vector (Container, Before, To_Vector (New_Item, Count));
procedure Insert
(Container : in out Vector;
Before : Cursor;
New_Item : Element_Type;
Position : out Cursor;
Count : Count_Type := 1);
-- Equivalent to
-- Insert_Vector (Container, Before, To_Vector (New_Item, Count), Position)
procedure Insert
(Container : in out Vector;
Before : Extended_Index;
Count : Count_Type := 1);
-- If Before is not in the range First_Index (Container) .. Last_Index
-- (Container) + 1, then Constraint_Error is propagated. If Count is 0,
-- then Insert does nothing. Otherwise, it computes the new length NL as
-- the sum of the current length and Count; if the value of Last
-- appropriate for length NL would be greater than Index_Type'Last then
-- Constraint_Error is propagated.
--
-- If the current vector capacity is less than NL, Reserve_Capacity
-- (Container, NL) is called to increase the vector capacity. Then Insert
-- slides the elements in the range Before .. Last_Index (Container) up by
-- Count positions, and then inserts elements that are initialized by
-- default (see 3.3.1) in the positions starting at Before.
procedure Insert
(Container : in out Vector;
Before : Cursor;
Position : out Cursor;
Count : Count_Type := 1);
-- If Before is not No_Element, and does not designate an element in
-- Container, then Program_Error is propagated. If Before equals
-- No_Element, then let T be Last_Index (Container) + 1; otherwise, let T
-- be To_Index (Before). Insert (Container, T, Count) is called, and then
-- Position is set to To_Cursor (Container, T).
procedure Prepend_Vector
(Container : in out Vector;
New_Item : Vector);
-- Equivalent to Insert (Container, First_Index (Container), New_Item).
procedure Prepend
(Container : in out Vector;
New_Item : Vector) renames Prepend_Vector;
-- Retained for now for compatibility; AI12-0400 will remove this.
procedure Prepend
(Container : in out Vector;
New_Item : Element_Type;
Count : Count_Type := 1);
-- Equivalent to Insert (Container, First_Index (Container), New_Item,
-- Count).
procedure Append_Vector
(Container : in out Vector;
New_Item : Vector);
-- Equivalent to Insert (Container, Last_Index (Container) + 1, New_Item).
procedure Append
(Container : in out Vector;
New_Item : Vector) renames Append_Vector;
-- Retained for now for compatibility; AI12-0400 will remove this.
procedure Append
(Container : in out Vector;
New_Item : Element_Type;
Count : Count_Type);
-- Equivalent to Insert (Container, Last_Index (Container) + 1, New_Item,
-- Count).
procedure Append (Container : in out Vector;
New_Item : Element_Type);
procedure Insert_Space
(Container : in out Vector;
Before : Extended_Index;
Count : Count_Type := 1);
-- If Before is not in the range First_Index (Container) .. Last_Index
-- (Container) + 1, then Constraint_Error is propagated. If Count is 0,
-- then Insert_Space does nothing. Otherwise, it computes the new length NL
-- as the sum of the current length and Count; if the value of Last
-- appropriate for length NL would be greater than Index_Type'Last then
-- Constraint_Error is propagated.
--
-- If the current vector capacity is less than NL, Reserve_Capacity
-- (Container, NL) is called to increase the vector capacity. Then
-- Insert_Space slides the elements in the range Before .. Last_Index
-- (Container) up by Count positions, and then inserts empty elements in
-- the positions starting at Before.
procedure Insert_Space
(Container : in out Vector;
Before : Cursor;
Position : out Cursor;
Count : Count_Type := 1);
-- If Before is not No_Element, and does not designate an element in
-- Container, then Program_Error is propagated. If Before equals
-- No_Element, then let T be Last_Index (Container) + 1; otherwise, let T
-- be To_Index (Before). Insert_Space (Container, T, Count) is called, and
-- then Position is set to To_Cursor (Container, T).
procedure Delete
(Container : in out Vector;
Index : Extended_Index;
Count : Count_Type := 1);
-- If Index is not in the range First_Index (Container) .. Last_Index
-- (Container) + 1, then Constraint_Error is propagated. If Count is 0,
-- Delete has no effect. Otherwise Delete slides the elements (if any)
-- starting at position Index + Count down to Index. Any exception raised
-- during element assignment is propagated.
procedure Delete
(Container : in out Vector;
Position : in out Cursor;
Count : Count_Type := 1);
-- If Position equals No_Element, then Constraint_Error is propagated. If
-- Position does not designate an element in Container, then Program_Error
-- is propagated. Otherwise, Delete (Container, To_Index (Position), Count)
-- is called, and then Position is set to No_Element.
procedure Delete_First
(Container : in out Vector;
Count : Count_Type := 1);
-- Equivalent to Delete (Container, First_Index (Container), Count).
procedure Delete_Last
(Container : in out Vector;
Count : Count_Type := 1);
-- If Length (Container) <= Count then Delete_Last is equivalent to Clear
-- (Container). Otherwise it is equivalent to Delete (Container,
-- Index_Type'Val(Index_Type'Pos(Last_Index (Container)) - Count + 1),
-- Count).
procedure Reverse_Elements (Container : in out Vector);
-- Reorders the elements of Container in reverse order.
procedure Swap (Container : in out Vector; I, J : Index_Type);
-- If either I or J is not in the range First_Index (Container) ..
-- Last_Index (Container), then Constraint_Error is propagated. Otherwise,
-- Swap exchanges the values of the elements at positions I and J.
procedure Swap (Container : in out Vector; I, J : Cursor);
-- If either I or J is No_Element, then Constraint_Error is propagated. If
-- either I or J do not designate an element in Container, then
-- Program_Error is propagated. Otherwise, Swap exchanges the values of the
-- elements designated by I and J.
function First_Index (Container : Vector) return Index_Type;
-- Returns the value Index_Type'First.
function First (Container : Vector) return Cursor;
-- If Container is empty, First returns No_Element. Otherwise, it returns a
-- cursor that designates the first element in Container.
function First_Element (Container : Vector) return Element_Type;
-- Equivalent to Element (Container, First_Index (Container)).
function Last_Index (Container : Vector) return Extended_Index;
-- If Container is empty, Last_Index returns No_Index. Otherwise, it
-- returns the position of the last element in Container.
function Last (Container : Vector) return Cursor;
-- If Container is empty, Last returns No_Element. Otherwise, it returns a
-- cursor that designates the last element in Container.
function Last_Element (Container : Vector) return Element_Type;
-- Equivalent to Element (Container, Last_Index (Container)).
function Next (Position : Cursor) return Cursor;
-- If Position equals No_Element or designates the last element of the
-- container, then Next returns the value No_Element. Otherwise, it returns
-- a cursor that designates the element with index To_Index (Position) + 1
-- in the same vector as Position.
procedure Next (Position : in out Cursor);
-- Equivalent to Position := Next (Position).
function Previous (Position : Cursor) return Cursor;
-- If Position equals No_Element or designates the first element of the
-- container, then Previous returns the value No_Element. Otherwise, it
-- returns a cursor that designates the element with index To_Index
-- (Position) - 1 in the same vector as Position.
procedure Previous (Position : in out Cursor);
-- Equivalent to Position := Previous (Position).
function Find_Index
(Container : Vector;
Item : Element_Type;
Index : Index_Type := Index_Type'First) return Extended_Index;
-- Searches the elements of Container for an element equal to Item (using
-- the generic formal equality operator). The search starts at position
-- Index and proceeds towards Last_Index (Container). If no equal
-- element is found, then Find_Index returns No_Index. Otherwise, it
-- returns the index of the first equal element encountered.
function Find
(Container : Vector;
Item : Element_Type;
Position : Cursor := No_Element) return Cursor;
-- If Position is not No_Element, and does not designate an element in
-- Container, then Program_Error is propagated. Otherwise Find searches
-- the elements of Container for an element equal to Item (using the
-- generic formal equality operator). The search starts at the first
-- element if Position equals No_Element, and at the element designated
-- by Position otherwise. It proceeds towards the last element of
-- Container. If no equal element is found, then Find returns
-- No_Element. Otherwise, it returns a cursor designating the first
-- equal element encountered.
function Reverse_Find_Index
(Container : Vector;
Item : Element_Type;
Index : Index_Type := Index_Type'Last) return Extended_Index;
-- Searches the elements of Container for an element equal to Item (using
-- the generic formal equality operator). The search starts at position
-- Index or, if Index is greater than Last_Index (Container), at
-- position Last_Index (Container). It proceeds towards First_Index
-- (Container). If no equal element is found, then Reverse_Find_Index
-- returns No_Index. Otherwise, it returns the index of the first equal
-- element encountered.
function Reverse_Find
(Container : Vector;
Item : Element_Type;
Position : Cursor := No_Element) return Cursor;
-- If Position is not No_Element, and does not designate an element in
-- Container, then Program_Error is propagated. Otherwise Reverse_Find
-- searches the elements of Container for an element equal to Item
-- (using the generic formal equality operator). The search starts at
-- the last element if Position equals No_Element, and at the element
-- designated by Position otherwise. It proceeds towards the first
-- element of Container. If no equal element is found, then Reverse_Find
-- returns No_Element. Otherwise, it returns a cursor designating the
-- first equal element encountered.
function Contains
(Container : Vector;
Item : Element_Type) return Boolean;
-- Equivalent to Has_Element (Find (Container, Item)).
procedure Iterate
(Container : Vector;
Process : not null access procedure (Position : Cursor));
-- Invokes Process.all with a cursor that designates each element in
-- Container, in index order. Program_Error is propagated if Process.all
-- tampers with the cursors of Container. Any exception raised by Process
-- is propagated.
procedure Reverse_Iterate
(Container : Vector;
Process : not null access procedure (Position : Cursor));
-- Iterates over the elements in Container as per Iterate, except that
-- elements are traversed in reverse index order.
--
function Iterate (Container : Vector)
return Vector_Iterator_Interfaces.Reversible_Iterator'Class;
function Iterate (Container : Vector; Start : Cursor)
return Vector_Iterator_Interfaces.Reversible_Iterator'Class;
generic
with function "<" (Left, Right : Element_Type) return Boolean is <>;
-- The actual function for the generic formal function "<" of
-- Generic_Sorting is expected to return the same value each time it is
-- called with a particular pair of element values. It should define a
-- strict ordering relationship, that is, be irreflexive, asymmetric,
-- and transitive; it should not modify Container. If the actual for "<"
-- behaves in some other manner, the behavior of the subprograms of
-- Generic_Sorting are unspecified. How many times the subprograms of
-- Generic_Sorting call "<" is unspecified.
package Generic_Sorting is
function Is_Sorted (Container : Vector) return Boolean;
-- Returns True if the elements are sorted smallest first as determined
-- by the generic formal "<" operator; otherwise, Is_Sorted returns
-- False. Any exception raised during evaluation of "<" is propagated.
procedure Sort (Container : in out Vector);
-- Reorders the elements of Container such that the elements are sorted
-- smallest first as determined by the generic formal "<" operator
-- provided. Any exception raised during evaluation of "<" is
-- propagated.
procedure Merge (Target : in out Vector; Source : in out Vector);
-- Merge removes elements from Source and inserts them into Target;
-- afterwards, Target contains the union of the elements that were
-- initially in Source and Target; Source is left empty. If Target and
-- Source are initially sorted smallest first, then Target is ordered
-- smallest first as determined by the generic formal "<" operator;
-- otherwise, the order of elements in Target is unspecified. Any
-- exception raised during evaluation of "<" is propagated.
end Generic_Sorting;
private
pragma Inline (Append);
pragma Inline (First_Index);
pragma Inline (Last_Index);
pragma Inline (Element);
pragma Inline (First_Element);
pragma Inline (Last_Element);
pragma Inline (Query_Element);
pragma Inline (Update_Element);
pragma Inline (Replace_Element);
pragma Inline (Is_Empty);
pragma Inline (Contains);
pragma Inline (Next);
pragma Inline (Previous);
use Ada.Containers.Helpers;
package Implementation is new Generic_Implementation;
use Implementation;
type Elements_Array is array (Index_Type range <>) of aliased Element_Type;
function "=" (L, R : Elements_Array) return Boolean is abstract;
type Elements_Type (Last : Extended_Index) is limited record
EA : Elements_Array (Index_Type'First .. Last);
end record;
type Elements_Access is access all Elements_Type;
use Finalization;
use Streams;
type Vector is new Controlled with record
Elements : Elements_Access := null;
Last : Extended_Index := No_Index;
TC : aliased Tamper_Counts;
end record with Put_Image => Put_Image;
procedure Put_Image
(S : in out Ada.Strings.Text_Buffers.Root_Buffer_Type'Class; V : Vector);
overriding procedure Adjust (Container : in out Vector);
overriding procedure Finalize (Container : in out Vector);
procedure Write
(Stream : not null access Root_Stream_Type'Class;
Container : Vector);
for Vector'Write use Write;
procedure Read
(Stream : not null access Root_Stream_Type'Class;
Container : out Vector);
for Vector'Read use Read;
type Vector_Access is access all Vector;
for Vector_Access'Storage_Size use 0;
type Cursor is record
Container : Vector_Access;
Index : Index_Type := Index_Type'First;
end record;
procedure Read
(Stream : not null access Root_Stream_Type'Class;
Position : out Cursor);
for Cursor'Read use Read;
procedure Write
(Stream : not null access Root_Stream_Type'Class;
Position : Cursor);
for Cursor'Write use Write;
subtype Reference_Control_Type is Implementation.Reference_Control_Type;
-- It is necessary to rename this here, so that the compiler can find it
type Constant_Reference_Type
(Element : not null access constant Element_Type) is
record
Control : Reference_Control_Type :=
raise Program_Error with "uninitialized reference";
-- The RM says, "The default initialization of an object of
-- type Constant_Reference_Type or Reference_Type propagates
-- Program_Error."
end record;
procedure Write
(Stream : not null access Root_Stream_Type'Class;
Item : Constant_Reference_Type);
for Constant_Reference_Type'Write use Write;
procedure Read
(Stream : not null access Root_Stream_Type'Class;
Item : out Constant_Reference_Type);
for Constant_Reference_Type'Read use Read;
type Reference_Type
(Element : not null access Element_Type) is
record
Control : Reference_Control_Type :=
raise Program_Error with "uninitialized reference";
-- The RM says, "The default initialization of an object of
-- type Constant_Reference_Type or Reference_Type propagates
-- Program_Error."
end record;
procedure Write
(Stream : not null access Root_Stream_Type'Class;
Item : Reference_Type);
for Reference_Type'Write use Write;
procedure Read
(Stream : not null access Root_Stream_Type'Class;
Item : out Reference_Type);
for Reference_Type'Read use Read;
-- Three operations are used to optimize in the expansion of "for ... of"
-- loops: the Next(Cursor) procedure in the visible part, and the following
-- Pseudo_Reference and Get_Element_Access functions. See Exp_Ch5 for
-- details.
function Pseudo_Reference
(Container : aliased Vector'Class) return Reference_Control_Type;
pragma Inline (Pseudo_Reference);
-- Creates an object of type Reference_Control_Type pointing to the
-- container, and increments the Lock. Finalization of this object will
-- decrement the Lock.
type Element_Access is access all Element_Type;
function Get_Element_Access
(Position : Cursor) return not null Element_Access;
-- Returns a pointer to the element designated by Position.
No_Element : constant Cursor := Cursor'(null, Index_Type'First);
Empty_Vector : constant Vector := (Controlled with others => <>);
type Iterator is new Limited_Controlled and
Vector_Iterator_Interfaces.Reversible_Iterator with
record
Container : Vector_Access;
Index : Index_Type'Base;
end record
with Disable_Controlled => not T_Check;
overriding procedure Finalize (Object : in out Iterator);
overriding function First (Object : Iterator) return Cursor;
overriding function Last (Object : Iterator) return Cursor;
overriding function Next
(Object : Iterator;
Position : Cursor) return Cursor;
overriding function Previous
(Object : Iterator;
Position : Cursor) return Cursor;
end Ada.Containers.Vectors;
|
charlie5/lace | Ada | 899 | ads | with
gel.World,
gel.Camera,
gel.Window;
package gel.Applet.gui_world
--
-- Provides a gel applet configured with a single window and a single GUI world.
--
is
type Item is new gel.Applet.item with private;
type View is access all Item'Class;
package Forge
is
function new_Applet (Name : in String;
use_Window : in gel.Window.view;
space_Kind : in physics.space_Kind) return gel.Applet.gui_world.view;
end Forge;
procedure free (Self : in out View);
gui_world_Id : constant world_Id := 1;
gui_camera_Id : constant camera_Id := 1;
function gui_World (Self : in Item) return gel.World .view;
function gui_Camera (Self : in Item) return gel.Camera.view;
private
type Item is new gel.Applet.item with
record
null;
end record;
end gel.Applet.gui_world;
|
ytomino/xml-ada | Ada | 105 | adb | with Ada.Text_IO;
with XML;
procedure version is
begin
Ada.Text_IO.Put_Line (XML.Version);
end version;
|
rizalgowandy/Amass | Ada | 2,397 | ads | -- Copyright 2020-2021 Jeff Foley. All rights reserved.
-- Use of this source code is governed by Apache 2 LICENSE that can be found in the LICENSE file.
local json = require("json")
name = "Censys"
type = "cert"
function start()
set_rate_limit(3)
end
function vertical(ctx, domain)
local c
local cfg = datasrc_config()
if cfg ~= nil then
c = cfg.credentials
end
if (c == nil or c.key == nil or
c.key == "" or c.secret == nil or c.secret == "") then
local certpath_re = "/certificates/[a-z0-9]{64}"
for i=1,10 do
local page, err = request(ctx, {['url']=build_url(domain, i)})
if (err ~= nil and err ~= "") then
log(ctx, "vertical request to service failed: " .. err)
return
end
local paths = find(page, certpath_re)
for _, path in pairs(paths) do
scrape(ctx, {['url']="https://censys.io" .. path})
end
end
return
end
api_query(ctx, cfg, domain)
end
function build_url(domain, pagenum)
return "https://censys.io/certificates/_search?q=" .. domain .. "&page=" .. pagenum
end
function api_query(ctx, cfg, domain)
local p = 1
while(true) do
local err, body, resp
body, err = json.encode({
['query']="parsed.names: " .. domain,
['page']=p,
['fields']={"parsed.names"},
})
if (err ~= nil and err ~= "") then
return
end
resp, err = request(ctx, {
method="POST",
data=body,
['url']="https://www.censys.io/api/v1/search/certificates",
headers={['Content-Type']="application/json"},
id=cfg["credentials"].key,
pass=cfg["credentials"].secret,
})
if (err ~= nil and err ~= "") then
log(ctx, "vertical request to service failed: " .. err)
return
end
local d = json.decode(resp)
if (d == nil or d.status ~= "ok" or #(d.results) == 0) then
return
end
for _, r in pairs(d.results) do
for _, v in pairs(r["parsed.names"]) do
new_name(ctx, v)
end
end
if d["metadata"].page >= d["metadata"].pages then
return
end
p = p + 1
end
end
|
reznikmm/spawn | Ada | 860 | adb | --
-- Copyright (C) 2018-2019, AdaCore
--
-- SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
--
with Interfaces.C.Strings;
package body Spawn.Environments.Internal is
---------
-- Raw --
---------
function Raw
(Self : Spawn.Environments.Process_Environment'Class)
return Spawn.Posix.chars_ptr_array
is
Index : Positive := 1;
begin
return Result : Spawn.Posix.chars_ptr_array
(1 .. Natural (Self.Map.Length) + 1)
do
for J in Self.Map.Iterate loop
Result (Index) := Interfaces.C.Strings.New_String
(UTF_8_String_Maps.Key (J) & "=" &
UTF_8_String_Maps.Element (J));
Index := Index + 1;
end loop;
Result (Index) := Interfaces.C.Strings.Null_Ptr;
end return;
end Raw;
end Spawn.Environments.Internal;
|
Heziode/lsystem-editor | Ada | 2,247 | ads | -------------------------------------------------------------------------------
-- LSE -- L-System Editor
-- Author: Heziode
--
-- License:
-- MIT License
--
-- Copyright (c) 2018 Quentin Dauprat (Heziode) <[email protected]>
--
-- Permission is hereby granted, free of charge, to any person obtaining a
-- copy of this software and associated documentation files (the "Software"),
-- to deal in the Software without restriction, including without limitation
-- the rights to use, copy, modify, merge, publish, distribute, sublicense,
-- and/or sell copies of the Software, and to permit persons to whom the
-- Software is furnished to do so, subject to the following conditions:
--
-- The above copyright notice and this permission notice shall be included in
-- all copies or substantial portions of the Software.
--
-- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
-- FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
-- DEALINGS IN THE SOFTWARE.
-------------------------------------------------------------------------------
with LSE.Model.IO.Drawing_Area.Drawing_Area_Ptr;
use LSE.Model.IO.Drawing_Area.Drawing_Area_Ptr;
-- @description
-- This package provide an export (drawing area) factory.
-- It is used by GUI to found the good export format.
--
package LSE.IO.Export_Factory is
-- Error raise when the type of drawing area is unknown
Unknown_Drawing_Area_Type : exception;
-- Make the drawing area
-- @param Value Type of the drawing area
-- @param Path Path where to save the L-System drawed
procedure Make (This : out Holder;
Value : String;
Path : String);
-- Get file extension of export type
function Get_Extension (Value : String) return String;
private
-- Available drawing areas (export format)
type Available_Export is (PS);
end LSE.IO.Export_Factory;
|
stcarrez/ada-keystore | Ada | 13,597 | adb | -----------------------------------------------------------------------
-- keystore-marshallers -- Data marshaller for the keystore
-- Copyright (C) 2019, 2020 Stephane Carrez
-- Written by Stephane Carrez ([email protected])
--
-- Licensed under the Apache License, Version 2.0 (the "License");
-- you may not use this file except in compliance with the License.
-- You may obtain a copy of the License at
--
-- http://www.apache.org/licenses/LICENSE-2.0
--
-- Unless required by applicable law or agreed to in writing, software
-- distributed under the License is distributed on an "AS IS" BASIS,
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-- See the License for the specific language governing permissions and
-- limitations under the License.
-----------------------------------------------------------------------
with Interfaces.C;
with Ada.Calendar.Conversions;
with Util.Encoders.HMAC.SHA256;
with Util.Encoders.AES;
package body Keystore.Marshallers is
use Interfaces;
-- ------------------------------
-- Set the block header with the tag and wallet identifier.
-- ------------------------------
procedure Set_Header (Into : in out Marshaller;
Tag : in Interfaces.Unsigned_16;
Id : in Keystore.Wallet_Identifier) is
Buf : constant Buffers.Buffer_Accessor := Into.Buffer.Data.Value;
begin
Into.Pos := Block_Index'First + 1;
Buf.Data (Block_Index'First) := Stream_Element (Shift_Right (Tag, 8));
Buf.Data (Block_Index'First + 1) := Stream_Element (Tag and 16#0ff#);
Put_Unsigned_16 (Into, 0);
Put_Unsigned_32 (Into, Interfaces.Unsigned_32 (Id));
Put_Unsigned_32 (Into, 0);
Put_Unsigned_32 (Into, 0);
end Set_Header;
procedure Set_Header (Into : in out Marshaller;
Value : in Interfaces.Unsigned_32) is
Buf : constant Buffers.Buffer_Accessor := Into.Buffer.Data.Value;
begin
Buf.Data (Block_Index'First) := Stream_Element (Shift_Right (Value, 24));
Buf.Data (Block_Index'First + 1) := Stream_Element (Shift_Right (Value, 16) and 16#0ff#);
Buf.Data (Block_Index'First + 2) := Stream_Element (Shift_Right (Value, 8) and 16#0ff#);
Buf.Data (Block_Index'First + 3) := Stream_Element (Value and 16#0ff#);
Into.Pos := Block_Index'First + 3;
end Set_Header;
procedure Put_Unsigned_16 (Into : in out Marshaller;
Value : in Interfaces.Unsigned_16) is
Pos : constant Block_Index := Into.Pos;
Buf : constant Buffers.Buffer_Accessor := Into.Buffer.Data.Value;
begin
Into.Pos := Pos + 2;
Buf.Data (Pos + 1) := Stream_Element (Shift_Right (Value, 8));
Buf.Data (Pos + 2) := Stream_Element (Value and 16#0ff#);
end Put_Unsigned_16;
procedure Put_Unsigned_32 (Into : in out Marshaller;
Value : in Interfaces.Unsigned_32) is
Pos : constant Block_Index := Into.Pos;
Buf : constant Buffers.Buffer_Accessor := Into.Buffer.Data.Value;
begin
Into.Pos := Pos + 4;
Buf.Data (Pos + 1) := Stream_Element (Shift_Right (Value, 24));
Buf.Data (Pos + 2) := Stream_Element (Shift_Right (Value, 16) and 16#0ff#);
Buf.Data (Pos + 3) := Stream_Element (Shift_Right (Value, 8) and 16#0ff#);
Buf.Data (Pos + 4) := Stream_Element (Value and 16#0ff#);
end Put_Unsigned_32;
procedure Put_Unsigned_64 (Into : in out Marshaller;
Value : in Interfaces.Unsigned_64) is
begin
Put_Unsigned_32 (Into, Unsigned_32 (Shift_Right (Value, 32)));
Put_Unsigned_32 (Into, Unsigned_32 (Value and 16#0ffffffff#));
end Put_Unsigned_64;
procedure Put_Kind (Into : in out Marshaller;
Value : in Entry_Type) is
begin
case Value is
when T_INVALID =>
Put_Unsigned_16 (Into, 0);
when T_STRING =>
Put_Unsigned_16 (Into, 1);
when T_BINARY =>
Put_Unsigned_16 (Into, 2);
when T_WALLET =>
Put_Unsigned_16 (Into, 3);
when T_FILE =>
Put_Unsigned_16 (Into, 4);
when T_DIRECTORY =>
Put_Unsigned_16 (Into, 5);
end case;
end Put_Kind;
procedure Put_Block_Number (Into : in out Marshaller;
Value : in Block_Number) is
begin
Put_Unsigned_32 (Into, Interfaces.Unsigned_32 (Value));
end Put_Block_Number;
procedure Put_Block_Index (Into : in out Marshaller;
Value : in Block_Index) is
begin
Put_Unsigned_16 (Into, Interfaces.Unsigned_16 (Value));
end Put_Block_Index;
procedure Put_Buffer_Size (Into : in out Marshaller;
Value : in Buffer_Size) is
begin
Put_Unsigned_16 (Into, Interfaces.Unsigned_16 (Value));
end Put_Buffer_Size;
procedure Put_String (Into : in out Marshaller;
Value : in String) is
Pos : Block_Index;
Buf : constant Buffers.Buffer_Accessor := Into.Buffer.Data.Value;
begin
Put_Unsigned_16 (Into, Value'Length);
Pos := Into.Pos;
Into.Pos := Into.Pos + Value'Length;
for C of Value loop
Pos := Pos + 1;
Buf.Data (Pos) := Character'Pos (C);
end loop;
end Put_String;
procedure Put_Date (Into : in out Marshaller;
Value : in Ada.Calendar.Time) is
Unix_Time : Interfaces.C.long;
begin
Unix_Time := Ada.Calendar.Conversions.To_Unix_Time (Value);
Put_Unsigned_64 (Into, Unsigned_64 (Unix_Time));
end Put_Date;
procedure Put_Storage_Block (Into : in out Marshaller;
Value : in Buffers.Storage_Block) is
begin
Put_Unsigned_32 (Into, Interfaces.Unsigned_32 (Value.Storage));
Put_Unsigned_32 (Into, Interfaces.Unsigned_32 (Value.Block));
end Put_Storage_Block;
procedure Put_Secret (Into : in out Marshaller;
Value : in Secret_Key;
Protect_Key : in Secret_Key;
Protect_IV : in Secret_Key) is
Cipher_Key : Util.Encoders.AES.Encoder;
Last : Stream_Element_Offset;
Pos : constant Block_Index := Into.Pos + 1;
Buf : constant Buffers.Buffer_Accessor := Into.Buffer.Data.Value;
IV : constant Util.Encoders.AES.Word_Block_Type
:= (others => Interfaces.Unsigned_32 (Into.Buffer.Block.Block));
begin
Cipher_Key.Set_Key (Protect_Key, Util.Encoders.AES.CBC);
Cipher_Key.Set_IV (Protect_IV, IV);
Cipher_Key.Set_Padding (Util.Encoders.AES.NO_PADDING);
-- Encrypt the key into the key-slot using the protection key.
Last := Pos + Block_Index (Value.Length) - 1;
Cipher_Key.Encrypt_Secret (Secret => Value,
Into => Buf.Data (Pos .. Last));
Into.Pos := Last;
end Put_Secret;
procedure Put_HMAC_SHA256 (Into : in out Marshaller;
Key : in Secret_Key;
Content : in Ada.Streams.Stream_Element_Array) is
Pos : constant Block_Index := Into.Pos;
Buf : constant Buffers.Buffer_Accessor := Into.Buffer.Data.Value;
begin
Into.Pos := Into.Pos + SIZE_HMAC;
-- Make HMAC-SHA256 signature of the data content before encryption.
Util.Encoders.HMAC.SHA256.Sign (Key => Key,
Data => Content,
Result => Buf.Data (Pos + 1 .. Into.Pos));
end Put_HMAC_SHA256;
procedure Put_UUID (Into : in out Marshaller;
Value : in UUID_Type) is
begin
for I in Value'Range loop
Put_Unsigned_32 (Into, Value (I));
end loop;
end Put_UUID;
function Get_Header (From : in out Marshaller) return Interfaces.Unsigned_32 is
Buf : constant Buffers.Buffer_Accessor := From.Buffer.Data.Value;
begin
From.Pos := Block_Index'First + 3;
return Shift_Left (Unsigned_32 (Buf.Data (Block_Index'First)), 24) or
Shift_Left (Unsigned_32 (Buf.Data (Block_Index'First + 1)), 16) or
Shift_Left (Unsigned_32 (Buf.Data (Block_Index'First + 2)), 8) or
Unsigned_32 (Buf.Data (Block_Index'First + 3));
end Get_Header;
function Get_Header_16 (From : in out Marshaller) return Interfaces.Unsigned_16 is
Buf : constant Buffers.Buffer_Accessor := From.Buffer.Data.Value;
begin
From.Pos := Block_Index'First + 1;
return Shift_Left (Unsigned_16 (Buf.Data (Block_Index'First)), 8) or
Unsigned_16 (Buf.Data (Block_Index'First + 1));
end Get_Header_16;
function Get_Unsigned_16 (From : in out Marshaller) return Interfaces.Unsigned_16 is
Pos : constant Block_Index := From.Pos;
Buf : constant Buffers.Buffer_Accessor := From.Buffer.Data.Value;
begin
From.Pos := Pos + 2;
return Shift_Left (Unsigned_16 (Buf.Data (Pos + 1)), 8) or
Unsigned_16 (Buf.Data (Pos + 2));
end Get_Unsigned_16;
function Get_Unsigned_32 (From : in out Marshaller) return Interfaces.Unsigned_32 is
Pos : constant Block_Index := From.Pos;
Buf : constant Buffers.Buffer_Accessor := From.Buffer.Data.Value;
begin
From.Pos := Pos + 4;
return Shift_Left (Unsigned_32 (Buf.Data (Pos + 1)), 24) or
Shift_Left (Unsigned_32 (Buf.Data (Pos + 2)), 16) or
Shift_Left (Unsigned_32 (Buf.Data (Pos + 3)), 8) or
Unsigned_32 (Buf.Data (Pos + 4));
end Get_Unsigned_32;
function Get_Unsigned_64 (From : in out Marshaller) return Interfaces.Unsigned_64 is
High : constant Interfaces.Unsigned_32 := Get_Unsigned_32 (From);
Low : constant Interfaces.Unsigned_32 := Get_Unsigned_32 (From);
begin
return Shift_Left (Unsigned_64 (High), 32) or Unsigned_64 (Low);
end Get_Unsigned_64;
function Get_Storage_Block (From : in out Marshaller) return Buffers.Storage_Block is
Storage : constant Interfaces.Unsigned_32 := Get_Unsigned_32 (From);
Block : constant Interfaces.Unsigned_32 := Get_Unsigned_32 (From);
begin
return Buffers.Storage_Block '(Storage => Buffers.Storage_Identifier (Storage),
Block => Block_Number (Block));
end Get_Storage_Block;
procedure Get_String (From : in out Marshaller;
Result : in out String) is
Pos : Block_Index := From.Pos;
Buf : constant Buffers.Buffer_Accessor := From.Buffer.Data.Value;
begin
From.Pos := From.Pos + Block_Index (Result'Length);
for I in Result'Range loop
Pos := Pos + 1;
Result (I) := Character'Val (Buf.Data (Pos));
end loop;
end Get_String;
function Get_Date (From : in out Marshaller) return Ada.Calendar.Time is
Unix_Time : constant Unsigned_64 := Get_Unsigned_64 (From);
begin
return Ada.Calendar.Conversions.To_Ada_Time (Interfaces.C.long (Unix_Time));
end Get_Date;
function Get_Kind (From : in out Marshaller) return Entry_Type is
Value : constant Unsigned_16 := Get_Unsigned_16 (From);
begin
case Value is
when 0 =>
return T_INVALID;
when 1 =>
return T_STRING;
when 2 =>
return T_BINARY;
when 3 =>
return T_WALLET;
when 4 =>
return T_FILE;
when 5 =>
return T_DIRECTORY;
when others =>
return T_INVALID;
end case;
end Get_Kind;
procedure Get_Secret (From : in out Marshaller;
Secret : out Secret_Key;
Protect_Key : in Secret_Key;
Protect_IV : in Secret_Key) is
Decipher_Key : Util.Encoders.AES.Decoder;
Last : Stream_Element_Offset;
Pos : constant Block_Index := From.Pos + 1;
Buf : constant Buffers.Buffer_Accessor := From.Buffer.Data.Value;
IV : constant Util.Encoders.AES.Word_Block_Type
:= (others => Interfaces.Unsigned_32 (From.Buffer.Block.Block));
begin
Decipher_Key.Set_Key (Protect_Key, Util.Encoders.AES.CBC);
Decipher_Key.Set_IV (Protect_IV, IV);
Decipher_Key.Set_Padding (Util.Encoders.AES.NO_PADDING);
Last := Pos + Block_Index (Secret.Length) - 1;
Decipher_Key.Decrypt_Secret (Data => Buf.Data (Pos .. Last),
Secret => Secret);
From.Pos := Last;
end Get_Secret;
procedure Get_UUID (From : in out Marshaller;
UUID : out UUID_Type) is
begin
for I in UUID'Range loop
UUID (I) := Marshallers.Get_Unsigned_32 (From);
end loop;
end Get_UUID;
procedure Get_Data (From : in out Marshaller;
Size : in Ada.Streams.Stream_Element_Offset;
Data : out Ada.Streams.Stream_Element_Array;
Last : out Ada.Streams.Stream_Element_Offset) is
Buf : constant Buffers.Buffer_Accessor := From.Buffer.Data.Value;
Pos : constant Block_Index := From.Pos + 1;
begin
Last := Data'First + Size - 1;
Data (Data'First .. Last) := Buf.Data (Pos .. Pos + Size - 1);
From.Pos := Pos + Size - 1;
end Get_Data;
procedure Skip (From : in out Marshaller;
Count : in Block_Index) is
begin
From.Pos := From.Pos + Count;
end Skip;
end Keystore.Marshallers;
|
godunko/cga | Ada | 469 | ads | --
-- Copyright (C) 2023, Vadim Godunko <[email protected]>
--
-- SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
--
package CGK is
pragma Pure;
Construction_Error : exception;
-- Raised when construction can't be done.
Invalid_State_Error : exception;
-- Raised when object is not in valid state.
private
procedure Assert_Construction_Error (Value : Boolean);
procedure Assert_Invalid_State_Error (Valid : Boolean);
end CGK;
|
AdaCore/Ada_Drivers_Library | Ada | 791 | ads | -- This spec has been automatically generated from cm4.svd
pragma Restrictions (No_Elaboration_Code);
pragma Ada_2012;
pragma Style_Checks (Off);
with System;
package Cortex_M_SVD is
pragma Preelaborate;
--------------------
-- Base addresses --
--------------------
NVIC_Base : constant System.Address :=
System'To_Address (16#E000E100#);
SCB_Base : constant System.Address :=
System'To_Address (16#E000E000#);
SysTick_Base : constant System.Address :=
System'To_Address (16#E000E010#);
MPU_Base : constant System.Address :=
System'To_Address (16#E000ED90#);
Debug_Base : constant System.Address :=
System'To_Address (16#E000ED00#);
DWT_Base : constant System.Address :=
System'To_Address (16#E0001000#);
end Cortex_M_SVD;
|
tyudosen/HeterogeneousStack | Ada | 1,118 | ads | with Ada.Unchecked_Deallocation;
generic
type Item is tagged private; -- List Data Field
with function "="(ObjA: Item'Class; ObjB: Item'Class) return Boolean;
package hetro_stack is
type hetroStack is private;
type ItemPt is access all Item'Class;
type hetroStackElem is private;
type hetroStackElemPtr is access hetroStackElem;
procedure SetHeadNode(Stack: in out hetroStack);
procedure PushFront(Stack: in out hetroStack; Data: ItemPt);
procedure PushRear(Stack: in out hetroStack; Data: ItemPt);
function StackSize(Stack: hetroStack) return Integer;
function RemoveSpecificNode(Stack: in out hetroStack; Data: ItemPt) return ItemPt;
generic
with procedure PrintData(Data: Item'Class); -- Generic Print.
procedure PrintList(List: in hetroStack);
private
type hetroStackElem is record
Data: ItemPt;
LeftPtr: hetroStackElemPtr;
RightPtr: hetroStackElemPtr;
end record;
type hetroStack is record
Count: Integer := 0;
Top: hetroStackElemPtr := null;
end record;
end hetro_stack;
|
sf17k/sdlada | Ada | 5,651 | adb | --------------------------------------------------------------------------------------------------------------------
-- Copyright (c) 2014 Luke A. Guest
--
-- This software is provided 'as-is', without any express or implied
-- warranty. In no event will the authors be held liable for any damages
-- arising from the use of this software.
--
-- Permission is granted to anyone to use this software for any purpose,
-- including commercial applications, and to alter it and redistribute it
-- freely, subject to the following restrictions:
--
-- 1. The origin of this software must not be misrepresented; you must not
-- claim that you wrote the original software. If you use this software
-- in a product, an acknowledgment in the product documentation would be
-- appreciated but is not required.
--
-- 2. Altered source versions must be plainly marked as such, and must not be
-- misrepresented as being the original software.
--
-- 3. This notice may not be removed or altered from any source
-- distribution.
--------------------------------------------------------------------------------------------------------------------
with Interfaces.C;
with SDL.Error;
with System;
package body SDL.Inputs.Mice is
package C renames Interfaces.C;
use type C.int;
use type C.unsigned;
-- TODO: Re-enable this when the library links against 2.0.4!
-- function Capture (Enabled : in Boolean) return Supported is
-- function SDL_Capture_Mouse (Enabled : in C.unsigned) return C.int with
-- Import => True,
-- Convention => C,
-- External_Name => "SDL_CaptureMouse";
-- begin
-- if SDL_Capture_Mouse (if Enabled = True then 1 else 0) /= Success then
-- return No;
-- end if;
--
-- return Yes;
-- end Capture;
-- TODO: Re-enable this when the library links against 2.0.4!
-- function Get_Global_State (X_Relative, Y_Relative : out SDL.Events.Mice.Movement_Values) return
-- SDL.Events.Mice.Button_Masks is
--
-- function SDL_Get_Global_Mouse_State (X, Y : out C.int) return C.unsigned with
-- Import => True,
-- Convention => C,
-- External_Name => "SDL_GetGlobalMouseState";
--
-- X, Y : C.int;
-- Masks : C.unsigned := SDL_Get_Global_Mouse_State (X, Y);
--
-- use SDL.Events.Mice;
-- begin
-- X_Relative := Movement_Values (X);
-- Y_Relative := Movement_Values (Y);
--
-- return Button_Masks (Masks);
-- end Get_Global_State;
function Get_State (X_Relative, Y_Relative : out SDL.Events.Mice.Movement_Values) return
SDL.Events.Mice.Button_Masks is
function SDL_Get_Mouse_State (X, Y : out C.int) return C.unsigned with
Import => True,
Convention => C,
External_Name => "SDL_GetMouseState";
X, Y : C.int;
Masks : C.unsigned := SDL_Get_Mouse_State (X, Y);
use SDL.Events.Mice;
begin
X_Relative := Movement_Values (X);
Y_Relative := Movement_Values (Y);
return Button_Masks (Masks);
end Get_State;
function In_Relative_Mode return Boolean is
function SDL_Get_Relative_Mouse_Mode return SDL_Bool with
Import => True,
Convention => C,
External_Name => "SDL_GetRelativeMouseMode";
begin
if SDL_Get_Relative_Mouse_Mode = SDL_True then
return True;
end if;
return False;
end In_Relative_Mode;
function Get_Relative_State (X_Relative, Y_Relative : out SDL.Events.Mice.Movement_Values) return
SDL.Events.Mice.Button_Masks is
function SDL_Get_Relative_Mouse_State (X, Y : out C.int) return C.unsigned with
Import => True,
Convention => C,
External_Name => "SDL_GetRelativeMouseState";
X, Y : C.int;
Masks : C.unsigned := SDL_Get_Relative_Mouse_State (X, Y);
use SDL.Events.Mice;
begin
X_Relative := Movement_Values (X);
Y_Relative := Movement_Values (Y);
return Button_Masks (Masks);
end Get_Relative_State;
procedure Set_Relative_Mode (Enable : in Boolean) is
function SDL_Set_Relative_Mouse_Mode (Enable : in C.unsigned) return C.int with
Import => True,
Convention => C,
External_Name => "SDL_SetRelativeMouseMode";
begin
if SDL_Set_Relative_Mouse_Mode (if Enable = True then 1 else 0) /= Success then
raise Mice_Error with SDL.Error.Get;
end if;
end Set_Relative_Mode;
-- TODO: Re-enable this when the library links against 2.0.4!
-- procedure Warp (X, Y : in SDL.Events.Mice.Screen_Coordinates) is
-- procedure SDL_Warp_Mouse_Global (X, Y : in C.int) with
-- Import => True,
-- Convention => C,
-- External_Name => "SDL_WarpMouseGlobal";
-- begin
-- SDL_Warp_Mouse_Global (C.int (X), C.int (Y));
-- end Warp;
--
-- procedure Warp (Window : in SDL.Video.Windows.Window; X, Y : in SDL.Events.Mice.Window_Coordinates) is
-- function Get_Address (Self : in SDL.Video.Windows.Window) return System.Address with
-- Import => True,
-- Convention => Ada;
--
-- procedure SDL_Warp_Mouse_In_Window (Window : in System.Address; X, Y : in C.int) with
-- Import => True,
-- Convention => C,
-- External_Name => "SDL_WarpMouseInWindow";
-- begin
-- SDL_Warp_Mouse_In_Window (Get_Address (Window), C.int (X), C.int (Y));
-- end Warp;
end SDL.Inputs.Mice;
|
zhmu/ananas | Ada | 3,630 | adb | ------------------------------------------------------------------------------
-- --
-- GNAT RUN-TIME COMPONENTS --
-- --
-- ADA.STRINGS.TEXT_BUFFERS.UTILS --
-- --
-- B o d y --
-- --
-- Copyright (C) 2020-2022, Free Software Foundation, Inc. --
-- --
-- GNAT is free software; you can redistribute it and/or modify it under --
-- terms of the GNU General Public License as published by the Free Soft- --
-- ware Foundation; either version 3, or (at your option) any later ver- --
-- sion. GNAT is distributed in the hope that it will be useful, but WITH- --
-- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY --
-- or FITNESS FOR A PARTICULAR PURPOSE. --
-- --
-- As a special exception under Section 7 of GPL version 3, you are granted --
-- additional permissions described in the GCC Runtime Library Exception, --
-- version 3.1, as published by the Free Software Foundation. --
-- --
-- You should have received a copy of the GNU General Public License and --
-- a copy of the GCC Runtime Library Exception along with this program; --
-- see the files COPYING3 and COPYING.RUNTIME respectively. If not, see --
-- <http://www.gnu.org/licenses/>. --
-- --
-- GNAT was originally developed by the GNAT team at New York University. --
-- Extensive contributions were provided by Ada Core Technologies Inc. --
-- --
------------------------------------------------------------------------------
package body Ada.Strings.Text_Buffers.Utils is
procedure Put_7bit
(Buffer : in out Root_Buffer_Type'Class; Item : Character_7)
is
begin
Put (Buffer, [Item]);
end Put_7bit;
procedure Put_Character
(Buffer : in out Root_Buffer_Type'Class; Item : Character)
is
begin
Put (Buffer, [Item]);
end Put_Character;
procedure Put_Wide_Character
(Buffer : in out Root_Buffer_Type'Class; Item : Wide_Character)
is
begin
Wide_Put (Buffer, [Item]);
end Put_Wide_Character;
procedure Put_Wide_Wide_Character
(Buffer : in out Root_Buffer_Type'Class; Item : Wide_Wide_Character)
is
begin
Wide_Wide_Put (Buffer, [Item]);
end Put_Wide_Wide_Character;
procedure Put_UTF_8_Lines
(Buffer : in out Root_Buffer_Type'Class; Item : UTF_8_Lines)
is
begin
Put (Buffer, Item);
end Put_UTF_8_Lines;
function Column (Buffer : Root_Buffer_Type'Class) return Positive is
begin
return Buffer.UTF_8_Column;
end Column;
procedure Tab_To_Column
(Buffer : in out Root_Buffer_Type'Class; Column : Positive)
is
begin
Put (Buffer, String'(1 .. Column - Utils.Column (Buffer) => ' '));
end Tab_To_Column;
end Ada.Strings.Text_Buffers.Utils;
|
pchapin/augusta | Ada | 176 | adb |
procedure Type_Declare2 is
type T1 is range 1 .. 10;
type T2 is range 2 .. 1;
type T3 is range 1 .. 8#9#;
X1 : T1;
X2 : T2;
X3 : T3;
begin
null;
end;
|
pchapin/acrypto | Ada | 1,074 | ads | ---------------------------------------------------------------------------
-- FILE : aco-crypto-block_cipher-blowfish.ads
-- SUBJECT : Interface to Blowfish block cipher type.
-- AUTHOR : (C) Copyright 2010 by Peter Chapin
--
-- Please send comments or bug reports to
--
-- Peter Chapin <[email protected]>
---------------------------------------------------------------------------
private with ACO.Crypto.Algorithms.Blowfish;
package ACO.Crypto.Block_Cipher.Blowfish is
type Blowfish_Cipher is new Block_Cipher with private;
not overriding procedure Make(B : out Blowfish_Cipher; Key : in Octet_Array);
overriding function Block_Size(B : Blowfish_Cipher) return Natural;
overriding procedure Encrypt(B : in out Blowfish_Cipher; Block : in out Octet_Array);
overriding procedure Decrypt(B : in out Blowfish_Cipher; Block : in out Octet_Array);
private
type Blowfish_Cipher is new Block_Cipher with record
Processor : ACO.Crypto.Algorithms.Blowfish.Blowfish_Algorithm;
end record;
end ACO.Crypto.Block_Cipher.Blowfish;
|
strenkml/EE368 | Ada | 4,160 | adb |
with Ada.Unchecked_Deallocation;
with Device; use Device;
package body Benchmark is
procedure Set_Memory(benchmark : in out Benchmark_Type'Class;
mem : in Memory_Pointer) is
begin
benchmark.max_addr
:= (Address_Type(2) ** Get_Address_Bits) - 1;
benchmark.mem := mem;
end Set_Memory;
procedure Reset(benchmark : in out Benchmark_Type'Class;
context : in Natural) is
begin
Random.Reset(benchmark.generator, benchmark.seed);
Reset(benchmark.mem.all, context);
benchmark.data.all.Clear;
end Reset;
procedure Set_Argument(benchmark : in out Benchmark_Type;
arg : in String) is
value : constant String := Extract_Argument(arg);
begin
if Check_Argument(arg, "spacing") then
benchmark.spacing := Time_Type'Value(value);
elsif Check_Argument(arg, "seed") then
benchmark.seed := Integer'Value(value);
else
raise Invalid_Argument;
end if;
exception
when others =>
raise Invalid_Argument;
end Set_Argument;
function Check_Argument(arg : String;
name : String) return Boolean is
full_name : constant String := name & "=";
len : constant Natural := full_name'Length;
begin
if len < arg'Length then
return arg(arg'First .. arg'First + len - 1) = full_name;
else
return False;
end if;
end Check_Argument;
function Extract_Argument(arg : String) return String is
begin
for i in arg'First .. arg'Last loop
if arg(i) = '=' then
return arg(i + 1 .. arg'Last);
end if;
end loop;
return "";
end Extract_Argument;
function Get_Random(benchmark : Benchmark_Type'Class) return Natural is
begin
return Random.Random(benchmark.generator);
end Get_Random;
function Read_Value(benchmark : Benchmark_Type'Class;
address : Natural) return Integer is
begin
Read(benchmark, Address_Type(address * 4), 4);
Idle(benchmark, benchmark.spacing);
return benchmark.data.Element(address);
end Read_Value;
procedure Write_Value(benchmark : in Benchmark_Type'Class;
address : in Natural;
value : in Integer) is
begin
Write(benchmark, Address_Type(address * 4), 4);
Idle(benchmark, benchmark.spacing);
if Count_Type(address) >= benchmark.data.Length then
benchmark.data.Set_Length(Count_Type(address + 1));
end if;
benchmark.data.Replace_Element(address, value);
end Write_Value;
procedure Read(benchmark : in Benchmark_Type'Class;
address : in Address_Type;
size : in Positive) is
begin
if address + Address_Type(size) > benchmark.max_addr then
raise Invalid_Address;
end if;
Read(benchmark.mem.all, address, size);
end Read;
procedure Write(benchmark : in Benchmark_Type'Class;
address : in Address_Type;
size : in Positive) is
begin
if address + Address_Type(size) > benchmark.max_addr then
raise Invalid_Address;
end if;
Write(benchmark.mem.all, address, size);
end Write;
procedure Idle(benchmark : in Benchmark_Type'Class;
cycles : in Time_Type) is
begin
if cycles > 0 then
Idle(benchmark.mem.all, cycles);
end if;
end Idle;
procedure Free is
new Ada.Unchecked_Deallocation(Benchmark_Type'Class, Benchmark_Pointer);
procedure Free is
new Ada.Unchecked_Deallocation(Data_Vectors.Vector, Data_Pointer);
procedure Initialize(benchmark : in out Benchmark_Type) is
begin
benchmark.data := new Data_Vectors.Vector;
end Initialize;
procedure Finalize(benchmark : in out Benchmark_Type) is
begin
Free(benchmark.data);
end Finalize;
procedure Destroy(benchmark : in out Benchmark_Pointer) is
begin
Free(benchmark);
end Destroy;
end Benchmark;
|
reznikmm/matreshka | Ada | 4,763 | ads | ------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- XML Processor --
-- --
-- Runtime Library Component --
-- --
------------------------------------------------------------------------------
-- --
-- Copyright © 2012, Vadim Godunko <[email protected]> --
-- All rights reserved. --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions --
-- are met: --
-- --
-- * Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- --
-- * Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in the --
-- documentation and/or other materials provided with the distribution. --
-- --
-- * Neither the name of the Vadim Godunko, IE nor the names of its --
-- contributors may be used to endorse or promote products derived from --
-- this software without specific prior written permission. --
-- --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR --
-- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
-- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED --
-- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR --
-- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF --
-- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING --
-- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS --
-- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
-- --
------------------------------------------------------------------------------
-- $Revision$ $Date$
------------------------------------------------------------------------------
private with Ada.Finalization;
with XML.Schema.Objects;
private with Matreshka.XML_Schema.Object_Lists;
package XML.Schema.Object_Lists is
pragma Preelaborate;
type XS_Object_List is tagged private;
function Get_Length (Self : XS_Object_List'Class) return Natural;
-- The number of XSObjects in the XSObjectList.
-- The range of valid child object indices is 1 to Get_Length inclusive.
function Item
(Self : XS_Object_List'Class;
Index : Positive) return XML.Schema.Objects.XS_Object;
-- Returns the Index-th item in the collection or null if index is greater
-- than the number of objects in the list. The index starts at 1.
--
-- Parameters
--
-- index of type Positive - index into the collection.
--
-- Return Value
--
-- The XSObject at the indexth position in the XSObjectList, or null if the
-- index specified is not valid.
Empty_XS_Object_List : constant XS_Object_List;
private
type XS_Object_List is new Ada.Finalization.Controlled with record
Node : Matreshka.XML_Schema.Object_Lists.Object_List_Access;
end record;
overriding procedure Adjust (Self : in out XS_Object_List)
with Inline => True;
overriding procedure Finalize (Self : in out XS_Object_List);
Empty_XS_Object_List : constant XS_Object_List
:= (Ada.Finalization.Controlled with Node => null);
end XML.Schema.Object_Lists;
|
swagger-api/swagger-codegen | Ada | 711 | ads | -- Swagger Petstore
-- This is a sample server Petstore server. You can find out more about Swagger at [http://swagger.io](http://swagger.io) or on [irc.freenode.net, #swagger](http://swagger.io/irc/). For this sample, you can use the api key `special_key` to test the authorization filters.
-- ------------ EDIT NOTE ------------
-- This file was generated with swagger-codegen. You can modify it to implement
-- the server. After you modify this file, you should add the following line
-- to the .swagger-codegen-ignore file:
--
-- src/samples-petstore.ads
--
-- Then, you can drop this edit note comment.
-- ------------ EDIT NOTE ------------
package Samples.Petstore is
end Samples.Petstore;
|
usainzg/EHU | Ada | 1,690 | adb | WITH Ada.Text_IO;
USE Ada.Text_IO;
WITH Salas;
USE Salas;
PROCEDURE Probar_Salas IS
S : Sala;
BEGIN
S := Crear_Sala(" Ava ", 12,10);
Put_Line("El afaro de la sala es"& Integer'Image(Aforo_Sala(S)));
Put_Line("La sala tiene"&Integer'Image(Plazas_Libres(S))&" libres.");
Modificar_Pelicula(S, "BlackPanth");
Put_Line("La pelicula proyectada es "&La_Pelicula(S));
Mostrar_Sala(S);
Vender_Localidades_Contiguas(S,9);
Vender_Localidades_Contiguas(S,8);
Vender_Localidades_Contiguas(S,7);
Vender_Localidades_Contiguas(S,6);
Vender_Localidades_Contiguas(S,5);
Vender_Localidades_Contiguas(S,10);
Vender_Localidades_Contiguas(S,6);
Vender_Localidades_Contiguas(S,3);
Vender_Localidades_Contiguas(S,10);
Vender_Localidades_Contiguas(S,10);
Vender_Localidades_Contiguas(S,10);
Vender_Localidades_Contiguas(S,10);
Vender_Localidades_Contiguas(S,6);
Vender_Localidades_Contiguas(S,6);
Put_Line("La sala tiene"&Integer'Image(Plazas_Libres(S))&" libres.");
Mostrar_Sala(S);
Vender_Localidades_Contiguas(S,4);
Vender_Localidades_Contiguas(S,4);
Vender_Localidades_Contiguas(S,4);
Vender_Localidades_Contiguas(S,4);
Vender_Localidades_Contiguas(S,5);
Put_Line("La sala tiene"&Integer'Image(Plazas_Libres(S))&" libres.");
Mostrar_Sala(S);
Vender_Localidades_Contiguas(S,1);
Vender_Localidades_Contiguas(S,2);
Vender_Localidades_Contiguas(S,4);
Vender_Localidades_Contiguas(S,1);
Put_Line("La sala tiene"&Integer'Image(Plazas_Libres(S))&" libres.");
Mostrar_Sala(S);
Vender_Localidades_Contiguas(S,1);
Mostrar_Sala(S);
END Probar_Salas;
|
riccardo-bernardini/eugen | Ada | 1,743 | ads | with Ada.Strings.Unbounded; use Ada.Strings.Unbounded;
with Ada.Containers.Indefinite_Ordered_Maps;
with Ada.Containers.Vectors;
package Plugins is
type Dummy_Type is null record;
type No_Parameters is access Dummy_Type;
-- This type is handy for those plugins that require no parameters.
package Parameter_Maps is new
Ada.Containers.Indefinite_Ordered_Maps (Key_Type => String,
Element_Type => String);
subtype Parameter_Map is Parameter_Maps.Map;
type Parameter_Map_Access is access Parameter_Maps.Map;
-- Another very common case of plugin parameters: a map
-- parameter name --> parameter value. The parameters have no special
-- order and every name has at most one value
Empty_Map : constant Parameter_Map_Access := new Parameter_Maps.Map'(Parameter_Maps.Empty_Map);
type Parameter_Pair is
record
Name : Unbounded_String;
Value : Unbounded_String;
end record;
function "<" (L, R : Parameter_Pair) return Boolean
is (L.Name < R.Name or else (L.Name = R.Name and L.Value < R.Value));
package Parameter_Lists is new
Ada.Containers.Vectors (Index_Type => Positive,
Element_Type => Parameter_Pair);
package Parameter_List_Sorting is
new Parameter_Lists.Generic_Sorting;
type Parameter_List is access Parameter_Lists.Vector;
-- A third common case: a sequence of pairs (name, value). Note
-- that in this case there is an ordering and that every name can have
-- more than one value. A Parameter_List can be sorted according to
-- the parameter name by using the subroutines in Parameter_List_Sorting.
end Plugins;
|
AdaCore/training_material | Ada | 400 | ads | --Messages
package Messages is
type Message_T is private;
procedure Set_Content
(Message : in out Message_T;
Value : Integer);
function Content
(Message : Message_T)
return Integer;
function Image
(Message : Message_T)
return String;
private
-- Replace "null record" with your message content
type Message_T is null record;
end Messages;
|
reznikmm/matreshka | Ada | 9,644 | 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 League.Strings.Internals;
with Matreshka.Internals.Strings;
with AMF.Internals.Tables.UML_Attributes;
package body AMF.Internals.UML_Named_Elements is
--------------------
-- All_Namespaces --
--------------------
overriding function All_Namespaces
(Self : not null access constant UML_Named_Element_Proxy)
return AMF.UML.Namespaces.Collections.Ordered_Set_Of_UML_Namespace
is
-- [UML 2.4.1] 7.3.34 NamedElement (from Kernel, Dependencies)
--
-- [1] The query allNamespaces() gives the sequence of namespaces in
-- which the NamedElement is nested, working outwards.
--
-- NamedElement::allNamespaces(): Sequence(Namespace);
--
-- allNamespaces =
-- if self.namespace->isEmpty()
-- then Sequence{}
-- else self.namespace.allNamespaces()->prepend(self.namespace)
-- endif
use type AMF.UML.Namespaces.UML_Namespace_Access;
The_Namespace : AMF.UML.Namespaces.UML_Namespace_Access
:= UML_Named_Element_Proxy'Class (Self.all).Get_Namespace;
begin
return Result :
AMF.UML.Namespaces.Collections.Ordered_Set_Of_UML_Namespace
do
while The_Namespace /= null loop
Result.Add (The_Namespace);
The_Namespace := The_Namespace.Get_Namespace;
end loop;
end return;
end All_Namespaces;
--------------
-- Get_Name --
--------------
overriding function Get_Name
(Self : not null access constant UML_Named_Element_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_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_Name;
--------------------
-- Get_Visibility --
--------------------
overriding function Get_Visibility
(Self : not null access constant UML_Named_Element_Proxy)
return AMF.UML.Optional_UML_Visibility_Kind is
begin
return
AMF.Internals.Tables.UML_Attributes.Internal_Get_Visibility
(Self.Element);
end Get_Visibility;
--------------------
-- Qualified_Name --
--------------------
overriding function Qualified_Name
(Self : not null access constant UML_Named_Element_Proxy)
return League.Strings.Universal_String
is
-- [UML 2.4.1] 7.3.34 NamedElement (from Kernel, Dependencies)
--
-- Constraints
-- [1] If there is no name, or one of the containing namespaces has no
-- name, there is no qualified name.
--
-- (self.name->isEmpty()
-- or self.allNamespaces()->select
-- (ns | ns.name->isEmpty())->notEmpty())
-- implies self.qualifiedName->isEmpty()
--
-- [2] When there is a name, and all of the containing namespaces have a
-- name, the qualified name is constructed from the names of the
-- containing namespaces.
--
-- (self.name->notEmpty()
-- and self.allNamespaces()->select
-- (ns | ns.name->isEmpty())->isEmpty())
-- implies
-- self.qualifiedName =
-- self.allNamespaces()->iterate
-- ( ns : Namespace; result: String = self.name |
-- ns.name->union(self.separator())->union(result))
Namespaces : constant
AMF.UML.Namespaces.Collections.Ordered_Set_Of_UML_Namespace
:= UML_Named_Element_Proxy'Class (Self.all).All_Namespaces;
Separator : constant League.Strings.Universal_String
:= UML_Named_Element_Proxy'Class (Self.all).Separator;
Name : AMF.Optional_String
:= UML_Named_Element_Proxy'Class (Self.all).Get_Name;
begin
if Name.Is_Empty then
return League.Strings.Empty_Universal_String;
end if;
return Result : League.Strings.Universal_String := Name.Value do
for J in 1 .. Namespaces.Length loop
Name := Namespaces.Element (J).Get_Name;
if Name.Is_Empty then
-- When name of one of owning namespaces is empty the qualified
-- name is empty also. Clear result and exit from namespaces
-- loop.
Result.Clear;
exit;
else
-- Otherwise prepend separator and name of the namespace.
Result.Prepend (Separator);
Result.Prepend (Name.Value);
end if;
end loop;
end return;
end Qualified_Name;
---------------
-- Separator --
---------------
overriding function Separator
(Self : not null access constant UML_Named_Element_Proxy)
return League.Strings.Universal_String
is
pragma Unreferenced (Self);
-- [UML241] 7.3.34 NamedElement (from Kernel, Dependencies)
--
-- The query separator() gives the string that is used to separate names
-- when constructing a qualified name.
--
-- NamedElement::separator(): String;
-- separator = ‘::’
begin
return League.Strings.To_Universal_String ("::");
end Separator;
--------------
-- Set_Name --
--------------
overriding procedure Set_Name
(Self : not null access UML_Named_Element_Proxy;
To : AMF.Optional_String) is
begin
if To.Is_Empty then
AMF.Internals.Tables.UML_Attributes.Internal_Set_Name
(Self.Element, null);
else
AMF.Internals.Tables.UML_Attributes.Internal_Set_Name
(Self.Element, League.Strings.Internals.Internal (To.Value));
end if;
end Set_Name;
--------------------
-- Set_Visibility --
--------------------
overriding procedure Set_Visibility
(Self : not null access UML_Named_Element_Proxy;
To : AMF.UML.Optional_UML_Visibility_Kind) is
begin
AMF.Internals.Tables.UML_Attributes.Internal_Set_Visibility
(Self.Element, To);
end Set_Visibility;
end AMF.Internals.UML_Named_Elements;
|
PeterYHChen/nyu-pl-assignments | Ada | 1,402 | adb | with Text_Io; -- always need these two lines for printing
use Text_Io;
with Ada.Float_Text_IO;
use Ada.Float_Text_IO;
package body Adaptive_Quad is
function SimpsonsRule(a, b:float) return float is
c, h3:float;
begin
c := (a+b) / 2.0;
h3 := abs(b-a) / 6.0;
return h3*(f(a) + 4.0*f(c) + f(b));
end SimpsonsRule;
function RecAQuad(a, b, eps, whole:float) return float is
c, left, right:float;
result1, result2:float;
procedure Rec is
task recurTask1;
task recurTask2;
task body recurTask1 is
begin
result1 := RecAQuad(a, c, eps/2.0, left);
end recurTask1;
task body recurTask2 is
begin
result2 := RecAQuad(c, b, eps/2.0, right);
end recurTask2;
begin -- Rec
null;
end Rec;
begin
c := (a+b) / 2.0;
left := SimpsonsRule(a,c);
right := SimpsonsRule(c,b);
if (abs(left + right - whole) <= 15.0*eps) then
return left + right + (left + right - whole)/15.0;
else
Rec;
end if;
return result1 + result2;
end RecAQuad;
function AQuad(a, b, eps:float) return float is
begin
return RecAQuad(a, b, eps, SimpsonsRule(a,b));
end AQuad;
end Adaptive_Quad; |
docandrew/troodon | Ada | 952 | ads | with Freetype;
package Render.Fonts is
FONT_SIZE : constant := 14;
-- We reuse this object to store the current character glyph
face : Freetype.FT_Face;
emojiFace : Freetype.FT_Face;
--glyph : Freetype.FT_GlyphSlot;
function loadGlyph (c : Character; fontFace : Freetype.FT_Face) return Boolean;
function loadGlyph (c : Wide_Wide_Character; fontFace : Freetype.FT_Face) return Boolean;
---------------------------------------------------------------------------
-- start
-- Initialize Freetype and Fontconfig libraries
---------------------------------------------------------------------------
procedure start;
---------------------------------------------------------------------------
-- stop
-- Perform clean up of Freetype and Fontconfig libraries
---------------------------------------------------------------------------
procedure stop;
end Render.Fonts; |
reznikmm/matreshka | Ada | 4,751 | adb | ------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- Open Document Toolkit --
-- --
-- Runtime Library Component --
-- --
------------------------------------------------------------------------------
-- --
-- Copyright © 2014, Vadim Godunko <[email protected]> --
-- All rights reserved. --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions --
-- are met: --
-- --
-- * Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- --
-- * Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in the --
-- documentation and/or other materials provided with the distribution. --
-- --
-- * Neither the name of the Vadim Godunko, IE nor the names of its --
-- contributors may be used to endorse or promote products derived from --
-- this software without specific prior written permission. --
-- --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR --
-- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
-- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED --
-- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR --
-- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF --
-- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING --
-- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS --
-- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
-- --
------------------------------------------------------------------------------
-- $Revision$ $Date$
------------------------------------------------------------------------------
with Matreshka.DOM_Documents;
with Matreshka.ODF_String_Constants;
with ODF.DOM.Iterators;
with ODF.DOM.Visitors;
package body Matreshka.ODF_Draw.Extrusion_Second_Light_Level_Attributes is
------------
-- Create --
------------
overriding function Create
(Parameters : not null access Matreshka.DOM_Attributes.Attribute_L2_Parameters)
return Draw_Extrusion_Second_Light_Level_Attribute_Node is
begin
return Self : Draw_Extrusion_Second_Light_Level_Attribute_Node do
Matreshka.ODF_Draw.Constructors.Initialize
(Self'Unchecked_Access,
Parameters.Document,
Matreshka.ODF_String_Constants.Draw_Prefix);
end return;
end Create;
--------------------
-- Get_Local_Name --
--------------------
overriding function Get_Local_Name
(Self : not null access constant Draw_Extrusion_Second_Light_Level_Attribute_Node)
return League.Strings.Universal_String
is
pragma Unreferenced (Self);
begin
return Matreshka.ODF_String_Constants.Extrusion_Second_Light_Level_Attribute;
end Get_Local_Name;
begin
Matreshka.DOM_Documents.Register_Attribute
(Matreshka.ODF_String_Constants.Draw_URI,
Matreshka.ODF_String_Constants.Extrusion_Second_Light_Level_Attribute,
Draw_Extrusion_Second_Light_Level_Attribute_Node'Tag);
end Matreshka.ODF_Draw.Extrusion_Second_Light_Level_Attributes;
|
iptime-gpl/userapps_a3004nd | Ada | 12,516 | ads | ------------------------------------------------------------------------------
-- ZLib for Ada thick binding. --
-- --
-- Copyright (C) 2002-2003 Dmitriy Anisimkov --
-- --
-- This library is free software; you can redistribute it and/or modify --
-- it under the terms of the GNU General Public License as published by --
-- the Free Software Foundation; either version 2 of the License, or (at --
-- your option) any later version. --
-- --
-- This library is distributed in the hope that it will be useful, but --
-- WITHOUT ANY WARRANTY; without even the implied warranty of --
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU --
-- General Public License for more details. --
-- --
-- You should have received a copy of the GNU General Public License --
-- along with this library; if not, write to the Free Software Foundation, --
-- Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. --
-- --
-- As a special exception, if other files instantiate generics from this --
-- unit, or you link this unit with other files to produce an executable, --
-- this unit does not by itself cause the resulting executable to be --
-- covered by the GNU General Public License. This exception does not --
-- however invalidate any other reasons why the executable file might be --
-- covered by the GNU Public License. --
------------------------------------------------------------------------------
-- $Id: zlib.ads,v 1.1.1.1 2011/09/27 08:56:37 mvnas Exp $
with Ada.Streams;
with Interfaces;
package ZLib is
ZLib_Error : exception;
type Compression_Level is new Integer range -1 .. 9;
type Flush_Mode is private;
type Compression_Method is private;
type Window_Bits_Type is new Integer range 8 .. 15;
type Memory_Level_Type is new Integer range 1 .. 9;
type Unsigned_32 is new Interfaces.Unsigned_32;
type Strategy_Type is private;
type Header_Type is (None, Auto, Default, GZip);
-- Header type usage have a some limitation for inflate.
-- See comment for Inflate_Init.
subtype Count is Ada.Streams.Stream_Element_Count;
----------------------------------
-- Compression method constants --
----------------------------------
Deflated : constant Compression_Method;
-- Only one method allowed in this ZLib version.
---------------------------------
-- Compression level constants --
---------------------------------
No_Compression : constant Compression_Level := 0;
Best_Speed : constant Compression_Level := 1;
Best_Compression : constant Compression_Level := 9;
Default_Compression : constant Compression_Level := -1;
--------------------------
-- Flush mode constants --
--------------------------
No_Flush : constant Flush_Mode;
-- Regular way for compression, no flush
Partial_Flush : constant Flush_Mode;
-- will be removed, use Z_SYNC_FLUSH instead
Sync_Flush : constant Flush_Mode;
-- all pending output is flushed to the output buffer and the output
-- is aligned on a byte boundary, so that the decompressor can get all
-- input data available so far. (In particular avail_in is zero after the
-- call if enough output space has been provided before the call.)
-- Flushing may degrade compression for some compression algorithms and so
-- it should be used only when necessary.
Full_Flush : constant Flush_Mode;
-- all output is flushed as with SYNC_FLUSH, and the compression state
-- is reset so that decompression can restart from this point if previous
-- compressed data has been damaged or if random access is desired. Using
-- FULL_FLUSH too often can seriously degrade the compression.
Finish : constant Flush_Mode;
-- Just for tell the compressor that input data is complete.
------------------------------------
-- Compression strategy constants --
------------------------------------
-- RLE stategy could be used only in version 1.2.0 and later.
Filtered : constant Strategy_Type;
Huffman_Only : constant Strategy_Type;
RLE : constant Strategy_Type;
Default_Strategy : constant Strategy_Type;
Default_Buffer_Size : constant := 4096;
type Filter_Type is limited private;
-- The filter is for compression and for decompression.
-- The usage of the type is depend of its initialization.
function Version return String;
pragma Inline (Version);
-- Return string representation of the ZLib version.
procedure Deflate_Init
(Filter : in out Filter_Type;
Level : in Compression_Level := Default_Compression;
Strategy : in Strategy_Type := Default_Strategy;
Method : in Compression_Method := Deflated;
Window_Bits : in Window_Bits_Type := 15;
Memory_Level : in Memory_Level_Type := 8;
Header : in Header_Type := Default);
-- Compressor initialization.
-- When Header parameter is Auto or Default, then default zlib header
-- would be provided for compressed data.
-- When Header is GZip, then gzip header would be set instead of
-- default header.
-- When Header is None, no header would be set for compressed data.
procedure Inflate_Init
(Filter : in out Filter_Type;
Window_Bits : in Window_Bits_Type := 15;
Header : in Header_Type := Default);
-- Decompressor initialization.
-- Default header type mean that ZLib default header is expecting in the
-- input compressed stream.
-- Header type None mean that no header is expecting in the input stream.
-- GZip header type mean that GZip header is expecting in the
-- input compressed stream.
-- Auto header type mean that header type (GZip or Native) would be
-- detected automatically in the input stream.
-- Note that header types parameter values None, GZip and Auto is
-- supporting for inflate routine only in ZLib versions 1.2.0.2 and later.
-- Deflate_Init is supporting all header types.
procedure Close
(Filter : in out Filter_Type;
Ignore_Error : in Boolean := False);
-- Closing the compression or decompressor.
-- If stream is closing before the complete and Ignore_Error is False,
-- The exception would be raised.
generic
with procedure Data_In
(Item : out Ada.Streams.Stream_Element_Array;
Last : out Ada.Streams.Stream_Element_Offset);
with procedure Data_Out
(Item : in Ada.Streams.Stream_Element_Array);
procedure Generic_Translate
(Filter : in out Filter_Type;
In_Buffer_Size : in Integer := Default_Buffer_Size;
Out_Buffer_Size : in Integer := Default_Buffer_Size);
-- Compressing/decompressing data arrived from Data_In routine
-- to the Data_Out routine. User should provide Data_In and Data_Out
-- for compression/decompression data flow.
-- Compression or decompression depend on initialization of Filter.
function Total_In (Filter : in Filter_Type) return Count;
pragma Inline (Total_In);
-- Return total number of input bytes read so far.
function Total_Out (Filter : in Filter_Type) return Count;
pragma Inline (Total_Out);
-- Return total number of bytes output so far.
function CRC32
(CRC : in Unsigned_32;
Data : in Ada.Streams.Stream_Element_Array)
return Unsigned_32;
pragma Inline (CRC32);
-- Calculate CRC32, it could be necessary for make gzip format.
procedure CRC32
(CRC : in out Unsigned_32;
Data : in Ada.Streams.Stream_Element_Array);
pragma Inline (CRC32);
-- Calculate CRC32, it could be necessary for make gzip format.
-------------------------------------------------
-- Below is more complex low level routines. --
-------------------------------------------------
procedure Translate
(Filter : in out Filter_Type;
In_Data : in Ada.Streams.Stream_Element_Array;
In_Last : out Ada.Streams.Stream_Element_Offset;
Out_Data : out Ada.Streams.Stream_Element_Array;
Out_Last : out Ada.Streams.Stream_Element_Offset;
Flush : in Flush_Mode);
-- Compressing/decompressing the datas from In_Data buffer to the
-- Out_Data buffer.
-- In_Data is incoming data portion,
-- In_Last is the index of last element from In_Data accepted by the
-- Filter.
-- Out_Data is the buffer for output data from the filter.
-- Out_Last is the last element of the received data from Filter.
-- To tell the filter that incoming data is complete put the
-- Flush parameter to FINISH.
function Stream_End (Filter : in Filter_Type) return Boolean;
pragma Inline (Stream_End);
-- Return the true when the stream is complete.
procedure Flush
(Filter : in out Filter_Type;
Out_Data : out Ada.Streams.Stream_Element_Array;
Out_Last : out Ada.Streams.Stream_Element_Offset;
Flush : in Flush_Mode);
pragma Inline (Flush);
-- Flushing the data from the compressor.
generic
with procedure Write
(Item : in Ada.Streams.Stream_Element_Array);
-- User should provide this routine for accept
-- compressed/decompressed data.
Buffer_Size : in Ada.Streams.Stream_Element_Offset
:= Default_Buffer_Size;
-- Buffer size for Write user routine.
procedure Write
(Filter : in out Filter_Type;
Item : in Ada.Streams.Stream_Element_Array;
Flush : in Flush_Mode);
-- Compressing/Decompressing data from Item to the
-- generic parameter procedure Write.
-- Output buffer size could be set in Buffer_Size generic parameter.
generic
with procedure Read
(Item : out Ada.Streams.Stream_Element_Array;
Last : out Ada.Streams.Stream_Element_Offset);
-- User should provide data for compression/decompression
-- thru this routine.
Buffer : in out Ada.Streams.Stream_Element_Array;
-- Buffer for keep remaining data from the previous
-- back read.
Rest_First, Rest_Last : in out Ada.Streams.Stream_Element_Offset;
-- Rest_First have to be initialized to Buffer'Last + 1
-- before usage.
procedure Read
(Filter : in out Filter_Type;
Item : out Ada.Streams.Stream_Element_Array;
Last : out Ada.Streams.Stream_Element_Offset);
-- Compressing/Decompressing data from generic parameter
-- procedure Read to the Item.
-- User should provide Buffer for the operation
-- and Rest_First variable first time initialized to the Buffer'Last + 1.
private
use Ada.Streams;
type Flush_Mode is new Integer range 0 .. 4;
type Compression_Method is new Integer range 8 .. 8;
type Strategy_Type is new Integer range 0 .. 3;
No_Flush : constant Flush_Mode := 0;
Sync_Flush : constant Flush_Mode := 2;
Full_Flush : constant Flush_Mode := 3;
Finish : constant Flush_Mode := 4;
Partial_Flush : constant Flush_Mode := 1;
-- will be removed, use Z_SYNC_FLUSH instead
Filtered : constant Strategy_Type := 1;
Huffman_Only : constant Strategy_Type := 2;
RLE : constant Strategy_Type := 3;
Default_Strategy : constant Strategy_Type := 0;
Deflated : constant Compression_Method := 8;
type Z_Stream;
type Z_Stream_Access is access all Z_Stream;
type Filter_Type is record
Strm : Z_Stream_Access;
Compression : Boolean;
Stream_End : Boolean;
Header : Header_Type;
CRC : Unsigned_32;
Offset : Stream_Element_Offset;
-- Offset for gzip header/footer output.
Opened : Boolean := False;
end record;
end ZLib;
|
reznikmm/matreshka | Ada | 4,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.Visitors;
with ODF.DOM.Table_Desc_Elements;
package Matreshka.ODF_Table.Desc_Elements is
type Table_Desc_Element_Node is
new Matreshka.ODF_Table.Abstract_Table_Element_Node
and ODF.DOM.Table_Desc_Elements.ODF_Table_Desc
with null record;
overriding function Create
(Parameters : not null access Matreshka.DOM_Elements.Element_L2_Parameters)
return Table_Desc_Element_Node;
overriding function Get_Local_Name
(Self : not null access constant Table_Desc_Element_Node)
return League.Strings.Universal_String;
overriding procedure Enter_Node
(Self : not null access Table_Desc_Element_Node;
Visitor : in out XML.DOM.Visitors.Abstract_Visitor'Class;
Control : in out XML.DOM.Visitors.Traverse_Control);
overriding procedure Leave_Node
(Self : not null access Table_Desc_Element_Node;
Visitor : in out XML.DOM.Visitors.Abstract_Visitor'Class;
Control : in out XML.DOM.Visitors.Traverse_Control);
overriding procedure Visit_Node
(Self : not null access Table_Desc_Element_Node;
Iterator : in out XML.DOM.Visitors.Abstract_Iterator'Class;
Visitor : in out XML.DOM.Visitors.Abstract_Visitor'Class;
Control : in out XML.DOM.Visitors.Traverse_Control);
end Matreshka.ODF_Table.Desc_Elements;
|
Subsets and Splits
No saved queries yet
Save your SQL queries to embed, download, and access them later. Queries will appear here once saved.