content
stringlengths 23
1.05M
|
|---|
-- Motherlode
-- Copyright (c) 2020 Fabien Chouteau
package Cargo_Menu is
procedure Run;
end Cargo_Menu;
|
-- ////////////////////////////////////////////////////////////
-- //
-- // SFML - Simple and Fast Multimedia Library
-- // Copyright (C) 2007-2009 Laurent Gomila (laurent.gom@gmail.com)
-- //
-- // This software is provided 'as-is', without any express or implied warranty.
-- // In no event will the authors be held liable for any damages arising from the use of this software.
-- //
-- // Permission is granted to anyone to use this software for any purpose,
-- // including commercial applications, and to alter it and redistribute it freely,
-- // subject to the following restrictions:
-- //
-- // 1. The origin of this software must not be misrepresented;
-- // you must not claim that you wrote the original software.
-- // If you use this software in a product, an acknowledgment
-- // in the product documentation would be appreciated but is not required.
-- //
-- // 2. Altered source versions must be plainly marked as such,
-- // and must not be misrepresented as being the original software.
-- //
-- // 3. This notice may not be removed or altered from any source distribution.
-- //
-- ////////////////////////////////////////////////////////////
-- ////////////////////////////////////////////////////////////
-- // Headers
-- ////////////////////////////////////////////////////////////
with Sf.Config;
with Sf.Audio.Types;
package Sf.Audio.SoundBufferRecorder is
use Sf.Config;
use Sf.Audio.Types;
-- ////////////////////////////////////////////////////////////
-- /// Construct a new sound buffer recorder
-- ///
-- /// \return A new sfSoundBufferRecorder object (NULL if failed)
-- ///
-- ////////////////////////////////////////////////////////////
function sfSoundBufferRecorder_Create return sfSoundBufferRecorder_Ptr;
-- ////////////////////////////////////////////////////////////
-- /// Destroy an existing sound buffer recorder
-- ///
-- /// \param SoundBufferRecorder : Sound buffer recorder to delete
-- ///
-- ////////////////////////////////////////////////////////////
procedure sfSoundBufferRecorder_Destroy (SoundBufferRecorder : sfSoundBufferRecorder_Ptr);
-- ////////////////////////////////////////////////////////////
-- /// Start the capture.
-- /// Warning : only one capture can happen at the same time
-- ///
-- /// \param SoundBufferRecorder : Sound bufferrecorder to start
-- /// \param SampleRate : Sound frequency (the more samples, the higher the quality)
-- ///
-- ////////////////////////////////////////////////////////////
procedure sfSoundBufferRecorder_Start (SoundBufferRecorder : sfSoundBufferRecorder_Ptr; SampleRate : sfUint32);
-- ////////////////////////////////////////////////////////////
-- /// Stop the capture
-- ///
-- /// \param SoundBufferRecorder : Sound buffer recorder to stop
-- ///
-- ////////////////////////////////////////////////////////////
procedure sfSoundBufferRecorder_Stop (SoundBufferRecorder : sfSoundBufferRecorder_Ptr);
-- ////////////////////////////////////////////////////////////
-- /// Get the sample rate of a sound buffer recorder
-- ///
-- /// \param SoundBufferRecorder : Sound buffer recorder to get sample rate from
-- ///
-- /// \return Frequency, in samples per second
-- ///
-- ////////////////////////////////////////////////////////////
function sfSoundBufferRecorder_GetSampleRate (SoundBufferRecorder : sfSoundBufferRecorder_Ptr) return sfUint32;
-- ////////////////////////////////////////////////////////////
-- /// Get the sound buffer containing the captured audio data
-- /// of a sound buffer recorder
-- ///
-- /// \param SoundBufferRecorder : Sound buffer recorder to get the sound buffer from
-- ///
-- /// \return Pointer to the sound buffer (you don't need to destroy it after use)
-- ///
-- ////////////////////////////////////////////////////////////
function sfSoundBufferRecorder_GetBuffer (SoundBufferRecorder : sfSoundBufferRecorder_Ptr) return sfSoundBuffer_Ptr;
private
pragma Import (C, sfSoundBufferRecorder_Create, "sfSoundBufferRecorder_Create");
pragma Import (C, sfSoundBufferRecorder_Destroy, "sfSoundBufferRecorder_Destroy");
pragma Import (C, sfSoundBufferRecorder_Start, "sfSoundBufferRecorder_Start");
pragma Import (C, sfSoundBufferRecorder_Stop, "sfSoundBufferRecorder_Stop");
pragma Import (C, sfSoundBufferRecorder_GetSampleRate, "sfSoundBufferRecorder_GetSampleRate");
pragma Import (C, sfSoundBufferRecorder_GetBuffer, "sfSoundBufferRecorder_GetBuffer");
end Sf.Audio.SoundBufferRecorder;
|
-----------------------------------------------------------------------
-- package body Runge_pc_2, Runge-Kutta integrator.
-- Copyright (C) 2008-2018 Jonathan S. Parker.
--
-- Permission to use, copy, modify, and/or distribute this software for any
-- purpose with or without fee is hereby granted, provided that the above
-- copyright notice and this permission notice appear in all copies.
-- THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
-- WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
-- MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
-- ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
-- WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
-- ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
-- OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
-----------------------------------------------------------------------
with runge_coeffs_pd_8;
package body Runge_pc_2 is
package Coeffs is new Runge_Coeffs_pd_8 (Real);
use Coeffs;
type K_type1 is array (RK_Range) of Real;
type K_type2 is array (Dyn_Index) of K_type1;
type K_type is array (0..1) of K_type2;
type RK_Dynamical_Variable is array (0..1) of Dynamical_Variable;
procedure Runge_Sum
(Y : in RK_Dynamical_Variable;
Next_Y : out RK_Dynamical_Variable;
Stage : in Stages;
K : in K_type)
is
Stage2 : Stages;
Sum : Real;
begin
Stage2 := Stage;
for j in 0..1 loop
for l in Dyn_Index loop
Sum := 0.0;
for n in RK_Range range 0..Stage2-1 loop
Sum := Sum + A(Stage2)(n) * K(j)(l)(n);
end loop;
Next_Y(j)(l) := Y(j)(l) + Sum;
end loop;
end loop;
end Runge_Sum;
pragma Inline (Runge_Sum);
function F1
(Time : Real;
Y1 : RK_Dynamical_Variable)
return RK_Dynamical_Variable
is
Result : RK_Dynamical_Variable;
begin
Result(0) := Y1(1);
Result(1) := F (Time, Y1(0));
return Result;
end F1;
-- Integrate to eighth order using RKPD
procedure Integrate
(Final_Y : out Dynamical_Variable;
Final_deriv_Of_Y : out Dynamical_Variable;
Final_Time : in Real;
Initial_Y : in Dynamical_Variable;
Initial_deriv_Of_Y : in Dynamical_Variable;
Initial_Time : in Real;
No_of_Steps : in Real)
is
Delta_t : constant Real := (Final_Time - Initial_Time) / No_of_Steps;
Present_t : Real;
Y : RK_Dynamical_Variable;
K : K_type;
-- Increments of Independent variable
-- so K(13) = Delta_t*F (Time + Dt(13), Y + SUM (A(13), K))
Dt : Coefficient;
-- function to Sum Series For Delta Y efficiently
function Seventh_Order_Delta_Y return RK_Dynamical_Variable is
Result : RK_Dynamical_Variable;
begin
for j in 0..1 loop
for l in Dyn_Index loop
Result(j)(l) :=
B7(0) * K(j)(l)(0) + B7(5) * K(j)(l)(5) +
B7(6) * K(j)(l)(6) + B7(7) * K(j)(l)(7) +
B7(8) * K(j)(l)(8) + B7(9) * K(j)(l)(9) +
B7(10) * K(j)(l)(10) + B7(11) * K(j)(l)(11);
end loop;
end loop;
return Result;
end Seventh_Order_Delta_Y;
-- function to Sum Series For Delta Y efficiently
function Eighth_Order_Delta_Y return RK_Dynamical_Variable is
Result : RK_Dynamical_Variable;
begin
for j in 0..1 loop
for l in Dyn_Index loop
Result(j)(l) :=
B8(0) * K(j)(l)(0) + B8(5) * K(j)(l)(5) +
B8(6) * K(j)(l)(6) + B8(7) * K(j)(l)(7) +
B8(8) * K(j)(l)(8) + B8(9) * K(j)(l)(9) +
B8(10) * K(j)(l)(10) + B8(11) * K(j)(l)(11) +
B8(12) * K(j)(l)(12);
end loop;
end loop;
return Result;
end Eighth_Order_Delta_Y;
-- function to Sum Series For Delta Y efficiently
procedure Get_New_Y_to_Seventh_Order
(Y : in out RK_Dynamical_Variable)
is
begin
for j in 0..1 loop
for l in Dyn_Index loop
Y(j)(l) := Y(j)(l) +
B7(0) * K(j)(l)(0) + B7(5) * K(j)(l)(5) +
B7(6) * K(j)(l)(6) + B7(7) * K(j)(l)(7) +
B7(8) * K(j)(l)(8) + B7(9) * K(j)(l)(9) +
B7(10) * K(j)(l)(10) + B7(11) * K(j)(l)(11);
end loop;
end loop;
end Get_New_Y_to_Seventh_Order;
procedure Get_New_Y_to_Eighth_Order
(Y : in out RK_Dynamical_Variable) is
begin
for j in 0..1 loop
for l in Dyn_Index loop
Y(j)(l) := Y(j)(l) +
B8(0) * K(j)(l)(0) + B8(5) * K(j)(l)(5) +
B8(6) * K(j)(l)(6) + B8(7) * K(j)(l)(7) +
B8(8) * K(j)(l)(8) + B8(9) * K(j)(l)(9) +
B8(10) * K(j)(l)(10) + B8(11) * K(j)(l)(11) +
B8(12) * K(j)(l)(12);
end loop;
end loop;
end Get_New_Y_to_Eighth_Order;
begin
Y(0) := Initial_Y;
Y(1) := Initial_deriv_Of_Y;
Present_t := Initial_Time;
for i in Stages Loop
Dt(i) := Delta_t * C(i);
end loop;
Time_Steps:
for step in 1 .. Integer(No_Of_Steps) loop
-- First get DeltaY to 8th Order by calculating the
-- Runge-Kutta corrections K.
--
-- K(Stages'First) := Delta_t * F (Time, Y);
-- for Stage in Stages'First+1 .. Stages'Last loop
-- K(Stage) := Delta_t * F (Time + Dt(Stage), Y + Sum (Stage));
-- end loop;
Make_New_Corrections_K:
declare
Next_t : Real := Present_t;
Next_Deriv, Next_Y : RK_Dynamical_Variable;
begin
Next_Deriv := F1 (Next_t, Y);
for j in 0..1 loop
for l in Dyn_Index loop
K(j)(l)(Stages'First) := Delta_t * Next_Deriv(j)(l);
end loop;
end loop;
for Stage in Stages'First+1 .. Stages'Last loop
Runge_Sum (Y, Next_Y, Stage, K);
Next_t := Present_t + Dt(Stage);
Next_Deriv := F1 (Next_t, Next_Y);
for j in 0..1 loop
for l in Dyn_Index loop
K(j)(l)(Stage) := Delta_t * Next_Deriv(j)(l);
end loop;
end loop;
end loop;
end Make_New_Corrections_K;
-- use globally updated K to get new Y:
Get_New_Y_to_Eighth_Order (Y);
--Get_New_Y_to_Seventh_Order (Y);
Present_t := Present_t + Delta_t; -- new time
end loop Time_Steps;
Final_Y := Y(0);
Final_deriv_Of_Y := Y(1);
end Integrate;
end Runge_pc_2;
|
package Discriminant_Constraint is
type Unconstrained_Type (Size : Natural) is null record;
Constrained_Object : Unconstrained_Type (10);
end Discriminant_Constraint;
|
-- FILE: oedipus-complex_text_io.adb LICENSE: MIT © 2021 Mae Morella
with Oedipus, Ada.Float_Text_IO, Ada.Text_IO;
use Oedipus, Ada.Float_Text_IO, Ada.Text_IO;
package body Oedipus.Complex_Text_IO is
subtype Field is Ada.Text_IO.Field;
procedure Put
(Item : in Complex; Fore : in Field := Default_Fore;
Aft : in Field := Default_Aft; Exp : in Field := Default_Exp)
is
begin
Put (Get_Real (Item), Fore, Aft, Exp);
Put (" + ");
Put (Get_Imaginary (Item), Fore, Aft, Exp);
Put ("i");
end Put;
procedure Get (Item : out Complex) is
A : Float;
B : Float;
begin
Put ("Enter real component: ");
Get (A);
Put ("Enter imaginary component: ");
Get (B);
Item := Create_Complex (A, B);
end Get;
end Oedipus.Complex_Text_IO;
|
--
-- Copyright (c) 2015, John Leimon <jleimon@gmail.com>
--
-- 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 Ada_2005;
pragma Style_Checks (Off);
with Interfaces.C; use Interfaces.C;
with System;
with Interfaces.C.Strings;
package x86_64_linux_gnu_bits_types_h is
subtype uu_u_char is unsigned_char; -- /usr/include/x86_64-linux-gnu/bits/types.h:30
subtype uu_u_short is unsigned_short; -- /usr/include/x86_64-linux-gnu/bits/types.h:31
subtype uu_u_int is unsigned; -- /usr/include/x86_64-linux-gnu/bits/types.h:32
subtype uu_u_long is unsigned_long; -- /usr/include/x86_64-linux-gnu/bits/types.h:33
subtype uu_int8_t is signed_char; -- /usr/include/x86_64-linux-gnu/bits/types.h:36
subtype uu_uint8_t is unsigned_char; -- /usr/include/x86_64-linux-gnu/bits/types.h:37
subtype uu_int16_t is short; -- /usr/include/x86_64-linux-gnu/bits/types.h:38
subtype uu_uint16_t is unsigned_short; -- /usr/include/x86_64-linux-gnu/bits/types.h:39
subtype uu_int32_t is int; -- /usr/include/x86_64-linux-gnu/bits/types.h:40
subtype uu_uint32_t is unsigned; -- /usr/include/x86_64-linux-gnu/bits/types.h:41
subtype uu_int64_t is long; -- /usr/include/x86_64-linux-gnu/bits/types.h:43
subtype uu_uint64_t is unsigned_long; -- /usr/include/x86_64-linux-gnu/bits/types.h:44
subtype uu_quad_t is long; -- /usr/include/x86_64-linux-gnu/bits/types.h:52
subtype uu_u_quad_t is unsigned_long; -- /usr/include/x86_64-linux-gnu/bits/types.h:53
subtype uu_dev_t is unsigned_long; -- /usr/include/x86_64-linux-gnu/bits/types.h:124
subtype uu_uid_t is unsigned; -- /usr/include/x86_64-linux-gnu/bits/types.h:125
subtype uu_gid_t is unsigned; -- /usr/include/x86_64-linux-gnu/bits/types.h:126
subtype uu_ino_t is unsigned_long; -- /usr/include/x86_64-linux-gnu/bits/types.h:127
subtype uu_ino64_t is unsigned_long; -- /usr/include/x86_64-linux-gnu/bits/types.h:128
subtype uu_mode_t is unsigned; -- /usr/include/x86_64-linux-gnu/bits/types.h:129
subtype uu_nlink_t is unsigned_long; -- /usr/include/x86_64-linux-gnu/bits/types.h:130
subtype uu_off_t is long; -- /usr/include/x86_64-linux-gnu/bits/types.h:131
subtype uu_off64_t is long; -- /usr/include/x86_64-linux-gnu/bits/types.h:132
subtype uu_pid_t is int; -- /usr/include/x86_64-linux-gnu/bits/types.h:133
type uu_fsid_t_uu_val_array is array (0 .. 1) of aliased int;
type uu_fsid_t is record
uu_val : aliased uu_fsid_t_uu_val_array; -- /usr/include/x86_64-linux-gnu/bits/types.h:134
end record;
pragma Convention (C_Pass_By_Copy, uu_fsid_t); -- /usr/include/x86_64-linux-gnu/bits/types.h:134
-- skipped anonymous struct anon_0
subtype uu_clock_t is long; -- /usr/include/x86_64-linux-gnu/bits/types.h:135
subtype uu_rlim_t is unsigned_long; -- /usr/include/x86_64-linux-gnu/bits/types.h:136
subtype uu_rlim64_t is unsigned_long; -- /usr/include/x86_64-linux-gnu/bits/types.h:137
subtype uu_id_t is unsigned; -- /usr/include/x86_64-linux-gnu/bits/types.h:138
subtype uu_time_t is long; -- /usr/include/x86_64-linux-gnu/bits/types.h:139
subtype uu_useconds_t is unsigned; -- /usr/include/x86_64-linux-gnu/bits/types.h:140
subtype uu_suseconds_t is long; -- /usr/include/x86_64-linux-gnu/bits/types.h:141
subtype uu_daddr_t is int; -- /usr/include/x86_64-linux-gnu/bits/types.h:143
subtype uu_key_t is int; -- /usr/include/x86_64-linux-gnu/bits/types.h:144
subtype uu_clockid_t is int; -- /usr/include/x86_64-linux-gnu/bits/types.h:147
type uu_timer_t is new System.Address; -- /usr/include/x86_64-linux-gnu/bits/types.h:150
subtype uu_blksize_t is long; -- /usr/include/x86_64-linux-gnu/bits/types.h:153
subtype uu_blkcnt_t is long; -- /usr/include/x86_64-linux-gnu/bits/types.h:158
subtype uu_blkcnt64_t is long; -- /usr/include/x86_64-linux-gnu/bits/types.h:159
subtype uu_fsblkcnt_t is unsigned_long; -- /usr/include/x86_64-linux-gnu/bits/types.h:162
subtype uu_fsblkcnt64_t is unsigned_long; -- /usr/include/x86_64-linux-gnu/bits/types.h:163
subtype uu_fsfilcnt_t is unsigned_long; -- /usr/include/x86_64-linux-gnu/bits/types.h:166
subtype uu_fsfilcnt64_t is unsigned_long; -- /usr/include/x86_64-linux-gnu/bits/types.h:167
subtype uu_fsword_t is long; -- /usr/include/x86_64-linux-gnu/bits/types.h:170
subtype uu_ssize_t is long; -- /usr/include/x86_64-linux-gnu/bits/types.h:172
subtype uu_syscall_slong_t is long; -- /usr/include/x86_64-linux-gnu/bits/types.h:175
subtype uu_syscall_ulong_t is unsigned_long; -- /usr/include/x86_64-linux-gnu/bits/types.h:177
subtype uu_loff_t is uu_off64_t; -- /usr/include/x86_64-linux-gnu/bits/types.h:181
type uu_qaddr_t is access all uu_quad_t; -- /usr/include/x86_64-linux-gnu/bits/types.h:182
type uu_caddr_t is new Interfaces.C.Strings.chars_ptr; -- /usr/include/x86_64-linux-gnu/bits/types.h:183
subtype uu_intptr_t is long; -- /usr/include/x86_64-linux-gnu/bits/types.h:186
subtype uu_socklen_t is unsigned; -- /usr/include/x86_64-linux-gnu/bits/types.h:189
end x86_64_linux_gnu_bits_types_h;
|
-- Ascon_Definitions
-- Some type / subtype definitions in common use in the Ascon code.
-- As some uses of these types are in generic parameters, it is not possible
-- to hide them.
-- Copyright (c) 2016-2018, James Humphry - see LICENSE file for details
pragma Restrictions(No_Implementation_Attributes,
No_Implementation_Identifiers,
No_Implementation_Units,
No_Obsolescent_Features);
package Ascon_Definitions
with Pure, SPARK_Mode => On is
subtype Rate_Bits is Integer
with Static_Predicate => Rate_Bits in 64 | 128;
subtype Round_Count is Integer range 1..12;
subtype Round_Offset is Integer range 0..11;
end Ascon_Definitions;
|
with Ada.Text_IO; use Ada.Text_IO;
procedure Goodbye_World is
begin
Put_Line (Standard_Error, "Goodbye, World!");
end Goodbye_World;
|
-- Task worker - design 2
-- Adds pub-sub flow to receive and respond to kill signal
with Ada.Command_Line;
with Ada.Text_IO;
with GNAT.Formatted_String;
with ZMQ;
procedure TaskWork2 is
use type GNAT.Formatted_String.Formatted_String;
function Main return Ada.Command_Line.Exit_Status
is
begin
declare
Context : ZMQ.Context_Type := ZMQ.New_Context;
-- Socket to receive messages on
Receiver : constant ZMQ.Socket_Type'Class := Context.New_Socket (ZMQ.ZMQ_PULL);
-- Socket to send messages to
Sender : constant ZMQ.Socket_Type'Class := Context.New_Socket (ZMQ.ZMQ_PUSH);
-- Socket for control input
Controller : constant ZMQ.Socket_Type'Class := Context.New_Socket (ZMQ.ZMQ_SUB);
begin
Receiver.Connect ("tcp://localhost:5557");
Sender.Connect ("tcp://localhost:5558");
Controller.Connect ("tcp://localhost:5559");
Controller.Set_Sock_Opt (ZMQ.ZMQ_SUBSCRIBE, "");
-- Process messages from either socket
Process_Loop :
loop
declare
Items : ZMQ.Poll_Item_Array_Type :=
(ZMQ.New_Poll_Item (Receiver, Poll_In => True),
ZMQ.New_Poll_Item (Controller, Poll_In => True));
begin
ZMQ.Poll (Items);
if ZMQ.Is_Readable (Items (Items'First)) then
declare
Buf : constant String := Receiver.Recv;
begin
Ada.Text_IO.Put (Buf &"."); -- Show progress
Ada.Text_IO.Flush;
delay Duration'Value (Buf) / 1000.0; -- Do the work
Sender.Send (""); -- Send results to sink
end;
end if;
-- Any waiting controller command acts as 'KILL'
exit Process_Loop when ZMQ.Is_Readable (Items (Items'First + 1));
end;
end loop Process_Loop;
Receiver.Close;
Sender.Close;
Controller.Close;
Context.Term;
end;
return 0;
end Main;
begin
Ada.Command_Line.Set_Exit_Status (Main);
end TaskWork2;
|
pragma Ada_2005;
pragma Style_Checks (Off);
with Interfaces.C; use Interfaces.C;
with Interfaces.C.Strings;
package SDL_platform_h is
HAVE_WINAPIFAMILY_H : constant := 0; -- ..\SDL2_tmp\SDL_platform.h:134
WINAPI_FAMILY_WINRT : constant := 0; -- ..\SDL2_tmp\SDL_platform.h:141
-- Simple DirectMedia Layer
-- Copyright (C) 1997-2018 Sam Lantinga <slouken@libsdl.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.
--
--*
-- * \file SDL_platform.h
-- *
-- * Try to get a standard set of platform defines.
--
-- lets us know what version of Mac OS X we're compiling on
-- if compiling for iOS
-- if not compiling for iOS
-- Try to find out if we're compiling for WinRT or non-WinRT
-- If _USING_V110_SDK71_ is defined it means we are using the Windows XP toolset.
-- The NACL compiler defines __native_client__ and __pnacl__
-- * Ref: http://www.chromium.org/nativeclient/pnacl/stability-of-the-pnacl-bitcode-abi
--
-- PNACL with newlib supports static linking only
-- Set up for C function definitions, even when using C++
--*
-- * \brief Gets the name of the platform.
--
function SDL_GetPlatform return Interfaces.C.Strings.chars_ptr; -- ..\SDL2_tmp\SDL_platform.h:188
pragma Import (C, SDL_GetPlatform, "SDL_GetPlatform");
-- Ends C function definitions when using C++
-- vi: set ts=4 sw=4 expandtab:
end SDL_platform_h;
|
------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- Web Framework --
-- --
-- Runtime Library Component --
-- --
------------------------------------------------------------------------------
-- --
-- Copyright © 2014-2016, 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.Streams;
with AWS.Status;
private with League.String_Vectors;
private with League.Strings;
with Matreshka.Servlet_HTTP_Requests;
private with Servlet.HTTP_Cookie_Sets;
private with Servlet.HTTP_Parameter_Vectors;
with Servlet.HTTP_Requests;
with Servlet.HTTP_Upgrade_Handlers;
package Matreshka.Servlet_AWS_Requests is
type AWS_Servlet_Request is
new Matreshka.Servlet_HTTP_Requests.Abstract_HTTP_Servlet_Request
with private;
procedure Initialize
(Self : in out AWS_Servlet_Request'Class;
Data : AWS.Status.Data);
-- Initialize object to obtain information from given data object of AWS.
procedure Finalize (Self : in out AWS_Servlet_Request'Class);
-- Deallocate internal data.
function Get_Upgrade_Handler
(Self : AWS_Servlet_Request'Class)
return Servlet.HTTP_Upgrade_Handlers.HTTP_Upgrade_Handler_Access;
private
----------------------
-- Body_Stream_Type --
----------------------
type Body_Stream_Type
(Request : not null access AWS_Servlet_Request'Class) is
new Ada.Streams.Root_Stream_Type with record
null;
end record;
overriding procedure Read
(Self : in out Body_Stream_Type;
Item : out Ada.Streams.Stream_Element_Array;
Last : out Ada.Streams.Stream_Element_Offset);
overriding procedure Write
(Self : in out Body_Stream_Type;
Item : Ada.Streams.Stream_Element_Array);
-------------------------
-- AWS_Servlet_Request --
-------------------------
type Internal_Cache is record
Cookies : Servlet.HTTP_Cookie_Sets.Cookie_Set;
Cookies_Computed : Boolean := False;
Upgrade :
Servlet.HTTP_Upgrade_Handlers.HTTP_Upgrade_Handler_Access;
end record;
type AWS_Servlet_Request is
new Matreshka.Servlet_HTTP_Requests.Abstract_HTTP_Servlet_Request with
record
Request : AWS.Status.Data;
Data : access Internal_Cache;
Data_Storage : aliased Internal_Cache;
Body_Stream : aliased Body_Stream_Type (AWS_Servlet_Request'Access);
end record;
overriding function Get_Cookies
(Self : AWS_Servlet_Request)
return Servlet.HTTP_Cookie_Sets.Cookie_Set;
-- Returns an array containing all of the Cookie objects the client sent
-- with this request. This method returns null if no cookies were sent.
overriding function Get_Headers
(Self : AWS_Servlet_Request;
Name : League.Strings.Universal_String)
return League.String_Vectors.Universal_String_Vector;
-- Returns all the values of the specified request header as an Enumeration
-- of String objects.
overriding function Get_Input_Stream
(Self : AWS_Servlet_Request)
return not null access Ada.Streams.Root_Stream_Type'Class;
-- Retrieves the body of the request as binary data using a stream.
overriding function Get_Method
(Self : AWS_Servlet_Request) return Servlet.HTTP_Requests.HTTP_Method;
-- Returns the name of the HTTP method with which this request was made,
-- for example, GET, POST, or PUT. Same as the value of the CGI variable
-- REQUEST_METHOD.
overriding function Get_Parameter_Names
(Self : AWS_Servlet_Request)
return League.String_Vectors.Universal_String_Vector;
-- Returns an vector of String containing the names of the parameters
-- contained in this request. If the request has no parameters, the method
-- returns an empty vector.
overriding function Get_Parameter_Values
(Self : AWS_Servlet_Request;
Name : League.Strings.Universal_String)
return League.String_Vectors.Universal_String_Vector;
-- Returns an array of String objects containing all of the values the
-- given request parameter has, or null if the parameter does not exist.
overriding function Get_Parameter_Values
(Self : AWS_Servlet_Request;
Name : League.Strings.Universal_String)
return Servlet.HTTP_Parameter_Vectors.HTTP_Parameter_Vector;
overriding function Is_Async_Supported
(Self : not null access AWS_Servlet_Request) return Boolean;
-- Checks if this request supports asynchronous operation.
overriding procedure Upgrade
(Self : AWS_Servlet_Request;
Handler :
not null Servlet.HTTP_Upgrade_Handlers.HTTP_Upgrade_Handler_Access);
-- Uses given upgrade handler for the http protocol upgrade processing.
end Matreshka.Servlet_AWS_Requests;
|
------------------------------------------------------------------------------
-- --
-- Copyright (C) 2016, AdaCore --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions are --
-- met: --
-- 1. Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- 2. Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in --
-- the documentation and/or other materials provided with the --
-- distribution. --
-- 3. Neither the name of STMicroelectronics nor the names of its --
-- contributors may be used to endorse or promote products derived --
-- from this software without specific prior written permission. --
-- --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR --
-- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
-- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT --
-- LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, --
-- DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY --
-- THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT --
-- (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE --
-- OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
-- --
-- --
-- This file is based on: --
-- --
-- @file stm32f4xx_hal_i2s.c --
-- @author MCD Application Team --
-- @version V1.0.0 --
-- @date 18-February-2014 --
-- @brief I2S HAL module driver. --
-- --
-- COPYRIGHT(c) 2014 STMicroelectronics --
------------------------------------------------------------------------------
with Ada.Unchecked_Conversion;
with STM32.Device;
package body STM32.I2S is
function To_UInt16 is new Ada.Unchecked_Conversion (Integer_16,
UInt16);
function To_Integer_16 is new Ada.Unchecked_Conversion (UInt16,
Integer_16);
---------------
-- Configure --
---------------
procedure Configure (This : in out I2S_Port; Conf : I2S_Configuration) is
begin
This.Periph.I2SCFGR.I2SCFG := (case Conf.Mode is
when Slave_Transmit => 2#00#,
when Slave_Receive => 2#01#,
when Master_Transmit => 2#10#,
when Master_Receive => 2#11#);
This.Periph.I2SCFGR.PCMSYNC := Conf.Syncho = Long_Frame_Synchro;
This.Periph.I2SCFGR.I2SSTD := (case Conf.Standard is
when I2S_Philips_Standard => 2#00#,
when MSB_Justified_Standard => 2#01#,
when LSB_Justified_Standard => 2#10#,
when PCM_Standard => 2#11#);
This.Periph.I2SCFGR.CKPOL := Conf.Clock_Polarity = Steady_State_High;
This.Periph.I2SCFGR.DATLEN := (case Conf.Data_Length is
when Data_16bits => 2#00#,
when Data_24bits => 2#01#,
when Data_32bits => 2#10#);
This.Periph.I2SCFGR.CHLEN := Conf.Chan_Length = Channel_32bits;
This.Periph.I2SPR.MCKOE := Conf.Master_Clock_Out_Enabled;
This.Periph.CR2.TXDMAEN := Conf.Transmit_DMA_Enabled;
This.Periph.CR2.RXDMAEN := Conf.Receive_DMA_Enabled;
end Configure;
-----------------
-- In_I2S_Mode --
-----------------
function In_I2S_Mode (This : in out I2S_Port) return Boolean is
(This.Periph.I2SCFGR.I2SMOD);
------------
-- Enable --
------------
procedure Enable (This : in out I2S_Port) is
begin
if This.Periph.CR1.SPE then
raise Program_Error with "Device already enabled in SPI mode";
end if;
This.Periph.I2SCFGR.I2SMOD := True;
This.Periph.I2SCFGR.I2SE := True;
end Enable;
-------------
-- Disable --
-------------
procedure Disable (This : in out I2S_Port) is
begin
This.Periph.I2SCFGR.I2SE := False;
end Disable;
-------------
-- Enabled --
-------------
function Enabled (This : I2S_Port) return Boolean is
begin
return This.Periph.I2SCFGR.I2SE;
end Enabled;
---------------------------
-- Data_Register_Address --
---------------------------
function Data_Register_Address (This : I2S_Port)
return System.Address
is
begin
return This.Periph.DR'Address;
end Data_Register_Address;
-------------------
-- Set_Frequency --
-------------------
overriding
procedure Set_Frequency (This : in out I2S_Port;
Frequency : Audio_Frequency)
is
use STM32.Device;
I2SCLK : constant UInt32 := Get_Clock_Frequency (This);
Real_Divider : UInt32;
Packet_Len : constant UInt32 := (if This.Periph.I2SCFGR.DATLEN = 0
then 1 else 2);
Is_Odd : Boolean;
Divider : UInt32;
begin
if This.Periph.I2SPR.MCKOE then
Real_Divider := (I2SCLK / 256) * 10;
else
Real_Divider := (I2SCLK / (32 * Packet_Len)) * 10;
end if;
Real_Divider := ((Real_Divider / Frequency'Enum_Rep) + 5) / 10;
Is_Odd := Real_Divider mod 2 = 1;
if Is_Odd then
Divider := (Real_Divider - 1) / 2;
else
Divider := Real_Divider / 2;
end if;
if Divider < 2 or else Divider > 255 then
-- Value out of bounds, use default value
Divider := 2;
Is_Odd := False;
end if;
This.Periph.I2SPR.ODD := Is_Odd;
This.Periph.I2SPR.I2SDIV := UInt8 (Divider);
end Set_Frequency;
-------------
-- Receive --
-------------
overriding procedure Receive
(This : in out I2S_Port;
Data : out Audio_Buffer)
is
begin
for Elt of Data loop
while not This.Periph.SR.RXNE loop
null;
end loop;
Elt := To_Integer_16 (This.Periph.DR.DR);
end loop;
end Receive;
--------------
-- Transmit --
--------------
overriding procedure Transmit
(This : in out I2S_Port;
Data : Audio_Buffer)
is
begin
for Elt of Data loop
while not This.Periph.SR.TXE loop
null;
end loop;
This.Periph.DR.DR := To_UInt16 (Elt);
end loop;
end Transmit;
end STM32.I2S;
|
------------------------------------------------------------------------------
-- --
-- GNAT RUN-TIME LIBRARY (GNARL) COMPONENTS --
-- --
-- S Y S T E M . B B . B O A R D _ S U P P O R T . T I M E --
-- --
-- B o d y --
-- --
-- Copyright (C) 1999-2002 Universidad Politecnica de Madrid --
-- Copyright (C) 2003-2005 The European Space Agency --
-- Copyright (C) 2003-2017, AdaCore --
-- --
-- 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. --
-- --
-- The port of GNARL to bare board targets was initially developed by the --
-- Real-Time Systems Group at the Technical University of Madrid. --
-- --
------------------------------------------------------------------------------
-- For PowerPc: use time base and decrementer registers from the core
with System.Machine_Code; use System.Machine_Code;
separate (System.BB.Board_Support)
package body Time is
-----------------------
-- Local Definitions --
-----------------------
type Unsigned_32 is mod 2 ** 32;
for Unsigned_32'Size use 32;
-- Values of this type represent number of times that the clock finishes
-- its countdown. This type should allow atomic reads and updates.
function Read_TBL return Unsigned_32;
pragma Inline (Read_TBL);
-- Read the Time Base Lower word
function Read_TBU return Unsigned_32;
pragma Inline (Read_TBU);
-- Read the Time Base Upper word
----------------
-- Read_Clock --
----------------
function Read_Clock return BB.Time.Time is
use type BB.Time.Time;
Lo : Unsigned_32;
Hi : Unsigned_32;
Hi1 : Unsigned_32;
begin
-- We can't atomically read the 64-bits counter. So check that the
-- 32 MSB don't change.
Hi := Read_TBU;
loop
Lo := Read_TBL;
Hi1 := Read_TBU;
exit when Hi = Hi1;
Hi := Hi1;
end loop;
return (BB.Time.Time (Hi) * 2 ** 32) + BB.Time.Time (Lo);
end Read_Clock;
---------------------------
-- Install_Alarm_Handler --
---------------------------
procedure Install_Alarm_Handler
(Handler : BB.Interrupts.Interrupt_Handler) is
begin
CPU_Specific.Install_Exception_Handler
(Handler.all'Address, CPU_Specific.Decrementer_Excp);
end Install_Alarm_Handler;
--------------
-- Read_TBL --
--------------
function Read_TBL return Unsigned_32 is
Res : Unsigned_32;
begin
Asm ("mftbl %0",
Outputs => Unsigned_32'Asm_Output ("=r", Res),
Volatile => True);
return Res;
end Read_TBL;
--------------
-- Read_TBU --
--------------
function Read_TBU return Unsigned_32 is
Res : Unsigned_32;
begin
Asm ("mftbu %0",
Outputs => Unsigned_32'Asm_Output ("=r", Res),
Volatile => True);
return Res;
end Read_TBU;
---------------
-- Set_Alarm --
---------------
procedure Set_Alarm (Ticks : BB.Time.Time)
is
use BB.Time;
Now : constant BB.Time.Time := Read_Clock;
Diff : constant Unsigned_64 :=
(if Ticks > Now then Unsigned_64 (Ticks - Now) else 1);
Val : Unsigned_32;
begin
if Diff >= 2 ** 31 then
Val := 16#7FFF_FFFF#;
-- The maximum value that can be set in the DEC register. MSB must
-- not be set to avoid a useless interrupt (PowerPC triggers an
-- interrupt when the MSB switches from 0 to 1).
else
Val := Unsigned_32 (Diff);
end if;
Asm ("mtdec %0",
Inputs => Unsigned_32'Asm_Input ("r", Val),
Volatile => True);
end Set_Alarm;
---------------------------
-- Clear_Alarm_Interrupt --
---------------------------
procedure Clear_Alarm_Interrupt
renames BB.Board_Support.Clear_Alarm_Interrupt;
end Time;
|
------------------------------------------------------------------------------
-- --
-- GNAT COMPILER COMPONENTS --
-- --
-- M A K E U T L --
-- --
-- S p e c --
-- --
-- Copyright (C) 2004-2010, Free Software Foundation, Inc. --
-- --
-- GNAT is free software; you can redistribute it and/or modify it under --
-- terms of the GNU General Public License as published by the Free Soft- --
-- ware Foundation; either version 3, or (at your option) any later ver- --
-- sion. GNAT is distributed in the hope that it will be useful, but WITH- --
-- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY --
-- or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License --
-- for more details. You should have received a copy of the GNU General --
-- Public License distributed with GNAT; see file COPYING3. If not, go to --
-- http://www.gnu.org/licenses for a complete copy of the license. --
-- --
-- GNAT was originally developed by the GNAT team at New York University. --
-- Extensive contributions were provided by Ada Core Technologies Inc. --
-- --
------------------------------------------------------------------------------
with ALI;
with Namet; use Namet;
with Opt;
with Osint;
with Prj; use Prj;
with Prj.Tree;
with Types; use Types;
with GNAT.OS_Lib; use GNAT.OS_Lib;
package Makeutl is
type Fail_Proc is access procedure (S : String);
Do_Fail : Fail_Proc := Osint.Fail'Access;
-- Failing procedure called from procedure Test_If_Relative_Path below. May
-- be redirected.
Project_Tree : constant Project_Tree_Ref := new Project_Tree_Data;
-- The project tree
Source_Info_Option : constant String := "--source-info=";
-- Switch to indicate the source info file
Subdirs_Option : constant String := "--subdirs=";
-- Switch used to indicate that the real directories (object, exec,
-- library, ...) are subdirectories of those in the project file.
Unchecked_Shared_Lib_Imports : constant String :=
"--unchecked-shared-lib-imports";
-- Command line switch to allow shared library projects to import projects
-- that are not shared library projects.
Single_Compile_Per_Obj_Dir_Switch : constant String :=
"--single-compile-per-obj-dir";
-- Switch to forbid simultaneous compilations for the same object directory
-- when project files are used.
Create_Map_File_Switch : constant String := "--create-map-file";
-- Switch to create a map file when an executable is linked
procedure Add
(Option : String_Access;
To : in out String_List_Access;
Last : in out Natural);
procedure Add
(Option : String;
To : in out String_List_Access;
Last : in out Natural);
-- Add a string to a list of strings
function Create_Binder_Mapping_File return Path_Name_Type;
-- Create a binder mapping file and returns its path name
function Create_Name (Name : String) return File_Name_Type;
function Create_Name (Name : String) return Name_Id;
function Create_Name (Name : String) return Path_Name_Type;
-- Get an id for a name
function Base_Name_Index_For
(Main : String;
Main_Index : Int;
Index_Separator : Character) return File_Name_Type;
-- Returns the base name of Main, without the extension, followed by the
-- Index_Separator followed by the Main_Index if it is non-zero.
function Executable_Prefix_Path return String;
-- Return the absolute path parent directory of the directory where the
-- current executable resides, if its directory is named "bin", otherwise
-- return an empty string. When a directory is returned, it is guaranteed
-- to end with a directory separator.
procedure Inform (N : Name_Id := No_Name; Msg : String);
procedure Inform (N : File_Name_Type; Msg : String);
-- Prints out the program name followed by a colon, N and S
function File_Not_A_Source_Of
(Uname : Name_Id;
Sfile : File_Name_Type) return Boolean;
-- Check that file name Sfile is one of the source of unit Uname. Returns
-- True if the unit is in one of the project file, but the file name is not
-- one of its source. Returns False otherwise.
function Check_Source_Info_In_ALI
(The_ALI : ALI.ALI_Id;
Tree : Project_Tree_Ref) return Boolean;
-- Check whether all file references in ALI are still valid (i.e. the
-- source files are still associated with the same units). Return True
-- if everything is still valid.
function Is_External_Assignment
(Tree : Prj.Tree.Project_Node_Tree_Ref;
Argv : String) return Boolean;
-- Verify that an external assignment switch is syntactically correct
--
-- Correct forms are:
--
-- -Xname=value
-- -X"name=other value"
--
-- Assumptions: 'First = 1, Argv (1 .. 2) = "-X"
--
-- When this function returns True, the external assignment has been
-- entered by a call to Prj.Ext.Add, so that in a project file, External
-- ("name") will return "value".
procedure Verbose_Msg
(N1 : Name_Id;
S1 : String;
N2 : Name_Id := No_Name;
S2 : String := "";
Prefix : String := " -> ";
Minimum_Verbosity : Opt.Verbosity_Level_Type := Opt.Low);
procedure Verbose_Msg
(N1 : File_Name_Type;
S1 : String;
N2 : File_Name_Type := No_File;
S2 : String := "";
Prefix : String := " -> ";
Minimum_Verbosity : Opt.Verbosity_Level_Type := Opt.Low);
-- If the verbose flag (Verbose_Mode) is set and the verbosity level is at
-- least equal to Minimum_Verbosity, then print Prefix to standard output
-- followed by N1 and S1. If N2 /= No_Name then N2 is printed after S1. S2
-- is printed last. Both N1 and N2 are printed in quotation marks. The two
-- forms differ only in taking Name_Id or File_name_Type arguments.
function Linker_Options_Switches
(Project : Project_Id;
In_Tree : Project_Tree_Ref) return String_List;
-- Collect the options specified in the Linker'Linker_Options attributes
-- of project Project, in project tree In_Tree, and in the projects that
-- it imports directly or indirectly, and returns the result.
-- Package Mains is used to store the mains specified on the command line
-- and to retrieve them when a project file is used, to verify that the
-- files exist and that they belong to a project file.
function Unit_Index_Of (ALI_File : File_Name_Type) return Int;
-- Find the index of a unit in a source file. Return zero if the file is
-- not a multi-unit source file.
procedure Test_If_Relative_Path
(Switch : in out String_Access;
Parent : String;
Including_L_Switch : Boolean := True;
Including_Non_Switch : Boolean := True;
Including_RTS : Boolean := False);
-- Test if Switch is a relative search path switch. If it is, fail if
-- Parent is the empty string, otherwise prepend the path with Parent.
-- This subprogram is only called when using project files. For gnatbind
-- switches, Including_L_Switch is False, because the argument of the -L
-- switch is not a path. If Including_RTS is True, process also switches
-- --RTS=.
function Path_Or_File_Name (Path : Path_Name_Type) return String;
-- Returns a file name if -df is used, otherwise return a path name
-----------
-- Mains --
-----------
-- Mains are stored in a table. An index is used to retrieve the mains
-- from the table.
package Mains is
procedure Add_Main (Name : String);
-- Add one main to the table
procedure Set_Index (Index : Int);
procedure Set_Location (Location : Source_Ptr);
-- Set the location of the last main added. By default, the location is
-- No_Location.
procedure Delete;
-- Empty the table
procedure Reset;
-- Reset the index to the beginning of the table
function Next_Main return String;
-- Increase the index and return the next main. If table is exhausted,
-- return an empty string.
function Get_Index return Int;
function Get_Location return Source_Ptr;
-- Get the location of the current main
procedure Update_Main (Name : String);
-- Update the file name of the current main
function Number_Of_Mains return Natural;
-- Returns the number of mains added with Add_Main since the last call
-- to Delete.
end Mains;
----------------------
-- Marking Routines --
----------------------
procedure Mark (Source_File : File_Name_Type; Index : Int := 0);
-- Mark a unit, identified by its source file and, when Index is not 0, the
-- index of the unit in the source file. Marking is used to signal that the
-- unit has already been inserted in the Q.
function Is_Marked
(Source_File : File_Name_Type;
Index : Int := 0) return Boolean;
-- Returns True if the unit was previously marked
procedure Delete_All_Marks;
-- Remove all file/index couples marked
end Makeutl;
|
with Ada.Exceptions;
with ACO.States;
package body ACO.Protocols.Service_Data is
procedure Indicate_Status
(This : in out SDO'Class;
Session : in ACO.SDO_Sessions.SDO_Session;
Status : in ACO.SDO_Sessions.SDO_Status)
is
begin
This.Sessions.Put (Session);
if Status in ACO.SDO_Sessions.SDO_Result then
This.Result_Callback (Session, Status);
end if;
end Indicate_Status;
overriding
procedure Signal
(This : access Alarm;
T_Now : in Ada.Real_Time.Time)
is
pragma Unreferenced (T_Now);
Session : constant ACO.SDO_Sessions.SDO_Session :=
This.SDO_Ref.Sessions.Get (This.Id);
begin
This.SDO_Ref.SDO_Log
(ACO.Log.Info,
"Session timed out for service " & Session.Service'Img & This.Id'Img);
This.SDO_Ref.Send_Abort
(Endpoint => Session.Endpoint,
Error => SDO_Protocol_Timed_Out,
Index => Session.Index);
This.SDO_Ref.Indicate_Status (Session, ACO.SDO_Sessions.Error);
end Signal;
procedure Start_Alarm
(This : in out SDO;
Id : in ACO.SDO_Sessions.Valid_Endpoint_Nr)
is
use Ada.Real_Time, ACO.Configuration;
Timeout_Alarm : Alarm renames This.Alarms (Id);
begin
if This.Timers.Is_Pending (Timeout_Alarm'Unchecked_Access) then
This.Timers.Cancel (Timeout_Alarm'Unchecked_Access);
end if;
Timeout_Alarm.Id := Id;
This.Timers.Set
(Alarm => Timeout_Alarm'Unchecked_Access,
Signal_Time =>
This.Handler.Current_Time + Milliseconds (SDO_Session_Timeout_Ms));
end Start_Alarm;
procedure Stop_Alarm
(This : in out SDO;
Id : in ACO.SDO_Sessions.Valid_Endpoint_Nr)
is
begin
This.Timers.Cancel (This.Alarms (Id)'Unchecked_Access);
end Stop_Alarm;
procedure Send_Abort
(This : in out SDO;
Endpoint : in ACO.SDO_Sessions.Endpoint_Type;
Error : in Error_Type;
Index : in ACO.OD_Types.Entry_Index := (0,0))
is
use ACO.SDO_Commands;
Cmd : constant Abort_Cmd := Create (Index, Abort_Code (Error));
begin
This.SDO_Log (ACO.Log.Warning, "Aborting: " & Error'Img);
This.Send_SDO (Endpoint, Cmd.Raw);
end Send_Abort;
procedure Write
(This : in out SDO;
Index : in ACO.OD_Types.Entry_Index;
Data : in ACO.Messages.Data_Array;
Error : out Error_Type)
is
-- TODO:
-- Need a more efficient way to write large amount of data (Domain type)
Ety : ACO.OD_Types.Entry_Base'Class :=
This.Od.Get_Entry (Index.Object, Index.Sub);
begin
Ety.Write (ACO.OD_Types.Byte_Array (Data));
This.Od.Set_Entry (Ety, Index.Object, Index.Sub);
Error := Nothing;
exception
when E : others =>
Error := Failed_To_Transfer_Or_Store_Data;
This.SDO_Log (ACO.Log.Debug, Ada.Exceptions.Exception_Name (E));
end Write;
procedure Send_SDO
(This : in out SDO'Class;
Endpoint : in ACO.SDO_Sessions.Endpoint_Type;
Raw_Data : in ACO.Messages.Msg_Data)
is
Msg : constant ACO.Messages.Message :=
ACO.Messages.Create
(CAN_Id => This.Tx_CAN_Id (Endpoint.Parameters),
RTR => False,
DLC => 8,
Data => Raw_Data);
CS : constant Interfaces.Unsigned_32 :=
Interfaces.Unsigned_32 (SDO_Commands.Get_CS (Msg));
begin
This.SDO_Log (ACO.Log.Debug, "Sending command with cs = " & Hex_Str (CS));
This.Handler.Put (Msg);
end Send_SDO;
function Hex_Str
(X : Interfaces.Unsigned_32;
Trim : Boolean := True)
return String
is
use type Interfaces.Unsigned_32;
Chars : constant String := "0123456789abcdef";
N : Interfaces.Unsigned_32 := X;
Res : String (1 .. 10) := "0000000000";
I : Natural := Res'Last;
begin
loop
Res (I) := Chars (Natural (N mod 16) + 1);
N := N / 16;
exit when N = 0;
I := I - 1;
end loop;
if Trim then
Res (I - 1) := 'x';
return Res (I - 2 .. Res'Last);
else
Res (2) := 'x';
return Res;
end if;
end Hex_Str;
procedure Abort_All
(This : in out SDO;
Msg : in ACO.Messages.Message;
Endpoint : in ACO.SDO_Sessions.Endpoint_Type)
is
use ACO.SDO_Commands;
use type ACO.SDO_Commands.Abort_Code_Type;
Resp : constant Abort_Cmd := Convert (Msg);
Error : Error_Type := Unknown;
begin
for E in Error_Type'Range loop
if Abort_Code (E) = Code (Resp) then
Error := E;
exit;
end if;
end loop;
This.SDO_Log
(ACO.Log.Error,
Error'Img & " (" & Hex_Str (Code (Resp), Trim => False) & ") on" &
ACO.SDO_Sessions.Image (Endpoint));
This.Stop_Alarm (Endpoint.Id);
This.Indicate_Status
(Session => This.Sessions.Get (Endpoint.Id),
Status => ACO.SDO_Sessions.Error);
end Abort_All;
overriding
function Is_Valid
(This : in out SDO;
Msg : in ACO.Messages.Message)
return Boolean
is
begin
return SDO'Class (This).Get_Endpoint (ACO.Messages.CAN_Id (Msg)).Id /=
ACO.SDO_Sessions.No_Endpoint_Id;
end Is_Valid;
procedure Message_Received
(This : in out SDO'Class;
Msg : in ACO.Messages.Message)
is
use ACO.States;
begin
case This.Od.Get_Node_State is
when Initializing | Unknown_State | Stopped =>
return;
when Pre_Operational | Operational =>
null;
end case;
declare
Endpoint : constant ACO.SDO_Sessions.Endpoint_Type :=
This.Get_Endpoint (Rx_CAN_Id => ACO.Messages.CAN_Id (Msg));
begin
This.Handle_Message (Msg, Endpoint);
end;
end Message_Received;
procedure Clear
(This : in out SDO;
Id : in ACO.SDO_Sessions.Valid_Endpoint_Nr)
is
begin
This.Sessions.Clear (Id);
end Clear;
procedure Periodic_Actions
(This : in out SDO;
T_Now : in Ada.Real_Time.Time)
is
begin
This.Timers.Process (T_Now);
end Periodic_Actions;
procedure SDO_Log
(This : in out SDO;
Level : in ACO.Log.Log_Level;
Message : in String)
is
pragma Unreferenced (This);
begin
ACO.Log.Put_Line (Level, "(SDO) " & Message);
end SDO_Log;
end ACO.Protocols.Service_Data;
|
-----------------------------------------------------------------------
-- awa -- Ada Web Application
-- Copyright (C) 2009, 2010, 2011, 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 ASF.Requests;
with ASF.Responses;
with ASF.Server;
with Ada.IO_Exceptions;
with Util.Files;
with Util.Properties;
with EL.Contexts.Default;
with AWA.Modules.Reader;
with AWA.Applications;
package body AWA.Modules is
-- ------------------------------
-- Get the module name
-- ------------------------------
function Get_Name (Plugin : in Module) return String is
begin
return To_String (Plugin.Name);
end Get_Name;
-- ------------------------------
-- Get the base URI for this module
-- ------------------------------
function Get_URI (Plugin : in Module) return String is
begin
return To_String (Plugin.URI);
end Get_URI;
-- ------------------------------
-- Get the application in which this module is registered.
-- ------------------------------
function Get_Application (Plugin : in Module) return Application_Access is
begin
return Plugin.App;
end Get_Application;
-- ------------------------------
-- Get the module configuration property identified by the name.
-- If the configuration property does not exist, returns the default value.
-- ------------------------------
function Get_Config (Plugin : Module;
Name : String;
Default : String := "") return String is
begin
return Plugin.Config.Get (Name, Default);
end Get_Config;
-- ------------------------------
-- Get the module configuration property identified by the name.
-- If the configuration property does not exist, returns the default value.
-- ------------------------------
function Get_Config (Plugin : in Module;
Name : in String;
Default : in Integer := -1) return Integer is
Value : constant String := Plugin.Config.Get (Name, Integer'Image (Default));
begin
return Integer'Value (Value);
exception
when Constraint_Error =>
return Default;
end Get_Config;
-- ------------------------------
-- Get the module configuration property identified by the <tt>Config</tt> parameter.
-- If the property does not exist, the default configuration value is returned.
-- ------------------------------
function Get_Config (Plugin : in Module;
Config : in ASF.Applications.Config_Param) return String is
begin
return Plugin.Config.Get (Config);
end Get_Config;
-- ------------------------------
-- Send the event to the module
-- ------------------------------
procedure Send_Event (Plugin : in Module;
Content : in AWA.Events.Module_Event'Class) is
begin
Plugin.App.Send_Event (Content);
end Send_Event;
-- ------------------------------
-- Find the module with the given name
-- ------------------------------
function Find_Module (Plugin : Module;
Name : String) return Module_Access is
begin
if Plugin.Registry = null then
return null;
end if;
return Find_By_Name (Plugin.Registry.all, Name);
end Find_Module;
-- ------------------------------
-- Register under the given name a function to create the bean instance when
-- it is accessed for a first time. The scope defines the scope of the bean.
-- bean
-- ------------------------------
procedure Register (Plugin : in out Module;
Name : in String;
Bind : in ASF.Beans.Class_Binding_Access) is
begin
Plugin.App.Register_Class (Name, Bind);
end Register;
-- ------------------------------
-- Finalize the module.
-- ------------------------------
overriding
procedure Finalize (Plugin : in out Module) is
begin
null;
end Finalize;
procedure Initialize (Manager : in out Module_Manager;
Module : in AWA.Modules.Module'Class) is
begin
Manager.Module := Module.Self;
end Initialize;
function Get_Value (Manager : in Module_Manager;
Name : in String) return Util.Beans.Objects.Object is
pragma Unreferenced (Manager, Name);
begin
return Util.Beans.Objects.Null_Object;
end Get_Value;
-- Module manager
--
-- ------------------------------
-- Get the database connection for reading
-- ------------------------------
function Get_Session (Manager : Module_Manager)
return ADO.Sessions.Session is
begin
return Manager.Module.Get_Session;
end Get_Session;
-- ------------------------------
-- Get the database connection for writing
-- ------------------------------
function Get_Master_Session (Manager : Module_Manager)
return ADO.Sessions.Master_Session is
begin
return Manager.Module.Get_Master_Session;
end Get_Master_Session;
-- ------------------------------
-- Send the event to the module. The module identified by <b>To</b> is
-- found and the event is posted on its event channel.
-- ------------------------------
procedure Send_Event (Manager : in Module_Manager;
Content : in AWA.Events.Module_Event'Class) is
begin
Manager.Module.Send_Event (Content);
end Send_Event;
procedure Initialize (Plugin : in out Module;
App : in Application_Access;
Props : in ASF.Applications.Config) is
pragma Unreferenced (Props);
begin
Plugin.Self := Plugin'Unchecked_Access;
Plugin.App := App;
end Initialize;
-- ------------------------------
-- Initialize the registry
-- ------------------------------
procedure Initialize (Registry : in out Module_Registry;
Config : in ASF.Applications.Config) is
begin
Registry.Config := Config;
end Initialize;
-- ------------------------------
-- Register the module in the registry.
-- ------------------------------
procedure Register (Registry : in Module_Registry_Access;
App : in Application_Access;
Plugin : in Module_Access;
Name : in String;
URI : in String) is
procedure Copy (Params : in Util.Properties.Manager'Class);
procedure Copy (Params : in Util.Properties.Manager'Class) is
begin
Plugin.Config.Copy (From => Params, Prefix => Name & ".", Strip => True);
end Copy;
Paths : constant String := Registry.Config.Get (Applications.P_Module_Dir.P);
begin
Log.Info ("Register module '{0}' under URI '{1}'", Name, URI);
if Plugin.Registry /= null then
Log.Error ("Module '{0}' is already attached to a registry", Name);
raise Program_Error with "Module '" & Name & "' already registered";
end if;
Plugin.App := App;
Plugin.Registry := Registry;
Plugin.Name := To_Unbounded_String (Name);
Plugin.URI := To_Unbounded_String (URI);
Plugin.Registry.Name_Map.Insert (Name, Plugin);
if URI /= "" then
Plugin.Registry.URI_Map.Insert (URI, Plugin);
end if;
-- Load the module configuration file
Log.Debug ("Module search path: {0}", Paths);
declare
Base : constant String := Name & ".properties";
Path : constant String := Util.Files.Find_File_Path (Base, Paths);
begin
Plugin.Config.Load_Properties (Path => Path, Prefix => Name & ".", Strip => True);
exception
when Ada.IO_Exceptions.Name_Error =>
Log.Info ("Module configuration file '{0}' does not exist", Path);
end;
Plugin.Initialize (App, Plugin.Config);
-- Read the module XML configuration file if there is one.
declare
Base : constant String := Plugin.Config.Get ("config", Name & ".xml");
Path : constant String := Util.Files.Find_File_Path (Base, Paths);
Ctx : aliased EL.Contexts.Default.Default_Context;
begin
AWA.Modules.Reader.Read_Configuration (Plugin.all, Path, Ctx'Unchecked_Access);
exception
when Ada.IO_Exceptions.Name_Error =>
Log.Warn ("Module configuration file '{0}' does not exist", Path);
end;
-- Override the module configuration with the application configuration
App.Get_Init_Parameters (Copy'Access);
Plugin.Configure (Plugin.Config);
exception
when Constraint_Error =>
Log.Error ("Another module is already registered "
& "under name '{0}' or URI '{1}'", Name, URI);
raise;
end Register;
-- ------------------------------
-- Find the module with the given name
-- ------------------------------
function Find_By_Name (Registry : Module_Registry;
Name : String) return Module_Access is
Pos : constant Module_Maps.Cursor := Module_Maps.Find (Registry.Name_Map, Name);
begin
if Module_Maps.Has_Element (Pos) then
return Module_Maps.Element (Pos);
end if;
return null;
end Find_By_Name;
-- ------------------------------
-- Find the module mapped to a given URI
-- ------------------------------
function Find_By_URI (Registry : Module_Registry;
URI : String) return Module_Access is
Pos : constant Module_Maps.Cursor := Module_Maps.Find (Registry.URI_Map, URI);
begin
if Module_Maps.Has_Element (Pos) then
return Module_Maps.Element (Pos);
end if;
return null;
end Find_By_URI;
-- ------------------------------
-- Iterate over the modules that have been registered and execute the <b>Process</b>
-- procedure on each of the module instance.
-- ------------------------------
procedure Iterate (Registry : in Module_Registry;
Process : access procedure (Plugin : in out Module'Class)) is
Iter : Module_Maps.Cursor := Registry.Name_Map.First;
begin
while Module_Maps.Has_Element (Iter) loop
Process (Module_Maps.Element (Iter).all);
Module_Maps.Next (Iter);
end loop;
end Iterate;
-- ------------------------------
-- Get the database connection for reading
-- ------------------------------
function Get_Session (Manager : Module)
return ADO.Sessions.Session is
begin
return Manager.App.Get_Session;
end Get_Session;
-- ------------------------------
-- Get the database connection for writing
-- ------------------------------
function Get_Master_Session (Manager : Module)
return ADO.Sessions.Master_Session is
begin
return Manager.App.Get_Master_Session;
end Get_Master_Session;
-- ------------------------------
-- Add a listener to the module listner list. The module will invoke the listner
-- depending on events or actions that occur in the module.
-- ------------------------------
procedure Add_Listener (Into : in out Module;
Item : in Util.Listeners.Listener_Access) is
begin
Util.Listeners.Add_Listener (Into.Listeners, Item);
end Add_Listener;
-- ------------------------------
-- Remove a listener from the module listener list.
-- ------------------------------
procedure Remove_Listener (Into : in out Module;
Item : in Util.Listeners.Listener_Access) is
begin
Util.Listeners.Remove_Listener (Into.Listeners, Item);
end Remove_Listener;
-- Get per request manager => look in Request
-- Get per session manager => look in Request.Get_Session
-- Get per application manager => look in Application
-- Get per pool manager => look in pool attached to Application
function Get_Manager return Manager_Type_Access is
procedure Process (Request : in out ASF.Requests.Request'Class;
Response : in out ASF.Responses.Response'Class);
Value : Util.Beans.Objects.Object;
procedure Process (Request : in out ASF.Requests.Request'Class;
Response : in out ASF.Responses.Response'Class) is
pragma Unreferenced (Response);
begin
Value := Request.Get_Attribute (Name);
if Util.Beans.Objects.Is_Null (Value) then
declare
M : constant Manager_Type_Access := new Manager_Type;
begin
Value := Util.Beans.Objects.To_Object (M.all'Unchecked_Access);
Request.Set_Attribute (Name, Value);
end;
end if;
end Process;
begin
ASF.Server.Update_Context (Process'Access);
if Util.Beans.Objects.Is_Null (Value) then
return null;
end if;
declare
B : constant access Util.Beans.Basic.Readonly_Bean'Class
:= Util.Beans.Objects.To_Bean (Value);
begin
if not (B.all in Manager_Type'Class) then
return null;
end if;
return Manager_Type'Class (B.all)'Unchecked_Access;
end;
end Get_Manager;
end AWA.Modules;
|
with Ada.Text_IO, Ada.Command_Line;
procedure cmd is
primeNumberCount : Integer := 100;
j, number: Integer;
begin
if Ada.Command_Line.Argument_Count = 1 then
primeNumberCount := Integer'Value(Ada.Command_Line.Argument(1));
end if;
number := 0;
while primeNumberCount > 0 loop
number := number + 1;
j := 0;
for i in 1 .. number loop
if number mod i = 0 then
j := j + 1;
end if;
end loop;
if j = 2 then
primeNumberCount := primeNumberCount - 1;
end if;
end loop;
Ada.Text_IO.Put_Line("The latest prime number: " & Integer'Image(number));
end cmd;
|
-----------------------------------------------------------------------
-- swagger-credentials-oauth -- OAuth2 client credentials
-- Copyright (C) 2018 Stephane Carrez
-- Written by Stephane Carrez (Stephane.Carrez@gmail.com)
--
-- Licensed under the Apache License, Version 2.0 (the "License");
-- you may not use this file except in compliance with the License.
-- You may obtain a copy of the License at
--
-- http://www.apache.org/licenses/LICENSE-2.0
--
-- Unless required by applicable law or agreed to in writing, software
-- distributed under the License is distributed on an "AS IS" BASIS,
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-- See the License for the specific language governing permissions and
-- limitations under the License.
-----------------------------------------------------------------------
with Util.Http.Clients;
with Security.OAuth.Clients;
package Swagger.Credentials.OAuth is
type OAuth2_Credential_Type is new Security.OAuth.Clients.Application
and Credential_Type with private;
-- Set the credendials on the HTTP client request before doing the call.
overriding
procedure Set_Credentials (Credential : in OAuth2_Credential_Type;
Into : in out Util.Http.Clients.Client'Class);
-- Request a OAuth token with username and password credential.
-- Upon successful completion, the credential contains an access token that
-- can be used to authorize REST operations.
procedure Request_Token (Credential : in out OAuth2_Credential_Type;
Username : in String;
Password : in String;
Scope : in String);
-- Refresh the OAuth access token with the refresh token.
procedure Refresh_Token (Credential : in out OAuth2_Credential_Type);
private
type OAuth2_Credential_Type is new Security.OAuth.Clients.Application
and Credential_Type with record
Token : Security.OAuth.Clients.Grant_Type;
Scope : Ada.Strings.Unbounded.Unbounded_String;
end record;
end Swagger.Credentials.OAuth;
|
-----------------------------------------------------------------------
-- components -- Component tree
-- Copyright (C) 2009, 2010, 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.
-----------------------------------------------------------------------
-- The <bASF.Components</b> describes the components that form the
-- tree view. Each component has attributes and children. Children
-- represent sub-components and attributes control the rendering and
-- behavior of the component.
--
-- The component tree is created from the <b>ASF.Views</b> tag nodes
-- for each request. Unlike tag nodes, the component tree is not shared.
with Ada.Strings.Unbounded;
with EL.Objects;
with EL.Expressions;
limited with ASF.Views.Nodes;
package ASF.Components is
use Ada.Strings.Unbounded;
-- Flag indicating whether or not this component should be rendered
-- (during Render Response Phase), or processed on any subsequent form submit.
-- The default value for this property is true.
RENDERED_NAME : constant String := "rendered";
-- A localized user presentable name for the component.
LABEL_NAME : constant String := "label";
-- Converter instance registered with the component.
CONVERTER_NAME : constant String := "converter";
-- A ValueExpression enabled attribute that, if present, will be used as the text
-- of the converter message, replacing any message that comes from the converter.
CONVERTER_MESSAGE_NAME : constant String := "converterMessage";
-- A ValueExpression enabled attribute that, if present, will be used as the text
-- of the validator message, replacing any message that comes from the validator.
VALIDATOR_MESSAGE_NAME : constant String := "validatorMessage";
-- Flag indicating that the user is required to provide a submitted value for
-- the input component.
REQUIRED_NAME : constant String := "required";
-- A ValueExpression enabled attribute that, if present, will be used as the
-- text of the validation message for the "required" facility, if the "required"
-- facility is used.
REQUIRED_MESSAGE_NAME : constant String := "requiredMessage";
-- The current value of the component.
VALUE_NAME : constant String := "value";
ACTION_NAME : constant String := "action";
-- ------------------------------
-- Attribute of a component
-- ------------------------------
type UIAttribute is private;
private
type UIAttribute_Access is access all UIAttribute;
type UIAttribute is record
Definition : access ASF.Views.Nodes.Tag_Attribute;
Name : Unbounded_String;
Value : EL.Objects.Object;
Expr : EL.Expressions.Expression;
Next_Attr : UIAttribute_Access;
end record;
end ASF.Components;
|
-----------------------------------------------------------------------
-- GtkAda - Ada95 binding for Gtk+/Gnome --
-- --
-- Copyright (C) 1998-2000 E. Briot, J. Brobecker and A. Charlet --
-- Copyright (C) 2000-2006 AdaCore --
-- --
-- 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. --
-----------------------------------------------------------------------
-- <description>
--
-- This widget is a container that catches events for its child when its
-- child does not have its own window (like a Gtk_Scrolled_Window or a
-- Gtk_Label for instance).
-- Some widgets in GtkAda do not have their own window, and thus can not
-- directly get events from the server. The Gtk_Event_Box widget can be
-- used to force its child to receive events anyway.
--
-- For instance, this widget is used internally in a Gtk_Combo_Box so that
-- the application can change the cursor when the mouse is in the popup
-- window. In that case, it contains a frame, that itself contains the
-- scrolled window of the popup.
--
-- </description>
-- <c_version>2.8.17</c_version>
-- <group>Layout containers</group>
with Glib.Properties;
with Gtk.Bin;
package Gtk.Event_Box is
type Gtk_Event_Box_Record is new Gtk.Bin.Gtk_Bin_Record with private;
type Gtk_Event_Box is access all Gtk_Event_Box_Record'Class;
procedure Gtk_New (Event_Box : out Gtk_Event_Box);
-- Create a new box.
-- The box's child can then be set using the Gtk.Container.Add function.
procedure Initialize (Event_Box : access Gtk_Event_Box_Record'Class);
-- Internal initialization function.
-- See the section "Creating your own widgets" in the documentation.
function Get_Type return Gtk.Gtk_Type;
-- Return the internal value associated with a Gtk_Event_Box.
procedure Set_Visible_Window
(Event_Box : access Gtk_Event_Box_Record;
Visible_Window : Boolean);
function Get_Visible_Window
(Event_Box : access Gtk_Event_Box_Record) return Boolean;
-- Set whether the event box uses a visible or invisible child window. The
-- default is to use visible windows
-- Except if you want to explicitly change the background, or explicitly
-- draw on it, you should make the event box invisible.
procedure Set_Above_Child
(Event_Box : access Gtk_Event_Box_Record;
Above_Child : Boolean);
function Get_Above_Child
(Event_Box : access Gtk_Event_Box_Record) return Boolean;
-- Set whether the event box window is positioned above the windows of its
-- child, as opposed to below it. If the window is above, all events inside
-- the event box will go to the event box. If the window is below, events
-- in windows of child widgets will first go to that widget, and then to
-- its parent. The default is to keep the window below the child.
----------------
-- Properties --
----------------
-- <properties>
-- The following properties are defined for this widget. See
-- Glib.Properties for more information on properties.
--
-- Name: Above_Child_Property
-- Type: Boolean
-- Descr: Whether the event-trapping window of the eventbox is above the
-- window of the child widget as opposed to below it.
--
-- Name: Visible_Window_Property
-- Type: Boolean
-- Descr: Whether the event box is visible, as opposed to invisible and
-- only used to trap events.
--
-- </properties>
Above_Child_Property : constant Glib.Properties.Property_Boolean;
Visible_Window_Property : constant Glib.Properties.Property_Boolean;
-------------
-- Signals --
-------------
-- <signals>
-- The following new signals are defined for this widget:
-- </signals>
private
type Gtk_Event_Box_Record is new Gtk.Bin.Gtk_Bin_Record with null record;
Above_Child_Property : constant Glib.Properties.Property_Boolean :=
Glib.Properties.Build ("above-child");
Visible_Window_Property : constant Glib.Properties.Property_Boolean :=
Glib.Properties.Build ("visible-window");
pragma Import (C, Get_Type, "gtk_event_box_get_type");
end Gtk.Event_Box;
|
package body Impact.d2
--
-- A port of the Box2D physics engine.
--
is
function b2MixFriction (Friction1, Friction2 : float32) return float32
is
use float_math.Functions;
begin
return SqRt (friction1 * friction2);
end b2MixFriction;
function b2MixRestitution (restitution1, restitution2 : float32) return float32
is
begin
if restitution1 > restitution2 then return restitution1;
else return restitution2;
end if;
end b2MixRestitution;
procedure swap_any (a, b : in out T)
is
Pad : constant T := a;
begin
a := b;
b := Pad;
end swap_any;
end Impact.d2;
|
with Test;
with OpenAL.Context;
with OpenAL.Context.Error;
procedure init_002 is
package ALC renames OpenAL.Context;
package ALC_Error renames OpenAL.Context.Error;
Device : ALC.Device_t;
Context : ALC.Context_t;
OK : Boolean;
TC : Test.Context_t;
use type ALC.Device_t;
use type ALC.Context_t;
use type ALC_Error.Error_t;
begin
Test.Initialize
(Test_Context => TC,
Program => "init_002",
Test_DB => "TEST_DB",
Test_Results => "TEST_RESULTS");
Device := ALC.Open_Default_Device;
pragma Assert (Device /= ALC.Invalid_Device);
pragma Assert (ALC_Error.Get_Error (Device) = ALC_Error.No_Error);
Context := ALC.Create_Context (Device);
pragma Assert (Context /= ALC.Invalid_Context);
pragma Assert (ALC_Error.Get_Error (Device) = ALC_Error.No_Error);
OK := ALC.Make_Context_Current (Context);
pragma Assert (OK);
pragma Assert (ALC_Error.Get_Error (Device) = ALC_Error.No_Error);
OK := ALC.Make_Context_Current (ALC.Null_Context);
pragma Assert (OK);
pragma Assert (ALC_Error.Get_Error (Device) = ALC_Error.No_Error);
--
-- According to the 1.1 spec, this should return False.
-- Unfortunately, no implementation actually does that...
--
ALC.Close_Device (Device);
Test.Check (TC, 11, Device = ALC.Invalid_Device, "Device = ALC.Invalid_Device");
end init_002;
|
with
float_Math.Geometry .d2,
float_Math.Geometry .d3,
float_math.Algebra.linear.d3;
package Gasp
--
-- Provides a namespace and core declarations for the 'Gasp' game.
--
is
pragma Pure;
package Math renames float_Math;
package Geometry_2d renames Math.Geometry.d2;
package Geometry_3d renames Math.Geometry.d3;
package linear_Algebra_3d renames Math.Algebra.linear.d3;
end Gasp;
|
------------------------------------------------------------------------------
-- Copyright (c) 2011, Natacha Porté --
-- --
-- Permission to use, copy, modify, and distribute this software for any --
-- purpose with or without fee is hereby granted, provided that the above --
-- copyright notice and this permission notice appear in all copies. --
-- --
-- THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES --
-- WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF --
-- MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR --
-- ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES --
-- WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN --
-- ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF --
-- OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. --
------------------------------------------------------------------------------
------------------------------------------------------------------------------
-- Natools.Tests is an abstract interface for objects holding the results --
-- of a series of tests. --
-- --
-- Each test can have one of the following results: --
-- * Success, when everything goes well, --
-- * Fail, when the test itself went fine the but the result is wrong, --
-- * Error, when the test itself went wrong, which does not tell whether --
-- the tested thing is fine or not, --
-- * Skipped, when for any reason the test has not been performed --
-- (e.g. missing dependency). --
-- --
-- Tests are gathered into sections, which can be nested. What a section --
-- exactly means is left to the implementation of this interface. --
------------------------------------------------------------------------------
with Ada.Exceptions;
private with Ada.Finalization;
private with Ada.Strings.Unbounded;
private with Ada.Containers.Indefinite_Doubly_Linked_Lists;
package Natools.Tests is
pragma Preelaborate (Tests);
type Reporter is interface;
type Result is (Success, Fail, Error, Skipped);
type Result_Summary is array (Result) of Natural;
procedure Section (Report : in out Reporter; Name : String) is abstract;
procedure End_Section (Report : in out Reporter) is abstract;
-- These procedures change the internal state of Report to respectively
-- enter and leave a (sub)section.
procedure Item
(Report : in out Reporter;
Name : in String;
Outcome : in Result)
is abstract;
-- Append a new test item (with its outcome) to the current section
-- of Report.
procedure Info (Report : in out Reporter; Text : String) is abstract;
-- Append free informational text related to the previous Item appended.
function Current_Results (Report : Reporter) return Result_Summary
is abstract;
-- Return the number of each result type in the current section.
function Total_Results (Report : Reporter) return Result_Summary
is abstract;
-- Return the total number of each result type in the current section.
function To_Result (Succeeded : Boolean) return Result;
-- Return Success or Fail depending on the Boolean input.
Max_Result_String_Size : constant Positive := 7;
-- Maximum length of any string returned by Result'Image.
------------------------
-- Helper subprograms --
------------------------
procedure Report_Exception
(Report : in out Reporter'Class;
Test_Name : String;
Ex : Ada.Exceptions.Exception_Occurrence;
Code : Result := Error);
-- Append to Report a new Item, whose result is Code, along with
-- a description of the exception Ex as Info entries.
-----------------
-- Test Object --
-----------------
type Test (<>) is tagged limited private;
-- An object of type Test hold information about a single test.
-- It contains a reference to a Reporter object, which is filled with
-- held info when the Test object is finalized.
function Item
(Report : access Reporter'Class;
Name : String;
Default_Outcome : Result := Success)
return Test;
-- Create a new Test object with the given Name
procedure Set_Result (Object : in out Test; Outcome : in Result);
-- Set the test result
procedure Info (Object : in out Test; Text : in String);
-- Append the given text as extra information related to the test
procedure Report_Exception
(Object : in out Test;
Ex : in Ada.Exceptions.Exception_Occurrence;
Code : in Result := Error);
-- Append information about Ex to the test and set its result state
procedure Fail (Object : in out Test; Text : in String := "");
procedure Error (Object : in out Test; Text : in String := "");
procedure Skip (Object : in out Test; Text : in String := "");
-- Set the result state and append Text info in a single call
generic
type Result (<>) is limited private;
with function "=" (Left, Right : Result) return Boolean is <>;
with function Image (Object : Result) return String is <>;
Multiline : Boolean := True;
procedure Generic_Check
(Object : in out Test;
Expected : in Result;
Found : in Result;
Label : in String := "");
private
package Info_Lists is new Ada.Containers.Indefinite_Doubly_Linked_Lists
(String);
type Test (Report : access Reporter'Class) is
new Ada.Finalization.Limited_Controlled with record
Name : Ada.Strings.Unbounded.Unbounded_String;
Info : Info_Lists.List;
Outcome : Result;
Finalized : Boolean := False;
end record;
overriding procedure Finalize (Object : in out Test);
end Natools.Tests;
|
with gnat.command_line;
use gnat.command_line;
package body commandline_args is
procedure initialize is
procedure validate_int_initialization(x : integer; name : string) is
begin
if x = int_no_value then
raise argument_missing with name;
end if;
end;
procedure int_exception(name : string; text : in string; val : in out integer) is
begin
val := integer'value(text);
exception
when constraint_error =>
raise argument_missing with name;
end;
begin
-- Boucle d'obtention des paramètres
loop
case getopt("t: w: l: q: h: b: f: r: -fill: -border: -show-debug -log: -help -pattern:") is
when 't' =>
int_exception("t", parameter, t);
when 'w' =>
int_exception("w", parameter, w);
when 'l' =>
int_exception("l", parameter, l);
when 'q' =>
int_exception("q", parameter, q);
when 'h' =>
int_exception("h", parameter, h);
when 'b' =>
int_exception("b", parameter, b);
when 'f' =>
f := to_unbounded_string(parameter);
when '-' =>
if full_switch = "-fill" then
fill_color := to_unbounded_string(parameter);
elsif full_switch = "-border" then
border_color := to_unbounded_string(parameter);
elsif full_switch = "-help" then
show_help := true;
elsif full_switch = "-show-debug" then
show_debug := true;
elsif full_switch = "-log" then
log_file := to_unbounded_string(parameter);
elsif full_switch = "-pattern" then
pattern := to_unbounded_string(parameter);
end if;
when others =>
exit;
end case;
end loop;
-- Vérification de la validité des paramètres saisis
validate_int_initialization(t, "t");
validate_int_initialization(w, "w");
validate_int_initialization(l, "l");
validate_int_initialization(q, "q");
validate_int_initialization(h, "h");
validate_int_initialization(b, "b");
if f = null_unbounded_string then
raise argument_missing with "f";
end if;
end;
-- obtient le paramètre t
function get_t return integer is
begin
return t;
end;
-- obtient le paramètre l
function get_l return integer is
begin
return l;
end;
-- obtient le paramètre w
function get_w return integer is
begin
return w;
end;
-- obtient le paramètre q
function get_q return integer is
begin
return q;
end;
-- obtient le paramètre h
function get_h return integer is
begin
return h;
end;
-- obtient le paramètre b
function get_b return integer is
begin
return b;
end;
-- obtient le paramètre f
function get_f return string is
begin
return to_string(f);
end;
-- obtient le paramètre fill
function get_fill_color return string is
begin
return to_string(fill_color);
end;
-- obtient le paramètre border
function get_border_color return string is
begin
return to_string(border_color);
end;
-- obtient le paramètre help
function get_show_help return boolean is
begin
return show_help;
end;
-- obtient le paramètre debug
function get_show_debug return boolean is
begin
return show_debug;
end;
-- obtient le paramètre log
function get_log_file return string is
begin
return to_string(log_file);
end;
-- obtient le paramètre pattern
function get_pattern return string is
begin
return to_string(pattern);
end;
end commandline_args;
|
with Ada.Directories;
package Ch_Conn is
procedure Rejoin_Channels (Irc_Dir : String);
procedure Scan_Server (Srv_Dir : Ada.Directories.Directory_Entry_Type);
procedure Maintain_Channel_Connection
(Srv_Dir : Ada.Directories.Directory_Entry_Type;
Ch_Dir : Ada.Directories.Directory_Entry_Type);
procedure Rejoin_Channel
(Srv_Dir : Ada.Directories.Directory_Entry_Type;
Ch_Dir : Ada.Directories.Directory_Entry_Type);
end Ch_Conn;
|
------------------------------------------------------------------------------
-- Copyright (c) 2015, Natacha Porté --
-- --
-- Permission to use, copy, modify, and distribute this software for any --
-- purpose with or without fee is hereby granted, provided that the above --
-- copyright notice and this permission notice appear in all copies. --
-- --
-- THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES --
-- WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF --
-- MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR --
-- ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES --
-- WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN --
-- ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF --
-- OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. --
------------------------------------------------------------------------------
package body Natools.Web.Escapes.Filters is
overriding procedure Apply
(Object : in Filter;
Output : in out Ada.Streams.Root_Stream_Type'Class;
Data : in Ada.Streams.Stream_Element_Array) is
begin
Write (Output, Data, Object.Set);
end Apply;
function Create
(Arguments : in out S_Expressions.Lockable.Descriptor'Class)
return Web.Filters.Filter'Class
is
use type S_Expressions.Events.Event;
Event : S_Expressions.Events.Event := Arguments.Current_Event;
Set : Octet_Set := (others => False);
Empty : Boolean := True;
Result : Filter := (Set => (others => False));
begin
while Event = S_Expressions.Events.Add_Atom loop
for Octet of Arguments.Current_Atom loop
Set (Octet) := True;
Empty := False;
end loop;
Arguments.Next (Event);
end loop;
if Empty then
Result.Set := (others => True);
return Result;
end if;
if Set (Character'Pos ('<')) or Set (Character'Pos ('>')) then
Result.Set.Gt_Lt := True;
if Set (Character'Pos ('<')) /= Set (Character'Pos ('>')) then
Log (Severities.Warning,
"Escaping both angle brackets despite only one being selected");
end if;
Set (Character'Pos ('<')) := False;
Set (Character'Pos ('>')) := False;
end if;
if Set (Character'Pos ('&')) then
Result.Set.Amp := True;
Set (Character'Pos ('&')) := False;
end if;
if Set (Character'Pos (''')) then
Result.Set.Apos := True;
Set (Character'Pos (''')) := False;
end if;
if Set (Character'Pos ('"')) then
Result.Set.Quot := True;
Set (Character'Pos ('"')) := False;
end if;
for Octet in Set'Range loop
if Set (Octet) then
Log (Severities.Error, "Don't know how to escape "
& Character'Image (Character'Val (Octet)));
end if;
end loop;
return Result;
end Create;
end Natools.Web.Escapes.Filters;
|
package aspect_spec is
task type T
with Storage_Size => 1000;
end aspect_spec;
|
with
aIDE.Palette.of_types,
gtk.Widget;
private
with
gtk.Frame,
gtk.Scrolled_Window;
with Gtk.Box;
with Gtk.Button;
with Gtk.Notebook;
package aIDE.Palette.of_types_package
is
type Item is new Palette.item with private;
type View is access all Item'Class;
function to_types_Palette_package return View;
function new_Button (Named : in String;
package_Name : in String;
types_Palette : in palette.of_types.view;
use_simple_Name : in Boolean) return Gtk.Button.gtk_Button;
procedure Parent_is (Self : in out Item; Now : in aIDE.Palette.of_types.view);
function top_Widget (Self : in Item) return gtk.Widget.Gtk_Widget;
function children_Notebook (Self : in Item) return gtk.Notebook.gtk_Notebook;
procedure add_Type (Self : access Item; Named : in String;
package_Name : in String);
private
use --gtk.Window,
gtk.Button,
gtk.Box,
gtk.Notebook,
gtk.Frame,
gtk.Scrolled_Window;
type Item is new Palette.item with
record
Parent : Palette.of_types.view;
Top : gtk_Frame;
children_Notebook : gtk_Notebook;
types_Box : gtk_Box;
types_Window : Gtk_Scrolled_Window;
end record;
end aIDE.Palette.of_types_package;
|
-- Abstract :
--
-- A simple unbounded sorted vector of definite items.
--
-- Copyright (C) 2019 Free Software Foundation, Inc.
--
-- 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 MERCHAN-
-- TABILITY 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.
pragma License (Modified_GPL);
with Ada.Finalization;
with Ada.Iterator_Interfaces;
with Ada.Unchecked_Deallocation;
generic
type Element_Type is private;
type Key_Type is private;
with function To_Key (Item : in Element_Type) return Key_Type;
with function Key_Compare (Left, Right : in Key_Type) return Compare_Result;
package SAL.Gen_Unbounded_Definite_Vectors_Sorted is
type Vector is new Ada.Finalization.Controlled with private with
Constant_Indexing => Constant_Ref,
Default_Iterator => Iterate,
Iterator_Element => Element_Type;
Empty_Vector : constant Vector;
overriding procedure Finalize (Container : in out Vector);
overriding procedure Adjust (Container : in out Vector);
procedure Clear (Container : in out Vector)
renames Finalize;
function Length (Container : in Vector) return Ada.Containers.Count_Type;
function Capacity (Container : in Vector) return Ada.Containers.Count_Type;
procedure Set_Capacity
(Container : in out Vector;
Length : in Ada.Containers.Count_Type);
-- Allocates uninitialized memory; does not change Container.First,
-- Container.Last.
function "&" (Left, Right : in Element_Type) return Vector;
function "&" (Left : in Vector; Right : in Element_Type) return Vector;
function Contains (Container : in Vector; Key : in Key_Type) return Boolean;
procedure Insert
(Container : in out Vector;
New_Item : in Element_Type);
-- Insert New_Item in sorted position. Items are sorted in increasing
-- order according to Element_Compare.
--
-- Raises Duplicate_Key if To_Key (New_Item) is already in Container.
type Find_Reference_Type (Element : access Element_Type) is private with
Implicit_Dereference => Element;
function Find
(Container : aliased in Vector;
Key : in Key_Type)
return Find_Reference_Type;
-- Result.Element is null if Key not in Container. User must not modify Key.
type Find_Reference_Constant_Type (Element : access constant Element_Type) is private with
Implicit_Dereference => Element;
function Find_Constant
(Container : aliased in Vector;
Key : in Key_Type)
return Find_Reference_Constant_Type;
-- Result.Element is null if Key not in Container.
type Cursor is private;
No_Element : constant Cursor;
function Has_Element (Position : Cursor) return Boolean;
package Iterator_Interfaces is new Ada.Iterator_Interfaces (Cursor, Has_Element);
function Iterate (Container : aliased in Vector) return Iterator_Interfaces.Reversible_Iterator'Class;
type Constant_Reference_Type (Element : not null access constant Element_Type) is private with
Implicit_Dereference => Element;
function Constant_Ref (Container : aliased Vector; Position : in Cursor) return Constant_Reference_Type
with Inline;
function First_Index (Container : aliased Vector) return Peek_Type is (Peek_Type'First);
function Last_Index (Container : aliased Vector) return Base_Peek_Type
with Inline;
function Constant_Ref (Container : aliased Vector; Index : in Peek_Type) return Constant_Reference_Type
with Inline;
private
type Array_Type is array (SAL.Peek_Type range <>) of aliased Element_Type;
type Array_Access is access Array_Type;
procedure Free is new Ada.Unchecked_Deallocation (Array_Type, Array_Access);
No_Index : constant Base_Peek_Type := 0;
type Vector is new Ada.Finalization.Controlled with
record
Elements : Array_Access;
-- Elements may be non-null with First = No_Index, after
-- Set_Capacity. If First /= No_Index and Last >= First, Elements /=
-- null.
Last : Base_Peek_Type := No_Index;
end record;
type Vector_Access is access constant Vector;
for Vector_Access'Storage_Size use 0;
type Cursor is record
Container : Vector_Access := null;
Index : Base_Peek_Type := No_Index;
end record;
type Iterator is new Iterator_Interfaces.Reversible_Iterator with
record
Container : Vector_Access;
end record;
overriding function First (Object : Iterator) return Cursor;
overriding function Last (Object : Iterator) return Cursor;
overriding function Next
(Object : Iterator;
Position : Cursor) return Cursor;
overriding function Previous
(Object : Iterator;
Position : Cursor) return Cursor;
type Find_Reference_Type (Element : access Element_Type) is
record
Dummy : Integer := raise Program_Error with "uninitialized reference";
end record;
type Find_Reference_Constant_Type (Element : access constant Element_Type) is
record
Dummy : Integer := raise Program_Error with "uninitialized reference";
end record;
type Constant_Reference_Type (Element : not null access constant Element_Type) is
record
Dummy : Integer := raise Program_Error with "uninitialized reference";
end record;
Empty_Vector : constant Vector := (Ada.Finalization.Controlled with others => <>);
No_Element : constant Cursor := (others => <>);
----------
-- Visible for child package
procedure Grow (Elements : in out Array_Access; Index : in Base_Peek_Type);
end SAL.Gen_Unbounded_Definite_Vectors_Sorted;
|
-- C37005A.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 SCALAR RECORD COMPONENTS MAY HAVE NON-STATIC
-- RANGE CONSTRAINTS OR DEFAULT INITIAL VALUES.
-- DAT 3/6/81
-- JWC 6/28/85 RENAMED TO -AB
-- EDS 7/16/98 AVOID OPTIMIZATION
WITH REPORT;
PROCEDURE C37005A IS
USE REPORT;
BEGIN
TEST ("C37005A", "SCALAR RECORD COMPONENTS MAY HAVE NON-STATIC"
& " RANGE CONSTRAINTS OR DEFAULT INITIAL VALUES");
DECLARE
SUBTYPE DT IS INTEGER RANGE IDENT_INT (1) .. IDENT_INT (5);
L : INTEGER := IDENT_INT (DT'FIRST);
R : INTEGER := IDENT_INT (DT'LAST);
SUBTYPE DT2 IS INTEGER RANGE L .. R;
M : INTEGER := (L + R) / 2;
TYPE REC IS
RECORD
C1 : INTEGER := M;
C2 : DT2 := (L + R) / 2;
C3 : BOOLEAN RANGE (L < M) .. (R > M)
:= IDENT_BOOL (TRUE);
C4 : INTEGER RANGE L .. R := DT'FIRST;
END RECORD;
R1, R2 : REC := ((L+R)/2, M, M IN DT, L);
R3 : REC;
BEGIN
IF R3 /= R1
THEN
FAILED ("INCORRECT RECORD VALUES");
END IF;
R3 := (R2.C2, R2.C1, R3.C3, R); -- CONSTRAINTS CHECKED BY :=
IF EQUAL(IDENT_INT(1), 2) THEN
FAILED("IMPOSSIBLE " & INTEGER'IMAGE(R3.C1)); --USE R3
END IF;
BEGIN
R3 := (M, M, IDENT_BOOL (FALSE), M); -- RAISES CON_ERR.
FAILED ("CONSTRAINT ERROR NOT RAISED " & INTEGER'IMAGE(R3.C1));
EXCEPTION
WHEN CONSTRAINT_ERROR => NULL;
WHEN OTHERS => FAILED ("WRONG EXCEPTION");
END;
FOR I IN DT LOOP
R3 := (I, I, I /= 100, I);
R1.C2 := I;
IF EQUAL(IDENT_INT(1), 2) THEN
FAILED("IMPOSSIBLE " &
INTEGER'IMAGE(R3.C1 + R1.C2)); --USE R3, R1
END IF;
END LOOP;
EXCEPTION
WHEN OTHERS => FAILED ("INVALID EXCEPTION");
END;
RESULT;
END C37005A;
|
with Distance_Sensor_Controller;
with Ada.Real_Time; use Ada.Real_Time;
--with Ada.Execution_Time;
with Arduino_Nano_33_Ble_Sense.IOs;
with Servo_Controller;
package body Vehicle_Controller is
-------------
-- Compute --
-------------
task body Compute is
--Only for calculating schedule--
--StartTimer : Ada.Execution_Time.CPU_Time;
--EndTimer : Ada.Execution_Time.CPU_Time;
--ExeTime : Ada.Execution_Time.CPU_Time;
Time_Now : Ada.Real_Time.Time;
Front_Blocked : Boolean;
Back_Blocked : Boolean;
begin
--Only for calculating schedule--
--Should start at 0 when task is created, and increase only when used by CPU
--StartTimer := Ada.Execution_Time.Clock;
Time_Now := Ada.Real_Time.Clock;
delay until Time_Now + Ada.Real_Time.Milliseconds(1000);
loop
Time_Now := Ada.Real_Time.Clock;
Front_Blocked := Distance_Sensor_Controller.Front.Value < Stop_Distance_Front;
Back_Blocked := Distance_Sensor_Controller.Back.Value < Stop_Distance_Back;
--Check braking before sensors, can only enter Stop after braking.
if Current_Direction = Braking then
Next_Direction := Stop;
--If both sensors are blocked, stop, or brake if moving forward.
elsif Front_Blocked and Back_Blocked then
if Current_Direction = Forward then
Next_Direction := Braking;
else
Next_Direction := Stop;
end if;
--If only front is blocked, reverse, or brake if moving forward.
elsif Front_Blocked then
if Current_Direction = Forward then
Next_Direction := Braking;
else
Next_Direction := Backward;
end if;
--If only back is blocked, go forward, or stop if reversing.
elsif Back_Blocked then
if Current_Direction = Backward then
Next_Direction := Stop;
else
Next_Direction := Forward;
end if;
--Default direction if stopped and both sensors are ok is forward.
else
if Current_Direction = Stop then
Next_Direction := Forward;
else
Next_Direction := Current_Direction;
end if;
end if;
Change_Direction;
delay until Time_Now + Ada.Real_Time.Milliseconds(16);
--Only for calculating schedule--
--EndTimer := Ada.Execution_Time.Clock;
end loop;
end Compute;
----------------------
-- Change_Direction --
----------------------
procedure Change_Direction is
Time_Now : Ada.Real_Time.Time;
begin
case Next_Direction is
when Forward =>
Servo_Controller.Engine_Servo.Current_Direction := Servo_Controller.Forward;
Status_Light_Colour := Green;
when Backward =>
Servo_Controller.Engine_Servo.Current_Direction := Servo_Controller.Backward;
Status_Light_Colour := Blue;
when Stop =>
Servo_Controller.Engine_Servo.Current_Direction := Servo_Controller.Stop;
Time_Now := Ada.Real_Time.Clock;
delay until Time_Now + Ada.Real_Time.Milliseconds(600);
Status_Light_Colour := Red;
when Braking =>
Servo_Controller.Engine_Servo.Current_Direction := Servo_Controller.Backward;
Time_Now := Ada.Real_Time.Clock;
delay until Time_Now + Ada.Real_Time.Milliseconds(200);
Status_Light_Colour := Yellow;
end case;
Current_Direction := Next_Direction;
end Change_Direction;
------------------
-- Status_Light --
------------------
task body Status_Light is
Time_Now : Ada.Real_Time.Time;
begin
Arduino_Nano_33_Ble_Sense.IOs.DigitalWrite (24, True);
Arduino_Nano_33_Ble_Sense.IOs.DigitalWrite (16, True);
Arduino_Nano_33_Ble_Sense.IOs.DigitalWrite (6, True);
loop
Time_Now := Ada.Real_Time.Clock;
case Status_Light_Colour is
when Red =>
Arduino_Nano_33_Ble_Sense.IOs.DigitalWrite (24, False);
delay until Time_Now + Ada.Real_Time.Milliseconds(100);
Time_Now := Ada.Real_Time.Clock;
Arduino_Nano_33_Ble_Sense.IOs.DigitalWrite (24, True);
when Green =>
Arduino_Nano_33_Ble_Sense.IOs.DigitalWrite (16, False);
delay until Time_Now + Ada.Real_Time.Milliseconds(100);
Time_Now := Ada.Real_Time.Clock;
Arduino_Nano_33_Ble_Sense.IOs.DigitalWrite (16, True);
when Blue =>
Arduino_Nano_33_Ble_Sense.IOs.DigitalWrite (6, False);
delay until Time_Now + Ada.Real_Time.Milliseconds(100);
Time_Now := Ada.Real_Time.Clock;
Arduino_Nano_33_Ble_Sense.IOs.DigitalWrite (6, True);
when Yellow =>
Arduino_Nano_33_Ble_Sense.IOs.DigitalWrite (24, False);
Arduino_Nano_33_Ble_Sense.IOs.DigitalWrite (16, False);
delay until Time_Now + Ada.Real_Time.Milliseconds(100);
Time_Now := Ada.Real_Time.Clock;
Arduino_Nano_33_Ble_Sense.IOs.DigitalWrite (24, True);
Arduino_Nano_33_Ble_Sense.IOs.DigitalWrite (16, True);
end case;
delay until Time_Now + Ada.Real_Time.Milliseconds(100);
end loop;
end Status_Light;
end Vehicle_Controller;
|
-- Copyright (c) 2020 Raspberry Pi (Trading) Ltd.
--
-- SPDX-License-Identifier: BSD-3-Clause
-- This spec has been automatically generated from rp2040.svd
pragma Restrictions (No_Elaboration_Code);
pragma Ada_2012;
pragma Style_Checks (Off);
with HAL;
with System;
-- USB FS/LS controller device registers
package RP_SVD.USBCTRL_REGS is
pragma Preelaborate;
---------------
-- Registers --
---------------
subtype ADDR_ENDP_ADDRESS_Field is HAL.UInt7;
subtype ADDR_ENDP_ENDPOINT_Field is HAL.UInt4;
-- Device address and endpoint control
type ADDR_ENDP_Register is record
-- In device mode, the address that the device should respond to. Set in
-- response to a SET_ADDR setup packet from the host. In host mode set
-- to the address of the device to communicate with.
ADDRESS : ADDR_ENDP_ADDRESS_Field := 16#0#;
-- unspecified
Reserved_7_15 : HAL.UInt9 := 16#0#;
-- Device endpoint to send data to. Only valid for HOST mode.
ENDPOINT : ADDR_ENDP_ENDPOINT_Field := 16#0#;
-- unspecified
Reserved_20_31 : HAL.UInt12 := 16#0#;
end record
with Volatile_Full_Access, Object_Size => 32,
Bit_Order => System.Low_Order_First;
for ADDR_ENDP_Register use record
ADDRESS at 0 range 0 .. 6;
Reserved_7_15 at 0 range 7 .. 15;
ENDPOINT at 0 range 16 .. 19;
Reserved_20_31 at 0 range 20 .. 31;
end record;
-- Interrupt endpoint 1. Only valid for HOST mode.
type ADDR_ENDP_Register_1 is record
-- Device address
ADDRESS : ADDR_ENDP_ADDRESS_Field := 16#0#;
-- unspecified
Reserved_7_15 : HAL.UInt9 := 16#0#;
-- Endpoint number of the interrupt endpoint
ENDPOINT : ADDR_ENDP_ENDPOINT_Field := 16#0#;
-- unspecified
Reserved_20_24 : HAL.UInt5 := 16#0#;
-- Direction of the interrupt endpoint. In=0, Out=1
INTEP_DIR : Boolean := False;
-- Interrupt EP requires preamble (is a low speed device on a full speed
-- hub)
INTEP_PREAMBLE : Boolean := False;
-- unspecified
Reserved_27_31 : HAL.UInt5 := 16#0#;
end record
with Volatile_Full_Access, Object_Size => 32,
Bit_Order => System.Low_Order_First;
for ADDR_ENDP_Register_1 use record
ADDRESS at 0 range 0 .. 6;
Reserved_7_15 at 0 range 7 .. 15;
ENDPOINT at 0 range 16 .. 19;
Reserved_20_24 at 0 range 20 .. 24;
INTEP_DIR at 0 range 25 .. 25;
INTEP_PREAMBLE at 0 range 26 .. 26;
Reserved_27_31 at 0 range 27 .. 31;
end record;
-- Main control register
type MAIN_CTRL_Register is record
-- Enable controller
CONTROLLER_EN : Boolean := False;
-- Device mode = 0, Host mode = 1
HOST_NDEVICE : Boolean := False;
-- unspecified
Reserved_2_30 : HAL.UInt29 := 16#0#;
-- Reduced timings for simulation
SIM_TIMING : Boolean := False;
end record
with Volatile_Full_Access, Object_Size => 32,
Bit_Order => System.Low_Order_First;
for MAIN_CTRL_Register use record
CONTROLLER_EN at 0 range 0 .. 0;
HOST_NDEVICE at 0 range 1 .. 1;
Reserved_2_30 at 0 range 2 .. 30;
SIM_TIMING at 0 range 31 .. 31;
end record;
subtype SOF_WR_COUNT_Field is HAL.UInt11;
-- Set the SOF (Start of Frame) frame number in the host controller. The
-- SOF packet is sent every 1ms and the host will increment the frame
-- number by 1 each time.
type SOF_WR_Register is record
-- Write-only.
COUNT : SOF_WR_COUNT_Field := 16#0#;
-- unspecified
Reserved_11_31 : HAL.UInt21 := 16#0#;
end record
with Volatile_Full_Access, Object_Size => 32,
Bit_Order => System.Low_Order_First;
for SOF_WR_Register use record
COUNT at 0 range 0 .. 10;
Reserved_11_31 at 0 range 11 .. 31;
end record;
subtype SOF_RD_COUNT_Field is HAL.UInt11;
-- Read the last SOF (Start of Frame) frame number seen. In device mode the
-- last SOF received from the host. In host mode the last SOF sent by the
-- host.
type SOF_RD_Register is record
-- Read-only.
COUNT : SOF_RD_COUNT_Field;
-- unspecified
Reserved_11_31 : HAL.UInt21;
end record
with Volatile_Full_Access, Object_Size => 32,
Bit_Order => System.Low_Order_First;
for SOF_RD_Register use record
COUNT at 0 range 0 .. 10;
Reserved_11_31 at 0 range 11 .. 31;
end record;
-- SIE control register
type SIE_CTRL_Register is record
-- After a write operation all bits in the field are cleared (set to
-- zero). Host: Start transaction
START_TRANS : Boolean := False;
-- Host: Send Setup packet
SEND_SETUP : Boolean := False;
-- Host: Send transaction (OUT from host)
SEND_DATA : Boolean := False;
-- Host: Receive transaction (IN to host)
RECEIVE_DATA : Boolean := False;
-- After a write operation all bits in the field are cleared (set to
-- zero). Host: Stop transaction
STOP_TRANS : Boolean := False;
-- unspecified
Reserved_5_5 : HAL.Bit := 16#0#;
-- Host: Preable enable for LS device on FS hub
PREAMBLE_EN : Boolean := False;
-- unspecified
Reserved_7_7 : HAL.Bit := 16#0#;
-- Host: Delay packet(s) until after SOF
SOF_SYNC : Boolean := False;
-- Host: Enable SOF generation (for full speed bus)
SOF_EN : Boolean := False;
-- Host: Enable keep alive packet (for low speed bus)
KEEP_ALIVE_EN : Boolean := False;
-- Host: Enable VBUS
VBUS_EN : Boolean := False;
-- After a write operation all bits in the field are cleared (set to
-- zero). Device: Remote wakeup. Device can initiate its own resume
-- after suspend.
RESUME : Boolean := False;
-- After a write operation all bits in the field are cleared (set to
-- zero). Host: Reset bus
RESET_BUS : Boolean := False;
-- unspecified
Reserved_14_14 : HAL.Bit := 16#0#;
-- Host: Enable pull down resistors
PULLDOWN_EN : Boolean := False;
-- Device: Enable pull up resistor
PULLUP_EN : Boolean := False;
-- Device: Pull-up strength (0=1K2, 1=2k3)
RPU_OPT : Boolean := False;
-- Power down bus transceiver
TRANSCEIVER_PD : Boolean := False;
-- unspecified
Reserved_19_23 : HAL.UInt5 := 16#0#;
-- Direct control of DM
DIRECT_DM : Boolean := False;
-- Direct control of DP
DIRECT_DP : Boolean := False;
-- Direct bus drive enable
DIRECT_EN : Boolean := False;
-- Device: Set bit in EP_STATUS_STALL_NAK when EP0 sends a NAK
EP0_INT_NAK : Boolean := False;
-- Device: Set bit in BUFF_STATUS for every 2 buffers completed on EP0
EP0_INT_2BUF : Boolean := False;
-- Device: Set bit in BUFF_STATUS for every buffer completed on EP0
EP0_INT_1BUF : Boolean := False;
-- Device: EP0 single buffered = 0, double buffered = 1
EP0_DOUBLE_BUF : Boolean := False;
-- Device: Set bit in EP_STATUS_STALL_NAK when EP0 sends a STALL
EP0_INT_STALL : Boolean := False;
end record
with Volatile_Full_Access, Object_Size => 32,
Bit_Order => System.Low_Order_First;
for SIE_CTRL_Register use record
START_TRANS at 0 range 0 .. 0;
SEND_SETUP at 0 range 1 .. 1;
SEND_DATA at 0 range 2 .. 2;
RECEIVE_DATA at 0 range 3 .. 3;
STOP_TRANS at 0 range 4 .. 4;
Reserved_5_5 at 0 range 5 .. 5;
PREAMBLE_EN at 0 range 6 .. 6;
Reserved_7_7 at 0 range 7 .. 7;
SOF_SYNC at 0 range 8 .. 8;
SOF_EN at 0 range 9 .. 9;
KEEP_ALIVE_EN at 0 range 10 .. 10;
VBUS_EN at 0 range 11 .. 11;
RESUME at 0 range 12 .. 12;
RESET_BUS at 0 range 13 .. 13;
Reserved_14_14 at 0 range 14 .. 14;
PULLDOWN_EN at 0 range 15 .. 15;
PULLUP_EN at 0 range 16 .. 16;
RPU_OPT at 0 range 17 .. 17;
TRANSCEIVER_PD at 0 range 18 .. 18;
Reserved_19_23 at 0 range 19 .. 23;
DIRECT_DM at 0 range 24 .. 24;
DIRECT_DP at 0 range 25 .. 25;
DIRECT_EN at 0 range 26 .. 26;
EP0_INT_NAK at 0 range 27 .. 27;
EP0_INT_2BUF at 0 range 28 .. 28;
EP0_INT_1BUF at 0 range 29 .. 29;
EP0_DOUBLE_BUF at 0 range 30 .. 30;
EP0_INT_STALL at 0 range 31 .. 31;
end record;
subtype SIE_STATUS_LINE_STATE_Field is HAL.UInt2;
subtype SIE_STATUS_SPEED_Field is HAL.UInt2;
-- SIE status register
type SIE_STATUS_Register is record
-- Read-only. Device: VBUS Detected
VBUS_DETECTED : Boolean := False;
-- unspecified
Reserved_1_1 : HAL.Bit := 16#0#;
-- Read-only. USB bus line state
LINE_STATE : SIE_STATUS_LINE_STATE_Field := 16#0#;
-- Read-only. Bus in suspended state. Valid for device and host. Host
-- and device will go into suspend if neither Keep Alive / SOF frames
-- are enabled.
SUSPENDED : Boolean := False;
-- unspecified
Reserved_5_7 : HAL.UInt3 := 16#0#;
-- Read-only. Host: device speed. Disconnected = 00, LS = 01, FS = 10
SPEED : SIE_STATUS_SPEED_Field := 16#0#;
-- Read-only. VBUS over current detected
VBUS_OVER_CURR : Boolean := False;
-- Write data bit of one shall clear (set to zero) the corresponding bit
-- in the field. Host: Device has initiated a remote resume. Device:
-- host has initiated a resume.
RESUME : Boolean := False;
-- unspecified
Reserved_12_15 : HAL.UInt4 := 16#0#;
-- Read-only. Device: connected
CONNECTED : Boolean := False;
-- Write data bit of one shall clear (set to zero) the corresponding bit
-- in the field. Device: Setup packet received
SETUP_REC : Boolean := False;
-- Write data bit of one shall clear (set to zero) the corresponding bit
-- in the field. Transaction complete.\n\n Raised by device if:\n\n * An
-- IN or OUT packet is sent with the `LAST_BUFF` bit set in the buffer
-- control register\n\n Raised by host if:\n\n * A setup packet is sent
-- when no data in or data out transaction follows * An IN packet is
-- received and the `LAST_BUFF` bit is set in the buffer control
-- register * An IN packet is received with zero length * An OUT packet
-- is sent and the `LAST_BUFF` bit is set
TRANS_COMPLETE : Boolean := False;
-- Write data bit of one shall clear (set to zero) the corresponding bit
-- in the field. Device: bus reset received
BUS_RESET : Boolean := False;
-- unspecified
Reserved_20_23 : HAL.UInt4 := 16#0#;
-- Write data bit of one shall clear (set to zero) the corresponding bit
-- in the field. CRC Error. Raised by the Serial RX engine.
CRC_ERROR : Boolean := False;
-- Write data bit of one shall clear (set to zero) the corresponding bit
-- in the field. Bit Stuff Error. Raised by the Serial RX engine.
BIT_STUFF_ERROR : Boolean := False;
-- Write data bit of one shall clear (set to zero) the corresponding bit
-- in the field. RX overflow is raised by the Serial RX engine if the
-- incoming data is too fast.
RX_OVERFLOW : Boolean := False;
-- Write data bit of one shall clear (set to zero) the corresponding bit
-- in the field. RX timeout is raised by both the host and device if an
-- ACK is not received in the maximum time specified by the USB spec.
RX_TIMEOUT : Boolean := False;
-- Write data bit of one shall clear (set to zero) the corresponding bit
-- in the field. Host: NAK received
NAK_REC : Boolean := False;
-- Write data bit of one shall clear (set to zero) the corresponding bit
-- in the field. Host: STALL received
STALL_REC : Boolean := False;
-- Write data bit of one shall clear (set to zero) the corresponding bit
-- in the field. ACK received. Raised by both host and device.
ACK_REC : Boolean := False;
-- Write data bit of one shall clear (set to zero) the corresponding bit
-- in the field. Data Sequence Error.\n\n The device can raise a
-- sequence error in the following conditions:\n\n * A SETUP packet is
-- received followed by a DATA1 packet (data phase should always be
-- DATA0) * An OUT packet is received from the host but doesn't match
-- the data pid in the buffer control register read from DPSRAM\n\n The
-- host can raise a data sequence error in the following conditions:\n\n
-- * An IN packet from the device has the wrong data PID
DATA_SEQ_ERROR : Boolean := False;
end record
with Volatile_Full_Access, Object_Size => 32,
Bit_Order => System.Low_Order_First;
for SIE_STATUS_Register use record
VBUS_DETECTED at 0 range 0 .. 0;
Reserved_1_1 at 0 range 1 .. 1;
LINE_STATE at 0 range 2 .. 3;
SUSPENDED at 0 range 4 .. 4;
Reserved_5_7 at 0 range 5 .. 7;
SPEED at 0 range 8 .. 9;
VBUS_OVER_CURR at 0 range 10 .. 10;
RESUME at 0 range 11 .. 11;
Reserved_12_15 at 0 range 12 .. 15;
CONNECTED at 0 range 16 .. 16;
SETUP_REC at 0 range 17 .. 17;
TRANS_COMPLETE at 0 range 18 .. 18;
BUS_RESET at 0 range 19 .. 19;
Reserved_20_23 at 0 range 20 .. 23;
CRC_ERROR at 0 range 24 .. 24;
BIT_STUFF_ERROR at 0 range 25 .. 25;
RX_OVERFLOW at 0 range 26 .. 26;
RX_TIMEOUT at 0 range 27 .. 27;
NAK_REC at 0 range 28 .. 28;
STALL_REC at 0 range 29 .. 29;
ACK_REC at 0 range 30 .. 30;
DATA_SEQ_ERROR at 0 range 31 .. 31;
end record;
subtype INT_EP_CTRL_INT_EP_ACTIVE_Field is HAL.UInt15;
-- interrupt endpoint control register
type INT_EP_CTRL_Register is record
-- unspecified
Reserved_0_0 : HAL.Bit := 16#0#;
-- Host: Enable interrupt endpoint 1 -> 15
INT_EP_ACTIVE : INT_EP_CTRL_INT_EP_ACTIVE_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 INT_EP_CTRL_Register use record
Reserved_0_0 at 0 range 0 .. 0;
INT_EP_ACTIVE at 0 range 1 .. 15;
Reserved_16_31 at 0 range 16 .. 31;
end record;
-- Buffer status register. A bit set here indicates that a buffer has
-- completed on the endpoint (if the buffer interrupt is enabled). It is
-- possible for 2 buffers to be completed, so clearing the buffer status
-- bit may instantly re set it on the next clock cycle.
type BUFF_STATUS_Register is record
-- Read-only.
EP0_IN : Boolean;
-- Read-only.
EP0_OUT : Boolean;
-- Read-only.
EP1_IN : Boolean;
-- Read-only.
EP1_OUT : Boolean;
-- Read-only.
EP2_IN : Boolean;
-- Read-only.
EP2_OUT : Boolean;
-- Read-only.
EP3_IN : Boolean;
-- Read-only.
EP3_OUT : Boolean;
-- Read-only.
EP4_IN : Boolean;
-- Read-only.
EP4_OUT : Boolean;
-- Read-only.
EP5_IN : Boolean;
-- Read-only.
EP5_OUT : Boolean;
-- Read-only.
EP6_IN : Boolean;
-- Read-only.
EP6_OUT : Boolean;
-- Read-only.
EP7_IN : Boolean;
-- Read-only.
EP7_OUT : Boolean;
-- Read-only.
EP8_IN : Boolean;
-- Read-only.
EP8_OUT : Boolean;
-- Read-only.
EP9_IN : Boolean;
-- Read-only.
EP9_OUT : Boolean;
-- Read-only.
EP10_IN : Boolean;
-- Read-only.
EP10_OUT : Boolean;
-- Read-only.
EP11_IN : Boolean;
-- Read-only.
EP11_OUT : Boolean;
-- Read-only.
EP12_IN : Boolean;
-- Read-only.
EP12_OUT : Boolean;
-- Read-only.
EP13_IN : Boolean;
-- Read-only.
EP13_OUT : Boolean;
-- Read-only.
EP14_IN : Boolean;
-- Read-only.
EP14_OUT : Boolean;
-- Read-only.
EP15_IN : Boolean;
-- Read-only.
EP15_OUT : Boolean;
end record
with Volatile_Full_Access, Object_Size => 32,
Bit_Order => System.Low_Order_First;
for BUFF_STATUS_Register use record
EP0_IN at 0 range 0 .. 0;
EP0_OUT at 0 range 1 .. 1;
EP1_IN at 0 range 2 .. 2;
EP1_OUT at 0 range 3 .. 3;
EP2_IN at 0 range 4 .. 4;
EP2_OUT at 0 range 5 .. 5;
EP3_IN at 0 range 6 .. 6;
EP3_OUT at 0 range 7 .. 7;
EP4_IN at 0 range 8 .. 8;
EP4_OUT at 0 range 9 .. 9;
EP5_IN at 0 range 10 .. 10;
EP5_OUT at 0 range 11 .. 11;
EP6_IN at 0 range 12 .. 12;
EP6_OUT at 0 range 13 .. 13;
EP7_IN at 0 range 14 .. 14;
EP7_OUT at 0 range 15 .. 15;
EP8_IN at 0 range 16 .. 16;
EP8_OUT at 0 range 17 .. 17;
EP9_IN at 0 range 18 .. 18;
EP9_OUT at 0 range 19 .. 19;
EP10_IN at 0 range 20 .. 20;
EP10_OUT at 0 range 21 .. 21;
EP11_IN at 0 range 22 .. 22;
EP11_OUT at 0 range 23 .. 23;
EP12_IN at 0 range 24 .. 24;
EP12_OUT at 0 range 25 .. 25;
EP13_IN at 0 range 26 .. 26;
EP13_OUT at 0 range 27 .. 27;
EP14_IN at 0 range 28 .. 28;
EP14_OUT at 0 range 29 .. 29;
EP15_IN at 0 range 30 .. 30;
EP15_OUT at 0 range 31 .. 31;
end record;
-- Which of the double buffers should be handled. Only valid if using an
-- interrupt per buffer (i.e. not per 2 buffers). Not valid for host
-- interrupt endpoint polling because they are only single buffered.
type BUFF_CPU_SHOULD_HANDLE_Register is record
-- Read-only.
EP0_IN : Boolean;
-- Read-only.
EP0_OUT : Boolean;
-- Read-only.
EP1_IN : Boolean;
-- Read-only.
EP1_OUT : Boolean;
-- Read-only.
EP2_IN : Boolean;
-- Read-only.
EP2_OUT : Boolean;
-- Read-only.
EP3_IN : Boolean;
-- Read-only.
EP3_OUT : Boolean;
-- Read-only.
EP4_IN : Boolean;
-- Read-only.
EP4_OUT : Boolean;
-- Read-only.
EP5_IN : Boolean;
-- Read-only.
EP5_OUT : Boolean;
-- Read-only.
EP6_IN : Boolean;
-- Read-only.
EP6_OUT : Boolean;
-- Read-only.
EP7_IN : Boolean;
-- Read-only.
EP7_OUT : Boolean;
-- Read-only.
EP8_IN : Boolean;
-- Read-only.
EP8_OUT : Boolean;
-- Read-only.
EP9_IN : Boolean;
-- Read-only.
EP9_OUT : Boolean;
-- Read-only.
EP10_IN : Boolean;
-- Read-only.
EP10_OUT : Boolean;
-- Read-only.
EP11_IN : Boolean;
-- Read-only.
EP11_OUT : Boolean;
-- Read-only.
EP12_IN : Boolean;
-- Read-only.
EP12_OUT : Boolean;
-- Read-only.
EP13_IN : Boolean;
-- Read-only.
EP13_OUT : Boolean;
-- Read-only.
EP14_IN : Boolean;
-- Read-only.
EP14_OUT : Boolean;
-- Read-only.
EP15_IN : Boolean;
-- Read-only.
EP15_OUT : Boolean;
end record
with Volatile_Full_Access, Object_Size => 32,
Bit_Order => System.Low_Order_First;
for BUFF_CPU_SHOULD_HANDLE_Register use record
EP0_IN at 0 range 0 .. 0;
EP0_OUT at 0 range 1 .. 1;
EP1_IN at 0 range 2 .. 2;
EP1_OUT at 0 range 3 .. 3;
EP2_IN at 0 range 4 .. 4;
EP2_OUT at 0 range 5 .. 5;
EP3_IN at 0 range 6 .. 6;
EP3_OUT at 0 range 7 .. 7;
EP4_IN at 0 range 8 .. 8;
EP4_OUT at 0 range 9 .. 9;
EP5_IN at 0 range 10 .. 10;
EP5_OUT at 0 range 11 .. 11;
EP6_IN at 0 range 12 .. 12;
EP6_OUT at 0 range 13 .. 13;
EP7_IN at 0 range 14 .. 14;
EP7_OUT at 0 range 15 .. 15;
EP8_IN at 0 range 16 .. 16;
EP8_OUT at 0 range 17 .. 17;
EP9_IN at 0 range 18 .. 18;
EP9_OUT at 0 range 19 .. 19;
EP10_IN at 0 range 20 .. 20;
EP10_OUT at 0 range 21 .. 21;
EP11_IN at 0 range 22 .. 22;
EP11_OUT at 0 range 23 .. 23;
EP12_IN at 0 range 24 .. 24;
EP12_OUT at 0 range 25 .. 25;
EP13_IN at 0 range 26 .. 26;
EP13_OUT at 0 range 27 .. 27;
EP14_IN at 0 range 28 .. 28;
EP14_OUT at 0 range 29 .. 29;
EP15_IN at 0 range 30 .. 30;
EP15_OUT at 0 range 31 .. 31;
end record;
-- Device only: Can be set to ignore the buffer control register for this
-- endpoint in case you would like to revoke a buffer. A NAK will be sent
-- for every access to the endpoint until this bit is cleared. A
-- corresponding bit in `EP_ABORT_DONE` is set when it is safe to modify
-- the buffer control register.
type EP_ABORT_Register is record
EP0_IN : Boolean := False;
EP0_OUT : Boolean := False;
EP1_IN : Boolean := False;
EP1_OUT : Boolean := False;
EP2_IN : Boolean := False;
EP2_OUT : Boolean := False;
EP3_IN : Boolean := False;
EP3_OUT : Boolean := False;
EP4_IN : Boolean := False;
EP4_OUT : Boolean := False;
EP5_IN : Boolean := False;
EP5_OUT : Boolean := False;
EP6_IN : Boolean := False;
EP6_OUT : Boolean := False;
EP7_IN : Boolean := False;
EP7_OUT : Boolean := False;
EP8_IN : Boolean := False;
EP8_OUT : Boolean := False;
EP9_IN : Boolean := False;
EP9_OUT : Boolean := False;
EP10_IN : Boolean := False;
EP10_OUT : Boolean := False;
EP11_IN : Boolean := False;
EP11_OUT : Boolean := False;
EP12_IN : Boolean := False;
EP12_OUT : Boolean := False;
EP13_IN : Boolean := False;
EP13_OUT : Boolean := False;
EP14_IN : Boolean := False;
EP14_OUT : Boolean := False;
EP15_IN : Boolean := False;
EP15_OUT : Boolean := False;
end record
with Volatile_Full_Access, Object_Size => 32,
Bit_Order => System.Low_Order_First;
for EP_ABORT_Register use record
EP0_IN at 0 range 0 .. 0;
EP0_OUT at 0 range 1 .. 1;
EP1_IN at 0 range 2 .. 2;
EP1_OUT at 0 range 3 .. 3;
EP2_IN at 0 range 4 .. 4;
EP2_OUT at 0 range 5 .. 5;
EP3_IN at 0 range 6 .. 6;
EP3_OUT at 0 range 7 .. 7;
EP4_IN at 0 range 8 .. 8;
EP4_OUT at 0 range 9 .. 9;
EP5_IN at 0 range 10 .. 10;
EP5_OUT at 0 range 11 .. 11;
EP6_IN at 0 range 12 .. 12;
EP6_OUT at 0 range 13 .. 13;
EP7_IN at 0 range 14 .. 14;
EP7_OUT at 0 range 15 .. 15;
EP8_IN at 0 range 16 .. 16;
EP8_OUT at 0 range 17 .. 17;
EP9_IN at 0 range 18 .. 18;
EP9_OUT at 0 range 19 .. 19;
EP10_IN at 0 range 20 .. 20;
EP10_OUT at 0 range 21 .. 21;
EP11_IN at 0 range 22 .. 22;
EP11_OUT at 0 range 23 .. 23;
EP12_IN at 0 range 24 .. 24;
EP12_OUT at 0 range 25 .. 25;
EP13_IN at 0 range 26 .. 26;
EP13_OUT at 0 range 27 .. 27;
EP14_IN at 0 range 28 .. 28;
EP14_OUT at 0 range 29 .. 29;
EP15_IN at 0 range 30 .. 30;
EP15_OUT at 0 range 31 .. 31;
end record;
-- Device only: Used in conjunction with `EP_ABORT`. Set once an endpoint
-- is idle so the programmer knows it is safe to modify the buffer control
-- register.
type EP_ABORT_DONE_Register is record
-- Write data bit of one shall clear (set to zero) the corresponding bit
-- in the field.
EP0_IN : Boolean := False;
-- Write data bit of one shall clear (set to zero) the corresponding bit
-- in the field.
EP0_OUT : Boolean := False;
-- Write data bit of one shall clear (set to zero) the corresponding bit
-- in the field.
EP1_IN : Boolean := False;
-- Write data bit of one shall clear (set to zero) the corresponding bit
-- in the field.
EP1_OUT : Boolean := False;
-- Write data bit of one shall clear (set to zero) the corresponding bit
-- in the field.
EP2_IN : Boolean := False;
-- Write data bit of one shall clear (set to zero) the corresponding bit
-- in the field.
EP2_OUT : Boolean := False;
-- Write data bit of one shall clear (set to zero) the corresponding bit
-- in the field.
EP3_IN : Boolean := False;
-- Write data bit of one shall clear (set to zero) the corresponding bit
-- in the field.
EP3_OUT : Boolean := False;
-- Write data bit of one shall clear (set to zero) the corresponding bit
-- in the field.
EP4_IN : Boolean := False;
-- Write data bit of one shall clear (set to zero) the corresponding bit
-- in the field.
EP4_OUT : Boolean := False;
-- Write data bit of one shall clear (set to zero) the corresponding bit
-- in the field.
EP5_IN : Boolean := False;
-- Write data bit of one shall clear (set to zero) the corresponding bit
-- in the field.
EP5_OUT : Boolean := False;
-- Write data bit of one shall clear (set to zero) the corresponding bit
-- in the field.
EP6_IN : Boolean := False;
-- Write data bit of one shall clear (set to zero) the corresponding bit
-- in the field.
EP6_OUT : Boolean := False;
-- Write data bit of one shall clear (set to zero) the corresponding bit
-- in the field.
EP7_IN : Boolean := False;
-- Write data bit of one shall clear (set to zero) the corresponding bit
-- in the field.
EP7_OUT : Boolean := False;
-- Write data bit of one shall clear (set to zero) the corresponding bit
-- in the field.
EP8_IN : Boolean := False;
-- Write data bit of one shall clear (set to zero) the corresponding bit
-- in the field.
EP8_OUT : Boolean := False;
-- Write data bit of one shall clear (set to zero) the corresponding bit
-- in the field.
EP9_IN : Boolean := False;
-- Write data bit of one shall clear (set to zero) the corresponding bit
-- in the field.
EP9_OUT : Boolean := False;
-- Write data bit of one shall clear (set to zero) the corresponding bit
-- in the field.
EP10_IN : Boolean := False;
-- Write data bit of one shall clear (set to zero) the corresponding bit
-- in the field.
EP10_OUT : Boolean := False;
-- Write data bit of one shall clear (set to zero) the corresponding bit
-- in the field.
EP11_IN : Boolean := False;
-- Write data bit of one shall clear (set to zero) the corresponding bit
-- in the field.
EP11_OUT : Boolean := False;
-- Write data bit of one shall clear (set to zero) the corresponding bit
-- in the field.
EP12_IN : Boolean := False;
-- Write data bit of one shall clear (set to zero) the corresponding bit
-- in the field.
EP12_OUT : Boolean := False;
-- Write data bit of one shall clear (set to zero) the corresponding bit
-- in the field.
EP13_IN : Boolean := False;
-- Write data bit of one shall clear (set to zero) the corresponding bit
-- in the field.
EP13_OUT : Boolean := False;
-- Write data bit of one shall clear (set to zero) the corresponding bit
-- in the field.
EP14_IN : Boolean := False;
-- Write data bit of one shall clear (set to zero) the corresponding bit
-- in the field.
EP14_OUT : Boolean := False;
-- Write data bit of one shall clear (set to zero) the corresponding bit
-- in the field.
EP15_IN : Boolean := False;
-- Write data bit of one shall clear (set to zero) the corresponding bit
-- in the field.
EP15_OUT : Boolean := False;
end record
with Volatile_Full_Access, Object_Size => 32,
Bit_Order => System.Low_Order_First;
for EP_ABORT_DONE_Register use record
EP0_IN at 0 range 0 .. 0;
EP0_OUT at 0 range 1 .. 1;
EP1_IN at 0 range 2 .. 2;
EP1_OUT at 0 range 3 .. 3;
EP2_IN at 0 range 4 .. 4;
EP2_OUT at 0 range 5 .. 5;
EP3_IN at 0 range 6 .. 6;
EP3_OUT at 0 range 7 .. 7;
EP4_IN at 0 range 8 .. 8;
EP4_OUT at 0 range 9 .. 9;
EP5_IN at 0 range 10 .. 10;
EP5_OUT at 0 range 11 .. 11;
EP6_IN at 0 range 12 .. 12;
EP6_OUT at 0 range 13 .. 13;
EP7_IN at 0 range 14 .. 14;
EP7_OUT at 0 range 15 .. 15;
EP8_IN at 0 range 16 .. 16;
EP8_OUT at 0 range 17 .. 17;
EP9_IN at 0 range 18 .. 18;
EP9_OUT at 0 range 19 .. 19;
EP10_IN at 0 range 20 .. 20;
EP10_OUT at 0 range 21 .. 21;
EP11_IN at 0 range 22 .. 22;
EP11_OUT at 0 range 23 .. 23;
EP12_IN at 0 range 24 .. 24;
EP12_OUT at 0 range 25 .. 25;
EP13_IN at 0 range 26 .. 26;
EP13_OUT at 0 range 27 .. 27;
EP14_IN at 0 range 28 .. 28;
EP14_OUT at 0 range 29 .. 29;
EP15_IN at 0 range 30 .. 30;
EP15_OUT at 0 range 31 .. 31;
end record;
-- Device: this bit must be set in conjunction with the `STALL` bit in the
-- buffer control register to send a STALL on EP0. The device controller
-- clears these bits when a SETUP packet is received because the USB spec
-- requires that a STALL condition is cleared when a SETUP packet is
-- received.
type EP_STALL_ARM_Register is record
EP0_IN : Boolean := False;
EP0_OUT : Boolean := False;
-- unspecified
Reserved_2_31 : HAL.UInt30 := 16#0#;
end record
with Volatile_Full_Access, Object_Size => 32,
Bit_Order => System.Low_Order_First;
for EP_STALL_ARM_Register use record
EP0_IN at 0 range 0 .. 0;
EP0_OUT at 0 range 1 .. 1;
Reserved_2_31 at 0 range 2 .. 31;
end record;
subtype NAK_POLL_DELAY_LS_Field is HAL.UInt10;
subtype NAK_POLL_DELAY_FS_Field is HAL.UInt10;
-- Used by the host controller. Sets the wait time in microseconds before
-- trying again if the device replies with a NAK.
type NAK_POLL_Register is record
-- NAK polling interval for a low speed device
DELAY_LS : NAK_POLL_DELAY_LS_Field := 16#10#;
-- unspecified
Reserved_10_15 : HAL.UInt6 := 16#0#;
-- NAK polling interval for a full speed device
DELAY_FS : NAK_POLL_DELAY_FS_Field := 16#10#;
-- unspecified
Reserved_26_31 : HAL.UInt6 := 16#0#;
end record
with Volatile_Full_Access, Object_Size => 32,
Bit_Order => System.Low_Order_First;
for NAK_POLL_Register use record
DELAY_LS at 0 range 0 .. 9;
Reserved_10_15 at 0 range 10 .. 15;
DELAY_FS at 0 range 16 .. 25;
Reserved_26_31 at 0 range 26 .. 31;
end record;
-- Device: bits are set when the `IRQ_ON_NAK` or `IRQ_ON_STALL` bits are
-- set. For EP0 this comes from `SIE_CTRL`. For all other endpoints it
-- comes from the endpoint control register.
type EP_STATUS_STALL_NAK_Register is record
-- Write data bit of one shall clear (set to zero) the corresponding bit
-- in the field.
EP0_IN : Boolean := False;
-- Write data bit of one shall clear (set to zero) the corresponding bit
-- in the field.
EP0_OUT : Boolean := False;
-- Write data bit of one shall clear (set to zero) the corresponding bit
-- in the field.
EP1_IN : Boolean := False;
-- Write data bit of one shall clear (set to zero) the corresponding bit
-- in the field.
EP1_OUT : Boolean := False;
-- Write data bit of one shall clear (set to zero) the corresponding bit
-- in the field.
EP2_IN : Boolean := False;
-- Write data bit of one shall clear (set to zero) the corresponding bit
-- in the field.
EP2_OUT : Boolean := False;
-- Write data bit of one shall clear (set to zero) the corresponding bit
-- in the field.
EP3_IN : Boolean := False;
-- Write data bit of one shall clear (set to zero) the corresponding bit
-- in the field.
EP3_OUT : Boolean := False;
-- Write data bit of one shall clear (set to zero) the corresponding bit
-- in the field.
EP4_IN : Boolean := False;
-- Write data bit of one shall clear (set to zero) the corresponding bit
-- in the field.
EP4_OUT : Boolean := False;
-- Write data bit of one shall clear (set to zero) the corresponding bit
-- in the field.
EP5_IN : Boolean := False;
-- Write data bit of one shall clear (set to zero) the corresponding bit
-- in the field.
EP5_OUT : Boolean := False;
-- Write data bit of one shall clear (set to zero) the corresponding bit
-- in the field.
EP6_IN : Boolean := False;
-- Write data bit of one shall clear (set to zero) the corresponding bit
-- in the field.
EP6_OUT : Boolean := False;
-- Write data bit of one shall clear (set to zero) the corresponding bit
-- in the field.
EP7_IN : Boolean := False;
-- Write data bit of one shall clear (set to zero) the corresponding bit
-- in the field.
EP7_OUT : Boolean := False;
-- Write data bit of one shall clear (set to zero) the corresponding bit
-- in the field.
EP8_IN : Boolean := False;
-- Write data bit of one shall clear (set to zero) the corresponding bit
-- in the field.
EP8_OUT : Boolean := False;
-- Write data bit of one shall clear (set to zero) the corresponding bit
-- in the field.
EP9_IN : Boolean := False;
-- Write data bit of one shall clear (set to zero) the corresponding bit
-- in the field.
EP9_OUT : Boolean := False;
-- Write data bit of one shall clear (set to zero) the corresponding bit
-- in the field.
EP10_IN : Boolean := False;
-- Write data bit of one shall clear (set to zero) the corresponding bit
-- in the field.
EP10_OUT : Boolean := False;
-- Write data bit of one shall clear (set to zero) the corresponding bit
-- in the field.
EP11_IN : Boolean := False;
-- Write data bit of one shall clear (set to zero) the corresponding bit
-- in the field.
EP11_OUT : Boolean := False;
-- Write data bit of one shall clear (set to zero) the corresponding bit
-- in the field.
EP12_IN : Boolean := False;
-- Write data bit of one shall clear (set to zero) the corresponding bit
-- in the field.
EP12_OUT : Boolean := False;
-- Write data bit of one shall clear (set to zero) the corresponding bit
-- in the field.
EP13_IN : Boolean := False;
-- Write data bit of one shall clear (set to zero) the corresponding bit
-- in the field.
EP13_OUT : Boolean := False;
-- Write data bit of one shall clear (set to zero) the corresponding bit
-- in the field.
EP14_IN : Boolean := False;
-- Write data bit of one shall clear (set to zero) the corresponding bit
-- in the field.
EP14_OUT : Boolean := False;
-- Write data bit of one shall clear (set to zero) the corresponding bit
-- in the field.
EP15_IN : Boolean := False;
-- Write data bit of one shall clear (set to zero) the corresponding bit
-- in the field.
EP15_OUT : Boolean := False;
end record
with Volatile_Full_Access, Object_Size => 32,
Bit_Order => System.Low_Order_First;
for EP_STATUS_STALL_NAK_Register use record
EP0_IN at 0 range 0 .. 0;
EP0_OUT at 0 range 1 .. 1;
EP1_IN at 0 range 2 .. 2;
EP1_OUT at 0 range 3 .. 3;
EP2_IN at 0 range 4 .. 4;
EP2_OUT at 0 range 5 .. 5;
EP3_IN at 0 range 6 .. 6;
EP3_OUT at 0 range 7 .. 7;
EP4_IN at 0 range 8 .. 8;
EP4_OUT at 0 range 9 .. 9;
EP5_IN at 0 range 10 .. 10;
EP5_OUT at 0 range 11 .. 11;
EP6_IN at 0 range 12 .. 12;
EP6_OUT at 0 range 13 .. 13;
EP7_IN at 0 range 14 .. 14;
EP7_OUT at 0 range 15 .. 15;
EP8_IN at 0 range 16 .. 16;
EP8_OUT at 0 range 17 .. 17;
EP9_IN at 0 range 18 .. 18;
EP9_OUT at 0 range 19 .. 19;
EP10_IN at 0 range 20 .. 20;
EP10_OUT at 0 range 21 .. 21;
EP11_IN at 0 range 22 .. 22;
EP11_OUT at 0 range 23 .. 23;
EP12_IN at 0 range 24 .. 24;
EP12_OUT at 0 range 25 .. 25;
EP13_IN at 0 range 26 .. 26;
EP13_OUT at 0 range 27 .. 27;
EP14_IN at 0 range 28 .. 28;
EP14_OUT at 0 range 29 .. 29;
EP15_IN at 0 range 30 .. 30;
EP15_OUT at 0 range 31 .. 31;
end record;
-- Where to connect the USB controller. Should be to_phy by default.
type USB_MUXING_Register is record
TO_PHY : Boolean := False;
TO_EXTPHY : Boolean := False;
TO_DIGITAL_PAD : Boolean := False;
SOFTCON : Boolean := False;
-- unspecified
Reserved_4_31 : HAL.UInt28 := 16#0#;
end record
with Volatile_Full_Access, Object_Size => 32,
Bit_Order => System.Low_Order_First;
for USB_MUXING_Register use record
TO_PHY at 0 range 0 .. 0;
TO_EXTPHY at 0 range 1 .. 1;
TO_DIGITAL_PAD at 0 range 2 .. 2;
SOFTCON at 0 range 3 .. 3;
Reserved_4_31 at 0 range 4 .. 31;
end record;
-- Overrides for the power signals in the event that the VBUS signals are
-- not hooked up to GPIO. Set the value of the override and then the
-- override enable to switch over to the override value.
type USB_PWR_Register is record
VBUS_EN : Boolean := False;
VBUS_EN_OVERRIDE_EN : Boolean := False;
VBUS_DETECT : Boolean := False;
VBUS_DETECT_OVERRIDE_EN : Boolean := False;
OVERCURR_DETECT : Boolean := False;
OVERCURR_DETECT_EN : Boolean := False;
-- unspecified
Reserved_6_31 : HAL.UInt26 := 16#0#;
end record
with Volatile_Full_Access, Object_Size => 32,
Bit_Order => System.Low_Order_First;
for USB_PWR_Register use record
VBUS_EN at 0 range 0 .. 0;
VBUS_EN_OVERRIDE_EN at 0 range 1 .. 1;
VBUS_DETECT at 0 range 2 .. 2;
VBUS_DETECT_OVERRIDE_EN at 0 range 3 .. 3;
OVERCURR_DETECT at 0 range 4 .. 4;
OVERCURR_DETECT_EN at 0 range 5 .. 5;
Reserved_6_31 at 0 range 6 .. 31;
end record;
-- This register allows for direct control of the USB phy. Use in
-- conjunction with usbphy_direct_override register to enable each override
-- bit.
type USBPHY_DIRECT_Register is record
-- Enable the second DP pull up resistor. 0 - Pull = Rpu2; 1 - Pull =
-- Rpu1 + Rpu2
DP_PULLUP_HISEL : Boolean := False;
-- DP pull up enable
DP_PULLUP_EN : Boolean := False;
-- DP pull down enable
DP_PULLDN_EN : Boolean := False;
-- unspecified
Reserved_3_3 : HAL.Bit := 16#0#;
-- Enable the second DM pull up resistor. 0 - Pull = Rpu2; 1 - Pull =
-- Rpu1 + Rpu2
DM_PULLUP_HISEL : Boolean := False;
-- DM pull up enable
DM_PULLUP_EN : Boolean := False;
-- DM pull down enable
DM_PULLDN_EN : Boolean := False;
-- unspecified
Reserved_7_7 : HAL.Bit := 16#0#;
-- Output enable. If TX_DIFFMODE=1, OE for DPP/DPM diff pair. 0 -
-- DPP/DPM in Hi-Z state; 1 - DPP/DPM driving\n If TX_DIFFMODE=0, OE for
-- DPP only. 0 - DPP in Hi-Z state; 1 - DPP driving
TX_DP_OE : Boolean := False;
-- Output enable. If TX_DIFFMODE=1, Ignored.\n If TX_DIFFMODE=0, OE for
-- DPM only. 0 - DPM in Hi-Z state; 1 - DPM driving
TX_DM_OE : Boolean := False;
-- Output data. If TX_DIFFMODE=1, Drives DPP/DPM diff pair. TX_DP_OE=1
-- to enable drive. DPP=TX_DP, DPM=~TX_DP\n If TX_DIFFMODE=0, Drives DPP
-- only. TX_DP_OE=1 to enable drive. DPP=TX_DP
TX_DP : Boolean := False;
-- Output data. TX_DIFFMODE=1, Ignored\n TX_DIFFMODE=0, Drives DPM only.
-- TX_DM_OE=1 to enable drive. DPM=TX_DM
TX_DM : Boolean := False;
-- RX power down override (if override enable is set). 1 = powered down.
RX_PD : Boolean := False;
-- TX power down override (if override enable is set). 1 = powered down.
TX_PD : Boolean := False;
-- TX_FSSLEW=0: Low speed slew rate\n TX_FSSLEW=1: Full speed slew rate
TX_FSSLEW : Boolean := False;
-- TX_DIFFMODE=0: Single ended mode\n TX_DIFFMODE=1: Differential drive
-- mode (TX_DM, TX_DM_OE ignored)
TX_DIFFMODE : Boolean := False;
-- Read-only. Differential RX
RX_DD : Boolean := False;
-- Read-only. DPP pin state
RX_DP : Boolean := False;
-- Read-only. DPM pin state
RX_DM : Boolean := False;
-- Read-only. DP overcurrent
DP_OVCN : Boolean := False;
-- Read-only. DM overcurrent
DM_OVCN : Boolean := False;
-- Read-only. DP over voltage
DP_OVV : Boolean := False;
-- Read-only. DM over voltage
DM_OVV : Boolean := False;
-- unspecified
Reserved_23_31 : HAL.UInt9 := 16#0#;
end record
with Volatile_Full_Access, Object_Size => 32,
Bit_Order => System.Low_Order_First;
for USBPHY_DIRECT_Register use record
DP_PULLUP_HISEL at 0 range 0 .. 0;
DP_PULLUP_EN at 0 range 1 .. 1;
DP_PULLDN_EN at 0 range 2 .. 2;
Reserved_3_3 at 0 range 3 .. 3;
DM_PULLUP_HISEL at 0 range 4 .. 4;
DM_PULLUP_EN at 0 range 5 .. 5;
DM_PULLDN_EN at 0 range 6 .. 6;
Reserved_7_7 at 0 range 7 .. 7;
TX_DP_OE at 0 range 8 .. 8;
TX_DM_OE at 0 range 9 .. 9;
TX_DP at 0 range 10 .. 10;
TX_DM at 0 range 11 .. 11;
RX_PD at 0 range 12 .. 12;
TX_PD at 0 range 13 .. 13;
TX_FSSLEW at 0 range 14 .. 14;
TX_DIFFMODE at 0 range 15 .. 15;
RX_DD at 0 range 16 .. 16;
RX_DP at 0 range 17 .. 17;
RX_DM at 0 range 18 .. 18;
DP_OVCN at 0 range 19 .. 19;
DM_OVCN at 0 range 20 .. 20;
DP_OVV at 0 range 21 .. 21;
DM_OVV at 0 range 22 .. 22;
Reserved_23_31 at 0 range 23 .. 31;
end record;
-- Override enable for each control in usbphy_direct
type USBPHY_DIRECT_OVERRIDE_Register is record
DP_PULLUP_HISEL_OVERRIDE_EN : Boolean := False;
DM_PULLUP_HISEL_OVERRIDE_EN : Boolean := False;
DP_PULLUP_EN_OVERRIDE_EN : Boolean := False;
DP_PULLDN_EN_OVERRIDE_EN : Boolean := False;
DM_PULLDN_EN_OVERRIDE_EN : Boolean := False;
TX_DP_OE_OVERRIDE_EN : Boolean := False;
TX_DM_OE_OVERRIDE_EN : Boolean := False;
TX_DP_OVERRIDE_EN : Boolean := False;
TX_DM_OVERRIDE_EN : Boolean := False;
RX_PD_OVERRIDE_EN : Boolean := False;
TX_PD_OVERRIDE_EN : Boolean := False;
TX_FSSLEW_OVERRIDE_EN : Boolean := False;
DM_PULLUP_OVERRIDE_EN : Boolean := False;
-- unspecified
Reserved_13_14 : HAL.UInt2 := 16#0#;
TX_DIFFMODE_OVERRIDE_EN : Boolean := False;
-- unspecified
Reserved_16_31 : HAL.UInt16 := 16#0#;
end record
with Volatile_Full_Access, Object_Size => 32,
Bit_Order => System.Low_Order_First;
for USBPHY_DIRECT_OVERRIDE_Register use record
DP_PULLUP_HISEL_OVERRIDE_EN at 0 range 0 .. 0;
DM_PULLUP_HISEL_OVERRIDE_EN at 0 range 1 .. 1;
DP_PULLUP_EN_OVERRIDE_EN at 0 range 2 .. 2;
DP_PULLDN_EN_OVERRIDE_EN at 0 range 3 .. 3;
DM_PULLDN_EN_OVERRIDE_EN at 0 range 4 .. 4;
TX_DP_OE_OVERRIDE_EN at 0 range 5 .. 5;
TX_DM_OE_OVERRIDE_EN at 0 range 6 .. 6;
TX_DP_OVERRIDE_EN at 0 range 7 .. 7;
TX_DM_OVERRIDE_EN at 0 range 8 .. 8;
RX_PD_OVERRIDE_EN at 0 range 9 .. 9;
TX_PD_OVERRIDE_EN at 0 range 10 .. 10;
TX_FSSLEW_OVERRIDE_EN at 0 range 11 .. 11;
DM_PULLUP_OVERRIDE_EN at 0 range 12 .. 12;
Reserved_13_14 at 0 range 13 .. 14;
TX_DIFFMODE_OVERRIDE_EN at 0 range 15 .. 15;
Reserved_16_31 at 0 range 16 .. 31;
end record;
subtype USBPHY_TRIM_DP_PULLDN_TRIM_Field is HAL.UInt5;
subtype USBPHY_TRIM_DM_PULLDN_TRIM_Field is HAL.UInt5;
-- Used to adjust trim values of USB phy pull down resistors.
type USBPHY_TRIM_Register is record
-- Value to drive to USB PHY\n DP pulldown resistor trim control\n
-- Experimental data suggests that the reset value will work, but this
-- register allows adjustment if required
DP_PULLDN_TRIM : USBPHY_TRIM_DP_PULLDN_TRIM_Field := 16#1F#;
-- unspecified
Reserved_5_7 : HAL.UInt3 := 16#0#;
-- Value to drive to USB PHY\n DM pulldown resistor trim control\n
-- Experimental data suggests that the reset value will work, but this
-- register allows adjustment if required
DM_PULLDN_TRIM : USBPHY_TRIM_DM_PULLDN_TRIM_Field := 16#1F#;
-- unspecified
Reserved_13_31 : HAL.UInt19 := 16#0#;
end record
with Volatile_Full_Access, Object_Size => 32,
Bit_Order => System.Low_Order_First;
for USBPHY_TRIM_Register use record
DP_PULLDN_TRIM at 0 range 0 .. 4;
Reserved_5_7 at 0 range 5 .. 7;
DM_PULLDN_TRIM at 0 range 8 .. 12;
Reserved_13_31 at 0 range 13 .. 31;
end record;
-- Raw Interrupts
type INTR_Register is record
-- Read-only. Host: raised when a device is connected or disconnected
-- (i.e. when SIE_STATUS.SPEED changes). Cleared by writing to
-- SIE_STATUS.SPEED
HOST_CONN_DIS : Boolean;
-- Read-only. Host: raised when a device wakes up the host. Cleared by
-- writing to SIE_STATUS.RESUME
HOST_RESUME : Boolean;
-- Read-only. Host: raised every time the host sends a SOF (Start of
-- Frame). Cleared by reading SOF_RD
HOST_SOF : Boolean;
-- Read-only. Raised every time SIE_STATUS.TRANS_COMPLETE is set. Clear
-- by writing to this bit.
TRANS_COMPLETE : Boolean;
-- Read-only. Raised when any bit in BUFF_STATUS is set. Clear by
-- clearing all bits in BUFF_STATUS.
BUFF_STATUS : Boolean;
-- Read-only. Source: SIE_STATUS.DATA_SEQ_ERROR
ERROR_DATA_SEQ : Boolean;
-- Read-only. Source: SIE_STATUS.RX_TIMEOUT
ERROR_RX_TIMEOUT : Boolean;
-- Read-only. Source: SIE_STATUS.RX_OVERFLOW
ERROR_RX_OVERFLOW : Boolean;
-- Read-only. Source: SIE_STATUS.BIT_STUFF_ERROR
ERROR_BIT_STUFF : Boolean;
-- Read-only. Source: SIE_STATUS.CRC_ERROR
ERROR_CRC : Boolean;
-- Read-only. Source: SIE_STATUS.STALL_REC
STALL : Boolean;
-- Read-only. Source: SIE_STATUS.VBUS_DETECT
VBUS_DETECT : Boolean;
-- Read-only. Source: SIE_STATUS.BUS_RESET
BUS_RESET : Boolean;
-- Read-only. Set when the device connection state changes. Cleared by
-- writing to SIE_STATUS.CONNECTED
DEV_CONN_DIS : Boolean;
-- Read-only. Set when the device suspend state changes. Cleared by
-- writing to SIE_STATUS.SUSPENDED
DEV_SUSPEND : Boolean;
-- Read-only. Set when the device receives a resume from the host.
-- Cleared by writing to SIE_STATUS.RESUME
DEV_RESUME_FROM_HOST : Boolean;
-- Read-only. Device. Source: SIE_STATUS.SETUP_REC
SETUP_REQ : Boolean;
-- Read-only. Set every time the device receives a SOF (Start of Frame)
-- packet. Cleared by reading SOF_RD
DEV_SOF : Boolean;
-- Read-only. Raised when any bit in ABORT_DONE is set. Clear by
-- clearing all bits in ABORT_DONE.
ABORT_DONE : Boolean;
-- Read-only. Raised when any bit in EP_STATUS_STALL_NAK is set. Clear
-- by clearing all bits in EP_STATUS_STALL_NAK.
EP_STALL_NAK : Boolean;
-- unspecified
Reserved_20_31 : HAL.UInt12;
end record
with Volatile_Full_Access, Object_Size => 32,
Bit_Order => System.Low_Order_First;
for INTR_Register use record
HOST_CONN_DIS at 0 range 0 .. 0;
HOST_RESUME at 0 range 1 .. 1;
HOST_SOF at 0 range 2 .. 2;
TRANS_COMPLETE at 0 range 3 .. 3;
BUFF_STATUS at 0 range 4 .. 4;
ERROR_DATA_SEQ at 0 range 5 .. 5;
ERROR_RX_TIMEOUT at 0 range 6 .. 6;
ERROR_RX_OVERFLOW at 0 range 7 .. 7;
ERROR_BIT_STUFF at 0 range 8 .. 8;
ERROR_CRC at 0 range 9 .. 9;
STALL at 0 range 10 .. 10;
VBUS_DETECT at 0 range 11 .. 11;
BUS_RESET at 0 range 12 .. 12;
DEV_CONN_DIS at 0 range 13 .. 13;
DEV_SUSPEND at 0 range 14 .. 14;
DEV_RESUME_FROM_HOST at 0 range 15 .. 15;
SETUP_REQ at 0 range 16 .. 16;
DEV_SOF at 0 range 17 .. 17;
ABORT_DONE at 0 range 18 .. 18;
EP_STALL_NAK at 0 range 19 .. 19;
Reserved_20_31 at 0 range 20 .. 31;
end record;
-- Interrupt Enable
type INTE_Register is record
-- Host: raised when a device is connected or disconnected (i.e. when
-- SIE_STATUS.SPEED changes). Cleared by writing to SIE_STATUS.SPEED
HOST_CONN_DIS : Boolean := False;
-- Host: raised when a device wakes up the host. Cleared by writing to
-- SIE_STATUS.RESUME
HOST_RESUME : Boolean := False;
-- Host: raised every time the host sends a SOF (Start of Frame).
-- Cleared by reading SOF_RD
HOST_SOF : Boolean := False;
-- Raised every time SIE_STATUS.TRANS_COMPLETE is set. Clear by writing
-- to this bit.
TRANS_COMPLETE : Boolean := False;
-- Raised when any bit in BUFF_STATUS is set. Clear by clearing all bits
-- in BUFF_STATUS.
BUFF_STATUS : Boolean := False;
-- Source: SIE_STATUS.DATA_SEQ_ERROR
ERROR_DATA_SEQ : Boolean := False;
-- Source: SIE_STATUS.RX_TIMEOUT
ERROR_RX_TIMEOUT : Boolean := False;
-- Source: SIE_STATUS.RX_OVERFLOW
ERROR_RX_OVERFLOW : Boolean := False;
-- Source: SIE_STATUS.BIT_STUFF_ERROR
ERROR_BIT_STUFF : Boolean := False;
-- Source: SIE_STATUS.CRC_ERROR
ERROR_CRC : Boolean := False;
-- Source: SIE_STATUS.STALL_REC
STALL : Boolean := False;
-- Source: SIE_STATUS.VBUS_DETECT
VBUS_DETECT : Boolean := False;
-- Source: SIE_STATUS.BUS_RESET
BUS_RESET : Boolean := False;
-- Set when the device connection state changes. Cleared by writing to
-- SIE_STATUS.CONNECTED
DEV_CONN_DIS : Boolean := False;
-- Set when the device suspend state changes. Cleared by writing to
-- SIE_STATUS.SUSPENDED
DEV_SUSPEND : Boolean := False;
-- Set when the device receives a resume from the host. Cleared by
-- writing to SIE_STATUS.RESUME
DEV_RESUME_FROM_HOST : Boolean := False;
-- Device. Source: SIE_STATUS.SETUP_REC
SETUP_REQ : Boolean := False;
-- Set every time the device receives a SOF (Start of Frame) packet.
-- Cleared by reading SOF_RD
DEV_SOF : Boolean := False;
-- Raised when any bit in ABORT_DONE is set. Clear by clearing all bits
-- in ABORT_DONE.
ABORT_DONE : Boolean := False;
-- Raised when any bit in EP_STATUS_STALL_NAK is set. Clear by clearing
-- all bits in EP_STATUS_STALL_NAK.
EP_STALL_NAK : Boolean := False;
-- unspecified
Reserved_20_31 : HAL.UInt12 := 16#0#;
end record
with Volatile_Full_Access, Object_Size => 32,
Bit_Order => System.Low_Order_First;
for INTE_Register use record
HOST_CONN_DIS at 0 range 0 .. 0;
HOST_RESUME at 0 range 1 .. 1;
HOST_SOF at 0 range 2 .. 2;
TRANS_COMPLETE at 0 range 3 .. 3;
BUFF_STATUS at 0 range 4 .. 4;
ERROR_DATA_SEQ at 0 range 5 .. 5;
ERROR_RX_TIMEOUT at 0 range 6 .. 6;
ERROR_RX_OVERFLOW at 0 range 7 .. 7;
ERROR_BIT_STUFF at 0 range 8 .. 8;
ERROR_CRC at 0 range 9 .. 9;
STALL at 0 range 10 .. 10;
VBUS_DETECT at 0 range 11 .. 11;
BUS_RESET at 0 range 12 .. 12;
DEV_CONN_DIS at 0 range 13 .. 13;
DEV_SUSPEND at 0 range 14 .. 14;
DEV_RESUME_FROM_HOST at 0 range 15 .. 15;
SETUP_REQ at 0 range 16 .. 16;
DEV_SOF at 0 range 17 .. 17;
ABORT_DONE at 0 range 18 .. 18;
EP_STALL_NAK at 0 range 19 .. 19;
Reserved_20_31 at 0 range 20 .. 31;
end record;
-- Interrupt Force
type INTF_Register is record
-- Host: raised when a device is connected or disconnected (i.e. when
-- SIE_STATUS.SPEED changes). Cleared by writing to SIE_STATUS.SPEED
HOST_CONN_DIS : Boolean := False;
-- Host: raised when a device wakes up the host. Cleared by writing to
-- SIE_STATUS.RESUME
HOST_RESUME : Boolean := False;
-- Host: raised every time the host sends a SOF (Start of Frame).
-- Cleared by reading SOF_RD
HOST_SOF : Boolean := False;
-- Raised every time SIE_STATUS.TRANS_COMPLETE is set. Clear by writing
-- to this bit.
TRANS_COMPLETE : Boolean := False;
-- Raised when any bit in BUFF_STATUS is set. Clear by clearing all bits
-- in BUFF_STATUS.
BUFF_STATUS : Boolean := False;
-- Source: SIE_STATUS.DATA_SEQ_ERROR
ERROR_DATA_SEQ : Boolean := False;
-- Source: SIE_STATUS.RX_TIMEOUT
ERROR_RX_TIMEOUT : Boolean := False;
-- Source: SIE_STATUS.RX_OVERFLOW
ERROR_RX_OVERFLOW : Boolean := False;
-- Source: SIE_STATUS.BIT_STUFF_ERROR
ERROR_BIT_STUFF : Boolean := False;
-- Source: SIE_STATUS.CRC_ERROR
ERROR_CRC : Boolean := False;
-- Source: SIE_STATUS.STALL_REC
STALL : Boolean := False;
-- Source: SIE_STATUS.VBUS_DETECT
VBUS_DETECT : Boolean := False;
-- Source: SIE_STATUS.BUS_RESET
BUS_RESET : Boolean := False;
-- Set when the device connection state changes. Cleared by writing to
-- SIE_STATUS.CONNECTED
DEV_CONN_DIS : Boolean := False;
-- Set when the device suspend state changes. Cleared by writing to
-- SIE_STATUS.SUSPENDED
DEV_SUSPEND : Boolean := False;
-- Set when the device receives a resume from the host. Cleared by
-- writing to SIE_STATUS.RESUME
DEV_RESUME_FROM_HOST : Boolean := False;
-- Device. Source: SIE_STATUS.SETUP_REC
SETUP_REQ : Boolean := False;
-- Set every time the device receives a SOF (Start of Frame) packet.
-- Cleared by reading SOF_RD
DEV_SOF : Boolean := False;
-- Raised when any bit in ABORT_DONE is set. Clear by clearing all bits
-- in ABORT_DONE.
ABORT_DONE : Boolean := False;
-- Raised when any bit in EP_STATUS_STALL_NAK is set. Clear by clearing
-- all bits in EP_STATUS_STALL_NAK.
EP_STALL_NAK : Boolean := False;
-- unspecified
Reserved_20_31 : HAL.UInt12 := 16#0#;
end record
with Volatile_Full_Access, Object_Size => 32,
Bit_Order => System.Low_Order_First;
for INTF_Register use record
HOST_CONN_DIS at 0 range 0 .. 0;
HOST_RESUME at 0 range 1 .. 1;
HOST_SOF at 0 range 2 .. 2;
TRANS_COMPLETE at 0 range 3 .. 3;
BUFF_STATUS at 0 range 4 .. 4;
ERROR_DATA_SEQ at 0 range 5 .. 5;
ERROR_RX_TIMEOUT at 0 range 6 .. 6;
ERROR_RX_OVERFLOW at 0 range 7 .. 7;
ERROR_BIT_STUFF at 0 range 8 .. 8;
ERROR_CRC at 0 range 9 .. 9;
STALL at 0 range 10 .. 10;
VBUS_DETECT at 0 range 11 .. 11;
BUS_RESET at 0 range 12 .. 12;
DEV_CONN_DIS at 0 range 13 .. 13;
DEV_SUSPEND at 0 range 14 .. 14;
DEV_RESUME_FROM_HOST at 0 range 15 .. 15;
SETUP_REQ at 0 range 16 .. 16;
DEV_SOF at 0 range 17 .. 17;
ABORT_DONE at 0 range 18 .. 18;
EP_STALL_NAK at 0 range 19 .. 19;
Reserved_20_31 at 0 range 20 .. 31;
end record;
-- Interrupt status after masking & forcing
type INTS_Register is record
-- Read-only. Host: raised when a device is connected or disconnected
-- (i.e. when SIE_STATUS.SPEED changes). Cleared by writing to
-- SIE_STATUS.SPEED
HOST_CONN_DIS : Boolean;
-- Read-only. Host: raised when a device wakes up the host. Cleared by
-- writing to SIE_STATUS.RESUME
HOST_RESUME : Boolean;
-- Read-only. Host: raised every time the host sends a SOF (Start of
-- Frame). Cleared by reading SOF_RD
HOST_SOF : Boolean;
-- Read-only. Raised every time SIE_STATUS.TRANS_COMPLETE is set. Clear
-- by writing to this bit.
TRANS_COMPLETE : Boolean;
-- Read-only. Raised when any bit in BUFF_STATUS is set. Clear by
-- clearing all bits in BUFF_STATUS.
BUFF_STATUS : Boolean;
-- Read-only. Source: SIE_STATUS.DATA_SEQ_ERROR
ERROR_DATA_SEQ : Boolean;
-- Read-only. Source: SIE_STATUS.RX_TIMEOUT
ERROR_RX_TIMEOUT : Boolean;
-- Read-only. Source: SIE_STATUS.RX_OVERFLOW
ERROR_RX_OVERFLOW : Boolean;
-- Read-only. Source: SIE_STATUS.BIT_STUFF_ERROR
ERROR_BIT_STUFF : Boolean;
-- Read-only. Source: SIE_STATUS.CRC_ERROR
ERROR_CRC : Boolean;
-- Read-only. Source: SIE_STATUS.STALL_REC
STALL : Boolean;
-- Read-only. Source: SIE_STATUS.VBUS_DETECT
VBUS_DETECT : Boolean;
-- Read-only. Source: SIE_STATUS.BUS_RESET
BUS_RESET : Boolean;
-- Read-only. Set when the device connection state changes. Cleared by
-- writing to SIE_STATUS.CONNECTED
DEV_CONN_DIS : Boolean;
-- Read-only. Set when the device suspend state changes. Cleared by
-- writing to SIE_STATUS.SUSPENDED
DEV_SUSPEND : Boolean;
-- Read-only. Set when the device receives a resume from the host.
-- Cleared by writing to SIE_STATUS.RESUME
DEV_RESUME_FROM_HOST : Boolean;
-- Read-only. Device. Source: SIE_STATUS.SETUP_REC
SETUP_REQ : Boolean;
-- Read-only. Set every time the device receives a SOF (Start of Frame)
-- packet. Cleared by reading SOF_RD
DEV_SOF : Boolean;
-- Read-only. Raised when any bit in ABORT_DONE is set. Clear by
-- clearing all bits in ABORT_DONE.
ABORT_DONE : Boolean;
-- Read-only. Raised when any bit in EP_STATUS_STALL_NAK is set. Clear
-- by clearing all bits in EP_STATUS_STALL_NAK.
EP_STALL_NAK : Boolean;
-- unspecified
Reserved_20_31 : HAL.UInt12;
end record
with Volatile_Full_Access, Object_Size => 32,
Bit_Order => System.Low_Order_First;
for INTS_Register use record
HOST_CONN_DIS at 0 range 0 .. 0;
HOST_RESUME at 0 range 1 .. 1;
HOST_SOF at 0 range 2 .. 2;
TRANS_COMPLETE at 0 range 3 .. 3;
BUFF_STATUS at 0 range 4 .. 4;
ERROR_DATA_SEQ at 0 range 5 .. 5;
ERROR_RX_TIMEOUT at 0 range 6 .. 6;
ERROR_RX_OVERFLOW at 0 range 7 .. 7;
ERROR_BIT_STUFF at 0 range 8 .. 8;
ERROR_CRC at 0 range 9 .. 9;
STALL at 0 range 10 .. 10;
VBUS_DETECT at 0 range 11 .. 11;
BUS_RESET at 0 range 12 .. 12;
DEV_CONN_DIS at 0 range 13 .. 13;
DEV_SUSPEND at 0 range 14 .. 14;
DEV_RESUME_FROM_HOST at 0 range 15 .. 15;
SETUP_REQ at 0 range 16 .. 16;
DEV_SOF at 0 range 17 .. 17;
ABORT_DONE at 0 range 18 .. 18;
EP_STALL_NAK at 0 range 19 .. 19;
Reserved_20_31 at 0 range 20 .. 31;
end record;
-----------------
-- Peripherals --
-----------------
-- USB FS/LS controller device registers
type USBCTRL_REGS_Peripheral is record
-- Device address and endpoint control
ADDR_ENDP : aliased ADDR_ENDP_Register;
-- Interrupt endpoint 1. Only valid for HOST mode.
ADDR_ENDP1 : aliased ADDR_ENDP_Register_1;
-- Interrupt endpoint 2. Only valid for HOST mode.
ADDR_ENDP2 : aliased ADDR_ENDP_Register_1;
-- Interrupt endpoint 3. Only valid for HOST mode.
ADDR_ENDP3 : aliased ADDR_ENDP_Register_1;
-- Interrupt endpoint 4. Only valid for HOST mode.
ADDR_ENDP4 : aliased ADDR_ENDP_Register_1;
-- Interrupt endpoint 5. Only valid for HOST mode.
ADDR_ENDP5 : aliased ADDR_ENDP_Register_1;
-- Interrupt endpoint 6. Only valid for HOST mode.
ADDR_ENDP6 : aliased ADDR_ENDP_Register_1;
-- Interrupt endpoint 7. Only valid for HOST mode.
ADDR_ENDP7 : aliased ADDR_ENDP_Register_1;
-- Interrupt endpoint 8. Only valid for HOST mode.
ADDR_ENDP8 : aliased ADDR_ENDP_Register_1;
-- Interrupt endpoint 9. Only valid for HOST mode.
ADDR_ENDP9 : aliased ADDR_ENDP_Register_1;
-- Interrupt endpoint 10. Only valid for HOST mode.
ADDR_ENDP10 : aliased ADDR_ENDP_Register_1;
-- Interrupt endpoint 11. Only valid for HOST mode.
ADDR_ENDP11 : aliased ADDR_ENDP_Register_1;
-- Interrupt endpoint 12. Only valid for HOST mode.
ADDR_ENDP12 : aliased ADDR_ENDP_Register_1;
-- Interrupt endpoint 13. Only valid for HOST mode.
ADDR_ENDP13 : aliased ADDR_ENDP_Register_1;
-- Interrupt endpoint 14. Only valid for HOST mode.
ADDR_ENDP14 : aliased ADDR_ENDP_Register_1;
-- Interrupt endpoint 15. Only valid for HOST mode.
ADDR_ENDP15 : aliased ADDR_ENDP_Register_1;
-- Main control register
MAIN_CTRL : aliased MAIN_CTRL_Register;
-- Set the SOF (Start of Frame) frame number in the host controller. The
-- SOF packet is sent every 1ms and the host will increment the frame
-- number by 1 each time.
SOF_WR : aliased SOF_WR_Register;
-- Read the last SOF (Start of Frame) frame number seen. In device mode
-- the last SOF received from the host. In host mode the last SOF sent
-- by the host.
SOF_RD : aliased SOF_RD_Register;
-- SIE control register
SIE_CTRL : aliased SIE_CTRL_Register;
-- SIE status register
SIE_STATUS : aliased SIE_STATUS_Register;
-- interrupt endpoint control register
INT_EP_CTRL : aliased INT_EP_CTRL_Register;
-- Buffer status register. A bit set here indicates that a buffer has
-- completed on the endpoint (if the buffer interrupt is enabled). It is
-- possible for 2 buffers to be completed, so clearing the buffer status
-- bit may instantly re set it on the next clock cycle.
BUFF_STATUS : aliased BUFF_STATUS_Register;
-- Which of the double buffers should be handled. Only valid if using an
-- interrupt per buffer (i.e. not per 2 buffers). Not valid for host
-- interrupt endpoint polling because they are only single buffered.
BUFF_CPU_SHOULD_HANDLE : aliased BUFF_CPU_SHOULD_HANDLE_Register;
-- Device only: Can be set to ignore the buffer control register for
-- this endpoint in case you would like to revoke a buffer. A NAK will
-- be sent for every access to the endpoint until this bit is cleared. A
-- corresponding bit in `EP_ABORT_DONE` is set when it is safe to modify
-- the buffer control register.
EP_ABORT : aliased EP_ABORT_Register;
-- Device only: Used in conjunction with `EP_ABORT`. Set once an
-- endpoint is idle so the programmer knows it is safe to modify the
-- buffer control register.
EP_ABORT_DONE : aliased EP_ABORT_DONE_Register;
-- Device: this bit must be set in conjunction with the `STALL` bit in
-- the buffer control register to send a STALL on EP0. The device
-- controller clears these bits when a SETUP packet is received because
-- the USB spec requires that a STALL condition is cleared when a SETUP
-- packet is received.
EP_STALL_ARM : aliased EP_STALL_ARM_Register;
-- Used by the host controller. Sets the wait time in microseconds
-- before trying again if the device replies with a NAK.
NAK_POLL : aliased NAK_POLL_Register;
-- Device: bits are set when the `IRQ_ON_NAK` or `IRQ_ON_STALL` bits are
-- set. For EP0 this comes from `SIE_CTRL`. For all other endpoints it
-- comes from the endpoint control register.
EP_STATUS_STALL_NAK : aliased EP_STATUS_STALL_NAK_Register;
-- Where to connect the USB controller. Should be to_phy by default.
USB_MUXING : aliased USB_MUXING_Register;
-- Overrides for the power signals in the event that the VBUS signals
-- are not hooked up to GPIO. Set the value of the override and then the
-- override enable to switch over to the override value.
USB_PWR : aliased USB_PWR_Register;
-- This register allows for direct control of the USB phy. Use in
-- conjunction with usbphy_direct_override register to enable each
-- override bit.
USBPHY_DIRECT : aliased USBPHY_DIRECT_Register;
-- Override enable for each control in usbphy_direct
USBPHY_DIRECT_OVERRIDE : aliased USBPHY_DIRECT_OVERRIDE_Register;
-- Used to adjust trim values of USB phy pull down resistors.
USBPHY_TRIM : aliased USBPHY_TRIM_Register;
-- Raw Interrupts
INTR : aliased INTR_Register;
-- Interrupt Enable
INTE : aliased INTE_Register;
-- Interrupt Force
INTF : aliased INTF_Register;
-- Interrupt status after masking & forcing
INTS : aliased INTS_Register;
end record
with Volatile;
for USBCTRL_REGS_Peripheral use record
ADDR_ENDP at 16#0# range 0 .. 31;
ADDR_ENDP1 at 16#4# range 0 .. 31;
ADDR_ENDP2 at 16#8# range 0 .. 31;
ADDR_ENDP3 at 16#C# range 0 .. 31;
ADDR_ENDP4 at 16#10# range 0 .. 31;
ADDR_ENDP5 at 16#14# range 0 .. 31;
ADDR_ENDP6 at 16#18# range 0 .. 31;
ADDR_ENDP7 at 16#1C# range 0 .. 31;
ADDR_ENDP8 at 16#20# range 0 .. 31;
ADDR_ENDP9 at 16#24# range 0 .. 31;
ADDR_ENDP10 at 16#28# range 0 .. 31;
ADDR_ENDP11 at 16#2C# range 0 .. 31;
ADDR_ENDP12 at 16#30# range 0 .. 31;
ADDR_ENDP13 at 16#34# range 0 .. 31;
ADDR_ENDP14 at 16#38# range 0 .. 31;
ADDR_ENDP15 at 16#3C# range 0 .. 31;
MAIN_CTRL at 16#40# range 0 .. 31;
SOF_WR at 16#44# range 0 .. 31;
SOF_RD at 16#48# range 0 .. 31;
SIE_CTRL at 16#4C# range 0 .. 31;
SIE_STATUS at 16#50# range 0 .. 31;
INT_EP_CTRL at 16#54# range 0 .. 31;
BUFF_STATUS at 16#58# range 0 .. 31;
BUFF_CPU_SHOULD_HANDLE at 16#5C# range 0 .. 31;
EP_ABORT at 16#60# range 0 .. 31;
EP_ABORT_DONE at 16#64# range 0 .. 31;
EP_STALL_ARM at 16#68# range 0 .. 31;
NAK_POLL at 16#6C# range 0 .. 31;
EP_STATUS_STALL_NAK at 16#70# range 0 .. 31;
USB_MUXING at 16#74# range 0 .. 31;
USB_PWR at 16#78# range 0 .. 31;
USBPHY_DIRECT at 16#7C# range 0 .. 31;
USBPHY_DIRECT_OVERRIDE at 16#80# range 0 .. 31;
USBPHY_TRIM at 16#84# range 0 .. 31;
INTR at 16#8C# range 0 .. 31;
INTE at 16#90# range 0 .. 31;
INTF at 16#94# range 0 .. 31;
INTS at 16#98# range 0 .. 31;
end record;
-- USB FS/LS controller device registers
USBCTRL_REGS_Periph : aliased USBCTRL_REGS_Peripheral
with Import, Address => USBCTRL_REGS_Base;
end RP_SVD.USBCTRL_REGS;
|
with Operation; use Operation;
package Calculate1 is
function Execute(Value: String;
Current_Index: in out Integer) return NaturalDouble;
end Calculate1;
|
-- ---------------------------------------------------------------------------
-- --
-- TIME constant and type definitions and management services --
-- --
-- ---------------------------------------------------------------------------
package APEX.Timing is
procedure Timed_Wait
(Delay_Time : in System_Time_Type;
Return_Code : out Return_Code_Type);
procedure Periodic_Wait (Return_Code : out Return_Code_Type);
procedure Get_Time
(System_Time : out System_Time_Type;
Return_Code : out Return_Code_Type);
procedure Replenish
(Budget_Time : in System_Time_Type;
Return_Code : out Return_Code_Type);
-- POK BINDINGS
pragma Import (C, Timed_Wait, "TIMED_WAIT");
pragma Import (C, Periodic_Wait, "PERIODIC_WAIT");
pragma Import (C, Get_Time, "GET_TIME");
pragma Import (C, Replenish, "REPLENISH");
-- END OF POK BINDINGS
end Apex.Timing;
|
package lace.Text.forge
--
-- Provides constructors for Text.
--
is
-- Files
--
type Filename is new String;
function to_String (Filename : in forge.Filename) return String;
function to_Text (Filename : in forge.Filename) return Item;
-- Stock Items
--
function to_Text_2 (From : in String) return Item_2;
function to_Text_2 (From : in Text.item) return Item_2;
function to_Text_4 (From : in String) return Item_4;
function to_Text_4 (From : in Text.item) return Item_4;
function to_Text_8 (From : in String) return Item_8;
function to_Text_8 (From : in Text.item) return Item_8;
function to_Text_16 (From : in String) return Item_16;
function to_Text_16 (From : in Text.item) return Item_16;
function to_Text_32 (From : in String) return Item_32;
function to_Text_32 (From : in Text.item) return Item_32;
function to_Text_64 (From : in String) return Item_64;
function to_Text_64 (From : in Text.item) return Item_64;
function to_Text_128 (From : in String) return Item_128;
function to_Text_128 (From : in Text.item) return Item_128;
function to_Text_256 (From : in String) return Item_256;
function to_Text_256 (From : in Text.item) return Item_256;
function to_Text_512 (From : in String) return Item_512;
function to_Text_512 (From : in Text.item) return Item_512;
function to_Text_1k (From : in String) return Item_1k;
function to_Text_1k (From : in Text.item) return Item_1k;
function to_Text_2k (From : in String) return Item_2k;
function to_Text_2k (From : in Text.item) return Item_2k;
function to_Text_4k (From : in String) return Item_4k;
function to_Text_4k (From : in Text.item) return Item_4k;
function to_Text_8k (From : in String) return Item_8k;
function to_Text_8k (From : in Text.item) return Item_8k;
function to_Text_16k (From : in String) return Item_16k;
function to_Text_16k (From : in Text.item) return Item_16k;
function to_Text_32k (From : in String) return Item_32k;
function to_Text_32k (From : in Text.item) return Item_32k;
function to_Text_64k (From : in String) return Item_64k;
function to_Text_64k (From : in Text.item) return Item_64k;
function to_Text_128k (From : in String) return Item_128k;
function to_Text_128k (From : in Text.item) return Item_128k;
function to_Text_256k (From : in String) return Item_256k;
function to_Text_256k (From : in Text.item) return Item_256k;
function to_Text_512k (From : in String) return Item_512k;
function to_Text_512k (From : in Text.item) return Item_512k;
function to_Text_1m (From : in String) return Item_1m;
function to_Text_1m (From : in Text.item) return Item_1m;
function to_Text_2m (From : in String) return Item_2m;
function to_Text_2m (From : in Text.item) return Item_2m;
function to_Text_4m (From : in String) return Item_4m;
function to_Text_4m (From : in Text.item) return Item_4m;
function to_Text_8m (From : in String) return Item_8m;
function to_Text_8m (From : in Text.item) return Item_8m;
function to_Text_16m (From : in String) return Item_16m;
function to_Text_16m (From : in Text.item) return Item_16m;
function to_Text_32m (From : in String) return Item_32m;
function to_Text_32m (From : in Text.item) return Item_32m;
function to_Text_64m (From : in String) return Item_64m;
function to_Text_64m (From : in Text.item) return Item_64m;
function to_Text_128m (From : in String) return Item_128m;
function to_Text_128m (From : in Text.item) return Item_128m;
function to_Text_256m (From : in String) return Item_256m;
function to_Text_256m (From : in Text.item) return Item_256m;
function to_Text_512m (From : in String) return Item_512m;
function to_Text_512m (From : in Text.item) return Item_512m;
end lace.Text.forge;
|
package PIN with SPARK_Mode is
type PIN is private;
function From_String(S : in String) return PIN with
Pre => (S' Length = 4 and
(for all I in S'Range => S(I) >= '0' and S(I) <= '9'));
private
type PIN is new Natural range 0..9999;
end PIN;
|
-- Définition de structures de données sous forme d'une liste chaînée (LC).
generic
type T_Cle is private;
type T_Donnee is private;
package LC is
type T_LC is limited private;
-- Initialiser une Sda. La Sda est vide.
procedure Initialiser(Sda: out T_LC) with
Post => Est_Vide (Sda);
-- Est-ce qu'une Sda est vide ?
function Est_Vide (Sda : T_LC) return Boolean;
-- Obtenir le nombre d'éléments d'une Sda.
function Taille (Sda : in T_LC) return Integer with
Post => Taille'Result >= 0
and (Taille'Result = 0) = Est_Vide (Sda);
-- Ajoute une Donnée associée à une Clé dans une Sda.
procedure Ajouter (Sda : in out T_LC ; Cle : in T_Cle ; Donnee : in T_Donnee);
-- Supprimer tous les éléments d'une Sda.
procedure Vider (Sda : in out T_LC) with
Post => Est_Vide (Sda);
-- Appliquer un traitement (Traiter) pour chaque couple d'une Sda.
generic
with procedure Traiter (Cle : in T_Cle; Donnee: in T_Donnee);
procedure Pour_Chaque (Sda : in T_LC);
private
type T_Cellule;
type T_LC is access T_Cellule;
type T_Cellule is record
Cle : T_Cle;
Donnee : T_Donnee;
Suivant : T_LC;
end record;
end LC;
|
function Color (Picture : Grayscale_Image) return Image is
Result : Image (Picture'Range (1), Picture'Range (2));
begin
for I in Picture'Range (1) loop
for J in Picture'Range (2) loop
Result (I, J) := (others => Picture (I, J));
end loop;
end loop;
return Result;
end Color;
|
-- Score PIXAL le 07/10/2020 à 17:48 : 100%
with Ada.Text_IO; use Ada.Text_IO;
with Ada.Integer_Text_IO; use Ada.Integer_Text_IO;
-- Afficher le PGCD de deux entiers positifs.
procedure PGCD is
A, B: Integer;
n_A, n_B: Integer;
pgcd: Integer;
begin
-- Demander deux entiers A et B
Put("A et B ? ");
Get(A);
Get(B);
-- Determiner le PGCD de A et B
n_A := A;
n_B := B;
while n_A /= n_B loop -- Tant que n_A different de n_B
-- Soustraire au plus grande le plus petit
if n_A > n_B then
n_A := n_A - n_B;
else
n_B := n_B - n_A;
end if;
end loop;
pgcd := n_A;
-- Afficher le PGCD
Put("pgcd = ");
Put(pgcd);
end PGCD;
|
with Ada.Text_IO;
with Config; use Config;
procedure Read_Config is
use Ada.Text_IO;
use Rosetta_Config;
begin
New_Line;
Put_Line ("Reading Configuration File.");
Put_Line ("Fullname := " & Get (Key => FULLNAME));
Put_Line ("Favorite Fruit := " & Get (Key => FAVOURITEFRUIT));
Put_Line ("Other Family := " & Get (Key => OTHERFAMILY));
if Has_Value (Key => NEEDSPEELING) then
Put_Line ("NEEDSPEELLING := " & Get (Key => NEEDSPEELING));
else
Put_Line ("NEEDSPEELLING := True");
end if;
if Has_Value (Key => SEEDSREMOVED) then
Put_Line ("SEEDSREMOVED := " & Get (Key => SEEDSREMOVED));
else
Put_Line ("SEEDSREMOVED := True");
end if;
end Read_Config;
|
-- Initialization is executed only once at power-on and executes
-- routines that set-up peripherals.
package Startup is
procedure Initialize;
-- Initializes peripherals and configures them into a known state.
procedure Start_Inverter;
-- Start the inverter
private
Initialized : Boolean := False;
end Startup;
|
-- Copyright (c) 2019 Maxim Reznik <reznikmm@gmail.com>
--
-- SPDX-License-Identifier: MIT
-- License-Filename: LICENSE
-------------------------------------------------------------
with System.Storage_Elements;
with Ada.Storage_IO;
package body Slim.Messages is
-----------------
-- Read_Fields --
-----------------
procedure Read_Fields
(Self : in out Base_Message'Class;
List : Field_Description_Array;
Data : League.Stream_Element_Vectors.Stream_Element_Vector)
is
use type Ada.Streams.Stream_Element_Offset;
generic
type Element is private;
procedure Read (Result : out Element);
Input : Ada.Streams.Stream_Element_Offset := 1;
----------
-- Read --
----------
procedure Read (Result : out Element) is
package IO is new Ada.Storage_IO (Element);
Buffer : IO.Buffer_Type;
begin
for J in reverse Buffer'Range loop
Buffer (J) := System.Storage_Elements.Storage_Element
(Data.Element (Input));
Input := Input + 1;
end loop;
IO.Read (Buffer, Result);
end Read;
procedure Read_8 is new Read (Interfaces.Unsigned_8);
procedure Read_16 is new Read (Interfaces.Unsigned_16);
procedure Read_32 is new Read (Interfaces.Unsigned_32);
procedure Read_64 is new Read (Interfaces.Unsigned_64);
Kind : Field_Kinds;
Fields : Field_Description_Array := List;
Index : Positive := Fields'First;
Counts : array (Field_Kinds) of Natural := (others => 0);
begin
while Index <= Fields'Last loop
Kind := Fields (Index).Kind;
Counts (Kind) := Counts (Kind) + 1;
case Kind is
when Uint_8_Field =>
Read_8 (Self.Data_8 (Counts (Kind)));
when Uint_16_Field =>
Read_16 (Self.Data_16 (Counts (Kind)));
when Uint_32_Field =>
Read_32 (Self.Data_32 (Counts (Kind)));
when Uint_64_Field =>
Read_64 (Self.Data_64 (Counts (Kind)));
when others =>
Self.Read_Custom_Field
(Index => Counts (Kind),
Input => Input,
Data => Data);
end case;
if Fields (Index).Count = 1 then
Index := Index + 1;
else
Fields (Index).Count := Fields (Index).Count - 1;
end if;
end loop;
end Read_Fields;
-----------
-- Slice --
-----------
procedure Slice
(Result : out Ada.Streams.Stream_Element_Array;
From : Ada.Streams.Stream_Element_Offset)
is
use type Ada.Streams.Stream_Element_Offset;
begin
for J in Result'Range loop
Result (J) := Data.Element (From + J - Result'First);
end loop;
end Slice;
------------------
-- Write_Fields --
------------------
procedure Write_Fields
(Self : Base_Message'Class;
List : Field_Description_Array;
Data : in out League.Stream_Element_Vectors.Stream_Element_Vector)
is
generic
type Element is private;
procedure Write (Result : Element);
-----------
-- Write --
-----------
procedure Write (Result : Element) is
package IO is new Ada.Storage_IO (Element);
Buffer : IO.Buffer_Type;
begin
IO.Write (Buffer, Result);
-- Use network byte order, so use 'reverse'
for J in reverse Buffer'Range loop
Data.Append (Ada.Streams.Stream_Element (Buffer (J)));
end loop;
end Write;
procedure Write_8 is new Write (Interfaces.Unsigned_8);
procedure Write_16 is new Write (Interfaces.Unsigned_16);
procedure Write_32 is new Write (Interfaces.Unsigned_32);
procedure Write_64 is new Write (Interfaces.Unsigned_64);
Kind : Field_Kinds;
Fields : Field_Description_Array := List;
Index : Positive := Fields'First;
Counts : array (Field_Kinds) of Natural := (others => 0);
begin
while Index <= Fields'Last loop
Kind := Fields (Index).Kind;
Counts (Kind) := Counts (Kind) + 1;
case Kind is
when Uint_8_Field =>
Write_8 (Self.Data_8 (Counts (Kind)));
when Uint_16_Field =>
Write_16 (Self.Data_16 (Counts (Kind)));
when Uint_32_Field =>
Write_32 (Self.Data_32 (Counts (Kind)));
when Uint_64_Field =>
Write_64 (Self.Data_64 (Counts (Kind)));
when others =>
Self.Write_Custom_Field
(Index => Counts (Kind),
Data => Data);
end case;
if Fields (Index).Count = 1 then
Index := Index + 1;
else
Fields (Index).Count := Fields (Index).Count - 1;
end if;
end loop;
end Write_Fields;
end Slim.Messages;
|
package FLTK.Environment is
type Preferences is new Wrapper with private;
type Preferences_Reference (Data : not null access Preferences'Class) is
limited null record with Implicit_Dereference => Data;
type Scope is (Root, User);
Preference_Error : exception;
package Forge is
function From_Filesystem
(Path, Vendor, Application : in String)
return Preferences;
end Forge;
function Number_Of_Entries
(This : in Preferences)
return Natural;
function Get_Key
(This : in Preferences;
Index : in Natural)
return String;
function Entry_Exists
(This : in Preferences;
Key : in String)
return Boolean;
function Entry_Size
(This : in Preferences;
Key : in String)
return Natural;
function Get
(This : in Preferences;
Key : in String)
return Integer;
function Get
(This : in Preferences;
Key : in String)
return Float;
function Get
(This : in Preferences;
Key : in String)
return Long_Float;
function Get
(This : in Preferences;
Key : in String)
return String;
function Get
(This : in Preferences;
Key : in String;
Default : in Integer)
return Integer;
function Get
(This : in Preferences;
Key : in String;
Default : in Float)
return Float;
function Get
(This : in Preferences;
Key : in String;
Default : in Long_Float)
return Long_Float;
function Get
(This : in Preferences;
Key : in String;
Default : in String)
return String;
procedure Set
(This : in out Preferences;
Key : in String;
Value : in Integer);
procedure Set
(This : in out Preferences;
Key : in String;
Value : in Float);
procedure Set
(This : in out Preferences;
Key : in String;
Value : in Float;
Precision : in Natural);
procedure Set
(This : in out Preferences;
Key : in String;
Value : in Long_Float);
procedure Set
(This : in out Preferences;
Key : in String;
Value : in Long_Float;
Precision : in Natural);
procedure Set
(This : in out Preferences;
Key : in String;
Value : in String);
procedure Delete_Entry
(This : in out Preferences;
Key : in String);
procedure Delete_All_Entries
(This : in out Preferences);
procedure Clear
(This : in out Preferences);
procedure Flush
(This : in Preferences);
private
type Preferences is new Wrapper with null record;
overriding procedure Finalize
(This : in out Preferences);
pragma Inline (Number_Of_Entries);
pragma Inline (Get_Key);
pragma Inline (Entry_Exists);
pragma Inline (Entry_Size);
pragma Inline (Get);
pragma Inline (Set);
pragma Inline (Delete_Entry);
pragma Inline (Delete_All_Entries);
pragma Inline (Clear);
pragma Inline (Flush);
end FLTK.Environment;
|
-- -----------------------------------------------------------------------------
-- Copyright (C) 2003-2019 Stichting Mapcode Foundation (http://www.mapcode.com)
--
-- Licensed under the Apache License, Version 2.0 (the "License");
-- you may not use this file except in compliance with the License.
-- You may obtain a copy of the License at
--
-- http://www.apache.org/licenses/LICENSE-2.0
--
-- Unless required by applicable law or agreed to in writing, software
-- distributed under the License is distributed on an "AS IS" BASIS,
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-- See the License for the specific language governing permissions and
-- limitations under the License.
-- -----------------------------------------------------------------------------
with Language_Defs, Language_Utils;
package Mapcodes.Languages is
-- The supported languages
-- The language names in Roman are the Mixed_Str images of these enums
type Language_List is new Language_Defs.Language_List;
-- Roman, Greek, Cyrillic, Hebrew, Devanagari, Malayalam, Georgian, Katakana,
-- Thai, Lao, Armenian, Bengali, Gurmukhi, Tibetan, Arabic, Korean, Burmese,
-- Khmer, Sinhalese, Thaana, Chinese, Tifinagh, Tamil, Amharic, Telugu, Odia,
-- Kannada, Gujarati
-- The unicode sequence to provide a language name in its language
subtype Unicode_Sequence is Language_Utils.Unicode_Sequence;
-- Get the Language from its name in its language
-- Raises, if the output language is not known:
Unknown_Language : exception;
function Get_Language (Name : Unicode_Sequence) return Language_List;
-- Get the language of a text (territory name or mapcode)
-- All the characters must be of the same language, otherwise raises
Invalid_Text : exception;
function Get_Language (Input : Wide_String) return Language_List;
-- The default language
Default_Language : constant Language_List := Roman;
-- Conversion of a text (territory name or mapcode) into a given language
-- The language of the input is detected automatically
-- Raises Invalid_Text if the input is not valid
function Convert (Input : Wide_String;
Output_Language : Language_List := Default_Language)
return Wide_String;
end Mapcodes.Languages;
|
with Ada.Text_IO;
procedure Fib is
procedure Print(Item : Natural) is
S : constant String := Natural'Image(Item);
begin
Ada.Text_IO.Put_Line(S(S'First + 1 .. S'Last));
end Print;
A, B : Natural;
begin
Print(0);
Print(1);
A := 1;
Print(A);
B := A + A;
Print(B);
while A < 1000000 loop
A := A + B;
Print(A);
B := A + B;
Print(B);
end loop;
end Fib;
|
--with Imu.Library; use Imu.Library
with Exception_Declarations; use Exception_Declarations;
package Meassure_Acceleration is
procedure Retrieve_Acceleration (Acc_X, Acc_Y : out Float);
private
X_Coordinate : Float;
Y_Coordinate : Float;
Z_Coordinate : Float;
end Meassure_Acceleration;
|
-- -----------------------------------------------------------------------------
-- Copyright 2018 Lionel Draghi
--
-- 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.
-- -----------------------------------------------------------------------------
-- This file is part of the List_Image project
-- available at https://github.com/LionelDraghi/List_Image
-- -----------------------------------------------------------------------------
with Ada.Strings.Unbounded;
package body List_Image is
function Image (Cont : in Cursors.Container) return String is
use Cursors, Ada.Strings.Unbounded;
C1, C2 : Cursor;
Tmp : Unbounded_String;
begin
C1 := First (Cont);
if not Has_Element (C1) then
-- empty data structure
return Style.Prefix_If_Empty & Style.Postfix_If_Empty;
else
-- before using the first list item, we need to know if there is
-- another one.
C2 := Next (C1);
if not Has_Element (C2) then
-- single item list
return Style.Prefix_If_Single & Image (C1)
& Style.Postfix_If_Single;
else
-- at least two item in the list
Tmp := To_Unbounded_String (Style.Prefix);
Append (Tmp, Image (C1));
loop
C1 := C2;
C2 := Next (C2);
if Has_Element (C2) then
-- C1 do not yet point the last item
Append (Tmp, Style.Separator);
Append (Tmp, Image (C1));
else
-- C1 point the last item
Append (Tmp, Style.Last_Separator);
Append (Tmp, Image (C1));
exit;
end if;
end loop;
end if;
end if;
Append (Tmp, Style.Postfix);
return To_String (Tmp);
end Image;
end List_Image;
|
------------------------------------------------------------------------------
-- --
-- GNAT COMPILER COMPONENTS --
-- --
-- S E M _ C H 1 0 --
-- --
-- S p e c --
-- --
-- Copyright (C) 1992-2020, Free Software Foundation, Inc. --
-- --
-- GNAT is free software; you can redistribute it and/or modify it under --
-- terms of the GNU General Public License as published by the Free Soft- --
-- ware Foundation; either version 3, or (at your option) any later ver- --
-- sion. GNAT is distributed in the hope that it will be useful, but WITH- --
-- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY --
-- or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License --
-- for more details. You should have received a copy of the GNU General --
-- Public License distributed with GNAT; see file COPYING3. If not, go to --
-- http://www.gnu.org/licenses for a complete copy of the license. --
-- --
-- GNAT was originally developed by the GNAT team at New York University. --
-- Extensive contributions were provided by Ada Core Technologies Inc. --
-- --
------------------------------------------------------------------------------
with Types; use Types;
package Sem_Ch10 is
procedure Analyze_Compilation_Unit (N : Node_Id);
procedure Analyze_With_Clause (N : Node_Id);
procedure Analyze_Subprogram_Body_Stub (N : Node_Id);
procedure Analyze_Package_Body_Stub (N : Node_Id);
procedure Analyze_Task_Body_Stub (N : Node_Id);
procedure Analyze_Protected_Body_Stub (N : Node_Id);
procedure Analyze_Subunit (N : Node_Id);
procedure Install_Context (N : Node_Id; Chain : Boolean := True);
-- Installs the entities from the context clause of the given compilation
-- unit into the visibility chains. This is done before analyzing a unit.
-- For a child unit, install context of parents as well. The flag Chain is
-- used to control the "chaining" or linking of use-type and use-package
-- clauses to avoid circularities when reinstalling context clauses.
procedure Install_Private_With_Clauses (P : Entity_Id);
-- Install the private with_clauses of a compilation unit, when compiling
-- its private part, compiling a private child unit, or compiling the
-- private declarations of a public child unit.
function Is_Legal_Shadow_Entity_In_Body (T : Entity_Id) return Boolean;
-- Assuming that type T is an incomplete type coming from a limited with
-- view, determine whether the package where T resides is imported through
-- a regular with clause in the current package body.
procedure Remove_Context (N : Node_Id);
-- Removes the entities from the context clause of the given compilation
-- unit from the visibility chains. This is done on exit from a unit as
-- part of cleaning up the visibility chains for the caller. A special
-- case is that the call from the Main_Unit can be ignored, since at the
-- end of the main unit the visibility table won't be needed in any case.
-- For a child unit, remove parents and their context as well.
procedure Remove_Private_With_Clauses (Comp_Unit : Node_Id);
-- The private_with_clauses of a compilation unit are visible in the
-- private part of a nested package, even if this package appears in
-- the visible part of the enclosing compilation unit. This Ada 2005
-- rule imposes extra steps in order to install/remove the private_with
-- clauses of an enclosing unit.
procedure Load_Needed_Body
(N : Node_Id;
OK : out Boolean;
Do_Analyze : Boolean := True);
-- Load and analyze the body of a context unit that is generic, or that
-- contains generic units or inlined units. The body becomes part of the
-- semantic dependency set of the unit that needs it. The returned result
-- in OK is True if the load is successful, and False if the requested file
-- cannot be found. If the flag Do_Analyze is false, the unit is loaded and
-- parsed only. This allows a selective analysis in some inlining cases
-- where a full analysis would lead so circularities in the back-end.
end Sem_Ch10;
|
with
any_Math.any_fast_Trigonometry;
package float_Math.fast_Trigonometry is new float_Math.any_fast_Trigonometry;
|
-- Warning: This lexical scanner is automatically generated by AFLEX.
-- It is useless to modify it. Change the ".Y" & ".L" files instead.
with Ada.Strings.Unbounded;
with CSS.Parser.Parser_Tokens;
package CSS.Parser.Lexer is
use CSS.Parser.Parser_Tokens;
function YYLex return Token;
Current_Comment : Ada.Strings.Unbounded.Unbounded_String;
end CSS.Parser.Lexer;
|
------------------------------------------------------------------------------
-- --
-- GNAT RUN-TIME LIBRARY (GNARL) COMPONENTS --
-- --
-- S Y S T E M . T A S K I N G . P R O T E C T E D _ O B J E C T S . --
-- S I N G L E _ E N T R Y --
-- --
-- B o d y --
-- --
-- Copyright (C) 1998-2021, AdaCore --
-- --
-- GNARL 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. GNARL 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/>. --
-- --
-- GNARL was developed by the GNARL team at Florida State University. --
-- Extensive contributions were provided by Ada Core Technologies, Inc. --
-- --
------------------------------------------------------------------------------
pragma Style_Checks (All_Checks);
-- Turn off subprogram ordering check, since restricted GNARLI
-- subprograms are gathered together at end.
-- This package provides an optimized version of Protected_Objects.Operations
-- and Protected_Objects.Entries making the following assumptions:
--
-- PO have only one entry
-- There is only one caller at a time (No_Entry_Queue)
-- There is no dynamic priority support (No_Dynamic_Priorities)
-- No Abort Statements
-- (No_Abort_Statements, Max_Asynchronous_Select_Nesting => 0)
-- PO are at library level
-- No Requeue
-- None of the tasks will terminate (no need for finalization)
--
-- This interface is intended to be used in the ravenscar and restricted
-- profiles, the compiler is responsible for ensuring that the conditions
-- mentioned above are respected, except for the No_Entry_Queue restriction
-- that is checked dynamically in this package, since the check cannot be
-- performed at compile time (see Protected_Single_Entry_Call, Service_Entry).
pragma Suppress (All_Checks);
with System.Multiprocessors;
with System.Task_Primitives.Operations;
-- used for Self
-- Get_Priority
-- Set_Priority
with System.Tasking.Protected_Objects.Multiprocessors;
package body System.Tasking.Protected_Objects.Single_Entry is
use System.Multiprocessors;
package STPO renames System.Task_Primitives.Operations;
package STPOM renames System.Tasking.Protected_Objects.Multiprocessors;
Multiprocessor : constant Boolean := CPU'Range_Length /= 1;
---------------------------------
-- Initialize_Protection_Entry --
---------------------------------
procedure Initialize_Protection_Entry
(Object : Protection_Entry_Access;
Ceiling_Priority : Integer;
Compiler_Info : System.Address;
Entry_Body : Entry_Body_Access)
is
begin
Initialize_Protection (Object.Common'Access, Ceiling_Priority);
Object.Compiler_Info := Compiler_Info;
Object.Call_In_Progress := null;
Object.Entry_Body := Entry_Body;
Object.Entry_Queue := null;
end Initialize_Protection_Entry;
----------------
-- Lock_Entry --
----------------
procedure Lock_Entry (Object : Protection_Entry_Access) is
begin
Lock (Object.Common'Access);
end Lock_Entry;
---------------------------
-- Protected_Count_Entry --
---------------------------
function Protected_Count_Entry (Object : Protection_Entry) return Natural is
begin
return Boolean'Pos (Object.Entry_Queue /= null);
end Protected_Count_Entry;
---------------------------------
-- Protected_Single_Entry_Call --
---------------------------------
procedure Protected_Single_Entry_Call
(Object : Protection_Entry_Access;
Uninterpreted_Data : System.Address)
is
Self_Id : constant Task_Id := STPO.Self;
begin
-- For this run time, pragma Detect_Blocking is always active, so we
-- must raise Program_Error if this potentially blocking operation is
-- called from a protected action.
if Self_Id.Common.Protected_Action_Nesting > 0 then
raise Program_Error;
end if;
Lock_Entry (Object);
Self_Id.Entry_Call.Uninterpreted_Data := Uninterpreted_Data;
if Object.Entry_Body.Barrier (Object.Compiler_Info, 1) then
-- No other task can be executing an entry within this protected
-- object. On a single processor implementation (such as this one),
-- the ceiling priority protocol and the strictly preemptive priority
-- scheduling policy guarantee that protected objects are always
-- available when any task tries to use them (otherwise, either the
-- currently executing task would not have had a high enough priority
-- to be executing, or a blocking operation would have been called
-- from within the entry body).
pragma Assert (Object.Call_In_Progress = null);
Object.Call_In_Progress := Self_Id.Entry_Call'Access;
Object.Entry_Body.Action
(Object.Compiler_Info, Self_Id.Entry_Call.Uninterpreted_Data, 1);
Object.Call_In_Progress := null;
-- Entry call is over
Unlock_Entry (Object);
else
if Object.Entry_Queue /= null then
-- This violates the No_Entry_Queue restriction, raise
-- Program_Error.
Unlock_Entry (Object);
raise Program_Error;
end if;
-- There is a potential race condition between the Unlock_Entry and
-- the Sleep below (the Wakeup may be called before the Sleep). This
-- case is explicitly handled in the Sleep and Wakeup procedures:
-- Sleep won't block if Wakeup has been called before.
Object.Entry_Queue := Self_Id.Entry_Call'Access;
Unlock_Entry (Object);
-- Suspend until entry call has been completed.
-- On exit, the call will not be queued.
Self_Id.Common.State := Entry_Caller_Sleep;
STPO.Sleep (Self_Id, Entry_Caller_Sleep);
Self_Id.Common.State := Runnable;
end if;
end Protected_Single_Entry_Call;
-----------------------------------
-- Protected_Single_Entry_Caller --
-----------------------------------
function Protected_Single_Entry_Caller
(Object : Protection_Entry) return Task_Id
is
begin
return Object.Call_In_Progress.Self;
end Protected_Single_Entry_Caller;
-------------------
-- Service_Entry --
-------------------
procedure Service_Entry (Object : Protection_Entry_Access) is
Entry_Call : constant Entry_Call_Link := Object.Entry_Queue;
Caller : Task_Id;
begin
if Entry_Call /= null
and then Object.Entry_Body.Barrier (Object.Compiler_Info, 1)
then
Object.Entry_Queue := null;
-- No other task can be executing an entry within this protected
-- object. On a single processor implementation (such as this one),
-- the ceiling priority protocol and the strictly preemptive
-- priority scheduling policy guarantee that protected objects are
-- always available when any task tries to use them (otherwise,
-- either the currently executing task would not have had a high
-- enough priority to be executing, or a blocking operation would
-- have been called from within the entry body).
pragma Assert (Object.Call_In_Progress = null);
Object.Call_In_Progress := Entry_Call;
Object.Entry_Body.Action
(Object.Compiler_Info, Entry_Call.Uninterpreted_Data, 1);
Object.Call_In_Progress := null;
Caller := Entry_Call.Self;
Unlock_Entry (Object);
-- Signal the entry caller that the entry is completed
if not Multiprocessor
or else Caller.Common.Base_CPU = STPO.Self.Common.Base_CPU
then
-- Entry caller and servicing tasks are on the same CPU.
-- We are allowed to directly wake up the task.
STPO.Wakeup (Caller, Entry_Caller_Sleep);
else
-- The entry caller is on a different CPU.
STPOM.Served (Entry_Call);
end if;
else
-- Just unlock the entry
Unlock_Entry (Object);
end if;
end Service_Entry;
------------------
-- Unlock_Entry --
------------------
procedure Unlock_Entry (Object : Protection_Entry_Access) is
begin
Unlock (Object.Common'Access);
end Unlock_Entry;
end System.Tasking.Protected_Objects.Single_Entry;
|
//28/03/2022
with Text_IO; use Text_IO;
procedure hello is
begin
Put_Line("Hello world!");
end hello;
|
with ada.text_io;
use ada.text_io;
procedure euler2 is
a, b : integer := 1;
s : integer := 0;
begin
loop
declare
c : integer := a + b;
begin
exit when c > 4000000;
if c mod 2 = 0 then
s := s + c;
end if;
a := b;
b := c;
end;
end loop;
put_line(integer'image(s));
end euler2;
|
-- Copyright (c) 2021 Devin Hill
-- zlib License -- see LICENSE for details.
with GBA.Memory.IO_Registers;
use GBA.Memory.IO_Registers;
with Ada.Unchecked_Conversion;
with Interfaces;
use Interfaces;
package body GBA.Interrupts is
-- IO Register Definitions --
Enabled_Master : Boolean
with Import, Volatile, Address => IME;
Enabled_Flags : Interrupt_Flags
with Import, Volatile, Address => IE;
Acknowledge_Flags : Interrupt_Flags
with Import, Volatile, Address => IRF;
Acknowledge_BIOS_Flags : Interrupt_Flags
with Import, Volatile, Address => 16#3007FF8#;
-- ID to Flags conversions --
function As_Flags (ID : Interrupt_ID) return Interrupt_Flags
with Pure_Function, Inline_Always is
function Cast is new Ada.Unchecked_Conversion(Unsigned_16, Interrupt_Flags);
begin
return Cast( Shift_Left(1, Interrupt_ID'Enum_Rep(ID)) );
end;
function "or" (I1, I2 : Interrupt_ID) return Interrupt_Flags is
( As_Flags(I1) or As_Flags(I2) );
function "or" (F : Interrupt_Flags; I : Interrupt_ID) return Interrupt_Flags is
( F or As_Flags(I) );
-- Currently Registered Handlers --
Handlers : array (Interrupt_ID) of Interrupt_Handler := (others => null)
with Export, External_Name => "interrupt_handler_array";
procedure Default_Interrupt_Dispatcher is separate;
Interrupt_Dispatcher : access procedure
with Import, Address => 16#3007FFC#;
-- Master Interrupt Enable/Disable --
procedure Enable_Receiving_Interrupts (Enabled : Boolean) is
begin
Enabled_Master := Enabled;
end;
procedure Enable_Receiving_Interrupts is
begin
Enabled_Master := True;
end;
procedure Disable_Receiving_Interrupts (Enabled : out Boolean) is
begin
Enabled := Enabled_Master;
Enabled_Master := False;
end;
procedure Disable_Receiving_Interrupts is
begin
Enabled_Master := False;
end;
-- Individual Interrupt Enable/Disable --
procedure Enable_Interrupt (ID : Interrupt_ID) is
begin
Enabled_Flags := Enabled_Flags or ID;
end;
procedure Enable_Interrupt (Flags : Interrupt_Flags) is
begin
Enabled_Flags := Enabled_Flags or Flags;
end;
procedure Disable_Interrupt (ID : Interrupt_ID) is
begin
Enabled_Flags := Enabled_Flags and not As_Flags(ID);
end;
procedure Disable_Interrupt (Flags : Interrupt_Flags) is
begin
Enabled_Flags := Enabled_Flags and not Flags;
end;
procedure Disable_Interrupts_And_Save (Flags : out Interrupt_Flags) is
begin
Flags := Enabled_Flags;
Enabled_Flags := 0;
end;
procedure Acknowledge_Interrupt (ID : Interrupt_ID) is
Flags : Interrupt_Flags := As_Flags(ID);
begin
Acknowledge_Flags := Flags;
Acknowledge_BIOS_Flags := Flags;
end;
procedure Acknowledge_Interrupt (Flags : Interrupt_Flags) is
begin
Acknowledge_Flags := Flags;
Acknowledge_BIOS_Flags := Flags;
end;
-- Interrupt Handler Settings --
procedure Attach_Interrupt_Handler
(ID : Interrupt_ID; Handler : not null Interrupt_Handler) is
begin
Handlers(ID) := Handler;
end;
procedure Attach_Interrupt_Handler_And_Save
(ID : Interrupt_ID; Handler : not null Interrupt_Handler; Old_Handler : out Interrupt_Handler) is
begin
Old_Handler := Handlers(ID);
Handlers(ID) := Handler;
end;
procedure Detach_Interrupt_Handler (ID : Interrupt_ID) is
begin
Handlers(ID) := null;
end;
procedure Detach_Interrupt_Handler_And_Save
(ID : Interrupt_ID; Old_Handler : out Interrupt_Handler) is
begin
Old_Handler := Handlers(ID);
Handlers(ID) := null;
end;
begin
-- Register default handler.
-- Ensures safety of enabling interrupts.
Interrupt_Dispatcher := Default_Interrupt_Dispatcher'Access;
end GBA.Interrupts;
|
with Ada.Exceptions; use Ada.Exceptions;
with Ada.Real_Time; use Ada.Real_Time;
with Ada.Text_IO; use Ada.Text_IO;
with Ada.Unchecked_Deallocation;
with Communication; use Communication;
package body Botstate is
procedure Start (Self : in Bot)
is
Raw_RX : UByte_Array (1 .. Sensor_Collection'Size / 8);
Sensors : Sensor_Collection
with Address => Raw_RX'Address;
Next_Read : Time := Clock;
Period : constant Time_Span := Milliseconds (15);
begin
loop
Send_Command (Port => Self.Port,
Rec => Comm_Rec'(Op => Sensors_List,
Num_Query_Packets => 1),
Data => (1 => 100));
Read_Sensors (Port => Self.Port,
Buffer => Raw_RX);
Self.Algo.Safety_Check (Sensors => Sensors);
Self.Algo.Process (Port => Self.Port,
Sensors => Sensors);
Next_Read := Next_Read + Period;
delay until Next_Read;
end loop;
exception
when Safety_Exception =>
Put_Line ("Unhandled safety exception. Killing Control thread.");
when Error : others =>
Put ("Unexpected exception: ");
Put_Line (Exception_Information (Error));
end Start;
procedure Init (Self : in out Bot;
TTY_Name : in String;
Algo_Type : in Algorithm_Type)
is
begin
case Algo_Type is
when Pong =>
Self.Algo := new Pong_Algorithm;
Self.Port := Communication_Init (Data_Rate => B115200,
Name => TTY_Name);
Send_Command (Port => Self.Port,
Rec => Comm_Rec'(Op => Reset));
delay 5.0;
Send_Command (Port => Self.Port,
Rec => Comm_Rec'(Op => Start));
Clear_Comm_Buffer (Port => Self.Port);
Send_Command (Port => Self.Port,
Rec => Comm_Rec'(Op => Mode_Safe));
when others =>
null;
end case;
end Init;
procedure Free_Algo is new Ada.Unchecked_Deallocation
(Object => Abstract_Algorithm'Class, Name => Algorithm_Ptr);
procedure Kill (Self : in out Bot)
is
begin
Communications_Close (Port => Self.Port);
Free_Algo (Self.Algo);
end Kill;
end Botstate;
|
Pragma Ada_2012;
Package Body Connection_Types is
New_Line : Constant String := ASCII.CR & ASCII.LF;
---------------------
-- Solution Test --
---------------------
Function Is_Solution( Input : Partial_Board ) return Boolean is
(for all Index in Input'Range =>
(for all Connection in Node'Range =>
(if Network(Index)(Connection) and Connection in Input'Range
then abs (Input(Index) - Input(Connection)) > 1
)
)
);
------------------------
-- Concat Operators --
------------------------
Function "&"( Left : Used_Peg; Right : Peg ) return Used_Peg is
begin
return Result : Used_Peg := Left do
Result(Right):= True;
end return;
end "&";
Function "&"(Left : Connection_List; Right : Node) return Connection_List is
begin
Return Result : Connection_List := Left do
Result(Right):= True;
end return;
end "&";
-----------------------
-- IMAGE FUNCTIONS --
-----------------------
Function Image(Input : Peg) Return Character is
( Peg'Image(Input)(2) );
Function Image(Input : Peg) Return String is
( 1 => Image(Input) );
Function Image(Input : Partial_Board; Item : Node) Return String is
( 1 => (if Item not in Input'Range then '*' else Image(Input(Item)) ));
Function Image( Input : Partial_Board ) Return String is
A : String renames Image(Input, Connection_Types.A);
B : String renames Image(Input, Connection_Types.B);
C : String renames Image(Input, Connection_Types.C);
D : String renames Image(Input, Connection_Types.D);
E : String renames Image(Input, Connection_Types.E);
F : String renames Image(Input, Connection_Types.F);
G : String renames Image(Input, Connection_Types.G);
H : String renames Image(Input, Connection_Types.H);
begin
return
" "&A&" "&B & New_Line &
" /|\ /|\" & New_Line &
" / | X | \" & New_Line &
" / |/ \| \" & New_Line &
" "&C&" - "&D&" - "&E&" - "&F & New_Line &
" \ |\ /| /" & New_Line &
" \ | X | /" & New_Line &
" \|/ \|/" & New_Line &
" "&G&" "&H & New_Line;
end Image;
End Connection_Types;
|
--
-- Copyright (C) 2015-2016 secunet Security Networks AG
--
-- 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 2 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.
--
private package HW.Time.Timer
with
Abstract_State => ((Timer_State with Part_Of => HW.Time.State),
(Abstract_Time with
Part_Of => HW.Time.State,
External => Async_Writers)),
Initializes => (Timer_State)
is
-- Returns the highest point in time that has definitely passed.
function Raw_Value_Min return T
with
Volatile_Function,
Global => (Input => Abstract_Time),
Depends => (Raw_Value_Min'Result => Abstract_Time);
-- Returns the highest point in time that might have been reached yet.
function Raw_Value_Max return T
with
Volatile_Function,
Global => (Input => Abstract_Time),
Depends => (Raw_Value_Max'Result => Abstract_Time);
function Hz return T
with
Global => (Input => Timer_State);
end HW.Time.Timer;
|
pragma License (Unrestricted);
-- extended unit
with Ada.Strings.Functions;
with Ada.Strings.Generic_Bounded.Generic_Functions;
package Ada.Strings.Bounded_Strings.Functions is
new Generic_Functions (Strings.Functions);
pragma Preelaborate (Ada.Strings.Bounded_Strings.Functions);
|
pragma License (Unrestricted);
-- runtime unit specialized for POSIX (Darwin, FreeBSD, or Linux)
package System.Termination is
pragma Preelaborate;
-- write to standard error output
procedure Error_Put_Line (S : String);
-- force to abort
procedure Force_Abort;
pragma No_Return (Force_Abort);
-- register exit handler
type Exit_Handler is access procedure;
pragma Favor_Top_Level (Exit_Handler);
procedure Register_Exit (Handler : not null Exit_Handler);
end System.Termination;
|
with Ada.Text_IO; use Ada.Text_IO;
with Ada.Strings.Unbounded; use Ada.Strings.Unbounded;
with Ada.Exceptions;
with System.Storage_Elements; use System.Storage_Elements;
with COBS.Stream.Decoder;
with Offmt_Lib.Storage;
with Offmt_Lib.Fmt_Data;
package body Offmt_Lib.Decoding is
procedure Handle_Frame (Map : Trace_Map; Frame : in out Data_Frame);
procedure Put_Format (Fmt : Format; Frame : in out Data_Frame);
procedure Decode_From_File (Map : Trace_Map; File : in out File_Type);
type COBS_Decoder is new COBS.Stream.Decoder.Instance with record
Frame : Data_Frame;
Map : Trace_Map;
end record;
overriding
procedure Flush (This : in out COBS_Decoder;
Data : Storage_Array);
overriding
procedure End_Of_Frame (This : in out COBS_Decoder);
-----------
-- Flush --
-----------
overriding
procedure Flush (This : in out COBS_Decoder;
Data : Storage_Array)
is
begin
for Elt of Data loop
Push (This.Frame, Elt);
end loop;
end Flush;
------------------
-- End_Of_Frame --
------------------
overriding
procedure End_Of_Frame (This : in out COBS_Decoder) is
begin
Handle_Frame (This.Map, This.Frame);
Clear (This.Frame);
end End_Of_Frame;
----------------
-- Put_Format --
----------------
procedure Put_Format (Fmt : Format; Frame : in out Data_Frame) is
Data : Fmt_Data.Instance'Class := Fmt_Data.Create (Fmt.Typ);
begin
Data.From_Frame (Frame);
Put (Data.Format (Fmt.Kind));
end Put_Format;
------------------
-- Handle_Frame --
------------------
procedure Handle_Frame (Map : Trace_Map; Frame : in out Data_Frame) is
function Pop_Id (Frame : in out Data_Frame) return Trace_ID;
function Pop_Id (Frame : in out Data_Frame) return Trace_ID
is
Result : Trace_ID;
begin
if Remaining (Frame) < 2 then
raise Frame_Error with "Frame too short for ID";
else
Result := Trace_ID (Pop (Frame));
Result := Result or Shift_Left (Trace_ID (Pop (Frame)), 8);
return Result;
end if;
end Pop_Id;
Id : Trace_ID;
begin
-- Put_Line ("We have a frame of" & Remaining (Frame)'Img & " bytes");
Id := Pop_Id (Frame);
-- Put_Line ("Frame #" & Id'Img);
declare
T : constant Trace := Map.Element (Id);
begin
for Elt of T.List loop
case Elt.Kind is
when Plain_String =>
Put (To_String (Elt.Str));
when Format_String =>
Put_Format (Elt.Fmt, Frame);
end case;
end loop;
New_Line;
end;
exception
when E : Frame_Error =>
Put_Line ("Frame Error: " & Ada.Exceptions.Exception_Message (E));
end Handle_Frame;
----------------------
-- Decode_From_File --
----------------------
procedure Decode_From_File (Map : Trace_Map; File : in out File_Type) is
C : Character;
Decoder : COBS_Decoder;
begin
Decoder.Map := Map;
loop
Get_Immediate (File, C);
Decoder.Push (Storage_Element (C'Enum_Rep));
end loop;
exception
when End_Error =>
Close (File);
end Decode_From_File;
------------
-- Decode --
------------
procedure Decode (Map_Filename : String) is
Load : constant Storage.Load_Result := Storage.Load (Map_Filename);
File : File_Type := Standard_Input;
begin
if Load.Success then
Decode_From_File (Load.Map, File);
else
Put_Line ("Cannot open map file '" & Map_Filename & "': " &
To_String (Load.Msg));
raise Program_Error;
end if;
end Decode;
end Offmt_Lib.Decoding;
|
-- Copyright (c) 2020 Maxim Reznik <reznikmm@gmail.com>
--
-- SPDX-License-Identifier: MIT
-- License-Filename: LICENSE
-------------------------------------------------------------
with GNAT.Sockets;
with Torrent.Connections;
with Torrent.Downloaders;
limited with Torrent.Contexts;
package Torrent.Initiators is
task type Initiator
(Port : Natural;
Context : not null access Torrent.Contexts.Context;
Recycle : not null access
Torrent.Connections.Queue_Interfaces.Queue'Class)
is
entry Connect
(Downloader : not null Torrent.Downloaders.Downloader_Access;
Address : GNAT.Sockets.Sock_Addr_Type);
entry Stop;
end Initiator;
end Torrent.Initiators;
|
package lace.text.Cursor
--
-- Provides a cursor for traversing and interrogating text.
--
is
type Item is tagged private;
-- Forge
--
function First (of_Text : access constant Text.item) return Cursor.item;
-- Attributes
--
function Length (Self : in Item) return Natural;
--
-- Returns the length of the remaining text.
function has_Element (Self : in Item) return Boolean;
function next_Token (Self : in out item; Delimiter : in Character := ' ';
Trim : in Boolean := False) return String;
function next_Token (Self : in out item; Delimiter : in String := " ";
Trim : in Boolean := False) return String;
procedure skip_Token (Self : in out Item; Delimiter : in String := " ");
procedure skip_White (Self : in out Item);
procedure advance (Self : in out Item; Delimiter : in String := " ";
Repeat : in Natural := 0;
skip_Delimiter : in Boolean := True);
--
-- Search begins at the cursors current position.
-- Advances to the position immediately after Delimiter.
-- Sets Iterator to 0 if Delimiter is not found.
-- Search is repeated 'Repeat' times.
function get_Integer (Self : in out Item) return Integer;
--
-- Skips whitespace and reads the next legal 'integer' value.
-- Cursor is positioned at the next character following the integer.
-- Raises no_data_Error if no legal integer exists.
function get_Real (Self : in out Item) return long_Float;
--
-- Skips whitespace and reads the next legal 'real' value.
-- Cursor is positioned at the next character following the real.
-- Raises no_data_Error if no legal real exists.
Remaining : constant Natural;
function Peek (Self : in Item; Length : in Natural := Remaining) return String;
at_end_Error : exception;
no_data_Error : exception;
private
type Item is tagged
record
Target : access constant Text.item;
Current : Natural := 0;
end record;
Remaining : constant Natural := Natural'Last;
end lace.text.Cursor;
|
-- This spec has been automatically generated from STM32L562.svd
pragma Restrictions (No_Elaboration_Code);
pragma Ada_2012;
pragma Style_Checks (Off);
with HAL;
with System;
package STM32_SVD.HASH is
pragma Preelaborate;
---------------
-- Registers --
---------------
subtype CR_DATATYPE_Field is HAL.UInt2;
subtype CR_NBW_Field is HAL.UInt4;
type CR_Register is record
-- unspecified
Reserved_0_1 : HAL.UInt2 := 16#0#;
INIT : Boolean := False;
DMAE : Boolean := False;
DATATYPE : CR_DATATYPE_Field := 16#0#;
MODE : Boolean := False;
ALGO : Boolean := False;
NBW : CR_NBW_Field := 16#0#;
DINNE : Boolean := False;
MDMAT : Boolean := False;
-- unspecified
Reserved_14_15 : HAL.UInt2 := 16#0#;
LKEY : Boolean := False;
-- unspecified
Reserved_17_17 : HAL.Bit := 16#0#;
ALGO_1 : Boolean := False;
-- unspecified
Reserved_19_31 : HAL.UInt13 := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for CR_Register use record
Reserved_0_1 at 0 range 0 .. 1;
INIT at 0 range 2 .. 2;
DMAE at 0 range 3 .. 3;
DATATYPE at 0 range 4 .. 5;
MODE at 0 range 6 .. 6;
ALGO at 0 range 7 .. 7;
NBW at 0 range 8 .. 11;
DINNE at 0 range 12 .. 12;
MDMAT at 0 range 13 .. 13;
Reserved_14_15 at 0 range 14 .. 15;
LKEY at 0 range 16 .. 16;
Reserved_17_17 at 0 range 17 .. 17;
ALGO_1 at 0 range 18 .. 18;
Reserved_19_31 at 0 range 19 .. 31;
end record;
subtype STR_NBLW_Field is HAL.UInt5;
type STR_Register is record
NBLW : STR_NBLW_Field := 16#0#;
-- unspecified
Reserved_5_7 : HAL.UInt3 := 16#0#;
DCAL : Boolean := False;
-- unspecified
Reserved_9_31 : HAL.UInt23 := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for STR_Register use record
NBLW at 0 range 0 .. 4;
Reserved_5_7 at 0 range 5 .. 7;
DCAL at 0 range 8 .. 8;
Reserved_9_31 at 0 range 9 .. 31;
end record;
type IMR_Register is record
DINIE : Boolean := False;
DCIE : Boolean := False;
-- unspecified
Reserved_2_31 : HAL.UInt30 := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for IMR_Register use record
DINIE at 0 range 0 .. 0;
DCIE at 0 range 1 .. 1;
Reserved_2_31 at 0 range 2 .. 31;
end record;
type SR_Register is record
DINIS : Boolean := False;
DCIS : Boolean := False;
DMAS : Boolean := False;
BUSY : Boolean := False;
-- unspecified
Reserved_4_31 : HAL.UInt28 := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for SR_Register use record
DINIS at 0 range 0 .. 0;
DCIS at 0 range 1 .. 1;
DMAS at 0 range 2 .. 2;
BUSY at 0 range 3 .. 3;
Reserved_4_31 at 0 range 4 .. 31;
end record;
-----------------
-- Peripherals --
-----------------
type HASH_Peripheral is record
CR : aliased CR_Register;
DIN : aliased HAL.UInt32;
STR : aliased STR_Register;
HRA0 : aliased HAL.UInt32;
HRA1 : aliased HAL.UInt32;
HRA2 : aliased HAL.UInt32;
HRA3 : aliased HAL.UInt32;
HRA4 : aliased HAL.UInt32;
IMR : aliased IMR_Register;
SR : aliased SR_Register;
CSR0 : aliased HAL.UInt32;
CSR1 : aliased HAL.UInt32;
CSR2 : aliased HAL.UInt32;
CSR3 : aliased HAL.UInt32;
CSR4 : aliased HAL.UInt32;
CSR5 : aliased HAL.UInt32;
CSR6 : aliased HAL.UInt32;
CSR7 : aliased HAL.UInt32;
CSR8 : aliased HAL.UInt32;
CSR9 : aliased HAL.UInt32;
CSR10 : aliased HAL.UInt32;
CSR11 : aliased HAL.UInt32;
CSR12 : aliased HAL.UInt32;
CSR13 : aliased HAL.UInt32;
CSR14 : aliased HAL.UInt32;
CSR15 : aliased HAL.UInt32;
CSR16 : aliased HAL.UInt32;
CSR17 : aliased HAL.UInt32;
CSR18 : aliased HAL.UInt32;
CSR19 : aliased HAL.UInt32;
CSR20 : aliased HAL.UInt32;
CSR21 : aliased HAL.UInt32;
CSR22 : aliased HAL.UInt32;
CSR23 : aliased HAL.UInt32;
CSR24 : aliased HAL.UInt32;
CSR25 : aliased HAL.UInt32;
CSR26 : aliased HAL.UInt32;
CSR27 : aliased HAL.UInt32;
CSR28 : aliased HAL.UInt32;
CSR29 : aliased HAL.UInt32;
CSR30 : aliased HAL.UInt32;
CSR31 : aliased HAL.UInt32;
CSR32 : aliased HAL.UInt32;
CSR33 : aliased HAL.UInt32;
CSR34 : aliased HAL.UInt32;
CSR35 : aliased HAL.UInt32;
CSR36 : aliased HAL.UInt32;
CSR37 : aliased HAL.UInt32;
CSR38 : aliased HAL.UInt32;
CSR39 : aliased HAL.UInt32;
CSR40 : aliased HAL.UInt32;
CSR41 : aliased HAL.UInt32;
CSR42 : aliased HAL.UInt32;
CSR43 : aliased HAL.UInt32;
CSR44 : aliased HAL.UInt32;
CSR45 : aliased HAL.UInt32;
CSR46 : aliased HAL.UInt32;
CSR47 : aliased HAL.UInt32;
CSR48 : aliased HAL.UInt32;
CSR49 : aliased HAL.UInt32;
CSR50 : aliased HAL.UInt32;
CSR51 : aliased HAL.UInt32;
CSR52 : aliased HAL.UInt32;
CSR53 : aliased HAL.UInt32;
HR0 : aliased HAL.UInt32;
HR1 : aliased HAL.UInt32;
HR2 : aliased HAL.UInt32;
HR3 : aliased HAL.UInt32;
HR4 : aliased HAL.UInt32;
HR5 : aliased HAL.UInt32;
HR6 : aliased HAL.UInt32;
HR7 : aliased HAL.UInt32;
end record
with Volatile;
for HASH_Peripheral use record
CR at 16#0# range 0 .. 31;
DIN at 16#4# range 0 .. 31;
STR at 16#8# range 0 .. 31;
HRA0 at 16#C# range 0 .. 31;
HRA1 at 16#10# range 0 .. 31;
HRA2 at 16#14# range 0 .. 31;
HRA3 at 16#18# range 0 .. 31;
HRA4 at 16#1C# range 0 .. 31;
IMR at 16#20# range 0 .. 31;
SR at 16#24# range 0 .. 31;
CSR0 at 16#F8# range 0 .. 31;
CSR1 at 16#FC# range 0 .. 31;
CSR2 at 16#100# range 0 .. 31;
CSR3 at 16#104# range 0 .. 31;
CSR4 at 16#108# range 0 .. 31;
CSR5 at 16#10C# range 0 .. 31;
CSR6 at 16#110# range 0 .. 31;
CSR7 at 16#114# range 0 .. 31;
CSR8 at 16#118# range 0 .. 31;
CSR9 at 16#11C# range 0 .. 31;
CSR10 at 16#120# range 0 .. 31;
CSR11 at 16#124# range 0 .. 31;
CSR12 at 16#128# range 0 .. 31;
CSR13 at 16#12C# range 0 .. 31;
CSR14 at 16#130# range 0 .. 31;
CSR15 at 16#134# range 0 .. 31;
CSR16 at 16#138# range 0 .. 31;
CSR17 at 16#13C# range 0 .. 31;
CSR18 at 16#140# range 0 .. 31;
CSR19 at 16#144# range 0 .. 31;
CSR20 at 16#148# range 0 .. 31;
CSR21 at 16#14C# range 0 .. 31;
CSR22 at 16#150# range 0 .. 31;
CSR23 at 16#154# range 0 .. 31;
CSR24 at 16#158# range 0 .. 31;
CSR25 at 16#15C# range 0 .. 31;
CSR26 at 16#160# range 0 .. 31;
CSR27 at 16#164# range 0 .. 31;
CSR28 at 16#168# range 0 .. 31;
CSR29 at 16#16C# range 0 .. 31;
CSR30 at 16#170# range 0 .. 31;
CSR31 at 16#174# range 0 .. 31;
CSR32 at 16#178# range 0 .. 31;
CSR33 at 16#17C# range 0 .. 31;
CSR34 at 16#180# range 0 .. 31;
CSR35 at 16#184# range 0 .. 31;
CSR36 at 16#188# range 0 .. 31;
CSR37 at 16#18C# range 0 .. 31;
CSR38 at 16#190# range 0 .. 31;
CSR39 at 16#194# range 0 .. 31;
CSR40 at 16#198# range 0 .. 31;
CSR41 at 16#19C# range 0 .. 31;
CSR42 at 16#1A0# range 0 .. 31;
CSR43 at 16#1A4# range 0 .. 31;
CSR44 at 16#1A8# range 0 .. 31;
CSR45 at 16#1AC# range 0 .. 31;
CSR46 at 16#1B0# range 0 .. 31;
CSR47 at 16#1B4# range 0 .. 31;
CSR48 at 16#1B8# range 0 .. 31;
CSR49 at 16#1BC# range 0 .. 31;
CSR50 at 16#1C0# range 0 .. 31;
CSR51 at 16#1C4# range 0 .. 31;
CSR52 at 16#1C8# range 0 .. 31;
CSR53 at 16#1CC# range 0 .. 31;
HR0 at 16#310# range 0 .. 31;
HR1 at 16#314# range 0 .. 31;
HR2 at 16#318# range 0 .. 31;
HR3 at 16#31C# range 0 .. 31;
HR4 at 16#320# range 0 .. 31;
HR5 at 16#324# range 0 .. 31;
HR6 at 16#328# range 0 .. 31;
HR7 at 16#32C# range 0 .. 31;
end record;
HASH_Periph : aliased HASH_Peripheral
with Import, Address => System'To_Address (16#420C0400#);
SEC_HASH_Periph : aliased HASH_Peripheral
with Import, Address => System'To_Address (16#520C0400#);
end STM32_SVD.HASH;
|
--
-- Jan & Uwe R. Zimmer, Australia, July 2011
--
with GL.IO; use GL.IO;
package body Screenshots is
Screen_Shot_Count : Positive := 1;
---------------
-- Take_Shot --
---------------
procedure Take_Shot is
begin
Screenshot (Integer'Image (Screen_Shot_Count) & ".bmp");
Screen_Shot_Count := Screen_Shot_Count + 1;
end Take_Shot;
end Screenshots;
|
pragma License (Unrestricted);
-- implementation unit
package System.Growth is
pragma Preelaborate;
generic
type Count_Type is range <>;
function Fast_Grow (Capacity : Count_Type) return Count_Type;
generic
type Count_Type is range <>;
Component_Size : Positive;
function Good_Grow (Capacity : Count_Type) return Count_Type;
generic
type Count_Type is range <>;
Component_Size : Positive;
package Scoped_Holder is
function Capacity return Count_Type;
procedure Reserve_Capacity (Capacity : Count_Type);
function Storage_Address return Address;
end Scoped_Holder;
end System.Growth;
|
-----------------------------------------------------------------------
-- ADO Databases -- Database Connections
-- Copyright (C) 2010, 2011, 2012, 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.Finalization;
with ADO.Statements;
with ADO.Schemas;
with ADO.Drivers.Connections;
package ADO.Databases is
use ADO.Statements;
-- Raised for all errors reported by the database
DB_Error : exception;
-- Raised if the database connection is not open.
NOT_OPEN : exception;
NOT_FOUND : exception;
NO_DATABASE : exception;
-- Raised when the connection URI is invalid.
Connection_Error : exception;
-- The database connection status
type Connection_Status is (OPEN, CLOSED);
-- ---------
-- Database connection
-- ---------
-- Read-only database connection (or slave connection).
--
type Connection is tagged private;
-- Get the database connection status.
function Get_Status (Database : in Connection) return Connection_Status;
-- Close the database connection
procedure Close (Database : in out Connection);
-- Create a query statement. The statement is not prepared
function Create_Statement (Database : in Connection;
Table : in ADO.Schemas.Class_Mapping_Access)
return Query_Statement;
-- Create a query statement. The statement is not prepared
function Create_Statement (Database : in Connection;
Query : in String)
return Query_Statement;
-- Load the database schema definition for the current database.
procedure Load_Schema (Database : in Connection;
Schema : out ADO.Schemas.Schema_Definition);
-- Get the database driver which manages this connection.
function Get_Driver (Database : in Connection) return ADO.Drivers.Connections.Driver_Access;
-- Get the database driver index.
function Get_Driver_Index (Database : in Connection) return ADO.Drivers.Driver_Index;
-- Get a database connection identifier.
function Get_Ident (Database : in Connection) return String;
-- ---------
-- Master Database connection
-- ---------
-- Read-write database connection.
type Master_Connection is new Connection with private;
-- Start a transaction.
procedure Begin_Transaction (Database : in out Master_Connection);
-- Commit the current transaction.
procedure Commit (Database : in out Master_Connection);
-- Rollback the current transaction.
procedure Rollback (Database : in out Master_Connection);
-- Execute an SQL statement
-- procedure Execute (Database : in Master_Connection;
-- SQL : in Query_String);
-- Execute an SQL statement
-- procedure Execute (Database : in Master_Connection;
-- SQL : in Query_String;
-- Id : out Identifier);
-- Create a delete statement.
function Create_Statement (Database : in Master_Connection;
Table : in ADO.Schemas.Class_Mapping_Access)
return Delete_Statement;
-- Create an insert statement.
function Create_Statement (Database : in Master_Connection;
Table : in ADO.Schemas.Class_Mapping_Access)
return Insert_Statement;
-- Create an update statement.
function Create_Statement (Database : in Master_Connection;
Table : in ADO.Schemas.Class_Mapping_Access)
return Update_Statement;
-- ------------------------------
-- The database connection source
-- ------------------------------
-- The <b>DataSource</b> is the factory for getting a connection to the database.
-- It contains the configuration properties to define which database driver must
-- be used and which connection parameters the driver has to use to establish
-- the connection.
type DataSource is new ADO.Drivers.Connections.Configuration with private;
type DataSource_Access is access all DataSource'Class;
-- Attempts to establish a connection with the data source
-- that this DataSource object represents.
function Get_Connection (Controller : in DataSource)
return Master_Connection'Class;
-- ------------------------------
-- Replicated Data Source
-- ------------------------------
-- The replicated data source supports a Master/Slave database configuration.
-- When using this data source, the master is used to execute
-- update, insert, delete and also query statements. The slave is used
-- to execute query statements. The master and slave are represented by
-- two separate data sources. This allows to have a master on one server,
-- use a specific user/password and get a slave on another server with other
-- credentials.
type Replicated_DataSource is new DataSource with private;
type Replicated_DataSource_Access is access all Replicated_DataSource'Class;
-- Set the master data source
procedure Set_Master (Controller : in out Replicated_DataSource;
Master : in DataSource_Access);
-- Get the master data source
function Get_Master (Controller : in Replicated_DataSource)
return DataSource_Access;
-- Set the slave data source
procedure Set_Slave (Controller : in out Replicated_DataSource;
Slave : in DataSource_Access);
-- Get the slace data source
function Get_Slave (Controller : in Replicated_DataSource)
return DataSource_Access;
-- Get a slave database connection
function Get_Slave_Connection (Controller : in Replicated_DataSource)
return Connection'Class;
private
type Connection is new Ada.Finalization.Controlled with record
Impl : ADO.Drivers.Connections.Database_Connection_Access := null;
end record;
-- Adjust the connection reference counter
overriding
procedure Adjust (Object : in out Connection);
-- Releases the connection reference counter
overriding
procedure Finalize (Object : in out Connection);
type Master_Connection is new Connection with null record;
type DataSource is new ADO.Drivers.Connections.Configuration with null record;
type Replicated_DataSource is new DataSource with record
Master : DataSource_Access := null;
Slave : DataSource_Access := null;
end record;
end ADO.Databases;
|
package Inline3_Pkg is
procedure Test (I : Integer);
pragma Inline_Always (Test);
end Inline3_Pkg;
|
------------------------------------------------------------------------------
-- --
-- GNAT RUN-TIME LIBRARY (GNARL) COMPONENTS --
-- --
-- S Y S T E M . T A S K _ P R I M I T I V E S . O P E R A T I O N S --
-- --
-- B o d y --
-- --
-- Copyright (C) 1992-2019, Free Software Foundation, Inc. --
-- --
-- GNARL 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/>. --
-- --
-- GNARL was developed by the GNARL team at Florida State University. --
-- Extensive contributions were provided by Ada Core Technologies, Inc. --
-- --
------------------------------------------------------------------------------
-- This is a NT (native) version of this package
-- This package contains all the GNULL primitives that interface directly with
-- the underlying OS.
pragma Polling (Off);
-- Turn off polling, we do not want ATC polling to take place during tasking
-- operations. It causes infinite loops and other problems.
with Interfaces.C;
with Interfaces.C.Strings;
with System.Float_Control;
with System.Interrupt_Management;
with System.Multiprocessors;
with System.OS_Primitives;
with System.Task_Info;
with System.Tasking.Debug;
with System.Win32.Ext;
with System.Soft_Links;
-- We use System.Soft_Links instead of System.Tasking.Initialization because
-- the later is a higher level package that we shouldn't depend on. For
-- example when using the restricted run time, it is replaced by
-- System.Tasking.Restricted.Stages.
package body System.Task_Primitives.Operations is
package SSL renames System.Soft_Links;
use Interfaces.C;
use Interfaces.C.Strings;
use System.OS_Interface;
use System.OS_Primitives;
use System.Parameters;
use System.Task_Info;
use System.Tasking;
use System.Tasking.Debug;
use System.Win32;
use System.Win32.Ext;
pragma Link_With ("-Xlinker --stack=0x200000,0x1000");
-- Change the default stack size (2 MB) for tasking programs on Windows.
-- This allows about 1000 tasks running at the same time. Note that
-- we set the stack size for non tasking programs on System unit.
-- Also note that under Windows XP, we use a Windows XP extension to
-- specify the stack size on a per task basis, as done under other OSes.
---------------------
-- Local Functions --
---------------------
procedure InitializeCriticalSection (pCriticalSection : access RTS_Lock);
procedure InitializeCriticalSection
(pCriticalSection : access CRITICAL_SECTION);
pragma Import
(Stdcall, InitializeCriticalSection, "InitializeCriticalSection");
procedure EnterCriticalSection (pCriticalSection : access RTS_Lock);
procedure EnterCriticalSection
(pCriticalSection : access CRITICAL_SECTION);
pragma Import (Stdcall, EnterCriticalSection, "EnterCriticalSection");
procedure LeaveCriticalSection (pCriticalSection : access RTS_Lock);
procedure LeaveCriticalSection (pCriticalSection : access CRITICAL_SECTION);
pragma Import (Stdcall, LeaveCriticalSection, "LeaveCriticalSection");
procedure DeleteCriticalSection (pCriticalSection : access RTS_Lock);
procedure DeleteCriticalSection
(pCriticalSection : access CRITICAL_SECTION);
pragma Import (Stdcall, DeleteCriticalSection, "DeleteCriticalSection");
----------------
-- Local Data --
----------------
Environment_Task_Id : Task_Id;
-- A variable to hold Task_Id for the environment task
Single_RTS_Lock : aliased RTS_Lock;
-- This is a lock to allow only one thread of control in the RTS at
-- a time; it is used to execute in mutual exclusion from all other tasks.
-- Used mainly in Single_Lock mode, but also to protect All_Tasks_List
Time_Slice_Val : Integer;
pragma Import (C, Time_Slice_Val, "__gl_time_slice_val");
Dispatching_Policy : Character;
pragma Import (C, Dispatching_Policy, "__gl_task_dispatching_policy");
function Get_Policy (Prio : System.Any_Priority) return Character;
pragma Import (C, Get_Policy, "__gnat_get_specific_dispatching");
-- Get priority specific dispatching policy
Foreign_Task_Elaborated : aliased Boolean := True;
-- Used to identified fake tasks (i.e., non-Ada Threads)
Null_Thread_Id : constant Thread_Id := 0;
-- Constant to indicate that the thread identifier has not yet been
-- initialized.
------------------------------------
-- The thread local storage index --
------------------------------------
TlsIndex : DWORD;
pragma Export (Ada, TlsIndex);
-- To ensure that this variable won't be local to this package, since
-- in some cases, inlining forces this variable to be global anyway.
--------------------
-- Local Packages --
--------------------
package Specific is
function Is_Valid_Task return Boolean;
pragma Inline (Is_Valid_Task);
-- Does executing thread have a TCB?
procedure Set (Self_Id : Task_Id);
pragma Inline (Set);
-- Set the self id for the current task
end Specific;
package body Specific is
-------------------
-- Is_Valid_Task --
-------------------
function Is_Valid_Task return Boolean is
begin
return TlsGetValue (TlsIndex) /= System.Null_Address;
end Is_Valid_Task;
---------
-- Set --
---------
procedure Set (Self_Id : Task_Id) is
Succeeded : BOOL;
begin
Succeeded := TlsSetValue (TlsIndex, To_Address (Self_Id));
pragma Assert (Succeeded = Win32.TRUE);
end Set;
end Specific;
----------------------------------
-- ATCB allocation/deallocation --
----------------------------------
package body ATCB_Allocation is separate;
-- The body of this package is shared across several targets
---------------------------------
-- Support for foreign threads --
---------------------------------
function Register_Foreign_Thread
(Thread : Thread_Id;
Sec_Stack_Size : Size_Type := Unspecified_Size) return Task_Id;
-- Allocate and initialize a new ATCB for the current Thread. The size of
-- the secondary stack can be optionally specified.
function Register_Foreign_Thread
(Thread : Thread_Id;
Sec_Stack_Size : Size_Type := Unspecified_Size)
return Task_Id is separate;
----------------------------------
-- Condition Variable Functions --
----------------------------------
procedure Initialize_Cond (Cond : not null access Condition_Variable);
-- Initialize given condition variable Cond
procedure Finalize_Cond (Cond : not null access Condition_Variable);
-- Finalize given condition variable Cond
procedure Cond_Signal (Cond : not null access Condition_Variable);
-- Signal condition variable Cond
procedure Cond_Wait
(Cond : not null access Condition_Variable;
L : not null access RTS_Lock);
-- Wait on conditional variable Cond, using lock L
procedure Cond_Timed_Wait
(Cond : not null access Condition_Variable;
L : not null access RTS_Lock;
Rel_Time : Duration;
Timed_Out : out Boolean;
Status : out Integer);
-- Do timed wait on condition variable Cond using lock L. The duration
-- of the timed wait is given by Rel_Time. When the condition is
-- signalled, Timed_Out shows whether or not a time out occurred.
-- Status is only valid if Timed_Out is False, in which case it
-- shows whether Cond_Timed_Wait completed successfully.
---------------------
-- Initialize_Cond --
---------------------
procedure Initialize_Cond (Cond : not null access Condition_Variable) is
hEvent : HANDLE;
begin
hEvent := CreateEvent (null, Win32.TRUE, Win32.FALSE, Null_Ptr);
pragma Assert (hEvent /= 0);
Cond.all := Condition_Variable (hEvent);
end Initialize_Cond;
-------------------
-- Finalize_Cond --
-------------------
-- No such problem here, DosCloseEventSem has been derived.
-- What does such refer to in above comment???
procedure Finalize_Cond (Cond : not null access Condition_Variable) is
Result : BOOL;
begin
Result := CloseHandle (HANDLE (Cond.all));
pragma Assert (Result = Win32.TRUE);
end Finalize_Cond;
-----------------
-- Cond_Signal --
-----------------
procedure Cond_Signal (Cond : not null access Condition_Variable) is
Result : BOOL;
begin
Result := SetEvent (HANDLE (Cond.all));
pragma Assert (Result = Win32.TRUE);
end Cond_Signal;
---------------
-- Cond_Wait --
---------------
-- Pre-condition: Cond is posted
-- L is locked.
-- Post-condition: Cond is posted
-- L is locked.
procedure Cond_Wait
(Cond : not null access Condition_Variable;
L : not null access RTS_Lock)
is
Result : DWORD;
Result_Bool : BOOL;
begin
-- Must reset Cond BEFORE L is unlocked
Result_Bool := ResetEvent (HANDLE (Cond.all));
pragma Assert (Result_Bool = Win32.TRUE);
Unlock (L, Global_Lock => True);
-- No problem if we are interrupted here: if the condition is signaled,
-- WaitForSingleObject will simply not block
Result := WaitForSingleObject (HANDLE (Cond.all), Wait_Infinite);
pragma Assert (Result = 0);
Write_Lock (L, Global_Lock => True);
end Cond_Wait;
---------------------
-- Cond_Timed_Wait --
---------------------
-- Pre-condition: Cond is posted
-- L is locked.
-- Post-condition: Cond is posted
-- L is locked.
procedure Cond_Timed_Wait
(Cond : not null access Condition_Variable;
L : not null access RTS_Lock;
Rel_Time : Duration;
Timed_Out : out Boolean;
Status : out Integer)
is
Time_Out_Max : constant DWORD := 16#FFFF0000#;
-- NT 4 can't handle excessive timeout values (e.g. DWORD'Last - 1)
Time_Out : DWORD;
Result : BOOL;
Wait_Result : DWORD;
begin
-- Must reset Cond BEFORE L is unlocked
Result := ResetEvent (HANDLE (Cond.all));
pragma Assert (Result = Win32.TRUE);
Unlock (L, Global_Lock => True);
-- No problem if we are interrupted here: if the condition is signaled,
-- WaitForSingleObject will simply not block.
if Rel_Time <= 0.0 then
Timed_Out := True;
Wait_Result := 0;
else
Time_Out :=
(if Rel_Time >= Duration (Time_Out_Max) / 1000
then Time_Out_Max
else DWORD (Rel_Time * 1000));
Wait_Result := WaitForSingleObject (HANDLE (Cond.all), Time_Out);
if Wait_Result = WAIT_TIMEOUT then
Timed_Out := True;
Wait_Result := 0;
else
Timed_Out := False;
end if;
end if;
Write_Lock (L, Global_Lock => True);
-- Ensure post-condition
if Timed_Out then
Result := SetEvent (HANDLE (Cond.all));
pragma Assert (Result = Win32.TRUE);
end if;
Status := Integer (Wait_Result);
end Cond_Timed_Wait;
------------------
-- Stack_Guard --
------------------
-- The underlying thread system sets a guard page at the bottom of a thread
-- stack, so nothing is needed.
-- ??? Check the comment above
procedure Stack_Guard (T : ST.Task_Id; On : Boolean) is
pragma Unreferenced (T, On);
begin
null;
end Stack_Guard;
--------------------
-- Get_Thread_Id --
--------------------
function Get_Thread_Id (T : ST.Task_Id) return OSI.Thread_Id is
begin
return T.Common.LL.Thread;
end Get_Thread_Id;
----------
-- Self --
----------
function Self return Task_Id is
Self_Id : constant Task_Id := To_Task_Id (TlsGetValue (TlsIndex));
begin
if Self_Id = null then
return Register_Foreign_Thread (GetCurrentThread);
else
return Self_Id;
end if;
end Self;
---------------------
-- Initialize_Lock --
---------------------
-- Note: mutexes and cond_variables needed per-task basis are initialized
-- in Initialize_TCB and the Storage_Error is handled. Other mutexes (such
-- as RTS_Lock, Memory_Lock...) used in the RTS is initialized before any
-- status change of RTS. Therefore raising Storage_Error in the following
-- routines should be able to be handled safely.
procedure Initialize_Lock
(Prio : System.Any_Priority;
L : not null access Lock)
is
begin
InitializeCriticalSection (L.Mutex'Access);
L.Owner_Priority := 0;
L.Priority := Prio;
end Initialize_Lock;
procedure Initialize_Lock
(L : not null access RTS_Lock; Level : Lock_Level)
is
pragma Unreferenced (Level);
begin
InitializeCriticalSection (L);
end Initialize_Lock;
-------------------
-- Finalize_Lock --
-------------------
procedure Finalize_Lock (L : not null access Lock) is
begin
DeleteCriticalSection (L.Mutex'Access);
end Finalize_Lock;
procedure Finalize_Lock (L : not null access RTS_Lock) is
begin
DeleteCriticalSection (L);
end Finalize_Lock;
----------------
-- Write_Lock --
----------------
procedure Write_Lock
(L : not null access Lock; Ceiling_Violation : out Boolean) is
begin
L.Owner_Priority := Get_Priority (Self);
if L.Priority < L.Owner_Priority then
Ceiling_Violation := True;
return;
end if;
EnterCriticalSection (L.Mutex'Access);
Ceiling_Violation := False;
end Write_Lock;
procedure Write_Lock
(L : not null access RTS_Lock;
Global_Lock : Boolean := False)
is
begin
if not Single_Lock or else Global_Lock then
EnterCriticalSection (L);
end if;
end Write_Lock;
procedure Write_Lock (T : Task_Id) is
begin
if not Single_Lock then
EnterCriticalSection (T.Common.LL.L'Access);
end if;
end Write_Lock;
---------------
-- Read_Lock --
---------------
procedure Read_Lock
(L : not null access Lock; Ceiling_Violation : out Boolean) is
begin
Write_Lock (L, Ceiling_Violation);
end Read_Lock;
------------
-- Unlock --
------------
procedure Unlock (L : not null access Lock) is
begin
LeaveCriticalSection (L.Mutex'Access);
end Unlock;
procedure Unlock
(L : not null access RTS_Lock; Global_Lock : Boolean := False) is
begin
if not Single_Lock or else Global_Lock then
LeaveCriticalSection (L);
end if;
end Unlock;
procedure Unlock (T : Task_Id) is
begin
if not Single_Lock then
LeaveCriticalSection (T.Common.LL.L'Access);
end if;
end Unlock;
-----------------
-- Set_Ceiling --
-----------------
-- Dynamic priority ceilings are not supported by the underlying system
procedure Set_Ceiling
(L : not null access Lock;
Prio : System.Any_Priority)
is
pragma Unreferenced (L, Prio);
begin
null;
end Set_Ceiling;
-----------
-- Sleep --
-----------
procedure Sleep
(Self_ID : Task_Id;
Reason : System.Tasking.Task_States)
is
pragma Unreferenced (Reason);
begin
pragma Assert (Self_ID = Self);
if Single_Lock then
Cond_Wait (Self_ID.Common.LL.CV'Access, Single_RTS_Lock'Access);
else
Cond_Wait (Self_ID.Common.LL.CV'Access, Self_ID.Common.LL.L'Access);
end if;
if Self_ID.Deferral_Level = 0
and then Self_ID.Pending_ATC_Level < Self_ID.ATC_Nesting_Level
then
Unlock (Self_ID);
raise Standard'Abort_Signal;
end if;
end Sleep;
-----------------
-- Timed_Sleep --
-----------------
-- This is for use within the run-time system, so abort is assumed to be
-- already deferred, and the caller should be holding its own ATCB lock.
procedure Timed_Sleep
(Self_ID : Task_Id;
Time : Duration;
Mode : ST.Delay_Modes;
Reason : System.Tasking.Task_States;
Timedout : out Boolean;
Yielded : out Boolean)
is
pragma Unreferenced (Reason);
Check_Time : Duration := Monotonic_Clock;
Rel_Time : Duration;
Abs_Time : Duration;
Result : Integer;
pragma Unreferenced (Result);
Local_Timedout : Boolean;
begin
Timedout := True;
Yielded := False;
if Mode = Relative then
Rel_Time := Time;
Abs_Time := Duration'Min (Time, Max_Sensible_Delay) + Check_Time;
else
Rel_Time := Time - Check_Time;
Abs_Time := Time;
end if;
if Rel_Time > 0.0 then
loop
exit when Self_ID.Pending_ATC_Level < Self_ID.ATC_Nesting_Level;
if Single_Lock then
Cond_Timed_Wait
(Self_ID.Common.LL.CV'Access,
Single_RTS_Lock'Access,
Rel_Time, Local_Timedout, Result);
else
Cond_Timed_Wait
(Self_ID.Common.LL.CV'Access,
Self_ID.Common.LL.L'Access,
Rel_Time, Local_Timedout, Result);
end if;
Check_Time := Monotonic_Clock;
exit when Abs_Time <= Check_Time;
if not Local_Timedout then
-- Somebody may have called Wakeup for us
Timedout := False;
exit;
end if;
Rel_Time := Abs_Time - Check_Time;
end loop;
end if;
end Timed_Sleep;
-----------------
-- Timed_Delay --
-----------------
procedure Timed_Delay
(Self_ID : Task_Id;
Time : Duration;
Mode : ST.Delay_Modes)
is
Check_Time : Duration := Monotonic_Clock;
Rel_Time : Duration;
Abs_Time : Duration;
Timedout : Boolean;
Result : Integer;
pragma Unreferenced (Timedout, Result);
begin
if Single_Lock then
Lock_RTS;
end if;
Write_Lock (Self_ID);
if Mode = Relative then
Rel_Time := Time;
Abs_Time := Time + Check_Time;
else
Rel_Time := Time - Check_Time;
Abs_Time := Time;
end if;
if Rel_Time > 0.0 then
Self_ID.Common.State := Delay_Sleep;
loop
exit when Self_ID.Pending_ATC_Level < Self_ID.ATC_Nesting_Level;
if Single_Lock then
Cond_Timed_Wait
(Self_ID.Common.LL.CV'Access,
Single_RTS_Lock'Access,
Rel_Time, Timedout, Result);
else
Cond_Timed_Wait
(Self_ID.Common.LL.CV'Access,
Self_ID.Common.LL.L'Access,
Rel_Time, Timedout, Result);
end if;
Check_Time := Monotonic_Clock;
exit when Abs_Time <= Check_Time;
Rel_Time := Abs_Time - Check_Time;
end loop;
Self_ID.Common.State := Runnable;
end if;
Unlock (Self_ID);
if Single_Lock then
Unlock_RTS;
end if;
Yield;
end Timed_Delay;
------------
-- Wakeup --
------------
procedure Wakeup (T : Task_Id; Reason : System.Tasking.Task_States) is
pragma Unreferenced (Reason);
begin
Cond_Signal (T.Common.LL.CV'Access);
end Wakeup;
-----------
-- Yield --
-----------
procedure Yield (Do_Yield : Boolean := True) is
begin
-- Note: in a previous implementation if Do_Yield was False, then we
-- introduced a delay of 1 millisecond in an attempt to get closer to
-- annex D semantics, and in particular to make ACATS CXD8002 pass. But
-- this change introduced a huge performance regression evaluating the
-- Count attribute. So we decided to remove this processing.
-- Moreover, CXD8002 appears to pass on Windows (although we do not
-- guarantee full Annex D compliance on Windows in any case).
if Do_Yield then
SwitchToThread;
end if;
end Yield;
------------------
-- Set_Priority --
------------------
procedure Set_Priority
(T : Task_Id;
Prio : System.Any_Priority;
Loss_Of_Inheritance : Boolean := False)
is
Res : BOOL;
pragma Unreferenced (Loss_Of_Inheritance);
begin
Res :=
SetThreadPriority
(T.Common.LL.Thread,
Interfaces.C.int (Underlying_Priorities (Prio)));
pragma Assert (Res = Win32.TRUE);
-- Note: Annex D (RM D.2.3(5/2)) requires the task to be placed at the
-- head of its priority queue when decreasing its priority as a result
-- of a loss of inherited priority. This is not the case, but we
-- consider it an acceptable variation (RM 1.1.3(6)), given this is
-- the built-in behavior offered by the Windows operating system.
-- In older versions we attempted to better approximate the Annex D
-- required behavior, but this simulation was not entirely accurate,
-- and it seems better to live with the standard Windows semantics.
T.Common.Current_Priority := Prio;
end Set_Priority;
------------------
-- Get_Priority --
------------------
function Get_Priority (T : Task_Id) return System.Any_Priority is
begin
return T.Common.Current_Priority;
end Get_Priority;
----------------
-- Enter_Task --
----------------
-- There were two paths were we needed to call Enter_Task :
-- 1) from System.Task_Primitives.Operations.Initialize
-- 2) from System.Tasking.Stages.Task_Wrapper
-- The pseudo handle (LL.Thread) need not be closed when it is no
-- longer needed. Calling the CloseHandle function with this handle
-- has no effect.
procedure Enter_Task (Self_ID : Task_Id) is
procedure Get_Stack_Bounds (Base : Address; Limit : Address);
pragma Import (C, Get_Stack_Bounds, "__gnat_get_stack_bounds");
-- Get stack boundaries
begin
Specific.Set (Self_ID);
-- Properly initializes the FPU for x86 systems
System.Float_Control.Reset;
if Self_ID.Common.Task_Info /= null
and then
Self_ID.Common.Task_Info.CPU >= CPU_Number (Number_Of_Processors)
then
raise Invalid_CPU_Number;
end if;
-- Initialize the thread here only if not set. This is done for a
-- foreign task but is not needed when a real thread-id is already
-- set in Create_Task. Note that we do want to keep the real thread-id
-- as it is the only way to free the associated resource. Another way
-- to say this is that a pseudo thread-id from a foreign thread won't
-- allow for freeing resources.
if Self_ID.Common.LL.Thread = Null_Thread_Id then
Self_ID.Common.LL.Thread := GetCurrentThread;
end if;
Self_ID.Common.LL.Thread_Id := GetCurrentThreadId;
Get_Stack_Bounds
(Self_ID.Common.Compiler_Data.Pri_Stack_Info.Base'Address,
Self_ID.Common.Compiler_Data.Pri_Stack_Info.Limit'Address);
end Enter_Task;
-------------------
-- Is_Valid_Task --
-------------------
function Is_Valid_Task return Boolean renames Specific.Is_Valid_Task;
-----------------------------
-- Register_Foreign_Thread --
-----------------------------
function Register_Foreign_Thread return Task_Id is
begin
if Is_Valid_Task then
return Self;
else
return Register_Foreign_Thread (GetCurrentThread);
end if;
end Register_Foreign_Thread;
--------------------
-- Initialize_TCB --
--------------------
procedure Initialize_TCB (Self_ID : Task_Id; Succeeded : out Boolean) is
begin
-- Initialize thread ID to 0, this is needed to detect threads that
-- are not yet activated.
Self_ID.Common.LL.Thread := Null_Thread_Id;
Initialize_Cond (Self_ID.Common.LL.CV'Access);
if not Single_Lock then
Initialize_Lock (Self_ID.Common.LL.L'Access, ATCB_Level);
end if;
Succeeded := True;
end Initialize_TCB;
-----------------
-- Create_Task --
-----------------
procedure Create_Task
(T : Task_Id;
Wrapper : System.Address;
Stack_Size : System.Parameters.Size_Type;
Priority : System.Any_Priority;
Succeeded : out Boolean)
is
Initial_Stack_Size : constant := 1024;
-- We set the initial stack size to 1024. On Windows version prior to XP
-- there is no way to fix a task stack size. Only the initial stack size
-- can be set, the operating system will raise the task stack size if
-- needed.
function Is_Windows_XP return Integer;
pragma Import (C, Is_Windows_XP, "__gnat_is_windows_xp");
-- Returns 1 if running on Windows XP
hTask : HANDLE;
TaskId : aliased DWORD;
pTaskParameter : Win32.PVOID;
Result : DWORD;
Entry_Point : PTHREAD_START_ROUTINE;
use type System.Multiprocessors.CPU_Range;
begin
-- Check whether both Dispatching_Domain and CPU are specified for the
-- task, and the CPU value is not contained within the range of
-- processors for the domain.
if T.Common.Domain /= null
and then T.Common.Base_CPU /= System.Multiprocessors.Not_A_Specific_CPU
and then
(T.Common.Base_CPU not in T.Common.Domain'Range
or else not T.Common.Domain (T.Common.Base_CPU))
then
Succeeded := False;
return;
end if;
pTaskParameter := To_Address (T);
Entry_Point := To_PTHREAD_START_ROUTINE (Wrapper);
if Is_Windows_XP = 1 then
hTask := CreateThread
(null,
DWORD (Stack_Size),
Entry_Point,
pTaskParameter,
DWORD (Create_Suspended)
or DWORD (Stack_Size_Param_Is_A_Reservation),
TaskId'Unchecked_Access);
else
hTask := CreateThread
(null,
Initial_Stack_Size,
Entry_Point,
pTaskParameter,
DWORD (Create_Suspended),
TaskId'Unchecked_Access);
end if;
-- Step 1: Create the thread in blocked mode
if hTask = 0 then
Succeeded := False;
return;
end if;
-- Step 2: set its TCB
T.Common.LL.Thread := hTask;
-- Note: it would be useful to initialize Thread_Id right away to avoid
-- a race condition in gdb where Thread_ID may not have the right value
-- yet, but GetThreadId is a Vista specific API, not available under XP:
-- T.Common.LL.Thread_Id := GetThreadId (hTask); so instead we set the
-- field to 0 to avoid having a random value. Thread_Id is initialized
-- in Enter_Task anyway.
T.Common.LL.Thread_Id := 0;
-- Step 3: set its priority (child has inherited priority from parent)
Set_Priority (T, Priority);
if Time_Slice_Val = 0
or else Dispatching_Policy = 'F'
or else Get_Policy (Priority) = 'F'
then
-- Here we need Annex D semantics so we disable the NT priority
-- boost. A priority boost is temporarily given by the system to
-- a thread when it is taken out of a wait state.
SetThreadPriorityBoost (hTask, DisablePriorityBoost => Win32.TRUE);
end if;
-- Step 4: Handle pragma CPU and Task_Info
Set_Task_Affinity (T);
-- Step 5: Now, start it for good
Result := ResumeThread (hTask);
pragma Assert (Result = 1);
Succeeded := Result = 1;
end Create_Task;
------------------
-- Finalize_TCB --
------------------
procedure Finalize_TCB (T : Task_Id) is
Succeeded : BOOL;
pragma Unreferenced (Succeeded);
begin
if not Single_Lock then
Finalize_Lock (T.Common.LL.L'Access);
end if;
Finalize_Cond (T.Common.LL.CV'Access);
if T.Known_Tasks_Index /= -1 then
Known_Tasks (T.Known_Tasks_Index) := null;
end if;
if T.Common.LL.Thread /= Null_Thread_Id then
-- This task has been activated. Close the thread handle. This
-- is needed to release system resources.
Succeeded := CloseHandle (T.Common.LL.Thread);
-- Note that we do not check for the returned value, this is
-- because the above call will fail for a foreign thread. But
-- we still need to call it to properly close Ada tasks created
-- with CreateThread() in Create_Task above.
end if;
ATCB_Allocation.Free_ATCB (T);
end Finalize_TCB;
---------------
-- Exit_Task --
---------------
procedure Exit_Task is
begin
Specific.Set (null);
end Exit_Task;
----------------
-- Abort_Task --
----------------
procedure Abort_Task (T : Task_Id) is
pragma Unreferenced (T);
begin
null;
end Abort_Task;
----------------------
-- Environment_Task --
----------------------
function Environment_Task return Task_Id is
begin
return Environment_Task_Id;
end Environment_Task;
--------------
-- Lock_RTS --
--------------
procedure Lock_RTS is
begin
Write_Lock (Single_RTS_Lock'Access, Global_Lock => True);
end Lock_RTS;
----------------
-- Unlock_RTS --
----------------
procedure Unlock_RTS is
begin
Unlock (Single_RTS_Lock'Access, Global_Lock => True);
end Unlock_RTS;
----------------
-- Initialize --
----------------
procedure Initialize (Environment_Task : Task_Id) is
Discard : BOOL;
begin
Environment_Task_Id := Environment_Task;
OS_Primitives.Initialize;
Interrupt_Management.Initialize;
if Time_Slice_Val = 0 or else Dispatching_Policy = 'F' then
-- Here we need Annex D semantics, switch the current process to the
-- Realtime_Priority_Class.
Discard := OS_Interface.SetPriorityClass
(GetCurrentProcess, Realtime_Priority_Class);
end if;
TlsIndex := TlsAlloc;
-- Initialize the lock used to synchronize chain of all ATCBs
Initialize_Lock (Single_RTS_Lock'Access, RTS_Lock_Level);
Environment_Task.Common.LL.Thread := GetCurrentThread;
-- Make environment task known here because it doesn't go through
-- Activate_Tasks, which does it for all other tasks.
Known_Tasks (Known_Tasks'First) := Environment_Task;
Environment_Task.Known_Tasks_Index := Known_Tasks'First;
Enter_Task (Environment_Task);
-- pragma CPU and dispatching domains for the environment task
Set_Task_Affinity (Environment_Task);
end Initialize;
---------------------
-- Monotonic_Clock --
---------------------
function Monotonic_Clock return Duration is
function Internal_Clock return Duration;
pragma Import (Ada, Internal_Clock, "__gnat_monotonic_clock");
begin
return Internal_Clock;
end Monotonic_Clock;
-------------------
-- RT_Resolution --
-------------------
function RT_Resolution return Duration is
Ticks_Per_Second : aliased LARGE_INTEGER;
begin
QueryPerformanceFrequency (Ticks_Per_Second'Access);
return Duration (1.0 / Ticks_Per_Second);
end RT_Resolution;
----------------
-- Initialize --
----------------
procedure Initialize (S : in out Suspension_Object) is
begin
-- Initialize internal state. It is always initialized to False (ARM
-- D.10 par. 6).
S.State := False;
S.Waiting := False;
-- Initialize internal mutex
InitializeCriticalSection (S.L'Access);
-- Initialize internal condition variable
S.CV := CreateEvent (null, Win32.TRUE, Win32.FALSE, Null_Ptr);
pragma Assert (S.CV /= 0);
end Initialize;
--------------
-- Finalize --
--------------
procedure Finalize (S : in out Suspension_Object) is
Result : BOOL;
begin
-- Destroy internal mutex
DeleteCriticalSection (S.L'Access);
-- Destroy internal condition variable
Result := CloseHandle (S.CV);
pragma Assert (Result = Win32.TRUE);
end Finalize;
-------------------
-- Current_State --
-------------------
function Current_State (S : Suspension_Object) return Boolean is
begin
-- We do not want to use lock on this read operation. State is marked
-- as Atomic so that we ensure that the value retrieved is correct.
return S.State;
end Current_State;
---------------
-- Set_False --
---------------
procedure Set_False (S : in out Suspension_Object) is
begin
SSL.Abort_Defer.all;
EnterCriticalSection (S.L'Access);
S.State := False;
LeaveCriticalSection (S.L'Access);
SSL.Abort_Undefer.all;
end Set_False;
--------------
-- Set_True --
--------------
procedure Set_True (S : in out Suspension_Object) is
Result : BOOL;
begin
SSL.Abort_Defer.all;
EnterCriticalSection (S.L'Access);
-- If there is already a task waiting on this suspension object then
-- we resume it, leaving the state of the suspension object to False,
-- as it is specified in ARM D.10 par. 9. Otherwise, it just leaves
-- the state to True.
if S.Waiting then
S.Waiting := False;
S.State := False;
Result := SetEvent (S.CV);
pragma Assert (Result = Win32.TRUE);
else
S.State := True;
end if;
LeaveCriticalSection (S.L'Access);
SSL.Abort_Undefer.all;
end Set_True;
------------------------
-- Suspend_Until_True --
------------------------
procedure Suspend_Until_True (S : in out Suspension_Object) is
Result : DWORD;
Result_Bool : BOOL;
begin
SSL.Abort_Defer.all;
EnterCriticalSection (S.L'Access);
if S.Waiting then
-- Program_Error must be raised upon calling Suspend_Until_True
-- if another task is already waiting on that suspension object
-- (ARM D.10 par. 10).
LeaveCriticalSection (S.L'Access);
SSL.Abort_Undefer.all;
raise Program_Error;
else
-- Suspend the task if the state is False. Otherwise, the task
-- continues its execution, and the state of the suspension object
-- is set to False (ARM D.10 par. 9).
if S.State then
S.State := False;
LeaveCriticalSection (S.L'Access);
SSL.Abort_Undefer.all;
else
S.Waiting := True;
-- Must reset CV BEFORE L is unlocked
Result_Bool := ResetEvent (S.CV);
pragma Assert (Result_Bool = Win32.TRUE);
LeaveCriticalSection (S.L'Access);
SSL.Abort_Undefer.all;
Result := WaitForSingleObject (S.CV, Wait_Infinite);
pragma Assert (Result = 0);
end if;
end if;
end Suspend_Until_True;
----------------
-- Check_Exit --
----------------
-- Dummy versions, currently this only works for solaris (native)
function Check_Exit (Self_ID : ST.Task_Id) return Boolean is
pragma Unreferenced (Self_ID);
begin
return True;
end Check_Exit;
--------------------
-- Check_No_Locks --
--------------------
function Check_No_Locks (Self_ID : ST.Task_Id) return Boolean is
pragma Unreferenced (Self_ID);
begin
return True;
end Check_No_Locks;
------------------
-- Suspend_Task --
------------------
function Suspend_Task
(T : ST.Task_Id;
Thread_Self : Thread_Id) return Boolean
is
begin
if T.Common.LL.Thread /= Thread_Self then
return SuspendThread (T.Common.LL.Thread) = NO_ERROR;
else
return True;
end if;
end Suspend_Task;
-----------------
-- Resume_Task --
-----------------
function Resume_Task
(T : ST.Task_Id;
Thread_Self : Thread_Id) return Boolean
is
begin
if T.Common.LL.Thread /= Thread_Self then
return ResumeThread (T.Common.LL.Thread) = NO_ERROR;
else
return True;
end if;
end Resume_Task;
--------------------
-- Stop_All_Tasks --
--------------------
procedure Stop_All_Tasks is
begin
null;
end Stop_All_Tasks;
---------------
-- Stop_Task --
---------------
function Stop_Task (T : ST.Task_Id) return Boolean is
pragma Unreferenced (T);
begin
return False;
end Stop_Task;
-------------------
-- Continue_Task --
-------------------
function Continue_Task (T : ST.Task_Id) return Boolean is
pragma Unreferenced (T);
begin
return False;
end Continue_Task;
-----------------------
-- Set_Task_Affinity --
-----------------------
procedure Set_Task_Affinity (T : ST.Task_Id) is
Result : DWORD;
use type System.Multiprocessors.CPU_Range;
begin
-- Do nothing if the underlying thread has not yet been created. If the
-- thread has not yet been created then the proper affinity will be set
-- during its creation.
if T.Common.LL.Thread = Null_Thread_Id then
null;
-- pragma CPU
elsif T.Common.Base_CPU /= Multiprocessors.Not_A_Specific_CPU then
-- The CPU numbering in pragma CPU starts at 1 while the subprogram
-- to set the affinity starts at 0, therefore we must substract 1.
Result :=
SetThreadIdealProcessor
(T.Common.LL.Thread, ProcessorId (T.Common.Base_CPU) - 1);
pragma Assert (Result = 1);
-- Task_Info
elsif T.Common.Task_Info /= null then
if T.Common.Task_Info.CPU /= Task_Info.Any_CPU then
Result :=
SetThreadIdealProcessor
(T.Common.LL.Thread, T.Common.Task_Info.CPU);
pragma Assert (Result = 1);
end if;
-- Dispatching domains
elsif T.Common.Domain /= null
and then (T.Common.Domain /= ST.System_Domain
or else
T.Common.Domain.all /=
(Multiprocessors.CPU'First ..
Multiprocessors.Number_Of_CPUs => True))
then
declare
CPU_Set : DWORD := 0;
begin
for Proc in T.Common.Domain'Range loop
if T.Common.Domain (Proc) then
-- The thread affinity mask is a bit vector in which each
-- bit represents a logical processor.
CPU_Set := CPU_Set + 2 ** (Integer (Proc) - 1);
end if;
end loop;
Result := SetThreadAffinityMask (T.Common.LL.Thread, CPU_Set);
pragma Assert (Result = 1);
end;
end if;
end Set_Task_Affinity;
end System.Task_Primitives.Operations;
|
------------------------------------------------------------------------------
-- --
-- GNAT COMPILER COMPONENTS --
-- --
-- M L I B . T G T --
-- --
-- S p e c --
-- --
-- Copyright (C) 2001-2009, AdaCore --
-- --
-- GNAT is free software; you can redistribute it and/or modify it under --
-- terms of the GNU General Public License as published by the Free Soft- --
-- ware Foundation; either version 3, or (at your option) any later ver- --
-- sion. GNAT is distributed in the hope that it will be useful, but WITH- --
-- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY --
-- or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License --
-- for more details. You should have received a copy of the GNU General --
-- Public License distributed with GNAT; see file COPYING3. If not, go to --
-- http://www.gnu.org/licenses for a complete copy of the license. --
-- --
-- GNAT was originally developed by the GNAT team at New York University. --
-- Extensive contributions were provided by Ada Core Technologies Inc. --
-- --
------------------------------------------------------------------------------
-- This package provides a set of target dependent routines to build static,
-- dynamic and shared libraries. There are several packages providing
-- the actual routines. This package calls them indirectly by means of
-- access-to-subprogram values. Each target-dependent package initializes
-- these values in its elaboration block.
with Prj; use Prj;
package MLib.Tgt is
function Support_For_Libraries return Library_Support;
-- Indicates how building libraries by gnatmake is supported by the GNAT
-- implementation for the platform.
function Standalone_Library_Auto_Init_Is_Supported return Boolean;
-- Indicates if when building a dynamic Standalone Library,
-- automatic initialization is supported. If it is, then it is the default,
-- unless attribute Library_Auto_Init has the value "false".
function Archive_Builder return String;
-- Returns the name of the archive builder program, usually "ar"
function Archive_Builder_Options return String_List_Access;
-- A list of options to invoke the Archive_Builder, usually "cr" for "ar"
function Archive_Builder_Append_Options return String_List_Access;
-- A list of options to use with the archive builder to append object
-- files ("q", for example).
function Archive_Indexer return String;
-- Returns the name of the program, if any, that generates an index to the
-- contents of an archive, usually "ranlib". If there is no archive indexer
-- to be used, returns an empty string.
function Archive_Indexer_Options return String_List_Access;
-- A list of options to invoke the Archive_Indexer, usually empty
function Dynamic_Option return String;
-- gcc option to create a dynamic library.
-- For Unix, returns "-shared", for Windows returns "-mdll".
function Libgnat return String;
-- System dependent static GNAT library
function Archive_Ext return String;
-- System dependent static library extension, without leading dot.
-- For Unix and Windows, return "a".
function Object_Ext return String;
-- System dependent object extension, without leading dot.
-- On Unix, returns "o".
function DLL_Prefix return String;
-- System dependent dynamic library prefix.
-- On Windows, returns "". On other platforms, returns "lib".
function DLL_Ext return String;
-- System dependent dynamic library extension, without leading dot.
-- On Windows, returns "dll". On Unix, usually returns "so", but not
-- always, e.g. on HP-UX the extension for shared libraries is "sl".
function PIC_Option return String;
-- Position independent code option
function Is_Object_Ext (Ext : String) return Boolean;
-- Returns True iff Ext is an object file extension
function Is_C_Ext (Ext : String) return Boolean;
-- Returns True iff Ext is a C file extension
function Is_Archive_Ext (Ext : String) return Boolean;
-- Returns True iff Ext is an extension for a library
function Default_Symbol_File_Name return String;
-- Returns the name of the symbol file when Library_Symbol_File is not
-- specified. Return the empty string when symbol files are not supported.
procedure Build_Dynamic_Library
(Ofiles : Argument_List;
Options : Argument_List;
Interfaces : Argument_List;
Lib_Filename : String;
Lib_Dir : String;
Symbol_Data : Symbol_Record;
Driver_Name : Name_Id := No_Name;
Lib_Version : String := "";
Auto_Init : Boolean := False);
-- Build a dynamic/relocatable library
--
-- Ofiles is the list of all object files in the library
--
-- Options is a list of options to be passed to the tool
-- (gcc or other) that effectively builds the dynamic library.
--
-- Interfaces is the list of ALI files for the interfaces of a SAL.
-- It is empty if the library is not a SAL.
--
-- Lib_Filename is the name of the library, without any prefix or
-- extension. For example, on Unix, if Lib_Filename is "toto", the
-- name of the library file will be "libtoto.so".
--
-- Lib_Dir is the directory path where the library will be located
--
-- For OSes that support symbolic links, Lib_Version, if non null,
-- is the actual file name of the library. For example on Unix, if
-- Lib_Filename is "toto" and Lib_Version is "libtoto.so.2.1",
-- "libtoto.so" will be a symbolic link to "libtoto.so.2.1" which
-- will be the actual library file.
--
-- Symbol_Data is used for some platforms, including VMS, to generate
-- the symbols to be exported by the library.
--
-- Note: Depending on the OS, some of the parameters may not be taken into
-- account. For example, on Linux, Interfaces, Symbol_Data and Auto_Init
-- are ignored.
function Library_Exists_For
(Project : Project_Id;
In_Tree : Project_Tree_Ref) return Boolean;
-- Return True if the library file for a library project already exists.
-- This function can only be called for library projects.
function Library_File_Name_For
(Project : Project_Id;
In_Tree : Project_Tree_Ref) return File_Name_Type;
-- Returns the file name of the library file of a library project.
-- This function can only be called for library projects.
function Library_Major_Minor_Id_Supported return Boolean;
-- Indicates if major and minor ids are supported for libraries.
-- If they are supported, then a Library_Version such as libtoto.so.1.2
-- will have a major id of 1 and a minor id of 2. Then libtoto.so,
-- libtoto.so.1 and libtoto.so.1.2 will be created, all three designating
-- the same file.
private
No_Argument_List : constant Argument_List := (1 .. 0 => null);
-- Access to subprogram types for indirection
type String_Function is access function return String;
type Is_Ext_Function is access function (Ext : String) return Boolean;
type String_List_Access_Function is access function
return String_List_Access;
type Build_Dynamic_Library_Function is access procedure
(Ofiles : Argument_List;
Options : Argument_List;
Interfaces : Argument_List;
Lib_Filename : String;
Lib_Dir : String;
Symbol_Data : Symbol_Record;
Driver_Name : Name_Id := No_Name;
Lib_Version : String := "";
Auto_Init : Boolean := False);
type Library_Exists_For_Function is access function
(Project : Project_Id;
In_Tree : Project_Tree_Ref) return Boolean;
type Library_File_Name_For_Function is access function
(Project : Project_Id;
In_Tree : Project_Tree_Ref) return File_Name_Type;
type Boolean_Function is access function return Boolean;
type Library_Support_Function is access function return Library_Support;
function Archive_Builder_Default return String;
Archive_Builder_Ptr : String_Function := Archive_Builder_Default'Access;
function Archive_Builder_Options_Default return String_List_Access;
Archive_Builder_Options_Ptr : String_List_Access_Function :=
Archive_Builder_Options_Default'Access;
function Archive_Builder_Append_Options_Default return String_List_Access;
Archive_Builder_Append_Options_Ptr : String_List_Access_Function :=
Archive_Builder_Append_Options_Default'Access;
function Archive_Ext_Default return String;
Archive_Ext_Ptr : String_Function := Archive_Ext_Default'Access;
function Archive_Indexer_Default return String;
Archive_Indexer_Ptr : String_Function := Archive_Indexer_Default'Access;
function Archive_Indexer_Options_Default return String_List_Access;
Archive_Indexer_Options_Ptr : String_List_Access_Function :=
Archive_Indexer_Options_Default'Access;
function Default_Symbol_File_Name_Default return String;
Default_Symbol_File_Name_Ptr : String_Function :=
Default_Symbol_File_Name_Default'Access;
Build_Dynamic_Library_Ptr : Build_Dynamic_Library_Function;
function DLL_Ext_Default return String;
DLL_Ext_Ptr : String_Function := DLL_Ext_Default'Access;
function DLL_Prefix_Default return String;
DLL_Prefix_Ptr : String_Function := DLL_Prefix_Default'Access;
function Dynamic_Option_Default return String;
Dynamic_Option_Ptr : String_Function := Dynamic_Option_Default'Access;
function Is_Object_Ext_Default (Ext : String) return Boolean;
Is_Object_Ext_Ptr : Is_Ext_Function := Is_Object_Ext_Default'Access;
function Is_C_Ext_Default (Ext : String) return Boolean;
Is_C_Ext_Ptr : Is_Ext_Function := Is_C_Ext_Default'Access;
function Is_Archive_Ext_Default (Ext : String) return Boolean;
Is_Archive_Ext_Ptr : Is_Ext_Function := Is_Archive_Ext_Default'Access;
function Libgnat_Default return String;
Libgnat_Ptr : String_Function := Libgnat_Default'Access;
function Library_Exists_For_Default
(Project : Project_Id;
In_Tree : Project_Tree_Ref) return Boolean;
Library_Exists_For_Ptr : Library_Exists_For_Function :=
Library_Exists_For_Default'Access;
function Library_File_Name_For_Default
(Project : Project_Id;
In_Tree : Project_Tree_Ref) return File_Name_Type;
Library_File_Name_For_Ptr : Library_File_Name_For_Function :=
Library_File_Name_For_Default'Access;
function Object_Ext_Default return String;
Object_Ext_Ptr : String_Function := Object_Ext_Default'Access;
function PIC_Option_Default return String;
PIC_Option_Ptr : String_Function := PIC_Option_Default'Access;
function Standalone_Library_Auto_Init_Is_Supported_Default return Boolean;
Standalone_Library_Auto_Init_Is_Supported_Ptr : Boolean_Function :=
Standalone_Library_Auto_Init_Is_Supported_Default'Access;
function Support_For_Libraries_Default return Library_Support;
Support_For_Libraries_Ptr : Library_Support_Function :=
Support_For_Libraries_Default'Access;
function Library_Major_Minor_Id_Supported_Default return Boolean;
Library_Major_Minor_Id_Supported_Ptr : Boolean_Function :=
Library_Major_Minor_Id_Supported_Default'Access;
end MLib.Tgt;
|
--
-- Copyright (C) 2021, AdaCore
--
pragma Style_Checks (Off);
-- This spec has been automatically generated from STM32L562.svd
with System;
-- STM32L562
package Interfaces.STM32 is
pragma Preelaborate;
pragma No_Elaboration_Code_All;
---------------
-- Base type --
---------------
type UInt32 is new Interfaces.Unsigned_32;
type UInt16 is new Interfaces.Unsigned_16;
type Byte is new Interfaces.Unsigned_8;
type Bit is mod 2**1
with Size => 1;
type UInt2 is mod 2**2
with Size => 2;
type UInt3 is mod 2**3
with Size => 3;
type UInt4 is mod 2**4
with Size => 4;
type UInt5 is mod 2**5
with Size => 5;
type UInt6 is mod 2**6
with Size => 6;
type UInt7 is mod 2**7
with Size => 7;
type UInt9 is mod 2**9
with Size => 9;
type UInt10 is mod 2**10
with Size => 10;
type UInt11 is mod 2**11
with Size => 11;
type UInt12 is mod 2**12
with Size => 12;
type UInt13 is mod 2**13
with Size => 13;
type UInt14 is mod 2**14
with Size => 14;
type UInt15 is mod 2**15
with Size => 15;
type UInt17 is mod 2**17
with Size => 17;
type UInt18 is mod 2**18
with Size => 18;
type UInt19 is mod 2**19
with Size => 19;
type UInt20 is mod 2**20
with Size => 20;
type UInt21 is mod 2**21
with Size => 21;
type UInt22 is mod 2**22
with Size => 22;
type UInt23 is mod 2**23
with Size => 23;
type UInt24 is mod 2**24
with Size => 24;
type UInt25 is mod 2**25
with Size => 25;
type UInt26 is mod 2**26
with Size => 26;
type UInt27 is mod 2**27
with Size => 27;
type UInt28 is mod 2**28
with Size => 28;
type UInt29 is mod 2**29
with Size => 29;
type UInt30 is mod 2**30
with Size => 30;
type UInt31 is mod 2**31
with Size => 31;
--------------------
-- Base addresses --
--------------------
DFSDM1_Base : constant System.Address := System'To_Address (16#40016000#);
SEC_DFSDM1_Base : constant System.Address := System'To_Address (16#50016000#);
DMAMUX1_Base : constant System.Address := System'To_Address (16#40020800#);
SEC_DMAMUX1_Base : constant System.Address := System'To_Address (16#50020800#);
EXTI_Base : constant System.Address := System'To_Address (16#4002F400#);
SEC_EXTI_Base : constant System.Address := System'To_Address (16#5002F400#);
FLASH_Base : constant System.Address := System'To_Address (16#40022000#);
SEC_FLASH_Base : constant System.Address := System'To_Address (16#50022000#);
GPIOA_Base : constant System.Address := System'To_Address (16#42020000#);
SEC_GPIOA_Base : constant System.Address := System'To_Address (16#52020000#);
GPIOB_Base : constant System.Address := System'To_Address (16#42020400#);
SEC_GPIOB_Base : constant System.Address := System'To_Address (16#52020400#);
GPIOC_Base : constant System.Address := System'To_Address (16#42020800#);
GPIOD_Base : constant System.Address := System'To_Address (16#42020C00#);
GPIOE_Base : constant System.Address := System'To_Address (16#42021000#);
GPIOF_Base : constant System.Address := System'To_Address (16#42021400#);
GPIOG_Base : constant System.Address := System'To_Address (16#42021800#);
SEC_GPIOC_Base : constant System.Address := System'To_Address (16#52020800#);
SEC_GPIOD_Base : constant System.Address := System'To_Address (16#52020C00#);
SEC_GPIOE_Base : constant System.Address := System'To_Address (16#52021000#);
SEC_GPIOF_Base : constant System.Address := System'To_Address (16#52021400#);
SEC_GPIOG_Base : constant System.Address := System'To_Address (16#52021800#);
GPIOH_Base : constant System.Address := System'To_Address (16#42021C00#);
SEC_GPIOH_Base : constant System.Address := System'To_Address (16#52021C00#);
TAMP_Base : constant System.Address := System'To_Address (16#40003400#);
SEC_TAMP_Base : constant System.Address := System'To_Address (16#50003400#);
I2C1_Base : constant System.Address := System'To_Address (16#40005400#);
I2C2_Base : constant System.Address := System'To_Address (16#40005800#);
I2C3_Base : constant System.Address := System'To_Address (16#40005C00#);
I2C4_Base : constant System.Address := System'To_Address (16#40008400#);
SEC_I2C1_Base : constant System.Address := System'To_Address (16#50005400#);
SEC_I2C2_Base : constant System.Address := System'To_Address (16#50005800#);
SEC_I2C3_Base : constant System.Address := System'To_Address (16#50005C00#);
SEC_I2C4_Base : constant System.Address := System'To_Address (16#50008400#);
ICache_Base : constant System.Address := System'To_Address (16#40030400#);
SEC_ICache_Base : constant System.Address := System'To_Address (16#50030400#);
IWDG_Base : constant System.Address := System'To_Address (16#40003000#);
SEC_IWDG_Base : constant System.Address := System'To_Address (16#50003000#);
LPTIM1_Base : constant System.Address := System'To_Address (16#40007C00#);
LPTIM2_Base : constant System.Address := System'To_Address (16#40009400#);
LPTIM3_Base : constant System.Address := System'To_Address (16#40009800#);
SEC_LPTIM1_Base : constant System.Address := System'To_Address (16#50007C00#);
SEC_LPTIM2_Base : constant System.Address := System'To_Address (16#50009400#);
SEC_LPTIM3_Base : constant System.Address := System'To_Address (16#50009800#);
GTZC_MPCBB1_Base : constant System.Address := System'To_Address (16#40032C00#);
GTZC_MPCBB2_Base : constant System.Address := System'To_Address (16#40033000#);
PWR_Base : constant System.Address := System'To_Address (16#40007000#);
SEC_PWR_Base : constant System.Address := System'To_Address (16#50007000#);
RCC_Base : constant System.Address := System'To_Address (16#40021000#);
SEC_RCC_Base : constant System.Address := System'To_Address (16#50021000#);
RTC_Base : constant System.Address := System'To_Address (16#40002800#);
SEC_RTC_Base : constant System.Address := System'To_Address (16#50002800#);
SAI1_Base : constant System.Address := System'To_Address (16#40015400#);
SAI2_Base : constant System.Address := System'To_Address (16#40015800#);
SEC_SAI1_Base : constant System.Address := System'To_Address (16#50015400#);
SEC_SAI2_Base : constant System.Address := System'To_Address (16#50015800#);
DMA1_Base : constant System.Address := System'To_Address (16#40020000#);
SEC_DMA1_Base : constant System.Address := System'To_Address (16#50020000#);
DMA2_Base : constant System.Address := System'To_Address (16#40020400#);
SEC_DMA2_Base : constant System.Address := System'To_Address (16#50020400#);
SEC_GTZC_MPCBB1_Base : constant System.Address := System'To_Address (16#50032C00#);
SEC_GTZC_MPCBB2_Base : constant System.Address := System'To_Address (16#50033000#);
SPI1_Base : constant System.Address := System'To_Address (16#40013000#);
SPI2_Base : constant System.Address := System'To_Address (16#40003800#);
SPI3_Base : constant System.Address := System'To_Address (16#40003C00#);
SEC_SPI1_Base : constant System.Address := System'To_Address (16#50013000#);
SEC_SPI2_Base : constant System.Address := System'To_Address (16#50003800#);
SEC_SPI3_Base : constant System.Address := System'To_Address (16#50003C00#);
TIM1_Base : constant System.Address := System'To_Address (16#40012C00#);
SEC_TIM1_Base : constant System.Address := System'To_Address (16#50012C00#);
TIM15_Base : constant System.Address := System'To_Address (16#40014000#);
SEC_TIM15_Base : constant System.Address := System'To_Address (16#50014000#);
TIM16_Base : constant System.Address := System'To_Address (16#40014400#);
SEC_TIM16_Base : constant System.Address := System'To_Address (16#50014400#);
TIM17_Base : constant System.Address := System'To_Address (16#40014800#);
SEC_TIM17_Base : constant System.Address := System'To_Address (16#50014800#);
TIM2_Base : constant System.Address := System'To_Address (16#40000000#);
SEC_TIM2_Base : constant System.Address := System'To_Address (16#50000000#);
TIM3_Base : constant System.Address := System'To_Address (16#40000400#);
SEC_TIM3_Base : constant System.Address := System'To_Address (16#50000400#);
TIM4_Base : constant System.Address := System'To_Address (16#40000800#);
SEC_TIM4_Base : constant System.Address := System'To_Address (16#50000800#);
TIM5_Base : constant System.Address := System'To_Address (16#40000C00#);
SEC_TIM5_Base : constant System.Address := System'To_Address (16#50000C00#);
TIM6_Base : constant System.Address := System'To_Address (16#40001000#);
SEC_TIM6_Base : constant System.Address := System'To_Address (16#50001000#);
TIM7_Base : constant System.Address := System'To_Address (16#40001400#);
SEC_TIM7_Base : constant System.Address := System'To_Address (16#50001400#);
DAC_Base : constant System.Address := System'To_Address (16#40007400#);
SEC_DAC_Base : constant System.Address := System'To_Address (16#50007400#);
OPAMP_Base : constant System.Address := System'To_Address (16#40007800#);
SEC_OPAMP_Base : constant System.Address := System'To_Address (16#50007800#);
AES_Base : constant System.Address := System'To_Address (16#420C0000#);
SEC_AES_Base : constant System.Address := System'To_Address (16#520C0000#);
PKA_Base : constant System.Address := System'To_Address (16#420C2000#);
SEC_PKA_Base : constant System.Address := System'To_Address (16#520C2000#);
OTFDEC1_Base : constant System.Address := System'To_Address (16#420C5000#);
SEC_OTFDEC1_Base : constant System.Address := System'To_Address (16#520C5000#);
TIM8_Base : constant System.Address := System'To_Address (16#40013400#);
SEC_TIM8_Base : constant System.Address := System'To_Address (16#50013400#);
GTZC_TZIC_Base : constant System.Address := System'To_Address (16#40032800#);
SEC_GTZC_TZIC_Base : constant System.Address := System'To_Address (16#50032800#);
GTZC_TZSC_Base : constant System.Address := System'To_Address (16#40032400#);
SEC_GTZC_TZSC_Base : constant System.Address := System'To_Address (16#50032400#);
WWDG_Base : constant System.Address := System'To_Address (16#40002C00#);
SEC_WWDG_Base : constant System.Address := System'To_Address (16#50002C00#);
SYSCFG_Base : constant System.Address := System'To_Address (16#40010000#);
SEC_SYSCFG_Base : constant System.Address := System'To_Address (16#50010000#);
DBGMCU_Base : constant System.Address := System'To_Address (16#E0044000#);
USB_Base : constant System.Address := System'To_Address (16#4000D400#);
SEC_USB_Base : constant System.Address := System'To_Address (16#5000D400#);
OCTOSPI1_Base : constant System.Address := System'To_Address (16#44021000#);
SEC_OCTOSPI1_Base : constant System.Address := System'To_Address (16#54021000#);
LPUART1_Base : constant System.Address := System'To_Address (16#40008000#);
SEC_LPUART1_Base : constant System.Address := System'To_Address (16#50008000#);
COMP_Base : constant System.Address := System'To_Address (16#40010200#);
SEC_COMP_Base : constant System.Address := System'To_Address (16#50010200#);
VREFBUF_Base : constant System.Address := System'To_Address (16#40010030#);
SEC_VREFBUF_Base : constant System.Address := System'To_Address (16#50010030#);
TSC_Base : constant System.Address := System'To_Address (16#40024000#);
SEC_TSC_Base : constant System.Address := System'To_Address (16#50024000#);
UCPD1_Base : constant System.Address := System'To_Address (16#4000DC00#);
SEC_UCPD1_Base : constant System.Address := System'To_Address (16#5000DC00#);
FDCAN1_Base : constant System.Address := System'To_Address (16#4000A400#);
SEC_FDCAN1_Base : constant System.Address := System'To_Address (16#5000A400#);
CRC_Base : constant System.Address := System'To_Address (16#40023000#);
SEC_CRC_Base : constant System.Address := System'To_Address (16#50023000#);
CRS_Base : constant System.Address := System'To_Address (16#40006000#);
SEC_CRS_Base : constant System.Address := System'To_Address (16#50006000#);
USART1_Base : constant System.Address := System'To_Address (16#40013800#);
SEC_USART1_Base : constant System.Address := System'To_Address (16#50013800#);
USART2_Base : constant System.Address := System'To_Address (16#40004400#);
SEC_USART2_Base : constant System.Address := System'To_Address (16#50004400#);
USART3_Base : constant System.Address := System'To_Address (16#40004800#);
SEC_USART3_Base : constant System.Address := System'To_Address (16#50004800#);
UART4_Base : constant System.Address := System'To_Address (16#40004C00#);
UART5_Base : constant System.Address := System'To_Address (16#40005000#);
SEC_UART4_Base : constant System.Address := System'To_Address (16#50004C00#);
SEC_UART5_Base : constant System.Address := System'To_Address (16#50005000#);
ADC_Common_Base : constant System.Address := System'To_Address (16#42028300#);
SEC_ADC_Common_Base : constant System.Address := System'To_Address (16#52028300#);
ADC1_Base : constant System.Address := System'To_Address (16#42028000#);
SEC_ADC1_Base : constant System.Address := System'To_Address (16#52028000#);
ADC2_Base : constant System.Address := System'To_Address (16#42028100#);
SEC_ADC2_Base : constant System.Address := System'To_Address (16#52028100#);
NVIC_Base : constant System.Address := System'To_Address (16#E000E100#);
NVIC_STIR_Base : constant System.Address := System'To_Address (16#E000EF00#);
FMC_Base : constant System.Address := System'To_Address (16#44020000#);
SEC_FMC_Base : constant System.Address := System'To_Address (16#54020000#);
RNG_Base : constant System.Address := System'To_Address (16#420C0800#);
SEC_RNG_Base : constant System.Address := System'To_Address (16#520C0800#);
SDMMC1_Base : constant System.Address := System'To_Address (16#420C8000#);
SEC_SDMMC1_Base : constant System.Address := System'To_Address (16#520C8000#);
DCB_Base : constant System.Address := System'To_Address (16#E000EE08#);
HASH_Base : constant System.Address := System'To_Address (16#420C0400#);
SEC_HASH_Base : constant System.Address := System'To_Address (16#520C0400#);
end Interfaces.STM32;
|
-----------------------------------------------------------------------
-- util-commands-drivers -- Support to make command line tools
-- Copyright (C) 2017, 2018, 2019 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.Log.Loggers;
with Ada.Text_IO; use Ada.Text_IO;
package body Util.Commands.Drivers is
use Ada.Strings.Unbounded;
-- The logger
Logs : constant Util.Log.Loggers.Logger := Util.Log.Loggers.Create (Driver_Name);
function "-" (Message : in String) return String is (Translate (Message)) with Inline;
-- ------------------------------
-- Get the description associated with the command.
-- ------------------------------
function Get_Description (Command : in Command_Type) return String is
begin
return To_String (Command.Description);
end Get_Description;
-- ------------------------------
-- Get the name used to register the command.
-- ------------------------------
function Get_Name (Command : in Command_Type) return String is
begin
return To_String (Command.Name);
end Get_Name;
-- ------------------------------
-- Write the command usage.
-- ------------------------------
procedure Usage (Command : in out Command_Type;
Name : in String;
Context : in out Context_Type) is
Config : Config_Type;
begin
Command_Type'Class (Command).Setup (Config, Context);
Config_Parser.Usage (Name, Config);
end Usage;
-- ------------------------------
-- Print a message for the command. The level indicates whether the message is an error,
-- warning or informational. The command name can be used to known the originator.
-- The <tt>Log</tt> operation is redirected to the driver's <tt>Log</tt> procedure.
-- ------------------------------
procedure Log (Command : in Command_Type;
Level : in Util.Log.Level_Type;
Name : in String;
Message : in String) is
begin
Command.Driver.Log (Level, Name, Message);
end Log;
-- ------------------------------
-- Execute the help command with the arguments.
-- Print the help for every registered command.
-- ------------------------------
overriding
procedure Execute (Command : in out Help_Command_Type;
Name : in String;
Args : in Argument_List'Class;
Context : in out Context_Type) is
procedure Compute_Size (Position : in Command_Sets.Cursor);
procedure Print (Position : in Command_Sets.Cursor);
Column : Ada.Text_IO.Positive_Count := 1;
procedure Compute_Size (Position : in Command_Sets.Cursor) is
Cmd : constant Command_Access := Command_Sets.Element (Position);
Len : constant Natural := Length (Cmd.Name);
begin
if Natural (Column) < Len then
Column := Ada.Text_IO.Positive_Count (Len);
end if;
end Compute_Size;
procedure Print (Position : in Command_Sets.Cursor) is
Cmd : constant Command_Access := Command_Sets.Element (Position);
begin
Put (" ");
Put (To_String (Cmd.Name));
if Length (Cmd.Description) > 0 then
Set_Col (Column + 7);
Put (To_String (Cmd.Description));
end if;
New_Line;
end Print;
begin
Logs.Debug ("Execute command {0}", Name);
if Args.Get_Count = 0 then
Usage (Command.Driver.all, Args, Context);
New_Line;
Put ("Type '");
Put (Driver_Name);
Put_Line (" help {command}' for help on a specific command.");
New_Line;
Put_Line (-("Available subcommands:"));
Command.Driver.List.Iterate (Process => Compute_Size'Access);
Command.Driver.List.Iterate (Process => Print'Access);
else
declare
Cmd_Name : constant String := Args.Get_Argument (1);
Target_Cmd : constant Command_Access := Command.Driver.Find_Command (Cmd_Name);
begin
if Target_Cmd = null then
Logs.Error (-("Unknown command '{0}'"), Cmd_Name);
raise Not_Found;
else
Target_Cmd.Help (Cmd_Name, Context);
end if;
end;
end if;
end Execute;
-- ------------------------------
-- Write the help associated with the command.
-- ------------------------------
procedure Help (Command : in out Help_Command_Type;
Name : in String;
Context : in out Context_Type) is
begin
null;
end Help;
-- ------------------------------
-- Report the command usage.
-- ------------------------------
procedure Usage (Driver : in Driver_Type;
Args : in Argument_List'Class;
Context : in out Context_Type;
Name : in String := "") is
begin
Put_Line (To_String (Driver.Desc));
New_Line;
if Name'Length > 0 then
declare
Command : constant Command_Access := Driver.Find_Command (Name);
begin
if Command /= null then
Command.Usage (Name, Context);
else
Put (-("Invalid command"));
end if;
end;
else
Put (-("Usage: "));
Put (Args.Get_Command_Name);
Put (" ");
Put_Line (To_String (Driver.Usage));
end if;
end Usage;
-- ------------------------------
-- Set the driver description printed in the usage.
-- ------------------------------
procedure Set_Description (Driver : in out Driver_Type;
Description : in String) is
begin
Driver.Desc := Ada.Strings.Unbounded.To_Unbounded_String (Description);
end Set_Description;
-- ------------------------------
-- Set the driver usage printed in the usage.
-- ------------------------------
procedure Set_Usage (Driver : in out Driver_Type;
Usage : in String) is
begin
Driver.Usage := Ada.Strings.Unbounded.To_Unbounded_String (Usage);
end Set_Usage;
-- ------------------------------
-- Register the command under the given name.
-- ------------------------------
procedure Add_Command (Driver : in out Driver_Type;
Name : in String;
Command : in Command_Access) is
begin
Command.Name := To_Unbounded_String (Name);
Command.Driver := Driver'Unchecked_Access;
Driver.List.Include (Command);
end Add_Command;
procedure Add_Command (Driver : in out Driver_Type;
Name : in String;
Description : in String;
Command : in Command_Access) is
begin
Command.Name := To_Unbounded_String (Name);
Command.Description := To_Unbounded_String (Description);
Add_Command (Driver, Name, Command);
end Add_Command;
-- ------------------------------
-- Register the command under the given name.
-- ------------------------------
procedure Add_Command (Driver : in out Driver_Type;
Name : in String;
Description : in String;
Handler : in Command_Handler) is
Command : constant Command_Access
:= new Handler_Command_Type '(Driver => Driver'Unchecked_Access,
Description => To_Unbounded_String (Description),
Name => To_Unbounded_String (Name),
Handler => Handler);
begin
Driver.List.Include (Command);
end Add_Command;
-- ------------------------------
-- Find the command having the given name.
-- Returns null if the command was not found.
-- ------------------------------
function Find_Command (Driver : in Driver_Type;
Name : in String) return Command_Access is
Cmd : aliased Help_Command_Type;
Pos : Command_Sets.Cursor;
begin
Cmd.Name := To_Unbounded_String (Name);
Pos := Driver.List.Find (Cmd'Unchecked_Access);
if Command_Sets.Has_Element (Pos) then
return Command_Sets.Element (Pos);
else
return null;
end if;
end Find_Command;
-- ------------------------------
-- Execute the command registered under the given name.
-- ------------------------------
procedure Execute (Driver : in Driver_Type;
Name : in String;
Args : in Argument_List'Class;
Context : in out Context_Type) is
procedure Execute (Cmd_Args : in Argument_List'Class);
Command : constant Command_Access := Driver.Find_Command (Name);
procedure Execute (Cmd_Args : in Argument_List'Class) is
begin
Command.Execute (Name, Cmd_Args, Context);
end Execute;
begin
if Command /= null then
declare
Config : Config_Type;
begin
Command.Setup (Config, Context);
Config_Parser.Execute (Config, Args, Execute'Access);
end;
else
Logs.Error (-("Unkown command '{0}'"), Name);
raise Not_Found;
end if;
end Execute;
-- ------------------------------
-- Print a message for the command. The level indicates whether the message is an error,
-- warning or informational. The command name can be used to known the originator.
-- ------------------------------
procedure Log (Driver : in Driver_Type;
Level : in Util.Log.Level_Type;
Name : in String;
Message : in String) is
pragma Unreferenced (Driver);
begin
Logs.Print (Level, "{0}: {1}", Name, Message);
end Log;
-- ------------------------------
-- Execute the command with the arguments.
-- ------------------------------
overriding
procedure Execute (Command : in out Handler_Command_Type;
Name : in String;
Args : in Argument_List'Class;
Context : in out Context_Type) is
begin
Command.Handler (Name, Args, Context);
end Execute;
-- ------------------------------
-- Write the help associated with the command.
-- ------------------------------
overriding
procedure Help (Command : in out Handler_Command_Type;
Name : in String;
Context : in out Context_Type) is
begin
null;
end Help;
end Util.Commands.Drivers;
|
Ada.Text_IO.Put_Line -- would not compile
("Factorial(20) =" & Integer'Image(A_11_15 * A_16_20 * F_10));
|
------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- Ada Modeling Framework --
-- --
-- Runtime Library Component --
-- --
------------------------------------------------------------------------------
-- --
-- Copyright © 2012, 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.CMOF.Holders.Parameter_Direction_Kinds;
with AMF.CMOF.Holders.Visibility_Kinds;
with AMF.Internals.Elements;
with AMF.Internals.Extents;
with AMF.Internals.Helpers;
with AMF.Internals.Links;
with AMF.Internals.Listener_Registry;
with AMF.Internals.Tables.CMOF_Constructors;
with AMF.Internals.Tables.CMOF_Metamodel;
package body AMF.Internals.Factories.CMOF_Factories is
In_Img : constant League.Strings.Universal_String
:= League.Strings.To_Universal_String ("in");
Inout_Img : constant League.Strings.Universal_String
:= League.Strings.To_Universal_String ("inout");
Out_Img : constant League.Strings.Universal_String
:= League.Strings.To_Universal_String ("out");
Return_Img : constant League.Strings.Universal_String
:= League.Strings.To_Universal_String ("return");
Public_Img : constant League.Strings.Universal_String
:= League.Strings.To_Universal_String ("public");
Private_Img : constant League.Strings.Universal_String
:= League.Strings.To_Universal_String ("private");
Protected_Img : constant League.Strings.Universal_String
:= League.Strings.To_Universal_String ("protected");
Package_Img : constant League.Strings.Universal_String
:= League.Strings.To_Universal_String ("package");
function Convert_Boolean_To_String
(Value : League.Holders.Holder) return League.Strings.Universal_String
is separate;
function Create_Boolean_From_String
(Image : League.Strings.Universal_String) return League.Holders.Holder
is separate;
function Convert_Integer_To_String
(Value : League.Holders.Holder) return League.Strings.Universal_String
is separate;
function Create_Integer_From_String
(Image : League.Strings.Universal_String) return League.Holders.Holder
is separate;
function Convert_String_To_String
(Value : League.Holders.Holder) return League.Strings.Universal_String
is separate;
function Create_String_From_String
(Image : League.Strings.Universal_String) return League.Holders.Holder
is separate;
function Convert_Unlimited_Natural_To_String
(Value : League.Holders.Holder) return League.Strings.Universal_String
is separate;
function Create_Unlimited_Natural_From_String
(Image : League.Strings.Universal_String) return League.Holders.Holder
is separate;
-----------------
-- Constructor --
-----------------
function Constructor
(Extent : AMF.Internals.AMF_Extent)
return not null AMF.Factories.Factory_Access is
begin
return new CMOF_Factory'(Extent => Extent);
end Constructor;
-----------------------
-- Convert_To_String --
-----------------------
overriding function Convert_To_String
(Self : not null access CMOF_Factory;
Data_Type : not null access AMF.CMOF.Data_Types.CMOF_Data_Type'Class;
Value : League.Holders.Holder) return League.Strings.Universal_String
is
pragma Unreferenced (Self);
DT : constant AMF.Internals.CMOF_Element
:= AMF.Internals.Elements.Element_Base'Class (Data_Type.all).Element;
begin
if DT = AMF.Internals.Tables.CMOF_Metamodel.MC_CMOF_Boolean then
return Convert_Boolean_To_String (Value);
elsif DT = AMF.Internals.Tables.CMOF_Metamodel.MC_CMOF_Integer then
return Convert_Integer_To_String (Value);
elsif DT = AMF.Internals.Tables.CMOF_Metamodel.MC_CMOF_Parameter_Direction_Kind then
declare
Item : constant AMF.CMOF.CMOF_Parameter_Direction_Kind
:= AMF.CMOF.Holders.Parameter_Direction_Kinds.Element (Value);
begin
case Item is
when AMF.CMOF.In_Parameter =>
return In_Img;
when AMF.CMOF.In_Out_Parameter =>
return Inout_Img;
when AMF.CMOF.Out_Parameter =>
return Out_Img;
when AMF.CMOF.Return_Parameter =>
return Return_Img;
end case;
end;
elsif DT = AMF.Internals.Tables.CMOF_Metamodel.MC_CMOF_String then
return Convert_String_To_String (Value);
elsif DT = AMF.Internals.Tables.CMOF_Metamodel.MC_CMOF_Unlimited_Natural then
return Convert_Unlimited_Natural_To_String (Value);
elsif DT = AMF.Internals.Tables.CMOF_Metamodel.MC_CMOF_Visibility_Kind then
declare
Item : constant AMF.CMOF.CMOF_Visibility_Kind
:= AMF.CMOF.Holders.Visibility_Kinds.Element (Value);
begin
case Item is
when AMF.CMOF.Public_Visibility =>
return Public_Img;
when AMF.CMOF.Private_Visibility =>
return Private_Img;
when AMF.CMOF.Protected_Visibility =>
return Protected_Img;
when AMF.CMOF.Package_Visibility =>
return Package_Img;
end case;
end;
else
raise Program_Error;
end if;
end Convert_To_String;
------------
-- Create --
------------
overriding function Create
(Self : not null access CMOF_Factory;
Meta_Class : not null access AMF.CMOF.Classes.CMOF_Class'Class)
return not null AMF.Elements.Element_Access
is
MC : constant AMF.Internals.CMOF_Element
:= AMF.Internals.Elements.Element_Base'Class (Meta_Class.all).Element;
Element : AMF.Internals.AMF_Element;
begin
if MC = AMF.Internals.Tables.CMOF_Metamodel.MC_CMOF_Association then
Element := AMF.Internals.Tables.CMOF_Constructors.Create_CMOF_Association;
elsif MC = AMF.Internals.Tables.CMOF_Metamodel.MC_CMOF_Class then
Element := AMF.Internals.Tables.CMOF_Constructors.Create_CMOF_Class;
elsif MC = AMF.Internals.Tables.CMOF_Metamodel.MC_CMOF_Comment then
Element := AMF.Internals.Tables.CMOF_Constructors.Create_CMOF_Comment;
elsif MC = AMF.Internals.Tables.CMOF_Metamodel.MC_CMOF_Constraint then
Element := AMF.Internals.Tables.CMOF_Constructors.Create_CMOF_Constraint;
elsif MC = AMF.Internals.Tables.CMOF_Metamodel.MC_CMOF_Data_Type then
Element := AMF.Internals.Tables.CMOF_Constructors.Create_CMOF_Data_Type;
elsif MC = AMF.Internals.Tables.CMOF_Metamodel.MC_CMOF_Element_Import then
Element := AMF.Internals.Tables.CMOF_Constructors.Create_CMOF_Element_Import;
elsif MC = AMF.Internals.Tables.CMOF_Metamodel.MC_CMOF_Enumeration then
Element := AMF.Internals.Tables.CMOF_Constructors.Create_CMOF_Enumeration;
elsif MC = AMF.Internals.Tables.CMOF_Metamodel.MC_CMOF_Enumeration_Literal then
Element := AMF.Internals.Tables.CMOF_Constructors.Create_CMOF_Enumeration_Literal;
elsif MC = AMF.Internals.Tables.CMOF_Metamodel.MC_CMOF_Expression then
Element := AMF.Internals.Tables.CMOF_Constructors.Create_CMOF_Expression;
elsif MC = AMF.Internals.Tables.CMOF_Metamodel.MC_CMOF_Opaque_Expression then
Element := AMF.Internals.Tables.CMOF_Constructors.Create_CMOF_Opaque_Expression;
elsif MC = AMF.Internals.Tables.CMOF_Metamodel.MC_CMOF_Operation then
Element := AMF.Internals.Tables.CMOF_Constructors.Create_CMOF_Operation;
elsif MC = AMF.Internals.Tables.CMOF_Metamodel.MC_CMOF_Package then
Element := AMF.Internals.Tables.CMOF_Constructors.Create_CMOF_Package;
elsif MC = AMF.Internals.Tables.CMOF_Metamodel.MC_CMOF_Package_Import then
Element := AMF.Internals.Tables.CMOF_Constructors.Create_CMOF_Package_Import;
elsif MC = AMF.Internals.Tables.CMOF_Metamodel.MC_CMOF_Package_Merge then
Element := AMF.Internals.Tables.CMOF_Constructors.Create_CMOF_Package_Merge;
elsif MC = AMF.Internals.Tables.CMOF_Metamodel.MC_CMOF_Parameter then
Element := AMF.Internals.Tables.CMOF_Constructors.Create_CMOF_Parameter;
elsif MC = AMF.Internals.Tables.CMOF_Metamodel.MC_CMOF_Primitive_Type then
Element := AMF.Internals.Tables.CMOF_Constructors.Create_CMOF_Primitive_Type;
elsif MC = AMF.Internals.Tables.CMOF_Metamodel.MC_CMOF_Property then
Element := AMF.Internals.Tables.CMOF_Constructors.Create_CMOF_Property;
elsif MC = AMF.Internals.Tables.CMOF_Metamodel.MC_CMOF_Tag then
Element := AMF.Internals.Tables.CMOF_Constructors.Create_CMOF_Tag;
else
raise Program_Error;
end if;
AMF.Internals.Extents.Internal_Append (Self.Extent, Element);
AMF.Internals.Listener_Registry.Notify_Instance_Create
(AMF.Internals.Helpers.To_Element (Element));
return AMF.Internals.Helpers.To_Element (Element);
end Create;
------------------------
-- Create_From_String --
------------------------
overriding function Create_From_String
(Self : not null access CMOF_Factory;
Data_Type : not null access AMF.CMOF.Data_Types.CMOF_Data_Type'Class;
Image : League.Strings.Universal_String) return League.Holders.Holder
is
pragma Unreferenced (Self);
use type League.Strings.Universal_String;
DT : constant AMF.Internals.CMOF_Element
:= AMF.Internals.Elements.Element_Base'Class (Data_Type.all).Element;
begin
if DT = AMF.Internals.Tables.CMOF_Metamodel.MC_CMOF_Boolean then
return Create_Boolean_From_String (Image);
elsif DT = AMF.Internals.Tables.CMOF_Metamodel.MC_CMOF_Integer then
return Create_Integer_From_String (Image);
elsif DT = AMF.Internals.Tables.CMOF_Metamodel.MC_CMOF_Parameter_Direction_Kind then
if Image = In_Img then
return
AMF.CMOF.Holders.Parameter_Direction_Kinds.To_Holder
(AMF.CMOF.In_Parameter);
elsif Image = Inout_Img then
return
AMF.CMOF.Holders.Parameter_Direction_Kinds.To_Holder
(AMF.CMOF.In_Out_Parameter);
elsif Image = Out_Img then
return
AMF.CMOF.Holders.Parameter_Direction_Kinds.To_Holder
(AMF.CMOF.Out_Parameter);
elsif Image = Return_Img then
return
AMF.CMOF.Holders.Parameter_Direction_Kinds.To_Holder
(AMF.CMOF.Return_Parameter);
else
raise Constraint_Error;
end if;
elsif DT = AMF.Internals.Tables.CMOF_Metamodel.MC_CMOF_String then
return Create_String_From_String (Image);
elsif DT = AMF.Internals.Tables.CMOF_Metamodel.MC_CMOF_Unlimited_Natural then
return Create_Unlimited_Natural_From_String (Image);
elsif DT = AMF.Internals.Tables.CMOF_Metamodel.MC_CMOF_Visibility_Kind then
if Image = Public_Img then
return
AMF.CMOF.Holders.Visibility_Kinds.To_Holder
(AMF.CMOF.Public_Visibility);
elsif Image = Private_Img then
return
AMF.CMOF.Holders.Visibility_Kinds.To_Holder
(AMF.CMOF.Private_Visibility);
elsif Image = Protected_Img then
return
AMF.CMOF.Holders.Visibility_Kinds.To_Holder
(AMF.CMOF.Protected_Visibility);
elsif Image = Package_Img then
return
AMF.CMOF.Holders.Visibility_Kinds.To_Holder
(AMF.CMOF.Package_Visibility);
else
raise Constraint_Error;
end if;
else
raise Program_Error;
end if;
end Create_From_String;
-----------------
-- Create_Link --
-----------------
overriding function Create_Link
(Self : not null access CMOF_Factory;
Association :
not null access AMF.CMOF.Associations.CMOF_Association'Class;
First_Element : not null AMF.Elements.Element_Access;
Second_Element : not null AMF.Elements.Element_Access)
return not null AMF.Links.Link_Access
is
pragma Unreferenced (Self);
begin
return
AMF.Internals.Links.Proxy
(AMF.Internals.Links.Create_Link
(AMF.Internals.Elements.Element_Base'Class
(Association.all).Element,
AMF.Internals.Helpers.To_Element (First_Element),
AMF.Internals.Helpers.To_Element (Second_Element)));
end Create_Link;
-----------------
-- Get_Package --
-----------------
overriding function Get_Package
(Self : not null access constant CMOF_Factory)
return AMF.CMOF.Packages.Collections.Set_Of_CMOF_Package
is
pragma Unreferenced (Self);
begin
return Result : AMF.CMOF.Packages.Collections.Set_Of_CMOF_Package do
Result.Add (Get_Package);
end return;
end Get_Package;
-----------------
-- Get_Package --
-----------------
function Get_Package return not null AMF.CMOF.Packages.CMOF_Package_Access is
begin
return
AMF.CMOF.Packages.CMOF_Package_Access
(AMF.Internals.Helpers.To_Element
(AMF.Internals.Tables.CMOF_Metamodel.MM_CMOF_CMOF));
end Get_Package;
------------------------
-- Create_Association --
------------------------
overriding function Create_Association
(Self : not null access CMOF_Factory)
return AMF.CMOF.Associations.CMOF_Association_Access is
begin
return
AMF.CMOF.Associations.CMOF_Association_Access
(Self.Create
(AMF.CMOF.Classes.CMOF_Class_Access
(AMF.Internals.Helpers.To_Element
(AMF.Internals.Tables.CMOF_Metamodel.MC_CMOF_Association))));
end Create_Association;
------------------
-- Create_Class --
------------------
overriding function Create_Class
(Self : not null access CMOF_Factory)
return AMF.CMOF.Classes.CMOF_Class_Access is
begin
return
AMF.CMOF.Classes.CMOF_Class_Access
(Self.Create
(AMF.CMOF.Classes.CMOF_Class_Access
(AMF.Internals.Helpers.To_Element
(AMF.Internals.Tables.CMOF_Metamodel.MC_CMOF_Class))));
end Create_Class;
--------------------
-- Create_Comment --
--------------------
overriding function Create_Comment
(Self : not null access CMOF_Factory)
return AMF.CMOF.Comments.CMOF_Comment_Access is
begin
return
AMF.CMOF.Comments.CMOF_Comment_Access
(Self.Create
(AMF.CMOF.Classes.CMOF_Class_Access
(AMF.Internals.Helpers.To_Element
(AMF.Internals.Tables.CMOF_Metamodel.MC_CMOF_Comment))));
end Create_Comment;
-----------------------
-- Create_Constraint --
-----------------------
overriding function Create_Constraint
(Self : not null access CMOF_Factory)
return AMF.CMOF.Constraints.CMOF_Constraint_Access is
begin
return
AMF.CMOF.Constraints.CMOF_Constraint_Access
(Self.Create
(AMF.CMOF.Classes.CMOF_Class_Access
(AMF.Internals.Helpers.To_Element
(AMF.Internals.Tables.CMOF_Metamodel.MC_CMOF_Constraint))));
end Create_Constraint;
----------------------
-- Create_Data_Type --
----------------------
overriding function Create_Data_Type
(Self : not null access CMOF_Factory)
return AMF.CMOF.Data_Types.CMOF_Data_Type_Access is
begin
return
AMF.CMOF.Data_Types.CMOF_Data_Type_Access
(Self.Create
(AMF.CMOF.Classes.CMOF_Class_Access
(AMF.Internals.Helpers.To_Element
(AMF.Internals.Tables.CMOF_Metamodel.MC_CMOF_Data_Type))));
end Create_Data_Type;
---------------------------
-- Create_Element_Import --
---------------------------
overriding function Create_Element_Import
(Self : not null access CMOF_Factory)
return AMF.CMOF.Element_Imports.CMOF_Element_Import_Access is
begin
return
AMF.CMOF.Element_Imports.CMOF_Element_Import_Access
(Self.Create
(AMF.CMOF.Classes.CMOF_Class_Access
(AMF.Internals.Helpers.To_Element
(AMF.Internals.Tables.CMOF_Metamodel.MC_CMOF_Element_Import))));
end Create_Element_Import;
------------------------
-- Create_Enumeration --
------------------------
overriding function Create_Enumeration
(Self : not null access CMOF_Factory)
return AMF.CMOF.Enumerations.CMOF_Enumeration_Access is
begin
return
AMF.CMOF.Enumerations.CMOF_Enumeration_Access
(Self.Create
(AMF.CMOF.Classes.CMOF_Class_Access
(AMF.Internals.Helpers.To_Element
(AMF.Internals.Tables.CMOF_Metamodel.MC_CMOF_Enumeration))));
end Create_Enumeration;
--------------------------------
-- Create_Enumeration_Literal --
--------------------------------
overriding function Create_Enumeration_Literal
(Self : not null access CMOF_Factory)
return AMF.CMOF.Enumeration_Literals.CMOF_Enumeration_Literal_Access is
begin
return
AMF.CMOF.Enumeration_Literals.CMOF_Enumeration_Literal_Access
(Self.Create
(AMF.CMOF.Classes.CMOF_Class_Access
(AMF.Internals.Helpers.To_Element
(AMF.Internals.Tables.CMOF_Metamodel.MC_CMOF_Enumeration_Literal))));
end Create_Enumeration_Literal;
-----------------------
-- Create_Expression --
-----------------------
overriding function Create_Expression
(Self : not null access CMOF_Factory)
return AMF.CMOF.Expressions.CMOF_Expression_Access is
begin
return
AMF.CMOF.Expressions.CMOF_Expression_Access
(Self.Create
(AMF.CMOF.Classes.CMOF_Class_Access
(AMF.Internals.Helpers.To_Element
(AMF.Internals.Tables.CMOF_Metamodel.MC_CMOF_Expression))));
end Create_Expression;
------------------------------
-- Create_Opaque_Expression --
------------------------------
overriding function Create_Opaque_Expression
(Self : not null access CMOF_Factory)
return AMF.CMOF.Opaque_Expressions.CMOF_Opaque_Expression_Access is
begin
return
AMF.CMOF.Opaque_Expressions.CMOF_Opaque_Expression_Access
(Self.Create
(AMF.CMOF.Classes.CMOF_Class_Access
(AMF.Internals.Helpers.To_Element
(AMF.Internals.Tables.CMOF_Metamodel.MC_CMOF_Opaque_Expression))));
end Create_Opaque_Expression;
----------------------
-- Create_Operation --
----------------------
overriding function Create_Operation
(Self : not null access CMOF_Factory)
return AMF.CMOF.Operations.CMOF_Operation_Access is
begin
return
AMF.CMOF.Operations.CMOF_Operation_Access
(Self.Create
(AMF.CMOF.Classes.CMOF_Class_Access
(AMF.Internals.Helpers.To_Element
(AMF.Internals.Tables.CMOF_Metamodel.MC_CMOF_Operation))));
end Create_Operation;
--------------------
-- Create_Package --
--------------------
overriding function Create_Package
(Self : not null access CMOF_Factory)
return AMF.CMOF.Packages.CMOF_Package_Access is
begin
return
AMF.CMOF.Packages.CMOF_Package_Access
(Self.Create
(AMF.CMOF.Classes.CMOF_Class_Access
(AMF.Internals.Helpers.To_Element
(AMF.Internals.Tables.CMOF_Metamodel.MC_CMOF_Package))));
end Create_Package;
---------------------------
-- Create_Package_Import --
---------------------------
overriding function Create_Package_Import
(Self : not null access CMOF_Factory)
return AMF.CMOF.Package_Imports.CMOF_Package_Import_Access is
begin
return
AMF.CMOF.Package_Imports.CMOF_Package_Import_Access
(Self.Create
(AMF.CMOF.Classes.CMOF_Class_Access
(AMF.Internals.Helpers.To_Element
(AMF.Internals.Tables.CMOF_Metamodel.MC_CMOF_Package_Import))));
end Create_Package_Import;
--------------------------
-- Create_Package_Merge --
--------------------------
overriding function Create_Package_Merge
(Self : not null access CMOF_Factory)
return AMF.CMOF.Package_Merges.CMOF_Package_Merge_Access is
begin
return
AMF.CMOF.Package_Merges.CMOF_Package_Merge_Access
(Self.Create
(AMF.CMOF.Classes.CMOF_Class_Access
(AMF.Internals.Helpers.To_Element
(AMF.Internals.Tables.CMOF_Metamodel.MC_CMOF_Package_Merge))));
end Create_Package_Merge;
----------------------
-- Create_Parameter --
----------------------
overriding function Create_Parameter
(Self : not null access CMOF_Factory)
return AMF.CMOF.Parameters.CMOF_Parameter_Access is
begin
return
AMF.CMOF.Parameters.CMOF_Parameter_Access
(Self.Create
(AMF.CMOF.Classes.CMOF_Class_Access
(AMF.Internals.Helpers.To_Element
(AMF.Internals.Tables.CMOF_Metamodel.MC_CMOF_Parameter))));
end Create_Parameter;
---------------------------
-- Create_Primitive_Type --
---------------------------
overriding function Create_Primitive_Type
(Self : not null access CMOF_Factory)
return AMF.CMOF.Primitive_Types.CMOF_Primitive_Type_Access is
begin
return
AMF.CMOF.Primitive_Types.CMOF_Primitive_Type_Access
(Self.Create
(AMF.CMOF.Classes.CMOF_Class_Access
(AMF.Internals.Helpers.To_Element
(AMF.Internals.Tables.CMOF_Metamodel.MC_CMOF_Primitive_Type))));
end Create_Primitive_Type;
---------------------
-- Create_Property --
---------------------
overriding function Create_Property
(Self : not null access CMOF_Factory)
return AMF.CMOF.Properties.CMOF_Property_Access is
begin
return
AMF.CMOF.Properties.CMOF_Property_Access
(Self.Create
(AMF.CMOF.Classes.CMOF_Class_Access
(AMF.Internals.Helpers.To_Element
(AMF.Internals.Tables.CMOF_Metamodel.MC_CMOF_Property))));
end Create_Property;
----------------
-- Create_Tag --
----------------
overriding function Create_Tag
(Self : not null access CMOF_Factory)
return AMF.CMOF.Tags.CMOF_Tag_Access is
begin
return
AMF.CMOF.Tags.CMOF_Tag_Access
(Self.Create
(AMF.CMOF.Classes.CMOF_Class_Access
(AMF.Internals.Helpers.To_Element
(AMF.Internals.Tables.CMOF_Metamodel.MC_CMOF_Tag))));
end Create_Tag;
end AMF.Internals.Factories.CMOF_Factories;
|
-- { dg-do run }
with Init7; use Init7;
with Text_IO; use Text_IO;
with Dump;
procedure T7 is
Verbose : constant Boolean := False;
Local_R1 : R1;
Local_R2 : R2;
begin
Local_R1.I := My_R1.I + 1;
Local_R1.N.C1 := My_R1.N.C1 + 1;
Local_R1.N.C2 := My_R1.N.C2 + 1;
Local_R1.N.C3 := My_R1.N.C3 + 1;
Put ("Local_R1 :");
Dump (Local_R1'Address, R1'Max_Size_In_Storage_Elements);
New_Line;
-- { dg-output "Local_R1 : 79 56 34 12 13 00 ab 00 35 00 cd 00 57 00 ef 00.*\n" }
Local_R2.I := My_R2.I + 1;
Local_R2.N.C1 := My_R2.N.C1 + 1;
Local_R2.N.C2 := My_R2.N.C2 + 1;
Local_R2.N.C3 := My_R2.N.C3 + 1;
Put ("Local_R2 :");
Dump (Local_R2'Address, R2'Max_Size_In_Storage_Elements);
New_Line;
-- { dg-output "Local_R2 : 12 34 56 79 00 ab 00 13 00 cd 00 35 00 ef 00 57.*\n" }
--
Local_R1 := (I => 16#12345678#,
N => (16#AB0012#, 16#CD0034#, 16#EF0056#));
Put ("Local_R1 :");
Dump (Local_R1'Address, R1'Max_Size_In_Storage_Elements);
New_Line;
-- { dg-output "Local_R1 : 78 56 34 12 12 00 ab 00 34 00 cd 00 56 00 ef 00.*\n" }
Local_R2 := (I => 16#12345678#,
N => (16#AB0012#, 16#CD0034#, 16#EF0056#));
Put ("Local_R2 :");
Dump (Local_R2'Address, R2'Max_Size_In_Storage_Elements);
New_Line;
-- { dg-output "Local_R2 : 12 34 56 78 00 ab 00 12 00 cd 00 34 00 ef 00 56.*\n" }
Local_R1.I := Local_R1.I + 1;
Local_R1.N.C1 := Local_R1.N.C1 + 1;
Local_R1.N.C2 := Local_R1.N.C2 + 1;
Local_R1.N.C3 := Local_R1.N.C3 + 1;
Put ("Local_R1 :");
Dump (Local_R1'Address, R1'Max_Size_In_Storage_Elements);
New_Line;
-- { dg-output "Local_R1 : 79 56 34 12 13 00 ab 00 35 00 cd 00 57 00 ef 00.*\n" }
Local_R2.I := Local_R2.I + 1;
Local_R2.N.C1 := Local_R2.N.C1 + 1;
Local_R2.N.C2 := Local_R2.N.C2 + 1;
Local_R2.N.C3 := Local_R2.N.C3 + 1;
Put ("Local_R2 :");
Dump (Local_R2'Address, R2'Max_Size_In_Storage_Elements);
New_Line;
-- { dg-output "Local_R2 : 12 34 56 79 00 ab 00 13 00 cd 00 35 00 ef 00 57.*\n" }
end;
|
with Ada.Command_Line; use Ada.Command_Line;
with Ada.Text_IO; use Ada.Text_IO;
with Ada.Real_Time;
with Ada.Unchecked_Conversion;
procedure Main is
pragma Suppress(All_Checks);
Matrix_Size : constant := 3200;
type Matrix_Range is range 0 .. Matrix_Size - 1;
Bound_High, Bound_Low : Matrix_Range;
type Pile is range 0..7 with Size=>8;
type Pile_Pointer is access all Pile;
type Generic_Matrix_Row is array (Matrix_Range range <>) of aliased Pile with Pack;
subtype Matrix_Row is Generic_Matrix_Row(Matrix_Range);
subtype Matrix_Sub_Row is Generic_Matrix_Row(0..7);
type Matrix is array (Matrix_Range) of Matrix_Row with Pack;
type Matrix_Pointer is access all Matrix;
type m128i is array (0 .. 15) of Pile with Pack, Alignment=>16;
pragma Machine_Attribute (m128i, "vector_type");
pragma Machine_Attribute (m128i, "may_alias");
----------------------------------------------------------------------
function ia32_Add (X, Y : m128i) return m128i with Inline;
pragma Import (Intrinsic, ia32_Add, "__builtin_ia32_paddb128");
function ia32_Load (X : Pile_Pointer) return m128i with Inline;
pragma Import (Intrinsic, ia32_Load, "__builtin_ia32_loaddqu");
procedure ia32_Store (X : Pile_Pointer; Y : m128i) with Inline;
pragma Import (Intrinsic, ia32_Store, "__builtin_ia32_storedqu");
procedure Print (Map : in Matrix; Name : in String) is
begin
Put_Line(Name);
for I in Bound_Low .. Bound_High loop
for J in Bound_Low .. Bound_High loop
Put(Pile'Image(Map(I)(J)));
end loop;
New_Line(1);
end loop;
Put_Line("------------");
end;
function Topple (Base : in Matrix_Pointer) return Boolean is
type Mod_64 is mod 2**64;
type Mod_64_Array is array (0..1) of aliased Mod_64;
type Mod_64_Pointer is access all Mod_64;
function ia32_Load (X : Mod_64_Pointer) return m128i with Inline;
pragma Import (Intrinsic, ia32_Load, "__builtin_ia32_loaddqu");
function Move is new Ada.Unchecked_Conversion (Source=>Mod_64, Target=>Matrix_Sub_Row);
function Move is new Ada.Unchecked_Conversion (Source=>Matrix_Sub_Row, Target=>Mod_64);
Changed : Boolean := False;
Local_Bound_High : constant Matrix_Range := Bound_High;
Local_Bound_Low : constant Matrix_Range := Bound_Low;
I : Matrix_Range := Bound_Low;
Temp_Values : Mod_64_Array;
begin
while I <= Local_Bound_High loop
declare
J : Matrix_Range := Local_Bound_Low - (Local_Bound_Low mod 16);
Temp : m128i;
Sum_m128i_Buffer : m128i;
Upper_Sum_m128i_Buffer : m128i;
Lower_Sum_m128i_Buffer : m128i;
begin
while J <= Local_Bound_High loop
Temp_Values(0) := (Move(Base(I)(J..J+7)) / 2**2) AND 16#0F0F0F0F0F0F0F0F#;
Temp_Values(1) := (Move(Base(I)(J+8..J+15)) / 2**2) AND 16#0F0F0F0F0F0F0F0F#;
if (Temp_Values(0) OR Temp_Values(1)) /= 0 then
Changed := True;
if I - 1 < Bound_Low then
Bound_Low := Bound_Low - 1;
Bound_High := Bound_High + 1;
end if;
Temp := ia32_Load(Temp_Values(0)'Access);
Upper_Sum_m128i_Buffer := ia32_Load(Base(I-1)(J)'Access);
ia32_Store(Base(I-1)(J)'Access, ia32_Add(Upper_Sum_m128i_Buffer, Temp));
Lower_Sum_m128i_Buffer := ia32_Load(Base(I+1)(J)'Access);
ia32_Store(Base(I+1)(J)'Access, ia32_Add(Lower_Sum_m128i_Buffer, Temp));
Sum_m128i_Buffer := ia32_Load(Base(I)(J-1)'Access);
ia32_Store(Base(I)(J-1)'Access, ia32_Add(Sum_m128i_Buffer, Temp));
Sum_m128i_Buffer := ia32_Load(Base(I)(J+1)'Access);
ia32_Store(Base(I)(J+1)'Access, ia32_Add(Sum_m128i_Buffer, Temp));
Base(I)(J..J+7) := Move(Move(Base(I)(J..J+7)) - (Temp_Values(0) * 4));
Base(I)(J+8..J+15) := Move(Move(Base(I)(J+8..J+15)) - (Temp_Values(1) * 4));
end if;
J := J + 16;
end loop;
end;
I := I + 1;
end loop;
return Changed;
end Topple;
function Drip (Value : in out Natural) return Pile with Inline is
begin
if Value /= 0 then
Value := Value - 4;
return 4;
else
return 0;
end if;
end Drip;
procedure Color (Item : in Matrix) with Import, Convention=>C, Link_Name=>"color_map";
----------------------------------------------------------------------
Base_Matrix : constant Matrix_Pointer := new Matrix'(others=>(others=>0));
Input_Sand_Stream : Natural := Natural'Value(Argument(1));
Center : constant Matrix_Range := Matrix_Range'Last/2;
begin
if Input_Sand_Stream mod 4 /= 0 then
raise Constraint_Error with "Input should be multiple for 4";
end if;
if Matrix_Size mod 16 /= 0 then
raise Constraint_Error with "Compiled with a bad matrix size";
end if;
if Natural(Matrix_Size**2 * 1.5) < Input_Sand_Stream then
raise Constraint_Error with "Optimazation accounting for an infinite plane makes that input dangerous";
end if;
Bound_High := Center;
Bound_Low := Center;
Base_Matrix(Center)(Center) := Base_Matrix(Center)(Center) + Drip(Input_Sand_Stream);
declare
use type Ada.Real_Time.Time;
Start_Time :constant Ada.Real_Time.Time := Ada.Real_Time.Clock;
End_Time : Ada.Real_Time.Time;
begin
while Topple(Base_Matrix) loop
if Input_Sand_Stream mod 2048 = 0 then
Put_Line(Natural'Image(Input_Sand_Stream));
Put_Line(Matrix_Range'Image(Bound_High));
Put_Line(Matrix_Range'Image(Bound_Low));
end if;
if Base_Matrix(Center)(Center) < 4 then
Base_Matrix(Center)(Center) := Base_Matrix(Center)(Center) + Drip(Input_Sand_Stream);
end if;
end loop;
End_Time := Ada.Real_Time.Clock;
Put_Line(Duration'Image(Ada.Real_Time.To_Duration(End_Time-Start_Time)));
Put_Line("Printing...");
end;
Color(Base_Matrix.all);
end Main;
|
pragma License (Unrestricted);
-- implementation unit required by compiler
package System.Wid_Char is
pragma Pure;
-- required for Character'Width by compiler (s-widboo.ads)
function Width_Character (Lo, Hi : Character) return Natural;
-- compiler return 12 ("Reserved_153") for statically character types
end System.Wid_Char;
|
-- This is the main Asis_Tool_2 class.
private with Asis_Tool_2.Context;
private with Dot;
with A_Nodes;
with a_nodes_h;
package Asis_Tool_2.Tool is
type Class is tagged limited private;
-- Runs in the current directory.
-- Uses project file "default.gpr" in containing directory of File_Name.
-- Creates .adt file in project file Object_Dir.
-- Creates .dot file in Output_Dir. If Output_Dir = "", uses current directory.
--
-- LEAKS. Only intended to be called once per program execution:
procedure Process
(This : in out Class;
File_Name : in String;
Output_Dir : in String := "";
GNAT_Home : in String;
Debug : in Boolean);
-- Call Process first:
function Get_Nodes
(This : in out Class)
return a_nodes_h.Nodes_Struct;
private
type Class is tagged limited -- Initialized
record
My_Context : Asis_Tool_2.Context.Class; -- Initialized
Outputs : Outputs_Record; -- Initialized
end record;
end Asis_Tool_2.Tool;
|
---------------------------------------------------------------------------------
-- Copyright 2004-2005 © Luke A. Guest
--
-- This code is to be used for tutorial purposes only.
-- You may not redistribute this code in any form without my express permission.
---------------------------------------------------------------------------------
package body Plane is
function CreateX return Object is
begin
return Object'(Vector3.Object'(1.0, 0.0, 0.0), 0.0);
end CreateX;
function CreateY return Object is
begin
return Object'(Vector3.Object'(0.0, 1.0, 0.0), 0.0);
end CreateY;
function CreateZ return Object is
begin
return Object'(Vector3.Object'(0.0, 0.0, 1.0), 0.0);
end CreateZ;
function Create(V : in Vector3.Object; D : in Float) return Object is
begin
return Object'(V, D);
end Create;
end Plane;
|
with agar.gui.widget.button;
with agar.gui.widget.toolbar;
with agar.gui.window;
with agar.core.event;
with agar.core.slist;
with agar.core.timeout;
package agar.gui.widget.menu is
use type c.unsigned;
-- forward declarations
type item_t;
type item_access_t is access all item_t;
pragma convention (c, item_access_t);
type menu_t;
type menu_access_t is access all menu_t;
pragma convention (c, menu_access_t);
type popup_menu_t;
type popup_menu_access_t is access all popup_menu_t;
pragma convention (c, popup_menu_access_t);
type view_t;
type view_access_t is access all view_t;
pragma convention (c, view_access_t);
package menu_slist is new agar.core.slist
(entry_type => menu_access_t);
-- types
type binding_t is (
MENU_NO_BINDING,
MENU_INT_BOOL,
MENU_INT8_BOOL,
MENU_INT_FLAGS,
MENU_INT8_FLAGS,
MENU_INT16_FLAGS,
MENU_INT32_FLAGS
);
for binding_t use (
MENU_NO_BINDING => 0,
MENU_INT_BOOL => 1,
MENU_INT8_BOOL => 2,
MENU_INT_FLAGS => 3,
MENU_INT8_FLAGS => 4,
MENU_INT16_FLAGS => 5,
MENU_INT32_FLAGS => 6
);
for binding_t'size use c.unsigned'size;
pragma convention (c, binding_t);
subtype mask_t is c.unsigned;
subtype mask8_t is agar.core.types.uint8_t;
subtype mask16_t is agar.core.types.uint16_t;
subtype mask32_t is agar.core.types.uint32_t;
type state_t is (FROM_BINDING, DISABLED, ENABLED);
for state_t use
(FROM_BINDING => -1,
DISABLED => 0,
ENABLED => 1);
for state_t'size use c.unsigned'size;
pragma convention (c, state_t);
subtype item_flags_t is c.unsigned;
ITEM_ICONS : constant item_flags_t := 16#01#;
ITEM_NOSELECT : constant item_flags_t := 16#02#;
ITEM_SEPARATOR : constant item_flags_t := 16#04#;
type item_t is record
text : cs.chars_ptr;
label_enabled : c.int;
label_disabled : c.int;
icon : c.int;
icon_source : agar.gui.surface.surface_access_t;
value : c.int;
state : c.int;
key_equiv : c.int;
key_mod : c.int;
x : c.int;
y : c.int;
subitems : item_access_t;
nsubitems : c.unsigned;
click_func : access agar.core.event.event_t;
poll : access agar.core.event.event_t;
flags : item_flags_t;
bind_type : binding_t;
bind_ptr : agar.core.types.void_ptr_t;
bind_flags : agar.core.types.uint32_t;
bind_invert : c.int;
bind_lock : agar.core.threads.mutex_t;
view : view_access_t;
parent : menu_access_t;
parent_item : item_access_t;
selected_subitem : item_access_t;
toolbar_button : agar.gui.widget.button.button_access_t;
end record;
pragma convention (c, item_t);
subtype menu_flags_t is c.unsigned;
MENU_HFILL : constant menu_flags_t := 16#01#;
MENU_VFILL : constant menu_flags_t := 16#02#;
MENU_EXPAND : constant menu_flags_t := MENU_HFILL or MENU_VFILL;
MENU_GLOBAL : constant menu_flags_t := 16#04#;
type menu_t is record
widget : aliased widget_t;
flags : menu_flags_t;
root : item_access_t;
selecting : c.int;
item_selected : item_access_t;
spacing_horizontal : c.int;
spacing_vertical : c.int;
pad_left : c.int;
pad_right : c.int;
pad_top : c.int;
pad_bottom : c.int;
label_pad_left : c.int;
label_pad_right : c.int;
label_pad_top : c.int;
label_pad_bottom : c.int;
height : c.int;
current_state : c.int;
current_toolbar : agar.gui.widget.toolbar.toolbar_access_t;
r : agar.gui.rect.rect_t;
end record;
pragma convention (c, menu_t);
type popup_menu_t is record
menu : menu_access_t;
item : item_access_t;
window : agar.gui.window.window_access_t;
menus : menu_slist.entry_t;
end record;
pragma convention (c, popup_menu_t);
type view_t is record
widget : aliased widget_t;
panel : agar.gui.window.window_access_t;
panel_menu : menu_access_t;
panel_item : item_access_t;
icon_label_spacing : c.int;
label_arrow_spacing : c.int;
pad_left : c.int;
pad_right : c.int;
pad_top : c.int;
pad_bottom : c.int;
submenu_to : agar.core.timeout.timeout_t;
end record;
pragma convention (c, view_t);
--
function allocate
(widget : widget_access_t;
flags : flags_t) return menu_access_t;
pragma import (c, allocate, "AG_MenuNew");
function allocate_global (flags : flags_t) return menu_access_t;
pragma import (c, allocate_global, "AG_MenuNewGlobal");
procedure expand
(menu : menu_access_t;
item : item_access_t;
x : natural;
y : natural);
pragma inline (expand);
procedure collapse
(menu : menu_access_t;
item : item_access_t);
pragma import (c, collapse, "AG_MenuCollapse");
procedure set_padding
(menu : menu_access_t;
left : natural;
right : natural;
top : natural;
bottom : natural);
pragma inline (set_padding);
procedure set_label_padding
(menu : menu_access_t;
left : natural;
right : natural;
top : natural;
bottom : natural);
pragma inline (set_label_padding);
-- menu items
function node
(parent : item_access_t;
text : string;
icon : agar.gui.surface.surface_access_t) return item_access_t;
pragma inline (node);
function action
(parent : item_access_t;
text : string;
icon : agar.gui.surface.surface_access_t;
func : agar.core.event.callback_t) return item_access_t;
pragma inline (action);
function action_keyboard
(parent : item_access_t;
text : string;
icon : agar.gui.surface.surface_access_t;
key : c.int;
modkey : c.int;
func : agar.core.event.callback_t) return item_access_t;
pragma inline (action_keyboard);
function dynamic_item
(parent : item_access_t;
text : string;
icon : agar.gui.surface.surface_access_t;
func : agar.core.event.callback_t) return item_access_t;
pragma inline (dynamic_item);
function dynamic_item_keyboard
(parent : item_access_t;
text : string;
icon : agar.gui.surface.surface_access_t;
key : c.int;
modkey : c.int;
func : agar.core.event.callback_t) return item_access_t;
pragma inline (dynamic_item_keyboard);
function toolbar_item
(parent : item_access_t;
toolbar : agar.gui.widget.toolbar.toolbar_access_t;
text : string;
icon : agar.gui.surface.surface_access_t;
key : c.int;
modkey : c.int;
func : agar.core.event.callback_t) return item_access_t;
pragma inline (toolbar_item);
procedure set_icon
(item : item_access_t;
surface : agar.gui.surface.surface_access_t);
pragma import (c, set_icon, "AG_MenuSetIcon");
procedure set_label
(item : item_access_t;
label : string);
pragma inline (set_label);
procedure set_poll_function
(item : item_access_t;
func : agar.core.event.callback_t);
pragma inline (set_poll_function);
procedure deallocate_item (item : item_access_t);
pragma import (c, deallocate_item, "AG_MenuItemFree");
procedure item_state
(item : item_access_t;
state : state_t);
pragma import (c, item_state, "AG_MenuState");
procedure enable (item : item_access_t);
pragma import (c, enable, "AG_MenuEnable");
procedure disable (item : item_access_t);
pragma import (c, disable, "AG_MenuDisable");
-- boolean and bitmask items
function bind_bool
(item : item_access_t;
text : string;
icon : agar.gui.surface.surface_access_t;
value : access boolean;
invert : boolean) return item_access_t;
pragma inline (bind_bool);
function bind_bool_with_mutex
(item : item_access_t;
text : string;
icon : agar.gui.surface.surface_access_t;
value : access boolean;
invert : boolean;
mutex : agar.core.threads.mutex_t) return item_access_t;
pragma inline (bind_bool_with_mutex);
function bind_flags
(item : item_access_t;
text : string;
icon : agar.gui.surface.surface_access_t;
value : access mask_t;
flags : mask_t;
invert : boolean) return item_access_t;
pragma inline (bind_flags);
function bind_flags_with_mutex
(item : item_access_t;
text : string;
icon : agar.gui.surface.surface_access_t;
value : access mask_t;
flags : mask_t;
invert : boolean;
mutex : agar.core.threads.mutex_t) return item_access_t;
pragma inline (bind_flags_with_mutex);
function bind_flags8
(item : item_access_t;
text : string;
icon : agar.gui.surface.surface_access_t;
value : access mask8_t;
flags : mask8_t;
invert : boolean) return item_access_t;
pragma inline (bind_flags8);
function bind_flags8_with_mutex
(item : item_access_t;
text : string;
icon : agar.gui.surface.surface_access_t;
value : access mask8_t;
flags : mask8_t;
invert : boolean;
mutex : agar.core.threads.mutex_t) return item_access_t;
pragma inline (bind_flags8_with_mutex);
function bind_flags16
(item : item_access_t;
text : string;
icon : agar.gui.surface.surface_access_t;
value : access mask16_t;
flags : mask16_t;
invert : boolean) return item_access_t;
pragma inline (bind_flags16);
function bind_flags16_with_mutex
(item : item_access_t;
text : string;
icon : agar.gui.surface.surface_access_t;
value : access mask16_t;
flags : mask16_t;
invert : boolean;
mutex : agar.core.threads.mutex_t) return item_access_t;
pragma inline (bind_flags16_with_mutex);
function bind_flags32
(item : item_access_t;
text : string;
icon : agar.gui.surface.surface_access_t;
value : access mask32_t;
flags : mask32_t;
invert : boolean) return item_access_t;
pragma inline (bind_flags32);
function bind_flags32_with_mutex
(item : item_access_t;
text : string;
icon : agar.gui.surface.surface_access_t;
value : access mask32_t;
flags : mask32_t;
invert : boolean;
mutex : agar.core.threads.mutex_t) return item_access_t;
pragma inline (bind_flags32_with_mutex);
-- other items
procedure separator (item : item_access_t);
pragma import (c, separator, "AG_MenuSeparator");
procedure section
(item : item_access_t;
text : string);
pragma inline (section);
-- popup menus
package popup is
function allocate (widget : widget_access_t) return popup_menu_access_t;
pragma import (c, allocate, "AG_PopupNew");
procedure show_at
(menu : popup_menu_access_t;
x : natural;
y : natural);
pragma inline (show_at);
procedure hide (menu : popup_menu_access_t);
pragma import (c, hide, "AG_PopupHide");
procedure destroy
(widget : widget_access_t;
menu : popup_menu_access_t);
pragma import (c, destroy, "AG_PopupDestroy");
end popup;
-- widget casts
function widget (menu : menu_access_t) return widget_access_t;
pragma inline (widget);
function widget (view : view_access_t) return widget_access_t;
pragma inline (widget);
end agar.gui.widget.menu;
|
with
AdaM.a_Pragma,
gtk.Widget;
private
with
aIDE.Editor.of_block,
aIDE.Editor.of_context,
gtk.Box,
gtk.Button,
gtk.Frame,
gtk.Label,
gtk.Alignment,
gtk.GEntry;
package aIDE.Editor.of_pragma
is
type Item is new Editor.item with private;
type View is access all Item'Class;
package Forge
is
function new_Editor (the_Pragma : in AdaM.a_Pragma.view) return View;
end Forge;
overriding
function top_Widget (Self : in Item) return gtk.Widget.Gtk_Widget;
function Target (Self : in Item) return AdaM.a_Pragma.view;
procedure Target_is (Self : in out Item; Now : in AdaM.a_Pragma.view);
private
use gtk.Box,
gtk.GEntry,
gtk.Frame,
gtk.Label,
gtk.Button,
gtk.Alignment;
type Item is new Editor.item with
record
Target : AdaM.a_Pragma.view;
top_Frame : Gtk_Frame;
top_Box : Gtk_Box;
arguments_Box : Gtk_Box;
-- context_Alignment : Gtk_Alignment;
-- context_Editor : aIDE.Editor.of_context.view;
open_parenthesis_Label : Gtk_Label;
close_parenthesis_Label : Gtk_Label;
-- name_Entry : gtk_Entry;
choose_Button : gtk_Button;
-- block_Alignment : Gtk_Alignment;
-- block_Editor : aIDE.Editor.of_block.view;
end record;
overriding
procedure freshen (Self : in out Item);
end aIDE.Editor.of_pragma;
|
-- Copyright (c) 2021 Bartek thindil Jasicki <thindil@laeran.pl>
--
-- Licensed under the Apache License, Version 2.0 (the "License");
-- you may not use this file except in compliance with the License.
-- You may obtain a copy of the License at
--
-- http://www.apache.org/licenses/LICENSE-2.0
--
-- Unless required by applicable law or agreed to in writing, software
-- distributed under the License is distributed on an "AS IS" BASIS,
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-- See the License for the specific language governing permissions and
-- limitations under the License.
with Ada.Strings.Unbounded; use Ada.Strings.Unbounded;
with Tk.Widget; use Tk.Widget;
with Tcl.Strings; use Tcl.Strings;
-- ****h* Tk/TtkWidget
-- FUNCTION
-- Provide code for manipulate Ttk widgets. Parent of the all Ttk widgets.
-- SOURCE
package Tk.TtkWidget is
-- ****
--## rule off REDUCEABLE_SCOPE
-- ****t* TtkWidget/TtkWidget.Ttk_Widget
-- FUNCTION
-- The identifier of the Ttk Widget
-- HISTORY
-- 8.6.0 - Added
-- SOURCE
subtype Ttk_Widget is Tk_Widget;
-- ****
--## rule off TYPE_INITIAL_VALUES
-- ****s* TtkWidget/TtkWidget.Ttk_Widget_Options
-- FUNCTION
-- Abstract records to store available options and their values for widgets.
-- All Ttk widgets options should be children of this record
-- OPTIONS
-- Class - The class of the widget. Used to query for the widget options
-- and default binding tags for the widget
-- Style - The name of the style used by the widget
-- HISTORY
-- 8.6.0 - Added
-- SOURCE
type Ttk_Widget_Options is abstract new Widget_Options with record
Class: Tcl_String := Null_Tcl_String;
Style: Tcl_String := Null_Tcl_String;
end record;
-- ****
--## rule on TYPE_INITIAL_VALUES
-- ****t* TtkWidget/TtkWidget.Ttk_State_Type
-- FUNCTION
-- Type used to set the current state of the selected Ttk widget
-- OPTIONS
-- ACTIVE - Mouse cursor is above the widget, aka hover state
-- DISABLED - The widget is disabled aka inactive state
-- FOCUS - The widget has keyboard focus
-- PRESSED - The widget is being pressed
-- SELECTED - The widget (checkbuttons or radiobuttons) is on, selected
-- BACKGROUND - The widget is in background state (Windows and Mac only)
-- READONLY - The widget can't be modified by the user
-- ALTERNATE - The widget specific alternate display format. For example,
-- checkbuttons with mixed or tristate state
-- INVALID - The widget value is invalid (mostly entries and scales)
-- HOVER - Mouse cursor is above the widget, similar to ACTIVE state
-- HISTORY
-- 8.6.0 - Added
-- SOURCE
type Ttk_State_Type is
(ACTIVE, DISABLED, FOCUS, PRESSED, SELECTED, BACKGROUND, READONLY,
ALTERNATE, INVALID, HOVER) with
Default_Value => ACTIVE;
-- ****
-- ****d* TtkWidget/TtkWidget.Default_Ttk_State
-- FUNCTION
-- Default Ttk_State_Type value
-- HISTORY
-- 8.6.0 - Added
-- SOURCE
Default_Ttk_State: constant Ttk_State_Type := ACTIVE;
-- ****
--## rule off TYPE_INITIAL_VALUES
-- ****t* TtkWidget/TtkWidget.Ttk_State_Array
-- FUNCTION
-- Array of Ttk_State_Type. Used mostly in taking information about the
-- state of the selecte Ttk widget
-- HISTORY
-- 8.6.0 - Added
-- SOURCE
type Ttk_State_Array is array(Positive range <>) of Ttk_State_Type with
Default_Component_Value => Default_Ttk_State;
-- ****
--## rule on TYPE_INITIAL_VALUES
-- ****t* TtkWidget/TtkWidget.Compound_Type
-- FUNCTION
-- Type of possible place directions for text and image on the Ttk
-- widgets
-- OPTIONS
-- EMPTY - Used only during setting the widget configuration. Use the
-- default setting for the selected widget
-- NONE - The default, display image if present, otherwise text
-- BOTTOM - Display image below text
-- TOP - Display image above text
-- LEFT - Display image on the right from text
-- RIGHT - Display image on the left from text
-- CENTER - Display text on top of image
-- TEXT - Display text only
-- IMAGE - Display image only
-- HISTORY
-- 8.6.0 - Added
-- SOURCE
type Compound_Type is
(EMPTY, NONE, BOTTOM, TOP, LEFT, RIGHT, CENTER, TEXT, IMAGE) with
Default_Value => EMPTY;
-- ****
-- ****d* TtkWidget/TtkWidget.Default_Compound_Type
-- FUNCTION
-- Default value for Compound_Type
-- HISTORY
-- 8.6.0 - Added
-- SOURCE
Default_Compound_Type: constant Compound_Type := EMPTY;
-- ****
-- ****t* TtkWidget/TtkWidget.Disabled_State_Type
-- FUNCTION
-- Type used to set disabled bit of the Ttk widgets for compatybility
-- with old Tk widgets
-- OPTIONS
-- NORMAL - The widget is not disabled
-- DISABLED - The widget is disabled
-- NONE - Used only in configuring the widget, to set default state
-- HISTORY
-- 8.6.0 - Added
-- SOURCE
type Disabled_State_Type is (NORMAL, DISABLED, NONE) with
Default_Value => NONE;
-- ****
-- ****d* TtkWidget/TtkWidget.Default_Disabled_State
-- FUNCTION
-- Default value for Disabled_State_Type
-- HISTORY
-- 8.6.0 - Added
-- SOURCE
Default_Disabled_State: constant Disabled_State_Type := NONE;
-- ****
-- ****s* TtkWidget/TtkWidget.Ttk_Image_Option
-- FUNCTION
-- Used to store configuration of images used by the selected Ttk_Widget
-- OPTIONS
-- Default - The default image, used when no other specified for other
-- states
-- Active - The image used when widget is in active state
-- Disabled - The image used when widget is in disabled state
-- Focus - The image used when widget is in focus state
-- Pressed - The image used when widget is in pressed state
-- Selected - The image used when widget is in selected state
-- Background - The image used when widget is in background state
-- Readonly - The image used when widget is in readonly state
-- Alternate - The image used when widget is in alternate state
-- Invalid - The image used when widget is in invalid state
-- Hover - The image used when widget is in hover state
-- HISTORY
-- 8.6.0 - Added
-- SOURCE
type Ttk_Image_Option is record
Default: Tcl_String;
Active: Tcl_String;
Disabled: Tcl_String;
Focus: Tcl_String;
Pressed: Tcl_String;
Selected: Tcl_String;
Background: Tcl_String;
Readonly: Tcl_String;
Alternate: Tcl_String;
Invalid: Tcl_String;
Hover: Tcl_String;
end record;
-- ****
-- ****d* TtkWidget/TtkWidget.Default_Ttk_Image_Option
-- FUNCTION
-- Default value for Ttk_Image_Option
-- HISTORY
-- 8.6.0 - Added
-- SOURCE
Default_Ttk_Image_Option: constant Ttk_Image_Option :=
(others => Null_Tcl_String);
-- ****
-- ****s* TtkWidget/TtkWidget.Padding_Data
-- FUNCTION
-- Store padding information for ttk widgets
-- OPTIONS
-- Left - Free space added at the left side of the widget
-- Top - Free space added at the top of the widget
-- Right - Free space added at the right side of the widget
-- Bottom - Free space added at the bottom of the widget
-- HISTORY
-- 8.6.0 - Added
-- SOURCE
type Padding_Data is record
Left: Pixel_Data := Empty_Pixel_Data;
Top: Pixel_Data := Empty_Pixel_Data;
Right: Pixel_Data := Empty_Pixel_Data;
Bottom: Pixel_Data := Empty_Pixel_Data;
end record;
-- ****
-- ****d* TtkWidget/TtkWidget.Empty_Padding_Data
-- FUNCTION
-- Empty value for Padding_Data
-- HISTORY
-- 8.6.0 - Added
-- SOURCE
Empty_Padding_Data: constant Padding_Data := Padding_Data'(others => <>);
-- ****
-- ****f* TtkWidget/TtkWidget.Option_Image
-- FUNCTION
-- Allow to convert the selected widget's option to Unbounded_String
-- which can be used in creating or configuring the widget.
-- PARAMETERS
-- Name - The name of the selected widget's option
-- Value - The value of the selected widget's option which will
-- be converted to Unbounded_String
-- Options_String - String with currently set options for the selected
-- widget
-- OUTPUT
-- If Value has default value for the selected type, then return
-- unmodified Options_String. Otherwise append the proper Tk
-- configuration option to the Options_String.
-- HISTORY
-- 8.6.0 - Added
-- EXAMPLE
-- -- Set the text option to hello world in My_Options string
-- declare
-- My_Options: Unbounded_String;
-- begin
-- Option_Image("compound", BOTTOM, My_Options);
-- end;
-- SOURCE
procedure Option_Image
(Name: String; Value: Compound_Type;
Options_String: in out Unbounded_String) with
Pre => Name'Length > 0,
Test_Case => (Name => "Test_Option_Image_Compound_Type",
Mode => Nominal);
procedure Option_Image
(Name: String; Value: Disabled_State_Type;
Options_String: in out Unbounded_String) with
Pre => Name'Length > 0,
Test_Case => (Name => "Test_Option_Image_Distabled_State_Type",
Mode => Nominal);
procedure Option_Image
(Name: String; Value: Ttk_Image_Option;
Options_String: in out Unbounded_String) with
Pre => Name'Length > 0,
Test_Case => (Name => "Test_Option_Image_Image_Option", Mode => Nominal);
procedure Option_Image
(Name: String; Value: Padding_Data;
Options_String: in out Unbounded_String) with
Pre => Name'Length > 0,
Test_Case => (Name => "Test_Option_Image_Padding_Data", Mode => Nominal);
-- ****
-- ****f* TtkWidget/TtkWidget.Option_Value
-- FUNCTION
-- Allow convert the selected widget's option from Tcl string value to
-- proper Widget_Options field value. It is mostly used in the widgets
-- Get_Options funcion
-- PARAMETERS
-- Widget - Tk_Widget which option will be get
-- Name - The name of the option to get
-- RESULT
-- Tcl string value converted to the proper Ada binding type
-- HISTORY
-- 8.6.0 - Added
-- EXAMPLE
-- -- Get the value of option state in My_Button widget
-- Button_State: constant Disabled_State_Type := Option_Value(My_Button, "state");
-- SOURCE
function Option_Value
(Ttk_Widgt: Ttk_Widget; Name: String) return Compound_Type with
Pre => Ttk_Widgt /= Null_Widget and Name'Length > 0,
Test_Case => (Name => "Test_Option_Value_Compound_Type",
Mode => Nominal);
function Option_Value
(Ttk_Widgt: Ttk_Widget; Name: String) return Disabled_State_Type with
Pre => Ttk_Widgt /= Null_Widget and Name'Length > 0,
Test_Case => (Name => "Test_Option_Value_Disabled_State_Type",
Mode => Nominal);
function Option_Value
(Ttk_Widgt: Ttk_Widget; Name: String) return Ttk_Image_Option with
Pre => Ttk_Widgt /= Null_Widget and Name'Length > 0,
Test_Case => (Name => "Test_Option_Value_Ttk_Image_Option",
Mode => Nominal);
function Option_Value
(Ttk_Widgt: Ttk_Widget; Name: String) return Padding_Data with
Pre => Ttk_Widgt /= Null_Widget and Name'Length > 0,
Test_Case => (Name => "Test_Option_Value_Padding_Data", Mode => Nominal);
-- ****
-- ****f* TtkWidget/TtkWidget.In_State_(function)
-- FUNCTION
-- Check if the selected Ttk widget is in the selected state
-- PARAMETERS
-- Widget - The Ttk widget which state will be tested
-- State_Ttk - Ttk_State to check
-- RESULT
-- True if the selected Ttk widget is in the selected state, otherwise
-- False
-- HISTORY
-- 8.6.0 - Added
-- EXAMPLE
-- -- Check if the Ttk widget My_Button is disabled
-- Is_Disabled: constant Boolean := In_State(My_Button, DISABLED);
-- SEE ALSO
-- TtkWidget.In_State_(procedure)
-- COMMANDS
-- Widget instate State
-- SOURCE
function In_State
(Ttk_Widgt: Ttk_Widget; State_Ttk: Ttk_State_Type) return Boolean with
Pre => Ttk_Widgt /= Null_Widget,
Test_Case => (Name => "Test_Ttk_Widget_In_State", Mode => Nominal);
-- ****
-- ****f* TtkWidget/TtkWidget.In_State(procedure)
-- FUNCTION
-- Check if the selected Ttk widget is in the selected state. If is,
-- then execute the selected Tcl commands
-- PARAMETERS
-- Widget - The Ttk widget which state will be checked
-- State_Type - Ttk_State to check
-- Tcl_Script - The Tcl commands which will be executed if the widget
-- is in the selected state
-- HISTORY
-- 8.6.0 - Added
-- EXAMPLE
-- -- Exit the program if My_Entry Ttk widget is disabled
-- In_State(My_Entry, DISABLED, To_Tcl_String("exit"));
-- SEE ALSO
-- TtkWidget.In_State_(function)
-- COMMANDS
-- Widget instate State Tcl_Script
-- SOURCE
procedure In_State
(Ttk_Widgt: Ttk_Widget; State_Type: Ttk_State_Type;
Tcl_Script: Tcl_String) with
Pre => Ttk_Widgt /= Null_Widget and Length(Source => Tcl_Script) > 0,
Test_Case => (Name => "Test_Ttk_Widget_In_State2", Mode => Nominal);
-- ****
-- ****f* TtkWidget/TtkWidget.Set_State
-- FUNCTION
-- Set the selected state for the selected Ttk widget
-- PARAMETERS
-- Widget - The Ttk widget which state will be changed
-- Widget_State - The selected state to set or unset
-- Disable - If True, disable the selected State. Otherwise enable
-- it for the selected Widget. Default value is False.
-- HISTORY
-- 8.6.0 - Added
-- EXAMPLE
-- -- Enable Ttk widget My_Button
-- Set_State(My_Button, DISABLED, True);
-- SEE ALSO
-- TtkWidget.Get_States
-- COMMANDS
-- Widget state State
-- SOURCE
procedure Set_State
(Ttk_Widgt: Ttk_Widget; Widget_State: Ttk_State_Type;
Disable: Boolean := False) with
Pre => Ttk_Widgt /= Null_Widget,
Test_Case => (Name => "Test_Ttk_Widget_State", Mode => Nominal);
-- ****
-- ****f* TtkWidget/Ttk_Widget.Get_States
-- FUNCTION
-- Get the states of the selected Ttk widget
-- PARAMETERS
-- Widget - The Ttk widget which states will be taken
-- RESULT
-- Ttk_State_Array with all states currently set for the selected Widget
-- HISTORY
-- 8.6.0 - Added
-- EXAMPLE
-- -- Get the states of Ttk widget My_Button
-- States: constant Ttk_State_Array := Get_States(My_Button);
-- SEE ALSO
-- TtkWidget.Set_State
-- COMMANDS
-- Widget state
-- SOURCE
function Get_States(Ttk_Widgt: Ttk_Widget) return Ttk_State_Array with
Pre => Ttk_Widgt /= Null_Widget,
Test_Case => (Name => "Test_Ttk_Widget_State2", Mode => Nominal);
-- ****
--## rule on REDUCEABLE_SCOPE
end Tk.TtkWidget;
|
-----------------------------------------------------------------------
-- awa-mail-components-recipients -- Mail UI Recipients
-- 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 Util.Beans.Objects;
package body AWA.Mail.Components.Recipients is
-- ------------------------------
-- Set the recipient type.
-- ------------------------------
procedure Set_Recipient (UI : in out UIMailRecipient;
Recipient : in AWA.Mail.Clients.Recipient_Type) is
begin
UI.Recipient := Recipient;
end Set_Recipient;
-- ------------------------------
-- Get the mail name.
-- ------------------------------
function Get_Name (UI : in UIMailRecipient;
Context : in ASF.Contexts.Faces.Faces_Context'Class) return String is
Name : constant Util.Beans.Objects.Object := UI.Get_Attribute (Context, "name");
begin
if Util.Beans.Objects.Is_Null (Name) then
return "";
else
return Util.Beans.Objects.To_String (Name);
end if;
end Get_Name;
-- ------------------------------
-- Get the mail address.
-- ------------------------------
function Get_Address (UI : in UIMailRecipient;
Context : in ASF.Contexts.Faces.Faces_Context'Class) return String is
Addr : constant Util.Beans.Objects.Object := UI.Get_Attribute (Context, "address");
begin
if Util.Beans.Objects.Is_Null (Addr) then
return "";
else
return Util.Beans.Objects.To_String (Addr);
end if;
end Get_Address;
-- ------------------------------
-- Render the children components to obtain an email address and set the TO/CC/BCC address
-- of the message with the result.
-- ------------------------------
overriding
procedure Encode_Children (UI : in UIMailRecipient;
Context : in out ASF.Contexts.Faces.Faces_Context'Class) is
procedure Process (Content : in String);
procedure Process (Content : in String) is
Msg : constant AWA.Mail.Clients.Mail_Message_Access := UI.Get_Message;
Name : constant String := UI.Get_Name (Context);
begin
if Content'Length > 0 then
Msg.Add_Recipient (Kind => UI.Recipient,
Name => Name,
Address => Content);
else
Msg.Add_Recipient (Kind => UI.Recipient,
Name => Name,
Address => UI.Get_Address (Context));
end if;
end Process;
begin
UI.Wrap_Encode_Children (Context, Process'Access);
end Encode_Children;
-- ------------------------------
-- Render the children components to obtain an email address and set the From address
-- of the message with the result.
-- ------------------------------
overriding
procedure Encode_Children (UI : in UISender;
Context : in out ASF.Contexts.Faces.Faces_Context'Class) is
procedure Process (Content : in String);
procedure Process (Content : in String) is
Msg : constant AWA.Mail.Clients.Mail_Message_Access := UI.Get_Message;
Name : constant String := UI.Get_Name (Context);
begin
if Content'Length > 0 then
Msg.Set_From (Name => Name,
Address => Content);
else
Msg.Set_From (Name => Name,
Address => UI.Get_Address (Context));
end if;
end Process;
begin
UI.Wrap_Encode_Children (Context, Process'Access);
end Encode_Children;
end AWA.Mail.Components.Recipients;
|
-- { dg-do compile }
-- { dg-options "-w" }
package body Vect8 is
function Foo (V : Vec) return Vec is
Ret : Vec;
begin
Ret (1) := V (1) + V (2);
Ret (2) := V (1) - V (2);
return Ret;
end;
end Vect8;
|
with System;
-- =============================================================================
-- Package AVR.MCU
--
-- Maps AVR micro-controllers.
-- =============================================================================
package AVR.MCU is
F_CPU : constant := 16_000_000;
#if MCU="ATMEGA2560" then
type On_Chip_Debug_Register_Type is
record
LSB : Boolean;
Spare : Spare_Type (0 .. 5);
MSB_IDRD : Boolean;
end record;
pragma Pack (On_Chip_Debug_Register_Type);
for On_Chip_Debug_Register_Type'Size use BYTE_SIZE;
#end if;
type MCU_Status_Register_Type is
record
PORF : Boolean; -- Power-on Reset Flag
EXTRF : Boolean; -- External Reset Flag
BORF : Boolean; -- Brown-out Reset Flag
WDRF : Boolean; -- Watchdog Reset Flag
#if MCU="ATMEGA2560" then
JTRF : Boolean; -- JTAG Reset Flag
Spare : Spare_Type (0 .. 2);
#elsif MCU="ATMEGA328P" then
Spare : Spare_Type (0 .. 3);
#end if;
end record;
pragma Pack (MCU_Status_Register_Type);
for MCU_Status_Register_Type'Size use BYTE_SIZE;
type MCU_Control_Register_Type is
record
IVCE : Boolean; -- Interrupt Vector Select;
IVSEL : Boolean; -- Interrupt Vector Change Enable
Spare_23 : Spare_Type (0 .. 1);
PUD : Boolean; -- Pull-up Disable
#if MCU="ATMEGA2560" then
Spare_56 : Spare_Type (0 .. 1);
JTD : Boolean; -- JTAG Interface Disable
#elsif MCU="ATMEGA328P" then
BODSE : Boolean; -- BOD Sleep Enable
BODS : Boolean; -- BOD Sleep
#end if;
end record;
pragma Pack (MCU_Control_Register_Type);
for MCU_Control_Register_Type'Size use BYTE_SIZE;
type AVR_Status_Register_Type is
record
C : Boolean; -- Carry Flag
Z : Boolean; -- Zero Flag
N : Boolean; -- Negative Flag
V : Boolean; -- Two's Complement Overflow Flag
S : Boolean; -- Sign Bit, S = N xor V
H : Boolean; -- Half Carry Flag
T : Boolean; -- Bit Copy Storage
I : Boolean; -- Global Interrupt Enable
end record;
pragma Pack (AVR_Status_Register_Type);
for AVR_Status_Register_Type'Size use BYTE_SIZE;
#if MCU="ATMEGA2560" then
Reg_OCDR : On_Chip_Debug_Register_Type;
for Reg_OCDR'Address use System'To_Address (16#51#);
#end if;
Reg_MCUSR : MCU_Status_Register_Type;
for Reg_MCUSR'Address use System'To_Address (16#54#);
Reg_MCUCR : MCU_Control_Register_Type;
for Reg_MCUCR'Address use System'To_Address (16#55#);
Reg_RAMPZ : Bit_Array_Type (0 .. 7); -- Extended Z-pointer Register for ELPM/SPM
for Reg_RAMPZ'Address use System'To_Address (16#5B#);
Reg_EIND : Bit_Array_Type (0 .. 7); -- Extended Indirect Register
for Reg_EIND'Address use System'To_Address (16#5C#);
Reg_SP : Byte_Array_Type (0 .. 1); -- Stack Pointer
for Reg_SP'Address use System'To_Address (16#5D#);
Reg_SREG : AVR_Status_Register_Type;
for Reg_SREG'Address use System'To_Address (16#5F#);
type Clock_Prescale_Register_Type is
record
CLKPS : Bit_Array_Type (0 .. 3); -- Clock Prescaler Select Bits
Spare : Spare_Type (0 .. 2);
CLKPCE : Boolean; -- Clock Prescaler Change Enable
end record;
pragma Pack (Clock_Prescale_Register_Type);
for Clock_Prescale_Register_Type'Size use BYTE_SIZE;
Reg_CLKPR : Clock_Prescale_Register_Type;
for Reg_CLKPR'Address use System'To_Address (16#61#);
type Oscillator_Calibration_Value is new Byte_Type;
Reg_OSCCAL : Oscillator_Calibration_Value;
for Reg_OSCCAL'Address use System'To_Address (16#66#);
end AVR.MCU;
|
with Arbre_Binaire;
with Ada.Text_IO;
use Ada.Text_IO;
with Ada.Integer_Text_IO; use Ada.Integer_Text_IO;
procedure Test_Arbre_Binaire is
-- On instancie le package.
package arbre is
new Arbre_Binaire (T_Cle => Integer);
use arbre;
-- Afficher des entiers (pour les clés).
procedure Afficher_Entier (N : in Integer) is
begin
Put(N);
end Afficher_Entier;
-- On modifie la procèdure générique pour afficher l'arbre.
procedure Afficher_Arbre_Binaire is new arbre.Afficher_Arbre_Binaire (Afficher_Cle => Afficher_Entier);
arbre1 : T_Pointeur_Binaire;
procedure Tester_Initialiser(arbre1 : in out T_Pointeur_Binaire) is
begin
-- On initialise l'arbre.
Initialiser (arbre1,15061990 );
Afficher_Arbre_Binaire (arbre1);
New_Line;
-- On vérifie le nombre de fils.
pragma Assert (Nombre_Fils (arbre1, 15061990) = 1);
pragma Assert (Est_Vide (arbre1));
Vider(arbre1);
pragma Assert (Est_Vide (arbre1));
end Tester_Initialiser;
procedure Tester_Ajouter(arbre1 : in out T_Pointeur_Binaire) is
begin
Initialiser (arbre1,42 );
-- On ajoute un fils gauche à l'arbre binaire.
Ajouter_Fils_Gauche (arbre1, 42, 2);
Afficher_Arbre_Binaire (arbre1);
New_Line;
pragma Assert (not Est_Vide (arbre1));
pragma Assert (Nombre_Fils (arbre1, 42) = 2);
pragma Assert (Nombre_Fils (arbre1,2 ) = 1);
Ajouter_Fils_Droit (arbre1, 42, 1);
Afficher_Arbre_Binaire (arbre1);
New_Line;
-- On vérifie que l'arbre n'est plus vide, et que le
-- nombre de fils est de 3.
pragma Assert (not Est_Vide (arbre1));
pragma Assert (Nombre_Fils (arbre1, 42) = 3);
pragma Assert (Nombre_Fils (arbre1, 1) = 1);
-- On ajoute deux fils à 1.
Ajouter_Fils_Gauche (arbre1, 1, 4);
Ajouter_Fils_Droit (arbre1, 1, 3);
Afficher_Arbre_Binaire (arbre1);
New_Line;
-- On vérifie qu'il a bien le bon nombre de fils selon
-- le noeud qu'on sélectionne
pragma Assert (Nombre_Fils (arbre1, 1) = 3);
pragma Assert (Nombre_Fils (arbre1, 42) = 5);
-- On ajoute un fils à 2.
Ajouter_Fils_Droit (arbre1, 2, 55);
Afficher_Arbre_Binaire (arbre1);
New_Line;
pragma Assert (Nombre_Fils (arbre1, 2) = 2);
pragma Assert (Nombre_Fils (arbre1, 42) = 6);
-- On vérifie que le programme lève une exception si la Cle_Parent est Absente.
--Ajouter_Fils_Droit (arbre1, 8, 5);
-- On vérifie que le programme lève une exception si la Cle_Fils existe.
--Ajouter_Fils_Gauche (arbre1, 2, 3);
-- On vérifie que le programme lève une exception si le noeud a déja un fils Droit.
--Ajouter_Fils_Droit (arbre1, 2, 9);
Vider(arbre1);
pragma Assert(Est_Vide(arbre1));
end Tester_Ajouter;
procedure Tester_Supprimer(arbre1 : in out T_Pointeur_Binaire) is
begin
Initialiser (arbre1, 42);
Ajouter_Fils_Gauche (arbre1, 42, 2);
Ajouter_Fils_Droit (arbre1, 42, 1);
Ajouter_Fils_Gauche (arbre1, 1, 4);
Ajouter_Fils_Droit (arbre1, 1, 3);
Ajouter_Fils_Droit (arbre1, 2, 55);
Afficher_Arbre_Binaire(arbre1);
New_Line;
Supprimer (arbre1, 2);
Afficher_Arbre_Binaire (arbre1);
New_Line;
Supprimer (arbre1,3);
Afficher_Arbre_Binaire (arbre1);
New_Line;
-- On s'assure que l'arbre n'est pas complétement supprimé.
pragma Assert (not Est_Vide (arbre1));
-- On s'assure que le fils 1 n'a pas été touché.
pragma Assert (Nombre_Fils (arbre1, 42) = 3);
-- On vérifie que le fils de 2 (ie: 55) a bien été également supprimé.
pragma Assert (Nombre_Fils (arbre1, 1) = 2);
Supprimer(arbre1,42);
pragma Assert (Est_Vide (arbre1));
-- On vide l'arbre.
Vider (arbre1);
end Tester_Supprimer;
begin
Tester_Initialiser(arbre1);
Tester_Ajouter(arbre1);
Tester_Supprimer(arbre1);
Put("OK");
end Test_Arbre_Binaire;
|
pragma Ada_2005;
pragma Style_Checks (Off);
with Interfaces.C; use Interfaces.C;
with SDL_SDL_stdinc_h;
with Interfaces.C.Strings;
package SDL_SDL_cdrom_h is
SDL_MAX_TRACKS : constant := 99; -- ../include/SDL/SDL_cdrom.h:48
SDL_AUDIO_TRACK : constant := 16#00#; -- ../include/SDL/SDL_cdrom.h:54
SDL_DATA_TRACK : constant := 16#04#; -- ../include/SDL/SDL_cdrom.h:55
-- arg-macro: function CD_INDRIVE (status)
-- return (int)(status) > 0;
CD_FPS : constant := 75; -- ../include/SDL/SDL_cdrom.h:96
-- arg-macro: procedure FRAMES_TO_MSF (f, M, S, F)
-- { int value := f; *(F) := valuemodCD_FPS; value /= CD_FPS; *(S) := valuemod60; value /= 60; *(M) := value; }
-- arg-macro: function MSF_TO_FRAMES (M, S, F)
-- return (M)*60*CD_FPS+(S)*CD_FPS+(F);
subtype CDstatus is unsigned;
CD_TRAYEMPTY : constant CDstatus := 0;
CD_STOPPED : constant CDstatus := 1;
CD_PLAYING : constant CDstatus := 2;
CD_PAUSED : constant CDstatus := 3;
CD_ERROR : constant CDstatus := -1; -- ../include/SDL/SDL_cdrom.h:65
type SDL_CDtrack is record
id : aliased SDL_SDL_stdinc_h.Uint8; -- ../include/SDL/SDL_cdrom.h:71
c_type : aliased SDL_SDL_stdinc_h.Uint8; -- ../include/SDL/SDL_cdrom.h:72
unused : aliased SDL_SDL_stdinc_h.Uint16; -- ../include/SDL/SDL_cdrom.h:73
length : aliased SDL_SDL_stdinc_h.Uint32; -- ../include/SDL/SDL_cdrom.h:74
offset : aliased SDL_SDL_stdinc_h.Uint32; -- ../include/SDL/SDL_cdrom.h:75
end record;
pragma Convention (C_Pass_By_Copy, SDL_CDtrack); -- ../include/SDL/SDL_cdrom.h:70
type SDL_CD_track_array is array (0 .. 99) of aliased SDL_CDtrack;
type SDL_CD is record
id : aliased int; -- ../include/SDL/SDL_cdrom.h:80
status : aliased CDstatus; -- ../include/SDL/SDL_cdrom.h:81
numtracks : aliased int; -- ../include/SDL/SDL_cdrom.h:85
cur_track : aliased int; -- ../include/SDL/SDL_cdrom.h:86
cur_frame : aliased int; -- ../include/SDL/SDL_cdrom.h:87
track : aliased SDL_CD_track_array; -- ../include/SDL/SDL_cdrom.h:88
end record;
pragma Convention (C_Pass_By_Copy, SDL_CD); -- ../include/SDL/SDL_cdrom.h:79
function SDL_CDNumDrives return int; -- ../include/SDL/SDL_cdrom.h:114
pragma Import (C, SDL_CDNumDrives, "SDL_CDNumDrives");
function SDL_CDName (drive : int) return Interfaces.C.Strings.chars_ptr; -- ../include/SDL/SDL_cdrom.h:123
pragma Import (C, SDL_CDName, "SDL_CDName");
function SDL_CDOpen (drive : int) return access SDL_CD; -- ../include/SDL/SDL_cdrom.h:132
pragma Import (C, SDL_CDOpen, "SDL_CDOpen");
function SDL_CDStatus (cdrom : access SDL_CD) return CDstatus; -- ../include/SDL/SDL_cdrom.h:139
pragma Import (C, SDL_CDStatus, "SDL_CDStatus");
function SDL_CDPlayTracks
(cdrom : access SDL_CD;
start_track : int;
start_frame : int;
ntracks : int;
nframes : int) return int; -- ../include/SDL/SDL_cdrom.h:163
pragma Import (C, SDL_CDPlayTracks, "SDL_CDPlayTracks");
function SDL_CDPlay
(cdrom : access SDL_CD;
start : int;
length : int) return int; -- ../include/SDL/SDL_cdrom.h:170
pragma Import (C, SDL_CDPlay, "SDL_CDPlay");
function SDL_CDPause (cdrom : access SDL_CD) return int; -- ../include/SDL/SDL_cdrom.h:175
pragma Import (C, SDL_CDPause, "SDL_CDPause");
function SDL_CDResume (cdrom : access SDL_CD) return int; -- ../include/SDL/SDL_cdrom.h:180
pragma Import (C, SDL_CDResume, "SDL_CDResume");
function SDL_CDStop (cdrom : access SDL_CD) return int; -- ../include/SDL/SDL_cdrom.h:185
pragma Import (C, SDL_CDStop, "SDL_CDStop");
function SDL_CDEject (cdrom : access SDL_CD) return int; -- ../include/SDL/SDL_cdrom.h:190
pragma Import (C, SDL_CDEject, "SDL_CDEject");
procedure SDL_CDClose (cdrom : access SDL_CD); -- ../include/SDL/SDL_cdrom.h:193
pragma Import (C, SDL_CDClose, "SDL_CDClose");
end SDL_SDL_cdrom_h;
|
--------------------------------------------------------------------------
-- ASnip Source Code Decorator
-- Copyright (C) 2006, Georg Bauhaus
--
-- 1. Permission is hereby granted to use, copy, modify and/or distribute
-- this package, provided that:
-- * copyright notices are retained unchanged,
-- * any distribution of this package, whether modified or not,
-- includes this license text.
-- 2. Permission is hereby also granted to distribute binary programs which
-- depend on this package. If the binary program depends on a modified
-- version of this package, you are encouraged to publicly release the
-- modified version of this package.
--
-- THIS PACKAGE IS PROVIDED "AS IS" AND WITHOUT WARRANTY. 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 AUTHORS BE LIABLE TO ANY PARTY FOR
-- ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
-- DAMAGES ARISING IN ANY WAY OUT OF THE USE OF THIS PACKAGE.
--------------------------------------------------------------------------
-- eMail: bauhaus@arcor.de
with Ada.Strings.Wide_Maps;
private package ASnip.Support is
type WORD is access constant WIDE_STRING;
-- used for constant definitions of reserved words
function "+"(s: WIDE_STRING) return WORD;
-- an allocated WORD object storing the characters of `s`
generic
with function test(c: CHAR) return BOOLEAN;
function find_first(container: STR) return NATURAL;
-- index of the first character in `container` such that `test`
-- yields true when applied to the character, or 0
subtype WORDS_IDX is POSITIVE range 1 .. 2_000;
-- at most that many reserved words
type WORDLIST is array(WORDS_IDX range <>) of WORD;
-- Lists of reserved language words
use Ada.Strings.Wide_Maps;
Comp_Mapping: constant WIDE_CHARACTER_MAPPING :=
-- for making a comparison of reserved names case insensitive
to_mapping("abcdefghijklmnopqrstuvxyz",
"ABCDEFGHIJKLMNOPQRSTUVXYZ");
type LOCALE_ENV_VAR_NAMES is (LC_CTYPE, LANG, LC_ALL);
-- names of environment variables telling the character set in use
function input_encoding return SUPPORTED_ENCODING;
-- The character encoding found in the enviroment.
-- If there is none, returns the default. (Currently this
-- is ISO_8859, for hysteric raisins.)
function to_UTF_8 (s: STR) return STRING;
-- `s` as a string of `CHARACTER` octets, UTF-8 encoded
end;
with get_env_var;
with Ada.Command_Line;
with Ada.Strings.Wide_Fixed;
with Ada.Strings.Fixed;
with Ada.Characters.Handling;
with Interfaces;
package body ASnip.Support is
no_encoding_found: exception;
function encoding_from_environment return SUPPORTED_ENCODING;
-- The character encoding found in the enviroment, if any. Uses
-- the values in `LOCALE_ENV_VAR_NAMES`.
function encoding_from_command_line return SUPPORTED_ENCODING;
-- The character encoding found as the first command line
-- argument, if any. TODO rework/remove...!
function "+"(s: WIDE_STRING) return WORD is
use Ada.Strings.Wide_Fixed;
begin
return new STR'(translate(s, Comp_Mapping));
end "+";
function encoding_from_command_line return SUPPORTED_ENCODING is
use Ada.Command_Line, Ada.Strings.Fixed, Ada.Characters.Handling;
begin
if argument_count = 6 then
declare
arg: constant STRING := to_upper(argument(6));
begin
if arg = "UTF_8" or arg = "UTF-8" or arg = "UTF8" then
return UTF_8;
elsif arg = "UTF_16" or arg = "UTF-16" or arg = "UTF16" then
return UTF_16;
elsif index(arg, "ISO") > 0 and then index(arg, "8859") > 0 then
return ISO_8859;
end if;
end;
end if;
raise no_encoding_found;
end encoding_from_command_line;
function encoding_from_environment return SUPPORTED_ENCODING is
use Ada.Characters.Handling, Ada.Strings.Fixed;
var: LOCALE_ENV_VAR_NAMES := LOCALE_ENV_VAR_NAMES'first;
begin
-- (Possible enhancement: See whether there is a BE or LE suffix
-- after UTF-16. Make all `IO.next_char_16*` functions read byte-wise
-- then, and rotate when necessary.)
env_search:
loop
declare
locale: constant STRING :=
get_env_var(LOCALE_ENV_VAR_NAMES'image(var));
begin
if locale /= "" then
declare
val: constant STRING := to_upper(locale);
begin
if index(source => val, pattern => "8859") > 0 then
return ISO_8859;
elsif index(source => val, pattern => "UTF-8") > 0 then
return UTF_8;
elsif index(source => val, pattern => "UTF-16") > 0 then
if index(source => val, pattern => "LE") > 0 then
return UTF_16LE;
else
return UTF_16;
end if;
end if;
end;
end if;
end;
exit when var = LOCALE_ENV_VAR_NAMES'last;
-- nothing found
var := LOCALE_ENV_VAR_NAMES'succ(var);
end loop env_search;
raise no_encoding_found;
end encoding_from_environment;
function find_first(container: STR) return NATURAL is
begin
for k in container'range loop
if test(container(k)) then
return k;
end if;
end loop;
return 0;
end;
function input_encoding return SUPPORTED_ENCODING is
begin
return encoding_from_command_line;
exception
when no_encoding_found =>
begin
return encoding_from_environment;
exception
when no_encoding_found =>
return ISO_8859;
end;
end input_encoding;
function to_UTF_8 (s: STR) return STRING is
use Interfaces;
result: STRING(1.. 4 * s'length);
-- Unicode has at most 4 bytes for a UTF-8 encoded character
k: POSITIVE := result'first;
-- in the loop, points to the first insertion position of a
-- "byte sequence". (Can't use range because `s = ""` is possible.)
bits: UNSIGNED_32 := 2#0#;
-- the bits representing the WIDE_CHARACTER
subtype CH is Character;
-- abbreviation
B6: constant := 2#111111#;
begin
for j in s'range loop
bits := WIDE_CHARACTER'pos(s(j));
if bits <= 2#1111111# then
result(k) := Ch'Val(bits);
k := k + 1;
elsif bits <= 2#11111_111111# then
result(k .. k + 1) :=
(Ch'val(2#110_00000# or (shift_right(bits, 1 * 6) and 2#11111#)),
Ch'val(2#10_000000# or (shift_right(bits, 0 * 6) and B6)));
k := k + 2;
elsif
bits = 16#fffe#
or bits = 16#ffff#
then
-- ignore non-characters
null;
elsif bits <= 2#1111_111111_111111# then
result(k .. k + 2) :=
(Ch'val(2#1110_0000# or (shift_right(bits, 2 * 6) and 2#1111#)),
Ch'val(2#10_000000# or (shift_right(bits, 1 * 6) and B6)),
Ch'val(2#10_000000# or (shift_right(bits, 0 * 6) and B6)));
k := k + 3;
elsif bits <= 2#111_111111_111111_111111# then
result(k .. k + 3) :=
(Ch'val(2#11110_000# or (shift_right(bits, 3 * 6) and 2#111#)),
Ch'val(2#10_000000# or (shift_right(bits, 2 * 6) and B6)),
Ch'val(2#10_000000# or (shift_right(bits, 1 * 6) and B6)),
Ch'val(2#10_000000# or (shift_right(bits, 0 * 6) and B6)));
k := k + 4;
else
-- not Unicode
raise Constraint_Error;
end if;
end loop;
return result(1.. k - 1);
end to_UTF_8;
end ASnip.Support;
|
-----------------------------------------------------------------------
-- security -- Security
-- Copyright (C) 2010, 2011, 2012, 2015, 2017, 2018, 2019 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.
-----------------------------------------------------------------------
-- = Security =
-- The `Security` package provides a security framework that allows
-- an application to use OpenID or OAuth security frameworks. This security
-- framework was first developed within the Ada Server Faces project.
-- It was moved to a separate project so that it can easyly be used with AWS.
-- This package defines abstractions that are close or similar to Java
-- security package.
--
-- The security framework uses the following abstractions:
--
-- * **Policy and policy manager**:
-- The `Policy` defines and implements the set of security rules that specify how to
-- protect the system or resources. The `Policy_Manager` maintains the security policies.
--
-- * **Principal**:
-- The `Principal` is the entity that can be authenticated. A principal is obtained
-- after successful authentication of a user or of a system through an authorization process.
-- The OpenID or OAuth authentication processes generate such security principal.
--
-- * **Permission**:
-- The `Permission` represents an access to a system or application resource.
-- A permission is checked by using the security policy manager. The policy manager uses a
-- security controller to enforce the permission.
--
-- The `Security_Context` holds the contextual information that the security controller
-- can use to verify the permission. The security context is associated with a principal and
-- a set of policy context.
--
-- == Overview ==
-- An application will create a security policy manager and register one or several security
-- policies (yellow). The framework defines a simple role based security policy and an URL
-- security policy intended to provide security in web applications. The security policy manager
-- reads some security policy configuration file which allows the security policies to configure
-- and create the security controllers. These controllers will enforce the security according
-- to the application security rules. All these components are built only once when
-- an application starts.
--
-- A user is authenticated through an authentication system which creates a `Principal`
-- instance that identifies the user (green). The security framework provides two authentication
-- systems: OpenID and OAuth 2.0 OpenID Connect.
--
-- [images/ModelOverview.png]
--
-- When a permission must be enforced, a security context is created and linked to the
-- `Principal` instance (blue). Additional security policy context can be added depending
-- on the application context. To check the permission, the security policy manager is called
-- and it will ask a security controller to verify the permission.
--
-- The framework allows an application to plug its own security policy, its own policy context,
-- its own principal and authentication mechanism.
--
-- @include security-permissions.ads
--
-- == Principal ==
-- A principal is created by using either the [Security_Auth OpenID],
-- the [Security_OAuth OAuth] or another authentication mechanism. The authentication produces
-- an object that must implement the `Principal` interface. For example:
--
-- P : Security.Auth.Principal_Access := Security.Auth.Create_Principal (Auth);
--
-- or
--
-- P : Security.OAuth.Clients.Access_Token_Access := Security.OAuth.Clients.Create_Access_Token
--
-- The principal is then stored in a security context.
--
-- @include security-contexts.ads
--
package Security is
pragma Preelaborate;
-- ------------------------------
-- Principal
-- ------------------------------
type Principal is limited interface;
type Principal_Access is access all Principal'Class;
-- Get the principal name.
function Get_Name (From : in Principal) return String is abstract;
end Security;
|
-- Copyright 2016-2021 Bartek thindil Jasicki
--
-- This file is part of Steam Sky.
--
-- Steam Sky 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.
--
-- Steam Sky 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 Steam Sky. If not, see <http://www.gnu.org/licenses/>.
with Ada.Strings.Unbounded; use Ada.Strings.Unbounded;
with Ada.Containers.Vectors; use Ada.Containers;
with Items; use Items;
with Game; use Game;
-- ****h* Crew/Crew
-- FUNCTION
-- Provide code for manipulate player ship crew
-- SOURCE
package Crew is
-- ****
-- ****s* Crew/Crew.Skill_Info
-- FUNCTION
-- Data structure for skills
-- PARAMETERS
-- Index - The index of the skill in the skills list
-- Level - The current level of the skill
-- Experience - The amount of experience in the skill
-- HISTORY
-- 6.6 - Added
-- SOURCE
type Skill_Info is record
Index: Skills_Amount_Range := 1;
Level: Skill_Range := 0;
Experience: Natural := 0;
end record;
-- ****
-- ****d* Crew/Crew.Empty_Skill_Info
-- FUNCTION
-- Default empty skill
-- HISTORY
-- 6.6 - Added
-- SOURCE
Empty_Skill_Info: constant Skill_Info := Skill_Info'(others => <>);
-- ****
-- ****t* Crew/Crew.Skills_Container
-- FUNCTION
-- Used to store skills data
-- SOURCE
package Skills_Container is new Vectors(Skills_Amount_Range, Skill_Info);
-- ****
-- ****t* Crew/Crew.Crew_Orders
-- FUNCTION
-- Available orders for ships crews
-- SOURCE
type Crew_Orders is
(Pilot, Engineer, Gunner, Repair, Craft, Upgrading, Talk, Heal, Clean,
Rest, Defend, Boarding, Train) with
Default_Value => Rest;
-- ****
-- ****t* Crew/Crew.Equipment_Array
-- FUNCTION
-- Data structure for currently equipped items for crew members. 1 - weapon,
-- 2 - shield, 3 - helmet, 4 - torso, 5 - arms, 6 - legs, 7 - tool
-- SOURCE
type Equipment_Array is array(1 .. 7) of Natural with
Default_Component_Value => 0;
-- ****
-- ****s* Crew/Crew.Mob_Attribute_Record
-- FUNCTION
-- Used to store the attributes of mobs
-- PARAMETERS
-- Level - The level of the attribute
-- Experience - The experience amount in the attribute
-- HISTORY
-- 6.6 - Added
-- SOURCE
type Mob_Attribute_Record is record
Level: Positive range 1 .. 50 := 1;
Experience: Natural := 0;
end record;
-- ****
-- ****d* Crew/Crew.Empty_Attributes
-- FUNCTION
-- Empty values for mob attributes
-- HISTORY
-- 6.6 - Added
-- SOURCE
Empty_Attributes: constant Mob_Attribute_Record :=
Mob_Attribute_Record'(others => <>);
-- ****
-- ****t* Crew/Crew.Mob_Attributes
-- FUNCTION
-- Array used to store attributes of the mobs (crew, other mobs, recruits,
-- etc).
-- HISTORY
-- 6.5 - Added
-- 6.6 - Changed from array of array to array of record
-- SOURCE
type Mob_Attributes is
array(Attributes_Amount_Range range <>) of Mob_Attribute_Record;
-- ****
-- ****s* Crew/Crew.Mob_Record
-- FUNCTION
-- Abstract record to store all common settings for mobs (crew, other mobs,
-- recruits, etc)
-- PARAMETERS
-- Attributes - Levels and experience in attributes of the mob
-- Amount_Of_Attributes - The amount of attributes declared in the game
-- Amount_Of_Skills - The amount of skills declared in the game
-- HISTORY
-- 6.5 - Added
-- SOURCE
type Mob_Record
(Amount_Of_Attributes: Attributes_Amount_Range;
Amount_Of_Skills: Skills_Amount_Range)
is abstract tagged record
Attributes: Mob_Attributes(1 .. Amount_Of_Attributes);
Skills: Skills_Container.Vector;
end record;
-- ****
-- ****s* Crew/Crew.Member_Data
-- FUNCTION
-- Data structure for ship crew member
-- PARAMETERS
-- Name - Name of member
-- Gender - Gender of member
-- Health - Level of health of member
-- Tired - Tiredness of member
-- Skills - Names indexes, levels and experience in skills of
-- member
-- Hunger - Hunger level of member
-- Thirst - Thirst level of member
-- Order - Current order for member
-- PreviousOrder - Previous order for member
-- OrderTime - Minutes to next check for order result
-- Orders - Priority of orders of member
-- Attributes - Levels and experience in attributes of member
-- Inventory - Owned items by member
-- Equipment - Items indexes from inventory used by character:
-- 1 - weapon, 2 - shield, 3 - helmet, 4 - torso,
-- 5 - arms, 6 - legs, 7 - tool
-- Payment - How much money member takes as payment.
-- 1 - daily payment, 2 - percent from each trade
-- ContractLength - How many days crew member will be in crew. -1 mean
-- pernament contract
-- Morale - Morale of crew member, between 0 and 100, 1 - level,
-- 2 - points to next level
-- Loyality - Loyalty of crew member, between 0 and 100
-- HomeBase - Index of base from which crew member is
-- Faction - Index of faction to which crew member belongs
-- SOURCE
type Member_Data is new Mob_Record with record
Name: Unbounded_String;
Gender: Character;
Health: Skill_Range;
Tired: Natural range 0 .. 150 := 0;
Hunger: Skill_Range;
Thirst: Skill_Range;
Order: Crew_Orders;
PreviousOrder: Crew_Orders;
OrderTime: Integer := 15;
Orders: Natural_Array(1 .. 12);
Inventory: Inventory_Container.Vector;
Equipment: Equipment_Array;
Payment: Attributes_Array;
ContractLength: Integer := 0;
Morale: Attributes_Array;
Loyalty: Skill_Range;
HomeBase: Bases_Range;
Faction: Unbounded_String;
end record;
-- ****
-- ****v* Crew/Crew.MaleSyllablesStart
-- FUNCTION
-- List of males first syllables for generating crew members names
-- SOURCE
MaleSyllablesStart: UnboundedString_Container.Vector;
-- ****
-- ****v* Crew/Crew.MaleSyllablesMiddle
-- FUNCTION
-- List of males middle syllables for generating crew members names
-- SOURCE
MaleSyllablesMiddle: UnboundedString_Container.Vector;
-- ****
-- ****v* Crew/Crew.MaleSyllablesEnd
-- FUNCTION
-- List of males last syllables for generating crew members names
-- SOURCE
MaleSyllablesEnd: UnboundedString_Container.Vector;
-- ****
-- ****v* Crew/Crew.MaleVocals
-- FUNCTION
-- List of males vocals for generating crew members names
-- SOURCE
MaleVocals: UnboundedString_Container.Vector;
-- ****
-- ****v* Crew/Crew.MaleConsonants
-- FUNCTION
-- List of males consonants for generating crew members names
-- SOURCE
MaleConsonants: UnboundedString_Container.Vector;
-- ****
-- ****v* Crew/Crew.FemaleSyllablesStart
-- FUNCTION
-- List of females first syllables for generating crew members names
-- SOURCE
FemaleSyllablesStart: UnboundedString_Container.Vector;
-- ****
-- ****v* Crew/Crew.FemaleSyllablesMiddle
-- FUNCTION
-- List of females middle syllables for generating crew members names
-- SOURCE
FemaleSyllablesMiddle: UnboundedString_Container.Vector;
-- ****
-- ****v* Crew/Crew.FemaleSyllablesEnd
-- FUNCTION
-- List of females last syllables for generating crew members names
-- SOURCE
FemaleSyllablesEnd: UnboundedString_Container.Vector;
-- ****
-- ****v* Crew/Crew.FemaleVocals
-- FUNCTION
-- List of females vocals for generating crew members names
-- SOURCE
FemaleVocals: UnboundedString_Container.Vector;
-- ****
-- ****e* Crew/Crew.Crew_Order_Error
-- FUNCTION
-- Raised when new order can't be set for selected crew member
-- SOURCE
Crew_Order_Error: exception;
-- ****
-- ****e* Crew/Crew.Crew_No_Space_Error
-- FUNCTION
-- Raised when no space for new item in crew member inventory
-- SOURCE
Crew_No_Space_Error: exception;
-- ****
-- ****f* Crew/Crew.GainExp
-- FUNCTION
-- Gain experience in selected skill.
-- PARAMETERS
-- Amount - Amount of gained experience
-- SkillNumber - Index of skill in skills list
-- CrewIndex - Crew index of member
-- SOURCE
procedure GainExp(Amount: Natural; SkillNumber, CrewIndex: Positive) with
Pre => SkillNumber <= Skills_Amount,
Test_Case => (Name => "Test_GainExp", Mode => Nominal);
-- ****
-- ****f* Crew/Crew.GenerateMemberName
-- FUNCTION
-- Generate random name for crew member
-- PARAMETERS
-- Gender - Gender of crew member which name will be generated
-- FactionIndex - Faction to which crew member belongs
-- RESULT
-- Random name for crew member
-- SOURCE
function GenerateMemberName
(Gender: Character; FactionIndex: Unbounded_String)
return Unbounded_String with
Pre => Gender in 'M' | 'F' and FactionIndex /= Null_Unbounded_String,
Test_Case => (Name => "Test_GenerateMemberName", Mode => Nominal);
-- ****
-- ****f* Crew/Crew.FindCabin
-- FUNCTION
-- Find index of cabin which belongs to selected crew member
-- PARAMETERS
-- MemberIndex: Crew index of crew member which cabin is looking for
-- RESULT
-- Player ship module index of owned cabin or 0 if crew member don't
-- have any cabin assigned
-- SOURCE
function FindCabin(MemberIndex: Positive) return Natural with
Test_Case => (Name => "Test_FindCabin", Mode => Robustness);
-- ****
-- ****f* Crew/Crew.UpdateCrew
-- FUNCTION
-- Update player ship crew
-- PARAMETERS
-- Minutes - Amount of in-game minutes which passed
-- TiredPoints - Amount of Tired points which will be added to crew members
-- InCombat - If true, player is in combat. Default is false
-- SOURCE
procedure UpdateCrew
(Minutes: Positive; TiredPoints: Natural; InCombat: Boolean := False) with
Test_Case => (Name => "Test_UpdateCrew", Mode => Robustness);
-- ****
-- ****f* Crew/Crew.WaitForRest
-- FUNCTION
-- Wait until whole crew is rested
-- SOURCE
procedure WaitForRest with
Test_Case => (Name => "Test_WaitForRest", Mode => Robustness);
-- ****
-- ****f* Crew/Crew.GetSkillLevelName
-- FUNCTION
-- Get member skill level name
-- PARAMETERS
-- SkillLevel - Numeric value of skill level
-- RESULT
-- Name (as words) of skill level
-- SOURCE
function GetSkillLevelName(SkillLevel: Skill_Range) return String with
Test_Case => (Name => "Test_GetSkillLevelName", Mode => Nominal);
-- ****
-- ****f* Crew/Crew.GetAttributeLevelName
-- FUNCTION
-- Get member attribute level name
-- PARAMETERS
-- AttributeLevel - Numeric value of attribute level
-- RESULT
-- Name (as words) of attribute level
-- SOURCE
function GetAttributeLevelName(AttributeLevel: Positive) return String with
Pre => (AttributeLevel <= 50),
Test_Case => (Name => "Test_GetAttributeLevelName", Mode => Nominal);
-- ****
-- ****f* Crew/Crew.DailyPayment
-- FUNCTION
-- Daily payment and upgrade contracts length for player ship crew members
-- SOURCE
procedure DailyPayment with
Test_Case => (Name => "Test_DailyPayment", Mode => Robustness);
-- ****
-- ****f* Crew/Crew.GetTrainingToolQuality
-- FUNCTION
-- Get minumum required quality for training tool for the selected skill
-- for the selected crew member
-- PARAMETERS
-- MemberIndex - Index of crew member which skills will be queried
-- SkillIndex - Index of skill of which tool will be queried
-- RESULT
-- Minimum required quality of training tool or 100 if not set for this
-- skill
-- SOURCE
function GetTrainingToolQuality
(MemberIndex, SkillIndex: Positive) return Positive with
Pre => SkillIndex <= Skills_Amount,
Test_Case => (Name => "Test_GetTrainingToolQuality", Mode => Nominal);
-- ****
end Crew;
|
-- Copyright 2019 Simon Symeonidis (psyomn)
--
-- Licensed under the Apache License, Version 2.0 (the "License");
-- you may not use this file except in compliance with the License.
-- You may obtain a copy of the License at
--
-- http://www.apache.org/licenses/LICENSE-2.0
--
-- Unless required by applicable law or agreed to in writing, software
-- distributed under the License is distributed on an "AS IS" BASIS,
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-- See the License for the specific language governing permissions and
-- limitations under the License.
with Ada.Strings; use Ada.Strings;
with Ada.Strings.Fixed; use Ada.Strings.Fixed;
package body Common_Utils is
function Integer_To_Trimmed_String (I : Integer) return String is
Result : constant String :=
Trim (Source => Integer'Image (I), Side => Both);
begin
return Result;
end Integer_To_Trimmed_String;
function Header_String (Field : String; Value : String) return String is
Result : constant String := Field & ": " & Value;
begin
return Result;
end Header_String;
function Header_String (Field : String; Value : Integer) return String is
Result : constant String :=
Header_String (Field, Integer_To_Trimmed_String (Value));
begin
return Result;
end Header_String;
procedure Empty_String_Range
(S : String;
First : out Positive;
Last : out Positive) is
Current : Character := Character'Val (0);
begin
First := S'First;
Last := S'Last;
for I in Positive range S'First .. S'Last loop
Current := S (I);
if Current = Character'Val (0) then
First := (if I > 1 then I - 1 else I);
exit;
end if;
end loop;
for I in Positive range First .. S'Last loop
Current := S (I);
if Current /= Character'Val (0) then
Last := I;
exit;
end if;
end loop;
end Empty_String_Range;
procedure Empty_String (S : in out String) is
Null_Char : constant Character := Character'Val (0);
begin
for I in Positive range S'First .. S'Last loop
S (I) := Null_Char;
end loop;
end Empty_String;
function Concat_Null_Strings (S1, S2 : String) return String is
Upto1, Upto2 : Positive;
begin
for I in Positive range S1'Range loop
if S1 (I) = Character'Val (0) then
Upto1 := I - 1;
exit;
end if;
end loop;
for I in Positive range S2'Range loop
if S2 (I) = Character'Val (0) then
Upto2 := I - 1;
exit;
end if;
end loop;
declare
Ret : constant String (1 .. Upto1 + Upto2) :=
S1 (S1'First .. Upto1) & S2 (S2'First .. Upto2);
begin
return Ret;
end;
end Concat_Null_Strings;
procedure Print_Exception (E : Exception_Occurrence; Message : String)
is
package IO renames Ada.Text_IO;
begin
IO.Put_Line (
IO.Standard_Error,
Message & " " &
Exception_Name (E) & " " &
Exception_Message (E) & " " &
Symbolic_Traceback (E)
);
end Print_Exception;
end Common_Utils;
|
-----------------------------------------------------------------------
-- net-dns -- DNS Network utilities
-- Copyright (C) 2016, 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.Real_Time;
with Net.Interfaces;
with Net.Buffers;
with Net.Sockets.Udp;
-- == DNS Client ==
-- The DNS client is used to make a DNS resolution and resolve a hostname to get an IP address
-- (RFC 1035). The client implementation is based on the UDP client sockets and it uses a
-- random UDP port to receive the DNS response.
--
-- === Initialization ===
-- The DNS client is represented by the <tt>Query</tt> tagged type. An instance must be declared
-- for each hostname that must be resolved.
--
-- Client : Net.DNS.Query;
--
-- === Hostname resolution ===
-- The hostname resolution is started by calling the <tt>Resolve</tt> operation on the query
-- object. That operation needs an access to the network interface to be able to send the
-- DNS query packet. It returns a status code that indicates whether the packet was sent or not.
--
-- Client.Resolve (Ifnet'Access, "www.google.com", Status);
--
-- The DNS resolution is asynchronous. The <tt>Resolve</tt> operation does not wait for the
-- response. The <tt>Get_Status</tt> operation can be used to look at the progress of the DNS
-- query. The value <tt>PENDING</tt> indicates that a request was sent but no response was
-- received yet. The value <tt>NOERROR</tt> indicates that the DNS resolution was successful.
--
-- Once the <tt>Get_Status</tt> operation returns the <tt>NOERROR</tt> value, the IPv4 address
-- can be obtained by using the <tt>Get_Ip</tt> function.
--
-- IP : Net.Ip_Addr := Client.Get_Ip;
package Net.DNS is
-- Maximum length allowed for a hostname resolution.
DNS_NAME_MAX_LENGTH : constant Positive := 255;
-- Maximum length accepted by a response anwser. The official limit is 64K but this
-- implementation limits the length of DNS records to 512 bytes which is more than acceptable.
DNS_VALUE_MAX_LENGTH : constant Positive := 512;
-- The DNS query status.
type Status_Type is (NOQUERY, NOERROR, FORMERR, SERVFAIL, NXDOMAIN, NOTIMP,
REFUSED, YXDOMAIN, XRRSET, NOTAUTH, NOTZONE, OTHERERROR, PENDING);
-- The DNS record type is a 16-bit number.
type RR_Type is new Net.Uint16;
-- Common standard DNS record type values from RFC 1035, RFC 3586)
-- (See http://www.iana.org/assignments/dns-parameters/dns-parameters.xhtml)
A_RR : constant RR_Type := 1;
NS_RR : constant RR_Type := 2;
CNAME_RR : constant RR_Type := 5;
PTR_RR : constant RR_Type := 12;
MX_RR : constant RR_Type := 15;
TXT_RR : constant RR_Type := 16;
AAAA_RR : constant RR_Type := 28;
-- The possible value types in the response.
type Value_Type is (V_NONE, V_TEXT, V_IPV4, V_IPV6);
-- The Response_Type record describes a response anwser that was received from the
-- DNS server. The DNS server can send several response answers in the same packet.
-- The answer data is extracted according to the RR type and made available as String,
-- IPv4 and in the future IPv6.
type Response_Type (Kind : Value_Type;
Of_Type : RR_Type;
Len : Natural) is
record
Class : Net.Uint16;
Ttl : Net.Uint32;
case Kind is
when V_TEXT => -- CNAME_RR | TXT_RR | MX_RR | NS_RR | PTR_RR
Text : String (1 .. Len);
when V_IPV4 => -- A_RR
Ip : Net.Ip_Addr;
when others =>
null;
end case;
end record;
type Query is new Net.Sockets.Udp.Socket with private;
function Get_Status (Request : in Query) return Status_Type;
-- Get the name defined for the DNS query.
function Get_Name (Request : in Query) return String;
-- Get the IP address that was resolved by the DNS query.
function Get_Ip (Request : in Query) return Net.Ip_Addr;
-- Get the TTL associated with the response.
function Get_Ttl (Request : in Query) return Net.Uint32;
-- Start a DNS resolution for the given hostname.
procedure Resolve (Request : access Query;
Ifnet : access Net.Interfaces.Ifnet_Type'Class;
Name : in String;
Status : out Error_Code;
Timeout : in Duration := 10.0) with
Pre => Name'Length < DNS_NAME_MAX_LENGTH,
Post => Request.Get_Status /= NOQUERY;
-- Save the answer received from the DNS server. This operation is called for each answer
-- found in the DNS response packet. The Index is incremented at each answer. For example
-- a DNS server can return a CNAME_RR answer followed by an A_RR: the operation is called
-- two times.
--
-- This operation can be overriden to implement specific actions when an answer is received.
procedure Answer (Request : in out Query;
Status : in Status_Type;
Response : in Response_Type;
Index : in Natural);
overriding
procedure Receive (Request : in out Query;
From : in Net.Sockets.Sockaddr_In;
Packet : in out Net.Buffers.Buffer_Type);
private
protected type Request is
procedure Set_Result (Addr : in Net.Ip_Addr;
Time : in Net.Uint32);
procedure Set_Status (State : in Status_Type);
function Get_IP return Net.Ip_Addr;
function Get_Status return Status_Type;
function Get_TTL return Net.Uint32;
private
Status : Status_Type := NOQUERY;
Ip : Net.Ip_Addr := (others => 0);
Ttl : Net.Uint32;
end Request;
type Query is new Net.Sockets.Udp.Socket with record
Name : String (1 .. DNS_NAME_MAX_LENGTH);
Name_Len : Natural := 0;
Deadline : Ada.Real_Time.Time;
Xid : Net.Uint16;
Result : Request;
end record;
end Net.DNS;
|
--
-- 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 ewok.tasks; use ewok.tasks;
with ewok.tasks_shared; use ewok.tasks_shared;
with ewok.sched;
with ewok.softirq;
with ewok.syscalls.cfg.dev;
with ewok.syscalls.cfg.gpio;
with ewok.syscalls.dma;
with ewok.syscalls.gettick;
with ewok.syscalls.init;
with ewok.syscalls.ipc;
with ewok.syscalls.lock;
with ewok.syscalls.reset;
with ewok.syscalls.rng;
with ewok.syscalls.sleep;
with ewok.syscalls.yield;
with ewok.exported.interrupts;
use type ewok.exported.interrupts.t_interrupt_config_access;
with m4.cpu.instructions;
package body ewok.syscalls.handler
with spark_mode => off
is
type t_syscall_parameters_access is access all t_syscall_parameters;
function to_syscall_parameters_access is new ada.unchecked_conversion
(system_address, t_syscall_parameters_access);
procedure exec_synchronous_syscall
(current_id : in ewok.tasks_shared.t_task_id;
mode : in ewok.tasks_shared.t_task_mode;
sys_params_a : in t_syscall_parameters_access)
is
begin
case sys_params_a.all.syscall_type is
when SYS_IPC =>
ewok.syscalls.ipc.sys_ipc
(current_id, sys_params_a.all.args, mode);
when SYS_GETTICK =>
ewok.syscalls.gettick.sys_gettick
(current_id,
sys_params_a.all.args, mode);
when SYS_LOCK =>
ewok.syscalls.lock.sys_lock
(current_id, sys_params_a.all.args, mode);
when SYS_YIELD =>
ewok.syscalls.yield.sys_yield (current_id, mode);
when SYS_CFG =>
declare
syscall : t_syscalls_cfg
with address => sys_params_a.all.args(0)'address;
begin
case syscall is
when CFG_GPIO_SET =>
ewok.syscalls.cfg.gpio.gpio_set (current_id,
sys_params_a.all.args, mode);
when CFG_GPIO_GET =>
ewok.syscalls.cfg.gpio.gpio_get (current_id,
sys_params_a.all.args, mode);
when CFG_GPIO_UNLOCK_EXTI =>
ewok.syscalls.cfg.gpio.gpio_unlock_exti (current_id,
sys_params_a.all.args, mode);
when CFG_DMA_RECONF =>
ewok.syscalls.dma.sys_cfg_dma_reconf (current_id,
sys_params_a.all.args, mode);
when CFG_DMA_RELOAD =>
ewok.syscalls.dma.sys_cfg_dma_reload (current_id,
sys_params_a.all.args, mode);
when CFG_DMA_DISABLE =>
ewok.syscalls.dma.sys_cfg_dma_disable (current_id,
sys_params_a.all.args, mode);
when CFG_DEV_MAP =>
ewok.syscalls.cfg.dev.dev_map (current_id,
sys_params_a.all.args, mode);
when CFG_DEV_UNMAP =>
ewok.syscalls.cfg.dev.dev_unmap (current_id,
sys_params_a.all.args, mode);
when CFG_DEV_RELEASE =>
ewok.syscalls.cfg.dev.dev_release (current_id,
sys_params_a.all.args, mode);
end case;
end;
when SYS_SLEEP =>
ewok.syscalls.sleep.sys_sleep
(current_id, sys_params_a.all.args, mode);
when SYS_GET_RANDOM =>
ewok.syscalls.rng.sys_get_random
(current_id, sys_params_a.all.args, mode);
when SYS_RESET =>
ewok.syscalls.reset.sys_reset (current_id, mode);
when SYS_INIT =>
ewok.syscalls.init.sys_init
(current_id, sys_params_a.all.args, mode);
when SYS_LOG => raise program_error;
end case;
end exec_synchronous_syscall;
function svc_handler
(frame_a : t_stack_frame_access)
return t_stack_frame_access
is
svc : t_svc_type;
sys_params_a : t_syscall_parameters_access;
current_id : t_task_id;
current_a : ewok.tasks.t_task_access;
begin
current_id := ewok.sched.get_current;
current_a := ewok.tasks.get_task (current_id);
--
-- We must save the frame pointer because synchronous syscall don't refer
-- to the parameters on the stack indexed by 'frame_a' but to
-- 'current_a' (they access 'frame_a' via 'current_a.all.ctx.frame_a'
-- or 'current_a.all.isr_ctx.frame_a')
--
if ewok.tasks.get_mode (current_id) = TASK_MODE_MAINTHREAD then
current_a.all.ctx.frame_a := frame_a;
else
current_a.all.isr_ctx.frame_a := frame_a;
end if;
--
-- Getting the svc number from the SVC instruction
--
declare
inst : m4.cpu.instructions.t_svc_instruction
with import, address => to_address (frame_a.all.PC - 2);
begin
if not inst.opcode'valid then
raise program_error;
end if;
declare
svc_type : t_svc_type with address => inst.svc_num'address;
begin
if not svc_type'valid then
ewok.tasks.set_state
(current_id, TASK_MODE_MAINTHREAD, TASK_STATE_FAULT);
set_return_value
(current_id, current_a.all.mode, SYS_E_DENIED);
return frame_a;
end if;
svc := svc_type;
end;
end;
-------------------
-- Managing SVCs --
-------------------
case svc is
when SVC_SYSCALL =>
-- Extracting syscall parameters
sys_params_a := to_syscall_parameters_access (frame_a.all.R0);
-- Are they valid?
if not sys_params_a.all.syscall_type'valid then
ewok.tasks.set_state
(current_id, TASK_MODE_MAINTHREAD, TASK_STATE_FAULT);
set_return_value
(current_id, ewok.tasks.get_mode(current_id), SYS_E_DENIED);
end if;
-- Executing IPCs
if sys_params_a.all.syscall_type = SYS_IPC then
ewok.syscalls.ipc.sys_ipc
(current_id, sys_params_a.all.args, current_a.all.mode);
return ewok.sched.do_schedule (frame_a);
-- Executing other synchronous syscall
elsif sys_params_a.all.syscall_type /= SYS_LOG then
exec_synchronous_syscall
(current_id, current_a.all.mode, sys_params_a);
return frame_a;
-- Sys_log() syscall is postponed (asynchronously executed)
else
if current_a.all.mode = TASK_MODE_MAINTHREAD then
ewok.softirq.push_syscall (current_id);
ewok.tasks.set_state (current_id, TASK_MODE_MAINTHREAD,
TASK_STATE_SVC_BLOCKED);
return ewok.sched.do_schedule (frame_a);
else
-- Postponed syscalls are forbidden in ISR mode
set_return_value
(current_id, TASK_MODE_ISRTHREAD, SYS_E_DENIED);
return frame_a;
end if;
end if;
when SVC_TASK_DONE =>
ewok.tasks.set_state
(current_id, TASK_MODE_MAINTHREAD, TASK_STATE_FINISHED);
return ewok.sched.do_schedule (frame_a);
when SVC_ISR_DONE =>
#if CONFIG_SCHED_SUPPORT_FISR
declare
current_state : constant t_task_state :=
ewok.tasks.get_state (current_id, TASK_MODE_MAINTHREAD);
begin
if current_state = TASK_STATE_RUNNABLE or
current_state = TASK_STATE_IDLE
then
ewok.tasks.set_state
(current_id, TASK_MODE_MAINTHREAD, TASK_STATE_FORCED);
end if;
end;
#end if;
ewok.tasks.set_state
(current_id, TASK_MODE_ISRTHREAD, TASK_STATE_ISR_DONE);
return ewok.sched.do_schedule (frame_a);
end case;
end svc_handler;
end ewok.syscalls.handler;
|
package Giza.Bitmap_Fonts.FreeMono12pt7b is
Font : constant Giza.Font.Ref_Const;
private
FreeMono12pt7bBitmaps : aliased constant Font_Bitmap := (
16#49#, 16#24#, 16#92#, 16#48#, 16#01#, 16#F8#, 16#E7#, 16#E7#, 16#67#,
16#46#, 16#42#, 16#42#, 16#42#, 16#09#, 16#02#, 16#41#, 16#10#, 16#44#,
16#11#, 16#1F#, 16#F1#, 16#10#, 16#48#, 16#12#, 16#3F#, 16#E1#, 16#20#,
16#48#, 16#12#, 16#04#, 16#81#, 16#20#, 16#48#, 16#04#, 16#07#, 16#A2#,
16#19#, 16#02#, 16#40#, 16#10#, 16#03#, 16#00#, 16#3C#, 16#00#, 16#80#,
16#10#, 16#06#, 16#01#, 16#E0#, 16#A7#, 16#C0#, 16#40#, 16#10#, 16#04#,
16#00#, 16#3C#, 16#19#, 16#84#, 16#21#, 16#08#, 16#66#, 16#0F#, 16#00#,
16#0C#, 16#1C#, 16#70#, 16#01#, 16#E0#, 16#CC#, 16#21#, 16#08#, 16#43#,
16#30#, 16#78#, 16#3E#, 16#30#, 16#10#, 16#08#, 16#02#, 16#03#, 16#03#,
16#47#, 16#14#, 16#8A#, 16#43#, 16#11#, 16#8F#, 16#60#, 16#FF#, 16#A4#,
16#90#, 16#05#, 16#25#, 16#24#, 16#92#, 16#48#, 16#92#, 16#24#, 16#11#,
16#24#, 16#89#, 16#24#, 16#92#, 16#92#, 16#90#, 16#00#, 16#04#, 16#02#,
16#11#, 16#07#, 16#F0#, 16#C0#, 16#50#, 16#48#, 16#42#, 16#00#, 16#08#,
16#04#, 16#02#, 16#01#, 16#00#, 16#87#, 16#FC#, 16#20#, 16#10#, 16#08#,
16#04#, 16#02#, 16#00#, 16#3B#, 16#9C#, 16#CE#, 16#62#, 16#00#, 16#FF#,
16#E0#, 16#FF#, 16#80#, 16#00#, 16#80#, 16#C0#, 16#40#, 16#20#, 16#20#,
16#10#, 16#10#, 16#08#, 16#08#, 16#04#, 16#04#, 16#02#, 16#02#, 16#01#,
16#01#, 16#00#, 16#80#, 16#80#, 16#40#, 16#00#, 16#1C#, 16#31#, 16#90#,
16#58#, 16#38#, 16#0C#, 16#06#, 16#03#, 16#01#, 16#80#, 16#C0#, 16#60#,
16#30#, 16#34#, 16#13#, 16#18#, 16#70#, 16#30#, 16#E1#, 16#44#, 16#81#,
16#02#, 16#04#, 16#08#, 16#10#, 16#20#, 16#40#, 16#81#, 16#1F#, 16#C0#,
16#1E#, 16#10#, 16#90#, 16#68#, 16#10#, 16#08#, 16#0C#, 16#04#, 16#04#,
16#04#, 16#06#, 16#06#, 16#06#, 16#06#, 16#0E#, 16#07#, 16#FE#, 16#3E#,
16#10#, 16#40#, 16#08#, 16#02#, 16#00#, 16#80#, 16#40#, 16#E0#, 16#04#,
16#00#, 16#80#, 16#10#, 16#04#, 16#01#, 16#00#, 16#D8#, 16#63#, 16#E0#,
16#06#, 16#0A#, 16#0A#, 16#12#, 16#22#, 16#22#, 16#42#, 16#42#, 16#82#,
16#82#, 16#FF#, 16#02#, 16#02#, 16#02#, 16#0F#, 16#7F#, 16#20#, 16#10#,
16#08#, 16#04#, 16#02#, 16#F1#, 16#8C#, 16#03#, 16#00#, 16#80#, 16#40#,
16#20#, 16#18#, 16#16#, 16#18#, 16#F0#, 16#0F#, 16#8C#, 16#08#, 16#08#,
16#04#, 16#04#, 16#02#, 16#79#, 16#46#, 16#C1#, 16#E0#, 16#60#, 16#28#,
16#14#, 16#19#, 16#08#, 16#78#, 16#FF#, 16#81#, 16#81#, 16#01#, 16#02#,
16#02#, 16#02#, 16#04#, 16#04#, 16#04#, 16#08#, 16#08#, 16#08#, 16#08#,
16#08#, 16#3E#, 16#31#, 16#B0#, 16#70#, 16#18#, 16#0C#, 16#05#, 16#8C#,
16#38#, 16#63#, 16#40#, 16#60#, 16#30#, 16#18#, 16#1B#, 16#18#, 16#F8#,
16#3C#, 16#31#, 16#30#, 16#50#, 16#28#, 16#0C#, 16#0F#, 16#06#, 16#85#,
16#3C#, 16#80#, 16#40#, 16#40#, 16#20#, 16#20#, 16#63#, 16#E0#, 16#FF#,
16#80#, 16#07#, 16#FC#, 16#39#, 16#CE#, 16#00#, 16#00#, 16#06#, 16#33#,
16#18#, 16#C4#, 16#00#, 16#00#, 16#C0#, 16#60#, 16#18#, 16#0C#, 16#06#,
16#01#, 16#80#, 16#0C#, 16#00#, 16#60#, 16#03#, 16#00#, 16#30#, 16#01#,
16#00#, 16#FF#, 16#F0#, 16#00#, 16#00#, 16#0F#, 16#FF#, 16#C0#, 16#06#,
16#00#, 16#30#, 16#01#, 16#80#, 16#18#, 16#01#, 16#80#, 16#C0#, 16#30#,
16#18#, 16#0C#, 16#02#, 16#00#, 16#00#, 16#3E#, 16#60#, 16#A0#, 16#20#,
16#10#, 16#08#, 16#08#, 16#18#, 16#10#, 16#08#, 16#00#, 16#00#, 16#00#,
16#01#, 16#C0#, 16#E0#, 16#1C#, 16#31#, 16#10#, 16#50#, 16#28#, 16#14#,
16#3A#, 16#25#, 16#22#, 16#91#, 16#4C#, 16#A3#, 16#F0#, 16#08#, 16#02#,
16#01#, 16#80#, 16#7C#, 16#3F#, 16#00#, 16#0C#, 16#00#, 16#48#, 16#01#,
16#20#, 16#04#, 16#40#, 16#21#, 16#00#, 16#84#, 16#04#, 16#08#, 16#1F#,
16#E0#, 16#40#, 16#82#, 16#01#, 16#08#, 16#04#, 16#20#, 16#13#, 16#E1#,
16#F0#, 16#FF#, 16#08#, 16#11#, 16#01#, 16#20#, 16#24#, 16#04#, 16#81#,
16#1F#, 16#C2#, 16#06#, 16#40#, 16#68#, 16#05#, 16#00#, 16#A0#, 16#14#,
16#05#, 16#FF#, 16#00#, 16#1E#, 16#48#, 16#74#, 16#05#, 16#01#, 16#80#,
16#20#, 16#08#, 16#02#, 16#00#, 16#80#, 16#20#, 16#04#, 16#01#, 16#01#,
16#30#, 16#87#, 16#C0#, 16#FE#, 16#10#, 16#44#, 16#09#, 16#02#, 16#40#,
16#50#, 16#14#, 16#05#, 16#01#, 16#40#, 16#50#, 16#14#, 16#0D#, 16#02#,
16#41#, 16#3F#, 16#80#, 16#FF#, 16#C8#, 16#09#, 16#01#, 16#20#, 16#04#,
16#00#, 16#88#, 16#1F#, 16#02#, 16#20#, 16#40#, 16#08#, 16#01#, 16#00#,
16#A0#, 16#14#, 16#03#, 16#FF#, 16#C0#, 16#FF#, 16#E8#, 16#05#, 16#00#,
16#A0#, 16#04#, 16#00#, 16#88#, 16#1F#, 16#02#, 16#20#, 16#40#, 16#08#,
16#01#, 16#00#, 16#20#, 16#04#, 16#01#, 16#F0#, 16#00#, 16#1F#, 16#46#,
16#19#, 16#01#, 16#60#, 16#28#, 16#01#, 16#00#, 16#20#, 16#04#, 16#00#,
16#83#, 16#F0#, 16#0B#, 16#01#, 16#20#, 16#23#, 16#0C#, 16#3E#, 16#00#,
16#E1#, 16#D0#, 16#24#, 16#09#, 16#02#, 16#40#, 16#90#, 16#27#, 16#F9#,
16#02#, 16#40#, 16#90#, 16#24#, 16#09#, 16#02#, 16#40#, 16#B8#, 16#70#,
16#FE#, 16#20#, 16#40#, 16#81#, 16#02#, 16#04#, 16#08#, 16#10#, 16#20#,
16#40#, 16#81#, 16#1F#, 16#C0#, 16#0F#, 16#E0#, 16#10#, 16#02#, 16#00#,
16#40#, 16#08#, 16#01#, 16#00#, 16#20#, 16#04#, 16#80#, 16#90#, 16#12#,
16#02#, 16#40#, 16#C6#, 16#30#, 16#7C#, 16#00#, 16#F1#, 16#E4#, 16#0C#,
16#41#, 16#04#, 16#20#, 16#44#, 16#04#, 16#80#, 16#5C#, 16#06#, 16#60#,
16#43#, 16#04#, 16#10#, 16#40#, 16#84#, 16#08#, 16#40#, 16#CF#, 16#07#,
16#F8#, 16#04#, 16#00#, 16#80#, 16#10#, 16#02#, 16#00#, 16#40#, 16#08#,
16#01#, 16#00#, 16#20#, 16#04#, 16#04#, 16#80#, 16#90#, 16#12#, 16#03#,
16#FF#, 16#C0#, 16#E0#, 16#3B#, 16#01#, 16#94#, 16#14#, 16#A0#, 16#A4#,
16#89#, 16#24#, 16#49#, 16#14#, 16#48#, 16#A2#, 16#47#, 16#12#, 16#10#,
16#90#, 16#04#, 16#80#, 16#24#, 16#01#, 16#78#, 16#3C#, 16#E0#, 16#F6#,
16#02#, 16#50#, 16#25#, 16#02#, 16#48#, 16#24#, 16#C2#, 16#44#, 16#24#,
16#22#, 16#43#, 16#24#, 16#12#, 16#40#, 16#A4#, 16#0A#, 16#40#, 16#6F#,
16#06#, 16#0F#, 16#03#, 16#0C#, 16#60#, 16#64#, 16#02#, 16#80#, 16#18#,
16#01#, 16#80#, 16#18#, 16#01#, 16#80#, 16#18#, 16#01#, 16#40#, 16#26#,
16#06#, 16#30#, 16#C0#, 16#F0#, 16#FF#, 16#10#, 16#64#, 16#05#, 16#01#,
16#40#, 16#50#, 16#34#, 16#19#, 16#FC#, 16#40#, 16#10#, 16#04#, 16#01#,
16#00#, 16#40#, 16#3E#, 16#00#, 16#0F#, 16#03#, 16#0C#, 16#60#, 16#64#,
16#02#, 16#80#, 16#18#, 16#01#, 16#80#, 16#18#, 16#01#, 16#80#, 16#18#,
16#01#, 16#40#, 16#26#, 16#06#, 16#30#, 16#C1#, 16#F0#, 16#0C#, 16#01#,
16#F1#, 16#30#, 16#E0#, 16#FF#, 16#04#, 16#18#, 16#40#, 16#C4#, 16#04#,
16#40#, 16#44#, 16#0C#, 16#41#, 16#87#, 16#E0#, 16#43#, 16#04#, 16#10#,
16#40#, 16#84#, 16#04#, 16#40#, 16#4F#, 16#03#, 16#1F#, 16#48#, 16#34#,
16#05#, 16#01#, 16#40#, 16#08#, 16#01#, 16#C0#, 16#0E#, 16#00#, 16#40#,
16#18#, 16#06#, 16#01#, 16#E1#, 16#A7#, 16#C0#, 16#FF#, 16#F0#, 16#86#,
16#10#, 16#82#, 16#00#, 16#40#, 16#08#, 16#01#, 16#00#, 16#20#, 16#04#,
16#00#, 16#80#, 16#10#, 16#02#, 16#00#, 16#40#, 16#7F#, 16#00#, 16#F0#,
16#F4#, 16#02#, 16#40#, 16#24#, 16#02#, 16#40#, 16#24#, 16#02#, 16#40#,
16#24#, 16#02#, 16#40#, 16#24#, 16#02#, 16#40#, 16#22#, 16#04#, 16#30#,
16#C0#, 16#F0#, 16#F8#, 16#7C#, 16#80#, 16#22#, 16#01#, 16#0C#, 16#04#,
16#10#, 16#20#, 16#40#, 16#80#, 16#82#, 16#02#, 16#10#, 16#0C#, 16#40#,
16#12#, 16#00#, 16#48#, 16#01#, 16#A0#, 16#03#, 16#00#, 16#0C#, 16#00#,
16#F8#, 16#7C#, 16#80#, 16#22#, 16#00#, 16#88#, 16#C2#, 16#23#, 16#10#,
16#8E#, 16#42#, 16#29#, 16#09#, 16#24#, 16#24#, 16#90#, 16#91#, 16#41#,
16#85#, 16#06#, 16#14#, 16#18#, 16#70#, 16#60#, 16#80#, 16#F0#, 16#F2#,
16#02#, 16#30#, 16#41#, 16#08#, 16#09#, 16#80#, 16#50#, 16#06#, 16#00#,
16#60#, 16#0D#, 16#00#, 16#88#, 16#10#, 16#C2#, 16#04#, 16#60#, 16#2F#,
16#0F#, 16#F0#, 16#F2#, 16#02#, 16#10#, 16#41#, 16#04#, 16#08#, 16#80#,
16#50#, 16#05#, 16#00#, 16#20#, 16#02#, 16#00#, 16#20#, 16#02#, 16#00#,
16#20#, 16#02#, 16#01#, 16#FC#, 16#FF#, 16#40#, 16#A0#, 16#90#, 16#40#,
16#40#, 16#40#, 16#20#, 16#20#, 16#20#, 16#10#, 16#50#, 16#30#, 16#18#,
16#0F#, 16#FC#, 16#F2#, 16#49#, 16#24#, 16#92#, 16#49#, 16#24#, 16#9C#,
16#80#, 16#60#, 16#10#, 16#08#, 16#02#, 16#01#, 16#00#, 16#40#, 16#20#,
16#08#, 16#04#, 16#01#, 16#00#, 16#80#, 16#20#, 16#10#, 16#04#, 16#02#,
16#00#, 16#80#, 16#40#, 16#E4#, 16#92#, 16#49#, 16#24#, 16#92#, 16#49#,
16#3C#, 16#08#, 16#0C#, 16#09#, 16#0C#, 16#4C#, 16#14#, 16#04#, 16#FF#,
16#FC#, 16#84#, 16#21#, 16#3E#, 16#00#, 16#60#, 16#08#, 16#02#, 16#3F#,
16#98#, 16#28#, 16#0A#, 16#02#, 16#C3#, 16#9F#, 16#30#, 16#E0#, 16#01#,
16#00#, 16#08#, 16#00#, 16#40#, 16#02#, 16#00#, 16#13#, 16#E0#, 16#A0#,
16#86#, 16#02#, 16#20#, 16#09#, 16#00#, 16#48#, 16#02#, 16#40#, 16#13#,
16#01#, 16#14#, 16#1B#, 16#9F#, 16#00#, 16#1F#, 16#4C#, 16#19#, 16#01#,
16#40#, 16#28#, 16#01#, 16#00#, 16#20#, 16#02#, 16#00#, 16#60#, 16#43#,
16#F0#, 16#00#, 16#C0#, 16#08#, 16#01#, 16#00#, 16#20#, 16#04#, 16#3C#,
16#98#, 16#52#, 16#06#, 16#80#, 16#50#, 16#0A#, 16#01#, 16#40#, 16#24#,
16#0C#, 16#C2#, 16#87#, 16#98#, 16#3F#, 16#18#, 16#68#, 16#06#, 16#01#,
16#FF#, 16#E0#, 16#08#, 16#03#, 16#00#, 16#60#, 16#C7#, 16#C0#, 16#0F#,
16#98#, 16#08#, 16#04#, 16#02#, 16#07#, 16#F8#, 16#80#, 16#40#, 16#20#,
16#10#, 16#08#, 16#04#, 16#02#, 16#01#, 16#03#, 16#F8#, 16#1E#, 16#6C#,
16#39#, 16#03#, 16#40#, 16#28#, 16#05#, 16#00#, 16#A0#, 16#12#, 16#06#,
16#61#, 16#43#, 16#C8#, 16#01#, 16#00#, 16#20#, 16#08#, 16#3E#, 16#00#,
16#C0#, 16#10#, 16#04#, 16#01#, 16#00#, 16#40#, 16#13#, 16#87#, 16#11#,
16#82#, 16#40#, 16#90#, 16#24#, 16#09#, 16#02#, 16#40#, 16#90#, 16#2E#,
16#1C#, 16#08#, 16#04#, 16#02#, 16#00#, 16#00#, 16#03#, 16#C0#, 16#20#,
16#10#, 16#08#, 16#04#, 16#02#, 16#01#, 16#00#, 16#80#, 16#43#, 16#FE#,
16#04#, 16#08#, 16#10#, 16#00#, 16#1F#, 16#C0#, 16#81#, 16#02#, 16#04#,
16#08#, 16#10#, 16#20#, 16#40#, 16#81#, 16#02#, 16#0B#, 16#E0#, 16#E0#,
16#02#, 16#00#, 16#20#, 16#02#, 16#00#, 16#20#, 16#02#, 16#3C#, 16#21#,
16#02#, 16#60#, 16#2C#, 16#03#, 16#80#, 16#24#, 16#02#, 16#20#, 16#21#,
16#02#, 16#08#, 16#E1#, 16#F0#, 16#78#, 16#04#, 16#02#, 16#01#, 16#00#,
16#80#, 16#40#, 16#20#, 16#10#, 16#08#, 16#04#, 16#02#, 16#01#, 16#00#,
16#80#, 16#43#, 16#FE#, 16#DC#, 16#E3#, 16#19#, 16#90#, 16#84#, 16#84#,
16#24#, 16#21#, 16#21#, 16#09#, 16#08#, 16#48#, 16#42#, 16#42#, 16#17#,
16#18#, 16#C0#, 16#67#, 16#83#, 16#84#, 16#20#, 16#22#, 16#02#, 16#20#,
16#22#, 16#02#, 16#20#, 16#22#, 16#02#, 16#20#, 16#2F#, 16#07#, 16#1F#,
16#04#, 16#11#, 16#01#, 16#40#, 16#18#, 16#03#, 16#00#, 16#60#, 16#0A#,
16#02#, 16#20#, 16#83#, 16#E0#, 16#CF#, 16#85#, 16#06#, 16#60#, 16#24#,
16#01#, 16#40#, 16#14#, 16#01#, 16#40#, 16#16#, 16#02#, 16#50#, 16#44#,
16#F8#, 16#40#, 16#04#, 16#00#, 16#40#, 16#0F#, 16#00#, 16#1E#, 16#6C#,
16#3B#, 16#03#, 16#40#, 16#28#, 16#05#, 16#00#, 16#A0#, 16#12#, 16#06#,
16#61#, 16#43#, 16#C8#, 16#01#, 16#00#, 16#20#, 16#04#, 16#03#, 16#C0#,
16#E3#, 16#8B#, 16#13#, 16#80#, 16#80#, 16#20#, 16#08#, 16#02#, 16#00#,
16#80#, 16#20#, 16#3F#, 16#80#, 16#1F#, 16#58#, 16#34#, 16#05#, 16#80#,
16#1E#, 16#00#, 16#60#, 16#06#, 16#01#, 16#C0#, 16#AF#, 16#C0#, 16#20#,
16#04#, 16#00#, 16#80#, 16#10#, 16#0F#, 16#F0#, 16#40#, 16#08#, 16#01#,
16#00#, 16#20#, 16#04#, 16#00#, 16#80#, 16#10#, 16#03#, 16#04#, 16#3F#,
16#00#, 16#C1#, 16#C8#, 16#09#, 16#01#, 16#20#, 16#24#, 16#04#, 16#80#,
16#90#, 16#12#, 16#02#, 16#61#, 16#C7#, 16#CC#, 16#F8#, 16#FB#, 16#01#,
16#08#, 16#10#, 16#60#, 16#81#, 16#08#, 16#0C#, 16#40#, 16#22#, 16#01#,
16#20#, 16#05#, 16#00#, 16#30#, 16#00#, 16#F0#, 16#7A#, 16#01#, 16#10#,
16#08#, 16#8C#, 16#42#, 16#62#, 16#12#, 16#A0#, 16#A5#, 16#05#, 16#18#,
16#28#, 16#C0#, 16#86#, 16#00#, 16#78#, 16#F3#, 16#04#, 16#18#, 16#80#,
16#D0#, 16#06#, 16#00#, 16#70#, 16#09#, 16#81#, 16#0C#, 16#20#, 16#6F#,
16#8F#, 16#F0#, 16#F2#, 16#02#, 16#20#, 16#41#, 16#04#, 16#10#, 16#80#,
16#88#, 16#09#, 16#00#, 16#50#, 16#06#, 16#00#, 16#20#, 16#04#, 16#00#,
16#40#, 16#08#, 16#0F#, 16#E0#, 16#FF#, 16#41#, 16#00#, 16#80#, 16#80#,
16#80#, 16#80#, 16#80#, 16#80#, 16#40#, 16#BF#, 16#C0#, 16#19#, 16#08#,
16#42#, 16#10#, 16#84#, 16#64#, 16#18#, 16#42#, 16#10#, 16#84#, 16#20#,
16#C0#, 16#FF#, 16#FF#, 16#C0#, 16#C1#, 16#08#, 16#42#, 16#10#, 16#84#,
16#10#, 16#4C#, 16#42#, 16#10#, 16#84#, 16#26#, 16#00#, 16#38#, 16#13#,
16#38#, 16#38#);
FreeMono12pt7bGlyphs : aliased constant Glyph_Array := (
(0, 0, 0, 14, 0, 1), -- 0x20 ' '
(0, 3, 15, 14, 6, -14), -- 0x21 '!'
(6, 8, 7, 14, 3, -14), -- 0x22 '"'
(13, 10, 16, 14, 2, -14), -- 0x23 '#'
(33, 10, 17, 14, 2, -14), -- 0x24 '$'
(55, 10, 15, 14, 2, -14), -- 0x25 '%'
(74, 9, 12, 14, 3, -11), -- 0x26 '&'
(88, 3, 7, 14, 5, -14), -- 0x27 '''
(91, 3, 18, 14, 7, -14), -- 0x28 '('
(98, 3, 18, 14, 4, -14), -- 0x29 ')'
(105, 9, 9, 14, 3, -14), -- 0x2A '*'
(116, 9, 11, 14, 3, -11), -- 0x2B '+'
(129, 5, 7, 14, 3, -3), -- 0x2C ','
(134, 11, 1, 14, 2, -6), -- 0x2D '-'
(136, 3, 3, 14, 5, -2), -- 0x2E '.'
(138, 9, 18, 14, 3, -15), -- 0x2F '/'
(159, 9, 15, 14, 3, -14), -- 0x30 '0'
(176, 7, 14, 14, 4, -13), -- 0x31 '1'
(189, 9, 15, 14, 2, -14), -- 0x32 '2'
(206, 10, 15, 14, 2, -14), -- 0x33 '3'
(225, 8, 15, 14, 3, -14), -- 0x34 '4'
(240, 9, 15, 14, 3, -14), -- 0x35 '5'
(257, 9, 15, 14, 3, -14), -- 0x36 '6'
(274, 8, 15, 14, 3, -14), -- 0x37 '7'
(289, 9, 15, 14, 3, -14), -- 0x38 '8'
(306, 9, 15, 14, 3, -14), -- 0x39 '9'
(323, 3, 10, 14, 5, -9), -- 0x3A ':'
(327, 5, 13, 14, 3, -9), -- 0x3B ';'
(336, 11, 11, 14, 2, -11), -- 0x3C '<'
(352, 12, 4, 14, 1, -8), -- 0x3D '='
(358, 11, 11, 14, 2, -11), -- 0x3E '>'
(374, 9, 14, 14, 3, -13), -- 0x3F '?'
(390, 9, 16, 14, 3, -14), -- 0x40 '@'
(408, 14, 14, 14, 0, -13), -- 0x41 'A'
(433, 11, 14, 14, 2, -13), -- 0x42 'B'
(453, 10, 14, 14, 2, -13), -- 0x43 'C'
(471, 10, 14, 14, 2, -13), -- 0x44 'D'
(489, 11, 14, 14, 2, -13), -- 0x45 'E'
(509, 11, 14, 14, 2, -13), -- 0x46 'F'
(529, 11, 14, 14, 2, -13), -- 0x47 'G'
(549, 10, 14, 14, 2, -13), -- 0x48 'H'
(567, 7, 14, 14, 4, -13), -- 0x49 'I'
(580, 11, 14, 14, 2, -13), -- 0x4A 'J'
(600, 12, 14, 14, 2, -13), -- 0x4B 'K'
(621, 11, 14, 14, 2, -13), -- 0x4C 'L'
(641, 13, 14, 14, 1, -13), -- 0x4D 'M'
(664, 12, 14, 14, 1, -13), -- 0x4E 'N'
(685, 12, 14, 14, 1, -13), -- 0x4F 'O'
(706, 10, 14, 14, 2, -13), -- 0x50 'P'
(724, 12, 17, 14, 1, -13), -- 0x51 'Q'
(750, 12, 14, 14, 2, -13), -- 0x52 'R'
(771, 10, 14, 14, 2, -13), -- 0x53 'S'
(789, 11, 14, 14, 2, -13), -- 0x54 'T'
(809, 12, 14, 14, 1, -13), -- 0x55 'U'
(830, 14, 14, 14, 0, -13), -- 0x56 'V'
(855, 14, 14, 14, 0, -13), -- 0x57 'W'
(880, 12, 14, 14, 1, -13), -- 0x58 'X'
(901, 12, 14, 14, 1, -13), -- 0x59 'Y'
(922, 9, 14, 14, 3, -13), -- 0x5A 'Z'
(938, 3, 18, 14, 7, -14), -- 0x5B '['
(945, 9, 18, 14, 3, -15), -- 0x5C '\'
(966, 3, 18, 14, 5, -14), -- 0x5D ']'
(973, 9, 6, 14, 3, -14), -- 0x5E '^'
(980, 14, 1, 14, 0, 3), -- 0x5F '_'
(982, 4, 4, 14, 4, -15), -- 0x60 '`'
(984, 10, 10, 14, 2, -9), -- 0x61 'a'
(997, 13, 15, 14, 0, -14), -- 0x62 'b'
(1022, 11, 10, 14, 2, -9), -- 0x63 'c'
(1036, 11, 15, 14, 2, -14), -- 0x64 'd'
(1057, 10, 10, 14, 2, -9), -- 0x65 'e'
(1070, 9, 15, 14, 4, -14), -- 0x66 'f'
(1087, 11, 14, 14, 2, -9), -- 0x67 'g'
(1107, 10, 15, 14, 2, -14), -- 0x68 'h'
(1126, 9, 15, 14, 3, -14), -- 0x69 'i'
(1143, 7, 19, 14, 3, -14), -- 0x6A 'j'
(1160, 12, 15, 14, 1, -14), -- 0x6B 'k'
(1183, 9, 15, 14, 3, -14), -- 0x6C 'l'
(1200, 13, 10, 14, 1, -9), -- 0x6D 'm'
(1217, 12, 10, 14, 1, -9), -- 0x6E 'n'
(1232, 11, 10, 14, 2, -9), -- 0x6F 'o'
(1246, 12, 14, 14, 1, -9), -- 0x70 'p'
(1267, 11, 14, 14, 2, -9), -- 0x71 'q'
(1287, 10, 10, 14, 3, -9), -- 0x72 'r'
(1300, 10, 10, 14, 2, -9), -- 0x73 's'
(1313, 11, 14, 14, 1, -13), -- 0x74 't'
(1333, 11, 10, 14, 2, -9), -- 0x75 'u'
(1347, 13, 10, 14, 1, -9), -- 0x76 'v'
(1364, 13, 10, 14, 1, -9), -- 0x77 'w'
(1381, 12, 10, 14, 1, -9), -- 0x78 'x'
(1396, 12, 14, 14, 1, -9), -- 0x79 'y'
(1417, 9, 10, 14, 3, -9), -- 0x7A 'z'
(1429, 5, 18, 14, 5, -14), -- 0x7B '{'
(1441, 1, 18, 14, 7, -14), -- 0x7C '|'
(1444, 5, 18, 14, 5, -14), -- 0x7D '}'
(1456, 10, 3, 14, 2, -7)); -- 0x7E '~'
Font_D : aliased constant Bitmap_Font :=
(FreeMono12pt7bBitmaps'Access,
FreeMono12pt7bGlyphs'Access,
24);
Font : constant Giza.Font.Ref_Const := Font_D'Access;
end Giza.Bitmap_Fonts.FreeMono12pt7b;
|
with ada.text_io;
use ada.text_io;
package logger is
-- Log le message passé en débug
procedure debug(output : string);
-- Initialise le loggeur
procedure initialize(console : boolean; file : string);
-- Ferme le loggeur
procedure close;
private
-- Afficher le debug sur la console
show_debug : boolean := false;
-- Fichier de log
log_file : file_type;
end logger;
|
-- Lumen.GL -- Lumen's own thin OpenGL bindings
--
-- Chip Richards, NiEstu, Phoenix AZ, Summer 2010
-- This code is covered by the ISC License:
--
-- Copyright © 2010, NiEstu
--
-- Permission to use, copy, modify, and/or distribute this software for any
-- purpose with or without fee is hereby granted, provided that the above
-- copyright notice and this permission notice appear in all copies.
--
-- The software is provided "as is" and the author disclaims all warranties
-- with regard to this software including all implied warranties of
-- merchantability and fitness. In no event shall the author be liable for any
-- special, direct, indirect, or consequential damages or any damages
-- whatsoever resulting from loss of use, data or profits, whether in an
-- action of contract, negligence or other tortious action, arising out of or
-- in connection with the use or performance of this software.
with Interfaces.C.Strings;
package body Lumen.GL is
---------------------------------------------------------------------------
-- Misc stuff
function Get_String (Name : Enum) return String is
use type Interfaces.C.Strings.chars_ptr;
function glGetString (Name : Enum) return Interfaces.C.Strings.chars_ptr;
pragma Import (StdCall, glGetString, "glGetString");
Ptr : constant Interfaces.C.Strings.chars_ptr := glGetString (Name);
begin -- Get_String
if Ptr = Interfaces.C.Strings.Null_Ptr then
return "";
else
return Interfaces.C.Strings.Value (Ptr);
end if;
end Get_String;
function Get_String (Name : Enum;
Index : Int) return String is
use type Interfaces.C.Strings.chars_ptr;
function glGetStringi (Name : Enum;
Index : Int) return Interfaces.C.Strings.chars_ptr;
pragma Import (StdCall, glGetStringi, "glGetStringi");
Ptr : constant Interfaces.C.Strings.chars_ptr :=
glGetStringi (Name, Index);
begin -- Get_String
if Ptr = Interfaces.C.Strings.Null_Ptr then
return "";
else
return Interfaces.C.Strings.Value (Ptr);
end if;
end Get_String;
---------------------------------------------------------------------------
-- Transformations
procedure Rotate (Angle : in Double;
X : in Double;
Y : in Double;
Z : in Double) is
procedure glRotated (Angle : in Double;
X : in Double;
Y : in Double;
Z : in Double);
pragma Import (StdCall, glRotated, "glRotated");
begin -- Rotate
glRotated (Angle, X, Y, Z);
end Rotate;
procedure Rotate (Angle : in Float;
X : in Float;
Y : in Float;
Z : in Float) is
procedure glRotatef (Angle : in Float;
X : in Float;
Y : in Float;
Z : in Float);
pragma Import (StdCall, glRotatef, "glRotatef");
begin -- Rotate
glRotatef (Angle, X, Y, Z);
end Rotate;
procedure Scale (X : in Double;
Y : in Double;
Z : in Double) is
procedure glScaled (X : in Double;
Y : in Double;
Z : in Double);
pragma Import (StdCall, glScaled, "glScaled");
begin -- Scale
glScaled (X, Y, Z);
end Scale;
procedure Scale (X : in Float;
Y : in Float;
Z : in Float) is
procedure glScalef (X : in Float;
Y : in Float;
Z : in Float);
pragma Import (StdCall, glScalef, "glScalef");
begin -- Scale
glScalef (X, Y, Z);
end Scale;
procedure Translate (X : in Double;
Y : in Double;
Z : in Double) is
procedure glTranslated (X : in Double;
Y : in Double;
Z : in Double);
pragma Import (StdCall, glTranslated, "glTranslated");
begin -- Translate
glTranslated (X, Y, Z);
end Translate;
procedure Translate (X : in Float;
Y : in Float;
Z : in Float) is
procedure glTranslatef (X : in Float;
Y : in Float;
Z : in Float);
pragma Import (StdCall, glTranslatef, "glTranslatef");
begin -- Translate
glTranslatef (X, Y, Z);
end Translate;
---------------------------------------------------------------------------
-- Matrix operations
procedure Load_Matrix (M : in Float_Matrix) is
procedure glLoadMatrixf (M : in System.Address);
pragma Import (StdCall, glLoadMatrixf, "glLoadMatrixf");
begin -- LoadMatrix
glLoadMatrixf (M'Address);
end Load_Matrix;
procedure Load_Matrix (M : in Double_Matrix) is
procedure glLoadMatrixd (M : in System.Address);
pragma Import (StdCall, glLoadMatrixd, "glLoadMatrixd");
begin -- LoadMatrix
glLoadMatrixd (M'Address);
end Load_Matrix;
procedure Mult_Matrix (M : in Float_Matrix) is
procedure glMultMatrixf (M : in System.Address);
pragma Import (StdCall, glMultMatrixf, "glMultMatrixf");
begin -- MultMatrix
glMultMatrixf (M'Address);
end Mult_Matrix;
procedure Mult_Matrix (M : in Double_Matrix) is
procedure glMultMatrixd (M : in System.Address);
pragma Import (StdCall, glMultMatrixd, "glMultMatrixd");
begin -- MultMatrix
glMultMatrixd (M'Address);
end Mult_Matrix;
---------------------------------------------------------------------------
-- Component color
procedure Color (Red : in Byte;
Green : in Byte;
Blue : in Byte) is
procedure glColor3b (Red : in Byte;
Green : in Byte;
Blue : in Byte);
pragma Import (StdCall, glColor3b, "glColor3b");
begin -- Color
glColor3b (Red, Green, Blue);
end Color;
procedure Color (Red : in Short;
Green : in Short;
Blue : in Short) is
procedure glColor3s (Red : in Short;
Green : in Short;
Blue : in Short);
pragma Import (StdCall, glColor3s, "glColor3s");
begin -- Color
glColor3s (Red, Green, Blue);
end Color;
procedure Color (Red : in Int;
Green : in Int;
Blue : in Int) is
procedure glColor3i (Red : in Int;
Green : in Int;
Blue : in Int);
pragma Import (StdCall, glColor3i, "glColor3i");
begin -- Color
glColor3i (Red, Green, Blue);
end Color;
procedure Color (Red : in Float;
Green : in Float;
Blue : in Float) is
procedure glColor3f (Red : in Float;
Green : in Float;
Blue : in Float);
pragma Import (StdCall, glColor3f, "glColor3f");
begin -- Color
glColor3f (Red, Green, Blue);
end Color;
procedure Color (Red : in Double;
Green : in Double;
Blue : in Double) is
procedure glColor3d (Red : in Double;
Green : in Double;
Blue : in Double);
pragma Import (StdCall, glColor3d, "glColor3d");
begin -- Color
glColor3d (Red, Green, Blue);
end Color;
procedure Color (Red : in UByte;
Green : in UByte;
Blue : in UByte) is
procedure glColor3ub (Red : in UByte;
Green : in UByte;
Blue : in UByte);
pragma Import (StdCall, glColor3ub, "glColor3ub");
begin -- Color
glColor3ub (Red, Green, Blue);
end Color;
procedure Color (Red : in UShort;
Green : in UShort;
Blue : in UShort) is
procedure glColor3us (Red : in UShort;
Green : in UShort;
Blue : in UShort);
pragma Import (StdCall, glColor3us, "glColor3us");
begin -- Color
glColor3us (Red, Green, Blue);
end Color;
procedure Color (Red : in UInt;
Green : in UInt;
Blue : in UInt) is
procedure glColor3ui (Red : in UInt;
Green : in UInt;
Blue : in UInt);
pragma Import (StdCall, glColor3ui, "glColor3ui");
begin -- Color
glColor3ui (Red, Green, Blue);
end Color;
procedure Color (Red : in Byte;
Green : in Byte;
Blue : in Byte;
Alpha : in Byte) is
procedure glColor4b (Red : in Byte;
Green : in Byte;
Blue : in Byte;
Alpha : in Byte);
pragma Import (StdCall, glColor4b, "glColor4b");
begin -- Color
glColor4b (Red, Green, Blue, Alpha);
end Color;
procedure Color (Red : in Short;
Green : in Short;
Blue : in Short;
Alpha : in Short) is
procedure glColor4s (Red : in Short;
Green : in Short;
Blue : in Short;
Alpha : in Short);
pragma Import (StdCall, glColor4s, "glColor4s");
begin -- Color
glColor4s (Red, Green, Blue, Alpha);
end Color;
procedure Color (Red : in Int;
Green : in Int;
Blue : in Int;
Alpha : in Int) is
procedure glColor4i (Red : in Int;
Green : in Int;
Blue : in Int;
Alpha : in Int);
pragma Import (StdCall, glColor4i, "glColor4i");
begin -- Color
glColor4i (Red, Green, Blue, Alpha);
end Color;
procedure Color (Red : in Float;
Green : in Float;
Blue : in Float;
Alpha : in Float) is
procedure glColor4f (Red : in Float;
Green : in Float;
Blue : in Float;
Alpha : in Float);
pragma Import (StdCall, glColor4f, "glColor4f");
begin -- Color
glColor4f (Red, Green, Blue, Alpha);
end Color;
procedure Color (Red : in Double;
Green : in Double;
Blue : in Double;
Alpha : in Double) is
procedure glColor4d (Red : in Double;
Green : in Double;
Blue : in Double;
Alpha : in Double);
pragma Import (StdCall, glColor4d, "glColor4d");
begin -- Color
glColor4d (Red, Green, Blue, Alpha);
end Color;
procedure Color (Red : in UByte;
Green : in UByte;
Blue : in UByte;
Alpha : in UByte) is
procedure glColor4ub (Red : in UByte;
Green : in UByte;
Blue : in UByte;
Alpha : in UByte);
pragma Import (StdCall, glColor4ub, "glColor4ub");
begin -- Color
glColor4ub (Red, Green, Blue, Alpha);
end Color;
procedure Color (Red : in UShort;
Green : in UShort;
Blue : in UShort;
Alpha : in UShort) is
procedure glColor4us (Red : in UShort;
Green : in UShort;
Blue : in UShort;
Alpha : in UShort);
pragma Import (StdCall, glColor4us, "glColor4us");
begin -- Color
glColor4us (Red, Green, Blue, Alpha);
end Color;
procedure Color (Red : in UInt;
Green : in UInt;
Blue : in UInt;
Alpha : in UInt) is
procedure glColor4ui (Red : in UInt;
Green : in UInt;
Blue : in UInt;
Alpha : in UInt);
pragma Import (StdCall, glColor4ui, "glColor4ui");
begin -- Color
glColor4ui (Red, Green, Blue, Alpha);
end Color;
procedure Color (V : in Bytes_3) is
procedure glColor3bv (V : in Bytes_3);
pragma Import (StdCall, glColor3bv, "glColor3bv");
begin -- Color
glColor3bv (V);
end Color;
procedure Color (V : in Bytes_4) is
procedure glColor4bv (V : in Bytes_4);
pragma Import (StdCall, glColor4bv, "glColor4bv");
begin -- Color
glColor4bv (V);
end Color;
procedure Color (V : in Shorts_3) is
procedure glColor3sv (V : in Shorts_3);
pragma Import (StdCall, glColor3sv, "glColor3sv");
begin -- Color
glColor3sv (V);
end Color;
procedure Color (V : in Shorts_4) is
procedure glColor4sv (V : in Shorts_4);
pragma Import (StdCall, glColor4sv, "glColor4sv");
begin -- Color
glColor4sv (V);
end Color;
procedure Color (V : in Ints_3) is
procedure glColor3iv (V : in Ints_3);
pragma Import (StdCall, glColor3iv, "glColor3iv");
begin -- Color
glColor3iv (V);
end Color;
procedure Color (V : in Ints_4) is
procedure glColor4iv (V : in Ints_4);
pragma Import (StdCall, glColor4iv, "glColor4iv");
begin -- Color
glColor4iv (V);
end Color;
procedure Color (V : in Floats_3) is
procedure glColor3fv (V : in Floats_3);
pragma Import (StdCall, glColor3fv, "glColor3fv");
begin -- Color
glColor3fv (V);
end Color;
procedure Color (V : in Floats_4) is
procedure glColor4fv (V : in Floats_4);
pragma Import (StdCall, glColor4fv, "glColor4fv");
begin -- Color
glColor4fv (V);
end Color;
procedure Color (V : in Doubles_3) is
procedure glColor3dv (V : in Doubles_3);
pragma Import (StdCall, glColor3dv, "glColor3dv");
begin -- Color
glColor3dv (V);
end Color;
procedure Color (V : in Doubles_4) is
procedure glColor4dv (V : in Doubles_4);
pragma Import (StdCall, glColor4dv, "glColor4dv");
begin -- Color
glColor4dv (V);
end Color;
procedure Color (V : in UBytes_3) is
procedure glColor3ubv (V : in UBytes_3);
pragma Import (StdCall, glColor3ubv, "glColor3ubv");
begin -- Color
glColor3ubv (V);
end Color;
procedure Color (V : in UBytes_4) is
procedure glColor4ubv (V : in UBytes_4);
pragma Import (StdCall, glColor4ubv, "glColor4ubv");
begin -- Color
glColor4ubv (V);
end Color;
procedure Color (V : in UShorts_3) is
procedure glColor3usv (V : in UShorts_3);
pragma Import (StdCall, glColor3usv, "glColor3usv");
begin -- Color
glColor3usv (V);
end Color;
procedure Color (V : in UShorts_4) is
procedure glColor4usv (V : in UShorts_4);
pragma Import (StdCall, glColor4usv, "glColor4usv");
begin -- Color
glColor4usv (V);
end Color;
procedure Color (V : in UInts_3) is
procedure glColor3uiv (V : in UInts_3);
pragma Import (StdCall, glColor3uiv, "glColor3uiv");
begin -- Color
glColor3uiv (V);
end Color;
procedure Color (V : in UInts_4) is
procedure glColor4uiv (V : in UInts_4);
pragma Import (StdCall, glColor4uiv, "glColor4uiv");
begin -- Color
glColor4uiv (V);
end Color;
---------------------------------------------------------------------------
-- Lighting and materials
procedure Light (Light : in Enum;
PName : in Enum;
Params : in Int_Params) is
procedure glLightiv (Light : in Enum;
PName : in Enum;
Params : in System.Address);
pragma Import (StdCall, glLightiv, "glLightiv");
begin -- Light
glLightiv (Light, PName, Params (Params'First)'Address);
end Light;
procedure Light (Light : in Enum;
PName : in Enum;
Params : in Float_Params) is
procedure glLightfv (Light : in Enum;
PName : in Enum;
Params : in System.Address);
pragma Import (StdCall, glLightfv, "glLightfv");
begin -- Light
glLightfv (Light, PName, Params (Params'First)'Address);
end Light;
procedure Material (Face : in Enum;
PName : in Enum;
Params : in Int_Params) is
procedure glMaterialiv (Face : in Enum;
PName : in Enum;
Params : in System.Address);
pragma Import (StdCall, glMaterialiv, "glMaterialiv");
begin -- Material
glMaterialiv (Face, PName, Params (Params'First)'Address);
end Material;
procedure Material (Face : in Enum;
PName : in Enum;
Params : in Float_Params) is
procedure glMaterialfv (Face : in Enum;
PName : in Enum;
Params : in System.Address);
pragma Import (StdCall, glMaterialfv, "glMaterialfv");
begin -- Material
glMaterialfv (Face, PName, Params (Params'First)'Address);
end Material;
---------------------------------------------------------------------------
-- Lighting
procedure Light (Light : in Enum; PName : in Enum; Param : in Float) is
procedure glLightf (Light : in Enum;
PName : in Enum;
Param : in Float);
pragma Import (StdCall, glLightf, "glLightf");
begin -- Light
glLightf (Light, PName, Param);
end Light;
procedure Light (Light : in Enum; PName : in Enum; Params : in Floats_1) is
procedure glLightfv (Light : in Enum;
PName : in Enum;
Params : in Floats_1);
pragma Import (StdCall, glLightfv, "glLightfv");
begin -- Light
glLightfv (Light, PName, Params);
end Light;
procedure Light (Light : in Enum; PName : in Enum; Params : in Floats_3) is
procedure glLightfv (Light : in Enum;
PName : in Enum;
Params : in Floats_3);
pragma Import (StdCall, glLightfv, "glLightfv");
begin -- Light
glLightfv (Light, PName, Params);
end Light;
procedure Light (Light : in Enum; PName : in Enum; Params : in Floats_4) is
procedure glLightfv (Light : in Enum;
PName : in Enum;
Params : in Floats_4);
pragma Import (StdCall, glLightfv, "glLightfv");
begin -- Light
glLightfv (Light, PName, Params);
end Light;
procedure Light (Light : in Enum; PName : in Enum; Param : in Int) is
procedure glLighti (Light : in Enum;
PName : in Enum;
Param : in Int);
pragma Import (StdCall, glLighti, "glLighti");
begin -- Light
glLighti (Light, PName, Param);
end Light;
procedure Light (Light : in Enum; PName : in Enum; Params : in Ints_1) is
procedure glLightiv (Light : in Enum;
PName : in Enum;
Params : in Ints_1);
pragma Import (StdCall, glLightiv, "glLightiv");
begin -- Light
glLightiv (Light, PName, Params);
end Light;
procedure Light (Light : in Enum; PName : in Enum; Params : in Ints_3) is
procedure glLightiv (Light : in Enum;
PName : in Enum;
Params : in Ints_3);
pragma Import (StdCall, glLightiv, "glLightiv");
begin -- Light
glLightiv (Light, PName, Params);
end Light;
procedure Light (Light : in Enum; PName : in Enum; Params : in Ints_4) is
procedure glLightiv (Light : in Enum;
PName : in Enum;
Params : in Ints_4);
pragma Import (StdCall, glLightiv, "glLightiv");
begin -- Light
glLightiv (Light, PName, Params);
end Light;
-- Normal Vector
procedure Normal (X, Y, Z : Byte) is
procedure glNormal3b (X, Y, Z : Byte);
pragma Import (StdCall, glNormal3b, "glNormal3b");
begin -- Normal
glNormal3b (X, Y, Z);
end Normal;
procedure Normal (X, Y, Z : Double) is
procedure glNormal3d (X, Y, Z : Double);
pragma Import (StdCall, glNormal3d, "glNormal3d");
begin -- Normal
glNormal3d (X, Y, Z);
end Normal;
procedure Normal (X, Y, Z : Float) is
procedure glNormal3f (X, Y, Z : Float);
pragma Import (StdCall, glNormal3f, "glNormal3f");
begin -- Normal
glNormal3f (X, Y, Z);
end Normal;
procedure Normal (X, Y, Z : Int) is
procedure glNormal3i (X, Y, Z : Int);
pragma Import (StdCall, glNormal3i, "glNormal3i");
begin -- Normal
glNormal3i (X, Y, Z);
end Normal;
procedure Normal (X, Y, Z : Short) is
procedure glNormal3s (X, Y, Z : Short);
pragma Import (StdCall, glNormal3s, "glNormal3s");
begin -- Normal
glNormal3s (X, Y, Z);
end Normal;
procedure Normal (V : Bytes_3) is
procedure glNormal3bv (V : Bytes_3);
pragma Import (StdCall, glNormal3bv, "glNormal3bv");
begin -- Normal
glNormal3bv (V);
end Normal;
procedure Normal (V : Doubles_3) is
procedure glNormal3dv (V : Doubles_3);
pragma Import (StdCall, glNormal3dv, "glNormal3dv");
begin -- Normal
glNormal3dv (V);
end Normal;
procedure Normal (V : Floats_3) is
procedure glNormal3fv (V : Floats_3);
pragma Import (StdCall, glNormal3fv, "glNormal3fv");
begin -- Normal
glNormal3fv (V);
end Normal;
procedure Normal (V : Ints_3) is
procedure glNormal3iv (V : Ints_3);
pragma Import (StdCall, glNormal3iv, "glNormal3iv");
begin -- Normal
glNormal3iv (V);
end Normal;
procedure Normal (V : Shorts_3) is
procedure glNormal3sv (V : Shorts_3);
pragma Import (StdCall, glNormal3sv, "glNormal3sv");
begin -- Normal
glNormal3sv (V);
end Normal;
procedure Tex_Gen (Coord : in Enum;
PName : in Enum;
Param : in Int) is
procedure glTexGeni (Coord : in Enum;
PName : in Enum;
Param : in Int);
pragma Import (StdCall, glTexGeni, "glTexGeni");
begin -- Tex_Gen
glTexGeni (Coord, PName, Param);
end Tex_Gen;
procedure Tex_Gen (Coord : in Enum;
PName : in Enum;
Param : in Float) is
procedure glTexGenf (Coord : in Enum;
PName : in Enum;
Param : in Float);
pragma Import (StdCall, glTexGenf, "glTexGenf");
begin -- Tex_Gen
glTexGenf (Coord, PName, Param);
end Tex_Gen;
procedure Tex_Gen (Coord : in Enum;
PName : in Enum;
Param : in Double) is
procedure glTexGend (Coord : in Enum;
PName : in Enum;
Param : in Double);
pragma Import (StdCall, glTexGend, "glTexGend");
begin -- Tex_Gen
glTexGend (Coord, PName, Param);
end Tex_Gen;
procedure Tex_Parameter (Target : in Enum;
PName : in Enum;
Param : in Enum) is
procedure glTexParameteri (Target : in Enum;
PName : in Enum;
Param : in Enum);
pragma Import (StdCall, glTexParameteri, "glTexParameteri");
begin -- TexParameter
glTexParameteri (Target, PName, Param);
end Tex_Parameter;
procedure Tex_Parameter (Target : in Enum;
PName : in Enum;
Param : in Int) is
procedure glTexParameteri (Target : in Enum;
PName : in Enum;
Param : in Int);
pragma Import (StdCall, glTexParameteri, "glTexParameteri");
begin -- TexParameter
glTexParameteri (Target, PName, Param);
end Tex_Parameter;
procedure Tex_Parameter (Target : in Enum;
PName : in Enum;
Param : in Float) is
procedure glTexParameterf (Target : in Enum;
PName : in Enum;
Param : in Float);
pragma Import (StdCall, glTexParameterf, "glTexParameterf");
begin -- TexParameter
glTexParameterf (Target, PName, Param);
end Tex_Parameter;
-- Texture images
procedure Tex_Image (Target : in Enum;
Level : in Int;
Internal_Format : in Enum;
Width : in SizeI;
Border : in Int;
Format : in Enum;
Pixel_Type : in Enum;
Pixels : in System.Address) is
procedure glTexImage1D (Target : in Enum;
Level : in Int;
Internal_Format : in Enum;
Width : in SizeI;
Border : in Int;
Format : in Enum;
Pixel_Type : in Enum;
Pixels : in System.Address);
pragma Import (StdCall, glTexImage1D, "glTexImage1D");
begin -- TexImage
glTexImage1D (Target,
Level,
Internal_Format,
Width,
Border,
Format,
Pixel_Type,
Pixels);
end Tex_Image;
procedure Tex_Image (Target : in Enum;
Level : in Int;
Internal_Format : in Enum;
Width : in SizeI;
Height : in SizeI;
Border : in Int;
Format : in Enum;
Pixel_Type : in Enum;
Pixels : in System.Address) is
procedure glTexImage2D (Target : in Enum;
Level : in Int;
Internal_Format : in Enum;
Width : in SizeI;
Height : in SizeI;
Border : in Int;
Format : in Enum;
Pixel_Type : in Enum;
Pixels : in System.Address);
pragma Import (StdCall, glTexImage2D, "glTexImage2D");
begin -- TexImage
glTexImage2D (Target,
Level,
Internal_Format,
Width,
Height,
Border,
Format,
Pixel_Type,
Pixels);
end Tex_Image;
procedure Tex_Sub_Image (Target : in Enum;
Level : in Int;
X_Offset : in Int;
Y_Offset : in Int;
Width : in SizeI;
Height : in SizeI;
Format : in Enum;
Pixel_Type : in Enum;
Pixels : in GL.Pointer) is
procedure glTexSubImage2D (Target : in Enum;
Level : in Int;
X_Offset : in Int;
Y_Offset : in Int;
Width : in SizeI;
Height : in SizeI;
Format : in Enum;
Pixel_Type : in Enum;
Pixels : in GL.Pointer);
pragma Import (StdCall, glTexSubImage2D, "glTexSubImage2D");
begin
glTexSubImage2D (Target,
Level,
X_Offset,
Y_Offset,
Width,
Height,
Format,
Pixel_Type,
Pixels);
end Tex_Sub_Image;
-- procedure Tex_Image (Target : in Enum;
-- Level : in Int;
-- Internal_Format : in Int;
-- Width : in SizeI;
-- Height : in SizeI;
-- Depth : in SizeI;
-- Border : in Int;
-- Format : in Enum;
-- Pixel_Type : in Enum;
-- Pixels : in System.Address) is
-- procedure glTexImage3D (Target : in Enum;
-- Level : in Int;
-- Internal_Format : in Int;
-- Width : in SizeI;
-- Height : in SizeI;
-- Depth : in SizeI;
-- Border : in Int;
-- Format : in Enum;
-- Pixel_Type : in Enum;
-- Pixels : in System.Address);
-- pragma Import (StdCall, glTexImage3D, "glTexImage3D");
-- begin -- TexImage
-- glTexImage3D (Target,
-- Level,
-- Internal_Format,
-- Width,
-- Height,
-- Depth,
-- Border,
-- Format,
-- Pixel_Type,
-- Pixels);
-- end Tex_Image;
-- Texture coordinates
procedure Tex_Coord (S : in Short) is
procedure glTexCoord1s (S : in Short);
pragma Import (StdCall, glTexCoord1s, "glTexCoord1s");
begin -- Tex_Coord
glTexCoord1s (S);
end Tex_Coord;
procedure Tex_Coord (S : in Int) is
procedure glTexCoord1i (S : in Int);
pragma Import (StdCall, glTexCoord1i, "glTexCoord1i");
begin -- Tex_Coord
glTexCoord1i (S);
end Tex_Coord;
procedure Tex_Coord (S : in Float) is
procedure glTexCoord1f (S : in Float);
pragma Import (StdCall, glTexCoord1f, "glTexCoord1f");
begin -- Tex_Coord
glTexCoord1f (S);
end Tex_Coord;
procedure Tex_Coord (S : in Double) is
procedure glTexCoord1d (S : in Double);
pragma Import (StdCall, glTexCoord1d, "glTexCoord1d");
begin -- Tex_Coord
glTexCoord1d (S);
end Tex_Coord;
procedure Tex_Coord (S : in Short;
T : in Short) is
procedure glTexCoord2s (S : in Short;
T : in Short);
pragma Import (StdCall, glTexCoord2s, "glTexCoord2s");
begin -- Tex_Coord
glTexCoord2s (S, T);
end Tex_Coord;
procedure Tex_Coord (S : in Int;
T : in Int) is
procedure glTexCoord2i (S : in Int;
T : in Int);
pragma Import (StdCall, glTexCoord2i, "glTexCoord2i");
begin -- Tex_Coord
glTexCoord2i (S, T);
end Tex_Coord;
procedure Tex_Coord (S : in Float;
T : in Float) is
procedure glTexCoord2f (S : in Float;
T : in Float);
pragma Import (StdCall, glTexCoord2f, "glTexCoord2f");
begin -- Tex_Coord
glTexCoord2f (S, T);
end Tex_Coord;
procedure Tex_Coord (S : in Double;
T : in Double) is
procedure glTexCoord2d (S : in Double;
T : in Double);
pragma Import (StdCall, glTexCoord2d, "glTexCoord2d");
begin -- Tex_Coord
glTexCoord2d (S, T);
end Tex_Coord;
procedure Tex_Coord (S : in Short;
T : in Short;
R : in Short) is
procedure glTexCoord3s (S : in Short;
T : in Short;
R : in Short);
pragma Import (StdCall, glTexCoord3s, "glTexCoord3s");
begin -- Tex_Coord
glTexCoord3s (S, T, R);
end Tex_Coord;
procedure Tex_Coord (S : in Int;
T : in Int;
R : in Int) is
procedure glTexCoord3i (S : in Int;
T : in Int;
R : in Int);
pragma Import (StdCall, glTexCoord3i, "glTexCoord3i");
begin -- Tex_Coord
glTexCoord3i (S, T, R);
end Tex_Coord;
procedure Tex_Coord (S : in Float;
T : in Float;
R : in Float) is
procedure glTexCoord3f (S : in Float;
T : in Float;
R : in Float);
pragma Import (StdCall, glTexCoord3f, "glTexCoord3f");
begin -- Tex_Coord
glTexCoord3f (S, T, R);
end Tex_Coord;
procedure Tex_Coord (S : in Double;
T : in Double;
R : in Double) is
procedure glTexCoord3d (S : in Double;
T : in Double;
R : in Double);
pragma Import (StdCall, glTexCoord3d, "glTexCoord3d");
begin -- Tex_Coord
glTexCoord3d (S, T, R);
end Tex_Coord;
procedure Tex_Coord (S : in Short;
T : in Short;
R : in Short;
Q : in Short) is
procedure glTexCoord4s (S : in Short;
T : in Short;
R : in Short;
Q : in Short);
pragma Import (StdCall, glTexCoord4s, "glTexCoord4s");
begin -- Tex_Coord
glTexCoord4s (S, T, R, Q);
end Tex_Coord;
procedure Tex_Coord (S : in Int;
T : in Int;
R : in Int;
Q : in Int) is
procedure glTexCoord4i (S : in Int;
T : in Int;
R : in Int;
Q : in Int);
pragma Import (StdCall, glTexCoord4i, "glTexCoord4i");
begin -- Tex_Coord
glTexCoord4i (S, T, R, Q);
end Tex_Coord;
procedure Tex_Coord (S : in Float;
T : in Float;
R : in Float;
Q : in Float) is
procedure glTexCoord4f (S : in Float;
T : in Float;
R : in Float;
Q : in Float);
pragma Import (StdCall, glTexCoord4f, "glTexCoord4f");
begin -- Tex_Coord
glTexCoord4f (S, T, R, Q);
end Tex_Coord;
procedure Tex_Coord (S : in Double;
T : in Double;
R : in Double;
Q : in Double) is
procedure glTexCoord4d (S : in Double;
T : in Double;
R : in Double;
Q : in Double);
pragma Import (StdCall, glTexCoord4d, "glTexCoord4d");
begin -- Tex_Coord
glTexCoord4d (S, T, R, Q);
end Tex_Coord;
procedure Tex_Coord (V : in Shorts_1) is
procedure glTexCoord1sv (S : in Shorts_1);
pragma Import (StdCall, glTexCoord1sv, "glTexCoord1sv");
begin -- Tex_Coord
glTexCoord1sv (V);
end Tex_Coord;
procedure Tex_Coord (V : in Shorts_2) is
procedure glTexCoord2sv (S : in Shorts_2);
pragma Import (StdCall, glTexCoord2sv, "glTexCoord2sv");
begin -- Tex_Coord
glTexCoord2sv (V);
end Tex_Coord;
procedure Tex_Coord (V : in Shorts_3) is
procedure glTexCoord3sv (S : in Shorts_3);
pragma Import (StdCall, glTexCoord3sv, "glTexCoord3sv");
begin -- Tex_Coord
glTexCoord3sv (V);
end Tex_Coord;
procedure Tex_Coord (V : in Shorts_4) is
procedure glTexCoord4sv (S : in Shorts_4);
pragma Import (StdCall, glTexCoord4sv, "glTexCoord4sv");
begin -- Tex_Coord
glTexCoord4sv (V);
end Tex_Coord;
procedure Tex_Coord (V : in Ints_1) is
procedure glTexCoord1iv (S : in Ints_1);
pragma Import (StdCall, glTexCoord1iv, "glTexCoord1iv");
begin -- Tex_Coord
glTexCoord1iv (V);
end Tex_Coord;
procedure Tex_Coord (V : in Ints_2) is
procedure glTexCoord2iv (S : in Ints_2);
pragma Import (StdCall, glTexCoord2iv, "glTexCoord2iv");
begin -- Tex_Coord
glTexCoord2iv (V);
end Tex_Coord;
procedure Tex_Coord (V : in Ints_3) is
procedure glTexCoord3iv (S : in Ints_3);
pragma Import (StdCall, glTexCoord3iv, "glTexCoord3iv");
begin -- Tex_Coord
glTexCoord3iv (V);
end Tex_Coord;
procedure Tex_Coord (V : in Ints_4) is
procedure glTexCoord4iv (S : in Ints_4);
pragma Import (StdCall, glTexCoord4iv, "glTexCoord4iv");
begin -- Tex_Coord
glTexCoord4iv (V);
end Tex_Coord;
procedure Tex_Coord (V : in Floats_1) is
procedure glTexCoord1fv (S : in Floats_1);
pragma Import (StdCall, glTexCoord1fv, "glTexCoord1fv");
begin -- Tex_Coord
glTexCoord1fv (V);
end Tex_Coord;
procedure Tex_Coord (V : in Floats_2) is
procedure glTexCoord2fv (S : in Floats_2);
pragma Import (StdCall, glTexCoord2fv, "glTexCoord2fv");
begin -- Tex_Coord
glTexCoord2fv (V);
end Tex_Coord;
procedure Tex_Coord (V : in Floats_3) is
procedure glTexCoord3fv (S : in Floats_3);
pragma Import (StdCall, glTexCoord3fv, "glTexCoord3fv");
begin -- Tex_Coord
glTexCoord3fv (V);
end Tex_Coord;
procedure Tex_Coord (V : in Floats_4) is
procedure glTexCoord4fv (S : in Floats_4);
pragma Import (StdCall, glTexCoord4fv, "glTexCoord4fv");
begin -- Tex_Coord
glTexCoord4fv (V);
end Tex_Coord;
procedure Tex_Coord (V : in Doubles_1) is
procedure glTexCoord1dv (S : in Doubles_1);
pragma Import (StdCall, glTexCoord1dv, "glTexCoord1dv");
begin -- Tex_Coord
glTexCoord1dv (V);
end Tex_Coord;
procedure Tex_Coord (V : in Doubles_2) is
procedure glTexCoord2dv (S : in Doubles_2);
pragma Import (StdCall, glTexCoord2dv, "glTexCoord2dv");
begin -- Tex_Coord
glTexCoord2dv (V);
end Tex_Coord;
procedure Tex_Coord (V : in Doubles_3) is
procedure glTexCoord3dv (S : in Doubles_3);
pragma Import (StdCall, glTexCoord3dv, "glTexCoord3dv");
begin -- Tex_Coord
glTexCoord3dv (V);
end Tex_Coord;
procedure Tex_Coord (V : in Doubles_4) is
procedure glTexCoord4dv (S : in Doubles_4);
pragma Import (StdCall, glTexCoord4dv, "glTexCoord4dv");
begin -- Tex_Coord
glTexCoord4dv (V);
end Tex_Coord;
---------------------------------------------------------------------------
procedure Map (Target : in Enum;
U1 : in Float;
U2 : in Float;
Stride : in Int;
Order : in Int;
Points : in System.Address) is
procedure glMap1f (Target : in Enum;
U1 : in Float;
U2 : in Float;
Stride : in Int;
Order : in Int;
Points : in System.Address);
pragma Import (StdCall, glMap1f, "glMap1f");
begin -- Map
glMap1f (Target, U1, U2, Stride, Order, Points);
end Map;
procedure Map (Target : in Enum;
U1 : in Double;
U2 : in Double;
Stride : in Int;
Order : in Int;
Points : in System.Address) is
procedure glMap1d (Target : in Enum;
U1 : in Double;
U2 : in Double;
Stride : in Int;
Order : in Int;
Points : in System.Address);
pragma Import (StdCall, glMap1d, "glMap1d");
begin -- Map
glMap1d (Target, U1, U2, Stride, Order, Points);
end Map;
procedure Map (Target : in Enum;
U1 : in Float;
U2 : in Float;
UStride : in Int;
UOrder : in Int;
V1 : in Float;
V2 : in Float;
VStride : in Int;
VOrder : in Int;
Points : in System.Address) is
procedure glMap2f (Target : in Enum;
U1 : in Float;
U2 : in Float;
UStride : in Int;
UOrder : in Int;
V1 : in Float;
V2 : in Float;
VStride : in Int;
VOrder : in Int;
Points : in System.Address);
pragma Import (StdCall, glMap2f, "glMap2f");
begin -- Map
glMap2f (Target,
U1, U2, UStride, UOrder,
V1, V2, VStride, VOrder,
Points);
end Map;
procedure Map (Target : in Enum;
U1 : in Double;
U2 : in Double;
UStride : in Int;
UOrder : in Int;
V1 : in Double;
V2 : in Double;
VStride : in Int;
VOrder : in Int;
Points : in System.Address) is
procedure glMap2d (Target : in Enum;
U1 : in Double;
U2 : in Double;
UStride : in Int;
UOrder : in Int;
V1 : in Double;
V2 : in Double;
VStride : in Int;
VOrder : in Int;
Points : in System.Address);
pragma Import (StdCall, glMap2d, "glMap2d");
begin -- Map
glMap2d (Target,
U1, U2, UStride, UOrder,
V1, V2, VStride, VOrder,
Points);
end Map;
procedure Map_Grid (Un : in Int;
U1 : in Float;
U2 : in Float) is
procedure glMapGrid1f (Un : in Int;
U1 : in Float;
U2 : in Float);
pragma Import (StdCall, glMapGrid1f, "glMapGrid1f");
begin -- Map_Grid
glMapGrid1f (Un, U1, U2);
end Map_Grid;
procedure Map_Grid (Un : in Int;
U1 : in Double;
U2 : in Double) is
procedure glMapGrid1d (Un : in Int;
U1 : in Double;
U2 : in Double);
pragma Import (StdCall, glMapGrid1d, "glMapGrid1d");
begin -- Map_Grid
glMapGrid1d (Un, U1, U2);
end Map_Grid;
procedure Map_Grid (Un : in Int;
U1 : in Float;
U2 : in Float;
Vn : in Int;
V1 : in Float;
V2 : in Float) is
procedure glMapGrid2f (Un : in Int;
U1 : in Float;
U2 : in Float;
Vn : in Int;
V1 : in Float;
V2 : in Float);
pragma Import (StdCall, glMapGrid2f, "glMapGrid2f");
begin -- Map_Grid
glMapGrid2f (Un, U1, U2, Vn, V1, V2);
end Map_Grid;
procedure Map_Grid (Un : in Int;
U1 : in Double;
U2 : in Double;
Vn : in Int;
V1 : in Double;
V2 : in Double) is
procedure glMapGrid2d (Un : in Int;
U1 : in Double;
U2 : in Double;
Vn : in Int;
V1 : in Double;
V2 : in Double);
pragma Import (StdCall, glMapGrid2d, "glMapGrid2d");
begin -- Map_Grid
glMapGrid2d (Un, U1, U2, Vn, V1, V2);
end Map_Grid;
procedure Eval_Point (I : Int) is
procedure glEvalPoint1 (I : in Int);
pragma Import (StdCall, glEvalPoint1, "glEvalPoint1");
begin -- Eval_Point
glEvalPoint1 (I);
end Eval_Point;
procedure Eval_Point (I : in Int;
J : in Int) is
procedure glEvalPoint2 (I : in Int;
J : in Int);
pragma Import (StdCall, glEvalPoint2, "glEvalPoint2");
begin -- Eval_Point
glEvalPoint2 (I, J);
end Eval_Point;
procedure Eval_Mesh (Mode : in Enum;
I1 : in Int;
I2 : in Int) is
procedure glEvalMesh1 (Mode : in Enum;
I1 : in Int;
I2 : in Int);
pragma Import (StdCall, glEvalMesh1, "glEvalMesh1");
begin -- Eval_Mesh
glEvalMesh1 (Mode, I1, I2);
end Eval_Mesh;
procedure Eval_Mesh (Mode : in Enum;
I1 : in Int;
I2 : in Int;
J1 : in Int;
J2 : in Int) is
procedure glEvalMesh2 (Mode : in Enum;
I1 : in Int;
I2 : in Int;
J1 : in Int;
J2 : in Int);
pragma Import (StdCall, glEvalMesh2, "glEvalMesh2");
begin -- Eval_Mesh
glEvalMesh2 (Mode, I1, I2, J1, J2);
end Eval_Mesh;
---------------------------------------------------------------------------
procedure Vertex (X : in Short;
Y : in Short) is
procedure glVertex2s (X : in Short;
Y : in Short);
pragma Import (StdCall, glVertex2s, "glVertex2s");
begin -- Vertex
glVertex2s (X, Y);
end Vertex;
procedure Vertex (X : in Int;
Y : in Int) is
procedure glVertex2i (X : in Int;
Y : in Int);
pragma Import (StdCall, glVertex2i, "glVertex2i");
begin -- Vertex
glVertex2i (X, Y);
end Vertex;
procedure Vertex (X : in Float;
Y : in Float) is
procedure glVertex2f (X : in Float;
Y : in Float);
pragma Import (StdCall, glVertex2f, "glVertex2f");
begin -- Vertex
glVertex2f (X, Y);
end Vertex;
procedure Vertex (X : in Double;
Y : in Double) is
procedure glVertex2d (X : in Double;
Y : in Double);
pragma Import (StdCall, glVertex2d, "glVertex2d");
begin -- Vertex
glVertex2d (X, Y);
end Vertex;
procedure Vertex (X : in Short;
Y : in Short;
Z : in Short) is
procedure glVertex3s (X : in Short;
Y : in Short;
Z : in Short);
pragma Import (StdCall, glVertex3s, "glVertex3s");
begin -- Vertex
glVertex3s (X, Y, Z);
end Vertex;
procedure Vertex (X : in Int;
Y : in Int;
Z : in Int) is
procedure glVertex3i (X : in Int;
Y : in Int;
Z : in Int);
pragma Import (StdCall, glVertex3i, "glVertex3i");
begin -- Vertex
glVertex3i (X, Y, Z);
end Vertex;
procedure Vertex (X : in Float;
Y : in Float;
Z : in Float) is
procedure glVertex3f (X : in Float;
Y : in Float;
Z : in Float);
pragma Import (StdCall, glVertex3f, "glVertex3f");
begin -- Vertex
glVertex3f (X, Y, Z);
end Vertex;
procedure Vertex (X : in Double;
Y : in Double;
Z : in Double) is
procedure glVertex3d (X : in Double;
Y : in Double;
Z : in Double);
pragma Import (StdCall, glVertex3d, "glVertex3d");
begin -- Vertex
glVertex3d (X, Y, Z);
end Vertex;
procedure Vertex (X : in Short;
Y : in Short;
Z : in Short;
W : in Short) is
procedure glVertex4s (X : in Short;
Y : in Short;
Z : in Short;
W : in Short);
pragma Import (StdCall, glVertex4s, "glVertex4s");
begin -- Vertex
glVertex4s (X, Y, Z, W);
end Vertex;
procedure Vertex (X : in Int;
Y : in Int;
Z : in Int;
W : in Int) is
procedure glVertex4i (X : in Int;
Y : in Int;
Z : in Int;
W : in Int);
pragma Import (StdCall, glVertex4i, "glVertex4i");
begin -- Vertex
glVertex4i (X, Y, Z, W);
end Vertex;
procedure Vertex (X : in Float;
Y : in Float;
Z : in Float;
W : in Float) is
procedure glVertex4f (X : in Float;
Y : in Float;
Z : in Float;
W : in Float);
pragma Import (StdCall, glVertex4f, "glVertex4f");
begin -- Vertex
glVertex4f (X, Y, Z, W);
end Vertex;
procedure Vertex (X : in Double;
Y : in Double;
Z : in Double;
W : in Double) is
procedure glVertex4d (X : in Double;
Y : in Double;
Z : in Double;
W : in Double);
pragma Import (StdCall, glVertex4d, "glVertex4d");
begin -- Vertex
glVertex4d (X, Y, Z, W);
end Vertex;
procedure Vertex (V : in Shorts_2) is
procedure glVertex2sv (V : in Shorts_2);
pragma Import (StdCall, glVertex2sv, "glVertex2sv");
begin -- Vertex
glVertex2sv (V);
end Vertex;
procedure Vertex (V : in Shorts_3) is
procedure glVertex3sv (V : in Shorts_3);
pragma Import (StdCall, glVertex3sv, "glVertex3sv");
begin -- Vertex
glVertex3sv (V);
end Vertex;
procedure Vertex (V : in Shorts_4) is
procedure glVertex4sv (V : in Shorts_4);
pragma Import (StdCall, glVertex4sv, "glVertex4sv");
begin -- Vertex
glVertex4sv (V);
end Vertex;
procedure Vertex (V : in Ints_2) is
procedure glVertex2iv (V : in Ints_2);
pragma Import (StdCall, glVertex2iv, "glVertex2iv");
begin -- Vertex
glVertex2iv (V);
end Vertex;
procedure Vertex (V : in Ints_3) is
procedure glVertex3iv (V : in Ints_3);
pragma Import (StdCall, glVertex3iv, "glVertex3iv");
begin -- Vertex
glVertex3iv (V);
end Vertex;
procedure Vertex (V : in Ints_4) is
procedure glVertex4iv (V : in Ints_4);
pragma Import (StdCall, glVertex4iv, "glVertex4iv");
begin -- Vertex
glVertex4iv (V);
end Vertex;
procedure Vertex (V : in Floats_2) is
procedure glVertex2fv (V : in Floats_2);
pragma Import (StdCall, glVertex2fv, "glVertex2fv");
begin -- Vertex
glVertex2fv (V);
end Vertex;
procedure Vertex (V : in Floats_3) is
procedure glVertex3fv (V : in Floats_3);
pragma Import (StdCall, glVertex3fv, "glVertex3fv");
begin -- Vertex
glVertex3fv (V);
end Vertex;
procedure Vertex (V : in Floats_4) is
procedure glVertex4fv (V : in Floats_4);
pragma Import (StdCall, glVertex4fv, "glVertex4fv");
begin -- Vertex
glVertex4fv (V);
end Vertex;
procedure Vertex (V : in Doubles_2) is
procedure glVertex2dv (V : in Doubles_2);
pragma Import (StdCall, glVertex2dv, "glVertex2dv");
begin -- Vertex
glVertex2dv (V);
end Vertex;
procedure Vertex (V : in Doubles_3) is
procedure glVertex3dv (V : in Doubles_3);
pragma Import (StdCall, glVertex3dv, "glVertex3dv");
begin -- Vertex
glVertex3dv (V);
end Vertex;
procedure Vertex (V : in Doubles_4) is
procedure glVertex4dv (V : in Doubles_4);
pragma Import (StdCall, glVertex4dv, "glVertex4dv");
begin -- Vertex
glVertex4dv (V);
end Vertex;
---------------------------------------------------------------------------
procedure Vertex_Pointer (Size : in SizeI;
Element_Type : in Enum;
Stride : in SizeI;
Data_Pointer : in Pointer) is
procedure glVertexPointer (Size : in SizeI;
Element_Type : in Enum;
Stride : in SizeI;
Data_Pointer : in System.Address);
pragma Import (StdCall, glVertexPointer, "glVertexPointer");
begin
glVertexPointer (Size, Element_Type, Stride, Data_Pointer);
end Vertex_Pointer;
procedure Vertex_Pointer (Size : in SizeI;
Element_Type : in Enum;
Stride : in SizeI;
Offset : in SizeI) is
procedure glVertexPointer (Size : in SizeI;
Element_Type : in Enum;
Stride : in SizeI;
Offset : in SizeI);
pragma Import (StdCall, glVertexPointer, "glVertexPointer");
begin
glVertexPointer (Size, Element_Type, Stride, Offset);
end Vertex_Pointer;
---------------------------------------------------------------------------
-- Shader variables
function Get_Uniform_Location (Program : UInt; Name : String) return Int is
C_Name : Interfaces.C.char_array := Interfaces.C.To_C (Name);
function glGetUniformLocation (Program : UInt;
Name : Pointer) return Int;
pragma Import (StdCall, glGetUniformLocation, "glGetUniformLocation");
begin -- Get_Uniform_Location
return glGetUniformLocation (Program, C_Name'Address);
end Get_Uniform_Location;
procedure Uniform (Location : in Int;
V0 : in Float) is
procedure glUniform1f (Location : in Int;
V0 : in Float);
pragma Import (StdCall, glUniform1f, "glUniform1f");
begin -- Uniform
glUniform1f (Location, V0);
end Uniform;
procedure Uniform (Location : in Int;
V0 : in Float;
V1 : in Float) is
procedure glUniform2f (Location : in Int;
V0 : in Float;
V1 : in Float);
pragma Import (StdCall, glUniform2f, "glUniform2f");
begin -- Uniform
glUniform2f (Location, V0, V1);
end Uniform;
procedure Uniform (Location : in Int;
V0 : in Float;
V1 : in Float;
V2 : in Float) is
procedure glUniform3f (Location : in Int;
V0 : in Float;
V1 : in Float;
V2 : in Float);
pragma Import (StdCall, glUniform3f, "glUniform3f");
begin -- Uniform
glUniform3f (Location, V0, V1, V2);
end Uniform;
procedure Uniform (Location : in Int;
V0 : in Float;
V1 : in Float;
V2 : in Float;
V3 : in Float) is
procedure glUniform4f (Location : in Int;
V0 : in Float;
V1 : in Float;
V2 : in Float;
V3 : in Float);
pragma Import (StdCall, glUniform4f, "glUniform4f");
begin -- Uniform
glUniform4f (Location, V0, V1, V2, V3);
end Uniform;
procedure Uniform (Location : in Int;
V0 : in Int) is
procedure glUniform1i (Location : in Int;
V0 : in Int);
pragma Import (StdCall, glUniform1i, "glUniform1i");
begin -- Uniform
glUniform1i (Location, V0);
end Uniform;
procedure Uniform (Location : in Int;
V0 : in Int;
V1 : in Int) is
procedure glUniform2i (Location : in Int;
V0 : in Int;
V1 : in Int);
pragma Import (StdCall, glUniform2i, "glUniform2i");
begin -- Uniform
glUniform2i (Location, V0, V1);
end Uniform;
procedure Uniform (Location : in Int;
V0 : in Int;
V1 : in Int;
V2 : in Int) is
procedure glUniform3i (Location : in Int;
V0 : in Int;
V1 : in Int;
V2 : in Int);
pragma Import (StdCall, glUniform3i, "glUniform3i");
begin -- Uniform
glUniform3i (Location, V0, V1, V2);
end Uniform;
procedure Uniform (Location : in Int;
V0 : in Int;
V1 : in Int;
V2 : in Int;
V3 : in Int) is
procedure glUniform4i (Location : in Int;
V0 : in Int;
V1 : in Int;
V2 : in Int;
V3 : in Int);
pragma Import (StdCall, glUniform4i, "glUniform4i");
begin -- Uniform
glUniform4i (Location, V0, V1, V2, V3);
end Uniform;
procedure Uniform (Location : in Int;
V0 : in UInt) is
procedure glUniform1ui (Location : in Int;
V0 : in UInt);
pragma Import (StdCall, glUniform1ui, "glUniform1ui");
begin -- Uniform
glUniform1ui (Location, V0);
end Uniform;
procedure Uniform (Location : in Int;
V0 : in UInt;
V1 : in UInt) is
procedure glUniform2ui (Location : in Int;
V0 : in UInt;
V1 : in UInt);
pragma Import (StdCall, glUniform2ui, "glUniform2ui");
begin -- Uniform
glUniform2ui (Location, V0, V1);
end Uniform;
procedure Uniform (Location : in Int;
V0 : in UInt;
V1 : in UInt;
V2 : in UInt) is
procedure glUniform3ui (Location : in Int;
V0 : in UInt;
V1 : in UInt;
V2 : in UInt);
pragma Import (StdCall, glUniform3ui, "glUniform3ui");
begin -- Uniform
glUniform3ui (Location, V0, V1, V2);
end Uniform;
procedure Uniform (Location : in Int;
V0 : in UInt;
V1 : in UInt;
V2 : in UInt;
V3 : in UInt) is
procedure glUniform4ui (Location : in Int;
V0 : in UInt;
V1 : in UInt;
V2 : in UInt;
V3 : in UInt);
pragma Import (StdCall, glUniform4ui, "glUniform4ui");
begin -- Uniform
glUniform4ui (Location, V0, V1, V2, V3);
end Uniform;
procedure Uniform (Location : in Int;
Count : in SizeI;
Transpose : in Bool;
Value : in Float_Matrix) is
procedure glUniformMatrix4fv (Location : in Int;
Count : in SizeI;
Transpose : in Bool;
Value : in Pointer);
pragma Import (StdCall, glUniformMatrix4fv, "glUniformMatrix4fv");
begin
glUniformMatrix4fv (Location, Count, Transpose, Value'Address);
end Uniform;
function Get_Attribute_Location (Program : UInt;
Name : String) return Int is
C_Name : Interfaces.C.char_array := Interfaces.C.To_C (Name);
function glGetAttribLocation (Program : UInt; Name : Pointer) return Int;
pragma Import (StdCall, glGetAttribLocation, "glGetAttribLocation");
begin -- Get_Attribute_Location
return glGetAttribLocation (Program, C_Name'Address);
end Get_Attribute_Location;
procedure Vertex_Attrib (Index : in UInt;
X : in Float) is
procedure glVertexAttrib1f (Index : in UInt;
X : in Float);
pragma Import (StdCall, glVertexAttrib1f, "glVertexAttrib1f");
begin
glVertexAttrib1f (Index, X);
end Vertex_Attrib;
procedure Vertex_Attrib (Index : in UInt;
X : in Float;
Y : in Float) is
procedure glVertexAttrib2f (Index : in UInt;
X : in Float;
Y : in Float);
pragma Import (StdCall, glVertexAttrib2f, "glVertexAttrib2f");
begin
glVertexAttrib2f (Index, X, Y);
end Vertex_Attrib;
procedure Vertex_Attrib (Index : in UInt;
X : in Float;
Y : in Float;
Z : in Float) is
procedure glVertexAttrib3f (Index : in UInt;
X : in Float;
Y : in Float;
Z : in Float);
pragma Import (StdCall, glVertexAttrib3f, "glVertexAttrib3f");
begin
glVertexAttrib3f (Index, X, Y, Z);
end Vertex_Attrib;
procedure Vertex_Attrib (Index : in UInt;
X : in Float;
Y : in Float;
Z : in Float;
W : in Float) is
procedure glVertexAttrib4f (Index : in UInt;
X : in Float;
Y : in Float;
Z : in Float;
W : in Float);
pragma Import (StdCall, glVertexAttrib4f, "glVertexAttrib4f");
begin
glVertexAttrib4f (Index, X, Y, Z, W);
end Vertex_Attrib;
procedure Get_Double (Pname : in Enum;
Params : out Double_Matrix)
is
procedure glGetDoublev (Pname : in Enum;
Params : in Pointer);
pragma Import (StdCall, glGetDoublev, "glGetDoublev");
begin
glGetDoublev (Pname, Params'Address);
end Get_Double;
---------------------------------------------------------------------------
end Lumen.GL;
|
with Interfaces.C;
with System;
package C is
-- ****************************************
-- Types corresponding to C built-in types:
-- ****************************************
subtype char is Interfaces.C.char;
subtype signed_char is Interfaces.C.signed_char;
subtype unsigned_char is Interfaces.C.unsigned_char;
subtype short is Interfaces.C.short;
subtype unsigned_short is Interfaces.C.unsigned_short;
subtype int is Interfaces.C.int;
subtype natural_int is int range 0 .. int'Last; -- array indices
subtype unsigned_int is Interfaces.C.unsigned;
subtype long is Interfaces.C.long;
subtype unsigned_long is Interfaces.C.unsigned_long;
subtype float is Interfaces.C.C_float;
subtype double is Interfaces.C.double;
-- subtype charp is X.Strings.charp;
type charp is access all char;
-- subtype const_charp is X.Strings.const_charp;
type const_charp is access constant char;
nul : Interfaces.C.char renames Interfaces.C.nul;
subtype ptrdiff_t is Interfaces.C.ptrdiff_t;
subtype size_t is Interfaces.C.size_t;
-- **************************************************
-- Array types, moved up here so the type definitions
-- can be shared between packages.
-- **************************************************
subtype char_array is Interfaces.C.char_array;
type unsigned_char_array is array (natural_int range <>) of unsigned_char;
type short_array is array (natural_int range <>) of short;
type unsigned_short_array is array (natural_int range <>) of unsigned_short;
type int_array is array (natural_int range <>) of int;
type unsigned_int_array is array (natural_int range <>) of unsigned_int;
type long_array is array (natural_int range <>) of long;
type unsigned_long_array is array (natural_int range <>) of unsigned_long;
type float_array is array (natural_int range <>) of float;
type double_array is array (natural_int range <>) of double;
function "&" (S : char_array; C : char) return char_array
renames Interfaces.C."&";
-- *******************************************************
-- Allocate new nul-terminated strings and return pointers
-- *******************************************************
-- function New_String (S: String) return charp
-- renames X.Strings.New_String;
-- function New_String (S: String) return const_charp
-- renames X.Strings.New_String;
-- *************************************************
-- Map C untyped "void *" pointers to System.Address
-- *************************************************
subtype Void_Star is System.Address;
type function_pointer is access procedure; -- untyped
-- *********************************************************
-- In C, a variable-size array is declared as a[1] or
-- a[ANYSIZE_ARRAY], where ANYSIZE_ARRAY is defined as 1.
-- Then it is used as if it were bigger.
-- In Ada we declare it as array (0..ANYSIZE_ARRAY) and then
-- use the extensible array package.
-- In C ANYSIZE_ARRAY is 1 and in Ada it is 0.
-- *********************************************************
ANYSIZE_ARRAY : constant := 0; -- winnt.h:26
-- ****************************************************
-- Types moved up here, to break circular dependencies,
-- and to remove duplicate definitions:
-- ****************************************************
type int_access is access all int;
type unsigned_long_access is access all unsigned_long;
type unsigned_char_access is access all unsigned_char;
type const_unsigned_char_access is access constant unsigned_char;
type wchar_access is access all Interfaces.C.wchar_t; -- wchar *
type wchar_access_access is access all wchar_access; -- wchar **
-- *********************
-- bit fields in records
-- *********************
type bits1 is mod 2 ** 1; for bits1'Size use 1;
type bits2 is mod 2 ** 2; for bits2'Size use 2;
type bits3 is mod 2 ** 3; for bits3'Size use 3;
type bits4 is mod 2 ** 4; for bits4'Size use 4;
type bits5 is mod 2 ** 5; for bits5'Size use 5;
type bits6 is mod 2 ** 6; for bits6'Size use 6;
type bits7 is mod 2 ** 7; for bits7'Size use 7;
type bits8 is mod 2 ** 8; for bits8'Size use 8;
type bits9 is mod 2 ** 9; for bits9'Size use 9;
type bits10 is mod 2 ** 10; for bits10'Size use 10;
type bits11 is mod 2 ** 11; for bits11'Size use 11;
type bits12 is mod 2 ** 12; for bits12'Size use 12;
type bits13 is mod 2 ** 13; for bits13'Size use 13;
type bits14 is mod 2 ** 14; for bits14'Size use 14;
type bits15 is mod 2 ** 15; for bits15'Size use 15;
type bits16 is mod 2 ** 16; for bits16'Size use 16;
type bits17 is mod 2 ** 17; for bits17'Size use 17;
type bits18 is mod 2 ** 18; for bits18'Size use 18;
type bits19 is mod 2 ** 19; for bits19'Size use 19;
type bits20 is mod 2 ** 20; for bits20'Size use 20;
type bits21 is mod 2 ** 21; for bits21'Size use 21;
type bits22 is mod 2 ** 22; for bits22'Size use 22;
type bits23 is mod 2 ** 23; for bits23'Size use 23;
type bits24 is mod 2 ** 24; for bits24'Size use 24;
type bits25 is mod 2 ** 25; for bits25'Size use 25;
type bits26 is mod 2 ** 26; for bits26'Size use 26;
type bits27 is mod 2 ** 27; for bits27'Size use 27;
type bits28 is mod 2 ** 28; for bits28'Size use 28;
type bits29 is mod 2 ** 29; for bits29'Size use 29;
type bits30 is mod 2 ** 30; for bits30'Size use 30;
type bits31 is mod 2 ** 31; for bits31'Size use 31;
type bits32 is mod 2 ** 32; for bits32'Size use 32;
-- *********************************************
-- Support function for C macros and expressions
-- *********************************************
function Sizeof (Bits : Integer) return int;
function Bool_to_Int (Val : Boolean) return int;
procedure Call (Ignored_Function_Result : int);
procedure Call (Ignored_Function_Result : charp);
function To_C (C : Character) return Interfaces.C.char;
function "+" (C : char; I : int) return char;
pragma Inline ("+");
function "+" (C : char; I : int) return int;
pragma Inline ("+");
private
pragma Inline (Sizeof);
pragma Inline (Bool_to_Int);
pragma Inline (Call);
pragma Inline (To_C);
end C;
|
-- SPDX-License-Identifier: Apache-2.0
--
-- Copyright (c) 2012 Felix Krause <contact@flyx.org>
--
-- Licensed under the Apache License, Version 2.0 (the "License");
-- you may not use this file except in compliance with the License.
-- You may obtain a copy of the License at
--
-- http://www.apache.org/licenses/LICENSE-2.0
--
-- Unless required by applicable law or agreed to in writing, software
-- distributed under the License is distributed on an "AS IS" BASIS,
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-- See the License for the specific language governing permissions and
-- limitations under the License.
with Interfaces.C.Strings;
with Ada.Unchecked_Conversion;
with GL.API;
with GL.Enums;
with GL.Low_Level;
with GL.Objects.Programs.Uniforms;
package body GL.Objects.Programs is
procedure Attach (Subject : Program; Shader : Shaders.Shader) is
begin
API.Attach_Shader.Ref (Subject.Reference.GL_Id, Shader.Raw_Id);
end Attach;
procedure Detach (Subject : Program; Shader : Shaders.Shader) is
begin
API.Detach_Shader.Ref (Subject.Reference.GL_Id, Shader.Raw_Id);
end Detach;
procedure Link (Subject : Program) is
begin
API.Link_Program.Ref (Subject.Reference.GL_Id);
end Link;
function Link_Status (Subject : Program) return Boolean is
Status_Value : Int := 0;
begin
API.Get_Program_Param.Ref
(Subject.Reference.GL_Id, Enums.Link_Status, Status_Value);
return Status_Value /= 0;
end Link_Status;
function Info_Log (Subject : Program) return String is
Log_Length : Size := 0;
begin
API.Get_Program_Param.Ref
(Subject.Reference.GL_Id, Enums.Info_Log_Length, Log_Length);
if Log_Length = 0 then
return "";
end if;
declare
Info_Log : String (1 .. Integer (Log_Length));
begin
API.Get_Program_Info_Log.Ref
(Subject.Reference.GL_Id, Log_Length, Log_Length, Info_Log);
return Info_Log (1 .. Integer (Log_Length));
end;
end Info_Log;
procedure Use_Program (Subject : Program) is
begin
API.Use_Program.Ref (Subject.Reference.GL_Id);
end Use_Program;
procedure Set_Separable (Subject : Program; Separable : Boolean) is
begin
API.Program_Parameter_Bool.Ref (Subject.Reference.GL_Id, Enums.Program_Separable,
Low_Level.Bool (Separable));
end Set_Separable;
function Separable (Subject : Program) return Boolean is
Separable_Value : Int := 0;
begin
API.Get_Program_Param.Ref
(Subject.Reference.GL_Id, Enums.Program_Separable, Separable_Value);
return Separable_Value /= 0;
end Separable;
function Compute_Work_Group_Size (Object : Program) return Compute.Dimension_Size_Array is
Values : Compute.Dimension_Size_Array := (others => 0);
begin
API.Get_Program_Param_Compute.Ref
(Object.Reference.GL_Id, Enums.Compute_Work_Group_Size, Values);
return Values;
end Compute_Work_Group_Size;
overriding
procedure Initialize_Id (Object : in out Program) is
begin
Object.Reference.GL_Id := API.Create_Program.Ref.all;
end Initialize_Id;
procedure Initialize_Id
(Object : in out Program;
Kind : Shaders.Shader_Type;
Source : String)
is
C_Shader_Source : C.Strings.chars_ptr := C.Strings.New_String (Source);
C_Source : constant Low_Level.CharPtr_Array
:= (1 => C_Shader_Source);
begin
Object.Reference.GL_Id := API.Create_Shader_Program.Ref (Kind, 1, C_Source);
C.Strings.Free (C_Shader_Source);
end Initialize_Id;
overriding
procedure Delete_Id (Object : in out Program) is
begin
API.Delete_Program.Ref (Object.Reference.GL_Id);
Object.Reference.GL_Id := 0;
end Delete_Id;
function Uniform_Location (Subject : Program; Name : String)
return Uniforms.Uniform is
Result : constant Int := API.Get_Uniform_Location.Ref
(Subject.Reference.GL_Id, Interfaces.C.To_C (Name));
begin
if Result = -1 then
raise Uniform_Inactive_Error with "Uniform " & Name & " is inactive (unused)";
end if;
return Uniforms.Create_Uniform (Subject, Result);
end Uniform_Location;
function Buffer_Binding
(Object : Program;
Target : Buffers.Indexed_Buffer_Target;
Name : String) return Size
is
Index : UInt;
Iface : Enums.Program_Interface;
use all type Buffers.Indexed_Buffer_Target;
begin
case Target is
when Shader_Storage =>
Index := API.Get_Program_Resource_Index.Ref
(Object.Reference.GL_Id, Enums.Shader_Storage_Block, Interfaces.C.To_C (Name));
Iface := Enums.Shader_Storage_Block;
when Uniform =>
Index := API.Get_Program_Resource_Index.Ref
(Object.Reference.GL_Id, Enums.Uniform_Block, Interfaces.C.To_C (Name));
Iface := Enums.Uniform_Block;
when Atomic_Counter =>
Index := API.Get_Program_Resource_Index.Ref
(Object.Reference.GL_Id, Enums.Uniform, Interfaces.C.To_C (Name));
Iface := Enums.Atomic_Counter_Buffer;
if Index = -1 then
raise Uniform_Inactive_Error with "Uniform " & Name & " is inactive (unused)";
end if;
declare
Values : constant Int_Array := API.Get_Program_Resource.Ref
(Object.Reference.GL_Id, Enums.Uniform, Index,
1, (1 => Enums.Atomic_Counter_Buffer_Index), 1);
begin
Index := (if Values'Length > 0 then UInt (Values (Values'First)) else -1);
end;
end case;
if Index = -1 then
raise Uniform_Inactive_Error with "Buffer " & Name & " is inactive (unused)";
end if;
declare
Values : constant Int_Array := API.Get_Program_Resource.Ref
(Object.Reference.GL_Id, Iface, Index,
1, (1 => Enums.Buffer_Binding), 1);
begin
return Size (Values (Values'First));
end;
end Buffer_Binding;
function Uniform_Type (Object : Program; Name : String)
return Low_Level.Enums.Resource_Type is
Index : constant UInt := API.Get_Program_Resource_Index.Ref
(Object.Reference.GL_Id, Enums.Uniform, Interfaces.C.To_C (Name));
begin
if Index = -1 then
raise Uniform_Inactive_Error with "Uniform " & Name & " is inactive (unused)";
end if;
declare
Values : constant Int_Array := API.Get_Program_Resource.Ref
(Object.Reference.GL_Id, Enums.Uniform, Index,
1, (1 => Enums.Resource_Type), 1);
function Convert is new Ada.Unchecked_Conversion
(Source => Int, Target => Low_Level.Enums.Resource_Type);
begin
return Convert (Values (Values'First));
end;
end Uniform_Type;
end GL.Objects.Programs;
|
-----------------------------------------------------------------------
-- akt-commands-password -- Add/Change/Remove the wallet password
-- Copyright (C) 2019 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 Keystore.Passwords.Files;
with Keystore.Passwords.Unsafe;
with Keystore.Passwords.Input;
package body AKT.Commands.Password is
package KP renames Keystore.Passwords;
use GNAT.Strings;
use type Keystore.Passwords.Provider_Access;
use type Keystore.Header_Slot_Count_Type;
-- ------------------------------
-- Create the keystore file.
-- ------------------------------
overriding
procedure Execute (Command : in out Command_Type;
Name : in String;
Args : in Argument_List'Class;
Context : in out Context_Type) is
pragma Unreferenced (Name);
Config : Keystore.Wallet_Config := Keystore.Secure_Config;
New_Password_Provider : Keystore.Passwords.Provider_Access;
begin
Setup_Password_Provider (Context);
Setup_Key_Provider (Context);
if Command.Counter_Range /= null and then Command.Counter_Range'Length > 0 then
Parse_Range (Command.Counter_Range.all, Config);
end if;
if Command.Gpg_User'Length > 0 then
declare
GPG : Keystore.Passwords.GPG.Context_Type;
begin
AKT.Commands.Initialize (GPG);
GPG.Create_Secret (Context.Key_Provider.all);
Context.Change_Password (Args => Args,
New_Password => GPG,
Config => Config,
Mode => Command.Mode);
GPG.Save_Secret (User => Command.Gpg_User.all,
Index => Context.Info.Header_Count + 1,
Wallet => Context.Wallet);
end;
else
if Context.Provider = null then
Context.Provider := KP.Input.Create (-("Enter password: "), False);
end if;
if Command.Password_File'Length > 0 then
New_Password_Provider := KP.Files.Create (Command.Password_File.all);
elsif Command.Unsafe_Password'Length > 0 then
New_Password_Provider := KP.Unsafe.Create (Command.Unsafe_Password.all);
else
New_Password_Provider := KP.Input.Create (-("New password: "), False);
end if;
Context.Change_Password (Args => Args,
New_Password => New_Password_Provider.all,
Config => Config,
Mode => Command.Mode);
end if;
end Execute;
-- ------------------------------
-- Setup the command before parsing the arguments and executing it.
-- ------------------------------
procedure Setup (Command : in out Command_Type;
Config : in out GNAT.Command_Line.Command_Line_Configuration;
Context : in out Context_Type) is
package GC renames GNAT.Command_Line;
begin
Setup (Config, Context);
GC.Define_Switch (Config => Config,
Output => Command.Counter_Range'Access,
Switch => "-c:",
Long_Switch => "--counter-range:",
Argument => "RANGE",
Help => -("Set the range for the PBKDF2 counter"));
GC.Define_Switch (Config => Config,
Output => Command.Password_File'Access,
Long_Switch => "--new-passfile=",
Argument => "PATH",
Help => -("Read the file that contains the password"));
GC.Define_Switch (Config => Config,
Output => Command.Unsafe_Password'Access,
Long_Switch => "--new-passfd=",
Argument => "NUM",
Help => -("Read the password from the pipe with"
& " the given file descriptor"));
GC.Define_Switch (Config => Config,
Output => Command.Unsafe_Password'Access,
Long_Switch => "--new-passsocket=",
Help => -("The password is passed within the socket connection"));
GC.Define_Switch (Config => Config,
Output => Command.Password_Env'Access,
Long_Switch => "--new-passenv=",
Argument => "NAME",
Help => -("Read the environment variable that contains"
& " the password (not safe)"));
GC.Define_Switch (Config => Config,
Output => Command.Unsafe_Password'Access,
Long_Switch => "--new-password=",
Help => -("The password is passed within the command line (not safe)"));
GC.Define_Switch (Config => Config,
Output => Command.Gpg_User'Access,
Switch => "-g:",
Long_Switch => "--gpg=",
Argument => "USER",
Help => -("Use gpg to protect the keystore access"));
end Setup;
end AKT.Commands.Password;
|
with Ada.Text_IO; use Ada.Text_IO;
with System.Storage_Elements; use System.Storage_Elements;
with BBqueue;
with BBqueue.Buffers;
with System; use System;
procedure Main_Buffer
with SPARK_Mode
is
use type BBqueue.Result_Kind;
Q : aliased BBqueue.Buffers.Buffer (35);
procedure Fill (WG : BBqueue.Buffers.Write_Grant;
Val : Storage_Element)
with Pre => BBqueue.Buffers.State (WG) = BBqueue.Valid;
procedure Fill_With_CB (Size : BBqueue.Count;
Val : Storage_Element);
procedure Print_Content (RG : BBqueue.Buffers.Read_Grant)
with Pre => BBqueue.Buffers.State (RG) = BBqueue.Valid;
procedure Print_Content_With_CB;
----------
-- Fill --
----------
procedure Fill (WG : BBqueue.Buffers.Write_Grant;
Val : Storage_Element)
is
pragma SPARK_Mode (Off);
S : constant BBqueue.Buffers.Slice_Rec := BBqueue.Buffers.Slice (WG);
Arr : Storage_Array (1 .. S.Length) with Address => S.Addr;
begin
Put_Line ("Fill" & S.Length'Img & " bytes.");
Arr := (others => Val);
end Fill;
------------------
-- Fill_With_CB --
------------------
procedure Fill_With_CB (Size : BBqueue.Count; Val : Storage_Element) is
pragma SPARK_Mode (Off);
procedure Process_Write (Data : out Storage_Array; To_Commit : out BBqueue.Count);
procedure Process_Write (Data : out Storage_Array; To_Commit : out BBqueue.Count) is
begin
Put_Line ("Fill" & Data'Length'Img & " bytes.");
Data := (others => Val);
To_Commit := Data'Length;
end Process_Write;
procedure Write is new BBqueue.Buffers.Write_CB (Process_Write);
Result : BBqueue.Result_Kind;
begin
Write (Q, Size, Result);
if Result /= BBqueue.Valid then
Put_Line ("Write failed: " & Result'Img);
end if;
end Fill_With_CB;
-------------------
-- Print_Content --
-------------------
procedure Print_Content (RG : BBqueue.Buffers.Read_Grant) is
pragma SPARK_Mode (Off);
S : constant BBqueue.Buffers.Slice_Rec := BBqueue.Buffers.Slice (RG);
Arr : Storage_Array (1 .. S.Length) with Address => S.Addr;
begin
Put ("Print" & S.Length'Img & " bytes -> ");
for Elt of Arr loop
Put (Elt'Img);
end loop;
New_Line;
end Print_Content;
---------------------------
-- Print_Content_With_CB --
---------------------------
procedure Print_Content_With_CB is
procedure Process_Read (Data : Storage_Array; To_Release : out BBqueue.Count);
procedure Process_Read (Data : Storage_Array; To_Release : out BBqueue.Count) is
begin
Put ("Print" & Data'Length'Img & " bytes -> ");
for Elt of Data loop
Put (Elt'Img);
end loop;
New_Line;
To_Release := Data'Length;
end Process_Read;
procedure Read is new BBqueue.Buffers.Read_CB (Process_Read);
Result : BBqueue.Result_Kind;
begin
Read (Q, Result);
if Result /= BBqueue.Valid then
Put_Line ("Read failed: " & Result'Img);
end if;
end Print_Content_With_CB;
WG : BBqueue.Buffers.Write_Grant := BBqueue.Buffers.Empty;
RG : BBqueue.Buffers.Read_Grant := BBqueue.Buffers.Empty;
V : Storage_Element := 1;
begin
for X in 1 .. 4 loop
Put_Line ("-- Loop" & X'Img & " --");
BBqueue.Buffers.Grant (Q, WG, 10);
if BBqueue.Buffers.State (WG) /= BBqueue.Valid then
exit;
end if;
Put_Line ("BBqueue.Buffers.Grant (Q, 10) -> ");
Put_Line ("Fill (WG, " & V'Img & ")");
Fill (WG, V);
V := V + 1;
BBqueue.Buffers.Commit (Q, WG, 10);
Put_Line ("BBqueue.Buffers.Commit (WG, 10); ->");
BBqueue.Buffers.Read (Q, RG);
if BBqueue.Buffers.State (RG) /= BBqueue.Valid then
exit;
end if;
Put ("BBqueue.Buffers.Read (Q, RG); -> ");
Print_Content (RG);
BBqueue.Buffers.Release (Q, RG);
Put_Line ("BBqueue.Buffers.Release (Q, RG); -> ");
pragma Assert (BBqueue.Buffers.State (WG) = BBqueue.Empty);
pragma Assert (BBqueue.Buffers.State (RG) = BBqueue.Empty);
end loop;
for X in 5 .. 7 loop
Put_Line ("-- Loop" & X'Img & " with callbacks --");
Fill_With_CB (5, V);
Fill_With_CB (5, V + 1);
V := V + 1;
Print_Content_With_CB;
Print_Content_With_CB;
end loop;
end Main_Buffer;
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.