repo_name
stringlengths 9
74
| language
stringclasses 1
value | length_bytes
int64 11
9.34M
| extension
stringclasses 2
values | content
stringlengths 11
9.34M
|
---|---|---|---|---|
charlie5/cBound | Ada | 1,914 | ads | -- This file is generated by SWIG. Please do not modify by hand.
--
with Interfaces;
with Interfaces.C;
with Interfaces.C.Pointers;
package xcb.xcb_grab_button_request_t is
-- Item
--
type Item is record
major_opcode : aliased Interfaces.Unsigned_8;
owner_events : aliased Interfaces.Unsigned_8;
length : aliased Interfaces.Unsigned_16;
grab_window : aliased xcb.xcb_window_t;
event_mask : aliased Interfaces.Unsigned_16;
pointer_mode : aliased Interfaces.Unsigned_8;
keyboard_mode : aliased Interfaces.Unsigned_8;
confine_to : aliased xcb.xcb_window_t;
cursor : aliased xcb.xcb_cursor_t;
button : aliased Interfaces.Unsigned_8;
pad0 : aliased Interfaces.Unsigned_8;
modifiers : aliased Interfaces.Unsigned_16;
end record;
-- Item_Array
--
type Item_Array is
array
(Interfaces.C.size_t range <>) of aliased xcb.xcb_grab_button_request_t
.Item;
-- Pointer
--
package C_Pointers is new Interfaces.C.Pointers
(Index => Interfaces.C.size_t,
Element => xcb.xcb_grab_button_request_t.Item,
Element_Array => xcb.xcb_grab_button_request_t.Item_Array,
Default_Terminator => (others => <>));
subtype Pointer is C_Pointers.Pointer;
-- Pointer_Array
--
type Pointer_Array is
array
(Interfaces.C.size_t range <>) of aliased xcb.xcb_grab_button_request_t
.Pointer;
-- Pointer_Pointer
--
package C_Pointer_Pointers is new Interfaces.C.Pointers
(Index => Interfaces.C.size_t,
Element => xcb.xcb_grab_button_request_t.Pointer,
Element_Array => xcb.xcb_grab_button_request_t.Pointer_Array,
Default_Terminator => null);
subtype Pointer_Pointer is C_Pointer_Pointers.Pointer;
end xcb.xcb_grab_button_request_t;
|
optikos/oasis | Ada | 1,654 | ads | -- Copyright (c) 2019 Maxim Reznik <[email protected]>
--
-- SPDX-License-Identifier: MIT
-- License-Filename: LICENSE
-------------------------------------------------------------
with Program.Elements.Type_Definitions;
with Program.Lexical_Elements;
with Program.Elements.Expressions;
with Program.Elements.Real_Range_Specifications;
package Program.Elements.Ordinary_Fixed_Point_Types is
pragma Pure (Program.Elements.Ordinary_Fixed_Point_Types);
type Ordinary_Fixed_Point_Type is
limited interface and Program.Elements.Type_Definitions.Type_Definition;
type Ordinary_Fixed_Point_Type_Access is
access all Ordinary_Fixed_Point_Type'Class with Storage_Size => 0;
not overriding function Delta_Expression
(Self : Ordinary_Fixed_Point_Type)
return not null Program.Elements.Expressions.Expression_Access
is abstract;
not overriding function Real_Range
(Self : Ordinary_Fixed_Point_Type)
return not null Program.Elements.Real_Range_Specifications
.Real_Range_Specification_Access is abstract;
type Ordinary_Fixed_Point_Type_Text is limited interface;
type Ordinary_Fixed_Point_Type_Text_Access is
access all Ordinary_Fixed_Point_Type_Text'Class with Storage_Size => 0;
not overriding function To_Ordinary_Fixed_Point_Type_Text
(Self : aliased in out Ordinary_Fixed_Point_Type)
return Ordinary_Fixed_Point_Type_Text_Access is abstract;
not overriding function Delta_Token
(Self : Ordinary_Fixed_Point_Type_Text)
return not null Program.Lexical_Elements.Lexical_Element_Access
is abstract;
end Program.Elements.Ordinary_Fixed_Point_Types;
|
mfkiwl/ewok-kernel-security-OS | Ada | 3,199 | ads | --
-- Copyright 2018 The wookey project team <[email protected]>
-- - Ryad Benadjila
-- - Arnauld Michelizza
-- - Mathieu Renard
-- - Philippe Thierry
-- - Philippe Trebuchet
--
-- Licensed under the Apache License, Version 2.0 (the "License");
-- you may not use this file except in compliance with the License.
-- You may obtain a copy of the License at
--
-- http://www.apache.org/licenses/LICENSE-2.0
--
-- Unless required by applicable law or agreed to in writing, software
-- distributed under the License is distributed on an "AS IS" BASIS,
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-- See the License for the specific language governing permissions and
-- limitations under the License.
--
--
with config.applications; use config.applications;
with ewok.perm_auto;
with ewok.tasks_shared; use ewoK.tasks_shared;
package ewok.perm
with spark_mode => on
is
---------------
-- Types --
---------------
type t_perm_name is
(PERM_RES_DEV_DMA,
PERM_RES_DEV_CRYPTO_USR,
PERM_RES_DEV_CRYPTO_CFG,
PERM_RES_DEV_CRYPTO_FULL,
PERM_RES_DEV_BUSES,
PERM_RES_DEV_EXTI,
PERM_RES_DEV_TIM,
PERM_RES_TIM_GETMILLI,
PERM_RES_TIM_GETMICRO,
PERM_RES_TIM_GETCYCLE,
PERM_RES_TSK_FISR,
PERM_RES_TSK_FIPC,
PERM_RES_TSK_RESET,
PERM_RES_TSK_UPGRADE,
PERM_RES_TSK_RNG,
PERM_RES_MEM_DYNAMIC_MAP);
---------------
-- Functions --
---------------
pragma assertion_policy (pre => IGNORE, post => IGNORE, assert => IGNORE);
-- Test if a task is allowed to share a DMA SHM with another task
function dmashm_is_granted
(from : in t_real_task_id;
to : in t_real_task_id)
return boolean
with
Global => null, -- com_dmashm_perm is a constant, not a variable
Post => (if (from = to) then dmashm_is_granted'Result = false),
Contract_Cases => (ewok.perm_auto.com_dmashm_perm(from,to) => dmashm_is_granted'Result,
others => not dmashm_is_granted'Result);
-- Test if a task is allowed to send an IPC to another task
function ipc_is_granted
(from : in t_real_task_id;
to : in t_real_task_id)
return boolean
with
Global => null, -- com_ipc_perm is a constant, not a variable
Post => (if (from = to) then ipc_is_granted'Result = false),
Contract_Cases => (ewok.perm_auto.com_ipc_perm(from,to) => ipc_is_granted'Result,
others => not ipc_is_granted'Result);
#if CONFIG_KERNEL_DOMAIN
function is_same_domain
(from : in t_real_task_id;
to : in t_real_task_id)
return boolean
with
Global => null,
Post => (if (from = to) then is_same_domain'Result = false);
#end if;
-- Test if a task is allowed to use a resource
function ressource_is_granted
(perm_name : in t_perm_name;
task_id : in config.applications.t_real_task_id)
return boolean
with Global => null;
end ewok.perm;
|
bracke/Meaning | Ada | 1,300 | ads | with Ada.Strings.Unbounded; use Ada.Strings.Unbounded;
with AcronymList; use AcronymList;
with RASCAL.WimpTask; use RASCAL.WimpTask;
with RASCAL.Utility; use RASCAL.Utility;
with RASCAL.Variable; use RASCAL.Variable;
with RASCAL.OS; use RASCAL.OS;
package Main is
--
Main_Task : ToolBox_Task_Class;
main_objectid : Object_ID := -1;
main_winid : Wimp_Handle_Type := -1;
Data_Menu_Entries : natural := 0;
x_pos : Integer := -1;
y_pos : Integer := -1;
-- Constants
Not_Found_Message : UString;
app_name : constant String := "Meaning";
Choices_Write : constant String := "<Choices$Write>." & app_name;
Choices_Read : constant String := "Choices:" & app_name & ".Choices";
scrapdir : constant String := "<Wimp$ScrapDir>." & app_name;
--
Acronym_List : AcronymList.ListPointer := new AcronymList.List;
Untitled_String : Unbounded_String;
--
procedure Main;
procedure Discard_Acronyms;
procedure Read_Acronyms;
procedure Report_Error (Token : in String;
Info : in String);
--
end Main;
|
Rodeo-McCabe/orka | Ada | 13,414 | adb | -- SPDX-License-Identifier: Apache-2.0
--
-- Copyright (c) 2012 Felix Krause <[email protected]>
--
-- Licensed under the Apache License, Version 2.0 (the "License");
-- you may not use this file except in compliance with the License.
-- You may obtain a copy of the License at
--
-- http://www.apache.org/licenses/LICENSE-2.0
--
-- Unless required by applicable law or agreed to in writing, software
-- distributed under the License is distributed on an "AS IS" BASIS,
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-- See the License for the specific language governing permissions and
-- limitations under the License.
with Interfaces.C.Strings;
with Ada.Unchecked_Conversion;
with GL.API;
with GL.Enums;
with GL.Low_Level;
with GL.Objects.Programs.Uniforms;
package body GL.Objects.Programs is
procedure Attach (Subject : Program; Shader : Shaders.Shader) is
begin
API.Attach_Shader.Ref (Subject.Reference.GL_Id, Shader.Raw_Id);
end Attach;
procedure Detach (Subject : Program; Shader : Shaders.Shader) is
begin
API.Detach_Shader.Ref (Subject.Reference.GL_Id, Shader.Raw_Id);
end Detach;
procedure Link (Subject : Program) is
begin
API.Link_Program.Ref (Subject.Reference.GL_Id);
end Link;
function Link_Status (Subject : Program) return Boolean is
Status_Value : Int := 0;
begin
API.Get_Program_Param.Ref
(Subject.Reference.GL_Id, Enums.Link_Status, Status_Value);
return Status_Value /= 0;
end Link_Status;
function Info_Log (Subject : Program) return String is
Log_Length : Size := 0;
begin
API.Get_Program_Param.Ref
(Subject.Reference.GL_Id, Enums.Info_Log_Length, Log_Length);
if Log_Length = 0 then
return "";
end if;
declare
Info_Log : String (1 .. Integer (Log_Length));
begin
API.Get_Program_Info_Log.Ref
(Subject.Reference.GL_Id, Log_Length, Log_Length, Info_Log);
return Info_Log (1 .. Integer (Log_Length));
end;
end Info_Log;
procedure Use_Program (Subject : Program) is
begin
API.Use_Program.Ref (Subject.Reference.GL_Id);
end Use_Program;
procedure Set_Separable (Subject : Program; Separable : Boolean) is
begin
API.Program_Parameter_Bool.Ref (Subject.Reference.GL_Id, Enums.Program_Separable,
Low_Level.Bool (Separable));
end Set_Separable;
function Separable (Subject : Program) return Boolean is
Separable_Value : Int := 0;
begin
API.Get_Program_Param.Ref
(Subject.Reference.GL_Id, Enums.Program_Separable, Separable_Value);
return Separable_Value /= 0;
end Separable;
function Compute_Work_Group_Size (Object : Program) return Compute.Dimension_Size_Array is
Values : Compute.Dimension_Size_Array := (others => 0);
begin
API.Get_Program_Param_Compute.Ref
(Object.Reference.GL_Id, Enums.Compute_Work_Group_Size, Values);
return Values;
end Compute_Work_Group_Size;
overriding
procedure Initialize_Id (Object : in out Program) is
begin
Object.Reference.GL_Id := API.Create_Program.Ref.all;
end Initialize_Id;
procedure Initialize_Id (Object : in out Program; Kind : Shaders.Shader_Type; Source : String) is
C_Shader_Source : C.Strings.chars_ptr := C.Strings.New_String (Source);
C_Source : constant Low_Level.CharPtr_Array
:= (1 => C_Shader_Source);
begin
Object.Reference.GL_Id := API.Create_Shader_Program.Ref (Kind, 1, C_Source);
C.Strings.Free (C_Shader_Source);
end Initialize_Id;
overriding
procedure Delete_Id (Object : in out Program) is
begin
API.Delete_Program.Ref (Object.Reference.GL_Id);
Object.Reference.GL_Id := 0;
end Delete_Id;
function Uniform_Location (Subject : Program; Name : String)
return Uniforms.Uniform is
Result : constant Int := API.Get_Uniform_Location.Ref
(Subject.Reference.GL_Id, Interfaces.C.To_C (Name));
begin
if Result = -1 then
raise Uniform_Inactive_Error with "Uniform " & Name & " is inactive (unused)";
end if;
return Uniforms.Create_Uniform (Subject, Result);
end Uniform_Location;
function Buffer_Binding
(Object : Program;
Target : Buffers.Indexed_Buffer_Target;
Name : String) return Size
is
Index : UInt;
Iface : Enums.Program_Interface;
use all type Buffers.Indexed_Buffer_Target;
begin
case Target is
when Shader_Storage =>
Index := API.Get_Program_Resource_Index.Ref
(Object.Reference.GL_Id, Enums.Shader_Storage_Block, Interfaces.C.To_C (Name));
Iface := Enums.Shader_Storage_Block;
when Uniform =>
Index := API.Get_Program_Resource_Index.Ref
(Object.Reference.GL_Id, Enums.Uniform_Block, Interfaces.C.To_C (Name));
Iface := Enums.Uniform_Block;
when Atomic_Counter =>
Index := API.Get_Program_Resource_Index.Ref
(Object.Reference.GL_Id, Enums.Uniform, Interfaces.C.To_C (Name));
Iface := Enums.Atomic_Counter_Buffer;
if Index = -1 then
raise Uniform_Inactive_Error with "Uniform " & Name & " is inactive (unused)";
end if;
declare
Values : constant Int_Array := API.Get_Program_Resource.Ref
(Object.Reference.GL_Id, Enums.Uniform, Index,
1, (1 => Enums.Atomic_Counter_Buffer_Index), 1);
begin
Index := (if Values'Length > 0 then UInt (Values (Values'First)) else -1);
end;
end case;
if Index = -1 then
raise Uniform_Inactive_Error with "Buffer " & Name & " is inactive (unused)";
end if;
declare
Values : constant Int_Array := API.Get_Program_Resource.Ref
(Object.Reference.GL_Id, Iface, Index,
1, (1 => Enums.Buffer_Binding), 1);
begin
return Size (Values (Values'First));
end;
end Buffer_Binding;
function Uniform_Type (Object : Program; Name : String)
return Low_Level.Enums.Resource_Type is
Index : constant UInt := API.Get_Program_Resource_Index.Ref
(Object.Reference.GL_Id, Enums.Uniform, Interfaces.C.To_C (Name));
begin
if Index = -1 then
raise Uniform_Inactive_Error with "Uniform " & Name & " is inactive (unused)";
end if;
declare
Values : constant Int_Array := API.Get_Program_Resource.Ref
(Object.Reference.GL_Id, Enums.Uniform, Index,
1, (1 => Enums.Resource_Type), 1);
function Convert is new Ada.Unchecked_Conversion
(Source => Int, Target => Low_Level.Enums.Resource_Type);
begin
return Convert (Values (Values'First));
end;
end Uniform_Type;
-----------------------------------------------------------------------------
-- Subroutines --
-----------------------------------------------------------------------------
function Subroutine_Interface (Shader : Shaders.Shader_Type)
return Enums.Program_Interface with Inline is
begin
case Shader is
when Shaders.Vertex_Shader =>
return Enums.Vertex_Subroutine;
when Shaders.Geometry_Shader =>
return Enums.Geometry_Subroutine;
when Shaders.Fragment_Shader =>
return Enums.Fragment_Subroutine;
when Shaders.Tess_Control_Shader =>
return Enums.Tess_Control_Subroutine;
when Shaders.Tess_Evaluation_Shader =>
return Enums.Tess_Evaluation_Subroutine;
when Shaders.Compute_Shader =>
return Enums.Compute_Subroutine;
end case;
end Subroutine_Interface;
function Subroutine_Uniform_Interface (Shader : Shaders.Shader_Type)
return Enums.Program_Interface with Inline is
begin
case Shader is
when Shaders.Vertex_Shader =>
return Enums.Vertex_Subroutine_Uniform;
when Shaders.Geometry_Shader =>
return Enums.Geometry_Subroutine_Uniform;
when Shaders.Fragment_Shader =>
return Enums.Fragment_Subroutine_Uniform;
when Shaders.Tess_Control_Shader =>
return Enums.Tess_Control_Subroutine_Uniform;
when Shaders.Tess_Evaluation_Shader =>
return Enums.Tess_Evaluation_Subroutine_Uniform;
when Shaders.Compute_Shader =>
return Enums.Compute_Subroutine_Uniform;
end case;
end Subroutine_Uniform_Interface;
function Subroutine_Uniforms_Indices
(Object : Program;
Shader : Shaders.Shader_Type) return Size
is
Indices : GL.Low_Level.Int_Array (1 .. 1);
begin
API.Get_Program_Interface.Ref
(Object.Reference.GL_Id,
Subroutine_Uniform_Interface (Shader),
Enums.Active_Resources, Indices);
return Size (Indices (1));
end Subroutine_Uniforms_Indices;
-- Return total number of subroutine uniforms indices
--
-- A subroutine uniform that is an array has multiple locations, but
-- has one index.
function Subroutine_Uniform_Locations
(Object : Program;
Shader : Shaders.Shader_Type;
Index : Subroutine_Index_Type) return Size
is
Values : constant Int_Array := API.Get_Program_Resource.Ref
(Object.Reference.GL_Id,
Subroutine_Uniform_Interface (Shader), Index,
1, (1 => Enums.Array_Size), 1);
Locations : constant Size := Size (Values (1));
begin
return Locations;
end Subroutine_Uniform_Locations;
-- Return number of locations for a specific active subroutine uniform
function Subroutine_Uniform_Locations
(Object : Program;
Shader : Shaders.Shader_Type) return Size
is
Locations : Size := 0;
begin
for Index in 0 .. Object.Subroutine_Uniforms_Indices (Shader) - 1 loop
Locations := Locations + Subroutine_Uniform_Locations
(Object, Shader, Subroutine_Index_Type (Index));
end loop;
return Locations;
end Subroutine_Uniform_Locations;
function Subroutine_Index
(Object : Program;
Shader : Shaders.Shader_Type;
Name : String) return Subroutine_Index_Type
is
C_String : constant Interfaces.C.char_array
:= Interfaces.C.To_C (Name);
begin
return Index : constant Subroutine_Index_Type := Subroutine_Index_Type
(API.Get_Program_Resource_Index.Ref (Object.Reference.GL_Id,
Subroutine_Interface (Shader), C_String))
do
if Index = -1 then
raise Subroutine_Inactive_Error with "Subroutine " & Name & " is inactive (unused)";
end if;
end return;
end Subroutine_Index;
function Subroutine_Uniform_Index
(Object : Program;
Shader : Shaders.Shader_Type;
Name : String) return Subroutine_Index_Type
is
C_String : constant Interfaces.C.char_array
:= Interfaces.C.To_C (Name);
begin
return Index : constant Subroutine_Index_Type
:= Subroutine_Index_Type (API.Get_Program_Resource_Index.Ref
(Object.Reference.GL_Id,
Subroutine_Uniform_Interface (Shader),
C_String))
do
if Index = -1 then
raise Uniform_Inactive_Error with "Uniform " & Name & " is inactive (unused)";
end if;
end return;
end Subroutine_Uniform_Index;
function Subroutine_Uniform_Location
(Object : Program;
Shader : Shaders.Shader_Type;
Name : String) return Uniform_Location_Type
is
C_String : constant Interfaces.C.char_array
:= Interfaces.C.To_C (Name);
begin
return Index : constant Uniform_Location_Type
:= Uniform_Location_Type (API.Get_Program_Resource_Location.Ref
(Object.Reference.GL_Id,
Subroutine_Uniform_Interface (Shader),
C_String))
do
null;
end return;
end Subroutine_Uniform_Location;
function Subroutine_Indices_Uniform
(Object : Program;
Shader : Shaders.Shader_Type;
Index : Subroutine_Index_Type) return Subroutine_Index_Array
is
Values : constant Int_Array := API.Get_Program_Resource.Ref
(Object.Reference.GL_Id,
Subroutine_Uniform_Interface (Shader), Index,
1, (1 => Enums.Num_Compatible_Subroutines), 1);
Num_Subroutines : constant Size := Size (Values (1));
begin
declare
Values : constant Int_Array := API.Get_Program_Resource.Ref
(Object.Reference.GL_Id,
Subroutine_Uniform_Interface (Shader), Index,
1, (1 => Enums.Compatible_Subroutines), Num_Subroutines);
begin
return Result : Subroutine_Index_Array (1 .. Num_Subroutines) do
for Index in Values'Range loop
Result (Size (Index)) := Subroutine_Index_Type (Values (Index));
end loop;
end return;
end;
end Subroutine_Indices_Uniform;
procedure Set_Uniform_Subroutines (Shader : Shaders.Shader_Type; Indices : UInt_Array) is
begin
API.Uniform_Subroutines.Ref (Shader, Indices'Length, Indices);
end Set_Uniform_Subroutines;
end GL.Objects.Programs;
|
MinimSecure/unum-sdk | Ada | 841 | adb | -- Copyright 2014-2019 Free Software Foundation, Inc.
--
-- This program is free software; you can redistribute it and/or modify
-- it under the terms of the GNU General Public License as published by
-- the Free Software Foundation; either version 3 of the License, or
-- (at your option) any later version.
--
-- This program is distributed in the hope that it will be useful,
-- but WITHOUT ANY WARRANTY; without even the implied warranty of
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-- GNU General Public License for more details.
--
-- You should have received a copy of the GNU General Public License
-- along with this program. If not, see <http://www.gnu.org/licenses/>.
with Pck; use Pck;
procedure Parse is
My_Str : String := Foos; -- START
begin
Do_Nothing (My_Str'Address);
end Parse;
|
AdaCore/training_material | Ada | 19,932 | ads | pragma Ada_2005;
pragma Style_Checks (Off);
with Interfaces.C; use Interfaces.C;
with SDL_stdinc_h;
with Interfaces.C.Strings;
package SDL_joystick_h is
SDL_JOYSTICK_AXIS_MAX : constant := 32767; -- ..\SDL2_tmp\SDL_joystick.h:301
SDL_JOYSTICK_AXIS_MIN : constant := -32768; -- ..\SDL2_tmp\SDL_joystick.h:302
SDL_HAT_CENTERED : constant := 16#00#; -- ..\SDL2_tmp\SDL_joystick.h:329
SDL_HAT_UP : constant := 16#01#; -- ..\SDL2_tmp\SDL_joystick.h:330
SDL_HAT_RIGHT : constant := 16#02#; -- ..\SDL2_tmp\SDL_joystick.h:331
SDL_HAT_DOWN : constant := 16#04#; -- ..\SDL2_tmp\SDL_joystick.h:332
SDL_HAT_LEFT : constant := 16#08#; -- ..\SDL2_tmp\SDL_joystick.h:333
-- unsupported macro: SDL_HAT_RIGHTUP (SDL_HAT_RIGHT|SDL_HAT_UP)
-- unsupported macro: SDL_HAT_RIGHTDOWN (SDL_HAT_RIGHT|SDL_HAT_DOWN)
-- unsupported macro: SDL_HAT_LEFTUP (SDL_HAT_LEFT|SDL_HAT_UP)
-- unsupported macro: SDL_HAT_LEFTDOWN (SDL_HAT_LEFT|SDL_HAT_DOWN)
-- Simple DirectMedia Layer
-- Copyright (C) 1997-2018 Sam Lantinga <[email protected]>
-- 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.
--
--*
-- * \file SDL_joystick.h
-- *
-- * Include file for SDL joystick event handling
-- *
-- * The term "device_index" identifies currently plugged in joystick devices between 0 and SDL_NumJoysticks(), with the exact joystick
-- * behind a device_index changing as joysticks are plugged and unplugged.
-- *
-- * The term "instance_id" is the current instantiation of a joystick device in the system, if the joystick is removed and then re-inserted
-- * then it will get a new instance_id, instance_id's are monotonically increasing identifiers of a joystick plugged in.
-- *
-- * The term JoystickGUID is a stable 128-bit identifier for a joystick device that does not change over time, it identifies class of
-- * the device (a X360 wired controller for example). This identifier is platform dependent.
-- *
-- *
--
-- Set up for C function definitions, even when using C++
--*
-- * \file SDL_joystick.h
-- *
-- * In order to use these functions, SDL_Init() must have been called
-- * with the ::SDL_INIT_JOYSTICK flag. This causes SDL to scan the system
-- * for joysticks, and load appropriate drivers.
-- *
-- * If you would like to receive joystick updates while the application
-- * is in the background, you should set the following hint before calling
-- * SDL_Init(): SDL_HINT_JOYSTICK_ALLOW_BACKGROUND_EVENTS
--
--*
-- * The joystick structure used to identify an SDL joystick
--
type u_SDL_Joystick is null record; -- incomplete struct
subtype SDL_Joystick is u_SDL_Joystick; -- ..\SDL2_tmp\SDL_joystick.h:67
-- A structure that encodes the stable unique id for a joystick device
type SDL_JoystickGUID_data_array is array (0 .. 15) of aliased SDL_stdinc_h.Uint8;
type SDL_JoystickGUID is record
data : aliased SDL_JoystickGUID_data_array; -- ..\SDL2_tmp\SDL_joystick.h:71
end record;
pragma Convention (C_Pass_By_Copy, SDL_JoystickGUID); -- ..\SDL2_tmp\SDL_joystick.h:72
-- skipped anonymous struct anon_53
--*
-- * This is a unique ID for a joystick for the time it is connected to the system,
-- * and is never reused for the lifetime of the application. If the joystick is
-- * disconnected and reconnected, it will get a new ID.
-- *
-- * The ID value starts at 0 and increments from there. The value -1 is an invalid ID.
--
subtype SDL_JoystickID is SDL_stdinc_h.Sint32; -- ..\SDL2_tmp\SDL_joystick.h:81
type SDL_JoystickType is
(SDL_JOYSTICK_TYPE_UNKNOWN,
SDL_JOYSTICK_TYPE_GAMECONTROLLER,
SDL_JOYSTICK_TYPE_WHEEL,
SDL_JOYSTICK_TYPE_ARCADE_STICK,
SDL_JOYSTICK_TYPE_FLIGHT_STICK,
SDL_JOYSTICK_TYPE_DANCE_PAD,
SDL_JOYSTICK_TYPE_GUITAR,
SDL_JOYSTICK_TYPE_DRUM_KIT,
SDL_JOYSTICK_TYPE_ARCADE_PAD,
SDL_JOYSTICK_TYPE_THROTTLE);
pragma Convention (C, SDL_JoystickType); -- ..\SDL2_tmp\SDL_joystick.h:95
-- <= 5%
-- <= 20%
-- <= 70%
-- <= 100%
subtype SDL_JoystickPowerLevel is int;
SDL_JOYSTICK_POWER_UNKNOWN : constant int := -1;
SDL_JOYSTICK_POWER_EMPTY : constant int := 0;
SDL_JOYSTICK_POWER_LOW : constant int := 1;
SDL_JOYSTICK_POWER_MEDIUM : constant int := 2;
SDL_JOYSTICK_POWER_FULL : constant int := 3;
SDL_JOYSTICK_POWER_WIRED : constant int := 4;
SDL_JOYSTICK_POWER_MAX : constant int := 5; -- ..\SDL2_tmp\SDL_joystick.h:106
-- Function prototypes
--*
-- * Locking for multi-threaded access to the joystick API
-- *
-- * If you are using the joystick API or handling events from multiple threads
-- * you should use these locking functions to protect access to the joysticks.
-- *
-- * In particular, you are guaranteed that the joystick list won't change, so
-- * the API functions that take a joystick index will be valid, and joystick
-- * and game controller events will not be delivered.
--
procedure SDL_LockJoysticks; -- ..\SDL2_tmp\SDL_joystick.h:120
pragma Import (C, SDL_LockJoysticks, "SDL_LockJoysticks");
procedure SDL_UnlockJoysticks; -- ..\SDL2_tmp\SDL_joystick.h:121
pragma Import (C, SDL_UnlockJoysticks, "SDL_UnlockJoysticks");
--*
-- * Count the number of joysticks attached to the system right now
--
function SDL_NumJoysticks return int; -- ..\SDL2_tmp\SDL_joystick.h:126
pragma Import (C, SDL_NumJoysticks, "SDL_NumJoysticks");
--*
-- * Get the implementation dependent name of a joystick.
-- * This can be called before any joysticks are opened.
-- * If no name can be found, this function returns NULL.
--
function SDL_JoystickNameForIndex (device_index : int) return Interfaces.C.Strings.chars_ptr; -- ..\SDL2_tmp\SDL_joystick.h:133
pragma Import (C, SDL_JoystickNameForIndex, "SDL_JoystickNameForIndex");
--*
-- * Get the player index of a joystick, or -1 if it's not available
-- * This can be called before any joysticks are opened.
--
function SDL_JoystickGetDevicePlayerIndex (device_index : int) return int; -- ..\SDL2_tmp\SDL_joystick.h:139
pragma Import (C, SDL_JoystickGetDevicePlayerIndex, "SDL_JoystickGetDevicePlayerIndex");
--*
-- * Return the GUID for the joystick at this index
-- * This can be called before any joysticks are opened.
--
function SDL_JoystickGetDeviceGUID (device_index : int) return SDL_JoystickGUID; -- ..\SDL2_tmp\SDL_joystick.h:145
pragma Import (C, SDL_JoystickGetDeviceGUID, "SDL_JoystickGetDeviceGUID");
--*
-- * Get the USB vendor ID of a joystick, if available.
-- * This can be called before any joysticks are opened.
-- * If the vendor ID isn't available this function returns 0.
--
function SDL_JoystickGetDeviceVendor (device_index : int) return SDL_stdinc_h.Uint16; -- ..\SDL2_tmp\SDL_joystick.h:152
pragma Import (C, SDL_JoystickGetDeviceVendor, "SDL_JoystickGetDeviceVendor");
--*
-- * Get the USB product ID of a joystick, if available.
-- * This can be called before any joysticks are opened.
-- * If the product ID isn't available this function returns 0.
--
function SDL_JoystickGetDeviceProduct (device_index : int) return SDL_stdinc_h.Uint16; -- ..\SDL2_tmp\SDL_joystick.h:159
pragma Import (C, SDL_JoystickGetDeviceProduct, "SDL_JoystickGetDeviceProduct");
--*
-- * Get the product version of a joystick, if available.
-- * This can be called before any joysticks are opened.
-- * If the product version isn't available this function returns 0.
--
function SDL_JoystickGetDeviceProductVersion (device_index : int) return SDL_stdinc_h.Uint16; -- ..\SDL2_tmp\SDL_joystick.h:166
pragma Import (C, SDL_JoystickGetDeviceProductVersion, "SDL_JoystickGetDeviceProductVersion");
--*
-- * Get the type of a joystick, if available.
-- * This can be called before any joysticks are opened.
--
function SDL_JoystickGetDeviceType (device_index : int) return SDL_JoystickType; -- ..\SDL2_tmp\SDL_joystick.h:172
pragma Import (C, SDL_JoystickGetDeviceType, "SDL_JoystickGetDeviceType");
--*
-- * Get the instance ID of a joystick.
-- * This can be called before any joysticks are opened.
-- * If the index is out of range, this function will return -1.
--
function SDL_JoystickGetDeviceInstanceID (device_index : int) return SDL_JoystickID; -- ..\SDL2_tmp\SDL_joystick.h:179
pragma Import (C, SDL_JoystickGetDeviceInstanceID, "SDL_JoystickGetDeviceInstanceID");
--*
-- * Open a joystick for use.
-- * The index passed as an argument refers to the N'th joystick on the system.
-- * This index is not the value which will identify this joystick in future
-- * joystick events. The joystick's instance id (::SDL_JoystickID) will be used
-- * there instead.
-- *
-- * \return A joystick identifier, or NULL if an error occurred.
--
function SDL_JoystickOpen (device_index : int) return access SDL_Joystick; -- ..\SDL2_tmp\SDL_joystick.h:190
pragma Import (C, SDL_JoystickOpen, "SDL_JoystickOpen");
--*
-- * Return the SDL_Joystick associated with an instance id.
--
function SDL_JoystickFromInstanceID (joyid : SDL_JoystickID) return access SDL_Joystick; -- ..\SDL2_tmp\SDL_joystick.h:195
pragma Import (C, SDL_JoystickFromInstanceID, "SDL_JoystickFromInstanceID");
--*
-- * Return the name for this currently opened joystick.
-- * If no name can be found, this function returns NULL.
--
function SDL_JoystickName (joystick : access SDL_Joystick) return Interfaces.C.Strings.chars_ptr; -- ..\SDL2_tmp\SDL_joystick.h:201
pragma Import (C, SDL_JoystickName, "SDL_JoystickName");
--*
-- * Get the player index of an opened joystick, or -1 if it's not available
-- *
-- * For XInput controllers this returns the XInput user index.
--
function SDL_JoystickGetPlayerIndex (joystick : access SDL_Joystick) return int; -- ..\SDL2_tmp\SDL_joystick.h:208
pragma Import (C, SDL_JoystickGetPlayerIndex, "SDL_JoystickGetPlayerIndex");
--*
-- * Return the GUID for this opened joystick
--
function SDL_JoystickGetGUID (joystick : access SDL_Joystick) return SDL_JoystickGUID; -- ..\SDL2_tmp\SDL_joystick.h:213
pragma Import (C, SDL_JoystickGetGUID, "SDL_JoystickGetGUID");
--*
-- * Get the USB vendor ID of an opened joystick, if available.
-- * If the vendor ID isn't available this function returns 0.
--
function SDL_JoystickGetVendor (joystick : access SDL_Joystick) return SDL_stdinc_h.Uint16; -- ..\SDL2_tmp\SDL_joystick.h:219
pragma Import (C, SDL_JoystickGetVendor, "SDL_JoystickGetVendor");
--*
-- * Get the USB product ID of an opened joystick, if available.
-- * If the product ID isn't available this function returns 0.
--
function SDL_JoystickGetProduct (joystick : access SDL_Joystick) return SDL_stdinc_h.Uint16; -- ..\SDL2_tmp\SDL_joystick.h:225
pragma Import (C, SDL_JoystickGetProduct, "SDL_JoystickGetProduct");
--*
-- * Get the product version of an opened joystick, if available.
-- * If the product version isn't available this function returns 0.
--
function SDL_JoystickGetProductVersion (joystick : access SDL_Joystick) return SDL_stdinc_h.Uint16; -- ..\SDL2_tmp\SDL_joystick.h:231
pragma Import (C, SDL_JoystickGetProductVersion, "SDL_JoystickGetProductVersion");
--*
-- * Get the type of an opened joystick.
--
function SDL_JoystickGetType (joystick : access SDL_Joystick) return SDL_JoystickType; -- ..\SDL2_tmp\SDL_joystick.h:236
pragma Import (C, SDL_JoystickGetType, "SDL_JoystickGetType");
--*
-- * Return a string representation for this guid. pszGUID must point to at least 33 bytes
-- * (32 for the string plus a NULL terminator).
--
procedure SDL_JoystickGetGUIDString
(guid : SDL_JoystickGUID;
pszGUID : Interfaces.C.Strings.chars_ptr;
cbGUID : int); -- ..\SDL2_tmp\SDL_joystick.h:242
pragma Import (C, SDL_JoystickGetGUIDString, "SDL_JoystickGetGUIDString");
--*
-- * Convert a string into a joystick guid
--
function SDL_JoystickGetGUIDFromString (pchGUID : Interfaces.C.Strings.chars_ptr) return SDL_JoystickGUID; -- ..\SDL2_tmp\SDL_joystick.h:247
pragma Import (C, SDL_JoystickGetGUIDFromString, "SDL_JoystickGetGUIDFromString");
--*
-- * Returns SDL_TRUE if the joystick has been opened and currently connected, or SDL_FALSE if it has not.
--
function SDL_JoystickGetAttached (joystick : access SDL_Joystick) return SDL_stdinc_h.SDL_bool; -- ..\SDL2_tmp\SDL_joystick.h:252
pragma Import (C, SDL_JoystickGetAttached, "SDL_JoystickGetAttached");
--*
-- * Get the instance ID of an opened joystick or -1 if the joystick is invalid.
--
function SDL_JoystickInstanceID (joystick : access SDL_Joystick) return SDL_JoystickID; -- ..\SDL2_tmp\SDL_joystick.h:257
pragma Import (C, SDL_JoystickInstanceID, "SDL_JoystickInstanceID");
--*
-- * Get the number of general axis controls on a joystick.
--
function SDL_JoystickNumAxes (joystick : access SDL_Joystick) return int; -- ..\SDL2_tmp\SDL_joystick.h:262
pragma Import (C, SDL_JoystickNumAxes, "SDL_JoystickNumAxes");
--*
-- * Get the number of trackballs on a joystick.
-- *
-- * Joystick trackballs have only relative motion events associated
-- * with them and their state cannot be polled.
--
function SDL_JoystickNumBalls (joystick : access SDL_Joystick) return int; -- ..\SDL2_tmp\SDL_joystick.h:270
pragma Import (C, SDL_JoystickNumBalls, "SDL_JoystickNumBalls");
--*
-- * Get the number of POV hats on a joystick.
--
function SDL_JoystickNumHats (joystick : access SDL_Joystick) return int; -- ..\SDL2_tmp\SDL_joystick.h:275
pragma Import (C, SDL_JoystickNumHats, "SDL_JoystickNumHats");
--*
-- * Get the number of buttons on a joystick.
--
function SDL_JoystickNumButtons (joystick : access SDL_Joystick) return int; -- ..\SDL2_tmp\SDL_joystick.h:280
pragma Import (C, SDL_JoystickNumButtons, "SDL_JoystickNumButtons");
--*
-- * Update the current state of the open joysticks.
-- *
-- * This is called automatically by the event loop if any joystick
-- * events are enabled.
--
procedure SDL_JoystickUpdate; -- ..\SDL2_tmp\SDL_joystick.h:288
pragma Import (C, SDL_JoystickUpdate, "SDL_JoystickUpdate");
--*
-- * Enable/disable joystick event polling.
-- *
-- * If joystick events are disabled, you must call SDL_JoystickUpdate()
-- * yourself and check the state of the joystick when you want joystick
-- * information.
-- *
-- * The state can be one of ::SDL_QUERY, ::SDL_ENABLE or ::SDL_IGNORE.
--
function SDL_JoystickEventState (state : int) return int; -- ..\SDL2_tmp\SDL_joystick.h:299
pragma Import (C, SDL_JoystickEventState, "SDL_JoystickEventState");
--*
-- * Get the current state of an axis control on a joystick.
-- *
-- * The state is a value ranging from -32768 to 32767.
-- *
-- * The axis indices start at index 0.
--
function SDL_JoystickGetAxis (joystick : access SDL_Joystick; axis : int) return SDL_stdinc_h.Sint16; -- ..\SDL2_tmp\SDL_joystick.h:310
pragma Import (C, SDL_JoystickGetAxis, "SDL_JoystickGetAxis");
--*
-- * Get the initial state of an axis control on a joystick.
-- *
-- * The state is a value ranging from -32768 to 32767.
-- *
-- * The axis indices start at index 0.
-- *
-- * \return SDL_TRUE if this axis has any initial value, or SDL_FALSE if not.
--
function SDL_JoystickGetAxisInitialState
(joystick : access SDL_Joystick;
axis : int;
state : access SDL_stdinc_h.Sint16) return SDL_stdinc_h.SDL_bool; -- ..\SDL2_tmp\SDL_joystick.h:322
pragma Import (C, SDL_JoystickGetAxisInitialState, "SDL_JoystickGetAxisInitialState");
--*
-- * \name Hat positions
--
-- @{
-- @}
--*
-- * Get the current state of a POV hat on a joystick.
-- *
-- * The hat indices start at index 0.
-- *
-- * \return The return value is one of the following positions:
-- * - ::SDL_HAT_CENTERED
-- * - ::SDL_HAT_UP
-- * - ::SDL_HAT_RIGHT
-- * - ::SDL_HAT_DOWN
-- * - ::SDL_HAT_LEFT
-- * - ::SDL_HAT_RIGHTUP
-- * - ::SDL_HAT_RIGHTDOWN
-- * - ::SDL_HAT_LEFTUP
-- * - ::SDL_HAT_LEFTDOWN
--
function SDL_JoystickGetHat (joystick : access SDL_Joystick; hat : int) return SDL_stdinc_h.Uint8; -- ..\SDL2_tmp\SDL_joystick.h:356
pragma Import (C, SDL_JoystickGetHat, "SDL_JoystickGetHat");
--*
-- * Get the ball axis change since the last poll.
-- *
-- * \return 0, or -1 if you passed it invalid parameters.
-- *
-- * The ball indices start at index 0.
--
function SDL_JoystickGetBall
(joystick : access SDL_Joystick;
ball : int;
dx : access int;
dy : access int) return int; -- ..\SDL2_tmp\SDL_joystick.h:366
pragma Import (C, SDL_JoystickGetBall, "SDL_JoystickGetBall");
--*
-- * Get the current state of a button on a joystick.
-- *
-- * The button indices start at index 0.
--
function SDL_JoystickGetButton (joystick : access SDL_Joystick; button : int) return SDL_stdinc_h.Uint8; -- ..\SDL2_tmp\SDL_joystick.h:374
pragma Import (C, SDL_JoystickGetButton, "SDL_JoystickGetButton");
--*
-- * Trigger a rumble effect
-- * Each call to this function cancels any previous rumble effect, and calling it with 0 intensity stops any rumbling.
-- *
-- * \param joystick The joystick to vibrate
-- * \param low_frequency_rumble The intensity of the low frequency (left) rumble motor, from 0 to 0xFFFF
-- * \param high_frequency_rumble The intensity of the high frequency (right) rumble motor, from 0 to 0xFFFF
-- * \param duration_ms The duration of the rumble effect, in milliseconds
-- *
-- * \return 0, or -1 if rumble isn't supported on this joystick
--
function SDL_JoystickRumble
(joystick : access SDL_Joystick;
low_frequency_rumble : SDL_stdinc_h.Uint16;
high_frequency_rumble : SDL_stdinc_h.Uint16;
duration_ms : SDL_stdinc_h.Uint32) return int; -- ..\SDL2_tmp\SDL_joystick.h:388
pragma Import (C, SDL_JoystickRumble, "SDL_JoystickRumble");
--*
-- * Close a joystick previously opened with SDL_JoystickOpen().
--
procedure SDL_JoystickClose (joystick : access SDL_Joystick); -- ..\SDL2_tmp\SDL_joystick.h:393
pragma Import (C, SDL_JoystickClose, "SDL_JoystickClose");
--*
-- * Return the battery level of this joystick
--
function SDL_JoystickCurrentPowerLevel (joystick : access SDL_Joystick) return SDL_JoystickPowerLevel; -- ..\SDL2_tmp\SDL_joystick.h:398
pragma Import (C, SDL_JoystickCurrentPowerLevel, "SDL_JoystickCurrentPowerLevel");
-- Ends C function definitions when using C++
-- vi: set ts=4 sw=4 expandtab:
end SDL_joystick_h;
|
ytomino/vampire | Ada | 8,817 | adb | -- The Village of Vampire by YT, このソースコードはNYSLです
with Ada.Directories;
with Ada.Hierarchical_File_Names;
with Ada.IO_Exceptions;
with Ada.Streams.Stream_IO;
with Tabula.Users.Load;
with Tabula.Users.Save;
package body Tabula.Users.Lists is
use type Ada.Strings.Unbounded.Unbounded_String;
procedure Load_Users_Log (List : in out User_List) is
begin
if not List.Log_Read then
begin
declare
File : Ada.Streams.Stream_IO.File_Type :=
Ada.Streams.Stream_IO.Open (
Ada.Streams.Stream_IO.In_File,
Name => List.Log_File_Name.all);
begin
Users_Log.Map'Read (Ada.Streams.Stream_IO.Stream (File), List.Log);
Ada.Streams.Stream_IO.Close (File);
end;
exception
when Ada.IO_Exceptions.Name_Error => null;
end;
List.Log_Read := True;
end if;
end Load_Users_Log;
procedure Add_To_Users_Log (
List : in out User_List;
Id : in String;
Remote_Addr : in String;
Remote_Host : in String;
Now : in Ada.Calendar.Time)
is
Item : User_Log_Item := (+Id, +Remote_Addr, +Remote_Host);
begin
Load_Users_Log (List);
Users_Log.Include (List.Log, Item, Now);
-- create the directory
declare
Dir : constant String :=
Ada.Hierarchical_File_Names.Unchecked_Containing_Directory (
List.Log_File_Name.all);
begin
if Dir'Length /= 0 then
Ada.Directories.Create_Path (Dir);
end if;
end;
-- write the file
declare
File : Ada.Streams.Stream_IO.File_Type :=
Ada.Streams.Stream_IO.Create (Name => List.Log_File_Name.all);
begin
Users_Log.Map'Write (Ada.Streams.Stream_IO.Stream (File), List.Log);
Ada.Streams.Stream_IO.Close (File);
end;
end Add_To_Users_Log;
Upper_Subdirectory_Name : constant String := "+A";
function User_Full_Name (
Directory : String;
Id : String;
Only_Existing : Boolean := False)
return String
is
Lower_Name : constant String :=
Ada.Hierarchical_File_Names.Compose (
Directory => Directory,
Relative_Name => Id);
begin
if Ada.Directories.Exists (Lower_Name) then
return Lower_Name;
else
declare
Upper_Directory : constant String :=
Ada.Hierarchical_File_Names.Compose (
Directory => Directory,
Relative_Name => Upper_Subdirectory_Name);
Upper_Name : constant String :=
Ada.Hierarchical_File_Names.Compose (
Directory => Upper_Directory,
Relative_Name => Id);
begin
if Ada.Directories.Exists (Upper_Name) then
return Upper_Name;
else
if Only_Existing then
raise Ada.IO_Exceptions.Name_Error;
end if;
if Id (Id'First) in 'A' .. 'Z' then
return Upper_Name;
else
return Lower_Name;
end if;
end if;
end;
end if;
end User_Full_Name;
-- implementation
function Create (
Directory : not null Static_String_Access;
Log_File_Name : not null Static_String_Access)
return User_List is
begin
return (
Directory => Directory,
Log_File_Name => Log_File_Name,
Log_Read => False,
Log => Users_Log.Empty_Map);
end Create;
function Exists (List : User_List; Id : String) return Boolean is
begin
declare
Dummy_File_Name : constant String :=
User_Full_Name (List.Directory.all, Id, Only_Existing => True);
begin
return True;
end;
exception
when Ada.IO_Exceptions.Name_Error => return False;
end Exists;
procedure Query (
List : in out User_List;
Id : in String;
Password : in String;
Remote_Addr : in String;
Remote_Host : in String;
Now : in Ada.Calendar.Time;
Info : out User_Info;
State : out User_State) is
begin
if Id'Length = 0 then
State := Log_Off;
elsif not Exists (List, Id) then
State := Unknown;
else
Load (User_Full_Name (List.Directory.all, Id), Info);
if Info.Password /= Digest (Password) or else not Info.Renamed.Is_Null then
State := Invalid;
else
State := Valid;
if Id /= Administrator then
if not Info.No_Log then
Add_To_Users_Log (
List,
Id => Id,
Remote_Addr => Remote_Addr,
Remote_Host => Remote_Host,
Now => Now);
else
Add_To_Users_Log (
List,
Id => Id,
Remote_Addr => "",
Remote_Host => "",
Now => Now); -- log only time
end if;
end if;
end if;
end if;
end Query;
procedure New_User (
List : in out User_List;
Id : in String;
Password : in String;
Remote_Addr : in String;
Remote_Host : in String;
Now : in Ada.Calendar.Time;
Result : out Boolean) is
begin
if Exists (List, Id) then
Result := False;
else
declare
Info : User_Info := (
Password => Digest (Password),
Creation_Remote_Addr => +Remote_Addr,
Creation_Remote_Host => +Remote_Host,
Creation_Time => Now,
Last_Remote_Addr => +Remote_Addr,
Last_Remote_Host => +Remote_Host,
Last_Time => Now,
Ignore_Request => False,
Disallow_New_Village => False,
No_Log => False,
Renamed => Ada.Strings.Unbounded.Null_Unbounded_String);
Full_Name : constant String :=
User_Full_Name (List.Directory.all, Id);
begin
-- create the directory
declare
Dir : constant String :=
Ada.Hierarchical_File_Names.Unchecked_Containing_Directory (Full_Name);
begin
if Dir'Length /= 0 then
Ada.Directories.Create_Path (Dir);
end if;
end;
-- save the file
Save (Full_Name, Info);
Result := True;
end;
end if;
exception
when Ada.IO_Exceptions.Name_Error => Result := False;
end New_User;
procedure Update (
List : in out User_List;
Id : in String;
Remote_Addr : in String;
Remote_Host : in String;
Now : in Ada.Calendar.Time;
Info : in out User_Info) is
begin
Info.Last_Remote_Addr := +Remote_Addr;
Info.Last_Remote_Host := +Remote_Host;
Info.Last_Time := Now;
Save (User_Full_Name (List.Directory.all, Id), Info);
end Update;
function All_Users (List : User_List) return User_Info_Maps.Map is
procedure Add (Result : in out User_Info_Maps.Map; Directory : in String) is
Search : aliased Ada.Directories.Search_Type;
begin
Ada.Directories.Start_Search (
Search,
Directory,
"*",
Filter => (Ada.Directories.Ordinary_File => True, others => False));
while Ada.Directories.More_Entries(Search) loop
declare
File : Ada.Directories.Directory_Entry_Type
renames Ada.Directories.Look_Next_Entry (Search);
Id : String := Ada.Directories.Simple_Name (File);
begin
if Id (Id'First) /= '.' then -- excluding dot file
declare
Info : User_Info;
begin
Load (User_Full_Name (List.Directory.all, Id), Info);
User_Info_Maps.Include (Result, Id, Info);
end;
end if;
end;
Ada.Directories.Skip_Next_Entry (Search);
end loop;
Ada.Directories.End_Search(Search);
end Add;
begin
return Result : User_Info_Maps.Map do
Add (Result, List.Directory.all);
declare
Upper_Directory : constant String :=
Ada.Hierarchical_File_Names.Compose (
Directory => List.Directory.all,
Relative_Name => Upper_Subdirectory_Name);
begin
if Ada.Directories.Exists (Upper_Directory) then
Add (Result, Upper_Directory);
end if;
end;
end return;
end All_Users;
procedure Muramura_Count (
List : in out User_List;
Now : Ada.Calendar.Time;
Muramura_Duration : Duration;
Result : out Natural)
is
Muramura_Set : Users_Log.Map;
begin
Load_Users_Log (List);
for I in List.Log.Iterate loop
if Now - Users_Log.Element (I) <= Muramura_Duration then
declare
Item : User_Log_Item := (Users_Log.Key (I).Id,
Ada.Strings.Unbounded.Null_Unbounded_String,
Ada.Strings.Unbounded.Null_Unbounded_String);
begin
Users_Log.Include (Muramura_Set, Item, Now);
end;
end if;
end loop;
Result := Muramura_Set.Length;
end Muramura_Count;
function "<" (Left, Right : User_Log_Item) return Boolean is
begin
if Left.Id < Right.Id then
return True;
elsif Left.Id > Right.Id then
return False;
elsif Left.Remote_Addr < Right.Remote_Addr then
return True;
elsif Left.Remote_Addr > Right.Remote_Addr then
return False;
else
return Left.Remote_Host < Right.Remote_Host;
end if;
end "<";
procedure Iterate_Log (
List : in out User_List;
Process : not null access procedure (
Id : in String;
Remote_Addr : in String;
Remote_Host : in String;
Time : in Ada.Calendar.Time)) is
begin
Load_Users_Log (List);
for I in List.Log.Iterate loop
declare
Key : User_Log_Item renames Users_Log.Key (I);
begin
Process (
Id => Key.Id.Constant_Reference,
Remote_Addr => Key.Remote_Addr.Constant_Reference,
Remote_Host => Key.Remote_Host.Constant_Reference,
Time => List.Log.Constant_Reference (I));
end;
end loop;
end Iterate_Log;
end Tabula.Users.Lists;
|
sungyeon/drake | Ada | 783 | adb | with System.Native_Time;
with C.winbase;
with C.windef;
package body System.Native_Execution_Time is
use type C.windef.WINBOOL;
-- implementation
function Clock return CPU_Time is
CreationTime : aliased C.windef.FILETIME;
ExitTime : aliased C.windef.FILETIME;
KernelTime : aliased C.windef.FILETIME;
UserTime : aliased C.windef.FILETIME;
begin
if C.winbase.GetProcessTimes (
C.winbase.GetCurrentProcess,
CreationTime'Access,
ExitTime'Access,
KernelTime'Access,
UserTime'Access) =
C.windef.FALSE
then
raise Program_Error; -- ???
else
return Native_Time.To_Duration (UserTime);
end if;
end Clock;
end System.Native_Execution_Time;
|
Tim-Tom/project-euler | Ada | 1,519 | adb | with Ada.Text_IO;
with PrimeUtilities;
package body Problem_69 is
package IO renames Ada.Text_IO;
subtype One_Million is Integer range 1 .. 1_000_000;
best : One_Million := 1;
package Million_Primes is new PrimeUtilities(One_Million);
procedure Solve is
prime : One_Million;
gen : Million_Primes.Prime_Generator := Million_Primes.Make_Generator(One_Million'Last);
begin
-- The Euler number can be calculated by multiplying together the percent of the numbers that
-- each prime factor of the number will remove. Since we're scaling by the number itself
-- getting bigger numbers will not help us, just a larger percent of numbers filtered. Each
-- prime factor will filter out 1/p of the numbers in the number line, leaving p-1/p
-- remaining. So the smaller the primes we can pick, the larger the percent of numbers we will
-- filter out. And since we're picking the smallest primes, we know we could never pick more
-- larger primes and end up with a smaller end target (because we could replace the larger
-- prime with a smaller prime, get a better ratio). As a result we can just multiply from the
-- smallest prime number upwards until we get above our maximum ratio.
loop
Million_Primes.Next_Prime(gen, prime);
exit when prime = 1;
exit when One_Million'Last / prime < best;
best := best * prime;
end loop;
IO.Put_Line(Integer'Image(best));
end Solve;
end Problem_69;
|
optikos/oasis | Ada | 3,538 | ads | -- Copyright (c) 2019 Maxim Reznik <[email protected]>
--
-- SPDX-License-Identifier: MIT
-- License-Filename: LICENSE
-------------------------------------------------------------
with Program.Elements.Declarations;
with Program.Lexical_Elements;
with Program.Elements.Defining_Names;
with Program.Elements.Aspect_Specifications;
with Program.Element_Vectors;
with Program.Elements.Exception_Handlers;
with Program.Elements.Expressions;
package Program.Elements.Package_Body_Declarations is
pragma Pure (Program.Elements.Package_Body_Declarations);
type Package_Body_Declaration is
limited interface and Program.Elements.Declarations.Declaration;
type Package_Body_Declaration_Access is
access all Package_Body_Declaration'Class with Storage_Size => 0;
not overriding function Name
(Self : Package_Body_Declaration)
return not null Program.Elements.Defining_Names.Defining_Name_Access
is abstract;
not overriding function Aspects
(Self : Package_Body_Declaration)
return Program.Elements.Aspect_Specifications
.Aspect_Specification_Vector_Access is abstract;
not overriding function Declarations
(Self : Package_Body_Declaration)
return Program.Element_Vectors.Element_Vector_Access is abstract;
not overriding function Statements
(Self : Package_Body_Declaration)
return not null Program.Element_Vectors.Element_Vector_Access
is abstract;
not overriding function Exception_Handlers
(Self : Package_Body_Declaration)
return Program.Elements.Exception_Handlers
.Exception_Handler_Vector_Access is abstract;
not overriding function End_Name
(Self : Package_Body_Declaration)
return Program.Elements.Expressions.Expression_Access is abstract;
type Package_Body_Declaration_Text is limited interface;
type Package_Body_Declaration_Text_Access is
access all Package_Body_Declaration_Text'Class with Storage_Size => 0;
not overriding function To_Package_Body_Declaration_Text
(Self : aliased in out Package_Body_Declaration)
return Package_Body_Declaration_Text_Access is abstract;
not overriding function Package_Token
(Self : Package_Body_Declaration_Text)
return not null Program.Lexical_Elements.Lexical_Element_Access
is abstract;
not overriding function Body_Token
(Self : Package_Body_Declaration_Text)
return not null Program.Lexical_Elements.Lexical_Element_Access
is abstract;
not overriding function With_Token
(Self : Package_Body_Declaration_Text)
return Program.Lexical_Elements.Lexical_Element_Access is abstract;
not overriding function Is_Token
(Self : Package_Body_Declaration_Text)
return not null Program.Lexical_Elements.Lexical_Element_Access
is abstract;
not overriding function Begin_Token
(Self : Package_Body_Declaration_Text)
return not null Program.Lexical_Elements.Lexical_Element_Access
is abstract;
not overriding function Exception_Token
(Self : Package_Body_Declaration_Text)
return Program.Lexical_Elements.Lexical_Element_Access is abstract;
not overriding function End_Token
(Self : Package_Body_Declaration_Text)
return not null Program.Lexical_Elements.Lexical_Element_Access
is abstract;
not overriding function Semicolon_Token
(Self : Package_Body_Declaration_Text)
return not null Program.Lexical_Elements.Lexical_Element_Access
is abstract;
end Program.Elements.Package_Body_Declarations;
|
reznikmm/matreshka | Ada | 3,745 | ads | ------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- Localization, Internationalization, Globalization for Ada --
-- --
-- Runtime Library Component --
-- --
------------------------------------------------------------------------------
-- --
-- Copyright © 2013, Vadim Godunko <[email protected]> --
-- All rights reserved. --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions --
-- are met: --
-- --
-- * Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- --
-- * Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in the --
-- documentation and/or other materials provided with the distribution. --
-- --
-- * Neither the name of the Vadim Godunko, IE nor the names of its --
-- contributors may be used to endorse or promote products derived from --
-- this software without specific prior written permission. --
-- --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR --
-- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
-- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED --
-- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR --
-- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF --
-- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING --
-- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS --
-- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
-- --
------------------------------------------------------------------------------
-- $Revision$ $Date$
------------------------------------------------------------------------------
with Matreshka.JSON_Types;
package League.JSON.Objects.Internals is
pragma Preelaborate;
function Internal
(Self : League.JSON.Objects.JSON_Object)
return not null Matreshka.JSON_Types.Shared_JSON_Object_Access;
function Create
(Data : not null Matreshka.JSON_Types.Shared_JSON_Object_Access)
return League.JSON.Objects.JSON_Object;
end League.JSON.Objects.Internals;
|
zhmu/ananas | Ada | 6,246 | adb | ------------------------------------------------------------------------------
-- --
-- GNAT RUN-TIME COMPONENTS --
-- --
-- S Y S T E M . P A C K _ 2 1 --
-- --
-- B o d y --
-- --
-- Copyright (C) 1992-2022, Free Software Foundation, Inc. --
-- --
-- GNAT is free software; you can redistribute it and/or modify it under --
-- terms of the GNU General Public License as published by the Free Soft- --
-- ware Foundation; either version 3, or (at your option) any later ver- --
-- sion. GNAT is distributed in the hope that it will be useful, but WITH- --
-- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY --
-- or FITNESS FOR A PARTICULAR PURPOSE. --
-- --
-- As a special exception under Section 7 of GPL version 3, you are granted --
-- additional permissions described in the GCC Runtime Library Exception, --
-- version 3.1, as published by the Free Software Foundation. --
-- --
-- You should have received a copy of the GNU General Public License and --
-- a copy of the GCC Runtime Library Exception along with this program; --
-- see the files COPYING3 and COPYING.RUNTIME respectively. If not, see --
-- <http://www.gnu.org/licenses/>. --
-- --
-- GNAT was originally developed by the GNAT team at New York University. --
-- Extensive contributions were provided by Ada Core Technologies Inc. --
-- --
------------------------------------------------------------------------------
with System.Storage_Elements;
with System.Unsigned_Types;
package body System.Pack_21 is
subtype Bit_Order is System.Bit_Order;
Reverse_Bit_Order : constant Bit_Order :=
Bit_Order'Val (1 - Bit_Order'Pos (System.Default_Bit_Order));
subtype Ofs is System.Storage_Elements.Storage_Offset;
subtype Uns is System.Unsigned_Types.Unsigned;
subtype N07 is System.Unsigned_Types.Unsigned range 0 .. 7;
use type System.Storage_Elements.Storage_Offset;
use type System.Unsigned_Types.Unsigned;
type Cluster is record
E0, E1, E2, E3, E4, E5, E6, E7 : Bits_21;
end record;
for Cluster use record
E0 at 0 range 0 * Bits .. 0 * Bits + Bits - 1;
E1 at 0 range 1 * Bits .. 1 * Bits + Bits - 1;
E2 at 0 range 2 * Bits .. 2 * Bits + Bits - 1;
E3 at 0 range 3 * Bits .. 3 * Bits + Bits - 1;
E4 at 0 range 4 * Bits .. 4 * Bits + Bits - 1;
E5 at 0 range 5 * Bits .. 5 * Bits + Bits - 1;
E6 at 0 range 6 * Bits .. 6 * Bits + Bits - 1;
E7 at 0 range 7 * Bits .. 7 * Bits + Bits - 1;
end record;
for Cluster'Size use Bits * 8;
for Cluster'Alignment use Integer'Min (Standard'Maximum_Alignment,
1 +
1 * Boolean'Pos (Bits mod 2 = 0) +
2 * Boolean'Pos (Bits mod 4 = 0));
-- Use maximum possible alignment, given the bit field size, since this
-- will result in the most efficient code possible for the field.
type Cluster_Ref is access Cluster;
type Rev_Cluster is new Cluster
with Bit_Order => Reverse_Bit_Order,
Scalar_Storage_Order => Reverse_Bit_Order;
type Rev_Cluster_Ref is access Rev_Cluster;
------------
-- Get_21 --
------------
function Get_21
(Arr : System.Address;
N : Natural;
Rev_SSO : Boolean) return Bits_21
is
A : constant System.Address := Arr + Bits * Ofs (Uns (N) / 8);
C : Cluster_Ref with Address => A'Address, Import;
RC : Rev_Cluster_Ref with Address => A'Address, Import;
begin
if Rev_SSO then
case N07 (Uns (N) mod 8) is
when 0 => return RC.E0;
when 1 => return RC.E1;
when 2 => return RC.E2;
when 3 => return RC.E3;
when 4 => return RC.E4;
when 5 => return RC.E5;
when 6 => return RC.E6;
when 7 => return RC.E7;
end case;
else
case N07 (Uns (N) mod 8) is
when 0 => return C.E0;
when 1 => return C.E1;
when 2 => return C.E2;
when 3 => return C.E3;
when 4 => return C.E4;
when 5 => return C.E5;
when 6 => return C.E6;
when 7 => return C.E7;
end case;
end if;
end Get_21;
------------
-- Set_21 --
------------
procedure Set_21
(Arr : System.Address;
N : Natural;
E : Bits_21;
Rev_SSO : Boolean)
is
A : constant System.Address := Arr + Bits * Ofs (Uns (N) / 8);
C : Cluster_Ref with Address => A'Address, Import;
RC : Rev_Cluster_Ref with Address => A'Address, Import;
begin
if Rev_SSO then
case N07 (Uns (N) mod 8) is
when 0 => RC.E0 := E;
when 1 => RC.E1 := E;
when 2 => RC.E2 := E;
when 3 => RC.E3 := E;
when 4 => RC.E4 := E;
when 5 => RC.E5 := E;
when 6 => RC.E6 := E;
when 7 => RC.E7 := E;
end case;
else
case N07 (Uns (N) mod 8) is
when 0 => C.E0 := E;
when 1 => C.E1 := E;
when 2 => C.E2 := E;
when 3 => C.E3 := E;
when 4 => C.E4 := E;
when 5 => C.E5 := E;
when 6 => C.E6 := E;
when 7 => C.E7 := E;
end case;
end if;
end Set_21;
end System.Pack_21;
|
sungyeon/drake | Ada | 8,484 | ads | pragma License (Unrestricted);
-- extended unit
with Ada.Iterator_Interfaces;
-- diff (Copy_On_Write)
private with Ada.Containers.Hash_Tables;
private with Ada.Finalization;
private with Ada.Streams;
generic
type Key_Type (<>) is limited private;
type Element_Type (<>) is limited private;
with function Hash (Key : Key_Type) return Hash_Type;
with function Equivalent_Keys (Left, Right : Key_Type) return Boolean;
-- diff ("=")
package Ada.Containers.Limited_Hashed_Maps is
pragma Preelaborate;
pragma Remote_Types;
type Map is tagged limited private
with
Constant_Indexing => Constant_Reference,
Variable_Indexing => Reference,
Default_Iterator => Iterate,
Iterator_Element => Element_Type;
pragma Preelaborable_Initialization (Map);
type Cursor is private;
pragma Preelaborable_Initialization (Cursor);
-- diff
-- Empty_Map : constant Map;
function Empty_Map return Map;
No_Element : constant Cursor;
function Has_Element (Position : Cursor) return Boolean;
package Map_Iterator_Interfaces is
new Iterator_Interfaces (Cursor, Has_Element);
-- diff ("=")
function Capacity (Container : Map) return Count_Type;
procedure Reserve_Capacity (
Container : in out Map;
Capacity : Count_Type);
function Length (Container : Map) return Count_Type;
function Is_Empty (Container : Map) return Boolean;
procedure Clear (Container : in out Map);
type Key_Reference_Type (
Element : not null access constant Key_Type) is private
with Implicit_Dereference => Element;
function Key (Position : Cursor) return Key_Reference_Type;
-- diff (Element)
-- diff (Replace_Element)
--
--
--
procedure Query_Element (
Position : Cursor;
Process : not null access procedure (
Key : Key_Type;
Element : Element_Type));
-- modified
procedure Update_Element (
Container : in out Map'Class; -- not primitive
Position : Cursor;
Process : not null access procedure (
Key : Key_Type;
Element : in out Element_Type));
type Constant_Reference_Type (
Element : not null access constant Element_Type) is private
with Implicit_Dereference => Element;
type Reference_Type (Element : not null access Element_Type) is private
with Implicit_Dereference => Element;
function Constant_Reference (Container : aliased Map; Position : Cursor)
return Constant_Reference_Type;
function Reference (Container : aliased in out Map; Position : Cursor)
return Reference_Type;
function Constant_Reference (Container : aliased Map; Key : Key_Type)
return Constant_Reference_Type;
function Reference (Container : aliased in out Map; Key : Key_Type)
return Reference_Type;
-- diff (Assign)
-- diff (Copy)
procedure Move (Target : in out Map; Source : in out Map);
procedure Insert (
Container : in out Map'Class;
New_Key : not null access function return Key_Type;
New_Item : not null access function return Element_Type;
Position : out Cursor;
Inserted : out Boolean);
-- diff (Insert)
--
--
--
--
procedure Insert (
Container : in out Map'Class;
Key : not null access function return Key_Type;
New_Item : not null access function return Element_Type);
-- diff (Include)
--
--
--
-- diff (Replace)
--
--
--
procedure Exclude (Container : in out Map; Key : Key_Type);
procedure Delete (Container : in out Map; Key : Key_Type);
procedure Delete (Container : in out Map; Position : in out Cursor);
function First (Container : Map) return Cursor;
function Next (Position : Cursor) return Cursor;
procedure Next (Position : in out Cursor);
function Find (Container : Map; Key : Key_Type) return Cursor;
-- diff (Element)
--
--
--
--
function Contains (Container : Map; Key : Key_Type) return Boolean;
function Equivalent_Keys (Left, Right : Cursor) return Boolean;
function Equivalent_Keys (Left : Cursor; Right : Key_Type) return Boolean;
function Equivalent_Keys (Left : Key_Type; Right : Cursor) return Boolean;
-- modified
procedure Iterate (
Container : Map'Class; -- not primitive
Process : not null access procedure (Position : Cursor));
-- modified
function Iterate (Container : Map'Class) -- not primitive
return Map_Iterator_Interfaces.Forward_Iterator'Class;
-- extended
generic
with function "=" (Left, Right : Element_Type) return Boolean is <>;
package Equivalent is
function "=" (Left, Right : Map) return Boolean;
end Equivalent;
private
type Key_Access is access Key_Type;
type Element_Access is access Element_Type;
type Node is limited record
Super : aliased Hash_Tables.Node;
Key : Key_Access;
Element : Element_Access;
end record;
-- place Super at first whether Element_Type is controlled-type
for Node use record
Super at 0 range 0 .. Hash_Tables.Node_Size - 1;
end record;
-- diff (Data)
--
--
--
--
-- diff (Data_Access)
type Map is limited new Finalization.Limited_Controlled with record
Table : Hash_Tables.Table_Access;
Length : Count_Type := 0;
end record;
-- diff (Adjust)
overriding procedure Finalize (Object : in out Map)
renames Clear;
type Cursor is access Node;
type Key_Reference_Type (
Element : not null access constant Key_Type) is null record;
type Constant_Reference_Type (
Element : not null access constant Element_Type) is null record;
type Reference_Type (Element : not null access Element_Type) is null record;
type Map_Access is access constant Map;
for Map_Access'Storage_Size use 0;
type Map_Iterator is
new Map_Iterator_Interfaces.Forward_Iterator with
record
First : Cursor;
end record;
overriding function First (Object : Map_Iterator) return Cursor;
overriding function Next (Object : Map_Iterator; Position : Cursor)
return Cursor;
package Streaming is
-- diff (Read)
--
--
-- diff (Write)
--
--
procedure Missing_Read (
Stream : access Streams.Root_Stream_Type'Class;
Item : out Cursor)
with Import,
Convention => Ada, External_Name => "__drake_program_error";
procedure Missing_Write (
Stream : access Streams.Root_Stream_Type'Class;
Item : Cursor)
with Import,
Convention => Ada, External_Name => "__drake_program_error";
procedure Missing_Read (
Stream : access Streams.Root_Stream_Type'Class;
Item : out Key_Reference_Type)
with Import,
Convention => Ada, External_Name => "__drake_program_error";
procedure Missing_Write (
Stream : access Streams.Root_Stream_Type'Class;
Item : Key_Reference_Type)
with Import,
Convention => Ada, External_Name => "__drake_program_error";
procedure Missing_Read (
Stream : access Streams.Root_Stream_Type'Class;
Item : out Constant_Reference_Type)
with Import,
Convention => Ada, External_Name => "__drake_program_error";
procedure Missing_Write (
Stream : access Streams.Root_Stream_Type'Class;
Item : Constant_Reference_Type)
with Import,
Convention => Ada, External_Name => "__drake_program_error";
procedure Missing_Read (
Stream : access Streams.Root_Stream_Type'Class;
Item : out Reference_Type)
with Import,
Convention => Ada, External_Name => "__drake_program_error";
procedure Missing_Write (
Stream : access Streams.Root_Stream_Type'Class;
Item : Reference_Type)
with Import,
Convention => Ada, External_Name => "__drake_program_error";
end Streaming;
-- diff ('Read)
-- diff ('Write)
for Cursor'Read use Streaming.Missing_Read;
for Cursor'Write use Streaming.Missing_Write;
for Key_Reference_Type'Read use Streaming.Missing_Read;
for Key_Reference_Type'Write use Streaming.Missing_Write;
for Constant_Reference_Type'Read use Streaming.Missing_Read;
for Constant_Reference_Type'Write use Streaming.Missing_Write;
for Reference_Type'Read use Streaming.Missing_Read;
for Reference_Type'Write use Streaming.Missing_Write;
No_Element : constant Cursor := null;
end Ada.Containers.Limited_Hashed_Maps;
|
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.Text_Volume_Attributes;
package Matreshka.ODF_Text.Volume_Attributes is
type Text_Volume_Attribute_Node is
new Matreshka.ODF_Text.Abstract_Text_Attribute_Node
and ODF.DOM.Text_Volume_Attributes.ODF_Text_Volume_Attribute
with null record;
overriding function Create
(Parameters : not null access Matreshka.DOM_Attributes.Attribute_L2_Parameters)
return Text_Volume_Attribute_Node;
overriding function Get_Local_Name
(Self : not null access constant Text_Volume_Attribute_Node)
return League.Strings.Universal_String;
end Matreshka.ODF_Text.Volume_Attributes;
|
zhmu/ananas | Ada | 279 | adb | -- { dg-do run }
-- { dg-options "-O2" }
with Ada.Text_IO; use Ada.Text_IO;
procedure Opt80 is
Item : Integer;
begin
Item := Integer'Value ("zzz");
Put_Line (Boolean'Image (Item'Valid));
raise Program_Error;
exception
when Constraint_Error =>
null;
end;
|
charlie5/aIDE | Ada | 1,341 | ads | with
AdaM.Subprogram,
gtk.Widget;
private
with
aIDE.Editor.of_block,
aIDE.Editor.of_context,
gtk.Box,
gtk.Label,
gtk.Alignment,
gtk.GEntry;
package aIDE.Editor.of_subprogram
is
type Item is new Editor.item with private;
type View is access all Item'Class;
package Forge
is
function to_subprogram_Editor (the_Subprogram : in AdaM.Subprogram.view) return View;
end Forge;
overriding
function top_Widget (Self : in Item) return gtk.Widget.Gtk_Widget;
function Target (Self : in Item) return AdaM.Subprogram.view;
procedure Target_is (Self : in out Item; Now : in AdaM.Subprogram.view);
private
use gtk.Box,
gtk.GEntry,
gtk.Label,
gtk.Alignment;
type Item is new Editor.item with
record
Subprogram : AdaM.Subprogram.view; -- TODO: This should be called Target.
top_Box : Gtk_Box;
context_Alignment : Gtk_Alignment;
context_Editor : aIDE.Editor.of_context.view;
procedure_Label : Gtk_Label;
name_Entry : gtk_Entry;
block_Alignment : Gtk_Alignment;
block_Editor : aIDE.Editor.of_block.view;
end record;
overriding
procedure freshen (Self : in out Item);
end aIDE.Editor.of_subprogram;
|
zhmu/ananas | Ada | 151 | ads | with SYSTEM;
WITH array2; use array2;
package array1 is
procedure Foo (R : RIC_TYPE);
procedure Start_Timer (Q : SYSTEM.ADDRESS);
end array1;
|
onox/orka | Ada | 1,032 | ads | -- SPDX-License-Identifier: Apache-2.0
--
-- Copyright (c) 2021 onox <[email protected]>
--
-- Licensed under the Apache License, Version 2.0 (the "License");
-- you may not use this file except in compliance with the License.
-- You may obtain a copy of the License at
--
-- http://www.apache.org/licenses/LICENSE-2.0
--
-- Unless required by applicable law or agreed to in writing, software
-- distributed under the License is distributed on an "AS IS" BASIS,
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-- See the License for the specific language governing permissions and
-- limitations under the License.
package Orka.SIMD.AVX.Longs.Logical is
pragma Pure;
function Test_All_Zero (Elements, Mask : m256l) return Boolean
with Inline_Always;
function Test_All_Ones (Elements, Mask : m256l) return Boolean
with Inline_Always;
function Test_Mix_Ones_Zeros (Elements, Mask : m256l) return Boolean
with Inline_Always;
end Orka.SIMD.AVX.Longs.Logical;
|
guillaume-lin/tsc | Ada | 11,073 | ads | ------------------------------------------------------------------------------
-- --
-- GNAT ncurses Binding --
-- --
-- Terminal_Interface.Curses.Mouse --
-- --
-- S P E C --
-- --
------------------------------------------------------------------------------
-- Copyright (c) 1998 Free Software Foundation, Inc. --
-- --
-- Permission is hereby granted, free of charge, to any person obtaining a --
-- copy of this software and associated documentation files (the --
-- "Software"), to deal in the Software without restriction, including --
-- without limitation the rights to use, copy, modify, merge, publish, --
-- distribute, distribute with modifications, sublicense, and/or sell --
-- copies of the Software, and to permit persons to whom the Software is --
-- furnished to do so, subject to the following conditions: --
-- --
-- The above copyright notice and this permission notice shall be included --
-- in all copies or substantial portions of the Software. --
-- --
-- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS --
-- OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF --
-- MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. --
-- IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, --
-- DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR --
-- OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR --
-- THE USE OR OTHER DEALINGS IN THE SOFTWARE. --
-- --
-- Except as contained in this notice, the name(s) of the above copyright --
-- holders shall not be used in advertising or otherwise to promote the --
-- sale, use or other dealings in this Software without prior written --
-- authorization. --
------------------------------------------------------------------------------
-- Author: Juergen Pfeifer, 1996
-- Version Control:
-- $Revision: 1.22 $
-- Binding Version 01.00
------------------------------------------------------------------------------
-- mouse binding.
-- This module is generated. Please don't change it manually!
-- Run the generator instead.
-- |
with System;
package Terminal_Interface.Curses.Mouse is
pragma Preelaborate (Terminal_Interface.Curses.Mouse);
-- |=====================================================================
-- | Man page curs_mouse.3x
-- |=====================================================================
-- Please note, that in ncurses-1.9.9e documentation mouse support
-- is still marked as experimental. So also this binding will change
-- if the ncurses methods change.
--
-- mouse_trafo, wmouse_trafo are implemented as Transform_Coordinates
-- in the parent package.
--
-- Not implemented:
-- REPORT_MOUSE_POSITION (i.e. as a parameter to Register_Reportable_Event
-- or Start_Mouse)
type Event_Mask is private;
No_Events : constant Event_Mask;
All_Events : constant Event_Mask;
type Mouse_Button is (Left, -- aka: Button 1
Middle, -- aka: Button 2
Right, -- aka: Button 3
Button4, -- aka: Button 4
Control, -- Control Key
Shift, -- Shift Key
Alt); -- ALT Key
subtype Real_Buttons is Mouse_Button range Left .. Button4;
subtype Modifier_Keys is Mouse_Button range Control .. Alt;
type Button_State is (Released,
Pressed,
Clicked,
Double_Clicked,
Triple_Clicked);
type Button_States is array (Button_State) of Boolean;
pragma Pack (Button_States);
All_Clicks : constant Button_States := (Clicked .. Triple_Clicked => True,
others => False);
All_States : constant Button_States := (others => True);
type Mouse_Event is private;
-- |=====================================================================
-- | Man page curs_mouse.3x
-- |=====================================================================
function Has_Mouse return Boolean;
-- Return true if a mouse device is supported, false otherwise.
procedure Register_Reportable_Event
(Button : in Mouse_Button;
State : in Button_State;
Mask : in out Event_Mask);
-- Stores the event described by the button and the state in the mask.
-- Before you call this the first time, you should init the mask
-- with the Empty_Mask constant
pragma Inline (Register_Reportable_Event);
procedure Register_Reportable_Events
(Button : in Mouse_Button;
State : in Button_States;
Mask : in out Event_Mask);
-- Register all events described by the Button and the State bitmap.
-- Before you call this the first time, you should init the mask
-- with the Empty_Mask constant
-- |
-- There is one difference to mousmask(): we return the value of the
-- old mask, that means the event mask value before this call.
-- Not Implemented: The library version
-- returns a Mouse_Mask that tells which events are reported.
function Start_Mouse (Mask : Event_Mask := All_Events)
return Event_Mask;
-- AKA: mousemask()
pragma Inline (Start_Mouse);
procedure End_Mouse (Mask : in Event_Mask := No_Events);
-- Terminates the mouse, restores the specified event mask
pragma Inline (End_Mouse);
-- |
function Get_Mouse return Mouse_Event;
-- AKA: getmouse()
pragma Inline (Get_Mouse);
procedure Get_Event (Event : in Mouse_Event;
Y : out Line_Position;
X : out Column_Position;
Button : out Mouse_Button;
State : out Button_State);
-- !!! Warning: X and Y are screen coordinates. Due to ripped of lines they
-- may not be identical to window coordinates.
-- Not Implemented: Get_Event only reports one event, the C library
-- version supports multiple events, e.g. {click-1, click-3}
pragma Inline (Get_Event);
-- |
procedure Unget_Mouse (Event : in Mouse_Event);
-- AKA: ungetmouse()
pragma Inline (Unget_Mouse);
-- |
function Enclosed_In_Window (Win : Window := Standard_Window;
Event : Mouse_Event) return Boolean;
-- AKA: wenclose()
-- But : use event instead of screen coordinates.
pragma Inline (Enclosed_In_Window);
-- |
function Mouse_Interval (Msec : Natural := 200) return Natural;
-- AKA: mouseinterval()
pragma Inline (Mouse_Interval);
private
type Event_Mask is new Interfaces.C.unsigned_long;
type Mouse_Event is
record
Id : Integer range Integer (Interfaces.C.short'First) ..
Integer (Interfaces.C.short'Last);
X, Y, Z : Integer range Integer (Interfaces.C.int'First) ..
Integer (Interfaces.C.int'Last);
Bstate : Event_Mask;
end record;
pragma Convention (C, Mouse_Event);
pragma Pack (Mouse_Event);
for Mouse_Event use
record
Id at 0 range 0 .. 15;
X at 0 range 32 .. 63;
Y at 0 range 64 .. 95;
Z at 0 range 96 .. 127;
Bstate at 0 range 128 .. 159;
end record;
-- Please note: this rep. clause is generated and may be
-- different on your system.
Generation_Bit_Order : constant System.Bit_Order := System.Low_Order_First;
-- This constant may be different on your system.
BUTTON1_RELEASED : constant Event_Mask := 8#00000000001#;
BUTTON1_PRESSED : constant Event_Mask := 8#00000000002#;
BUTTON1_CLICKED : constant Event_Mask := 8#00000000004#;
BUTTON1_DOUBLE_CLICKED : constant Event_Mask := 8#00000000010#;
BUTTON1_TRIPLE_CLICKED : constant Event_Mask := 8#00000000020#;
BUTTON1_RESERVED_EVENT : constant Event_Mask := 8#00000000040#;
BUTTON2_RELEASED : constant Event_Mask := 8#00000000100#;
BUTTON2_PRESSED : constant Event_Mask := 8#00000000200#;
BUTTON2_CLICKED : constant Event_Mask := 8#00000000400#;
BUTTON2_DOUBLE_CLICKED : constant Event_Mask := 8#00000001000#;
BUTTON2_TRIPLE_CLICKED : constant Event_Mask := 8#00000002000#;
BUTTON2_RESERVED_EVENT : constant Event_Mask := 8#00000004000#;
BUTTON3_RELEASED : constant Event_Mask := 8#00000010000#;
BUTTON3_PRESSED : constant Event_Mask := 8#00000020000#;
BUTTON3_CLICKED : constant Event_Mask := 8#00000040000#;
BUTTON3_DOUBLE_CLICKED : constant Event_Mask := 8#00000100000#;
BUTTON3_TRIPLE_CLICKED : constant Event_Mask := 8#00000200000#;
BUTTON3_RESERVED_EVENT : constant Event_Mask := 8#00000400000#;
BUTTON4_RELEASED : constant Event_Mask := 8#00001000000#;
BUTTON4_PRESSED : constant Event_Mask := 8#00002000000#;
BUTTON4_CLICKED : constant Event_Mask := 8#00004000000#;
BUTTON4_DOUBLE_CLICKED : constant Event_Mask := 8#00010000000#;
BUTTON4_TRIPLE_CLICKED : constant Event_Mask := 8#00020000000#;
BUTTON4_RESERVED_EVENT : constant Event_Mask := 8#00040000000#;
BUTTON_CTRL : constant Event_Mask := 8#00100000000#;
BUTTON_SHIFT : constant Event_Mask := 8#00200000000#;
BUTTON_ALT : constant Event_Mask := 8#00400000000#;
REPORT_MOUSE_POSITION : constant Event_Mask := 8#01000000000#;
ALL_MOUSE_EVENTS : constant Event_Mask := 8#00777777777#;
BUTTON1_EVENTS : constant Event_Mask := 8#00000000077#;
BUTTON2_EVENTS : constant Event_Mask := 8#00000007700#;
BUTTON3_EVENTS : constant Event_Mask := 8#00000770000#;
BUTTON4_EVENTS : constant Event_Mask := 8#00077000000#;
No_Events : constant Event_Mask := 0;
All_Events : constant Event_Mask := ALL_MOUSE_EVENTS;
end Terminal_Interface.Curses.Mouse;
|
annexi-strayline/AURA | Ada | 4,190 | adb | ------------------------------------------------------------------------------
-- --
-- Ada User Repository Annex (AURA) --
-- Reference Implementation --
-- --
-- ------------------------------------------------------------------------ --
-- --
-- Copyright (C) 2020-2023, ANNEXI-STRAYLINE Trans-Human Ltd. --
-- All rights reserved. --
-- --
-- Original Contributors: --
-- * Richard Wai (ANNEXI-STRAYLINE) --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions are --
-- met: --
-- --
-- * Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- --
-- * Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in --
-- the documentation and/or other materials provided with the --
-- distribution. --
-- --
-- * Neither the name of 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 --
-- OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT --
-- LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, --
-- DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY --
-- THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT --
-- (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE --
-- OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
-- --
------------------------------------------------------------------------------
separate (Repositories.AURA_Spec_Handling.Check_AURA_Spec)
procedure Check_Package_Completion is
begin
Next_Element;
Check (Test => Category = Reserved_Word and then Content = "end",
Fail_Message => "AURA package shall only contain the Repository_Format "
& "type declaration, and the Platform information constants.");
if not Correct then return; end if;
Next_Element;
if Category = Identifier then
Check (Test => Content = "aura",
Fail_Message => "Package name mismatch - should be AURA");
end if;
if not Correct then return; end if;
Next_Element;
Check (Test => Category = Delimiter and then Content = ";",
Fail_Message => "Syntax error at end of package - expected "";"" "
& "following ""end""");
end Check_Package_Completion;
|
LionelDraghi/smk | Ada | 1,565 | ads | pragma Ada_2005;
pragma Style_Checks (Off);
with Interfaces.C; use Interfaces.C;
package linux_posix_types_h is
-- SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note
-- * This allows for 1024 file descriptors: if NR_OPEN is ever grown
-- * beyond that you'll have to change this too. But 1024 fd's seem to be
-- * enough even for such "real" unices like OSF/1, so hopefully this is
-- * one limit that doesn't have to be changed [again].
-- *
-- * Note that POSIX wants the FD_CLEAR(fd,fdsetp) defines to be in
-- * <sys/time.h> (and thus <linux/time.h>) - but this is a more logical
-- * place for them. Solved by having dummy defines in <sys/time.h>.
--
-- * This macro may have been defined in <gnu/types.h>. But we always
-- * use the one here.
--
type uu_kernel_fd_set_fds_bits_array is array (0 .. 15) of aliased unsigned_long;
type uu_kernel_fd_set is record
fds_bits : aliased uu_kernel_fd_set_fds_bits_array; -- /usr/include/linux/posix_types.h:26
end record;
pragma Convention (C_Pass_By_Copy, uu_kernel_fd_set); -- /usr/include/linux/posix_types.h:27
-- skipped anonymous struct anon_0
-- Type of a signal handler.
type uu_kernel_sighandler_t is access procedure (arg1 : int);
pragma Convention (C, uu_kernel_sighandler_t); -- /usr/include/linux/posix_types.h:30
-- Type of a SYSV IPC key.
subtype uu_kernel_key_t is int; -- /usr/include/linux/posix_types.h:33
subtype uu_kernel_mqd_t is int; -- /usr/include/linux/posix_types.h:34
end linux_posix_types_h;
|
JeremyGrosser/clock3 | Ada | 1,643 | adb | package body HT16K33 is
procedure Initialize
(This : in out Device)
is
Oscillator_On : I2C_Data (1 .. 1) := (1 => 16#21#);
Display_On : I2C_Data (1 .. 1) := (1 => 16#81#);
Row_Output : I2C_Data (1 .. 1) := (1 => 16#A0#);
Status : I2C_Status;
begin
This.Port.Master_Transmit (This.Address, Oscillator_On, Status);
This.Port.Master_Transmit (This.Address, Display_On, Status);
This.Port.Master_Transmit (This.Address, Row_Output, Status);
Set_Brightness (This, Brightness_Level'Last);
Update (This);
end Initialize;
procedure Set_Brightness
(This : in out Device;
Level : Brightness_Level)
is
Data : I2C_Data (1 .. 1) := (1 => 16#E0# or Level);
Status : I2C_Status;
begin
This.Port.Master_Transmit (This.Address, Data, Status);
end Set_Brightness;
procedure Update
(This : in out Device)
is
Status : I2C_Status;
begin
This.Port.Master_Transmit (This.Address, This.Buffer, Status);
end Update;
procedure Set
(This : in out Device;
Num : Output_Index)
is
Index : Positive := (Num / 8) + 1;
begin
This.Buffer (Index) := This.Buffer (Index) or Shift_Left (1, Num mod 8);
end Set;
procedure Clear
(This : in out Device;
Num : Output_Index)
is
Index : Positive := (Num / 8) + 1;
begin
This.Buffer (Index) := This.Buffer (Index) and not Shift_Left (1, Num mod 8);
end Clear;
procedure Clear_All
(This : in out Device)
is
begin
This.Buffer := (others => 0);
end Clear_All;
end HT16K33;
|
zhmu/ananas | Ada | 4,568 | adb | ------------------------------------------------------------------------------
-- --
-- GNAT RUN-TIME LIBRARY COMPONENTS --
-- --
-- S Y S T E M . C O M P A R E _ A R R A Y _ S I G N E D _ 1 2 8 --
-- --
-- B o d y --
-- --
-- Copyright (C) 2002-2022, Free Software Foundation, Inc. --
-- --
-- GNAT is free software; you can redistribute it and/or modify it under --
-- terms of the GNU General Public License as published by the Free Soft- --
-- ware Foundation; either version 3, or (at your option) any later ver- --
-- sion. GNAT is distributed in the hope that it will be useful, but WITH- --
-- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY --
-- or FITNESS FOR A PARTICULAR PURPOSE. --
-- --
-- As a special exception under Section 7 of GPL version 3, you are granted --
-- additional permissions described in the GCC Runtime Library Exception, --
-- version 3.1, as published by the Free Software Foundation. --
-- --
-- You should have received a copy of the GNU General Public License and --
-- a copy of the GCC Runtime Library Exception along with this program; --
-- see the files COPYING3 and COPYING.RUNTIME respectively. If not, see --
-- <http://www.gnu.org/licenses/>. --
-- --
-- GNAT was originally developed by the GNAT team at New York University. --
-- Extensive contributions were provided by Ada Core Technologies Inc. --
-- --
------------------------------------------------------------------------------
with System.Address_Operations; use System.Address_Operations;
with Ada.Unchecked_Conversion;
package body System.Compare_Array_Signed_128 is
type Word is range -2**127 .. 2**127 - 1;
for Word'Size use 128;
-- Used to process operands by 128-bit words
type Uword is new Word;
for Uword'Alignment use 1;
-- Used to process operands when unaligned
type WP is access Word;
type UP is access Uword;
function W is new Ada.Unchecked_Conversion (Address, WP);
function U is new Ada.Unchecked_Conversion (Address, UP);
------------------------
-- Compare_Array_S128 --
------------------------
function Compare_Array_S128
(Left : System.Address;
Right : System.Address;
Left_Len : Natural;
Right_Len : Natural) return Integer
is
Clen : Natural := Natural'Min (Left_Len, Right_Len);
-- Number of elements left to compare
L : Address := Left;
R : Address := Right;
-- Pointers to next elements to compare
begin
-- Case of going by aligned quadruple words
if ModA (OrA (Left, Right), 16) = 0 then
while Clen /= 0 loop
if W (L).all /= W (R).all then
if W (L).all > W (R).all then
return +1;
else
return -1;
end if;
end if;
Clen := Clen - 1;
L := AddA (L, 16);
R := AddA (R, 16);
end loop;
-- Case of going by unaligned quadruple words
else
while Clen /= 0 loop
if U (L).all /= U (R).all then
if U (L).all > U (R).all then
return +1;
else
return -1;
end if;
end if;
Clen := Clen - 1;
L := AddA (L, 16);
R := AddA (R, 16);
end loop;
end if;
-- Here if common section equal, result decided by lengths
if Left_Len = Right_Len then
return 0;
elsif Left_Len > Right_Len then
return +1;
else
return -1;
end if;
end Compare_Array_S128;
end System.Compare_Array_Signed_128;
|
ohenley/ada-util | Ada | 9,028 | adb | -----------------------------------------------------------------------
-- log.tests -- Unit tests for loggers
-- Copyright (C) 2009, 2010, 2011, 2013, 2015 Stephane Carrez
-- Written by Stephane Carrez ([email protected])
--
-- Licensed under the Apache License, Version 2.0 (the "License");
-- you may not use this file except in compliance with the License.
-- You may obtain a copy of the License at
--
-- http://www.apache.org/licenses/LICENSE-2.0
--
-- Unless required by applicable law or agreed to in writing, software
-- distributed under the License is distributed on an "AS IS" BASIS,
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-- See the License for the specific language governing permissions and
-- limitations under the License.
-----------------------------------------------------------------------
with Ada.Strings.Fixed;
with Ada.Directories;
with Util.Test_Caller;
with Util.Log;
with Util.Log.Loggers;
with Util.Properties;
with Util.Measures;
package body Util.Log.Tests is
use Util;
Log : constant Loggers.Logger := Loggers.Create ("util.log.test");
procedure Test_Log (T : in out Test) is
pragma Unreferenced (T);
L : Loggers.Logger := Loggers.Create ("util.log.test.debug");
begin
L.Set_Level (DEBUG_LEVEL);
Log.Info ("My log message");
Log.Error ("My error message");
Log.Debug ("A debug message Not printed");
L.Info ("An info message");
L.Debug ("A debug message on logger 'L'");
end Test_Log;
-- Test configuration and creation of file
procedure Test_File_Appender (T : in out Test) is
pragma Unreferenced (T);
Props : Util.Properties.Manager;
begin
Props.Set ("log4j.appender.test", "File");
Props.Set ("log4j.appender.test.File", "test.log");
Props.Set ("log4j.logger.util.log.test.file", "DEBUG,test");
Util.Log.Loggers.Initialize (Props);
declare
L : constant Loggers.Logger := Loggers.Create ("util.log.test.file");
begin
L.Debug ("Writing a debug message");
L.Debug ("{0}: {1}", "Parameter", "Value");
end;
end Test_File_Appender;
procedure Test_Log_Perf (T : in out Test) is
pragma Unreferenced (T);
Props : Util.Properties.Manager;
begin
Props.Set ("log4j.appender.test", "File");
Props.Set ("log4j.appender.test.File", "test.log");
Props.Set ("log4j.logger.util.log.test.perf", "DEBUG,test");
Util.Log.Loggers.Initialize (Props);
for I in 1 .. 1000 loop
declare
S : Util.Measures.Stamp;
begin
Util.Measures.Report (S, "Util.Measures.Report", 1000);
end;
end loop;
declare
L : Loggers.Logger := Loggers.Create ("util.log.test.perf");
S : Util.Measures.Stamp;
begin
L.Set_Level (DEBUG_LEVEL);
for I in 1 .. 1000 loop
L.Info ("My log message: {0}: {1}", "A message",
"A second parameter");
end loop;
Util.Measures.Report (S, "Log.Info message (output)", 1000);
L.Set_Level (INFO_LEVEL);
for I in 1 .. 10_000 loop
L.Debug ("My log message: {0}: {1}", "A message",
"A second parameter");
end loop;
Util.Measures.Report (S, "Log.Debug message (no output)", 10_000);
end;
end Test_Log_Perf;
-- ------------------------------
-- Test appending the log on several log files
-- ------------------------------
procedure Test_List_Appender (T : in out Test) is
use Ada.Strings;
use Ada.Directories;
Props : Util.Properties.Manager;
begin
for I in 1 .. 10 loop
declare
Id : constant String := Fixed.Trim (Integer'Image (I), Both);
Name : constant String := "log4j.appender.test" & Id;
begin
Props.Set (Name, "File");
Props.Set (Name & ".File", "test" & Id & ".log");
Props.Set (Name & ".layout", "date-level-message");
if I > 5 then
Props.Set (Name & ".level", "INFO");
end if;
end;
end loop;
Props.Set ("log4j.rootCategory", "DEBUG, test.log");
Props.Set ("log4j.logger.util.log.test.file",
"DEBUG,test4,test1 , test2,test3, test4, test5 , test6 , test7,test8,");
Util.Log.Loggers.Initialize (Props);
declare
L : constant Loggers.Logger := Loggers.Create ("util.log.test.file");
begin
L.Debug ("Writing a debug message");
L.Debug ("{0}: {1}", "Parameter", "Value");
L.Debug ("Done");
end;
-- Check that we have non empty log files (up to test8.log).
for I in 1 .. 8 loop
declare
Id : constant String := Fixed.Trim (Integer'Image (I), Both);
Path : constant String := "test" & Id & ".log";
begin
T.Assert (Ada.Directories.Exists (Path), "Log file " & Path & " not found");
if I > 5 then
T.Assert (Ada.Directories.Size (Path) < 100, "Log file "
& Path & " should be empty");
else
T.Assert (Ada.Directories.Size (Path) > 100, "Log file " & Path & " is empty");
end if;
end;
end loop;
end Test_List_Appender;
-- ------------------------------
-- Test file appender with different modes.
-- ------------------------------
procedure Test_File_Appender_Modes (T : in out Test) is
use Ada.Directories;
Props : Util.Properties.Manager;
begin
Props.Set ("log4j.appender.test", "File");
Props.Set ("log4j.appender.test.File", "test-append.log");
Props.Set ("log4j.appender.test.append", "true");
Props.Set ("log4j.appender.test.immediateFlush", "true");
Props.Set ("log4j.appender.test_global", "File");
Props.Set ("log4j.appender.test_global.File", "test-append-global.log");
Props.Set ("log4j.appender.test_global.append", "false");
Props.Set ("log4j.appender.test_global.immediateFlush", "false");
Props.Set ("log4j.logger.util.log.test.file", "DEBUG");
Props.Set ("log4j.rootCategory", "DEBUG,test_global,test");
Util.Log.Loggers.Initialize (Props);
declare
L : constant Loggers.Logger := Loggers.Create ("util.log.test.file");
begin
L.Debug ("Writing a debug message");
L.Debug ("{0}: {1}", "Parameter", "Value");
L.Debug ("Done");
L.Error ("This is the error test message");
end;
Props.Set ("log4j.appender.test_append", "File");
Props.Set ("log4j.appender.test_append.File", "test-append2.log");
Props.Set ("log4j.appender.test_append.append", "true");
Props.Set ("log4j.appender.test_append.immediateFlush", "true");
Props.Set ("log4j.logger.util.log.test2.file", "DEBUG,test_append,test_global");
Util.Log.Loggers.Initialize (Props);
declare
L1 : constant Loggers.Logger := Loggers.Create ("util.log.test.file");
L2 : constant Loggers.Logger := Loggers.Create ("util.log.test2.file");
begin
L1.Info ("L1-1 Writing a info message");
L2.Info ("L2-2 {0}: {1}", "Parameter", "Value");
L1.Info ("L1-3 Done");
L2.Error ("L2-4 This is the error test2 message");
end;
Props.Set ("log4j.appender.test_append.append", "plop");
Props.Set ("log4j.appender.test_append.immediateFlush", "falsex");
Props.Set ("log4j.rootCategory", "DEBUG, test.log");
Util.Log.Loggers.Initialize (Props);
T.Assert (Ada.Directories.Size ("test-append.log") > 100,
"Log file test-append.log is empty");
T.Assert (Ada.Directories.Size ("test-append2.log") > 100,
"Log file test-append2.log is empty");
T.Assert (Ada.Directories.Size ("test-append-global.log") > 100,
"Log file test-append.log is empty");
end Test_File_Appender_Modes;
package Caller is new Util.Test_Caller (Test, "Log");
procedure Add_Tests (Suite : in Util.Tests.Access_Test_Suite) is
begin
Caller.Add_Test (Suite, "Test Util.Log.Loggers.Info",
Test_Log'Access);
Caller.Add_Test (Suite, "Test Util.Log.Loggers.Debug",
Test_Log'Access);
Caller.Add_Test (Suite, "Test Util.Log.Loggers.Set_Level",
Test_Log'Access);
Caller.Add_Test (Suite, "Test Util.Log.Appenders.File_Appender",
Test_File_Appender'Access);
Caller.Add_Test (Suite, "Test Util.Log.Appenders.File_Appender (append)",
Test_File_Appender_Modes'Access);
Caller.Add_Test (Suite, "Test Util.Log.Appenders.List_Appender",
Test_List_Appender'Access);
Caller.Add_Test (Suite, "Test Util.Log.Loggers.Log (Perf)",
Test_Log_Perf'Access);
end Add_Tests;
end Util.Log.Tests;
|
reznikmm/matreshka | Ada | 36,968 | ads | ------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- Ada Modeling Framework --
-- --
-- Runtime Library Component --
-- --
------------------------------------------------------------------------------
-- --
-- Copyright © 2011-2012, Vadim Godunko <[email protected]> --
-- All rights reserved. --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions --
-- are met: --
-- --
-- * Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- --
-- * Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in the --
-- documentation and/or other materials provided with the distribution. --
-- --
-- * Neither the name of the Vadim Godunko, IE nor the names of its --
-- contributors may be used to endorse or promote products derived from --
-- this software without specific prior written permission. --
-- --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR --
-- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
-- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED --
-- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR --
-- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF --
-- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING --
-- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS --
-- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
-- --
------------------------------------------------------------------------------
-- $Revision$ $Date$
------------------------------------------------------------------------------
with AMF.Internals.UML_Properties;
with AMF.UML.Associations;
with AMF.UML.Classes;
with AMF.UML.Classifiers.Collections;
with AMF.UML.Connectable_Element_Template_Parameters;
with AMF.UML.Connector_Ends.Collections;
with AMF.UML.Data_Types;
with AMF.UML.Dependencies.Collections;
with AMF.UML.Deployments.Collections;
with AMF.UML.Interfaces.Collections;
with AMF.UML.Multiplicity_Elements;
with AMF.UML.Named_Elements;
with AMF.UML.Namespaces;
with AMF.UML.Packageable_Elements.Collections;
with AMF.UML.Packages.Collections;
with AMF.UML.Parameterable_Elements;
with AMF.UML.Ports.Collections;
with AMF.UML.Properties.Collections;
with AMF.UML.Protocol_State_Machines;
with AMF.UML.Redefinable_Elements.Collections;
with AMF.UML.String_Expressions;
with AMF.UML.Template_Parameters;
with AMF.UML.Types.Collections;
with AMF.UML.Value_Specifications;
with AMF.Visitors;
package AMF.Internals.UML_Ports is
type UML_Port_Proxy is
limited new AMF.Internals.UML_Properties.UML_Property_Proxy
and AMF.UML.Ports.UML_Port with null record;
overriding function Get_Is_Behavior
(Self : not null access constant UML_Port_Proxy)
return Boolean;
-- Getter of Port::isBehavior.
--
-- Specifies whether requests arriving at this port are sent to the
-- classifier behavior of this classifier. Such ports are referred to as
-- behavior port. Any invocation of a behavioral feature targeted at a
-- behavior port will be handled by the instance of the owning classifier
-- itself, rather than by any instances that this classifier may contain.
overriding procedure Set_Is_Behavior
(Self : not null access UML_Port_Proxy;
To : Boolean);
-- Setter of Port::isBehavior.
--
-- Specifies whether requests arriving at this port are sent to the
-- classifier behavior of this classifier. Such ports are referred to as
-- behavior port. Any invocation of a behavioral feature targeted at a
-- behavior port will be handled by the instance of the owning classifier
-- itself, rather than by any instances that this classifier may contain.
overriding function Get_Is_Conjugated
(Self : not null access constant UML_Port_Proxy)
return Boolean;
-- Getter of Port::isConjugated.
--
-- Specifies the way that the provided and required interfaces are derived
-- from the Port’s Type. The default value is false.
overriding procedure Set_Is_Conjugated
(Self : not null access UML_Port_Proxy;
To : Boolean);
-- Setter of Port::isConjugated.
--
-- Specifies the way that the provided and required interfaces are derived
-- from the Port’s Type. The default value is false.
overriding function Get_Is_Service
(Self : not null access constant UML_Port_Proxy)
return Boolean;
-- Getter of Port::isService.
--
-- If true indicates that this port is used to provide the published
-- functionality of a classifier; if false, this port is used to implement
-- the classifier but is not part of the essential externally-visible
-- functionality of the classifier and can, therefore, be altered or
-- deleted along with the internal implementation of the classifier and
-- other properties that are considered part of its implementation.
overriding procedure Set_Is_Service
(Self : not null access UML_Port_Proxy;
To : Boolean);
-- Setter of Port::isService.
--
-- If true indicates that this port is used to provide the published
-- functionality of a classifier; if false, this port is used to implement
-- the classifier but is not part of the essential externally-visible
-- functionality of the classifier and can, therefore, be altered or
-- deleted along with the internal implementation of the classifier and
-- other properties that are considered part of its implementation.
overriding function Get_Protocol
(Self : not null access constant UML_Port_Proxy)
return AMF.UML.Protocol_State_Machines.UML_Protocol_State_Machine_Access;
-- Getter of Port::protocol.
--
-- References an optional protocol state machine which describes valid
-- interactions at this interaction point.
overriding procedure Set_Protocol
(Self : not null access UML_Port_Proxy;
To : AMF.UML.Protocol_State_Machines.UML_Protocol_State_Machine_Access);
-- Setter of Port::protocol.
--
-- References an optional protocol state machine which describes valid
-- interactions at this interaction point.
overriding function Get_Provided
(Self : not null access constant UML_Port_Proxy)
return AMF.UML.Interfaces.Collections.Set_Of_UML_Interface;
-- Getter of Port::provided.
--
-- References the interfaces specifying the set of operations and
-- receptions that the classifier offers to its environment via this port,
-- and which it will handle either directly or by forwarding it to a part
-- of its internal structure. This association is derived according to the
-- value of isConjugated. If isConjugated is false, provided is derived as
-- the union of the sets of interfaces realized by the type of the port
-- and its supertypes, or directly from the type of the port if the port
-- is typed by an interface. If isConjugated is true, it is derived as the
-- union of the sets of interfaces used by the type of the port and its
-- supertypes.
overriding function Get_Redefined_Port
(Self : not null access constant UML_Port_Proxy)
return AMF.UML.Ports.Collections.Set_Of_UML_Port;
-- Getter of Port::redefinedPort.
--
-- A port may be redefined when its containing classifier is specialized.
-- The redefining port may have additional interfaces to those that are
-- associated with the redefined port or it may replace an interface by
-- one of its subtypes.
overriding function Get_Required
(Self : not null access constant UML_Port_Proxy)
return AMF.UML.Interfaces.Collections.Set_Of_UML_Interface;
-- Getter of Port::required.
--
-- References the interfaces specifying the set of operations and
-- receptions that the classifier expects its environment to handle via
-- this port. This association is derived according to the value of
-- isConjugated. If isConjugated is false, required is derived as the
-- union of the sets of interfaces used by the type of the port and its
-- supertypes. If isConjugated is true, it is derived as the union of the
-- sets of interfaces realized by the type of the port and its supertypes,
-- or directly from the type of the port if the port is typed by an
-- interface.
overriding function Get_Aggregation
(Self : not null access constant UML_Port_Proxy)
return AMF.UML.UML_Aggregation_Kind;
-- Getter of Property::aggregation.
--
-- Specifies the kind of aggregation that applies to the Property.
overriding procedure Set_Aggregation
(Self : not null access UML_Port_Proxy;
To : AMF.UML.UML_Aggregation_Kind);
-- Setter of Property::aggregation.
--
-- Specifies the kind of aggregation that applies to the Property.
overriding function Get_Association
(Self : not null access constant UML_Port_Proxy)
return AMF.UML.Associations.UML_Association_Access;
-- Getter of Property::association.
--
-- References the association of which this property is a member, if any.
overriding procedure Set_Association
(Self : not null access UML_Port_Proxy;
To : AMF.UML.Associations.UML_Association_Access);
-- Setter of Property::association.
--
-- References the association of which this property is a member, if any.
overriding function Get_Association_End
(Self : not null access constant UML_Port_Proxy)
return AMF.UML.Properties.UML_Property_Access;
-- Getter of Property::associationEnd.
--
-- Designates the optional association end that owns a qualifier attribute.
overriding procedure Set_Association_End
(Self : not null access UML_Port_Proxy;
To : AMF.UML.Properties.UML_Property_Access);
-- Setter of Property::associationEnd.
--
-- Designates the optional association end that owns a qualifier attribute.
overriding function Get_Class
(Self : not null access constant UML_Port_Proxy)
return AMF.UML.Classes.UML_Class_Access;
-- Getter of Property::class.
--
-- References the Class that owns the Property.
-- References the Class that owns the Property.
overriding procedure Set_Class
(Self : not null access UML_Port_Proxy;
To : AMF.UML.Classes.UML_Class_Access);
-- Setter of Property::class.
--
-- References the Class that owns the Property.
-- References the Class that owns the Property.
overriding function Get_Datatype
(Self : not null access constant UML_Port_Proxy)
return AMF.UML.Data_Types.UML_Data_Type_Access;
-- Getter of Property::datatype.
--
-- The DataType that owns this Property.
overriding procedure Set_Datatype
(Self : not null access UML_Port_Proxy;
To : AMF.UML.Data_Types.UML_Data_Type_Access);
-- Setter of Property::datatype.
--
-- The DataType that owns this Property.
overriding function Get_Default
(Self : not null access constant UML_Port_Proxy)
return AMF.Optional_String;
-- Getter of Property::default.
--
-- A String that is evaluated to give a default value for the Property
-- when an object of the owning Classifier is instantiated.
-- Specifies a String that represents a value to be used when no argument
-- is supplied for the Property.
overriding procedure Set_Default
(Self : not null access UML_Port_Proxy;
To : AMF.Optional_String);
-- Setter of Property::default.
--
-- A String that is evaluated to give a default value for the Property
-- when an object of the owning Classifier is instantiated.
-- Specifies a String that represents a value to be used when no argument
-- is supplied for the Property.
overriding function Get_Default_Value
(Self : not null access constant UML_Port_Proxy)
return AMF.UML.Value_Specifications.UML_Value_Specification_Access;
-- Getter of Property::defaultValue.
--
-- A ValueSpecification that is evaluated to give a default value for the
-- Property when an object of the owning Classifier is instantiated.
overriding procedure Set_Default_Value
(Self : not null access UML_Port_Proxy;
To : AMF.UML.Value_Specifications.UML_Value_Specification_Access);
-- Setter of Property::defaultValue.
--
-- A ValueSpecification that is evaluated to give a default value for the
-- Property when an object of the owning Classifier is instantiated.
overriding function Get_Interface
(Self : not null access constant UML_Port_Proxy)
return AMF.UML.Interfaces.UML_Interface_Access;
-- Getter of Property::interface.
--
-- References the Interface that owns the Property
overriding procedure Set_Interface
(Self : not null access UML_Port_Proxy;
To : AMF.UML.Interfaces.UML_Interface_Access);
-- Setter of Property::interface.
--
-- References the Interface that owns the Property
overriding function Get_Is_Derived
(Self : not null access constant UML_Port_Proxy)
return Boolean;
-- Getter of Property::isDerived.
--
-- Specifies whether the Property is derived, i.e., whether its value or
-- values can be computed from other information.
-- If isDerived is true, the value of the attribute is derived from
-- information elsewhere.
overriding procedure Set_Is_Derived
(Self : not null access UML_Port_Proxy;
To : Boolean);
-- Setter of Property::isDerived.
--
-- Specifies whether the Property is derived, i.e., whether its value or
-- values can be computed from other information.
-- If isDerived is true, the value of the attribute is derived from
-- information elsewhere.
overriding function Get_Is_Derived_Union
(Self : not null access constant UML_Port_Proxy)
return Boolean;
-- Getter of Property::isDerivedUnion.
--
-- Specifies whether the property is derived as the union of all of the
-- properties that are constrained to subset it.
overriding procedure Set_Is_Derived_Union
(Self : not null access UML_Port_Proxy;
To : Boolean);
-- Setter of Property::isDerivedUnion.
--
-- Specifies whether the property is derived as the union of all of the
-- properties that are constrained to subset it.
overriding function Get_Is_ID
(Self : not null access constant UML_Port_Proxy)
return Boolean;
-- Getter of Property::isID.
--
-- True indicates this property can be used to uniquely identify an
-- instance of the containing Class.
overriding procedure Set_Is_ID
(Self : not null access UML_Port_Proxy;
To : Boolean);
-- Setter of Property::isID.
--
-- True indicates this property can be used to uniquely identify an
-- instance of the containing Class.
overriding function Get_Is_Read_Only
(Self : not null access constant UML_Port_Proxy)
return Boolean;
-- Getter of Property::isReadOnly.
--
-- If isReadOnly is true, the attribute may not be written to after
-- initialization.
-- If true, the attribute may only be read, and not written.
overriding procedure Set_Is_Read_Only
(Self : not null access UML_Port_Proxy;
To : Boolean);
-- Setter of Property::isReadOnly.
--
-- If isReadOnly is true, the attribute may not be written to after
-- initialization.
-- If true, the attribute may only be read, and not written.
overriding function Get_Opposite
(Self : not null access constant UML_Port_Proxy)
return AMF.UML.Properties.UML_Property_Access;
-- Getter of Property::opposite.
--
-- In the case where the property is one navigable end of a binary
-- association with both ends navigable, this gives the other end.
overriding procedure Set_Opposite
(Self : not null access UML_Port_Proxy;
To : AMF.UML.Properties.UML_Property_Access);
-- Setter of Property::opposite.
--
-- In the case where the property is one navigable end of a binary
-- association with both ends navigable, this gives the other end.
overriding function Get_Owning_Association
(Self : not null access constant UML_Port_Proxy)
return AMF.UML.Associations.UML_Association_Access;
-- Getter of Property::owningAssociation.
--
-- References the owning association of this property, if any.
overriding procedure Set_Owning_Association
(Self : not null access UML_Port_Proxy;
To : AMF.UML.Associations.UML_Association_Access);
-- Setter of Property::owningAssociation.
--
-- References the owning association of this property, if any.
overriding function Get_Qualifier
(Self : not null access constant UML_Port_Proxy)
return AMF.UML.Properties.Collections.Ordered_Set_Of_UML_Property;
-- Getter of Property::qualifier.
--
-- An optional list of ordered qualifier attributes for the end. If the
-- list is empty, then the Association is not qualified.
overriding function Get_Redefined_Property
(Self : not null access constant UML_Port_Proxy)
return AMF.UML.Properties.Collections.Set_Of_UML_Property;
-- Getter of Property::redefinedProperty.
--
-- References the properties that are redefined by this property.
overriding function Get_Subsetted_Property
(Self : not null access constant UML_Port_Proxy)
return AMF.UML.Properties.Collections.Set_Of_UML_Property;
-- Getter of Property::subsettedProperty.
--
-- References the properties of which this property is constrained to be a
-- subset.
overriding function Get_End
(Self : not null access constant UML_Port_Proxy)
return AMF.UML.Connector_Ends.Collections.Ordered_Set_Of_UML_Connector_End;
-- Getter of ConnectableElement::end.
--
-- Denotes a set of connector ends that attaches to this connectable
-- element.
overriding function Get_Template_Parameter
(Self : not null access constant UML_Port_Proxy)
return AMF.UML.Connectable_Element_Template_Parameters.UML_Connectable_Element_Template_Parameter_Access;
-- Getter of ConnectableElement::templateParameter.
--
-- The ConnectableElementTemplateParameter for this ConnectableElement
-- parameter.
overriding procedure Set_Template_Parameter
(Self : not null access UML_Port_Proxy;
To : AMF.UML.Connectable_Element_Template_Parameters.UML_Connectable_Element_Template_Parameter_Access);
-- Setter of ConnectableElement::templateParameter.
--
-- The ConnectableElementTemplateParameter for this ConnectableElement
-- parameter.
overriding function Get_Type
(Self : not null access constant UML_Port_Proxy)
return AMF.UML.Types.UML_Type_Access;
-- Getter of TypedElement::type.
--
-- The type of the TypedElement.
-- This information is derived from the return result for this Operation.
overriding procedure Set_Type
(Self : not null access UML_Port_Proxy;
To : AMF.UML.Types.UML_Type_Access);
-- Setter of TypedElement::type.
--
-- The type of the TypedElement.
-- This information is derived from the return result for this Operation.
overriding function Get_Client_Dependency
(Self : not null access constant UML_Port_Proxy)
return AMF.UML.Dependencies.Collections.Set_Of_UML_Dependency;
-- Getter of NamedElement::clientDependency.
--
-- Indicates the dependencies that reference the client.
overriding function Get_Name_Expression
(Self : not null access constant UML_Port_Proxy)
return AMF.UML.String_Expressions.UML_String_Expression_Access;
-- Getter of NamedElement::nameExpression.
--
-- The string expression used to define the name of this named element.
overriding procedure Set_Name_Expression
(Self : not null access UML_Port_Proxy;
To : AMF.UML.String_Expressions.UML_String_Expression_Access);
-- Setter of NamedElement::nameExpression.
--
-- The string expression used to define the name of this named element.
overriding function Get_Namespace
(Self : not null access constant UML_Port_Proxy)
return AMF.UML.Namespaces.UML_Namespace_Access;
-- Getter of NamedElement::namespace.
--
-- Specifies the namespace that owns the NamedElement.
overriding function Get_Qualified_Name
(Self : not null access constant UML_Port_Proxy)
return AMF.Optional_String;
-- Getter of NamedElement::qualifiedName.
--
-- A name which allows the NamedElement to be identified within a
-- hierarchy of nested Namespaces. It is constructed from the names of the
-- containing namespaces starting at the root of the hierarchy and ending
-- with the name of the NamedElement itself.
overriding function Get_Owning_Template_Parameter
(Self : not null access constant UML_Port_Proxy)
return AMF.UML.Template_Parameters.UML_Template_Parameter_Access;
-- Getter of ParameterableElement::owningTemplateParameter.
--
-- The formal template parameter that owns this element.
overriding procedure Set_Owning_Template_Parameter
(Self : not null access UML_Port_Proxy;
To : AMF.UML.Template_Parameters.UML_Template_Parameter_Access);
-- Setter of ParameterableElement::owningTemplateParameter.
--
-- The formal template parameter that owns this element.
overriding function Get_Template_Parameter
(Self : not null access constant UML_Port_Proxy)
return AMF.UML.Template_Parameters.UML_Template_Parameter_Access;
-- Getter of ParameterableElement::templateParameter.
--
-- The template parameter that exposes this element as a formal parameter.
overriding procedure Set_Template_Parameter
(Self : not null access UML_Port_Proxy;
To : AMF.UML.Template_Parameters.UML_Template_Parameter_Access);
-- Setter of ParameterableElement::templateParameter.
--
-- The template parameter that exposes this element as a formal parameter.
overriding function Get_Deployed_Element
(Self : not null access constant UML_Port_Proxy)
return AMF.UML.Packageable_Elements.Collections.Set_Of_UML_Packageable_Element;
-- Getter of DeploymentTarget::deployedElement.
--
-- The set of elements that are manifested in an Artifact that is involved
-- in Deployment to a DeploymentTarget.
overriding function Get_Deployment
(Self : not null access constant UML_Port_Proxy)
return AMF.UML.Deployments.Collections.Set_Of_UML_Deployment;
-- Getter of DeploymentTarget::deployment.
--
-- The set of Deployments for a DeploymentTarget.
overriding function Get_Featuring_Classifier
(Self : not null access constant UML_Port_Proxy)
return AMF.UML.Classifiers.Collections.Set_Of_UML_Classifier;
-- Getter of Feature::featuringClassifier.
--
-- The Classifiers that have this Feature as a feature.
overriding function Get_Is_Static
(Self : not null access constant UML_Port_Proxy)
return Boolean;
-- Getter of Feature::isStatic.
--
-- Specifies whether this feature characterizes individual instances
-- classified by the classifier (false) or the classifier itself (true).
overriding procedure Set_Is_Static
(Self : not null access UML_Port_Proxy;
To : Boolean);
-- Setter of Feature::isStatic.
--
-- Specifies whether this feature characterizes individual instances
-- classified by the classifier (false) or the classifier itself (true).
overriding function Get_Is_Leaf
(Self : not null access constant UML_Port_Proxy)
return Boolean;
-- Getter of RedefinableElement::isLeaf.
--
-- Indicates whether it is possible to further redefine a
-- RedefinableElement. If the value is true, then it is not possible to
-- further redefine the RedefinableElement. Note that this property is
-- preserved through package merge operations; that is, the capability to
-- redefine a RedefinableElement (i.e., isLeaf=false) must be preserved in
-- the resulting RedefinableElement of a package merge operation where a
-- RedefinableElement with isLeaf=false is merged with a matching
-- RedefinableElement with isLeaf=true: the resulting RedefinableElement
-- will have isLeaf=false. Default value is false.
overriding procedure Set_Is_Leaf
(Self : not null access UML_Port_Proxy;
To : Boolean);
-- Setter of RedefinableElement::isLeaf.
--
-- Indicates whether it is possible to further redefine a
-- RedefinableElement. If the value is true, then it is not possible to
-- further redefine the RedefinableElement. Note that this property is
-- preserved through package merge operations; that is, the capability to
-- redefine a RedefinableElement (i.e., isLeaf=false) must be preserved in
-- the resulting RedefinableElement of a package merge operation where a
-- RedefinableElement with isLeaf=false is merged with a matching
-- RedefinableElement with isLeaf=true: the resulting RedefinableElement
-- will have isLeaf=false. Default value is false.
overriding function Get_Redefined_Element
(Self : not null access constant UML_Port_Proxy)
return AMF.UML.Redefinable_Elements.Collections.Set_Of_UML_Redefinable_Element;
-- Getter of RedefinableElement::redefinedElement.
--
-- The redefinable element that is being redefined by this element.
overriding function Get_Redefinition_Context
(Self : not null access constant UML_Port_Proxy)
return AMF.UML.Classifiers.Collections.Set_Of_UML_Classifier;
-- Getter of RedefinableElement::redefinitionContext.
--
-- References the contexts that this element may be redefined from.
overriding function Provided
(Self : not null access constant UML_Port_Proxy)
return AMF.UML.Interfaces.Collections.Set_Of_UML_Interface;
-- Operation Port::provided.
--
-- Missing derivation for Port::/provided : Interface
overriding function Required
(Self : not null access constant UML_Port_Proxy)
return AMF.UML.Interfaces.Collections.Set_Of_UML_Interface;
-- Operation Port::required.
--
-- Missing derivation for Port::/required : Interface
overriding function Default
(Self : not null access constant UML_Port_Proxy)
return AMF.Optional_String;
-- Operation Property::default.
--
-- Missing derivation for Property::/default : String
overriding function Is_Attribute
(Self : not null access constant UML_Port_Proxy;
P : AMF.UML.Properties.UML_Property_Access)
return Boolean;
-- Operation Property::isAttribute.
--
-- The query isAttribute() is true if the Property is defined as an
-- attribute of some classifier.
overriding function Is_Compatible_With
(Self : not null access constant UML_Port_Proxy;
P : AMF.UML.Parameterable_Elements.UML_Parameterable_Element_Access)
return Boolean;
-- Operation Property::isCompatibleWith.
--
-- The query isCompatibleWith() determines if this parameterable element
-- is compatible with the specified parameterable element. By default
-- parameterable element P is compatible with parameterable element Q if
-- the kind of P is the same or a subtype as the kind of Q. In addition,
-- for properties, the type must be conformant with the type of the
-- specified parameterable element.
overriding function Is_Composite
(Self : not null access constant UML_Port_Proxy)
return Boolean;
-- Operation Property::isComposite.
--
-- The value of isComposite is true only if aggregation is composite.
overriding function Is_Consistent_With
(Self : not null access constant UML_Port_Proxy;
Redefinee : AMF.UML.Redefinable_Elements.UML_Redefinable_Element_Access)
return Boolean;
-- Operation Property::isConsistentWith.
--
-- The query isConsistentWith() specifies, for any two Properties in a
-- context in which redefinition is possible, whether redefinition would
-- be logically consistent. A redefining property is consistent with a
-- redefined property if the type of the redefining property conforms to
-- the type of the redefined property, the multiplicity of the redefining
-- property (if specified) is contained in the multiplicity of the
-- redefined property.
-- The query isConsistentWith() specifies, for any two Properties in a
-- context in which redefinition is possible, whether redefinition would
-- be logically consistent. A redefining property is consistent with a
-- redefined property if the type of the redefining property conforms to
-- the type of the redefined property, and the multiplicity of the
-- redefining property (if specified) is contained in the multiplicity of
-- the redefined property.
overriding function Is_Navigable
(Self : not null access constant UML_Port_Proxy)
return Boolean;
-- Operation Property::isNavigable.
--
-- The query isNavigable() indicates whether it is possible to navigate
-- across the property.
overriding function Opposite
(Self : not null access constant UML_Port_Proxy)
return AMF.UML.Properties.UML_Property_Access;
-- Operation Property::opposite.
--
-- If this property is owned by a class, associated with a binary
-- association, and the other end of the association is also owned by a
-- class, then opposite gives the other end.
overriding function Subsetting_Context
(Self : not null access constant UML_Port_Proxy)
return AMF.UML.Types.Collections.Set_Of_UML_Type;
-- Operation Property::subsettingContext.
--
-- The query subsettingContext() gives the context for subsetting a
-- property. It consists, in the case of an attribute, of the
-- corresponding classifier, and in the case of an association end, all of
-- the classifiers at the other ends.
overriding function Ends
(Self : not null access constant UML_Port_Proxy)
return AMF.UML.Connector_Ends.Collections.Set_Of_UML_Connector_End;
-- Operation ConnectableElement::end.
--
-- Missing derivation for ConnectableElement::/end : ConnectorEnd
overriding function All_Owning_Packages
(Self : not null access constant UML_Port_Proxy)
return AMF.UML.Packages.Collections.Set_Of_UML_Package;
-- Operation NamedElement::allOwningPackages.
--
-- The query allOwningPackages() returns all the directly or indirectly
-- owning packages.
overriding function Is_Distinguishable_From
(Self : not null access constant UML_Port_Proxy;
N : AMF.UML.Named_Elements.UML_Named_Element_Access;
Ns : AMF.UML.Namespaces.UML_Namespace_Access)
return Boolean;
-- Operation NamedElement::isDistinguishableFrom.
--
-- The query isDistinguishableFrom() determines whether two NamedElements
-- may logically co-exist within a Namespace. By default, two named
-- elements are distinguishable if (a) they have unrelated types or (b)
-- they have related types but different names.
overriding function Namespace
(Self : not null access constant UML_Port_Proxy)
return AMF.UML.Namespaces.UML_Namespace_Access;
-- Operation NamedElement::namespace.
--
-- Missing derivation for NamedElement::/namespace : Namespace
overriding function Is_Template_Parameter
(Self : not null access constant UML_Port_Proxy)
return Boolean;
-- Operation ParameterableElement::isTemplateParameter.
--
-- The query isTemplateParameter() determines if this parameterable
-- element is exposed as a formal template parameter.
overriding function Deployed_Element
(Self : not null access constant UML_Port_Proxy)
return AMF.UML.Packageable_Elements.Collections.Set_Of_UML_Packageable_Element;
-- Operation DeploymentTarget::deployedElement.
--
-- Missing derivation for DeploymentTarget::/deployedElement :
-- PackageableElement
overriding function Compatible_With
(Self : not null access constant UML_Port_Proxy;
Other : AMF.UML.Multiplicity_Elements.UML_Multiplicity_Element_Access)
return Boolean;
-- Operation MultiplicityElement::compatibleWith.
--
-- The operation compatibleWith takes another multiplicity as input. It
-- checks if one multiplicity is compatible with another.
overriding function Includes_Cardinality
(Self : not null access constant UML_Port_Proxy;
C : Integer)
return Boolean;
-- Operation MultiplicityElement::includesCardinality.
--
-- The query includesCardinality() checks whether the specified
-- cardinality is valid for this multiplicity.
overriding function Includes_Multiplicity
(Self : not null access constant UML_Port_Proxy;
M : AMF.UML.Multiplicity_Elements.UML_Multiplicity_Element_Access)
return Boolean;
-- Operation MultiplicityElement::includesMultiplicity.
--
-- The query includesMultiplicity() checks whether this multiplicity
-- includes all the cardinalities allowed by the specified multiplicity.
overriding function Iss
(Self : not null access constant UML_Port_Proxy;
Lowerbound : Integer;
Upperbound : Integer)
return Boolean;
-- Operation MultiplicityElement::is.
--
-- The operation is determines if the upper and lower bound of the ranges
-- are the ones given.
overriding function Is_Redefinition_Context_Valid
(Self : not null access constant UML_Port_Proxy;
Redefined : AMF.UML.Redefinable_Elements.UML_Redefinable_Element_Access)
return Boolean;
-- Operation RedefinableElement::isRedefinitionContextValid.
--
-- The query isRedefinitionContextValid() specifies whether the
-- redefinition contexts of this RedefinableElement are properly related
-- to the redefinition contexts of the specified RedefinableElement to
-- allow this element to redefine the other. By default at least one of
-- the redefinition contexts of this element must be a specialization of
-- at least one of the redefinition contexts of the specified element.
overriding procedure Enter_Element
(Self : not null access constant UML_Port_Proxy;
Visitor : in out AMF.Visitors.Abstract_Visitor'Class;
Control : in out AMF.Visitors.Traverse_Control);
-- Dispatch call to corresponding subprogram of visitor interface.
overriding procedure Leave_Element
(Self : not null access constant UML_Port_Proxy;
Visitor : in out AMF.Visitors.Abstract_Visitor'Class;
Control : in out AMF.Visitors.Traverse_Control);
-- Dispatch call to corresponding subprogram of visitor interface.
overriding procedure Visit_Element
(Self : not null access constant UML_Port_Proxy;
Iterator : in out AMF.Visitors.Abstract_Iterator'Class;
Visitor : in out AMF.Visitors.Abstract_Visitor'Class;
Control : in out AMF.Visitors.Traverse_Control);
-- Dispatch call to corresponding subprogram of iterator interface.
end AMF.Internals.UML_Ports;
|
reznikmm/matreshka | Ada | 4,065 | 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.Presentation_Duration_Attributes;
package Matreshka.ODF_Presentation.Duration_Attributes is
type Presentation_Duration_Attribute_Node is
new Matreshka.ODF_Presentation.Abstract_Presentation_Attribute_Node
and ODF.DOM.Presentation_Duration_Attributes.ODF_Presentation_Duration_Attribute
with null record;
overriding function Create
(Parameters : not null access Matreshka.DOM_Attributes.Attribute_L2_Parameters)
return Presentation_Duration_Attribute_Node;
overriding function Get_Local_Name
(Self : not null access constant Presentation_Duration_Attribute_Node)
return League.Strings.Universal_String;
end Matreshka.ODF_Presentation.Duration_Attributes;
|
sungyeon/drake | Ada | 459 | ads | pragma License (Unrestricted);
-- extended unit
generic
type Index_Type is range <>;
type Element_Type is (<>); -- scalar only
type Array_Type is array (Index_Type range <>) of Element_Type;
type Name is access Array_Type;
procedure Ada.Unchecked_Reallocation (
X : in out Name;
First_Index : Index_Type;
Last_Index : Index_Type'Base);
-- Change the size of the allocated array object.
pragma Preelaborate (Ada.Unchecked_Reallocation);
|
likai3g/afmt | Ada | 2,076 | adb | with Ada.Calendar.Time_Zones;
with Ada.Calendar.Formatting;
with Fmt.Integer_Argument;
package body Fmt.Time_Argument is
Default_Time_Edit : aliased constant String := "%Y-%m-%d %H:%M:%S";
overriding
function Get_Placeholder_Width (
Self : in out Time_Argument_Type;
Name : Character)
return Natural
is
begin
return (
case Name is
when 'Y' => 4,
when 'y' | 'm' | 'd' | 'H' | 'M' | 'S' => 2,
when others => 0);
end Get_Placeholder_Width;
overriding
function Is_Valid_Placeholder (
Self : Time_Argument_Type;
Name : Character)
return Boolean
is
begin
return Name in 'Y' | 'y' | 'm' | 'd' | 'H' | 'M' | 'S';
end Is_Valid_Placeholder;
overriding
procedure Put_Placeholder (
Self : in out Time_Argument_Type;
Name : Character;
To : in out String)
is
use Ada.Calendar.Formatting;
use Ada.Calendar.Time_Zones;
use Integer_Argument;
TZ : constant Time_Offset := Local_Time_Offset(Self.Value);
begin
case Name is
when 'Y' => To := Format("{:w=4,f=0}", To_Argument(Year(Self.Value, TZ)));
when 'm' => To := Format("{:w=2,f=0}", To_Argument(Month(Self.Value, TZ)));
when 'd' => To := Format("{:w=2,f=0}", To_Argument(Day(Self.Value, TZ)));
when 'H' => To := Format("{:w=2,f=0}", To_Argument(Hour(Self.Value, TZ)));
when 'M' => To := Format("{:w=2,f=0}", To_Argument(Minute(Self.Value, TZ)));
when 'S' => To := Format("{:w=2,f=0}", To_Argument(Second(Self.Value)));
when others => null;
end case;
end Put_Placeholder;
function To_Argument (X : Ada.Calendar.Time) return Argument_Type'Class
is
begin
return Time_Argument_Type'(
Value => X,
Default_Edit => Default_Time_Edit'Access,
others => <>);
end To_Argument;
function "&" (Args : Arguments; X : Ada.Calendar.Time) return Arguments
is
begin
return Args & To_Argument(X);
end "&";
end Fmt.Time_Argument;
|
charlie5/cBound | Ada | 1,627 | ads | -- This file is generated by SWIG. Please do not modify by hand.
--
with Interfaces;
with swig;
with Interfaces.C;
with Interfaces.C.Pointers;
package xcb.xcb_glx_is_direct_reply_t is
-- Item
--
type Item is record
response_type : aliased Interfaces.Unsigned_8;
pad0 : aliased Interfaces.Unsigned_8;
sequence : aliased Interfaces.Unsigned_16;
length : aliased Interfaces.Unsigned_32;
is_direct : aliased Interfaces.Unsigned_8;
pad1 : aliased swig.int8_t_Array (0 .. 22);
end record;
-- Item_Array
--
type Item_Array is
array
(Interfaces.C.size_t range <>) of aliased xcb.xcb_glx_is_direct_reply_t
.Item;
-- Pointer
--
package C_Pointers is new Interfaces.C.Pointers
(Index => Interfaces.C.size_t,
Element => xcb.xcb_glx_is_direct_reply_t.Item,
Element_Array => xcb.xcb_glx_is_direct_reply_t.Item_Array,
Default_Terminator => (others => <>));
subtype Pointer is C_Pointers.Pointer;
-- Pointer_Array
--
type Pointer_Array is
array
(Interfaces.C.size_t range <>) of aliased xcb.xcb_glx_is_direct_reply_t
.Pointer;
-- Pointer_Pointer
--
package C_Pointer_Pointers is new Interfaces.C.Pointers
(Index => Interfaces.C.size_t,
Element => xcb.xcb_glx_is_direct_reply_t.Pointer,
Element_Array => xcb.xcb_glx_is_direct_reply_t.Pointer_Array,
Default_Terminator => null);
subtype Pointer_Pointer is C_Pointer_Pointers.Pointer;
end xcb.xcb_glx_is_direct_reply_t;
|
zhmu/ananas | Ada | 10,470 | adb | ------------------------------------------------------------------------------
-- --
-- GNAT LIBRARY COMPONENTS --
-- --
-- ADA.CONTAINERS.FUNCTIONAL_BASE --
-- --
-- B o d y --
-- --
-- Copyright (C) 2016-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/>. --
------------------------------------------------------------------------------
pragma Ada_2012;
with Ada.Unchecked_Deallocation;
package body Ada.Containers.Functional_Base with SPARK_Mode => Off is
function To_Count (Idx : Extended_Index) return Count_Type is
(Count_Type
(Extended_Index'Pos (Idx) -
Extended_Index'Pos (Extended_Index'First)));
function To_Index (Position : Count_Type) return Extended_Index is
(Extended_Index'Val
(Position + Extended_Index'Pos (Extended_Index'First)));
-- Conversion functions between Index_Type and Count_Type
function Find (C : Container; E : access Element_Type) return Count_Type;
-- Search a container C for an element equal to E.all, returning the
-- position in the underlying array.
procedure Resize (Base : Array_Base_Access);
-- Resize the underlying array if needed so that it can contain one more
-- element.
---------
-- "=" --
---------
function "=" (C1 : Container; C2 : Container) return Boolean is
begin
if C1.Length /= C2.Length then
return False;
end if;
for I in 1 .. C1.Length loop
if C1.Base.Elements (I).all /= C2.Base.Elements (I).all then
return False;
end if;
end loop;
return True;
end "=";
----------
-- "<=" --
----------
function "<=" (C1 : Container; C2 : Container) return Boolean is
begin
for I in 1 .. C1.Length loop
if Find (C2, C1.Base.Elements (I)) = 0 then
return False;
end if;
end loop;
return True;
end "<=";
---------
-- Add --
---------
function Add
(C : Container;
I : Index_Type;
E : Element_Type) return Container
is
begin
if To_Count (I) = C.Length + 1 and then C.Length = C.Base.Max_Length then
Resize (C.Base);
C.Base.Max_Length := C.Base.Max_Length + 1;
C.Base.Elements (C.Base.Max_Length) := new Element_Type'(E);
return Container'(Length => C.Base.Max_Length, Base => C.Base);
else
declare
A : constant Array_Base_Access := Content_Init (C.Length);
P : Count_Type := 0;
begin
A.Max_Length := C.Length + 1;
for J in 1 .. C.Length + 1 loop
if J /= To_Count (I) then
P := P + 1;
A.Elements (J) := C.Base.Elements (P);
else
A.Elements (J) := new Element_Type'(E);
end if;
end loop;
return Container'(Length => A.Max_Length,
Base => A);
end;
end if;
end Add;
------------------
-- Content_Init --
------------------
function Content_Init (L : Count_Type := 0) return Array_Base_Access
is
Max_Init : constant Count_Type := 100;
Size : constant Count_Type :=
(if L < Count_Type'Last - Max_Init then L + Max_Init
else Count_Type'Last);
Elements : constant Element_Array_Access :=
new Element_Array'(1 .. Size => <>);
begin
return new Array_Base'(Max_Length => 0, Elements => Elements);
end Content_Init;
----------
-- Find --
----------
function Find (C : Container; E : access Element_Type) return Count_Type is
begin
for I in 1 .. C.Length loop
if C.Base.Elements (I).all = E.all then
return I;
end if;
end loop;
return 0;
end Find;
function Find (C : Container; E : Element_Type) return Extended_Index is
(To_Index (Find (C, E'Unrestricted_Access)));
---------
-- Get --
---------
function Get (C : Container; I : Index_Type) return Element_Type is
(C.Base.Elements (To_Count (I)).all);
------------------
-- Intersection --
------------------
function Intersection (C1 : Container; C2 : Container) return Container is
L : constant Count_Type := Num_Overlaps (C1, C2);
A : constant Array_Base_Access := Content_Init (L);
P : Count_Type := 0;
begin
A.Max_Length := L;
for I in 1 .. C1.Length loop
if Find (C2, C1.Base.Elements (I)) > 0 then
P := P + 1;
A.Elements (P) := C1.Base.Elements (I);
end if;
end loop;
return Container'(Length => P, Base => A);
end Intersection;
------------
-- Length --
------------
function Length (C : Container) return Count_Type is (C.Length);
---------------------
-- Num_Overlaps --
---------------------
function Num_Overlaps (C1 : Container; C2 : Container) return Count_Type is
P : Count_Type := 0;
begin
for I in 1 .. C1.Length loop
if Find (C2, C1.Base.Elements (I)) > 0 then
P := P + 1;
end if;
end loop;
return P;
end Num_Overlaps;
------------
-- Remove --
------------
function Remove (C : Container; I : Index_Type) return Container is
begin
if To_Count (I) = C.Length then
return Container'(Length => C.Length - 1, Base => C.Base);
else
declare
A : constant Array_Base_Access := Content_Init (C.Length - 1);
P : Count_Type := 0;
begin
A.Max_Length := C.Length - 1;
for J in 1 .. C.Length loop
if J /= To_Count (I) then
P := P + 1;
A.Elements (P) := C.Base.Elements (J);
end if;
end loop;
return Container'(Length => C.Length - 1, Base => A);
end;
end if;
end Remove;
------------
-- Resize --
------------
procedure Resize (Base : Array_Base_Access) is
begin
if Base.Max_Length < Base.Elements'Length then
return;
end if;
pragma Assert (Base.Max_Length = Base.Elements'Length);
if Base.Max_Length = Count_Type'Last then
raise Constraint_Error;
end if;
declare
procedure Finalize is new Ada.Unchecked_Deallocation
(Object => Element_Array,
Name => Element_Array_Access_Base);
New_Length : constant Positive_Count_Type :=
(if Base.Max_Length > Count_Type'Last / 2 then Count_Type'Last
else 2 * Base.Max_Length);
Elements : constant Element_Array_Access :=
new Element_Array (1 .. New_Length);
Old_Elmts : Element_Array_Access_Base := Base.Elements;
begin
Elements (1 .. Base.Max_Length) := Base.Elements.all;
Base.Elements := Elements;
Finalize (Old_Elmts);
end;
end Resize;
---------
-- Set --
---------
function Set
(C : Container;
I : Index_Type;
E : Element_Type) return Container
is
Result : constant Container :=
Container'(Length => C.Length,
Base => Content_Init (C.Length));
begin
Result.Base.Max_Length := C.Length;
Result.Base.Elements (1 .. C.Length) := C.Base.Elements (1 .. C.Length);
Result.Base.Elements (To_Count (I)) := new Element_Type'(E);
return Result;
end Set;
-----------
-- Union --
-----------
function Union (C1 : Container; C2 : Container) return Container is
N : constant Count_Type := Num_Overlaps (C1, C2);
begin
-- if C2 is completely included in C1 then return C1
if N = Length (C2) then
return C1;
end if;
-- else loop through C2 to find the remaining elements
declare
L : constant Count_Type := Length (C1) - N + Length (C2);
A : constant Array_Base_Access := Content_Init (L);
P : Count_Type := Length (C1);
begin
A.Max_Length := L;
A.Elements (1 .. C1.Length) := C1.Base.Elements (1 .. C1.Length);
for I in 1 .. C2.Length loop
if Find (C1, C2.Base.Elements (I)) = 0 then
P := P + 1;
A.Elements (P) := C2.Base.Elements (I);
end if;
end loop;
return Container'(Length => L, Base => A);
end;
end Union;
end Ada.Containers.Functional_Base;
|
zhmu/ananas | Ada | 415 | ads | package Assert2
with SPARK_Mode
is
type Living is new Integer;
function Is_Martian (Unused : Living) return Boolean is (False);
function Is_Green (Unused : Living) return Boolean is (True);
pragma Assert
(for all M in Living => (if Is_Martian (M) then Is_Green (M)));
pragma Assert
(for all M in Living => (if Is_Martian (M) then not Is_Green (M)));
procedure Dummy;
end Assert2;
|
charlie5/lace | Ada | 2,522 | adb | with
gel.Events,
gel.Camera.forge,
lace.Event.utility,
ada.unchecked_Deallocation;
package body gel.Applet.client_world
is
procedure define (Self : in gel.Applet.client_world.view; Name : in String;
space_Kind : in physics.space_Kind)
is
use lace.Event.utility;
the_world_Info : constant world_Info_view := new world_Info;
the_Camera : constant gel.Camera.View := gel.Camera.forge.new_Camera;
begin
the_world_Info.World := gel.World.client.forge.new_World (Name,
client_world_Id,
space_Kind,
Self.Renderer).all'Access;
the_Camera.Viewport_is (Self.Window.Width, Self.Window.Height);
the_Camera.Renderer_is (Self.Renderer);
the_Camera.Site_is ([0.0, 5.0, 50.0]);
the_world_Info.Cameras.append (the_Camera);
Self.Worlds.append (the_world_Info);
Self.local_Subject_and_Observer.add (the_add_new_sprite_Response'Access,
to_Kind (gel.events.new_sprite_added_to_world_Event'Tag),
the_world_Info.World.Name);
the_world_Info.World.start;
end define;
package body Forge
is
function new_Applet (Name : in String;
use_Window : in gel.Window.view;
space_Kind : in physics.space_Kind) return gel.Applet.client_world.view
is
Self : constant View := new Item' (gel.Applet.Forge.to_Applet (Name, use_Window)
with null record);
begin
define (Self, Name, space_Kind);
return Self;
end new_Applet;
end Forge;
procedure free (Self : in out View)
is
procedure deallocate is new ada.unchecked_Deallocation (Item'Class, View);
begin
Self.destroy;
deallocate (Self);
end free;
function client_World (Self : in Item) return gel.World.client.view
is
begin
return gel.World.client.view (Self.World (client_world_Id));
end client_World;
function client_Camera (Self : in Item) return gel.Camera.view
is
begin
return Self.Camera (client_world_Id,
client_camera_Id);
end client_Camera;
end gel.Applet.client_world;
|
reznikmm/matreshka | Ada | 4,750 | ads | ------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- Open Document Toolkit --
-- --
-- Runtime Library Component --
-- --
------------------------------------------------------------------------------
-- --
-- Copyright © 2013, Vadim Godunko <[email protected]> --
-- All rights reserved. --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions --
-- are met: --
-- --
-- * Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- --
-- * Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in the --
-- documentation and/or other materials provided with the distribution. --
-- --
-- * Neither the name of the Vadim Godunko, IE nor the names of its --
-- contributors may be used to endorse or promote products derived from --
-- this software without specific prior written permission. --
-- --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR --
-- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
-- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED --
-- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR --
-- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF --
-- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING --
-- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS --
-- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
-- --
------------------------------------------------------------------------------
-- $Revision$ $Date$
------------------------------------------------------------------------------
package Matreshka.ODF_Elements.Style.Table_Properties is
type Style_Table_Properties_Node is
new Matreshka.ODF_Elements.Style.Style_Node_Base with null record;
type Style_Table_Properties_Access is
access all Style_Table_Properties_Node'Class;
overriding procedure Enter_Element
(Self : not null access Style_Table_Properties_Node;
Visitor : in out XML.DOM.Visitors.Abstract_Visitor'Class;
Control : in out XML.DOM.Visitors.Traverse_Control);
-- Dispatch call to corresponding subprogram of visitor interface.
overriding function Get_Local_Name
(Self : not null access constant Style_Table_Properties_Node)
return League.Strings.Universal_String;
overriding procedure Leave_Element
(Self : not null access Style_Table_Properties_Node;
Visitor : in out XML.DOM.Visitors.Abstract_Visitor'Class;
Control : in out XML.DOM.Visitors.Traverse_Control);
-- Dispatch call to corresponding subprogram of visitor interface.
overriding procedure Visit_Element
(Self : not null access Style_Table_Properties_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);
-- Dispatch call to corresponding subprogram of iterator interface.
end Matreshka.ODF_Elements.Style.Table_Properties;
|
reznikmm/matreshka | Ada | 7,001 | 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_Chart.Regression_Curve_Elements is
------------
-- Create --
------------
overriding function Create
(Parameters : not null access Matreshka.DOM_Elements.Element_L2_Parameters)
return Chart_Regression_Curve_Element_Node is
begin
return Self : Chart_Regression_Curve_Element_Node do
Matreshka.ODF_Chart.Constructors.Initialize
(Self'Unchecked_Access,
Parameters.Document,
Matreshka.ODF_String_Constants.Chart_Prefix);
end return;
end Create;
----------------
-- Enter_Node --
----------------
overriding procedure Enter_Node
(Self : not null access Chart_Regression_Curve_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_Chart_Regression_Curve
(ODF.DOM.Chart_Regression_Curve_Elements.ODF_Chart_Regression_Curve_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 Chart_Regression_Curve_Element_Node)
return League.Strings.Universal_String
is
pragma Unreferenced (Self);
begin
return Matreshka.ODF_String_Constants.Regression_Curve_Element;
end Get_Local_Name;
----------------
-- Leave_Node --
----------------
overriding procedure Leave_Node
(Self : not null access Chart_Regression_Curve_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_Chart_Regression_Curve
(ODF.DOM.Chart_Regression_Curve_Elements.ODF_Chart_Regression_Curve_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 Chart_Regression_Curve_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_Chart_Regression_Curve
(Visitor,
ODF.DOM.Chart_Regression_Curve_Elements.ODF_Chart_Regression_Curve_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.Chart_URI,
Matreshka.ODF_String_Constants.Regression_Curve_Element,
Chart_Regression_Curve_Element_Node'Tag);
end Matreshka.ODF_Chart.Regression_Curve_Elements;
|
jhumphry/parse_args | Ada | 18,587 | adb | -- parse_args.adb
-- A simple command line option parser
-- Copyright (c) 2014 - 2016, James Humphry
--
-- Permission to use, copy, modify, and/or distribute this software for any
-- purpose with or without fee is hereby granted, provided that the above
-- copyright notice and this permission notice appear in all copies.
--
-- THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
-- REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
-- AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
-- INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
-- LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
-- OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
-- PERFORMANCE OF THIS SOFTWARE.
pragma Restrictions(No_Implementation_Aspect_Specifications,
No_Implementation_Attributes,
No_Implementation_Identifiers,
No_Implementation_Units);
-- pragma Profile(No_Implementation_Extensions) is not used in this compilation
-- unit because it sets the restriction No_Implementation_Pragmas. A GNAT
-- specific pragma Unreferenced is being used to suppress unneccesary warnings
-- where parameters are intentionally not being used.
with Parse_Args.Concrete;
use Parse_Args.Concrete;
with Ada.Unchecked_Deallocation;
package body Parse_Args is
use Ada.Finalization;
-------------------------
-- Make_Boolean_Option --
-------------------------
function Make_Boolean_Option(Default : in Boolean := False) return Option_Ptr is
(new Concrete_Boolean_Option'(Limited_Controlled with
Set => False,
Value => Default,
Default => Default
));
--------------------------
-- Make_Repeated_Option --
--------------------------
function Make_Repeated_Option(Default : in Natural := 0) return Option_Ptr is
(new Repeated_Option'(Limited_Controlled with
Set => False,
Value => Default,
Default => Default,
Min => 0,
Max => Integer'Last
));
-------------------------
-- Make_Integer_Option --
-------------------------
function Make_Integer_Option(Default : in Integer := 0;
Min : in Integer := Integer'First;
Max : in Integer := Integer'Last
) return Option_Ptr is
(new Concrete_Integer_Option'(Limited_Controlled with
Set => False,
Value => Default,
Default => Default,
Min => Min,
Max => Max
));
------------------------
-- Make_String_Option --
------------------------
function Make_String_Option(Default : in String := "") return Option_Ptr
is
Default_US : constant Unbounded_String := To_Unbounded_String(Default);
begin
return new Concrete_String_Option'(Limited_Controlled with
Set => False,
Value => Default_US,
Default => Default_US
);
end Make_String_Option;
----------------
-- Add_Option --
----------------
procedure Add_Option(A : in out Argument_Parser;
O : in Option_Ptr;
Name : in String;
Short_Option : in Character := '-';
Long_Option : in String := "";
Usage : in String := "";
Prepend_Usage : in Boolean := False
) is
Pos : Option_Help_Lists.Cursor;
Final_Long_Option : Unbounded_String;
begin
A.Arguments.Insert(Name, O);
if Prepend_Usage then
Pos := A.Option_Help_Details.First;
else
Pos := Option_Help_Lists.No_Element;
end if;
if Short_Option /= '-' then
A.Short_Options.Insert(Short_Option, O);
end if;
if Long_Option = "" then
A.Long_Options.Insert(Name, O);
Final_Long_Option := To_Unbounded_String(Name);
elsif Long_Option /= "-" then
A.Long_Options.Insert(Long_Option, O);
Final_Long_Option := To_Unbounded_String(Long_Option);
else
Final_Long_Option := Null_Unbounded_String;
end if;
A.Option_Help_Details.Insert(Before => Pos,
New_Item => Option_Help'(Name => To_Unbounded_String(Name),
Positional => False,
Long_Option => Final_Long_Option,
Short_Option => Short_Option,
Usage => To_Unbounded_String(Usage))
);
end Add_Option;
-----------------------
-- Append_Positional --
-----------------------
procedure Append_Positional(A : in out Argument_Parser;
O : in Option_Ptr;
Name : in String
) is
begin
A.Arguments.Insert(Name, O);
A.Positional.Append(O);
A.Option_Help_Details.Append(Option_Help'(Name => To_Unbounded_String(Name),
Positional => True,
Long_Option => Null_Unbounded_String,
Short_Option => '-',
Usage => Null_Unbounded_String));
end Append_Positional;
--------------------------
-- Allow_Tail_Arguments --
--------------------------
procedure Allow_Tail_Arguments(A : in out Argument_Parser;
Usage : in String := "ARGUMENTS";
Allow : in Boolean := True) is
begin
A.Tail_Usage := To_Unbounded_String(Usage);
A.Allow_Tail := Allow;
end Allow_Tail_Arguments;
------------------
-- Set_Prologue --
------------------
procedure Set_Prologue(A: in out Argument_Parser;
Prologue : in String) is
begin
A.Prologue := To_Unbounded_String(Prologue);
end Set_Prologue;
------------------------
-- Parse_Command_Line --
------------------------
procedure Parse_Command_Line (A : in out Argument_Parser) is
-- Separating these out into expression functions keeps the mechanics
-- of the state machine below a little cleaner.
function is_short_option(A : String) return Boolean is
(A'Length = 2 and then A(A'First) = '-' and then A(A'First+1) /= '-');
function short_option(A : String) return Character is (A(A'Last));
function is_short_option_group(A : String) return Boolean is
(A'Length > 2 and then
A(A'First) = '-' and then
(for all I in A'First+1..A'Last => A(I) /= '-'));
function short_option_group(A : String) return String is (A(A'First+1..A'Last));
function is_long_option(A : String) return Boolean is
(A'Length > 2 and then A(A'First..A'First+1) = "--");
function long_option(A : String) return String is
(A(A'First+2..A'Last));
function is_options_end(A : String) return Boolean is
(A = "--");
begin
if A.State /= Init then
raise Program_Error with "Argument Parser has already been fed data!";
end if;
A.State := Ready;
A.Current_Positional := A.Positional.First;
A.Last_Option := null;
-- Last_Option holds a pointer to the option seen in the previous loop
-- iteration so we know where to direct any arguments.
for I in 1..Argument_Parser'Class(A).Argument_Count loop
declare
Arg : constant String := Argument_Parser'Class(A).Argument(I);
begin
case A.State is
when Init | Finish_Success =>
raise Program_Error with "Argument Parser in impossible state!";
when Ready =>
if is_options_end(Arg) then
A.State := Positional_Only;
elsif is_long_option(Arg) then
if A.Long_Options.Contains(long_option(Arg)) then
Set_Option(A.Long_Options.Element(long_option(Arg)).all, A);
A.Last_Option := A.Long_Options.Element(long_option(Arg));
else
A.Message := To_Unbounded_String("Unrecognised option: " & Arg);
A.State := Finish_Erroneous;
end if;
elsif is_short_option(Arg) then
if A.Short_Options.Contains(short_option(Arg)) then
Set_Option(A.Short_Options.Element(short_option(Arg)).all, A);
A.Last_Option := A.Short_Options.Element(short_option(Arg));
else
A.Message := To_Unbounded_String("Unrecognised option: " & Arg);
A.State := Finish_Erroneous;
end if;
elsif is_short_option_group(Arg) then
for C of short_option_group(Arg) loop
if A.State /= Ready then
-- If one of the options specified previously in the
-- option group takes an argument it will have left
-- the parser state as Required_Argument. The only
-- time this isn't a problem is if such an option is
-- the last one in the group.
A.Message := To_Unbounded_String("Option requiring an argument must be last in the group: " &
short_option_group(Arg));
A.State := Finish_Erroneous;
exit;
elsif A.Short_Options.Contains(C) then
Set_Option(A.Short_Options.Element(C).all, A);
A.Last_Option := A.Short_Options.Element(C);
else
A.Message := To_Unbounded_String("Unrecognised option: " & C);
A.State := Finish_Erroneous;
exit;
end if;
end loop;
elsif A.Current_Positional /= Positional_Lists.No_Element then
Set_Option_Argument(Positional_Lists.Element(A.Current_Positional).all, Arg, A);
Positional_Lists.Next(A.Current_Positional);
elsif A.Allow_Tail then
A.Tail.Append(Arg);
else
A.Message := To_Unbounded_String("Unrecognised option: " & Arg);
A.State := Finish_Erroneous;
end if;
when Required_Argument =>
-- The parser can never get into the Required_Argument state
-- without going through the Ready state above, and all the
-- branches set Last_Option to a valid, non-null option.
Set_Option_Argument(A.Last_Option.all, Arg, A);
-- The state could be set to Finish_Erroneous
-- OTherwise it should go back to Ready
if A.State = Required_Argument then
A.State := Ready;
end if;
when Positional_Only =>
if A.Current_Positional /= Positional_Lists.No_Element then
Set_Option_Argument(Positional_Lists.Element(A.Current_Positional).all, Arg, A);
Positional_Lists.Next(A.Current_Positional);
elsif A.Allow_Tail then
A.Tail.Append(Arg);
else
A.Message := To_Unbounded_String("Additional unused argument: " & Arg);
A.State := Finish_Erroneous;
end if;
when Finish_Erroneous =>
-- When an problem is encountered, skip all subsequent arguments
-- Hopefully A.message has also been filled out with an informative
-- message.
null;
end case;
end;
end loop;
case A.State is
when Init | Required_Argument | Finish_Success | Finish_Erroneous =>
A.State := Finish_Erroneous;
when Ready | Positional_Only =>
A.State := Finish_Success;
end case;
end Parse_Command_Line;
-------------------
-- Parse_Success --
-------------------
function Parse_Success(A : in Argument_Parser) return Boolean is
begin
if A.State = Finish_Success then
return True;
else
return False;
end if;
end Parse_Success;
-------------------
-- Parse_Message --
-------------------
function Parse_Message(A : in Argument_Parser) return String is
begin
case A.State is
when Finish_Success | Finish_Erroneous =>
return To_String(A.Message);
when others =>
raise Program_Error with "No parse yet taken place?";
end case;
end Parse_Message;
-------------------
-- Boolean_Value --
-------------------
function Boolean_Value(A : Argument_Parser; Name : String) return Boolean is
begin
if A.Arguments.Contains(Name) and then A.Arguments(Name).all in Boolean_Option'Class then
return Boolean_Option'Class(A.Arguments(Name).all).Value;
else
raise Constraint_Error with "No suitable argument: " & Name & " with boolean result.";
end if;
end Boolean_Value;
-------------------
-- Integer_Value --
-------------------
function Integer_Value(A : Argument_Parser; Name : String) return Integer is
begin
if A.Arguments.Contains(Name) and then A.Arguments(Name).all in Integer_Option'Class then
return Integer_Option'Class(A.Arguments(Name).all).Value;
else
raise Constraint_Error with "No suitable argument: " & Name & " with integer result.";
end if;
end Integer_Value;
-------------------
-- String_Value --
-------------------
function String_Value(A : Argument_Parser; Name : String) return String is
begin
if A.Arguments.Contains(Name) and then A.Arguments(Name).all in String_Option'Class then
return String_Option'Class(A.Arguments(Name).all).Value;
else
raise Constraint_Error with "No suitable argument: " & Name & " with string result.";
end if;
end String_Value;
----------
-- Tail --
----------
function Tail(A: in Argument_Parser) return String_Doubly_Linked_Lists.List is
(A.Tail);
-----------
-- Usage --
-----------
procedure Usage(A : in Argument_Parser) is separate;
-----------------
-- Has_Element --
-----------------
function Has_Element (Position : Cursor) return Boolean is
(Option_Maps.Has_Element(Option_Maps.Cursor(Position)));
-----------------
-- Option_Name --
-----------------
function Option_Name(Position : Cursor) return String is
(Option_Maps.Key(Option_Maps.Cursor(Position)));
-------------
-- Iterate --
-------------
function Iterate (Container : in Argument_Parser)
return Argument_Parser_Iterators.Forward_Iterator'Class is
begin
return Argument_Parser_Iterator'(Start => Option_Maps.First(Container.Arguments));
end Iterate;
------------------------
-- Constant_Reference --
------------------------
function Constant_Reference
(C : aliased in Argument_Parser;
Name : in String)
return Option_Constant_Ref
is
begin
return Option_Constant_Ref'(Element => C.Arguments.Element(Name));
end Constant_Reference;
------------------------
-- Constant_Reference --
------------------------
function Constant_Reference
(C : aliased in Argument_Parser;
Position : in Cursor)
return Option_Constant_Ref
is
pragma Unreferenced(C);
begin
return Option_Constant_Ref'(Element => Option_Maps.Element(Option_Maps.Cursor(Position)));
end Constant_Reference;
--------------
-- Finalize --
--------------
procedure Free_Option is new Ada.Unchecked_Deallocation(Object => Option'Class,
Name => General_Option_Ptr);
overriding procedure Finalize(Object : in out Argument_Parser) is
begin
Object.State := Finish_Erroneous;
-- All of the various collections and unbounded strings within Object
-- should themselves be controlled types and per AARM 7.6.1 9/3 they
-- will be automatically finalized after this procedure is run. The
-- requirements for containers in (for example) AARM A.18.3 158/2 suggests
-- that no storage should be lost on scope exit, which suggests that the
-- storage allocated for the elements is being reclaimed.
--
-- As the elements are only access types, the actual options themselves
-- still need to be manually released.
for O of Object.Arguments loop
if O /= null then
Free_Option(General_Option_Ptr(O));
end if;
end loop;
for O of Object.Option_Help_Details loop
O.Name := Null_Unbounded_String;
O.Long_Option := Null_Unbounded_String;
O.Usage := Null_Unbounded_String;
end loop;
end Finalize;
-----------
-- First --
-----------
function First (Object : Argument_Parser_Iterator) return Cursor is
(Cursor(Object.Start));
----------
-- Next --
----------
function Next (Object : Argument_Parser_Iterator; Position : Cursor)
return Cursor is
(Cursor(Option_Maps.Next(Option_Maps.Cursor(Position))));
end Parse_Args;
|
reznikmm/matreshka | Ada | 3,744 | ads | ------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- Open Document Toolkit --
-- --
-- Runtime Library Component --
-- --
------------------------------------------------------------------------------
-- --
-- Copyright © 2014, Vadim Godunko <[email protected]> --
-- All rights reserved. --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions --
-- are met: --
-- --
-- * Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- --
-- * Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in the --
-- documentation and/or other materials provided with the distribution. --
-- --
-- * Neither the name of the Vadim Godunko, IE nor the names of its --
-- contributors may be used to endorse or promote products derived from --
-- this software without specific prior written permission. --
-- --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR --
-- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
-- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED --
-- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR --
-- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF --
-- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING --
-- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS --
-- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
-- --
------------------------------------------------------------------------------
-- $Revision$ $Date$
------------------------------------------------------------------------------
with XML.DOM.Elements;
package ODF.DOM.Table_Data_Pilot_Group_Member_Elements is
pragma Preelaborate;
type ODF_Table_Data_Pilot_Group_Member is limited interface
and XML.DOM.Elements.DOM_Element;
type ODF_Table_Data_Pilot_Group_Member_Access is
access all ODF_Table_Data_Pilot_Group_Member'Class
with Storage_Size => 0;
end ODF.DOM.Table_Data_Pilot_Group_Member_Elements;
|
ekoeppen/STM32_Generic_Ada_Drivers | Ada | 2,648 | ads | -- This spec has been automatically generated from STM32F0xx.svd
-- Definition of the device's interrupts
package STM32_SVD.Interrupts is
pragma Preelaborate;
----------------
-- Interrupts --
----------------
-- Window Watchdog interrupt
WWDG : constant := 0;
-- PVD through EXTI line detection
PVD : constant := 1;
-- RTC global interrupt
RTC : constant := 2;
-- Flash global interrupt
FLASH : constant := 3;
-- RCC global interrupt
RCC : constant := 4;
-- EXTI Line[1:0] interrupts
EXTI0_1 : constant := 5;
-- EXTI Line[3:2] interrupts
EXTI2_3 : constant := 6;
-- EXTI Line15 and EXTI4 interrupts
EXTI4_15 : constant := 7;
-- Touch sensing interrupt
TSC : constant := 8;
-- DMA channel 1 interrupt
DMA_CH1 : constant := 9;
-- DMA channel 2 and 3 interrupts
DMA_CH2_3 : constant := 10;
-- DMA channel 4 and 5 interrupts
DMA_CH4_5 : constant := 11;
-- ADC and comparator 1 and 2
ADC_COMP : constant := 12;
-- TIM1 Break, update, trigger and
TIM1_BRK_UP : constant := 13;
-- TIM1 Capture Compare interrupt
TIM1_CC : constant := 14;
-- TIM2 global interrupt
TIM2 : constant := 15;
-- TIM3 global interrupt
TIM3 : constant := 16;
-- TIM6 global interrupt and DAC
TIM6_DAC : constant := 17;
-- TIM14 global interrupt
TIM14 : constant := 19;
-- TIM15 global interrupt
TIM15 : constant := 20;
-- TIM16 global interrupt
TIM16 : constant := 21;
-- TIM17 global interrupt
TIM17 : constant := 22;
-- I2C1 global interrupt
I2C1 : constant := 23;
-- I2C2 global interrupt
I2C2 : constant := 24;
-- SPI1_global_interrupt
SPI1 : constant := 25;
-- SPI2 global interrupt
SPI2 : constant := 26;
-- USART1 global interrupt
USART1 : constant := 27;
-- USART2 global interrupt
USART2 : constant := 28;
-- CEC global interrupt
CEC : constant := 30;
Number_Of_Interrupts : constant := 31;
end STM32_SVD.Interrupts;
|
micahwelf/FLTK-Ada | Ada | 931 | ads |
package FLTK.Widgets.Valuators.Sliders.Value.Horizontal is
type Hor_Value_Slider is new Value_Slider with private;
type Hor_Value_Slider_Reference (Data : not null access Hor_Value_Slider'Class) is
limited null record with Implicit_Dereference => Data;
package Forge is
function Create
(X, Y, W, H : in Integer;
Text : in String)
return Hor_Value_Slider;
end Forge;
procedure Draw
(This : in out Hor_Value_Slider);
function Handle
(This : in out Hor_Value_Slider;
Event : in Event_Kind)
return Event_Outcome;
private
type Hor_Value_Slider is new Value_Slider with null record;
overriding procedure Finalize
(This : in out Hor_Value_Slider);
pragma Inline (Draw);
pragma Inline (Handle);
end FLTK.Widgets.Valuators.Sliders.Value.Horizontal;
|
AaronC98/PlaneSystem | Ada | 3,598 | ads | ------------------------------------------------------------------------------
-- Ada Web Server --
-- --
-- Copyright (C) 2003-2014, AdaCore --
-- --
-- This library is free software; you can redistribute it and/or modify --
-- it under terms of the GNU General Public License as published by the --
-- Free Software Foundation; either version 3, or (at your option) any --
-- later version. This library is distributed in the hope that it will be --
-- useful, but WITHOUT ANY WARRANTY; without even the implied warranty of --
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. --
-- --
-- --
-- --
-- --
-- --
-- You should have received a copy of the GNU General Public License and --
-- a copy of the GCC Runtime Library Exception along with this program; --
-- see the files COPYING3 and COPYING.RUNTIME respectively. If not, see --
-- <http://www.gnu.org/licenses/>. --
-- --
-- --
-- --
-- --
-- --
-- --
-- --
------------------------------------------------------------------------------
with Ada.Exceptions;
with AWS.Log;
with AWS.Response;
with AWS.Status;
package AWS.Exceptions is
use Ada.Exceptions;
type Data is record
Fatal : Boolean;
-- If True it means that we go a fatal error. The slot will be
-- terminated so AWS will loose one of it's simultaneous connection.
-- This is clearly an AWS internal error that should be fixed in AWS.
Slot : Positive;
-- The failing slot number
Request : Status.Data;
-- The complete request information that was served when the slot has
-- failed. This variable is set only when Fatal is False.
end record;
type Unexpected_Exception_Handler is not null access
procedure (E : Exception_Occurrence;
Log : in out AWS.Log.Object;
Error : Data;
Answer : in out Response.Data);
-- Unexpected exception handler can be set to monitor server errors.
-- Answer can be set with the answer to send back to the client's
-- browser. Note that this is possible only for non fatal error
-- (i.e. Error.Fatal is False).
-- Log is the error log object for the failing server, it can be used
-- to log user's information (if error log is activated for this
-- server). Note that the server will have already logged information
-- about the problem.
end AWS.Exceptions;
|
damaki/SPARKNaCl | Ada | 483 | ads | package SPARKNaCl.Scalar
with Pure,
SPARK_Mode => On
is
--------------------------------------------------------
-- Scalar multiplication
--------------------------------------------------------
function Mult (N : in Bytes_32;
P : in Bytes_32) return Bytes_32
with Global => null,
Pure_Function;
function Mult_Base (N : in Bytes_32) return Bytes_32
with Global => null,
Pure_Function;
end SPARKNaCl.Scalar;
|
Statkus/json-ada | Ada | 1,873 | ads | -- 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 JSON.Types;
with JSON.Streams;
generic
with package Types is new JSON.Types (<>);
package JSON.Tokenizers with SPARK_Mode => On is
pragma Preelaborate;
type Token_Kind is
(Begin_Array_Token,
Begin_Object_Token,
End_Array_Token,
End_Object_Token,
Name_Separator_Token,
Value_Separator_Token,
String_Token,
Integer_Token,
Float_Token,
Boolean_Token,
Null_Token,
EOF_Token,
Invalid_Token);
type Token (Kind : Token_Kind := Invalid_Token) is record
case Kind is
when String_Token =>
String_Offset, String_Length : Streams.AS.Stream_Element_Offset;
when Integer_Token =>
Integer_Value : Types.Integer_Type;
when Float_Token =>
Float_Value : Types.Float_Type;
when Boolean_Token =>
Boolean_Value : Boolean;
when others =>
null;
end case;
end record;
procedure Read_Token
(Stream : in out Streams.Stream'Class;
Next_Token : out Token;
Expect_EOF : Boolean := False)
with Post => Next_Token.Kind /= Invalid_Token and Expect_EOF = (Next_Token.Kind = EOF_Token);
Tokenizer_Error : exception;
end JSON.Tokenizers;
|
charlie5/cBound | Ada | 1,421 | ads | -- This file is generated by SWIG. Please do not modify by hand.
--
with xcb.xcb_glx_generic_error_t;
with Interfaces.C;
with Interfaces.C.Pointers;
package xcb.xcb_glx_bad_current_drawable_error_t is
-- Item
--
subtype Item is xcb.xcb_glx_generic_error_t.Item;
-- Item_Array
--
type Item_Array is
array
(Interfaces.C
.size_t range <>) of aliased xcb.xcb_glx_bad_current_drawable_error_t
.Item;
-- Pointer
--
package C_Pointers is new Interfaces.C.Pointers
(Index => Interfaces.C.size_t,
Element => xcb.xcb_glx_bad_current_drawable_error_t.Item,
Element_Array => xcb.xcb_glx_bad_current_drawable_error_t.Item_Array,
Default_Terminator => (others => <>));
subtype Pointer is C_Pointers.Pointer;
-- Pointer_Array
--
type Pointer_Array is
array
(Interfaces.C
.size_t range <>) of aliased xcb.xcb_glx_bad_current_drawable_error_t
.Pointer;
-- Pointer_Pointer
--
package C_Pointer_Pointers is new Interfaces.C.Pointers
(Index => Interfaces.C.size_t,
Element => xcb.xcb_glx_bad_current_drawable_error_t.Pointer,
Element_Array => xcb.xcb_glx_bad_current_drawable_error_t.Pointer_Array,
Default_Terminator => null);
subtype Pointer_Pointer is C_Pointer_Pointers.Pointer;
end xcb.xcb_glx_bad_current_drawable_error_t;
|
charlie5/lace | Ada | 14,342 | adb | with
gel.Window.setup,
gel.Applet.gui_and_sim_world,
gel.Forge,
gel.Sprite,
physics.Model,
openGL.Model.box .colored,
openGL.Model.sphere .textured,
openGL.Model.capsule.textured,
openGL.Model.any,
openGL.Model.terrain,
openGL.IO,
openGL.Light,
openGL.Palette;
pragma unreferenced (gel.Window.setup);
procedure launch_full_Demo
--
-- Drops a variety of shapes onto a terrain.
--
is
use gel.Math,
openGL,
openGL.Model.box,
opengl.Palette;
the_Applet : constant gel.Applet.gui_and_sim_world.view := gel.Forge.new_gui_and_sim_Applet ("mixed Shapes", 1536, 864);
text_line_Site : gel.Math.Vector_3 := (-10.0, 50.0, -60.0);
procedure put_Line (Message : in String)
is
Text : constant gel.Sprite.view := gel.Forge.new_text_Sprite (the_Applet.gui_World,
text_line_Site,
Message,
the_Applet.Font,
White);
begin
the_Applet.gui_World.add (Text);
text_line_Site (2) := text_line_Site (2) - 2.0;
end put_Line;
x : math.Real := 0.0;
y : math.Real := 10.0;
-----------
-- Terrain
--
-- Heightfield
--
function to_Heightfield (From : in openGL.height_Map) return physics.Heightfield
is
Result : physics.Heightfield (1 .. Integer (From'Last (1)),
1 .. Integer (From'Last (2)));
Last_i : constant Index_t := From'Last (1);
begin
for i in Result'Range (1)
loop
for j in Result'Range (1)
loop
Result (i, j) := math.Real (From (Last_i - Index_t (i) + 1,
Index_t (j)));
end loop;
end loop;
return Result;
end to_Heightfield;
terrain_Heights : constant openGL.asset_Name := to_Asset ("assets/gel/kidwelly-terrain.png");
terrain_Texture : constant openGL.asset_Name := to_Asset ("assets/gel/kidwelly-terrain-texture.png");
hs : constant := 1.0;
gl_Heights : constant openGL.IO.height_Map_view := openGL.IO.to_height_Map (image_Filename => terrain_Heights,
Scale => 10.0);
the_terrain_Model : constant openGL.Model.terrain.view
:= openGL.Model.terrain.new_Terrain (heights_Asset => terrain_Heights,
Row => 1,
Col => 1,
Heights => openGL.Model.terrain.height_Map_view (gl_Heights),
color_Map => terrain_Texture,
Tiling => (s => (0.0, 1.0),
t => (0.0, 1.0)));
the_terrain_physics_Model : constant physics.Model.view
:= physics.Model.forge.new_physics_Model (shape_Info => (Kind => physics.Model.heightfield,
Heights => new physics.Heightfield' (to_Heightfield (gl_Heights.all)),
height_Range => (0.0, 200.0)),
Scale => (hs, 1.0, hs));
the_Terrain : constant gel.Sprite.view
:= gel.Sprite.forge.new_Sprite ("demo.Terrain",
the_Applet.gui_World.all'Access,
Origin_3D,
the_terrain_Model,
the_terrain_physics_Model);
begin
-- Setup the applet.
--
the_Applet.gui_Camera.Site_is ((0.0, 4.0, 30.0)); -- Position the camera.
the_Applet.sim_Camera.Site_is ((0.0, 4.0, 30.0)); -- Position the camera.
the_Applet.enable_simple_Dolly (in_World => the_Applet.sim_World.Id); -- Enable user camera control via keyboard.
the_Applet.Dolly.Speed_is (0.1);
the_Applet.Renderer.Background_is (sky_Blue);
the_Applet.sim_World.Gravity_is ((0.0, -9.8, 0.0));
-- Camera controls text.
--
put_Line ("Camera Controls: - Use arrow and PgUp/PgDn keys to move.");
put_Line (" - Use Shift key to move faster.");
put_Line (" - Use Ctrl key to rotate instead of move.");
put_Line (" - Use Alt key to orbit instead of move.");
-- Set the lights position.
--
declare
use openGL.Light;
Light : openGL.Light.item := the_Applet.Renderer.new_Light;
begin
Light.Kind_is (Diffuse);
Light.Site_is ((0.0, 100.0, 100.0));
Light.ambient_Coefficient_is (0.2);
the_Applet.Renderer.set (Light);
end;
-- Terrain.
--
the_Applet.sim_World.add (the_Terrain); -- Add the terrain.
-- Add several sprites of each shape.
--
for i in 1 .. 5
loop
declare
-- Box
--
the_box_Model : constant openGL.Model.box.colored.view
:= openGL.Model.box.colored.new_Box (Size => (1.0, 1.0, 1.0),
Faces => (Front => (Colors => (others => (Red, Opaque))),
Rear => (Colors => (others => (Green, Opaque))),
Upper => (Colors => (others => (Violet, Opaque))),
Lower => (Colors => (others => (Yellow, Opaque))),
Left => (Colors => (others => (Cyan, Opaque))),
Right => (Colors => (others => (Magenta, Opaque)))));
the_box_physics_Model : constant physics.Model.view
:= physics.Model.forge.new_physics_Model (shape_Info => (Kind => physics.Model.Cube,
half_Extents => the_box_Model.Size / 2.0),
Mass => 1.0);
the_Box : constant gel.Sprite.view
:= gel.Sprite.forge.new_Sprite ("demo.Box",
the_Applet.gui_World.all'Access,
Origin_3D,
the_box_Model.all'Access,
the_box_physics_Model);
-- Ball
--
the_ball_physics_Model : constant physics.Model.view
:= physics.Model.forge.new_physics_Model (shape_Info => (Kind => physics.Model.a_sphere,
sphere_Radius => 0.5),
Mass => 1.0);
the_ball_Model : constant openGL.Model.sphere.textured.view
:= openGL.Model.sphere.textured.new_Sphere (Radius => 0.5,
Image => openGL.to_Asset ("assets/gel/texture/earth_map.bmp"));
the_Ball : constant gel.Sprite.view
:= gel.Sprite.forge.new_Sprite ("demo.Ball",
the_Applet.gui_World.all'Access,
Origin_3D,
the_ball_Model,
the_ball_physics_Model);
-- Cone
--
the_cone_Model : constant openGL.Model.any.view
:= openGL.Model.any.new_Model (Model => openGL.to_Asset ("assets/gel/model/unit_cone.obj"),
Texture => openGL.to_Asset ("assets/gel/Face1.bmp"),
Texture_is_lucid => False);
the_cone_physics_Model : constant physics.Model.view
:= physics.Model.forge.new_physics_Model (shape_Info => (Kind => physics.Model.cone),
Mass => 1.0);
the_Cone : constant gel.Sprite.view
:= gel.Sprite.forge.new_Sprite ("demo.Cone",
the_Applet.gui_World.all'Access,
Origin_3D,
the_cone_Model.all'Access,
the_cone_physics_Model);
-- Capsule
--
the_capsule_Model : constant openGL.Model.capsule.textured.view
:= openGL.Model.capsule.textured.new_Capsule (Radius => 0.5,
Height => 1.0,
Image => openGL.to_Asset ("assets/gel/Face1.bmp"));
the_capsule_physics_Model : constant physics.Model.view
:= physics.Model.forge.new_physics_Model (shape_Info => (Kind => physics.Model.a_Capsule,
lower_Radius => 0.5,
upper_Radius => 0.5,
Height => 1.0),
Mass => 1.0);
the_Capsule : constant gel.Sprite.view
:= gel.Sprite.forge.new_Sprite ("demo.Capsule",
the_Applet.gui_World.all'Access,
Origin_3D,
the_capsule_Model.all'Access,
the_capsule_physics_Model);
-- multi_Sphere
--
the_multi_Sphere_Model : constant openGL.Model.capsule.textured.view
:= openGL.Model.capsule.textured.new_Capsule (Radius => 0.5,
Height => 0.0,
Image => openGL.to_Asset ("assets/gel/golf_green-16x16.tga"));
the_multi_Sphere_physics_Model : constant physics.Model.view
:= physics.Model.forge.new_physics_Model (shape_Info => (Kind => physics.Model.multi_Sphere,
Sites => new physics.Vector_3_array' ((-0.5, 0.0, 0.0),
( 0.5, 0.0, 0.0)),
Radii => new gel.math.Vector' (1 => 0.5,
2 => 0.5)),
Mass => 1.0);
the_multi_Sphere : constant gel.Sprite.view
:= gel.Sprite.forge.new_Sprite ("demo.multi_Sphere",
the_Applet.gui_World.all'Access,
Origin_3D,
the_multi_Sphere_Model.all'Access,
the_multi_Sphere_physics_Model);
-- Hull
--
s : constant := 0.5;
the_hull_Model : constant openGL.Model.box.colored.view
:= openGL.Model.box.colored.new_Box (Size => (s * 2.0, s * 2.0, s * 2.0),
Faces => (others => (others => (others => (Palette.random_Color, Opaque)))));
the_hull_physics_Model : constant physics.Model.view
:= physics.Model.forge.new_physics_Model (shape_Info => (Kind => physics.Model.hull,
Points => new physics.Vector_3_array' ((-s, -s, s),
( s, -s, s),
( s, s, s),
(-s, s, s),
(-s, -s, -s),
( s, -s, -s),
( s, s, -s),
(-s, s, -s))),
Mass => 1.0);
the_Hull : constant gel.Sprite.view
:= gel.Sprite.forge.new_Sprite ("demo.Hull",
the_Applet.gui_World.all'Access,
Origin_3D,
the_hull_Model.all'Access,
the_hull_physics_Model);
begin
the_Applet.sim_World.add (the_Ball);
the_Applet.sim_World.add (the_Box);
the_Applet.sim_World.add (the_Cone);
the_Applet.sim_World.add (the_Capsule);
the_Applet.sim_World.add (the_multi_Sphere);
the_Applet.sim_World.add (the_Hull);
the_Ball .Site_is (( x, y, 0.0));
the_Box .Site_is (( 0.0, y, -2.5));
the_Cone .Site_is (( 0.0, y, 0.0));
the_Capsule .Site_is (( 0.0 + X, y, 0.0 + x));
the_multi_Sphere.Site_is ((-4.0, y, 4.4));
the_Hull .Site_is (( 4.0, y, 4.4));
x := x + 2.0;
y := y + 2.0;
end;
end loop;
-- Main loop.
--
while the_Applet.is_open
loop
the_Applet.freshen; -- Handle any new events, evolve physics and update the screen.
end loop;
the_Applet.destroy;
end launch_full_Demo;
|
charlie5/lace | Ada | 117 | ads | generic
package any_Math.any_Arithmetic
is
pragma Pure;
pragma Optimize (Time);
end any_Math.any_Arithmetic;
|
stcarrez/ada-util | Ada | 1,615 | ads | -----------------------------------------------------------------------
-- util-beans-objects-records -- Generic Typed Data Representation
-- Copyright (C) 2011, 2022 Stephane Carrez
-- Written by Stephane Carrez ([email protected])
--
-- Licensed under the Apache License, Version 2.0 (the "License");
-- you may not use this file except in compliance with the License.
-- You may obtain a copy of the License at
--
-- http://www.apache.org/licenses/LICENSE-2.0
--
-- Unless required by applicable law or agreed to in writing, software
-- distributed under the License is distributed on an "AS IS" BASIS,
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-- See the License for the specific language governing permissions and
-- limitations under the License.
-----------------------------------------------------------------------
generic
type Element_Type is private;
package Util.Beans.Objects.Records is
type Element_Type_Access is access all Element_Type;
-- Create an object which holds a record of the type <b>Element_Type</b>.
function Create return Object;
-- Create an object which is initialized with the given value.
function To_Object (Value : in Element_Type) return Object;
-- Returns the element
function To_Element (Value : in Object) return Element_Type;
-- Returns an access to the element.
function To_Element_Access (Value : in Object) return Element_Type_Access;
private
type Element_Proxy is new Proxy with record
Value : aliased Element_Type;
end record;
end Util.Beans.Objects.Records;
|
reznikmm/matreshka | Ada | 4,717 | 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.Form_Fixed_Text_Elements;
package Matreshka.ODF_Form.Fixed_Text_Elements is
type Form_Fixed_Text_Element_Node is
new Matreshka.ODF_Form.Abstract_Form_Element_Node
and ODF.DOM.Form_Fixed_Text_Elements.ODF_Form_Fixed_Text
with null record;
overriding function Create
(Parameters : not null access Matreshka.DOM_Elements.Element_L2_Parameters)
return Form_Fixed_Text_Element_Node;
overriding function Get_Local_Name
(Self : not null access constant Form_Fixed_Text_Element_Node)
return League.Strings.Universal_String;
overriding procedure Enter_Node
(Self : not null access Form_Fixed_Text_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 Form_Fixed_Text_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 Form_Fixed_Text_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_Form.Fixed_Text_Elements;
|
psyomn/ash | Ada | 741 | ads | -- Copyright 2019 Simon Symeonidis (psyomn)
--
-- 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 Transaction_Handlers is
function Handle_Request (R : String; Context : String) return String;
end Transaction_Handlers;
|
Letractively/ada-el | Ada | 2,375 | ads | -----------------------------------------------------------------------
-- EL.Contexts.Properties -- EL Resolver using util properties
-- Copyright (C) 2011 Stephane Carrez
-- Written by Stephane Carrez ([email protected])
--
-- Licensed under the Apache License, Version 2.0 (the "License");
-- you may not use this file except in compliance with the License.
-- You may obtain a copy of the License at
--
-- http://www.apache.org/licenses/LICENSE-2.0
--
-- Unless required by applicable law or agreed to in writing, software
-- distributed under the License is distributed on an "AS IS" BASIS,
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-- See the License for the specific language governing permissions and
-- limitations under the License.
-----------------------------------------------------------------------
with EL.Objects;
with Util.Beans.Basic;
with Util.Properties;
package EL.Contexts.Properties is
-- ------------------------------
-- Property Resolver
-- ------------------------------
-- The <b>Property_Resolver</b> uses a property manager to resolve names.
type Property_Resolver is new ELResolver with private;
type Property_Resolver_Access is access all Property_Resolver'Class;
-- Set the properties used for resolving values.
procedure Set_Properties (Resolver : in out Property_Resolver;
Properties : in Util.Properties.Manager'Class);
-- Get the value associated with a base object and a given property.
overriding
function Get_Value (Resolver : in Property_Resolver;
Context : in ELContext'Class;
Base : access Util.Beans.Basic.Readonly_Bean'Class;
Name : in Unbounded_String) return EL.Objects.Object;
-- Set the value associated with a base object and a given property.
overriding
procedure Set_Value (Resolver : in out Property_Resolver;
Context : in ELContext'Class;
Base : access Util.Beans.Basic.Bean'Class;
Name : in Unbounded_String;
Value : in EL.Objects.Object);
private
type Property_Resolver is new ELResolver with record
Props : Util.Properties.Manager;
end record;
end EL.Contexts.Properties;
|
stcarrez/helios | Ada | 3,350 | adb | -----------------------------------------------------------------------
-- helios-reports-files -- Write reports in files
-- Copyright (C) 2017, 2019 Stephane Carrez
-- Written by Stephane Carrez ([email protected])
--
-- Licensed under the Apache License, Version 2.0 (the "License");
-- you may not use this file except in compliance with the License.
-- You may obtain a copy of the License at
--
-- http://www.apache.org/licenses/LICENSE-2.0
--
-- Unless required by applicable law or agreed to in writing, software
-- distributed under the License is distributed on an "AS IS" BASIS,
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-- See the License for the specific language governing permissions and
-- limitations under the License.
-----------------------------------------------------------------------
with Ada.Streams.Stream_IO;
with Ada.Calendar;
with Ada.Directories;
with Util.Serialize.IO.JSON;
with Util.Streams.Texts;
with Util.Streams.Files;
with Util.Log.Loggers;
with Helios.Tools.Formats;
with Helios.Monitor;
package body Helios.Reports.Files is
use type Ada.Real_Time.Time_Span;
Log : constant Util.Log.Loggers.Logger := Util.Log.Loggers.Create ("Helios.Reports.Files");
-- ------------------------------
-- The timer handler executed when the timer deadline has passed.
-- ------------------------------
overriding
procedure Time_Handler (Report : in out File_Report_Type;
Event : in out Util.Events.Timers.Timer_Ref'Class) is
Pattern : constant String := Ada.Strings.Unbounded.To_String (Report.Path);
Path : constant String := Helios.Tools.Formats.Format (Pattern, Ada.Calendar.Clock);
Dir : constant String := Ada.Directories.Containing_Directory (Path);
begin
if not Ada.Directories.Exists (Dir) then
Log.Info ("Creating directory {0}", Dir);
Ada.Directories.Create_Directory (Dir);
end if;
Save_Snapshot (Path, Helios.Monitor.Get_Report);
if Report.Period /= Ada.Real_Time.Time_Span_Zero then
Event.Repeat (Report.Period);
end if;
end Time_Handler;
-- ------------------------------
-- Write the collected snapshot in the file in JSON format.
-- ------------------------------
procedure Save_Snapshot (Path : in String;
Data : in Helios.Datas.Report_Queue_Type) is
procedure Write (Data : in Helios.Datas.Snapshot_Type;
Node : in Helios.Schemas.Definition_Type_Access);
File : aliased Util.Streams.Files.File_Stream;
Output : aliased Util.Streams.Texts.Print_Stream;
Stream : Util.Serialize.IO.JSON.Output_Stream;
procedure Write (Data : in Helios.Datas.Snapshot_Type;
Node : in Helios.Schemas.Definition_Type_Access) is
begin
Write_Snapshot (Stream, Data, Node);
end Write;
begin
Log.Info ("Saving snapshot to {0}", Path);
File.Create (Ada.Streams.Stream_IO.Out_File, Path);
Output.Initialize (File'Unchecked_Access);
Stream.Initialize (Output'Unchecked_Access);
Stream.Start_Document;
Helios.Datas.Iterate (Data, Write'Access);
Stream.End_Document;
Stream.Close;
end Save_Snapshot;
end Helios.Reports.Files;
|
apple-oss-distributions/old_ncurses | Ada | 8,926 | adb | ------------------------------------------------------------------------------
-- --
-- GNAT ncurses Binding Samples --
-- --
-- Sample.Curses_Demo.Mouse --
-- --
-- B O D Y --
-- --
------------------------------------------------------------------------------
-- Copyright (c) 1998 Free Software Foundation, Inc. --
-- --
-- Permission is hereby granted, free of charge, to any person obtaining a --
-- copy of this software and associated documentation files (the --
-- "Software"), to deal in the Software without restriction, including --
-- without limitation the rights to use, copy, modify, merge, publish, --
-- distribute, distribute with modifications, sublicense, and/or sell --
-- copies of the Software, and to permit persons to whom the Software is --
-- furnished to do so, subject to the following conditions: --
-- --
-- The above copyright notice and this permission notice shall be included --
-- in all copies or substantial portions of the Software. --
-- --
-- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS --
-- OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF --
-- MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. --
-- IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, --
-- DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR --
-- OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR --
-- THE USE OR OTHER DEALINGS IN THE SOFTWARE. --
-- --
-- Except as contained in this notice, the name(s) of the above copyright --
-- holders shall not be used in advertising or otherwise to promote the --
-- sale, use or other dealings in this Software without prior written --
-- authorization. --
------------------------------------------------------------------------------
-- Author: Juergen Pfeifer <[email protected]> 1996
-- Version Control
-- $Revision: 1.1.1.1 $
-- Binding Version 01.00
------------------------------------------------------------------------------
with Terminal_Interface.Curses; use Terminal_Interface.Curses;
with Terminal_Interface.Curses.Panels; use Terminal_Interface.Curses.Panels;
with Terminal_Interface.Curses.Mouse; use Terminal_Interface.Curses.Mouse;
with Terminal_Interface.Curses.Text_IO; use Terminal_Interface.Curses.Text_IO;
with Terminal_Interface.Curses.Text_IO.Integer_IO;
with Terminal_Interface.Curses.Text_IO.Enumeration_IO;
with Sample.Helpers; use Sample.Helpers;
with Sample.Manifest; use Sample.Manifest;
with Sample.Keyboard_Handler; use Sample.Keyboard_Handler;
with Sample.Function_Key_Setting; use Sample.Function_Key_Setting;
with Sample.Explanation; use Sample.Explanation;
package body Sample.Curses_Demo.Mouse is
package Int_IO is new
Terminal_Interface.Curses.Text_IO.Integer_IO (Integer);
use Int_IO;
package Button_IO is new
Terminal_Interface.Curses.Text_IO.Enumeration_IO (Mouse_Button);
use Button_IO;
package State_IO is new
Terminal_Interface.Curses.Text_IO.Enumeration_IO (Button_State);
use State_IO;
procedure Demo is
type Controls is array (1 .. 3) of Panel;
Frame : Window;
Msg : Window;
Ctl : Controls;
Pan : Panel;
K : Real_Key_Code;
V : Cursor_Visibility := Invisible;
W : Window;
Note : Window;
Msg_L : constant Line_Count := 8;
Lins : Line_Position := Lines;
Cols : Column_Position;
Mask : Event_Mask;
procedure Show_Mouse_Event;
procedure Show_Mouse_Event
is
Evt : constant Mouse_Event := Get_Mouse;
Y : Line_Position;
X : Column_Position;
Button : Mouse_Button;
State : Button_State;
W : Window;
begin
Get_Event (Evt, Y, X, Button, State);
Put (Msg, "Event at");
Put (Msg, " X="); Put (Msg, Integer (X), 3);
Put (Msg, ", Y="); Put (Msg, Integer (Y), 3);
Put (Msg, ", Btn="); Put (Msg, Button, 10);
Put (Msg, ", Stat="); Put (Msg, State, 15);
for I in Ctl'Range loop
W := Get_Window (Ctl (I));
if Enclosed_In_Window (W, Evt) then
Transform_Coordinates (W, Y, X, From_Screen);
Put (Msg, ",Box(");
Put (Msg, Integer (I), 1); Put (Msg, ",");
Put (Msg, Integer (Y), 1); Put (Msg, ",");
Put (Msg, Integer (X), 1); Put (Msg, ")");
end if;
end loop;
New_Line (Msg);
Flush (Msg);
Update_Panels; Update_Screen;
end Show_Mouse_Event;
begin
Push_Environment ("MOUSE00");
Notepad ("MOUSE-PAD00");
Default_Labels;
Set_Cursor_Visibility (V);
Note := Notepad_Window;
if Note /= Null_Window then
Get_Window_Position (Note, Lins, Cols);
end if;
Frame := Create (Msg_L, Columns, Lins - Msg_L, 0);
if Has_Colors then
Set_Background (Win => Frame,
Ch => (Color => Default_Colors,
Attr => Normal_Video,
Ch => ' '));
Set_Character_Attributes (Win => Frame,
Attr => Normal_Video,
Color => Default_Colors);
Erase (Frame);
end if;
Msg := Derived_Window (Frame, Msg_L - 2, Columns - 2, 1, 1);
Pan := Create (Frame);
Set_Meta_Mode;
Set_KeyPad_Mode;
Mask := Start_Mouse;
Box (Frame);
Window_Title (Frame, "Mouse Protocol");
Refresh_Without_Update (Frame);
Allow_Scrolling (Msg, True);
declare
Middle_Column : constant Integer := Integer (Columns) / 2;
Middle_Index : constant Natural := Ctl'First + (Ctl'Length / 2);
Width : constant Column_Count := 5;
Height : constant Line_Count := 3;
Half : constant Column_Count := Width / 2;
Space : constant Column_Count := 3;
Position : Integer;
W : Window;
begin
for I in Ctl'Range loop
Position := (Integer (I) - Integer (Middle_Index)) *
Integer (Half + Space + Width) + Middle_Column;
W := Create (Height,
Width,
1,
Column_Position (Position));
if Has_Colors then
Set_Background (Win => W,
Ch => (Color => Menu_Back_Color,
Attr => Normal_Video,
Ch => ' '));
Set_Character_Attributes (Win => W,
Attr => Normal_Video,
Color => Menu_Fore_Color);
Erase (W);
end if;
Ctl (I) := Create (W);
Box (W);
Move_Cursor (W, 1, Half);
Put (W, Integer (I), 1);
Refresh_Without_Update (W);
end loop;
end;
Update_Panels; Update_Screen;
loop
K := Get_Key;
if K in Special_Key_Code'Range then
case K is
when QUIT_CODE => exit;
when HELP_CODE => Explain_Context;
when EXPLAIN_CODE => Explain ("MOUSEKEYS");
when Key_Mouse => Show_Mouse_Event;
when others => null;
end case;
end if;
end loop;
for I in Ctl'Range loop
W := Get_Window (Ctl (I));
Clear (W);
Delete (Ctl (I));
Delete (W);
end loop;
Clear (Frame);
Delete (Pan);
Delete (Msg);
Delete (Frame);
Set_Cursor_Visibility (V);
End_Mouse (Mask);
Pop_Environment;
Update_Panels; Update_Screen;
end Demo;
end Sample.Curses_Demo.Mouse;
|
silky/synth | Ada | 43,588 | adb | -- This file is covered by the Internet Software Consortium (ISC) License
-- Reference: ../License.txt
with Ada.Strings.Hash;
with Ada.Calendar.Formatting;
with GNAT.Regpat;
with GNAT.String_Split;
with Signals;
with Unix;
package body PortScan is
package ACF renames Ada.Calendar.Formatting;
package RGX renames GNAT.Regpat;
package GSS renames GNAT.String_Split;
package SIG renames Signals;
------------------------------
-- scan_entire_ports_tree --
------------------------------
function scan_entire_ports_tree (portsdir : String) return Boolean
is
good_scan : Boolean;
using_screen : constant Boolean := Unix.screen_attached;
begin
-- tree must be already mounted in the scan slave.
-- However, prescan works on the real ports tree, not the mount.
if not prescanned then
prescan_ports_tree (portsdir);
end if;
scan_start := CAL.Clock;
parallel_deep_scan (success => good_scan, show_progress => using_screen);
scan_stop := CAL.Clock;
return good_scan;
end scan_entire_ports_tree;
------------------------
-- scan_single_port --
------------------------
function scan_single_port (catport : String; always_build : Boolean;
fatal : out Boolean)
return Boolean
is
xports : constant String := JT.USS (PM.configuration.dir_buildbase) &
ss_base & dir_ports;
procedure dig (cursor : block_crate.Cursor);
target : port_index;
aborted : Boolean := False;
indy500 : Boolean := False;
uscatport : JT.Text := JT.SUS (catport);
procedure dig (cursor : block_crate.Cursor)
is
new_target : port_index := block_crate.Element (cursor);
begin
if not aborted then
if all_ports (new_target).scan_locked then
-- We've already seen this (circular dependency)
raise circular_logic;
end if;
if not all_ports (new_target).scanned then
populate_port_data (new_target);
all_ports (new_target).scan_locked := True;
all_ports (new_target).blocked_by.Iterate (dig'Access);
all_ports (new_target).scan_locked := False;
if indy500 then
TIO.Put_Line ("... backtrace " &
get_catport (all_ports (new_target)));
end if;
end if;
end if;
exception
when issue : nonexistent_port =>
aborted := True;
TIO.Put_Line (LAT.LF & get_catport (all_ports (new_target)) &
" scan aborted because dependency could " &
"not be located.");
TIO.Put_Line (EX.Exception_Message (issue));
when issue : bmake_execution =>
aborted := True;
TIO.Put_Line (LAT.LF & get_catport (all_ports (new_target)) &
" scan aborted because 'make' encounted " &
"an error in the Makefile.");
TIO.Put_Line (EX.Exception_Message (issue));
when issue : make_garbage =>
aborted := True;
TIO.Put_Line (LAT.LF & get_catport (all_ports (new_target)) &
" scan aborted because dependency is malformed.");
TIO.Put_Line (EX.Exception_Message (issue));
when issue : circular_logic =>
aborted := True;
indy500 := True;
TIO.Put_Line (LAT.LF & catport &
" scan aborted because a circular dependency on " &
get_catport (all_ports (new_target)) &
" was detected.");
when issue : others =>
aborted := True;
declare
why : constant String := obvious_problem
(xports, get_catport (all_ports (new_target)));
begin
if why = "" then
TIO.Put_Line (LAT.LF & get_catport (all_ports (new_target)) &
" scan aborted for an unknown reason.");
TIO.Put_Line (EX.Exception_Message (issue));
else
TIO.Put_Line (LAT.LF & get_catport (all_ports (new_target)) &
" scan aborted" & why);
end if;
end;
end dig;
begin
fatal := False;
if not AD.Exists (xports & "/" & catport & "/Makefile") then
return False;
end if;
if not prescanned then
prescan_ports_tree (xports);
end if;
if ports_keys.Contains (Key => uscatport) then
target := ports_keys.Element (Key => uscatport);
else
return False;
end if;
begin
if all_ports (target).scanned then
-- This can happen when a dependency is also on the build list.
return True;
else
populate_port_data (target);
all_ports (target).never_remote := always_build;
end if;
exception
when issue : others =>
TIO.Put ("Encountered issue with " & catport &
" or its dependencies" & LAT.LF & " => ");
TIO.Put_Line (EX.Exception_Message (issue));
return False;
end;
all_ports (target).scan_locked := True;
all_ports (target).blocked_by.Iterate (dig'Access);
all_ports (target).scan_locked := False;
if indy500 then
TIO.Put_Line ("... backtrace " & catport);
fatal := True;
end if;
return not aborted;
end scan_single_port;
--------------------------
-- set_build_priority --
--------------------------
procedure set_build_priority is
begin
iterate_reverse_deps;
iterate_drill_down;
end set_build_priority;
------------------------
-- reset_ports_tree --
------------------------
procedure reset_ports_tree
is
PR : port_record_access;
begin
for k in dim_all_ports'Range loop
PR := all_ports (k)'Access;
PR.sequence_id := 0;
PR.key_cursor := portkey_crate.No_Element;
PR.jobs := 1;
PR.ignore_reason := JT.blank;
PR.port_version := JT.blank;
PR.package_name := JT.blank;
PR.pkg_dep_query := JT.blank;
PR.ignored := False;
PR.scanned := False;
PR.rev_scanned := False;
PR.unlist_failed := False;
PR.work_locked := False;
PR.scan_locked := False;
PR.pkg_present := False;
PR.remote_pkg := False;
PR.never_remote := False;
PR.deletion_due := False;
PR.use_procfs := False;
PR.use_linprocfs := False;
PR.reverse_score := 0;
PR.min_librun := 0;
PR.librun.Clear;
PR.blocks.Clear;
PR.blocked_by.Clear;
PR.all_reverse.Clear;
PR.options.Clear;
end loop;
ports_keys.Clear;
rank_queue.Clear;
lot_number := 1;
lot_counter := 0;
last_port := 0;
prescanned := False;
wipe_make_queue;
for m in scanners'Range loop
mq_progress (m) := 0;
end loop;
end reset_ports_tree;
-- PRIVATE FUNCTIONS --
--------------------------
-- iterate_drill_down --
--------------------------
procedure iterate_drill_down is
begin
rank_queue.Clear;
for port in port_index'First .. last_port loop
if all_ports (port).scanned then
drill_down (next_target => port, original_target => port);
declare
ndx : constant port_index :=
port_index (all_ports (port).reverse_score);
QR : constant queue_record :=
(ap_index => port,
reverse_score => ndx);
begin
rank_queue.Insert (New_Item => QR);
end;
end if;
end loop;
end iterate_drill_down;
--------------------------
-- parallel_deep_scan --
--------------------------
procedure parallel_deep_scan (success : out Boolean; show_progress : Boolean)
is
finished : array (scanners) of Boolean := (others => False);
combined_wait : Boolean := True;
aborted : Boolean := False;
task type scan (lot : scanners);
task body scan
is
procedure populate (cursor : subqueue.Cursor);
procedure populate (cursor : subqueue.Cursor)
is
target_port : port_index := subqueue.Element (cursor);
begin
if not aborted then
populate_port_data (target_port);
mq_progress (lot) := mq_progress (lot) + 1;
end if;
exception
when issue : others =>
TIO.Put_Line (LAT.LF & "culprit: " &
get_catport (all_ports (target_port)));
EX.Reraise_Occurrence (issue);
end populate;
begin
make_queue (lot).Iterate (populate'Access);
finished (lot) := True;
exception
when issue : nonexistent_port =>
aborted := True;
TIO.Put_Line ("Scan aborted because dependency could " &
"not be located.");
TIO.Put_Line (EX.Exception_Message (issue));
when issue : bmake_execution =>
aborted := True;
TIO.Put_Line ("Scan aborted because 'make' encounted " &
"an error in the Makefile.");
TIO.Put_Line (EX.Exception_Message (issue));
when issue : make_garbage =>
aborted := True;
TIO.Put_Line ("Scan aborted because dependency is malformed.");
TIO.Put_Line (EX.Exception_Message (issue));
when issue : others =>
aborted := True;
TIO.Put_Line ("Scan aborted for an unknown reason.");
TIO.Put_Line (EX.Exception_Message (issue));
end scan;
scan_01 : scan (lot => 1);
scan_02 : scan (lot => 2);
scan_03 : scan (lot => 3);
scan_04 : scan (lot => 4);
scan_05 : scan (lot => 5);
scan_06 : scan (lot => 6);
scan_07 : scan (lot => 7);
scan_08 : scan (lot => 8);
scan_09 : scan (lot => 9);
scan_10 : scan (lot => 10);
scan_11 : scan (lot => 11);
scan_12 : scan (lot => 12);
scan_13 : scan (lot => 13);
scan_14 : scan (lot => 14);
scan_15 : scan (lot => 15);
scan_16 : scan (lot => 16);
scan_17 : scan (lot => 17);
scan_18 : scan (lot => 18);
scan_19 : scan (lot => 19);
scan_20 : scan (lot => 20);
scan_21 : scan (lot => 21);
scan_22 : scan (lot => 22);
scan_23 : scan (lot => 23);
scan_24 : scan (lot => 24);
scan_25 : scan (lot => 25);
scan_26 : scan (lot => 26);
scan_27 : scan (lot => 27);
scan_28 : scan (lot => 28);
scan_29 : scan (lot => 29);
scan_30 : scan (lot => 30);
scan_31 : scan (lot => 31);
scan_32 : scan (lot => 32);
begin
TIO.Put_Line ("Scanning entire ports tree.");
while combined_wait loop
delay 1.0;
if show_progress then
TIO.Put (scan_progress);
end if;
combined_wait := False;
for j in scanners'Range loop
if not finished (j) then
combined_wait := True;
exit;
end if;
end loop;
if SIG.graceful_shutdown_requested then
aborted := True;
end if;
end loop;
success := not aborted;
end parallel_deep_scan;
-----------------------
-- wipe_make_queue --
-----------------------
procedure wipe_make_queue is
begin
for j in scanners'Range loop
make_queue (j).Clear;
end loop;
end wipe_make_queue;
------------------
-- drill_down --
------------------
procedure drill_down (next_target : port_index;
original_target : port_index)
is
PR : port_record_access := all_ports (next_target)'Access;
procedure stamp_and_drill (cursor : block_crate.Cursor);
procedure slurp_scanned (cursor : block_crate.Cursor);
procedure slurp_scanned (cursor : block_crate.Cursor)
is
rev_id : port_index := block_crate.Element (Position => cursor);
begin
if not all_ports (original_target).all_reverse.Contains (rev_id) then
all_ports (original_target).all_reverse.Insert
(Key => rev_id,
New_Item => rev_id);
end if;
end slurp_scanned;
procedure stamp_and_drill (cursor : block_crate.Cursor)
is
pmc : port_index := block_crate.Element (Position => cursor);
begin
if not all_ports (original_target).all_reverse.Contains (pmc) then
all_ports (original_target).all_reverse.Insert
(Key => pmc,
New_Item => pmc);
end if;
if pmc = original_target then
declare
top_port : constant String :=
get_catport (all_ports (original_target));
this_port : constant String :=
get_catport (all_ports (next_target));
begin
raise circular_logic with top_port & " <=> " & this_port;
end;
end if;
if not all_ports (pmc).rev_scanned then
drill_down (next_target => pmc, original_target => pmc);
end if;
all_ports (pmc).all_reverse.Iterate (slurp_scanned'Access);
end stamp_and_drill;
begin
if not PR.scanned then
return;
end if;
if PR.rev_scanned then
-- It is possible to get here if an earlier port scanned this port
-- as a reverse dependencies
return;
end if;
PR.blocks.Iterate (stamp_and_drill'Access);
PR.reverse_score := port_index (PR.all_reverse.Length);
PR.rev_scanned := True;
end drill_down;
----------------------------
-- iterate_reverse_deps --
-----------------------------
procedure iterate_reverse_deps
is
madre : port_index;
procedure set_reverse (cursor : block_crate.Cursor);
procedure set_reverse (cursor : block_crate.Cursor) is
begin
-- Using conditional insert here causes a finalization error when
-- the program exists. Reluctantly, do the condition check manually
if not all_ports (block_crate.Element (cursor)).blocks.Contains
(Key => madre)
then
all_ports (block_crate.Element (cursor)).blocks.Insert
(Key => madre, New_Item => madre);
end if;
end set_reverse;
begin
for port in port_index'First .. last_port loop
if all_ports (port).scanned then
madre := port;
all_ports (port).blocked_by.Iterate (set_reverse'Access);
end if;
end loop;
end iterate_reverse_deps;
--------------------
-- get_pkg_name --
--------------------
function get_pkg_name (origin : String) return String
is
fullport : constant String := dir_ports & "/" & origin;
ssroot : constant String := chroot &
JT.USS (PM.configuration.dir_buildbase) & ss_base;
command : constant String := ssroot & " " & chroot_make_program &
" .MAKE.EXPAND_VARIABLES=yes -C " & fullport & " -VPKGFILE:T";
content : JT.Text;
topline : JT.Text;
status : Integer;
begin
-- Same command for both ports collection and pkgsrc
content := Unix.piped_command (command, status);
if status /= 0 then
raise bmake_execution with origin &
" (return code =" & status'Img & ")";
end if;
JT.nextline (lineblock => content, firstline => topline);
return JT.USS (topline);
end get_pkg_name;
----------------------------
-- populate_set_depends --
----------------------------
procedure populate_set_depends (target : port_index;
catport : String;
line : JT.Text;
dtype : dependency_type)
is
subs : GSS.Slice_Set;
deps_found : GSS.Slice_Number;
trimline : constant JT.Text := JT.trim (line);
zero_deps : constant GSS.Slice_Number := GSS.Slice_Number (0);
dirlen : constant Natural := dir_ports'Length;
bracketed : Natural := 0;
use type GSS.Slice_Number;
begin
if JT.IsBlank (trimline) then
return;
end if;
GSS.Create (S => subs,
From => JT.USS (trimline),
Separators => " " & LAT.HT,
Mode => GSS.Multiple);
deps_found := GSS.Slice_Count (S => subs);
if deps_found = zero_deps then
return;
end if;
for j in 1 .. deps_found loop
declare
workdep : constant String := GSS.Slice (subs, j);
fulldep : constant String (1 .. workdep'Length) := workdep;
flen : constant Natural := fulldep'Length;
colon : constant Natural := find_colon (fulldep);
colon1 : constant Natural := colon + 1;
deprec : portkey_crate.Cursor;
use type portkey_crate.Cursor;
begin
if colon < 2 then
raise make_garbage
with dtype'Img & ": " & JT.USS (trimline) &
" (" & catport & ")";
end if;
if flen > colon1 + dirlen + 1 and then
fulldep (colon1 .. colon1 + dirlen) = dir_ports & "/"
then
deprec := ports_keys.Find
(Key => scrub_phase
(fulldep (colon + dirlen + 2 .. fulldep'Last)));
elsif flen > colon1 + 5 and then
fulldep (colon1 .. colon1 + 5) = "../../"
then
deprec := ports_keys.Find
(Key => scrub_phase
(fulldep (colon1 + 6 .. fulldep'Last)));
else
deprec := ports_keys.Find
(Key => scrub_phase
(fulldep (colon1 .. fulldep'Last)));
end if;
if deprec = portkey_crate.No_Element then
raise nonexistent_port
with fulldep &
" (required dependency of " & catport & ") does not exist.";
end if;
declare
depindex : port_index := portkey_crate.Element (deprec);
begin
if not all_ports (target).blocked_by.Contains (depindex) then
all_ports (target).blocked_by.Insert
(Key => depindex,
New_Item => depindex);
end if;
if dtype in LR_set then
if not all_ports (target).librun.Contains (depindex) then
all_ports (target).librun.Insert
(Key => depindex,
New_Item => depindex);
all_ports (target).min_librun :=
all_ports (target).min_librun + 1;
case software_framework is
when ports_collection => null;
when pkgsrc =>
if fulldep (1) = '{' then
bracketed := bracketed + 1;
end if;
end case;
end if;
end if;
end;
end;
end loop;
if bracketed > 0 and then all_ports (target).min_librun > 1 then
declare
newval : Integer := all_ports (target).min_librun - bracketed;
begin
if newval <= 1 then
all_ports (target).min_librun := 1;
else
all_ports (target).min_librun := newval;
end if;
end;
end if;
end populate_set_depends;
----------------------------
-- populate_set_options --
----------------------------
procedure populate_set_options (target : port_index;
line : JT.Text;
on : Boolean)
is
subs : GSS.Slice_Set;
opts_found : GSS.Slice_Number;
trimline : constant JT.Text := JT.trim (line);
zero_opts : constant GSS.Slice_Number := GSS.Slice_Number (0);
use type GSS.Slice_Number;
begin
if JT.IsBlank (trimline) then
return;
end if;
GSS.Create (S => subs,
From => JT.USS (trimline),
Separators => " ",
Mode => GSS.Multiple);
opts_found := GSS.Slice_Count (S => subs);
if opts_found = zero_opts then
return;
end if;
for j in 1 .. opts_found loop
declare
opt : JT.Text := JT.SUS (GSS.Slice (subs, j));
begin
if not all_ports (target).options.Contains (opt) then
all_ports (target).options.Insert (Key => opt,
New_Item => on);
end if;
end;
end loop;
end populate_set_options;
--------------------------
-- populate_port_data --
--------------------------
procedure populate_port_data (target : port_index) is
begin
case software_framework is
when ports_collection =>
populate_port_data_fpc (target);
when pkgsrc =>
populate_port_data_nps (target);
end case;
end populate_port_data;
------------------------------
-- populate_port_data_fpc --
------------------------------
procedure populate_port_data_fpc (target : port_index)
is
catport : String := get_catport (all_ports (target));
fullport : constant String := dir_ports & "/" & catport;
ssroot : constant String := chroot &
JT.USS (PM.configuration.dir_buildbase) & ss_base;
command : constant String :=
ssroot & " " & chroot_make_program & " -C " & fullport &
" -VPKGVERSION -VPKGFILE:T -VMAKE_JOBS_NUMBER -VIGNORE" &
" -VFETCH_DEPENDS -VEXTRACT_DEPENDS -VPATCH_DEPENDS" &
" -VBUILD_DEPENDS -VLIB_DEPENDS -VRUN_DEPENDS" &
" -VSELECTED_OPTIONS -VDESELECTED_OPTIONS -VUSE_LINUX";
content : JT.Text;
topline : JT.Text;
status : Integer;
type result_range is range 1 .. 13;
begin
content := Unix.piped_command (command, status);
if status /= 0 then
raise bmake_execution with catport &
" (return code =" & status'Img & ")";
end if;
for k in result_range loop
JT.nextline (lineblock => content, firstline => topline);
case k is
when 1 => all_ports (target).port_version := topline;
when 2 => all_ports (target).package_name := topline;
when 3 =>
begin
all_ports (target).jobs :=
builders (Integer'Value (JT.USS (topline)));
exception
when others =>
all_ports (target).jobs := PM.configuration.num_builders;
end;
when 4 => all_ports (target).ignore_reason := topline;
all_ports (target).ignored := not JT.IsBlank (topline);
when 5 => populate_set_depends (target, catport, topline, fetch);
when 6 => populate_set_depends (target, catport, topline, extract);
when 7 => populate_set_depends (target, catport, topline, patch);
when 8 => populate_set_depends (target, catport, topline, build);
when 9 => populate_set_depends (target, catport, topline, library);
when 10 => populate_set_depends (target, catport, topline, runtime);
when 11 => populate_set_options (target, topline, True);
when 12 => populate_set_options (target, topline, False);
when 13 =>
if not JT.IsBlank (JT.trim (topline)) then
all_ports (target).use_linprocfs := True;
end if;
end case;
end loop;
all_ports (target).scanned := True;
if catport = "x11-toolkits/gnustep-gui" then
all_ports (target).use_procfs := True;
end if;
if catport = "emulators/linux_base-c6" or else
catport = "emulators/linux_base-f10" or else
catport = "sysutils/htop"
then
all_ports (target).use_linprocfs := True;
end if;
exception
when issue : others =>
EX.Reraise_Occurrence (issue);
end populate_port_data_fpc;
------------------------------
-- populate_port_data_nps --
------------------------------
procedure populate_port_data_nps (target : port_index)
is
catport : String := get_catport (all_ports (target));
fullport : constant String := dir_ports & "/" & catport;
ssroot : constant String := chroot &
JT.USS (PM.configuration.dir_buildbase) & ss_base;
command : constant String :=
ssroot & " " & chroot_make_program & " -C " & fullport &
" .MAKE.EXPAND_VARIABLES=yes " &
" -VPKGVERSION -VPKGFILE:T -V_MAKE_JOBS:C/^-j//" &
" -V_CBBH_MSGS -VTOOL_DEPENDS -VBUILD_DEPENDS -VDEPENDS" &
" -VPKG_OPTIONS -VPKG_DISABLED_OPTIONS" &
" -VEMUL_PLATFORMS";
content : JT.Text;
topline : JT.Text;
status : Integer;
type result_range is range 1 .. 10;
begin
content := Unix.piped_command (command, status);
if status /= 0 then
raise bmake_execution with catport &
" (return code =" & status'Img & ")";
end if;
for k in result_range loop
JT.nextline (lineblock => content, firstline => topline);
case k is
when 1 => all_ports (target).port_version := topline;
when 2 => all_ports (target).package_name := topline;
when 3 =>
if JT.IsBlank (topline) then
all_ports (target).jobs := PM.configuration.num_builders;
else
begin
all_ports (target).jobs :=
builders (Integer'Value (JT.USS (topline)));
exception
when others =>
all_ports (target).jobs :=
PM.configuration.num_builders;
end;
end if;
when 4 =>
all_ports (target).ignore_reason :=
clean_up_pkgsrc_ignore_reason (JT.USS (topline));
all_ports (target).ignored := not JT.IsBlank (topline);
when 5 => populate_set_depends (target, catport, topline, build);
when 6 => populate_set_depends (target, catport, topline, build);
when 7 => populate_set_depends (target, catport, topline, runtime);
when 8 => populate_set_options (target, topline, True);
when 9 => populate_set_options (target, topline, False);
when 10 =>
if JT.contains (topline, "linux") then
all_ports (target).use_linprocfs := True;
end if;
end case;
end loop;
all_ports (target).scanned := True;
if catport = "x11/gnustep-gui" then
all_ports (target).use_procfs := True;
end if;
if catport = "sysutils/htop" then
all_ports (target).use_linprocfs := True;
end if;
exception
when issue : others =>
EX.Reraise_Occurrence (issue);
end populate_port_data_nps;
-----------------
-- set_cores --
-----------------
procedure set_cores
is
number : constant Positive := Replicant.Platform.get_number_cpus;
begin
if number > Positive (cpu_range'Last) then
number_cores := cpu_range'Last;
else
number_cores := cpu_range (number);
end if;
end set_cores;
-----------------------
-- cores_available --
-----------------------
function cores_available return cpu_range is
begin
return number_cores;
end cores_available;
--------------------------
-- prescan_ports_tree --
--------------------------
procedure prescan_ports_tree (portsdir : String)
is
package sorter is new string_crate.Generic_Sorting ("<" => JT.SU."<");
procedure quick_scan (cursor : string_crate.Cursor);
Search : AD.Search_Type;
Dir_Ent : AD.Directory_Entry_Type;
categories : string_crate.Vector;
-- scan entire ports tree, and for each port hooked into the build,
-- push an initial port_rec into the all_ports container
procedure quick_scan (cursor : string_crate.Cursor)
is
category : constant String :=
JT.USS (string_crate.Element (Position => cursor));
begin
if AD.Exists (portsdir & "/" & category & "/Makefile") then
grep_Makefile (portsdir => portsdir, category => category);
else
walk_all_subdirectories (portsdir => portsdir,
category => category);
end if;
end quick_scan;
begin
AD.Start_Search (Search => Search,
Directory => portsdir,
Filter => (AD.Directory => True, others => False),
Pattern => "[a-z]*");
while AD.More_Entries (Search => Search) loop
AD.Get_Next_Entry (Search => Search, Directory_Entry => Dir_Ent);
declare
category : constant String := AD.Simple_Name (Dir_Ent);
good_directory : Boolean := True;
begin
case software_framework is
when ports_collection =>
if category = "base" or else
category = "distfiles" or else
category = "packages"
then
good_directory := False;
end if;
when pkgsrc =>
if category = "bootstrap" or else
category = "distfiles" or else
category = "doc" or else
category = "licenses" or else
category = "mk" or else
category = "packages" or else
category = "regress"
then
good_directory := False;
end if;
end case;
if good_directory then
categories.Append (New_Item => JT.SUS (category));
end if;
end;
end loop;
AD.End_Search (Search => Search);
sorter.Sort (Container => categories);
categories.Iterate (Process => quick_scan'Access);
prescanned := True;
end prescan_ports_tree;
------------------
-- find_colon --
------------------
function find_colon (Source : String) return Natural
is
result : Natural := 0;
strlen : constant Natural := Source'Length;
begin
for j in 1 .. strlen loop
if Source (j) = LAT.Colon then
result := j;
exit;
end if;
end loop;
return result;
end find_colon;
-------------------
-- scrub_phase --
-------------------
function scrub_phase (Source : String) return JT.Text
is
reset : constant String (1 .. Source'Length) := Source;
colon : constant Natural := find_colon (reset);
begin
if colon = 0 then
return JT.SUS (reset);
end if;
return JT.SUS (reset (1 .. colon - 1));
end scrub_phase;
--------------------------
-- determine_max_lots --
--------------------------
function get_max_lots return scanners
is
first_try : constant Positive := Positive (number_cores) * 3;
begin
if first_try > Positive (scanners'Last) then
return scanners'Last;
else
return scanners (first_try);
end if;
end get_max_lots;
---------------------
-- grep_Makefile --
---------------------
procedure grep_Makefile (portsdir, category : String)
is
archive : TIO.File_Type;
matches : RGX.Match_Array (0 .. 1);
pattern : constant String := "^SUBDIR[[:space:]]*[:+:]=[[:space:]]*([[:graph:]]*)";
regex : constant RGX.Pattern_Matcher := RGX.Compile (pattern);
max_lots : constant scanners := get_max_lots;
begin
TIO.Open (File => archive,
Mode => TIO.In_File,
Name => portsdir & "/" & category & "/Makefile");
while not TIO.End_Of_File (File => archive) loop
declare
line : constant String := JT.trim (TIO.Get_Line (File => archive));
blank_rec : port_record;
kc : portkey_crate.Cursor;
success : Boolean;
use type RGX.Match_Location;
begin
RGX.Match (Self => regex, Data => line, Matches => matches);
if matches (0) /= RGX.No_Match then
declare
portkey : constant JT.Text := JT.SUS (category & '/' &
line (matches (1).First .. matches (1).Last));
begin
ports_keys.Insert (Key => portkey,
New_Item => lot_counter,
Position => kc,
Inserted => success);
last_port := lot_counter;
all_ports (lot_counter).sequence_id := lot_counter;
all_ports (lot_counter).key_cursor := kc;
make_queue (lot_number).Append (lot_counter);
end;
end if;
end;
lot_counter := lot_counter + 1;
if lot_number = max_lots then
lot_number := 1;
else
lot_number := lot_number + 1;
end if;
end loop;
TIO.Close (File => archive);
end grep_Makefile;
-------------------------------
-- walk_all_subdirectories --
-------------------------------
procedure walk_all_subdirectories (portsdir, category : String)
is
inner_search : AD.Search_Type;
inner_dirent : AD.Directory_Entry_Type;
max_lots : constant scanners := get_max_lots;
begin
AD.Start_Search (Search => inner_search,
Directory => portsdir & "/" & category,
Filter => (AD.Directory => True, others => False),
Pattern => "");
while AD.More_Entries (Search => inner_search) loop
AD.Get_Next_Entry (Search => inner_search,
Directory_Entry => inner_dirent);
declare
portname : constant String := AD.Simple_Name (inner_dirent);
portkey : constant JT.Text := JT.SUS (category & "/" & portname);
kc : portkey_crate.Cursor;
success : Boolean;
begin
if portname /= "." and then portname /= ".." then
ports_keys.Insert (Key => portkey,
New_Item => lot_counter,
Position => kc,
Inserted => success);
last_port := lot_counter;
all_ports (lot_counter).sequence_id := lot_counter;
all_ports (lot_counter).key_cursor := kc;
make_queue (lot_number).Append (lot_counter);
lot_counter := lot_counter + 1;
if lot_number = max_lots then
lot_number := 1;
else
lot_number := lot_number + 1;
end if;
end if;
end;
end loop;
end walk_all_subdirectories;
-----------------
-- port_hash --
-----------------
function port_hash (key : JT.Text) return AC.Hash_Type is
begin
return Ada.Strings.Hash (JT.USS (key));
end port_hash;
------------------
-- block_hash --
------------------
function block_hash (key : port_index) return AC.Hash_Type is
preresult : constant AC.Hash_Type := AC.Hash_Type (key);
use type AC.Hash_Type;
begin
-- Equivalent to mod 128
return preresult and 2#1111111#;
end block_hash;
------------------
-- block_ekey --
------------------
function block_ekey (left, right : port_index) return Boolean is
begin
return left = right;
end block_ekey;
--------------------------------------
-- "<" function for ranking_crate --
--------------------------------------
function "<" (L, R : queue_record) return Boolean is
begin
if L.reverse_score = R.reverse_score then
return R.ap_index > L.ap_index;
end if;
return L.reverse_score > R.reverse_score;
end "<";
-------------------
-- get_catport --
-------------------
function get_catport (PR : port_record) return String
is
use type portkey_crate.Cursor;
begin
if PR.key_cursor = portkey_crate.No_Element then
return "get_catport: invalid key_cursor";
end if;
return JT.USS (portkey_crate.Key (PR.key_cursor));
end get_catport;
---------------------
-- scan_progress --
---------------------
function scan_progress return String
is
type percent is delta 0.01 digits 5;
complete : port_index := 0;
pc : percent;
begin
for k in scanners'Range loop
complete := complete + mq_progress (k);
end loop;
pc := percent (100.0 * Float (complete) / Float (last_port));
return " progress:" & pc'Img & "% " & LAT.CR;
end scan_progress;
-----------------------
-- obvious_problem --
-----------------------
function obvious_problem (portsdir, catport : String) return String
is
fullpath : constant String := portsdir & "/" & catport;
begin
if AD.Exists (fullpath) then
declare
Search : AD.Search_Type;
dirent : AD.Directory_Entry_Type;
has_contents : Boolean := False;
begin
AD.Start_Search (Search => Search,
Directory => fullpath,
Filter => (others => True),
Pattern => "*");
while AD.More_Entries (Search => Search) loop
AD.Get_Next_Entry (Search => Search, Directory_Entry => dirent);
if AD.Simple_Name (dirent) /= "." and then
AD.Simple_Name (dirent) /= ".."
then
has_contents := True;
exit;
end if;
end loop;
AD.End_Search (Search => Search);
if not has_contents then
return " (directory empty)";
end if;
if AD.Exists (fullpath & "/Makefile") then
return "";
else
return " (Makefile missing)";
end if;
end;
else
return " (port deleted)";
end if;
end obvious_problem;
-------------------------------------
-- clean_up_pkgsrc_ignore_reason --
-------------------------------------
function clean_up_pkgsrc_ignore_reason (dirty_string : String) return JT.Text
is
-- 1. strip out all double-quotation marks
-- 2. strip out all single reverse solidus ("\")
-- 3. condense contiguous spaces to a single space
function strip_this_package_has_set (raw : String) return String;
function strip_this_package_has_set (raw : String) return String
is
pattern : constant String := "This package has set ";
begin
if JT.contains (raw, pattern) then
declare
uno : String := JT.part_1 (raw, pattern);
duo : String := JT.part_2 (raw, pattern);
begin
return strip_this_package_has_set (uno & duo);
end;
else
return raw;
end if;
end strip_this_package_has_set;
product : String (1 .. dirty_string'Length);
dstx : Natural := 0;
keep_it : Boolean;
last_was_slash : Boolean := False;
last_was_space : Boolean := False;
begin
for srcx in dirty_string'Range loop
keep_it := True;
case dirty_string (srcx) is
when LAT.Quotation | LAT.LF =>
keep_it := False;
when LAT.Reverse_Solidus =>
if not last_was_slash then
keep_it := False;
end if;
last_was_slash := not last_was_slash;
when LAT.Space =>
if last_was_space then
keep_it := False;
end if;
last_was_space := True;
last_was_slash := False;
when others =>
last_was_space := False;
last_was_slash := False;
end case;
if keep_it then
dstx := dstx + 1;
product (dstx) := dirty_string (srcx);
end if;
end loop;
return JT.SUS (strip_this_package_has_set (product (1 .. dstx)));
end clean_up_pkgsrc_ignore_reason;
-----------------
-- timestamp --
-----------------
function timestamp (hack : CAL.Time; www_format : Boolean := False) return String
is
function MON (num : CAL.Month_Number) return String;
function WKDAY (day : ACF.Day_Name) return String;
function MON (num : CAL.Month_Number) return String is
begin
case num is
when 1 => return "JAN";
when 2 => return "FEB";
when 3 => return "MAR";
when 4 => return "APR";
when 5 => return "MAY";
when 6 => return "JUN";
when 7 => return "JUL";
when 8 => return "AUG";
when 9 => return "SEP";
when 10 => return "OCT";
when 11 => return "NOV";
when 12 => return "DEC";
end case;
end MON;
function WKDAY (day : ACF.Day_Name) return String is
begin
case day is
when ACF.Monday => return "Monday";
when ACF.Tuesday => return "Tuesday";
when ACF.Wednesday => return "Wednesday";
when ACF.Thursday => return "Thursday";
when ACF.Friday => return "Friday";
when ACF.Saturday => return "Saturday";
when ACF.Sunday => return "Sunday";
end case;
end WKDAY;
begin
if www_format then
return CAL.Day (hack)'Img & " " & MON (CAL.Month (hack)) & CAL.Year (hack)'Img & ", " &
ACF.Image (hack)(11 .. 19) & " UTC";
end if;
return WKDAY (ACF.Day_Of_Week (hack)) & "," & CAL.Day (hack)'Img & " " &
MON (CAL.Month (hack)) & CAL.Year (hack)'Img & " at" &
ACF.Image (hack)(11 .. 19) & " UTC";
end timestamp;
end PortScan;
|
reznikmm/matreshka | Ada | 4,741 | adb | ------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- XML Processor --
-- --
-- Testsuite Component --
-- --
------------------------------------------------------------------------------
-- --
-- Copyright © 2012-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.Strings;
with XML.SAX.Simple_Readers;
with XML.SAX.String_Input_Sources;
with Test_245_Handlers;
procedure Test_245 is
procedure Run_Testcase (Testcase : Test_245_Handlers.Testcases);
------------------
-- Run_Testcase --
------------------
procedure Run_Testcase (Testcase : Test_245_Handlers.Testcases) is
Source : aliased XML.SAX.String_Input_Sources.String_Input_Source;
Handler : aliased Test_245_Handlers.Test_Handler;
Reader : aliased XML.SAX.Simple_Readers.Simple_Reader;
begin
Handler.Set_Testcase (Testcase);
Source.Set_String
(League.Strings.To_Universal_String
("<?xml version='1.0'?>"
& "<!DOCTYPE element ["
& "<!ELEMENT element (text)*>"
& "<!ATTLIST element xmlns CDATA #IMPLIED>"
& "<!ELEMENT text (#PCDATA)>"
& "]>"
& "<element xmlns='http://forge.ada-ru.org/'>"
& " <?PI?>"
& " <text>Text</text>"
& "</element>"));
Reader.Set_Error_Handler (Handler'Unchecked_Access);
Reader.Set_Content_Handler (Handler'Unchecked_Access);
Reader.Parse (Source'Unchecked_Access);
if not Handler.Is_Passed then
raise Program_Error;
end if;
end Run_Testcase;
begin
for J in Test_245_Handlers.Testcases loop
Run_Testcase (J);
end loop;
end Test_245;
|
reznikmm/matreshka | Ada | 7,000 | 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.Enhanced_Geometry_Elements is
------------
-- Create --
------------
overriding function Create
(Parameters : not null access Matreshka.DOM_Elements.Element_L2_Parameters)
return Draw_Enhanced_Geometry_Element_Node is
begin
return Self : Draw_Enhanced_Geometry_Element_Node do
Matreshka.ODF_Draw.Constructors.Initialize
(Self'Unchecked_Access,
Parameters.Document,
Matreshka.ODF_String_Constants.Draw_Prefix);
end return;
end Create;
----------------
-- Enter_Node --
----------------
overriding procedure Enter_Node
(Self : not null access Draw_Enhanced_Geometry_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_Draw_Enhanced_Geometry
(ODF.DOM.Draw_Enhanced_Geometry_Elements.ODF_Draw_Enhanced_Geometry_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 Draw_Enhanced_Geometry_Element_Node)
return League.Strings.Universal_String
is
pragma Unreferenced (Self);
begin
return Matreshka.ODF_String_Constants.Enhanced_Geometry_Element;
end Get_Local_Name;
----------------
-- Leave_Node --
----------------
overriding procedure Leave_Node
(Self : not null access Draw_Enhanced_Geometry_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_Draw_Enhanced_Geometry
(ODF.DOM.Draw_Enhanced_Geometry_Elements.ODF_Draw_Enhanced_Geometry_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 Draw_Enhanced_Geometry_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_Draw_Enhanced_Geometry
(Visitor,
ODF.DOM.Draw_Enhanced_Geometry_Elements.ODF_Draw_Enhanced_Geometry_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.Draw_URI,
Matreshka.ODF_String_Constants.Enhanced_Geometry_Element,
Draw_Enhanced_Geometry_Element_Node'Tag);
end Matreshka.ODF_Draw.Enhanced_Geometry_Elements;
|
reznikmm/matreshka | Ada | 6,780 | 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_Dr3d.Rotate_Elements is
------------
-- Create --
------------
overriding function Create
(Parameters : not null access Matreshka.DOM_Elements.Element_L2_Parameters)
return Dr3d_Rotate_Element_Node is
begin
return Self : Dr3d_Rotate_Element_Node do
Matreshka.ODF_Dr3d.Constructors.Initialize
(Self'Unchecked_Access,
Parameters.Document,
Matreshka.ODF_String_Constants.Dr3d_Prefix);
end return;
end Create;
----------------
-- Enter_Node --
----------------
overriding procedure Enter_Node
(Self : not null access Dr3d_Rotate_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_Dr3d_Rotate
(ODF.DOM.Dr3d_Rotate_Elements.ODF_Dr3d_Rotate_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 Dr3d_Rotate_Element_Node)
return League.Strings.Universal_String
is
pragma Unreferenced (Self);
begin
return Matreshka.ODF_String_Constants.Rotate_Element;
end Get_Local_Name;
----------------
-- Leave_Node --
----------------
overriding procedure Leave_Node
(Self : not null access Dr3d_Rotate_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_Dr3d_Rotate
(ODF.DOM.Dr3d_Rotate_Elements.ODF_Dr3d_Rotate_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 Dr3d_Rotate_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_Dr3d_Rotate
(Visitor,
ODF.DOM.Dr3d_Rotate_Elements.ODF_Dr3d_Rotate_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.Dr3d_URI,
Matreshka.ODF_String_Constants.Rotate_Element,
Dr3d_Rotate_Element_Node'Tag);
end Matreshka.ODF_Dr3d.Rotate_Elements;
|
tum-ei-rcs/StratoX | Ada | 13,382 | ads | ------------------------------------------------------------------------------
-- --
-- Copyright (C) 2015, AdaCore --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions are --
-- met: --
-- 1. Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- 2. Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in --
-- the documentation and/or other materials provided with the --
-- distribution. --
-- 3. Neither the name of STMicroelectronics nor the names of its --
-- contributors may be used to endorse or promote products derived --
-- from this software without specific prior written permission. --
-- --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR --
-- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
-- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT --
-- LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, --
-- DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY --
-- THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT --
-- (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE --
-- OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
-- --
-- --
-- This file is based on: --
-- --
-- @file stm32f4xx_hal_dac.h and stm32f4xx_hal_dac_ex.h --
-- @author MCD Application Team --
-- @version V1.3.1 --
-- @date 25-March-2015 --
-- @brief Header file of DAC HAL module. --
-- --
-- COPYRIGHT(c) 2014 STMicroelectronics --
------------------------------------------------------------------------------
-- This file provides interfaces for the digital-to-analog converters on the
-- STM32F4 (ARM Cortex M4F) microcontrollers from ST Microelectronics.
with System; use System;
private with STM32_SVD.DAC;
package STM32.DAC is
type Digital_To_Analog_Converter is limited private;
type DAC_Channel is (Channel_1, Channel_2);
-- Note that Channel 1 is tied to GPIO pin PA4, and Channel 2 to PA5
procedure Enable
(This : in out Digital_To_Analog_Converter;
Channel : DAC_Channel)
with
Inline,
Post => Enabled (This, Channel);
-- Powers up the channel. The channel is then enabled after a startup
-- time "Twakeup" specified in the datasheet.
--
-- NB: When no hardware trigger has been selected, the value in the
-- DAC_DHRx register is transfered automatically to the DOR register.
-- Therefore, in that case enabling the channel starts the output
-- conversion on that channel. See the RM, section 14.3.4 "DAC
-- conversion" second and third paragraphs.
procedure Disable
(This : in out Digital_To_Analog_Converter;
Channel : DAC_Channel)
with
Inline,
Post => not Enabled (This, Channel);
-- When the software trigger has been selected, disabling the channel stops
-- the output conversion on that channel.
function Enabled
(This : Digital_To_Analog_Converter;
Channel : DAC_Channel)
return Boolean;
type DAC_Resolution is (DAC_Resolution_12_Bits, DAC_Resolution_8_Bits);
Max_12bit_Resolution : constant := 16#0FFF#;
Max_8bit_Resolution : constant := 16#00FF#;
type Data_Alignment is (Left_Aligned, Right_Aligned);
procedure Set_Output
(This : in out Digital_To_Analog_Converter;
Channel : DAC_Channel;
Value : Word;
Resolution : DAC_Resolution;
Alignment : Data_Alignment);
-- For the specified channel, writes the output Value to the data holding
-- register within This corresponding to the Resolution and Alignment.
--
-- The output voltage = ((Value / Max_nbit_Counts) * VRef+), where VRef+ is
-- the reference input voltage and the 'n' of Max_nbit_Counts is either 12
-- or 8.
procedure Trigger_Conversion_By_Software
(This : in out Digital_To_Analog_Converter;
Channel : DAC_Channel)
with
Pre => Trigger_Selection (This, Channel) = Software_Trigger and
Trigger_Enabled (This, Channel);
-- Cause the conversion to occur and the output to appear, per 14.3.6 "DAC
-- trigger selection" in the RM. This routine is needed when the Software
-- Trigger has been selected and the trigger has been enabled, otherwise no
-- conversion occurs. If you don't enable the trigger any prior selection
-- has no effect, but note that when no *hardware* trigger is selected the
-- output happens automatically when the channel is enabled. See the RM,
-- section 14.3.4 "DAC conversion" second and third paragraphs.
function Converted_Output_Value
(This : Digital_To_Analog_Converter;
Channel : DAC_Channel)
return Word;
-- Returns the latest output value for the specified channel.
procedure Set_Dual_Output_Voltages
(This : in out Digital_To_Analog_Converter;
Channel_1_Value : Word;
Channel_2_Value : Word;
Resolution : DAC_Resolution;
Alignment : Data_Alignment);
type Dual_Channel_Output is record
Channel_1_Data : Short;
Channel_2_Data : Short;
end record;
function Converted_Dual_Output_Value (This : Digital_To_Analog_Converter)
return Dual_Channel_Output;
-- Returns the combination of the latest output values for both channels.
procedure Enable_Output_Buffer
(This : in out Digital_To_Analog_Converter;
Channel : DAC_Channel)
with Post => Output_Buffer_Enabled (This, Channel);
procedure Disable_Output_Buffer
(This : in out Digital_To_Analog_Converter;
Channel : DAC_Channel)
with Post => not Output_Buffer_Enabled (This, Channel);
function Output_Buffer_Enabled
(This : Digital_To_Analog_Converter;
Channel : DAC_Channel)
return Boolean;
type External_Event_Trigger_Selection is
(Timer_6_Output_Trigger,
Timer_8_Output_Trigger,
Timer_7_Output_Trigger,
Timer_5_Output_Trigger,
Timer_2_Output_Trigger,
Timer_4_Output_Trigger,
EXTI_Line_9_Trigger, -- any GPIO_x Pin_9
Software_Trigger);
procedure Select_Trigger
(This : in out Digital_To_Analog_Converter;
Channel : DAC_Channel;
Trigger : External_Event_Trigger_Selection)
with
Pre => not Trigger_Enabled (This, Channel), -- per note in RM, pg 435
Post => Trigger_Selection (This, Channel) = Trigger and
not Trigger_Enabled (This, Channel);
-- If the software trigger is selected, output conversion starts once the
-- channel is enabled.
function Trigger_Selection
(This : Digital_To_Analog_Converter;
Channel : DAC_Channel)
return External_Event_Trigger_Selection;
procedure Enable_Trigger
(This : in out Digital_To_Analog_Converter;
Channel : DAC_Channel)
with Post => Trigger_Enabled (This, Channel);
procedure Disable_Trigger
(This : in out Digital_To_Analog_Converter;
Channel : DAC_Channel)
with Post => not Trigger_Enabled (This, Channel);
function Trigger_Enabled
(This : Digital_To_Analog_Converter;
Channel : DAC_Channel)
return Boolean;
procedure Enable_DMA
(This : in out Digital_To_Analog_Converter;
Channel : DAC_Channel)
with Post => DMA_Enabled (This, Channel);
procedure Disable_DMA
(This : in out Digital_To_Analog_Converter;
Channel : DAC_Channel)
with Post => not DMA_Enabled (This, Channel);
function DMA_Enabled
(This : Digital_To_Analog_Converter;
Channel : DAC_Channel)
return Boolean;
type DAC_Status_Flag is
(DMA_Underrun_Channel_1,
DMA_Underrun_Channel_2);
-- For the indicated channel, the currently selected trigger is driving the
-- channel conversion at a frequency higher than the DMA service capability
-- rate
function Status
(This : Digital_To_Analog_Converter;
Flag : DAC_Status_Flag)
return Boolean;
procedure Clear_Status
(This : in out Digital_To_Analog_Converter;
Flag : DAC_Status_Flag)
with
Inline,
Post => not Status (This, Flag);
type DAC_Interrupts is
(DMA_Underrun_Channel_1,
DMA_Underrun_Channel_2);
procedure Enable_Interrupts
(This : in out Digital_To_Analog_Converter;
Source : DAC_Interrupts)
with
Inline,
Post => Interrupt_Enabled (This, Source);
procedure Disable_Interrupts
(This : in out Digital_To_Analog_Converter;
Source : DAC_Interrupts)
with
Inline,
Post => not Interrupt_Enabled (This, Source);
function Interrupt_Enabled
(This : Digital_To_Analog_Converter;
Source : DAC_Interrupts)
return Boolean
with Inline;
function Interrupt_Source
(This : Digital_To_Analog_Converter)
return DAC_Interrupts
with Inline;
procedure Clear_Interrupt_Pending
(This : in out Digital_To_Analog_Converter;
Channel : DAC_Channel)
with Inline;
type Wave_Generation_Selection is
(No_Wave_Generation,
Noise_Wave,
Triangle_Wave);
type Noise_Wave_Mask_Selection is
(LFSR_Unmask_Bit0,
LFSR_Unmask_Bits1_0,
LFSR_Unmask_Bits2_0,
LFSR_Unmask_Bits3_0,
LFSR_Unmask_Bits4_0,
LFSR_Unmask_Bits5_0,
LFSR_Unmask_Bits6_0,
LFSR_Unmask_Bits7_0,
LFSR_Unmask_Bits8_0,
LFSR_Unmask_Bits9_0,
LFSR_Unmask_Bits10_0,
LFSR_Unmask_Bits11_0);
-- Unmask LFSR bits for noise wave generation
type Triangle_Wave_Amplitude_Selection is
(Triangle_Amplitude_1, -- Select max triangle amplitude of 1
Triangle_Amplitude_3, -- Select max triangle amplitude of 3
Triangle_Amplitude_7, -- Select max triangle amplitude of 7
Triangle_Amplitude_15, -- Select max triangle amplitude of 15
Triangle_Amplitude_31, -- Select max triangle amplitude of 31
Triangle_Amplitude_63, -- Select max triangle amplitude of 63
Triangle_Amplitude_127, -- Select max triangle amplitude of 127
Triangle_Amplitude_255, -- Select max triangle amplitude of 255
Triangle_Amplitude_511, -- Select max triangle amplitude of 511
Triangle_Amplitude_1023, -- Select max triangle amplitude of 1023
Triangle_Amplitude_2047, -- Select max triangle amplitude of 2047
Triangle_Amplitude_4095); -- Select max triangle amplitude of 4095
type Wave_Generation (Kind : Wave_Generation_Selection) is record
case Kind is
when No_Wave_Generation =>
null;
when Noise_Wave =>
Mask : Noise_Wave_Mask_Selection;
when Triangle_Wave =>
Amplitude : Triangle_Wave_Amplitude_Selection;
end case;
end record;
Wave_Generation_Disabled : constant Wave_Generation :=
(Kind => No_Wave_Generation);
procedure Select_Wave_Generation
(This : in out Digital_To_Analog_Converter;
Channel : DAC_Channel;
Selection : Wave_Generation)
with Post => Selected_Wave_Generation (This, Channel) = Selection;
function Selected_Wave_Generation
(This : Digital_To_Analog_Converter;
Channel : DAC_Channel)
return Wave_Generation;
function Data_Address
(This : Digital_To_Analog_Converter;
Channel : DAC_Channel;
Resolution : DAC_Resolution;
Alignment : Data_Alignment)
return Address;
-- Returns the address of the Data Holding register within This, for the
-- specified Channel, at the specified Resolution and Alignment.
--
-- This function is stricly for use with DMA, all others use the API above.
private
type Digital_To_Analog_Converter is new STM32_SVD.DAC.DAC_Peripheral;
end STM32.DAC;
|
zhmu/ananas | Ada | 275 | adb | -- { dg-do run }
-- { dg-options "-gnatws" }
with System.OS_Lib; use System.OS_Lib;
procedure Split_Args is
X : constant Argument_List_Access :=
Argument_String_To_List (" -v");
begin
if X'Length /= 1 then
raise Program_Error;
end if;
end Split_Args;
|
eqcola/ada-ado | Ada | 3,109 | adb | -----------------------------------------------------------------------
-- ADO Dialects -- Driver support for basic SQL Generation
-- Copyright (C) 2010, 2011, 2012, 2015 Stephane Carrez
-- Written by Stephane Carrez ([email protected])
--
-- Licensed under the Apache License, Version 2.0 (the "License");
-- you may not use this file except in compliance with the License.
-- You may obtain a copy of the License at
--
-- http://www.apache.org/licenses/LICENSE-2.0
--
-- Unless required by applicable law or agreed to in writing, software
-- distributed under the License is distributed on an "AS IS" BASIS,
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-- See the License for the specific language governing permissions and
-- limitations under the License.
-----------------------------------------------------------------------
package body ADO.Drivers.Dialects is
-- --------------------
-- Get the quote character to escape an identifier.
-- --------------------
function Get_Identifier_Quote (D : in Dialect) return Character is
pragma Unreferenced (D);
begin
return '`';
end Get_Identifier_Quote;
-- ------------------------------
-- Append the item in the buffer escaping some characters if necessary.
-- The default implementation only escapes the single quote ' by doubling them.
-- ------------------------------
procedure Escape_Sql (D : in Dialect;
Buffer : in out Unbounded_String;
Item : in String) is
pragma Unreferenced (D);
C : Character;
begin
for I in Item'Range loop
C := Item (I);
if C = ''' then
Append (Buffer, ''');
end if;
Append (Buffer, C);
end loop;
end Escape_Sql;
-- ------------------------------
-- Append the item in the buffer escaping some characters if necessary
-- ------------------------------
procedure Escape_Sql (D : in Dialect;
Buffer : in out Unbounded_String;
Item : in ADO.Blob_Ref) is
pragma Unreferenced (D);
use type Ada.Streams.Stream_Element;
C : Ada.Streams.Stream_Element;
Blob : constant ADO.Blob_Access := Item.Value;
begin
for I in Blob.Data'Range loop
C := Blob.Data (I);
case C is
when Character'Pos (ASCII.NUL) =>
Append (Buffer, '\');
Append (Buffer, '0');
when Character'Pos (ASCII.CR) =>
Append (Buffer, '\');
Append (Buffer, 'r');
when Character'Pos (ASCII.LF) =>
Append (Buffer, '\');
Append (Buffer, 'n');
when Character'Pos ('\') | Character'Pos (''') | Character'Pos ('"') =>
Append (Buffer, '\');
Append (Buffer, Character'Val (C));
when others =>
Append (Buffer, Character'Val (C));
end case;
end loop;
end Escape_Sql;
end ADO.Drivers.Dialects;
|
zhmu/ananas | Ada | 52,736 | adb | ------------------------------------------------------------------------------
-- --
-- GNAT RUN-TIME COMPONENTS --
-- --
-- A D A . W I D E _ W I D E _ T E X T _ I O --
-- --
-- B o d y --
-- --
-- Copyright (C) 1992-2022, Free Software Foundation, Inc. --
-- --
-- GNAT is free software; you can redistribute it and/or modify it under --
-- terms of the GNU General Public License as published by the Free Soft- --
-- ware Foundation; either version 3, or (at your option) any later ver- --
-- sion. GNAT is distributed in the hope that it will be useful, but WITH- --
-- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY --
-- or FITNESS FOR A PARTICULAR PURPOSE. --
-- --
-- As a special exception under Section 7 of GPL version 3, you are granted --
-- additional permissions described in the GCC Runtime Library Exception, --
-- version 3.1, as published by the Free Software Foundation. --
-- --
-- You should have received a copy of the GNU General Public License and --
-- a copy of the GCC Runtime Library Exception along with this program; --
-- see the files COPYING3 and COPYING.RUNTIME respectively. If not, see --
-- <http://www.gnu.org/licenses/>. --
-- --
-- GNAT was originally developed by the GNAT team at New York University. --
-- Extensive contributions were provided by Ada Core Technologies Inc. --
-- --
------------------------------------------------------------------------------
with Ada.Streams; use Ada.Streams;
with Interfaces.C_Streams; use Interfaces.C_Streams;
with System.CRTL;
with System.File_IO;
with System.WCh_Cnv; use System.WCh_Cnv;
with System.WCh_Con; use System.WCh_Con;
with Ada.Unchecked_Conversion;
with Ada.Unchecked_Deallocation;
pragma Elaborate_All (System.File_IO);
-- Needed because of calls to Chain_File in package body elaboration
package body Ada.Wide_Wide_Text_IO is
package FIO renames System.File_IO;
subtype AP is FCB.AFCB_Ptr;
function To_FCB is new Ada.Unchecked_Conversion (File_Mode, FCB.File_Mode);
function To_TIO is new Ada.Unchecked_Conversion (FCB.File_Mode, File_Mode);
use type FCB.File_Mode;
use type System.CRTL.size_t;
WC_Encoding : constant Character;
pragma Import (C, WC_Encoding, "__gl_wc_encoding");
-- Default wide character encoding
Err_Name : aliased String := "*stderr" & ASCII.NUL;
In_Name : aliased String := "*stdin" & ASCII.NUL;
Out_Name : aliased String := "*stdout" & ASCII.NUL;
-- Names of standard files
--
-- Use "preallocated" strings to avoid calling "new" during the elaboration
-- of the run time. This is needed in the tasking case to avoid calling
-- Task_Lock too early. A filename is expected to end with a null character
-- in the runtime, here the null characters are added just to have a
-- correct filename length.
--
-- Note: the names for these files are bogus, and probably it would be
-- better for these files to have no names, but the ACVC tests insist.
-- We use names that are bound to fail in open etc.
Null_Str : aliased constant String := "";
-- Used as form string for standard files
-----------------------
-- Local Subprograms --
-----------------------
function Get_Wide_Wide_Char_Immed
(C : Character;
File : File_Type) return Wide_Wide_Character;
-- This routine is identical to Get_Wide_Wide_Char, except that the reads
-- are done in Get_Immediate mode (i.e. without waiting for a line return).
function Getc_Immed (File : File_Type) return int;
-- This routine is identical to Getc, except that the read is done in
-- Get_Immediate mode (i.e. without waiting for a line return).
procedure Putc (ch : int; File : File_Type);
-- Outputs the given character to the file, which has already been checked
-- for being in output status. Device_Error is raised if the character
-- cannot be written.
procedure Set_WCEM (File : in out File_Type);
-- Called by Open and Create to set the wide character encoding method for
-- the file, processing a WCEM form parameter if one is present. File is
-- IN OUT because it may be closed in case of an error.
procedure Terminate_Line (File : File_Type);
-- If the file is in Write_File or Append_File mode, and the current line
-- is not terminated, then a line terminator is written using New_Line.
-- Note that there is no Terminate_Page routine, because the page mark at
-- the end of the file is implied if necessary.
procedure Ungetc (ch : int; File : File_Type);
-- Pushes back character into stream, using ungetc. The caller has checked
-- that the file is in read status. Device_Error is raised if the character
-- cannot be pushed back. An attempt to push back and end of file character
-- (EOF) is ignored.
-------------------
-- AFCB_Allocate --
-------------------
function AFCB_Allocate
(Control_Block : Wide_Wide_Text_AFCB) return FCB.AFCB_Ptr
is
pragma Unreferenced (Control_Block);
begin
return new Wide_Wide_Text_AFCB;
end AFCB_Allocate;
----------------
-- AFCB_Close --
----------------
procedure AFCB_Close (File : not null access Wide_Wide_Text_AFCB) is
begin
-- If the file being closed is one of the current files, then close
-- the corresponding current file. It is not clear that this action
-- is required (RM A.10.3(23)) but it seems reasonable, and besides
-- ACVC test CE3208A expects this behavior.
if File = Current_In then
Current_In := null;
elsif File = Current_Out then
Current_Out := null;
elsif File = Current_Err then
Current_Err := null;
end if;
Terminate_Line (File.all'Access);
end AFCB_Close;
---------------
-- AFCB_Free --
---------------
procedure AFCB_Free (File : not null access Wide_Wide_Text_AFCB) is
FT : File_Type := File.all'Access;
procedure Free is new
Ada.Unchecked_Deallocation (Wide_Wide_Text_AFCB, File_Type);
begin
Free (FT);
end AFCB_Free;
-----------
-- Close --
-----------
procedure Close (File : in out File_Type) is
begin
FIO.Close (AP (File)'Unrestricted_Access);
end Close;
---------
-- Col --
---------
-- Note: we assume that it is impossible in practice for the column
-- to exceed the value of Count'Last, i.e. no check is required for
-- overflow raising layout error.
function Col (File : File_Type) return Positive_Count is
begin
FIO.Check_File_Open (AP (File));
return File.Col;
end Col;
function Col return Positive_Count is
begin
return Col (Current_Out);
end Col;
------------
-- Create --
------------
procedure Create
(File : in out File_Type;
Mode : File_Mode := Out_File;
Name : String := "";
Form : String := "")
is
Dummy_File_Control_Block : Wide_Wide_Text_AFCB;
pragma Warnings (Off, Dummy_File_Control_Block);
-- Yes, we know this is never assigned a value, only the tag
-- is used for dispatching purposes, so that's expected.
begin
FIO.Open (File_Ptr => AP (File),
Dummy_FCB => Dummy_File_Control_Block,
Mode => To_FCB (Mode),
Name => Name,
Form => Form,
Amethod => 'W',
Creat => True,
Text => True);
File.Self := File;
Set_WCEM (File);
end Create;
-------------------
-- Current_Error --
-------------------
function Current_Error return File_Type is
begin
return Current_Err;
end Current_Error;
function Current_Error return File_Access is
begin
return Current_Err.Self'Access;
end Current_Error;
-------------------
-- Current_Input --
-------------------
function Current_Input return File_Type is
begin
return Current_In;
end Current_Input;
function Current_Input return File_Access is
begin
return Current_In.Self'Access;
end Current_Input;
--------------------
-- Current_Output --
--------------------
function Current_Output return File_Type is
begin
return Current_Out;
end Current_Output;
function Current_Output return File_Access is
begin
return Current_Out.Self'Access;
end Current_Output;
------------
-- Delete --
------------
procedure Delete (File : in out File_Type) is
begin
FIO.Delete (AP (File)'Unrestricted_Access);
end Delete;
-----------------
-- End_Of_File --
-----------------
function End_Of_File (File : File_Type) return Boolean is
ch : int;
begin
FIO.Check_Read_Status (AP (File));
if File.Before_Wide_Wide_Character then
return False;
elsif File.Before_LM then
if File.Before_LM_PM then
return Nextc (File) = EOF;
end if;
else
ch := Getc (File);
if ch = EOF then
return True;
elsif ch /= LM then
Ungetc (ch, File);
return False;
else -- ch = LM
File.Before_LM := True;
end if;
end if;
-- Here we are just past the line mark with Before_LM set so that we
-- do not have to try to back up past the LM, thus avoiding the need
-- to back up more than one character.
ch := Getc (File);
if ch = EOF then
return True;
elsif ch = PM and then File.Is_Regular_File then
File.Before_LM_PM := True;
return Nextc (File) = EOF;
-- Here if neither EOF nor PM followed end of line
else
Ungetc (ch, File);
return False;
end if;
end End_Of_File;
function End_Of_File return Boolean is
begin
return End_Of_File (Current_In);
end End_Of_File;
-----------------
-- End_Of_Line --
-----------------
function End_Of_Line (File : File_Type) return Boolean is
ch : int;
begin
FIO.Check_Read_Status (AP (File));
if File.Before_Wide_Wide_Character then
return False;
elsif File.Before_LM then
return True;
else
ch := Getc (File);
if ch = EOF then
return True;
else
Ungetc (ch, File);
return (ch = LM);
end if;
end if;
end End_Of_Line;
function End_Of_Line return Boolean is
begin
return End_Of_Line (Current_In);
end End_Of_Line;
-----------------
-- End_Of_Page --
-----------------
function End_Of_Page (File : File_Type) return Boolean is
ch : int;
begin
FIO.Check_Read_Status (AP (File));
if not File.Is_Regular_File then
return False;
elsif File.Before_Wide_Wide_Character then
return False;
elsif File.Before_LM then
if File.Before_LM_PM then
return True;
end if;
else
ch := Getc (File);
if ch = EOF then
return True;
elsif ch /= LM then
Ungetc (ch, File);
return False;
else -- ch = LM
File.Before_LM := True;
end if;
end if;
-- Here we are just past the line mark with Before_LM set so that we
-- do not have to try to back up past the LM, thus avoiding the need
-- to back up more than one character.
ch := Nextc (File);
return ch = PM or else ch = EOF;
end End_Of_Page;
function End_Of_Page return Boolean is
begin
return End_Of_Page (Current_In);
end End_Of_Page;
-----------
-- Flush --
-----------
procedure Flush (File : File_Type) is
begin
FIO.Flush (AP (File));
end Flush;
procedure Flush is
begin
Flush (Current_Out);
end Flush;
----------
-- Form --
----------
function Form (File : File_Type) return String is
begin
return FIO.Form (AP (File));
end Form;
---------
-- Get --
---------
procedure Get
(File : File_Type;
Item : out Wide_Wide_Character)
is
C : Character;
begin
FIO.Check_Read_Status (AP (File));
if File.Before_Wide_Wide_Character then
File.Before_Wide_Wide_Character := False;
Item := File.Saved_Wide_Wide_Character;
-- Ada.Text_IO checks Before_LM_PM here, shouldn't we do the same???
else
Get_Character (File, C);
Item := Get_Wide_Wide_Char (C, File);
end if;
end Get;
procedure Get (Item : out Wide_Wide_Character) is
begin
Get (Current_In, Item);
end Get;
procedure Get
(File : File_Type;
Item : out Wide_Wide_String)
is
begin
for J in Item'Range loop
Get (File, Item (J));
end loop;
end Get;
procedure Get (Item : out Wide_Wide_String) is
begin
Get (Current_In, Item);
end Get;
-------------------
-- Get_Character --
-------------------
procedure Get_Character
(File : File_Type;
Item : out Character)
is
ch : int;
begin
if File.Before_LM then
File.Before_LM := False;
File.Before_LM_PM := False;
File.Col := 1;
if File.Before_LM_PM then
File.Line := 1;
File.Page := File.Page + 1;
File.Before_LM_PM := False;
else
File.Line := File.Line + 1;
end if;
end if;
loop
ch := Getc (File);
if ch = EOF then
raise End_Error;
elsif ch = LM then
File.Line := File.Line + 1;
File.Col := 1;
elsif ch = PM and then File.Is_Regular_File then
File.Page := File.Page + 1;
File.Line := 1;
else
Item := Character'Val (ch);
File.Col := File.Col + 1;
return;
end if;
end loop;
end Get_Character;
-------------------
-- Get_Immediate --
-------------------
procedure Get_Immediate
(File : File_Type;
Item : out Wide_Wide_Character)
is
ch : int;
begin
FIO.Check_Read_Status (AP (File));
if File.Before_Wide_Wide_Character then
File.Before_Wide_Wide_Character := False;
Item := File.Saved_Wide_Wide_Character;
elsif File.Before_LM then
File.Before_LM := False;
File.Before_LM_PM := False;
Item := Wide_Wide_Character'Val (LM);
else
ch := Getc_Immed (File);
if ch = EOF then
raise End_Error;
else
Item := Get_Wide_Wide_Char_Immed (Character'Val (ch), File);
end if;
end if;
end Get_Immediate;
procedure Get_Immediate
(Item : out Wide_Wide_Character)
is
begin
Get_Immediate (Current_In, Item);
end Get_Immediate;
procedure Get_Immediate
(File : File_Type;
Item : out Wide_Wide_Character;
Available : out Boolean)
is
ch : int;
begin
FIO.Check_Read_Status (AP (File));
Available := True;
if File.Before_Wide_Wide_Character then
File.Before_Wide_Wide_Character := False;
Item := File.Saved_Wide_Wide_Character;
elsif File.Before_LM then
File.Before_LM := False;
File.Before_LM_PM := False;
Item := Wide_Wide_Character'Val (LM);
else
-- Shouldn't we use getc_immediate_nowait here, like Text_IO???
ch := Getc_Immed (File);
if ch = EOF then
raise End_Error;
else
Item := Get_Wide_Wide_Char_Immed (Character'Val (ch), File);
end if;
end if;
end Get_Immediate;
procedure Get_Immediate
(Item : out Wide_Wide_Character;
Available : out Boolean)
is
begin
Get_Immediate (Current_In, Item, Available);
end Get_Immediate;
--------------
-- Get_Line --
--------------
procedure Get_Line
(File : File_Type;
Item : out Wide_Wide_String;
Last : out Natural)
is
begin
FIO.Check_Read_Status (AP (File));
Last := Item'First - 1;
-- Immediate exit for null string, this is a case in which we do not
-- need to test for end of file and we do not skip a line mark under
-- any circumstances.
if Last >= Item'Last then
return;
end if;
-- Here we have at least one character, if we are immediately before
-- a line mark, then we will just skip past it storing no characters.
if File.Before_LM then
File.Before_LM := False;
File.Before_LM_PM := False;
-- Otherwise we need to read some characters
else
-- If we are at the end of file now, it means we are trying to
-- skip a file terminator and we raise End_Error (RM A.10.7(20))
if Nextc (File) = EOF then
raise End_Error;
end if;
-- Loop through characters in string
loop
-- Exit the loop if read is terminated by encountering line mark
-- Note that the use of Skip_Line here ensures we properly deal
-- with setting the page and line numbers.
if End_Of_Line (File) then
Skip_Line (File);
return;
end if;
-- Otherwise store the character, note that we know that ch is
-- something other than LM or EOF. It could possibly be a page
-- mark if there is a stray page mark in the middle of a line,
-- but this is not an official page mark in any case, since
-- official page marks can only follow a line mark. The whole
-- page business is pretty much nonsense anyway, so we do not
-- want to waste time trying to make sense out of non-standard
-- page marks in the file. This means that the behavior of
-- Get_Line is different from repeated Get of a character, but
-- that's too bad. We only promise that page numbers etc make
-- sense if the file is formatted in a standard manner.
-- Note: we do not adjust the column number because it is quicker
-- to adjust it once at the end of the operation than incrementing
-- it each time around the loop.
Last := Last + 1;
Get (File, Item (Last));
-- All done if the string is full, this is the case in which
-- we do not skip the following line mark. We need to adjust
-- the column number in this case.
if Last = Item'Last then
File.Col := File.Col + Count (Item'Length);
return;
end if;
-- Exit from the loop if we are at the end of file. This happens
-- if we have a last line that is not terminated with a line mark.
-- In this case we consider that there is an implied line mark;
-- this is a non-standard file, but we will treat it nicely.
exit when Nextc (File) = EOF;
end loop;
end if;
end Get_Line;
procedure Get_Line
(Item : out Wide_Wide_String;
Last : out Natural)
is
begin
Get_Line (Current_In, Item, Last);
end Get_Line;
function Get_Line (File : File_Type) return Wide_Wide_String is
Buffer : Wide_Wide_String (1 .. 500);
Last : Natural;
function Get_Rest (S : Wide_Wide_String) return Wide_Wide_String;
-- This is a recursive function that reads the rest of the line and
-- returns it. S is the part read so far.
--------------
-- Get_Rest --
--------------
function Get_Rest (S : Wide_Wide_String) return Wide_Wide_String is
-- Each time we allocate a buffer the same size as what we have
-- read so far. This limits us to a logarithmic number of calls
-- to Get_Rest and also ensures only a linear use of stack space.
Buffer : Wide_Wide_String (1 .. S'Length);
Last : Natural;
begin
Get_Line (File, Buffer, Last);
declare
R : constant Wide_Wide_String := S & Buffer (1 .. Last);
begin
if Last < Buffer'Last then
return R;
else
return Get_Rest (R);
end if;
end;
end Get_Rest;
-- Start of processing for Get_Line
begin
Get_Line (File, Buffer, Last);
if Last < Buffer'Last then
return Buffer (1 .. Last);
else
return Get_Rest (Buffer (1 .. Last));
end if;
end Get_Line;
function Get_Line return Wide_Wide_String is
begin
return Get_Line (Current_In);
end Get_Line;
------------------------
-- Get_Wide_Wide_Char --
------------------------
function Get_Wide_Wide_Char
(C : Character;
File : File_Type) return Wide_Wide_Character
is
function In_Char return Character;
-- Function used to obtain additional characters it the wide character
-- sequence is more than one character long.
function WC_In is new Char_Sequence_To_UTF_32 (In_Char);
-------------
-- In_Char --
-------------
function In_Char return Character is
ch : constant Integer := Getc (File);
begin
if ch = EOF then
raise End_Error;
else
return Character'Val (ch);
end if;
end In_Char;
-- Start of processing for Get_Wide_Wide_Char
begin
FIO.Check_Read_Status (AP (File));
return Wide_Wide_Character'Val (WC_In (C, File.WC_Method));
end Get_Wide_Wide_Char;
------------------------------
-- Get_Wide_Wide_Char_Immed --
------------------------------
function Get_Wide_Wide_Char_Immed
(C : Character;
File : File_Type) return Wide_Wide_Character
is
function In_Char return Character;
-- Function used to obtain additional characters it the wide character
-- sequence is more than one character long.
function WC_In is new Char_Sequence_To_UTF_32 (In_Char);
-------------
-- In_Char --
-------------
function In_Char return Character is
ch : constant Integer := Getc_Immed (File);
begin
if ch = EOF then
raise End_Error;
else
return Character'Val (ch);
end if;
end In_Char;
-- Start of processing for Get_Wide_Wide_Char_Immed
begin
FIO.Check_Read_Status (AP (File));
return Wide_Wide_Character'Val (WC_In (C, File.WC_Method));
end Get_Wide_Wide_Char_Immed;
----------
-- Getc --
----------
function Getc (File : File_Type) return int is
ch : int;
begin
ch := fgetc (File.Stream);
if ch = EOF and then ferror (File.Stream) /= 0 then
raise Device_Error;
else
return ch;
end if;
end Getc;
----------------
-- Getc_Immed --
----------------
function Getc_Immed (File : File_Type) return int is
ch : int;
end_of_file : int;
procedure getc_immediate
(stream : FILEs; ch : out int; end_of_file : out int);
pragma Import (C, getc_immediate, "getc_immediate");
begin
FIO.Check_Read_Status (AP (File));
if File.Before_LM then
File.Before_LM := False;
File.Before_LM_PM := False;
ch := LM;
else
getc_immediate (File.Stream, ch, end_of_file);
if ferror (File.Stream) /= 0 then
raise Device_Error;
elsif end_of_file /= 0 then
return EOF;
end if;
end if;
return ch;
end Getc_Immed;
-------------------------------
-- Initialize_Standard_Files --
-------------------------------
procedure Initialize_Standard_Files is
begin
Standard_Err.Stream := stderr;
Standard_Err.Name := Err_Name'Access;
Standard_Err.Form := Null_Str'Unrestricted_Access;
Standard_Err.Mode := FCB.Out_File;
Standard_Err.Is_Regular_File := is_regular_file (fileno (stderr)) /= 0;
Standard_Err.Is_Temporary_File := False;
Standard_Err.Is_System_File := True;
Standard_Err.Text_Encoding := Default_Text;
Standard_Err.Access_Method := 'T';
Standard_Err.Self := Standard_Err;
Standard_Err.WC_Method := Default_WCEM;
Standard_In.Stream := stdin;
Standard_In.Name := In_Name'Access;
Standard_In.Form := Null_Str'Unrestricted_Access;
Standard_In.Mode := FCB.In_File;
Standard_In.Is_Regular_File := is_regular_file (fileno (stdin)) /= 0;
Standard_In.Is_Temporary_File := False;
Standard_In.Is_System_File := True;
Standard_In.Text_Encoding := Default_Text;
Standard_In.Access_Method := 'T';
Standard_In.Self := Standard_In;
Standard_In.WC_Method := Default_WCEM;
Standard_Out.Stream := stdout;
Standard_Out.Name := Out_Name'Access;
Standard_Out.Form := Null_Str'Unrestricted_Access;
Standard_Out.Mode := FCB.Out_File;
Standard_Out.Is_Regular_File := is_regular_file (fileno (stdout)) /= 0;
Standard_Out.Is_Temporary_File := False;
Standard_Out.Is_System_File := True;
Standard_Out.Text_Encoding := Default_Text;
Standard_Out.Access_Method := 'T';
Standard_Out.Self := Standard_Out;
Standard_Out.WC_Method := Default_WCEM;
FIO.Make_Unbuffered (AP (Standard_Out));
FIO.Make_Unbuffered (AP (Standard_Err));
end Initialize_Standard_Files;
-------------
-- Is_Open --
-------------
function Is_Open (File : File_Type) return Boolean is
begin
return FIO.Is_Open (AP (File));
end Is_Open;
----------
-- Line --
----------
-- Note: we assume that it is impossible in practice for the line
-- to exceed the value of Count'Last, i.e. no check is required for
-- overflow raising layout error.
function Line (File : File_Type) return Positive_Count is
begin
FIO.Check_File_Open (AP (File));
return File.Line;
end Line;
function Line return Positive_Count is
begin
return Line (Current_Out);
end Line;
-----------------
-- Line_Length --
-----------------
function Line_Length (File : File_Type) return Count is
begin
FIO.Check_Write_Status (AP (File));
return File.Line_Length;
end Line_Length;
function Line_Length return Count is
begin
return Line_Length (Current_Out);
end Line_Length;
----------------
-- Look_Ahead --
----------------
procedure Look_Ahead
(File : File_Type;
Item : out Wide_Wide_Character;
End_Of_Line : out Boolean)
is
ch : int;
-- Start of processing for Look_Ahead
begin
FIO.Check_Read_Status (AP (File));
-- If we are logically before a line mark, we can return immediately
if File.Before_LM then
End_Of_Line := True;
Item := Wide_Wide_Character'Val (0);
-- If we are before a wide character, just return it (this can happen
-- if there are two calls to Look_Ahead in a row).
elsif File.Before_Wide_Wide_Character then
End_Of_Line := False;
Item := File.Saved_Wide_Wide_Character;
-- otherwise we must read a character from the input stream
else
ch := Getc (File);
if ch = LM
or else ch = EOF
or else (ch = EOF and then File.Is_Regular_File)
then
End_Of_Line := True;
Ungetc (ch, File);
Item := Wide_Wide_Character'Val (0);
-- Case where character obtained does not represent the start of an
-- encoded sequence so it stands for itself and we can unget it with
-- no difficulty.
elsif not Is_Start_Of_Encoding
(Character'Val (ch), File.WC_Method)
then
End_Of_Line := False;
Ungetc (ch, File);
Item := Wide_Wide_Character'Val (ch);
-- For the start of an encoding, we read the character using the
-- Get_Wide_Wide_Char routine. It will occupy more than one byte so
-- we can't put it back with ungetc. Instead we save it in the
-- control block, setting a flag that everyone interested in reading
-- characters must test before reading the stream.
else
Item := Get_Wide_Wide_Char (Character'Val (ch), File);
End_Of_Line := False;
File.Saved_Wide_Wide_Character := Item;
File.Before_Wide_Wide_Character := True;
end if;
end if;
end Look_Ahead;
procedure Look_Ahead
(Item : out Wide_Wide_Character;
End_Of_Line : out Boolean)
is
begin
Look_Ahead (Current_In, Item, End_Of_Line);
end Look_Ahead;
----------
-- Mode --
----------
function Mode (File : File_Type) return File_Mode is
begin
return To_TIO (FIO.Mode (AP (File)));
end Mode;
----------
-- Name --
----------
function Name (File : File_Type) return String is
begin
return FIO.Name (AP (File));
end Name;
--------------
-- New_Line --
--------------
procedure New_Line
(File : File_Type;
Spacing : Positive_Count := 1)
is
begin
-- Raise Constraint_Error if out of range value. The reason for this
-- explicit test is that we don't want junk values around, even if
-- checks are off in the caller.
if not Spacing'Valid then
raise Constraint_Error;
end if;
FIO.Check_Write_Status (AP (File));
for K in 1 .. Spacing loop
Putc (LM, File);
File.Line := File.Line + 1;
if File.Page_Length /= 0
and then File.Line > File.Page_Length
then
Putc (PM, File);
File.Line := 1;
File.Page := File.Page + 1;
end if;
end loop;
File.Col := 1;
end New_Line;
procedure New_Line (Spacing : Positive_Count := 1) is
begin
New_Line (Current_Out, Spacing);
end New_Line;
--------------
-- New_Page --
--------------
procedure New_Page (File : File_Type) is
begin
FIO.Check_Write_Status (AP (File));
if File.Col /= 1 or else File.Line = 1 then
Putc (LM, File);
end if;
Putc (PM, File);
File.Page := File.Page + 1;
File.Line := 1;
File.Col := 1;
end New_Page;
procedure New_Page is
begin
New_Page (Current_Out);
end New_Page;
-----------
-- Nextc --
-----------
function Nextc (File : File_Type) return int is
ch : int;
begin
ch := fgetc (File.Stream);
if ch = EOF then
if ferror (File.Stream) /= 0 then
raise Device_Error;
end if;
else
if ungetc (ch, File.Stream) = EOF then
raise Device_Error;
end if;
end if;
return ch;
end Nextc;
----------
-- Open --
----------
procedure Open
(File : in out File_Type;
Mode : File_Mode;
Name : String;
Form : String := "")
is
Dummy_File_Control_Block : Wide_Wide_Text_AFCB;
pragma Warnings (Off, Dummy_File_Control_Block);
-- Yes, we know this is never assigned a value, only the tag
-- is used for dispatching purposes, so that's expected.
begin
FIO.Open (File_Ptr => AP (File),
Dummy_FCB => Dummy_File_Control_Block,
Mode => To_FCB (Mode),
Name => Name,
Form => Form,
Amethod => 'W',
Creat => False,
Text => True);
File.Self := File;
Set_WCEM (File);
end Open;
----------
-- Page --
----------
-- Note: we assume that it is impossible in practice for the page
-- to exceed the value of Count'Last, i.e. no check is required for
-- overflow raising layout error.
function Page (File : File_Type) return Positive_Count is
begin
FIO.Check_File_Open (AP (File));
return File.Page;
end Page;
function Page return Positive_Count is
begin
return Page (Current_Out);
end Page;
-----------------
-- Page_Length --
-----------------
function Page_Length (File : File_Type) return Count is
begin
FIO.Check_Write_Status (AP (File));
return File.Page_Length;
end Page_Length;
function Page_Length return Count is
begin
return Page_Length (Current_Out);
end Page_Length;
---------
-- Put --
---------
procedure Put
(File : File_Type;
Item : Wide_Wide_Character)
is
procedure Out_Char (C : Character);
-- Procedure to output one character of a wide character sequence
procedure WC_Out is new UTF_32_To_Char_Sequence (Out_Char);
--------------
-- Out_Char --
--------------
procedure Out_Char (C : Character) is
begin
Putc (Character'Pos (C), File);
end Out_Char;
-- Start of processing for Put
begin
FIO.Check_Write_Status (AP (File));
WC_Out (Wide_Wide_Character'Pos (Item), File.WC_Method);
File.Col := File.Col + 1;
end Put;
procedure Put (Item : Wide_Wide_Character) is
begin
Put (Current_Out, Item);
end Put;
---------
-- Put --
---------
procedure Put
(File : File_Type;
Item : Wide_Wide_String)
is
begin
for J in Item'Range loop
Put (File, Item (J));
end loop;
end Put;
procedure Put (Item : Wide_Wide_String) is
begin
Put (Current_Out, Item);
end Put;
--------------
-- Put_Line --
--------------
procedure Put_Line
(File : File_Type;
Item : Wide_Wide_String)
is
begin
Put (File, Item);
New_Line (File);
end Put_Line;
procedure Put_Line (Item : Wide_Wide_String) is
begin
Put (Current_Out, Item);
New_Line (Current_Out);
end Put_Line;
----------
-- Putc --
----------
procedure Putc (ch : int; File : File_Type) is
begin
if fputc (ch, File.Stream) = EOF then
raise Device_Error;
end if;
end Putc;
----------
-- Read --
----------
-- This is the primitive Stream Read routine, used when a Text_IO file
-- is treated directly as a stream using Text_IO.Streams.Stream.
procedure Read
(File : in out Wide_Wide_Text_AFCB;
Item : out Stream_Element_Array;
Last : out Stream_Element_Offset)
is
Discard_ch : int;
pragma Unreferenced (Discard_ch);
begin
-- Need to deal with Before_Wide_Wide_Character ???
if File.Mode /= FCB.In_File then
raise Mode_Error;
end if;
-- Deal with case where our logical and physical position do not match
-- because of being after an LM or LM-PM sequence when in fact we are
-- logically positioned before it.
if File.Before_LM then
-- If we are before a PM, then it is possible for a stream read
-- to leave us after the LM and before the PM, which is a bit
-- odd. The easiest way to deal with this is to unget the PM,
-- so we are indeed positioned between the characters. This way
-- further stream read operations will work correctly, and the
-- effect on text processing is a little weird, but what can
-- be expected if stream and text input are mixed this way?
if File.Before_LM_PM then
Discard_ch := ungetc (PM, File.Stream);
File.Before_LM_PM := False;
end if;
File.Before_LM := False;
Item (Item'First) := Stream_Element (Character'Pos (ASCII.LF));
if Item'Length = 1 then
Last := Item'Last;
else
Last :=
Item'First +
Stream_Element_Offset
(fread (buffer => Item'Address,
index => size_t (Item'First + 1),
size => 1,
count => Item'Length - 1,
stream => File.Stream));
end if;
return;
end if;
-- Now we do the read. Since this is a text file, it is normally in
-- text mode, but stream data must be read in binary mode, so we
-- temporarily set binary mode for the read, resetting it after.
-- These calls have no effect in a system (like Unix) where there is
-- no distinction between text and binary files.
set_binary_mode (fileno (File.Stream));
Last :=
Item'First +
Stream_Element_Offset
(fread (Item'Address, 1, Item'Length, File.Stream)) - 1;
if Last < Item'Last then
if ferror (File.Stream) /= 0 then
raise Device_Error;
end if;
end if;
set_text_mode (fileno (File.Stream));
end Read;
-----------
-- Reset --
-----------
procedure Reset
(File : in out File_Type;
Mode : File_Mode)
is
begin
-- Don't allow change of mode for current file (RM A.10.2(5))
if (File = Current_In or else
File = Current_Out or else
File = Current_Error)
and then To_FCB (Mode) /= File.Mode
then
raise Mode_Error;
end if;
Terminate_Line (File);
FIO.Reset (AP (File)'Unrestricted_Access, To_FCB (Mode));
File.Page := 1;
File.Line := 1;
File.Col := 1;
File.Line_Length := 0;
File.Page_Length := 0;
File.Before_LM := False;
File.Before_LM_PM := False;
end Reset;
procedure Reset (File : in out File_Type) is
begin
Terminate_Line (File);
FIO.Reset (AP (File)'Unrestricted_Access);
File.Page := 1;
File.Line := 1;
File.Col := 1;
File.Line_Length := 0;
File.Page_Length := 0;
File.Before_LM := False;
File.Before_LM_PM := False;
end Reset;
-------------
-- Set_Col --
-------------
procedure Set_Col
(File : File_Type;
To : Positive_Count)
is
ch : int;
begin
-- Raise Constraint_Error if out of range value. The reason for this
-- explicit test is that we don't want junk values around, even if
-- checks are off in the caller.
if not To'Valid then
raise Constraint_Error;
end if;
FIO.Check_File_Open (AP (File));
if To = File.Col then
return;
end if;
if Mode (File) >= Out_File then
if File.Line_Length /= 0 and then To > File.Line_Length then
raise Layout_Error;
end if;
if To < File.Col then
New_Line (File);
end if;
while File.Col < To loop
Put (File, ' ');
end loop;
else
loop
ch := Getc (File);
if ch = EOF then
raise End_Error;
elsif ch = LM then
File.Line := File.Line + 1;
File.Col := 1;
elsif ch = PM and then File.Is_Regular_File then
File.Page := File.Page + 1;
File.Line := 1;
File.Col := 1;
elsif To = File.Col then
Ungetc (ch, File);
return;
else
File.Col := File.Col + 1;
end if;
end loop;
end if;
end Set_Col;
procedure Set_Col (To : Positive_Count) is
begin
Set_Col (Current_Out, To);
end Set_Col;
---------------
-- Set_Error --
---------------
procedure Set_Error (File : File_Type) is
begin
FIO.Check_Write_Status (AP (File));
Current_Err := File;
end Set_Error;
---------------
-- Set_Input --
---------------
procedure Set_Input (File : File_Type) is
begin
FIO.Check_Read_Status (AP (File));
Current_In := File;
end Set_Input;
--------------
-- Set_Line --
--------------
procedure Set_Line
(File : File_Type;
To : Positive_Count)
is
begin
-- Raise Constraint_Error if out of range value. The reason for this
-- explicit test is that we don't want junk values around, even if
-- checks are off in the caller.
if not To'Valid then
raise Constraint_Error;
end if;
FIO.Check_File_Open (AP (File));
if To = File.Line then
return;
end if;
if Mode (File) >= Out_File then
if File.Page_Length /= 0 and then To > File.Page_Length then
raise Layout_Error;
end if;
if To < File.Line then
New_Page (File);
end if;
while File.Line < To loop
New_Line (File);
end loop;
else
while To /= File.Line loop
Skip_Line (File);
end loop;
end if;
end Set_Line;
procedure Set_Line (To : Positive_Count) is
begin
Set_Line (Current_Out, To);
end Set_Line;
---------------------
-- Set_Line_Length --
---------------------
procedure Set_Line_Length (File : File_Type; To : Count) is
begin
-- Raise Constraint_Error if out of range value. The reason for this
-- explicit test is that we don't want junk values around, even if
-- checks are off in the caller.
if not To'Valid then
raise Constraint_Error;
end if;
FIO.Check_Write_Status (AP (File));
File.Line_Length := To;
end Set_Line_Length;
procedure Set_Line_Length (To : Count) is
begin
Set_Line_Length (Current_Out, To);
end Set_Line_Length;
----------------
-- Set_Output --
----------------
procedure Set_Output (File : File_Type) is
begin
FIO.Check_Write_Status (AP (File));
Current_Out := File;
end Set_Output;
---------------------
-- Set_Page_Length --
---------------------
procedure Set_Page_Length (File : File_Type; To : Count) is
begin
-- Raise Constraint_Error if out of range value. The reason for this
-- explicit test is that we don't want junk values around, even if
-- checks are off in the caller.
if not To'Valid then
raise Constraint_Error;
end if;
FIO.Check_Write_Status (AP (File));
File.Page_Length := To;
end Set_Page_Length;
procedure Set_Page_Length (To : Count) is
begin
Set_Page_Length (Current_Out, To);
end Set_Page_Length;
--------------
-- Set_WCEM --
--------------
procedure Set_WCEM (File : in out File_Type) is
Start : Natural;
Stop : Natural;
begin
FIO.Form_Parameter (File.Form.all, "wcem", Start, Stop);
if Start = 0 then
File.WC_Method := Default_WCEM;
else
if Stop = Start then
for J in WC_Encoding_Letters'Range loop
if File.Form (Start) = WC_Encoding_Letters (J) then
File.WC_Method := J;
return;
end if;
end loop;
end if;
Close (File);
raise Use_Error with "invalid WCEM form parameter";
end if;
end Set_WCEM;
---------------
-- Skip_Line --
---------------
procedure Skip_Line
(File : File_Type;
Spacing : Positive_Count := 1)
is
ch : int;
begin
-- Raise Constraint_Error if out of range value. The reason for this
-- explicit test is that we don't want junk values around, even if
-- checks are off in the caller.
if not Spacing'Valid then
raise Constraint_Error;
end if;
FIO.Check_Read_Status (AP (File));
for L in 1 .. Spacing loop
if File.Before_LM then
File.Before_LM := False;
File.Before_LM_PM := False;
else
ch := Getc (File);
-- If at end of file now, then immediately raise End_Error. Note
-- that we can never be positioned between a line mark and a page
-- mark, so if we are at the end of file, we cannot logically be
-- before the implicit page mark that is at the end of the file.
-- For the same reason, we do not need an explicit check for a
-- page mark. If there is a FF in the middle of a line, the file
-- is not in canonical format and we do not care about the page
-- numbers for files other than ones in canonical format.
if ch = EOF then
raise End_Error;
end if;
-- If not at end of file, then loop till we get to an LM or EOF.
-- The latter case happens only in non-canonical files where the
-- last line is not terminated by LM, but we don't want to blow
-- up for such files, so we assume an implicit LM in this case.
loop
exit when ch = LM or else ch = EOF;
ch := Getc (File);
end loop;
end if;
-- We have got past a line mark, now, for a regular file only,
-- see if a page mark immediately follows this line mark and
-- if so, skip past the page mark as well. We do not do this
-- for non-regular files, since it would cause an undesirable
-- wait for an additional character.
File.Col := 1;
File.Line := File.Line + 1;
if File.Before_LM_PM then
File.Page := File.Page + 1;
File.Line := 1;
File.Before_LM_PM := False;
elsif File.Is_Regular_File then
ch := Getc (File);
-- Page mark can be explicit, or implied at the end of the file
if (ch = PM or else ch = EOF)
and then File.Is_Regular_File
then
File.Page := File.Page + 1;
File.Line := 1;
else
Ungetc (ch, File);
end if;
end if;
end loop;
File.Before_Wide_Wide_Character := False;
end Skip_Line;
procedure Skip_Line (Spacing : Positive_Count := 1) is
begin
Skip_Line (Current_In, Spacing);
end Skip_Line;
---------------
-- Skip_Page --
---------------
procedure Skip_Page (File : File_Type) is
ch : int;
begin
FIO.Check_Read_Status (AP (File));
-- If at page mark already, just skip it
if File.Before_LM_PM then
File.Before_LM := False;
File.Before_LM_PM := False;
File.Page := File.Page + 1;
File.Line := 1;
File.Col := 1;
return;
end if;
-- This is a bit tricky, if we are logically before an LM then
-- it is not an error if we are at an end of file now, since we
-- are not really at it.
if File.Before_LM then
File.Before_LM := False;
File.Before_LM_PM := False;
ch := Getc (File);
-- Otherwise we do raise End_Error if we are at the end of file now
else
ch := Getc (File);
if ch = EOF then
raise End_Error;
end if;
end if;
-- Now we can just rumble along to the next page mark, or to the
-- end of file, if that comes first. The latter case happens when
-- the page mark is implied at the end of file.
loop
exit when ch = EOF
or else (ch = PM and then File.Is_Regular_File);
ch := Getc (File);
end loop;
File.Page := File.Page + 1;
File.Line := 1;
File.Col := 1;
File.Before_Wide_Wide_Character := False;
end Skip_Page;
procedure Skip_Page is
begin
Skip_Page (Current_In);
end Skip_Page;
--------------------
-- Standard_Error --
--------------------
function Standard_Error return File_Type is
begin
return Standard_Err;
end Standard_Error;
function Standard_Error return File_Access is
begin
return Standard_Err'Access;
end Standard_Error;
--------------------
-- Standard_Input --
--------------------
function Standard_Input return File_Type is
begin
return Standard_In;
end Standard_Input;
function Standard_Input return File_Access is
begin
return Standard_In'Access;
end Standard_Input;
---------------------
-- Standard_Output --
---------------------
function Standard_Output return File_Type is
begin
return Standard_Out;
end Standard_Output;
function Standard_Output return File_Access is
begin
return Standard_Out'Access;
end Standard_Output;
--------------------
-- Terminate_Line --
--------------------
procedure Terminate_Line (File : File_Type) is
begin
FIO.Check_File_Open (AP (File));
-- For file other than In_File, test for needing to terminate last line
if Mode (File) /= In_File then
-- If not at start of line definition need new line
if File.Col /= 1 then
New_Line (File);
-- For files other than standard error and standard output, we
-- make sure that an empty file has a single line feed, so that
-- it is properly formatted. We avoid this for the standard files
-- because it is too much of a nuisance to have these odd line
-- feeds when nothing has been written to the file.
elsif (File /= Standard_Err and then File /= Standard_Out)
and then (File.Line = 1 and then File.Page = 1)
then
New_Line (File);
end if;
end if;
end Terminate_Line;
------------
-- Ungetc --
------------
procedure Ungetc (ch : int; File : File_Type) is
begin
if ch /= EOF then
if ungetc (ch, File.Stream) = EOF then
raise Device_Error;
end if;
end if;
end Ungetc;
-----------
-- Write --
-----------
-- This is the primitive Stream Write routine, used when a Text_IO file
-- is treated directly as a stream using Text_IO.Streams.Stream.
procedure Write
(File : in out Wide_Wide_Text_AFCB;
Item : Stream_Element_Array)
is
pragma Warnings (Off, File);
-- Because in this implementation we don't need IN OUT, we only read
Siz : constant size_t := Item'Length;
begin
if File.Mode = FCB.In_File then
raise Mode_Error;
end if;
-- Now we do the write. Since this is a text file, it is normally in
-- text mode, but stream data must be written in binary mode, so we
-- temporarily set binary mode for the write, resetting it after.
-- These calls have no effect in a system (like Unix) where there is
-- no distinction between text and binary files.
set_binary_mode (fileno (File.Stream));
if fwrite (Item'Address, 1, Siz, File.Stream) /= Siz then
raise Device_Error;
end if;
set_text_mode (fileno (File.Stream));
end Write;
begin
-- Initialize Standard Files
for J in WC_Encoding_Method loop
if WC_Encoding = WC_Encoding_Letters (J) then
Default_WCEM := J;
end if;
end loop;
Initialize_Standard_Files;
FIO.Chain_File (AP (Standard_In));
FIO.Chain_File (AP (Standard_Out));
FIO.Chain_File (AP (Standard_Err));
end Ada.Wide_Wide_Text_IO;
|
sungyeon/drake | Ada | 12,274 | adb | with Ada.Exception_Identification.From_Here;
with Ada.Exceptions.Finally;
with System.Formatting;
with System.Long_Long_Integer_Types;
with C.signal;
with C.sys.ioctl;
with C.unistd;
package body System.Native_Text_IO is
use Ada.Exception_Identification.From_Here;
use type Ada.Streams.Stream_Element_Offset;
use type C.signed_int;
use type C.unsigned_char; -- cc_t
use type C.unsigned_int; -- tcflag_t in Linux or FreeBSD
use type C.unsigned_long; -- tcflag_t in Darwin
subtype Word_Unsigned is Long_Long_Integer_Types.Word_Unsigned;
procedure tcgetsetattr (
Handle : Handle_Type;
Action : C.signed_int;
Mask : C.termios.tcflag_t;
Min : C.termios.cc_t;
Saved_Settings : not null access C.termios.struct_termios);
procedure tcgetsetattr (
Handle : Handle_Type;
Action : C.signed_int;
Mask : C.termios.tcflag_t;
Min : C.termios.cc_t;
Saved_Settings : not null access C.termios.struct_termios)
is
Settings : aliased C.termios.struct_termios;
begin
-- get current terminal mode
if C.termios.tcgetattr (Handle, Saved_Settings) < 0 then
Raise_Exception (Device_Error'Identity);
end if;
-- set non-canonical mode
Settings := Saved_Settings.all;
Settings.c_lflag := Settings.c_lflag and Mask;
Settings.c_cc (C.termios.VTIME) := 0; -- wait 0.0 sec
Settings.c_cc (C.termios.VMIN) := Min; -- wait Min bytes
if C.termios.tcsetattr (Handle, Action, Settings'Access) < 0 then
Raise_Exception (Device_Error'Identity);
end if;
end tcgetsetattr;
procedure Read_Escape_Sequence (
Handle : Handle_Type;
Item : out String;
Last : out Natural;
Read_Until : Character);
procedure Read_Escape_Sequence (
Handle : Handle_Type;
Item : out String;
Last : out Natural;
Read_Until : Character)
is
Read_Length : Ada.Streams.Stream_Element_Offset;
begin
Last := Item'First - 1;
loop
Native_IO.Read (
Handle,
Item (Last + 1)'Address,
1,
Read_Length);
if Read_Length < 0 then
Raise_Exception (Device_Error'Identity);
end if;
exit when Read_Length = 0;
if Last < Item'First then
-- skip until 16#1b#
if Item (Last + 1) = Character'Val (16#1b#) then
Last := Last + 1;
end if;
else
Last := Last + 1;
exit when Item (Last) = Read_Until or else Last >= Item'Last;
end if;
end loop;
end Read_Escape_Sequence;
procedure Parse_Escape_Sequence (
Item : String;
Prefix : String;
Postfix : Character;
X1, X2 : out Word_Unsigned);
procedure Parse_Escape_Sequence (
Item : String;
Prefix : String;
Postfix : Character;
X1, X2 : out Word_Unsigned)
is
P : Natural;
Error : Boolean;
L : constant Natural := Item'First + (Prefix'Length - 1);
begin
if L > Item'Last or else Item (Item'First .. L) /= Prefix then
Error := True;
else
Formatting.Value (
Item (L + 1 .. Item'Last),
P,
X1,
Error => Error);
if not Error then
if P >= Item'Last or else Item (P + 1) /= ';' then
Error := True;
else
Formatting.Value (
Item (P + 2 .. Item'Last),
P,
X2,
Error => Error);
if not Error
and then (P + 1 /= Item'Last or else Item (P + 1) /= Postfix)
then
Error := True;
end if;
end if;
end if;
end if;
if Error then
Raise_Exception (Data_Error'Identity);
end if;
end Parse_Escape_Sequence;
State_Stack_Count : Natural := 0;
-- implementation
procedure Write_Just (
Handle : Handle_Type;
Item : String)
is
Written_Length : Ada.Streams.Stream_Element_Offset;
begin
Native_IO.Write (
Handle,
Item'Address,
Item'Length,
Written_Length);
if Written_Length < 0 then
Raise_Exception (Device_Error'Identity);
end if;
end Write_Just;
procedure Terminal_Size (
Handle : Handle_Type;
Line_Length, Page_Length : out Natural)
is
WS : aliased C.sys.ioctl.struct_winsize;
begin
if C.sys.ioctl.ioctl (Handle, C.sys.ioctl.TIOCGWINSZ, WS'Access) < 0 then
Raise_Exception (Device_Error'Identity);
else
Line_Length := Natural (WS.ws_col);
Page_Length := Natural (WS.ws_row);
end if;
end Terminal_Size;
procedure Set_Terminal_Size (
Handle : Handle_Type;
Line_Length, Page_Length : Natural)
is
Seq : String (1 .. 256);
Last : Natural := 0;
Error : Boolean;
begin
Seq (1) := Character'Val (16#1b#);
Seq (2) := '[';
Seq (3) := '8';
Seq (4) := ';';
Last := 4;
Formatting.Image (
Word_Unsigned (Page_Length),
Seq (Last + 1 .. Seq'Last),
Last,
Error => Error);
Last := Last + 1;
Seq (Last) := ';';
Formatting.Image (
Word_Unsigned (Line_Length),
Seq (Last + 1 .. Seq'Last),
Last,
Error => Error);
Last := Last + 1;
Seq (Last) := 't';
Write_Just (Handle, Seq (1 .. Last));
end Set_Terminal_Size;
procedure Terminal_View (
Handle : Handle_Type;
Left, Top : out Positive;
Right, Bottom : out Natural) is
begin
Terminal_Size (Handle, Right, Bottom);
Left := 1;
Top := 1;
end Terminal_View;
function Use_Terminal_Position (Handle : Handle_Type) return Boolean is
begin
-- It's a workaround for that in some kinds of combinations of
-- commands like timeout(1), the process may be run as background,
-- so it may receive SIGTTOU by tcsetattr and be stopped.
return C.unistd.tcgetpgrp (Handle) = C.unistd.getpgrp;
end Use_Terminal_Position;
procedure Terminal_Position (
Handle : Handle_Type;
Col, Line : out Positive)
is
Seq : constant String (1 .. 4) :=
(Character'Val (16#1b#), '[', '6', 'n');
type Signal_Setting is record
Old_Mask : aliased C.signal.sigset_t;
Error : Boolean;
end record;
pragma Suppress_Initialization (Signal_Setting);
SS : aliased Signal_Setting;
type Terminal_Setting is record
Old_Settings : aliased C.termios.struct_termios;
Handle : Handle_Type;
Error : Boolean;
end record;
pragma Suppress_Initialization (Terminal_Setting);
TS : aliased Terminal_Setting;
Buffer : String (1 .. 256);
Last : Natural;
begin
-- block SIGINT
declare
Mask : aliased C.signal.sigset_t;
Dummy_R : C.signed_int;
begin
Dummy_R := C.signal.sigemptyset (Mask'Access);
Dummy_R := C.signal.sigaddset (Mask'Access, C.signal.SIGINT);
if C.signal.sigprocmask (
C.signal.SIG_BLOCK,
Mask'Access,
SS.Old_Mask'Access) < 0
then
raise Program_Error; -- sigprocmask failed
end if;
end;
declare
procedure Finally (X : in out Signal_Setting);
procedure Finally (X : in out Signal_Setting) is
begin
-- unblock SIGINT
X.Error := C.signal.sigprocmask (
C.signal.SIG_SETMASK,
X.Old_Mask'Access,
null) < 0;
end Finally;
package Holder is
new Ada.Exceptions.Finally.Scoped_Holder (
Signal_Setting,
Finally);
begin
Holder.Assign (SS);
TS.Handle := Handle;
-- non-canonical mode and disable echo
tcgetsetattr (
Handle,
C.termios.TCSAFLUSH,
not (C.termios.ECHO or C.termios.ICANON),
1,
TS.Old_Settings'Access);
declare
procedure Finally (X : in out Terminal_Setting);
procedure Finally (X : in out Terminal_Setting) is
begin
-- restore terminal mode
X.Error := C.termios.tcsetattr (
X.Handle,
C.termios.TCSANOW,
X.Old_Settings'Access) < 0;
end Finally;
package Holder is
new Ada.Exceptions.Finally.Scoped_Holder (
Terminal_Setting,
Finally);
begin
Holder.Assign (TS);
-- output
Write_Just (Handle, Seq);
-- input
Read_Escape_Sequence (Handle, Buffer, Last, 'R');
end;
if TS.Error then
Raise_Exception (Device_Error'Identity);
end if;
end;
if SS.Error then
raise Program_Error; -- sigprocmask failed
end if;
-- parse
Parse_Escape_Sequence (
Buffer (1 .. Last),
Character'Val (16#1b#) & "[",
'R',
Word_Unsigned (Line),
Word_Unsigned (Col));
end Terminal_Position;
procedure Set_Terminal_Position (
Handle : Handle_Type;
Col, Line : Positive)
is
Seq : String (1 .. 256);
Last : Natural := 0;
Error : Boolean;
begin
Seq (1) := Character'Val (16#1b#);
Seq (2) := '[';
Last := 2;
Formatting.Image (
Word_Unsigned (Line),
Seq (Last + 1 .. Seq'Last),
Last,
Error => Error);
Last := Last + 1;
Seq (Last) := ';';
Formatting.Image (
Word_Unsigned (Col),
Seq (Last + 1 .. Seq'Last),
Last,
Error => Error);
Last := Last + 1;
Seq (Last) := 'H';
Write_Just (Handle, Seq (1 .. Last));
end Set_Terminal_Position;
procedure Set_Terminal_Col (
Handle : Handle_Type;
To : Positive)
is
Seq : String (1 .. 256);
Last : Natural := 0;
Error : Boolean;
begin
Seq (1) := Character'Val (16#1b#);
Seq (2) := '[';
Last := 2;
Formatting.Image (
Word_Unsigned (To),
Seq (Last + 1 .. Seq'Last),
Last,
Error => Error);
Last := Last + 1;
Seq (Last) := 'G';
Write_Just (Handle, Seq (1 .. Last));
end Set_Terminal_Col;
procedure Terminal_Clear (
Handle : Handle_Type)
is
Code : constant String (1 .. 10) := (
Character'Val (16#1b#),
'[',
'2',
'J',
Character'Val (16#1b#),
'[',
'0',
';',
'0',
'H');
begin
Write_Just (Handle, Code);
end Terminal_Clear;
procedure Set_Non_Canonical_Mode (
Handle : Handle_Type;
Wait : Boolean;
Saved_Settings : aliased out Setting) is
begin
tcgetsetattr (
Handle,
C.termios.TCSADRAIN,
not C.termios.ICANON,
C.termios.cc_t (Boolean'Pos (Wait)), -- minimum waiting size
Saved_Settings'Access);
end Set_Non_Canonical_Mode;
procedure Restore (
Handle : Handle_Type;
Settings : aliased Setting) is
begin
if C.termios.tcsetattr (
Handle,
C.termios.TCSANOW,
Settings'Access) < 0
then
Raise_Exception (Device_Error'Identity);
end if;
end Restore;
procedure Save_State (Handle : Handle_Type; To_State : out Output_State) is
Seq : constant String (1 .. 2) := (Character'Val (16#1b#), '7');
begin
State_Stack_Count := State_Stack_Count + 1;
To_State := State_Stack_Count;
Write_Just (Handle, Seq);
end Save_State;
procedure Reset_State (Handle : Handle_Type; From_State : Output_State) is
pragma Check (Pre,
Check => From_State = State_Stack_Count or else raise Status_Error);
Seq : constant String (1 .. 2) := (Character'Val (16#1b#), '8');
begin
State_Stack_Count := State_Stack_Count - 1;
Write_Just (Handle, Seq);
end Reset_State;
end System.Native_Text_IO;
|
thierr26/ada-keystore | Ada | 13,627 | adb | -----------------------------------------------------------------------
-- keystore-marshallers -- Data marshaller for the keystore
-- Copyright (C) 2019 Stephane Carrez
-- Written by Stephane Carrez ([email protected])
--
-- Licensed under the Apache License, Version 2.0 (the "License");
-- you may not use this file except in compliance with the License.
-- You may obtain a copy of the License at
--
-- http://www.apache.org/licenses/LICENSE-2.0
--
-- Unless required by applicable law or agreed to in writing, software
-- distributed under the License is distributed on an "AS IS" BASIS,
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-- See the License for the specific language governing permissions and
-- limitations under the License.
-----------------------------------------------------------------------
with Interfaces.C;
with Ada.Calendar.Conversions;
with Util.Encoders.HMAC.SHA256;
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;
function Get_String (From : in out Marshaller;
Length : in Natural) return String is
Result : String (1 .. Length);
Pos : Block_Index := From.Pos;
Buf : constant Buffers.Buffer_Accessor := From.Buffer.Data.Value;
begin
From.Pos := From.Pos + Block_Index (Length);
for I in Result'Range loop
Pos := Pos + 1;
Result (I) := Character'Val (Buf.Data (Pos));
end loop;
return Result;
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;
|
reznikmm/matreshka | Ada | 3,525 | ads | ------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- Localization, Internationalization, Globalization for Ada --
-- --
-- Testsuite Component --
-- --
------------------------------------------------------------------------------
-- --
-- Copyright © 2009, Vadim Godunko <[email protected]> --
-- All rights reserved. --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions --
-- are met: --
-- --
-- * Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- --
-- * Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in the --
-- documentation and/or other materials provided with the distribution. --
-- --
-- * Neither the name of the Vadim Godunko, IE nor the names of its --
-- contributors may be used to endorse or promote products derived from --
-- this software without specific prior written permission. --
-- --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR --
-- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
-- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED --
-- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR --
-- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF --
-- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING --
-- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS --
-- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
-- --
------------------------------------------------------------------------------
-- $Revision$ $Date$
------------------------------------------------------------------------------
package Unicode_Data_File_Utilities is
function Parse (Text : String) return Wide_Wide_String;
-- Parse string into sequence of code points.
end Unicode_Data_File_Utilities;
|
reznikmm/matreshka | Ada | 3,739 | ads | ------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- Open Document Toolkit --
-- --
-- Runtime Library Component --
-- --
------------------------------------------------------------------------------
-- --
-- Copyright © 2014, Vadim Godunko <[email protected]> --
-- All rights reserved. --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions --
-- are met: --
-- --
-- * Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- --
-- * Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in the --
-- documentation and/or other materials provided with the distribution. --
-- --
-- * Neither the name of the Vadim Godunko, IE nor the names of its --
-- contributors may be used to endorse or promote products derived from --
-- this software without specific prior written permission. --
-- --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR --
-- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
-- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED --
-- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR --
-- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF --
-- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING --
-- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS --
-- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
-- --
------------------------------------------------------------------------------
-- $Revision$ $Date$
------------------------------------------------------------------------------
with XML.DOM.Elements;
package ODF.DOM.Text_Linenumbering_Separator_Elements is
pragma Preelaborate;
type ODF_Text_Linenumbering_Separator is limited interface
and XML.DOM.Elements.DOM_Element;
type ODF_Text_Linenumbering_Separator_Access is
access all ODF_Text_Linenumbering_Separator'Class
with Storage_Size => 0;
end ODF.DOM.Text_Linenumbering_Separator_Elements;
|
zhmu/ananas | Ada | 3,070 | ads | ------------------------------------------------------------------------------
-- --
-- GNAT RUN-TIME COMPONENTS --
-- --
-- A D A . W I D E _ W I D E _ T E X T _ I O . C _ S T R E A M S --
-- --
-- S p e c --
-- --
-- Copyright (C) 1992-2022, Free Software Foundation, Inc. --
-- --
-- GNAT is free software; you can redistribute it and/or modify it under --
-- terms of the GNU General Public License as published by the Free Soft- --
-- ware Foundation; either version 3, or (at your option) any later ver- --
-- sion. GNAT is distributed in the hope that it will be useful, but WITH- --
-- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY --
-- or FITNESS FOR A PARTICULAR PURPOSE. --
-- --
-- As a special exception under Section 7 of GPL version 3, you are granted --
-- additional permissions described in the GCC Runtime Library Exception, --
-- version 3.1, as published by the Free Software Foundation. --
-- --
-- You should have received a copy of the GNU General Public License and --
-- a copy of the GCC Runtime Library Exception along with this program; --
-- see the files COPYING3 and COPYING.RUNTIME respectively. If not, see --
-- <http://www.gnu.org/licenses/>. --
-- --
-- GNAT was originally developed by the GNAT team at New York University. --
-- Extensive contributions were provided by Ada Core Technologies Inc. --
-- --
------------------------------------------------------------------------------
-- This package provides an interface between Ada.Wide_Wide_Text_IO and the
-- C streams. This allows sharing of a stream between Ada and C or C++,
-- as well as allowing the Ada program to operate directly on the stream.
with Interfaces.C_Streams;
package Ada.Wide_Wide_Text_IO.C_Streams is
package ICS renames Interfaces.C_Streams;
function C_Stream (F : File_Type) return ICS.FILEs;
-- Obtain stream from existing open file
procedure Open
(File : in out File_Type;
Mode : File_Mode;
C_Stream : ICS.FILEs;
Form : String := "";
Name : String := "");
-- Create new file from existing stream
end Ada.Wide_Wide_Text_IO.C_Streams;
|
sungyeon/drake | Ada | 441 | ads | pragma License (Unrestricted);
-- extended unit
with Ada.References.Strings;
with Ada.Streams.Block_Transmission.Strings;
with Ada.Strings.Generic_Unbounded;
package Ada.Strings.Unbounded_Strings is
new Generic_Unbounded (
Character,
String,
Streams.Block_Transmission.Strings.Read,
Streams.Block_Transmission.Strings.Write,
References.Strings.Slicing);
pragma Preelaborate (Ada.Strings.Unbounded_Strings);
|
reznikmm/matreshka | Ada | 4,567 | 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_Meta.Delay_Attributes is
------------
-- Create --
------------
overriding function Create
(Parameters : not null access Matreshka.DOM_Attributes.Attribute_L2_Parameters)
return Meta_Delay_Attribute_Node is
begin
return Self : Meta_Delay_Attribute_Node do
Matreshka.ODF_Meta.Constructors.Initialize
(Self'Unchecked_Access,
Parameters.Document,
Matreshka.ODF_String_Constants.Meta_Prefix);
end return;
end Create;
--------------------
-- Get_Local_Name --
--------------------
overriding function Get_Local_Name
(Self : not null access constant Meta_Delay_Attribute_Node)
return League.Strings.Universal_String
is
pragma Unreferenced (Self);
begin
return Matreshka.ODF_String_Constants.Delay_Attribute;
end Get_Local_Name;
begin
Matreshka.DOM_Documents.Register_Attribute
(Matreshka.ODF_String_Constants.Meta_URI,
Matreshka.ODF_String_Constants.Delay_Attribute,
Meta_Delay_Attribute_Node'Tag);
end Matreshka.ODF_Meta.Delay_Attributes;
|
optikos/oasis | Ada | 6,277 | ads | -- Copyright (c) 2019 Maxim Reznik <[email protected]>
--
-- SPDX-License-Identifier: MIT
-- License-Filename: LICENSE
-------------------------------------------------------------
with Program.Lexical_Elements;
with Program.Elements.Subtype_Indications;
with Program.Elements.Anonymous_Access_To_Objects;
with Program.Element_Visitors;
package Program.Nodes.Anonymous_Access_To_Objects is
pragma Preelaborate;
type Anonymous_Access_To_Object is
new Program.Nodes.Node
and Program.Elements.Anonymous_Access_To_Objects
.Anonymous_Access_To_Object
and Program.Elements.Anonymous_Access_To_Objects
.Anonymous_Access_To_Object_Text
with private;
function Create
(Not_Token : Program.Lexical_Elements.Lexical_Element_Access;
Null_Token : Program.Lexical_Elements.Lexical_Element_Access;
Access_Token : not null Program.Lexical_Elements
.Lexical_Element_Access;
All_Token : Program.Lexical_Elements.Lexical_Element_Access;
Constant_Token : Program.Lexical_Elements.Lexical_Element_Access;
Subtype_Indication : not null Program.Elements.Subtype_Indications
.Subtype_Indication_Access)
return Anonymous_Access_To_Object;
type Implicit_Anonymous_Access_To_Object is
new Program.Nodes.Node
and Program.Elements.Anonymous_Access_To_Objects
.Anonymous_Access_To_Object
with private;
function Create
(Subtype_Indication : not null Program.Elements.Subtype_Indications
.Subtype_Indication_Access;
Is_Part_Of_Implicit : Boolean := False;
Is_Part_Of_Inherited : Boolean := False;
Is_Part_Of_Instance : Boolean := False;
Has_Not_Null : Boolean := False;
Has_All : Boolean := False;
Has_Constant : Boolean := False)
return Implicit_Anonymous_Access_To_Object
with Pre =>
Is_Part_Of_Implicit or Is_Part_Of_Inherited or Is_Part_Of_Instance;
private
type Base_Anonymous_Access_To_Object is
abstract new Program.Nodes.Node
and Program.Elements.Anonymous_Access_To_Objects
.Anonymous_Access_To_Object
with record
Subtype_Indication : not null Program.Elements.Subtype_Indications
.Subtype_Indication_Access;
end record;
procedure Initialize
(Self : aliased in out Base_Anonymous_Access_To_Object'Class);
overriding procedure Visit
(Self : not null access Base_Anonymous_Access_To_Object;
Visitor : in out Program.Element_Visitors.Element_Visitor'Class);
overriding function Subtype_Indication
(Self : Base_Anonymous_Access_To_Object)
return not null Program.Elements.Subtype_Indications
.Subtype_Indication_Access;
overriding function Is_Anonymous_Access_To_Object_Element
(Self : Base_Anonymous_Access_To_Object)
return Boolean;
overriding function Is_Anonymous_Access_Definition_Element
(Self : Base_Anonymous_Access_To_Object)
return Boolean;
overriding function Is_Definition_Element
(Self : Base_Anonymous_Access_To_Object)
return Boolean;
type Anonymous_Access_To_Object is
new Base_Anonymous_Access_To_Object
and Program.Elements.Anonymous_Access_To_Objects
.Anonymous_Access_To_Object_Text
with record
Not_Token : Program.Lexical_Elements.Lexical_Element_Access;
Null_Token : Program.Lexical_Elements.Lexical_Element_Access;
Access_Token : not null Program.Lexical_Elements
.Lexical_Element_Access;
All_Token : Program.Lexical_Elements.Lexical_Element_Access;
Constant_Token : Program.Lexical_Elements.Lexical_Element_Access;
end record;
overriding function To_Anonymous_Access_To_Object_Text
(Self : aliased in out Anonymous_Access_To_Object)
return Program.Elements.Anonymous_Access_To_Objects
.Anonymous_Access_To_Object_Text_Access;
overriding function Not_Token
(Self : Anonymous_Access_To_Object)
return Program.Lexical_Elements.Lexical_Element_Access;
overriding function Null_Token
(Self : Anonymous_Access_To_Object)
return Program.Lexical_Elements.Lexical_Element_Access;
overriding function Access_Token
(Self : Anonymous_Access_To_Object)
return not null Program.Lexical_Elements.Lexical_Element_Access;
overriding function All_Token
(Self : Anonymous_Access_To_Object)
return Program.Lexical_Elements.Lexical_Element_Access;
overriding function Constant_Token
(Self : Anonymous_Access_To_Object)
return Program.Lexical_Elements.Lexical_Element_Access;
overriding function Has_Not_Null
(Self : Anonymous_Access_To_Object)
return Boolean;
overriding function Has_All
(Self : Anonymous_Access_To_Object)
return Boolean;
overriding function Has_Constant
(Self : Anonymous_Access_To_Object)
return Boolean;
type Implicit_Anonymous_Access_To_Object is
new Base_Anonymous_Access_To_Object
with record
Is_Part_Of_Implicit : Boolean;
Is_Part_Of_Inherited : Boolean;
Is_Part_Of_Instance : Boolean;
Has_Not_Null : Boolean;
Has_All : Boolean;
Has_Constant : Boolean;
end record;
overriding function To_Anonymous_Access_To_Object_Text
(Self : aliased in out Implicit_Anonymous_Access_To_Object)
return Program.Elements.Anonymous_Access_To_Objects
.Anonymous_Access_To_Object_Text_Access;
overriding function Is_Part_Of_Implicit
(Self : Implicit_Anonymous_Access_To_Object)
return Boolean;
overriding function Is_Part_Of_Inherited
(Self : Implicit_Anonymous_Access_To_Object)
return Boolean;
overriding function Is_Part_Of_Instance
(Self : Implicit_Anonymous_Access_To_Object)
return Boolean;
overriding function Has_Not_Null
(Self : Implicit_Anonymous_Access_To_Object)
return Boolean;
overriding function Has_All
(Self : Implicit_Anonymous_Access_To_Object)
return Boolean;
overriding function Has_Constant
(Self : Implicit_Anonymous_Access_To_Object)
return Boolean;
end Program.Nodes.Anonymous_Access_To_Objects;
|
jscparker/math_packages | Ada | 15,234 | adb |
-------------------------------------------------------------------------------
-- package body Chirped, a chirped fast fourier transform.
-- Copyright (C) 1995-2018 Jonathan S. Parker
--
-- Permission to use, copy, modify, and/or distribute this software for any
-- purpose with or without fee is hereby granted, provided that the above
-- copyright notice and this permission notice appear in all copies.
-- THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
-- WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
-- MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
-- ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
-- WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
-- ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
-- OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
-------------------------------------------------------------------------------
with Fourier8;
with Text_IO; use Text_IO;
with Ada.Numerics.Generic_Elementary_Functions;
package body Chirped is
package mth is new Ada.Numerics.Generic_Elementary_Functions (Real);
use mth;
-- Make an FFT that operates on an array with index Array_Index,
-- (which has twice the range of Data_Index).
package fft8 is new
Fourier8 (Real, Array_Index, Data_Array, Log_Of_Max_Data_Length+1);
use fft8;
Exp_Table : Exp_Storage;
subtype Exponent_Of_Two_Type is Natural range 0..Log_Of_Max_Data_Length;
-- Global tables of SIN's and COS's used by FFT_Chirped:
type Exp_Function is record
Re : Real;
Im : Real;
end record;
type Sinusoid_Storage is Array(Data_Index) of Exp_Function;
Zero : constant Exp_Function := (0.0, 0.0);
W_Table : Sinusoid_Storage := (others => Zero);
-- The following is the set of chirped exponentials Exp(i*(2Pi/N)*K*K/2).
-- It is constructed on the first call to FFT_Chirped, and only rebuilt
-- if the size of the data set is changed, resulting in a change to
-- the global variable: Table_Status.Of_Current_Size_Of_W_Table.
V_Re : Data_Array := (others => 0.0);
V_Im : Data_Array := (others => 0.0);
-- Following record holds info on the status of the arrays V and W_Table.
-- Sometimes they have to updated, and whether or not they do depends
-- on the settings held in the record Table_Status:
type Table_Status is record
Is_Not_Yet_Initialized : Boolean := True;
Inverse_FFT_Was_Desired_During_Previous_Call : Boolean := False;
Of_Current_Size_Of_W_Table : Data_Index := 0;
end record;
Memory : Table_Status;
-----------------------
-- Construct_W_Table --
-----------------------
-- The procedure calculates a table of W = Exp(-i(2Pi/N)*(K*K)/2)
-- where K goes from 0..N-1, and N = LastIndexOfData + 1.
--
procedure Construct_W_Table
(Last_Data_Point : in Data_Index)
is
C, S, Theta : Real;
pragma Assert(Real'Digits >= 15);
Pii : constant Real := 3.14159_26535_89793_23846_26433_83279_50288;
TwoN : constant Real := 2.0 * (Real(Last_Data_Point) + 1.0);
Two_Pi_Over_2N : constant Real := 2.0 * Pii / TwoN;
type Integer_64 is range 0 .. 2**63-1;
B : constant Integer_64 := 2 * (Integer_64 (Last_Data_Point) + 1); -- 2*N
Base : Integer_64 := Integer_64 (Real'Ceiling (Sqrt (Real(B))));
pragma Assert (B <= 2**40); -- K_Squared_Modulo_B needs this.
------------------------
-- K_Squared_Modulo_B --
------------------------
function K_Squared_Modulo_B (K : Data_Index)
return Real
is
e, f, t1, t2, t3 : Integer_64;
K64 : constant Integer_64 := Integer_64 (K);
begin
-- K is in 0..N-1, and B = 2*N
if K64 < 2**31-1 then
return Real ((k64 * k64) mod B);
end if;
if Base**2 < B then Base := Base + 1; end if;
e := K64 mod Base;
f := K64 / Base;
-- K = e + f*Base
-- so K*K = e*e + 2*e*f*Base + f*f*Base**2
t1 := (e*e) mod B;
t2 := (e*f*2*Base) mod B;
t3 := (f*f*(Base**2 mod B)) mod B;-- Base**2 mod B <= 2*Base
return Real ((t1 + t2 + t3) mod B);
end K_Squared_Modulo_B;
begin
W_Table (Data_Index'First) := (1.0, 0.0);
-- For accuracy in the calculation of Cos ((2Pi)*(K*K)/(2N))
-- use the equivalent quantity: Cos (2Pi * ((K*K) Mod (2N))/(2N))
-- which equals Cos ((2Pi/(2N)) * (K*K) Mod (2N))
-- (using A/B = (A Mod B) / B + Some_Integer.)
for K in Data_Index range 1 .. Last_Data_Point loop
Theta := Two_Pi_Over_2N * K_Squared_Modulo_B (K); -- B = 2N
C := Cos (Theta);
S := Sin (Theta);
W_Table (K) := (C, -S);
end loop;
end Construct_W_Table;
-----------------
-- FFT_Chirped --
-----------------
procedure FFT_Chirped
(Data_Re, Data_Im : in out Data_Array;
Input_Data_Last : in Data_Index;
Inverse_FFT_Desired : in Boolean := False;
Normalized_Data_Desired : in Boolean := True)
is
L_Minus_1, L_Temp, Half_Data : Array_Index;
Test : Array_Index;
Table_Index, Starting_Index : Array_Index;
Last_Data_Point : constant Array_Index := Input_Data_Last;
Log_Of_Data_Size_Minus_1 : Exponent_Of_Two_Type;
NormFactor : Real;
W_Table_Was_Reconstructed : Boolean;
Choice_Of_Inverse_Has_Changed : Boolean;
W_Re, W_Im, D_Re, D_Im, V1_Re, V1_Im : Real;
------------------
-- Integer_Log2 --
------------------
-- Rounds down, so on range (eg) 0..2**15-1 it returns 0 .. 14
-- returns 0 for I in 0..1 and returns 1 for I in 2..3, etc.
function Integer_Log2 (I : Array_Index)
return Exponent_Of_Two_Type
is
Log2 : Exponent_Of_Two_Type := 0;
begin
for Exponent in Natural loop
exit when 2**Exponent > I;
Log2 := Exponent;
end loop;
return Log2;
end Integer_Log2;
begin
-- Below use the variable names in the reference given above.
if Last_Data_Point = 0 then return; end if;
if Last_Data_Point > Data_Index'Last then
put_line ("Can't FFT a data set that large. Input_Data_Last is too big.");
raise Constraint_Error;
end if;
-- If checks are suppressed, then this check is very helpful.
--**************************************************************
-- Step 1. We use a radix 2 FFT to calculate the convolution
-- used in the chirped FFT. Must find the first
-- power of two (L) that is greater than or equal to 2*N-1 where
-- N = Last_Data_Point+1. So L is to equal the 1st
-- power of 2 that is greater than or equal 2*Last_Data_Point + 1.
-- What really want is L-1, which call L_Minus_1. Notice
-- that if Last_Data_Point = 255, then L_Minus_1 = 511.
-- If Last_Data_Point = 256, then L_Minus_1 = 1023.
--**************************************************************
L_temp := 2*Last_Data_Point + 1;
Log_Of_Data_Size_Minus_1 := Integer_Log2 (L_temp);
-- Integer_Log2 rounds down so LogOf.. is in Exponent_Of_Two_Type range.
-- This is LogOfDataSize - 1, not LogOf(DataSize-1).
-- The length of the padded data is twice 2**Log_Of_Data_Size_Minus_1
Half_Data := Array_Index (2**Integer(Log_Of_Data_Size_Minus_1));
L_Minus_1 := Half_Data + (Half_Data - 1);
--**************************************************************
-- Step 2. Construct the W table, if a Table of the correct length
-- has not already been constructed. Perform Step 3 whenever we
-- perform step 2. (And also if the setting of Inverse_FFT_Desired
-- changes from what it was in the previous call.)
--**************************************************************
W_Table_Was_Reconstructed := False;
if Memory.Of_Current_Size_Of_W_Table /= Last_Data_Point
or Memory.Is_Not_Yet_Initialized then
Construct_W_Table (Last_Data_Point);
W_Table_Was_Reconstructed := True;
Memory.Of_Current_Size_Of_W_Table := Last_Data_Point;
Memory.Is_Not_Yet_Initialized := False;
end if;
--**************************************************************
-- Step 3. FFT the global chirp array V. Don't remake it if it is already
-- OK. V depends on size of Last_Data_Point. If size of Last_Data_Point
-- not constant between calls to FFT_Chirped, then V and FFT(V) must be
-- reconstructed. Also, if the setting of Inverse_FFT_Desired changes
-- from the previous call to FFT_Chirped then reconstruct V and FFT(V).
-- V is global array that is often reused between calls.
-- (W_Table is also a global that is saved between calls.)
--**************************************************************
Choice_Of_Inverse_Has_Changed :=
(Inverse_FFT_Desired /= Memory.Inverse_FFT_Was_Desired_During_Previous_Call);
if W_Table_Was_Reconstructed or Choice_Of_Inverse_Has_Changed then
if Inverse_FFT_Desired then
for I in Data_Index range 0..Last_Data_Point loop
V_Re(I) := W_Table(I).Re;
V_Im(I) := W_Table(I).Im;
end loop;
else
for I in Data_Index range 0..Last_Data_Point loop
V_Re(I) := W_Table(I).Re;
V_Im(I) := -W_Table(I).Im;
end loop;
end if;
Starting_Index := L_Minus_1 - Last_Data_Point + 1;
for I in Array_Index range Starting_Index..L_Minus_1 loop
Table_Index := L_Minus_1 - I;
Table_Index := Table_Index + 1;
if Inverse_FFT_Desired then
V_Re(I) := W_Table(Table_Index).Re;
V_Im(I) := W_Table(Table_Index).Im;
else
V_Re(I) := W_Table(Table_Index).Re;
V_Im(I) := -W_Table(Table_Index).Im;
end if;
end loop;
if Starting_Index > Last_Data_Point+1 then
for I in Last_Data_Point+1..Starting_Index-1 loop
V_Re(I) := 0.0; V_Im(I) := 0.0;
end loop;
end if;
FFT
(Data_Re => V_Re,
Data_Im => V_Im,
Transformed_Data_Last => Test,
Input_Data_Last => L_Minus_1,
Exp_Table => Exp_Table,
Inverse_FFT_Desired => False,
Normalized_Data_Desired => False);
end if;
-- Update the global memory of the status of the Inverse_FFT_Desired setting.
Memory.Inverse_FFT_Was_Desired_During_Previous_Call := Inverse_FFT_Desired;
--**************************************************************
-- Step 4. Multiply Data by W, put the product into Data, and FFT it:
--**************************************************************
if Inverse_FFT_Desired then
for I in Array_Index range 0..Last_Data_Point loop
-- Data(I) := Data(I) * Conjugate (W_Table (I));
W_Re := W_Table(I).Re; W_Im := -W_Table(I).Im;
D_Re := Data_Re(I); D_Im := Data_Im(I);
Data_Re(I) := D_Re*W_Re - D_Im*W_Im;
Data_Im(I) := D_Re*W_Im + D_Im*W_Re;
end loop;
else
for I in Array_Index range 0..Last_Data_Point loop
-- Data(I) := Data(I) * W_Table (I);
W_Re := W_Table(I).Re; W_Im := W_Table(I).Im;
D_Re := Data_Re(I); D_Im := Data_Im(I);
Data_Re(I) := D_Re*W_Re - D_Im*W_Im;
Data_Im(I) := D_Re*W_Im + D_Im*W_Re;
end loop;
end if;
for I in Array_Index range Last_Data_Point+1..L_Minus_1 loop
Data_Re(I) := 0.0; Data_Im(I) := 0.0;
end loop;
FFT
(Data_Re => Data_Re,
Data_Im => Data_Im,
Transformed_Data_Last => Test,
Input_Data_Last => L_Minus_1,
Exp_Table => Exp_Table,
Inverse_FFT_Desired => False,
Normalized_Data_Desired => False);
--**************************************************************
-- Step 5. Multiply Data by V. Call the product Data,
-- and then inverse FFT it. (This completes the convolution.)
--**************************************************************
for I in Array_Index range 0..L_Minus_1 loop
V1_Re:= V_Re(I); V1_Im := V_Im(I);
D_Re := Data_Re(I); D_Im := Data_Im(I);
Data_Re(I) := D_Re*V1_Re - D_Im*V1_Im;
Data_Im(I) := D_Re*V1_Im + D_Im*V1_Re;
end loop;
FFT
(Data_Re => Data_Re,
Data_Im => Data_Im,
Transformed_Data_Last => Test,
Input_Data_Last => L_Minus_1,
Exp_Table => Exp_Table,
Inverse_FFT_Desired => True,
Normalized_Data_Desired => False);
--**************************************************************
-- Step 6. Multiply result by the appropriate Chirped exp's, and
-- simultaneously put the FFT'd data back into the output array Data.
--**************************************************************
if Inverse_FFT_Desired then
for I in Data_Index range 0..Last_Data_Point loop
-- Data(I) := Data(I) * Conjugate (W_Table(I));
W_Re := W_Table(I).Re; W_Im := -W_Table(I).Im;
D_Re := Data_Re(I); D_Im := Data_Im(I);
Data_Re(I) := D_Re*W_Re - D_Im*W_Im;
Data_Im(I) := D_Re*W_Im + D_Im*W_Re;
end loop;
else
for I in Data_Index range 0..Last_Data_Point loop
-- Data(I) := Data(I) * W_Table (I);
W_Re := W_Table(I).Re; W_Im := W_Table(I).Im;
D_Re := Data_Re(I); D_Im := Data_Im(I);
Data_Re(I) := D_Re*W_Re - D_Im*W_Im;
Data_Im(I) := D_Re*W_Im + D_Im*W_Re;
end loop;
end if;
for I in Last_Data_Point+1..Array_Index'Last loop
Data_Re(I) := 0.0; Data_Im(I) := 0.0;
end loop;
--**************************************************************
-- Step 7. Normalize data if so desired. We have saved some time
-- by failing to normalize in the above FFT's. Two of the three
-- calls should have normalized, each dividing the data by
-- Sqrt (L_Minus_1 + 1). In addition, must divide by another
-- factor: Sqrt (Last_Data_Point + 1). We do them all together:
--**************************************************************
if Normalized_Data_Desired then
NormFactor := (Real(L_Minus_1) + 1.0) * Sqrt (Real(Last_Data_Point) + 1.0);
NormFactor := 1.0 / NormFactor;
for I in Data_Index range 0..Last_Data_Point loop
Data_Re(I) := NormFactor * Data_Re(I);
Data_Im(I) := NormFactor * Data_Im(I);
end loop;
end if;
end FFT_Chirped;
end Chirped;
|
zhmu/ananas | Ada | 867 | adb | -- { dg-do compile }
-- { dg-options "-gnatws" }
procedure Rep_Clause3 is
subtype U_16 is integer range 0..2**16-1;
type TYPE1 is range 0 .. 135;
for TYPE1'size use 14;
type TYPE2 is range 0 .. 262_143;
for TYPE2'size use 18;
subtype TYPE3 is integer range 1 .. 21*6;
type ARR is array (TYPE3 range <>) of boolean;
pragma Pack(ARR);
subtype SUB_ARR is ARR(1 .. 5*6);
OBJ : SUB_ARR;
type R is
record
N : TYPE1;
L : TYPE2;
I : SUB_ARR;
CRC : U_16;
end record;
for R use
record at mod 4;
N at 0 range 0 .. 13;
L at 0 range 14 .. 31;
I at 4 range 2 .. 37;
CRC at 8 range 16 .. 31;
end record;
for R'size use 12*8;
type SUB_R is array (1..4) of R;
T : SUB_R;
begin
if OBJ = T(1).I then
raise Program_Error;
end if;
end;
|
DrenfongWong/tkm-rpc | Ada | 1,000 | adb | with Tkmrpc.Servers.Ike;
with Tkmrpc.Results;
with Tkmrpc.Request.Ike.Ae_Reset.Convert;
with Tkmrpc.Response.Ike.Ae_Reset.Convert;
package body Tkmrpc.Operation_Handlers.Ike.Ae_Reset is
-------------------------------------------------------------------------
procedure Handle (Req : Request.Data_Type; Res : out Response.Data_Type) is
Specific_Req : Request.Ike.Ae_Reset.Request_Type;
Specific_Res : Response.Ike.Ae_Reset.Response_Type;
begin
Specific_Res := Response.Ike.Ae_Reset.Null_Response;
Specific_Req := Request.Ike.Ae_Reset.Convert.From_Request (S => Req);
if Specific_Req.Data.Ae_Id'Valid then
Servers.Ike.Ae_Reset
(Result => Specific_Res.Header.Result,
Ae_Id => Specific_Req.Data.Ae_Id);
Res := Response.Ike.Ae_Reset.Convert.To_Response (S => Specific_Res);
else
Res.Header.Result := Results.Invalid_Parameter;
end if;
end Handle;
end Tkmrpc.Operation_Handlers.Ike.Ae_Reset;
|
onox/orka | Ada | 2,231 | ads | -- SPDX-License-Identifier: Apache-2.0
--
-- Copyright (c) 2017 onox <[email protected]>
--
-- Licensed under the Apache License, Version 2.0 (the "License");
-- you may not use this file except in compliance with the License.
-- You may obtain a copy of the License at
--
-- http://www.apache.org/licenses/LICENSE-2.0
--
-- Unless required by applicable law or agreed to in writing, software
-- distributed under the License is distributed on an "AS IS" BASIS,
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-- See the License for the specific language governing permissions and
-- limitations under the License.
package Orka.Rendering.Buffers.Mapped.Persistent is
pragma Preelaborate;
type Persistent_Mapped_Buffer is new Mapped_Buffer with private;
function Create_Buffer
(Kind : Orka.Types.Element_Type;
Length : Positive;
Mode : IO_Mode;
Regions : Positive) return Persistent_Mapped_Buffer
with Post => Create_Buffer'Result.Length = Length;
-- Create a persistent mapped buffer for only writes or only reads
--
-- The actual size of the buffer is n * Length where n is the number
-- of regions. Each region has an index (>= 0).
--
-- After writing or reading, you must call Advance_Index (once per frame).
--
-- If Mode = Write, then you must wait for a fence to complete before
-- writing and then set the fence after the drawing or dispatch commands
-- which uses the mapped buffer.
--
-- If Mode = Read, then you must set a fence after the drawing or
-- dispatch commands that write to the buffer and then wait for the
-- fence to complete before reading the data.
overriding
function Length (Object : Persistent_Mapped_Buffer) return Positive;
-- Number of elements in the buffer
--
-- Will be less than the actual size of the buffer due to the n regions.
procedure Advance_Index (Object : in out Persistent_Mapped_Buffer);
private
type Persistent_Mapped_Buffer is new Mapped_Buffer with record
Index : Natural;
Regions : Positive;
end record
with Type_Invariant => Index < Regions;
end Orka.Rendering.Buffers.Mapped.Persistent;
|
SayCV/rtems-addon-packages | Ada | 6,229 | adb | ------------------------------------------------------------------------------
-- --
-- GNAT ncurses Binding --
-- --
-- Terminal_Interface.Curses.Panels --
-- --
-- B O D Y --
-- --
------------------------------------------------------------------------------
-- Copyright (c) 1998-2004,2009 Free Software Foundation, Inc. --
-- --
-- Permission is hereby granted, free of charge, to any person obtaining a --
-- copy of this software and associated documentation files (the --
-- "Software"), to deal in the Software without restriction, including --
-- without limitation the rights to use, copy, modify, merge, publish, --
-- distribute, distribute with modifications, sublicense, and/or sell --
-- copies of the Software, and to permit persons to whom the Software is --
-- furnished to do so, subject to the following conditions: --
-- --
-- The above copyright notice and this permission notice shall be included --
-- in all copies or substantial portions of the Software. --
-- --
-- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS --
-- OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF --
-- MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. --
-- IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, --
-- DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR --
-- OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR --
-- THE USE OR OTHER DEALINGS IN THE SOFTWARE. --
-- --
-- Except as contained in this notice, the name(s) of the above copyright --
-- holders shall not be used in advertising or otherwise to promote the --
-- sale, use or other dealings in this Software without prior written --
-- authorization. --
------------------------------------------------------------------------------
-- Author: Juergen Pfeifer, 1996
-- Version Control:
-- $Revision$
-- $Date$
-- Binding Version 01.00
------------------------------------------------------------------------------
with Terminal_Interface.Curses.Aux; use Terminal_Interface.Curses.Aux;
with Interfaces.C;
package body Terminal_Interface.Curses.Panels is
use type Interfaces.C.int;
function Create (Win : Window) return Panel
is
function Newpanel (Win : Window) return Panel;
pragma Import (C, Newpanel, "new_panel");
Pan : Panel;
begin
Pan := Newpanel (Win);
if Pan = Null_Panel then
raise Panel_Exception;
end if;
return Pan;
end Create;
procedure Bottom (Pan : Panel)
is
function Bottompanel (Pan : Panel) return C_Int;
pragma Import (C, Bottompanel, "bottom_panel");
begin
if Bottompanel (Pan) = Curses_Err then
raise Panel_Exception;
end if;
end Bottom;
procedure Top (Pan : Panel)
is
function Toppanel (Pan : Panel) return C_Int;
pragma Import (C, Toppanel, "top_panel");
begin
if Toppanel (Pan) = Curses_Err then
raise Panel_Exception;
end if;
end Top;
procedure Show (Pan : Panel)
is
function Showpanel (Pan : Panel) return C_Int;
pragma Import (C, Showpanel, "show_panel");
begin
if Showpanel (Pan) = Curses_Err then
raise Panel_Exception;
end if;
end Show;
procedure Hide (Pan : Panel)
is
function Hidepanel (Pan : Panel) return C_Int;
pragma Import (C, Hidepanel, "hide_panel");
begin
if Hidepanel (Pan) = Curses_Err then
raise Panel_Exception;
end if;
end Hide;
function Get_Window (Pan : Panel) return Window
is
function Panel_Win (Pan : Panel) return Window;
pragma Import (C, Panel_Win, "panel_window");
Win : constant Window := Panel_Win (Pan);
begin
if Win = Null_Window then
raise Panel_Exception;
end if;
return Win;
end Get_Window;
procedure Replace (Pan : Panel;
Win : Window)
is
function Replace_Pan (Pan : Panel;
Win : Window) return C_Int;
pragma Import (C, Replace_Pan, "replace_panel");
begin
if Replace_Pan (Pan, Win) = Curses_Err then
raise Panel_Exception;
end if;
end Replace;
procedure Move (Pan : Panel;
Line : Line_Position;
Column : Column_Position)
is
function Move (Pan : Panel;
Line : C_Int;
Column : C_Int) return C_Int;
pragma Import (C, Move, "move_panel");
begin
if Move (Pan, C_Int (Line), C_Int (Column)) = Curses_Err then
raise Panel_Exception;
end if;
end Move;
function Is_Hidden (Pan : Panel) return Boolean
is
function Panel_Hidden (Pan : Panel) return C_Int;
pragma Import (C, Panel_Hidden, "panel_hidden");
begin
if Panel_Hidden (Pan) = Curses_False then
return False;
else
return True;
end if;
end Is_Hidden;
procedure Delete (Pan : in out Panel)
is
function Del_Panel (Pan : Panel) return C_Int;
pragma Import (C, Del_Panel, "del_panel");
begin
if Del_Panel (Pan) = Curses_Err then
raise Panel_Exception;
end if;
Pan := Null_Panel;
end Delete;
end Terminal_Interface.Curses.Panels;
|
zhmu/ananas | Ada | 350 | adb | -- { dg-do compile }
-- { dg-require-effective-target store_merge }
-- { dg-options "-O2 -fdump-tree-store-merging" }
with Opt71_Pkg; use Opt71_Pkg;
procedure Opt71b (X : not null access Rec; Y : not null access Rec) is
begin
X.all := (Flag => True, Size => Y.Size);
end;
-- { dg-final { scan-tree-dump "Merging successful" "store-merging" } }
|
AdaCore/gpr | Ada | 54,349 | adb | --
-- Copyright (C) 2019-2023, AdaCore
--
-- SPDX-License-Identifier: Apache-2.0 WITH LLVM-Exception
--
package body GPR2.Project.Registry.Attribute.Description is
package PRA renames GPR2.Project.Registry.Attribute;
-------------------------------
-- Get_Attribute_Description --
-------------------------------
function Get_Attribute_Description (Key : Q_Attribute_Id)
return String is
use Pack_Attribute_Description;
begin
if Contains (Attribute_Description, Key)
then
return Element (Attribute_Description, Key);
else
return "";
end if;
end Get_Attribute_Description;
----------
-- Hash --
----------
function Hash (Key : Q_Attribute_Id)
return Hash_Type is (Ada.Strings.Hash (Image (Key)));
-------------------------------
-- Set_Attribute_Description --
-------------------------------
procedure Set_Attribute_Description
(Key : Q_Attribute_Id; Description : String) is
use Pack_Attribute_Description;
C : constant Cursor := Find (Attribute_Description, Key);
begin
if C = No_Element then
Insert (Attribute_Description, Key, Description);
else
Replace_Element (Attribute_Description, C, Description);
end if;
end Set_Attribute_Description;
begin
-- Name
Set_Attribute_Description
(Key => PRA.Name,
Description =>
"The name of the project."
);
-- Project_Dir
Set_Attribute_Description
(Key => PRA.Project_Dir,
Description =>
"The path name of the project directory."
);
-- Main
Set_Attribute_Description
(Key => PRA.Main,
Description =>
"The list of main sources for the executables."
);
-- Languages
Set_Attribute_Description
(Key => PRA.Languages,
Description =>
"The list of languages of the sources of the project."
);
-- Config_Prj_File
Set_Attribute_Description
(Key => PRA.Config_Prj_File,
Description =>
"The main configuration project file."
);
-- Roots
Set_Attribute_Description
(Key => PRA.Roots,
Description =>
"The index is the file name of an executable source. Indicates the " &
"list of units from the main project that need to be bound and " &
"linked with their closures with the executable. The index is either" &
" a file name, a language name or '*'. The roots for an executable " &
"source are those in Roots with an index that is the executable " &
"source file name, if declared. Otherwise, they are those in Roots " &
"with an index that is the language name of the executable source, " &
"if present. Otherwise, they are those in Roots ('*'), if declared. " &
"If none of these three possibilities are declared, then there are " &
"no roots for the executable source."
);
-- Externally_Built
Set_Attribute_Description
(Key => PRA.Externally_Built,
Description =>
"Indicates if the project is externally built. Only case-insensitive" &
" values allowed are 'true' and 'false', the default."
);
-- Warning_Message
Set_Attribute_Description
(Key => PRA.Warning_Message,
Description =>
"Causes gprbuild to emit a user-defined warning message."
);
-- Object_Dir
Set_Attribute_Description
(Key => PRA.Object_Dir,
Description =>
"Indicates the object directory for the project."
);
-- Exec_Dir
Set_Attribute_Description
(Key => PRA.Exec_Dir,
Description =>
"Indicates the exec directory for the project, that is the directory" &
" where the executables are."
);
-- Create_Missing_Dirs
Set_Attribute_Description
(Key => PRA.Create_Missing_Dirs,
Description =>
"Indicates if the missing object, library and executable directories" &
" should be created automatically by the project-aware tool. Taken " &
"into account only in the main project. Only authorized " &
"case-insensitive values are 'true' and 'false'."
);
-- Source_Dirs
Set_Attribute_Description
(Key => PRA.Source_Dirs,
Description =>
"The list of source directories of the project."
);
-- Inherit_Source_Path
Set_Attribute_Description
(Key => PRA.Inherit_Source_Path,
Description =>
"Index is a language name. Value is a list of language names. " &
"Indicates that in the source search path of the index language the " &
"source directories of the languages in the list should be included."
);
-- Exclude_Source_Dirs
Set_Attribute_Description
(Key => PRA.Excluded_Source_Dirs,
Description =>
"The list of directories that are included in Source_Dirs but are " &
"not source directories of the project."
);
-- Ignore_Source_Sub_Dirs
Set_Attribute_Description
(Key => PRA.Ignore_Source_Sub_Dirs,
Description =>
"Value is a list of simple names or patterns for subdirectories that" &
" are removed from the list of source directories, including their " &
"subdirectories."
);
-- Source_Files
Set_Attribute_Description
(Key => PRA.Source_Files,
Description =>
"Value is a list of source file simple names."
);
-- Locally_Removed_Files
Set_Attribute_Description
(Key => PRA.Locally_Removed_Files,
Description =>
"Obsolescent. Equivalent to Excluded_Source_Files."
);
-- Excluded_Source_Files
Set_Attribute_Description
(Key => PRA.Excluded_Source_Files,
Description =>
"Value is a list of simple file names that are not sources of the " &
"project. Allows to remove sources that are inherited or found in " &
"the source directories and that match the naming scheme."
);
-- Source_List_File
Set_Attribute_Description
(Key => PRA.Source_List_File,
Description =>
"Value is a text file name that contains a list of source file " &
"simple names, one on each line."
);
-- Excluded_Source_List_File
Set_Attribute_Description
(Key => PRA.Excluded_Source_List_File,
Description =>
"Value is a text file name that contains a list of file simple names" &
" that are not sources of the project."
);
-- Interfaces
Set_Attribute_Description
(Key => PRA.Interfaces,
Description =>
"Value is a list of file names that constitutes the interfaces of " &
"the project."
);
-- Project_Files
Set_Attribute_Description
(Key => PRA.Project_Files,
Description =>
"Value is the list of aggregated projects."
);
-- Project_Path
Set_Attribute_Description
(Key => PRA.Project_Path,
Description =>
"Value is a list of directories that are added to the project search" &
" path when looking for the aggregated projects."
);
-- External
Set_Attribute_Description
(Key => PRA.External,
Description =>
"Index is the name of an external reference. Value is the value of " &
"the external reference to be used when parsing the aggregated " &
"projects."
);
-- Library_Dir
Set_Attribute_Description
(Key => PRA.Library_Dir,
Description =>
"Value is the name of the library directory. This attribute needs to" &
" be declared for each library project."
);
-- Library_Name
Set_Attribute_Description
(Key => PRA.Library_Name,
Description =>
"Value is the name of the library. This attribute needs to be " &
"declared or inherited for each library project."
);
-- Library_Kind
Set_Attribute_Description
(Key => PRA.Library_Kind,
Description =>
"Specifies the kind of library: static library (archive) or shared " &
"library. Case-insensitive values must be one of 'static' for " &
"archives (the default), 'static-pic' for archives of Position " &
"Independent Code, or 'dynamic' or 'relocatable' for shared " &
"libraries."
);
-- Library_Version
Set_Attribute_Description
(Key => PRA.Library_Version,
Description =>
"Value is the name of the library file."
);
-- Library_Interface
Set_Attribute_Description
(Key => PRA.Library_Interface,
Description =>
"Value is the list of unit names that constitutes the interfaces of " &
"a Stand-Alone Library project."
);
-- Library_Standalone
Set_Attribute_Description
(Key => PRA.Library_Standalone,
Description =>
"Specifies if a Stand-Alone Library (SAL) is encapsulated or not. " &
"Only authorized case-insensitive values are 'standard' for non " &
"encapsulated SALs, 'encapsulated' for encapsulated SALs or 'no' for" &
" non SAL library project."
);
-- Library_Encapsulated_Options
Set_Attribute_Description
(Key => PRA.Library_Encapsulated_Options,
Description =>
"Value is a list of options that need to be used when linking an " &
"encapsulated Stand-Alone Library."
);
-- Library_Encapsulated_Supported
Set_Attribute_Description
(Key => PRA.Library_Encapsulated_Supported,
Description =>
"Indicates if encapsulated Stand-Alone Libraries are supported. Only" &
" authorized case-insensitive values are 'true' and 'false' (the " &
"default)."
);
-- Library_Auto_Init
Set_Attribute_Description
(Key => PRA.Library_Auto_Init,
Description =>
"Indicates if a Stand-Alone Library is auto-initialized. Only " &
"authorized case-insensitive values are 'true' and 'false'."
);
-- Leading_Library_Options
Set_Attribute_Description
(Key => PRA.Leading_Library_Options,
Description =>
"Value is a list of options that are to be used at the beginning of " &
"the command line when linking a shared library."
);
-- Library_Options
Set_Attribute_Description
(Key => PRA.Library_Options,
Description =>
"Value is a list of options that are to be used when linking a " &
"shared library."
);
-- Library_Rpath_Options
Set_Attribute_Description
(Key => PRA.Library_Rpath_Options,
Description =>
"Index is a language name. Value is a list of options for an " &
"invocation of the compiler of the language. This invocation is done" &
" for a shared library project with sources of the language. The " &
"output of the invocation is the path name of a shared library file." &
" The directory name is to be put in the run path option switch when" &
" linking the shared library for the project."
);
-- Library_Src_Dir
Set_Attribute_Description
(Key => PRA.Library_Src_Dir,
Description =>
"Value is the name of the directory where copies of the sources of " &
"the interfaces of a Stand-Alone Library are to be copied."
);
-- Library_ALI_Dir
Set_Attribute_Description
(Key => PRA.Library_Ali_Dir,
Description =>
"Value is the name of the directory where the ALI files of the " &
"interfaces of a Stand-Alone Library are to be copied. When this " &
"attribute is not declared, the directory is the library directory."
);
-- Library_gcc
Set_Attribute_Description
(Key => PRA.Library_Gcc,
Description =>
"Obsolescent attribute. Specify the linker driver used to link a " &
"shared library. Use instead attribute Linker'Driver."
);
-- Library_Symbol_File
Set_Attribute_Description
(Key => PRA.Library_Symbol_File,
Description =>
"Value is the name of the library symbol file."
);
-- Library_Symbol_Policy
Set_Attribute_Description
(Key => PRA.Library_Symbol_Policy,
Description =>
"Indicates the symbol policy kind. Only authorized case-insensitive " &
"values are 'restricted', 'unrestricted'."
);
-- Library_Reference_Symbol_File
Set_Attribute_Description
(Key => PRA.Library_Reference_Symbol_File,
Description =>
"Value is the name of the reference symbol file."
);
-- Default_Language
Set_Attribute_Description
(Key => PRA.Default_Language,
Description =>
"Value is the case-insensitive name of the language of a project " &
"when attribute Languages is not specified."
);
-- Run_Path_Option
Set_Attribute_Description
(Key => PRA.Run_Path_Option,
Description =>
"Value is the list of switches to be used when specifying the run " &
"path option in an executable."
);
-- Run_Path_Origin
Set_Attribute_Description
(Key => PRA.Run_Path_Origin,
Description =>
"Value is the string that may replace the path name of the " &
"executable directory in the run path options."
);
-- Separate_Run_Path_Options
Set_Attribute_Description
(Key => PRA.Separate_Run_Path_Options,
Description =>
"Indicates if there may be several run path options specified when " &
"linking an executable. Only authorized case-insensitive values are " &
"'true' or 'false' (the default)."
);
-- Toolchain_Version
Set_Attribute_Description
(Key => PRA.Toolchain_Version,
Description =>
"Index is a language name. Specify the version of a toolchain for a " &
"language."
);
-- Required_Toolchain_Version
Set_Attribute_Description
(Key => PRA.Required_Toolchain_Version,
Description =>
"Index is a language name. Specify the value expected for the " &
"Toolchain_Version attribute for this language, typically provided " &
"by an auto-generated configuration project. If " &
"Required_Toolchain_Version and Toolchain_Version do not match, the " &
"project processing aborts with an error."
);
-- Toolchain_Description
Set_Attribute_Description
(Key => PRA.Toolchain_Description,
Description =>
"Obsolescent. No longer used."
);
-- Object_Generated
Set_Attribute_Description
(Key => PRA.Object_Generated,
Description =>
"Index is a language name. Indicates if invoking the compiler for a " &
"language produces an object file. Only authorized case-insensitive " &
"values are 'false' and 'true' (the default)."
);
-- Objects_Linked
Set_Attribute_Description
(Key => PRA.Objects_Linked,
Description =>
"Index is a language name. Indicates if the object files created by " &
"the compiler for a language need to be linked in the executable. " &
"Only authorized case-insensitive values are 'false' and 'true' (the" &
" default)."
);
-- Target
Set_Attribute_Description
(Key => PRA.Target,
Description =>
"Value is the name of the target platform. Taken into account only " &
"in the main project. Note that when the target is specified on the " &
"command line (usually with a switch ``--target=``), the value of " &
"attribute reference 'Target is the one specified on the command " &
"line."
);
-- Runtime
Set_Attribute_Description
(Key => PRA.Runtime,
Description =>
"Index is a language name. Indicates the runtime directory that is " &
"to be used when using the compiler of the language. Taken into " &
"account only in the main project, or its extended projects if any. " &
"Note that when the runtime is specified for a language on the " &
"command line (usually with a switch ``--RTS``), the value of " &
"attribute reference 'Runtime for this language is the one " &
"specified on the command line."
);
-- Runtime_Dir
Set_Attribute_Description
(Key => PRA.Runtime_Dir,
Description =>
"Index is a language name. Value is the path name of the runtime " &
"directory for the language."
);
-- Runtime_Library_Dir
Set_Attribute_Description
(Key => PRA.Runtime_Library_Dir,
Description =>
"Index is a language name. Value is the path name of the directory " &
"where the runtime libraries are located. This attribute is " &
"obsolete."
);
-- Runtime_Source_Dirs
Set_Attribute_Description
(Key => PRA.Runtime_Source_Dirs,
Description =>
"Index is a language name. Value is the path names of the " &
"directories where the sources of runtime libraries are located. " &
"This attribute is not normally declared."
);
-- Runtime_Source_Dir
Set_Attribute_Description
(Key => PRA.Runtime_Source_Dir,
Description =>
"Index is a language name. Value is the path name of the directory " &
"where the sources of runtime libraries are located. This attribute " &
"is obsolete."
);
-- Toolchain_Name
Set_Attribute_Description
(Key => PRA.Toolchain_Name,
Description =>
"Index is a language name. Indicates the toolchain name that is to " &
"be used when using the compiler of the language. Taken into account" &
" only in the main project, or its extended projects if any."
);
-- Library_Builder
Set_Attribute_Description
(Key => PRA.Library_Builder,
Description =>
"Value is the path name of the application that is to be used to " &
"build libraries. Usually the path name of 'gprlib'."
);
-- Library_Support
Set_Attribute_Description
(Key => PRA.Library_Support,
Description =>
"Indicates the level of support of libraries. Only authorized " &
"case-insensitive values are 'static_only', 'full' or 'none' (the " &
"default)."
);
-- Archive_Builder
Set_Attribute_Description
(Key => PRA.Archive_Builder,
Description =>
"Value is the name of the application to be used to create a static " &
"library (archive), followed by the options to be used."
);
-- Archive_Builder_Append_Option
Set_Attribute_Description
(Key => PRA.Archive_Builder_Append_Option,
Description =>
"Value is the list of options to be used when invoking the archive " &
"builder to add project files into an archive."
);
-- Archive_Indexer
Set_Attribute_Description
(Key => PRA.Archive_Indexer,
Description =>
"Value is the name of the archive indexer, followed by the required " &
"options."
);
-- Archive_Suffix
Set_Attribute_Description
(Key => PRA.Archive_Suffix,
Description =>
"Value is the extension of archives. When not declared, the " &
"extension is '.a'."
);
-- Library_Partial_Linker
Set_Attribute_Description
(Key => PRA.Library_Partial_Linker,
Description =>
"Value is the name of the partial linker executable, followed by the" &
" required options. If set to an empty list, partial linking is not" &
" performed."
);
-- Shared_Library_Prefix
Set_Attribute_Description
(Key => PRA.Shared_Library_Prefix,
Description =>
"Value is the prefix in the name of shared library files. When not " &
"declared, the prefix is 'lib'."
);
-- Shared_Library_Suffix
Set_Attribute_Description
(Key => PRA.Shared_Library_Suffix,
Description =>
"Value is the extension of the name of shared library files. When " &
"not declared, the extension is '.so'."
);
-- Symbolic_Link_Supported
Set_Attribute_Description
(Key => PRA.Symbolic_Link_Supported,
Description =>
"Indicates if symbolic links are supported on the platform. Only " &
"authorized case-insensitive values are 'true' and 'false' (the " &
"default)."
);
-- Library_Major_Minor_Id_Supported
Set_Attribute_Description
(Key => PRA.Library_Major_Minor_Id_Supported,
Description =>
"Indicates if major and minor ids for shared library names are " &
"supported on the platform. Only authorized case-insensitive values " &
"are 'true' and 'false' (the default)."
);
-- Library_Auto_Init_Supported
Set_Attribute_Description
(Key => PRA.Library_Auto_Init_Supported,
Description =>
"Indicates if auto-initialization of Stand-Alone Libraries is " &
"supported. Only authorized case-insensitive values are 'true' and " &
"'false' (the default)."
);
-- Shared_Library_Minimum_Switches
Set_Attribute_Description
(Key => PRA.Shared_Library_Minimum_Switches,
Description =>
"Value is the list of required switches when linking a shared " &
"library."
);
-- Library_Version_Switches
Set_Attribute_Description
(Key => PRA.Library_Version_Switches,
Description =>
"Value is the list of switches to specify a internal name for a " &
"shared library."
);
-- Library_Install_Name_Option
Set_Attribute_Description
(Key => PRA.Library_Install_Name_Option,
Description =>
"Value is the name of the option that needs to be used, concatenated" &
" with the path name of the library file, when linking a shared " &
"library."
);
-- Binder.Default_Switches
Set_Attribute_Description
(Key => PRA.Binder.Default_Switches,
Description =>
"Index is a language name. Value is the list of switches to be used " &
"when binding code of the language, if there is no applicable " &
"attribute Switches."
);
-- Binder.Switches
Set_Attribute_Description
(Key => PRA.Binder.Switches,
Description =>
"Index is either a language name or a source file name. Value is the" &
" list of switches to be used when binding code. Index is either the" &
" source file name of the executable to be bound or the language " &
"name of the code to be bound."
);
-- Binder.Driver
Set_Attribute_Description
(Key => PRA.Binder.Driver,
Description =>
"Index is a language name. Value is the name of the application to " &
"be used when binding code of the language."
);
-- Binder.Required_Switches
Set_Attribute_Description
(Key => PRA.Binder.Required_Switches,
Description =>
"Index is a language name. Value is the list of the required " &
"switches to be used when binding code of the language."
);
-- Binder.Prefix
Set_Attribute_Description
(Key => PRA.Binder.Prefix,
Description =>
"Index is a language name. Value is a prefix to be used for the " &
"binder exchange file name for the language. Used to have different " &
"binder exchange file names when binding different languages."
);
-- Binder.Objects_Path
Set_Attribute_Description
(Key => PRA.Binder.Objects_Path,
Description =>
"Index is a language name. Value is the name of the environment " &
"variable that contains the path for the object directories."
);
-- Binder.Object_Path_File
Set_Attribute_Description
(Key => PRA.Binder.Objects_Path_File,
Description =>
"Index is a language name. Value is the name of the environment " &
"variable. The value of the environment variable is the path name of" &
" a text file that contains the list of object directories."
);
-- Builder.Default_Switches
Set_Attribute_Description
(Key => PRA.Builder.Default_Switches,
Description =>
"Index is a language name. Value is the list of builder switches to " &
"be used when building an executable of the language, if there is no" &
" applicable attribute Switches."
);
-- Builder.Switches
Set_Attribute_Description
(Key => PRA.Builder.Switches,
Description =>
"Index is either a language name or a source file name. Value is the" &
" list of builder switches to be used when building an executable. " &
"Index is either the source file name of the executable to be built " &
"or its language name."
);
-- Builder.Global_Compilation_Switches
Set_Attribute_Description
(Key => PRA.Builder.Global_Compilation_Switches,
Description =>
"Index is a language name. Value is the list of compilation switches" &
" to be used when building an executable. Index is either the source" &
" file name of the executable to be built or its language name."
);
-- Builder.Executable
Set_Attribute_Description
(Key => PRA.Builder.Executable,
Description =>
"Index is an executable source file name. Value is the simple file " &
"name of the executable to be built."
);
-- Builder.Executable_Suffix
Set_Attribute_Description
(Key => PRA.Builder.Executable_Suffix,
Description =>
"Value is the extension of the file name of executables. The actual " &
"default value for the extension depends on the host: ``.exe`` on " &
"windows, else an empty string."
);
-- Builder.Global_Configuration_Pragmas
Set_Attribute_Description
(Key => PRA.Builder.Global_Configuration_Pragmas,
Description =>
"Value is the file name of a configuration pragmas file that is " &
"specified to the Ada compiler when compiling any Ada source in the " &
"project tree."
);
-- Builder.Global_Config_File
Set_Attribute_Description
(Key => PRA.Builder.Global_Config_File,
Description =>
"Index is a language name. Value is the file name of a configuration" &
" file that is specified to the compiler when compiling any source " &
"of the language in the project tree."
);
-- Clean.Switches
Set_Attribute_Description
(Key => PRA.Clean.Switches,
Description =>
"Taken into account only in the main project. Value is a list of " &
"switches to be used by the cleaning application."
);
-- Clean.Source_Artifact_Extensions
Set_Attribute_Description
(Key => PRA.Clean.Source_Artifact_Extensions,
Description =>
"Index is a language names. Value is the list of extensions for file" &
" names derived from object file names that need to be cleaned in " &
"the object directory of the project."
);
-- Clean.Object_Artifact_Extensions
Set_Attribute_Description
(Key => PRA.Clean.Object_Artifact_Extensions,
Description =>
"Index is a language names. Value is the list of extensions for file" &
" names derived from source file names that need to be cleaned in " &
"the object directory of the project."
);
-- Clean.Artifacts_In_Object_Dir
Set_Attribute_Description
(Key => PRA.Clean.Artifacts_In_Object_Dir,
Description =>
"Value is a list of file names expressed as regular expressions that" &
" are to be deleted by gprclean in the object directory of the " &
"project."
);
-- Clean.Artifacts_In_Exec_Dir
Set_Attribute_Description
(Key => PRA.Clean.Artifacts_In_Exec_Dir,
Description =>
"Value is list of file names expressed as regular expressions that " &
"are to be deleted by gprclean in the exec directory of the main " &
"project."
);
-- Compiler.Default_Switches
Set_Attribute_Description
(Key => PRA.Compiler.Default_Switches,
Description =>
"Index is a language name. Value is a list of switches to be used " &
"when invoking the compiler for the language for a source of the " &
"project, if there is no applicable attribute Switches."
);
-- Compiler.Switches
Set_Attribute_Description
(Key => PRA.Compiler.Switches,
Description =>
"Index is a source file name or a language name. Value is the list " &
"of switches to be used when invoking the compiler for the source or" &
" for its language."
);
-- Compiler.Local_Configuration_Pragmas
Set_Attribute_Description
(Key => PRA.Compiler.Local_Configuration_Pragmas,
Description =>
"Value is the file name of a configuration pragmas file that is " &
"specified to the Ada compiler when compiling any Ada source in the " &
"project."
);
-- Compiler.Local_Config_File
Set_Attribute_Description
(Key => PRA.Compiler.Local_Config_File,
Description =>
"Index is a language name. Value is the file name of a configuration" &
" file that is specified to the compiler when compiling any source " &
"of the language in the project."
);
-- Compiler.Driver
Set_Attribute_Description
(Key => PRA.Compiler.Driver,
Description =>
"Index is a language name. Value is the name of the executable for " &
"the compiler of the language."
);
-- Compiler.Language_Kind
Set_Attribute_Description
(Key => PRA.Compiler.Language_Kind,
Description =>
"Index is a language name. Indicates the kind of the language, " &
"either file based or unit based. Only authorized case-insensitive " &
"values are 'unit_based' and 'file_based' (the default)."
);
-- Compiler.Dependency_Kind
Set_Attribute_Description
(Key => PRA.Compiler.Dependency_Kind,
Description =>
"Index is a language name. Indicates how the dependencies are " &
"handled for the language. Only authorized case-insensitive values " &
"are 'makefile', 'ali_file', 'ali_closure' or 'none' (the default)."
);
-- Compiler.Required_Switches
Set_Attribute_Description
(Key => PRA.Compiler.Required_Switches,
Description =>
"Equivalent to attribute Leading_Required_Switches."
);
-- Compiler.Leading_Required_Switches
Set_Attribute_Description
(Key => PRA.Compiler.Leading_Required_Switches,
Description =>
"Index is a language name. Value is the list of the minimum switches" &
" to be used at the beginning of the command line when invoking the " &
"compiler for the language."
);
-- Compiler.Trailing_Required_Switches
Set_Attribute_Description
(Key => PRA.Compiler.Trailing_Required_Switches,
Description =>
"Index is a language name. Value is the list of the minimum switches" &
" to be used at the end of the command line when invoking the " &
"compiler for the language."
);
-- Compiler.PIC_Option
Set_Attribute_Description
(Key => PRA.Compiler.Pic_Option,
Description =>
"Index is a language name. Value is the list of switches to be used " &
"when compiling a source of the language when the project is a " &
"shared library project."
);
-- Compiler.Source_File_Switches
Set_Attribute_Description
(Key => PRA.Compiler.Source_File_Switches,
Description =>
"Index is a language name. Value is a list of switches to be used " &
"just before the path name of the source to compile when invoking " &
"the compiler for a source of the language."
);
-- Compiler.Object_File_Suffix
Set_Attribute_Description
(Key => PRA.Compiler.Object_File_Suffix,
Description =>
"Index is a language name. Value is the extension of the object " &
"files created by the compiler of the language. When not specified, " &
"the extension is the default one for the platform."
);
-- Compiler.Object_File_Switches
Set_Attribute_Description
(Key => PRA.Compiler.Object_File_Switches,
Description =>
"Index is a language name. Value is the list of switches to be used " &
"by the compiler of the language to specify the path name of the " &
"object file. When not specified, the switch used is '-o'."
);
-- Compiler.Multi_Unit_Switches
Set_Attribute_Description
(Key => PRA.Compiler.Multi_Unit_Switches,
Description =>
"Index is a language name. Value is the list of switches to be used " &
"to compile a unit in a multi unit source of the language. The index" &
" of the unit in the source is concatenated with the last switches " &
"in the list."
);
-- Compiler.Multi_Unit_Object_Separator
Set_Attribute_Description
(Key => PRA.Compiler.Multi_Unit_Object_Separator,
Description =>
"Index is a language name. Value is the string to be used in the " &
"object file name before the index of the unit, when compiling a " &
"unit in a multi unit source of the language."
);
-- Compiler.Mapping_File_Switches
Set_Attribute_Description
(Key => PRA.Compiler.Mapping_File_Switches,
Description =>
"Index is a language name. Value is the list of switches to be used " &
"to specify a mapping file when invoking the compiler for a source " &
"of the language."
);
-- Compiler.Mapping_Spec_Suffix
Set_Attribute_Description
(Key => PRA.Compiler.Mapping_Spec_Suffix,
Description =>
"Index is a language name. Value is the suffix to be used in a " &
"mapping file to indicate that the source is a spec."
);
-- Compiler.Mapping_Body_Suffix
Set_Attribute_Description
(Key => PRA.Compiler.Mapping_Body_Suffix,
Description =>
"Index is a language name. Value is the suffix to be used in a " &
"mapping file to indicate that the source is a body."
);
-- Compiler.Config_File_Switches
Set_Attribute_Description
(Key => PRA.Compiler.Config_File_Switches,
Description =>
"Index is a language name. Value is the list of switches to specify " &
"to the compiler of the language a configuration file."
);
-- Compiler.Config_Body_File_Name
Set_Attribute_Description
(Key => PRA.Compiler.Config_Body_File_Name,
Description =>
"Index is a language name. Value is the template to be used to " &
"indicate a configuration specific to a body of the language in a " &
"configuration file."
);
-- Compiler.Config_Body_File_Name_Index
Set_Attribute_Description
(Key => PRA.Compiler.Config_Body_File_Name_Index,
Description =>
"Index is a language name. Value is the template to be used to " &
"indicate a configuration specific to the body a unit in a multi " &
"unit source of the language in a configuration file."
);
-- Compiler.Config_Body_File_Name_Pattern
Set_Attribute_Description
(Key => PRA.Compiler.Config_Body_File_Name_Pattern,
Description =>
"Index is a language name. Value is the template to be used to " &
"indicate a configuration for all bodies of the languages in a " &
"configuration file."
);
-- Compiler.Config_Spec_File_Name
Set_Attribute_Description
(Key => PRA.Compiler.Config_Spec_File_Name,
Description =>
"Index is a language name. Value is the template to be used to " &
"indicate a configuration specific to a spec of the language in a " &
"configuration file."
);
-- Compiler.Config_Spec_File_Name_Index
Set_Attribute_Description
(Key => PRA.Compiler.Config_Spec_File_Name_Index,
Description =>
"Index is a language name. Value is the template to be used to " &
"indicate a configuration specific to the spec a unit in a multi " &
"unit source of the language in a configuration file."
);
-- Compiler.Config_Spec_File_Name_Pattern
Set_Attribute_Description
(Key => PRA.Compiler.Config_Spec_File_Name_Pattern,
Description =>
"Index is a language name. Value is the template to be used to " &
"indicate a configuration for all specs of the languages in a " &
"configuration file."
);
-- Compiler.Config_File_Unique
Set_Attribute_Description
(Key => PRA.Compiler.Config_File_Unique,
Description =>
"Index is a language name. Indicates if there should be only one " &
"configuration file specified to the compiler of the language. Only " &
"authorized case-insensitive values are 'true' and 'false' (the " &
"default)."
);
-- Compiler.Dependency_Switches
Set_Attribute_Description
(Key => PRA.Compiler.Dependency_Switches,
Description =>
"Index is a language name. Value is the list of switches to be used " &
"to specify to the compiler the dependency file when the dependency " &
"kind of the language is file based, and when Dependency_Driver is " &
"not specified for the language."
);
-- Compiler.Dependency_Driver
Set_Attribute_Description
(Key => PRA.Compiler.Dependency_Driver,
Description =>
"Index is a language name. Value is the name of the executable to be" &
" used to create the dependency file for a source of the language, " &
"followed by the required switches."
);
-- Compiler.Include_Switches
Set_Attribute_Description
(Key => PRA.Compiler.Include_Switches,
Description =>
"Index is a language name. Value is the list of switches to specify " &
"to the compiler of the language to indicate a directory to look for" &
" sources."
);
-- Compiler.Include_Path
Set_Attribute_Description
(Key => PRA.Compiler.Include_Path,
Description =>
"Index is a language name. Value is the name of an environment " &
"variable that contains the path of all the directories that the " &
"compiler of the language may search for sources."
);
-- Compiler.Include_Path_File
Set_Attribute_Description
(Key => PRA.Compiler.Include_Path_File,
Description =>
"Index is a language name. Value is the name of an environment " &
"variable the value of which is the path name of a text file that " &
"contains the directories that the compiler of the language may " &
"search for sources."
);
-- Compiler.Object_Path_Switches
Set_Attribute_Description
(Key => PRA.Compiler.Object_Path_Switches,
Description =>
"Index is a language name. Value is the list of switches to specify " &
"to the compiler of the language the name of a text file that " &
"contains the list of object directories. When this attribute is not" &
" declared, the text file is not created."
);
-- Compiler.Max_Command_Line_Length
Set_Attribute_Description
(Key => PRA.Compiler.Max_Command_Line_Length,
Description =>
"Value is the maximum number of character in the command line when " &
"invoking a compiler that supports response files."
);
-- Compiler.Response_File_Format
Set_Attribute_Description
(Key => PRA.Compiler.Response_File_Format,
Description =>
"Indicates the kind of response file to create when the length of " &
"the compiling command line is too large. The index is the name of " &
"the language for the compiler. Only authorized case-insensitive " &
"values are 'none', 'gnu', 'object_list', 'gcc_gnu', " &
"'gcc_option_list' and 'gcc_object_list'."
);
-- Compiler.Response_File_Switches
Set_Attribute_Description
(Key => PRA.Compiler.Response_File_Switches,
Description =>
"Value is the list of switches to specify a response file for a " &
"compiler. The index is the name of the language for the compiler."
);
-- Gnatls.Switches
Set_Attribute_Description
(Key => PRA.Gnatls.Switches,
Description =>
"Taken into account only in the main project. Value is a list of " &
"switches to be used when invoking gnatls."
);
-- Install.Artifacts
Set_Attribute_Description
(Key => PRA.Install.Artifacts,
Description =>
"An indexed attribute to declare a set of files not part of the " &
"sources to be installed. The array index is the directory where the" &
" file is to be installed. If a relative directory then Prefix (see " &
"below) is prepended. Note also that if the same file name occurs " &
"multiple time in the attribute list, the last one will be the one " &
"installed. If an artifact is not found a warning is displayed."
);
-- Install.Required_Artifacts
Set_Attribute_Description
(Key => PRA.Install.Required_Artifacts,
Description =>
"As above, but artifacts must be present or an error is reported."
);
-- Install.Prefix
Set_Attribute_Description
(Key => PRA.Install.Prefix,
Description =>
"Value is the install destination directory. If the value is a " &
"relative path, it is taken as relative to the global prefix " &
"directory. That is, either the value passed to --prefix option or " &
"the default installation prefix."
);
-- Install.Sources_Subdir
Set_Attribute_Description
(Key => PRA.Install.Sources_Subdir,
Description =>
"Value is the sources directory or subdirectory of Prefix."
);
-- Install.Exec_Subdir
Set_Attribute_Description
(Key => PRA.Install.Exec_Subdir,
Description =>
"Value is the executables directory or subdirectory of Prefix."
);
-- Install.ALI_Subdir
Set_Attribute_Description
(Key => PRA.Install.ALI_Subdir,
Description =>
"Value is ALI directory or subdirectory of Prefix."
);
-- Install.Lib_Subdir
Set_Attribute_Description
(Key => PRA.Install.Lib_Subdir,
Description =>
"Value is library directory or subdirectory of Prefix."
);
-- Install.Project_Subdir
Set_Attribute_Description
(Key => PRA.Install.Project_Subdir,
Description =>
"Value is the project directory or subdirectory of Prefix."
);
-- Install.Active
Set_Attribute_Description
(Key => PRA.Install.Active,
Description =>
"Indicates that the project is to be installed or not. " &
"Case-insensitive value 'false' means that the project is not to be " &
"installed, all other values mean that the project is to be " &
"installed."
);
-- Install.Mode
Set_Attribute_Description
(Key => PRA.Install.Mode,
Description =>
"Value is the installation mode, it is either 'dev' (default) or " &
"'usage'."
);
-- Install.Install_Name
Set_Attribute_Description
(Key => PRA.Install.Install_Name,
Description =>
"Specify the name to use for recording the installation. The default" &
" is the project name without the extension."
);
-- Install.Side_Debug
Set_Attribute_Description
(Key => PRA.Install.Side_Debug,
Description =>
"Indicates that the project's executable and shared libraries are to" &
" be stripped of the debug symbols. Those debug symbols are written " &
"into a side file named after the original file with the '.debug' " &
"extension added. Case-insensitive value 'false' (default) disables " &
"this feature. Set it to 'true' to activate."
);
-- Install.Install_Project
Set_Attribute_Description
(Key => PRA.Install.Install_Project,
Description =>
"Indicates that a project is to be generated and installed. The " &
"value is either 'true' to 'false'. Default is 'true'."
);
-- Linker.Required_Switches
Set_Attribute_Description
(Key => PRA.Linker.Required_Switches,
Description =>
"Value is a list of switches that are required when invoking the " &
"linker to link an executable."
);
-- Linker.Default_Switches
Set_Attribute_Description
(Key => PRA.Linker.Default_Switches,
Description =>
"Index is a language name. Value is a list of switches for the " &
"linker when linking an executable for a main source of the " &
"language, when there is no applicable Switches."
);
-- Linker.Leading_Switches
Set_Attribute_Description
(Key => PRA.Linker.Leading_Switches,
Description =>
"Index is a source file name or a language name. Value is the list " &
"of switches to be used at the beginning of the command line when " &
"invoking the linker to build an executable for the source or for " &
"its language."
);
-- Linker.Switches
Set_Attribute_Description
(Key => PRA.Linker.Switches,
Description =>
"Index is a source file name or a language name. Value is the list " &
"of switches to be used when invoking the linker to build an " &
"executable for the source or for its language."
);
-- Linker.Trailing_Switches
Set_Attribute_Description
(Key => PRA.Linker.Trailing_Switches,
Description =>
"Index is a source file name or a language name. Value is the list " &
"of switches to be used at the end of the command line when invoking" &
" the linker to build an executable for the source or for its " &
"language. These switches may override the Required_Switches."
);
-- Linker.Linker_Options
Set_Attribute_Description
(Key => PRA.Linker.Linker_Options,
Description =>
"This attribute specifies a list of additional switches to be given " &
"to the linker when linking an executable. It is ignored when " &
"defined in the main project and taken into account in all other " &
"projects that are imported directly or indirectly. These switches " &
"complement the Linker'Switches defined in the main project. This is" &
" useful when a particular subsystem depends on an external library:" &
" adding this dependency as a Linker_Options in the project of the " &
"subsystem is more convenient than adding it to all the " &
"Linker'Switches of the main projects that depend upon this " &
"subsystem."
);
-- Linker. Map_File_Option
Set_Attribute_Description
(Key => PRA.Linker.Map_File_Option,
Description =>
"Value is the switch to specify the map file name that the linker " &
"needs to create."
);
-- Linker.Driver
Set_Attribute_Description
(Key => PRA.Linker.Driver,
Description =>
"Value is the name of the linker executable."
);
-- Linker.Max_Command_Line_Length
Set_Attribute_Description
(Key => PRA.Linker.Max_Command_Line_Length,
Description =>
"Value is the maximum number of character in the command line when " &
"invoking the linker to link an executable."
);
-- Linker.Response_File_Format
Set_Attribute_Description
(Key => PRA.Linker.Response_File_Format,
Description =>
"Indicates the kind of response file to create when the length of " &
"the linking command line is too large. Only authorized " &
"case-insensitive values are 'none', 'gnu', 'object_list', " &
"'gcc_gnu', 'gcc_option_list' and 'gcc_object_list'."
);
-- Linker.Response_File_Switches
Set_Attribute_Description
(Key => PRA.Linker.Response_File_Switches,
Description =>
"Value is the list of switches to specify a response file to the " &
"linker."
);
-- Naming.Specification_Suffix
Set_Attribute_Description
(Key => PRA.Naming.Specification_Suffix,
Description =>
"Equivalent to attribute Spec_Suffix."
);
-- Naming.Spec_Suffix
Set_Attribute_Description
(Key => PRA.Naming.Spec_Suffix,
Description =>
"Index is a language name. Value is the extension of file names for " &
"specs of the language."
);
-- Naming.Implementation_Suffix
Set_Attribute_Description
(Key => PRA.Naming.Implementation_Suffix,
Description =>
"Equivalent to attribute Body_Suffix."
);
-- Naming.Body_Suffix
Set_Attribute_Description
(Key => PRA.Naming.Body_Suffix,
Description =>
"Index is a language name. Value is the extension of file names for " &
"bodies of the language."
);
-- Naming.Separate_Suffix
Set_Attribute_Description
(Key => PRA.Naming.Separate_Suffix,
Description =>
"Value is the extension of file names for subunits of Ada."
);
-- Naming.Casing
Set_Attribute_Description
(Key => PRA.Naming.Casing,
Description =>
"Indicates the casing of sources of the Ada language. Only " &
"authorized case-insensitive values are 'lowercase', 'uppercase' and" &
" 'mixedcase'."
);
-- Naming.Dot_Replacement
Set_Attribute_Description
(Key => PRA.Naming.Dot_Replacement,
Description =>
"Value is the string that replace the dot of unit names in the " &
"source file names of the Ada language."
);
-- Naming.Specification
Set_Attribute_Description
(Key => PRA.Naming.Specification,
Description =>
"Equivalent to attribute Spec."
);
-- Naming.Spec
Set_Attribute_Description
(Key => PRA.Naming.Spec,
Description =>
"Index is a unit name. Value is the file name of the spec of the " &
"unit."
);
-- Naming.Implementation
Set_Attribute_Description
(Key => PRA.Naming.Implementation,
Description =>
"Equivalent to attribute Body."
);
-- Naming.Specification_Exceptions
Set_Attribute_Description
(Key => PRA.Naming.Specification_Exceptions,
Description =>
"Index is a language name. Value is a list of specs for the language" &
" that do not necessarily follow the naming scheme for the language " &
"and that may or may not be found in the source directories of the " &
"project."
);
-- Naming.Implementation_Exceptions
Set_Attribute_Description
(Key => PRA.Naming.Implementation_Exceptions,
Description =>
"Index is a language name. Value is a list of bodies for the " &
"language that do not necessarily follow the naming scheme for the " &
"language and that may or may not be found in the source directories" &
" of the project."
);
-- Naming.Body
Set_Attribute_Description
(Key => PRA.Naming.Body_N,
Description =>
"Index is a unit name. Value is the file name of the body of the unit."
);
-- Remote.Included_Patterns
Set_Attribute_Description
(Key => PRA.Remote.Included_Patterns,
Description =>
"If this attribute is defined it sets the patterns to synchronized " &
"from the master to the slaves. It is incompatible with " &
"Excluded_Patterns, that is it is an error to define both."
);
-- Remote.Included_Artifact_Patterns
Set_Attribute_Description
(Key => PRA.Remote.Included_Artifact_Patterns,
Description =>
"If this attribute is defined it sets the patterns of compilation " &
"artifacts to synchronized from the slaves to the build master. This" &
" attribute replace the default hard-coded patterns."
);
-- Remote.Excluded_Patterns
Set_Attribute_Description
(Key => PRA.Remote.Excluded_Patterns,
Description =>
"Set of patterns to ignore when synchronizing sources from the build" &
" master to the slaves. A set of predefined patterns are supported " &
"(e.g. *.o, *.ali, *.exe, etc.), this attribute makes it possible" &
" to add some more patterns."
);
-- Remote.Root_Dir
Set_Attribute_Description
(Key => PRA.Remote.Root_Dir,
Description =>
"Value is the root directory used by the slave machines."
);
end GPR2.Project.Registry.Attribute.Description;
|
stcarrez/ada-ado | Ada | 6,880 | adb | -----------------------------------------------------------------------
-- ado-schemas-postgresql -- Postgresql Database Schemas
-- Copyright (C) 2018, 2019, 2023 Stephane Carrez
-- Written by Stephane Carrez ([email protected])
--
-- Licensed under the Apache License, Version 2.0 (the "License");
-- you may not use this file except in compliance with the License.
-- You may obtain a copy of the License at
--
-- http://www.apache.org/licenses/LICENSE-2.0
--
-- Unless required by applicable law or agreed to in writing, software
-- distributed under the License is distributed on an "AS IS" BASIS,
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-- See the License for the specific language governing permissions and
-- limitations under the License.
-----------------------------------------------------------------------
with ADO.Statements;
with ADO.Statements.Create;
package body ADO.Schemas.Postgresql is
use ADO.Statements;
procedure Load_Table_Schema (C : in ADO.Connections.Database_Connection'Class;
Database : in String;
Table : in Table_Definition);
procedure Load_Table_Keys (C : in ADO.Connections.Database_Connection'Class;
Database : in String;
Table : in Table_Definition);
function String_To_Type (Value : in String) return Column_Type;
function String_To_Type (Value : in String) return Column_Type is
begin
if Value = "date" then
return T_DATE;
elsif Value = "timestamp without time zone" then
return T_DATE_TIME;
elsif Value = "timestamp with time zone" then
return T_DATE_TIME;
elsif Value = "integer" then
return T_INTEGER;
elsif Value = "smallint" then
return T_SMALLINT;
elsif Value = "bigint" then
return T_LONG_INTEGER;
elsif Value = "bytea" then
return T_BLOB;
elsif Value = "character varying" then
return T_VARCHAR;
elsif Value = "text" or else Value = "xml" or else Value = "json" then
return T_VARCHAR;
elsif Value = "double precision" then
return T_DOUBLE;
elsif Value = "real" then
return T_FLOAT;
elsif Value = "money" then
return T_DECIMAL;
elsif Value = "boolean" then
return T_BOOLEAN;
end if;
return T_UNKNOWN;
end String_To_Type;
-- ------------------------------
-- Load the table definition
-- ------------------------------
procedure Load_Table_Schema (C : in ADO.Connections.Database_Connection'Class;
Database : in String;
Table : in Table_Definition) is
Name : constant String := Get_Name (Table);
SQL : constant String
:= "SELECT column_name, column_default, data_type, is_nullable, "
& "character_maximum_length, collation_name FROM information_schema.columns "
& "WHERE table_catalog = ? AND table_name = ?";
Stmt : Query_Statement
:= Create.Create_Statement (C.Create_Statement (SQL));
Last : Column_Definition := null;
Col : Column_Definition;
Value : Unbounded_String;
begin
Stmt.Add_Param (Database);
Stmt.Add_Param (Name);
Stmt.Execute;
while Stmt.Has_Elements loop
Col := new Column;
Col.Name := Stmt.Get_Unbounded_String (0);
if not Stmt.Is_Null (5) then
Col.Collation := Stmt.Get_Unbounded_String (5);
end if;
if not Stmt.Is_Null (1) then
Col.Default := Stmt.Get_Unbounded_String (1);
end if;
if Last /= null then
Last.Next_Column := Col;
else
Table.First_Column := Col;
end if;
if not Stmt.Is_Null (4) then
Col.Size := Stmt.Get_Integer (4);
end if;
Value := Stmt.Get_Unbounded_String (2);
Col.Col_Type := String_To_Type (To_String (Value));
Value := Stmt.Get_Unbounded_String (3);
Col.Is_Null := Value = "YES";
Last := Col;
Stmt.Next;
end loop;
end Load_Table_Schema;
-- ------------------------------
-- Load the table definition
-- ------------------------------
procedure Load_Table_Keys (C : in ADO.Connections.Database_Connection'Class;
Database : in String;
Table : in Table_Definition) is
Name : constant String := Get_Name (Table);
SQL : constant String
:= "SELECT column_name FROM"
& " information_schema.table_constraints tc, "
& " information_schema.key_column_usage kc "
& "WHERE tc.constraint_type = 'PRIMARY KEY' "
& " AND kc.table_name = tc.table_name "
& " AND kc.table_schema = tc.table_schema "
& " AND kc.constraint_name = tc.constraint_name "
& " AND tc.table_catalog = ? and tc.table_name = ?";
Stmt : Query_Statement
:= Create.Create_Statement (C.Create_Statement (SQL));
Col : Column_Definition;
begin
Stmt.Add_Param (Database);
Stmt.Add_Param (Name);
Stmt.Execute;
while Stmt.Has_Elements loop
declare
Col_Name : constant String := Stmt.Get_String (0);
begin
Col := Find_Column (Table, Col_Name);
if Col /= null then
Col.Is_Primary := True;
end if;
end;
Stmt.Next;
end loop;
end Load_Table_Keys;
-- ------------------------------
-- Load the database schema
-- ------------------------------
procedure Load_Schema (C : in ADO.Connections.Database_Connection'Class;
Schema : out Schema_Definition;
Database : in String) is
SQL : constant String
:= "SELECT tablename FROM pg_catalog.pg_tables "
& "WHERE schemaname != 'pg_catalog' AND schemaname != 'information_schema'";
Stmt : Query_Statement
:= Create.Create_Statement (C.Create_Statement (SQL));
Table : Table_Definition;
Last : Table_Definition := null;
begin
Schema.Schema := new ADO.Schemas.Schema;
Stmt.Execute;
while Stmt.Has_Elements loop
Table := new ADO.Schemas.Table;
Table.Name := Stmt.Get_Unbounded_String (0);
if Last /= null then
Last.Next_Table := Table;
else
Schema.Schema.First_Table := Table;
end if;
Load_Table_Schema (C, Database, Table);
Load_Table_Keys (C, Database, Table);
Last := Table;
Stmt.Next;
end loop;
end Load_Schema;
end ADO.Schemas.Postgresql;
|
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_Draw.Color_Mode_Attributes is
------------
-- Create --
------------
overriding function Create
(Parameters : not null access Matreshka.DOM_Attributes.Attribute_L2_Parameters)
return Draw_Color_Mode_Attribute_Node is
begin
return Self : Draw_Color_Mode_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_Color_Mode_Attribute_Node)
return League.Strings.Universal_String
is
pragma Unreferenced (Self);
begin
return Matreshka.ODF_String_Constants.Color_Mode_Attribute;
end Get_Local_Name;
begin
Matreshka.DOM_Documents.Register_Attribute
(Matreshka.ODF_String_Constants.Draw_URI,
Matreshka.ODF_String_Constants.Color_Mode_Attribute,
Draw_Color_Mode_Attribute_Node'Tag);
end Matreshka.ODF_Draw.Color_Mode_Attributes;
|
aeszter/lox-spark | Ada | 1,658 | ads | with Exprs; use Exprs;
use Exprs.Visitors;
with L_Strings; use L_Strings;
package Ast_Printers is
-- Creates an unambiguous, if ugly, string representation of AST nodes.
-- SPARK implementation follows Matthew Heaney
-- http://www.adapower.com/index.php?Command=Class&ClassID=Patterns&CID=288
-- This is because in Ada, generic functions cannot be overloaded, so we
-- cannot follow Bob's implementation
type Ast_Printer is new Visitor with
record
Image : L_String := To_Bounded_String ("");
end record;
function Print (V : Ast_Printer) return String;
function Print (The_Expr : Expr'Class) return String;
overriding
procedure visit_Binary_Expr (Self : in out Ast_Printer; The_Expr : Binary) with
Global => (input => Exprs.State);
overriding
procedure visit_Grouping_Expr (Self : in out Ast_Printer; The_Expr : Grouping);
overriding
procedure visit_Float_Literal_Expr (Self : in out Ast_Printer; The_Expr : Float_Literal);
overriding
procedure visit_Num_Literal_Expr (Self : in out Ast_Printer; The_Expr : Num_Literal);
overriding
procedure visit_Str_Literal_Expr (Self : in out Ast_Printer; The_Expr : Str_Literal);
overriding
procedure visit_Unary_Expr (Self : in out Ast_Printer; The_Expr : Unary);
private
function Print (The_Expr : Binary) return String;
function Print (The_Expr : Grouping) return String;
function Print (The_Expr : Float_Literal) return String;
function Print (The_Expr : Num_Literal) return String;
function Print (The_Expr : Str_Literal) return String;
function Print (The_Expr : Unary) return String;
end Ast_Printers;
|
RREE/build-avr-ada-toolchain | Ada | 3,395 | adb | ------------------------------------------------------------------------------
-- --
-- GNAT COMPILER COMPONENTS --
-- --
-- A D A . E X C E P T I O N S --
-- --
-- B o d y --
-- --
-- Copyright (C) 1992-2011, Free Software Foundation, Inc. --
-- Copyright (C) 2012, Rolf Ebert --
-- --
-- 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.Exceptions is
procedure Reset;
pragma Import (Ada, Reset);
for Reset'Address use 0;
pragma No_Return (Reset);
procedure Default_Handler (Msg : System.Address; Line : Integer);
pragma Export (C, Default_Handler, "__gnat_last_chance_handler");
pragma Weak_External (Default_Handler);
pragma No_Return (Default_Handler);
procedure Default_Handler (Msg : System.Address; Line : Integer) is
pragma Unreferenced (Msg);
pragma Unreferenced (Line);
begin
Reset;
end Default_Handler;
procedure Last_Chance_Handler (Msg : System.Address; Line : Integer);
pragma Import (C, Last_Chance_Handler, "__gnat_last_chance_handler");
pragma No_Return (Last_Chance_Handler);
procedure Raise_Exception (E : Exception_Id; Message : String := "") is
pragma Unreferenced (E);
begin
Last_Chance_Handler (Message'Address, 0);
end Raise_Exception;
end Ada.Exceptions;
|
davidkristola/vole | Ada | 8,678 | adb | with Ada.Unchecked_Deallocation;
package body kv.avm.Messages is
type Message_Data_Type is
record
Source_Actor : kv.avm.Actor_References.Actor_Reference_Type;
Reply_To : kv.avm.Actor_References.Actor_Reference_Type;
Destination_Actor : kv.avm.Actor_References.Actor_Reference_Type;
Message_Name : kv.avm.Registers.String_Type;
Data : kv.avm.Tuples.Tuple_Type;
Future : Interfaces.Unsigned_32;
end record;
type Message_Data_Access is access Message_Data_Type;
type Reference_Counted_Message_Type is
record
Count : Natural := 0;
Data : Message_Data_Access;
end record;
-----------------------------------------------------------------------------
procedure Free is new Ada.Unchecked_Deallocation(Reference_Counted_Message_Type, Reference_Counted_Message_Access);
-----------------------------------------------------------------------------
procedure Free is new Ada.Unchecked_Deallocation(Message_Data_Type, Message_Data_Access);
-----------------------------------------------------------------------------
function Debug(Data : Message_Data_Access) return String is
begin
return "N: '" & (+Data.Message_Name) & "'" &
" S:" & Data.Source_Actor.Image &
" R:" & Data.Reply_To.Image &
" D:" & Data.Destination_Actor.Image &
" T: " & Data.Data.To_String &
" F:" & Interfaces.Unsigned_32'IMAGE(Data.Future);
end Debug;
-----------------------------------------------------------------------------
procedure Initialize
(Self : in out Message_Type) is
begin
null;
end Initialize;
----------------------------------------------------------------------------
procedure Adjust
(Self : in out Message_Type) is
begin
if Self.Ref /= null then
Self.Ref.Count := Self.Ref.Count + 1;
end if;
end Adjust;
----------------------------------------------------------------------------
procedure Finalize
(Self : in out Message_Type) is
Ref : Reference_Counted_Message_Access := Self.Ref;
begin
Self.Ref := null;
if Ref /= null then
Ref.Count := Ref.Count - 1;
if Ref.Count = 0 then
Free(Ref.Data);
Free(Ref);
end if;
end if;
end Finalize;
-----------------------------------------------------------------------------
procedure Initialize
(Self : in out Message_Type;
Source : in kv.avm.Actor_References.Actor_Reference_Type;
Reply_To : in kv.avm.Actor_References.Actor_Reference_Type;
Destination : in kv.avm.Actor_References.Actor_Reference_Type;
Message_Name : in String;
Data : in kv.avm.Tuples.Tuple_Type;
Future : in Interfaces.Unsigned_32) is
use kv.avm.Registers;
begin
Self.Ref := new Reference_Counted_Message_Type;
Self.Ref.Count := 1;
Self.Ref.Data := new Message_Data_Type;
Self.Ref.Data.Source_Actor := Source;
Self.Ref.Data.Reply_To := Reply_To;
Self.Ref.Data.Destination_Actor := Destination;
Self.Ref.Data.Message_Name := +Message_Name;
Self.Ref.Data.Data := Data;
Self.Ref.Data.Future := Future;
end Initialize;
-----------------------------------------------------------------------------
function Get_Name(Self : Message_Type) return String is
use kv.avm.Registers;
begin
return +Self.Ref.Data.Message_Name;
end Get_Name;
-----------------------------------------------------------------------------
function Get_Source(Self : Message_Type) return kv.avm.Actor_References.Actor_Reference_Type is
begin
return Self.Ref.Data.Source_Actor;
end Get_Source;
-----------------------------------------------------------------------------
function Get_Reply_To(Self : Message_Type) return kv.avm.Actor_References.Actor_Reference_Type is
begin
return Self.Ref.Data.Reply_To;
end Get_Reply_To;
-----------------------------------------------------------------------------
function Get_Destination(Self : Message_Type) return kv.avm.Actor_References.Actor_Reference_Type is
begin
return Self.Ref.Data.Destination_Actor;
end Get_Destination;
-----------------------------------------------------------------------------
function Get_Data(Self : Message_Type) return kv.avm.Tuples.Tuple_Type is
begin
return Self.Ref.Data.Data;
end Get_Data;
-----------------------------------------------------------------------------
function Get_Future(Self : Message_Type) return Interfaces.Unsigned_32 is
begin
return Self.Ref.Data.Future;
end Get_Future;
-----------------------------------------------------------------------------
function Image(Self : Message_Type) return String is
begin
return "Message<" & Self.Get_Name & ">";
end Image;
-----------------------------------------------------------------------------
function Debug(Ref : Reference_Counted_Message_Access) return String is
Count : constant String := Natural'IMAGE(Ref.Count);
begin
if Ref.Data = null then
return "null data"&Count;
else
return Debug(Ref.Data);
end if;
end Debug;
-----------------------------------------------------------------------------
function Debug(Self : Message_Type) return String is
begin
if Self.Ref = null then
return "null ref";
else
return Debug(Self.Ref);
end if;
end Debug;
-----------------------------------------------------------------------------
function Reachable(Self : Message_Type) return kv.avm.Actor_References.Sets.Set is
begin
return Self.Ref.Data.Data.Reachable;
end Reachable;
----------------------------------------------------------------------------
function "="(L, R: Message_Type) return Boolean is
begin
if L.Ref = Null or R.Ref = Null then
return False;
end if;
if L.Ref.Data = Null or R.Ref.Data = Null then
return False;
end if;
return (L.Ref.Data.all = R.Ref.Data.all);
end "=";
----------------------------------------------------------------------------
procedure Message_Write(Stream : not null access Ada.Streams.Root_Stream_Type'CLASS; Item : in Message_Type) is
begin
kv.avm.Actor_References.Actor_Reference_Type'OUTPUT(Stream, Item.Ref.Data.Source_Actor);
kv.avm.Actor_References.Actor_Reference_Type'OUTPUT(Stream, Item.Ref.Data.Reply_To);
kv.avm.Actor_References.Actor_Reference_Type'OUTPUT(Stream, Item.Ref.Data.Destination_Actor);
kv.avm.Registers.String_Type'OUTPUT (Stream, Item.Ref.Data.Message_Name);
kv.avm.Tuples.Tuple_Type'OUTPUT (Stream, Item.Ref.Data.Data);
Interfaces.Unsigned_32'OUTPUT (Stream, Item.Ref.Data.Future);
end Message_Write;
----------------------------------------------------------------------------
procedure Message_Read(Stream : not null access Ada.Streams.Root_Stream_Type'CLASS; Item : out Message_Type) is
Source : kv.avm.Actor_References.Actor_Reference_Type;
Reply_To : kv.avm.Actor_References.Actor_Reference_Type;
Destination : kv.avm.Actor_References.Actor_Reference_Type;
Message_Name : kv.avm.Registers.String_Type;
Data : kv.avm.Tuples.Tuple_Type;
Future : Interfaces.Unsigned_32;
use kv.avm.Registers;
begin
Item.Finalize; -- Clear out the old one, if there was something there.
-- Even though the parameters to a message's Initialize routine are
-- in this order, reading the values as parameters to the routine
-- resulted in an out-of-order read from the Stream.
Source := kv.avm.Actor_References.Actor_Reference_Type'INPUT(Stream);
Reply_To := kv.avm.Actor_References.Actor_Reference_Type'INPUT(Stream);
Destination := kv.avm.Actor_References.Actor_Reference_Type'INPUT(Stream);
Message_Name := kv.avm.Registers.String_Type'INPUT(Stream);
Data := kv.avm.Tuples.Tuple_Type'INPUT(Stream);
Future := Interfaces.Unsigned_32'INPUT(Stream);
Item.Initialize
(Source => Source,
Reply_To => Reply_To,
Destination => Destination,
Message_Name => +Message_Name,
Data => Data,
Future => Future);
end Message_Read;
end kv.avm.Messages;
|
sungyeon/drake | Ada | 4,427 | ads | pragma License (Unrestricted);
-- implementation unit required by compiler
with System.Storage_Elements;
package System.Tasking is
pragma Preelaborate;
-- required for local tagged types by compiler (s-taskin.ads)
subtype Master_Level is Integer;
subtype Master_ID is Master_Level;
Foreign_Task_Level : constant Master_Level := 0;
Environment_Task_Level : constant Master_Level := 1;
Independent_Task_Level : constant Master_Level := 2;
Library_Task_Level : constant Master_Level := 3;
-- required for task by compiler (s-taskin.ads)
type Task_Procedure_Access is access procedure (Params : Address);
-- required for task by compiler (s-taskin.ads)
subtype Task_Id is Address; -- same as System.Tasks.Task_Id
-- required for task by compiler (s-taskin.ads)
-- "limited" is important to force pass-by-reference for Stages.Create_Task
type Activation_Chain is limited record
Data : Address := Null_Address;
end record;
for Activation_Chain'Size use Standard'Address_Size;
-- required for built-in-place of task by compiler (s-taskin.ads)
type Activation_Chain_Access is access all Activation_Chain;
for Activation_Chain_Access'Storage_Size use 0;
pragma No_Strict_Aliasing (Activation_Chain_Access);
-- required for task by compiler (s-taskin.ads)
Unspecified_Priority : constant Integer := Priority'First - 1;
Unspecified_CPU : constant := -1;
-- required for entry of task by compiler (s-taskin.ads)
Interrupt_Entry : constant := -2;
Cancelled_Entry : constant := -1;
Null_Entry : constant := 0;
Max_Entry : constant := Integer'Last;
subtype Entry_Index is Integer range Interrupt_Entry .. Max_Entry;
subtype Task_Entry_Index is Entry_Index range Null_Entry .. Max_Entry;
-- required for select when or by compiler (s-taskin.ads)
Null_Task_Entry : constant := Null_Entry;
-- required for protected entry by compiler (s-taskin.ads)
-- compiler may crash if Call_Modes is not declared as enum
type Call_Modes is (
Simple_Call, -- 0
Conditional_Call, -- 1
Asynchronous_Call); -- 2
-- Timed_Call); -- 3
pragma Discard_Names (Call_Modes);
-- required for slective accept by compiler (s-taskin.ads)
type Select_Modes is (Simple_Mode, Else_Mode, Terminate_Mode, Delay_Mode);
pragma Discard_Names (Select_Modes);
-- required for slective accept by compiler (s-taskin.ads)
No_Rendezvous : constant := 0;
-- required for slective accept by compiler (s-taskin.ads)
subtype Select_Index is Natural;
type Accept_Alternative is record
Null_Body : Boolean;
S : Task_Entry_Index;
end record;
pragma Suppress_Initialization (Accept_Alternative);
-- required for slective accept by compiler (s-taskin.ads)
type Accept_List is array (Positive range <>) of Accept_Alternative;
pragma Suppress_Initialization (Accept_List);
-- required for abort statement by compiler (s-taskin.ads)
type Task_List is array (Positive range <>) of Task_Id;
pragma Suppress_Initialization (Task_List);
-- required for abort statement by compiler (s-taskin.ads)
function Self return Task_Id
with Import, Convention => Ada, External_Name => "__drake_current_task";
type Storage_Size_Handler is access function (T : Task_Id)
return Storage_Elements.Storage_Count;
-- System.Parameters.Size_Type ???
pragma Favor_Top_Level (Storage_Size_Handler);
pragma Suppress (Access_Check, Storage_Size_Handler);
-- required for 'Storage_Size by compiler (s-taskin.ads)
Storage_Size : Storage_Size_Handler := null;
pragma Suppress (Access_Check, Storage_Size);
-- equivalent to String_Access (s-taskin.ads)
type Entry_Name_Access is access all String;
-- dispatching domain (s-taskin.ads)
type Dispatching_Domain is
array (Positive range <>) of Boolean;
-- array (Multiprocessors.CPU range <>) of Boolean
pragma Suppress_Initialization (Dispatching_Domain);
type Dispatching_Domain_Access is access Dispatching_Domain;
-- GDB knows below names, but hard to implement.
-- type Ada_Task_Control_Block;
-- type Common_ATCB;
-- type Entry_Call_Record;
-- Debug.Known_Tasks : array (0 .. 999) of Task_Id;
-- Debug.First_Task : ???
-- procedure Restricted.Stages.Task_Wrapper (Self_ID : Task_Id);
-- type System.Task_Primitives.Private_Data;
end System.Tasking;
|
stcarrez/ada-asf | Ada | 7,944 | ads | -----------------------------------------------------------------------
-- asf-navigations -- Navigations
-- Copyright (C) 2010, 2011, 2012, 2013, 2018 Stephane Carrez
-- Written by Stephane Carrez ([email protected])
--
-- Licensed under the Apache License, Version 2.0 (the "License");
-- you may not use this file except in compliance with the License.
-- You may obtain a copy of the License at
--
-- http://www.apache.org/licenses/LICENSE-2.0
--
-- Unless required by applicable law or agreed to in writing, software
-- distributed under the License is distributed on an "AS IS" BASIS,
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-- See the License for the specific language governing permissions and
-- limitations under the License.
-----------------------------------------------------------------------
with ASF.Contexts.Faces;
with EL.Expressions;
with EL.Contexts;
with Ada.Finalization;
with ASF.Applications.Views;
with Ada.Strings.Unbounded;
private with Ada.Containers.Vectors;
private with Ada.Containers.Hashed_Maps;
private with Ada.Strings.Unbounded.Hash;
-- The <b>ASF.Navigations</b> package is responsible for calculating the view to be
-- rendered after an action is processed. The navigation handler contains some rules
-- (defined in XML files) and it uses the current view id, the action outcome and
-- the faces context to decide which view must be rendered.
--
-- See JSR 314 - JavaServer Faces Specification 7.4 NavigationHandler
package ASF.Navigations is
-- ------------------------------
-- Navigation Handler
-- ------------------------------
type Navigation_Handler is new Ada.Finalization.Limited_Controlled with private;
type Navigation_Handler_Access is access all Navigation_Handler'Class;
-- After executing an action and getting the action outcome, proceed to the navigation
-- to the next page.
procedure Handle_Navigation (Handler : in Navigation_Handler;
Action : in String;
Outcome : in String;
Context : in out ASF.Contexts.Faces.Faces_Context'Class);
-- Provide a default navigation rules for the view and the outcome when no application
-- navigation was found. The default looks for an XHTML file in the same directory as
-- the view and which has the base name defined by <b>Outcome</b>.
procedure Handle_Default_Navigation (Handler : in Navigation_Handler;
View : in String;
Outcome : in String;
Context : in out ASF.Contexts.Faces.Faces_Context'Class);
-- Initialize the the lifecycle handler.
procedure Initialize (Handler : in out Navigation_Handler;
Views : ASF.Applications.Views.View_Handler_Access);
-- Free the storage used by the navigation handler.
overriding
procedure Finalize (Handler : in out Navigation_Handler);
-- Add a navigation case to navigate from the view identifier by <b>From</b>
-- to the result view identified by <b>To</b>. Some optional conditions are evaluated
-- The <b>Outcome</b> must match unless it is empty.
-- The <b>Action</b> must match unless it is empty.
-- The <b>Condition</b> expression must evaluate to True.
procedure Add_Navigation_Case (Handler : in out Navigation_Handler;
From : in String;
To : in String;
Outcome : in String := "";
Action : in String := "";
Condition : in String := "";
Context : in EL.Contexts.ELContext'Class);
-- ------------------------------
-- Navigation Case
-- ------------------------------
-- The <b>Navigation_Case</b> contains a condition and a navigation action.
-- The condition must be matched to execute the navigation action.
type Navigation_Case is abstract tagged limited private;
type Navigation_Access is access all Navigation_Case'Class;
-- Check if the navigator specific condition matches the current execution context.
function Matches (Navigator : in Navigation_Case;
Action : in String;
Outcome : in String;
Context : in ASF.Contexts.Faces.Faces_Context'Class) return Boolean;
-- Navigate to the next page or action according to the controller's navigator.
-- A navigator controller could redirect the user to another page, render a specific
-- view or return some raw content.
procedure Navigate (Navigator : in Navigation_Case;
Context : in out ASF.Contexts.Faces.Faces_Context'Class) is abstract;
-- Add a navigation case to navigate from the view identifier by <b>From</b>
-- by using the navigation rule defined by <b>Navigator</b>.
-- Some optional conditions are evaluated:
-- The <b>Outcome</b> must match unless it is empty.
-- The <b>Action</b> must match unless it is empty.
-- The <b>Condition</b> expression must evaluate to True.
procedure Add_Navigation_Case (Handler : in out Navigation_Handler'Class;
Navigator : in Navigation_Access;
From : in String;
Outcome : in String := "";
Action : in String := "";
Condition : in String := "";
Context : in EL.Contexts.ELContext'Class);
private
use Ada.Strings.Unbounded;
type Navigation_Case is abstract tagged limited record
-- When not empty, the condition that must be verified to follow this navigator.
Condition : EL.Expressions.Expression;
View_Handler : access ASF.Applications.Views.View_Handler'Class;
Outcome : String_Access;
Action : String_Access;
end record;
package Navigator_Vector is new Ada.Containers.Vectors (Index_Type => Natural,
Element_Type => Navigation_Access);
-- ------------------------------
-- Navigation Rule
-- ------------------------------
type Rule is tagged limited record
Navigators : Navigator_Vector.Vector;
end record;
-- Clear the navigation rules.
procedure Clear (Controller : in out Rule);
-- Search for the navigator that matches the current action, outcome and context.
-- Returns the navigator or null if there was no match.
function Find_Navigation (Controller : in Rule;
Action : in String;
Outcome : in String;
Context : in Contexts.Faces.Faces_Context'Class)
return Navigation_Access;
type Rule_Access is access all Rule'Class;
package Rule_Map is new Ada.Containers.Hashed_Maps (Key_Type => Unbounded_String,
Element_Type => Rule_Access,
Hash => Hash,
Equivalent_Keys => "=");
type Navigation_Rules is limited record
-- Exact match rules
Rules : Rule_Map.Map;
end record;
-- Clear the navigation rules.
procedure Clear (Controller : in out Navigation_Rules);
type Navigation_Rules_Access is access all Navigation_Rules;
type Navigation_Handler is new Ada.Finalization.Limited_Controlled with record
Rules : Navigation_Rules_Access;
View_Handler : access ASF.Applications.Views.View_Handler'Class;
end record;
end ASF.Navigations;
|
Rodeo-McCabe/orka | Ada | 1,416 | adb | -- 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 Ada.Text_IO;
with GL.Types;
with Orka.Types;
procedure Orka_Test.Test_7_Half is
use type GL.Types.Single;
Numbers : constant GL.Types.Single_Array
:= (0.0, 0.5, -0.5, 1.0, -1.0, 0.1, -0.1, 0.0, 0.1234, -0.123456,
10.1234, 20.1234, 50.1234, 100.1234, 1000.1234);
Half_Numbers : constant GL.Types.Half_Array := Orka.Types.Convert (Numbers);
Single_Numbers : constant GL.Types.Single_Array := Orka.Types.Convert (Half_Numbers);
begin
for Number of Numbers loop
Ada.Text_IO.Put_Line (GL.Types.Single'Image (Number));
end loop;
Ada.Text_IO.Put_Line ("------------");
for Number of Single_Numbers loop
Ada.Text_IO.Put_Line (GL.Types.Single'Image (Number));
end loop;
end Orka_Test.Test_7_Half;
|
AdaCore/Ada_Drivers_Library | Ada | 9,679 | 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.PPI is
pragma Preelaborate;
---------------
-- Registers --
---------------
-----------------------------------
-- TASKS_CHG cluster's Registers --
-----------------------------------
-- Channel group tasks
type TASKS_CHG_Cluster is record
-- Description cluster[0]: Enable channel group 0
EN : aliased HAL.UInt32;
-- Description cluster[0]: Disable channel group 0
DIS : aliased HAL.UInt32;
end record
with Size => 64;
for TASKS_CHG_Cluster use record
EN at 16#0# range 0 .. 31;
DIS at 16#4# range 0 .. 31;
end record;
-- Channel group tasks
type TASKS_CHG_Clusters is array (0 .. 5) of TASKS_CHG_Cluster;
-- Enable or disable channel 0
type CHEN_CH0_Field is
(-- Disable channel
Disabled,
-- Enable channel
Enabled)
with Size => 1;
for CHEN_CH0_Field use
(Disabled => 0,
Enabled => 1);
-- CHEN_CH array
type CHEN_CH_Field_Array is array (0 .. 31) of CHEN_CH0_Field
with Component_Size => 1, Size => 32;
-- Channel enable register
type CHEN_Register
(As_Array : Boolean := False)
is record
case As_Array is
when False =>
-- CH as a value
Val : HAL.UInt32;
when True =>
-- CH as an array
Arr : CHEN_CH_Field_Array;
end case;
end record
with Unchecked_Union, Size => 32, Volatile_Full_Access, Object_Size => 32,
Bit_Order => System.Low_Order_First;
for CHEN_Register use record
Val at 0 range 0 .. 31;
Arr at 0 range 0 .. 31;
end record;
-- Channel 0 enable set register. Writing '0' has no effect
type CHENSET_CH0_Field is
(-- Read: channel disabled
Disabled,
-- Read: channel enabled
Enabled)
with Size => 1;
for CHENSET_CH0_Field use
(Disabled => 0,
Enabled => 1);
-- Channel 0 enable set register. Writing '0' has no effect
type CHENSET_CH0_Field_1 is
(-- Reset value for the field
Chenset_Ch0_Field_Reset,
-- Write: Enable channel
Set)
with Size => 1;
for CHENSET_CH0_Field_1 use
(Chenset_Ch0_Field_Reset => 0,
Set => 1);
-- CHENSET_CH array
type CHENSET_CH_Field_Array is array (0 .. 31) of CHENSET_CH0_Field_1
with Component_Size => 1, Size => 32;
-- Channel enable set register
type CHENSET_Register
(As_Array : Boolean := False)
is record
case As_Array is
when False =>
-- CH as a value
Val : HAL.UInt32;
when True =>
-- CH as an array
Arr : CHENSET_CH_Field_Array;
end case;
end record
with Unchecked_Union, Size => 32, Volatile_Full_Access, Object_Size => 32,
Bit_Order => System.Low_Order_First;
for CHENSET_Register use record
Val at 0 range 0 .. 31;
Arr at 0 range 0 .. 31;
end record;
-- Channel 0 enable clear register. Writing '0' has no effect
type CHENCLR_CH0_Field is
(-- Read: channel disabled
Disabled,
-- Read: channel enabled
Enabled)
with Size => 1;
for CHENCLR_CH0_Field use
(Disabled => 0,
Enabled => 1);
-- Channel 0 enable clear register. Writing '0' has no effect
type CHENCLR_CH0_Field_1 is
(-- Reset value for the field
Chenclr_Ch0_Field_Reset,
-- Write: disable channel
Clear)
with Size => 1;
for CHENCLR_CH0_Field_1 use
(Chenclr_Ch0_Field_Reset => 0,
Clear => 1);
-- CHENCLR_CH array
type CHENCLR_CH_Field_Array is array (0 .. 31) of CHENCLR_CH0_Field_1
with Component_Size => 1, Size => 32;
-- Channel enable clear register
type CHENCLR_Register
(As_Array : Boolean := False)
is record
case As_Array is
when False =>
-- CH as a value
Val : HAL.UInt32;
when True =>
-- CH as an array
Arr : CHENCLR_CH_Field_Array;
end case;
end record
with Unchecked_Union, Size => 32, Volatile_Full_Access, Object_Size => 32,
Bit_Order => System.Low_Order_First;
for CHENCLR_Register use record
Val at 0 range 0 .. 31;
Arr at 0 range 0 .. 31;
end record;
----------------------------
-- CH cluster's Registers --
----------------------------
-- PPI Channel
type CH_Cluster is record
-- Description cluster[0]: Channel 0 event end-point
EEP : aliased HAL.UInt32;
-- Description cluster[0]: Channel 0 task end-point
TEP : aliased HAL.UInt32;
end record
with Size => 64;
for CH_Cluster use record
EEP at 16#0# range 0 .. 31;
TEP at 16#4# range 0 .. 31;
end record;
-- PPI Channel
type CH_Clusters is array (0 .. 19) of CH_Cluster;
-- Include or exclude channel 0
type CHG_CH0_Field is
(-- Exclude
Excluded,
-- Include
Included)
with Size => 1;
for CHG_CH0_Field use
(Excluded => 0,
Included => 1);
-- CHG_CH array
type CHG_CH_Field_Array is array (0 .. 31) of CHG_CH0_Field
with Component_Size => 1, Size => 32;
-- Description collection[0]: Channel group 0
type CHG_Register
(As_Array : Boolean := False)
is record
case As_Array is
when False =>
-- CH as a value
Val : HAL.UInt32;
when True =>
-- CH as an array
Arr : CHG_CH_Field_Array;
end case;
end record
with Unchecked_Union, Size => 32, Volatile_Full_Access, Object_Size => 32,
Bit_Order => System.Low_Order_First;
for CHG_Register use record
Val at 0 range 0 .. 31;
Arr at 0 range 0 .. 31;
end record;
-- Description collection[0]: Channel group 0
type CHG_Registers is array (0 .. 5) of CHG_Register;
------------------------------
-- FORK cluster's Registers --
------------------------------
-- Fork
type FORK_Cluster is record
-- Description cluster[0]: Channel 0 task end-point
TEP : aliased HAL.UInt32;
end record
with Size => 32;
for FORK_Cluster use record
TEP at 0 range 0 .. 31;
end record;
-- Fork
type FORK_Clusters is array (0 .. 31) of FORK_Cluster;
-----------------
-- Peripherals --
-----------------
-- Programmable Peripheral Interconnect
type PPI_Peripheral is record
-- Channel group tasks
TASKS_CHG : aliased TASKS_CHG_Clusters;
-- Channel enable register
CHEN : aliased CHEN_Register;
-- Channel enable set register
CHENSET : aliased CHENSET_Register;
-- Channel enable clear register
CHENCLR : aliased CHENCLR_Register;
-- PPI Channel
CH : aliased CH_Clusters;
-- Description collection[0]: Channel group 0
CHG : aliased CHG_Registers;
-- Fork
FORK : aliased FORK_Clusters;
end record
with Volatile;
for PPI_Peripheral use record
TASKS_CHG at 16#0# range 0 .. 383;
CHEN at 16#500# range 0 .. 31;
CHENSET at 16#504# range 0 .. 31;
CHENCLR at 16#508# range 0 .. 31;
CH at 16#510# range 0 .. 1279;
CHG at 16#800# range 0 .. 191;
FORK at 16#910# range 0 .. 1023;
end record;
-- Programmable Peripheral Interconnect
PPI_Periph : aliased PPI_Peripheral
with Import, Address => PPI_Base;
end NRF_SVD.PPI;
|
dbanetto/uni | Ada | 1,076 | adb | package body Vehicle with SPARK_Mode is
function Initialize(capacity : FuelUnit; current : FuelUnit) return Tank is
t : Tank := ( capacity => capacity,
current => current);
begin
return t;
end;
------------
-- IsFull --
------------
function IsFull (this : Tank) return Boolean is
begin
return this.current = this.capacity;
end IsFull;
----------
-- Fill --
----------
procedure Fill
(this : in out Tank; amount : in out FuelUnit)
is
begin
-- only store the amount of the fuel that can fit
if amount + this.current > this.capacity then
-- store how much is actually put into the tank
amount := this.capacity - this.current;
this.current := this.capacity;
else
-- fill up the tank
this.current := amount + this.current;
end if;
end Fill;
function GetCurrent (this : in Tank) return FuelUnit is (this.current);
function GetCapacity (this : in Tank) return FuelUnit is (this.capacity);
end Vehicle;
|
erik/ada-irc | Ada | 734 | adb | with Irc.Bot;
with Irc.Commands;
with Irc.Message;
with Ada.Strings.Unbounded;
with GNAT.Sockets;
-- for host_bot.adb
package Host_Command is
procedure Host (Bot : in out Irc.Bot.Connection;
Msg : Irc.Message.Message);
end Host_Command;
package body Host_Command is
procedure Host (Bot : in out Irc.Bot.Connection;
Msg : Irc.Message.Message) is
Host : String := GNAT.Sockets.Host_Name;
Target : String := Ada.Strings.Unbounded.To_String
(Msg.Privmsg.Target);
begin
-- Send back our host name to whichever nick/channel
-- triggered the callback
Bot.Privmsg (Target, "I am running on " & Host);
end Host;
end Host_Command;
|
reznikmm/matreshka | Ada | 4,550 | 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_Svg.Name_Attributes is
------------
-- Create --
------------
overriding function Create
(Parameters : not null access Matreshka.DOM_Attributes.Attribute_L2_Parameters)
return Svg_Name_Attribute_Node is
begin
return Self : Svg_Name_Attribute_Node do
Matreshka.ODF_Svg.Constructors.Initialize
(Self'Unchecked_Access,
Parameters.Document,
Matreshka.ODF_String_Constants.Svg_Prefix);
end return;
end Create;
--------------------
-- Get_Local_Name --
--------------------
overriding function Get_Local_Name
(Self : not null access constant Svg_Name_Attribute_Node)
return League.Strings.Universal_String
is
pragma Unreferenced (Self);
begin
return Matreshka.ODF_String_Constants.Name_Attribute;
end Get_Local_Name;
begin
Matreshka.DOM_Documents.Register_Attribute
(Matreshka.ODF_String_Constants.Svg_URI,
Matreshka.ODF_String_Constants.Name_Attribute,
Svg_Name_Attribute_Node'Tag);
end Matreshka.ODF_Svg.Name_Attributes;
|
stcarrez/ada-asf | Ada | 1,350 | ads | -----------------------------------------------------------------------
-- asf-models-selects-tests - Unit tests for UI select model
-- Copyright (C) 2011 Stephane Carrez
-- Written by Stephane Carrez ([email protected])
--
-- Licensed under the Apache License, Version 2.0 (the "License");
-- you may not use this file except in compliance with the License.
-- You may obtain a copy of the License at
--
-- http://www.apache.org/licenses/LICENSE-2.0
--
-- Unless required by applicable law or agreed to in writing, software
-- distributed under the License is distributed on an "AS IS" BASIS,
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-- See the License for the specific language governing permissions and
-- limitations under the License.
-----------------------------------------------------------------------
with Util.Tests;
package ASF.Models.Selects.Tests is
procedure Add_Tests (Suite : in Util.Tests.Access_Test_Suite);
type Test is new Util.Tests.Test with null record;
-- Test creation of Select_Item
procedure Test_Select_Item (T : in out Test);
-- Test To_Object and To_Select_Item
procedure Test_To_Object (T : in out Test);
-- Test creation of Select_Item_List
procedure Test_Select_Item_List (T : in out Test);
end ASF.Models.Selects.Tests;
|
AdaCore/training_material | Ada | 363 | adb | with Tasks; use Tasks;
with Protected_Objects; use Protected_Objects;
procedure Test_Protected_Objects is
begin
O1.Initialize ('X');
O2.Initialize ('Y');
T1.Start ('A', 1, 2);
T2.Start ('B', 1_000, 2_000);
T1.Receive_Message (1, 2);
T2.Receive_Message (10, 20);
-- Ugly...
abort T1;
abort T2;
end Test_Protected_Objects;
|
reznikmm/markdown | Ada | 4,995 | ads | -- SPDX-FileCopyrightText: 2020 Max Reznik <[email protected]>
--
-- SPDX-License-Identifier: MIT
----------------------------------------------------------------
with Ada.Containers.Vectors;
with League.Strings;
with League.String_Vectors;
with Markdown.Link_Registers;
package Markdown.Inline_Parsers is
type Annotation_Kind is
(Soft_Line_Break, Emphasis, Strong, Link, Code_Span,
Open_HTML_Tag, Close_HTML_Tag, HTML_Comment,
HTML_Processing_Instruction, HTML_Declaration, HTML_CDATA);
type HTML_Attribute is record
Name : League.Strings.Universal_String;
Value : League.String_Vectors.Universal_String_Vector;
-- An empty vector means no value for the attribute
end record;
package Attr_Vectors is new Ada.Containers.Vectors
(Positive, HTML_Attribute);
type Annotation (Kind : Annotation_Kind := Annotation_Kind'First) is record
From : Positive;
To : Natural;
case Kind is
when Emphasis | Strong | Link =>
case Kind is
when Link =>
Destination : League.Strings.Universal_String;
Title : League.String_Vectors.Universal_String_Vector;
when others =>
null;
end case;
when Soft_Line_Break | Code_Span =>
null;
when Open_HTML_Tag | Close_HTML_Tag =>
Tag : League.Strings.Universal_String;
case Kind is
when Open_HTML_Tag =>
Attr : Attr_Vectors.Vector;
Is_Empty : Boolean;
when others =>
null;
end case;
when HTML_Comment =>
HTML_Comment : League.String_Vectors.Universal_String_Vector;
when HTML_Processing_Instruction =>
HTML_PI : League.String_Vectors.Universal_String_Vector;
when HTML_Declaration =>
HTML_Decl : League.String_Vectors.Universal_String_Vector;
when HTML_CDATA =>
HTML_CDATA : League.String_Vectors.Universal_String_Vector;
end case;
end record;
package Annotation_Vectors is new
Ada.Containers.Vectors (Positive, Annotation);
type Annotated_Text is record
Plain_Text : League.Strings.Universal_String;
Annotation : Annotation_Vectors.Vector;
end record;
function Parse
(Register : Markdown.Link_Registers.Link_Register'Class;
Lines : League.String_Vectors.Universal_String_Vector)
return Annotated_Text;
private
type Position is record
Line : Positive;
Column : Natural;
end record;
function "+" (Cursor : Position; Value : Integer) return Position is
((Cursor.Line, Cursor.Column + Value));
function "<" (Left, Right : Position) return Boolean is
(Left.Line < Right.Line or
(Left.Line = Right.Line and Left.Column < Right.Column));
function "<=" (Left, Right : Position) return Boolean is
(Left < Right or Left = Right);
function ">" (Left, Right : Position) return Boolean is
(Left.Line > Right.Line or
(Left.Line = Right.Line and Left.Column > Right.Column));
package Plain_Texts is
type Plain_Text is tagged limited private;
procedure Initialize
(Self : in out Plain_Text'Class;
Text : League.String_Vectors.Universal_String_Vector;
From : Position := (1, 1);
To : Position := (Positive'Last, Positive'Last));
procedure Initialize
(Self : in out Plain_Text'Class;
Text : Plain_Text'Class;
From : Position;
To : Position := (Positive'Last, Positive'Last));
function First (Self : Plain_Text'Class) return Position;
function Last (Self : Plain_Text'Class) return Position;
function Line
(Self : Plain_Text'Class;
From : Position) return League.Strings.Universal_String;
function Line
(Self : Plain_Text'Class;
Index : Positive) return League.Strings.Universal_String;
function Lines (Self : Plain_Text'Class) return Positive;
pragma Unreferenced (Lines);
procedure Step
(Self : Plain_Text'Class;
Value : Natural;
Cursor : in out Position);
function Join
(Self : Plain_Text'Class;
From : Position;
Char : Wide_Wide_Character) return League.Strings.Universal_String;
private
type Plain_Text is tagged limited record
Data : League.String_Vectors.Universal_String_Vector;
From : Position;
To : Position;
end record;
end Plain_Texts;
type Inline_Span is record
From : Position;
To : Position;
end record;
type Optional_Inline_State (Is_Set : Boolean := False) is record
case Is_Set is
when True =>
Span : Inline_Span;
Value : Annotated_Text;
when False =>
null;
end case;
end record;
end Markdown.Inline_Parsers;
|
sparre/Command-Line-Parser-Generator | Ada | 651 | adb | -- Copyright: JSA Research & Innovation <[email protected]>
-- License: Beer Ware
pragma License (Unrestricted);
package body Command_Line_Parser_Generator.Identifier_Matrix is
procedure Append (Container : in out Instance;
Key : in Source_Text;
Value : in Source_Text) is
begin
if Container.Contains (Key) then
Container.Reference (Key).Append (Value);
else
Container.Insert (Key => Key,
New_Item => Identifier_Set.To_Set (Value));
end if;
end Append;
end Command_Line_Parser_Generator.Identifier_Matrix;
|
io7m/coreland-symbex | Ada | 55 | ads | package Symbex is
pragma Pure (Symbex);
end Symbex;
|
Rodeo-McCabe/orka | Ada | 1,030 | 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 Ahven.Framework;
package Test_SIMD_AVX_Math is
type Test is new Ahven.Framework.Test_Case with null record;
overriding
procedure Initialize (T : in out Test);
private
procedure Test_Min;
procedure Test_Max;
procedure Test_Nearest_Integer;
procedure Test_Floor;
procedure Test_Ceil;
procedure Test_Truncate;
end Test_SIMD_AVX_Math;
|
zhmu/ananas | Ada | 3,895 | ads | ------------------------------------------------------------------------------
-- --
-- GNAT RUN-TIME COMPONENTS --
-- --
-- S Y S T E M . P A C K _ 2 2 --
-- --
-- S p e c --
-- --
-- Copyright (C) 1992-2022, Free Software Foundation, Inc. --
-- --
-- GNAT is free software; you can redistribute it and/or modify it under --
-- terms of the GNU General Public License as published by the Free Soft- --
-- ware Foundation; either version 3, or (at your option) any later ver- --
-- sion. GNAT is distributed in the hope that it will be useful, but WITH- --
-- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY --
-- or FITNESS FOR A PARTICULAR PURPOSE. --
-- --
-- As a special exception under Section 7 of GPL version 3, you are granted --
-- additional permissions described in the GCC Runtime Library Exception, --
-- version 3.1, as published by the Free Software Foundation. --
-- --
-- You should have received a copy of the GNU General Public License and --
-- a copy of the GCC Runtime Library Exception along with this program; --
-- see the files COPYING3 and COPYING.RUNTIME respectively. If not, see --
-- <http://www.gnu.org/licenses/>. --
-- --
-- GNAT was originally developed by the GNAT team at New York University. --
-- Extensive contributions were provided by Ada Core Technologies Inc. --
-- --
------------------------------------------------------------------------------
-- Handling of packed arrays with Component_Size = 22
package System.Pack_22 is
pragma Preelaborate;
Bits : constant := 22;
type Bits_22 is mod 2 ** Bits;
for Bits_22'Size use Bits;
-- In all subprograms below, Rev_SSO is set True if the array has the
-- non-default scalar storage order.
function Get_22
(Arr : System.Address;
N : Natural;
Rev_SSO : Boolean) return Bits_22 with Inline;
-- Arr is the address of the packed array, N is the zero-based
-- subscript. This element is extracted and returned.
procedure Set_22
(Arr : System.Address;
N : Natural;
E : Bits_22;
Rev_SSO : Boolean) with Inline;
-- Arr is the address of the packed array, N is the zero-based
-- subscript. This element is set to the given value.
function GetU_22
(Arr : System.Address;
N : Natural;
Rev_SSO : Boolean) return Bits_22 with Inline;
-- Arr is the address of the packed array, N is the zero-based
-- subscript. This element is extracted and returned. This version
-- is used when Arr may represent an unaligned address.
procedure SetU_22
(Arr : System.Address;
N : Natural;
E : Bits_22;
Rev_SSO : Boolean) with Inline;
-- Arr is the address of the packed array, N is the zero-based
-- subscript. This element is set to the given value. This version
-- is used when Arr may represent an unaligned address
end System.Pack_22;
|
reznikmm/matreshka | Ada | 4,365 | ads | ------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- Ada Modeling Framework --
-- --
-- Runtime Library Component --
-- --
------------------------------------------------------------------------------
-- --
-- Copyright © 2012, Vadim Godunko <[email protected]> --
-- All rights reserved. --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions --
-- are met: --
-- --
-- * Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- --
-- * Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in the --
-- documentation and/or other materials provided with the distribution. --
-- --
-- * Neither the name of the Vadim Godunko, IE nor the names of its --
-- contributors may be used to endorse or promote products derived from --
-- this software without specific prior written permission. --
-- --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR --
-- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
-- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED --
-- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR --
-- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF --
-- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING --
-- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS --
-- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
-- --
------------------------------------------------------------------------------
-- $Revision$ $Date$
------------------------------------------------------------------------------
-- This package provides two-stage table to manage storage for model elements.
------------------------------------------------------------------------------
generic
type Element_Type is private;
package AMF.Internals.Generic_Element_Table is
pragma Preelaborate;
type Element_Access is access all Element_Type;
procedure Initialize (Metamodel : AMF_Metamodel);
function Table (Element : AMF_Element) return Element_Access;
pragma Inline (Table);
function Last return AMF_Element;
pragma Inline (Last);
procedure Increment_Last;
function Allocate return AMF_Element;
pragma Inline (Allocate);
private
type Element_Index is mod 2 ** 12;
type Segment_Index is mod 2 ** 12;
type Segment_Array is array (Element_Index) of aliased Element_Type;
type Segment_Access is access all Segment_Array;
Module_Component : AMF_Element;
Segments : array (Segment_Index) of Segment_Access;
Last_Element : AMF_Element;
end AMF.Internals.Generic_Element_Table;
|
zhmu/ananas | Ada | 156 | adb | package body Opt23_Pkg is
function Get (R : Rec; I : Positive; M : Natural) return Path is
begin
return R.Val (I) (M);
end;
end Opt23_Pkg;
|
albertklee/AdaFractalCPP | Ada | 2,518 | ads | pragma Ada_2012;
pragma Style_Checks (Off);
with Interfaces.C; use Interfaces.C;
with Interfaces.C.Strings;
with System;
with Interfaces.C.Extensions;
package Uri_Router_Hh is
package Class_Capture_Groups is
type Capture_Groups is limited record
null;
end record
with Import => True,
Convention => CPP;
function New_Capture_Groups return Capture_Groups; -- uri_router.hh:10
pragma CPP_Constructor (New_Capture_Groups, "_ZN14capture_groupsC1Ev");
function Size (This : access Capture_Groups) return Int -- uri_router.hh:11
with Import => True,
Convention => CPP,
External_Name => "_ZN14capture_groups4sizeEv";
function Get_Match (This : access Capture_Groups; Index : Int) return Interfaces.C.Strings.Chars_Ptr -- uri_router.hh:12
with Import => True,
Convention => CPP,
External_Name => "_ZN14capture_groups9get_matchEi";
end;
use Class_Capture_Groups;
type Callback_Function is access procedure (Arg1 : access Capture_Groups; Arg2 : System.Address)
with Convention => C; -- uri_router.hh:20
type Default_Callback is access procedure (Arg1 : Interfaces.C.Strings.Chars_Ptr; Arg2 : System.Address)
with Convention => C; -- uri_router.hh:22
package Class_Uri_Router is
type Uri_Router is limited record
null;
end record
with Import => True,
Convention => CPP;
function New_Uri_Router return Uri_Router; -- uri_router.hh:34
pragma CPP_Constructor (New_Uri_Router, "_ZN10uri_routerC1Ev");
procedure Register_Path
(This : access Uri_Router;
Rgx_Str : Interfaces.C.Strings.Chars_Ptr;
Cb : Callback_Function) -- uri_router.hh:36
with Import => True,
Convention => CPP,
External_Name => "_ZN10uri_router13register_pathEPKcPFvP14capture_groupsPvE";
procedure Register_Default (This : access Uri_Router; Cb : Default_Callback) -- uri_router.hh:37
with Import => True,
Convention => CPP,
External_Name => "_ZN10uri_router16register_defaultEPFvPKcPvE";
function Match_Path
(This : access Uri_Router;
Path : Interfaces.C.Strings.Chars_Ptr;
Response : System.Address) return Extensions.Bool -- uri_router.hh:38
with Import => True,
Convention => CPP,
External_Name => "_ZN10uri_router10match_pathEPKcPv";
end;
use Class_Uri_Router;
end Uri_Router_Hh;
|
zhmu/ananas | Ada | 24,512 | ads | ------------------------------------------------------------------------------
-- --
-- GNAT LIBRARY COMPONENTS --
-- --
-- ADA.CONTAINERS.INDEFINITE_ORDERED_MULTISETS --
-- --
-- S p e c --
-- --
-- Copyright (C) 2004-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/>. --
-- --
-- This unit was originally developed by Matthew J Heaney. --
------------------------------------------------------------------------------
-- The indefinite ordered multiset container is similar to the indefinite
-- ordered set, but with the difference that multiple equivalent elements are
-- allowed. It also provides additional operations, to iterate over items that
-- are equivalent.
private with Ada.Containers.Red_Black_Trees;
private with Ada.Finalization;
private with Ada.Streams;
private with Ada.Strings.Text_Buffers;
with Ada.Iterator_Interfaces;
generic
type Element_Type (<>) is private;
with function "<" (Left, Right : Element_Type) return Boolean is <>;
with function "=" (Left, Right : Element_Type) return Boolean is <>;
package Ada.Containers.Indefinite_Ordered_Multisets with
SPARK_Mode => Off
is
pragma Annotate (CodePeer, Skip_Analysis);
pragma Preelaborate;
pragma Remote_Types;
function Equivalent_Elements (Left, Right : Element_Type) return Boolean;
-- Returns False if Left is less than Right, or Right is less than Left;
-- otherwise, it returns True.
type Set is tagged private
with Constant_Indexing => Constant_Reference,
Default_Iterator => Iterate,
Iterator_Element => Element_Type;
pragma Preelaborable_Initialization (Set);
type Cursor is private;
pragma Preelaborable_Initialization (Cursor);
Empty_Set : constant Set;
-- The default value for set objects declared without an explicit
-- initialization expression.
No_Element : constant Cursor;
-- The default value for cursor objects declared without an explicit
-- initialization expression.
function Has_Element (Position : Cursor) return Boolean;
-- Equivalent to Position /= No_Element
package Set_Iterator_Interfaces is new
Ada.Iterator_Interfaces (Cursor, Has_Element);
function "=" (Left, Right : Set) return Boolean;
-- If Left denotes the same set object as Right, then equality returns
-- True. If the length of Left is different from the length of Right, then
-- it returns False. Otherwise, set equality iterates over Left and Right,
-- comparing the element of Left to the element of Right using the equality
-- operator for elements. If the elements compare False, then the iteration
-- terminates and set equality returns False. Otherwise, if all elements
-- compare True, then set equality returns True.
function Equivalent_Sets (Left, Right : Set) return Boolean;
-- Similar to set equality, but with the difference that elements are
-- compared for equivalence instead of equality.
function To_Set (New_Item : Element_Type) return Set;
-- Constructs a set object with New_Item as its single element
function Length (Container : Set) return Count_Type;
-- Returns the total number of elements in Container
function Is_Empty (Container : Set) return Boolean;
-- Returns True if Container.Length is 0
procedure Clear (Container : in out Set);
-- Deletes all elements from Container
function Element (Position : Cursor) return Element_Type;
-- If Position equals No_Element, then Constraint_Error is raised.
-- Otherwise, function Element returns the element designed by Position.
procedure Replace_Element
(Container : in out Set;
Position : Cursor;
New_Item : Element_Type);
-- If Position equals No_Element, then Constraint_Error is raised. If
-- Position is associated with a set different from Container, then
-- Program_Error is raised. If New_Item is equivalent to the element
-- designated by Position, then if Container is locked (element tampering
-- has been attempted), Program_Error is raised; otherwise, the element
-- designated by Position is assigned the value of New_Item. If New_Item is
-- not equivalent to the element designated by Position, then if the
-- container is busy (cursor tampering has been attempted), Program_Error
-- is raised; otherwise, the element designed by Position is assigned the
-- value of New_Item, and the node is moved to its new position (in
-- canonical insertion order).
procedure Query_Element
(Position : Cursor;
Process : not null access procedure (Element : Element_Type));
-- If Position equals No_Element, then Constraint_Error is
-- raised. Otherwise, it calls Process with the element designated by
-- Position as the parameter. This call locks the container, so attempts to
-- change the value of the element while Process is executing (to "tamper
-- with elements") will raise Program_Error.
type Constant_Reference_Type
(Element : not null access constant Element_Type) is private
with Implicit_Dereference => Element;
function Constant_Reference
(Container : aliased Set;
Position : Cursor) return Constant_Reference_Type;
pragma Inline (Constant_Reference);
procedure Assign (Target : in out Set; Source : Set);
function Copy (Source : Set) return Set;
procedure Move (Target : in out Set; Source : in out Set);
-- If Target denotes the same object as Source, the operation does
-- nothing. If either Target or Source is busy (cursor tampering is
-- attempted), then it raises Program_Error. Otherwise, Target is cleared,
-- and the nodes from Source are moved (not copied) to Target (so Source
-- becomes empty).
procedure Insert
(Container : in out Set;
New_Item : Element_Type;
Position : out Cursor);
-- Insert adds New_Item to Container, and returns cursor Position
-- designating the newly inserted node. The node is inserted after any
-- existing elements less than or equivalent to New_Item (and before any
-- elements greater than New_Item). Note that the issue of where the new
-- node is inserted relative to equivalent elements does not arise for
-- unique-key containers, since in that case the insertion would simply
-- fail. For a multiple-key container (the case here), insertion always
-- succeeds, and is defined such that the new item is positioned after any
-- equivalent elements already in the container.
procedure Insert (Container : in out Set; New_Item : Element_Type);
-- Inserts New_Item in Container, but does not return a cursor designating
-- the newly-inserted node.
-- TODO: include Replace too???
--
-- procedure Replace
-- (Container : in out Set;
-- New_Item : Element_Type);
procedure Exclude (Container : in out Set; Item : Element_Type);
-- Deletes from Container all of the elements equivalent to Item
procedure Delete (Container : in out Set; Item : Element_Type);
-- Deletes from Container all of the elements equivalent to Item. If there
-- are no elements equivalent to Item, then it raises Constraint_Error.
procedure Delete (Container : in out Set; Position : in out Cursor);
-- If Position equals No_Element, then Constraint_Error is raised. If
-- Position is associated with a set different from Container, then
-- Program_Error is raised. Otherwise, the node designated by Position is
-- removed from Container, and Position is set to No_Element.
procedure Delete_First (Container : in out Set);
-- Removes the first node from Container
procedure Delete_Last (Container : in out Set);
-- Removes the last node from Container
procedure Union (Target : in out Set; Source : Set);
-- If Target is busy (cursor tampering is attempted), then Program_Error is
-- raised. Otherwise, it inserts each element of Source into Target.
-- Elements are inserted in the canonical order for multisets, such that
-- the elements from Source are inserted after equivalent elements already
-- in Target.
function Union (Left, Right : Set) return Set;
-- Returns a set comprising the all elements from Left and all of the
-- elements from Right. The elements from Right follow the equivalent
-- elements from Left.
function "or" (Left, Right : Set) return Set renames Union;
procedure Intersection (Target : in out Set; Source : Set);
-- If Target denotes the same object as Source, the operation does
-- nothing. If Target is busy (cursor tampering is attempted),
-- Program_Error is raised. Otherwise, the elements in Target having no
-- equivalent element in Source are deleted from Target.
function Intersection (Left, Right : Set) return Set;
-- If Left denotes the same object as Right, then the function returns a
-- copy of Left. Otherwise, it returns a set comprising the equivalent
-- elements from both Left and Right. Items are inserted in the result set
-- in canonical order, such that the elements from Left precede the
-- equivalent elements from Right.
function "and" (Left, Right : Set) return Set renames Intersection;
procedure Difference (Target : in out Set; Source : Set);
-- If Target is busy (cursor tampering is attempted), then Program_Error is
-- raised. Otherwise, the elements in Target that are equivalent to
-- elements in Source are deleted from Target.
function Difference (Left, Right : Set) return Set;
-- Returns a set comprising the elements from Left that have no equivalent
-- element in Right.
function "-" (Left, Right : Set) return Set renames Difference;
procedure Symmetric_Difference (Target : in out Set; Source : Set);
-- If Target is busy, then Program_Error is raised. Otherwise, the elements
-- in Target equivalent to elements in Source are deleted from Target, and
-- the elements in Source not equivalent to elements in Target are inserted
-- into Target.
function Symmetric_Difference (Left, Right : Set) return Set;
-- Returns a set comprising the union of the elements from Target having no
-- equivalent in Source, and the elements of Source having no equivalent in
-- Target.
function "xor" (Left, Right : Set) return Set renames Symmetric_Difference;
function Overlap (Left, Right : Set) return Boolean;
-- Returns True if Left contains an element equivalent to an element of
-- Right.
function Is_Subset (Subset : Set; Of_Set : Set) return Boolean;
-- Returns True if every element in Subset has an equivalent element in
-- Of_Set.
function First (Container : Set) return Cursor;
-- If Container is empty, the function returns No_Element. Otherwise, it
-- returns a cursor designating the smallest element.
function First_Element (Container : Set) return Element_Type;
-- Equivalent to Element (First (Container))
function Last (Container : Set) return Cursor;
-- If Container is empty, the function returns No_Element. Otherwise, it
-- returns a cursor designating the largest element.
function Last_Element (Container : Set) return Element_Type;
-- Equivalent to Element (Last (Container))
function Next (Position : Cursor) return Cursor;
-- If Position equals No_Element or Last (Container), the function returns
-- No_Element. Otherwise, it returns a cursor designating the node that
-- immediately follows (as per the insertion order) the node designated by
-- Position.
procedure Next (Position : in out Cursor);
-- Equivalent to Position := Next (Position)
function Previous (Position : Cursor) return Cursor;
-- If Position equals No_Element or First (Container), the function returns
-- No_Element. Otherwise, it returns a cursor designating the node that
-- immediately precedes (as per the insertion order) the node designated by
-- Position.
procedure Previous (Position : in out Cursor);
-- Equivalent to Position := Previous (Position)
function Find (Container : Set; Item : Element_Type) return Cursor;
-- Returns a cursor designating the first element in Container equivalent
-- to Item. If there is no equivalent element, it returns No_Element.
function Floor (Container : Set; Item : Element_Type) return Cursor;
-- If Container is empty, the function returns No_Element. If Item is
-- equivalent to elements in Container, it returns a cursor designating the
-- first equivalent element. Otherwise, it returns a cursor designating the
-- largest element less than Item, or No_Element if all elements are
-- greater than Item.
function Ceiling (Container : Set; Item : Element_Type) return Cursor;
-- If Container is empty, the function returns No_Element. If Item is
-- equivalent to elements of Container, it returns a cursor designating the
-- last equivalent element. Otherwise, it returns a cursor designating the
-- smallest element greater than Item, or No_Element if all elements are
-- less than Item.
function Contains (Container : Set; Item : Element_Type) return Boolean;
-- Equivalent to Container.Find (Item) /= No_Element
function "<" (Left, Right : Cursor) return Boolean;
-- Equivalent to Element (Left) < Element (Right)
function ">" (Left, Right : Cursor) return Boolean;
-- Equivalent to Element (Right) < Element (Left)
function "<" (Left : Cursor; Right : Element_Type) return Boolean;
-- Equivalent to Element (Left) < Right
function ">" (Left : Cursor; Right : Element_Type) return Boolean;
-- Equivalent to Right < Element (Left)
function "<" (Left : Element_Type; Right : Cursor) return Boolean;
-- Equivalent to Left < Element (Right)
function ">" (Left : Element_Type; Right : Cursor) return Boolean;
-- Equivalent to Element (Right) < Left
procedure Iterate
(Container : Set;
Process : not null access procedure (Position : Cursor));
-- Calls Process with a cursor designating each element of Container, in
-- order from Container.First to Container.Last.
procedure Reverse_Iterate
(Container : Set;
Process : not null access procedure (Position : Cursor));
-- Calls Process with a cursor designating each element of Container, in
-- order from Container.Last to Container.First.
procedure Iterate
(Container : Set;
Item : Element_Type;
Process : not null access procedure (Position : Cursor));
-- Call Process with a cursor designating each element equivalent to Item,
-- in order from Container.Floor (Item) to Container.Ceiling (Item).
procedure Reverse_Iterate
(Container : Set;
Item : Element_Type;
Process : not null access procedure (Position : Cursor));
-- Call Process with a cursor designating each element equivalent to Item,
-- in order from Container.Ceiling (Item) to Container.Floor (Item).
function Iterate
(Container : Set)
return Set_Iterator_Interfaces.Reversible_Iterator'class;
function Iterate
(Container : Set;
Start : Cursor)
return Set_Iterator_Interfaces.Reversible_Iterator'class;
generic
type Key_Type (<>) is private;
with function Key (Element : Element_Type) return Key_Type;
with function "<" (Left, Right : Key_Type) return Boolean is <>;
package Generic_Keys is
function Equivalent_Keys (Left, Right : Key_Type) return Boolean;
-- Returns False if Left is less than Right, or Right is less than Left;
-- otherwise, it returns True.
function Key (Position : Cursor) return Key_Type;
-- Equivalent to Key (Element (Position))
function Element (Container : Set; Key : Key_Type) return Element_Type;
-- Equivalent to Element (Find (Container, Key))
procedure Exclude (Container : in out Set; Key : Key_Type);
-- Deletes from Container any elements whose key is equivalent to Key
procedure Delete (Container : in out Set; Key : Key_Type);
-- Deletes from Container any elements whose key is equivalent to
-- Key. If there are no such elements, then it raises Constraint_Error.
function Find (Container : Set; Key : Key_Type) return Cursor;
-- Returns a cursor designating the first element in Container whose key
-- is equivalent to Key. If there is no equivalent element, it returns
-- No_Element.
function Floor (Container : Set; Key : Key_Type) return Cursor;
-- If Container is empty, the function returns No_Element. If Item is
-- equivalent to the keys of elements in Container, it returns a cursor
-- designating the first such element. Otherwise, it returns a cursor
-- designating the largest element whose key is less than Item, or
-- No_Element if all keys are greater than Item.
function Ceiling (Container : Set; Key : Key_Type) return Cursor;
-- If Container is empty, the function returns No_Element. If Item is
-- equivalent to the keys of elements of Container, it returns a cursor
-- designating the last such element. Otherwise, it returns a cursor
-- designating the smallest element whose key is greater than Item, or
-- No_Element if all keys are less than Item.
function Contains (Container : Set; Key : Key_Type) return Boolean;
-- Equivalent to Find (Container, Key) /= No_Element
procedure Update_Element -- Update_Element_Preserving_Key ???
(Container : in out Set;
Position : Cursor;
Process : not null access
procedure (Element : in out Element_Type));
-- If Position equals No_Element, then Constraint_Error is raised. If
-- Position is associated with a set object different from Container,
-- then Program_Error is raised. Otherwise, it makes a copy of the key
-- of the element designated by Position, and then calls Process with
-- the element as the parameter. Update_Element then compares the key
-- value obtained before calling Process to the key value obtained from
-- the element after calling Process. If the keys are equivalent then
-- the operation terminates. If Container is busy (cursor tampering has
-- been attempted), then Program_Error is raised. Otherwise, the node
-- is moved to its new position (in canonical order).
procedure Iterate
(Container : Set;
Key : Key_Type;
Process : not null access procedure (Position : Cursor));
-- Call Process with a cursor designating each element equivalent to
-- Key, in order from Floor (Container, Key) to
-- Ceiling (Container, Key).
procedure Reverse_Iterate
(Container : Set;
Key : Key_Type;
Process : not null access procedure (Position : Cursor));
-- Call Process with a cursor designating each element equivalent to
-- Key, in order from Ceiling (Container, Key) to
-- Floor (Container, Key).
end Generic_Keys;
private
pragma Inline (Next);
pragma Inline (Previous);
type Node_Type;
type Node_Access is access Node_Type;
type Element_Access is access Element_Type;
type Node_Type is limited record
Parent : Node_Access;
Left : Node_Access;
Right : Node_Access;
Color : Red_Black_Trees.Color_Type := Red_Black_Trees.Red;
Element : Element_Access;
end record;
package Tree_Types is new Red_Black_Trees.Generic_Tree_Types
(Node_Type,
Node_Access);
type Set is new Ada.Finalization.Controlled with record
Tree : Tree_Types.Tree_Type;
end record with Put_Image => Put_Image;
procedure Put_Image
(S : in out Ada.Strings.Text_Buffers.Root_Buffer_Type'Class; V : Set);
overriding procedure Adjust (Container : in out Set);
overriding procedure Finalize (Container : in out Set) renames Clear;
use Red_Black_Trees;
use Tree_Types, Tree_Types.Implementation;
use Ada.Finalization;
use Ada.Streams;
type Set_Access is access all Set;
for Set_Access'Storage_Size use 0;
-- In all predefined libraries the following type is controlled, for proper
-- management of tampering checks. For performance reason we omit this
-- machinery for multisets, which are used in a number of our tools.
type Reference_Control_Type is record
Container : Set_Access;
end record;
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;
type Cursor is record
Container : Set_Access;
Node : Node_Access;
end record;
procedure Write
(Stream : not null access Root_Stream_Type'Class;
Item : Cursor);
for Cursor'Write use Write;
procedure Read
(Stream : not null access Root_Stream_Type'Class;
Item : out Cursor);
for Cursor'Read use Read;
No_Element : constant Cursor := Cursor'(null, null);
procedure Write
(Stream : not null access Root_Stream_Type'Class;
Container : Set);
for Set'Write use Write;
procedure Read
(Stream : not null access Root_Stream_Type'Class;
Container : out Set);
for Set'Read use Read;
procedure Read
(Stream : not null access Root_Stream_Type'Class;
Item : out Constant_Reference_Type);
for Constant_Reference_Type'Read use Read;
procedure Write
(Stream : not null access Root_Stream_Type'Class;
Item : Constant_Reference_Type);
for Constant_Reference_Type'Write use Write;
Empty_Set : constant Set := (Controlled with others => <>);
type Iterator is new Limited_Controlled and
Set_Iterator_Interfaces.Reversible_Iterator with
record
Container : Set_Access;
Node : Node_Access;
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.Indefinite_Ordered_Multisets;
|
persan/AdaYaml | Ada | 611 | ads | -- part of AdaYaml, (c) 2017 Felix Krause
-- released under the terms of the MIT license, see the file "copying.txt"
with Ada.Finalization;
package Yaml.Transformator is
type Instance is abstract tagged limited private;
type Pointer is access Instance'Class;
procedure Put (Object : in out Instance; E : Event) is abstract;
function Has_Next (Object : Instance) return Boolean is abstract;
function Next (Object : in out Instance) return Event is abstract;
private
type Instance is abstract limited new Ada.Finalization.Limited_Controlled
with null record;
end Yaml.Transformator;
|
reznikmm/matreshka | Ada | 4,720 | adb | ------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- Open Document Toolkit --
-- --
-- Runtime Library Component --
-- --
------------------------------------------------------------------------------
-- --
-- Copyright © 2014, Vadim Godunko <[email protected]> --
-- All rights reserved. --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions --
-- are met: --
-- --
-- * Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- --
-- * Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in the --
-- documentation and/or other materials provided with the distribution. --
-- --
-- * Neither the name of the Vadim Godunko, IE nor the names of its --
-- contributors may be used to endorse or promote products derived from --
-- this software without specific prior written permission. --
-- --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR --
-- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
-- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED --
-- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR --
-- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF --
-- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING --
-- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS --
-- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
-- --
------------------------------------------------------------------------------
-- $Revision$ $Date$
------------------------------------------------------------------------------
with Matreshka.DOM_Documents;
with Matreshka.ODF_String_Constants;
with ODF.DOM.Iterators;
with ODF.DOM.Visitors;
package body Matreshka.ODF_Style.Layout_Grid_Base_Height_Attributes is
------------
-- Create --
------------
overriding function Create
(Parameters : not null access Matreshka.DOM_Attributes.Attribute_L2_Parameters)
return Style_Layout_Grid_Base_Height_Attribute_Node is
begin
return Self : Style_Layout_Grid_Base_Height_Attribute_Node do
Matreshka.ODF_Style.Constructors.Initialize
(Self'Unchecked_Access,
Parameters.Document,
Matreshka.ODF_String_Constants.Style_Prefix);
end return;
end Create;
--------------------
-- Get_Local_Name --
--------------------
overriding function Get_Local_Name
(Self : not null access constant Style_Layout_Grid_Base_Height_Attribute_Node)
return League.Strings.Universal_String
is
pragma Unreferenced (Self);
begin
return Matreshka.ODF_String_Constants.Layout_Grid_Base_Height_Attribute;
end Get_Local_Name;
begin
Matreshka.DOM_Documents.Register_Attribute
(Matreshka.ODF_String_Constants.Style_URI,
Matreshka.ODF_String_Constants.Layout_Grid_Base_Height_Attribute,
Style_Layout_Grid_Base_Height_Attribute_Node'Tag);
end Matreshka.ODF_Style.Layout_Grid_Base_Height_Attributes;
|
zhmu/ananas | Ada | 16,190 | ads | ------------------------------------------------------------------------------
-- --
-- GNAT RUN-TIME COMPONENTS --
-- --
-- A D A . S T R I N G S . W I D E _ S U P E R B O U N D E D --
-- --
-- S p e c --
-- --
-- Copyright (C) 2003-2022, Free Software Foundation, Inc. --
-- --
-- GNAT is free software; you can redistribute it and/or modify it under --
-- terms of the GNU General Public License as published by the Free Soft- --
-- ware Foundation; either version 3, or (at your option) any later ver- --
-- sion. GNAT is distributed in the hope that it will be useful, but WITH- --
-- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY --
-- or FITNESS FOR A PARTICULAR PURPOSE. --
-- --
-- As a special exception under Section 7 of GPL version 3, you are granted --
-- additional permissions described in the GCC Runtime Library Exception, --
-- version 3.1, as published by the Free Software Foundation. --
-- --
-- You should have received a copy of the GNU General Public License and --
-- a copy of the GCC Runtime Library Exception along with this program; --
-- see the files COPYING3 and COPYING.RUNTIME respectively. If not, see --
-- <http://www.gnu.org/licenses/>. --
-- --
-- GNAT was originally developed by the GNAT team at New York University. --
-- Extensive contributions were provided by Ada Core Technologies Inc. --
-- --
------------------------------------------------------------------------------
-- This non generic package contains most of the implementation of the
-- generic package Ada.Strings.Wide_Bounded.Generic_Bounded_Length.
-- It defines type Super_String as a discriminated record with the maximum
-- length as the discriminant. Individual instantiations of the package
-- Strings.Wide_Bounded.Generic_Bounded_Length use this type with
-- an appropriate discriminant value set.
with Ada.Strings.Wide_Maps;
package Ada.Strings.Wide_Superbounded is
pragma Preelaborate;
Wide_NUL : constant Wide_Character := Wide_Character'Val (0);
-- Ada.Strings.Wide_Bounded.Generic_Bounded_Length.Wide_Bounded_String is
-- derived from Super_String, with the constraint of the maximum length.
type Super_String (Max_Length : Positive) is record
Current_Length : Natural := 0;
Data : Wide_String (1 .. Max_Length);
-- A previous version had a default initial value for Data, which is
-- no longer necessary, because we now special-case this type in the
-- compiler, so "=" composes properly for descendants of this type.
-- Leaving it out is more efficient.
end record;
-- The subprograms defined for Super_String are similar to those defined
-- for Bounded_Wide_String, except that they have different names, so that
-- they can be renamed in Ada.Strings.Wide_Bounded.Generic_Bounded_Length.
function Super_Length (Source : Super_String) return Natural;
--------------------------------------------------------
-- Conversion, Concatenation, and Selection Functions --
--------------------------------------------------------
function To_Super_String
(Source : Wide_String;
Max_Length : Natural;
Drop : Truncation := Error) return Super_String;
-- Note the additional parameter Max_Length, which specifies the maximum
-- length setting of the resulting Super_String value.
-- The following procedures have declarations (and semantics) that are
-- exactly analogous to those declared in Ada.Strings.Wide_Bounded.
function Super_To_String (Source : Super_String) return Wide_String;
procedure Set_Super_String
(Target : out Super_String;
Source : Wide_String;
Drop : Truncation := Error);
function Super_Append
(Left : Super_String;
Right : Super_String;
Drop : Truncation := Error) return Super_String;
function Super_Append
(Left : Super_String;
Right : Wide_String;
Drop : Truncation := Error) return Super_String;
function Super_Append
(Left : Wide_String;
Right : Super_String;
Drop : Truncation := Error) return Super_String;
function Super_Append
(Left : Super_String;
Right : Wide_Character;
Drop : Truncation := Error) return Super_String;
function Super_Append
(Left : Wide_Character;
Right : Super_String;
Drop : Truncation := Error) return Super_String;
procedure Super_Append
(Source : in out Super_String;
New_Item : Super_String;
Drop : Truncation := Error);
procedure Super_Append
(Source : in out Super_String;
New_Item : Wide_String;
Drop : Truncation := Error);
procedure Super_Append
(Source : in out Super_String;
New_Item : Wide_Character;
Drop : Truncation := Error);
function Concat
(Left : Super_String;
Right : Super_String) return Super_String;
function Concat
(Left : Super_String;
Right : Wide_String) return Super_String;
function Concat
(Left : Wide_String;
Right : Super_String) return Super_String;
function Concat
(Left : Super_String;
Right : Wide_Character) return Super_String;
function Concat
(Left : Wide_Character;
Right : Super_String) return Super_String;
function Super_Element
(Source : Super_String;
Index : Positive) return Wide_Character;
procedure Super_Replace_Element
(Source : in out Super_String;
Index : Positive;
By : Wide_Character);
function Super_Slice
(Source : Super_String;
Low : Positive;
High : Natural) return Wide_String;
function Super_Slice
(Source : Super_String;
Low : Positive;
High : Natural) return Super_String;
procedure Super_Slice
(Source : Super_String;
Target : out Super_String;
Low : Positive;
High : Natural);
function "="
(Left : Super_String;
Right : Super_String) return Boolean;
function Equal
(Left : Super_String;
Right : Super_String) return Boolean renames "=";
function Equal
(Left : Super_String;
Right : Wide_String) return Boolean;
function Equal
(Left : Wide_String;
Right : Super_String) return Boolean;
function Less
(Left : Super_String;
Right : Super_String) return Boolean;
function Less
(Left : Super_String;
Right : Wide_String) return Boolean;
function Less
(Left : Wide_String;
Right : Super_String) return Boolean;
function Less_Or_Equal
(Left : Super_String;
Right : Super_String) return Boolean;
function Less_Or_Equal
(Left : Super_String;
Right : Wide_String) return Boolean;
function Less_Or_Equal
(Left : Wide_String;
Right : Super_String) return Boolean;
function Greater
(Left : Super_String;
Right : Super_String) return Boolean;
function Greater
(Left : Super_String;
Right : Wide_String) return Boolean;
function Greater
(Left : Wide_String;
Right : Super_String) return Boolean;
function Greater_Or_Equal
(Left : Super_String;
Right : Super_String) return Boolean;
function Greater_Or_Equal
(Left : Super_String;
Right : Wide_String) return Boolean;
function Greater_Or_Equal
(Left : Wide_String;
Right : Super_String) return Boolean;
----------------------
-- Search Functions --
----------------------
function Super_Index
(Source : Super_String;
Pattern : Wide_String;
Going : Direction := Forward;
Mapping : Wide_Maps.Wide_Character_Mapping := Wide_Maps.Identity)
return Natural;
function Super_Index
(Source : Super_String;
Pattern : Wide_String;
Going : Direction := Forward;
Mapping : Wide_Maps.Wide_Character_Mapping_Function) return Natural;
function Super_Index
(Source : Super_String;
Set : Wide_Maps.Wide_Character_Set;
Test : Membership := Inside;
Going : Direction := Forward) return Natural;
function Super_Index
(Source : Super_String;
Pattern : Wide_String;
From : Positive;
Going : Direction := Forward;
Mapping : Wide_Maps.Wide_Character_Mapping := Wide_Maps.Identity)
return Natural;
function Super_Index
(Source : Super_String;
Pattern : Wide_String;
From : Positive;
Going : Direction := Forward;
Mapping : Wide_Maps.Wide_Character_Mapping_Function) return Natural;
function Super_Index
(Source : Super_String;
Set : Wide_Maps.Wide_Character_Set;
From : Positive;
Test : Membership := Inside;
Going : Direction := Forward) return Natural;
function Super_Index_Non_Blank
(Source : Super_String;
Going : Direction := Forward) return Natural;
function Super_Index_Non_Blank
(Source : Super_String;
From : Positive;
Going : Direction := Forward) return Natural;
function Super_Count
(Source : Super_String;
Pattern : Wide_String;
Mapping : Wide_Maps.Wide_Character_Mapping := Wide_Maps.Identity)
return Natural;
function Super_Count
(Source : Super_String;
Pattern : Wide_String;
Mapping : Wide_Maps.Wide_Character_Mapping_Function) return Natural;
function Super_Count
(Source : Super_String;
Set : Wide_Maps.Wide_Character_Set) return Natural;
procedure Super_Find_Token
(Source : Super_String;
Set : Wide_Maps.Wide_Character_Set;
From : Positive;
Test : Membership;
First : out Positive;
Last : out Natural);
procedure Super_Find_Token
(Source : Super_String;
Set : Wide_Maps.Wide_Character_Set;
Test : Membership;
First : out Positive;
Last : out Natural);
------------------------------------
-- String Translation Subprograms --
------------------------------------
function Super_Translate
(Source : Super_String;
Mapping : Wide_Maps.Wide_Character_Mapping) return Super_String;
procedure Super_Translate
(Source : in out Super_String;
Mapping : Wide_Maps.Wide_Character_Mapping);
function Super_Translate
(Source : Super_String;
Mapping : Wide_Maps.Wide_Character_Mapping_Function) return Super_String;
procedure Super_Translate
(Source : in out Super_String;
Mapping : Wide_Maps.Wide_Character_Mapping_Function);
---------------------------------------
-- String Transformation Subprograms --
---------------------------------------
function Super_Replace_Slice
(Source : Super_String;
Low : Positive;
High : Natural;
By : Wide_String;
Drop : Truncation := Error) return Super_String;
procedure Super_Replace_Slice
(Source : in out Super_String;
Low : Positive;
High : Natural;
By : Wide_String;
Drop : Truncation := Error);
function Super_Insert
(Source : Super_String;
Before : Positive;
New_Item : Wide_String;
Drop : Truncation := Error) return Super_String;
procedure Super_Insert
(Source : in out Super_String;
Before : Positive;
New_Item : Wide_String;
Drop : Truncation := Error);
function Super_Overwrite
(Source : Super_String;
Position : Positive;
New_Item : Wide_String;
Drop : Truncation := Error) return Super_String;
procedure Super_Overwrite
(Source : in out Super_String;
Position : Positive;
New_Item : Wide_String;
Drop : Truncation := Error);
function Super_Delete
(Source : Super_String;
From : Positive;
Through : Natural) return Super_String;
procedure Super_Delete
(Source : in out Super_String;
From : Positive;
Through : Natural);
---------------------------------
-- String Selector Subprograms --
---------------------------------
function Super_Trim
(Source : Super_String;
Side : Trim_End) return Super_String;
procedure Super_Trim
(Source : in out Super_String;
Side : Trim_End);
function Super_Trim
(Source : Super_String;
Left : Wide_Maps.Wide_Character_Set;
Right : Wide_Maps.Wide_Character_Set) return Super_String;
procedure Super_Trim
(Source : in out Super_String;
Left : Wide_Maps.Wide_Character_Set;
Right : Wide_Maps.Wide_Character_Set);
function Super_Head
(Source : Super_String;
Count : Natural;
Pad : Wide_Character := Wide_Space;
Drop : Truncation := Error) return Super_String;
procedure Super_Head
(Source : in out Super_String;
Count : Natural;
Pad : Wide_Character := Wide_Space;
Drop : Truncation := Error);
function Super_Tail
(Source : Super_String;
Count : Natural;
Pad : Wide_Character := Wide_Space;
Drop : Truncation := Error) return Super_String;
procedure Super_Tail
(Source : in out Super_String;
Count : Natural;
Pad : Wide_Character := Wide_Space;
Drop : Truncation := Error);
------------------------------------
-- String Constructor Subprograms --
------------------------------------
-- Note: in some of the following routines, there is an extra parameter
-- Max_Length which specifies the value of the maximum length for the
-- resulting Super_String value.
function Times
(Left : Natural;
Right : Wide_Character;
Max_Length : Positive) return Super_String;
-- Note the additional parameter Max_Length
function Times
(Left : Natural;
Right : Wide_String;
Max_Length : Positive) return Super_String;
-- Note the additional parameter Max_Length
function Times
(Left : Natural;
Right : Super_String) return Super_String;
function Super_Replicate
(Count : Natural;
Item : Wide_Character;
Drop : Truncation := Error;
Max_Length : Positive) return Super_String;
-- Note the additional parameter Max_Length
function Super_Replicate
(Count : Natural;
Item : Wide_String;
Drop : Truncation := Error;
Max_Length : Positive) return Super_String;
-- Note the additional parameter Max_Length
function Super_Replicate
(Count : Natural;
Item : Super_String;
Drop : Truncation := Error) return Super_String;
private
-- Pragma Inline declarations
pragma Inline ("=");
pragma Inline (Less);
pragma Inline (Less_Or_Equal);
pragma Inline (Greater);
pragma Inline (Greater_Or_Equal);
pragma Inline (Concat);
pragma Inline (Super_Count);
pragma Inline (Super_Element);
pragma Inline (Super_Find_Token);
pragma Inline (Super_Index);
pragma Inline (Super_Index_Non_Blank);
pragma Inline (Super_Length);
pragma Inline (Super_Replace_Element);
pragma Inline (Super_Slice);
pragma Inline (Super_To_String);
end Ada.Strings.Wide_Superbounded;
|
Subsets and Splits
No saved queries yet
Save your SQL queries to embed, download, and access them later. Queries will appear here once saved.