repo_name
stringlengths 9
74
| language
stringclasses 1
value | length_bytes
int64 11
9.34M
| extension
stringclasses 2
values | content
stringlengths 11
9.34M
|
---|---|---|---|---|
wookey-project/ewok-legacy | Ada | 1,763 | adb | --
-- Copyright 2018 The wookey project team <[email protected]>
-- - Ryad Benadjila
-- - Arnauld Michelizza
-- - Mathieu Renard
-- - Philippe Thierry
-- - Philippe Trebuchet
--
-- Licensed under the Apache License, Version 2.0 (the "License");
-- you may not use this file except in compliance with the License.
-- You may obtain a copy of the License at
--
-- http://www.apache.org/licenses/LICENSE-2.0
--
-- Unless required by applicable law or agreed to in writing, software
-- distributed under the License is distributed on an "AS IS" BASIS,
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-- See the License for the specific language governing permissions and
-- limitations under the License.
--
--
with ewok.tasks; use ewok.tasks;
with ewok.sched;
package body ewok.syscalls.yield
with spark_mode => off
is
procedure sys_yield
(caller_id : in ewok.tasks_shared.t_task_id;
mode : in ewok.tasks_shared.t_task_mode)
is
begin
if mode = TASK_MODE_ISRTHREAD then
set_return_value (caller_id, mode, SYS_E_DENIED);
return;
end if;
-- Before setting the current task in IDLE state, we verify that
-- no IPC was sent to this task.
if ewok.tasks.is_ipc_waiting (caller_id) then
-- An IPC is waiting to be managed by the current task
ewok.tasks.set_state (caller_id, mode, TASK_STATE_RUNNABLE);
set_return_value (caller_id, mode, SYS_E_BUSY);
else
ewok.tasks.set_state (caller_id, mode, TASK_STATE_IDLE);
set_return_value (caller_id, mode, SYS_E_DONE);
ewok.sched.request_schedule;
end if;
end sys_yield;
end ewok.syscalls.yield;
|
reznikmm/matreshka | Ada | 4,756 | ads | ------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- Localization, Internationalization, Globalization for Ada --
-- --
-- Runtime Library Component --
-- --
------------------------------------------------------------------------------
-- --
-- Copyright © 2012-2015, Vadim Godunko <[email protected]> --
-- All rights reserved. --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions --
-- are met: --
-- --
-- * Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- --
-- * Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in the --
-- documentation and/or other materials provided with the distribution. --
-- --
-- * Neither the name of the Vadim Godunko, IE nor the names of its --
-- contributors may be used to endorse or promote products derived from --
-- this software without specific prior written permission. --
-- --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR --
-- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
-- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED --
-- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR --
-- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF --
-- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING --
-- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS --
-- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
-- --
------------------------------------------------------------------------------
-- $Revision$ $Date$
------------------------------------------------------------------------------
pragma Restrictions (No_Elaboration_Code);
-- GNAT: enforce generation of preinitialized data section instead of
-- generation of elaboration code.
package Matreshka.Internals.Unicode.Ucd.Core_01F0 is
pragma Preelaborate;
Group_01F0 : aliased constant Core_Second_Stage
:= (16#2C# .. 16#2F# => -- 01F02C .. 01F02F
(Unassigned, Neutral,
Other, Other, Other, Unknown,
(others => False)),
16#94# .. 16#9F# => -- 01F094 .. 01F09F
(Unassigned, Neutral,
Other, Other, Other, Unknown,
(others => False)),
16#AF# .. 16#B0# => -- 01F0AF .. 01F0B0
(Unassigned, Neutral,
Other, Other, Other, Unknown,
(others => False)),
16#C0# => -- 01F0C0
(Unassigned, Neutral,
Other, Other, Other, Unknown,
(others => False)),
16#D0# => -- 01F0D0
(Unassigned, Neutral,
Other, Other, Other, Unknown,
(others => False)),
16#F6# .. 16#FF# => -- 01F0F6 .. 01F0FF
(Unassigned, Neutral,
Other, Other, Other, Unknown,
(others => False)),
others =>
(Other_Symbol, Neutral,
Other, Other, Other, Ideographic,
(Grapheme_Base => True,
others => False)));
end Matreshka.Internals.Unicode.Ucd.Core_01F0;
|
mirror/ncurses | Ada | 8,986 | adb | ------------------------------------------------------------------------------
-- --
-- GNAT ncurses Binding Samples --
-- --
-- Sample.Curses_Demo.Mouse --
-- --
-- B O D Y --
-- --
------------------------------------------------------------------------------
-- Copyright 2020 Thomas E. Dickey --
-- Copyright 1998-2006,2008 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.17 $
-- $Date: 2020/02/02 23:34:34 $
-- 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, (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 := ((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, (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;
|
charlie5/cBound | Ada | 1,636 | ads | -- This file is generated by SWIG. Please do not modify by hand.
--
with Interfaces;
with Interfaces.C;
with Interfaces.C.Pointers;
package xcb.xcb_glx_delete_textures_request_t is
-- Item
--
type Item is record
major_opcode : aliased Interfaces.Unsigned_8;
minor_opcode : aliased Interfaces.Unsigned_8;
length : aliased Interfaces.Unsigned_16;
context_tag : aliased xcb.xcb_glx_context_tag_t;
n : aliased Interfaces.Integer_32;
end record;
-- Item_Array
--
type Item_Array is
array
(Interfaces.C
.size_t range <>) of aliased xcb.xcb_glx_delete_textures_request_t
.Item;
-- Pointer
--
package C_Pointers is new Interfaces.C.Pointers
(Index => Interfaces.C.size_t,
Element => xcb.xcb_glx_delete_textures_request_t.Item,
Element_Array => xcb.xcb_glx_delete_textures_request_t.Item_Array,
Default_Terminator => (others => <>));
subtype Pointer is C_Pointers.Pointer;
-- Pointer_Array
--
type Pointer_Array is
array
(Interfaces.C
.size_t range <>) of aliased xcb.xcb_glx_delete_textures_request_t
.Pointer;
-- Pointer_Pointer
--
package C_Pointer_Pointers is new Interfaces.C.Pointers
(Index => Interfaces.C.size_t,
Element => xcb.xcb_glx_delete_textures_request_t.Pointer,
Element_Array => xcb.xcb_glx_delete_textures_request_t.Pointer_Array,
Default_Terminator => null);
subtype Pointer_Pointer is C_Pointer_Pointers.Pointer;
end xcb.xcb_glx_delete_textures_request_t;
|
reznikmm/matreshka | Ada | 7,240 | adb | ------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- Open Document Toolkit --
-- --
-- Runtime Library Component --
-- --
------------------------------------------------------------------------------
-- --
-- Copyright © 2014, Vadim Godunko <[email protected]> --
-- All rights reserved. --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions --
-- are met: --
-- --
-- * Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- --
-- * Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in the --
-- documentation and/or other materials provided with the distribution. --
-- --
-- * Neither the name of the Vadim Godunko, IE nor the names of its --
-- contributors may be used to endorse or promote products derived from --
-- this software without specific prior written permission. --
-- --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR --
-- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
-- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED --
-- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR --
-- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF --
-- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING --
-- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS --
-- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
-- --
------------------------------------------------------------------------------
-- $Revision$ $Date$
------------------------------------------------------------------------------
with Matreshka.DOM_Documents;
with Matreshka.ODF_String_Constants;
with ODF.DOM.Iterators;
with ODF.DOM.Visitors;
package body Matreshka.ODF_Text.Alphabetical_Index_Mark_Start_Elements is
------------
-- Create --
------------
overriding function Create
(Parameters : not null access Matreshka.DOM_Elements.Element_L2_Parameters)
return Text_Alphabetical_Index_Mark_Start_Element_Node is
begin
return Self : Text_Alphabetical_Index_Mark_Start_Element_Node do
Matreshka.ODF_Text.Constructors.Initialize
(Self'Unchecked_Access,
Parameters.Document,
Matreshka.ODF_String_Constants.Text_Prefix);
end return;
end Create;
----------------
-- Enter_Node --
----------------
overriding procedure Enter_Node
(Self : not null access Text_Alphabetical_Index_Mark_Start_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_Text_Alphabetical_Index_Mark_Start
(ODF.DOM.Text_Alphabetical_Index_Mark_Start_Elements.ODF_Text_Alphabetical_Index_Mark_Start_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 Text_Alphabetical_Index_Mark_Start_Element_Node)
return League.Strings.Universal_String
is
pragma Unreferenced (Self);
begin
return Matreshka.ODF_String_Constants.Alphabetical_Index_Mark_Start_Element;
end Get_Local_Name;
----------------
-- Leave_Node --
----------------
overriding procedure Leave_Node
(Self : not null access Text_Alphabetical_Index_Mark_Start_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_Text_Alphabetical_Index_Mark_Start
(ODF.DOM.Text_Alphabetical_Index_Mark_Start_Elements.ODF_Text_Alphabetical_Index_Mark_Start_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 Text_Alphabetical_Index_Mark_Start_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_Text_Alphabetical_Index_Mark_Start
(Visitor,
ODF.DOM.Text_Alphabetical_Index_Mark_Start_Elements.ODF_Text_Alphabetical_Index_Mark_Start_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.Text_URI,
Matreshka.ODF_String_Constants.Alphabetical_Index_Mark_Start_Element,
Text_Alphabetical_Index_Mark_Start_Element_Node'Tag);
end Matreshka.ODF_Text.Alphabetical_Index_Mark_Start_Elements;
|
ZinebZaad/ENSEEIHT | Ada | 895 | adb | with Ada.Text_IO; use Ada.Text_IO;
with Ada.Integer_Text_IO; use Ada.Integer_Text_IO;
with Ada.Float_Text_IO; use Ada.Float_Text_IO;
-- Afficher une valeur approchée de la racine carréé d'un nombre réel
procedure Racine_Carree_Rang is
A: Float; -- le nombre dont on veut calculer la racine carrée
Rang: Integer; -- le rang souhaité
Racine: Float; -- valeur approchée de la racine carrée de A
begin
-- Demander la valeur (sans contrôle)
Get (A);
-- Déterminer la valeur approchée de la racine carrée
-- Demander le rang (sans contrôle)
Get (Rang);
-- Calculer le terme de rang Rang de la suite
Racine := A;
for I in 1 .. Rang loop
exit when Racine = 0.0;
Racine := (Racine + A/Racine)/2.0;
end loop;
-- Afficher la valeur approchée de la racine carrée
Put (Racine, Exp => 0, Aft => 4);
New_Line;
end Racine_Carree_Rang;
|
MinimSecure/unum-sdk | Ada | 928 | ads | -- Copyright 2018-2019 Free Software Foundation, Inc.
--
-- This program is free software; you can redistribute it and/or modify
-- it under the terms of the GNU General Public License as published by
-- the Free Software Foundation; either version 3 of the License, or
-- (at your option) any later version.
--
-- This program is distributed in the hope that it will be useful,
-- but WITHOUT ANY WARRANTY; without even the implied warranty of
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-- GNU General Public License for more details.
--
-- You should have received a copy of the GNU General Public License
-- along with this program. If not, see <http://www.gnu.org/licenses/>.
package Global_Pack is
Some_Number_In_Ada : Integer := 0;
type Some_Type_In_Ada is
record
Some_Component_In_Ada : Integer;
end record;
Some_Struct_In_Ada : Some_Type_In_Ada;
end Global_Pack;
|
buotex/BICEPS | Ada | 5,998 | adb | ----------------------------------------------------------------
-- ZLib for Ada thick binding. --
-- --
-- Copyright (C) 2002-2003 Dmitriy Anisimkov --
-- --
-- Open source license information is in the zlib.ads file. --
----------------------------------------------------------------
-- $Id: zlib-streams.adb,v 1.1 2008/06/11 20:00:39 chambers Exp $
with Ada.Unchecked_Deallocation;
package body ZLib.Streams is
-----------
-- Close --
-----------
procedure Close (Stream : in out Stream_Type) is
procedure Free is new Ada.Unchecked_Deallocation
(Stream_Element_Array, Buffer_Access);
begin
if Stream.Mode = Out_Stream or Stream.Mode = Duplex then
-- We should flush the data written by the writer.
Flush (Stream, Finish);
Close (Stream.Writer);
end if;
if Stream.Mode = In_Stream or Stream.Mode = Duplex then
Close (Stream.Reader);
Free (Stream.Buffer);
end if;
end Close;
------------
-- Create --
------------
procedure Create
(Stream : out Stream_Type;
Mode : in Stream_Mode;
Back : in Stream_Access;
Back_Compressed : in Boolean;
Level : in Compression_Level := Default_Compression;
Strategy : in Strategy_Type := Default_Strategy;
Header : in Header_Type := Default;
Read_Buffer_Size : in Ada.Streams.Stream_Element_Offset
:= Default_Buffer_Size;
Write_Buffer_Size : in Ada.Streams.Stream_Element_Offset
:= Default_Buffer_Size)
is
subtype Buffer_Subtype is Stream_Element_Array (1 .. Read_Buffer_Size);
procedure Init_Filter
(Filter : in out Filter_Type;
Compress : in Boolean);
-----------------
-- Init_Filter --
-----------------
procedure Init_Filter
(Filter : in out Filter_Type;
Compress : in Boolean) is
begin
if Compress then
Deflate_Init
(Filter, Level, Strategy, Header => Header);
else
Inflate_Init (Filter, Header => Header);
end if;
end Init_Filter;
begin
Stream.Back := Back;
Stream.Mode := Mode;
if Mode = Out_Stream or Mode = Duplex then
Init_Filter (Stream.Writer, Back_Compressed);
Stream.Buffer_Size := Write_Buffer_Size;
else
Stream.Buffer_Size := 0;
end if;
if Mode = In_Stream or Mode = Duplex then
Init_Filter (Stream.Reader, not Back_Compressed);
Stream.Buffer := new Buffer_Subtype;
Stream.Rest_First := Stream.Buffer'Last + 1;
Stream.Rest_Last := Stream.Buffer'Last;
end if;
end Create;
-----------
-- Flush --
-----------
procedure Flush
(Stream : in out Stream_Type;
Mode : in Flush_Mode := Sync_Flush)
is
Buffer : Stream_Element_Array (1 .. Stream.Buffer_Size);
Last : Stream_Element_Offset;
begin
loop
Flush (Stream.Writer, Buffer, Last, Mode);
Ada.Streams.Write (Stream.Back.all, Buffer (1 .. Last));
exit when Last < Buffer'Last;
end loop;
end Flush;
-------------
-- Is_Open --
-------------
function Is_Open (Stream : Stream_Type) return Boolean is
begin
return Is_Open (Stream.Reader) or else Is_Open (Stream.Writer);
end Is_Open;
----------
-- Read --
----------
procedure Read
(Stream : in out Stream_Type;
Item : out Stream_Element_Array;
Last : out Stream_Element_Offset)
is
procedure Read
(Item : out Stream_Element_Array;
Last : out Stream_Element_Offset);
----------
-- Read --
----------
procedure Read
(Item : out Stream_Element_Array;
Last : out Stream_Element_Offset) is
begin
Ada.Streams.Read (Stream.Back.all, Item, Last);
end Read;
procedure Read is new ZLib.Read
(Read => Read,
Buffer => Stream.Buffer.all,
Rest_First => Stream.Rest_First,
Rest_Last => Stream.Rest_Last);
begin
Read (Stream.Reader, Item, Last);
end Read;
-------------------
-- Read_Total_In --
-------------------
function Read_Total_In (Stream : in Stream_Type) return Count is
begin
return Total_In (Stream.Reader);
end Read_Total_In;
--------------------
-- Read_Total_Out --
--------------------
function Read_Total_Out (Stream : in Stream_Type) return Count is
begin
return Total_Out (Stream.Reader);
end Read_Total_Out;
-----------
-- Write --
-----------
procedure Write
(Stream : in out Stream_Type;
Item : in Stream_Element_Array)
is
procedure Write (Item : in Stream_Element_Array);
-----------
-- Write --
-----------
procedure Write (Item : in Stream_Element_Array) is
begin
Ada.Streams.Write (Stream.Back.all, Item);
end Write;
procedure Write is new ZLib.Write
(Write => Write,
Buffer_Size => Stream.Buffer_Size);
begin
Write (Stream.Writer, Item, No_Flush);
end Write;
--------------------
-- Write_Total_In --
--------------------
function Write_Total_In (Stream : in Stream_Type) return Count is
begin
return Total_In (Stream.Writer);
end Write_Total_In;
---------------------
-- Write_Total_Out --
---------------------
function Write_Total_Out (Stream : in Stream_Type) return Count is
begin
return Total_Out (Stream.Writer);
end Write_Total_Out;
end ZLib.Streams;
|
Fabien-Chouteau/coffee-clock | Ada | 16,244 | ads | -- This file was generated by bmp2ada
with Giza.Image;
with Giza.Image.DMA2D;
use Giza.Image.DMA2D;
package ok_80x80 is
pragma Style_Checks (Off);
CLUT : aliased constant L4_CLUT_T := (
(R => 181, G => 230, B => 18),
(R => 186, G => 232, B => 41),
(R => 190, G => 233, B => 56),
(R => 195, G => 236, B => 73),
(R => 202, G => 237, B => 89),
(R => 208, G => 239, B => 105),
(R => 210, G => 240, B => 116),
(R => 213, G => 240, B => 124),
(R => 216, G => 242, B => 135),
(R => 220, G => 244, B => 153),
(R => 226, G => 245, B => 165),
(R => 229, G => 246, B => 178),
(R => 239, G => 250, B => 207),
(R => 244, G => 251, B => 222),
(R => 249, G => 252, B => 235),
(R => 254, G => 255, B => 252));
Data : aliased constant L4_Data_T := (
255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 240, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
255, 255, 255, 255, 255, 255, 0, 0, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 15, 0, 240, 255, 255,
255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 0, 0, 240, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 15, 0, 0, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 0, 0, 0, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
255, 255, 255, 15, 0, 0, 240, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 0, 0, 0, 255, 255, 255, 255,
255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 15, 0, 0, 0, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 15, 0, 0, 240, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 0, 0, 0, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
255, 15, 0, 0, 0, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 15, 0, 0, 240, 255, 255, 255, 255, 255,
255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 0, 0, 0, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 15, 0, 0, 0, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 15, 0, 0, 240, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
0, 0, 0, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 15, 0, 0, 240, 255, 255, 255, 255, 255, 255, 255,
255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 15, 0, 0, 240, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 0, 0, 0, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
255, 255, 255, 255, 255, 255, 255, 255, 15, 0, 0, 240, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 0, 0,
0, 240, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 0, 0, 0, 255, 255, 255, 255, 255, 255, 255, 255, 255,
255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 15, 0, 0, 240, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 0, 0, 0, 240, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 240, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
255, 255, 255, 255, 255, 255, 255, 0, 0, 0, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 0, 0, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 15, 0, 0, 240,
255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 15, 0, 0, 240, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 0, 0, 0, 240, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
255, 255, 255, 255, 255, 0, 0, 0, 0, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 0, 0, 0, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 15, 0, 0, 0, 0, 240,
255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 15, 0, 0, 240, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 0, 0, 0, 0, 0, 0, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
255, 255, 255, 255, 255, 0, 0, 0, 240, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 15, 0, 0, 0, 0, 0, 0, 240, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 0, 0, 0, 255, 255,
255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 0, 0, 0, 0, 0, 0, 0, 0, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 15, 0, 0, 240, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
255, 255, 255, 0, 0, 0, 0, 0, 0, 0, 0, 240, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 0, 0, 0, 240, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 15, 0, 0, 0, 0, 0, 0, 0,
0, 0, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 0, 0, 0, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 0, 0, 0, 0, 0, 0, 0, 0, 0, 240, 255, 255, 255, 255, 255, 255, 255,
255, 255, 255, 15, 0, 0, 240, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 15, 0, 0, 0, 0, 0, 0, 0, 0, 0, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 0, 0, 0, 240, 255, 255, 255,
255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 0, 0, 0, 0, 0, 0, 0, 0, 0, 240, 255, 255, 255, 255, 255, 255, 255, 255, 255, 0, 0, 0, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
255, 255, 255, 255, 15, 0, 0, 0, 0, 0, 0, 0, 0, 0, 240, 255, 255, 255, 255, 255, 255, 255, 15, 0, 0, 240, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 255, 255, 255, 255, 255, 255, 255, 0, 0, 0, 240, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 15, 0, 0, 0, 0, 0, 0, 0, 0, 0, 240, 255, 255, 255, 255,
255, 255, 0, 0, 0, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 255, 255, 255, 255, 255, 15, 0, 0, 240, 255, 255, 255, 255, 255,
255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 15, 0, 0, 0, 0, 0, 0, 0, 0, 0, 240, 255, 255, 255, 255, 0, 0, 0, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
255, 255, 255, 255, 255, 255, 255, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 255, 255, 255, 255, 0, 0, 0, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 15, 0, 0,
0, 0, 0, 0, 0, 0, 0, 240, 255, 255, 15, 0, 0, 240, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 255, 255,
0, 0, 0, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 15, 0, 0, 0, 0, 0, 0, 0, 0, 0, 240, 15, 0, 0, 0, 255, 255, 255, 255, 255, 255, 255,
255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 15, 0, 0, 240, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
255, 255, 255, 255, 255, 255, 255, 255, 255, 15, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
15, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 240, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 15, 0, 0, 0, 0, 0, 0, 0, 0, 0, 255, 255, 255, 255, 255, 255, 255, 255, 255,
255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 0, 0, 0, 0, 0, 0, 0, 0, 0, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 15, 0, 0, 0, 0, 0, 0, 0, 240, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
255, 255, 255, 0, 0, 0, 0, 0, 0, 0, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 15, 0, 0, 0, 0, 0, 240,
255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 0, 0, 0, 0, 0, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 15, 0, 0, 0, 240, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 0, 0, 0, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
255, 255, 255, 255, 255, 15, 0, 240, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 240, 255, 255, 255,
255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255
);
Image : constant Giza.Image.Ref := new Giza.Image.DMA2D.Instance'
(Mode => L4, W => 80, H => 80, Length => 3200, L4_CLUT => CLUT'Access, L4_Data => Data'Access);
pragma Style_Checks (On);
end ok_80x80;
|
Feqzz/film-parser | Ada | 5,454 | adb | with Ada.Text_IO;
with Ada.Strings.Unbounded;
with Ada.Strings.Fixed;
with Ada.Command_Line;
with Ada.Integer_Text_IO;
with Ada.Task_Identification;
with Parser;
with Json;
procedure Main is
fileType : Ada.Text_IO.File_Type;
fileName : Ada.Strings.Unbounded.Unbounded_String;
counter: Integer;
currentLine : Ada.Strings.Unbounded.Unbounded_String;
currentArgument : Ada.Strings.Unbounded.Unbounded_String;
filmScore : Integer;
imdbId : Ada.Strings.Unbounded.Unbounded_String;
filmTitle : Ada.Strings.Unbounded.Unbounded_String;
filmYear : Ada.Strings.Unbounded.Unbounded_String;
showScore : Boolean := False;
showImdb : Boolean := False;
showOnlyImdb: Boolean := False;
writeToFile: Boolean := False;
procedure PrintUsage is
begin
Ada.Text_IO.Put_Line("Usage: film-parser <file.html> [options]");
Ada.Text_IO.Put_Line(" --score Shows the score for each movie. If there is none, 'Seen' is displayed");
Ada.Text_IO.Put_Line(" --imdb Appends the IMDb tab for each movie. Example: (tt0092550)");
Ada.Text_IO.Put_Line(" --only_imdb Overrides the other arguments and displays only the IMDb tags.");
Ada.Text_IO.Put_Line(" --json Writes to json file.");
end PrintUsage;
begin
if Ada.Command_Line.Argument_Count < 1 then
PrintUsage;
return;
end if;
if Ada.Command_Line.Argument(1) = "--help" or Ada.Command_Line.Argument(1) = "-h" then
PrintUsage;
return;
end if;
for I in 1 .. (Ada.Command_Line.Argument_Count - 1) loop
if Ada.Command_Line.Argument(I + 1) = "--score" then
showScore := True;
elsif Ada.Command_Line.Argument(I + 1) = "--imdb" then
showImdb := True;
elsif Ada.Command_Line.Argument(I + 1) = "--only_imdb" then
showImdb := True;
showOnlyImdb := True;
elsif Ada.Command_Line.Argument(I + 1) = "--json" then
writeToFile := True;
else
Ada.Text_IO.Put_Line("Invalid argument!");
return;
end if;
end loop;
counter := 0;
if writeToFile then
Json.Init;
end if;
fileName := Ada.Strings.Unbounded.To_Unbounded_String(Ada.Command_Line.Argument(1));
Ada.Text_IO.Open(fileType, Ada.Text_IO.In_File, Ada.Strings.Unbounded.To_String(fileName));
loop
exit when Ada.Text_IO.End_Of_File(fileType);
currentLine := Ada.Strings.Unbounded.To_Unbounded_String(Ada.Text_IO.Get_Line(fileType));
if (Ada.Strings.Fixed.Index (Ada.Strings.Unbounded.To_String(currentLine), "<a class=""l_movie""") > 0) then
--Found a movie!
counter := counter + 1;
for J in 1 .. Ada.Strings.Unbounded.Length (currentLine) loop
if Ada.Strings.Unbounded.Element (currentLine, J) = '>' then
for K in (J + 1) .. Ada.Strings.Unbounded.Length (currentLine) loop
if Ada.Strings.Unbounded.Element (currentLine, K) = '<' then
for L in 1 .. 4 loop
Ada.Strings.Unbounded.Append(filmYear, Ada.Strings.Unbounded.Element(currentLine, (K + 5 + L)));
end loop;
exit;
end if;
Ada.Strings.Unbounded.Append(filmTitle, Ada.Strings.Unbounded.Element(currentLine, K));
end loop;
exit;
end if;
end loop;
imdbId := Parser.getImdbMovieId(currentLine);
--Skips 6 lines in the HTML file.
for I in 1 .. 6 loop
currentLine := Ada.Strings.Unbounded.To_Unbounded_String(Ada.Text_IO.Get_Line(fileType));
end loop;
if (Ada.Strings.Fixed.Index (Ada.Strings.Unbounded.To_String(currentLine), "<span id=") > 0) then
filmScore := Parser.getRating(currentLine);
end if;
if writeToFile then
Json.AppendFilm(Ada.Strings.Unbounded.To_String(filmTitle), Ada.Strings.Unbounded.To_String(filmYear), Integer'Image(filmScore), Ada.Strings.Unbounded.To_String(imdbId));
end if;
--------------
-- Printing --
--------------
if showOnlyImdb then
Ada.Text_IO.Put(Ada.Strings.Unbounded.To_String(imdbId));
else
Ada.Text_IO.Put(Ada.Strings.Unbounded.To_String(filmTitle));
Ada.Text_IO.Put(" [");
Ada.Text_IO.Put(Ada.Strings.Unbounded.To_String(filmYear));
Ada.Text_IO.Put("]");
if showScore then
Ada.Text_IO.Put(" ");
if filmScore = -1 then
Ada.Text_IO.Put("Seen");
else
Ada.Integer_Text_IO.Put(filmScore, 2);
end if;
end if;
if showImdb then
Ada.Text_IO.Put(" ");
Ada.Text_IO.Put(Ada.Strings.Unbounded.To_String(imdbId));
end if;
end if;
Ada.Text_IO.New_Line;
Ada.Strings.Unbounded.Delete(filmYear, 1, Ada.Strings.Unbounded.Length(filmYear));
Ada.Strings.Unbounded.Delete(filmTitle, 1, Ada.Strings.Unbounded.Length(filmTitle));
end if;
end loop;
if counter = 0 then
Ada.Text_IO.Put("Sorry! Your file was not accepted.");
return;
end if;
Ada.Text_IO.Put("You have seen a total of ");
Ada.Integer_Text_IO.Put(counter, 4);
Ada.Text_IO.Put(" movies!");
Json.Close;
null;
end Main;
|
rogermc2/GA_Ada | Ada | 1,815 | adb |
package body GA_Base_Types is
function "*" (I1, I2 : NI_T) return float is
begin
return 0.0;
end "*";
-- -------------------------------------------------------------------------
function "*" (I : NI_T; O : NO_T) return float is
begin
-- return -I.Inf * O.Origin;
return -1.0;
end "*";
-- -------------------------------------------------------------------------
function "*" (O : NO_T; I : NI_T) return float is
begin
-- return -I.Inf * O.Origin;
return -1.0;
end "*";
-- -------------------------------------------------------------------------
function "*" (O1, O2 : NO_T) return float is
begin
return 0.0;
end "*";
-- -------------------------------------------------------------------------
function NI return float is
begin
return 1.0;
end NI;
-- ------------------------------------------------------------------------
function NI (N : NI_T) return float is
begin
return N.Inf;
end NI;
-- ------------------------------------------------------------------------
function NO return float is
begin
return 1.0;
end NO;
-- ------------------------------------------------------------------------
function NO (N : NO_T) return float is
begin
return N.Origin;
end NO;
-- ------------------------------------------------------------------------
procedure Set_NI (N : out NI_T; Inf : float) is
begin
N.Inf := Inf;
end Set_NI;
-- -------------------------------------------------------------------------
procedure Set_NO (N : out NO_T; Origin : float) is
begin
N.Origin := Origin;
end Set_NO;
-- -------------------------------------------------------------------------
end GA_Base_Types;
|
reznikmm/matreshka | Ada | 3,729 | ads | ------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- Open Document Toolkit --
-- --
-- Runtime Library Component --
-- --
------------------------------------------------------------------------------
-- --
-- Copyright © 2014, Vadim Godunko <[email protected]> --
-- All rights reserved. --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions --
-- are met: --
-- --
-- * Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- --
-- * Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in the --
-- documentation and/or other materials provided with the distribution. --
-- --
-- * Neither the name of the Vadim Godunko, IE nor the names of its --
-- contributors may be used to endorse or promote products derived from --
-- this software without specific prior written permission. --
-- --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR --
-- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
-- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED --
-- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR --
-- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF --
-- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING --
-- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS --
-- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
-- --
------------------------------------------------------------------------------
-- $Revision$ $Date$
------------------------------------------------------------------------------
with XML.DOM.Attributes;
package ODF.DOM.Style_Leader_Style_Attributes is
pragma Preelaborate;
type ODF_Style_Leader_Style_Attribute is limited interface
and XML.DOM.Attributes.DOM_Attribute;
type ODF_Style_Leader_Style_Attribute_Access is
access all ODF_Style_Leader_Style_Attribute'Class
with Storage_Size => 0;
end ODF.DOM.Style_Leader_Style_Attributes;
|
mapcode-foundation/mapcode-ada | Ada | 2,097 | adb | -- -----------------------------------------------------------------------------
-- Copyright (C) 2003-2019 Stichting Mapcode Foundation (http://www.mapcode.com)
--
-- Licensed under the Apache License, Version 2.0 (the "License");
-- you may not use this file except in compliance with the License.
-- You may obtain a copy of the License at
--
-- http://www.apache.org/licenses/LICENSE-2.0
--
-- Unless required by applicable law or agreed to in writing, software
-- distributed under the License is distributed on an "AS IS" BASIS,
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-- See the License for the specific language governing permissions and
-- limitations under the License.
-- -----------------------------------------------------------------------------
package body Language_Utils is
-- Make Unicode_Sequence
function To_Unicode (Str : String) return Unicode_Sequence is
Res : Unicode_Sequence (1 .. Str'Length);
begin
for I in Str'Range loop
Res(I - Str'First + 1) := Character'Pos (Str(I));
end loop;
return Res;
end To_Unicode;
-- Make character set
function To_Set (Code : Char_Code) return Char_Set is
Res : Char_Set;
begin
for I in Code'Range loop
Res (I - Code'First + 1) := Wide_Character'Val (Code(I));
end loop;
return Res;
end To_Set;
-- Make descriptor
function Build_Desc (Name : Unicode_Sequence;
Code : Char_Code) return Language_Desc is
Res : Language_Desc (Name'Length);
begin
Res.Name.Txt := Name;
Res.Set := To_Set (Code);
-- Store first and last character of the set
Res.First := Wide_Character'Last;
Res.Last := Wide_Character'First;
for C of Res.Set loop
if C > '9' and then C /= 'I' and then C /= 'O' then
-- Discard characterers that are shared
if C < Res.First then
Res.First := C;
end if;
if C > '9' and then C > Res.Last then
Res.Last := C;
end if;
end if;
end loop;
return Res;
end Build_Desc;
end Language_Utils;
|
sebsgit/textproc | Ada | 311 | ads | with PixelArray;
package Morphology is
function erode(image: PixelArray.ImagePlane; size: Positive) return PixelArray.ImagePlane
with Pre => size mod 2 /= 0;
function dilate(image: PixelArray.ImagePlane; size: Positive) return PixelArray.ImagePlane
with Pre => size mod 2 /= 0;
end Morphology;
|
Tim-Tom/project-euler | Ada | 58 | ads | package Problem_45 is
procedure Solve;
end Problem_45;
|
AdaCore/spat | Ada | 3,015 | ads | ------------------------------------------------------------------------------
-- Copyright (C) 2020 by Heisenbug Ltd. ([email protected])
--
-- This work is free. You can redistribute it and/or modify it under the
-- terms of the Do What The Fuck You Want To Public License, Version 2,
-- as published by Sam Hocevar. See the LICENSE file for more details.
------------------------------------------------------------------------------
pragma License (Unrestricted);
------------------------------------------------------------------------------
--
-- SPARK Proof Analysis Tool
--
-- S.P.A.T. - Message output utilities
--
------------------------------------------------------------------------------
with Ada.Exceptions;
package SPAT.Log is
---------------------------------------------------------------------------
-- Warning
--
-- Print a warning message to Standard_Error.
---------------------------------------------------------------------------
procedure Warning (Message : in String);
---------------------------------------------------------------------------
-- Error
--
-- Print a error message to Standard_Error.
---------------------------------------------------------------------------
procedure Error (Message : in String);
---------------------------------------------------------------------------
-- Message
--
-- Print a message to Standard_Output.
---------------------------------------------------------------------------
procedure Message (Message : in String;
New_Line : in Boolean := True);
---------------------------------------------------------------------------
-- Debug
--
-- Print a debug message to Standard_Output if the command line parameter
-- --verbose is set.
---------------------------------------------------------------------------
procedure Debug (Message : in String;
New_Line : in Boolean := True);
---------------------------------------------------------------------------
-- Debug_Enabled
--
-- Returns True if Debug would output something.
---------------------------------------------------------------------------
function Debug_Enabled return Boolean;
---------------------------------------------------------------------------
-- Dump_Exception
--
-- Print the error Message followed by exception information to
-- Standard_Error.
--
-- The (symbolic) stacktrace only works if the binder option "-E" has been
-- enabled when compiling the program.
--
-- The optional parameter File can be used to also print a file name, if
-- the error may have been related to a file.
---------------------------------------------------------------------------
procedure Dump_Exception (E : in Ada.Exceptions.Exception_Occurrence;
Message : in String;
File : in String := "");
end SPAT.Log;
|
ekoeppen/STM32_Generic_Ada_Drivers | Ada | 2,208 | adb | with System;
with Ada.Synchronous_Task_Control; use Ada.Synchronous_Task_Control;
with STM32_SVD; use STM32_SVD;
with STM32_SVD.PWR; use STM32_SVD.PWR;
with STM32_SVD.RCC; use STM32_SVD.RCC;
with STM32_SVD.GPIO; use STM32_SVD.GPIO;
with STM32GD.RTC;
with STM32GD.Board; use STM32GD.Board;
with Drivers.Text_IO;
with RTC_IRQ;
procedure Main is
package RTC renames STM32GD.RTC;
package Text_IO is new Drivers.Text_IO (USART => STM32GD.Board.USART);
use Text_IO;
procedure Print_Date is new STM32GD.RTC.Print (Put => Text_IO.Put);
procedure Enable_Stop_Mode (Low_Power : Boolean) is
SCB_SCR : aliased STM32_SVD.UInt32
with Address => System'To_Address (16#E000ED10#);
SCR : UInt32;
begin
PWR_Periph.CR.LPDS := (if Low_Power then 1 else 0);
PWR_Periph.CR.PDDS := 0;
SCR := SCB_SCR or 2#100#;
SCB_SCR := SCR;
end Enable_Stop_Mode;
procedure Disable_Stop_Mode is
SCB_SCR : aliased STM32_SVD.UInt32
with Address => System'To_Address (16#E000ED10#);
SCR : UInt32;
begin
SCR := SCB_SCR and not 2#100#;
SCB_SCR := SCR;
end Disable_Stop_Mode;
procedure Disable_Peripherals is
begin
RCC_Periph.AHBENR.IOPAEN := 1;
RCC_Periph.AHBENR.IOPBEN := 1;
RCC_Periph.AHBENR.IOPCEN := 1;
RCC_Periph.AHBENR.IOPDEN := 1;
RCC_Periph.AHBENR.IOPFEN := 1;
GPIOA_Periph.MODER.Val := 16#28FF_FFFF#;
GPIOB_Periph.MODER.Val := 16#FFFF_FFFF#;
GPIOC_Periph.MODER.Val := 16#FFFF_FFFF#;
GPIOD_Periph.MODER.Val := 16#FFFF_FFFF#;
GPIOF_Periph.MODER.Val := 16#FFFF_FFFF#;
RCC_Periph.AHBENR.IOPAEN := 0;
RCC_Periph.AHBENR.IOPBEN := 0;
RCC_Periph.AHBENR.IOPCEN := 0;
RCC_Periph.AHBENR.IOPDEN := 0;
RCC_Periph.AHBENR.IOPFEN := 0;
end Disable_Peripherals;
Date_Time : RTC.Date_Time_Type;
begin
Init;
RTC.Init;
LED2.Set;
-- Enable_Stop_Mode (True);
loop
Print_Date (Date_Time);
RTC.Read (Date_Time);
RTC.Add_Seconds (Date_Time, 1);
RTC.Set_Alarm (Date_Time);
Set_False (RTC_IRQ.Alarm_Occurred);
Suspend_Until_True (RTC_IRQ.Alarm_Occurred);
LED2.Toggle;
end loop;
end Main;
|
AaronC98/PlaneSystem | Ada | 4,946 | ads | ------------------------------------------------------------------------------
-- Ada Web Server --
-- --
-- Copyright (C) 2005-2015, 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.IO_Exceptions;
with AWS.Resources;
with AWS.Response;
with AWS.Status;
package AWS.Server.HTTP_Utils is
Name_Error : exception renames Ada.IO_Exceptions.Name_Error;
Device_Error : exception renames Ada.IO_Exceptions.Device_Error;
Wrong_Request_Line : exception;
-- Raised when a non well formed request line is detected
procedure Answer_To_Client
(HTTP_Server : in out AWS.Server.HTTP;
Line_Index : Positive;
C_Stat : in out AWS.Status.Data;
Socket_Taken : in out Boolean;
Will_Close : in out Boolean);
-- This procedure use the C_Stat status data to build the correct answer
-- to the client. If Force_Answer is not Empty it will be sent back to the
-- client's browser, otherwise the answer will be retrieved from user's
-- callback.
procedure Get_Message_Data
(HTTP_Server : AWS.Server.HTTP;
Line_Index : Positive;
C_Stat : in out AWS.Status.Data;
Expect_100 : Boolean);
-- If the client sent us some data read them.
-- This procedure fill in the C_Stat status data.
procedure Get_Request_Line (C_Stat : in out AWS.Status.Data);
-- Parse HTTP request line. This procedure fills in the C_Stat status
-- data.
procedure Parse_Request_Line
(Command : String; C_Stat : in out AWS.Status.Data);
-- Parse the request line:
-- Request-Line = Method SP Request-URI SP HTTP-Version CRLF
procedure Send
(Answer : in out Response.Data;
HTTP_Server : in out AWS.Server.HTTP;
Line_Index : Positive;
C_Stat : AWS.Status.Data;
Socket_Taken : in out Boolean;
Will_Close : in out Boolean);
-- Send Answer to the client's browser
procedure Send_Resource
(Answer : in out Response.Data;
Method : Status.Request_Method;
File : in out Resources.File_Type;
Length : in out Resources.Content_Length_Type;
HTTP_Server : AWS.Server.HTTP;
Line_Index : Positive;
C_Stat : AWS.Status.Data);
-- Send the last header line Transfer-Encoding and Content_Length if
-- necessary and send the file content. Length is the size of the
-- resource/file as known before the call, Length returned value is the
-- actual number of bytes sent. Close the resource only if Close is set to
-- True.
procedure Set_Close_Status
(C_Stat : AWS.Status.Data;
Keep_Alive : Boolean;
Will_Close : in out Boolean);
-- Set Will_Close properly depending on the HTTP version and current
-- request status. This routine must be called after Get_Message_header as
-- the request header must have been parsed.
end AWS.Server.HTTP_Utils;
|
stcarrez/bbox-ada-api | Ada | 1,707 | ads | -----------------------------------------------------------------------
-- druss-commands-status -- Druss status commands
-- Copyright (C) 2017, 2018, 2019, 2021 Stephane Carrez
-- Written by Stephane Carrez ([email protected])
--
-- Licensed under the Apache License, Version 2.0 (the "License");
-- you may not use this file except in compliance with the License.
-- You may obtain a copy of the License at
--
-- http://www.apache.org/licenses/LICENSE-2.0
--
-- Unless required by applicable law or agreed to in writing, software
-- distributed under the License is distributed on an "AS IS" BASIS,
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-- See the License for the specific language governing permissions and
-- limitations under the License.
-----------------------------------------------------------------------
package Druss.Commands.Status is
type Command_Type is new Druss.Commands.Drivers.Command_Type with null record;
procedure Do_Status (Command : in Command_Type;
Args : in Argument_List'Class;
Context : in out Context_Type);
-- Execute a status command to report information about the Bbox.
overriding
procedure Execute (Command : in out Command_Type;
Name : in String;
Args : in Argument_List'Class;
Context : in out Context_Type);
-- Write the help associated with the command.
overriding
procedure Help (Command : in out Command_Type;
Name : in String;
Context : in out Context_Type);
end Druss.Commands.Status;
|
reznikmm/matreshka | Ada | 4,965 | ads | ------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- Ada Modeling Framework --
-- --
-- Runtime Library Component --
-- --
------------------------------------------------------------------------------
-- --
-- Copyright © 2012-2013, Vadim Godunko <[email protected]> --
-- All rights reserved. --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions --
-- are met: --
-- --
-- * Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- --
-- * Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in the --
-- documentation and/or other materials provided with the distribution. --
-- --
-- * Neither the name of the Vadim Godunko, IE nor the names of its --
-- contributors may be used to endorse or promote products derived from --
-- this software without specific prior written permission. --
-- --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR --
-- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
-- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED --
-- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR --
-- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF --
-- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING --
-- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS --
-- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
-- --
------------------------------------------------------------------------------
-- $Revision$ $Date$
------------------------------------------------------------------------------
-- This file is generated, don't edit it.
------------------------------------------------------------------------------
with AMF.Generic_Collections;
package AMF.OCL.Tuple_Types.Collections is
pragma Preelaborate;
package OCL_Tuple_Type_Collections is
new AMF.Generic_Collections
(OCL_Tuple_Type,
OCL_Tuple_Type_Access);
type Set_Of_OCL_Tuple_Type is
new OCL_Tuple_Type_Collections.Set with null record;
Empty_Set_Of_OCL_Tuple_Type : constant Set_Of_OCL_Tuple_Type;
type Ordered_Set_Of_OCL_Tuple_Type is
new OCL_Tuple_Type_Collections.Ordered_Set with null record;
Empty_Ordered_Set_Of_OCL_Tuple_Type : constant Ordered_Set_Of_OCL_Tuple_Type;
type Bag_Of_OCL_Tuple_Type is
new OCL_Tuple_Type_Collections.Bag with null record;
Empty_Bag_Of_OCL_Tuple_Type : constant Bag_Of_OCL_Tuple_Type;
type Sequence_Of_OCL_Tuple_Type is
new OCL_Tuple_Type_Collections.Sequence with null record;
Empty_Sequence_Of_OCL_Tuple_Type : constant Sequence_Of_OCL_Tuple_Type;
private
Empty_Set_Of_OCL_Tuple_Type : constant Set_Of_OCL_Tuple_Type
:= (OCL_Tuple_Type_Collections.Set with null record);
Empty_Ordered_Set_Of_OCL_Tuple_Type : constant Ordered_Set_Of_OCL_Tuple_Type
:= (OCL_Tuple_Type_Collections.Ordered_Set with null record);
Empty_Bag_Of_OCL_Tuple_Type : constant Bag_Of_OCL_Tuple_Type
:= (OCL_Tuple_Type_Collections.Bag with null record);
Empty_Sequence_Of_OCL_Tuple_Type : constant Sequence_Of_OCL_Tuple_Type
:= (OCL_Tuple_Type_Collections.Sequence with null record);
end AMF.OCL.Tuple_Types.Collections;
|
xeenta/learning-ada | Ada | 1,274 | adb | with
Ada.Text_IO,
Ada.Containers.Doubly_Linked_Lists;
use Ada.Text_IO;
procedure dll is
Equal_Limit : constant := 10;
generic
Threshold : in Integer := 0;
function Special_Equal (Left, Right : Integer) return Boolean;
function Special_Equal (Left, Right : Integer) return Boolean is
begin
return abs (Left - Right) <= Threshold;
end Special_Equal;
function Int_Cmp_Fuzzy is new Special_Equal (Threshold => Equal_Limit);
package Integer_List is new Ada.Containers.Doubly_Linked_Lists
(Element_Type => Integer,
"=" => Int_Cmp_Fuzzy);
package Int_IO is new Ada.Text_IO.Integer_IO (Integer);
use Int_IO;
A_List : Integer_List.List;
begin
-- we can write it like this: Pkg.Subprogram (O, ...)
Integer_List.Append (A_List, 10);
Integer_List.Append (A_List, 200);
Integer_List.Append (A_List, 220);
for E of A_List loop
Put (E); New_Line;
end loop;
-- or like this: O.Subprogram (...)
if A_List.Contains (200) then
Put_Line ("Contains 200");
end if;
-- we haven't put a 210 into the list, but our fuzzy cmp
-- says we did.
if A_List.Contains (210) then
Put_Line ("it seems there's a 210 too");
end if;
end dll;
|
zhmu/ananas | Ada | 589 | adb | -- { dg-do run }
with GNAT.Expect.TTY;
with GNAT.OS_Lib;
procedure Expect4 is
Pid : GNAT.Expect.TTY.TTY_Process_Descriptor;
Args : GNAT.OS_Lib.Argument_List (1 .. 0);
Result : GNAT.Expect.Expect_Match;
begin
Pid.Non_Blocking_Spawn ("true", Args);
begin
Pid.Expect (Result, ".*");
raise Program_Error;
exception
when GNAT.Expect.Process_Died =>
null;
end;
begin
Pid.Expect (Result, ".*");
raise Program_Error;
exception
when GNAT.Expect.Process_Died =>
null;
end;
Pid.Close;
end Expect4; |
reznikmm/matreshka | Ada | 4,680 | adb | ------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- Open Document Toolkit --
-- --
-- Runtime Library Component --
-- --
------------------------------------------------------------------------------
-- --
-- Copyright © 2014, Vadim Godunko <[email protected]> --
-- All rights reserved. --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions --
-- are met: --
-- --
-- * Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- --
-- * Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in the --
-- documentation and/or other materials provided with the distribution. --
-- --
-- * Neither the name of the Vadim Godunko, IE nor the names of its --
-- contributors may be used to endorse or promote products derived from --
-- this software without specific prior written permission. --
-- --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR --
-- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
-- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED --
-- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR --
-- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF --
-- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING --
-- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS --
-- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
-- --
------------------------------------------------------------------------------
-- $Revision$ $Date$
------------------------------------------------------------------------------
with Matreshka.DOM_Documents;
with Matreshka.ODF_String_Constants;
with ODF.DOM.Iterators;
with ODF.DOM.Visitors;
package body Matreshka.ODF_Style.Font_Style_Complex_Attributes is
------------
-- Create --
------------
overriding function Create
(Parameters : not null access Matreshka.DOM_Attributes.Attribute_L2_Parameters)
return Style_Font_Style_Complex_Attribute_Node is
begin
return Self : Style_Font_Style_Complex_Attribute_Node do
Matreshka.ODF_Style.Constructors.Initialize
(Self'Unchecked_Access,
Parameters.Document,
Matreshka.ODF_String_Constants.Style_Prefix);
end return;
end Create;
--------------------
-- Get_Local_Name --
--------------------
overriding function Get_Local_Name
(Self : not null access constant Style_Font_Style_Complex_Attribute_Node)
return League.Strings.Universal_String
is
pragma Unreferenced (Self);
begin
return Matreshka.ODF_String_Constants.Font_Style_Complex_Attribute;
end Get_Local_Name;
begin
Matreshka.DOM_Documents.Register_Attribute
(Matreshka.ODF_String_Constants.Style_URI,
Matreshka.ODF_String_Constants.Font_Style_Complex_Attribute,
Style_Font_Style_Complex_Attribute_Node'Tag);
end Matreshka.ODF_Style.Font_Style_Complex_Attributes;
|
stcarrez/bbox-ada-api | Ada | 2,412 | ads | -----------------------------------------------------------------------
-- druss-commands-bboxes -- Commands to manage the bboxes
-- Copyright (C) 2017, 2018, 2019, 2021 Stephane Carrez
-- Written by Stephane Carrez ([email protected])
--
-- Licensed under the Apache License, Version 2.0 (the "License");
-- you may not use this file except in compliance with the License.
-- You may obtain a copy of the License at
--
-- http://www.apache.org/licenses/LICENSE-2.0
--
-- Unless required by applicable law or agreed to in writing, software
-- distributed under the License is distributed on an "AS IS" BASIS,
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-- See the License for the specific language governing permissions and
-- limitations under the License.
-----------------------------------------------------------------------
package Druss.Commands.Bboxes is
type Command_Type is new Druss.Commands.Drivers.Command_Type with null record;
procedure Discover (Command : in Command_Type;
Context : in out Context_Type);
-- Add the bbox with the given IP address.
procedure Add_Bbox (Command : in Command_Type;
IP : in String;
Context : in out Context_Type);
-- Enable or disable the bbox management by Druss.
procedure Do_Enable (Command : in Command_Type;
Args : in Util.Commands.Argument_List'Class;
Context : in out Context_Type);
-- Set the password to be used by the Bbox API to connect to the box.
procedure Do_Password (Command : in Command_Type;
Args : in Util.Commands.Argument_List'Class;
Context : in out Context_Type);
-- Execute the command with the arguments. The command name is passed with the command
-- arguments.
overriding
procedure Execute (Command : in out Command_Type;
Name : in String;
Args : in Druss.Commands.Argument_List'Class;
Context : in out Context_Type);
-- Write the help associated with the command.
overriding
procedure Help (Command : in out Command_Type;
Name : in String;
Context : in out Context_Type);
end Druss.Commands.Bboxes;
|
jrmarino/AdaBase | Ada | 492 | ads | -- Used for all testcases for MySQL driver
with AdaBase.Driver.Base.MySQL;
with AdaBase.Statement.Base.MySQL;
package Connect is
-- All specific drivers renamed to "Database_Driver"
subtype Database_Driver is AdaBase.Driver.Base.MySQL.MySQL_Driver;
subtype Stmt_Type is AdaBase.Statement.Base.MySQL.MySQL_statement;
subtype Stmt_Type_access is
AdaBase.Statement.Base.MySQL.MySQL_statement_access;
DR : Database_Driver;
procedure connect_database;
end Connect;
|
reznikmm/matreshka | Ada | 7,432 | adb | ------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- Web Framework --
-- --
-- Runtime Library Component --
-- --
------------------------------------------------------------------------------
-- --
-- Copyright © 2015, Vadim Godunko <[email protected]> --
-- All rights reserved. --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions --
-- are met: --
-- --
-- * Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- --
-- * Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in the --
-- documentation and/or other materials provided with the distribution. --
-- --
-- * Neither the name of the Vadim Godunko, IE nor the names of its --
-- contributors may be used to endorse or promote products derived from --
-- this software without specific prior written permission. --
-- --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR --
-- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
-- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED --
-- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR --
-- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF --
-- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING --
-- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS --
-- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
-- --
------------------------------------------------------------------------------
-- $Revision$ $Date$
------------------------------------------------------------------------------
with League.Holders.JSON_Objects;
with League.JSON.Objects;
with League.JSON.Values;
package body AWFC.Accounts.Pages.Signup is
function "+"
(Item : Wide_Wide_String) return League.Strings.Universal_String
renames League.Strings.To_Universal_String;
Signup_Template_Parameters :
constant array (Signup_Error) of League.Strings.Universal_String
:= (Email_Empty => +"emailEmpty",
Email_Used => +"emailUsed");
---------------------
-- Bind_Parameters --
---------------------
overriding procedure Bind_Parameters
(Self : in out Signup_Page_Generator;
Processor : in out XML.Templates.Processors.Template_Processor'Class)
is
use type AWFC.Accounts.Users.User_Access;
Object : League.JSON.Objects.JSON_Object;
User_Object : League.JSON.Objects.JSON_Object;
begin
if Self.User /= null then
Object.Insert (+"hasUser", League.JSON.Values.To_JSON_Value (True));
User_Object.Insert
(+"email", League.JSON.Values.To_JSON_Value (Self.User.Get_Email));
User_Object.Insert
(+"exists", League.JSON.Values.To_JSON_Value (True));
User_Object.Insert
(+"enabled",
League.JSON.Values.To_JSON_Value (Self.User.Is_Enabled));
elsif not Self.Email.Is_Empty then
Object.Insert (+"hasUser", League.JSON.Values.To_JSON_Value (True));
User_Object.Insert
(+"email", League.JSON.Values.To_JSON_Value (Self.Email));
User_Object.Insert
(+"exists", League.JSON.Values.To_JSON_Value (False));
else
Object.Insert (+"hasUser", League.JSON.Values.To_JSON_Value (False));
end if;
Object.Insert (+"user", User_Object.To_JSON_Value);
Object.Insert (+"done", League.JSON.Values.To_JSON_Value (Self.Done));
Object.Insert
(+"hasErrors",
League.JSON.Values.To_JSON_Value (Self.Errors /= No_Signup_Errors));
for Error in Signup_Errors'Range loop
Object.Insert
(Signup_Template_Parameters (Error),
League.JSON.Values.To_JSON_Value (Self.Errors (Error)));
end loop;
Processor.Set_Parameter
(+"account", League.Holders.JSON_Objects.To_Holder (Object));
end Bind_Parameters;
-----------------
-- Render_Done --
-----------------
function Render_Done
(Self : in out Signup_Page_Generator'Class;
User : not null AWFC.Accounts.Users.User_Access)
return League.Strings.Universal_String is
begin
Self.Email := League.Strings.Empty_Universal_String;
Self.User := User;
Self.Errors := No_Signup_Errors;
Self.Done := True;
return Self.Render;
end Render_Done;
------------------
-- Render_Error --
------------------
function Render_Error
(Self : in out Signup_Page_Generator'Class;
Email : League.Strings.Universal_String;
Errors : Signup_Errors)
return League.Strings.Universal_String is
begin
Self.Email := Email;
Self.User := null;
Self.Errors := Errors;
Self.Done := False;
return Self.Render;
end Render_Error;
------------------
-- Render_Error --
------------------
function Render_Error
(Self : in out Signup_Page_Generator'Class;
User : not null AWFC.Accounts.Users.User_Access;
Errors : Signup_Errors)
return League.Strings.Universal_String is
begin
Self.Email := League.Strings.Empty_Universal_String;
Self.User := User;
Self.Errors := Errors;
Self.Done := False;
return Self.Render;
end Render_Error;
-----------------
-- Render_Form --
-----------------
function Render_Form
(Self : in out Signup_Page_Generator'Class)
return League.Strings.Universal_String is
begin
Self.Email := League.Strings.Empty_Universal_String;
Self.User := null;
Self.Errors := No_Signup_Errors;
Self.Done := False;
return Self.Render;
end Render_Form;
end AWFC.Accounts.Pages.Signup;
|
reznikmm/clic | Ada | 5,668 | ads | with AAA.Strings;
with TOML;
private with Ada.Containers.Hashed_Maps;
private with Ada.Strings.Unbounded.Hash;
package CLIC.Config with Preelaborate is
function Is_Valid_Config_Key (Key : String) return Boolean
is ((for all C of Key => C in '0' .. '9' | 'a' .. 'z' | 'A' .. 'Z' |
'-' | '.' | '_')
and then Key (Key'First) not in '-' | '.' | '_'
and then Key (Key'Last) not in '-' | '.' | '_'
and then not AAA.Strings.Contains (Key, ".."));
-- Rule that define a valid configuration key. Dots are used to separate
-- levels of configuration groups.
-- eg:
-- user.login
-- user.email
subtype Config_Key is String
with Dynamic_Predicate => Is_Valid_Config_Key (Config_Key);
type Instance is tagged limited private;
pragma Preelaborable_Initialization (Instance);
type Check_Import is
access function (Key : Config_Key; Value : TOML.TOML_Value)
return Boolean;
-- Return False when a Key/Value combination is not valid. Can be used to
-- check formating of string value like email address for instance.
procedure Import (This : in out Instance;
Table : TOML.TOML_Value;
Origin : String;
Check : Check_Import := null);
-- Import configuration from the TOML table.
--
-- The Origin parameter is used in error messages and when listing config
-- values to help the user identify the origin of the value. It can be just
-- a word (e.g. local vs global), or the full path to the config file.
--
-- When a Check function is provided, it will be called for each imported
-- config key/value. If Check return False, the value is ignored and not
-- imported in the configuration. Import will print an Error message saying
-- that the key/value is ignored. In addition the Check function can also
-- print an error message explaining why the key/value is invalid.
function Defined (This : Instance; Key : Config_Key) return Boolean;
-- Return True if a value is defined for the given key
function Get_As_String (This : Instance; Key : Config_Key) return String;
-- Return a string representation of the value for the given configuration
-- Key. If the key is not defined, an empty string is returned.
function Get (This : Instance;
Key : Config_Key;
Default : Boolean)
return Boolean;
-- Return the Boolean value for the given configuration Key. If the key is
-- not defined, the Default value is returned. If the key is defined but
-- not as a Boolean, an error message is displayed and the Default value
-- is returned.
function Get (This : Instance;
Key : Config_Key;
Default : String)
return String;
-- Return the String value for the given configuration Key. If the key is
-- not defined, the Default value is returned. If the key is defined but
-- not as a String, an error message is displayed and the Default value
-- is returned.
function Get (This : Instance;
Key : Config_Key;
Default : TOML.Any_Integer)
return TOML.Any_Integer;
-- Return the Integer value for the given configuration Key. If the key is
-- not defined, the Default value is returned. If the key is defined but
-- not as an Integer, an error message is displayed and the Default value
-- is returned.
function Get (This : Instance;
Key : Config_Key;
Default : TOML.Any_Float)
return TOML.Any_Float;
-- Return the Float value for the given configuration Key. If the key is
-- not defined, the Default value is returned. If the key is defined but
-- not as an Float, an error message is displayed and the Default value
-- is returned.
procedure Clear (This : in out Instance);
-- Remove all configuration keys
function Image (Val : TOML.TOML_Value) return String;
private
generic
type Return_Type (<>) is private;
Expected_TOML_Kind : TOML.Any_Value_Kind;
Type_Name : String;
with function TOML_As_Return_Type (Value : TOML.TOML_Value)
return Return_Type;
with function Image (V : Return_Type) return String;
function Get_With_Default_Gen (This : Instance;
Key : Config_Key;
Default : Return_Type)
return Return_Type;
function To_TOML_Value (Str : String) return TOML.TOML_Value;
-- Use the TOML parser to convert the string Str. If Str is not a valid
-- TOML value, No_TOML_Value is returned.
type Config_Value is record
Value : TOML.TOML_Value;
Origin : Ada.Strings.Unbounded.Unbounded_String;
end record;
function No_Config_Value return Config_Value;
package Config_Maps is new Ada.Containers.Hashed_Maps
(Key_Type => Ada.Strings.Unbounded.Unbounded_String,
Element_Type => Config_Value,
Hash => Ada.Strings.Unbounded.Hash,
Equivalent_Keys => Ada.Strings.Unbounded."=");
function "+" (Source : String) return Ada.Strings.Unbounded.Unbounded_String
renames Ada.Strings.Unbounded.To_Unbounded_String;
type Instance is tagged limited record
Config_Map : Config_Maps.Map;
end record;
function Get (This : Instance; Key : Config_Key) return Config_Value;
end CLIC.Config;
|
throwException/genode-world | Ada | 334 | adb | with GNAT.IO; use GNAT.IO;
package body Except
is
procedure Do_Something
is
begin
raise Test_Exception;
end Do_Something;
procedure Do_Sth_2
is
begin
begin
Do_Something;
exception
when others => Put_Line ("Exception caught (inner)");
end;
end Do_Sth_2;
end Except;
|
reznikmm/matreshka | Ada | 3,845 | ads | ------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- Web Framework --
-- --
-- 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 Servlet.HTTP_Requests;
package Servlet.FastCGI_Requests is
type FastCGI_Servlet_Request is
limited new Servlet.HTTP_Requests.HTTP_Servlet_Request with private;
private
type FastCGI_Servlet_Request is
limited new Servlet.HTTP_Requests.HTTP_Servlet_Request with null record;
overriding function Is_Async_Supported
(Self : not null access FastCGI_Servlet_Request) return Boolean;
-- Checks if this request supports asynchronous operation.
end Servlet.FastCGI_Requests;
|
ekoeppen/STM32_Generic_Ada_Drivers | Ada | 4,642 | adb | with System;
with STM32_SVD; use STM32_SVD;
with STM32_SVD.RCC; use STM32_SVD.RCC;
with STM32_SVD.ADC; use STM32_SVD.ADC;
with STM32_SVD.PWR; use STM32_SVD.PWR;
with STM32_SVD.GPIO; use STM32_SVD.GPIO;
with STM32GD.Board; use STM32GD.Board;
with STM32GD.GPIO;
package body Peripherals is
procedure Idle_Hook;
pragma Export (
Convention => C,
Entity => Idle_Hook,
External_Name => "vApplicationIdleHook");
procedure Idle_Hook is
begin
STM32GD.WFI;
end Idle_Hook;
procedure Init is
begin
Power_Up;
RFM69_RESET.Clear;
Radio.Init;
Enable_Stop_Mode (True);
end Init;
procedure Enter_Stop_Mode is
begin
Enable_Stop_Mode (True);
STM32GD.WFI;
end Enter_Stop_Mode;
procedure Enable_Stop_Mode (Low_Power : Boolean) is
SCB_SCR : aliased STM32_SVD.UInt32
with Address => System'To_Address (16#E000ED10#);
SCR : UInt32;
begin
PWR_Periph.CR.CWUF := 1;
PWR_Periph.CR.LPDS := (if Low_Power then 1 else 0);
PWR_Periph.CR.PDDS := 0;
SCR := SCB_SCR or 2#100#;
SCB_SCR := SCR;
end Enable_Stop_Mode;
procedure Disable_Stop_Mode is
SCB_SCR : aliased STM32_SVD.UInt32
with Address => System'To_Address (16#E000ED10#);
SCR : UInt32;
begin
SCR := SCB_SCR and not 2#100#;
SCB_SCR := SCR;
end Disable_Stop_Mode;
procedure Power_Up is
begin
STM32GD.Board.Init;
RCC_Periph.APB2ENR.ADCEN := 1;
end Power_Up;
procedure Power_Down_New is
begin
Radio.Power_Down;
RCC_Periph.AHBENR.IOPAEN := 1;
RCC_Periph.AHBENR.IOPBEN := 1;
RCC_Periph.AHBENR.IOPCEN := 1;
RCC_Periph.AHBENR.IOPDEN := 1;
RCC_Periph.AHBENR.IOPFEN := 1;
GPIOA_Periph.MODER.Val := 16#0000_0000#;
GPIOB_Periph.MODER.Val := 16#0000_0000#;
GPIOC_Periph.MODER.Val := 16#0000_0000#;
GPIOD_Periph.MODER.Val := 16#0000_0000#;
GPIOF_Periph.MODER.Val := 16#0000_0000#;
GPIOA_Periph.PUPDR.Val := 16#5555_5565#;
GPIOB_Periph.PUPDR.Val := 16#AAAA_AAAA#;
GPIOC_Periph.PUPDR.Val := 16#AAAA_AAAA#;
GPIOD_Periph.PUPDR.Val := 16#AAAA_AAAA#;
GPIOF_Periph.PUPDR.Val := 16#AAAA_AAAA#;
RCC_Periph.AHBENR.IOPAEN := 0;
RCC_Periph.AHBENR.IOPBEN := 0;
RCC_Periph.AHBENR.IOPCEN := 0;
RCC_Periph.AHBENR.IOPDEN := 0;
RCC_Periph.AHBENR.IOPFEN := 0;
RCC_Periph.APB2ENR.USART1EN := 0;
RCC_Periph.APB2ENR.SPI1EN := 0;
RCC_Periph.APB1ENR.I2C1EN := 0;
RCC_Periph.AHBENR.DMAEN := 0;
RCC_Periph.APB2ENR.ADCEN := 0;
end Power_Down_New;
procedure Power_Down is
begin
Radio.Power_Down;
RCC_Periph.AHBENR.IOPAEN := 1;
RCC_Periph.AHBENR.IOPBEN := 1;
RCC_Periph.AHBENR.IOPCEN := 1;
RCC_Periph.AHBENR.IOPDEN := 1;
RCC_Periph.AHBENR.IOPFEN := 1;
GPIOA_Periph.MODER.Val := 16#FFFF_FFFF#;
GPIOB_Periph.MODER.Val := 16#FFFF_FFFF#;
GPIOC_Periph.MODER.Val := 16#FFFF_FFFF#;
GPIOD_Periph.MODER.Val := 16#FFFF_FFFF#;
GPIOF_Periph.MODER.Val := 16#FFFF_FFFF#;
MOSI.Set_Mode (STM32GD.GPIO.Mode_In);
MOSI.Set_Pull_Resistor (STM32GD.GPIO.Pull_Down);
MISO.Set_Mode (STM32GD.GPIO.Mode_In);
MISO.Set_Pull_Resistor (STM32GD.GPIO.Pull_Down);
SCLK.Set_Mode (STM32GD.GPIO.Mode_In);
SCLK.Set_Pull_Resistor (STM32GD.GPIO.Pull_Up);
CSN.Set_Mode (STM32GD.GPIO.Mode_In);
CSN.Set_Pull_Resistor (STM32GD.GPIO.Pull_Up);
RCC_Periph.AHBENR.IOPAEN := 0;
RCC_Periph.AHBENR.IOPBEN := 0;
RCC_Periph.AHBENR.IOPCEN := 0;
RCC_Periph.AHBENR.IOPDEN := 0;
RCC_Periph.AHBENR.IOPFEN := 0;
RCC_Periph.APB2ENR.USART1EN := 0;
RCC_Periph.APB2ENR.SPI1EN := 0;
RCC_Periph.APB1ENR.I2C1EN := 0;
RCC_Periph.AHBENR.DMAEN := 0;
RCC_Periph.APB2ENR.ADCEN := 0;
end Power_Down;
function Supply_Voltage return Millivolts is
V : Millivolts;
VREFINT_CAL : aliased STM32_SVD.UInt16
with Address => System'To_Address (16#1FFF_F7BA#);
begin
ADC.ADC_Periph.CR.ADEN := 0;
ADC.ADC_Periph.CR.ADEN := 1;
ADC.ADC_Periph.CCR.VREFEN := 1;
while ADC.ADC_Periph.ISR.ADRDY = 0 loop
null;
end loop;
ADC.ADC_Periph.CHSELR.CHSEL.Arr (17) := 1;
ADC.ADC_Periph.CR.ADSTART := 1;
while ADC.ADC_Periph.ISR.EOC = 0 loop
null;
end loop;
V := 3300 * Standard.Integer (VREFINT_CAL) / Standard.Integer (ADC.ADC_Periph.DR.Data);
ADC.ADC_Periph.CR.ADDIS := 1;
return V;
end Supply_Voltage;
end Peripherals;
|
reznikmm/matreshka | Ada | 3,773 | 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_Attributes.Style.Line_Break is
type Style_Line_Break_Node is
new Matreshka.ODF_Attributes.Style.Style_Node_Base with null record;
type Style_Line_Break_Access is access all Style_Line_Break_Node'Class;
overriding function Get_Local_Name
(Self : not null access constant Style_Line_Break_Node)
return League.Strings.Universal_String;
end Matreshka.ODF_Attributes.Style.Line_Break;
|
reznikmm/matreshka | Ada | 3,699 | ads | ------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- Open Document Toolkit --
-- --
-- Runtime Library Component --
-- --
------------------------------------------------------------------------------
-- --
-- Copyright © 2014, Vadim Godunko <[email protected]> --
-- All rights reserved. --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions --
-- are met: --
-- --
-- * Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- --
-- * Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in the --
-- documentation and/or other materials provided with the distribution. --
-- --
-- * Neither the name of the Vadim Godunko, IE nor the names of its --
-- contributors may be used to endorse or promote products derived from --
-- this software without specific prior written permission. --
-- --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR --
-- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
-- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED --
-- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR --
-- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF --
-- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING --
-- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS --
-- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
-- --
------------------------------------------------------------------------------
-- $Revision$ $Date$
------------------------------------------------------------------------------
with XML.DOM.Attributes;
package ODF.DOM.Svg_X_Height_Attributes is
pragma Preelaborate;
type ODF_Svg_X_Height_Attribute is limited interface
and XML.DOM.Attributes.DOM_Attribute;
type ODF_Svg_X_Height_Attribute_Access is
access all ODF_Svg_X_Height_Attribute'Class
with Storage_Size => 0;
end ODF.DOM.Svg_X_Height_Attributes;
|
landgraf/nanomsg-ada | Ada | 2,795 | ads | -- The MIT License (MIT)
-- Copyright (c) 2015 Pavel Zhukov <[email protected]>
-- Permission is hereby granted, free of charge, to any person obtaining a copy
-- of this software and associated documentation files (the "Software"), to deal
-- in the Software without restriction, including without limitation the rights
-- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-- copies of the Software, and to permit persons to whom the Software is
-- furnished to do so, subject to the following conditions:
-- The above copyright notice and this permission notice shall be included in all
-- copies or substantial portions of the Software.
-- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
-- SOFTWARE.
with System;
with Ada.Finalization;
with Ada.Streams;
package Nanomsg.Messages is
type Bytes_Array_Access_T is access all Ada.Streams.Stream_Element_Array with Convention => C, Size => System.Word_Size;
type Message_T is new Ada.Finalization.Controlled with private;
Empty_Message : constant Message_T;
procedure Init (Obj : out Message_T;
Payload : in Bytes_Array_Access_T;
Length : in Integer);
procedure Free (Obj : in out Message_T);
function Is_Empty (Obj : in Message_T) return Boolean;
procedure From_String (Message : out Message_T;
Text : in String);
function Text (Obj : in Message_T) return String;
function Get_Payload (Obj : in Message_T) return Bytes_Array_Access_T;
function Get_Length (Obj : in Message_T) return Natural;
procedure Set_Length (Obj : in out Message_T;
Length : in Natural);
procedure Set_Payload (Obj : in out Message_T;
Payload : Bytes_Array_Access_T);
procedure Set_Payload (Obj : in out Message_T;
Payload : in Ada.Streams.Stream_Element_Array);
private
overriding
procedure Finalize (Obj : in out Message_T);
type Message_T is new Ada.Finalization.Controlled with record
Payload : Bytes_Array_Access_T := null;
Length : Natural;
end record;
Empty_Message : constant Message_T := (Ada.Finalization.Controlled with Payload => null, Length => 0);
end Nanomsg.Messages;
|
xeenta/learning-ada | Ada | 1,459 | adb | with Ada.Text_IO; use Ada.Text_IO;
procedure T_Inv is
package Internal is
type Unknown is private with
Type_Invariant => Isnt_Bad_Luck (Unknown);
function Isnt_Bad_Luck
(S : Unknown) return Boolean;
procedure Assign (S : out Unknown;
D : in Integer);
function To_String (S : Unknown) return String;
private
type Unknown is new Integer;
end Internal;
package body Internal is
procedure Assign (S : out Unknown;
D : in Integer) is
P : constant Unknown := 13;
begin
-- This is ok: this intermediate value won't go outside here
S := P;
Put_Line ("It's ok " & Integer'Image (Integer (S)));
S := Unknown (D + 2 * Integer (P));
Put_Line ("And now?"); -- let's see what happens later
end Assign;
-- 13 is bad luck - indeed it's just like any other number, but
-- you know, people can believe it.
function Isnt_Bad_Luck (S : Unknown) return Boolean
is (S /= 13);
-- This helps
function To_String (S : Unknown) return String is
(Integer'Image (Integer (S)));
end Internal;
V : Internal.Unknown;
begin
Internal.Assign (V, 11);
Put_Line ("Here it is " & Internal.To_String (V));
Internal.Assign (V, -13);
Put_Line ("And another one " & Internal.To_String (V));
end T_Inv;
|
zhmu/ananas | Ada | 293 | ads | package Thunk1_Pkg2 is
type Root is tagged record
I : Integer;
end record;
type Iface is interface;
procedure Op (This : in out Iface; S : String) is abstract;
type Ext is new Root and Iface with null record;
procedure Op (This : in out Ext; S : String);
end Thunk1_Pkg2;
|
thierr26/ada-keystore | Ada | 9,728 | adb | -----------------------------------------------------------------------
-- keystore-verifier -- Toolbox to explore raw content of 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.Strings;
with Ada.IO_Exceptions;
with Ada.Text_IO;
with Util.Strings;
with Util.Systems.Os;
with Util.Systems.Types;
with Util.Systems.Constants;
with Util.Streams.Raw;
with Util.Log.Loggers;
with Util.Encoders;
with Keystore.Buffers;
with Keystore.Marshallers;
with Keystore.IO.Headers;
with Keystore.Passwords.GPG;
package body Keystore.Verifier is
use type Interfaces.Unsigned_16;
use type Interfaces.Unsigned_32;
use type Interfaces.C.int;
use type Ada.Text_IO.Count;
use Ada.Streams;
use Util.Systems.Constants;
use Util.Systems.Types;
use type Keystore.Buffers.Block_Count;
use type Keystore.IO.Storage_Identifier;
function Sys_Error return String;
function Get_Storage_Id (Path : in String) return IO.Storage_Identifier;
procedure Open (Path : in String;
File : in out Util.Streams.Raw.Raw_Stream;
Sign : in Secret_Key;
Header : in out Keystore.IO.Headers.Wallet_Header;
Is_Keystore : out Boolean);
Log : constant Util.Log.Loggers.Logger := Util.Log.Loggers.Create ("Keystore.Verifier");
function Sys_Error return String is
Msg : constant Interfaces.C.Strings.chars_ptr
:= Util.Systems.Os.Strerror (Util.Systems.Os.Errno);
begin
return Interfaces.C.Strings.Value (Msg);
end Sys_Error;
function Get_Storage_Id (Path : in String) return IO.Storage_Identifier is
Pos : Natural;
begin
if Util.Strings.Ends_With (Path, ".dkt") then
Pos := Util.Strings.Rindex (Path, '-');
if Pos = 0 then
return IO.DEFAULT_STORAGE_ID;
end if;
return IO.Storage_Identifier'Value (Path (Pos + 1 .. Path'Last - 4));
else
return IO.DEFAULT_STORAGE_ID;
end if;
exception
when Constraint_Error =>
return IO.DEFAULT_STORAGE_ID;
end Get_Storage_Id;
procedure Open (Path : in String;
File : in out Util.Streams.Raw.Raw_Stream;
Sign : in Secret_Key;
Header : in out Keystore.IO.Headers.Wallet_Header;
Is_Keystore : out Boolean) is
-- Compilation on Windows requires this type visibility but GNAT 2019 complains.
pragma Warnings (Off);
use type Util.Systems.Types.File_Type;
pragma Warnings (On);
Storage_Id : constant IO.Storage_Identifier := Get_Storage_Id (Path);
Fd : Util.Systems.Types.File_Type := Util.Systems.Os.NO_FILE;
P : Interfaces.C.Strings.chars_ptr;
Flags : Interfaces.C.int;
Stat : aliased Util.Systems.Types.Stat_Type;
Result : Integer;
begin
Flags := O_CLOEXEC + O_RDONLY;
P := Interfaces.C.Strings.New_String (Path);
Fd := Util.Systems.Os.Sys_Open (P, Flags, 8#600#);
Interfaces.C.Strings.Free (P);
if Fd = Util.Systems.Os.NO_FILE then
Log.Error ("Cannot open keystore '{0}': {1}", Path, Sys_Error);
raise Ada.IO_Exceptions.Name_Error with Path;
end if;
Result := Util.Systems.Os.Sys_Fstat (Fd, Stat'Access);
if Result /= 0 then
Result := Util.Systems.Os.Sys_Close (Fd);
Log.Error ("Invalid keystore file '{0}': {1}", Path, Sys_Error);
raise Ada.IO_Exceptions.Name_Error with Path;
end if;
Ada.Text_IO.Put ("Path");
Ada.Text_IO.Set_Col (30);
Ada.Text_IO.Put_Line (Path);
Ada.Text_IO.Put ("File size");
Ada.Text_IO.Set_Col (30 - 1);
Ada.Text_IO.Put_Line (off_t'Image (Stat.st_size));
if Stat.st_size mod IO.Block_Size /= 0 then
Result := Util.Systems.Os.Sys_Close (Fd);
Log.Error ("Invalid or truncated keystore file '{0}': size is incorrect", Path);
raise Ada.IO_Exceptions.Name_Error with Path;
end if;
File.Initialize (Fd);
Header.Buffer := Buffers.Allocate ((Storage_Id, IO.HEADER_BLOCK_NUM));
declare
Buf : constant Buffers.Buffer_Accessor := Header.Buffer.Data.Value;
Last : Ada.Streams.Stream_Element_Offset;
Data : Keystore.IO.IO_Block_Type;
begin
File.Read (Data, Last);
if Last /= Data'Last then
Log.Warn ("Header block is too short");
raise Invalid_Keystore;
end if;
Buf.Data := Data (Buf.Data'Range);
Keystore.IO.Headers.Sign_Header (Header, Sign);
if Header.HMAC /= Data (Keystore.IO.BT_HMAC_HEADER_POS .. Data'Last) then
Log.Warn ("Header block HMAC signature is invalid");
-- raise Invalid_Block;
end if;
Keystore.IO.Headers.Read_Header (Header);
Is_Keystore := Storage_Id = IO.DEFAULT_STORAGE_ID;
Ada.Text_IO.Put ("Type");
Ada.Text_IO.Set_Col (30);
if not Is_Keystore then
Ada.Text_IO.Put ("storage");
Ada.Text_IO.Put_Line (IO.Storage_Identifier'Image (Storage_Id));
else
Ada.Text_IO.Put_Line ("keystore");
end if;
end;
end Open;
procedure Print_Information (Path : in String;
Is_Keystore : out Boolean) is
Header : Keystore.IO.Headers.Wallet_Header;
File : Util.Streams.Raw.Raw_Stream;
Sign : Secret_Key (Length => 32);
Data : Ada.Streams.Stream_Element_Array (1 .. 1024);
Last : Ada.Streams.Stream_Element_Offset;
Kind : Header_Slot_Type;
Encode : constant Util.Encoders.Encoder := Util.Encoders.Create ("hex");
begin
Open (Path => Path,
File => File,
Sign => Sign,
Header => Header,
Is_Keystore => Is_Keystore);
Ada.Text_IO.Put ("UUID");
Ada.Text_IO.Set_Col (30);
Ada.Text_IO.Put_Line (To_String (Header.UUID));
Ada.Text_IO.Put ("HMAC");
Ada.Text_IO.Set_Col (30);
Ada.Text_IO.Put_Line (Encode.Encode_Binary (Header.HMAC));
Ada.Text_IO.Put ("Header data");
Ada.Text_IO.Set_Col (29);
Ada.Text_IO.Put_Line (Header_Slot_Count_Type'Image (Header.Data_Count));
for I in 1 .. Header.Data_Count loop
IO.Headers.Get_Header_Data (Header, I, Kind, Data, Last);
Ada.Text_IO.Put (Header_Slot_Count_Type'Image (I));
Ada.Text_IO.Put (" Kind");
Ada.Text_IO.Set_Col (29);
Ada.Text_IO.Put (Header_Slot_Type'Image (Kind));
Ada.Text_IO.Set_Col (39);
Ada.Text_IO.Put (Stream_Element_Offset'Image (Last));
Ada.Text_IO.Put (" bytes ");
Ada.Text_IO.Put_Line (Keystore.Passwords.GPG.Extract_Key_Id (Data));
end loop;
declare
procedure Report;
Buf : constant Buffers.Buffer_Accessor := Header.Buffer.Data.Value;
Last : Ada.Streams.Stream_Element_Offset;
Data : Keystore.IO.IO_Block_Type;
Block : IO.Block_Number := 1;
Buffer : Keystore.Marshallers.Marshaller;
Btype : Interfaces.Unsigned_16;
Esize : Interfaces.Unsigned_16 with Unreferenced;
Id : Interfaces.Unsigned_32;
Current_Id : Interfaces.Unsigned_32 := 0;
Current_Type : Interfaces.Unsigned_16 := 0;
First_Block : IO.Block_Number := 1;
procedure Report is
begin
Ada.Text_IO.Put (IO.Block_Number'Image (First_Block));
if First_Block + 1 < Block then
Ada.Text_IO.Put ("..");
Ada.Text_IO.Put (IO.Block_Number'Image (Block - 1));
end if;
Ada.Text_IO.Put (" Wallet");
Ada.Text_IO.Put (Interfaces.Unsigned_32'Image (Current_Id));
if Current_Type = IO.BT_WALLET_DIRECTORY then
Ada.Text_IO.Put (" Directory");
elsif Current_Type = IO.BT_WALLET_HEADER then
Ada.Text_IO.Put (" Header");
elsif Current_Type = IO.BT_WALLET_DATA then
Ada.Text_IO.Put (" Data");
else
Ada.Text_IO.Put (" Unkown");
end if;
Ada.Text_IO.New_Line;
end Report;
begin
loop
File.Read (Data, Last);
exit when Last /= Data'Last;
Buffer.Buffer := Header.Buffer;
Buf.Data := Data (Buf.Data'Range);
Btype := Marshallers.Get_Header_16 (Buffer);
Esize := Marshallers.Get_Unsigned_16 (Buffer);
Id := Marshallers.Get_Unsigned_32 (Buffer);
if Btype /= Current_Type or Id /= Current_Id then
if Current_Id > 0 then
Report;
end if;
Current_Id := Id;
Current_Type := Btype;
First_Block := Block;
end if;
Block := Block + 1;
end loop;
Report;
end;
end Print_Information;
end Keystore.Verifier;
|
PThierry/ewok-kernel | Ada | 1,854 | 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 interfaces; use interfaces;
with types; use types;
with ada.unchecked_conversion;
with m4.cpu;
package ewok
with spark_mode => on
is
type t_stack_frame is record
R4, R5, R6, R7 : unsigned_32;
R8, R9, R10, R11 : unsigned_32;
exc_return : unsigned_32;
R0, R1, R2, R3 : unsigned_32;
R12 : unsigned_32;
LR : system_address;
PC : system_address;
PSR : m4.cpu.t_PSR_register;
end record
with size => 17 * 32;
type t_stack_frame_access is access t_stack_frame;
function to_stack_frame_access is new ada.unchecked_conversion
(system_address, t_stack_frame_access);
function to_system_address is new ada.unchecked_conversion
(t_stack_frame_access, system_address);
type t_parameters is array (1 .. 4) of unsigned_32 with pack;
type t_parameters_access is access t_parameters;
function to_parameters_access is new ada.unchecked_conversion
(system_address, t_parameters_access);
end ewok;
|
AdaCore/langkit | Ada | 2,140 | adb | with Langkit_Support.Text; use Langkit_Support.Text;
with Libfoolang.Analysis; use Libfoolang.Analysis;
with Libfoolang.Common; use Libfoolang.Common;
with Libfoolang.Public_Converters; use Libfoolang.Public_Converters;
package body Libfoolang.Helpers is
type My_Unit_Provider is new Unit_Provider_Interface with null record;
overriding function Get_Unit_Filename
(Provider : My_Unit_Provider;
Name : Text_Type;
Kind : Analysis_Unit_Kind) return String;
overriding function Get_Unit
(Provider : My_Unit_Provider;
Context : Analysis_Context'Class;
Name : Text_Type;
Kind : Analysis_Unit_Kind;
Charset : String := "";
Reparse : Boolean := False) return Analysis_Unit'Class;
overriding procedure Release (Provider : in out My_Unit_Provider) is null;
-----------------------
-- Get_Unit_Filename --
-----------------------
overriding function Get_Unit_Filename
(Provider : My_Unit_Provider;
Name : Text_Type;
Kind : Analysis_Unit_Kind) return String is
begin
return
Image (Name)
& "-"
& (case Kind is
when Unit_Specification => "spec",
when Unit_Body => "body")
& ".txt";
end Get_Unit_Filename;
--------------
-- Get_Unit --
--------------
overriding function Get_Unit
(Provider : My_Unit_Provider;
Context : Analysis_Context'Class;
Name : Text_Type;
Kind : Analysis_Unit_Kind;
Charset : String := "";
Reparse : Boolean := False) return Analysis_Unit'Class
is
begin
return Analysis_Unit'Class
(Context.Get_From_File
(Provider.Get_Unit_Filename (Name, Kind), Charset, Reparse));
end Get_Unit;
--------------------------
-- Create_Unit_Provider --
--------------------------
function Create_Unit_Provider return Internal_Unit_Provider_Access is
begin
return Wrap_Public_Provider
(Create_Unit_Provider_Reference (My_Unit_Provider'(null record)));
end Create_Unit_Provider;
end Libfoolang.Helpers;
|
reznikmm/matreshka | Ada | 13,660 | adb | ------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- Ada Modeling Framework --
-- --
-- Runtime Library Component --
-- --
------------------------------------------------------------------------------
-- --
-- Copyright © 2012-2013, Vadim Godunko <[email protected]> --
-- All rights reserved. --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions --
-- are met: --
-- --
-- * Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- --
-- * Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in the --
-- documentation and/or other materials provided with the distribution. --
-- --
-- * Neither the name of the Vadim Godunko, IE nor the names of its --
-- contributors may be used to endorse or promote products derived from --
-- this software without specific prior written permission. --
-- --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR --
-- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
-- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED --
-- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR --
-- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF --
-- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING --
-- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS --
-- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
-- --
------------------------------------------------------------------------------
-- $Revision$ $Date$
------------------------------------------------------------------------------
with AMF.CMOF.Associations;
with AMF.CMOF.Properties.Collections;
with AMF.CMOF.Types;
with Generator.Names;
with Generator.Units;
package body Generator.Link_Sets is
use Generator.Names;
------------------------------
-- Generate_Construct_Union --
------------------------------
procedure Generate_Construct_Union is
Package_Name : constant League.Strings.Universal_String
:= "AMF.Internals.Factories."
& Module_Info.Ada_Name
& "_Module_Factory";
First_Class : Boolean := True;
First_Attribute : Boolean;
Unit : Generator.Units.Unit;
Position : CMOF_Class_Sets.Cursor := Module_Info.Classes.First;
The_Class : AMF.CMOF.Classes.CMOF_Class_Access;
begin
Unit.Add_Unit_Header (2012, 2013);
Unit.Add_Line;
Unit.Add_Line ("separate (" & Package_Name & ")");
Unit.Add_Line (+"procedure Construct_Union");
Unit.Add_Line (+" (Element : AMF.Internals.AMF_Element;");
Unit.Add_Line (+" Property : AMF.Internals.CMOF_Element;");
Unit.Add_Line (+" Link : AMF.Internals.AMF_Link)");
Unit.Add_Line (+"is");
Unit.Context.Add
("AMF.Internals.Tables." & Module_Info.Ada_Name & "_Types");
Unit.Add_Line
(" Element_Kind : constant AMF.Internals.Tables."
& Module_Info.Ada_Name
& "_Types.Element_Kinds");
Unit.Context.Add
("AMF.Internals.Tables." & Module_Info.Ada_Name & "_Element_Table");
Unit.Add_Line
(" := AMF.Internals.Tables."
& Module_Info.Ada_Name
& "_Element_Table.Table (Element).Kind;");
Unit.Context.Add (+"AMF.Internals.Links");
Unit.Add_Line
(+" Opposite : constant AMF.Internals.AMF_Element");
Unit.Add_Line
(+" := AMF.Internals.Links.Opposite_Element (Link, Element);");
Unit.Add_Line;
Unit.Add_Line (+"begin");
Unit.Add_Line (+" case Element_Kind is");
-- Go through all non-abstract classes of the module.
while CMOF_Class_Sets.Has_Element (Position) loop
The_Class := CMOF_Class_Sets.Element (Position);
if not The_Class.Get_Is_Abstract then
declare
use type AMF.CMOF.Properties.CMOF_Property_Access;
Class_Info : constant Class_Information_Access
:= Generator.Class_Info.Element (The_Class);
Position : CMOF_Property_Sets.Cursor
:= Class_Info.All_Attributes.First;
The_Property : AMF.CMOF.Properties.CMOF_Property_Access;
The_Type : AMF.CMOF.Types.CMOF_Type_Access;
Subsetted :
AMF.CMOF.Properties.Collections.Set_Of_CMOF_Property;
Redefined :
AMF.CMOF.Properties.Collections.Set_Of_CMOF_Property;
Union_Property : AMF.CMOF.Properties.CMOF_Property_Access;
Association : AMF.CMOF.Associations.CMOF_Association_Access;
Member_Ends :
AMF.CMOF.Properties.Collections.Ordered_Set_Of_CMOF_Property;
begin
First_Attribute := True;
while CMOF_Property_Sets.Has_Element (Position) loop
The_Property := CMOF_Property_Sets.Element (Position);
Subsetted := The_Property.Get_Subsetted_Property;
for J in 1 .. Subsetted.Length loop
Union_Property := Subsetted.Element (J);
if Union_Property.Get_Is_Derived_Union then
Association := Union_Property.Get_Association;
Member_Ends := Association.Get_Member_End;
Unit.Context.Add
(Property_Constant_Package_Name (The_Property));
if First_Attribute then
First_Attribute := False;
if First_Class then
First_Class := False;
else
Unit.Add_Line;
end if;
Unit.Add_Line
(" when AMF.Internals.Tables."
& Module_Info.Ada_Name
& "_Types.E_"
& Owning_Metamodel_Ada_Name (Class_Info.Class)
& '_'
& To_Ada_Identifier
(Class_Info.Class.Get_Name.Value)
& " =>");
Unit.Add_Line
(" if Property = "
& Property_Constant_Qualified_Name
(The_Property)
& " then");
elsif J = 1 then
Unit.Add_Line;
Unit.Add_Line
(" elsif Property = "
& Property_Constant_Qualified_Name
(The_Property)
& " then");
end if;
Unit.Add_Line
(+" AMF.Internals.Links.Create_Link");
Unit.Context.Add
(Association_Constant_Package_Name (Association));
Unit.Add_Line
(" ("
& Association_Constant_Qualified_Name (Association)
& ",");
if Member_Ends.Element (1) = Union_Property then
Unit.Add_Line (+" Element,");
Unit.Add_Line (+" Opposite,");
elsif Member_Ends.Element (2) = Union_Property then
Unit.Add_Line (+" Opposite,");
Unit.Add_Line (+" Element,");
else
raise Program_Error;
end if;
Unit.Add_Line (+" Link);");
end if;
end loop;
-- Create set of links for redefined properties.
--
-- XXX This works for one direction only right now, and must
-- be fixed.
The_Property := CMOF_Property_Sets.Element (Position);
The_Type := The_Property.Get_Type;
Redefined := The_Property.Get_Redefined_Property;
if The_Type.all in AMF.CMOF.Classes.CMOF_Class'Class then
for J in 1 .. Redefined.Length loop
Union_Property := Redefined.Element (J);
Association := Union_Property.Get_Association;
Member_Ends := Association.Get_Member_End;
Unit.Context.Add
(Property_Constant_Package_Name (The_Property));
if First_Attribute then
First_Attribute := False;
if First_Class then
First_Class := False;
else
Unit.Add_Line;
end if;
Unit.Add_Line
(" when AMF.Internals.Tables."
& Module_Info.Ada_Name
& "_Types.E_"
& Owning_Metamodel_Ada_Name (Class_Info.Class)
& '_'
& To_Ada_Identifier
(Class_Info.Class.Get_Name.Value)
& " =>");
Unit.Add_Line
(" if Property = "
& Property_Constant_Qualified_Name
(The_Property)
& " then");
elsif J = 1 then
Unit.Add_Line;
Unit.Add_Line
(" elsif Property = "
& Property_Constant_Qualified_Name
(The_Property)
& " then");
end if;
Unit.Add_Line
(+" AMF.Internals.Links.Create_Link");
Unit.Context.Add
(Association_Constant_Package_Name (Association));
Unit.Add_Line
(" ("
& Association_Constant_Qualified_Name (Association)
& ",");
if Member_Ends.Element (1) = Union_Property then
Unit.Add_Line (+" Element,");
Unit.Add_Line (+" Opposite,");
elsif Member_Ends.Element (2) = Union_Property then
Unit.Add_Line (+" Opposite,");
Unit.Add_Line (+" Element,");
else
raise Program_Error;
end if;
Unit.Add_Line (+" Link);");
end loop;
end if;
CMOF_Property_Sets.Next (Position);
end loop;
if not First_Attribute then
Unit.Add_Line (+" end if;");
end if;
end;
end if;
CMOF_Class_Sets.Next (Position);
end loop;
Unit.Add_Line;
Unit.Add_Line (+" when others =>");
Unit.Add_Line (+" null;");
Unit.Add_Line (+" end case;");
Unit.Add_Line (+"end Construct_Union;");
Unit.Put;
end Generate_Construct_Union;
end Generator.Link_Sets;
|
persan/gprTools | Ada | 29,821 | adb | pragma Ada_2012;
with Ada.Command_Line;
with Ada.Containers.Vectors;
with Ada.Directories;
with Ada.Strings.Fixed.Equal_Case_Insensitive;
with Ada.Strings.Unbounded;
with GNAT.Command_Line;
with GNAT.Exception_Traces;
with GNAT.IO; use GNAT.IO;
with GNAT.OS_Lib;
with GNAT.Regexp;
with GNAT.Regpat;
with GNAT.Spitbol.Table_Boolean;
with GNAT.String_Split;
with GNAT.Strings;
with GNAT.Traceback.Symbolic;
with GNAT.Traceback;
with GNATCOLL.Arg_Lists;
with GNATCOLL.Projects;
with GNATCOLL.Templates;
with GNATCOLL.VFS;
with Ada.Containers.Indefinite_Ordered_Sets;
with GNAT.Directory_Operations;
with GPR.Opt;
with GNAT.Case_Util;
procedure GPR_Tools.Gprinfo is
use Ada.Containers;
use Ada.Directories;
use Ada.Strings.Fixed;
use GNAT.Command_Line;
use GNAT.Regpat;
use GNAT.Spitbol.Table_Boolean;
use GNAT.Strings;
use GNATCOLL.Arg_Lists;
use GNATCOLL.Projects;
use GNATCOLL.Templates;
use GNATCOLL.VFS;
type Command_Kind is (Do_Echo, Do_Exec);
type Command_Type is record
Kind : Command_Kind := Do_Echo;
Cmd : GNAT.Strings.String_Access;
end record;
GPR_PROJECT_PATH_ORIG : constant GNAT.Strings.String_Access := GNAT.OS_Lib.Getenv ("GPR_PROJECT_PATH");
package Command_Vectors is new Ada.Containers.Vectors (Natural, Command_Type);
package String_Vectors is new Ada.Containers.Vectors (Natural, GNAT.Strings.String_Access);
package String_Sets is new Ada.Containers.Indefinite_Ordered_Sets (Element_Type => String);
GPR_PROJECT_PATH_LOCAL : String_Vectors.Vector;
GPR_PROJECT_PATH_SUBPROCESS : String_Vectors.Vector;
BaseName : Boolean := False;
Commands : Command_Vectors.Vector;
Cwd : Boolean := False;
DirName : Boolean := False;
Direct_Imports : Boolean := False;
Displayed_Folders : GNAT.Spitbol.Table_Boolean.Table (512);
Env : Project_Environment_Access;
Exclude_Externally_Built : Boolean := True;
Exclude_No_Source : Boolean := True;
Exclude_Patterns : String_Vectors.Vector;
Exclude_RTS : Boolean := True;
Exec_Dir : Boolean := False;
GNAT_Version : GNAT.Strings.String_Access;
Gnatls : GNAT.Strings.String_Access := new String'("gnatls");
Help : Boolean := False;
Is_Aggregate : Boolean := False;
Languages : Boolean := False;
Library_Dir : Boolean := False;
Missing : Boolean := False;
Missing_Fail : Boolean := False;
No_Duplicates : Boolean := False;
Object_Dir : Boolean := False;
Proj : Project_Tree;
Project_File : GNAT.Strings.String_Access;
Recursive : Boolean := False;
Rts_Root : GNAT.Strings.String_Access;
Show_Version : Boolean := False;
Source_Dirs : Boolean := False;
Source_Dirs_I : Boolean := False;
Source_Files : Boolean := False;
Verbose : Boolean := False;
Exit_Status : Ada.Command_Line.Exit_Status := Ada.Command_Line.Success;
Reverse_Order : Boolean := False;
Execute_Commands : Boolean := False;
Max_Iterations : Positive := 1;
Default_Max_Iterations : constant := 16;
Attribute : GNAT.Strings.String_Access;
Query_Languages : GNAT.Strings.String_Access;
Reload_Project_After_Warnings : Boolean := True;
function Image (Item : String_Vectors.Vector) return String is
Ret : Ada.Strings.Unbounded.Unbounded_String;
begin
for I of Item loop
if Ada.Strings.Unbounded.Length (Ret) /= 0 then
Ada.Strings.Unbounded.Append (Ret, GNAT.OS_Lib.Path_Separator);
end if;
Ada.Strings.Unbounded.Append (Ret, I.all);
end loop;
return Ada.Strings.Unbounded.To_String (Ret);
end Image;
procedure Output (Full_Name : String;
Base_Name : String;
Dir_Name : String;
Name : String;
Continue : out Boolean) is
Subst : GNATCOLL.Templates.Substitution_Array
:= ((new String'("full_name"), new String'(Full_Name)),
(new String'("base_name"), new String'(Base_Name)),
(new String'("dir_name"), new String'(Dir_Name)),
(new String'("name"), new String'(Name)));
Args : GNAT.OS_Lib.Argument_List_Access;
Cmd : GNAT.OS_Lib.String_Access;
begin
Continue := True;
if No_Duplicates then
if not Present (Displayed_Folders, Dir_Name) then
Set (Displayed_Folders, Dir_Name, True);
else
return;
end if;
end if;
if Exclude_RTS and then Ada.Strings.Fixed.Index (Dir_Name, Rts_Root.all) = Dir_Name'First then
return;
end if;
for Exclude_Pattern of Exclude_Patterns loop
if GNAT.Regexp.Match (Full_Name, GNAT.Regexp.Compile (Exclude_Pattern.all)) then
return;
end if;
end loop;
for C of Commands loop
declare
Command : GNATCOLL.Arg_Lists.Arg_List;
Commands_Template : GNATCOLL.Arg_Lists.Arg_List;
use type Ada.Command_Line.Exit_Status;
begin
Commands_Template := GNATCOLL.Arg_Lists.Parse_String (C.Cmd.all, Separate_Args);
for I in 0 .. Args_Length (Commands_Template) loop
Append_Argument (C => Command,
Argument => Substitute (Str => Nth_Arg (Commands_Template, I),
Substrings => Subst),
Mode => One_Arg);
end loop;
case C.Kind is
when Do_Echo =>
GNAT.IO.Put_Line (GNATCOLL.Arg_Lists.To_Display_String (Command));
when Do_Exec =>
if Cwd then
if Verbose then
GNAT.IO.Put_Line ("<cwd> " & Dir_Name);
end if;
Ada.Directories.Set_Directory (Dir_Name);
end if;
if Verbose then
GNAT.IO.Put_Line ("<exec> " & GNATCOLL.Arg_Lists.To_Display_String (Command));
end if;
Args := new GNAT.OS_Lib.Argument_List'(GNATCOLL.Arg_Lists.To_List (Command, False));
Cmd := GNAT.OS_Lib.Locate_Exec_On_Path (GNATCOLL.Arg_Lists.Get_Command (Command));
Exit_Status := Ada.Command_Line.Exit_Status (GNAT.OS_Lib.Spawn (Cmd.all, Args.all));
if Exit_Status /= 0 then
Continue := False;
end if;
Free (Cmd);
Free (Args);
end case;
end;
end loop;
GNATCOLL.Templates.Free (Subst);
end Output;
procedure Locate_Proj is
Found : Boolean := False;
procedure Process (Directory_Entry : Directory_Entry_Type) is
begin
if not Found then
Project_File := new String'(Full_Name (Directory_Entry));
Found := True;
end if;
end Process;
begin
declare
Name : constant String := Get_Argument (True);
begin
if Name'Length /= 0 then
Project_File := new String'(Full_Name (Name));
return;
end if;
end;
Search (".", "*.gpr", Process => Process'Access);
end Locate_Proj;
procedure Print_Attribute (P : Project_Type; Attribute : String) is
Matcher : constant Pattern_Matcher := Compile ("((\w+)\.|)(\w+)(\((\w+)\)|)");
Matches : Match_Array (1 .. Paren_Count (Matcher));
Pkg_IX : constant := 2;
Attr_IX : constant := 3;
IX_IX : constant := 5;
function Get (S : String; Slice : Match_Location) return String is
begin
if Slice = No_Match then
return "";
else
return S (Slice.First .. Slice.Last);
end if;
end Get;
begin
Match (Matcher, Attribute, Matches);
if Matches (Attr_IX) /= No_Match then
declare
Attr_L : constant String_List_Access := P.Attribute_Value
(Attribute => Build (Get (Attribute, Matches (Pkg_IX)), Get (Attribute, Matches (Attr_IX))),
Index => Get (Attribute, Matches (IX_IX)));
First : Boolean := True;
begin
for I of Attr_L.all loop
if not First then
GNAT.IO.Put (" ");
end if;
GNAT.IO.Put (I.all);
First := False;
end loop;
GNAT.IO.New_Line;
end;
end if;
end Print_Attribute;
procedure Display (P : Project_Type) is
begin
if Exclude_Externally_Built and then Equal_Case_Insensitive (P.Attribute_Value (Build ("", "externally_built")), "true") then
return;
elsif Exclude_No_Source and then P.Direct_Sources_Count = 0 then
return;
elsif Languages then
for I of P.Languages loop
declare
Lang : String := I.all;
begin
GNAT.Case_Util.To_Mixed (Lang);
GNAT.IO.Put_Line (Lang);
end;
end loop;
elsif Attribute /= null then
Print_Attribute (P, Attribute.all);
elsif Source_Dirs or Source_Dirs_I then
for I of P.Source_Dirs (Recursive) loop
GNAT.IO.Put_Line ((if Source_Dirs_I then "-I " else "") & (+Full_Name (I)));
end loop;
elsif Source_Files then
for I of GNATCOLL.VFS.File_Array_Access'(P.Source_Files (Recursive)).all loop
GNAT.IO.Put_Line (+Full_Name (I));
end loop;
elsif Object_Dir then
for I of P.Object_Path (Recursive) loop
GNAT.IO.Put_Line (+Full_Name (I));
end loop;
elsif Exec_Dir then
GNAT.IO.Put_Line (+Full_Name (P.Executables_Directory));
elsif Library_Dir then
GNAT.IO.Put_Line (+Full_Name (P.Library_Directory));
elsif Recursive or Direct_Imports then
declare
Iter : Project_Iterator;
Continue : Boolean;
begin
if Reverse_Order then
Iter := P.Start_Reversed (Recursive, Direct_Imports);
else
Iter := P.Start (Recursive, Direct_Imports);
end if;
loop
exit when Current (Iter) = No_Project;
if DirName then
declare
Name : constant String := +Dir_Name (Current (Iter).Project_Path);
begin
if No_Duplicates and then not Present (Displayed_Folders, Name) then
GNAT.IO.Put_Line (Name);
Set (Displayed_Folders, Name, True);
end if;
end;
elsif BaseName then
GNAT.IO.Put_Line (+Base_Name (Current (Iter).Project_Path));
elsif Commands.Length /= 0 then
Output (Full_Name => +Full_Name (Current (Iter).Project_Path),
Base_Name => +Base_Name (Current (Iter).Project_Path),
Dir_Name => +Dir_Name (Current (Iter).Project_Path),
Name => Current (Iter).Name,
Continue => Continue);
else
if Query_Languages = null then
GNAT.IO.Put_Line (+Full_Name (Current (Iter).Project_Path));
else
for I of Current (Iter).Languages loop
if Ada.Strings.Fixed.Equal_Case_Insensitive (I.all, Query_Languages.all) then
GNAT.IO.Put_Line (+Full_Name (Current (Iter).Project_Path));
end if;
end loop;
end if;
end if;
Next (Iter);
end loop;
end;
elsif Is_Aggregate and Query_Languages /= null then
for I of P.Languages loop
if Ada.Strings.Fixed.Equal_Case_Insensitive (I.all, Query_Languages.all) then
GNAT.IO.Put_Line (+Full_Name (P.Project_Path));
end if;
end loop;
end if;
end Display;
procedure Handle_Error_Report (Msg : String) is
Matcher : constant GNAT.Regpat.Pattern_Matcher := Compile ("^((\w+\.gpr):\d+:\d+: (unknown project file:|imported project file) ""(.+)"")");
Matches : GNAT.Regpat.Match_Array (1 .. GNAT.Regpat.Paren_Count (Matcher));
Continue : Boolean;
begin
Match (Matcher, Msg, Matches);
if Matches (3) /= No_Match then
if Missing_Fail then
Exit_Status := Ada.Command_Line.Failure;
end if;
if Commands.Length /= 0 then
Output (Full_Name => Msg (Matches (4).First .. Matches (4).Last),
Base_Name => Msg (Matches (2).First .. Matches (2).Last),
Dir_Name => Msg (Matches (4).First .. Matches (4).Last),
Name => Msg (Matches (4).First .. Matches (4).Last),
Continue => Continue);
else
GNAT.IO.Put_Line (Msg (Matches (4).First .. Matches (4).Last));
end if;
end if;
end Handle_Error_Report;
procedure Handle_Error_Report_Suppress_Warnings (Msg : String) is
Matcher : constant GNAT.Regpat.Pattern_Matcher := Compile ("^(\w+)\.gpr:\d+:\d+: warning: object directory ""(.+)"" not found");
Matches : GNAT.Regpat.Match_Array (1 .. GNAT.Regpat.Paren_Count (Matcher));
begin
Match (Matcher, Msg, Matches);
if Matches (2) /= No_Match then
Reload_Project_After_Warnings := True;
else
GNAT.IO.Put_Line (Msg);
end if;
end Handle_Error_Report_Suppress_Warnings;
-- -------------------------------------------------------------------------
-- -------------------------------------------------------------------------
procedure Print_Help is
use ASCII;
begin
Put_Line ("Displays various aspects of .gpr-project files. " & ASCII.LF &
"could also excute commands on the resulting project set." & ASCII.LF &
"The usage usage is multiple:" & ASCII.LF &
" * Extract aspects of a single project file to be used in scripts." & ASCII.LF &
" * Iterate over project-trees." & LF &
" * Find missing projects in a project tree.");
Put_Line ("-P=proj Use Project File proj");
Put_Line ("-aP=dir Add directory dir to project search path (not propageted to subproceses).");
Put_Line ("-Ap=dir Add directory dir to project search path (only propageted to subproceses).");
Put_Line ("-AP=dir Add directory dir to project search path global.");
Put_Line ("--dirname Show directorynames of projects.");
Put_Line ("--basename Show basenames of projects.");
Put_Line ("-m --missing Show missing projects substitution is %name is the missing file and %base_name is the importing file.");
Put_Line ("-M --Missing Show missing projects substitution same as in ""-m"" (exit with error if not complete).");
Put_Line ("-x{num} Repeats load of missing projects max ""num"" times (default is" & Default_Max_Iterations'Img & ") does only apply on ""-exec"".");
Put_Line ("--exec-dir Print exec dir.");
Put_Line ("--object-dir Print object dir.");
Put_Line ("--source-dirs Print source dirs.");
Put_Line ("--source-dirs-include Print source dirs with ""-I "" before each entry.");
Put_Line ("--source-files Print source files.");
Put_Line ("--imports Print direct imports.");
Put_Line ("--library-dir Print library dir.");
Put_Line ("--languages Print project languages.");
Put_Line ("--contains-lang=lang Print projects containing languages lang (implies recursive)");
Put_Line ("--gnatls={gnatls} Use as gnatls default=>'" & Gnatls.all & "' .");
Put_Line ("-r --recursive Show recursive on all projects in tree in buildorder.");
Put_Line ("--reverse Show recursive on all projects in tree in reverse buildorder.");
Put_Line ("--echo=""command line"" Echo the argument with substitution %full_name %base_Name %dir_name %name.");
Put_Line ("--exec=""command line"" Execute the argument with substitution %full_name %base_Name %dir_name %name.");
Put_Line ("--cwd Change dir to projects enclosing dir before executing command.");
Put_Line ("--rts Include projects from runtimes.");
Put_Line ("--externally-built Include externally built procjects.");
Put_Line ("--empty-sources Include projects that dont have source files.");
Put_Line ("--no-duplicates Don't duplicate folders when showing dirnames.");
Put_Line ("--exclude-pattern=regexp Exclude project paths matching regexp.");
Put_Line ("--attribute={pkg.}attr{(ix)} Prints the attribute attr.");
Put_Line ("-Xnm=val Specify an external reference for Project Files.");
Put_Line ("-v --version Print version and then exit.");
Put_Line ("--verbose Be verbose.");
Put_Line ("--exceptions Trace all exceptions.");
Put_Line ("-? -h --help Display this text.");
end Print_Help;
procedure Parse_Command_Line is
Opt : Character;
begin
loop
Opt := Getopt ("P= " &
"AP= " &
"aP= " &
"-dirname " &
"-basename " &
"m -missing " &
"M -Missing " &
"-exec-dir " &
"-object-dir " &
"-source-dirs " &
"-source-dirs-include " &
"-source-files " &
"-imports " &
"-library-dir " &
"-languages " &
"-contains-lang= " &
"-gnatls= " &
"x? " &
"X! " &
"r -recursive " &
"-reverse " &
"-echo= " &
"-exec= " &
"-cwd " &
"-rts " &
"-externally-built " &
"-empty-sources " &
"-no-duplicates " &
"-exclude-pattern " &
"v -verbose " &
"-version " &
"-attribute= " &
"-exceptions " &
"? h -help");
case Opt is
when ASCII.NUL => exit;
when 'P' =>
Project_File := new String'(Parameter);
when 'a' =>
if Full_Switch = "aP" then
GPR_PROJECT_PATH_LOCAL.Append (new String'(Parameter));
else
raise Program_Error with "invalid switch => '" & Full_Switch & "'";
end if;
when 'A' =>
if Full_Switch = "Ap" then
GPR_PROJECT_PATH_SUBPROCESS.Append (new String'(Parameter));
elsif Full_Switch = "AP" then
GPR_PROJECT_PATH_LOCAL.Append (new String'(Parameter));
GPR_PROJECT_PATH_SUBPROCESS.Append (new String'(Parameter));
else
raise Program_Error with "invalid switch => '" & Full_Switch & "'";
end if;
when 'm' =>
Missing := True;
when 'M' =>
Missing_Fail := True;
when 'r' =>
Recursive := True;
when 'v' =>
Show_Version := True;
when 'x' =>
if Parameter'Length = 0 then
Max_Iterations := Default_Max_Iterations;
else
Max_Iterations := Integer'Value (Parameter);
end if;
when 'X' =>
declare
S : GNAT.String_Split.Slice_Set; use GNAT.String_Split;
begin
Create (S, Parameter, "=");
if Slice_Count (S) = 2 then
Change_Environment (Env.all, Slice (S, 1), Slice (S, 2));
else
Put_Line ("Invalid argument for ""-X"" """ & Parameter & """.");
Help := True;
end if;
end;
when '?' | 'h' =>
Help := True;
when '-' =>
if Full_Switch = "-dirname" then
DirName := True;
elsif Full_Switch = "-basename" then
BaseName := True;
elsif Full_Switch = "-missing" then
Missing := True;
elsif Full_Switch = "-Missing" then
Missing := True;
Missing_Fail := True;
elsif Full_Switch = "-object-dir" then
Object_Dir := True;
elsif Full_Switch = "-object-dir" then
Object_Dir := True;
elsif Full_Switch = "-source-dirs" then
Source_Dirs := True;
elsif Full_Switch = "-source-dirs-include" then
Source_Dirs_I := True;
elsif Full_Switch = "-source-files" then
Source_Files := True;
elsif Full_Switch = "-imports" then
Direct_Imports := True;
elsif Full_Switch = "-exec-dir" then
Exec_Dir := True;
elsif Full_Switch = "-library-dir" then
Library_Dir := True;
elsif Full_Switch = "-languages" then
Languages := True;
elsif Full_Switch = "-contains-lang" then
Query_Languages := new String'(Parameter);
Recursive := True;
elsif Full_Switch = "-gnatls" then
Gnatls := new String'(Parameter);
elsif Full_Switch = "-reverse" then
Recursive := True;
Reverse_Order := True;
elsif Full_Switch = "-recursive" then
Recursive := True;
elsif Full_Switch = "-cwd" then
Cwd := True;
elsif Full_Switch = "-echo" then
Commands.Append ((Do_Echo, new String'(Parameter)));
elsif Full_Switch = "-exec" then
Commands.Append ((Do_Exec, new String'(Parameter)));
Execute_Commands := True;
elsif Full_Switch = "-rts" then
Exclude_RTS := False;
elsif Full_Switch = "-externally-built" then
Exclude_Externally_Built := False;
elsif Full_Switch = "-empty-sources" then
Exclude_No_Source := False;
elsif Full_Switch = "-exclude-pattern" then
Exclude_Patterns.Append (new String'(Parameter));
elsif Full_Switch = "-no-duplicates" then
No_Duplicates := True;
elsif Full_Switch = "-version" then
Show_Version := True;
elsif Full_Switch = "-verbose" then
Verbose := True;
elsif Full_Switch = "-attribute" then
Attribute := new String'(Parameter);
elsif Full_Switch = "-exceptions" then
GNAT.Exception_Traces.Set_Trace_Decorator (GNAT.Traceback.Symbolic.Symbolic_Traceback'Access);
GNAT.Exception_Traces.Trace_On (GNAT.Exception_Traces.Every_Raise);
elsif Full_Switch = "-help" then
Help := True;
else
raise Program_Error with "invalid switch => '" & Full_Switch & "'";
end if;
when others =>
raise Program_Error with "invalid switch => '" & Full_Switch & "'";
end case;
end loop;
exception
when GNAT.Command_Line.Invalid_Switch =>
GNAT.IO.Put_Line ("Invalid switch: " & Full_Switch);
Print_Help;
raise;
end Parse_Command_Line;
begin
Initialize (Env);
Parse_Command_Line;
if Help then
Print_Help;
return;
elsif Show_Version then
GNAT.IO.Put_Line (VERSION);
return;
end if;
if Direct_Imports then
Recursive := True;
end if;
-- ============
-- Set up paths
-- ============
if GPR_PROJECT_PATH_ORIG /= null and then GPR_PROJECT_PATH_ORIG.all /= "" then
declare
S : GNAT.String_Split.Slice_Set;
begin
GNAT.String_Split.Create (S, GPR_PROJECT_PATH_ORIG.all, GNAT.OS_Lib.Path_Separator & "", GNAT.String_Split.Multiple);
for I in 1 .. GNAT.String_Split.Slice_Count (S) loop
GPR_PROJECT_PATH_SUBPROCESS.Append (new String'(GNAT.String_Split.Slice (S, I)));
GPR_PROJECT_PATH_LOCAL.Append (new String'(GNAT.String_Split.Slice (S, I)));
end loop;
end;
end if;
declare
Realgnatls : GNAT.Strings.String_Access;
begin
Realgnatls := GNAT.OS_Lib.Locate_Exec_On_Path (Gnatls.all);
Rts_Root := new String'(Containing_Directory (Containing_Directory (Realgnatls.all)));
Free (Realgnatls);
end;
Env.Set_Path_From_Gnatls (Gnatls.all, GNAT_Version, GNAT.IO.Put_Line'Access);
-- ======================
-- Locate the root-project
-- ======================
if Project_File = null then
Locate_Proj;
elsif Project_File.all = "" then
Free (Project_File);
Locate_Proj;
end if;
if not Exists (Name => Project_File.all) then
if Exists (Name => Project_File.all & ".gpr") then
Project_File := new String'(Project_File.all & ".gpr");
end if;
end if;
-- ================
-- Do the real work
-- ================
if GPR_PROJECT_PATH_LOCAL.Length /= 0 then
GNAT.OS_Lib.Setenv ("GPR_PROJECT_PATH", Image (GPR_PROJECT_PATH_LOCAL));
end if;
if Missing or Missing_Fail then
Load_Loop : for I in 1 .. (if Execute_Commands then Max_Iterations else 1) loop
begin
Proj.Load (Create (Filesystem_String (Project_File.all)), Env,
Errors => Handle_Error_Report'Unrestricted_Access,
Recompute_View => False);
exit Load_Loop;
exception
when others =>
null;
end;
end loop Load_Loop;
else
GPR.Opt.Create_Dirs := GPR.Opt.Create_All_Dirs;
null;
GPR.Opt.Unchecked_Shared_Lib_Imports := True;
GPR.Opt.Full_Path_Name_For_Brief_Errors := True;
Proj.Load (Create (Filesystem_String (Project_File.all)), Env, Errors => Handle_Error_Report_Suppress_Warnings'Unrestricted_Access);
if Reload_Project_After_Warnings then
Proj.Load (Create (Filesystem_String (Project_File.all)), Env, Errors => Handle_Error_Report_Suppress_Warnings'Unrestricted_Access);
end if;
if GPR_PROJECT_PATH_SUBPROCESS.Length /= 0 then
GNAT.OS_Lib.Setenv ("GPR_PROJECT_PATH", Image (GPR_PROJECT_PATH_SUBPROCESS));
end if;
if Proj.Root_Project.Is_Aggregate_Project or Proj.Root_Project.Is_Aggregate_Library then
Recursive := False;
Is_Aggregate := True;
declare
Projects : String_Sets.Set;
procedure Process (Directory_Entry : Directory_Entry_Type) is
P : constant Project_Type := Project_From_Path (Proj, Create_From_UTF8 (Ada.Directories.Full_Name (Directory_Entry)));
Iter : Project_Iterator;
begin
Projects.Include (P.Name);
Iter := P.Start (True, False, True);
while Current (Iter) /= No_Project loop
Projects.Include (Current (Iter).Name);
Next (Iter);
end loop;
end Process;
Project_Files : constant GNAT.Strings.String_List_Access := Proj.Root_Project.Attribute_Value (Build ("", "Project_Files"));
begin
Locate_All_Projects : for I of Project_Files.all loop
Ada.Directories.Search (GNAT.Directory_Operations.Dir_Name (I.all),
GNAT.Directory_Operations.Base_Name (I.all),
(False, True, False),
Process'Access);
end loop Locate_All_Projects;
for I of Projects loop
Display (Proj.Project_From_Name (I));
end loop;
end;
else
Display (Proj.Root_Project);
end if;
end if;
Ada.Command_Line.Set_Exit_Status (Exit_Status);
exception
when others =>
Ada.Command_Line.Set_Exit_Status (Ada.Command_Line.Failure);
end GPR_Tools.Gprinfo;
|
reznikmm/matreshka | Ada | 4,107 | ads | ------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- Open Document Toolkit --
-- --
-- Runtime Library Component --
-- --
------------------------------------------------------------------------------
-- --
-- Copyright © 2014, Vadim Godunko <[email protected]> --
-- All rights reserved. --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions --
-- are met: --
-- --
-- * Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- --
-- * Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in the --
-- documentation and/or other materials provided with the distribution. --
-- --
-- * Neither the name of the Vadim Godunko, IE nor the names of its --
-- contributors may be used to endorse or promote products derived from --
-- this software without specific prior written permission. --
-- --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR --
-- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
-- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED --
-- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR --
-- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF --
-- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING --
-- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS --
-- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
-- --
------------------------------------------------------------------------------
-- $Revision$ $Date$
------------------------------------------------------------------------------
with ODF.DOM.Style_Text_Line_Through_Text_Attributes;
package Matreshka.ODF_Style.Text_Line_Through_Text_Attributes is
type Style_Text_Line_Through_Text_Attribute_Node is
new Matreshka.ODF_Style.Abstract_Style_Attribute_Node
and ODF.DOM.Style_Text_Line_Through_Text_Attributes.ODF_Style_Text_Line_Through_Text_Attribute
with null record;
overriding function Create
(Parameters : not null access Matreshka.DOM_Attributes.Attribute_L2_Parameters)
return Style_Text_Line_Through_Text_Attribute_Node;
overriding function Get_Local_Name
(Self : not null access constant Style_Text_Line_Through_Text_Attribute_Node)
return League.Strings.Universal_String;
end Matreshka.ODF_Style.Text_Line_Through_Text_Attributes;
|
MinimSecure/unum-sdk | Ada | 826 | adb | -- Copyright 2010-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 Foo is
New_Node : Node_Id;
begin
New_Node := Pn (1234); -- STOP
end Foo;
|
reznikmm/matreshka | Ada | 16,293 | adb | ------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- Ada Modeling Framework --
-- --
-- Runtime Library Component --
-- --
------------------------------------------------------------------------------
-- --
-- Copyright © 2011-2012, Vadim Godunko <[email protected]> --
-- All rights reserved. --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions --
-- are met: --
-- --
-- * Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- --
-- * Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in the --
-- documentation and/or other materials provided with the distribution. --
-- --
-- * Neither the name of the Vadim Godunko, IE nor the names of its --
-- contributors may be used to endorse or promote products derived from --
-- this software without specific prior written permission. --
-- --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR --
-- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
-- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED --
-- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR --
-- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF --
-- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING --
-- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS --
-- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
-- --
------------------------------------------------------------------------------
-- $Revision$ $Date$
------------------------------------------------------------------------------
with AMF.Elements;
with AMF.Internals.Element_Collections;
with AMF.Internals.Helpers;
with AMF.Internals.Tables.UML_Attributes;
with AMF.Visitors.UML_Iterators;
with AMF.Visitors.UML_Visitors;
with League.Strings.Internals;
with Matreshka.Internals.Strings;
package body AMF.Internals.UML_Literal_Booleans is
-------------------
-- Enter_Element --
-------------------
overriding procedure Enter_Element
(Self : not null access constant UML_Literal_Boolean_Proxy;
Visitor : in out AMF.Visitors.Abstract_Visitor'Class;
Control : in out AMF.Visitors.Traverse_Control) is
begin
if Visitor in AMF.Visitors.UML_Visitors.UML_Visitor'Class then
AMF.Visitors.UML_Visitors.UML_Visitor'Class
(Visitor).Enter_Literal_Boolean
(AMF.UML.Literal_Booleans.UML_Literal_Boolean_Access (Self),
Control);
end if;
end Enter_Element;
-------------------
-- Leave_Element --
-------------------
overriding procedure Leave_Element
(Self : not null access constant UML_Literal_Boolean_Proxy;
Visitor : in out AMF.Visitors.Abstract_Visitor'Class;
Control : in out AMF.Visitors.Traverse_Control) is
begin
if Visitor in AMF.Visitors.UML_Visitors.UML_Visitor'Class then
AMF.Visitors.UML_Visitors.UML_Visitor'Class
(Visitor).Leave_Literal_Boolean
(AMF.UML.Literal_Booleans.UML_Literal_Boolean_Access (Self),
Control);
end if;
end Leave_Element;
-------------------
-- Visit_Element --
-------------------
overriding procedure Visit_Element
(Self : not null access constant UML_Literal_Boolean_Proxy;
Iterator : in out AMF.Visitors.Abstract_Iterator'Class;
Visitor : in out AMF.Visitors.Abstract_Visitor'Class;
Control : in out AMF.Visitors.Traverse_Control) is
begin
if Iterator in AMF.Visitors.UML_Iterators.UML_Iterator'Class then
AMF.Visitors.UML_Iterators.UML_Iterator'Class
(Iterator).Visit_Literal_Boolean
(Visitor,
AMF.UML.Literal_Booleans.UML_Literal_Boolean_Access (Self),
Control);
end if;
end Visit_Element;
---------------
-- Get_Value --
---------------
overriding function Get_Value
(Self : not null access constant UML_Literal_Boolean_Proxy)
return Boolean is
begin
return
AMF.Internals.Tables.UML_Attributes.Internal_Get_Value
(Self.Element);
end Get_Value;
---------------
-- Set_Value --
---------------
overriding procedure Set_Value
(Self : not null access UML_Literal_Boolean_Proxy;
To : Boolean) is
begin
AMF.Internals.Tables.UML_Attributes.Internal_Set_Value
(Self.Element, To);
end Set_Value;
--------------
-- Get_Type --
--------------
overriding function Get_Type
(Self : not null access constant UML_Literal_Boolean_Proxy)
return AMF.UML.Types.UML_Type_Access is
begin
return
AMF.UML.Types.UML_Type_Access
(AMF.Internals.Helpers.To_Element
(AMF.Internals.Tables.UML_Attributes.Internal_Get_Type
(Self.Element)));
end Get_Type;
--------------
-- Set_Type --
--------------
overriding procedure Set_Type
(Self : not null access UML_Literal_Boolean_Proxy;
To : AMF.UML.Types.UML_Type_Access) is
begin
AMF.Internals.Tables.UML_Attributes.Internal_Set_Type
(Self.Element,
AMF.Internals.Helpers.To_Element
(AMF.Elements.Element_Access (To)));
end Set_Type;
---------------------------
-- Get_Client_Dependency --
---------------------------
overriding function Get_Client_Dependency
(Self : not null access constant UML_Literal_Boolean_Proxy)
return AMF.UML.Dependencies.Collections.Set_Of_UML_Dependency is
begin
return
AMF.UML.Dependencies.Collections.Wrap
(AMF.Internals.Element_Collections.Wrap
(AMF.Internals.Tables.UML_Attributes.Internal_Get_Client_Dependency
(Self.Element)));
end Get_Client_Dependency;
-------------------------
-- Get_Name_Expression --
-------------------------
overriding function Get_Name_Expression
(Self : not null access constant UML_Literal_Boolean_Proxy)
return AMF.UML.String_Expressions.UML_String_Expression_Access is
begin
return
AMF.UML.String_Expressions.UML_String_Expression_Access
(AMF.Internals.Helpers.To_Element
(AMF.Internals.Tables.UML_Attributes.Internal_Get_Name_Expression
(Self.Element)));
end Get_Name_Expression;
-------------------------
-- Set_Name_Expression --
-------------------------
overriding procedure Set_Name_Expression
(Self : not null access UML_Literal_Boolean_Proxy;
To : AMF.UML.String_Expressions.UML_String_Expression_Access) is
begin
AMF.Internals.Tables.UML_Attributes.Internal_Set_Name_Expression
(Self.Element,
AMF.Internals.Helpers.To_Element
(AMF.Elements.Element_Access (To)));
end Set_Name_Expression;
-------------------
-- Get_Namespace --
-------------------
overriding function Get_Namespace
(Self : not null access constant UML_Literal_Boolean_Proxy)
return AMF.UML.Namespaces.UML_Namespace_Access is
begin
return
AMF.UML.Namespaces.UML_Namespace_Access
(AMF.Internals.Helpers.To_Element
(AMF.Internals.Tables.UML_Attributes.Internal_Get_Namespace
(Self.Element)));
end Get_Namespace;
------------------------
-- Get_Qualified_Name --
------------------------
overriding function Get_Qualified_Name
(Self : not null access constant UML_Literal_Boolean_Proxy)
return AMF.Optional_String is
begin
declare
use type Matreshka.Internals.Strings.Shared_String_Access;
Aux : constant Matreshka.Internals.Strings.Shared_String_Access
:= AMF.Internals.Tables.UML_Attributes.Internal_Get_Qualified_Name (Self.Element);
begin
if Aux = null then
return (Is_Empty => True);
else
return (False, League.Strings.Internals.Create (Aux));
end if;
end;
end Get_Qualified_Name;
-----------------------------------
-- Get_Owning_Template_Parameter --
-----------------------------------
overriding function Get_Owning_Template_Parameter
(Self : not null access constant UML_Literal_Boolean_Proxy)
return AMF.UML.Template_Parameters.UML_Template_Parameter_Access is
begin
return
AMF.UML.Template_Parameters.UML_Template_Parameter_Access
(AMF.Internals.Helpers.To_Element
(AMF.Internals.Tables.UML_Attributes.Internal_Get_Owning_Template_Parameter
(Self.Element)));
end Get_Owning_Template_Parameter;
-----------------------------------
-- Set_Owning_Template_Parameter --
-----------------------------------
overriding procedure Set_Owning_Template_Parameter
(Self : not null access UML_Literal_Boolean_Proxy;
To : AMF.UML.Template_Parameters.UML_Template_Parameter_Access) is
begin
AMF.Internals.Tables.UML_Attributes.Internal_Set_Owning_Template_Parameter
(Self.Element,
AMF.Internals.Helpers.To_Element
(AMF.Elements.Element_Access (To)));
end Set_Owning_Template_Parameter;
----------------------------
-- Get_Template_Parameter --
----------------------------
overriding function Get_Template_Parameter
(Self : not null access constant UML_Literal_Boolean_Proxy)
return AMF.UML.Template_Parameters.UML_Template_Parameter_Access is
begin
return
AMF.UML.Template_Parameters.UML_Template_Parameter_Access
(AMF.Internals.Helpers.To_Element
(AMF.Internals.Tables.UML_Attributes.Internal_Get_Template_Parameter
(Self.Element)));
end Get_Template_Parameter;
----------------------------
-- Set_Template_Parameter --
----------------------------
overriding procedure Set_Template_Parameter
(Self : not null access UML_Literal_Boolean_Proxy;
To : AMF.UML.Template_Parameters.UML_Template_Parameter_Access) is
begin
AMF.Internals.Tables.UML_Attributes.Internal_Set_Template_Parameter
(Self.Element,
AMF.Internals.Helpers.To_Element
(AMF.Elements.Element_Access (To)));
end Set_Template_Parameter;
-------------------
-- Boolean_Value --
-------------------
overriding function Boolean_Value
(Self : not null access constant UML_Literal_Boolean_Proxy)
return Boolean is
begin
-- Generated stub: replace with real body!
pragma Compile_Time_Warning (Standard.True, "Boolean_Value unimplemented");
raise Program_Error with "Unimplemented procedure UML_Literal_Boolean_Proxy.Boolean_Value";
return Boolean_Value (Self);
end Boolean_Value;
-------------------
-- Is_Computable --
-------------------
overriding function Is_Computable
(Self : not null access constant UML_Literal_Boolean_Proxy)
return Boolean is
begin
-- Generated stub: replace with real body!
pragma Compile_Time_Warning (Standard.True, "Is_Computable unimplemented");
raise Program_Error with "Unimplemented procedure UML_Literal_Boolean_Proxy.Is_Computable";
return Is_Computable (Self);
end Is_Computable;
-------------------
-- Boolean_Value --
-------------------
overriding function Boolean_Value
(Self : not null access constant UML_Literal_Boolean_Proxy)
return AMF.Optional_Boolean is
begin
-- Generated stub: replace with real body!
pragma Compile_Time_Warning (Standard.True, "Boolean_Value unimplemented");
raise Program_Error with "Unimplemented procedure UML_Literal_Boolean_Proxy.Boolean_Value";
return Boolean_Value (Self);
end Boolean_Value;
------------------------
-- Is_Compatible_With --
------------------------
overriding function Is_Compatible_With
(Self : not null access constant UML_Literal_Boolean_Proxy;
P : AMF.UML.Parameterable_Elements.UML_Parameterable_Element_Access)
return Boolean is
begin
-- Generated stub: replace with real body!
pragma Compile_Time_Warning (Standard.True, "Is_Compatible_With unimplemented");
raise Program_Error with "Unimplemented procedure UML_Literal_Boolean_Proxy.Is_Compatible_With";
return Is_Compatible_With (Self, P);
end Is_Compatible_With;
-------------------------
-- All_Owning_Packages --
-------------------------
overriding function All_Owning_Packages
(Self : not null access constant UML_Literal_Boolean_Proxy)
return AMF.UML.Packages.Collections.Set_Of_UML_Package is
begin
-- Generated stub: replace with real body!
pragma Compile_Time_Warning (Standard.True, "All_Owning_Packages unimplemented");
raise Program_Error with "Unimplemented procedure UML_Literal_Boolean_Proxy.All_Owning_Packages";
return All_Owning_Packages (Self);
end All_Owning_Packages;
-----------------------------
-- Is_Distinguishable_From --
-----------------------------
overriding function Is_Distinguishable_From
(Self : not null access constant UML_Literal_Boolean_Proxy;
N : AMF.UML.Named_Elements.UML_Named_Element_Access;
Ns : AMF.UML.Namespaces.UML_Namespace_Access)
return Boolean is
begin
-- Generated stub: replace with real body!
pragma Compile_Time_Warning (Standard.True, "Is_Distinguishable_From unimplemented");
raise Program_Error with "Unimplemented procedure UML_Literal_Boolean_Proxy.Is_Distinguishable_From";
return Is_Distinguishable_From (Self, N, Ns);
end Is_Distinguishable_From;
---------------
-- Namespace --
---------------
overriding function Namespace
(Self : not null access constant UML_Literal_Boolean_Proxy)
return AMF.UML.Namespaces.UML_Namespace_Access is
begin
-- Generated stub: replace with real body!
pragma Compile_Time_Warning (Standard.True, "Namespace unimplemented");
raise Program_Error with "Unimplemented procedure UML_Literal_Boolean_Proxy.Namespace";
return Namespace (Self);
end Namespace;
---------------------------
-- Is_Template_Parameter --
---------------------------
overriding function Is_Template_Parameter
(Self : not null access constant UML_Literal_Boolean_Proxy)
return Boolean is
begin
-- Generated stub: replace with real body!
pragma Compile_Time_Warning (Standard.True, "Is_Template_Parameter unimplemented");
raise Program_Error with "Unimplemented procedure UML_Literal_Boolean_Proxy.Is_Template_Parameter";
return Is_Template_Parameter (Self);
end Is_Template_Parameter;
end AMF.Internals.UML_Literal_Booleans;
|
yannickmoy/SPARKNaCl | Ada | 1,461 | ads | with SPARKNaCl.Stream;
with SPARKNaCl.Core;
package SPARKNaCl.Secretbox
with Pure,
SPARK_Mode => On
is
--------------------------------------------------------
-- Secret Key Authenticated Encryption - "SecretBox" --
--------------------------------------------------------
Secretbox_Zero_Bytes : constant := 32;
procedure Create (C : out Byte_Seq;
Status : out Boolean;
M : in Byte_Seq;
N : in Stream.HSalsa20_Nonce;
K : in Core.Salsa20_Key)
with Global => null,
Pre => (M'First = 0 and
C'First = 0 and
C'Last = M'Last and
M'Length >= 32) and then
Equal (M (0 .. 31), Zero_Bytes_32),
Post => Equal (C (0 .. 15), Zero_Bytes_16);
procedure Open
(M : out Byte_Seq; -- Output plaintext
Status : out Boolean;
C : in Byte_Seq; -- Input ciphertext
N : in Stream.HSalsa20_Nonce;
K : in Core.Salsa20_Key)
with Global => null,
Pre => (M'First = 0 and
C'First = 0 and
M'Last = C'Last and
C'Length >= 32) and then
Equal (C (0 .. 15), Zero_Bytes_16),
Post => Equal (M (0 .. 31), Zero_Bytes_32);
end SPARKNaCl.Secretbox;
|
zhmu/ananas | Ada | 378 | ads | package Renaming11 is
subtype Index_Type is Integer range 1..10;
type Arr is array (Index_Type range <>) of Integer;
type Rec (Min : Index_Type; Max : Index_Type) is record
A : Arr (Min .. Max);
end record;
type Ptr1 is access Rec;
type Ptr2 is access Ptr1;
type Ptr3 is access Ptr2;
function F (Arg : Ptr3) return Integer;
end Renaming11;
|
reznikmm/matreshka | Ada | 6,899 | 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.Font_Face_Uri_Elements is
------------
-- Create --
------------
overriding function Create
(Parameters : not null access Matreshka.DOM_Elements.Element_L2_Parameters)
return Svg_Font_Face_Uri_Element_Node is
begin
return Self : Svg_Font_Face_Uri_Element_Node do
Matreshka.ODF_Svg.Constructors.Initialize
(Self'Unchecked_Access,
Parameters.Document,
Matreshka.ODF_String_Constants.Svg_Prefix);
end return;
end Create;
----------------
-- Enter_Node --
----------------
overriding procedure Enter_Node
(Self : not null access Svg_Font_Face_Uri_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_Svg_Font_Face_Uri
(ODF.DOM.Svg_Font_Face_Uri_Elements.ODF_Svg_Font_Face_Uri_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 Svg_Font_Face_Uri_Element_Node)
return League.Strings.Universal_String
is
pragma Unreferenced (Self);
begin
return Matreshka.ODF_String_Constants.Font_Face_Uri_Element;
end Get_Local_Name;
----------------
-- Leave_Node --
----------------
overriding procedure Leave_Node
(Self : not null access Svg_Font_Face_Uri_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_Svg_Font_Face_Uri
(ODF.DOM.Svg_Font_Face_Uri_Elements.ODF_Svg_Font_Face_Uri_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 Svg_Font_Face_Uri_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_Svg_Font_Face_Uri
(Visitor,
ODF.DOM.Svg_Font_Face_Uri_Elements.ODF_Svg_Font_Face_Uri_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.Svg_URI,
Matreshka.ODF_String_Constants.Font_Face_Uri_Element,
Svg_Font_Face_Uri_Element_Node'Tag);
end Matreshka.ODF_Svg.Font_Face_Uri_Elements;
|
cielavenir/procon | Ada | 562 | adb | -- gnat compile tyama_icpc2007dA.adb
-- gnatbind -x tyama_icpc2007dA.ali
-- gnatlink tyama_icpc2007dA.ali
with Ada.Text_IO, Ada.Integer_Text_IO;
procedure icpc2007dA is
n,s,ma,mi,sum:integer;
begin
loop
ma:=0;mi:=1000;sum:=0;
Ada.Integer_Text_IO.Get(n);
if n=0 then exit; end if;
for i in 1..n loop
Ada.Integer_Text_IO.Get(s);
if ma<s then ma:=s; end if;
if mi>s then mi:=s; end if;
sum:=sum+s;
end loop;
Ada.Integer_Text_IO.Put((sum-ma-mi)/(n-2),width=>1);
Ada.Text_IO.New_line;
end loop;
end icpc2007dA; |
sungyeon/drake | Ada | 11,135 | adb | pragma Check_Policy (Trace => Ignore);
with Ada.Unchecked_Conversion;
with System.Address_To_Named_Access_Conversions;
with System.Formatting.Address;
with System.Runtime_Context;
with System.Stack;
with System.Storage_Map;
with System.Unwind.Raising;
with System.Unwind.Standard;
with C.basetsd;
with C.excpt;
with C.vadefs;
with C.winbase;
with C.windef;
with C.winnls;
with C.winnt;
package body System.Unwind.Mapping is
pragma Suppress (All_Checks);
use type C.size_t;
use type C.windef.DWORD;
use type C.winnt.struct_EXCEPTION_REGISTRATION_RECORD_ptr;
package LPSTR_Conv is
new Address_To_Named_Access_Conversions (C.char, C.winnt.LPSTR);
package LPWSTR_Conv is
new Address_To_Named_Access_Conversions (C.winnt.WCHAR, C.winnt.LPWSTR);
package EXCEPTION_REGISTRATION_RECORD_ptr_Conv is
new Address_To_Named_Access_Conversions (
C.winnt.struct_EXCEPTION_REGISTRATION_RECORD,
C.winnt.struct_EXCEPTION_REGISTRATION_RECORD_ptr);
function To_NT_TIB_ptr is
new Ada.Unchecked_Conversion (
C.winnt.struct_TEB_ptr,
C.winnt.NT_TIB_ptr);
type SEH_Handler is access function (
Exception_Record : C.winnt.struct_EXCEPTION_RECORD_ptr;
Establisher_Frame : C.void_ptr;
Context_Record : C.winnt.struct_CONTEXT_ptr;
Dispatcher_Context : C.void_ptr)
return C.signed_int
with Convention => C;
type SEH_Record is record
ExceptionList : aliased C.winnt.struct_EXCEPTION_REGISTRATION_RECORD_ptr;
Handler : aliased SEH_Handler;
end record;
for SEH_Record'Size use Standard'Address_Size * 2;
pragma Suppress_Initialization (SEH_Record);
function Ada_SEH_Handler (
Exception_Record : C.winnt.struct_EXCEPTION_RECORD_ptr;
Establisher_Frame : C.void_ptr;
Context_Record : C.winnt.struct_CONTEXT_ptr;
Dispatcher_Context : C.void_ptr)
return C.signed_int
with Convention => C;
function Ada_SEH_Handler (
Exception_Record : C.winnt.struct_EXCEPTION_RECORD_ptr;
Establisher_Frame : C.void_ptr;
Context_Record : C.winnt.struct_CONTEXT_ptr;
Dispatcher_Context : C.void_ptr)
return C.signed_int
is
function Cast is
new Ada.Unchecked_Conversion (C.windef.HMODULE, C.windef.LPCVOID);
function Cast is
new Ada.Unchecked_Conversion (C.winnt.LPWSTR_ptr, C.winnt.LPTSTR);
function Cast is
new Ada.Unchecked_Conversion (
C.basetsd.ULONG_PTR_ptr,
C.vadefs.va_list_ptr);
pragma Unreferenced (Establisher_Frame);
pragma Unreferenced (Context_Record);
pragma Unreferenced (Dispatcher_Context);
-- space for overflow detection, decided for CB1010C
Stack_Overflow_Space : constant :=
(Standard'Address_Size / Standard'Storage_Unit) * 8 * 1024 * 1024;
-- the components of the exception
Code : constant C.windef.DWORD := Exception_Record.ExceptionCode;
Eexception_Id : Exception_Data_Access;
Stack_Guard : Address := Null_Address;
begin
pragma Check (Trace, Ada.Debug.Put ("enter"));
case Code is
when C.winbase.EXCEPTION_ACCESS_VIOLATION => -- 0xC0000005
-- get stack range
declare
Stack_Top, Stack_Bottom : Address;
AV_Address : constant Address :=
System'To_Address (
Exception_Record.ExceptionInformation (1));
begin
Stack.Get (Top => Stack_Top, Bottom => Stack_Bottom);
if AV_Address >= Stack_Top - Stack_Overflow_Space
and then AV_Address < Stack_Bottom
then -- stack overflow
Stack_Guard := Stack_Top + 4096;
Eexception_Id := Standard.Storage_Error'Access;
else
Eexception_Id := Standard.Program_Error'Access;
end if;
end;
when C.winbase.EXCEPTION_INVALID_HANDLE => -- 0xC0000008
Eexception_Id := Standard.Constraint_Error'Access;
when C.winbase.EXCEPTION_ARRAY_BOUNDS_EXCEEDED -- 0xC000008C
| C.winbase.EXCEPTION_FLT_DENORMAL_OPERAND -- 0xC000008D
| C.winbase.EXCEPTION_FLT_DIVIDE_BY_ZERO -- 0xC000008E
| C.winbase.EXCEPTION_FLT_INEXACT_RESULT -- 0xC000008F
| C.winbase.EXCEPTION_FLT_INVALID_OPERATION -- 0xC0000090
| C.winbase.EXCEPTION_FLT_OVERFLOW -- 0xC0000091
| C.winbase.EXCEPTION_FLT_STACK_CHECK -- 0xC0000092
| C.winbase.EXCEPTION_FLT_UNDERFLOW -- 0xC0000093
| C.winbase.EXCEPTION_INT_DIVIDE_BY_ZERO -- 0xC0000094
| C.winbase.EXCEPTION_INT_OVERFLOW => -- 0xC0000095
Eexception_Id := Standard.Constraint_Error'Access;
when C.winbase.EXCEPTION_STACK_OVERFLOW => -- 0xC00000FD
-- get stack range
declare
Dummy : Address;
begin
Stack.Get (Top => Stack_Guard, Bottom => Dummy);
end;
Stack_Guard := Stack_Guard + 4096;
-- Storage_Error
Eexception_Id := Standard.Storage_Error'Access;
when others =>
Eexception_Id := null;
end case;
if Eexception_Id /= null then
declare
Message : String (1 .. 256);
Message_Last : Natural;
Wide_Message : aliased C.winnt.LPWSTR;
Wide_Message_Length : C.windef.DWORD;
begin
Wide_Message_Length := C.winbase.FormatMessage (
dwFlags =>
C.winbase.FORMAT_MESSAGE_FROM_HMODULE
or C.winbase.FORMAT_MESSAGE_ARGUMENT_ARRAY
or C.winbase.FORMAT_MESSAGE_ALLOCATE_BUFFER,
lpSource => Cast (Storage_Map.NTDLL),
dwMessageId => Code,
dwLanguageId => C.winnt.LANG_USER_DEFAULT,
lpBuffer => Cast (Wide_Message'Unchecked_Access),
nSize => 0,
Arguments =>
Cast (Exception_Record.ExceptionInformation (0)'Access));
declare
Wide_Message_Last : constant Natural :=
Integer (Wide_Message_Length);
Wide_Message_All : Wide_String (1 .. Wide_Message_Last);
for Wide_Message_All'Address use
LPWSTR_Conv.To_Address (Wide_Message);
begin
if Wide_Message_All (
Wide_Message_Last - 2 .. Wide_Message_Last) =
"""0x"
and then Code = C.winbase.EXCEPTION_ACCESS_VIOLATION
then
-- bug of FormatString ???
-- there are some reports in stackoverflow.com
-- perhaps, FormatString can not convert %p in
-- 'The instruction at %p referenced memory at %p.'
Message (1 .. 21) := "The instruction at 0x";
Message_Last := 21;
Formatting.Address.Image (
Address (Exception_Record.ExceptionAddress),
Message (
Message_Last + 1 ..
Message'Last
+ Formatting.Address.Address_String'Length),
Set => Formatting.Lower_Case);
Message_Last :=
Message_Last + Formatting.Address.Address_String'Length;
Message (Message_Last + 1 .. Message_Last + 24) :=
" referenced memory at 0x";
Message_Last := Message_Last + 24;
Formatting.Address.Image (
System'To_Address (
Exception_Record.ExceptionInformation (1)),
Message (
Message_Last + 1 ..
Message_Last
+ Formatting.Address.Address_String'Length),
Set => Formatting.Lower_Case);
Message_Last :=
Message_Last + Formatting.Address.Address_String'Length;
Message (Message_Last + 1) := '.';
Message_Last := Message_Last + 1;
else
Message_Last := Natural (
C.winnls.WideCharToMultiByte (
C.winnls.CP_UTF8,
0,
Wide_Message,
C.signed_int (Wide_Message_Length),
LPSTR_Conv.To_Pointer (Message'Address),
Message'Length,
null,
null));
end if;
end;
declare
Dummy : C.windef.HLOCAL;
begin
Dummy := C.winbase.LocalFree (
C.windef.HLOCAL (LPWSTR_Conv.To_Address (Wide_Message)));
end;
pragma Check (Trace, Ada.Debug.Put ("raising"));
Raising.Raise_From_Signal_Handler (
Eexception_Id,
Message => Message (1 .. Message_Last),
Stack_Guard => Stack_Guard);
end;
else
pragma Check (Trace, Ada.Debug.Put ("leave"));
return C.excpt.ExceptionContinueSearch;
end if;
end Ada_SEH_Handler;
-- implementation
procedure Install_Exception_Handler (SEH : Address) is
TLS : constant not null Runtime_Context.Task_Local_Storage_Access :=
Runtime_Context.Get_Task_Local_Storage;
TEB : constant C.winnt.struct_TEB_ptr := C.winnt.NtCurrentTeb;
TIB : constant C.winnt.NT_TIB_ptr := To_NT_TIB_ptr (TEB);
SEH_All : SEH_Record;
for SEH_All'Address use SEH;
begin
SEH_All.ExceptionList := TIB.ExceptionList;
SEH_All.Handler := Ada_SEH_Handler'Access;
-- register new handler
TIB.ExceptionList :=
EXCEPTION_REGISTRATION_RECORD_ptr_Conv.To_Pointer (SEH);
-- memory the stack area of main
TLS.SEH := SEH;
end Install_Exception_Handler;
procedure Install_Task_Exception_Handler (
SEH : Address;
Signal_Stack : not null access Signal_Stack_Type)
is
pragma Unreferenced (Signal_Stack);
begin
Install_Exception_Handler (SEH);
end Install_Task_Exception_Handler;
procedure Reinstall_Exception_Handler is
TLS : constant not null Runtime_Context.Task_Local_Storage_Access :=
Runtime_Context.Get_Task_Local_Storage;
SEH : constant Address := TLS.SEH;
TEB : constant C.winnt.struct_TEB_ptr := C.winnt.NtCurrentTeb;
TIB : constant C.winnt.NT_TIB_ptr := To_NT_TIB_ptr (TEB);
begin
if TIB.ExceptionList /=
EXCEPTION_REGISTRATION_RECORD_ptr_Conv.To_Pointer (SEH)
then
TIB.ExceptionList :=
EXCEPTION_REGISTRATION_RECORD_ptr_Conv.To_Pointer (SEH);
pragma Check (Trace, Ada.Debug.Put ("reinstalled"));
end if;
end Reinstall_Exception_Handler;
-- Note: SetUnhandledExceptionFilter is probably too late to raise
-- Ada exceptions.
end System.Unwind.Mapping;
|
optikos/oasis | Ada | 4,376 | ads | -- Copyright (c) 2019 Maxim Reznik <[email protected]>
--
-- SPDX-License-Identifier: MIT
-- License-Filename: LICENSE
-------------------------------------------------------------
with Program.Lexical_Elements;
with Program.Elements.Expressions;
with Program.Elements.Real_Range_Specifications;
with Program.Elements.Floating_Point_Types;
with Program.Element_Visitors;
package Program.Nodes.Floating_Point_Types is
pragma Preelaborate;
type Floating_Point_Type is
new Program.Nodes.Node
and Program.Elements.Floating_Point_Types.Floating_Point_Type
and Program.Elements.Floating_Point_Types.Floating_Point_Type_Text
with private;
function Create
(Digits_Token : not null Program.Lexical_Elements
.Lexical_Element_Access;
Digits_Expression : not null Program.Elements.Expressions
.Expression_Access;
Real_Range : Program.Elements.Real_Range_Specifications
.Real_Range_Specification_Access)
return Floating_Point_Type;
type Implicit_Floating_Point_Type is
new Program.Nodes.Node
and Program.Elements.Floating_Point_Types.Floating_Point_Type
with private;
function Create
(Digits_Expression : not null Program.Elements.Expressions
.Expression_Access;
Real_Range : Program.Elements.Real_Range_Specifications
.Real_Range_Specification_Access;
Is_Part_Of_Implicit : Boolean := False;
Is_Part_Of_Inherited : Boolean := False;
Is_Part_Of_Instance : Boolean := False)
return Implicit_Floating_Point_Type
with Pre =>
Is_Part_Of_Implicit or Is_Part_Of_Inherited or Is_Part_Of_Instance;
private
type Base_Floating_Point_Type is
abstract new Program.Nodes.Node
and Program.Elements.Floating_Point_Types.Floating_Point_Type
with record
Digits_Expression : not null Program.Elements.Expressions
.Expression_Access;
Real_Range : Program.Elements.Real_Range_Specifications
.Real_Range_Specification_Access;
end record;
procedure Initialize (Self : aliased in out Base_Floating_Point_Type'Class);
overriding procedure Visit
(Self : not null access Base_Floating_Point_Type;
Visitor : in out Program.Element_Visitors.Element_Visitor'Class);
overriding function Digits_Expression
(Self : Base_Floating_Point_Type)
return not null Program.Elements.Expressions.Expression_Access;
overriding function Real_Range
(Self : Base_Floating_Point_Type)
return Program.Elements.Real_Range_Specifications
.Real_Range_Specification_Access;
overriding function Is_Floating_Point_Type_Element
(Self : Base_Floating_Point_Type)
return Boolean;
overriding function Is_Type_Definition_Element
(Self : Base_Floating_Point_Type)
return Boolean;
overriding function Is_Definition_Element
(Self : Base_Floating_Point_Type)
return Boolean;
type Floating_Point_Type is
new Base_Floating_Point_Type
and Program.Elements.Floating_Point_Types.Floating_Point_Type_Text
with record
Digits_Token : not null Program.Lexical_Elements
.Lexical_Element_Access;
end record;
overriding function To_Floating_Point_Type_Text
(Self : aliased in out Floating_Point_Type)
return Program.Elements.Floating_Point_Types
.Floating_Point_Type_Text_Access;
overriding function Digits_Token
(Self : Floating_Point_Type)
return not null Program.Lexical_Elements.Lexical_Element_Access;
type Implicit_Floating_Point_Type is
new Base_Floating_Point_Type
with record
Is_Part_Of_Implicit : Boolean;
Is_Part_Of_Inherited : Boolean;
Is_Part_Of_Instance : Boolean;
end record;
overriding function To_Floating_Point_Type_Text
(Self : aliased in out Implicit_Floating_Point_Type)
return Program.Elements.Floating_Point_Types
.Floating_Point_Type_Text_Access;
overriding function Is_Part_Of_Implicit
(Self : Implicit_Floating_Point_Type)
return Boolean;
overriding function Is_Part_Of_Inherited
(Self : Implicit_Floating_Point_Type)
return Boolean;
overriding function Is_Part_Of_Instance
(Self : Implicit_Floating_Point_Type)
return Boolean;
end Program.Nodes.Floating_Point_Types;
|
reznikmm/matreshka | Ada | 4,609 | 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_Office.Currency_Attributes is
------------
-- Create --
------------
overriding function Create
(Parameters : not null access Matreshka.DOM_Attributes.Attribute_L2_Parameters)
return Office_Currency_Attribute_Node is
begin
return Self : Office_Currency_Attribute_Node do
Matreshka.ODF_Office.Constructors.Initialize
(Self'Unchecked_Access,
Parameters.Document,
Matreshka.ODF_String_Constants.Office_Prefix);
end return;
end Create;
--------------------
-- Get_Local_Name --
--------------------
overriding function Get_Local_Name
(Self : not null access constant Office_Currency_Attribute_Node)
return League.Strings.Universal_String
is
pragma Unreferenced (Self);
begin
return Matreshka.ODF_String_Constants.Currency_Attribute;
end Get_Local_Name;
begin
Matreshka.DOM_Documents.Register_Attribute
(Matreshka.ODF_String_Constants.Office_URI,
Matreshka.ODF_String_Constants.Currency_Attribute,
Office_Currency_Attribute_Node'Tag);
end Matreshka.ODF_Office.Currency_Attributes;
|
reznikmm/matreshka | Ada | 16,541 | adb | ------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- Ada Modeling Framework --
-- --
-- Runtime Library Component --
-- --
------------------------------------------------------------------------------
-- --
-- Copyright © 2011-2012, Vadim Godunko <[email protected]> --
-- All rights reserved. --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions --
-- are met: --
-- --
-- * Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- --
-- * Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in the --
-- documentation and/or other materials provided with the distribution. --
-- --
-- * Neither the name of the Vadim Godunko, IE nor the names of its --
-- contributors may be used to endorse or promote products derived from --
-- this software without specific prior written permission. --
-- --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR --
-- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
-- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED --
-- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR --
-- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF --
-- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING --
-- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS --
-- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
-- --
------------------------------------------------------------------------------
-- $Revision$ $Date$
------------------------------------------------------------------------------
with AMF.Elements;
with AMF.Internals.Element_Collections;
with AMF.Internals.Helpers;
with AMF.Internals.Tables.UML_Attributes;
with AMF.Visitors.UML_Iterators;
with AMF.Visitors.UML_Visitors;
with League.Strings.Internals;
with Matreshka.Internals.Strings;
package body AMF.Internals.UML_Realizations is
-------------------
-- Enter_Element --
-------------------
overriding procedure Enter_Element
(Self : not null access constant UML_Realization_Proxy;
Visitor : in out AMF.Visitors.Abstract_Visitor'Class;
Control : in out AMF.Visitors.Traverse_Control) is
begin
if Visitor in AMF.Visitors.UML_Visitors.UML_Visitor'Class then
AMF.Visitors.UML_Visitors.UML_Visitor'Class
(Visitor).Enter_Realization
(AMF.UML.Realizations.UML_Realization_Access (Self),
Control);
end if;
end Enter_Element;
-------------------
-- Leave_Element --
-------------------
overriding procedure Leave_Element
(Self : not null access constant UML_Realization_Proxy;
Visitor : in out AMF.Visitors.Abstract_Visitor'Class;
Control : in out AMF.Visitors.Traverse_Control) is
begin
if Visitor in AMF.Visitors.UML_Visitors.UML_Visitor'Class then
AMF.Visitors.UML_Visitors.UML_Visitor'Class
(Visitor).Leave_Realization
(AMF.UML.Realizations.UML_Realization_Access (Self),
Control);
end if;
end Leave_Element;
-------------------
-- Visit_Element --
-------------------
overriding procedure Visit_Element
(Self : not null access constant UML_Realization_Proxy;
Iterator : in out AMF.Visitors.Abstract_Iterator'Class;
Visitor : in out AMF.Visitors.Abstract_Visitor'Class;
Control : in out AMF.Visitors.Traverse_Control) is
begin
if Iterator in AMF.Visitors.UML_Iterators.UML_Iterator'Class then
AMF.Visitors.UML_Iterators.UML_Iterator'Class
(Iterator).Visit_Realization
(Visitor,
AMF.UML.Realizations.UML_Realization_Access (Self),
Control);
end if;
end Visit_Element;
-----------------
-- Get_Mapping --
-----------------
overriding function Get_Mapping
(Self : not null access constant UML_Realization_Proxy)
return AMF.UML.Opaque_Expressions.UML_Opaque_Expression_Access is
begin
return
AMF.UML.Opaque_Expressions.UML_Opaque_Expression_Access
(AMF.Internals.Helpers.To_Element
(AMF.Internals.Tables.UML_Attributes.Internal_Get_Mapping
(Self.Element)));
end Get_Mapping;
-----------------
-- Set_Mapping --
-----------------
overriding procedure Set_Mapping
(Self : not null access UML_Realization_Proxy;
To : AMF.UML.Opaque_Expressions.UML_Opaque_Expression_Access) is
begin
AMF.Internals.Tables.UML_Attributes.Internal_Set_Mapping
(Self.Element,
AMF.Internals.Helpers.To_Element
(AMF.Elements.Element_Access (To)));
end Set_Mapping;
----------------
-- Get_Client --
----------------
overriding function Get_Client
(Self : not null access constant UML_Realization_Proxy)
return AMF.UML.Named_Elements.Collections.Set_Of_UML_Named_Element is
begin
return
AMF.UML.Named_Elements.Collections.Wrap
(AMF.Internals.Element_Collections.Wrap
(AMF.Internals.Tables.UML_Attributes.Internal_Get_Client
(Self.Element)));
end Get_Client;
------------------
-- Get_Supplier --
------------------
overriding function Get_Supplier
(Self : not null access constant UML_Realization_Proxy)
return AMF.UML.Named_Elements.Collections.Set_Of_UML_Named_Element is
begin
return
AMF.UML.Named_Elements.Collections.Wrap
(AMF.Internals.Element_Collections.Wrap
(AMF.Internals.Tables.UML_Attributes.Internal_Get_Supplier
(Self.Element)));
end Get_Supplier;
----------------
-- Get_Source --
----------------
overriding function Get_Source
(Self : not null access constant UML_Realization_Proxy)
return AMF.UML.Elements.Collections.Set_Of_UML_Element is
begin
return
AMF.UML.Elements.Collections.Wrap
(AMF.Internals.Element_Collections.Wrap
(AMF.Internals.Tables.UML_Attributes.Internal_Get_Source
(Self.Element)));
end Get_Source;
----------------
-- Get_Target --
----------------
overriding function Get_Target
(Self : not null access constant UML_Realization_Proxy)
return AMF.UML.Elements.Collections.Set_Of_UML_Element is
begin
return
AMF.UML.Elements.Collections.Wrap
(AMF.Internals.Element_Collections.Wrap
(AMF.Internals.Tables.UML_Attributes.Internal_Get_Target
(Self.Element)));
end Get_Target;
-------------------------
-- Get_Related_Element --
-------------------------
overriding function Get_Related_Element
(Self : not null access constant UML_Realization_Proxy)
return AMF.UML.Elements.Collections.Set_Of_UML_Element is
begin
return
AMF.UML.Elements.Collections.Wrap
(AMF.Internals.Element_Collections.Wrap
(AMF.Internals.Tables.UML_Attributes.Internal_Get_Related_Element
(Self.Element)));
end Get_Related_Element;
---------------------------
-- Get_Client_Dependency --
---------------------------
overriding function Get_Client_Dependency
(Self : not null access constant UML_Realization_Proxy)
return AMF.UML.Dependencies.Collections.Set_Of_UML_Dependency is
begin
return
AMF.UML.Dependencies.Collections.Wrap
(AMF.Internals.Element_Collections.Wrap
(AMF.Internals.Tables.UML_Attributes.Internal_Get_Client_Dependency
(Self.Element)));
end Get_Client_Dependency;
-------------------------
-- Get_Name_Expression --
-------------------------
overriding function Get_Name_Expression
(Self : not null access constant UML_Realization_Proxy)
return AMF.UML.String_Expressions.UML_String_Expression_Access is
begin
return
AMF.UML.String_Expressions.UML_String_Expression_Access
(AMF.Internals.Helpers.To_Element
(AMF.Internals.Tables.UML_Attributes.Internal_Get_Name_Expression
(Self.Element)));
end Get_Name_Expression;
-------------------------
-- Set_Name_Expression --
-------------------------
overriding procedure Set_Name_Expression
(Self : not null access UML_Realization_Proxy;
To : AMF.UML.String_Expressions.UML_String_Expression_Access) is
begin
AMF.Internals.Tables.UML_Attributes.Internal_Set_Name_Expression
(Self.Element,
AMF.Internals.Helpers.To_Element
(AMF.Elements.Element_Access (To)));
end Set_Name_Expression;
-------------------
-- Get_Namespace --
-------------------
overriding function Get_Namespace
(Self : not null access constant UML_Realization_Proxy)
return AMF.UML.Namespaces.UML_Namespace_Access is
begin
return
AMF.UML.Namespaces.UML_Namespace_Access
(AMF.Internals.Helpers.To_Element
(AMF.Internals.Tables.UML_Attributes.Internal_Get_Namespace
(Self.Element)));
end Get_Namespace;
------------------------
-- Get_Qualified_Name --
------------------------
overriding function Get_Qualified_Name
(Self : not null access constant UML_Realization_Proxy)
return AMF.Optional_String is
begin
declare
use type Matreshka.Internals.Strings.Shared_String_Access;
Aux : constant Matreshka.Internals.Strings.Shared_String_Access
:= AMF.Internals.Tables.UML_Attributes.Internal_Get_Qualified_Name (Self.Element);
begin
if Aux = null then
return (Is_Empty => True);
else
return (False, League.Strings.Internals.Create (Aux));
end if;
end;
end Get_Qualified_Name;
-----------------------------------
-- Get_Owning_Template_Parameter --
-----------------------------------
overriding function Get_Owning_Template_Parameter
(Self : not null access constant UML_Realization_Proxy)
return AMF.UML.Template_Parameters.UML_Template_Parameter_Access is
begin
return
AMF.UML.Template_Parameters.UML_Template_Parameter_Access
(AMF.Internals.Helpers.To_Element
(AMF.Internals.Tables.UML_Attributes.Internal_Get_Owning_Template_Parameter
(Self.Element)));
end Get_Owning_Template_Parameter;
-----------------------------------
-- Set_Owning_Template_Parameter --
-----------------------------------
overriding procedure Set_Owning_Template_Parameter
(Self : not null access UML_Realization_Proxy;
To : AMF.UML.Template_Parameters.UML_Template_Parameter_Access) is
begin
AMF.Internals.Tables.UML_Attributes.Internal_Set_Owning_Template_Parameter
(Self.Element,
AMF.Internals.Helpers.To_Element
(AMF.Elements.Element_Access (To)));
end Set_Owning_Template_Parameter;
----------------------------
-- Get_Template_Parameter --
----------------------------
overriding function Get_Template_Parameter
(Self : not null access constant UML_Realization_Proxy)
return AMF.UML.Template_Parameters.UML_Template_Parameter_Access is
begin
return
AMF.UML.Template_Parameters.UML_Template_Parameter_Access
(AMF.Internals.Helpers.To_Element
(AMF.Internals.Tables.UML_Attributes.Internal_Get_Template_Parameter
(Self.Element)));
end Get_Template_Parameter;
----------------------------
-- Set_Template_Parameter --
----------------------------
overriding procedure Set_Template_Parameter
(Self : not null access UML_Realization_Proxy;
To : AMF.UML.Template_Parameters.UML_Template_Parameter_Access) is
begin
AMF.Internals.Tables.UML_Attributes.Internal_Set_Template_Parameter
(Self.Element,
AMF.Internals.Helpers.To_Element
(AMF.Elements.Element_Access (To)));
end Set_Template_Parameter;
-------------------------
-- All_Owning_Packages --
-------------------------
overriding function All_Owning_Packages
(Self : not null access constant UML_Realization_Proxy)
return AMF.UML.Packages.Collections.Set_Of_UML_Package is
begin
-- Generated stub: replace with real body!
pragma Compile_Time_Warning (Standard.True, "All_Owning_Packages unimplemented");
raise Program_Error with "Unimplemented procedure UML_Realization_Proxy.All_Owning_Packages";
return All_Owning_Packages (Self);
end All_Owning_Packages;
-----------------------------
-- Is_Distinguishable_From --
-----------------------------
overriding function Is_Distinguishable_From
(Self : not null access constant UML_Realization_Proxy;
N : AMF.UML.Named_Elements.UML_Named_Element_Access;
Ns : AMF.UML.Namespaces.UML_Namespace_Access)
return Boolean is
begin
-- Generated stub: replace with real body!
pragma Compile_Time_Warning (Standard.True, "Is_Distinguishable_From unimplemented");
raise Program_Error with "Unimplemented procedure UML_Realization_Proxy.Is_Distinguishable_From";
return Is_Distinguishable_From (Self, N, Ns);
end Is_Distinguishable_From;
---------------
-- Namespace --
---------------
overriding function Namespace
(Self : not null access constant UML_Realization_Proxy)
return AMF.UML.Namespaces.UML_Namespace_Access is
begin
-- Generated stub: replace with real body!
pragma Compile_Time_Warning (Standard.True, "Namespace unimplemented");
raise Program_Error with "Unimplemented procedure UML_Realization_Proxy.Namespace";
return Namespace (Self);
end Namespace;
------------------------
-- Is_Compatible_With --
------------------------
overriding function Is_Compatible_With
(Self : not null access constant UML_Realization_Proxy;
P : AMF.UML.Parameterable_Elements.UML_Parameterable_Element_Access)
return Boolean is
begin
-- Generated stub: replace with real body!
pragma Compile_Time_Warning (Standard.True, "Is_Compatible_With unimplemented");
raise Program_Error with "Unimplemented procedure UML_Realization_Proxy.Is_Compatible_With";
return Is_Compatible_With (Self, P);
end Is_Compatible_With;
---------------------------
-- Is_Template_Parameter --
---------------------------
overriding function Is_Template_Parameter
(Self : not null access constant UML_Realization_Proxy)
return Boolean is
begin
-- Generated stub: replace with real body!
pragma Compile_Time_Warning (Standard.True, "Is_Template_Parameter unimplemented");
raise Program_Error with "Unimplemented procedure UML_Realization_Proxy.Is_Template_Parameter";
return Is_Template_Parameter (Self);
end Is_Template_Parameter;
end AMF.Internals.UML_Realizations;
|
onox/orka | Ada | 19,804 | 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.Command_Line;
with Ada.Directories;
with Ada.Exceptions;
with Ada.Real_Time;
with GL.Low_Level.Enums;
with GL.Objects.Samplers;
with GL.Objects.Textures;
with GL.Pixels;
with GL.Types;
with Orka.Behaviors;
with Orka.Contexts.AWT;
with Orka.Cameras.Rotate_Around_Cameras;
with Orka.Culling;
with Orka.Debug;
with Orka.Frame_Graphs;
with Orka.Futures;
with Orka.Jobs;
with Orka.Loggers.Terminal;
with Orka.Logging.Default;
with Orka.Loops;
with Orka.OS;
with Orka.Rendering.Drawing;
with Orka.Rendering.Framebuffers;
with Orka.Rendering.Programs.Modules;
with Orka.Rendering.Programs.Uniforms;
with Orka.Rendering.States;
with Orka.Rendering.Textures;
with Orka.Resources.Loaders;
with Orka.Resources.Locations.Directories;
with Orka.Resources.Managers;
with Orka.Resources.Models.glTF;
with Orka.Types;
with Orka.Windows;
with AWT.Inputs;
with AWT.Monitors;
with Orka_Package_glTF;
procedure Orka_GLTF is
Width : constant := 1280;
Height : constant := 720;
Samples : constant := 2;
Light_Position : constant Orka.Types.Singles.Vector4 := (0.0, 0.0, 0.0, 1.0);
use all type Orka.Logging.Default_Module;
use all type Orka.Logging.Severity;
procedure Log is new Orka.Logging.Default.Generic_Log (Application);
type Add_Behavior_Access is access procedure (Object : Orka.Behaviors.Behavior_Ptr);
Add_Behavior : Add_Behavior_Access := null;
Scene : Orka.Behaviors.Behavior_Array_Access;
----------------------------------------------------------------------
procedure Load_Texture (Texture : in out GL.Objects.Textures.Texture) is
Pixels : aliased constant Orka.Float_32_Array
-- White
:= (0.5, 0.5, 0.5, 1.0, 1.0, 1.0, 0.5, 0.5, 0.5, 1.0, 1.0, 1.0,
1.0, 1.0, 1.0, 0.5, 0.5, 0.5, 1.0, 1.0, 1.0, 0.5, 0.5, 0.5,
0.5, 0.5, 0.5, 1.0, 1.0, 1.0, 0.5, 0.5, 0.5, 1.0, 1.0, 1.0,
1.0, 1.0, 1.0, 0.5, 0.5, 0.5, 1.0, 1.0, 1.0, 0.5, 0.5, 0.5,
-- Red
0.5, 0.5, 0.5, 1.0, 0.0, 0.0, 0.5, 0.5, 0.5, 1.0, 0.0, 0.0,
1.0, 0.0, 0.0, 0.5, 0.5, 0.5, 1.0, 0.0, 0.0, 0.5, 0.5, 0.5,
0.5, 0.5, 0.5, 1.0, 0.0, 0.0, 0.5, 0.5, 0.5, 1.0, 0.0, 0.0,
1.0, 0.0, 0.0, 0.5, 0.5, 0.5, 1.0, 0.0, 0.0, 0.5, 0.5, 0.5,
-- Green
0.5, 0.5, 0.5, 0.0, 1.0, 0.0, 0.5, 0.5, 0.5, 0.0, 1.0, 0.0,
0.0, 1.0, 0.0, 0.5, 0.5, 0.5, 0.0, 1.0, 0.0, 0.5, 0.5, 0.5,
0.5, 0.5, 0.5, 0.0, 1.0, 0.0, 0.5, 0.5, 0.5, 0.0, 1.0, 0.0,
0.0, 1.0, 0.0, 0.5, 0.5, 0.5, 0.0, 1.0, 0.0, 0.5, 0.5, 0.5,
-- Blue
0.5, 0.5, 0.5, 0.0, 0.0, 1.0, 0.5, 0.5, 0.5, 0.0, 0.0, 1.0,
0.0, 0.0, 1.0, 0.5, 0.5, 0.5, 0.0, 0.0, 1.0, 0.5, 0.5, 0.5,
0.5, 0.5, 0.5, 0.0, 0.0, 1.0, 0.5, 0.5, 0.5, 0.0, 0.0, 1.0,
0.0, 0.0, 1.0, 0.5, 0.5, 0.5, 0.0, 0.0, 1.0, 0.5, 0.5, 0.5,
-- Cyan
0.5, 0.5, 0.5, 0.0, 1.0, 1.0, 0.5, 0.5, 0.5, 0.0, 1.0, 1.0,
0.0, 1.0, 1.0, 0.5, 0.5, 0.5, 0.0, 1.0, 1.0, 0.5, 0.5, 0.5,
0.5, 0.5, 0.5, 0.0, 1.0, 1.0, 0.5, 0.5, 0.5, 0.0, 1.0, 1.0,
0.0, 1.0, 1.0, 0.5, 0.5, 0.5, 0.0, 1.0, 1.0, 0.5, 0.5, 0.5,
-- Yellow
0.5, 0.5, 0.5, 1.0, 1.0, 0.0, 0.5, 0.5, 0.5, 1.0, 1.0, 0.0,
1.0, 1.0, 0.0, 0.5, 0.5, 0.5, 1.0, 1.0, 0.0, 0.5, 0.5, 0.5,
0.5, 0.5, 0.5, 1.0, 1.0, 0.0, 0.5, 0.5, 0.5, 1.0, 1.0, 0.0,
1.0, 1.0, 0.0, 0.5, 0.5, 0.5, 1.0, 1.0, 0.0, 0.5, 0.5, 0.5,
-- Magenta
0.5, 0.5, 0.5, 1.0, 0.0, 1.0, 0.5, 0.5, 0.5, 1.0, 0.0, 1.0,
1.0, 0.0, 1.0, 0.5, 0.5, 0.5, 1.0, 0.0, 1.0, 0.5, 0.5, 0.5,
0.5, 0.5, 0.5, 1.0, 0.0, 1.0, 0.5, 0.5, 0.5, 1.0, 0.0, 1.0,
1.0, 0.0, 1.0, 0.5, 0.5, 0.5, 1.0, 0.0, 1.0, 0.5, 0.5, 0.5);
begin
Texture.Allocate_Storage (1, 1, GL.Pixels.RGBA8, 4, 4, 7);
Texture.Load_From_Data (0, 0, 0, 0, 4, 4, 7,
GL.Pixels.RGB, GL.Pixels.Float, Pixels'Address);
end Load_Texture;
package Job_System renames Orka_Package_glTF.Job_System;
package Loader renames Orka_Package_glTF.Loader;
use Ada.Exceptions;
begin
if Ada.Command_Line.Argument_Count /= 1 then
Orka.OS.Put_Line ("Usage: <path to .gltf file");
Job_System.Shutdown;
Loader.Shutdown;
return;
end if;
Orka.Logging.Set_Logger (Orka.Loggers.Terminal.Create_Logger (Level => Orka.Loggers.Debug));
AWT.Initialize;
for Monitor of AWT.Monitors.Monitors loop
Monitor.Log_Information;
end loop;
declare
Context : constant Orka.Contexts.Context'Class := Orka.Contexts.AWT.Create_Context
(Version => (4, 2), Flags => (Debug => True, others => False));
Window : constant Orka.Windows.Window'Class
:= Orka.Contexts.AWT.Create_Window (Context, Width, Height);
begin
Orka.Debug.Set_Log_Messages (Enable => True, Raise_API_Error => True);
declare
Full_Path : constant String := Ada.Command_Line.Argument (1);
Location_Path : constant String := Ada.Directories.Containing_Directory (Full_Path);
Model_Path : constant String := Ada.Directories.Simple_Name (Full_Path);
use Orka.Resources;
Location_Shaders : constant Locations.Location_Ptr
:= Locations.Directories.Create_Location ("data/shaders");
package LE renames GL.Low_Level.Enums;
use Orka.Rendering.Programs;
use Orka.Rendering.Framebuffers;
P_1 : constant Program := Create_Program (Modules.Create_Module
(Location_Shaders,
VS => "tools/gltf.vert",
FS => "tools/gltf.frag"));
P_2 : constant Program := Create_Program (Modules.Create_Module
(Location_Shaders,
VS => "oversized-triangle.vert",
FS => "tools/resolve.frag"));
Uni_View : constant Uniforms.Uniform := P_1.Uniform ("view");
Uni_Proj : constant Uniforms.Uniform := P_1.Uniform ("proj");
Uni_Light : constant Uniforms.Uniform := P_1.Uniform ("lightPosition");
----------------------------------------------------------------------
Uni_Texture : constant Uniforms.Uniform_Sampler := P_1.Uniform_Sampler ("diffuseTexture");
Uni_Resolution : constant Uniforms.Uniform := P_2.Uniform ("screenResolution");
Uni_Exposure : constant Uniforms.Uniform := P_2.Uniform ("exposure");
use GL.Objects.Textures;
use GL.Objects.Samplers;
Texture_1 : Texture (LE.Texture_2D_Array);
Sampler_1 : Sampler;
----------------------------------------------------------------------
FB_D : constant Framebuffer := Create_Default_Framebuffer (Window.Width, Window.Height);
Lens : constant Orka.Cameras.Camera_Lens :=
Orka.Cameras.Create_Lens
(Width, Height, Orka.Cameras.Transforms.FOV (36.0, 50.0));
Current_Camera : aliased Orka.Cameras.Rotate_Around_Cameras.Rotate_Around_Camera :=
Orka.Cameras.Rotate_Around_Cameras.Create_Camera (Lens);
use Orka.Culling;
Culler_1 : aliased Culler := Create_Culler (Location_Shaders);
----------------------------------------------------------------------
Group : aliased Orka.Resources.Models.Group_Access := null;
use type Orka.Resources.Models.Group_Access;
Group_Added : Boolean := False;
procedure Run_P1 (P : in out Program) is
Camera : constant Orka.Cameras.Camera_Ptr := Current_Camera'Unchecked_Access;
begin
Uni_View.Set_Matrix (Camera.View_Matrix);
declare
use Orka.Cameras.Transforms;
begin
-- TODO Don't re-compute projection matrix every frame
Culler_1.Bind (Camera.Projection_Matrix * Camera.View_Matrix);
end;
if Group /= null then
if not Group_Added then
Group_Added := True;
declare
Instance_1 : Orka.Resources.Models.Model_Instance_Ptr :=
new Orka_Package_glTF.No_Behavior'(Orka.Resources.Models.Model_Instance
with Position => (0.0, 0.0, 0.0, 1.0));
begin
Group.Add_Instance (Instance_1);
Add_Behavior (Orka.Behaviors.Behavior_Ptr (Instance_1));
-- For Rotate_Around_Camera and Look_At_Camera
if Camera.all in Orka.Cameras.Observing_Camera'Class then
Orka.Cameras.Observing_Camera'Class (Camera.all).Look_At
(Orka.Behaviors.Behavior_Ptr (Instance_1));
end if;
end;
end if;
Group.Cull;
P.Use_Program;
-- Render objects in scene here
for Behavior of Scene.all loop
Behavior.Render;
end loop;
Group.Render;
end if;
end Run_P1;
procedure Run_P2 (P : in out Program) is
begin
Uni_Resolution.Set_Vector (Orka.Types.Singles.Vector4'
(Orka.Float_32 (FB_D.Width), Orka.Float_32 (FB_D.Height), 0.0, 0.0));
Uni_Exposure.Set_Single (1.0);
Orka.Rendering.Drawing.Draw (GL.Types.Triangles, 0, 3);
end Run_P2;
use Orka.Frame_Graphs;
Graph_Builder : Orka.Frame_Graphs.Frame_Graph
(Maximum_Passes => 3,
Maximum_Handles => 10,
Maximum_Resources => 10);
Default_State : constant Orka.Rendering.States.State := (others => <>);
Fullscreen_State : constant Orka.Rendering.States.State :=
(Depth_Func => GL.Types.Always, others => <>);
Pass_1 : Render_Pass'Class :=
Graph_Builder.Add_Pass ("P1", Default_State, P_1, Run_P1'Unrestricted_Access);
Pass_2 : Render_Pass'Class :=
Graph_Builder.Add_Pass ("P2", Fullscreen_State, P_2, Run_P2'Unrestricted_Access);
Resource_1 : constant Orka.Frame_Graphs.Resource :=
(Name => +"R1",
Kind => LE.Texture_2D_Multisample,
Format => GL.Pixels.R11F_G11F_B10F,
Size => (1280, 720, 1),
Samples => Samples,
others => <>);
Resource_2 : constant Orka.Frame_Graphs.Resource :=
(Name => +"R2",
Kind => LE.Texture_2D_Multisample,
Format => GL.Pixels.Depth_Component32F,
Size => (1280, 720, 1),
Samples => Samples,
others => <>);
Resource_3 : constant Orka.Frame_Graphs.Resource :=
(Name => +"R3",
Kind => LE.Texture_2D,
Format => GL.Pixels.R11F_G11F_B10F,
Size => (FB_D.Width, FB_D.Height, 1),
Samples => 0,
others => <>);
----------------------------------------------------------------------
task Resource_Test;
Manager : constant Managers.Manager_Ptr := Managers.Create_Manager;
task body Resource_Test is
use Ada.Real_Time;
Loader_glTF : constant Loaders.Loader_Ptr := Models.glTF.Create_Loader (Manager);
Location_Models : constant Locations.Location_Ptr
:= Locations.Directories.Create_Location (Location_Path);
begin
Loader.Add_Location (Location_Models, Loader_glTF);
declare
T1 : constant Time := Clock;
Future_Ref : Orka.Futures.Pointers.Reference := Loader.Load (Model_Path).Get;
use type Orka.Futures.Status;
Resource_Status : Orka.Futures.Status;
Resource_Future : constant Orka.Futures.Future_Access := Future_Ref.Value;
begin
select
Resource_Future.Wait_Until_Done (Resource_Status);
pragma Assert (Resource_Status = Orka.Futures.Done);
pragma Assert (Manager.Contains (Model_Path));
declare
Model_1 : constant Models.Model_Ptr
:= Models.Model_Ptr (Manager.Resource (Model_Path));
Handle : Orka.Futures.Pointers.Mutable_Pointer;
Create_Instance_Job : constant Orka.Jobs.Job_Ptr
:= new Orka_Package_glTF.Create_Group_Job'
(Orka.Jobs.Abstract_Job with
Model => Model_1,
Culler => Culler_1'Unchecked_Access,
Group => Group'Unchecked_Access);
begin
Job_System.Queue.Enqueue (Create_Instance_Job, Handle);
end;
or
delay until T1 + Milliseconds (4000);
Log (Failure, "Not completed loading: " & Future_Ref.Current_Status'Image);
end select;
end;
exception
when Error : others =>
Log (Orka.Loggers.Error, "Error loading resource: " & Exception_Information (Error));
end Resource_Test;
begin
Pass_1.Add_Output (Resource_1, Framebuffer_Attachment, 0);
Pass_1.Add_Output (Resource_2, Framebuffer_Attachment, 1);
Pass_2.Add_Input (Resource_1, Texture_Read, 0);
Pass_2.Add_Output (Resource_3, Framebuffer_Attachment, 0);
Sampler_1.Set_X_Wrapping (Clamp_To_Edge);
Sampler_1.Set_Y_Wrapping (Clamp_To_Edge);
Sampler_1.Set_Minifying_Filter (Nearest);
Sampler_1.Set_Magnifying_Filter (Nearest);
Sampler_1.Bind (0);
-- Load checkerboard texture array
Load_Texture (Texture_1);
Uni_Texture.Verify_Compatibility (Texture_1);
Orka.Rendering.Textures.Bind (Texture_1, Orka.Rendering.Textures.Texture, 0);
Uni_Proj.Set_Matrix (Current_Camera.Projection_Matrix);
Uni_Light.Set_Vector (Light_Position);
Window.Set_Title ("glTF viewer - " & Model_Path);
declare
package Loops is new Orka.Loops
(Time_Step => Ada.Real_Time.Microseconds (2_083),
Frame_Limit => Ada.Real_Time.Microseconds (16_667),
Camera => Current_Camera'Unchecked_Access,
Job_Manager => Job_System);
procedure Add_Behavior_Callback (Object : Orka.Behaviors.Behavior_Ptr);
-- Resource_2 is depth buffer
-- Resource_3 is color buffer
Graph : Orka.Frame_Graphs.Renderable_Graph'Class := Graph_Builder.Cull (Resource_2);
procedure Render_Scene
(Scene_X : not null Orka.Behaviors.Behavior_Array_Access;
Camera : Orka.Cameras.Camera_Ptr) is
begin
Add_Behavior := Add_Behavior_Callback'Unrestricted_Access;
Scene := Scene_X;
Graph.Render (Context);
if Group /= null then
Group.After_Render;
for Behavior of Scene.all loop
Behavior.After_Render;
end loop;
end if;
Window.Swap_Buffers;
if Window.Should_Close then
Loops.Stop_Loop;
end if;
end Render_Scene;
procedure Add_Behavior_Callback (Object : Orka.Behaviors.Behavior_Ptr) is
begin
Loops.Scene.Add (Object);
end Add_Behavior_Callback;
begin
Graph.Initialize (Location_Shaders, FB_D);
Graph.Log_Graph;
Loops.Scene.Add (Orka.Behaviors.Null_Behavior);
declare
task Render_Task is new Orka.Contexts.Task_With_Surface_Context with
entry Move_Context
(Context : not null Orka.Contexts.Surface_Context_Access;
Window : in out Orka.Windows.Window'Class);
end Render_Task;
task body Render_Task is
Context : Orka.Contexts.Surface_Context_Access;
begin
accept Move_Context
(Context : not null Orka.Contexts.Surface_Context_Access;
Window : in out Orka.Windows.Window'Class)
do
Context.Make_Current (Window);
Render_Task.Context := Context;
end Move_Context;
Loops.Run_Loop (Render_Scene'Access);
Context.Make_Not_Current;
exception
when Error : others =>
Log (Orka.Loggers.Error, "Error: " & Exception_Information (Error));
Context.Make_Not_Current;
raise;
end Render_Task;
begin
Context.Move_To (Render_Task, Window);
while not Window.Should_Close loop
AWT.Process_Events (0.016667);
declare
Pointer : constant AWT.Inputs.Pointer_State := Window.State;
Keyboard : constant AWT.Inputs.Keyboard_State := Window.State;
use all type AWT.Inputs.Button_State;
use all type AWT.Inputs.Keyboard_Button;
use all type AWT.Inputs.Pointer_Button;
use all type AWT.Inputs.Pointer_Mode;
use all type AWT.Inputs.Dimension;
Rotate_Camera : constant Boolean :=
Pointer.Focused and Pointer.Buttons (Right) = Pressed;
begin
if Keyboard.Pressed (Key_Escape) then
Window.Close;
end if;
declare
New_Mode : constant AWT.Inputs.Pointer_Mode :=
(if Rotate_Camera then Locked else Visible);
begin
if Pointer.Mode /= New_Mode then
Window.Set_Pointer_Mode (New_Mode);
end if;
end;
-- FIXME Update with PO?
Current_Camera.Change_Orientation
(((if Rotate_Camera then Orka.Float_64 (Pointer.Relative (X)) else 0.0),
(if Rotate_Camera then Orka.Float_64 (Pointer.Relative (Y)) else 0.0),
Orka.Float_64 (Pointer.Scroll (Y)),
0.0));
end;
end loop;
end;
end;
end;
end;
Job_System.Shutdown;
Loader.Shutdown;
exception
when Error : others =>
Orka.OS.Put_Line ("Error: " & Exception_Information (Error));
Job_System.Shutdown;
Loader.Shutdown;
end Orka_GLTF;
|
apple-oss-distributions/old_ncurses | Ada | 6,840 | adb | ------------------------------------------------------------------------------
-- --
-- GNAT ncurses Binding Samples --
-- --
-- ncurses --
-- --
-- B O D Y --
-- --
------------------------------------------------------------------------------
-- Copyright (c) 2000 Free Software Foundation, Inc. --
-- --
-- Permission is hereby granted, free of charge, to any person obtaining a --
-- copy of this software and associated documentation files (the --
-- "Software"), to deal in the Software without restriction, including --
-- without limitation the rights to use, copy, modify, merge, publish, --
-- distribute, distribute with modifications, sublicense, and/or sell --
-- copies of the Software, and to permit persons to whom the Software is --
-- furnished to do so, subject to the following conditions: --
-- --
-- The above copyright notice and this permission notice shall be included --
-- in all copies or substantial portions of the Software. --
-- --
-- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS --
-- OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF --
-- MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. --
-- IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, --
-- DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR --
-- OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR --
-- THE USE OR OTHER DEALINGS IN THE SOFTWARE. --
-- --
-- Except as contained in this notice, the name(s) of the above copyright --
-- holders shall not be used in advertising or otherwise to promote the --
-- sale, use or other dealings in this Software without prior written --
-- authorization. --
------------------------------------------------------------------------------
-- Author: Eugene V. Melaragno <[email protected]> 2000
-- Version Control
-- $Revision: 1.1.1.1 $
-- Binding Version 01.00
------------------------------------------------------------------------------
with ncurses2.util; use ncurses2.util;
with Terminal_Interface.Curses; use Terminal_Interface.Curses;
-- test effects of overlapping windows
procedure ncurses2.overlap_test is
procedure fillwin (win : Window; ch : Character);
procedure crosswin (win : Window; ch : Character);
procedure fillwin (win : Window; ch : Character) is
y1 : Line_Position;
x1 : Column_Position;
begin
Get_Size (win, y1, x1);
for y in 0 .. y1 - 1 loop
Move_Cursor (win, y, 0);
for x in 0 .. x1 - 1 loop
Add (win, Ch => ch);
end loop;
end loop;
exception
when Curses_Exception => null;
-- write to lower right corner
end fillwin;
procedure crosswin (win : Window; ch : Character) is
y1 : Line_Position;
x1 : Column_Position;
begin
Get_Size (win, y1, x1);
for y in 0 .. y1 - 1 loop
for x in 0 .. x1 - 1 loop
if (((x > (x1 - 1) / 3) and (x <= (2 * (x1 - 1)) / 3))
or (((y > (y1 - 1) / 3) and (y <= (2 * (y1 - 1)) / 3)))) then
Move_Cursor (win, y, x);
Add (win, Ch => ch);
end if;
end loop;
end loop;
end crosswin;
-- In a 24x80 screen like some xterms are, the instructions will
-- be overwritten.
ch : Character;
win1 : Window := New_Window (9, 20, 3, 3);
win2 : Window := New_Window (9, 20, 9, 16);
begin
Set_Raw_Mode (SwitchOn => True);
Refresh;
Move_Cursor (Line => 0, Column => 0);
Add (Str => "This test shows the behavior of wnoutrefresh() with " &
"respect to");
Add (Ch => newl);
Add (Str => "the shared region of two overlapping windows A and B. "&
"The cross");
Add (Ch => newl);
Add (Str => "pattern in each window does not overlap the other.");
Add (Ch => newl);
Move_Cursor (Line => 18, Column => 0);
Add (Str => "a = refresh A, then B, then doupdate. b = refresh B, " &
"then A, then doupdaute");
Add (Ch => newl);
Add (Str => "c = fill window A with letter A. d = fill window B " &
"with letter B.");
Add (Ch => newl);
Add (Str => "e = cross pattern in window A. f = cross pattern " &
"in window B.");
Add (Ch => newl);
Add (Str => "g = clear window A. h = clear window B.");
Add (Ch => newl);
Add (Str => "i = overwrite A onto B. j = overwrite " &
"B onto A.");
Add (Ch => newl);
Add (Str => "^Q/ESC = terminate test.");
loop
ch := Code_To_Char (Getchar);
exit when ch = CTRL ('Q') or ch = CTRL ('['); -- QUIT or ESCAPE
case ch is
when 'a' => -- refresh window A first, then B
Refresh_Without_Update (win1);
Refresh_Without_Update (win2);
Update_Screen;
when 'b' => -- refresh window B first, then A
Refresh_Without_Update (win2);
Refresh_Without_Update (win1);
Update_Screen;
when 'c' => -- fill window A so it's visible
fillwin (win1, 'A');
when 'd' => -- fill window B so it's visible
fillwin (win2, 'B');
when 'e' => -- cross test pattern in window A
crosswin (win1, 'A');
when 'f' => -- cross test pattern in window B
crosswin (win2, 'B');
when 'g' => -- clear window A
Clear (win1);
Move_Cursor (win1, 0, 0);
when 'h' => -- clear window B
Clear (win2);
Move_Cursor (win2, 0, 0);
when 'i' => -- overwrite A onto B
Overwrite (win1, win2);
when 'j' => -- overwrite B onto A
Overwrite (win2, win1);
when others => null;
end case;
end loop;
Delete (win2);
Delete (win1);
Erase;
End_Windows;
end ncurses2.overlap_test;
|
BrickBot/Bound-T-H8-300 | Ada | 9,581 | ads | -- Bounds.Opt (decl)
--
-- Command-line options for the dynamic bounding functions.
--
-- A component of the Bound-T Worst-Case Execution Time Tool.
--
-------------------------------------------------------------------------------
-- Copyright (c) 1999 .. 2015 Tidorum Ltd
-- All rights reserved.
--
-- Redistribution and use in source and binary forms, with or without
-- modification, are permitted provided that the following conditions are met:
--
-- 1. Redistributions of source code must retain the above copyright notice, this
-- list of conditions and the following disclaimer.
-- 2. Redistributions in binary form must reproduce the above copyright notice,
-- this list of conditions and the following disclaimer in the documentation
-- and/or other materials provided with the distribution.
--
-- This software is provided by the copyright holders and contributors "as is" and
-- any express or implied warranties, including, but not limited to, the implied
-- warranties of merchantability and fitness for a particular purpose are
-- disclaimed. In no event shall the copyright owner or contributors be liable for
-- any direct, indirect, incidental, special, exemplary, or consequential damages
-- (including, but not limited to, procurement of substitute goods or services;
-- loss of use, data, or profits; or business interruption) however caused and
-- on any theory of liability, whether in contract, strict liability, or tort
-- (including negligence or otherwise) arising in any way out of the use of this
-- software, even if advised of the possibility of such damage.
--
-- Other modules (files) of this software composition should contain their
-- own copyright statements, which may have different copyright and usage
-- conditions. The above conditions apply to this file.
-------------------------------------------------------------------------------
--
-- $Revision: 1.26 $
-- $Date: 2015/10/24 19:36:47 $
--
-- $Log: bounds-opt.ads,v $
-- Revision 1.26 2015/10/24 19:36:47 niklas
-- Moved to free licence.
--
-- Revision 1.25 2013-02-05 20:09:11 niklas
-- Using Options.General.Trace_Resolution for Trace_Data_Resolution.
--
-- Revision 1.24 2011-08-31 04:23:33 niklas
-- BT-CH-0222: Option registry. Option -dump. External help files.
--
-- Revision 1.23 2009-12-27 22:34:31 niklas
-- BT-CH-0205: Licensing based on code size and time/space dimensions.
--
-- Revision 1.22 2008-11-09 21:41:57 niklas
-- BT-CH-0158: Option "-trace instr".
--
-- Revision 1.21 2008/04/26 19:19:43 niklas
-- BT-CH-0124: Joint loop counters and induction variables.
--
-- Revision 1.20 2007/12/22 15:23:46 niklas
-- BT-CH-0101: Option "-trace graph".
--
-- Revision 1.19 2007/10/31 12:16:00 niklas
-- BT-CH-0095: Arithmetic analysis of "live" dynamic data refs.
--
-- Revision 1.18 2007/10/28 09:32:45 niklas
-- BT-CH-0092: Arithmetic analysis of dynamic data refs is optional.
--
-- Revision 1.17 2007/08/06 09:20:42 niklas
-- Added option Trace_Phase.
--
-- Revision 1.16 2007/01/13 13:51:02 niklas
-- BT-CH-0041.
--
-- Revision 1.15 2006/09/04 15:07:03 niklas
-- Added the option "-trace arith", as Bounds.Opt.Trace_Arith.
--
-- Revision 1.14 2005/09/14 11:50:30 niklas
-- Extended the meaning of Trace_Context to display the asserted and
-- derived bounds when starting any arithmetic analysis of a
-- subprogram, whether universal or context-dependent.
--
-- Revision 1.13 2005/09/12 19:02:57 niklas
-- BT-CH-0008.
--
-- Revision 1.12 2005/06/28 08:36:10 niklas
-- Amended the names of -trace options to Trace_Xxx.
-- Added option Trace_Context.
--
-- Revision 1.11 2005/02/23 09:05:14 niklas
-- BT-CH-0005.
--
-- Revision 1.10 2005/02/16 21:11:39 niklas
-- BT-CH-0002.
--
-- Revision 1.9 2004/05/01 20:36:33 niklas
-- First Tidorum version.
-- Added option Bound_Time.
-- Moved option Warn_Unresolved_Data to the new package Flow.Dynamic.Opt.
--
-- Revision 1.8 2003/02/27 14:36:44 holsti
-- Added option Warn_Unresolved_Data.
--
-- Revision 1.7 2001/12/18 20:34:44 holsti
-- Default_Max_Dependency_Depth added.
--
-- Revision 1.6 2001/12/14 10:48:34 saarinen
-- Added option 'max_dependency_depth'.
--
-- Revision 1.5 2001/03/10 22:35:47 holsti
-- Show_Cell_Sets (-trace io) added.
--
-- Revision 1.4 2001/02/19 14:48:06 holsti
-- Option Bound_Stack added.
--
-- Revision 1.3 2001/02/14 06:49:12 holsti
-- Option to trace counters added.
--
-- Revision 1.2 2001/01/07 21:59:49 holsti
-- Show_Parameters added. Default values := False.
--
-- Revision 1.1 2000/08/18 18:15:40 holsti
-- First version.
--
with License.Dimension;
with Options.Bool;
with Options.Nat;
with Programs.Opt;
package Bounds.Opt is
Bound_Time_Opt : aliased Options.Bool.Option_T (
Default => License.Dimension.Time);
--
-- Whether to compute bounds on the execution time.
--
Bound_Time : Boolean renames Bound_Time_Opt.Value;
Bound_Stack_Opt : aliased Options.Bool.Option_T (
Default => License.Dimension.Space
and not License.Dimension.Time);
--
-- Whether to compute bounds on the stack usage.
-- The default is True when space analysis is the only
-- licensed dimension of analysis.
--
Bound_Stack : Boolean renames Bound_Stack_Opt.Value;
procedure Set_Stack_Analysis (To : in Boolean);
--
-- Sets the value of Bound_Stack.
Trace_Subprograms : Boolean renames Programs.Opt.Trace_Subprograms;
--
-- Whether to list (trace) the subprograms to which bounding is
-- being applied.
Trace_Phase_Opt : aliased Options.Bool.Option_T (Default => False);
--
-- Whether to trace the progress through the various phases of
-- analysis: constant propagation, ..., arithmetic analysis.
--
Trace_Phase : Boolean renames Trace_Phase_Opt.Value;
Trace_Arith_Opt : aliased Options.Bool.Option_T (Default => False);
--
-- Whether the trace the starting and stopping of each arithmetic
-- analysis (Calculator execution).
--
Trace_Arith : Boolean renames Trace_Arith_Opt.Value;
Trace_Context_Opt : aliased Options.Bool.Option_T (Default => False);
--
-- Whether to list (trace) the asserted and derived bounds on
-- input parameters, global variables, and local variables, when
-- starting to bound the execution of a subprogram.
--
Trace_Context : Boolean renames Trace_Context_Opt.Value;
Trace_Nubs_Opt : aliased Options.Bool.Option_T (Default => False);
--
-- Whether to list (trace) those steps in each flow-graph that are
-- interesting for the arithmetic analysis, that is, the steps that
-- contain some boundable things that were not bounded by simpler
-- analyses such as constant propagation.
--
Trace_Nubs : Boolean renames Trace_Nubs_Opt.Value;
Trace_Cell_Sets_Opt : aliased Options.Bool.Option_T (Default => False);
--
-- Whether to list (trace) the sets of input cells, output cells,
-- and basis cells for each arithmetic analysis, as soon as they
-- are defined.
--
Trace_Cell_Sets : Boolean renames Trace_Cell_Sets_Opt.Value;
function Trace_Data_Resolution return Boolean;
--
-- Whether to trace the process of resolving dynamic data access.
-- This option tracks the value of Options.General.Trace_Resolution.
Warn_Unresolved_Data_Opt : aliased Options.Bool.Option_T (Default => False);
--
-- Whether to issue a warning message when a dynamic data access
-- is left unresolved (with an unknown source or target cell).
--
Warn_Unresolved_Data : Boolean renames Warn_Unresolved_Data_Opt.Value;
Trace_Graphs_Opt : aliased Options.Bool.Option_T (Default => False);
--
-- Whether to trace the steps and edges and their properties in
-- the finished flow-graphs for all subprograms.
--
Trace_Graphs : Boolean renames Trace_Graphs_Opt.Value;
Trace_Instructions_Opt : aliased Options.Bool.Option_T (Default => False);
--
-- Whether to trace, in each completed flow-graph, the symbolic
-- disassembly and the arithmetic effect and computational effort
-- of each step, and the necessary arithmetic condition and
-- execution time for each edge.
--
-- This option is meant to help test the arithmetic modelling of
-- instructions while being insensitive to the source-level and
-- machine-level locations (source file, line number, code address),
-- as far as possible. The trace line for a step does show the locus
-- of the step, but this can easily be ignored when the trace is
-- compared to a reference file. The trace line for an edge shows
-- the source instruction disassembled and the offset to the
-- target instruction.
--
Trace_Instructions : Boolean renames Trace_Instructions_Opt.Value;
Max_Dependency_Depth_Opt : aliased Options.Nat.Option_T (Default => 3);
--
-- The maximum analysis depth for call-dependent call paths, in
-- terms of the number of calls involved.
-- Call-dependendent bounding will not be attempted for longer
-- call-paths (so they will be unbounded in the result).
--
Max_Dependency_Depth : Natural renames Max_Dependency_Depth_Opt.Value;
Max_Restarts_Opt : aliased Options.Nat.Option_T (Default => 5);
--
-- The maximum number of times the analysis process will be restarted
-- from an earlier phase (see Bound_Execution.Phase_T) because a later
-- phase has changed the model (flow-graph or computation model) in a
-- way that requires repeating the earlier phases.
--
Max_Restarts : Natural renames Max_Restarts_Opt.Value;
end Bounds.Opt;
|
mfkiwl/ewok-kernel-security-OS | Ada | 11,109 | 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 ada.unchecked_conversion;
with m4.layout;
with m4.scb;
package m4.mpu
with spark_mode => on
is
------------
-- Config --
------------
subtype t_region_number is unsigned_8 range 0 .. 7;
subtype t_region_size is bits_5 range 4 .. 31;
subtype t_region_perm is bits_3;
subtype t_subregion_range is unsigned_8 range 1 .. 8;
type t_subregion_status is
(SUB_REGION_ENABLED,
SUB_REGION_DISABLED)
with size => 1;
for t_subregion_status use
(SUB_REGION_ENABLED => 0,
SUB_REGION_DISABLED => 1);
type t_subregion_mask is
array (t_subregion_range) of t_subregion_status
with pack, size => 8;
function to_subregion_mask is new ada.unchecked_conversion
(unsigned_8, t_subregion_mask);
function to_unsigned_8 is new ada.unchecked_conversion
(t_subregion_mask, unsigned_8);
type t_region_config is record
region_number : t_region_number;
addr : system_address;
size : t_region_size;
access_perm : t_region_perm;
xn : boolean; -- Execute Never
b : boolean;
s : boolean;
subregion_mask : t_subregion_mask;
end record;
REGION_SIZE_32B : constant t_region_size := 4;
REGION_SIZE_64B : constant t_region_size := 5;
REGION_SIZE_128B : constant t_region_size := 6;
REGION_SIZE_256B : constant t_region_size := 7;
REGION_SIZE_512B : constant t_region_size := 8;
REGION_SIZE_1KB : constant t_region_size := 9;
REGION_SIZE_2KB : constant t_region_size := 10;
REGION_SIZE_4KB : constant t_region_size := 11;
REGION_SIZE_8KB : constant t_region_size := 12;
REGION_SIZE_16KB : constant t_region_size := 13;
REGION_SIZE_32KB : constant t_region_size := 14;
REGION_SIZE_64KB : constant t_region_size := 15;
REGION_SIZE_128KB : constant t_region_size := 16;
REGION_SIZE_256KB : constant t_region_size := 17;
REGION_SIZE_512KB : constant t_region_size := 18;
REGION_SIZE_1MB : constant t_region_size := 19;
REGION_SIZE_2MB : constant t_region_size := 20;
REGION_SIZE_4MB : constant t_region_size := 21;
REGION_SIZE_8MB : constant t_region_size := 22;
REGION_SIZE_16MB : constant t_region_size := 23;
REGION_SIZE_32MB : constant t_region_size := 24;
REGION_SIZE_64MB : constant t_region_size := 25;
REGION_SIZE_128MB : constant t_region_size := 26;
REGION_SIZE_256MB : constant t_region_size := 27;
REGION_SIZE_512MB : constant t_region_size := 28;
REGION_SIZE_1GB : constant t_region_size := 29;
REGION_SIZE_2GB : constant t_region_size := 30;
REGION_SIZE_4GB : constant t_region_size := 31;
-- Access Permissions
-- Note: Describes privileged and user access.
-- For example, REGION_PERM_PRIV_RW_USER_NO means
-- - privileged : read/write access
-- - user : no access
REGION_PERM_PRIV_NO_USER_NO : constant t_region_perm := 2#000#;
REGION_PERM_PRIV_RW_USER_NO : constant t_region_perm := 2#001#;
REGION_PERM_PRIV_RW_USER_RO : constant t_region_perm := 2#010#;
REGION_PERM_PRIV_RW_USER_RW : constant t_region_perm := 2#011#;
REGION_PERM_UNUSED : constant t_region_perm := 2#100#;
REGION_PERM_PRIV_RO_USER_NO : constant t_region_perm := 2#101#;
REGION_PERM_PRIV_RO_USER_RO : constant t_region_perm := 2#110#;
REGION_PERM_PRIV_RO_USER_RO2 : constant t_region_perm := 2#111#;
---------------
-- Functions --
---------------
procedure is_mpu_available
(success : out boolean)
with
inline_always,
Global => (In_Out => MPU);
procedure enable
with
inline_always,
global => (in_out => (MPU));
procedure disable
with
inline_always,
global => (in_out => (MPU));
procedure disable_region
(region_number : in t_region_number)
with
inline_always,
global => (in_out => (MPU));
-- Return true if configured region is executable and writable
-- by the CPU in privileged or unprivileged mode
function region_rwx(region : t_region_config) return boolean
is (region.xn = false and
(region.access_perm = REGION_PERM_PRIV_RW_USER_NO or
region.access_perm = REGION_PERM_PRIV_RW_USER_RO or
region.access_perm = REGION_PERM_PRIV_RW_USER_RW))
with ghost;
procedure init
with
global => (in_out => (MPU, m4.scb.SCB));
procedure enable_unrestricted_kernel_access
with
inline_always,
global => (in_out => (MPU));
procedure disable_unrestricted_kernel_access
with
inline_always,
global => (in_out => (MPU));
-- That function is only used by SPARK prover
function get_region_size_mask (size : t_region_size) return unsigned_32
is (2**(natural (size) + 1) - 1)
with ghost;
pragma assertion_policy (pre => IGNORE, post => IGNORE, assert => IGNORE);
pragma warnings (off, "explicit membership test may be optimized");
pragma warnings (off, "condition can only be False if invalid values present");
procedure configure_region
(region : in t_region_config)
with
global => (in_out => (MPU)),
pre =>
(region.region_number in 0 .. 7
and
(region.addr and 2#11111#) = 0
and
region.size >= 4
and
(region.addr and get_region_size_mask(region.size)) = 0)
and not region_rwx (region);
procedure update_subregion_mask
(region_number : in t_region_number;
subregion_mask : in t_subregion_mask)
with
inline_always,
global => (in_out => (MPU));
pragma warnings (on);
-----------------------
-- MPU Type Register --
-----------------------
type t_MPU_TYPE is record
SEPARAT : boolean := true; -- Support for separate instruction and date memory maps
DREGION : unsigned_8 := 8; -- Number of supported MPU data regions
IREGION : unsigned_8 := 0; -- Number of supported MPU instruction regions
end record
with size => 32;
for t_MPU_TYPE use
record
SEPARAT at 0 range 0 .. 0;
DREGION at 0 range 8 .. 15;
IREGION at 0 range 16 .. 23;
end record;
function to_unsigned_32 is new ada.unchecked_conversion
(t_MPU_TYPE, unsigned_32);
--------------------------
-- MPU Control Register --
--------------------------
type t_MPU_CTRL is record
ENABLE : boolean; -- Enables the MPU
HFNMIENA : boolean; -- Enables the operation of MPU during hard fault,
-- NMI, and FAULTMASK handlers
PRIVDEFENA : boolean; -- Enables privileged software access to the
-- default memory map
end record
with size => 32;
for t_MPU_CTRL use record
ENABLE at 0 range 0 .. 0;
HFNMIENA at 0 range 1 .. 1;
PRIVDEFENA at 0 range 2 .. 2;
end record;
--------------------------------
-- MPU Region Number Register --
--------------------------------
type t_MPU_RNR is record
REGION : unsigned_8 range 0 .. 7; -- Indicates the region referenced by
-- MPU_RBAR and MPU_RASR
end record
with size => 32;
for t_MPU_RNR use record
REGION at 0 range 0 .. 7;
end record;
--------------------------------------
-- MPU Region Base Address Register --
--------------------------------------
--
-- Defines the base address of the MPU region selected by the MPU_RNR
--
type t_MPU_RBAR is record
REGION : bits_4 range 0 .. 7;
VALID : boolean;
ADDR : bits_27;
end record
with size => 32;
for t_MPU_RBAR use record
REGION at 0 range 0 .. 3;
VALID at 0 range 4 .. 4;
ADDR at 0 range 5 .. 31;
end record;
function address_to_bits_27 (addr : system_address)
return bits_27
with pre => (addr and 2#11111#) = 0;
--------------------------------------------
-- MPU Region Attribute and Size Register --
--------------------------------------------
type t_MPU_RASR is record
ENABLE : boolean; -- Enable region
SIZE : t_region_size;
SRD : unsigned_8; -- Subregion disable bits (0 = enabled, 1 = disabled)
B : boolean;
C : boolean;
S : boolean; -- Shareable
TEX : bits_3; -- Memory attributes
AP : t_region_perm; -- Permissions
XN : boolean; -- Instruction fetches disabled
end record
with size => 32;
for t_MPU_RASR use record
ENABLE at 0 range 0 .. 0;
SIZE at 0 range 1 .. 5;
SRD at 0 range 8 .. 15;
B at 0 range 16 .. 16;
C at 0 range 17 .. 17;
S at 0 range 18 .. 18;
TEX at 0 range 19 .. 21;
AP at 0 range 24 .. 26;
XN at 0 range 28 .. 28;
end record;
function to_MPU_RASR is new ada.unchecked_conversion
(unsigned_32, t_MPU_RASR);
--------------------
-- MPU peripheral --
--------------------
type t_MPU_peripheral is record
TYPER : t_MPU_TYPE;
CTRL : t_MPU_CTRL;
RNR : t_MPU_RNR;
RBAR : t_MPU_RBAR;
RASR : t_MPU_RASR;
RBAR_A1 : t_MPU_RBAR;
RASR_A1 : t_MPU_RASR;
RBAR_A2 : t_MPU_RBAR;
RASR_A2 : t_MPU_RASR;
RBAR_A3 : t_MPU_RBAR;
RASR_A3 : t_MPU_RASR;
end record;
for t_MPU_peripheral use record
TYPER at 16#00# range 0 .. 31;
CTRL at 16#04# range 0 .. 31;
RNR at 16#08# range 0 .. 31;
RBAR at 16#0C# range 0 .. 31;
RASR at 16#10# range 0 .. 31;
RBAR_A1 at 16#14# range 0 .. 31;
RASR_A1 at 16#18# range 0 .. 31;
RBAR_A2 at 16#1C# range 0 .. 31;
RASR_A2 at 16#20# range 0 .. 31;
RBAR_A3 at 16#24# range 0 .. 31;
RASR_A3 at 16#28# range 0 .. 31;
end record;
----------------
-- Peripheral --
----------------
MPU : t_MPU_peripheral
with
import,
volatile,
address => m4.layout.MPU_base;
end m4.mpu;
|
Fabien-Chouteau/GESTE | Ada | 148 | ads | package Levels is
type Level_Id is (Lvl_1, Lvl_2, Lvl_3);
procedure Enter (Id : Level_Id);
procedure Leave (Id : Level_Id);
end Levels;
|
reznikmm/matreshka | Ada | 4,930 | ads | ------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- Ada Modeling Framework --
-- --
-- Runtime Library Component --
-- --
------------------------------------------------------------------------------
-- --
-- Copyright © 2011-2012, Vadim Godunko <[email protected]> --
-- All rights reserved. --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions --
-- are met: --
-- --
-- * Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- --
-- * Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in the --
-- documentation and/or other materials provided with the distribution. --
-- --
-- * Neither the name of the Vadim Godunko, IE nor the names of its --
-- contributors may be used to endorse or promote products derived from --
-- this software without specific prior written permission. --
-- --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR --
-- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
-- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED --
-- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR --
-- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF --
-- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING --
-- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS --
-- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
-- --
------------------------------------------------------------------------------
-- $Revision$ $Date$
------------------------------------------------------------------------------
with AMF.Internals.UML_Elements;
with AMF.Standard_Profile_L2.Services;
with AMF.UML.Components;
with AMF.Visitors;
package AMF.Internals.Standard_Profile_L2_Services is
type Standard_Profile_L2_Service_Proxy is
limited new AMF.Internals.UML_Elements.UML_Element_Base
and AMF.Standard_Profile_L2.Services.Standard_Profile_L2_Service with null record;
overriding function Get_Base_Component
(Self : not null access constant Standard_Profile_L2_Service_Proxy)
return AMF.UML.Components.UML_Component_Access;
-- Getter of Service::base_Component.
--
overriding procedure Set_Base_Component
(Self : not null access Standard_Profile_L2_Service_Proxy;
To : AMF.UML.Components.UML_Component_Access);
-- Setter of Service::base_Component.
--
overriding procedure Enter_Element
(Self : not null access constant Standard_Profile_L2_Service_Proxy;
Visitor : in out AMF.Visitors.Abstract_Visitor'Class;
Control : in out AMF.Visitors.Traverse_Control);
overriding procedure Leave_Element
(Self : not null access constant Standard_Profile_L2_Service_Proxy;
Visitor : in out AMF.Visitors.Abstract_Visitor'Class;
Control : in out AMF.Visitors.Traverse_Control);
overriding procedure Visit_Element
(Self : not null access constant Standard_Profile_L2_Service_Proxy;
Iterator : in out AMF.Visitors.Abstract_Iterator'Class;
Visitor : in out AMF.Visitors.Abstract_Visitor'Class;
Control : in out AMF.Visitors.Traverse_Control);
end AMF.Internals.Standard_Profile_L2_Services;
|
sebsgit/textproc | Ada | 80 | adb | with MainTestSuite;
procedure Main is
begin
MainTestSuite.runAll;
end Main;
|
reznikmm/matreshka | Ada | 3,679 | 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_Author_Name_Elements is
pragma Preelaborate;
type ODF_Text_Author_Name is limited interface
and XML.DOM.Elements.DOM_Element;
type ODF_Text_Author_Name_Access is
access all ODF_Text_Author_Name'Class
with Storage_Size => 0;
end ODF.DOM.Text_Author_Name_Elements;
|
yannickmoy/spat | Ada | 2,560 | ads | ------------------------------------------------------------------------------
-- Copyright (C) 2020 by Heisenbug Ltd. ([email protected])
--
-- This work is free. You can redistribute it and/or modify it under the
-- terms of the Do What The Fuck You Want To Public License, Version 2,
-- as published by Sam Hocevar. See the LICENSE file for more details.
------------------------------------------------------------------------------
pragma License (Unrestricted);
------------------------------------------------------------------------------
--
-- SPARK Proof Analysis Tool
--
-- S.P.A.T. - Object representing a JSON "flow" object.
--
------------------------------------------------------------------------------
with SPAT.Entity.Tree;
with SPAT.Entity_Location;
with SPAT.Preconditions;
package SPAT.Flow_Item is
---------------------------------------------------------------------------
-- Has_Required_Fields
---------------------------------------------------------------------------
function Has_Required_Fields (Object : in JSON_Value) return Boolean is
(Entity_Location.Has_Required_Fields (Object => Object) and
Preconditions.Ensure_Rule_Severity (Object => Object));
type T is new Entity_Location.T with private;
---------------------------------------------------------------------------
-- Create
---------------------------------------------------------------------------
overriding
function Create (Object : in JSON_Value) return T with
Pre => Has_Required_Fields (Object => Object);
---------------------------------------------------------------------------
-- Before
--
-- Comparison operator used for sorting instantiations.
---------------------------------------------------------------------------
function Before (Left : in Entity.T'Class;
Right : in Entity.T'Class) return Boolean is
(Flow_Item.T (Left) < Flow_Item.T (Right));
package By_Location is new Entity.Tree.Generic_Sorting (Before => Before);
---------------------------------------------------------------------------
-- Sort_By_Location
---------------------------------------------------------------------------
procedure Sort_By_Location (This : in out Entity.Tree.T;
Parent : in Entity.Tree.Cursor) renames
By_Location.Sort;
private
type T is new Entity_Location.T with
record
Rule : Subject_Name;
Severity : Subject_Name;
end record;
end SPAT.Flow_Item;
|
AaronC98/PlaneSystem | Ada | 14,508 | adb | ------------------------------------------------------------------------------
-- Generic memory stream --
-- --
-- Copyright (C) 2003-2015, Dmitriy Anisimkov --
-- --
-- This library is free software; you can redistribute it and/or modify --
-- it under the terms of the GNU General Public License as published by --
-- the Free Software Foundation; either version 2 of the License, or (at --
-- your option) any later version. --
-- --
-- This library is distributed in the hope that it will be useful, but --
-- WITHOUT ANY WARRANTY; without even the implied warranty of --
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU --
-- General Public License for more details. --
-- --
-- You should have received a copy of the GNU General Public License --
-- along with this library; if not, write to the Free Software Foundation, --
-- Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. --
-- --
-- --
-- --
-- --
-- --
-- --
-- --
------------------------------------------------------------------------------
pragma Ada_2012;
with Ada.Unchecked_Deallocation;
package body Memory_Streams is
procedure Free (Item : in out Buffer_Access);
procedure Free is
new Ada.Unchecked_Deallocation (Element_Array, Element_Access);
procedure Trim_Last_Block (Stream : in out Stream_Type);
-- Remove unused space from last buffer
function First (Item : in Buffer_Access) return Element_Index with Inline;
function Last (Item : in Buffer_Access) return Element_Index with Inline;
------------
-- Append --
------------
procedure Append
(Stream : in out Stream_Type;
Value : in Element_Array;
Trim : in Boolean := False) is
begin
if Value'Length = 0 then
if Trim then
Trim_Last_Block (Stream);
end if;
return;
end if;
if Stream.First = null then
Stream.First := new Buffer_Type (False);
if Value'Length >= First_Block_Length or else Trim then
Stream.First.Data := new Element_Array (1 .. Value'Length);
else
Stream.First.Data := new Element_Array (1 .. First_Block_Length);
end if;
Stream.First.Data (1 .. Value'Length) := Value;
Stream.Current := Stream.First;
Stream.Last := Stream.First;
Stream.Last_Length := Value'Length;
elsif Stream.Last.Steady
or else Stream.Last_Length = Stream.Last.Data'Length
then
Stream.Last.Next := new Buffer_Type (False);
Stream.Last := Stream.Last.Next;
if Value'Length >= Next_Block_Length or else Trim then
Stream.Last.Data := new Element_Array (1 .. Value'Length);
else
Stream.Last.Data := new Element_Array (1 .. Next_Block_Length);
end if;
Stream.Last.Data (1 .. Value'Length) := Value;
Stream.Last_Length := Value'Length;
else
declare
Block_Length : constant Element_Offset :=
Stream.Last_Length + Value'Length;
begin
if Block_Length <= Stream.Last.Data'Length then
Stream.Last.Data
(Stream.Last_Length + 1 .. Block_Length) := Value;
Stream.Last_Length := Block_Length;
if Trim then
Trim_Last_Block (Stream);
end if;
else
declare
Split_Value : constant Element_Index :=
Value'First
+ Stream.Last.Data'Length
- Stream.Last_Length;
Next_Length : constant Element_Index :=
Value'Last - Split_Value + 1;
begin
Stream.Last.Data
(Stream.Last_Length + 1 .. Stream.Last.Data'Last) :=
Value (Value'First .. Split_Value - 1);
Stream.Last.Next := new Buffer_Type (False);
Stream.Last := Stream.Last.Next;
if Next_Length >= Next_Block_Length or else Trim then
Stream.Last.Data := new Element_Array (1 .. Next_Length);
else
Stream.Last.Data :=
new Element_Array (1 .. Next_Block_Length);
end if;
Stream.Last.Data (1 .. Next_Length) :=
Value (Split_Value .. Value'Last);
Stream.Last_Length := Next_Length;
end;
end if;
end;
end if;
Stream.Length := Stream.Length + Value'Length;
end Append;
------------
-- Append --
------------
procedure Append
(Stream : in out Stream_Type;
Data : in Constant_Access) is
begin
if Data'Length = 0 then
return;
end if;
if Stream.First = null then
Stream.First := new Buffer_Type (True);
Stream.First.Const := Data;
Stream.Current := Stream.First;
Stream.Last := Stream.First;
Stream.Last_Length := Data'Length;
Stream.Current_Offset := Data'First;
else
Trim_Last_Block (Stream);
Stream.Last.Next := new Buffer_Type (True);
Stream.Last := Stream.Last.Next;
Stream.Last.Const := Data;
Stream.Last_Length := Data'Length;
end if;
Stream.Length := Stream.Length + Data'Length;
end Append;
procedure Append
(Stream : in out Stream_Type;
Data : in Element_Access) is
begin
if Data'Length = 0 then
return;
end if;
if Stream.First = null then
Stream.First := new Buffer_Type (False);
Stream.First.Data := Data;
Stream.Current := Stream.First;
Stream.Last := Stream.First;
Stream.Last_Length := Data'Length;
Stream.Current_Offset := Data'First;
else
Trim_Last_Block (Stream);
Stream.Last.Next := new Buffer_Type (False);
Stream.Last := Stream.Last.Next;
Stream.Last.Data := Data;
Stream.Last_Length := Data'Length;
end if;
Stream.Length := Stream.Length + Data'Length;
end Append;
-----------
-- Close --
-----------
procedure Close (Stream : in out Stream_Type) is
First : Buffer_Access;
Length : Element_Offset := 0;
begin
while Stream.First /= null loop
First := Stream.First;
if First.Next = null then
Length := Length + Stream.Last_Length;
else
if First.Steady then
Length := Length + First.Const'Length;
else
Length := Length + First.Data'Length;
end if;
end if;
Stream.First := First.Next;
Free (First);
end loop;
Stream.Current := null;
Stream.Last := null;
Reset (Stream);
if Stream.Length /= Length then
raise Program_Error;
end if;
Stream.Length := 0;
end Close;
-----------------
-- End_Of_File --
-----------------
function End_Of_File (Stream : in Stream_Type) return Boolean is
begin
return Stream.Current = null
or else (Stream.Current.Next = null
and then Stream.Current_Offset > Last (Stream.Current));
end End_Of_File;
-----------
-- First --
-----------
function First (Item : in Buffer_Access) return Element_Index is
begin
if Item.Steady then
return Item.Const'First;
else
return Item.Data'First;
end if;
end First;
----------
-- Free --
----------
procedure Free (Item : in out Buffer_Access) is
procedure Deallocate is
new Ada.Unchecked_Deallocation (Buffer_Type, Buffer_Access);
begin
if not Item.Steady then
Free (Item.Data);
end if;
Deallocate (Item);
end Free;
----------
-- Last --
----------
function Last (Item : in Buffer_Access) return Element_Index is
begin
if Item.Steady then
return Item.Const'Last;
else
return Item.Data'Last;
end if;
end Last;
-------------
-- Pending --
-------------
function Pending (Stream : in Stream_Type) return Element_Offset is
begin
if Stream.Current = null then
return 0;
else
declare
B : Buffer_Access := Stream.Current;
S : Element_Offset := 0;
begin
while B /= null loop
if B.Next = null then
if B.Steady then
S := S + Last (B);
else
S := S + Stream.Last_Length - Stream.Current_Offset + 1;
end if;
else
S := S + Last (B);
end if;
B := B.Next;
end loop;
return S;
end;
end if;
end Pending;
----------
-- Read --
----------
procedure Read
(Stream : in out Stream_Type;
Buffer : out Element_Array;
Last : out Element_Offset)
is
Buffer_Offset : Element_Offset := Buffer'First;
Block_Over : Boolean;
procedure Append (Data : in Element_Array);
-- Add the Data to the Buffer till necessary from the
-- Resource.Current_Offset and move it.
------------
-- Append --
------------
procedure Append (Data : in Element_Array) is
Buffer_Len_1 : constant Element_Offset :=
Buffer'Last - Buffer_Offset;
-- Buffer remain length minus 1
Current_Len_1 : constant Element_Offset :=
Data'Last - Stream.Current_Offset;
-- Data remain length minus 1
Current_Last : Element_Index;
begin
Block_Over := Buffer_Len_1 >= Current_Len_1;
if Block_Over then
Last := Buffer_Offset + Current_Len_1;
Buffer (Buffer_Offset .. Last) :=
Data (Stream.Current_Offset .. Data'Last);
Buffer_Offset := Last + 1;
Stream.Current_Offset := Data'Last + 1;
else
Last := Buffer'Last;
Current_Last := Stream.Current_Offset + Buffer_Len_1;
Buffer (Buffer_Offset .. Last) :=
Data (Stream.Current_Offset .. Current_Last);
Stream.Current_Offset := Current_Last + 1;
end if;
end Append;
begin
Last := Buffer'First - 1;
if Stream.Current = null then
return;
end if;
loop
if Stream.Current.Next = null then
-- Last block
if Stream.Current.Steady then
Append (Stream.Current.Const.all);
else
Append (Stream.Current.Data
(Stream.Current.Data'First
.. Stream.Last_Length + Stream.Current.Data'First
- 1));
end if;
if Block_Over then
Stream.Current := null;
exit;
end if;
else
if Stream.Current.Steady then
Append (Stream.Current.Const.all);
else
Append (Stream.Current.Data.all);
end if;
if Block_Over then
Stream.Current := Stream.Current.Next;
Stream.Current_Offset := First (Stream.Current);
end if;
end if;
exit when Last = Buffer'Last;
end loop;
end Read;
-----------
-- Reset --
-----------
procedure Reset (Stream : in out Stream_Type) is
begin
Stream.Current := Stream.First;
Stream.Current_Offset := 1;
end Reset;
---------------
-- Set_Index --
---------------
procedure Set_Index
(Stream : in out Stream_Type;
To : in Element_Offset)
is
Idx : Element_Offset := Last (Stream.First);
begin
if To < 1 or else To > Size (Stream) then
Stream.Current := Stream.Last;
Stream.Current_Offset := Last (Stream.Current) + 1;
else
Stream.Current := Stream.First;
while Idx < To loop
Stream.Current := Stream.Current.Next;
Idx := Idx + Last (Stream.Current);
end loop;
Stream.Current_Offset := Last (Stream.Current) - Idx + To;
end if;
end Set_Index;
----------
-- Size --
----------
function Size (Stream : in Stream_Type) return Element_Offset is
begin
return Stream.Length;
end Size;
----------------------
-- Trim_Last_Buffer --
----------------------
procedure Trim_Last_Block (Stream : in out Stream_Type) is
begin
if Stream.Last = null
or else Stream.Last.Steady
or else Stream.Last.Data'Length = Stream.Last_Length
then
return;
end if;
declare
Ptr : constant Element_Access :=
new Element_Array'
(Stream.Last.Data (1 .. Stream.Last_Length));
begin
Free (Stream.Last.Data);
Stream.Last.Data := Ptr;
Stream.Last_Length := Ptr'Length;
end;
end Trim_Last_Block;
end Memory_Streams;
|
AdaCore/gpr | Ada | 955 | adb | with p3_0; use p3_0;
package body p3_3 is
function p3_3_0 (Item : Integer) return Integer is
Result : Long_Long_Integer;
begin
if Item < 0 then
return -Item;
end if;
Result := Long_Long_Integer (p3_0_0 (Item - 1)) + 330;
return Integer (Result rem Long_Long_Integer (Integer'Last));
end p3_3_0;
function p3_3_1 (Item : Integer) return Integer is
Result : Long_Long_Integer;
begin
if Item < 0 then
return -Item;
end if;
Result := Long_Long_Integer (p3_0_1 (Item - 1)) + 331;
return Integer (Result rem Long_Long_Integer (Integer'Last));
end p3_3_1;
function p3_3_2 (Item : Integer) return Integer is
Result : Long_Long_Integer;
begin
if Item < 0 then
return -Item;
end if;
Result := Long_Long_Integer (p3_0_2 (Item - 1)) + 332;
return Integer (Result rem Long_Long_Integer (Integer'Last));
end p3_3_2;
end p3_3;
|
reznikmm/matreshka | Ada | 3,636 | ads | ------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- Ada Modeling Framework --
-- --
-- Runtime Library Component --
-- --
------------------------------------------------------------------------------
-- --
-- Copyright © 2011-2012, Vadim Godunko <[email protected]> --
-- All rights reserved. --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions --
-- are met: --
-- --
-- * Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- --
-- * Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in the --
-- documentation and/or other materials provided with the distribution. --
-- --
-- * Neither the name of the Vadim Godunko, IE nor the names of its --
-- contributors may be used to endorse or promote products derived from --
-- this software without specific prior written permission. --
-- --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR --
-- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
-- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED --
-- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR --
-- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF --
-- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING --
-- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS --
-- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
-- --
------------------------------------------------------------------------------
-- $Revision$ $Date$
------------------------------------------------------------------------------
-- This file is generated, don't edit it.
------------------------------------------------------------------------------
with AMF.Elements.Generic_Hash;
function AMF.UML.Duration_Observations.Hash is
new AMF.Elements.Generic_Hash (UML_Duration_Observation, UML_Duration_Observation_Access);
|
reznikmm/matreshka | Ada | 4,576 | 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.Width_Attributes is
------------
-- Create --
------------
overriding function Create
(Parameters : not null access Matreshka.DOM_Attributes.Attribute_L2_Parameters)
return Style_Width_Attribute_Node is
begin
return Self : Style_Width_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_Width_Attribute_Node)
return League.Strings.Universal_String
is
pragma Unreferenced (Self);
begin
return Matreshka.ODF_String_Constants.Width_Attribute;
end Get_Local_Name;
begin
Matreshka.DOM_Documents.Register_Attribute
(Matreshka.ODF_String_Constants.Style_URI,
Matreshka.ODF_String_Constants.Width_Attribute,
Style_Width_Attribute_Node'Tag);
end Matreshka.ODF_Style.Width_Attributes;
|
AdaCore/ada-traits-containers | Ada | 4,309 | adb | --
-- Copyright (C) 2016-2016, AdaCore
--
-- SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
--
-- A graph data structure implemented as an adjacency list.
-- It stores a sequence of out-edges for each vertex.
-- This package lets users decide whether to use lists, vectors, or other
-- types of sequences for vertices and their edges.
pragma Ada_2012;
package body Conts.Graphs.Adjacency_List is
----------
-- Impl --
----------
package body Impl is
-----------
-- Clear --
-----------
procedure Clear (Self : in out Graph) is
begin
Self.Vertices.Clear;
end Clear;
------------------
-- Add_Vertices --
------------------
procedure Add_Vertices
(Self : in out Graph;
Props : Vertex_Properties.Element_Type;
Count : Count_Type := 1) is
begin
Self.Vertices.Append
(Element =>
(Props => Vertex_Properties.To_Stored (Props),
Out_Edges => <>),
Count => Count);
end Add_Vertices;
--------------
-- Add_Edge --
--------------
procedure Add_Edge
(Self : in out Graph;
From, To : Vertex;
Props : Edge_Properties.Element_Type) is
begin
Self.Vertices.Reference (From).Out_Edges.Append
(Edge'
(From => From,
To => To,
Props => Edge_Properties.To_Stored (Props)));
end Add_Edge;
------------
-- Length --
------------
function Length (Self : Graph) return Count_Type is
begin
return Self.Vertices.Length;
end Length;
----------------
-- Get_Target --
----------------
function Get_Target (G : Graph; E : Edge) return Vertex is
pragma Unreferenced (G);
begin
return E.To;
end Get_Target;
-----------
-- First --
-----------
function First (G : Graph) return Vertex_Cursor is
begin
return (Current => G.Vertices.First);
end First;
-------------
-- Element --
-------------
function Element (G : Graph; C : Vertex_Cursor) return Vertex is
pragma Unreferenced (G);
begin
return C.Current;
end Element;
-----------------
-- Has_Element --
-----------------
function Has_Element (G : Graph; C : Vertex_Cursor) return Boolean is
begin
return G.Vertices.Has_Element (C.Current);
end Has_Element;
----------
-- Next --
----------
function Next (G : Graph; C : Vertex_Cursor) return Vertex_Cursor is
begin
return (Current => G.Vertices.Next (C.Current));
end Next;
---------------
-- Out_Edges --
---------------
function Out_Edges (G : Graph; V : Vertex) return Edges_Cursor is
begin
return (Current => G.Vertices.Element (V).Out_Edges.First,
From => V);
end Out_Edges;
-------------
-- Element --
-------------
function Element (G : Graph; C : Edges_Cursor) return Edge is
begin
return G.Vertices.Element (C.From).Out_Edges.Element (C.Current);
end Element;
-----------------
-- Has_Element --
-----------------
function Has_Element (G : Graph; C : Edges_Cursor) return Boolean is
begin
return G.Vertices.Element (C.From).Out_Edges.Has_Element (C.Current);
end Has_Element;
----------
-- Next --
----------
function Next (G : Graph; C : Edges_Cursor) return Edges_Cursor is
begin
return (Current =>
G.Vertices.Element (C.From).Out_Edges.Next (C.Current),
From => C.From);
end Next;
-------------
-- Release --
-------------
procedure Release (E : in out Edge) is
begin
Edge_Properties.Release (E.Props);
end Release;
-------------
-- Release --
-------------
procedure Release (V : in out Vertex_Record) is
begin
Vertex_Properties.Release (V.Props);
V.Out_Edges.Clear;
end Release;
end Impl;
end Conts.Graphs.Adjacency_List;
|
reznikmm/matreshka | Ada | 4,021 | ads | ------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- Open Document Toolkit --
-- --
-- Runtime Library Component --
-- --
------------------------------------------------------------------------------
-- --
-- Copyright © 2014, Vadim Godunko <[email protected]> --
-- All rights reserved. --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions --
-- are met: --
-- --
-- * Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- --
-- * Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in the --
-- documentation and/or other materials provided with the distribution. --
-- --
-- * Neither the name of the Vadim Godunko, IE nor the names of its --
-- contributors may be used to endorse or promote products derived from --
-- this software without specific prior written permission. --
-- --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR --
-- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
-- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED --
-- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR --
-- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF --
-- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING --
-- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS --
-- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
-- --
------------------------------------------------------------------------------
-- $Revision$ $Date$
------------------------------------------------------------------------------
with ODF.DOM.Office_Value_Type_Attributes;
package Matreshka.ODF_Office.Value_Type_Attributes is
type Office_Value_Type_Attribute_Node is
new Matreshka.ODF_Office.Abstract_Office_Attribute_Node
and ODF.DOM.Office_Value_Type_Attributes.ODF_Office_Value_Type_Attribute
with null record;
overriding function Create
(Parameters : not null access Matreshka.DOM_Attributes.Attribute_L2_Parameters)
return Office_Value_Type_Attribute_Node;
overriding function Get_Local_Name
(Self : not null access constant Office_Value_Type_Attribute_Node)
return League.Strings.Universal_String;
end Matreshka.ODF_Office.Value_Type_Attributes;
|
onox/orka | Ada | 11,239 | ads | -- SPDX-License-Identifier: Apache-2.0
--
-- Copyright (c) 2013 Felix Krause <[email protected]>
--
-- Licensed under the Apache License, Version 2.0 (the "License");
-- you may not use this file except in compliance with the License.
-- You may obtain a copy of the License at
--
-- http://www.apache.org/licenses/LICENSE-2.0
--
-- Unless required by applicable law or agreed to in writing, software
-- distributed under the License is distributed on an "AS IS" BASIS,
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-- See the License for the specific language governing permissions and
-- limitations under the License.
with GL.Buffers;
with GL.Low_Level.Enums;
with GL.Objects.Textures;
with GL.Pixels.Extensions;
with GL.Types.Colors;
private with GL.Enums;
package GL.Objects.Framebuffers is
pragma Preelaborate;
use all type GL.Low_Level.Enums.Texture_Kind;
type Interpolation_Function is
(Nearest, Linear, Scaled_Resolve_Fastest, Scaled_Resolve_Nicest);
type Framebuffer_Status is (Undefined, Complete, Incomplete_Attachment,
Incomplete_Missing_Attachment,
Incomplete_Draw_Buffer, Incomplete_Read_Buffer,
Unsupported, Incomplete_Multisample,
Incomplete_Layer_Targets);
type Attachment_Point is (Depth_Stencil_Attachment,
Color_Attachment_0, Color_Attachment_1,
Color_Attachment_2, Color_Attachment_3,
Color_Attachment_4, Color_Attachment_5,
Color_Attachment_6, Color_Attachment_7,
Color_Attachment_8, Color_Attachment_9,
Color_Attachment_10, Color_Attachment_11,
Color_Attachment_12, Color_Attachment_13,
Color_Attachment_14, Color_Attachment_15,
Depth_Attachment, Stencil_Attachment);
type Default_Attachment_Point is
(Front_Left, Front_Right, Back_Left, Back_Right, Depth, Stencil);
type Attachment_List is array (Positive range <>) of Attachment_Point;
type Default_Attachment_List is array (Positive range <>) of Default_Attachment_Point;
function Valid_Attachment
(Attachment : Attachment_Point;
Texture : Textures.Texture) return Boolean
with Pre => not Texture.Compressed and Texture.Allocated;
type Framebuffer is new GL_Object with private;
overriding
procedure Initialize_Id (Object : in out Framebuffer);
overriding
procedure Delete_Id (Object : in out Framebuffer);
overriding
function Identifier (Object : Framebuffer) return Types.Debug.Identifier is
(Types.Debug.Framebuffer);
procedure Set_Draw_Buffer
(Object : Framebuffer;
Selector : Buffers.Color_Buffer_Selector)
with Pre => (if Object = Default_Framebuffer then
Selector in Buffers.Default_Color_Buffer_Selector | Buffers.None
else
Selector in Buffers.Explicit_Color_Buffer_Selector | Buffers.None);
procedure Set_Draw_Buffers
(Object : Framebuffer;
List : Buffers.Color_Buffer_List)
with Pre => (if Object = Default_Framebuffer then
(for all S of List =>
S in Buffers.Default_Color_Buffer_Selector | Buffers.None)
else
(for all S of List =>
S in Buffers.Explicit_Color_Buffer_Selector | Buffers.None));
procedure Set_Read_Buffer (Object : Framebuffer; Selector : Buffers.Color_Buffer_Selector)
with Pre => (if Object = Default_Framebuffer then
Selector in Buffers.Default_Color_Buffer_Selector | Buffers.None
else
Selector in Buffers.Explicit_Color_Buffer_Selector | Buffers.None);
procedure Attach_Texture
(Object : Framebuffer;
Attachment : Attachment_Point;
Texture : Textures.Texture;
Level : Textures.Mipmap_Level)
with Pre => Object /= Default_Framebuffer and
Valid_Attachment (Attachment, Texture) and
(if Texture.Kind in
Texture_2D_Multisample | Texture_2D_Multisample_Array
then Level = 0);
procedure Attach_Texture_Layer
(Object : Framebuffer;
Attachment : Attachment_Point;
Texture : Textures.Texture;
Level : Textures.Mipmap_Level;
Layer : Natural)
with Pre => Object /= Default_Framebuffer and
Valid_Attachment (Attachment, Texture) and
Texture.Layered;
procedure Detach (Object : Framebuffer; Attachment : Attachment_Point)
with Pre => Object /= Default_Framebuffer;
procedure Invalidate_Data
(Object : Framebuffer;
Attachments : Attachment_List)
with Pre => Object /= Default_Framebuffer;
procedure Invalidate_Sub_Data
(Object : Framebuffer;
Attachments : Attachment_List;
X, Y : Int;
Width, Height : Size)
with Pre => Object /= Default_Framebuffer;
procedure Invalidate_Data
(Object : Framebuffer;
Attachments : Default_Attachment_List)
with Pre => Object = Default_Framebuffer;
procedure Invalidate_Sub_Data
(Object : Framebuffer;
Attachments : Default_Attachment_List;
X, Y : Int;
Width, Height : Size)
with Pre => Object = Default_Framebuffer;
----------------------------------------------------------------------------
procedure Set_Default_Width (Object : Framebuffer; Value : Size)
with Pre => Object /= Default_Framebuffer;
procedure Set_Default_Height (Object : Framebuffer; Value : Size)
with Pre => Object /= Default_Framebuffer;
procedure Set_Default_Layers (Object : Framebuffer; Value : Size)
with Pre => Object /= Default_Framebuffer;
procedure Set_Default_Samples (Object : Framebuffer; Value : Size)
with Pre => Object /= Default_Framebuffer;
procedure Set_Default_Fixed_Sample_Locations (Object : Framebuffer; Value : Boolean)
with Pre => Object /= Default_Framebuffer;
----------------------------------------------------------------------------
function Max_Framebuffer_Width return Size
with Post => Max_Framebuffer_Width'Result >= 16_384;
function Max_Framebuffer_Height return Size
with Post => Max_Framebuffer_Height'Result >= 16_384;
function Max_Framebuffer_Layers return Size
with Post => Max_Framebuffer_Layers'Result >= 2_048;
function Max_Framebuffer_Samples return Size
with Post => Max_Framebuffer_Samples'Result >= 4;
procedure Blit (Read_Object, Draw_Object : Framebuffer;
Src_X0, Src_Y0, Src_X1, Src_Y1,
Dst_X0, Dst_Y0, Dst_X1, Dst_Y1 : Int;
Mask : Buffers.Buffer_Bits;
Filter : Interpolation_Function);
-- Copy a rectangle of pixels in Read_Object framebuffer to a region
-- in Draw_Object framebuffer
procedure Clear_Color_Buffer
(Object : Framebuffer;
Index : Buffers.Draw_Buffer_Index;
Format_Type : Pixels.Extensions.Format_Type;
Value : Colors.Color);
procedure Clear_Depth_Buffer (Object : Framebuffer; Value : Buffers.Depth);
procedure Clear_Stencil_Buffer (Object : Framebuffer; Value : Buffers.Stencil_Index);
procedure Clear_Depth_And_Stencil_Buffer (Object : Framebuffer;
Depth_Value : Buffers.Depth;
Stencil_Value : Buffers.Stencil_Index);
type Framebuffer_Target (<>) is tagged limited private;
procedure Bind (Target : Framebuffer_Target;
Object : Framebuffer'Class);
function Status
(Object : Framebuffer;
Target : Framebuffer_Target'Class) return Framebuffer_Status;
Read_Target : constant Framebuffer_Target;
Draw_Target : constant Framebuffer_Target;
function Default_Framebuffer return Framebuffer;
private
for Interpolation_Function use
(Nearest => 16#2600#,
Linear => 16#2601#,
Scaled_Resolve_Fastest => 16#90BA#,
Scaled_Resolve_Nicest => 16#90BB#);
for Interpolation_Function'Size use Low_Level.Enum'Size;
for Framebuffer_Status use (Undefined => 16#8219#,
Complete => 16#8CD5#,
Incomplete_Attachment => 16#8CD6#,
Incomplete_Missing_Attachment => 16#8CD7#,
Incomplete_Draw_Buffer => 16#8CDB#,
Incomplete_Read_Buffer => 16#8CDC#,
Unsupported => 16#8CDD#,
Incomplete_Multisample => 16#8D56#,
Incomplete_Layer_Targets => 16#8DA8#);
for Framebuffer_Status'Size use Low_Level.Enum'Size;
for Attachment_Point use (Depth_Stencil_Attachment => 16#821A#,
Color_Attachment_0 => 16#8CE0#,
Color_Attachment_1 => 16#8CE1#,
Color_Attachment_2 => 16#8CE2#,
Color_Attachment_3 => 16#8CE3#,
Color_Attachment_4 => 16#8CE4#,
Color_Attachment_5 => 16#8CE5#,
Color_Attachment_6 => 16#8CE6#,
Color_Attachment_7 => 16#8CE7#,
Color_Attachment_8 => 16#8CE8#,
Color_Attachment_9 => 16#8CE9#,
Color_Attachment_10 => 16#8CEA#,
Color_Attachment_11 => 16#8CEB#,
Color_Attachment_12 => 16#8CEC#,
Color_Attachment_13 => 16#8CED#,
Color_Attachment_14 => 16#8CEE#,
Color_Attachment_15 => 16#8CEF#,
Depth_Attachment => 16#8D00#,
Stencil_Attachment => 16#8D20#);
for Attachment_Point'Size use Low_Level.Enum'Size;
for Default_Attachment_Point use
(Front_Left => 16#0400#,
Front_Right => 16#0401#,
Back_Left => 16#0402#,
Back_Right => 16#0403#,
Depth => 16#1801#,
Stencil => 16#1802#);
for Default_Attachment_Point'Size use Low_Level.Enum'Size;
pragma Convention (C, Attachment_List);
pragma Convention (C, Default_Attachment_List);
type Framebuffer is new GL_Object with null record;
type Framebuffer_Target (Kind : Enums.Framebuffer_Kind) is
tagged limited null record;
Read_Target : constant Framebuffer_Target :=
Framebuffer_Target'(Kind => Enums.Read);
Draw_Target : constant Framebuffer_Target :=
Framebuffer_Target'(Kind => Enums.Draw);
end GL.Objects.Framebuffers;
|
zrmyers/VulkanAda | Ada | 8,573 | ads | --------------------------------------------------------------------------------
-- MIT License
--
-- Copyright (c) 2021 Zane Myers
--
-- Permission is hereby granted, free of charge, to any person obtaining a copy
-- of this software and associated documentation files (the "Software"), to deal
-- in the Software without restriction, including without limitation the rights
-- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-- copies of the Software, and to permit persons to whom the Software is
-- furnished to do so, subject to the following conditions:
--
-- The above copyright notice and this permission notice shall be included in all
-- copies or substantial portions of the Software.
--
-- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
-- SOFTWARE.
--------------------------------------------------------------------------------
with Ada.Containers.Vectors;
with System;
--------------------------------------------------------------------------------
--< @group Vulkan Core
--------------------------------------------------------------------------------
--< @summary
--< This package provides access to a Vulkan instance.
--------------------------------------------------------------------------------
package Vulkan.Core.Instance is
--< Instance extension names.
VK_EXT_debug_utils : constant Vk_String := To_Vk_String("VK_EXT_debug_utils");
--< Instance layer names.
VK_LAYER_KHRONOS_validation : constant Vk_String := To_Vk_String("VK_LAYER_KHRONOS_validation");
--< A reference to the vkInstance type.
type Vk_Instance is private;
--< This record describes extensions that can be supported by an instance of
--< Vulkan on the platform on which it is being run.
type Vk_Extension_Properties is record
--< Name of the extension.
name : Vk_String;
--< The the version of the extension.
version : Vk_Spec_Version;
end record;
--< Instantiation of Vectors package for holding a list of extensions.
package Vk_Extension_Properties_Vectors is new Ada.Containers.Vectors
(Index_Type => Natural,
Element_Type => Vk_Extension_Properties);
--< Subtype declared for the extension properties vector to make it easier to
--< use.
subtype Vk_Extension_Properties_Vector is Vk_Extension_Properties_Vectors.Vector;
--< This record supported layer properties for an instant of Vulkan.
type Vk_Layer_Properties is record
name : Vk_String;
spec_version : Vk_Spec_Version;
implementation_version : Vk_Spec_Version;
description : Vk_String;
end record;
package Vk_Layer_Properties_Vectors is new Ada.Containers.Vectors
(Index_Type => Natural,
Element_Type => Vk_Layer_Properties);
subtype Vk_Layer_Properties_Vector is Vk_Layer_Properties_Vectors.Vector;
--< Application creation information.
type Vk_Application_Create_Info is record
application_name : Vk_String := To_Vk_String("");
application_version : Vk_Spec_Version := (major => 0, minor => 0, patch => 0);
engine_name : Vk_String := To_Vk_String("");
engine_version : Vk_Spec_Version := (major => 0, minor => 0, patch => 0);
api_version : Vk_Spec_Version := (major => 1, minor => 2, patch => 0);
end record;
--< Instance creation information.
type Vk_Instance_Create_Info is record
application_info : Vk_Application_Create_Info;
enabled_layer_names : Vk_String_Vector;
enabled_extension_names : Vk_String_Vector;
end record;
----------------------------------------------------------------------------
-- Operations
----------------------------------------------------------------------------
----------------------------------------------------------------------------
--< @brief
--< This operation retrieves all of the extension properties that can be used
--< to create a Vulkan instance.
--<
--< @param properties
--< A list of properties with which an instance of Vulkan can be created.
--<
--< @errors
--< The following exceptions can be raised by this operation:
--< VULKAN_ERROR
----------------------------------------------------------------------------
procedure Vk_Enumerate_Instance_Extension_Properties (
properties : in out Vk_Extension_Properties_Vector);
----------------------------------------------------------------------------
--< @brief
--< This operation retrieves all of the layer properties that can be used
--< to create a Vulkan instance.
--<
--< @param properties
--< A list of properties with which an instance of Vulkan can be created.
--<
--< @errors
--< The following exceptions can be raised by this operation:
--< VULKAN_ERROR
----------------------------------------------------------------------------
procedure Vk_Enumerate_Instance_Layer_Properties (
properties : in out Vk_Layer_Properties_Vector);
----------------------------------------------------------------------------
--< @brief
--< This operation creates a new Vulkan Instance.
--<
--< @param create_info
--< Information for creating a new Vulkan Instance.
--<
--< @return
--< Returns a handle to the Vulkan Instance.
--<
--< @errors
--< The following exceptions can be raised by this operation:
--< VULKAN_ERROR
----------------------------------------------------------------------------
function Vk_Create_Instance(
create_info : in Vk_Instance_Create_Info) return Vk_Instance;
----------------------------------------------------------------------------
--< @brief
--< This operation destroys a Vulkan instance.
--<
--< @param instance
--< The instance to destroy.
--<
--< @errors
--< The following exceptions can be raised by this operation:
--< VULKAN_ERROR
----------------------------------------------------------------------------
procedure Vk_Destroy_Instance(
instance : in out Vk_Instance);
----------------------------------------------------------------------------
--< @brief
--< This operation converts the extension properties object to a human readable
--< string.
function Image(property : in Vk_Extension_Properties) return String is
("[ name = " & Image(property.name) & ", version = " & Image(property.version) & " ]") with inline;
function Image(property : in Vk_Layer_Properties) return String is
("[ name = " & Image(property.name) &
", spec_version = " & Image(property.spec_version) &
", implementation_version = " & Image(property.implementation_version) &
", description = " & Image(property.description) & "]") with inline;
function Image(application_info :in Vk_Application_Create_Info) return String is
("[ application_name = " & Image(application_info.application_name) & LF &
", application_version = " & Image(application_info.application_version) & LF &
", engine_name = " & Image(application_info.engine_name) & LF &
", engine_version = " & Image(application_info.engine_version) & LF &
", api_version = " & Image(application_info.api_version) & " ]") with inline;
function Image(instance_create_info : in Vk_Instance_Create_Info) return String is
("[ application_info = " & Image(instance_create_info.application_info) & LF &
", enabled_extension_names.Length = " & instance_create_info.enabled_extension_names.Length'Image & LF &
", enabled_layer_names.Length = " & instance_create_info.enabled_layer_names.Length'Image & "]") with inline;
private
type Vk_Instance is record
instance : System.Address := System.Null_Address;
end record;
end Vulkan.Core.Instance;
|
sungyeon/drake | Ada | 4,250 | adb | with Ada.Text_IO.Formatting;
with System.Formatting.Literals;
with System.Long_Long_Integer_Types;
package body Ada.Text_IO.Modular_IO is
use type System.Long_Long_Integer_Types.Word_Unsigned;
use type System.Long_Long_Integer_Types.Long_Long_Unsigned;
subtype Word_Unsigned is System.Long_Long_Integer_Types.Word_Unsigned;
subtype Long_Long_Unsigned is
System.Long_Long_Integer_Types.Long_Long_Unsigned;
procedure Put_To_Field (
To : out String;
Last : out Natural;
Item : Num;
Base : Number_Base);
procedure Put_To_Field (
To : out String;
Last : out Natural;
Item : Num;
Base : Number_Base) is
begin
if Num'Size > Standard'Word_Size then
Formatting.Modular_Image (To, Last, Long_Long_Unsigned (Item), Base);
else
Formatting.Modular_Image (To, Last, Word_Unsigned (Item), Base);
end if;
end Put_To_Field;
procedure Get_From_Field (
From : String;
Item : out Num;
Last : out Positive);
procedure Get_From_Field (
From : String;
Item : out Num;
Last : out Positive) is
begin
if Num'Size > Standard'Word_Size then
declare
Base_Item : Long_Long_Unsigned;
Error : Boolean;
begin
System.Formatting.Literals.Get_Literal (
From,
Last,
Base_Item,
Error => Error);
if Error or else Base_Item > Long_Long_Unsigned (Num'Last) then
raise Data_Error;
end if;
Item := Num (Base_Item);
end;
else
declare
Base_Item : Word_Unsigned;
Error : Boolean;
begin
System.Formatting.Literals.Get_Literal (
From,
Last,
Base_Item,
Error => Error);
if Error or else Base_Item > Word_Unsigned (Num'Last) then
raise Data_Error;
end if;
Item := Num (Base_Item);
end;
end if;
end Get_From_Field;
-- implementation
procedure Get (
File : File_Type;
Item : out Num;
Width : Field := 0) is
begin
if Width /= 0 then
declare
S : String (1 .. Width);
Last_1 : Natural;
Last_2 : Natural;
begin
Formatting.Get_Field (File, S, Last_1); -- checking the predicate
Get_From_Field (S (1 .. Last_1), Item, Last_2);
if Last_2 /= Last_1 then
raise Data_Error;
end if;
end;
else
declare
S : constant String :=
Formatting.Get_Numeric_Literal (
File, -- checking the predicate
Real => False);
Last : Natural;
begin
Get_From_Field (S, Item, Last);
if Last /= S'Last then
raise Data_Error;
end if;
end;
end if;
end Get;
procedure Get (
Item : out Num;
Width : Field := 0) is
begin
Get (Current_Input.all, Item, Width);
end Get;
procedure Put (
File : File_Type;
Item : Num;
Width : Field := Default_Width;
Base : Number_Base := Default_Base)
is
S : String (1 .. 4 + Num'Width + Width); -- "16##"
Last : Natural;
begin
Put_To_Field (S, Last, Item, Base);
Formatting.Tail (File, S (1 .. Last), Width); -- checking the predicate
end Put;
procedure Put (
Item : Num;
Width : Field := Default_Width;
Base : Number_Base := Default_Base) is
begin
Put (Current_Output.all, Item, Width, Base);
end Put;
procedure Get (
From : String;
Item : out Num;
Last : out Positive) is
begin
Formatting.Get_Tail (From, First => Last);
Get_From_Field (From (Last .. From'Last), Item, Last);
end Get;
procedure Put (
To : out String;
Item : Num;
Base : Number_Base := Default_Base)
is
S : String (1 .. To'Length);
Last : Natural;
begin
Put_To_Field (S, Last, Item, Base);
Formatting.Tail (To, S (1 .. Last));
end Put;
end Ada.Text_IO.Modular_IO;
|
onox/sdlada | Ada | 3,093 | adb | --------------------------------------------------------------------------------------------------------------------
-- Copyright (c) 2013-2018 Luke A. Guest
--
-- This software is provided 'as-is', without any express or implied
-- warranty. In no event will the authors be held liable for any damages
-- arising from the use of this software.
--
-- Permission is granted to anyone to use this software for any purpose,
-- including commercial applications, and to alter it and redistribute it
-- freely, subject to the following restrictions:
--
-- 1. The origin of this software must not be misrepresented; you must not
-- claim that you wrote the original software. If you use this software
-- in a product, an acknowledgment in the product documentation would be
-- appreciated but is not required.
--
-- 2. Altered source versions must be plainly marked as such, and must not be
-- misrepresented as being the original software.
--
-- 3. This notice may not be removed or altered from any source
-- distribution.
--------------------------------------------------------------------------------------------------------------------
with SDL.Error;
package body SDL.TTFs.Makers is
use type RWops.RWops;
procedure Create (Font : in out Fonts;
File_Name : in String;
Point_Size : in Point_Sizes;
Font_Index : in Font_Faces := Font_Faces'First) is
Ops : RWops.RWops := RWops.From_File (File_Name => File_Name,
Mode => RWops.Read_Binary);
begin
if RWops.Is_Null (Ops) then
raise TTF_Error with "Unable to open font """ & File_Name & '"';
end if;
Create (Font => Font,
Source => Ops,
Point_Size => Point_Size,
Font_Index => Font_Index,
Free_Source => True);
end Create;
procedure Create (Font : in out Fonts;
Source : in RWops.RWops;
Point_Size : in Point_Sizes;
Font_Index : in Font_Faces := Font_Faces'First;
Free_Source : in Boolean := True) is
function TTF_Open_Font_Index_RW (Ops : in RWops.RWops;
Free : in C.int;
Size : in Point_Sizes;
Index : in Font_Faces) return Fonts_Pointer with
Import => True,
Convention => C,
External_Name => "TTF_OpenFontIndexRW";
begin
Font.Internal := TTF_Open_Font_Index_RW (Ops => Source,
Free => (if Free_Source = True then 1 else 0),
Size => Point_Size,
Index => Font_Index);
if Font.Internal = null then
raise TTF_Error with Error.Get;
else
Font.Source_Freed := Free_Source;
end if;
end Create;
end SDL.TTFs.Makers;
|
reznikmm/matreshka | Ada | 4,574 | 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.Descent_Attributes is
------------
-- Create --
------------
overriding function Create
(Parameters : not null access Matreshka.DOM_Attributes.Attribute_L2_Parameters)
return Svg_Descent_Attribute_Node is
begin
return Self : Svg_Descent_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_Descent_Attribute_Node)
return League.Strings.Universal_String
is
pragma Unreferenced (Self);
begin
return Matreshka.ODF_String_Constants.Descent_Attribute;
end Get_Local_Name;
begin
Matreshka.DOM_Documents.Register_Attribute
(Matreshka.ODF_String_Constants.Svg_URI,
Matreshka.ODF_String_Constants.Descent_Attribute,
Svg_Descent_Attribute_Node'Tag);
end Matreshka.ODF_Svg.Descent_Attributes;
|
zhmu/ananas | Ada | 5,047 | adb | ------------------------------------------------------------------------------
-- --
-- GNAT RUN-TIME COMPONENTS --
-- --
-- A D A . W I D E _ T E X T _ I O . F I X E D _ I O --
-- --
-- B o d y --
-- --
-- Copyright (C) 2020-2022, Free Software Foundation, Inc. --
-- --
-- GNAT is free software; you can redistribute it and/or modify it under --
-- terms of the GNU General Public License as published by the Free Soft- --
-- ware Foundation; either version 3, or (at your option) any later ver- --
-- sion. GNAT is distributed in the hope that it will be useful, but WITH- --
-- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY --
-- or FITNESS FOR A PARTICULAR PURPOSE. --
-- --
-- As a special exception under Section 7 of GPL version 3, you are granted --
-- additional permissions described in the GCC Runtime Library Exception, --
-- version 3.1, as published by the Free Software Foundation. --
-- --
-- You should have received a copy of the GNU General Public License and --
-- a copy of the GCC Runtime Library Exception along with this program; --
-- see the files COPYING3 and COPYING.RUNTIME respectively. If not, see --
-- <http://www.gnu.org/licenses/>. --
-- --
-- GNAT was originally developed by the GNAT team at New York University. --
-- Extensive contributions were provided by Ada Core Technologies Inc. --
-- --
------------------------------------------------------------------------------
with Ada.Wide_Text_IO.Generic_Aux; use Ada.Wide_Text_IO.Generic_Aux;
package body Ada.Wide_Text_IO.Fixed_Aux is
---------
-- Get --
---------
function Get
(File : File_Type;
Width : Field;
Num : Int;
Den : Int) return Int
is
Buf : String (1 .. Field'Last);
Ptr : aliased Integer;
Stop : Integer := 0;
Item : Int;
begin
if Width /= 0 then
Load_Width (File, Width, Buf, Stop);
String_Skip (Buf, Ptr);
else
Load_Real (File, Buf, Stop);
Ptr := 1;
end if;
Item := Scan (Buf, Ptr'Access, Stop, Num, Den);
Check_End_Of_Field (Buf, Stop, Ptr, Width);
return Item;
end Get;
----------
-- Gets --
----------
function Gets
(From : String;
Last : out Positive;
Num : Int;
Den : Int) return Int
is
Pos : aliased Integer;
Item : Int;
begin
String_Skip (From, Pos);
Item := Scan (From, Pos'Access, From'Last, Num, Den);
Last := Pos - 1;
return Item;
exception
when Constraint_Error =>
Last := Pos - 1;
raise Data_Error;
end Gets;
---------
-- Put --
---------
procedure Put
(File : File_Type;
Item : Int;
Fore : Field;
Aft : Field;
Exp : Natural;
Num : Int;
Den : Int;
For0 : Natural;
Aft0 : Natural)
is
Buf : String (1 .. Field'Last);
Ptr : Natural := 0;
begin
Set_Image (Item, Buf, Ptr, Num, Den, For0, Aft0, Fore, Aft, Exp);
Put_Item (File, Buf (1 .. Ptr));
end Put;
----------
-- Puts --
----------
procedure Puts
(To : out String;
Item : Int;
Aft : Field;
Exp : Natural;
Num : Int;
Den : Int;
For0 : Natural;
Aft0 : Natural)
is
Buf : String (1 .. Positive'Max (Field'Last, To'Length));
Fore : Integer;
Ptr : Natural := 0;
begin
-- Compute Fore, allowing for the decimal dot and Aft digits
Fore := To'Length - 1 - Field'Max (1, Aft);
-- Allow for Exp and one more for E if exponent present
if Exp /= 0 then
Fore := Fore - 1 - Field'Max (2, Exp);
end if;
-- Make sure we have enough room
if Fore < 1 + Boolean'Pos (Item < 0) then
raise Layout_Error;
end if;
-- Do the conversion and check length of result
Set_Image (Item, Buf, Ptr, Num, Den, For0, Aft0, Fore, Aft, Exp);
if Ptr > To'Length then
raise Layout_Error;
else
To := Buf (1 .. Ptr);
end if;
end Puts;
end Ada.Wide_Text_IO.Fixed_Aux;
|
zhmu/ananas | Ada | 63,462 | adb | ------------------------------------------------------------------------------
-- --
-- GNAT LIBRARY COMPONENTS --
-- --
-- ADA.CONTAINERS.INDEFINITE_ORDERED_SETS --
-- --
-- B o d y --
-- --
-- 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. --
------------------------------------------------------------------------------
with Ada.Containers.Helpers; use Ada.Containers.Helpers;
with Ada.Containers.Red_Black_Trees.Generic_Operations;
pragma Elaborate_All (Ada.Containers.Red_Black_Trees.Generic_Operations);
with Ada.Containers.Red_Black_Trees.Generic_Keys;
pragma Elaborate_All (Ada.Containers.Red_Black_Trees.Generic_Keys);
with Ada.Containers.Red_Black_Trees.Generic_Set_Operations;
pragma Elaborate_All (Ada.Containers.Red_Black_Trees.Generic_Set_Operations);
with Ada.Unchecked_Deallocation;
with System; use type System.Address;
with System.Put_Images;
package body Ada.Containers.Indefinite_Ordered_Sets with
SPARK_Mode => Off
is
pragma Warnings (Off, "variable ""Busy*"" is not referenced");
pragma Warnings (Off, "variable ""Lock*"" is not referenced");
-- See comment in Ada.Containers.Helpers
-----------------------
-- Local Subprograms --
-----------------------
function Color (Node : Node_Access) return Color_Type;
pragma Inline (Color);
function Copy_Node (Source : Node_Access) return Node_Access;
pragma Inline (Copy_Node);
procedure Free (X : in out Node_Access);
procedure Insert_Sans_Hint
(Tree : in out Tree_Type;
New_Item : Element_Type;
Node : out Node_Access;
Inserted : out Boolean);
procedure Insert_With_Hint
(Dst_Tree : in out Tree_Type;
Dst_Hint : Node_Access;
Src_Node : Node_Access;
Dst_Node : out Node_Access);
function Is_Greater_Element_Node
(Left : Element_Type;
Right : Node_Access) return Boolean;
pragma Inline (Is_Greater_Element_Node);
function Is_Less_Element_Node
(Left : Element_Type;
Right : Node_Access) return Boolean;
pragma Inline (Is_Less_Element_Node);
function Is_Less_Node_Node (L, R : Node_Access) return Boolean;
pragma Inline (Is_Less_Node_Node);
function Left (Node : Node_Access) return Node_Access;
pragma Inline (Left);
function Parent (Node : Node_Access) return Node_Access;
pragma Inline (Parent);
procedure Replace_Element
(Tree : in out Tree_Type;
Node : Node_Access;
Item : Element_Type);
function Right (Node : Node_Access) return Node_Access;
pragma Inline (Right);
procedure Set_Color (Node : Node_Access; Color : Color_Type);
pragma Inline (Set_Color);
procedure Set_Left (Node : Node_Access; Left : Node_Access);
pragma Inline (Set_Left);
procedure Set_Parent (Node : Node_Access; Parent : Node_Access);
pragma Inline (Set_Parent);
procedure Set_Right (Node : Node_Access; Right : Node_Access);
pragma Inline (Set_Right);
--------------------------
-- Local Instantiations --
--------------------------
procedure Free_Element is
new Ada.Unchecked_Deallocation (Element_Type, Element_Access);
package Tree_Operations is
new Red_Black_Trees.Generic_Operations (Tree_Types);
procedure Delete_Tree is
new Tree_Operations.Generic_Delete_Tree (Free);
function Copy_Tree is
new Tree_Operations.Generic_Copy_Tree (Copy_Node, Delete_Tree);
use Tree_Operations;
package Element_Keys is
new Red_Black_Trees.Generic_Keys
(Tree_Operations => Tree_Operations,
Key_Type => Element_Type,
Is_Less_Key_Node => Is_Less_Element_Node,
Is_Greater_Key_Node => Is_Greater_Element_Node);
package Set_Ops is
new Generic_Set_Operations
(Tree_Operations => Tree_Operations,
Insert_With_Hint => Insert_With_Hint,
Copy_Tree => Copy_Tree,
Delete_Tree => Delete_Tree,
Is_Less => Is_Less_Node_Node,
Free => Free);
---------
-- "<" --
---------
function "<" (Left, Right : Cursor) return Boolean is
begin
if Checks and then Left.Node = null then
raise Constraint_Error with "Left cursor equals No_Element";
end if;
if Checks and then Right.Node = null then
raise Constraint_Error with "Right cursor equals No_Element";
end if;
if Checks and then Left.Node.Element = null then
raise Program_Error with "Left cursor is bad";
end if;
if Checks and then Right.Node.Element = null then
raise Program_Error with "Right cursor is bad";
end if;
pragma Assert (Vet (Left.Container.Tree, Left.Node),
"bad Left cursor in ""<""");
pragma Assert (Vet (Right.Container.Tree, Right.Node),
"bad Right cursor in ""<""");
return Left.Node.Element.all < Right.Node.Element.all;
end "<";
function "<" (Left : Cursor; Right : Element_Type) return Boolean is
begin
if Checks and then Left.Node = null then
raise Constraint_Error with "Left cursor equals No_Element";
end if;
if Checks and then Left.Node.Element = null then
raise Program_Error with "Left cursor is bad";
end if;
pragma Assert (Vet (Left.Container.Tree, Left.Node),
"bad Left cursor in ""<""");
return Left.Node.Element.all < Right;
end "<";
function "<" (Left : Element_Type; Right : Cursor) return Boolean is
begin
if Checks and then Right.Node = null then
raise Constraint_Error with "Right cursor equals No_Element";
end if;
if Checks and then Right.Node.Element = null then
raise Program_Error with "Right cursor is bad";
end if;
pragma Assert (Vet (Right.Container.Tree, Right.Node),
"bad Right cursor in ""<""");
return Left < Right.Node.Element.all;
end "<";
---------
-- "=" --
---------
function "=" (Left, Right : Set) return Boolean is
function Is_Equal_Node_Node (L, R : Node_Access) return Boolean;
pragma Inline (Is_Equal_Node_Node);
function Is_Equal is
new Tree_Operations.Generic_Equal (Is_Equal_Node_Node);
------------------------
-- Is_Equal_Node_Node --
------------------------
function Is_Equal_Node_Node (L, R : Node_Access) return Boolean is
begin
return L.Element.all = R.Element.all;
end Is_Equal_Node_Node;
-- Start of processing for "="
begin
return Is_Equal (Left.Tree, Right.Tree);
end "=";
---------
-- ">" --
---------
function ">" (Left, Right : Cursor) return Boolean is
begin
if Checks and then Left.Node = null then
raise Constraint_Error with "Left cursor equals No_Element";
end if;
if Checks and then Right.Node = null then
raise Constraint_Error with "Right cursor equals No_Element";
end if;
if Checks and then Left.Node.Element = null then
raise Program_Error with "Left cursor is bad";
end if;
if Checks and then Right.Node.Element = null then
raise Program_Error with "Right cursor is bad";
end if;
pragma Assert (Vet (Left.Container.Tree, Left.Node),
"bad Left cursor in "">""");
pragma Assert (Vet (Right.Container.Tree, Right.Node),
"bad Right cursor in "">""");
-- L > R same as R < L
return Right.Node.Element.all < Left.Node.Element.all;
end ">";
function ">" (Left : Cursor; Right : Element_Type) return Boolean is
begin
if Checks and then Left.Node = null then
raise Constraint_Error with "Left cursor equals No_Element";
end if;
if Checks and then Left.Node.Element = null then
raise Program_Error with "Left cursor is bad";
end if;
pragma Assert (Vet (Left.Container.Tree, Left.Node),
"bad Left cursor in "">""");
return Right < Left.Node.Element.all;
end ">";
function ">" (Left : Element_Type; Right : Cursor) return Boolean is
begin
if Checks and then Right.Node = null then
raise Constraint_Error with "Right cursor equals No_Element";
end if;
if Checks and then Right.Node.Element = null then
raise Program_Error with "Right cursor is bad";
end if;
pragma Assert (Vet (Right.Container.Tree, Right.Node),
"bad Right cursor in "">""");
return Right.Node.Element.all < Left;
end ">";
------------
-- Adjust --
------------
procedure Adjust is new Tree_Operations.Generic_Adjust (Copy_Tree);
procedure Adjust (Container : in out Set) is
begin
Adjust (Container.Tree);
end Adjust;
------------
-- Assign --
------------
procedure Assign (Target : in out Set; Source : Set) is
begin
if Target'Address = Source'Address then
return;
end if;
Target.Clear;
Target.Union (Source);
end Assign;
-------------
-- Ceiling --
-------------
function Ceiling (Container : Set; Item : Element_Type) return Cursor is
Node : constant Node_Access :=
Element_Keys.Ceiling (Container.Tree, Item);
begin
return (if Node = null then No_Element
else Cursor'(Container'Unrestricted_Access, Node));
end Ceiling;
-----------
-- Clear --
-----------
procedure Clear is
new Tree_Operations.Generic_Clear (Delete_Tree);
procedure Clear (Container : in out Set) is
begin
Clear (Container.Tree);
end Clear;
-----------
-- Color --
-----------
function Color (Node : Node_Access) return Color_Type is
begin
return Node.Color;
end Color;
------------------------
-- Constant_Reference --
------------------------
function Constant_Reference
(Container : aliased Set;
Position : Cursor) return Constant_Reference_Type
is
begin
if Checks and then Position.Container = null then
raise Constraint_Error with "Position cursor has no element";
end if;
if Checks and then Position.Container /= Container'Unrestricted_Access
then
raise Program_Error with
"Position cursor designates wrong container";
end if;
if Checks and then Position.Node.Element = null then
raise Program_Error with "Node has no element";
end if;
pragma Assert
(Vet (Container.Tree, Position.Node),
"bad cursor in Constant_Reference");
declare
Tree : Tree_Type renames Position.Container.all.Tree;
TC : constant Tamper_Counts_Access :=
Tree.TC'Unrestricted_Access;
begin
return R : constant Constant_Reference_Type :=
(Element => Position.Node.Element.all'Access,
Control => (Controlled with TC))
do
Busy (TC.all);
end return;
end;
end Constant_Reference;
--------------
-- Contains --
--------------
function Contains (Container : Set; Item : Element_Type) return Boolean is
begin
return Find (Container, Item) /= No_Element;
end Contains;
----------
-- Copy --
----------
function Copy (Source : Set) return Set is
begin
return Target : Set do
Target.Assign (Source);
end return;
end Copy;
---------------
-- Copy_Node --
---------------
function Copy_Node (Source : Node_Access) return Node_Access is
Element : Element_Access := new Element_Type'(Source.Element.all);
begin
return new Node_Type'(Parent => null,
Left => null,
Right => null,
Color => Source.Color,
Element => Element);
exception
when others =>
Free_Element (Element);
raise;
end Copy_Node;
------------
-- Delete --
------------
procedure Delete (Container : in out Set; Position : in out Cursor) is
begin
if Checks and then Position.Node = null then
raise Constraint_Error with "Position cursor equals No_Element";
end if;
if Checks and then Position.Node.Element = null then
raise Program_Error with "Position cursor is bad";
end if;
if Checks and then Position.Container /= Container'Unrestricted_Access
then
raise Program_Error with "Position cursor designates wrong set";
end if;
pragma Assert (Vet (Container.Tree, Position.Node),
"bad cursor in Delete");
Tree_Operations.Delete_Node_Sans_Free (Container.Tree, Position.Node);
Free (Position.Node);
Position.Container := null;
end Delete;
procedure Delete (Container : in out Set; Item : Element_Type) is
X : Node_Access := Element_Keys.Find (Container.Tree, Item);
begin
if Checks and then X = null then
raise Constraint_Error with "attempt to delete element not in set";
end if;
Tree_Operations.Delete_Node_Sans_Free (Container.Tree, X);
Free (X);
end Delete;
------------------
-- Delete_First --
------------------
procedure Delete_First (Container : in out Set) is
Tree : Tree_Type renames Container.Tree;
X : Node_Access := Tree.First;
begin
if X /= null then
Tree_Operations.Delete_Node_Sans_Free (Tree, X);
Free (X);
end if;
end Delete_First;
-----------------
-- Delete_Last --
-----------------
procedure Delete_Last (Container : in out Set) is
Tree : Tree_Type renames Container.Tree;
X : Node_Access := Tree.Last;
begin
if X /= null then
Tree_Operations.Delete_Node_Sans_Free (Tree, X);
Free (X);
end if;
end Delete_Last;
----------------
-- Difference --
----------------
procedure Difference (Target : in out Set; Source : Set) is
begin
Set_Ops.Difference (Target.Tree, Source.Tree);
end Difference;
function Difference (Left, Right : Set) return Set is
Tree : constant Tree_Type := Set_Ops.Difference (Left.Tree, Right.Tree);
begin
return Set'(Controlled with Tree);
end Difference;
-------------
-- Element --
-------------
function Element (Position : Cursor) return Element_Type is
begin
if Checks and then Position.Node = null then
raise Constraint_Error with "Position cursor equals No_Element";
end if;
if Checks and then Position.Node.Element = null then
raise Program_Error with "Position cursor is bad";
end if;
if Checks
and then (Left (Position.Node) = Position.Node
or else
Right (Position.Node) = Position.Node)
then
raise Program_Error with "dangling cursor";
end if;
pragma Assert (Vet (Position.Container.Tree, Position.Node),
"bad cursor in Element");
return Position.Node.Element.all;
end Element;
-------------------------
-- Equivalent_Elements --
-------------------------
function Equivalent_Elements (Left, Right : Element_Type) return Boolean is
begin
if Left < Right or else Right < Left then
return False;
else
return True;
end if;
end Equivalent_Elements;
---------------------
-- Equivalent_Sets --
---------------------
function Equivalent_Sets (Left, Right : Set) return Boolean is
function Is_Equivalent_Node_Node (L, R : Node_Access) return Boolean;
pragma Inline (Is_Equivalent_Node_Node);
function Is_Equivalent is
new Tree_Operations.Generic_Equal (Is_Equivalent_Node_Node);
-----------------------------
-- Is_Equivalent_Node_Node --
-----------------------------
function Is_Equivalent_Node_Node (L, R : Node_Access) return Boolean is
begin
if L.Element.all < R.Element.all then
return False;
elsif R.Element.all < L.Element.all then
return False;
else
return True;
end if;
end Is_Equivalent_Node_Node;
-- Start of processing for Equivalent_Sets
begin
return Is_Equivalent (Left.Tree, Right.Tree);
end Equivalent_Sets;
-------------
-- Exclude --
-------------
procedure Exclude (Container : in out Set; Item : Element_Type) is
X : Node_Access := Element_Keys.Find (Container.Tree, Item);
begin
if X /= null then
Tree_Operations.Delete_Node_Sans_Free (Container.Tree, X);
Free (X);
end if;
end Exclude;
--------------
-- Finalize --
--------------
procedure Finalize (Object : in out Iterator) is
begin
if Object.Container /= null then
Unbusy (Object.Container.Tree.TC);
end if;
end Finalize;
----------
-- Find --
----------
function Find (Container : Set; Item : Element_Type) return Cursor is
Node : constant Node_Access := Element_Keys.Find (Container.Tree, Item);
begin
if Node = null then
return No_Element;
else
return Cursor'(Container'Unrestricted_Access, Node);
end if;
end Find;
-----------
-- First --
-----------
function First (Container : Set) return Cursor is
begin
return
(if Container.Tree.First = null then No_Element
else Cursor'(Container'Unrestricted_Access, Container.Tree.First));
end First;
function First (Object : Iterator) return Cursor is
begin
-- The value of the iterator object's Node component influences the
-- behavior of the First (and Last) selector function.
-- When the Node component is null, this means the iterator object was
-- constructed without a start expression, in which case the (forward)
-- iteration starts from the (logical) beginning of the entire sequence
-- of items (corresponding to Container.First, for a forward iterator).
-- Otherwise, this is iteration over a partial sequence of items. When
-- the Node component is non-null, the iterator object was constructed
-- with a start expression, that specifies the position from which the
-- (forward) partial iteration begins.
if Object.Node = null then
return Object.Container.First;
else
return Cursor'(Object.Container, Object.Node);
end if;
end First;
-------------------
-- First_Element --
-------------------
function First_Element (Container : Set) return Element_Type is
begin
if Checks and then Container.Tree.First = null then
raise Constraint_Error with "set is empty";
end if;
return Container.Tree.First.Element.all;
end First_Element;
-----------
-- Floor --
-----------
function Floor (Container : Set; Item : Element_Type) return Cursor is
Node : constant Node_Access := Element_Keys.Floor (Container.Tree, Item);
begin
return (if Node = null then No_Element
else Cursor'(Container'Unrestricted_Access, Node));
end Floor;
----------
-- Free --
----------
procedure Free (X : in out Node_Access) is
procedure Deallocate is
new Ada.Unchecked_Deallocation (Node_Type, Node_Access);
begin
if X = null then
return;
end if;
X.Parent := X;
X.Left := X;
X.Right := X;
begin
Free_Element (X.Element);
exception
when others =>
X.Element := null;
Deallocate (X);
raise;
end;
Deallocate (X);
end Free;
------------------
-- Generic_Keys --
------------------
package body Generic_Keys is
-----------------------
-- Local Subprograms --
-----------------------
function Is_Greater_Key_Node
(Left : Key_Type;
Right : Node_Access) return Boolean;
pragma Inline (Is_Greater_Key_Node);
function Is_Less_Key_Node
(Left : Key_Type;
Right : Node_Access) return Boolean;
pragma Inline (Is_Less_Key_Node);
--------------------------
-- Local Instantiations --
--------------------------
package Key_Keys is
new Red_Black_Trees.Generic_Keys
(Tree_Operations => Tree_Operations,
Key_Type => Key_Type,
Is_Less_Key_Node => Is_Less_Key_Node,
Is_Greater_Key_Node => Is_Greater_Key_Node);
-------------
-- Ceiling --
-------------
function Ceiling (Container : Set; Key : Key_Type) return Cursor is
Node : constant Node_Access := Key_Keys.Ceiling (Container.Tree, Key);
begin
return (if Node = null then No_Element
else Cursor'(Container'Unrestricted_Access, Node));
end Ceiling;
------------------------
-- Constant_Reference --
------------------------
function Constant_Reference
(Container : aliased Set;
Key : Key_Type) return Constant_Reference_Type
is
Position : constant Cursor := Find (Container, Key);
begin
if Checks and then Position = No_Element then
raise Constraint_Error with "Key not in set";
end if;
return Constant_Reference (Container, Position);
end Constant_Reference;
--------------
-- Contains --
--------------
function Contains (Container : Set; Key : Key_Type) return Boolean is
begin
return Find (Container, Key) /= No_Element;
end Contains;
------------
-- Delete --
------------
procedure Delete (Container : in out Set; Key : Key_Type) is
X : Node_Access := Key_Keys.Find (Container.Tree, Key);
begin
if Checks and then X = null then
raise Constraint_Error with "attempt to delete key not in set";
end if;
Tree_Operations.Delete_Node_Sans_Free (Container.Tree, X);
Free (X);
end Delete;
-------------
-- Element --
-------------
function Element (Container : Set; Key : Key_Type) return Element_Type is
Node : constant Node_Access := Key_Keys.Find (Container.Tree, Key);
begin
if Checks and then Node = null then
raise Constraint_Error with "key not in set";
end if;
return Node.Element.all;
end Element;
---------------------
-- Equivalent_Keys --
---------------------
function Equivalent_Keys (Left, Right : Key_Type) return Boolean is
begin
if Left < Right or else Right < Left then
return False;
else
return True;
end if;
end Equivalent_Keys;
-------------
-- Exclude --
-------------
procedure Exclude (Container : in out Set; Key : Key_Type) is
X : Node_Access := Key_Keys.Find (Container.Tree, Key);
begin
if X /= null then
Tree_Operations.Delete_Node_Sans_Free (Container.Tree, X);
Free (X);
end if;
end Exclude;
--------------
-- Finalize --
--------------
procedure Finalize (Control : in out Reference_Control_Type) is
begin
if Control.Container /= null then
Impl.Reference_Control_Type (Control).Finalize;
if Checks and then not (Key (Control.Pos) = Control.Old_Key.all)
then
Delete (Control.Container.all, Key (Control.Pos));
raise Program_Error;
end if;
Control.Container := null;
Control.Old_Key := null;
end if;
end Finalize;
----------
-- Find --
----------
function Find (Container : Set; Key : Key_Type) return Cursor is
Node : constant Node_Access := Key_Keys.Find (Container.Tree, Key);
begin
return (if Node = null then No_Element
else Cursor'(Container'Unrestricted_Access, Node));
end Find;
-----------
-- Floor --
-----------
function Floor (Container : Set; Key : Key_Type) return Cursor is
Node : constant Node_Access := Key_Keys.Floor (Container.Tree, Key);
begin
return (if Node = null then No_Element
else Cursor'(Container'Unrestricted_Access, Node));
end Floor;
-------------------------
-- Is_Greater_Key_Node --
-------------------------
function Is_Greater_Key_Node
(Left : Key_Type;
Right : Node_Access) return Boolean
is
begin
return Key (Right.Element.all) < Left;
end Is_Greater_Key_Node;
----------------------
-- Is_Less_Key_Node --
----------------------
function Is_Less_Key_Node
(Left : Key_Type;
Right : Node_Access) return Boolean
is
begin
return Left < Key (Right.Element.all);
end Is_Less_Key_Node;
---------
-- Key --
---------
function Key (Position : Cursor) return Key_Type is
begin
if Checks and then Position.Node = null then
raise Constraint_Error with
"Position cursor equals No_Element";
end if;
if Checks and then Position.Node.Element = null then
raise Program_Error with
"Position cursor is bad";
end if;
pragma Assert (Vet (Position.Container.Tree, Position.Node),
"bad cursor in Key");
return Key (Position.Node.Element.all);
end Key;
-------------
-- Replace --
-------------
procedure Replace
(Container : in out Set;
Key : Key_Type;
New_Item : Element_Type)
is
Node : constant Node_Access := Key_Keys.Find (Container.Tree, Key);
begin
if Checks and then Node = null then
raise Constraint_Error with
"attempt to replace key not in set";
end if;
Replace_Element (Container.Tree, Node, New_Item);
end Replace;
----------
-- Read --
----------
procedure Read
(Stream : not null access Root_Stream_Type'Class;
Item : out Reference_Type)
is
begin
raise Program_Error with "attempt to stream reference";
end Read;
------------------------------
-- Reference_Preserving_Key --
------------------------------
function Reference_Preserving_Key
(Container : aliased in out Set;
Position : Cursor) return Reference_Type
is
begin
if Checks and then Position.Container = null then
raise Constraint_Error with "Position cursor has no element";
end if;
if Checks and then Position.Container /= Container'Unrestricted_Access
then
raise Program_Error with
"Position cursor designates wrong container";
end if;
if Checks and then Position.Node.Element = null then
raise Program_Error with "Node has no element";
end if;
pragma Assert
(Vet (Container.Tree, Position.Node),
"bad cursor in function Reference_Preserving_Key");
declare
Tree : Tree_Type renames Container.Tree;
begin
return R : constant Reference_Type :=
(Element => Position.Node.Element.all'Unchecked_Access,
Control =>
(Controlled with
Tree.TC'Unrestricted_Access,
Container => Container'Unchecked_Access,
Pos => Position,
Old_Key => new Key_Type'(Key (Position))))
do
Busy (Tree.TC);
end return;
end;
end Reference_Preserving_Key;
function Reference_Preserving_Key
(Container : aliased in out Set;
Key : Key_Type) return Reference_Type
is
Position : constant Cursor := Find (Container, Key);
begin
if Checks and then Position = No_Element then
raise Constraint_Error with "Key not in set";
end if;
return Reference_Preserving_Key (Container, Position);
end Reference_Preserving_Key;
-----------------------------------
-- Update_Element_Preserving_Key --
-----------------------------------
procedure Update_Element_Preserving_Key
(Container : in out Set;
Position : Cursor;
Process : not null access
procedure (Element : in out Element_Type))
is
Tree : Tree_Type renames Container.Tree;
begin
if Checks and then Position.Node = null then
raise Constraint_Error with "Position cursor equals No_Element";
end if;
if Checks and then Position.Node.Element = null then
raise Program_Error with "Position cursor is bad";
end if;
if Checks and then Position.Container /= Container'Unrestricted_Access
then
raise Program_Error with "Position cursor designates wrong set";
end if;
pragma Assert (Vet (Container.Tree, Position.Node),
"bad cursor in Update_Element_Preserving_Key");
declare
E : Element_Type renames Position.Node.Element.all;
K : constant Key_Type := Key (E);
Lock : With_Lock (Tree.TC'Unrestricted_Access);
begin
Process (E);
if Equivalent_Keys (K, Key (E)) then
return;
end if;
end;
declare
X : Node_Access := Position.Node;
begin
Tree_Operations.Delete_Node_Sans_Free (Tree, X);
Free (X);
end;
raise Program_Error with "key was modified";
end Update_Element_Preserving_Key;
-----------
-- Write --
-----------
procedure Write
(Stream : not null access Root_Stream_Type'Class;
Item : Reference_Type)
is
begin
raise Program_Error with "attempt to stream reference";
end Write;
end Generic_Keys;
------------------------
-- Get_Element_Access --
------------------------
function Get_Element_Access
(Position : Cursor) return not null Element_Access is
begin
return Position.Node.Element;
end Get_Element_Access;
-----------------
-- Has_Element --
-----------------
function Has_Element (Position : Cursor) return Boolean is
begin
return Position /= No_Element;
end Has_Element;
-------------
-- Include --
-------------
procedure Include (Container : in out Set; New_Item : Element_Type) is
Position : Cursor;
Inserted : Boolean;
X : Element_Access;
begin
Insert (Container, New_Item, Position, Inserted);
if not Inserted then
TE_Check (Container.Tree.TC);
declare
-- The element allocator may need an accessibility check in the
-- case the actual type is class-wide or has access discriminants
-- (see RM 4.8(10.1) and AI12-0035).
pragma Unsuppress (Accessibility_Check);
begin
X := Position.Node.Element;
Position.Node.Element := new Element_Type'(New_Item);
Free_Element (X);
end;
end if;
end Include;
------------
-- Insert --
------------
procedure Insert
(Container : in out Set;
New_Item : Element_Type;
Position : out Cursor;
Inserted : out Boolean)
is
begin
Insert_Sans_Hint
(Container.Tree,
New_Item,
Position.Node,
Inserted);
Position.Container := Container'Unrestricted_Access;
end Insert;
procedure Insert (Container : in out Set; New_Item : Element_Type) is
Position : Cursor;
Inserted : Boolean;
begin
Insert (Container, New_Item, Position, Inserted);
if Checks and then not Inserted then
raise Constraint_Error with
"attempt to insert element already in set";
end if;
end Insert;
----------------------
-- Insert_Sans_Hint --
----------------------
procedure Insert_Sans_Hint
(Tree : in out Tree_Type;
New_Item : Element_Type;
Node : out Node_Access;
Inserted : out Boolean)
is
function New_Node return Node_Access;
pragma Inline (New_Node);
procedure Insert_Post is
new Element_Keys.Generic_Insert_Post (New_Node);
procedure Conditional_Insert_Sans_Hint is
new Element_Keys.Generic_Conditional_Insert (Insert_Post);
--------------
-- New_Node --
--------------
function New_Node return Node_Access is
-- The element allocator may need an accessibility check in the case
-- the actual type is class-wide or has access discriminants (see
-- RM 4.8(10.1) and AI12-0035).
pragma Unsuppress (Accessibility_Check);
Element : Element_Access := new Element_Type'(New_Item);
begin
return new Node_Type'(Parent => null,
Left => null,
Right => null,
Color => Red_Black_Trees.Red,
Element => Element);
exception
when others =>
Free_Element (Element);
raise;
end New_Node;
-- Start of processing for Insert_Sans_Hint
begin
Conditional_Insert_Sans_Hint
(Tree,
New_Item,
Node,
Inserted);
end Insert_Sans_Hint;
----------------------
-- Insert_With_Hint --
----------------------
procedure Insert_With_Hint
(Dst_Tree : in out Tree_Type;
Dst_Hint : Node_Access;
Src_Node : Node_Access;
Dst_Node : out Node_Access)
is
Success : Boolean;
function New_Node return Node_Access;
procedure Insert_Post is
new Element_Keys.Generic_Insert_Post (New_Node);
procedure Insert_Sans_Hint is
new Element_Keys.Generic_Conditional_Insert (Insert_Post);
procedure Insert_With_Hint is
new Element_Keys.Generic_Conditional_Insert_With_Hint
(Insert_Post,
Insert_Sans_Hint);
--------------
-- New_Node --
--------------
function New_Node return Node_Access is
Element : Element_Access := new Element_Type'(Src_Node.Element.all);
Node : Node_Access;
begin
begin
Node := new Node_Type;
exception
when others =>
Free_Element (Element);
raise;
end;
Node.Element := Element;
return Node;
end New_Node;
-- Start of processing for Insert_With_Hint
begin
Insert_With_Hint
(Dst_Tree,
Dst_Hint,
Src_Node.Element.all,
Dst_Node,
Success);
end Insert_With_Hint;
------------------
-- Intersection --
------------------
procedure Intersection (Target : in out Set; Source : Set) is
begin
Set_Ops.Intersection (Target.Tree, Source.Tree);
end Intersection;
function Intersection (Left, Right : Set) return Set is
Tree : constant Tree_Type :=
Set_Ops.Intersection (Left.Tree, Right.Tree);
begin
return Set'(Controlled with Tree);
end Intersection;
--------------
-- Is_Empty --
--------------
function Is_Empty (Container : Set) return Boolean is
begin
return Container.Tree.Length = 0;
end Is_Empty;
-----------------------------
-- Is_Greater_Element_Node --
-----------------------------
function Is_Greater_Element_Node
(Left : Element_Type;
Right : Node_Access) return Boolean
is
begin
-- e > node same as node < e
return Right.Element.all < Left;
end Is_Greater_Element_Node;
--------------------------
-- Is_Less_Element_Node --
--------------------------
function Is_Less_Element_Node
(Left : Element_Type;
Right : Node_Access) return Boolean
is
begin
return Left < Right.Element.all;
end Is_Less_Element_Node;
-----------------------
-- Is_Less_Node_Node --
-----------------------
function Is_Less_Node_Node (L, R : Node_Access) return Boolean is
begin
return L.Element.all < R.Element.all;
end Is_Less_Node_Node;
---------------
-- Is_Subset --
---------------
function Is_Subset (Subset : Set; Of_Set : Set) return Boolean is
begin
return Set_Ops.Is_Subset (Subset => Subset.Tree, Of_Set => Of_Set.Tree);
end Is_Subset;
-------------
-- Iterate --
-------------
procedure Iterate
(Container : Set;
Process : not null access procedure (Position : Cursor))
is
procedure Process_Node (Node : Node_Access);
pragma Inline (Process_Node);
procedure Local_Iterate is
new Tree_Operations.Generic_Iteration (Process_Node);
------------------
-- Process_Node --
------------------
procedure Process_Node (Node : Node_Access) is
begin
Process (Cursor'(Container'Unrestricted_Access, Node));
end Process_Node;
T : Tree_Type renames Container'Unrestricted_Access.all.Tree;
Busy : With_Busy (T.TC'Unrestricted_Access);
-- Start of processing for Iterate
begin
Local_Iterate (T);
end Iterate;
function Iterate
(Container : Set)
return Set_Iterator_Interfaces.Reversible_Iterator'class
is
begin
-- The value of the Node component influences the behavior of the First
-- and Last selector functions of the iterator object. When the Node
-- component is null (as is the case here), this means the iterator
-- object was constructed without a start expression. This is a complete
-- iterator, meaning that the iteration starts from the (logical)
-- beginning of the sequence of items.
-- Note: For a forward iterator, Container.First is the beginning, and
-- for a reverse iterator, Container.Last is the beginning.
return It : constant Iterator :=
Iterator'(Limited_Controlled with
Container => Container'Unrestricted_Access,
Node => null)
do
Busy (Container.Tree.TC'Unrestricted_Access.all);
end return;
end Iterate;
function Iterate
(Container : Set;
Start : Cursor)
return Set_Iterator_Interfaces.Reversible_Iterator'class
is
begin
-- It was formerly the case that when Start = No_Element, the partial
-- iterator was defined to behave the same as for a complete iterator,
-- and iterate over the entire sequence of items. However, those
-- semantics were unintuitive and arguably error-prone (it is too easy
-- to accidentally create an endless loop), and so they were changed,
-- per the ARG meeting in Denver on 2011/11. However, there was no
-- consensus about what positive meaning this corner case should have,
-- and so it was decided to simply raise an exception. This does imply,
-- however, that it is not possible to use a partial iterator to specify
-- an empty sequence of items.
if Checks and then Start = No_Element then
raise Constraint_Error with
"Start position for iterator equals No_Element";
end if;
if Checks and then Start.Container /= Container'Unrestricted_Access then
raise Program_Error with
"Start cursor of Iterate designates wrong set";
end if;
pragma Assert (Vet (Container.Tree, Start.Node),
"Start cursor of Iterate is bad");
-- The value of the Node component influences the behavior of the First
-- and Last selector functions of the iterator object. When the Node
-- component is non-null (as is the case here), it means that this is a
-- partial iteration, over a subset of the complete sequence of
-- items. The iterator object was constructed with a start expression,
-- indicating the position from which the iteration begins. Note that
-- the start position has the same value irrespective of whether this is
-- a forward or reverse iteration.
return It : constant Iterator :=
(Limited_Controlled with
Container => Container'Unrestricted_Access,
Node => Start.Node)
do
Busy (Container.Tree.TC'Unrestricted_Access.all);
end return;
end Iterate;
----------
-- Last --
----------
function Last (Container : Set) return Cursor is
begin
return
(if Container.Tree.Last = null then No_Element
else Cursor'(Container'Unrestricted_Access, Container.Tree.Last));
end Last;
function Last (Object : Iterator) return Cursor is
begin
-- The value of the iterator object's Node component influences the
-- behavior of the Last (and First) selector function.
-- When the Node component is null, this means the iterator object was
-- constructed without a start expression, in which case the (reverse)
-- iteration starts from the (logical) beginning of the entire sequence
-- (corresponding to Container.Last, for a reverse iterator).
-- Otherwise, this is iteration over a partial sequence of items. When
-- the Node component is non-null, the iterator object was constructed
-- with a start expression, that specifies the position from which the
-- (reverse) partial iteration begins.
if Object.Node = null then
return Object.Container.Last;
else
return Cursor'(Object.Container, Object.Node);
end if;
end Last;
------------------
-- Last_Element --
------------------
function Last_Element (Container : Set) return Element_Type is
begin
if Checks and then Container.Tree.Last = null then
raise Constraint_Error with "set is empty";
end if;
return Container.Tree.Last.Element.all;
end Last_Element;
----------
-- Left --
----------
function Left (Node : Node_Access) return Node_Access is
begin
return Node.Left;
end Left;
------------
-- Length --
------------
function Length (Container : Set) return Count_Type is
begin
return Container.Tree.Length;
end Length;
----------
-- Move --
----------
procedure Move is new Tree_Operations.Generic_Move (Clear);
procedure Move (Target : in out Set; Source : in out Set) is
begin
Move (Target => Target.Tree, Source => Source.Tree);
end Move;
----------
-- Next --
----------
procedure Next (Position : in out Cursor) is
begin
Position := Next (Position);
end Next;
function Next (Position : Cursor) return Cursor is
begin
if Position = No_Element then
return No_Element;
end if;
if Checks and then Position.Node.Element = null then
raise Program_Error with "Position cursor is bad";
end if;
pragma Assert (Vet (Position.Container.Tree, Position.Node),
"bad cursor in Next");
declare
Node : constant Node_Access := Tree_Operations.Next (Position.Node);
begin
return (if Node = null then No_Element
else Cursor'(Position.Container, Node));
end;
end Next;
function Next
(Object : Iterator;
Position : Cursor) return Cursor
is
begin
if Position.Container = null then
return No_Element;
end if;
if Checks and then Position.Container /= Object.Container then
raise Program_Error with
"Position cursor of Next designates wrong set";
end if;
return Next (Position);
end Next;
-------------
-- Overlap --
-------------
function Overlap (Left, Right : Set) return Boolean is
begin
return Set_Ops.Overlap (Left.Tree, Right.Tree);
end Overlap;
------------
-- Parent --
------------
function Parent (Node : Node_Access) return Node_Access is
begin
return Node.Parent;
end Parent;
--------------
-- Previous --
--------------
procedure Previous (Position : in out Cursor) is
begin
Position := Previous (Position);
end Previous;
function Previous (Position : Cursor) return Cursor is
begin
if Position = No_Element then
return No_Element;
end if;
if Checks and then Position.Node.Element = null then
raise Program_Error with "Position cursor is bad";
end if;
pragma Assert (Vet (Position.Container.Tree, Position.Node),
"bad cursor in Previous");
declare
Node : constant Node_Access :=
Tree_Operations.Previous (Position.Node);
begin
return (if Node = null then No_Element
else Cursor'(Position.Container, Node));
end;
end Previous;
function Previous
(Object : Iterator;
Position : Cursor) return Cursor
is
begin
if Position.Container = null then
return No_Element;
end if;
if Checks and then Position.Container /= Object.Container then
raise Program_Error with
"Position cursor of Previous designates wrong set";
end if;
return Previous (Position);
end Previous;
----------------------
-- Pseudo_Reference --
----------------------
function Pseudo_Reference
(Container : aliased Set'Class) return Reference_Control_Type
is
TC : constant Tamper_Counts_Access :=
Container.Tree.TC'Unrestricted_Access;
begin
return R : constant Reference_Control_Type := (Controlled with TC) do
Busy (TC.all);
end return;
end Pseudo_Reference;
-------------------
-- Query_Element --
-------------------
procedure Query_Element
(Position : Cursor;
Process : not null access procedure (Element : Element_Type))
is
begin
if Checks and then Position.Node = null then
raise Constraint_Error with "Position cursor equals No_Element";
end if;
if Checks and then Position.Node.Element = null then
raise Program_Error with "Position cursor is bad";
end if;
pragma Assert (Vet (Position.Container.Tree, Position.Node),
"bad cursor in Query_Element");
declare
T : Tree_Type renames Position.Container.Tree;
Lock : With_Lock (T.TC'Unrestricted_Access);
begin
Process (Position.Node.Element.all);
end;
end Query_Element;
---------------
-- Put_Image --
---------------
procedure Put_Image
(S : in out Ada.Strings.Text_Buffers.Root_Buffer_Type'Class; V : Set)
is
First_Time : Boolean := True;
use System.Put_Images;
begin
Array_Before (S);
for X of V loop
if First_Time then
First_Time := False;
else
Simple_Array_Between (S);
end if;
Element_Type'Put_Image (S, X);
end loop;
Array_After (S);
end Put_Image;
----------
-- Read --
----------
procedure Read
(Stream : not null access Root_Stream_Type'Class;
Container : out Set)
is
function Read_Node
(Stream : not null access Root_Stream_Type'Class) return Node_Access;
pragma Inline (Read_Node);
procedure Read is
new Tree_Operations.Generic_Read (Clear, Read_Node);
---------------
-- Read_Node --
---------------
function Read_Node
(Stream : not null access Root_Stream_Type'Class) return Node_Access
is
Node : Node_Access := new Node_Type;
begin
Node.Element := new Element_Type'(Element_Type'Input (Stream));
return Node;
exception
when others =>
Free (Node); -- Note that Free deallocates elem too
raise;
end Read_Node;
-- Start of processing for Read
begin
Read (Stream, Container.Tree);
end Read;
procedure Read
(Stream : not null access Root_Stream_Type'Class;
Item : out Cursor)
is
begin
raise Program_Error with "attempt to stream set cursor";
end Read;
procedure Read
(Stream : not null access Root_Stream_Type'Class;
Item : out Constant_Reference_Type)
is
begin
raise Program_Error with "attempt to stream reference";
end Read;
-------------
-- Replace --
-------------
procedure Replace (Container : in out Set; New_Item : Element_Type) is
Node : constant Node_Access :=
Element_Keys.Find (Container.Tree, New_Item);
X : Element_Access;
pragma Warnings (Off, X);
begin
TE_Check (Container.Tree.TC);
if Checks and then Node = null then
raise Constraint_Error with "attempt to replace element not in set";
end if;
declare
-- The element allocator may need an accessibility check in the case
-- the actual type is class-wide or has access discriminants (see
-- RM 4.8(10.1) and AI12-0035).
pragma Unsuppress (Accessibility_Check);
begin
X := Node.Element;
Node.Element := new Element_Type'(New_Item);
Free_Element (X);
end;
end Replace;
---------------------
-- Replace_Element --
---------------------
procedure Replace_Element
(Tree : in out Tree_Type;
Node : Node_Access;
Item : Element_Type)
is
pragma Assert (Node /= null);
pragma Assert (Node.Element /= null);
function New_Node return Node_Access;
pragma Inline (New_Node);
procedure Local_Insert_Post is
new Element_Keys.Generic_Insert_Post (New_Node);
procedure Local_Insert_Sans_Hint is
new Element_Keys.Generic_Conditional_Insert (Local_Insert_Post);
procedure Local_Insert_With_Hint is
new Element_Keys.Generic_Conditional_Insert_With_Hint
(Local_Insert_Post,
Local_Insert_Sans_Hint);
--------------
-- New_Node --
--------------
function New_Node return Node_Access is
-- The element allocator may need an accessibility check in the case
-- the actual type is class-wide or has access discriminants (see
-- RM 4.8(10.1) and AI12-0035).
pragma Unsuppress (Accessibility_Check);
begin
Node.Element := new Element_Type'(Item); -- OK if fails
Node.Color := Red;
Node.Parent := null;
Node.Right := null;
Node.Left := null;
return Node;
end New_Node;
Hint : Node_Access;
Result : Node_Access;
Inserted : Boolean;
Compare : Boolean;
X : Element_Access := Node.Element;
-- Start of processing for Replace_Element
begin
-- Replace_Element assigns value Item to the element designated by Node,
-- per certain semantic constraints, described as follows.
-- If Item is equivalent to the element, then element is replaced and
-- there's nothing else to do. This is the easy case.
-- If Item is not equivalent, then the node will (possibly) have to move
-- to some other place in the tree. This is slighly more complicated,
-- because we must ensure that Item is not equivalent to some other
-- element in the tree (in which case, the replacement is not allowed).
-- Determine whether Item is equivalent to element on the specified
-- node.
declare
Lock : With_Lock (Tree.TC'Unrestricted_Access);
begin
Compare := (if Item < Node.Element.all then False
elsif Node.Element.all < Item then False
else True);
end;
if Compare then
-- Item is equivalent to the node's element, so we will not have to
-- move the node.
TE_Check (Tree.TC);
declare
-- The element allocator may need an accessibility check in the
-- case the actual type is class-wide or has access discriminants
-- (see RM 4.8(10.1) and AI12-0035).
pragma Unsuppress (Accessibility_Check);
begin
Node.Element := new Element_Type'(Item);
Free_Element (X);
end;
return;
end if;
-- The replacement Item is not equivalent to the element on the
-- specified node, which means that it will need to be re-inserted in a
-- different position in the tree. We must now determine whether Item is
-- equivalent to some other element in the tree (which would prohibit
-- the assignment and hence the move).
-- Ceiling returns the smallest element equivalent or greater than the
-- specified Item; if there is no such element, then it returns null.
Hint := Element_Keys.Ceiling (Tree, Item);
if Hint /= null then
declare
Lock : With_Lock (Tree.TC'Unrestricted_Access);
begin
Compare := Item < Hint.Element.all;
end;
-- Item >= Hint.Element
if Checks and then not Compare then
-- Ceiling returns an element that is equivalent or greater
-- than Item. If Item is "not less than" the element, then
-- by elimination we know that Item is equivalent to the element.
-- But this means that it is not possible to assign the value of
-- Item to the specified element (on Node), because a different
-- element (on Hint) equivalent to Item already exsits. (Were we
-- to change Node's element value, we would have to move Node, but
-- we would be unable to move the Node, because its new position
-- in the tree is already occupied by an equivalent element.)
raise Program_Error with "attempt to replace existing element";
end if;
-- Item is not equivalent to any other element in the tree, so it is
-- safe to assign the value of Item to Node.Element. This means that
-- the node will have to move to a different position in the tree
-- (because its element will have a different value).
-- The nearest (greater) neighbor of Item is Hint. This will be the
-- insertion position of Node (because its element will have Item as
-- its new value).
-- If Node equals Hint, the relative position of Node does not
-- change. This allows us to perform an optimization: we need not
-- remove Node from the tree and then reinsert it with its new value,
-- because it would only be placed in the exact same position.
if Hint = Node then
TE_Check (Tree.TC);
declare
-- The element allocator may need an accessibility check in the
-- case actual type is class-wide or has access discriminants
-- (see RM 4.8(10.1) and AI12-0035).
pragma Unsuppress (Accessibility_Check);
begin
Node.Element := new Element_Type'(Item);
Free_Element (X);
end;
return;
end if;
end if;
-- If we get here, it is because Item was greater than all elements in
-- the tree (Hint = null), or because Item was less than some element at
-- a different place in the tree (Item < Hint.Element.all). In either
-- case, we remove Node from the tree (without actually deallocating
-- it), and then insert Item into the tree, onto the same Node (so no
-- new node is actually allocated).
Tree_Operations.Delete_Node_Sans_Free (Tree, Node); -- Checks busy-bit
Local_Insert_With_Hint
(Tree => Tree,
Position => Hint,
Key => Item,
Node => Result,
Inserted => Inserted);
pragma Assert (Inserted);
pragma Assert (Result = Node);
Free_Element (X);
end Replace_Element;
procedure Replace_Element
(Container : in out Set;
Position : Cursor;
New_Item : Element_Type)
is
begin
if Checks and then Position.Node = null then
raise Constraint_Error with "Position cursor equals No_Element";
end if;
if Checks and then Position.Node.Element = null then
raise Program_Error with "Position cursor is bad";
end if;
if Checks and then Position.Container /= Container'Unrestricted_Access
then
raise Program_Error with "Position cursor designates wrong set";
end if;
pragma Assert (Vet (Container.Tree, Position.Node),
"bad cursor in Replace_Element");
Replace_Element (Container.Tree, Position.Node, New_Item);
end Replace_Element;
---------------------
-- Reverse_Iterate --
---------------------
procedure Reverse_Iterate
(Container : Set;
Process : not null access procedure (Position : Cursor))
is
procedure Process_Node (Node : Node_Access);
pragma Inline (Process_Node);
procedure Local_Reverse_Iterate is
new Tree_Operations.Generic_Reverse_Iteration (Process_Node);
------------------
-- Process_Node --
------------------
procedure Process_Node (Node : Node_Access) is
begin
Process (Cursor'(Container'Unrestricted_Access, Node));
end Process_Node;
T : Tree_Type renames Container.Tree'Unrestricted_Access.all;
Busy : With_Busy (T.TC'Unrestricted_Access);
-- Start of processing for Reverse_Iterate
begin
Local_Reverse_Iterate (T);
end Reverse_Iterate;
-----------
-- Right --
-----------
function Right (Node : Node_Access) return Node_Access is
begin
return Node.Right;
end Right;
---------------
-- Set_Color --
---------------
procedure Set_Color (Node : Node_Access; Color : Color_Type) is
begin
Node.Color := Color;
end Set_Color;
--------------
-- Set_Left --
--------------
procedure Set_Left (Node : Node_Access; Left : Node_Access) is
begin
Node.Left := Left;
end Set_Left;
----------------
-- Set_Parent --
----------------
procedure Set_Parent (Node : Node_Access; Parent : Node_Access) is
begin
Node.Parent := Parent;
end Set_Parent;
---------------
-- Set_Right --
---------------
procedure Set_Right (Node : Node_Access; Right : Node_Access) is
begin
Node.Right := Right;
end Set_Right;
--------------------------
-- Symmetric_Difference --
--------------------------
procedure Symmetric_Difference (Target : in out Set; Source : Set) is
begin
Set_Ops.Symmetric_Difference (Target.Tree, Source.Tree);
end Symmetric_Difference;
function Symmetric_Difference (Left, Right : Set) return Set is
Tree : constant Tree_Type :=
Set_Ops.Symmetric_Difference (Left.Tree, Right.Tree);
begin
return Set'(Controlled with Tree);
end Symmetric_Difference;
------------
-- To_Set --
------------
function To_Set (New_Item : Element_Type) return Set is
Tree : Tree_Type;
Node : Node_Access;
Inserted : Boolean;
begin
Insert_Sans_Hint (Tree, New_Item, Node, Inserted);
return Set'(Controlled with Tree);
end To_Set;
-----------
-- Union --
-----------
procedure Union (Target : in out Set; Source : Set) is
begin
Set_Ops.Union (Target.Tree, Source.Tree);
end Union;
function Union (Left, Right : Set) return Set is
Tree : constant Tree_Type := Set_Ops.Union (Left.Tree, Right.Tree);
begin
return Set'(Controlled with Tree);
end Union;
-----------
-- Write --
-----------
procedure Write
(Stream : not null access Root_Stream_Type'Class;
Container : Set)
is
procedure Write_Node
(Stream : not null access Root_Stream_Type'Class;
Node : Node_Access);
pragma Inline (Write_Node);
procedure Write is
new Tree_Operations.Generic_Write (Write_Node);
----------------
-- Write_Node --
----------------
procedure Write_Node
(Stream : not null access Root_Stream_Type'Class;
Node : Node_Access)
is
begin
Element_Type'Output (Stream, Node.Element.all);
end Write_Node;
-- Start of processing for Write
begin
Write (Stream, Container.Tree);
end Write;
procedure Write
(Stream : not null access Root_Stream_Type'Class;
Item : Cursor)
is
begin
raise Program_Error with "attempt to stream set cursor";
end Write;
procedure Write
(Stream : not null access Root_Stream_Type'Class;
Item : Constant_Reference_Type)
is
begin
raise Program_Error with "attempt to stream reference";
end Write;
end Ada.Containers.Indefinite_Ordered_Sets;
|
sungyeon/drake | Ada | 48,997 | adb | -- ***************************************************************************
--
-- This implementation violates some ACATS intentionally.
--
-- Violated ACATS Tests: CE3106A, CE3106B, CE3406C
--
-- These test requires End_Of_Page/File looking over the line/page terminater.
-- But this behavior discards last line in file.
--
-- Violated ACATS Tests: CE3402C, CE3405A, CE3405D, CE3410C, CE3606A, CE3606B
--
-- With the same reason, CHECK_FILE fails at CHECK_END_OF_PAGE.
--
-- Look discussions on comp.lang.ada.
-- http://groups.google.com/group/comp.lang.ada/browse_frm/thread/
-- 5afe598156615c8b/f690474efabf7a93#f690474efabf7a93
-- http://groups.google.com/group/comp.lang.ada/browse_frm/thread/
-- 68cd50941308f5a9/5d2b3f163916189c#5d2b3f163916189c
--
-- ***************************************************************************
pragma Check_Policy (Trace => Ignore);
with Ada.Exception_Identification.From_Here;
with Ada.Exceptions.Finally;
with Ada.Streams.Naked_Stream_IO;
with Ada.Unchecked_Conversion;
with System.Unwind.Occurrences;
package body Ada.Text_IO is
use Exception_Identification.From_Here;
function To_File_Access is
new Unchecked_Conversion (Controlled.File_Access, File_Access);
function To_Controlled_File_Access is
new Unchecked_Conversion (File_Access, Controlled.File_Access);
procedure Flush_IO;
procedure Flush_IO is
begin
Streams.Naked_Stream_IO.Flush_Writing_Buffer (
Naked_Text_IO.Stream_IO (Naked_Text_IO.Standard_Output).all,
Raise_On_Error => False);
Streams.Naked_Stream_IO.Flush_Writing_Buffer (
Naked_Text_IO.Stream_IO (Naked_Text_IO.Standard_Error).all,
Raise_On_Error => False);
end Flush_IO;
procedure Reallocate is
new Unchecked_Reallocation (
Positive,
Wide_Character,
Wide_String,
Wide_String_Access);
procedure Reallocate is
new Unchecked_Reallocation (
Positive,
Wide_Wide_Character,
Wide_Wide_String,
Wide_Wide_String_Access);
procedure Raw_Get_Line (
File : File_Type; -- Input_File_Type
Item : aliased out String_Access;
Last : out Natural);
procedure Raw_Get_Line (
File : File_Type;
Item : aliased out String_Access;
Last : out Natural) is
begin
Item := new String (1 .. 256);
Last := 0;
loop
Overloaded_Get_Line (
File, -- checking the predicate
Item (Last + 1 .. Item'Last),
Last);
exit when Last < Item'Last;
Reallocate (Item, 1, String_Grow (Item'Last));
end loop;
end Raw_Get_Line;
procedure Raw_Get_Line (
File : File_Type; -- Input_File_Type
Item : aliased out Wide_String_Access;
Last : out Natural);
procedure Raw_Get_Line (
File : File_Type;
Item : aliased out Wide_String_Access;
Last : out Natural) is
begin
Item := new Wide_String (1 .. 256);
Last := 0;
loop
Overloaded_Get_Line (
File, -- checking the predicate
Item (Last + 1 .. Item'Last),
Last);
exit when Last < Item'Last;
Reallocate (Item, 1, Wide_String_Grow (Item'Last));
end loop;
end Raw_Get_Line;
procedure Raw_Get_Line (
File : File_Type; -- Input_File_Type
Item : aliased out Wide_Wide_String_Access;
Last : out Natural);
procedure Raw_Get_Line (
File : File_Type;
Item : aliased out Wide_Wide_String_Access;
Last : out Natural) is
begin
Item := new Wide_Wide_String (1 .. 256);
Last := 0;
loop
Overloaded_Get_Line (
File, -- checking the predicate
Item (Last + 1 .. Item'Last),
Last);
exit when Last < Item'Last;
Reallocate (Item, 1, Wide_Wide_String_Grow (Item'Last));
end loop;
end Raw_Get_Line;
-- implementation of File Management
procedure Create (
File : in out File_Type;
Mode : File_Mode := Out_File;
Name : String := "";
Form : String)
is
NC_File : Naked_Text_IO.Non_Controlled_File_Type
renames Controlled.Reference (File).all;
begin
Naked_Text_IO.Create (
NC_File,
IO_Modes.File_Mode (Mode),
Name => Name,
Form => Naked_Text_IO.Pack (Form));
end Create;
procedure Create (
File : in out File_Type;
Mode : File_Mode := Out_File;
Name : String := "";
Shared : IO_Modes.File_Shared_Spec := IO_Modes.By_Mode;
Wait : Boolean := False;
Overwrite : Boolean := True;
External : IO_Modes.File_External_Spec := IO_Modes.By_Target;
New_Line : IO_Modes.File_New_Line_Spec := IO_Modes.By_Target)
is
NC_File : Naked_Text_IO.Non_Controlled_File_Type
renames Controlled.Reference (File).all;
begin
Naked_Text_IO.Create (
NC_File,
IO_Modes.File_Mode (Mode),
Name => Name,
Form => ((Shared, Wait, Overwrite), External, New_Line));
end Create;
function Create (
Mode : File_Mode := Out_File;
Name : String := "";
Shared : IO_Modes.File_Shared_Spec := IO_Modes.By_Mode;
Wait : Boolean := False;
Overwrite : Boolean := True;
External : IO_Modes.File_External_Spec := IO_Modes.By_Target;
New_Line : IO_Modes.File_New_Line_Spec := IO_Modes.By_Target)
return File_Type is
begin
return Result : File_Type do
declare
NC_Result : Naked_Text_IO.Non_Controlled_File_Type
renames Controlled.Reference (Result).all;
begin
Naked_Text_IO.Create (
NC_Result,
IO_Modes.File_Mode (Mode),
Name => Name,
Form => ((Shared, Wait, Overwrite), External, New_Line));
end;
end return;
end Create;
procedure Open (
File : in out File_Type;
Mode : File_Mode;
Name : String;
Form : String)
is
NC_File : Naked_Text_IO.Non_Controlled_File_Type
renames Controlled.Reference (File).all;
begin
Naked_Text_IO.Open (
NC_File,
IO_Modes.File_Mode (Mode),
Name => Name,
Form => Naked_Text_IO.Pack (Form));
end Open;
procedure Open (
File : in out File_Type;
Mode : File_Mode;
Name : String;
Shared : IO_Modes.File_Shared_Spec := IO_Modes.By_Mode;
Wait : Boolean := False;
Overwrite : Boolean := True;
External : IO_Modes.File_External_Spec := IO_Modes.By_Target;
New_Line : IO_Modes.File_New_Line_Spec := IO_Modes.By_Target)
is
NC_File : Naked_Text_IO.Non_Controlled_File_Type
renames Controlled.Reference (File).all;
begin
Naked_Text_IO.Open (
NC_File,
IO_Modes.File_Mode (Mode),
Name => Name,
Form => ((Shared, Wait, Overwrite), External, New_Line));
end Open;
function Open (
Mode : File_Mode;
Name : String;
Shared : IO_Modes.File_Shared_Spec := IO_Modes.By_Mode;
Wait : Boolean := False;
Overwrite : Boolean := True;
External : IO_Modes.File_External_Spec := IO_Modes.By_Target;
New_Line : IO_Modes.File_New_Line_Spec := IO_Modes.By_Target)
return File_Type is
begin
return Result : File_Type do
declare
NC_Result : Naked_Text_IO.Non_Controlled_File_Type
renames Controlled.Reference (Result).all;
begin
Naked_Text_IO.Open (
NC_Result,
IO_Modes.File_Mode (Mode),
Name => Name,
Form => ((Shared, Wait, Overwrite), External, New_Line));
end;
end return;
end Open;
procedure Close (File : in out File_Type) is
NC_File : Naked_Text_IO.Non_Controlled_File_Type
renames Controlled.Reference (File).all;
begin
Naked_Text_IO.Close (NC_File, Raise_On_Error => True);
end Close;
procedure Delete (File : in out File_Type) is
NC_File : Naked_Text_IO.Non_Controlled_File_Type
renames Controlled.Reference (File).all;
begin
Naked_Text_IO.Delete (NC_File);
end Delete;
procedure Reset (File : in out File_Type; Mode : File_Mode) is
pragma Check (Pre,
Check =>
(File'Unrestricted_Access /= Current_Input
and then File'Unrestricted_Access /= Current_Output
and then File'Unrestricted_Access /= Current_Error)
or else Text_IO.Mode (File) = Mode
or else raise Mode_Error);
NC_File : Naked_Text_IO.Non_Controlled_File_Type
renames Controlled.Reference (File).all;
begin
Naked_Text_IO.Reset (NC_File, IO_Modes.File_Mode (Mode));
end Reset;
procedure Reset (File : in out File_Type) is
begin
Reset (File, Mode (File));
end Reset;
function Mode (
File : File_Type)
return File_Mode
is
pragma Check (Dynamic_Predicate,
Check => Is_Open (File) or else raise Status_Error);
NC_File : Naked_Text_IO.Non_Controlled_File_Type
renames Controlled.Reference (File).all;
begin
return File_Mode (Naked_Text_IO.Mode (NC_File));
end Mode;
function Name (
File : File_Type)
return String
is
pragma Check (Dynamic_Predicate,
Check => Is_Open (File) or else raise Status_Error);
NC_File : Naked_Text_IO.Non_Controlled_File_Type
renames Controlled.Reference (File).all;
begin
return Naked_Text_IO.Name (NC_File);
end Name;
function Name (File : not null File_Access) return String is
begin
return Name (File.all);
end Name;
function Form (
File : File_Type)
return String
is
pragma Check (Dynamic_Predicate,
Check => Is_Open (File) or else raise Status_Error);
NC_File : Naked_Text_IO.Non_Controlled_File_Type
renames Controlled.Reference (File).all;
Result : Streams.Naked_Stream_IO.Form_String;
Last : Natural;
begin
Naked_Text_IO.Unpack (
Naked_Text_IO.Form (NC_File),
Result,
Last);
return Result (Result'First .. Last);
end Form;
function Is_Open (File : File_Type) return Boolean is
NC_File : Naked_Text_IO.Non_Controlled_File_Type
renames Controlled.Reference (File).all;
begin
return Naked_Text_IO.Is_Open (NC_File);
end Is_Open;
function Is_Open (File : not null File_Access) return Boolean is
begin
return Is_Open (File.all);
end Is_Open;
-- implementation of Control of default input and output files
procedure Set_Input (File : File_Type) is
begin
Set_Input (File'Unrestricted_Access);
end Set_Input;
procedure Set_Input (File : not null File_Access) is
pragma Check (Pre,
Check => Mode (File.all) = In_File or else raise Mode_Error);
begin
Controlled.Reference_Current_Input.all :=
To_Controlled_File_Access (File);
end Set_Input;
procedure Set_Output (File : File_Type) is
begin
Set_Output (File'Unrestricted_Access);
end Set_Output;
procedure Set_Output (File : not null File_Access) is
pragma Check (Pre,
Check => Mode (File.all) /= In_File or else raise Mode_Error);
begin
Controlled.Reference_Current_Output.all :=
To_Controlled_File_Access (File);
end Set_Output;
procedure Set_Error (File : File_Type) is
begin
Set_Error (File'Unrestricted_Access);
end Set_Error;
procedure Set_Error (File : not null File_Access) is
pragma Check (Pre,
Check => Mode (File.all) /= In_File or else raise Mode_Error);
begin
Controlled.Reference_Current_Error.all :=
To_Controlled_File_Access (File);
end Set_Error;
function Standard_Input return File_Access is
begin
return To_File_Access (Controlled.Standard_Input);
end Standard_Input;
function Standard_Output return File_Access is
begin
return To_File_Access (Controlled.Standard_Output);
end Standard_Output;
function Standard_Error return File_Access is
begin
return To_File_Access (Controlled.Standard_Error);
end Standard_Error;
function Current_Input return File_Access is
begin
return To_File_Access (Controlled.Reference_Current_Input.all);
end Current_Input;
function Current_Output return File_Access is
begin
return To_File_Access (Controlled.Reference_Current_Output.all);
end Current_Output;
function Current_Error return File_Access is
begin
return To_File_Access (Controlled.Reference_Current_Error.all);
end Current_Error;
-- implementation of Buffer control
procedure Flush (
File : File_Type)
is
pragma Check (Dynamic_Predicate,
Check => Is_Open (File) or else raise Status_Error);
pragma Check (Dynamic_Predicate,
Check => Mode (File) /= In_File or else raise Mode_Error);
NC_File : Naked_Text_IO.Non_Controlled_File_Type
renames Controlled.Reference (File).all;
begin
Naked_Text_IO.Flush (NC_File);
end Flush;
procedure Flush is
begin
Flush (Current_Output.all);
end Flush;
-- implementation of Specification of line and page lengths
procedure Set_Line_Length (
File : File_Type;
To : Count)
is
pragma Check (Dynamic_Predicate,
Check => Is_Open (File) or else raise Status_Error);
pragma Check (Dynamic_Predicate,
Check => Mode (File) /= In_File or else raise Mode_Error);
NC_File : Naked_Text_IO.Non_Controlled_File_Type
renames Controlled.Reference (File).all;
begin
Naked_Text_IO.Set_Line_Length (NC_File, Integer (To));
end Set_Line_Length;
procedure Set_Line_Length (To : Count) is
begin
Set_Line_Length (Current_Output.all, To);
end Set_Line_Length;
procedure Set_Line_Length (File : not null File_Access; To : Count) is
begin
Set_Line_Length (File.all, To);
end Set_Line_Length;
procedure Set_Page_Length (
File : File_Type;
To : Count)
is
pragma Check (Dynamic_Predicate,
Check => Is_Open (File) or else raise Status_Error);
pragma Check (Dynamic_Predicate,
Check => Mode (File) /= In_File or else raise Mode_Error);
NC_File : Naked_Text_IO.Non_Controlled_File_Type
renames Controlled.Reference (File).all;
begin
Naked_Text_IO.Set_Page_Length (NC_File, Integer (To));
end Set_Page_Length;
procedure Set_Page_Length (To : Count) is
begin
Set_Page_Length (Current_Output.all, To);
end Set_Page_Length;
procedure Set_Page_Length (File : not null File_Access; To : Count) is
begin
Set_Page_Length (File.all, To);
end Set_Page_Length;
function Line_Length (
File : File_Type)
return Count
is
pragma Check (Dynamic_Predicate,
Check => Is_Open (File) or else raise Status_Error);
pragma Check (Dynamic_Predicate,
Check => Mode (File) /= In_File or else raise Mode_Error);
NC_File : Naked_Text_IO.Non_Controlled_File_Type
renames Controlled.Reference (File).all;
begin
return Count (Naked_Text_IO.Line_Length (NC_File));
end Line_Length;
function Line_Length return Count is
begin
return Line_Length (Current_Output.all);
end Line_Length;
function Page_Length (
File : File_Type)
return Count
is
pragma Check (Dynamic_Predicate,
Check => Is_Open (File) or else raise Status_Error);
pragma Check (Dynamic_Predicate,
Check => Mode (File) /= In_File or else raise Mode_Error);
NC_File : Naked_Text_IO.Non_Controlled_File_Type
renames Controlled.Reference (File).all;
begin
return Count (Naked_Text_IO.Page_Length (NC_File));
end Page_Length;
function Page_Length return Count is
begin
return Page_Length (Current_Output.all);
end Page_Length;
-- implementation of Column, Line, and Page Control
procedure New_Line (
File : File_Type;
Spacing : Positive_Count := 1)
is
pragma Check (Dynamic_Predicate,
Check => Is_Open (File) or else raise Status_Error);
pragma Check (Dynamic_Predicate,
Check => Mode (File) /= In_File or else raise Mode_Error);
NC_File : Naked_Text_IO.Non_Controlled_File_Type
renames Controlled.Reference (File).all;
begin
Naked_Text_IO.New_Line (NC_File, Integer (Spacing));
end New_Line;
procedure New_Line (Spacing : Positive_Count := 1) is
begin
New_Line (Current_Output.all, Spacing);
end New_Line;
procedure New_Line (
File : not null File_Access;
Spacing : Positive_Count := 1) is
begin
New_Line (File.all, Spacing);
end New_Line;
procedure Skip_Line (
File : File_Type;
Spacing : Positive_Count := 1)
is
pragma Check (Dynamic_Predicate,
Check => Is_Open (File) or else raise Status_Error);
pragma Check (Dynamic_Predicate,
Check => Mode (File) = In_File or else raise Mode_Error);
NC_File : Naked_Text_IO.Non_Controlled_File_Type
renames Controlled.Reference (File).all;
begin
Naked_Text_IO.Skip_Line (NC_File, Integer (Spacing));
end Skip_Line;
procedure Skip_Line (Spacing : Positive_Count := 1) is
begin
Skip_Line (Current_Input.all, Spacing);
end Skip_Line;
procedure Skip_Line (
File : not null File_Access;
Spacing : Positive_Count := 1) is
begin
Skip_Line (File.all, Spacing);
end Skip_Line;
function End_Of_Line (
File : File_Type)
return Boolean
is
pragma Check (Dynamic_Predicate,
Check => Is_Open (File) or else raise Status_Error);
pragma Check (Dynamic_Predicate,
Check => Mode (File) = In_File or else raise Mode_Error);
NC_File : Naked_Text_IO.Non_Controlled_File_Type
renames Controlled.Reference (File).all;
begin
return Naked_Text_IO.End_Of_Line (NC_File);
end End_Of_Line;
function End_Of_Line return Boolean is
begin
return End_Of_Line (Current_Input.all);
end End_Of_Line;
procedure New_Page (
File : File_Type)
is
pragma Check (Dynamic_Predicate,
Check => Is_Open (File) or else raise Status_Error);
pragma Check (Dynamic_Predicate,
Check => Mode (File) /= In_File or else raise Mode_Error);
NC_File : Naked_Text_IO.Non_Controlled_File_Type
renames Controlled.Reference (File).all;
begin
Naked_Text_IO.New_Page (NC_File);
end New_Page;
procedure New_Page is
begin
New_Page (Current_Output.all);
end New_Page;
procedure New_Page (File : not null File_Access) is
begin
New_Page (File.all);
end New_Page;
procedure Skip_Page (
File : File_Type)
is
pragma Check (Dynamic_Predicate,
Check => Is_Open (File) or else raise Status_Error);
pragma Check (Dynamic_Predicate,
Check => Mode (File) = In_File or else raise Mode_Error);
NC_File : Naked_Text_IO.Non_Controlled_File_Type
renames Controlled.Reference (File).all;
begin
Naked_Text_IO.Skip_Page (NC_File);
end Skip_Page;
procedure Skip_Page is
begin
Skip_Page (Current_Input.all);
end Skip_Page;
procedure Skip_Page (File : not null File_Access) is
begin
Skip_Page (File.all);
end Skip_Page;
function End_Of_Page (
File : File_Type)
return Boolean
is
pragma Check (Dynamic_Predicate,
Check => Is_Open (File) or else raise Status_Error);
pragma Check (Dynamic_Predicate,
Check => Mode (File) = In_File or else raise Mode_Error);
NC_File : Naked_Text_IO.Non_Controlled_File_Type
renames Controlled.Reference (File).all;
begin
return Naked_Text_IO.End_Of_Page (NC_File);
end End_Of_Page;
function End_Of_Page return Boolean is
begin
return End_Of_Page (Current_Input.all);
end End_Of_Page;
function End_Of_Page (File : not null File_Access) return Boolean is
begin
return End_Of_Page (File.all);
end End_Of_Page;
function End_Of_File (
File : File_Type)
return Boolean
is
pragma Check (Dynamic_Predicate,
Check => Is_Open (File) or else raise Status_Error);
pragma Check (Dynamic_Predicate,
Check => Mode (File) = In_File or else raise Mode_Error);
NC_File : Naked_Text_IO.Non_Controlled_File_Type
renames Controlled.Reference (File).all;
begin
return Naked_Text_IO.End_Of_File (NC_File);
end End_Of_File;
function End_Of_File return Boolean is
begin
return End_Of_File (Current_Input.all);
end End_Of_File;
function End_Of_File (File : not null File_Access) return Boolean is
begin
return End_Of_File (File.all);
end End_Of_File;
procedure Set_Col (
File : File_Type;
To : Positive_Count)
is
pragma Check (Dynamic_Predicate,
Check => Is_Open (File) or else raise Status_Error);
NC_File : Naked_Text_IO.Non_Controlled_File_Type
renames Controlled.Reference (File).all;
begin
Naked_Text_IO.Set_Col (NC_File, Integer (To));
end Set_Col;
procedure Set_Col (To : Positive_Count) is
begin
Set_Col (Current_Output.all, To);
end Set_Col;
procedure Set_Col (File : not null File_Access; To : Positive_Count) is
begin
Set_Col (File.all, To);
end Set_Col;
procedure Set_Line (
File : File_Type;
To : Positive_Count)
is
pragma Check (Dynamic_Predicate,
Check => Is_Open (File) or else raise Status_Error);
NC_File : Naked_Text_IO.Non_Controlled_File_Type
renames Controlled.Reference (File).all;
begin
Naked_Text_IO.Set_Line (NC_File, Integer (To));
end Set_Line;
procedure Set_Line (To : Positive_Count) is
begin
Set_Line (Current_Output.all, To);
end Set_Line;
procedure Set_Line (File : not null File_Access; To : Positive_Count) is
begin
Set_Line (File.all, To);
end Set_Line;
function Col (
File : File_Type)
return Positive_Count
is
pragma Check (Dynamic_Predicate,
Check => Is_Open (File) or else raise Status_Error);
NC_File : Naked_Text_IO.Non_Controlled_File_Type
renames Controlled.Reference (File).all;
begin
return Count (Naked_Text_IO.Col (NC_File));
end Col;
function Col return Positive_Count is
begin
return Col (Current_Output.all);
end Col;
function Col (File : not null File_Access) return Positive_Count is
begin
return Col (File.all);
end Col;
function Line (
File : File_Type)
return Positive_Count
is
pragma Check (Dynamic_Predicate,
Check => Is_Open (File) or else raise Status_Error);
NC_File : Naked_Text_IO.Non_Controlled_File_Type
renames Controlled.Reference (File).all;
begin
return Count (Naked_Text_IO.Line (NC_File));
end Line;
function Line return Positive_Count is
begin
return Line (Current_Output.all);
end Line;
function Line (File : not null File_Access) return Positive_Count is
begin
return Line (File.all);
end Line;
function Page (
File : File_Type)
return Positive_Count
is
pragma Check (Dynamic_Predicate,
Check => Is_Open (File) or else raise Status_Error);
NC_File : Naked_Text_IO.Non_Controlled_File_Type
renames Controlled.Reference (File).all;
begin
return Count (Naked_Text_IO.Page (NC_File));
end Page;
function Page return Positive_Count is
begin
return Page (Current_Output.all);
end Page;
function Page (File : not null File_Access) return Positive_Count is
begin
return Page (File.all);
end Page;
-- implementation of Character Input-Output
procedure Overloaded_Get (
File : File_Type;
Item : out Character)
is
pragma Check (Dynamic_Predicate,
Check => Is_Open (File) or else raise Status_Error);
pragma Check (Dynamic_Predicate,
Check => Mode (File) = In_File or else raise Mode_Error);
NC_File : Naked_Text_IO.Non_Controlled_File_Type
renames Controlled.Reference (File).all;
begin
Naked_Text_IO.Get (NC_File, Item);
end Overloaded_Get;
procedure Overloaded_Get (
File : File_Type;
Item : out Wide_Character)
is
pragma Check (Dynamic_Predicate,
Check => Is_Open (File) or else raise Status_Error);
pragma Check (Dynamic_Predicate,
Check => Mode (File) = In_File or else raise Mode_Error);
NC_File : Naked_Text_IO.Non_Controlled_File_Type
renames Controlled.Reference (File).all;
begin
Naked_Text_IO.Get (NC_File, Item);
end Overloaded_Get;
procedure Overloaded_Get (
File : File_Type;
Item : out Wide_Wide_Character)
is
pragma Check (Dynamic_Predicate,
Check => Is_Open (File) or else raise Status_Error);
pragma Check (Dynamic_Predicate,
Check => Mode (File) = In_File or else raise Mode_Error);
NC_File : Naked_Text_IO.Non_Controlled_File_Type
renames Controlled.Reference (File).all;
begin
Naked_Text_IO.Get (NC_File, Item);
end Overloaded_Get;
procedure Overloaded_Get (Item : out Character) is
begin
Overloaded_Get (Current_Input.all, Item);
end Overloaded_Get;
procedure Overloaded_Get (Item : out Wide_Character) is
begin
Overloaded_Get (Current_Input.all, Item);
end Overloaded_Get;
procedure Overloaded_Get (Item : out Wide_Wide_Character) is
begin
Overloaded_Get (Current_Input.all, Item);
end Overloaded_Get;
procedure Get (File : not null File_Access; Item : out Character) is
begin
Get (File.all, Item);
end Get;
procedure Overloaded_Put (
File : File_Type;
Item : Character)
is
pragma Check (Dynamic_Predicate,
Check => Is_Open (File) or else raise Status_Error);
pragma Check (Dynamic_Predicate,
Check => Mode (File) /= In_File or else raise Mode_Error);
NC_File : Naked_Text_IO.Non_Controlled_File_Type
renames Controlled.Reference (File).all;
begin
Naked_Text_IO.Put (NC_File, Item);
end Overloaded_Put;
procedure Overloaded_Put (
File : File_Type;
Item : Wide_Character)
is
pragma Check (Dynamic_Predicate,
Check => Is_Open (File) or else raise Status_Error);
pragma Check (Dynamic_Predicate,
Check => Mode (File) /= In_File or else raise Mode_Error);
NC_File : Naked_Text_IO.Non_Controlled_File_Type
renames Controlled.Reference (File).all;
begin
Naked_Text_IO.Put (NC_File, Item);
end Overloaded_Put;
procedure Overloaded_Put (
File : File_Type;
Item : Wide_Wide_Character)
is
pragma Check (Dynamic_Predicate,
Check => Is_Open (File) or else raise Status_Error);
pragma Check (Dynamic_Predicate,
Check => Mode (File) /= In_File or else raise Mode_Error);
NC_File : Naked_Text_IO.Non_Controlled_File_Type
renames Controlled.Reference (File).all;
begin
Naked_Text_IO.Put (NC_File, Item);
end Overloaded_Put;
procedure Overloaded_Put (Item : Character) is
begin
Overloaded_Put (Current_Output.all, Item);
end Overloaded_Put;
procedure Overloaded_Put (Item : Wide_Character) is
begin
Overloaded_Put (Current_Output.all, Item);
end Overloaded_Put;
procedure Overloaded_Put (Item : Wide_Wide_Character) is
begin
Overloaded_Put (Current_Output.all, Item);
end Overloaded_Put;
procedure Put (File : not null File_Access; Item : Character) is
begin
Put (File.all, Item);
end Put;
procedure Overloaded_Look_Ahead (
File : File_Type;
Item : out Character;
End_Of_Line : out Boolean)
is
pragma Check (Dynamic_Predicate,
Check => Is_Open (File) or else raise Status_Error);
pragma Check (Dynamic_Predicate,
Check => Mode (File) = In_File or else raise Mode_Error);
NC_File : Naked_Text_IO.Non_Controlled_File_Type
renames Controlled.Reference (File).all;
begin
Naked_Text_IO.Look_Ahead (NC_File, Item, End_Of_Line);
end Overloaded_Look_Ahead;
procedure Overloaded_Look_Ahead (
File : File_Type;
Item : out Wide_Character;
End_Of_Line : out Boolean)
is
pragma Check (Dynamic_Predicate,
Check => Is_Open (File) or else raise Status_Error);
pragma Check (Dynamic_Predicate,
Check => Mode (File) = In_File or else raise Mode_Error);
NC_File : Naked_Text_IO.Non_Controlled_File_Type
renames Controlled.Reference (File).all;
begin
Naked_Text_IO.Look_Ahead (NC_File, Item, End_Of_Line);
end Overloaded_Look_Ahead;
procedure Overloaded_Look_Ahead (
File : File_Type;
Item : out Wide_Wide_Character;
End_Of_Line : out Boolean)
is
pragma Check (Dynamic_Predicate,
Check => Is_Open (File) or else raise Status_Error);
pragma Check (Dynamic_Predicate,
Check => Mode (File) = In_File or else raise Mode_Error);
NC_File : Naked_Text_IO.Non_Controlled_File_Type
renames Controlled.Reference (File).all;
begin
Naked_Text_IO.Look_Ahead (NC_File, Item, End_Of_Line);
end Overloaded_Look_Ahead;
procedure Overloaded_Look_Ahead (
Item : out Character;
End_Of_Line : out Boolean) is
begin
Overloaded_Look_Ahead (Current_Input.all, Item, End_Of_Line);
end Overloaded_Look_Ahead;
procedure Overloaded_Look_Ahead (
Item : out Wide_Character;
End_Of_Line : out Boolean) is
begin
Overloaded_Look_Ahead (Current_Input.all, Item, End_Of_Line);
end Overloaded_Look_Ahead;
procedure Overloaded_Look_Ahead (
Item : out Wide_Wide_Character;
End_Of_Line : out Boolean) is
begin
Overloaded_Look_Ahead (Current_Input.all, Item, End_Of_Line);
end Overloaded_Look_Ahead;
procedure Skip_Ahead (
File : File_Type)
is
pragma Check (Dynamic_Predicate,
Check => Is_Open (File) or else raise Status_Error);
pragma Check (Dynamic_Predicate,
Check => Mode (File) = In_File or else raise Mode_Error);
NC_File : Naked_Text_IO.Non_Controlled_File_Type
renames Controlled.Reference (File).all;
begin
Naked_Text_IO.Skip_Ahead (NC_File);
end Skip_Ahead;
procedure Overloaded_Get_Immediate (
File : File_Type;
Item : out Character)
is
pragma Check (Dynamic_Predicate,
Check => Is_Open (File) or else raise Status_Error);
pragma Check (Dynamic_Predicate,
Check => Mode (File) = In_File or else raise Mode_Error);
NC_File : Naked_Text_IO.Non_Controlled_File_Type
renames Controlled.Reference (File).all;
begin
Naked_Text_IO.Get_Immediate (NC_File, Item);
end Overloaded_Get_Immediate;
procedure Overloaded_Get_Immediate (
File : File_Type;
Item : out Wide_Character)
is
pragma Check (Dynamic_Predicate,
Check => Is_Open (File) or else raise Status_Error);
pragma Check (Dynamic_Predicate,
Check => Mode (File) = In_File or else raise Mode_Error);
NC_File : Naked_Text_IO.Non_Controlled_File_Type
renames Controlled.Reference (File).all;
begin
Naked_Text_IO.Get_Immediate (NC_File, Item);
end Overloaded_Get_Immediate;
procedure Overloaded_Get_Immediate (
File : File_Type;
Item : out Wide_Wide_Character)
is
pragma Check (Dynamic_Predicate,
Check => Is_Open (File) or else raise Status_Error);
pragma Check (Dynamic_Predicate,
Check => Mode (File) = In_File or else raise Mode_Error);
NC_File : Naked_Text_IO.Non_Controlled_File_Type
renames Controlled.Reference (File).all;
begin
Naked_Text_IO.Get_Immediate (NC_File, Item);
end Overloaded_Get_Immediate;
procedure Overloaded_Get_Immediate (Item : out Character) is
begin
Overloaded_Get_Immediate (Current_Input.all, Item);
end Overloaded_Get_Immediate;
procedure Overloaded_Get_Immediate (Item : out Wide_Character) is
begin
Overloaded_Get_Immediate (Current_Input.all, Item);
end Overloaded_Get_Immediate;
procedure Overloaded_Get_Immediate (Item : out Wide_Wide_Character) is
begin
Overloaded_Get_Immediate (Current_Input.all, Item);
end Overloaded_Get_Immediate;
procedure Overloaded_Get_Immediate (
File : File_Type;
Item : out Character;
Available : out Boolean)
is
pragma Check (Dynamic_Predicate,
Check => Is_Open (File) or else raise Status_Error);
pragma Check (Dynamic_Predicate,
Check => Mode (File) = In_File or else raise Mode_Error);
NC_File : Naked_Text_IO.Non_Controlled_File_Type
renames Controlled.Reference (File).all;
begin
Naked_Text_IO.Get_Immediate (NC_File, Item, Available);
end Overloaded_Get_Immediate;
procedure Overloaded_Get_Immediate (
File : File_Type;
Item : out Wide_Character;
Available : out Boolean)
is
pragma Check (Dynamic_Predicate,
Check => Is_Open (File) or else raise Status_Error);
pragma Check (Dynamic_Predicate,
Check => Mode (File) = In_File or else raise Mode_Error);
NC_File : Naked_Text_IO.Non_Controlled_File_Type
renames Controlled.Reference (File).all;
begin
Naked_Text_IO.Get_Immediate (NC_File, Item, Available);
end Overloaded_Get_Immediate;
procedure Overloaded_Get_Immediate (
File : File_Type;
Item : out Wide_Wide_Character;
Available : out Boolean)
is
pragma Check (Dynamic_Predicate,
Check => Is_Open (File) or else raise Status_Error);
pragma Check (Dynamic_Predicate,
Check => Mode (File) = In_File or else raise Mode_Error);
NC_File : Naked_Text_IO.Non_Controlled_File_Type
renames Controlled.Reference (File).all;
begin
Naked_Text_IO.Get_Immediate (NC_File, Item, Available);
end Overloaded_Get_Immediate;
procedure Overloaded_Get_Immediate (
Item : out Character;
Available : out Boolean) is
begin
Overloaded_Get_Immediate (Current_Input.all, Item, Available);
end Overloaded_Get_Immediate;
procedure Overloaded_Get_Immediate (
Item : out Wide_Character;
Available : out Boolean) is
begin
Overloaded_Get_Immediate (Current_Input.all, Item, Available);
end Overloaded_Get_Immediate;
procedure Overloaded_Get_Immediate (
Item : out Wide_Wide_Character;
Available : out Boolean) is
begin
Overloaded_Get_Immediate (Current_Input.all, Item, Available);
end Overloaded_Get_Immediate;
-- implementation of String Input-Output
procedure Overloaded_Get (
File : File_Type;
Item : out String)
is
pragma Check (Dynamic_Predicate,
Check => Is_Open (File) or else raise Status_Error);
pragma Check (Dynamic_Predicate,
Check => Mode (File) = In_File or else raise Mode_Error);
begin
for I in Item'Range loop
Overloaded_Get (File, Item (I));
end loop;
end Overloaded_Get;
procedure Overloaded_Get (
File : File_Type;
Item : out Wide_String)
is
pragma Check (Dynamic_Predicate,
Check => Is_Open (File) or else raise Status_Error);
pragma Check (Dynamic_Predicate,
Check => Mode (File) = In_File or else raise Mode_Error);
begin
for I in Item'Range loop
Overloaded_Get (File, Item (I));
end loop;
end Overloaded_Get;
procedure Overloaded_Get (
File : File_Type;
Item : out Wide_Wide_String)
is
pragma Check (Dynamic_Predicate,
Check => Is_Open (File) or else raise Status_Error);
pragma Check (Dynamic_Predicate,
Check => Mode (File) = In_File or else raise Mode_Error);
begin
for I in Item'Range loop
Overloaded_Get (File, Item (I));
end loop;
end Overloaded_Get;
procedure Overloaded_Get (Item : out String) is
begin
Overloaded_Get (Current_Input.all, Item);
end Overloaded_Get;
procedure Overloaded_Get (Item : out Wide_String) is
begin
Overloaded_Get (Current_Input.all, Item);
end Overloaded_Get;
procedure Overloaded_Get (Item : out Wide_Wide_String) is
begin
Overloaded_Get (Current_Input.all, Item);
end Overloaded_Get;
procedure Get (File : not null File_Access; Item : out String) is
begin
Get (File.all, Item);
end Get;
procedure Overloaded_Put (
File : File_Type;
Item : String)
is
pragma Check (Dynamic_Predicate,
Check => Is_Open (File) or else raise Status_Error);
pragma Check (Dynamic_Predicate,
Check => Mode (File) /= In_File or else raise Mode_Error);
begin
for I in Item'Range loop
Overloaded_Put (File, Item (I));
end loop;
end Overloaded_Put;
procedure Overloaded_Put (
File : File_Type;
Item : Wide_String)
is
pragma Check (Dynamic_Predicate,
Check => Is_Open (File) or else raise Status_Error);
pragma Check (Dynamic_Predicate,
Check => Mode (File) /= In_File or else raise Mode_Error);
begin
for I in Item'Range loop
Overloaded_Put (File, Item (I));
end loop;
end Overloaded_Put;
procedure Overloaded_Put (
File : File_Type;
Item : Wide_Wide_String)
is
pragma Check (Dynamic_Predicate,
Check => Is_Open (File) or else raise Status_Error);
pragma Check (Dynamic_Predicate,
Check => Mode (File) /= In_File or else raise Mode_Error);
begin
for I in Item'Range loop
Overloaded_Put (File, Item (I));
end loop;
end Overloaded_Put;
procedure Overloaded_Put (Item : String) is
begin
Overloaded_Put (Current_Output.all, Item);
end Overloaded_Put;
procedure Overloaded_Put (Item : Wide_String) is
begin
Overloaded_Put (Current_Output.all, Item);
end Overloaded_Put;
procedure Overloaded_Put (Item : Wide_Wide_String) is
begin
Overloaded_Put (Current_Output.all, Item);
end Overloaded_Put;
procedure Put (File : not null File_Access; Item : String) is
begin
Put (File.all, Item);
end Put;
procedure Overloaded_Get_Line (
File : File_Type;
Item : out String;
Last : out Natural)
is
pragma Check (Dynamic_Predicate,
Check => Is_Open (File) or else raise Status_Error);
pragma Check (Dynamic_Predicate,
Check => Mode (File) = In_File or else raise Mode_Error);
begin
Last := Item'First - 1;
if Item'Length > 0 then
if End_Of_File (File) then
Raise_Exception (End_Error'Identity);
end if;
while Last < Item'Last loop
declare
C : Character;
End_Of_Line : Boolean;
begin
Overloaded_Look_Ahead (File, C, End_Of_Line);
Skip_Ahead (File);
exit when End_Of_Line;
Last := Last + 1;
Item (Last) := C;
end;
end loop;
end if;
end Overloaded_Get_Line;
procedure Overloaded_Get_Line (
File : File_Type;
Item : out Wide_String;
Last : out Natural)
is
pragma Check (Dynamic_Predicate,
Check => Is_Open (File) or else raise Status_Error);
pragma Check (Dynamic_Predicate,
Check => Mode (File) = In_File or else raise Mode_Error);
begin
Last := Item'First - 1;
if Item'Length > 0 then
if End_Of_File (File) then
Raise_Exception (End_Error'Identity);
end if;
while Last < Item'Last loop
declare
C : Wide_Character;
End_Of_Line : Boolean;
begin
Overloaded_Look_Ahead (File, C, End_Of_Line);
Skip_Ahead (File);
exit when End_Of_Line;
Last := Last + 1;
Item (Last) := C;
end;
end loop;
end if;
end Overloaded_Get_Line;
procedure Overloaded_Get_Line (
File : File_Type;
Item : out Wide_Wide_String;
Last : out Natural)
is
pragma Check (Dynamic_Predicate,
Check => Is_Open (File) or else raise Status_Error);
pragma Check (Dynamic_Predicate,
Check => Mode (File) = In_File or else raise Mode_Error);
begin
Last := Item'First - 1;
if Item'Length > 0 then
if End_Of_File (File) then
Raise_Exception (End_Error'Identity);
end if;
while Last < Item'Last loop
declare
C : Wide_Wide_Character;
End_Of_Line : Boolean;
begin
Overloaded_Look_Ahead (File, C, End_Of_Line);
Skip_Ahead (File);
exit when End_Of_Line;
Last := Last + 1;
Item (Last) := C;
end;
end loop;
end if;
end Overloaded_Get_Line;
procedure Overloaded_Get_Line (
Item : out String;
Last : out Natural) is
begin
Overloaded_Get_Line (Current_Input.all, Item, Last);
end Overloaded_Get_Line;
procedure Overloaded_Get_Line (
Item : out Wide_String;
Last : out Natural) is
begin
Overloaded_Get_Line (Current_Input.all, Item, Last);
end Overloaded_Get_Line;
procedure Overloaded_Get_Line (
Item : out Wide_Wide_String;
Last : out Natural) is
begin
Overloaded_Get_Line (Current_Input.all, Item, Last);
end Overloaded_Get_Line;
procedure Get_Line (
File : not null File_Access;
Item : out String;
Last : out Natural) is
begin
Get_Line (File.all, Item, Last);
end Get_Line;
procedure Overloaded_Get_Line (
File : File_Type;
Item : out String_Access)
is
Aliased_Item : aliased String_Access;
Last : Natural;
package Holder is
new Exceptions.Finally.Scoped_Holder (String_Access, Free);
begin
Holder.Assign (Aliased_Item);
Raw_Get_Line (File, Aliased_Item, Last); -- checking the predicate
Reallocate (Aliased_Item, 1, Last);
Holder.Clear;
Item := Aliased_Item;
end Overloaded_Get_Line;
procedure Overloaded_Get_Line (
File : File_Type;
Item : out Wide_String_Access)
is
Aliased_Item : aliased Wide_String_Access;
Last : Natural;
package Holder is
new Exceptions.Finally.Scoped_Holder (Wide_String_Access, Free);
begin
Holder.Assign (Aliased_Item);
Raw_Get_Line (File, Aliased_Item, Last); -- checking the predicate
Reallocate (Aliased_Item, 1, Last);
Holder.Clear;
Item := Aliased_Item;
end Overloaded_Get_Line;
procedure Overloaded_Get_Line (
File : File_Type;
Item : out Wide_Wide_String_Access)
is
Aliased_Item : aliased Wide_Wide_String_Access;
Last : Natural;
package Holder is
new Exceptions.Finally.Scoped_Holder (Wide_Wide_String_Access, Free);
begin
Holder.Assign (Aliased_Item);
Raw_Get_Line (File, Aliased_Item, Last); -- checking the predicate
Reallocate (Aliased_Item, 1, Last);
Holder.Clear;
Item := Aliased_Item;
end Overloaded_Get_Line;
function Overloaded_Get_Line (
File : File_Type)
return String
is
Aliased_Item : aliased String_Access;
Last : Natural;
package Holder is
new Exceptions.Finally.Scoped_Holder (String_Access, Free);
begin
Holder.Assign (Aliased_Item);
Raw_Get_Line (File, Aliased_Item, Last); -- checking the predicate
return Aliased_Item (Aliased_Item'First .. Last);
end Overloaded_Get_Line;
function Overloaded_Get_Line (
File : File_Type)
return Wide_String
is
Aliased_Item : aliased Wide_String_Access;
Last : Natural;
package Holder is
new Exceptions.Finally.Scoped_Holder (Wide_String_Access, Free);
begin
Holder.Assign (Aliased_Item);
Raw_Get_Line (File, Aliased_Item, Last); -- checking the predicate
return Aliased_Item (Aliased_Item'First .. Last);
end Overloaded_Get_Line;
function Overloaded_Get_Line (
File : File_Type)
return Wide_Wide_String
is
Aliased_Item : aliased Wide_Wide_String_Access;
Last : Natural;
package Holder is
new Exceptions.Finally.Scoped_Holder (Wide_Wide_String_Access, Free);
begin
Holder.Assign (Aliased_Item);
Raw_Get_Line (File, Aliased_Item, Last); -- checking the predicate
return Aliased_Item (Aliased_Item'First .. Last);
end Overloaded_Get_Line;
function Overloaded_Get_Line return String is
begin
return Overloaded_Get_Line (Current_Input.all);
end Overloaded_Get_Line;
function Overloaded_Get_Line return Wide_String is
begin
return Overloaded_Get_Line (Current_Input.all);
end Overloaded_Get_Line;
function Overloaded_Get_Line return Wide_Wide_String is
begin
return Overloaded_Get_Line (Current_Input.all);
end Overloaded_Get_Line;
procedure Overloaded_Put_Line (
File : File_Type;
Item : String) is
begin
Overloaded_Put (File, Item); -- checking the predicate
New_Line (File);
end Overloaded_Put_Line;
procedure Overloaded_Put_Line (
File : File_Type;
Item : Wide_String) is
begin
Overloaded_Put (File, Item); -- checking the predicate
New_Line (File);
end Overloaded_Put_Line;
procedure Overloaded_Put_Line (
File : File_Type;
Item : Wide_Wide_String) is
begin
Overloaded_Put (File, Item); -- checking the predicate
New_Line (File);
end Overloaded_Put_Line;
procedure Overloaded_Put_Line (Item : String) is
begin
Overloaded_Put_Line (Current_Output.all, Item);
end Overloaded_Put_Line;
procedure Overloaded_Put_Line (Item : Wide_String) is
begin
Overloaded_Put_Line (Current_Output.all, Item);
end Overloaded_Put_Line;
procedure Overloaded_Put_Line (Item : Wide_Wide_String) is
begin
Overloaded_Put_Line (Current_Output.all, Item);
end Overloaded_Put_Line;
procedure Put_Line (File : not null File_Access; Item : String) is
begin
Put_Line (File.all, Item);
end Put_Line;
package body Controlled is
Standard_Input_Object : aliased File_Type :=
(Finalization.Limited_Controlled
with Text => Naked_Text_IO.Standard_Input);
Standard_Output_Object : aliased File_Type :=
(Finalization.Limited_Controlled
with Text => Naked_Text_IO.Standard_Output);
Standard_Error_Object : aliased File_Type :=
(Finalization.Limited_Controlled
with Text => Naked_Text_IO.Standard_Error);
Current_Input : aliased File_Access := Standard_Input_Object'Access;
Current_Output : aliased File_Access := Standard_Output_Object'Access;
Current_Error : aliased File_Access := Standard_Error_Object'Access;
-- implementation
function Standard_Input return File_Access is
begin
return Standard_Input_Object'Access;
end Standard_Input;
function Standard_Output return File_Access is
begin
return Standard_Output_Object'Access;
end Standard_Output;
function Standard_Error return File_Access is
begin
return Standard_Error_Object'Access;
end Standard_Error;
function Reference_Current_Input return not null access File_Access is
begin
return Current_Input'Access;
end Reference_Current_Input;
function Reference_Current_Output return not null access File_Access is
begin
return Current_Output'Access;
end Reference_Current_Output;
function Reference_Current_Error return not null access File_Access is
begin
return Current_Error'Access;
end Reference_Current_Error;
function Reference (File : Text_IO.File_Type)
return not null access Naked_Text_IO.Non_Controlled_File_Type is
begin
return File_Type (File).Text'Unrestricted_Access;
end Reference;
overriding procedure Finalize (Object : in out File_Type) is
begin
pragma Check (Trace, Debug.Put ("enter"));
if Naked_Text_IO.Is_Open (Object.Text) then
Naked_Text_IO.Close (Object.Text, Raise_On_Error => False);
end if;
pragma Check (Trace, Debug.Put ("leave"));
end Finalize;
end Controlled;
begin
System.Unwind.Occurrences.Flush_IO_Hook := Flush_IO'Access;
end Ada.Text_IO;
|
elderdo/AdaRoombot | Ada | 1,559 | ads | with Types; use Types;
with Communication; use Communication;
package Algorithm is
type Algorithm_Type is
(Pong);
Safety_Exception : exception;
Default_Velocity : Velocity := 320;
type Abstract_Algorithm is abstract tagged record
null;
end record;
type Algorithm_Ptr is access Abstract_Algorithm'Class;
procedure Process (Self : in out Abstract_Algorithm;
Port : in Serial_Port;
Sensors : in Sensor_Collection) is abstract;
procedure Safety_Check (Self : in Abstract_Algorithm;
Sensors : in Sensor_Collection) is abstract;
type Algorithm_State is
(Drive,
Passive_Driving,
Collision,
Recover,
Passive_Recover);
type Pong_Algorithm is new Abstract_Algorithm with record
State : Algorithm_State := Drive;
Collision : Boolean := False;
Reported_Angle : Radius;
Last_Turn : Boolean := False;
end record;
procedure Process (Self : in out Pong_Algorithm;
Port : in Serial_Port;
Sensors : in Sensor_Collection);
function Detect_Collision (Self : in Pong_Algorithm;
Sensors : in Sensor_Collection)
return Boolean;
procedure Safety_Check (Self : in Pong_Algorithm;
Sensors : in Sensor_Collection);
end Algorithm;
|
joakim-strandberg/wayland_ada_binding | Ada | 104 | ads | package Client_Examples.Connect_To_Server is
procedure Run;
end Client_Examples.Connect_To_Server;
|
acornagl/Control_flow_graph-wcet | Ada | 258 | ads | package Instructions is
-- Type Instruction colleclt all the possible processors instructions.
-- At the present moment it is statically defined but in a future work it
-- can be
type Instruction is ( );
end Instructions;
|
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.Path_Attributes is
------------
-- Create --
------------
overriding function Create
(Parameters : not null access Matreshka.DOM_Attributes.Attribute_L2_Parameters)
return Svg_Path_Attribute_Node is
begin
return Self : Svg_Path_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_Path_Attribute_Node)
return League.Strings.Universal_String
is
pragma Unreferenced (Self);
begin
return Matreshka.ODF_String_Constants.Path_Attribute;
end Get_Local_Name;
begin
Matreshka.DOM_Documents.Register_Attribute
(Matreshka.ODF_String_Constants.Svg_URI,
Matreshka.ODF_String_Constants.Path_Attribute,
Svg_Path_Attribute_Node'Tag);
end Matreshka.ODF_Svg.Path_Attributes;
|
AdaCore/libadalang | Ada | 123 | adb | package body Pkg is
type Before is new Integer;
procedure Subunit is separate;
type After is new String;
end Pkg;
|
AntoineLestrade/Automatic_Shutdown | Ada | 278 | adb | with Interfaces.C;
package body Shutdown_Windows is
---------------------
-- System_Shutdown --
---------------------
procedure System_Shutdown is
Res : Interfaces.C.int;
begin
Res := System_Shutdown;
end System_Shutdown;
end Shutdown_Windows;
|
leo-brewin/adm-bssn-numerical | Ada | 360 | adb | package body BSSNBase.Coords is
function x_coord (i : Integer) return Real is
begin
return Real(i-1)*dx;
end x_coord;
function y_coord (j : Integer) return Real is
begin
return Real(j-1)*dy;
end y_coord;
function z_coord (k : Integer) return Real is
begin
return Real(k-1)*dz;
end z_coord;
end BSSNBase.Coords;
|
reznikmm/matreshka | Ada | 3,689 | ads | ------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- Open Document Toolkit --
-- --
-- Runtime Library Component --
-- --
------------------------------------------------------------------------------
-- --
-- Copyright © 2014, Vadim Godunko <[email protected]> --
-- All rights reserved. --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions --
-- are met: --
-- --
-- * Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- --
-- * Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in the --
-- documentation and/or other materials provided with the distribution. --
-- --
-- * Neither the name of the Vadim Godunko, IE nor the names of its --
-- contributors may be used to endorse or promote products derived from --
-- this software without specific prior written permission. --
-- --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR --
-- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
-- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED --
-- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR --
-- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF --
-- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING --
-- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS --
-- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
-- --
------------------------------------------------------------------------------
-- $Revision$ $Date$
------------------------------------------------------------------------------
with XML.DOM.Elements;
package ODF.DOM.Office_Binary_Data_Elements is
pragma Preelaborate;
type ODF_Office_Binary_Data is limited interface
and XML.DOM.Elements.DOM_Element;
type ODF_Office_Binary_Data_Access is
access all ODF_Office_Binary_Data'Class
with Storage_Size => 0;
end ODF.DOM.Office_Binary_Data_Elements;
|
reznikmm/matreshka | Ada | 8,837 | adb |
with Ada.Characters.Handling;
with Ada.Directories;
with Ada.Strings.Unbounded;
with String_Pkg;
package body Ayacc_File_Names is
use Ada.Characters.Handling;
use Ada.Strings.Unbounded;
function "+" (Item : String) return Unbounded_String
renames To_Unbounded_String;
function "+" (Item : Unbounded_String) return String
renames To_String;
Source_File_Name : Unbounded_String;
Out_File_Name : Unbounded_String;
Verbose_File_Name : Unbounded_String;
Template_File_Name : Unbounded_String;
Actions_File_Name : Unbounded_String;
Shift_Reduce_File_Name : Unbounded_String;
Goto_File_Name : Unbounded_String;
Tokens_File_Name : Unbounded_String;
-- UMASS CODES :
Error_Report_File_Name : Unbounded_String;
Listing_File_Name : Unbounded_String;
-- END OF UMASS CODES.
C_Lex_File_Name : Unbounded_String;
Include_File_Name : Unbounded_String;
--RJS ==========================================
function End_of_Unit_Name (Name : in String) return Natural is
Dot_Position : Natural := Name'Last;
begin
while Dot_Position >= Name'First and then
Name (Dot_Position) /= '.'
loop
Dot_Position := Dot_Position - 1;
end loop;
return Dot_Position - 1;
end End_of_Unit_Name;
function Get_Unit_Name (Filename : in String) return String is
-- modified to check for valid Ada identifiers. 11/28/88 kn
Filename_Without_Extension : String :=
Filename (Filename'First .. End_of_Unit_Name (Filename));
End_of_Directory : Natural := Filename_Without_Extension'Last + 1;
function Is_Alphabetic (Ch : in Character) return Boolean is
begin
return Ch in 'A' .. 'Z' or else
Ch in 'a' .. 'z';
end Is_Alphabetic;
function Is_AlphaNum_or_Underscore (Ch : in Character) return Boolean is
begin
return Is_Alphabetic(Ch) or else
Ch in '0' .. '9' or else
Ch = '_' or else Ch = '-';
end Is_AlphaNum_or_Underscore;
use String_Pkg;
begin
-- find end of directory
for Pos in reverse Filename_Without_Extension'FIRST..
Filename_Without_Extension'LAST loop
exit when Filename_Without_Extension(Pos) = '/';
End_Of_Directory := Pos;
end loop;
if End_Of_Directory <= Filename_Without_Extension'LAST and then
Is_Alphabetic (Filename_Without_Extension (End_of_Directory)) then
Check_Remaining_Characters :
for i in End_Of_Directory + 1 .. Filename_Without_Extension'LAST
loop
if not Is_AlphaNum_or_Underscore (Filename_Without_Extension(i)) then
return "";
elsif Filename_Without_Extension(i) = '-' then
Filename_Without_Extension(i) := '.';
end if;
end loop Check_Remaining_Characters;
return Value (Mixed (Filename_Without_Extension (End_of_Directory ..
Filename_Without_Extension'Last)));
else
return "";
end if;
end Get_Unit_Name;
---------------------
-- C_Lex_Unit_Name --
---------------------
function C_Lex_Unit_Name return String is
Filename : constant String := To_Upper (+C_Lex_File_Name);
begin
return Get_Unit_Name (Filename);
end C_Lex_Unit_Name;
---------------------------
-- Goto_Tables_Unit_Name --
---------------------------
function Goto_Tables_Unit_Name return String is
Filename : constant String := To_Upper (+Goto_File_Name);
begin
return Get_Unit_Name (Filename);
end Goto_Tables_Unit_Name;
-----------------------------------
-- Shift_Reduce_Tables_Unit_Name --
-----------------------------------
function Shift_Reduce_Tables_Unit_Name return String is
Filename : constant String := To_Upper (+Shift_Reduce_File_Name);
begin
return Get_Unit_Name (Filename);
end Shift_Reduce_Tables_Unit_Name;
----------------------
-- Tokens_Unit_Name --
----------------------
function Tokens_Unit_Name return String is
Filename : constant String := To_Upper (+Tokens_File_Name);
begin
return Get_Unit_Name (Filename);
end Tokens_Unit_Name;
--------------------
-- Main_Unit_Name --
--------------------
function Main_Unit_Name return String is
Filename : constant String := To_Upper (+Out_File_Name);
begin
return Get_Unit_Name (Filename);
end Main_Unit_Name;
-- UMASS CODES :
----------------------------
-- Error_Report_Unit_Name --
----------------------------
function Error_Report_Unit_Name return String is
Filename : constant String := To_Upper (+Error_Report_File_Name);
begin
return Get_Unit_Name (Filename);
end Error_Report_Unit_Name;
-- END OF UMASS CODES.
--RJS ==========================================
--------------------------
-- Get_Source_File_Name --
--------------------------
function Get_Source_File_Name return String is
begin
return +Source_File_Name;
end;
-----------------------
-- Get_Out_File_Name --
-----------------------
function Get_Out_File_Name return String is
begin
return +Out_File_Name;
end;
---------------------------
-- Get_Verbose_File_Name --
---------------------------
function Get_Verbose_File_Name return String is
begin
return +Verbose_File_Name;
end;
----------------------------
-- Get_Template_File_Name --
----------------------------
function Get_Template_File_Name return String is
begin
return +Template_File_Name;
end;
---------------------------
-- Get_Actions_File_Name --
---------------------------
function Get_Actions_File_Name return String is
begin
return +Actions_File_Name;
end;
--------------------------------
-- Get_Shift_Reduce_File_Name --
--------------------------------
function Get_Shift_Reduce_File_Name return String is
begin
return +Shift_Reduce_File_Name;
end;
------------------------
-- Get_Goto_File_Name --
------------------------
function Get_Goto_File_Name return String is
begin
return +Goto_File_Name;
end;
--------------------------
-- Get_Tokens_File_Name --
--------------------------
function Get_Tokens_File_Name return String is
begin
return +Tokens_File_Name;
end;
-- UMASS CODES :
--------------------------------
-- Get_Error_Report_File_Name --
--------------------------------
function Get_Error_Report_File_Name return String is
begin
return +Error_Report_File_Name;
end Get_Error_Report_File_Name;
---------------------------
-- Get_Listing_File_Name --
---------------------------
function Get_Listing_File_Name return String is
begin
return +Listing_File_Name;
end;
-- END OF UMASS CODES.
-------------------------
-- Get_C_Lex_File_Name --
-------------------------
function Get_C_Lex_File_Name return String is
begin
return +C_Lex_File_Name;
end;
---------------------------
-- Get_Include_File_Name --
---------------------------
function Get_Include_File_Name return String is
begin
return +Include_File_Name;
end;
--------------------
-- Set_File_Names --
--------------------
procedure Set_File_Names(Input_File, Extension: in String) is
Base_Name : constant String := Ada.Directories.Base_Name (Input_File);
begin
if Input_File'Length < 3
or else (Input_File(Input_File'Last) /= 'y'
and then Input_File(Input_File'Last) /= 'Y')
or else Input_File(Input_File'Last - 1) /= '.' then
raise Illegal_File_Name;
end if;
Source_File_Name := +Input_File;
Out_File_Name := +Base_Name;
Append (Out_File_Name, Extension);
Verbose_File_Name := +Base_Name;
Append (Verbose_File_Name, ".verbose");
Tokens_File_Name := +Base_Name;
Append (Tokens_File_Name, "_tokens" & Extension & "ds");
-- UMASS CODES :
Error_Report_File_Name := +Base_Name;
Append (Error_Report_File_Name, "-error_report" & Extension);
Listing_File_Name := +Base_Name;
Append (Listing_File_Name, ".lis");
-- END OF UMASS CODES.
Template_File_Name := +"yyparse.template";
Actions_File_Name := +Base_Name;
Append (Actions_File_Name, ".accs");
Shift_Reduce_File_Name := +Base_Name;
Append (Shift_Reduce_File_Name, "-shift_reduce" & Extension & "ds");
Goto_File_Name := +Base_Name;
Append (Goto_File_Name, "-goto_table" & Extension & "ds");
C_Lex_File_Name := +Base_Name;
Append (C_Lex_File_Name, "-c_lex" & Extension);
Include_File_Name := +Base_Name;
Append (Include_File_Name, ".h");
end Set_File_Names;
end Ayacc_File_Names;
|
zhmu/ananas | Ada | 169 | ads | package Vect16 is
type Sarray is array (1 .. 5) of Long_Float;
for Sarray'Alignment use 16;
procedure Add_Sub (X, Y : Sarray; R,S : out Sarray);
end Vect16;
|
reznikmm/matreshka | Ada | 53,331 | adb | ------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- Ada Modeling Framework --
-- --
-- Runtime Library Component --
-- --
------------------------------------------------------------------------------
-- --
-- Copyright © 2012, Vadim Godunko <[email protected]> --
-- All rights reserved. --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions --
-- are met: --
-- --
-- * Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- --
-- * Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in the --
-- documentation and/or other materials provided with the distribution. --
-- --
-- * Neither the name of the Vadim Godunko, IE nor the names of its --
-- contributors may be used to endorse or promote products derived from --
-- this software without specific prior written permission. --
-- --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR --
-- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
-- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED --
-- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR --
-- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF --
-- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING --
-- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS --
-- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
-- --
------------------------------------------------------------------------------
-- $Revision$ $Date$
------------------------------------------------------------------------------
-- This file is generated, don't edit it.
------------------------------------------------------------------------------
with AMF.Elements;
with AMF.Internals.Element_Collections;
with AMF.Internals.Helpers;
with AMF.Internals.Tables.OCL_Attributes;
with AMF.String_Collections;
with AMF.UML.Classifier_Template_Parameters;
with AMF.UML.Classifiers.Collections;
with AMF.UML.Collaboration_Uses.Collections;
with AMF.UML.Comments.Collections;
with AMF.UML.Constraints.Collections;
with AMF.UML.Dependencies.Collections;
with AMF.UML.Element_Imports.Collections;
with AMF.UML.Elements.Collections;
with AMF.UML.Features.Collections;
with AMF.UML.Generalization_Sets.Collections;
with AMF.UML.Generalizations.Collections;
with AMF.UML.Named_Elements.Collections;
with AMF.UML.Namespaces.Collections;
with AMF.UML.Operations.Collections;
with AMF.UML.Package_Imports.Collections;
with AMF.UML.Packageable_Elements.Collections;
with AMF.UML.Packages.Collections;
with AMF.UML.Parameterable_Elements.Collections;
with AMF.UML.Properties.Collections;
with AMF.UML.Redefinable_Elements.Collections;
with AMF.UML.Redefinable_Template_Signatures;
with AMF.UML.String_Expressions;
with AMF.UML.Substitutions.Collections;
with AMF.UML.Template_Bindings.Collections;
with AMF.UML.Template_Parameters;
with AMF.UML.Template_Signatures;
with AMF.UML.Types;
with AMF.UML.Use_Cases.Collections;
with AMF.Visitors.OCL_Iterators;
with AMF.Visitors.OCL_Visitors;
with League.Strings.Internals;
with Matreshka.Internals.Strings;
package body AMF.Internals.OCL_Ordered_Set_Types is
----------------------
-- Get_Element_Type --
----------------------
overriding function Get_Element_Type
(Self : not null access constant OCL_Ordered_Set_Type_Proxy)
return AMF.UML.Classifiers.UML_Classifier_Access is
begin
return
AMF.UML.Classifiers.UML_Classifier_Access
(AMF.Internals.Helpers.To_Element
(AMF.Internals.Tables.OCL_Attributes.Internal_Get_Element_Type
(Self.Element)));
end Get_Element_Type;
----------------------
-- Set_Element_Type --
----------------------
overriding procedure Set_Element_Type
(Self : not null access OCL_Ordered_Set_Type_Proxy;
To : AMF.UML.Classifiers.UML_Classifier_Access) is
begin
AMF.Internals.Tables.OCL_Attributes.Internal_Set_Element_Type
(Self.Element,
AMF.Internals.Helpers.To_Element
(AMF.Elements.Element_Access (To)));
end Set_Element_Type;
-------------------------
-- Get_Owned_Attribute --
-------------------------
overriding function Get_Owned_Attribute
(Self : not null access constant OCL_Ordered_Set_Type_Proxy)
return AMF.UML.Properties.Collections.Ordered_Set_Of_UML_Property is
begin
return
AMF.UML.Properties.Collections.Wrap
(AMF.Internals.Element_Collections.Wrap
(AMF.Internals.Tables.OCL_Attributes.Internal_Get_Owned_Attribute
(Self.Element)));
end Get_Owned_Attribute;
-------------------------
-- Get_Owned_Operation --
-------------------------
overriding function Get_Owned_Operation
(Self : not null access constant OCL_Ordered_Set_Type_Proxy)
return AMF.UML.Operations.Collections.Ordered_Set_Of_UML_Operation is
begin
return
AMF.UML.Operations.Collections.Wrap
(AMF.Internals.Element_Collections.Wrap
(AMF.Internals.Tables.OCL_Attributes.Internal_Get_Owned_Operation
(Self.Element)));
end Get_Owned_Operation;
-------------------
-- Get_Attribute --
-------------------
overriding function Get_Attribute
(Self : not null access constant OCL_Ordered_Set_Type_Proxy)
return AMF.UML.Properties.Collections.Set_Of_UML_Property is
begin
return
AMF.UML.Properties.Collections.Wrap
(AMF.Internals.Element_Collections.Wrap
(AMF.Internals.Tables.OCL_Attributes.Internal_Get_Attribute
(Self.Element)));
end Get_Attribute;
---------------------------
-- Get_Collaboration_Use --
---------------------------
overriding function Get_Collaboration_Use
(Self : not null access constant OCL_Ordered_Set_Type_Proxy)
return AMF.UML.Collaboration_Uses.Collections.Set_Of_UML_Collaboration_Use is
begin
return
AMF.UML.Collaboration_Uses.Collections.Wrap
(AMF.Internals.Element_Collections.Wrap
(AMF.Internals.Tables.OCL_Attributes.Internal_Get_Collaboration_Use
(Self.Element)));
end Get_Collaboration_Use;
-----------------
-- Get_Feature --
-----------------
overriding function Get_Feature
(Self : not null access constant OCL_Ordered_Set_Type_Proxy)
return AMF.UML.Features.Collections.Set_Of_UML_Feature is
begin
return
AMF.UML.Features.Collections.Wrap
(AMF.Internals.Element_Collections.Wrap
(AMF.Internals.Tables.OCL_Attributes.Internal_Get_Feature
(Self.Element)));
end Get_Feature;
-----------------
-- Get_General --
-----------------
overriding function Get_General
(Self : not null access constant OCL_Ordered_Set_Type_Proxy)
return AMF.UML.Classifiers.Collections.Set_Of_UML_Classifier is
begin
return
AMF.UML.Classifiers.Collections.Wrap
(AMF.Internals.Element_Collections.Wrap
(AMF.Internals.Tables.OCL_Attributes.Internal_Get_General
(Self.Element)));
end Get_General;
------------------------
-- Get_Generalization --
------------------------
overriding function Get_Generalization
(Self : not null access constant OCL_Ordered_Set_Type_Proxy)
return AMF.UML.Generalizations.Collections.Set_Of_UML_Generalization is
begin
return
AMF.UML.Generalizations.Collections.Wrap
(AMF.Internals.Element_Collections.Wrap
(AMF.Internals.Tables.OCL_Attributes.Internal_Get_Generalization
(Self.Element)));
end Get_Generalization;
--------------------------
-- Get_Inherited_Member --
--------------------------
overriding function Get_Inherited_Member
(Self : not null access constant OCL_Ordered_Set_Type_Proxy)
return AMF.UML.Named_Elements.Collections.Set_Of_UML_Named_Element is
begin
return
AMF.UML.Named_Elements.Collections.Wrap
(AMF.Internals.Element_Collections.Wrap
(AMF.Internals.Tables.OCL_Attributes.Internal_Get_Inherited_Member
(Self.Element)));
end Get_Inherited_Member;
---------------------
-- Get_Is_Abstract --
---------------------
overriding function Get_Is_Abstract
(Self : not null access constant OCL_Ordered_Set_Type_Proxy)
return Boolean is
begin
return
AMF.Internals.Tables.OCL_Attributes.Internal_Get_Is_Abstract
(Self.Element);
end Get_Is_Abstract;
---------------------
-- Set_Is_Abstract --
---------------------
overriding procedure Set_Is_Abstract
(Self : not null access OCL_Ordered_Set_Type_Proxy;
To : Boolean) is
begin
AMF.Internals.Tables.OCL_Attributes.Internal_Set_Is_Abstract
(Self.Element, To);
end Set_Is_Abstract;
---------------------------------
-- Get_Is_Final_Specialization --
---------------------------------
overriding function Get_Is_Final_Specialization
(Self : not null access constant OCL_Ordered_Set_Type_Proxy)
return Boolean is
begin
return
AMF.Internals.Tables.OCL_Attributes.Internal_Get_Is_Final_Specialization
(Self.Element);
end Get_Is_Final_Specialization;
---------------------------------
-- Set_Is_Final_Specialization --
---------------------------------
overriding procedure Set_Is_Final_Specialization
(Self : not null access OCL_Ordered_Set_Type_Proxy;
To : Boolean) is
begin
AMF.Internals.Tables.OCL_Attributes.Internal_Set_Is_Final_Specialization
(Self.Element, To);
end Set_Is_Final_Specialization;
----------------------------------
-- Get_Owned_Template_Signature --
----------------------------------
overriding function Get_Owned_Template_Signature
(Self : not null access constant OCL_Ordered_Set_Type_Proxy)
return AMF.UML.Redefinable_Template_Signatures.UML_Redefinable_Template_Signature_Access is
begin
return
AMF.UML.Redefinable_Template_Signatures.UML_Redefinable_Template_Signature_Access
(AMF.Internals.Helpers.To_Element
(AMF.Internals.Tables.OCL_Attributes.Internal_Get_Owned_Template_Signature
(Self.Element)));
end Get_Owned_Template_Signature;
----------------------------------
-- Set_Owned_Template_Signature --
----------------------------------
overriding procedure Set_Owned_Template_Signature
(Self : not null access OCL_Ordered_Set_Type_Proxy;
To : AMF.UML.Redefinable_Template_Signatures.UML_Redefinable_Template_Signature_Access) is
begin
AMF.Internals.Tables.OCL_Attributes.Internal_Set_Owned_Template_Signature
(Self.Element,
AMF.Internals.Helpers.To_Element
(AMF.Elements.Element_Access (To)));
end Set_Owned_Template_Signature;
------------------------
-- Get_Owned_Use_Case --
------------------------
overriding function Get_Owned_Use_Case
(Self : not null access constant OCL_Ordered_Set_Type_Proxy)
return AMF.UML.Use_Cases.Collections.Set_Of_UML_Use_Case is
begin
return
AMF.UML.Use_Cases.Collections.Wrap
(AMF.Internals.Element_Collections.Wrap
(AMF.Internals.Tables.OCL_Attributes.Internal_Get_Owned_Use_Case
(Self.Element)));
end Get_Owned_Use_Case;
--------------------------
-- Get_Powertype_Extent --
--------------------------
overriding function Get_Powertype_Extent
(Self : not null access constant OCL_Ordered_Set_Type_Proxy)
return AMF.UML.Generalization_Sets.Collections.Set_Of_UML_Generalization_Set is
begin
return
AMF.UML.Generalization_Sets.Collections.Wrap
(AMF.Internals.Element_Collections.Wrap
(AMF.Internals.Tables.OCL_Attributes.Internal_Get_Powertype_Extent
(Self.Element)));
end Get_Powertype_Extent;
------------------------------
-- Get_Redefined_Classifier --
------------------------------
overriding function Get_Redefined_Classifier
(Self : not null access constant OCL_Ordered_Set_Type_Proxy)
return AMF.UML.Classifiers.Collections.Set_Of_UML_Classifier is
begin
return
AMF.UML.Classifiers.Collections.Wrap
(AMF.Internals.Element_Collections.Wrap
(AMF.Internals.Tables.OCL_Attributes.Internal_Get_Redefined_Classifier
(Self.Element)));
end Get_Redefined_Classifier;
------------------------
-- Get_Representation --
------------------------
overriding function Get_Representation
(Self : not null access constant OCL_Ordered_Set_Type_Proxy)
return AMF.UML.Collaboration_Uses.UML_Collaboration_Use_Access is
begin
return
AMF.UML.Collaboration_Uses.UML_Collaboration_Use_Access
(AMF.Internals.Helpers.To_Element
(AMF.Internals.Tables.OCL_Attributes.Internal_Get_Representation
(Self.Element)));
end Get_Representation;
------------------------
-- Set_Representation --
------------------------
overriding procedure Set_Representation
(Self : not null access OCL_Ordered_Set_Type_Proxy;
To : AMF.UML.Collaboration_Uses.UML_Collaboration_Use_Access) is
begin
AMF.Internals.Tables.OCL_Attributes.Internal_Set_Representation
(Self.Element,
AMF.Internals.Helpers.To_Element
(AMF.Elements.Element_Access (To)));
end Set_Representation;
----------------------
-- Get_Substitution --
----------------------
overriding function Get_Substitution
(Self : not null access constant OCL_Ordered_Set_Type_Proxy)
return AMF.UML.Substitutions.Collections.Set_Of_UML_Substitution is
begin
return
AMF.UML.Substitutions.Collections.Wrap
(AMF.Internals.Element_Collections.Wrap
(AMF.Internals.Tables.OCL_Attributes.Internal_Get_Substitution
(Self.Element)));
end Get_Substitution;
----------------------------
-- Get_Template_Parameter --
----------------------------
overriding function Get_Template_Parameter
(Self : not null access constant OCL_Ordered_Set_Type_Proxy)
return AMF.UML.Classifier_Template_Parameters.UML_Classifier_Template_Parameter_Access is
begin
return
AMF.UML.Classifier_Template_Parameters.UML_Classifier_Template_Parameter_Access
(AMF.Internals.Helpers.To_Element
(AMF.Internals.Tables.OCL_Attributes.Internal_Get_Template_Parameter
(Self.Element)));
end Get_Template_Parameter;
----------------------------
-- Set_Template_Parameter --
----------------------------
overriding procedure Set_Template_Parameter
(Self : not null access OCL_Ordered_Set_Type_Proxy;
To : AMF.UML.Classifier_Template_Parameters.UML_Classifier_Template_Parameter_Access) is
begin
AMF.Internals.Tables.OCL_Attributes.Internal_Set_Template_Parameter
(Self.Element,
AMF.Internals.Helpers.To_Element
(AMF.Elements.Element_Access (To)));
end Set_Template_Parameter;
------------------
-- Get_Use_Case --
------------------
overriding function Get_Use_Case
(Self : not null access constant OCL_Ordered_Set_Type_Proxy)
return AMF.UML.Use_Cases.Collections.Set_Of_UML_Use_Case is
begin
return
AMF.UML.Use_Cases.Collections.Wrap
(AMF.Internals.Element_Collections.Wrap
(AMF.Internals.Tables.OCL_Attributes.Internal_Get_Use_Case
(Self.Element)));
end Get_Use_Case;
------------------------
-- Get_Element_Import --
------------------------
overriding function Get_Element_Import
(Self : not null access constant OCL_Ordered_Set_Type_Proxy)
return AMF.UML.Element_Imports.Collections.Set_Of_UML_Element_Import is
begin
return
AMF.UML.Element_Imports.Collections.Wrap
(AMF.Internals.Element_Collections.Wrap
(AMF.Internals.Tables.OCL_Attributes.Internal_Get_Element_Import
(Self.Element)));
end Get_Element_Import;
-------------------------
-- Get_Imported_Member --
-------------------------
overriding function Get_Imported_Member
(Self : not null access constant OCL_Ordered_Set_Type_Proxy)
return AMF.UML.Packageable_Elements.Collections.Set_Of_UML_Packageable_Element is
begin
return
AMF.UML.Packageable_Elements.Collections.Wrap
(AMF.Internals.Element_Collections.Wrap
(AMF.Internals.Tables.OCL_Attributes.Internal_Get_Imported_Member
(Self.Element)));
end Get_Imported_Member;
----------------
-- Get_Member --
----------------
overriding function Get_Member
(Self : not null access constant OCL_Ordered_Set_Type_Proxy)
return AMF.UML.Named_Elements.Collections.Set_Of_UML_Named_Element is
begin
return
AMF.UML.Named_Elements.Collections.Wrap
(AMF.Internals.Element_Collections.Wrap
(AMF.Internals.Tables.OCL_Attributes.Internal_Get_Member
(Self.Element)));
end Get_Member;
----------------------
-- Get_Owned_Member --
----------------------
overriding function Get_Owned_Member
(Self : not null access constant OCL_Ordered_Set_Type_Proxy)
return AMF.UML.Named_Elements.Collections.Set_Of_UML_Named_Element is
begin
return
AMF.UML.Named_Elements.Collections.Wrap
(AMF.Internals.Element_Collections.Wrap
(AMF.Internals.Tables.OCL_Attributes.Internal_Get_Owned_Member
(Self.Element)));
end Get_Owned_Member;
--------------------
-- Get_Owned_Rule --
--------------------
overriding function Get_Owned_Rule
(Self : not null access constant OCL_Ordered_Set_Type_Proxy)
return AMF.UML.Constraints.Collections.Set_Of_UML_Constraint is
begin
return
AMF.UML.Constraints.Collections.Wrap
(AMF.Internals.Element_Collections.Wrap
(AMF.Internals.Tables.OCL_Attributes.Internal_Get_Owned_Rule
(Self.Element)));
end Get_Owned_Rule;
------------------------
-- Get_Package_Import --
------------------------
overriding function Get_Package_Import
(Self : not null access constant OCL_Ordered_Set_Type_Proxy)
return AMF.UML.Package_Imports.Collections.Set_Of_UML_Package_Import is
begin
return
AMF.UML.Package_Imports.Collections.Wrap
(AMF.Internals.Element_Collections.Wrap
(AMF.Internals.Tables.OCL_Attributes.Internal_Get_Package_Import
(Self.Element)));
end Get_Package_Import;
---------------------------
-- Get_Client_Dependency --
---------------------------
overriding function Get_Client_Dependency
(Self : not null access constant OCL_Ordered_Set_Type_Proxy)
return AMF.UML.Dependencies.Collections.Set_Of_UML_Dependency is
begin
return
AMF.UML.Dependencies.Collections.Wrap
(AMF.Internals.Element_Collections.Wrap
(AMF.Internals.Tables.OCL_Attributes.Internal_Get_Client_Dependency
(Self.Element)));
end Get_Client_Dependency;
--------------
-- Get_Name --
--------------
overriding function Get_Name
(Self : not null access constant OCL_Ordered_Set_Type_Proxy)
return AMF.Optional_String is
begin
declare
use type Matreshka.Internals.Strings.Shared_String_Access;
Aux : constant Matreshka.Internals.Strings.Shared_String_Access
:= AMF.Internals.Tables.OCL_Attributes.Internal_Get_Name (Self.Element);
begin
if Aux = null then
return (Is_Empty => True);
else
return (False, League.Strings.Internals.Create (Aux));
end if;
end;
end Get_Name;
--------------
-- Set_Name --
--------------
overriding procedure Set_Name
(Self : not null access OCL_Ordered_Set_Type_Proxy;
To : AMF.Optional_String) is
begin
if To.Is_Empty then
AMF.Internals.Tables.OCL_Attributes.Internal_Set_Name
(Self.Element, null);
else
AMF.Internals.Tables.OCL_Attributes.Internal_Set_Name
(Self.Element,
League.Strings.Internals.Internal (To.Value));
end if;
end Set_Name;
-------------------------
-- Get_Name_Expression --
-------------------------
overriding function Get_Name_Expression
(Self : not null access constant OCL_Ordered_Set_Type_Proxy)
return AMF.UML.String_Expressions.UML_String_Expression_Access is
begin
return
AMF.UML.String_Expressions.UML_String_Expression_Access
(AMF.Internals.Helpers.To_Element
(AMF.Internals.Tables.OCL_Attributes.Internal_Get_Name_Expression
(Self.Element)));
end Get_Name_Expression;
-------------------------
-- Set_Name_Expression --
-------------------------
overriding procedure Set_Name_Expression
(Self : not null access OCL_Ordered_Set_Type_Proxy;
To : AMF.UML.String_Expressions.UML_String_Expression_Access) is
begin
AMF.Internals.Tables.OCL_Attributes.Internal_Set_Name_Expression
(Self.Element,
AMF.Internals.Helpers.To_Element
(AMF.Elements.Element_Access (To)));
end Set_Name_Expression;
-------------------
-- Get_Namespace --
-------------------
overriding function Get_Namespace
(Self : not null access constant OCL_Ordered_Set_Type_Proxy)
return AMF.UML.Namespaces.UML_Namespace_Access is
begin
return
AMF.UML.Namespaces.UML_Namespace_Access
(AMF.Internals.Helpers.To_Element
(AMF.Internals.Tables.OCL_Attributes.Internal_Get_Namespace
(Self.Element)));
end Get_Namespace;
------------------------
-- Get_Qualified_Name --
------------------------
overriding function Get_Qualified_Name
(Self : not null access constant OCL_Ordered_Set_Type_Proxy)
return AMF.Optional_String is
begin
declare
use type Matreshka.Internals.Strings.Shared_String_Access;
Aux : constant Matreshka.Internals.Strings.Shared_String_Access
:= AMF.Internals.Tables.OCL_Attributes.Internal_Get_Qualified_Name (Self.Element);
begin
if Aux = null then
return (Is_Empty => True);
else
return (False, League.Strings.Internals.Create (Aux));
end if;
end;
end Get_Qualified_Name;
--------------------
-- Get_Visibility --
--------------------
overriding function Get_Visibility
(Self : not null access constant OCL_Ordered_Set_Type_Proxy)
return AMF.UML.Optional_UML_Visibility_Kind is
begin
return
AMF.Internals.Tables.OCL_Attributes.Internal_Get_Visibility
(Self.Element);
end Get_Visibility;
--------------------
-- Set_Visibility --
--------------------
overriding procedure Set_Visibility
(Self : not null access OCL_Ordered_Set_Type_Proxy;
To : AMF.UML.Optional_UML_Visibility_Kind) is
begin
AMF.Internals.Tables.OCL_Attributes.Internal_Set_Visibility
(Self.Element, To);
end Set_Visibility;
-----------------------
-- Get_Owned_Comment --
-----------------------
overriding function Get_Owned_Comment
(Self : not null access constant OCL_Ordered_Set_Type_Proxy)
return AMF.UML.Comments.Collections.Set_Of_UML_Comment is
begin
return
AMF.UML.Comments.Collections.Wrap
(AMF.Internals.Element_Collections.Wrap
(AMF.Internals.Tables.OCL_Attributes.Internal_Get_Owned_Comment
(Self.Element)));
end Get_Owned_Comment;
-----------------------
-- Get_Owned_Element --
-----------------------
overriding function Get_Owned_Element
(Self : not null access constant OCL_Ordered_Set_Type_Proxy)
return AMF.UML.Elements.Collections.Set_Of_UML_Element is
begin
return
AMF.UML.Elements.Collections.Wrap
(AMF.Internals.Element_Collections.Wrap
(AMF.Internals.Tables.OCL_Attributes.Internal_Get_Owned_Element
(Self.Element)));
end Get_Owned_Element;
---------------
-- Get_Owner --
---------------
overriding function Get_Owner
(Self : not null access constant OCL_Ordered_Set_Type_Proxy)
return AMF.UML.Elements.UML_Element_Access is
begin
return
AMF.UML.Elements.UML_Element_Access
(AMF.Internals.Helpers.To_Element
(AMF.Internals.Tables.OCL_Attributes.Internal_Get_Owner
(Self.Element)));
end Get_Owner;
-----------------
-- Get_Package --
-----------------
overriding function Get_Package
(Self : not null access constant OCL_Ordered_Set_Type_Proxy)
return AMF.UML.Packages.UML_Package_Access is
begin
return
AMF.UML.Packages.UML_Package_Access
(AMF.Internals.Helpers.To_Element
(AMF.Internals.Tables.OCL_Attributes.Internal_Get_Package
(Self.Element)));
end Get_Package;
-----------------
-- Set_Package --
-----------------
overriding procedure Set_Package
(Self : not null access OCL_Ordered_Set_Type_Proxy;
To : AMF.UML.Packages.UML_Package_Access) is
begin
AMF.Internals.Tables.OCL_Attributes.Internal_Set_Package
(Self.Element,
AMF.Internals.Helpers.To_Element
(AMF.Elements.Element_Access (To)));
end Set_Package;
--------------------
-- Get_Visibility --
--------------------
overriding function Get_Visibility
(Self : not null access constant OCL_Ordered_Set_Type_Proxy)
return AMF.UML.UML_Visibility_Kind is
begin
return
AMF.Internals.Tables.OCL_Attributes.Internal_Get_Visibility
(Self.Element).Value;
end Get_Visibility;
--------------------
-- Set_Visibility --
--------------------
overriding procedure Set_Visibility
(Self : not null access OCL_Ordered_Set_Type_Proxy;
To : AMF.UML.UML_Visibility_Kind) is
begin
AMF.Internals.Tables.OCL_Attributes.Internal_Set_Visibility
(Self.Element, (False, To));
end Set_Visibility;
-----------------------------------
-- Get_Owning_Template_Parameter --
-----------------------------------
overriding function Get_Owning_Template_Parameter
(Self : not null access constant OCL_Ordered_Set_Type_Proxy)
return AMF.UML.Template_Parameters.UML_Template_Parameter_Access is
begin
return
AMF.UML.Template_Parameters.UML_Template_Parameter_Access
(AMF.Internals.Helpers.To_Element
(AMF.Internals.Tables.OCL_Attributes.Internal_Get_Owning_Template_Parameter
(Self.Element)));
end Get_Owning_Template_Parameter;
-----------------------------------
-- Set_Owning_Template_Parameter --
-----------------------------------
overriding procedure Set_Owning_Template_Parameter
(Self : not null access OCL_Ordered_Set_Type_Proxy;
To : AMF.UML.Template_Parameters.UML_Template_Parameter_Access) is
begin
AMF.Internals.Tables.OCL_Attributes.Internal_Set_Owning_Template_Parameter
(Self.Element,
AMF.Internals.Helpers.To_Element
(AMF.Elements.Element_Access (To)));
end Set_Owning_Template_Parameter;
----------------------------
-- Get_Template_Parameter --
----------------------------
overriding function Get_Template_Parameter
(Self : not null access constant OCL_Ordered_Set_Type_Proxy)
return AMF.UML.Template_Parameters.UML_Template_Parameter_Access is
begin
return
AMF.UML.Template_Parameters.UML_Template_Parameter_Access
(AMF.Internals.Helpers.To_Element
(AMF.Internals.Tables.OCL_Attributes.Internal_Get_Template_Parameter
(Self.Element)));
end Get_Template_Parameter;
----------------------------
-- Set_Template_Parameter --
----------------------------
overriding procedure Set_Template_Parameter
(Self : not null access OCL_Ordered_Set_Type_Proxy;
To : AMF.UML.Template_Parameters.UML_Template_Parameter_Access) is
begin
AMF.Internals.Tables.OCL_Attributes.Internal_Set_Template_Parameter
(Self.Element,
AMF.Internals.Helpers.To_Element
(AMF.Elements.Element_Access (To)));
end Set_Template_Parameter;
----------------------------------
-- Get_Owned_Template_Signature --
----------------------------------
overriding function Get_Owned_Template_Signature
(Self : not null access constant OCL_Ordered_Set_Type_Proxy)
return AMF.UML.Template_Signatures.UML_Template_Signature_Access is
begin
return
AMF.UML.Template_Signatures.UML_Template_Signature_Access
(AMF.Internals.Helpers.To_Element
(AMF.Internals.Tables.OCL_Attributes.Internal_Get_Owned_Template_Signature
(Self.Element)));
end Get_Owned_Template_Signature;
----------------------------------
-- Set_Owned_Template_Signature --
----------------------------------
overriding procedure Set_Owned_Template_Signature
(Self : not null access OCL_Ordered_Set_Type_Proxy;
To : AMF.UML.Template_Signatures.UML_Template_Signature_Access) is
begin
AMF.Internals.Tables.OCL_Attributes.Internal_Set_Owned_Template_Signature
(Self.Element,
AMF.Internals.Helpers.To_Element
(AMF.Elements.Element_Access (To)));
end Set_Owned_Template_Signature;
--------------------------
-- Get_Template_Binding --
--------------------------
overriding function Get_Template_Binding
(Self : not null access constant OCL_Ordered_Set_Type_Proxy)
return AMF.UML.Template_Bindings.Collections.Set_Of_UML_Template_Binding is
begin
return
AMF.UML.Template_Bindings.Collections.Wrap
(AMF.Internals.Element_Collections.Wrap
(AMF.Internals.Tables.OCL_Attributes.Internal_Get_Template_Binding
(Self.Element)));
end Get_Template_Binding;
-----------------
-- Get_Is_Leaf --
-----------------
overriding function Get_Is_Leaf
(Self : not null access constant OCL_Ordered_Set_Type_Proxy)
return Boolean is
begin
return
AMF.Internals.Tables.OCL_Attributes.Internal_Get_Is_Leaf
(Self.Element);
end Get_Is_Leaf;
-----------------
-- Set_Is_Leaf --
-----------------
overriding procedure Set_Is_Leaf
(Self : not null access OCL_Ordered_Set_Type_Proxy;
To : Boolean) is
begin
AMF.Internals.Tables.OCL_Attributes.Internal_Set_Is_Leaf
(Self.Element, To);
end Set_Is_Leaf;
---------------------------
-- Get_Redefined_Element --
---------------------------
overriding function Get_Redefined_Element
(Self : not null access constant OCL_Ordered_Set_Type_Proxy)
return AMF.UML.Redefinable_Elements.Collections.Set_Of_UML_Redefinable_Element is
begin
return
AMF.UML.Redefinable_Elements.Collections.Wrap
(AMF.Internals.Element_Collections.Wrap
(AMF.Internals.Tables.OCL_Attributes.Internal_Get_Redefined_Element
(Self.Element)));
end Get_Redefined_Element;
------------------------------
-- Get_Redefinition_Context --
------------------------------
overriding function Get_Redefinition_Context
(Self : not null access constant OCL_Ordered_Set_Type_Proxy)
return AMF.UML.Classifiers.Collections.Set_Of_UML_Classifier is
begin
return
AMF.UML.Classifiers.Collections.Wrap
(AMF.Internals.Element_Collections.Wrap
(AMF.Internals.Tables.OCL_Attributes.Internal_Get_Redefinition_Context
(Self.Element)));
end Get_Redefinition_Context;
-------------
-- Inherit --
-------------
overriding function Inherit
(Self : not null access constant OCL_Ordered_Set_Type_Proxy;
Inhs : AMF.UML.Named_Elements.Collections.Set_Of_UML_Named_Element)
return AMF.UML.Named_Elements.Collections.Set_Of_UML_Named_Element is
begin
-- Generated stub: replace with real body!
pragma Compile_Time_Warning (Standard.True, "Inherit unimplemented");
raise Program_Error with "Unimplemented procedure OCL_Ordered_Set_Type_Proxy.Inherit";
return Inherit (Self, Inhs);
end Inherit;
------------------
-- All_Features --
------------------
overriding function All_Features
(Self : not null access constant OCL_Ordered_Set_Type_Proxy)
return AMF.UML.Features.Collections.Set_Of_UML_Feature is
begin
-- Generated stub: replace with real body!
pragma Compile_Time_Warning (Standard.True, "All_Features unimplemented");
raise Program_Error with "Unimplemented procedure OCL_Ordered_Set_Type_Proxy.All_Features";
return All_Features (Self);
end All_Features;
-----------------
-- All_Parents --
-----------------
overriding function All_Parents
(Self : not null access constant OCL_Ordered_Set_Type_Proxy)
return AMF.UML.Classifiers.Collections.Set_Of_UML_Classifier is
begin
-- Generated stub: replace with real body!
pragma Compile_Time_Warning (Standard.True, "All_Parents unimplemented");
raise Program_Error with "Unimplemented procedure OCL_Ordered_Set_Type_Proxy.All_Parents";
return All_Parents (Self);
end All_Parents;
-----------------
-- Conforms_To --
-----------------
overriding function Conforms_To
(Self : not null access constant OCL_Ordered_Set_Type_Proxy;
Other : AMF.UML.Classifiers.UML_Classifier_Access)
return Boolean is
begin
-- Generated stub: replace with real body!
pragma Compile_Time_Warning (Standard.True, "Conforms_To unimplemented");
raise Program_Error with "Unimplemented procedure OCL_Ordered_Set_Type_Proxy.Conforms_To";
return Conforms_To (Self, Other);
end Conforms_To;
-------------
-- General --
-------------
overriding function General
(Self : not null access constant OCL_Ordered_Set_Type_Proxy)
return AMF.UML.Classifiers.Collections.Set_Of_UML_Classifier is
begin
-- Generated stub: replace with real body!
pragma Compile_Time_Warning (Standard.True, "General unimplemented");
raise Program_Error with "Unimplemented procedure OCL_Ordered_Set_Type_Proxy.General";
return General (Self);
end General;
-----------------------
-- Has_Visibility_Of --
-----------------------
overriding function Has_Visibility_Of
(Self : not null access constant OCL_Ordered_Set_Type_Proxy;
N : AMF.UML.Named_Elements.UML_Named_Element_Access)
return Boolean is
begin
-- Generated stub: replace with real body!
pragma Compile_Time_Warning (Standard.True, "Has_Visibility_Of unimplemented");
raise Program_Error with "Unimplemented procedure OCL_Ordered_Set_Type_Proxy.Has_Visibility_Of";
return Has_Visibility_Of (Self, N);
end Has_Visibility_Of;
-------------------------
-- Inheritable_Members --
-------------------------
overriding function Inheritable_Members
(Self : not null access constant OCL_Ordered_Set_Type_Proxy;
C : AMF.UML.Classifiers.UML_Classifier_Access)
return AMF.UML.Named_Elements.Collections.Set_Of_UML_Named_Element is
begin
-- Generated stub: replace with real body!
pragma Compile_Time_Warning (Standard.True, "Inheritable_Members unimplemented");
raise Program_Error with "Unimplemented procedure OCL_Ordered_Set_Type_Proxy.Inheritable_Members";
return Inheritable_Members (Self, C);
end Inheritable_Members;
----------------------
-- Inherited_Member --
----------------------
overriding function Inherited_Member
(Self : not null access constant OCL_Ordered_Set_Type_Proxy)
return AMF.UML.Named_Elements.Collections.Set_Of_UML_Named_Element is
begin
-- Generated stub: replace with real body!
pragma Compile_Time_Warning (Standard.True, "Inherited_Member unimplemented");
raise Program_Error with "Unimplemented procedure OCL_Ordered_Set_Type_Proxy.Inherited_Member";
return Inherited_Member (Self);
end Inherited_Member;
-----------------
-- Is_Template --
-----------------
overriding function Is_Template
(Self : not null access constant OCL_Ordered_Set_Type_Proxy)
return Boolean is
begin
-- Generated stub: replace with real body!
pragma Compile_Time_Warning (Standard.True, "Is_Template unimplemented");
raise Program_Error with "Unimplemented procedure OCL_Ordered_Set_Type_Proxy.Is_Template";
return Is_Template (Self);
end Is_Template;
-------------------------
-- May_Specialize_Type --
-------------------------
overriding function May_Specialize_Type
(Self : not null access constant OCL_Ordered_Set_Type_Proxy;
C : AMF.UML.Classifiers.UML_Classifier_Access)
return Boolean is
begin
-- Generated stub: replace with real body!
pragma Compile_Time_Warning (Standard.True, "May_Specialize_Type unimplemented");
raise Program_Error with "Unimplemented procedure OCL_Ordered_Set_Type_Proxy.May_Specialize_Type";
return May_Specialize_Type (Self, C);
end May_Specialize_Type;
-------------
-- Parents --
-------------
overriding function Parents
(Self : not null access constant OCL_Ordered_Set_Type_Proxy)
return AMF.UML.Classifiers.Collections.Set_Of_UML_Classifier is
begin
-- Generated stub: replace with real body!
pragma Compile_Time_Warning (Standard.True, "Parents unimplemented");
raise Program_Error with "Unimplemented procedure OCL_Ordered_Set_Type_Proxy.Parents";
return Parents (Self);
end Parents;
------------------------
-- Exclude_Collisions --
------------------------
overriding function Exclude_Collisions
(Self : not null access constant OCL_Ordered_Set_Type_Proxy;
Imps : AMF.UML.Packageable_Elements.Collections.Set_Of_UML_Packageable_Element)
return AMF.UML.Packageable_Elements.Collections.Set_Of_UML_Packageable_Element is
begin
-- Generated stub: replace with real body!
pragma Compile_Time_Warning (Standard.True, "Exclude_Collisions unimplemented");
raise Program_Error with "Unimplemented procedure OCL_Ordered_Set_Type_Proxy.Exclude_Collisions";
return Exclude_Collisions (Self, Imps);
end Exclude_Collisions;
-------------------------
-- Get_Names_Of_Member --
-------------------------
overriding function Get_Names_Of_Member
(Self : not null access constant OCL_Ordered_Set_Type_Proxy;
Element : AMF.UML.Named_Elements.UML_Named_Element_Access)
return AMF.String_Collections.Set_Of_String is
begin
-- Generated stub: replace with real body!
pragma Compile_Time_Warning (Standard.True, "Get_Names_Of_Member unimplemented");
raise Program_Error with "Unimplemented procedure OCL_Ordered_Set_Type_Proxy.Get_Names_Of_Member";
return Get_Names_Of_Member (Self, Element);
end Get_Names_Of_Member;
--------------------
-- Import_Members --
--------------------
overriding function Import_Members
(Self : not null access constant OCL_Ordered_Set_Type_Proxy;
Imps : AMF.UML.Packageable_Elements.Collections.Set_Of_UML_Packageable_Element)
return AMF.UML.Packageable_Elements.Collections.Set_Of_UML_Packageable_Element is
begin
-- Generated stub: replace with real body!
pragma Compile_Time_Warning (Standard.True, "Import_Members unimplemented");
raise Program_Error with "Unimplemented procedure OCL_Ordered_Set_Type_Proxy.Import_Members";
return Import_Members (Self, Imps);
end Import_Members;
---------------------
-- Imported_Member --
---------------------
overriding function Imported_Member
(Self : not null access constant OCL_Ordered_Set_Type_Proxy)
return AMF.UML.Packageable_Elements.Collections.Set_Of_UML_Packageable_Element is
begin
-- Generated stub: replace with real body!
pragma Compile_Time_Warning (Standard.True, "Imported_Member unimplemented");
raise Program_Error with "Unimplemented procedure OCL_Ordered_Set_Type_Proxy.Imported_Member";
return Imported_Member (Self);
end Imported_Member;
---------------------------------
-- Members_Are_Distinguishable --
---------------------------------
overriding function Members_Are_Distinguishable
(Self : not null access constant OCL_Ordered_Set_Type_Proxy)
return Boolean is
begin
-- Generated stub: replace with real body!
pragma Compile_Time_Warning (Standard.True, "Members_Are_Distinguishable unimplemented");
raise Program_Error with "Unimplemented procedure OCL_Ordered_Set_Type_Proxy.Members_Are_Distinguishable";
return Members_Are_Distinguishable (Self);
end Members_Are_Distinguishable;
------------------
-- Owned_Member --
------------------
overriding function Owned_Member
(Self : not null access constant OCL_Ordered_Set_Type_Proxy)
return AMF.UML.Named_Elements.Collections.Set_Of_UML_Named_Element is
begin
-- Generated stub: replace with real body!
pragma Compile_Time_Warning (Standard.True, "Owned_Member unimplemented");
raise Program_Error with "Unimplemented procedure OCL_Ordered_Set_Type_Proxy.Owned_Member";
return Owned_Member (Self);
end Owned_Member;
--------------------
-- All_Namespaces --
--------------------
overriding function All_Namespaces
(Self : not null access constant OCL_Ordered_Set_Type_Proxy)
return AMF.UML.Namespaces.Collections.Ordered_Set_Of_UML_Namespace is
begin
-- Generated stub: replace with real body!
pragma Compile_Time_Warning (Standard.True, "All_Namespaces unimplemented");
raise Program_Error with "Unimplemented procedure OCL_Ordered_Set_Type_Proxy.All_Namespaces";
return All_Namespaces (Self);
end All_Namespaces;
-------------------------
-- All_Owning_Packages --
-------------------------
overriding function All_Owning_Packages
(Self : not null access constant OCL_Ordered_Set_Type_Proxy)
return AMF.UML.Packages.Collections.Set_Of_UML_Package is
begin
-- Generated stub: replace with real body!
pragma Compile_Time_Warning (Standard.True, "All_Owning_Packages unimplemented");
raise Program_Error with "Unimplemented procedure OCL_Ordered_Set_Type_Proxy.All_Owning_Packages";
return All_Owning_Packages (Self);
end All_Owning_Packages;
-----------------------------
-- Is_Distinguishable_From --
-----------------------------
overriding function Is_Distinguishable_From
(Self : not null access constant OCL_Ordered_Set_Type_Proxy;
N : AMF.UML.Named_Elements.UML_Named_Element_Access;
Ns : AMF.UML.Namespaces.UML_Namespace_Access)
return Boolean is
begin
-- Generated stub: replace with real body!
pragma Compile_Time_Warning (Standard.True, "Is_Distinguishable_From unimplemented");
raise Program_Error with "Unimplemented procedure OCL_Ordered_Set_Type_Proxy.Is_Distinguishable_From";
return Is_Distinguishable_From (Self, N, Ns);
end Is_Distinguishable_From;
---------------
-- Namespace --
---------------
overriding function Namespace
(Self : not null access constant OCL_Ordered_Set_Type_Proxy)
return AMF.UML.Namespaces.UML_Namespace_Access is
begin
-- Generated stub: replace with real body!
pragma Compile_Time_Warning (Standard.True, "Namespace unimplemented");
raise Program_Error with "Unimplemented procedure OCL_Ordered_Set_Type_Proxy.Namespace";
return Namespace (Self);
end Namespace;
--------------------
-- Qualified_Name --
--------------------
overriding function Qualified_Name
(Self : not null access constant OCL_Ordered_Set_Type_Proxy)
return League.Strings.Universal_String is
begin
-- Generated stub: replace with real body!
pragma Compile_Time_Warning (Standard.True, "Qualified_Name unimplemented");
raise Program_Error with "Unimplemented procedure OCL_Ordered_Set_Type_Proxy.Qualified_Name";
return Qualified_Name (Self);
end Qualified_Name;
---------------
-- Separator --
---------------
overriding function Separator
(Self : not null access constant OCL_Ordered_Set_Type_Proxy)
return League.Strings.Universal_String is
begin
-- Generated stub: replace with real body!
pragma Compile_Time_Warning (Standard.True, "Separator unimplemented");
raise Program_Error with "Unimplemented procedure OCL_Ordered_Set_Type_Proxy.Separator";
return Separator (Self);
end Separator;
------------------------
-- All_Owned_Elements --
------------------------
overriding function All_Owned_Elements
(Self : not null access constant OCL_Ordered_Set_Type_Proxy)
return AMF.UML.Elements.Collections.Set_Of_UML_Element is
begin
-- Generated stub: replace with real body!
pragma Compile_Time_Warning (Standard.True, "All_Owned_Elements unimplemented");
raise Program_Error with "Unimplemented procedure OCL_Ordered_Set_Type_Proxy.All_Owned_Elements";
return All_Owned_Elements (Self);
end All_Owned_Elements;
-------------------
-- Must_Be_Owned --
-------------------
overriding function Must_Be_Owned
(Self : not null access constant OCL_Ordered_Set_Type_Proxy)
return Boolean is
begin
-- Generated stub: replace with real body!
pragma Compile_Time_Warning (Standard.True, "Must_Be_Owned unimplemented");
raise Program_Error with "Unimplemented procedure OCL_Ordered_Set_Type_Proxy.Must_Be_Owned";
return Must_Be_Owned (Self);
end Must_Be_Owned;
-----------------
-- Conforms_To --
-----------------
overriding function Conforms_To
(Self : not null access constant OCL_Ordered_Set_Type_Proxy;
Other : AMF.UML.Types.UML_Type_Access)
return Boolean is
begin
-- Generated stub: replace with real body!
pragma Compile_Time_Warning (Standard.True, "Conforms_To unimplemented");
raise Program_Error with "Unimplemented procedure OCL_Ordered_Set_Type_Proxy.Conforms_To";
return Conforms_To (Self, Other);
end Conforms_To;
------------------------
-- Is_Compatible_With --
------------------------
overriding function Is_Compatible_With
(Self : not null access constant OCL_Ordered_Set_Type_Proxy;
P : AMF.UML.Parameterable_Elements.UML_Parameterable_Element_Access)
return Boolean is
begin
-- Generated stub: replace with real body!
pragma Compile_Time_Warning (Standard.True, "Is_Compatible_With unimplemented");
raise Program_Error with "Unimplemented procedure OCL_Ordered_Set_Type_Proxy.Is_Compatible_With";
return Is_Compatible_With (Self, P);
end Is_Compatible_With;
---------------------------
-- Is_Template_Parameter --
---------------------------
overriding function Is_Template_Parameter
(Self : not null access constant OCL_Ordered_Set_Type_Proxy)
return Boolean is
begin
-- Generated stub: replace with real body!
pragma Compile_Time_Warning (Standard.True, "Is_Template_Parameter unimplemented");
raise Program_Error with "Unimplemented procedure OCL_Ordered_Set_Type_Proxy.Is_Template_Parameter";
return Is_Template_Parameter (Self);
end Is_Template_Parameter;
----------------------------
-- Parameterable_Elements --
----------------------------
overriding function Parameterable_Elements
(Self : not null access constant OCL_Ordered_Set_Type_Proxy)
return AMF.UML.Parameterable_Elements.Collections.Set_Of_UML_Parameterable_Element is
begin
-- Generated stub: replace with real body!
pragma Compile_Time_Warning (Standard.True, "Parameterable_Elements unimplemented");
raise Program_Error with "Unimplemented procedure OCL_Ordered_Set_Type_Proxy.Parameterable_Elements";
return Parameterable_Elements (Self);
end Parameterable_Elements;
------------------------
-- Is_Consistent_With --
------------------------
overriding function Is_Consistent_With
(Self : not null access constant OCL_Ordered_Set_Type_Proxy;
Redefinee : AMF.UML.Redefinable_Elements.UML_Redefinable_Element_Access)
return Boolean is
begin
-- Generated stub: replace with real body!
pragma Compile_Time_Warning (Standard.True, "Is_Consistent_With unimplemented");
raise Program_Error with "Unimplemented procedure OCL_Ordered_Set_Type_Proxy.Is_Consistent_With";
return Is_Consistent_With (Self, Redefinee);
end Is_Consistent_With;
-----------------------------------
-- Is_Redefinition_Context_Valid --
-----------------------------------
overriding function Is_Redefinition_Context_Valid
(Self : not null access constant OCL_Ordered_Set_Type_Proxy;
Redefined : AMF.UML.Redefinable_Elements.UML_Redefinable_Element_Access)
return Boolean is
begin
-- Generated stub: replace with real body!
pragma Compile_Time_Warning (Standard.True, "Is_Redefinition_Context_Valid unimplemented");
raise Program_Error with "Unimplemented procedure OCL_Ordered_Set_Type_Proxy.Is_Redefinition_Context_Valid";
return Is_Redefinition_Context_Valid (Self, Redefined);
end Is_Redefinition_Context_Valid;
-------------------
-- Enter_Element --
-------------------
overriding procedure Enter_Element
(Self : not null access constant OCL_Ordered_Set_Type_Proxy;
Visitor : in out AMF.Visitors.Abstract_Visitor'Class;
Control : in out AMF.Visitors.Traverse_Control) is
begin
if Visitor in AMF.Visitors.OCL_Visitors.OCL_Visitor'Class then
AMF.Visitors.OCL_Visitors.OCL_Visitor'Class
(Visitor).Enter_Ordered_Set_Type
(AMF.OCL.Ordered_Set_Types.OCL_Ordered_Set_Type_Access (Self),
Control);
end if;
end Enter_Element;
-------------------
-- Leave_Element --
-------------------
overriding procedure Leave_Element
(Self : not null access constant OCL_Ordered_Set_Type_Proxy;
Visitor : in out AMF.Visitors.Abstract_Visitor'Class;
Control : in out AMF.Visitors.Traverse_Control) is
begin
if Visitor in AMF.Visitors.OCL_Visitors.OCL_Visitor'Class then
AMF.Visitors.OCL_Visitors.OCL_Visitor'Class
(Visitor).Leave_Ordered_Set_Type
(AMF.OCL.Ordered_Set_Types.OCL_Ordered_Set_Type_Access (Self),
Control);
end if;
end Leave_Element;
-------------------
-- Visit_Element --
-------------------
overriding procedure Visit_Element
(Self : not null access constant OCL_Ordered_Set_Type_Proxy;
Iterator : in out AMF.Visitors.Abstract_Iterator'Class;
Visitor : in out AMF.Visitors.Abstract_Visitor'Class;
Control : in out AMF.Visitors.Traverse_Control) is
begin
if Iterator in AMF.Visitors.OCL_Iterators.OCL_Iterator'Class then
AMF.Visitors.OCL_Iterators.OCL_Iterator'Class
(Iterator).Visit_Ordered_Set_Type
(Visitor,
AMF.OCL.Ordered_Set_Types.OCL_Ordered_Set_Type_Access (Self),
Control);
end if;
end Visit_Element;
end AMF.Internals.OCL_Ordered_Set_Types;
|
MinimSecure/unum-sdk | Ada | 797 | ads | -- Copyright 2009-2016 Free Software Foundation, Inc.
--
-- This program is free software; you can redistribute it and/or modify
-- it under the terms of the GNU General Public License as published by
-- the Free Software Foundation; either version 3 of the License, or
-- (at your option) any later version.
--
-- This program is distributed in the hope that it will be useful,
-- but WITHOUT ANY WARRANTY; without even the implied warranty of
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-- GNU General Public License for more details.
--
-- You should have received a copy of the GNU General Public License
-- along with this program. If not, see <http://www.gnu.org/licenses/>.
with System;
package Pck is
procedure Do_Nothing (A : System.Address);
end Pck;
|
zhmu/ananas | Ada | 330 | ads | package Vect11 is
-- Constrained array types are vectorizable
type Sarray is array (1 .. 4) of Float;
for Sarray'Alignment use 16;
function "+" (X, Y : Sarray) return Sarray;
procedure Add (X, Y : Sarray; R : out Sarray);
procedure Add (X, Y : not null access Sarray; R : not null access Sarray);
end Vect11;
|
zhmu/ananas | Ada | 9,395 | ads | ------------------------------------------------------------------------------
-- --
-- GNAT COMPILER COMPONENTS --
-- --
-- S Y S T E M . F I N A L I Z A T I O N _ M A S T E R S --
-- --
-- S p e c --
-- --
-- Copyright (C) 2011-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.Finalization;
with System.Storage_Elements;
with System.Storage_Pools;
package System.Finalization_Masters is
pragma Preelaborate;
-- A reference to primitive Finalize_Address. The expander generates an
-- implementation of this procedure for each controlled and class-wide
-- type. Since controlled objects are simply viewed as addresses once
-- allocated through a master, Finalize_Address provides a backward
-- indirection from an address to a type-specific context.
type Finalize_Address_Ptr is access procedure (Obj : System.Address);
-- Heterogeneous collection type structure
type FM_Node is private;
type FM_Node_Ptr is access all FM_Node;
pragma No_Strict_Aliasing (FM_Node_Ptr);
-- A reference to any derivation from Root_Storage_Pool. Since this type
-- may not be used to allocate objects, its storage size is zero.
type Any_Storage_Pool_Ptr is
access System.Storage_Pools.Root_Storage_Pool'Class;
for Any_Storage_Pool_Ptr'Storage_Size use 0;
-- Finalization master type structure. A unique master is associated with
-- each access-to-controlled or access-to-class-wide type. Masters also act
-- as components of subpools. By default, a master contains objects of the
-- same designated type but it may also accommodate heterogeneous objects.
type Finalization_Master is
new Ada.Finalization.Limited_Controlled with private;
-- A reference to a finalization master. Since this type may not be used
-- to allocate objects, its storage size is zero.
type Finalization_Master_Ptr is access all Finalization_Master;
for Finalization_Master_Ptr'Storage_Size use 0;
procedure Attach (N : not null FM_Node_Ptr; L : not null FM_Node_Ptr);
-- Compiler interface, do not call from within the run-time. Prepend a
-- node to a specific finalization master.
procedure Attach_Unprotected
(N : not null FM_Node_Ptr;
L : not null FM_Node_Ptr);
-- Prepend a node to a specific finalization master
procedure Delete_Finalize_Address_Unprotected (Obj : System.Address);
-- Destroy the relation pair object - Finalize_Address from the internal
-- hash table.
procedure Detach_Unprotected (N : not null FM_Node_Ptr);
-- Remove a node from an arbitrary finalization master
overriding procedure Finalize (Master : in out Finalization_Master);
-- Lock the master to prevent allocations during finalization. Iterate over
-- the list of allocated controlled objects, finalizing each one by calling
-- its specific Finalize_Address. In the end, deallocate the dummy head.
function Finalize_Address
(Master : Finalization_Master) return Finalize_Address_Ptr;
-- Return a reference to the TSS primitive Finalize_Address associated with
-- a master.
function Finalize_Address_Unprotected
(Obj : System.Address) return Finalize_Address_Ptr;
-- Retrieve the Finalize_Address primitive associated with a particular
-- object.
function Finalization_Started (Master : Finalization_Master) return Boolean;
-- Return the finalization status of a master
function Header_Size return System.Storage_Elements.Storage_Count;
-- Return the size of type FM_Node as Storage_Count
function Is_Homogeneous (Master : Finalization_Master) return Boolean;
-- Return the behavior flag of a master
function Objects (Master : Finalization_Master) return FM_Node_Ptr;
-- Return the header of the doubly-linked list of controlled objects
procedure Print_Master (Master : Finalization_Master);
-- Debug routine, outputs the contents of a master
procedure Set_Finalize_Address
(Master : in out Finalization_Master;
Fin_Addr_Ptr : Finalize_Address_Ptr);
-- Compiler interface, do not call from within the run-time. Set the clean
-- up routine of a finalization master
procedure Set_Finalize_Address_Unprotected
(Master : in out Finalization_Master;
Fin_Addr_Ptr : Finalize_Address_Ptr);
-- Set the clean up routine of a finalization master
procedure Set_Heterogeneous_Finalize_Address_Unprotected
(Obj : System.Address;
Fin_Addr_Ptr : Finalize_Address_Ptr);
-- Add a relation pair object - Finalize_Address to the internal hash
-- table. This is done in the context of allocation on a heterogeneous
-- finalization master where a single master services multiple anonymous
-- access-to-controlled types.
procedure Set_Is_Heterogeneous (Master : in out Finalization_Master);
-- Mark the master as being a heterogeneous collection of objects
private
-- Heterogeneous collection type structure
type FM_Node is record
Prev : FM_Node_Ptr := null;
Next : FM_Node_Ptr := null;
end record;
-- Finalization master type structure. A unique master is associated with
-- each access-to-controlled or access-to-class-wide type. Masters also act
-- as components of subpools. By default, a master contains objects of the
-- same designated type but it may also accommodate heterogeneous objects.
type Finalization_Master is
new Ada.Finalization.Limited_Controlled with
record
Is_Homogeneous : Boolean := True;
-- A flag which controls the behavior of the master. A value of False
-- denotes a heterogeneous collection.
Base_Pool : Any_Storage_Pool_Ptr := null;
-- A reference to the pool which this finalization master services. This
-- field is used in conjunction with the build-in-place machinery.
Objects : aliased FM_Node;
-- A doubly linked list which contains the headers of all controlled
-- objects allocated in a [sub]pool.
Finalize_Address : Finalize_Address_Ptr := null;
-- A reference to the routine reponsible for object finalization. This
-- is used only when the master is in homogeneous mode.
Finalization_Started : Boolean := False;
-- A flag used to detect allocations which occur during the finalization
-- of a master. The allocations must raise Program_Error. This scenario
-- may arise in a multitask environment.
end record;
-- Since RTSfind cannot contain names of the form RE_"+", the following
-- routine serves as a wrapper around System.Storage_Elements."+".
function Add_Offset_To_Address
(Addr : System.Address;
Offset : System.Storage_Elements.Storage_Offset) return System.Address;
function Base_Pool
(Master : Finalization_Master) return Any_Storage_Pool_Ptr;
-- Return a reference to the underlying storage pool on which the master
-- operates.
overriding procedure Initialize (Master : in out Finalization_Master);
-- Initialize the dummy head of a finalization master
procedure Set_Base_Pool
(Master : in out Finalization_Master;
Pool_Ptr : Any_Storage_Pool_Ptr);
-- Set the underlying pool of a finalization master
end System.Finalization_Masters;
|
reznikmm/matreshka | Ada | 4,965 | ads | ------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- Ada Modeling Framework --
-- --
-- Runtime Library Component --
-- --
------------------------------------------------------------------------------
-- --
-- Copyright © 2011-2012, Vadim Godunko <[email protected]> --
-- All rights reserved. --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions --
-- are met: --
-- --
-- * Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- --
-- * Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in the --
-- documentation and/or other materials provided with the distribution. --
-- --
-- * Neither the name of the Vadim Godunko, IE nor the names of its --
-- contributors may be used to endorse or promote products derived from --
-- this software without specific prior written permission. --
-- --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR --
-- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
-- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED --
-- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR --
-- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF --
-- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING --
-- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS --
-- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
-- --
------------------------------------------------------------------------------
-- $Revision$ $Date$
------------------------------------------------------------------------------
-- This file is generated, don't edit it.
------------------------------------------------------------------------------
with AMF.Generic_Collections;
package AMF.UML.Constraints.Collections is
pragma Preelaborate;
package UML_Constraint_Collections is
new AMF.Generic_Collections
(UML_Constraint,
UML_Constraint_Access);
type Set_Of_UML_Constraint is
new UML_Constraint_Collections.Set with null record;
Empty_Set_Of_UML_Constraint : constant Set_Of_UML_Constraint;
type Ordered_Set_Of_UML_Constraint is
new UML_Constraint_Collections.Ordered_Set with null record;
Empty_Ordered_Set_Of_UML_Constraint : constant Ordered_Set_Of_UML_Constraint;
type Bag_Of_UML_Constraint is
new UML_Constraint_Collections.Bag with null record;
Empty_Bag_Of_UML_Constraint : constant Bag_Of_UML_Constraint;
type Sequence_Of_UML_Constraint is
new UML_Constraint_Collections.Sequence with null record;
Empty_Sequence_Of_UML_Constraint : constant Sequence_Of_UML_Constraint;
private
Empty_Set_Of_UML_Constraint : constant Set_Of_UML_Constraint
:= (UML_Constraint_Collections.Set with null record);
Empty_Ordered_Set_Of_UML_Constraint : constant Ordered_Set_Of_UML_Constraint
:= (UML_Constraint_Collections.Ordered_Set with null record);
Empty_Bag_Of_UML_Constraint : constant Bag_Of_UML_Constraint
:= (UML_Constraint_Collections.Bag with null record);
Empty_Sequence_Of_UML_Constraint : constant Sequence_Of_UML_Constraint
:= (UML_Constraint_Collections.Sequence with null record);
end AMF.UML.Constraints.Collections;
|
sungyeon/drake | Ada | 3,460 | adb | with Ada.Text_IO.Editing;
procedure textioed is
type T is delta 0.001 digits 12;
package O is new Ada.Text_IO.Editing.Decimal_Output (T);
begin
-- simple
pragma Assert (
O.Image (0.0, Ada.Text_IO.Editing.To_Picture ("999.999")) =
"000.000");
pragma Assert (
O.Image (0.0, Ada.Text_IO.Editing.To_Picture ("ZZ9.999")) =
" 0.000");
pragma Assert (
O.Image (0.0, Ada.Text_IO.Editing.To_Picture ("ZZZ.999")) =
" .000");
pragma Assert (
O.Image (1.0, Ada.Text_IO.Editing.To_Picture ("ZZZ_ZZ9")) =
" 1");
pragma Assert (
O.Image (1000.0, Ada.Text_IO.Editing.To_Picture ("ZZZ_ZZ9")) =
" 1,000");
pragma Assert (
O.Image (-10.0, Ada.Text_IO.Editing.To_Picture ("++9")) =
"-10");
pragma Assert (
O.Image (10.0, Ada.Text_IO.Editing.To_Picture ("++9")) =
"+10");
pragma Assert (
O.Image (10.0, Ada.Text_IO.Editing.To_Picture ("--9")) =
" 10");
pragma Assert (
O.Image (10.0, Ada.Text_IO.Editing.To_Picture ("-9")) =
"10");
begin
declare -- overflow
Dummy : constant String :=
O.Image (1000.0, Ada.Text_IO.Editing.To_Picture ("--9"));
begin
null;
end;
raise Program_Error; -- bad
exception
when Ada.Text_IO.Layout_Error =>
null;
end;
pragma Assert (
O.Image (0.999, Ada.Text_IO.Editing.To_Picture ("9")) =
"1");
pragma Assert (
O.Image (0.999, Ada.Text_IO.Editing.To_Picture ("9.9")) =
"1.0");
pragma Assert (
O.Image (0.555, Ada.Text_IO.Editing.To_Picture ("9.9_9")) =
"0.5,6");
-- examples in RM F.3.2
S_73_3 : declare
Item : constant T := 123456.78;
Pi : constant String := "-###**_***_**9.99";
R1 : constant String := " $***123,456.78";
R2 : constant String := " FF***123.456,78";
begin
pragma Assert (O.Image (Item, Ada.Text_IO.Editing.To_Picture (Pi)) = R1);
pragma Assert (
O.Image (
Item,
Ada.Text_IO.Editing.To_Picture (Pi),
Currency => "FF",
Separator => '.',
Radix_Mark => ',') =
R2);
null;
end S_73_3;
S_74_1 : declare
Item : constant T := 123456.78;
Pi : constant String := "-$**_***_**9.99";
R1 : constant String := " $***123,456.78";
R2 : constant String := " FF***123.456,78";
begin
pragma Assert (O.Image (Item, Ada.Text_IO.Editing.To_Picture (Pi)) = R1);
pragma Assert (
O.Image (
Item,
Ada.Text_IO.Editing.To_Picture (Pi),
Currency => "FF",
Separator => '.',
Radix_Mark => ',') =
R2);
null;
end S_74_1;
S_75 : declare
Item : constant T := 0.0;
Pi : constant String := "-$$$$$$.$$";
R1 : constant String := " ";
begin
pragma Assert (O.Image (Item, Ada.Text_IO.Editing.To_Picture (Pi)) = R1);
null;
end S_75;
S_76 : declare
Item : constant T := 0.20;
Pi : constant String := "-$$$$$$.$$";
R1 : constant String := " $.20";
begin
pragma Assert (O.Image (Item, Ada.Text_IO.Editing.To_Picture (Pi)) = R1);
null;
end S_76;
S_77 : declare
Item : constant T := -1234.565;
Pi : constant String := "<<<<_<<<.<<###>";
R1 : constant String := " (1,234.57DM )";
begin
pragma Assert (
O.Image (
Item,
Ada.Text_IO.Editing.To_Picture (Pi),
Currency => "DM") =
R1);
null;
end S_77;
S_78 : declare
Item : constant T := 12345.67;
Pi : constant String := "###_###_##9.99";
R1 : constant String := " CHF12,345.67";
begin
pragma Assert (
O.Image (
Item,
Ada.Text_IO.Editing.To_Picture (Pi),
Currency => "CHF") =
R1);
null;
end S_78;
pragma Debug (Ada.Debug.Put ("OK"));
end textioed;
|
reznikmm/matreshka | Ada | 31,976 | adb | ------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- XML Processor --
-- --
-- Runtime Library Component --
-- --
------------------------------------------------------------------------------
-- --
-- Copyright © 2010-2017, Vadim Godunko <[email protected]> --
-- All rights reserved. --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions --
-- are met: --
-- --
-- * Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- --
-- * Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in the --
-- documentation and/or other materials provided with the distribution. --
-- --
-- * Neither the name of the Vadim Godunko, IE nor the names of its --
-- contributors may be used to endorse or promote products derived from --
-- this software without specific prior written permission. --
-- --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR --
-- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
-- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED --
-- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR --
-- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF --
-- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING --
-- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS --
-- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
-- --
------------------------------------------------------------------------------
-- $Revision$ $Date$
------------------------------------------------------------------------------
with League.Strings.Internals;
with Matreshka.Internals.Strings.Operations;
with XML.SAX.Simple_Readers.Callbacks;
with XML.SAX.Simple_Readers.Parser.Actions;
with XML.SAX.Simple_Readers.Parser.Tables;
with XML.SAX.Simple_Readers.Scanner;
package body XML.SAX.Simple_Readers.Parser is
use Matreshka.Internals.XML;
use XML.SAX.Simple_Readers.Parser.Tables;
function YY_Goto_State (State : Integer; Sym : Integer) return Integer;
-- Lookup for next state.
function YY_Parse_Action (State : Natural; T : Token) return Integer;
-- Lookup for parser action.
procedure Process_Comment
(Self : in out Simple_Reader'Class;
Comment : League.Strings.Universal_String);
-- Process comment in the document.
procedure Process_External_Id
(Self : in out Simple_Reader'Class;
Public_Id : League.Strings.Universal_String;
System_Id : League.Strings.Universal_String);
-- Process external id declaration.
----------------
-- Initialize --
----------------
procedure Initialize (State : in out Parser_State_Information) is
begin
-- Initialize by pushing state 0 and getting the first input symbol.
State.TOS := 0;
State.State_Stack (State.TOS) := 0;
State.Look_Ahead := True;
end Initialize;
---------------------
-- Process_Comment --
---------------------
procedure Process_Comment
(Self : in out Simple_Reader'Class;
Comment : League.Strings.Universal_String) is
begin
Callbacks.Call_Comment (Self, Comment);
end Process_Comment;
-------------------------
-- Process_External_Id --
-------------------------
procedure Process_External_Id
(Self : in out Simple_Reader'Class;
Public_Id : League.Strings.Universal_String;
System_Id : League.Strings.Universal_String) is
begin
Self.Public_Id := Public_Id;
Self.System_Id := System_Id;
end Process_External_Id;
-------------------
-- YY_Goto_State --
-------------------
function YY_Goto_State (State : Integer; Sym : Integer) return Integer is
Index : Integer := YY_Goto_Offset (State);
begin
while YY_Goto_Matrix (Index).Nonterm /= Sym loop
Index := Index + 1;
end loop;
return YY_Goto_Matrix (Index).Newstate;
end YY_Goto_State;
---------------------
-- YY_Parse_Action --
---------------------
function YY_Parse_Action (State : Natural; T : Token) return Integer is
Tok_Pos : constant Integer := Token'Pos (T);
Index : Integer := YY_Shift_Reduce_Offset (State);
begin
while YY_Shift_Reduce_Matrix (Index).T /= Tok_Pos
and then YY_Shift_Reduce_Matrix (Index).T /= YY_Default
loop
Index := Index + 1;
end loop;
return YY_Shift_Reduce_Matrix (Index).Act;
end YY_Parse_Action;
-------------
-- YYParse --
-------------
procedure YYParse (Self : in out Simple_Reader) is
YY : Parser_State_Information renames Self.Parser_State;
-- procedure yyerrok;
-- procedure yyclearin;
---- error recovery stuff
procedure Handle_Error;
-- Handles error state.
-- procedure On_Fatal_Error;
-- -- Handles fatal error.
------------------
-- Handle_Error --
------------------
procedure Handle_Error is
YY_Action : Integer;
begin
-- XXX Code of this subprogram as well as relevant code in shift
-- operation handling must be reviewed, because actually there
-- are no error recovery features used for now. Primary purpose
-- of this subprogram is to pop all elements from parser stack.
if YY.Error then
raise Program_Error with "error recovery clobber";
end if;
-- if yy.error_flag = 3 then -- no shift yet, clobber input.
-- if yy.input_symbol = yy_tokens.end_of_input then -- don't discard,
-- raise yy_tokens.syntax_error;
-- end if;
--
-- yy.look_ahead := true; -- get next token
--
-- return; -- and try again...
-- end if;
--
-- if yy.error_flag = 0 then -- brand new error
-- yyerror("Syntax Error");
-- end if;
--
-- yy.error_flag := 3;
YY.Error := True;
Self.Continue := True;
-- Find state on stack where error is a valid shift.
loop
YY_Action := YY_Parse_Action (YY.State_Stack (YY.TOS), Error);
if YY_Action >= YY_First_Shift_Entry then
YY.TOS := YY.TOS + 1;
YY.State_Stack (YY.TOS) := YY_Action;
raise Program_Error with "unsupported";
-- exit;
end if;
if YY.TOS > 0 then
-- Clear top element on the value stack.
Clear (YY.Value_Stack (YY.TOS));
YY.TOS := YY.TOS - 1;
end if;
if YY.TOS = 0 then
Actions.On_End_Of_Document (Self);
return;
end if;
end loop;
end Handle_Error;
-- -- make the parser believe that 3 valid shifts have occured.
-- -- used for error recovery.
-- procedure yyerrok is
-- begin
-- yy.error_flag := 0;
-- end yyerrok;
--
-- -- called to clear input symbol that caused an error.
-- procedure yyclearin is
-- begin
-- -- yy.input_symbol := yylex;
-- yy.look_ahead := true;
-- end yyclearin;
-- --------------------
-- -- On_Fatal_Error --
-- --------------------
--
-- procedure On_Fatal_Error is
-- begin
-- YY.Input_Symbol := End_Of_Input;
-- YY.Look_Ahead := False;
-- YY.Error := False;
-- end On_Fatal_Error;
YY_Action : Integer;
YY_Rule_Id : Integer;
YY_Index : Integer;
YY_TOS_Old : Natural;
YYVal : YYSType;
begin
loop
YY_Index := YY_Shift_Reduce_Offset (YY.State_Stack (YY.TOS));
if YY_Shift_Reduce_Matrix (YY_Index).T = YY_Default then
YY_Action := YY_Shift_Reduce_Matrix (YY_Index).Act;
else
if YY.Look_Ahead then
YY.Input_Symbol := Scanner.YYLex (Self);
if YY.Input_Symbol = End_Of_Chunk then
return;
end if;
YY.Look_Ahead := False;
end if;
YY_Action :=
YY_Parse_Action (YY.State_Stack (YY.TOS), YY.Input_Symbol);
end if;
if YY_Action >= YY_First_Shift_Entry then -- SHIFT
-- Enter new state.
YY.TOS := YY.TOS + 1;
YY.State_Stack (YY.TOS) := YY_Action;
Move (YY.Value_Stack (YY.TOS), Self.YYLVal);
YY.Error := False;
-- if yy.error_flag > 0 then -- indicate a valid shift
-- yy.error_flag := yy.error_flag - 1;
-- end if;
-- Advance lookahead.
YY.Look_Ahead := True;
elsif YY_Action = YY_Error_Code then -- ERROR
if not Self.Error_Reported then
Callbacks.Call_Fatal_Error
(Self,
League.Strings.To_Universal_String ("syntax error"));
Self.Continue := False;
end if;
Handle_Error;
exit;
elsif YY_Action = YY_Accept_Code then
-- Accepting grammar.
Actions.On_End_Of_Document (Self);
exit;
else -- REDUCE
-- Convert action into a rule.
YY_Rule_Id := -YY_Action;
-- Execute User Action.
if Self.Continue then
-- When scanner reports fatal error it sets Self.Continue to
-- False. Thus, parser action must not be executed at all.
case YY_Rule_Id is
pragma Style_Checks ("M127");
when 1 =>
Actions.On_Start_Of_Document (Self);
when 2 =>
null;
when 3 =>
null;
when 4 =>
null;
when 5 =>
null;
when 6 =>
Actions.On_XML_Declaration
(Self, YY.Value_Stack (YY.TOS - 5).String, YY.Value_Stack (YY.TOS - 2).String);
when 7 =>
Actions.On_XML_Declaration
(Self, YY.Value_Stack (YY.TOS - 2).String, Matreshka.Internals.Strings.Shared_Empty'Access);
when 8 =>
-- [XML1.0 2.8]
--
-- "Note: When an XML 1.0 processor encounters a document that
-- specifies a 1.x version number other than '1.0', it will process
-- it as a 1.0 document. This means that an XML 1.0 processor will
-- accept 1.x documents provided they do not use any non-1.0
-- features."
--
-- [XML1.1 4.3.4]
--
-- "Each entity, including the document entity, can be separately
-- declared as XML 1.0 or XML 1.1. The version declaration appearing
-- in the document entity determines the version of the document as a
-- whole. An XML 1.1 document may invoke XML 1.0 external entities,
-- so that otherwise duplicated versions of external entities,
-- particularly DTD external subsets, need not be maintained.
-- However, in such a case the rules of XML 1.1 are applied to the
-- entire document."
Actions.On_Text_Declaration
(Self,
YY.Value_Stack (YY.TOS - 4).String,
YY.Value_Stack (YY.TOS - 1).String);
when 9 =>
Actions.On_Text_Declaration
(Self,
Matreshka.Internals.Strings.Shared_Empty'Access,
YY.Value_Stack (YY.TOS - 1).String);
when 10 =>
Actions.On_Standalone (Self, YY.Value_Stack (YY.TOS).String);
when 11 =>
null;
when 12 =>
null;
when 13 =>
null;
when 14 =>
null;
when 15 =>
Process_Comment
(Self,
League.Strings.Internals.Create
(YY.Value_Stack (YY.TOS).String));
when 16 =>
null;
when 17 =>
Actions.On_Processing_Instruction
(Self,
YY.Value_Stack (YY.TOS - 1).Symbol,
YY.Value_Stack (YY.TOS).String);
when 18 =>
-- Document type declaration, rule [28]. Once external identifier are
-- recognized external document type declaration subset need to be parsed
-- after processing of internal subset. External subset is inserted
-- immediately after the internal subset. Thus original rule [28] is
-- rewritten and extended to reflect this inclusion.
Actions.On_Start_Of_Document_Type_Declaration
(Self,
YY.Value_Stack (YY.TOS - 1).Symbol,
True);
when 19 =>
Actions.On_End_Of_Document_Type_Declaration (Self);
when 20 =>
null;
when 21 =>
Actions.On_Start_Of_Document_Type_Declaration
(Self,
YY.Value_Stack (YY.TOS).Symbol,
False);
when 22 =>
-- Document type declaration, rule [28].
Actions.On_End_Of_Document_Type_Declaration (Self);
when 23 =>
null;
when 24 =>
Actions.On_No_Document_Type_Declaration (Self);
when 25 =>
-- ExternalID specified by SYSTEM, rule [75].
Process_External_Id
(Self,
League.Strings.Empty_Universal_String,
League.Strings.Internals.Create
(YY.Value_Stack (YY.TOS).String));
when 26 =>
-- ExternalID specified by PUBLIC, rule [75].
Process_External_Id
(Self,
League.Strings.Internals.Create
(YY.Value_Stack (YY.TOS - 1).String),
League.Strings.Internals.Create
(YY.Value_Stack (YY.TOS).String));
when 27 =>
null;
when 28 =>
null;
when 29 =>
null;
when 30 =>
null;
when 31 =>
null;
when 32 =>
null;
when 33 =>
null;
when 34 =>
null;
when 35 =>
null;
when 36 =>
null;
when 37 =>
Process_Comment
(Self,
League.Strings.Internals.Create
(YY.Value_Stack (YY.TOS).String));
when 38 =>
null;
when 39 =>
-- Text declaration comes from external subset or external entity.
null;
when 40 =>
-- Conditional sections can be used in external entities only, but
-- external paramete entity reference can insert conditional sections
-- from external entity into the internal subset. This situation is
-- handled by the scanner.
null;
when 41 =>
-- [XML [WFC: PE Between Declarations]]
--
-- "The replacement text of a parameter entity reference in a DeclSep
-- MUST match the production extSubsetDecl."
--
-- This production is used to enforce this check.
null;
when 42 =>
Actions.On_Notation_Declaration
(Self,
YY.Value_Stack (YY.TOS - 3).Symbol,
Matreshka.Internals.Strings.Shared_Empty'Access,
YY.Value_Stack (YY.TOS - 1).String);
when 43 =>
Actions.On_Notation_Declaration
(Self,
YY.Value_Stack (YY.TOS - 3).Symbol,
YY.Value_Stack (YY.TOS - 1).String,
Matreshka.Internals.Strings.Shared_Empty'Access);
when 44 =>
Actions.On_Notation_Declaration
(Self,
YY.Value_Stack (YY.TOS - 4).Symbol,
YY.Value_Stack (YY.TOS - 2).String,
YY.Value_Stack (YY.TOS - 1).String);
when 45 =>
Actions.On_General_Entity_Declaration
(Self => Self,
Symbol => YY.Value_Stack (YY.TOS - 2).Symbol,
Is_External => False,
Value =>
League.Strings.Internals.Create
(YY.Value_Stack (YY.TOS - 1).String),
Notation => Matreshka.Internals.XML.No_Symbol);
when 46 =>
Actions.On_General_Entity_Declaration
(Self => Self,
Symbol => YY.Value_Stack (YY.TOS - 2).Symbol,
Is_External => True,
Value => League.Strings.Empty_Universal_String,
Notation => Matreshka.Internals.XML.No_Symbol);
when 47 =>
Actions.On_General_Entity_Declaration
(Self => Self,
Symbol => YY.Value_Stack (YY.TOS - 4).Symbol,
Is_External => True,
Value => League.Strings.Empty_Universal_String,
Notation => YY.Value_Stack (YY.TOS - 1).Symbol);
when 48 =>
Actions.On_Parameter_Entity_Declaration
(Self,
YY.Value_Stack (YY.TOS - 2).Symbol,
False,
League.Strings.Internals.Create
(YY.Value_Stack (YY.TOS - 1).String));
when 49 =>
Actions.On_Parameter_Entity_Declaration
(Self,
YY.Value_Stack (YY.TOS - 2).Symbol,
True,
League.Strings.Empty_Universal_String);
when 50 =>
-- Entity value including surrounding delimiters.
Move (YYVal, YY.Value_Stack (YY.TOS - 1));
when 51 =>
-- Additional string segment in entity value.
Move
(YYVal,
YY.Value_Stack (YY.TOS - 1));
Matreshka.Internals.Strings.Operations.Append
(YYVal.String,
YY.Value_Stack (YY.TOS).String);
when 52 =>
-- Single string segment in entity value.
Move
(YYVal,
YY.Value_Stack (YY.TOS));
when 53 =>
Set_String
(Item => YYVal,
String => League.Strings.Empty_Universal_String,
Is_Whitespace => False);
when 54 =>
Actions.On_Start_Of_Element_Declaration
(Self,
YY.Value_Stack (YY.TOS).Symbol);
when 55 =>
null;
when 56 =>
Actions.On_Empty_Declaration (Self);
when 57 =>
Actions.On_Any_Declaration (Self);
when 58 =>
null;
when 59 =>
null;
when 60 =>
null;
when 61 =>
null;
when 62 =>
null;
when 63 =>
null;
when 64 =>
null;
when 65 =>
null;
when 66 =>
null;
when 67 =>
null;
when 68 =>
null;
when 69 =>
null;
when 70 =>
null;
when 71 =>
null;
when 72 =>
null;
when 73 =>
null;
when 74 =>
null;
when 75 =>
null;
when 76 =>
null;
when 77 =>
null;
when 78 =>
null;
when 79 =>
null;
when 80 =>
null;
when 81 =>
null;
when 82 =>
null;
when 83 =>
null;
when 84 =>
null;
when 85 =>
null;
when 86 =>
Actions.On_Mixed_Content_Declaration (Self, True);
when 87 =>
-- Mixed_content is added here to allow ayacc to generate usable code.
-- Asterisk can be omitted only when Mixed_content is empty, this check
-- is done in handling subprogram.
Actions.On_Mixed_Content_Declaration (Self, False);
when 88 =>
null;
when 89 =>
Actions.On_Name_In_Mixed_Content_Declaration (Self);
when 90 =>
null;
when 91 =>
Actions.On_Start_Of_Attribute_List_Declaration
(Self,
YY.Value_Stack (YY.TOS).Symbol);
when 92 =>
null;
when 93 =>
null;
when 94 =>
null;
when 95 =>
null;
when 96 =>
Actions.On_CDATA_Attribute_Declaration
(Self => Self,
Symbol => YY.Value_Stack (YY.TOS - 1).Symbol);
when 97 =>
null;
when 98 =>
Actions.On_Id_Attribute_Declaration
(Self => Self,
Symbol => YY.Value_Stack (YY.TOS - 1).Symbol);
when 99 =>
null;
when 100 =>
Actions.On_IdRef_Attribute_Declaration
(Self => Self,
Symbol => YY.Value_Stack (YY.TOS - 1).Symbol);
when 101 =>
null;
when 102 =>
Actions.On_IdRefs_Attribute_Declaration
(Self => Self,
Symbol => YY.Value_Stack (YY.TOS - 1).Symbol);
when 103 =>
null;
when 104 =>
Actions.On_Entity_Attribute_Declaration
(Self => Self,
Symbol => YY.Value_Stack (YY.TOS - 1).Symbol);
when 105 =>
null;
when 106 =>
Actions.On_Entities_Attribute_Declaration
(Self => Self,
Symbol => YY.Value_Stack (YY.TOS - 1).Symbol);
when 107 =>
null;
when 108 =>
Actions.On_NmToken_Attribute_Declaration
(Self => Self,
Symbol => YY.Value_Stack (YY.TOS - 1).Symbol);
when 109 =>
null;
when 110 =>
Actions.On_NmTokens_Attribute_Declaration
(Self => Self,
Symbol => YY.Value_Stack (YY.TOS - 1).Symbol);
when 111 =>
null;
when 112 =>
Actions.On_Notation_Attribute_Declaration
(Self => Self,
Symbol => YY.Value_Stack (YY.TOS - 1).Symbol);
when 113 =>
null;
when 114 =>
Actions.On_Enumeration_Attribute_Declaration
(Self => Self,
Symbol => YY.Value_Stack (YY.TOS).Symbol);
when 115 =>
null;
when 116 =>
null;
when 117 =>
null;
when 118 =>
null;
when 119 =>
null;
when 120 =>
null;
when 121 =>
null;
when 122 =>
null;
when 123 =>
null;
when 124 =>
null;
when 125 =>
null;
when 126 =>
null;
when 127 =>
null;
when 128 =>
null;
when 129 =>
null;
when 130 =>
null;
when 131 =>
null;
when 132 =>
null;
when 133 =>
null;
when 134 =>
null;
when 135 =>
null;
when 136 =>
Actions.On_Required_Attribute_Default_Declaration (Self);
when 137 =>
Actions.On_Implied_Attribute_Default_Declaration (Self);
when 138 =>
Actions.On_Fixed_Attribute_Default_Declaration
(Self,
YY.Value_Stack (YY.TOS).String);
when 139 =>
Actions.On_Attribute_Default_Declaration
(Self,
YY.Value_Stack (YY.TOS).String);
when 140 =>
Actions.On_Open_Of_Tag
(Self,
YY.Value_Stack (YY.TOS).Symbol);
when 141 =>
null;
when 142 =>
Actions.On_Start_Tag (Self);
when 143 =>
Actions.On_End_Tag
(Self,
YY.Value_Stack (YY.TOS - 1).Symbol);
when 144 =>
Actions.On_Empty_Element_Tag (Self);
when 145 =>
null;
when 146 =>
null;
when 147 =>
null;
when 148 =>
null;
when 149 =>
Actions.On_Character_Data
(Self,
YY.Value_Stack (YY.TOS).String,
YY.Value_Stack (YY.TOS).Is_Whitespace);
when 150 =>
Actions.On_CDATA_Open (Self);
Actions.On_Character_Data
(Self,
YY.Value_Stack (YY.TOS).String,
YY.Value_Stack (YY.TOS).Is_Whitespace);
when 151 =>
Actions.On_CDATA_Close (Self);
when 152 =>
Actions.On_CDATA_Open (Self);
Actions.On_CDATA_Close (Self);
when 153 =>
Process_Comment
(Self,
League.Strings.Internals.Create
(YY.Value_Stack (YY.TOS).String));
when 154 =>
null;
when 155 =>
-- TextDecl come from substitution of external parsed entities.
null;
when 156 =>
-- Synthetic rule to check validity of entity boundaries.
null;
when 157 =>
Actions.On_Element_Attribute_Name (Self, YY.Value_Stack (YY.TOS).Symbol);
when 158 =>
Actions.On_Element_Attribute
(Self,
YY.Value_Stack (YY.TOS - 3).Symbol,
YY.Value_Stack (YY.TOS).String);
when 159 =>
Actions.On_Element_Attribute_Name
(Self,
YY.Value_Stack (YY.TOS).Symbol);
when 160 =>
Actions.On_Element_Attribute
(Self,
YY.Value_Stack (YY.TOS - 3).Symbol,
YY.Value_Stack (YY.TOS).String);
when 161 =>
null;
pragma Style_Checks ("M79");
when others =>
raise Program_Error
with "Unhandled state"
& Integer'Image (YY_Rule_Id) & " in parser";
end case;
end if;
-- Pop RHS states and goto next state.
YY_TOS_Old := YY.TOS;
YY.TOS := YY.TOS - YY_Rule_Length (YY_Rule_Id) + 1;
YY.State_Stack (YY.TOS) :=
YY_Goto_State
(YY.State_Stack (YY.TOS - 1), YY_Get_LHS_Rule (YY_Rule_Id));
-- Clear poped elements of the value stack.
for J in YY.TOS .. YY_TOS_Old loop
Clear (YY.Value_Stack (J));
end loop;
Move (YY.Value_Stack (YY.TOS), YYVal);
-- Exit loop on user request or on unrecoverable error.
if not Self.Continue then
YY.Input_Symbol := Error;
YY.Look_Ahead := False;
Self.Continue := True;
end if;
end if;
end loop;
end YYParse;
end XML.SAX.Simple_Readers.Parser;
|
charlie5/cBound | Ada | 635 | ads | -- This file is generated by SWIG. Please do *not* modify by hand.
--
with gmp_c.a_a_mpq_struct;
with Interfaces.C;
package gmp_c.mpq_srcptr is
-- Item
--
subtype Item is gmp_c.a_a_mpq_struct.Pointer;
-- Items
--
type Items is
array (Interfaces.C.size_t range <>) of aliased gmp_c.mpq_srcptr.Item;
-- Pointer
--
type Pointer is access all gmp_c.mpq_srcptr.Item;
-- Pointers
--
type Pointers is
array (Interfaces.C.size_t range <>) of aliased gmp_c.mpq_srcptr.Pointer;
-- Pointer_Pointer
--
type Pointer_Pointer is access all gmp_c.mpq_srcptr.Pointer;
end gmp_c.mpq_srcptr;
|
stcarrez/ada-servlet | Ada | 2,576 | adb | -----------------------------------------------------------------------
-- servlet-parts-web -- Servlet Parts on top of AWS attachments
-- Copyright (C) 2011, 2012, 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 AWS.Attachments.Extend;
package body Servlet.Parts.Web is
-- ------------------------------
-- Get the size of the mime part.
-- ------------------------------
overriding
function Get_Size (Data : in AWS_Part) return Natural is
begin
return AWS.Attachments.Extend.Get_Length (Data.Element);
end Get_Size;
-- ------------------------------
-- Get the content name submitted in the mime part.
-- ------------------------------
overriding
function Get_Name (Data : in AWS_Part) return String is
begin
return AWS.Attachments.Filename (Data.Element);
end Get_Name;
-- ------------------------------
-- Get the path of the local file which contains the part.
-- ------------------------------
overriding
function Get_Local_Filename (Data : in AWS_Part) return String is
begin
return AWS.Attachments.Local_Filename (Data.Element);
end Get_Local_Filename;
-- ------------------------------
-- Get the content type of the part.
-- ------------------------------
overriding
function Get_Content_Type (Data : in AWS_Part) return String is
begin
return AWS.Attachments.Content_Type (Data.Element);
end Get_Content_Type;
-- ------------------------------
-- Build a part instance from the AWS attachment and execute the <b>Process</b> operation.
-- ------------------------------
procedure Process_Part (Part : in AWS.Attachments.Element;
Process : not null access procedure (Part : in Parts.Part'Class)) is
P : AWS_Part;
begin
P.Element := Part;
Process (P);
end Process_Part;
end Servlet.Parts.Web;
|
reznikmm/matreshka | Ada | 3,781 | adb | ------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- Open Document Toolkit --
-- --
-- Runtime Library Component --
-- --
------------------------------------------------------------------------------
-- --
-- Copyright © 2013, Vadim Godunko <[email protected]> --
-- All rights reserved. --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions --
-- are met: --
-- --
-- * Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- --
-- * Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in the --
-- documentation and/or other materials provided with the distribution. --
-- --
-- * Neither the name of the Vadim Godunko, IE nor the names of its --
-- contributors may be used to endorse or promote products derived from --
-- this software without specific prior written permission. --
-- --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR --
-- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
-- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED --
-- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR --
-- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF --
-- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING --
-- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS --
-- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
-- --
------------------------------------------------------------------------------
-- $Revision$ $Date$
------------------------------------------------------------------------------
with ODF.Constants;
package body Matreshka.ODF_Attributes.Style.Flow_With_Text is
--------------------
-- Get_Local_Name --
--------------------
overriding function Get_Local_Name
(Self : not null access constant Style_Flow_With_Text_Node)
return League.Strings.Universal_String is
begin
return ODF.Constants.Flow_With_Text_Name;
end Get_Local_Name;
end Matreshka.ODF_Attributes.Style.Flow_With_Text;
|
AdaCore/training_material | Ada | 341 | ads | with Surfaces;
with Ada.Streams.Stream_IO; use Ada.Streams.Stream_IO;
package BMP_File_IO is
function Get (File : File_Type) return Surfaces.Surface_T;
-- Get the BMP file content from a file type
function Get (File_Name : String) return Surfaces.Surface_T;
-- Get the BMP file content from its name on disk
end BMP_File_IO;
|
onox/orka | Ada | 1,818 | adb | -- SPDX-License-Identifier: Apache-2.0
--
-- Copyright (c) 2017 onox <[email protected]>
--
-- Licensed under the Apache License, Version 2.0 (the "License");
-- you may not use this file except in compliance with the License.
-- You may obtain a copy of the License at
--
-- http://www.apache.org/licenses/LICENSE-2.0
--
-- Unless required by applicable law or agreed to in writing, software
-- distributed under the License is distributed on an "AS IS" BASIS,
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-- See the License for the specific language governing permissions and
-- limitations under the License.
package body Orka.Containers.Ring_Buffers is
function Length (Container : Buffer) return Natural is
(Container.Count);
function Is_Empty (Container : Buffer) return Boolean is
(Length (Container) = 0);
function Is_Full (Container : Buffer) return Boolean is
(Length (Container) = Container.Capacity);
procedure Add_Last (Container : in out Buffer; Element : Element_Type) is
begin
Container.Elements (Container.Head) := Element;
Container.Head := (Container.Head mod Container.Capacity) + 1;
Container.Count := Container.Count + 1;
end Add_Last;
function Remove_First (Container : in out Buffer) return Element_Type is
Result : constant Element_Type := Container.Elements (Container.Tail);
begin
-- Make position in buffer null to fix references in case Element_Type
-- is/contains a controlled type
Container.Elements (Container.Tail .. Container.Tail) := (others => <>);
Container.Tail := (Container.Tail mod Container.Capacity) + 1;
Container.Count := Container.Count - 1;
return Result;
end Remove_First;
end Orka.Containers.Ring_Buffers;
|
reznikmm/matreshka | Ada | 5,042 | ads | ------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- Ada Modeling Framework --
-- --
-- Runtime Library Component --
-- --
------------------------------------------------------------------------------
-- --
-- Copyright © 2012-2013, Vadim Godunko <[email protected]> --
-- All rights reserved. --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions --
-- are met: --
-- --
-- * Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- --
-- * Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in the --
-- documentation and/or other materials provided with the distribution. --
-- --
-- * Neither the name of the Vadim Godunko, IE nor the names of its --
-- contributors may be used to endorse or promote products derived from --
-- this software without specific prior written permission. --
-- --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR --
-- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
-- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED --
-- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR --
-- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF --
-- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING --
-- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS --
-- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
-- --
------------------------------------------------------------------------------
-- $Revision$ $Date$
------------------------------------------------------------------------------
-- This file is generated, don't edit it.
------------------------------------------------------------------------------
with AMF.OCL.Ocl_Expressions;
package AMF.OCL.If_Exps is
pragma Preelaborate;
type OCL_If_Exp is limited interface
and AMF.OCL.Ocl_Expressions.OCL_Ocl_Expression;
type OCL_If_Exp_Access is
access all OCL_If_Exp'Class;
for OCL_If_Exp_Access'Storage_Size use 0;
not overriding function Get_Condition
(Self : not null access constant OCL_If_Exp)
return AMF.OCL.Ocl_Expressions.OCL_Ocl_Expression_Access is abstract;
-- Getter of IfExp::condition.
--
not overriding procedure Set_Condition
(Self : not null access OCL_If_Exp;
To : AMF.OCL.Ocl_Expressions.OCL_Ocl_Expression_Access) is abstract;
-- Setter of IfExp::condition.
--
not overriding function Get_Then_Expression
(Self : not null access constant OCL_If_Exp)
return AMF.OCL.Ocl_Expressions.OCL_Ocl_Expression_Access is abstract;
-- Getter of IfExp::thenExpression.
--
not overriding procedure Set_Then_Expression
(Self : not null access OCL_If_Exp;
To : AMF.OCL.Ocl_Expressions.OCL_Ocl_Expression_Access) is abstract;
-- Setter of IfExp::thenExpression.
--
not overriding function Get_Else_Expression
(Self : not null access constant OCL_If_Exp)
return AMF.OCL.Ocl_Expressions.OCL_Ocl_Expression_Access is abstract;
-- Getter of IfExp::elseExpression.
--
not overriding procedure Set_Else_Expression
(Self : not null access OCL_If_Exp;
To : AMF.OCL.Ocl_Expressions.OCL_Ocl_Expression_Access) is abstract;
-- Setter of IfExp::elseExpression.
--
end AMF.OCL.If_Exps;
|
stcarrez/dynamo | Ada | 2,223 | ads | -----------------------------------------------------------------------
-- gen-artifacts-query -- Query artifact for Code Generator
-- Copyright (C) 2011, 2012, 2021 Stephane Carrez
-- Written by Stephane Carrez ([email protected])
--
-- Licensed under the Apache License, Version 2.0 (the "License");
-- you may not use this file except in compliance with the License.
-- You may obtain a copy of the License at
--
-- http://www.apache.org/licenses/LICENSE-2.0
--
-- Unless required by applicable law or agreed to in writing, software
-- distributed under the License is distributed on an "AS IS" BASIS,
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-- See the License for the specific language governing permissions and
-- limitations under the License.
-----------------------------------------------------------------------
with DOM.Core;
with Gen.Model.Packages;
-- The <b>Gen.Artifacts.Query</b> package is an artifact for the generation of
-- data structures returned by queries.
package Gen.Artifacts.Query is
-- ------------------------------
-- Query artifact
-- ------------------------------
type Artifact is new Gen.Artifacts.Artifact with private;
-- After the configuration file is read, processes the node whose root
-- is passed in <b>Node</b> and initializes the <b>Model</b> with the information.
overriding
procedure Initialize (Handler : in out Artifact;
Path : in String;
Node : in DOM.Core.Node;
Model : in out Gen.Model.Packages.Model_Definition'Class;
Context : in out Generator'Class);
-- Prepare the model after all the configuration files have been read and before
-- actually invoking the generation.
overriding
procedure Prepare (Handler : in out Artifact;
Model : in out Gen.Model.Packages.Model_Definition'Class;
Project : in out Gen.Model.Projects.Project_Definition'Class;
Context : in out Generator'Class);
private
type Artifact is new Gen.Artifacts.Artifact with null record;
end Gen.Artifacts.Query;
|
reznikmm/matreshka | Ada | 3,606 | ads | ------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- Ada Modeling Framework --
-- --
-- Runtime Library Component --
-- --
------------------------------------------------------------------------------
-- --
-- Copyright © 2012, Vadim Godunko <[email protected]> --
-- All rights reserved. --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions --
-- are met: --
-- --
-- * Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- --
-- * Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in the --
-- documentation and/or other materials provided with the distribution. --
-- --
-- * Neither the name of the Vadim Godunko, IE nor the names of its --
-- contributors may be used to endorse or promote products derived from --
-- this software without specific prior written permission. --
-- --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR --
-- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
-- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED --
-- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR --
-- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF --
-- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING --
-- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS --
-- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
-- --
------------------------------------------------------------------------------
-- $Revision$ $Date$
------------------------------------------------------------------------------
-- This file is generated, don't edit it.
------------------------------------------------------------------------------
with AMF.Elements.Generic_Hash;
function AMF.Utp.Determ_Alts.Hash is
new AMF.Elements.Generic_Hash (Utp_Determ_Alt, Utp_Determ_Alt_Access);
|
strenkml/EE368 | Ada | 3,745 | adb |
with Device; use Device;
with Memory.Container; use Memory.Container;
package body Memory.Transform.Offset is
function Create_Offset return Offset_Pointer is
result : constant Offset_Pointer := new Offset_Type;
begin
return result;
end Create_Offset;
function Random_Offset(next : access Memory_Type'Class;
generator : Distribution_Type;
max_cost : Cost_Type) return Memory_Pointer is
result : constant Offset_Pointer := Create_Offset;
wsize : constant Positive := Get_Word_Size(next.all);
lwsize : constant Long_Integer := Long_Integer(wsize);
rand : constant Natural := Random(generator);
begin
Set_Memory(result.all, next);
if (rand mod 2) = 0 then
-- Byte offset.
result.value := Long_Integer(Random(generator)) mod lwsize;
if ((rand / 2) mod 2) = 0 then
result.value := -result.value;
end if;
else
-- Word offset.
declare
temp : constant Address_Type := Random_Address(generator, wsize);
begin
if temp > Address_Type(Long_Integer'Last) then
result.value := -Long_Integer(-temp);
else
result.value := Long_Integer(temp);
end if;
end;
end if;
return Memory_Pointer(result);
end Random_Offset;
function Clone(mem : Offset_Type) return Memory_Pointer is
result : constant Offset_Pointer := new Offset_Type'(mem);
begin
return Memory_Pointer(result);
end Clone;
procedure Permute(mem : in out Offset_Type;
generator : in Distribution_Type;
max_cost : in Cost_Type) is
wsize : constant Positive := Get_Word_Size(mem);
lwsize : constant Long_Integer := Long_Integer(wsize);
rand : constant Natural := Random(generator);
begin
if abs(mem.value) < Long_Integer(wsize) then
mem.value := Long_Integer(Random(generator)) mod lwsize;
if ((rand / 2) mod 2) = 0 then
mem.value := -mem.value;
end if;
else
declare
temp : constant Address_Type := Random_Address(generator, wsize);
begin
if temp > Address_Type(Long_Integer'Last) then
mem.value := -Long_Integer(-temp);
else
mem.value := Long_Integer(temp);
end if;
end;
end if;
end Permute;
function Get_Name(mem : Offset_Type) return String is
begin
return "offset";
end Get_Name;
function Apply(mem : Offset_Type;
address : Address_Type;
dir : Boolean) return Address_Type is
offset : Address_Type;
begin
if mem.value < 0 then
offset := 0 - Address_Type(-mem.value);
else
offset := Address_Type(mem.value);
end if;
if dir then
return address + offset;
else
return address - offset;
end if;
end Apply;
function Is_Empty(mem : Offset_Type) return Boolean is
begin
return mem.value = 0;
end Is_Empty;
function Get_Alignment(mem : Offset_Type) return Positive is
alignment : Positive := 1;
wsize : constant Positive := Get_Word_Size(mem);
begin
while (mem.value mod Long_Integer(alignment)) = 0 and
alignment < wsize loop
alignment := alignment * 2;
end loop;
return alignment;
end Get_Alignment;
function Get_Transform_Length(mem : Offset_Type) return Natural is
begin
return Get_Address_Bits;
end Get_Transform_Length;
end Memory.Transform.Offset;
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.