content stringlengths 23 1.05M |
|---|
with Sort;
with Ada.Text_Io;
with Ada.Float_Text_IO; use Ada.Float_Text_IO;
procedure Sort_Test is
type Days is (Mon, Tue, Wed, Thu, Fri, Sat, Sun);
type Sales is array(Days range <>) of Float;
procedure Sort_Days is new Sort(Float, Days, Sales);
procedure Print(Item : Sales) is
begin
for I in Item'range loop
Put(Item => Item(I), Fore => 5, Aft => 2, Exp => 0);
end loop;
end Print;
Weekly_Sales : Sales := (Mon => 300.0,
Tue => 700.0,
Wed => 800.0,
Thu => 500.0,
Fri => 200.0,
Sat => 100.0,
Sun => 900.0);
begin
Print(Weekly_Sales);
Ada.Text_Io.New_Line(2);
Sort_Days(Weekly_Sales);
Print(Weekly_Sales);
end Sort_Test;
|
-- SPDX-FileCopyrightText: 2021 Max Reznik <reznikmm@gmail.com>
--
-- SPDX-License-Identifier: MIT
-------------------------------------------------------------
with Program.Interpretations.Names;
package body Program.Complete_Contexts.Call_Statements is
--------------------
-- Call_Statement --
--------------------
procedure Call_Statement
(Sets : not null Program.Interpretations.Context_Access;
Setter : not null Program.Cross_Reference_Updaters
.Cross_Reference_Updater_Access;
Element : Program.Elements.Call_Statements.Call_Statement_Access)
is
use type Program.Interpretations.Names.Cursor;
use all type Program.Visibility.View_Kind;
procedure Callback (Down : Program.Interpretations.Solution_Array);
Name : Program.Interpretations.Interpretation_Set;
Args : Program.Interpretations.Interpretation_Set_Array
(1 .. Element.Parameters.Length);
Found : Program.Interpretations.Solution_Array (0 .. Args'Length);
Count : Natural := 0;
procedure Callback (Down : Program.Interpretations.Solution_Array) is
begin
Count := Count + 1;
Found := Down;
end Callback;
begin
Name := Up (Element.Called_Name, Sets);
for J in Element.Parameters.Each_Element loop
Args (J.Index) := Up (J.Element, Sets);
end loop;
for N in Program.Interpretations.Names.Each (Name) loop
declare
View : constant Program.Visibility.View := +N;
Params : constant Program.Visibility.View_Array :=
Program.Visibility.Parameters (View);
Down : Program.Interpretations.Solution_Array
(0 .. Params'Length);
begin
if View.Kind = Procedure_View then
Down (0) :=
(Program.Interpretations.Defining_Name_Solution,
View);
Resolve_Parameters
(Arguments => Args,
Parameters => Params,
Callback => Callback'Access,
Down => Down);
end if;
end;
end loop;
if Count > 0 then
Down (Element.Called_Name, Found (0), Setter, Sets);
for J in Element.Parameters.Each_Element loop
Down (J.Element, Found (J.Index), Setter, Sets);
end loop;
end if;
end Call_Statement;
end Program.Complete_Contexts.Call_Statements;
|
with Generic_List;
procedure Int_List is
Number : Integer;
begin
for I in 1 .. 100000000 loop
Number := I;
end loop;
end Int_List;
|
package body agar.gui.widget.console is
package cbinds is
procedure set_padding
(console : console_access_t;
padding : c.int);
pragma import (c, set_padding, "AG_ConsoleSetPadding");
function message
(console : console_access_t;
text : cs.chars_ptr) return line_access_t;
pragma import (c, message, "AG_ConsoleMsgS");
function append_line
(console : console_access_t;
text : cs.chars_ptr) return line_access_t;
pragma import (c, append_line, "AG_ConsoleAppendLine");
end cbinds;
procedure set_padding
(console : console_access_t;
padding : natural) is
begin
cbinds.set_padding
(console => console,
padding => c.int (padding));
end set_padding;
function append_line
(console : console_access_t;
text : string) return line_access_t
is
ca_text : aliased c.char_array := c.to_c (text);
begin
return cbinds.append_line
(console => console,
text => cs.to_chars_ptr (ca_text'unchecked_access));
end append_line;
function widget (console : console_access_t) return widget_access_t is
begin
return console.widget'access;
end widget;
end agar.gui.widget.console;
|
with RASCAL.OS; use RASCAL.OS;
package Controller_Help is
type TEL_ViewManual_Type is new Toolbox_UserEventListener(16#11#,-1,-1) with null record;
type TEL_ViewSection_Type is new Toolbox_UserEventListener(16#20#,-1,-1) with null record;
type TEL_ViewIHelp_Type is new Toolbox_UserEventListener(16#17#,-1,-1) with null record;
--
-- The user wants to view the manual.
--
procedure Handle (The : in TEL_ViewManual_Type);
--
-- The user wants to view a particular section of the manual.
--
procedure Handle (The : in TEL_ViewSection_Type);
--
-- The user wants to use the interactive help - activate or run it if its not loaded already.
--
procedure Handle (The : in TEL_ViewIHelp_Type);
end Controller_Help;
|
------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- Localization, Internationalization, Globalization for Ada --
-- --
-- Tools Component --
-- --
------------------------------------------------------------------------------
-- --
-- Copyright © 2011-2015, Vadim Godunko <vgodunko@gmail.com> --
-- 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.String_Vectors;
with League.Strings;
with Ada.Containers.Ordered_Maps;
with Ada.Containers.Vectors;
with Matreshka.Internals.Finite_Automatons;
package UAFLEX.Nodes is
type Node_Kind is (Text, Rule, Macro, Name_List);
type Node (Kind : Node_Kind := Node_Kind'First) is record
case Kind is
when Text =>
Value : League.Strings.Universal_String;
when Rule =>
Regexp : League.Strings.Universal_String;
Action : League.Strings.Universal_String;
when Macro =>
Name : League.Strings.Universal_String;
Text : League.Strings.Universal_String;
when Name_List =>
List : League.String_Vectors.Universal_String_Vector;
end case;
end record;
subtype Rule_Node is Node (Rule);
function To_Node (Value : League.Strings.Universal_String) return Node;
function To_Action (Value : League.Strings.Universal_String) return Node;
Empty_Name_List : constant Node (Name_List) :=
(Kind => Name_List, List => <>);
use type League.Strings.Universal_String;
package Macro_Maps is new Ada.Containers.Ordered_Maps
(League.Strings.Universal_String, -- Macro name
League.Strings.Universal_String); -- Macro value
package Positive_Vectors is new Ada.Containers.Vectors
(Index_Type => Positive,
Element_Type => Positive);
type Start_Condition is record
Exclusive : Boolean;
Rules : Positive_Vectors.Vector;
end record;
package Start_Condition_Maps is new Ada.Containers.Ordered_Maps
(League.Strings.Universal_String, -- Condition name
Start_Condition);
type Shared_Pattern_Array_Access is access all
Matreshka.Internals.Finite_Automatons.Shared_Pattern_Array;
-- List of regexp from input file
Rules : League.String_Vectors.Universal_String_Vector;
-- List of DISTINCT action from input file
Actions : League.String_Vectors.Universal_String_Vector;
-- Map rule index to action index
Indexes : Positive_Vectors.Vector;
-- Map rule index to input file line number
Lines : Positive_Vectors.Vector;
-- Map condition name to Start_Condition
Conditions : Start_Condition_Maps.Map;
-- Map macros name to macros value
Macros : Macro_Maps.Map;
-- Array of compiled regexps
Regexp : Shared_Pattern_Array_Access;
Success : Boolean := True;
procedure Add_Start_Conditions
(List : League.String_Vectors.Universal_String_Vector;
Exclusive : Boolean);
procedure Add_Rule
(RegExp : League.Strings.Universal_String;
Action : League.Strings.Universal_String;
Line : Positive);
end UAFLEX.Nodes;
|
-----------------------------------------------------------------------
-- akt-commands-get -- Get content from keystore
-- Copyright (C) 2019, 2021 Stephane Carrez
-- Written by Stephane Carrez (Stephane.Carrez@gmail.com)
--
-- Licensed under the Apache License, Version 2.0 (the "License");
-- you may not use this file except in compliance with the License.
-- You may obtain a copy of the License at
--
-- http://www.apache.org/licenses/LICENSE-2.0
--
-- Unless required by applicable law or agreed to in writing, software
-- distributed under the License is distributed on an "AS IS" BASIS,
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-- See the License for the specific language governing permissions and
-- limitations under the License.
-----------------------------------------------------------------------
with Ada.Command_Line;
with Ada.Streams;
with Util.Systems.Os;
with Util.Streams.Raw;
with GNAT.Command_Line;
package body AKT.Commands.Get is
Sep : Ada.Streams.Stream_Element_Array (1 .. Util.Systems.Os.Line_Separator'Length);
for Sep'Address use Util.Systems.Os.Line_Separator'Address;
Output : Util.Streams.Raw.Raw_Stream;
-- ------------------------------
-- Get a value from the keystore.
-- ------------------------------
overriding
procedure Execute (Command : in out Command_Type;
Name : in String;
Args : in Argument_List'Class;
Context : in out Context_Type) is
begin
if Args.Get_Count = 0 then
AKT.Commands.Usage (Args, Context, Name);
else
Context.Open_Keystore (Args, Use_Worker => True);
Output.Initialize (File => Util.Systems.Os.STDOUT_FILENO);
for I in Context.First_Arg .. Args.Get_Count loop
declare
Key : constant String := Args.Get_Argument (I);
begin
Context.Wallet.Get (Key, Output);
if not Command.No_Newline then
Output.Write (Sep);
end if;
exception
when Keystore.Not_Found =>
AKT.Commands.Log.Error (-("value '{0}' not found"), Key);
Ada.Command_Line.Set_Exit_Status (Ada.Command_Line.Failure);
end;
end loop;
end if;
end Execute;
-- ------------------------------
-- Setup the command before parsing the arguments and executing it.
-- ------------------------------
procedure Setup (Command : in out Command_Type;
Config : in out GNAT.Command_Line.Command_Line_Configuration;
Context : in out Context_Type) is
package GC renames GNAT.Command_Line;
begin
Drivers.Command_Type (Command).Setup (Config, Context);
GC.Define_Switch (Config, Command.No_Newline'Access,
"-n", "", -("Do not output the trailing newline"));
end Setup;
end AKT.Commands.Get;
|
pragma Ada_2012;
pragma Style_Checks (Off);
with Interfaces.C; use Interfaces.C;
package stddef_h is
-- Copyright (C) 1989-2019 Free Software Foundation, Inc.
--This file is part of GCC.
--GCC 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, or (at your option)
--any later version.
--GCC 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.
--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/>.
-- * ISO C Standard: 7.17 Common definitions <stddef.h>
--
-- Any one of these symbols __need_* means that GNU libc
-- wants us just to define one data type. So don't define
-- the symbols that indicate this file's entire job has been done.
-- snaroff@next.com says the NeXT needs this.
-- This avoids lossage on SunOS but only if stdtypes.h comes first.
-- There's no way to win with the other order! Sun lossage.
-- On BSD/386 1.1, at least, machine/ansi.h defines _BSD_WCHAR_T_
-- instead of _WCHAR_T_.
-- Undef _FOO_T_ if we are supposed to define foo_t.
-- Sequent's header files use _PTRDIFF_T_ in some conflicting way.
-- Just ignore it.
-- On VxWorks, <type/vxTypesBase.h> may have defined macros like
-- _TYPE_size_t which will typedef size_t. fixincludes patched the
-- vxTypesBase.h so that this macro is only defined if _GCC_SIZE_T is
-- not defined, and so that defining this macro defines _GCC_SIZE_T.
-- If we find that the macros are still defined at this point, we must
-- invoke them so that the type is defined as expected.
-- In case nobody has defined these types, but we aren't running under
-- GCC 2.00, make sure that __PTRDIFF_TYPE__, __SIZE_TYPE__, and
-- __WCHAR_TYPE__ have reasonable values. This can happen if the
-- parts of GCC is compiled by an older compiler, that actually
-- include gstddef.h, such as collect2.
-- Signed type of difference of two pointers.
-- Define this type if we are doing the whole job,
-- or if we want this type in particular.
-- If this symbol has done its job, get rid of it.
-- Unsigned type of `sizeof' something.
-- Define this type if we are doing the whole job,
-- or if we want this type in particular.
-- __size_t is a typedef, must not trash it.
subtype size_t is unsigned_long; -- /home/doc/opt/GNAT/2020/lib/gcc/x86_64-pc-linux-gnu/9.3.1/include/stddef.h:209
-- Wide character type.
-- Locale-writers should change this as necessary to
-- be big enough to hold unique values not between 0 and 127,
-- and not (wchar_t) -1, for each defined multibyte character.
-- Define this type if we are doing the whole job,
-- or if we want this type in particular.
-- On BSD/386 1.1, at least, machine/ansi.h defines _BSD_WCHAR_T_
-- instead of _WCHAR_T_, and _BSD_RUNE_T_ (which, unlike the other
-- symbols in the _FOO_T_ family, stays defined even after its
-- corresponding type is defined). If we define wchar_t, then we
-- must undef _WCHAR_T_; for BSD/386 1.1 (and perhaps others), if
-- we undef _WCHAR_T_, then we must also define rune_t, since
-- headers like runetype.h assume that if machine/ansi.h is included,
-- and _BSD_WCHAR_T_ is not defined, then rune_t is available.
-- machine/ansi.h says, "Note that _WCHAR_T_ and _RUNE_T_ must be of
-- the same type."
-- Why is this file so hard to maintain properly? In contrast to
-- the comment above regarding BSD/386 1.1, on FreeBSD for as long
-- as the symbol has existed, _BSD_RUNE_T_ must not stay defined or
-- redundant typedefs will occur when stdlib.h is included after this file.
-- FreeBSD 5 can't be handled well using "traditional" logic above
-- since it no longer defines _BSD_RUNE_T_ yet still desires to export
-- rune_t in some cases...
-- The references to _GCC_PTRDIFF_T_, _GCC_SIZE_T_, and _GCC_WCHAR_T_
-- are probably typos and should be removed before 2.8 is released.
-- The following ones are the real ones.
-- A null pointer constant.
-- Offset of member MEMBER in a struct of type TYPE.
-- Type whose alignment is supported in every context and is at least
-- as great as that of any standard type not using alignment
-- specifiers.
-- _Float128 is defined as a basic type, so max_align_t must be
-- sufficiently aligned for it. This code must work in C++, so we
-- use __float128 here; that is only available on some
-- architectures, but only on i386 is extra alignment needed for
-- __float128.
end stddef_h;
|
--//////////////////////////////////////////////////////////
-- //
-- // SFML - Simple and Fast Multimedia Library
-- // Copyright (C) 2007-2009 Laurent Gomila (laurent.gom@gmail.com)
-- //
-- // This software is provided 'as-is', without any express or implied warranty.
-- // In no event will the authors be held liable for any damages arising from the use of this software.
-- //
-- // Permission is granted to anyone to use this software for any purpose,
-- // including commercial applications, and to alter it and redistribute it freely,
-- // subject to the following restrictions:
-- //
-- // 1. The origin of this software must not be misrepresented;
-- // you must not claim that you wrote the original software.
-- // If you use this software in a product, an acknowledgment
-- // in the product documentation would be appreciated but is not required.
-- //
-- // 2. Altered source versions must be plainly marked as such,
-- // and must not be misrepresented as being the original software.
-- //
-- // 3. This notice may not be removed or altered from any source distribution.
-- //
--//////////////////////////////////////////////////////////
--//////////////////////////////////////////////////////////
--//////////////////////////////////////////////////////////
with Interfaces.C.Strings;
package body Sf.Network.Http is
use Interfaces.C.Strings;
package body Request is
--//////////////////////////////////////////////////////////
--/ Set the value of a field; the field is added if it doesn't exist
--/
--/ @param HttpRequest Http request to modify
--/ @param Field Name of the field to set (case-insensitive)
--/ @param Value Value of the field
--/
--//////////////////////////////////////////////////////////
procedure SetField (HttpRequest : sfHttpRequest_Ptr; Field : String; Value : String) is
procedure Internal (HttpRequest : sfHttpRequest_Ptr; Field : chars_ptr; Value : chars_ptr);
pragma Import (C, Internal, "sfHttpRequest_setField");
Temp1 : chars_ptr := New_String (Field);
Temp2 : chars_ptr := New_String (Value);
begin
Internal (HttpRequest, Temp1, Temp2);
Free (Temp1);
Free (Temp2);
end SetField;
--//////////////////////////////////////////////////////////
--/ Set the target URI of the request.
--/ This parameter is "/" by default
--/
--/ @param HttpRequest Http request to modify
--/ @param URI URI to request, local to the host
--/
--//////////////////////////////////////////////////////////
procedure SetURI (HttpRequest : sfHttpRequest_Ptr; URI : String) is
procedure Internal (HttpRequest : sfHttpRequest_Ptr; URI : chars_ptr);
pragma Import (C, Internal, "sfHttpRequest_setUri");
Temp : chars_ptr := New_String (URI);
begin
Internal (HttpRequest, Temp);
Free (Temp);
end SetURI;
--//////////////////////////////////////////////////////////
--/ Set the body of the request. This parameter is optional and
--/ makes sense only for POST requests.
--/ This parameter is empty by default
--/
--/ @param HttpRequest Http request to modify
--/ @param Body Content of the request body
--/
--//////////////////////////////////////////////////////////
procedure SetBody (HttpRequest : sfHttpRequest_Ptr; httpBody : String) is
procedure Internal (HttpRequest : sfHttpRequest_Ptr; httpBody : chars_ptr);
pragma Import (C, Internal, "sfHttpRequest_setBody");
Temp : chars_ptr := New_String (httpBody);
begin
Internal (HttpRequest, Temp);
Free (Temp);
end SetBody;
end Request;
package body Response is
--//////////////////////////////////////////////////////////
--/ Get the value of a field; returns NULL if the field doesn't exist
--/
--/ @param HttpResponse Http response
--/ @param Field Field to get
--/
--/ @return Value of the field (NULL if it doesn't exist)
--/
--//////////////////////////////////////////////////////////
function GetField (HttpResponse : sfHttpResponse_Ptr; Field : String) return String is
function Internal (HttpResponse : sfHttpResponse_Ptr; Field : chars_ptr) return chars_ptr;
pragma Import (C, Internal, "sfHttpResponse_getField");
Temp1 : chars_ptr := New_String (Field);
Temp2 : chars_ptr := Internal (HttpResponse, Temp1);
R : String := Value (Temp2);
begin
Free (Temp1);
Free (Temp2);
return R;
end GetField;
--//////////////////////////////////////////////////////////
--/ Get the body of the response. The body can contain :
--/ - the requested page (for GET requests)
--/ - a response from the server (for POST requests)
--/ - nothing (for HEAD requests)
--/ - an error message (in case of an error)
--/
--/ @param HttpResponse Http response
--/
--/ @return Body of the response (empty string if no body)
--/
--//////////////////////////////////////////////////////////
function GetBody (HttpResponse : sfHttpResponse_Ptr) return String is
function Internal (HttpResponse : sfHttpResponse_Ptr) return chars_ptr;
pragma Import (C, Internal, "sfHttpResponse_getBody");
Temp : chars_ptr := Internal (HttpResponse);
R : String := Value (Temp);
begin
Free (Temp);
return R;
end GetBody;
end Response;
--//////////////////////////////////////////////////////////
--/ Set the target host of a Http server
--/
--/ @param Http Http object
--/ @param Host Web server to connect to
--/ @param Port Port to use for connection (0 to use the standard port of the protocol used)
--/
--//////////////////////////////////////////////////////////
procedure SetHost (Http : sfHttp_Ptr; Host : String; Port : sfUint16) is
procedure Internal (Http : sfHttp_Ptr; Host : chars_ptr; Port : sfUint16);
pragma Import (C, Internal, "sfHttp_setHost");
Temp : chars_ptr := New_String (Host);
begin
Internal (Http, Temp, Port);
Free (Temp);
end SetHost;
end Sf.Network.Http;
|
package Problem_69 is
-- Euler's Totient function, φ(n) [sometimes called the phi function], is used to determine the
-- number of numbers less than n which are relatively prime to n. For example, as 1, 2, 4, 5, 7,
-- and 8, are all less than nine and relatively prime to nine, φ(9)=6.
--
-- It can be seen that n=6 produces a maximum n/φ(n) for n ≤ 10.
--
-- Find the value of n ≤ 1,000,000 for which n/φ(n) is a maximum.
procedure Solve;
end Problem_69;
|
with
ada.Text_IO;
package body openGL.frame_Counter
is
procedure increment (Self : in out Item)
is
use ada.Text_IO;
use type ada.Calendar.Time;
begin
if ada.Calendar.Clock >= Self.next_FPS_Time
then
put_Line ("FPS:" & Integer'Image (Self.frame_Count));
Self.next_FPS_Time := Self.next_FPS_Time + 1.0;
Self.frame_Count := 0;
else
Self.frame_Count := Self.frame_Count + 1;
end if;
end increment;
end openGL.frame_Counter;
|
with Ada.Long_Long_Integer_Text_IO;
with Ada.Text_IO;
with PrimeInstances;
package body Problem_10 is
package IO renames Ada.Text_IO;
package I_IO renames Ada.Long_Long_Integer_Text_IO;
procedure Solve is
package Integer_Primes renames PrimeInstances.Integer_Primes;
gen : Integer_Primes.Prime_Generator := Integer_Primes.Make_Generator(2_000_000);
sum : Long_Long_Integer := 0;
prime : Integer;
begin
loop
Integer_Primes.Next_Prime(gen, prime);
exit when prime = 1;
sum := sum + Long_Long_Integer(prime);
end loop;
I_IO.Put(sum);
IO.New_Line;
end Solve;
end Problem_10;
|
------------------------------------------------------------------------------
-- --
-- WAVEFILES --
-- --
-- Test application --
-- --
-- The MIT License (MIT) --
-- --
-- Copyright (c) 2020 Gustavo A. Hoffmann --
-- --
-- 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 Audio.Wavefiles.Data_Types; use Audio.Wavefiles.Data_Types;
with Generic_Fixed_Wave_Test;
with Generic_Float_Wave_Test;
package body Wave_Test_Instances is
PCM_Bits : Positive := 32;
PCM_Fixed : Boolean := True;
package Wave_Test_Fixed_8 is new Generic_Fixed_Wave_Test
(PCM_Sample => Wav_Fixed_8,
PCM_MC_Sample => Wav_Buffer_Fixed_8);
package Wave_Test_Fixed_16 is new Generic_Fixed_Wave_Test
(PCM_Sample => Wav_Fixed_16,
PCM_MC_Sample => Wav_Buffer_Fixed_16);
package Wave_Test_Fixed_24 is new Generic_Fixed_Wave_Test
(PCM_Sample => Wav_Fixed_24,
PCM_MC_Sample => Wav_Buffer_Fixed_24);
package Wave_Test_Fixed_32 is new Generic_Fixed_Wave_Test
(PCM_Sample => Wav_Fixed_32,
PCM_MC_Sample => Wav_Buffer_Fixed_32);
package Wave_Test_Fixed_64 is new Generic_Fixed_Wave_Test
(PCM_Sample => Wav_Fixed_64,
PCM_MC_Sample => Wav_Buffer_Fixed_64);
package Wave_Test_Float_32 is new Generic_Float_Wave_Test
(PCM_Sample => Wav_Float_32,
PCM_MC_Sample => Wav_Buffer_Float_32);
package Wave_Test_Float_64 is new Generic_Float_Wave_Test
(PCM_Sample => Wav_Float_64,
PCM_MC_Sample => Wav_Buffer_Float_64);
package Wave_Test_Float_128 is new Generic_Float_Wave_Test
(PCM_Sample => Wav_Float_128,
PCM_MC_Sample => Wav_Buffer_Float_128);
Proc_Display_Info_File : access procedure (File_In : String)
:= Wave_Test_Fixed_32.Display_Info_File'Access;
Proc_Copy_File : access procedure
(File_In : String;
File_Out : String) := Wave_Test_Fixed_32.Copy_File'Access;
Proc_Compare_Files : access procedure
(File_Ref : String;
File_DUT : String) := Wave_Test_Fixed_32.Compare_Files'Access;
Proc_Diff_Files : access procedure
(File_Ref : String;
File_DUT : String;
File_Diff : String) := Wave_Test_Fixed_32.Diff_Files'Access;
Proc_Mix_Files : access procedure
(File_Ref : String;
File_DUT : String;
File_Mix : String) := Wave_Test_Fixed_32.Mix_Files'Access;
-----------------------
-- Display_Info_File --
-----------------------
procedure Display_Info_File (File_In : String) is
begin
Proc_Display_Info_File (File_In);
end Display_Info_File;
---------------
-- Copy_File --
---------------
procedure Copy_File
(File_In : String;
File_Out : String) is
begin
Proc_Copy_File (File_In, File_Out);
end Copy_File;
-------------------
-- Compare_Files --
-------------------
procedure Compare_Files
(File_Ref : String;
File_DUT : String) is
begin
Proc_Compare_Files (File_Ref, File_DUT);
end Compare_Files;
----------------
-- Diff_Files --
----------------
procedure Diff_Files
(File_Ref : String;
File_DUT : String;
File_Diff : String) is
begin
Proc_Diff_Files (File_Ref, File_DUT, File_Diff);
end Diff_Files;
---------------
-- Mix_Files --
---------------
procedure Mix_Files
(File_Ref : String;
File_DUT : String;
File_Mix : String) is
begin
Proc_Mix_Files (File_Ref, File_DUT, File_Mix);
end Mix_Files;
-------------------------
-- Set_Test_Procedures --
-------------------------
procedure Set_Test_Procedures (Bits : Positive;
Fixed : Boolean;
Status : out Boolean)
is
procedure Set_It;
procedure Set_It is
begin
Status := True;
PCM_Bits := Bits;
PCM_Fixed := Fixed;
end Set_It;
begin
Status := False;
case Fixed is
when False => -- Floating-point PCM buffer
case Bits is
when 32 =>
Proc_Display_Info_File
:= Wave_Test_Float_32.Display_Info_File'Access;
Proc_Copy_File
:= Wave_Test_Float_32.Copy_File'Access;
Proc_Compare_Files
:= Wave_Test_Float_32.Compare_Files'Access;
Proc_Diff_Files
:= Wave_Test_Float_32.Diff_Files'Access;
Proc_Mix_Files
:= Wave_Test_Float_32.Mix_Files'Access;
Set_It;
when 64 =>
Proc_Display_Info_File
:= Wave_Test_Float_64.Display_Info_File'Access;
Proc_Copy_File
:= Wave_Test_Float_64.Copy_File'Access;
Proc_Compare_Files
:= Wave_Test_Float_64.Compare_Files'Access;
Proc_Diff_Files
:= Wave_Test_Float_64.Diff_Files'Access;
Proc_Mix_Files
:= Wave_Test_Float_64.Mix_Files'Access;
Set_It;
when 128 =>
Proc_Display_Info_File
:= Wave_Test_Float_128.Display_Info_File'Access;
Proc_Copy_File
:= Wave_Test_Float_128.Copy_File'Access;
Proc_Compare_Files
:= Wave_Test_Float_128.Compare_Files'Access;
Proc_Diff_Files
:= Wave_Test_Float_128.Diff_Files'Access;
Proc_Mix_Files
:= Wave_Test_Float_128.Mix_Files'Access;
Set_It;
when others =>
null;
end case;
when True => -- Fixed-point PCM buffer
case Bits is
when 8 =>
Proc_Display_Info_File
:= Wave_Test_Fixed_8.Display_Info_File'Access;
Proc_Copy_File
:= Wave_Test_Fixed_8.Copy_File'Access;
Proc_Compare_Files
:= Wave_Test_Fixed_8.Compare_Files'Access;
Proc_Diff_Files
:= Wave_Test_Fixed_8.Diff_Files'Access;
Proc_Mix_Files
:= Wave_Test_Fixed_8.Mix_Files'Access;
Set_It;
when 16 =>
Proc_Display_Info_File
:= Wave_Test_Fixed_16.Display_Info_File'Access;
Proc_Copy_File
:= Wave_Test_Fixed_16.Copy_File'Access;
Proc_Compare_Files
:= Wave_Test_Fixed_16.Compare_Files'Access;
Proc_Diff_Files
:= Wave_Test_Fixed_16.Diff_Files'Access;
Proc_Mix_Files
:= Wave_Test_Fixed_16.Mix_Files'Access;
Set_It;
when 24 =>
Proc_Display_Info_File
:= Wave_Test_Fixed_24.Display_Info_File'Access;
Proc_Copy_File
:= Wave_Test_Fixed_24.Copy_File'Access;
Proc_Compare_Files
:= Wave_Test_Fixed_24.Compare_Files'Access;
Proc_Diff_Files
:= Wave_Test_Fixed_24.Diff_Files'Access;
Proc_Mix_Files
:= Wave_Test_Fixed_24.Mix_Files'Access;
Set_It;
when 32 =>
Proc_Display_Info_File
:= Wave_Test_Fixed_32.Display_Info_File'Access;
Proc_Copy_File
:= Wave_Test_Fixed_32.Copy_File'Access;
Proc_Compare_Files
:= Wave_Test_Fixed_32.Compare_Files'Access;
Proc_Diff_Files
:= Wave_Test_Fixed_32.Diff_Files'Access;
Proc_Mix_Files
:= Wave_Test_Fixed_32.Mix_Files'Access;
Set_It;
when 64 =>
Proc_Display_Info_File
:= Wave_Test_Fixed_64.Display_Info_File'Access;
Proc_Copy_File
:= Wave_Test_Fixed_64.Copy_File'Access;
Proc_Compare_Files
:= Wave_Test_Fixed_64.Compare_Files'Access;
Proc_Diff_Files
:= Wave_Test_Fixed_64.Diff_Files'Access;
Proc_Mix_Files
:= Wave_Test_Fixed_64.Mix_Files'Access;
Set_It;
when others =>
null;
end case;
end case;
end Set_Test_Procedures;
--------------
-- Get_Bits --
--------------
function Get_Bits return Positive is (PCM_Bits);
--------------
-- Is_Fixed --
--------------
function Is_Fixed return Boolean is (PCM_Fixed);
end Wave_Test_Instances;
|
-- DECLS-DTDESC.ads
-- Declaracions de descripcio
with Decls.Dgenerals,
Decls.D_Taula_De_Noms;
use Decls.Dgenerals,
Decls.D_Taula_De_Noms;
package Decls.Dtdesc is
--pragma pure;
-- Representa tambit
Max_Nprof : constant Integer := 25;
type Nprof is new Integer
range -1 .. Max_Nprof;
Nul_Nprof : constant Nprof := 0;
No_Prof : constant Nprof := -1;
type Despl is new Integer;
-- Representa texpansio
type Rang_Despl is new Integer
range 0 .. (Max_Id * Max_Nprof);
Nul_Despl : constant Rang_Despl := 0;
type Tdescrip is
(Dnula,
Dconst,
Dvar,
Dtipus,
Dproc,
Dcamp,
Dargc);
type Tipussubjacent is
(Tsbool,
Tscar,
Tsstr,
Tsent,
Tsrec,
Tsarr,
Tsnul);
type Descriptipus (Tt: Tipussubjacent := Tsnul) is
record
Ocup : Despl;
case Tt is
when Tsbool | Tscar | Tsent =>
Linf, Lsup : Valor;
when Tsarr | Tsstr => Tcamp : Id_Nom;
Base : Valor;
when Tsrec | Tsnul => null;
end case;
end record;
type Descrip (Td : Tdescrip := Dnula) is
record
case Td is
when Dnula => null;
when Dtipus => Dt : Descriptipus;
when Dvar => Tr : Id_Nom;
Nv : Num_Var;
when Dproc => Np : Num_Proc;
when Dconst => Tc : Id_Nom;
Vc : Valor;
Nvc : Num_Var;
when Dargc => Nvarg : Num_Var;
Targ : Id_Nom;
when Dcamp => Tcamp : Id_Nom;
Dsp : Despl;
end case;
end record;
end Decls.Dtdesc;
|
with STM32F4.SPI; use STM32F4.SPI;
with STM32F4.GPIO; use STM32F4.GPIO;
with Ada.Unchecked_Conversion;
with Fonts; use Fonts;
package body STM32F4.GYRO is
function As_Half_Word is new Ada.Unchecked_Conversion
(Source => Byte, Target => Half_Word);
L3GD20_SPI : SPI_Port renames SPI_5;
SCK_GPIO : GPIO_Port renames GPIO_F;
SCK_Pin : GPIO_Pins renames Pin_7;
SCK_AF : GPIO_AF renames GPIO_AF_SPI5;
MISO_GPIO : GPIO_Port renames GPIO_F;
MISO_Pin : GPIO_Pins renames Pin_8;
MISO_AF : GPIO_AF renames GPIO_AF_SPI5;
MOSI_GPIO : GPIO_Port renames GPIO_F;
MOSI_Pin : GPIO_Pins renames Pin_9;
MOSI_AF : GPIO_AF renames GPIO_AF_SPI5;
CS_GPIO : GPIO_Port renames GPIO_C;
CS_Pin : GPIO_Pins renames Pin_1;
Int1_GPIO : GPIO_Port renames GPIO_A;
Int1_Pin : GPIO_Pins renames Pin_1;
Int2_GPIO : GPIO_Port renames GPIO_A;
Int2_Pin : GPIO_Pins renames Pin_2;
Sensitivity_250dps : constant := 114.285;
Sensitivity_500dps : constant := 57.1429;
Sensitivity_2000dps : constant := 14.285;
-- L3GD20 Registers
WHO_AM_I_REG : constant := 16#0F#; -- device identification register
CTRL_REG1_REG : constant := 16#20#; -- Control register 1
CTRL_REG2_REG : constant := 16#21#; -- Control register 2
CTRL_REG3_REG : constant := 16#22#; -- Control register 3
CTRL_REG4_REG : constant := 16#23#; -- Control register 4
CTRL_REG5_REG : constant := 16#24#; -- Control register 5
REFERENCE_REG_REG : constant := 16#25#; -- Reference register
OUT_TEMP_REG : constant := 16#26#; -- Out temp register
STATUS_REG : constant := 16#27#; -- Status register
OUT_X_L_REG : constant := 16#28#; -- Output Register X
OUT_X_H_REG : constant := 16#29#; -- Output Register X
OUT_Y_L_REG : constant := 16#2A#; -- Output Register Y
OUT_Y_H_REG : constant := 16#2B#; -- Output Register Y
OUT_Z_L_REG : constant := 16#2C#; -- Output Register Z
OUT_Z_H_REG : constant := 16#2D#; -- Output Register Z
FIFO_CTRL_REG_REG : constant := 16#2E#; -- Fifo control Register
FIFO_SRC_REG_REG : constant := 16#2F#; -- Fifo src Register
INT1_CFG_REG : constant := 16#30#; -- Interrupt 1 configuration Register
INT1_SRC_REG : constant := 16#31#; -- Interrupt 1 source Register
INT1_TSH_XH_REG : constant := 16#32#; -- Interrupt 1 Threshold X register
INT1_TSH_XL_REG : constant := 16#33#; -- Interrupt 1 Threshold X register
INT1_TSH_YH_REG : constant := 16#34#; -- Interrupt 1 Threshold Y register
INT1_TSH_YL_REG : constant := 16#35#; -- Interrupt 1 Threshold Y register
INT1_TSH_ZH_REG : constant := 16#36#; -- Interrupt 1 Threshold Z register
INT1_TSH_ZL_REG : constant := 16#37#; -- Interrupt 1 Threshold Z register
INT1_DURATION_REG : constant := 16#38#; -- Interrupt 1 DURATION register
-- Read/Write command
READWRITE_CMD : constant := 16#80#;
-- Multiple byte read/write command
MULTIPLEBYTE_CMD : constant := 16#40#;
NO_DATA : constant := 16#00#;
procedure Chip_Select (Enabled : Boolean) is
begin
if Enabled then
-- GPIO Reset = select
GPIO_Reset (CS_GPIO, CS_Pin);
else
-- GPIO Set = deselect
GPIO_Set (CS_GPIO, CS_Pin);
end if;
end Chip_Select;
type Buffer is array (Natural range <>) of Byte;
function Send_Byte (Data : Byte) return Byte is
begin
loop
exit when SPI_Tx_Is_Empty (L3GD20_SPI);
end loop;
SPI_Send_Data (L3GD20_SPI, Half_Word (Data));
loop
exit when not SPI_Rx_Is_Empty (L3GD20_SPI);
end loop;
return SPI_Read_Data (L3GD20_SPI);
end Send_Byte;
procedure Send_Byte (Data : Byte) is
Ret : Byte with Unreferenced;
begin
Ret := Send_Byte (Data);
end Send_Byte;
procedure Write (Addr : Byte; Buff : Buffer) is
Full_Addr : Byte := Addr;
begin
if Buff'Length > 1 then
Full_Addr := Addr or MULTIPLEBYTE_CMD;
end if;
Chip_Select (true);
-- Send Register address
Send_Byte (Full_Addr);
for Data of Buff loop
Send_Byte (Data);
end loop;
Chip_Select (false);
end Write;
procedure Read (Addr : Byte; Buff : out Buffer) is
Full_Addr : Byte := Addr or READWRITE_CMD;
begin
if Buff'Length > 1 then
Full_Addr := Addr or MULTIPLEBYTE_CMD;
end if;
Chip_Select (true);
-- Send Register address
Send_Byte (Full_Addr);
for Data of Buff loop
Data := Send_Byte (NO_DATA);
end loop;
Chip_Select (false);
end Read;
procedure L3GD20_Ctrl_Lines is
SPI_Conf : SPI_Config;
GPIO_Conf : GPIO_Config;
begin
GPIO_Enable (SCK_GPIO);
GPIO_Enable (MISO_GPIO);
GPIO_Enable (MOSI_GPIO);
GPIO_Enable (CS_GPIO);
GPIO_Enable (Int1_GPIO);
GPIO_Enable (Int2_GPIO);
SPI_CLK_Enable (L3GD20_SPI);
Configure_Alternate_Function (SCK_GPIO, SCK_Pin, SCK_AF);
Configure_Alternate_Function (MISO_GPIO, MISO_Pin, MISO_AF);
Configure_Alternate_Function (MOSI_GPIO, MOSI_Pin, MOSI_AF);
GPIO_Conf.Speed := Speed_25MHz;
GPIO_Conf.Mode := Mode_AF;
GPIO_Conf.Output_Type := Type_PP;
GPIO_Conf.Resistors := Pull_Down;
GPIO_Conf.Lock := True;
Configure (SCK_GPIO, SCK_Pin, GPIO_Conf);
Configure (MISO_GPIO, MISO_Pin, GPIO_Conf);
Configure (MOSI_GPIO, MOSI_Pin, GPIO_Conf);
SPI_Set_Enable (L3GD20_SPI, False);
SPI_Conf.Direction := D2Lines_FullDuplex;
SPI_Conf.Mode := Master;
SPI_Conf.Data_Size := Data_8;
SPI_Conf.Clock_Polarity := Low;
SPI_Conf.Clock_Phase := P1Edge;
SPI_Conf.Slave_Management := Soft;
SPI_Conf.Baud_Rate_Prescaler := BRP_16;
SPI_Conf.First_Bit := MSB;
SPI_Conf.CRC_Poly := 7;
SPI_Set_Config (L3GD20_SPI, SPI_Conf);
SPI_Set_Enable (L3GD20_SPI, True);
GPIO_Conf.Speed := Speed_25MHz;
GPIO_Conf.Mode := Mode_OUT;
GPIO_Conf.Output_Type := Type_PP;
GPIO_Conf.Resistors := Floating;
GPIO_Conf.Lock := True;
Configure (CS_GPIO, CS_Pin, GPIO_Conf);
Chip_Select (false);
GPIO_Conf.Speed := Speed_25MHz;
GPIO_Conf.Mode := Mode_IN;
GPIO_Conf.Output_Type := Type_PP;
GPIO_Conf.Resistors := Floating;
GPIO_Conf.Lock := True;
Configure (Int1_GPIO, Int1_Pin, GPIO_Conf);
Configure (Int2_GPIO, Int2_Pin, GPIO_Conf);
end L3GD20_Ctrl_Lines;
procedure Initialize (Conf : Gyro_Config) is
Ctrl1 : Buffer (1 .. 1);
Ctrl4 : Buffer (1 .. 1);
begin
L3GD20_Ctrl_Lines;
Read (WHO_AM_I_REG, Ctrl1);
Draw_String (0, 110, "ID :" & Ctrl1 (1)'Img & " ");
Ctrl1 (1) := Conf.Power_Mode or Conf.Output_DataRate
or Conf.Axes_Enable or Conf.Band_Width;
Ctrl4 (1) := Conf.BlockData_Update or Conf.Endianness or Conf.Full_Scale;
Write (CTRL_REG1_REG, Ctrl1);
Write (CTRL_REG4_REG, Ctrl4);
end Initialize;
procedure Set_Filter_Config (Conf : Filter_Config) is
Ctrl2 : Buffer (1 .. 1);
begin
Read (CTRL_REG2_REG, Ctrl2);
Ctrl2 (1) := Ctrl2 (1) and 16#C0#;
Ctrl2 (1) := Ctrl2 (1) or Conf.Mode_Selection or Conf.CutOff_Frequency;
Write (CTRL_REG2_REG, Ctrl2);
end Set_Filter_Config;
procedure Set_Filter_State (State : Filter_State) is
Ctrl5 : Buffer (1 .. 1);
begin
Read (CTRL_REG5_REG, Ctrl5);
if State = Enabled then
-- Set HPen
Ctrl5 (1) := Ctrl5 (1) or 16#01#;
else
-- Clear HPen
Ctrl5 (1) := Ctrl5 (1) and 16#EF#;
end if;
Write (CTRL_REG5_REG, Ctrl5);
end Set_Filter_State;
function Get_Data_Status return Byte is
Reg : Buffer (1 .. 1);
begin
Read (STATUS_REG, Reg);
return Reg (1);
end Get_Data_Status;
procedure Reboot is
Ctrl5 : Buffer (1 .. 1);
begin
Read (CTRL_REG5_REG, Ctrl5);
-- Enable the reboot memory
Ctrl5 (1) := Ctrl5 (1) or 16#80#;
Write (CTRL_REG5_REG, Ctrl5);
end Reboot;
function Read_Angle_Rate return Angles_Rates is
Ctrl4 : Buffer (1 .. 1);
Status : Byte;
Reg_Data : Buffer (0 .. 5);
Raw_Data : array (0 .. 2) of Half_Word;
Sensitivity : Float := 0.0;
Ret : Angles_Rates;
begin
loop
Status := Get_Data_Status;
-- Wait for new Data
exit when (Status and 16#8#) /= 0;
-- Data overrun
if (Status and 16#80#) /= 0 then
raise Program_Error;
end if;
end loop;
Read (CTRL_REG4_REG, Ctrl4);
Read (OUT_X_L_REG, Reg_Data);
-- Check data alignment (Big Endian or Little Endian)
for Index in Raw_Data'Range loop
if (Ctrl4 (1) and 16#40#) /= 0 then
Raw_Data (Index) :=
As_Half_Word (Reg_Data (2 * Index + 1) * (2**8))
+ As_Half_Word (Reg_Data (2 * Index));
else
Raw_Data (Index) := As_Half_Word (Reg_Data (2 * Index) * (2**8))
+ As_Half_Word (Reg_Data (2 * Index + 1));
end if;
end loop;
if (Ctrl4 (1) and 16#30#) = 16#00# then
Sensitivity := Sensitivity_250dps;
elsif (Ctrl4 (1) and 16#30#) = 16#10# then
Sensitivity := Sensitivity_500dps;
elsif (Ctrl4 (1) and 16#30#) = 16#20# then
Sensitivity := Sensitivity_2000dps;
end if;
Draw_String (0, 80, "Raw_Data (0):" & Raw_Data (0)'Img & " ");
Draw_String (0, 88, "Raw_Data (1):" & Raw_Data (1)'Img & " ");
Draw_String (0, 96, "Raw_Data (2):" & Raw_Data (2)'Img & " ");
if Raw_Data (1) = 16#FF#
or else Raw_Data (1) = 16#FF#
or else Raw_Data (1) = 16#FF#
then
Ret := (others => 0.0);
else
Ret (X) := Float (Raw_Data (0)) / Sensitivity;
Ret (Y) := Float (Raw_Data (1)) / Sensitivity;
Ret (Z) := Float (Raw_Data (2)) / Sensitivity;
end if;
return Ret;
end Read_Angle_Rate;
end STM32F4.GYRO;
|
------------------------------------------------------------------------------
-- --
-- THIS IS AN AUTOMATICALLY GENERATED FILE! DO NOT EDIT! --
-- --
-- WAVEFILES --
-- --
-- Quick Wave Data I/O Check --
-- --
-- The MIT License (MIT) --
-- --
-- Copyright (c) 2020 Gustavo A. Hoffmann --
-- --
-- Permission is hereby granted, free of charge, to any person obtaining --
-- a copy of this software and associated documentation files (the --
-- "Software"), to deal in the Software without restriction, including --
-- without limitation the rights to use, copy, modify, merge, publish, --
-- distribute, sublicense, and / or sell copies of the Software, and to --
-- permit persons to whom the Software is furnished to do so, subject to --
-- the following conditions: --
-- --
-- The above copyright notice and this permission notice shall be --
-- included in all copies or substantial portions of the Software. --
-- --
-- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, --
-- EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF --
-- MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. --
-- IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY --
-- CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, --
-- TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE --
-- SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. --
------------------------------------------------------------------------------
with Ada.Text_IO; use Ada.Text_IO;
with Ada.Strings.Fixed; use Ada.Strings.Fixed;
with Audio.Wavefiles; use Audio.Wavefiles;
with Audio.Wavefiles.Report; use Audio.Wavefiles.Report;
with Audio.Wavefiles.Data_Types; use Audio.Wavefiles.Data_Types;
with Audio.Wavefiles.Data_Types.Text_IO;
use Audio.Wavefiles.Data_Types.Text_IO;
#if NUM_TYPE'Defined and then (NUM_TYPE = "FLOAT") then
with Audio.Wavefiles.Generic_Float_PCM_IO;
#else
with Audio.Wavefiles.Generic_Fixed_PCM_IO;
#end if;
with Audio.RIFF.Wav.Formats; use Audio.RIFF.Wav.Formats;
with Audio.RIFF.Wav.Formats.Report;
#if NUM_TYPE'Defined and then (NUM_TYPE = "FLOAT") then
package body Quick_Wav_Data_Checks.Float_Checks is
#else
package body Quick_Wav_Data_Checks.Fixed_Checks is
#end if;
Verbose : constant Boolean := False;
type Integer_64 is range -2 ** 63 .. 2 ** 63 - 1
with Size => 64;
package Fixed_64_PCM_As_Integer_Text_IO is new
Ada.Text_IO.Integer_IO (Integer_64);
#if NUM_TYPE'Defined and then (NUM_TYPE = "FLOAT") then
subtype PCM_Sample is Wav_Float_128;
subtype PCM_Buffer is Wav_Buffer_Float_128;
subtype Channel_Range is Wav_Buffer_Range;
package PCM_Sample_Text_IO renames Wav_Float_128_Text_IO;
package PCM_IO is new Audio.Wavefiles.Generic_Float_PCM_IO
(PCM_Sample => PCM_Sample,
Channel_Range => Channel_Range,
PCM_MC_Sample => PCM_Buffer);
use PCM_IO;
PCM_Ref : constant PCM_Buffer (1 .. 11) :=
(1 => 2#1.0#e-0,
2 => -2#1.0#e-0,
3 => 2#1.0#e-1,
4 => -2#1.0#e-1,
5 => (2#1.0#e-0 + 2#1.0#e-23),
6 => (-2#1.0#e-0 - 2#1.0#e-23),
7 => (2#1.0#e-0 + 2#1.0#e-52),
8 => (-2#1.0#e-0 - 2#1.0#e-52),
9 => (2#1.0#e-0 + 2#1.0#e-56),
10 => (-2#1.0#e-0 - 2#1.0#e-56),
others => 0.0);
-- 32-bit Float: 23-bit mantissa
-- 64-bit Float: 52-bit mantissa
-- 128-bit Float: 112-bit mantissa
PCM_Ref_32 : constant PCM_Buffer (1 .. 11) :=
(1 => 2#1.0#e-0,
2 => -2#1.0#e-0,
3 => 2#1.0#e-1,
4 => -2#1.0#e-1,
5 => (2#1.0#e-0 + 2#1.0#e-23),
6 => (-2#1.0#e-0 - 2#1.0#e-23),
7 => (2#1.0#e-0),
8 => (-2#1.0#e-0),
9 => (2#1.0#e-0),
10 => (-2#1.0#e-0),
others => 0.0);
PCM_Ref_64 : constant PCM_Buffer (1 .. 11) :=
(1 => 2#1.0#e-0,
2 => -2#1.0#e-0,
3 => 2#1.0#e-1,
4 => -2#1.0#e-1,
5 => (2#1.0#e-0 + 2#1.0#e-23),
6 => (-2#1.0#e-0 - 2#1.0#e-23),
7 => (2#1.0#e-0 + 2#1.0#e-52),
8 => (-2#1.0#e-0 - 2#1.0#e-52),
9 => (2#1.0#e-0),
10 => (-2#1.0#e-0),
others => 0.0);
#else
subtype PCM_Sample is Wav_Fixed_64;
subtype PCM_Buffer is Wav_Buffer_Fixed_64;
subtype Channel_Range is Wav_Buffer_Range;
package PCM_Sample_Text_IO renames Wav_Fixed_64_Text_IO;
package PCM_IO is new Audio.Wavefiles.Generic_Fixed_PCM_IO
(PCM_Sample => PCM_Sample,
Channel_Range => Channel_Range,
PCM_MC_Sample => PCM_Buffer);
use PCM_IO;
PCM_Ref : constant PCM_Buffer (1 .. 15) :=
(1 => 16#0.FFFF_FFFF_FFFF_FFFE#,
2 => -2#1.0#e-0,
3 => 2#1.0#e-1,
4 => -2#1.0#e-1,
5 => 2#1.0#e-15,
6 => -2#1.0#e-15,
7 => 2#1.0#e-23,
8 => -2#1.0#e-23,
9 => 2#1.0#e-31,
10 => -2#1.0#e-31,
11 => 2#1.0#e-63,
12 => -2#1.0#e-63,
others => 0.0);
PCM_Ref_16 : constant PCM_Buffer (1 .. 15) :=
(1 => 16#0.FFFE_0000_0000_0000#,
2 => -2#1.0#e-0,
3 => 2#1.0#e-1,
4 => -2#1.0#e-1,
5 => 2#1.0#e-15,
6 => -2#1.0#e-15,
others => 0.0);
PCM_Ref_24 : constant PCM_Buffer (1 .. 15) :=
(1 => 16#0.FFFF_FE00_0000_0000#,
2 => -2#1.0#e-0,
3 => 2#1.0#e-1,
4 => -2#1.0#e-1,
5 => 2#1.0#e-15,
6 => -2#1.0#e-15,
7 => 2#1.0#e-23,
8 => -2#1.0#e-23,
others => 0.0);
PCM_Ref_32 : constant PCM_Buffer (1 .. 15) :=
(1 => 16#0.FFFF_FFFE_0000_0000#,
2 => -2#1.0#e-0,
3 => 2#1.0#e-1,
4 => -2#1.0#e-1,
5 => 2#1.0#e-15,
6 => -2#1.0#e-15,
7 => 2#1.0#e-23,
8 => -2#1.0#e-23,
9 => 2#1.0#e-31,
10 => -2#1.0#e-31,
others => 0.0);
#end if;
type Bits_Per_Sample_List is array (Positive range <>) of Wav_Bit_Depth;
#if NUM_TYPE'Defined and then (NUM_TYPE = "FLOAT") then
Test_Bits_Per_Sample : constant Bits_Per_Sample_List := (Bit_Depth_32,
Bit_Depth_64);
#else
Test_Bits_Per_Sample : constant Bits_Per_Sample_List := (Bit_Depth_16,
Bit_Depth_24,
Bit_Depth_32);
#end if;
procedure Display_PCM_Vals
(PCM_Vals : PCM_Buffer;
Header : String);
procedure Write_PCM_Vals
(WF : in out Wavefile;
PCM_Vals : PCM_Buffer);
function PCM_Data_Is_OK
(PCM_Ref, PCM_DUT : PCM_Buffer) return Boolean;
function PCM_Data_Is_OK
(Test_Bits : Wav_Bit_Depth;
PCM_DUT : PCM_Buffer) return Boolean;
function Wav_IO_OK_For_Audio_Resolution
(Test_Bits : Wav_Bit_Depth;
Wav_Test_File_Name : String) return Boolean;
procedure Display_Info
(WF : Wavefile;
Header : String);
procedure Write_Wavefile
(Wav_File_Name : String;
Test_Bits : Wav_Bit_Depth);
procedure Read_Wavefile
(Wav_File_Name : String;
PCM_DUT : out PCM_Buffer);
function Image (B : Wav_Bit_Depth) return String renames
Audio.RIFF.Wav.Formats.Report.Image;
----------------------
-- Display_PCM_Vals --
----------------------
procedure Display_PCM_Vals (PCM_Vals : PCM_Buffer;
Header : String)
is
#if NUM_TYPE'Defined and then (NUM_TYPE = "FLOAT") then
Display_Integer_Value : constant Boolean := False;
#else
Display_Integer_Value : constant Boolean := True;
#end if;
begin
Put_Line (Header);
for Sample_Count in PCM_Vals'Range loop
declare
#if NUM_TYPE'Defined and then (NUM_TYPE = "FLOAT") then
PCM_Integer : array (1 .. 2) of Integer_64
with
Address => PCM_Vals (Sample_Count)'Address,
Size => 128;
#else
PCM_Integer : Integer_64
with
Address => PCM_Vals (Sample_Count)'Address,
Size => 64;
#end if;
begin
Put (" Val: ");
PCM_Sample_Text_IO.Put (Item => PCM_Vals (Sample_Count),
Fore => 5,
Aft => 60,
Exp => 5);
if Display_Integer_Value then
Put (" - ");
#if NUM_TYPE'Defined and then (NUM_TYPE = "FLOAT") then
for I in PCM_Integer'Range loop
Fixed_64_PCM_As_Integer_Text_IO.Put
(PCM_Integer (I), Base => 2, Width => 68);
end loop;
#else
Fixed_64_PCM_As_Integer_Text_IO.Put
(PCM_Integer, Base => 2, Width => 68);
#end if;
end if;
New_Line;
end;
end loop;
end Display_PCM_Vals;
--------------------
-- Write_PCM_Vals --
--------------------
procedure Write_PCM_Vals (WF : in out Wavefile;
PCM_Vals : PCM_Buffer) is
PCM_Buf : PCM_Buffer (1 .. Number_Of_Channels (WF));
begin
for Sample_Count in PCM_Vals'Range loop
for J in PCM_Buf'Range loop
PCM_Buf (J) := PCM_Vals (Sample_Count);
end loop;
Put (WF, PCM_Buf);
end loop;
end Write_PCM_Vals;
------------------
-- Display_Info --
------------------
procedure Display_Info
(WF : Wavefile;
Header : String)
is
Separator : constant String
:= "===========================================================";
begin
Put_Line (Separator);
Put_Line (Header);
Display_Info (WF);
Put_Line (Separator);
end Display_Info;
--------------------
-- Write_Wavefile --
--------------------
procedure Write_Wavefile
(Wav_File_Name : String;
Test_Bits : Wav_Bit_Depth)
is
WF_Out : Wavefile;
Wave_Format : Wave_Format_Extensible;
begin
Wave_Format := Init (Bit_Depth => Test_Bits,
Sample_Rate => Sample_Rate_44100,
Number_Of_Channels => 2,
#if NUM_TYPE'Defined and then (NUM_TYPE = "FLOAT") then
Use_Float => True);
#else
Use_Float => False);
#end if;
WF_Out.Set_Format_Of_Wavefile (Wave_Format);
WF_Out.Create (Out_File, Wav_File_Name);
Write_PCM_Vals (WF_Out, PCM_Ref);
WF_Out.Close;
end Write_Wavefile;
-------------------
-- Read_Wavefile --
-------------------
procedure Read_Wavefile
(Wav_File_Name : String;
PCM_DUT : out PCM_Buffer)
is
WF_In : Wavefile;
-- Wave_Format : Wave_Format_Extensible;
EOF : Boolean;
Samples : Integer := 0;
begin
WF_In.Open (In_File, Wav_File_Name);
-- Wave_Format := WF_In.Format_Of_Wavefile;
if Verbose then
Display_Info (WF_In, "Input File:");
end if;
Samples := 0;
PCM_DUT := (others => 0.0);
loop
Samples := Samples + 1;
-- Put ("[" & Integer'Image (Samples) & "]");
declare
PCM_Buf : constant PCM_Buffer := Get (WF_In);
begin
PCM_DUT (Samples) := PCM_Buf (PCM_Buf'First);
end;
EOF := WF_In.End_Of_File;
exit when EOF;
end loop;
if Verbose then
Display_PCM_Vals (PCM_Ref,
"Constant PCM values for testing:");
Display_PCM_Vals (PCM_DUT,
"Read PCM values:");
end if;
WF_In.Close;
end Read_Wavefile;
--------------------
-- PCM_Data_Is_OK --
--------------------
function PCM_Data_Is_OK
(PCM_Ref, PCM_DUT : PCM_Buffer) return Boolean
is
Success : Boolean := True;
begin
for I in PCM_DUT'Range loop
if PCM_DUT (I) /= PCM_Ref (I) then
Put_Line ("- Error for check at index"
& Integer'Image (I));
Success := False;
end if;
end loop;
return Success;
end PCM_Data_Is_OK;
--------------------
-- PCM_Data_Is_OK --
--------------------
function PCM_Data_Is_OK
(Test_Bits : Wav_Bit_Depth;
PCM_DUT : PCM_Buffer) return Boolean is
begin
case Test_Bits is
#if NUM_TYPE'Defined and then (NUM_TYPE = "FLOAT") then
when Bit_Depth_32 =>
return PCM_Data_Is_OK (PCM_Ref_32, PCM_DUT);
when Bit_Depth_64 =>
return PCM_Data_Is_OK (PCM_Ref_64, PCM_DUT);
#else
when Bit_Depth_16 =>
return PCM_Data_Is_OK (PCM_Ref_16, PCM_DUT);
when Bit_Depth_24 =>
return PCM_Data_Is_OK (PCM_Ref_24, PCM_DUT);
when Bit_Depth_32 =>
return PCM_Data_Is_OK (PCM_Ref_32, PCM_DUT);
#end if;
when others =>
Put_Line ("Unknown test for "
& Image (Test_Bits)
& " bits");
return False;
end case;
end PCM_Data_Is_OK;
------------------------------------
-- Wav_IO_OK_For_Audio_Resolution --
------------------------------------
function Wav_IO_OK_For_Audio_Resolution
(Test_Bits : Wav_Bit_Depth;
Wav_Test_File_Name : String) return Boolean
is
Test_Bits_String : constant String
:= Trim (Image (Test_Bits), Ada.Strings.Both);
Wav_File_Name : constant String
:= Wav_Test_File_Name & "_" & Test_Bits_String & ".wav";
Test_Message : constant String
#if NUM_TYPE'Defined and then (NUM_TYPE = "FLOAT") then
:= "Float " & Image (Test_Bits);
#else
:= "Fixed " & Image (Test_Bits);
#end if;
PCM_DUT : PCM_Buffer (PCM_Ref'Range);
Success : Boolean := True;
begin
Write_Wavefile (Wav_File_Name, Test_Bits);
Read_Wavefile (Wav_File_Name, PCM_DUT);
if PCM_Data_Is_OK (Test_Bits, PCM_DUT) then
Put_Line ("PASS : " & Test_Message);
else
Put_Line ("FAIL : " & Test_Message);
Success := False;
end if;
return Success;
end Wav_IO_OK_For_Audio_Resolution;
---------------
-- Wav_IO_OK --
---------------
function Wav_IO_OK
(Wav_Filename_Prefix : String) return Boolean
is
Wav_Test_File_Name : constant String
#if NUM_TYPE'Defined and then (NUM_TYPE = "FLOAT") then
:= Wav_Filename_Prefix & "check_extremes_float";
#else
:= Wav_Filename_Prefix & "check_extremes_fixed";
#end if;
Success : Boolean := True;
begin
for Test_Bits of Test_Bits_Per_Sample loop
if not Wav_IO_OK_For_Audio_Resolution (Test_Bits,
Wav_Test_File_Name)
then
Success := False;
end if;
end loop;
return Success;
end Wav_IO_OK;
#if NUM_TYPE'Defined and then (NUM_TYPE = "FLOAT") then
end Quick_Wav_Data_Checks.Float_Checks;
#else
end Quick_Wav_Data_Checks.Fixed_Checks;
#end if;
|
with Ada.Calendar; use Ada.Calendar;
with Ada.Numerics; use Ada.Numerics;
with Ada.Numerics.Elementary_Functions; use Ada.Numerics.Elementary_Functions;
with Ada.Text_IO; use Ada.Text_IO;
procedure Test_Integrator is
type Func is access function (T : Time) return Float;
function Zero (T : Time) return Float is
begin
return 0.0;
end Zero;
Epoch : constant Time := Clock;
function Sine (T : Time) return Float is
begin
return Sin (Pi * Float (T - Epoch));
end Sine;
task type Integrator is
entry Input (Value : Func);
entry Output (Value : out Float);
entry Shut_Down;
end Integrator;
task body Integrator is
K : Func := Zero'Access;
S : Float := 0.0;
F0 : Float := 0.0;
F1 : Float;
T0 : Time := Clock;
T1 : Time;
begin
loop
select
accept Input (Value : Func) do
K := Value;
end Input;
or accept Output (Value : out Float) do
Value := S;
end Output;
or accept Shut_Down;
exit;
else
T1 := Clock;
F1 := K (T1);
S := S + 0.5 * (F1 + F0) * Float (T1 - T0);
T0 := T1;
F0 := F1;
end select;
end loop;
end Integrator;
I : Integrator;
S : Float;
begin
I.Input (Sine'Access);
delay 2.0;
I.Input (Zero'Access);
delay 0.5;
I.Output (S);
Put_Line ("Integrated" & Float'Image (S) & "s");
I.Shut_Down;
end Test_Integrator;
|
-------------------------------------------------------------------------------
-- Copyright 2021, The Septum Developers (see AUTHORS file)
-- 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.Containers.Vectors;
with SP.Cache;
with SP.Contexts;
with SP.Filters;
with SP.Strings;
package SP.Searches is
use SP.Strings;
type Search is limited private;
package Positive_Vectors is new Ada.Containers.Vectors (Index_Type => Positive, Element_Type => Positive);
use all type Ada.Containers.Count_Type;
function Reload_Working_Set (Srch : in out Search) return Boolean;
-- Dumps currently loaded search text and loads it again.
function Add_Directory (Srch : in out Search; Dir_Name : String) return Boolean;
function List_Directories (Srch : in Search) return String_Vectors.Vector;
-- Lists top level search directories.
procedure Clear_Directories (Srch : in out Search)
with Post => List_Directories (Srch).Is_Empty;
procedure Add_Extension (Srch : in out Search; Extension : String);
procedure Remove_Extension (Srch : in out Search; Extension : String);
procedure Clear_Extensions (Srch : in out Search);
function List_Extensions (Srch : in Search) return String_Vectors.Vector;
procedure Find_Text (Srch : in out Search; Text : String);
procedure Exclude_Text (Srch : in out Search; Text : String);
procedure Find_Like (Srch : in out Search; Text : String);
procedure Exclude_Like (Srch : in out Search; Text : String);
procedure Find_Regex (Srch : in out Search; Text : String);
procedure Exclude_Regex (Srch : in out Search; Text : String);
procedure Drop_Filter (Srch : in out Search; Index : Positive);
procedure Pop_Filter (Srch : in out Search);
-- Undoes the last search operations.
procedure Reorder_Filters (Srch : in out Search; Indices : Positive_Vectors.Vector)
with Pre => (for all Index of Indices => Natural (Index) <= Num_Filters (Srch))
and then (Natural (Indices.Length) = Num_Filters (Srch))
and then (for all I in 1 .. Num_Filters (Srch) => Indices.Contains (I));
procedure Clear_Filters (Srch : in out Search);
No_Context_Width : constant := Natural'Last;
procedure Set_Context_Width (Srch : in out Search; Context_Width : Natural);
function Get_Context_Width (Srch : in Search) return Natural;
No_Max_Results : constant := Natural'Last;
procedure Set_Max_Results (Srch : in out Search; Max_Results : Natural);
function Get_Max_Results (Srch : in Search) return Natural;
procedure Set_Search_On_Filters_Changed (Srch : in out Search; Enabled : Boolean);
function Get_Search_On_Filters_Changed (Srch : in out Search) return Boolean;
procedure Set_Line_Colors_Enabled (Srch : in out Search; Enabled : Boolean);
procedure Set_Print_Line_Numbers (Srch : in out Search; Enabled : Boolean);
function Get_Print_Line_Numbers (Srch : in Search) return Boolean;
function List_Filter_Names (Srch : in Search) return String_Vectors.Vector;
function Num_Filters (Srch : in Search) return Natural;
function Matching_Contexts (Srch : in Search) return SP.Contexts.Context_Vectors.Vector;
No_Limit : constant := Natural'Last;
procedure Print_Contexts (
Srch : in Search;
Contexts : SP.Contexts.Context_Vectors.Vector;
First : Natural;
Last : Natural);
procedure Print_Contexts_With_Cancellation(
Srch : in Search;
Contexts : SP.Contexts.Context_Vectors.Vector;
First : Natural;
Last : Natural);
function Num_Files (Srch : in Search) return Natural;
function Num_Lines (Srch : in Search) return Natural;
protected type Concurrent_Context_Results is
entry Get_Results(Out_Results : out SP.Contexts.Context_Vectors.Vector);
procedure Wait_For(Num_Results : Natural);
procedure Add_Result(More : SP.Contexts.Context_Vectors.Vector);
private
Pending_Results : Natural := 0;
Results : SP.Contexts.Context_Vectors.Vector;
end Concurrent_Context_Results;
function Is_Running_Script (Srch : Search; Script_Path : String) return Boolean;
procedure Push_Script (Srch : in out Search; Script_Path : String)
with Pre => not Is_Running_Script (Srch, Script_Path);
procedure Pop_Script (Srch : in out Search; Script_Path : String)
with Pre => Is_Running_Script (Srch, Script_Path);
procedure Test (Srch : Search; Input : String);
private
use SP.Filters;
-- The lines which match can determine the width of the context to be saved.
type Search is limited record
Directories : String_Sets.Set;
-- A list of all directories to search.
File_Cache : SP.Cache.Async_File_Cache;
-- Cached contents of files.
Line_Filters : Filter_List.Vector;
Extensions : String_Sets.Set;
Context_Width : Natural := 7;-- No_Context_Width;
Max_Results : Natural := No_Max_Results;
Print_Line_Numbers : Boolean := True;
Search_On_Filters_Changed : Boolean := False;
Enable_Line_Colors : Boolean := False;
-- The stack of currently executing scripts.
-- Intuitively this is a stack, but a set should work just a well,
-- since the focus is the membership test.
Script_Stack : String_Sets.Set;
end record;
end SP.Searches;
|
-- Copyright (c) 2021 Bartek thindil Jasicki <thindil@laeran.pl>
--
-- 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 Tcl.Strings; use Tcl.Strings;
with Tk.Widget; use Tk.Widget;
with Tk.TtkWidget; use Tk.TtkWidget;
-- ****h* Tk/TtkButton
-- FUNCTION
-- Provides code for manipulate Tk widget ttk::button
-- SOURCE
package Tk.TtkButton is
-- ****
--## rule off REDUCEABLE_SCOPE
-- ****t* TtkButton/TtkButton.Ttk_Button
-- FUNCTION
-- The Tk identifier of the ttk::button
-- HISTORY
-- 8.6.0 - Added
-- SOURCE
subtype Ttk_Button is Ttk_Widget;
-- ****
-- ****s* TtkButton/TtkButton.Ttk_Button_Options
-- FUNCTION
-- Data structure for all available options for the Tk ttk::button
-- OPTIONS
-- Command - The Tcl command which will be executed when the button
-- was pressed
-- Compound - Specifies if the button should display image and text in
-- the same time. If yes (other value than NONE or EMPTY),
-- then mean position of image related to the text
-- Default - Specifies the state for the default button (activated
-- when the user press Enter)
-- Image - Tk image used to display on the button. Default option
-- mean image used when other state's images are not
-- specified
-- State - The current state of the button
-- Text - The text displayed on the button
-- Text_Variable - The Tcl variable which value will be used for the text
-- on the button
-- Underline - The index of the character in the button text which will be
-- underlined. The index starts from 0
-- Width - Width of the button. If greater than 0, allocate that
-- much space for the button, if less than zero, it is
-- minimum width, if zero, use natural width
-- HISTORY
-- 8.6.0 - Added
-- SOURCE
type Ttk_Button_Options is new Ttk_Widget_Options with record
Command: Tcl_String := Null_Tcl_String;
Compound: Compound_Type := EMPTY;
Default: State_Type := NONE;
Image: Ttk_Image_Option := Default_Ttk_Image_Option;
State: Disabled_State_Type := NONE;
Text: Tcl_String := Null_Tcl_String;
Text_Variable: Tcl_String := Null_Tcl_String;
Underline: Extended_Natural := -1;
Width: Integer := 0;
end record;
-- ****
-- ****f* TtkButton/TtkButton.Create_(function)
-- FUNCTION
-- Create a new Tk button widget with the selected pathname and options
-- PARAMETERS
-- Path_Name - Tk pathname for the newly created button
-- Options - Options for the newly created button
-- Interpreter - Tcl interpreter on which the button will be created. Can
-- be empty. Default value is the default Tcl interpreter
-- RESULT
-- The Tk identifier of the newly created button widget
-- HISTORY
-- 8.6.0 - Added
-- EXAMPLE
-- -- Create the button with pathname .mybutton, text Quit and quitting from
-- -- the program on activate
-- My_Button: constant Ttk_Button := Create(".mybutton", (Text => To_Tcl_String("Quit"),
-- Command => To_Tcl_String("exit"), others => <>));
-- SEE ALSO
-- TtkButton.Create_(procedure)
-- COMMANDS
-- ttk::button Path_Name Options
-- SOURCE
function Create
(Path_Name: Tk_Path_String; Options: Ttk_Button_Options;
Interpreter: Tcl_Interpreter := Get_Interpreter) return Ttk_Button with
Pre'Class => Path_Name'Length > 0 and Interpreter /= Null_Interpreter,
Test_Case => (Name => "Test_Create_TtkButton1", Mode => Nominal);
-- ****
-- ****f* TtkButton/TtkButton.Create_(procedure)
-- FUNCTION
-- Create a new Tk button widget with the selected pathname and options
-- PARAMETERS
-- Button - Ttk_Button identifier which will be returned
-- Path_Name - Tk pathname for the newly created button
-- Options - Options for the newly created button
-- Interpreter - Tcl interpreter on which the button will be created. Can
-- be empty. Default value is the default Tcl interpreter
-- OUTPUT
-- The Button parameter as Tk identifier of the newly created button widget
-- HISTORY
-- 8.6.0 - Added
-- EXAMPLE
-- -- Create the button with pathname .mybutton, text Quit and quitting from
-- -- the program on activate
-- declare
-- My_Button: Ttk_Button;
-- begin
-- Create(My_Button, ".mybutton", (Text => To_Tcl_String("Quit"),
-- Command => To_Tcl_String("exit"), others => <>));
-- end;
-- SEE ALSO
-- TtkButton.Create_(function)
-- COMMANDS
-- ttk::button Path_Name Options
-- SOURCE
procedure Create
(Button: out Ttk_Button; Path_Name: Tk_Path_String;
Options: Ttk_Button_Options;
Interpreter: Tcl_Interpreter := Get_Interpreter) with
Pre'Class => Path_Name'Length > 0 and Interpreter /= Null_Interpreter,
Test_Case => (Name => "Test_Create_TtkButton2", Mode => Nominal);
-- ****
-- ****f* TtkButton/TtkButton.Get_Options
-- FUNCTION
-- Get all values of Tk options of the selected button
-- PARAMETERS
-- Button - Ttk_Button which options' values will be taken
-- RESULT
-- Ttk_Button_Options record with values of the selected button options
-- HISTORY
-- 8.6.0 - Added
-- EXAMPLE
-- -- Get all values of option of button with pathname .mybutton
-- My_Button_Options: constant Ttk_Button_Options := Get_Options(Get_Widget(".mybutton"));
-- SEE ALSO
-- TtkButton.Configure
-- COMMANDS
-- Button configure
-- SOURCE
function Get_Options(Button: Ttk_Button) return Ttk_Button_Options with
Pre'Class => Button /= Null_Widget,
Test_Case => (Name => "Test_Get_Options_TtkButton", Mode => Nominal);
-- ****
-- ****f* TtkButton/TtkButton.Configure
-- FUNCTION
-- Set the selected options for the selected button
-- PARAMETERS
-- Button - Ttk_Button which options will be set
-- Options - The record with new values for the button options
-- HISTORY
-- 8.6.0 - Added
-- EXAMPLE
-- -- Disable button with pathname .mybutton
-- Configure(Get_Widget(".mybutton"), (State => DISABLED, others => <>));
-- SEE ALSO
-- TtkButton.Get_Options
-- COMMANDS
-- Button configure Options
-- SOURCE
procedure Configure(Button: Ttk_Button; Options: Ttk_Button_Options) with
Pre'Class => Button /= Null_Widget,
Test_Case => (Name => "Test_Configure_TtkButton", Mode => Nominal);
-- ****
-- ****d* TtkButton/TtkButton.Default_Ttk_Button_Options
-- FUNCTION
-- The default options for the Ttk_Button
-- HISTORY
-- 8.6.0 - Added
-- SOURCE
Default_Ttk_Button_Options: constant Ttk_Button_Options :=
Ttk_Button_Options'(others => <>);
-- ****
-- ****f* TtkButton/TtkButton.Invoke_(procedure)
-- FUNCTION
-- Invoke the Tcl command associated with the selected button. Does
-- nothing if the button state is disabled.
-- PARAMETERS
-- Button - Ttk_Button which the command will be invoked
-- HISTORY
-- 8.6.0 - Added
-- EXAMPLE
-- -- Invoke the Tcl command of the Ttk_Button My_Button
-- Invoke(My_Button);
-- SEE ALSO
-- TtkButton.Invoke_(function_and_string_result), TtkButton.Invoke_(function_and_integer_result),
-- TtkButton.Invoke_(function_and_float_result)
-- COMMANDS
-- Button invoke
-- SOURCE
procedure Invoke(Button: Ttk_Button) with
Pre => Button /= Null_Widget,
Test_Case => (Name => "Test_Invoke_TtkButton1", Mode => Nominal);
-- ****
-- ****f* TtkButton/TtkButton.Invoke_(function)
-- FUNCTION
-- Invoke the Tcl command associated with the selected button. Does
-- nothing if the button state is disabled.
-- PARAMETERS
-- Button - Ttk_Button which the command will be invoked
-- RESULT
-- The string with the return value of the associated Tcl command.
-- HISTORY
-- 8.6.0 - Added
-- EXAMPLE
-- -- Invoke the Tcl command of the Ttk_Button My_Button
-- Result: constant String := Invoke(My_Button);
-- SEE ALSO
-- TtkButton.Invoke_(procedure)
-- COMMANDS
-- Button invoke
-- SOURCE
function Invoke(Button: Ttk_Button) return String with
Pre => Button /= Null_Widget,
Test_Case => (Name => "Test_Invoke_TtkButton2", Mode => Nominal);
-- ****
-- ****f* TtkButton/TtkButton.Generic_Scalar_Invoke_Button
-- FUNCTION
-- Invoke the Tcl command associated with the selected button. Does
-- nothing if the button state is disabled.
-- PARAMETERS
-- Button - Ttk_Button which the command will be invoked
-- RESULT
-- Scalar type result with the value of associated Tcl command.
-- HISTORY
-- 8.6.0 - Added
-- EXAMPLE
-- -- Invoke the Tcl command of the Ttk_Button My_Button
-- function Integer_Invoke is new Generic_Scalar_Invoke_Button(Integer);
-- Result: constant Integer := Integer_Invoke(My_Button);
-- SEE ALSO
-- TtkButton.Invoke_(function), TtkButton.Generic_Float_Invoke_Button,
-- COMMANDS
-- Button invoke
-- SOURCE
generic
type Result_Type is (<>);
function Generic_Scalar_Invoke_Button
(Button: Ttk_Button) return Result_Type;
-- ****
-- ****f* TtkButton/TtkButton.Generic_Float_Invoke_Button
-- FUNCTION
-- Invoke the Tcl command associated with the selected button. Does
-- nothing if the button state is disabled.
-- PARAMETERS
-- Button - Ttk_Button which the command will be invoked
-- RESULT
-- Float type result with the value of associated Tcl command.
-- HISTORY
-- 8.6.0 - Added
-- EXAMPLE
-- -- Invoke the Tcl command of the Ttk_Button My_Button
-- function Float_Invoke is new Generic_Float_Invoke_Button(Float);
-- Result: constant Float := Float_Invoke(My_Button);
-- SEE ALSO
-- TtkButton.Invoke_(function), TtkButton.Generic_Scalar_Invoke_Button,
-- COMMANDS
-- Button invoke
-- SOURCE
generic
type Result_Type is digits <>;
function Generic_Float_Invoke_Button(Button: Ttk_Button) return Result_Type;
-- ****
--## rule on REDUCEABLE_SCOPE
end Tk.TtkButton;
|
-- Copyright 2021 Jeff Foley. All rights reserved.
-- Use of this source code is governed by Apache 2 LICENSE that can be found in the LICENSE file.
local json = require("json")
name = "ARIN"
type = "api"
function start()
set_rate_limit(1)
end
function asn(ctx, addr, asn)
if addr == "" then
return
end
local resp, err = request(ctx, {url=asn_url(addr)})
if (err ~= nil and err ~= "") then
log(ctx, "asn request to service failed: " .. err)
return
end
local j = json.decode(resp)
if (j == nil or j.cidr0_cidrs == nil or j.arin_originas0_originautnums == nil or
#(j.cidr0_cidrs) == 0 or #(j.arin_originas0_originautnums) == 0) then
return
end
local asn = j.arin_originas0_originautnums[1]
if (j.cidr0_cidrs[1]['v4prefix'] == nil or j.cidr0_cidrs[1]['v4prefix'] == "") then
return
end
local cidr = j.cidr0_cidrs[1]['v4prefix'] .. "/" .. tostring(j.cidr0_cidrs[1]['length'])
if j.entities[1]['vcardArray'] == nil then
return
end
local desc = j.name .. " - " .. j.entities[1]['vcardArray'][2][2][4]
new_asn(ctx, {
['addr']=addr,
['asn']=asn,
['desc']=desc,
['prefix']=cidr,
})
end
function asn_url(addr)
return "https://rdap.arin.net/registry/ip/" .. addr
end
|
with
Ada.Text_IO,
Ada.Command_Line,
Ada.Numerics.Elementary_Functions;
use
Ada.Text_IO,
Ada.Command_Line,
Ada.Numerics.Elementary_Functions;
procedure Fib is
function fib(n : integer) return integer is
begin
if n < 2 then
return n;
else
return fib(n-1) + fib(n-2);
end if;
end fib;
function fibLinear(n : integer) return integer is
prevFib : integer := 0;
fib : integer := 1;
temp : integer;
begin
for i in 1..n loop
temp := prevFib + fib;
prevFib := fib;
fib := temp;
end loop;
return prevFib;
end fibLinear;
function fibFormula(n : integer) return integer is
begin
return integer(((5.0 ** 0.5 + 1.0) / 2.0) ** float(n) / 5.0 ** 0.5);
end fibFormula;
function fibTailAuxiliary(n : integer; prevFib : integer; fib : integer) return integer is
begin
if n = 0 then
return prevFib;
else
return fibTailAuxiliary(n - 1, fib, prevFib + fib);
end if;
end fibTailAuxiliary;
function fibTailRecursive(n : integer) return integer is
begin
return fibTailAuxiliary(n, 0, 1);
end fibTailRecursive;
input: Integer;
begin
if Argument_Count > 0 then
input := Integer'Value(Argument(1));
else
input := 29;
end if;
Put_Line(Integer'Image(fibLinear(input)));
end Fib;
|
-- Description: Wrapper to use Base_Unit_Type with a-nuelfu
-- TODO: all the postconditions are unproven, because a-nuelfu
-- builds on the generic C math interface
-- however, instead of modifying the RTS, we add them here and
-- leave them unproven (hoping the RTS introduces contracts later on)
package Units.Numerics with SPARK_Mode is
function Sqrt (X : Base_Unit_Type) return Base_Unit_Type with
Pre => X >= 0.0,
Contract_Cases => ((X >= 0.0 and then X < 1.0) => Sqrt'Result >= X,
(X >= 1.0) => Sqrt'Result <= X),
Post => Sqrt'Result >= 0.0;
function Log (X : Base_Unit_Type) return Base_Unit_Type with
Pre => X > 0.0,
Contract_Cases => ((X <= 1.0) => Log'Result <= 0.0,
(X > 1.0) => Log'Result >= 0.0),
Post => Log'Result < X;
-- natural logarithm of <X>, R=>R+
-- FIXME: very weak contract (magnitude of result could be approximated)
function Exp (X : Base_Unit_Type) return Base_Unit_Type with
Pre => X <= Log (Base_Unit_Type'Last),
Post => Exp'Result >= 0.0; -- allow rounding
-- return the base-e exponential function of <X>, i.e., e**X
function "**" (Left : Base_Unit_Type; Right : Float) return Base_Unit_Type
with Pre => Left > 0.0;
-- FIXME: change implementation to allow negative base
function Sin (X : Angle_Type) return Base_Unit_Type with
Post => Sin'Result in -1.0 .. 1.0;
-- @req cosine-x
function Cos (X : Angle_Type) return Base_Unit_Type with
Post => Cos'Result in -1.0 .. 1.0;
function Arctan
(Y : Base_Unit_Type;
X : Base_Unit_Type := 1.0) return Angle_Type with
Pre => X /= 0.0 or Y /= 0.0,
Contract_Cases => ( Y >= 0.0 => Arctan'Result in 0.0 * Degree .. 180.0 * Degree,
Y < 0.0 => Arctan'Result in -180.0 * Degree .. 0.0 * Degree);
-- Calculates angle to point y,x
-- These postconditions are backed up by unit tests on the STM32F4 target.
function Arctan
(Y : Base_Unit_Type'Base;
X : Base_Unit_Type'Base := 1.0;
Cycle : Angle_Type) return Angle_Type with
Post => Arctan'Result in -Cycle/2.0 .. Cycle/2.0;
-- Calculates angle to point y,x, but wraps the result into the given cycle
-- function Arccot
-- (X : Base_Unit_Type;
-- Y : Base_Unit_Type := 1.0) return Angle_Type;
--
-- function Arccot
-- (X : Base_Unit_Type;
-- Y : Base_Unit_Type := 1.0;
-- Cycle : Angle_Type) return Angle_Type;
--
-- function Arcsin (X : Angle_Type) return Base_Unit_Type
-- with Post => Arcsin'Result in -90.0*Degree .. 90.0*Degree;
--
-- function Cos (X, Cycle : Angle_Type) return Base_Unit_Type;
--
-- function Tan (X : Angle_Type) return Base_Unit_Type;
--
-- function Tan (X, Cycle : Angle_Type) return Base_Unit_Type;
--
-- function Cot (X : Angle_Type) return Base_Unit_Type;
--
-- function Cot (X, Cycle : Angle_Type) return Base_Unit_Type;
--
-- function Arcsin (X : Base_Unit_Type) return Angle_Type;
--
-- function Arcsin (X : Base_Unit_Type; Cycle : Angle_Type) return Angle_Type;
--
-- function Arccos (X : Base_Unit_Type) return Angle_Type;
--
-- function Arccos (X : Base_Unit_Type; Cycle : Angle_Type) return Angle_Type;
--
-- function Exp (X : Base_Unit_Type) return Float;
--
-- function Log (X : Base_Unit_Type) return Float;
end Units.Numerics;
|
------------------------------------------------------------------------------
-- G E L A A S I S --
-- ASIS implementation for Gela project, a portable Ada compiler --
-- http://gela.ada-ru.org --
-- - - - - - - - - - - - - - - - --
-- Read copyright and license at the end of this file --
------------------------------------------------------------------------------
-- $Revision: 209 $ $Date: 2013-11-30 21:03:24 +0200 (Сб., 30 нояб. 2013) $
-- Purpose:
-- Helper subprograms
with Asis.Declarations;
private package Asis.Gela.Normalizer.Utils is
procedure Set_Default_Kind (Element : Asis.Element);
procedure Set_Names
(Element : Asis.Element;
Name : Asis.Defining_Name := Asis.Nil_Element);
procedure Check_Empty_Profile (Element : in out Asis.Element);
procedure Check_Empty_Result (Profile : in out Asis.Element);
procedure Check_Empty_Generic (Element : Asis.Element);
procedure Normalize_Access_Type (Element : Asis.Element);
procedure Normalize_Formal_Access_Type (Element : Asis.Element);
procedure Normalize_Attribute_Reference (Element : Asis.Element);
procedure Normalize_Qualified_Expression (Element : Asis.Element);
procedure Normalize_Procedure_Call (Element : Asis.Element);
procedure Normalize_Pragma_Argument (Element : in out Asis.Expression);
procedure Normalize_Function_Call
(Element : in out Asis.Element;
Control : in out Traverse_Control;
State : in out State_Information);
procedure Normalize_Record_Aggregate
(Element : in out Asis.Element;
Control : in out Traverse_Control;
State : in out State_Information);
procedure To_Deferred_Constant (Element : in out Asis.Element);
procedure Normalize_Enumeration_Rep_Clause (Element : in out Asis.Element);
procedure Set_Start_Position
(Element, Source : Asis.Element);
procedure Set_Enum_Positions
(List : Asis.Declaration_List);
procedure Create_Incomplete_Definition (Element : Asis.Declaration);
----------------------------------
-- Split_Function_Specification --
----------------------------------
generic
type Node_Type is new Element_Node with private;
with function Specification (Element : Node_Type)
return Asis.Element is <>;
with procedure Set_Parameter_Profile
(Element : in out Node_Type;
Value : in Asis.Element) is <>;
with procedure Set_Result_Subtype
(Element : in out Node_Type;
Value : in Asis.Expression) is <>;
procedure Split_Function_Specification (Element : Asis.Element);
-----------------------------------
-- Split_Procedure_Specification --
-----------------------------------
generic
type Node_Type is new Element_Node with private;
with function Specification (Element : Node_Type)
return Asis.Element is <>;
with procedure Set_Parameter_Profile
(Element : in out Node_Type;
Value : in Asis.Element) is <>;
procedure Split_Procedure_Specification (Element : Asis.Element);
-------------------
-- Split_Profile --
-------------------
generic
type Node_Type is new Element_Node with private;
with function Result_Subtype (Element : Node_Type)
return Asis.Element is <>;
with procedure Set_Parameter_Profile
(Element : in out Node_Type;
Value : in Asis.Element) is <>;
with procedure Set_Result_Subtype
(Element : in out Node_Type;
Value : in Asis.Definition) is <>;
procedure Split_Profile (Element : Asis.Element);
----------------------------------
-- Normalize_Handled_Statements --
----------------------------------
generic
type Node_Type is new Element_Node with private;
with function Handled_Statements
(Element : Node_Type) return Asis.Element is <>;
with procedure Set_Statements
(Element : in out Node_Type;
Value : in Asis.Element) is <>;
with procedure Set_Exception_Handlers
(Element : in out Node_Type;
Value : in Asis.Element) is <>;
procedure Normalize_Handled_Statements (Element : Asis.Element);
---------------------------
-- Check_Back_Identifier --
---------------------------
generic
type Node_Type is new Element_Node with private;
with function Compound_Name
(Element : Node_Type) return Asis.Element is <>;
with procedure Set_Is_Name_Repeated
(Element : in out Node_Type;
Value : in Boolean) is <>;
with function Names (Element : Asis.Element) return Asis.Element_List
is Asis.Declarations.Names;
procedure Check_Back_Identifier (Element : Asis.Element);
---------------------------------
-- Split_Package_Specification --
---------------------------------
generic
type Node_Type is new Element_Node with private;
with function Specification (Element : Node_Type)
return Asis.Element is <>;
with procedure Set_Is_Name_Repeated
(Element : in out Node_Type;
Value : in Boolean) is <>;
with procedure Set_Is_Private_Present
(Element : in out Node_Type;
Value : in Boolean) is <>;
with procedure Set_Visible_Part_Declarative_Items
(Element : in out Node_Type;
Value : in Asis.Element) is <>;
with procedure Set_Private_Part_Declarative_Items
(Element : in out Node_Type;
Value : in Asis.Element) is <>;
procedure Split_Package_Specification (Element : Asis.Element);
---------------------------
-- Set_Generic_Unit_Name --
---------------------------
generic
type Node_Type is new Element_Node with private;
with procedure Set_Generic_Unit_Name
(Element : in out Node_Type;
Value : in Asis.Expression) is <>;
procedure Set_Generic_Unit_Names (Element : Asis.Element);
generic
type Node_Type is new Element_Node with private;
with procedure Set_Trait_Kind
(Element : in out Node_Type;
Value : in Asis.Trait_Kinds) is <>;
procedure Set_Trait_Kind (Element : Asis.Element);
------------------------------
-- Normalize_Component_List --
------------------------------
generic
type Node_Type is new Element_Node with private;
with function Record_Components_List
(Element : Node_Type) return Asis.Element is <>;
procedure Normalize_Component_List (Element : Asis.Element);
---------------------
-- Set_Has_Private --
---------------------
generic
type Node_Type is new Element_Node with private;
with function Private_Part_Items_List
(Element : Node_Type) return Asis.Element is <>;
with procedure Set_Is_Private_Present
(Element : in out Node_Type;
Value : in Boolean) is <>;
procedure Set_Has_Private (Element : Asis.Element);
----------------------
-- Set_Formal_Array --
----------------------
generic
type Node_Type is new Element_Node with private;
type Array_Type is new Element_Node with private;
with procedure Set_Index_Subtype_Definitions
(Element : in out Node_Type;
Value : in Asis.Element) is <>;
with function Index_Subtype_Definitions_List
(Element : Array_Type) return Asis.Element is <>;
with procedure Set_Array_Component_Definition
(Element : in out Node_Type;
Value : in Asis.Component_Definition) is <>;
with function Array_Definition
(Element : Node_Type) return Asis.Element is <>;
-- with function Array_Component_Definition
-- (Element : Array_Type) return Asis.Element is <>;
procedure Set_Formal_Array (Element : Asis.Element);
-------------------------------
-- Drop_Range_Attr_Reference --
-------------------------------
generic
type Node_Type is new Element_Node with private;
with procedure Set_Range_Attribute
(Element : in out Node_Type;
Value : in Asis.Expression) is <>;
procedure Drop_Range_Attr_Reference (Element : Asis.Element);
generic
type Node_Type is new Element_Node with private;
with procedure Set_Subtype_Mark
(Element : in out Node_Type;
Value : in Asis.Expression) is <>;
with procedure Set_Subtype_Constraint
(Element : in out Node_Type;
Value : in Asis.Constraint) is <>;
procedure Drop_Range_Subtype_Indication (Element : Asis.Element);
end Asis.Gela.Normalizer.Utils;
------------------------------------------------------------------------------
-- Copyright (c) 2006-2013, Maxim Reznik
-- 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 Maxim Reznik, 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 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.
------------------------------------------------------------------------------
|
------------------------------------------------------------------------------
-- --
-- GNAT RUN-TIME COMPONENTS --
-- --
-- S Y S T E M . S C A L A R _ V A L U E S --
-- --
-- B o d y --
-- --
-- Copyright (C) 2003-2021, 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. --
-- --
-- --
-- --
-- --
-- --
-- You should have received a copy of the GNU General Public License and --
-- a copy of the GCC Runtime Library Exception along with this program; --
-- see the files COPYING3 and COPYING.RUNTIME respectively. If not, see --
-- <http://www.gnu.org/licenses/>. --
-- --
-- GNAT was originally developed by the GNAT team at New York University. --
-- Extensive contributions were provided by Ada Core Technologies Inc. --
-- --
------------------------------------------------------------------------------
with Ada.Unchecked_Conversion;
package body System.Scalar_Values is
use Interfaces;
----------------
-- Initialize --
----------------
procedure Initialize (Mode1 : Character; Mode2 : Character) is
C1 : Character := Mode1;
C2 : Character := Mode2;
procedure Get_Env_Value_Ptr (Name, Length, Ptr : Address);
pragma Import (C, Get_Env_Value_Ptr, "__gnat_getenv");
subtype String2 is String (1 .. 2);
type String2_Ptr is access all String2;
Env_Value_Ptr : aliased String2_Ptr;
Env_Value_Length : aliased Integer;
EV_Val : aliased constant String :=
"GNAT_INIT_SCALARS" & ASCII.NUL;
B : Byte1;
EFloat : constant Boolean := Long_Long_Float'Size > Long_Float'Size;
-- Set True if we are on an x86 with 96-bit floats for extended
type ByteLF is array (0 .. 7) of Byte1;
for ByteLF'Component_Size use 8;
-- Type used to hold Long_Float values on all targets. On most targets
-- the type is 8 bytes, and type Byte8 is used for values that are then
-- converted to ByteLF.
function To_ByteLF is new Ada.Unchecked_Conversion (Byte8, ByteLF);
type ByteLLF is array (0 .. 7 + 4 * Boolean'Pos (EFloat)) of Byte1;
for ByteLLF'Component_Size use 8;
-- Type used to initialize Long_Long_Float values used on x86 and
-- any other target with the same 80-bit floating-point values that
-- GCC always stores in 96-bits. Note that we are assuming Intel
-- format little-endian addressing for this type. On non-Intel
-- architectures, this is the same length as Byte8 and holds
-- a Long_Float value.
-- The following variables are used to initialize the float values
-- by overlay. We can't assign directly to the float values, since
-- we may be assigning signalling Nan's that will cause a trap if
-- loaded into a floating-point register.
IV_Isf : aliased Byte4; -- Initialize short float
IV_Ifl : aliased Byte4; -- Initialize float
IV_Ilf : aliased ByteLF; -- Initialize long float
IV_Ill : aliased ByteLLF; -- Initialize long long float
for IV_Isf'Address use IS_Isf'Address;
for IV_Ifl'Address use IS_Ifl'Address;
for IV_Ilf'Address use IS_Ilf'Address;
for IV_Ill'Address use IS_Ill'Address;
-- The following pragmas are used to suppress initialization
pragma Import (Ada, IV_Isf);
pragma Import (Ada, IV_Ifl);
pragma Import (Ada, IV_Ilf);
pragma Import (Ada, IV_Ill);
begin
-- Acquire environment variable value if necessary
if C1 = 'E' and then C2 = 'V' then
Get_Env_Value_Ptr
(EV_Val'Address, Env_Value_Length'Address, Env_Value_Ptr'Address);
-- Ignore if length is not 2
if Env_Value_Length /= 2 then
C1 := 'I';
C2 := 'N';
-- Length is 2, see if it is a valid value
else
-- Acquire two characters and fold to upper case
C1 := Env_Value_Ptr (1);
C2 := Env_Value_Ptr (2);
if C1 in 'a' .. 'z' then
C1 := Character'Val (Character'Pos (C1) - 32);
end if;
if C2 in 'a' .. 'z' then
C2 := Character'Val (Character'Pos (C2) - 32);
end if;
-- IN/LO/HI are ok values
if (C1 = 'I' and then C2 = 'N')
or else
(C1 = 'L' and then C2 = 'O')
or else
(C1 = 'H' and then C2 = 'I')
then
null;
-- Try for valid hex digits
elsif (C1 in '0' .. '9' or else C1 in 'A' .. 'Z')
or else
(C2 in '0' .. '9' or else C2 in 'A' .. 'Z')
then
null;
-- Otherwise environment value is bad, ignore and use IN (invalid)
else
C1 := 'I';
C2 := 'N';
end if;
end if;
end if;
-- IN (invalid value)
if C1 = 'I' and then C2 = 'N' then
IS_Is1 := 16#80#;
IS_Is2 := 16#8000#;
IS_Is4 := 16#8000_0000#;
IS_Is8 := 16#8000_0000_0000_0000#;
IS_Iu1 := 16#FF#;
IS_Iu2 := 16#FFFF#;
IS_Iu4 := 16#FFFF_FFFF#;
IS_Iu8 := 16#FFFF_FFFF_FFFF_FFFF#;
IS_Iz1 := 16#00#;
IS_Iz2 := 16#0000#;
IS_Iz4 := 16#0000_0000#;
IS_Iz8 := 16#0000_0000_0000_0000#;
IV_Isf := IS_Iu4;
IV_Ifl := IS_Iu4;
IV_Ilf := To_ByteLF (IS_Iu8);
if EFloat then
IV_Ill := (0, 0, 0, 0, 0, 0, 0, 16#C0#, 16#FF#, 16#FF#, 0, 0);
end if;
-- LO (Low values)
elsif C1 = 'L' and then C2 = 'O' then
IS_Is1 := 16#80#;
IS_Is2 := 16#8000#;
IS_Is4 := 16#8000_0000#;
IS_Is8 := 16#8000_0000_0000_0000#;
IS_Iu1 := 16#00#;
IS_Iu2 := 16#0000#;
IS_Iu4 := 16#0000_0000#;
IS_Iu8 := 16#0000_0000_0000_0000#;
IS_Iz1 := 16#00#;
IS_Iz2 := 16#0000#;
IS_Iz4 := 16#0000_0000#;
IS_Iz8 := 16#0000_0000_0000_0000#;
IV_Isf := 16#FF80_0000#;
IV_Ifl := 16#FF80_0000#;
IV_Ilf := To_ByteLF (16#FFF0_0000_0000_0000#);
if EFloat then
IV_Ill := (0, 0, 0, 0, 0, 0, 0, 16#80#, 16#FF#, 16#FF#, 0, 0);
end if;
-- HI (High values)
elsif C1 = 'H' and then C2 = 'I' then
IS_Is1 := 16#7F#;
IS_Is2 := 16#7FFF#;
IS_Is4 := 16#7FFF_FFFF#;
IS_Is8 := 16#7FFF_FFFF_FFFF_FFFF#;
IS_Iu1 := 16#FF#;
IS_Iu2 := 16#FFFF#;
IS_Iu4 := 16#FFFF_FFFF#;
IS_Iu8 := 16#FFFF_FFFF_FFFF_FFFF#;
IS_Iz1 := 16#FF#;
IS_Iz2 := 16#FFFF#;
IS_Iz4 := 16#FFFF_FFFF#;
IS_Iz8 := 16#FFFF_FFFF_FFFF_FFFF#;
IV_Isf := 16#7F80_0000#;
IV_Ifl := 16#7F80_0000#;
IV_Ilf := To_ByteLF (16#7FF0_0000_0000_0000#);
if EFloat then
IV_Ill := (0, 0, 0, 0, 0, 0, 0, 16#80#, 16#FF#, 16#7F#, 0, 0);
end if;
-- -Shh (hex byte)
else
-- Convert the two hex digits (we know they are valid here)
B := 16 * (Character'Pos (C1)
- (if C1 in '0' .. '9'
then Character'Pos ('0')
else Character'Pos ('A') - 10))
+ (Character'Pos (C2)
- (if C2 in '0' .. '9'
then Character'Pos ('0')
else Character'Pos ('A') - 10));
-- Initialize data values from the hex value
IS_Is1 := B;
IS_Is2 := 2**8 * Byte2 (IS_Is1) + Byte2 (IS_Is1);
IS_Is4 := 2**16 * Byte4 (IS_Is2) + Byte4 (IS_Is2);
IS_Is8 := 2**32 * Byte8 (IS_Is4) + Byte8 (IS_Is4);
IS_Iu1 := IS_Is1;
IS_Iu2 := IS_Is2;
IS_Iu4 := IS_Is4;
IS_Iu8 := IS_Is8;
IS_Iz1 := IS_Is1;
IS_Iz2 := IS_Is2;
IS_Iz4 := IS_Is4;
IS_Iz8 := IS_Is8;
IV_Isf := IS_Is4;
IV_Ifl := IS_Is4;
IV_Ilf := To_ByteLF (IS_Is8);
if EFloat then
IV_Ill := (B, B, B, B, B, B, B, B, B, B, B, B);
end if;
end if;
-- If no separate Long_Long_Float, then use Long_Float value as
-- Long_Long_Float initial value.
if not EFloat then
declare
pragma Warnings (Off); -- because sizes don't match
function To_ByteLLF is
new Ada.Unchecked_Conversion (ByteLF, ByteLLF);
pragma Warnings (On);
begin
IV_Ill := To_ByteLLF (IV_Ilf);
end;
end if;
end Initialize;
end System.Scalar_Values;
|
--
-- ABench2020 Benchmark Suite
--
-- Sample Correlation Coefficient Calculation Program
--
-- Licensed under the MIT License. See LICENSE file in the ABench root
-- directory for license information.
--
-- Uncomment the line below to print the result.
-- with Ada.Text_IO; use Ada.Text_IO;
with Ada.Numerics.Elementary_Functions; use Ada.Numerics.Elementary_Functions;
procedure Correlation is
type Float_Array is array (1..10) of Float;
function Calc_Coefficient (Sample_X, Sample_Y : in Float_Array) return Float is
Coefficient : Float := 0.0;
Sum_X, Sum_Y, Sum_XY : Float := 0.0;
Square_Sum_X, Square_Sum_Y : Float := 0.0;
Avg_X, Avg_Y : Float := 0.0;
begin
for I in Sample_X'First..Sample_X'Last loop
Sum_X := Sum_X + Sample_X (I);
end loop;
Avg_X := Sum_X / Float(Sample_X'Length);
for I in Sample_Y'First..Sample_Y'Last loop
Sum_Y := Sum_Y + Sample_Y (I);
end loop;
Avg_Y := Sum_Y / Float(Sample_Y'Length);
for I in Sample_X'First..Sample_X'Last loop
Sum_XY := Sum_XY + ((Sample_X (I) - Avg_X) * (Sample_Y (I) - Avg_Y));
end loop;
for I in Sample_X'First..Sample_X'Last loop
Square_Sum_X := Square_Sum_X + ((Sample_X (I) - Avg_X) * (Sample_X (I) - Avg_X));
Square_Sum_Y := Square_Sum_Y + ((Sample_Y (I) - Avg_Y) * (Sample_Y (I) - Avg_Y));
end loop;
Coefficient := Sum_XY / Sqrt (Square_Sum_X * Square_Sum_Y);
return Coefficient;
end;
Result : Float;
Sample_X : Float_Array := (15.0, 18.0, 21.0, 23.0, 27.0, 33.4, 4.7, 21.2,
15.0, 34.2);
Sample_Y : Float_Array := (25.0, 12.1, 27.0, 31.0, 32.0, 1.1, 6.5, 23.0,
4.4, 6.2);
begin
Result := Calc_Coefficient (Sample_X, Sample_Y);
-- Uncomment the line below to print the result.
-- Put_Line (Float'Image (Result));
end;
|
------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- Localization, Internationalization, Globalization for Ada --
-- --
-- Runtime Library Component --
-- --
------------------------------------------------------------------------------
-- --
-- Copyright © 2010-2013, Vadim Godunko <vgodunko@gmail.com> --
-- 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.SIMD.Intel.MMX;
package body Matreshka.SIMD.Intel.SSE is
use Matreshka.SIMD.Intel.MMX;
-----------------
-- mm_cmpge_ss --
-----------------
-- function mm_cmpge_ss (A : v4sf; B : v4sf) return v4sf is
-- begin
-- return mm_move_ss (A, mm_cmple_ss (B, A));
-- end mm_cmpge_ss;
-----------------
-- mm_cmpgt_ss --
-----------------
-- function mm_cmpgt_ss (A : v4sf; B : v4sf) return v4sf is
-- begin
-- return mm_move_ss (A, mm_cmplt_ss (B, A));
-- end mm_cmpgt_ss;
------------------
-- mm_cmpnge_ss --
------------------
-- function mm_cmpnge_ss (A : v4sf; B : v4sf) return v4sf is
-- begin
-- return mm_move_ss (A, mm_cmpnle_ss (B, A));
-- end mm_cmpnge_ss;
------------------
-- mm_cmpngt_ss --
------------------
-- function mm_cmpngt_ss (A : v4sf; B : v4sf) return v4sf is
-- begin
-- return mm_move_ss (A, mm_cmpnlt_ss (B, A));
-- end mm_cmpngt_ss;
-------------------
-- mm_cvtpi16_ps --
-------------------
function mm_cvtpi16_ps (A : v4hi) return v4sf is
Sign : v4hi;
HiSi : v2si;
LoSi : v2si;
Zero : v4sf;
Ra : v4sf;
Rb : v4sf;
begin
-- This comparison against zero gives us a mask that can be used to
-- fill in the missing sign bits in the unpack operations below, so
-- that we get signed values after unpacking.
Sign := mm_cmpgt_pi16 ((others => 0), A);
-- Convert the four words to doublewords.
LoSi := To_v2si (mm_unpacklo_pi16 (A, Sign));
HiSi := To_v2si (mm_unpackhi_pi16 (A, Sign));
-- Convert the doublewords to floating point two at a time.
Zero := mm_setzero_ps;
Ra := mm_cvtpi32_ps (Zero, LoSi);
Rb := mm_cvtpi32_ps (Ra, HiSi);
return mm_movelh_ps (Ra, Rb);
end mm_cvtpi16_ps;
---------------------
-- mm_cvtpi32x2_ps --
---------------------
function mm_cvtpi32x2_ps (A : v2si; B : v2si) return v4sf is
Zero : v4sf;
Sfa : v4sf;
Sfb : v4sf;
begin
Zero := mm_setzero_ps;
Sfa := mm_cvtpi32_ps (Zero, A);
Sfb := mm_cvtpi32_ps (Sfa, B);
return mm_movelh_ps (Sfa, Sfb);
end mm_cvtpi32x2_ps;
------------------
-- mm_cvtpi8_ps --
------------------
function mm_cvtpi8_ps (A : v8qi) return v4sf is
Sign : v8qi;
B : v8qi;
begin
-- This comparison against zero gives us a mask that can be used to
-- fill in the missing sign bits in the unpack operations below, so
-- that we get signed values after unpacking.
Sign := mm_cmpgt_pi8 (To_v8qi (mm_setzero_si64), A);
-- Convert the four low bytes to words.
B := mm_unpacklo_pi8 (A, Sign);
return mm_cvtpi16_ps (To_v4hi (B));
end mm_cvtpi8_ps;
-------------------
-- mm_cvtps_pi16 --
-------------------
function mm_cvtps_pi16 (A : v4sf) return v4hi is
HiSf : v4sf;
LoSf : v4sf;
HiSi : v2si;
LoSi : v2si;
begin
HiSf := A;
LoSf := mm_movehl_ps (HiSf, HiSf);
HiSi := mm_cvtps_pi32 (HiSf);
LoSi := mm_cvtps_pi32 (LoSf);
return mm_packs_pi32 (HiSi, LoSi);
end mm_cvtps_pi16;
------------------
-- mm_cvtps_pi8 --
------------------
function mm_cvtps_pi8 (A : v4sf) return v8qi is
Tmp : v4hi;
begin
Tmp := mm_cvtps_pi16 (A);
return mm_packs_pi16 (Tmp, (others => 0));
end mm_cvtps_pi8;
-------------------
-- mm_cvtpu16_ps --
-------------------
function mm_cvtpu16_ps (A : v4hi) return v4sf is
HiSi : v2si;
LoSi : v2si;
Zero : v4sf;
Ra : v4sf;
Rb : v4sf;
begin
-- Convert the four words to doublewords.
LoSi := To_v2si (mm_unpacklo_pi16 (A, (others => 0)));
HiSi := To_v2si (mm_unpackhi_pi16 (A, (others => 0)));
-- Convert the doublewords to floating point two at a time.
Zero := mm_setzero_ps;
Ra := mm_cvtpi32_ps (Zero, LoSi);
Rb := mm_cvtpi32_ps (Ra, HiSi);
return mm_movelh_ps (Ra, Rb);
end mm_cvtpu16_ps;
------------------
-- mm_cvtpu8_ps --
------------------
function mm_cvtpu8_ps (A : v8qi) return v4sf is
B : v8qi;
begin
B := mm_unpacklo_pi8 (A, To_v8qi (mm_setzero_si64));
return mm_cvtpu16_ps (To_v4hi (B));
end mm_cvtpu8_ps;
-------------------
-- mm_setzero_ps --
-------------------
function mm_setzero_ps return v4sf is
begin
return (0.0, 0.0, 0.0, 0.0);
end mm_setzero_ps;
end Matreshka.SIMD.Intel.SSE;
|
-- Copyright 2015,2016 Steven Stewart-Gallus
--
-- 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 Linted.Angles;
package Linted.Types is
pragma Pure;
type Large is range -2**(64 - 1) .. 2**(64 - 1) - 1;
type Nat is mod 2**32;
type Int is range -2**(32 - 1) .. 2**(32 - 1) - 1;
type Fixed is delta 1.0 / 2.0**30 range -2.0**32 .. 2.0**32 + 1.0;
package Sim_Angles is new Linted.Angles (Nat);
subtype Sim_Angle is Sim_Angles.Angle;
type Differentiable is record
Value : Int;
Old : Int;
end record;
type Position is (X, Y, Z);
type Varying_Positions is array (Position) of Differentiable;
type Object_State is array (Positive range <>) of Types.Varying_Positions;
function Absolute (X : Types.Int) return Types.Nat with
Post => Absolute'Result <= Types.Nat (Types.Int'Last) + 1,
Global => null,
Depends => (Absolute'Result => X);
function Tilt_Rotation
(Rotation : Types.Sim_Angle;
Tilt : Types.Int) return Types.Sim_Angle with
Global => null,
Depends => (Tilt_Rotation'Result => (Rotation, Tilt));
function Tilt_Clamped_Rotation
(Rotation : Types.Sim_Angle;
Tilt : Types.Int) return Types.Sim_Angle with
Global => null,
Depends => (Tilt_Clamped_Rotation'Result => (Rotation, Tilt));
function Min_Int (X : Types.Int; Y : Types.Int) return Types.Int;
function Find_Sign (X : Types.Int) return Types.Int;
function Saturate (X : Types.Large) return Types.Int;
function Sim_Isatadd (X : Types.Int; Y : Types.Int) return Types.Int;
function Downscale (X : Types.Int; Y : Types.Int) return Types.Int;
function Sim_Sin is new Types.Sim_Angles.Sin (Fixed);
function Sim_Cos is new Types.Sim_Angles.Cos (Fixed);
end Linted.Types;
|
with Ada.Text_IO;
package TOML.File_IO is
-- Subprograms to load/save TOML files
use all type Ada.Text_IO.File_Mode;
function Load_File (Filename : String) return Read_Result;
-- Read Filename and parse its content as a TOML document
procedure Dump_To_File
(Value : TOML_Value; File : in out Ada.Text_IO.File_Type)
with Pre => Value.Kind = TOML_Table
and then Ada.Text_IO.Mode (File) in Out_File | Append_File;
-- Serialize Value and write the corresponding TOML document to File
end TOML.File_IO;
|
-- RUN: %llvmgcc -S %s
package Field_Order is
type Tagged_Type is abstract tagged null record;
type With_Discriminant (L : Positive) is new Tagged_Type with record
S : String (1 .. L);
end record;
end;
|
pragma Ada_2012;
-------------------------------
-- Protypo.API.Engine_Values --
-------------------------------
package body Protypo.API.Engine_Values is
function "mod" (X, Y : Integer_Value) return Integer_Value
is
begin
return Engine_Value'(Class => Int,
Int_Val => X.Int_Val mod Y.Int_Val);
end "mod";
---------
-- "-" --
---------
function "-" (X : Engine_Value) return Engine_Value is
begin
if not Is_Numeric (X) then
raise Constraint_Error with "Non-numeric value";
end if;
case Numeric_Classes (X.Class) is
when Int =>
return Create (-Get_Integer (X));
when Real =>
return Create (-Get_Float (X));
end case;
end "-";
-----------
-- "not" --
-----------
function "not" (X : Engine_Value) return Integer_Value is
begin
if not Is_Numeric (X) then
raise Constraint_Error with "Non-numeric value";
end if;
return Create (1 - Bool (X));
end "not";
---------
-- "+" --
---------
function "+" (Left, Right : Engine_Value) return Engine_Value is
begin
if not (Is_Scalar (Left) and Is_Scalar (Right)) then
raise Constraint_Error;
end if;
if Is_Numeric (Left) xor Is_Numeric (Right) then
raise Constraint_Error;
end if;
if Left.Class = Text and Right.Class = Text then
return Create (Get_String (Left) & Get_String (Right));
elsif Left.Class = Int and Right.Class = Int then
return Create (Get_Integer (Left) + Get_Integer (Right));
else
return Create (Real (Left) + Real (Right));
end if;
end "+";
---------
-- "*" --
---------
function "*" (Left, Right : Engine_Value) return Engine_Value is
begin
if not (Is_Numeric (Left) and Is_Numeric (Right)) then
raise Constraint_Error;
end if;
if Left.Class = Int and Right.Class = Int then
return Create (Get_Integer (Left) * Get_Integer (Right));
else
return Create (Real (Left) * Real (Right));
end if;
end "*";
---------
-- "/" --
---------
function "/" (Left, Right : Engine_Value) return Engine_Value is
begin
if not (Is_Numeric (Left) and Is_Numeric (Right)) then
raise Constraint_Error;
end if;
if Left.Class = Int and Right.Class = Int then
return Create (Get_Integer (Left) / Get_Integer (Right));
else
return Create (Real (Left) / Real (Right));
end if;
end "/";
---------
-- "=" --
---------
function "=" (Left, Right : Engine_Value) return Integer_Value is
begin
if not (Is_Scalar (Left) and Is_Scalar (Right)) then
raise Constraint_Error;
end if;
if Is_Numeric (Left) xor Is_Numeric (Right) then
raise Constraint_Error;
end if;
if Left.Class = Text and Right.Class = Text then
return Create (Get_String (Left) = Get_String (Right));
elsif Left.Class = Int and Right.Class = Int then
return Create (Get_Integer (Left) = Get_Integer (Right));
else
return Create (Real (Left) = Real (Right));
end if;
end "=";
---------
-- "<" --
---------
function "<" (Left, Right : Engine_Value) return Integer_Value is
begin
if not (Is_Scalar (Left) and Is_Scalar (Right)) then
raise Constraint_Error;
end if;
if Is_Numeric (Left) xor Is_Numeric (Right) then
raise Constraint_Error;
end if;
if Left.Class = Text and Right.Class = Text then
return Create (Get_String (Left) < Get_String (Right));
elsif Left.Class = Int and Right.Class = Int then
return Create (Get_Integer (Left) < Get_Integer (Right));
else
return Create (Real (Left) < Real (Right));
end if;
end "<";
-----------
-- "and" --
-----------
function "and" (Left, Right : Integer_Value) return Integer_Value is
begin
return Create (Bool (Left) * Bool (Right));
end "and";
----------
-- "or" --
----------
function "or" (Left, Right : Integer_Value) return Integer_Value is
begin
return Create (Bool (Left) + Bool (Right));
end "or";
-----------
-- "xor" --
-----------
function "xor" (Left, Right : Integer_Value) return Integer_Value is
begin
return Create ((Bool (Left) + Bool (Right)) mod 2);
end "xor";
end Protypo.API.Engine_Values;
|
with Ada.Text_IO; use Ada.Text_IO;
-- for access to Halt
with Support;
-- for parsing of the command line arguments
with Support.RegEx; use Support.RegEx;
with Support.CmdLine; use Support.CmdLine;
-- for setup of initial data
with BSSNBase; use BSSNBase;
with BSSNBase.Initial;
-- for data io
with BSSNBase.Data_IO;
with Metric.Kasner; use Metric.Kasner;
procedure BSSNInitial is
procedure initialize is
re_intg : String := "([-+]?[0-9]+)";
re_real : String := "([-+]?[0-9]*[.]?[0-9]+([eE][-+]?[0-9]+)?)"; -- note counts as 2 groups (1.234(e+56))
re_intg_seq : String := re_intg&"x"&re_intg&"x"&re_intg;
re_real_seq : String := re_real&":"&re_real&":"&re_real;
begin
if find_command_arg('h') then
Put_Line (" Usage: bssninitial [-nPxQxR] [-dDx:Dy:Dz] [-pp1:p2:p3] [-Ddata] [-tTime] [-h]");
Put_Line (" -nPxQxR : Create a grid with P by Q by NR grid points, default: P=Q=R=20");
Put_Line (" -dDx:Dy:Dz : Grid spacings are Dx, Dy and Dz, default: Dx=Dy=Dz=0.1");
Put_Line (" -pp1:p2:p3 : p1, p2, and p3 are the Kasner parameters, default: p1=p2=2/3, p3=-1/3");
Put_line (" -Ddata : Where to save the data, default: data/");
Put_Line (" -tTime : Set the initial time, default: T=1");
Put_Line (" -h : This message.");
Support.Halt (0);
else
beg_time := read_command_arg ('t',1.0);
dx := grep (read_command_arg ('d',"0.1:0.1:0.1"),re_real_seq,1,fail=>0.1);
dy := grep (read_command_arg ('d',"0.1:0.1:0.1"),re_real_seq,3,fail=>0.1);
dz := grep (read_command_arg ('d',"0.1:0.1:0.1"),re_real_seq,5,fail=>0.1);
num_x := grep (read_command_arg ('n',"20x20x20"),re_intg_seq,1,fail=>20);
num_y := grep (read_command_arg ('n',"20x20x20"),re_intg_seq,2,fail=>20);
num_z := grep (read_command_arg ('n',"20x20x20"),re_intg_seq,3,fail=>20);
the_time := beg_time;
grid_point_num := num_x * num_y * num_z;
end if;
end initialize;
begin
initialize;
echo_command_line;
report_kasner_params;
BSSNBase.Initial.create_grid;
BSSNBase.Initial.create_data;
-- two ways to save the data
-- these use binary format for the data, not for human consumption
-- BSSNBase.Data_IO.write_grid;
-- BSSNBase.Data_IO.write_data;
--
-- BSSNBase.Data_IO.read_grid;
-- BSSNBase.Data_IO.read_data;
-- these use plain text format for the data, safe for humans
BSSNBase.Data_IO.write_grid_fmt;
BSSNBase.Data_IO.write_data_fmt;
BSSNBase.Data_IO.read_grid_fmt;
BSSNBase.Data_IO.read_data_fmt;
end BSSNInitial;
|
-----------------------------------------------------------------------------
-- This file contains the body, please refer to specification (.ads file)
-----------------------------------------------------------------------------
with Interfaces;
with GLUT.Windows; use GLUT.Windows;
with Ada.Characters.Handling; use Ada.Characters.Handling;
with System;
with Ada.Unchecked_Conversion;
package body GLUT.Devices is
-- current_Window : - for accessing the current GLUT window
-- - used by GLUT callbacks to determine the Window to which a callback event relates.
--
function current_Window return Windows.Window_view is
function to_Window is new Ada.Unchecked_Conversion (System.Address, Windows.Window_view);
begin
return to_Window (GLUT.GetWindowData);
end current_Window;
-- Keyboard
--
function current_Keyboard return p_Keyboard is
the_current_Window : constant Windows.Window_view := current_Window;
begin
case the_current_Window = null is
when True => return default_Keyboard'Access;
when False => return GLUT.Windows.Keyboard (the_current_Window);
end case;
end current_Keyboard;
procedure Affect_modif_key (modif_code : Integer) is
use Interfaces;
m : constant Unsigned_32 := Unsigned_32 (modif_code);
begin
current_Keyboard.all.modif_set (GLUT.Active_Shift) := (m and GLUT.Active_Shift) /= 0;
current_Keyboard.all.modif_set (GLUT.Active_Control) := (m and GLUT.Active_Control) /= 0;
current_Keyboard.all.modif_set (GLUT.Active_Alt) := (m and GLUT.Active_Alt) /= 0;
end Affect_modif_key;
procedure Update_modifier_keys is
begin
Affect_modif_key (GLUT.GetModifiers);
-- During a callback, GetModifiers may be called
-- to determine the state of modifier keys
-- when the keystroke generating the callback occurred.
end Update_modifier_keys;
-- GLUT Callback procedures --
procedure Key_Pressed (k : GLUT.Key_type; x, y : Integer) is
begin
pragma Unreferenced (x, y);
current_Keyboard.all.normal_set (To_Upper (Character'Val (k))) := True; -- key k is pressed
Update_modifier_keys;
end Key_Pressed;
procedure Key_Unpressed (k : GLUT.Key_type; x, y : Integer) is
begin
pragma Unreferenced (x, y);
current_Keyboard.all.normal_set (To_Upper (Character'Val (k))) := False; -- key k is unpressed
Update_modifier_keys;
end Key_Unpressed;
procedure Special_Key_Pressed (k : Integer; x, y : Integer) is
begin
pragma Unreferenced (x, y);
current_Keyboard.all.special_set (k) := True; -- key k is pressed
Update_modifier_keys;
end Special_Key_Pressed;
procedure Special_Key_Unpressed (k : Integer; x, y : Integer) is
begin
pragma Unreferenced (x, y);
current_Keyboard.all.special_set (k) := False; -- key k is unpressed
Update_modifier_keys;
end Special_Key_Unpressed;
-- Mouse
--
function current_Mouse return p_Mouse is
the_current_Window : constant Windows.Window_view := current_Window;
begin
case the_current_Window = null is
when True => return default_Mouse'Access;
when False => return GLUT.Windows.Mouse (the_current_Window);
end case;
end current_Mouse;
procedure Mouse_Event (button, state, x, y : Integer) is
-- When a user presses and releases mouse buttons in the window,
-- each press and each release generates a mouse callback.
begin
current_Mouse.all.mx := x;
current_Mouse.all.my := y;
if button in current_Mouse.all.button_state'Range then -- skip extra buttons (wheel, etc.)
current_Mouse.all.button_state (button) := state = GLUT.DOWN; -- Joli, non ?
end if;
Update_modifier_keys;
end Mouse_Event;
procedure Motion (x, y : Integer) is
-- The motion callback for a window is called when the mouse moves within the
-- window while one or more mouse buttons are pressed.
begin
current_Mouse.all.mx := x;
current_Mouse.all.my := y;
end Motion;
procedure Passive_Motion (x, y : Integer) is
-- The passive motion callback for a window is called when
-- the mouse moves within the window while no mouse buttons are pressed.
begin
current_Mouse.all.mx := x;
current_Mouse.all.my := y;
end Passive_Motion;
-- Initialize
--
procedure Initialize is
use GLUT;
begin
IgnoreKeyRepeat (1);
KeyboardFunc (Key_Pressed'Address);
KeyboardUpFunc (Key_Unpressed'Address);
SpecialFunc (Special_Key_Pressed'Address);
SpecialUpFunc (Special_Key_Unpressed'Address);
MouseFunc (Mouse_Event'Address);
MotionFunc (Motion'Address);
PassiveMotionFunc (Passive_Motion'Address);
end Initialize;
-- User input management
--
function Strike_once (c : Character;
kb : access Keyboard := default_Keyboard'Access) return Boolean is
begin
kb.all.normal_set_mem (c) := kb.all.normal_set (c);
return kb.all.normal_set (c) and then not kb.all.normal_set_mem (c);
end Strike_once;
function Strike_once (special : Integer;
kb : access Keyboard := default_Keyboard'Access) return Boolean is
begin
kb.all.special_set_mem (special) := kb.all.special_set (special);
return special in Special_key_set'Range
and then kb.all.special_set (special) and then not kb.all.special_set_mem (special);
end Strike_once;
end GLUT.Devices;
|
pragma License (Unrestricted);
-- implementation unit
package Ada.Containers.Binary_Trees.Arne_Andersson.Debug is
pragma Preelaborate;
function Root (Node : not null Node_Access) return not null Node_Access;
function Dump (
Container : Node_Access;
Marker : Node_Access;
Message : String := "")
return Boolean;
function Valid (
Container : Node_Access;
Length : Count_Type;
Level_Check : Boolean := True)
return Boolean;
end Ada.Containers.Binary_Trees.Arne_Andersson.Debug;
|
with System.Formatting.Literals;
with System.Long_Long_Integer_Types;
with System.Value_Errors;
package body System.Val_Int is
subtype Word_Integer is Long_Long_Integer_Types.Word_Integer;
-- implementation
function Value_Integer (Str : String) return Integer is
Last : Natural;
Result : Word_Integer;
Error : Boolean;
begin
Formatting.Literals.Get_Literal (Str, Last, Result, Error);
if not Error
and then (
Standard'Word_Size = Integer'Size
or else Result in
Word_Integer (Integer'First) .. Word_Integer (Integer'Last))
then
Formatting.Literals.Check_Last (Str, Last, Error);
if not Error then
return Integer (Result);
end if;
end if;
Value_Errors.Raise_Discrete_Value_Failure ("Integer", Str);
declare
Uninitialized : Integer;
pragma Unmodified (Uninitialized);
begin
return Uninitialized;
end;
end Value_Integer;
end System.Val_Int;
|
-----------------------------------------------------------------------
-- util-commands-parsers -- Support to parse command line options
-- Copyright (C) 2018 Stephane Carrez
-- Written by Stephane Carrez (Stephane.Carrez@gmail.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.
-----------------------------------------------------------------------
-- == Command line parsers ==
-- Parsing command line arguments before their execution is handled by the
-- `Config_Parser` generic package. This allows to customize how the arguments are
-- parsed.
--
-- The `Util.Commands.Parsers.No_Parser` package can be used to execute the command
-- without parsing its arguments.
--
-- The `Util.Commands.Parsers.GNAT_Parser.Config_Parser` package provides support to
-- parse command line arguments by using the `GNAT` `Getopt` support.
package Util.Commands.Parsers is
-- The config parser that must be instantiated to provide the configuration type
-- and the Execute procedure that will parse the arguments before executing the command.
generic
type Config_Type is limited private;
with procedure Execute (Config : in out Config_Type;
Args : in Argument_List'Class;
Process : not null access
procedure (Cmd_Args : in Argument_List'Class)) is <>;
with procedure Usage (Name : in String;
Config : in out Config_Type) is <>;
package Config_Parser is
end Config_Parser;
-- The empty parser.
type No_Config_Type is limited null record;
-- Execute the command with its arguments (no parsing).
procedure Execute (Config : in out No_Config_Type;
Args : in Argument_List'Class;
Process : not null access
procedure (Cmd_Args : in Argument_List'Class));
procedure Usage (Name : in String;
Config : in out No_Config_Type) is null;
-- A parser that executes the command immediately (no parsing of arguments).
package No_Parser is
new Config_Parser (Config_Type => No_Config_Type,
Execute => Execute,
Usage => Usage);
end Util.Commands.Parsers;
|
with Prime_Numbers, Ada.Text_IO;
procedure Test_Kth_Prime is
package Integer_Numbers is new
Prime_Numbers (Natural, 0, 1, 2);
use Integer_Numbers;
Out_Length: constant Positive := 10; -- 10 k-th almost primes
N: Positive; -- the "current number" to be checked
begin
for K in 1 .. 5 loop
Ada.Text_IO.Put("K =" & Integer'Image(K) &": ");
N := 2;
for I in 1 .. Out_Length loop
while Decompose(N)'Length /= K loop
N := N + 1;
end loop; -- now N is Kth almost prime;
Ada.Text_IO.Put(Integer'Image(Integer(N)));
N := N + 1;
end loop;
Ada.Text_IO.New_Line;
end loop;
end Test_Kth_Prime;
|
------------------------------------------------------------------------------
-- --
-- GNAT COMPILER COMPONENTS --
-- --
-- S I N F O . C N --
-- --
-- S p e c --
-- --
-- Copyright (C) 1992-2011, Free Software Foundation, Inc. --
-- --
-- GNAT is free software; you can redistribute it and/or modify it under --
-- terms of the GNU General Public License as published by the Free Soft- --
-- ware Foundation; either version 3, or (at your option) any later ver- --
-- sion. GNAT is distributed in the hope that it will be useful, but WITH- --
-- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY --
-- or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License --
-- for more details. You should have received a copy of the GNU General --
-- Public License distributed with GNAT; see file COPYING3. If not, go to --
-- http://www.gnu.org/licenses for a complete copy of the license. --
-- --
-- GNAT was originally developed by the GNAT team at New York University. --
-- Extensive contributions were provided by Ada Core Technologies Inc. --
-- --
------------------------------------------------------------------------------
-- This child package of Sinfo contains some routines that permit in place
-- alteration of existing tree nodes by changing the value in the Nkind
-- field. Since Nkind functions logically in a manner similar to a variant
-- record discriminant part, such alterations cannot be permitted in a
-- general manner, but in some specific cases, the fields of related nodes
-- have been deliberately laid out in a manner that permits such alteration.
package Sinfo.CN is
procedure Change_Identifier_To_Defining_Identifier (N : in out Node_Id);
-- N must refer to a node of type N_Identifier. This node is modified to
-- be of type N_Defining_Identifier. The scanner always returns identifiers
-- as N_Identifier. The parser then uses this routine to change the node
-- to be a defining identifier where the context demands it. This routine
-- also allocates the necessary extension node. Note that this procedure
-- may (but is not required to) change the Id of the node in question.
procedure Change_Character_Literal_To_Defining_Character_Literal
(N : in out Node_Id);
-- Similar processing for a character literal
procedure Change_Operator_Symbol_To_Defining_Operator_Symbol
(N : in out Node_Id);
-- Similar processing for an operator symbol
procedure Change_Conversion_To_Unchecked (N : Node_Id);
-- Change checked conversion node to unchecked conversion node, clearing
-- irrelevant check flags (other fields in the two nodes are identical)
procedure Change_Operator_Symbol_To_String_Literal (N : Node_Id);
-- The scanner returns any string that looks like an operator symbol as
-- a N_Operator_Symbol node. The parser then uses this procedure to change
-- the node to a normal N_String_Literal node if the context is not one
-- in which an operator symbol is required. There are some cases where the
-- parser cannot tell, in which case this transformation happens later on.
procedure Change_Selected_Component_To_Expanded_Name (N : Node_Id);
-- The parser always generates Selected_Component nodes. The semantics
-- modifies these to Expanded_Name nodes where appropriate. Note that
-- on return the Chars field is set to a copy of the contents of the
-- Chars field of the Selector_Name field.
procedure Change_Name_To_Procedure_Call_Statement (N : Node_Id);
-- Some statements (procedure call statements) are in the form of a name
-- and are parsed as such. This routine takes the scanned name as input
-- and returns the corresponding N_Procedure_Call_Statement.
end Sinfo.CN;
|
package randfloat is --Generates a uniformly distributed random real
function next_float(x: in out integer) return float; -- between 0.0 <= next <= 1.0.
end randfloat; |
-----------------------------------------------------------------------
-- util-systems-os -- Unix system operations
-- Copyright (C) 2011, 2012, 2014, 2015, 2016, 2017, 2018, 2019, 2021 Stephane Carrez
-- Written by Stephane Carrez (Stephane.Carrez@gmail.com)
--
-- Licensed under the Apache License, Version 2.0 (the "License");
-- you may not use this file except in compliance with the License.
-- You may obtain a copy of the License at
--
-- http://www.apache.org/licenses/LICENSE-2.0
--
-- Unless required by applicable law or agreed to in writing, software
-- distributed under the License is distributed on an "AS IS" BASIS,
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-- See the License for the specific language governing permissions and
-- limitations under the License.
-----------------------------------------------------------------------
with System;
with Interfaces.C;
with Interfaces.C.Strings;
with Util.Processes;
with Util.Systems.Constants;
with Util.Systems.Types;
-- The <b>Util.Systems.Os</b> package defines various types and operations which are specific
-- to the OS (Unix).
package Util.Systems.Os is
-- The directory separator.
Directory_Separator : constant Character := '/';
-- The path separator.
Path_Separator : constant Character := ':';
-- The line ending separator.
Line_Separator : constant String := "" & ASCII.LF;
use Util.Systems.Constants;
subtype Ptr is Interfaces.C.Strings.chars_ptr;
subtype Ptr_Array is Interfaces.C.Strings.chars_ptr_array;
type Ptr_Ptr_Array is access all Ptr_Array;
subtype File_Type is Util.Systems.Types.File_Type;
-- Standard file streams Posix, X/Open standard values.
STDIN_FILENO : constant File_Type := 0;
STDOUT_FILENO : constant File_Type := 1;
STDERR_FILENO : constant File_Type := 2;
-- File is not opened
use type Util.Systems.Types.File_Type; -- This use clause is required by GNAT 2018 for the -1!
NO_FILE : constant File_Type := -1;
-- The following values should be externalized. They are valid for GNU/Linux.
F_SETFL : constant Interfaces.C.int := Util.Systems.Constants.F_SETFL;
FD_CLOEXEC : constant Interfaces.C.int := Util.Systems.Constants.FD_CLOEXEC;
-- These values are specific to Linux.
O_RDONLY : constant Interfaces.C.int := Util.Systems.Constants.O_RDONLY;
O_WRONLY : constant Interfaces.C.int := Util.Systems.Constants.O_WRONLY;
O_RDWR : constant Interfaces.C.int := Util.Systems.Constants.O_RDWR;
O_CREAT : constant Interfaces.C.int := Util.Systems.Constants.O_CREAT;
O_EXCL : constant Interfaces.C.int := Util.Systems.Constants.O_EXCL;
O_TRUNC : constant Interfaces.C.int := Util.Systems.Constants.O_TRUNC;
O_APPEND : constant Interfaces.C.int := Util.Systems.Constants.O_APPEND;
type Size_T is mod 2 ** Standard'Address_Size;
type Ssize_T is range -(2 ** (Standard'Address_Size - 1))
.. +(2 ** (Standard'Address_Size - 1)) - 1;
function Close (Fd : in File_Type) return Integer
with Import => True, Convention => C, Link_Name => SYMBOL_PREFIX & "close";
function Read (Fd : in File_Type;
Buf : in System.Address;
Size : in Size_T) return Ssize_T
with Import => True, Convention => C, Link_Name => SYMBOL_PREFIX & "read";
function Write (Fd : in File_Type;
Buf : in System.Address;
Size : in Size_T) return Ssize_T
with Import => True, Convention => C, Link_Name => SYMBOL_PREFIX & "write";
-- System exit without any process cleaning.
-- (destructors, finalizers, atexit are not called)
procedure Sys_Exit (Code : in Integer)
with Import => True, Convention => C, Link_Name => SYMBOL_PREFIX & "exit";
-- Fork a new process
function Sys_Fork return Util.Processes.Process_Identifier
with Import => True, Convention => C, Link_Name => SYMBOL_PREFIX & "fork";
-- Fork a new process (vfork implementation)
function Sys_VFork return Util.Processes.Process_Identifier
with Import => True, Convention => C, Link_Name => SYMBOL_PREFIX & "fork";
-- Execute a process with the given arguments.
function Sys_Execvp (File : in Ptr;
Args : in Ptr_Array) return Integer
with Import => True, Convention => C, Link_Name => SYMBOL_PREFIX & "execvp";
-- Execute a process with the given arguments.
function Sys_Execve (File : in Ptr;
Args : in Ptr_Array;
Envp : in Ptr_Array) return Integer
with Import => True, Convention => C, Link_Name => SYMBOL_PREFIX & "execve";
-- Wait for the process <b>Pid</b> to finish and return
function Sys_Waitpid (Pid : in Integer;
Status : in System.Address;
Options : in Integer) return Integer
with Import => True, Convention => C, Link_Name => SYMBOL_PREFIX & "waitpid";
-- Create a bi-directional pipe
function Sys_Pipe (Fds : in System.Address) return Integer
with Import => True, Convention => C, Link_Name => SYMBOL_PREFIX & "pipe";
-- Make <b>fd2</b> the copy of <b>fd1</b>
function Sys_Dup2 (Fd1, Fd2 : in File_Type) return Integer
with Import => True, Convention => C, Link_Name => SYMBOL_PREFIX & "dup2";
-- Close a file
function Sys_Close (Fd : in File_Type) return Integer
with Import => True, Convention => C, Link_Name => SYMBOL_PREFIX & "close";
-- Open a file
function Sys_Open (Path : in Ptr;
Flags : in Interfaces.C.int;
Mode : in Util.Systems.Types.mode_t) return File_Type
with Import => True, Convention => C, Link_Name => SYMBOL_PREFIX & "open";
-- Change the file settings
function Sys_Fcntl (Fd : in File_Type;
Cmd : in Interfaces.C.int;
Flags : in Interfaces.C.int) return Integer
with Import => True, Convention => C, Link_Name => SYMBOL_PREFIX & "fcntl";
function Sys_Kill (Pid : in Integer;
Signal : in Integer) return Integer
with Import => True, Convention => C, Link_Name => SYMBOL_PREFIX & "kill";
function Sys_Stat (Path : in Ptr;
Stat : access Util.Systems.Types.Stat_Type) return Integer
with Import => True, Convention => C, Link_Name => Util.Systems.Types.STAT_NAME;
function Sys_Fstat (Fs : in File_Type;
Stat : access Util.Systems.Types.Stat_Type) return Integer
with Import => True, Convention => C, Link_Name => Util.Systems.Types.FSTAT_NAME;
function Sys_Lseek (Fs : in File_Type;
Offset : in Util.Systems.Types.off_t;
Mode : in Util.Systems.Types.Seek_Mode)
return Util.Systems.Types.off_t
with Import => True, Convention => C, Link_Name => SYMBOL_PREFIX & "lseek";
function Sys_Ftruncate (Fs : in File_Type;
Length : in Util.Systems.Types.off_t) return Integer
with Import => True, Convention => C, Link_Name => SYMBOL_PREFIX & "ftruncate";
function Sys_Truncate (Path : in Ptr;
Length : in Util.Systems.Types.off_t) return Integer
with Import => True, Convention => C, Link_Name => SYMBOL_PREFIX & "truncate";
function Sys_Fchmod (Fd : in File_Type;
Mode : in Util.Systems.Types.mode_t) return Integer
with Import => True, Convention => C, Link_Name => SYMBOL_PREFIX & "fchmod";
-- Change permission of a file.
function Sys_Chmod (Path : in Ptr;
Mode : in Util.Systems.Types.mode_t) return Integer
with Import => True, Convention => C, Link_Name => SYMBOL_PREFIX & "chmod";
-- Change working directory.
function Sys_Chdir (Path : in Ptr) return Integer
with Import => True, Convention => C, Link_Name => SYMBOL_PREFIX & "chdir";
-- Rename a file (the Ada.Directories.Rename does not allow to use
-- the Unix atomic file rename!)
function Sys_Rename (Oldpath : in Ptr;
Newpath : in Ptr) return Integer
with Import => True, Convention => C, Link_Name => SYMBOL_PREFIX & "rename";
-- Libc errno. The __get_errno function is provided by the GNAT runtime.
function Errno return Integer
with Import => True, Convention => C, Link_Name => SYMBOL_PREFIX & "__get_errno";
function Strerror (Errno : in Integer) return Interfaces.C.Strings.chars_ptr
with Import => True, Convention => C, Link_Name => SYMBOL_PREFIX & "strerror";
end Util.Systems.Os;
|
--------------------------------------------------------------------------
-- package body Jacobi_Eigen, Jacobi iterative eigen-decomposition
-- Copyright (C) 2008-2018 Jonathan S. Parker
--
-- Permission to use, copy, modify, and/or distribute this software for any
-- purpose with or without fee is hereby granted, provided that the above
-- copyright notice and this permission notice appear in all copies.
-- THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
-- WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
-- MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
-- ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
-- WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
-- ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
-- OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
---------------------------------------------------------------------------
with Hypot;
package body Jacobi_Eigen is
Zero : constant Real := +0.0;
One : constant Real := +1.0;
Two : constant Real := +2.0;
Half : constant Real := +0.5;
package Hyp is new Hypot (Real); use Hyp;
Min_Exp : constant Integer := Real'Machine_Emin;
Min_Allowed_Real : constant Real := Two ** (Min_Exp - Min_Exp/4);
---------------------------------
-- Get_Jacobi_Rotation_Factors --
---------------------------------
-- underflows OK here. No overflows are OK.
procedure Get_Jacobi_Rotation_Factors
(P, Q : in Real;
s : out Real;
tau : out Real;
Del_D : out Real)
is
t, Alpha, A, B, Denom : Real; -- t is Q / P
begin
s := Zero;
tau := Zero;
Del_D := Zero;
if Abs (P) < Min_Allowed_Real then
return; -- use default vals of s, tau, del_d
end if;
if Abs (Q) > Abs (P) then
-- Abs (P) > 0 (tested before arrival also), which implies Abs (Q) > 0.
t := P / Q;
Alpha := Half * t * (t / (One + Hypotenuse (One, t)));
A := Half * t;
B := One + Alpha;
else -- if Abs (P) >= Abs (Q) then
t := Q / P;
Alpha := Abs (t) + t * (t / (One + Hypotenuse (One, t)));
A := One;
B := One + Alpha;
if t < Zero then A := -A; end if;
end if;
--s := A / Sqrt(B*B + A*A); -- Sine
--c := B / Sqrt(B*B + A*A); -- Cosine
Denom := Hypotenuse (A, B);
s := A / Denom;
tau := A / (B + Denom); -- -(cos - 1) / sin
Del_D := (P * A) / B;
end Get_Jacobi_Rotation_Factors;
---------------------
-- Eigen_Decompose --
---------------------
procedure Eigen_Decompose
(A : in out Matrix;
Q_tr : out Matrix;
Eigenvals : out Col_Vector;
No_of_Sweeps_Performed : out Natural;
Total_No_of_Rotations : out Natural;
Start_Col : in Index := Index'First;
Final_Col : in Index := Index'Last;
Eigenvectors_Desired : in Boolean := True)
is
D : Col_Vector renames Eigenvals;
Z, B : Col_Vector;
Max_Allowed_No_of_Sweeps : constant Positive := 256; -- badly scaled A needs lots
No_of_Preliminary_Sweeps : constant Positive := 14; -- use 14; don't change.
subtype Sweep_Range is Positive range 1 .. Max_Allowed_No_of_Sweeps;
Reciprocal_Epsilon : constant Real := One / (Real'Epsilon * Two**(-3));
-- Bst stnd setting for accuracy seems to be about: Real'Epsilon * Two**(-3).
-- Matrices with clustered eigvals seem to need the more accurate setting (3).
-- Usually, Real'Epsilon := 2.0**(-50) for 15 digit Reals.
Matrix_Size : constant Real := Real (Final_Col) - Real (Start_Col) + One;
No_of_Off_Diag_Elements : constant Real := Half*Matrix_Size*(Matrix_Size-One);
Exp : Integer;
Factor : Real;
s, g, h, tau : Real; -- Rutishauser variable names.
Q, Del_D : Real;
Sum, Mean_Off_Diagonal_Element_Size, Threshold : Real;
Pivot : Real;
begin
-- Initialize all out parameters. D renames Eigenvals.
-- Q_tr starts as Identity; is rotated into set of Eigenvectors of A.
if Eigenvectors_Desired then
Q_tr := (others => (others => Zero));
for j in Index loop
Q_tr(j, j) := One;
end loop;
end if;
-- Don't fill (potentially) giant array with 0's unless it's needed.
-- If Eigenvectors_Desired=False, we can free up much memory if
-- this is never touched.
Z := (others => Zero);
B := (others => Zero);
D := (others => Zero);
for j in Start_Col .. Final_Col loop -- assume A not all init
D(j) := A(j, j);
B(j) := A(j, j);
end loop;
No_of_Sweeps_Performed := 0;
Total_No_of_Rotations := 0;
if Matrix_Size <= One then return; end if; -- right answer for Size=1.
Sweep_Upper_Triangle:
for Sweep_id in Sweep_Range loop
No_of_Sweeps_Performed := Sweep_id - Sweep_Range'First;
Sum := Zero;
for Row in Start_Col .. Final_Col-1 loop --sum off-diagonal elements
for Col in Row+1 .. Final_Col loop
Sum := Sum + Abs (A(Row, Col));
end loop;
end loop;
Mean_Off_Diagonal_Element_Size := Sum / No_of_Off_Diag_Elements;
exit Sweep_Upper_Triangle when Mean_Off_Diagonal_Element_Size < Min_Allowed_Real;
-- Program does Threshold pivoting.
--
-- If a Pivot (an off-diagonal matrix element) satisfies
-- Abs (Pivot) > Threshold, then do a Jacobi rotation to zero it out.
--
-- Next calculate size of Threshold:
if Sweep_id > No_of_Preliminary_Sweeps then
Threshold := Zero;
elsif Standard_Threshold_Policy then
Threshold := One * Mean_Off_Diagonal_Element_Size;
-- On average, fewer overall rotations done here, at slight
-- expense of accuracy.
else
Exp := 11 - Sweep_id;
Factor := One + (+1.666)**Exp;
Threshold := Factor * Mean_Off_Diagonal_Element_Size;
-- The big Threshold here helps with badly scaled matrices.
-- May improve accuracy a bit if scaling is bad. Policy
-- here is closer to that of the original Jacobi, which
-- always rotates away the largest Pivots 1st.
end if;
Pivots_Row_id: for Pivot_Row in Start_Col .. Final_Col-1 loop
sum := 0.0;
Pivots_Col_id: for Pivot_Col in Pivot_Row+1 .. Final_Col loop
Pivot := A(Pivot_Row, Pivot_Col);
-- Have to zero-out sufficiently small A(Pivot_Col, Pivot_Row) to get convergence,
-- ie, to get Mean_Off_Diagonal_Element_Size -> 0.0. The test is:
--
-- A(Pivot_Col, Pivot_Row) / Epsilon <= Abs D(Pivot_Col) and
-- A(Pivot_Col, Pivot_Row) / Epsilon <= Abs D(Pivot_Row).
if (Sweep_id > No_of_Preliminary_Sweeps) and then
(Abs (Pivot) * Reciprocal_Epsilon <= Abs D(Pivot_Row)) and then
(Abs (Pivot) * Reciprocal_Epsilon <= Abs D(Pivot_Col)) then
A(Pivot_Row, Pivot_Col) := Zero;
elsif Abs (Pivot) > Threshold then
Q := Half * (D(Pivot_Col) - D(Pivot_Row));
Get_Jacobi_Rotation_Factors (Pivot, Q, s, tau, Del_D);
D(Pivot_Row) := D(Pivot_Row) - Del_D; -- Locally D is only used for threshold test.
D(Pivot_Col) := D(Pivot_Col) + Del_D;
Z(Pivot_Row) := Z(Pivot_Row) - Del_D; -- Z is reinitialized to 0 each sweep, so
Z(Pivot_Col) := Z(Pivot_Col) + Del_D; -- it sums the small d's 1st. Helps a tad.
A(Pivot_Row, Pivot_Col) := Zero;
if Pivot_Row > Start_Col then
for j in Start_Col .. Pivot_Row-1 loop
g := A(j, Pivot_Row);
h := A(j, Pivot_Col);
A(j, Pivot_Row) := g-s*(h+g*tau);
A(j, Pivot_Col) := h+s*(g-h*tau);
end loop;
end if;
for j in Pivot_Row+1 .. Pivot_Col-1 loop
g := A(Pivot_Row, j);
h := A(j, Pivot_Col);
A(Pivot_Row, j) := g-s*(h+g*tau);
A(j, Pivot_Col) := h+s*(g-h*tau);
end loop;
if Pivot_Col < Final_Col then
for j in Pivot_Col+1 .. Final_Col loop
g := A(Pivot_Row, j);
h := A(Pivot_Col, j);
A(Pivot_Row, j) := g-s*(h+g*tau);
A(Pivot_Col, j) := h+s*(g-h*tau);
end loop;
end if;
if Eigenvectors_Desired then
for j in Start_Col .. Final_Col loop
g := Q_tr(Pivot_Row, j);
h := Q_tr(Pivot_Col, j);
Q_tr(Pivot_Row, j) := g-s*(h+g*tau);
Q_tr(Pivot_Col, j) := h+s*(g-h*tau);
end loop;
end if;
Total_No_of_Rotations := Total_No_of_Rotations + 1;
end if; -- if (Sweep_id > No_of_Preliminary_Sweeps)
end loop Pivots_Col_id;
end loop Pivots_Row_id;
for j in Start_Col .. Final_Col loop -- assume A not all initialized
B(j) := B(j) + Z(j);
D(j) := B(j);
Z(j) := Zero;
end loop;
end loop Sweep_Upper_Triangle;
end Eigen_Decompose;
---------------
-- Sort_Eigs --
---------------
procedure Sort_Eigs
(Eigenvals : in out Col_Vector;
Q_tr : in out Matrix; -- rows are the eigvectors
Start_Col : in Index := Index'First;
Final_Col : in Index := Index'Last;
Sort_Eigvecs_Also : in Boolean := True)
is
Max_Eig, tmp : Real;
Max_id : Index;
begin
if Start_Col < Final_Col then
for i in Start_Col .. Final_Col-1 loop
Max_Eig := Eigenvals(i); Max_id := i;
for j in i+1 .. Final_Col loop
if Eigenvals(j) > Max_Eig then
Max_Eig := Eigenvals(j); Max_id := j;
end if;
end loop;
tmp := Eigenvals(i);
Eigenvals(i) := Max_Eig;
Eigenvals(Max_id) := tmp;
-- swap rows of Q_tr:
if Sort_Eigvecs_Also then
for k in Start_Col .. Final_Col loop
tmp := Q_tr(i, k);
Q_tr(i, k) := Q_tr(Max_id, k);
Q_tr(Max_id, k) := tmp;
end loop;
end if;
end loop;
end if;
end Sort_Eigs;
end Jacobi_Eigen;
|
-- C83051A.ADA
-- Grant of Unlimited Rights
--
-- Under contracts F33600-87-D-0337, F33600-84-D-0280, MDA903-79-C-0687,
-- F08630-91-C-0015, and DCA100-97-D-0025, the U.S. Government obtained
-- unlimited rights in the software and documentation contained herein.
-- Unlimited rights are defined in DFAR 252.227-7013(a)(19). By making
-- this public release, the Government intends to confer upon all
-- recipients unlimited rights equal to those held by the Government.
-- These rights include rights to use, duplicate, release or disclose the
-- released technical data and computer software in whole or in part, in
-- any manner and for any purpose whatsoever, and to have or permit others
-- to do so.
--
-- DISCLAIMER
--
-- ALL MATERIALS OR INFORMATION HEREIN RELEASED, MADE AVAILABLE OR
-- DISCLOSED ARE AS IS. THE GOVERNMENT MAKES NO EXPRESS OR IMPLIED
-- WARRANTY AS TO ANY MATTER WHATSOEVER, INCLUDING THE CONDITIONS OF THE
-- SOFTWARE, DOCUMENTATION OR OTHER INFORMATION RELEASED, MADE AVAILABLE
-- OR DISCLOSED, OR THE OWNERSHIP, MERCHANTABILITY, OR FITNESS FOR A
-- PARTICULAR PURPOSE OF SAID MATERIAL.
--*
-- OBJECTIVE:
-- CHECK THAT DECLARATIONS IN THE VISIBLE PART OF A PACKAGE NESTED
-- WITHIN THE VISIBLE PART OF A PACKAGE ARE VISIBLE BY SELECTION
-- FROM OUTSIDE THE OUTERMOST PACKAGE.
-- HISTORY:
-- GMT 09/07/88 CREATED ORIGINAL TEST.
WITH REPORT; USE REPORT;
PROCEDURE C83051A IS
BEGIN
TEST ("C83051A", "CHECK THAT DECLARATIONS IN THE VISIBLE " &
"PART OF A PACKAGE NESTED WITHIN THE VISIBLE " &
"PART OF A PACKAGE ARE VISIBLE BY SELECTION " &
"FROM OUTSIDE THE OUTERMOST PACKAGE");
A_BLOCK:
DECLARE
PACKAGE APACK IS
PACKAGE BPACK IS
TYPE T1 IS (RED,GREEN);
TYPE T2A IS ('A', 'B', 'C', 'D');
TYPE T3 IS NEW BOOLEAN;
TYPE T4 IS NEW INTEGER RANGE -3 .. 8;
TYPE T5 IS DIGITS 5;
TYPE T67 IS DELTA 0.5 RANGE -2.0 .. 10.0;
TYPE T9A IS ARRAY (INTEGER RANGE <>) OF T3;
SUBTYPE T9B IS T9A (1..10);
TYPE T9C IS ACCESS T9B;
TYPE T10 IS PRIVATE;
V1 : T3 := FALSE;
ZERO : CONSTANT T4 := 0;
A_FLT : T5 := 3.0;
A_FIX : T67 := -1.0;
ARY : T9A(1..4) := (TRUE,TRUE,TRUE,FALSE);
P1 : T9C := NEW T9B'( 1..5 => T3'(TRUE),
6..10 => T3'(FALSE) );
C1 : CONSTANT T10;
FUNCTION RET_T1 (X : T1) RETURN T1;
FUNCTION RET_CHAR (X : CHARACTER) RETURN T10;
GENERIC
PROCEDURE DO_NOTHING (X : IN OUT T3);
PRIVATE
TYPE T10 IS NEW CHARACTER;
C1 : CONSTANT T10 := 'J';
END BPACK;
END APACK;
PACKAGE BODY APACK IS
PACKAGE BODY BPACK IS
FUNCTION RET_T1 (X : T1) RETURN T1 IS
BEGIN
IF X = RED THEN
RETURN GREEN;
ELSE
RETURN RED;
END IF;
END RET_T1;
FUNCTION RET_CHAR (X : CHARACTER) RETURN T10 IS
BEGIN
RETURN T10(X);
END RET_CHAR;
PROCEDURE DO_NOTHING (X : IN OUT T3) IS
BEGIN
IF X = TRUE THEN
X := FALSE;
ELSE
X := TRUE;
END IF;
END DO_NOTHING;
END BPACK;
END APACK;
PROCEDURE NEW_DO_NOTHING IS NEW APACK.BPACK.DO_NOTHING;
BEGIN
-- A1: VISIBILITY FOR UNOVERLOADED ENUMERATION LITERALS
IF APACK.BPACK.">"(APACK.BPACK.RED, APACK.BPACK.GREEN) THEN
FAILED ("VISIBILITY FOR UNOVERLOADED ENUMERATION " &
"LITERAL BAD - A1");
END IF;
-- A2: VISIBILITY FOR OVERLOADED
-- ENUMERATION CHARACTER LITERALS
IF APACK.BPACK."<"(APACK.BPACK.T2A'(APACK.BPACK.'C'),
APACK.BPACK.T2A'(APACK.BPACK.'B')) THEN
FAILED ("VISIBILITY FOR OVERLOADED ENUMERATION " &
"LITERAL BAD - A2");
END IF;
-- A3: VISIBILITY FOR A DERIVED BOOLEAN TYPE
IF APACK.BPACK."<"(APACK.BPACK.T3'(APACK.BPACK.TRUE),
APACK.BPACK.FALSE) THEN
FAILED ("VISIBILITY FOR DERIVED BOOLEAN BAD - A3");
END IF;
-- A4: VISIBILITY FOR AN INTEGER TYPE
IF APACK.BPACK."/="(APACK.BPACK."MOD"(6,2),APACK.BPACK.ZERO)
THEN FAILED ("VISIBILITY FOR INTEGER TYPE BAD - A4");
END IF;
-- A5: VISIBILITY FOR A FLOATING POINT TYPE
IF APACK.BPACK.">"(APACK.BPACK.T5'(2.7),APACK.BPACK.A_FLT)
THEN FAILED ("VISIBILITY FOR FLOATING POINT BAD - A5");
END IF;
-- A6: VISIBILITY FOR A FIXED POINT INVOLVING UNARY MINUS
IF APACK.BPACK."<"(APACK.BPACK.A_FIX,APACK.BPACK.T67'
(APACK.BPACK."-"(1.5))) THEN
FAILED ("VISIBILITY FOR FIXED POINT WITH UNARY MINUS " &
"BAD - A6");
END IF;
-- A7: VISIBILITY FOR A FIXED POINT DIVIDED BY INTEGER
IF APACK.BPACK."/="(APACK.BPACK.T67(-0.5),APACK.BPACK."/"
(APACK.BPACK.A_FIX,2)) THEN
FAILED ("VISIBILITY FOR FIXED POINT DIVIDED BY " &
"INTEGER BAD - A7");
END IF;
-- A8: VISIBILITY FOR ARRAY EQUALITY
IF APACK.BPACK."/="(APACK.BPACK.ARY,(APACK.BPACK.T3(TRUE),
APACK.BPACK.T3(TRUE),APACK.BPACK.T3(TRUE),
APACK.BPACK.T3(FALSE))) THEN
FAILED ("VISIBILITY FOR ARRAY EQUALITY BAD - A8");
END IF;
-- A9: VISIBILITY FOR ACCESS EQUALITY
IF APACK.BPACK."/="(APACK.BPACK.P1(3),
APACK.BPACK.T3(IDENT_BOOL(TRUE)))
THEN FAILED ("VISIBILITY FOR ACCESS EQUALITY BAD - A9");
END IF;
-- A10: VISIBILITY FOR PRIVATE TYPE
IF APACK.BPACK."/="(APACK.BPACK.C1,
APACK.BPACK.RET_CHAR('J')) THEN
FAILED ("VISIBILITY FOR PRIVATE TYPE BAD - A10");
END IF;
-- A11: VISIBILITY FOR DERIVED SUBPROGRAM
IF APACK.BPACK."/="(APACK.BPACK.RET_T1(APACK.BPACK.RED),
APACK.BPACK.GREEN) THEN
FAILED ("VISIBILITY FOR DERIVED SUBPROGRAM BAD - A11");
END IF;
-- A12: VISIBILITY FOR GENERIC SUBPROGRAM
NEW_DO_NOTHING (APACK.BPACK.V1);
IF APACK.BPACK."/="(APACK.BPACK.V1,APACK.BPACK.T3(TRUE)) THEN
FAILED ("VISIBILITY FOR GENERIC SUBPROGRAM BAD - A12");
END IF;
END A_BLOCK;
B_BLOCK:
DECLARE
GENERIC
TYPE T1 IS (<>);
PACKAGE GENPACK IS
PACKAGE APACK IS
PACKAGE BPACK IS
TYPE T1 IS (ORANGE,GREEN);
TYPE T2A IS ('E', 'F', 'G');
TYPE T3 IS NEW BOOLEAN;
TYPE T4 IS NEW INTEGER RANGE -3 .. 8;
TYPE T5 IS DIGITS 5;
TYPE T67 IS DELTA 0.5 RANGE -3.0 .. 25.0;
TYPE T9A IS ARRAY (INTEGER RANGE <>) OF T3;
SUBTYPE T9B IS T9A (2 .. 8);
TYPE T9C IS ACCESS T9B;
TYPE T10 IS PRIVATE;
V1 : T3 := TRUE;
SIX : T4 := 6;
B_FLT : T5 := 4.0;
ARY : T9A(1..4) := (TRUE,FALSE,TRUE,FALSE);
P1 : T9C := NEW T9B'( 2..4 => T3'(FALSE),
5..8 => T3'(TRUE));
K1 : CONSTANT T10;
FUNCTION RET_T1 (X : T1) RETURN T1;
FUNCTION RET_CHAR (X : CHARACTER) RETURN T10;
GENERIC
PROCEDURE DO_NOTHING (X : IN OUT T3);
PRIVATE
TYPE T10 IS NEW CHARACTER;
K1 : CONSTANT T10 := 'V';
END BPACK;
END APACK;
END GENPACK;
PACKAGE BODY GENPACK IS
PACKAGE BODY APACK IS
PACKAGE BODY BPACK IS
FUNCTION RET_T1 (X : T1) RETURN T1 IS
BEGIN
IF X = ORANGE THEN
RETURN GREEN;
ELSE
RETURN ORANGE;
END IF;
END RET_T1;
FUNCTION RET_CHAR (X : CHARACTER) RETURN T10 IS
BEGIN
RETURN T10(X);
END RET_CHAR;
PROCEDURE DO_NOTHING (X : IN OUT T3) IS
BEGIN
IF X = TRUE THEN
X := FALSE;
ELSE
X := TRUE;
END IF;
END DO_NOTHING;
END BPACK;
END APACK;
END GENPACK;
PACKAGE MYPACK IS NEW GENPACK (T1 => INTEGER);
PROCEDURE MY_DO_NOTHING IS NEW MYPACK.APACK.BPACK.DO_NOTHING;
BEGIN
-- B1: GENERIC INSTANCE OF UNOVERLOADED ENUMERATION LITERAL
IF MYPACK.APACK.BPACK."<"(MYPACK.APACK.BPACK.GREEN,
MYPACK.APACK.BPACK.ORANGE) THEN
FAILED ("VISIBILITY FOR GENERIC INSTANCE OF " &
"UNOVERLOADED ENUMERATION LITERAL BAD - B1");
END IF;
-- B2: GENERIC INSTANCE OF OVERLOADED ENUMERATION LITERAL
IF MYPACK.APACK.BPACK.">"(MYPACK.APACK.BPACK.T2A'(MYPACK.
APACK.BPACK.'F'),MYPACK.APACK.BPACK.T2A'(MYPACK.APACK.
BPACK.'G')) THEN
FAILED ("VISIBILITY FOR GENERIC INSTANCE OF " &
"OVERLOADED ENUMERATION LITERAL BAD - B2");
END IF;
-- B3: VISIBILITY FOR GENERIC INSTANCE OF DERIVED BOOLEAN
IF MYPACK.APACK.BPACK."/="(MYPACK.APACK.BPACK."NOT"(MYPACK.
APACK.BPACK.T3'(MYPACK.APACK.BPACK.TRUE)),MYPACK.APACK.
BPACK.FALSE) THEN
FAILED ("VISIBILITY FOR GENERIC INSTANCE OF DERIVED " &
"BOOLEAN BAD - B3");
END IF;
-- B4: VISIBILITY FOR GENERIC INSTANCE OF DERIVED INTEGER
IF MYPACK.APACK.BPACK."/="(MYPACK.APACK.BPACK."MOD"(MYPACK.
APACK.BPACK.SIX,2),0) THEN
FAILED ("VISIBILITY FOR GENERIC INSTANCE OF INTEGER " &
"BAD - B4");
END IF;
-- B5: VISIBILITY FOR GENERIC INSTANCE OF FLOATING POINT
IF MYPACK.APACK.BPACK.">"(MYPACK.APACK.BPACK.T5'(1.9),MYPACK.
APACK.BPACK.B_FLT) THEN
FAILED ("VISIBILITY FOR GENERIC INSTANCE OF FLOATING " &
"POINT BAD - B5");
END IF;
-- B6: VISIBILITY FOR GENERIC INSTANCE OF
-- FIXED POINT UNARY PLUS
IF MYPACK.APACK.BPACK."<"(2.5,MYPACK.APACK.BPACK.T67'(MYPACK.
APACK.BPACK."+"(1.75))) THEN
FAILED ("VISIBILITY FOR GENERIC INSTANCE OF FIXED " &
"POINT UNARY PLUS BAD - B6");
END IF;
-- B7: VISIBILITY FOR GENERIC INSTANCE OF
-- FIXED POINT DIVIDED BY INTEGER
IF MYPACK.APACK.BPACK."/="(MYPACK.APACK.BPACK."/"(2.5,4),
0.625) THEN
FAILED ("VISIBILITY FOR GENERIC INSTANCE OF FIXED " &
"POINT DIVIDED BY INTEGER BAD - B7");
END IF;
-- B8: VISIBILITY FOR GENERIC INSTANCE OF ARRAY EQUALITY
IF MYPACK.APACK.BPACK."/="(MYPACK.APACK.BPACK.ARY,(MYPACK.
APACK.BPACK.T3(TRUE),MYPACK.APACK.BPACK.T3(FALSE),MYPACK.
APACK.BPACK.T3(TRUE),MYPACK.APACK.BPACK.T3(FALSE))) THEN
FAILED ("VISIBILITY FOR GENERIC INSTANCE OF ARRAY " &
"EQUALITY BAD - B8");
END IF;
-- B9: VISIBILITY FOR GENERIC INSTANCE OF ACCESS EQUALITY
IF MYPACK.APACK.BPACK."/="(MYPACK.APACK.BPACK.P1(3),MYPACK.
APACK.BPACK.T3(IDENT_BOOL(FALSE))) THEN
FAILED ("VISIBILITY FOR GENERIC INSTANCE OF ACCESS " &
"EQUALITY BAD - B9");
END IF;
-- B10: VISIBILITY FOR GENERIC INSTANCE OF PRIVATE EQUALITY
IF MYPACK.APACK.BPACK."/="(MYPACK.APACK.BPACK.K1,MYPACK.APACK.
BPACK.RET_CHAR('V')) THEN
FAILED ("VISIBILITY FOR GENERIC INSTANCE OF PRIVATE " &
"EQUALITY BAD - B10");
END IF;
-- B11: VISIBILITY FOR GENERIC INSTANCE OF DERIVED SUBPROGRAM
IF MYPACK.APACK.BPACK."/="(MYPACK.APACK.BPACK.RET_T1(MYPACK.
APACK.BPACK.ORANGE),MYPACK.APACK.BPACK.GREEN) THEN
FAILED ("VISIBILITY FOR GENERIC INSTANCE OF DERIVED " &
"SUBPROGRAM BAD - B11");
END IF;
-- B12: VISIBILITY FOR GENERIC INSTANCE OF GENERIC SUBPROGRAM
MY_DO_NOTHING (MYPACK.APACK.BPACK.V1);
IF MYPACK.APACK.BPACK."/="(MYPACK.APACK.BPACK.V1,
MYPACK.APACK.BPACK.T3(FALSE)) THEN
FAILED ("VISIBILITY FOR GENERIC INSTANCE OF GENERIC " &
"SUBPROGRAM BAD - B12");
END IF;
END B_BLOCK;
RESULT;
END C83051A;
|
generic
package any_Math.any_Geometry.any_d3
--
-- Provides a namespace and core types for 3D geometry.
--
is
pragma Pure;
--------------
-- Core Types
--
subtype Site is Vector_3;
type Sites is array (Positive range <>) of Site;
type a_Model (Site_Count : Positive;
Tri_Count : Positive) is
record
Sites : any_d3 .Sites (1 .. Site_Count);
Triangles : any_Geometry.Triangles (1 .. Tri_Count);
end record;
function Image (the_Model : in a_Model) return String;
---------
-- Planes
--
type Plane is new Vector_4; -- A general plane equation.
procedure normalise (the_Plane : in out Plane);
----------
-- Bounds
--
type bounding_Box is
record
Lower,
Upper : Site;
end record;
null_Bounds : constant bounding_Box;
function to_bounding_Box (Self : Sites) return bounding_Box;
function "or" (Left : in bounding_Box; Right : in Site) return bounding_Box;
--
-- Returns the bounds expanded to include the vector.
function "or" (Left : in bounding_Box; Right : in bounding_Box) return bounding_Box;
--
-- Returns the bounds expanded to include both Left and Right.
function "+" (Left : in bounding_Box; Right : in Vector_3) return bounding_Box;
--
-- Returns the bounds translated by the vector.
function Extent (Self : in bounding_Box; Dimension : in Index) return Real;
function Image (Self : in bounding_Box) return String;
private
null_Bounds : constant bounding_Box := (Lower => (Real'Last, Real'Last, Real'Last),
Upper => (Real'First, Real'First, Real'First));
end any_Math.any_Geometry.any_d3;
|
with Unchecked_Conversion;
package Debug10_Pkg is
type Node_Id is range 0 .. 99_999_999;
Empty : constant Node_Id := 0;
subtype Entity_Id is Node_Id;
type Union_Id is new Integer;
function My_Is_Entity_Name (N : Node_Id) return Boolean;
function My_Scalar_Range (Id : Entity_Id) return Node_Id;
function My_Test (N : Node_Id) return Boolean;
type Node_Kind is (N_Unused_At_Start, N_Unused_At_End);
type Entity_Kind is (
E_Void,
E_Component,
E_Constant,
E_Discriminant,
E_Loop_Parameter,
E_Variable,
E_Out_Parameter,
E_In_Out_Parameter,
E_In_Parameter,
E_Generic_In_Out_Parameter,
E_Generic_In_Parameter,
E_Named_Integer,
E_Named_Real,
E_Enumeration_Type,
E_Enumeration_Subtype,
E_Signed_Integer_Type,
E_Signed_Integer_Subtype,
E_Modular_Integer_Type,
E_Modular_Integer_Subtype,
E_Ordinary_Fixed_Point_Type,
E_Ordinary_Fixed_Point_Subtype,
E_Decimal_Fixed_Point_Type,
E_Decimal_Fixed_Point_Subtype,
E_Floating_Point_Type,
E_Floating_Point_Subtype,
E_Access_Type,
E_Access_Subtype,
E_Access_Attribute_Type,
E_Allocator_Type,
E_General_Access_Type,
E_Access_Subprogram_Type,
E_Anonymous_Access_Subprogram_Type,
E_Access_Protected_Subprogram_Type,
E_Anonymous_Access_Protected_Subprogram_Type,
E_Anonymous_Access_Type,
E_Array_Type,
E_Array_Subtype,
E_String_Literal_Subtype,
E_Class_Wide_Type,
E_Class_Wide_Subtype,
E_Record_Type,
E_Record_Subtype,
E_Record_Type_With_Private,
E_Record_Subtype_With_Private,
E_Private_Type,
E_Private_Subtype,
E_Limited_Private_Type,
E_Limited_Private_Subtype,
E_Incomplete_Type,
E_Incomplete_Subtype,
E_Task_Type,
E_Task_Subtype,
E_Protected_Type,
E_Protected_Subtype,
E_Exception_Type,
E_Subprogram_Type,
E_Enumeration_Literal,
E_Function,
E_Operator,
E_Procedure,
E_Abstract_State,
E_Entry,
E_Entry_Family,
E_Block,
E_Entry_Index_Parameter,
E_Exception,
E_Generic_Function,
E_Generic_Procedure,
E_Generic_Package,
E_Label,
E_Loop,
E_Return_Statement,
E_Package,
E_Package_Body,
E_Protected_Object,
E_Protected_Body,
E_Task_Body,
E_Subprogram_Body
);
subtype Access_Kind is Entity_Kind range
E_Access_Type ..
E_Anonymous_Access_Type;
subtype Array_Kind is Entity_Kind range
E_Array_Type ..
E_String_Literal_Subtype;
subtype Object_Kind is Entity_Kind range
E_Component ..
E_Generic_In_Parameter;
subtype Record_Kind is Entity_Kind range
E_Class_Wide_Type ..
E_Record_Subtype_With_Private;
subtype Scalar_Kind is Entity_Kind range
E_Enumeration_Type ..
E_Floating_Point_Subtype;
subtype Type_Kind is Entity_Kind range
E_Enumeration_Type ..
E_Subprogram_Type;
type Node_Record (Is_Extension : Boolean := False) is record
Flag16 : Boolean;
Nkind : Node_Kind;
end record;
function N_To_E is new Unchecked_Conversion (Node_Kind, Entity_Kind);
type Arr is array (Node_Id) of Node_Record;
Nodes : Arr;
end Debug10_Pkg;
|
package Slice2 is
type R1 is record
Text : String (1 .. 30);
end record;
type R2 is record
Text : String (1 .. 8);
B : Boolean := True;
end record;
function F (I : R1) return R2;
end Slice2;
|
with Ada.Command_Line; use Ada.Command_Line;
with System.Multiprocessors; use System.Multiprocessors;
package Constant4_Pkg is
Max_CPUs : constant CPU := (if Argument_Count < 2 then Number_Of_CPUs
else CPU'Value (Argument (2)));
subtype Worker_Id is CPU range 1 .. Max_CPUs;
type Counter is range 0 .. 10**18;
Steals : array (Worker_Id) of Counter := (others => 0);
end Constant4_Pkg;
|
-- This file is covered by the Internet Software Consortium (ISC) License
-- Reference: ../License.txt
with Definitions; use Definitions;
with Ada.Characters.Latin_1;
with Ada.Directories;
with Ada.Text_IO;
with Ada.Exceptions;
with Package_Manifests;
with File_Operations;
with Utilities;
package body Port_Specification.Buildsheet is
package TIO renames Ada.Text_IO;
package DIR renames Ada.Directories;
package LAT renames Ada.Characters.Latin_1;
package MAN renames Package_Manifests;
package FOP renames File_Operations;
package UTL renames Utilities;
package EX renames Ada.Exceptions;
--------------------------------------------------------------------------------------------
-- generator
--------------------------------------------------------------------------------------------
procedure generator
(specs : Portspecs;
ravensrcdir : String;
output_file : String)
is
package crate is new CON.Vectors (Index_Type => Positive,
Element_Type => HT.Text,
"=" => HT.SU."=");
package local_sorter is new crate.Generic_Sorting ("<" => HT.SU."<");
procedure send (data : String; use_put : Boolean := False);
procedure send (varname : String; value, default : Integer);
procedure send (varname, value : String);
procedure send (varname : String; value : HT.Text);
procedure send (varname : String; crate : string_crate.Vector; flavor : Positive);
procedure send (varname : String; crate : def_crate.Map);
procedure send (varname : String; crate : list_crate.Map; flavor : Positive);
procedure send (varname : String; value : Boolean; show_when : Boolean);
procedure send_options;
procedure send_targets;
procedure send_descriptions;
procedure send_scripts;
procedure send_manifests;
procedure send_download_groups;
procedure print_item (position : string_crate.Cursor);
procedure print_item40 (position : string_crate.Cursor);
procedure print_straight (position : string_crate.Cursor);
procedure print_adjacent (position : string_crate.Cursor);
procedure print_adjacent_nowrap (position : string_crate.Cursor);
procedure dump_vardesc (position : string_crate.Cursor);
procedure dump_vardesc2 (position : string_crate.Cursor);
procedure dump_manifest (position : string_crate.Cursor);
procedure dump_manifest2 (position : string_crate.Cursor);
procedure dump_sdesc (position : def_crate.Cursor);
procedure dump_subpkgs (position : list_crate.Cursor);
procedure dump_optgroup (position : list_crate.Cursor);
procedure dump_distfiles (position : string_crate.Cursor);
procedure dump_targets (position : list_crate.Cursor);
procedure dump_helper (option_name : String; crate : string_crate.Vector; helper : String);
procedure expand_option_record (position : option_crate.Cursor);
procedure blank_line;
procedure send_file (filename : String);
procedure send_plist (filename : String);
procedure send_directory (dirname : String; pattern : String := "");
procedure send_catchall;
write_to_file : constant Boolean := (output_file /= "");
makefile_handle : TIO.File_Type;
varname_prefix : HT.Text;
save_variant : HT.Text;
current_len : Natural;
currently_blank : Boolean := True;
desc_prefix : constant String := "descriptions/desc.";
plist_prefix : constant String := "manifests/plist.";
distinfo : constant String := "distinfo";
temp_storage : string_crate.Vector;
procedure send (data : String; use_put : Boolean := False) is
begin
if write_to_file then
if use_put then
TIO.Put (makefile_handle, data);
else
TIO.Put_Line (makefile_handle, data);
end if;
else
if use_put then
TIO.Put (data);
else
TIO.Put_Line (data);
end if;
end if;
if data /= "" then
currently_blank := False;
end if;
end send;
procedure send (varname, value : String) is
begin
if value /= "" then
send (align24 (varname & LAT.Equals_Sign) & value);
end if;
end send;
procedure send (varname : String; value : HT.Text) is
begin
if not HT.IsBlank (value) then
send (align24 (varname & LAT.Equals_Sign) & HT.USS (value));
end if;
end send;
procedure send (varname : String; value, default : Integer) is
begin
if value /= default then
send (align24 (varname & LAT.Equals_Sign) & HT.int2str (value));
end if;
end send;
procedure send (varname : String; crate : string_crate.Vector; flavor : Positive) is
begin
if crate.Is_Empty then
return;
end if;
case flavor is
when 1 =>
send (align24 (varname & "="), True);
crate.Iterate (Process => print_item'Access);
when 2 =>
current_len := 0;
send (align24 (varname & "="), True);
crate.Iterate (Process => print_adjacent'Access);
send ("");
when 3 =>
varname_prefix := HT.SUS (varname);
crate.Iterate (Process => dump_distfiles'Access);
when 4 =>
current_len := 0;
send (align24 (varname & "="), True);
crate.Iterate (Process => print_adjacent_nowrap'Access);
send ("");
when others =>
null;
end case;
end send;
procedure send (varname : String; crate : def_crate.Map) is
begin
varname_prefix := HT.SUS (varname);
crate.Iterate (Process => dump_sdesc'Access);
end send;
procedure send (varname : String; crate : list_crate.Map; flavor : Positive) is
begin
varname_prefix := HT.SUS (varname);
case flavor is
when 4 =>
crate.Iterate (Process => dump_subpkgs'Access);
when 5 =>
crate.Iterate (Process => dump_optgroup'Access);
when others =>
null;
end case;
end send;
procedure send (varname : String; value : Boolean; show_when : Boolean) is
begin
if value = show_when then
send (align24 (varname & LAT.Equals_Sign) & "yes");
end if;
end send;
procedure print_item (position : string_crate.Cursor)
is
index : Natural := string_crate.To_Index (position);
item : String := HT.USS (string_crate.Element (position));
begin
if index = 1 then
send (item);
else
send (LAT.HT & LAT.HT & LAT.HT & item);
end if;
end print_item;
procedure print_item40 (position : string_crate.Cursor)
is
index : Natural := string_crate.To_Index (position);
item : String := HT.USS (string_crate.Element (position));
begin
if index = 1 then
send (item);
else
send (LAT.HT & LAT.HT & LAT.HT & LAT.HT & LAT.HT & item);
end if;
end print_item40;
procedure print_adjacent (position : string_crate.Cursor)
is
index : Natural := string_crate.To_Index (position);
item : String := HT.USS (string_crate.Element (position));
len : Natural := item'Length;
begin
-- Try to hit 75 chars
-- 76 - 24 = 52
if current_len + len + 1 > 52 then
current_len := 0;
send ("");
send (LAT.HT & LAT.HT & LAT.HT, True);
end if;
if current_len > 0 then
send (" ", True);
current_len := current_len + 1;
end if;
send (item, True);
current_len := current_len + len;
end print_adjacent;
procedure print_adjacent_nowrap (position : string_crate.Cursor)
is
index : Natural := string_crate.To_Index (position);
item : String := HT.USS (string_crate.Element (position));
len : Natural := item'Length;
begin
if current_len > 0 then
send (" ", True);
current_len := current_len + 1;
end if;
send (item, True);
current_len := current_len + len;
end print_adjacent_nowrap;
procedure print_straight (position : string_crate.Cursor)
is
item : String := HT.USS (string_crate.Element (position));
begin
send (item);
end print_straight;
procedure dump_sdesc (position : def_crate.Cursor)
is
varname : String := HT.USS (varname_prefix) & LAT.Left_Square_Bracket &
HT.USS (def_crate.Key (position)) & LAT.Right_Square_Bracket & LAT.Equals_Sign;
begin
send (align24 (varname) & HT.USS (def_crate.Element (position)));
end dump_sdesc;
procedure dump_subpkgs (position : list_crate.Cursor)
is
rec : group_list renames list_crate.Element (position);
varname : String := HT.USS (varname_prefix) & LAT.Left_Square_Bracket &
HT.USS (rec.group) & LAT.Right_Square_Bracket & LAT.Equals_Sign;
begin
if not rec.list.Is_Empty then
send (align24 (varname), True);
rec.list.Iterate (Process => print_item'Access);
end if;
end dump_subpkgs;
procedure dump_optgroup (position : list_crate.Cursor)
is
rec : group_list renames list_crate.Element (position);
varname : String := HT.USS (varname_prefix) & LAT.Left_Square_Bracket &
HT.USS (rec.group) & LAT.Right_Square_Bracket & LAT.Equals_Sign;
begin
if not rec.list.Is_Empty then
current_len := 0;
send (align24 (varname), True);
rec.list.Iterate (Process => print_adjacent'Access);
send ("");
end if;
end dump_optgroup;
procedure dump_distfiles (position : string_crate.Cursor)
is
index : Natural := string_crate.To_Index (position);
NDX : String := HT.USS (varname_prefix) & LAT.Left_Square_Bracket &
HT.int2str (index) & LAT.Right_Square_Bracket & LAT.Equals_Sign;
begin
send (align24 (NDX) & HT.USS (string_crate.Element (position)));
end dump_distfiles;
procedure blank_line is
begin
if not currently_blank then
send ("");
end if;
currently_blank := True;
end blank_line;
procedure send_targets is
begin
specs.make_targets.Iterate (Process => dump_targets'Access);
end send_targets;
procedure dump_targets (position : list_crate.Cursor)
is
rec : group_list renames list_crate.Element (position);
target : String := HT.USS (rec.group) & LAT.Colon;
begin
blank_line;
send (target);
rec.list.Iterate (Process => print_straight'Access);
end dump_targets;
procedure dump_helper (option_name : String; crate : string_crate.Vector; helper : String)
is
begin
if not crate.Is_Empty then
send (align40 (LAT.Left_Square_Bracket & option_name & "]." &
helper & LAT.Equals_Sign), True);
crate.Iterate (Process => print_item40'Access);
end if;
end dump_helper;
procedure expand_option_record (position : option_crate.Cursor)
is
rec : Option_Helper renames option_crate.Element (position);
name : String := HT.USS (rec.option_name);
begin
blank_line;
if not HT.IsBlank (rec.option_description) then
send (align40 (LAT.Left_Square_Bracket & name & "].DESCRIPTION=") &
HT.USS (rec.option_description));
end if;
if not HT.IsBlank (rec.BROKEN_ON) then
send (align40 (LAT.Left_Square_Bracket & name & "].BROKEN_ON=") &
HT.USS (rec.BROKEN_ON));
end if;
dump_helper (name, rec.BUILDRUN_DEPENDS_OFF, "BUILDRUN_DEPENDS_OFF");
dump_helper (name, rec.BUILDRUN_DEPENDS_ON, "BUILDRUN_DEPENDS_ON");
dump_helper (name, rec.BUILD_DEPENDS_OFF, "BUILD_DEPENDS_OFF");
dump_helper (name, rec.BUILD_DEPENDS_ON, "BUILD_DEPENDS_ON");
dump_helper (name, rec.BUILD_TARGET_OFF, "BUILD_TARGET_OFF");
dump_helper (name, rec.BUILD_TARGET_ON, "BUILD_TARGET_ON");
dump_helper (name, rec.CFLAGS_OFF, "CFLAGS_OFF");
dump_helper (name, rec.CFLAGS_ON, "CFLAGS_ON");
dump_helper (name, rec.CMAKE_ARGS_OFF, "CMAKE_ARGS_OFF");
dump_helper (name, rec.CMAKE_ARGS_ON, "CMAKE_ARGS_ON");
dump_helper (name, rec.CMAKE_BOOL_T_BOTH, "CMAKE_BOOL_T_BOTH");
dump_helper (name, rec.CMAKE_BOOL_F_BOTH, "CMAKE_BOOL_F_BOTH");
dump_helper (name, rec.CONFIGURE_ARGS_OFF, "CONFIGURE_ARGS_OFF");
dump_helper (name, rec.CONFIGURE_ARGS_ON, "CONFIGURE_ARGS_ON");
dump_helper (name, rec.CONFIGURE_ENABLE_BOTH, "CONFIGURE_ENABLE_BOTH");
dump_helper (name, rec.CONFIGURE_ENV_OFF, "CONFIGURE_ENV_OFF");
dump_helper (name, rec.CONFIGURE_ENV_ON, "CONFIGURE_ENV_ON");
dump_helper (name, rec.CONFIGURE_WITH_BOTH, "CONFIGURE_WITH_BOTH");
dump_helper (name, rec.CPPFLAGS_OFF, "CPPFLAGS_OFF");
dump_helper (name, rec.CPPFLAGS_ON, "CPPFLAGS_ON");
dump_helper (name, rec.CXXFLAGS_OFF, "CXXFLAGS_OFF");
dump_helper (name, rec.CXXFLAGS_ON, "CXXFLAGS_ON");
dump_helper (name, rec.DF_INDEX_OFF, "DF_INDEX_OFF");
dump_helper (name, rec.DF_INDEX_ON, "DF_INDEX_ON");
dump_helper (name, rec.EXTRACT_ONLY_OFF, "EXTRACT_ONLY_OFF");
dump_helper (name, rec.EXTRACT_ONLY_ON, "EXTRACT_ONLY_ON");
dump_helper (name, rec.EXTRA_PATCHES_OFF, "EXTRA_PATCHES_OFF");
dump_helper (name, rec.EXTRA_PATCHES_ON, "EXTRA_PATCHES_ON");
dump_helper (name, rec.GNOME_COMPONENTS_OFF, "GNOME_COMPONENTS_OFF");
dump_helper (name, rec.GNOME_COMPONENTS_ON, "GNOME_COMPONENTS_ON");
dump_helper (name, rec.IMPLIES_ON, "IMPLIES_ON");
dump_helper (name, rec.INFO_OFF, "INFO_OFF");
dump_helper (name, rec.INFO_ON, "INFO_ON");
dump_helper (name, rec.INSTALL_TARGET_OFF, "INSTALL_TARGET_OFF");
dump_helper (name, rec.INSTALL_TARGET_ON, "INSTALL_TARGET_ON");
dump_helper (name, rec.KEYWORDS_OFF, "KEYWORDS_OFF");
dump_helper (name, rec.KEYWORDS_ON, "KEYWORDS_ON");
dump_helper (name, rec.LDFLAGS_OFF, "LDFLAGS_OFF");
dump_helper (name, rec.LDFLAGS_ON, "LDFLAGS_ON");
dump_helper (name, rec.MAKEFILE_OFF, "MAKEFILE_OFF");
dump_helper (name, rec.MAKEFILE_ON, "MAKEFILE_ON");
dump_helper (name, rec.MAKE_ARGS_OFF, "MAKE_ARGS_OFF");
dump_helper (name, rec.MAKE_ARGS_ON, "MAKE_ARGS_ON");
dump_helper (name, rec.MAKE_ENV_OFF, "MAKE_ENV_OFF");
dump_helper (name, rec.MAKE_ENV_ON, "MAKE_ENV_ON");
dump_helper (name, rec.ONLY_FOR_OPSYS_ON, "ONLY_FOR_OPSYS_ON");
dump_helper (name, rec.PATCHFILES_OFF, "PATCHFILES_OFF");
dump_helper (name, rec.PATCHFILES_ON, "PATCHFILES_ON");
dump_helper (name, rec.PLIST_SUB_OFF, "PLIST_SUB_OFF");
dump_helper (name, rec.PLIST_SUB_ON, "PLIST_SUB_ON");
dump_helper (name, rec.PHP_EXTENSIONS_OFF, "PHP_EXTENSIONS_OFF");
dump_helper (name, rec.PHP_EXTENSIONS_ON, "PHP_EXTENSIONS_ON");
dump_helper (name, rec.PREVENTS_ON, "PREVENTS_ON");
dump_helper (name, rec.QMAKE_ARGS_OFF, "QMAKE_ARGS_OFF");
dump_helper (name, rec.QMAKE_ARGS_ON, "QMAKE_ARGS_ON");
dump_helper (name, rec.RUN_DEPENDS_OFF, "RUN_DEPENDS_OFF");
dump_helper (name, rec.RUN_DEPENDS_ON, "RUN_DEPENDS_ON");
dump_helper (name, rec.SUB_FILES_OFF, "SUB_FILES_OFF");
dump_helper (name, rec.SUB_FILES_ON, "SUB_FILES_ON");
dump_helper (name, rec.SUB_LIST_OFF, "SUB_LIST_OFF");
dump_helper (name, rec.SUB_LIST_ON, "SUB_LIST_ON");
dump_helper (name, rec.TEST_TARGET_OFF, "TEST_TARGET_OFF");
dump_helper (name, rec.TEST_TARGET_ON, "TEST_TARGET_ON");
dump_helper (name, rec.USES_OFF, "USES_OFF");
dump_helper (name, rec.USES_ON, "USES_ON");
dump_helper (name, rec.XORG_COMPONENTS_OFF, "XORG_COMPONENTS_OFF");
dump_helper (name, rec.XORG_COMPONENTS_ON, "XORG_COMPONENTS_ON");
end expand_option_record;
procedure send_options is
begin
specs.ops_helpers.Iterate (Process => expand_option_record'Access);
end send_options;
procedure send_file (filename : String)
is
abspath : constant String := ravensrcdir & "/" & filename;
begin
if DIR.Exists (abspath) then
declare
contents : constant String := FOP.get_file_contents (abspath);
begin
blank_line;
send ("[FILE:" & HT.int2str (contents'Length) & LAT.Colon & filename &
LAT.Right_Square_Bracket);
send (contents);
end;
end if;
end send_file;
procedure send_plist (filename : String)
is
abspath : constant String := ravensrcdir & "/" & filename;
begin
if DIR.Exists (abspath) then
declare
contents : constant String := MAN.compress_manifest (MAN.Filename (abspath));
begin
blank_line;
send ("[FILE:" & HT.int2str (contents'Length) & LAT.Colon & filename &
LAT.Right_Square_Bracket);
send (contents);
end;
end if;
end send_plist;
procedure dump_vardesc2 (position : string_crate.Cursor)
is
item : HT.Text renames string_crate.Element (position);
subpkg : String := HT.USS (item);
begin
send_file (desc_prefix & subpkg & LAT.Full_Stop & HT.USS (varname_prefix));
if DIR.Exists (ravensrcdir & "/" & desc_prefix & subpkg) and then
not temp_storage.Contains (item)
then
temp_storage.Append (item);
send_file (desc_prefix & subpkg);
end if;
end dump_vardesc2;
procedure dump_vardesc (position : string_crate.Cursor) is
begin
varname_prefix := string_crate.Element (position);
specs.subpackages.Element (varname_prefix).list.Iterate (dump_vardesc2'Access);
end dump_vardesc;
procedure send_descriptions is
begin
specs.variants.Iterate (Process => dump_vardesc'Access);
temp_storage.Clear;
end send_descriptions;
procedure send_scripts
is
function get_phasestr (index : Positive) return String;
function get_prefix (index : Positive) return String;
function get_phasestr (index : Positive) return String is
begin
case index is
when 1 => return "fetch";
when 2 => return "extract";
when 3 => return "patch";
when 4 => return "configure";
when 5 => return "build";
when 6 => return "install";
when others => return "";
end case;
end get_phasestr;
function get_prefix (index : Positive) return String is
begin
case index is
when 1 => return "pre-";
when 2 => return "post-";
when others => return "";
end case;
end get_prefix;
begin
for phase in Positive range 1 .. 6 loop
for prefix in Positive range 1 .. 2 loop
declare
target : String := get_prefix (prefix) & get_phasestr (phase) & "-script";
begin
send_file ("scripts/" & target);
end;
end loop;
end loop;
end send_scripts;
procedure send_directory (dirname : String; pattern : String := "")
is
procedure dump_file (cursor : string_crate.Cursor);
Search : DIR.Search_Type;
Dir_Ent : DIR.Directory_Entry_Type;
bucket : string_crate.Vector;
abspath : constant String := ravensrcdir & "/" & dirname;
filter : constant DIR.Filter_Type := (DIR.Directory => False,
DIR.Ordinary_File => True,
DIR.Special_File => False);
procedure dump_file (cursor : string_crate.Cursor)
is
filename : String := HT.USS (string_crate.Element (cursor));
begin
send_file (dirname & "/" & filename);
end dump_file;
begin
if not DIR.Exists (abspath) then
return;
end if;
DIR.Start_Search (Search => Search,
Directory => abspath,
Pattern => pattern,
Filter => filter);
while DIR.More_Entries (Search => Search) loop
DIR.Get_Next_Entry (Search => Search, Directory_Entry => Dir_Ent);
bucket.Append (HT.SUS (DIR.Simple_Name (Dir_Ent)));
end loop;
DIR.End_Search (Search);
sorter.Sort (Container => bucket);
bucket.Iterate (Process => dump_file'Access);
end send_directory;
procedure dump_manifest2 (position : string_crate.Cursor)
is
item : HT.Text renames string_crate.Element (position);
subpkg : String := HT.USS (item);
fullkey : HT.Text;
shortlist : String := plist_prefix & subpkg;
fullplist : String := shortlist & "." & HT.USS (save_variant);
begin
if DIR.Exists (ravensrcdir & "/" & fullplist) then
fullkey := HT.SUS (subpkg & "." & HT.USS (save_variant));
if not temp_storage.Contains (fullkey) then
temp_storage.Append (fullkey);
send_plist (fullplist);
end if;
else
if DIR.Exists (ravensrcdir & "/" & shortlist) and then
not temp_storage.Contains (item)
then
temp_storage.Append (item);
send_plist (shortlist);
end if;
end if;
end dump_manifest2;
procedure dump_manifest (position : string_crate.Cursor)
is
variant : HT.Text renames string_crate.Element (position);
begin
save_variant := variant;
specs.subpackages.Element (variant).list.Iterate (dump_manifest2'Access);
end dump_manifest;
procedure send_manifests
is
-- Manifests are subpackage-based
-- Not having a subpackage manifest is ok.
-- Subpackages typically missing: docs, examples, complete (Metaport)
begin
specs.variants.Iterate (Process => dump_manifest'Access);
temp_storage.Clear;
end send_manifests;
procedure send_download_groups
is
-- The first group must be either "main" or "none"
procedure gather (position : list_crate.Cursor);
procedure dump_groups (position : crate.Cursor);
procedure dump_sites (position : crate.Cursor);
num_groups : constant Natural := Natural (specs.dl_sites.Length);
first_one : constant String := HT.USS (list_crate.Element (specs.dl_sites.First).group);
groups : crate.Vector;
gcounter : Natural := 0;
procedure dump_groups (position : crate.Cursor)
is
index : HT.Text renames crate.Element (position);
rec : group_list renames specs.dl_sites.Element (index);
site : constant String := HT.USS (rec.group);
begin
gcounter := gcounter + 1;
if gcounter = 1 then
send (site, True);
else
send (" " & site, True);
end if;
end dump_groups;
procedure dump_sites (position : crate.Cursor)
is
index : HT.Text renames crate.Element (position);
rec : group_list renames specs.dl_sites.Element (index);
vname : String := "SITES[" & HT.USS (rec.group) & "]=";
begin
if not rec.list.Is_Empty then
send (align24 (vname), True);
rec.list.Iterate (Process => print_item'Access);
end if;
end dump_sites;
procedure gather (position : list_crate.Cursor)
is
name : HT.Text renames list_crate.Key (position);
begin
if not HT.equivalent (name, dlgroup_main) then
groups.Append (name);
end if;
end gather;
begin
send (align24 ("DOWNLOAD_GROUPS="), True);
if num_groups = 1 and then
first_one = dlgroup_none
then
send (dlgroup_none, False);
-- no SITES entry in this case
else
specs.dl_sites.Iterate (gather'Access);
local_sorter.Sort (Container => groups);
if specs.dl_sites.Contains (HT.SUS (dlgroup_main)) then
groups.Prepend (HT.SUS (dlgroup_main));
end if;
groups.Iterate (Process => dump_groups'Access);
send ("");
-- list SITES entries in same order
groups.Iterate (Process => dump_sites'Access);
end if;
end send_download_groups;
procedure send_catchall
is
procedure scan (position : list_crate.Cursor);
procedure putout (position : string_crate.Cursor);
temp_storage : string_crate.Vector;
procedure scan (position : list_crate.Cursor)
is
rec : group_list renames list_crate.Element (position);
begin
temp_storage.Append (rec.group);
end scan;
procedure putout (position : string_crate.Cursor)
is
text_value : HT.Text renames string_crate.Element (position);
begin
send (align24 (HT.USS (text_value) & "="), True);
specs.catch_all.Element (text_value).list.Iterate (print_item'Access);
end putout;
begin
specs.catch_all.Iterate (scan'Access);
sorter.Sort (temp_storage);
temp_storage.Iterate (putout'Access);
end send_catchall;
begin
if write_to_file then
TIO.Create (File => makefile_handle,
Mode => TIO.Out_File,
Name => output_file);
end if;
send ("# Buildsheet autogenerated by ravenadm tool -- Do not edit." & LAT.LF);
send ("NAMEBASE", specs.namebase);
send ("VERSION", specs.version);
send ("REVISION", specs.revision, 0);
send ("EPOCH", specs.epoch, 0);
send ("KEYWORDS", specs.keywords, 2);
send ("VARIANTS", specs.variants, 4);
send ("SDESC", specs.taglines);
send ("HOMEPAGE", specs.homepage);
send ("CONTACT", specs.contacts, 1);
blank_line;
send_download_groups;
send ("DISTFILE", specs.distfiles, 3);
send ("DIST_SUBDIR", specs.dist_subdir);
send ("DF_INDEX", specs.df_index, 2);
send ("SPKGS", specs.subpackages, 4);
blank_line;
send ("OPTIONS_AVAILABLE", specs.ops_avail, 2);
send ("OPTIONS_STANDARD", specs.ops_standard, 2);
send ("OPTGROUP_RADIO", specs.opt_radio, 2);
send ("OPTGROUP_RESTRICTED", specs.opt_restrict, 2);
send ("OPTGROUP_UNLIMITED", specs.opt_unlimited, 2);
send ("OPTDESCR", specs.optgroup_desc, 4);
send ("OPTGROUP", specs.optgroups, 5);
send ("VOPTS", specs.variantopts, 5);
send ("OPT_ON", specs.options_on, 5);
blank_line;
send ("BROKEN", specs.broken, 4);
send ("BROKEN_SSL", specs.broken_ssl, 2);
send ("BROKEN_MYSQL", specs.broken_mysql, 2);
send ("BROKEN_PGSQL", specs.broken_pgsql, 2);
send ("NOT_FOR_OPSYS", specs.exc_opsys, 2);
send ("ONLY_FOR_OPSYS", specs.inc_opsys, 2);
send ("NOT_FOR_ARCH", specs.exc_arch, 2);
send ("DEPRECATED", specs.deprecated);
send ("EXPIRATION_DATE", specs.expire_date);
blank_line;
send ("BUILD_DEPENDS", specs.build_deps, 1);
send ("BUILDRUN_DEPENDS", specs.buildrun_deps, 1);
send ("RUN_DEPENDS", specs.run_deps, 1);
send ("B_DEPS", specs.opsys_b_deps, 5);
send ("BR_DEPS", specs.opsys_br_deps, 5);
send ("R_DEPS", specs.opsys_r_deps, 5);
send ("EXRUN", specs.extra_rundeps, 4);
blank_line;
send ("USERS", specs.users, 2);
send ("GROUPS", specs.groups, 2);
send ("USERGROUP_SPKG", specs.usergroup_pkg);
blank_line;
send ("USES", specs.uses, 2);
send ("C_USES", specs.opsys_c_uses, 5);
send ("GNOME_COMPONENTS", specs.gnome_comps, 2);
send ("SDL_COMPONENTS", specs.sdl_comps, 2);
send ("XORG_COMPONENTS", specs.xorg_comps, 2);
send ("PHP_EXTENSIONS", specs.php_extensions, 2);
blank_line;
send ("DISTNAME", specs.distname);
send ("EXTRACT_DIRTY", specs.extract_dirty, 2);
send ("EXTRACT_ONLY", specs.extract_only, 2);
send ("EXTRACT_WITH_UNZIP", specs.extract_zip, 2);
send ("EXTRACT_WITH_7Z", specs.extract_7z, 2);
send ("EXTRACT_WITH_LHA", specs.extract_lha, 2);
send ("EXTRACT_DEB_PACKAGE", specs.extract_deb, 2);
send ("EXTRACT_HEAD", specs.extract_head, 4);
send ("EXTRACT_TAIL", specs.extract_tail, 4);
blank_line;
send ("LICENSE", specs.licenses, 2);
send ("LICENSE_TERMS", specs.lic_terms, 1);
send ("LICENSE_NAME", specs.lic_names, 1);
send ("LICENSE_FILE", specs.lic_files, 1);
send ("LICENSE_AWK", specs.lic_awk, 1);
send ("LICENSE_SOURCE", specs.lic_source, 1);
send ("LICENSE_SCHEME", specs.lic_scheme);
blank_line;
send ("PREFIX", specs.prefix);
send ("INFO", specs.info, 1);
send_catchall;
send ("GENERATED", specs.generated, True);
send ("SKIP_CCACHE", specs.skip_ccache, True);
blank_line;
send ("PATCH_WRKSRC", specs.patch_wrksrc);
send ("PATCHFILES", specs.patchfiles, 2);
send ("EXTRA_PATCHES", specs.extra_patches, 1);
send ("PATCH_STRIP", specs.patch_strip, 2);
send ("PATCHFILES_STRIP", specs.pfiles_strip, 2);
blank_line;
send ("INVALID_RPATH", specs.fatal_rpath, False);
send ("MUST_CONFIGURE", specs.config_must);
send ("GNU_CONFIGURE_PREFIX", specs.config_prefix);
send ("CONFIGURE_OUTSOURCE", specs.config_outsrc, True);
send ("CONFIGURE_WRKSRC", specs.config_wrksrc);
send ("CONFIGURE_SCRIPT", specs.config_script);
send ("CONFIGURE_TARGET", specs.config_target);
send ("CONFIGURE_ARGS", specs.config_args, 1);
send ("CONFIGURE_ENV", specs.config_env, 1);
blank_line;
send ("SKIP_BUILD", specs.skip_build, True);
send ("BUILD_WRKSRC", specs.build_wrksrc);
send ("BUILD_TARGET", specs.build_target, 2);
send ("MAKEFILE", specs.makefile);
send ("MAKE_ARGS", specs.make_args, 1);
send ("MAKE_ENV", specs.make_env, 1);
send ("DESTDIRNAME", specs.destdirname);
send ("DESTDIR_VIA_ENV", specs.destdir_env, True);
send ("MAKE_JOBS_NUMBER_LIMIT", specs.job_limit, 0);
send ("SINGLE_JOB", specs.single_job, True);
blank_line;
send ("SKIP_INSTALL", specs.skip_install, True);
send ("INSTALL_WRKSRC", specs.install_wrksrc);
send ("INSTALL_TARGET", specs.install_tgt, 2);
send ("INSTALL_REQ_TOOLCHAIN", specs.shift_install, True);
send ("MANDIRS", specs.mandirs, 1);
send ("SOVERSION", specs.soversion);
send ("PLIST_SUB", specs.plist_sub, 1);
send ("RC_SUBR", specs.subr_scripts, 1);
send ("SUB_FILES", specs.sub_files, 1);
send ("SUB_LIST", specs.sub_list, 1);
blank_line;
send ("REPOLOGY_SUCKS", specs.repology_sucks, True);
send ("BLOCK_WATCHDOG", specs.kill_watchdog, True);
send ("SET_DEBUGGING_ON", specs.debugging_on, True);
send ("CFLAGS", specs.cflags, 1);
send ("CXXFLAGS", specs.cxxflags, 1);
send ("CPPFLAGS", specs.cppflags, 1);
send ("LDFLAGS", specs.ldflags, 1);
send ("OPTIMIZER_LEVEL", specs.optimizer_lvl, 2);
send ("CMAKE_ARGS", specs.cmake_args, 1);
send ("QMAKE_ARGS", specs.qmake_args, 1);
send ("TEST_TARGET", specs.test_tgt, 2);
send ("TEST_ARGS", specs.test_args, 1);
send ("TEST_ENV", specs.test_env, 1);
send ("VAR_OPSYS", specs.var_opsys, 4);
send ("VAR_ARCH", specs.var_arch, 4);
send ("CARGO_SKIP_CONFIGURE", specs.cgo_skip_conf, True);
send ("CARGO_SKIP_BUILD", specs.cgo_skip_build, True);
send ("CARGO_SKIP_INSTALL", specs.cgo_skip_inst, True);
send ("CARGO_CONFIG_ARGS", specs.cgo_conf_args, 2);
send ("CARGO_BUILD_ARGS", specs.cgo_build_args, 2);
send ("CARGO_INSTALL_ARGS", specs.cgo_inst_args, 2);
send ("CARGO_FEATURES", specs.cgo_features, 2);
send_options;
send_targets;
send_descriptions;
send_file (distinfo);
send_manifests;
send_scripts;
send_directory ("patches", "patch-*");
send_directory ("files", "");
for opsys in supported_opsys'Range loop
send_directory (UTL.lower_opsys (opsys), "");
end loop;
if write_to_file then
TIO.Close (makefile_handle);
end if;
exception
when issue : others =>
if TIO.Is_Open (makefile_handle) then
TIO.Close (makefile_handle);
end if;
TIO.Put_Line ("PROBLEM: Buildsheet generation aborted");
TIO.Put_Line (EX.Exception_Information (issue));
end generator;
--------------------------------------------------------------------------------------------
-- align24
--------------------------------------------------------------------------------------------
function align24 (payload : String) return String
is
len : Natural := payload'Length;
begin
if len < 8 then
return payload & LAT.HT & LAT.HT & LAT.HT;
elsif len < 16 then
return payload & LAT.HT & LAT.HT;
elsif len < 24 then
return payload & LAT.HT;
else
return payload;
end if;
end align24;
--------------------------------------------------------------------------------------------
-- align40
--------------------------------------------------------------------------------------------
function align40 (payload : String) return String
is
len : Natural := payload'Length;
begin
if len < 8 then
return payload & LAT.HT & LAT.HT & LAT.HT & LAT.HT & LAT.HT;
elsif len < 16 then
return payload & LAT.HT & LAT.HT & LAT.HT & LAT.HT;
elsif len < 24 then
return payload & LAT.HT & LAT.HT & LAT.HT;
elsif len < 32 then
return payload & LAT.HT & LAT.HT;
elsif len < 40 then
return payload & LAT.HT;
else
return payload;
end if;
end align40;
--------------------------------------------------------------------------------------------
-- print_specification_template
--------------------------------------------------------------------------------------------
procedure print_specification_template (dump_to_file : Boolean)
is
tab : constant Character := LAT.HT;
CR : constant Character := LAT.LF;
part1 : constant String :=
"# DEF[PORTVERSION]=" & tab & "1.00" & CR &
"# ----------------------------------------------------------------------------";
part2 : constant String := CR &
"NAMEBASE=" & tab & tab & "..." & CR &
"VERSION=" & tab & tab & "${PORTVERSION}" & CR &
"KEYWORDS=" & tab & tab & "..." & CR &
"VARIANTS=" & tab & tab & "standard" & CR &
"SDESC[standard]=" & tab & "..." & CR &
"HOMEPAGE=" & tab & tab & "none" & CR &
"CONTACT=" & tab & tab & "Jay_Leno[jay@aarp.org]" & CR & CR &
"DOWNLOAD_GROUPS=" & tab & "main" & CR &
"SITES[main]=" & tab & tab & "http://www.example.com/" & CR &
"DISTFILE[1]=" & tab & tab & "x-${PORTVERSION}.tar.gz:main" & CR & CR &
"SPKGS[standard]=" & tab & "single" & CR & CR &
"OPTIONS_AVAILABLE=" & tab & "none" & CR &
"OPTIONS_STANDARD=" & tab & "none" & CR & CR &
"FPC_EQUIVALENT=" & tab & tab & "...";
template : TIO.File_Type;
filename : constant String := "specification";
begin
if dump_to_file then
if DIR.Exists (filename) then
TIO.Put_Line ("The " & filename &
" file already exists. I wouldn't want to overwrite it!");
return;
end if;
TIO.Create (File => template,
Mode => TIO.Out_File,
Name => filename);
TIO.Put_Line (template, part1);
TIO.Put_Line (template, part2);
TIO.Close (template);
DIR.Create_Directory ("manifests");
DIR.Create_Directory ("descriptions");
else
TIO.Put_Line (part1);
TIO.Put_Line (part2);
end if;
exception
when others =>
if TIO.Is_Open (template) then
TIO.Close (template);
end if;
end print_specification_template;
end Port_Specification.Buildsheet;
|
with Poly; use Poly;
with Ada.Text_IO;
procedure Main is
Arr: Vector (0 .. 1) := (7, 4);
X: Integer;
begin
X := 2;
Ada.Text_IO.Put_Line ("Value of poly: " & Horner(X, Arr)'Image);
end Main;
|
------------------------------------------------------------------------------
-- --
-- Copyright (C) 2016, AdaCore --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions are --
-- met: --
-- 1. Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- 2. Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in --
-- the documentation and/or other materials provided with the --
-- distribution. --
-- 3. Neither the name of STMicroelectronics nor the names of its --
-- contributors may be used to endorse or promote products derived --
-- from this software without specific prior written permission. --
-- --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR --
-- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
-- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT --
-- LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, --
-- DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY --
-- THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT --
-- (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE --
-- OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
-- --
-- --
-- This file is based on: --
-- --
-- @file stm32f4xx_hal_i2s.h --
-- @author MCD Application Team --
-- @version V1.0.0 --
-- @date 18-February-2014 --
-- @brief Header file of I2S HAL module. --
-- --
-- COPYRIGHT(c) 2014 STMicroelectronics --
------------------------------------------------------------------------------
-- This file provides definitions for the STM32F4 (ARM Cortex M4F
-- from ST Microelectronics) Inter-IC Sound (I2S) facility.
private with STM32_SVD.SPI;
with HAL.Audio; use HAL.Audio;
with System;
package STM32.I2S is
type I2S_Mode is (Slave_Transmit,
Slave_Receive,
Master_Transmit,
Master_Receive);
type I2S_Standard is (I2S_Philips_Standard,
MSB_Justified_Standard,
LSB_Justified_Standard,
PCM_Standard);
type I2S_Synchronization is (Short_Frame_Syncrho,
Long_Frame_Synchro);
type I2S_Clock_Polarity is (Steady_State_Low,
Steady_State_High);
type I2S_Data_Length is (Data_16bits, Data_24bits, Data_32bits);
type I2S_Channel_Length is (Channel_16bits, Channel_32bits);
type I2S_Linear_Prescaler is range 2 .. 255;
type I2S_Configuration is record
Mode : I2S_Mode;
Standard : I2S_Standard;
Syncho : I2S_Synchronization;
Clock_Polarity : I2S_Clock_Polarity;
Data_Length : I2S_Data_Length;
Chan_Length : I2S_Channel_Length;
Master_Clock_Out_Enabled : Boolean;
Transmit_DMA_Enabled : Boolean;
Receive_DMA_Enabled : Boolean;
end record;
type Internal_I2S_Port is private;
type I2S_Port (Periph : not null access Internal_I2S_Port) is
limited new Audio_Stream with private;
function In_I2S_Mode (This : in out I2S_Port) return Boolean;
-- I2S peripherals are shared with SPI, this function returns True only if
-- the periperal is configure in I2S mode.
procedure Configure (This : in out I2S_Port; Conf : I2S_Configuration)
with Pre => not This.Enabled,
Post => not This.Enabled;
procedure Enable (This : in out I2S_Port)
with Post => This.Enabled and This.In_I2S_Mode;
procedure Disable (This : in out I2S_Port)
with Pre => This.In_I2S_Mode;
function Enabled (This : I2S_Port) return Boolean;
function Data_Register_Address (This : I2S_Port)
return System.Address;
-- For DMA transfer
overriding
procedure Set_Frequency (This : in out I2S_Port;
Frequency : Audio_Frequency)
with Pre => not This.Enabled;
overriding
procedure Transmit (This : in out I2S_Port;
Data : Audio_Buffer)
with Pre => This.In_I2S_Mode;
overriding
procedure Receive (This : in out I2S_Port;
Data : out Audio_Buffer)
with Pre => This.In_I2S_Mode;
private
type Internal_I2S_Port is new STM32_SVD.SPI.SPI_Peripheral;
type I2S_Port (Periph : not null access Internal_I2S_Port) is
limited new Audio_Stream with null record;
end STM32.I2S;
|
pragma Style_Checks (Off);
--
-- Copyright (c) 2009, 2012 Tero Koskinen <tero.koskinen@iki.fi>
--
-- Permission to use, copy, modify, and distribute this software for any
-- purpose with or without fee is hereby granted, provided that the above
-- copyright notice and this permission notice appear in all copies.
--
-- THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
-- WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
-- MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
-- ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
-- WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
-- ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
-- OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
--
with Interfaces.C.Strings;
package body SQLite3 is
procedure Open (Filename : in String;
Handle : out SQLite3_DB;
Status : out Error_Code)
is
function sqlite3_open (Filename : Interfaces.C.Char_Array;
DB_Handle : access DB_Private_Access)
return Interfaces.C.Int;
pragma Import (C, sqlite3_open, "sqlite3_open");
Code : Interfaces.C.Int;
begin
Code := sqlite3_open (Interfaces.C.To_C (Filename), Handle.Ptr'Access);
Status := Error_Code (Code);
end Open;
procedure Close (Handle : in out SQLite3_DB; Status : out Error_Code) is
function sqlite3_close (DB_Handle : DB_Private_Access)
return Interfaces.C.Int;
pragma Import (C, sqlite3_close, "sqlite3_close");
Code : Interfaces.C.Int;
begin
Code := sqlite3_close (Handle.Ptr);
Status := Error_Code (Code);
end Close;
procedure Prepare (Handle : SQLite3_DB;
Sql : String;
SQL_Handle : out SQLite3_Statement;
Status : out Error_Code) is
type Chars_Ptr_Ptr is access all Interfaces.C.Strings.Chars_Ptr;
-- int sqlite3_prepare_v2(
-- sqlite3 *db, /* Database handle */
-- const char *zSql, /* SQL statement, UTF-8 encoded */
-- int nByte, /* Maximum length of zSql in bytes. */
-- sqlite3_stmt **ppStmt, /* OUT: Statement handle */
-- const char **pzTail /* OUT: Pointer to unused portion of zSql */
-- );
function sqlite3_prepare_v2
(DB_Handle : DB_Private_Access;
zSql : Interfaces.C.Char_Array;
nByte : Interfaces.C.Int;
ppStmt : access Statement_Private_Access;
pzTail : Chars_Ptr_Ptr)
return Interfaces.C.Int;
pragma Import (C, sqlite3_prepare_v2, "sqlite3_prepare_v2");
Sql_Str : constant Interfaces.C.Char_Array :=
Interfaces.C.To_C (Sql);
Code : Interfaces.C.Int;
begin
Code := sqlite3_prepare_v2
(DB_Handle => Handle.Ptr,
zSql => Sql_Str,
nByte => Sql_Str'Length,
ppStmt => Sql_Handle.Ptr'Access,
pzTail => null);
Status := Error_Code (Code);
end Prepare;
procedure Step (SQL_Handle : SQLite3_Statement; Status : out Error_Code) is
-- int sqlite3_step(sqlite3_stmt*);
function sqlite3_step (Stmt : Statement_Private_Access)
return Interfaces.C.Int;
pragma Import (C, sqlite3_step, "sqlite3_step");
Code : Interfaces.C.Int;
begin
Code := sqlite3_step (SQL_Handle.Ptr);
Status := Error_Code (Code);
end Step;
procedure Finish (SQL_Handle : SQLite3_Statement;
Status : out Error_Code) is
-- int sqlite3_finalize(sqlite3_stmt*);
function sqlite3_finalize (Stmt : Statement_Private_Access)
return Interfaces.C.Int;
pragma Import (C, sqlite3_finalize, "sqlite3_finalize");
Code : Interfaces.C.Int;
begin
Code := sqlite3_finalize (SQL_Handle.Ptr);
Status := Error_Code (Code);
end Finish;
procedure Reset (SQL_Handle : SQLite3_Statement;
Status : out Error_Code) is
-- int sqlite3_reset(sqlite3_stmt*);
function sqlite3_reset (Stmt : Statement_Private_Access)
return Interfaces.C.Int;
pragma Import (C, sqlite3_reset, "sqlite3_reset");
Code : Interfaces.C.Int;
begin
Code := sqlite3_reset (SQL_Handle.Ptr);
Status := Error_Code (Code);
end Reset;
procedure Clear_Bindings (SQL_Handle : SQLite3_Statement;
Status : out Error_Code)
is
-- int sqlite3_clear_bindings(sqlite3_stmt*);
function sqlite3_clear_bindings (Stmt : Statement_Private_Access)
return Interfaces.C.Int;
pragma Import (C, sqlite3_clear_bindings, "sqlite3_clear_bindings");
Code : Interfaces.C.Int;
begin
Code := sqlite3_clear_bindings (SQL_Handle.Ptr);
Status := Error_Code (Code);
end Clear_Bindings;
procedure Bind (SQL_Handle : SQLite3_Statement;
Index : SQL_Parameter_Index;
Value : Integer;
Status : out Error_Code) is
begin
Bind (SQL_Handle, Index, Long_Integer (Value), Status);
end Bind;
procedure Bind (SQL_Handle : SQLite3_Statement;
Index : SQL_Parameter_Index;
Value : Long_Integer;
Status : out Error_Code) is
-- int sqlite3_bind_int(sqlite3_stmt*, int, int);
function sqlite3_bind_int (Stmt : Statement_Private_Access;
Index : Interfaces.C.Int;
Value : Interfaces.C.Int)
return Interfaces.C.Int;
pragma Import (C, sqlite3_bind_int, "sqlite3_bind_int");
Code : Interfaces.C.Int;
begin
Code := sqlite3_bind_int (Stmt => Sql_Handle.Ptr,
Index => Interfaces.C.Int (Index),
Value => Interfaces.C.Int (Value));
Status := Error_Code (Code);
end Bind;
procedure Bind (SQL_Handle : SQLite3_Statement;
Index : SQL_Parameter_Index;
Value : Ada.Strings.Unbounded.Unbounded_String;
Status : out Error_Code)
is
use Ada.Strings.Unbounded;
-- int sqlite3_bind_text
-- (sqlite3_stmt*,
-- int,
-- const char*,
-- int,
-- void(*)(void*));
function sqlite3_bind_text (Stmt : Statement_Private_Access;
Index : Interfaces.C.int;
Value : Interfaces.C.char_array;
Bytes : Interfaces.C.int;
Opt : Interfaces.C.long)
return Interfaces.C.Int;
pragma Import (C, sqlite3_bind_text, "sqlite3_bind_text");
Code : Interfaces.C.Int;
begin
Code := sqlite3_bind_text
(Stmt => Sql_Handle.Ptr,
Index => Interfaces.C.int (Index),
Value => Interfaces.C.To_C (To_String (Value)),
Bytes => Interfaces.C.int (Length (Value)),
Opt => SQLITE_TRANSIENT);
Status := Error_Code (Code);
end Bind;
procedure Bind (SQL_Handle : SQLite3_Statement;
Index : SQL_Parameter_Index;
Value : String;
Status : out Error_Code)
is
-- int sqlite3_bind_text
-- (sqlite3_stmt*,
-- int,
-- const char*,
-- int,
-- void(*)(void*));
function sqlite3_bind_text (Stmt : Statement_Private_Access;
Index : Interfaces.C.int;
Value : Interfaces.C.char_array;
Bytes : Interfaces.C.int;
Opt : Interfaces.C.long)
return Interfaces.C.Int;
pragma Import (C, sqlite3_bind_text, "sqlite3_bind_text");
Code : Interfaces.C.Int;
begin
Code := sqlite3_bind_text
(Stmt => Sql_Handle.Ptr,
Index => Interfaces.C.int (Index),
Value => Interfaces.C.To_C (Value),
Bytes => Interfaces.C.int (Value'Length),
Opt => SQLITE_TRANSIENT);
Status := Error_Code (Code);
end Bind;
procedure Bind (SQL_Handle : SQLite3_Statement;
Index : SQL_Parameter_Index;
Value : Interfaces.C.double;
Status : out Error_Code)
is
-- int sqlite3_bind_double
-- (sqlite3_stmt*,
-- int,
-- double);
function sqlite3_bind_double (Stmt : Statement_Private_Access;
Index : Interfaces.C.int;
Value : Interfaces.C.double)
return Interfaces.C.Int;
pragma Import (C, sqlite3_bind_double, "sqlite3_bind_double");
Code : Interfaces.C.Int;
begin
Code := sqlite3_bind_double
(Stmt => Sql_Handle.Ptr,
Index => Interfaces.C.int (Index),
Value => Value);
Status := Error_Code (Code);
end Bind;
procedure Column (SQL_Handle : SQLite3_Statement;
Index : SQL_Column_Index;
Value : out Int) is
-- int sqlite3_column_int(sqlite3_stmt*, int iCol);
function sqlite3_column_int (Stmt : Statement_Private_Access;
Index : Interfaces.C.Int)
return Interfaces.C.Int;
pragma Import (C, sqlite3_column_int, "sqlite3_column_int");
Ret_Val : Interfaces.C.Int;
begin
Ret_Val := sqlite3_column_int (Stmt => Sql_Handle.Ptr,
Index => Interfaces.C.Int (Index));
Value := Int (Ret_Val);
end Column;
procedure Column (SQL_Handle : SQLite3_Statement;
Index : SQL_Column_Index;
Value : out Ada.Strings.Unbounded.Unbounded_String)
is
use Ada.Strings.Unbounded;
use Interfaces;
use type Interfaces.C.Strings.chars_ptr;
-- const unsigned char *sqlite3_column_text(sqlite3_stmt*, int iCol);
function sqlite3_column_text (Stmt : Statement_Private_Access;
Index : Interfaces.C.Int)
return Interfaces.C.Strings.chars_ptr;
pragma Import (C, sqlite3_column_text, "sqlite3_column_text");
Ret_Val : Interfaces.C.Strings.chars_ptr;
begin
Ret_Val := sqlite3_column_text (Stmt => Sql_Handle.Ptr,
Index => Interfaces.C.Int (Index));
if Ret_Val = C.Strings.Null_Ptr then
Value := Null_Unbounded_String;
else
Value := To_Unbounded_String (C.To_Ada (C.Strings.Value (Ret_Val)));
end if;
end Column;
function Error_Message (Handle : SQLite3_DB) return String is
use Interfaces;
-- const char *sqlite3_errmsg(sqlite3*);
function sqlite3_errmsg(DB_Handle : DB_Private_Access)
return C.Strings.chars_ptr;
pragma Import (C, sqlite3_errmsg, "sqlite3_errmsg");
begin
return C.To_Ada (C.Strings.Value (sqlite3_errmsg (Handle.Ptr)));
end Error_Message;
procedure Busy_Timeout (Handle : SQLite3_DB;
ms : Interfaces.C.int;
Status : out Error_Code)
is
-- int sqlite3_busy_timeout
-- (sqlite3*,
-- int);
function sqlite3_busy_timeout (DB_Handle : DB_Private_Access;
ms : Interfaces.C.int)
return Interfaces.C.Int;
pragma Import (C, sqlite3_busy_timeout, "sqlite3_busy_timeout");
Code : Interfaces.C.Int;
begin
Code := sqlite3_busy_timeout
(DB_Handle => Handle.Ptr,
ms => ms);
Status := Error_Code (Code);
end Busy_Timeout;
end SQLite3;
|
with Ada.Characters.Latin_1; use Ada.Characters.Latin_1;
with Ada.Integer_Text_IO; use Ada.Integer_Text_IO;
with Ada.Streams.Stream_IO; use Ada.Streams.Stream_IO;
function Get_PPM (File : File_Type) return Image is
use Ada.Characters.Latin_1;
use Ada.Integer_Text_IO;
function Get_Line return String is -- Skips comments
Byte : Character;
Buffer : String (1..80);
begin
loop
for I in Buffer'Range loop
Character'Read (Stream (File), Byte);
if Byte = LF then
exit when Buffer (1) = '#';
return Buffer (1..I - 1);
end if;
Buffer (I) := Byte;
end loop;
if Buffer (1) /= '#' then
raise Data_Error;
end if;
end loop;
end Get_Line;
Height : Integer;
Width : Integer;
begin
if Get_Line /= "P6" then
raise Data_Error;
end if;
declare
Line : String := Get_Line;
Start : Integer := Line'First;
Last : Positive;
begin
Get (Line, Width, Last); Start := Start + Last;
Get (Line (Start..Line'Last), Height, Last); Start := Start + Last;
if Start <= Line'Last then
raise Data_Error;
end if;
if Width < 1 or else Height < 1 then
raise Data_Error;
end if;
end;
if Get_Line /= "255" then
raise Data_Error;
end if;
declare
Result : Image (1..Height, 1..Width);
Buffer : String (1..Width * 3);
Index : Positive;
begin
for I in Result'Range (1) loop
String'Read (Stream (File), Buffer);
Index := Buffer'First;
for J in Result'Range (2) loop
Result (I, J) :=
( R => Luminance (Character'Pos (Buffer (Index))),
G => Luminance (Character'Pos (Buffer (Index + 1))),
B => Luminance (Character'Pos (Buffer (Index + 2)))
);
Index := Index + 3;
end loop;
end loop;
return Result;
end;
end Get_PPM;
|
with STM32_SVD; use STM32_SVD;
with STM32_SVD.RCC; use STM32_SVD.RCC;
with STM32GD.Startup;
with STM32GD.GPIO;
package body STM32GD.Board is
procedure Init is
begin
CLOCKS.Init;
RCC_Periph.IOPENR.IOPAEN := 1;
RCC_Periph.IOPENR.IOPBEN := 1;
RCC_Periph.IOPENR.IOPCEN := 1;
RCC_Periph.APB2ENR.SYSCFGEN := 1;
RCC_Periph.APB2ENR.SPI1EN := 1;
RCC_Periph.APB1ENR.I2C1EN := 1;
RCC_Periph.APB1ENR.USART2EN := 1;
A5.Init;
A4.Init;
SCL.Init;
SDA.Init;
SCL.Set_Type (STM32GD.GPIO.Open_Drain);
SDA.Set_Type (STM32GD.GPIO.Open_Drain);
-- SCL.Set_Speed (STM32GD.GPIO.Speed_100MHz);
-- SDA.Set_Speed (STM32GD.GPIO.Speed_100MHz);
TX.Init;
RX.Init;
USART.Init;
SPI.Init;
I2C.Init;
RTC.Init;
end Init;
end STM32GD.Board;
|
with System.Address_To_Named_Access_Conversions;
with System.Tasks;
package body System.Task_Primitives.Operations is
package Task_Id_Conv is
new Address_To_Named_Access_Conversions (
Tasks.Task_Record,
Tasks.Task_Id);
procedure Abort_Task (T : System.Tasking.Task_Id) is
begin
System.Tasks.Send_Abort (Task_Id_Conv.To_Pointer (T));
end Abort_Task;
end System.Task_Primitives.Operations;
|
package body prefix1 is
Counter : Integer := 2;
Table : Arr := (2, 4, 8, 16, 32, 64, 128, 256, 512, 1024);
function Func (Object : T) return Arr is
begin
return Table;
end;
end prefix1;
|
-- *************************************************************************************
--
-- The recipient is warned that this code should be handled in accordance
-- with the HM Government Security Classification indicated throughout.
--
-- This code and its contents shall not be used for other than UK Government
-- purposes.
--
-- The copyright in this code is the property of BAE SYSTEMS Electronic Systems Limited.
-- The Code is supplied by BAE SYSTEMS on the express terms that it is to be treated in
-- confidence and that it may not be copied, used or disclosed to others for any
-- purpose except in accordance with DEFCON 91 (Edn 10/92).
--
-- File Name: Generic_List.adb
-- Version: As detailed by ClearCase
-- Version Date: As detailed by ClearCase
-- Creation Date: 03-11-99
-- Security Classification: Unclassified
-- Project: SRLE (Sting Ray Life Extension)
-- Author: J Mann
-- Section: Tactical Software/ Software Architecture
-- Division: Underwater Systems Division
-- Description: Implementation of application-wide list type
-- Comments:
--
-- MODIFICATION RECORD
-- --------------------
-- NAME DATE ECR No MODIFICATION
--
-- jmm 29/06/99 QAR beatd40
--
-- jmm 10/05/00 ecr 008996 Cosmetic changes to source code, but no change to code content.
-- Changes can be identified by comparison with previous version.
--
-- jmm 11/07/00 PILOT_0000_0452 Add additional operation to remove entries without destroying
-- list.
--
-- db 04/07/01 PILOT_0000_0262 Set Stepping_Pointer to null
-- PILOT_0000_0230 Remove use clause as per coding standards.
--
-- db 08/02/02 SRLE100001619 Prevent de-referencing an empty queue when clearing.
--
-- db 17/04/02 SRLE100003005 Removal of loitering legacy code.
--
-- **************************************************************************************
with Ada.Unchecked_Deallocation;
with Application_Types;
use type Application_Types.Base_Integer_Type;
package body Generic_List is
--
-- Provide two removal procedures
procedure Remove_Node is new Ada.Unchecked_Deallocation (Node_Type, Node_Access_Type);
procedure Remove_List is new Ada.Unchecked_Deallocation (List_Header_Type, List_Header_Access_Type);
---------------------------------------------------------------------
function Initialise return List_Header_Access_Type is
Temp_Entry: List_Header_Access_Type;
begin
--
-- allocate new memory for the header information
--
Temp_Entry := new List_Header_Type;
--
-- and set the fields up. These could be replaced by default values in the
-- record declaration.
--
Temp_Entry.First_Entry := null;
Temp_Entry.Count := 0;
Temp_Entry.Free_List := null;
Temp_Entry.Free_List_Count := 0;
-- DEFECT 262 set Stepping_Pointer to null.
Temp_Entry.Stepping_Pointer := null;
return Temp_Entry;
end Initialise;
---------------------------------------------------------------------
function Count_Of (Target_List : List_Header_Access_Type) return Application_Types.Base_Integer_Type is
begin
return Target_List.Count;
end Count_Of;
---------------------------------------------------------------------
function Count_Of_Free_List (Target_List : List_Header_Access_Type) return Application_Types.Base_Integer_Type is
begin
return Target_List.Free_List_Count;
end Count_Of_Free_List;
---------------------------------------------------------------------
function Max_Count_Of (Target_List : List_Header_Access_Type) return Application_Types.Base_Integer_Type is
begin
return Target_List.Max_Count;
end Max_Count_Of;
---------------------------------------------------------------------
function First_Entry_Of (Target_List : List_Header_Access_Type) return Node_Access_Type is
begin
Target_List.Stepping_Pointer := Target_List.First_Entry;
return Target_List.Stepping_Pointer;
end First_Entry_Of;
---------------------------------------------------------------------
function Next_Entry_Of (Target_List : List_Header_Access_Type) return Node_Access_Type is
begin
Target_List.Stepping_Pointer := Target_List.Stepping_Pointer.Next;
return Target_List.Stepping_Pointer;
end Next_Entry_Of;
---------------------------------------------------------------------
procedure Insert (New_Item : in Element_Type;
On_To : in List_Header_Access_Type) is
New_Cell: Node_Access_Type;
begin
if On_To.Free_List = null then
--
-- there are no 'old' entries available for reuse
--
begin
New_Cell:= new Node_Type;
exception
when Storage_Error => raise List_Storage_Error ;
end;
--
-- this has been placed in a block to limit the scope of the exception handler
--
else -- Free_List /= null
--
-- there is an 'old' entry available for reuse, so grab it
--
New_Cell := On_To.Free_List;
On_To.Free_List := On_To.Free_List.Next;
On_To.Free_List_Count := On_To.Free_List_Count - 1;
end if; -- Free_List = null
--
-- The new call has been identified, so set it up
--
New_Cell.all := (
Item => New_Item,
Next => On_To.First_Entry);
On_To.First_Entry := New_Cell;
--
-- and increment the list size
--
On_To.Count := On_To.Count + 1;
if On_To.Count > On_To.Max_Count then
On_To.Max_Count := On_To.Count;
end if;
end Insert;
---------------------------------------------------------------------
procedure Delete (Item : in Node_Access_Type;
From : in out List_Header_Access_Type) is
Temp_Node : Node_Type;
Temp_Node_Pointer : Node_Access_Type;
begin
-- If item to delete and list to delete from are both valid
if (From /= null) and then (Item /= null) then
Temp_Node_Pointer := From.First_Entry;
if (Temp_Node_Pointer /= null) then
--
-- a request to delete an item from an empty queue
--
--
-- queue is not empty, find the requested item
--
if Temp_Node_Pointer = Item then
--
-- it's the first in the list to be deleted
--
Temp_Node.Next := Temp_Node_Pointer.Next;
From.First_Entry.Next := From.Free_List;
From.Free_List := Temp_Node_Pointer;
From.First_Entry := Temp_Node.Next;
From.Count := From.Count - 1;
From.Free_List_Count := From.Free_List_Count + 1;
else -- Temp_Node_Pointer /= Item
--
-- step through the list and find it
--
loop
exit when Temp_Node_Pointer.next = null;
--
-- or if the end is reached without finding it
--
if Temp_Node_Pointer.next = Item then
--
-- Found it. So remove it to the free list and remake the queue links
--
Temp_Node.Next := Temp_Node_Pointer.Next.Next;
Temp_Node_Pointer.Next.Next := From.Free_List;
From.Free_List := Temp_Node_Pointer.Next;
Temp_Node_Pointer.Next := Temp_Node.Next;
From.Count := From.Count - 1;
From.Free_List_Count := From.Free_List_Count + 1;
exit;
end if; --Temp_Node_Pointer.next = Item
Temp_Node_Pointer := Temp_Node_Pointer.Next;
--
-- Or not found, so let's look at the next in the list
--
end loop;
end if; -- Temp_Node_Pointer = Item
end if; -- Temp_Node_Pointer /= null
end if; -- Item or list /= null
--
-- there is no indication here:
-- a) if an item was deleted
-- b) if the requested item was not found in the list
-- c) if the list was empty
-- However, there is not yet any facility to act on this error information, so watch this space.
--
end Delete;
---------------------------------------------------------------------
--
-- PILOT_0000_0452 Add additional operation to remove entries without destroying list.
---------------------------------------------------------------------
procedure Clear (From : in out List_Header_Access_Type) is
Old_Cell : Node_Access_Type;
begin
-- SRLE100001619 Prevent de-referencing an empty queue
if From /= null then
while From.First_Entry /= null loop
--
-- don't try to clear an already-empty queue
--
Old_Cell := From.First_Entry;
From.First_Entry := From.First_Entry.Next;
--
-- Got one. So remove it to the free list
--
Old_Cell.Next := From.Free_List;
From.Free_List := Old_Cell;
--
From.Count := From.Count - 1;
From.Free_List_Count := From.Free_List_Count + 1;
--
-- Try again.
--
end loop; -- while From.First_Entry /= null
end if;
end Clear;
---------------------------------------------------------------------
procedure Destroy_List (Target_List : in out List_Header_Access_Type) is
Temp_Node_Pointer : Node_Access_Type;
Counter : Natural;
begin
--
-- qar beatd40
-- incorporate a null test into Destroy_List as changes to other components can result in the
-- attempted destruction of non-initialised lists
--
if Target_List /= null then
--
-- iterate over the free list and remove each individual item
--
Counter := 0;
while Target_List.Free_List /= null loop
Temp_Node_Pointer := Target_List.Free_List;
Target_List.Free_List := Target_List.Free_List.Next;
Remove_Node (Temp_Node_Pointer);
Counter := Counter + 1;
end loop;
--
-- iterate over the active list and remove each individual item
--
Counter := 0;
while Target_List.First_Entry /= null loop
Temp_Node_Pointer := Target_List.First_Entry;
Target_List.First_Entry := Target_List.First_Entry.Next;
Remove_Node (Temp_Node_Pointer);
Counter := Counter + 1;
end loop;
--
-- and finally remove the header information
--
Remove_List (Target_List);
end if;
end Destroy_List;
---------------------------------------------------------------------
function First_Entry_Of_Free_List (Target_List : List_Header_Access_Type) return Node_Access_Type is
begin
Target_List.Stepping_Pointer := Target_List.Free_List;
return Target_List.Stepping_Pointer;
end First_Entry_Of_Free_List;
---------------------------------------------------------------------
function Next_Entry_Of_Free_List (Target_List : List_Header_Access_Type) return Node_Access_Type is
begin
Target_List.Stepping_Pointer := Target_List.Stepping_Pointer.Next;
return Target_List.Stepping_Pointer;
end Next_Entry_Of_Free_List;
---------------------------------------------------------------------
end Generic_List;
|
-- Copyright (c) 2017 Maxim Reznik <reznikmm@gmail.com>
--
-- SPDX-License-Identifier: MIT
-- License-Filename: LICENSE
-------------------------------------------------------------
private package Ada_Pretty.Statements is
type Assignment is new Node with private;
function New_Assignment
(Left : not null Node_Access;
Right : not null Node_Access) return Node'Class;
type Case_Statement is new Node with private;
function New_Case
(Expression : not null Node_Access;
List : not null Node_Access) return Node'Class;
type Case_Path is new Node with private;
function New_Case_Path
(Choice : not null Node_Access;
List : not null Node_Access) return Node'Class;
type Elsif_Statement is new Node with private;
function New_Elsif
(Condition : not null Node_Access;
List : not null Node_Access) return Node'Class;
type If_Statement is new Node with private;
function New_If
(Condition : not null Node_Access;
Then_Path : not null Node_Access;
Elsif_List : Node_Access;
Else_Path : Node_Access) return Node'Class;
type For_Statement is new Node with private;
function New_For
(Name : not null Node_Access;
Iterator : not null Node_Access;
Statements : not null Node_Access) return Node'Class;
type Loop_Statement is new Node with private;
function New_Loop
(Condition : Node_Access;
Statements : not null Node_Access) return Node'Class;
type Return_Statement is new Node with private;
function New_Return
(Expression : Node_Access) return Node'Class;
type Extended_Return_Statement is new Node with private;
function New_Extended_Return
(Name : not null Node_Access;
Type_Definition : not null Node_Access;
Initialization : Node_Access;
Statements : not null Node_Access) return Node'Class;
type Statement is new Node with private;
function New_Statement
(Expression : Node_Access) return Node'Class;
type Block_Statement is new Node with private;
function New_Block_Statement
(Declarations : Node_Access;
Statements : Node_Access;
Exceptions : Node_Access) return Node'Class;
private
type Assignment is new Node with record
Left : not null Node_Access;
Right : not null Node_Access;
end record;
overriding function Document
(Self : Assignment;
Printer : not null access League.Pretty_Printers.Printer'Class;
Pad : Natural)
return League.Pretty_Printers.Document;
type Case_Statement is new Node with record
Expression : not null Node_Access;
List : not null Node_Access;
end record;
overriding function Document
(Self : Case_Statement;
Printer : not null access League.Pretty_Printers.Printer'Class;
Pad : Natural)
return League.Pretty_Printers.Document;
type Case_Path is new Node with record
Choice : not null Node_Access;
List : not null Node_Access;
end record;
overriding function Document
(Self : Case_Path;
Printer : not null access League.Pretty_Printers.Printer'Class;
Pad : Natural)
return League.Pretty_Printers.Document;
type Elsif_Statement is new Node with record
Condition : not null Node_Access;
List : not null Node_Access;
end record;
overriding function Document
(Self : Elsif_Statement;
Printer : not null access League.Pretty_Printers.Printer'Class;
Pad : Natural)
return League.Pretty_Printers.Document;
type If_Statement is new Node with record
Condition : not null Node_Access;
Then_Path : not null Node_Access;
Elsif_List : Node_Access;
Else_Path : Node_Access;
end record;
overriding function Document
(Self : If_Statement;
Printer : not null access League.Pretty_Printers.Printer'Class;
Pad : Natural)
return League.Pretty_Printers.Document;
type For_Statement is new Node with record
Name : not null Node_Access;
Iterator : not null Node_Access;
Statements : not null Node_Access;
end record;
overriding function Document
(Self : For_Statement;
Printer : not null access League.Pretty_Printers.Printer'Class;
Pad : Natural)
return League.Pretty_Printers.Document;
type Loop_Statement is new Node with record
Condition : Node_Access;
Statements : not null Node_Access;
end record;
overriding function Document
(Self : Loop_Statement;
Printer : not null access League.Pretty_Printers.Printer'Class;
Pad : Natural)
return League.Pretty_Printers.Document;
type Return_Statement is new Node with record
Expression : Node_Access;
end record;
overriding function Document
(Self : Return_Statement;
Printer : not null access League.Pretty_Printers.Printer'Class;
Pad : Natural)
return League.Pretty_Printers.Document;
type Extended_Return_Statement is new Node with record
Name : not null Node_Access;
Type_Definition : not null Node_Access;
Initialization : Node_Access;
Statements : not null Node_Access;
end record;
overriding function Document
(Self : Extended_Return_Statement;
Printer : not null access League.Pretty_Printers.Printer'Class;
Pad : Natural)
return League.Pretty_Printers.Document;
type Statement is new Node with record
Expression : Node_Access;
end record;
overriding function Document
(Self : Statement;
Printer : not null access League.Pretty_Printers.Printer'Class;
Pad : Natural)
return League.Pretty_Printers.Document;
type Block_Statement is new Node with record
Declarations : Node_Access;
Statements : Node_Access;
Exceptions : Node_Access;
end record;
overriding function Document
(Self : Block_Statement;
Printer : not null access League.Pretty_Printers.Printer'Class;
Pad : Natural)
return League.Pretty_Printers.Document;
end Ada_Pretty.Statements;
|
with SPARKNaCl; use SPARKNaCl;
with SPARKNaCl.Debug; use SPARKNaCl.Debug;
with SPARKNaCl.Scalar; use SPARKNaCl.Scalar;
procedure Scalarmult5
is
AliceSK : constant Bytes_32 :=
(16#77#, 16#07#, 16#6d#, 16#0a#, 16#73#, 16#18#, 16#a5#, 16#7d#,
16#3c#, 16#16#, 16#c1#, 16#72#, 16#51#, 16#b2#, 16#66#, 16#45#,
16#df#, 16#4c#, 16#2f#, 16#87#, 16#eb#, 16#c0#, 16#99#, 16#2a#,
16#b1#, 16#77#, 16#fb#, 16#a5#, 16#1d#, 16#b9#, 16#2c#, 16#2a#);
BobPK : constant Bytes_32 :=
(16#de#, 16#9e#, 16#db#, 16#7d#, 16#7b#, 16#7d#, 16#c1#, 16#b4#,
16#d3#, 16#5b#, 16#61#, 16#c2#, 16#ec#, 16#e4#, 16#35#, 16#37#,
16#3f#, 16#83#, 16#43#, 16#c8#, 16#5b#, 16#78#, 16#67#, 16#4d#,
16#ad#, 16#fc#, 16#7e#, 16#14#, 16#6f#, 16#88#, 16#2b#, 16#4f#);
K : Bytes_32;
begin
K := Mult (AliceSK, BobPK);
DH ("K is", K);
end Scalarmult5;
|
with System;
with HAL;
with HAL.Bitmap;
package PyGamer.Screen is
Width : constant := 160;
Height : constant := 128;
procedure Set_Address (X_Start, X_End, Y_Start, Y_End : HAL.UInt16);
procedure Start_Pixel_TX;
procedure End_Pixel_TX;
procedure Push_Pixels (Addr : System.Address; Len : Natural);
-- Addr: pointer to a read-only buffer of Len pixels (16-bit RGB565)
procedure Push_Pixels_Swap (Addr : System.Address; Len : Natural);
-- Addr: pointer to a read-write buffer of Len pixels (16-bit RGB565)
procedure Scroll (Val : HAL.UInt8);
-- DMA --
procedure Start_DMA (Addr : System.Address; Len : Natural);
-- Addr: pointer to a read-only buffer of Len pixels (16-bit RGB565)
procedure Wait_End_Of_DMA;
end PyGamer.Screen;
|
package body Ringbuffers is
procedure Write (Self : in out Ringbuffer; e : Item) is
begin
Self.Items (Self.Write_Index) := e;
Self.Write_Index := Self.Write_Index + 1;
if Self.Write_Index = Size then
Self.Write_Index := 1;
end if;
end Write;
function Read (Self : in out Ringbuffer) return Item is
Result : Item;
begin
Result := Self.Items (Self.Read_Index);
Self.Read_Index := Self.Read_Index + 1;
if Self.Read_Index = Size then
Self.Read_Index := 1;
end if;
return Result;
end Read;
function Is_Empty (Self : Ringbuffer) return Boolean is
begin
return Self.Write_Index = Self.Read_Index;
end Is_Empty;
end Ringbuffers;
|
------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- Localization, Internationalization, Globalization for Ada --
-- --
-- Runtime Library Component --
-- --
------------------------------------------------------------------------------
-- --
-- Copyright © 2012-2015, Vadim Godunko <vgodunko@gmail.com> --
-- 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_0010 is
pragma Preelaborate;
Group_0010 : aliased constant Core_Second_Stage
:= (16#2B# .. 16#2C# => -- 102B .. 102C
(Spacing_Mark, Neutral,
Other, Extend, Extend, Complex_Context,
(Other_Alphabetic
| Alphabetic
| Grapheme_Base
| ID_Continue
| XID_Continue => True,
others => False)),
16#2D# .. 16#30# => -- 102D .. 1030
(Nonspacing_Mark, Neutral,
Extend, Extend, Extend, Complex_Context,
(Other_Alphabetic
| Alphabetic
| Case_Ignorable
| Grapheme_Extend
| ID_Continue
| XID_Continue => True,
others => False)),
16#31# => -- 1031
(Spacing_Mark, Neutral,
Spacing_Mark, Extend, Extend, Complex_Context,
(Other_Alphabetic
| Alphabetic
| Grapheme_Base
| ID_Continue
| XID_Continue => True,
others => False)),
16#32# .. 16#36# => -- 1032 .. 1036
(Nonspacing_Mark, Neutral,
Extend, Extend, Extend, Complex_Context,
(Other_Alphabetic
| Alphabetic
| Case_Ignorable
| Grapheme_Extend
| ID_Continue
| XID_Continue => True,
others => False)),
16#37# => -- 1037
(Nonspacing_Mark, Neutral,
Extend, Extend, Extend, Complex_Context,
(Diacritic
| Case_Ignorable
| Grapheme_Extend
| ID_Continue
| XID_Continue => True,
others => False)),
16#38# => -- 1038
(Spacing_Mark, Neutral,
Other, Extend, Extend, Complex_Context,
(Other_Alphabetic
| Alphabetic
| Grapheme_Base
| ID_Continue
| XID_Continue => True,
others => False)),
16#39# .. 16#3A# => -- 1039 .. 103A
(Nonspacing_Mark, Neutral,
Extend, Extend, Extend, Complex_Context,
(Diacritic
| Case_Ignorable
| Grapheme_Extend
| Grapheme_Link
| ID_Continue
| XID_Continue => True,
others => False)),
16#3B# .. 16#3C# => -- 103B .. 103C
(Spacing_Mark, Neutral,
Spacing_Mark, Extend, Extend, Complex_Context,
(Other_Alphabetic
| Alphabetic
| Grapheme_Base
| ID_Continue
| XID_Continue => True,
others => False)),
16#3D# .. 16#3E# => -- 103D .. 103E
(Nonspacing_Mark, Neutral,
Extend, Extend, Extend, Complex_Context,
(Other_Alphabetic
| Alphabetic
| Case_Ignorable
| Grapheme_Extend
| ID_Continue
| XID_Continue => True,
others => False)),
16#40# .. 16#49# => -- 1040 .. 1049
(Decimal_Number, Neutral,
Other, Numeric, Numeric, Numeric,
(Grapheme_Base
| ID_Continue
| XID_Continue => True,
others => False)),
16#4A# .. 16#4B# => -- 104A .. 104B
(Other_Punctuation, Neutral,
Other, Other, S_Term, Break_After,
(STerm
| Terminal_Punctuation
| Grapheme_Base => True,
others => False)),
16#4C# .. 16#4F# => -- 104C .. 104F
(Other_Punctuation, Neutral,
Other, Other, Other, Alphabetic,
(Grapheme_Base => True,
others => False)),
16#56# .. 16#57# => -- 1056 .. 1057
(Spacing_Mark, Neutral,
Spacing_Mark, Extend, Extend, Complex_Context,
(Other_Alphabetic
| Alphabetic
| Grapheme_Base
| ID_Continue
| XID_Continue => True,
others => False)),
16#58# .. 16#59# => -- 1058 .. 1059
(Nonspacing_Mark, Neutral,
Extend, Extend, Extend, Complex_Context,
(Other_Alphabetic
| Alphabetic
| Case_Ignorable
| Grapheme_Extend
| ID_Continue
| XID_Continue => True,
others => False)),
16#5E# .. 16#60# => -- 105E .. 1060
(Nonspacing_Mark, Neutral,
Extend, Extend, Extend, Complex_Context,
(Other_Alphabetic
| Alphabetic
| Case_Ignorable
| Grapheme_Extend
| ID_Continue
| XID_Continue => True,
others => False)),
16#62# => -- 1062
(Spacing_Mark, Neutral,
Other, Extend, Extend, Complex_Context,
(Other_Alphabetic
| Alphabetic
| Grapheme_Base
| ID_Continue
| XID_Continue => True,
others => False)),
16#63# .. 16#64# => -- 1063 .. 1064
(Spacing_Mark, Neutral,
Other, Extend, Extend, Complex_Context,
(Grapheme_Base
| ID_Continue
| XID_Continue => True,
others => False)),
16#67# .. 16#68# => -- 1067 .. 1068
(Spacing_Mark, Neutral,
Other, Extend, Extend, Complex_Context,
(Other_Alphabetic
| Alphabetic
| Grapheme_Base
| ID_Continue
| XID_Continue => True,
others => False)),
16#69# .. 16#6D# => -- 1069 .. 106D
(Spacing_Mark, Neutral,
Other, Extend, Extend, Complex_Context,
(Grapheme_Base
| ID_Continue
| XID_Continue => True,
others => False)),
16#71# .. 16#74# => -- 1071 .. 1074
(Nonspacing_Mark, Neutral,
Extend, Extend, Extend, Complex_Context,
(Other_Alphabetic
| Alphabetic
| Case_Ignorable
| Grapheme_Extend
| ID_Continue
| XID_Continue => True,
others => False)),
16#82# => -- 1082
(Nonspacing_Mark, Neutral,
Extend, Extend, Extend, Complex_Context,
(Other_Alphabetic
| Alphabetic
| Case_Ignorable
| Grapheme_Extend
| ID_Continue
| XID_Continue => True,
others => False)),
16#83# => -- 1083
(Spacing_Mark, Neutral,
Other, Extend, Extend, Complex_Context,
(Other_Alphabetic
| Alphabetic
| Grapheme_Base
| ID_Continue
| XID_Continue => True,
others => False)),
16#84# => -- 1084
(Spacing_Mark, Neutral,
Spacing_Mark, Extend, Extend, Complex_Context,
(Other_Alphabetic
| Alphabetic
| Grapheme_Base
| ID_Continue
| XID_Continue => True,
others => False)),
16#85# .. 16#86# => -- 1085 .. 1086
(Nonspacing_Mark, Neutral,
Extend, Extend, Extend, Complex_Context,
(Other_Alphabetic
| Alphabetic
| Case_Ignorable
| Grapheme_Extend
| ID_Continue
| XID_Continue => True,
others => False)),
16#87# .. 16#8C# => -- 1087 .. 108C
(Spacing_Mark, Neutral,
Other, Extend, Extend, Complex_Context,
(Diacritic
| Grapheme_Base
| ID_Continue
| XID_Continue => True,
others => False)),
16#8D# => -- 108D
(Nonspacing_Mark, Neutral,
Extend, Extend, Extend, Complex_Context,
(Diacritic
| Case_Ignorable
| Grapheme_Extend
| ID_Continue
| XID_Continue => True,
others => False)),
16#8F# => -- 108F
(Spacing_Mark, Neutral,
Other, Extend, Extend, Complex_Context,
(Diacritic
| Grapheme_Base
| ID_Continue
| XID_Continue => True,
others => False)),
16#90# .. 16#99# => -- 1090 .. 1099
(Decimal_Number, Neutral,
Other, Numeric, Numeric, Numeric,
(Grapheme_Base
| ID_Continue
| XID_Continue => True,
others => False)),
16#9A# .. 16#9B# => -- 109A .. 109B
(Spacing_Mark, Neutral,
Other, Extend, Extend, Complex_Context,
(Diacritic
| Grapheme_Base
| ID_Continue
| XID_Continue => True,
others => False)),
16#9C# => -- 109C
(Spacing_Mark, Neutral,
Other, Extend, Extend, Complex_Context,
(Other_Alphabetic
| Alphabetic
| Grapheme_Base
| ID_Continue
| XID_Continue => True,
others => False)),
16#9D# => -- 109D
(Nonspacing_Mark, Neutral,
Extend, Extend, Extend, Complex_Context,
(Other_Alphabetic
| Alphabetic
| Case_Ignorable
| Grapheme_Extend
| ID_Continue
| XID_Continue => True,
others => False)),
16#9E# .. 16#9F# => -- 109E .. 109F
(Other_Symbol, Neutral,
Other, Other, Other, Complex_Context,
(Grapheme_Base => True,
others => False)),
16#A0# .. 16#C5# => -- 10A0 .. 10C5
(Uppercase_Letter, Neutral,
Other, A_Letter, Upper, Alphabetic,
(Alphabetic
| Cased
| Changes_When_Lowercased
| Changes_When_Casefolded
| Changes_When_Casemapped
| Grapheme_Base
| ID_Continue
| ID_Start
| Uppercase
| XID_Continue
| XID_Start
| Changes_When_NFKC_Casefolded => True,
others => False)),
16#C6# => -- 10C6
(Unassigned, Neutral,
Other, Other, Other, Unknown,
(others => False)),
16#C7# => -- 10C7
(Uppercase_Letter, Neutral,
Other, A_Letter, Upper, Alphabetic,
(Alphabetic
| Cased
| Changes_When_Lowercased
| Changes_When_Casefolded
| Changes_When_Casemapped
| Grapheme_Base
| ID_Continue
| ID_Start
| Uppercase
| XID_Continue
| XID_Start
| Changes_When_NFKC_Casefolded => True,
others => False)),
16#C8# .. 16#CC# => -- 10C8 .. 10CC
(Unassigned, Neutral,
Other, Other, Other, Unknown,
(others => False)),
16#CD# => -- 10CD
(Uppercase_Letter, Neutral,
Other, A_Letter, Upper, Alphabetic,
(Alphabetic
| Cased
| Changes_When_Lowercased
| Changes_When_Casefolded
| Changes_When_Casemapped
| Grapheme_Base
| ID_Continue
| ID_Start
| Uppercase
| XID_Continue
| XID_Start
| Changes_When_NFKC_Casefolded => True,
others => False)),
16#CE# .. 16#CF# => -- 10CE .. 10CF
(Unassigned, Neutral,
Other, Other, Other, Unknown,
(others => False)),
16#D0# .. 16#FA# => -- 10D0 .. 10FA
(Other_Letter, Neutral,
Other, A_Letter, O_Letter, Alphabetic,
(Alphabetic
| Grapheme_Base
| ID_Continue
| ID_Start
| XID_Continue
| XID_Start => True,
others => False)),
16#FB# => -- 10FB
(Other_Punctuation, Neutral,
Other, Other, Other, Alphabetic,
(Grapheme_Base => True,
others => False)),
16#FC# => -- 10FC
(Modifier_Letter, Neutral,
Other, A_Letter, O_Letter, Alphabetic,
(Alphabetic
| Case_Ignorable
| Grapheme_Base
| ID_Continue
| ID_Start
| XID_Continue
| XID_Start
| Changes_When_NFKC_Casefolded => True,
others => False)),
16#FD# .. 16#FF# => -- 10FD .. 10FF
(Other_Letter, Neutral,
Other, A_Letter, O_Letter, Alphabetic,
(Alphabetic
| Grapheme_Base
| ID_Continue
| ID_Start
| XID_Continue
| XID_Start => True,
others => False)),
others =>
(Other_Letter, Neutral,
Other, Other, O_Letter, Complex_Context,
(Alphabetic
| Grapheme_Base
| ID_Continue
| ID_Start
| XID_Continue
| XID_Start => True,
others => False)));
end Matreshka.Internals.Unicode.Ucd.Core_0010;
|
pragma Restrictions (No_Elaboration_Code);
pragma Ada_2012;
pragma Style_Checks (Off);
with System;
with STM32_SVD; use STM32_SVD;
package STM32GD.SysTick is
pragma Preelaborate;
type SysTick_Callback_Type is access procedure;
subtype CSR_ENABLE_Field is STM32_SVD.Bit;
subtype CSR_TICKINT_Field is STM32_SVD.Bit;
subtype CSR_CLKSOURCE_Field is STM32_SVD.Bit;
subtype CSR_COUNTFLAG_Field is STM32_SVD.Bit;
-- control and status register
type CSR_Register is record
-- Enable counter
ENABLE : CSR_ENABLE_Field := 16#0#;
-- Enable tick interrupt
TICKINT : CSR_CLKSOURCE_Field := 16#0#;
-- Clock source
CLKSOURCE : CSR_TICKINT_Field := 16#0#;
-- unspecified
Reserved_3_15 : STM32_SVD.UInt13 := 16#0#;
-- Counter wraparound
COUNTFLAG : CSR_COUNTFLAG_Field := 16#0#;
-- unspecified
Reserved_17_31 : STM32_SVD.UInt15 := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for CSR_Register use record
ENABLE at 0 range 0 .. 0;
TICKINT at 0 range 1 .. 1;
CLKSOURCE at 0 range 2 .. 2;
Reserved_3_15 at 0 range 3 .. 15;
COUNTFLAG at 0 range 16 .. 16;
Reserved_17_31 at 0 range 17 .. 31;
end record;
subtype RVR_RELOAD_Field is STM32_SVD.UInt24;
-- Reload value register
type RVR_Register is record
-- Reload value
RELOAD : RVR_RELOAD_Field := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for RVR_Register use record
RELOAD at 0 range 0 .. 23;
end record;
subtype CVR_CURRENT_Field is STM32_SVD.UInt24;
-- Reload value register
type CVR_Register is record
-- Reload value
CURRENT : CVR_CURRENT_Field := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for CVR_Register use record
CURRENT at 0 range 0 .. 23;
end record;
-----------------
-- Peripherals --
-----------------
-- Power control
type SysTick_Peripheral is record
-- SysTick control/status register
CSR : aliased CSR_Register;
RVR : aliased RVR_Register;
CVR : aliased CVR_Register;
end record
with Volatile;
for SysTick_Peripheral use record
CSR at 16#0# range 0 .. 31;
RVR at 16#4# range 0 .. 31;
CVR at 16#8# range 0 .. 31;
end record;
-- SysTick
SysTick_Periph : aliased SysTick_Peripheral
with Import, Address => System'To_Address (16#E000E010#);
end STM32GD.SysTick;
|
------------------------------------------------------------------------------
-- --
-- GNAT COMPILER COMPONENTS --
-- --
-- S Y S T E M . S T A N D A R D _ L I B R A R Y --
-- --
-- S p e c --
-- --
-- Copyright (C) 1992-2020, 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. --
-- --
------------------------------------------------------------------------------
-- SweetAda SFP cutted-down version --
------------------------------------------------------------------------------
-- This package is included in all programs. It contains declarations that
-- are required to be part of every Ada program. A special mechanism is
-- required to ensure that these are loaded, since it may be the case in
-- some programs that the only references to these required packages are
-- from C code or from code generated directly by Gigi, and in both cases
-- the binder is not aware of such references.
-- System.Standard_Library also includes data that must be present in every
-- program, in particular data for all the standard exceptions, and also some
-- subprograms that must be present in every program.
-- The binder unconditionally includes s-stalib.ali, which ensures that this
-- package and the packages it references are included in all Ada programs,
-- together with the included data.
pragma Compiler_Unit_Warning;
-- with Ada.Unchecked_Conversion;
package System.Standard_Library is
-- Historical note: pragma Preelaborate was surrounded by a pair of pragma
-- Warnings (Off/On) to circumvent a bootstrap issue.
pragma Preelaborate;
-------------------------------------
-- Exception Declarations and Data --
-------------------------------------
type Raise_Action is access procedure;
pragma Favor_Top_Level (Raise_Action);
-- A pointer to a procedure used in the Raise_Hook field
type Exception_Data;
type Exception_Data_Ptr is access all Exception_Data;
-- An equivalent of Exception_Id that is public
-- The following record defines the underlying representation of exceptions
-- WARNING: Any changes to this may need to be reflected in the following
-- locations in the compiler and runtime code:
-- 1. The Internal_Exception routine in s-exctab.adb
-- 2. The processing in gigi that tests Not_Handled_By_Others
-- 3. Expand_N_Exception_Declaration in Exp_Ch11
-- 4. The construction of the exception type in Cstand
type Exception_Data is record
Not_Handled_By_Others : Boolean;
-- Normally set False, indicating that the exception is handled in the
-- usual way by others (i.e. an others handler handles the exception).
-- Set True to indicate that this exception is not caught by others
-- handlers, but must be explicitly named in a handler. This latter
-- setting is currently used by the Abort_Signal.
Lang : Character;
-- A character indicating the language raising the exception.
-- Set to "A" for exceptions defined by an Ada program.
-- Set to "C" for imported C++ exceptions.
Name_Length : Natural;
-- Length of fully expanded name of exception
Full_Name : System.Address;
-- Fully expanded name of exception, null terminated
-- You can use To_Ptr to convert this to a string.
HTable_Ptr : Exception_Data_Ptr;
-- Hash table pointer used to link entries together in the hash table
-- built (by Register_Exception in s-exctab.adb) for converting between
-- identities and names.
Foreign_Data : Address;
-- Data for imported exceptions. Not used in the Ada case. This
-- represents the address of the RTTI for the C++ case.
Raise_Hook : Raise_Action;
-- This field can be used to place a "hook" on an exception. If the
-- value is non-null, then it points to a procedure which is called
-- whenever the exception is raised. This call occurs immediately,
-- before any other actions taken by the raise (and in particular
-- before any unwinding of the stack occurs).
end record;
-- Definitions for standard predefined exceptions defined in Standard,
-- Why are the NULs necessary here, seems like they should not be
-- required, since Gigi is supposed to add a Nul to each name ???
Constraint_Error_Name : constant String := "CONSTRAINT_ERROR" & ASCII.NUL;
Program_Error_Name : constant String := "PROGRAM_ERROR" & ASCII.NUL;
Storage_Error_Name : constant String := "STORAGE_ERROR" & ASCII.NUL;
Tasking_Error_Name : constant String := "TASKING_ERROR" & ASCII.NUL;
Abort_Signal_Name : constant String := "_ABORT_SIGNAL" & ASCII.NUL;
Numeric_Error_Name : constant String := "NUMERIC_ERROR" & ASCII.NUL;
-- This is used only in the Ada 83 case, but it is not worth having a
-- separate version of s-stalib.ads for use in Ada 83 mode.
Constraint_Error_Def : aliased Exception_Data :=
(Not_Handled_By_Others => False,
Lang => 'A',
Name_Length => Constraint_Error_Name'Length,
Full_Name => Constraint_Error_Name'Address,
HTable_Ptr => null,
Foreign_Data => Null_Address,
Raise_Hook => null);
Numeric_Error_Def : aliased Exception_Data :=
(Not_Handled_By_Others => False,
Lang => 'A',
Name_Length => Numeric_Error_Name'Length,
Full_Name => Numeric_Error_Name'Address,
HTable_Ptr => null,
Foreign_Data => Null_Address,
Raise_Hook => null);
Program_Error_Def : aliased Exception_Data :=
(Not_Handled_By_Others => False,
Lang => 'A',
Name_Length => Program_Error_Name'Length,
Full_Name => Program_Error_Name'Address,
HTable_Ptr => null,
Foreign_Data => Null_Address,
Raise_Hook => null);
Storage_Error_Def : aliased Exception_Data :=
(Not_Handled_By_Others => False,
Lang => 'A',
Name_Length => Storage_Error_Name'Length,
Full_Name => Storage_Error_Name'Address,
HTable_Ptr => null,
Foreign_Data => Null_Address,
Raise_Hook => null);
Tasking_Error_Def : aliased Exception_Data :=
(Not_Handled_By_Others => False,
Lang => 'A',
Name_Length => Tasking_Error_Name'Length,
Full_Name => Tasking_Error_Name'Address,
HTable_Ptr => null,
Foreign_Data => Null_Address,
Raise_Hook => null);
Abort_Signal_Def : aliased Exception_Data :=
(Not_Handled_By_Others => True,
Lang => 'A',
Name_Length => Abort_Signal_Name'Length,
Full_Name => Abort_Signal_Name'Address,
HTable_Ptr => null,
Foreign_Data => Null_Address,
Raise_Hook => null);
pragma Export (C, Constraint_Error_Def, "constraint_error");
pragma Export (C, Numeric_Error_Def, "numeric_error");
pragma Export (C, Program_Error_Def, "program_error");
pragma Export (C, Storage_Error_Def, "storage_error");
pragma Export (C, Tasking_Error_Def, "tasking_error");
pragma Export (C, Abort_Signal_Def, "_abort_signal");
-- Binder variables
main_priority : Integer
with Export, External_Name => "__gl_main_priority";
time_slice_val : Integer
with Export, External_Name => "__gl_time_slice_val";
wc_encoding : Integer
with Export, External_Name => "__gl_wc_encoding";
locking_policy : Integer
with Export, External_Name => "__gl_locking_policy";
queuing_policy : Integer
with Export, External_Name => "__gl_queuing_policy";
task_dispatching_policy : Integer
with Export, External_Name => "__gl_task_dispatching_policy";
priority_specific_dispatching : Integer
with Export, External_Name => "__gl_priority_specific_dispatching";
num_specific_dispatching : Integer
with Export, External_Name => "__gl_num_specific_dispatching";
main_cpu : Integer
with Export, External_Name => "__gl_main_cpu";
interrupt_states : Integer
with Export, External_Name => "__gl_interrupt_states";
num_interrupt_states : Integer
with Export, External_Name => "__gl_num_interrupt_states";
unreserve_all_interrupts : Integer
with Export, External_Name => "__gl_unreserve_all_interrupts";
detect_blocking : Integer
with Export, External_Name => "__gl_detect_blocking";
default_stack_size : Integer
with Export, External_Name => "__gl_default_stack_size";
procedure GNAT_Initialize is null
with Export, External_Name => "__gnat_initialize";
procedure GNAT_Finalize is null
with Export, External_Name => "__gnat_finalize";
procedure GNAT_Runtime_Initialize is null
with Export, External_Name => "__gnat_runtime_initialize";
procedure GNAT_Runtime_Finalize is null
with Export, External_Name => "__gnat_runtime_finalize";
procedure Adafinal is null;
end System.Standard_Library;
|
with Ada
.Text_IO, Ada
.Integer_Text_IO, Ada.Numerics
.Discrete_Random, Ada
.Strings, Ada.Strings
.Fixed;
use Ada.Text_IO, Ada.Integer_Text_IO;
package body DataOperations is
subtype Random_Range is Positive range 1 .. 1;
package Random_Integer is new Ada.Numerics.Discrete_Random (Random_Range);
G : Random_Integer.Generator;
Random_Item : Random_Range;
procedure Input (a : out Integer) is
begin
Put_Line ("Input value:");
Ada.Integer_Text_IO.Get (Item => a);
end Input;
procedure Generate (a : out Integer) is
begin
Random_Integer.Reset (G);
Random_Item := Random_Integer.Random (G);
a := Random_Item;
end Generate;
procedure FillWithOne (a : out Integer) is
begin
a := 1;
end FillWithOne;
procedure Input (A : out Vector) is
begin
Put_Line ("Input vector:");
for i in 1 .. N loop
Get (Item => A (i));
end loop;
end Input;
procedure Generate (A : out Vector) is
begin
Random_Integer.Reset (G);
for i in 1 .. N loop
Random_Item := Random_Integer.Random (G);
A (i) := Random_Item;
end loop;
end Generate;
procedure FillWithOne (A : out Vector) is
begin
for i in 1 .. N loop
A (i) := 1;
end loop;
end FillWithOne;
procedure Input (MA : out Matrix) is
begin
Put_Line ("Enter matrix values:");
for i in 1 .. N loop
for j in 1 .. N loop
Ada.Integer_Text_IO.Get (Item => MA (i) (j));
end loop;
end loop;
end Input;
procedure Generate (MA : out Matrix) is
begin
Random_Integer.Reset (G);
for i in 1 .. N loop
for j in 1 .. N loop
Random_Item := Random_Integer.Random (G);
MA (i) (j) := Random_Item;
end loop;
end loop;
end Generate;
procedure FillWithOne (MA : out Matrix) is
begin
for i in 1 .. N loop
for j in 1 .. N loop
MA (i) (j) := 1;
end loop;
end loop;
end FillWithOne;
procedure Output (V : in Vector) is
begin
New_Line;
for i in 1 .. N loop
Put (Item => V (i), Width => 10);
end loop;
New_Line;
end Output;
procedure Output (MA : in Matrix) is
begin
New_Line;
for i in 1 .. N loop
for j in 1 .. N loop
Put (Item => MA (i) (j), Width => 10);
end loop;
New_Line;
end loop;
New_Line;
end Output;
function Multiple
(A : in Integer;
MB : in Matrix;
From : Integer;
To : Integer) return Matrix
is
MR : Matrix;
begin
for i in From .. To loop
for j in 1 .. N loop
MR (i) (j) := MB (i) (j) * A;
end loop;
end loop;
return MR;
end Multiple;
function Multiple
(Left : in Matrix;
Right : in Matrix;
From : Integer;
To : Integer) return Matrix
is
MR : Matrix;
begin
for i in From .. To loop
for j in 1 .. N loop
MR (i) (j) := 0;
for K in Right'Range loop
MR (i) (j) := MR (i) (j) + Left (i) (K) * Right (K) (j);
end loop;
end loop;
end loop;
return MR;
end Multiple;
function Amount
(MA : in Matrix;
MB : in Matrix;
From : Integer;
To : Integer) return Matrix
is
MR : Matrix;
begin
for i in From .. To loop
for j in 1 .. N loop
MR (i) (j) := MA (i) (j) + MB (i) (j);
end loop;
end loop;
return MR;
end Amount;
end DataOperations;
|
--
-- The author disclaims copyright to this source code. In place of
-- a legal notice, here is a blessing:
--
-- May you do good and not evil.
-- May you find forgiveness for yourself and forgive others.
-- May you share freely, not taking more than you give.
--
with Ada.Text_IO;
with Ada.Directories;
with Setup;
with Auxiliary;
package body Generate_Ada is
procedure Open_Template
(Context : in out Context_Type;
File_Name : in out Ada.Strings.Unbounded.Unbounded_String;
User_Template : in String;
Error_Count : in out Integer)
is
use Ada.Strings.Unbounded;
use Ada.Text_IO;
Default_Template : String renames Setup.Default_Template_Ada;
Template_Name : Unbounded_String;
begin
Ada.Text_IO.Put_Line ("### AOT 1");
-- First, see if user specified a template filename on the command line.
if User_Template /= "" then
-- Eksisterer den angivede template fil
if not Ada.Directories.Exists (User_Template) then
Ada.Text_IO.Put_Line
(Ada.Text_IO.Standard_Error,
"Can not find the parser driver template file '" & User_Template & "'.");
Error_Count := Error_Count + 1;
Template_Name := Null_Unbounded_String;
return;
end if;
-- Can User_Template open.
begin
Open (Context.File_Template, In_File, User_Template);
exception
when others =>
-- No it could not open User_Template.
Put_Line
(Standard_Error,
"Can not open the template file '" & User_Template & "'.");
Error_Count := Error_Count + 1;
Template_Name := Null_Unbounded_String;
return;
end;
return; -- User template open with success.
end if;
-- No user template.
declare
-- use Ada.Strings.Fixed;
Point : constant Natural := Index (File_Name, ".");
Buf : Unbounded_String;
begin
if Point = 0 then
Buf := File_Name & ".lt";
-- Buf (Buf_0'Range) := Buf_0; Last := Buf_0'Last;
else
Buf := File_Name & ".lt";
-- Buf (Buf_X'Range) := Buf_X; Last := Buf_X'Last;
end if;
if Ada.Directories.Exists (To_String (Buf)) then
Ada.Text_IO.Put_Line ("### 3-1");
Template_Name := Buf;
elsif Ada.Directories.Exists (Default_Template) then
Ada.Text_IO.Put_Line ("### 3-2");
Template_Name := To_Unbounded_String (Default_Template);
else
Ada.Text_IO.Put_Line ("### 3-3");
-- Template_Name := Pathsearch (Lemp.Argv0, Templatename, 0);
end if;
end;
Ada.Text_IO.Put_Line ("### 3-4");
if Template_Name = Null_Unbounded_String then
Ada.Text_IO.Put_Line ("### 3-5");
Put_Line
(Standard_Error,
"Can not find then parser driver template file '" & To_String (Template_Name) & "'.");
Error_Count := Error_Count + 1;
return;
end if;
begin
Ada.Text_IO.Put_Line ("### 6-1");
Open (Context.File_Template,
In_File, To_String (Template_Name));
Ada.Text_IO.Put_Line ("### 6-2");
exception
when others =>
Ada.Text_IO.Put_Line ("### 3-6");
Put_Line
(Standard_Error,
"Can not open then template file '" & To_String (Template_Name) & ".");
Error_Count := Error_Count + 1;
return;
end;
-- Template_Name := New_String (Tem
end Open_Template;
procedure Generate_Spec
(Context : in out Context_Type;
Base_Name : in String;
Module : in String;
Prefix : in String;
First : in Integer;
Last : in Integer)
is
pragma Unreferenced (Context);
use Auxiliary, Ada.Text_IO;
-- Module : constant String := Auxiliary.To_Ada_Symbol (Base_Name);
File : File_Type;
begin
Put_Line ("GENERATE_SPEC");
Recreate (File, Out_File, Base_Name & ".ads");
Set_Output (File);
-- Prolog
Put_Line ("--");
Put_Line ("-- Generated by cherrylemon");
Put_Line ("--");
New_Line;
Put_Line ("package " & Module & " is");
Set_Output (File);
for I in First .. Last loop
declare
Symbol : constant String := Prefix; -- & Lime.Get_Token (I);
begin
Set_Col (File, 4); -- ..Put (File, " ");
Put (File, Symbol);
Set_Col (File, 20);
Put (File, " : constant Token_Type := ");
Put (File, Integer'Image (I));
Put (File, ";");
New_Line (File);
end;
end loop;
-- Epilog
Put_Line (File, "end " & Module & ";");
Close (File);
Set_Output (Standard_Output);
end Generate_Spec;
end Generate_Ada;
|
-- Copyright (c) 2019 Maxim Reznik <reznikmm@gmail.com>
--
-- SPDX-License-Identifier: MIT
-- License-Filename: LICENSE
-------------------------------------------------------------
with Ada.Calendar;
with Ada.Text_IO;
with League.String_Vectors;
with Slim.Messages.cont;
-- with Slim.Players.Displays;
package body Slim.Players.Play_Radio_Visiters is
----------
-- DSCO --
----------
overriding procedure DSCO
(Self : in out Visiter;
Message : not null access Slim.Messages.DSCO.DSCO_Message)
is
pragma Unreferenced (Message);
use type Ada.Calendar.Time;
Player : Players.Player renames Self.Player.all;
begin
-- got disconnection on the data channel
Player.State := (Idle, Ada.Calendar.Clock - 60.0, Player.First_Menu);
end DSCO;
----------
-- META --
----------
overriding procedure META
(Self : in out Visiter;
Message : not null access Slim.Messages.META.META_Message)
is
Player : Players.Player renames Self.Player.all;
Text : League.Strings.Universal_String := Message.Value;
Prefix : constant Wide_Wide_String := "StreamTitle='";
Suffix : constant Wide_Wide_String := "';";
begin
if Text.Starts_With (Prefix) then
Text := Text.Tail_From (Prefix'Length + 1);
end if;
if Text.Ends_With (Suffix) then
Text := Text.Head_To (Text.Length - Suffix'Length);
end if;
Player.State.Play_State.Current_Song := Text;
Slim.Players.Common_Play_Visiters.Update_Display (Player);
end META;
----------
-- RESP --
----------
overriding procedure RESP
(Self : in out Visiter;
Message : not null access Slim.Messages.RESP.RESP_Message)
is
List : constant League.String_Vectors.Universal_String_Vector :=
Message.Headers;
Player : Players.Player renames Self.Player.all;
Line : League.Strings.Universal_String;
Metaint_Header : constant Wide_Wide_String := "icy-metaint:";
Metaint : Natural := 0;
Cont : Slim.Messages.cont.Cont_Message;
begin
for J in 1 .. List.Length loop
Line := List.Element (J);
if Line.Starts_With (Metaint_Header) then
Line := Line.Tail_From (Metaint_Header'Length + 1);
begin
Metaint :=
Natural'Wide_Wide_Value (Line.To_Wide_Wide_String);
exception
when Constraint_Error =>
null;
end;
exit;
end if;
end loop;
Cont.Set_Metaint (Metaint);
Write_Message (Player.Socket, Cont);
end RESP;
----------
-- STAT --
----------
overriding procedure STAT
(Self : in out Visiter;
Message : not null access Slim.Messages.STAT.STAT_Message)
is
Player : Players.Player renames Self.Player.all;
begin
Player.WiFi := Message.WiFi_Level;
if Message.Event (1 .. 3) /= "STM" then
return;
elsif not Player.State.Play_State.Current_Song.Is_Empty then
null;
elsif Message.Event = "STMc" then
Player.State.Play_State.Current_Song.Clear;
Player.State.Play_State.Current_Song.Append ("Connecting...");
elsif Message.Event = "STMe" then
Player.State.Play_State.Current_Song.Clear;
Player.State.Play_State.Current_Song.Append ("Connected");
end if;
Slim.Players.Common_Play_Visiters.Update_Display (Player);
if Message.Event /= "STMt" then
Ada.Text_IO.Put_Line (Message.Event);
end if;
end STAT;
end Slim.Players.Play_Radio_Visiters;
|
--
-- This package provides a generic handler for a "parsed" type, that is,
-- a type that has a function "Parse" to map a string to a value.
--
generic
type Value_Type is private;
with function Parse (Item : String) return Value_Type is <>;
package Line_Parsers.Receivers.Parsed_Receivers is
type Receiver_Type is new Abstract_Parameter_Handler with private;
function Is_Set (Handler : Receiver_Type) return Boolean;
procedure Receive (Handler : in out Receiver_Type;
Name : String;
Value : String;
Position : Natural);
function Reusable (Handler : Receiver_Type) return Boolean;
function Get (Handler : Receiver_Type) return Value_Type
with Pre => Handler.Is_Set;
private
type Receiver_Type is new Abstract_Parameter_Handler with
record
Value : Value_Type;
Set : Boolean := False;
end record;
function Get (Handler : Receiver_Type) return Value_Type
is (Handler.Value);
function Reusable (Handler : Receiver_Type) return Boolean
is (False);
function Is_Set (Handler : Receiver_Type) return Boolean
is (Handler.Set);
end Line_Parsers.Receivers.Parsed_Receivers;
|
pragma Ada_2012;
with Ada.Strings.Fixed;
with Protypo.Api.Engine_Values.Array_Wrappers;
with Protypo.Api.Field_Names;
with Protypo.Api.Engine_Values.Constant_Wrappers;
pragma Warnings (Off, "no entities of ""Ada.Text_IO"" are referenced");
with Ada.Text_IO; use Ada.Text_IO;
package body Protypo.Api.Engine_Values.Table_Wrappers is
type Field_Name is
(
Rows,
Titles,
N_Rows,
N_Columns
);
package My_Fields is
new Field_Names (Field_Enumerator => Field_Name,
Prefix => "");
package Row_Wrappers is
new Array_Wrappers (Element_Type => Engine_Value,
Array_Type => Engine_Value_Vectors.Vector,
Create => Identity);
function Force_Handler (Item : Engine_Value) return Handler_Value
is (case Item.Class is
when Handler_Classes =>
Item,
when Int =>
Constant_Wrappers.To_Handler_Value(Get_Integer(Item)),
when Real =>
Constant_Wrappers.To_Handler_Value (Get_Float (Item)),
when Text =>
Constant_Wrappers.To_Handler_Value (Get_String (Item)),
when Void | Iterator =>
raise Constraint_Error);
--------------------
-- Default_Titles --
--------------------
function Default_Titles (N_Columns : Positive) return Title_Array
is
Result : constant Title_Array (1 .. N_Columns) :=
(others => Null_Unbounded_String);
begin
return Result;
end Default_Titles;
--------------------
-- Default_Titles --
--------------------
function Default_Titles (Labels : Label_Array) return Title_Array
is
Result : Title_Array (Labels'Range);
begin
for k in Labels'Range loop
Result (K) := Unbounded_String (Labels (K));
end loop;
return Result;
end Default_Titles;
--------------------
-- Default_Labels --
--------------------
function Default_Labels (N_Columns : Positive) return Label_Array
is
use Ada.Strings;
use Ada.Strings.Fixed;
Result : Label_Array (1 .. N_Columns);
begin
for I in Result'Range loop
Result (I) := To_Unbounded_String ("C" & Trim (I'Image, Both));
end loop;
return Result;
end Default_Labels;
------------
-- Create --
------------
function Create (Titles : Title_Array)
return Engine_Value_Vectors.Vector_Handler_Access
is
Result : constant Engine_Value_Vectors.Vector_Handler_Access :=
new Engine_Value_Vectors.Vector_Handler;
begin
for K in Titles'Range loop
Result.Vector.Append (Create (To_String (Titles (K))));
end loop;
return Result;
end Create;
--------------
-- Make_Map --
--------------
function Make_Map (Labels : Label_Array) return Label_Maps.Map
is
Result : Label_Maps.Map;
begin
for K in Labels'Range loop
if Result.Contains (To_Id (Labels (K))) then
raise Run_Time_Error
with "Duplicated column label '" & To_String (Labels (K)) & "'";
end if;
-- Put_Line ("@@@ inserting [" & To_String (Labels (K)) & "]");
Result.Insert (Key => To_Id (Labels (K)),
New_Item => K - Labels'First + 1);
end loop;
return Result;
end Make_Map;
--------------
-- Make_Row --
--------------
function Make_Row (Data : Engine_Value_Array;
Labels : Label_Maps.Map) return Row_Wrapper_Access
is
Result : constant Row_Wrapper_Access :=
new Row_Wrapper'(Engine_Value_Vectors.Vector_Handler with
Label_To_Column => Labels);
begin
for Item of Data loop
Result.Vector.Append (item);
end loop;
return Result;
end Make_Row;
------------
-- Append --
------------
procedure Append (Table : in out Table_Wrapper; Row : Engine_Value_Array) is
X : Row_Wrapper_Access;
begin
if Row'Length /= Table.N_Columns then
raise Constraint_Error
with
"Trying to append a row with " &
Row'Length'Image & " columns to a table with " &
Table.N_Rows'Image & " columns";
end if;
X := Make_Row (Row, Make_Map (Table.Labels));
Table.Rows.Vector.Append (Create (Ambivalent_Interface_Access (X)));
end Append;
---------
-- Get --
---------
function Get
(X : Table_Wrapper; Index : Engine_Value_Array) return Handler_Value
is
begin
if not (Index'Length = 1
and then Index (Index'First).Class = Int
and then Get_Integer (Index (Index'First)) > 0
and then Get_Integer (Index (Index'First)) <= X.N_Rows)
then
raise Constraint_Error with "Bad index for table";
end if;
return X.Rows.Vector.Ref.all (Get_Integer (Index (Index'First)));
end Get;
---------
-- Get --
---------
function Get (X : Table_Wrapper; Field : ID) return Handler_Value is
begin
case My_Fields.To_Field (Field) is
when Rows =>
return Create (Ambivalent_Interface_Access (X.Rows));
when Titles =>
return Create (Ambivalent_Interface_Access (X.Titles));
when N_Rows =>
return Create (Integer (X.Rows.Vector.Length));
when N_Columns =>
return Create (X.N_Columns);
end case;
end Get;
--------------
-- Is_Field --
--------------
function Is_Field (X : Table_Wrapper; Field : Id) return Boolean
is (My_Fields.Is_Field (Field));
---------
-- Get --
---------
overriding function Get (X : Row_Wrapper;
Field : ID)
return Handler_Value
is
begin
-- Put_Line ("@@@ proviamo [" & String (field) & "]");
if not X.Label_To_Column.Contains (Field) then
-- Put_Line ("@@@ manca");
return Engine_Value_Vectors.Vector_Handler (X).Get (Field);
else
-- Put_Line ("@@@ trovato");
return Force_Handler (X.Vector.Element (X.Label_To_Column (Field)));
end if;
end Get;
---------
-- Get --
---------
overriding function Get (X : Row_Wrapper;
Index : Engine_Value_Array)
return Handler_Value
is
begin
if Index'Length /= 1 then
raise Run_Time_Error with "too many indexes";
end if;
case Index (Index'First).Class is
when Int =>
return Engine_Value_Vectors.Vector_Handler (X).Get (Index);
when Text =>
declare
S : constant String := Get_String (Index (Index'First));
begin
if Is_Valid_Id (S) and then X.Label_To_Column.Contains (Id (S)) then
return Force_Handler (X.Vector.Element (X.Label_To_Column (ID (S))));
else
raise Run_Time_Error
with "Row ID-indexing with bad/unknown column name"
& "'" & S & "'";
end if;
end;
when others =>
raise Run_Time_Error
with "Bad index type: " & Index (Index'First).Class'Image;
end case;
end Get;
--------------
-- Is_Field --
--------------
overriding function Is_Field (X : Row_Wrapper; Field : Id) return Boolean
is (X.Label_To_Column.Contains (Field) or else
Engine_Value_Vectors.Vector_Handler (X).Is_Field (Field));
package body Enumerated_Rows is
First : constant Integer := Field_Type'Pos (Field_Type'First);
function Make_Table (Titles : Enumerated_Title_Array) return Table_Wrapper_Access
is
T : Title_Array (1 .. N_Fields);
L : Label_Array (1 .. N_Fields);
begin
for Field in Field_Type loop
T (Field_Type'Pos (Field)-First + T'First) := Titles (Field);
L (Field_Type'Pos (Field)-First + L'First) := To_Unbounded_String (Field'Image);
end loop;
return Make_Table (T, L);
end Make_Table;
procedure Append (Table : in out Table_Wrapper;
Item : Aggregate_Type)
is
Row : Engine_Value_Array (1 .. N_Fields);
begin
for Field in Field_Type loop
Row (Field_Type'Pos (Field)-First + Row'First) := Item (Field);
end loop;
Table.Append (Row);
end Append;
------------------
-- Append_Array --
------------------
procedure Append_Array (Table : in out Table_Wrapper;
Item : Generic_Aggregate_Array)
is
begin
for Element of Item loop
Append(Table, Convert(Element));
end loop;
end Append_Array;
--------------------
-- Default_Titles --
--------------------
function Default_Titles return Enumerated_Title_Array
is
Result : Enumerated_Title_Array;
begin
for field in Field_Type loop
Result (Field) := To_Unbounded_String (Field'Image);
end loop;
return Result;
end Default_Titles;
end Enumerated_Rows;
end Protypo.Api.Engine_Values.Table_Wrappers;
|
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;
|
with Ada.Calendar;
with Ada.Characters.Latin_1;
with Ada.Command_Line;
with Ada.Directories;
with Ada.Streams.Stream_IO;
with Ada.Text_IO.Text_Streams;
with Web.HTML;
with Web.Lock_Files;
with Web.Producers;
with Web.RSS;
pragma Unreferenced (Web.RSS);
procedure test_web is
use type Ada.Calendar.Time;
Verbose : Boolean := False;
HT : Character renames Ada.Characters.Latin_1.HT;
Template_Source : constant String := "template.html";
Template_Cache : constant String :=
Ada.Directories.Compose (
Ada.Directories.Containing_Directory (Ada.Command_Line.Command_Name),
"template-cache.dat");
Lock_Name : constant String :=
Ada.Directories.Compose (
Ada.Directories.Containing_Directory (Ada.Command_Line.Command_Name),
"lockfile");
Output_Name : constant String :=
Ada.Directories.Compose (
Ada.Directories.Containing_Directory (Ada.Command_Line.Command_Name),
"out");
procedure Check_Line (F : in Ada.Text_IO.File_Type; S : in String) is
Line : constant String := Ada.Text_IO.Get_Line (F);
begin
if Verbose then
Ada.Text_IO.Put_Line (Line);
end if;
pragma Assert (Line = S);
end Check_Line;
procedure Try_Produce (By_Iterator : Boolean) is
Lock : Web.Lock_Files.Lock_Type := Web.Lock_Files.Lock (Lock_Name);
Output_File : Ada.Text_IO.File_Type;
Output : Ada.Text_IO.Text_Streams.Stream_Access;
Template_Source_File : Ada.Streams.Stream_IO.File_Type;
Template_Cache_File : Ada.Streams.Stream_IO.File_Type;
Is_Cache : Boolean;
begin
Ada.Text_IO.Create (Output_File, Name => Output_Name);
Output := Ada.Text_IO.Text_Streams.Stream (Output_File);
Web.Header_Content_Type (Output, Web.Text_HTML);
Web.Header_Break (Output);
Ada.Streams.Stream_IO.Open (
Template_Source_File,
Ada.Streams.Stream_IO.In_File,
Name => Template_Source);
declare
procedure Handler (
Output : not null access Ada.Streams.Root_Stream_Type'Class;
Tag : in String;
Contents : in Web.Producers.Template) is
begin
if Tag = "title" then
Web.HTML.Write_In_HTML (Output, Web.HTML.HTML, "<<sample>>");
elsif Tag = "generator" then
Web.HTML.Write_Begin_Attribute (Output, "content");
if By_Iterator then
Web.HTML.Write_In_Attribute (Output, Web.HTML.HTML, "by iterator");
else -- by closure
Web.HTML.Write_In_Attribute (Output, Web.HTML.HTML, "by closure");
end if;
Web.HTML.Write_End_Attribute (Output);
elsif Tag = "href" then
String'Write (Output, "href=""");
Web.HTML.Write_In_Attribute (
Output,
Web.HTML.HTML,
"http://www.google.co.jp/search?q=1%2B1");
Character'Write (Output, '"');
elsif Tag = "is_cache" then
if Is_Cache then
if By_Iterator then
for I in Web.Producers.Produce (Output, Contents, "true") loop
raise Web.Producers.Data_Error;
end loop;
else -- by closure
Web.Producers.Produce (Output, Contents, "true");
end if;
else
if By_Iterator then
for I in Web.Producers.Produce (Output, Contents, "false") loop
raise Web.Producers.Data_Error;
end loop;
else -- by closure
Web.Producers.Produce (Output, Contents, "false");
end if;
end if;
else
raise Web.Producers.Data_Error;
end if;
end Handler;
Template : Web.Producers.Template := Web.Producers.Read (
Ada.Streams.Stream_IO.Stream (Template_Source_File),
Ada.Streams.Stream_Element_Count (
Ada.Streams.Stream_IO.Size (Template_Source_File)),
Parsing => False); -- suppress parsing now
begin
if Ada.Directories.Exists (Template_Cache)
and then Ada.Directories.Modification_Time (Template_Cache) >
Ada.Directories.Modification_Time (Template_Source)
then
Is_Cache := True;
-- read parsed-structure from cache file
Ada.Streams.Stream_IO.Open (Template_Cache_File, Ada.Streams.Stream_IO.In_File,
Name => Template_Cache);
Web.Producers.Read_Parsed_Information (
Ada.Streams.Stream_IO.Stream (Template_Cache_File),
Template);
Ada.Streams.Stream_IO.Close (Template_Cache_File);
else
Is_Cache := False;
Web.Producers.Parse (Template);
-- save parsed-structure to cache file
Ada.Streams.Stream_IO.Create (
Template_Cache_File,
Ada.Streams.Stream_IO.Out_File,
Name => Template_Cache);
Web.Producers.Write_Parsed_Information (
Ada.Streams.Stream_IO.Stream (Template_Cache_File),
Template);
Ada.Streams.Stream_IO.Close (Template_Cache_File);
end if;
if By_Iterator then
for I in Web.Producers.Produce (Output, Template) loop
Handler (Output, Web.Producers.Tag (I), Web.Producers.Contents (I));
end loop;
else -- by closure
Web.Producers.Produce (Output, Template, Handler => Handler'Access);
end if;
end;
Ada.Streams.Stream_IO.Close (Template_Source_File);
Ada.Text_IO.Close (Output_File);
-- check the content
Ada.Text_IO.Open (Output_File, Ada.Text_IO.In_File, Name => Output_Name);
Check_Line (Output_File, "content-type: text/html");
Check_Line (Output_File, "");
Check_Line (Output_File, "<html>");
Check_Line (Output_File, "<head>");
Check_Line (Output_File, HT & "<title><<sample>></title>");
if By_Iterator then
Check_Line (
Output_File,
HT & "<meta name=""GENERATOR"" content=""by iterator"" />");
else
Check_Line (
Output_File,
HT & "<meta name=""GENERATOR"" content=""by closure"" />");
end if;
Check_Line (Output_File, "</head>");
Check_Line (Output_File, "<body>");
Check_Line (
Output_File,
HT & "<a href=""http://www.google.co.jp/search?q=1%2B1"" >1 + 1 = ?"
& "</a><br/>");
if Is_Cache then
Check_Line (Output_File, HT & "this is cache.");
else
Check_Line (Output_File, HT & "this is parsed template.");
end if;
Check_Line (Output_File, "</body>");
Check_Line (Output_File, "</html>");
pragma Assert (Ada.Text_IO.End_Of_File (Output_File));
Ada.Text_IO.Close (Output_File);
end Try_Produce;
begin
for I in 1 .. Ada.Command_Line.Argument_Count loop
if Ada.Command_Line.Argument (I) = "-v" then
Verbose := True;
end if;
end loop;
for By_Iterator in Boolean loop
for Cached in Boolean loop
if not Cached and then Ada.Directories.Exists (Template_Cache) then
Ada.Directories.Delete_File (Template_Cache);
end if;
Try_Produce (By_Iterator);
end loop;
end loop;
pragma Assert (not Ada.Directories.Exists (Lock_Name));
-- finish
Ada.Text_IO.Put_Line (Ada.Text_IO.Standard_Error.all, "ok");
end test_web;
|
-- Copyright 2017-2021 Jeff Foley. All rights reserved.
-- Use of this source code is governed by Apache 2 LICENSE that can be found in the LICENSE file.
local json = require("json")
name = "FullHunt"
type = "api"
function start()
set_rate_limit(1)
end
function vertical(ctx, domain)
local resp, err = request(ctx, {['url']=build_url(domain)})
if (err ~= nil and err ~= "") then
log(ctx, "vertical request to service failed: " .. err)
return
end
local j = json.decode(resp)
if (j == nil or j.hosts == nil or #(j.hosts) == 0) then
return
end
for _, h in pairs(j.hosts) do
if (h.domain ~= nil and h.domain == domain and h.host ~= nil and h.host ~= "") then
new_name(ctx, h.host)
if (h.ip_address ~= nil and h.ip_address ~= "") then
new_addr(ctx, h.ip_address, domain)
end
if (h.dns ~= nil) then
if (h.dns.cname ~= nil and #(h.dns.cname) > 0) then
names_from_table(ctx, domain, h.dns.cname)
end
if (h.dns.ptr ~= nil and #(h.dns.ptr) > 0) then
names_from_table(ctx, domain, h.dns.ptr)
end
if (h.dns.a ~= nil and #(h.dns.a) > 0) then
addrs_from_table(ctx, domain, h.dns.a)
end
if (h.dns.aaaa ~= nil and #(h.dns.aaaa) > 0) then
addrs_from_table(ctx, domain, h.dns.aaaa)
end
end
end
end
end
function names_from_table(ctx, domain, t)
if t == nil then
return
end
for _, name in pairs(t) do
if in_scope(ctx, name) then
new_name(ctx, name)
end
end
end
function addrs_from_table(ctx, domain, t)
if t == nil then
return
end
for _, addr in pairs(t) do
new_addr(ctx, addr, domain)
end
end
function build_url(domain)
return "https://fullhunt.io/api/v1/domain/" .. domain .. "/details"
end
|
type Price is delta 0.01 digits 3 range 0.0..1.0;
function Scale (Value : Price) return Price is
X : constant array (1..19) of Price :=
( 0.06, 0.11, 0.16, 0.21, 0.26, 0.31, 0.36, 0.41, 0.46, 0.51,
0.56, 0.61, 0.66, 0.71, 0.76, 0.81, 0.86, 0.91, 0.96
);
Y : constant array (1..20) of Price :=
( 0.10, 0.18, 0.26, 0.32, 0.38, 0.44, 0.50, 0.54, 0.58, 0.62,
0.66, 0.70, 0.74, 0.78, 0.82, 0.86, 0.90, 0.94, 0.98, 1.0
);
Low : Natural := X'First;
High : Natural := X'Last;
Middle : Natural;
begin
loop
Middle := (Low + High) / 2;
if Value = X (Middle) then
return Y (Middle + 1);
elsif Value < X (Middle) then
if Low = Middle then
return Y (Low);
end if;
High := Middle - 1;
else
if High = Middle then
return Y (High + 1);
end if;
Low := Middle + 1;
end if;
end loop;
end Scale;
|
with ZMQ.Sockets;
with ZMQ.Contexts;
with ZMQ.Messages;
with Ada.Text_IO; use Ada.Text_IO;
procedure ZMQ.examples.Client is
ctx : ZMQ.Contexts.Context;
s : ZMQ.Sockets.Socket;
begin
-- Initialise 0MQ context, requesting a single application thread
-- and a single I/O thread
ctx.Initialize (1);
-- Create a ZMQ_REP socket to receive requests and send replies
s.Initialize (ctx, Sockets.REQ);
-- Bind to the TCP transport and port 5555 on the 'lo' interface
s.Connect ("tcp://localhost:5555");
for i in 1 .. 10 loop
declare
query_string : constant String := "SELECT * FROM mytable";
query : ZMQ.Messages.Message;
begin
query.Initialize (query_string & "(" & i'Img & ");");
s.Send (query);
query.Finalize;
end;
declare
resultset : ZMQ.Messages.Message;
begin
resultset.Initialize;
s.recv (resultset);
Put_Line ('"' & resultset.getData & '"');
resultset.Finalize;
end;
end loop;
end ZMQ.Examples.Client;
|
with Pig, Ada.Text_IO;
procedure Play_Pig is
use Pig;
type Hand is new Actor with record
Name: String(1 .. 5);
end record;
function Roll_More(A: Hand; Self, Opponent: Player'Class) return Boolean;
function Roll_More(A: Hand; Self, Opponent: Player'Class) return Boolean is
Ch: Character := ' ';
use Ada.Text_IO;
begin
Put(A.Name & " you:" & Natural'Image(Self.Score) &
" (opponent:" & Natural'Image(Opponent.Score) &
") this round:" & Natural'Image(Self.All_Recent) &
" this roll:" & Natural'Image(Self.Recent) &
"; add to score(+)?");
Get(Ch);
return Ch /= '+';
end Roll_More;
A1: Hand := (Name => "Alice");
A2: Hand := (Name => "Bob ");
Alice: Boolean;
begin
Play(A1, A2, Alice);
Ada.Text_IO.Put_Line("Winner = " & (if Alice then "Alice!" else "Bob!"));
end Play_Pig;
|
with
openGL.Visual,
openGL.Terrain,
openGL.Demo,
openGL.Light;
procedure launch_large_Terrain_Demo
--
-- Exercise the culler with a large terrain grid.
--
is
use openGL,
openGL.Math,
openGL.linear_Algebra_3d;
begin
Demo.print_Usage;
Demo.define ("openGL 'Large Terrain' Demo");
-- Setup the camera.
--
Demo.Camera.Position_is ((0.0, 100.0, 500.0),
y_Rotation_from (to_Radians (0.0)));
-- Set the lights initial position to far behind and far to the left.
--
declare
use openGL.Light;
the_Light : openGL.Light.item := Demo.Renderer.new_Light;
begin
the_Light.Site_is ((0.0, 1000.0, 0.0));
Demo.Renderer.set (the_Light);
end;
declare
Heights : constant asset_Name := to_Asset ("assets/kidwelly-terrain-510x510.png");
Texture : constant asset_Name := to_Asset ("assets/kidwelly-terrain-texture-255x255.png");
Terrain : constant openGL.Visual.Grid := openGL.Terrain.new_Terrain (heights_File => Heights,
texture_File => Texture,
Scale => (1.0, 25.0, 1.0));
Count : constant Positive := Terrain'Length (1)
* Terrain'Length (2);
Last : Natural := 0;
Sprites : openGL.Visual.views (1 .. Count);
begin
for Row in Terrain'Range (1)
loop
for Col in Terrain'Range (2)
loop
Last := Last + 1;
Sprites (Last) := Terrain (Row, Col);
end loop;
end loop;
-- Main loop.
--
while not Demo.Done
loop
Demo.Dolly.evolve;
Demo.Done := Demo.Dolly.quit_Requested;
Demo.Camera.render (Sprites (1 .. Last));
while not Demo.Camera.cull_Completed
loop
delay Duration'Small;
end loop;
Demo.Renderer.render;
Demo.FPS_Counter.increment; -- Frames per second display.
end loop;
end;
Demo.destroy;
end launch_large_Terrain_Demo;
|
-- { dg-do run { target i?86-*-* x86_64-*-* alpha*-*-* ia64-*-* } }
with Unchecked_Conversion;
procedure Unchecked_Convert5b is
subtype c_1 is string(1..1);
function int2c1 is -- { dg-warning "different sizes" }
new unchecked_conversion (source => integer, target => c_1);
c1 : c_1;
begin
c1 := int2c1(16#12#);
if c1 (1) /= ASCII.DC2 then
raise Program_Error;
end if;
end;
|
--//////////////////////////////////////////////////////////
-- SFML - Simple and Fast Multimedia Library
-- Copyright (C) 2007-2015 Laurent Gomila (laurent@sfml-dev.org)
-- 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 Sf.Window.Keyboard;
with Sf.Window.Mouse;
with Sf.Window.Joystick;
with Sf.Window.Sensor;
package Sf.Window.Event is
--//////////////////////////////////////////////////////////
--//////////////////////////////////////////////////////////
--/ @brief Definition of all the event types
--/
--//////////////////////////////////////////////////////////
--/< The window requested to be closed (no data)
--/< The window was resized (data in event.size)
--/< The window lost the focus (no data)
--/< The window gained the focus (no data)
--/< A character was entered (data in event.text)
--/< A key was pressed (data in event.key)
--/< A key was released (data in event.key)
--/< The mouse wheel was scrolled (data in event.mouseWheel) (deprecated)
--/< The mouse wheel was scrolled (data in event.mouseWheelScroll)
--/< A mouse button was pressed (data in event.mouseButton)
--/< A mouse button was released (data in event.mouseButton)
--/< The mouse cursor moved (data in event.mouseMove)
--/< The mouse cursor entered the area of the window (no data)
--/< The mouse cursor left the area of the window (no data)
--/< A joystick button was pressed (data in event.joystickButton)
--/< A joystick button was released (data in event.joystickButton)
--/< The joystick moved along an axis (data in event.joystickMove)
--/< A joystick was connected (data in event.joystickConnect)
--/< A joystick was disconnected (data in event.joystickConnect)
--/< A touch event began (data in event.touch)
--/< A touch moved (data in event.touch)
--/< A touch event ended (data in event.touch)
--/< A sensor value changed (data in event.sensor)
--/< Keep last -- the total number of event types
type sfEventType is
(sfEvtClosed,
sfEvtResized,
sfEvtLostFocus,
sfEvtGainedFocus,
sfEvtTextEntered,
sfEvtKeyPressed,
sfEvtKeyReleased,
sfEvtMouseWheelMoved,
sfEvtMouseWheelScrolled,
sfEvtMouseButtonPressed,
sfEvtMouseButtonReleased,
sfEvtMouseMoved,
sfEvtMouseEntered,
sfEvtMouseLeft,
sfEvtJoystickButtonPressed,
sfEvtJoystickButtonReleased,
sfEvtJoystickMoved,
sfEvtJoystickConnected,
sfEvtJoystickDisconnected,
sfEvtTouchBegan,
sfEvtTouchMoved,
sfEvtTouchEnded,
sfEvtSensorChanged,
sfEvtCount);
--//////////////////////////////////////////////////////////
--/ @brief Keyboard event parameters
--/
--//////////////////////////////////////////////////////////
type sfKeyEvent is record
eventType : aliased sfEventType;
code : aliased Sf.Window.Keyboard.sfKeyCode;
alt : aliased sfBool;
control : aliased sfBool;
shift : aliased sfBool;
system : aliased sfBool;
end record;
--//////////////////////////////////////////////////////////
--/ @brief Text event parameters
--/
--//////////////////////////////////////////////////////////
type sfTextEvent is record
eventType : aliased sfEventType;
unicode : aliased sfUint32;
end record;
--//////////////////////////////////////////////////////////
--/ @brief Mouse move event parameters
--/
--//////////////////////////////////////////////////////////
type sfMouseMoveEvent is record
eventType : aliased sfEventType;
x : aliased sfInt32;
y : aliased sfInt32;
end record;
--//////////////////////////////////////////////////////////
--/ @brief Mouse buttons events parameters
--/
--//////////////////////////////////////////////////////////
type sfMouseButtonEvent is record
eventType : aliased sfEventType;
button : aliased Sf.Window.Mouse.sfMouseButton;
x : aliased sfInt32;
y : aliased sfInt32;
end record;
--//////////////////////////////////////////////////////////
--/ @brief Mouse wheel events parameters
--/
--/ @deprecated
--/ Use sfMouseWheelScrollEvent instead.
--/
--//////////////////////////////////////////////////////////
type sfMouseWheelEvent is record
eventType : aliased sfEventType;
eventDelta : aliased sfInt32;
x : aliased sfInt32;
y : aliased sfInt32;
end record;
--//////////////////////////////////////////////////////////
--/ @brief Mouse wheel events parameters
--/
--//////////////////////////////////////////////////////////
type sfMouseWheelScrollEvent is record
eventType : aliased sfEventType;
wheel : aliased Sf.Window.Mouse.sfMouseWheel;
eventDelta : aliased float;
x : aliased sfInt32;
y : aliased sfInt32;
end record;
--//////////////////////////////////////////////////////////
--/ @brief Joystick axis move event parameters
--/
--//////////////////////////////////////////////////////////
type sfJoystickMoveEvent is record
eventType : aliased sfEventType;
joystickId : aliased sfUint32;
axis : aliased Sf.Window.Joystick.sfJoystickAxis;
position : aliased float;
end record;
--//////////////////////////////////////////////////////////
--/ @brief Joystick buttons events parameters
--/
--//////////////////////////////////////////////////////////
type sfJoystickButtonEvent is record
eventType : aliased sfEventType;
joystickId : aliased sfUint32;
button : aliased sfUint32;
end record;
--//////////////////////////////////////////////////////////
--/ @brief Joystick connection/disconnection event parameters
--/
--//////////////////////////////////////////////////////////
type sfJoystickConnectEvent is record
eventType : aliased sfEventType;
joystickId : aliased sfUint32;
end record;
--//////////////////////////////////////////////////////////
--/ @brief Size events parameters
--/
--//////////////////////////////////////////////////////////
type sfSizeEvent is record
eventType : aliased sfEventType;
width : aliased sfUint32;
height : aliased sfUint32;
end record;
--//////////////////////////////////////////////////////////
--/ @brief Touch events parameters
--/
--//////////////////////////////////////////////////////////
type sfTouchEvent is record
eventType : aliased sfEventType;
finger : aliased sfUint32;
x : aliased sfInt32;
y : aliased sfInt32;
end record;
--//////////////////////////////////////////////////////////
--/ @brief Sensor event parameters
--/
--//////////////////////////////////////////////////////////
type sfSensorEvent is record
eventType : aliased sfEventType;
sensorType : aliased Sf.Window.Sensor.sfSensorType;
x : aliased float;
y : aliased float;
z : aliased float;
end record;
--//////////////////////////////////////////////////////////
--/ @brief sfEvent defines a system event and its parameters
--/
--//////////////////////////////////////////////////////////
--/< Type of the event
--/< Size event parameters
--/< Key event parameters
--/< Text event parameters
--/< Mouse move event parameters
--/< Mouse button event parameters
--/< Mouse wheel event parameters (deprecated)
--/< Mouse wheel event parameters
--/< Joystick move event parameters
--/< Joystick button event parameters
--/< Joystick (dis)connect event parameters
--/< Touch events parameters
--/< Sensor event parameters
type sfEvent (discr : sfUint32 := 0) is record
case discr is
when 0 =>
eventType : aliased sfEventType;
when 1 =>
size : aliased sfSizeEvent;
when 2 =>
key : aliased sfKeyEvent;
when 3 =>
text : aliased sfTextEvent;
when 4 =>
mouseMove : aliased sfMouseMoveEvent;
when 5 =>
mouseButton : aliased sfMouseButtonEvent;
when 6 =>
mouseWheel : aliased sfMouseWheelEvent;
when 7 =>
mouseWheelScroll : aliased sfMouseWheelScrollEvent;
when 8 =>
joystickMove : aliased sfJoystickMoveEvent;
when 9 =>
joystickButton : aliased sfJoystickButtonEvent;
when 10 =>
joystickConnect : aliased sfJoystickConnectEvent;
when 11 =>
touch : aliased sfTouchEvent;
when others =>
sensor : aliased sfSensorEvent;
end case;
end record;
private
pragma Convention (C_Pass_By_Copy, sfSensorEvent);
pragma Convention (C_Pass_By_Copy, sfTouchEvent);
pragma Convention (C_Pass_By_Copy, sfSizeEvent);
pragma Convention (C_Pass_By_Copy, sfJoystickConnectEvent);
pragma Convention (C_Pass_By_Copy, sfJoystickButtonEvent);
pragma Convention (C_Pass_By_Copy, sfJoystickMoveEvent);
pragma Convention (C_Pass_By_Copy, sfMouseWheelScrollEvent);
pragma Convention (C_Pass_By_Copy, sfMouseWheelEvent);
pragma Convention (C_Pass_By_Copy, sfMouseButtonEvent);
pragma Convention (C_Pass_By_Copy, sfMouseMoveEvent);
pragma Convention (C_Pass_By_Copy, sfTextEvent);
pragma Convention (C_Pass_By_Copy, sfKeyEvent);
pragma Convention (C, sfEventType);
pragma Convention (C_Pass_By_Copy, sfEvent);
pragma Unchecked_Union (sfEvent);
end Sf.Window.Event;
|
pragma License (Unrestricted);
-- extended unit
with Ada.Iterator_Interfaces;
private with System;
package Ada.Bind_Time_Variables is
-- This is similar to Ada.Environment_Variables,
-- but reads bind-time variables set by gnatbind -Vkey=val.
pragma Preelaborate;
function Value (Name : String) return String;
function Value (Name : String; Default : String) return String;
function Exists (Name : String) return Boolean;
procedure Iterate (
Process : not null access procedure (Name, Value : String));
-- Iterators:
type Cursor is private;
pragma Preelaborable_Initialization (Cursor);
function Has_Element (Position : Cursor) return Boolean;
pragma Inline (Has_Element);
function Name (Position : Cursor) return String;
function Value (Position : Cursor) return String;
package Iterator_Interfaces is
new Ada.Iterator_Interfaces (Cursor, Has_Element);
function Iterate return Iterator_Interfaces.Forward_Iterator'Class;
private
type Cursor is new System.Address;
type Iterator is new Iterator_Interfaces.Forward_Iterator with null record;
overriding function First (Object : Iterator) return Cursor;
overriding function Next (Object : Iterator; Position : Cursor)
return Cursor;
end Ada.Bind_Time_Variables;
|
with Ada.Calendar.Formatting;
with Ada.Calendar.Time_Zones;
with Ada.Command_Line;
with Ada.Text_IO;
with Web;
procedure test_time is
use type Ada.Calendar.Time;
use type Ada.Calendar.Time_Zones.Time_Offset;
Verbose : Boolean := False;
S : constant String := Web.Image (Ada.Calendar.Clock);
begin
for I in 1 .. Ada.Command_Line.Argument_Count loop
if Ada.Command_Line.Argument (I) = "-v" then
Verbose := True;
end if;
end loop;
if Verbose then
Ada.Text_IO.Put_Line (S);
end if;
if S /= Web.Image (Web.Value (S)) then
raise Program_Error;
end if;
if Web.Value ("Thu, 21 Jul 2005 14:46:19 +0900")
/= Ada.Calendar.Formatting.Time_Of (2005, 7, 21, 14, 46, 19,
Time_Zone => 9 * 60)
then
raise Program_Error;
end if;
-- finish
Ada.Text_IO.Put_Line (Ada.Text_IO.Standard_Error.all, "ok");
end test_time;
|
pragma Ada_2012;
with Ada.Strings.Unbounded;
with Ada.Strings.Equal_Case_Insensitive;
with Ada.Text_IO; use Ada.Text_IO;
with Ada.Unchecked_Deallocation;
with Ada.Containers.Vectors;
with Ada.Containers.Ordered_Sets;
with EU_Projects.Nodes.Partners;
with EU_Projects.Nodes.Action_Nodes.WPs;
with EU_Projects.Nodes.Action_Nodes.Tasks;
with Project_Processor.Processors.Processor_Tables;
with EU_Projects.Times;
with Latex_Writer.Picture;
with EU_Projects.Nodes.Timed_Nodes.Deliverables;
with EU_Projects.Nodes.Timed_Nodes.Milestones;
with EU_Projects.Efforts;
package body Project_Processor.Processors.LaTeX is
use EU_Projects.Projects;
use EU_Projects.Nodes;
use EU_Projects.Nodes.Action_Nodes;
use EU_Projects.Nodes.Timed_Nodes;
use Latex_Writer.Picture;
use EU_Projects.Times;
use Ada.Strings.Unbounded;
Formatter : constant Time_Formatter :=
Create.Set_Option (To_Be_Decided_Image, "\TBD");
type Table_Style is (Light, Full);
subtype Deliverable_Type_Image_Value is String (1 .. 5);
Deliverable_Type_Image : constant
array (Deliverables.Deliverable_Type) of Deliverable_Type_Image_Value :=
(Deliverables.Report => "R ",
Deliverables.Demo => "DEM ",
Deliverables.Dissemination => "DEC ",
Deliverables.Other => "OTHER");
subtype Dissemination_Level_Image_Value is String (1 .. 2);
Dissemination_Level_Image : constant array (Deliverables.Dissemination_Level)
of Dissemination_Level_Image_Value :=
(Deliverables.Public => "PU",
Deliverables.Confidential => "CO",
Deliverables.Classified => "Cl");
-- The result of function 'Image associated to discrete types has
-- a space at the beginning. That space is quite annoying and needs
-- to be trimmed. This function is here so that everyone can use it
function Chop (X : String) return String
is (Ada.Strings.Fixed.Trim (X, Ada.Strings.Both));
function Image (X : Integer) return String
is (Chop (Integer'Image (X)));
type Tone is (Light, Medium, Dark);
function Gray (T : Natural) return String
is ("\cellcolor[gray]{0." & Image (T) & "}");
function Gray (T : Tone := Medium) return String
is (Gray ((case T is
when Light => 95,
when Medium => 90,
when Dark => 80)));
------------
-- Create --
------------
overriding function Create
(Params : not null access Processor_Parameter) return Processor_Type
is
function Get_Target (Key : String) return Target_Spec
is
begin
if not Params.Contains (Key) then
return Target_Spec'(Class => File,
Filename => Bless (Key & "s.tex"));
elsif Params.all (Key) = "%" then
return Target_Spec'(Class => None);
elsif Params.all (Key) = "-" then
return Target_Spec'(Class => Standard_Output);
else
return Target_Spec'(Class => File,
Filename => Bless (Params.all (Key)));
end if;
end Get_Target;
-------------------------
-- Extract_Gantt_Style --
-------------------------
function Extract_Gantt_Style return GANTT_Parameters
is
Result : GANTT_Parameters :=
GANTT_Parameters'(Font_Size => 11.0 * Pt,
Textwidth => 160.0 * Mm,
Pre_Label_Skip => 0.125,
Post_Label_Skip => 0.125,
Header_Skip => 0.2,
Tick_Length => 0.5,
Task_Indent => 1,
Show_Deliverables => False);
function Eq (X, Y : String) return Boolean
renames Ada.Strings.Equal_Case_Insensitive;
function To_Boolean (X : String) return Boolean
is (if Eq (X, "") or Eq (X, "y") or Eq (X, "t") or Eq (X, "yes") then
True
elsif Eq (X, "n") or Eq (X, "f") or Eq (X, "no") then
False
else
raise Constraint_Error);
begin
if Params.Contains ("show-deliverables") then
Result.Show_Deliverables := To_Boolean (Params.all ("show-deliverables"));
end if;
return Result;
end Extract_Gantt_Style;
begin
return Processor_Type'(Wp_Target => Get_Target ("wp"),
Partner_Target => Get_Target ("partner"),
Deliverable_Target => Get_Target ("deliverable"),
Wp_Summary_Target => Get_Target ("summary-wp"),
Milestone_Target => Get_Target ("milestone"),
Deliv_Summary_Target => Get_Target ("summary-deliv"),
Deliv_Compact_Summary_Target => Get_Target ("compact-summary-deliv"),
Gantt_Target => Get_Target ("gantt"),
Effort_Summary_Target => Get_Target ("summary-effort"),
Gantt_Style => Extract_Gantt_Style);
end Create;
type File_Pt is access File_Type;
type Extended_File (Class : Target_Class := File) is
record
case Class is
when None | Standard_Output =>
null;
when File =>
F : File_Pt;
end case;
end record;
function Open (What : Target_Spec) return Extended_File
is
begin
case What.Class is
when None =>
return Extended_File'(Class => None);
when Standard_Output =>
return Extended_File'(Class => Standard_Output);
when File =>
declare
Result : constant File_Pt := new File_Type;
begin
Create (File => Result.all,
Mode => Out_File,
Name => To_S (What.Filename));
return Extended_File'(Class => File,
F => Result);
end;
end case;
end Open;
procedure Close (What : in out Extended_File)
is
procedure Free is
new Ada.Unchecked_Deallocation (Object => File_Type,
Name => File_Pt);
begin
case What.Class is
when None | Standard_Output =>
null;
when File =>
Close (What.F.all);
Free (What.F);
end case;
end Close;
function To_File_Access (What : Extended_File) return File_Access
is (case What.Class is
when None =>
null,
when Standard_Output =>
Standard_Output,
when File =>
File_Access (What.F));
--------------------------
-- Print_Warning_Header --
--------------------------
procedure Print_Warning_Header (To : File_Access)
is
begin
Put_Line (To.all, "%");
Put_Line (To.all, "%---");
Put_Line (To.all, "% WARNING: Automatically generated file");
Put_Line (To.all, "% WARNING: If you edit this your changes will be lost");
Put_Line (To.all, "%---");
Put_Line (To.all, "%");
New_Page (To.all);
end Print_Warning_Header;
--------------------
-- Print_Partners --
--------------------
procedure Print_Partners (Input : EU_Projects.Projects.Project_Descriptor;
Target : Target_Spec)
is
use EU_Projects.Nodes.Partners;
procedure Print_Partners (To : File_Access) is
procedure Print_Single_Partner (To : File_Type; Partner : Partner_Access) is
begin
Put_Line (To, "\newpartner"
& "{" & Partner.Short_Name & "}"
& "{" & To_String (Partner.Label) & "}"
& "{" & Partner.Name & "}"
& "{" & Partner.Country & "}");
end Print_Single_Partner;
begin
for Idx in Input.All_Partners loop
Print_Single_Partner (To.all, Element (Idx));
end loop;
end Print_Partners;
Output : Extended_File := Open (Target);
begin
if Output.Class = None then
return;
end if;
Within (Output => To_File_Access (Output),
Env_Name => "partnerlist",
Callback => Print_Partners'Access);
Close (Output);
end Print_Partners;
------------------
-- Define_Label --
------------------
procedure Define_Label (Output : File_Type;
Item : Node_Type'Class;
Prefix : String;
Add_New_Line : Boolean := True)
is
begin
Put (Output,
"\failabel{" & Image (Item.Label) & "}"
& "{" & Prefix & "}"
& "{" & Item.Short_Name & "}"
& "{" & Item.Full_Index (False) & "}");
if Add_New_Line then
New_Line (Output);
end if;
end Define_Label;
------------------
-- Join_Indexes --
------------------
function Join_Indexes (Input : EU_Projects.Projects.Project_Descriptor;
Labels : Node_Label_Lists.Vector;
Separator : String)
return String
is
Result : Unbounded_String;
begin
for Idx in Labels.Iterate loop
Result := Result & Input.Find (Labels (Idx)).Full_Index (Prefixed => True);
if Node_Label_Lists.To_Index (Idx) < Labels.Last_Index then
Result := Result & Separator;
end if;
end loop;
return To_String (Result);
end Join_Indexes;
procedure Print_WP (Input : Project_Descriptor;
Output : Extended_File;
WP : WPs.Project_WP_Access) is
Efforts : constant Action_Nodes.Effort_List :=
WP.Efforts_Of (Input.Partner_Names);
function Short_Name (X : Partners.Partner_Label) return String
is
N : constant Node_Access := Input.Find (Node_Label (X));
begin
if N = null then
raise Processor_Error
with "Unknown partner '" & Image (Node_Label (X)) & "'";
else
return N.Short_Name;
end if;
end Short_Name;
procedure Write_WP_Header (Output : File_Access;
Table : in out Table_Handler)
is
pragma Unreferenced (Output);
Headstyle : constant String := "\stilehead";
procedure Put_Pair (Title, Content : String) is
begin
Table.Put (Title, Headstyle);
Table.Put (Content);
end Put_Pair;
procedure First_Row_Standard_Style is
begin
Table.Cline (1, 4);
Put_Pair ("WP Number", WP.Index_Image);
Put_Pair ("Leader", Short_Name (WP.Leader));
Table.Hline;
Table.Put ("WP Name", Headstyle);
Table.Multicolumn (Span => Efforts'Length + 1,
Spec => "|l|",
Content => WP.Name);
end First_Row_Standard_Style;
procedure First_Row_Compact_Style is
begin
Table.Hline;
Put_Pair ("WP N.", WP.Index_Image);
Table.Put ("WP Name", Headstyle);
Table.Multicolumn (Span => Efforts'Length - 4,
Spec => "|l|",
Content => WP.Name);
Table.Put ("\WPleadertitle");
Table.Multicolumn (Span => 2,
Spec => "c|",
Content =>
"\WPleadername{" & Short_Name (WP.Leader) & "}");
end First_Row_Compact_Style;
begin
if True then
First_Row_Compact_Style;
else
First_Row_Standard_Style;
end if;
Table.Hline;
Table.Put ("N. Partner", Headstyle);
for Idx in Efforts'Range loop
Table.Put (Image (Idx));
end loop;
Table.Put ("");
Table.Hline;
Table.Put ("Name", Headstyle);
for Idx in Efforts'Range loop
Table.Put (Short_Name (Efforts (Idx).Partner));
end loop;
Table.Put ("all");
Table.Hline;
Table.Put ("PM", Headstyle);
declare
use EU_Projects.Efforts;
Total_Effort : Person_Months := 0;
begin
for Idx in Efforts'Range loop
Table.Put (Chop (Efforts (Idx).Effort'Image));
Total_Effort := Total_Effort + Efforts (Idx).Effort;
end loop;
Table.Put (Chop (Total_Effort'Image));
end;
Table.Hline;
Put_Pair ("Start", "M" & EU_Projects.Times.Image (Formatter, WP.Starting_Time));
Put_Pair ("End", "M" & EU_Projects.Times.Image (Formatter, WP.Ending_Time));
Table.Cline (1, 4);
end Write_WP_Header;
-------------------------
-- Write_WP_objectives --
-------------------------
procedure Write_WP_Objectives (Output : File_Access)
is
begin
if WP.Description /= "" then
Put_Line (Output.all, Wp.Description);
else
Put_Line (Output.all, "Placeholder, to be written");
end if;
end Write_WP_Objectives;
--------------------------
-- Write_WP_Description --
--------------------------
procedure Write_WP_Description (Output : File_Access)
is
procedure Write_WP_Tasks (Output : File_Access)
is
procedure Print_Task (Output : File_Access;
Tsk : Tasks.Project_Task_Access) is
begin
Put_Line (Output.all,
"\HXXitem{" & Tsk.Full_Index (Prefixed => True) & "}"
& "{" & Tsk.Name & "}"
& "{("
& Tsk.Timing & "; Leader: " & Short_Name (Tsk.Leader)
& ")}");
Define_Label (Output => Output.all,
Item => Tsk.all,
Prefix => "T");
Put_Line (Output.all, Tsk.Description);
end Print_Task;
begin
if Wp.Max_Task_Index > 0 then
for Idx in WP.All_Tasks loop
Print_Task (Output, WPs.Element (Idx));
end loop;
else
Put_Line (Output.all, "\HXXitem{T0.0}{Placeholder}{(please ignore)}");
end if;
end Write_WP_Tasks;
begin
Within (Output => Output,
Env_Name => "HXXitemize",
Callback => Write_WP_Tasks'Access);
end Write_WP_Description;
---------------------------
-- Write_WP_Deliverables --
---------------------------
procedure Write_WP_Deliverables (Output : File_Access)
is
procedure Loop_Over_Deliv (Output : File_Access)
is
procedure Print_Deliv (Output : File_Access;
Deliv : Deliverables.Deliverable_Access)
is
use type Deliverables.Deliverable_Status;
N_Deliverers : constant Natural := Natural (Deliv.Delivered_By.Length);
function Add_Colon_If_Not_Empty (X : String) return String
is (if X = "" then "" else ": " & X);
begin
if Deliv.Status = Deliverables.Clone then
return;
end if;
Put (Output.all,
"\wpdeliv{" & Deliv.Full_Index (Prefixed => True) & "}"
& "{" & Deliv.Name & "}"
& "{" & Add_Colon_If_Not_Empty (Deliv.Description) & "}"
& "{("
& "Due: M" & Deliverables.Image (Deliv.Due_On)
-- & "; Nature: " & "WRITE ME"
& (case N_Deliverers is
when 0 => "",
when 1 => " Task:",
when others => " Tasks:")
& Join_Indexes (Input, Deliv.Delivered_By, ", ")
& ")}");
Define_Label (Output => Output.all,
Item => Deliv.all,
Prefix => "D",
Add_New_Line => False);
-- Put_Line (Output.all, Deliv.Description);
end Print_Deliv;
At_Least_One_Deliverable : Boolean := False;
begin
for Idx in WP.All_Deliverables loop
Print_Deliv (Output, WPs.Element (Idx));
At_Least_One_Deliverable := True;
end loop;
if not At_Least_One_Deliverable then
Put_Line (Output.all, "\wpdeliv{D0.0}{Placeholder}{(please ignore)}");
end if;
end Loop_Over_Deliv;
begin
Within (Output => Output,
Env_Name => "wpdeliverables",
Callback => Loop_Over_Deliv'Access);
end Write_WP_Deliverables;
begin
if Output.Class = None then
return;
end if;
Define_Label (To_File_Access (Output).all, WP.all, "WP");
if WP.Index > 1 then
Put_Line (To_File_Access (Output).all, "\beforeheaderskip");
end if;
Put_Line (To_File_Access (Output).all, "\noindent{\headersize");
Within_Table (Output => To_File_Access (Output),
Table_Spec => "|l*{" & Project_Processor.Image (Efforts'Length + 1) & "}{|c}|",
Callback => Write_WP_Header'Access,
Default_Style => "\stilecontent");
Put_Line (To_File_Access (Output).all, "}\\[\wpheadersep]");
Within (Output => To_File_Access (Output),
Env_Name => "titledbox",
Callback => Write_Wp_Objectives'Access,
Parameter => "Objectives");
Within (Output => To_File_Access (Output),
Env_Name => "titledbox",
Callback => Write_WP_Description'Access,
Parameter => "Description");
Within (Output => To_File_Access (Output),
Env_Name => "titledbox",
Callback => Write_WP_Deliverables'Access,
Parameter => "Deliverables");
end Print_WP;
procedure Print_WPs (Input : EU_Projects.Projects.Project_Descriptor;
Output : Target_Spec)
is
Target : Extended_File := Open (Output);
begin
if Target.Class = None then
return;
end if;
Print_Warning_Header (To_File_Access (Target));
Print_Default_Macro (To_File_Access (Target), "\stilecontent", "#1", 1);
Print_Default_Macro (To_File_Access (Target), "\stilehead", "\textbf{#1}", 1);
Print_Default_Macro (To_File_Access (Target), "\headersize", "\footnotesize", 0);
for Idx in Input.All_WPs loop
Print_WP (Input, Target, Element (Idx));
end loop;
Close (Target);
end Print_WPs;
procedure Print_Milestones (Input : EU_Projects.Projects.Project_Descriptor;
Output : Target_Spec;
Style : Table_Style)
is
pragma Unreferenced (Style);
use EU_Projects.Nodes.Timed_Nodes.Milestones;
procedure Loop_Over_Milestones (Output : File_Access)
is
procedure Print_Milestone (Mstone : Milestone_Access)
is
function Image (X : Node_Label_Lists.Vector;
Separator : String) return String
is
Result : Unbounded_String;
Deliv : Deliverables.Deliverable_Access;
N : Node_Access;
begin
for Lb of X loop
if Result /= Null_Unbounded_String then
Result := Result & Separator;
end if;
N := Input.Find (Lb);
if N = null then
Put_Line (Standard_Error, "Deliverable '" & To_String (Lb) & "' unknown");
else
Deliv := Deliverables.Deliverable_Access (N);
Result := Result & "\ref{" & To_String (Deliv.Parent_Wp.Label) & "}";
end if;
end loop;
return To_String (Result);
end Image;
begin
Put_Line (Output.all, "\milestoneitem" &
"[" & Mstone.Description & "]" &
"{" & Mstone.Full_Index (Prefixed => False) & "}" &
"{" & Mstone.Name & "}" &
"{M" & EU_Projects.Times.Image (Formatter, Mstone.Due_On) & "}" &
"{" & Image (Mstone.Deliverable_List, ", ") & "}" &
"{" & Mstone.Verification_Mean & "}" &
"{" & Image (Mstone.Label) & "}" &
"{" & Mstone.Short_Name & "}");
-- Table.Put (Mstone.Full_Index (Prefixed => True));
-- Table.Put (Mstone.Name);
-- Table.Put (Join_Indexes (Input, Mstone.Deliverable_List, ", "));
-- Table.Put ("M" & EU_Projects.Times.Image (Mstone.Due_On));
-- Table.Put (Mstone.Verification_Mean);
--
-- if Style = Full then
-- Table.Hline;
--
-- Table.Multicolumn (Span => 5,
-- Spec => (case Style is
-- when Full => "|l|",
-- when Light => "l"),
-- Content => Mstone.Description);
-- else
-- Table.Put (Mstone.Description);
-- end if;
--
--
--
-- Define_Label (Output => Output.all,
-- Item => Mstone.all,
-- Prefix => "M");
--
-- Table.Hline (Style = Full);
end Print_Milestone;
begin
-- Table.Hline (Style = Full);
-- Table.Multicolumn (1, "c|", "");
-- Table.Multicolumn (1, "c|", "");
-- Table.Multicolumn (1, "c|", "Deliverable");
-- Table.Multicolumn (1, "c|", "");
-- Table.Multicolumn (1, "c|", "Means of");
--
-- Table.New_Row;
--
-- Table.Multicolumn (1, "c|", "N.");
-- Table.Multicolumn (1, "c|", "Name");
-- Table.Multicolumn (1, "c|", "involved");
-- Table.Multicolumn (1, "c|", "Date");
-- Table.Multicolumn (1, "c|", "verification");
--
-- if Style = Light then
-- Table.Multicolumn (1, "c", "Description");
-- end if;
-- Table.Hline;
for Idx in Input.All_Milestones loop
Print_Milestone (Element (Idx));
end loop;
end Loop_Over_Milestones;
Target : Extended_File := Open (Output);
begin
if Target.Class = None then
return;
end if;
Print_Warning_Header (To_File_Access (Target));
Within (Output => To_File_Access (Target),
Env_Name => "milestonetable",
Callback => Loop_Over_Milestones'Access);
-- Within_Table (Output => To_File_Access (Target),
-- Table_Spec => (case Style is
-- when Full => "|*5{l|}",
-- when Light => "*5{l|}X"),
-- Callback => Loop_Over_Milestones'Access,
-- Default_Style => "",
-- Caption => "Milestones \label{tbl:milestones}");
Close (Target);
end Print_Milestones;
----------------------
-- Print_WP_Summary --
----------------------
procedure Print_WP_Summary (Input : EU_Projects.Projects.Project_Descriptor;
Output : Target_Spec;
Style : Table_Style)
is
pragma Unreferenced (Style);
procedure Make_Summary (Output : File_Access;
Table : in out Table_Handler)
is
pragma Unreferenced (Table);
use EU_Projects.Efforts;
use EU_Projects.Nodes.Action_Nodes.WPs;
------------------
-- Total_Effort --
------------------
function Total_Effort (WP : Project_WP_Access) return Person_Months
is
Result : Person_Months := 0;
Partner_Efforts : constant Effort_List := Wp.Efforts_Of (Input.Partner_Names);
begin
for Val of Partner_Efforts loop
Result := Result + Val.Effort;
end loop;
return Result;
end Total_Effort;
-- procedure Full_Header is
--
-- begin
-- Table.Hline;
-- Table.Head ("WP");
-- Table.Head ("WP Name");
-- Table.Multicolumn (2, "|c|", "\stilehead{Leader}");
-- -- Table.Put ("Leader N.", "\stilehead");
-- -- Table.Put ("Leader"");
-- Table.Head ("PM");
-- Table.Head ("Start");
-- Table.Head ("End");
-- Table.Cline (3, 4);
--
-- Table.Put ("");
-- Table.Put ("");
-- Table.Head ("Name");
-- Table.Head ("N.");
-- Table.Put ("");
-- Table.Put ("");
-- Table.Put ("");
-- end Full_Header;
--
-- procedure Light_Header is
--
-- begin
-- Table.Put ("");
-- Table.Put ("");
-- Table.Multicolumn (2, "c", "\stilehead{Leader}");
-- -- Table.Put ("Leader N.", "\stilehead");
-- -- Table.Put ("Leader"");
-- Table.Put ("");
-- Table.Put ("");
-- Table.Put ("");
-- Table.Put ("");
-- Table.Cline (3, 4);
--
-- Table.Multicolumn (1, "c", "WP");
-- Table.Multicolumn (1, "c", "WP Name");
-- Table.Multicolumn (1, "c", "Name");
-- Table.Multicolumn (1, "c", "N.");
-- Table.Multicolumn (1, "c", "~");
-- Table.Multicolumn (1, "c", "PM");
-- Table.Multicolumn (1, "c", "Start");
-- Table.Multicolumn (1, "c", "End");
-- end Light_Header;
Project_Effort : Person_Months := 0;
begin
-- case Style is
-- when Full => Full_Header;
-- when Light => Light_Header;
-- end case;
Put_Line (Output.all, "\summarywptableheader");
-- Table.Hline;
for Pos in Input.All_WPs loop
declare
use EU_Projects.Nodes.Partners;
procedure Put_Arg (X : String) is
begin
Put (Output.all, "{" & X & "}");
end Put_Arg;
WP : constant Project_WP_Access := Element (Pos);
Wp_Effort : constant Person_Months := Total_Effort (Wp);
Leader : constant Partner_Access :=
Partner_Access (Input.Find (Node_Label (WP.Leader)));
begin
Put (Output.all, "\summarywpitem");
Put_Arg (WP.Full_Index (Prefixed => False));
Put_Arg (WP.Short_Name);
Put_Arg (Leader.Short_Name);
Put_Arg (Leader.Full_Index (Prefixed => False));
Put_Arg (Chop (Wp_Effort'Image));
Put_Arg (EU_Projects.Times.Image (Formatter, Wp.Starting_Time));
Put_Arg (EU_Projects.Times.Image (Formatter, Wp.Ending_Time));
New_Line (Output.all);
Project_Effort := Project_Effort + Wp_Effort;
-- Table.Hline (Style = Full);
end;
end loop;
Put_Line (Output.all, "\summarywptotalrow{" & Chop (Project_Effort'Image) & "}");
-- case Style is
-- when Full =>
-- Table.Put ("\cellavuota");
-- Table.Put ("\cellavuota");
-- Table.Put ("\cellavuota");
-- Table.Put ("\cellavuota");
-- Table.Put (Chop (Project_Effort'Image));
-- Table.Put ("\cellavuota");
-- Table.Put ("\cellavuota");
-- Table.Hline;
--
-- when Light =>
-- Table.Hline;
-- Put (Output.all, "\rigatotali");
-- Table.Put ("");
-- Table.Put ("Total");
-- Table.Put ("");
-- Table.Put ("");
-- Table.Put ("");
-- Table.Put (Chop (Project_Effort'Image));
-- Table.Put ("");
-- Table.Put ("");
-- end case;
end Make_Summary;
Target : Extended_File := Open (Output);
begin
if Target.Class = None then
return;
end if;
Within_Table_Like (Output => To_File_Access (Target),
Env_Name => "summarywptable",
Callback => Make_Summary'Access,
Parameter => "List of work packages \label{tbl:wps}");
-- Within_Table (Output => To_File_Access (Target),
-- Table_Spec => (case Style is
-- when Full => "|c|X|c|c|r|r|r|",
-- when Light => "cXlccrrr"),
-- Callback => Make_Summary'Access,
-- Default_Style => "",
-- Default_Head => "\textbf",
-- caption => "List of work packages \label{tbl:wps}");
Close (Target);
end Print_WP_Summary;
-------------------------
-- Print_Deliv_Summary --
-------------------------
procedure Print_Deliv_Summary_Low_Level (Input : EU_Projects.Projects.Project_Descriptor;
Output : Target_Spec;
Style : Table_Style)
is
------------------
-- Make_Summary --
------------------
procedure Make_Summary (Output : File_Access;
Table : in out Table_Handler)
is
pragma Unreferenced (Output);
use EU_Projects.Nodes.Timed_Nodes.Deliverables;
-- use type EU_Projects.Times.Instant;
function "<" (X, Y : Deliverable_Access) return Boolean
is (EU_Projects.Times.Instant'(X.Due_On) < Y.Due_On
or else
(EU_Projects.Times.Instant'(X.Due_On) = Y.Due_On
and X.Full_Index (False) < Y.Full_Index (False)));
package Deliverable_Vectors is
new Ada.Containers.Vectors (Index_Type => Positive,
Element_Type => Deliverable_Access);
package Deliv_Sorting is
new Deliverable_Vectors.Generic_Sorting;
Project_Deliverables : Deliverable_Vectors.Vector;
begin
Table.Hline (Style = Full);
Table.Put ("N.", "\stilehead");
Table.Put ("Name", "\stilehead");
Table.Put ("WP", "\stilehead");
Table.Put ("Leader", "\stilehead");
Table.Put ("Type", "\stilehead");
Table.Put ("Policy", "\stilehead");
Table.Put ("Due", "\stilehead");
Table.Hline;
for Pos in Input.All_Deliverables loop
Project_Deliverables.Append (Element (Pos));
end loop;
Deliv_Sorting.Sort (Project_Deliverables);
for Deliv of Project_Deliverables loop
declare
use Wps;
use Partners;
Parent : constant Project_WP_Access := Project_WP_Access (Deliv.Parent_Wp);
Leader : constant Partner_Access :=
Partner_Access (Input.Find (Node_Label (Parent.Leader)));
begin
Table.Put (Deliv.Full_Index (Prefixed => True));
Table.Put (Deliv.Name);
Table.Put (Parent.Full_Index (True));
Table.Put (Leader.Short_Name);
Table.Put (Chop (Deliverable_Type_Image (Deliv.Nature)));
Table.Put (Chop (Dissemination_Level_Image (Deliv.Dissemination)));
Table.Put ("M" & EU_Projects.Times.Image (Deliv.Due_On));
Table.Hline (Style = Full);
end;
end loop;
end Make_Summary;
Target : Extended_File := Open (Output);
begin
if Target.Class = None then
return;
end if;
Within_Table (Output => To_File_Access (Target),
Table_Spec => (case Style is
when Full => "|c|X|c|l|c|c|r|",
when Light => "cXclccr"),
Callback => Make_Summary'Access,
Default_Style => "",
Caption => "List of deliverables \label{tbl:delivs}");
Close (Target);
end Print_Deliv_Summary_Low_Level;
procedure Print_Deliv_Summary (Input : EU_Projects.Projects.Project_Descriptor;
Output : Target_Spec)
is
------------------
-- Make_Summary --
------------------
procedure Make_Summary (Output : File_Access)
is
use EU_Projects.Nodes.Timed_Nodes.Deliverables;
-- use type EU_Projects.Times.Instant;
function "<" (X, Y : Deliverable_Access) return Boolean
is (EU_Projects.Times.Instant'(X.Due_On) < Y.Due_On
or else
(EU_Projects.Times.Instant'(X.Due_On) = Y.Due_On
and X.Full_Index (False) < Y.Full_Index (False)));
package Deliverable_Vectors is
new Ada.Containers.Vectors (Index_Type => Positive,
Element_Type => Deliverable_Access);
package Deliv_Sorting is
new Deliverable_Vectors.Generic_Sorting;
Project_Deliverables : Deliverable_Vectors.Vector;
begin
for Pos in Input.All_Deliverables loop
if Element (Pos).Status /= Parent then
Project_Deliverables.Append (Element (Pos));
end if;
end loop;
Deliv_Sorting.Sort (Project_Deliverables);
for Deliv of Project_Deliverables loop
declare
use Wps;
use Partners;
Parent : constant Project_WP_Access := Project_WP_Access (Deliv.Parent_Wp);
Leader : constant Partner_Access :=
Partner_Access (Input.Find (Node_Label (Parent.Leader)));
begin
Put (Output.all, "\delivitem");
Put (Output.all, "{" & Deliv.Full_Index (Prefixed => True) & "}");
Put (Output.all, "{" & Deliv.Short_Name & "}");
Put (Output.all, "{" & Parent.Full_Index (True) & "}");
Put (Output.all, "{" & Leader.Short_Name & "}");
Put (Output.all, "{" & Chop (Deliverable_Type_Image (Deliv.Nature)) & "}");
Put (Output.all, "{" & Chop (Dissemination_Level_Image (Deliv.Dissemination)) & "}");
Put (Output.all, "{" & "M" & EU_Projects.Times.Image (Formatter, Deliv.Due_On) & "}");
New_Line (Output.all);
end;
end loop;
end Make_Summary;
Target : Extended_File := Open (Output);
begin
if Target.Class = None then
return;
end if;
Within (Output => To_File_Access (Target),
Env_Name => "deliverablelist",
Callback => Make_Summary'Access);
Close (Target);
end Print_Deliv_Summary;
procedure Print_Compact_Deliv_Summary (Project : EU_Projects.Projects.Project_Descriptor;
Output : Target_Spec)
is
--------------------------
-- Make_compact_Summary --
--------------------------
procedure Make_compact_Summary (Output : File_Access)
is
use EU_Projects.Nodes.Timed_Nodes.Deliverables;
function Expected_Date (Deliverable : Deliverable_Access) return Instant
with Pre => Deliverable.Status /= Clone;
function Expected_Date (Deliverable : Deliverable_Access) return Instant
is (case Deliverable.Status is
when Parent =>
Deliverable.Clone (1).Due_On,
when
Stand_Alone => Deliverable.Due_On,
when Clone =>
-- we should never arrive here
raise Program_Error);
function "<" (X, Y : Deliverable_Access) return Boolean
is (EU_Projects.Times.Instant'(Expected_Date (X)) < Expected_Date (Y)
or else
(EU_Projects.Times.Instant'(Expected_Date (X)) = Expected_Date (Y)
and X.Full_Index (False) < Y.Full_Index (False)));
package Deliverable_Vectors is
new Ada.Containers.Vectors (Index_Type => Positive,
Element_Type => Deliverable_Access);
package Deliv_Sorting is
new Deliverable_Vectors.Generic_Sorting;
Project_Deliverables : Deliverable_Vectors.Vector;
function Expected_Date_Image (Deliv : Deliverable_Access) return String
with Pre => Deliv.Status /= Clone;
function Expected_Date_Image (Deliv : Deliverable_Access) return String
is
begin
case Deliv.Status is
when Clone =>
raise Program_Error;
when Stand_Alone =>
return EU_Projects.Times.Image (Formatter, Deliv.Due_On);
when Parent =>
declare
Result : Unbounded_String;
begin
for Idx in 1 .. Deliv.Max_Clone loop
if Idx > 1 then
Result := Result & ".";
end if;
Result := Result & EU_Projects.Times.Image (Formatter, Deliv.Clone (Idx).Due_On);
end loop;
return To_String (Result);
end;
end case;
end Expected_Date_Image;
begin
for Pos in Project.All_Deliverables loop
if Element (Pos).Status /= Clone then
Project_Deliverables.Append (Element (Pos));
end if;
end loop;
Deliv_Sorting.Sort (Project_Deliverables);
for Deliv of Project_Deliverables loop
declare
use Wps;
use Partners;
Parent_WP : constant Project_WP_Access := Project_WP_Access (Deliv.Parent_Wp);
Leader : constant Partner_Access :=
Partner_Access (Project.Find (Node_Label (Parent_WP.Leader)));
begin
Put (Output.all, "\delivitem");
Put (Output.all, "{" & Deliv.Full_Index (Prefixed => True) & "}");
Put (Output.all, "{" & Deliv.Short_Name & "}");
Put (Output.all, "{" & Parent_WP.Full_Index (True) & "}");
Put (Output.all, "{" & Leader.Short_Name & "}");
Put (Output.all, "{" & Chop (Deliverable_Type_Image (Deliv.Nature)) & "}");
Put (Output.all, "{" & Chop (Dissemination_Level_Image (Deliv.Dissemination)) & "}");
Put (Output.all, "{" & "M" & Expected_Date_Image (Deliv) & "}");
New_Line (Output.all);
end;
end loop;
end Make_compact_Summary;
Target : Extended_File := Open (Output);
begin
if Target.Class = None then
return;
end if;
Within (Output => To_File_Access (Target),
Env_Name => "deliverablelist",
Callback => Make_Compact_Summary'Access);
Close (Target);
end Print_Compact_Deliv_Summary;
procedure Print_Effort_Summary (Input : EU_Projects.Projects.Project_Descriptor;
Output : Target_Spec)
is
------------------
-- Make_Summary --
------------------
procedure Make_Summary (Output : File_Access;
Table : in out Table_Handler)
is
pragma Unreferenced (Output);
use EU_Projects;
use EU_Projects.Efforts;
use EU_Projects.Nodes.Action_Nodes.WPs;
use EU_Projects.Nodes.Partners;
Total_Per_WP : array (1 .. Node_Index (Input.N_WPs)) of Person_Months := (others => 0);
Project_Effort : Person_Months := 0;
begin
Table.Cline (2, Input.N_WPs + 2);
Table.Multicolumn (Span => 1,
Spec => "c|",
Content => "");
for Pos in Input.All_WPs loop
Table.Put (Element (Pos).Full_Index (True), "\effortheader");
end loop;
Table.Put ("Total", "\effortheader");
Table.Hline;
for Partner_Pos in Input.All_Partners loop
declare
Partner : constant Partner_Access := Element (Partner_Pos);
Label : constant Partner_Label := Partner_Label (Partner.Label);
Effort : Person_Months;
Total : Person_Months := 0;
begin
Table.Put (Partner.Short_Name, "\effortpartner");
for WP in Input.All_WPs loop
Effort := Element (Wp).Effort_Of (Label);
Total := Total + Effort;
Total_Per_WP (Element (WP).Index) := Total_Per_WP (Element (WP).Index) + Effort;
if Element (Wp).Leader = Label then
Table.Put (Efforts.Person_Months'Image (Effort), "\textbf");
else
Table.Put (Efforts.Person_Months'Image (Effort));
end if;
end loop;
Table.Put (Gray & Person_Months'Image (Total));
Table.Hline;
Project_Effort := Project_Effort + Total;
end;
end loop;
Table.Put ("Total");
for WP in Input.All_WPs loop
Table.Put (Gray & Person_Months'Image (Total_Per_WP (Element (WP).Index)));
end loop;
Table.Put (Gray & Person_Months'Image (Project_Effort));
Table.Hline;
end Make_Summary;
Target : Extended_File := Open (Output);
begin
if Target.Class = None then
return;
end if;
Within_Table_Like (Output => To_File_Access (Target),
Env_Name => "efforts",
Callback => Make_Summary'Access,
Parameters =>
"Summary of staff effort"
and Image (Input.N_WPs + 2));
-- (Output => ,
-- Table_Spec => "|l|*{" & Image (Input.N_WPs + 2) & "}{r|}",
-- Callback => Make_Summary'Access,
-- Default_Style => "",
-- Caption => "Summary of staff effort \label{tbl:staff}");
Close (Target);
end Print_Effort_Summary;
-----------------
-- Print_Gantt --
-----------------
procedure Print_Gantt_Old (Input : EU_Projects.Projects.Project_Descriptor;
Output : Target_Spec)
is
-- use EU_Projects.Times;
Last_Month : constant Positive :=
(if Input.Duration = To_Be_Decided
then
36
else
Months (Input.Duration));
procedure Make_GANTT (Output : File_Access;
Table : in out Table_Handler)
is
pragma Unreferenced (Output);
Step : constant Positive := 6;
procedure Compact_Header_Line is
begin
Table.Multicolumn (2, "c", "");
for M in 1 .. Last_Month loop
if M mod Step = 0 then
Table.Multicolumn
(Span => 1,
Spec => "c",
Content => "\stilemese{" & Image (M) & "}");
else
Table.Put ("");
end if;
Table.Put ("");
end loop;
Table.New_Row;
end Compact_Header_Line;
procedure First_Header_Line is
begin
Table.Put ("");
Table.Put ("");
for M in 1 .. Last_Month loop
if M mod Step = 0 and M > 9 then
Table.Put (Image (M / 10));
else
Table.Put ("");
end if;
Table.Put ("");
end loop;
Table.New_Row;
end First_Header_Line;
procedure Second_Header_Line is
begin
Table.Put ("");
Table.Put ("");
for M in 1 .. Last_Month loop
if M mod Step = 0 then
Table.Put (Image (M mod 10));
else
Table.Put ("");
end if;
Table.Put ("");
end loop;
Table.New_Row;
end Second_Header_Line;
procedure Show_Busy_Time (Item : EU_Projects.Nodes.Action_Nodes.Action_Node'Class)
is
From : constant Instant := Item.Starting_Time;
To : constant Instant := Item.Ending_Time;
begin
if From = To_Be_Decided or To = To_Be_Decided then
for M in 1 .. Last_Month loop
Table.Put ("\TBDcell");
Table.Put ("");
end loop;
else
declare
T : Instant;
begin
for M in 1 .. Last_Month loop
T := To_Instant (M);
Table.Put ((if T >= From and then T <= To
then
"\busytimecell"
else
"\freetimecell"));
Table.Put ("");
end loop;
end;
end if;
Table.New_Row;
end Show_Busy_Time;
Compact : constant Boolean := True;
begin
if Compact then
Compact_Header_Line;
else
First_Header_Line;
Second_Header_Line;
end if;
Table.Hline;
for WP in Input.All_WPs loop
Table.Multicolumn
(Span => 2,
Spec => "l|",
Content => "\GANTTwpname{"
& Element (Wp).Full_Index (True)
& "~"
& Element (WP).Short_Name
& "}");
Show_Busy_Time (Element (WP).all);
for T in Element (WP).All_Tasks loop
Table.Put ("");
Table.Put ("\GANTTtaskname{"
& WPs.Element (T).Full_Index (True)
& "~"
& WPs.Element (T).Short_Name
& "}");
Show_Busy_Time (WPs.Element (T).all);
end loop;
Table.Hline;
end loop;
Table.Hline;
declare
use EU_Projects.Nodes.Timed_Nodes.Milestones;
Mstone_Table : constant Milestone_Table_Type := Input.Milestone_Table;
Milestone_Month : array (Mstone_Table'Range (1)) of Boolean := (others => False);
begin
for Row in Mstone_Table'Range (2) loop
for M in Mstone_Table'Range (1) loop
if Mstone_Table (M, Row) /= null then
Milestone_Month (M) := True;
end if;
end loop;
end loop;
Table.Multicolumn (2, "l|", "Milestones");
for Has_Milestone of Milestone_Month loop
Table.Multicolumn (1, "c", (if Has_Milestone then "\GANTTmshere" else ""));
Table.Put ("");
end loop;
Table.New_Row;
for Row in Mstone_Table'Range (2) loop
Table.Put ("");
Table.Put ("");
for M in Mstone_Table'Range (1) loop
if Mstone_Table (M, Row) = null then
Table.Put ("");
else
Table.Multicolumn (1, "c", "\GANTTmsstyle"
& "{" & Mstone_Table (M, Row).Full_Index (True) & "}");
end if;
Table.Put ("");
end loop;
Table.New_Row;
end loop;
end;
end Make_GANTT;
Target : Extended_File := Open (Output);
begin
if Target.Class = None then
return;
end if;
Within_Table (Output => To_File_Access (Target),
Table_Spec => "p{1em}l|"
& "*{" & Image (Last_Month) & "}"
& "{p{\larghezzacella}p{\larghezzasep}@{}}",
Callback => Make_GANTT'Access,
Default_Style => "",
Caption => "GANTT \label{tbl:gantt}");
Close (Target);
end Print_Gantt_Old;
------------------------
-- Longest_Label_Size --
------------------------
procedure Longest_Label_Size (Input : EU_Projects.Projects.Project_Descriptor;
WP_Label_Size : out Natural;
Task_Label_Size : out Natural;
Wp_And_Task_Count : out Natural)
is
begin
WP_Label_Size := 0;
Task_Label_Size := 0;
Wp_And_Task_Count := 0;
for Wp in Input.All_WPs loop
WP_Label_Size := Integer'Max (WP_Label_Size,
Element (Wp).Short_Name'Length);
Wp_And_Task_Count := Wp_And_Task_Count + 1;
for Tsk in Element (Wp).All_Tasks loop
Task_Label_Size := Integer'Max (Task_Label_Size,
WPs.Element (Tsk).Short_Name'Length);
Wp_And_Task_Count := Wp_And_Task_Count + 1;
end loop;
end loop;
-- Put_Line ("WW=" & Wp_And_Task_Count'Image);
end Longest_Label_Size;
-----------------
-- Print_Gantt --
-----------------
type Graphic_Setup_Descriptor is
record
Task_X0 : Picture_Length;
Month_Step : Month_Number;
Label_Size : Picture_Length;
Month_Width : Picture_Length;
Line_Heigth : Picture_Length;
Pre_Skip : Picture_Length;
Post_Skip : Picture_Length;
Interline : Picture_Length;
Unit_Length : Latex_Length;
Last_Month : Month_Number;
Top_Position : Picture_Length;
Total_Width : Picture_Length;
Small_Interline : Picture_Length;
Grid_Height : Picture_Length;
Tick_Length : Picture_Length;
Top_WP : Picture_Length;
Header_Skip : Picture_Length;
Font_Height : Picture_Length;
end record;
procedure Make_GANTT (Input : EU_Projects.Projects.Project_Descriptor;
Output : File_Access;
Graphic_Setup : Graphic_Setup_Descriptor;
Parameters : GANTT_Parameters)
is
use EU_Projects;
-- use EU_Projects.Times;
procedure Make_WP_Separator;
Current_V_Pos : Picture_Length;
function Month_Position (Month : Projects.Month_Number;
Setup : Graphic_Setup_Descriptor)
return Picture_Length
is (Setup.Label_Size + (Integer (Month) - 1) * Setup.Month_Width);
function To_Length (L : Picture_Length;
Setup : Graphic_Setup_Descriptor)
return Latex_Length
is (Float (L) * Setup.Unit_Length);
procedure Next_Row is
begin
-- Put_Line (Current_V_Pos'Image);
-- Put_Line (Graphic_Setup.Month_Heigth'Image);
-- Put_Line (Graphic_Setup.Interline'image);
Current_V_Pos := Current_V_Pos - Graphic_Setup.Line_Heigth;
end Next_Row;
procedure Show_Busy_Time (Item : EU_Projects.Nodes.Action_Nodes.Action_Node'Class;
Style : String;
Intensity : EU_Projects.Nodes.Action_Nodes.Tasks.Task_Intensity)
is
procedure Make_Bar (From, To : Month_Number;
Command : String;
Show_Intensity : Boolean) is
Start : constant Picture_Length :=
Month_Position (From, Graphic_Setup);
Len : constant Latex_Length :=
To_Length (Month_Position (To, Graphic_Setup)-Start, Graphic_Setup);
Shrink : constant Float := 0.8;
H : constant Latex_Length :=
Shrink * To_Length (Graphic_Setup.Line_Heigth, Graphic_Setup);
H2 : constant Latex_Length := Float'Max (Intensity, 0.15) * H;
Box_Raise : constant Latex_Length :=
(1.0 - Shrink) * 0.5 * To_Length (Graphic_Setup.Line_Heigth, Graphic_Setup);
begin
if Show_Intensity then
Put_Line (Output.all, Put (X => Start,
Y => Current_V_Pos,
What => Style
& "{"
& (
"\shadedrule"
& "[" & Image (Box_Raise) & "]"
& "{" & Image (Len) & "}"
& "{" & Image (H) & "}"
)
& "}"));
Put_Line (Output.all, Put (X => Start,
Y => Current_V_Pos,
What => Style
& "{"
& (
Command
& "[" & Image (Box_Raise) & "]"
& "{" & Image (Len) & "}"
& "{" & Image (H2) & "}"
)
& "}"));
else
Put_Line (Output.all, Put (X => Start,
Y => Current_V_Pos,
What => Style
& "{"
& (
Command
& "[" & Image (Box_Raise) & "]"
& "{" & Image (Len) & "}"
& "{" & Image (H) & "}"
)
& "}"));
end if;
declare
Dx : constant Picture_Length := Picture_Length (Len / Graphic_Setup.Unit_Length);
Dy : constant Picture_Length := Picture_Length (H / Graphic_Setup.Unit_Length);
B : constant Picture_Length := Picture_Length (Box_Raise / Graphic_Setup.Unit_Length);
Y0 : constant Picture_Length := Current_V_Pos + B;
begin
Put_Line (Output.all, Put (X => Start,
Y => Y0,
What => HLine (Dx)));
Put_Line (Output.all, Put (X => Start,
Y => Y0,
What => Vline (Dy)));
Put_Line (Output.all, Put (X => Start,
Y => Y0 + Dy,
What => HLine (Dx)));
Put_Line (Output.all, Put (X => Start + Dx,
Y => Y0,
What => VLine (Dy)));
end;
end Make_Bar;
From : constant Instant := Item.Starting_Time;
To : constant Instant := Item.Ending_Time;
begin
if From = To_Be_Decided or To = To_Be_Decided then
Make_Bar (From => 1,
To => Graphic_Setup.Last_Month,
Command => "\lightshadedrule",
Show_Intensity => False);
else
Make_Bar (From => Projects.Month_Number (Months (From)),
To => Projects.Month_Number (Months (To)),
Command => "\rule",
Show_Intensity => Intensity < 0.99);
end if;
end Show_Busy_Time;
procedure Make_Label (Command : String;
Item : EU_Projects.Nodes.Action_Nodes.Action_Node'Class;
Indent : Picture_Length)
is
begin
Put_Line (Output.all,
Picture.Put (X => Indent,
Y => Current_V_Pos,
What => Command
& "{" & Item.Full_Index (True) & "~" & Item.Short_Name & "}"));
end Make_Label;
procedure Mark_Month_With_Milestone (Month : Projects.Month_Number) is
begin
Put_Line (Output.all,
Picture.Text (X => Month_Position (Month, Graphic_Setup),
Y => Current_V_Pos,
Content => "\GANTThasmilestone"));
end Mark_Month_With_Milestone;
procedure Put_Milestone (Month : Month_Number;
Mstone : Milestones.Milestone_Access)
is
begin
Put_Line (Output.all,
Text (X => Month_Position (Month, Graphic_Setup),
Y => Current_V_Pos,
Content => Hbox ("\GANTTmstoneNumber "
& Mstone.Full_Index (False)
& ";")));
end Put_Milestone;
procedure Mark_Milestones
is
use EU_Projects.Nodes.Timed_Nodes.Milestones;
Mstone_Table : constant Milestone_Table_Type := Input.Milestone_Table;
Has_Milestone : array (Mstone_Table'Range (1)) of Boolean := (others => False);
begin
Make_WP_Separator;
Put_Line (Output.all,
Picture.Put (X => 0.0,
Y => Current_V_Pos,
What => "\milestonelabel"));
for Row in Mstone_Table'Range (2) loop
for Month in Mstone_Table'Range (1) loop
if Mstone_Table (Month, Row) /= null then
Has_Milestone (Month) := True;
end if;
end loop;
end loop;
for Month in Has_Milestone'Range loop
if Has_Milestone (Month) then
Mark_Month_With_Milestone (Month);
end if;
end loop;
Next_Row;
for Row in Mstone_Table'Range (2) loop
for Month in Mstone_Table'Range (1) loop
if Mstone_Table (Month, Row) /= null then
Put_Milestone (Month, Mstone_Table (Month, Row));
end if;
end loop;
Next_Row;
end loop;
end Mark_Milestones;
procedure Make_Header_And_Grid (Setup : Graphic_Setup_Descriptor)
is
Current_Month : Month_Number;
function Skip (Month : Month_Number) return Picture_Length
is
begin
return Setup.Header_Skip + (if Month mod 12 = 0 then
0.0
elsif Month mod 6 = 0 then
0.4 * Setup.Tick_Length
elsif Month mod 3 = 0 then
0.8 * Setup.Tick_Length
else
0.8 * Setup.Tick_Length);
end Skip;
begin
Current_Month := Setup.Month_Step;
while Current_Month <= Setup.Last_Month loop
Put_Line (Output.all,
Picture.Put (X => Month_Position (Current_Month, Setup),
Y => Current_V_Pos,
What => Hbox (Chop (Current_Month'Image))));
Current_Month := Current_Month + Setup.Month_Step;
end loop;
for Month in 1 .. Setup.Last_Month loop
Put (Output.all, "{");
Put (Output.all,
(if Month mod 12 = 0 then
"\xiithick"
elsif Month mod 6 = 0 then
"\vithick"
elsif Month mod 3 = 0 then
"\iiithick"
else
"\ithick"));
Put (Output.all,
Picture.VLine (X => Month_Position (Month, Setup),
Y => 2 * Setup.Line_Heigth,
Length => Current_V_Pos - Skip (Month)-2 * Setup.Line_Heigth,
Direction => Up));
Put_Line (Output.all, "}");
end loop;
end Make_Header_And_Grid;
procedure Make_WP_Separator
is
begin
Put_Line (Output.all,
Picture.Hline
(X =>
0.0,
Y =>
Current_V_Pos
+ Graphic_Setup.Font_Height
+ Graphic_Setup.Small_Interline,
Length =>
Month_Position (Graphic_Setup.Last_Month, Graphic_Setup)));
end Make_WP_Separator;
procedure Show_Deliverables (Wp : WPs.Project_WP)
is
use type Deliverables.Deliverable_Status;
package Instant_Sets is
new Ada.Containers.Ordered_Sets (Times.Instant);
Active_Months : Instant_Sets.Set;
H : constant Latex_Length :=
0.5 * To_Length (Graphic_Setup.Line_Heigth, Graphic_Setup);
begin
for Pos in Wp.All_Deliverables loop
if WPs.Element (Pos).Status /= Deliverables.Parent then
Active_Months.Include (WPs.Element (Pos).Due_On);
end if;
end loop;
for M of Active_Months loop
if M /= To_Be_Decided then
Put_Line (Output.all,
Picture.Put (X => Month_Position (Month_Number (Months (M)), Graphic_Setup),
Y => Current_V_Pos + Picture_Length (H / Graphic_Setup.Unit_Length),
What => "\GANTTdeliv{" & Image (0.9 * H) & "}"));
end if;
end loop;
end Show_Deliverables;
begin
Current_V_Pos := Graphic_Setup.Top_Position;
Make_Header_And_Grid (Graphic_Setup);
Current_V_Pos := Graphic_Setup.Top_WP;
for WP in Input.All_WPs loop
Make_WP_Separator;
Make_Label (Command => "\GANTTwpname",
Item => Element (WP).all,
Indent => 0.0);
Show_Busy_Time (Element (WP).all, "\GANTTwpBarStyle", 1.0);
if Parameters.Show_Deliverables then
Show_Deliverables (Element (Wp).all);
end if;
Next_Row;
for T in Element (WP).All_Tasks loop
Make_Label (Command => "\GANTTtaskname",
Item => WPs.Element (T).all,
Indent => Graphic_Setup.Task_X0);
Show_Busy_Time (WPs.Element (T).all, "\GANTTtaskBarStyle", Wps.Element (T).Intensity);
Next_Row;
end loop;
end loop;
Mark_Milestones;
end Make_GANTT;
procedure Print_Gantt (Input : EU_Projects.Projects.Project_Descriptor;
Target : Target_Spec;
Parameters : GANTT_Parameters)
is
-- use EU_Projects.Times;
--
-- We use as unit length in the picture environment 0.5em that is
-- (we measured) approximately the average letter length. 1em is
-- approximately the font size, so we use half the font size
-- as \unitlength.
--
Extended_Output : Extended_File := Open (Target);
Output : File_Access;
Longest_WP_Label : Natural;
Longest_Task_Label : Natural;
Wp_And_Task_Count : Natural;
Task_Indent : constant Positive := 1;
Last_Month : constant Month_Number :=
(if Input.Duration = To_Be_Decided
then
36
else
Month_Number (Months (Input.Duration)));
begin
if Extended_Output.Class = None then
return;
else
Output := To_File_Access (Extended_Output);
end if;
Longest_Label_Size (Input => Input,
WP_Label_Size => Longest_WP_Label,
Task_Label_Size => Longest_Task_Label,
Wp_And_Task_Count => Wp_And_Task_Count);
declare
--
-- We checked experimentally that the average width of a char
-- is half the font size. This allows us a crude estimation of
-- text size.
--
Average_Font_Size : constant Latex_Length := 0.5 * Parameters.Font_Size;
--
-- We choose the picture \unitlength so that the average letter
-- width is equal to Averave_Font_Picture_Size in picture units
--
Unit_Length : constant Latex_Length := 1.0 * Pt;
Font_Width : constant Picture_Length :=
Picture_Length (Average_Font_Size / Unit_Length);
Font_Height : constant Picture_Length :=
Picture_Length (Parameters.Font_Size / Unit_Length);
Picture_Width : constant Picture_Length :=
Picture_Length (Parameters.Textwidth / Unit_Length);
Pre_Skip : constant Picture_Length :=
Picture_Length (Parameters.Pre_Label_Skip * Parameters.Font_Size / Unit_Length);
Post_Skip : constant Picture_Length :=
Picture_Length (Parameters.Post_Label_Skip * Parameters.Font_Size / Unit_Length);
Longest_Label : constant Positive :=
Integer'Max (Longest_WP_Label, Task_Indent + Longest_Task_Label);
pragma Warnings (Off, "static fixed-point value is not a multiple of Small");
Label_Width : constant Picture_Length :=
Longest_Label * Font_Width;
Month_Width : constant Picture_Length :=
(Picture_Width - Label_Width) / Picture_Length (Last_Month);
Line_Height : constant Picture_Length :=
Pre_Skip + Font_Height + Post_Skip;
Header_Skip : constant Picture_Length :=
Picture_Length (Parameters.Header_Skip * Parameters.Font_Size / Unit_Length);
Tick_Length : constant Picture_Length :=
Picture_Length (Parameters.Tick_Length * Parameters.Font_Size / Unit_Length);
Header_Height : constant Picture_Length :=
Font_Height + Tick_Length + Header_Skip;
Grid_Height : constant Picture_Length :=
Wp_And_Task_Count * Line_Height;
Picture_Heigth : constant Picture_Length :=
Header_Height + Grid_Height + 3.0 * Line_Height;
Graphic_Setup : constant Graphic_Setup_Descriptor :=
Graphic_Setup_Descriptor'
(Task_X0 => Parameters.Task_Indent * Font_Width,
Month_Step => 3,
Label_Size => Label_Width,
Month_Width => Month_Width,
Line_Heigth => Line_Height,
Unit_Length => Unit_Length,
Last_Month => Last_Month,
Pre_Skip => Pre_Skip,
Post_Skip => Post_Skip,
Interline => Pre_Skip + Post_Skip,
Small_Interline => Pre_Skip * 0.25,
Top_Position => Picture_Heigth - Font_Height,
Total_Width => Picture_Width,
Grid_Height => Grid_Height,
Tick_Length => Tick_Length,
Top_WP => (Wp_And_Task_Count - 1 + 3) * Line_Height,
Header_Skip => Header_Skip,
Font_Height => Font_Height);
procedure Make_Picture (Output : File_Access) is
procedure Make_GANTT_Gateway (Output : File_Access) is
begin
Make_GANTT (Input, Output, Graphic_Setup, Parameters);
end Make_GANTT_Gateway;
begin
Put_Line (Output.all, "\setlength{\unitlength}{" & Image (Unit_Length, Pt) & "}");
Put (Output.all, "\rotategannt{");
Within_Picture (Output => Output,
Width => Picture_Width,
Heigth => Picture_Heigth,
Callback => Make_GANTT_Gateway'Access);
Put_Line (Output.all, "}");
end Make_Picture;
begin
Within (Output => Output,
Env_Name => "gantt",
Callback => Make_Picture'Access,
Parameter => "\GANTTcaption");
-- Put (Output.all, "\begin{gantt}{\GANTTcaption}");
-- Put (Output.all, "\centering");
-- Put_Line (Output.all, "\setlength{\unitlength}{" & Image (Unit_Length, Pt) & "}");
-- Within_Picture (Output => Output,
-- Width => Picture_Width,
-- Heigth => Picture_Heigth,
-- Callback => Make_GANTT_Gateway'Access);
-- Put (Output.all, "\end{gantt}");
end;
Close (Extended_Output);
end Print_Gantt;
-------------
-- Process --
-------------
overriding procedure Process
(Processor : Processor_Type;
Input : EU_Projects.Projects.Project_Descriptor)
is
begin
Print_Partners (Input, Processor.Partner_Target);
Print_WPs (Input, Processor.Wp_Target);
Print_WP_Summary (Input, Processor.WP_Summary_Target, Light);
Print_Milestones (Input, Processor.Milestone_Target, Full);
if True then
Print_Deliv_Summary (Input, Processor.Deliv_Summary_Target);
else
Print_Deliv_Summary_Low_Level (Input, Processor.Deliv_Summary_Target, Light);
end if;
Print_Compact_Deliv_Summary (Input, Processor.Deliv_Compact_Summary_Target);
Print_Effort_Summary (Input, Processor.Effort_Summary_Target);
if False then
Print_Gantt_Old (Input, Processor.Gantt_Target);
else
Print_Gantt (Input => Input,
Target => Processor.Gantt_Target,
Parameters => Processor.Gantt_Style);
end if;
end Process;
begin
Processor_Tables.Register (ID => To_Id ("latex"),
Tag => Processor_Type'Tag);
end Project_Processor.Processors.LaTeX;
|
------------------------------------------------------------------------------
-- --
-- Copyright (C) 2017, AdaCore --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions are --
-- met: --
-- 1. Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- 2. Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in --
-- the documentation and/or other materials provided with the --
-- distribution. --
-- 3. Neither the name of the copyright holder nor the names of its --
-- contributors may be used to endorse or promote products derived --
-- from this software without specific prior written permission. --
-- --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR --
-- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
-- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT --
-- LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, --
-- DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY --
-- THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT --
-- (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE --
-- OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
-- --
------------------------------------------------------------------------------
with NRF51_SVD.TIMER; use NRF51_SVD.TIMER;
package body nRF51.Timers is
-----------
-- Start --
-----------
procedure Start (This : in out Timer) is
begin
This.Periph.TASKS_START := 1;
end Start;
----------
-- Stop --
----------
procedure Stop (This : in out Timer) is
begin
This.Periph.TASKS_STOP := 1;
end Stop;
-----------
-- Clear --
-----------
procedure Clear (This : in out Timer) is
begin
This.Periph.TASKS_CLEAR := 1;
end Clear;
-------------------
-- Set_Prescaler --
-------------------
procedure Set_Prescaler
(This : in out Timer;
Prescaler : UInt4)
is
begin
This.Periph.PRESCALER.PRESCALER := Prescaler;
end Set_Prescaler;
--------------
-- Set_Mode --
--------------
procedure Set_Mode
(This : in out Timer;
Mode : Timer_Mode)
is
begin
This.Periph.MODE.MODE :=
(case Mode is
when Mode_Timer => NRF51_SVD.TIMER.Timer,
when Mode_Counter => NRF51_SVD.TIMER.Counter);
end Set_Mode;
-----------------
-- Set_Bitmode --
-----------------
procedure Set_Bitmode
(This : in out Timer;
Mode : Timer_Bitmode)
is
begin
This.Periph.BITMODE.BITMODE :=
(case Mode is
when Bitmode_8bit => BITMODE_BITMODE_Field_08Bit,
when Bitmode_16bit => BITMODE_BITMODE_Field_16Bit,
when Bitmode_24bit => BITMODE_BITMODE_Field_24Bit,
when Bitmode_32bit => BITMODE_BITMODE_Field_32Bit);
end Set_Bitmode;
-------------
-- Bitmode --
-------------
function Bitmode (This : Timer) return Timer_Bitmode is
begin
return
(case This.Periph.BITMODE.BITMODE is
when BITMODE_BITMODE_Field_08Bit => Bitmode_8bit,
when BITMODE_BITMODE_Field_16Bit => Bitmode_16bit,
when BITMODE_BITMODE_Field_24Bit => Bitmode_24bit,
when BITMODE_BITMODE_Field_32Bit => Bitmode_32bit);
end Bitmode;
-----------------------
-- Compare_Interrupt --
-----------------------
procedure Compare_Interrupt (This : in out Timer;
Chan : Timer_Channel;
Enable : Boolean)
is
begin
if Enable then
This.Periph.INTENSET.COMPARE.Arr (Integer (Chan)) := Set;
else
This.Periph.INTENSET.COMPARE.Arr (Integer (Chan)) := Intenset_Compare0_Field_Reset;
end if;
end Compare_Interrupt;
----------------------
-- Compare_Shortcut --
----------------------
procedure Compare_Shortcut (This : in out Timer;
Chan : Timer_Channel;
Stop : Boolean;
Clear : Boolean)
is
begin
case Chan is
when 0 =>
This.Periph.SHORTS.COMPARE0_CLEAR := (if Clear then Enabled else Disabled);
This.Periph.SHORTS.COMPARE0_STOP := (if Stop then Enabled else Disabled);
when 1 =>
This.Periph.SHORTS.COMPARE1_CLEAR := (if Clear then Enabled else Disabled);
This.Periph.SHORTS.COMPARE1_STOP := (if Stop then Enabled else Disabled);
when 2 =>
This.Periph.SHORTS.COMPARE2_CLEAR := (if Clear then Enabled else Disabled);
This.Periph.SHORTS.COMPARE2_STOP := (if Stop then Enabled else Disabled);
when 3 =>
This.Periph.SHORTS.COMPARE3_CLEAR := (if Clear then Enabled else Disabled);
This.Periph.SHORTS.COMPARE3_STOP := (if Stop then Enabled else Disabled);
end case;
end Compare_Shortcut;
-----------------
-- Set_Compare --
-----------------
procedure Set_Compare
(This : in out Timer;
Chan : Timer_Channel;
Compare : UInt32)
is
begin
This.Periph.CC (Integer (Chan)) := Compare;
end Set_Compare;
-------------
-- Capture --
-------------
procedure Capture (This : in out Timer;
Chan : Timer_Channel)
is
begin
This.Periph.TASKS_CAPTURE (Integer (Chan)) := 1;
end Capture;
-------------
-- Capture --
-------------
function Capture
(This : in out Timer;
Chan : Timer_Channel)
return UInt32
is
begin
This.Capture (Chan);
return This.CC_Register (Chan);
end Capture;
-----------------
-- CC_Register --
-----------------
function CC_Register (This : in out Timer;
Chan : Timer_Channel)
return UInt32
is
begin
return This.Periph.CC (Integer (Chan));
end CC_Register;
----------------
-- Start_Task --
----------------
function Start_Task (This : Timer)
return Task_Type
is (Task_Type (This.Periph.TASKS_START'Address));
---------------
-- Stop_Task --
---------------
function Stop_Task (This : Timer)
return Task_Type
is (Task_Type (This.Periph.TASKS_STOP'Address));
----------------
-- Count_Task --
----------------
function Count_Task (This : Timer)
return Task_Type
is (Task_Type (This.Periph.TASKS_COUNT'Address));
----------------
-- Clear_Task --
----------------
function Clear_Task (This : Timer)
return Task_Type
is (Task_Type (This.Periph.TASKS_CLEAR'Address));
------------------
-- Capture_Task --
------------------
function Capture_Task (This : Timer;
Chan : Timer_Channel)
return Task_Type
is (Task_Type (This.Periph.TASKS_CAPTURE (Integer (Chan))'Address));
-------------------
-- Compare_Event --
-------------------
function Compare_Event (This : Timer;
Chan : Timer_Channel)
return Event_Type
is (Event_Type (This.Periph.EVENTS_COMPARE (Integer (Chan))'Address));
end nRF51.Timers;
|
-- MIT License
-- Copyright (c) 2021 Stephen Merrony
-- 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.Streams.Stream_IO; use Ada.Streams.Stream_IO;
with Ada.Strings.Unbounded; use Ada.Strings.Unbounded;
with Interfaces; use Interfaces;
with DG_Types; use DG_Types;
with Simh_Tapes; use Simh_Tapes;
package Devices.Magtape6026 is
Max_Record_Size_W : constant Integer := 16_384;
Max_Record_Size_B : constant Integer := Max_Record_Size_W * 2;
Cmd_Mask : constant Word_T := 16#00b8#;
-- Cmd_Read_Bits : constant Word_T := 16#0000#;
-- Cmd_Rewind_Bits : constant Word_T := 16#0008#;
-- Cmd_Ctrl_Mode_Bits : constant Word_T := 16#0010#;
-- Cmd_Space_Fwd_Bits : constant Word_T := 16#0018#;
-- Cmd_Space_Rev_Bits : constant Word_T := 16#0020#;
-- Cmd_Wite_Bits : constant Word_T := 16#0028#;
-- Cmd_Write_EOF_Bits : constant Word_T := 16#0030#;
-- Cmd_Erase_Bits : constant Word_T := 16#0038#;
-- Cmd_Read_Nonstop_Bits : constant Word_T := 16#0080#;
-- Cmd_Unload_Bits : constant Word_T := 16#0088#;
-- Cmd_Drive_Mode_Bits : constant Word_T := 16#0090#;
type Cmd_T is (Read,Rewind,Ctrl_Mode,Space_Fwd,Space_Rev,Write,Write_EOF,Erase,Read_Nonstop,Unload,Drive_Mode);
type Cmd_Bits_T is array (Cmd_T range Cmd_T'Range) of Word_T;
Commands : constant Cmd_Bits_T := (
Read => 16#0000#,
Rewind => 16#0008#,
Ctrl_Mode => 16#0010#,
Space_Fwd => 16#0018#,
Space_Rev => 16#0020#,
Write => 16#0028#,
Write_EOF => 16#0030#,
Erase => 16#0038#,
Read_Nonstop=> 16#0080#,
Unload => 16#0088#,
Drive_Mode => 16#0090#
);
-- Cmd_Read : constant Integer := 0;
-- Cmd_Rewind : constant Integer := 1;
-- Cmd_Ctrl_Mode : constant Integer := 2;
-- Cmd_Space_Fwd : constant Integer := 3;
-- Cmd_Space_Rev : constant Integer := 4;
-- Cmd_Write : constant Integer := 5;
-- Cmd_Write_EOF : constant Integer := 6;
-- Cmd_Erase : constant Integer := 7;
-- Cmd_Read_Nonstop : constant Integer := 8;
-- Cmd_Unload : constant Integer := 9;
-- Cmd_Drive_Mode : constant Integer := 10;
SR_1_Error : constant Word_T := Shift_Left (1, 15);
SR_1_DataLate : constant Word_T := Shift_Left (1, 14);
SR_1_Rewinding : constant Word_T := Shift_Left (1, 13);
SR_1_Illegal : constant Word_T := Shift_Left (1, 12);
SR_1_HiDensity : constant Word_T := Shift_Left (1, 11);
SR_1_DataError : constant Word_T := Shift_Left (1, 10);
SR_1_EOT : constant Word_T := Shift_Left (1, 9);
SR_1_EOF : constant Word_T := Shift_Left (1, 8);
SR_1_BOT : constant Word_T := Shift_Left (1, 7);
SR_1_9Track : constant Word_T := Shift_Left (1, 6);
SR_1_BadTape : constant Word_T := Shift_Left (1, 5);
SR_1_Reserved : constant Word_T := Shift_Left (1, 4);
SR_1_StatusChanged : constant Word_T := Shift_Left (1, 3);
SR_1_WriteLock : constant Word_T := Shift_Left (1, 2);
SR_1_OddChar : constant Word_T := Shift_Left (1, 1);
SR_1_UnitReady : constant Word_T := 1;
SR_1_Readable : constant String := "ELRIHDEFB9TrSWOR";
SR_2_Error : constant Word_T := Shift_Left (1, 15);
SR_2_PE_Mode : constant Word_T := 1;
Max_Tapes : constant Integer := 7;
type Att_Arr is array (0 .. Max_Tapes) of Boolean;
type FN_Arr is array (0 .. Max_Tapes) of Unbounded_String;
type File_Arr is array (0 .. Max_Tapes) of File_Type;
type MT6026_Rec is record
-- DG device state
Mem_Addr_Reg : Phys_Addr_T;
Current_Cmd : Cmd_T;
Current_Unit : Natural;
Status_Reg_1, Status_Reg_2 : Word_T;
Neg_Word_Count : Integer_16;
Image_Attached : Att_Arr;
Image_Filename : FN_Arr;
SIMH_File : File_Arr;
end record;
type Status_Rec is record
Image_Attached : Att_Arr;
Image_Filename : FN_Arr;
Mem_Addr_Reg : Phys_Addr_T;
Current_Cmd : Cmd_T;
Status_Reg_1, Status_Reg_2 : Word_T;
end record;
protected Drives is
procedure Init;
procedure Reset;
procedure Attach
(Unit : in Natural; Image_Name : in String; OK : out Boolean);
procedure Detach (Unit : in Natural);
procedure Data_In (ABC : in IO_Reg_T; IO_Flag : in IO_Flag_T; Datum : out Word_T);
procedure Data_Out (Datum : in Word_T; ABC : in IO_Reg_T; IO_Flag : in IO_Flag_T);
function Get_Image_Name (Unit : in Natural) return String;
function Get_Status return Status_Rec;
procedure Load_TBOOT;
private
State : MT6026_Rec;
end Drives;
task Status_Sender is
entry Start;
end Status_Sender;
Unexpected_Return_Code : exception;
end Devices.Magtape6026;
|
--- config/src/aws-net-std__ipv4.adb.orig 2021-05-19 05:14:30 UTC
+++ config/src/aws-net-std__ipv4.adb
@@ -65,10 +65,6 @@ package body AWS.Net.Std is
-- Set the socket to the non-blocking mode.
-- AWS is not using blocking sockets internally.
- To_GNAT : constant array (Family_Type) of Sockets.Family_Type :=
- (Family_Inet => Sockets.Family_Inet,
- Family_Inet6 => Sockets.Family_Inet6,
- Family_Unspec => Sockets.Family_Inet);
-------------------
-- Accept_Socket --
@@ -141,9 +137,16 @@ package body AWS.Net.Std is
Option => (Sockets.Reuse_Address, Enabled => True));
end if;
- Sockets.Bind_Socket
- (Socket.S.FD,
- (To_GNAT (Family), Inet_Addr, Sockets.Port_Type (Port)));
+ case Family is
+ when Family_Inet | Family_Unspec =>
+ Sockets.Bind_Socket
+ (Socket.S.FD,
+ (Sockets.Family_Inet, Inet_Addr, Sockets.Port_Type (Port)));
+ when Family_Inet6 =>
+ Sockets.Bind_Socket
+ (Socket.S.FD,
+ (Sockets.Family_Inet6, Inet_Addr, Sockets.Port_Type (Port)));
+ end case;
exception
when E : Sockets.Socket_Error | Sockets.Host_Error =>
@@ -210,9 +213,16 @@ package body AWS.Net.Std is
Socket.S := new Socket_Hidden;
- Sock_Addr := (To_GNAT (Family),
- Get_Inet_Addr (Host, Passive => False),
- Sockets.Port_Type (Port));
+ case Family is
+ when Family_Inet | Family_Unspec =>
+ Sock_Addr := (Sockets.Family_Inet,
+ Get_Inet_Addr (Host, Passive => False),
+ Sockets.Port_Type (Port));
+ when Family_Inet6 =>
+ Sock_Addr := (Sockets.Family_Inet6,
+ Get_Inet_Addr (Host, Passive => False),
+ Sockets.Port_Type (Port));
+ end case;
Sockets.Create_Socket (Socket.S.FD);
Close_On_Exception := True;
|
limited with Parent_Ltd_With.Child_Full_View;
package Parent_Ltd_With is
type Symbol is abstract tagged limited private;
type Symbol_Access is access all Symbol'Class;
private
type Symbol is abstract tagged limited record
Comp : Integer;
end record;
end Parent_Ltd_With;
|
-- { dg-do compile }
package Renaming1 is
package Inner is
procedure PI (X : Integer);
end Inner;
procedure P (X : Integer) renames Inner.PI;
procedure P (X : Float);
pragma Convention (C, P); -- { dg-error "non-local entity" }
procedure Q (X : Float);
procedure Q (X : Integer) renames Inner.PI;
pragma Convention (C, Q); -- { dg-error "non-local entity" }
end Renaming1;
|
----------------------------------------------------------------------
--
-- Semaphore Package
--
-- written by
--
-- Edmond Schonberg
--
-- Ada Project
-- Courant Institute
-- New York University
-- 251 Mercer Street
-- New York, New York 10012
--
-----------------------------------------------------------------------
package SEMAPHORE is
generic
INIT: NATURAL; -- initial value of semaphore
package COUNT_SEMAPHORE is
task COUNTING_SEMAPHORE is --similar to Amoroso's counting semaphore
entry P;
entry V;
end COUNTING_SEMAPHORE;
end COUNT_SEMAPHORE;
task type BINARY_SEMAPHORE is -- implements binary semaphores as suggested by
entry P; -- Amoroso and Ingargiola.
entry V;
end BINARY_SEMAPHORE;
type ACCESS_BINARY_SEMAPHORE is access BINARY_SEMAPHORE;
end SEMAPHORE;
package body SEMAPHORE is
package body COUNT_SEMAPHORE is
task body COUNTING_SEMAPHORE is
S: INTEGER := INIT;
begin
loop -- run forever, waiting for P or V to be called
select
when S > 0 => accept P; S := S - 1;
or
accept V; S := S + 1; -- S > INIT implies that new resources
end select; -- became available that were originally
end loop; -- unknown. This is not like Amoroso's
end COUNTING_SEMAPHORE; -- version.
end COUNT_SEMAPHORE;
task body BINARY_SEMAPHORE is
begin
loop
select
accept P;
or
terminate ;
end select ;
accept V;
end loop;
end BINARY_SEMAPHORE;
end SEMAPHORE;
|
-- CE3115A.ADA
-- Grant of Unlimited Rights
--
-- Under contracts F33600-87-D-0337, F33600-84-D-0280, MDA903-79-C-0687,
-- F08630-91-C-0015, and DCA100-97-D-0025, the U.S. Government obtained
-- unlimited rights in the software and documentation contained herein.
-- Unlimited rights are defined in DFAR 252.227-7013(a)(19). By making
-- this public release, the Government intends to confer upon all
-- recipients unlimited rights equal to those held by the Government.
-- These rights include rights to use, duplicate, release or disclose the
-- released technical data and computer software in whole or in part, in
-- any manner and for any purpose whatsoever, and to have or permit others
-- to do so.
--
-- DISCLAIMER
--
-- ALL MATERIALS OR INFORMATION HEREIN RELEASED, MADE AVAILABLE OR
-- DISCLOSED ARE AS IS. THE GOVERNMENT MAKES NO EXPRESS OR IMPLIED
-- WARRANTY AS TO ANY MATTER WHATSOEVER, INCLUDING THE CONDITIONS OF THE
-- SOFTWARE, DOCUMENTATION OR OTHER INFORMATION RELEASED, MADE AVAILABLE
-- OR DISCLOSED, OR THE OWNERSHIP, MERCHANTABILITY, OR FITNESS FOR A
-- PARTICULAR PURPOSE OF SAID MATERIAL.
--*
-- OBJECTIVE:
-- CHECK THAT RESETTING ONE OF A MULTIPLE OF INTERNAL FILES
-- ASSOCIATED WITH THE SAME EXTERNAL FILE HAS NO EFFECT ON ANY
-- OF THE OTHER INTERNAL FILES.
-- APPLICABILITY CRITERIA:
-- THIS TEST APPLIES ONLY TO IMPLEMENTATIONS WHICH SUPPORT MULTIPLE
-- INTERNAL FILES ASSOCIATED WITH THE SAME EXTERNAL FILE AND
-- RESETTING OF THESE MULTIPLE INTERNAL FILES FOR TEXT FILES.
-- HISTORY:
-- DLD 08/16/82
-- SPS 11/09/82
-- JBG 06/04/84
-- EG 11/19/85 MADE TEST INAPPLICABLE IF CREATE USE_ERROR.
-- TBN 11/04/86 REVISED TEST TO OUTPUT A NON_APPLICABLE RESULT WHEN
-- FILES NOT SUPPORTED.
-- GMT 08/25/87 COMPLETELY REVISED.
-- EDS 12/01/97 ADD NAME_ERROR HANDLER TO OUTPUT NOT_APPLICABLE RESULT.
-- RLB 09/29/98 MADE MODIFICATION TO AVOID BUFFERING PROBLEMS.
WITH REPORT; USE REPORT;
WITH TEXT_IO; USE TEXT_IO;
PROCEDURE CE3115A IS
BEGIN
TEST ("CE3115A", "CHECK THAT RESETTING ONE OF A MULTIPLE OF " &
"INTERNAL FILES ASSOCIATED WITH THE SAME " &
"EXTERNAL FILE HAS NO EFFECT ON ANY OF THE " &
"OTHER INTERNAL FILES");
DECLARE
TXT_FILE_ONE : TEXT_IO.FILE_TYPE;
TXT_FILE_TWO : TEXT_IO.FILE_TYPE;
CH : CHARACTER := 'A';
INCOMPLETE : EXCEPTION;
PROCEDURE TXT_CLEANUP IS
FILE1_OPEN : BOOLEAN := IS_OPEN (TXT_FILE_ONE);
FILE2_OPEN : BOOLEAN := IS_OPEN (TXT_FILE_TWO);
BEGIN
IF FILE1_OPEN AND FILE2_OPEN THEN
CLOSE (TXT_FILE_TWO);
DELETE (TXT_FILE_ONE);
ELSIF FILE1_OPEN THEN
DELETE (TXT_FILE_ONE);
ELSIF FILE2_OPEN THEN
DELETE (TXT_FILE_TWO);
END IF;
EXCEPTION
WHEN TEXT_IO.USE_ERROR =>
NULL;
WHEN OTHERS =>
FAILED ("UNEXPECTED EXCEPTION RAISED " &
"IN CLEANUP - 1");
END TXT_CLEANUP;
BEGIN
BEGIN -- CREATE FIRST FILE
CREATE (TXT_FILE_ONE, OUT_FILE, LEGAL_FILE_NAME);
PUT (TXT_FILE_ONE, CH);
EXCEPTION
WHEN TEXT_IO.USE_ERROR =>
NOT_APPLICABLE ("USE_ERROR RAISED; CREATE OF " &
"EXTERNAL FILENAME IS NOT " &
"SUPPORTED - 2");
RAISE INCOMPLETE;
WHEN TEXT_IO.NAME_ERROR =>
NOT_APPLICABLE ("NAME_ERROR RAISED; CREATE OF " &
"EXTERNAL FILENAME IS NOT " &
"SUPPORTED - 3");
RAISE INCOMPLETE;
END; -- CREATE FIRST FILE
BEGIN -- OPEN SECOND FILE
OPEN (TXT_FILE_TWO, IN_FILE, LEGAL_FILE_NAME);
EXCEPTION
WHEN TEXT_IO.USE_ERROR =>
NOT_APPLICABLE ("MULTIPLE INTERNAL FILES ARE NOT " &
"SUPPORTED WHEN ONE IS MODE " &
"OUT_FILE AND THE OTHER IS MODE " &
"IN_FILE - 4" &
" - USE_ERROR RAISED ");
TXT_CLEANUP;
RAISE INCOMPLETE;
WHEN TEXT_IO.NAME_ERROR =>
NOT_APPLICABLE ("MULTIPLE INTERNAL FILES ARE NOT " &
"SUPPORTED WHEN ONE IS MODE " &
"OUT_FILE AND THE OTHER IS MODE " &
"IN_FILE - 4" &
" - NAME_ERROR RAISED ");
TXT_CLEANUP;
RAISE INCOMPLETE;
END; -- OPEN SECOND FILE
FLUSH (TXT_FILE_ONE); -- AVOID BUFFERING PROBLEMS.
CH := 'B';
GET (TXT_FILE_TWO, CH);
IF CH /= 'A' THEN
FAILED ("INCORRECT VALUE FOR GET - 5");
END IF;
BEGIN -- INITIALIZE FIRST FILE TO CHECK POINTER RESETTING
RESET (TXT_FILE_ONE);
IF MODE (TXT_FILE_ONE) /= OUT_FILE THEN
FAILED ("FILE WAS NOT RESET - 6");
END IF;
IF MODE (TXT_FILE_TWO) /= IN_FILE THEN
FAILED ("RESETTING OF ONE INTERNAL FILE " &
"AFFECTED THE OTHER INTERNAL FILE - 7");
END IF;
EXCEPTION
WHEN TEXT_IO.USE_ERROR =>
NOT_APPLICABLE ("RESETTING OF EXTERNAL FILE FOR " &
"OUT_FILE MODE IS " &
" NOT SUPPORTED - 8");
TXT_CLEANUP;
RAISE INCOMPLETE;
END; -- INITIALIZE FIRST FILE TO CHECK POINTER RESETTING
-- PERFORM SOME I/O ON THE FIRST FILE
PUT (TXT_FILE_ONE, 'C');
PUT (TXT_FILE_ONE, 'D');
PUT (TXT_FILE_ONE, 'E');
CLOSE (TXT_FILE_ONE);
BEGIN
OPEN (TXT_FILE_ONE, IN_FILE, LEGAL_FILE_NAME);
EXCEPTION
WHEN USE_ERROR =>
NOT_APPLICABLE ("MULTIPLE INTERNAL FILES NOT " &
"SUPPORTED WHEN BOTH FILES HAVE " &
"IN_FILE MODE - 9");
RAISE INCOMPLETE;
END;
GET (TXT_FILE_ONE, CH);
GET (TXT_FILE_ONE, CH);
BEGIN -- INITIALIZE SECOND FILE AND PERFORM SOME I/O
CLOSE (TXT_FILE_TWO);
OPEN (TXT_FILE_TWO, IN_FILE, LEGAL_FILE_NAME);
EXCEPTION
WHEN TEXT_IO.USE_ERROR =>
FAILED ("MULTIPLE INTERNAL FILES SHOULD STILL " &
"BE ALLOWED - 10");
TXT_CLEANUP;
RAISE INCOMPLETE;
END; -- INITIALIZE SECOND FILE AND PERFORM SOME I/O
BEGIN -- RESET FIRST FILE AND CHECK EFFECTS ON SECOND FILE
GET (TXT_FILE_TWO, CH);
IF CH /= 'C' THEN
FAILED ("INCORRECT VALUE FOR GET OPERATION - 11");
END IF;
RESET (TXT_FILE_ONE);
GET (TXT_FILE_TWO, CH);
IF CH /= 'D' THEN
FAILED ("RESETTING INDEX OF ONE TEXT FILE " &
"RESETS THE OTHER ASSOCIATED FILE - 12");
END IF;
EXCEPTION
WHEN TEXT_IO.USE_ERROR =>
FAILED ("RESETTING SHOULD STILL BE SUPPORTED - 13");
TXT_CLEANUP;
RAISE INCOMPLETE;
END; -- RESET FIRST FILE AND CHECK EFFECTS ON SECOND FILE
TXT_CLEANUP;
EXCEPTION
WHEN INCOMPLETE =>
NULL;
END;
RESULT;
END CE3115A;
|
with Solitaire_Operations.Text_Representation;
with Ada.Text_IO;
use Ada;
procedure Null_Key is
Deck : Solitaire_Operations.Deck_List := Solitaire_Operations.Standard_Deck;
begin -- Null_Key
Output : for I in Deck'range loop
Text_IO.Put (Item => Solitaire_Operations.Text_Representation.Short_Card_Name (Deck (I) ) );
end loop Output;
Text_IO.New_Line;
end Null_Key; |
package body STM32GD.USB is
function EP_Unused_Reset (BTable_Offset : Integer) return Integer is
begin
return BTable_Offset;
end EP_Unused_Reset;
procedure EP_Unused_Handler (Out_Transaction : Boolean) is
begin
null;
end EP_Unused_Handler;
procedure Set_TX_Status (EP : Endpoint_Range; Status : EP_Status) is
begin
USB_Endpoints (EP).STAT_TX := USB_Endpoints (EP).STAT_TX xor Status'Enum_Rep;
end Set_TX_Status;
procedure Set_RX_Status (EP : Endpoint_Range; Status : EP_Status) is
begin
USB_Endpoints (EP).STAT_RX := USB_Endpoints (EP).STAT_RX xor Status'Enum_Rep;
end Set_RX_Status;
procedure Set_TX_RX_Status (EP : Endpoint_Range; TX_Status : EP_Status; RX_Status : EP_Status) is
begin
USB_Endpoints (EP).STAT_TX := USB_Endpoints (EP).STAT_TX xor TX_Status'Enum_Rep;
USB_Endpoints (EP).STAT_RX := USB_Endpoints (EP).STAT_RX xor RX_Status'Enum_Rep;
end Set_TX_RX_Status;
end STM32GD.USB;
|
with Interfaces;
use Interfaces;
package ROSA.Tasks is
type States is (Running, Suspended, Waiting, Ready);
type Task_Status is (OK,
Not_Ready,
Not_Running);
type Tasking is private;
-- Initialise a new tasking structure.
procedure Create (Task_ID, Priority : in Unsigned_8; t : out Tasking);
-- Start up a ready task, putting it into the running state.
function Run (t : in Tasking) return Task_Status;
-- Suspend a running task.
function Suspend (t : in Tasking) return Task_Status;
private
type Tasking is record
Task_ID : Unsigned_8;
State : States;
Priority : Unsigned_8;
end record;
end ROSA.Tasks;
|
with Ada.Numerics.Float_Random;
package Taszkseged is
task type Szemafor( Max: Positive ) is
entry P;
entry V;
end Szemafor;
protected Veletlen is
procedure Reset;
entry General( F: out Float );
private
G: Ada.Numerics.Float_Random.Generator;
Inicializalt: Boolean := False;
end Veletlen;
end Taszkseged;
|
--
-- Copyright (C) 2022 Jeremy Grosser <jeremy@synack.me>
--
-- SPDX-License-Identifier: BSD-3-Clause
--
with Ada.Text_IO; use Ada.Text_IO;
with Interfaces;
package body Server is
use GNAT.Sockets;
Listen_Backlog : constant := 128;
function Hash (Element : GNAT.Sockets.Socket_Type)
return Ada.Containers.Hash_Type
is
begin
return Ada.Containers.Hash_Type (To_C (Element));
end Hash;
function "=" (Left, Right : GNAT.Sockets.Socket_Type)
return Boolean
is (To_C (Left) = To_C (Right));
procedure Bind
(Server : in out Socket_Server;
Host : String;
Port : String)
is
Non_Blocking : Request_Type := (Name => Non_Blocking_IO, Enabled => True);
Acceptable : aliased Epoll.Epoll_Event :=
(Flags =>
(Readable => True,
Error => True,
others => False),
others => <>);
Addresses : constant Address_Info_Array := Get_Address_Info
(Host => Host,
Service => Port,
Passive => True);
Socket : Socket_Type;
begin
Acceptable.Flags.Readable := True;
for Addr of Addresses loop
if Host = "" and Addr.Addr.Family = Family_Inet6 then
null;
else
Put_Line ("Bind " & Image (Addr.Addr));
Create_Socket
(Socket, Addr.Addr.Family, Addr.Mode, Addr.Level);
Set_Socket_Option
(Socket, Socket_Level, (Reuse_Address, True));
Set_Socket_Option
(Socket, IP_Protocol_For_TCP_Level, (No_Delay, True));
Control_Socket
(Socket, Non_Blocking);
Bind_Socket
(Socket, Addr.Addr);
Listen_Socket
(Socket, Listen_Backlog);
Acceptable.Data := Interfaces.Unsigned_64 (To_C (Socket));
Epoll.Control (Server.EP, Socket, Epoll.Add, Acceptable'Access);
Socket_Sets.Insert (Server.Listeners, Socket);
end if;
end loop;
end Bind;
procedure Listener_Event
(Server : in out Socket_Server;
Socket : Socket_Type;
Event : Epoll.Epoll_Event)
is
E : aliased Epoll.Epoll_Event :=
(Flags =>
(Readable => (Server.On_Readable /= null),
Writable => (Server.On_Writable /= null),
One_Shot => False,
Hang_Up => True,
Error => True,
others => False),
others => <>);
Client_Socket : Socket_Type;
Client_Address : Sock_Addr_Type;
begin
if Event.Flags.Readable then
Accept_Socket (Socket, Client_Socket, Client_Address);
Put_Line ("Accepted connection from " & Image (Client_Address));
E.Data := Interfaces.Unsigned_64 (To_C (Client_Socket));
Epoll.Control (Server.EP, Client_Socket, Epoll.Add, E'Access);
Server.Sessions.Insert (Client_Socket);
if Server.On_Connect /= null then
if Server.On_Connect.all (Client_Socket) = Should_Close then
Epoll.Control (Server.EP, Client_Socket, Epoll.Delete, null);
Close_Socket (Client_Socket);
Server.Sessions.Delete (Client_Socket);
return;
end if;
end if;
end if;
if Event.Flags.Error then
Put_Line ("Listener socket error!");
Epoll.Control (Server.EP, Socket, Epoll.Delete, null);
Close_Socket (Socket);
Server.Listeners.Delete (Socket);
end if;
end Listener_Event;
procedure Session_Event
(Server : in out Socket_Server;
Socket : Socket_Type;
Event : Epoll.Epoll_Event)
is
begin
if Event.Flags.Readable and Server.On_Readable /= null then
if Server.On_Readable.all (Socket) = Should_Close then
Epoll.Control (Server.EP, Socket, Epoll.Delete, null);
Close_Socket (Socket);
Server.Sessions.Delete (Socket);
Put_Line ("Socket closed by reader");
return;
end if;
end if;
if Event.Flags.Writable and Server.On_Writable /= null then
if Server.On_Writable.all (Socket) = Should_Close then
Epoll.Control (Server.EP, Socket, Epoll.Delete, null);
Close_Socket (Socket);
Server.Sessions.Delete (Socket);
Put_Line ("Socket closed by writer");
return;
end if;
end if;
if Event.Flags.Hang_Up then
Epoll.Control (Server.EP, Socket, Epoll.Delete, null);
Close_Socket (Socket);
Server.Sessions.Delete (Socket);
Put_Line ("Socket closed by client");
end if;
if Event.Flags.Error then
Epoll.Control (Server.EP, Socket, Epoll.Delete, null);
Close_Socket (Socket);
Server.Sessions.Delete (Socket);
Put_Line ("Socket closed by error");
end if;
end Session_Event;
procedure Poll
(Server : in out Socket_Server)
is
Socket : Socket_Type;
begin
for Event of Epoll.Wait (Server.EP, Max_Events => 128) loop
Socket := To_Ada (Integer (Event.Data));
if Server.Listeners.Contains (Socket) then
Listener_Event (Server, Socket, Event);
elsif Server.Sessions.Contains (Socket) then
Session_Event (Server, Socket, Event);
else
Put_Line ("Got event for unknown socket descriptor: " & Image (Socket));
end if;
end loop;
end Poll;
procedure Destroy
(Server : in out Socket_Server)
is
use Socket_Sets;
begin
for Socket of Server.Listeners loop
Close_Socket (Socket);
end loop;
Clear (Server.Listeners);
for Socket of Server.Sessions loop
Close_Socket (Socket);
end loop;
Clear (Server.Sessions);
-- Epoll.Close (Server.EP);
end Destroy;
end Server;
|
with
FLTK.Widgets.Boxes,
FLTK.Widgets.Groups.Color_Choosers;
package FLTK.Dialogs is
type Beep_Kind is
(Default_Beep, Message_Beep, Error_Beep,
Question_Beep, Password_Beep, Notification_Beep);
type Choice is (First, Second, Third);
type RGB_Float is new Long_Float range 0.0 .. 1.0;
type RGB_Int is mod 256;
procedure Alert
(Message : String);
-- function Ask
-- (Message : in String)
-- return Boolean;
procedure Beep
(Kind : in Beep_Kind);
function Three_Way_Choice
(Message, Button1, Button2, Button3 : in String)
return Choice;
function Text_Input
(Message : in String;
Default : in String := "")
return String;
procedure Message_Box
(Message : in String);
function Password
(Message : in String;
Default : in String := "")
return String;
function Color_Chooser
(Title : in String;
R, G, B : in out RGB_Float;
Mode : in FLTK.Widgets.Groups.Color_Choosers.Color_Mode :=
FLTK.Widgets.Groups.Color_Choosers.RGB)
return Boolean;
function Color_Chooser
(Title : in String;
R, G, B : in out RGB_Int;
Mode : in FLTK.Widgets.Groups.Color_Choosers.Color_Mode :=
FLTK.Widgets.Groups.Color_Choosers.RGB)
return Boolean;
function Dir_Chooser
(Message, Default : in String;
Relative : in Boolean := False)
return String;
function File_Chooser
(Message, Filter_Pattern, Default : in String;
Relative : in Boolean := False)
return String;
function Get_Hotspot
return Boolean;
procedure Set_Hotspot
(To : in Boolean);
procedure Set_Message_Font
(Font : in Font_Kind;
Size : in Font_Size);
function Get_Message_Icon
return FLTK.Widgets.Boxes.Box_Reference;
procedure Set_Message_Title
(To : in String);
procedure Set_Message_Title_Default
(To : in String);
private
Icon_Box : aliased FLTK.Widgets.Boxes.Box;
pragma Inline (Alert);
-- pragma Inline (Ask);
pragma Inline (Beep);
pragma Inline (Three_Way_Choice);
pragma Inline (Text_Input);
pragma Inline (Message_Box);
pragma Inline (Password);
pragma Inline (Color_Chooser);
pragma Inline (Dir_Chooser);
pragma Inline (File_Chooser);
pragma Inline (Get_Hotspot);
pragma Inline (Set_Hotspot);
pragma Inline (Set_Message_Font);
pragma Inline (Get_Message_Icon);
pragma Inline (Set_Message_Title);
pragma Inline (Set_Message_Title_Default);
end FLTK.Dialogs;
|
------------------------------------------------------------------------------
-- G E L A A S I S --
-- ASIS implementation for Gela project, a portable Ada compiler --
-- http://gela.ada-ru.org --
-- - - - - - - - - - - - - - - - --
-- Read copyright and license at the end of this file --
------------------------------------------------------------------------------
-- $Revision: 209 $ $Date: 2013-11-30 21:03:24 +0200 (Сб., 30 нояб. 2013) $
with Nodes;
with Tokens;
with Gela.Containers.Lists;
with Ada.Text_IO;
with Gramar_Items; use Gramar_Items;
with Gramar_Items.Code;
with Ada.Strings.Unbounded;
package body Generate is
Output : Ada.Text_IO.File_Type;
procedure Print_Token (Name : in String);
procedure Print_Rule (Item : in Rule);
procedure Print_Token_Rule (Name : in String);
Max_Position : constant := 20;
subtype Item_Position is Positive range 1 .. Max_Position;
subtype Iteration is Natural range 0 .. Max_Position;
type Positions_List is array (Item_Position) of Iteration;
function "&"
(Left : Positions_List;
Right : Item_Position) return Positions_List;
Empty_List : constant Positions_List := (others => 0);
procedure Print_Sequence
(Item : in Sequence;
Rule_Name : in String;
Name_Of_List : in String := "");
procedure Print_Sequence
(Item : in Sequence;
Rule_Name : in String;
Start_From : in Item_Position;
Processed_Positions : in Positions_List;
Name_Of_List : in String;
First_In_Rule : in boolean);
procedure Print_Sequence_Code
(Item : in Sequence;
Processed_Positions : in Positions_List;
Name_Of_List : in String);
procedure Print_List_Code
(Item : in Sequence;
Rule_Name : in String;
Processed_Positions : in Positions_List;
Name_Of_List : in String);
procedure Print_Infix_Code
(Seq : in Sequence;
Rule_Name : in String;
Processed_Positions : in Positions_List;
Name_Of_List : in String);
procedure Print_Infix_Code1
(Seq : in Sequence;
Rule_Name : in String;
Processed_Positions : in Positions_List;
Name_Of_List : in String);
procedure Print_Infix_Code2
(Processed_Positions : in Positions_List);
procedure Print_Infix_Code3
(Seq : in Sequence;
Name_Of_List : in String);
procedure Print_Infix_Code4
(Processed_Positions : in Positions_List;
List_Index : in Positive := 2);
procedure Print_Infix_Code5
(Seq : in Sequence;
Rule_Name : in String;
Processed_Positions : in Positions_List;
Name_Of_List : in String);
procedure Print_Infix_Code6
(Seq : in Sequence;
Name_Of_List : in String);
procedure Print_Infix_Code7
(Seq : in Sequence;
Name_Of_List : in String);
procedure Create_Alt_Nodes
(Seq : in Sequence;
Processed_Positions : in Positions_List);
function Count_Total_Positions (Item : Sequence) return Natural;
function Include
(Positions : Positions_List;
Position : Item_Position) return Boolean;
function Include
(Positions : Positions_List;
Position : Item_Position) return Iteration;
procedure Put_Line (Text : String) is
begin
Ada.Text_IO.Put_Line (Output, Text);
end Put_Line;
procedure New_Line;
procedure Put (Text : String) is
begin
Ada.Text_IO.Put (Output, Text);
end Put;
procedure Options_And_Lists_In_Sequence (Item : Sequence);
procedure Print_List (Item : in List);
procedure Print_Option (Item : in Option);
procedure Create_Node_Code
(Item : in Sequence;
Processed_Positions : in Positions_List;
Name_Of_List : in String;
Node_Type_Name : in String);
procedure Print_Code
(Child : Item'Class;
Parent_Type : String;
Parent_Name : String;
Index : Positive;
Force : Boolean);
procedure Print_Wrap_Code
(Child : Wrapper;
Last : Boolean);
function Find_Attribute
(Child : Item'Class;
Node_Type_Name : String) return String;
function Find_Attribute
(Name : String;
Type_Name : String;
User_Attr : String;
Node_Type_Name : String) return String;
function Find_Procedure
(Node_Name : String;
Attr_Name : String) return String;
function Indent return String;
procedure Step_Indent (Step : Integer);
-- Append "_r" for pragma and range names
function Translate_Name (Name : String) return String;
function Is_List (Item : Sequence) return Boolean;
function Is_List_Type (Node_Name : String) return Boolean;
function Quote (Text : String; Double : Boolean) return String;
function Processed
(Seq : in Sequence;
Processed_Positions : in Positions_List;
Index : Positive) return Boolean;
function Real_Index
(Seq : in Sequence;
Processed_Positions : in Positions_List;
Index : in Positive;
Name_Of_List : in String) return Positive;
function New_Node (Type_Name : String) return String;
procedure Set_Name_Image_Code
(Name : in String;
Child : in Item'Class;
Index : in Positive := 1;
Proc : in String := "Set_Name_Image";
In_Quote : in Boolean := True);
function Is_First
(Seq : in Sequence;
Index : in Positive;
Processed_Positions : in Positions_List) return Boolean;
function Is_Last
(Seq : in Sequence;
Index : in Positive;
Processed_Positions : in Positions_List) return Boolean;
function Just_Keywords (Item : in Sequence) return Boolean;
package U renames Ada.Strings.Unbounded;
use type U.Unbounded_String;
package Unbounded_String_Lists is
new Gela.Containers.Lists (U.Unbounded_String);
Printed_Lists : Unbounded_String_Lists.List;
Printed_Options : Unbounded_String_Lists.List;
List_Phase : Boolean := False;
---------
-- "&" --
---------
function "&"
(Left : Positions_List;
Right : Item_Position) return Positions_List
is
Result : Positions_List := Left;
begin
Result (Right) := Result (Right) + 1;
return Result;
end "&";
procedure All_Tokens is
procedure Print_Tokens is new Tokens.For_Each_Name (Print_Token);
begin
Print_Tokens;
end All_Tokens;
procedure Print_Token (Name : in String) is
begin
Put_Line ("%token " & Name & "_Token");
end Print_Token;
procedure Start_Rule is
begin
New_Line;
Put_Line ("%start compilation");
New_Line;
Put_Line ("{");
Put_Line (" subtype YYSTYPE is Asis.Element;");
Put_Line (" subtype T is YYSTYPE;");
Put_Line ("}");
New_Line;
Put_Line ("%%");
New_Line;
end Start_Rule;
procedure All_Rules is
begin
for I in 1 .. Rule_Count loop
Print_Rule (Get_Rule (I));
end loop;
end All_Rules;
procedure Print_Rule (Item : in Rule) is
Rule_Name : constant String := Translate_Name (Name (Item));
begin
if Code.Skip_Rule (Rule_Name) then
return;
end if;
Put_Line (Rule_Name & " :");
for I in 1 .. Count (Item) loop
if I > 1 then
Put (" |");
else
Put (" ");
end if;
Print_Sequence (Get_Alternative (Item, I), Rule_Name);
end loop;
Put_Line (";");
New_Line;
end Print_Rule;
procedure Print_Sequence
(Item : in Sequence;
Rule_Name : in String;
Name_Of_List : in String := "") is
begin
Print_Sequence
(Item, Rule_Name, 1, Empty_List, Name_Of_List, True);
end Print_Sequence;
procedure Print_Sequence
(Item : in Sequence;
Rule_Name : in String;
Start_From : in Item_Position;
Processed_Positions : in Positions_List;
Name_Of_List : in String;
First_In_Rule : in Boolean)
is
Item_Count : constant Natural := Count (Item);
procedure Expand_Option
(Item : Option;
Nested : Boolean)
is
Seq : constant Sequence := Items (Item);
begin
for I in 1 .. Count (Seq) loop
declare
Child : Gramar_Items.Item'Class renames Get_Item (Seq, I).all;
begin
if Child in Reference then
Put(" " & Translate_Name (Item_Name (Child)));
elsif Child in Option then
if Nested then
Put(" " & Item_Name (Child));
end if;
elsif Child in Keyword or Child in Delimiter then
Put(" " & Item_Name (Child));
else
Put (Rule_Name &
"!!!! List not supported in inlined option !!!");
raise Constraint_Error;
end if;
end;
end loop;
end Expand_Option;
use type Ada.Text_IO.Count;
First : Boolean := First_In_Rule;
begin
for I in Start_From .. Item_Count loop
declare
Child : Gramar_Items.Item'Class renames Get_Item (Item, I).all;
begin
-- Expand nested option
if Child in Option then
if Count (Option (Child)) > Include (Processed_Positions, I)
then
Print_Sequence -- recursive call
(Item => Item,
Rule_Name => Rule_Name,
Start_From => I,
Processed_Positions => Processed_Positions & I,
Name_Of_List => Name_Of_List,
First_In_Rule => First);
First := False;
elsif Inline_Option (Option (Child)) then
case Count_Total_Positions (Items (Option (Child))) is
when 0 =>
null;
when 1 =>
Print_Sequence -- recursive call
(Item => Item,
Rule_Name => Rule_Name,
Start_From => I + 1,
Processed_Positions => Processed_Positions & I & I,
Name_Of_List => Name_Of_List,
First_In_Rule => First);
First := False;
when others =>
raise Constraint_Error;
end case;
end if;
elsif Child in List then
Print_Sequence -- recursive call
(Item => Item,
Rule_Name => Rule_Name,
Start_From => I + 1,
Processed_Positions => Processed_Positions & I,
Name_Of_List => Name_Of_List,
First_In_Rule => First);
First := False;
end if;
end;
end loop;
if First then
First := False;
else
Put (" |");
end if;
if Name_Of_List /= "" then
Put(" " & Name_Of_List);
end if;
for I in 1 .. Item_Count loop
declare
Child : Gramar_Items.Item'Class renames Get_Item (Item, I).all;
Print : Boolean := False;
begin
if (Child in List or Child in Option) then
if Include (Processed_Positions, I) then
Print := True;
end if;
else
Print := True;
end if;
if Print then
if Ada.Text_IO.Col > 55 then
New_Line;
Put (" ");
end if;
if Child in Reference then
Put(" " & Translate_Name (Item_Name (Child)));
elsif Child in Option then
if Count (Option (Child)) > 1 then
declare
Index : constant Positive :=
Include (Processed_Positions, I);
Seq : constant Sequence :=
Items (Option (Child), Index);
begin
if Count (Seq) /= 1 then
Put (Rule_Name &
"!!!! Multiple items in option alternative");
raise Constraint_Error;
end if;
Put(" " & Item_Name (Get_Item (Seq, 1).all));
end;
elsif Inline_Option (Option (Child)) then
Expand_Option
(Option (Child),
Include (Processed_Positions, I) > 1);
else
Put(" " & Item_Name (Child));
end if;
else
Put(" " & Item_Name (Child));
end if;
end if;
end;
end loop;
New_Line;
Print_Sequence_Code (Item, Processed_Positions, Name_Of_List);
end Print_Sequence;
function Count_Total_Positions (Item : Sequence) return Natural is
Counted : Natural := 0;
begin
for I in 1 .. Count (Item) loop
declare
Child : Gramar_Items.Item'Class renames Get_Item (Item, I).all;
-- No more 1 nested inline options supported
Nested : Integer range 0 .. 1;
begin
if Child in List then
Counted := Counted + 1;
elsif Child in Option then
if Inline_Option (Option (Child)) then
Nested := Count_Total_Positions (Items (Option (Child)));
Counted := Counted + Nested;
end if;
Counted := Counted + 1;
end if;
end;
end loop;
return Counted;
end Count_Total_Positions;
function Include
(Positions : Positions_List;
Position : Item_Position) return Boolean is
begin
return Positions (Position) > 0;
end Include;
function Include
(Positions : Positions_List;
Position : Item_Position) return Iteration is
begin
return Positions (Position);
end Include;
procedure New_Line is
begin
Ada.Text_IO.New_Line (Output);
end New_Line;
procedure Options_And_Lists is
begin
List_Phase := True;
for I in 1 .. Rule_Count loop
declare
Current_Rule : constant Rule := Get_Rule (I);
begin
for J in 1 .. Count (Current_Rule) loop
Options_And_Lists_In_Sequence
(Get_Alternative (Current_Rule, J));
end loop;
end;
end loop;
-- Put_Line ("%%");
end Options_And_Lists;
procedure Options_And_Lists_In_Sequence (Item : Sequence) is
begin
for I in 1 .. Count (Item) loop
declare
Child : Gramar_Items.Item'Class renames Get_Item (Item, I).all;
begin
if Child in List then
Print_List (List (Child));
Options_And_Lists_In_Sequence (Items (List (Child)));
elsif Child in Option then
if not Inline_Option (Option (Child)) then
Print_Option (Option (Child));
Options_And_Lists_In_Sequence (Items (Option (Child)));
end if;
end if;
end;
end loop;
end Options_And_Lists_In_Sequence;
procedure Print_List (Item : in List) is
use Unbounded_String_Lists;
Name : constant String := Item_Name (Item);
begin
if not Contains (Printed_Lists, U.To_Unbounded_String (Name)) then
Put_Line (Name & " :");
Put (" ");
Print_Sequence (Items (Item), Name, Name);
Put (" |");
Print_Sequence (Items (Item), Name);
Put_Line (";");
New_Line;
Append (Printed_Lists, U.To_Unbounded_String (Name));
end if;
end Print_List;
procedure Print_Option (Item : in Option) is
use Unbounded_String_Lists;
Name : constant String := Item_Name (Item);
begin
if Separate_Option (Item) then
if not Contains (Printed_Options, U.To_Unbounded_String (Name)) then
Put_Line (Name & " :");
Put (" ");
Print_Sequence (Items (Item), Name);
for J in 2 .. Count (Item) loop
Put (" |");
Print_Sequence (Items (Item, J), Name);
end loop;
Put_Line (";");
New_Line;
Append (Printed_Options, U.To_Unbounded_String (Name));
end if;
end if;
end Print_Option;
function Is_List (Item : Sequence) return Boolean is
R_Name : constant String := Rule_Name (Item);
N_Name : constant String := Node_Name (Item);
begin
if R_Name'Length > 4 and then
R_Name (R_Name'Last - 4 .. R_Name'Last) = "_list" then
return True;
end if;
if N_Name'Length > 4 and then
N_Name (N_Name'Last - 4 .. N_Name'Last) = ".List" then
return True;
end if;
return False;
end Is_List;
procedure Print_Sequence_Code
(Item : in Sequence;
Processed_Positions : in Positions_List;
Name_Of_List : in String)
is
R_Name : constant String := Rule_Name (Item);
begin
if Infix (Item) /= "" then
Print_Infix_Code (Item, R_Name, Processed_Positions, Name_Of_List);
return;
end if;
if False and then List_Phase and then Is_List (Item) then
Print_List_Code (Item, R_Name, Processed_Positions, Name_Of_List);
return;
end if;
if Pass_Through (Item) then
declare
First_Reference : constant Natural := Find_First_Reference (Item);
begin
if First_Reference = 0 and Count (Item) > 1 then
declare
Child : Gramar_Items.Item'Class
renames Get_Item (Item, 2).all;
begin
if Child in Option and Include (Processed_Positions, 2) then
Put_Line ("{$$ := $2;}");
end if;
end;
elsif First_Reference /= 0 then
declare
Index : constant Positive := Real_Index (Item,
Processed_Positions, First_Reference, Name_Of_List);
begin
Put_Line ("{ $$ := $" & To_String (Index) & ";}");
end;
end if;
end;
return;
end if;
if True_Node (Item) /= "" then
declare
Index : constant Natural := Choise_Item_Index (Item);
Child : Gramar_Items.Item'Class renames Get_Item (Item, Index).all;
begin
if Child not in Option or else
Include (Processed_Positions, Index) then
Create_Alt_Nodes (Item, Processed_Positions);
return;
end if;
end;
end if;
if R_Name = "statement" then
if Include (Processed_Positions, 1) then
Put_Line ("{");
Put_Line (Indent & "Set_Label_Names (Statement_Node ($2.all), $1);");
Put_Line (Indent & "$$ := $2;");
Put_Line ("}");
end if;
elsif Node_Name (Item) /= "" then
Put_Line ("{");
Create_Node_Code (Item, Processed_Positions, Name_Of_List, "");
Put_Line ("}");
end if;
end Print_Sequence_Code;
procedure Create_Node_Code
(Item : in Sequence;
Processed_Positions : in Positions_List;
Name_Of_List : in String;
Node_Type_Name : in String)
is
function Get_Node_Name
(Wrap : Wrapper) return String is
begin
if Top (Wrap) and Node_Type_Name /= "" then
return Node_Type_Name;
end if;
for I in 1 .. Count (Item) loop
declare
Child : Gramar_Items.Item'Class renames Get_Item (Item, I).all;
begin
if Child in Option and then
Include (Processed_Positions, I) and then
Alternative_Node_Name (Option (Child)) /= "" and then
Parent (Child) = Wrap then
return Alternative_Node_Name (Option (Child));
end if;
end;
end loop;
return Node_Name (Wrap);
end Get_Node_Name;
procedure Expand_Option_Code
(Item : in Option;
Parent_Node : in String;
Parent_Name : in String;
Index : in out Positive;
With_Nested : in Boolean)
is
Seq : Sequence := Items (Item);
begin
for I in 1 .. Count (Seq) loop
declare
Child : Gramar_Items.Item'Class renames Get_Item (Seq, I).all;
begin
if Child not in Option or With_Nested then
Print_Code (Child, Parent_Node, Parent_Name,
Index, Force => False);
Index := Index + 1;
end if;
end;
end loop;
-- Back to last element
Index := Index - 1;
end Expand_Option_Code;
Index : Positive := 1;
Force : Boolean := Just_Keywords (Item);
Last : array (0 .. Wrap_Count (Item)) of Natural := (others => 0);
begin
Put_Line (Indent & "declare");
Step_Indent (+1);
for I in 1 .. Wrap_Count (Item) loop
declare
Wrap : constant Wrapper := Get_Wrapper (Item, I);
Node : constant String := Get_Node_Name (Wrap);
Ptr : constant String := Nodes.Get_Pointer_Name (Node);
Ind : constant Natural := Item_Index (Wrap);
begin
if Node /= "" then
Put_Line (Indent & Object_Name (Wrap) & " : constant " &
Ptr & " :=");
if Ind > 0 and then
Processed (Item, Processed_Positions, Ind) then
Put_Line (Indent & " " & Ptr & " ($" &
To_String (Real_Index (Item,
Processed_Positions,
Ind,
Name_Of_List)) &
");");
elsif I = 1 and Name_Of_List /= "" then
Put_Line (Indent & " " & Ptr & " ($1);");
else
Put_Line (Indent & " " & New_Node (Node) & ";");
end if;
end if;
end;
end loop;
Step_Indent (-1);
Put_Line (Indent & "begin");
Step_Indent (+1);
declare
Wrap : constant Wrapper := Get_Wrapper (Item, 1);
begin
if Rule_Name (Item) = "compilation" then
Put_Line (Indent & "Last_Compilation := T (" &
Object_Name (Wrap) & ");");
else
Put_Line (Indent & "$$ := YYSTYPE (" & Object_Name (Wrap) & ");");
end if;
end;
if Name_Of_List /= "" then
Index := Index + 1;
end if;
for I in 1 .. Count (Item) loop
declare
Child : Gramar_Items.Item'Class
renames Get_Item (Item, I).all;
Wrap : constant Wrapper := Parent (Child);
Parent_Node : constant String := Get_Node_Name (Wrap);
Parent_Name : constant String := Object_Name (Wrap);
Wrap_Index : constant Natural := Item_Index (Wrap);
begin
if Processed (Item, Processed_Positions, I) then
if I /= Wrap_Index then
if Parent_Node /= "Primary_Token_Lists.List_Node" then
Force := False;
end if;
if (not Is_List_Type (Parent_Node) or Child in Keyword)
and then Is_First (Item, I, Processed_Positions)
and then Parent_Node /= ""
then
Put_Line (Indent & "Set_Start_Position (" & Parent_Name &
".all, Start_Position ($" &
To_String (Index) & ".all));");
end if;
if Parent_Node /= "Primary_Token_Lists.List_Node" then
Force := False;
end if;
if Child in Option and then
(Inline_Option (Option (Child)) or
Count (Option (Child)) > 1)
then
if Inline_Option (Option (Child)) then
Expand_Option_Code
(Option (Child),
Parent_Node,
Parent_Name,
Index,
Include (Processed_Positions, I) > 1);
else
declare
Ind : constant Positive :=
Include (Processed_Positions, I);
Seq : constant Sequence :=
Items (Option (Child), Ind);
Cld : Gramar_Items.Item'Class
renames Get_Item (Seq, 1).all;
begin
Print_Code
(Cld, Parent_Node, Parent_Name, Index, Force);
end;
end if;
else
Print_Code
(Child, Parent_Node, Parent_Name, Index, Force);
end if;
if (not Is_List_Type (Parent_Node) or Child in Keyword)
and then Is_Last (Item, I, Processed_Positions)
and then Parent_Node /= ""
then
Put_Line (Indent & "Set_End_Position (" & Parent_Name &
".all, End_Position ($" &
To_String (Index) & ".all));");
Last (Wrapper_Index (Wrap)) := Index;
end if;
else
Last (Wrapper_Index (Wrap)) := Index;
end if;
Index := Index + 1;
end if;
end;
end loop;
for I in reverse 2 .. Wrap_Count (Item) loop
declare
Wrap : constant Wrapper := Get_Wrapper (Item, I);
Up : constant Wrapper := Parent (Wrap);
begin
Print_Wrap_Code (Wrap, Last (I) > Last (Wrapper_Index (Up)));
end;
end loop;
Step_Indent (-1);
Put_Line (Indent & "end;");
end Create_Node_Code;
procedure Print_Code
(Child : Item'Class;
Parent_Type : String;
Parent_Name : String;
Index : Positive;
Force : Boolean)
is
use Nodes;
Attr : constant String := Find_Attribute (Child, Parent_Type);
Proc : constant String := Find_Procedure (Parent_Type, Attr);
Trait_Attr : constant String :=
Find_Attribute (Parent_Type, "Trait_Kind");
begin
if Trait_Attr /= "" then
declare
Proc : constant String := Find_Procedure (Parent_Type, Trait_Attr);
Trait : constant String := Trait_Name (Child);
begin
if Trait /= "" then
Put_Line (Indent & Proc & " (" & Parent_Name &
".all, " & Trait & ");");
end if;
end;
end if;
if not Force and Attr = "" and
(Child in Keyword or Child in Delimiter) then
return;
end if;
if Proc /= "" then
if Attribute_Type (Parent_Type, Attr) = "Unbounded_Wide_String" then
Set_Name_Image_Code (Parent_Name, Child, Index, Proc,
In_Quote => Parent_Type = "Operator_Symbol_Node");
elsif Attribute_Type (Parent_Type, Attr) = "Boolean" then
Put_Line (Indent & Proc & " (" & Parent_Name & ".all, True);");
elsif Attribute_Type (Parent_Type, Attr) = "Mode_Kinds" then
Put_Line (Indent & Proc & " (" & Parent_Name &
".all, Modes.$" & To_String (Index) &
");");
elsif Value (Child) /= "" then
Put_Line (Indent & Proc & " (" & Parent_Name &
".all, " & Value (Child) & ");");
else
Put_Line (Indent & Proc & " (" & Parent_Name & ".all, $" &
To_String (Index) & ");");
end if;
end if;
end Print_Code;
Current_Indent : Positive := 3;
function Indent return String is
Spaces : constant String := " ";
begin
return Spaces (1 .. Current_Indent);
end;
procedure Step_Indent (Step : Integer) is
begin
Current_Indent := Current_Indent + 3 * Step;
end Step_Indent;
procedure Token_Rules is
procedure Print_Token_Rules is
new Tokens.For_Each_Name (Print_Token_Rule);
begin
Print_Token_Rules;
end Token_Rules;
procedure Print_Token_Rule (Name : in String) is
Length : constant Natural := Tokens.Token_Length (Name);
Cap : constant String := Nodes.Capitalise (Name);
begin
Put_Line (Name & " : " & Name & "_Token");
Put_Line (" {");
Put_Line (Indent & "declare");
if Length /= 0 then
Put_Line (Indent &
" Node : constant Token_Ptr := " &
"Token_Stack (yy.tos)'Unchecked_Access;");
Put_Line (Indent & "begin");
Put_Line (Indent & " Init_Token (Element => Node.all,");
Put_Line (Indent & " Line => Get_Current_Line,");
Put_Line (Indent & " Column => Get_Current_Column,");
Put_Line (Indent & " Image => Raw_Value,");
Put_Line (Indent &
" Length => " & To_String (Length) & ");");
else
declare
Node_Type_Name : constant String := Cap & "_Node";
Ptr : constant String := Nodes.Get_Pointer_Name (Node_Type_Name);
Attr : constant String := Nodes.Find_Attr_By_Type
(Node_Type_Name, "Unbounded_Wide_String");
Proc : constant String := Nodes.Find_Procedure
(Node_Type_Name, Attr);
begin
Put_Line (Indent & " Node : constant " & Ptr &
" := " & New_Node (Node_Type_Name) & ";");
Put_Line (Indent & " Value : constant Wide_String := Get_Token_Value;");
Put_Line (Indent & "begin");
Put_Line (Indent & " " & Proc & " (Node.all, Value);");
Put_Line (Indent & " Set_Start_Position (Node.all,");
Put_Line (Indent & " (Get_Current_Line, Get_Current_Column - Value'Length));");
Put_Line (Indent & " Set_End_Position (Node.all,");
Put_Line (Indent & " (Get_Current_Line, Get_Current_Column - 1));");
end;
end if;
Put_Line (Indent & " $$ := YYSTYPE (Node);");
Put_Line (Indent & "end;");
Put_Line (" };");
New_Line;
end Print_Token_Rule;
function Find_Attribute
(Child : Item'Class;
Node_Type_Name : String) return String
is
Name : constant String := Item_Name (Child);
Type_Name : constant String := Node_Name (Child);
U_Attr : constant String := User_Attr (Child);
begin
return Find_Attribute (Name, Type_Name, U_Attr, Node_Type_Name);
end Find_Attribute;
function Find_Attribute
(Name : String;
Type_Name : String;
User_Attr : String;
Node_Type_Name : String) return String
is
begin
-- Put_Line ("Find_Attribute: " & Name);
-- Put_Line ("Type_Name: " & Type_Name);
if User_Attr /= "" and then
Nodes.Find_Attribute (Node_Type_Name, User_Attr) /= "" then
return User_Attr;
end if;
if User_Attr /= "" then
declare
By_Type : constant String := Nodes.Find_Attr_By_Type
(Node_Type_Name, User_Attr);
begin
if By_Type /= "" then
return By_Type;
end if;
end;
end if;
if Type_Name /= "" then
declare
Stripped : String renames Type_Name (1 .. Type_Name'Last - 5);
By_Name : constant String := Nodes.Find_Attribute
(Node_Type_Name, Stripped);
By_Type : constant String := Nodes.Find_Attr_By_Type
(Node_Type_Name, Stripped);
begin
if By_Name /= "" then
return By_Name;
end if;
if By_Type /= "" then
return By_Type;
end if;
end;
end if;
declare
Attr_Type : constant String := Nodes.Capitalise (Name);
By_Name : constant String := Nodes.Find_Attribute
(Node_Type_Name, Attr_Type);
By_Type : constant String := Nodes.Find_Attr_By_Type
(Node_Type_Name, Attr_Type);
begin
if By_Name /= "" then
return By_Name;
end if;
if By_Type /= "" then
return By_Type;
end if;
end;
if Name = "identifier" then
declare
Attr_Name : constant String := Nodes.Find_Attr_By_Type
(Node_Type_Name, "Unbounded_Wide_String");
begin
if Attr_Name /= "" then
return Attr_Name;
end if;
end;
end if;
if Name = "defining_identifier" or Name = "defining_identifier_list" then
declare
Attr_Name : constant String := Nodes.Find_Attribute
(Node_Type_Name, "Name");
begin
if Attr_Name /= "" then
return Attr_Name;
end if;
end;
end if;
return "";
end Find_Attribute;
-- Append "_r" for pragma and range names
function Translate_Name (Name : String) return String is
begin
if Name = "pragma" or Name = "range" or Name = "body" then
return Name & "_r";
else
return Name;
end if;
end Translate_Name;
function Just_Keywords (Item : in Sequence) return Boolean is
begin
for I in 1 .. Count (Item) loop
declare
Child : Gramar_Items.Item'Class renames Get_Item (Item, I).all;
begin
if Child in Option then
if not Just_Keywords (Items (Option (Child))) then
return False;
end if;
elsif not (Child in Delimiter or Child in Keyword) then
return False;
end if;
end;
end loop;
return Count (Item) /= 0;
end Just_Keywords;
procedure Print_List_Code
(Item : in Sequence;
Rule_Name : in String;
Processed_Positions : in Positions_List;
Name_Of_List : in String)
is
Index : Positive := 1;
Node : constant String := Node_Name (Item);
Node_Ptr : constant String := Nodes.Get_Pointer_Name (Node);
Create : constant String := Create_Node (Get_Item (Item, 1).all);
Crt_Ptr : constant String := Nodes.Get_Pointer_Name (Create);
Proc : constant String := Find_Procedure (Node, "");
begin
if Node = "" then
return;
end if;
Put_Line ("{");
Put_Line (Indent & "declare");
if Name_Of_List /= "" then
Put_Line (Indent & " New_Node : constant " & Node_Ptr & " :=");
Put_Line (Indent & " " & Node_Ptr & " ($1);");
Index := Index + 1;
else
Put_Line (Indent & " New_Node : constant " & Node_Ptr & " :=");
Put_Line (Indent & " " & New_Node (Node) & ";");
end if;
if Create /= "" then
Put_Line (Indent & " Crt_Node : constant " & Crt_Ptr & " :=");
Put_Line (Indent & " " & New_Node (Create) & ";");
end if;
Put_Line (Indent & "begin");
Step_Indent (+1);
Put_Line (Indent & "$$ := YYSTYPE (New_Node);");
if Create /= "" then
Put_Line (Indent & "Add (New_Node.all, Crt_Node);");
end if;
for I in 1 .. Count (Item) loop
declare
Child : Gramar_Items.Item'Class renames Get_Item (Item, I).all;
Print : Boolean := True;
begin
if (Child in List or Child in Option) then
if not Include (Processed_Positions, I) then
Print := False;
end if;
elsif (Child in Delimiter or Child in Keyword)
and then not Just_Keywords (Item)
then
Index := Index + 1;
Print := False;
end if;
if Print then
if Proc /= "" then
Put_Line (Indent & Proc & " (New_Node.all, $"
& To_String (Index) & ");");
end if;
Index := Index + 1;
end if;
end;
end loop;
Step_Indent (-1);
Put_Line (Indent & "end;");
Put_Line ("}");
end Print_List_Code;
procedure Print_Infix_Code
(Seq : in Sequence;
Rule_Name : in String;
Processed_Positions : in Positions_List;
Name_Of_List : in String)
is
First : Item'Class renames Get_Item (Seq, 1).all;
begin
if Count (Seq) = 5 then
Print_Infix_Code5 (Seq, Rule_Name, Processed_Positions, Name_Of_List);
elsif Count (Seq) = 4 then
Print_Infix_Code1 (Seq, Rule_Name, Processed_Positions, Name_Of_List);
elsif First in Option then
Print_Infix_Code2 (Processed_Positions);
elsif Count (Seq) = 2 and (First in Keyword or First in Delimiter) then
Print_Infix_Code3 (Seq, Name_Of_List);
elsif First in Keyword then
Print_Infix_Code6 (Seq, Name_Of_List);
else
declare
Second : Item'Class renames Get_Item (Seq, 2).all;
begin
if Second in Reference then
Print_Infix_Code7 (Seq, Name_Of_List);
else
Print_Infix_Code4 (Processed_Positions);
end if;
end;
end if;
end Print_Infix_Code;
-- ref keyword ref list
procedure Print_Infix_Code1
(Seq : in Sequence;
Rule_Name : in String;
Processed_Positions : in Positions_List;
Name_Of_List : in String)
is
Child : Item'Class renames Get_Item (Seq, 2).all;
begin
if Include (Processed_Positions, 4) then
Put_Line ("{");
Put_Line (Indent & "declare");
Put_Line (Indent & " Call_Node1 : constant Function_Call_Ptr :=");
Put_Line (Indent & " New_Function_Call_Node (The_Context);");
Put_Line (Indent & " Arg_List : constant Primary_Association_Lists.List :=");
Put_Line (Indent & " Primary_Association_Lists.New_List (The_Context);");
Put_Line (Indent & " Arg_Node1 : constant Parameter_Association_Ptr :=");
Put_Line (Indent & " New_Parameter_Association_Node (The_Context);");
Put_Line (Indent & " Arg_Node2 : constant Parameter_Association_Ptr :=");
Put_Line (Indent & " New_Parameter_Association_Node (The_Context);");
Put_Line (Indent & " Call_Node2 : constant Function_Call_Ptr :=");
Put_Line (Indent & " Function_Call_Ptr ($4);");
Put_Line (Indent & " Sym_Node : constant Operator_Symbol_Ptr :=");
Put_Line (Indent & " New_Operator_Symbol_Node (The_Context);");
Put_Line (Indent & "begin");
Step_Indent (+1);
Put_Line (Indent & "Set_Actual_Parameter (Arg_Node1.all, $1);");
Put_Line (Indent & "Set_Start_Position (Arg_Node1.all, Start_Position ($1.all));");
Put_Line (Indent & "Set_End_Position (Arg_Node1.all, End_Position ($1.all));");
Put_Line (Indent & "Set_Actual_Parameter (Arg_Node2.all, $3);");
Put_Line (Indent & "Set_Start_Position (Arg_Node2.all, Start_Position ($3.all));");
Put_Line (Indent & "Set_End_Position (Arg_Node2.all, End_Position ($3.all));");
Put_Line (Indent & "Primary_Association_Lists.Add (Arg_List.all, T (Arg_Node1));");
Put_Line (Indent & "Primary_Association_Lists.Add (Arg_List.all, T (Arg_Node2));");
Put_Line (Indent & "Set_Function_Call_Parameters (Call_Node1.all, T (Arg_List));");
Put_Line (Indent & "Set_Start_Position (Call_Node1.all, Start_Position ($1.all));");
Put_Line (Indent & "Set_End_Position (Call_Node1.all, End_Position ($3.all));");
Set_Name_Image_Code ("Sym_Node", Child, 2);
Put_Line (Indent & "Set_Start_Position (Sym_Node.all, Start_Position ($2.all));");
Put_Line (Indent & "Set_End_Position (Sym_Node.all, End_Position ($2.all));");
Put_Line (Indent & "Set_Prefix (Call_Node1.all, T (Sym_Node));");
Put_Line (Indent & "Set_Is_Prefix_Call (Call_Node1.all, False);");
Put_Line (Indent & "Push_Argument (Call_Node2.all, T (Call_Node1));");
Put_Line (Indent & "Set_Start_Position (Call_Node2.all, Start_Position ($1.all));");
Put_Line (Indent & "$$ := YYSTYPE (Call_Node2);");
Step_Indent (-1);
Put_Line (Indent & "end;");
Put_Line ("}");
else
Put_Line ("{");
Put_Line (Indent & "declare");
Put_Line (Indent & " Call_Node1 : constant Function_Call_Ptr :=");
Put_Line (Indent & " New_Function_Call_Node (The_Context);");
Put_Line (Indent & " Arg_List : constant Primary_Association_Lists.List :=");
Put_Line (Indent & " Primary_Association_Lists.New_List (The_Context);");
Put_Line (Indent & " Arg_Node1 : constant Parameter_Association_Ptr :=");
Put_Line (Indent & " New_Parameter_Association_Node (The_Context);");
Put_Line (Indent & " Arg_Node2 : constant Parameter_Association_Ptr :=");
Put_Line (Indent & " New_Parameter_Association_Node (The_Context);");
Put_Line (Indent & " Sym_Node : constant Operator_Symbol_Ptr :=");
Put_Line (Indent & " New_Operator_Symbol_Node (The_Context);");
Put_Line (Indent & "begin");
Step_Indent (+1);
Put_Line (Indent & "Set_Actual_Parameter (Arg_Node1.all, $1);");
Put_Line (Indent & "Set_Start_Position (Arg_Node1.all, Start_Position ($1.all));");
Put_Line (Indent & "Set_End_Position (Arg_Node1.all, End_Position ($1.all));");
Put_Line (Indent & "Set_Actual_Parameter (Arg_Node2.all, $3);");
Put_Line (Indent & "Set_Start_Position (Arg_Node2.all, Start_Position ($3.all));");
Put_Line (Indent & "Set_End_Position (Arg_Node2.all, End_Position ($3.all));");
Put_Line (Indent & "Primary_Association_Lists.Add (Arg_List.all, T (Arg_Node1));");
Put_Line (Indent & "Primary_Association_Lists.Add (Arg_List.all, T (Arg_Node2));");
Put_Line (Indent & "Set_Function_Call_Parameters (Call_Node1.all, T (Arg_List));");
Put_Line (Indent & "Set_Start_Position (Call_Node1.all, Start_Position ($1.all));");
Put_Line (Indent & "Set_End_Position (Call_Node1.all, End_Position ($3.all));");
Put_Line (Indent & "Set_Prefix (Call_Node1.all, T (Sym_Node));");
Set_Name_Image_Code ("Sym_Node", Child, 2);
Put_Line (Indent & "Set_Start_Position (Sym_Node.all, Start_Position ($2.all));");
Put_Line (Indent & "Set_End_Position (Sym_Node.all, End_Position ($2.all));");
Put_Line (Indent & "Set_Is_Prefix_Call (Call_Node1.all, False);");
Put_Line (Indent & "$$ := YYSTYPE (Call_Node1);");
Step_Indent (-1);
Put_Line (Indent & "end;");
Put_Line ("}");
end if;
end Print_Infix_Code1;
-- opt(unar_op) ref list
procedure Print_Infix_Code2
(Processed_Positions : in Positions_List)
is
begin
if not Include (Processed_Positions, 1) then
Print_Infix_Code4 (Processed_Positions, 3);
return;
end if;
if Include (Processed_Positions, 3) then
Put_Line ("{");
Put_Line (Indent & "declare");
Put_Line (Indent & " Call_Node1 : constant Function_Call_Ptr :=");
Put_Line (Indent & " New_Function_Call_Node (The_Context);");
Put_Line (Indent & " Arg_List : constant Primary_Association_Lists.List :=");
Put_Line (Indent & " Primary_Association_Lists.New_List (The_Context);");
Put_Line (Indent & " Arg_Node1 : constant Parameter_Association_Ptr :=");
Put_Line (Indent & " New_Parameter_Association_Node (The_Context);");
Put_Line (Indent & " Call_Node2 : constant Function_Call_Ptr :=");
Put_Line (Indent & " Function_Call_Ptr ($3);");
Put_Line (Indent & "begin");
Put_Line (Indent & " Set_Actual_Parameter (Arg_Node1.all, $2);");
Put_Line (Indent & " Set_Start_Position (Arg_Node1.all, Start_Position ($2.all));");
Put_Line (Indent & " Set_End_Position (Arg_Node1.all, End_Position ($2.all));");
Put_Line (Indent & " Primary_Association_Lists.Add (Arg_List.all, T (Arg_Node1));");
Put_Line (Indent & " Set_Function_Call_Parameters (Call_Node1.all, T (Arg_List));");
Put_Line (Indent & " Set_Prefix (Call_Node1.all, $1);");
Put_Line (Indent & " Set_Start_Position (Call_Node1.all, Start_Position ($1.all));");
Put_Line (Indent & " Set_End_Position (Call_Node1.all, End_Position ($2.all));");
Put_Line (Indent & " Set_Is_Prefix_Call (Call_Node1.all, False);");
Put_Line (Indent & " Push_Argument (Call_Node2.all, T (Call_Node1));");
Put_Line (Indent & " Set_Start_Position (Call_Node2.all, Start_Position ($1.all));");
Put_Line (Indent & " $$ := YYSTYPE (Call_Node2);");
Put_Line (Indent & "end;");
Put_Line ("}");
else
Put_Line ("{");
Put_Line (Indent & "declare");
Put_Line (Indent & " Call_Node : constant Function_Call_Ptr :=");
Put_Line (Indent & " New_Function_Call_Node (The_Context);");
Put_Line (Indent & " Arg_List : constant Primary_Association_Lists.List :=");
Put_Line (Indent & " Primary_Association_Lists.New_List (The_Context);");
Put_Line (Indent & " Arg_Node : constant Parameter_Association_Ptr :=");
Put_Line (Indent & " New_Parameter_Association_Node (The_Context);");
Put_Line (Indent & "begin");
Put_Line (Indent & " Set_Actual_Parameter (Arg_Node.all, $2);");
Put_Line (Indent & " Set_Start_Position (Arg_Node.all, Start_Position ($2.all));");
Put_Line (Indent & " Set_End_Position (Arg_Node.all, End_Position ($2.all));");
Put_Line (Indent & " Primary_Association_Lists.Add (Arg_List.all, T (Arg_Node));");
Put_Line (Indent & " Set_Function_Call_Parameters (Call_Node.all, T (Arg_List));");
Put_Line (Indent & " Set_Prefix (Call_Node.all, $1);");
Put_Line (Indent & " Set_Start_Position (Call_Node.all, Start_Position ($1.all));");
Put_Line (Indent & " Set_End_Position (Call_Node.all, End_Position ($2.all));");
Put_Line (Indent & " Set_Is_Prefix_Call (Call_Node.all, False);");
Put_Line (Indent & " $$ := YYSTYPE (Call_Node);");
Put_Line (Indent & "end;");
Put_Line ("}");
end if;
end Print_Infix_Code2;
-- keyword ref
-- delimiter ref
procedure Print_Infix_Code3
(Seq : in Sequence;
Name_Of_List : in String)
is
First : Item'Class renames Get_Item (Seq, 1).all;
Name : constant String := Item_Name (First);
begin
if Name_Of_List = "" then
Put_Line ("{");
Put_Line (Indent & "declare");
Put_Line (Indent & " Call_Node : constant Function_Call_Ptr :=");
Put_Line (Indent & " New_Function_Call_Node (The_Context);");
Put_Line (Indent & " Arg_List : constant Primary_Association_Lists.List :=");
Put_Line (Indent & " Primary_Association_Lists.New_List (The_Context);");
Put_Line (Indent & " Arg_Node : constant Parameter_Association_Ptr :=");
Put_Line (Indent & " New_Parameter_Association_Node (The_Context);");
Put_Line (Indent & " Sym_Node : constant Operator_Symbol_Ptr :=");
Put_Line (Indent & " New_Operator_Symbol_Node (The_Context);");
if Name = "and" or Name = "or" or Name = "xor" or Name = "double_star" then
Put_Line (Indent & " Arg_2_Node : constant Parameter_Association_Ptr :=");
Put_Line (Indent & " New_Parameter_Association_Node (The_Context);");
Put_Line (Indent & "begin");
Step_Indent (+1);
-- make placeholder for first argument
Put_Line (Indent & "Primary_Association_Lists.Add (Arg_List.all, T (Arg_2_Node));");
else
Put_Line (Indent & "begin");
Step_Indent (+1);
end if;
Put_Line (Indent & "Set_Actual_Parameter (Arg_Node.all, $2);");
Put_Line (Indent & "Set_Start_Position (Arg_Node.all, Start_Position ($2.all));");
Put_Line (Indent & "Set_End_Position (Arg_Node.all, End_Position ($2.all));");
Put_Line (Indent & "Primary_Association_Lists.Add (Arg_List.all, T (Arg_Node));");
Put_Line (Indent & "Set_Function_Call_Parameters (Call_Node.all, T (Arg_List));");
Put_Line (Indent & "Set_Start_Position (Arg_Node.all, Start_Position ($1.all));");
Put_Line (Indent & "Set_End_Position (Arg_Node.all, End_Position ($2.all));");
Put_Line (Indent & "Set_Prefix (Call_Node.all, T (Sym_Node));");
Set_Name_Image_Code ("Sym_Node", First);
Put_Line (Indent & "Set_Start_Position (Sym_Node.all, Start_Position ($1.all));");
Put_Line (Indent & "Set_End_Position (Sym_Node.all, End_Position ($1.all));");
Put_Line (Indent & "Set_Start_Position (Call_Node.all, Start_Position ($1.all));");
Put_Line (Indent & "Set_End_Position (Call_Node.all, End_Position ($2.all));");
Put_Line (Indent & "Set_Is_Prefix_Call (Call_Node.all, False);");
Put_Line (Indent & "$$ := YYSTYPE (Call_Node);");
Step_Indent (-1);
Put_Line (Indent & "end;");
Put_Line ("}");
else
Put_Line ("{");
Put_Line (Indent & "declare");
Put_Line (Indent & " Arg_Node1 : constant Parameter_Association_Ptr :=");
Put_Line (Indent & " New_Parameter_Association_Node (The_Context);");
Put_Line (Indent & " Arg_Node2 : constant Parameter_Association_Ptr :=");
Put_Line (Indent & " New_Parameter_Association_Node (The_Context);");
Put_Line (Indent & " Arg_List : constant Primary_Association_Lists.List :=");
Put_Line (Indent & " Primary_Association_Lists.New_List (The_Context);");
Put_Line (Indent & " Call_Node : constant Function_Call_Ptr :=");
Put_Line (Indent & " New_Function_Call_Node (The_Context);");
Put_Line (Indent & " Sym_Node : constant Operator_Symbol_Ptr :=");
Put_Line (Indent & " New_Operator_Symbol_Node (The_Context);");
Put_Line (Indent & "begin");
Step_Indent (+1);
Put_Line (Indent & "Set_Actual_Parameter (Arg_Node1.all, $1);");
Put_Line (Indent & "Set_Start_Position (Arg_Node1.all, Start_Position ($1.all));");
Put_Line (Indent & "Set_End_Position (Arg_Node1.all, End_Position ($1.all));");
Put_Line (Indent & "Set_Actual_Parameter (Arg_Node2.all, $3);");
Put_Line (Indent & "Set_Start_Position (Arg_Node2.all, Start_Position ($3.all));");
Put_Line (Indent & "Set_End_Position (Arg_Node2.all, End_Position ($3.all));");
Put_Line (Indent & "Primary_Association_Lists.Add (Arg_List.all, T (Arg_Node1));");
Put_Line (Indent & "Primary_Association_Lists.Add (Arg_List.all, T (Arg_Node2));");
Put_Line (Indent & "Set_Function_Call_Parameters (Call_Node.all, T (Arg_List));");
Put_Line (Indent & "Set_Start_Position (Call_Node.all, Start_Position ($1.all));");
Put_Line (Indent & "Set_End_Position (Call_Node.all, End_Position ($3.all));");
Set_Name_Image_Code ("Sym_Node", First, 2);
Put_Line (Indent & "Set_Start_Position (Sym_Node.all, Start_Position ($2.all));");
Put_Line (Indent & "Set_End_Position (Sym_Node.all, End_Position ($2.all));");
Put_Line (Indent & "Set_Prefix (Call_Node.all, T (Sym_Node));");
Put_Line (Indent & "Set_Is_Prefix_Call (Call_Node.all, False);");
Put_Line (Indent & "$$ := YYSTYPE (Call_Node);");
Step_Indent (-1);
Put_Line (Indent & "end;");
Put_Line ("}");
end if;
end Print_Infix_Code3;
-- ref (list|option)
procedure Print_Infix_Code4
(Processed_Positions : in Positions_List;
List_Index : in Positive := 2)
is
begin
if not Include (Processed_Positions, List_Index) then
return;
end if;
Put_Line ("{");
Put_Line (Indent & "declare");
Put_Line (Indent & " Call_Node : constant Function_Call_Ptr :=");
Put_Line (Indent & " Function_Call_Ptr ($2);");
Put_Line (Indent & "begin");
Put_Line (Indent & " Push_Argument (Call_Node.all, $1);");
Put_Line (Indent & " Set_Start_Position (Call_Node.all, Start_Position ($1.all));");
Put_Line (Indent & " $$ := YYSTYPE (Call_Node);");
Put_Line (Indent & "end;");
Put_Line ("}");
end Print_Infix_Code4;
-- ref keyword keyword ref list
procedure Print_Infix_Code5
(Seq : in Sequence;
Rule_Name : in String;
Processed_Positions : in Positions_List;
Name_Of_List : in String)
is
Node : constant String := Node_Name (Seq);
Node_Ptr : constant String := Nodes.Get_Pointer_Name (Node);
begin
if Include (Processed_Positions, 5) then
Put_Line ("{");
Put_Line (Indent & "declare");
Put_Line (Indent & " Node1 : constant " & Node_Ptr & ":=");
Put_Line (Indent & " " & New_Node (Node) & ";");
Put_Line (Indent & " Node2 : constant " & Node_Ptr & ":=");
Put_Line (Indent & " " & Node_Ptr & " ($5);");
Put_Line (Indent & "begin");
Put_Line (Indent & " Set_Short_Circuit_Operation_Left_Expression (Node1.all, $1);");
Put_Line (Indent & " Set_Start_Position (Node1.all, Start_Position ($1.all));");
Put_Line (Indent & " Set_End_Position (Node1.all, End_Position ($4.all));");
Put_Line (Indent & " Set_Short_Circuit_Operation_Right_Expression (Node1.all, $4);");
Put_Line (Indent & " Push_Argument (Node2.all, T (Node1));");
Put_Line (Indent & " Set_Start_Position (Node2.all, Start_Position ($1.all));");
Put_Line (Indent & " $$ := YYSTYPE (Node2);");
Put_Line (Indent & "end;");
Put_Line ("}");
else
Put_Line ("{");
Put_Line (Indent & "declare");
Put_Line (Indent & " Node1 : constant " & Node_Ptr & ":=");
Put_Line (Indent & " " & New_Node (Node) & ";");
Put_Line (Indent & "begin");
Put_Line (Indent & " Set_Short_Circuit_Operation_Left_Expression (Node1.all, $1);");
Put_Line (Indent & " Set_Short_Circuit_Operation_Right_Expression (Node1.all, $4);");
Put_Line (Indent & " Set_Start_Position (Node1.all, Start_Position ($1.all));");
Put_Line (Indent & " Set_End_Position (Node1.all, End_Position ($4.all));");
Put_Line (Indent & " $$ := YYSTYPE (Node1);");
Put_Line (Indent & "end;");
Put_Line ("}");
end if;
end Print_Infix_Code5;
-- list : keyword keyword ref
procedure Print_Infix_Code6
(Seq : in Sequence;
Name_Of_List : in String)
is
Node : constant String := Node_Name (Seq);
Node_Ptr : constant String := Nodes.Get_Pointer_Name (Node);
begin
if Name_Of_List /= "" then
Put_Line ("{");
Put_Line (Indent & "declare");
Put_Line (Indent & " Node1 : constant " & Node_Ptr & ":=");
Put_Line (Indent & " " & New_Node (Node) & ";");
Put_Line (Indent & "begin");
Put_Line (Indent & " Set_Short_Circuit_Operation_Left_Expression (Node1.all, $1);");
Put_Line (Indent & " Set_Short_Circuit_Operation_Right_Expression (Node1.all, $4);");
Put_Line (Indent & " Set_Start_Position (Node1.all, Start_Position ($1.all));");
Put_Line (Indent & " Set_End_Position (Node1.all, End_Position ($4.all));");
Put_Line (Indent & " $$ := YYSTYPE (Node1);");
Put_Line (Indent & "end;");
Put_Line ("}");
else
Put_Line ("{");
Put_Line (Indent & "declare");
Put_Line (Indent & " Node1 : constant " & Node_Ptr & ":=");
Put_Line (Indent & " " & New_Node (Node) & ";");
Put_Line (Indent & "begin");
Put_Line (Indent & " Set_Short_Circuit_Operation_Right_Expression (Node1.all, $3);");
Put_Line (Indent & " Set_Start_Position (Node1.all, Start_Position ($1.all));");
Put_Line (Indent & " Set_End_Position (Node1.all, End_Position ($3.all));");
Put_Line (Indent & " $$ := YYSTYPE (Node1);");
Put_Line (Indent & "end;");
Put_Line ("}");
end if;
end Print_Infix_Code6;
-- list: ref (oper) ref (term)
procedure Print_Infix_Code7
(Seq : in Sequence;
Name_Of_List : in String) is
begin
if Name_Of_List /= "" then
Put_Line ("{");
Put_Line (Indent & "declare");
Put_Line (Indent & " Arg_Node1 : constant Parameter_Association_Ptr :=");
Put_Line (Indent & " New_Parameter_Association_Node (The_Context);");
Put_Line (Indent & " Arg_Node2 : constant Parameter_Association_Ptr :=");
Put_Line (Indent & " New_Parameter_Association_Node (The_Context);");
Put_Line (Indent & " Arg_List : constant Primary_Association_Lists.List :=");
Put_Line (Indent & " Primary_Association_Lists.New_List (The_Context);");
Put_Line (Indent & " Call_Node : constant Function_Call_Ptr :=");
Put_Line (Indent & " New_Function_Call_Node (The_Context);");
Put_Line (Indent & "begin");
Put_Line (Indent & " Set_Actual_Parameter (Arg_Node1.all, $1);");
Put_Line (Indent & " Set_Start_Position (Arg_Node1.all, Start_Position ($1.all));");
Put_Line (Indent & " Set_End_Position (Arg_Node1.all, End_Position ($1.all));");
Put_Line (Indent & " Set_Actual_Parameter (Arg_Node2.all, $3);");
Put_Line (Indent & " Set_Start_Position (Arg_Node2.all, Start_Position ($3.all));");
Put_Line (Indent & " Set_End_Position (Arg_Node2.all, End_Position ($3.all));");
Put_Line (Indent & " Primary_Association_Lists.Add (Arg_List.all, T (Arg_Node1));");
Put_Line (Indent & " Primary_Association_Lists.Add (Arg_List.all, T (Arg_Node2));");
Put_Line (Indent & " Set_Function_Call_Parameters (Call_Node.all, T (Arg_List));");
Put_Line (Indent & " Set_Start_Position (Call_Node.all, Start_Position ($1.all));");
Put_Line (Indent & " Set_End_Position (Call_Node.all, End_Position ($3.all));");
Put_Line (Indent & " Set_Prefix (Call_Node.all, $2);");
Put_Line (Indent & " Set_Is_Prefix_Call (Call_Node.all, False);");
Put_Line (Indent & " $$ := YYSTYPE (Call_Node);");
Put_Line (Indent & "end;");
Put_Line ("}");
else
Put_Line ("{");
Put_Line (Indent & "declare");
Put_Line (Indent & " Arg_Node1 : constant Parameter_Association_Ptr :=");
Put_Line (Indent & " New_Parameter_Association_Node (The_Context);");
Put_Line (Indent & " Arg_Node2 : constant Parameter_Association_Ptr :=");
Put_Line (Indent & " New_Parameter_Association_Node (The_Context);");
Put_Line (Indent & " Arg_List : constant Primary_Association_Lists.List :=");
Put_Line (Indent & " Primary_Association_Lists.New_List (The_Context);");
Put_Line (Indent & " Call_Node : constant Function_Call_Ptr :=");
Put_Line (Indent & " New_Function_Call_Node (The_Context);");
Put_Line (Indent & "begin");
Put_Line (Indent & " Set_Actual_Parameter (Arg_Node2.all, $2);");
Put_Line (Indent & " Set_Start_Position (Arg_Node2.all, Start_Position ($2.all));");
Put_Line (Indent & " Set_End_Position (Arg_Node2.all, End_Position ($2.all));");
Put_Line (Indent & " Primary_Association_Lists.Add (Arg_List.all, T (Arg_Node1));");
Put_Line (Indent & " Primary_Association_Lists.Add (Arg_List.all, T (Arg_Node2));");
Put_Line (Indent & " Set_Function_Call_Parameters (Call_Node.all, T (Arg_List));");
Put_Line (Indent & " Set_Start_Position (Call_Node.all, Start_Position ($1.all));");
Put_Line (Indent & " Set_End_Position (Call_Node.all, End_Position ($2.all));");
Put_Line (Indent & " Set_Prefix (Call_Node.all, $1);");
Put_Line (Indent & " Set_Is_Prefix_Call (Call_Node.all, False);");
Put_Line (Indent & " $$ := YYSTYPE (Call_Node);");
Put_Line (Indent & "end;");
Put_Line ("}");
end if;
end Print_Infix_Code7;
procedure Create_Alt_Nodes
(Seq : in Sequence;
Processed_Positions : in Positions_List)
is
Index : constant Natural := Choise_Item_Index (Seq);
R_Ind : constant Natural :=
Real_Index (Seq, Processed_Positions, Index, "");
Ch_Name : constant String := Choise (Get_Item (Seq, Index).all);
begin
Put_Line ("{");
Put_Line (Indent & "if $" & To_String (R_Ind) &
".all in " & Ch_Name & " then");
Step_Indent (+1);
Create_Node_Code (Seq, Processed_Positions,
"", True_Node (Seq));
Step_Indent (-1);
Put_Line (Indent & "else");
Step_Indent (+1);
Create_Node_Code (Seq, Processed_Positions,
"", False_Node (Seq));
Step_Indent (-1);
Put_Line (Indent & "end if;");
Put_Line ("}");
end Create_Alt_Nodes;
function Processed
(Seq : in Sequence;
Processed_Positions : in Positions_List;
Index : Positive) return Boolean
is
Child : Item'Class renames Get_Item (Seq, Index).all;
begin
if (Child in Option or Child in List) and then
not Include (Processed_Positions, Index) then
return False;
else
return True;
end if;
end Processed;
function Real_Index
(Seq : in Sequence;
Processed_Positions : in Positions_List;
Index : in Positive;
Name_Of_List : in String) return Positive
is
Result : Positive := Index;
begin
if Name_Of_List /= "" then
Result := Result + 1;
end if;
for I in 1 .. Index - 1 loop
if not Processed (Seq, Processed_Positions, I) then
Result := Result - 1;
end if;
end loop;
return Result;
end Real_Index;
procedure Print_Wrap_Code
(Child : Wrapper;
Last : Boolean)
is
Child_Name : constant String := Object_Name (Child);
Child_Node : constant String := Node_Name (Child);
Child_Pos : constant String := Position (Child);
Wrap : constant Wrapper := Parent (Child);
Attr_Name : constant String := User_Attr_Name (Child);
Parent_Node : constant String := Node_Name (Wrap);
Parent_Name : constant String := Object_Name (Wrap);
Attr : constant String :=
Find_Attribute (Child_Name, Child_Node, Attr_Name, Parent_Node);
Proc : constant String := Find_Procedure (Parent_Node, Attr);
begin
if Child_Pos = "start" or Child_Pos = "both" then
Put_Line (Indent & "Set_Start_Position (" & Parent_Name &
".all, Start_Position (T (" & Child_Name & ").all));");
end if;
if Proc /= "" then
Put_Line (Indent & Proc & " (" & Parent_Name & ".all, T (" &
Child_Name & "));");
end if;
if Last and (Child_Pos = "end" or Child_Pos = "both") then
Put_Line (Indent & "Set_End_Position (" & Parent_Name &
".all, End_Position (T (" & Child_Name & ").all));");
end if;
end Print_Wrap_Code;
function Find_Procedure
(Node_Name : String;
Attr_Name : String) return String
is
begin
if Is_List_Type (Node_Name) then
return Node_Name (1 .. Node_Name'Last - 9) & "Add";
end if;
return Nodes.Find_Procedure (Node_Name, Attr_Name);
end Find_Procedure;
function New_Node (Type_Name : String) return String is
begin
if Type_Name = "Any_Compilation_Unit_Node" then
return
"Any_Compilation_Unit_Ptr (New_Compilation_Unit (The_Context))";
elsif Is_List_Type (Type_Name) then
return Type_Name (Type_Name'First .. Type_Name'Last - 9)
& "New_List (The_Context)";
else
return "New_" & Type_Name & " (The_Context)";
end if;
end New_Node;
function Is_List_Type (Node_Name : String) return Boolean is
begin
return Node_Name'Length > 9 and then
Node_Name (Node_Name'Last - 9 .. Node_Name'Last) = ".List_Node";
end Is_List_Type;
function Quote (Text : String; Double : Boolean) return String is
begin
if Double then
return """""""" & Text & """""""";
else
return """" & Text & """";
end if;
end Quote;
procedure Set_Name_Image_Code
(Name : in String;
Child : in Item'Class;
Index : in Positive := 1;
Proc : in String := "Set_Name_Image";
In_Quote : in Boolean := True)
is
begin
if Child in Delimiter then
Put_Line (Indent & Proc & " (" & Name & ".all, " &
Quote (Text (Delimiter (Child)), In_Quote) & ");");
elsif Child in Reference then
declare
Node : constant String := Node_Name (Child);
Ptr : constant String := Nodes.Get_Pointer_Name (Node);
Attr : constant String := Nodes.Find_Attr_By_Type
(Node, "Unbounded_Wide_String");
begin
Put_Line (Indent & Proc & " (" & Name & ".all, " & Attr & " (" &
Ptr & " ($" & To_String (Index) & ").all));");
end;
elsif In_Quote then
Put_Line (Indent & Proc & " (" & Name & ".all, '""' & " &
"To_String (Raw_Image ($" & To_String (Index) &
".all)) & '""');");
else
Put_Line (Indent & Proc & " (" & Name & ".all, " &
"To_String (Raw_Image ($" & To_String (Index) &
".all)));");
-- Quote (Item_Name (Child), In_Quote) & ");");
end if;
end Set_Name_Image_Code;
function Is_First
(Seq : in Sequence;
Index : in Positive;
Processed_Positions : in Positions_List) return Boolean
is
Child : Item'Class renames Get_Item (Seq, Index).all;
Wrap : Wrapper := Parent (Child);
begin
for I in 1 .. Index - 1 loop
if Processed (Seq, Processed_Positions, I) then
declare
Child_I : Item'Class renames Get_Item (Seq, I).all;
Wrap_I : Wrapper := Parent (Child_I);
begin
if Wrap_I = Wrap then
return False;
end if;
end;
end if;
end loop;
return True;
end Is_First;
function Is_Last
(Seq : in Sequence;
Index : in Positive;
Processed_Positions : in Positions_List) return Boolean
is
Child : Item'Class renames Get_Item (Seq, Index).all;
Wrap : Wrapper := Parent (Child);
begin
for I in Index + 1 .. Count (Seq) loop
if Processed (Seq, Processed_Positions, I) then
declare
Child_I : Item'Class renames Get_Item (Seq, I).all;
Wrap_I : Wrapper := Parent (Child_I);
begin
if Wrap_I = Wrap then
return False;
end if;
end;
end if;
end loop;
return True;
end Is_Last;
procedure Close_File is
begin
Ada.Text_IO.Close (Output);
end Close_File;
procedure Open_File (Name : String) is
begin
Ada.Text_IO.Open (Output, Ada.Text_IO.Out_File, Name);
end Open_File;
end Generate;
------------------------------------------------------------------------------
-- Copyright (c) 2006-2012, Maxim Reznik
-- 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 Maxim Reznik, 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 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.
------------------------------------------------------------------------------
|
------------------------------------------------------------------------------
-- --
-- Copyright (C) 2018, Adacore --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions are --
-- met: --
-- 1. Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- 2. Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in --
-- the documentation and/or other materials provided with the --
-- distribution. --
-- 3. Neither the name of the copyright holder nor the names of its --
-- contributors may be used to endorse or promote products derived --
-- from this software without specific prior written permission. --
-- --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR --
-- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
-- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT --
-- LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, --
-- DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY --
-- THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT --
-- (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE --
-- OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
-- --
------------------------------------------------------------------------------
with HAL;
with System;
with Interfaces; use Interfaces;
with Interfaces.C; use Interfaces.C;
package Posix is
type Direction is
(None,
Write,
Read)
with Size => 2;
for Direction use
(None => 2#00#,
Write => 2#01#,
Read => 2#10#);
type Request is record
dir: Direction;
typ: HAL.UInt8;
nr: HAL.UInt8;
size: HAL.UInt14;
end record
with Size => 32,
Bit_Order => System.Low_Order_First;
for Request use record
dir at 0 range 30..31;
typ at 0 range 8..15;
nr at 0 range 0..7;
size at 0 range 16..29;
end record;
type File_Id is new int;
type File_Mode is new int;
type Size is new Long_Integer;
-- FIXME: Is Errno on 64 Bit machines 32 Bit ot 64 Bit?
Err_No : Unsigned_32;
pragma Thread_Local_Storage (Err_No);
pragma Import (C, Err_No, "errno");
function Ioctl (File_Desc : in File_Id;
Req : in Request;
Data : in System.Address)
return Interfaces.C.int;
pragma Import (C, Ioctl, "ioctl");
pragma Import_Function(Ioctl, Mechanism => Value);
function Simple_Ioctl (File_Desc : in File_Id;
Req : in HAL.UInt32;
Data : in HAL.UInt64)
return Interfaces.C.int;
pragma Import (C, Simple_Ioctl, "ioctl");
function Open (Path : String;
Flags : int;
Mode : File_Mode)
return File_Id;
pragma Import(C, open, "open");
function Read (File_Desc : File_Id;
Data : System.Address;
Length : Size)
return Size;
pragma Import(C, read, "read");
function Write (File_Desc : File_Id;
Data : System.Address;
Length : Size)
return Size;
pragma Import(C, write, "write");
end Posix;
|
-- This file is covered by the Internet Software Consortium (ISC) License
-- Reference: ../License.txt
with Port_Specification;
package PortScan.Packager is
package PSP renames Port_Specification;
-- Executes package phase (run sometime after stage)
function exec_phase_package
(specification : PSP.Portspecs;
log_handle : in out TIO.File_Type;
log_name : String;
phase_name : String;
seq_id : port_id;
port_prefix : String;
rootdir : String) return Boolean;
private
-- create +MANIFEST file for each subpackage
procedure write_package_manifest
(spec : PSP.Portspecs;
port_prefix : String;
subpackage : String;
seq_id : port_id;
pkgversion : String;
filename : String);
-- Alert if port is deprecated
procedure check_deprecation (spec : PSP.Portspecs; log_handle : TIO.File_Type);
-- remove filename if it's zero-length, otherwise dump it to the log
procedure dump_pkg_message_to_log (display_file : String; log_handle : TIO.File_Type);
-- Returns true if package directory exists or if it was successfully created.
function create_package_directory_if_necessary (log_handle : TIO.File_Type) return Boolean;
-- Returns true if the latest package directory exists or if it was successfully created.
function create_latest_package_directory_too (log_handle : TIO.File_Type) return Boolean;
-- Used to launch root commands (no watchdog)
function execute_command (command : String; name_of_log : String) return Boolean;
-- Puts quotation marks around given string
function quote (thetext : String) return String;
-- Handle "complete" metapackage deps case for the metadata file
procedure write_complete_metapackage_deps
(spec : PSP.Portspecs;
file_handle : TIO.File_Type;
variant : String;
pkgversion : String);
-- Document buildrun + run dependencies in the "deps" category of the manifest.
procedure write_down_run_dependencies
(file_handle : TIO.File_Type;
seq_id : port_id;
subpackage : String);
-- If there are any package notes, write them to the manifest
procedure write_package_annotations
(spec : PSP.Portspecs;
file_handle : TIO.File_Type);
end PortScan.Packager;
|
------------------------------------------------------------------------------
-- --
-- Common UUID Handling Package --
-- - RFC 4122 Implementation - --
-- --
-- ------------------------------------------------------------------------ --
-- --
-- Copyright (C) 2018-2021 ANNEXI-STRAYLINE Trans-Human Ltd. --
-- All rights reserved. --
-- --
-- Original Contributors: --
-- * Richard Wai, Ensi Martini, Aninda Poddar, Noshen Atashe --
-- (ANNEXI-STRAYLINE) --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions are --
-- met: --
-- --
-- * Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- --
-- * Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in --
-- the documentation and/or other materials provided with the --
-- distribution. --
-- --
-- * Neither the name of the copyright holder nor the names of its --
-- contributors may be used to endorse or promote products derived --
-- from this software without specific prior written permission. --
-- --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A --
-- PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
-- OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT --
-- LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, --
-- DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY --
-- THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT --
-- (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE --
-- OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
-- --
------------------------------------------------------------------------------
with Interfaces;
with Ada.Streams;
with Ada.Containers;
package UUIDs is
----------------
-- Exceptions --
----------------
Generation_Failed: exception;
-- Raised by ID Generation subprograms that cannot generate a valid UUID.
-----------------
-- UUID_String --
-----------------
-- The UUID_String format is sized to contain the standard UUID encoding
-- format as specified in RFC 4122, Section 3, under "Declaration of
-- syntactic structure"
subtype UUID_String_Index is Positive range 1 .. 36; -- 16 "hexOctets", 4 '-'
subtype UUID_String is String(UUID_String_Index);
UUID_Nil_String: constant UUID_String
:= "00000000-0000-0000-0000-000000000000";
-- An string-encoded representation of a Nil UUID, as defined in RFC 4122,
-- Section 4.1.7
UUID_Format_Error: exception;
-- Raised when attempting to "Decode" an invalid UUID_String, which either
-- has non hex-digits, or improperly placed/missing hyphens.
-- RFC 4122 Field Ranges --
subtype UUID_String_time_low
is UUID_String_Index
-- "4hexOctet" = 8 Characters
range UUID_String_Index'First .. UUID_String_Index'First + 8 - 1;
subtype UUID_String_Hyphen_1
is UUID_String_Index
range UUID_String_time_low'Last + 1 .. UUID_String_time_low'Last + 1;
subtype UUID_String_time_mid
is UUID_String_Index
-- "2hexOctet" = 4 Characters
range UUID_String_Hyphen_1'Last + 1 .. UUID_String_Hyphen_1'Last + 4;
subtype UUID_String_Hyphen_2
is UUID_String_Index
range UUID_String_time_mid'Last + 1 .. UUID_String_time_mid'Last + 1;
subtype UUID_String_time_high_and_version
is UUID_String_Index
-- "2hexOctet" = 4 Characters
range UUID_String_Hyphen_2'Last + 1 .. UUID_String_Hyphen_2'Last + 4;
subtype UUID_String_Hyphen_3
is UUID_String_Index
range UUID_String_time_high_and_version'Last + 1 ..
UUID_String_time_high_and_version'Last + 1;
subtype UUID_String_clock_seq_and_reserved
is UUID_String_Index
-- "hexOctet" = 2 Characters
range UUID_String_Hyphen_3'Last + 1 .. UUID_String_Hyphen_3'Last + 2;
subtype UUID_String_clock_seq_low
is UUID_String_Index
-- "hexOctet" = 2 Characters
range UUID_String_clock_seq_and_reserved'Last + 1 ..
UUID_String_clock_seq_and_reserved'Last + 2;
subtype UUID_String_Hyphen_4
is UUID_String_Index
range UUID_String_clock_seq_low'Last + 1 ..
UUID_String_clock_seq_low'Last + 1;
subtype UUID_String_node
is UUID_String_Index
-- "6hexOctet" = 12 Characters
range UUID_String_Hyphen_4'Last + 1 .. UUID_String_Hyphen_4'Last + 12;
----------
-- UUID --
----------
type UUID is private with Preelaborable_Initialization;
-- Unassigned UUIDs are initialized to the equivalent of Nil_UUID
--
-- Note that the underlying representation of UUID is not guarunteed to
-- be "correct" (contiguous 128-bit big-endian), since this is rarely
-- important within a common system. However, the streaming attributes
-- of UUID will send the correct 128-bit big-endian value "over the wire"
function ">" (Left, Right: UUID) return Boolean;
function "<" (Left, Right: UUID) return Boolean;
-- Hex Encode and Decode
function Encode (ID: UUID) return UUID_String;
-- Encodes any UUID into it's representative UUID_String value, according to
-- the rules specified by RFC 4122, Section 3.
function Decode (ID_String: UUID_String) return UUID;
-- Decodes a UUID_String into a UUID object.
-- -- Explicit Exceptions --
-- * UUID_Format_Error: ID_String was non-complaint with RFC 4122,
-- Section 3
-- Hashing
function Hash (ID: UUID) return Ada.Containers.Hash_Type;
-- Returns a hash value generally suitable for use in Containers.
-- This hash is produced via binary xors of various Hash_Type'Mod results
-- from each discrete binary "field" of the UUID
-- Binary IO
UUID_Binary_LSB: constant := 0;
UUID_Binary_MSB: constant := 15;
type Binary_UUID is array (UUID_Binary_LSB .. UUID_Binary_MSB)
of Interfaces.Unsigned_8;
-- UUID_Binary is a Little-endian representation of the 128-bit UUID value
-- as a
function To_Binary (ID: in UUID) return Binary_UUID;
function From_Binary (ID: in Binary_UUID) return UUID;
-- Converion to/from a binary UUID representation
procedure Write (Stream: not null access Ada.Streams.Root_Stream_Type'Class;
ID : in UUID);
procedure Read (Stream: not null access Ada.Streams.Root_Stream_Type'Class;
ID : out UUID);
-- The binary value Write or Read from stram is strictly occording to
-- RFC 4122, Section 4.1.2 - "Layout and Byte Order". Specifically, the
-- binary value is a single 128-bit big-endian value.
--
-- The effect of Write is equivalent to:
--
-- declare
-- Bin: constant Binary_UUID := To_Binary (ID);
-- begin
-- for Octet of reverse Bin loop
-- Interfaces.Unsigned_8'Write (Stream, Octet);
-- end loop;
-- end;
--
-- Ergo, UUID_Binary_MSB is written to the stream first.
for UUID'Write use Write;
for UUID'Read use Read;
-- Nil UUID --
--------------
Nil_UUID: constant UUID;
-- A Nil UUID as defined in RFC 4122, Section 4.1.7
------------------
-- UUID_Version --
------------------
subtype UUID_Version is Integer range 0 .. (2**4) - 1;
-- RFC 4122 specifies that they Version of a UUID is represented by an
-- unsigned 4-bit value. However, we do not want to export wrap-around
-- semantics here
function Version(ID: UUID) return UUID_Version;
-- Returns the reported Version of any UUID. If the UUID is a Nil UUID,
-- Version returns zero. On any kind of internal error, Version returns
-- zero.
--
-- -- Suppresses All Exceptions --
private
type Bitfield_8 is mod 2**8;
type Bitfield_16 is mod 2**16;
type Bitfield_32 is mod 2**32;
type Bitfield_48 is mod 2**48;
-- As demanded by the RFC 4122 specification implemented by the UUID type.
type UUID is
record
time_low : Bitfield_32 := 0; -- Octet #0-3
time_mid : Bitfield_16 := 0; -- Octet #4-5
time_hi_and_version : Bitfield_16 := 0; -- Octet #6-7
clock_seq_hi_and_reserved: Bitfield_8 := 0; -- Octet #8
clock_seq_low : Bitfield_8 := 0; -- Octet #9
node : Bitfield_48 := 0; -- Octet #10-15
end record;
-- Basic specification of UUID as specified by RFC 4122, Section 4.1.2 -
-- "Layout and Byte Order".
--
-- However, to improve efficiency of the system, the UUID is stored in
-- a conventional record with native byte order.
--
-- When output/input via the stream attributes, the stream representation
-- will be as specified by RFC 4122 - exactly 128 contiguous bits, big-
-- endian
Nil_UUID: constant UUID := UUID'(others => <>);
end UUIDs;
|
-- { dg-do compile }
package body Aggr20 is
procedure Proc (R : out Rec3) is
begin
R := (Callback => Nil_Rec2);
end;
end Aggr20;
|
-- RUN: %llvmgcc -S %s -I%p/Support
package body Global_Constant is
begin
raise An_Error;
end;
|
-- part of AdaYaml, (c) 2017 Felix Krause
-- released under the terms of the MIT license, see the file "copying.txt"
private with Ada.Containers.Indefinite_Vectors;
with Ada.Iterator_Interfaces;
package Yaml.Dom.Sequence_Data is
type Instance is tagged limited private
with Default_Iterator => Iterate,
Iterator_Element => Node_Reference,
Constant_Indexing => Element;
type Cursor is private;
function "=" (Left, Right : Instance) return Boolean;
function Capacity (Container : Instance) return Count_Type;
procedure Reserve_Capacity (Container : in out Instance;
Capacity : in Count_Type);
function Length (Object : Instance) return Count_Type;
function Is_Empty (Container : Instance) return Boolean;
procedure Clear (Container : in out Instance);
function To_Cursor (Container : Instance;
Index : Natural) return Cursor;
function To_Index (Position : Cursor) return Natural;
function Has_Element (Position : Cursor) return Boolean;
package Iterators is new Ada.Iterator_Interfaces (Cursor, Has_Element);
procedure Iterate (Object : Instance;
Process : not null access procedure
(Item : not null access Node.Instance));
function Iterate (Object : Instance)
return Iterators.Forward_Iterator'Class;
function Element (Object : Instance; Index : Positive) return Node_Reference;
function Element (Object : Instance; Position : Cursor) return Node_Reference
with Pre => Has_Element (Position);
procedure Replace_Element (Container : in out Instance;
Index : in Positive;
New_Item : in Node_Reference);
procedure Replace_Element (Container : in out Instance;
Position : in Cursor;
New_Item : in Node_Reference);
procedure Insert (Container : in out Instance;
Before : in Positive;
New_Item : in Node_Reference);
procedure Insert (Container : in out Instance;
Before : in Cursor;
New_Item : in Node_Reference);
procedure Insert (Container : in out Instance;
Before : in Cursor;
New_Item : in Node_Reference;
Position : out Cursor);
procedure Prepend (Container : in out Instance;
New_Item : in Node_Reference);
procedure Append (Container : in out Instance;
New_Item : in Node_Reference);
procedure Delete (Container : in out Instance;
Index : in Positive;
Count : in Count_Type := 1);
procedure Delete (Container : in out Instance;
Position : in out Cursor;
Count : in Count_Type := 1);
procedure Delete_First (Container : in out Instance;
Count : in Count_Type := 1);
procedure Delete_Last (Container : in out Instance;
Count : in Count_Type := 1);
procedure Reverse_Elements (Container : in out Instance);
procedure Swap (Container : in out Instance;
I, J : in Positive);
procedure Swap (Container : in out Instance;
I, J : in Cursor);
function First_Index (Container : Instance) return Positive;
function First (Container : Instance) return Cursor;
function First_Element (Container : Instance) return Node_Reference;
function Last_Index (Container : Instance) return Natural;
function Last (Container : Instance) return Cursor;
function Last_Element (Container : Instance) return Node_Reference;
function Next (Position : Cursor) return Cursor;
procedure Next (Position : in out Cursor);
function Previous (Position : Cursor) return Cursor;
procedure Previous (Position : in out Cursor);
No_Element : constant Cursor;
private
package Node_Vectors is new Ada.Containers.Indefinite_Vectors
(Index_Type => Positive,
Element_Type => Node_Pointer);
type Instance is tagged limited record
Document : not null access Document_Instance;
Data : Node_Vectors.Vector;
end record;
type Cursor is record
Container : access constant Instance;
Index : Natural;
end record;
No_Element : constant Cursor := (Container => null, Index => 0);
package Friend_Interface is
-- these subprograms are used by other child packages of Yaml.Dom. Since
-- they are not memory safe, they are hidden here from the library user,
-- but made available via importing.
function For_Document (Document : not null access Document_Instance)
return Instance with Export, Convention => Ada,
Link_Name => "AdaYaml__Sequence_Data__For_Document";
procedure Raw_Append (Container : in out Instance;
New_Item : not null access Node.Instance)
with Export, Convention => Ada,
Link_Name => "AdaYaml__Sequence_Data__Raw_Append";
end Friend_Interface;
end Yaml.Dom.Sequence_Data;
|
package body agar.gui.widget.socket is
package cbinds is
function from_bitmap
(parent : widget_access_t;
flags : flags_t;
file : cs.chars_ptr) return socket_access_t;
pragma import (c, from_bitmap, "AG_SocketFromBMP");
procedure set_padding
(socket : socket_access_t;
left : c.int;
right : c.int;
top : c.int;
bottom : c.int);
pragma import (c, set_padding, "AG_SocketSetPadding");
procedure shape_rectangle
(socket : socket_access_t;
width : c.unsigned;
height : c.unsigned);
pragma import (c, shape_rectangle, "AG_SocketBgRect");
procedure shape_circle
(socket : socket_access_t;
radius : c.unsigned);
pragma import (c, shape_circle, "AG_SocketBgCircle");
end cbinds;
function from_bitmap
(parent : widget_access_t;
flags : flags_t;
file : string) return socket_access_t
is
ca_file : aliased c.char_array := c.to_c (file);
begin
return cbinds.from_bitmap
(parent => parent,
flags => flags,
file => cs.to_chars_ptr (ca_file'unchecked_access));
end from_bitmap;
procedure set_padding
(socket : socket_access_t;
left : natural;
right : natural;
top : natural;
bottom : natural) is
begin
cbinds.set_padding
(socket => socket,
left => c.int (left),
right => c.int (right),
top => c.int (top),
bottom => c.int (bottom));
end set_padding;
procedure shape_rectangle
(socket : socket_access_t;
width : natural;
height : natural) is
begin
cbinds.shape_rectangle
(socket => socket,
width => c.unsigned (width),
height => c.unsigned (height));
end shape_rectangle;
procedure shape_circle
(socket : socket_access_t;
radius : natural) is
begin
cbinds.shape_circle
(socket => socket,
radius => c.unsigned (radius));
end shape_circle;
function widget (socket : socket_access_t) return widget_access_t is
begin
return socket.widget'access;
end widget;
function icon (socket : socket_access_t) return agar.gui.widget.icon.icon_access_t is
begin
return socket.icon;
end icon;
end agar.gui.widget.socket;
|
with Ada.Strings.Unbounded;
with Ada.Text_IO.Text_Streams;
with DOM.Core.Documents;
with DOM.Core.Elements;
with DOM.Core.Nodes;
procedure Character_Remarks is
package DC renames DOM.Core;
package IO renames Ada.Text_IO;
package US renames Ada.Strings.Unbounded;
type Remarks is record
Name : US.Unbounded_String;
Text : US.Unbounded_String;
end record;
type Remark_List is array (Positive range <>) of Remarks;
My_Remarks : Remark_List :=
((US.To_Unbounded_String ("April"),
US.To_Unbounded_String ("Bubbly: I'm > Tam and <= Emily")),
(US.To_Unbounded_String ("Tam O'Shanter"),
US.To_Unbounded_String ("Burns: ""When chapman billies leave the street ...""")),
(US.To_Unbounded_String ("Emily"),
US.To_Unbounded_String ("Short & shrift")));
My_Implementation : DC.DOM_Implementation;
My_Document : DC.Document := DC.Create_Document (My_Implementation);
My_Root_Node : DC.Element := DC.Nodes.Append_Child (My_Document,
DC.Documents.Create_Element (My_Document, "CharacterRemarks"));
My_Element_Node : DC.Element;
My_Text_Node : DC.Text;
begin
for I in My_Remarks'Range loop
My_Element_Node := DC.Nodes.Append_Child (My_Root_Node,
DC.Documents.Create_Element (My_Document, "Character"));
DC.Elements.Set_Attribute (My_Element_Node, "Name", US.To_String (My_Remarks (I).Name));
My_Text_Node := DC.Nodes.Append_Child (My_Element_Node,
DC.Documents.Create_Text_Node (My_Document, US.To_String (My_Remarks (I).Text)));
end loop;
DC.Nodes.Write (IO.Text_Streams.Stream (IO.Standard_Output),
N => My_Document,
Pretty_Print => True);
end Character_Remarks;
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.