content
stringlengths 23
1.05M
|
|---|
-- Copyright (c) 2015-2017 Maxim Reznik <reznikmm@gmail.com>
--
-- SPDX-License-Identifier: MIT
-- License-Filename: LICENSE
-------------------------------------------------------------
package body Incr.Nodes.Tokens is
------------------
-- Constructors --
------------------
package body Constructors is
----------------
-- Initialize --
----------------
procedure Initialize
(Self : out Token'Class;
Kind : Node_Kind;
Value : League.Strings.Universal_String;
State : Scanner_State;
Lookahead : Natural)
is
Now : constant Version_Trees.Version :=
Self.Document.History.Changing;
Diff : Integer := 0;
begin
Self.Kind := Kind;
Nodes.Constructors.Initialize (Self);
Versioned_Strings.Initialize
(Self.Text, League.Strings.Empty_Universal_String);
Versioned_Naturals.Initialize (Self.Back, 1);
Versioned_Naturals.Initialize (Self.Ahead, 1);
Versioned_Naturals.Initialize (Self.States, 0);
Versioned_Booleans.Set (Self.Exist, True, Now, Diff); -- UNDELETE??
Versioned_Strings.Set (Self.Text, Value, Now, Diff);
Versioned_Naturals.Set (Self.Ahead, Lookahead, Now, Diff);
Versioned_Naturals.Set (Self.States, Natural (State), Now, Diff);
Self.Update_Local_Changes (Diff);
end Initialize;
------------------------
-- Initialize_Ancient --
------------------------
procedure Initialize_Ancient
(Self : aliased in out Token'Class;
Parent : Node_Access;
Back : Natural) is
begin
Self.Kind := 0;
Nodes.Constructors.Initialize_Ancient (Self, Parent);
Versioned_Strings.Initialize
(Self.Text, League.Strings.Empty_Universal_String);
Versioned_Naturals.Initialize (Self.Back, Back);
Versioned_Naturals.Initialize (Self.Ahead, 1);
Versioned_Naturals.Initialize (Self.States, 0);
end Initialize_Ancient;
end Constructors;
-----------
-- Arity --
-----------
overriding function Arity (Self : Token) return Natural is
pragma Unreferenced (Self);
begin
return 0;
end Arity;
-----------
-- Child --
-----------
overriding function Child
(Self : Token;
Index : Positive;
Time : Version_Trees.Version) return Node_Access
is
pragma Unreferenced (Self, Index, Time);
begin
return null;
end Child;
-------------
-- Discard --
-------------
overriding procedure Discard (Self : in out Token) is
Now : constant Version_Trees.Version := Self.Document.History.Changing;
Diff : Integer;
begin
Versioned_Booleans.Discard (Self.Exist, Now, Diff);
Versioned_Strings.Discard (Self.Text, Now, Diff);
Versioned_Naturals.Discard (Self.Back, Now, Diff);
Versioned_Naturals.Discard (Self.Ahead, Now, Diff);
Versioned_Naturals.Discard (Self.States, Now, Diff);
Self.Update_Local_Changes (Diff);
end Discard;
--------------
-- Is_Token --
--------------
overriding function Is_Token (Self : Token) return Boolean is
pragma Unreferenced (Self);
begin
return True;
end Is_Token;
----------
-- Kind --
----------
overriding function Kind (Self : Token) return Node_Kind is
begin
return Self.Kind;
end Kind;
--------------
-- Lookback --
--------------
not overriding function Lookback
(Self : Token;
Time : Version_Trees.Version) return Natural is
begin
return Versioned_Naturals.Get (Self.Back, Time);
end Lookback;
--------------------
-- Nested_Changes --
--------------------
overriding function Nested_Changes
(Self : Token;
From : Version_Trees.Version;
To : Version_Trees.Version) return Boolean
is
pragma Unreferenced (Self, From, To);
begin
return False;
end Nested_Changes;
----------------
-- Next_Token --
----------------
not overriding function Next_Token
(Self : aliased Token;
Time : Version_Trees.Version) return Token_Access
is
Next_Subtree : Node_Access := Self.Next_Subtree (Time);
Result : Token_Access;
begin
while Next_Subtree /= null loop
Result := Next_Subtree.First_Token (Time);
exit when Result /= null;
Next_Subtree := Next_Subtree.Next_Subtree (Time);
end loop;
return Result;
end Next_Token;
--------------------
-- Previous_Token --
--------------------
not overriding function Previous_Token
(Self : aliased Token;
Time : Version_Trees.Version) return Token_Access
is
Prev_Subtree : Node_Access := Self.Previous_Subtree (Time);
Result : Token_Access;
begin
while Prev_Subtree /= null loop
Result := Prev_Subtree.Last_Token (Time);
exit when Result /= null;
Prev_Subtree := Prev_Subtree.Previous_Subtree (Time);
end loop;
return Result;
end Previous_Token;
--------------
-- Set_Text --
--------------
not overriding procedure Set_Text
(Self : in out Token;
Value : League.Strings.Universal_String)
is
Now : constant Version_Trees.Version := Self.Document.History.Changing;
Diff : Integer := 0;
begin
Versioned_Strings.Set (Self.Text, Value, Now, Diff);
Self.Update_Local_Changes (Diff);
end Set_Text;
----------
-- Span --
----------
overriding function Span
(Self : aliased in out Token;
Kind : Span_Kinds;
Time : Version_Trees.Version) return Natural is
begin
case Kind is
when Text_Length =>
return Tokens.Text (Self, Time).Length;
when Token_Count =>
return 1;
when Line_Count =>
return Tokens.Text (Self, Time).Count (LF);
end case;
end Span;
-----------
-- State --
-----------
not overriding function State
(Self : access Token;
Time : Version_Trees.Version) return Scanner_State is
begin
return Scanner_State
(Versioned_Naturals.Get (Self.States, Time));
end State;
----------
-- Text --
----------
not overriding function Text
(Self : Token;
Time : Version_Trees.Version) return League.Strings.Universal_String is
begin
return Versioned_Strings.Get (Self.Text, Time);
end Text;
end Incr.Nodes.Tokens;
|
with Protypo.Scanning;
with Protypo.Code_Trees;
private
package Protypo.Parsing is
function Parse_Statement_Sequence (Input : in out Scanning.Token_List)
return Code_Trees.Parsed_Code;
function Parse_Expression (Input: in out Scanning.Token_List)
return Code_Trees.Parsed_Code;
end Protypo.Parsing;
|
with Ada.Text_IO; use Ada.Text_IO;
with Ada.Strings.Unbounded;
procedure Main is
package SU renames Ada.Strings.Unbounded;
procedure I_Return_String(Sun : out SU.Unbounded_String) is
begin
Sun := SU.To_Unbounded_String("Hellew, I am an Ada string.");
end I_Return_String;
SUnb : SU.Unbounded_String;
begin
I_Return_String(SUnb);
Put_Line("Output string is here ==>" & SU.To_String(SUnb) & "<==");
end Main;
|
with Ada.Unchecked_Deallocation;
with Test_Utils.Abstract_Decoder.COBS_Simple;
with Test_Utils.Abstract_Decoder.COBS_Stream;
with Testsuite.Decode.Basic_Tests;
with Testsuite.Decode.Multiframe_Tests;
package body Testsuite.Decode is
Kind : Decoder_Kind := Decoder_Kind'First;
----------------------
-- Set_Decoder_Kind --
----------------------
procedure Set_Decoder_Kind (K : Decoder_Kind) is
begin
Kind := K;
end Set_Decoder_Kind;
------------
-- Set_Up --
------------
overriding
procedure Set_Up (Test : in out Decoder_Fixture) is
begin
Test.Kind := Kind;
Test.Decoder := Create_Decoder (Kind);
end Set_Up;
---------------
-- Tear_Down --
---------------
overriding
procedure Tear_Down (Test : in out Decoder_Fixture) is
begin
Free_Decoder (Test.Decoder);
end Tear_Down;
---------------
-- Add_Tests --
---------------
procedure Add_Tests (Suite : in out AUnit.Test_Suites.Test_Suite'Class) is
begin
Testsuite.Decode.Basic_Tests.Add_Tests (Suite);
if False then
Testsuite.Decode.Multiframe_Tests.Add_Tests (Suite);
end if;
end Add_Tests;
--------------------
-- Create_Decoder --
--------------------
function Create_Decoder (K : Decoder_Kind)
return not null Test_Utils.Abstract_Decoder.Any_Acc
is
use Test_Utils.Abstract_Decoder;
begin
case K is
when Simple =>
return new COBS_Simple.Instance;
when Simple_In_Place =>
return new COBS_Simple.Instance (True);
when Stream =>
return new COBS_Stream.Instance;
end case;
end Create_Decoder;
------------------
-- Free_Decoder --
------------------
procedure Free_Decoder (Dec : in out Test_Utils.Abstract_Decoder.Any_Acc) is
use Test_Utils.Abstract_Decoder;
procedure Free is new Ada.Unchecked_Deallocation
(COBS_Simple.Instance,
COBS_Simple.Acc);
procedure Free is new Ada.Unchecked_Deallocation
(COBS_Stream.Instance,
COBS_Stream.Acc);
begin
if Dec.all in COBS_Simple.Instance'Class then
Free (COBS_Simple.Acc (Dec));
elsif Dec.all in COBS_Stream.Instance'Class then
Free (COBS_Stream.Acc (Dec));
else
raise Program_Error;
end if;
end Free_Decoder;
end Testsuite.Decode;
|
--------------------------------------------------------------------------------
-- --
-- Copyright (C) 2004, RISC OS Ada Library (RASCAL) developers. --
-- --
-- This library is free software; you can redistribute it and/or --
-- modify it under the terms of the GNU Lesser General Public --
-- License as published by the Free Software Foundation; either --
-- version 2.1 of the License, or (at your option) any later version. --
-- --
-- This library is distributed in the hope that it will be useful, --
-- but WITHOUT ANY WARRANTY; without even the implied warranty of --
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU --
-- Lesser General Public License for more details. --
-- --
-- You should have received a copy of the GNU Lesser General Public --
-- License along with this library; if not, write to the Free Software --
-- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA --
-- --
--------------------------------------------------------------------------------
-- @brief Time related types and methods.
-- $Author$
-- $Date$
-- $Revision$
with RASCAL.OS; use RASCAL.OS;
with System.Unsigned_Types; use System.Unsigned_Types;
package RASCAL.Time is
type UTC_Time_Type is
record
Word : Unsigned;
Last_Byte : Byte;
end record;
type UTC_Pointer is access UTC_Time_Type;
pragma Convention (C, UTC_Time_Type);
--
-- Returns the time either with or without centiseconds.
-- {fcode}Hour:Minutes:Seconds:Centiseconds{f}
--
function Get_Time (Centi : in boolean := false) return string;
--
-- Returns the date in a format specified by 'Format'.
--
function Get_Date (Format : in string := "%ce%yr-%mn-%dy") return string;
--
-- Returns monotonic time : Number of centiceconds since last hard reset.
--
function Read_MonotonicTime return Integer;
end RASCAL.Time;
|
-- Copyright (c) 2020 Maxim Reznik <reznikmm@gmail.com>
--
-- SPDX-License-Identifier: MIT
-- License-Filename: LICENSE
-------------------------------------------------------------
with Skynet;
with League.Strings;
with Ada.Wide_Wide_Text_IO;
procedure Skynet_Test is
Options : Skynet.Upload_Options;
Skylink : League.Strings.Universal_String;
begin
Skynet.Upload_File
(Path => League.Strings.To_Universal_String ("/etc/hosts"),
Skylink => Skylink,
Options => Options);
Ada.Wide_Wide_Text_IO.Put_Line (Skylink.To_Wide_Wide_String);
Skynet.Download_File
(Path => League.Strings.To_Universal_String ("/tmp/hosts"),
Skylink => Skylink);
end Skynet_Test;
|
------------------------------------------------------------------------------
-- --
-- Copyright (C) 2018, Universidad Politécnica de Madrid --
-- --
-- This is free software; you can redistribute it and/or modify it under --
-- terms of the GNU General Public License as published by the Free Soft- --
-- ware Foundation; either version 3, or (at your option) any later ver- --
-- sion. This software is distributed in the hope that it will be useful, --
-- but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHAN- --
-- TABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public --
-- License for more details. You should have received a copy of the GNU --
-- General Public License distributed with this software; see file --
-- COPYING3. If not, go to http://www.gnu.org/licenses for a complete copy --
-- of the license. --
-- --
------------------------------------------------------------------------------
-- Buffer for storing measurements. Measurements are inserted
-- and extracted in FIFO order.
with HK_Data; use HK_Data;
package Storage is -- protected
Capacity : constant Positive := 5;
procedure Put (Data : in Sensor_Data);
-- Insert a measurement into the buffer.
-- Overwrite the oldest element if the buffer is full.
procedure Get (Data : out Sensor_Data);
-- Extract a measurement from the buffer.
-- Raise Constraint_Error if the buffer is empty.
function Last return Sensor_Data;
-- Get most recent measurement. The data is not erased.
-- Raise Constraint_Error if the buffer is empty.
function Empty return Boolean;
-- Test for empty buffer
function Full return Boolean;
-- Test for full bufer
end Storage;
|
-------------------------------------------------------------------------------
--
-- This file is only for conviniece to be able to build and run with
-- one click
--
-------------------------------------------------------------------------------
with Ada.Command_Line;
with Ada.Directories;
with Ada.Text_IO;
with GNAT.OS_Lib;
procedure DDS.Request_Reply.Tests.Simple.Driver is
use Ada.Text_IO;
Args : constant GNAT.OS_Lib.Argument_List :=
(new Standard.String'("-j0"),
new Standard.String'("-k"),
new Standard.String'("-s"));
procedure Non_Blocking_Spawn (Name : Standard.String) is
Full_Name : constant Standard.String := "bin/dds-request_reply-tests-simple-" & Name;
Pid : GNAT.OS_Lib.Process_Id;
begin
if Ada.Directories.Exists (Full_Name) then
Put ("Spawning:" & Full_Name);
Pid := GNAT.OS_Lib.Non_Blocking_Spawn (Full_Name, Args);
Put_Line (" | Pid ->" & GNAT.OS_Lib.Pid_To_Integer (Pid)'Img);
delay 0.4;
else
Put_Line (Full_Name & ": does not exists.");
Ada.Command_Line.Set_Exit_Status (Ada.Command_Line.Failure);
end if;
end;
Gprbuild : constant GNAT.OS_Lib.String_Access := GNAT.OS_Lib.Locate_Exec_On_Path ("gprbuild");
begin
if GNAT.OS_Lib.Spawn (Gprbuild.all, Args) = 0 then -- Dont try to run if the build fails
Non_Blocking_Spawn ("replier_main");
Non_Blocking_Spawn ("requester_main");
end if;
end;
|
------------------------------------------------------------------------------
-- --
-- GNAT RUN-TIME LIBRARY (GNARL) COMPONENTS --
-- --
-- S Y S T E M . S T R I N G S . S T R E A M _ O P S --
-- --
-- S p e c --
-- --
-- Copyright (C) 2009, 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. --
-- --
------------------------------------------------------------------------------
-- This package provides subprogram implementations of stream attributes for
-- the following types:
-- Ada.String
-- Ada.Wide_String
-- Ada.Wide_Wide_String
--
-- The compiler will generate references to the subprograms in this package
-- when expanding stream attributes for the above mentioned types. Example:
--
-- String'Output (Some_Stream, Some_String);
--
-- will be expanded into:
--
-- String_Output (Some_Stream, Some_String);
-- or
-- String_Output_Blk_IO (Some_Stream, Some_String);
pragma Compiler_Unit;
with Ada.Streams;
package System.Strings.Stream_Ops is
------------------------------
-- String stream operations --
------------------------------
function String_Input
(Strm : access Ada.Streams.Root_Stream_Type'Class)
return String;
function String_Input_Blk_IO
(Strm : access Ada.Streams.Root_Stream_Type'Class)
return String;
procedure String_Output
(Strm : access Ada.Streams.Root_Stream_Type'Class;
Item : String);
procedure String_Output_Blk_IO
(Strm : access Ada.Streams.Root_Stream_Type'Class;
Item : String);
procedure String_Read
(Strm : access Ada.Streams.Root_Stream_Type'Class;
Item : out String);
procedure String_Read_Blk_IO
(Strm : access Ada.Streams.Root_Stream_Type'Class;
Item : out String);
procedure String_Write
(Strm : access Ada.Streams.Root_Stream_Type'Class;
Item : String);
procedure String_Write_Blk_IO
(Strm : access Ada.Streams.Root_Stream_Type'Class;
Item : String);
-----------------------------------
-- Wide_String stream operations --
-----------------------------------
function Wide_String_Input
(Strm : access Ada.Streams.Root_Stream_Type'Class)
return Wide_String;
function Wide_String_Input_Blk_IO
(Strm : access Ada.Streams.Root_Stream_Type'Class)
return Wide_String;
procedure Wide_String_Output
(Strm : access Ada.Streams.Root_Stream_Type'Class;
Item : Wide_String);
procedure Wide_String_Output_Blk_IO
(Strm : access Ada.Streams.Root_Stream_Type'Class;
Item : Wide_String);
procedure Wide_String_Read
(Strm : access Ada.Streams.Root_Stream_Type'Class;
Item : out Wide_String);
procedure Wide_String_Read_Blk_IO
(Strm : access Ada.Streams.Root_Stream_Type'Class;
Item : out Wide_String);
procedure Wide_String_Write
(Strm : access Ada.Streams.Root_Stream_Type'Class;
Item : Wide_String);
procedure Wide_String_Write_Blk_IO
(Strm : access Ada.Streams.Root_Stream_Type'Class;
Item : Wide_String);
----------------------------------------
-- Wide_Wide_String stream operations --
----------------------------------------
function Wide_Wide_String_Input
(Strm : access Ada.Streams.Root_Stream_Type'Class)
return Wide_Wide_String;
function Wide_Wide_String_Input_Blk_IO
(Strm : access Ada.Streams.Root_Stream_Type'Class)
return Wide_Wide_String;
procedure Wide_Wide_String_Output
(Strm : access Ada.Streams.Root_Stream_Type'Class;
Item : Wide_Wide_String);
procedure Wide_Wide_String_Output_Blk_IO
(Strm : access Ada.Streams.Root_Stream_Type'Class;
Item : Wide_Wide_String);
procedure Wide_Wide_String_Read
(Strm : access Ada.Streams.Root_Stream_Type'Class;
Item : out Wide_Wide_String);
procedure Wide_Wide_String_Read_Blk_IO
(Strm : access Ada.Streams.Root_Stream_Type'Class;
Item : out Wide_Wide_String);
procedure Wide_Wide_String_Write
(Strm : access Ada.Streams.Root_Stream_Type'Class;
Item : Wide_Wide_String);
procedure Wide_Wide_String_Write_Blk_IO
(Strm : access Ada.Streams.Root_Stream_Type'Class;
Item : Wide_Wide_String);
end System.Strings.Stream_Ops;
|
with Ada.Containers.Binary_Trees.Arne_Andersson.Debug;
with Ada.Unchecked_Conversion;
package body Ada.Containers.Ordered_Sets.Debug is
use type Copy_On_Write.Data_Access;
function Downcast is
new Unchecked_Conversion (Copy_On_Write.Data_Access, Data_Access);
procedure Dump (Source : Set; Message : String := "") is
Container : Binary_Trees.Node_Access;
Dummy : Boolean;
begin
if Source.Super.Data = null then
Container := null;
else
Container := Downcast (Source.Super.Data).Root;
end if;
Dummy :=
Base.Debug.Dump (
Container => Container,
Marker => null,
Message => Message);
end Dump;
function Valid (Source : Set) return Boolean is
Container : Binary_Trees.Node_Access;
Length : Count_Type;
begin
if Source.Super.Data = null then
Container := null;
Length := 0;
else
Container := Downcast (Source.Super.Data).Root;
Length := Downcast (Source.Super.Data).Length;
end if;
return Base.Debug.Valid (Container => Container, Length => Length);
end Valid;
end Ada.Containers.Ordered_Sets.Debug;
|
with Ada.Text_IO, Lab10_03;
use Ada.Text_IO, Lab10_03;
procedure Prueba_quitar_repetidos_primero is
L1: T_Lista_Estatica;
begin
Put_Line(" QUITAR REPETIDOS PRIMERO - PRUEBAS");
Put_Line("--------------------------------------");
Put_Line("Caso 01: ()");
Put_Line("--> ()");
L1.Cont := 0;
Quitar_repetidos_primero(L1);
Put("==>");
Escribir_lista(L1);
New_Line;
Put_Line("Caso 02: (8)");
Put_Line("--> (8)");
L1.Cont := 1;
L1.Elem(1) := 8;
Quitar_repetidos_primero(L1);
Put("==>");
Escribir_lista(L1);
New_Line;
Put_Line("Caso 03: (3 3 3 3 3 3 3 3 3 3)");
Put_Line("--> (3)");
L1 := ((OTHERS=>3),10);
L1.Cont := 10;
Quitar_repetidos_primero(L1);
Put("==>");
Escribir_Lista(L1);
New_Line;
Put_Line("Caso 04: (8 8 2 8 6 0 5 6 8)");
Put_Line("--> (8 2 6 0 5 6)");
L1.Cont := 9;
L1.Elem(1..9) := (8,8,2,8,6,0,5,6,8);
Quitar_repetidos_primero(L1);
Put("==>");
Escribir_lista(L1);
New_Line;
Put_Line("Caso 05: (1 2 3 4 5 6 7 8 9)");
Put_Line("--> (1 2 3 4 5 6 7 8 9)");
L1.Cont := 9;
L1.Elem(1..9) := (1,2,3,4,5,6,7,8,9);
Quitar_repetidos_primero(L1);
Put("==>");
Escribir_lista(L1);
New_Line;
Put_Line("Caso 06: (1 1 1 2 2 2 1 1 1)");
Put_Line("--> (1 2 2 2)");
L1.Cont := 9;
L1.Elem(1..9) := (1,1,1,2,2,2,1,1,1);
Quitar_repetidos_primero(L1);
Put("==>");
Escribir_lista(L1);
New_Line;
end Prueba_quitar_repetidos_primero;
|
-- -----------------------------------------------------------------------------
-- smk, the smart make (http://lionel.draghi.free.fr/smk/)
-- © 2018, 2019 Lionel Draghi <lionel.draghi@free.fr>
-- SPDX-License-Identifier: APSL-2.0
-- -----------------------------------------------------------------------------
-- Licensed under the Apache License, Version 2.0 (the "License");
-- you may not use this file except in compliance with the License.
-- You may obtain a copy of the License at
-- http://www.apache.org/licenses/LICENSE-2.0
-- Unless required by applicable law or agreed to in writing, software
-- distributed under the License is distributed on an "AS IS" BASIS,
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-- See the License for the specific language governing permissions and
-- limitations under the License.
-- -----------------------------------------------------------------------------
with Smk.Settings;
package body Smk.Assertions is
-- --------------------------------------------------------------------------
function Image (A : Condition;
Prefix : String := "") return String is
begin
if Settings.Long_Listing_Format then
return (Prefix & "[" & Trigger_Image (A.Trigger) & "] ");
else
return (Prefix);
end if;
end Image;
-- --------------------------------------------------------------------------
function Count (Cond_List : Condition_Lists.List;
Count_Sources : Boolean := False;
Count_Targets : Boolean := False;
With_System_Files : Boolean := False)
return File_Count is
C : File_Count := 0;
begin
for A of Cond_List loop
if With_System_Files or else not Is_System (A.File)
then
if (Count_Sources and then Is_Source (A.File))
or else (Count_Targets and then Is_Target (A.File))
then
C := C + 1;
end if;
end if;
end loop;
return C;
end Count;
-- --------------------------------------------------------------------------
function Count_Image (Count : File_Count) return String is
Raw : constant String := File_Count'Image (Count);
begin
return Raw (2 .. Raw'Last);
end Count_Image;
end Smk.Assertions;
|
pragma License (Unrestricted);
-- implementation unit required by compiler
package System.Exn_LLF is
pragma Pure;
-- required for "**" without checking by compiler (s-exnllf.ads)
function Exn_Float (Left : Float; Right : Integer) return Float
with Import, Convention => Intrinsic, External_Name => "__builtin_powif";
function Exn_Long_Float (Left : Long_Float; Right : Integer)
return Long_Float
with Import, Convention => Intrinsic, External_Name => "__builtin_powi";
function Exn_Long_Long_Float (Left : Long_Long_Float; Right : Integer)
return Long_Long_Float
with Import, Convention => Intrinsic, External_Name => "__builtin_powil";
end System.Exn_LLF;
|
-- part of ParserTools, (c) 2017 Felix Krause
-- released under the terms of the MIT license, see the file "copying.txt"
with Text.Pool;
package Text.Builder is
type Reference is new Ada.Finalization.Controlled with private;
procedure Init (Object : in out Reference; Pool : Text.Pool.Reference;
Initial_Size : Positive := 255);
function Create (Pool : Text.Pool.Reference;
Initial_Size : Positive := 255) return Reference;
function Initialized (Object : Reference) return Boolean;
procedure Append (Object : in out Reference; Value : String)
with Pre => Object.Initialized;
procedure Append (Object : in out Reference; Value : Character)
with Pre => Object.Initialized;
procedure Append (Object : in out Reference; Value : Text.Reference)
with Pre => Object.Initialized;
function Lock (Object : in out Reference) return Text.Reference;
function Length (Object : Reference) return Natural;
private
type Reference is new Ada.Finalization.Controlled with record
Pool : Text.Pool.Reference;
Buffer : UTF_8_String_Access;
Next : System.Storage_Elements.Storage_Offset := 1;
end record;
overriding procedure Adjust (Object : in out Reference);
overriding procedure Finalize (Object : in out Reference);
procedure Grow (Object : in out Reference;
Size : System.Storage_Elements.Storage_Offset);
end Text.Builder;
|
-- CB4003A.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 EXCEPTIONS RAISED DURING ELABORATION OF PACKAGE
-- SPECIFICATIONS, OR DECLARATIVE_PARTS OF BLOCKS AND PACKAGE
-- BODIES, ARE PROPAGATED TO THE STATIC ENVIRONMENT. EXCEPTIONS
-- ARE CAUSED BY INITIALIZATIONS AND FUNCTION CALLS.
-- HISTORY:
-- DAT 04/14/81 CREATED ORIGINAL TEST.
-- JET 01/06/88 UPDATED HEADER FORMAT AND ADDED CODE TO
-- PREVENT OPTIMIZATION.
WITH REPORT; USE REPORT;
PROCEDURE CB4003A IS
E : EXCEPTION;
FUNCTION F (B : BOOLEAN) RETURN INTEGER IS
BEGIN
IF B THEN
RAISE E;
ELSE
RETURN 1;
END IF;
END F;
BEGIN
TEST ("CB4003A", "CHECK THAT EXCEPTIONS DURING ELABORATION"
& " OF DECLARATIVE PARTS"
& " IN BLOCKS, PACKAGE SPECS, AND PACKAGE BODIES ARE"
& " PROPAGATED TO STATIC ENCLOSING ENVIRONMENT");
BEGIN
DECLARE
PACKAGE P1 IS
I : INTEGER RANGE 1 .. 1 := 2;
END P1;
BEGIN
FAILED ("EXCEPTION NOT RAISED 1");
IF NOT EQUAL(P1.I,P1.I) THEN
COMMENT ("NO EXCEPTION RAISED");
END IF;
EXCEPTION
WHEN OTHERS => FAILED ("WRONG HANDLER 1");
END;
FAILED ("EXCEPTION NOT RAISED 1A");
EXCEPTION
WHEN CONSTRAINT_ERROR =>NULL;
WHEN OTHERS => FAILED ("WRONG EXCEPTION 1");
END;
FOR L IN IDENT_INT(1) .. IDENT_INT(4) LOOP
BEGIN
DECLARE
PACKAGE P2 IS
PRIVATE
J : INTEGER RANGE 2 .. 4 := L;
END P2;
Q : INTEGER := F(L = 3);
PACKAGE BODY P2 IS
K : INTEGER := F(L = 2);
BEGIN
IF NOT (EQUAL(J,J) OR EQUAL(K,K)) THEN
COMMENT("CAN'T OPTIMIZE THIS");
END IF;
END P2;
BEGIN
IF L /= 4 THEN
FAILED ("EXCEPTION NOT RAISED 2");
END IF;
IF NOT EQUAL(Q,Q) THEN
COMMENT("CAN'T OPTIMIZE THIS");
END IF;
EXIT;
EXCEPTION
WHEN OTHERS =>
FAILED ("WRONG EXCEPTION HANDLER 2");
EXIT;
END;
FAILED ("EXCEPTION NOT RAISED 2A");
EXCEPTION
WHEN E | CONSTRAINT_ERROR =>
NULL;
WHEN OTHERS => FAILED ("WRONG EXCEPTION RAISED 2");
END;
END LOOP;
RESULT;
END CB4003A;
|
-- Copyright 2015 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 Interfaces.C.Strings;
with Libc.Errno.POSIX_2008;
package Libc.Errno.GNU with
Spark_Mode => Off is
pragma Preelaborate;
program_invocation_name : Interfaces.C.Strings
.chars_ptr; -- /usr/include/errno.h:54
pragma Import (C, program_invocation_name, "program_invocation_name");
program_invocation_short_name : Interfaces.C.Strings
.chars_ptr; -- /usr/include/errno.h:54
pragma Import
(C,
program_invocation_short_name,
"program_invocation_short_name");
ENOTBLK : constant := 15;
ECHRNG : constant := 44;
EL2NSYNC : constant := 45;
EL3HLT : constant := 46;
EL3RST : constant := 47;
ELNRNG : constant := 48;
EUNATCH : constant := 49;
ENOCSI : constant := 50;
EL2HLT : constant := 51;
EBADE : constant := 52;
EBADR : constant := 53;
EXFULL : constant := 54;
ENOANO : constant := 55;
EBADRQC : constant := 56;
EBADSLT : constant := 57;
EDEADLOCK : constant := Libc.Errno.POSIX_2008.EDEADLK;
EBFONT : constant := 59;
ENONET : constant := 64;
ENOPKG : constant := 65;
EREMOTE : constant := 66;
EADV : constant := 68;
ESRMNT : constant := 69;
ECOMM : constant := 70;
EDOTDOT : constant := 73;
ENOTUNIQ : constant := 76;
EBADFD : constant := 77;
EREMCHG : constant := 78;
ELIBACC : constant := 79;
ELIBBAD : constant := 80;
ELIBSCN : constant := 81;
ELIBMAX : constant := 82;
ELIBEXEC : constant := 83;
ERESTART : constant := 85;
ESTRPIPE : constant := 86;
EUSERS : constant := 87;
ESOCKTNOSUPPORT : constant := 94;
EPFNOSUPPORT : constant := 96;
EADDRNOTAVAIL : constant := 99;
ESHUTDOWN : constant := 108;
ETOOMANYREFS : constant := 109;
EHOSTDOWN : constant := 112;
EUCLEAN : constant := 117;
ENOTNAM : constant := 118;
ENAVAIL : constant := 119;
EISNAM : constant := 120;
EREMOTEIO : constant := 121;
ENOMEDIUM : constant := 123;
EMEDIUMTYPE : constant := 124;
ENOKEY : constant := 126;
EKEYEXPIRED : constant := 127;
EKEYREVOKED : constant := 128;
EKEYREJECTED : constant := 129;
ERFKILL : constant := 132;
EHWPOISON : constant := 133;
end Libc.Errno.GNU;
|
-- NORX1641
-- an Ada implementation of the NORX Authenticated Encryption Algorithm
-- created by Jean-Philippe Aumasson, Philipp Jovanovic and Samuel Neves
-- This instantiation words on 16-bit words, with 4 rounds and a parallelism
-- degree of 1. Note that the Key_Position is 2 here, not 4 as it is in all
-- the other instantiations. This was a deliberate decision by the designers in
-- order to keep the lower half of the state initialised in a constant way, as
-- it may be slightly more exposed to differential attacks.
-- Copyright (c) 2016, James Humphry - see LICENSE file for details
pragma SPARK_Mode (On);
with Interfaces;
with NORX;
with NORX_Load_Store;
pragma Elaborate_All(NORX);
use all type Interfaces.Unsigned_16;
package NORX1641 is new NORX(w => 16,
Word => Interfaces.Unsigned_16,
Storage_Array_To_Word => NORX_Load_Store.Storage_Array_To_Unsigned_16,
Word_To_Storage_Array => NORX_Load_Store.Unsigned_16_To_Storage_Array,
l => 4,
k => 96,
Key_Position => 2,
t => 96,
n => 32,
rot => (8, 11, 12, 15),
r => 128,
c => 128);
|
pragma Check_Policy (Trace => Ignore);
package body System.Tasking.Protected_Objects.Entries is
procedure Cancel_Call (Call : not null Node_Access);
procedure Cancel_Call (Call : not null Node_Access) is
begin
-- C940016, not Tasking_Error
Ada.Exceptions.Save_Exception (Call.X, Program_Error'Identity);
Synchronous_Objects.Set (Call.Waiting);
end Cancel_Call;
procedure Cancel_Call (X : in out Synchronous_Objects.Queue_Node_Access);
procedure Cancel_Call (X : in out Synchronous_Objects.Queue_Node_Access) is
Call : constant not null Node_Access := Downcast (X);
begin
Cancel_Call (Call);
end Cancel_Call;
-- implementation
procedure Initialize_Protection_Entries (
Object : not null access Protection_Entries'Class;
Ceiling_Priority : Integer;
Compiler_Info : Address;
Entry_Queue_Maxes : Protected_Entry_Queue_Max_Access;
Entry_Bodies : Protected_Entry_Body_Access;
Find_Body_Index : Find_Body_Index_Access)
is
pragma Unreferenced (Ceiling_Priority);
pragma Unreferenced (Entry_Queue_Maxes);
begin
Synchronous_Objects.Initialize (Object.Mutex);
Synchronous_Objects.Initialize (Object.Calling, Object.Mutex'Access);
Object.Compiler_Info := Compiler_Info;
Object.Entry_Bodies := Entry_Bodies;
Object.Find_Body_Index := Find_Body_Index;
Object.Raised_On_Barrier := False;
end Initialize_Protection_Entries;
overriding procedure Finalize (Object : in out Protection_Entries) is
begin
Cancel_Calls (Object);
Synchronous_Objects.Finalize (Object.Calling);
Synchronous_Objects.Finalize (Object.Mutex);
end Finalize;
procedure Lock_Entries (
Object : not null access Protection_Entries'Class) is
begin
pragma Check (Trace, Ada.Debug.Put ("enter"));
Synchronous_Objects.Enter (Object.Mutex);
pragma Check (Trace, Ada.Debug.Put ("leave"));
end Lock_Entries;
procedure Unlock_Entries (
Object : not null access Protection_Entries'Class) is
begin
pragma Check (Trace, Ada.Debug.Put ("enter"));
Synchronous_Objects.Leave (Object.Mutex);
pragma Check (Trace, Ada.Debug.Put ("leave"));
end Unlock_Entries;
procedure Cancel_Calls (Object : in out Protection_Entries'Class) is
begin
Synchronous_Objects.Cancel (Object.Calling, Cancel_Call'Access);
end Cancel_Calls;
function Get_Ceiling (Object : not null access Protection_Entries'Class)
return Any_Priority is
begin
raise Program_Error; -- unimplemented
return Get_Ceiling (Object);
end Get_Ceiling;
end System.Tasking.Protected_Objects.Entries;
|
------------------------------------------------------------------------------
-- --
-- GNAT RUN-TIME COMPONENTS --
-- --
-- A D A . C A L E N D A R --
-- --
-- B o d y --
-- --
-- $Revision$
-- --
-- Copyright (C) 1992-2001 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 2, or (at your option) any later ver- --
-- sion. GNAT is distributed in the hope that it will be useful, but WITH- --
-- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY --
-- or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License --
-- for more details. You should have received a copy of the GNU General --
-- Public License distributed with GNAT; see file COPYING. If not, write --
-- to the Free Software Foundation, 59 Temple Place - Suite 330, Boston, --
-- MA 02111-1307, USA. --
-- --
-- As a special exception, if other files instantiate generics from this --
-- unit, or you link this unit with other files to produce an executable, --
-- this unit does not by itself cause the resulting executable to be --
-- covered by the GNU General Public License. This exception does not --
-- however invalidate any other reasons why the executable file might be --
-- covered by the GNU Public License. --
-- --
-- GNAT was originally developed by the GNAT team at New York University. --
-- Extensive contributions were provided by Ada Core Technologies Inc. --
-- --
------------------------------------------------------------------------------
with Unchecked_Conversion;
with System.OS_Primitives;
-- used for Clock
package body Ada.Calendar is
------------------------------
-- Use of Pragma Unsuppress --
------------------------------
-- This implementation of Calendar takes advantage of the permission in
-- Ada 95 of using arithmetic overflow checks to check for out of bounds
-- time values. This means that we must catch the constraint error that
-- results from arithmetic overflow, so we use pragma Unsuppress to make
-- sure that overflow is enabled, using software overflow checking if
-- necessary. That way, compiling Calendar with options to suppress this
-- checking will not affect its correctness.
------------------------
-- Local Declarations --
------------------------
type Char_Pointer is access Character;
subtype int is Integer;
subtype long is Long_Integer;
-- Synonyms for C types. We don't want to get them from Interfaces.C
-- because there is no point in loading that unit just for calendar.
type tm is record
tm_sec : int; -- seconds after the minute (0 .. 60)
tm_min : int; -- minutes after the hour (0 .. 59)
tm_hour : int; -- hours since midnight (0 .. 24)
tm_mday : int; -- day of the month (1 .. 31)
tm_mon : int; -- months since January (0 .. 11)
tm_year : int; -- years since 1900
tm_wday : int; -- days since Sunday (0 .. 6)
tm_yday : int; -- days since January 1 (0 .. 365)
tm_isdst : int; -- Daylight Savings Time flag (-1 .. +1)
tm_gmtoff : long; -- offset from CUT in seconds
tm_zone : Char_Pointer; -- timezone abbreviation
end record;
type tm_Pointer is access all tm;
subtype time_t is long;
type time_t_Pointer is access all time_t;
procedure localtime_r (C : time_t_Pointer; res : tm_Pointer);
pragma Import (C, localtime_r, "__gnat_localtime_r");
function mktime (TM : tm_Pointer) return time_t;
pragma Import (C, mktime);
-- mktime returns -1 in case the calendar time given by components of
-- TM.all cannot be represented.
-- The following constants are used in adjusting Ada dates so that they
-- fit into the range that can be handled by Unix (1970 - 2038). The trick
-- is that the number of days in any four year period in the Ada range of
-- years (1901 - 2099) has a constant number of days. This is because we
-- have the special case of 2000 which, contrary to the normal exception
-- for centuries, is a leap year after all.
Unix_Year_Min : constant := 1970;
Unix_Year_Max : constant := 2038;
Ada_Year_Min : constant := 1901;
Ada_Year_Max : constant := 2099;
-- Some basic constants used throughout
Days_In_Month : constant array (Month_Number) of Day_Number :=
(31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31);
Days_In_4_Years : constant := 365 * 3 + 366;
Seconds_In_4_Years : constant := 86_400 * Days_In_4_Years;
Seconds_In_4_YearsD : constant Duration := Duration (Seconds_In_4_Years);
---------
-- "+" --
---------
function "+" (Left : Time; Right : Duration) return Time is
pragma Unsuppress (Overflow_Check);
begin
return (Left + Time (Right));
exception
when Constraint_Error =>
raise Time_Error;
end "+";
function "+" (Left : Duration; Right : Time) return Time is
pragma Unsuppress (Overflow_Check);
begin
return (Time (Left) + Right);
exception
when Constraint_Error =>
raise Time_Error;
end "+";
---------
-- "-" --
---------
function "-" (Left : Time; Right : Duration) return Time is
pragma Unsuppress (Overflow_Check);
begin
return Left - Time (Right);
exception
when Constraint_Error =>
raise Time_Error;
end "-";
function "-" (Left : Time; Right : Time) return Duration is
pragma Unsuppress (Overflow_Check);
begin
return Duration (Left) - Duration (Right);
exception
when Constraint_Error =>
raise Time_Error;
end "-";
---------
-- "<" --
---------
function "<" (Left, Right : Time) return Boolean is
begin
return Duration (Left) < Duration (Right);
end "<";
----------
-- "<=" --
----------
function "<=" (Left, Right : Time) return Boolean is
begin
return Duration (Left) <= Duration (Right);
end "<=";
---------
-- ">" --
---------
function ">" (Left, Right : Time) return Boolean is
begin
return Duration (Left) > Duration (Right);
end ">";
----------
-- ">=" --
----------
function ">=" (Left, Right : Time) return Boolean is
begin
return Duration (Left) >= Duration (Right);
end ">=";
-----------
-- Clock --
-----------
function Clock return Time is
begin
return Time (System.OS_Primitives.Clock);
end Clock;
---------
-- Day --
---------
function Day (Date : Time) return Day_Number is
DY : Year_Number;
DM : Month_Number;
DD : Day_Number;
DS : Day_Duration;
begin
Split (Date, DY, DM, DD, DS);
return DD;
end Day;
-----------
-- Month --
-----------
function Month (Date : Time) return Month_Number is
DY : Year_Number;
DM : Month_Number;
DD : Day_Number;
DS : Day_Duration;
begin
Split (Date, DY, DM, DD, DS);
return DM;
end Month;
-------------
-- Seconds --
-------------
function Seconds (Date : Time) return Day_Duration is
DY : Year_Number;
DM : Month_Number;
DD : Day_Number;
DS : Day_Duration;
begin
Split (Date, DY, DM, DD, DS);
return DS;
end Seconds;
-----------
-- Split --
-----------
procedure Split
(Date : Time;
Year : out Year_Number;
Month : out Month_Number;
Day : out Day_Number;
Seconds : out Day_Duration)
is
-- The following declare bounds for duration that are comfortably
-- wider than the maximum allowed output result for the Ada range
-- of representable split values. These are used for a quick check
-- that the value is not wildly out of range.
Low : constant := (Ada_Year_Min - Unix_Year_Min - 2) * 365 * 86_400;
High : constant := (Ada_Year_Max - Unix_Year_Min + 2) * 365 * 86_400;
LowD : constant Duration := Duration (Low);
HighD : constant Duration := Duration (High);
-- The following declare the maximum duration value that can be
-- successfully converted to a 32-bit integer suitable for passing
-- to the localtime_r function. Note that we cannot assume that the
-- localtime_r function expands to accept 64-bit input on a 64-bit
-- machine, but we can count on a 32-bit range on all machines.
Max_Time : constant := 2 ** 31 - 1;
Max_TimeD : constant Duration := Duration (Max_Time);
-- Finally the actual variables used in the computation
D : Duration;
Frac_Sec : Duration;
Year_Val : Integer;
Adjusted_Seconds : aliased time_t;
Tm_Val : aliased tm;
begin
-- For us a time is simply a signed duration value, so we work with
-- this duration value directly. Note that it can be negative.
D := Duration (Date);
-- First of all, filter out completely ludicrous values. Remember
-- that we use the full stored range of duration values, which may
-- be significantly larger than the allowed range of Ada times. Note
-- that these checks are wider than required to make absolutely sure
-- that there are no end effects from time zone differences.
if D < LowD or else D > HighD then
raise Time_Error;
end if;
-- The unix localtime_r function is more or less exactly what we need
-- here. The less comes from the fact that it does not support the
-- required range of years (the guaranteed range available is only
-- EPOCH through EPOCH + N seconds). N is in practice 2 ** 31 - 1.
-- If we have a value outside this range, then we first adjust it
-- to be in the required range by adding multiples of four years.
-- For the range we are interested in, the number of days in any
-- consecutive four year period is constant. Then we do the split
-- on the adjusted value, and readjust the years value accordingly.
Year_Val := 0;
while D < 0.0 loop
D := D + Seconds_In_4_YearsD;
Year_Val := Year_Val - 4;
end loop;
while D > Max_TimeD loop
D := D - Seconds_In_4_YearsD;
Year_Val := Year_Val + 4;
end loop;
-- Now we need to take the value D, which is now non-negative, and
-- break it down into seconds (to pass to the localtime_r function)
-- and fractions of seconds (for the adjustment below).
-- Surprisingly there is no easy way to do this in Ada, and certainly
-- no easy way to do it and generate efficient code. Therefore we
-- do it at a low level, knowing that it is really represented as
-- an integer with units of Small
declare
type D_Int is range 0 .. 2 ** (Duration'Size - 1) - 1;
for D_Int'Size use Duration'Size;
Small_Div : constant D_Int := D_Int (1.0 / Duration'Small);
D_As_Int : D_Int;
function To_D_As_Int is new Unchecked_Conversion (Duration, D_Int);
function To_Duration is new Unchecked_Conversion (D_Int, Duration);
begin
D_As_Int := To_D_As_Int (D);
Adjusted_Seconds := time_t (D_As_Int / Small_Div);
Frac_Sec := To_Duration (D_As_Int rem Small_Div);
end;
localtime_r (Adjusted_Seconds'Unchecked_Access, Tm_Val'Unchecked_Access);
Year_Val := Tm_Val.tm_year + 1900 + Year_Val;
Month := Tm_Val.tm_mon + 1;
Day := Tm_Val.tm_mday;
-- The Seconds value is a little complex. The localtime function
-- returns the integral number of seconds, which is what we want,
-- but we want to retain the fractional part from the original
-- Time value, since this is typically stored more accurately.
Seconds := Duration (Tm_Val.tm_hour * 3600 +
Tm_Val.tm_min * 60 +
Tm_Val.tm_sec)
+ Frac_Sec;
-- Note: the above expression is pretty horrible, one of these days
-- we should stop using time_of and do everything ourselves to avoid
-- these unnecessary divides and multiplies???.
-- The Year may still be out of range, since our entry test was
-- deliberately crude. Trying to make this entry test accurate is
-- tricky due to time zone adjustment issues affecting the exact
-- boundary. It is interesting to note that whether or not a given
-- Calendar.Time value gets Time_Error when split depends on the
-- current time zone setting.
if Year_Val not in Ada_Year_Min .. Ada_Year_Max then
raise Time_Error;
else
Year := Year_Val;
end if;
end Split;
-------------
-- Time_Of --
-------------
function Time_Of
(Year : Year_Number;
Month : Month_Number;
Day : Day_Number;
Seconds : Day_Duration := 0.0)
return Time
is
Result_Secs : aliased time_t;
TM_Val : aliased tm;
Int_Secs : constant Integer := Integer (Seconds);
Year_Val : Integer := Year;
Duration_Adjust : Duration := 0.0;
begin
-- The following checks are redundant with respect to the constraint
-- error checks that should normally be made on parameters, but we
-- decide to raise Constraint_Error in any case if bad values come
-- in (as a result of checks being off in the caller, or for other
-- erroneous or bounded error cases).
if not Year 'Valid
or else not Month 'Valid
or else not Day 'Valid
or else not Seconds'Valid
then
raise Constraint_Error;
end if;
-- Check for Day value too large (one might expect mktime to do this
-- check, as well as the basi checks we did with 'Valid, but it seems
-- that at least on some systems, this built-in check is too weak).
if Day > Days_In_Month (Month)
and then (Day /= 29 or Month /= 2 or Year mod 4 /= 0)
then
raise Time_Error;
end if;
TM_Val.tm_sec := Int_Secs mod 60;
TM_Val.tm_min := (Int_Secs / 60) mod 60;
TM_Val.tm_hour := (Int_Secs / 60) / 60;
TM_Val.tm_mday := Day;
TM_Val.tm_mon := Month - 1;
-- For the year, we have to adjust it to a year that Unix can handle.
-- We do this in four year steps, since the number of days in four
-- years is constant, so the timezone effect on the conversion from
-- local time to GMT is unaffected.
while Year_Val <= Unix_Year_Min loop
Year_Val := Year_Val + 4;
Duration_Adjust := Duration_Adjust - Seconds_In_4_YearsD;
end loop;
while Year_Val >= Unix_Year_Max loop
Year_Val := Year_Val - 4;
Duration_Adjust := Duration_Adjust + Seconds_In_4_YearsD;
end loop;
TM_Val.tm_year := Year_Val - 1900;
-- Since we do not have information on daylight savings,
-- rely on the default information.
TM_Val.tm_isdst := -1;
Result_Secs := mktime (TM_Val'Unchecked_Access);
-- That gives us the basic value in seconds. Two adjustments are
-- needed. First we must undo the year adjustment carried out above.
-- Second we put back the fraction seconds value since in general the
-- Day_Duration value we received has additional precision which we
-- do not want to lose in the constructed result.
return
Time (Duration (Result_Secs) +
Duration_Adjust +
(Seconds - Duration (Int_Secs)));
end Time_Of;
----------
-- Year --
----------
function Year (Date : Time) return Year_Number is
DY : Year_Number;
DM : Month_Number;
DD : Day_Number;
DS : Day_Duration;
begin
Split (Date, DY, DM, DD, DS);
return DY;
end Year;
end Ada.Calendar;
|
with Ada.Text_IO;
with Ada.Integer_Text_IO;
procedure TableSorting is
package IO renames Ada.Text_IO;
package I_IO renames Ada.Integer_Text_IO;
Num_Elements : constant := 14;
type Extended_Index is new Integer range 1 .. Num_Elements + 1;
subtype Index is Extended_Index range 1 .. Num_Elements;
a : Array(Index'Range) of Integer;
output_width : constant := 3;
count : Natural := 0;
procedure Print_Array is
begin
for i in Index'Range loop
I_IO.put(a(i), Width => output_width);
if i = Index'Last then
IO.New_Line;
else
IO.Put(' ');
end if;
end loop;
end Print_Array;
-- Standard next Lexicographic order permutation function from Knuth modified slightly
-- to ensure all indexes stay in bounds since I'm in Ada and it checks those things.
procedure Permute is
i : Index;
j : Index;
temp : Integer;
begin
-- Output
count := count + 1;
loop
i := Index'Last;
j := Index'Last;
-- Find left pivot (first item that is less than a successor)
while i > Index'First and then a(i - 1) >= a(i) loop
i := i - 1;
end loop;
-- Dropped off the left side, no more pivots.
exit when i = Index'First;
-- Previously i was the head of the ascending suffix, change it to be the pivot.
i := i - 1;
-- Find the rightmost element that exceeds our pivot
while a(j) <= a(i) loop
j := j - 1;
end loop;
-- Swap the pivot and that element
temp := a(i);
a(i) := a(j);
a(j) := temp;
-- Reverse the suffix
i := i + 1;
j := Index'Last;
while i < j loop
temp := a(i);
a(i) := a(j);
a(j) := temp;
i := i + 1;
j := j - 1;
end loop;
-- Output
count := count + 1;
end loop;
end Permute;
procedure Initialize(start : Extended_Index; size : Index) is
next : Extended_Index := start;
begin
if size = 1 then
for i in start .. Index'Last loop
a(i) := 100 + Integer(start);
end loop;
count := 0;
Permute;
for i in Index'First .. Index'Last / 2 loop
declare
j : constant Index := Index'Last - i + 1;
temp : constant Integer := a(i);
begin
a(i) := a(j);
a(j) := temp;
end;
end loop;
IO.Put(Natural'Image(count) & " iterations to solve: ");
Print_Array;
else
Initialize(next, size - 1);
while next + size <= Extended_Index'Last loop
for i in 0 .. size - 1 loop
a(next + i) := Integer(next);
end loop;
next := next + size;
Initialize(next, size - 1);
end loop;
end if;
end Initialize;
begin
Initialize(Index'First, 4);
-- for i in Index'Range loop
-- a(i) := Integer(i);
-- end loop;
-- loop
-- Print_Array;
-- exit when not Next_Permutation;
-- end loop;
end TableSorting;
|
--
-- Copyright 2018 The wookey project team <wookey@ssi.gouv.fr>
-- - Ryad Benadjila
-- - Arnauld Michelizza
-- - Mathieu Renard
-- - Philippe Thierry
-- - Philippe Trebuchet
--
-- Licensed under the Apache License, Version 2.0 (the "License");
-- you may not use this file except in compliance with the License.
-- You may obtain a copy of the License at
--
-- http://www.apache.org/licenses/LICENSE-2.0
--
-- Unless required by applicable law or agreed to in writing, software
-- distributed under the License is distributed on an "AS IS" BASIS,
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-- See the License for the specific language governing permissions and
-- limitations under the License.
--
--
with system;
package soc.pwr
with spark_mode => off
is
-------------------------------------------
-- PWR power control register (PWR_CR) --
-- STM32F405xx/07xx and STM32F415xx/17xx --
-------------------------------------------
type t_vos is (VOS_SCALE2, VOS_SCALE1) with size => 1;
for t_vos use
(VOS_SCALE2 => 0,
VOS_SCALE1 => 1);
type t_PWR_CR is record
LPDS : bit;
PDDS : bit;
CWUF : bit;
CSBF : bit;
PVDE : bit;
PLS : bits_3;
DBP : bit;
FPDS : bit;
reserved_10_13 : bits_4;
VOS : t_vos;
reserved_15_31 : bits_17;
end record
with volatile_full_access, size => 32;
for t_PWR_CR use record
LPDS at 0 range 0 .. 0;
PDDS at 0 range 1 .. 1;
CWUF at 0 range 2 .. 2;
CSBF at 0 range 3 .. 3;
PVDE at 0 range 4 .. 4;
PLS at 0 range 5 .. 7;
DBP at 0 range 8 .. 8;
FPDS at 0 range 9 .. 9;
reserved_10_13 at 0 range 10 .. 13;
VOS at 0 range 14 .. 14;
reserved_15_31 at 0 range 15 .. 31;
end record;
--------------------
-- PWR peripheral --
--------------------
type t_PWR_peripheral is record
CR : t_PWR_CR;
end record
with volatile;
for t_PWR_peripheral use record
CR at 16#00# range 0 .. 31;
end record;
PWR : t_PWR_peripheral
with
import,
volatile,
address => system'to_address(16#4000_7000#);
end soc.pwr;
|
with Ada.Text_IO; use Ada.Text_IO;
with Ada.Integer_Text_IO; use Ada.Integer_Text_IO;
procedure pgcd is
function PGCD_Euclide (a : Integer; b : Integer) return Integer is
p : Integer := a;
q : Integer := b;
r : Integer;
begin
while q /= 0 loop
r := p;
p := q;
q := r mod p;
end loop;
return p;
end PGCD_Euclide;
function PGCD_Diff (a : Integer; b : Integer) return Integer is
p : Integer := a;
q : Integer := b;
begin
while p /= q loop
if p > q then
p := p - q;
else
q := q - p;
end if;
end loop;
return p;
end PGCD_Diff;
a, b : Integer;
begin
loop
Put(">>> a = ");
Get(a);
exit when a = -1;
Put(">>> b = ");
Get(b);
Put_Line("Euclide : " & Integer'Image(PGCD_Euclide(a, b)));
Put_Line("Différences : " & Integer'Image(PGCD_Diff(a, b)));
end loop;
end pgcd;
|
-- { dg-do run }
procedure Case_Character is
function Test (C : Character) return Integer is
begin
case C is
when ASCII.HT | ' ' .. Character'Last => return 1;
when others => return 0;
end case;
end;
begin
if Test ('A') /= 1 then
raise Program_Error;
end if;
end;
|
-------------------------------------------------------------------------------
-- LSE -- L-System Editor
-- Author: Heziode
--
-- License:
-- MIT License
--
-- Copyright (c) 2018 Quentin Dauprat (Heziode) <Heziode@protonmail.com>
--
-- 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.Float_Text_IO;
with Ada.Numerics;
with Ada.Numerics.Elementary_Functions;
with Ada.Text_IO;
with LSE.Utils.Coordinate_2D;
with LSE.Utils.Coordinate_2D_Ptr;
with LSE.Utils.Utils;
package body LSE.Model.IO.Turtle is
function Initialize return Instance
is
This : Instance;
begin
return This;
end Initialize;
procedure Set_Width (This : out Instance; Value : Positive)
is
begin
This.Width := Value;
end Set_Width;
procedure Set_Height (This : out Instance; Value : Positive)
is
begin
This.Height := Value;
end Set_Height;
procedure Set_Background_Color (This : out Instance;
Value : String)
is
begin
This.Background_Color := To_Unbounded_String (Value);
end Set_Background_Color;
procedure Set_Foreground_Color (This : out Instance; Value : String)
is
begin
This.Foreground_Color := To_Unbounded_String (Value);
end Set_Foreground_Color;
procedure Set_Angle (This : out Instance;
Value : LSE.Utils.Angle.Angle)
is
begin
This.Angle := Value;
end Set_Angle;
function Get_Width (This : Instance) return Positive
is
begin
return This.Width;
end Get_Width;
function Get_Height (This : Instance) return Positive
is
begin
return This.Height;
end Get_Height;
function Get_Background_Color (This : Instance) return String
is
begin
return To_String (This.Background_Color);
end Get_Background_Color;
function Get_Foreground_Color (This : Instance) return String
is
begin
return To_String (This.Foreground_Color);
end Get_Foreground_Color;
function Get_Offset_X (This : Instance) return Float
is
begin
return This.Offset_X;
end Get_Offset_X;
function Get_Offset_Y (This : Instance) return Float
is
begin
return This.Offset_Y;
end Get_Offset_Y;
function Get_Max_X (This : Instance) return Float
is
begin
return This.Max_X;
end Get_Max_X;
function Get_Max_Y (This : Instance) return Float
is
begin
return This.Max_Y;
end Get_Max_Y;
function Get_Min_X (This : Instance) return Float
is
begin
return This.Min_X;
end Get_Min_X;
function Get_Min_Y (This : Instance) return Float
is
begin
return This.Min_Y;
end Get_Min_Y;
procedure Set_Max_X (This : out Instance; Value : Float)
is
begin
This.Max_X := Value;
end Set_Max_X;
procedure Set_Max_Y (This : out Instance; Value : Float)
is
begin
This.Max_Y := Value;
end Set_Max_Y;
procedure Set_Min_X (This : out Instance; Value : Float)
is
begin
This.Min_X := Value;
end Set_Min_X;
procedure Set_Min_Y (This : out Instance; Value : Float)
is
begin
This.Min_Y := Value;
end Set_Min_Y;
function Get_Margin_Top (This : Instance) return Float
is
begin
return This.Margin_Top;
end Get_Margin_Top;
function Get_Margin_Right (This : Instance) return Float
is
begin
return This.Margin_Right;
end Get_Margin_Right;
function Get_Margin_Bottom (This : Instance) return Float
is
begin
return This.Margin_Bottom;
end Get_Margin_Bottom;
function Get_Margin_Left (This : Instance) return Float
is
begin
return This.Margin_Left;
end Get_Margin_Left;
function Get_Medium (This : Instance)
return LSE.Model.IO.Drawing_Area.Drawing_Area_Ptr.Holder
is
begin
return This.Medium;
end Get_Medium;
procedure Set_Margin_Top (This : out Instance; Value : Natural)
is
begin
This.Margin_Top := Float (Value);
end Set_Margin_Top;
procedure Set_Margin_Right (This : out Instance; Value : Natural)
is
begin
This.Margin_Right := Float (Value);
end Set_Margin_Right;
procedure Set_Margin_Bottom (This : out Instance; Value : Natural)
is
begin
This.Margin_Bottom := Float (Value);
end Set_Margin_Bottom;
procedure Set_Margin_Left (This : out Instance; Value : Natural)
is
begin
This.Margin_Left := Float (Value);
end Set_Margin_Left;
procedure Set_Margin (This : out Instance; Value : Natural)
is
begin
This.Margin_Top := Float (Value);
This.Margin_Right := Float (Value);
This.Margin_Bottom := Float (Value);
This.Margin_Left := Float (Value);
end Set_Margin;
procedure Set_Medium (This : out Instance;
Value : LSE.Model.IO.Drawing_Area.Drawing_Area_Ptr.Holder)
is
begin
This.Medium := Value;
end Set_Medium;
procedure Set_Dry_Run (This : out Instance; Value : Boolean)
is
begin
This.Dry_Run := Value;
end Set_Dry_Run;
procedure Put (This : Instance)
is
use Ada.Text_IO;
use Ada.Float_Text_IO;
begin
Put_Line ("Turtle:");
Put_Line (" Width :" & Positive'Image (This.Width));
Put_Line (" Height :" & Positive'Image (This.Height));
Put_Line (" Background_Color : " & To_String (This.Background_Color));
Put_Line (" Foreground_Color : " & To_String (This.Foreground_Color));
Put (" Line_Size : ");
Put (Item => This.Line_Size, Aft => 2, Exp => 0);
New_Line;
Put (" Angle :");
Put (Item => Float (This.Angle), Aft => 2, Exp => 0);
New_Line;
Put (" Max_X :");
Put (Item => This.Max_X, Aft => 2, Exp => 0);
New_Line;
Put (" Max_Y :");
Put (Item => This.Max_Y, Aft => 2, Exp => 0);
New_Line;
Put (" Min_X :");
Put (Item => This.Min_X, Aft => 2, Exp => 0);
New_Line;
Put (" Min_Y :");
Put (Item => This.Min_Y, Aft => 2, Exp => 0);
New_Line;
Put (" Ratio :");
Put (Item => This.Ratio, Aft => 2, Exp => 0);
New_Line;
Put (" Offset_X :");
Put (Item => This.Offset_X, Aft => 2, Exp => 0);
New_Line;
Put (" Offset_Y :");
Put (Item => This.Offset_Y, Aft => 2, Exp => 0);
New_Line;
Put (" Margin_Top :");
Put (Item => This.Margin_Top, Aft => 2, Exp => 0);
New_Line;
Put (" Margin_Right :");
Put (Item => This.Margin_Right, Aft => 2, Exp => 0);
New_Line;
Put (" Margin_Bottom :");
Put (Item => This.Margin_Bottom, Aft => 2, Exp => 0);
New_Line;
Put (" Margin_Left :");
Put (Item => This.Margin_Left, Aft => 2, Exp => 0);
New_Line;
end Put;
procedure Make_Offset (This : in out Instance)
is
Boxed_Width : constant Float :=
Float (This.Width) - This.Margin_Right - This.Margin_Left;
Boxed_Height : constant Float :=
Float (This.Height) - This.Margin_Top - This.Margin_Bottom;
begin
if (This.Max_X - This.Min_X) = 0.0 or (This.Max_Y - This.Min_Y) = 0.0
then
raise Divide_By_Zero;
end if;
if Boxed_Width / (This.Max_X - This.Min_X) <=
Boxed_Height / (This.Max_Y - This.Min_Y)
then
-- X has the smallest delta
This.Ratio := Boxed_Width / (This.Max_X - This.Min_X);
else
-- Y has the smallest delta
This.Ratio := Boxed_Height / (This.Max_Y - This.Min_Y);
end if;
This.Offset_X := (Boxed_Width / 2.0) -
(((This.Ratio * This.Max_X
- This.Ratio * This.Min_X) / 2.0)
+ This.Ratio * This.Min_X);
This.Offset_Y := (Boxed_Height / 2.0) -
(((This.Ratio * This.Max_Y
- This.Ratio * This.Min_Y) / 2.0)
+ This.Ratio * This.Min_Y);
end Make_Offset;
procedure Configure (This : in out Instance)
is
use Ada.Strings;
begin
if not This.Dry_Run then
This.Make_Offset;
end if;
This.Stack_Angle.Clear;
This.Stack_Coordinate.Clear;
if This.Dry_Run then
This.Max_X := 0.0;
This.Max_Y := 0.0;
This.Min_X := 0.0;
This.Min_Y := 0.0;
else
-- Configure the medium
This.Medium.Reference.Configure (This);
end if;
This.Stack_Angle.Append (LSE.Utils.Angle.To_Angle (90.0));
This.Stack_Coordinate.Append (
LSE.Utils.Coordinate_2D_Ptr.To_Holder (
LSE.Utils.Coordinate_2D.Initialize));
end Configure;
procedure Draw (This : in out Instance)
is
begin
if not This.Dry_Run then
This.Medium.Reference.Draw;
end if;
end Draw;
procedure Forward (This : in out Instance; Trace : Boolean := False)
is
use Ada.Float_Text_IO;
use Ada.Numerics.Elementary_Functions;
------------------------
-- Methods prototype --
------------------------
-- Callback of Update_Element of Stack_Coordinate
procedure Update (Item : in out LSE.Utils.Coordinate_2D_Ptr.Holder);
-- Update all corners of the L-System edges
procedure Update_Corners (This : in out Instance);
-----------------------------
-- Declaration of methods --
-----------------------------
procedure Update (Item : in out LSE.Utils.Coordinate_2D_Ptr.Holder)
is
Copy : LSE.Utils.Coordinate_2D_Ptr.Holder := Item;
X : constant Float := This.Ratio *
This.Line_Size * Cos (This.Stack_Angle.Last_Element, Degrees_Cycle);
Y : constant Float := This.Ratio *
This.Line_Size * Sin (This.Stack_Angle.Last_Element, Degrees_Cycle);
begin
Copy.Reference.Set_X (X);
Copy.Reference.Set_Y (Y);
Item.Move (Copy);
end Update;
procedure Update_Corners (This : in out Instance)
is
X, Y : Float := 0.0;
begin
for H of reverse This.Stack_Coordinate loop
X := X + H.Reference.Get_X;
Y := Y + H.Reference.Get_Y;
end loop;
if X < This.Min_X then
This.Min_X := X;
elsif X > This.Max_X then
This.Max_X := X;
end if;
if Y < This.Min_Y then
This.Min_Y := Y;
elsif Y > This.Max_Y then
This.Max_Y := Y;
end if;
end Update_Corners;
---------------
-- Variables --
---------------
Copy : LSE.Utils.Coordinate_2D_Ptr.Holder :=
This.Stack_Coordinate.Last_Element.Copy;
begin
This.Stack_Coordinate.Update_Element
(Index => This.Stack_Coordinate.Last_Index,
Process => Update'Access);
if not This.Dry_Run then
This.Medium.Reference.Forward
(This.Stack_Coordinate.Last_Element.Element, Trace);
end if;
Copy.Reference.Set_X (This.Stack_Coordinate.Last_Element.Element.Get_X +
Copy.Reference.Get_X);
Copy.Reference.Set_Y (This.Stack_Coordinate.Last_Element.Element.Get_Y +
Copy.Reference.Get_Y);
This.Stack_Coordinate.Delete_Last;
This.Stack_Coordinate.Append (Copy);
if This.Dry_Run then
Update_Corners (This);
end if;
end Forward;
procedure Rotate_Clockwise (This : in out Instance)
is
begin
This.Stack_Angle.Replace_Element
(This.Stack_Angle.Last,
To_Angle (This.Stack_Angle.Last_Element - This.Angle));
if not This.Dry_Run then
This.Medium.Reference.Rotate_Clockwise;
end if;
end Rotate_Clockwise;
procedure Rotate_Anticlockwise (This : in out Instance)
is
begin
This.Stack_Angle.Replace_Element
(This.Stack_Angle.Last,
To_Angle (This.Stack_Angle.Last_Element + This.Angle));
if not This.Dry_Run then
This.Medium.Reference.Rotate_Anticlockwise;
end if;
end Rotate_Anticlockwise;
procedure UTurn (This : in out Instance)
is
begin
This.Stack_Angle.Replace_Element
(This.Stack_Angle.Last,
To_Angle (This.Stack_Angle.Last_Element + 180.0));
if not This.Dry_Run then
This.Medium.Reference.UTurn;
end if;
end UTurn;
procedure Position_Save (This : in out Instance)
is
begin
This.Stack_Coordinate.Append (LSE.Utils.Coordinate_2D_Ptr.To_Holder (
LSE.Utils.Coordinate_2D.Initialize));
This.Stack_Angle.Append (LSE.Utils.Angle.To_Angle (
This.Stack_Angle.Last_Element));
if not This.Dry_Run then
This.Medium.Reference.Position_Save;
end if;
end Position_Save;
procedure Position_Restore (This : in out Instance)
is
use LSE.Utils.Utils;
Item : LSE.Utils.Coordinate_2D_Ptr.Holder;
X : Fixed_Point;
Y : Fixed_Point;
begin
Item := This.Stack_Coordinate.Last_Element;
X := -Fixed_Point (Item.Element.Get_X);
Y := -Fixed_Point (Item.Element.Get_Y);
This.Stack_Angle.Delete_Last;
This.Stack_Coordinate.Delete_Last;
if not This.Dry_Run then
This.Medium.Reference.Position_Restore (X, Y);
end if;
end Position_Restore;
end LSE.Model.IO.Turtle;
|
with Unchecked_Conversion;
package Rep_Clause2 is
type Tiny is range 0 .. 3;
for Tiny'Size use 2;
type Small is range 0 .. 255;
for Small'Size use 8;
type Small_Data is record
D : Tiny;
N : Small;
end record;
pragma Pack (Small_Data);
type Chunk is
record
S : Small_Data;
C : Character;
end record;
for Chunk use record
S at 0 range 0 .. 15;
C at 2 range 0 .. 7;
end record;
type Index is range 1 .. 10;
type Data_Array is array (Index) of Chunk;
for Data_Array'Alignment use 2;
pragma Pack (Data_Array);
type Data is record
D : Data_Array;
end record;
type Bit is range 0 .. 1;
for Bit'Size use 1;
type Bit_Array is array (Positive range <>) of Bit;
pragma Pack (Bit_Array);
type Byte is new Bit_Array (1 .. 8);
for Byte'Size use 8;
for Byte'Alignment use 1;
function Conv
is new Unchecked_Conversion(Source => Small, Target => Byte);
procedure Assign (From : Data; Offset : Positive; I : Index; To : out Bit_Array);
end Rep_Clause2;
|
package Examples.Ast is
procedure Demo (Project_Name : String; File_Name : String);
end Examples.Ast;
|
-----------------------------------------------------------------------
-- are-generator-ada2012 -- Generator for Ada
-- Copyright (C) 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.Calendar.Conversions;
with Interfaces.C;
with Util.Files;
with Util.Log.Loggers;
with GNAT.Perfect_Hash_Generators;
package body Are.Generator.Ada2012 is
use Ada.Text_IO;
use Ada.Strings.Unbounded;
use type Ada.Containers.Count_Type;
function Get_Function_Type (Generator : in Generator_Type;
Resource : in Are.Resource_Type;
Context : in Are.Context_Type'Class) return String;
function Get_Content_Type (Generator : in Generator_Type;
Resource : in Are.Resource_Type;
Context : in Are.Context_Type'Class) return String;
function Get_Import_Type (Cur_Pkg : in String;
Type_Name : in String) return String;
-- Generate the resource declaration list.
procedure Generate_Resource_Declarations (Resource : in Are.Resource_Type;
Into : in out Ada.Text_IO.File_Type;
Content_Type : in String;
Var_Prefix : in String);
-- Generate the resource content definition.
procedure Generate_Resource_Contents (Resource : in Are.Resource_Type;
Into : in out Ada.Text_IO.File_Type;
Declare_Var : in Boolean;
Content_Type : in String;
Var_Prefix : in String);
Log : constant Util.Log.Loggers.Logger := Util.Log.Loggers.Create ("Are.Generator.Ada2012");
-- ------------------------------
-- Generate the Ada code for the resources that have been collected.
-- ------------------------------
overriding
procedure Generate (Generator : in out Generator_Type;
Resources : in Resource_List;
Context : in out Are.Context_Type'Class) is
Resource : Resource_Access := Resources.Head;
begin
while Resource /= null loop
if Context.Name_Index then
Resource.Collect_Names (Context.Ignore_Case, Generator.Names);
if Generator.Names.Length > 1 then
Generator.Generate_Perfect_Hash (Resource.all, Context);
end if;
end if;
Generator.Generate_Specs (Resource.all, Context);
Generator.Generate_Body (Resource.all, Context);
Generator.Names.Clear;
Resource := Resource.Next;
end loop;
end Generate;
-- ------------------------------
-- Setup the command line configuration to accept specific generation options.
-- ------------------------------
overriding
procedure Setup (Generator : in out Generator_Type;
Config : in out GC.Command_Line_Configuration) is
begin
GC.Define_Switch (Config => Config,
Output => Generator.Pragma_Preelaborate'Access,
Long_Switch => "--preelaborate",
Help => -("[Ada] Generate a pragma Preelaborate in the specification"));
GC.Define_Switch (Config => Config,
Output => Generator.Content_Only'Access,
Long_Switch => "--content-only",
Help => -("[Ada] Give access only to the file content"));
end Setup;
function Get_Function_Type (Generator : in Generator_Type;
Resource : in Are.Resource_Type;
Context : in Are.Context_Type'Class) return String is
Def_Type : constant String := (if Generator.Content_Only then
"Content_Access" else "Content_Type");
begin
return Resource.Get_Type_Name (Context, Def_Type);
end Get_Function_Type;
function Get_Content_Type (Generator : in Generator_Type;
Resource : in Are.Resource_Type;
Context : in Are.Context_Type'Class) return String is
Func_Type : constant String := Get_Function_Type (Generator, Resource, Context);
begin
if Resource.Format = R_LINES then
return Resource.Get_Content_Type_Name (Context, "Content_Array");
end if;
if Util.Strings.Starts_With (Func_Type, "access constant ") then
return Resource.Get_Content_Type_Name
(Context, Func_Type (Func_Type'First + 16 .. Func_Type'Last));
end if;
if Resource.Format = R_STRING then
return Resource.Get_Content_Type_Name (Context, "String");
end if;
return Resource.Get_Content_Type_Name (Context, "Ada.Streams.Stream_Element_Array");
end Get_Content_Type;
-- ------------------------------
-- Get the import package name for the given type. We try to guess if
-- `Type_Name` is declared in a parent package of the current unit.
-- ------------------------------
function Get_Import_Type (Cur_Pkg : in String;
Type_Name : in String) return String is
Pos : constant Natural := Util.Strings.Rindex (Type_Name, '.');
begin
if Pos = 0 then
return "";
end if;
declare
Pkg_Name : constant String := Type_Name (Type_Name'First .. Pos - 1);
begin
if Util.Strings.Starts_With (Cur_Pkg, Pkg_Name) then
return "";
end if;
return Pkg_Name;
end;
end Get_Import_Type;
-- ------------------------------
-- Given a package name, return the file name that correspond.
-- ------------------------------
function To_File_Name (Name : in String) return String is
Result : String (Name'Range);
begin
for J in Name'Range loop
if Name (J) in 'A' .. 'Z' then
Result (J) := Character'Val (Character'Pos (Name (J))
- Character'Pos ('A')
+ Character'Pos ('a'));
elsif Name (J) = '.' then
Result (J) := '-';
else
Result (J) := Name (J);
end if;
end loop;
return Result;
end To_File_Name;
function To_Ada_Name (Prefix : in String;
Name : in String) return String is
Result : Unbounded_String;
begin
Append (Result, Prefix);
for C of Name loop
if C = '-' or C = '.' then
Append (Result, '_');
elsif C >= 'a' and C <= 'z' then
Append (Result, C);
elsif C >= 'A' and C <= 'Z' then
Append (Result, C);
elsif C >= '0' and C <= '9' then
Append (Result, C);
end if;
end loop;
return To_String (Result);
end To_Ada_Name;
-- ------------------------------
-- Generate the perfect hash implementation used by the name indexer.
-- ------------------------------
procedure Generate_Perfect_Hash (Generator : in out Generator_Type;
Resource : in Are.Resource_Type;
Context : in out Are.Context_Type'Class) is
Count : constant Positive := Positive (Generator.Names.Length);
Pkg : constant String := To_String (Resource.Name);
Seed : constant Natural := 4321; -- Needed by the hash algorithm
K_2_V : Float;
V : Natural;
begin
-- Collect the keywords for the hash.
for Name of Generator.Names loop
declare
-- SCz 2021-07-03: s-pehage.adb:1900 index check failed is raised
-- if we give a string that has a first index > 1. Make a copy
-- with new bounds.
Word : constant String (1 .. Name'Length) := Name;
begin
GNAT.Perfect_Hash_Generators.Insert (Word);
end;
end loop;
-- Generate the perfect hash package.
V := 2 * Count + 1;
loop
K_2_V := Float (V) / Float (Count);
GNAT.Perfect_Hash_Generators.Initialize (Seed, K_2_V);
begin
GNAT.Perfect_Hash_Generators.Compute;
exit;
exception
when GNAT.Perfect_Hash_Generators.Too_Many_Tries =>
V := V + 1;
end;
end loop;
GNAT.Perfect_Hash_Generators.Produce (Pkg_Name => Pkg);
GNAT.Perfect_Hash_Generators.Finalize;
-- The perfect hash generator can only write files in the current directory.
-- Move them to the target directory.
if Context.Output'Length > 0 and Context.Output.all /= "." then
declare
Filename : String := To_File_Name (Pkg) & ".ads";
Path : String := Context.Get_Output_Path (Filename);
begin
if Ada.Directories.Exists (Path) then
Ada.Directories.Delete_File (Path);
end if;
Ada.Directories.Rename (Filename, Path);
Filename (Filename'Last) := 'b';
Path (Path'Last) := 'b';
if Ada.Directories.Exists (Path) then
Ada.Directories.Delete_File (Path);
end if;
Ada.Directories.Rename (Filename, Path);
end;
end if;
end Generate_Perfect_Hash;
-- ------------------------------
-- Generate the resource declaration list.
-- ------------------------------
procedure Generate_Resource_Declarations (Resource : in Are.Resource_Type;
Into : in out Ada.Text_IO.File_Type;
Content_Type : in String;
Var_Prefix : in String) is
begin
for File in Resource.Files.Iterate loop
Put (Into, " ");
Put (Into, To_Ada_Name (Var_Prefix, File_Maps.Key (File)));
Put (Into, " : aliased constant ");
Put (Into, Content_Type);
Put_Line (Into, ";");
end loop;
New_Line (Into);
end Generate_Resource_Declarations;
-- ------------------------------
-- Generate the resource content definition.
-- ------------------------------
procedure Generate_Resource_Contents (Resource : in Are.Resource_Type;
Into : in out Ada.Text_IO.File_Type;
Declare_Var : in Boolean;
Content_Type : in String;
Var_Prefix : in String) is
function Get_Variable_Name (Key : in String) return String;
procedure Write_Binary (Name : in String;
Content : in Are.File_Info);
procedure Write_String (Content : in String);
procedure Write_String (Name : in String;
Content : in Are.File_Info);
procedure Write_Lines (Name : in String;
Content : in Are.File_Info);
procedure Write_Binary (Name : in String;
Content : in Are.File_Info) is
Need_Sep : Boolean := False;
Column : Natural := 0;
begin
Put (Into, " ");
Put (Into, Name);
Put (Into, " : aliased constant ");
Put (Into, Content_Type);
if Content.Content = null or else Content.Content'Length = 0 then
Put_Line (Into, "(1 .. 0) := (others => <>);");
elsif Content.Content'Length = 1 then
Put (Into, " := (0 => ");
Put (Into, Util.Strings.Image (Natural (Content.Content (Content.Content'First))));
Put_Line (Into, ");");
else
Put_Line (Into, " :=");
Put (Into, " (");
for C of Content.Content.all loop
if Need_Sep then
Put (Into, ",");
Need_Sep := False;
end if;
if Column > 20 then
New_Line (Into);
Put (Into, " ");
Column := 1;
elsif Column > 0 then
Put (Into, " ");
end if;
Put (Into, Util.Strings.Image (Natural (C)));
Column := Column + 1;
Need_Sep := True;
end loop;
Put_Line (Into, ");");
end if;
end Write_Binary;
procedure Write_String (Content : in String) is
Need_Sep : Boolean := False;
Column : Natural := 0;
C : Character;
Pos : Natural := Content'First;
begin
Column := 40;
Put (Into, """");
while Pos <= Content'Last loop
C := Content (Pos);
if Column > 80 then
if not Need_Sep then
Put (Into, """");
end if;
New_Line (Into);
Put (Into, " ");
Column := 6;
Need_Sep := True;
end if;
case C is
when ASCII.CR =>
if not Need_Sep then
Put (Into, """");
Need_Sep := True;
Column := Column + 1;
end if;
Put (Into, " & ASCII.CR");
Column := Column + 11;
when ASCII.LF =>
if not Need_Sep then
Put (Into, """");
Need_Sep := True;
Column := Column + 1;
end if;
Put (Into, " & ASCII.LF");
Column := Column + 11;
when ASCII.HT =>
if not Need_Sep then
Put (Into, """");
Need_Sep := True;
Column := Column + 1;
end if;
Put (Into, " & ASCII.HT");
Column := Column + 11;
when '"' =>
if Need_Sep then
Put (Into, " & """);
Need_Sep := False;
Column := Column + 3;
end if;
Put (Into, """""");
Column := Column + 1;
when ' ' | '!' | '#' .. '~' =>
if Need_Sep then
Put (Into, " & """);
Need_Sep := False;
Column := Column + 3;
end if;
Put (Into, C);
when Character'Val (192) .. Character'Val (255) =>
if Need_Sep then
Put (Into, " & """);
Need_Sep := False;
Column := Column + 3;
end if;
Put (Into, C);
while Pos + 1 <= Content'Last loop
C := Content (Pos + 1);
exit when Character'Pos (C) < 128;
exit when Character'Pos (C) >= 192;
Pos := Pos + 1;
Put (Into, C);
end loop;
when others =>
if not Need_Sep then
Put (Into, """");
Need_Sep := True;
Column := Column + 1;
end if;
Put (Into, " & Character'Val (");
Put (Into, Util.Strings.Image (Integer (Character'Pos (C))));
Put (Into, ")");
Column := Column + 22;
end case;
Column := Column + 1;
Pos := Pos + 1;
end loop;
if not Need_Sep then
Put (Into, """");
end if;
end Write_String;
procedure Write_String (Name : in String;
Content : in Are.File_Info) is
begin
Put (Into, " ");
Put (Into, Name);
Put (Into, " : aliased constant ");
Put (Into, Content_Type);
Put (Into, " := ");
if Content.Content /= null and then Content.Content'Length > 0 then
declare
First : constant Natural := Natural (Content.Content'First);
Last : constant Natural := Natural (Content.Content'Last);
File_Content : String (First .. Last);
for File_Content'Address use Content.Content.all'Address;
begin
Write_String (File_Content);
end;
end if;
Put_Line (Into, ";");
end Write_String;
-- Line index is global for the resource.
Line_Index : Natural := 0;
procedure Write_Lines (Name : in String;
Content : in Are.File_Info) is
Lines : Util.Strings.Vectors.Vector;
First : Natural := Line_Index;
begin
Are.Convert_To_Lines (Resource, Content, Lines);
for Line of Lines loop
Line_Index := Line_Index + 1;
Put (Into, " L_");
Put (Into, Util.Strings.Image (Line_Index));
Set_Col (Into, 10);
Put (Into, ": aliased constant String := ");
Write_String (Line);
Put_Line (Into, ";");
end loop;
Put (Into, " ");
Put (Into, Name);
Put (Into, " : aliased constant ");
Put (Into, Content_Type);
if Lines.Is_Empty then
Put_Line (Into, "(1 .. 0) := (others => <>);");
elsif Lines.Length = 1 then
Put (Into, " := (1 => L_");
Put (Into, Util.Strings.Image (First));
Put_Line (Into, "'Access);");
else
Put_Line (Into, " :=");
Put (Into, " (");
for I in 1 .. Lines.Length loop
if I > 1 then
Put_Line (Into, ",");
Set_Col (Into, 7);
end if;
First := First + 1;
Put (Into, "L_");
Put (Into, Util.Strings.Image (First));
Put (Into, "'Access");
end loop;
Put_Line (Into, ");");
end if;
end Write_Lines;
Index : Natural := 0;
function Get_Variable_Name (Key : in String) return String is
begin
if Declare_Var then
return To_Ada_Name (Var_Prefix, Key);
else
return "C_" & Util.Strings.Image (Index);
end if;
end Get_Variable_Name;
begin
for File in Resource.Files.Iterate loop
declare
Name : constant String := Get_Variable_Name (File_Maps.Key (File));
Content : constant Are.File_Info := File_Maps.Element (File);
begin
Index := Index + 1;
if Resource.Format = R_LINES then
Write_Lines (Name, Content);
elsif Resource.Format = R_STRING then
Write_String (Name, Content);
else
Write_Binary (Name, Content);
end if;
end;
New_Line (Into);
end loop;
end Generate_Resource_Contents;
-- ------------------------------
-- Generate the keyword table.
-- ------------------------------
procedure Generate_Keyword_Table (Generator : in out Generator_Type;
Into : in out Ada.Text_IO.File_Type) is
Index : Integer := 0;
procedure Print_Keyword (Pos : in Util.Strings.Vectors.Cursor);
procedure Print_Table (Pos : in Util.Strings.Vectors.Cursor);
-- ------------------------------
-- Print a keyword as an Ada constant string.
-- ------------------------------
procedure Print_Keyword (Pos : in Util.Strings.Vectors.Cursor) is
Name : constant String := Util.Strings.Vectors.Element (Pos);
begin
Put (Into, " K_");
Put (Into, Util.Strings.Image (Index));
Set_Col (Into, 20);
Put (Into, ": aliased constant String := """);
Put (Into, Name);
Put_Line (Into, """;");
Index := Index + 1;
end Print_Keyword;
-- ------------------------------
-- Build the keyword table.
-- ------------------------------
procedure Print_Table (Pos : in Util.Strings.Vectors.Cursor) is
pragma Unreferenced (Pos);
begin
if Index > 0 then
if Index mod 4 = 0 then
Put_Line (Into, ",");
Put (Into, " ");
else
Put (Into, ", ");
end if;
end if;
Put (Into, "K_");
Put (Into, Util.Strings.Image (Index));
Put (Into, "'Access");
Index := Index + 1;
end Print_Table;
begin
New_Line (Into);
Generator.Names.Iterate (Print_Keyword'Access);
New_Line (Into);
Index := 0;
Put_Line (Into, " Names : constant Name_Array := (");
Put (Into, " ");
if Generator.Names.Length = 1 then
Put (Into, "0 => ");
end if;
Generator.Names.Iterate (Print_Table'Access);
Put_Line (Into, ");");
end Generate_Keyword_Table;
-- ------------------------------
-- Generate the package specification.
-- ------------------------------
procedure Generate_Specs (Generator : in out Generator_Type;
Resource : in Are.Resource_Type;
Context : in out Are.Context_Type'Class) is
Name : constant String := To_String (Resource.Name);
Filename : constant String := To_File_Name (Name) & ".ads";
Path : constant String := Context.Get_Output_Path (Filename);
Def_Type : constant String := (if Generator.Content_Only then
"Content_Access" else "Content_Type");
Type_Name : constant String := Resource.Get_Type_Name (Context, Def_Type);
Content_Type : constant String := Get_Content_Type (Generator, Resource, Context);
File : Ada.Text_IO.File_Type;
Has_Private : Boolean := False;
begin
Log.Info ("Writing {0}", Path);
Ada.Text_IO.Create (File => File,
Mode => Ada.Text_IO.Out_File,
Name => Path);
Put (File, "-- ");
Put_Line (File, Get_Title);
if not Context.No_Type_Declaration then
if Resource.Format = R_BINARY then
declare
Pkg_Import : constant String := Get_Import_Type (Name, Content_Type);
begin
if Pkg_Import'Length > 0 then
Put (File, "with ");
Put (File, Pkg_Import);
Put_Line (File, ";");
end if;
end;
end if;
if not Generator.Content_Only then
Put_Line (File, "with Interfaces.C;");
end if;
end if;
Put (File, "package ");
Put (File, Name);
Put_Line (File, " is");
if Generator.Pragma_Preelaborate then
New_Line (File);
Put_Line (File, " pragma Preelaborate;");
end if;
New_Line (File);
if not Context.No_Type_Declaration then
if Resource.Format = R_BINARY then
Put (File, " type Content_Access is access constant ");
Put (File, Content_Type);
Put_Line (File, ";");
elsif Resource.Format = R_LINES then
Put_Line (File, " type Content_Array is array (Positive range <>)"
& " of access constant String;");
Put_Line (File, " type Content_Access is access constant Content_Array;");
elsif Resource.Format = R_STRING then
Put_Line (File, " type Content_Access is access constant String;");
end if;
New_Line (File);
if Context.List_Content or not Generator.Content_Only then
Put_Line (File, " type Name_Access is access constant String;");
New_Line (File);
end if;
if not Generator.Content_Only then
Put_Line (File, " type Format_Type is (FILE_RAW, FILE_GZIP);");
New_Line (File);
Put (File, " type ");
Put (File, Type_Name);
Put_Line (File, " is record");
Put_Line (File, " Name : Name_Access;");
Put_Line (File, " Content : Content_Access;");
Put_Line (File, " Modtime : Interfaces.C.long := 0;");
Put_Line (File, " Format : Format_Type := FILE_RAW;");
Put_Line (File, " end record;");
New_Line (File);
Put (File, " Null_Content : constant ");
Put (File, Type_Name);
Put_Line (File, ";");
New_Line (File);
end if;
end if;
if Context.Declare_Var then
Generate_Resource_Declarations (Resource, File, Content_Type, Context.Var_Prefix.all);
end if;
if Context.List_Content then
if not Context.No_Type_Declaration then
Put_Line (File, " type Name_Array is array (Natural range <>) of Name_Access;");
New_Line (File);
end if;
Put_Line (File, " Names : constant Name_Array;");
New_Line (File);
end if;
if Context.Name_Index then
Put_Line (File, " -- Returns the data stream with the given name or null.");
Put_Line (File, " function Get_Content (Name : String) return");
Put (File, " ");
Put (File, Type_Name);
Put_Line (File, ";");
New_Line (File);
end if;
if Context.Declare_Var then
Put_Line (File, "private");
New_Line (File);
Has_Private := True;
Generate_Resource_Contents (Resource, File, Context.Declare_Var,
Content_Type, Context.Var_Prefix.all);
end if;
if not Context.No_Type_Declaration and not Generator.Content_Only then
if not Has_Private then
Put_Line (File, "private");
New_Line (File);
Has_Private := True;
end if;
Put (File, " Null_Content : constant ");
Put (File, Type_Name);
Put_Line (File, " := (others => <>);");
New_Line (File);
end if;
if Context.List_Content then
if not Has_Private then
Put_Line (File, "private");
New_Line (File);
Has_Private := True;
end if;
Generate_Keyword_Table (Generator, File);
end if;
Put (File, "end ");
Put (File, Name);
Put (File, ";");
New_Line (File);
Close (File);
end Generate_Specs;
-- ------------------------------
-- Generate the package body.
-- ------------------------------
procedure Generate_Body (Generator : in out Generator_Type;
Resource : in Are.Resource_Type;
Context : in out Are.Context_Type'Class) is
procedure Read_Body (Line : in String);
procedure Generate_Contents_Array;
Name : constant String := To_String (Resource.Name);
Filename : constant String := To_File_Name (Name) & ".adb";
Path : constant String := Context.Get_Output_Path (Filename);
Def_Type : constant String := (if Generator.Content_Only then
"Content_Access" else "Content_Type");
Type_Name : constant String := Resource.Get_Type_Name (Context, Def_Type);
Content_Type : constant String := Get_Content_Type (Generator, Resource, Context);
Use_Hash : constant Boolean := Context.Name_Index and Generator.Names.Length > 1;
File : Ada.Text_IO.File_Type;
Count : Natural;
Lines : Util.Strings.Vectors.Vector;
-- ------------------------------
-- Read the generated body file.
-- ------------------------------
procedure Read_Body (Line : in String) is
begin
Lines.Append (Line);
end Read_Body;
procedure Generate_Contents_Array is
Need_Sep : Boolean := False;
Col : Natural := 0;
Index : Natural := 0;
begin
Put_Line (File, " Contents : constant Content_List_Array := (");
Put (File, " ");
if Resource.Files.Length = 1 then
Put (File, "0 => ");
end if;
for Content in Resource.Files.Iterate loop
if Need_Sep then
Put (File, ",");
end if;
if Col > 5 then
New_Line (File);
Put (File, " ");
Col := 0;
else
Put (File, " ");
end if;
if not Generator.Content_Only then
Put (File, "(K_");
Put (File, Util.Strings.Image (Index));
Put (File, "'Access, ");
end if;
if Context.Declare_Var then
Put (File, To_Ada_Name (Context.Var_Prefix.all, File_Maps.Key (Content)));
else
Put (File, "C_");
Put (File, Util.Strings.Image (Index));
end if;
Index := Index + 1;
Put (File, "'Access");
if not Generator.Content_Only then
declare
use Ada.Calendar.Conversions;
Data : constant File_Info := File_Maps.Element (Content);
begin
Put (File, ",");
Put (File, Interfaces.C.long'Image (To_Unix_Time (Data.Modtime)));
Put (File, ", FILE_RAW");
end;
Put (File, ")");
end if;
Col := Col + 1;
Need_Sep := True;
end loop;
Put_Line (File, ");");
end Generate_Contents_Array;
begin
if not Context.Name_Index or else Generator.Names.Is_Empty then
Log.Debug ("Skipping body generation for {0}", Filename);
return;
end if;
Log.Info ("Writing {0}", Path);
if Use_Hash then
Util.Files.Read_File (Path => Path, Process => Read_Body'Access);
end if;
Ada.Text_IO.Create (File => File,
Mode => Ada.Text_IO.Out_File,
Name => Path);
Put (File, "-- ");
Put_Line (File, Get_Title);
if Context.Ignore_Case then
Put_Line (File, "with Ada.Characters.Handling;");
end if;
if Use_Hash then
Count := Natural (Lines.Length);
for I in 1 .. Count - 1 loop
declare
L : constant String := Lines.Element (I);
begin
Put_Line (File, L);
if Util.Strings.Starts_With (L, "package ") then
Put_Line (File, " function Hash (S : String) return Natural;");
end if;
end;
end loop;
else
Put (File, "package body ");
Put (File, Name);
Put_Line (File, " is");
end if;
if not Context.Declare_Var then
Generate_Resource_Contents (Resource, File, Context.Declare_Var,
Content_Type, Context.Var_Prefix.all);
end if;
if Context.Name_Index and not Context.List_Content then
if Generator.Content_Only then
Put_Line (File, " type Name_Access is access constant String;");
end if;
Put_Line (File, " type Name_Array is array "
& "(Natural range <>) of Name_Access;");
New_Line (File);
Generate_Keyword_Table (Generator, File);
end if;
New_Line (File);
Put (File, " type Content_List_Array is array (Natural range <>) of ");
Put (File, Type_Name);
Put_Line (File, ";");
Generate_Contents_Array;
if Context.Name_Index then
New_Line (File);
Put (File, " function Get_Content (Name : String) return ");
Put (File, Type_Name);
Put_Line (File, " is");
if Use_Hash then
if Context.Ignore_Case then
Put_Line (File, " K : constant String := "
& "Ada.Characters.Handling.To_Upper (Name);");
Put_Line (File, " H : constant Natural := Hash (K);");
else
Put_Line (File, " H : constant Natural := Hash (Name);");
end if;
Put_Line (File, " begin");
if Context.Ignore_Case then
Put (File, " return (if Names (H).all = K then Contents (H) else ");
else
Put (File, " return (if Names (H).all = Name then Contents (H) else ");
end if;
if Generator.Content_Only then
Put_Line (File, "null);");
else
Put_Line (File, "Null_Content);");
end if;
else
if Context.Ignore_Case then
Put_Line (File, " K : constant String := "
& "Ada.Characters.Handling.To_Upper (Name);");
end if;
Put_Line (File, " begin");
if Context.Ignore_Case then
Put (File, " return (if Names (0).all = K then Contents (0) else ");
else
Put (File, " return (if Names (0).all = Name then Contents (0) else ");
end if;
if Generator.Content_Only then
Put_Line (File, "null);");
else
Put_Line (File, "Null_Content);");
end if;
end if;
Put_Line (File, " end Get_Content;");
New_Line (File);
end if;
Put (File, "end ");
Put (File, Name);
Put_Line (File, ";");
Close (File);
end Generate_Body;
end Are.Generator.Ada2012;
|
--------------------------------------------------------------------------------
-- Copyright (C) 2020 by Heisenbug Ltd. (gh+si_units@heisenbug.eu)
--
-- This work is free. You can redistribute it and/or modify it under the
-- terms of the Do What The Fuck You Want To Public License, Version 2,
-- as published by Sam Hocevar. See the LICENSE file for more details.
--------------------------------------------------------------------------------
pragma License (Unrestricted);
with Ada.Unchecked_Conversion;
with SI_Units.Float_IO;
package body SI_Units.Binary.Scaling is
function To_Exponent is new Ada.Unchecked_Conversion (Source => Prefixes,
Target => Integer);
use type Float_IO.General_Float;
function General_Scale
(Value : in Float_IO.General_Float;
From_Prefix : in Prefixes;
To_Prefix : in Prefixes) return Float_IO.General_Float
is
(Value * 2.0 ** (To_Exponent (From_Prefix) - To_Exponent (To_Prefix)));
function Mod_Scale (Value : in Item;
From_Prefix : in Prefixes;
To_Prefix : in Prefixes := None) return Item is
(Item (General_Scale (Value => Float_IO.General_Float (Value),
From_Prefix => From_Prefix,
To_Prefix => To_Prefix)));
end SI_Units.Binary.Scaling;
|
-- Shoot'n'loot
-- Copyright (c) 2020 Fabien Chouteau
with HAL; use HAL;
with PyGamer.Screen;
with PyGamer.Time;
with PyGamer.Controls;
use PyGamer;
with Sound;
package body Render is
Buffer_Size : constant Positive :=
PyGamer.Screen.Width * PyGamer.Screen.Height;
Render_Buffer : GESTE.Output_Buffer (1 .. Buffer_Size);
-----------------
-- Push_Pixels --
-----------------
procedure Push_Pixels (Buffer : GESTE.Output_Buffer) is
begin
PyGamer.Screen.Push_Pixels (Buffer'Address, Buffer'Length);
end Push_Pixels;
----------------------
-- Set_Drawing_Area --
----------------------
procedure Set_Drawing_Area (Area : GESTE.Pix_Rect) is
begin
PyGamer.Screen.End_Pixel_TX;
PyGamer.Screen.Set_Address (X_Start => HAL.UInt16 (Area.TL.X),
X_End => HAL.UInt16 (Area.BR.X),
Y_Start => HAL.UInt16 (Area.TL.Y),
Y_End => HAL.UInt16 (Area.BR.Y));
PyGamer.Screen.Start_Pixel_TX;
end Set_Drawing_Area;
----------------
-- Render_All --
----------------
procedure Render_All (Background : GESTE_Config.Output_Color) is
begin
GESTE.Render_All
(((0, 0), (Screen.Width - 1, Screen.Height - 1)),
Background,
Render_Buffer,
Push_Pixels'Access,
Set_Drawing_Area'Access);
PyGamer.Screen.End_Pixel_TX;
end Render_All;
------------------
-- Render_Dirty --
------------------
procedure Render_Dirty (Background : GESTE_Config.Output_Color) is
begin
GESTE.Render_Dirty
(((0, 0), (Screen.Width - 1, Screen.Height - 1)),
Background,
Render_Buffer,
Push_Pixels'Access,
Set_Drawing_Area'Access);
PyGamer.Screen.End_Pixel_TX;
end Render_Dirty;
----------------------
-- Scroll_New_Scene --
----------------------
procedure Scroll_New_Scene (Background : GESTE_Config.Output_Color)
is
Period : constant Time.Time_Ms := 1000 / 60;
Next_Release : Time.Time_Ms := Time.Clock + Period;
Scroll : UInt8 := PyGamer.Screen.Width;
Step : constant := 2;
X : Natural := 0;
begin
for Count in 1 .. PyGamer.Screen.Width / Step loop
Scroll := Scroll - Step;
Screen.Scroll (Scroll);
-- Render one column of pixel at Width - Scroll
GESTE.Render_All
(((X, 0),
(X + Step - 1, Screen.Height - 1)),
Background,
Render_Buffer,
Push_Pixels'Access,
Set_Drawing_Area'Access);
X := X + Step;
Screen.End_Pixel_TX;
Sound.Tick;
Controls.Scan;
Time.Delay_Until (Next_Release);
Next_Release := Next_Release + Period;
end loop;
end Scroll_New_Scene;
----------------------
-- Background_Color --
----------------------
function Background_Color return GESTE_Config.Output_Color
is (To_RGB565 (51, 153, 204));
---------------
-- To_RGB565 --
---------------
function To_RGB565 (R, G, B : Unsigned_8) return Unsigned_16 is
R16 : constant Unsigned_16 :=
Shift_Right (Unsigned_16 (R), 3) and 16#1F#;
G16 : constant Unsigned_16 :=
Shift_Right (Unsigned_16 (G), 2) and 16#3F#;
B16 : constant Unsigned_16 :=
Shift_Right (Unsigned_16 (B), 3) and 16#1F#;
RGB : constant Unsigned_16 :=
(Shift_Left (R16, 11) or Shift_Left (G16, 5) or B16);
begin
return Shift_Right (RGB and 16#FF00#, 8) or
(Shift_Left (RGB, 8) and 16#FF00#);
end To_RGB565;
end Render;
|
with Array23_Pkg2;
package Array23_Pkg1 is
C2 : Natural := Array23_Pkg2.C1;
subtype Index is Natural range 0 .. C2;
type Inner is array (Index) of Natural;
type Arr is array (Array23_Pkg2.Index) of Inner;
end Array23_Pkg1;
|
-----------------------------------------------------------------------
-- keystore-containers -- Container protected keystore
-- Copyright (C) 2019, 2020 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 Util.Streams;
with Ada.Streams;
with Keystore.IO.Refs;
with Keystore.Passwords.Keys;
with Keystore.Repository;
with Keystore.Keys;
private package Keystore.Containers is
type Wallet_Container;
-- The `Wallet_Container` protects concurrent accesses to the repository.
protected type Wallet_Container is
procedure Initialize;
procedure Open (Config : in Wallet_Config;
Ident : in Wallet_Identifier;
Block : in Keystore.IO.Storage_Block;
Wallet_Stream : in out Keystore.IO.Refs.Stream_Ref);
procedure Open (Name : in String;
Password : in out Keystore.Passwords.Provider'Class;
From_Repo : in out Keystore.Repository.Wallet_Repository;
From_Stream : in out IO.Refs.Stream_Ref);
procedure Create (Password : in out Keystore.Passwords.Provider'Class;
Config : in Wallet_Config;
Block : in IO.Storage_Block;
Ident : in Wallet_Identifier;
Wallet_Stream : in out IO.Refs.Stream_Ref);
procedure Set_Master_Key (Password : in out Keystore.Passwords.Keys.Key_Provider'Class);
function Get_State return State_Type;
procedure Set_Header_Data (Index : in Header_Slot_Index_Type;
Kind : in Header_Slot_Type;
Data : in Ada.Streams.Stream_Element_Array);
procedure Get_Header_Data (Index : in Header_Slot_Index_Type;
Kind : out Header_Slot_Type;
Data : out Ada.Streams.Stream_Element_Array;
Last : out Ada.Streams.Stream_Element_Offset);
procedure Unlock (Password : in out Keystore.Passwords.Provider'Class;
Slot : out Key_Slot);
procedure Set_Key (Password : in out Keystore.Passwords.Provider'Class;
New_Password : in out Keystore.Passwords.Provider'Class;
Config : in Wallet_Config;
Mode : in Mode_Type);
procedure Remove_Key (Password : in out Keystore.Passwords.Provider'Class;
Slot : in Key_Slot;
Force : in Boolean);
function Contains (Name : in String) return Boolean;
procedure Add (Name : in String;
Kind : in Entry_Type;
Content : in Ada.Streams.Stream_Element_Array);
procedure Add (Name : in String;
Kind : in Entry_Type;
Input : in out Util.Streams.Input_Stream'Class);
procedure Create (Name : in String;
Password : in out Keystore.Passwords.Provider'Class;
From_Repo : in out Keystore.Repository.Wallet_Repository;
From_Stream : in out IO.Refs.Stream_Ref);
procedure Set (Name : in String;
Kind : in Entry_Type;
Content : in Ada.Streams.Stream_Element_Array);
procedure Set (Name : in String;
Kind : in Entry_Type;
Input : in out Util.Streams.Input_Stream'Class);
procedure Update (Name : in String;
Kind : in Entry_Type;
Content : in Ada.Streams.Stream_Element_Array);
procedure Find (Name : in String;
Result : out Entry_Info);
procedure Get_Data (Name : in String;
Result : out Entry_Info;
Output : out Ada.Streams.Stream_Element_Array);
procedure Get_Data (Name : in String;
Output : in out Util.Streams.Output_Stream'Class);
procedure Read (Name : in String;
Offset : in Ada.Streams.Stream_Element_Offset;
Content : out Ada.Streams.Stream_Element_Array;
Last : out Ada.Streams.Stream_Element_Offset);
procedure Write (Name : in String;
Offset : in Ada.Streams.Stream_Element_Offset;
Content : in Ada.Streams.Stream_Element_Array);
procedure Delete (Name : in String);
procedure List (Filter : in Filter_Type;
Content : out Entry_Map);
procedure List (Pattern : in GNAT.Regpat.Pattern_Matcher;
Filter : in Filter_Type;
Content : out Entry_Map);
procedure Get_Stats (Stats : out Wallet_Stats);
procedure Close;
procedure Set_Work_Manager (Workers : in Keystore.Task_Manager_Access);
procedure Do_Repository (Process : not null access
procedure (Repo : in out Repository.Wallet_Repository;
Stream : in out IO.Refs.Stream_Ref));
private
Stream : Keystore.IO.Refs.Stream_Ref;
Master : Keystore.Keys.Key_Manager;
Repository : Keystore.Repository.Wallet_Repository;
State : State_Type := S_INVALID;
Master_Block : Keystore.IO.Storage_Block;
Master_Ident : Wallet_Identifier := Wallet_Identifier'First;
end Wallet_Container;
procedure Open_Wallet (Container : in out Wallet_Container;
Name : in String;
Password : in out Keystore.Passwords.Provider'Class;
Wallet : in out Wallet_Container);
procedure Add_Wallet (Container : in out Wallet_Container;
Name : in String;
Password : in out Keystore.Passwords.Provider'Class;
Wallet : in out Wallet_Container);
end Keystore.Containers;
|
-- SPDX-FileCopyrightText: 2021 Max Reznik <reznikmm@gmail.com>
--
-- SPDX-License-Identifier: MIT
-------------------------------------------------------------
with League.Strings;
package WebIDL.Definitions is
pragma Preelaborate;
type Definition is limited interface;
not overriding function Name (Self : Definition)
return League.Strings.Universal_String is abstract;
type Definition_Access is access all Definition'Class
with Storage_Size => 0;
end WebIDL.Definitions;
|
-- --
-- package Tables.Names Copyright (c) Dmitry A. Kazakov --
-- Implementation Luebeck --
-- Spring, 2003 --
-- --
-- Last revision : 13:11 14 Sep 2019 --
-- --
-- This library is free software; you can redistribute it and/or --
-- modify it under the terms of the GNU General Public License as --
-- published by the Free Software Foundation; either version 2 of --
-- the License, or (at your option) any later version. This library --
-- is distributed in the hope that it will be useful, but WITHOUT --
-- ANY WARRANTY; without even the implied warranty of --
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU --
-- General Public License for more details. You should have --
-- received a copy of the GNU General Public License along with --
-- this library; if not, write to the Free Software Foundation, --
-- Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. --
-- --
-- As a special exception, if other files instantiate generics from --
-- this unit, or you link this unit with other files to produce an --
-- executable, this unit does not by itself cause the resulting --
-- executable to be covered by the GNU General Public License. This --
-- exception does not however invalidate any other reasons why the --
-- executable file might be covered by the GNU Public License. --
--____________________________________________________________________--
with Ada.Characters.Handling; use Ada.Characters.Handling;
with Ada.IO_Exceptions; use Ada.IO_Exceptions;
with Ada.Strings.Maps; use Ada.Strings.Maps;
package body Tables.Names is
type Extended_Equality is (Less, Equal, Prefix, Greater);
--
-- Compare -- String with a pattern
--
-- Source - The string
-- Pointer - The position in it
-- Item - The pattern
--
-- Pointer is advanced if the outcome is Equal or Prefix
--
-- Returns :
--
-- Comparison result
--
function Compare
( Source : String;
Pointer : access Integer;
Item : String
) return Extended_Equality is
pragma Inline (Compare);
Index1 : Integer := Pointer.all;
Index2 : Integer := Item'First;
Symbol1 : Character;
Symbol2 : Character;
begin
loop
if Index2 > Item'Last then
if Index1 > Source'Last then
Pointer.all := Index1;
return Equal;
else
Pointer.all := Index1;
return Prefix;
end if;
else
if Index1 > Source'Last then
return Less;
end if;
end if;
Symbol1 := Source (Index1);
Symbol2 := Item (Index2);
if Is_In (Symbol1, Blanks) then
if Is_In (Symbol2, Blanks) then
Index1 := Index1 + 1;
Index2 := Index2 + 1;
while Index1 <= Source'Last loop
exit when not Is_In (Source (Index1), Blanks);
Index1 := Index1 + 1;
end loop;
while Index2 <= Item'Last loop
exit when not Is_In (Item (Index2), Blanks);
Index2 := Index2 + 1;
end loop;
else
return Less;
end if;
else
if Is_In (Symbol2, Blanks) then
return Greater;
else
Symbol1 := To_Lower (Symbol1);
Symbol2 := To_Lower (Symbol2);
if Symbol1 = Symbol2 then
Index1 := Index1 + 1;
Index2 := Index2 + 1;
else
if Symbol1 > Symbol2 then
return Greater;
else
return Less;
end if;
end if;
end if;
end if;
end loop;
end Compare;
function Search
( Folder : Dictionary;
Name : String
) return Integer is
Low : Integer := 0;
High : Integer := Folder.Size + 1;
This : Integer;
Index : aliased Integer;
begin
if High = 1 then
return -1;
end if;
loop
This := (Low + High) / 2;
Index := Name'First;
case Compare (Name, Index'Access, Folder.List (This).Name) is
when Less =>
High := This;
if High - Low = 1 then
return -This;
end if;
when Equal =>
return This;
when Prefix | Greater =>
Low := This;
if High - Low = 1 then
return -(This + 1);
end if;
end case;
end loop;
end Search;
procedure Add
( Folder : in out Dictionary;
Name : String;
Data : Tag
) is
begin
Check_Spelling (Name);
declare
Index : constant Integer := Search (Folder, Name);
begin
if Index > 0 then
raise Name_Error;
else
Insert (Folder, -Index, Name, Data);
end if;
end;
end Add;
procedure Add
( Folder : in out Dictionary;
Name : String;
Data : Tag;
Offset : out Positive
) is
begin
Check_Spelling (Name);
declare
Index : Integer := Search (Folder, Name);
begin
if Index > 0 then
raise Name_Error;
else
Index := -Index;
Insert (Folder, Index, Name, Data);
Offset := Index;
end if;
end;
end Add;
procedure Delete (Folder : in out Dictionary; Name : String) is
Index : constant Integer := Search (Folder, Name);
begin
if Index > 0 then
Delete (Folder, Index);
end if;
end Delete;
function Find (Folder : Dictionary; Name : String) return Tag is
Index : constant Integer := Search (Folder, Name);
begin
if Index > 0 then
return Folder.List (Index).Data;
else
raise End_Error;
end if;
end Find;
function IsIn (Folder : Dictionary; Name : String) return Boolean is
begin
return Search (Folder, Name) > 0;
end IsIn;
procedure Get
( Source : String;
Pointer : in out Integer;
Folder : Dictionary;
Data : out Tag
) is
Index : Natural;
begin
Locate (Source, Pointer, Folder, Index);
if Index = 0 then
raise End_Error;
else
Data := Folder.List (Index).Data;
end if;
end Get;
procedure Get
( Source : String;
Pointer : in out Integer;
Folder : Dictionary;
Data : out Tag;
Got_It : out Boolean
) is
Index : Natural;
begin
Locate (Source, Pointer, Folder, Index);
if Index = 0 then
Got_It := False;
else
Got_It := True;
Data := Folder.List (Index).Data;
end if;
end Get;
function Locate (Folder : Dictionary; Name : String)
return Natural is
Index : constant Integer := Search (Folder, Name);
begin
if Index > 0 then
return Index;
else
return 0;
end if;
end Locate;
procedure Locate
( Source : String;
Pointer : in out Integer;
Folder : Dictionary;
Offset : out Natural
) is
Found : Integer := 0;
Low : Integer := 0;
High : Integer := Folder.Size + 1;
This : Integer;
Next : Integer;
Index : aliased Integer;
begin
if ( Pointer < Source'First
or else
( Pointer > Source'Last
and then
Pointer - 1 > Source'Last
) )
then
raise Layout_Error;
end if;
while High - Low /= 1 loop
This := (Low + High) / 2;
Index := Pointer;
case Compare (Source, Index'Access, Folder.List (This).Name) is
when Less =>
High := This;
when Equal | Prefix =>
Found := This;
Next := Index;
Low := This;
when Greater =>
for Lower in reverse Low + 1 .. This - 1 loop
exit when
( Found /= 0
and then
( Folder.List (Found).Name'Length
> Folder.List (Lower).Name'Length
) );
Index := Pointer;
case Compare
( Source,
Index'Access,
Folder.List (Lower).Name
) is
when Less => -- Rest items could be only
exit; -- lesser than this, exit
when Equal | Prefix =>
Found := Lower; -- Here we are. Ignore the rest
Next := Index; -- lesser, i.e. shorter, items
exit;
when Greater =>
null; -- Undecided, continue
end case;
end loop;
Low := This;
end case;
end loop;
if ( Found = 0
or else
( Next <= Source'Last
and then
not Check_Matched (Source, Next)
) )
then
Offset := 0;
else
Offset := Found;
Pointer := Next;
end if;
end Locate;
procedure Replace
( Folder : in out Dictionary;
Name : String;
Data : Tag
) is
begin
Check_Spelling (Name);
declare
Index : constant Integer := Search (Folder, Name);
begin
if Index > 0 then
Folder.List (Index).Data := Data;
else
Insert (Folder, -Index, Name, Data);
end if;
end;
end Replace;
procedure Replace
( Folder : in out Dictionary;
Name : String;
Data : Tag;
Offset : out Positive
) is
begin
Check_Spelling (Name);
declare
Index : Integer := Search (Folder, Name);
begin
if Index > 0 then
Folder.List (Index).Data := Data;
else
Index := -Index;
Insert (Folder, Index, Name, Data);
Offset := Index;
end if;
end;
end Replace;
end Tables.Names;
|
-- part of OpenGLAda, (c) 2017 Felix Krause
-- released under the terms of the MIT license, see the file "COPYING"
with GL.API;
with GL.Load_Function_Pointers;
package body GL is
procedure Init renames GL.Load_Function_Pointers;
procedure Flush is
begin
API.Flush;
end Flush;
procedure Finish is
begin
API.Finish;
end Finish;
-- implementation depends on whether Auto_Exceptions has been enabled.
procedure Raise_Exception_On_OpenGL_Error is separate;
end GL;
|
--
-- Raytracer implementation in Ada
-- by John Perry (github: johnperry-math)
-- 2021
--
-- specification for Cameras, that view the scene
--
-- local packages
with Vectors; use Vectors;
-- @summary Cameras that view the scene
package Cameras is
type Camera_Type is record
Forward, Right, Up, Position: Vector;
end record;
function Create_Camera(Position, Target: Vector) return Camera_Type;
-- creates a camera at Position that is looking at Target
end Cameras;
|
with Ada.Text_IO;
with Ada.Long_Float_Text_IO;
-- No need to put pragma Elaborate_All on standard library packages.
with File_IO;
pragma Elaborate_All (File_IO);
-- Imagine some developer in the future introduces a dependency
-- upon the code in this file in the File_IO package or any of the code
-- that it depends upon by writing "with Gc;". Putting a pragma Elaborate_All
-- on the package enables the compiler to detect such circular dependencies.
-- This application can be compiled with two compilers:
-- 1. The GNAT CE (Community Edition) 2020 compiler (gcc)
-- 2. The GNAT LLVM compiler
-- All proofs can be recreated using the SPARK tools part of GNAT CE 2020.
-- In GNAT Studio select SPARK -> Prove All Sources, proof level 2.
--
-- To compile the code using GNAT CE 2020:
--
-- gprbuild -P default.gpr
--
-- To compile using the GNAT-LLVM compiler:
--
-- llvm-gnatmake -P default.gpr
--
procedure Gc with SPARK_Mode is
-- The code in this file is SPARK code and can successfully be formally
-- verified by the SPARK tools which means it is safe to suppress
-- the following run-time checks the compiler otherwise would genereate
-- unless it can itself prove a check is unnecessary.
pragma Suppress (Discriminant_Check);
pragma Suppress (Division_Check);
pragma Suppress (Index_Check);
pragma Suppress (Length_Check);
pragma Suppress (Range_Check);
pragma Suppress (Tag_Check);
pragma Suppress (Overflow_Check);
-- Note that overflow checks are expensive performance-wise.
-- These checks can here be safely turned off since it can be
-- mathematically proven that it cannot happen with any of the variables
-- used in this application.
use all type File_IO.Read_Result;
use all type File_IO.EOF_Result;
-- use all type enables use of enumeration values without need
-- for prefixing them with the package name.
subtype Nucleotide_Count is Long_Integer range 0 .. Long_Integer'Last / 4;
-- The restriction on the maximum allowed value can be relaxed
-- but will make the contracts more cumbersome to write.
A : Nucleotide_Count := 0;
T : Nucleotide_Count := 0;
G : Nucleotide_Count := 0;
C : Nucleotide_Count := 0;
procedure Handle_Read_Line (Line : File_IO.Read_Result;
Shall_Continue : in out Boolean) with
Global => (In_Out => (A, T, G, C, Ada.Text_IO.File_System)),
Pre => A + T + G + C <= Nucleotide_Count'Last - 120,
Post => A + T + G + C <= A'Old + T'Old + G'Old + C'Old + 120;
procedure Handle_Read_Line (Line : File_IO.Read_Result;
Shall_Continue : in out Boolean)
is
Initial_Value : constant Long_Integer := A + T + G + C with Ghost;
-- Ghost variables are only used in proofs, not application code.
begin
for I in Line.Text'Range loop
case Line.Text (I) is
when 'A' => A := A + 1;
when 'C' => C := C + 1;
when 'G' => G := G + 1;
when 'T' => T := T + 1;
when 'N' => null; -- Ingore undecisive
when others =>
Ada.Text_IO.Put_Line ("Forbidden character detected.");
Shall_Continue := False;
return;
end case;
pragma Loop_Invariant (A + T + G + C <= Initial_Value + Long_Integer (I));
end loop;
end Handle_Read_Line;
type Counter_Type is range 1 .. Nucleotide_Count'Last / 128;
Ghost_Sum : Long_Integer := 0 with Ghost;
-- Ghost variables are only used in proofs, not application code.
File : File_IO.File_Type;
Is_Success : Boolean;
Is_File_Too_Large : Boolean := True;
Shall_Continue : Boolean := True;
File_Name : constant String := "chry_multiplied.fa";
begin
File_IO.Open_Input_File (File_Name, File, Is_Success);
if Is_Success then
for Counter in Counter_Type'Range loop
pragma Loop_Invariant (Ghost_Sum <= 120 * (Long_Integer (Counter) - 1));
pragma Loop_Invariant (A + T + G + C <= Ghost_Sum);
case End_Of_File (File) is
when End_Reached =>
Is_File_Too_Large := False;
exit;
when More_Data_Exists =>
declare
Line : File_IO.Read_Result := Read_Line (File);
begin
if Line.Is_Success then
if Line.Text'Length > 0 then
if Line.Text (1) = '>' then
null; -- Ignore comments in input file
else
Handle_Read_Line (Line, Shall_Continue);
if not Shall_Continue then
return; -- error was detected
end if;
Ghost_Sum := Ghost_Sum + 120;
end if;
else
null; -- Ignore empty lines in input file
end if;
else
Ada.Text_IO.Put_Line ("Error reading file. Hardware issue?");
return;
end if;
end;
when EOF_Error =>
Ada.Text_IO.Put_Line ("Error checking for end of file. Hardware issue?");
return;
end case;
end loop;
if Is_File_Too_Large then
Ada.Text_IO.Put_Line ("Too many rows of data.");
Ada.Text_IO.Put_Line ("Variables not large enough to store result.");
else
declare
Gc_Count : constant Long_Float := Long_Float (G + C);
Total_Count : constant Long_Float := Long_Float (A + T + G + C);
begin
if Total_Count > 0.0 then
Ada.Long_Float_Text_IO.Put (Item => 100.0 * (Gc_Count / Total_Count),
Exp => 0);
Ada.Text_IO.New_Line;
else
Ada.Text_IO.Put_Line ("No nucleotide A, T, G nor C found in input file.");
end if;
end;
end if;
else
Ada.Text_IO.Put_Line ("Can't open file " & File_Name);
end if;
end Gc;
|
------------------------------------------------------------------------------
-- --
-- GNAT LIBRARY COMPONENTS --
-- --
-- ADA.CONTAINERS.RED_BLACK_TREES.GENERIC_OPERATIONS --
-- --
-- S p e c --
-- --
-- Copyright (C) 2004-2009, 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/>. --
-- --
-- This unit was originally developed by Matthew J Heaney. --
------------------------------------------------------------------------------
-- Tree_Type is used to implement the ordered containers. This package
-- declares the tree operations that do not depend on keys.
with Ada.Streams; use Ada.Streams;
generic
with package Tree_Types is new Generic_Tree_Types (<>);
use Tree_Types;
with function Parent (Node : Node_Access) return Node_Access is <>;
with procedure Set_Parent (Node : Node_Access; Parent : Node_Access) is <>;
with function Left (Node : Node_Access) return Node_Access is <>;
with procedure Set_Left (Node : Node_Access; Left : Node_Access) is <>;
with function Right (Node : Node_Access) return Node_Access is <>;
with procedure Set_Right (Node : Node_Access; Right : Node_Access) is <>;
with function Color (Node : Node_Access) return Color_Type is <>;
with procedure Set_Color (Node : Node_Access; Color : Color_Type) is <>;
package Ada.Containers.Red_Black_Trees.Generic_Operations is
pragma Pure;
function Min (Node : Node_Access) return Node_Access;
-- Returns the smallest-valued node of the subtree rooted at Node
function Max (Node : Node_Access) return Node_Access;
-- Returns the largest-valued node of the subtree rooted at Node
-- NOTE: The Check_Invariant operation was used during early
-- development of the red-black tree. Now that the tree type
-- implementation has matured, we don't really need Check_Invariant
-- anymore.
-- procedure Check_Invariant (Tree : Tree_Type);
function Vet (Tree : Tree_Type; Node : Node_Access) return Boolean;
-- Inspects Node to determine (to the extent possible) whether
-- the node is valid; used to detect if the node is dangling.
function Next (Node : Node_Access) return Node_Access;
-- Returns the smallest node greater than Node
function Previous (Node : Node_Access) return Node_Access;
-- Returns the largest node less than Node
generic
with function Is_Equal (L, R : Node_Access) return Boolean;
function Generic_Equal (Left, Right : Tree_Type) return Boolean;
-- Uses Is_Equal to perform a node-by-node comparison of the
-- Left and Right trees; processing stops as soon as the first
-- non-equal node is found.
procedure Delete_Node_Sans_Free
(Tree : in out Tree_Type;
Node : Node_Access);
-- Removes Node from Tree without deallocating the node. If Tree
-- is busy then Program_Error is raised.
generic
with procedure Free (X : in out Node_Access);
procedure Generic_Delete_Tree (X : in out Node_Access);
-- Deallocates the tree rooted at X, calling Free on each node
generic
with function Copy_Node (Source : Node_Access) return Node_Access;
with procedure Delete_Tree (X : in out Node_Access);
function Generic_Copy_Tree (Source_Root : Node_Access) return Node_Access;
-- Copies the tree rooted at Source_Root, using Copy_Node to copy each
-- node of the source tree. If Copy_Node propagates an exception
-- (e.g. Storage_Error), then Delete_Tree is first used to deallocate
-- the target tree, and then the exception is propagated.
generic
with function Copy_Tree (Root : Node_Access) return Node_Access;
procedure Generic_Adjust (Tree : in out Tree_Type);
-- Used to implement controlled Adjust. On input to Generic_Adjust, Tree
-- holds a bitwise (shallow) copy of the source tree (as would be the case
-- when controlled Adjust is called). On output, Tree holds its own (deep)
-- copy of the source tree, which is constructed by calling Copy_Tree.
generic
with procedure Delete_Tree (X : in out Node_Access);
procedure Generic_Clear (Tree : in out Tree_Type);
-- Clears Tree by deallocating all of its nodes. If Tree is busy then
-- Program_Error is raised.
generic
with procedure Clear (Tree : in out Tree_Type);
procedure Generic_Move (Target, Source : in out Tree_Type);
-- Moves the tree belonging to Source onto Target. If Source is busy then
-- Program_Error is raised. Otherwise Target is first cleared (by calling
-- Clear, to deallocate its existing tree), then given the Source tree, and
-- then finally Source is cleared (by setting its pointers to null).
generic
with procedure Process (Node : Node_Access) is <>;
procedure Generic_Iteration (Tree : Tree_Type);
-- Calls Process for each node in Tree, in order from smallest-valued
-- node to largest-valued node.
generic
with procedure Process (Node : Node_Access) is <>;
procedure Generic_Reverse_Iteration (Tree : Tree_Type);
-- Calls Process for each node in Tree, in order from largest-valued
-- node to smallest-valued node.
generic
with procedure Write_Node
(Stream : not null access Root_Stream_Type'Class;
Node : Node_Access);
procedure Generic_Write
(Stream : not null access Root_Stream_Type'Class;
Tree : Tree_Type);
-- Used to implement stream attribute T'Write. Generic_Write
-- first writes the number of nodes into Stream, then calls
-- Write_Node for each node in Tree.
generic
with procedure Clear (Tree : in out Tree_Type);
with function Read_Node
(Stream : not null access Root_Stream_Type'Class) return Node_Access;
procedure Generic_Read
(Stream : not null access Root_Stream_Type'Class;
Tree : in out Tree_Type);
-- Used to implement stream attribute T'Read. Generic_Read
-- first clears Tree. It then reads the number of nodes out of
-- Stream, and calls Read_Node for each node in Stream.
procedure Rebalance_For_Insert
(Tree : in out Tree_Type;
Node : Node_Access);
-- This rebalances Tree to complete the insertion of Node (which
-- must already be linked in at its proper insertion position).
end Ada.Containers.Red_Black_Trees.Generic_Operations;
|
------------------------------------------------------------------------------
-- --
-- GNAT COMPILER COMPONENTS --
-- --
-- A D A . E X C E P T I O N S --
-- --
-- B o d y --
-- --
-- $Revision$
-- --
-- Copyright (C) 1992-2001 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 2, or (at your option) any later ver- --
-- sion. GNAT is distributed in the hope that it will be useful, but WITH- --
-- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY --
-- or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License --
-- for more details. You should have received a copy of the GNU General --
-- Public License distributed with GNAT; see file COPYING. If not, write --
-- to the Free Software Foundation, 59 Temple Place - Suite 330, Boston, --
-- MA 02111-1307, USA. --
-- --
-- As a special exception, if other files instantiate generics from this --
-- unit, or you link this unit with other files to produce an executable, --
-- this unit does not by itself cause the resulting executable to be --
-- covered by the GNU General Public License. This exception does not --
-- however invalidate any other reasons why the executable file might be --
-- covered by the GNU Public License. --
-- --
-- GNAT was originally developed by the GNAT team at New York University. --
-- Extensive contributions were provided by Ada Core Technologies Inc. --
-- --
------------------------------------------------------------------------------
pragma Polling (Off);
-- We must turn polling off for this unit, because otherwise we get
-- elaboration circularities with System.Exception_Tables.
with Ada.Unchecked_Deallocation;
with GNAT.Heap_Sort_A; use GNAT.Heap_Sort_A;
with System; use System;
with System.Exception_Table; use System.Exception_Table;
with System.Exceptions; use System.Exceptions;
with System.Standard_Library; use System.Standard_Library;
with System.Storage_Elements; use System.Storage_Elements;
with System.Soft_Links; use System.Soft_Links;
with System.Machine_State_Operations; use System.Machine_State_Operations;
with System.Traceback;
with Unchecked_Conversion;
package body Ada.Exceptions is
procedure builtin_longjmp (buffer : Address; Flag : Integer);
pragma No_Return (builtin_longjmp);
pragma Import (C, builtin_longjmp, "_gnat_builtin_longjmp");
pragma Suppress (All_Checks);
-- We definitely do not want exceptions occurring within this unit, or
-- we are in big trouble. If an exceptional situation does occur, better
-- that it not be raised, since raising it can cause confusing chaos.
type Subprogram_Descriptor_List_Ptr is
access all Subprogram_Descriptor_List;
Subprogram_Descriptors : Subprogram_Descriptor_List_Ptr;
-- This location is initialized by Register_Exceptions to point to a
-- list of pointers to procedure descriptors, sorted into ascending
-- order of PC addresses.
--
-- Note that SDP_Table_Build is called *before* this unit (or any
-- other unit) is elaborated. That's important, because exceptions can
-- and do occur during elaboration of units, and must be handled during
-- elaboration. This means that we are counting on the fact that the
-- initialization of Subprogram_Descriptors to null is done by the
-- load process and NOT by an explicit assignment during elaboration.
Num_Subprogram_Descriptors : Natural;
-- Number of subprogram descriptors, the useful descriptors are stored
-- in Subprogram_Descriptors (1 .. Num_Subprogram_Descriptors). There
-- can be unused entries at the end of the array due to elimination of
-- duplicated entries (which can arise from use of pragma Import).
Exception_Tracebacks : Integer;
pragma Import (C, Exception_Tracebacks, "__gl_exception_tracebacks");
-- Boolean indicating whether tracebacks should be stored in exception
-- occurrences.
Nline : constant String := String' (1 => ASCII.LF);
-- Convenient shortcut
-----------------------
-- Local Subprograms --
-----------------------
-- Note: the exported subprograms in this package body are called directly
-- from C clients using the given external name, even though they are not
-- technically visible in the Ada sense.
procedure AAA;
-- Mark start of procedures in this unit
procedure ZZZ;
-- Mark end of procedures in this package
Address_Image_Length : constant :=
13 + 10 * Boolean'Pos (Standard'Address_Size > 32);
-- Length of string returned by Address_Image function
function Address_Image (A : System.Address) return String;
-- Returns at string of the form 0xhhhhhhhhh for 32-bit addresses
-- or 0xhhhhhhhhhhhhhhhh for 64-bit addresses. Hex characters are
-- in lower case.
procedure Free
is new Ada.Unchecked_Deallocation
(Subprogram_Descriptor_List, Subprogram_Descriptor_List_Ptr);
procedure Raise_Current_Excep (E : Exception_Id);
pragma No_Return (Raise_Current_Excep);
pragma Export (C, Raise_Current_Excep, "__gnat_raise_nodefer_with_msg");
-- This is the lowest level raise routine. It raises the exception
-- referenced by Current_Excep.all in the TSD, without deferring
-- abort (the caller must ensure that abort is deferred on entry).
-- The parameter E is ignored.
--
-- This external name for Raise_Current_Excep is historical, and probably
-- should be changed but for now we keep it, because gdb knows about it.
-- The parameter is also present for historical compatibility. ???
procedure Raise_Exception_No_Defer
(E : Exception_Id; Message : String := "");
pragma Export (Ada, Raise_Exception_No_Defer,
"ada__exceptions__raise_exception_no_defer");
pragma No_Return (Raise_Exception_No_Defer);
-- Similar to Raise_Exception, but with no abort deferral
procedure Raise_With_Msg (E : Exception_Id);
pragma No_Return (Raise_With_Msg);
pragma Export (C, Raise_With_Msg, "__gnat_raise_with_msg");
-- Raises an exception with given exception id value. A message
-- is associated with the raise, and has already been stored in the
-- exception occurrence referenced by the Current_Excep in the TSD.
-- Abort is deferred before the raise call.
procedure Raise_With_Location
(E : Exception_Id;
F : SSL.Big_String_Ptr;
L : Integer);
pragma No_Return (Raise_With_Location);
-- Raise an exception with given exception id value. A filename and line
-- number is associated with the raise and is stored in the exception
-- occurrence.
procedure Raise_Constraint_Error
(File : SSL.Big_String_Ptr; Line : Integer);
pragma No_Return (Raise_Constraint_Error);
pragma Export (C, Raise_Constraint_Error, "__gnat_raise_constraint_error");
-- Raise constraint error with file:line information
procedure Raise_Program_Error
(File : SSL.Big_String_Ptr; Line : Integer);
pragma No_Return (Raise_Program_Error);
pragma Export (C, Raise_Program_Error, "__gnat_raise_program_error");
-- Raise program error with file:line information
procedure Raise_Storage_Error
(File : SSL.Big_String_Ptr; Line : Integer);
pragma No_Return (Raise_Storage_Error);
pragma Export (C, Raise_Storage_Error, "__gnat_raise_storage_error");
-- Raise storage error with file:line information
-- The exception raising process and the automatic tracing mechanism rely
-- on some careful use of flags attached to the exception occurrence. The
-- graph below illustrates the relations between the Raise_ subprograms
-- and identifies the points where basic flags such as Exception_Raised
-- are initialized.
--
-- (i) signs indicate the flags initialization points. R stands for Raise,
-- W for With, and E for Exception.
--
-- R_No_Msg R_E R_Pe R_Ce R_Se
-- | | | | |
-- +--+ +--+ +---+ | +---+
-- | | | | |
-- R_E_No_Defer(i) R_W_Msg(i) R_W_Loc R_W_C_Msg
-- | | | | | |
-- +------------+ | +-----------+ +--+ +--+ |
-- | | | | | |
-- | | | Set_E_C_Msg(i) |
-- | | | |
-- | | | +--------------------------+
-- | | | |
-- Raise_Current_Excep
procedure Reraise;
pragma No_Return (Reraise);
pragma Export (C, Reraise, "__gnat_reraise");
-- Reraises the exception referenced by the Current_Excep field of
-- the TSD (all fields of this exception occurrence are set). Abort
-- is deferred before the reraise operation.
function SDP_Table_Sort_Lt (Op1, Op2 : Natural) return Boolean;
-- Used in call to sort SDP table (SDP_Table_Build), compares two elements
procedure SDP_Table_Sort_Move (From : Natural; To : Natural);
-- Used in call to sort SDP table (SDP_Table_Build), moves one element
procedure Set_Exception_C_Msg
(Id : Exception_Id;
Msg : SSL.Big_String_Ptr;
Line : Integer := 0);
-- This routine is called to setup the exception referenced by the
-- Current_Excep field in the TSD to contain the indicated Id value
-- and message. Msg is a null terminated string. when Line > 0,
-- Msg is the filename and line the line number of the exception location.
procedure To_Stderr (S : String);
pragma Export (Ada, To_Stderr, "__gnat_to_stderr");
-- Little routine to output string to stderr that is also used
-- in the tasking run time.
procedure Unhandled_Exception_Terminate;
pragma No_Return (Unhandled_Exception_Terminate);
-- This procedure is called to terminate execution following an unhandled
-- exception. The exception information, including traceback if available
-- is output, and execution is then terminated. Note that at the point
-- where this routine is called, the stack has typically been destroyed
---------------------------------
-- Debugger Interface Routines --
---------------------------------
-- The routines here are null routines that normally have no effect.
-- they are provided for the debugger to place breakpoints on their
-- entry points to get control on an exception.
procedure Notify_Exception
(Id : Exception_Id;
Handler : Code_Loc;
Is_Others : Boolean);
pragma Export (C, Notify_Exception, "__gnat_notify_exception");
-- This routine is called whenever an exception is signalled. The Id
-- parameter is the Exception_Id of the exception being raised. The
-- second parameter Handler is Null_Loc if the exception is unhandled,
-- and is otherwise the entry point of the handler that will handle
-- the exception. Is_Others is True if the handler is an others handler
-- and False otherwise. In the unhandled exception case, if possible
-- (and certainly if zero cost exception handling is active), the
-- stack is still intact when this procedure is called. Note that this
-- routine is entered before any finalization handlers are entered if
-- the exception is unhandled by a "real" exception handler.
procedure Unhandled_Exception;
pragma Export (C, Unhandled_Exception, "__gnat_unhandled_exception");
-- This routine is called in addition to Notify_Exception in the
-- unhandled exception case. The fact that there are two routines
-- which are somewhat redundant is historical. Notify_Exception
-- certainly is complete enough, but GDB still uses this routine.
---------------------------------------
-- Exception backtracing subprograms --
---------------------------------------
-- What is automatically output when exception tracing is on basically
-- corresponds to the usual exception information, but with the call
-- chain backtrace possibly tailored by a backtrace decorator. Modifying
-- Exception_Information itself is not a good idea because the decorated
-- output is completely out of control and would break all our code
-- related to the streaming of exceptions.
--
-- We then provide an alternative function to Exception_Information to
-- compute the possibly tailored output, which is equivalent if no
-- decorator is currently set :
function Tailored_Exception_Information
(X : Exception_Occurrence)
return String;
-- Exception information to be output in the case of automatic tracing
-- requested through GNAT.Exception_Traces.
--
-- This is the same as Exception_Information if no backtrace decorator
-- is currently in place. Otherwise, this is Exception_Information with
-- the call chain raw addresses replaced by the result of a call to the
-- current decorator provided with the call chain addresses.
pragma Export
(Ada, Tailored_Exception_Information,
"__gnat_tailored_exception_information");
-- This function is used within this package but also from within
-- System.Tasking.Stages.
--
-- The output of Exception_Information and Tailored_Exception_Information
-- share a common part which was formerly built using local procedures
-- within Exception_Information. These procedures have been extracted from
-- their original place to be available to Tailored_Exception_Information
-- also.
--
-- Each of these procedures appends some input to an information string
-- currently being built. The Ptr argument represents the last position
-- in this string at which a character has been written.
procedure Append_Info_Nat
(N : Natural;
Info : in out String;
Ptr : in out Natural);
-- Append the image of N at the end of the provided information string.
procedure Append_Info_NL
(Info : in out String;
Ptr : in out Natural);
-- Append a CR/LF couple at the end of the provided information string.
procedure Append_Info_String
(S : String;
Info : in out String;
Ptr : in out Natural);
-- Append a string at the end of the provided information string.
-- To build Exception_Information and Tailored_Exception_Information,
-- we then use three intermediate functions :
function Basic_Exception_Information
(X : Exception_Occurrence)
return String;
-- Returns the basic exception information string associated with a
-- given exception occurrence. This is the common part shared by both
-- Exception_Information and Tailored_Exception_Infomation.
function Basic_Exception_Traceback
(X : Exception_Occurrence)
return String;
-- Returns an image of the complete call chain associated with an
-- exception occurrence in its most basic form, that is as a raw sequence
-- of hexadecimal binary addresses.
function Tailored_Exception_Traceback
(X : Exception_Occurrence)
return String;
-- Returns an image of the complete call chain associated with an
-- exception occurrence, either in its basic form if no decorator is
-- in place, or as formatted by the decorator otherwise.
-- The overall organization of the exception information related code
-- is summarized below :
--
-- Exception_Information
-- |
-- +-------+--------+
-- | |
-- Basic_Exc_Info & Basic_Exc_Tback
--
--
-- Tailored_Exception_Information
-- |
-- +----------+----------+
-- | |
-- Basic_Exc_Info & Tailored_Exc_Tback
-- |
-- +-----------+------------+
-- | |
-- Basic_Exc_Tback Or Tback_Decorator
-- if no decorator set otherwise
----------------------------------------------
-- Run-Time Exception Notification Routines --
----------------------------------------------
-- The notification routines described above are low level "handles" for
-- the debugger but what needs to be done at the notification points
-- always involves more than just calling one of these routines. The
-- routines below provide a common run-time interface for this purpose,
-- with variations depending on the handled/not handled status of the
-- occurrence. They are exported to be usable by the Ada exception
-- handling personality routine when the GCC 3 mechanism is used.
procedure Notify_Handled_Exception
(Handler : Code_Loc;
Is_Others : Boolean;
Low_Notify : Boolean);
pragma Export (C, Notify_Handled_Exception,
"__gnat_notify_handled_exception");
-- Routine to call when a handled occurrence is about to be propagated.
-- Low_Notify might be set to false to skip the low level debugger
-- notification, which is useful when the information it requires is
-- not available, like in the SJLJ case.
procedure Notify_Unhandled_Exception (Id : Exception_Id);
pragma Export (C, Notify_Unhandled_Exception,
"__gnat_notify_unhandled_exception");
-- Routine to call when an unhandled occurrence is about to be propagated.
--------------------------------
-- Import Run-Time C Routines --
--------------------------------
-- The purpose of the following pragma Imports is to ensure that we
-- generate appropriate subprogram descriptors for all C routines in
-- the standard GNAT library that can raise exceptions. This ensures
-- that the exception propagation can properly find these routines
pragma Warnings (Off); -- so old compiler does not complain
pragma Propagate_Exceptions;
procedure Unhandled_Terminate;
pragma Import (C, Unhandled_Terminate, "__gnat_unhandled_terminate");
procedure Propagate_Exception (Mstate : Machine_State);
pragma No_Return (Propagate_Exception);
-- This procedure propagates the exception represented by the occurrence
-- referenced by Current_Excep in the TSD for the current task. M is
-- the initial machine state, representing the site of the exception
-- raise operation. Propagate_Exception searches the exception tables
-- for an applicable handler, calling Pop_Frame as needed. If and when
-- it locates an applicable handler Propagate_Exception makes a call
-- to Enter_Handler to actually enter the handler. If the search is
-- unable to locate an applicable handler, execution is terminated by
-- calling Unhandled_Exception_Terminate.
procedure Call_Chain (Excep : EOA);
-- Store up to Max_Tracebacks in Excep, corresponding to the current
-- call chain.
-----------------------
-- Polling Interface --
-----------------------
type Unsigned is mod 2 ** 32;
Counter : Unsigned := 0;
-- This counter is provided for convenience. It can be used in Poll to
-- perform periodic but not systematic operations.
procedure Poll is separate;
-- The actual polling routine is separate, so that it can easily
-- be replaced with a target dependent version.
---------
-- AAA --
---------
-- This dummy procedure gives us the start of the PC range for addresses
-- within the exception unit itself. We hope that gigi/gcc keep all the
-- procedures in their original order!
procedure AAA is
begin
null;
end AAA;
-------------------
-- Address_Image --
-------------------
function Address_Image (A : Address) return String is
S : String (1 .. 18);
P : Natural;
N : Integer_Address;
H : constant array (Integer range 0 .. 15) of Character :=
"0123456789abcdef";
begin
P := S'Last;
N := To_Integer (A);
while N /= 0 loop
S (P) := H (Integer (N mod 16));
P := P - 1;
N := N / 16;
end loop;
S (P - 1) := '0';
S (P) := 'x';
return S (P - 1 .. S'Last);
end Address_Image;
---------------------
-- Append_Info_Nat --
---------------------
procedure Append_Info_Nat
(N : Natural;
Info : in out String;
Ptr : in out Natural)
is
begin
if N > 9 then
Append_Info_Nat (N / 10, Info, Ptr);
end if;
Ptr := Ptr + 1;
Info (Ptr) := Character'Val (Character'Pos ('0') + N mod 10);
end Append_Info_Nat;
--------------------
-- Append_Info_NL --
--------------------
procedure Append_Info_NL
(Info : in out String;
Ptr : in out Natural)
is
begin
Ptr := Ptr + 1;
Info (Ptr) := ASCII.CR;
Ptr := Ptr + 1;
Info (Ptr) := ASCII.LF;
end Append_Info_NL;
------------------------
-- Append_Info_String --
------------------------
procedure Append_Info_String
(S : String;
Info : in out String;
Ptr : in out Natural)
is
begin
Info (Ptr + 1 .. Ptr + S'Length) := S;
Ptr := Ptr + S'Length;
end Append_Info_String;
---------------------------------
-- Basic_Exception_Information --
---------------------------------
function Basic_Exception_Information
(X : Exception_Occurrence)
return String
is
Name : constant String := Exception_Name (X);
Msg : constant String := Exception_Message (X);
-- Exception name and message that are going to be included in the
-- information to return, if not empty.
Name_Len : constant Natural := Name'Length;
Msg_Len : constant Natural := Msg'Length;
-- Length of these strings, useful to compute the size of the string
-- we have to allocate for the complete result as well as in the body
-- of this procedure.
Info_Maxlen : constant Natural := 50 + Name_Len + Msg_Len;
-- Maximum length of the information string we will build, with :
--
-- 50 = 16 + 2 for the text associated with the name
-- + 9 + 2 for the text associated with the message
-- + 5 + 2 for the text associated with the pid
-- + 14 for the text image of the pid itself and a margin.
--
-- This is indeed a maximum since some data may not appear at all if
-- not relevant. For example, nothing related to the exception message
-- will be there if this message is empty.
--
-- WARNING : Do not forget to update these numbers if anything
-- involved in the computation changes.
Info : String (1 .. Info_Maxlen);
-- Information string we are going to build, containing the common
-- part shared by Exc_Info and Tailored_Exc_Info.
Ptr : Natural := 0;
begin
-- Output exception name and message except for _ABORT_SIGNAL, where
-- these two lines are omitted (see discussion above).
if Name (1) /= '_' then
Append_Info_String ("Exception name: ", Info, Ptr);
Append_Info_String (Name, Info, Ptr);
Append_Info_NL (Info, Ptr);
if Msg_Len /= 0 then
Append_Info_String ("Message: ", Info, Ptr);
Append_Info_String (Msg, Info, Ptr);
Append_Info_NL (Info, Ptr);
end if;
end if;
-- Output PID line if non-zero
if X.Pid /= 0 then
Append_Info_String ("PID: ", Info, Ptr);
Append_Info_Nat (X.Pid, Info, Ptr);
Append_Info_NL (Info, Ptr);
end if;
return Info (1 .. Ptr);
end Basic_Exception_Information;
-------------------------------
-- Basic_Exception_Traceback --
-------------------------------
function Basic_Exception_Traceback
(X : Exception_Occurrence)
return String
is
Info_Maxlen : constant Natural := 35 + X.Num_Tracebacks * 19;
-- Maximum length of the information string we are building, with :
-- 33 = 31 + 4 for the text before and after the traceback, and
-- 19 = 2 + 16 + 1 for each address ("0x" + HHHH + " ")
--
-- WARNING : Do not forget to update these numbers if anything
-- involved in the computation changes.
Info : String (1 .. Info_Maxlen);
-- Information string we are going to build, containing an image
-- of the call chain associated with the exception occurrence in its
-- most basic form, that is as a sequence of binary addresses.
Ptr : Natural := 0;
begin
if X.Num_Tracebacks > 0 then
Append_Info_String ("Call stack traceback locations:", Info, Ptr);
Append_Info_NL (Info, Ptr);
for J in 1 .. X.Num_Tracebacks loop
Append_Info_String (Address_Image (X.Tracebacks (J)), Info, Ptr);
exit when J = X.Num_Tracebacks;
Append_Info_String (" ", Info, Ptr);
end loop;
Append_Info_NL (Info, Ptr);
end if;
return Info (1 .. Ptr);
end Basic_Exception_Traceback;
-----------------
-- Break_Start --
-----------------
procedure Break_Start is
begin
null;
end Break_Start;
----------------
-- Call_Chain --
----------------
procedure Call_Chain (Excep : EOA) is
begin
if Excep.Num_Tracebacks /= 0 then
-- This is a reraise, no need to store a new (wrong) chain.
return;
end if;
System.Traceback.Call_Chain
(Excep.Tracebacks'Address,
Max_Tracebacks,
Excep.Num_Tracebacks,
AAA'Address,
ZZZ'Address);
end Call_Chain;
------------------------------
-- Current_Target_Exception --
------------------------------
function Current_Target_Exception return Exception_Occurrence is
begin
return Null_Occurrence;
end Current_Target_Exception;
-------------------
-- EId_To_String --
-------------------
function EId_To_String (X : Exception_Id) return String is
begin
if X = Null_Id then
return "";
else
return Exception_Name (X);
end if;
end EId_To_String;
------------------
-- EO_To_String --
------------------
-- We use the null string to represent the null occurrence, otherwise
-- we output the Exception_Information string for the occurrence.
function EO_To_String (X : Exception_Occurrence) return String is
begin
if X.Id = Null_Id then
return "";
else
return Exception_Information (X);
end if;
end EO_To_String;
------------------------
-- Exception_Identity --
------------------------
function Exception_Identity
(X : Exception_Occurrence)
return Exception_Id
is
begin
if X.Id = Null_Id then
raise Constraint_Error;
else
return X.Id;
end if;
end Exception_Identity;
---------------------------
-- Exception_Information --
---------------------------
-- The format of the string is:
-- Exception_Name: nnnnn
-- Message: mmmmm
-- PID: ppp
-- Call stack traceback locations:
-- 0xhhhh 0xhhhh 0xhhhh ... 0xhhh
-- where
-- nnnn is the fully qualified name of the exception in all upper
-- case letters. This line is always present.
-- mmmm is the message (this line present only if message is non-null)
-- ppp is the Process Id value as a decimal integer (this line is
-- present only if the Process Id is non-zero). Currently we are
-- not making use of this field.
-- The Call stack traceback locations line and the following values
-- are present only if at least one traceback location was recorded.
-- the values are given in C style format, with lower case letters
-- for a-f, and only as many digits present as are necessary.
-- The line terminator sequence at the end of each line, including the
-- last line is a CR-LF sequence (16#0D# followed by 16#0A#).
-- The Exception_Name and Message lines are omitted in the abort
-- signal case, since this is not really an exception, and the only
-- use of this routine is internal for printing termination output.
-- WARNING: if the format of the generated string is changed, please note
-- that an equivalent modification to the routine String_To_EO must be
-- made to preserve proper functioning of the stream attributes.
function Exception_Information (X : Exception_Occurrence) return String is
-- This information is now built using the circuitry introduced in
-- association with the support of traceback decorators, as the
-- catenation of the exception basic information and the call chain
-- backtrace in its basic form.
Basic_Info : constant String := Basic_Exception_Information (X);
Tback_Info : constant String := Basic_Exception_Traceback (X);
Basic_Len : constant Natural := Basic_Info'Length;
Tback_Len : constant Natural := Tback_Info'Length;
Info : String (1 .. Basic_Len + Tback_Len);
Ptr : Natural := 0;
begin
Append_Info_String (Basic_Info, Info, Ptr);
Append_Info_String (Tback_Info, Info, Ptr);
return Info;
end Exception_Information;
-----------------------
-- Exception_Message --
-----------------------
function Exception_Message (X : Exception_Occurrence) return String is
begin
if X.Id = Null_Id then
raise Constraint_Error;
end if;
return X.Msg (1 .. X.Msg_Length);
end Exception_Message;
--------------------
-- Exception_Name --
--------------------
function Exception_Name (Id : Exception_Id) return String is
begin
if Id = null then
raise Constraint_Error;
end if;
return Id.Full_Name.all (1 .. Id.Name_Length - 1);
end Exception_Name;
function Exception_Name (X : Exception_Occurrence) return String is
begin
return Exception_Name (X.Id);
end Exception_Name;
---------------------------
-- Exception_Name_Simple --
---------------------------
function Exception_Name_Simple (X : Exception_Occurrence) return String is
Name : constant String := Exception_Name (X);
P : Natural;
begin
P := Name'Length;
while P > 1 loop
exit when Name (P - 1) = '.';
P := P - 1;
end loop;
return Name (P .. Name'Length);
end Exception_Name_Simple;
-------------------------
-- Propagate_Exception --
-------------------------
procedure Propagate_Exception (Mstate : Machine_State) is
Excep : constant EOA := Get_Current_Excep.all;
Loc : Code_Loc;
Lo, Hi : Natural;
Pdesc : Natural;
Hrec : Handler_Record_Ptr;
Info : Subprogram_Info_Type;
type Machine_State_Record is
new Storage_Array (1 .. Machine_State_Length);
for Machine_State_Record'Alignment use Standard'Maximum_Alignment;
procedure Duplicate_Machine_State (Dest, Src : Machine_State);
-- Copy Src into Dest, assuming that a Machine_State is pointing to
-- an area of Machine_State_Length bytes.
procedure Duplicate_Machine_State (Dest, Src : Machine_State) is
type Machine_State_Record_Access is access Machine_State_Record;
function To_MSR is new Unchecked_Conversion
(Machine_State, Machine_State_Record_Access);
begin
To_MSR (Dest).all := To_MSR (Src).all;
end Duplicate_Machine_State;
-- Data for handling the finalization handler case. A simple approach
-- in this routine would simply to unwind stack frames till we find a
-- handler and then enter it. But this is undesirable in the case where
-- we have only finalization handlers, and no "real" handler, i.e. a
-- case where we have an unhandled exception.
-- In this case we prefer to signal unhandled exception with the stack
-- intact, and entering finalization handlers would destroy the stack
-- state. To deal with this, as we unwind the stack, we note the first
-- finalization handler, and remember it in the following variables.
-- We then continue to unwind. If and when we find a "real", i.e. non-
-- finalization handler, then we use these variables to pass control to
-- the finalization handler.
FH_Found : Boolean := False;
-- Set when a finalization handler is found
FH_Mstate : aliased Machine_State_Record;
-- Records the machine state for the finalization handler
FH_Handler : Code_Loc;
-- Record handler address for finalization handler
FH_Num_Trb : Natural;
-- Save number of tracebacks for finalization handler
begin
-- Loop through stack frames as exception propagates
Main_Loop : loop
Loc := Get_Code_Loc (Mstate);
exit Main_Loop when Loc = Null_Loc;
-- Record location unless it is inside this unit. Note: this
-- test should really say Code_Address, but Address is the same
-- as Code_Address for unnested subprograms, and Code_Address
-- would cause a bootstrap problem
if Loc < AAA'Address or else Loc > ZZZ'Address then
-- Record location unless we already recorded max tracebacks
if Excep.Num_Tracebacks /= Max_Tracebacks then
-- Do not record location if it is the return point from
-- a reraise call from within a cleanup handler
if not Excep.Cleanup_Flag then
Excep.Num_Tracebacks := Excep.Num_Tracebacks + 1;
Excep.Tracebacks (Excep.Num_Tracebacks) := Loc;
-- For reraise call from cleanup handler, skip entry and
-- clear the flag so that we will start to record again
else
Excep.Cleanup_Flag := False;
end if;
end if;
end if;
-- Do binary search on procedure table
Lo := 1;
Hi := Num_Subprogram_Descriptors;
-- Binary search loop
loop
Pdesc := (Lo + Hi) / 2;
-- Note that Loc is expected to be the procedure's call point
-- and not the return point.
if Loc < Subprogram_Descriptors (Pdesc).Code then
Hi := Pdesc - 1;
elsif Pdesc < Num_Subprogram_Descriptors
and then Loc > Subprogram_Descriptors (Pdesc + 1).Code
then
Lo := Pdesc + 1;
else
exit;
end if;
-- This happens when the current Loc is completely outside of
-- the range of the program, which usually means that we reached
-- the top level frame (e.g __start). In this case we have an
-- unhandled exception.
exit Main_Loop when Hi < Lo;
end loop;
-- Come here with Subprogram_Descriptors (Pdesc) referencing the
-- procedure descriptor that applies to this PC value. Now do a
-- serial search to see if any handler is applicable to this PC
-- value, and to the exception that we are propagating
for J in 1 .. Subprogram_Descriptors (Pdesc).Num_Handlers loop
Hrec := Subprogram_Descriptors (Pdesc).Handler_Records (J);
if Loc >= Hrec.Lo and then Loc < Hrec.Hi then
-- PC range is applicable, see if handler is for this exception
-- First test for case of "all others" (finalization) handler.
-- We do not enter such a handler until we are sure there is
-- a real handler further up the stack.
if Hrec.Id = All_Others_Id then
-- If this is the first finalization handler, then
-- save the machine state so we can enter it later
-- without having to repeat the search.
if not FH_Found then
FH_Found := True;
Duplicate_Machine_State
(Machine_State (FH_Mstate'Address), Mstate);
FH_Handler := Hrec.Handler;
FH_Num_Trb := Excep.Num_Tracebacks;
end if;
-- Normal (non-finalization exception with matching Id)
elsif Excep.Id = Hrec.Id
or else (Hrec.Id = Others_Id
and not Excep.Id.Not_Handled_By_Others)
then
-- Perform the necessary notification tasks.
Notify_Handled_Exception
(Hrec.Handler, Hrec.Id = Others_Id, True);
-- If we already encountered a finalization handler, then
-- reset the context to that handler, and enter it.
if FH_Found then
Excep.Num_Tracebacks := FH_Num_Trb;
Excep.Cleanup_Flag := True;
Enter_Handler
(Machine_State (FH_Mstate'Address), FH_Handler);
-- If we have not encountered a finalization handler,
-- then enter the current handler.
else
Enter_Handler (Mstate, Hrec.Handler);
end if;
end if;
end if;
end loop;
Info := Subprogram_Descriptors (Pdesc).Subprogram_Info;
exit Main_Loop when Info = No_Info;
Pop_Frame (Mstate, Info);
end loop Main_Loop;
-- Fall through if no "real" exception handler found. First thing is to
-- perform the necessary notification tasks with the stack intact.
Notify_Unhandled_Exception (Excep.Id);
-- If there were finalization handlers, then enter the top one.
-- Just because there is no handler does not mean we don't have
-- to still execute all finalizations and cleanups before
-- terminating. Note that the process of calling cleanups
-- does not disturb the back trace stack, since he same
-- exception occurrence gets reraised, and new traceback
-- entries added as we go along.
if FH_Found then
Excep.Num_Tracebacks := FH_Num_Trb;
Excep.Cleanup_Flag := True;
Enter_Handler (Machine_State (FH_Mstate'Address), FH_Handler);
end if;
-- If no cleanups, then this is the real unhandled termination
Unhandled_Exception_Terminate;
end Propagate_Exception;
-------------------------
-- Raise_Current_Excep --
-------------------------
procedure Raise_Current_Excep (E : Exception_Id) is
pragma Inspection_Point (E);
-- This is so the debugger can reliably inspect the parameter
Jumpbuf_Ptr : constant Address := Get_Jmpbuf_Address.all;
Mstate_Ptr : constant Machine_State :=
Machine_State (Get_Machine_State_Addr.all);
Excep : EOA;
begin
-- WARNING : There should be no exception handler for this body
-- because this would cause gigi to prepend a setup for a new
-- jmpbuf to the sequence of statements. We would then always get
-- this new buf in Jumpbuf_Ptr instead of the one for the exception
-- we are handling, which would completely break the whole design
-- of this procedure.
-- If the jump buffer pointer is non-null, it means that a jump
-- buffer was allocated (obviously that happens only in the case
-- of zero cost exceptions not implemented, or if a jump buffer
-- was manually set up by C code).
if Jumpbuf_Ptr /= Null_Address then
Excep := Get_Current_Excep.all;
if Exception_Tracebacks /= 0 then
Call_Chain (Excep);
end if;
-- Perform the necessary notification tasks if this is not a
-- reraise. Actually ask to skip the low level debugger notification
-- call since we do not have the necessary information to "feed"
-- it properly.
if not Excep.Exception_Raised then
Excep.Exception_Raised := True;
Notify_Handled_Exception (Null_Loc, False, False);
end if;
builtin_longjmp (Jumpbuf_Ptr, 1);
-- If we have no jump buffer, then either zero cost exception
-- handling is in place, or we have no handlers anyway. In
-- either case we have an unhandled exception. If zero cost
-- exception handling is in place, propagate the exception
elsif Subprogram_Descriptors /= null then
Set_Machine_State (Mstate_Ptr);
Propagate_Exception (Mstate_Ptr);
-- Otherwise, we know the exception is unhandled by the absence
-- of an allocated jump buffer. Note that this means that we also
-- have no finalizations to do other than at the outer level.
else
if Exception_Tracebacks /= 0 then
Call_Chain (Get_Current_Excep.all);
end if;
Notify_Unhandled_Exception (E);
Unhandled_Exception_Terminate;
end if;
end Raise_Current_Excep;
---------------------
-- Raise_Exception --
---------------------
procedure Raise_Exception
(E : Exception_Id;
Message : String := "")
is
Len : constant Natural :=
Natural'Min (Message'Length, Exception_Msg_Max_Length);
Excep : constant EOA := Get_Current_Excep.all;
begin
if E /= null then
Excep.Msg_Length := Len;
Excep.Msg (1 .. Len) := Message (1 .. Len);
Raise_With_Msg (E);
end if;
end Raise_Exception;
----------------------------
-- Raise_Exception_Always --
----------------------------
procedure Raise_Exception_Always
(E : Exception_Id;
Message : String := "")
is
Len : constant Natural :=
Natural'Min (Message'Length, Exception_Msg_Max_Length);
Excep : constant EOA := Get_Current_Excep.all;
begin
Excep.Msg_Length := Len;
Excep.Msg (1 .. Len) := Message (1 .. Len);
Raise_With_Msg (E);
end Raise_Exception_Always;
-------------------------------
-- Raise_From_Signal_Handler --
-------------------------------
procedure Raise_From_Signal_Handler
(E : Exception_Id;
M : SSL.Big_String_Ptr)
is
Jumpbuf_Ptr : constant Address := Get_Jmpbuf_Address.all;
Mstate_Ptr : constant Machine_State :=
Machine_State (Get_Machine_State_Addr.all);
begin
Set_Exception_C_Msg (E, M);
Abort_Defer.all;
-- Now we raise the exception. The following code is essentially
-- identical to the Raise_Current_Excep routine, except that in the
-- zero cost exception case, we do not call Set_Machine_State, since
-- the signal handler that passed control here has already set the
-- machine state directly.
--
-- We also do not compute the backtrace for the occurrence since going
-- through the signal handler is far from trivial and it is not a
-- problem to fail providing a backtrace in the "raised from signal
-- handler" case.
-- If the jump buffer pointer is non-null, it means that a jump
-- buffer was allocated (obviously that happens only in the case
-- of zero cost exceptions not implemented, or if a jump buffer
-- was manually set up by C code).
if Jumpbuf_Ptr /= Null_Address then
builtin_longjmp (Jumpbuf_Ptr, 1);
-- If we have no jump buffer, then either zero cost exception
-- handling is in place, or we have no handlers anyway. In
-- either case we have an unhandled exception. If zero cost
-- exception handling is in place, propagate the exception
elsif Subprogram_Descriptors /= null then
Propagate_Exception (Mstate_Ptr);
-- Otherwise, we know the exception is unhandled by the absence
-- of an allocated jump buffer. Note that this means that we also
-- have no finalizations to do other than at the outer level.
else
Notify_Unhandled_Exception (E);
Unhandled_Exception_Terminate;
end if;
end Raise_From_Signal_Handler;
------------------
-- Raise_No_Msg --
------------------
procedure Raise_No_Msg (E : Exception_Id) is
Excep : constant EOA := Get_Current_Excep.all;
begin
Excep.Msg_Length := 0;
Raise_With_Msg (E);
end Raise_No_Msg;
-------------------------
-- Raise_With_Location --
-------------------------
procedure Raise_With_Location
(E : Exception_Id;
F : SSL.Big_String_Ptr;
L : Integer) is
begin
Set_Exception_C_Msg (E, F, L);
Abort_Defer.all;
Raise_Current_Excep (E);
end Raise_With_Location;
----------------------------
-- Raise_Constraint_Error --
----------------------------
procedure Raise_Constraint_Error
(File : SSL.Big_String_Ptr; Line : Integer) is
begin
Raise_With_Location (Constraint_Error_Def'Access, File, Line);
end Raise_Constraint_Error;
-------------------------
-- Raise_Program_Error --
-------------------------
procedure Raise_Program_Error
(File : SSL.Big_String_Ptr; Line : Integer) is
begin
Raise_With_Location (Program_Error_Def'Access, File, Line);
end Raise_Program_Error;
-------------------------
-- Raise_Storage_Error --
-------------------------
procedure Raise_Storage_Error
(File : SSL.Big_String_Ptr; Line : Integer) is
begin
Raise_With_Location (Storage_Error_Def'Access, File, Line);
end Raise_Storage_Error;
----------------------
-- Raise_With_C_Msg --
----------------------
procedure Raise_With_C_Msg
(E : Exception_Id;
M : SSL.Big_String_Ptr) is
begin
Set_Exception_C_Msg (E, M);
Abort_Defer.all;
Raise_Current_Excep (E);
end Raise_With_C_Msg;
--------------------
-- Raise_With_Msg --
--------------------
procedure Raise_With_Msg (E : Exception_Id) is
Excep : constant EOA := Get_Current_Excep.all;
begin
Excep.Exception_Raised := False;
Excep.Id := E;
Excep.Num_Tracebacks := 0;
Excep.Cleanup_Flag := False;
Excep.Pid := Local_Partition_ID;
Abort_Defer.all;
Raise_Current_Excep (E);
end Raise_With_Msg;
-------------
-- Reraise --
-------------
procedure Reraise is
Excep : constant EOA := Get_Current_Excep.all;
begin
Abort_Defer.all;
Raise_Current_Excep (Excep.Id);
end Reraise;
------------------------
-- Reraise_Occurrence --
------------------------
procedure Reraise_Occurrence (X : Exception_Occurrence) is
begin
if X.Id /= null then
Abort_Defer.all;
Save_Occurrence (Get_Current_Excep.all.all, X);
Raise_Current_Excep (X.Id);
end if;
end Reraise_Occurrence;
-------------------------------
-- Reraise_Occurrence_Always --
-------------------------------
procedure Reraise_Occurrence_Always (X : Exception_Occurrence) is
begin
Abort_Defer.all;
Save_Occurrence (Get_Current_Excep.all.all, X);
Raise_Current_Excep (X.Id);
end Reraise_Occurrence_Always;
---------------------------------
-- Reraise_Occurrence_No_Defer --
---------------------------------
procedure Reraise_Occurrence_No_Defer (X : Exception_Occurrence) is
begin
Save_Occurrence (Get_Current_Excep.all.all, X);
Raise_Current_Excep (X.Id);
end Reraise_Occurrence_No_Defer;
---------------------
-- Save_Occurrence --
---------------------
procedure Save_Occurrence
(Target : out Exception_Occurrence;
Source : Exception_Occurrence)
is
begin
Target.Id := Source.Id;
Target.Msg_Length := Source.Msg_Length;
Target.Num_Tracebacks := Source.Num_Tracebacks;
Target.Pid := Source.Pid;
Target.Cleanup_Flag := Source.Cleanup_Flag;
Target.Msg (1 .. Target.Msg_Length) :=
Source.Msg (1 .. Target.Msg_Length);
Target.Tracebacks (1 .. Target.Num_Tracebacks) :=
Source.Tracebacks (1 .. Target.Num_Tracebacks);
end Save_Occurrence;
function Save_Occurrence
(Source : Exception_Occurrence)
return EOA
is
Target : EOA := new Exception_Occurrence;
begin
Save_Occurrence (Target.all, Source);
return Target;
end Save_Occurrence;
---------------------
-- SDP_Table_Build --
---------------------
procedure SDP_Table_Build
(SDP_Addresses : System.Address;
SDP_Count : Natural;
Elab_Addresses : System.Address;
Elab_Addr_Count : Natural)
is
type SDLP_Array is array (1 .. SDP_Count) of Subprogram_Descriptors_Ptr;
type SDLP_Array_Ptr is access all SDLP_Array;
function To_SDLP_Array_Ptr is new Unchecked_Conversion
(System.Address, SDLP_Array_Ptr);
T : constant SDLP_Array_Ptr := To_SDLP_Array_Ptr (SDP_Addresses);
type Elab_Array is array (1 .. Elab_Addr_Count) of Code_Loc;
type Elab_Array_Ptr is access all Elab_Array;
function To_Elab_Array_Ptr is new Unchecked_Conversion
(System.Address, Elab_Array_Ptr);
EA : constant Elab_Array_Ptr := To_Elab_Array_Ptr (Elab_Addresses);
Ndes : Natural;
Previous_Subprogram_Descriptors : Subprogram_Descriptor_List_Ptr;
begin
-- If first call, then initialize count of subprogram descriptors
if Subprogram_Descriptors = null then
Num_Subprogram_Descriptors := 0;
end if;
-- First count number of subprogram descriptors. This count includes
-- entries with duplicated code addresses (resulting from Import).
Ndes := Num_Subprogram_Descriptors + Elab_Addr_Count;
for J in T'Range loop
Ndes := Ndes + T (J).Count;
end loop;
-- Now, allocate the new table (extra zero'th element is for sort call)
-- after having saved the previous one
Previous_Subprogram_Descriptors := Subprogram_Descriptors;
Subprogram_Descriptors := new Subprogram_Descriptor_List (0 .. Ndes);
-- If there was a previous Subprogram_Descriptors table, copy it back
-- into the new one being built. Then free the memory used for the
-- previous table.
for J in 1 .. Num_Subprogram_Descriptors loop
Subprogram_Descriptors (J) := Previous_Subprogram_Descriptors (J);
end loop;
Free (Previous_Subprogram_Descriptors);
-- Next, append the elaboration routine addresses, building dummy
-- SDP's for them as we go through the list.
Ndes := Num_Subprogram_Descriptors;
for J in EA'Range loop
Ndes := Ndes + 1;
Subprogram_Descriptors (Ndes) := new Subprogram_Descriptor_0;
Subprogram_Descriptors (Ndes).all :=
Subprogram_Descriptor'
(Num_Handlers => 0,
Code => Fetch_Code (EA (J)),
Subprogram_Info => EA (J),
Handler_Records => (1 .. 0 => null));
end loop;
-- Now copy in pointers to SDP addresses of application subprograms
for J in T'Range loop
for K in 1 .. T (J).Count loop
Ndes := Ndes + 1;
Subprogram_Descriptors (Ndes) := T (J).SDesc (K);
Subprogram_Descriptors (Ndes).Code :=
Fetch_Code (T (J).SDesc (K).Code);
end loop;
end loop;
-- Now we need to sort the table into ascending PC order
Sort (Ndes, SDP_Table_Sort_Move'Access, SDP_Table_Sort_Lt'Access);
-- Now eliminate duplicate entries. Note that in the case where
-- entries have duplicate code addresses, the code for the Lt
-- routine ensures that the interesting one (i.e. the one with
-- handler entries if there are any) comes first.
Num_Subprogram_Descriptors := 1;
for J in 2 .. Ndes loop
if Subprogram_Descriptors (J).Code /=
Subprogram_Descriptors (Num_Subprogram_Descriptors).Code
then
Num_Subprogram_Descriptors := Num_Subprogram_Descriptors + 1;
Subprogram_Descriptors (Num_Subprogram_Descriptors) :=
Subprogram_Descriptors (J);
end if;
end loop;
end SDP_Table_Build;
-----------------------
-- SDP_Table_Sort_Lt --
-----------------------
function SDP_Table_Sort_Lt (Op1, Op2 : Natural) return Boolean is
SDC1 : constant Code_Loc := Subprogram_Descriptors (Op1).Code;
SDC2 : constant Code_Loc := Subprogram_Descriptors (Op2).Code;
begin
if SDC1 < SDC2 then
return True;
elsif SDC1 > SDC2 then
return False;
-- For two descriptors for the same procedure, we want the more
-- interesting one first. A descriptor with an exception handler
-- is more interesting than one without. This happens if the less
-- interesting one came from a pragma Import.
else
return Subprogram_Descriptors (Op1).Num_Handlers /= 0
and then Subprogram_Descriptors (Op2).Num_Handlers = 0;
end if;
end SDP_Table_Sort_Lt;
--------------------------
-- SDP_Table_Sort_Move --
--------------------------
procedure SDP_Table_Sort_Move (From : Natural; To : Natural) is
begin
Subprogram_Descriptors (To) := Subprogram_Descriptors (From);
end SDP_Table_Sort_Move;
-------------------------
-- Set_Exception_C_Msg --
-------------------------
procedure Set_Exception_C_Msg
(Id : Exception_Id;
Msg : Big_String_Ptr;
Line : Integer := 0)
is
Excep : constant EOA := Get_Current_Excep.all;
Val : Integer := Line;
Remind : Integer;
Size : Integer := 1;
begin
Excep.Exception_Raised := False;
Excep.Id := Id;
Excep.Num_Tracebacks := 0;
Excep.Pid := Local_Partition_ID;
Excep.Msg_Length := 0;
Excep.Cleanup_Flag := False;
while Msg (Excep.Msg_Length + 1) /= ASCII.NUL
and then Excep.Msg_Length < Exception_Msg_Max_Length
loop
Excep.Msg_Length := Excep.Msg_Length + 1;
Excep.Msg (Excep.Msg_Length) := Msg (Excep.Msg_Length);
end loop;
if Line > 0 then
-- Compute the number of needed characters
while Val > 0 loop
Val := Val / 10;
Size := Size + 1;
end loop;
-- If enough characters are available, put the line number
if Excep.Msg_Length <= Exception_Msg_Max_Length - Size then
Excep.Msg (Excep.Msg_Length + 1) := ':';
Excep.Msg_Length := Excep.Msg_Length + Size;
Val := Line;
Size := 0;
while Val > 0 loop
Remind := Val rem 10;
Val := Val / 10;
Excep.Msg (Excep.Msg_Length - Size) :=
Character'Val (Remind + Character'Pos ('0'));
Size := Size + 1;
end loop;
end if;
end if;
end Set_Exception_C_Msg;
-------------------
-- String_To_EId --
-------------------
function String_To_EId (S : String) return Exception_Id is
begin
if S = "" then
return Null_Id;
else
return Exception_Id (Internal_Exception (S));
end if;
end String_To_EId;
------------------
-- String_To_EO --
------------------
function String_To_EO (S : String) return Exception_Occurrence is
From : Natural;
To : Integer;
X : Exception_Occurrence;
-- This is the exception occurrence we will create
procedure Bad_EO;
pragma No_Return (Bad_EO);
-- Signal bad exception occurrence string
procedure Next_String;
-- On entry, To points to last character of previous line of the
-- message, terminated by CR/LF. On return, From .. To are set to
-- specify the next string, or From > To if there are no more lines.
procedure Bad_EO is
begin
Raise_Exception
(Program_Error'Identity,
"bad exception occurrence in stream input");
end Bad_EO;
procedure Next_String is
begin
From := To + 3;
if From < S'Last then
To := From + 1;
while To < S'Last - 2 loop
if To >= S'Last then
Bad_EO;
elsif S (To + 1) = ASCII.CR then
exit;
else
To := To + 1;
end if;
end loop;
end if;
end Next_String;
-- Start of processing for String_To_EO
begin
if S = "" then
return Null_Occurrence;
else
X.Cleanup_Flag := False;
To := S'First - 3;
Next_String;
if S (From .. From + 15) /= "Exception name: " then
Bad_EO;
end if;
X.Id := Exception_Id (Internal_Exception (S (From + 16 .. To)));
Next_String;
if From <= To and then S (From) = 'M' then
if S (From .. From + 8) /= "Message: " then
Bad_EO;
end if;
X.Msg_Length := To - From - 8;
X.Msg (1 .. X.Msg_Length) := S (From + 9 .. To);
Next_String;
else
X.Msg_Length := 0;
end if;
X.Pid := 0;
if From <= To and then S (From) = 'P' then
if S (From .. From + 3) /= "PID:" then
Bad_EO;
end if;
From := From + 5; -- skip past PID: space
while From <= To loop
X.Pid := X.Pid * 10 +
(Character'Pos (S (From)) - Character'Pos ('0'));
From := From + 1;
end loop;
Next_String;
end if;
X.Num_Tracebacks := 0;
if From <= To then
if S (From .. To) /= "Call stack traceback locations:" then
Bad_EO;
end if;
Next_String;
loop
exit when From > To;
declare
Ch : Character;
C : Integer_Address;
N : Integer_Address;
begin
if S (From) /= '0'
or else S (From + 1) /= 'x'
then
Bad_EO;
else
From := From + 2;
end if;
C := 0;
while From <= To loop
Ch := S (From);
if Ch in '0' .. '9' then
N :=
Character'Pos (S (From)) - Character'Pos ('0');
elsif Ch in 'a' .. 'f' then
N :=
Character'Pos (S (From)) - Character'Pos ('a') + 10;
elsif Ch = ' ' then
From := From + 1;
exit;
else
Bad_EO;
end if;
C := C * 16 + N;
From := From + 1;
end loop;
if X.Num_Tracebacks = Max_Tracebacks then
Bad_EO;
end if;
X.Num_Tracebacks := X.Num_Tracebacks + 1;
X.Tracebacks (X.Num_Tracebacks) := To_Address (C);
end;
end loop;
end if;
-- If an exception was converted to a string, it must have
-- already been raised, so flag it accordingly and we are done.
X.Exception_Raised := True;
return X;
end if;
end String_To_EO;
----------------------------------
-- Tailored_Exception_Traceback --
----------------------------------
function Tailored_Exception_Traceback
(X : Exception_Occurrence)
return String
is
-- We indeed reference the decorator *wrapper* from here and not the
-- decorator itself. The purpose of the local variable Wrapper is to
-- prevent a potential crash by race condition in the code below. The
-- atomicity of this assignment is enforced by pragma Atomic in
-- System.Soft_Links.
-- The potential race condition here, if no local variable was used,
-- relates to the test upon the wrapper's value and the call, which
-- are not performed atomically. With the local variable, potential
-- changes of the wrapper's global value between the test and the
-- call become inoffensive.
Wrapper : constant Traceback_Decorator_Wrapper_Call :=
Traceback_Decorator_Wrapper;
begin
if Wrapper = null then
return Basic_Exception_Traceback (X);
else
return Wrapper.all (X.Tracebacks'Address, X.Num_Tracebacks);
end if;
end Tailored_Exception_Traceback;
------------------------------------
-- Tailored_Exception_Information --
------------------------------------
function Tailored_Exception_Information
(X : Exception_Occurrence)
return String
is
-- The tailored exception information is simply the basic information
-- associated with the tailored call chain backtrace.
Basic_Info : constant String := Basic_Exception_Information (X);
Tback_Info : constant String := Tailored_Exception_Traceback (X);
Basic_Len : constant Natural := Basic_Info'Length;
Tback_Len : constant Natural := Tback_Info'Length;
Info : String (1 .. Basic_Len + Tback_Len);
Ptr : Natural := 0;
begin
Append_Info_String (Basic_Info, Info, Ptr);
Append_Info_String (Tback_Info, Info, Ptr);
return Info;
end Tailored_Exception_Information;
-------------------------
-- Unhandled_Exception --
-------------------------
procedure Unhandled_Exception is
begin
null;
end Unhandled_Exception;
----------------------
-- Notify_Exception --
----------------------
procedure Notify_Exception
(Id : Exception_Id;
Handler : Code_Loc;
Is_Others : Boolean)
is
begin
null;
end Notify_Exception;
------------------------------
-- Notify_Handled_Exception --
------------------------------
procedure Notify_Handled_Exception
(Handler : Code_Loc;
Is_Others : Boolean;
Low_Notify : Boolean)
is
Excep : constant EOA := Get_Current_Excep.all;
begin
-- Notify the debugger that we have found a handler and are about to
-- propagate an exception, but only if specifically told to do so.
if Low_Notify then
Notify_Exception (Excep.Id, Handler, Is_Others);
end if;
-- Output some exception information if necessary, as specified by
-- GNAT.Exception_Traces. Take care not to output information about
-- internal exceptions.
--
-- ??? In the ZCX case, the traceback entries we have at this point
-- only include the ones we stored while walking up the stack *up to
-- the handler*. All the frames above the subprogram in which the
-- handler is found are missing.
if Exception_Trace = Every_Raise
and then not Excep.Id.Not_Handled_By_Others
then
To_Stderr (Nline);
To_Stderr ("Exception raised");
To_Stderr (Nline);
To_Stderr (Tailored_Exception_Information (Excep.all));
end if;
end Notify_Handled_Exception;
------------------------------
-- Notify_Handled_Exception --
------------------------------
procedure Notify_Unhandled_Exception (Id : Exception_Id) is
begin
-- Simply perform the two necessary low level notification calls.
Unhandled_Exception;
Notify_Exception (Id, Null_Loc, False);
end Notify_Unhandled_Exception;
-----------------------------------
-- Unhandled_Exception_Terminate --
-----------------------------------
adafinal_Called : Boolean := False;
-- Used to prevent recursive call to adafinal in the event that
-- adafinal processing itself raises an unhandled exception.
type FILEs is new System.Address;
type int is new Integer;
procedure Unhandled_Exception_Terminate is
Excep : constant EOA := Get_Current_Excep.all;
Msg : constant String := Exception_Message (Excep.all);
-- Start of processing for Unhandled_Exception_Terminate
begin
-- First call adafinal
if not adafinal_Called then
adafinal_Called := True;
System.Soft_Links.Adafinal.all;
end if;
-- Check for special case of raising _ABORT_SIGNAL, which is not
-- really an exception at all. We recognize this by the fact that
-- it is the only exception whose name starts with underscore.
if Exception_Name (Excep.all) (1) = '_' then
To_Stderr (Nline);
To_Stderr ("Execution terminated by abort of environment task");
To_Stderr (Nline);
-- If no tracebacks, we print the unhandled exception in the old style
-- (i.e. the style used before ZCX was implemented). We do this to
-- retain compatibility, especially with the nightly scripts, but
-- this can be removed at some point ???
elsif Excep.Num_Tracebacks = 0 then
To_Stderr (Nline);
To_Stderr ("raised ");
To_Stderr (Exception_Name (Excep.all));
if Msg'Length /= 0 then
To_Stderr (" : ");
To_Stderr (Msg);
end if;
To_Stderr (Nline);
-- New style, zero cost exception case
else
-- Tailored_Exception_Information is also called here so that the
-- backtrace decorator gets called if it has been set. This is
-- currently required because some paths in Raise_Current_Excep
-- do not go through the calls that display this information.
--
-- Note also that with the current scheme in Raise_Current_Excep
-- we can have this whole information output twice, typically when
-- some handler is found on the call chain but none deals with the
-- occurrence or if this occurrence gets reraised up to here.
To_Stderr (Nline);
To_Stderr ("Execution terminated by unhandled exception");
To_Stderr (Nline);
To_Stderr (Tailored_Exception_Information (Excep.all));
end if;
-- Perform system dependent shutdown code
declare
procedure Unhandled_Terminate;
pragma No_Return (Unhandled_Terminate);
pragma Import
(C, Unhandled_Terminate, "__gnat_unhandled_terminate");
begin
Unhandled_Terminate;
end;
end Unhandled_Exception_Terminate;
------------------------------
-- Raise_Exception_No_Defer --
------------------------------
procedure Raise_Exception_No_Defer
(E : Exception_Id;
Message : String := "")
is
Len : constant Natural :=
Natural'Min (Message'Length, Exception_Msg_Max_Length);
Excep : constant EOA := Get_Current_Excep.all;
begin
Excep.Exception_Raised := False;
Excep.Msg_Length := Len;
Excep.Msg (1 .. Len) := Message (1 .. Len);
Excep.Id := E;
Excep.Num_Tracebacks := 0;
Excep.Cleanup_Flag := False;
Excep.Pid := Local_Partition_ID;
-- DO NOT CALL Abort_Defer.all; !!!!
Raise_Current_Excep (E);
end Raise_Exception_No_Defer;
---------------
-- To_Stderr --
---------------
procedure To_Stderr (S : String) is
procedure put_char_stderr (C : int);
pragma Import (C, put_char_stderr, "put_char_stderr");
begin
for J in 1 .. S'Length loop
if S (J) /= ASCII.CR then
put_char_stderr (Character'Pos (S (J)));
end if;
end loop;
end To_Stderr;
---------
-- ZZZ --
---------
-- This dummy procedure gives us the end of the PC range for addresses
-- within the exception unit itself. We hope that gigi/gcc keeps all the
-- procedures in their original order!
procedure ZZZ is
begin
null;
end ZZZ;
begin
-- Allocate the Non-Tasking Machine_State
Set_Machine_State_Addr_NT (System.Address (Allocate_Machine_State));
end Ada.Exceptions;
|
--
--
--
with Ada.Unchecked_Deallocation;
package body Sets is
Index_First : Index_Type := Index_Type'First;
Index_Last : Index_Type := Index_Type'First;
procedure Set_Range (First : in Index_Type;
Last : in Index_Type)
is
begin
Index_First := First;
Index_Last := Last;
end Set_Range;
function Set_New return Set_Type is
begin
return new Set_Array'(Index_First .. Index_Last => False);
end Set_New;
procedure Set_Free (Set : in out Set_Type) is
procedure Free is
new Ada.Unchecked_Deallocation (Object => Set_Array,
Name => Set_Type);
begin
Free (Set);
end Set_Free;
function Set_Add (Set : in out Set_Type;
Item : in Index_Type) return Boolean
is
RV : Boolean;
begin
pragma Assert (Item >= Index_First);
pragma Assert (Item <= Index_Last);
RV := Set (Item);
Set (Item) := True;
return not RV;
end Set_Add;
function Set_Union (Set_1 : in out Set_Type;
Set_2 : in out Set_Type) return Boolean
is
Progress : Boolean;
begin
Progress := False;
for I in Index_First .. Index_Last loop
if Set_2 (I) then
if not Set_1 (I) then
Progress := True;
Set_1 (I) := True;
end if;
end if;
end loop;
return Progress;
end Set_Union;
function Set_Find (Set : in Set_Type;
Item : in Index_Type) return Boolean
is
begin
return Set (Item);
end Set_Find;
function First_Index return Index_Type is (Index_First);
function Last_Index return Index_Type is (Index_Last);
end Sets;
|
-----------------------------------------------------------------------
-- util-encoders-base16 -- Encode/Decode a stream in hexadecimal
-- Copyright (C) 2009, 2010, 2011, 2017 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.Streams;
-- The <b>Util.Encodes.Base16</b> packages encodes and decodes streams
-- in hexadecimal.
package Util.Encoders.Base16 is
pragma Preelaborate;
-- ------------------------------
-- Base16 encoder
-- ------------------------------
-- This <b>Encoder</b> translates the (binary) input stream into
-- an ascii hexadecimal stream. The encoding alphabet is: 0123456789ABCDEF.
type Encoder is new Util.Encoders.Transformer with private;
-- Encodes the binary input stream represented by <b>Data</b> into
-- the a base16 (hexadecimal) output stream <b>Into</b>.
--
-- If the transformer does not have enough room to write the result,
-- it must return in <b>Encoded</b> the index of the last encoded
-- position in the <b>Data</b> stream.
--
-- The transformer returns in <b>Last</b> the last valid position
-- in the output stream <b>Into</b>.
--
-- The <b>Encoding_Error</b> exception is raised if the input
-- stream cannot be transformed.
overriding
procedure Transform (E : in out Encoder;
Data : in Ada.Streams.Stream_Element_Array;
Into : out Ada.Streams.Stream_Element_Array;
Last : out Ada.Streams.Stream_Element_Offset;
Encoded : out Ada.Streams.Stream_Element_Offset);
-- ------------------------------
-- Base16 decoder
-- ------------------------------
-- The <b>Decoder</b> decodes an hexadecimal stream into a binary stream.
type Decoder is new Util.Encoders.Transformer with private;
-- Decodes the base16 input stream represented by <b>Data</b> into
-- the binary output stream <b>Into</b>.
--
-- If the transformer does not have enough room to write the result,
-- it must return in <b>Encoded</b> the index of the last encoded
-- position in the <b>Data</b> stream.
--
-- The transformer returns in <b>Last</b> the last valid position
-- in the output stream <b>Into</b>.
--
-- The <b>Encoding_Error</b> exception is raised if the input
-- stream cannot be transformed.
overriding
procedure Transform (E : in out Decoder;
Data : in Ada.Streams.Stream_Element_Array;
Into : out Ada.Streams.Stream_Element_Array;
Last : out Ada.Streams.Stream_Element_Offset;
Encoded : out Ada.Streams.Stream_Element_Offset);
private
type Encoder is new Util.Encoders.Transformer with null record;
type Decoder is new Util.Encoders.Transformer with null record;
generic
type Input_Char is (<>);
type Output_Char is (<>);
type Index is range <>;
type Output_Index is range <>;
type Input is array (Index range <>) of Input_Char;
type Output is array (Output_Index range <>) of Output_Char;
package Encoding is
procedure Encode (From : in Input;
Into : in out Output;
Last : out Output_Index;
Encoded : out Index);
procedure Decode (From : in Input;
Into : in out Output;
Last : out Output_Index;
Encoded : out Index);
end Encoding;
end Util.Encoders.Base16;
|
generic
N: Integer;
package data is
type Vector is private;
type Matrix is private;
function Func1(A,B,C: in Vector; MA,ME: in Matrix) return Integer;
function Func2(MH,MK,ML: in Matrix) return Integer;
function Func3(P: out Vector; MR,MT: in Matrix) return Vector;
function Matrix_Multiplication(A,B: in Matrix) return Matrix;
function Sum_Vector(A,B: in Vector) return Vector;
function Vector_Matrix_Multiplication(A: in Vector; B: in Matrix) return Vector;
function Max_of_Vector(A: in Vector) return Integer;
function Max_of_Matrix(A: in Matrix) return Integer;
function Matrix_Sub(A,B: in Matrix) return Matrix;
procedure Vector_Sort(A: in out Vector);
procedure Vector_Fill_Ones(A: out Vector);
procedure Matrix_Fill_Ones(A: out Matrix);
procedure Vector_Input (A: out Vector); -- fills values of
procedure Vector_Output (A: in Vector); -- shows values of
procedure Matrix_Input (A: out Matrix);
procedure Matrix_Output (A: in Matrix);
private
type Vector is array(1..N) of Integer;
type Matrix is array(1..N) of Vector;
end data;
|
-- part of OpenGLAda, (c) 2017 Felix Krause
-- released under the terms of the MIT license, see the file "COPYING"
with GL.API;
package body GL.Objects.Queries is
procedure Begin_Query (Target : GL.Low_Level.Enums.Query_Param;
Object : Query_Object) is
begin
API.Begin_Query (Target, Object.Reference.GL_Id);
Raise_Exception_On_OpenGL_Error;
end Begin_Query;
procedure End_Query (Target : GL.Low_Level.Enums.Query_Param) is
begin
API.End_Query (Target);
Raise_Exception_On_OpenGL_Error;
end End_Query;
procedure Begin_Query_Indexed (Target : GL.Low_Level.Enums.Query_Param;
Index : UInt; Object : Query_Object) is
begin
API.Begin_Query_Indexed (Target, Index, Object.Reference.GL_Id);
Raise_Exception_On_OpenGL_Error;
end Begin_Query_Indexed;
procedure End_Query_Indexed (Target : GL.Low_Level.Enums.Query_Param;
Index : UInt) is
begin
API.End_Query_Indexed (Target, Index);
Raise_Exception_On_OpenGL_Error;
end End_Query_Indexed;
procedure Get_Query_Object
(Object : Query_Object; Pname : GL.Low_Level.Enums.Query_Results;
Params : out UInt) is
begin
API.Get_Query_Object (Object.Reference.GL_Id, Pname, Params);
Raise_Exception_On_OpenGL_Error;
end Get_Query_Object;
overriding
procedure Internal_Create_Id (Object : Query_Object; Id : out UInt) is
pragma Unreferenced (Object);
begin
API.Gen_Queries (1, Id);
Raise_Exception_On_OpenGL_Error;
end Internal_Create_Id;
overriding
procedure Internal_Release_Id (Object : Query_Object; Id : UInt) is
pragma Unreferenced (Object);
begin
API.Delete_Queries (1, (1 => Id));
Raise_Exception_On_OpenGL_Error;
end Internal_Release_Id;
function Is_Query (Query : Query_Object) return Boolean is
begin
return API.Is_Query (Raw_Id (Query));
end Is_Query;
procedure Query_Counter (Object : Query_Object;
Target : Low_Level.Enums.Query_Param) is
begin
API.Query_Counter (Object.Reference.GL_Id, Target);
Raise_Exception_On_OpenGL_Error;
end Query_Counter;
end GL.Objects.Queries;
|
-----------------------------------------------------------------------
-- awa-helpers -- Helpers for AWA applications
-- Copyright (C) 2011 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 Util.Beans.Basic;
with Util.Beans.Objects;
with Util.Properties.Bundles;
with ADO.Sessions;
with ADO.Queries;
with ADO.Statements;
with ASF.Models.Selects;
with ASF.Contexts.Faces;
-- The <b>Selectors</b> package provides several helper operations to create and populate
-- a selector list from an static list (type) or from by using a database SQL query.
package AWA.Helpers.Selectors is
-- Create a selector list from the definition of a discrete type such as an enum.
-- The select item has the enum value as value and the label is created by
-- localizing the string <b>Prefix</b>_<i>enum name</i>.
generic
type T is (<>);
Prefix : String;
function Create_From_Enum (Bundle : in Util.Properties.Bundles.Manager'Class)
return ASF.Models.Selects.Select_Item_List;
-- Create a selector list by using a resource bundle and a create operation that looks for
-- messages in the bundle. The bundle name <b>Bundle</b> gives the name of the resource
-- bundled to load. The locale is determined by the ASF context passed in <b>Context</b>.
-- The <b>Create</b> function is in charge of creating and populating the select list.
function Create_Selector_Bean (Bundle : in String;
Context : in ASF.Contexts.Faces.Faces_Context_Access := null;
Create : access function
(Bundle : in Util.Properties.Bundles.Manager'Class)
return ASF.Models.Selects.Select_Item_List)
return Util.Beans.Basic.Readonly_Bean_Access;
-- Append the selector list from the SQL query. The query will be executed.
-- It should return rows with at least two columns. The first column is the
-- selector value and the second column is the selector label.
procedure Append_From_Query (Into : in out ASF.Models.Selects.Select_Item_List;
Query : in out ADO.Statements.Query_Statement'Class);
-- Create the selector list from the SQL query. The query will be executed.
-- It should return rows with at least two columns. The first column is the
-- selector value and the second column is the selector label.
function Create_From_Query (Session : in ADO.Sessions.Session'Class;
Query : in ADO.Queries.Context'Class)
return ASF.Models.Selects.Select_Item_List;
-- ------------------------------
-- Select list bean
-- ------------------------------
-- The <b>Select_List_Bean</b> type is a bean object that can be declared in XML
-- configuration files and customized by the <b>query</b> property.
type Select_List_Bean is new Util.Beans.Basic.Bean with record
List : ASF.Models.Selects.Select_Item_List;
end record;
type Select_List_Bean_Access is access all Select_List_Bean;
-- Get the value identified by the name.
-- If the name cannot be found, the method should return the Null object.
overriding
function Get_Value (From : in Select_List_Bean;
Name : in String) return Util.Beans.Objects.Object;
-- Set the value identified by the name.
-- If the name cannot be found, the method should raise the No_Value
-- exception.
overriding
procedure Set_Value (From : in out Select_List_Bean;
Name : in String;
Value : in Util.Beans.Objects.Object);
-- Create the select list bean instance.
function Create_Select_List_Bean return Util.Beans.Basic.Readonly_Bean_Access;
end AWA.Helpers.Selectors;
|
-- Copyright 2019 Michael Casadevall <michael@casadevall.pro>
--
-- 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.Strings.Unbounded; use Ada.Strings.Unbounded;
with Ada.Containers.Vectors; use Ada.Containers;
with Ada.Containers.Hashed_Maps;
with Interfaces.C.Extensions; use Interfaces.C.Extensions;
with GNAT.Sockets; use GNAT.Sockets;
with DNSCatcher.Datasets; use DNSCatcher.Datasets;
with DNSCatcher.Types; use DNSCatcher.Types;
-- @summary
-- The Transaction Manager keeps state of DNS connections and ensures that each
-- individual client gets the correct DNS request without crossrouting them
--
-- @description
-- The Transaction Manager keeps track of the state of DNS handshakes and
-- requests. This is required due to the connectionless nature of UDP, and to
-- a lesser extent with TCP/IP, DoH/DoT. This is handled on a per network layer
-- level, so UDP v4 and v6 have seperate transaction managers to handle result
-- management.
--
package DNSCatcher.DNS.Transaction_Manager is
-- Collection of stored packets for processing or delivery
package Stored_Packets_Vector is new Vectors (Natural,
Raw_Packet_Record_Ptr);
-- DNS Transaction Task
--
-- Handles transaction management as a many procedures, one (or more)
-- consumers.
task type DNS_Transaction_Manager_Task is
-- Starts the Transaction Manager
entry Start;
-- Sets the packet queue vector for a given network interface
--
-- @value Queue
-- The raw packet queue to use
entry Set_Packet_Queue (Queue : DNS_Raw_Packet_Queue_Ptr);
-- Inbound client packets come here
--
-- @value Packet
-- The raw packet as generated by the network interface
--
-- @value Local
-- Is this packet generated by the internal DNS client?
entry From_Client_Resolver_Packet
(Packet : Raw_Packet_Record_Ptr;
Local : Boolean);
-- Inbound server packets are loaded here
--
-- @value Packet
-- Raw DNS packet generated by the network interface code
--
entry From_Upstream_Resolver_Packet (Packet : Raw_Packet_Record_Ptr);
-- DNS Transaction Manager shutdown
entry Stop;
end DNS_Transaction_Manager_Task;
type DNS_Transaction_Manager_Task_Ptr is
access DNS_Transaction_Manager_Task;
private
-- Record of a DNS Transaction
--
-- @value Client_Resolver_Address
-- The downstream client making a request to DNSCatcher's internal DNS
-- server (or relay)
--
-- @value Client_Resolver_Port
--
-- The port used for communicating with; due to the way UDP sockets work,
-- this can be a high level port that's dynamically allocated and not port
-- 53 as may be expected
--
-- @value Server_Resolver_Address
--
-- The upstream server that is handling this result. May be the Catcher
-- instance itself.
--
-- @value Server_Resolver_Port
--
-- The port used to communicate with the upstream server location
--
-- @value DNS_Transaction_Id
--
-- The 16-bit integer sent by the client to isolate individual DNS
-- transactions from a given client.
--
-- @value Local_Request
-- The internal DNS Client made this request
--
-- @value From_Client_Resolver_Packet The client's packet allocated on the
-- heap ready for processing
--
-- @value From_Upstream_Resolver_Packet The upstream server's packet ready
-- for delivery to the client
--
type DNS_Transaction is record
Client_Resolver_Address : Unbounded_String;
Client_Resolver_Port : Port_Type;
Server_Resolver_Address : Unbounded_String;
Server_Resolver_Port : Port_Type;
DNS_Transaction_Id : Unsigned_16;
Local_Request : Boolean;
From_Client_Resolver_Packet : Raw_Packet_Record_Ptr;
From_Upstream_Resolver_Packet : Raw_Packet_Record_Ptr;
end record;
type DNS_Transaction_Ptr is access DNS_Transaction;
type IP_Transaction_Key is new Unbounded_String;
function IP_Transaction_Key_HashID
(id : IP_Transaction_Key)
return Hash_Type;
package DNS_Transaction_Maps is new Hashed_Maps
(Key_Type => IP_Transaction_Key, Element_Type => DNS_Transaction_Ptr,
Hash => IP_Transaction_Key_HashID, Equivalent_Keys => "=");
use DNS_Transaction_Maps;
procedure Free_Hash_Map_Entry (c : DNS_Transaction_Maps.Cursor);
end DNSCatcher.DNS.Transaction_Manager;
|
with System;
package body Flash is
Flash_Memory : array (Unsigned_32 range 0 .. 16#3FFFF#) of Unsigned_16
with Import, Address => System'To_Address (0);
procedure Init is
begin
null;
end Init;
procedure Unlock is
begin
null;
end Unlock;
procedure Lock is
begin
null;
end Lock;
procedure Enable_Erase is
begin
null;
end Enable_Erase;
procedure Erase (Addr : Unsigned_32) is
begin
Enable_Erase;
Write (Addr, 0);
end Erase;
procedure Enable_Write is
begin
null;
end Enable_Write;
procedure Write (Addr : Unsigned_32; Value : Unsigned_16) is
begin
Flash_Memory (Addr / 2) := Value;
end Write;
function Read (Addr : Unsigned_32) return Unsigned_16 is
begin
return Flash_Memory (Addr / 2);
end Read;
procedure Wait_Until_Ready is
begin
null;
end Wait_Until_Ready;
end Flash;
|
with Ada.Text_IO;
use Ada.Text_IO;
--with xample1;
--use xample1;
package body xample1 is
procedure xercise is
begin
xample.SayWelcome(1);
end xercise;
end xample1;
|
--//////////////////////////////////////////////////////////
-- 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.System.InputStream;
with Sf.Graphics.Glsl;
with Sf.Graphics.Color;
with Sf.System.Vector2;
with Sf.System.Vector3;
with Sf.Graphics.Transform;
package Sf.Graphics.Shader is
--//////////////////////////////////////////////////////////
--//////////////////////////////////////////////////////////
--//////////////////////////////////////////////////////////
--//////////////////////////////////////////////////////////
--//////////////////////////////////////////////////////////
--/ @brief Load the vertex, geometry and fragment shaders from files
--/
--/ This function loads the vertex, geometry and fragment
--/ shaders. Pass NULL if you don't want to load
--/ a specific shader.
--/ The sources must be text files containing valid shaders
--/ in GLSL language. GLSL is a C-like language dedicated to
--/ OpenGL shaders; you'll probably need to read a good documentation
--/ for it before writing your own shaders.
--/
--/ @param vertexShaderFilename Path of the vertex shader file to load, or NULL to skip this shader
--/ @param geometryShaderFilename Path of the geometry shader file to load, or NULL to skip this shader
--/ @param fragmentShaderFilename Path of the fragment shader file to load, or NULL to skip this shader
--/
--/ @return A new sfShader object, or NULL if it failed
--/
--//////////////////////////////////////////////////////////
function createFromFile
(vertexShaderFilename : String;
geometryShaderFilename : String;
fragmentShaderFilename : String) return sfShader_Ptr;
--//////////////////////////////////////////////////////////
--/ @brief Load the vertex, geometry and fragment shaders from source code in memory
--/
--/ This function loads the vertex, geometry and fragment
--/ shaders. Pass NULL if you don't want to load
--/ a specific shader.
--/ The sources must be valid shaders in GLSL language. GLSL is
--/ a C-like language dedicated to OpenGL shaders; you'll
--/ probably need to read a good documentation for it before
--/ writing your own shaders.
--/
--/ @param vertexShader String containing the source code of the vertex shader, or NULL to skip this shader
--/ @param geometryShader String containing the source code of the geometry shader, or NULL to skip this shader
--/ @param fragmentShader String containing the source code of the fragment shader, or NULL to skip this shader
--/
--/ @return A new sfShader object, or NULL if it failed
--/
--//////////////////////////////////////////////////////////
function createFromMemory
(vertexShader : String;
geometryShader : String;
fragmentShader : String) return sfShader_Ptr;
--//////////////////////////////////////////////////////////
--/ @brief Load the vertex, geometry and fragment shaders from custom streams
--/
--/ This function loads the vertex, geometry and fragment
--/ shaders. Pass NULL if you don't want to load
--/ a specific shader.
--/ The source codes must be valid shaders in GLSL language.
--/ GLSL is a C-like language dedicated to OpenGL shaders;
--/ you'll probably need to read a good documentation for
--/ it before writing your own shaders.
--/
--/ @param vertexShaderStream Source stream to read the vertex shader from, or NULL to skip this shader
--/ @param geometryShaderStream Source stream to read the geometry shader from, or NULL to skip this shader
--/ @param fragmentShaderStream Source stream to read the fragment shader from, or NULL to skip this shader
--/
--/ @return A new sfShader object, or NULL if it failed
--/
--//////////////////////////////////////////////////////////
function createFromStream
(vertexShaderStream : access Sf.System.InputStream.sfInputStream;
geometryShaderStream : access Sf.System.InputStream.sfInputStream;
fragmentShaderStream : access Sf.System.InputStream.sfInputStream) return sfShader_Ptr;
--//////////////////////////////////////////////////////////
--/ @brief Destroy an existing shader
--/
--/ @param shader Shader to delete
--/
--//////////////////////////////////////////////////////////
procedure destroy (shader : sfShader_Ptr);
--//////////////////////////////////////////////////////////
--/ @brief Specify value for @p float uniform
--/
--/ @param shader Shader object
--/ @param name Name of the uniform variable in GLSL
--/ @param x Value of the float scalar
--/
--//////////////////////////////////////////////////////////
procedure setFloatUniform
(shader : sfShader_Ptr;
name : String;
x : float);
--//////////////////////////////////////////////////////////
--/ @brief Specify value for @p vec2 uniform
--/
--/ @param shader Shader object
--/ @param name Name of the uniform variable in GLSL
--/ @param vector Value of the vec2 vector
--/
--//////////////////////////////////////////////////////////
procedure setVec2Uniform
(shader : sfShader_Ptr;
name : String;
vector : Sf.Graphics.Glsl.sfGlslVec2);
--//////////////////////////////////////////////////////////
--/ @brief Specify value for @p vec3 uniform
--/
--/ @param shader Shader object
--/ @param name Name of the uniform variable in GLSL
--/ @param vector Value of the vec3 vector
--/
--//////////////////////////////////////////////////////////
procedure setVec3Uniform
(shader : sfShader_Ptr;
name : String;
vector : Sf.Graphics.Glsl.sfGlslVec3);
--//////////////////////////////////////////////////////////
--/ @brief Specify value for @p vec4 uniform
--/
--/ sfColor objects can be passed to this function via
--/ the use of sfGlslVec4_fromsfColor(sfColor);
--/
--/ @param shader Shader object
--/ @param name Name of the uniform variable in GLSL
--/ @param vector Value of the vec4 vector
--/
--//////////////////////////////////////////////////////////
procedure setVec4Uniform
(shader : sfShader_Ptr;
name : String;
vector : Sf.Graphics.Glsl.sfGlslVec4);
--//////////////////////////////////////////////////////////
--/ @brief Specify value for @p vec4 uniform
--/
--/ @param shader Shader object
--/ @param name Name of the uniform variable in GLSL
--/ @param color Value of the vec4 vector
--/
--//////////////////////////////////////////////////////////
procedure setColorUniform
(shader : sfShader_Ptr;
name : String;
color : Sf.Graphics.Color.sfColor);
--//////////////////////////////////////////////////////////
--/ @brief Specify value for @p int uniform
--/
--/ @param shader Shader object
--/ @param name Name of the uniform variable in GLSL
--/ @param x Value of the integer scalar
--/
--//////////////////////////////////////////////////////////
procedure setIntUniform
(shader : sfShader_Ptr;
name : String;
x : sfInt32);
--//////////////////////////////////////////////////////////
--/ @brief Specify value for @p ivec2 uniform
--/
--/ @param shader Shader object
--/ @param name Name of the uniform variable in GLSL
--/ @param vector Value of the ivec2 vector
--/
--//////////////////////////////////////////////////////////
procedure setIvec2Uniform
(shader : sfShader_Ptr;
name : String;
vector : Sf.Graphics.Glsl.sfGlslIvec2);
--//////////////////////////////////////////////////////////
--/ @brief Specify value for @p ivec3 uniform
--/
--/ @param shader Shader object
--/ @param name Name of the uniform variable in GLSL
--/ @param vector Value of the ivec3 vector
--/
--//////////////////////////////////////////////////////////
procedure setIvec3Uniform
(shader : sfShader_Ptr;
name : String;
vector : Sf.Graphics.Glsl.sfGlslIvec3);
--//////////////////////////////////////////////////////////
--/ @brief Specify value for @p ivec4 uniform
--/
--/ sfColor objects can be passed to this function via
--/ the use of sfGlslIvec4_fromsfColor(sfColor);
--/
--/ @param shader Shader object
--/ @param name Name of the uniform variable in GLSL
--/ @param vector Value of the ivec4 vector
--/
--//////////////////////////////////////////////////////////
procedure setIvec4Uniform
(shader : sfShader_Ptr;
name : String;
vector : Sf.Graphics.Glsl.sfGlslIvec4);
--//////////////////////////////////////////////////////////
--/ @brief Specify value for @p ivec4 uniform
--/
--/ @param shader Shader object
--/ @param name Name of the uniform variable in GLSL
--/ @param color Value of the ivec4 vector
--/
--//////////////////////////////////////////////////////////
procedure setIntColorUniform
(shader : sfShader_Ptr;
name : String;
color : Sf.Graphics.Color.sfColor);
--//////////////////////////////////////////////////////////
--/ @brief Specify value for @p bool uniform
--/
--/ @param shader Shader object
--/ @param name Name of the uniform variable in GLSL
--/ @param x Value of the bool scalar
--/
--//////////////////////////////////////////////////////////
procedure setBoolUniform
(shader : sfShader_Ptr;
name : String;
x : sfBool);
--//////////////////////////////////////////////////////////
--/ @brief Specify value for @p bvec2 uniform
--/
--/ @param shader Shader object
--/ @param name Name of the uniform variable in GLSL
--/ @param vector Value of the bvec2 vector
--/
--//////////////////////////////////////////////////////////
procedure setBvec2Uniform
(shader : sfShader_Ptr;
name : String;
vector : Sf.Graphics.Glsl.sfGlslBvec2);
--//////////////////////////////////////////////////////////
--/ @brief Specify value for @p Bvec3 uniform
--/
--/ @param shader Shader object
--/ @param name Name of the uniform variable in GLSL
--/ @param vector Value of the Bvec3 vector
--/
--//////////////////////////////////////////////////////////
procedure setBvec3Uniform
(shader : sfShader_Ptr;
name : String;
vector : Sf.Graphics.Glsl.sfGlslBvec3);
--//////////////////////////////////////////////////////////
--/ @brief Specify value for @p bvec4 uniform
--/
--/ sfColor objects can be passed to this function via
--/ the use of sfGlslIvec4_fromsfColor(sfColor);
--/
--/ @param shader Shader object
--/ @param name Name of the uniform variable in GLSL
--/ @param vector Value of the bvec4 vector
--/
--//////////////////////////////////////////////////////////
procedure setBvec4Uniform
(shader : sfShader_Ptr;
name : String;
vector : Sf.Graphics.Glsl.sfGlslBvec4);
--//////////////////////////////////////////////////////////
--/ @brief Specify value for @p mat3 matrix
--/
--/ @param shader Shader object
--/ @param name Name of the uniform variable in GLSL
--/ @param matrix Value of the mat3 matrix
--/
--//////////////////////////////////////////////////////////
procedure setMat3Uniform
(shader : sfShader_Ptr;
name : String;
matrix : access constant Sf.Graphics.Glsl.sfGlslMat3);
--//////////////////////////////////////////////////////////
--/ @brief Specify value for @p mat4 matrix
--/
--/ @param shader Shader object
--/ @param name Name of the uniform variable in GLSL
--/ @param matrix Value of the mat4 matrix
--/
--//////////////////////////////////////////////////////////
procedure setMat4Uniform
(shader : sfShader_Ptr;
name : String;
matrix : access constant Sf.Graphics.Glsl.sfGlslMat4);
--//////////////////////////////////////////////////////////
--/ @brief Specify a texture as @p sampler2D uniform
--/
--/ @a name is the name of the variable to change in the shader.
--/ The corresponding parameter in the shader must be a 2D texture
--/ (@p sampler2D GLSL type).
--/
--/ Example:
--/ @code
--/ uniform sampler2D the_texture; // this is the variable in the shader
--/ @endcode
--/ @code
--/ sfTexture texture;
--/ ...
--/ sfShader_setTextureUniform(shader, "the_texture", &texture);
--/ @endcode
--/ It is important to note that @a texture must remain alive as long
--/ as the shader uses it, no copy is made internally.
--/
--/ To use the texture of the object being drawn, which cannot be
--/ known in advance, you can pass the special value
--/ sf::Shader::CurrentTexture:
--/ @code
--/ shader.setUniform("the_texture", sf::Shader::CurrentTexture).
--/ @endcode
--/
--/ @param shader Shader object
--/ @param name Name of the texture in the shader
--/ @param texture Texture to assign
--/
--//////////////////////////////////////////////////////////
procedure setTextureUniform
(shader : sfShader_Ptr;
name : String;
texture : sfTexture_Ptr);
--//////////////////////////////////////////////////////////
--/ @brief Specify current texture as @p sampler2D uniform
--/
--/ This overload maps a shader texture variable to the
--/ texture of the object being drawn, which cannot be
--/ known in advance.
--/ The corresponding parameter in the shader must be a 2D texture
--/ (@p sampler2D GLSL type).
--/
--/ Example:
--/ @code
--/ uniform sampler2D current; // this is the variable in the shader
--/ @endcode
--/ @code
--/ sfShader_setCurrentTextureUniform(shader, "current");
--/ @endcode
--/
--/ @param shader Shader object
--/ @param name Name of the texture in the shader
--/
--//////////////////////////////////////////////////////////
procedure setCurrentTextureUniform (shader : sfShader_Ptr; name : String);
--//////////////////////////////////////////////////////////
--/ @brief Specify values for @p float[] array uniform
--/
--/ @param shader Shader object
--/ @param name Name of the uniform variable in GLSL
--/ @param scalarArray pointer to array of @p float values
--/ @param length Number of elements in the array
--/
--//////////////////////////////////////////////////////////
procedure setFloatUniformArray
(shader : sfShader_Ptr;
name : String;
scalarArray : access float;
length : sfSize_t);
--//////////////////////////////////////////////////////////
--/ @brief Specify values for @p vec2[] array uniform
--/
--/ @param shader Shader object
--/ @param name Name of the uniform variable in GLSL
--/ @param vectorArray pointer to array of @p vec2 values
--/ @param length Number of elements in the array
--/
--//////////////////////////////////////////////////////////
procedure setVec2UniformArray
(shader : sfShader_Ptr;
name : String;
vectorArray : access constant Sf.Graphics.Glsl.sfGlslVec2;
length : sfSize_t);
--//////////////////////////////////////////////////////////
--/ @brief Specify values for @p vec3[] array uniform
--/
--/ @param shader Shader object
--/ @param name Name of the uniform variable in GLSL
--/ @param vectorArray pointer to array of @p vec3 values
--/ @param length Number of elements in the array
--/
--//////////////////////////////////////////////////////////
procedure setVec3UniformArray
(shader : sfShader_Ptr;
name : String;
vectorArray : access constant Sf.Graphics.Glsl.sfGlslVec3;
length : sfSize_t);
--//////////////////////////////////////////////////////////
--/ @brief Specify values for @p vec4[] array uniform
--/
--/ @param shader Shader object
--/ @param name Name of the uniform variable in GLSL
--/ @param vectorArray pointer to array of @p vec4 values
--/ @param length Number of elements in the array
--/
--//////////////////////////////////////////////////////////
procedure setVec4UniformArray
(shader : sfShader_Ptr;
name : String;
vectorArray : access constant Sf.Graphics.Glsl.sfGlslVec4;
length : sfSize_t);
--//////////////////////////////////////////////////////////
--/ @brief Specify values for @p mat3[] array uniform
--/
--/ @param shader Shader object
--/ @param name Name of the uniform variable in GLSL
--/ @param matrixArray pointer to array of @p mat3 values
--/ @param length Number of elements in the array
--/
--//////////////////////////////////////////////////////////
procedure setMat3UniformArray
(shader : sfShader_Ptr;
name : String;
matrixArray : access constant Sf.Graphics.Glsl.sfGlslMat3;
length : sfSize_t);
--//////////////////////////////////////////////////////////
--/ @brief Specify values for @p mat4[] array uniform
--/
--/ @param shader Shader object
--/ @param name Name of the uniform variable in GLSL
--/ @param matrixArray pointer to array of @p mat4 values
--/ @param length Number of elements in the array
--/
--//////////////////////////////////////////////////////////
procedure setMat4UniformArray
(shader : sfShader_Ptr;
name : String;
matrixArray : access constant Sf.Graphics.Glsl.sfGlslMat4;
length : sfSize_t);
--//////////////////////////////////////////////////////////
--/ @brief Change a float parameter of a shader
--/
--/ @a name is the name of the variable to change in the shader.
--/ The corresponding parameter in the shader must be a float
--/ (float GLSL type).
--/
--/ Example:
--/ @code
--/ uniform float myparam; // this is the variable in the shader
--/ @endcode
--/ @code
--/ sfShader_setFloatParameter(shader, "myparam", 5.2f);
--/ @endcode
--/
--/ @param shader Shader object
--/ @param name Name of the parameter in the shader
--/ @param x Value to assign
--/
--//////////////////////////////////////////////////////////
procedure setFloatParameter
(shader : sfShader_Ptr;
name : String;
x : float);
--//////////////////////////////////////////////////////////
--/ @brief Change a 2-components vector parameter of a shader
--/
--/ @a name is the name of the variable to change in the shader.
--/ The corresponding parameter in the shader must be a 2x1 vector
--/ (vec2 GLSL type).
--/
--/ Example:
--/ @code
--/ uniform vec2 myparam; // this is the variable in the shader
--/ @endcode
--/ @code
--/ sfShader_setFloat2Parameter(shader, "myparam", 5.2f, 6.0f);
--/ @endcode
--/
--/ @param shader Shader object
--/ @param name Name of the parameter in the shader
--/ @param x First component of the value to assign
--/ @param y Second component of the value to assign
--/
--//////////////////////////////////////////////////////////
procedure setFloat2Parameter
(shader : sfShader_Ptr;
name : String;
x : float;
y : float);
--//////////////////////////////////////////////////////////
--/ @brief Change a 3-components vector parameter of a shader
--/
--/ @a name is the name of the variable to change in the shader.
--/ The corresponding parameter in the shader must be a 3x1 vector
--/ (vec3 GLSL type).
--/
--/ Example:
--/ @code
--/ uniform vec3 myparam; // this is the variable in the shader
--/ @endcode
--/ @code
--/ sfShader_setFloat3Parameter(shader, "myparam", 5.2f, 6.0f, -8.1f);
--/ @endcode
--/
--/ @param shader Shader object
--/ @param name Name of the parameter in the shader
--/ @param x First component of the value to assign
--/ @param y Second component of the value to assign
--/ @param z Third component of the value to assign
--/
--//////////////////////////////////////////////////////////
procedure setFloat3Parameter
(shader : sfShader_Ptr;
name : String;
x : float;
y : float;
z : float);
--//////////////////////////////////////////////////////////
--/ @brief Change a 4-components vector parameter of a shader
--/
--/ @a name is the name of the variable to change in the shader.
--/ The corresponding parameter in the shader must be a 4x1 vector
--/ (vec4 GLSL type).
--/
--/ Example:
--/ @code
--/ uniform vec4 myparam; // this is the variable in the shader
--/ @endcode
--/ @code
--/ sfShader_setFloat4Parameter(shader, "myparam", 5.2f, 6.0f, -8.1f, 0.4f);
--/ @endcode
--/
--/ @param shader Shader object
--/ @param name Name of the parameter in the shader
--/ @param x First component of the value to assign
--/ @param y Second component of the value to assign
--/ @param z Third component of the value to assign
--/ @param w Fourth component of the value to assign
--/
--//////////////////////////////////////////////////////////
procedure setFloat4Parameter
(shader : sfShader_Ptr;
name : String;
x : float;
y : float;
z : float;
w : float);
--//////////////////////////////////////////////////////////
--/ @brief Change a 2-components vector parameter of a shader
--/
--/ @a name is the name of the variable to change in the shader.
--/ The corresponding parameter in the shader must be a 2x1 vector
--/ (vec2 GLSL type).
--/
--/ Example:
--/ @code
--/ uniform vec2 myparam; // this is the variable in the shader
--/ @endcode
--/ @code
--/ sfVector2f vec = {5.2f, 6.0f};
--/ sfShader_setVector2Parameter(shader, "myparam", vec);
--/ @endcode
--/
--/ @param shader Shader object
--/ @param name Name of the parameter in the shader
--/ @param vector Vector to assign
--/
--//////////////////////////////////////////////////////////
procedure setVector2Parameter
(shader : sfShader_Ptr;
name : String;
vector : Sf.System.Vector2.sfVector2f);
--//////////////////////////////////////////////////////////
--/ @brief Change a 3-components vector parameter of a shader
--/
--/ @a name is the name of the variable to change in the shader.
--/ The corresponding parameter in the shader must be a 3x1 vector
--/ (vec3 GLSL type).
--/
--/ Example:
--/ @code
--/ uniform vec3 myparam; // this is the variable in the shader
--/ @endcode
--/ @code
--/ sfVector3f vec = {5.2f, 6.0f, -8.1f};
--/ sfShader_setVector3Parameter(shader, "myparam", vec);
--/ @endcode
--/
--/ @param shader Shader object
--/ @param name Name of the parameter in the shader
--/ @param vector Vector to assign
--/
--//////////////////////////////////////////////////////////
procedure setVector3Parameter
(shader : sfShader_Ptr;
name : String;
vector : Sf.System.Vector3.sfVector3f);
--//////////////////////////////////////////////////////////
--/ @brief Change a color parameter of a shader
--/
--/ @a name is the name of the variable to change in the shader.
--/ The corresponding parameter in the shader must be a 4x1 vector
--/ (vec4 GLSL type).
--/
--/ It is important to note that the components of the color are
--/ normalized before being passed to the shader. Therefore,
--/ they are converted from range [0 .. 255] to range [0 .. 1].
--/ For example, a sf::Color(255, 125, 0, 255) will be transformed
--/ to a vec4(1.0, 0.5, 0.0, 1.0) in the shader.
--/
--/ Example:
--/ @code
--/ uniform vec4 color; // this is the variable in the shader
--/ @endcode
--/ @code
--/ sfShader_setColorParameter(shader, "color", sfColor_fromRGB(255, 128, 0));
--/ @endcode
--/
--/ @param shader Shader object
--/ @param name Name of the parameter in the shader
--/ @param color Color to assign
--/
--//////////////////////////////////////////////////////////
procedure setColorParameter
(shader : sfShader_Ptr;
name : String;
color : Sf.Graphics.Color.sfColor);
--//////////////////////////////////////////////////////////
--/ @brief Change a matrix parameter of a shader
--/
--/ @a name is the name of the variable to change in the shader.
--/ The corresponding parameter in the shader must be a 4x4 matrix
--/ (mat4 GLSL type).
--/
--/ Example:
--/ @code
--/ uniform mat4 matrix; // this is the variable in the shader
--/ @endcode
--/ @code
--/ @todo
--/ sfShader_setTransformParameter(shader, "matrix", transform);
--/ @endcode
--/
--/ @param shader Shader object
--/ @param name Name of the parameter in the shader
--/ @param transform Transform to assign
--/
--//////////////////////////////////////////////////////////
procedure setTransformParameter
(shader : sfShader_Ptr;
name : String;
transform : Sf.Graphics.Transform.sfTransform);
--//////////////////////////////////////////////////////////
--/ @brief Change a texture parameter of a shader
--/
--/ @a name is the name of the variable to change in the shader.
--/ The corresponding parameter in the shader must be a 2D texture
--/ (sampler2D GLSL type).
--/
--/ Example:
--/ @code
--/ uniform sampler2D the_texture; // this is the variable in the shader
--/ @endcode
--/ @code
--/ sf::Texture texture;
--/ ...
--/ sfShader_setTextureParameter(shader, "the_texture", texture);
--/ @endcode
--/ It is important to note that @a texture must remain alive as long
--/ as the shader uses it, no copy is made internally.
--/
--/ To use the texture of the object being draw, which cannot be
--/ known in advance, you can use the special function
--/ sfShader_setCurrentTextureParameter:
--/ @code
--/ sfShader_setCurrentTextureParameter(shader, "the_texture").
--/ @endcode
--/
--/ @param shader Shader object
--/ @param name Name of the texture in the shader
--/ @param texture Texture to assign
--/
--//////////////////////////////////////////////////////////
procedure setTextureParameter
(shader : sfShader_Ptr;
name : String;
texture : sfTexture_Ptr);
--//////////////////////////////////////////////////////////
--/ @brief Change a texture parameter of a shader
--/
--/ This function maps a shader texture variable to the
--/ texture of the object being drawn, which cannot be
--/ known in advance.
--/ The corresponding parameter in the shader must be a 2D texture
--/ (sampler2D GLSL type).
--/
--/ Example:
--/ @code
--/ uniform sampler2D current; // this is the variable in the shader
--/ @endcode
--/ @code
--/ sfShader_setCurrentTextureParameter(shader, "current");
--/ @endcode
--/
--/ @param shader Shader object
--/ @param name Name of the texture in the shader
--/
--//////////////////////////////////////////////////////////
procedure setCurrentTextureParameter (shader : sfShader_Ptr; name : String);
--//////////////////////////////////////////////////////////
--/ @brief Get the underlying OpenGL handle of the shader.
--/
--/ You shouldn't need to use this function, unless you have
--/ very specific stuff to implement that SFML doesn't support,
--/ or implement a temporary workaround until a bug is fixed.
--/
--/ @param shader Shader object
--/
--/ @return OpenGL handle of the shader or 0 if not yet loaded
--/
--//////////////////////////////////////////////////////////
function getNativeHandle (shader : sfShader_Ptr) return sfUint32;
--//////////////////////////////////////////////////////////
--/ @brief Bind a shader for rendering (activate it)
--/
--/ This function is not part of the graphics API, it mustn't be
--/ used when drawing SFML entities. It must be used only if you
--/ mix sfShader with OpenGL code.
--/
--/ @code
--/ sfShader *s1, *s2;
--/ ...
--/ sfShader_bind(s1);
--/ // draw OpenGL stuff that use s1...
--/ sfShader_bind(s2);
--/ // draw OpenGL stuff that use s2...
--/ sfShader_bind(0);
--/ // draw OpenGL stuff that use no shader...
--/ @endcode
--/
--/ @param shader Shader to bind, can be null to use no shader
--/
--//////////////////////////////////////////////////////////
procedure bind (shader : sfShader_Ptr);
--//////////////////////////////////////////////////////////
--/ @brief Tell whether or not the system supports shaders
--/
--/ This function should always be called before using
--/ the shader features. If it returns false, then
--/ any attempt to use sfShader will fail.
--/
--/ @return sfTrue if the system can use shaders, sfFalse otherwise
--/
--//////////////////////////////////////////////////////////
function isAvailable return sfBool;
--//////////////////////////////////////////////////////////
--/ @brief Tell whether or not the system supports geometry shaders
--/
--/ This function should always be called before using
--/ the geometry shader features. If it returns false, then
--/ any attempt to use sfShader geometry shader features will fail.
--/
--/ This function can only return true if isAvailable() would also
--/ return true, since shaders in general have to be supported in
--/ order for geometry shaders to be supported as well.
--/
--/ Note: The first call to this function, whether by your
--/ code or SFML will result in a context switch.
--/
--/ @return True if geometry shaders are supported, false otherwise
--/
--//////////////////////////////////////////////////////////
function isGeometryAvailable return sfBool;
private
pragma Import (C, createFromFile, "sfShader_createFromFile");
pragma Import (C, createFromMemory, "sfShader_createFromMemory");
pragma Import (C, createFromStream, "sfShader_createFromStream");
pragma Import (C, destroy, "sfShader_destroy");
pragma Import (C, setFloatUniform, "sfShader_setFloatUniform");
pragma Import (C, setVec2Uniform, "sfShader_setVec2Uniform");
pragma Import (C, setVec3Uniform, "sfShader_setVec3Uniform");
pragma Import (C, setVec4Uniform, "sfShader_setVec4Uniform");
pragma Import (C, setColorUniform, "sfShader_setColorUniform");
pragma Import (C, setIntUniform, "sfShader_setIntUniform");
pragma Import (C, setIvec2Uniform, "sfShader_setIvec2Uniform");
pragma Import (C, setIvec3Uniform, "sfShader_setIvec3Uniform");
pragma Import (C, setIvec4Uniform, "sfShader_setIvec4Uniform");
pragma Import (C, setIntColorUniform, "sfShader_setIntColorUniform");
pragma Import (C, setBoolUniform, "sfShader_setBoolUniform");
pragma Import (C, setBvec2Uniform, "sfShader_setBvec2Uniform");
pragma Import (C, setBvec3Uniform, "sfShader_setBvec3Uniform");
pragma Import (C, setBvec4Uniform, "sfShader_setBvec4Uniform");
pragma Import (C, setMat3Uniform, "sfShader_setMat3Uniform");
pragma Import (C, setMat4Uniform, "sfShader_setMat4Uniform");
pragma Import (C, setTextureUniform, "sfShader_setTextureUniform");
pragma Import (C, setCurrentTextureUniform, "sfShader_setCurrentTextureUniform");
pragma Import (C, setFloatUniformArray, "sfShader_setFloatUniformArray");
pragma Import (C, setVec2UniformArray, "sfShader_setVec2UniformArray");
pragma Import (C, setVec3UniformArray, "sfShader_setVec3UniformArray");
pragma Import (C, setVec4UniformArray, "sfShader_setVec4UniformArray");
pragma Import (C, setMat3UniformArray, "sfShader_setMat3UniformArray");
pragma Import (C, setMat4UniformArray, "sfShader_setMat4UniformArray");
pragma Import (C, setFloatParameter, "sfShader_setFloatParameter");
pragma Import (C, setFloat2Parameter, "sfShader_setFloat2Parameter");
pragma Import (C, setFloat3Parameter, "sfShader_setFloat3Parameter");
pragma Import (C, setFloat4Parameter, "sfShader_setFloat4Parameter");
pragma Import (C, setVector2Parameter, "sfShader_setVector2Parameter");
pragma Import (C, setVector3Parameter, "sfShader_setVector3Parameter");
pragma Import (C, setColorParameter, "sfShader_setColorParameter");
pragma Import (C, setTransformParameter, "sfShader_setTransformParameter");
pragma Import (C, setTextureParameter, "sfShader_setTextureParameter");
pragma Import (C, setCurrentTextureParameter, "sfShader_setCurrentTextureParameter");
pragma Import (C, getNativeHandle, "sfShader_getNativeHandle");
pragma Import (C, bind, "sfShader_bind");
pragma Import (C, isAvailable, "sfShader_isAvailable");
pragma Import (C, isGeometryAvailable, "sfShader_isGeometryAvailable");
end Sf.Graphics.Shader;
|
with Interfaces; use Interfaces;
with SHA2_Generic_32;
with SHA2_Generic_64;
generic
type Element is mod <>;
type Index is range <>;
type Element_Array is array (Index range <>) of Element;
package SHA2_Generic with
Pure,
Preelaborate
is
pragma Compile_Time_Error
(Element'Modulus /= 256,
"'Element' type must be mod 2**8, i.e. represent a byte");
type State_Array_32 is array (Natural range <>) of Unsigned_32;
type State_Array_64 is array (Natural range <>) of Unsigned_64;
package SHA_224 is new SHA2_Generic_32
(Element => Element, Index => Index, Element_Array => Element_Array,
Length => 28, State_Array => State_Array_32,
Initial_State =>
(16#c105_9ed8#, 16#367c_d507#, 16#3070_dd17#, 16#f70e_5939#,
16#ffc0_0b31#, 16#6858_1511#, 16#64f9_8fa7#, 16#befa_4fa4#));
package SHA_256 is new SHA2_Generic_32
(Element => Element, Index => Index, Element_Array => Element_Array,
Length => 32, State_Array => State_Array_32,
Initial_State =>
(16#6a09_e667#, 16#bb67_ae85#, 16#3c6e_f372#, 16#a54f_f53a#,
16#510e_527f#, 16#9b05_688c#, 16#1f83_d9ab#, 16#5be0_cd19#));
package SHA_384 is new SHA2_Generic_64
(Element => Element, Index => Index, Element_Array => Element_Array,
Length => 48, State_Array => State_Array_64,
Initial_State =>
(16#cbbb_9d5d_c105_9ed8#, 16#629a_292a_367c_d507#,
16#9159_015a_3070_dd17#, 16#152f_ecd8_f70e_5939#,
16#6733_2667_ffc0_0b31#, 16#8eb4_4a87_6858_1511#,
16#db0c_2e0d_64f9_8fa7#, 16#47b5_481d_befa_4fa4#));
package SHA_512 is new SHA2_Generic_64
(Element => Element, Index => Index, Element_Array => Element_Array,
Length => 64, State_Array => State_Array_64,
Initial_State =>
(16#6a09_e667_f3bc_c908#, 16#bb67_ae85_84ca_a73b#,
16#3c6e_f372_fe94_f82b#, 16#a54f_f53a_5f1d_36f1#,
16#510e_527f_ade6_82d1#, 16#9b05_688c_2b3e_6c1f#,
16#1f83_d9ab_fb41_bd6b#, 16#5be0_cd19_137e_2179#));
package SHA_512_224 is new SHA2_Generic_64
(Element => Element, Index => Index, Element_Array => Element_Array,
Length => 28, State_Array => State_Array_64,
Initial_State =>
(16#8C3D_37C8_1954_4DA2#, 16#73E1_9966_89DC_D4D6#,
16#1DFA_B7AE_32FF_9C82#, 16#679D_D514_582F_9FCF#,
16#0F6D_2B69_7BD4_4DA8#, 16#77E3_6F73_04C4_8942#,
16#3F9D_85A8_6A1D_36C8#, 16#1112_E6AD_91D6_92A1#));
package SHA_512_256 is new SHA2_Generic_64
(Element => Element, Index => Index, Element_Array => Element_Array,
Length => 32, State_Array => State_Array_64,
Initial_State =>
(16#2231_2194_FC2B_F72C#, 16#9F55_5FA3_C84C_64C2#,
16#2393_B86B_6F53_B151#, 16#9638_7719_5940_EABD#,
16#9628_3EE2_A88E_FFE3#, 16#BE5E_1E25_5386_3992#,
16#2B01_99FC_2C85_B8AA#, 16#0EB7_2DDC_81C5_2CA2#));
end SHA2_Generic;
|
-----------------------------------------------------------------------
-- awa-tags-beans -- Beans for the tags module
-- Copyright (C) 2013 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.Unchecked_Deallocation;
with ADO.Queries;
with ADO.Statements;
with ADO.Sessions.Entities;
package body AWA.Tags.Beans is
-- ------------------------------
-- Compare two tags on their count and name.
-- ------------------------------
function "<" (Left, Right : in AWA.Tags.Models.Tag_Info) return Boolean is
use type Ada.Strings.Unbounded.Unbounded_String;
begin
if Left.Count = Right.Count then
return Left.Tag < Right.Tag;
else
return Left.Count > Right.Count;
end if;
end "<";
-- ------------------------------
-- Set the value identified by the name.
-- If the name cannot be found, the method should raise the No_Value
-- exception.
-- ------------------------------
overriding
procedure Set_Value (From : in out Tag_List_Bean;
Name : in String;
Value : in Util.Beans.Objects.Object) is
begin
if Name = "entity_type" then
From.Entity_Type := Util.Beans.Objects.To_Unbounded_String (Value);
elsif Name = "permission" then
From.Permission := Util.Beans.Objects.To_Unbounded_String (Value);
end if;
end Set_Value;
-- ------------------------------
-- Set the entity type (database table) onto which the tags are associated.
-- ------------------------------
procedure Set_Entity_Type (Into : in out Tag_List_Bean;
Table : in ADO.Schemas.Class_Mapping_Access) is
begin
Into.Entity_Type := Ada.Strings.Unbounded.To_Unbounded_String (Table.Table.all);
end Set_Entity_Type;
-- ------------------------------
-- Set the permission to check before removing or adding a tag on the entity.
-- ------------------------------
procedure Set_Permission (Into : in out Tag_List_Bean;
Permission : in String) is
begin
Into.Permission := Ada.Strings.Unbounded.To_Unbounded_String (Permission);
end Set_Permission;
-- ------------------------------
-- Load the tags associated with the given database identifier.
-- ------------------------------
procedure Load_Tags (Into : in out Tag_List_Bean;
Session : in ADO.Sessions.Session;
For_Entity_Id : in ADO.Identifier) is
use ADO.Sessions.Entities;
Entity_Type : constant String := Ada.Strings.Unbounded.To_String (Into.Entity_Type);
Kind : constant ADO.Entity_Type := Find_Entity_Type (Session, Entity_Type);
Query : ADO.Queries.Context;
begin
Query.Set_Query (AWA.Tags.Models.Query_Tag_List);
Query.Bind_Param ("entity_type", Kind);
Query.Bind_Param ("entity_id", For_Entity_Id);
declare
Stmt : ADO.Statements.Query_Statement := Session.Create_Statement (Query);
begin
Stmt.Execute;
while Stmt.Has_Elements loop
Into.List.Append (Util.Beans.Objects.To_Object (Stmt.Get_String (0)));
Stmt.Next;
end loop;
end;
end Load_Tags;
-- ------------------------------
-- Set the list of tags to add.
-- ------------------------------
procedure Set_Added (Into : in out Tag_List_Bean;
Tags : in Util.Strings.Vectors.Vector) is
begin
Into.Added := Tags;
end Set_Added;
-- ------------------------------
-- Set the list of tags to remove.
-- ------------------------------
procedure Set_Deleted (Into : in out Tag_List_Bean;
Tags : in Util.Strings.Vectors.Vector) is
begin
Into.Deleted := Tags;
end Set_Deleted;
-- ------------------------------
-- Update the tags associated with the tag entity represented by <tt>For_Entity_Id</tt>.
-- The list of tags defined by <tt>Set_Deleted</tt> are removed first and the list of
-- tags defined by <tt>Set_Added</tt> are associated with the database entity.
-- ------------------------------
procedure Update_Tags (From : in Tag_List_Bean;
For_Entity_Id : in ADO.Identifier) is
use type AWA.Tags.Modules.Tag_Module_Access;
Entity_Type : constant String := Ada.Strings.Unbounded.To_String (From.Entity_Type);
Service : AWA.Tags.Modules.Tag_Module_Access := From.Module;
begin
if Service = null then
Service := AWA.Tags.Modules.Get_Tag_Module;
end if;
Service.Update_Tags (Id => For_Entity_Id,
Entity_Type => Entity_Type,
Permission => Ada.Strings.Unbounded.To_String (From.Permission),
Added => From.Added,
Deleted => From.Deleted);
end Update_Tags;
-- ------------------------------
-- Create the tag list bean instance.
-- ------------------------------
function Create_Tag_List_Bean (Module : in AWA.Tags.Modules.Tag_Module_Access)
return Util.Beans.Basic.Readonly_Bean_Access is
Result : constant Tag_List_Bean_Access := new Tag_List_Bean;
begin
Result.Module := Module;
return Result.all'Access;
end Create_Tag_List_Bean;
-- ------------------------------
-- Search the tags that match the search string.
-- ------------------------------
procedure Search_Tags (Into : in out Tag_Search_Bean;
Session : in ADO.Sessions.Session;
Search : in String) is
use ADO.Sessions.Entities;
Entity_Type : constant String := Ada.Strings.Unbounded.To_String (Into.Entity_Type);
Kind : constant ADO.Entity_Type := Find_Entity_Type (Session, Entity_Type);
Query : ADO.Queries.Context;
begin
Query.Set_Query (AWA.Tags.Models.Query_Tag_Search);
Query.Bind_Param ("entity_type", Kind);
Query.Bind_Param ("search", Search & "%");
declare
Stmt : ADO.Statements.Query_Statement := Session.Create_Statement (Query);
begin
Stmt.Execute;
while Stmt.Has_Elements loop
Into.List.Append (Util.Beans.Objects.To_Object (Stmt.Get_String (0)));
Stmt.Next;
end loop;
end;
end Search_Tags;
-- ------------------------------
-- Set the value identified by the name.
-- If the name cannot be found, the method should raise the No_Value
-- exception.
-- ------------------------------
overriding
procedure Set_Value (From : in out Tag_Search_Bean;
Name : in String;
Value : in Util.Beans.Objects.Object) is
begin
if Name = "entity_type" then
From.Entity_Type := Util.Beans.Objects.To_Unbounded_String (Value);
elsif Name = "search" then
declare
Session : constant ADO.Sessions.Session := From.Module.Get_Session;
begin
From.Search_Tags (Session, Util.Beans.Objects.To_String (Value));
end;
end if;
end Set_Value;
-- ------------------------------
-- Set the entity type (database table) onto which the tags are associated.
-- ------------------------------
procedure Set_Entity_Type (Into : in out Tag_Search_Bean;
Table : in ADO.Schemas.Class_Mapping_Access) is
begin
Into.Entity_Type := Ada.Strings.Unbounded.To_Unbounded_String (Table.Table.all);
end Set_Entity_Type;
-- ------------------------------
-- Create the tag search bean instance.
-- ------------------------------
function Create_Tag_Search_Bean (Module : in AWA.Tags.Modules.Tag_Module_Access)
return Util.Beans.Basic.Readonly_Bean_Access is
Result : constant Tag_Search_Bean_Access := new Tag_Search_Bean;
begin
Result.Module := Module;
return Result.all'Access;
end Create_Tag_Search_Bean;
-- ------------------------------
-- Set the value identified by the name.
-- If the name cannot be found, the method should raise the No_Value
-- exception.
-- ------------------------------
overriding
procedure Set_Value (From : in out Tag_Info_List_Bean;
Name : in String;
Value : in Util.Beans.Objects.Object) is
begin
if Name = "entity_type" then
From.Entity_Type := Util.Beans.Objects.To_Unbounded_String (Value);
declare
Session : ADO.Sessions.Session := From.Module.Get_Session;
begin
From.Load_Tags (Session);
end;
end if;
end Set_Value;
-- ------------------------------
-- Load the list of tags.
-- ------------------------------
procedure Load_Tags (Into : in out Tag_Info_List_Bean;
Session : in out ADO.Sessions.Session) is
use ADO.Sessions.Entities;
Entity_Type : constant String := Ada.Strings.Unbounded.To_String (Into.Entity_Type);
Kind : constant ADO.Entity_Type := Find_Entity_Type (Session, Entity_Type);
Query : ADO.Queries.Context;
begin
Query.Set_Query (AWA.Tags.Models.Query_Tag_List_All);
Query.Bind_Param ("entity_type", Kind);
AWA.Tags.Models.List (Into, Session, Query);
end Load_Tags;
-- ------------------------------
-- Create the tag info list bean instance.
-- ------------------------------
function Create_Tag_Info_List_Bean (Module : in AWA.Tags.Modules.Tag_Module_Access)
return Util.Beans.Basic.Readonly_Bean_Access is
Result : constant Tag_Info_List_Bean_Access := new Tag_Info_List_Bean;
begin
Result.Module := Module;
return Result.all'Access;
end Create_Tag_Info_List_Bean;
-- ------------------------------
-- Get the list of tags associated with the given entity.
-- Returns null if the entity does not have any tag.
-- ------------------------------
function Get_Tags (From : in Entity_Tag_Map;
For_Entity : in ADO.Identifier)
return Util.Beans.Lists.Strings.List_Bean_Access is
Pos : constant Entity_Tag_Maps.Cursor := From.Tags.Find (For_Entity);
begin
if Entity_Tag_Maps.Has_Element (Pos) then
return Entity_Tag_Maps.Element (Pos);
else
return null;
end if;
end Get_Tags;
-- ------------------------------
-- Get the list of tags associated with the given entity.
-- Returns a null object if the entity does not have any tag.
-- ------------------------------
function Get_Tags (From : in Entity_Tag_Map;
For_Entity : in ADO.Identifier)
return Util.Beans.Objects.Object is
Pos : constant Entity_Tag_Maps.Cursor := From.Tags.Find (For_Entity);
begin
if Entity_Tag_Maps.Has_Element (Pos) then
return Util.Beans.Objects.To_Object (Value => Entity_Tag_Maps.Element (Pos).all'Access,
Storage => Util.Beans.Objects.STATIC);
else
return Util.Beans.Objects.Null_Object;
end if;
end Get_Tags;
-- ------------------------------
-- Load the list of tags associated with a list of entities.
-- ------------------------------
procedure Load_Tags (Into : in out Entity_Tag_Map;
Session : in out ADO.Sessions.Session'Class;
Entity_Type : in String;
List : in ADO.Utils.Identifier_Vector) is
Query : ADO.Queries.Context;
Kind : ADO.Entity_Type;
begin
Into.Clear;
if List.Is_Empty then
return;
end if;
Kind := ADO.Sessions.Entities.Find_Entity_Type (Session, Entity_Type);
Query.Set_Query (AWA.Tags.Models.Query_Tag_List_For_Entities);
Query.Bind_Param ("entity_id_list", List);
Query.Bind_Param ("entity_type", Kind);
declare
Stmt : ADO.Statements.Query_Statement := Session.Create_Statement (Query);
Id : ADO.Identifier;
List : Util.Beans.Lists.Strings.List_Bean_Access;
Pos : Entity_Tag_Maps.Cursor;
begin
Stmt.Execute;
while Stmt.Has_Elements loop
Id := Stmt.Get_Identifier (0);
Pos := Into.Tags.Find (Id);
if not Entity_Tag_Maps.Has_Element (Pos) then
List := new Util.Beans.Lists.Strings.List_Bean;
Into.Tags.Insert (Id, List);
else
List := Entity_Tag_Maps.Element (Pos);
end if;
List.List.Append (Stmt.Get_String (1));
Stmt.Next;
end loop;
end;
end Load_Tags;
-- ------------------------------
-- Release the list of tags.
-- ------------------------------
procedure Clear (List : in out Entity_Tag_Map) is
procedure Free is
new Ada.Unchecked_Deallocation (Object => Util.Beans.Lists.Strings.List_Bean'Class,
Name => Util.Beans.Lists.Strings.List_Bean_Access);
Pos : Entity_Tag_Maps.Cursor;
Tags : Util.Beans.Lists.Strings.List_Bean_Access;
begin
loop
Pos := List.Tags.First;
exit when not Entity_Tag_Maps.Has_Element (Pos);
Tags := Entity_Tag_Maps.Element (Pos);
List.Tags.Delete (Pos);
Free (Tags);
end loop;
end Clear;
-- ------------------------------
-- Release the list of tags.
-- ------------------------------
overriding
procedure Finalize (List : in out Entity_Tag_Map) is
begin
List.Clear;
end Finalize;
end AWA.Tags.Beans;
|
-- Copyright (c) 2020-2021 Bartek thindil Jasicki <thindil@laeran.pl>
--
-- This program is free software: you can redistribute it and/or modify
-- it under the terms of the GNU General Public License as published by
-- the Free Software Foundation, either version 3 of the License, or
-- (at your option) any later version.
--
-- This program is distributed in the hope that it will be useful,
-- but WITHOUT ANY WARRANTY; without even the implied warranty of
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-- GNU General Public License for more details.
--
-- You should have received a copy of the GNU General Public License
-- along with this program. If not, see <http://www.gnu.org/licenses/>.
with Ada.Characters.Latin_1; use Ada.Characters.Latin_1;
with Ada.Containers.Generic_Array_Sort;
with Ada.Exceptions; use Ada.Exceptions;
with Ada.Strings; use Ada.Strings;
with Ada.Strings.Fixed; use Ada.Strings.Fixed;
with Interfaces.C; use Interfaces.C;
with Interfaces.C.Strings; use Interfaces.C.Strings;
with CArgv;
with Tcl; use Tcl;
with Tcl.Ada; use Tcl.Ada;
with Tcl.Tk.Ada; use Tcl.Tk.Ada;
with Tcl.Tk.Ada.Font; use Tcl.Tk.Ada.Font;
with Tcl.Tk.Ada.Grid;
with Tcl.Tk.Ada.Pack;
with Tcl.Tk.Ada.Widgets; use Tcl.Tk.Ada.Widgets;
with Tcl.Tk.Ada.Widgets.Canvas; use Tcl.Tk.Ada.Widgets.Canvas;
with Tcl.Tk.Ada.Widgets.Menu; use Tcl.Tk.Ada.Widgets.Menu;
with Tcl.Tk.Ada.Widgets.Text; use Tcl.Tk.Ada.Widgets.Text;
with Tcl.Tk.Ada.Widgets.Toplevel; use Tcl.Tk.Ada.Widgets.Toplevel;
with Tcl.Tk.Ada.Widgets.Toplevel.MainWindow;
use Tcl.Tk.Ada.Widgets.Toplevel.MainWindow;
with Tcl.Tk.Ada.Widgets.TtkButton; use Tcl.Tk.Ada.Widgets.TtkButton;
with Tcl.Tk.Ada.Widgets.TtkButton.TtkCheckButton;
use Tcl.Tk.Ada.Widgets.TtkButton.TtkCheckButton;
with Tcl.Tk.Ada.Widgets.TtkFrame; use Tcl.Tk.Ada.Widgets.TtkFrame;
with Tcl.Tk.Ada.Widgets.TtkLabel; use Tcl.Tk.Ada.Widgets.TtkLabel;
with Tcl.Tk.Ada.Widgets.TtkProgressBar; use Tcl.Tk.Ada.Widgets.TtkProgressBar;
with Tcl.Tk.Ada.Widgets.TtkScrollbar; use Tcl.Tk.Ada.Widgets.TtkScrollbar;
with Tcl.Tk.Ada.Widgets.TtkWidget; use Tcl.Tk.Ada.Widgets.TtkWidget;
with Tcl.Tk.Ada.Winfo; use Tcl.Tk.Ada.Winfo;
with Tcl.Tklib.Ada.Autoscroll; use Tcl.Tklib.Ada.Autoscroll;
with Tcl.Tklib.Ada.Tooltip; use Tcl.Tklib.Ada.Tooltip;
with Config; use Config;
with CoreUI; use CoreUI;
with Crafts; use Crafts;
with Dialogs; use Dialogs;
with Factions; use Factions;
with Maps; use Maps;
with Maps.UI; use Maps.UI;
with Messages; use Messages;
with Missions; use Missions;
with ShipModules; use ShipModules;
with Ships.Cargo; use Ships.Cargo;
with Ships.Crew; use Ships.Crew;
with Ships.UI.Crew; use Ships.UI.Crew;
with Ships.Upgrade; use Ships.Upgrade;
with Table; use Table;
with Utils.UI; use Utils.UI;
package body Ships.UI.Modules is
-- ****iv* SUModules/SUModules.ModulesTable
-- FUNCTION
-- Table with info about the installed modules on the player ship
-- SOURCE
ModulesTable: Table_Widget (2);
-- ****
-- ****iv* SUModules/SUModules.Modules_Indexes
-- FUNCTION
-- Indexes of the player ship modules
-- SOURCE
Modules_Indexes: Positive_Container.Vector;
-- ****
-- ****if* SUModules/SUModules.Show_Module_Menu_Command
-- FUNCTION
-- Show the menu with available the selected module options
-- PARAMETERS
-- ClientData - Custom data send to the command. Unused
-- Interp - Tcl interpreter in which command was executed.
-- Argc - Number of arguments passed to the command. Unused
-- Argv - Values of arguments passed to the command.
-- RESULT
-- This function always return TCL_OK
-- COMMANDS
-- ShowModuleMenu moduleindex
-- ModuleIndex is the index of the module's menu to show
-- SOURCE
function Show_Module_Menu_Command
(ClientData: Integer; Interp: Tcl.Tcl_Interp; Argc: Interfaces.C.int;
Argv: CArgv.Chars_Ptr_Ptr) return Interfaces.C.int with
Convention => C;
-- ****
function Show_Module_Menu_Command
(ClientData: Integer; Interp: Tcl.Tcl_Interp; Argc: Interfaces.C.int;
Argv: CArgv.Chars_Ptr_Ptr) return Interfaces.C.int is
pragma Unreferenced(ClientData, Argc);
MaxValue: Positive;
IsPassenger: Boolean := False;
ModuleIndex: constant Positive := Positive'Value(CArgv.Arg(Argv, 1));
ModuleMenu: Tk_Menu := Get_Widget(".modulemenu", Interp);
begin
if Winfo_Get(ModuleMenu, "exists") = "0" then
ModuleMenu := Create(".modulemenu", "-tearoff false");
end if;
Delete(ModuleMenu, "0", "end");
Menu.Add
(ModuleMenu, "command",
"-label {Rename module} -command {GetString {Enter a new name for the " &
To_String(Player_Ship.Modules(ModuleIndex).Name) & ":} modulename" &
CArgv.Arg(Argv, 1) & " {Renaming the module}}");
if Player_Ship.Repair_Module /= ModuleIndex then
Menu.Add
(ModuleMenu, "command",
"-label {Repair selected module as first when damaged} -command {SetRepair assign " &
CArgv.Arg(Argv, 1) & "}");
end if;
MaxValue :=
Natural
(Float
(Modules_List(Player_Ship.Modules(ModuleIndex).Proto_Index)
.Durability) *
1.5);
if Player_Ship.Modules(ModuleIndex).Upgrade_Action = DURABILITY and
Player_Ship.Upgrade_Module = ModuleIndex then
MaxValue := 1;
end if;
if Player_Ship.Modules(ModuleIndex).Max_Durability < MaxValue then
Menu.Add
(ModuleMenu, "command",
"-label {Start upgrading module durability} -command {SetUpgrade 1 " &
CArgv.Arg(Argv, 1) & "}");
end if;
case Player_Ship.Modules(ModuleIndex).M_Type is
when ENGINE =>
MaxValue :=
Natural
(Float
(Modules_List(Player_Ship.Modules(ModuleIndex).Proto_Index)
.MaxValue) *
1.5);
if Player_Ship.Modules(ModuleIndex).Upgrade_Action = MAX_VALUE and
Player_Ship.Upgrade_Module = ModuleIndex then
MaxValue := 1;
end if;
if Player_Ship.Modules(ModuleIndex).Power < MaxValue then
Menu.Add
(ModuleMenu, "command",
"-label {Start upgrading engine power} -command {SetUpgrade 2 " &
CArgv.Arg(Argv, 1) & "}");
end if;
MaxValue :=
Natural
(Float
(Modules_List(Player_Ship.Modules(ModuleIndex).Proto_Index)
.Value) /
2.0);
if Player_Ship.Modules(ModuleIndex).Upgrade_Action = VALUE and
Player_Ship.Upgrade_Module = ModuleIndex then
MaxValue := Player_Ship.Modules(ModuleIndex).Fuel_Usage + 1;
end if;
if Player_Ship.Modules(ModuleIndex).Fuel_Usage > MaxValue then
Menu.Add
(ModuleMenu, "command",
"-label {Start working on reduce fuel usage of this engine} -command {SetUpgrade 3 " &
CArgv.Arg(Argv, 1) & "}");
end if;
if not Player_Ship.Modules(ModuleIndex).Disabled then
Menu.Add
(ModuleMenu, "command",
"-label {Turn off engine so it stop using fuel} -command {DisableEngine " &
CArgv.Arg(Argv, 1) & "}");
else
Menu.Add
(ModuleMenu, "command",
"-label {Turn on engine so ship will be fly faster} -command {DisableEngine " &
CArgv.Arg(Argv, 1) & "}");
end if;
when CABIN =>
MaxValue :=
Natural
(Float
(Modules_List(Player_Ship.Modules(ModuleIndex).Proto_Index)
.MaxValue) *
1.5);
if Player_Ship.Modules(ModuleIndex).Upgrade_Action = MAX_VALUE and
Player_Ship.Upgrade_Module = ModuleIndex then
MaxValue := 1;
end if;
if Player_Ship.Modules(ModuleIndex).Quality < MaxValue then
Menu.Add
(ModuleMenu, "command",
"-label {Start upgrading cabin quality} -command {SetUpgrade 2 " &
CArgv.Arg(Argv, 1) & "}");
end if;
Missions_Loop :
for Mission of AcceptedMissions loop
if Mission.MType = Passenger then
for Owner of Player_Ship.Modules(ModuleIndex).Owner loop
if Mission.Data = Owner then
IsPassenger := True;
exit Missions_Loop;
end if;
end loop;
end if;
end loop Missions_Loop;
if not IsPassenger then
Menu.Add
(ModuleMenu, "command",
"-label {Assign a crew member as owner of cabin...} -command {ShowAssignCrew " &
CArgv.Arg(Argv, 1) & "}");
end if;
when GUN | HARPOON_GUN =>
declare
CurrentValue: constant Positive :=
(if Player_Ship.Modules(ModuleIndex).M_Type = GUN then
Player_Ship.Modules(ModuleIndex).Damage
else Player_Ship.Modules(ModuleIndex).Duration);
begin
MaxValue :=
Natural
(Float
(Modules_List
(Player_Ship.Modules(ModuleIndex).Proto_Index)
.MaxValue) *
1.5);
if Player_Ship.Modules(ModuleIndex).Upgrade_Action =
MAX_VALUE and
Player_Ship.Upgrade_Module = ModuleIndex then
MaxValue := 1;
end if;
if CurrentValue < MaxValue then
if Player_Ship.Modules(ModuleIndex).M_Type = GUN then
Menu.Add
(ModuleMenu, "command",
"-label {Start upgrading damage of gun} -command {SetUpgrade 2 " &
CArgv.Arg(Argv, 1) & "}");
else
Menu.Add
(ModuleMenu, "command",
"-label {Start upgrading strength of gun} -command {SetUpgrade 2 " &
CArgv.Arg(Argv, 1) & "}");
end if;
end if;
end;
Menu.Add
(ModuleMenu, "command",
"-label {Assign a crew member as gunner...} -command {ShowAssignCrew " &
CArgv.Arg(Argv, 1) & "}");
declare
AmmoIndex: constant Natural :=
(if Player_Ship.Modules(ModuleIndex).M_Type = GUN then
Player_Ship.Modules(ModuleIndex).Ammo_Index
else Player_Ship.Modules(ModuleIndex).Harpoon_Index);
AmmoMenu: Tk_Menu :=
Get_Widget(Widget_Image(ModuleMenu) & ".ammomenu");
NotEmpty: Boolean := False;
begin
if Winfo_Get(AmmoMenu, "exists") = "0" then
AmmoMenu :=
Create
(Widget_Image(ModuleMenu) & ".ammomenu",
"-tearoff false");
end if;
Delete(AmmoMenu, "0", "end");
Find_Ammo_Loop :
for I in
Player_Ship.Cargo.First_Index ..
Player_Ship.Cargo.Last_Index loop
if Items_List(Player_Ship.Cargo(I).ProtoIndex).IType =
Items_Types
(Modules_List
(Player_Ship.Modules(ModuleIndex).Proto_Index)
.Value) and
I /= AmmoIndex then
Menu.Add
(AmmoMenu, "command",
"-label {" &
To_String
(Items_List(Player_Ship.Cargo(I).ProtoIndex).Name) &
"} -command {AssignModule ammo " & CArgv.Arg(Argv, 1) &
Positive'Image(I) & "}");
NotEmpty := True;
end if;
end loop Find_Ammo_Loop;
if NotEmpty then
Menu.Add
(ModuleMenu, "cascade",
"-label {Assign an ammo to gun} -menu " &
Widget_Image(AmmoMenu));
end if;
end;
when BATTERING_RAM =>
MaxValue :=
Natural
(Float
(Modules_List(Player_Ship.Modules(ModuleIndex).Proto_Index)
.MaxValue) *
1.5);
if Player_Ship.Modules(ModuleIndex).Upgrade_Action = MAX_VALUE and
Player_Ship.Upgrade_Module = ModuleIndex then
MaxValue := 1;
end if;
if Player_Ship.Modules(ModuleIndex).Damage2 < MaxValue then
Menu.Add
(ModuleMenu, "command",
"-label {Start upgrading damage of battering ram} -command {SetUpgrade 2 " &
CArgv.Arg(Argv, 1) & "}");
end if;
when HULL =>
MaxValue :=
Natural
(Float
(Modules_List(Player_Ship.Modules(ModuleIndex).Proto_Index)
.MaxValue) *
1.5);
if Player_Ship.Modules(ModuleIndex).Upgrade_Action = MAX_VALUE and
Player_Ship.Upgrade_Module = ModuleIndex then
MaxValue := 1;
end if;
if Player_Ship.Modules(ModuleIndex).Max_Modules < MaxValue then
Menu.Add
(ModuleMenu, "command",
"-label {Start enlarging hull so it can have more modules installed} -command {SetUpgrade 2 " &
CArgv.Arg(Argv, 1) & "}");
end if;
when WORKSHOP =>
if Player_Ship.Modules(ModuleIndex).Crafting_Index /=
Null_Unbounded_String then
Menu.Add
(ModuleMenu, "command",
"-label {Assign selected crew member as worker...} -command {ShowAssignCrew " &
CArgv.Arg(Argv, 1) & "}");
Menu.Add
(ModuleMenu, "command",
"-label {Cancel current crafting order} -command {CancelOrder " &
CArgv.Arg(Argv, 1) & "}");
end if;
when MEDICAL_ROOM =>
Find_Healing_Tool_Loop :
for Member of Player_Ship.Crew loop
if Member.Health < 100 and
FindItem
(Inventory => Player_Ship.Cargo,
ItemType =>
Factions_List(Player_Ship.Crew(1).Faction)
.HealingTools) >
0 then
Menu.Add
(ModuleMenu, "command",
"-label {Assign selected crew member as medic...} -command {ShowAssignCrew " &
CArgv.Arg(Argv, 1) & "}");
exit Find_Healing_Tool_Loop;
end if;
end loop Find_Healing_Tool_Loop;
when TRAINING_ROOM =>
if Player_Ship.Modules(ModuleIndex).Trained_Skill > 0 then
Menu.Add
(ModuleMenu, "command",
"-label {Assign selected crew member as worker...} -command {ShowAssignCrew " &
CArgv.Arg(Argv, 1) & "}");
end if;
Menu.Add
(ModuleMenu, "command",
"-label {Assign a skill which will be trained in the training room...} -command {ShowAssignSkill " &
CArgv.Arg(Argv, 1) & "}");
when others =>
null;
end case;
Menu.Add
(ModuleMenu, "command",
"-label {Show more info about the module} -command {ShowModuleInfo " &
CArgv.Arg(Argv, 1) & "}");
Tk_Popup
(ModuleMenu, Winfo_Get(Get_Main_Window(Interp), "pointerx"),
Winfo_Get(Get_Main_Window(Interp), "pointery"));
return TCL_OK;
end Show_Module_Menu_Command;
-- ****o* SUModules/SUModules.Show_Module_Info_Command
-- FUNCTION
-- Show information about the selected module and set option for it
-- PARAMETERS
-- ClientData - Custom data send to the command. Unused
-- Interp - Tcl interpreter in which command was executed. Unused
-- Argc - Number of arguments passed to the command. Unused
-- Argv - Values of arguments passed to the command.
-- RESULT
-- This function always return TCL_OK
-- COMMANDS
-- ShowModuleInfo moduleindex
-- ModuleIndex is the index of the module to show
-- SOURCE
function Show_Module_Info_Command
(ClientData: Integer; Interp: Tcl.Tcl_Interp; Argc: Interfaces.C.int;
Argv: CArgv.Chars_Ptr_Ptr) return Interfaces.C.int with
Convention => C;
-- ****
function Show_Module_Info_Command
(ClientData: Integer; Interp: Tcl.Tcl_Interp; Argc: Interfaces.C.int;
Argv: CArgv.Chars_Ptr_Ptr) return Interfaces.C.int is
pragma Unreferenced(ClientData, Interp, Argc);
use Tiny_String;
ModuleIndex: constant Positive := Positive'Value(CArgv.Arg(Argv, 1));
Module: constant Module_Data := Player_Ship.Modules(ModuleIndex);
MaxValue: Positive;
HaveAmmo: Boolean;
Mamount, MaxUpgrade: Natural := 0;
DamagePercent, UpgradePercent: Float;
ProgressBar: Ttk_ProgressBar;
Label: Ttk_Label;
ModuleInfo, ProgressBarStyle: Unbounded_String;
ModuleDialog: constant Ttk_Frame :=
Create_Dialog
(Name => ".moduledialog",
Title => To_String(Player_Ship.Modules(ModuleIndex).Name),
Columns => 2);
YScroll: constant Ttk_Scrollbar :=
Create
(ModuleDialog & ".yscroll",
"-orient vertical -command [list .moduledialog.canvas yview]");
ModuleCanvas: constant Tk_Canvas :=
Create
(ModuleDialog & ".canvas",
"-yscrollcommand [list " & YScroll & " set]");
ModuleFrame: constant Ttk_Frame := Create(ModuleCanvas & ".frame");
ModuleText: constant Tk_Text :=
Create(ModuleFrame & ".info", "-wrap char -height 15 -width 40");
Height: Positive := 10;
procedure AddOwnersInfo(OwnersName: String) is
HaveOwner: Boolean := False;
begin
Insert(ModuleText, "end", "{" & LF & OwnersName & "}");
if Module.Owner.Length > 1 then
Insert(ModuleText, "end", "s");
end if;
Insert
(ModuleText, "end",
"{ (max" & Count_Type'Image(Module.Owner.Length) & "): }");
Add_Owners_Info_Loop :
for I in Module.Owner.First_Index .. Module.Owner.Last_Index loop
if Module.Owner(I) > 0 then
if HaveOwner then
Insert(ModuleText, "end", "{, }");
end if;
HaveOwner := True;
Insert
(ModuleText, "end",
To_String(Player_Ship.Crew(Module.Owner(I)).Name));
end if;
end loop Add_Owners_Info_Loop;
if not HaveOwner then
Insert(ModuleText, "end", "{none}");
end if;
end AddOwnersInfo;
begin
Tcl.Tk.Ada.Grid.Grid(ModuleCanvas, "-sticky nwes -padx 5 -pady 5");
Tcl.Tk.Ada.Grid.Grid
(YScroll, "-sticky ns -column 1 -row 1 -padx {0 5} -pady 5");
Tcl.Tk.Ada.Grid.Grid_Propagate(ModuleDialog, "off");
Tcl.Tk.Ada.Grid.Column_Configure
(ModuleDialog, ModuleCanvas, "-weight 1");
Tcl.Tk.Ada.Grid.Row_Configure(ModuleDialog, ModuleCanvas, "-weight 1");
Autoscroll(YScroll);
if Module.Durability < Module.Max_Durability then
Label := Create(ModuleFrame & ".damagelbl");
DamagePercent :=
(Float(Module.Durability) / Float(Module.Max_Durability));
if DamagePercent < 1.0 and DamagePercent > 0.79 then
configure(Label, "-text {Status: Slightly damaged}");
elsif DamagePercent < 0.8 and DamagePercent > 0.49 then
configure(Label, "-text {Status: Damaged}");
elsif DamagePercent < 0.5 and DamagePercent > 0.19 then
configure(Label, "-text {Status: Heavily damaged}");
elsif DamagePercent < 0.2 and DamagePercent > 0.0 then
configure(Label, "-text {Status: Almost destroyed}");
elsif DamagePercent = 0.0 then
configure(Label, "-text {Status: Destroyed}");
end if;
Tcl.Tk.Ada.Grid.Grid(Label, "-sticky w");
Height := Height + Positive'Value(Winfo_Get(Label, "reqheight"));
MaxValue :=
Positive(Float(Modules_List(Module.Proto_Index).Durability) * 1.5);
if Module.Max_Durability = MaxValue then
configure
(Label, "-text {" & cget(Label, "-text") & " (max upgrade)}");
end if;
end if;
Tag_Configure(ModuleText, "red", "-foreground red");
Insert
(ModuleText, "end",
"{Weight: " & Integer'Image(Module.Weight) & " kg" & LF &
"Repair/Upgrade material: }");
Find_Repair_Material_Loop :
for Item of Items_List loop
if Item.IType = Modules_List(Module.Proto_Index).RepairMaterial then
if Mamount > 0 then
Insert(ModuleText, "end", "{ or }");
end if;
Insert
(ModuleText, "end",
"{" & To_String(Item.Name) & "}" &
(if
FindItem
(Inventory => Player_Ship.Cargo, ItemType => Item.IType) =
0
then " [list red]"
else ""));
Mamount := Mamount + 1;
end if;
end loop Find_Repair_Material_Loop;
Insert
(ModuleText, "end",
"{" & LF & "Repair/Upgrade skill: " &
To_String
(SkillsData_Container.Element
(Skills_List, Modules_List(Module.Proto_Index).RepairSkill)
.Name) &
"/" &
To_String
(AttributesData_Container.Element
(Attributes_List,
SkillsData_Container.Element
(Skills_List, Modules_List(Module.Proto_Index).RepairSkill)
.Attribute)
.Name) &
"}");
case Module.M_Type is
when ENGINE =>
Insert
(ModuleText, "end",
"{" & LF & "Max power:" & Integer'Image(Module.Power) & "}");
MaxValue :=
Positive(Float(Modules_List(Module.Proto_Index).MaxValue) * 1.5);
if Module.Power = MaxValue then
Insert(ModuleText, "end", "{ (max upgrade)}");
end if;
if Module.Disabled then
Insert(ModuleText, "end", "{ (disabled)}");
end if;
Insert
(ModuleText, "end",
"{" & LF & "Fuel usage:" & Integer'Image(Module.Fuel_Usage) &
"}");
MaxValue :=
Positive(Float(Modules_List(Module.Proto_Index).Value) / 2.0);
if Module.Fuel_Usage = MaxValue then
Insert(ModuleText, "end", "{ (max upgrade)}");
end if;
when CARGO_ROOM =>
Insert
(ModuleText, "end",
"{" & LF & "Max cargo:" &
Integer'Image(Modules_List(Module.Proto_Index).MaxValue) &
" kg}");
when HULL =>
Label :=
Create
(ModuleFrame & ".modules",
"-text {Modules installed:" &
Integer'Image(Module.Installed_Modules) & " /" &
Integer'Image(Module.Max_Modules) & "}");
MaxValue :=
Positive(Float(Modules_List(Module.Proto_Index).MaxValue) * 1.5);
if Module.Max_Modules = MaxValue then
configure
(Label, "-text {" & cget(Label, "-text") & " (max upgrade)}");
end if;
Tcl.Tk.Ada.Grid.Grid(Label, "-sticky w");
Height := Height + Positive'Value(Winfo_Get(Label, "reqheight"));
when CABIN =>
AddOwnersInfo("Owner");
if Module.Cleanliness /= Module.Quality then
Label := Create(ModuleFrame & ".cleanlbl");
DamagePercent :=
1.0 - (Float(Module.Cleanliness) / Float(Module.Quality));
if DamagePercent > 0.0 and DamagePercent < 0.2 then
configure(Label, "-text {Bit dusty}");
ProgressBarStyle :=
To_Unbounded_String
(" -style green.Horizontal.TProgressbar");
elsif DamagePercent > 0.19 and DamagePercent < 0.5 then
configure(Label, "-text {Dusty}");
ProgressBarStyle :=
To_Unbounded_String
(" -style yellow.Horizontal.TProgressbar");
elsif DamagePercent > 0.49 and DamagePercent < 0.8 then
configure(Label, "-text {Dirty}");
ProgressBarStyle :=
To_Unbounded_String
(" -style yellow.Horizontal.TProgressbar");
elsif DamagePercent > 0.79 and DamagePercent < 1.0 then
configure(Label, "-text {Very dirty}");
ProgressBarStyle := Null_Unbounded_String;
else
configure(Label, "-text {Ruined}");
ProgressBarStyle := Null_Unbounded_String;
end if;
ProgressBar :=
Create
(ModuleFrame & ".clean",
"-orient horizontal -maximum 1.0 -value {" &
Float'Image(DamagePercent) & "}" &
To_String(ProgressBarStyle));
Add(ProgressBar, "Cleanliness of the selected cabin");
Tcl.Tk.Ada.Grid.Grid(Label, "-row 1 -sticky w");
Tcl.Tk.Ada.Grid.Grid
(ProgressBar, "-row 1 -column 1 -sticky we");
Height :=
Height + Positive'Value(Winfo_Get(Label, "reqheight"));
end if;
ProgressBar :=
Create
(ModuleFrame & ".quality",
"-orient horizontal -style blue.Horizontal.TProgressbar -maximum 1.0 -value {" &
Float'Image(Float(Module.Quality) / 100.0) & "}");
Add(ProgressBar, "Quality of the selected cabin");
Label :=
Create
(ModuleFrame & ".qualitylbl",
"-text {" & Get_Cabin_Quality(Module.Quality) & "}");
MaxValue :=
Positive(Float(Modules_List(Module.Proto_Index).MaxValue) * 1.5);
if Module.Quality = MaxValue then
configure
(Label, "-text {" & cget(Label, "-text") & " (max upgrade)}");
end if;
Tcl.Tk.Ada.Grid.Grid(Label, "-row 2 -sticky w");
Tcl.Tk.Ada.Grid.Grid(ProgressBar, "-row 2 -column 1 -sticky we");
Height := Height + Positive'Value(Winfo_Get(Label, "reqheight"));
when GUN | HARPOON_GUN =>
Insert
(ModuleText, "end",
"{" & LF & "Strength:" &
(if Modules_List(Module.Proto_Index).MType = GUN then
Positive'Image(Module.Damage)
else Positive'Image(Module.Duration)) &
LF & "Ammunition: }");
HaveAmmo := False;
declare
AmmoIndex: constant Natural :=
(if Module.M_Type = GUN then Module.Ammo_Index
else Module.Harpoon_Index);
begin
if AmmoIndex in
Player_Ship.Cargo.First_Index ..
Player_Ship.Cargo.Last_Index
and then
Items_List(Player_Ship.Cargo(AmmoIndex).ProtoIndex).IType =
Items_Types(Modules_List(Module.Proto_Index).Value) then
Insert
(ModuleText, "end",
"{" &
To_String
(Items_List(Player_Ship.Cargo(AmmoIndex).ProtoIndex)
.Name) &
" (assigned)}");
HaveAmmo := True;
end if;
end;
if not HaveAmmo then
Mamount := 0;
Find_Ammo_Info_Loop :
for I in Items_List.Iterate loop
if Items_List(I).IType =
Items_Types(Modules_List(Module.Proto_Index).Value) then
if Mamount > 0 then
Insert(ModuleText, "end", "{ or }");
end if;
Insert
(ModuleText, "end",
"{" & To_String(Items_List(I).Name) & "}" &
(if
FindItem
(Player_Ship.Cargo, Objects_Container.Key(I)) >
0
then ""
else " [list red]"));
Mamount := Mamount + 1;
end if;
end loop Find_Ammo_Info_Loop;
end if;
Insert
(ModuleText, "end",
"{" & LF & "Gunner: " &
(if Module.Owner(1) > 0 then
To_String(Player_Ship.Crew(Module.Owner(1)).Name)
else "none") &
"}");
if Module.M_Type = GUN then
Insert
(ModuleText, "end",
"{" & LF & "Max fire rate:" &
(if Modules_List(Module.Proto_Index).Speed > 0 then
Positive'Image(Modules_List(Module.Proto_Index).Speed) &
"/round}"
else "1/" &
Trim
(Integer'Image
(abs (Modules_List(Module.Proto_Index).Speed)),
Left) &
" rounds}"));
end if;
when TURRET =>
Insert
(ModuleText, "end",
"{" & LF & "Weapon: " &
(if Module.Gun_Index > 0 then
To_String(Player_Ship.Modules(Module.Gun_Index).Name)
else "none") &
"}");
when WORKSHOP =>
AddOwnersInfo("Worker");
Insert(ModuleText, "end", "{" & LF & "}");
if Module.Crafting_Index /= Null_Unbounded_String then
if Length(Module.Crafting_Index) > 6
and then Slice(Module.Crafting_Index, 1, 5) = "Study" then
Insert
(ModuleText, "end",
"{Studying " &
To_String
(Items_List
(Unbounded_Slice
(Module.Crafting_Index, 7,
Length(Module.Crafting_Index)))
.Name) &
"}");
elsif Length(Module.Crafting_Index) > 12
and then Slice(Module.Crafting_Index, 1, 11) =
"Deconstruct" then
Insert
(ModuleText, "end",
"{Deconstructing " &
To_String
(Items_List
(Unbounded_Slice
(Module.Crafting_Index, 13,
Length(Module.Crafting_Index)))
.Name) &
"}");
else
Insert
(ModuleText, "end",
"{Manufacturing:" &
Positive'Image(Module.Crafting_Amount) & "x " &
To_String
(Items_List
(Recipes_List(Module.Crafting_Index).ResultIndex)
.Name) &
"}");
end if;
Insert
(ModuleText, "end",
"{" & LF & "Time to complete current:" &
Positive'Image(Module.Crafting_Time) & " mins}");
else
Insert(ModuleText, "end", "{Manufacturing: nothing}");
end if;
when MEDICAL_ROOM =>
AddOwnersInfo("Medic");
when TRAINING_ROOM =>
Insert
(ModuleText, "end",
"{" & LF &
(if Module.Trained_Skill > 0 then
"Set for training " &
To_String
(SkillsData_Container.Element
(Skills_List, Module.Trained_Skill)
.Name)
else "Must be set for training") &
".}");
AddOwnersInfo("Trainee");
when BATTERING_RAM =>
Insert
(ModuleText, "end",
"Strength:" & Positive'Image(Module.Damage2) & "}");
when others =>
null;
end case;
if Modules_List(Module.Proto_Index).Size > 0 then
Insert
(ModuleText, "end",
"{" & LF & "Size:" &
Natural'Image(Modules_List(Module.Proto_Index).Size) & "}");
end if;
if Modules_List(Module.Proto_Index).Description /=
Null_Unbounded_String then
Insert
(ModuleText, "end",
"{" & LF & LF &
To_String(Modules_List(Module.Proto_Index).Description) & "}");
end if;
if Module.Upgrade_Action /= NONE then
ModuleInfo := To_Unbounded_String("Upgrading: ");
case Module.Upgrade_Action is
when DURABILITY =>
Append(ModuleInfo, "durability");
MaxUpgrade := Modules_List(Module.Proto_Index).Durability;
when MAX_VALUE =>
case Modules_List(Module.Proto_Index).MType is
when ENGINE =>
Append(ModuleInfo, "power");
MaxUpgrade :=
Modules_List(Module.Proto_Index).MaxValue / 20;
when CABIN =>
Append(ModuleInfo, "quality");
MaxUpgrade := Modules_List(Module.Proto_Index).MaxValue;
when GUN | BATTERING_RAM =>
Append(ModuleInfo, "damage");
MaxUpgrade :=
Modules_List(Module.Proto_Index).MaxValue * 2;
when HULL =>
Append(ModuleInfo, "enlarge");
MaxUpgrade :=
Modules_List(Module.Proto_Index).MaxValue * 40;
when HARPOON_GUN =>
Append(ModuleInfo, "strength");
MaxUpgrade :=
Modules_List(Module.Proto_Index).MaxValue * 10;
when others =>
null;
end case;
when VALUE =>
case Modules_List(Module.Proto_Index).MType is
when ENGINE =>
Append(ModuleInfo, "fuel usage");
MaxUpgrade := Modules_List(Module.Proto_Index).Value * 20;
when others =>
null;
end case;
when others =>
null;
end case;
MaxUpgrade :=
Integer
(Float(MaxUpgrade) * Float(New_Game_Settings.Upgrade_Cost_Bonus));
if MaxUpgrade = 0 then
MaxUpgrade := 1;
end if;
UpgradePercent :=
1.0 - (Float(Module.Upgrade_Progress) / Float(MaxUpgrade));
ProgressBarStyle :=
(if UpgradePercent > 0.74 then
To_Unbounded_String(" -style green.Horizontal.TProgressbar")
elsif UpgradePercent > 0.24 then
To_Unbounded_String(" -style yellow.Horizontal.TProgressbar")
else To_Unbounded_String(" -style Horizontal.TProgressbar"));
ProgressBar :=
Create
(ModuleFrame & ".upgrade",
"-orient horizontal -maximum 1.0 -value {" &
Float'Image(UpgradePercent) & "}" & To_String(ProgressBarStyle));
Add(ProgressBar, "The progress of the current upgrade of the module");
Label :=
Create
(ModuleFrame & ".upgradelbl",
"-text {" & To_String(ModuleInfo) & "}");
Tcl.Tk.Ada.Grid.Grid(Label, "-row 3 -sticky w");
Tcl.Tk.Ada.Grid.Grid(ProgressBar, "-row 3 -column 1 -sticky we");
Height := Height + Positive'Value(Winfo_Get(Label, "reqheight"));
end if;
configure
(ModuleText,
"-state disabled -height" &
Positive'Image
(Positive'Value(Count(ModuleText, "-displaylines", "0.0", "end")) /
Positive'Value(Metrics("InterfaceFont", "-linespace")) +
1));
Tcl.Tk.Ada.Grid.Grid(ModuleText, "-columnspan 2");
Height := Height + Positive'Value(Winfo_Get(ModuleText, "reqheight"));
Add_Close_Button
(ModuleFrame & ".button", "Close", "CloseDialog " & ModuleDialog, 2);
Height :=
Height +
Positive'Value
(Winfo_Get
(Ttk_Frame'(Get_Widget(ModuleFrame & ".button")), "reqheight"));
if Height > 500 then
Height := 500;
end if;
configure
(ModuleFrame,
"-height" & Positive'Image(Height) & " -width " &
Winfo_Get(ModuleText, "reqwidth"));
Canvas_Create
(ModuleCanvas, "window",
"0 0 -anchor nw -window " & Widget_Image(ModuleFrame));
configure
(ModuleCanvas,
"-scrollregion [list " & BBox(ModuleCanvas, "all") & "]");
Height :=
Height + 15 +
Positive'Value
(Winfo_Get
(Ttk_Frame'(Get_Widget(ModuleDialog & ".header")), "reqheight"));
declare
Width: Positive;
begin
Width :=
Positive'Value(Winfo_Get(ModuleText, "reqwidth")) +
Positive'Value(Winfo_Get(YScroll, "reqwidth")) + 5;
configure
(ModuleDialog,
"-height" & Positive'Image(Height) & " -width" &
Positive'Image(Width));
end;
Show_Dialog
(Dialog => ModuleDialog, Relative_X => 0.2, Relative_Y => 0.1);
return TCL_OK;
end Show_Module_Info_Command;
-- ****o* SUModules/SUModules.Set_Upgrade_Command
-- FUNCTION
-- Set the selected upgrade for the selected module
-- PARAMETERS
-- ClientData - Custom data send to the command.
-- Interp - Tcl interpreter in which command was executed.
-- Argc - Number of arguments passed to the command.
-- Argv - Values of arguments passed to the command.
-- RESULT
-- This function always return TCL_OK
-- COMMANDS
-- SetUpgrade upgradetype moduleindex
-- upgradetype is type of upgrade to start: 1, 2 or 3. moduleindex is the
-- index of the player ship module which will be upgraded
-- SOURCE
function Set_Upgrade_Command
(ClientData: Integer; Interp: Tcl.Tcl_Interp; Argc: Interfaces.C.int;
Argv: CArgv.Chars_Ptr_Ptr) return Interfaces.C.int with
Convention => C;
-- ****
function Set_Upgrade_Command
(ClientData: Integer; Interp: Tcl.Tcl_Interp; Argc: Interfaces.C.int;
Argv: CArgv.Chars_Ptr_Ptr) return Interfaces.C.int is
begin
StartUpgrading
(Positive'Value(CArgv.Arg(Argv, 2)),
Positive'Value(CArgv.Arg(Argv, 1)));
UpdateOrders(Player_Ship);
Update_Messages;
return Show_Ship_Info_Command(ClientData, Interp, Argc, Argv);
end Set_Upgrade_Command;
-- ****o* SUModules/SUModules.Assign_Module_Command
-- FUNCTION
-- Assign member, ammo or skill to module
-- PARAMETERS
-- ClientData - Custom data send to the command.
-- Interp - Tcl interpreter in which command was executed.
-- Argc - Number of arguments passed to the command.
-- Argv - Values of arguments passed to the command.
-- RESULT
-- This function always return TCL_OK
-- COMMANDS
-- AssignModule assigntype moduleindex assignindex
-- assigntype is type of item to assing to module: crew, ammo, skills.
-- moduleindex is the index of the Player_Ship module to which item will be
-- assigned. assignindex is the index of the item which will be assigned
-- to the module
-- SOURCE
function Assign_Module_Command
(ClientData: Integer; Interp: Tcl.Tcl_Interp; Argc: Interfaces.C.int;
Argv: CArgv.Chars_Ptr_Ptr) return Interfaces.C.int with
Convention => C;
-- ****
function Assign_Module_Command
(ClientData: Integer; Interp: Tcl.Tcl_Interp; Argc: Interfaces.C.int;
Argv: CArgv.Chars_Ptr_Ptr) return Interfaces.C.int is
use Tiny_String;
ModuleIndex: constant Positive := Positive'Value(CArgv.Arg(Argv, 2));
AssignIndex: constant Positive := Positive'Value(CArgv.Arg(Argv, 3));
Assigned: Boolean;
procedure UpdateOrder(Order: Crew_Orders) is
begin
GiveOrders(Player_Ship, AssignIndex, Order, ModuleIndex);
if Player_Ship.Crew(AssignIndex).Order /= Order then
Tcl_SetVar
(Interp,
".moduledialog.canvas.frame.crewbutton" & CArgv.Arg(Argv, 3),
"0");
end if;
end UpdateOrder;
begin
if CArgv.Arg(Argv, 1) = "crew" then
case Modules_List(Player_Ship.Modules(ModuleIndex).Proto_Index)
.MType is
when CABIN =>
Modules_Loop :
for Module of Player_Ship.Modules loop
if Module.M_Type = CABIN then
for Owner of Module.Owner loop
if Owner = AssignIndex then
Owner := 0;
exit Modules_Loop;
end if;
end loop;
end if;
end loop Modules_Loop;
Assigned := False;
Check_Assigned_Loop :
for Owner of Player_Ship.Modules(ModuleIndex).Owner loop
if Owner = 0 then
Owner := AssignIndex;
Assigned := True;
exit Check_Assigned_Loop;
end if;
end loop Check_Assigned_Loop;
if not Assigned then
Player_Ship.Modules(ModuleIndex).Owner(1) := AssignIndex;
end if;
AddMessage
("You assigned " &
To_String(Player_Ship.Modules(ModuleIndex).Name) & " to " &
To_String(Player_Ship.Crew(AssignIndex).Name) & ".",
OrderMessage);
when GUN | HARPOON_GUN =>
UpdateOrder(Gunner);
when ALCHEMY_LAB .. GREENHOUSE =>
UpdateOrder(Craft);
when MEDICAL_ROOM =>
UpdateOrder(Heal);
when TRAINING_ROOM =>
UpdateOrder(Train);
when others =>
null;
end case;
UpdateHeader;
elsif CArgv.Arg(Argv, 1) = "ammo" then
if Player_Ship.Modules(ModuleIndex).M_Type = GUN then
Player_Ship.Modules(ModuleIndex).Ammo_Index := AssignIndex;
else
Player_Ship.Modules(ModuleIndex).Harpoon_Index := AssignIndex;
end if;
AddMessage
("You assigned " &
To_String
(Items_List(Player_Ship.Cargo(AssignIndex).ProtoIndex).Name) &
" to " & To_String(Player_Ship.Modules(ModuleIndex).Name) & ".",
OrderMessage);
elsif CArgv.Arg(Argv, 1) = "skill" then
if Player_Ship.Modules(ModuleIndex).Trained_Skill = AssignIndex then
return TCL_OK;
end if;
Player_Ship.Modules(ModuleIndex).Trained_Skill := AssignIndex;
AddMessage
("You prepared " &
To_String(Player_Ship.Modules(ModuleIndex).Name) &
" for training " &
To_String
(SkillsData_Container.Element(Skills_List, AssignIndex).Name) &
".",
OrderMessage);
end if;
Update_Messages;
return Show_Ship_Info_Command(ClientData, Interp, Argc, Argv);
exception
when An_Exception : Crew_Order_Error =>
ShowMessage
(Text => Exception_Message(An_Exception),
Title => "Can't assign crew");
return TCL_OK;
end Assign_Module_Command;
-- ****o* SUModules/SUModules.Disable_Engine_Command
-- FUNCTION
-- Enable or disable selected engine
-- PARAMETERS
-- ClientData - Custom data send to the command.
-- Interp - Tcl interpreter in which command was executed.
-- Argc - Number of arguments passed to the command. Unused
-- Argv - Values of arguments passed to the command.
-- RESULT
-- This function always return TCL_OK
-- COMMANDS
-- DisableEngine engineindex
-- engineindex is the index of the engine module in the player ship
-- SOURCE
function Disable_Engine_Command
(ClientData: Integer; Interp: Tcl.Tcl_Interp; Argc: Interfaces.C.int;
Argv: CArgv.Chars_Ptr_Ptr) return Interfaces.C.int with
Convention => C;
-- ****
function Disable_Engine_Command
(ClientData: Integer; Interp: Tcl.Tcl_Interp; Argc: Interfaces.C.int;
Argv: CArgv.Chars_Ptr_Ptr) return Interfaces.C.int is
pragma Unreferenced(Argc);
CanDisable: Boolean := False;
ModuleIndex: constant Positive := Positive'Value(CArgv.Arg(Argv, 1));
begin
if not Player_Ship.Modules(ModuleIndex).Disabled then
Check_Can_Disable_Loop :
for I in Player_Ship.Modules.Iterate loop
if Player_Ship.Modules(I).M_Type = ENGINE
and then
(not Player_Ship.Modules(I).Disabled and
Modules_Container.To_Index(I) /= ModuleIndex) then
CanDisable := True;
exit Check_Can_Disable_Loop;
end if;
end loop Check_Can_Disable_Loop;
if not CanDisable then
ShowMessage
(Text =>
"You can't disable this engine because it is your last working engine.",
Title => "Can't disable engine");
return TCL_OK;
end if;
Player_Ship.Modules(ModuleIndex).Disabled := True;
AddMessage
("You disabled " &
To_String(Player_Ship.Modules(ModuleIndex).Name) & ".",
OrderMessage);
else
Player_Ship.Modules(ModuleIndex).Disabled := False;
AddMessage
("You enabled " & To_String(Player_Ship.Modules(ModuleIndex).Name) &
".",
OrderMessage);
end if;
Update_Messages;
return Show_Ship_Info_Command(ClientData, Interp, 2, Argv);
end Disable_Engine_Command;
-- ****o* SUModules/SUModules.Stop_Upgrading_Command
-- FUNCTION
-- Stop the current ship upgrade
-- PARAMETERS
-- ClientData - Custom data send to the command.
-- Interp - Tcl interpreter in which command was executed.
-- Argc - Number of arguments passed to the command. Unused
-- Argv - Values of arguments passed to the command.
-- RESULT
-- This function always return TCL_OK
-- COMMANDS
-- StopUpgrading
-- SOURCE
function Stop_Upgrading_Command
(ClientData: Integer; Interp: Tcl.Tcl_Interp; Argc: Interfaces.C.int;
Argv: CArgv.Chars_Ptr_Ptr) return Interfaces.C.int with
Convention => C;
-- ****
function Stop_Upgrading_Command
(ClientData: Integer; Interp: Tcl.Tcl_Interp; Argc: Interfaces.C.int;
Argv: CArgv.Chars_Ptr_Ptr) return Interfaces.C.int is
pragma Unreferenced(Argc);
begin
Player_Ship.Upgrade_Module := 0;
Give_Orders_Loop :
for I in Player_Ship.Crew.First_Index .. Player_Ship.Crew.Last_Index loop
if Player_Ship.Crew(I).Order = Upgrading then
GiveOrders(Player_Ship, I, Rest);
exit Give_Orders_Loop;
end if;
end loop Give_Orders_Loop;
AddMessage("You stopped current upgrade.", OrderMessage);
Update_Messages;
return Show_Ship_Info_Command(ClientData, Interp, 2, Argv);
end Stop_Upgrading_Command;
-- ****o* SUModules/SUModules.Set_Repair_Command
-- FUNCTION
-- Set or remove the repair priority from the selected module
-- PARAMETERS
-- ClientData - Custom data send to the command.
-- Interp - Tcl interpreter in which command was executed.
-- Argc - Number of arguments passed to the command. Unused
-- Argv - Values of arguments passed to the command.
-- RESULT
-- This function always return TCL_OK
-- COMMANDS
-- SetRepair action
-- Action can be assing or remove. If assing, then assing the currently
-- selected module as the repair first, otherwise clear current priority
-- setting
-- SOURCE
function Set_Repair_Command
(ClientData: Integer; Interp: Tcl.Tcl_Interp; Argc: Interfaces.C.int;
Argv: CArgv.Chars_Ptr_Ptr) return Interfaces.C.int with
Convention => C;
-- ****
function Set_Repair_Command
(ClientData: Integer; Interp: Tcl.Tcl_Interp; Argc: Interfaces.C.int;
Argv: CArgv.Chars_Ptr_Ptr) return Interfaces.C.int is
begin
if CArgv.Arg(Argv, 1) = "assign" then
Player_Ship.Repair_Module := Positive'Value(CArgv.Arg(Argv, 2));
AddMessage
("You assigned " &
To_String
(Player_Ship.Modules(Positive'Value(CArgv.Arg(Argv, 2))).Name) &
" as repair priority.",
OrderMessage);
else
Player_Ship.Repair_Module := 0;
AddMessage("You removed repair priority.", OrderMessage);
end if;
Update_Messages;
return Show_Ship_Info_Command(ClientData, Interp, Argc, Argv);
end Set_Repair_Command;
-- ****o* SUModules/SUModules.Reset_Destination_Command
-- FUNCTION
-- Reset the current destination point for the player's ship
-- PARAMETERS
-- ClientData - Custom data send to the command. Unused
-- Interp - Tcl interpreter in which command was executed.
-- Argc - Number of arguments passed to the command. Unused
-- Argv - Values of arguments passed to the command. Unused
-- RESULT
-- This function always return TCL_OK
-- COMMANDS
-- ResetDestination
-- SOURCE
function Reset_Destination_Command
(ClientData: Integer; Interp: Tcl.Tcl_Interp; Argc: Interfaces.C.int;
Argv: CArgv.Chars_Ptr_Ptr) return Interfaces.C.int with
Convention => C;
-- ****
function Reset_Destination_Command
(ClientData: Integer; Interp: Tcl.Tcl_Interp; Argc: Interfaces.C.int;
Argv: CArgv.Chars_Ptr_Ptr) return Interfaces.C.int is
pragma Unreferenced(Argc);
begin
Player_Ship.Destination_X := 0;
Player_Ship.Destination_Y := 0;
return Show_Ship_Info_Command(ClientData, Interp, 2, Argv);
end Reset_Destination_Command;
-- ****o* SUModules/SUModules.Update_Assign_Crew_Command
-- FUNCTION
-- Update assign the crew member UI
-- PARAMETERS
-- ClientData - Custom data send to the command. Unused
-- Interp - Tcl interpreter in which command was executed.
-- Argc - Number of arguments passed to the command. Unused
-- Argv - Values of arguments passed to the command.
-- RESULT
-- This function always return TCL_OK
-- COMMANDS
-- UpdateAssignCrew moduleindex ?crewindex?
-- Moduleindex is the index of the module to which a new crew members will
-- be assigned. Crewindex is the index of the crew member which will be
-- assigned or removed
-- SOURCE
function Update_Assign_Crew_Command
(ClientData: Integer; Interp: Tcl.Tcl_Interp; Argc: Interfaces.C.int;
Argv: CArgv.Chars_Ptr_Ptr) return Interfaces.C.int with
Convention => C;
-- ****
function Update_Assign_Crew_Command
(ClientData: Integer; Interp: Tcl.Tcl_Interp; Argc: Interfaces.C.int;
Argv: CArgv.Chars_Ptr_Ptr) return Interfaces.C.int is
ModuleIndex: constant Positive := Positive'Value(CArgv.Arg(Argv, 1));
Assigned: Natural := 0;
FrameName: constant String := ".moduledialog.canvas.frame";
CrewButton: Ttk_CheckButton;
ButtonName: Unbounded_String;
CrewIndex: constant Natural :=
(if Argc = 3 then Positive'Value(CArgv.Arg(Argv, 2)) else 0);
InfoLabel: constant Ttk_Label :=
Get_Widget(FrameName & ".infolabel", Interp);
begin
if Argc = 3 then
if Tcl_GetVar
(Interp, FrameName & ".crewbutton" & CArgv.Arg(Argv, 2)) =
"0" then
Remove_Owner_Loop :
for Owner of Player_Ship.Modules(ModuleIndex).Owner loop
if Owner = CrewIndex then
Owner := 0;
exit Remove_Owner_Loop;
end if;
end loop Remove_Owner_Loop;
if Modules_List(Player_Ship.Modules(ModuleIndex).Proto_Index)
.MType /=
CABIN then
GiveOrders(Player_Ship, CrewIndex, Rest, 0, False);
end if;
elsif Assign_Module_Command
(ClientData, Interp, 4,
CArgv.Empty & "AssignModule" & "crew" & CArgv.Arg(Argv, 1) &
CArgv.Arg(Argv, 2)) /=
TCL_OK then
return TCL_ERROR;
end if;
end if;
CrewButton.Interp := Interp;
Enable_Buttons_Loop :
for I in Player_Ship.Crew.Iterate loop
CrewButton.Name :=
New_String
(FrameName & ".crewbutton" &
Trim(Positive'Image(Crew_Container.To_Index(I)), Left));
State(CrewButton, "!disabled");
configure(CrewButton, "-takefocus 1");
end loop Enable_Buttons_Loop;
for Owner of Player_Ship.Modules(ModuleIndex).Owner loop
if Owner /= 0 then
Assigned := Assigned + 1;
end if;
end loop;
if Assigned =
Positive(Player_Ship.Modules(ModuleIndex).Owner.Length) then
Disable_Buttons_Loop :
for I in Player_Ship.Crew.Iterate loop
ButtonName :=
To_Unbounded_String
(FrameName & ".crewbutton" &
Trim(Positive'Image(Crew_Container.To_Index(I)), Left));
if Tcl_GetVar(Interp, To_String(ButtonName)) = "0" then
CrewButton.Name := New_String(To_String(ButtonName));
State(CrewButton, "disabled");
configure(CrewButton, "-takefocus 0");
end if;
end loop Disable_Buttons_Loop;
end if;
if Winfo_Get(InfoLabel, "exists") = "1" then
configure
(InfoLabel,
"-text {Available:" &
Natural'Image
(Positive(Player_Ship.Modules(ModuleIndex).Owner.Length) -
Assigned) &
"}");
UpdateHeader;
UpdateCrewInfo;
end if;
return TCL_OK;
end Update_Assign_Crew_Command;
-- ****o* SUModules/SUModules.Show_Assign_Crew_Command
-- FUNCTION
-- Show assign the crew member UI
-- PARAMETERS
-- ClientData - Custom data send to the command.
-- Interp - Tcl interpreter in which command was executed.
-- Argc - Number of arguments passed to the command.
-- Argv - Values of arguments passed to the command.
-- RESULT
-- This function always return TCL_OK
-- COMMANDS
-- ShowAssignCrew moduleindex
-- Moduleindex is the index of the module to which a new crew members will
-- be assigned.
-- SOURCE
function Show_Assign_Crew_Command
(ClientData: Integer; Interp: Tcl.Tcl_Interp; Argc: Interfaces.C.int;
Argv: CArgv.Chars_Ptr_Ptr) return Interfaces.C.int with
Convention => C;
-- ****
function Show_Assign_Crew_Command
(ClientData: Integer; Interp: Tcl.Tcl_Interp; Argc: Interfaces.C.int;
Argv: CArgv.Chars_Ptr_Ptr) return Interfaces.C.int is
ModuleIndex: constant Positive := Positive'Value(CArgv.Arg(Argv, 1));
Module: constant Module_Data := Player_Ship.Modules(ModuleIndex);
ModuleDialog: constant Ttk_Frame :=
Create_Dialog
(".moduledialog",
"Assign a crew member to " & To_String(Module.Name), 250);
YScroll: constant Ttk_Scrollbar :=
Create
(ModuleDialog & ".yscroll",
"-orient vertical -command [list .moduledialog.canvas yview]");
CrewCanvas: constant Tk_Canvas :=
Create
(ModuleDialog & ".canvas",
"-yscrollcommand [list " & YScroll & " set]");
CrewFrame: constant Ttk_Frame := Create(CrewCanvas & ".frame");
CloseButton: constant Ttk_Button :=
Create
(ModuleDialog & ".button",
"-text Close -command {CloseDialog " & Widget_Image(ModuleDialog) &
"}");
Height: Positive := 10;
Width: Positive := 250;
CrewButton: Ttk_CheckButton;
InfoLabel: Ttk_Label;
Assigned: Natural := 0;
Recipe: constant Craft_Data :=
(if Module.M_Type = WORKSHOP then SetRecipeData(Module.Crafting_Index)
else Craft_Data'(others => <>));
begin
Tcl.Tk.Ada.Grid.Grid(CrewCanvas, "-sticky nwes -padx 5 -pady 5");
Tcl.Tk.Ada.Grid.Grid
(YScroll, "-sticky ns -padx {0 5} -pady {5 0} -row 0 -column 1");
Tcl.Tk.Ada.Grid.Grid(CloseButton, "-pady {0 5} -columnspan 2");
Focus(CloseButton);
Autoscroll(YScroll);
Load_Crew_List_Loop :
for I in Player_Ship.Crew.Iterate loop
CrewButton :=
Create
(CrewFrame & ".crewbutton" &
Trim(Positive'Image(Crew_Container.To_Index(I)), Left),
"-text {" & To_String(Player_Ship.Crew(I).Name) &
(if Module.M_Type = WORKSHOP then
Get_Skill_Marks(Recipe.Skill, Crew_Container.To_Index(I))
else "") &
"} -command {UpdateAssignCrew" & Positive'Image(ModuleIndex) &
Positive'Image(Crew_Container.To_Index(I)) & "}");
Tcl_SetVar(Interp, Widget_Image(CrewButton), "0");
Count_Assigned_Loop :
for Owner of Module.Owner loop
if Owner = Crew_Container.To_Index(I) then
Tcl_SetVar(Interp, Widget_Image(CrewButton), "1");
Assigned := Assigned + 1;
exit Count_Assigned_Loop;
end if;
end loop Count_Assigned_Loop;
Tcl.Tk.Ada.Pack.Pack(CrewButton, "-anchor w");
Height := Height + Positive'Value(Winfo_Get(CrewButton, "reqheight"));
if Positive'Value(Winfo_Get(CrewButton, "reqwidth")) + 10 > Width then
Width := Positive'Value(Winfo_Get(CrewButton, "reqwidth")) + 10;
end if;
Bind(CrewButton, "<Escape>", "{" & CloseButton & " invoke;break}");
Bind
(CrewButton, "<Tab>",
"{focus [GetActiveButton" &
Positive'Image(Crew_Container.To_Index(I)) & "];break}");
end loop Load_Crew_List_Loop;
if Update_Assign_Crew_Command(ClientData, Interp, Argc, Argv) /=
TCL_OK then
return TCL_ERROR;
end if;
InfoLabel :=
Create
(CrewFrame & ".infolabel",
"-text {Available:" &
Natural'Image(Positive(Module.Owner.Length) - Assigned) & "}");
Tcl.Tk.Ada.Pack.Pack(InfoLabel);
Height := Height + Positive'Value(Winfo_Get(InfoLabel, "reqheight"));
if Positive'Value(Winfo_Get(InfoLabel, "reqwidth")) > Width then
Width := Positive'Value(Winfo_Get(InfoLabel, "reqwidth"));
end if;
if Height > 500 then
Height := 500;
end if;
Canvas_Create
(CrewCanvas, "window",
"0 0 -anchor nw -window " & Widget_Image(CrewFrame));
Tcl_Eval(Interp, "update");
configure
(CrewCanvas,
"-scrollregion [list " & BBox(CrewCanvas, "all") & "] -height" &
Positive'Image(Height) & " -width" & Positive'Image(Width));
Bind(CloseButton, "<Escape>", "{" & CloseButton & " invoke;break}");
Bind(CloseButton, "<Tab>", "{focus [GetActiveButton 0];break}");
Show_Dialog(Dialog => ModuleDialog, Relative_Y => 0.2);
return TCL_OK;
end Show_Assign_Crew_Command;
-- ****o* SUModules/SUModules.Show_Assign_Skill_Command
-- FUNCTION
-- Show assign the skill UI
-- PARAMETERS
-- ClientData - Custom data send to the command. Unused
-- Interp - Tcl interpreter in which command was executed. Unused
-- Argc - Number of arguments passed to the command. Unused
-- Argv - Values of arguments passed to the command.
-- RESULT
-- This function always return TCL_OK
-- COMMANDS
-- ShowAssignSkill moduleindex
-- Moduleindex is the index of the module to which a new skill will
-- be assigned.
-- SOURCE
function Show_Assign_Skill_Command
(ClientData: Integer; Interp: Tcl.Tcl_Interp; Argc: Interfaces.C.int;
Argv: CArgv.Chars_Ptr_Ptr) return Interfaces.C.int with
Convention => C;
-- ****
function Show_Assign_Skill_Command
(ClientData: Integer; Interp: Tcl.Tcl_Interp; Argc: Interfaces.C.int;
Argv: CArgv.Chars_Ptr_Ptr) return Interfaces.C.int is
pragma Unreferenced(ClientData, Interp, Argc);
use Tiny_String;
ModuleIndex: constant Positive := Positive'Value(CArgv.Arg(Argv, 1));
ModuleDialog: constant Ttk_Frame :=
Create_Dialog
(Name => ".moduledialog",
Title =>
"Assign skill to " &
To_String(Player_Ship.Modules(ModuleIndex).Name),
Title_Width => 400);
SkillsFrame: constant Ttk_Frame := Create(ModuleDialog & ".frame");
ToolName, ProtoIndex, SkillName, ToolColor: Unbounded_String;
SkillsTable: Table_Widget (2) :=
CreateTable
(Widget_Image(SkillsFrame),
(To_Unbounded_String("Skill"),
To_Unbounded_String("Training tool")));
begin
Load_Skills_List_Loop :
for I in 1 .. Skills_Amount loop
if SkillsData_Container.Element(Skills_List, I).Tool /=
Null_Bounded_String then
ProtoIndex :=
FindProtoItem
(ItemType =>
To_Unbounded_String
(To_String
(SkillsData_Container.Element(Skills_List, I).Tool)));
ToolName :=
(if Items_List(ProtoIndex).ShowType /= Null_Unbounded_String then
Items_List(ProtoIndex).ShowType
else Items_List(ProtoIndex).IType);
end if;
SkillName :=
To_Unbounded_String
(To_String(SkillsData_Container.Element(Skills_List, I).Name));
ToolColor := To_Unbounded_String("green");
if GetItemAmount(Items_List(ProtoIndex).IType) = 0 then
Append(SkillName, " (no tool)");
ToolColor := To_Unbounded_String("red");
end if;
AddButton
(SkillsTable, To_String(SkillName),
"Press mouse " &
(if Game_Settings.Right_Button then "right" else "left") &
" button to set as trained skill",
"AssignModule skill" & Positive'Image(ModuleIndex) &
Positive'Image(I),
1);
AddButton
(SkillsTable, To_String(ToolName),
"Press mouse " &
(if Game_Settings.Right_Button then "right" else "left") &
" button to set as trained skill",
"AssignModule skill" & Positive'Image(ModuleIndex) &
Positive'Image(I),
2, True, To_String(ToolColor));
end loop Load_Skills_List_Loop;
UpdateTable(SkillsTable);
Tcl.Tk.Ada.Grid.Grid(SkillsFrame, "-padx 2");
Tcl_Eval(Get_Context, "update");
configure
(SkillsTable.Canvas,
"-scrollregion [list " & BBox(SkillsTable.Canvas, "all") & "]");
Xview_Move_To(SkillsTable.Canvas, "0.0");
Yview_Move_To(SkillsTable.Canvas, "0.0");
Add_Close_Button
(ModuleDialog & ".button", "Close", "CloseDialog " & ModuleDialog);
Show_Dialog(Dialog => ModuleDialog, Relative_Y => 0.2);
return TCL_OK;
end Show_Assign_Skill_Command;
-- ****o* SUModules/SUModules.Cancel_Order_Command
-- FUNCTION
-- Cancel the current crafting order
-- PARAMETERS
-- ClientData - Custom data send to the command.
-- Interp - Tcl interpreter in which command was executed.
-- Argc - Number of arguments passed to the command.
-- Argv - Values of arguments passed to the command.
-- RESULT
-- This function always return TCL_OK
-- COMMANDS
-- Cancel moduleindex
-- Moduleindex is the index of the module which the crafting order will
-- be canceled
-- SOURCE
function Cancel_Order_Command
(ClientData: Integer; Interp: Tcl.Tcl_Interp; Argc: Interfaces.C.int;
Argv: CArgv.Chars_Ptr_Ptr) return Interfaces.C.int with
Convention => C;
-- ****
function Cancel_Order_Command
(ClientData: Integer; Interp: Tcl.Tcl_Interp; Argc: Interfaces.C.int;
Argv: CArgv.Chars_Ptr_Ptr) return Interfaces.C.int is
pragma Unreferenced(ClientData, Interp, Argc);
ModuleIndex: constant Positive := Positive'Value(CArgv.Arg(Argv, 1));
begin
Player_Ship.Modules(ModuleIndex).Crafting_Index := Null_Unbounded_String;
Player_Ship.Modules(ModuleIndex).Crafting_Amount := 0;
Player_Ship.Modules(ModuleIndex).Crafting_Time := 0;
Give_Orders_Loop :
for Owner of Player_Ship.Modules(ModuleIndex).Owner loop
if Owner > 0 then
GiveOrders(Player_Ship, Owner, Rest);
end if;
end loop Give_Orders_Loop;
AddMessage
("You cancelled crafting order in " &
To_String(Player_Ship.Modules(ModuleIndex).Name) & ".",
CraftMessage, RED);
Update_Messages;
UpdateHeader;
UpdateCrewInfo;
return TCL_OK;
end Cancel_Order_Command;
-- ****o* SUModules/SUModules.Get_Active_Button_Command
-- FUNCTION
-- Get the next active button in assing crew dialog
-- PARAMETERS
-- ClientData - Custom data send to the command. Unused
-- Interp - Tcl interpreter in which command was executed.
-- Argc - Number of arguments passed to the command. Unused
-- Argv - Values of arguments passed to the command.
-- RESULT
-- This function always return TCL_OK
-- COMMANDS
-- GetActiveButton crewindex
-- Crewindex is the index of the crew member which is currently selected
-- or 0 for close button
-- SOURCE
function Get_Active_Button_Command
(ClientData: Integer; Interp: Tcl.Tcl_Interp; Argc: Interfaces.C.int;
Argv: CArgv.Chars_Ptr_Ptr) return Interfaces.C.int with
Convention => C;
-- ****
function Get_Active_Button_Command
(ClientData: Integer; Interp: Tcl.Tcl_Interp; Argc: Interfaces.C.int;
Argv: CArgv.Chars_Ptr_Ptr) return Interfaces.C.int is
pragma Unreferenced(ClientData, Argc);
CrewIndex: constant Natural := Natural'Value(CArgv.Arg(Argv, 1));
ButtonName: Unbounded_String;
Button: Ttk_CheckButton;
begin
Find_Active_Button_Loop :
for I in Player_Ship.Crew.Iterate loop
ButtonName :=
To_Unbounded_String
(".moduledialog.canvas.frame.crewbutton" &
Trim(Positive'Image(Crew_Container.To_Index(I)), Left));
Button := Get_Widget(To_String(ButtonName), Interp);
exit Find_Active_Button_Loop when InState(Button, "disabled") =
"0" and
Crew_Container.To_Index(I) > CrewIndex;
ButtonName := Null_Unbounded_String;
end loop Find_Active_Button_Loop;
if ButtonName = Null_Unbounded_String then
ButtonName := To_Unbounded_String(".moduledialog.button");
end if;
Button := Get_Widget(To_String(ButtonName), Interp);
Focus(Button);
return TCL_OK;
end Get_Active_Button_Command;
procedure UpdateModulesInfo(Page: Positive := 1) is
ShipCanvas: constant Tk_Canvas :=
Get_Widget(Main_Paned & ".shipinfoframe.modules.canvas");
ShipInfoFrame: constant Ttk_Frame := Get_Widget(ShipCanvas & ".frame");
Row: Positive := 2;
Start_Row: constant Positive :=
((Page - 1) * Game_Settings.Lists_Limit) + 1;
Current_Row: Positive := 1;
begin
if ModulesTable.Row_Height = 1 then
ModulesTable :=
CreateTable
(Widget_Image(ShipInfoFrame),
(To_Unbounded_String("Name"), To_Unbounded_String("Durability")),
Get_Widget(Main_Paned & ".shipinfoframe.modules.scrolly"),
"SortShipModules", "Press mouse button to sort the modules.");
end if;
if Modules_Indexes.Length /= Player_Ship.Modules.Length then
Modules_Indexes.Clear;
for I in Player_Ship.Modules.Iterate loop
Modules_Indexes.Append(Modules_Container.To_Index(I));
end loop;
end if;
ClearTable(ModulesTable);
Show_Modules_Menu_Loop :
for Module_Index of Modules_Indexes loop
if Current_Row < Start_Row then
Current_Row := Current_Row + 1;
goto End_Of_Loop;
end if;
AddButton
(ModulesTable, To_String(Player_Ship.Modules(Module_Index).Name),
"Show available module's options",
"ShowModuleMenu" & Positive'Image(Module_Index), 1);
AddProgressBar
(ModulesTable, Player_Ship.Modules(Module_Index).Durability,
Player_Ship.Modules(Module_Index).Max_Durability,
"Show available module's options",
"ShowModuleMenu" & Positive'Image(Module_Index), 2, True);
Row := Row + 1;
exit Show_Modules_Menu_Loop when ModulesTable.Row =
Game_Settings.Lists_Limit + 1;
<<End_Of_Loop>>
end loop Show_Modules_Menu_Loop;
if Page > 1 then
if ModulesTable.Row < Game_Settings.Lists_Limit + 1 then
AddPagination
(ModulesTable, "ShowModules" & Positive'Image(Page - 1), "");
else
AddPagination
(ModulesTable, "ShowModules" & Positive'Image(Page - 1),
"ShowModules" & Positive'Image(Page + 1));
end if;
elsif ModulesTable.Row = Game_Settings.Lists_Limit + 1 then
AddPagination
(ModulesTable, "", "ShowModules" & Positive'Image(Page + 1));
end if;
UpdateTable(ModulesTable);
Tcl_Eval(Get_Context, "update");
configure
(ShipCanvas, "-scrollregion [list " & BBox(ShipCanvas, "all") & "]");
Xview_Move_To(ShipCanvas, "0.0");
Yview_Move_To(ShipCanvas, "0.0");
end UpdateModulesInfo;
-- ****o* SUModules/SUModules.Show_Modules_Command
-- FUNCTION
-- Show the list of the player's ship modules to a player
-- PARAMETERS
-- ClientData - Custom data send to the command. Unused
-- Interp - Tcl interpreter in which command was executed. Unused
-- Argc - Number of arguments passed to the command. Unused
-- Argv - Values of arguments passed to the command.
-- RESULT
-- This function always return TCL_OK
-- COMMANDS
-- ShowModules ?page?
-- Page parameter is a index of page from which starts showing
-- modules.
-- SOURCE
function Show_Modules_Command
(ClientData: Integer; Interp: Tcl.Tcl_Interp; Argc: Interfaces.C.int;
Argv: CArgv.Chars_Ptr_Ptr) return Interfaces.C.int with
Convention => C;
-- ****
function Show_Modules_Command
(ClientData: Integer; Interp: Tcl.Tcl_Interp; Argc: Interfaces.C.int;
Argv: CArgv.Chars_Ptr_Ptr) return Interfaces.C.int is
pragma Unreferenced(ClientData, Interp, Argc);
begin
UpdateModulesInfo(Positive'Value(CArgv.Arg(Argv, 1)));
return TCL_OK;
end Show_Modules_Command;
-- ****it* SUModules/SUModules.Modules_Sort_Orders
-- FUNCTION
-- Sorting orders for the ship modules list
-- OPTIONS
-- NAMEASC - Sort modules by name ascending
-- NAMEDESC - Sort modules by name descending
-- DAMAGEASC - Sort modules by damage ascending
-- DAMAGEDESC - Sort modules by damage descending
-- NONE - No sorting modules (default)
-- HISTORY
-- 6.4 - Added
-- SOURCE
type Modules_Sort_Orders is
(NAMEASC, NAMEDESC, DAMAGEASC, DAMAGEDESC, NONE) with
Default_Value => NONE;
-- ****
-- ****id* SUModules/SUModules.Default_Modules_Sort_Order
-- FUNCTION
-- Default sorting order for the player's ship's modules
-- HISTORY
-- 6.4 - Added
-- SOURCE
Default_Modules_Sort_Order: constant Modules_Sort_Orders := NONE;
-- ****
-- ****iv* SUModules/SUModules.Modules_Sort_Order
-- FUNCTION
-- The current sorting order for modules list
-- HISTORY
-- 6.4 - Added
-- SOURCE
Modules_Sort_Order: Modules_Sort_Orders := Default_Modules_Sort_Order;
-- ****
-- ****o* SUModules/SUModules.Sort_Modules_Command
-- FUNCTION
-- Sort the player's ship's modules list
-- PARAMETERS
-- ClientData - Custom data send to the command. Unused
-- Interp - Tcl interpreter in which command was executed. Unused
-- Argc - Number of arguments passed to the command. Unused
-- Argv - Values of arguments passed to the command.
-- RESULT
-- This function always return TCL_OK
-- COMMANDS
-- SortShipModules x
-- X is X axis coordinate where the player clicked the mouse button
-- SOURCE
function Sort_Modules_Command
(ClientData: Integer; Interp: Tcl.Tcl_Interp; Argc: Interfaces.C.int;
Argv: CArgv.Chars_Ptr_Ptr) return Interfaces.C.int with
Convention => C;
-- ****
function Sort_Modules_Command
(ClientData: Integer; Interp: Tcl.Tcl_Interp; Argc: Interfaces.C.int;
Argv: CArgv.Chars_Ptr_Ptr) return Interfaces.C.int is
pragma Unreferenced(ClientData, Interp, Argc);
Column: constant Positive :=
Get_Column_Number(ModulesTable, Natural'Value(CArgv.Arg(Argv, 1)));
type Local_Module_Data is record
Name: Unbounded_String;
Damage: Float;
Id: Positive;
end record;
type Modules_Array is array(Positive range <>) of Local_Module_Data;
Local_Modules: Modules_Array(1 .. Positive(Player_Ship.Modules.Length));
function "<"(Left, Right: Local_Module_Data) return Boolean is
begin
if Modules_Sort_Order = NAMEASC and then Left.Name < Right.Name then
return True;
end if;
if Modules_Sort_Order = NAMEDESC and then Left.Name > Right.Name then
return True;
end if;
if Modules_Sort_Order = DAMAGEASC
and then Left.Damage < Right.Damage then
return True;
end if;
if Modules_Sort_Order = DAMAGEDESC
and then Left.Damage > Right.Damage then
return True;
end if;
return False;
end "<";
procedure Sort_Modules is new Ada.Containers.Generic_Array_Sort
(Index_Type => Positive, Element_Type => Local_Module_Data,
Array_Type => Modules_Array);
begin
case Column is
when 1 =>
if Modules_Sort_Order = NAMEASC then
Modules_Sort_Order := NAMEDESC;
else
Modules_Sort_Order := NAMEASC;
end if;
when 2 =>
if Modules_Sort_Order = DAMAGEASC then
Modules_Sort_Order := DAMAGEDESC;
else
Modules_Sort_Order := DAMAGEASC;
end if;
when others =>
null;
end case;
if Modules_Sort_Order = NONE then
return TCL_OK;
end if;
for I in Player_Ship.Modules.Iterate loop
Local_Modules(Modules_Container.To_Index(I)) :=
(Name => Player_Ship.Modules(I).Name,
Damage =>
Float(Player_Ship.Modules(I).Durability) /
Float(Player_Ship.Modules(I).Max_Durability),
Id => Modules_Container.To_Index(I));
end loop;
Sort_Modules(Local_Modules);
Modules_Indexes.Clear;
for Module of Local_Modules loop
Modules_Indexes.Append(Module.Id);
end loop;
UpdateModulesInfo;
return TCL_OK;
end Sort_Modules_Command;
procedure AddCommands is
begin
Add_Command("ShowModuleMenu", Show_Module_Menu_Command'Access);
Add_Command("ShowModuleInfo", Show_Module_Info_Command'Access);
Add_Command("SetUpgrade", Set_Upgrade_Command'Access);
Add_Command("AssignModule", Assign_Module_Command'Access);
Add_Command("DisableEngine", Disable_Engine_Command'Access);
Add_Command("StopUpgrading", Stop_Upgrading_Command'Access);
Add_Command("SetRepair", Set_Repair_Command'Access);
Add_Command("ResetDestination", Reset_Destination_Command'Access);
Add_Command("ShowAssignCrew", Show_Assign_Crew_Command'Access);
Add_Command("UpdateAssignCrew", Update_Assign_Crew_Command'Access);
Add_Command("ShowAssignSkill", Show_Assign_Skill_Command'Access);
Add_Command("CancelOrder", Cancel_Order_Command'Access);
Add_Command("GetActiveButton", Get_Active_Button_Command'Access);
Add_Command("ShowModules", Show_Modules_Command'Access);
Add_Command("SortShipModules", Sort_Modules_Command'Access);
end AddCommands;
end Ships.UI.Modules;
|
B : Arr_Type (1 .. 26);
begin
B(B'First) := 'a';
for I in B'First .. B'Last-1 loop
B(I+1) := Lower_Case'Succ(B(I));
end loop; -- now all the B(I) are different
|
-----------------------------------------------------------------------
-- security-permissions -- Definition of permissions
-- Copyright (C) 2010, 2011, 2016, 2017, 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.
-----------------------------------------------------------------------
with Ada.Containers.Indefinite_Hashed_Maps;
with Ada.Strings.Hash;
with Util.Strings.Tokenizers;
with Util.Log.Loggers;
-- The <b>Security.Permissions</b> package defines the different permissions that can be
-- checked by the access control manager.
package body Security.Permissions is
function Occurence (List : in String; Of_Char : in Character) return Natural;
-- The logger
Log : constant Util.Log.Loggers.Logger := Util.Log.Loggers.Create ("Security.Permissions");
-- A global map to translate a string to a permission index.
package Permission_Maps is
new Ada.Containers.Indefinite_Hashed_Maps (Key_Type => String,
Element_Type => Permission_Index,
Hash => Ada.Strings.Hash,
Equivalent_Keys => "=",
"=" => "=");
protected type Global_Index is
-- Get the permission index
function Get_Permission_Index (Name : in String) return Permission_Index;
-- Get the last permission index registered in the global permission map.
function Get_Last_Permission_Index return Permission_Index;
-- Get the permission name associated with the index.
function Get_Name (Index : in Permission_Index) return String;
procedure Add_Permission (Name : in String;
Index : out Permission_Index);
private
Map : Permission_Maps.Map;
Next_Index : Permission_Index := NONE + 1;
end Global_Index;
protected body Global_Index is
function Get_Permission_Index (Name : in String) return Permission_Index is
Pos : constant Permission_Maps.Cursor := Map.Find (Name);
begin
if Permission_Maps.Has_Element (Pos) then
return Permission_Maps.Element (Pos);
else
raise Invalid_Name with "There is no permission '" & Name & "'";
end if;
end Get_Permission_Index;
-- ------------------------------
-- Get the last permission index registered in the global permission map.
-- ------------------------------
function Get_Last_Permission_Index return Permission_Index is
begin
return Next_Index - 1;
end Get_Last_Permission_Index;
procedure Add_Permission (Name : in String;
Index : out Permission_Index) is
Pos : constant Permission_Maps.Cursor := Map.Find (Name);
begin
if Permission_Maps.Has_Element (Pos) then
Index := Permission_Maps.Element (Pos);
else
Index := Next_Index;
Log.Debug ("Creating permission index {1} for {0}",
Name, Permission_Index'Image (Index));
Map.Insert (Name, Index);
if Next_Index = Permission_Index'Last then
Log.Error ("Too many permission instantiated. "
& "Increase Security.Permissions.MAX_PERMISSION");
else
Next_Index := Next_Index + 1;
end if;
end if;
end Add_Permission;
-- ------------------------------
-- Get the permission name associated with the index.
-- ------------------------------
function Get_Name (Index : in Permission_Index) return String is
Iter : Permission_Maps.Cursor := Map.First;
begin
while Permission_Maps.Has_Element (Iter) loop
if Permission_Maps.Element (Iter) = Index then
return Permission_Maps.Key (Iter);
end if;
Permission_Maps.Next (Iter);
end loop;
return "";
end Get_Name;
end Global_Index;
Permission_Indexes : Global_Index;
-- ------------------------------
-- Get the permission index associated with the name.
-- ------------------------------
function Get_Permission_Index (Name : in String) return Permission_Index is
begin
return Permission_Indexes.Get_Permission_Index (Name);
end Get_Permission_Index;
function Occurence (List : in String; Of_Char : in Character) return Natural is
Count : Natural := 0;
begin
if List'Length > 0 then
Count := 1;
for C of List loop
if C = Of_Char then
Count := Count + 1;
end if;
end loop;
end if;
return Count;
end Occurence;
-- ------------------------------
-- Get the list of permissions whose name is given in the string with separated comma.
-- ------------------------------
function Get_Permission_Array (List : in String) return Permission_Index_Array is
procedure Process (Name : in String;
Done : out Boolean);
Result : Permission_Index_Array (1 .. Occurence (List, ','));
Count : Natural := 0;
procedure Process (Name : in String;
Done : out Boolean) is
begin
Done := False;
Result (Count + 1) := Get_Permission_Index (Name);
Count := Count + 1;
exception
when Invalid_Name =>
Log.Info ("Permission {0} does not exist", Name);
end Process;
begin
Util.Strings.Tokenizers.Iterate_Tokens (Content => List,
Pattern => ",",
Process => Process'Access,
Going => Ada.Strings.Forward);
return Result (1 .. Count);
end Get_Permission_Array;
-- ------------------------------
-- Get the permission name given the index.
-- ------------------------------
function Get_Name (Index : in Permission_Index) return String is
begin
return Permission_Indexes.Get_Name (Index);
end Get_Name;
-- ------------------------------
-- Get the last permission index registered in the global permission map.
-- ------------------------------
function Get_Last_Permission_Index return Permission_Index is
begin
return Permission_Indexes.Get_Last_Permission_Index;
end Get_Last_Permission_Index;
-- ------------------------------
-- Add the permission name and allocate a unique permission index.
-- ------------------------------
procedure Add_Permission (Name : in String;
Index : out Permission_Index) is
begin
Permission_Indexes.Add_Permission (Name, Index);
end Add_Permission;
-- ------------------------------
-- Check if the permission index set contains the given permission index.
-- ------------------------------
function Has_Permission (Set : in Permission_Index_Set;
Index : in Permission_Index) return Boolean is
use Interfaces;
begin
return (Set (Natural (Index / 8)) and Shift_Left (1, Natural (Index mod 8))) /= 0;
end Has_Permission;
-- ------------------------------
-- Add the permission index to the set.
-- ------------------------------
procedure Add_Permission (Set : in out Permission_Index_Set;
Index : in Permission_Index) is
use Interfaces;
Pos : constant Natural := Natural (Index / 8);
begin
Set (Pos) := Set (Pos) or Shift_Left (1, Natural (Index mod 8));
end Add_Permission;
package body Definition is
P : Permission_Index;
function Permission return Permission_Index is
begin
return P;
end Permission;
begin
Add_Permission (Name => Name, Index => P);
end Definition;
end Security.Permissions;
|
with Ada.Unchecked_Conversion;
with System;
package Subset
with SPARK_Mode => On
is
-- A few simple example of language constructs that currently violate the
-- SPARK subset.
-- Unchecked conversion with access type is not allowed in SPARK
type T is access Integer;
function Conv is new Ada.Unchecked_Conversion (System.Address, T);
-- Access discriminant is not allowed in SPARK
type R2 (D : access Boolean) is record
F1 : Integer;
end record;
-- Task requires the use of Ravenscar profile
task type My_Task;
end Subset;
|
package P is
X : Integer; -- Allocated in the result the package elaboration
end P;
|
------------------------------------------------------------------------------
-- A d a r u n - t i m e s p e c i f i c a t i o n --
-- ASIS implementation for Gela project, a portable Ada compiler --
-- http://gela.ada-ru.org --
-- - - - - - - - - - - - - - - - --
-- Read copyright and license at the end of ada.ads file --
------------------------------------------------------------------------------
-- $Revision: 209 $ $Date: 2013-11-30 21:03:24 +0200 (Сб., 30 нояб. 2013) $
package Ada.Tags is
pragma Preelaborate(Tags);
type Tag is private;
pragma Preelaborable_Initialization(Tag);
No_Tag : constant Tag;
function Expanded_Name (T : Tag) return String;
function Wide_Expanded_Name (T : Tag) return Wide_String;
function Wide_Wide_Expanded_Name (T : Tag) return Wide_Wide_String;
function External_Tag (T : Tag) return String;
function Internal_Tag (External : String) return Tag;
function Descendant_Tag (External : String; Ancestor : Tag) return Tag;
function Is_Descendant_At_Same_Level
(Descendant, Ancestor : Tag)
return Boolean;
function Parent_Tag (T : Tag) return Tag;
type Tag_Array is array (Positive range <>) of Tag;
function Interface_Ancestor_Tags (T : Tag) return Tag_Array;
Tag_Error : exception;
private
pragma Import (Ada, Tag);
pragma Import (Ada, No_Tag);
end Ada.Tags;
|
pragma Style_Checks (Off);
-- This spec has been automatically generated from ATSAMD51G19A.svd
pragma Restrictions (No_Elaboration_Code);
with HAL;
with System;
package SAM_SVD.EIC is
pragma Preelaborate;
---------------
-- Registers --
---------------
-- Clock Selection
type CTRLA_CKSELSelect is
(-- Clocked by GCLK
CLK_GCLK,
-- Clocked by ULP32K
CLK_ULP32K)
with Size => 1;
for CTRLA_CKSELSelect use
(CLK_GCLK => 0,
CLK_ULP32K => 1);
-- Control A
type EIC_CTRLA_Register is record
-- Software Reset
SWRST : Boolean := False;
-- Enable
ENABLE : Boolean := False;
-- unspecified
Reserved_2_3 : HAL.UInt2 := 16#0#;
-- Clock Selection
CKSEL : CTRLA_CKSELSelect := SAM_SVD.EIC.CLK_GCLK;
-- unspecified
Reserved_5_7 : HAL.UInt3 := 16#0#;
end record
with Volatile_Full_Access, Object_Size => 8,
Bit_Order => System.Low_Order_First;
for EIC_CTRLA_Register use record
SWRST at 0 range 0 .. 0;
ENABLE at 0 range 1 .. 1;
Reserved_2_3 at 0 range 2 .. 3;
CKSEL at 0 range 4 .. 4;
Reserved_5_7 at 0 range 5 .. 7;
end record;
-- Non-Maskable Interrupt Sense Configuration
type NMICTRL_NMISENSESelect is
(-- No detection
NONE,
-- Rising-edge detection
RISE,
-- Falling-edge detection
FALL,
-- Both-edges detection
BOTH,
-- High-level detection
HIGH,
-- Low-level detection
LOW)
with Size => 3;
for NMICTRL_NMISENSESelect use
(NONE => 0,
RISE => 1,
FALL => 2,
BOTH => 3,
HIGH => 4,
LOW => 5);
-- Asynchronous Edge Detection Mode
type NMICTRL_NMIASYNCHSelect is
(-- Edge detection is clock synchronously operated
SYNC,
-- Edge detection is clock asynchronously operated
ASYNC)
with Size => 1;
for NMICTRL_NMIASYNCHSelect use
(SYNC => 0,
ASYNC => 1);
-- Non-Maskable Interrupt Control
type EIC_NMICTRL_Register is record
-- Non-Maskable Interrupt Sense Configuration
NMISENSE : NMICTRL_NMISENSESelect := SAM_SVD.EIC.NONE;
-- Non-Maskable Interrupt Filter Enable
NMIFILTEN : Boolean := False;
-- Asynchronous Edge Detection Mode
NMIASYNCH : NMICTRL_NMIASYNCHSelect := SAM_SVD.EIC.SYNC;
-- unspecified
Reserved_5_7 : HAL.UInt3 := 16#0#;
end record
with Volatile_Full_Access, Object_Size => 8,
Bit_Order => System.Low_Order_First;
for EIC_NMICTRL_Register use record
NMISENSE at 0 range 0 .. 2;
NMIFILTEN at 0 range 3 .. 3;
NMIASYNCH at 0 range 4 .. 4;
Reserved_5_7 at 0 range 5 .. 7;
end record;
-- Non-Maskable Interrupt Flag Status and Clear
type EIC_NMIFLAG_Register is record
-- Non-Maskable Interrupt
NMI : Boolean := False;
-- unspecified
Reserved_1_15 : HAL.UInt15 := 16#0#;
end record
with Volatile_Full_Access, Object_Size => 16,
Bit_Order => System.Low_Order_First;
for EIC_NMIFLAG_Register use record
NMI at 0 range 0 .. 0;
Reserved_1_15 at 0 range 1 .. 15;
end record;
-- Synchronization Busy
type EIC_SYNCBUSY_Register is record
-- Read-only. Software Reset Synchronization Busy Status
SWRST : Boolean;
-- Read-only. Enable Synchronization Busy Status
ENABLE : Boolean;
-- unspecified
Reserved_2_31 : HAL.UInt30;
end record
with Volatile_Full_Access, Object_Size => 32,
Bit_Order => System.Low_Order_First;
for EIC_SYNCBUSY_Register use record
SWRST at 0 range 0 .. 0;
ENABLE at 0 range 1 .. 1;
Reserved_2_31 at 0 range 2 .. 31;
end record;
subtype EIC_EVCTRL_EXTINTEO_Field is HAL.UInt16;
-- Event Control
type EIC_EVCTRL_Register is record
-- External Interrupt Event Output Enable
EXTINTEO : EIC_EVCTRL_EXTINTEO_Field := 16#0#;
-- unspecified
Reserved_16_31 : HAL.UInt16 := 16#0#;
end record
with Volatile_Full_Access, Object_Size => 32,
Bit_Order => System.Low_Order_First;
for EIC_EVCTRL_Register use record
EXTINTEO at 0 range 0 .. 15;
Reserved_16_31 at 0 range 16 .. 31;
end record;
subtype EIC_INTENCLR_EXTINT_Field is HAL.UInt16;
-- Interrupt Enable Clear
type EIC_INTENCLR_Register is record
-- External Interrupt Enable
EXTINT : EIC_INTENCLR_EXTINT_Field := 16#0#;
-- unspecified
Reserved_16_31 : HAL.UInt16 := 16#0#;
end record
with Volatile_Full_Access, Object_Size => 32,
Bit_Order => System.Low_Order_First;
for EIC_INTENCLR_Register use record
EXTINT at 0 range 0 .. 15;
Reserved_16_31 at 0 range 16 .. 31;
end record;
subtype EIC_INTENSET_EXTINT_Field is HAL.UInt16;
-- Interrupt Enable Set
type EIC_INTENSET_Register is record
-- External Interrupt Enable
EXTINT : EIC_INTENSET_EXTINT_Field := 16#0#;
-- unspecified
Reserved_16_31 : HAL.UInt16 := 16#0#;
end record
with Volatile_Full_Access, Object_Size => 32,
Bit_Order => System.Low_Order_First;
for EIC_INTENSET_Register use record
EXTINT at 0 range 0 .. 15;
Reserved_16_31 at 0 range 16 .. 31;
end record;
subtype EIC_INTFLAG_EXTINT_Field is HAL.UInt16;
-- Interrupt Flag Status and Clear
type EIC_INTFLAG_Register is record
-- External Interrupt
EXTINT : EIC_INTFLAG_EXTINT_Field := 16#0#;
-- unspecified
Reserved_16_31 : HAL.UInt16 := 16#0#;
end record
with Volatile_Full_Access, Object_Size => 32,
Bit_Order => System.Low_Order_First;
for EIC_INTFLAG_Register use record
EXTINT at 0 range 0 .. 15;
Reserved_16_31 at 0 range 16 .. 31;
end record;
-- Asynchronous Edge Detection Mode
type ASYNCH_ASYNCHSelect is
(-- Edge detection is clock synchronously operated
SYNC,
-- Edge detection is clock asynchronously operated
ASYNC)
with Size => 16;
for ASYNCH_ASYNCHSelect use
(SYNC => 0,
ASYNC => 1);
-- External Interrupt Asynchronous Mode
type EIC_ASYNCH_Register is record
-- Asynchronous Edge Detection Mode
ASYNCH : ASYNCH_ASYNCHSelect := SAM_SVD.EIC.SYNC;
-- unspecified
Reserved_16_31 : HAL.UInt16 := 16#0#;
end record
with Volatile_Full_Access, Object_Size => 32,
Bit_Order => System.Low_Order_First;
for EIC_ASYNCH_Register use record
ASYNCH at 0 range 0 .. 15;
Reserved_16_31 at 0 range 16 .. 31;
end record;
-- Input Sense Configuration 0
type CONFIG_SENSE0Select is
(-- No detection
NONE,
-- Rising edge detection
RISE,
-- Falling edge detection
FALL,
-- Both edges detection
BOTH,
-- High level detection
HIGH,
-- Low level detection
LOW)
with Size => 3;
for CONFIG_SENSE0Select use
(NONE => 0,
RISE => 1,
FALL => 2,
BOTH => 3,
HIGH => 4,
LOW => 5);
-- Input Sense Configuration 1
type CONFIG_SENSE1Select is
(-- No detection
NONE,
-- Rising edge detection
RISE,
-- Falling edge detection
FALL,
-- Both edges detection
BOTH,
-- High level detection
HIGH,
-- Low level detection
LOW)
with Size => 3;
for CONFIG_SENSE1Select use
(NONE => 0,
RISE => 1,
FALL => 2,
BOTH => 3,
HIGH => 4,
LOW => 5);
-- Input Sense Configuration 2
type CONFIG_SENSE2Select is
(-- No detection
NONE,
-- Rising edge detection
RISE,
-- Falling edge detection
FALL,
-- Both edges detection
BOTH,
-- High level detection
HIGH,
-- Low level detection
LOW)
with Size => 3;
for CONFIG_SENSE2Select use
(NONE => 0,
RISE => 1,
FALL => 2,
BOTH => 3,
HIGH => 4,
LOW => 5);
-- Input Sense Configuration 3
type CONFIG_SENSE3Select is
(-- No detection
NONE,
-- Rising edge detection
RISE,
-- Falling edge detection
FALL,
-- Both edges detection
BOTH,
-- High level detection
HIGH,
-- Low level detection
LOW)
with Size => 3;
for CONFIG_SENSE3Select use
(NONE => 0,
RISE => 1,
FALL => 2,
BOTH => 3,
HIGH => 4,
LOW => 5);
-- Input Sense Configuration 4
type CONFIG_SENSE4Select is
(-- No detection
NONE,
-- Rising edge detection
RISE,
-- Falling edge detection
FALL,
-- Both edges detection
BOTH,
-- High level detection
HIGH,
-- Low level detection
LOW)
with Size => 3;
for CONFIG_SENSE4Select use
(NONE => 0,
RISE => 1,
FALL => 2,
BOTH => 3,
HIGH => 4,
LOW => 5);
-- Input Sense Configuration 5
type CONFIG_SENSE5Select is
(-- No detection
NONE,
-- Rising edge detection
RISE,
-- Falling edge detection
FALL,
-- Both edges detection
BOTH,
-- High level detection
HIGH,
-- Low level detection
LOW)
with Size => 3;
for CONFIG_SENSE5Select use
(NONE => 0,
RISE => 1,
FALL => 2,
BOTH => 3,
HIGH => 4,
LOW => 5);
-- Input Sense Configuration 6
type CONFIG_SENSE6Select is
(-- No detection
NONE,
-- Rising edge detection
RISE,
-- Falling edge detection
FALL,
-- Both edges detection
BOTH,
-- High level detection
HIGH,
-- Low level detection
LOW)
with Size => 3;
for CONFIG_SENSE6Select use
(NONE => 0,
RISE => 1,
FALL => 2,
BOTH => 3,
HIGH => 4,
LOW => 5);
-- Input Sense Configuration 7
type CONFIG_SENSE7Select is
(-- No detection
NONE,
-- Rising edge detection
RISE,
-- Falling edge detection
FALL,
-- Both edges detection
BOTH,
-- High level detection
HIGH,
-- Low level detection
LOW)
with Size => 3;
for CONFIG_SENSE7Select use
(NONE => 0,
RISE => 1,
FALL => 2,
BOTH => 3,
HIGH => 4,
LOW => 5);
-- External Interrupt Sense Configuration
type EIC_CONFIG_Register is record
-- Input Sense Configuration 0
SENSE0 : CONFIG_SENSE0Select := SAM_SVD.EIC.NONE;
-- Filter Enable 0
FILTEN0 : Boolean := False;
-- Input Sense Configuration 1
SENSE1 : CONFIG_SENSE1Select := SAM_SVD.EIC.NONE;
-- Filter Enable 1
FILTEN1 : Boolean := False;
-- Input Sense Configuration 2
SENSE2 : CONFIG_SENSE2Select := SAM_SVD.EIC.NONE;
-- Filter Enable 2
FILTEN2 : Boolean := False;
-- Input Sense Configuration 3
SENSE3 : CONFIG_SENSE3Select := SAM_SVD.EIC.NONE;
-- Filter Enable 3
FILTEN3 : Boolean := False;
-- Input Sense Configuration 4
SENSE4 : CONFIG_SENSE4Select := SAM_SVD.EIC.NONE;
-- Filter Enable 4
FILTEN4 : Boolean := False;
-- Input Sense Configuration 5
SENSE5 : CONFIG_SENSE5Select := SAM_SVD.EIC.NONE;
-- Filter Enable 5
FILTEN5 : Boolean := False;
-- Input Sense Configuration 6
SENSE6 : CONFIG_SENSE6Select := SAM_SVD.EIC.NONE;
-- Filter Enable 6
FILTEN6 : Boolean := False;
-- Input Sense Configuration 7
SENSE7 : CONFIG_SENSE7Select := SAM_SVD.EIC.NONE;
-- Filter Enable 7
FILTEN7 : Boolean := False;
end record
with Volatile_Full_Access, Object_Size => 32,
Bit_Order => System.Low_Order_First;
for EIC_CONFIG_Register use record
SENSE0 at 0 range 0 .. 2;
FILTEN0 at 0 range 3 .. 3;
SENSE1 at 0 range 4 .. 6;
FILTEN1 at 0 range 7 .. 7;
SENSE2 at 0 range 8 .. 10;
FILTEN2 at 0 range 11 .. 11;
SENSE3 at 0 range 12 .. 14;
FILTEN3 at 0 range 15 .. 15;
SENSE4 at 0 range 16 .. 18;
FILTEN4 at 0 range 19 .. 19;
SENSE5 at 0 range 20 .. 22;
FILTEN5 at 0 range 23 .. 23;
SENSE6 at 0 range 24 .. 26;
FILTEN6 at 0 range 27 .. 27;
SENSE7 at 0 range 28 .. 30;
FILTEN7 at 0 range 31 .. 31;
end record;
-- External Interrupt Sense Configuration
type EIC_CONFIG_Registers is array (0 .. 1) of EIC_CONFIG_Register;
subtype EIC_DEBOUNCEN_DEBOUNCEN_Field is HAL.UInt16;
-- Debouncer Enable
type EIC_DEBOUNCEN_Register is record
-- Debouncer Enable
DEBOUNCEN : EIC_DEBOUNCEN_DEBOUNCEN_Field := 16#0#;
-- unspecified
Reserved_16_31 : HAL.UInt16 := 16#0#;
end record
with Volatile_Full_Access, Object_Size => 32,
Bit_Order => System.Low_Order_First;
for EIC_DEBOUNCEN_Register use record
DEBOUNCEN at 0 range 0 .. 15;
Reserved_16_31 at 0 range 16 .. 31;
end record;
-- Debouncer Prescaler
type DPRESCALER_PRESCALER0Select is
(-- EIC clock divided by 2
DIV2,
-- EIC clock divided by 4
DIV4,
-- EIC clock divided by 8
DIV8,
-- EIC clock divided by 16
DIV16,
-- EIC clock divided by 32
DIV32,
-- EIC clock divided by 64
DIV64,
-- EIC clock divided by 128
DIV128,
-- EIC clock divided by 256
DIV256)
with Size => 3;
for DPRESCALER_PRESCALER0Select use
(DIV2 => 0,
DIV4 => 1,
DIV8 => 2,
DIV16 => 3,
DIV32 => 4,
DIV64 => 5,
DIV128 => 6,
DIV256 => 7);
-- Debouncer number of states
type DPRESCALER_STATES0Select is
(-- 3 low frequency samples
LFREQ3,
-- 7 low frequency samples
LFREQ7)
with Size => 1;
for DPRESCALER_STATES0Select use
(LFREQ3 => 0,
LFREQ7 => 1);
-- Debouncer Prescaler
type DPRESCALER_PRESCALER1Select is
(-- EIC clock divided by 2
DIV2,
-- EIC clock divided by 4
DIV4,
-- EIC clock divided by 8
DIV8,
-- EIC clock divided by 16
DIV16,
-- EIC clock divided by 32
DIV32,
-- EIC clock divided by 64
DIV64,
-- EIC clock divided by 128
DIV128,
-- EIC clock divided by 256
DIV256)
with Size => 3;
for DPRESCALER_PRESCALER1Select use
(DIV2 => 0,
DIV4 => 1,
DIV8 => 2,
DIV16 => 3,
DIV32 => 4,
DIV64 => 5,
DIV128 => 6,
DIV256 => 7);
-- Debouncer number of states
type DPRESCALER_STATES1Select is
(-- 3 low frequency samples
LFREQ3,
-- 7 low frequency samples
LFREQ7)
with Size => 1;
for DPRESCALER_STATES1Select use
(LFREQ3 => 0,
LFREQ7 => 1);
-- Pin Sampler frequency selection
type DPRESCALER_TICKONSelect is
(-- Clocked by GCLK
CLK_GCLK_EIC,
-- Clocked by Low Frequency Clock
CLK_LFREQ)
with Size => 1;
for DPRESCALER_TICKONSelect use
(CLK_GCLK_EIC => 0,
CLK_LFREQ => 1);
-- Debouncer Prescaler
type EIC_DPRESCALER_Register is record
-- Debouncer Prescaler
PRESCALER0 : DPRESCALER_PRESCALER0Select := SAM_SVD.EIC.DIV2;
-- Debouncer number of states
STATES0 : DPRESCALER_STATES0Select := SAM_SVD.EIC.LFREQ3;
-- Debouncer Prescaler
PRESCALER1 : DPRESCALER_PRESCALER1Select := SAM_SVD.EIC.DIV2;
-- Debouncer number of states
STATES1 : DPRESCALER_STATES1Select := SAM_SVD.EIC.LFREQ3;
-- unspecified
Reserved_8_15 : HAL.UInt8 := 16#0#;
-- Pin Sampler frequency selection
TICKON : DPRESCALER_TICKONSelect := SAM_SVD.EIC.CLK_GCLK_EIC;
-- unspecified
Reserved_17_31 : HAL.UInt15 := 16#0#;
end record
with Volatile_Full_Access, Object_Size => 32,
Bit_Order => System.Low_Order_First;
for EIC_DPRESCALER_Register use record
PRESCALER0 at 0 range 0 .. 2;
STATES0 at 0 range 3 .. 3;
PRESCALER1 at 0 range 4 .. 6;
STATES1 at 0 range 7 .. 7;
Reserved_8_15 at 0 range 8 .. 15;
TICKON at 0 range 16 .. 16;
Reserved_17_31 at 0 range 17 .. 31;
end record;
subtype EIC_PINSTATE_PINSTATE_Field is HAL.UInt16;
-- Pin State
type EIC_PINSTATE_Register is record
-- Read-only. Pin State
PINSTATE : EIC_PINSTATE_PINSTATE_Field;
-- unspecified
Reserved_16_31 : HAL.UInt16;
end record
with Volatile_Full_Access, Object_Size => 32,
Bit_Order => System.Low_Order_First;
for EIC_PINSTATE_Register use record
PINSTATE at 0 range 0 .. 15;
Reserved_16_31 at 0 range 16 .. 31;
end record;
-----------------
-- Peripherals --
-----------------
-- External Interrupt Controller
type EIC_Peripheral is record
-- Control A
CTRLA : aliased EIC_CTRLA_Register;
-- Non-Maskable Interrupt Control
NMICTRL : aliased EIC_NMICTRL_Register;
-- Non-Maskable Interrupt Flag Status and Clear
NMIFLAG : aliased EIC_NMIFLAG_Register;
-- Synchronization Busy
SYNCBUSY : aliased EIC_SYNCBUSY_Register;
-- Event Control
EVCTRL : aliased EIC_EVCTRL_Register;
-- Interrupt Enable Clear
INTENCLR : aliased EIC_INTENCLR_Register;
-- Interrupt Enable Set
INTENSET : aliased EIC_INTENSET_Register;
-- Interrupt Flag Status and Clear
INTFLAG : aliased EIC_INTFLAG_Register;
-- External Interrupt Asynchronous Mode
ASYNCH : aliased EIC_ASYNCH_Register;
-- External Interrupt Sense Configuration
CONFIG : aliased EIC_CONFIG_Registers;
-- Debouncer Enable
DEBOUNCEN : aliased EIC_DEBOUNCEN_Register;
-- Debouncer Prescaler
DPRESCALER : aliased EIC_DPRESCALER_Register;
-- Pin State
PINSTATE : aliased EIC_PINSTATE_Register;
end record
with Volatile;
for EIC_Peripheral use record
CTRLA at 16#0# range 0 .. 7;
NMICTRL at 16#1# range 0 .. 7;
NMIFLAG at 16#2# range 0 .. 15;
SYNCBUSY at 16#4# range 0 .. 31;
EVCTRL at 16#8# range 0 .. 31;
INTENCLR at 16#C# range 0 .. 31;
INTENSET at 16#10# range 0 .. 31;
INTFLAG at 16#14# range 0 .. 31;
ASYNCH at 16#18# range 0 .. 31;
CONFIG at 16#1C# range 0 .. 63;
DEBOUNCEN at 16#30# range 0 .. 31;
DPRESCALER at 16#34# range 0 .. 31;
PINSTATE at 16#38# range 0 .. 31;
end record;
-- External Interrupt Controller
EIC_Periph : aliased EIC_Peripheral
with Import, Address => EIC_Base;
end SAM_SVD.EIC;
|
with impact.d2.Colliders,
impact.d2.Shape.polygon;
package body impact.d2.Contact.polygon
is
function to_b2CircleContact (fixtureA, fixtureB : access fixture.b2Fixture'Class) return b2PolygonContact
is
use type shape.Kind;
new_Contact : Contact.polygon.b2PolygonContact;
begin
define (new_Contact, fixtureA, fixtureB);
pragma Assert (new_Contact.m_fixtureA.GetKind = Shape.e_polygon);
pragma Assert (new_Contact.m_fixtureB.GetKind = Shape.e_polygon);
return new_Contact;
end to_b2CircleContact;
overriding procedure Evaluate (Self : in out b2PolygonContact; manifold : access collision.b2Manifold;
xfA, xfB : in b2Transform)
is
begin
colliders.b2CollidePolygons (manifold,
Shape.polygon.view (Self.m_fixtureA.GetShape), xfA,
Shape.polygon.view (Self.m_fixtureB.GetShape), xfB);
end Evaluate;
function Create (fixtureA, fixtureB : access Fixture.b2Fixture) return access b2Contact'Class
is
new_Contact : constant Contact.polygon.view := new Contact.polygon.b2PolygonContact;
begin
define (new_Contact.all, fixtureA, fixtureB);
return new_Contact.all'Access;
end Create;
procedure Destroy (contact : in out impact.d2.Contact.view)
is
begin
contact.destruct;
free (contact);
end Destroy;
end impact.d2.Contact.polygon;
|
package body openGL.surface_Profile.privvy
is
function to_GLX (Self : in Item'Class) return glx.FBConfig
is
begin
return Self.glx_Config;
end to_GLX;
end openGL.surface_Profile.privvy;
|
------------------------------------------------------------------------------
-- --
-- Copyright (C) 2015-2017, AdaCore --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions are --
-- met: --
-- 1. Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- 2. Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in --
-- the documentation and/or other materials provided with the --
-- distribution. --
-- 3. Neither the name of the copyright holder nor the names of its --
-- contributors may be used to endorse or promote products derived --
-- from this software without specific prior written permission. --
-- --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR --
-- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
-- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT --
-- LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, --
-- DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY --
-- THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT --
-- (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE --
-- OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
-- --
------------------------------------------------------------------------------
-- This packages provide a low level driver for the FAT file system
-- architecture. It is recommended to _not_ use this interface directly but to
-- access the file system using the File_IO package. For more info, see the
-- file system chapter of the documentation.
with Ada.Unchecked_Conversion;
package body Filesystem.FAT.Directories is
subtype Entry_Data is Block (1 .. 32);
function To_Data is new Ada.Unchecked_Conversion
(FAT_Directory_Entry, Entry_Data);
function To_Data is new Ada.Unchecked_Conversion
(VFAT_Directory_Entry, Entry_Data);
function Find_Empty_Entry_Sequence
(Parent : access FAT_Directory_Handle;
Num_Entries : Natural) return Entry_Index;
-- Finds a sequence of deleted entries that can fit Num_Entries.
-- Returns the first entry of this sequence
--------------
-- Set_Size --
--------------
procedure Set_Size
(E : in out FAT_Node;
Size : FAT_File_Size)
is
begin
if E.Size /= Size then
E.Size := Size;
E.Is_Dirty := True;
end if;
end Set_Size;
----------
-- Find --
----------
function Find
(Parent : FAT_Node;
Filename : FAT_Name;
DEntry : out FAT_Node) return Status_Code
is
-- We use a copy of the handle, so as not to touch the state of initial
-- handle
Status : Status_Code;
Cluster : Cluster_Type := Parent.Start_Cluster;
Block : Block_Offset := Parent.FS.Cluster_To_Block (Cluster);
Index : Entry_Index := 0;
begin
loop
Status := Next_Entry
(FS => Parent.FS,
Current_Cluster => Cluster,
Current_Block => Block,
Current_Index => Index,
DEntry => DEntry);
if Status /= OK then
return No_Such_File;
end if;
if Long_Name (DEntry) = Filename or else
(DEntry.L_Name.Len = 0 and then Short_Name (DEntry) = Filename)
then
return OK;
end if;
end loop;
end Find;
----------
-- Find --
----------
function Find
(FS : in out FAT_Filesystem;
Path : String;
DEntry : out FAT_Node) return Status_Code
is
Status : Status_Code;
Idx : Natural; -- Idx is used to walk through the Path
Token : FAT_Name;
begin
DEntry := Root_Entry (FS);
-- Looping through the Path. We start at 2 as we ignore the initial '/'
Idx := Path'First + 1;
while Idx <= Path'Last loop
Token.Len := 0;
for J in Idx .. Path'Last loop
if Path (J) = '/' then
exit;
end if;
Token.Len := Token.Len + 1;
Token.Name (Token.Len) := Path (J);
end loop;
Idx := Idx + Token.Len + 1;
Status := Find (DEntry, Token, DEntry);
if Status /= OK then
return No_Such_File;
end if;
if Idx < Path'Last then
-- Intermediate entry: needs to be a directory
if not Is_Subdirectory (DEntry) then
return No_Such_Path;
end if;
end if;
end loop;
return OK;
end Find;
------------------
-- Update_Entry --
------------------
function Update_Entry
(Parent : FAT_Node;
Value : in out FAT_Node) return Status_Code
is
subtype Entry_Block is Block (1 .. 32);
function To_Block is new
Ada.Unchecked_Conversion (FAT_Directory_Entry, Entry_Block);
function To_Entry is new
Ada.Unchecked_Conversion (Entry_Block, FAT_Directory_Entry);
Ent : FAT_Directory_Entry;
Cluster : Cluster_Type := Parent.Start_Cluster;
Offset : FAT_File_Size := FAT_File_Size (Value.Index) * 32;
Block_Off : Natural;
Block : Block_Offset;
Ret : Status_Code;
begin
if not Value.Is_Dirty then
return OK;
end if;
while Offset > Parent.FS.Cluster_Size loop
Cluster := Parent.FS.Get_FAT (Cluster);
Offset := Offset - Parent.FS.Cluster_Size;
end loop;
Block := Block_Offset (Offset / Parent.FS.Block_Size);
Block_Off := Natural (Offset mod Parent.FS.Block_Size);
Ret := Parent.FS.Ensure_Block
(Parent.FS.Cluster_To_Block (Cluster) + Block);
if Ret /= OK then
return Ret;
end if;
Ent := To_Entry (Parent.FS.Window (Block_Off .. Block_Off + 31));
-- For now only the size can be modified, so just apply this
-- modification
Ent.Size := Value.Size;
Value.Is_Dirty := False;
Parent.FS.Window (Block_Off .. Block_Off + 31) := To_Block (Ent);
Ret := Parent.FS.Write_Window;
return Ret;
end Update_Entry;
----------------
-- Root_Entry --
----------------
function Root_Entry (FS : in out FAT_Filesystem) return FAT_Node
is
Ret : FAT_Node;
begin
Ret.FS := FS'Unchecked_Access;
Ret.Attributes := (Subdirectory => True,
others => False);
Ret.Is_Root := True;
Ret.L_Name := (Name => (others => ' '),
Len => 0);
if FS.Version = FAT16 then
Ret.Start_Cluster := 0;
else
Ret.Start_Cluster := FS.Root_Dir_Cluster;
end if;
Ret.Index := 0;
return Ret;
end Root_Entry;
----------------
-- Next_Entry --
----------------
function Next_Entry
(FS : access FAT_Filesystem;
Current_Cluster : in out Cluster_Type;
Current_Block : in out Block_Offset;
Current_Index : in out Entry_Index;
DEntry : out FAT_Directory_Entry) return Status_Code
is
subtype Entry_Data is Block (1 .. 32);
function To_Entry is new Ada.Unchecked_Conversion
(Entry_Data, FAT_Directory_Entry);
Ret : Status_Code;
Block_Off : Natural;
begin
if Current_Index = 16#FFFF# then
return No_More_Entries;
end if;
if Current_Cluster = 0 and then FS.Version = FAT16 then
if Current_Index >
Entry_Index (FS.FAT16_Root_Dir_Num_Entries)
then
return No_More_Entries;
else
Block_Off :=
Natural (FAT_File_Size (Current_Index * 32) mod
FS.Block_Size);
Current_Block :=
FS.Root_Dir_Area +
Block_Offset
(FAT_File_Size (Current_Index * 32) / FS.Block_Size);
end if;
else
Block_Off := Natural
(FAT_File_Size (Current_Index * 32) mod FS.Block_Size);
-- Check if we're on a block boundare
if Unsigned_32 (Block_Off) = 0 and then Current_Index /= 0 then
Current_Block := Current_Block + 1;
end if;
-- Check if we're on the boundary of a new cluster
if Current_Block - FS.Cluster_To_Block (Current_Cluster)
= FS.Blocks_Per_Cluster
then
-- The block we need to read is outside of the current cluster.
-- Let's move on to the next
-- Read the FAT table to determine the next cluster
Current_Cluster := FS.Get_FAT (Current_Cluster);
if Current_Cluster = 1
or else FS.Is_Last_Cluster (Current_Cluster)
then
return Internal_Error;
end if;
Current_Block := FS.Cluster_To_Block (Current_Cluster);
end if;
end if;
Ret := FS.Ensure_Block (Current_Block);
if Ret /= OK then
return Ret;
end if;
if FS.Window (Block_Off) = 0 then
-- End of entries: we stick the index here to make sure that further
-- calls to Next_Entry always end-up here
return No_More_Entries;
end if;
DEntry := To_Entry (FS.Window (Block_Off .. Block_Off + 31));
Current_Index := Current_Index + 1;
return OK;
end Next_Entry;
----------------
-- Next_Entry --
----------------
function Next_Entry
(FS : access FAT_Filesystem;
Current_Cluster : in out Cluster_Type;
Current_Block : in out Block_Offset;
Current_Index : in out Entry_Index;
DEntry : out FAT_Node) return Status_Code
is
procedure Prepend
(Name : Wide_String;
Full : in out String;
Idx : in out Natural);
-- Prepends Name to Full
-------------
-- Prepend --
-------------
procedure Prepend
(Name : Wide_String;
Full : in out String;
Idx : in out Natural)
is
Val : Unsigned_16;
begin
for J in reverse Name'Range loop
Val := Wide_Character'Pos (Name (J));
if Val /= 16#FFFF#
and then Val /= 0
then
Idx := Idx - 1;
exit when Idx not in Full'Range;
if Val < 255 then
Full (Idx) := Character'Val (Val);
elsif Val = 16#F029# then
-- Path ends with a '.'
Full (Idx) := '.';
elsif Val = 16#F028# then
-- Path ends with a ' '
Full (Idx) := ' ';
else
Full (Idx) := '?';
end if;
end if;
end loop;
end Prepend;
Ret : Status_Code;
D_Entry : FAT_Directory_Entry;
V_Entry : VFAT_Directory_Entry;
function To_VFAT_Entry is new Ada.Unchecked_Conversion
(FAT_Directory_Entry, VFAT_Directory_Entry);
C : Unsigned_8;
Last_Seq : VFAT_Sequence_Number := 0;
CRC : Unsigned_8 := 0;
Matches : Boolean;
Current_CRC : Unsigned_8;
L_Name : String (1 .. MAX_FILENAME_LENGTH);
L_Name_First : Natural;
begin
L_Name_First := L_Name'Last + 1;
loop
Ret := Next_Entry
(FS,
Current_Cluster => Current_Cluster,
Current_Block => Current_Block,
Current_Index => Current_Index,
DEntry => D_Entry);
if Ret /= OK then
return Ret;
end if;
-- Check if we have a VFAT entry here by checking that the
-- attributes are 16#0F# (e.g. all attributes set except
-- subdirectory and archive)
if D_Entry.Attributes = VFAT_Directory_Entry_Attribute then
V_Entry := To_VFAT_Entry (D_Entry);
if V_Entry.VFAT_Attr.Stop_Bit then
L_Name_First := L_Name'Last + 1;
else
if Last_Seq = 0
or else Last_Seq - 1 /= V_Entry.VFAT_Attr.Sequence
then
L_Name_First := L_Name'Last + 1;
end if;
end if;
Last_Seq := V_Entry.VFAT_Attr.Sequence;
Prepend (V_Entry.Name_3, L_Name, L_Name_First);
Prepend (V_Entry.Name_2, L_Name, L_Name_First);
Prepend (V_Entry.Name_1, L_Name, L_Name_First);
if V_Entry.VFAT_Attr.Sequence = 1 then
CRC := V_Entry.Checksum;
end if;
-- Ignore Volumes and deleted files
elsif not D_Entry.Attributes.Volume_Label
and then Character'Pos (D_Entry.Filename (1)) /= 16#E5#
then
if L_Name_First not in L_Name'Range then
Matches := False;
else
Current_CRC := 0;
Last_Seq := 0;
for Ch of String'(D_Entry.Filename & D_Entry.Extension) loop
C := Character'Enum_Rep (Ch);
Current_CRC := Shift_Right (Current_CRC and 16#FE#, 1)
or Shift_Left (Current_CRC and 16#01#, 7);
-- Modulo addition
Current_CRC := Current_CRC + C;
end loop;
Matches := Current_CRC = CRC;
end if;
DEntry :=
(FS => FAT_Filesystem_Access (FS),
L_Name => <>,
S_Name => D_Entry.Filename,
S_Name_Ext => D_Entry.Extension,
Attributes => D_Entry.Attributes,
Start_Cluster => (if FS.Version = FAT16
then Cluster_Type (D_Entry.Cluster_L)
else Cluster_Type (D_Entry.Cluster_L) or
Shift_Left
(Cluster_Type (D_Entry.Cluster_H), 16)),
Size => D_Entry.Size,
Index => Current_Index - 1,
Is_Root => False,
Is_Dirty => False);
if Matches then
DEntry.L_Name := -L_Name (L_Name_First .. L_Name'Last);
else
DEntry.L_Name.Len := 0;
end if;
return OK;
end if;
end loop;
end Next_Entry;
----------
-- Read --
----------
function Read
(Dir : in out FAT_Directory_Handle;
DEntry : out FAT_Node) return Status_Code
is
begin
return Next_Entry
(Dir.FS,
Current_Cluster => Dir.Current_Cluster,
Current_Block => Dir.Current_Block,
Current_Index => Dir.Current_Index,
DEntry => DEntry);
end Read;
-------------------
-- Create_Subdir --
-------------------
function Create_Subdir
(Dir : FAT_Node;
Name : FAT_Name;
New_Dir : out FAT_Node) return Status_Code
is
Handle : FAT_Directory_Handle_Access;
Ret : Status_Code;
Block : Block_Offset;
Dot : FAT_Directory_Entry;
Dot_Dot : FAT_Directory_Entry;
begin
Ret := Dir.FAT_Open (Handle);
if Ret /= OK then
return Ret;
end if;
Ret := Allocate_Entry
(Parent => Handle,
Name => Name,
Attributes => (Read_Only => False,
Hidden => False,
System_File => False,
Volume_Label => False,
Subdirectory => True,
Archive => False),
E => New_Dir);
if Ret /= OK then
return Ret;
end if;
Block := Dir.FS.Cluster_To_Block (New_Dir.Start_Cluster);
Ret := Handle.FS.Ensure_Block (Block);
if Ret /= OK then
return Ret;
end if;
-- Allocate '.', '..' and the directory entry terminator
Dot :=
(Filename => (1 => '.', others => ' '),
Extension => (others => ' '),
Attributes => (Read_Only => False,
Hidden => False,
System_File => False,
Volume_Label => False,
Subdirectory => True,
Archive => False),
Reserved => (others => ASCII.NUL),
Cluster_H =>
Unsigned_16
(Shift_Right
(Unsigned_32
(New_Dir.Start_Cluster) and 16#FFFF_0000#, 16)),
Time => 0,
Date => 0,
Cluster_L => Unsigned_16 (New_Dir.Start_Cluster and 16#FFFF#),
Size => 0);
Dot_Dot :=
(Filename => (1 .. 2 => '.', others => ' '),
Extension => (others => ' '),
Attributes => (Read_Only => False,
Hidden => False,
System_File => False,
Volume_Label => False,
Subdirectory => True,
Archive => False),
Reserved => (others => ASCII.NUL),
Cluster_H =>
Unsigned_16
(Shift_Right
(Unsigned_32 (Handle.Start_Cluster) and 16#FFFF_0000#, 16)),
Time => 0,
Date => 0,
Cluster_L => Unsigned_16 (Handle.Start_Cluster and 16#FFFF#),
Size => 0);
Handle.FS.Window (0 .. 31) := To_Data (Dot);
Handle.FS.Window (32 .. 63) := To_Data (Dot_Dot);
Handle.FS.Window (64 .. 95) := (others => 0);
Ret := Handle.FS.Write_Window;
Close (Handle.all);
return Ret;
end Create_Subdir;
----------------------
-- Create_File_Node --
----------------------
function Create_File_Node
(Dir : FAT_Node;
Name : FAT_Name;
New_File : out FAT_Node) return Status_Code
is
Handle : FAT_Directory_Handle_Access;
Ret : Status_Code;
begin
Ret := Dir.FAT_Open (Handle);
if Ret /= OK then
return Ret;
end if;
Ret := Allocate_Entry
(Parent => Handle,
Name => Name,
Attributes => (Read_Only => False,
Hidden => False,
System_File => False,
Volume_Label => False,
Subdirectory => False,
Archive => True),
E => New_File);
Close (Handle.all);
if Ret /= OK then
return Ret;
end if;
return Ret;
end Create_File_Node;
-------------------
-- Delete_Subdir --
-------------------
function Delete_Subdir
(Dir : FAT_Node;
Recursive : Boolean) return Status_Code
is
Parent : FAT_Node;
Handle : FAT_Directory_Handle_Access;
Ent : FAT_Node;
Ret : Status_Code;
begin
Ret := Dir.FAT_Open (Handle);
if Ret /= OK then
return Ret;
end if;
while Read (Handle.all, Ent) = OK loop
if -Long_Name (Ent) = "." then
null;
elsif -Long_Name (Ent) = ".." then
Parent := Ent;
elsif not Recursive then
return Non_Empty_Directory;
else
if Ent.Attributes.Subdirectory then
Ret := Delete_Subdir (Ent, True);
else
Ret := Delete_Entry (Dir, Ent);
end if;
if Ret /= OK then
Close (Handle.all);
return Ret;
end if;
end if;
end loop;
Close (Handle.all);
-- Free the clusters associated to the subdirectory
Ret := Delete_Entry (Parent, Dir);
if Ret /= OK then
return Ret;
end if;
return Ret;
end Delete_Subdir;
------------------
-- Delete_Entry --
------------------
function Delete_Entry
(Dir : FAT_Node;
Ent : FAT_Node) return Status_Code
is
Current : Cluster_Type := Ent.Start_Cluster;
Handle : FAT_Directory_Handle_Access;
Next : Cluster_Type;
Child_Ent : FAT_Node;
Ret : Status_Code;
Block_Off : Natural;
begin
-- Mark the entry's cluster chain as available
loop
Next := Ent.FS.Get_FAT (Current);
Ret := Ent.FS.Set_FAT (Current, FREE_CLUSTER_VALUE);
exit when Ret /= OK;
exit when Ent.FS.Is_Last_Cluster (Next);
Current := Next;
end loop;
-- Mark the parent's entry as deleted
Ret := Dir.FAT_Open (Handle);
if Ret /= OK then
return Ret;
end if;
while Read (Handle.all, Child_Ent) = OK loop
if Long_Name (Child_Ent) = Long_Name (Ent) then
Block_Off := Natural
((FAT_File_Size (Handle.Current_Index - 1) * 32)
mod Dir.FS.Block_Size);
-- Mark the entry as deleted: first basename character set to
-- 16#E5#
Handle.FS.Window (Block_Off) := 16#E5#;
Ret := Handle.FS.Write_Window;
exit;
end if;
end loop;
Close (Handle.all);
return Ret;
end Delete_Entry;
---------------------
-- Adjust_Clusters --
---------------------
function Adjust_Clusters (Ent : FAT_Node) return Status_Code
is
B_Per_Cluster : constant FAT_File_Size :=
FAT_File_Size (Ent.FS.Blocks_Per_Cluster) *
Ent.FS.Block_Size;
Size : FAT_File_Size := Ent.Size;
Current : Cluster_Type := Ent.Start_Cluster;
Next : Cluster_Type;
Ret : Status_Code := OK;
begin
if Ent.Attributes.Subdirectory then
-- ??? Do nothing for now
return OK;
end if;
loop
Next := Ent.FS.Get_FAT (Current);
if Size > B_Per_Cluster then
-- Current cluster is fully used
Size := Size - B_Per_Cluster;
elsif Size > 0 or else Current = Ent.Start_Cluster then
-- Partially used cluster, but the last one
Size := 0;
if Next /= LAST_CLUSTER_VALUE then
Ret := Ent.FS.Set_FAT (Current, LAST_CLUSTER_VALUE);
end if;
else
-- We don't need more clusters
Ret := Ent.FS.Set_FAT (Current, FREE_CLUSTER_VALUE);
end if;
exit when Ret /= OK;
exit when Ent.FS.Is_Last_Cluster (Next);
Current := Next;
Size := Size - B_Per_Cluster;
end loop;
return Ret;
end Adjust_Clusters;
-------------------------------
-- Find_Empty_Entry_Sequence --
-------------------------------
function Find_Empty_Entry_Sequence
(Parent : access FAT_Directory_Handle;
Num_Entries : Natural) return Entry_Index
is
Status : Status_Code;
D_Entry : FAT_Directory_Entry;
Sequence : Natural := 0;
Ret : Entry_Index;
Cluster : Cluster_Type := Parent.Start_Cluster;
Block : Block_Offset := Cluster_To_Block (Parent.FS.all, Cluster);
begin
Parent.Current_Index := 0;
loop
Status := Next_Entry
(Parent.FS,
Current_Cluster => Cluster,
Current_Block => Block,
Current_Index => Parent.Current_Index,
DEntry => D_Entry);
if Status /= OK then
return Null_Index;
end if;
if D_Entry.Attributes = VFAT_Directory_Entry_Attribute then
if Sequence = 0 then
-- Parent.Current_Index points to the next unread value.
-- So the just read entry is at Parent.Current_Index - 1
Ret := Parent.Current_Index - 1;
end if;
Sequence := Sequence + 1;
elsif Character'Pos (D_Entry.Filename (1)) = 16#E5# then
-- A deleted entry has been found
if Sequence >= Num_Entries then
return Ret;
else
Sequence := 0;
end if;
else
Sequence := 0;
end if;
end loop;
end Find_Empty_Entry_Sequence;
--------------------
-- Allocate_Entry --
--------------------
function Allocate_Entry
(Parent : access FAT_Directory_Handle;
Name : FAT_Name;
Attributes : FAT_Directory_Entry_Attribute;
E : out FAT_Node) return Status_Code
is
subtype Short_Name is String (1 .. 8);
subtype Extension is String (1 .. 3);
function Is_Legal_Character (C : Character) return Boolean
is (C in 'A' .. 'Z'
or else C in '0' .. '9'
or else C = '!'
or else C = '#'
or else C = '$'
or else C = '%'
or else C = '&'
or else C = '''
or else C = '('
or else C = ')'
or else C = '-'
or else C = '@'
or else C = '^'
or else C = '_'
or else C = '`'
or else C = '{'
or else C = '}'
or else C = '~');
Block_Off : Natural;
Status : Status_Code;
DEntry : FAT_Node;
SName : Short_Name := (others => ' ');
SExt : Extension := (others => ' ');
Index : Entry_Index;
-- Retrieve the number of VFAT entries that are needed, plus one for
-- the regular FAT entry.
N_Entries : Natural := Get_Num_VFAT_Entries (Name) + 1;
Bytes : Entry_Data;
procedure To_Short_Name
(Name : FAT_Name;
SName : out Short_Name;
Ext : out Extension);
-- Translates a long name into short 8.3 name
-- If the long name is mixed or lower case. then 8.3 will be uppercased
-- If the long name contains characters not allowed in an 8.3 name, then
-- the name is stripped of invalid characters such as space and extra
-- periods. Other unknown characters are changed to underscores.
-- The stripped name is then truncated, followed by a ~1. Inc_SName
-- below will increase the digit number in case there's overloaded 8.3
-- names.
-- If the long name is longer than 8.3, then ~1 suffix will also be
-- used.
function To_Upper (C : Character) return Character is
(if C in 'a' .. 'z'
then Character'Val
(Character'Pos (C) + Character'Pos ('A') - Character'Pos ('a'))
else C);
function Value (S : String) return Natural;
-- For a positive int represented in S, returns its value
procedure Inc_SName (SName : in out String);
-- Increment the suffix of the short FAT name
-- e.g.:
-- ABCDEFGH => ABCDEF~1
-- ABC => ABC~1
-- ABC~9 => ABC~10
-- ABCDEF~9 => ABCDE~10
procedure To_WString
(S : FAT_Name;
Idx : in out Natural;
WS : in out Wide_String);
-- Dumps S (Idx .. Idx + WS'Length - 1) into WS and increments Idx
-----------
-- Value --
-----------
function Value (S : String) return Natural
is
Val : constant String := Trim (S);
Digit : Natural;
Ret : Natural := 0;
begin
for J in Val'Range loop
Digit := Character'Pos (Val (J)) - Character'Pos ('0');
Ret := Ret * 10 + Digit;
end loop;
return Ret;
end Value;
-------------------
-- To_Short_Name --
-------------------
procedure To_Short_Name
(Name : FAT_Name;
SName : out Short_Name;
Ext : out Extension)
is
S_Idx : Natural := 0;
Add_Tilde : Boolean := False;
Last : Natural := Name.Len;
begin
-- Copy the file extension
Ext := (others => ' ');
for J in reverse 1 .. Name.Len loop
if Name.Name (J) = '.' then
if J = Name.Len then
-- Take care of names ending with a '.' (e.g. no extension,
-- the final '.' is part of the basename)
Last := J;
Ext := (others => ' ');
else
Last := J - 1;
S_Idx := Ext'First;
for K in J + 1 .. Name.Len loop
Ext (S_Idx) := To_Upper (Name.Name (K));
S_Idx := S_Idx + 1;
-- In case the extension is more than 3 characters, we
-- keep the first 3 ones.
exit when S_Idx > Ext'Last;
end loop;
end if;
exit;
end if;
end loop;
S_Idx := 0;
SName := (others => ' ');
for J in 1 .. Last loop
exit when Add_Tilde and then S_Idx >= 6;
exit when not Add_Tilde and then S_Idx = 8;
if Name.Name (J) in 'a' .. 'z' then
S_Idx := S_Idx + 1;
SName (S_Idx) := To_Upper (Name.Name (J));
elsif Is_Legal_Character (Name.Name (J)) then
S_Idx := S_Idx + 1;
SName (S_Idx) := Name.Name (J);
elsif Name.Name (J) = '.'
or else Name.Name (J) = ' '
then
-- dots that are not used as extension delimiters are invalid
-- in FAT short names and ignored in long names to short names
-- translation
Add_Tilde := True;
else
-- Any other character is translated as '_'
Add_Tilde := True;
S_Idx := S_Idx + 1;
SName (S_Idx) := '_';
end if;
end loop;
if Add_Tilde then
if S_Idx >= 6 then
SName (7 .. 8) := "~1";
else
SName (S_Idx + 1 .. S_Idx + 2) := "~1";
end if;
end if;
end To_Short_Name;
---------------
-- Inc_SName --
---------------
procedure Inc_SName (SName : in out String)
is
Idx : Natural := 0;
Num : Natural := 0;
begin
for J in reverse SName'Range loop
if Idx = 0 then
if SName (J) = ' ' then
null;
elsif SName (J) in '0' .. '9' then
Idx := J;
else
SName (SName'Last - 1 .. SName'Last) := "~1";
return;
end if;
elsif SName (J) in '0' .. '9' then
Idx := J;
elsif SName (J) = '~' then
Num := Value (SName (Idx .. SName'Last)) + 1;
-- make Idx point to '~'
Idx := J;
declare
N_Suffix : String := Natural'Image (Num);
begin
N_Suffix (N_Suffix'First) := '~';
if Idx + N_Suffix'Length - 1 > SName'Last then
SName (SName'Last - N_Suffix'Length + 1 .. SName'Last) :=
N_Suffix;
else
SName (Idx .. Idx + N_Suffix'Length - 1) := N_Suffix;
end if;
return;
end;
else
SName (SName'Last - 2 .. SName'Last) := "~1";
return;
end if;
end loop;
SName (SName'Last - 2 .. SName'Last) := "~1";
end Inc_SName;
----------------
-- To_WString --
----------------
procedure To_WString
(S : FAT_Name;
Idx : in out Natural;
WS : in out Wide_String)
is
begin
for J in WS'Range loop
if Idx = S.Len and then S.Name (Idx) = '.' then
WS (J) := Wide_Character'Val (16#F029#);
elsif Idx = S.Len and then S.Name (Idx) = ' ' then
WS (J) := Wide_Character'Val (16#F028#);
elsif Idx = S.Len + 1 then
WS (J) := Wide_Character'Val (0);
elsif Idx > S.Len + 1 then
WS (J) := Wide_Character'Val (16#FFFF#);
else
WS (J) := Wide_Character'Val (Character'Pos (S.Name (Idx)));
end if;
Idx := Idx + 1;
end loop;
end To_WString;
begin
if Parent.FS.Version /= FAT32 then
-- we only support FAT32 for now.
return Internal_Error;
end if;
-- Compute an initial version of the short name
To_Short_Name (Name, SName, SExt);
-- Look for an already existing entry, and compute the short name
Reset (Parent.all);
loop
Status := Read (Parent.all, DEntry);
if Status /= OK then
-- no such existing entry, we're good
Status := OK;
exit;
end if;
-- Can't create a new entry as an old entry with the same long name
-- already exists
if Long_Name (DEntry) = Name then
return Already_Exists;
end if;
if DEntry.S_Name = SName
and then DEntry.S_Name_Ext = SExt
then
Inc_SName (SName);
end if;
end loop;
Reset (Parent.all);
-- Look for an already existing entry that has been deleted and so that
-- we could reuse
Index := Find_Empty_Entry_Sequence (Parent, N_Entries);
if Index = Null_Index then
-- No such free sequence of directory entries are available, so we'll
-- need to allocate new ones
-- At this point, Parent.Current_Index points to the first invalid
-- entry.
Index := Parent.Current_Index;
-- Indicate that a new Entry terminator needs to be added.
N_Entries := N_Entries + 1;
end if;
if Status = OK then
-- we now write down the new entry
declare
VFAT_Entry : array (1 .. Get_Num_VFAT_Entries (Name)) of
VFAT_Directory_Entry;
FAT_Entry : FAT_Directory_Entry;
Idx : Natural := Name.Name'First;
CRC : Unsigned_8 := 0;
C : Unsigned_8;
N_Blocks : Block_Offset;
begin
CRC := 0;
for Ch of String'(SName & SExt) loop
C := Character'Enum_Rep (Ch);
CRC := Shift_Right (CRC and 16#FE#, 1)
or Shift_Left (CRC and 16#01#, 7);
-- Modulo addition
CRC := CRC + C;
end loop;
for J in reverse VFAT_Entry'Range loop
VFAT_Entry (J).VFAT_Attr.Sequence :=
VFAT_Sequence_Number (VFAT_Entry'Last - J + 1);
VFAT_Entry (J).VFAT_Attr.Stop_Bit := False;
VFAT_Entry (J).Attribute := VFAT_Directory_Entry_Attribute;
VFAT_Entry (J).Reserved := 0;
VFAT_Entry (J).Checksum := CRC;
VFAT_Entry (J).Cluster := 0;
To_WString (Name, Idx, VFAT_Entry (J).Name_1);
To_WString (Name, Idx, VFAT_Entry (J).Name_2);
To_WString (Name, Idx, VFAT_Entry (J).Name_3);
end loop;
VFAT_Entry (VFAT_Entry'First).VFAT_Attr.Stop_Bit := True;
E :=
(FS => Parent.FS,
L_Name => Name,
S_Name => SName,
S_Name_Ext => SExt,
Attributes => Attributes,
Start_Cluster => Parent.FS.New_Cluster,
Size => 0,
Index => Index + VFAT_Entry'Length,
Is_Root => False,
Is_Dirty => False);
if E.Start_Cluster = INVALID_CLUSTER then
return Disk_Full;
end if;
FAT_Entry :=
(Filename => SName,
Extension => SExt,
Attributes => Attributes,
Reserved => (others => ASCII.NUL),
Cluster_H =>
Unsigned_16
(Shift_Right
(Unsigned_32 (E.Start_Cluster) and 16#FFFF_0000#, 16)),
Time => 0,
Date => 0,
Cluster_L => Unsigned_16 (E.Start_Cluster and 16#FFFF#),
Size => 0);
-- Now write down the new entries:
-- First reset the directory handle
Reset (Parent.all);
-- Retrieve the block number relative to the first block of the
-- directory content
N_Blocks := Block_Offset
(FAT_File_Size (Index) * 32 / Parent.FS.Block_Size);
-- Check if we need to change cluster
while N_Blocks >= Parent.FS.Blocks_Per_Cluster loop
Parent.Current_Cluster :=
Parent.FS.Get_FAT (Parent.Current_Cluster);
N_Blocks := N_Blocks - Parent.FS.Blocks_Per_Cluster;
end loop;
Parent.Current_Block :=
Parent.FS.Cluster_To_Block (Parent.Current_Cluster) + N_Blocks;
Status := Parent.FS.Ensure_Block (Parent.Current_Block);
if Status /= OK then
return Status;
end if;
for J in 1 .. N_Entries loop
if J <= VFAT_Entry'Last then
Bytes := To_Data (VFAT_Entry (J));
elsif J = VFAT_Entry'Last + 1 then
Bytes := To_Data (FAT_Entry);
else
Bytes := (others => 0);
end if;
Block_Off := Natural
((FAT_File_Size (Index) * 32) mod Parent.FS.Block_Size);
if J > 1 and then Block_Off = 0 then
Status := Parent.FS.Write_Window;
exit when Status /= OK;
N_Blocks := N_Blocks + 1;
if N_Blocks = Parent.FS.Blocks_Per_Cluster then
N_Blocks := 0;
if Parent.FS.Is_Last_Cluster
(Parent.FS.Get_FAT (Parent.Current_Cluster))
then
Parent.Current_Cluster :=
Parent.FS.New_Cluster (Parent.Current_Cluster);
else
Parent.Current_Cluster :=
Parent.FS.Get_FAT (Parent.Current_Cluster);
end if;
Parent.Current_Block :=
Parent.FS.Cluster_To_Block (Parent.Current_Cluster);
else
Parent.Current_Block := Parent.Current_Block + 1;
end if;
Status := Parent.FS.Ensure_Block (Parent.Current_Block);
exit when Status /= OK;
end if;
Parent.FS.Window (Block_Off .. Block_Off + 31) := Bytes;
Index := Index + 1;
end loop;
Status := Parent.FS.Write_Window;
Reset (Parent.all);
end;
end if;
return Status;
end Allocate_Entry;
end Filesystem.FAT.Directories;
|
with Date_Package; use Date_Package;
with Ada.Text_IO; use Ada.Text_IO;
package body Person_Handling is
function "="(Person1, Person2: in Person) return Boolean is
begin
return Person1.Birth = Person2.Birth;
end;
function ">"(Person1, Person2: in Person) return Boolean is
begin
return Person1.Birth > Person2.Birth;
end;
function "<"(Person1, Person2: in Person) return Boolean is
begin
return Person1.Birth < Person2.Birth;
end;
procedure Put(Pers: in Person) is
begin
Put(Pers.Name(1..Pers.Name_Length)); Put(" ");
Put(Pers.Address(1..Pers.Address_Length)); Put(" ");
Put(Pers.Birth); Put(" ");
end Put;
procedure Get(Pers: out Person) is
Name: String(1..20);
Address: String(1..20);
Birth: Date_Type;
begin
Put("Namn: ");
Get_Line(Pers.Name, Pers.Name_Length);
if Pers.Name_Length >= 20 then Skip_Line; end if;
Put("Adress: ");
Get_Line(Pers.Address, Pers.Address_Length);
if Pers.Address_Length >= 20 then Skip_Line; end if;
Put("Födelsedatum: ");
Get(Pers.Birth);
Skip_Line;
end Get;
end Person_Handling;
|
with EU_Projects.Times.Time_Expressions.Solving;
with EU_Projects.Projects.Housekeeping;
with Ada.Text_IO; use Ada.Text_IO;
with Ada.Exceptions;
package body EU_Projects.Projects is
-----------
-- Bless --
-----------
procedure Bless (Project : in out Project_Descriptor;
Info : Nodes.Timed_Nodes.Project_Infos.Info_Access)
is
begin
Project.Info := Info;
end Bless;
---------------------
-- Milestone_Table --
---------------------
function Milestone_Table (Item : Project_Descriptor)
return Milestone_Table_Type
is
use Times;
function Due_On (X : Milestone_Cursor) return Extended_Month_Number
is ((if Element (X).Due_On = To_Be_Decided
then
No_Month
else
Month_Number (Months (Element (X).Due_On))));
type Counter_Array is array (Month_Number range <>) of Natural;
Last_Month : constant Month_Number :=
(if Item.Last_Month = To_Be_Decided
then
36
else
Month_Number (Months (Item.Last_Month)));
Counters : Counter_Array (1 .. Last_Month) := (others => 0);
Max_Counter : Natural := 0;
begin
for Mstone in Item.All_Milestones loop
declare
Due : constant Extended_Month_Number := Due_On (Mstone);
begin
if Due /= No_Month then
Counters (Due) := Counters (Due)+1;
Max_Counter := Natural'Max (Max_Counter, Counters (Due));
end if;
end;
end loop;
declare
Result : Milestone_Table_Type (Counters'Range, 1 .. Max_Counter) :=
(others => (others => null));
begin
Counters := (others => 0);
for Mstone in Item.All_Milestones loop
declare
Due : constant Extended_Month_Number := Due_On (Mstone);
begin
if Due /= No_Month then
Counters (Due) := Counters (Due)+1;
Result (Due, Counters (Due)) := Element (Mstone);
end if;
end;
end loop;
return Result;
end;
end Milestone_Table;
-------------------
-- Partner_Names --
-------------------
function Partner_Names (Item : Project_Descriptor) return Partners.Partner_Name_Array
is
First : constant Partners.Partner_Index := Item.Partner_List.First_Index;
Last : constant Partners.Partner_Index := Item.Partner_List.Last_Index;
Result : Partners.Partner_Name_Array (First .. Last);
begin
for Idx in Result'Range loop
Result (Idx) := Partners.Partner_Label (Item.Partner_List (Idx).all.Label);
end loop;
return Result;
end Partner_Names;
-----------
-- First --
-----------
function First (Object : All_Task_Iterator) return All_Task_Cursor
is
Result : All_Task_Cursor;
begin
Result.WP_Pos := First (Object.WP_Iter);
loop
exit when not Has_Element (Result.WP_Pos);
Result.Task_Iter := WPs.Task_Iterator (Element (Result.WP_Pos).All_Tasks);
Result.Task_Pos := First (Result.Task_Iter);
exit when Has_Element (Result.Task_Pos);
Result.WP_Pos := Next (Object.WP_Iter, Result.WP_Pos);
end loop;
return Result;
end First;
-----------
-- First --
-----------
function First (Object : All_Deliverable_Iterator) return All_Deliverable_Cursor
is
Result : All_Deliverable_Cursor;
begin
Result.WP_Pos := First (Object.WP_Iter);
loop
exit when not Has_Element (Result.WP_Pos);
Result.Deliv_Iter := WPs.Deliverable_Iterator (Element (Result.WP_Pos).All_Deliverables);
Result.Deliv_Pos := Result.Deliv_Iter.First;
exit when Has_Element (Result.Deliv_Pos);
Result.WP_Pos := Next (Object.WP_Iter, Result.WP_Pos);
end loop;
return Result;
end First;
----------
-- Next --
----------
function Next
(Object : All_Task_Iterator;
Position : All_Task_Cursor) return All_Task_Cursor
is
Result : All_Task_Cursor := Position;
begin
Result.Task_Pos := Next (Result.Task_Iter, Result.Task_Pos);
loop
exit when Has_Element (Result.Task_Pos);
Result.WP_Pos := Next (Object.WP_Iter, Result.WP_Pos);
exit when not Has_Element (Result.Wp_Pos);
Result.Task_Iter := WPs.Task_Iterator (Element (Result.WP_Pos).All_Tasks);
Result.Task_Pos := First (Result.Task_Iter);
end loop;
return Result;
end Next;
----------
-- Next --
----------
function Next
(Object : All_Deliverable_Iterator;
Position : All_Deliverable_Cursor) return All_Deliverable_Cursor
is
Result : All_Deliverable_Cursor := Position;
begin
Result.Deliv_Pos := Wps.Next (Result.Deliv_Iter, Result.Deliv_Pos);
loop
exit when Has_Element (Result.Deliv_Pos);
Result.WP_Pos := Next (Object.WP_Iter, Result.WP_Pos);
exit when not Has_Element (Result.Wp_Pos);
Result.Deliv_Iter := WPs.Deliverable_Iterator (Element (Result.WP_Pos).All_Deliverables);
Result.Deliv_Pos := Result.Deliv_Iter.First;
end loop;
return Result;
end Next;
----------
-- Next --
----------
function Next
(Object : All_Node_Iterator;
Position : All_Node_Cursor) return All_Node_Cursor
is
Result : All_Node_Cursor := Position;
Make_New : Boolean;
End_Of_Group : Boolean;
begin
if not Has_Element (Position) then
return Position;
end if;
Make_New := False;
if Position.Prj_Info_Access /= null then
Result.Prj_Info_Access := null;
return Result;
end if;
loop
End_Of_Group := False;
case Result.Current_Class is
when WP_Node =>
Result.WP_Pos := (if Make_New then
First (Object.WP_Iter)
else
Next (Object.WP_Iter, Result.WP_Pos));
End_Of_Group := not Has_Element (Result.WP_Pos);
when Task_Node =>
Result.Task_Pos := (if Make_New then
First (Object.All_Task_Iter)
else
Next (Object.All_Task_Iter, Result.Task_Pos));
End_Of_Group := not Has_Element (Result.Task_Pos);
when Deliverable_Node =>
Result.Deliverable_Pos := (if Make_New then
First (Object.Deliverable_Iter)
else
Next (Object.Deliverable_Iter, Result.Deliverable_Pos));
End_Of_Group := not Has_Element (Result.Deliverable_Pos);
when Risk_Node =>
Result.Risk_Pos := (if Make_New then
First (Object.Risk_Iter)
else
Next (Object.Risk_Iter, Result.Risk_Pos));
End_Of_Group := not Has_Element (Result.Risk_Pos);
when Partner_Node =>
Result.Partner_Pos := (if Make_New then
First (Object.Partner_Iter)
else
Next (Object.Partner_Iter, Result.Partner_Pos));
End_Of_Group := not Has_Element (Result.Partner_Pos);
when Milestone_Node =>
Result.Milestone_Pos := (if Make_New then
First (Object.Milestone_Iter)
else
Next (Object.Milestone_Iter, Result.Milestone_Pos));
End_Of_Group := not Has_Element (Result.Milestone_Pos);
end case;
exit when not End_Of_Group;
exit when Result.Current_Class = Node_Class'Last;
Result.Current_Class := Node_Class'Succ (Result.Current_Class);
Make_New := True;
end loop;
return Result;
end Next;
-- --------------
-- -- Add_Node --
-- --------------
--
-- procedure Add_Node (Project : in out Project_Descriptor;
-- Label : Nodes.Node_Label;
-- Node : Nodes.Node_Access)
-- is
-- begin
-- Project.Node_Directory.Insert (Key => Label,
-- New_Item => Node);
-- end Add_Node;
---------------
-- Configure --
---------------
procedure Configure
(Project : in out Project_Descriptor;
Name : String;
Value : String)
is
begin
Project.Options.Insert (Key => Name,
New_Item => Value);
end Configure;
-----------------
-- Add_Partner --
-----------------
procedure Add_Partner
(Project : in out Project_Descriptor;
Partner : in Nodes.Partners.Partner_Access)
is
begin
Project.Partner_List.Append (Partner);
Partner.Set_Index (Project.Partner_List.Last_Index);
end Add_Partner;
------------
-- Add_WP --
------------
procedure Add_WP
(Project : in out Project_Descriptor;
WP : in WPs.Project_WP_Access)
is
begin
Project.WP_List.Append (WP);
WP.Set_Index (Project.WP_List.Last_Index);
end Add_WP;
-------------------
-- Add_Milestone --
-------------------
procedure Add_Milestone
(Project : in out Project_Descriptor;
Item : in Milestones.Milestone_Access)
is
begin
Project.Milestones.Append (Item);
Item.Set_Index (Project.Milestones.Last_Index);
end Add_Milestone;
--------------
-- Add_Risk --
--------------
procedure Add_Risk
(Project : in out Project_Descriptor;
Item : in Risks.Risk_Access)
is
begin
Project.Risk_List.Append (Item);
end Add_Risk;
----------
-- Find --
----------
function Find
(Where : Project_Descriptor;
Label : Nodes.Node_Label)
return Nodes.Node_Access
is
use Node_Tables;
begin
if Where.Node_Directory.Contains (Label) then
-- Put_Line ("TROVATO");
return Where.Node_Directory (Label);
else
-- Where.Node_Directory.Dump;
-- Put_Line ("NON TROVATO");
return null;
end if;
end Find;
------------
-- Exists --
------------
function Exists
(Where : Project_Descriptor;
Label : Nodes.Node_Label)
return Boolean
is (Where.Node_Directory.Contains (Label));
--------------
-- Complete --
--------------
procedure Freeze (Project : in out Project_Descriptor;
Options : Freezing_Options := Sort_Milestones) is
Equations : Times.Time_Expressions.Solving.Time_Equation_System;
Results : Times.Time_Expressions.Solving.Variable_Map;
procedure Compute_Project_Duration is
use Times;
Last_Month : Times.Instant := Times.Earliest_Istant;
T : Times.Instant;
begin
for WP in Project.All_WPs loop
T := Element (Wp).Ending_Time;
if T /= Times.To_Be_Decided then
Last_Month := (if Last_Month >= T then Last_Month else T);
end if;
end loop;
Project.Last_Month := Last_Month;
end Compute_Project_Duration;
begin
if Project.Freezed then
return;
end if;
Housekeeping.Check_Node_Table (Project);
Housekeeping.Link_Milestone_To_Deliverable (Project);
Equations := Housekeeping.Collect_Equations (Project);
Results := Times.Time_Expressions.Solving.Solve (Equations);
Housekeeping.Assign_Results (Project, Results);
Compute_Project_Duration;
if Options (Milestone_Sorting) then
Milestone_Sort.Sort (Project.Milestones);
for pos in Project.Milestones.Iterate loop
Project.Milestones (Pos).all.Update_Index (Milestone_Vectors.To_Index (Pos));
end loop;
end if;
Project.Freezed := True;
exception
when Error: Housekeeping.Housekeeping_Failed =>
raise Bad_Input
with Ada.Exceptions.Exception_Message (Error);
end Freeze;
end EU_Projects.Projects;
-- declare
-- procedure Update (Mstone : in out Nodes.Timed_Nodes.Milestones.Milestone_Access)
-- is
-- begin
-- Mstone.Update_Index ();
-- end Update;
-- begin
--
-- Project.Milestones.Update_Element (Position => pos,
-- Process => Update'access);
-- end;
|
with System.Native_Time;
with C.winbase;
with C.windef;
package body System.Native_Real_Time is
use type C.windef.WINBOOL;
use type C.winnt.LONGLONG;
subtype Positive_LONGLONG is
C.winnt.LONGLONG range 1 .. C.winnt.LONGLONG'Last;
Performance_Counter_Enabled : Boolean;
Frequency : Positive_LONGLONG;
procedure Initialize;
procedure Initialize is
Freq : aliased C.winnt.LARGE_INTEGER;
begin
Performance_Counter_Enabled :=
C.winbase.QueryPerformanceFrequency (Freq'Access) /= C.windef.FALSE;
Frequency := Freq.QuadPart;
end Initialize;
-- implementation
function To_Native_Time (T : Duration) return Native_Time is
begin
return C.winnt.LONGLONG (
System.Native_Time.Nanosecond_Number'Integer_Value (T));
end To_Native_Time;
function To_Duration (T : Native_Time) return Duration is
begin
return Duration'Fixed_Value (System.Native_Time.Nanosecond_Number (T));
end To_Duration;
function Clock return Native_Time is
begin
if Performance_Counter_Enabled then
declare
Count : aliased C.winnt.LARGE_INTEGER;
begin
if C.winbase.QueryPerformanceCounter (Count'Access) =
C.windef.FALSE
then
raise Program_Error; -- ???
else
return Count.QuadPart * 1_000_000_000 / Frequency;
end if;
end;
else
raise Program_Error; -- ???
end if;
end Clock;
procedure Delay_Until (T : Native_Time) is
Timeout_T : constant Duration := To_Duration (T);
Current_T : constant Duration := To_Duration (Clock);
D : Duration;
begin
if Timeout_T > Current_T then
D := Timeout_T - Current_T;
else
D := 0.0; -- always calling Delay_For for abort checking
end if;
System.Native_Time.Delay_For (D);
end Delay_Until;
begin
Initialize;
end System.Native_Real_Time;
|
package body Debug4_Pkg is
type Vertex_To_Vertex_T is array (Vertex_Id range <>) of Vertex_Id;
function Dominator_Tree_Internal (G : T'Class) return Vertex_To_Vertex_T is
subtype V_To_V is Vertex_To_Vertex_T (0 .. G.Vertices.Last_Index);
type V_To_VIL is array
(Valid_Vertex_Id range 1 .. G.Vertices.Last_Index)
of Vertex_Index_List;
Bucket : V_To_VIL := (others => VIL.Empty_Vector);
Dom : V_To_V := (others => 0);
begin
return Dom;
end;
function Dominator_Tree (G : T'Class) return T is
Dom : constant Vertex_To_Vertex_T := Dominator_Tree_Internal (G);
DT : T := (Vertices => VL.Empty_Vector);
begin
return DT;
end;
end Debug4_Pkg;
|
------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- Ada Modeling Framework --
-- --
-- Runtime Library Component --
-- --
------------------------------------------------------------------------------
-- --
-- Copyright © 2012-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$
------------------------------------------------------------------------------
-- This file is generated, don't edit it.
------------------------------------------------------------------------------
with AMF.OCL.Any_Types;
with AMF.OCL.Association_Class_Call_Exps;
with AMF.OCL.Bag_Types;
with AMF.OCL.Boolean_Literal_Exps;
with AMF.OCL.Collection_Items;
with AMF.OCL.Collection_Literal_Exps;
with AMF.OCL.Collection_Ranges;
with AMF.OCL.Collection_Types;
with AMF.OCL.Enum_Literal_Exps;
with AMF.OCL.Expression_In_Ocls;
with AMF.OCL.If_Exps;
with AMF.OCL.Integer_Literal_Exps;
with AMF.OCL.Invalid_Literal_Exps;
with AMF.OCL.Invalid_Types;
with AMF.OCL.Iterate_Exps;
with AMF.OCL.Iterator_Exps;
with AMF.OCL.Let_Exps;
with AMF.OCL.Message_Exps;
with AMF.OCL.Message_Types;
with AMF.OCL.Null_Literal_Exps;
with AMF.OCL.Operation_Call_Exps;
with AMF.OCL.Ordered_Set_Types;
with AMF.OCL.Property_Call_Exps;
with AMF.OCL.Real_Literal_Exps;
with AMF.OCL.Sequence_Types;
with AMF.OCL.Set_Types;
with AMF.OCL.State_Exps;
with AMF.OCL.String_Literal_Exps;
with AMF.OCL.Template_Parameter_Types;
with AMF.OCL.Tuple_Literal_Exps;
with AMF.OCL.Tuple_Literal_Parts;
with AMF.OCL.Tuple_Types;
with AMF.OCL.Type_Exps;
with AMF.OCL.Unlimited_Natural_Literal_Exps;
with AMF.OCL.Unspecified_Value_Exps;
with AMF.OCL.Variable_Exps;
with AMF.OCL.Variables;
with AMF.OCL.Void_Types;
package AMF.Visitors.OCL_Visitors is
pragma Preelaborate;
type OCL_Visitor is limited interface and AMF.Visitors.Abstract_Visitor;
not overriding procedure Enter_Any_Type
(Self : in out OCL_Visitor;
Element : not null AMF.OCL.Any_Types.OCL_Any_Type_Access;
Control : in out AMF.Visitors.Traverse_Control) is null;
not overriding procedure Leave_Any_Type
(Self : in out OCL_Visitor;
Element : not null AMF.OCL.Any_Types.OCL_Any_Type_Access;
Control : in out AMF.Visitors.Traverse_Control) is null;
not overriding procedure Enter_Association_Class_Call_Exp
(Self : in out OCL_Visitor;
Element : not null AMF.OCL.Association_Class_Call_Exps.OCL_Association_Class_Call_Exp_Access;
Control : in out AMF.Visitors.Traverse_Control) is null;
not overriding procedure Leave_Association_Class_Call_Exp
(Self : in out OCL_Visitor;
Element : not null AMF.OCL.Association_Class_Call_Exps.OCL_Association_Class_Call_Exp_Access;
Control : in out AMF.Visitors.Traverse_Control) is null;
not overriding procedure Enter_Bag_Type
(Self : in out OCL_Visitor;
Element : not null AMF.OCL.Bag_Types.OCL_Bag_Type_Access;
Control : in out AMF.Visitors.Traverse_Control) is null;
not overriding procedure Leave_Bag_Type
(Self : in out OCL_Visitor;
Element : not null AMF.OCL.Bag_Types.OCL_Bag_Type_Access;
Control : in out AMF.Visitors.Traverse_Control) is null;
not overriding procedure Enter_Boolean_Literal_Exp
(Self : in out OCL_Visitor;
Element : not null AMF.OCL.Boolean_Literal_Exps.OCL_Boolean_Literal_Exp_Access;
Control : in out AMF.Visitors.Traverse_Control) is null;
not overriding procedure Leave_Boolean_Literal_Exp
(Self : in out OCL_Visitor;
Element : not null AMF.OCL.Boolean_Literal_Exps.OCL_Boolean_Literal_Exp_Access;
Control : in out AMF.Visitors.Traverse_Control) is null;
not overriding procedure Enter_Collection_Item
(Self : in out OCL_Visitor;
Element : not null AMF.OCL.Collection_Items.OCL_Collection_Item_Access;
Control : in out AMF.Visitors.Traverse_Control) is null;
not overriding procedure Leave_Collection_Item
(Self : in out OCL_Visitor;
Element : not null AMF.OCL.Collection_Items.OCL_Collection_Item_Access;
Control : in out AMF.Visitors.Traverse_Control) is null;
not overriding procedure Enter_Collection_Literal_Exp
(Self : in out OCL_Visitor;
Element : not null AMF.OCL.Collection_Literal_Exps.OCL_Collection_Literal_Exp_Access;
Control : in out AMF.Visitors.Traverse_Control) is null;
not overriding procedure Leave_Collection_Literal_Exp
(Self : in out OCL_Visitor;
Element : not null AMF.OCL.Collection_Literal_Exps.OCL_Collection_Literal_Exp_Access;
Control : in out AMF.Visitors.Traverse_Control) is null;
not overriding procedure Enter_Collection_Range
(Self : in out OCL_Visitor;
Element : not null AMF.OCL.Collection_Ranges.OCL_Collection_Range_Access;
Control : in out AMF.Visitors.Traverse_Control) is null;
not overriding procedure Leave_Collection_Range
(Self : in out OCL_Visitor;
Element : not null AMF.OCL.Collection_Ranges.OCL_Collection_Range_Access;
Control : in out AMF.Visitors.Traverse_Control) is null;
not overriding procedure Enter_Collection_Type
(Self : in out OCL_Visitor;
Element : not null AMF.OCL.Collection_Types.OCL_Collection_Type_Access;
Control : in out AMF.Visitors.Traverse_Control) is null;
not overriding procedure Leave_Collection_Type
(Self : in out OCL_Visitor;
Element : not null AMF.OCL.Collection_Types.OCL_Collection_Type_Access;
Control : in out AMF.Visitors.Traverse_Control) is null;
not overriding procedure Enter_Enum_Literal_Exp
(Self : in out OCL_Visitor;
Element : not null AMF.OCL.Enum_Literal_Exps.OCL_Enum_Literal_Exp_Access;
Control : in out AMF.Visitors.Traverse_Control) is null;
not overriding procedure Leave_Enum_Literal_Exp
(Self : in out OCL_Visitor;
Element : not null AMF.OCL.Enum_Literal_Exps.OCL_Enum_Literal_Exp_Access;
Control : in out AMF.Visitors.Traverse_Control) is null;
not overriding procedure Enter_Expression_In_Ocl
(Self : in out OCL_Visitor;
Element : not null AMF.OCL.Expression_In_Ocls.OCL_Expression_In_Ocl_Access;
Control : in out AMF.Visitors.Traverse_Control) is null;
not overriding procedure Leave_Expression_In_Ocl
(Self : in out OCL_Visitor;
Element : not null AMF.OCL.Expression_In_Ocls.OCL_Expression_In_Ocl_Access;
Control : in out AMF.Visitors.Traverse_Control) is null;
not overriding procedure Enter_If_Exp
(Self : in out OCL_Visitor;
Element : not null AMF.OCL.If_Exps.OCL_If_Exp_Access;
Control : in out AMF.Visitors.Traverse_Control) is null;
not overriding procedure Leave_If_Exp
(Self : in out OCL_Visitor;
Element : not null AMF.OCL.If_Exps.OCL_If_Exp_Access;
Control : in out AMF.Visitors.Traverse_Control) is null;
not overriding procedure Enter_Integer_Literal_Exp
(Self : in out OCL_Visitor;
Element : not null AMF.OCL.Integer_Literal_Exps.OCL_Integer_Literal_Exp_Access;
Control : in out AMF.Visitors.Traverse_Control) is null;
not overriding procedure Leave_Integer_Literal_Exp
(Self : in out OCL_Visitor;
Element : not null AMF.OCL.Integer_Literal_Exps.OCL_Integer_Literal_Exp_Access;
Control : in out AMF.Visitors.Traverse_Control) is null;
not overriding procedure Enter_Invalid_Literal_Exp
(Self : in out OCL_Visitor;
Element : not null AMF.OCL.Invalid_Literal_Exps.OCL_Invalid_Literal_Exp_Access;
Control : in out AMF.Visitors.Traverse_Control) is null;
not overriding procedure Leave_Invalid_Literal_Exp
(Self : in out OCL_Visitor;
Element : not null AMF.OCL.Invalid_Literal_Exps.OCL_Invalid_Literal_Exp_Access;
Control : in out AMF.Visitors.Traverse_Control) is null;
not overriding procedure Enter_Invalid_Type
(Self : in out OCL_Visitor;
Element : not null AMF.OCL.Invalid_Types.OCL_Invalid_Type_Access;
Control : in out AMF.Visitors.Traverse_Control) is null;
not overriding procedure Leave_Invalid_Type
(Self : in out OCL_Visitor;
Element : not null AMF.OCL.Invalid_Types.OCL_Invalid_Type_Access;
Control : in out AMF.Visitors.Traverse_Control) is null;
not overriding procedure Enter_Iterate_Exp
(Self : in out OCL_Visitor;
Element : not null AMF.OCL.Iterate_Exps.OCL_Iterate_Exp_Access;
Control : in out AMF.Visitors.Traverse_Control) is null;
not overriding procedure Leave_Iterate_Exp
(Self : in out OCL_Visitor;
Element : not null AMF.OCL.Iterate_Exps.OCL_Iterate_Exp_Access;
Control : in out AMF.Visitors.Traverse_Control) is null;
not overriding procedure Enter_Iterator_Exp
(Self : in out OCL_Visitor;
Element : not null AMF.OCL.Iterator_Exps.OCL_Iterator_Exp_Access;
Control : in out AMF.Visitors.Traverse_Control) is null;
not overriding procedure Leave_Iterator_Exp
(Self : in out OCL_Visitor;
Element : not null AMF.OCL.Iterator_Exps.OCL_Iterator_Exp_Access;
Control : in out AMF.Visitors.Traverse_Control) is null;
not overriding procedure Enter_Let_Exp
(Self : in out OCL_Visitor;
Element : not null AMF.OCL.Let_Exps.OCL_Let_Exp_Access;
Control : in out AMF.Visitors.Traverse_Control) is null;
not overriding procedure Leave_Let_Exp
(Self : in out OCL_Visitor;
Element : not null AMF.OCL.Let_Exps.OCL_Let_Exp_Access;
Control : in out AMF.Visitors.Traverse_Control) is null;
not overriding procedure Enter_Message_Exp
(Self : in out OCL_Visitor;
Element : not null AMF.OCL.Message_Exps.OCL_Message_Exp_Access;
Control : in out AMF.Visitors.Traverse_Control) is null;
not overriding procedure Leave_Message_Exp
(Self : in out OCL_Visitor;
Element : not null AMF.OCL.Message_Exps.OCL_Message_Exp_Access;
Control : in out AMF.Visitors.Traverse_Control) is null;
not overriding procedure Enter_Message_Type
(Self : in out OCL_Visitor;
Element : not null AMF.OCL.Message_Types.OCL_Message_Type_Access;
Control : in out AMF.Visitors.Traverse_Control) is null;
not overriding procedure Leave_Message_Type
(Self : in out OCL_Visitor;
Element : not null AMF.OCL.Message_Types.OCL_Message_Type_Access;
Control : in out AMF.Visitors.Traverse_Control) is null;
not overriding procedure Enter_Null_Literal_Exp
(Self : in out OCL_Visitor;
Element : not null AMF.OCL.Null_Literal_Exps.OCL_Null_Literal_Exp_Access;
Control : in out AMF.Visitors.Traverse_Control) is null;
not overriding procedure Leave_Null_Literal_Exp
(Self : in out OCL_Visitor;
Element : not null AMF.OCL.Null_Literal_Exps.OCL_Null_Literal_Exp_Access;
Control : in out AMF.Visitors.Traverse_Control) is null;
not overriding procedure Enter_Operation_Call_Exp
(Self : in out OCL_Visitor;
Element : not null AMF.OCL.Operation_Call_Exps.OCL_Operation_Call_Exp_Access;
Control : in out AMF.Visitors.Traverse_Control) is null;
not overriding procedure Leave_Operation_Call_Exp
(Self : in out OCL_Visitor;
Element : not null AMF.OCL.Operation_Call_Exps.OCL_Operation_Call_Exp_Access;
Control : in out AMF.Visitors.Traverse_Control) is null;
not overriding procedure Enter_Ordered_Set_Type
(Self : in out OCL_Visitor;
Element : not null AMF.OCL.Ordered_Set_Types.OCL_Ordered_Set_Type_Access;
Control : in out AMF.Visitors.Traverse_Control) is null;
not overriding procedure Leave_Ordered_Set_Type
(Self : in out OCL_Visitor;
Element : not null AMF.OCL.Ordered_Set_Types.OCL_Ordered_Set_Type_Access;
Control : in out AMF.Visitors.Traverse_Control) is null;
not overriding procedure Enter_Property_Call_Exp
(Self : in out OCL_Visitor;
Element : not null AMF.OCL.Property_Call_Exps.OCL_Property_Call_Exp_Access;
Control : in out AMF.Visitors.Traverse_Control) is null;
not overriding procedure Leave_Property_Call_Exp
(Self : in out OCL_Visitor;
Element : not null AMF.OCL.Property_Call_Exps.OCL_Property_Call_Exp_Access;
Control : in out AMF.Visitors.Traverse_Control) is null;
not overriding procedure Enter_Real_Literal_Exp
(Self : in out OCL_Visitor;
Element : not null AMF.OCL.Real_Literal_Exps.OCL_Real_Literal_Exp_Access;
Control : in out AMF.Visitors.Traverse_Control) is null;
not overriding procedure Leave_Real_Literal_Exp
(Self : in out OCL_Visitor;
Element : not null AMF.OCL.Real_Literal_Exps.OCL_Real_Literal_Exp_Access;
Control : in out AMF.Visitors.Traverse_Control) is null;
not overriding procedure Enter_Sequence_Type
(Self : in out OCL_Visitor;
Element : not null AMF.OCL.Sequence_Types.OCL_Sequence_Type_Access;
Control : in out AMF.Visitors.Traverse_Control) is null;
not overriding procedure Leave_Sequence_Type
(Self : in out OCL_Visitor;
Element : not null AMF.OCL.Sequence_Types.OCL_Sequence_Type_Access;
Control : in out AMF.Visitors.Traverse_Control) is null;
not overriding procedure Enter_Set_Type
(Self : in out OCL_Visitor;
Element : not null AMF.OCL.Set_Types.OCL_Set_Type_Access;
Control : in out AMF.Visitors.Traverse_Control) is null;
not overriding procedure Leave_Set_Type
(Self : in out OCL_Visitor;
Element : not null AMF.OCL.Set_Types.OCL_Set_Type_Access;
Control : in out AMF.Visitors.Traverse_Control) is null;
not overriding procedure Enter_State_Exp
(Self : in out OCL_Visitor;
Element : not null AMF.OCL.State_Exps.OCL_State_Exp_Access;
Control : in out AMF.Visitors.Traverse_Control) is null;
not overriding procedure Leave_State_Exp
(Self : in out OCL_Visitor;
Element : not null AMF.OCL.State_Exps.OCL_State_Exp_Access;
Control : in out AMF.Visitors.Traverse_Control) is null;
not overriding procedure Enter_String_Literal_Exp
(Self : in out OCL_Visitor;
Element : not null AMF.OCL.String_Literal_Exps.OCL_String_Literal_Exp_Access;
Control : in out AMF.Visitors.Traverse_Control) is null;
not overriding procedure Leave_String_Literal_Exp
(Self : in out OCL_Visitor;
Element : not null AMF.OCL.String_Literal_Exps.OCL_String_Literal_Exp_Access;
Control : in out AMF.Visitors.Traverse_Control) is null;
not overriding procedure Enter_Template_Parameter_Type
(Self : in out OCL_Visitor;
Element : not null AMF.OCL.Template_Parameter_Types.OCL_Template_Parameter_Type_Access;
Control : in out AMF.Visitors.Traverse_Control) is null;
not overriding procedure Leave_Template_Parameter_Type
(Self : in out OCL_Visitor;
Element : not null AMF.OCL.Template_Parameter_Types.OCL_Template_Parameter_Type_Access;
Control : in out AMF.Visitors.Traverse_Control) is null;
not overriding procedure Enter_Tuple_Literal_Exp
(Self : in out OCL_Visitor;
Element : not null AMF.OCL.Tuple_Literal_Exps.OCL_Tuple_Literal_Exp_Access;
Control : in out AMF.Visitors.Traverse_Control) is null;
not overriding procedure Leave_Tuple_Literal_Exp
(Self : in out OCL_Visitor;
Element : not null AMF.OCL.Tuple_Literal_Exps.OCL_Tuple_Literal_Exp_Access;
Control : in out AMF.Visitors.Traverse_Control) is null;
not overriding procedure Enter_Tuple_Literal_Part
(Self : in out OCL_Visitor;
Element : not null AMF.OCL.Tuple_Literal_Parts.OCL_Tuple_Literal_Part_Access;
Control : in out AMF.Visitors.Traverse_Control) is null;
not overriding procedure Leave_Tuple_Literal_Part
(Self : in out OCL_Visitor;
Element : not null AMF.OCL.Tuple_Literal_Parts.OCL_Tuple_Literal_Part_Access;
Control : in out AMF.Visitors.Traverse_Control) is null;
not overriding procedure Enter_Tuple_Type
(Self : in out OCL_Visitor;
Element : not null AMF.OCL.Tuple_Types.OCL_Tuple_Type_Access;
Control : in out AMF.Visitors.Traverse_Control) is null;
not overriding procedure Leave_Tuple_Type
(Self : in out OCL_Visitor;
Element : not null AMF.OCL.Tuple_Types.OCL_Tuple_Type_Access;
Control : in out AMF.Visitors.Traverse_Control) is null;
not overriding procedure Enter_Type_Exp
(Self : in out OCL_Visitor;
Element : not null AMF.OCL.Type_Exps.OCL_Type_Exp_Access;
Control : in out AMF.Visitors.Traverse_Control) is null;
not overriding procedure Leave_Type_Exp
(Self : in out OCL_Visitor;
Element : not null AMF.OCL.Type_Exps.OCL_Type_Exp_Access;
Control : in out AMF.Visitors.Traverse_Control) is null;
not overriding procedure Enter_Unlimited_Natural_Literal_Exp
(Self : in out OCL_Visitor;
Element : not null AMF.OCL.Unlimited_Natural_Literal_Exps.OCL_Unlimited_Natural_Literal_Exp_Access;
Control : in out AMF.Visitors.Traverse_Control) is null;
not overriding procedure Leave_Unlimited_Natural_Literal_Exp
(Self : in out OCL_Visitor;
Element : not null AMF.OCL.Unlimited_Natural_Literal_Exps.OCL_Unlimited_Natural_Literal_Exp_Access;
Control : in out AMF.Visitors.Traverse_Control) is null;
not overriding procedure Enter_Unspecified_Value_Exp
(Self : in out OCL_Visitor;
Element : not null AMF.OCL.Unspecified_Value_Exps.OCL_Unspecified_Value_Exp_Access;
Control : in out AMF.Visitors.Traverse_Control) is null;
not overriding procedure Leave_Unspecified_Value_Exp
(Self : in out OCL_Visitor;
Element : not null AMF.OCL.Unspecified_Value_Exps.OCL_Unspecified_Value_Exp_Access;
Control : in out AMF.Visitors.Traverse_Control) is null;
not overriding procedure Enter_Variable
(Self : in out OCL_Visitor;
Element : not null AMF.OCL.Variables.OCL_Variable_Access;
Control : in out AMF.Visitors.Traverse_Control) is null;
not overriding procedure Leave_Variable
(Self : in out OCL_Visitor;
Element : not null AMF.OCL.Variables.OCL_Variable_Access;
Control : in out AMF.Visitors.Traverse_Control) is null;
not overriding procedure Enter_Variable_Exp
(Self : in out OCL_Visitor;
Element : not null AMF.OCL.Variable_Exps.OCL_Variable_Exp_Access;
Control : in out AMF.Visitors.Traverse_Control) is null;
not overriding procedure Leave_Variable_Exp
(Self : in out OCL_Visitor;
Element : not null AMF.OCL.Variable_Exps.OCL_Variable_Exp_Access;
Control : in out AMF.Visitors.Traverse_Control) is null;
not overriding procedure Enter_Void_Type
(Self : in out OCL_Visitor;
Element : not null AMF.OCL.Void_Types.OCL_Void_Type_Access;
Control : in out AMF.Visitors.Traverse_Control) is null;
not overriding procedure Leave_Void_Type
(Self : in out OCL_Visitor;
Element : not null AMF.OCL.Void_Types.OCL_Void_Type_Access;
Control : in out AMF.Visitors.Traverse_Control) is null;
end AMF.Visitors.OCL_Visitors;
|
------------------------------------------------------------------------------
-- --
-- GNAT COMPILER COMPONENTS --
-- --
-- S Y S T E M . V A L _ R E A L --
-- --
-- B o d y --
-- --
-- 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. --
-- --
------------------------------------------------------------------------------
with System.Val_Util; use System.Val_Util;
with System.Float_Control;
package body System.Val_Real is
procedure Scan_Integral_Digits
(Str : String;
Index : in out Integer;
Max : Integer;
Value : out Long_Long_Integer;
Scale : out Integer;
Base_Violation : in out Boolean;
Base : Long_Long_Integer := 10;
Base_Specified : Boolean := False);
-- Scan the integral part of a real (i.e: before decimal separator)
--
-- The string parsed is Str (Index .. Max), and after the call Index will
-- point to the first non parsed character.
--
-- For each digit parsed either value := value * base + digit, or scale
-- is incremented by 1.
--
-- Base_Violation will be set to True a digit found is not part of the Base
procedure Scan_Decimal_Digits
(Str : String;
Index : in out Integer;
Max : Integer;
Value : in out Long_Long_Integer;
Scale : in out Integer;
Base_Violation : in out Boolean;
Base : Long_Long_Integer := 10;
Base_Specified : Boolean := False);
-- Scan the decimal part of a real (i.e: after decimal separator)
--
-- The string parsed is Str (Index .. Max), and after the call Index will
-- point to the first non parsed character.
--
-- For each digit parsed value = value * base + digit and scale is
-- decremented by 1. If precision limit is reached remaining digits are
-- still parsed but ignored.
--
-- Base_Violation will be set to True a digit found is not part of the Base
subtype Char_As_Digit is Long_Long_Integer range -2 .. 15;
subtype Valid_Digit is Char_As_Digit range 0 .. Char_As_Digit'Last;
Underscore : constant Char_As_Digit := -2;
E_Digit : constant Char_As_Digit := 14;
function As_Digit (C : Character) return Char_As_Digit;
-- Given a character return the digit it represent. If the character is
-- not a digit then a negative value is returned, -2 for underscore and
-- -1 for any other character.
Precision_Limit : constant Long_Long_Integer :=
2 ** (Long_Long_Float'Machine_Mantissa - 1) - 1;
-- This is an upper bound for the number of bits used to represent the
-- mantissa. Beyond that number, any digits parsed are useless.
--------------
-- As_Digit --
--------------
function As_Digit (C : Character) return Char_As_Digit is
begin
case C is
when '0' .. '9' =>
return Character'Pos (C) - Character'Pos ('0');
when 'a' .. 'f' =>
return Character'Pos (C) - (Character'Pos ('a') - 10);
when 'A' .. 'F' =>
return Character'Pos (C) - (Character'Pos ('A') - 10);
when '_' =>
return Underscore;
when others =>
return -1;
end case;
end As_Digit;
-------------------------
-- Scan_Decimal_Digits --
-------------------------
procedure Scan_Decimal_Digits
(Str : String;
Index : in out Integer;
Max : Integer;
Value : in out Long_Long_Integer;
Scale : in out Integer;
Base_Violation : in out Boolean;
Base : Long_Long_Integer := 10;
Base_Specified : Boolean := False)
is
Precision_Limit_Reached : Boolean := False;
-- Set to True if addition of a digit will cause Value to be superior
-- to Precision_Limit.
Digit : Char_As_Digit;
-- The current digit.
Trailing_Zeros : Natural := 0;
-- Number of trailing zeros at a given point.
begin
pragma Assert (Base in 2 .. 16);
-- If initial Scale is not 0 then it means that Precision_Limit was
-- reached during integral part scanning.
if Scale > 0 then
Precision_Limit_Reached := True;
end if;
-- The function precondition is that the first character is a valid
-- digit.
Digit := As_Digit (Str (Index));
loop
-- Check if base is correct. If the base is not specified the digit
-- E or e cannot be considered as a base violation as it can be used
-- for exponentiation.
if Digit >= Base then
if Base_Specified then
Base_Violation := True;
elsif Digit = E_Digit then
return;
else
Base_Violation := True;
end if;
end if;
-- If precision limit has been reached just ignore any remaining
-- digits for the computation of Value and Scale. The scanning
-- should continue only to assess the validity of the string
if not Precision_Limit_Reached then
if Digit = 0 then
-- Trailing '0' digits are ignored unless a non-zero digit is
-- found.
Trailing_Zeros := Trailing_Zeros + 1;
else
-- Handle accumulated zeros.
for J in 1 .. Trailing_Zeros loop
if Value > Precision_Limit / Base then
Precision_Limit_Reached := True;
exit;
else
Value := Value * Base;
Scale := Scale - 1;
end if;
end loop;
-- Reset trailing zero counter
Trailing_Zeros := 0;
-- Handle current non zero digit
if Value > (Precision_Limit - Digit) / Base then
Precision_Limit_Reached := True;
else
Value := Value * Base + Digit;
Scale := Scale - 1;
end if;
end if;
end if;
-- Check next character
Index := Index + 1;
if Index > Max then
return;
end if;
Digit := As_Digit (Str (Index));
if Digit < 0 then
if Digit = Underscore and Index + 1 <= Max then
-- Underscore is only allowed if followed by a digit
Digit := As_Digit (Str (Index + 1));
if Digit in Valid_Digit then
Index := Index + 1;
else
return;
end if;
else
-- Neither a valid underscore nor a digit.
return;
end if;
end if;
end loop;
end Scan_Decimal_Digits;
--------------------------
-- Scan_Integral_Digits --
--------------------------
procedure Scan_Integral_Digits
(Str : String;
Index : in out Integer;
Max : Integer;
Value : out Long_Long_Integer;
Scale : out Integer;
Base_Violation : in out Boolean;
Base : Long_Long_Integer := 10;
Base_Specified : Boolean := False)
is
Precision_Limit_Reached : Boolean := False;
-- Set to True if addition of a digit will cause Value to be superior
-- to Precision_Limit.
Digit : Char_As_Digit;
-- The current digit
begin
-- Initialize Scale and Value
Value := 0;
Scale := 0;
-- The function precondition is that the first character is a valid
-- digit.
Digit := As_Digit (Str (Index));
loop
-- Check if base is correct. If the base is not specified the digit
-- E or e cannot be considered as a base violation as it can be used
-- for exponentiation.
if Digit >= Base then
if Base_Specified then
Base_Violation := True;
elsif Digit = E_Digit then
return;
else
Base_Violation := True;
end if;
end if;
if Precision_Limit_Reached then
-- Precision limit has been reached so just update the exponent
Scale := Scale + 1;
else
pragma Assert (Base /= 0);
if Value > (Precision_Limit - Digit) / Base then
-- Updating Value will overflow so ignore this digit and any
-- following ones. Only update the scale
Precision_Limit_Reached := True;
Scale := Scale + 1;
else
Value := Value * Base + Digit;
end if;
end if;
-- Look for the next character
Index := Index + 1;
if Index > Max then
return;
end if;
Digit := As_Digit (Str (Index));
if Digit not in Valid_Digit then
-- Next character is not a digit. In that case stop scanning
-- unless the next chracter is an underscore followed by a digit.
if Digit = Underscore and Index + 1 <= Max then
Digit := As_Digit (Str (Index + 1));
if Digit in Valid_Digit then
Index := Index + 1;
else
return;
end if;
else
return;
end if;
end if;
end loop;
end Scan_Integral_Digits;
---------------
-- Scan_Real --
---------------
function Scan_Real
(Str : String;
Ptr : not null access Integer;
Max : Integer)
return Long_Long_Float
is
Start : Positive;
-- Position of starting non-blank character
Minus : Boolean;
-- Set to True if minus sign is present, otherwise to False
Index : Integer;
-- Local copy of string pointer
Int_Value : Long_Long_Integer := -1;
-- Mantissa as an Integer
Int_Scale : Integer := 0;
-- Exponent value
Base_Violation : Boolean := False;
-- If True some digits where not in the base. The float is still scan
-- till the end even if an error will be raised.
Uval : Long_Long_Float := 0.0;
-- Contain the final value at the end of the function
After_Point : Boolean := False;
-- True if a decimal should be parsed
Base : Long_Long_Integer := 10;
-- Current base (default: 10)
Base_Char : Character := ASCII.NUL;
-- Character used to set the base. If Nul this means that default
-- base is used.
begin
-- We do not tolerate strings with Str'Last = Positive'Last
if Str'Last = Positive'Last then
raise Program_Error with
"string upper bound is Positive'Last, not supported";
end if;
-- We call the floating-point processor reset routine so that we can
-- be sure the floating-point processor is properly set for conversion
-- calls. This is notably need on Windows, where calls to the operating
-- system randomly reset the processor into 64-bit mode.
System.Float_Control.Reset;
-- Scan the optional sign
Scan_Sign (Str, Ptr, Max, Minus, Start);
Index := Ptr.all;
Ptr.all := Start;
-- First character can be either a decimal digit or a dot.
if Str (Index) in '0' .. '9' then
pragma Annotate
(CodePeer, Intentional,
"test always true", "defensive code below");
-- If this is a digit it can indicates either the float decimal
-- part or the base to use
Scan_Integral_Digits
(Str,
Index,
Max => Max,
Value => Int_Value,
Scale => Int_Scale,
Base_Violation => Base_Violation,
Base => 10);
elsif Str (Index) = '.' and then
-- A dot is only allowed if followed by a digit.
Index < Max and then
Str (Index + 1) in '0' .. '9'
then
-- Initial point, allowed only if followed by digit (RM 3.5(47))
After_Point := True;
Index := Index + 1;
Int_Value := 0;
else
Bad_Value (Str);
end if;
-- Check if the first number encountered is a base
if Index < Max and then
(Str (Index) = '#' or else Str (Index) = ':')
then
Base_Char := Str (Index);
Base := Int_Value;
-- Reset Int_Value to indicate that parsing of integral value should
-- be done
Int_Value := -1;
if Base < 2 or else Base > 16 then
Base_Violation := True;
Base := 16;
end if;
Index := Index + 1;
if Str (Index) = '.' and then
Index < Max and then
As_Digit (Str (Index + 1)) in Valid_Digit
then
After_Point := True;
Index := Index + 1;
Int_Value := 0;
end if;
end if;
-- Does scanning of integral part needed
if Int_Value < 0 then
if Index > Max or else As_Digit (Str (Index)) not in Valid_Digit then
Bad_Value (Str);
end if;
Scan_Integral_Digits
(Str,
Index,
Max => Max,
Value => Int_Value,
Scale => Int_Scale,
Base_Violation => Base_Violation,
Base => Base,
Base_Specified => Base_Char /= ASCII.NUL);
end if;
-- Do we have a dot ?
if not After_Point and then
Index <= Max and then
Str (Index) = '.'
then
-- At this stage if After_Point was not set, this means that an
-- integral part has been found. Thus the dot is valid even if not
-- followed by a digit.
if Index < Max and then As_Digit (Str (Index + 1)) in Valid_Digit then
After_Point := True;
end if;
Index := Index + 1;
end if;
if After_Point then
-- Parse decimal part
Scan_Decimal_Digits
(Str,
Index,
Max => Max,
Value => Int_Value,
Scale => Int_Scale,
Base_Violation => Base_Violation,
Base => Base,
Base_Specified => Base_Char /= ASCII.NUL);
end if;
-- If an explicit base was specified ensure that the delimiter is found
if Base_Char /= ASCII.NUL then
if Index > Max or else Str (Index) /= Base_Char then
Bad_Value (Str);
else
Index := Index + 1;
end if;
end if;
-- Compute the final value
Uval := Long_Long_Float (Int_Value);
-- Update pointer and scan exponent.
Ptr.all := Index;
Int_Scale := Int_Scale + Scan_Exponent (Str,
Ptr,
Max,
Real => True);
Uval := Uval * Long_Long_Float (Base) ** Int_Scale;
-- Here is where we check for a bad based number
if Base_Violation then
Bad_Value (Str);
-- If OK, then deal with initial minus sign, note that this processing
-- is done even if Uval is zero, so that -0.0 is correctly interpreted.
else
if Minus then
return -Uval;
else
return Uval;
end if;
end if;
end Scan_Real;
----------------
-- Value_Real --
----------------
function Value_Real (Str : String) return Long_Long_Float is
begin
-- We have to special case Str'Last = Positive'Last because the normal
-- circuit ends up setting P to Str'Last + 1 which is out of bounds. We
-- deal with this by converting to a subtype which fixes the bounds.
if Str'Last = Positive'Last then
declare
subtype NT is String (1 .. Str'Length);
begin
return Value_Real (NT (Str));
end;
-- Normal case where Str'Last < Positive'Last
else
declare
V : Long_Long_Float;
P : aliased Integer := Str'First;
begin
V := Scan_Real (Str, P'Access, Str'Last);
Scan_Trailing_Blanks (Str, P);
return V;
end;
end if;
end Value_Real;
end System.Val_Real;
|
with Coordinates;
with Planets.Earth;
package body Atmosphere_Types is
Hit_Detection : constant Boolean := True;
use type GL.Types.Double;
procedure Set_Mass (Object : in out Gravity_Object; Value : GL.Types.Double) is
begin
Object.Mass := Value;
end Set_Mass;
procedure Set_Gravity (Object : in out Gravity_Object; Value : GL.Types.Double) is
begin
Object.Gravity := Value;
end Set_Gravity;
procedure Set_Thrust (Object : in out Gravity_Object; Value : GL.Types.Double) is
begin
Object.Thrust := Value;
end Set_Thrust;
function Altitude (Object : Gravity_Object) return GL.Types.Double is (Object.Altitude);
overriding
procedure Update
(Object : in out Gravity_Object;
State : Integrators.Integrator_State;
Delta_Time : Duration)
is
use Integrators.Vectors;
Earth_Center : constant Vector4 := Zero_Point;
Direction_Down : constant Vector4 :=
Normalize (Earth_Center - State.Position);
Direction_Up : constant Vector4 :=
Normalize (State.Position - Earth_Center);
Gravity : Vector4 :=
Direction_Down * (Object.Gravity * Object.Mass);
-- GM
-- g = ---
-- r^2
--
-- g0 = GM/Re^2
--
-- g = g0 * (Re^2)/(Re + z)^2 = g0 / (1.0 + z/Re)^2
--
-- z = altitude above sea level
Distance_To_Center : constant GL.Types.Double :=
Integrators.Vectors.Length (State.Position - Earth_Center);
Radius_To_Center : constant GL.Types.Double :=
Planets.Earth.Planet.Radius (Direction_Up);
-- FIXME Direction_Up is already flattened
begin
Integrators.Quaternions.Rotate_At_Origin
(Gravity, Integrators.Quaternions.Conjugate (State.Orientation));
if Hit_Detection and Distance_To_Center <= Radius_To_Center then
declare
Inverse_DT : constant GL.Types.Double := (1.0 / GL.Types.Double (Delta_Time));
New_Momentum : Vector4 := -State.Momentum;
-- New_Momentum : Vector4 := -1.0 * State.Velocity * Object.Mass;
begin
Integrators.Quaternions.Rotate_At_Origin
(New_Momentum, Integrators.Quaternions.Conjugate (State.Orientation));
-- FIXME Doesn't bounce on the surface of the planet
-- FIXME Doesn't respect rotational velocity of surface
Object.F_Anti_Gravity := New_Momentum * Inverse_DT;
Object.F_Gravity := Zero_Direction;
end;
-- v1' = (m1 - m2)/(m1 + m2) * v1
-- v2' = (2*m1)/(m1 + m2) * v1
--
-- v1' = v1 v2' = 2*v1 m1 >> m2 m2 => 0
-- v1' = -v1 v2' = 0 m1 << m2 m1 => 0
-- v1' = 0 v2' = v1 m1 = m2
-- m1v1 = m1v1' + m2v2'
else
Object.F_Anti_Gravity := Zero_Direction;
Object.F_Gravity := Gravity;
end if;
Object.Altitude := Distance_To_Center - Radius_To_Center;
end Update;
overriding
function Forces (Object : Gravity_Object) return Integrators.Force_Array_Access is
Forces : constant Integrators.Force_Array_Access := new Integrators.Force_At_Point_Array'
(1 => (Force => Object.F_Gravity,
Point => Object.Center_Of_Mass),
2 => (Force => Object.F_Anti_Gravity,
Point => Object.Center_Of_Mass),
3 => (Force => (Object.Thrust, 0.0, 0.0, 0.0),
Point => Object.Center_Of_Mass));
begin
return Forces;
end Forces;
overriding
function Moments (Object : Gravity_Object) return Integrators.Moment_Array_Access is
Moments : constant Integrators.Moment_Array_Access := new Integrators.Moment_Array (1 .. 0);
begin
return Moments;
end Moments;
overriding
function Inverse_Mass (Object : Gravity_Object) return GL.Types.Double is
(1.0 / Object.Mass);
overriding
function Inverse_Inertia (Object : Gravity_Object) return GL.Types.Double is
(8.643415877954968e-05);
overriding
function Center_Of_Mass (Object : Gravity_Object) return Integrators.Vectors.Vector4 is
((0.0, 0.0, 0.0, 1.0));
----------------------------------------------------------------------------
protected body Integrator is
procedure Initialize
(FDM : Integrators.Physics_Object'Class;
Position, Velocity : Orka.Behaviors.Vector4;
Orientation : Integrators.Quaternions.Quaternion) is
begin
RK4 := Integrators.RK4.Create_Integrator
(FDM, Position => Position, Velocity => Velocity, Orientation => Orientation);
end Initialize;
procedure Update
(FDM : in out Integrators.Physics_Object'Class;
Delta_Time : Duration)
is
DT : constant GL.Types.Double := GL.Types.Double (Delta_Time);
begin
RK4.Integrate (FDM, T, DT);
T := T + DT;
end Update;
function State return Integrators.Integrator_State is (RK4.State);
end Integrator;
overriding
function Position (Object : Physics_Behavior) return Orka.Behaviors.Vector4 is
use Coordinates.Matrices;
begin
case Object.Frame is
when ECI =>
return Coordinates.Rotate_ECI * Object.Int.State.Position;
when ECEF =>
return Coordinates.Rotate_ECEF * Object.Int.State.Position;
end case;
end Position;
overriding
procedure Fixed_Update (Object : in out Physics_Behavior; Delta_Time : Duration) is
begin
Object.Int.Update (Object.FDM, Delta_Time);
end Fixed_Update;
end Atmosphere_Types;
|
-- { dg-do compile }
-- { dg-options "-gnatc" }
generic
type T_Item is private;
function genericppc (T : in t_Item; I : integer) return integer;
pragma Precondition (I > 0);
|
-- This package has been generated automatically by GNATtest.
-- You are allowed to add your code to the bodies of test routines.
-- Such changes will be kept during further regeneration of this file.
-- All code placed outside of test routine bodies will be lost. The
-- code intended to set up and tear down the test environment should be
-- placed into Tk.Image.Photo.Photo_Options_Test_Data.
with AUnit.Assertions; use AUnit.Assertions;
with System.Assertions;
-- begin read only
-- id:2.2/00/
--
-- This section can be used to add with clauses if necessary.
--
-- end read only
with Ada.Environment_Variables; use Ada.Environment_Variables;
with GNAT.Directory_Operations; use GNAT.Directory_Operations;
-- begin read only
-- end read only
package body Tk.Image.Photo.Photo_Options_Test_Data.Photo_Options_Tests is
-- begin read only
-- id:2.2/01/
--
-- This section can be used to add global variables and other elements.
--
-- end read only
-- begin read only
-- end read only
-- begin read only
procedure Wrap_Test_Create_22037c_8377bb
(Photo_Image: Tk_Image; Options: Photo_Options;
Interpreter: Tcl_Interpreter := Get_Interpreter) is
begin
begin
pragma Assert(True);
null;
exception
when System.Assertions.Assert_Failure =>
AUnit.Assertions.Assert
(False,
"req_sloc(tk-image-photo.ads:0):Tests_Create_Photo test requirement violated");
end;
GNATtest_Generated.GNATtest_Standard.Tk.Image.Photo.Create
(Photo_Image, Options, Interpreter);
begin
pragma Assert(True);
null;
exception
when System.Assertions.Assert_Failure =>
AUnit.Assertions.Assert
(False,
"ens_sloc(tk-image-photo.ads:0:):Tests_Create_Photo test commitment violated");
end;
end Wrap_Test_Create_22037c_8377bb;
-- end read only
-- begin read only
procedure Test_1_Create_tests_create_photo
(Gnattest_T: in out Test_Photo_Options);
procedure Test_Create_22037c_8377bb
(Gnattest_T: in out Test_Photo_Options) renames
Test_1_Create_tests_create_photo;
-- id:2.2/22037c1fbc7ae682/Create/1/0/tests_create_photo/
procedure Test_1_Create_tests_create_photo
(Gnattest_T: in out Test_Photo_Options) is
procedure Create
(Photo_Image: Tk_Image; Options: Photo_Options;
Interpreter: Tcl_Interpreter := Get_Interpreter) renames
Wrap_Test_Create_22037c_8377bb;
-- end read only
pragma Unreferenced(Gnattest_T);
begin
if Value("DISPLAY", "")'Length = 0 then
Assert(True, "No display, can't test");
return;
end if;
Create
("myphoto",
(Format => To_Tcl_String("png"),
File => To_Tcl_String(".." & Dir_Separator & "test.png"),
others => <>));
Assert
(Image_Type("myphoto") = "photo",
"Failed to create a photo image with selected name from file.");
-- begin read only
end Test_1_Create_tests_create_photo;
-- end read only
-- begin read only
function Wrap_Test_Create_fa334a_6f3d65
(Options: Photo_Options; Interpreter: Tcl_Interpreter := Get_Interpreter)
return Tk_Image is
begin
begin
pragma Assert(True);
null;
exception
when System.Assertions.Assert_Failure =>
AUnit.Assertions.Assert
(False,
"req_sloc(tk-image-photo.ads:0):Tests_Create2_Photo test requirement violated");
end;
declare
Test_Create_fa334a_6f3d65_Result: constant Tk_Image :=
GNATtest_Generated.GNATtest_Standard.Tk.Image.Photo.Create
(Options, Interpreter);
begin
begin
pragma Assert(True);
null;
exception
when System.Assertions.Assert_Failure =>
AUnit.Assertions.Assert
(False,
"ens_sloc(tk-image-photo.ads:0:):Tests_Create2_Photo test commitment violated");
end;
return Test_Create_fa334a_6f3d65_Result;
end;
end Wrap_Test_Create_fa334a_6f3d65;
-- end read only
-- begin read only
procedure Test_2_Create_tests_create2_photo
(Gnattest_T: in out Test_Photo_Options);
procedure Test_Create_fa334a_6f3d65
(Gnattest_T: in out Test_Photo_Options) renames
Test_2_Create_tests_create2_photo;
-- id:2.2/fa334a87cdcf0776/Create/0/0/tests_create2_photo/
procedure Test_2_Create_tests_create2_photo
(Gnattest_T: in out Test_Photo_Options) is
function Create
(Options: Photo_Options;
Interpreter: Tcl_Interpreter := Get_Interpreter)
return Tk_Image renames
Wrap_Test_Create_fa334a_6f3d65;
-- end read only
pragma Unreferenced(Gnattest_T);
begin
if Value("DISPLAY", "")'Length = 0 then
Assert(True, "No display, can't test");
return;
end if;
declare
Photo_Image: constant Tk_Image :=
Create((Format => To_Tcl_String("png"), others => <>));
begin
Assert
(Photo_Image'Length > 0,
"Failed to create photo image with random name.");
Delete(Photo_Image);
end;
-- begin read only
end Test_2_Create_tests_create2_photo;
-- end read only
-- begin read only
procedure Wrap_Test_Configure_6e2ac0_462460
(Photo_Image: Tk_Image; Options: Photo_Options;
Interpreter: Tcl_Interpreter := Get_Interpreter) is
begin
begin
pragma Assert(True);
null;
exception
when System.Assertions.Assert_Failure =>
AUnit.Assertions.Assert
(False,
"req_sloc(tk-image-photo.ads:0):Tests_Configure_Photo test requirement violated");
end;
GNATtest_Generated.GNATtest_Standard.Tk.Image.Photo.Configure
(Photo_Image, Options, Interpreter);
begin
pragma Assert(True);
null;
exception
when System.Assertions.Assert_Failure =>
AUnit.Assertions.Assert
(False,
"ens_sloc(tk-image-photo.ads:0:):Tests_Configure_Photo test commitment violated");
end;
end Wrap_Test_Configure_6e2ac0_462460;
-- end read only
-- begin read only
procedure Test_Configure_tests_configure_photo
(Gnattest_T: in out Test_Photo_Options);
procedure Test_Configure_6e2ac0_462460
(Gnattest_T: in out Test_Photo_Options) renames
Test_Configure_tests_configure_photo;
-- id:2.2/6e2ac08c4cd9ce38/Configure/1/0/tests_configure_photo/
procedure Test_Configure_tests_configure_photo
(Gnattest_T: in out Test_Photo_Options) is
procedure Configure
(Photo_Image: Tk_Image; Options: Photo_Options;
Interpreter: Tcl_Interpreter := Get_Interpreter) renames
Wrap_Test_Configure_6e2ac0_462460;
-- end read only
pragma Unreferenced(Gnattest_T);
begin
if Value("DISPLAY", "")'Length = 0 then
Assert(True, "No display, can't test");
return;
end if;
Configure("myphoto", Photo_Options'(Height => 12, others => <>));
Assert
(Get_Option("myphoto", "height") = "12",
"Failed to set options for photo image.");
Configure("myphoto", Photo_Options'(Height => 11, others => <>));
-- begin read only
end Test_Configure_tests_configure_photo;
-- end read only
-- begin read only
function Wrap_Test_Get_Options_5c7a9c_d39689
(Photo_Image: Tk_Image; Interpreter: Tcl_Interpreter := Get_Interpreter)
return Photo_Options is
begin
begin
pragma Assert(True);
null;
exception
when System.Assertions.Assert_Failure =>
AUnit.Assertions.Assert
(False,
"req_sloc(tk-image-photo.ads:0):Tests_Get_Options_Photo test requirement violated");
end;
declare
Test_Get_Options_5c7a9c_d39689_Result: constant Photo_Options :=
GNATtest_Generated.GNATtest_Standard.Tk.Image.Photo.Get_Options
(Photo_Image, Interpreter);
begin
begin
pragma Assert(True);
null;
exception
when System.Assertions.Assert_Failure =>
AUnit.Assertions.Assert
(False,
"ens_sloc(tk-image-photo.ads:0:):Tests_Get_Options_Photo test commitment violated");
end;
return Test_Get_Options_5c7a9c_d39689_Result;
end;
end Wrap_Test_Get_Options_5c7a9c_d39689;
-- end read only
-- begin read only
procedure Test_Get_Options_tests_get_options_photo
(Gnattest_T: in out Test_Photo_Options);
procedure Test_Get_Options_5c7a9c_d39689
(Gnattest_T: in out Test_Photo_Options) renames
Test_Get_Options_tests_get_options_photo;
-- id:2.2/5c7a9c2ff87b2567/Get_Options/1/0/tests_get_options_photo/
procedure Test_Get_Options_tests_get_options_photo
(Gnattest_T: in out Test_Photo_Options) is
function Get_Options
(Photo_Image: Tk_Image;
Interpreter: Tcl_Interpreter := Get_Interpreter)
return Photo_Options renames
Wrap_Test_Get_Options_5c7a9c_d39689;
-- end read only
pragma Unreferenced(Gnattest_T);
begin
if Value("DISPLAY", "")'Length = 0 then
Assert(True, "No display, can't test");
return;
end if;
Assert
(Get_Options("myphoto").Format = "png",
"Failed to get options for photo image.");
-- begin read only
end Test_Get_Options_tests_get_options_photo;
-- end read only
-- begin read only
-- id:2.2/02/
--
-- This section can be used to add elaboration code for the global state.
--
begin
-- end read only
null;
-- begin read only
-- end read only
end Tk.Image.Photo.Photo_Options_Test_Data.Photo_Options_Tests;
|
-----------------------------------------------------------------------
-- util-dates -- Date utilities
-- Copyright (C) 2011, 2013 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.Calendar;
with Ada.Calendar.Formatting;
with Ada.Calendar.Arithmetic;
with Ada.Calendar.Time_Zones;
package Util.Dates is
-- The Unix equivalent of 'struct tm'.
type Date_Record is record
Date : Ada.Calendar.Time;
Year : Ada.Calendar.Year_Number;
Month : Ada.Calendar.Month_Number;
Month_Day : Ada.Calendar.Day_Number;
Day : Ada.Calendar.Formatting.Day_Name;
Hour : Ada.Calendar.Formatting.Hour_Number;
Minute : Ada.Calendar.Formatting.Minute_Number;
Second : Ada.Calendar.Formatting.Second_Number;
Sub_Second : Ada.Calendar.Formatting.Second_Duration;
Time_Zone : Ada.Calendar.Time_Zones.Time_Offset;
Leap_Second : Boolean;
end record;
-- Split the date into a date record (See Ada.Calendar.Formatting.Split).
procedure Split (Into : out Date_Record;
Date : in Ada.Calendar.Time;
Time_Zone : in Ada.Calendar.Time_Zones.Time_Offset := 0);
-- Returns true if the given year is a leap year.
function Is_Leap_Year (Year : in Ada.Calendar.Year_Number) return Boolean;
-- Get the number of days in the given year.
function Get_Day_Count (Year : in Ada.Calendar.Year_Number)
return Ada.Calendar.Arithmetic.Day_Count;
-- Get the number of days in the given month.
function Get_Day_Count (Year : in Ada.Calendar.Year_Number;
Month : in Ada.Calendar.Month_Number)
return Ada.Calendar.Arithmetic.Day_Count;
-- Get a time representing the given date at 00:00:00.
function Get_Day_Start (Date : in Date_Record) return Ada.Calendar.Time;
function Get_Day_Start (Date : in Ada.Calendar.Time) return Ada.Calendar.Time;
-- Get a time representing the given date at 23:59:59.
function Get_Day_End (Date : in Date_Record) return Ada.Calendar.Time;
function Get_Day_End (Date : in Ada.Calendar.Time) return Ada.Calendar.Time;
-- Get a time representing the beginning of the week at 00:00:00.
function Get_Week_Start (Date : in Date_Record) return Ada.Calendar.Time;
function Get_Week_Start (Date : in Ada.Calendar.Time) return Ada.Calendar.Time;
-- Get a time representing the end of the week at 23:59:99.
function Get_Week_End (Date : in Date_Record) return Ada.Calendar.Time;
function Get_Week_End (Date : in Ada.Calendar.Time) return Ada.Calendar.Time;
-- Get a time representing the beginning of the month at 00:00:00.
function Get_Month_Start (Date : in Date_Record) return Ada.Calendar.Time;
function Get_Month_Start (Date : in Ada.Calendar.Time) return Ada.Calendar.Time;
-- Get a time representing the end of the month at 23:59:59.
function Get_Month_End (Date : in Date_Record) return Ada.Calendar.Time;
function Get_Month_End (Date : in Ada.Calendar.Time) return Ada.Calendar.Time;
end Util.Dates;
|
WITH Ada.Text_IO;
USE Ada.Text_IO;
WITH Salas;
USE Salas;
PROCEDURE Probar_Salas IS
S : Sala;
BEGIN
S := Crear_Sala(" Ava ", 12,10);
Put_Line("El afaro de la sala es"& Integer'Image(Aforo_Sala(S)));
Put_Line("La sala tiene"&Integer'Image(Plazas_Libres(S))&" libres.");
Modificar_Pelicula(S, "BlackPanth");
Put_Line("La pelicula proyectada es "&La_Pelicula(S));
Mostrar_Sala(S);
Vender_Localidades_Contiguas(S,9);
Vender_Localidades_Contiguas(S,8);
Vender_Localidades_Contiguas(S,7);
Vender_Localidades_Contiguas(S,6);
Vender_Localidades_Contiguas(S,5);
Vender_Localidades_Contiguas(S,10);
Vender_Localidades_Contiguas(S,6);
Vender_Localidades_Contiguas(S,3);
Vender_Localidades_Contiguas(S,10);
Vender_Localidades_Contiguas(S,10);
Vender_Localidades_Contiguas(S,10);
Vender_Localidades_Contiguas(S,10);
Vender_Localidades_Contiguas(S,6);
Vender_Localidades_Contiguas(S,6);
Put_Line("La sala tiene"&Integer'Image(Plazas_Libres(S))&" libres.");
Mostrar_Sala(S);
Vender_Localidades_Contiguas(S,4);
Vender_Localidades_Contiguas(S,4);
Vender_Localidades_Contiguas(S,4);
Vender_Localidades_Contiguas(S,4);
Vender_Localidades_Contiguas(S,5);
Put_Line("La sala tiene"&Integer'Image(Plazas_Libres(S))&" libres.");
Mostrar_Sala(S);
Vender_Localidades_Contiguas(S,1);
Vender_Localidades_Contiguas(S,2);
Vender_Localidades_Contiguas(S,4);
Vender_Localidades_Contiguas(S,1);
Put_Line("La sala tiene"&Integer'Image(Plazas_Libres(S))&" libres.");
Mostrar_Sala(S);
Vender_Localidades_Contiguas(S,1);
Mostrar_Sala(S);
END Probar_Salas;
|
with ada.text_io, ada.Integer_text_IO, Ada.Text_IO.Text_Streams, Ada.Strings.Fixed, Interfaces.C;
use ada.text_io, ada.Integer_text_IO, Ada.Strings, Ada.Strings.Fixed, Interfaces.C;
procedure linkedList is
type stringptr is access all char_array;
type intlist;
type intlist_PTR is access intlist;
type intlist is record
head : Integer;
tail : intlist_PTR;
end record;
function cons(list : in intlist_PTR; i : in Integer) return intlist_PTR is
out0 : intlist_PTR;
begin
out0 := new intlist;
out0.head := i;
out0.tail := list;
return out0;
end;
function is_empty(foo : in intlist_PTR) return Boolean is
begin
return TRUE;
end;
function rev2(acc : in intlist_PTR; torev : in intlist_PTR) return intlist_PTR is
acc2 : intlist_PTR;
begin
if is_empty(torev)
then
return acc;
else
acc2 := new intlist;
acc2.head := torev.head;
acc2.tail := acc;
return rev2(acc, torev.tail);
end if;
end;
function rev(empty : in intlist_PTR; torev : in intlist_PTR) return intlist_PTR is
begin
return rev2(empty, torev);
end;
procedure test(empty : in intlist_PTR) is
list : intlist_PTR;
i : Integer;
begin
list := empty;
i := (-1);
while i /= 0 loop
Get(i);
if i /= 0
then
list := cons(list, i);
end if;
end loop;
end;
begin
NULL;
end;
|
with OLED_SH1106.Display; use OLED_SH1106.Display;
with Bitmap_Buffer;
with Bitmap_Graphics; use Bitmap_Graphics;
with SPI;
with GPIO;
package body OLED_SH1106 is
Display_Width : constant Natural := 128;
Display_Height: constant Natural := 64;
package Graphics is new Bitmap_Buffer
(Width => Display_Width, Height => Display_Height);
Buffer : aliased Graphics.Buffer;
function Start_Driver return Boolean is
begin
return OLED_SH1106.Display.Module_Init;
end Start_Driver;
procedure Stop_Driver is
begin
SPI.Stop;
GPIO.Close;
end Stop_Driver;
procedure Init_Display is
begin
OLED_SH1106.Display.Reset;
OLED_SH1106.Display.Init_Reg;
delay 0.2;
Write_Reg(16#AF#);
end Init_Display;
procedure Show is
Start : Natural := 0;
begin
for Page in 0..7 loop
-- set page address
Write_Reg(16#B0# + Unsigned_8(Page));
-- set low column address
Write_Reg(16#02#);
-- set high column address
Write_Reg(16#10#);
-- write data
Start_Data;
for I in Start..(Start+Display_Width-1) loop
Write_Data(Buffer.Data(i));
end loop;
Start := Start + Display_Width;
end loop;
end Show;
-- Clear the screen.
procedure Clear(Clr: Color:= Black) is
begin
Graphics.Set(Buffer'access, Clr);
end Clear;
-- Draw a point with size "Size" at poiny X,Y.
procedure Dot(P: Point; Size: Positive:=1; Clr: Color:=White) is
begin
Graphics.Dot(Buffer'access, P, Size, Clr);
end Dot;
procedure Line
(P,Q: Point; Size: Positive:= 1; Clr:Color:= White) is
begin
Graphics.Line(Buffer'access, P, Q, Size, Clr);
end Line;
procedure Rectangle
(P, Q: Point; Size: Positive:= 1; Clr: Color:= White) is
begin
Graphics.Rectangle(Buffer'access, P, Q, Size, Clr);
end Rectangle;
procedure Fill_Rectangle
(P, Q: Point; Clr: Color := White) is
begin
Graphics.Fill_Rectangle(Buffer'access, P, Q, Clr);
end Fill_Rectangle;
procedure Circle
(Center: Point; R:Natural; Size: Positive := 1; Clr: Color:= White) is
begin
Graphics.Circle(Buffer'access, Center, R, Size, Clr);
end Circle;
procedure Fill_Circle
(Center: Point; R: Natural; Clr: Color:= White) is
begin
Graphics.Fill_Circle(Buffer'access, Center, R, Clr);
end Fill_Circle;
procedure Put
(P : Point;
Ch : Character;
Size : Positive:= 12;
Fgnd : Color := White;
Bgnd : Color := Black) is
begin
Graphics.Put(Buffer'access, P, Ch, Size, Fgnd, Bgnd);
end Put;
procedure Put
(P : Point;
Text : String;
Size : Positive:= 12;
Fgnd : Color := White;
Bgnd : Color := Black) is
begin
Graphics.Put(Buffer'access, P, Text, Size, Fgnd, Bgnd);
end Put;
-- Draw a number to the display
procedure Put
(P : Point; -- Position
Num : Natural; -- The number to draw
Size : Positive := 12; -- Font size
Fgnd : Color := White; -- Foreground color
Bgnd : Color := Black) is -- Background color
begin
Graphics.Put(Buffer'access, P, Num, Size, Fgnd, Bgnd);
end Put;
procedure Bitmap
(P: Point; Bytes : Byte_Array_Access; S: Size) is
begin
Graphics.Bitmap(Buffer'access, P, Bytes, S);
end Bitmap;
procedure Bitmap
(P: Point; Icon: Bitmap_Icon) is
begin
Graphics.Bitmap(Buffer'access, P, Icon);
end;
end OLED_SH1106;
|
-- C36205F.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.
--*
-- CHECK THAT ATTRIBUTES GIVE THE CORRECT VALUES FOR
-- UNCONSTRAINED FORMAL PARAMETERS.
-- ATTRIBUTES OF STATIC NON-NULL AGGREGATES
-- DAT 2/17/81
-- JBG 9/11/81
-- JWC 6/28/85 RENAMED TO -AB
WITH REPORT;
PROCEDURE C36205F IS
USE REPORT;
TYPE I_A IS ARRAY (INTEGER RANGE <> ) OF INTEGER;
TYPE I_A_2 IS ARRAY (INTEGER RANGE <> ,
INTEGER RANGE <> ) OF INTEGER;
A10 : I_A (1 .. 10);
A20 : I_A (18 .. 20);
I10 : INTEGER := IDENT_INT (10);
A2_10 : I_A_2 (1 .. I10, 3+I10 .. I10*I10); -- 1..10, 13..20
A2_20 : I_A_2 (11 .. 3*I10, I10+11 .. I10+I10); -- 11..30, 21..20
SUBTYPE STR IS STRING;
ALF : CONSTANT STR(IDENT_INT(1)..IDENT_INT(5)) := "ABCDE";
ARF : STR(5 .. 9) := ALF;
PROCEDURE P1 (A : I_A; FIR, LAS: INTEGER; S : STRING) IS
BEGIN
IF A'FIRST /= FIR
OR A'FIRST(1) /= FIR
THEN
FAILED ("'FIRST IS WRONG " & S);
END IF;
IF A'LAST /= LAS
OR A'LAST(1) /= LAS
THEN
FAILED ("'LAST IS WRONG " & S);
END IF;
IF A'LENGTH /= LAS - FIR + 1
OR A'LENGTH /= A'LENGTH(1)
THEN
FAILED ("'LENGTH IS WRONG " & S);
END IF;
IF (LAS NOT IN A'RANGE AND LAS >= FIR)
OR (FIR NOT IN A'RANGE AND LAS >= FIR)
OR FIR - 1 IN A'RANGE
OR LAS + 1 IN A'RANGE(1)
THEN
FAILED ("'RANGE IS WRONG " & S);
END IF;
END P1;
PROCEDURE P2 (A : I_A_2; F1,L1,F2,L2 : INTEGER; S : STRING) IS
BEGIN
IF A'FIRST /= A'FIRST(1)
OR A'FIRST /= F1
THEN
FAILED ("'FIRST(1) IS WRONG " & S);
END IF;
IF A'LAST(1) /= L1 THEN
FAILED ("'LAST(1) IS WRONG " & S);
END IF;
IF A'LENGTH(1) /= A'LENGTH
OR A'LENGTH /= L1 - F1 + 1
THEN
FAILED ("'LENGTH(1) IS WRONG " & S);
END IF;
IF F1 - 1 IN A'RANGE
OR (F1 NOT IN A'RANGE AND F1 <= L1)
OR (L1 NOT IN A'RANGE(1) AND F1 <= L1)
OR L1 + 1 IN A'RANGE(1)
THEN
FAILED ("'RANGE(1) IS WRONG " & S);
END IF;
IF A'FIRST(2) /= F2 THEN
FAILED ("'FIRST(2) IS WRONG " & S);
END IF;
IF A'LAST(2) /= L2 THEN
FAILED ("'LAST(2) IS WRONG " & S);
END IF;
IF L2 - F2 /= A'LENGTH(2) - 1 THEN
FAILED ("'LENGTH(2) IS WRONG " & S);
END IF;
IF F2 - 1 IN A'RANGE(2)
OR (F2 NOT IN A'RANGE(2) AND A'LENGTH(2) > 0)
OR (L2 NOT IN A'RANGE(2) AND A'LENGTH(2) /= 0)
OR L2 + 1 IN A'RANGE(2)
THEN
FAILED ("'RANGE(2) IS WRONG " & S);
END IF;
END P2;
PROCEDURE S1 (S:STR; F,L:INTEGER; MESS:STRING) IS
BEGIN
IF S'FIRST /= F THEN
FAILED ("STRING 'FIRST IS WRONG " & MESS);
END IF;
IF S'LAST(1) /= L THEN
FAILED ("STRING 'LAST IS WRONG " & MESS);
END IF;
IF S'LENGTH /= L - F + 1
OR S'LENGTH(1) /= S'LENGTH
THEN
FAILED ("STRING 'LENGTH IS WRONG " & MESS);
END IF;
IF (F <= L AND
(F NOT IN S'RANGE
OR L NOT IN S'RANGE
OR F NOT IN S'RANGE(1)
OR L NOT IN S'RANGE(1)))
OR F - 1 IN S'RANGE
OR L + 1 IN S'RANGE(1)
THEN
FAILED ("STRING 'RANGE IS WRONG " & MESS);
END IF;
END S1;
BEGIN
TEST ( "C36205F", "CHECKING ATTRIBUTE VALUES POSSESSED BY FORMAL "&
"PARAMETERS WHOSE ACTUALS ARE UNCONSTRAINED " &
"ARRAYS - STATIC NON-NULL AGGREGATES");
P1 ((3 .. 5 => 2), 3, 5, "P1 16");
P1 ((5 .. 5 => 5), 5, 5, "P1 17");
RESULT;
END C36205F;
|
------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- Web Framework --
-- --
-- Runtime Library Component --
-- --
------------------------------------------------------------------------------
-- --
-- Copyright © 2014-2018, 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$
------------------------------------------------------------------------------
private with Ada.Containers.Hashed_Maps;
private with Ada.Containers.Vectors;
private with League.Strings.Hash;
private with Servlet.Context_Listeners;
with Servlet.Contexts;
private with Servlet.Event_Listeners;
private with Servlet.Servlets;
private with Servlet.Servlet_Registrations;
with Spikedog.Servlet_Contexts;
private with Spikedog.HTTP_Session_Managers;
with Matreshka.Servlet_Dispatchers;
with Matreshka.Servlet_HTTP_Requests;
with Matreshka.Servlet_HTTP_Responses;
with Matreshka.Servlet_Registrations;
with Matreshka.Servlet_Servers;
private with Matreshka.Spikedog_Deployment_Descriptors;
package Matreshka.Servlet_Containers is
type Servlet_Container is
new Matreshka.Servlet_Dispatchers.Context_Dispatcher
and Spikedog.Servlet_Contexts.Spikedog_Servlet_Context
and Servlet.Contexts.Servlet_Context with private;
type Servlet_Container_Access is access all Servlet_Container'Class;
procedure Initialize
(Self : not null access Servlet_Container'Class;
Server : not null Matreshka.Servlet_Servers.Server_Access;
Success : out Boolean);
-- Initializes servlet container. Specified server object must be
-- initialized. Sets Success to False on error during application
-- loading/startup.
procedure Finalize (Self : not null access Servlet_Container'Class);
-- Finalizes servlet container.
procedure Dispatch
(Self : not null access Servlet_Container'Class;
Request : not null
Matreshka.Servlet_HTTP_Requests.HTTP_Servlet_Request_Access;
Response : not null
Matreshka.Servlet_HTTP_Responses.HTTP_Servlet_Response_Access);
-- Dispatch request to filters/servlet.
private
type Container_States is (Uninitialized, Initialization, Initialized);
package Servlet_Context_Listener_Vectors is
new Ada.Containers.Vectors
(Positive,
Servlet.Context_Listeners.Servlet_Context_Listener_Access,
Servlet.Context_Listeners."=");
package Servlet_Registration_Maps is
new Ada.Containers.Hashed_Maps
(League.Strings.Universal_String,
Matreshka.Servlet_Registrations.Servlet_Registration_Access,
League.Strings.Hash,
League.Strings."=",
Matreshka.Servlet_Registrations."=");
type Servlet_Container is
new Matreshka.Servlet_Dispatchers.Context_Dispatcher
and Spikedog.Servlet_Contexts.Spikedog_Servlet_Context
and Servlet.Contexts.Servlet_Context with
record
Descriptor :
Matreshka.Spikedog_Deployment_Descriptors.Deployment_Descriptor_Access;
State : Container_States := Uninitialized;
Context_Listeners : Servlet_Context_Listener_Vectors.Vector;
Servlets : Servlet_Registration_Maps.Map;
Session_Manager :
Spikedog.HTTP_Session_Managers.HTTP_Session_Manager_Access;
end record;
overriding procedure Add_Listener
(Self : not null access Servlet_Container;
Listener : not null Servlet.Event_Listeners.Event_Listener_Access);
overriding function Add_Servlet
(Self : not null access Servlet_Container;
Name : League.Strings.Universal_String;
Instance : not null access Servlet.Servlets.Servlet'Class)
return access Servlet.Servlet_Registrations.Servlet_Registration'Class;
overriding function Get_MIME_Type
(Self : Servlet_Container;
Path : League.Strings.Universal_String)
return League.Strings.Universal_String;
-- Returns the MIME type of the specified file, or null if the MIME type is
-- not known. The MIME type is determined by the configuration of the
-- servlet container, and may be specified in a web application deployment
-- descriptor. Common MIME types include text/html and image/gif.
overriding function Get_Real_Path
(Self : Servlet_Container;
Path : League.Strings.Universal_String)
return League.Strings.Universal_String;
-- Gets the real path corresponding to the given virtual path.
overriding function Get_Servlet_Registration
(Self : not null access Servlet_Container;
Servlet_Name : League.Strings.Universal_String)
return access Servlet.Servlet_Registrations.Servlet_Registration'Class;
overriding procedure Set_Session_Manager
(Self : in out Servlet_Container;
Manager :
not null Spikedog.HTTP_Session_Managers.HTTP_Session_Manager_Access);
end Matreshka.Servlet_Containers;
|
-----------------------------------------------------------------------
-- css-core-values -- Representation of CSS property value(s).
-- Copyright (C) 2017, 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.
-----------------------------------------------------------------------
with Ada.Containers.Ordered_Sets;
with Ada.Finalization;
-- == CSS Values ==
-- The <tt>CSS.Core.Values</tt> package describes types and operations to hold CSS property
-- values. A property value is a list of tokens some of them being strings, urls, integers,
-- typed integers (for example dimensions) or function calls. Each of these token is
-- represented by the <tt>Value_Type</tt> type and the property value is represented by
-- the <tt>Value_List</tt>.
--
-- The value token is created and maintained in the <tt>Repository_Type</tt> that holds all the
-- possible values.
package CSS.Core.Values is
-- The optional value token unit. For example, 12px has the unit <tt>UNIT_PX</tt>.
type Unit_Type is (UNIT_NONE,
UNIT_PERCENT,
UNIT_PX,
UNIT_EX,
UNIT_EM,
UNIT_REM, -- relative font-size of the root element
UNIT_LH, -- relative to line height of the element
UNIT_RLH, -- relative to the line height of the root element
UNIT_IC, -- average character advance of a fullwidth glyph
UNIT_VW, -- relative to 1% of the width of the viewport
UNIT_VH, -- relative to 1% of the height of the viewport
UNIT_VI, -- 1% of viewport’s size in the root element’s inline axis
UNIT_VB, -- 1% of viewport’s size in the root element’s block axis
UNIT_VMIN, -- 1% of viewport’s smaller dimension
UNIT_VMAX, -- 1% of viewport’s larger dimension
UNIT_CM, UNIT_MM, UNIT_IN,
UNIT_DPI,
UNIT_DPCM,
UNIT_DPPX,
UNIT_PI, UNIT_PC, UNIT_PT,
UNIT_DEG, UNIT_RAD, UNIT_GRAD,
UNIT_MS, UNIT_SEC, UNIT_HZ, UNIT_KHZ);
subtype Length_Unit_Type is Unit_Type range UNIT_PX .. UNIT_PT;
subtype Time_Unit_Type is Unit_Type range UNIT_MS .. UNIT_SEC;
subtype Angle_Unit_Type is Unit_Type range UNIT_DEG .. UNIT_GRAD;
-- The type of the value.
type Value_Kind is (VALUE_NULL,
VALUE_IDENT, -- Identifier: left, right, ...
VALUE_STRING, -- String: "..." or '...'
VALUE_URL, -- URL: url(http://...) or url("../img.png")
VALUE_NUMBER, -- Number: .2em or 10
VALUE_COLOR, -- Color: #fed or rgb(10, 20, 30)
VALUE_FUNCTION);
type Value_List;
type Value_List_Access is access all Value_List;
type Value_Type is private;
-- Get a printable representation of the value.
function To_String (Value : in Value_Type) return String;
-- Get the value type.
function Get_Type (Value : in Value_Type) return Value_Kind;
-- Get the value unit.
function Get_Unit (Value : in Value_Type) return Unit_Type;
-- Get the value.
function Get_Value (Value : in Value_Type) return String;
-- Get the function parameters.
function Get_Parameters (Value : in Value_Type) return Value_List_Access;
function "<" (Left, Right : in Value_Type) return Boolean;
EMPTY : constant Value_Type;
type Value_List is tagged private;
function "<" (Left, Right : in Value_List) return Boolean;
-- Append the value to the list.
procedure Append (List : in out Value_List;
Value : in Value_Type);
-- Get the number of values in the list.
function Get_Count (List : in Value_List) return Natural;
-- Get the value at the given list position.
function Get_Value (List : in Value_List;
Pos : in Positive) return Value_Type;
-- Get a printable representation of the list or a subset of the list.
function To_String (List : in Value_List;
From : in Positive := 1;
To : in Positive := Positive'Last;
Sep : in Character := ' ') return String;
-- Compare the two values for identity.
function Compare (Left, Right : in Value_Type) return Boolean;
EMPTY_LIST : constant Value_List;
-- A repository of all known values.
type Repository_Type is new Ada.Finalization.Limited_Controlled with private;
-- Create a color value.
function Create_Color (Repository : in out Repository_Type;
Value : in String) return Value_Type;
-- Create a URL value.
function Create_URL (Repository : in out Repository_Type;
Value : in String) return Value_Type;
-- Create a String value.
function Create_String (Repository : in out Repository_Type;
Value : in String) return Value_Type;
-- Create an identifier value.
function Create_Ident (Repository : in out Repository_Type;
Value : in String) return Value_Type;
-- Create a function value with one parameter.
function Create_Function (Repository : in out Repository_Type;
Name : in String;
Parameter : in Value_Type) return Value_Type;
-- Create a function value with parameters.
function Create_Function (Repository : in out Repository_Type;
Name : in String;
Parameters : in Value_List'Class) return Value_Type;
-- Create a number value with an optional unit.
function Create_Number (Repository : in out Repository_Type;
Value : in String;
Unit : in Unit_Type := UNIT_NONE) return Value_Type;
-- Return the number of entries in the repository.
function Length (Repository : in Repository_Type) return Natural;
-- Iterate over the list of properties and call the <tt>Process</tt> procedure.
procedure Iterate (Repository : in Repository_Type;
Process : not null access procedure (Value : in Value_Type));
private
type Value_Node;
type Value_Type is access all Value_Node;
type Value_Node (Len : Natural;
Kind : Value_Kind) is
limited record
Unit : Unit_Type;
Params : Value_List_Access;
Value : String (1 .. Len);
end record;
-- The Value_Sets package represents a set of values all of
-- them being strictly different.
package Value_Sets is
new Ada.Containers.Ordered_Sets (Element_Type => Value_Type,
"<" => "<",
"=" => Compare);
-- Release the storage held by the selector sub-tree.
procedure Finalize (Node : in out Value_Node);
type Repository_Type is new Ada.Finalization.Limited_Controlled with record
Root : Value_Sets.Set;
end record;
function Create_Value (Repository : in out Repository_Type;
Value : in Value_Type) return Value_Type;
-- Release the values held by the repository.
overriding
procedure Finalize (Object : in out Repository_Type);
type Value_Array is array (Positive range <>) of Value_Type;
type Value_List is new Ada.Finalization.Controlled with record
Next : Value_List_Access;
Values : Value_Array (1 .. 10);
Count : Natural := 0;
end record;
-- Copy the value list chain if there is one.
overriding
procedure Adjust (Object : in out Value_List);
-- Release the values.
overriding
procedure Finalize (Object : in out Value_List);
EMPTY : constant Value_Type := null;
EMPTY_LIST : constant Value_List := Value_List '(Ada.Finalization.Controlled with
Next => null,
Values => (others => null),
Count => 0);
end CSS.Core.Values;
|
function System.Address_Image (A : Address)
return Storage_Elements.Formatting.Address_String
is
pragma Suppress (All_Checks);
begin
return Storage_Elements.Formatting.Image (A);
end System.Address_Image;
|
with Ada.Characters.Handling;
with Ada.Containers;
with Ada.Containers.Indefinite_Hashed_Maps;
with Ada.Strings.Hash;
package body Opt50_Pkg is
type Enum_Name is array (Enum) of access constant String;
Enum_Name_Table : constant Enum_Name := (
One => new String'("one"),
Two => new String'("two"),
Three => new String'("three"));
package String_To_Enum_Map is new Ada.Containers.Indefinite_Hashed_Maps
(Key_Type => String, Element_Type => Enum,
Hash => Ada.Strings.Hash, Equivalent_Keys => "=");
function Fill_Hashed_Map return String_To_Enum_Map.Map is
Res : String_To_Enum_Map.Map;
use String_To_Enum_Map;
begin
for I in Enum_Name_Table'Range loop
declare
Kind : constant String := Enum_Name_Table (I).all;
begin
Res.Insert(Key => Kind, New_Item => I);
end;
end loop;
return Res;
end;
String_To_Enum : constant String_To_Enum_Map.Map := Fill_Hashed_Map;
procedure Get (Kind : String; Result : out Enum; Success : out Boolean) is
X : constant String := Ada.Characters.Handling.To_Lower (Kind);
use String_To_Enum_Map;
Curs : constant Cursor := String_To_Enum.Find (X);
begin
Success := Curs /= No_Element;
if Success then
Result := Element(Curs);
end if;
end;
procedure Set (A : Enum_Boolean_Array) is null;
end Opt50_Pkg;
|
-- Automatically generated, do not edit.
with Interfaces.C;
with System;
package OpenGL.Thin is
package C renames Interfaces.C;
-- Constants
GL_S : constant := 16#2000#;
GL_T : constant := 16#2001#;
GL_R : constant := 16#2002#;
GL_Q : constant := 16#2003#;
GL_OR : constant := 16#1507#;
GL_2D : constant := 16#600#;
GL_3D : constant := 16#601#;
GL_CW : constant := 16#900#;
GL_ONE : constant := 16#1#;
GL_ADD : constant := 16#104#;
GL_INT : constant := 16#1404#;
GL_AND : constant := 16#1501#;
GL_XOR : constant := 16#1506#;
GL_NOR : constant := 16#1508#;
GL_SET : constant := 16#150f#;
GL_RED : constant := 16#1903#;
GL_RGB : constant := 16#1907#;
GL_V2F : constant := 16#2a20#;
GL_V3F : constant := 16#2a21#;
GL_EXP : constant := 16#800#;
GL_MIN : constant := 16#8007#;
GL_MAX : constant := 16#8008#;
GL_BGR : constant := 16#80e0#;
GL_CCW : constant := 16#901#;
GL_FOG : constant := 16#b60#;
GL_NONE : constant := 16#0#;
GL_ZERO : constant := 16#0#;
GL_TRUE : constant := 16#1#;
GL_LOAD : constant := 16#101#;
GL_MULT : constant := 16#103#;
GL_BYTE : constant := 16#1400#;
GL_COPY : constant := 16#1503#;
GL_NOOP : constant := 16#1505#;
GL_NAND : constant := 16#150e#;
GL_BLUE : constant := 16#1905#;
GL_RGBA : constant := 16#1908#;
GL_LINE : constant := 16#1b01#;
GL_FILL : constant := 16#1b02#;
GL_FLAT : constant := 16#1d00#;
GL_KEEP : constant := 16#1e00#;
GL_INCR : constant := 16#1e02#;
GL_DECR : constant := 16#1e03#;
GL_LESS : constant := 16#201#;
GL_BACK : constant := 16#405#;
GL_LEFT : constant := 16#406#;
GL_AUX0 : constant := 16#409#;
GL_AUX1 : constant := 16#40a#;
GL_AUX2 : constant := 16#40b#;
GL_AUX3 : constant := 16#40c#;
GL_EXP2 : constant := 16#801#;
GL_RGB4 : constant := 16#804f#;
GL_RGB5 : constant := 16#8050#;
GL_RGB8 : constant := 16#8051#;
GL_BGRA : constant := 16#80e1#;
GL_SRGB : constant := 16#8C40#;
GL_FALSE : constant := 16#0#;
GL_LINES : constant := 16#1#;
GL_ACCUM : constant := 16#100#;
GL_SHORT : constant := 16#1402#;
GL_FLOAT : constant := 16#1406#;
GL_CLEAR : constant := 16#1500#;
GL_EQUIV : constant := 16#1509#;
GL_COLOR : constant := 16#1800#;
GL_DEPTH : constant := 16#1801#;
GL_GREEN : constant := 16#1904#;
GL_ALPHA : constant := 16#1906#;
GL_POINT : constant := 16#1b00#;
GL_NEVER : constant := 16#200#;
GL_EQUAL : constant := 16#202#;
GL_DECAL : constant := 16#2101#;
GL_CLAMP : constant := 16#2900#;
GL_FRONT : constant := 16#404#;
GL_RIGHT : constant := 16#407#;
GL_QUADS : constant := 16#7#;
GL_RGB10 : constant := 16#8052#;
GL_RGB12 : constant := 16#8053#;
GL_RGB16 : constant := 16#8054#;
GL_RGBA2 : constant := 16#8055#;
GL_RGBA4 : constant := 16#8056#;
GL_RGBA8 : constant := 16#8058#;
GL_SRGB8 : constant := 16#8C41#;
GL_COEFF : constant := 16#a00#;
GL_ORDER : constant := 16#a01#;
GL_BLEND : constant := 16#be2#;
GL_POINTS : constant := 16#0#;
GL_RETURN : constant := 16#102#;
GL_NICEST : constant := 16#1102#;
GL_DOUBLE : constant := 16#140a#;
GL_INVERT : constant := 16#150a#;
GL_BITMAP : constant := 16#1a00#;
GL_RENDER : constant := 16#1c00#;
GL_SELECT : constant := 16#1c02#;
GL_SMOOTH : constant := 16#1d01#;
GL_VENDOR : constant := 16#1f00#;
GL_LEQUAL : constant := 16#203#;
GL_GEQUAL : constant := 16#206#;
GL_ALWAYS : constant := 16#207#;
GL_LINEAR : constant := 16#2601#;
GL_REPEAT : constant := 16#2901#;
GL_LIGHT0 : constant := 16#4000#;
GL_LIGHT1 : constant := 16#4001#;
GL_LIGHT2 : constant := 16#4002#;
GL_LIGHT3 : constant := 16#4003#;
GL_LIGHT4 : constant := 16#4004#;
GL_LIGHT5 : constant := 16#4005#;
GL_LIGHT6 : constant := 16#4006#;
GL_LIGHT7 : constant := 16#4007#;
GL_REDUCE : constant := 16#8016#;
GL_MINMAX : constant := 16#802e#;
GL_ALPHA4 : constant := 16#803b#;
GL_ALPHA8 : constant := 16#803c#;
GL_RGBA12 : constant := 16#805a#;
GL_RGBA16 : constant := 16#805b#;
GL_DOMAIN : constant := 16#a02#;
GL_DITHER : constant := 16#bd0#;
GL_STEREO : constant := 16#c33#;
GL_ZOOM_X : constant := 16#d16#;
GL_ZOOM_Y : constant := 16#d17#;
GL_FASTEST : constant := 16#1101#;
GL_AMBIENT : constant := 16#1200#;
GL_DIFFUSE : constant := 16#1201#;
GL_COMPILE : constant := 16#1300#;
GL_2_BYTES : constant := 16#1407#;
GL_3_BYTES : constant := 16#1408#;
GL_4_BYTES : constant := 16#1409#;
GL_TEXTURE : constant := 16#1702#;
GL_STENCIL : constant := 16#1802#;
GL_REPLACE : constant := 16#1e01#;
GL_VERSION : constant := 16#1f02#;
GL_GREATER : constant := 16#204#;
GL_NEAREST : constant := 16#2600#;
GL_C3F_V3F : constant := 16#2a24#;
GL_N3F_V3F : constant := 16#2a25#;
GL_T2F_V3F : constant := 16#2a27#;
GL_T4F_V4F : constant := 16#2a28#;
GL_FOG_BIT : constant := 16#80#;
GL_ALPHA12 : constant := 16#803d#;
GL_ALPHA16 : constant := 16#803e#;
GL_RGB5_A1 : constant := 16#8057#;
GL_SAMPLES : constant := 16#80a9#;
GL_COMBINE : constant := 16#8570#;
GL_POLYGON : constant := 16#9#;
GL_FOG_END : constant := 16#b64#;
GL_NO_ERROR : constant := 16#0#;
GL_EVAL_BIT : constant := 16#10000#;
GL_SPECULAR : constant := 16#1202#;
GL_POSITION : constant := 16#1203#;
GL_EMISSION : constant := 16#1600#;
GL_FEEDBACK : constant := 16#1c01#;
GL_RENDERER : constant := 16#1f01#;
GL_LIST_BIT : constant := 16#20000#;
GL_NOTEQUAL : constant := 16#205#;
GL_MODULATE : constant := 16#2100#;
GL_R3_G3_B2 : constant := 16#2a10#;
GL_C4UB_V2F : constant := 16#2a22#;
GL_C4UB_V3F : constant := 16#2a23#;
GL_LINE_BIT : constant := 16#4#;
GL_3D_COLOR : constant := 16#602#;
GL_HINT_BIT : constant := 16#8000#;
GL_FUNC_ADD : constant := 16#8006#;
GL_RGB10_A2 : constant := 16#8059#;
GL_TEXTURE0 : constant := 16#84c0#;
GL_TEXTURE1 : constant := 16#84c1#;
GL_TEXTURE2 : constant := 16#84c2#;
GL_TEXTURE3 : constant := 16#84c3#;
GL_TEXTURE4 : constant := 16#84c4#;
GL_TEXTURE5 : constant := 16#84c5#;
GL_TEXTURE6 : constant := 16#84c6#;
GL_TEXTURE7 : constant := 16#84c7#;
GL_TEXTURE8 : constant := 16#84c8#;
GL_TEXTURE9 : constant := 16#84c9#;
GL_SUBTRACT : constant := 16#84e7#;
GL_CONSTANT : constant := 16#8576#;
GL_PREVIOUS : constant := 16#8578#;
GL_SRC0_RGB : constant := 16#8580#;
GL_SRC1_RGB : constant := 16#8581#;
GL_SRC2_RGB : constant := 16#8582#;
GL_DOT3_RGB : constant := 16#86ae#;
GL_SRGB_EXT : constant := 16#8C40#;
GL_LIGHTING : constant := 16#b50#;
GL_FOG_MODE : constant := 16#b65#;
GL_VIEWPORT : constant := 16#ba2#;
GL_LOGIC_OP : constant := 16#bf1#;
GL_FOG_HINT : constant := 16#c54#;
GL_RED_BIAS : constant := 16#d15#;
GL_RED_BITS : constant := 16#d52#;
GL_DONT_CARE : constant := 16#1100#;
GL_SHININESS : constant := 16#1601#;
GL_MODELVIEW : constant := 16#1700#;
GL_LUMINANCE : constant := 16#1909#;
GL_LINE_LOOP : constant := 16#2#;
GL_POINT_BIT : constant := 16#2#;
GL_EYE_PLANE : constant := 16#2502#;
GL_SRC_COLOR : constant := 16#300#;
GL_SRC_ALPHA : constant := 16#302#;
GL_DST_ALPHA : constant := 16#304#;
GL_DST_COLOR : constant := 16#306#;
GL_TRIANGLES : constant := 16#4#;
GL_BACK_LEFT : constant := 16#402#;
GL_HISTOGRAM : constant := 16#8024#;
GL_INTENSITY : constant := 16#8049#;
GL_FOG_COORD : constant := 16#8451#;
GL_COLOR_SUM : constant := 16#8458#;
GL_TEXTURE10 : constant := 16#84ca#;
GL_TEXTURE11 : constant := 16#84cb#;
GL_TEXTURE12 : constant := 16#84cc#;
GL_TEXTURE13 : constant := 16#84cd#;
GL_TEXTURE14 : constant := 16#84ce#;
GL_TEXTURE15 : constant := 16#84cf#;
GL_TEXTURE16 : constant := 16#84d0#;
GL_TEXTURE17 : constant := 16#84d1#;
GL_TEXTURE18 : constant := 16#84d2#;
GL_TEXTURE19 : constant := 16#84d3#;
GL_TEXTURE20 : constant := 16#84d4#;
GL_TEXTURE21 : constant := 16#84d5#;
GL_TEXTURE22 : constant := 16#84d6#;
GL_TEXTURE23 : constant := 16#84d7#;
GL_TEXTURE24 : constant := 16#84d8#;
GL_TEXTURE25 : constant := 16#84d9#;
GL_TEXTURE26 : constant := 16#84da#;
GL_TEXTURE27 : constant := 16#84db#;
GL_TEXTURE28 : constant := 16#84dc#;
GL_TEXTURE29 : constant := 16#84dd#;
GL_TEXTURE30 : constant := 16#84de#;
GL_TEXTURE31 : constant := 16#84df#;
GL_RGB_SCALE : constant := 16#8573#;
GL_DOT3_RGBA : constant := 16#86af#;
GL_SRGB8_EXT : constant := 16#8C41#;
GL_LIST_MODE : constant := 16#b30#;
GL_LIST_BASE : constant := 16#b32#;
GL_EDGE_FLAG : constant := 16#b43#;
GL_CULL_FACE : constant := 16#b44#;
GL_FOG_INDEX : constant := 16#b61#;
GL_FOG_START : constant := 16#b63#;
GL_FOG_COLOR : constant := 16#b66#;
GL_NORMALIZE : constant := 16#ba1#;
GL_BLEND_DST : constant := 16#be0#;
GL_BLEND_SRC : constant := 16#be1#;
GL_RGBA_MODE : constant := 16#c31#;
GL_MAP_COLOR : constant := 16#d10#;
GL_RED_SCALE : constant := 16#d14#;
GL_BLUE_BIAS : constant := 16#d1b#;
GL_BLUE_BITS : constant := 16#d54#;
GL_OR_REVERSE : constant := 16#150b#;
GL_PROJECTION : constant := 16#1701#;
GL_EXTENSIONS : constant := 16#1f03#;
GL_ENABLE_BIT : constant := 16#2000#;
GL_EYE_LINEAR : constant := 16#2400#;
GL_SPHERE_MAP : constant := 16#2402#;
GL_LINE_STRIP : constant := 16#3#;
GL_FRONT_LEFT : constant := 16#400#;
GL_BACK_RIGHT : constant := 16#403#;
GL_LINE_TOKEN : constant := 16#702#;
GL_QUAD_STRIP : constant := 16#8#;
GL_LUMINANCE4 : constant := 16#803f#;
GL_LUMINANCE8 : constant := 16#8040#;
GL_INTENSITY4 : constant := 16#804a#;
GL_INTENSITY8 : constant := 16#804b#;
GL_TEXTURE_3D : constant := 16#806f#;
GL_NORMAL_MAP : constant := 16#8511#;
GL_ADD_SIGNED : constant := 16#8574#;
GL_SRC0_ALPHA : constant := 16#8588#;
GL_SRC1_ALPHA : constant := 16#8589#;
GL_SRC2_ALPHA : constant := 16#858A#;
GL_SRGB_ALPHA : constant := 16#8C42#;
GL_SLUMINANCE : constant := 16#8C46#;
GL_POINT_SIZE : constant := 16#b11#;
GL_LINE_WIDTH : constant := 16#b21#;
GL_LIST_INDEX : constant := 16#b33#;
GL_FRONT_FACE : constant := 16#b46#;
GL_DEPTH_TEST : constant := 16#b71#;
GL_DEPTH_FUNC : constant := 16#b74#;
GL_ALPHA_TEST : constant := 16#bc0#;
GL_INDEX_MODE : constant := 16#c30#;
GL_GREEN_BIAS : constant := 16#d19#;
GL_BLUE_SCALE : constant := 16#d1a#;
GL_ALPHA_BIAS : constant := 16#d1d#;
GL_DEPTH_BIAS : constant := 16#d1f#;
GL_MAX_LIGHTS : constant := 16#d31#;
GL_INDEX_BITS : constant := 16#d51#;
GL_GREEN_BITS : constant := 16#d53#;
GL_ALPHA_BITS : constant := 16#d55#;
GL_DEPTH_BITS : constant := 16#d56#;
GL_MAP1_INDEX : constant := 16#d91#;
GL_MAP2_INDEX : constant := 16#db1#;
GL_TEXTURE_1D : constant := 16#de0#;
GL_TEXTURE_2D : constant := 16#de1#;
GL_ARB_imaging : constant := 16#1#;
GL_CURRENT_BIT : constant := 16#1#;
GL_SPOT_CUTOFF : constant := 16#1206#;
GL_AND_REVERSE : constant := 16#1502#;
GL_OR_INVERTED : constant := 16#150d#;
GL_COLOR_INDEX : constant := 16#1900#;
GL_TEXTURE_ENV : constant := 16#2300#;
GL_C4F_N3F_V3F : constant := 16#2a26#;
GL_T2F_C3F_V3F : constant := 16#2a2a#;
GL_T2F_N3F_V3F : constant := 16#2a2b#;
GL_CLIP_PLANE0 : constant := 16#3000#;
GL_CLIP_PLANE1 : constant := 16#3001#;
GL_CLIP_PLANE2 : constant := 16#3002#;
GL_CLIP_PLANE3 : constant := 16#3003#;
GL_CLIP_PLANE4 : constant := 16#3004#;
GL_CLIP_PLANE5 : constant := 16#3005#;
GL_TEXTURE_BIT : constant := 16#40000#;
GL_FRONT_RIGHT : constant := 16#401#;
GL_POINT_TOKEN : constant := 16#701#;
GL_POLYGON_BIT : constant := 16#8#;
GL_SCISSOR_BIT : constant := 16#80000#;
GL_BLEND_COLOR : constant := 16#8005#;
GL_MINMAX_SINK : constant := 16#8030#;
GL_LUMINANCE12 : constant := 16#8041#;
GL_LUMINANCE16 : constant := 16#8042#;
GL_INTENSITY12 : constant := 16#804c#;
GL_INTENSITY16 : constant := 16#804d#;
GL_COLOR_ARRAY : constant := 16#8076#;
GL_INDEX_ARRAY : constant := 16#8077#;
GL_MULTISAMPLE : constant := 16#809d#;
GL_COLOR_TABLE : constant := 16#80d0#;
GL_COMBINE_RGB : constant := 16#8571#;
GL_INTERPOLATE : constant := 16#8575#;
GL_SOURCE0_RGB : constant := 16#8580#;
GL_SOURCE1_RGB : constant := 16#8581#;
GL_SOURCE2_RGB : constant := 16#8582#;
GL_STREAM_DRAW : constant := 16#88E0#;
GL_STREAM_READ : constant := 16#88E1#;
GL_STREAM_COPY : constant := 16#88E2#;
GL_STATIC_DRAW : constant := 16#88E4#;
GL_STATIC_READ : constant := 16#88E5#;
GL_STATIC_COPY : constant := 16#88E6#;
GL_SLUMINANCE8 : constant := 16#8C47#;
GL_LINE_SMOOTH : constant := 16#b20#;
GL_SHADE_MODEL : constant := 16#b54#;
GL_FOG_DENSITY : constant := 16#b62#;
GL_DEPTH_RANGE : constant := 16#b70#;
GL_STENCIL_REF : constant := 16#b97#;
GL_MATRIX_MODE : constant := 16#ba0#;
GL_AUX_BUFFERS : constant := 16#c00#;
GL_DRAW_BUFFER : constant := 16#c01#;
GL_READ_BUFFER : constant := 16#c02#;
GL_SCISSOR_BOX : constant := 16#c10#;
GL_RENDER_MODE : constant := 16#c40#;
GL_MAP_STENCIL : constant := 16#d11#;
GL_INDEX_SHIFT : constant := 16#d12#;
GL_GREEN_SCALE : constant := 16#d18#;
GL_ALPHA_SCALE : constant := 16#d1c#;
GL_DEPTH_SCALE : constant := 16#d1e#;
GL_AUTO_NORMAL : constant := 16#d80#;
GL_MAP1_NORMAL : constant := 16#d92#;
GL_MAP2_NORMAL : constant := 16#db2#;
GL_MAP_READ_BIT : constant := 16#1#;
GL_UNSIGNED_INT : constant := 16#1405#;
GL_AND_INVERTED : constant := 16#1504#;
GL_OBJECT_PLANE : constant := 16#2501#;
GL_T2F_C4UB_V3F : constant := 16#2a29#;
GL_LIGHTING_BIT : constant := 16#40#;
GL_INVALID_ENUM : constant := 16#500#;
GL_TRIANGLE_FAN : constant := 16#6#;
GL_BITMAP_TOKEN : constant := 16#704#;
GL_VIEWPORT_BIT : constant := 16#800#;
GL_SEPARABLE_2D : constant := 16#8012#;
GL_VERTEX_ARRAY : constant := 16#8074#;
GL_NORMAL_ARRAY : constant := 16#8075#;
GL_COLOR_MATRIX : constant := 16#80b1#;
GL_SINGLE_COLOR : constant := 16#81f9#;
GL_TEXTURE0_ARB : constant := 16#84c0#;
GL_TEXTURE1_ARB : constant := 16#84c1#;
GL_TEXTURE2_ARB : constant := 16#84c2#;
GL_TEXTURE3_ARB : constant := 16#84c3#;
GL_TEXTURE4_ARB : constant := 16#84c4#;
GL_TEXTURE5_ARB : constant := 16#84c5#;
GL_TEXTURE6_ARB : constant := 16#84c6#;
GL_TEXTURE7_ARB : constant := 16#84c7#;
GL_TEXTURE8_ARB : constant := 16#84c8#;
GL_TEXTURE9_ARB : constant := 16#84c9#;
GL_OPERAND0_RGB : constant := 16#8590#;
GL_OPERAND1_RGB : constant := 16#8591#;
GL_OPERAND2_RGB : constant := 16#8592#;
GL_POINT_SPRITE : constant := 16#8861#;
GL_ARRAY_BUFFER : constant := 16#8892#;
GL_DYNAMIC_DRAW : constant := 16#88E8#;
GL_DYNAMIC_READ : constant := 16#88E9#;
GL_DYNAMIC_COPY : constant := 16#88EA#;
GL_SRGB8_ALPHA8 : constant := 16#8C43#;
GL_POINT_SMOOTH : constant := 16#b10#;
GL_LINE_STIPPLE : constant := 16#b24#;
GL_POLYGON_MODE : constant := 16#b40#;
GL_STENCIL_TEST : constant := 16#b90#;
GL_STENCIL_FUNC : constant := 16#b92#;
GL_STENCIL_FAIL : constant := 16#b94#;
GL_SCISSOR_TEST : constant := 16#c11#;
GL_DOUBLEBUFFER : constant := 16#c32#;
GL_INDEX_OFFSET : constant := 16#d13#;
GL_STENCIL_BITS : constant := 16#d57#;
GL_MAP1_COLOR_4 : constant := 16#d90#;
GL_MAP2_COLOR_4 : constant := 16#db0#;
GL_TEXTURE_WIDTH : constant := 16#1000#;
GL_TRANSFORM_BIT : constant := 16#1000#;
GL_SPOT_EXPONENT : constant := 16#1205#;
GL_UNSIGNED_BYTE : constant := 16#1401#;
GL_COPY_INVERTED : constant := 16#150c#;
GL_COLOR_INDEXES : constant := 16#1603#;
GL_STENCIL_INDEX : constant := 16#1901#;
GL_MAP_WRITE_BIT : constant := 16#2#;
GL_OBJECT_LINEAR : constant := 16#2401#;
GL_INVALID_VALUE : constant := 16#501#;
GL_OUT_OF_MEMORY : constant := 16#505#;
GL_POLYGON_TOKEN : constant := 16#703#;
GL_FUNC_SUBTRACT : constant := 16#800a#;
GL_MINMAX_FORMAT : constant := 16#802f#;
GL_TEXTURE_DEPTH : constant := 16#8071#;
GL_CLAMP_TO_EDGE : constant := 16#812f#;
GL_FOG_COORD_SRC : constant := 16#8450#;
GL_TEXTURE10_ARB : constant := 16#84ca#;
GL_TEXTURE11_ARB : constant := 16#84cb#;
GL_TEXTURE12_ARB : constant := 16#84cc#;
GL_TEXTURE13_ARB : constant := 16#84cd#;
GL_TEXTURE14_ARB : constant := 16#84ce#;
GL_TEXTURE15_ARB : constant := 16#84cf#;
GL_TEXTURE16_ARB : constant := 16#84d0#;
GL_TEXTURE17_ARB : constant := 16#84d1#;
GL_TEXTURE18_ARB : constant := 16#84d2#;
GL_TEXTURE19_ARB : constant := 16#84d3#;
GL_TEXTURE20_ARB : constant := 16#84d4#;
GL_TEXTURE21_ARB : constant := 16#84d5#;
GL_TEXTURE22_ARB : constant := 16#84d6#;
GL_TEXTURE23_ARB : constant := 16#84d7#;
GL_TEXTURE24_ARB : constant := 16#84d8#;
GL_TEXTURE25_ARB : constant := 16#84d9#;
GL_TEXTURE26_ARB : constant := 16#84da#;
GL_TEXTURE27_ARB : constant := 16#84db#;
GL_TEXTURE28_ARB : constant := 16#84dc#;
GL_TEXTURE29_ARB : constant := 16#84dd#;
GL_TEXTURE30_ARB : constant := 16#84de#;
GL_TEXTURE31_ARB : constant := 16#84df#;
GL_COMBINE_ALPHA : constant := 16#8572#;
GL_PRIMARY_COLOR : constant := 16#8577#;
GL_SOURCE0_ALPHA : constant := 16#8588#;
GL_SOURCE1_ALPHA : constant := 16#8589#;
GL_SOURCE2_ALPHA : constant := 16#858a#;
GL_COORD_REPLACE : constant := 16#8862#;
GL_CURRENT_COLOR : constant := 16#b00#;
GL_CURRENT_INDEX : constant := 16#b01#;
GL_LOGIC_OP_MODE : constant := 16#bf0#;
GL_TEXTURE_GEN_S : constant := 16#c60#;
GL_TEXTURE_GEN_T : constant := 16#c61#;
GL_TEXTURE_GEN_R : constant := 16#c62#;
GL_TEXTURE_GEN_Q : constant := 16#c63#;
GL_SUBPIXEL_BITS : constant := 16#d50#;
GL_MAP1_VERTEX_3 : constant := 16#d97#;
GL_MAP1_VERTEX_4 : constant := 16#d98#;
GL_MAP2_VERTEX_3 : constant := 16#db7#;
GL_MAP2_VERTEX_4 : constant := 16#db8#;
GL_TEXTURE_HEIGHT : constant := 16#1001#;
GL_TEXTURE_BORDER : constant := 16#1005#;
GL_SPOT_DIRECTION : constant := 16#1204#;
GL_UNSIGNED_SHORT : constant := 16#1403#;
GL_PIXEL_MODE_BIT : constant := 16#20#;
GL_TEXTURE_WRAP_S : constant := 16#2802#;
GL_TEXTURE_WRAP_T : constant := 16#2803#;
GL_FRONT_AND_BACK : constant := 16#408#;
GL_TRIANGLE_STRIP : constant := 16#5#;
GL_STACK_OVERFLOW : constant := 16#503#;
GL_CONSTANT_COLOR : constant := 16#8001#;
GL_CONSTANT_ALPHA : constant := 16#8003#;
GL_BLEND_EQUATION : constant := 16#8009#;
GL_CONVOLUTION_1D : constant := 16#8010#;
GL_CONVOLUTION_2D : constant := 16#8011#;
GL_HISTOGRAM_SINK : constant := 16#802d#;
GL_RESCALE_NORMAL : constant := 16#803a#;
GL_TEXTURE_WRAP_R : constant := 16#8072#;
GL_SAMPLE_BUFFERS : constant := 16#80a8#;
GL_FRAGMENT_DEPTH : constant := 16#8452#;
GL_ACTIVE_TEXTURE : constant := 16#84e0#;
GL_COMPRESSED_RGB : constant := 16#84ed#;
GL_REFLECTION_MAP : constant := 16#8512#;
GL_OPERAND0_ALPHA : constant := 16#8598#;
GL_OPERAND1_ALPHA : constant := 16#8599#;
GL_OPERAND2_ALPHA : constant := 16#859a#;
GL_UNIFORM_BUFFER : constant := 16#8A11#;
GL_TEXTURE_BUFFER : constant := 16#8C2A#;
GL_SRGB_ALPHA_EXT : constant := 16#8C42#;
GL_SLUMINANCE_EXT : constant := 16#8C46#;
GL_CURRENT_NORMAL : constant := 16#b02#;
GL_POLYGON_SMOOTH : constant := 16#b41#;
GL_CULL_FACE_MODE : constant := 16#b45#;
GL_COLOR_MATERIAL : constant := 16#b57#;
GL_TEXTURE_MATRIX : constant := 16#ba8#;
GL_ALPHA_TEST_REF : constant := 16#bc2#;
GL_INDEX_LOGIC_OP : constant := 16#bf1#;
GL_COLOR_LOGIC_OP : constant := 16#bf2#;
GL_PACK_LSB_FIRST : constant := 16#d01#;
GL_PACK_SKIP_ROWS : constant := 16#d03#;
GL_PACK_ALIGNMENT : constant := 16#d05#;
GL_MAX_EVAL_ORDER : constant := 16#d30#;
GL_ACCUM_RED_BITS : constant := 16#d58#;
GL_DEPTH_COMPONENT : constant := 16#1902#;
GL_LUMINANCE_ALPHA : constant := 16#190a#;
GL_MULTISAMPLE_BIT : constant := 16#20000000#;
GL_T2F_C4F_N3F_V3F : constant := 16#2a2c#;
GL_T4F_C4F_N3F_V4F : constant := 16#2a2d#;
GL_STACK_UNDERFLOW : constant := 16#504#;
GL_PROXY_HISTOGRAM : constant := 16#8025#;
GL_HISTOGRAM_WIDTH : constant := 16#8026#;
GL_TABLE_TOO_LARGE : constant := 16#8031#;
GL_EDGE_FLAG_ARRAY : constant := 16#8079#;
GL_SAMPLE_COVERAGE : constant := 16#80a0#;
GL_CLAMP_TO_BORDER : constant := 16#812d#;
GL_TEXTURE_MIN_LOD : constant := 16#813a#;
GL_TEXTURE_MAX_LOD : constant := 16#813b#;
GL_CONSTANT_BORDER : constant := 16#8151#;
GL_GENERATE_MIPMAP : constant := 16#8191#;
GL_MIRRORED_REPEAT : constant := 16#8370#;
GL_FOG_COORD_ARRAY : constant := 16#8457#;
GL_COMPRESSED_RGBA : constant := 16#84ee#;
GL_SLUMINANCE8_EXT : constant := 16#8C47#;
GL_COMPRESSED_SRGB : constant := 16#8C48#;
GL_POLYGON_STIPPLE : constant := 16#b42#;
GL_DEPTH_WRITEMASK : constant := 16#b72#;
GL_ALPHA_TEST_FUNC : constant := 16#bc1#;
GL_INDEX_WRITEMASK : constant := 16#c21#;
GL_COLOR_WRITEMASK : constant := 16#c23#;
GL_PACK_SWAP_BYTES : constant := 16#d00#;
GL_PACK_ROW_LENGTH : constant := 16#d02#;
GL_MAX_CLIP_PLANES : constant := 16#d32#;
GL_ACCUM_BLUE_BITS : constant := 16#d5a#;
GL_ALL_ATTRIB_BITS : constant := 16#fffff#;
GL_ARB_multitexture : constant := 16#1#;
GL_DEPTH_BUFFER_BIT : constant := 16#100#;
GL_ACCUM_BUFFER_BIT : constant := 16#200#;
GL_TEXTURE_ENV_MODE : constant := 16#2200#;
GL_TEXTURE_GEN_MODE : constant := 16#2500#;
GL_COLOR_BUFFER_BIT : constant := 16#4000#;
GL_3D_COLOR_TEXTURE : constant := 16#603#;
GL_4D_COLOR_TEXTURE : constant := 16#604#;
GL_DRAW_PIXEL_TOKEN : constant := 16#705#;
GL_COPY_PIXEL_TOKEN : constant := 16#706#;
GL_LINE_RESET_TOKEN : constant := 16#707#;
GL_HISTOGRAM_FORMAT : constant := 16#8027#;
GL_TEXTURE_RED_SIZE : constant := 16#805c#;
GL_PROXY_TEXTURE_1D : constant := 16#8063#;
GL_PROXY_TEXTURE_2D : constant := 16#8064#;
GL_TEXTURE_PRIORITY : constant := 16#8066#;
GL_TEXTURE_RESIDENT : constant := 16#8067#;
GL_PACK_SKIP_IMAGES : constant := 16#806b#;
GL_PROXY_TEXTURE_3D : constant := 16#8070#;
GL_COLOR_ARRAY_SIZE : constant := 16#8081#;
GL_COLOR_ARRAY_TYPE : constant := 16#8082#;
GL_INDEX_ARRAY_TYPE : constant := 16#8085#;
GL_COLOR_TABLE_BIAS : constant := 16#80d7#;
GL_REPLICATE_BORDER : constant := 16#8153#;
GL_COMPRESSED_ALPHA : constant := 16#84e9#;
GL_TEXTURE_LOD_BIAS : constant := 16#8501#;
GL_TEXTURE_CUBE_MAP : constant := 16#8513#;
GL_SRGB8_ALPHA8_EXT : constant := 16#8C43#;
GL_SLUMINANCE_ALPHA : constant := 16#8C44#;
GL_COPY_READ_BUFFER : constant := 16#8F36#;
GL_POINT_SIZE_RANGE : constant := 16#b12#;
GL_LINE_WIDTH_RANGE : constant := 16#b22#;
GL_MAX_LIST_NESTING : constant := 16#b31#;
GL_MODELVIEW_MATRIX : constant := 16#ba6#;
GL_LINE_SMOOTH_HINT : constant := 16#c52#;
GL_PIXEL_MAP_I_TO_I : constant := 16#c70#;
GL_PIXEL_MAP_S_TO_S : constant := 16#c71#;
GL_PIXEL_MAP_I_TO_R : constant := 16#c72#;
GL_PIXEL_MAP_I_TO_G : constant := 16#c73#;
GL_PIXEL_MAP_I_TO_B : constant := 16#c74#;
GL_PIXEL_MAP_I_TO_A : constant := 16#c75#;
GL_PIXEL_MAP_R_TO_R : constant := 16#c76#;
GL_PIXEL_MAP_G_TO_G : constant := 16#c77#;
GL_PIXEL_MAP_B_TO_B : constant := 16#c78#;
GL_PIXEL_MAP_A_TO_A : constant := 16#c79#;
GL_UNPACK_LSB_FIRST : constant := 16#cf1#;
GL_UNPACK_SKIP_ROWS : constant := 16#cf3#;
GL_UNPACK_ALIGNMENT : constant := 16#cf5#;
GL_PACK_SKIP_PIXELS : constant := 16#d04#;
GL_MAX_TEXTURE_SIZE : constant := 16#d33#;
GL_ACCUM_GREEN_BITS : constant := 16#d59#;
GL_ACCUM_ALPHA_BITS : constant := 16#d5b#;
GL_NAME_STACK_DEPTH : constant := 16#d70#;
GL_MAP1_GRID_DOMAIN : constant := 16#dd0#;
GL_MAP2_GRID_DOMAIN : constant := 16#dd2#;
GL_TEXTURE_ENV_COLOR : constant := 16#2201#;
GL_INVALID_OPERATION : constant := 16#502#;
GL_CONVOLUTION_WIDTH : constant := 16#8018#;
GL_LUMINANCE4_ALPHA4 : constant := 16#8043#;
GL_LUMINANCE6_ALPHA2 : constant := 16#8044#;
GL_LUMINANCE8_ALPHA8 : constant := 16#8045#;
GL_TEXTURE_BLUE_SIZE : constant := 16#805e#;
GL_PACK_IMAGE_HEIGHT : constant := 16#806c#;
GL_VERTEX_ARRAY_SIZE : constant := 16#807a#;
GL_VERTEX_ARRAY_TYPE : constant := 16#807b#;
GL_NORMAL_ARRAY_TYPE : constant := 16#807e#;
GL_PROXY_COLOR_TABLE : constant := 16#80d3#;
GL_COLOR_TABLE_SCALE : constant := 16#80d6#;
GL_COLOR_TABLE_WIDTH : constant := 16#80d9#;
GL_TEXTURE_MAX_LEVEL : constant := 16#813d#;
GL_MAX_TEXTURE_UNITS : constant := 16#84e2#;
GL_PIXEL_PACK_BUFFER : constant := 16#88EB#;
GL_COPY_WRITE_BUFFER : constant := 16#8F37#;
GL_DEPTH_CLEAR_VALUE : constant := 16#b73#;
GL_ACCUM_CLEAR_VALUE : constant := 16#b80#;
GL_STENCIL_WRITEMASK : constant := 16#b98#;
GL_PROJECTION_MATRIX : constant := 16#ba7#;
GL_INDEX_CLEAR_VALUE : constant := 16#c20#;
GL_COLOR_CLEAR_VALUE : constant := 16#c22#;
GL_POINT_SMOOTH_HINT : constant := 16#c51#;
GL_UNPACK_SWAP_BYTES : constant := 16#cf0#;
GL_UNPACK_ROW_LENGTH : constant := 16#cf2#;
GL_MAX_VIEWPORT_DIMS : constant := 16#d3a#;
GL_TEXTURE_COMPONENTS : constant := 16#1003#;
GL_LINEAR_ATTENUATION : constant := 16#1208#;
GL_TEXTURE_MAG_FILTER : constant := 16#2800#;
GL_TEXTURE_MIN_FILTER : constant := 16#2801#;
GL_SRC_ALPHA_SATURATE : constant := 16#308#;
GL_STENCIL_BUFFER_BIT : constant := 16#400#;
GL_PASS_THROUGH_TOKEN : constant := 16#700#;
GL_CONVOLUTION_FORMAT : constant := 16#8017#;
GL_CONVOLUTION_HEIGHT : constant := 16#8019#;
GL_HISTOGRAM_RED_SIZE : constant := 16#8028#;
GL_LUMINANCE12_ALPHA4 : constant := 16#8046#;
GL_TEXTURE_GREEN_SIZE : constant := 16#805d#;
GL_TEXTURE_ALPHA_SIZE : constant := 16#805f#;
GL_TEXTURE_BINDING_1D : constant := 16#8068#;
GL_TEXTURE_BINDING_2D : constant := 16#8069#;
GL_TEXTURE_BINDING_3D : constant := 16#806a#;
GL_UNPACK_SKIP_IMAGES : constant := 16#806d#;
GL_COLOR_ARRAY_STRIDE : constant := 16#8083#;
GL_INDEX_ARRAY_STRIDE : constant := 16#8086#;
GL_COLOR_TABLE_FORMAT : constant := 16#80d8#;
GL_TEXTURE_BASE_LEVEL : constant := 16#813c#;
GL_ACTIVE_TEXTURE_ARB : constant := 16#84e0#;
GL_TEXTURE_COMPRESSED : constant := 16#86a1#;
GL_DEPTH_TEXTURE_MODE : constant := 16#884B#;
GL_MAX_VERTEX_ATTRIBS : constant := 16#8869#;
GL_SLUMINANCE8_ALPHA8 : constant := 16#8C45#;
GL_STENCIL_VALUE_MASK : constant := 16#b93#;
GL_ATTRIB_STACK_DEPTH : constant := 16#bb0#;
GL_UNPACK_SKIP_PIXELS : constant := 16#cf4#;
GL_MAP1_GRID_SEGMENTS : constant := 16#dd1#;
GL_MAP2_GRID_SEGMENTS : constant := 16#dd3#;
GL_POLYGON_STIPPLE_BIT : constant := 16#10#;
GL_COMPILE_AND_EXECUTE : constant := 16#1301#;
GL_AMBIENT_AND_DIFFUSE : constant := 16#1602#;
GL_POLYGON_OFFSET_LINE : constant := 16#2a02#;
GL_ONE_MINUS_SRC_COLOR : constant := 16#301#;
GL_ONE_MINUS_SRC_ALPHA : constant := 16#303#;
GL_ONE_MINUS_DST_ALPHA : constant := 16#305#;
GL_ONE_MINUS_DST_COLOR : constant := 16#307#;
GL_HISTOGRAM_BLUE_SIZE : constant := 16#802a#;
GL_UNSIGNED_BYTE_3_3_2 : constant := 16#8032#;
GL_POLYGON_OFFSET_FILL : constant := 16#8037#;
GL_LUMINANCE12_ALPHA12 : constant := 16#8047#;
GL_LUMINANCE16_ALPHA16 : constant := 16#8048#;
GL_UNPACK_IMAGE_HEIGHT : constant := 16#806e#;
GL_MAX_3D_TEXTURE_SIZE : constant := 16#8073#;
GL_TEXTURE_COORD_ARRAY : constant := 16#8078#;
GL_VERTEX_ARRAY_STRIDE : constant := 16#807c#;
GL_NORMAL_ARRAY_STRIDE : constant := 16#807f#;
GL_COLOR_ARRAY_POINTER : constant := 16#8090#;
GL_INDEX_ARRAY_POINTER : constant := 16#8091#;
GL_SAMPLE_ALPHA_TO_ONE : constant := 16#809f#;
GL_PIXEL_UNPACK_BUFFER : constant := 16#88EC#;
GL_COMPRESSED_SRGB_EXT : constant := 16#8C48#;
GL_LINE_STIPPLE_REPEAT : constant := 16#b26#;
GL_LIGHT_MODEL_AMBIENT : constant := 16#b53#;
GL_COLOR_MATERIAL_FACE : constant := 16#b55#;
GL_STENCIL_CLEAR_VALUE : constant := 16#b91#;
GL_TEXTURE_STACK_DEPTH : constant := 16#ba5#;
GL_POLYGON_SMOOTH_HINT : constant := 16#c53#;
GL_MAX_PIXEL_MAP_TABLE : constant := 16#d34#;
GL_TEXTURE_BORDER_COLOR : constant := 16#1004#;
GL_CONSTANT_ATTENUATION : constant := 16#1207#;
GL_LINEAR_MIPMAP_LINEAR : constant := 16#2703#;
GL_POLYGON_OFFSET_UNITS : constant := 16#2a00#;
GL_POLYGON_OFFSET_POINT : constant := 16#2a01#;
GL_HISTOGRAM_GREEN_SIZE : constant := 16#8029#;
GL_HISTOGRAM_ALPHA_SIZE : constant := 16#802b#;
GL_UNSIGNED_INT_8_8_8_8 : constant := 16#8035#;
GL_VERTEX_ARRAY_POINTER : constant := 16#808e#;
GL_NORMAL_ARRAY_POINTER : constant := 16#808f#;
GL_COLOR_TABLE_RED_SIZE : constant := 16#80da#;
GL_MAX_ELEMENTS_INDICES : constant := 16#80e9#;
GL_UNSIGNED_SHORT_5_6_5 : constant := 16#8363#;
GL_TEXTURE_RECTANGLE_NV : constant := 16#84F5#;
GL_COMPRESSED_LUMINANCE : constant := 16#84ea#;
GL_COMPRESSED_INTENSITY : constant := 16#84ec#;
GL_TEXTURE_COMPARE_MODE : constant := 16#884C#;
GL_TEXTURE_COMPARE_FUNC : constant := 16#884D#;
GL_ELEMENT_ARRAY_BUFFER : constant := 16#8893#;
GL_SLUMINANCE_ALPHA_EXT : constant := 16#8C44#;
GL_CURRENT_RASTER_COLOR : constant := 16#b04#;
GL_CURRENT_RASTER_INDEX : constant := 16#b05#;
GL_LINE_STIPPLE_PATTERN : constant := 16#b25#;
GL_LIGHT_MODEL_TWO_SIDE : constant := 16#b52#;
GL_MAX_NAME_STACK_DEPTH : constant := 16#d37#;
GL_MAP1_TEXTURE_COORD_1 : constant := 16#d93#;
GL_MAP1_TEXTURE_COORD_2 : constant := 16#d94#;
GL_MAP1_TEXTURE_COORD_3 : constant := 16#d95#;
GL_MAP1_TEXTURE_COORD_4 : constant := 16#d96#;
GL_MAP2_TEXTURE_COORD_1 : constant := 16#db3#;
GL_MAP2_TEXTURE_COORD_2 : constant := 16#db4#;
GL_MAP2_TEXTURE_COORD_3 : constant := 16#db5#;
GL_MAP2_TEXTURE_COORD_4 : constant := 16#db6#;
GL_FEEDBACK_BUFFER_SIZE : constant := 16#df1#;
GL_FEEDBACK_BUFFER_TYPE : constant := 16#df2#;
GL_QUADRATIC_ATTENUATION : constant := 16#1209#;
GL_LINEAR_MIPMAP_NEAREST : constant := 16#2701#;
GL_NEAREST_MIPMAP_LINEAR : constant := 16#2702#;
GL_FUNC_REVERSE_SUBTRACT : constant := 16#800b#;
GL_MAX_CONVOLUTION_WIDTH : constant := 16#801a#;
GL_POLYGON_OFFSET_FACTOR : constant := 16#8038#;
GL_SAMPLE_COVERAGE_VALUE : constant := 16#80aa#;
GL_COLOR_TABLE_BLUE_SIZE : constant := 16#80dc#;
GL_MAX_ELEMENTS_VERTICES : constant := 16#80e8#;
GL_SECONDARY_COLOR_ARRAY : constant := 16#845e#;
GL_TEXTURE_RECTANGLE_ARB : constant := 16#84F5#;
GL_CLIENT_ACTIVE_TEXTURE : constant := 16#84e1#;
GL_MAX_TEXTURE_UNITS_ARB : constant := 16#84e2#;
GL_COMPRESSED_SRGB_ALPHA : constant := 16#8C49#;
GL_COMPRESSED_SLUMINANCE : constant := 16#8C4A#;
GL_MODELVIEW_STACK_DEPTH : constant := 16#ba3#;
GL_PIXEL_MAP_I_TO_I_SIZE : constant := 16#cb0#;
GL_PIXEL_MAP_S_TO_S_SIZE : constant := 16#cb1#;
GL_PIXEL_MAP_I_TO_R_SIZE : constant := 16#cb2#;
GL_PIXEL_MAP_I_TO_G_SIZE : constant := 16#cb3#;
GL_PIXEL_MAP_I_TO_B_SIZE : constant := 16#cb4#;
GL_PIXEL_MAP_I_TO_A_SIZE : constant := 16#cb5#;
GL_PIXEL_MAP_R_TO_R_SIZE : constant := 16#cb6#;
GL_PIXEL_MAP_G_TO_G_SIZE : constant := 16#cb7#;
GL_PIXEL_MAP_B_TO_B_SIZE : constant := 16#cb8#;
GL_PIXEL_MAP_A_TO_A_SIZE : constant := 16#cb9#;
GL_SELECTION_BUFFER_SIZE : constant := 16#df4#;
GL_CLIENT_PIXEL_STORE_BIT : constant := 16#1#;
GL_MAP_FLUSH_EXPLICIT_BIT : constant := 16#10#;
GL_MAP_UNSYNCHRONIZED_BIT : constant := 16#20#;
GL_NEAREST_MIPMAP_NEAREST : constant := 16#2700#;
GL_MAX_CONVOLUTION_HEIGHT : constant := 16#801b#;
GL_UNSIGNED_SHORT_4_4_4_4 : constant := 16#8033#;
GL_UNSIGNED_SHORT_5_5_5_1 : constant := 16#8034#;
GL_TEXTURE_LUMINANCE_SIZE : constant := 16#8060#;
GL_TEXTURE_INTENSITY_SIZE : constant := 16#8061#;
GL_EDGE_FLAG_ARRAY_STRIDE : constant := 16#808c#;
GL_SAMPLE_COVERAGE_INVERT : constant := 16#80ab#;
GL_COLOR_TABLE_GREEN_SIZE : constant := 16#80db#;
GL_COLOR_TABLE_ALPHA_SIZE : constant := 16#80dd#;
GL_TRANSPOSE_COLOR_MATRIX : constant := 16#84e6#;
GL_TEXTURE_FILTER_CONTROL : constant := 16#8500#;
GL_PROXY_TEXTURE_CUBE_MAP : constant := 16#851b#;
GL_SLUMINANCE8_ALPHA8_EXT : constant := 16#8C45#;
GL_CURRENT_TEXTURE_COORDS : constant := 16#b03#;
GL_POINT_SIZE_GRANULARITY : constant := 16#b13#;
GL_LINE_WIDTH_GRANULARITY : constant := 16#b23#;
GL_PROJECTION_STACK_DEPTH : constant := 16#ba4#;
GL_MAX_ATTRIB_STACK_DEPTH : constant := 16#d35#;
GL_ALL_CLIENT_ATTRIB_BITS : constant := 16#ffffffff#;
GL_CLIENT_ALL_ATTRIB_BITS : constant := 16#ffffffff#;
GL_TEXTURE_INTERNAL_FORMAT : constant := 16#1003#;
GL_CLIENT_VERTEX_ARRAY_BIT : constant := 16#2#;
GL_CONVOLUTION_BORDER_MODE : constant := 16#8013#;
GL_CONVOLUTION_FILTER_BIAS : constant := 16#8015#;
GL_UNSIGNED_INT_10_10_10_2 : constant := 16#8036#;
GL_EDGE_FLAG_ARRAY_POINTER : constant := 16#8093#;
GL_SEPARATE_SPECULAR_COLOR : constant := 16#81fa#;
GL_UNSIGNED_BYTE_2_3_3_REV : constant := 16#8362#;
GL_VERTEX_PROGRAM_TWO_SIDE : constant := 16#8643#;
GL_CURRENT_RASTER_POSITION : constant := 16#b07#;
GL_CURRENT_RASTER_DISTANCE : constant := 16#b09#;
GL_SMOOTH_POINT_SIZE_RANGE : constant := 16#b12#;
GL_SMOOTH_LINE_WIDTH_RANGE : constant := 16#b22#;
GL_STENCIL_PASS_DEPTH_FAIL : constant := 16#b95#;
GL_STENCIL_PASS_DEPTH_PASS : constant := 16#b96#;
GL_MAX_TEXTURE_STACK_DEPTH : constant := 16#d39#;
GL_FEEDBACK_BUFFER_POINTER : constant := 16#df0#;
GL_MAP_INVALIDATE_RANGE_BIT : constant := 16#4#;
GL_ONE_MINUS_CONSTANT_COLOR : constant := 16#8002#;
GL_ONE_MINUS_CONSTANT_ALPHA : constant := 16#8004#;
GL_CONVOLUTION_FILTER_SCALE : constant := 16#8014#;
GL_HISTOGRAM_LUMINANCE_SIZE : constant := 16#802c#;
GL_TEXTURE_COORD_ARRAY_SIZE : constant := 16#8088#;
GL_TEXTURE_COORD_ARRAY_TYPE : constant := 16#8089#;
GL_SAMPLE_ALPHA_TO_COVERAGE : constant := 16#809e#;
GL_COLOR_MATRIX_STACK_DEPTH : constant := 16#80b2#;
GL_CONVOLUTION_BORDER_COLOR : constant := 16#8154#;
GL_UNSIGNED_SHORT_5_6_5_REV : constant := 16#8364#;
GL_UNSIGNED_INT_8_8_8_8_REV : constant := 16#8367#;
GL_ALIASED_POINT_SIZE_RANGE : constant := 16#846d#;
GL_ALIASED_LINE_WIDTH_RANGE : constant := 16#846e#;
GL_TRANSPOSE_TEXTURE_MATRIX : constant := 16#84e5#;
GL_TEXTURE_COMPRESSION_HINT : constant := 16#84ef#;
GL_TEXTURE_BINDING_CUBE_MAP : constant := 16#8514#;
GL_LIGHT_MODEL_LOCAL_VIEWER : constant := 16#b51#;
GL_COLOR_MATERIAL_PARAMETER : constant := 16#b56#;
GL_SELECTION_BUFFER_POINTER : constant := 16#df3#;
GL_MAP_INVALIDATE_BUFFER_BIT : constant := 16#8#;
GL_POST_CONVOLUTION_RED_BIAS : constant := 16#8020#;
GL_LIGHT_MODEL_COLOR_CONTROL : constant := 16#81f8#;
GL_CLIENT_ACTIVE_TEXTURE_ARB : constant := 16#84e1#;
GL_MAX_CUBE_MAP_TEXTURE_SIZE : constant := 16#851c#;
GL_VERTEX_PROGRAM_POINT_SIZE : constant := 16#8642#;
GL_COMPRESSED_SRGB_ALPHA_EXT : constant := 16#8C49#;
GL_COMPRESSED_SLUMINANCE_EXT : constant := 16#8C4A#;
GL_TRANSFORM_FEEDBACK_BUFFER : constant := 16#8C8E#;
GL_CLIENT_ATTRIB_STACK_DEPTH : constant := 16#bb1#;
GL_MAX_MODELVIEW_STACK_DEPTH : constant := 16#d36#;
GL_POST_CONVOLUTION_RED_SCALE : constant := 16#801c#;
GL_POST_CONVOLUTION_BLUE_BIAS : constant := 16#8022#;
GL_TEXTURE_COORD_ARRAY_STRIDE : constant := 16#808a#;
GL_POST_COLOR_MATRIX_RED_BIAS : constant := 16#80b8#;
GL_COLOR_TABLE_LUMINANCE_SIZE : constant := 16#80de#;
GL_COLOR_TABLE_INTENSITY_SIZE : constant := 16#80df#;
GL_UNSIGNED_SHORT_4_4_4_4_REV : constant := 16#8365#;
GL_UNSIGNED_SHORT_1_5_5_5_REV : constant := 16#8366#;
GL_PROXY_TEXTURE_RECTANGLE_NV : constant := 16#84F7#;
GL_TRANSPOSE_MODELVIEW_MATRIX : constant := 16#84e3#;
GL_COMPRESSED_LUMINANCE_ALPHA : constant := 16#84eb#;
GL_COMPRESSED_TEXTURE_FORMATS : constant := 16#86a3#;
GL_MAX_PROJECTION_STACK_DEPTH : constant := 16#d38#;
GL_POST_CONVOLUTION_BLUE_SCALE : constant := 16#801e#;
GL_POST_CONVOLUTION_GREEN_BIAS : constant := 16#8021#;
GL_POST_CONVOLUTION_ALPHA_BIAS : constant := 16#8023#;
GL_TEXTURE_COORD_ARRAY_POINTER : constant := 16#8092#;
GL_POST_COLOR_MATRIX_RED_SCALE : constant := 16#80b4#;
GL_POST_COLOR_MATRIX_BLUE_BIAS : constant := 16#80ba#;
GL_UNSIGNED_INT_2_10_10_10_REV : constant := 16#8368#;
GL_PROXY_TEXTURE_RECTANGLE_ARB : constant := 16#84F7#;
GL_TRANSPOSE_PROJECTION_MATRIX : constant := 16#84e4#;
GL_TEXTURE_CUBE_MAP_POSITIVE_X : constant := 16#8515#;
GL_TEXTURE_CUBE_MAP_NEGATIVE_X : constant := 16#8516#;
GL_TEXTURE_CUBE_MAP_POSITIVE_Y : constant := 16#8517#;
GL_TEXTURE_CUBE_MAP_NEGATIVE_Y : constant := 16#8518#;
GL_TEXTURE_CUBE_MAP_POSITIVE_Z : constant := 16#8519#;
GL_TEXTURE_CUBE_MAP_NEGATIVE_Z : constant := 16#851a#;
GL_COMPRESSED_SLUMINANCE_ALPHA : constant := 16#8C4B#;
GL_PERSPECTIVE_CORRECTION_HINT : constant := 16#c50#;
GL_POST_CONVOLUTION_GREEN_SCALE : constant := 16#801d#;
GL_POST_CONVOLUTION_ALPHA_SCALE : constant := 16#801f#;
GL_MAX_COLOR_MATRIX_STACK_DEPTH : constant := 16#80b3#;
GL_POST_COLOR_MATRIX_BLUE_SCALE : constant := 16#80b6#;
GL_POST_COLOR_MATRIX_GREEN_BIAS : constant := 16#80b9#;
GL_POST_COLOR_MATRIX_ALPHA_BIAS : constant := 16#80bb#;
GL_POST_CONVOLUTION_COLOR_TABLE : constant := 16#80d1#;
GL_TEXTURE_BINDING_RECTANGLE_NV : constant := 16#84F6#;
GL_INVALID_FRAMEBUFFER_OPERATION : constant := 16#506#;
GL_POST_COLOR_MATRIX_GREEN_SCALE : constant := 16#80b5#;
GL_POST_COLOR_MATRIX_ALPHA_SCALE : constant := 16#80b7#;
GL_POST_COLOR_MATRIX_COLOR_TABLE : constant := 16#80d2#;
GL_TEXTURE_BINDING_RECTANGLE_ARB : constant := 16#84F6#;
GL_MAX_RECTANGLE_TEXTURE_SIZE_NV : constant := 16#84F8#;
GL_TEXTURE_COMPRESSED_IMAGE_SIZE : constant := 16#86a0#;
GL_COMPRESSED_SRGB_S3TC_DXT1_EXT : constant := 16#8C4C#;
GL_CURRENT_RASTER_TEXTURE_COORDS : constant := 16#b06#;
GL_CURRENT_RASTER_POSITION_VALID : constant := 16#b08#;
GL_SMOOTH_POINT_SIZE_GRANULARITY : constant := 16#b13#;
GL_SMOOTH_LINE_WIDTH_GRANULARITY : constant := 16#b23#;
GL_MAX_CLIENT_ATTRIB_STACK_DEPTH : constant := 16#d3b#;
GL_MAX_RECTANGLE_TEXTURE_SIZE_ARB : constant := 16#84F8#;
GL_NUM_COMPRESSED_TEXTURE_FORMATS : constant := 16#86a2#;
GL_COMPRESSED_SLUMINANCE_ALPHA_EXT : constant := 16#8C4B#;
GL_PROXY_POST_CONVOLUTION_COLOR_TABLE : constant := 16#80d4#;
GL_PROXY_POST_COLOR_MATRIX_COLOR_TABLE : constant := 16#80d5#;
GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT : constant := 16#8C4D#;
GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT : constant := 16#8C4E#;
GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT : constant := 16#8C4F#;
--
-- Types
--
type String_t is new System.Address;
-- GLfloat
type Float_t is new C.C_float;
-- GLdouble
type Double_t is new C.double;
-- GLsizeiptr
type Size_Pointer_t is mod 2 ** System.Word_Size;
for Size_Pointer_t'Size use System.Word_Size;
pragma Convention (C, Size_Pointer_t);
-- GLintptr
type Integer_Pointer_t is mod 2 ** System.Word_Size;
for Integer_Pointer_t'Size use System.Word_Size;
pragma Convention (C, Integer_Pointer_t);
-- GLbitfield
type Bitfield_t is mod 2 ** 32;
for Bitfield_t'Size use 32;
pragma Convention (C, Bitfield_t);
-- GLboolean
type Boolean_t is new Boolean;
for Boolean_t'Size use 8;
pragma Convention (C, Boolean_t);
-- GLbyte
type Byte_t is range -127 .. 127;
for Byte_t'Size use 8;
pragma Convention (C, Byte_t);
-- GLclampd
subtype Clamped_Double_t is Double_t range 0.0 .. 1.0;
-- GLclampf
subtype Clamped_Float_t is Float_t range 0.0 .. 1.0;
-- GLenum
type Enumeration_t is mod 2 ** 32;
for Enumeration_t'Size use 32;
pragma Convention (C, Enumeration_t);
-- GLint
type Integer_t is range -2147483647 .. 2147483647;
for Integer_t'Size use 32;
pragma Convention (C, Integer_t);
-- GLshort
type Short_t is range -32767 .. 32767;
for Short_t'Size use 16;
pragma Convention (C, Short_t);
-- GLsizei
type Size_t is range -2147483647 .. 2147483647;
for Size_t'Size use 32;
pragma Convention (C, Size_t);
-- GLubyte
type Unsigned_Byte_t is mod 2 ** 8;
for Unsigned_Byte_t'Size use 8;
pragma Convention (C, Unsigned_Byte_t);
-- GLuint
type Unsigned_Integer_t is mod 2 ** 32;
for Unsigned_Integer_t'Size use 32;
pragma Convention (C, Unsigned_Integer_t);
-- GLushort
type Unsigned_Short_t is mod 2 ** 16;
for Unsigned_Short_t'Size use 16;
pragma Convention (C, Unsigned_Short_t);
-- GLvoid *
subtype Void_Pointer_t is System.Address;
-- GLvoid **
type Void_Pointer_Access_t is access all Void_Pointer_t;
pragma Convention (C, Void_Pointer_Access_t);
-- const GLvoid **
type Void_Pointer_Access_Constant_t is access constant System.Address;
pragma Convention (C, Void_Pointer_Access_Constant_t);
--
-- OpenGL 1.1
--
procedure Accum
(Operation : Enumeration_t;
Value : Float_t);
pragma Import (C, Accum, "glAccum");
procedure Alpha_Func
(Func : Enumeration_t;
Reference : Clamped_Float_t);
pragma Import (C, Alpha_Func, "glAlphaFunc");
function Are_Textures_Resident
(Size : Size_t;
Textures : System.Address;
Residences : System.Address) return Boolean_t;
pragma Import (C, Are_Textures_Resident, "glAreTexturesResident");
procedure Array_Element
(Index : Integer_t);
pragma Import (C, Array_Element, "glArrayElement");
procedure GL_Begin
(Mode : Enumeration_t);
pragma Import (C, GL_Begin, "glBegin");
procedure Bind_Texture
(Target : Enumeration_t;
Texture : Unsigned_Integer_t);
pragma Import (C, Bind_Texture, "glBindTexture");
procedure Bitmap
(Width : Size_t;
Height : Size_t;
X_Original : Float_t;
Y_Original : Float_t;
X_Move : Float_t;
Y_Move : Float_t;
Bitmap_Data : System.Address);
pragma Import (C, Bitmap, "glBitmap");
procedure Blend_Func
(Source_Factor : Enumeration_t;
Target_Factor : Enumeration_t);
pragma Import (C, Blend_Func, "glBlendFunc");
procedure Call_List
(List : Unsigned_Integer_t);
pragma Import (C, Call_List, "glCallList");
procedure Call_Lists
(Number : Size_t;
Value_Type : Enumeration_t;
Lists : System.Address);
pragma Import (C, Call_Lists, "glCallLists");
procedure Clear
(Mask : Bitfield_t);
pragma Import (C, Clear, "glClear");
procedure Clear_Accum
(Red : Float_t;
Green : Float_t;
Blue : Float_t;
Alpha : Float_t);
pragma Import (C, Clear_Accum, "glClearAccum");
procedure Clear_Color
(Red : Clamped_Float_t;
Green : Clamped_Float_t;
Blue : Clamped_Float_t;
Alpha : Clamped_Float_t);
pragma Import (C, Clear_Color, "glClearColor");
procedure Clear_Depth
(Depth : Clamped_Double_t);
pragma Import (C, Clear_Depth, "glClearDepth");
procedure Clear_Index
(Index : Float_t);
pragma Import (C, Clear_Index, "glClearIndex");
procedure Clear_Stencil
(Index : Integer_t);
pragma Import (C, Clear_Stencil, "glClearStencil");
procedure Clip_Plane
(Plane : Enumeration_t;
Equation : System.Address);
pragma Import (C, Clip_Plane, "glClipPlane");
procedure Color_3b
(Red : Byte_t;
Green : Byte_t;
Blue : Byte_t);
pragma Import (C, Color_3b, "glColor3b");
procedure Color_3d
(Red : Double_t;
Green : Double_t;
Blue : Double_t);
pragma Import (C, Color_3d, "glColor3d");
procedure Color_3f
(Red : Float_t;
Green : Float_t;
Blue : Float_t);
pragma Import (C, Color_3f, "glColor3f");
procedure Color_3i
(Red : Integer_t;
Green : Integer_t;
Blue : Integer_t);
pragma Import (C, Color_3i, "glColor3i");
procedure Color_3s
(Red : Short_t;
Green : Short_t;
Blue : Short_t);
pragma Import (C, Color_3s, "glColor3s");
procedure Color_4b
(Red : Byte_t;
Green : Byte_t;
Blue : Byte_t;
Alpha : Byte_t);
pragma Import (C, Color_4b, "glColor4b");
procedure Color_4d
(Red : Double_t;
Green : Double_t;
Blue : Double_t;
Alpha : Double_t);
pragma Import (C, Color_4d, "glColor4d");
procedure Color_4f
(Red : Float_t;
Green : Float_t;
Blue : Float_t;
Alpha : Float_t);
pragma Import (C, Color_4f, "glColor4f");
procedure Color_4i
(Red : Integer_t;
Green : Integer_t;
Blue : Integer_t;
Alpha : Integer_t);
pragma Import (C, Color_4i, "glColor4i");
procedure Color_4s
(Red : Short_t;
Green : Short_t;
Blue : Short_t;
Alpha : Short_t);
pragma Import (C, Color_4s, "glColor4s");
procedure Color_Mask
(Red : Boolean_t;
Green : Boolean_t;
Blue : Boolean_t;
Alpha : Boolean_t);
pragma Import (C, Color_Mask, "glColorMask");
procedure Color_Material
(Face : Enumeration_t;
Mode : Enumeration_t);
pragma Import (C, Color_Material, "glColorMaterial");
procedure Color_Pointer
(Size : Integer_t;
Data_Type : Enumeration_t;
Stride : Size_t;
Pointer : System.Address);
pragma Import (C, Color_Pointer, "glColorPointer");
procedure Copy_Pixels
(X : Integer_t;
Y : Integer_t;
Width : Size_t;
Height : Size_t;
Value_Type : Enumeration_t);
pragma Import (C, Copy_Pixels, "glCopyPixels");
procedure Copy_Tex_Image_1D
(Target : Enumeration_t;
Level : Integer_t;
Internal_Format : Enumeration_t;
X : Integer_t;
Y : Integer_t;
Width : Size_t;
Border : Integer_t);
pragma Import (C, Copy_Tex_Image_1D, "glCopyTexImage1D");
procedure Copy_Tex_Image_2D
(Target : Enumeration_t;
Level : Integer_t;
Internal_Format : Enumeration_t;
X : Integer_t;
Y : Integer_t;
Width : Size_t;
Height : Size_t;
Border : Integer_t);
pragma Import (C, Copy_Tex_Image_2D, "glCopyTexImage2D");
procedure Copy_Tex_Sub_Image_1D
(Target : Enumeration_t;
Level : Integer_t;
X_Offset : Integer_t;
X : Integer_t;
Y : Integer_t;
Width : Size_t);
pragma Import (C, Copy_Tex_Sub_Image_1D, "glCopyTexSubImage1D");
procedure Copy_Tex_Sub_Image_2D
(Target : Enumeration_t;
Level : Integer_t;
X_Offset : Integer_t;
Y_Offset : Integer_t;
X : Integer_t;
Y : Integer_t;
Width : Size_t;
Height : Size_t);
pragma Import (C, Copy_Tex_Sub_Image_2D, "glCopyTexSubImage2D");
procedure Cull_Face
(Mode : Enumeration_t);
pragma Import (C, Cull_Face, "glCullFace");
procedure Delete_Lists
(List : Unsigned_Integer_t;
List_Range : Size_t);
pragma Import (C, Delete_Lists, "glDeleteLists");
procedure Delete_Textures
(Size : Size_t;
Textures : System.Address);
pragma Import (C, Delete_Textures, "glDeleteTextures");
procedure Depth_Func
(Func : Enumeration_t);
pragma Import (C, Depth_Func, "glDepthFunc");
procedure Depth_Mask
(Flag : Boolean_t);
pragma Import (C, Depth_Mask, "glDepthMask");
procedure Depth_Range
(Near_Value : Clamped_Double_t;
Far_Value : Clamped_Double_t);
pragma Import (C, Depth_Range, "glDepthRange");
procedure Disable
(Capability : Enumeration_t);
pragma Import (C, Disable, "glDisable");
procedure Disable_Client_State
(Capability : Enumeration_t);
pragma Import (C, Disable_Client_State, "glDisableClientState");
procedure Draw_Arrays
(Mode : Enumeration_t;
First : Integer_t;
Count : Size_t);
pragma Import (C, Draw_Arrays, "glDrawArrays");
procedure Draw_Buffer
(Mode : Enumeration_t);
pragma Import (C, Draw_Buffer, "glDrawBuffer");
procedure Draw_Elements
(Mode : Enumeration_t;
Count : Size_t;
Value_Type : Enumeration_t;
Indices : System.Address);
pragma Import (C, Draw_Elements, "glDrawElements");
procedure Draw_Pixels
(Width : Size_t;
Height : Size_t;
Format : Enumeration_t;
Data_Type : Enumeration_t;
Data : System.Address);
pragma Import (C, Draw_Pixels, "glDrawPixels");
procedure Edge_Flag
(Flag : Boolean_t);
pragma Import (C, Edge_Flag, "glEdgeFlag");
procedure Edge_Flag_Pointer
(Stride : Size_t;
Pointer : System.Address);
pragma Import (C, Edge_Flag_Pointer, "glEdgeFlagPointer");
procedure Edge_Flagv
(Flag : System.Address);
pragma Import (C, Edge_Flagv, "glEdgeFlagv");
procedure Enable
(Capability : Enumeration_t);
pragma Import (C, Enable, "glEnable");
procedure Enable_Client_State
(Capability : Enumeration_t);
pragma Import (C, Enable_Client_State, "glEnableClientState");
procedure GL_End;
pragma Import (C, GL_End, "glEnd");
procedure End_List;
pragma Import (C, End_List, "glEndList");
procedure Eval_Coord_1d
(U : Double_t);
pragma Import (C, Eval_Coord_1d, "glEvalCoord1d");
procedure Eval_Coord_1dv
(U : System.Address);
pragma Import (C, Eval_Coord_1dv, "glEvalCoord1dv");
procedure Eval_Coord_1f
(U : Float_t);
pragma Import (C, Eval_Coord_1f, "glEvalCoord1f");
procedure Eval_Coord_1fv
(U : System.Address);
pragma Import (C, Eval_Coord_1fv, "glEvalCoord1fv");
procedure Eval_Coord_2d
(U : Double_t;
V : Double_t);
pragma Import (C, Eval_Coord_2d, "glEvalCoord2d");
procedure Eval_Coord_2dv
(U : System.Address);
pragma Import (C, Eval_Coord_2dv, "glEvalCoord2dv");
procedure Eval_Coord_2f
(U : Float_t;
V : Float_t);
pragma Import (C, Eval_Coord_2f, "glEvalCoord2f");
procedure Eval_Coord_2fv
(U : System.Address);
pragma Import (C, Eval_Coord_2fv, "glEvalCoord2fv");
procedure Eval_Mesh_1
(Mode : Enumeration_t;
I1 : Integer_t;
I2 : Integer_t);
pragma Import (C, Eval_Mesh_1, "glEvalMesh1");
procedure Eval_Mesh_2
(Mode : Enumeration_t;
I1 : Integer_t;
I2 : Integer_t;
J1 : Integer_t;
J2 : Integer_t);
pragma Import (C, Eval_Mesh_2, "glEvalMesh2");
procedure Eval_Point_1
(I : Integer_t);
pragma Import (C, Eval_Point_1, "glEvalPoint1");
procedure Eval_Point_2
(I : Integer_t;
J : Integer_t);
pragma Import (C, Eval_Point_2, "glEvalPoint2");
procedure Feedback_Buffer
(Size : Size_t;
Info_Type : Enumeration_t;
Buffer : System.Address);
pragma Import (C, Feedback_Buffer, "glFeedbackBuffer");
procedure Finish;
pragma Import (C, Finish, "glFinish");
procedure Flush;
pragma Import (C, Flush, "glFlush");
procedure Fogf
(Parameter : Enumeration_t;
Value : Float_t);
pragma Import (C, Fogf, "glFogf");
procedure Fogfv
(Parameter : Enumeration_t;
Values : System.Address);
pragma Import (C, Fogfv, "glFogfv");
procedure Fogi
(Parameter : Enumeration_t;
Value : Integer_t);
pragma Import (C, Fogi, "glFogi");
procedure Fogiv
(Parameter : Enumeration_t;
Values : System.Address);
pragma Import (C, Fogiv, "glFogiv");
procedure Front_Face
(Mode : Enumeration_t);
pragma Import (C, Front_Face, "glFrontFace");
procedure Frustum
(Left : Double_t;
Right : Double_t;
Bottom : Double_t;
Top : Double_t;
Near : Double_t;
Far : Double_t);
pragma Import (C, Frustum, "glFrustum");
function Gen_Lists
(List_Range : Size_t) return Unsigned_Integer_t;
pragma Import (C, Gen_Lists, "glGenLists");
procedure Gen_Textures
(Size : Size_t;
Textures : System.Address);
pragma Import (C, Gen_Textures, "glGenTextures");
procedure Get_Booleanv
(Parameter : Enumeration_t;
Values : System.Address);
pragma Import (C, Get_Booleanv, "glGetBooleanv");
procedure Get_Clip_Plane
(Plane : Enumeration_t;
Equation : System.Address);
pragma Import (C, Get_Clip_Plane, "glGetClipPlane");
procedure Get_Doublev
(Parameter : Enumeration_t;
Values : System.Address);
pragma Import (C, Get_Doublev, "glGetDoublev");
function Get_Error return Enumeration_t;
pragma Import (C, Get_Error, "glGetError");
procedure Get_Floatv
(Parameter : Enumeration_t;
Values : System.Address);
pragma Import (C, Get_Floatv, "glGetFloatv");
procedure Get_Integerv
(Parameter : Enumeration_t;
Values : System.Address);
pragma Import (C, Get_Integerv, "glGetIntegerv");
procedure Get_Lightfv
(Light : Enumeration_t;
Parameter : Enumeration_t;
Values : System.Address);
pragma Import (C, Get_Lightfv, "glGetLightfv");
procedure Get_Lightiv
(Light : Enumeration_t;
Parameter : Enumeration_t;
Values : System.Address);
pragma Import (C, Get_Lightiv, "glGetLightiv");
procedure Get_Mapdv
(Target : Enumeration_t;
Query : Enumeration_t;
Values : System.Address);
pragma Import (C, Get_Mapdv, "glGetMapdv");
procedure Get_Mapfv
(Target : Enumeration_t;
Query : Enumeration_t;
Values : System.Address);
pragma Import (C, Get_Mapfv, "glGetMapfv");
procedure Get_Mapiv
(Target : Enumeration_t;
Query : Enumeration_t;
Values : System.Address);
pragma Import (C, Get_Mapiv, "glGetMapiv");
procedure Get_Materialfv
(Face : Enumeration_t;
Parameter : Enumeration_t;
Values : System.Address);
pragma Import (C, Get_Materialfv, "glGetMaterialfv");
procedure Get_Materialiv
(Face : Enumeration_t;
Parameter : Enumeration_t;
Values : System.Address);
pragma Import (C, Get_Materialiv, "glGetMaterialiv");
procedure Get_Pointerv
(Parameter : Enumeration_t;
Values : System.Address);
pragma Import (C, Get_Pointerv, "glGetPointerv");
procedure Get_Polygon_Stipple
(Pattern : System.Address);
pragma Import (C, Get_Polygon_Stipple, "glGetPolygonStipple");
function Get_String
(Name : Enumeration_t) return System.Address;
pragma Import (C, Get_String, "glGetString");
procedure Get_Tex_Envfv
(Target : Enumeration_t;
Parameter : Enumeration_t;
Values : System.Address);
pragma Import (C, Get_Tex_Envfv, "glGetTexEnvfv");
procedure Get_Tex_Enviv
(Target : Enumeration_t;
Parameter : Enumeration_t;
Values : System.Address);
pragma Import (C, Get_Tex_Enviv, "glGetTexEnviv");
procedure Get_Tex_Genfv
(Coord : Enumeration_t;
Parameter : Enumeration_t;
Values : System.Address);
pragma Import (C, Get_Tex_Genfv, "glGetTexGenfv");
procedure Get_Tex_Geniv
(Coord : Enumeration_t;
Parameter : Enumeration_t;
Values : System.Address);
pragma Import (C, Get_Tex_Geniv, "glGetTexGeniv");
procedure Get_Tex_Image
(Target : Enumeration_t;
Level : Integer_t;
Format : Enumeration_t;
Pixel_Type : Enumeration_t;
Image : Void_Pointer_t);
pragma Import (C, Get_Tex_Image, "glGetTexImage");
procedure Get_Tex_Level_Parameterfv
(Target : Enumeration_t;
Level : Integer_t;
Parameter : Enumeration_t;
Values : System.Address);
pragma Import (C, Get_Tex_Level_Parameterfv, "glGetTexLevelParameterfv");
procedure Get_Tex_Level_Parameteriv
(Target : Enumeration_t;
Level : Integer_t;
Parameter : Enumeration_t;
Values : System.Address);
pragma Import (C, Get_Tex_Level_Parameteriv, "glGetTexLevelParameteriv");
procedure Get_Tex_Parameterfv
(Target : Enumeration_t;
Parameter : Enumeration_t;
Values : System.Address);
pragma Import (C, Get_Tex_Parameterfv, "glGetTexParameterfv");
procedure Get_Tex_Parameteriv
(Target : Enumeration_t;
Parameter : Enumeration_t;
Values : System.Address);
pragma Import (C, Get_Tex_Parameteriv, "glGetTexParameteriv");
procedure Hint
(Target : Enumeration_t;
Mode : Enumeration_t);
pragma Import (C, Hint, "glHint");
procedure Index_Mask
(Mask : Unsigned_Integer_t);
pragma Import (C, Index_Mask, "glIndexMask");
procedure Index_Pointer
(Data_Type : Enumeration_t;
Stride : Size_t;
Pointer : System.Address);
pragma Import (C, Index_Pointer, "glIndexPointer");
procedure Indexd
(Value : Double_t);
pragma Import (C, Indexd, "glIndexd");
procedure Indexf
(Value : Float_t);
pragma Import (C, Indexf, "glIndexf");
procedure Indexi
(Value : Integer_t);
pragma Import (C, Indexi, "glIndexi");
procedure Indexs
(Value : Short_t);
pragma Import (C, Indexs, "glIndexs");
procedure Init_Names;
pragma Import (C, Init_Names, "glInitNames");
procedure Interleaved_Arrays
(Format : Enumeration_t;
Stride : Size_t;
Pointer : System.Address);
pragma Import (C, Interleaved_Arrays, "glInterleavedArrays");
function Is_Enabled
(Capability : Enumeration_t) return Boolean_t;
pragma Import (C, Is_Enabled, "glIsEnabled");
function Is_List
(List : Unsigned_Integer_t) return Boolean_t;
pragma Import (C, Is_List, "glIsList");
function Is_Texture
(Texture : Unsigned_Integer_t) return Boolean_t;
pragma Import (C, Is_Texture, "glIsTexture");
procedure Light_Modelf
(Parameter : Enumeration_t;
Value : Float_t);
pragma Import (C, Light_Modelf, "glLightModelf");
procedure Light_Modelfv
(Parameter : Enumeration_t;
Values : System.Address);
pragma Import (C, Light_Modelfv, "glLightModelfv");
procedure Light_Modeli
(Parameter : Enumeration_t;
Value : Integer_t);
pragma Import (C, Light_Modeli, "glLightModeli");
procedure Light_Modeliv
(Parameter : Enumeration_t;
Values : System.Address);
pragma Import (C, Light_Modeliv, "glLightModeliv");
procedure Lightf
(Light : Enumeration_t;
Parameter : Enumeration_t;
Value : Float_t);
pragma Import (C, Lightf, "glLightf");
procedure Lightfv
(Light : Enumeration_t;
Parameter : Enumeration_t;
Values : System.Address);
pragma Import (C, Lightfv, "glLightfv");
procedure Lighti
(Light : Enumeration_t;
Parameter : Enumeration_t;
Value : Integer_t);
pragma Import (C, Lighti, "glLighti");
procedure Lightiv
(Light : Enumeration_t;
Parameter : Enumeration_t;
Values : System.Address);
pragma Import (C, Lightiv, "glLightiv");
procedure Line_Stipple
(Factor : Integer_t;
Pattern : Unsigned_Short_t);
pragma Import (C, Line_Stipple, "glLineStipple");
procedure Line_Width
(Width : Float_t);
pragma Import (C, Line_Width, "glLineWidth");
procedure List_Base
(Base : Unsigned_Integer_t);
pragma Import (C, List_Base, "glListBase");
procedure Load_Identity;
pragma Import (C, Load_Identity, "glLoadIdentity");
procedure Load_Matrixd
(Matrix : System.Address);
pragma Import (C, Load_Matrixd, "glLoadMatrixd");
procedure Load_Matrixf
(Matrix : System.Address);
pragma Import (C, Load_Matrixf, "glLoadMatrixf");
procedure Load_Name
(Name : Unsigned_Integer_t);
pragma Import (C, Load_Name, "glLoadName");
procedure Logic_Op
(Opcode : Enumeration_t);
pragma Import (C, Logic_Op, "glLogicOp");
procedure Map_1d
(Target : Enumeration_t;
U1 : Double_t;
U2 : Double_t;
Stride : Integer_t;
Order : Integer_t;
Points : System.Address);
pragma Import (C, Map_1d, "glMap1d");
procedure Map_1f
(Target : Enumeration_t;
U1 : Float_t;
U2 : Float_t;
Stride : Integer_t;
Order : Integer_t;
Points : System.Address);
pragma Import (C, Map_1f, "glMap1f");
procedure Map_2d
(Target : Enumeration_t;
U1 : Double_t;
U2 : Double_t;
U_Stride : Integer_t;
U_Order : Integer_t;
V1 : Double_t;
V2 : Double_t;
V_Stride : Integer_t;
V_Order : Integer_t;
Points : System.Address);
pragma Import (C, Map_2d, "glMap2d");
procedure Map_2f
(Target : Enumeration_t;
U1 : Float_t;
U2 : Float_t;
U_Stride : Integer_t;
U_Order : Integer_t;
V1 : Float_t;
V2 : Float_t;
V_Stride : Integer_t;
V_Order : Integer_t;
Points : System.Address);
pragma Import (C, Map_2f, "glMap2f");
procedure Map_Grid_1d
(U_Partitions : Integer_t;
U1 : Double_t;
U2 : Double_t);
pragma Import (C, Map_Grid_1d, "glMapGrid1d");
procedure Map_Grid_1f
(U_Partitions : Integer_t;
U1 : Float_t;
U2 : Float_t);
pragma Import (C, Map_Grid_1f, "glMapGrid1f");
procedure Map_Grid_2d
(U_Partitions : Integer_t;
U1 : Double_t;
U2 : Double_t;
V_Partitions : Integer_t;
V1 : Double_t;
V2 : Double_t);
pragma Import (C, Map_Grid_2d, "glMapGrid2d");
procedure Map_Grid_2f
(U_Partitions : Integer_t;
U1 : Float_t;
U2 : Float_t;
V_Partitions : Integer_t;
V1 : Float_t;
V2 : Float_t);
pragma Import (C, Map_Grid_2f, "glMapGrid2f");
procedure Materialf
(Face : Enumeration_t;
Parameter : Enumeration_t;
Value : Float_t);
pragma Import (C, Materialf, "glMaterialf");
procedure Materialfv
(Face : Enumeration_t;
Parameter : Enumeration_t;
Values : System.Address);
pragma Import (C, Materialfv, "glMaterialfv");
procedure Materiali
(Face : Enumeration_t;
Parameter : Enumeration_t;
Value : Integer_t);
pragma Import (C, Materiali, "glMateriali");
procedure Materialiv
(Face : Enumeration_t;
Parameter : Enumeration_t;
Values : System.Address);
pragma Import (C, Materialiv, "glMaterialiv");
procedure Matrix_Mode
(Mode : Enumeration_t);
pragma Import (C, Matrix_Mode, "glMatrixMode");
procedure Mult_Matrixd
(Matrix : System.Address);
pragma Import (C, Mult_Matrixd, "glMultMatrixd");
procedure Mult_Matrixf
(Matrix : System.Address);
pragma Import (C, Mult_Matrixf, "glMultMatrixf");
procedure New_List
(List : Unsigned_Integer_t;
Mode : Enumeration_t);
pragma Import (C, New_List, "glNewList");
procedure Normal_3b
(Normal_X : Byte_t;
Normal_Y : Byte_t;
Normal_Z : Byte_t);
pragma Import (C, Normal_3b, "glNormal3b");
procedure Normal_3bv
(Vector : System.Address);
pragma Import (C, Normal_3bv, "glNormal3bv");
procedure Normal_3d
(Normal_X : Double_t;
Normal_Y : Double_t;
Normal_Z : Double_t);
pragma Import (C, Normal_3d, "glNormal3d");
procedure Normal_3dv
(Vector : System.Address);
pragma Import (C, Normal_3dv, "glNormal3dv");
procedure Normal_3f
(Normal_X : Float_t;
Normal_Y : Float_t;
Normal_Z : Float_t);
pragma Import (C, Normal_3f, "glNormal3f");
procedure Normal_3fv
(Vector : System.Address);
pragma Import (C, Normal_3fv, "glNormal3fv");
procedure Normal_3i
(Normal_X : Integer_t;
Normal_Y : Integer_t;
Normal_Z : Integer_t);
pragma Import (C, Normal_3i, "glNormal3i");
procedure Normal_3iv
(Vector : System.Address);
pragma Import (C, Normal_3iv, "glNormal3iv");
procedure Normal_3s
(Normal_X : Short_t;
Normal_Y : Short_t;
Normal_Z : Short_t);
pragma Import (C, Normal_3s, "glNormal3s");
procedure Normal_3sv
(Vector : System.Address);
pragma Import (C, Normal_3sv, "glNormal3sv");
procedure Normal_Pointer
(Data_Type : Enumeration_t;
Stride : Size_t;
Pointer : System.Address);
pragma Import (C, Normal_Pointer, "glNormalPointer");
procedure Ortho
(Left : Double_t;
Right : Double_t;
Bottom : Double_t;
Top : Double_t;
Near_Value : Double_t;
Far_Value : Double_t);
pragma Import (C, Ortho, "glOrtho");
procedure Pass_Through
(Token : Float_t);
pragma Import (C, Pass_Through, "glPassThrough");
procedure Pixel_Mapuiv
(Map : Enumeration_t;
Map_Size : Size_t;
Values : System.Address);
pragma Import (C, Pixel_Mapuiv, "glPixelMapuiv");
procedure Pixel_Storef
(Parameter : Enumeration_t;
Value : Float_t);
pragma Import (C, Pixel_Storef, "glPixelStoref");
procedure Pixel_Storei
(Parameter : Enumeration_t;
Value : Integer_t);
pragma Import (C, Pixel_Storei, "glPixelStorei");
procedure Pixel_Transferf
(Parameter : Enumeration_t;
Value : Float_t);
pragma Import (C, Pixel_Transferf, "glPixelTransferf");
procedure Pixel_Transferi
(Parameter : Enumeration_t;
Value : Integer_t);
pragma Import (C, Pixel_Transferi, "glPixelTransferi");
procedure Pixel_Zoom
(X_Factor : Float_t;
Y_Factor : Float_t);
pragma Import (C, Pixel_Zoom, "glPixelZoom");
procedure Point_Size
(Size : Float_t);
pragma Import (C, Point_Size, "glPointSize");
procedure Polygon_Mode
(Face : Enumeration_t;
Mode : Enumeration_t);
pragma Import (C, Polygon_Mode, "glPolygonMode");
procedure Polygon_Offset
(Factor : Float_t;
Units : Float_t);
pragma Import (C, Polygon_Offset, "glPolygonOffset");
procedure Polygon_Stipple
(Pattern : System.Address);
pragma Import (C, Polygon_Stipple, "glPolygonStipple");
procedure Pop_Attrib;
pragma Import (C, Pop_Attrib, "glPopAttrib");
procedure Pop_Client_Attrib;
pragma Import (C, Pop_Client_Attrib, "glPopClientAttrib");
procedure Pop_Matrix;
pragma Import (C, Pop_Matrix, "glPopMatrix");
procedure Pop_Name;
pragma Import (C, Pop_Name, "glPopName");
procedure Prioritize_Textures
(Size : Size_t;
Textures : System.Address;
Priorities : System.Address);
pragma Import (C, Prioritize_Textures, "glPrioritizeTextures");
procedure Push_Attrib
(Mask : Bitfield_t);
pragma Import (C, Push_Attrib, "glPushAttrib");
procedure Push_Client_Attrib
(Mask : Bitfield_t);
pragma Import (C, Push_Client_Attrib, "glPushClientAttrib");
procedure Push_Matrix;
pragma Import (C, Push_Matrix, "glPushMatrix");
procedure Push_Name
(Name : Unsigned_Integer_t);
pragma Import (C, Push_Name, "glPushName");
procedure Raster_Pos_2d
(X : Double_t;
Y : Double_t);
pragma Import (C, Raster_Pos_2d, "glRasterPos2d");
procedure Raster_Pos_2dv
(Vector : System.Address);
pragma Import (C, Raster_Pos_2dv, "glRasterPos2dv");
procedure Raster_Pos_2f
(X : Float_t;
Y : Float_t);
pragma Import (C, Raster_Pos_2f, "glRasterPos2f");
procedure Raster_Pos_2fv
(Vector : System.Address);
pragma Import (C, Raster_Pos_2fv, "glRasterPos2fv");
procedure Raster_Pos_2i
(X : Integer_t;
Y : Integer_t);
pragma Import (C, Raster_Pos_2i, "glRasterPos2i");
procedure Raster_Pos_2iv
(Vector : System.Address);
pragma Import (C, Raster_Pos_2iv, "glRasterPos2iv");
procedure Raster_Pos_2s
(X : Short_t;
Y : Short_t);
pragma Import (C, Raster_Pos_2s, "glRasterPos2s");
procedure Raster_Pos_2sv
(Vector : System.Address);
pragma Import (C, Raster_Pos_2sv, "glRasterPos2sv");
procedure Raster_Pos_3d
(X : Double_t;
Y : Double_t;
Z : Double_t);
pragma Import (C, Raster_Pos_3d, "glRasterPos3d");
procedure Raster_Pos_3dv
(Vector : System.Address);
pragma Import (C, Raster_Pos_3dv, "glRasterPos3dv");
procedure Raster_Pos_3f
(X : Float_t;
Y : Float_t;
Z : Float_t);
pragma Import (C, Raster_Pos_3f, "glRasterPos3f");
procedure Raster_Pos_3fv
(Vector : System.Address);
pragma Import (C, Raster_Pos_3fv, "glRasterPos3fv");
procedure Raster_Pos_3i
(X : Integer_t;
Y : Integer_t;
Z : Integer_t);
pragma Import (C, Raster_Pos_3i, "glRasterPos3i");
procedure Raster_Pos_3iv
(Vector : System.Address);
pragma Import (C, Raster_Pos_3iv, "glRasterPos3iv");
procedure Raster_Pos_3s
(X : Short_t;
Y : Short_t;
Z : Short_t);
pragma Import (C, Raster_Pos_3s, "glRasterPos3s");
procedure Raster_Pos_3sv
(Vector : System.Address);
pragma Import (C, Raster_Pos_3sv, "glRasterPos3sv");
procedure Raster_Pos_4d
(X : Double_t;
Y : Double_t;
Z : Double_t;
W : Double_t);
pragma Import (C, Raster_Pos_4d, "glRasterPos4d");
procedure Raster_Pos_4dv
(Vector : System.Address);
pragma Import (C, Raster_Pos_4dv, "glRasterPos4dv");
procedure Raster_Pos_4f
(X : Float_t;
Y : Float_t;
Z : Float_t;
W : Float_t);
pragma Import (C, Raster_Pos_4f, "glRasterPos4f");
procedure Raster_Pos_4fv
(Vector : System.Address);
pragma Import (C, Raster_Pos_4fv, "glRasterPos4fv");
procedure Raster_Pos_4i
(X : Integer_t;
Y : Integer_t;
Z : Integer_t;
W : Integer_t);
pragma Import (C, Raster_Pos_4i, "glRasterPos4i");
procedure Raster_Pos_4iv
(Vector : System.Address);
pragma Import (C, Raster_Pos_4iv, "glRasterPos4iv");
procedure Raster_Pos_4s
(X : Short_t;
Y : Short_t;
Z : Short_t;
W : Short_t);
pragma Import (C, Raster_Pos_4s, "glRasterPos4s");
procedure Raster_Pos_4sv
(Vector : System.Address);
pragma Import (C, Raster_Pos_4sv, "glRasterPos4sv");
procedure Read_Buffer
(Mode : Enumeration_t);
pragma Import (C, Read_Buffer, "glReadBuffer");
procedure Read_Pixels
(X : Integer_t;
Y : Integer_t;
Width : Size_t;
Height : Size_t;
Format : Enumeration_t;
Data_Type : Enumeration_t;
Data : Void_Pointer_t);
pragma Import (C, Read_Pixels, "glReadPixels");
procedure Rectd
(X1 : Double_t;
Y1 : Double_t;
X2 : Double_t;
Y2 : Double_t);
pragma Import (C, Rectd, "glRectd");
procedure Rectdv
(Vertex_1 : System.Address;
Vertex_2 : System.Address);
pragma Import (C, Rectdv, "glRectdv");
procedure Rectf
(X1 : Float_t;
Y1 : Float_t;
X2 : Float_t;
Y2 : Float_t);
pragma Import (C, Rectf, "glRectf");
procedure Rectfv
(Vertex_1 : System.Address;
Vertex_2 : System.Address);
pragma Import (C, Rectfv, "glRectfv");
procedure Recti
(X1 : Integer_t;
Y1 : Integer_t;
X2 : Integer_t;
Y2 : Integer_t);
pragma Import (C, Recti, "glRecti");
procedure Rectiv
(Vertex_1 : System.Address;
Vertex_2 : System.Address);
pragma Import (C, Rectiv, "glRectiv");
procedure Rects
(X1 : Short_t;
Y1 : Short_t;
X2 : Short_t;
Y2 : Short_t);
pragma Import (C, Rects, "glRects");
procedure Rectsv
(Vertex_1 : System.Address;
Vertex_2 : System.Address);
pragma Import (C, Rectsv, "glRectsv");
function Render_Mode
(Mode : Enumeration_t) return Integer_t;
pragma Import (C, Render_Mode, "glRenderMode");
procedure Rotated
(Angle : Double_t;
X : Double_t;
Y : Double_t;
Z : Double_t);
pragma Import (C, Rotated, "glRotated");
procedure Rotatef
(Angle : Float_t;
X : Float_t;
Y : Float_t;
Z : Float_t);
pragma Import (C, Rotatef, "glRotatef");
procedure Scaled
(X : Double_t;
Y : Double_t;
Z : Double_t);
pragma Import (C, Scaled, "glScaled");
procedure Scalef
(X : Float_t;
Y : Float_t;
Z : Float_t);
pragma Import (C, Scalef, "glScalef");
procedure Scissor
(X : Integer_t;
Y : Integer_t;
Width : Size_t;
Height : Size_t);
pragma Import (C, Scissor, "glScissor");
procedure Select_Buffer
(Size : Size_t;
Buffer : System.Address);
pragma Import (C, Select_Buffer, "glSelectBuffer");
procedure Shade_Model
(Mode : Enumeration_t);
pragma Import (C, Shade_Model, "glShadeModel");
procedure Stencil_Func
(Func : Enumeration_t;
Reference : Integer_t;
Mask : Unsigned_Integer_t);
pragma Import (C, Stencil_Func, "glStencilFunc");
procedure Stencil_Mask
(Mask : Unsigned_Integer_t);
pragma Import (C, Stencil_Mask, "glStencilMask");
procedure Stencil_Op
(Stencil_Fail : Enumeration_t;
Depth_Fail : Enumeration_t;
Depth_Pass : Enumeration_t);
pragma Import (C, Stencil_Op, "glStencilOp");
procedure Tex_Coord_1d
(S : Double_t);
pragma Import (C, Tex_Coord_1d, "glTexCoord1d");
procedure Tex_Coord_1dv
(Vector : System.Address);
pragma Import (C, Tex_Coord_1dv, "glTexCoord1dv");
procedure Tex_Coord_1f
(S : Float_t);
pragma Import (C, Tex_Coord_1f, "glTexCoord1f");
procedure Tex_Coord_1fv
(Vector : System.Address);
pragma Import (C, Tex_Coord_1fv, "glTexCoord1fv");
procedure Tex_Coord_1i
(S : Integer_t);
pragma Import (C, Tex_Coord_1i, "glTexCoord1i");
procedure Tex_Coord_1iv
(Vector : System.Address);
pragma Import (C, Tex_Coord_1iv, "glTexCoord1iv");
procedure Tex_Coord_1s
(S : Short_t);
pragma Import (C, Tex_Coord_1s, "glTexCoord1s");
procedure Tex_Coord_1sv
(Vector : System.Address);
pragma Import (C, Tex_Coord_1sv, "glTexCoord1sv");
procedure Tex_Coord_2d
(S : Double_t;
T : Double_t);
pragma Import (C, Tex_Coord_2d, "glTexCoord2d");
procedure Tex_Coord_2dv
(Vector : System.Address);
pragma Import (C, Tex_Coord_2dv, "glTexCoord2dv");
procedure Tex_Coord_2f
(S : Float_t;
T : Float_t);
pragma Import (C, Tex_Coord_2f, "glTexCoord2f");
procedure Tex_Coord_2fv
(Vector : System.Address);
pragma Import (C, Tex_Coord_2fv, "glTexCoord2fv");
procedure Tex_Coord_2i
(S : Integer_t;
T : Integer_t);
pragma Import (C, Tex_Coord_2i, "glTexCoord2i");
procedure Tex_Coord_2iv
(Vector : System.Address);
pragma Import (C, Tex_Coord_2iv, "glTexCoord2iv");
procedure Tex_Coord_2s
(S : Short_t;
T : Short_t);
pragma Import (C, Tex_Coord_2s, "glTexCoord2s");
procedure Tex_Coord_2sv
(Vector : System.Address);
pragma Import (C, Tex_Coord_2sv, "glTexCoord2sv");
procedure Tex_Coord_3d
(S : Double_t;
T : Double_t;
R : Double_t);
pragma Import (C, Tex_Coord_3d, "glTexCoord3d");
procedure Tex_Coord_3dv
(Vector : System.Address);
pragma Import (C, Tex_Coord_3dv, "glTexCoord3dv");
procedure Tex_Coord_3f
(S : Float_t;
T : Float_t;
R : Float_t);
pragma Import (C, Tex_Coord_3f, "glTexCoord3f");
procedure Tex_Coord_3fv
(Vector : System.Address);
pragma Import (C, Tex_Coord_3fv, "glTexCoord3fv");
procedure Tex_Coord_3i
(S : Integer_t;
T : Integer_t;
R : Integer_t);
pragma Import (C, Tex_Coord_3i, "glTexCoord3i");
procedure Tex_Coord_3iv
(Vector : System.Address);
pragma Import (C, Tex_Coord_3iv, "glTexCoord3iv");
procedure Tex_Coord_3s
(S : Short_t;
T : Short_t;
R : Short_t);
pragma Import (C, Tex_Coord_3s, "glTexCoord3s");
procedure Tex_Coord_3sv
(Vector : System.Address);
pragma Import (C, Tex_Coord_3sv, "glTexCoord3sv");
procedure Tex_Coord_4d
(S : Double_t;
T : Double_t;
R : Double_t;
Q : Double_t);
pragma Import (C, Tex_Coord_4d, "glTexCoord4d");
procedure Tex_Coord_4dv
(Vector : System.Address);
pragma Import (C, Tex_Coord_4dv, "glTexCoord4dv");
procedure Tex_Coord_4f
(S : Float_t;
T : Float_t;
R : Float_t;
Q : Float_t);
pragma Import (C, Tex_Coord_4f, "glTexCoord4f");
procedure Tex_Coord_4fv
(Vector : System.Address);
pragma Import (C, Tex_Coord_4fv, "glTexCoord4fv");
procedure Tex_Coord_4i
(S : Integer_t;
T : Integer_t;
R : Integer_t;
Q : Integer_t);
pragma Import (C, Tex_Coord_4i, "glTexCoord4i");
procedure Tex_Coord_4iv
(Vector : System.Address);
pragma Import (C, Tex_Coord_4iv, "glTexCoord4iv");
procedure Tex_Coord_4s
(S : Short_t;
T : Short_t;
R : Short_t;
Q : Short_t);
pragma Import (C, Tex_Coord_4s, "glTexCoord4s");
procedure Tex_Coord_4sv
(Vector : System.Address);
pragma Import (C, Tex_Coord_4sv, "glTexCoord4sv");
procedure Tex_Coord_Pointer
(Size : Integer_t;
Data_Type : Enumeration_t;
Stride : Size_t;
Pointer : System.Address);
pragma Import (C, Tex_Coord_Pointer, "glTexCoordPointer");
procedure Tex_Envf
(Target : Enumeration_t;
Parameter : Enumeration_t;
Value : Float_t);
pragma Import (C, Tex_Envf, "glTexEnvf");
procedure Tex_Envfv
(Target : Enumeration_t;
Parameter : Enumeration_t;
Values : System.Address);
pragma Import (C, Tex_Envfv, "glTexEnvfv");
procedure Tex_Envi
(Target : Enumeration_t;
Parameter : Enumeration_t;
Value : Integer_t);
pragma Import (C, Tex_Envi, "glTexEnvi");
procedure Tex_Enviv
(Target : Enumeration_t;
Parameter : Enumeration_t;
Values : System.Address);
pragma Import (C, Tex_Enviv, "glTexEnviv");
procedure Tex_Gend
(Coord : Enumeration_t;
Parameter : Enumeration_t;
Value : Double_t);
pragma Import (C, Tex_Gend, "glTexGend");
procedure Tex_Gendv
(Coord : Enumeration_t;
Parameter : Enumeration_t;
Values : System.Address);
pragma Import (C, Tex_Gendv, "glTexGendv");
procedure Tex_Genf
(Coord : Enumeration_t;
Parameter : Enumeration_t;
Value : Float_t);
pragma Import (C, Tex_Genf, "glTexGenf");
procedure Tex_Genfv
(Coord : Enumeration_t;
Parameter : Enumeration_t;
Values : System.Address);
pragma Import (C, Tex_Genfv, "glTexGenfv");
procedure Tex_Geni
(Coord : Enumeration_t;
Parameter : Enumeration_t;
Value : Integer_t);
pragma Import (C, Tex_Geni, "glTexGeni");
procedure Tex_Geniv
(Coord : Enumeration_t;
Parameter : Enumeration_t;
Values : System.Address);
pragma Import (C, Tex_Geniv, "glTexGeniv");
procedure Tex_Image_1D
(Target : Enumeration_t;
Level : Integer_t;
Internal_Format : Integer_t;
Width : Size_t;
Border : Integer_t;
Format : Enumeration_t;
Data_Type : Enumeration_t;
Data : System.Address);
pragma Import (C, Tex_Image_1D, "glTexImage1D");
procedure Tex_Image_2D
(Target : Enumeration_t;
Level : Integer_t;
Internal_Format : Integer_t;
Width : Size_t;
Height : Size_t;
Border : Integer_t;
Format : Enumeration_t;
Data_Type : Enumeration_t;
Data : System.Address);
pragma Import (C, Tex_Image_2D, "glTexImage2D");
procedure Tex_Parameterf
(Target : Enumeration_t;
Parameter : Enumeration_t;
Value : Float_t);
pragma Import (C, Tex_Parameterf, "glTexParameterf");
procedure Tex_Parameterfv
(Target : Enumeration_t;
Parameter : Enumeration_t;
Values : System.Address);
pragma Import (C, Tex_Parameterfv, "glTexParameterfv");
procedure Tex_Parameteri
(Target : Enumeration_t;
Parameter : Enumeration_t;
Value : Integer_t);
pragma Import (C, Tex_Parameteri, "glTexParameteri");
procedure Tex_Parameteriv
(Target : Enumeration_t;
Parameter : Enumeration_t;
Values : System.Address);
pragma Import (C, Tex_Parameteriv, "glTexParameteriv");
procedure Tex_Sub_Image_1D
(Target : Enumeration_t;
Level : Integer_t;
X_Offset : Integer_t;
Width : Size_t;
Format : Enumeration_t;
Data_Type : Enumeration_t;
Data : System.Address);
pragma Import (C, Tex_Sub_Image_1D, "glTexSubImage1D");
procedure Tex_Sub_Image_2D
(Target : Enumeration_t;
Level : Integer_t;
X_Offset : Integer_t;
Y_Offset : Integer_t;
Width : Size_t;
Height : Size_t;
Format : Enumeration_t;
Data_Type : Enumeration_t;
Data : System.Address);
pragma Import (C, Tex_Sub_Image_2D, "glTexSubImage2D");
procedure Translated
(X : Double_t;
Y : Double_t;
Z : Double_t);
pragma Import (C, Translated, "glTranslated");
procedure Translatef
(X : Float_t;
Y : Float_t;
Z : Float_t);
pragma Import (C, Translatef, "glTranslatef");
procedure Vertex_2d
(X : Double_t;
Y : Double_t);
pragma Import (C, Vertex_2d, "glVertex2d");
procedure Vertex_2dv
(Vector : System.Address);
pragma Import (C, Vertex_2dv, "glVertex2dv");
procedure Vertex_2f
(X : Float_t;
Y : Float_t);
pragma Import (C, Vertex_2f, "glVertex2f");
procedure Vertex_2fv
(Vector : System.Address);
pragma Import (C, Vertex_2fv, "glVertex2fv");
procedure Vertex_2i
(X : Integer_t;
Y : Integer_t);
pragma Import (C, Vertex_2i, "glVertex2i");
procedure Vertex_2iv
(Vector : System.Address);
pragma Import (C, Vertex_2iv, "glVertex2iv");
procedure Vertex_2s
(X : Short_t;
Y : Short_t);
pragma Import (C, Vertex_2s, "glVertex2s");
procedure Vertex_2sv
(Vector : System.Address);
pragma Import (C, Vertex_2sv, "glVertex2sv");
procedure Vertex_3d
(X : Double_t;
Y : Double_t;
Z : Double_t);
pragma Import (C, Vertex_3d, "glVertex3d");
procedure Vertex_3dv
(Vector : System.Address);
pragma Import (C, Vertex_3dv, "glVertex3dv");
procedure Vertex_3f
(X : Float_t;
Y : Float_t;
Z : Float_t);
pragma Import (C, Vertex_3f, "glVertex3f");
procedure Vertex_3fv
(Vector : System.Address);
pragma Import (C, Vertex_3fv, "glVertex3fv");
procedure Vertex_3i
(X : Integer_t;
Y : Integer_t;
Z : Integer_t);
pragma Import (C, Vertex_3i, "glVertex3i");
procedure Vertex_3iv
(Vector : System.Address);
pragma Import (C, Vertex_3iv, "glVertex3iv");
procedure Vertex_3s
(X : Short_t;
Y : Short_t;
Z : Short_t);
pragma Import (C, Vertex_3s, "glVertex3s");
procedure Vertex_3sv
(Vector : System.Address);
pragma Import (C, Vertex_3sv, "glVertex3sv");
procedure Vertex_4d
(X : Double_t;
Y : Double_t;
Z : Double_t;
W : Double_t);
pragma Import (C, Vertex_4d, "glVertex4d");
procedure Vertex_4dv
(Vector : System.Address);
pragma Import (C, Vertex_4dv, "glVertex4dv");
procedure Vertex_4f
(X : Float_t;
Y : Float_t;
Z : Float_t;
W : Float_t);
pragma Import (C, Vertex_4f, "glVertex4f");
procedure Vertex_4fv
(Vector : System.Address);
pragma Import (C, Vertex_4fv, "glVertex4fv");
procedure Vertex_4i
(X : Integer_t;
Y : Integer_t;
Z : Integer_t;
W : Integer_t);
pragma Import (C, Vertex_4i, "glVertex4i");
procedure Vertex_4iv
(Vector : System.Address);
pragma Import (C, Vertex_4iv, "glVertex4iv");
procedure Vertex_4s
(X : Short_t;
Y : Short_t;
Z : Short_t;
W : Short_t);
pragma Import (C, Vertex_4s, "glVertex4s");
procedure Vertex_4sv
(Vector : System.Address);
pragma Import (C, Vertex_4sv, "glVertex4sv");
procedure Vertex_Pointer
(Size : Integer_t;
Data_Type : Enumeration_t;
Stride : Size_t;
Pointer : System.Address);
pragma Import (C, Vertex_Pointer, "glVertexPointer");
procedure Viewport
(X : Integer_t;
Y : Integer_t;
Width : Size_t;
Height : Size_t);
pragma Import (C, Viewport, "glViewport");
--
-- OpenGL 1.2
--
procedure Active_Texture_ARB
(Texture : Enumeration_t);
pragma Import (C, Active_Texture_ARB, "glActiveTextureARB");
procedure Blend_Color
(Red : Clamped_Float_t;
Blue : Clamped_Float_t;
Green : Clamped_Float_t;
Alpha : Clamped_Float_t);
pragma Import (C, Blend_Color, "glBlendColor");
procedure Blend_Equation
(Mode : Enumeration_t);
pragma Import (C, Blend_Equation, "glBlendEquation");
procedure Client_Active_Texture_ARB
(Texture : Enumeration_t);
pragma Import (C, Client_Active_Texture_ARB, "glClientActiveTextureARB");
procedure Color_3bv
(Vector : System.Address);
pragma Import (C, Color_3bv, "glColor3bv");
procedure Color_3dv
(Vector : System.Address);
pragma Import (C, Color_3dv, "glColor3dv");
procedure Color_3fv
(Vector : System.Address);
pragma Import (C, Color_3fv, "glColor3fv");
procedure Color_3iv
(Vector : System.Address);
pragma Import (C, Color_3iv, "glColor3iv");
procedure Color_3sv
(Vector : System.Address);
pragma Import (C, Color_3sv, "glColor3sv");
procedure Color_3ub
(Red : Unsigned_Byte_t;
Green : Unsigned_Byte_t;
Blue : Unsigned_Byte_t);
pragma Import (C, Color_3ub, "glColor3ub");
procedure Color_3ubv
(Vector : System.Address);
pragma Import (C, Color_3ubv, "glColor3ubv");
procedure Color_3ui
(Red : Unsigned_Integer_t;
Green : Unsigned_Integer_t;
Blue : Unsigned_Integer_t);
pragma Import (C, Color_3ui, "glColor3ui");
procedure Color_3uiv
(Vector : System.Address);
pragma Import (C, Color_3uiv, "glColor3uiv");
procedure Color_3us
(Red : Unsigned_Short_t;
Green : Unsigned_Short_t;
Blue : Unsigned_Short_t);
pragma Import (C, Color_3us, "glColor3us");
procedure Color_3usv
(Vector : System.Address);
pragma Import (C, Color_3usv, "glColor3usv");
procedure Color_4bv
(Vector : System.Address);
pragma Import (C, Color_4bv, "glColor4bv");
procedure Color_4dv
(Vector : System.Address);
pragma Import (C, Color_4dv, "glColor4dv");
procedure Color_4fv
(Vector : System.Address);
pragma Import (C, Color_4fv, "glColor4fv");
procedure Color_4iv
(Vector : System.Address);
pragma Import (C, Color_4iv, "glColor4iv");
procedure Color_4sv
(Vector : System.Address);
pragma Import (C, Color_4sv, "glColor4sv");
procedure Color_4ub
(Red : Unsigned_Byte_t;
Green : Unsigned_Byte_t;
Blue : Unsigned_Byte_t;
Alpha : Unsigned_Byte_t);
pragma Import (C, Color_4ub, "glColor4ub");
procedure Color_4ubv
(Vector : System.Address);
pragma Import (C, Color_4ubv, "glColor4ubv");
procedure Color_4ui
(Red : Unsigned_Integer_t;
Green : Unsigned_Integer_t;
Blue : Unsigned_Integer_t;
Alpha : Unsigned_Integer_t);
pragma Import (C, Color_4ui, "glColor4ui");
procedure Color_4uiv
(Vector : System.Address);
pragma Import (C, Color_4uiv, "glColor4uiv");
procedure Color_4us
(Red : Unsigned_Short_t;
Green : Unsigned_Short_t;
Blue : Unsigned_Short_t;
Alpha : Unsigned_Short_t);
pragma Import (C, Color_4us, "glColor4us");
procedure Color_4usv
(Vector : System.Address);
pragma Import (C, Color_4usv, "glColor4usv");
procedure Color_Sub_Table
(Target : Enumeration_t;
First : Size_t;
Size : Size_t;
Format : Enumeration_t;
Data_Type : Enumeration_t;
Data : System.Address);
pragma Import (C, Color_Sub_Table, "glColorSubTable");
procedure Color_Table
(Target : Enumeration_t;
Internal_Format : Enumeration_t;
Width : Size_t;
Format : Enumeration_t;
Data_Type : Enumeration_t;
Data : System.Address);
pragma Import (C, Color_Table, "glColorTable");
procedure Color_Table_Parameterfv
(Target : Enumeration_t;
Parameter : Enumeration_t;
Values : System.Address);
pragma Import (C, Color_Table_Parameterfv, "glColorTableParameterfv");
procedure Color_Table_Parameteriv
(Target : Enumeration_t;
Parameter : Enumeration_t;
Values : System.Address);
pragma Import (C, Color_Table_Parameteriv, "glColorTableParameteriv");
procedure Convolution_Filter_1D
(Target : Enumeration_t;
Internal_Format : Enumeration_t;
Width : Size_t;
Format : Enumeration_t;
Data_Type : Enumeration_t;
Data : System.Address);
pragma Import (C, Convolution_Filter_1D, "glConvolutionFilter1D");
procedure Convolution_Filter_2D
(Target : Enumeration_t;
Internal_Format : Enumeration_t;
Width : Size_t;
Height : Size_t;
Format : Enumeration_t;
Data_Type : Enumeration_t;
Data : System.Address);
pragma Import (C, Convolution_Filter_2D, "glConvolutionFilter2D");
procedure Convolution_Parameterf
(Target : Enumeration_t;
Parameter : Enumeration_t;
Value : Float_t);
pragma Import (C, Convolution_Parameterf, "glConvolutionParameterf");
procedure Convolution_Parameterfv
(Target : Enumeration_t;
Parameter : Enumeration_t;
Values : System.Address);
pragma Import (C, Convolution_Parameterfv, "glConvolutionParameterfv");
procedure Convolution_Parameteri
(Target : Enumeration_t;
Parameter : Enumeration_t;
Value : Integer_t);
pragma Import (C, Convolution_Parameteri, "glConvolutionParameteri");
procedure Convolution_Parameteriv
(Target : Enumeration_t;
Parameter : Enumeration_t;
Values : System.Address);
pragma Import (C, Convolution_Parameteriv, "glConvolutionParameteriv");
procedure Copy_Color_Sub_Table
(Target : Enumeration_t;
First : Size_t;
X : Integer_t;
Y : Integer_t;
Width : Size_t);
pragma Import (C, Copy_Color_Sub_Table, "glCopyColorSubTable");
procedure Copy_Color_Table
(Target : Enumeration_t;
Internal_Format : Enumeration_t;
X : Integer_t;
Y : Integer_t;
Width : Size_t);
pragma Import (C, Copy_Color_Table, "glCopyColorTable");
procedure Copy_Convolution_Filter_1D
(Target : Enumeration_t;
Internal_Format : Enumeration_t;
X : Integer_t;
Y : Integer_t;
Width : Size_t);
pragma Import (C, Copy_Convolution_Filter_1D, "glCopyConvolutionFilter1D");
procedure Copy_Convolution_Filter_2D
(Target : Enumeration_t;
Internal_Format : Enumeration_t;
X : Integer_t;
Y : Integer_t;
Width : Size_t;
Height : Size_t);
pragma Import (C, Copy_Convolution_Filter_2D, "glCopyConvolutionFilter2D");
procedure Copy_Tex_Sub_Image_3D
(Target : Enumeration_t;
Level : Integer_t;
X_Offset : Integer_t;
Y_Offset : Integer_t;
Z_Offset : Integer_t;
X : Integer_t;
Y : Integer_t;
Width : Size_t;
Height : Size_t);
pragma Import (C, Copy_Tex_Sub_Image_3D, "glCopyTexSubImage3D");
procedure Draw_Range_Elements
(Mode : Enumeration_t;
First : Unsigned_Integer_t;
Last : Unsigned_Integer_t;
Size : Size_t;
Data_Type : Enumeration_t;
Indices : System.Address);
pragma Import (C, Draw_Range_Elements, "glDrawRangeElements");
procedure Get_Color_Table
(Target : Enumeration_t;
Format : Enumeration_t;
Data_Type : Enumeration_t;
Data : Void_Pointer_t);
pragma Import (C, Get_Color_Table, "glGetColorTable");
procedure Get_Color_Table_Parameterfv
(Target : Enumeration_t;
Parameter : Enumeration_t;
Values : System.Address);
pragma Import (C, Get_Color_Table_Parameterfv, "glGetColorTableParameterfv");
procedure Get_Color_Table_Parameteriv
(Target : Enumeration_t;
Parameter : Enumeration_t;
Values : System.Address);
pragma Import (C, Get_Color_Table_Parameteriv, "glGetColorTableParameteriv");
procedure Get_Convolution_Filter
(Target : Enumeration_t;
Format : Enumeration_t;
Data_Type : Enumeration_t;
Image : Void_Pointer_t);
pragma Import (C, Get_Convolution_Filter, "glGetConvolutionFilter");
procedure Get_Convolution_Parameterfv
(Target : Enumeration_t;
Parameter : Enumeration_t;
Values : System.Address);
pragma Import (C, Get_Convolution_Parameterfv, "glGetConvolutionParameterfv");
procedure Get_Convolution_Parameteriv
(Target : Enumeration_t;
Parameter : Enumeration_t;
Values : System.Address);
pragma Import (C, Get_Convolution_Parameteriv, "glGetConvolutionParameteriv");
procedure Get_Histogram
(Target : Enumeration_t;
Reset : Boolean_t;
Format : Enumeration_t;
Data_Type : Enumeration_t;
Data : Void_Pointer_t);
pragma Import (C, Get_Histogram, "glGetHistogram");
procedure Get_Histogram_Parameterfv
(Target : Enumeration_t;
Parameter : Enumeration_t;
Values : System.Address);
pragma Import (C, Get_Histogram_Parameterfv, "glGetHistogramParameterfv");
procedure Get_Histogram_Parameteriv
(Target : Enumeration_t;
Parameter : Enumeration_t;
Values : System.Address);
pragma Import (C, Get_Histogram_Parameteriv, "glGetHistogramParameteriv");
procedure Get_Minmax
(Target : Enumeration_t;
Reset : Boolean_t;
Format : Enumeration_t;
Data_Type : Enumeration_t;
Data : Void_Pointer_t);
pragma Import (C, Get_Minmax, "glGetMinmax");
procedure Get_Minmax_Parameterfv
(Target : Enumeration_t;
Parameter : Enumeration_t;
Values : System.Address);
pragma Import (C, Get_Minmax_Parameterfv, "glGetMinmaxParameterfv");
procedure Get_Minmax_Parameteriv
(Target : Enumeration_t;
Parameter : Enumeration_t;
Values : System.Address);
pragma Import (C, Get_Minmax_Parameteriv, "glGetMinmaxParameteriv");
procedure Get_Pixel_Mapfv
(Map : Enumeration_t;
Data : System.Address);
pragma Import (C, Get_Pixel_Mapfv, "glGetPixelMapfv");
procedure Get_Pixel_Mapuiv
(Map : Enumeration_t;
Data : System.Address);
pragma Import (C, Get_Pixel_Mapuiv, "glGetPixelMapuiv");
procedure Get_Pixel_Mapusv
(Map : Enumeration_t;
Data : System.Address);
pragma Import (C, Get_Pixel_Mapusv, "glGetPixelMapusv");
procedure Get_Separable_Filter
(Target : Enumeration_t;
Format : Enumeration_t;
Data_Type : Enumeration_t;
Row : Void_Pointer_t;
Column : Void_Pointer_t;
Span : Void_Pointer_t);
pragma Import (C, Get_Separable_Filter, "glGetSeparableFilter");
procedure Get_Tex_Gendv
(Coordinate : Enumeration_t;
Parameter : Enumeration_t;
Values : System.Address);
pragma Import (C, Get_Tex_Gendv, "glGetTexGendv");
procedure Histogram
(Target : Enumeration_t;
Width : Size_t;
Internal_Format : Enumeration_t;
Sink : Boolean_t);
pragma Import (C, Histogram, "glHistogram");
procedure Indexdv
(Value : System.Address);
pragma Import (C, Indexdv, "glIndexdv");
procedure Indexfv
(Value : System.Address);
pragma Import (C, Indexfv, "glIndexfv");
procedure Indexiv
(Value : System.Address);
pragma Import (C, Indexiv, "glIndexiv");
procedure Indexsv
(Value : System.Address);
pragma Import (C, Indexsv, "glIndexsv");
procedure Indexub
(Value : Unsigned_Byte_t);
pragma Import (C, Indexub, "glIndexub");
procedure Indexubv
(Value : System.Address);
pragma Import (C, Indexubv, "glIndexubv");
procedure Minmax
(Target : Enumeration_t;
Internal_Format : Enumeration_t;
Sink : Boolean_t);
pragma Import (C, Minmax, "glMinmax");
procedure Multi_Tex_Coord_1d
(Target : Enumeration_t;
S : Double_t);
pragma Import (C, Multi_Tex_Coord_1d, "glMultiTexCoord1d");
procedure Multi_Tex_Coord_1d_ARB
(Target : Enumeration_t;
S : Double_t);
pragma Import (C, Multi_Tex_Coord_1d_ARB, "glMultiTexCoord1dARB");
procedure Multi_Tex_Coord_1dv
(Target : Enumeration_t;
Vector : System.Address);
pragma Import (C, Multi_Tex_Coord_1dv, "glMultiTexCoord1dv");
procedure Multi_Tex_Coord_1dv_ARB
(Target : Enumeration_t;
Vector : System.Address);
pragma Import (C, Multi_Tex_Coord_1dv_ARB, "glMultiTexCoord1dvARB");
procedure Multi_Tex_Coord_1f
(Target : Enumeration_t;
S : Float_t);
pragma Import (C, Multi_Tex_Coord_1f, "glMultiTexCoord1f");
procedure Multi_Tex_Coord_1f_ARB
(Target : Enumeration_t;
S : Float_t);
pragma Import (C, Multi_Tex_Coord_1f_ARB, "glMultiTexCoord1fARB");
procedure Multi_Tex_Coord_1fv
(Target : Enumeration_t;
Vector : System.Address);
pragma Import (C, Multi_Tex_Coord_1fv, "glMultiTexCoord1fv");
procedure Multi_Tex_Coord_1fv_ARB
(Target : Enumeration_t;
Vector : System.Address);
pragma Import (C, Multi_Tex_Coord_1fv_ARB, "glMultiTexCoord1fvARB");
procedure Multi_Tex_Coord_1i
(Target : Enumeration_t;
S : Integer_t);
pragma Import (C, Multi_Tex_Coord_1i, "glMultiTexCoord1i");
procedure Multi_Tex_Coord_1i_ARB
(Target : Enumeration_t;
S : Integer_t);
pragma Import (C, Multi_Tex_Coord_1i_ARB, "glMultiTexCoord1iARB");
procedure Multi_Tex_Coord_1iv
(Target : Enumeration_t;
Vector : System.Address);
pragma Import (C, Multi_Tex_Coord_1iv, "glMultiTexCoord1iv");
procedure Multi_Tex_Coord_1iv_ARB
(Target : Enumeration_t;
Vector : System.Address);
pragma Import (C, Multi_Tex_Coord_1iv_ARB, "glMultiTexCoord1ivARB");
procedure Multi_Tex_Coord_1s
(Target : Enumeration_t;
S : Short_t);
pragma Import (C, Multi_Tex_Coord_1s, "glMultiTexCoord1s");
procedure Multi_Tex_Coord_1s_ARB
(Target : Enumeration_t;
S : Short_t);
pragma Import (C, Multi_Tex_Coord_1s_ARB, "glMultiTexCoord1sARB");
procedure Multi_Tex_Coord_1sv
(Target : Enumeration_t;
Vector : System.Address);
pragma Import (C, Multi_Tex_Coord_1sv, "glMultiTexCoord1sv");
procedure Multi_Tex_Coord_1sv_ARB
(Target : Enumeration_t;
Vector : System.Address);
pragma Import (C, Multi_Tex_Coord_1sv_ARB, "glMultiTexCoord1svARB");
procedure Multi_Tex_Coord_2d
(Target : Enumeration_t;
S : Double_t;
T : Double_t);
pragma Import (C, Multi_Tex_Coord_2d, "glMultiTexCoord2d");
procedure Multi_Tex_Coord_2d_ARB
(Target : Enumeration_t;
S : Double_t;
T : Double_t);
pragma Import (C, Multi_Tex_Coord_2d_ARB, "glMultiTexCoord2dARB");
procedure Multi_Tex_Coord_2dv
(Target : Enumeration_t;
Vector : System.Address);
pragma Import (C, Multi_Tex_Coord_2dv, "glMultiTexCoord2dv");
procedure Multi_Tex_Coord_2dv_ARB
(Target : Enumeration_t;
Vector : System.Address);
pragma Import (C, Multi_Tex_Coord_2dv_ARB, "glMultiTexCoord2dvARB");
procedure Multi_Tex_Coord_2f
(Target : Enumeration_t;
S : Float_t;
T : Float_t);
pragma Import (C, Multi_Tex_Coord_2f, "glMultiTexCoord2f");
procedure Multi_Tex_Coord_2f_ARB
(Target : Enumeration_t;
S : Float_t;
T : Float_t);
pragma Import (C, Multi_Tex_Coord_2f_ARB, "glMultiTexCoord2fARB");
procedure Multi_Tex_Coord_2fv
(Target : Enumeration_t;
Vector : System.Address);
pragma Import (C, Multi_Tex_Coord_2fv, "glMultiTexCoord2fv");
procedure Multi_Tex_Coord_2fv_ARB
(Target : Enumeration_t;
Vector : System.Address);
pragma Import (C, Multi_Tex_Coord_2fv_ARB, "glMultiTexCoord2fvARB");
procedure Multi_Tex_Coord_2i
(Target : Enumeration_t;
S : Integer_t;
T : Integer_t);
pragma Import (C, Multi_Tex_Coord_2i, "glMultiTexCoord2i");
procedure Multi_Tex_Coord_2i_ARB
(Target : Enumeration_t;
S : Integer_t;
T : Integer_t);
pragma Import (C, Multi_Tex_Coord_2i_ARB, "glMultiTexCoord2iARB");
procedure Multi_Tex_Coord_2iv
(Target : Enumeration_t;
Vector : System.Address);
pragma Import (C, Multi_Tex_Coord_2iv, "glMultiTexCoord2iv");
procedure Multi_Tex_Coord_2iv_ARB
(Target : Enumeration_t;
Vector : System.Address);
pragma Import (C, Multi_Tex_Coord_2iv_ARB, "glMultiTexCoord2ivARB");
procedure Multi_Tex_Coord_2s
(Target : Enumeration_t;
S : Short_t;
T : Short_t);
pragma Import (C, Multi_Tex_Coord_2s, "glMultiTexCoord2s");
procedure Multi_Tex_Coord_2s_ARB
(Target : Enumeration_t;
S : Short_t;
T : Short_t);
pragma Import (C, Multi_Tex_Coord_2s_ARB, "glMultiTexCoord2sARB");
procedure Multi_Tex_Coord_2sv
(Target : Enumeration_t;
Vector : System.Address);
pragma Import (C, Multi_Tex_Coord_2sv, "glMultiTexCoord2sv");
procedure Multi_Tex_Coord_2sv_ARB
(Target : Enumeration_t;
Vector : System.Address);
pragma Import (C, Multi_Tex_Coord_2sv_ARB, "glMultiTexCoord2svARB");
procedure Multi_Tex_Coord_3d
(Target : Enumeration_t;
S : Double_t;
T : Double_t;
R : Double_t);
pragma Import (C, Multi_Tex_Coord_3d, "glMultiTexCoord3d");
procedure Multi_Tex_Coord_3d_ARB
(Target : Enumeration_t;
S : Double_t;
T : Double_t;
R : Double_t);
pragma Import (C, Multi_Tex_Coord_3d_ARB, "glMultiTexCoord3dARB");
procedure Multi_Tex_Coord_3dv
(Target : Enumeration_t;
Vector : System.Address);
pragma Import (C, Multi_Tex_Coord_3dv, "glMultiTexCoord3dv");
procedure Multi_Tex_Coord_3dv_ARB
(Target : Enumeration_t;
Vector : System.Address);
pragma Import (C, Multi_Tex_Coord_3dv_ARB, "glMultiTexCoord3dvARB");
procedure Multi_Tex_Coord_3f
(Target : Enumeration_t;
S : Float_t;
T : Float_t;
R : Float_t);
pragma Import (C, Multi_Tex_Coord_3f, "glMultiTexCoord3f");
procedure Multi_Tex_Coord_3f_ARB
(Target : Enumeration_t;
S : Float_t;
T : Float_t;
R : Float_t);
pragma Import (C, Multi_Tex_Coord_3f_ARB, "glMultiTexCoord3fARB");
procedure Multi_Tex_Coord_3fv
(Target : Enumeration_t;
Vector : System.Address);
pragma Import (C, Multi_Tex_Coord_3fv, "glMultiTexCoord3fv");
procedure Multi_Tex_Coord_3fv_ARB
(Target : Enumeration_t;
Vector : System.Address);
pragma Import (C, Multi_Tex_Coord_3fv_ARB, "glMultiTexCoord3fvARB");
procedure Multi_Tex_Coord_3i
(Target : Enumeration_t;
S : Integer_t;
T : Integer_t;
R : Integer_t);
pragma Import (C, Multi_Tex_Coord_3i, "glMultiTexCoord3i");
procedure Multi_Tex_Coord_3i_ARB
(Target : Enumeration_t;
S : Integer_t;
T : Integer_t;
R : Integer_t);
pragma Import (C, Multi_Tex_Coord_3i_ARB, "glMultiTexCoord3iARB");
procedure Multi_Tex_Coord_3iv
(Target : Enumeration_t;
Vector : System.Address);
pragma Import (C, Multi_Tex_Coord_3iv, "glMultiTexCoord3iv");
procedure Multi_Tex_Coord_3iv_ARB
(Target : Enumeration_t;
Vector : System.Address);
pragma Import (C, Multi_Tex_Coord_3iv_ARB, "glMultiTexCoord3ivARB");
procedure Multi_Tex_Coord_3s
(Target : Enumeration_t;
S : Short_t;
T : Short_t;
R : Short_t);
pragma Import (C, Multi_Tex_Coord_3s, "glMultiTexCoord3s");
procedure Multi_Tex_Coord_3s_ARB
(Target : Enumeration_t;
S : Short_t;
T : Short_t;
R : Short_t);
pragma Import (C, Multi_Tex_Coord_3s_ARB, "glMultiTexCoord3sARB");
procedure Multi_Tex_Coord_3sv
(Target : Enumeration_t;
Vector : System.Address);
pragma Import (C, Multi_Tex_Coord_3sv, "glMultiTexCoord3sv");
procedure Multi_Tex_Coord_3sv_ARB
(Target : Enumeration_t;
Vector : System.Address);
pragma Import (C, Multi_Tex_Coord_3sv_ARB, "glMultiTexCoord3svARB");
procedure Multi_Tex_Coord_4d
(Target : Enumeration_t;
S : Double_t;
T : Double_t;
R : Double_t;
Q : Double_t);
pragma Import (C, Multi_Tex_Coord_4d, "glMultiTexCoord4d");
procedure Multi_Tex_Coord_4d_ARB
(Target : Enumeration_t;
S : Double_t;
T : Double_t;
R : Double_t;
Q : Double_t);
pragma Import (C, Multi_Tex_Coord_4d_ARB, "glMultiTexCoord4dARB");
procedure Multi_Tex_Coord_4dv
(Target : Enumeration_t;
Vector : System.Address);
pragma Import (C, Multi_Tex_Coord_4dv, "glMultiTexCoord4dv");
procedure Multi_Tex_Coord_4dv_ARB
(Target : Enumeration_t;
Vector : System.Address);
pragma Import (C, Multi_Tex_Coord_4dv_ARB, "glMultiTexCoord4dvARB");
procedure Multi_Tex_Coord_4f
(Target : Enumeration_t;
S : Float_t;
T : Float_t;
R : Float_t;
Q : Float_t);
pragma Import (C, Multi_Tex_Coord_4f, "glMultiTexCoord4f");
procedure Multi_Tex_Coord_4f_ARB
(Target : Enumeration_t;
S : Float_t;
T : Float_t;
R : Float_t;
Q : Float_t);
pragma Import (C, Multi_Tex_Coord_4f_ARB, "glMultiTexCoord4fARB");
procedure Multi_Tex_Coord_4fv
(Target : Enumeration_t;
Vector : System.Address);
pragma Import (C, Multi_Tex_Coord_4fv, "glMultiTexCoord4fv");
procedure Multi_Tex_Coord_4fv_ARB
(Target : Enumeration_t;
Vector : System.Address);
pragma Import (C, Multi_Tex_Coord_4fv_ARB, "glMultiTexCoord4fvARB");
procedure Multi_Tex_Coord_4i
(Target : Enumeration_t;
S : Integer_t;
T : Integer_t;
R : Integer_t;
Q : Integer_t);
pragma Import (C, Multi_Tex_Coord_4i, "glMultiTexCoord4i");
procedure Multi_Tex_Coord_4i_ARB
(Target : Enumeration_t;
S : Integer_t;
T : Integer_t;
R : Integer_t;
Q : Integer_t);
pragma Import (C, Multi_Tex_Coord_4i_ARB, "glMultiTexCoord4iARB");
procedure Multi_Tex_Coord_4iv
(Target : Enumeration_t;
Vector : System.Address);
pragma Import (C, Multi_Tex_Coord_4iv, "glMultiTexCoord4iv");
procedure Multi_Tex_Coord_4iv_ARB
(Target : Enumeration_t;
Vector : System.Address);
pragma Import (C, Multi_Tex_Coord_4iv_ARB, "glMultiTexCoord4ivARB");
procedure Multi_Tex_Coord_4s
(Target : Enumeration_t;
S : Short_t;
T : Short_t;
R : Short_t;
Q : Short_t);
pragma Import (C, Multi_Tex_Coord_4s, "glMultiTexCoord4s");
procedure Multi_Tex_Coord_4s_ARB
(Target : Enumeration_t;
S : Short_t;
T : Short_t;
R : Short_t;
Q : Short_t);
pragma Import (C, Multi_Tex_Coord_4s_ARB, "glMultiTexCoord4sARB");
procedure Multi_Tex_Coord_4sv
(Target : Enumeration_t;
Vector : System.Address);
pragma Import (C, Multi_Tex_Coord_4sv, "glMultiTexCoord4sv");
procedure Multi_Tex_Coord_4sv_ARB
(Target : Enumeration_t;
Vector : System.Address);
pragma Import (C, Multi_Tex_Coord_4sv_ARB, "glMultiTexCoord4svARB");
procedure Pixel_Mapfv
(Map : Enumeration_t;
Size : Size_t;
Values : System.Address);
pragma Import (C, Pixel_Mapfv, "glPixelMapfv");
procedure Pixel_Mapusv
(Map : Enumeration_t;
Size : Size_t;
Values : System.Address);
pragma Import (C, Pixel_Mapusv, "glPixelMapusv");
procedure Reset_Histogram
(Target : Enumeration_t);
pragma Import (C, Reset_Histogram, "glResetHistogram");
procedure Reset_Minmax
(Target : Enumeration_t);
pragma Import (C, Reset_Minmax, "glResetMinmax");
procedure Separable_Filter_2D
(Target : Enumeration_t;
Internal_Format : Enumeration_t;
Width : Size_t;
Height : Size_t;
Format : Enumeration_t;
Data_Type : Enumeration_t;
Row : System.Address;
Column : System.Address);
pragma Import (C, Separable_Filter_2D, "glSeparableFilter2D");
procedure Tex_Image_3D
(Target : Enumeration_t;
Level : Integer_t;
Internal_Format : Integer_t;
Width : Size_t;
Height : Size_t;
Depth : Size_t;
Border : Integer_t;
Format : Enumeration_t;
Data_Type : Enumeration_t;
Data : System.Address);
pragma Import (C, Tex_Image_3D, "glTexImage3D");
procedure Tex_Sub_Image_3D
(Target : Enumeration_t;
Level : Integer_t;
X_Offset : Integer_t;
Y_Offset : Integer_t;
Z_Offset : Integer_t;
Width : Size_t;
Height : Size_t;
Depth : Size_t;
Format : Enumeration_t;
Data_Type : Enumeration_t;
Data : System.Address);
pragma Import (C, Tex_Sub_Image_3D, "glTexSubImage3D");
--
-- OpenGL 1.3
--
procedure Active_Texture
(Texture : Enumeration_t);
pragma Import (C, Active_Texture, "glActiveTexture");
procedure Client_Active_Texture
(Texture : Enumeration_t);
pragma Import (C, Client_Active_Texture, "glClientActiveTexture");
procedure Compressed_Tex_Image_1D
(Target : Enumeration_t;
Level : Integer_t;
Internal_Format : Enumeration_t;
Width : Size_t;
Border : Integer_t;
Image_Size : Size_t;
Data : System.Address);
pragma Import (C, Compressed_Tex_Image_1D, "glCompressedTexImage1D");
procedure Compressed_Tex_Image_2D
(Target : Enumeration_t;
Level : Integer_t;
Internal_Format : Enumeration_t;
Width : Size_t;
Height : Size_t;
Border : Integer_t;
Image_Size : Size_t;
Data : System.Address);
pragma Import (C, Compressed_Tex_Image_2D, "glCompressedTexImage2D");
procedure Compressed_Tex_Image_3D
(Target : Enumeration_t;
Level : Integer_t;
Internal_Format : Enumeration_t;
Width : Size_t;
Height : Size_t;
Depth : Size_t;
Border : Integer_t;
Image_Size : Size_t;
Data : System.Address);
pragma Import (C, Compressed_Tex_Image_3D, "glCompressedTexImage3D");
procedure Compressed_Tex_Sub_Image_1D
(Target : Enumeration_t;
Level : Integer_t;
X_Offset : Integer_t;
Width : Size_t;
Format : Enumeration_t;
Image_Size : Size_t;
Data : System.Address);
pragma Import (C, Compressed_Tex_Sub_Image_1D, "glCompressedTexSubImage1D");
procedure Compressed_Tex_Sub_Image_2D
(Target : Enumeration_t;
Level : Integer_t;
X_Offset : Integer_t;
Y_Offset : Integer_t;
Width : Size_t;
Height : Size_t;
Format : Enumeration_t;
Image_Size : Size_t;
Data : System.Address);
pragma Import (C, Compressed_Tex_Sub_Image_2D, "glCompressedTexSubImage2D");
procedure Compressed_Tex_Sub_Image_3D
(Target : Enumeration_t;
Level : Integer_t;
X_Offset : Integer_t;
Y_Offset : Integer_t;
Z_Offset : Integer_t;
Width : Size_t;
Height : Size_t;
Depth : Size_t;
Format : Enumeration_t;
Image_Size : Size_t;
Data : System.Address);
pragma Import (C, Compressed_Tex_Sub_Image_3D, "glCompressedTexSubImage3D");
procedure Get_Compressed_Tex_Image
(Target : Enumeration_t;
Level : Integer_t;
Image : Void_Pointer_t);
pragma Import (C, Get_Compressed_Tex_Image, "glGetCompressedTexImage");
procedure Load_Transpose_Matrixd
(Matrix : System.Address);
pragma Import (C, Load_Transpose_Matrixd, "glLoadTransposeMatrixd");
procedure Load_Transpose_Matrixf
(Matrix : System.Address);
pragma Import (C, Load_Transpose_Matrixf, "glLoadTransposeMatrixf");
procedure Mult_Transpose_Matrixd
(Matrix : System.Address);
pragma Import (C, Mult_Transpose_Matrixd, "glMultTransposeMatrixd");
procedure Mult_Transpose_Matrixf
(Matrix : System.Address);
pragma Import (C, Mult_Transpose_Matrixf, "glMultTransposeMatrixf");
procedure Sample_Coverage
(Value : Clamped_Float_t;
Invert : Boolean_t);
pragma Import (C, Sample_Coverage, "glSampleCoverage");
--
-- OpenGL 1.4
--
procedure Blend_Func_Separate
(Source_RGB : Enumeration_t;
Target_RGB : Enumeration_t;
Source_Alpha : Enumeration_t;
Target_Alpha : Enumeration_t);
pragma Import (C, Blend_Func_Separate, "glBlendFuncSeparate");
procedure Fog_Coordf
(Coordinate : Float_t);
pragma Import (C, Fog_Coordf, "glFogCoordf");
procedure Fog_Coordfv
(Coordinate : System.Address);
pragma Import (C, Fog_Coordfv, "glFogCoordfv");
procedure Fog_Coordd
(Coordinate : Float_t);
pragma Import (C, Fog_Coordd, "glFogCoordd");
procedure Fog_Coorddv
(Coordinate : System.Address);
pragma Import (C, Fog_Coorddv, "glFogCoorddv");
procedure Fog_Coord_Pointer
(Data_Type : Enumeration_t;
Stride : Size_t;
Pointer : Void_Pointer_t);
pragma Import (C, Fog_Coord_Pointer, "glFogCoordPointer");
procedure Multi_Draw_Arrays
(Mode : Enumeration_t;
First : System.Address;
Size : System.Address;
Primitive_Count : Size_t);
pragma Import (C, Multi_Draw_Arrays, "glMultiDrawArrays");
procedure Multi_Draw_Elements
(Mode : Enumeration_t;
Size : System.Address;
Data_Type : Enumeration_t;
Indices : System.Address;
Primitive_Count : Size_t);
pragma Import (C, Multi_Draw_Elements, "glMultiDrawElements");
procedure Point_Parameterf
(Parameter : Enumeration_t;
Value : Float_t);
pragma Import (C, Point_Parameterf, "glPointParameterf");
procedure Point_Parameterfv
(Parameter : Enumeration_t;
Value : System.Address);
pragma Import (C, Point_Parameterfv, "glPointParameterfv");
procedure Point_Parameteri
(Parameter : Enumeration_t;
Value : Integer_t);
pragma Import (C, Point_Parameteri, "glPointParameteri");
procedure Point_Parameteriv
(Parameter : Enumeration_t;
Value : System.Address);
pragma Import (C, Point_Parameteriv, "glPointParameteriv");
procedure Secondary_Color_3b
(Red : Byte_t;
Green : Byte_t;
Blue : Byte_t);
pragma Import (C, Secondary_Color_3b, "glSecondaryColor3b");
procedure Secondary_Color_3bv
(Vector : System.Address);
pragma Import (C, Secondary_Color_3bv, "glSecondaryColor3bv");
procedure Secondary_Color_3d
(Red : Double_t;
Green : Double_t;
Blue : Double_t);
pragma Import (C, Secondary_Color_3d, "glSecondaryColor3d");
procedure Secondary_Color_3dv
(Vector : System.Address);
pragma Import (C, Secondary_Color_3dv, "glSecondaryColor3dv");
procedure Secondary_Color_3f
(Red : Float_t;
Green : Float_t;
Blue : Float_t);
pragma Import (C, Secondary_Color_3f, "glSecondaryColor3f");
procedure Secondary_Color_3fv
(Vector : System.Address);
pragma Import (C, Secondary_Color_3fv, "glSecondaryColor3fv");
procedure Secondary_Color_3i
(Red : Integer_t;
Green : Integer_t;
Blue : Integer_t);
pragma Import (C, Secondary_Color_3i, "glSecondaryColor3i");
procedure Secondary_Color_3iv
(Vector : System.Address);
pragma Import (C, Secondary_Color_3iv, "glSecondaryColor3iv");
procedure Secondary_Color_3s
(Red : Short_t;
Green : Short_t;
Blue : Short_t);
pragma Import (C, Secondary_Color_3s, "glSecondaryColor3s");
procedure Secondary_Color_3sv
(Vector : System.Address);
pragma Import (C, Secondary_Color_3sv, "glSecondaryColor3sv");
procedure Secondary_Color_3ub
(Red : Unsigned_Byte_t;
Green : Unsigned_Byte_t;
Blue : Unsigned_Byte_t);
pragma Import (C, Secondary_Color_3ub, "glSecondaryColor3ub");
procedure Secondary_Color_3ubv
(Vector : System.Address);
pragma Import (C, Secondary_Color_3ubv, "glSecondaryColor3ubv");
procedure Secondary_Color_3ui
(Red : Unsigned_Integer_t;
Green : Unsigned_Integer_t;
Blue : Unsigned_Integer_t);
pragma Import (C, Secondary_Color_3ui, "glSecondaryColor3ui");
procedure Secondary_Color_3uiv
(Vector : System.Address);
pragma Import (C, Secondary_Color_3uiv, "glSecondaryColor3uiv");
procedure Secondary_Color_3us
(Red : Unsigned_Short_t;
Green : Unsigned_Short_t;
Blue : Unsigned_Short_t);
pragma Import (C, Secondary_Color_3us, "glSecondaryColor3us");
procedure Secondary_Color_3usv
(Vector : System.Address);
pragma Import (C, Secondary_Color_3usv, "glSecondaryColor3usv");
procedure Secondary_Color_Pointer
(Size : Integer_t;
Data_Type : Enumeration_t;
Stride : Size_t;
Pointer : System.Address);
pragma Import (C, Secondary_Color_Pointer, "glSecondaryColorPointer");
procedure Window_Pos_2d
(X : Double_t;
Y : Double_t);
pragma Import (C, Window_Pos_2d, "glWindowPos2d");
procedure Window_Pos_2dv
(Vector : System.Address);
pragma Import (C, Window_Pos_2dv, "glWindowPos2dv");
procedure Window_Pos_2f
(X : Float_t;
Y : Float_t);
pragma Import (C, Window_Pos_2f, "glWindowPos2f");
procedure Window_Pos_2fv
(Vector : System.Address);
pragma Import (C, Window_Pos_2fv, "glWindowPos2fv");
procedure Window_Pos_2i
(X : Integer_t;
Y : Integer_t);
pragma Import (C, Window_Pos_2i, "glWindowPos2i");
procedure Window_Pos_2iv
(Vector : System.Address);
pragma Import (C, Window_Pos_2iv, "glWindowPos2iv");
procedure Window_Pos_2s
(X : Short_t;
Y : Short_t);
pragma Import (C, Window_Pos_2s, "glWindowPos2s");
procedure Window_Pos_2sv
(Vector : System.Address);
pragma Import (C, Window_Pos_2sv, "glWindowPos2sv");
procedure Window_Pos_3d
(X : Double_t;
Y : Double_t;
Z : Double_t);
pragma Import (C, Window_Pos_3d, "glWindowPos3d");
procedure Window_Pos_3dv
(Vector : System.Address);
pragma Import (C, Window_Pos_3dv, "glWindowPos3dv");
procedure Window_Pos_3f
(X : Float_t;
Y : Float_t;
Z : Float_t);
pragma Import (C, Window_Pos_3f, "glWindowPos3f");
procedure Window_Pos_3fv
(Vector : System.Address);
pragma Import (C, Window_Pos_3fv, "glWindowPos3fv");
procedure Window_Pos_3i
(X : Integer_t;
Y : Integer_t;
Z : Integer_t);
pragma Import (C, Window_Pos_3i, "glWindowPos3i");
procedure Window_Pos_3iv
(Vector : System.Address);
pragma Import (C, Window_Pos_3iv, "glWindowPos3iv");
procedure Window_Pos_3s
(X : Short_t;
Y : Short_t;
Z : Short_t);
pragma Import (C, Window_Pos_3s, "glWindowPos3s");
procedure Window_Pos_3sv
(Vector : System.Address);
pragma Import (C, Window_Pos_3sv, "glWindowPos3sv");
--
-- OpenGL 1.5
--
procedure Begin_Query
(Target : Enumeration_t;
ID : Unsigned_Integer_t);
pragma Import (C, Begin_Query, "glBeginQuery");
procedure Bind_Buffer
(Target : Enumeration_t;
Buffer : Unsigned_Integer_t);
pragma Import (C, Bind_Buffer, "glBindBuffer");
procedure Buffer_Data
(Target : Enumeration_t;
Size : Size_Pointer_t;
Data : System.Address;
Usage : Enumeration_t);
pragma Import (C, Buffer_Data, "glBufferData");
procedure Buffer_Sub_Data
(Target : Enumeration_t;
Offset : Integer_Pointer_t;
Size : Size_Pointer_t;
Data : System.Address);
pragma Import (C, Buffer_Sub_Data, "glBufferSubData");
procedure Delete_Buffers
(Size : Size_t;
Buffers : System.Address);
pragma Import (C, Delete_Buffers, "glDeleteBuffers");
procedure Delete_Queries
(Size : Size_t;
IDs : System.Address);
pragma Import (C, Delete_Queries, "glDeleteQueries");
procedure End_Query
(Target : Enumeration_t;
ID : Unsigned_Integer_t);
pragma Import (C, End_Query, "glEndQuery");
procedure Gen_Buffers
(Size : Size_t;
Buffers : System.Address);
pragma Import (C, Gen_Buffers, "glGenBuffers");
procedure Gen_Queries
(Size : Size_t;
IDs : System.Address);
pragma Import (C, Gen_Queries, "glGenQueries");
procedure Get_Buffer_Parameteriv
(Target : Enumeration_t;
Value : Enumeration_t;
Data : System.Address);
pragma Import (C, Get_Buffer_Parameteriv, "glGetBufferParameteriv");
procedure Get_Buffer_Pointerv
(Target : Enumeration_t;
Parameter : Enumeration_t;
Values : System.Address);
pragma Import (C, Get_Buffer_Pointerv, "glGetBufferPointerv");
procedure Get_Buffer_Sub_Data
(Target : Enumeration_t;
Offset : Integer_Pointer_t;
Size : Size_Pointer_t;
Data : Void_Pointer_t);
pragma Import (C, Get_Buffer_Sub_Data, "glGetBufferSubData");
procedure Get_Query_Objectiv
(Target : Unsigned_Integer_t;
Parameter : Enumeration_t;
Values : System.Address);
pragma Import (C, Get_Query_Objectiv, "glGetQueryObjectiv");
procedure Get_Query_Objectuiv
(Target : Unsigned_Integer_t;
Parameter : Enumeration_t;
Values : System.Address);
pragma Import (C, Get_Query_Objectuiv, "glGetQueryObjectuiv");
procedure Get_Queryiv
(Target : Enumeration_t;
Parameter : Enumeration_t;
Values : System.Address);
pragma Import (C, Get_Queryiv, "glGetQueryiv");
function Is_Buffer
(Buffer : Unsigned_Integer_t) return Boolean_t;
pragma Import (C, Is_Buffer, "glIsBuffer");
function Is_Query
(Query : Unsigned_Integer_t) return Boolean_t;
pragma Import (C, Is_Query, "glIsQuery");
function Map_Buffer
(Target : Enumeration_t;
Access_Policy : Enumeration_t) return Void_Pointer_t;
pragma Import (C, Map_Buffer, "glMapBuffer");
function Unmap_Buffer
(Target : Enumeration_t) return Boolean_t;
pragma Import (C, Unmap_Buffer, "glUnmapBuffer");
--
-- OpenGL 2.0
--
procedure Attach_Shader
(Program : Unsigned_Integer_t;
Shader : Unsigned_Integer_t);
pragma Import (C, Attach_Shader, "glAttachShader");
procedure Bind_Attrib_Location
(Program : Unsigned_Integer_t;
Index : Unsigned_Integer_t;
Name : System.Address);
pragma Import (C, Bind_Attrib_Location, "glBindAttribLocation");
procedure Blend_Equation_Separate
(Mode_RGB : Enumeration_t;
Mode_Alpha : Enumeration_t);
pragma Import (C, Blend_Equation_Separate, "glBlendEquationSeparate");
procedure Compile_Shader
(Shader : Unsigned_Integer_t);
pragma Import (C, Compile_Shader, "glCompileShader");
function Create_Program return Unsigned_Integer_t;
pragma Import (C, Create_Program, "glCreateProgram");
function Create_Shader
(Shader_Type : Enumeration_t) return Unsigned_Integer_t;
pragma Import (C, Create_Shader, "glCreateShader");
procedure Delete_Program
(Program : Unsigned_Integer_t);
pragma Import (C, Delete_Program, "glDeleteProgram");
procedure Delete_Shader
(Shader : Unsigned_Integer_t);
pragma Import (C, Delete_Shader, "glDeleteShader");
procedure Detach_Shader
(Program : Unsigned_Integer_t;
Shader : Unsigned_Integer_t);
pragma Import (C, Detach_Shader, "glDetachShader");
procedure Disable_Vertex_Attrib_Array
(Index : Unsigned_Integer_t);
pragma Import (C, Disable_Vertex_Attrib_Array, "glDisableVertexAttribArray");
procedure Draw_Buffers
(Size : Size_t;
Buffers : System.Address);
pragma Import (C, Draw_Buffers, "glDrawBuffers");
procedure Enable_Vertex_Attrib_Array
(Index : Unsigned_Integer_t);
pragma Import (C, Enable_Vertex_Attrib_Array, "glEnableVertexAttribArray");
procedure Get_Active_Attrib
(Program : Unsigned_Integer_t;
Index : Unsigned_Integer_t;
Buffer_Size : Size_t;
Length : System.Address;
Size : System.Address;
Data_Type : System.Address;
Name : System.Address);
pragma Import (C, Get_Active_Attrib, "glGetActiveAttrib");
procedure Get_Active_Uniform
(Program : Unsigned_Integer_t;
Index : Unsigned_Integer_t;
Buffer_Size : Size_t;
Length : System.Address;
Size : System.Address;
Data_Type : System.Address;
Name : System.Address);
pragma Import (C, Get_Active_Uniform, "glGetActiveUniform");
procedure Get_Attached_Shaders
(Program : Unsigned_Integer_t;
Size : Size_t;
Returned_Size : System.Address;
Shaders : System.Address);
pragma Import (C, Get_Attached_Shaders, "glGetAttachedShaders");
function Get_Attrib_Location
(Program : Unsigned_Integer_t;
Name : System.Address) return Integer_t;
pragma Import (C, Get_Attrib_Location, "glGetAttribLocation");
procedure Get_Program_Info_Log
(Program : Unsigned_Integer_t;
Max_Length : Size_t;
Length : System.Address;
Info_Log : System.Address);
pragma Import (C, Get_Program_Info_Log, "glGetProgramInfoLog");
procedure Get_Programiv
(Target : Unsigned_Integer_t;
Parameter : Enumeration_t;
Values : System.Address);
pragma Import (C, Get_Programiv, "glGetProgramiv");
procedure Get_Shader_Info_Log
(Shader : Unsigned_Integer_t;
Max_Length : Size_t;
Length : System.Address;
Info_Log : System.Address);
pragma Import (C, Get_Shader_Info_Log, "glGetShaderInfoLog");
procedure Get_Shader_Source
(Shader : Unsigned_Integer_t;
Max_Length : Size_t;
Length : System.Address;
Source : System.Address);
pragma Import (C, Get_Shader_Source, "glGetShaderSource");
procedure Get_Shaderiv
(Shader : Unsigned_Integer_t;
Parameter : Enumeration_t;
Values : System.Address);
pragma Import (C, Get_Shaderiv, "glGetShaderiv");
function Get_Uniform_Location
(Program : Unsigned_Integer_t;
Name : System.Address) return Integer_t;
pragma Import (C, Get_Uniform_Location, "glGetUniformLocation");
procedure Get_Uniformfv
(Program : Unsigned_Integer_t;
Location : Integer_t;
Values : System.Address);
pragma Import (C, Get_Uniformfv, "glGetUniformfv");
procedure Get_Uniformiv
(Program : Unsigned_Integer_t;
Location : Integer_t;
Values : System.Address);
pragma Import (C, Get_Uniformiv, "glGetUniformiv");
procedure Get_Vertex_Attrib_Pointerv
(Index : Unsigned_Integer_t;
Name : Enumeration_t;
Pointer : System.Address);
pragma Import (C, Get_Vertex_Attrib_Pointerv, "glGetVertexAttribPointerv");
procedure Get_Vertex_Attribdv
(Index : Unsigned_Integer_t;
Parameter : Enumeration_t;
Values : System.Address);
pragma Import (C, Get_Vertex_Attribdv, "glGetVertexAttribdv");
procedure Get_Vertex_Attribfv
(Index : Unsigned_Integer_t;
Parameter : Enumeration_t;
Values : System.Address);
pragma Import (C, Get_Vertex_Attribfv, "glGetVertexAttribfv");
procedure Get_Vertex_Attribiv
(Index : Unsigned_Integer_t;
Parameter : Enumeration_t;
Values : System.Address);
pragma Import (C, Get_Vertex_Attribiv, "glGetVertexAttribiv");
function Is_Program
(Program : Unsigned_Integer_t) return Boolean_t;
pragma Import (C, Is_Program, "glIsProgram");
function Is_Shader
(Shader : Unsigned_Integer_t) return Boolean_t;
pragma Import (C, Is_Shader, "glIsShader");
procedure Link_Program
(Program : Unsigned_Integer_t);
pragma Import (C, Link_Program, "glLinkProgram");
procedure Shader_Source
(Shader : Unsigned_Integer_t;
Size : Size_t;
String_Array : System.Address;
Length : System.Address);
pragma Import (C, Shader_Source, "glShaderSource");
procedure Stencil_Func_Separate
(Face : Enumeration_t;
Func : Enumeration_t;
Reference : Integer_t;
Mask : Unsigned_Integer_t);
pragma Import (C, Stencil_Func_Separate, "glStencilFuncSeparate");
procedure Stencil_Mask_Separate
(Face : Enumeration_t;
Mask : Unsigned_Integer_t);
pragma Import (C, Stencil_Mask_Separate, "glStencilMaskSeparate");
procedure Stencil_Op_Separate
(Face : Enumeration_t;
Stencil_Fail : Enumeration_t;
Depth_Fail : Enumeration_t;
Depth_Pass : Enumeration_t);
pragma Import (C, Stencil_Op_Separate, "glStencilOpSeparate");
procedure Uniform_1f
(Location : Integer_t;
V0 : Float_t);
pragma Import (C, Uniform_1f, "glUniform1f");
procedure Uniform_1fv
(Location : Integer_t;
Size : Size_t;
Value : System.Address);
pragma Import (C, Uniform_1fv, "glUniform1fv");
procedure Uniform_1i
(Location : Integer_t;
V0 : Integer_t);
pragma Import (C, Uniform_1i, "glUniform1i");
procedure Uniform_1iv
(Location : Integer_t;
Size : Size_t;
Value : System.Address);
pragma Import (C, Uniform_1iv, "glUniform1iv");
procedure Uniform_2f
(Location : Integer_t;
V0 : Float_t;
V1 : Float_t);
pragma Import (C, Uniform_2f, "glUniform2f");
procedure Uniform_2fv
(Location : Integer_t;
Size : Size_t;
Value : System.Address);
pragma Import (C, Uniform_2fv, "glUniform2fv");
procedure Uniform_2i
(Location : Integer_t;
V0 : Integer_t;
V1 : Integer_t);
pragma Import (C, Uniform_2i, "glUniform2i");
procedure Uniform_2iv
(Location : Integer_t;
Size : Size_t;
Value : System.Address);
pragma Import (C, Uniform_2iv, "glUniform2iv");
procedure Uniform_3f
(Location : Integer_t;
V0 : Float_t;
V1 : Float_t;
V2 : Float_t);
pragma Import (C, Uniform_3f, "glUniform3f");
procedure Uniform_3fv
(Location : Integer_t;
Size : Size_t;
Value : System.Address);
pragma Import (C, Uniform_3fv, "glUniform3fv");
procedure Uniform_3i
(Location : Integer_t;
V0 : Integer_t;
V1 : Integer_t;
V2 : Integer_t);
pragma Import (C, Uniform_3i, "glUniform3i");
procedure Uniform_3iv
(Location : Integer_t;
Size : Size_t;
Value : System.Address);
pragma Import (C, Uniform_3iv, "glUniform3iv");
procedure Uniform_4f
(Location : Integer_t;
V0 : Float_t;
V1 : Float_t;
V2 : Float_t;
V3 : Float_t);
pragma Import (C, Uniform_4f, "glUniform4f");
procedure Uniform_4fv
(Location : Integer_t;
Size : Size_t;
Value : System.Address);
pragma Import (C, Uniform_4fv, "glUniform4fv");
procedure Uniform_4i
(Location : Integer_t;
V0 : Integer_t;
V1 : Integer_t;
V2 : Integer_t;
V3 : Integer_t);
pragma Import (C, Uniform_4i, "glUniform4i");
procedure Uniform_4iv
(Location : Integer_t;
Size : Size_t;
Value : System.Address);
pragma Import (C, Uniform_4iv, "glUniform4iv");
procedure Uniform_Matrix_2fv
(Location : Integer_t;
Size : Size_t;
Transpose : Boolean_t;
Value : System.Address);
pragma Import (C, Uniform_Matrix_2fv, "glUniformMatrix2fv");
procedure Uniform_Matrix_3fv
(Location : Integer_t;
Size : Size_t;
Transpose : Boolean_t;
Value : System.Address);
pragma Import (C, Uniform_Matrix_3fv, "glUniformMatrix3fv");
procedure Uniform_Matrix_4fv
(Location : Integer_t;
Size : Size_t;
Transpose : Boolean_t;
Value : System.Address);
pragma Import (C, Uniform_Matrix_4fv, "glUniformMatrix4fv");
procedure Use_Program
(Program : Unsigned_Integer_t);
pragma Import (C, Use_Program, "glUseProgram");
procedure Validate_Program
(Program : Unsigned_Integer_t);
pragma Import (C, Validate_Program, "glValidateProgram");
procedure Vertex_Attrib_1d
(Index : Unsigned_Integer_t;
V0 : Double_t);
pragma Import (C, Vertex_Attrib_1d, "glVertexAttrib1d");
procedure Vertex_Attrib_1dv
(Index : Unsigned_Integer_t;
Vector : System.Address);
pragma Import (C, Vertex_Attrib_1dv, "glVertexAttrib1dv");
procedure Vertex_Attrib_1f
(Index : Unsigned_Integer_t;
V0 : Float_t);
pragma Import (C, Vertex_Attrib_1f, "glVertexAttrib1f");
procedure Vertex_Attrib_1fv
(Index : Unsigned_Integer_t;
Vector : System.Address);
pragma Import (C, Vertex_Attrib_1fv, "glVertexAttrib1fv");
procedure Vertex_Attrib_1s
(Index : Unsigned_Integer_t;
V0 : Short_t);
pragma Import (C, Vertex_Attrib_1s, "glVertexAttrib1s");
procedure Vertex_Attrib_1sv
(Index : Unsigned_Integer_t;
Vector : System.Address);
pragma Import (C, Vertex_Attrib_1sv, "glVertexAttrib1sv");
procedure Vertex_Attrib_2d
(Index : Unsigned_Integer_t;
V0 : Double_t;
V1 : Double_t);
pragma Import (C, Vertex_Attrib_2d, "glVertexAttrib2d");
procedure Vertex_Attrib_2dv
(Index : Unsigned_Integer_t;
Vector : System.Address);
pragma Import (C, Vertex_Attrib_2dv, "glVertexAttrib2dv");
procedure Vertex_Attrib_2f
(Index : Unsigned_Integer_t;
V0 : Float_t;
V1 : Float_t);
pragma Import (C, Vertex_Attrib_2f, "glVertexAttrib2f");
procedure Vertex_Attrib_2fv
(Index : Unsigned_Integer_t;
Vector : System.Address);
pragma Import (C, Vertex_Attrib_2fv, "glVertexAttrib2fv");
procedure Vertex_Attrib_2s
(Index : Unsigned_Integer_t;
V0 : Short_t;
V1 : Short_t);
pragma Import (C, Vertex_Attrib_2s, "glVertexAttrib2s");
procedure Vertex_Attrib_2sv
(Index : Unsigned_Integer_t;
Vector : System.Address);
pragma Import (C, Vertex_Attrib_2sv, "glVertexAttrib2sv");
procedure Vertex_Attrib_3d
(Index : Unsigned_Integer_t;
V0 : Double_t;
V1 : Double_t;
V2 : Double_t);
pragma Import (C, Vertex_Attrib_3d, "glVertexAttrib3d");
procedure Vertex_Attrib_3dv
(Index : Unsigned_Integer_t;
Vector : System.Address);
pragma Import (C, Vertex_Attrib_3dv, "glVertexAttrib3dv");
procedure Vertex_Attrib_3f
(Index : Unsigned_Integer_t;
V0 : Float_t;
V1 : Float_t;
V2 : Float_t);
pragma Import (C, Vertex_Attrib_3f, "glVertexAttrib3f");
procedure Vertex_Attrib_3fv
(Index : Unsigned_Integer_t;
Vector : System.Address);
pragma Import (C, Vertex_Attrib_3fv, "glVertexAttrib3fv");
procedure Vertex_Attrib_3s
(Index : Unsigned_Integer_t;
V0 : Short_t;
V1 : Short_t;
V2 : Short_t);
pragma Import (C, Vertex_Attrib_3s, "glVertexAttrib3s");
procedure Vertex_Attrib_3sv
(Index : Unsigned_Integer_t;
Vector : System.Address);
pragma Import (C, Vertex_Attrib_3sv, "glVertexAttrib3sv");
procedure Vertex_Attrib_4Nbv
(Index : Unsigned_Integer_t;
Vector : System.Address);
pragma Import (C, Vertex_Attrib_4Nbv, "glVertexAttrib4Nbv");
procedure Vertex_Attrib_4Niv
(Index : Unsigned_Integer_t;
Vector : System.Address);
pragma Import (C, Vertex_Attrib_4Niv, "glVertexAttrib4Niv");
procedure Vertex_Attrib_4Nsv
(Index : Unsigned_Integer_t;
Vector : System.Address);
pragma Import (C, Vertex_Attrib_4Nsv, "glVertexAttrib4Nsv");
procedure Vertex_Attrib_4Nub
(Index : Unsigned_Integer_t;
V0 : Unsigned_Byte_t;
V1 : Unsigned_Byte_t;
V2 : Unsigned_Byte_t;
V3 : Unsigned_Byte_t);
pragma Import (C, Vertex_Attrib_4Nub, "glVertexAttrib4Nub");
procedure Vertex_Attrib_4Nubv
(Index : Unsigned_Integer_t;
Vector : System.Address);
pragma Import (C, Vertex_Attrib_4Nubv, "glVertexAttrib4Nubv");
procedure Vertex_Attrib_4Nuiv
(Index : Unsigned_Integer_t;
Vector : System.Address);
pragma Import (C, Vertex_Attrib_4Nuiv, "glVertexAttrib4Nuiv");
procedure Vertex_Attrib_4Nusv
(Index : Unsigned_Integer_t;
Vector : System.Address);
pragma Import (C, Vertex_Attrib_4Nusv, "glVertexAttrib4Nusv");
procedure Vertex_Attrib_4bv
(Index : Unsigned_Integer_t;
Vector : System.Address);
pragma Import (C, Vertex_Attrib_4bv, "glVertexAttrib4bv");
procedure Vertex_Attrib_4d
(Index : Unsigned_Integer_t;
V0 : Double_t;
V1 : Double_t;
V2 : Double_t;
V3 : Double_t);
pragma Import (C, Vertex_Attrib_4d, "glVertexAttrib4d");
procedure Vertex_Attrib_4dv
(Index : Unsigned_Integer_t;
Vector : System.Address);
pragma Import (C, Vertex_Attrib_4dv, "glVertexAttrib4dv");
procedure Vertex_Attrib_4f
(Index : Unsigned_Integer_t;
V0 : Float_t;
V1 : Float_t;
V2 : Float_t;
V3 : Float_t);
pragma Import (C, Vertex_Attrib_4f, "glVertexAttrib4f");
procedure Vertex_Attrib_4fv
(Index : Unsigned_Integer_t;
Vector : System.Address);
pragma Import (C, Vertex_Attrib_4fv, "glVertexAttrib4fv");
procedure Vertex_Attrib_4iv
(Index : Unsigned_Integer_t;
Vector : System.Address);
pragma Import (C, Vertex_Attrib_4iv, "glVertexAttrib4iv");
procedure Vertex_Attrib_4s
(Index : Unsigned_Integer_t;
V0 : Short_t;
V1 : Short_t;
V2 : Short_t;
V3 : Short_t);
pragma Import (C, Vertex_Attrib_4s, "glVertexAttrib4s");
procedure Vertex_Attrib_4sv
(Index : Unsigned_Integer_t;
Vector : System.Address);
pragma Import (C, Vertex_Attrib_4sv, "glVertexAttrib4sv");
procedure Vertex_Attrib_4ubv
(Index : Unsigned_Integer_t;
Vector : System.Address);
pragma Import (C, Vertex_Attrib_4ubv, "glVertexAttrib4ubv");
procedure Vertex_Attrib_4uiv
(Index : Unsigned_Integer_t;
Vector : System.Address);
pragma Import (C, Vertex_Attrib_4uiv, "glVertexAttrib4uiv");
procedure Vertex_Attrib_4usv
(Index : Unsigned_Integer_t;
Vector : System.Address);
pragma Import (C, Vertex_Attrib_4usv, "glVertexAttrib4usv");
procedure Vertex_Attrib_Pointer
(Index : Unsigned_Integer_t;
Size : Integer_t;
Data_Type : Enumeration_t;
Normalized : Boolean_t;
Stride : Size_t;
Pointer : System.Address);
pragma Import (C, Vertex_Attrib_Pointer, "glVertexAttribPointer");
--
-- OpenGL 2.1
--
--
-- OpenGL 3.0
--
procedure Bind_Vertex_Array
(Index : Unsigned_Integer_t);
pragma Import (C, Bind_Vertex_Array, "glBindVertexArray");
procedure Delete_Vertex_Arrays
(Size : Size_t;
Arrays : System.Address);
pragma Import (C, Delete_Vertex_Arrays, "glDeleteVertexArrays");
procedure Flush_Mapped_Buffer_Range
(Target : Enumeration_t;
Offset : Integer_Pointer_t;
Length : Size_Pointer_t);
pragma Import (C, Flush_Mapped_Buffer_Range, "glFlushMappedBufferRange");
procedure Gen_Vertex_Arrays
(Size : Size_t;
Arrays : System.Address);
pragma Import (C, Gen_Vertex_Arrays, "glGenVertexArrays");
function Map_Buffer_Range
(Target : Enumeration_t;
Offset : Integer_Pointer_t;
Length : Size_Pointer_t;
Access_Policy : Bitfield_t) return Void_Pointer_t;
pragma Import (C, Map_Buffer_Range, "glMapBufferRange");
end OpenGL.Thin;
|
------------------------------------------------------------------------------
-- --
-- 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. --
-- --
------------------------------------------------------------------------------
package body SGTL5000 is
------------
-- Modify --
------------
procedure Modify (This : in out SGTL5000_DAC;
Reg : UInt16;
Mask : UInt16;
Value : UInt16)
is
Tmp : UInt16 := This.I2C_Read (Reg);
begin
Tmp := Tmp and (not Mask);
Tmp := Tmp or Value;
This.I2C_Write (Reg, Tmp);
end Modify;
---------------
-- I2C_Write --
---------------
procedure I2C_Write (This : in out SGTL5000_DAC;
Reg : UInt16;
Value : UInt16)
is
Status : I2C_Status with Unreferenced;
begin
This.Port.Mem_Write
(Addr => SGTL5000_QFN20_I2C_Addr,
Mem_Addr => Reg,
Mem_Addr_Size => Memory_Size_16b,
Data => (1 => UInt8 (Shift_Right (Value, 8) and 16#FF#),
2 => UInt8 (Value and 16#FF#)),
Status => Status);
end I2C_Write;
--------------
-- I2C_Read --
--------------
function I2C_Read (This : SGTL5000_DAC;
Reg : UInt16)
return UInt16
is
Status : I2C_Status;
Data : I2C_Data (1 .. 2);
begin
This.Port.Mem_Read
(Addr => SGTL5000_QFN20_I2C_Addr,
Mem_Addr => Reg,
Mem_Addr_Size => Memory_Size_16b,
Data => Data,
Status => Status);
return Shift_Left (UInt16 (Data (1)), 8) or UInt16 (Data (2));
end I2C_Read;
--------------
-- Valid_Id --
--------------
function Valid_Id (This : SGTL5000_DAC) return Boolean is
Id : constant UInt16 := This.I2C_Read (Chip_ID_Reg);
begin
return (Id and 16#FF00#) = SGTL5000_Chip_ID;
end Valid_Id;
--------------------
-- Set_DAC_Volume --
--------------------
procedure Set_DAC_Volume (This : in out SGTL5000_DAC;
Left, Right : DAC_Volume)
is
begin
This.I2C_Write (DAC_VOL_REG,
UInt16 (Left) or Shift_Left (UInt16 (Right), 8));
end Set_DAC_Volume;
--------------------
-- Set_ADC_Volume --
--------------------
procedure Set_ADC_Volume (This : in out SGTL5000_DAC;
Left, Right : ADC_Volume;
Minus_6db : Boolean)
is
begin
This.Modify (ANA_ADC_CTRL_REG,
2#0000_0001_1111_1111#,
UInt16 (Left) or Shift_Left (UInt16 (Right), 4)
or (if Minus_6db then 2#000_0001_0000_0000# else 0));
end Set_ADC_Volume;
---------------------------
-- Set_Headphones_Volume --
---------------------------
procedure Set_Headphones_Volume (This : in out SGTL5000_DAC;
Left, Right : HP_Volume)
is
begin
This.Modify (ANA_HP_CTRL_REG,
2#0111_1111_0111_1111#,
UInt16 (Left) or Shift_Left (UInt16 (Right), 8));
end Set_Headphones_Volume;
-------------------------
-- Set_Line_Out_Volume --
-------------------------
procedure Set_Line_Out_Volume (This : in out SGTL5000_DAC;
Left, Right : Line_Out_Volume)
is
begin
This.Modify (LINE_OUT_VOL_REG,
2#0001_1111_0001_1111#,
UInt16 (Left) or Shift_Left (UInt16 (Right), 8));
end Set_Line_Out_Volume;
---------------------
-- Mute_Headphones --
---------------------
procedure Mute_Headphones (This : in out SGTL5000_DAC;
Mute : Boolean := True)
is
begin
This.Modify (ANA_CTRL_REG,
2#0000_0000_0001_0000#,
(if Mute then 2#0000_0000_0001_0000# else 0));
end Mute_Headphones;
-------------------
-- Mute_Line_Out --
-------------------
procedure Mute_Line_Out (This : in out SGTL5000_DAC;
Mute : Boolean := True)
is
begin
This.Modify (ANA_CTRL_REG,
2#0000_0001_0000_0000#,
(if Mute then 2#0000_0001_0000_0000# else 0));
end Mute_Line_Out;
--------------
-- Mute_ADC --
--------------
procedure Mute_ADC (This : in out SGTL5000_DAC;
Mute : Boolean := True)
is
begin
This.Modify (ANA_CTRL_REG,
2#0000_0000_0000_0001#,
(if Mute then 2#0000_0000_0000_0001# else 0));
end Mute_ADC;
--------------
-- Mute_DAC --
--------------
procedure Mute_DAC (This : in out SGTL5000_DAC;
Mute : Boolean := True)
is
begin
This.Modify (ADCDAC_CTRL_REG,
2#0000_0000_0000_1100#,
(if Mute then 2#0000_0000_0000_1100# else 0));
end Mute_DAC;
-----------------------
-- Set_Power_Control --
-----------------------
procedure Set_Power_Control (This : in out SGTL5000_DAC;
ADC : Power_State;
DAC : Power_State;
DAP : Power_State;
I2S_Out : Power_State;
I2S_In : Power_State)
is
Value : UInt16 := 0;
begin
if ADC = On then
Value := Value or 2#0000_0000_0100_0000#;
end if;
if DAC = On then
Value := Value or 2#0000_0000_0010_0000#;
end if;
if DAP = On then
Value := Value or 2#0000_0000_0001_0000#;
end if;
if I2S_Out = On then
Value := Value or 2#0000_0000_0000_0010#;
end if;
if I2S_In = On then
Value := Value or 2#0000_0000_0000_0001#;
end if;
This.Modify (DIG_POWER_REG,
2#0000_0000_0111_0011#,
Value);
end Set_Power_Control;
---------------------------
-- Set_Reference_Control --
---------------------------
procedure Set_Reference_Control (This : in out SGTL5000_DAC;
VAG : Analog_Ground_Voltage;
Bias : Current_Bias;
Slow_VAG_Ramp : Boolean)
is
Value : UInt16 := 0;
begin
Value := Value or Shift_Left (UInt16 (VAG), 4);
Value := Value or Shift_Left (UInt16 (Bias), 1);
Value := Value or (if Slow_VAG_Ramp then 1 else 0);
This.I2C_Write (REF_CTRL_REG, Value);
end Set_Reference_Control;
-------------------------
-- Set_Short_Detectors --
-------------------------
procedure Set_Short_Detectors (This : in out SGTL5000_DAC;
Right_HP : Short_Detector_Level;
Left_HP : Short_Detector_Level;
Center_HP : Short_Detector_Level;
Mode_LR : UInt2;
Mode_CM : UInt2)
is
Value : UInt16 := 0;
begin
Value := Value or (Shift_Left (UInt16 (Right_HP), 12));
Value := Value or (Shift_Left (UInt16 (Left_HP), 8));
Value := Value or (Shift_Left (UInt16 (Center_HP), 4));
Value := Value or (Shift_Left (UInt16 (Mode_LR), 2));
Value := Value or UInt16 (Mode_CM);
This.I2C_Write (SHORT_CTRL_REG, Value);
end Set_Short_Detectors;
-------------------------
-- Set_Linereg_Control --
-------------------------
procedure Set_Linereg_Control (This : in out SGTL5000_DAC;
Charge_Pump_Src_Override : Boolean;
Charge_Pump_Src : Charge_Pump_Source;
Linereg_Out_Voltage : Linear_Regulator_Out_Voltage)
is
Value : UInt16 := 0;
begin
if Charge_Pump_Src_Override then
Value := Value or 2#10_0000#;
end if;
if Charge_Pump_Src = VDDIO then
Value := Value or 2#100_0000#;
end if;
Value := Value or UInt16 (Linereg_Out_Voltage);
This.I2C_Write (LINE_OUT_CTRL_REG, Value);
end Set_Linereg_Control;
----------------------
-- Set_Analog_Power --
----------------------
procedure Set_Analog_Power (This : in out SGTL5000_DAC;
DAC_Mono : Boolean := False;
Linreg_Simple_PowerUp : Boolean := False;
Startup_PowerUp : Boolean := False;
VDDC_Charge_Pump_PowerUp : Boolean := False;
PLL_PowerUp : Boolean := False;
Linereg_D_PowerUp : Boolean := False;
VCOAmp_PowerUp : Boolean := False;
VAG_PowerUp : Boolean := False;
ADC_Mono : Boolean := False;
Reftop_PowerUp : Boolean := False;
Headphone_PowerUp : Boolean := False;
DAC_PowerUp : Boolean := False;
Capless_Headphone_PowerUp : Boolean := False;
ADC_PowerUp : Boolean := False;
Linout_PowerUp : Boolean := False)
is
Value : UInt16 := 0;
begin
if Linout_PowerUp then
Value := Value or 2**0;
end if;
if ADC_PowerUp then
Value := Value or 2**1;
end if;
if Capless_Headphone_PowerUp then
Value := Value or 2**2;
end if;
if DAC_PowerUp then
Value := Value or 2**3;
end if;
if Headphone_PowerUp then
Value := Value or 2**4;
end if;
if Reftop_PowerUp then
Value := Value or 2**5;
end if;
if not ADC_Mono then
Value := Value or 2**6;
end if;
if VAG_PowerUp then
Value := Value or 2**7;
end if;
if VCOAmp_PowerUp then
Value := Value or 2**8;
end if;
if Linereg_D_PowerUp then
Value := Value or 2**9;
end if;
if PLL_PowerUp then
Value := Value or 2**10;
end if;
if VDDC_Charge_Pump_PowerUp then
Value := Value or 2**11;
end if;
if Startup_PowerUp then
Value := Value or 2**12;
end if;
if Linreg_Simple_PowerUp then
Value := Value or 2**13;
end if;
if not DAC_Mono then
Value := Value or 2**14;
end if;
This.I2C_Write (ANA_POWER_REG, Value);
end Set_Analog_Power;
-----------------------
-- Set_Clock_Control --
-----------------------
procedure Set_Clock_Control (This : in out SGTL5000_DAC;
Rate : Rate_Mode;
FS : SYS_FS_Freq;
MCLK : MCLK_Mode)
is
Value : UInt16 := 0;
begin
Value := Value or (case Rate is
when SYS_FS => 2#00_0000#,
when Half_SYS_FS => 2#01_0000#,
when Quarter_SYS_FS => 2#10_0000#,
when Sixth_SYS_FS => 2#11_0000#);
Value := Value or (case FS is
when SYS_FS_32kHz => 2#0000#,
when SYS_FS_44kHz => 2#0100#,
when SYS_FS_48kHz => 2#1000#,
when SYS_FS_96kHz => 2#1100#);
Value := Value or (case MCLK is
when MCLK_256FS => 2#00#,
when MCLK_384FS => 2#01#,
when MCLK_512FS => 2#10#,
when Use_PLL => 2#11#);
This.I2C_Write (CLK_CTRL_REG, Value);
end Set_Clock_Control;
---------------------
-- Set_I2S_Control --
---------------------
procedure Set_I2S_Control (This : in out SGTL5000_DAC;
SCLKFREQ : SCLKFREQ_Mode;
Invert_SCLK : Boolean;
Master_Mode : Boolean;
Data_Len : Data_Len_Mode;
I2S : I2S_Mode;
LR_Align : Boolean;
LR_Polarity : Boolean)
is
Value : UInt16 := 0;
begin
Value := Value or (case SCLKFREQ is
when SCLKFREQ_64FS => 2#0_0000_0000#,
when SCLKFREQ_32FS => 2#1_0000_0000#);
if Invert_SCLK then
Value := Value or 2#0100_0000#;
end if;
if Master_Mode then
Value := Value or 2#1000_0000#;
end if;
Value := Value or (case Data_Len is
when Data_32b => 2#00_0000#,
when Data_24b => 2#01_0000#,
when Data_20b => 2#10_0000#,
when Data_16b => 2#11_0000#);
Value := Value or (case I2S is
when I2S_Left_Justified => 2#0000#,
when Right_Justified => 2#0100#,
when PCM => 2#1000#);
if LR_Align then
Value := Value or 2#10#;
end if;
if LR_Polarity then
Value := Value or 2#1#;
end if;
This.I2C_Write (I2S_CTRL_REG, Value);
end Set_I2S_Control;
-----------------------
-- Select_ADC_Source --
-----------------------
procedure Select_ADC_Source (This : in out SGTL5000_DAC;
Source : ADC_Source;
Enable_ZCD : Boolean)
is
begin
This.Modify (ANA_CTRL_REG,
2#0000_0000_0000_0100#,
(case Source is
when Microphone => 2#0000_0000_0000_0000#,
when Line_In => 2#0000_0000_0000_0100#)
or (if Enable_ZCD then 2#0000_0000_0000_0010# else 0));
end Select_ADC_Source;
-----------------------
-- Select_DAP_Source --
-----------------------
procedure Select_DAP_Source (This : in out SGTL5000_DAC;
Source : DAP_Source)
is
begin
This.Modify (SSS_CTRL_REG,
2#0000_0000_1100_0000#,
(case Source is
when ADC => 2#0000_0000_0000_0000#,
when I2S_In => 2#0000_0000_0100_0000#));
end Select_DAP_Source;
---------------------------
-- Select_DAP_Mix_Source --
---------------------------
procedure Select_DAP_Mix_Source (This : in out SGTL5000_DAC;
Source : DAP_Mix_Source)
is
begin
This.Modify (SSS_CTRL_REG,
2#0000_0011_0000_0000#,
(case Source is
when ADC => 2#0000_0000_0000_0000#,
when I2S_In => 2#0000_0001_0000_0000#));
end Select_DAP_Mix_Source;
-----------------------
-- Select_DAC_Source --
-----------------------
procedure Select_DAC_Source (This : in out SGTL5000_DAC;
Source : DAC_Source)
is
begin
This.Modify (SSS_CTRL_REG,
2#0000_0000_0011_0000#,
(case Source is
when ADC => 2#0000_0000_0000_0000#,
when I2S_In => 2#0000_0000_0001_0000#,
when DAP => 2#0000_0000_0011_0000#));
end Select_DAC_Source;
----------------------
-- Select_HP_Source --
----------------------
procedure Select_HP_Source (This : in out SGTL5000_DAC;
Source : HP_Source;
Enable_ZCD : Boolean)
is
begin
This.Modify (ANA_CTRL_REG,
2#0000_0000_0100_0000#,
(case Source is
when DAC => 2#0000_0000_0000_0000#,
when Line_In => 2#0000_0000_0100_0000#)
or (if Enable_ZCD then 2#0000_0000_0010_0000# else 0));
end Select_HP_Source;
---------------------------
-- Select_I2S_Out_Source --
---------------------------
procedure Select_I2S_Out_Source (This : in out SGTL5000_DAC;
Source : I2S_Out_Source)
is
begin
This.Modify (SSS_CTRL_REG,
2#0000_0000_0000_0011#,
(case Source is
when ADC => 2#0000_0000_0000_0000#,
when I2S_In => 2#0000_0000_0000_0001#,
when DAP => 2#0000_0000_0000_0011#));
end Select_I2S_Out_Source;
end SGTL5000;
|
with Ada.Calendar;
with Ada.Streams.Stream_IO;
with Ada.Unchecked_Deallocation;
with GID;
with GL.Types;
with GL.Objects.Textures.Targets;
package body GL.Images is
generic
type Component is mod <>;
Num_Components : Types.Int;
Width, Height : Types.Size;
package Loader is
type Raw_Data is array (Types.Int range <>) of Component;
type Raw_Data_Access is access Raw_Data;
procedure To_Array (
Source : in out GID.Image_descriptor;
Data : out Raw_Data_Access);
procedure Free_Data is new Ada.Unchecked_Deallocation
(Raw_Data, Raw_Data_Access);
end Loader;
package body Loader is
procedure To_Array (
Source : in out GID.Image_descriptor;
Data : out Raw_Data_Access) is
use type Types.Int;
Cur_Pos : Types.Int := 0;
procedure Set_X_Y (X, Y : Natural) is
begin
Cur_Pos := GL.Types.Int (Y) * Width * Num_Components
+ GL.Types.Int (X) * Num_Components;
end Set_X_Y;
procedure Put_Pixel (R, G, B, A : Component) is
Input : constant array (Types.Int'(0) .. Types.Int'(3)) of Component := (R, G, B, A);
begin
for I in 0 .. Num_Components - 1 loop
Data (Cur_Pos + I) := Input (I);
end loop;
Cur_Pos := Cur_Pos + Num_Components;
end Put_Pixel;
procedure Feedback (Percents : Natural) is null;
procedure Content_Loader is new GID.Load_image_contents
(Component, Set_X_Y, Put_Pixel, Feedback, GID.nice);
Next_Frame : Ada.Calendar.Day_Duration;
begin
Data := new Raw_Data (0 .. Width * Height * Num_Components - 1);
Content_Loader (Source, Next_Frame);
end To_Array;
end Loader;
procedure Load_Image_To_Texture (
Source : in out Ada.Streams.Root_Stream_Type'Class;
Texture : in out GL.Objects.Textures.Texture'Class;
Texture_Format : GL.Pixels.Internal_Format;
Try_TGA : Boolean := False) is
Descriptor : GID.Image_descriptor;
Width, Height : Types.Size;
use GL.Pixels;
use GL.Objects.Textures.Targets;
Needs_Wide_Component : Boolean := False;
Num_Components : GL.Types.Int;
Format : Pixels.Data_Format;
begin
GID.Load_image_header (Descriptor, Source, Try_TGA);
Width := Types.Size (GID.Pixel_width (Descriptor));
Height := Types.Size (GID.Pixel_height (Descriptor));
case Texture_Format is
when Depth_Component | Red | Alpha | Luminance | Alpha4 | Alpha8 |
Luminance4 | Luminance8 | Intensity | Intensity4 | Intensity8 |
Compressed_Red | R8 | R8I | R8UI | Compressed_Alpha |
Compressed_Luminance | Compressed_Intensity | SLuminance |
SLuminance8 | Compressed_Red_RGTC1 | Compressed_Signed_Red_RGTC1 |
R8_SNorm =>
Num_Components := 1;
Format := Pixels.Red;
when Alpha12 | Alpha16 | Luminance12 | Luminance16 |
Intensity12 | Intensity16 | Depth_Component16 |
Depth_Component24 | Depth_Component32 | R16 | R16F | R32F |
R16I | R16UI | R32I | R32UI | R16_SNorm =>
Num_Components := 1;
Format := Pixels.Red;
Needs_Wide_Component := True;
when Luminance_Alpha | Luminance4_Alpha4 | Luminance6_Alpha2 |
Luminance8_Alpha8 | Compressed_RG | RG | RG8 | RG8I | RG8UI |
Compressed_Luminance_Alpha | SLuminance_Alpha |
SLuminance8_Alpha8 | Compressed_RG_RGTC2 |
Compressed_Signed_RG_RGTC2 | RG8_SNorm =>
Num_Components := 2;
Format := Pixels.RG;
when Luminance12_Alpha4 | Luminance12_Alpha12 | Luminance16_Alpha16 |
RG16 | RG16F | RG32F | RG16I | RG16UI | RG32I | RG32UI |
Depth24_Stencil8 | RG16_SNorm =>
Num_Components := 2;
Format := Pixels.RG;
Needs_Wide_Component := True;
when RGB | R3_G3_B2 | RGB4 | RGB5 | RGB8 | Compressed_RGB_S3TC_DXT1 |
Compressed_RGB | SRGB | SRGB8 | Compressed_SRGB |
Compressed_SRGB_S3TC_DXT1 | RGB8UI | RGB8I |
Compressed_RGB_BPTC_Signed_Float |
Compressed_RGB_BPTC_Unsigned_Float | RGB8_SNorm =>
Num_Components := 3;
Format := Pixels.RGB;
when RGB10 | RGB12 | RGB16 | R11F_G11F_B10F | RGB9_E5 | RGB32UI |
RGB16UI | RGB32I | RGB16I | RGB16_SNorm =>
Num_Components := 3;
Format := Pixels.RGB;
Needs_Wide_Component := True;
when RGBA | RGBA2 | RGBA4 | RGB5_A1 | RGBA8 |
Compressed_RGBA_S3TC_DXT1 | Compressed_RGBA_S3TC_DXT3 |
Compressed_RGBA_S3TC_DXT5 | Compressed_RGBA | SRGB_Alpha |
SRGB8_Alpha8 | Compressed_SRGB_Alpha |
Compressed_SRGB_Alpha_S3TC_DXT1 |
Compressed_SRGB_Alpha_S3TC_DXT3 |
Compressed_SRGB_Alpha_S3TC_DXT5 | RGBA8UI | RGBA8I |
Compressed_RGBA_BPTC_Unorm | Compressed_SRGB_Alpha_BPTC_UNorm |
RGBA8_SNorm | Compressed_RGBA_ASTC_4x4 |
Compressed_RGBA_ASTC_5x4 | Compressed_RGBA_ASTC_5x5 |
Compressed_RGBA_ASTC_6x5 | Compressed_RGBA_ASTC_6x6 |
Compressed_RGBA_ASTC_8x5 | Compressed_RGBA_ASTC_8x6 |
Compressed_RGBA_ASTC_8x8 | Compressed_SRGB8_Alpha8_ASTC_4x4 |
Compressed_SRGB8_Alpha8_ASTC_5x4 |
Compressed_SRGB8_Alpha8_ASTC_5x5 |
Compressed_SRGB8_Alpha8_ASTC_6x5 |
Compressed_SRGB8_Alpha8_ASTC_6x6 |
Compressed_SRGB8_Alpha8_ASTC_8x5 |
Compressed_SRGB8_Alpha8_ASTC_8x6 |
Compressed_SRGB8_Alpha8_ASTC_8x8 |
Compressed_SRGB8_Alpha8_ASTC_10x5 |
Compressed_SRGB8_Alpha8_ASTC_10x6 |
Compressed_SRGB8_Alpha8_ASTC_10x8 |
Compressed_SRGB8_Alpha8_ASTC_10x10 |
Compressed_SRGB8_Alpha8_ASTC_12x10 |
Compressed_SRGB8_Alpha8_ASTC_12x12 =>
Num_Components := 4;
Format := Pixels.RGBA;
when RGB10_A2 | RGBA12 | RGBA16 | RGBA32F | RGB32F | RGBA16F | RGB16F |
RGBA32UI | RGBA16UI | RGBA32I | RGBA16I | RGBA16_SNorm |
RGB10_A2UI | Compressed_RGBA_ASTC_10x5 |
Compressed_RGBA_ASTC_10x6 | Compressed_RGBA_ASTC_10x8 |
Compressed_RGBA_ASTC_10x10 | Compressed_RGBA_ASTC_12x10 |
Compressed_RGBA_ASTC_12x12 =>
Num_Components := 4;
Format := Pixels.RGBA;
Needs_Wide_Component := True;
end case;
if Needs_Wide_Component then
declare
package Impl is new Loader
(GL.Types.UShort, Num_Components, Width, Height);
use type Impl.Raw_Data_Access;
Data : Impl.Raw_Data_Access := null;
begin
Impl.To_Array (Descriptor, Data);
if not Texture.Initialized then
Texture.Initialize_Id;
end if;
Texture_2D.Bind (Texture);
Texture_2D.Load_From_Data (0, Texture_Format, Width, Height, Format,
Pixels.Unsigned_Short, Objects.Textures.Image_Source
(Data.all (Data.all'First)'Address));
Impl.Free_Data (Data);
exception when others =>
if Data /= null then
Impl.Free_Data (Data);
end if;
raise;
end;
else
declare
package Impl is new Loader
(GL.Types.UByte, Num_Components, Width, Height);
use type Impl.Raw_Data_Access;
Data : Impl.Raw_Data_Access := null;
begin
Impl.To_Array (Descriptor, Data);
if not Texture.Initialized then
Texture.Initialize_Id;
end if;
Texture_2D.Bind (Texture);
Texture_2D.Set_Minifying_Filter (GL.Objects.Textures.Linear);
Texture_2D.Set_Magnifying_Filter (GL.Objects.Textures.Linear);
GL.Pixels.Set_Unpack_Alignment (GL.Pixels.Bytes);
Texture_2D.Load_From_Data (0, Texture_Format, Width, Height, Format,
Pixels.Unsigned_Byte, Objects.Textures.Image_Source
(Data.all (Data.all'First)'Address));
Impl.Free_Data (Data);
exception when others =>
if Data /= null then
Impl.Free_Data (Data);
end if;
raise;
end;
end if;
end Load_Image_To_Texture;
procedure Load_File_To_Texture (
Path : String;
Texture : in out GL.Objects.Textures.Texture'Class;
Texture_Format : GL.Pixels.Internal_Format;
Try_TGA : Boolean := False) is
use Ada.Streams.Stream_IO;
Input_File : File_Type;
Input_Stream : Stream_Access;
begin
Ada.Streams.Stream_IO.Open (Input_File, In_File, Path);
Input_Stream := Stream (Input_File);
Load_Image_To_Texture
(Input_Stream.all, Texture, Texture_Format, Try_TGA);
Ada.Streams.Stream_IO.Close (Input_File);
end Load_File_To_Texture;
end GL.Images;
|
-- Copyright (C) 2019 Thierry Rascle <thierr26@free.fr>
-- MIT license. Please refer to the LICENSE file.
private with Apsepp.Debug_Trace_Class.Stub.Create;
package Apsepp.Debug_Trace_Class.Standard is
----------------------------------------------------------------------------
protected type Debug_Trace_Standard is new Debug_Trace_Interfa with
overriding
function Message_W_Entity (Message : String;
Entity_Name : String) return String;
overriding
function E_To_String (E : Exception_Occurrence) return String;
-- TODOC: Calls primitive Clock_String of
-- Apsepp.Debug_Trace_Class.Stub.Debug_Trace_Stub. So the reset
-- applies to all Debug_Trace_Interfa'Class objects with an
-- implementation relying on Reset_Date_Handler. <2019-06-29>
overriding
function Clock_String (Reset_Elapsed : Boolean := False) return String;
overriding
procedure Trace (Message : String; Entity_Name : String := "");
overriding
procedure Trace_E (E : Exception_Occurrence; Entity_Name : String := "");
-- TODOC: Calls primitive Set_Time_Zone of
-- Apsepp.Debug_Trace_Class.Stub.Debug_Trace_Stub so affects all
-- Debug_Trace_Interfa'Class objects with an implementation relying on
-- Reset_Date_Handler. <2019-06-29>
overriding
procedure Set_Time_Zone (Time_Zone : Time_Offset);
-- TODOC: Ditto. <2019-06-29>
overriding
procedure Set_Local_Time_Zone;
-- TODOC: CallsClock_String. So the reset applies to all
-- Debug_Trace_Interfa'Class objects with an implementation relying on
-- Reset_Date_Handler. <2019-06-29>
overriding
procedure Trace_Time (Entity_Name : String := "";
Reset_Elapsed : Boolean := False);
end Debug_Trace_Standard;
----------------------------------------------------------------------------
private
use Stub;
Debug_Trace_Stub_Instance : Debug_Trace_Stub := Create;
end Apsepp.Debug_Trace_Class.Standard;
|
-- protected_counters.adb
-- Task safe counters for use with smart_ptrs
-- Copyright (c) 2016, James Humphry
--
-- Permission to use, copy, modify, and/or distribute this software for any
-- purpose with or without fee is hereby granted, provided that the above
-- copyright notice and this permission notice appear in all copies.
--
-- THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
-- REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
-- AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
-- INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
-- LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
-- OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
-- PERFORMANCE OF THIS SOFTWARE.
pragma Profile (No_Implementation_Extensions);
with Ada.Unchecked_Deallocation;
package body Protected_Counters is
procedure Deallocate_Counter is new Ada.Unchecked_Deallocation
(Object => Counter,
Name => Counter_Ptr);
protected body Counter is
entry Lock when not Locked is
begin
Locked := True;
end Lock;
procedure Unlock is
begin
Locked := False;
end Unlock;
procedure Initialize_New_Counter is
begin
Locked := False;
SP_Count := 1;
WP_Count := 0;
end Initialize_New_Counter;
function Use_Count return Natural is
(SP_Count);
entry Check_Increment_Use_Count when not Locked is
begin
if SP_Count > 0 then
SP_Count := SP_Count + 1;
end if;
end Check_Increment_Use_Count;
entry Decrement_Use_Count when not Locked is
begin
SP_Count := SP_Count - 1;
end Decrement_Use_Count;
function Weak_Ptr_Count return Natural is
(WP_Count);
entry Increment_Weak_Ptr_Count when not Locked is
begin
WP_Count := WP_Count + 1;
end Increment_Weak_Ptr_Count;
entry Decrement_Weak_Ptr_Count when not Locked is
begin
WP_Count := WP_Count - 1;
end Decrement_Weak_Ptr_Count;
end Counter;
function Make_New_Counter return Counter_Ptr is
Result : constant Counter_Ptr := new Counter;
begin
Result.Initialize_New_Counter;
return Result;
end Make_New_Counter;
procedure Deallocate_If_Unused (C : in out Counter_Ptr) is
begin
C.Lock;
if C.Use_Count = 0 and C.Weak_Ptr_Count = 0 then
Deallocate_Counter(C);
else
C.Unlock;
end if;
end Deallocate_If_Unused;
procedure Check_Increment_Use_Count (C : in out Counter) is
begin
C.Check_Increment_Use_Count;
end Check_Increment_Use_Count;
procedure Decrement_Use_Count (C : in out Counter) is
begin
C.Decrement_Use_Count;
end Decrement_Use_Count;
procedure Increment_Weak_Ptr_Count (C : in out Counter) is
begin
C.Increment_Weak_Ptr_Count;
end Increment_Weak_Ptr_Count;
procedure Decrement_Weak_Ptr_Count (C : in out Counter) is
begin
C.Decrement_Weak_Ptr_Count;
end Decrement_Weak_Ptr_Count;
end Protected_Counters;
|
package ICE_Types is
type Float_View_T is private;
procedure Initialize (X : out Float_View_T);
private
type Float_View_T is new Float;
end;
|
-- Ascon.Utils
-- Some utility routines useful when writing the examples.
-- Copyright (c) 2016, James Humphry - see LICENSE file for details
generic
package Ascon.Utils is
procedure Put_State(S : in Ascon.State);
-- Print out a hexadecimal representation of the state to the console
procedure Put_Storage_Array(X : in Storage_Array);
-- Print out a hexadecimal representation of the storage array to the console
end Ascon.Utils;
|
------------------------------------------------------------------------------
-- 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 XASIS.Utils;
with Asis.Elements;
with Asis.Statements;
with Asis.Definitions;
with Asis.Declarations;
with Asis.Gela.Classes;
with Asis.Gela.Element_Utils;
package body Asis.Gela.Utils is
function Direct_Name (Name : Asis.Defining_Name) return Asis.Program_Text
renames XASIS.Utils.Direct_Name;
function Has_Name
(Element : Asis.Defining_Name;
Direct_Name : Asis.Program_Text) return Boolean
renames XASIS.Utils.Has_Name;
function Overloadable
(Element : Asis.Defining_Name) return Boolean
renames XASIS.Utils.Overloadable;
function Parent_Declaration
(Element : Asis.Element) return Asis.Declaration
renames XASIS.Utils.Parent_Declaration;
use Asis;
use Asis.Gela.Classes;
function Get_Parameter_Profile
(Def : Asis.Element)
return Asis.Parameter_Specification_List;
function Get_Result_Profile
(Def : Asis.Element;
Place : Asis.Element) return Type_Info;
function In_List
(List : Asis.Element_List;
Declaration : Asis.Declaration) return Boolean;
--------------------
-- Are_Homographs --
--------------------
function Are_Homographs
(Left : Asis.Defining_Name;
Right : Asis.Defining_Name;
Place : Asis.Element)
return Boolean
is
begin
pragma Assert (Elements.Element_Kind (Left) = A_Defining_Name and
Elements.Element_Kind (Right) = A_Defining_Name,
"Unexpected element in Direct_Name");
if Has_Name (Left, Direct_Name (Right)) then
if Overloadable (Left) and then Overloadable (Right) then
return Are_Type_Conformant (Left, Right, Place);
else
return True;
end if;
else
return False;
end if;
end Are_Homographs;
-------------------------
-- Are_Type_Conformant --
-------------------------
function Are_Type_Conformant
(Left : Asis.Element;
Right : Asis.Element;
Place : Asis.Element;
Right_Is_Prefixed_View : Boolean := False)
return Boolean
is
use Asis.Elements;
function Equal_Designated_Types (Left, Right : Type_Info) return Boolean
is
D_Left, D_Right : Type_Info;
begin
if not Is_Anonymous_Access (Left) or else
not Is_Anonymous_Access (Right) or else
(Is_Subprogram_Access (Left) xor Is_Subprogram_Access (Right))
then
return False;
end if;
if Is_Subprogram_Access (Left) then
return Destinated_Are_Type_Conformant (Left, Right);
else
D_Left := Destination_Type (Left);
D_Right := Destination_Type (Right);
return D_Left = D_Right;
end if;
end Equal_Designated_Types;
Left_Result : Type_Info := Get_Result_Profile (Left, Place);
Right_Result : Type_Info := Get_Result_Profile (Right, Place);
begin
if Is_Not_Type (Left_Result) and not Is_Not_Type (Right_Result) then
return False;
elsif not Is_Not_Type (Left_Result) and Is_Not_Type (Right_Result) then
return False;
elsif not Is_Not_Type (Left_Result)
and then not Is_Not_Type (Right_Result)
and then not Is_Equal (Left_Result, Right_Result)
and then not Equal_Designated_Types (Left_Result, Right_Result)
then
return False;
end if;
declare
use Asis.Declarations;
Left_Profile : Asis.Parameter_Specification_List :=
Get_Parameter_Profile (Left);
Right_Profile : Asis.Parameter_Specification_List :=
Get_Parameter_Profile (Right);
Left_Param : Asis.ASIS_Natural := 0;
Left_Names : Asis.ASIS_Natural := 0;
Right_Param : Asis.ASIS_Natural := 0;
Right_Names : Asis.ASIS_Integer := 0;
Exit_Loop : Boolean := False;
Left_Type : Type_Info;
Right_Type : Type_Info;
Left_Trait : Asis.Trait_Kinds;
Right_Trait : Asis.Trait_Kinds;
begin
if Right_Is_Prefixed_View then
Right_Names := -1;
end if;
loop
if Left_Names = 0 then
Left_Param := Left_Param + 1;
if Left_Param in Left_Profile'Range then
Left_Names := Names (Left_Profile (Left_Param))'Length;
Left_Trait := Trait_Kind (Left_Profile (Left_Param));
Left_Type :=
Type_Of_Declaration (Left_Profile (Left_Param), Place);
else
Exit_Loop := True;
end if;
end if;
while Right_Names <= 0 loop
Right_Param := Right_Param + 1;
if Right_Param in Right_Profile'Range then
Right_Names := Right_Names +
Names (Right_Profile (Right_Param))'Length;
Right_Trait := Trait_Kind (Right_Profile (Right_Param));
Right_Type :=
Type_Of_Declaration (Right_Profile (Right_Param), Place);
else
Exit_Loop := True;
exit;
end if;
end loop;
exit when Exit_Loop;
if Left_Trait /= Right_Trait then
return False;
end if;
if not Is_Equal (Left_Type, Right_Type) and then
not Equal_Designated_Types (Left_Type, Right_Type)
then
return False;
end if;
Left_Names := Left_Names - 1;
Right_Names := Right_Names - 1;
end loop;
if Left_Names = 0 and Right_Names = 0 then
return True;
else
return False;
end if;
end;
end Are_Type_Conformant;
---------------------------
-- Get_Parameter_Profile --
---------------------------
function Get_Parameter_Profile
(Def : Asis.Element)
return Asis.Parameter_Specification_List
is
use Asis.Elements;
use Asis.Definitions;
use Asis.Declarations;
Decl : Asis.Declaration := Enclosing_Element (Def);
Kind : Asis.Declaration_Kinds := Declaration_Kind (Decl);
Tipe : Asis.Definition;
begin
if Definition_Kind (Def) = An_Access_Definition then
return Access_To_Subprogram_Parameter_Profile (Def);
end if;
case Kind is
when A_Function_Declaration |
A_Procedure_Declaration |
A_Function_Body_Declaration |
A_Procedure_Body_Declaration |
A_Function_Body_Stub |
A_Procedure_Body_Stub |
A_Function_Renaming_Declaration |
A_Procedure_Renaming_Declaration |
An_Entry_Declaration |
A_Formal_Function_Declaration |
A_Formal_Procedure_Declaration =>
return Parameter_Profile (Decl);
when A_Generic_Function_Renaming_Declaration |
A_Generic_Procedure_Renaming_Declaration |
A_Function_Instantiation |
A_Procedure_Instantiation =>
declare
Unwind : constant Asis.Declaration :=
Corresponding_Declaration (Decl);
Name : constant Asis.Defining_Name_List := Names (Unwind);
begin
return Get_Parameter_Profile (Name (1));
end;
when An_Ordinary_Type_Declaration =>
Tipe := Type_Declaration_View (Decl);
case Access_Type_Kind (Tipe) is
when Access_To_Subprogram_Definition =>
return Access_To_Subprogram_Parameter_Profile (Tipe);
when others =>
return Nil_Element_List;
end case;
when A_Variable_Declaration |
A_Constant_Declaration |
A_Component_Declaration |
A_Discriminant_Specification |
A_Parameter_Specification |
A_Formal_Object_Declaration =>
declare
Def : constant Asis.Definition :=
Object_Declaration_Subtype (Decl);
begin
case Access_Definition_Kind (Def) is
when An_Anonymous_Access_To_Procedure |
An_Anonymous_Access_To_Protected_Procedure |
An_Anonymous_Access_To_Function |
An_Anonymous_Access_To_Protected_Function
=>
return Access_To_Subprogram_Parameter_Profile (Def);
when others =>
return Nil_Element_List;
end case;
end;
when Not_A_Declaration =>
if Statement_Kind (Decl) = An_Accept_Statement then
return Statements.Accept_Parameters (Decl);
else
return Nil_Element_List;
end if;
when others =>
return Nil_Element_List;
end case;
end Get_Parameter_Profile;
------------------------
-- Get_Result_Profile --
------------------------
function Get_Result_Profile
(Def : Asis.Element;
Place : Asis.Element)
return Type_Info
is
use Asis.Elements;
use Asis.Definitions;
use Asis.Declarations;
Decl : Asis.Declaration := Enclosing_Element (Def);
Kind : Asis.Declaration_Kinds := Declaration_Kind (Decl);
Tipe : Asis.Definition;
begin
if Definition_Kind (Def) = An_Access_Definition then
if Access_Definition_Kind (Def) in An_Anonymous_Access_To_Function ..
An_Anonymous_Access_To_Protected_Function
then
return Type_From_Indication
(Access_To_Function_Result_Subtype (Def), Place);
else
return Not_A_Type;
end if;
end if;
case Kind is
when A_Function_Declaration |
A_Function_Body_Declaration |
A_Function_Body_Stub |
A_Function_Renaming_Declaration |
A_Generic_Function_Declaration |
A_Formal_Function_Declaration =>
return Type_From_Indication (Result_Subtype (Decl), Place);
when An_Enumeration_Literal_Specification =>
return Type_Of_Declaration (Decl, Place);
when A_Generic_Function_Renaming_Declaration |
A_Function_Instantiation =>
declare
Unwind : constant Asis.Declaration :=
Corresponding_Declaration (Decl);
Name : constant Asis.Defining_Name_List := Names (Unwind);
begin
return Get_Result_Profile (Name (1), Place);
end;
when An_Ordinary_Type_Declaration =>
Tipe := Type_Declaration_View (Decl);
case Access_Type_Kind (Tipe) is
when An_Access_To_Function | An_Access_To_Protected_Function =>
return Type_From_Indication
(Access_To_Function_Result_Subtype (Tipe), Place);
when others =>
return Not_A_Type;
end case;
when A_Variable_Declaration |
A_Constant_Declaration |
A_Component_Declaration |
A_Discriminant_Specification |
A_Parameter_Specification |
A_Formal_Object_Declaration =>
declare
Def : constant Asis.Definition :=
Object_Declaration_Subtype (Decl);
begin
case Access_Definition_Kind (Def) is
when An_Anonymous_Access_To_Function |
An_Anonymous_Access_To_Protected_Function =>
return Type_From_Indication
(Access_To_Function_Result_Subtype (Def), Place);
when others =>
return Not_A_Type;
end case;
end;
when others =>
return Not_A_Type;
end case;
end Get_Result_Profile;
-------------
-- In_List --
-------------
function In_List
(List : Asis.Element_List;
Declaration : Asis.Declaration) return Boolean is
begin
for I in List'Range loop
if Asis.Elements.Is_Equal (List (I), Declaration) then
return True;
end if;
end loop;
return False;
end In_List;
-----------------------
-- In_Context_Clause --
-----------------------
function In_Context_Clause (Clause : Asis.Clause) return Boolean is
use Asis.Elements;
Unit : Asis.Compilation_Unit := Enclosing_Compilation_Unit (Clause);
List : Asis.Element_List := Context_Clause_Elements (Unit);
begin
return In_List (List, Clause);
end In_Context_Clause;
---------------------
-- In_Visible_Part --
---------------------
function In_Visible_Part
(Declaration : Asis.Declaration) return Boolean
is
use Asis;
use Asis.Elements;
use Asis.Declarations;
use Asis.Definitions;
Parent : Asis.Declaration := Parent_Declaration (Declaration);
Parent_Kind : Asis.Declaration_Kinds := Declaration_Kind (Parent);
Decl_Kind : Asis.Declaration_Kinds := Declaration_Kind (Declaration);
Expr : Asis.Expression;
begin
case Parent_Kind is
when Asis.A_Procedure_Declaration |
Asis.A_Function_Declaration |
Asis.A_Procedure_Body_Declaration |
Asis.A_Function_Body_Declaration |
Asis.A_Procedure_Renaming_Declaration |
Asis.A_Function_Renaming_Declaration |
Asis.An_Entry_Declaration =>
return Decl_Kind = Asis.A_Parameter_Specification;
when Asis.An_Ordinary_Type_Declaration =>
return Decl_Kind = Asis.A_Discriminant_Specification or
Decl_Kind = Asis.A_Component_Declaration or
Decl_Kind = Asis.An_Enumeration_Literal_Specification;
when Asis.A_Generic_Function_Declaration |
Asis.A_Generic_Procedure_Declaration =>
return In_List (Generic_Formal_Part (Parent), Declaration) or
Decl_Kind = Asis.A_Parameter_Specification;
when Asis.A_Generic_Package_Declaration =>
return In_List (Generic_Formal_Part (Parent), Declaration) or
In_List (Visible_Part_Declarative_Items (Parent), Declaration);
when Asis.A_Package_Declaration =>
if Is_Part_Of_Instance (Parent) then
if Decl_Kind in A_Formal_Declaration then
Expr := Element_Utils.Generic_Actual (Declaration);
if Expression_Kind (Expr) = A_Box_Expression then
return True;
end if;
end if;
end if;
return In_List
(Visible_Part_Declarative_Items (Parent), Declaration);
when Asis.A_Single_Task_Declaration |
Asis.A_Single_Protected_Declaration =>
declare
Def : Asis.Definition := Object_Declaration_View (Parent);
begin
return In_List (Visible_Part_Items (Def), Declaration);
end;
when Asis.A_Task_Type_Declaration |
Asis.A_Protected_Type_Declaration =>
declare
Def : Asis.Definition := Type_Declaration_View (Parent);
D : Asis.Definition := Discriminant_Part (Parent);
begin
return In_List (Visible_Part_Items (Def), Declaration) or else
(Definition_Kind (D) = A_Known_Discriminant_Part and then
In_List (Discriminants (D), Declaration));
end;
when others =>
return False;
end case;
end In_Visible_Part;
---------------------
-- Is_Limited_Type --
---------------------
function Is_Limited_Type (Tipe : Asis.Definition) return Boolean is
use Asis.Elements;
begin
case Definition_Kind (Tipe) is
when A_Private_Type_Definition |
A_Tagged_Private_Type_Definition
=>
return Has_Limited (Tipe);
when others =>
null;
end case;
case Type_Kind (Tipe) is
when A_Derived_Type_Definition |
A_Derived_Record_Extension_Definition |
A_Record_Type_Definition |
A_Tagged_Record_Type_Definition
=>
case Trait_Kind (Tipe) is
when A_Limited_Trait |
A_Limited_Private_Trait |
An_Abstract_Limited_Trait |
An_Abstract_Limited_Private_Trait =>
return True;
when others =>
return False;
end case;
when An_Interface_Type_Definition =>
return Interface_Kind (Tipe) /= An_Ordinary_Interface;
when others =>
null;
end case;
case Formal_Type_Kind (Tipe) is
when A_Formal_Private_Type_Definition |
A_Formal_Tagged_Private_Type_Definition =>
case Trait_Kind (Tipe) is
when A_Limited_Trait |
A_Limited_Private_Trait |
An_Abstract_Limited_Trait |
An_Abstract_Limited_Private_Trait =>
return True;
when others =>
return False;
end case;
when A_Formal_Interface_Type_Definition =>
return Interface_Kind (Tipe) /= An_Ordinary_Interface;
when others =>
null;
end case;
return False;
end Is_Limited_Type;
---------------------
-- Walk_Components --
---------------------
procedure Walk_Components
(Item : Asis.Element;
Continue : out Boolean)
is
use Asis.Elements;
use Asis.Declarations;
use Asis.Definitions;
Walk_Error : exception;
begin
case Element_Kind (Item) is
-- when An_Expression =>
-- Walk_Components (To_Type (Item).Declaration, Continue);
when A_Declaration =>
case Declaration_Kind (Item) is
when An_Incomplete_Type_Declaration =>
declare
Discr : Asis.Element := Discriminant_Part (Item);
begin
if not Is_Nil (Discr) then
Walk_Components (Discr, Continue);
if not Continue then
return;
end if;
end if;
end;
when An_Ordinary_Type_Declaration
| A_Task_Type_Declaration
| A_Protected_Type_Declaration
| A_Private_Type_Declaration
| A_Private_Extension_Declaration
| A_Formal_Type_Declaration =>
declare
Discr : Asis.Element := Discriminant_Part (Item);
View : Asis.Element := Type_Declaration_View (Item);
begin
if not Is_Nil (Discr) then
Walk_Components (Discr, Continue);
if not Continue then
return;
end if;
end if;
Walk_Components (View, Continue);
end;
when A_Discriminant_Specification | A_Component_Declaration =>
Walk_Component (Item, Continue);
when others =>
raise Walk_Error;
end case;
when A_Definition =>
case Definition_Kind (Item) is
when A_Subtype_Indication =>
declare
-- Get type view and walk it's declaration
Def : constant Asis.Definition :=
Get_Type_Def (Type_From_Indication (Item, Place));
begin
Walk_Components
(Enclosing_Element (Def),
Continue);
end;
when A_Type_Definition =>
case Type_Kind (Item) is
when A_Derived_Record_Extension_Definition =>
Walk_Components
(Asis.Definitions.Parent_Subtype_Indication (Item),
Continue);
if not Continue then
return;
end if;
Walk_Components
(Asis.Definitions.Record_Definition (Item),
Continue);
when A_Derived_Type_Definition =>
Walk_Components
(Asis.Definitions.Parent_Subtype_Indication (Item),
Continue);
when A_Record_Type_Definition |
A_Tagged_Record_Type_Definition =>
Walk_Components
(Asis.Definitions.Record_Definition (Item),
Continue);
when An_Interface_Type_Definition =>
Continue := True;
when others =>
raise Walk_Error;
end case;
when A_Record_Definition | A_Variant =>
if Definition_Kind (Item) = A_Variant then
Walk_Variant (Item, Continue);
if not Continue then
Continue := True;
return;
end if;
end if;
declare
List : Asis.Record_Component_List :=
Record_Components (Item);
begin
for I in List'Range loop
case Element_Kind (List (I)) is
when A_Declaration | A_Definition =>
Walk_Components (List (I), Continue);
when others =>
raise Walk_Error;
end case;
if not Continue then
return;
end if;
end loop;
end;
when A_Variant_Part =>
declare
List : Asis.Variant_List := Variants (Item);
begin
for I in List'Range loop
Walk_Components (List (I), Continue);
if not Continue then
return;
end if;
end loop;
end;
when A_Known_Discriminant_Part =>
declare
List : Asis.Discriminant_Specification_List :=
Discriminants (Item);
begin
for I in List'Range loop
Walk_Components (List (I), Continue);
if not Continue then
return;
end if;
end loop;
end;
when A_Null_Record_Definition
| A_Null_Component
| A_Private_Type_Definition
| A_Tagged_Private_Type_Definition
| A_Private_Extension_Definition
| A_Task_Definition
| A_Protected_Definition
| A_Formal_Type_Definition
| An_Unknown_Discriminant_Part
=>
Continue := True;
when others =>
raise Walk_Error;
end case;
when others =>
raise Walk_Error;
end case;
end Walk_Components;
end Asis.Gela.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.
------------------------------------------------------------------------------
|
with Ada.Text_IO; use Ada.Text_IO;
procedure Zebra is
type Content is (Beer, Coffee, Milk, Tea, Water,
Danish, English, German, Norwegian, Swedish,
Blue, Green, Red, White, Yellow,
Blend, BlueMaster, Dunhill, PallMall, Prince,
Bird, Cat, Dog, Horse, Zebra);
type Test is (Drink, Person, Color, Smoke, Pet);
type House is (One, Two, Three, Four, Five);
type Street is array (Test'Range, House'Range) of Content;
type Alley is access all Street;
procedure Print (mat : Alley) is begin
for H in House'Range loop
Put(H'Img&": ");
for T in Test'Range loop
Put(T'Img&"="&mat(T,H)'Img&" ");
end loop; New_Line; end loop;
end Print;
function FinalChecks (mat : Alley) return Boolean is
function Diff (A, B : Content; CA , CB : Test) return Integer is begin
for H1 in House'Range loop for H2 in House'Range loop
if mat(CA,H1) = A and mat(CB,H2) = B then
return House'Pos(H1) - House'Pos(H2);
end if;
end loop; end loop;
end Diff;
begin
if abs(Diff(Norwegian, Blue, Person, Color)) = 1
and Diff(Green, White, Color, Color) = -1
and abs(Diff(Horse, Dunhill, Pet, Smoke)) = 1
and abs(Diff(Water, Blend, Drink, Smoke)) = 1
and abs(Diff(Blend, Cat, Smoke, Pet)) = 1
then return True;
end if;
return False;
end FinalChecks;
function Constrained (mat : Alley; atest : Natural) return Boolean is begin
-- Tests seperated into levels for speed, not strictly necessary
-- As such, the program finishes in around ~0.02s
case Test'Val (atest) is
when Drink => -- Drink
if mat (Drink, Three) /= Milk then return False; end if;
return True;
when Person => -- Drink+Person
for H in House'Range loop
if (mat(Person,H) = Norwegian and H /= One)
or (mat(Person,H) = Danish and mat(Drink,H) /= Tea)
then return False; end if;
end loop;
return True;
when Color => -- Drink+People+Color
for H in House'Range loop
if (mat(Person,H) = English and mat(Color,H) /= Red)
or (mat(Drink,H) = Coffee and mat(Color,H) /= Green)
then return False; end if;
end loop;
return True;
when Smoke => -- Drink+People+Color+Smoke
for H in House'Range loop
if (mat(Color,H) = Yellow and mat(Smoke,H) /= Dunhill)
or (mat(Smoke,H) = BlueMaster and mat(Drink,H) /= Beer)
or (mat(Person,H) = German and mat(Smoke,H) /= Prince)
then return False; end if;
end loop;
return True;
when Pet => -- Drink+People+Color+Smoke+Pet
for H in House'Range loop
if (mat(Person,H) = Swedish and mat(Pet,H) /= Dog)
or (mat(Smoke,H) = PallMall and mat(Pet,H) /= Bird)
then return False; end if;
end loop;
return FinalChecks(mat); -- Do the next-to checks
end case;
end Constrained;
procedure Solve (mat : Alley; t, n : Natural) is
procedure Swap (I, J : Natural) is
temp : constant Content := mat (Test'Val (t), House'Val (J));
begin
mat (Test'Val (t), House'Val (J)) := mat (Test'Val (t), House'Val (I));
mat (Test'Val (t), House'Val (I)) := temp;
end Swap;
begin
if n = 1 and Constrained (mat, t) then -- test t passed
if t < 4 then Solve (mat, t + 1, 5); -- Onto next test
else Print (mat); return; -- Passed and t=4 means a solution
end if;
end if;
for i in 0 .. n - 1 loop -- The permutations part
Solve (mat, t, n - 1);
if n mod 2 = 1 then Swap (0, n - 1);
else Swap (i, n - 1); end if;
end loop;
end Solve;
myStreet : aliased Street;
myAlley : constant Alley := myStreet'Access;
begin
for i in Test'Range loop for j in House'Range loop -- Init Matrix
myStreet (i,j) := Content'Val(Test'Pos(i)*5 + House'Pos(j));
end loop; end loop;
Solve (myAlley, 0, 5); -- start at test 0 with 5 options
end Zebra;
|
with Interfaces;
with Startup;
with MSPGD.GPIO; use MSPGD.GPIO;
with MSPGD.GPIO.Pin;
with MSPGD.UART.Peripheral;
with MSPGD.SPI.Peripheral;
with MSPGD.Clock; use MSPGD.Clock;
with MSPGD.Clock.Source;
package MSPGD.Board is
pragma Preelaborate;
package Clock is new MSPGD.Clock.Source (Source => SMCLK, Input => DCO, Frequency => 8_000_000);
package LED is new MSPGD.GPIO.Pin (Port => 2, Pin => 5, Direction => Output);
package LED2 is new MSPGD.GPIO.Pin (Port => 1, Pin => 3, Direction => Output);
package RX is new MSPGD.GPIO.Pin (Port => 1, Pin => 1, Alt_Func => Secondary);
package TX is new MSPGD.GPIO.Pin (Port => 1, Pin => 2, Alt_Func => Secondary);
package SCLK is new MSPGD.GPIO.Pin (Port => 1, Pin => 5, Alt_Func => Secondary);
package MISO is new MSPGD.GPIO.Pin (Port => 1, Pin => 6, Alt_Func => Secondary);
package MOSI is new MSPGD.GPIO.Pin (Port => 1, Pin => 7, Alt_Func => Secondary);
package SSEL is new MSPGD.GPIO.Pin (Port => 2, Pin => 1, Direction => Output);
package MODEM_RST is new MSPGD.GPIO.Pin (Port => 2, Pin => 0, Direction => Output);
package IRQ is new MSPGD.GPIO.Pin (Port => 2, Pin => 2);
package BUTTON is new MSPGD.GPIO.Pin (Port => 2, Pin => 7);
package TEMP_NTC is new MSPGD.GPIO.Pin (Port => 1, Pin => 0);
package TEMP_REF is new MSPGD.GPIO.Pin (Port => 1, Pin => 4);
package UART is new MSPGD.UART.Peripheral (Speed => 9600, Clock => Clock);
package SPI is new MSPGD.SPI.Peripheral (Module => MSPGD.SPI.USCI_B, Speed => 4_000_000, Clock => Clock);
procedure Init;
procedure Power_Up;
procedure Power_Down;
function Read_NTC return Unsigned_16;
function Read_VCC return Unsigned_16;
end MSPGD.Board;
|
-- Abstract:
--
-- Generic leading zero unsigned decimal image
--
-- Copyright (C) 2004, 2009, 2019 Free Software Foundation. All Rights Reserved.
--
-- This library is free software; you can redistribute it and/or
-- modify it under terms of the GNU General Public License as
-- published by the Free Software Foundation; either version 3, or (at
-- your option) any later version. This library is distributed in the
-- hope that it will be useful, but WITHOUT ANY WARRANTY; without even
-- the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
-- PURPOSE. See the GNU General Public License for more details. You
-- should have received a copy of the GNU General Public License
-- distributed with this program; see file COPYING. If not, write to
-- the Free Software Foundation, 59 Temple Place - Suite 330, Boston,
-- MA 02111-1307, USA.
--
-- As a special exception, if other files instantiate generics from
-- this unit, or you link this unit with other files to produce an
-- executable, this unit does not by itself cause the resulting
-- executable to be covered by the GNU General Public License. This
-- exception does not however invalidate any other reasons why the
-- executable file might be covered by the GNU Public License.
pragma License (Modified_GPL);
generic
type Number_Type is range <>;
function SAL.Generic_Decimal_Image
(Item : in Number_Type;
Width : in Natural)
return String;
-- Return a decimal unsigned image of Item, padded with leading zeros
-- to Width. If Width is too small for Item, leading digits are
-- silently truncated.
pragma Pure (SAL.Generic_Decimal_Image);
|
pragma License (Unrestricted);
-- implementation unit specialized for Darwin (or Linux, or Windows)
package System.Long_Long_Complex_Types is
pragma Pure;
-- Complex
type Imaginary is new Float;
type Complex is record
Re, Im : Float;
end record;
pragma Complex_Representation (Complex);
-- Long_Complex
type Long_Imaginary is new Long_Float;
type Long_Complex is record
Re, Im : Long_Float;
end record;
pragma Complex_Representation (Long_Complex);
-- Long_Long_Complex
type Long_Long_Imaginary is new Long_Long_Float;
type Long_Long_Complex is record
Re, Im : Long_Long_Float;
end record;
pragma Complex_Representation (Long_Long_Complex);
end System.Long_Long_Complex_Types;
|
with Ada.Text_IO;
procedure Odd_Word_Problem is
use Ada.Text_IO; -- Get, Put, and Look_Ahead
function Current return Character is
-- reads the current input character, without consuming it
End_Of_Line: Boolean;
C: Character;
begin
Look_Ahead(C, End_Of_Line);
if End_Of_Line then
raise Constraint_Error with "end of line before the terminating '.'";
end if;
return C;
end Current;
procedure Skip is
-- consumes the current input character
C: Character;
begin
Get(C);
end Skip;
function Is_Alpha(Ch: Character) return Boolean is
begin
return (Ch in 'a' .. 'z') or (Ch in 'A' .. 'Z');
end Is_Alpha;
procedure Odd_Word(C: Character) is
begin
if Is_Alpha(C) then
Skip;
Odd_Word(Current);
Put(C);
end if;
end Odd_Word;
begin -- Odd_Word_Problem
Put(Current);
while Is_Alpha(Current) loop -- read an even word
Skip;
Put(Current);
end loop;
if Current /= '.' then -- read an odd word
Skip;
Odd_Word(Current);
Put(Current);
if Current /= '.' then -- read the remaining words
Skip;
Odd_Word_Problem;
end if;
end if;
end Odd_Word_Problem;
|
------------------------------------------------------------------------------
-- --
-- GNU ADA RUNTIME LIBRARY (GNARL) COMPONENTS --
-- --
-- I N T E R F A C E S . C . P T H R E A D S --
-- --
-- S p e c --
-- --
-- $Revision: 2 $ --
-- --
-- Copyright (c) 1991,1992,1993,1994, FSU, All Rights Reserved --
-- --
-- GNARL is free software; you can redistribute it and/or modify it under --
-- terms of the GNU Library General Public License as published by the --
-- Free Software Foundation; either version 2, or (at your option) any --
-- later version. GNARL is distributed in the hope that it will be use- --
-- ful, but but WITHOUT ANY WARRANTY; without even the implied warranty of --
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Gen- --
-- eral Library Public License for more details. You should have received --
-- a copy of the GNU Library General Public License along with GNARL; see --
-- file COPYING.LIB. If not, write to the Free Software Foundation, 675 --
-- Mass Ave, Cambridge, MA 02139, USA. --
-- --
------------------------------------------------------------------------------
-- This package interfaces with Pthreads. It is not a complete interface;
-- it only includes what is needed to implement the Ada runtime.
with System;
with Interfaces.C.System_Constants;
-- Used for, Add_Prio
-- pthread_attr_t_size
-- pthread_mutexattr_t_size
-- pthread_mutex_t_size
-- pthread_condattr_t_size
-- pthread_cond_t_size
-- NO_PRIO_INHERIT
-- PRIO_INHERIT
-- PRIO_PROTECT
with Interfaces.C.POSIX_RTE;
-- Used for, Signal,
-- Signal_Set
with Interfaces.C.POSIX_Error; use Interfaces.C.POSIX_Error;
-- Used for, Return_Code
with Interfaces.C.POSIX_Timers;
-- Used for, timespec
package Interfaces.C.Pthreads is
Alignment : constant := Natural'Min (16, 8);
Pthreads_Error : exception;
type Priority_Type is new int;
type pthread_t is private;
type pthread_mutex_t is private;
type pthread_cond_t is private;
type pthread_attr_t is private;
type pthread_mutexattr_t is private;
type pthread_condattr_t is private;
type pthread_key_t is private;
type pthread_protocol_t is private;
NO_PRIO_INHERIT : constant pthread_protocol_t;
PRIO_INHERIT : constant pthread_protocol_t;
PRIO_PROTECT : constant pthread_protocol_t;
procedure pthread_attr_init
(attributes : out pthread_attr_t;
result : out Return_Code);
pragma Inline (pthread_attr_init);
procedure pthread_attr_destroy
(attributes : in out pthread_attr_t;
result : out Return_Code);
pragma Inline (pthread_attr_destroy);
procedure pthread_attr_setstacksize
(attr : in out pthread_attr_t;
stacksize : size_t;
result : out Return_Code);
pragma Inline (pthread_attr_setstacksize);
procedure pthread_attr_setdetachstate
(attr : in out pthread_attr_t;
detachstate : int;
Result : out Return_Code);
pragma Inline (pthread_attr_setdetachstate);
procedure pthread_create
(thread : out pthread_t;
attributes : pthread_attr_t;
start_routine : System.Address;
arg : System.Address;
result : out Return_Code);
pragma Inline (pthread_create);
procedure pthread_init;
function pthread_self return pthread_t;
pragma Inline (pthread_self);
procedure pthread_detach
(thread : in out pthread_t;
result : out Return_Code);
pragma Inline (pthread_detach);
procedure pthread_mutexattr_init
(attributes : out pthread_mutexattr_t;
result : out Return_Code);
pragma Inline (pthread_mutexattr_init);
procedure pthread_mutexattr_setprotocol
(attributes : in out pthread_mutexattr_t;
protocol : pthread_protocol_t;
result : out Return_Code);
pragma Inline (pthread_mutexattr_setprotocol);
procedure pthread_mutexattr_setprio_ceiling
(attributes : in out pthread_mutexattr_t;
prio_ceiling : int;
result : out Return_Code);
pragma Inline (pthread_mutexattr_setprio_ceiling);
procedure pthread_mutex_init
(mutex : out pthread_mutex_t;
attributes : pthread_mutexattr_t;
result : out Return_Code);
pragma Inline (pthread_mutex_init);
procedure pthread_mutex_destroy
(mutex : in out pthread_mutex_t;
result : out Return_Code);
pragma Inline (pthread_mutex_destroy);
procedure pthread_mutex_trylock
(mutex : in out pthread_mutex_t;
result : out Return_Code);
pragma Inline (pthread_mutex_trylock);
procedure pthread_mutex_lock
(mutex : in out pthread_mutex_t;
result : out Return_Code);
pragma Inline (pthread_mutex_lock);
procedure pthread_mutex_unlock
(mutex : in out pthread_mutex_t;
result : out Return_Code);
pragma Inline (pthread_mutex_unlock);
procedure pthread_cond_init
(condition : out pthread_cond_t;
attributes : pthread_condattr_t;
result : out Return_Code);
pragma Inline (pthread_cond_init);
procedure pthread_cond_wait
(condition : in out pthread_cond_t;
mutex : in out pthread_mutex_t;
result : out Return_Code);
pragma Inline (pthread_cond_wait);
procedure pthread_cond_timedwait
(condition : in out pthread_cond_t;
mutex : in out pthread_mutex_t;
absolute_time : Interfaces.C.POSIX_Timers.timespec;
result : out Return_Code);
pragma Inline (pthread_cond_timedwait);
procedure pthread_cond_signal
(condition : in out pthread_cond_t;
result : out Return_Code);
pragma Inline (pthread_cond_signal);
procedure pthread_cond_broadcast
(condition : in out pthread_cond_t;
result : out Return_Code);
pragma Inline (pthread_cond_broadcast);
procedure pthread_cond_destroy
(condition : in out pthread_cond_t;
result : out Return_Code);
pragma Inline (pthread_cond_destroy);
procedure pthread_condattr_init
(attributes : out pthread_condattr_t;
result : out Return_Code);
pragma Inline (pthread_condattr_init);
procedure pthread_condattr_destroy
(attributes : in out pthread_condattr_t;
result : out Return_Code);
pragma Inline (pthread_condattr_destroy);
procedure pthread_setspecific
(key : pthread_key_t;
value : System.Address;
result : out Return_Code);
pragma Inline (pthread_setspecific);
procedure pthread_getspecific
(key : pthread_key_t;
value : out System.Address;
result : out Return_Code);
pragma Inline (pthread_getspecific);
procedure pthread_key_create
(key : out pthread_key_t;
destructor : System.Address;
result : out Return_Code);
pragma Inline (pthread_key_create);
procedure pthread_attr_setprio
(attr : in out pthread_attr_t;
priority : Priority_Type;
result : out Return_Code);
pragma Inline (pthread_attr_setprio);
procedure pthread_attr_getprio
(attr : pthread_attr_t;
priority : out Priority_Type;
result : out Return_Code);
pragma Inline (pthread_attr_getprio);
procedure pthread_setschedattr
(thread : pthread_t;
attributes : pthread_attr_t;
result : out Return_Code);
pragma Inline (pthread_setschedattr);
procedure pthread_getschedattr
(thread : pthread_t;
attributes : out pthread_attr_t;
result : out Return_Code);
pragma Inline (pthread_getschedattr);
procedure pthread_exit (status : System.Address);
pragma Interface (C, pthread_exit);
pragma Interface_Name (pthread_exit, "pthread_exit");
procedure sigwait
(set : Interfaces.C.POSIX_RTE.Signal_Set;
sig : out Interfaces.C.POSIX_RTE.Signal;
result : out Return_Code);
pragma Inline (sigwait);
procedure pthread_kill
(thread : pthread_t; sig : Interfaces.C.POSIX_RTE.Signal;
result : out Return_Code);
pragma Inline (pthread_kill);
procedure pthread_cleanup_push
(routine : System.Address;
arg : System.Address);
pragma Inline (pthread_cleanup_push);
procedure pthread_cleanup_pop (execute : int);
pragma Inline (pthread_cleanup_pop);
procedure pthread_yield;
pragma Inline (pthread_yield);
private
-- The use of longword alignment for the following C types is
-- a stopgap measure which is not generally portable. A portable
-- solution will require some means of getting alignment information
-- from the C compiler.
type pthread_attr_t is
array (1 .. System_Constants.pthread_attr_t_size) of unsigned;
for pthread_attr_t'Alignment use Alignment;
type pthread_mutexattr_t is
array (1 .. System_Constants.pthread_mutexattr_t_size) of unsigned;
for pthread_mutexattr_t'Alignment use Alignment;
type pthread_mutex_t is
array (1 .. System_Constants.pthread_mutex_t_size) of unsigned;
for pthread_mutex_t'Alignment use Alignment;
type pthread_condattr_t is
array (1 .. System_Constants.pthread_condattr_t_size) of unsigned;
for pthread_condattr_t'Alignment use Alignment;
type pthread_cond_t is
array (1 .. System_Constants.pthread_cond_t_size) of unsigned;
for pthread_cond_t'Alignment use Alignment;
-- type pthread_t is
-- array (1 .. System_Constants.pthread_t_size) of unsigned;
type pthread_t is new unsigned;
-- ??? The use of an array here (of one element, usually) seems to cause
-- problems in the compiler. It put a long word 4 in the
-- instruction stream of Interfaces.C.Pthreads.pthread_self. This
-- is obviously meant to provide some clue as to what size
-- item it is to return, but pthread_self tried to execute it.
type pthread_key_t is new unsigned;
-- This type is passed as a scaler into a C function. It must
-- be declared as a scaler, not an array. This being so, an unsigned
-- should work.
type pthread_protocol_t is new int;
NO_PRIO_INHERIT : constant pthread_protocol_t :=
System_Constants.NO_PRIO_INHERIT;
PRIO_INHERIT : constant pthread_protocol_t :=
System_Constants.PRIO_INHERIT;
PRIO_PROTECT : constant pthread_protocol_t :=
System_Constants.PRIO_PROTECT;
end Interfaces.C.Pthreads;
|
------------------------------------------------------------------------------
-- --
-- GNAT RUN-TIME COMPONENTS --
-- --
-- S Y S T E M . D I M . F L O A T _ I O --
-- --
-- S p e c --
-- --
-- Copyright (C) 2011-2012, 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. --
-- --
------------------------------------------------------------------------------
-- This package provides output routines for float dimensioned types. All Put
-- routines are modelled after those in package Ada.Text_IO.Float_IO with the
-- addition of an extra default parameter.
-- Parameter Symbol may be used in the following manner (all the examples are
-- based on the MKS system of units as defined in package System.Dim.Mks):
-- Case 1. A value is supplied for Symbol
-- The string appears as a suffix of Item
-- Obj : Mks_Type := 2.6;
-- Put (Obj, 1, 1, 0, " dimensionless");
-- The corresponding output is: 2.6 dimensionless
-- Case 2. No value is supplied for Symbol and Item is dimensionless
-- Item appears without a suffix
-- Obj : Mks_Type := 2.6;
-- Put (Obj, 1, 1, 0);
-- The corresponding output is: 2.6
-- Case 3. No value is supplied for Symbol and Item has a dimension
-- If the type of Item is a dimensioned subtype whose symbolic name is not
-- empty, then the symbolic name appears as a suffix.
-- subtype Length is Mks_Type
-- with
-- Dimension => ('m',
-- Meter => 1,
-- others => 0);
-- Obj : Length := 2.3 * dm;
-- Put (Obj, 1, 2, 0);
-- The corresponding output is: 0.23 m
-- Otherwise, a new string is created and appears as a suffix of Item.
-- This string results in the successive concatanations between each
-- dimension symbolic name raised by its corresponding dimension power from
-- the dimensions of Item.
-- subtype Random is Mks_Type
-- with
-- Dimension => ("",
-- Meter => 3,
-- Candela => -1,
-- others => 0);
-- Obj : Random := 5.0;
-- Put (Obj);
-- The corresponding output is: 5.0 m**3.cd**(-1)
-- Put (3.3 * km * dm * min, 5, 1, 0);
-- The corresponding output is: 19800.0 m**2.s
with Ada.Text_IO; use Ada.Text_IO;
generic
type Num_Dim_Float is digits <>;
package System.Dim.Float_IO is
Default_Fore : Field := 2;
Default_Aft : Field := Num_Dim_Float'Digits - 1;
Default_Exp : Field := 3;
procedure Put
(File : File_Type;
Item : Num_Dim_Float;
Fore : Field := Default_Fore;
Aft : Field := Default_Aft;
Exp : Field := Default_Exp;
Symbols : String := "");
procedure Put
(Item : Num_Dim_Float;
Fore : Field := Default_Fore;
Aft : Field := Default_Aft;
Exp : Field := Default_Exp;
Symbols : String := "");
procedure Put
(To : out String;
Item : Num_Dim_Float;
Aft : Field := Default_Aft;
Exp : Field := Default_Exp;
Symbols : String := "");
pragma Inline (Put);
end System.Dim.Float_IO;
|
------------------------------------------------------------------------------
-- --
-- GNAT RUN-TIME COMPONENTS --
-- --
-- A D A . W I D E _ W I D E _ C H A R A C T E R S . H A N D L I N G --
-- --
-- S p e c --
-- --
-- This specification is derived from the Ada Reference Manual for use with --
-- GNAT. In accordance with the copyright of that document, you can freely --
-- copy and modify this specification, provided that if you redistribute a --
-- modified version, any changes that you have made are clearly indicated. --
-- --
------------------------------------------------------------------------------
package Ada.Wide_Wide_Characters.Handling is
pragma Pure;
-- This package is clearly intended to be Pure, by analogy with the
-- base Ada.Characters.Handling package. The version in the RM does
-- not yet have this pragma, but that is a clear omission. This will
-- be fixed in a future version of AI05-0266-1.
function Is_Control (Item : Wide_Wide_Character) return Boolean;
pragma Inline (Is_Control);
-- Returns True if the Wide_Wide_Character designated by Item is
-- categorized as other_control, otherwise returns false.
function Is_Letter (Item : Wide_Wide_Character) return Boolean;
pragma Inline (Is_Letter);
-- Returns True if the Wide_Wide_Character designated by Item is
-- categorized as letter_uppercase, letter_lowercase, letter_titlecase,
-- letter_modifier, letter_other, or number_letter. Otherwise returns
-- false.
function Is_Lower (Item : Wide_Wide_Character) return Boolean;
pragma Inline (Is_Lower);
-- Returns True if the Wide_Wide_Character designated by Item is
-- categorized as letter_lowercase, otherwise returns false.
function Is_Upper (Item : Wide_Wide_Character) return Boolean;
pragma Inline (Is_Upper);
-- Returns True if the Wide_Wide_Character designated by Item is
-- categorized as letter_uppercase, otherwise returns false.
function Is_Digit (Item : Wide_Wide_Character) return Boolean;
pragma Inline (Is_Digit);
-- Returns True if the Wide_Wide_Character designated by Item is
-- categorized as number_decimal, otherwise returns false.
function Is_Decimal_Digit (Item : Wide_Wide_Character) return Boolean
renames Is_Digit;
function Is_Hexadecimal_Digit (Item : Wide_Wide_Character) return Boolean;
-- Returns True if the Wide_Wide_Character designated by Item is
-- categorized as number_decimal, or is in the range 'A' .. 'F' or
-- 'a' .. 'f', otherwise returns false.
function Is_Alphanumeric (Item : Wide_Wide_Character) return Boolean;
pragma Inline (Is_Alphanumeric);
-- Returns True if the Wide_Wide_Character designated by Item is
-- categorized as letter_uppercase, letter_lowercase, letter_titlecase,
-- letter_modifier, letter_other, number_letter, or number_decimal.
-- Otherwise returns false.
function Is_Special (Item : Wide_Wide_Character) return Boolean;
pragma Inline (Is_Special);
-- Returns True if the Wide_Wide_Character designated by Item
-- is categorized as graphic_character, but not categorized as
-- letter_uppercase, letter_lowercase, letter_titlecase, letter_modifier,
-- letter_other, number_letter, or number_decimal. Otherwise returns false.
function Is_Line_Terminator (Item : Wide_Wide_Character) return Boolean;
pragma Inline (Is_Line_Terminator);
-- Returns True if the Wide_Wide_Character designated by Item is
-- categorized as separator_line or separator_paragraph, or if Item is a
-- conventional line terminator character (CR, LF, VT, or FF). Otherwise
-- returns false.
function Is_Mark (Item : Wide_Wide_Character) return Boolean;
pragma Inline (Is_Mark);
-- Returns True if the Wide_Wide_Character designated by Item is
-- categorized as mark_non_spacing or mark_spacing_combining, otherwise
-- returns false.
function Is_Other (Item : Wide_Wide_Character) return Boolean;
pragma Inline (Is_Other);
-- Returns True if the Wide_Wide_Character designated by Item is
-- categorized as other_format, otherwise returns false.
function Is_Punctuation (Item : Wide_Wide_Character) return Boolean;
pragma Inline (Is_Punctuation);
-- Returns True if the Wide_Wide_Character designated by Item is
-- categorized as punctuation_connector, otherwise returns false.
function Is_Space (Item : Wide_Wide_Character) return Boolean;
pragma Inline (Is_Space);
-- Returns True if the Wide_Wide_Character designated by Item is
-- categorized as separator_space, otherwise returns false.
function Is_Graphic (Item : Wide_Wide_Character) return Boolean;
pragma Inline (Is_Graphic);
-- Returns True if the Wide_Wide_Character designated by Item is
-- categorized as graphic_character, otherwise returns false.
function To_Lower (Item : Wide_Wide_Character) return Wide_Wide_Character;
pragma Inline (To_Lower);
-- Returns the Simple Lowercase Mapping of the Wide_Wide_Character
-- designated by Item. If the Simple Lowercase Mapping does not exist for
-- the Wide_Wide_Character designated by Item, then the value of Item is
-- returned.
function To_Lower (Item : Wide_Wide_String) return Wide_Wide_String;
-- Returns the result of applying the To_Lower Wide_Wide_Character to
-- Wide_Wide_Character conversion to each element of the Wide_Wide_String
-- designated by Item. The result is the null Wide_Wide_String if the value
-- of the formal parameter is the null Wide_Wide_String.
function To_Upper (Item : Wide_Wide_Character) return Wide_Wide_Character;
pragma Inline (To_Upper);
-- Returns the Simple Uppercase Mapping of the Wide_Wide_Character
-- designated by Item. If the Simple Uppercase Mapping does not exist for
-- the Wide_Wide_Character designated by Item, then the value of Item is
-- returned.
function To_Upper (Item : Wide_Wide_String) return Wide_Wide_String;
-- Returns the result of applying the To_Upper Wide_Wide_Character to
-- Wide_Wide_Character conversion to each element of the Wide_Wide_String
-- designated by Item. The result is the null Wide_Wide_String if the value
-- of the formal parameter is the null Wide_Wide_String.
end Ada.Wide_Wide_Characters.Handling;
|
with GLU;
with GLOBE_3D.Math;
package body GLOBE_3D.Portals is
-- Cheap but fast portal method with rectangles.
procedure Intersect (A, B : Rectangle; C : out Rectangle; non_empty : out Boolean) is
begin
C := (X1 => Integer'Max (A.X1, B.X1),
X2 => Integer'Min (A.X2, B.X2),
Y1 => Integer'Max (A.Y1, B.Y1),
Y2 => Integer'Min (A.Y2, B.Y2));
non_empty := C.X1 <= C.X2 and then C.Y1 <= C.Y2;
end Intersect;
procedure Projection (P : Point_3D;
x, y : out Integer;
success : out Boolean) is
model, proj : GLU.Matrix_Double;
view : GLU.Viewport_Rec;
uu, vv, ww : GL.Double;
z_a : constant := 0.0001;
z_z : constant := 1.0 - z_a;
-- GLU sometimes gives fuzzy (e.g. -3612 instead of +4243)
-- x, y coordinates, with z outside ]0;1[; looks like a wrap-around
-- of large integer values
begin
GLU.Get (GL.MODELVIEW_MATRIX, model);
GLU.Get (GL.PROJECTION_MATRIX, proj);
GLU.Get (view);
GLU.Project (P (0), P (1), P (2), model, proj, view, uu, vv, ww, success);
success := success and then ww > z_a and then ww < z_z;
if success then
x := Integer (uu);
y := Integer (vv);
-- info_a_pnt (0) := (uu, vv, ww);
else
x := -1;
y := -1;
end if;
end Projection;
procedure Find_bounding_box (o : Object_3D'Class;
face : Positive;
b : out Rectangle;
success : out Boolean) is
x, y : Integer;
proj_success : Boolean;
use GLOBE_3D.Math;
begin
b := (X1 | Y1 => Integer'Last, X2 | Y2 => Integer'First);
for sf in reverse 1 .. o.Face_Invariant (face).last_edge loop
Projection (o.Point (o.Face_Invariant (face).P_compact (sf)) + o.Centre,
x, y,
proj_success);
if proj_success then
-- info_a_pnt (sf) := info_a_pnt (0);
b := (X1 => Integer'Min (b.X1, x),
X2 => Integer'Max (b.X2, x),
Y1 => Integer'Min (b.Y1, y),
Y2 => Integer'Max (b.Y2, y));
else
success := False;
return; -- we cannot project all edges of the polygon, then fail.
end if;
end loop;
success := True;
end Find_bounding_box;
procedure Draw_boundary (main, clip : Rectangle) is
z : constant := 0.0;
procedure Line (x1, y1, x2, y2 : Integer) is
begin
Vertex (GL.Double (x1), GL.Double (y1), z);
Vertex (GL.Double (x2), GL.Double (y2), z);
end Line;
procedure Frame_Rect (x1, y1, x2, y2 : Integer) is
begin
Line (x1, y1, x2, y1);
Line (x2, y1, x2, y2);
Line (x2, y2, x1, y2);
Line (x1, y2, x1, y1);
end Frame_Rect;
rect : Rectangle;
begin
GL.Disable (GL.LIGHTING);
GL.Disable (GL.TEXTURE_2D);
-- GL.Disable (GL.DEPTH_TEST); -- eeerh, @#*$!, doesn't work!
-- Workaround, we make the rectangle 1 pixel smaller
rect := (clip.X1 + 1, clip.Y1 + 1, clip.X2 - 1, clip.Y2 - 1);
-- Push current matrix mode and viewport attributes.
GL.PushAttrib (GL.TRANSFORM_BIT + GL.VIEWPORT_BIT);
GL.MatrixMode (GL.PROJECTION);
GL.PushMatrix;
GL.LoadIdentity;
GL.Ortho (ortho_left => 0.0,
ortho_right => GL.Double (main.X2 - 1),
bottom => 0.0,
top => GL.Double (main.Y2 - 1),
near_val => -1.0,
far_val => 1.0);
GL.MatrixMode (GL.MODELVIEW);
GL.PushMatrix;
GL.LoadIdentity;
-- A green rectangle to signal the clipping area
GL.Color (0.1, 1.0, 0.1, 1.0);
GL_Begin (GL.LINES);
Frame_Rect (rect.X1, rect.Y1, rect.X2, rect.Y2);
GL_End;
-- A red cross across the area
GL.Color (1.0, 0.1, 0.1, 1.0);
GL_Begin (GL.LINES);
Line (clip.X1, clip.Y1, clip.X2, clip.Y2);
Line (clip.X2, clip.Y1, clip.X1, clip.Y2);
GL_End;
GL.PopMatrix;
GL.MatrixMode (GL.PROJECTION);
GL.PopMatrix;
GL.PopAttrib;
GL.Enable (GL.LIGHTING);
-- GL.Enable (GL.DEPTH_TEST);
end Draw_boundary;
end GLOBE_3D.Portals;
|
-----------------------------------------------------------------------
-- gen-commands-docs -- Extract and generate documentation for the project
-- Copyright (C) 2012 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 GNAT.Command_Line;
with Ada.Text_IO;
with Gen.Artifacts.Docs;
with Gen.Model.Packages;
package body Gen.Commands.Docs is
use GNAT.Command_Line;
-- ------------------------------
-- Execute the command with the arguments.
-- ------------------------------
procedure Execute (Cmd : in Command;
Generator : in out Gen.Generator.Handler) is
pragma Unreferenced (Cmd);
Doc : Gen.Artifacts.Docs.Artifact;
M : Gen.Model.Packages.Model_Definition;
begin
Generator.Read_Project ("dynamo.xml", False);
-- Setup the target directory where the distribution is created.
declare
Target_Dir : constant String := Get_Argument;
begin
if Target_Dir'Length = 0 then
Generator.Error ("Missing target directory");
return;
end if;
Generator.Set_Result_Directory (Target_Dir);
end;
Doc.Prepare (M, Generator);
end Execute;
-- ------------------------------
-- Write the help associated with the command.
-- ------------------------------
procedure Help (Cmd : in Command;
Generator : in out Gen.Generator.Handler) is
pragma Unreferenced (Cmd, Generator);
use Ada.Text_IO;
begin
Put_Line ("build-doc: Extract and generate the project documentation");
Put_Line ("Usage: build-doc");
New_Line;
Put_Line (" Extract the documentation from the project source files and generate the");
Put_Line (" project documentation. The following files are scanned:");
Put_Line (" - Ada specifications (src/*.ads)");
Put_Line (" - XML configuration files (config/*.xml)");
Put_Line (" - XML database model files (db/*.xml)");
end Help;
end Gen.Commands.Docs;
|
with Ada.Numerics.Generic_Real_Arrays;
with GA_Maths;
package SVD is
type Real is digits 18;
package Real_Arrays is new Ada.Numerics.Generic_Real_Arrays (Real);
type SVD (Num_Rows, Num_Cols, Num_Singular, Work_Vector_Rows : Natural) is private;
SVD_Exception : Exception;
function Condition_Number (aMatrix : GA_Maths.Float_Matrix) return Float;
function Singular_Value_Decomposition (aMatrix : Real_Arrays.Real_Matrix)
return SVD;
function Singular_Value_Decomposition (aMatrix : GA_Maths.Float_Matrix)
return SVD;
private
type SVD (Num_Rows, Num_Cols, Num_Singular, Work_Vector_Rows : Natural) is record
Matrix_U : Real_Arrays.Real_Matrix
(1 .. Num_Rows, 1 .. Num_Cols) := (others => (others => 0.0));
Matrix_V : Real_Arrays.Real_Matrix
(1 .. Num_Rows, 1 .. Num_Cols) := (others => (others => 0.0));
Matrix_W : Real_Arrays.Real_Vector
(1 .. Work_Vector_Rows) :=(others => 0.0);
Sorted_Singular_Values : Real_Arrays.Real_Vector (1 .. Num_Singular);
end record;
end SVD;
|
-- Copyright (c) 2019 Maxim Reznik <reznikmm@gmail.com>
--
-- SPDX-License-Identifier: MIT
-- License-Filename: LICENSE
-------------------------------------------------------------
with Slim.Messages.grfe;
package body Slim.Players.Displays is
-----------
-- Clear --
-----------
procedure Clear (Self : in out Display) is
begin
Self.Buffer := (1 .. Self.Size => 0);
end Clear;
---------------
-- Draw_Text --
---------------
procedure Draw_Text
(Self : in out Display;
X, Y : Positive;
Font : Slim.Fonts.Font;
Text : League.Strings.Universal_String)
is
procedure Draw_Pixel (X, Y : Positive);
procedure Draw_Pixel (X, Y : Positive) is
begin
Draw_Pixel (Self, X, Y);
end Draw_Pixel;
procedure Draw_Text is new Slim.Fonts.Draw_Text
(Coordinate => Integer,
Draw_Pixel => Draw_Pixel);
Line : League.Strings.Universal_String := Text;
begin
while Fonts.Size (Font, Line).Right + X - 1 > 160 loop
Line := Line.Head_To (Line.Length - 1);
end loop;
Draw_Text (Font, Line, X - 1, Y - 1);
end Draw_Text;
----------------
-- Draw_Pixel --
----------------
procedure Draw_Pixel
(Self : in out Display;
X, Y : Positive;
Set : Boolean := True)
is
use type Ada.Streams.Stream_Element;
Index : constant Ada.Streams.Stream_Element_Offset :=
Ada.Streams.Stream_Element_Offset ((X - 1) * 4 + (32 - Y) / 8 + 1);
Mask : constant Ada.Streams.Stream_Element :=
2 ** ((Y - 1) mod 8);
begin
if Set then
Self.Buffer (Index) := Self.Buffer (Index) or Mask;
else
Self.Buffer (Index) := Self.Buffer (Index) and not Mask;
end if;
end Draw_Pixel;
----------------
-- Initialize --
----------------
procedure Initialize
(Self : in out Display;
Player : Players.Player) is
begin
Self.Socket := Player.Socket;
end Initialize;
------------------
-- Send_Message --
------------------
procedure Send_Message
(Self : Display;
Transition : Transition_Kind := None;
Offset : Natural := 0)
is
Grfe : Slim.Messages.grfe.Grfe_Message;
begin
Grfe.Initialize (Self.Buffer, Transition, Offset);
Write_Message (Self.Socket, Grfe);
end Send_Message;
end Slim.Players.Displays;
|
with Ada.Text_IO; use Ada.Text_IO;
procedure Adventofcode.Day_20.Main is
begin
Put_Line ("Day-20");
end Adventofcode.Day_20.Main;
|
function Increment_By
(I : Integer := 0;
Incr : Integer := 1) return Integer is
-- ^ Default value for parameters
begin
return I + Incr;
end Increment_By;
|
-- C32107C.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.
--*
-- FOR OBJECTS OF A GENERIC FORMAL TYPE WHOSE ACTUAL PARAMETER IS A
-- TYPE WITH DEFAULT VALUES, CHECK THAT OBJECT DECLARATIONS ARE
-- ELABORATED IN THE ORDER OF THEIR OCCURRENCE, I.E., THAT EXPRESSIONS
-- ASSOCIATED WITH ONE DECLARATION (INCLUDING DEFAULT EXPRESSIONS) ARE
-- EVALUATED BEFORE ANY EXPRESSION BELONGING TO THE NEXT DECLARATION.
-- R.WILLIAMS 9/24/86
WITH REPORT; USE REPORT;
PROCEDURE C32107C IS
BUMP : INTEGER := 0;
G1, H1 : INTEGER;
FUNCTION F RETURN INTEGER IS
BEGIN
BUMP := BUMP + 1;
RETURN BUMP;
END F;
FUNCTION G RETURN INTEGER IS
BEGIN
BUMP := BUMP + 1;
G1 := BUMP;
RETURN BUMP;
END G;
FUNCTION H RETURN INTEGER IS
BEGIN
BUMP := BUMP + 1;
H1 := BUMP;
RETURN BUMP;
END H;
BEGIN
TEST ( "C32107C", "FOR OBJECTS OF A GENERIC FORMAL TYPE WHOSE " &
"ACTUAL PARAMETER IS A TYPE WITH DEFAULT " &
"VALUES, CHECK THAT OBJECT DECLARATIONS ARE " &
"ELABORATED IN THE ORDER OF THEIR " &
"OCCURRENCE, I.E., THAT EXPRESSIONS " &
"ASSOCIATED WITH ONE DECLARATION (INCLUDING " &
"DEFAULT EXPRESSIONS) ARE EVALUATED BEFORE " &
"ANY EXPRESSION BELONGING TO THE NEXT " &
"DECLARATION" );
DECLARE -- (A).
TYPE REC (D : INTEGER := F) IS
RECORD
A : INTEGER := F;
END RECORD;
FUNCTION GET_A (R : REC) RETURN INTEGER IS
BEGIN
RETURN R.A;
END GET_A;
GENERIC
TYPE T IS (<>);
TYPE PRIV (D : T) IS PRIVATE;
WITH FUNCTION GET_A (P : PRIV) RETURN INTEGER IS <>;
PROCEDURE P;
PROCEDURE P IS
P1 : PRIV (T'VAL (F));
P2 : PRIV (T'VAL (F * 100));
ORDER_CHECK : INTEGER;
BEGIN
ORDER_CHECK :=
T'POS (P1.D) + T'POS (P2.D) +
(GET_A (P1) * 10) + (GET_A (P2) * 1000);
IF ORDER_CHECK /= 4321 THEN
FAILED ( "OBJECTS NOT ELABORATED IN PROPER " &
"ORDER VALUE OF ORDER_CHECK SHOULD BE " &
"4321 -- ACTUAL VALUE IS " &
INTEGER'IMAGE (ORDER_CHECK) & " - (A)" );
END IF;
END P;
PROCEDURE PROC IS NEW P (INTEGER, REC);
BEGIN
PROC;
END; -- (A).
BUMP := 0;
DECLARE -- (B).
TYPE REC (D1 : INTEGER := F; D2 : INTEGER := F) IS
RECORD
A : INTEGER := F;
END RECORD;
FUNCTION GET_A (R : REC) RETURN INTEGER IS
BEGIN
RETURN R.A;
END GET_A;
GENERIC
TYPE T IS (<>);
TYPE PRIV (D1 : T; D2 : T) IS PRIVATE;
WITH FUNCTION GET_A (P : PRIV) RETURN INTEGER IS <>;
PROCEDURE P;
PROCEDURE P IS
P1 : PRIV (T'VAL (F * 1000), T'VAL (F * 10000));
P2 : PRIV (T'VAL (F), T'VAL (F * 10));
ORDER_CHECK : INTEGER;
BEGIN
ORDER_CHECK :=
T'POS (P1.D1) + T'POS (P1.D2) +
T'POS (P2.D1) + T'POS (P2.D2) +
(GET_A (P1) * 100);
IF (GET_A (P2) = 6) AND
(ORDER_CHECK = 12345 OR ORDER_CHECK = 21345 OR
ORDER_CHECK = 21354 OR ORDER_CHECK = 12354) THEN
COMMENT ( "ORDER_CHECK HAS VALUE " &
INTEGER'IMAGE (ORDER_CHECK) &
" - (B)" );
ELSE
FAILED ( "OBJECTS NOT ELABORATED IN PROPER " &
"ORDER VALUE OF ORDER_CHECK SHOULD BE " &
"6 12345, 6 21345, 6 21354, OR " &
"6 12354 -- ACTUAL VALUE IS " &
INTEGER'IMAGE (GET_A (P2)) &
INTEGER'IMAGE (ORDER_CHECK) & " - (B)" );
END IF;
END P;
PROCEDURE PROC IS NEW P (INTEGER, REC);
BEGIN
PROC;
END; -- (B).
RESULT;
END C32107C;
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.