repo_name
stringlengths 9
74
| language
stringclasses 1
value | length_bytes
int64 11
9.34M
| extension
stringclasses 2
values | content
stringlengths 11
9.34M
|
---|---|---|---|---|
AdaCore/langkit | Ada | 716 | adb | with Ada.Text_IO; use Ada.Text_IO;
with Langkit_Support.Relative_Get;
procedure Main is
type Char_Array is array (Natural range <>) of Character;
function Length (A : Char_Array) return Natural is (A'Length);
function Get (A : Char_Array; Index : Integer) return Character is
(A (Index));
function Relative_Get is new Langkit_Support.Relative_Get
(Character, Char_Array, Length, Get);
A : constant Char_Array (0 .. 5) := ('A', 'B', 'C', 'D', 'E', 'F');
Item : Character;
begin
for I in -7 .. 6 loop
if Relative_Get (A, I, Item) then
Put_Line (I'Image & ": " & Item);
else
Put_Line (I'Image & ": out of bound");
end if;
end loop;
end Main;
|
zhmu/ananas | Ada | 670 | adb | with Ada.Containers; use Ada.Containers;
with Ada.Containers.Hashed_Maps;
with Ada.Containers.Vectors;
package body Lto21_Pkg2 is
pragma Suppress (Tampering_Check);
procedure Proc is
function Hash (Syd : Natural) return Hash_Type is (Hash_Type'Mod (Syd));
package Vect2 is new Vectors (Positive, Natural);
package Maps is
new Hashed_Maps (Natural, Vect2.Vector, Hash, "=", Vect2."=");
procedure Nested (M : Maps.Map) is
use Maps;
procedure Inner (Position : Cursor) is null;
begin
Iterate (M, Inner'Access);
end;
M : Maps.Map;
begin
Nested (M);
end;
end Lto21_Pkg2;
|
reznikmm/matreshka | Ada | 3,709 | ads | ------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- Open Document Toolkit --
-- --
-- Runtime Library Component --
-- --
------------------------------------------------------------------------------
-- --
-- Copyright © 2014, Vadim Godunko <[email protected]> --
-- All rights reserved. --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions --
-- are met: --
-- --
-- * Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- --
-- * Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in the --
-- documentation and/or other materials provided with the distribution. --
-- --
-- * Neither the name of the Vadim Godunko, IE nor the names of its --
-- contributors may be used to endorse or promote products derived from --
-- this software without specific prior written permission. --
-- --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR --
-- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
-- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED --
-- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR --
-- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF --
-- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING --
-- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS --
-- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
-- --
------------------------------------------------------------------------------
-- $Revision$ $Date$
------------------------------------------------------------------------------
with XML.DOM.Attributes;
package ODF.DOM.Smil_Direction_Attributes is
pragma Preelaborate;
type ODF_Smil_Direction_Attribute is limited interface
and XML.DOM.Attributes.DOM_Attribute;
type ODF_Smil_Direction_Attribute_Access is
access all ODF_Smil_Direction_Attribute'Class
with Storage_Size => 0;
end ODF.DOM.Smil_Direction_Attributes;
|
reznikmm/matreshka | Ada | 3,902 | ads | ------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- Open Document Toolkit --
-- --
-- Runtime Library Component --
-- --
------------------------------------------------------------------------------
-- --
-- Copyright © 2013, Vadim Godunko <[email protected]> --
-- All rights reserved. --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions --
-- are met: --
-- --
-- * Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- --
-- * Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in the --
-- documentation and/or other materials provided with the distribution. --
-- --
-- * Neither the name of the Vadim Godunko, IE nor the names of its --
-- contributors may be used to endorse or promote products derived from --
-- this software without specific prior written permission. --
-- --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR --
-- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
-- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED --
-- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR --
-- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF --
-- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING --
-- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS --
-- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
-- --
------------------------------------------------------------------------------
-- $Revision$ $Date$
------------------------------------------------------------------------------
with Matreshka.ODF_Elements.Office.Automatic_Styles;
package ODF.DOM.Elements.Office.Automatic_Styles.Internals is
function Create
(Node : Matreshka.ODF_Elements.Office.Automatic_Styles.Office_Automatic_Styles_Access)
return ODF.DOM.Elements.Office.Automatic_Styles.ODF_Office_Automatic_Styles;
function Wrap
(Node : Matreshka.ODF_Elements.Office.Automatic_Styles.Office_Automatic_Styles_Access)
return ODF.DOM.Elements.Office.Automatic_Styles.ODF_Office_Automatic_Styles;
end ODF.DOM.Elements.Office.Automatic_Styles.Internals;
|
AdaCore/training_material | Ada | 19,958 | ads | pragma Ada_2005;
pragma Style_Checks (Off);
with Interfaces.C; use Interfaces.C;
limited with SDL_rwops_h;
with Interfaces.C.Strings;
with SDL_joystick_h;
with SDL_stdinc_h;
package SDL_gamecontroller_h is
-- arg-macro: procedure SDL_GameControllerAddMappingsFromFile (file)
-- SDL_GameControllerAddMappingsFromRW(SDL_RWFromFile(file, "rb"), 1)
-- Simple DirectMedia Layer
-- Copyright (C) 1997-2018 Sam Lantinga <[email protected]>
-- This software is provided 'as-is', without any express or implied
-- warranty. In no event will the authors be held liable for any damages
-- arising from the use of this software.
-- Permission is granted to anyone to use this software for any purpose,
-- including commercial applications, and to alter it and redistribute it
-- freely, subject to the following restrictions:
-- 1. The origin of this software must not be misrepresented; you must not
-- claim that you wrote the original software. If you use this software
-- in a product, an acknowledgment in the product documentation would be
-- appreciated but is not required.
-- 2. Altered source versions must be plainly marked as such, and must not be
-- misrepresented as being the original software.
-- 3. This notice may not be removed or altered from any source distribution.
--
--*
-- * \file SDL_gamecontroller.h
-- *
-- * Include file for SDL game controller event handling
--
-- Set up for C function definitions, even when using C++
--*
-- * \file SDL_gamecontroller.h
-- *
-- * In order to use these functions, SDL_Init() must have been called
-- * with the ::SDL_INIT_GAMECONTROLLER flag. This causes SDL to scan the system
-- * for game controllers, and load appropriate drivers.
-- *
-- * If you would like to receive controller updates while the application
-- * is in the background, you should set the following hint before calling
-- * SDL_Init(): SDL_HINT_JOYSTICK_ALLOW_BACKGROUND_EVENTS
--
--*
-- * The gamecontroller structure used to identify an SDL game controller
--
type u_SDL_GameController is null record; -- incomplete struct
subtype SDL_GameController is u_SDL_GameController; -- ..\SDL2_tmp\SDL_gamecontroller.h:58
type SDL_GameControllerBindType is
(SDL_CONTROLLER_BINDTYPE_NONE,
SDL_CONTROLLER_BINDTYPE_BUTTON,
SDL_CONTROLLER_BINDTYPE_AXIS,
SDL_CONTROLLER_BINDTYPE_HAT);
pragma Convention (C, SDL_GameControllerBindType); -- ..\SDL2_tmp\SDL_gamecontroller.h:67
--*
-- * Get the SDL joystick layer binding for this controller button/axis mapping
--
type anon_58 is record
hat : aliased int; -- ..\SDL2_tmp\SDL_gamecontroller.h:80
hat_mask : aliased int; -- ..\SDL2_tmp\SDL_gamecontroller.h:81
end record;
pragma Convention (C_Pass_By_Copy, anon_58);
type anon_57 (discr : unsigned := 0) is record
case discr is
when 0 =>
button : aliased int; -- ..\SDL2_tmp\SDL_gamecontroller.h:77
when 1 =>
axis : aliased int; -- ..\SDL2_tmp\SDL_gamecontroller.h:78
when others =>
hat : aliased anon_58; -- ..\SDL2_tmp\SDL_gamecontroller.h:82
end case;
end record;
pragma Convention (C_Pass_By_Copy, anon_57);
pragma Unchecked_Union (anon_57);type SDL_GameControllerButtonBind is record
bindType : aliased SDL_GameControllerBindType; -- ..\SDL2_tmp\SDL_gamecontroller.h:74
value : aliased anon_57; -- ..\SDL2_tmp\SDL_gamecontroller.h:83
end record;
pragma Convention (C_Pass_By_Copy, SDL_GameControllerButtonBind); -- ..\SDL2_tmp\SDL_gamecontroller.h:72
--*
-- * To count the number of game controllers in the system for the following:
-- * int nJoysticks = SDL_NumJoysticks();
-- * int nGameControllers = 0;
-- * for (int i = 0; i < nJoysticks; i++) {
-- * if (SDL_IsGameController(i)) {
-- * nGameControllers++;
-- * }
-- * }
-- *
-- * Using the SDL_HINT_GAMECONTROLLERCONFIG hint or the SDL_GameControllerAddMapping() you can add support for controllers SDL is unaware of or cause an existing controller to have a different binding. The format is:
-- * guid,name,mappings
-- *
-- * Where GUID is the string value from SDL_JoystickGetGUIDString(), name is the human readable string for the device and mappings are controller mappings to joystick ones.
-- * Under Windows there is a reserved GUID of "xinput" that covers any XInput devices.
-- * The mapping format for joystick is:
-- * bX - a joystick button, index X
-- * hX.Y - hat X with value Y
-- * aX - axis X of the joystick
-- * Buttons can be used as a controller axis and vice versa.
-- *
-- * This string shows an example of a valid mapping for a controller
-- * "03000000341a00003608000000000000,PS3 Controller,a:b1,b:b2,y:b3,x:b0,start:b9,guide:b12,back:b8,dpup:h0.1,dpleft:h0.8,dpdown:h0.4,dpright:h0.2,leftshoulder:b4,rightshoulder:b5,leftstick:b10,rightstick:b11,leftx:a0,lefty:a1,rightx:a2,righty:a3,lefttrigger:b6,righttrigger:b7",
-- *
--
--*
-- * Load a set of mappings from a seekable SDL data stream (memory or file), filtered by the current SDL_GetPlatform()
-- * A community sourced database of controllers is available at https://raw.github.com/gabomdq/SDL_GameControllerDB/master/gamecontrollerdb.txt
-- *
-- * If \c freerw is non-zero, the stream will be closed after being read.
-- *
-- * \return number of mappings added, -1 on error
--
function SDL_GameControllerAddMappingsFromRW (rw : access SDL_rwops_h.SDL_RWops; freerw : int) return int; -- ..\SDL2_tmp\SDL_gamecontroller.h:122
pragma Import (C, SDL_GameControllerAddMappingsFromRW, "SDL_GameControllerAddMappingsFromRW");
--*
-- * Load a set of mappings from a file, filtered by the current SDL_GetPlatform()
-- *
-- * Convenience macro.
--
--*
-- * Add or update an existing mapping configuration
-- *
-- * \return 1 if mapping is added, 0 if updated, -1 on error
--
function SDL_GameControllerAddMapping (mappingString : Interfaces.C.Strings.chars_ptr) return int; -- ..\SDL2_tmp\SDL_gamecontroller.h:136
pragma Import (C, SDL_GameControllerAddMapping, "SDL_GameControllerAddMapping");
--*
-- * Get the number of mappings installed
-- *
-- * \return the number of mappings
--
function SDL_GameControllerNumMappings return int; -- ..\SDL2_tmp\SDL_gamecontroller.h:143
pragma Import (C, SDL_GameControllerNumMappings, "SDL_GameControllerNumMappings");
--*
-- * Get the mapping at a particular index.
-- *
-- * \return the mapping string. Must be freed with SDL_free(). Returns NULL if the index is out of range.
--
function SDL_GameControllerMappingForIndex (mapping_index : int) return Interfaces.C.Strings.chars_ptr; -- ..\SDL2_tmp\SDL_gamecontroller.h:150
pragma Import (C, SDL_GameControllerMappingForIndex, "SDL_GameControllerMappingForIndex");
--*
-- * Get a mapping string for a GUID
-- *
-- * \return the mapping string. Must be freed with SDL_free(). Returns NULL if no mapping is available
--
function SDL_GameControllerMappingForGUID (guid : SDL_joystick_h.SDL_JoystickGUID) return Interfaces.C.Strings.chars_ptr; -- ..\SDL2_tmp\SDL_gamecontroller.h:157
pragma Import (C, SDL_GameControllerMappingForGUID, "SDL_GameControllerMappingForGUID");
--*
-- * Get a mapping string for an open GameController
-- *
-- * \return the mapping string. Must be freed with SDL_free(). Returns NULL if no mapping is available
--
function SDL_GameControllerMapping (gamecontroller : access SDL_GameController) return Interfaces.C.Strings.chars_ptr; -- ..\SDL2_tmp\SDL_gamecontroller.h:164
pragma Import (C, SDL_GameControllerMapping, "SDL_GameControllerMapping");
--*
-- * Is the joystick on this index supported by the game controller interface?
--
function SDL_IsGameController (joystick_index : int) return SDL_stdinc_h.SDL_bool; -- ..\SDL2_tmp\SDL_gamecontroller.h:169
pragma Import (C, SDL_IsGameController, "SDL_IsGameController");
--*
-- * Get the implementation dependent name of a game controller.
-- * This can be called before any controllers are opened.
-- * If no name can be found, this function returns NULL.
--
function SDL_GameControllerNameForIndex (joystick_index : int) return Interfaces.C.Strings.chars_ptr; -- ..\SDL2_tmp\SDL_gamecontroller.h:176
pragma Import (C, SDL_GameControllerNameForIndex, "SDL_GameControllerNameForIndex");
--*
-- * Get the mapping of a game controller.
-- * This can be called before any controllers are opened.
-- *
-- * \return the mapping string. Must be freed with SDL_free(). Returns NULL if no mapping is available
--
function SDL_GameControllerMappingForDeviceIndex (joystick_index : int) return Interfaces.C.Strings.chars_ptr; -- ..\SDL2_tmp\SDL_gamecontroller.h:184
pragma Import (C, SDL_GameControllerMappingForDeviceIndex, "SDL_GameControllerMappingForDeviceIndex");
--*
-- * Open a game controller for use.
-- * The index passed as an argument refers to the N'th game controller on the system.
-- * This index is not the value which will identify this controller in future
-- * controller events. The joystick's instance id (::SDL_JoystickID) will be
-- * used there instead.
-- *
-- * \return A controller identifier, or NULL if an error occurred.
--
function SDL_GameControllerOpen (joystick_index : int) return access SDL_GameController; -- ..\SDL2_tmp\SDL_gamecontroller.h:195
pragma Import (C, SDL_GameControllerOpen, "SDL_GameControllerOpen");
--*
-- * Return the SDL_GameController associated with an instance id.
--
function SDL_GameControllerFromInstanceID (joyid : SDL_joystick_h.SDL_JoystickID) return access SDL_GameController; -- ..\SDL2_tmp\SDL_gamecontroller.h:200
pragma Import (C, SDL_GameControllerFromInstanceID, "SDL_GameControllerFromInstanceID");
--*
-- * Return the name for this currently opened controller
--
function SDL_GameControllerName (gamecontroller : access SDL_GameController) return Interfaces.C.Strings.chars_ptr; -- ..\SDL2_tmp\SDL_gamecontroller.h:205
pragma Import (C, SDL_GameControllerName, "SDL_GameControllerName");
--*
-- * Get the player index of an opened game controller, or -1 if it's not available
-- *
-- * For XInput controllers this returns the XInput user index.
--
function SDL_GameControllerGetPlayerIndex (gamecontroller : access SDL_GameController) return int; -- ..\SDL2_tmp\SDL_gamecontroller.h:212
pragma Import (C, SDL_GameControllerGetPlayerIndex, "SDL_GameControllerGetPlayerIndex");
--*
-- * Get the USB vendor ID of an opened controller, if available.
-- * If the vendor ID isn't available this function returns 0.
--
function SDL_GameControllerGetVendor (gamecontroller : access SDL_GameController) return SDL_stdinc_h.Uint16; -- ..\SDL2_tmp\SDL_gamecontroller.h:218
pragma Import (C, SDL_GameControllerGetVendor, "SDL_GameControllerGetVendor");
--*
-- * Get the USB product ID of an opened controller, if available.
-- * If the product ID isn't available this function returns 0.
--
function SDL_GameControllerGetProduct (gamecontroller : access SDL_GameController) return SDL_stdinc_h.Uint16; -- ..\SDL2_tmp\SDL_gamecontroller.h:224
pragma Import (C, SDL_GameControllerGetProduct, "SDL_GameControllerGetProduct");
--*
-- * Get the product version of an opened controller, if available.
-- * If the product version isn't available this function returns 0.
--
function SDL_GameControllerGetProductVersion (gamecontroller : access SDL_GameController) return SDL_stdinc_h.Uint16; -- ..\SDL2_tmp\SDL_gamecontroller.h:230
pragma Import (C, SDL_GameControllerGetProductVersion, "SDL_GameControllerGetProductVersion");
--*
-- * Returns SDL_TRUE if the controller has been opened and currently connected,
-- * or SDL_FALSE if it has not.
--
function SDL_GameControllerGetAttached (gamecontroller : access SDL_GameController) return SDL_stdinc_h.SDL_bool; -- ..\SDL2_tmp\SDL_gamecontroller.h:236
pragma Import (C, SDL_GameControllerGetAttached, "SDL_GameControllerGetAttached");
--*
-- * Get the underlying joystick object used by a controller
--
function SDL_GameControllerGetJoystick (gamecontroller : access SDL_GameController) return access SDL_joystick_h.Class_SDL_Joystick.SDL_Joystick; -- ..\SDL2_tmp\SDL_gamecontroller.h:241
pragma Import (C, SDL_GameControllerGetJoystick, "SDL_GameControllerGetJoystick");
--*
-- * Enable/disable controller event polling.
-- *
-- * If controller events are disabled, you must call SDL_GameControllerUpdate()
-- * yourself and check the state of the controller when you want controller
-- * information.
-- *
-- * The state can be one of ::SDL_QUERY, ::SDL_ENABLE or ::SDL_IGNORE.
--
function SDL_GameControllerEventState (state : int) return int; -- ..\SDL2_tmp\SDL_gamecontroller.h:252
pragma Import (C, SDL_GameControllerEventState, "SDL_GameControllerEventState");
--*
-- * Update the current state of the open game controllers.
-- *
-- * This is called automatically by the event loop if any game controller
-- * events are enabled.
--
procedure SDL_GameControllerUpdate; -- ..\SDL2_tmp\SDL_gamecontroller.h:260
pragma Import (C, SDL_GameControllerUpdate, "SDL_GameControllerUpdate");
--*
-- * The list of axes available from a controller
-- *
-- * Thumbstick axis values range from SDL_JOYSTICK_AXIS_MIN to SDL_JOYSTICK_AXIS_MAX,
-- * and are centered within ~8000 of zero, though advanced UI will allow users to set
-- * or autodetect the dead zone, which varies between controllers.
-- *
-- * Trigger axis values range from 0 to SDL_JOYSTICK_AXIS_MAX.
--
subtype SDL_GameControllerAxis is int;
SDL_CONTROLLER_AXIS_INVALID : constant int := -1;
SDL_CONTROLLER_AXIS_LEFTX : constant int := 0;
SDL_CONTROLLER_AXIS_LEFTY : constant int := 1;
SDL_CONTROLLER_AXIS_RIGHTX : constant int := 2;
SDL_CONTROLLER_AXIS_RIGHTY : constant int := 3;
SDL_CONTROLLER_AXIS_TRIGGERLEFT : constant int := 4;
SDL_CONTROLLER_AXIS_TRIGGERRIGHT : constant int := 5;
SDL_CONTROLLER_AXIS_MAX : constant int := 6; -- ..\SDL2_tmp\SDL_gamecontroller.h:282
--*
-- * turn this string into a axis mapping
--
function SDL_GameControllerGetAxisFromString (pchString : Interfaces.C.Strings.chars_ptr) return SDL_GameControllerAxis; -- ..\SDL2_tmp\SDL_gamecontroller.h:287
pragma Import (C, SDL_GameControllerGetAxisFromString, "SDL_GameControllerGetAxisFromString");
--*
-- * turn this axis enum into a string mapping
--
function SDL_GameControllerGetStringForAxis (axis : SDL_GameControllerAxis) return Interfaces.C.Strings.chars_ptr; -- ..\SDL2_tmp\SDL_gamecontroller.h:292
pragma Import (C, SDL_GameControllerGetStringForAxis, "SDL_GameControllerGetStringForAxis");
--*
-- * Get the SDL joystick layer binding for this controller button mapping
--
function SDL_GameControllerGetBindForAxis (gamecontroller : access SDL_GameController; axis : SDL_GameControllerAxis) return SDL_GameControllerButtonBind; -- ..\SDL2_tmp\SDL_gamecontroller.h:298
pragma Import (C, SDL_GameControllerGetBindForAxis, "SDL_GameControllerGetBindForAxis");
--*
-- * Get the current state of an axis control on a game controller.
-- *
-- * The state is a value ranging from -32768 to 32767 (except for the triggers,
-- * which range from 0 to 32767).
-- *
-- * The axis indices start at index 0.
--
function SDL_GameControllerGetAxis (gamecontroller : access SDL_GameController; axis : SDL_GameControllerAxis) return SDL_stdinc_h.Sint16; -- ..\SDL2_tmp\SDL_gamecontroller.h:310
pragma Import (C, SDL_GameControllerGetAxis, "SDL_GameControllerGetAxis");
--*
-- * The list of buttons available from a controller
--
subtype SDL_GameControllerButton is int;
SDL_CONTROLLER_BUTTON_INVALID : constant int := -1;
SDL_CONTROLLER_BUTTON_A : constant int := 0;
SDL_CONTROLLER_BUTTON_B : constant int := 1;
SDL_CONTROLLER_BUTTON_X : constant int := 2;
SDL_CONTROLLER_BUTTON_Y : constant int := 3;
SDL_CONTROLLER_BUTTON_BACK : constant int := 4;
SDL_CONTROLLER_BUTTON_GUIDE : constant int := 5;
SDL_CONTROLLER_BUTTON_START : constant int := 6;
SDL_CONTROLLER_BUTTON_LEFTSTICK : constant int := 7;
SDL_CONTROLLER_BUTTON_RIGHTSTICK : constant int := 8;
SDL_CONTROLLER_BUTTON_LEFTSHOULDER : constant int := 9;
SDL_CONTROLLER_BUTTON_RIGHTSHOULDER : constant int := 10;
SDL_CONTROLLER_BUTTON_DPAD_UP : constant int := 11;
SDL_CONTROLLER_BUTTON_DPAD_DOWN : constant int := 12;
SDL_CONTROLLER_BUTTON_DPAD_LEFT : constant int := 13;
SDL_CONTROLLER_BUTTON_DPAD_RIGHT : constant int := 14;
SDL_CONTROLLER_BUTTON_MAX : constant int := 15; -- ..\SDL2_tmp\SDL_gamecontroller.h:335
--*
-- * turn this string into a button mapping
--
function SDL_GameControllerGetButtonFromString (pchString : Interfaces.C.Strings.chars_ptr) return SDL_GameControllerButton; -- ..\SDL2_tmp\SDL_gamecontroller.h:340
pragma Import (C, SDL_GameControllerGetButtonFromString, "SDL_GameControllerGetButtonFromString");
--*
-- * turn this button enum into a string mapping
--
function SDL_GameControllerGetStringForButton (button : SDL_GameControllerButton) return Interfaces.C.Strings.chars_ptr; -- ..\SDL2_tmp\SDL_gamecontroller.h:345
pragma Import (C, SDL_GameControllerGetStringForButton, "SDL_GameControllerGetStringForButton");
--*
-- * Get the SDL joystick layer binding for this controller button mapping
--
function SDL_GameControllerGetBindForButton (gamecontroller : access SDL_GameController; button : SDL_GameControllerButton) return SDL_GameControllerButtonBind; -- ..\SDL2_tmp\SDL_gamecontroller.h:351
pragma Import (C, SDL_GameControllerGetBindForButton, "SDL_GameControllerGetBindForButton");
--*
-- * Get the current state of a button on a game controller.
-- *
-- * The button indices start at index 0.
--
function SDL_GameControllerGetButton (gamecontroller : access SDL_GameController; button : SDL_GameControllerButton) return SDL_stdinc_h.Uint8; -- ..\SDL2_tmp\SDL_gamecontroller.h:360
pragma Import (C, SDL_GameControllerGetButton, "SDL_GameControllerGetButton");
--*
-- * Trigger a rumble effect
-- * Each call to this function cancels any previous rumble effect, and calling it with 0 intensity stops any rumbling.
-- *
-- * \param gamecontroller The controller to vibrate
-- * \param low_frequency_rumble The intensity of the low frequency (left) rumble motor, from 0 to 0xFFFF
-- * \param high_frequency_rumble The intensity of the high frequency (right) rumble motor, from 0 to 0xFFFF
-- * \param duration_ms The duration of the rumble effect, in milliseconds
-- *
-- * \return 0, or -1 if rumble isn't supported on this joystick
--
function SDL_GameControllerRumble
(gamecontroller : access SDL_GameController;
low_frequency_rumble : SDL_stdinc_h.Uint16;
high_frequency_rumble : SDL_stdinc_h.Uint16;
duration_ms : SDL_stdinc_h.Uint32) return int; -- ..\SDL2_tmp\SDL_gamecontroller.h:374
pragma Import (C, SDL_GameControllerRumble, "SDL_GameControllerRumble");
--*
-- * Close a controller previously opened with SDL_GameControllerOpen().
--
procedure SDL_GameControllerClose (gamecontroller : access SDL_GameController); -- ..\SDL2_tmp\SDL_gamecontroller.h:379
pragma Import (C, SDL_GameControllerClose, "SDL_GameControllerClose");
-- Ends C function definitions when using C++
-- vi: set ts=4 sw=4 expandtab:
end SDL_gamecontroller_h;
|
Rodeo-McCabe/orka | Ada | 1,617 | adb | -- SPDX-License-Identifier: Apache-2.0
--
-- Copyright (c) 2019 onox <[email protected]>
--
-- Licensed under the Apache License, Version 2.0 (the "License");
-- you may not use this file except in compliance with the License.
-- You may obtain a copy of the License at
--
-- http://www.apache.org/licenses/LICENSE-2.0
--
-- Unless required by applicable law or agreed to in writing, software
-- distributed under the License is distributed on an "AS IS" BASIS,
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-- See the License for the specific language governing permissions and
-- limitations under the License.
package body Orka.Inputs.Joysticks.Tapping is
use Ada.Real_Time;
function Create_Tap_Detector
(Button : Button_Index;
Max_Delta : Duration) return Button_Tap_Detector
is
DT : constant Time_Span := To_Time_Span (Max_Delta);
begin
return
(Button => Button,
Max_Delta => DT,
Last_Press => Clock - DT,
Active => False);
end Create_Tap_Detector;
function Detect_Activation
(Object : in out Button_Tap_Detector;
Joystick : Joystick_Input'Class) return Boolean
is
Current_Time : constant Time := Clock;
On_Time : constant Boolean := Current_Time - Object.Last_Press < Object.Max_Delta;
begin
if Joystick.Just_Pressed (Object.Button) then
Object.Last_Press := Current_Time;
Object.Active := On_Time;
end if;
return On_Time and Object.Active;
end Detect_Activation;
end Orka.Inputs.Joysticks.Tapping;
|
zhmu/ananas | Ada | 2,561 | ads | ------------------------------------------------------------------------------
-- --
-- GNAT COMPILER COMPONENTS --
-- --
-- G N A T . S T R I N G S --
-- --
-- S p e c --
-- --
-- Copyright (C) 1995-2022, Free Software Foundation, Inc. --
-- --
-- GNAT is free software; you can redistribute it and/or modify it under --
-- terms of the GNU General Public License as published by the Free Soft- --
-- ware Foundation; either version 3, or (at your option) any later ver- --
-- sion. GNAT is distributed in the hope that it will be useful, but WITH- --
-- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY --
-- or FITNESS FOR A PARTICULAR PURPOSE. --
-- --
-- As a special exception under Section 7 of GPL version 3, you are granted --
-- additional permissions described in the GCC Runtime Library Exception, --
-- version 3.1, as published by the Free Software Foundation. --
-- --
-- You should have received a copy of the GNU General Public License and --
-- a copy of the GCC Runtime Library Exception along with this program; --
-- see the files COPYING3 and COPYING.RUNTIME respectively. If not, see --
-- <http://www.gnu.org/licenses/>. --
-- --
-- GNAT was originally developed by the GNAT team at New York University. --
-- Extensive contributions were provided by Ada Core Technologies Inc. --
-- --
------------------------------------------------------------------------------
-- Common String access types and related subprograms
-- See file s-string.ads for full documentation of the interface
with System.Strings;
package GNAT.Strings renames System.Strings;
|
BrickBot/Bound-T-H8-300 | Ada | 3,636 | adb | -- Calling (body)
--
-- A component of the Bound-T Worst-Case Execution Time Tool.
--
-------------------------------------------------------------------------------
-- Copyright (c) 1999 .. 2015 Tidorum Ltd
-- All rights reserved.
--
-- Redistribution and use in source and binary forms, with or without
-- modification, are permitted provided that the following conditions are met:
--
-- 1. Redistributions of source code must retain the above copyright notice, this
-- list of conditions and the following disclaimer.
-- 2. Redistributions in binary form must reproduce the above copyright notice,
-- this list of conditions and the following disclaimer in the documentation
-- and/or other materials provided with the distribution.
--
-- This software is provided by the copyright holders and contributors "as is" and
-- any express or implied warranties, including, but not limited to, the implied
-- warranties of merchantability and fitness for a particular purpose are
-- disclaimed. In no event shall the copyright owner or contributors be liable for
-- any direct, indirect, incidental, special, exemplary, or consequential damages
-- (including, but not limited to, procurement of substitute goods or services;
-- loss of use, data, or profits; or business interruption) however caused and
-- on any theory of liability, whether in contract, strict liability, or tort
-- (including negligence or otherwise) arising in any way out of the use of this
-- software, even if advised of the possibility of such damage.
--
-- Other modules (files) of this software composition should contain their
-- own copyright statements, which may have different copyright and usage
-- conditions. The above conditions apply to this file.
-------------------------------------------------------------------------------
--
-- $Revision: 1.5 $
-- $Date: 2015/10/24 20:05:47 $
--
-- $Log: calling.adb,v $
-- Revision 1.5 2015/10/24 20:05:47 niklas
-- Moved to free licence.
--
-- Revision 1.4 2010-01-30 21:13:29 niklas
-- BT-CH-0216: Subprograms have a Return_Method_T attribute.
--
-- Revision 1.3 2006-02-27 09:15:51 niklas
-- Added Static_Protocol_T.
--
-- Revision 1.2 2005/02/23 09:05:17 niklas
-- BT-CH-0005.
--
-- Revision 1.1 2005/02/16 21:11:42 niklas
-- BT-CH-0002.
--
with Output;
package body Calling is
--
--- Calling protocols
--
function Invariant (
Callee : Storage.Cell_T;
Under : Protocol_T)
return Boolean
is
begin
return Map_Kind (Callee, Protocol_T'Class (Under)) = Privy;
end Invariant;
--
--- Static calling protocols
--
function Static (Item : Static_Protocol_T) return Boolean
is
begin
return True;
end Static;
function Basis (Item : Static_Protocol_T) return Storage.Cell_List_T
is
begin
return Storage.Null_Cell_List;
end Basis;
procedure Apply (
Bounds : in Storage.Bounds.Bounds_T'Class;
Upon : in Static_Protocol_T;
Giving : out Protocol_Ref)
is
begin
Output.Fault (
Location => "Calling.Apply (Static_Protocol_T)",
Text => "Should not be called");
Giving := null;
end Apply;
--
--- Return methods
--
function Image (Item : Return_Method_T) return String
is
Way : constant String := Return_Way_T'Image (Item.Way);
begin
case Item.Way is
when No_Return | Normal_Return =>
return Way;
when Offset_Return =>
return Way
& ' '
& Processor.Image (Item.Offset);
end case;
end Image;
end Calling;
|
reznikmm/matreshka | Ada | 7,036 | ads | ------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- Ada Modeling Framework --
-- --
-- Runtime Library Component --
-- --
------------------------------------------------------------------------------
-- --
-- Copyright © 2012, Vadim Godunko <[email protected]> --
-- All rights reserved. --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions --
-- are met: --
-- --
-- * Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- --
-- * Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in the --
-- documentation and/or other materials provided with the distribution. --
-- --
-- * Neither the name of the Vadim Godunko, IE nor the names of its --
-- contributors may be used to endorse or promote products derived from --
-- this software without specific prior written permission. --
-- --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR --
-- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
-- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED --
-- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR --
-- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF --
-- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING --
-- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS --
-- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
-- --
------------------------------------------------------------------------------
-- $Revision$ $Date$
------------------------------------------------------------------------------
-- This file is generated, don't edit it.
------------------------------------------------------------------------------
package AMF.Internals.Tables.DI_Metamodel.Objects is
procedure Initialize;
private
procedure Initialize_1 (Extent : AMF.Internals.AMF_Extent);
procedure Initialize_2 (Extent : AMF.Internals.AMF_Extent);
procedure Initialize_3 (Extent : AMF.Internals.AMF_Extent);
procedure Initialize_4 (Extent : AMF.Internals.AMF_Extent);
procedure Initialize_5 (Extent : AMF.Internals.AMF_Extent);
procedure Initialize_6 (Extent : AMF.Internals.AMF_Extent);
procedure Initialize_7 (Extent : AMF.Internals.AMF_Extent);
procedure Initialize_8 (Extent : AMF.Internals.AMF_Extent);
procedure Initialize_9 (Extent : AMF.Internals.AMF_Extent);
procedure Initialize_10 (Extent : AMF.Internals.AMF_Extent);
procedure Initialize_11 (Extent : AMF.Internals.AMF_Extent);
procedure Initialize_12 (Extent : AMF.Internals.AMF_Extent);
procedure Initialize_13 (Extent : AMF.Internals.AMF_Extent);
procedure Initialize_14 (Extent : AMF.Internals.AMF_Extent);
procedure Initialize_15 (Extent : AMF.Internals.AMF_Extent);
procedure Initialize_16 (Extent : AMF.Internals.AMF_Extent);
procedure Initialize_17 (Extent : AMF.Internals.AMF_Extent);
procedure Initialize_18 (Extent : AMF.Internals.AMF_Extent);
procedure Initialize_19 (Extent : AMF.Internals.AMF_Extent);
procedure Initialize_20 (Extent : AMF.Internals.AMF_Extent);
procedure Initialize_21 (Extent : AMF.Internals.AMF_Extent);
procedure Initialize_22 (Extent : AMF.Internals.AMF_Extent);
procedure Initialize_23 (Extent : AMF.Internals.AMF_Extent);
procedure Initialize_24 (Extent : AMF.Internals.AMF_Extent);
procedure Initialize_25 (Extent : AMF.Internals.AMF_Extent);
procedure Initialize_26 (Extent : AMF.Internals.AMF_Extent);
procedure Initialize_27 (Extent : AMF.Internals.AMF_Extent);
procedure Initialize_28 (Extent : AMF.Internals.AMF_Extent);
procedure Initialize_29 (Extent : AMF.Internals.AMF_Extent);
procedure Initialize_30 (Extent : AMF.Internals.AMF_Extent);
procedure Initialize_31 (Extent : AMF.Internals.AMF_Extent);
procedure Initialize_32 (Extent : AMF.Internals.AMF_Extent);
procedure Initialize_33 (Extent : AMF.Internals.AMF_Extent);
procedure Initialize_34 (Extent : AMF.Internals.AMF_Extent);
procedure Initialize_35 (Extent : AMF.Internals.AMF_Extent);
procedure Initialize_36 (Extent : AMF.Internals.AMF_Extent);
procedure Initialize_37 (Extent : AMF.Internals.AMF_Extent);
procedure Initialize_38 (Extent : AMF.Internals.AMF_Extent);
procedure Initialize_39 (Extent : AMF.Internals.AMF_Extent);
procedure Initialize_40 (Extent : AMF.Internals.AMF_Extent);
procedure Initialize_41 (Extent : AMF.Internals.AMF_Extent);
procedure Initialize_42 (Extent : AMF.Internals.AMF_Extent);
procedure Initialize_43 (Extent : AMF.Internals.AMF_Extent);
procedure Initialize_44 (Extent : AMF.Internals.AMF_Extent);
procedure Initialize_45 (Extent : AMF.Internals.AMF_Extent);
procedure Initialize_46 (Extent : AMF.Internals.AMF_Extent);
procedure Initialize_47 (Extent : AMF.Internals.AMF_Extent);
procedure Initialize_48 (Extent : AMF.Internals.AMF_Extent);
procedure Initialize_49 (Extent : AMF.Internals.AMF_Extent);
procedure Initialize_50 (Extent : AMF.Internals.AMF_Extent);
procedure Initialize_51 (Extent : AMF.Internals.AMF_Extent);
procedure Initialize_52 (Extent : AMF.Internals.AMF_Extent);
procedure Initialize_53 (Extent : AMF.Internals.AMF_Extent);
end AMF.Internals.Tables.DI_Metamodel.Objects;
|
reznikmm/matreshka | Ada | 4,743 | ads | ------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- Open Document Toolkit --
-- --
-- Runtime Library Component --
-- --
------------------------------------------------------------------------------
-- --
-- Copyright © 2014, Vadim Godunko <[email protected]> --
-- All rights reserved. --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions --
-- are met: --
-- --
-- * Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- --
-- * Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in the --
-- documentation and/or other materials provided with the distribution. --
-- --
-- * Neither the name of the Vadim Godunko, IE nor the names of its --
-- contributors may be used to endorse or promote products derived from --
-- this software without specific prior written permission. --
-- --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR --
-- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
-- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED --
-- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR --
-- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF --
-- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING --
-- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS --
-- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
-- --
------------------------------------------------------------------------------
-- $Revision$ $Date$
------------------------------------------------------------------------------
with XML.DOM.Visitors;
with ODF.DOM.Office_Annotation_Elements;
package Matreshka.ODF_Office.Annotation_Elements is
type Office_Annotation_Element_Node is
new Matreshka.ODF_Office.Abstract_Office_Element_Node
and ODF.DOM.Office_Annotation_Elements.ODF_Office_Annotation
with null record;
overriding function Create
(Parameters : not null access Matreshka.DOM_Elements.Element_L2_Parameters)
return Office_Annotation_Element_Node;
overriding function Get_Local_Name
(Self : not null access constant Office_Annotation_Element_Node)
return League.Strings.Universal_String;
overriding procedure Enter_Node
(Self : not null access Office_Annotation_Element_Node;
Visitor : in out XML.DOM.Visitors.Abstract_Visitor'Class;
Control : in out XML.DOM.Visitors.Traverse_Control);
overriding procedure Leave_Node
(Self : not null access Office_Annotation_Element_Node;
Visitor : in out XML.DOM.Visitors.Abstract_Visitor'Class;
Control : in out XML.DOM.Visitors.Traverse_Control);
overriding procedure Visit_Node
(Self : not null access Office_Annotation_Element_Node;
Iterator : in out XML.DOM.Visitors.Abstract_Iterator'Class;
Visitor : in out XML.DOM.Visitors.Abstract_Visitor'Class;
Control : in out XML.DOM.Visitors.Traverse_Control);
end Matreshka.ODF_Office.Annotation_Elements;
|
vikasbidhuri1995/DW1000 | Ada | 13,698 | ads | -- This spec has been automatically generated from STM32F105xx.svd
pragma Restrictions (No_Elaboration_Code);
pragma Ada_2012;
with System;
package STM32.AFIO is
pragma Preelaborate;
---------------
-- Registers --
---------------
-------------------
-- EVCR_Register --
-------------------
subtype EVCR_PIN_Field is STM32.UInt4;
subtype EVCR_PORT_Field is STM32.UInt3;
subtype EVCR_EVOE_Field is STM32.Bit;
-- Event Control Register (AFIO_EVCR)
type EVCR_Register is record
-- Pin selection
PIN : EVCR_PIN_Field := 16#0#;
-- Port selection
PORT : EVCR_PORT_Field := 16#0#;
-- Event Output Enable
EVOE : EVCR_EVOE_Field := 16#0#;
-- unspecified
Reserved_8_31 : STM32.UInt24 := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for EVCR_Register use record
PIN at 0 range 0 .. 3;
PORT at 0 range 4 .. 6;
EVOE at 0 range 7 .. 7;
Reserved_8_31 at 0 range 8 .. 31;
end record;
-------------------
-- MAPR_Register --
-------------------
subtype MAPR_SPI1_REMAP_Field is STM32.Bit;
subtype MAPR_I2C1_REMAP_Field is STM32.Bit;
subtype MAPR_USART1_REMAP_Field is STM32.Bit;
subtype MAPR_USART2_REMAP_Field is STM32.Bit;
subtype MAPR_USART3_REMAP_Field is STM32.UInt2;
subtype MAPR_TIM1_REMAP_Field is STM32.UInt2;
subtype MAPR_TIM2_REMAP_Field is STM32.UInt2;
subtype MAPR_TIM3_REMAP_Field is STM32.UInt2;
subtype MAPR_TIM4_REMAP_Field is STM32.Bit;
subtype MAPR_CAN1_REMAP_Field is STM32.UInt2;
subtype MAPR_PD01_REMAP_Field is STM32.Bit;
subtype MAPR_TIM5CH4_IREMAP_Field is STM32.Bit;
subtype MAPR_ETH_REMAP_Field is STM32.Bit;
subtype MAPR_CAN2_REMAP_Field is STM32.Bit;
subtype MAPR_MII_RMII_SEL_Field is STM32.Bit;
subtype MAPR_SWJ_CFG_Field is STM32.UInt3;
subtype MAPR_SPI3_REMAP_Field is STM32.Bit;
subtype MAPR_TIM2ITR1_IREMAP_Field is STM32.Bit;
subtype MAPR_PTP_PPS_REMAP_Field is STM32.Bit;
-- AF remap and debug I/O configuration register (AFIO_MAPR)
type MAPR_Register is record
-- SPI1 remapping
SPI1_REMAP : MAPR_SPI1_REMAP_Field := 16#0#;
-- I2C1 remapping
I2C1_REMAP : MAPR_I2C1_REMAP_Field := 16#0#;
-- USART1 remapping
USART1_REMAP : MAPR_USART1_REMAP_Field := 16#0#;
-- USART2 remapping
USART2_REMAP : MAPR_USART2_REMAP_Field := 16#0#;
-- USART3 remapping
USART3_REMAP : MAPR_USART3_REMAP_Field := 16#0#;
-- TIM1 remapping
TIM1_REMAP : MAPR_TIM1_REMAP_Field := 16#0#;
-- TIM2 remapping
TIM2_REMAP : MAPR_TIM2_REMAP_Field := 16#0#;
-- TIM3 remapping
TIM3_REMAP : MAPR_TIM3_REMAP_Field := 16#0#;
-- TIM4 remapping
TIM4_REMAP : MAPR_TIM4_REMAP_Field := 16#0#;
-- CAN1 remapping
CAN1_REMAP : MAPR_CAN1_REMAP_Field := 16#0#;
-- Port D0/Port D1 mapping on OSCIN/OSCOUT
PD01_REMAP : MAPR_PD01_REMAP_Field := 16#0#;
-- Set and cleared by software
TIM5CH4_IREMAP : MAPR_TIM5CH4_IREMAP_Field := 16#0#;
-- unspecified
Reserved_17_20 : STM32.UInt4 := 16#0#;
-- Ethernet MAC I/O remapping
ETH_REMAP : MAPR_ETH_REMAP_Field := 16#0#;
-- CAN2 I/O remapping
CAN2_REMAP : MAPR_CAN2_REMAP_Field := 16#0#;
-- MII or RMII selection
MII_RMII_SEL : MAPR_MII_RMII_SEL_Field := 16#0#;
-- Write-only. Serial wire JTAG configuration
SWJ_CFG : MAPR_SWJ_CFG_Field := 16#0#;
-- unspecified
Reserved_27_27 : STM32.Bit := 16#0#;
-- SPI3/I2S3 remapping
SPI3_REMAP : MAPR_SPI3_REMAP_Field := 16#0#;
-- TIM2 internal trigger 1 remapping
TIM2ITR1_IREMAP : MAPR_TIM2ITR1_IREMAP_Field := 16#0#;
-- Ethernet PTP PPS remapping
PTP_PPS_REMAP : MAPR_PTP_PPS_REMAP_Field := 16#0#;
-- unspecified
Reserved_31_31 : STM32.Bit := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for MAPR_Register use record
SPI1_REMAP at 0 range 0 .. 0;
I2C1_REMAP at 0 range 1 .. 1;
USART1_REMAP at 0 range 2 .. 2;
USART2_REMAP at 0 range 3 .. 3;
USART3_REMAP at 0 range 4 .. 5;
TIM1_REMAP at 0 range 6 .. 7;
TIM2_REMAP at 0 range 8 .. 9;
TIM3_REMAP at 0 range 10 .. 11;
TIM4_REMAP at 0 range 12 .. 12;
CAN1_REMAP at 0 range 13 .. 14;
PD01_REMAP at 0 range 15 .. 15;
TIM5CH4_IREMAP at 0 range 16 .. 16;
Reserved_17_20 at 0 range 17 .. 20;
ETH_REMAP at 0 range 21 .. 21;
CAN2_REMAP at 0 range 22 .. 22;
MII_RMII_SEL at 0 range 23 .. 23;
SWJ_CFG at 0 range 24 .. 26;
Reserved_27_27 at 0 range 27 .. 27;
SPI3_REMAP at 0 range 28 .. 28;
TIM2ITR1_IREMAP at 0 range 29 .. 29;
PTP_PPS_REMAP at 0 range 30 .. 30;
Reserved_31_31 at 0 range 31 .. 31;
end record;
----------------------
-- EXTICR1_Register --
----------------------
------------------
-- EXTICR1.EXTI --
------------------
-- EXTICR1_EXTI array element
subtype EXTICR1_EXTI_Element is STM32.UInt4;
-- EXTICR1_EXTI array
type EXTICR1_EXTI_Field_Array is array (0 .. 3) of EXTICR1_EXTI_Element
with Component_Size => 4, Size => 16;
-- Type definition for EXTICR1_EXTI
type EXTICR1_EXTI_Field
(As_Array : Boolean := False)
is record
case As_Array is
when False =>
-- EXTI as a value
Val : STM32.Short;
when True =>
-- EXTI as an array
Arr : EXTICR1_EXTI_Field_Array;
end case;
end record
with Unchecked_Union, Size => 16;
for EXTICR1_EXTI_Field use record
Val at 0 range 0 .. 15;
Arr at 0 range 0 .. 15;
end record;
-- External interrupt configuration register 1 (AFIO_EXTICR1)
type EXTICR1_Register is record
-- EXTI0 configuration
EXTI : EXTICR1_EXTI_Field :=
(As_Array => False, Val => 16#0#);
-- unspecified
Reserved_16_31 : STM32.Short := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for EXTICR1_Register use record
EXTI at 0 range 0 .. 15;
Reserved_16_31 at 0 range 16 .. 31;
end record;
----------------------
-- EXTICR2_Register --
----------------------
------------------
-- EXTICR2.EXTI --
------------------
-- EXTICR2_EXTI array element
subtype EXTICR2_EXTI_Element is STM32.UInt4;
-- EXTICR2_EXTI array
type EXTICR2_EXTI_Field_Array is array (4 .. 7) of EXTICR2_EXTI_Element
with Component_Size => 4, Size => 16;
-- Type definition for EXTICR2_EXTI
type EXTICR2_EXTI_Field
(As_Array : Boolean := False)
is record
case As_Array is
when False =>
-- EXTI as a value
Val : STM32.Short;
when True =>
-- EXTI as an array
Arr : EXTICR2_EXTI_Field_Array;
end case;
end record
with Unchecked_Union, Size => 16;
for EXTICR2_EXTI_Field use record
Val at 0 range 0 .. 15;
Arr at 0 range 0 .. 15;
end record;
-- External interrupt configuration register 2 (AFIO_EXTICR2)
type EXTICR2_Register is record
-- EXTI4 configuration
EXTI : EXTICR2_EXTI_Field :=
(As_Array => False, Val => 16#0#);
-- unspecified
Reserved_16_31 : STM32.Short := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for EXTICR2_Register use record
EXTI at 0 range 0 .. 15;
Reserved_16_31 at 0 range 16 .. 31;
end record;
----------------------
-- EXTICR3_Register --
----------------------
------------------
-- EXTICR3.EXTI --
------------------
-- EXTICR3_EXTI array element
subtype EXTICR3_EXTI_Element is STM32.UInt4;
-- EXTICR3_EXTI array
type EXTICR3_EXTI_Field_Array is array (8 .. 11) of EXTICR3_EXTI_Element
with Component_Size => 4, Size => 16;
-- Type definition for EXTICR3_EXTI
type EXTICR3_EXTI_Field
(As_Array : Boolean := False)
is record
case As_Array is
when False =>
-- EXTI as a value
Val : STM32.Short;
when True =>
-- EXTI as an array
Arr : EXTICR3_EXTI_Field_Array;
end case;
end record
with Unchecked_Union, Size => 16;
for EXTICR3_EXTI_Field use record
Val at 0 range 0 .. 15;
Arr at 0 range 0 .. 15;
end record;
-- External interrupt configuration register 3 (AFIO_EXTICR3)
type EXTICR3_Register is record
-- EXTI8 configuration
EXTI : EXTICR3_EXTI_Field :=
(As_Array => False, Val => 16#0#);
-- unspecified
Reserved_16_31 : STM32.Short := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for EXTICR3_Register use record
EXTI at 0 range 0 .. 15;
Reserved_16_31 at 0 range 16 .. 31;
end record;
----------------------
-- EXTICR4_Register --
----------------------
------------------
-- EXTICR4.EXTI --
------------------
-- EXTICR4_EXTI array element
subtype EXTICR4_EXTI_Element is STM32.UInt4;
-- EXTICR4_EXTI array
type EXTICR4_EXTI_Field_Array is array (12 .. 15) of EXTICR4_EXTI_Element
with Component_Size => 4, Size => 16;
-- Type definition for EXTICR4_EXTI
type EXTICR4_EXTI_Field
(As_Array : Boolean := False)
is record
case As_Array is
when False =>
-- EXTI as a value
Val : STM32.Short;
when True =>
-- EXTI as an array
Arr : EXTICR4_EXTI_Field_Array;
end case;
end record
with Unchecked_Union, Size => 16;
for EXTICR4_EXTI_Field use record
Val at 0 range 0 .. 15;
Arr at 0 range 0 .. 15;
end record;
-- External interrupt configuration register 4 (AFIO_EXTICR4)
type EXTICR4_Register is record
-- EXTI12 configuration
EXTI : EXTICR4_EXTI_Field :=
(As_Array => False, Val => 16#0#);
-- unspecified
Reserved_16_31 : STM32.Short := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for EXTICR4_Register use record
EXTI at 0 range 0 .. 15;
Reserved_16_31 at 0 range 16 .. 31;
end record;
--------------------
-- MAPR2_Register --
--------------------
subtype MAPR2_TIM9_REMAP_Field is STM32.Bit;
subtype MAPR2_TIM10_REMAP_Field is STM32.Bit;
subtype MAPR2_TIM11_REMAP_Field is STM32.Bit;
subtype MAPR2_TIM13_REMAP_Field is STM32.Bit;
subtype MAPR2_TIM14_REMAP_Field is STM32.Bit;
subtype MAPR2_FSMC_NADV_Field is STM32.Bit;
-- AF remap and debug I/O configuration register
type MAPR2_Register is record
-- unspecified
Reserved_0_4 : STM32.UInt5 := 16#0#;
-- TIM9 remapping
TIM9_REMAP : MAPR2_TIM9_REMAP_Field := 16#0#;
-- TIM10 remapping
TIM10_REMAP : MAPR2_TIM10_REMAP_Field := 16#0#;
-- TIM11 remapping
TIM11_REMAP : MAPR2_TIM11_REMAP_Field := 16#0#;
-- TIM13 remapping
TIM13_REMAP : MAPR2_TIM13_REMAP_Field := 16#0#;
-- TIM14 remapping
TIM14_REMAP : MAPR2_TIM14_REMAP_Field := 16#0#;
-- NADV connect/disconnect
FSMC_NADV : MAPR2_FSMC_NADV_Field := 16#0#;
-- unspecified
Reserved_11_31 : STM32.UInt21 := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for MAPR2_Register use record
Reserved_0_4 at 0 range 0 .. 4;
TIM9_REMAP at 0 range 5 .. 5;
TIM10_REMAP at 0 range 6 .. 6;
TIM11_REMAP at 0 range 7 .. 7;
TIM13_REMAP at 0 range 8 .. 8;
TIM14_REMAP at 0 range 9 .. 9;
FSMC_NADV at 0 range 10 .. 10;
Reserved_11_31 at 0 range 11 .. 31;
end record;
-----------------
-- Peripherals --
-----------------
-- Alternate function I/O
type AFIO_Peripheral is record
-- Event Control Register (AFIO_EVCR)
EVCR : EVCR_Register;
-- AF remap and debug I/O configuration register (AFIO_MAPR)
MAPR : MAPR_Register;
-- External interrupt configuration register 1 (AFIO_EXTICR1)
EXTICR1 : EXTICR1_Register;
-- External interrupt configuration register 2 (AFIO_EXTICR2)
EXTICR2 : EXTICR2_Register;
-- External interrupt configuration register 3 (AFIO_EXTICR3)
EXTICR3 : EXTICR3_Register;
-- External interrupt configuration register 4 (AFIO_EXTICR4)
EXTICR4 : EXTICR4_Register;
-- AF remap and debug I/O configuration register
MAPR2 : MAPR2_Register;
end record
with Volatile;
for AFIO_Peripheral use record
EVCR at 0 range 0 .. 31;
MAPR at 4 range 0 .. 31;
EXTICR1 at 8 range 0 .. 31;
EXTICR2 at 12 range 0 .. 31;
EXTICR3 at 16 range 0 .. 31;
EXTICR4 at 20 range 0 .. 31;
MAPR2 at 28 range 0 .. 31;
end record;
-- Alternate function I/O
AFIO_Periph : aliased AFIO_Peripheral
with Import, Address => AFIO_Base;
end STM32.AFIO;
|
reznikmm/matreshka | Ada | 4,353 | ads | ------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- Localization, Internationalization, Globalization for Ada --
-- --
-- Runtime Library Component --
-- --
------------------------------------------------------------------------------
-- --
-- Copyright © 2012-2015, Vadim Godunko <[email protected]> --
-- All rights reserved. --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions --
-- are met: --
-- --
-- * Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- --
-- * Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in the --
-- documentation and/or other materials provided with the distribution. --
-- --
-- * Neither the name of the Vadim Godunko, IE nor the names of its --
-- contributors may be used to endorse or promote products derived from --
-- this software without specific prior written permission. --
-- --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR --
-- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
-- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED --
-- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR --
-- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF --
-- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING --
-- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS --
-- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
-- --
------------------------------------------------------------------------------
-- $Revision$ $Date$
------------------------------------------------------------------------------
pragma Restrictions (No_Elaboration_Code);
-- GNAT: enforce generation of preinitialized data section instead of
-- generation of elaboration code.
package Matreshka.Internals.Unicode.Ucd.Core_00FC is
pragma Preelaborate;
Group_00FC : aliased constant Core_Second_Stage
:= (16#5E# .. 16#63# => -- FC5E .. FC63
(Other_Letter, Neutral,
Other, A_Letter, O_Letter, Alphabetic,
(Alphabetic
| Grapheme_Base
| ID_Continue
| ID_Start
| Changes_When_NFKC_Casefolded => True,
others => False)),
others =>
(Other_Letter, Neutral,
Other, A_Letter, O_Letter, Alphabetic,
(Alphabetic
| Grapheme_Base
| ID_Continue
| ID_Start
| XID_Continue
| XID_Start
| Changes_When_NFKC_Casefolded => True,
others => False)));
end Matreshka.Internals.Unicode.Ucd.Core_00FC;
|
LionelDraghi/smk | Ada | 1,951 | adb | -- -----------------------------------------------------------------------------
-- smk, the smart make (http://lionel.draghi.free.fr/smk/)
-- © 2018, 2019 Lionel Draghi <[email protected]>
-- SPDX-License-Identifier: APSL-2.0
-- -----------------------------------------------------------------------------
-- Licensed under the Apache License, Version 2.0 (the "License");
-- you may not use this file except in compliance with the License.
-- You may obtain a copy of the License at
-- http://www.apache.org/licenses/LICENSE-2.0
-- Unless required by applicable law or agreed to in writing, software
-- distributed under the License is distributed on an "AS IS" BASIS,
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-- See the License for the specific language governing permissions and
-- limitations under the License.
-- -----------------------------------------------------------------------------
with Smk.Settings;
-- -----------------------------------------------------------------------------
procedure Smk.Files.Put (File_List : File_Lists.Map;
Prefix : String := "";
Print_Sources : Boolean := False;
Print_Targets : Boolean := False;
Print_Unused : Boolean := False) is
use File_Lists;
use Smk.Settings;
begin
for F in File_List.Iterate loop
if not (Settings.Filter_Sytem_Files and Is_System (File_List (F)))
then
if (Print_Sources and then Is_Source (File_List (F)))
or else (Print_Targets and then Is_Target (File_List (F)))
or else (Print_Unused and then Is_Unused (File_List (F)))
then
Put_File_Description (Name => Key (F),
File => File_List (F),
Prefix => Prefix);
end if;
end if;
end loop;
end Smk.Files.Put;
|
DrenfongWong/tkm-rpc | Ada | 2,035 | ads | --
-- Copyright (C) 2013 Reto Buerki <[email protected]>
-- Copyright (C) 2013 Adrian-Ken Rueegsegger <[email protected]>
-- All rights reserved.
--
-- Redistribution and use in source and binary forms, with or without
-- modification, are permitted provided that the following conditions
-- are met:
-- 1. Redistributions of source code must retain the above copyright
-- notice, this list of conditions and the following disclaimer.
-- 2. Redistributions in binary form must reproduce the above copyright
-- notice, this list of conditions and the following disclaimer in the
-- documentation and/or other materials provided with the distribution.
-- 3. Neither the name of the University 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 REGENTS 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 REGENTS OR CONTRIBUTORS BE LIABLE
-- FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
-- DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
-- OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
-- HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
-- LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
-- OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
-- SUCH DAMAGE.
--
with Ahven.Framework;
package Tkmrpc_ORB_Tests
is
type Testcase is new Ahven.Framework.Test_Case with null record;
procedure Initialize (T : in out Testcase);
-- Initialize testcase.
procedure Client_Server_ORBs;
-- Test client/server ORB interaction.
procedure C_Test_Client;
-- Test interaction with client written in C.
end Tkmrpc_ORB_Tests;
|
reznikmm/matreshka | Ada | 4,570 | ads | ------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- Localization, Internationalization, Globalization for Ada --
-- --
-- Tools Component --
-- --
------------------------------------------------------------------------------
-- --
-- Copyright © 2015, Vadim Godunko <[email protected]> --
-- All rights reserved. --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions --
-- are met: --
-- --
-- * Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- --
-- * Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in the --
-- documentation and/or other materials provided with the distribution. --
-- --
-- * Neither the name of the Vadim Godunko, IE nor the names of its --
-- contributors may be used to endorse or promote products derived from --
-- this software without specific prior written permission. --
-- --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR --
-- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
-- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED --
-- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR --
-- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF --
-- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING --
-- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS --
-- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
-- --
------------------------------------------------------------------------------
-- $Revision$ $Date$
------------------------------------------------------------------------------
-- This test detects target operating system.
------------------------------------------------------------------------------
with Configure.Abstract_Tests;
package Configure.Tests.Operating_System is
type Operating_System_Test is
new Configure.Abstract_Tests.Abstract_Test with private;
type Operating_Systems is (POSIX, MacOS, Windows);
overriding function Name (Self : Operating_System_Test) return String;
-- Returns name of the test to be used in reports.
overriding function Help
(Self : Operating_System_Test) return Unbounded_String_Vector;
-- Returns help information for test.
overriding procedure Execute
(Self : in out Operating_System_Test;
Arguments : in out Unbounded_String_Vector);
-- Executes test's actions. All used arguments must be removed from
-- Arguments.
function Get_Operating_System
(Self : Operating_System_Test) return Operating_Systems;
-- Returns detected target operating system.
private
type Operating_System_Test is
new Configure.Abstract_Tests.Abstract_Test with record
Executed : Boolean := False;
Operating_System : Operating_Systems;
end record;
end Configure.Tests.Operating_System;
|
Heziode/lsystem-editor | Ada | 4,269 | adb | -------------------------------------------------------------------------------
-- LSE -- L-System Editor
-- Author: Heziode
--
-- License:
-- MIT License
--
-- Copyright (c) 2018 Quentin Dauprat (Heziode) <[email protected]>
--
-- Permission is hereby granted, free of charge, to any person obtaining a
-- copy of this software and associated documentation files (the "Software"),
-- to deal in the Software without restriction, including without limitation
-- the rights to use, copy, modify, merge, publish, distribute, sublicense,
-- and/or sell copies of the Software, and to permit persons to whom the
-- Software is furnished to do so, subject to the following conditions:
--
-- The above copyright notice and this permission notice shall be included in
-- all copies or substantial portions of the Software.
--
-- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
-- FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
-- DEALINGS IN THE SOFTWARE.
-------------------------------------------------------------------------------
with Gtk.Check_Button;
with Gtk.Spin_Button;
package body LSE.View.Callbacks is
procedure Stop_Program (Emitter : access Gtk_Widget_Record'Class)
is
pragma Unreferenced (Emitter);
begin
View.Stop_Program;
end Stop_Program;
procedure LS_Level_Cb (Emitter : access Gtk_Widget_Record'Class)
is
use Gtk.Spin_Button;
Spin : constant Gtk_Spin_Button := Gtk_Spin_Button (Emitter);
begin
View.LS_Level (Integer (Get_Value_As_Int (Spin)));
end LS_Level_Cb;
procedure New_File_Cb (Emitter : access Gtk_Widget_Record'Class)
is
pragma Unreferenced (Emitter);
begin
View.New_File;
end New_File_Cb;
procedure Open_File_Cb (Emitter : access Gtk_Widget_Record'Class)
is
pragma Unreferenced (Emitter);
begin
View.Open;
end Open_File_Cb;
procedure Save_File_Cb (Emitter : access Gtk_Widget_Record'Class)
is
pragma Unreferenced (Emitter);
begin
View.Save;
end Save_File_Cb;
procedure Save_As_File_Cb (Emitter : access Gtk_Widget_Record'Class)
is
pragma Unreferenced (Emitter);
begin
View.Save (True);
end Save_As_File_Cb;
procedure Validate_Cb (Emitter : access Gtk_Widget_Record'Class)
is
pragma Unreferenced (Emitter);
begin
View.Validate;
end Validate_Cb;
procedure Bg_Color_Cb (Emitter : access Gtk_Widget_Record'Class)
is
pragma Unreferenced (Emitter);
begin
View.Background_Color;
end Bg_Color_Cb;
procedure Fg_Color_Cb (Emitter : access Gtk_Widget_Record'Class)
is
pragma Unreferenced (Emitter);
begin
View.Foreground_Color;
end Fg_Color_Cb;
procedure Export_Cb (Emitter : access Gtk_Widget_Record'Class;
Format : String)
is
pragma Unreferenced (Emitter);
begin
View.Export (Format);
end Export_Cb;
procedure About_Cb (Emitter : access Gtk_Widget_Record'Class)
is
pragma Unreferenced (Emitter);
begin
View.About;
end About_Cb;
procedure Export_Bg_Color_Cb (Emitter : access Gtk_Widget_Record'Class;
Item : Gtk_Color_Button)
is
use Gtk.Check_Button;
This : constant Gtk_Check_Button := Gtk_Check_Button (Emitter);
begin
Item.Set_Sensitive (This.Get_Active);
end Export_Bg_Color_Cb;
function Draw_Cb (Emitter : access Gtk_Widget_Record'Class;
Cr : Cairo.Cairo_Context) return Boolean
is
pragma Unreferenced (Emitter);
begin
View.Draw (Cr);
return False;
end Draw_Cb;
procedure Size_Allocate_Cb (Emitter : access Gtk_Widget_Record'Class;
Allocation : Gtk_Allocation)
is
pragma Unreferenced (Emitter, Allocation);
begin
View.Size_Allocate;
end Size_Allocate_Cb;
end LSE.View.Callbacks;
|
faicaltoubali/ENSEEIHT | Ada | 17,065 | adb | with Ada.text_IO ; use Ada.text_IO ;
with Ada.integer_text_IO ; use Ada.integer_text_IO ;
with Ada.Strings.Unbounded; use Ada.Strings.Unbounded;
with Ada.Strings.Unbounded.Text_IO ; use Ada.Strings.Unbounded.Text_IO;
with arbre_genealogique;
procedure programme_principale is
taillearbre : integer;
procedure programme_principale1 (c : in Integer) is
package arbre_gen is
new arbre_genealogique( Registre_Taille => c );
use arbre_gen ;
package Mois_IO is new Enumeration_IO (T_Mois_Gen); use Mois_IO;
Abr : T_Abr_Genea ;
T : T_Ensemble_Identifiant ;
reponse : Integer := 1 ;
reponse1 : Integer ;
reponse2 : Integer ;
reponse3 : Integer ;
Identifiant_racine : Integer ;
Identifiant_Pere : Integer ;
Lieu_Naissance : Unbounded_String ;
Nom_racine : Unbounded_String ;
Nom_pere : Unbounded_String ;
Prenom_racine : Unbounded_String ;
Prenom_pere : Unbounded_String ;
Jour : Integer ;
Annee : Integer ;
Mois : T_Mois_Gen ;
n : Integer ;
m : Integer ;
alpha : Integer ;
Betta : Integer ;
Reponse_Mere_Pere : Integer ;
registre : T_Registre_Genea ;
begin
Initialiser(registre);
Put_Line("Veuillez choisir la procédure que vous voulez opérer" );
Put_Line(" -1 - Veuillez initialiser votre arbre par un individu." );
Put_Line(" -2 - Ajouter un parent d'un individu" );
Put_Line(" -3 - Obtenir le nombre d'ancêtres connus d'un individu donné,lui aussi compris ." );
Put_Line(" -4 - Afficher l'arbre genealogique d'un individu donné ." );
Put_Line(" -5 - Supprimer , pour un arbre genealogique, un individu et ses ancêtres ." );
Put_Line(" -6 - Obtenir l'ensemble des individus qui n'ont qu'un seul parent connu ." );
Put_Line(" -7 - Obtenir l'ensemble des individus qui ont deux parents connus ." );
Put_Line(" -8 - Obtenir l'ensemble des individus dont les deux parents sont inconnus." );
Put_Line(" -9 - Identifier les ancêtres d'un individu sur n donné générations données pour un individu donné.");
Put_Line(" -10- Verifier que deux individus n et m ont un ou plusieurs ancêtres homonymes ." );
Put_Line(" -11- Verifier si un individu existe " );
get(reponse2);
if reponse2 = 1 then
Put_Line ("Vous avez choisi d'initialiser un arbre genealogique par un individu ");
Put_Line ("veuillez entrer donc l'identifiant de votre individu ");
Get (Identifiant_racine );
Put_Line ("quel est le nom de votre individu ");
Nom_racine := Get_Line;Skip_line;
Put_Line ("quel est le prenom de votre racine ");
Prenom_racine := Get_Line;
Put_Line ("quel est sa date de naissance ? ( le jour ) ");
Get (Jour );Skip_line;
Put_Line ("quel est sa date de naissance ? ( le mois ) ");
Get(Mois) ; Skip_line;
Put_Line ("quel est sa date de naissance ? ( l'année ) ");
Get (Annee );
Put_Line ("quel est son lieu de naissance ? ");
Lieu_Naissance := Get_Line ;Skip_line;
Creer_Minimal(Abr ,Identifiant_racine, registre , Nom_racine , Prenom_racine , Jour ,Janvier ,Annee, Lieu_Naissance);
Put_Line ("Merci pour votre saisi , Vous voulez continuer le programme ?" );
Put_Line ("Si oui , tapez 1 . Si non , tapez 2" );
Get (reponse1 );
else
Put("Vous n'avez pas encore creer un arbre genealogique");
Put_Line ("Vous voulez continuer le programme ?" );
Put_Line ("Si oui , tapez 1 . Si non , tapez 2" );
Get (reponse1 );
end if ;
while reponse=1 loop
Put_Line("Veuillez choisir la procédure que vous voulez opérer ");
Put_Line(" -1 - Ajouter un parent ");
Put_Line(" -2 - Obtenir le nombre d'ancêtres connus d'un individu donné,lui aussi compris . ");
Put_Line(" -3 - Afficher l'arbre d'individu donné . ");
Put_Line(" -4 - Supprimer , pour un arbre , un individu et ses ancêtres . ");
Put_Line(" -5 - Obtenir l'ensemble des individu qui n'ont qu'un parent connu . ");
Put_Line(" -6 - Obtenir l'ensemble des individu qui ont deux parents connus . ");
Put_Line(" -7 - Obtenir l'ensemble des individu dont les deux parents sont inconnus. ");
Put_Line(" -8 - Identifier les ancêtres d'un individu sur n donné générations données pour un noeud donné.");
Put_Line(" -9 - Verifier que deux individus n et m ont un ou plusieurs ancêtres homonymes . ");
Put_Line(" -10- Verifier si un individu existe ");
get(reponse3);
if reponse3 = 1 then
Put_Line ("Vous avez choisi d'ajouter un parent");
Put_Line ("Vous voulez ajouter une mère ou un pére ? 1 pour père / 2 pour mère");
Get(Reponse_Mere_Pere);
if Reponse_Mere_Pere = 1 then
Put_Line ("Pour quel identifiant voulez vous ajouter un père?");
Get(Identifiant_racine);
Put_Line ("quel est l'identifiant du parent ajouté?");
Get(Identifiant_Pere);
Put_Line("Quel est son nom");
Nom_pere := Get_Line;Skip_line;
Put_Line("Quel est son prenom");
Prenom_pere := Get_Line;
Put_Line ("quel est sa date de naissance ? ( le jour ) ");
Get (Jour );Skip_line;
Put_Line ("quel est sa date de naissance ? ( le mois ) ");
Get(Mois);Skip_Line;
Put_Line ("quel est sa date de naissance ? ( l'année ) ");
Get (Annee );
Put_Line ("quel est son lieu de naissance ? ");
Lieu_Naissance := Get_Line ;Skip_line;
Ajouter_Pere (Abr,Identifiant_racine,Identifiant_Pere,Registre,Nom_pere,Prenom_pere,Jour,Janvier,Annee,Lieu_Naissance);
elsif Reponse_Mere_Pere = 2 then
Put_Line ("Pour quel identifiant voulez vous ajouter une mère?");
Get(Identifiant_racine);
Put_Line ("quel est l'identifiant du parent ajouté?");
Get(Identifiant_Pere);
Put_Line("Quel est son nom");
Nom_pere := Get_Line;Skip_Line;
Put_Line("Quel est son prenom");
Prenom_pere := Get_Line;
Put_Line ("quel est sa date de naissance ? ( le jour ) ");
Get (Jour );Skip_line;
Put_Line ("quel est sa date de naissance ? ( le mois ) ");
Get (Mois );Skip_Line;
Put_Line ("quel est sa date de naissance ? ( l'année ) ");
Get (Annee );
Put_Line ("quel est son lieu de naissance ? ");
Lieu_Naissance := Get_Line ;Skip_Line;
Ajouter_Mere (Abr,Identifiant_racine,Identifiant_Pere,Registre,Nom_pere,Prenom_pere,Jour,Janvier,Annee,Lieu_Naissance );
end if ;
Put_Line ("Merci pour votre saisi , Vous voulez continuer le programme ?");
Put_Line ("Si oui , tapez 1 . Si non , tapez 2");
get(reponse);
elsif reponse3 =2 then
Put_Line ("Vous avez choisi d'obtenir le nombre d'ancetres d'un individu , veuillez entrer l'identifiant de votre individu ");
Get(Identifiant_racine);
n := Nombre_Ancetre ( Abr , Identifiant_racine ) ;
Put_Line("le nombre d'ancetres de votre individu est");
Put(n);New_Line;
skip_line;
Put_Line ("Merci pour votre saisi , Vous voulez continuer le programme ?");
Put_Line ("Si oui , tapez 1 . Si non , tapez 2");
get(reponse);
skip_line;
elsif reponse3 =3 then
Put_Line ("Vous avez choisi d'afficher l'arbre d'un noeud donné , veuillez entrer l'identifiant de votre noeud");
Get(Identifiant_racine);
skip_line;
Afficher_Arbre_Noeud ( Abr , Identifiant_racine , 1);New_line;
Put_Line ("Merci pour votre saisi , Vous voulez continuer le programme ?");
Put_Line ("Si oui , tapez 1 . Si non , tapez 2");
get(reponse) ;
skip_line;
elsif reponse3 =4 then
Put_Line("Vous avez choisi de supprimer un individu et ses ancetres");
Put_Line("Vous entrer l'identifiant de votre individu");
get(Identifiant_racine);
skip_line;
Supprimer_Noeud_Ancetres ( Abr , Identifiant_racine );
Put_Line("Votre identifiant est bien supprimé avec succes");
Put_Line ("Merci pour votre saisi , Vous voulez continuer le programme ?");
Put_Line ("Si oui , tapez 1 . Si non , tapez 2");
get(reponse);
skip_line;
elsif reponse3 =5 then
Put_Line("Vous avez choisi d'obtenir l'ensemble des individus dont un seul parent est connu");
T := Un_Seul_Parent ( Abr );
Put_Line("L'ensemble est obtenu par succes , Voulez-vous l'afficher ? 1 : oui , 0 : Non ");
get(Betta);
skip_line;
if Betta = 1 then
while T /= Null loop
Put(T.all.Identifiant);New_Line;
T := T.all.suivant ;
end loop ;
end if ;New_Line;
Put_Line ("Merci pour votre saisi , Vous voulez continuer le programme ?");
Put_Line ("Si oui , tapez 1 . Si non , tapez 2");
get(reponse);
skip_line;
elsif reponse3= 6 then
Put_Line("Vous avez choisi d'obtenir l'ensemble des individus qui ont deux parents");
T := Deux_parent( Abr ) ;
Put_Line("L'ensemble est obtenu par succes , Voulez-vous l'afficher ? 1 : oui , 0 : Non ");
get(Betta);
skip_line;
if Betta = 1 then
while T /= Null loop
Put( Avoir_Identifiant (T) );New_Line;
T := Avoir_Suivant ( T ) ;
end loop ;
end if ;New_Line;
Put_Line ("Merci pour votre saisi , Vous voulez continuer le programme ?");
Put_Line ("Si oui , tapez 1 . Si non , tapez 2");
get(reponse);
skip_line;
elsif reponse3=7 then
Put_Line("Vous avez choisi d'Obtenir l'ensemble des individu qui n'ont aucun parent");
T := Aucun_Parent ( Abr );
Put_Line("L'ensemble est obtenu par succes , Voulez-vous l'afficher ? 1 : oui , 0 : Non ");
get(Betta);
if Betta = 1 then
while T /= Null loop
Put(T.all.Identifiant);New_Line;
T := T.all.suivant ;
end loop ;
end if ;New_Line;
Put_Line ("Merci pour votre saisi , Vous voulez continuer le programme ?");
Put_Line ("Si oui , tapez 1 . Si non , tapez 2");
get(reponse);
skip_line;
elsif reponse3=8 then
Put_Line("Vous avez choisi d'identifier les ancêtres d'un individu sur n donné générations données pour un noeud donné");
Put_Line("Veuillez entrer le nombre n");
get(n);
skip_line;
Put("Veuillez entrer votre identifiant");
get(Identifiant_racine);
T := Ancetres_Plusieurs_Generation ( Abr , Identifiant_racine , n );
if Betta = 1 then
while T /= Null loop
Put(T.all.Identifiant);New_Line;
T := T.all.suivant ;
end loop ;
end if ;New_Line;
Put_Line ("Merci pour votre saisi , Vous voulez continuer le programme ?");
Put_Line ("Si oui , tapez 1 . Si non , tapez 2");
get(reponse);
skip_line;
elsif reponse3=9 then
Put_Line("Vous avez choisi de verifier que si deux identifant n et m ont un ancetre commun");
Put_Line("Veuillez entrer l'identifiant n");
get(n);
skip_line;
Put_Line("Veuillez entrer l'identifiant m");
get(m);
skip_line;
if m > n then
alpha := Verifier_Ancetres ( Abr , m , n );
else
alpha := Verifier_Ancetres ( Abr , n , m );
end if;
if alpha = 0 then
Put_Line("Les deux identifiants ne possedent pas un ancetre commun");
elsif alpha = 1 then
Put_Line("Les deux identifiants possedent un ancetre commun");
end if ;
Put_Line ("Merci pour votre saisi , Vous voulez continuer le programme ?");
Put_Line ("Si oui , tapez 1 . Si non , tapez 2");
get(reponse);
skip_line;
elsif reponse3=10 then
Put_Line("Vous avez choisi de verifier si un individu existe ou non");
Put_Line("Veuillez entrer l'identifiant de votre individu");
Get(Identifiant_racine);
skip_line;
Put_Line("La reponse à votre demande est");
if Existe_Noeud ( Abr , Identifiant_racine ) = True then
Put_Line("Vrai");
else
Put_Line("Faux");
end if ;
Put_Line ("Merci pour votre saisi , Vous voulez continuer le programme ?");
Put_Line ("Si oui , tapez 1 . Si non , tapez 2");
get(reponse);
skip_line;
end if ;
end loop ;
if reponse=2 then
Put_Line("vous avez choisi de quitter le programme , Merci ");
end if ;
end programme_principale1;
begin
Put ("Veuillez entrer le nombre de personnes ques vous voulez ajouter dans votre arbre genealogique : ");
Get(taillearbre);
programme_principale1( taillearbre + 1);
end programme_principale ;
|
persan/AdaYaml | Ada | 2,173 | ads | -- part of AdaYaml, (c) 2017 Felix Krause
-- released under the terms of the MIT license, see the file "copying.txt"
with AUnit; use AUnit;
with AUnit.Test_Cases; use AUnit.Test_Cases;
package Yaml.Lexer.Tokenization_Test is
type TC is new Test_Cases.Test_Case with record
Pool : Text.Pool.Reference;
end record;
overriding procedure Register_Tests (T : in out TC);
overriding procedure Set_Up (T : in out TC);
function Name (T : TC) return Message_String;
procedure Empty_Document (T : in out Test_Cases.Test_Case'Class);
procedure Single_Line_Scalar (T : in out Test_Cases.Test_Case'Class);
procedure Multiline_Scalar (T : in out Test_Cases.Test_Case'Class);
procedure Single_Line_Mapping (T : in out Test_Cases.Test_Case'Class);
procedure Multiline_Mapping (T : in out Test_Cases.Test_Case'Class);
procedure Explicit_Mapping (T : in out Test_Cases.Test_Case'Class);
procedure Sequence (T : in out Test_Cases.Test_Case'Class);
procedure Sequence_With_Block_Mappings (T : in out Test_Cases.Test_Case'Class);
procedure Single_Quoted_Scalar (T : in out Test_Cases.Test_Case'Class);
procedure Multiline_Single_Quoted_Scalar (T : in out Test_Cases.Test_Case'Class);
procedure Double_Quoted_Scalar (T : in out Test_Cases.Test_Case'Class);
procedure Multiline_Double_Quoted_Scalar (T : in out Test_Cases.Test_Case'Class);
procedure Escape_Sequences (T : in out Test_Cases.Test_Case'Class);
procedure Block_Scalar (T : in out Test_Cases.Test_Case'Class);
procedure Block_Scalars (T : in out Test_Cases.Test_Case'Class);
procedure Directives (T : in out Test_Cases.Test_Case'Class);
procedure Markers (T : in out Test_Cases.Test_Case'Class);
procedure Flow_Indicators (T : in out Test_Cases.Test_Case'Class);
procedure Adjacent_Map_Values (T : in out Test_Cases.Test_Case'Class);
procedure Tag_Handles (T : in out Test_Cases.Test_Case'Class);
procedure Verbatim_Tag_Handle (T : in out Test_Cases.Test_Case'Class);
procedure Anchors_And_Aliases (T : in out Test_Cases.Test_Case'Class);
procedure Empty_Lines (T : in out Test_Cases.Test_Case'Class);
end Yaml.Lexer.Tokenization_Test;
|
sungyeon/drake | Ada | 37,284 | adb | pragma Check_Policy (Trace => Ignore);
with Ada.Exception_Identification.From_Here;
with Ada.Text_IO.Formatting;
with System.Formatting.Decimal;
with System.Formatting.Literals;
with System.Long_Long_Integer_Types;
package body Ada.Text_IO.Editing is
use Exception_Identification.From_Here;
use type System.Long_Long_Integer_Types.Word_Unsigned;
subtype Word_Unsigned is System.Long_Long_Integer_Types.Word_Unsigned;
procedure To_Picture (
Pic_String : String;
Result : out Picture;
Blank_When_Zero : Boolean := False;
Error : out Boolean);
procedure To_Picture (
Pic_String : String;
Result : out Picture;
Blank_When_Zero : Boolean := False;
Error : out Boolean)
is
type Currency_State is (None, Dollar, Sharp);
pragma Discard_Names (Currency_State);
Currency : Currency_State := None;
type Paren_State is (None, Opened, Closed);
pragma Discard_Names (Paren_State);
Paren : Paren_State := None;
type Sign_State is (None, Plus, Minus);
pragma Discard_Names (Sign_State);
Sign : Sign_State := None;
type Suppression_State is (None, Z, Asterisk);
pragma Discard_Names (Suppression_State);
Suppression : Suppression_State := None;
type State_Type is (
Start,
Any_Sign,
B_After_Sign,
Any_Suppression,
Nine,
Radix,
Fraction);
pragma Discard_Names (State_Type);
State : State_Type := Start;
I : Positive := Pic_String'First;
begin
Result.Length := 0;
Result.Has_V := False;
Result.Has_Dollar := None;
Result.Blank_When_Zero := Blank_When_Zero;
Result.Real_Blank_When_Zero := True;
Result.First_Sign_Position := 0;
Result.Aft := 0;
while I <= Pic_String'Last loop
case Pic_String (I) is
when '(' =>
declare
Count_First : Positive;
Count_Last : Natural;
Count : Natural;
begin
Formatting.Get_Tail (
Pic_String (I + 1 .. Pic_String'Last),
First => Count_First);
declare
Count_U : Word_Unsigned;
begin
System.Formatting.Literals.Get_Literal (
Pic_String (Count_First .. Pic_String'Last),
Count_Last,
Count_U,
Error => Error);
if Error
or else Count_U > Word_Unsigned (Natural'Last)
then
return; -- Picture_Error
end if;
Count := Natural (Count_U);
end;
if Count = 0
or else I = Pic_String'First
or else I + Count - 1 > Pic_String'Last
then
Error := True;
return; -- Picture_Error
end if;
System.Formatting.Fill_Padding (
Result.Expanded (
Result.Length + 1 ..
Result.Length + Count - 1),
Pic_String (I - 1));
Result.Length := Result.Length + Count - 1;
I := Count_Last + 1;
end;
when ')' =>
Error := True;
return; -- Picture_Error
when others =>
Result.Length := Result.Length + 1;
if Result.Length > Result.Expanded'Last then
Error := True;
return; -- Picture_Error
end if;
Result.Expanded (Result.Length) := Pic_String (I);
case Pic_String (I) is
when '$' =>
if Currency = Sharp then
Error := True;
return; -- Picture_Error
end if;
Currency := Dollar;
if State >= Radix then
if Result.Has_Dollar = None then
Error := True;
return; -- Picture_Error
end if;
Result.Aft := Result.Aft + 1;
else
Result.Has_Dollar := Previous;
end if;
when '#' =>
if Currency = Dollar then
Error := True;
return; -- Picture_Error
end if;
Currency := Sharp;
when '<' =>
if Paren = Closed then
Error := True;
return; -- Picture_Error
end if;
Paren := Opened;
if Result.First_Sign_Position = 0 then
Result.First_Sign_Position := Result.Length;
end if;
if State >= Radix then
State := Fraction;
Result.Aft := Result.Aft + 1;
end if;
when '>' =>
if Paren /= Opened then
Error := True;
return; -- Picture_Error
end if;
Paren := Closed;
when '+' =>
if Sign = Minus or else State >= Radix then
Error := True;
return; -- Picture_Error
end if;
if Result.First_Sign_Position = 0 then
Result.First_Sign_Position := Result.Length;
end if;
Sign := Plus;
if State < Any_Sign then
State := Any_Sign;
end if;
when '-' =>
if Sign = Plus or else State >= Radix then
Error := True;
return; -- Picture_Error
end if;
if Result.First_Sign_Position = 0 then
Result.First_Sign_Position := Result.Length;
end if;
Sign := Minus;
if State < Any_Sign then
State := Any_Sign;
end if;
when '*' =>
if Blank_When_Zero then
Error := True;
return; -- Picture_Error
end if;
Result.Real_Blank_When_Zero := False;
if State >= Radix then
State := Fraction;
Result.Aft := Result.Aft + 1;
elsif Suppression = Z
or else State > Any_Suppression
then
Error := True;
return; -- Picture_Error
else
Suppression := Asterisk;
State := Any_Suppression;
end if;
when 'Z' | 'z' =>
Result.Expanded (Result.Length) := 'Z';
if State >= Radix then
State := Fraction;
Result.Aft := Result.Aft + 1;
elsif Suppression = Asterisk
or else State > Any_Suppression
then
Error := True;
return; -- Picture_Error
else
Suppression := Z;
State := Any_Suppression;
end if;
when '9' =>
Result.Real_Blank_When_Zero := False;
if State >= Radix then
State := Fraction;
Result.Aft := Result.Aft + 1;
elsif State > Nine then
Error := True;
return; -- Picture_Error
else
State := Nine;
end if;
when '.' =>
if State > Radix
or else (
State <= Any_Sign
and then Currency = None
and then Paren = None)
then
Error := True;
return; -- Picture_Error
end if;
State := Radix;
Result.Radix_Position := Result.Length;
when 'V' | 'v' =>
Result.Expanded (Result.Length) := 'V';
if State > Radix
or else (
State <= Any_Sign
and then Currency = None
and then Paren = None)
then
Error := True;
return; -- Picture_Error
end if;
State := Radix;
Result.Radix_Position := Result.Length;
Result.Has_V := True;
when 'B' | 'b' =>
Result.Expanded (Result.Length) := 'B';
if State = Any_Sign then
State := B_After_Sign;
end if;
when '_' | '/' | '0' =>
null;
when others =>
Error := True;
return; -- Picture_Error
end case;
I := I + 1;
end case;
end loop;
if Paren = Opened
or else (
State < Any_Sign
and then Currency = None
and then Paren = None)
or else State = B_After_Sign -- CXF3A01
then
Error := True;
return; -- Picture_Error
end if;
if State < Radix then
Result.Radix_Position := Result.Length + 1;
end if;
Result.Real_Blank_When_Zero :=
(Result.Real_Blank_When_Zero and then State > Any_Suppression)
or else Blank_When_Zero;
Error := False;
end To_Picture;
function Length (Pic : Picture; Currency : String := Default_Currency)
return Natural;
function Length (Pic : Picture; Currency : String := Default_Currency)
return Natural
is
Result : Natural := Pic.Length;
begin
if Pic.Has_V then
Result := Result - 1;
end if;
if Pic.Has_Dollar /= None then
Result := Result + Currency'Length - 1;
end if;
return Result;
end Length;
procedure Image (
Item : Long_Long_Integer;
Result : out String;
Scale : Integer;
Fore : Integer;
Pic : Picture;
Currency : String := Default_Currency;
Fill : Character := Default_Fill;
Separator : Character := Default_Separator;
Radix_Mark : Character := Default_Radix_Mark;
Error : out Boolean);
procedure Image (
Item : Long_Long_Integer;
Result : out String;
Scale : Integer;
Fore : Integer;
Pic : Picture;
Currency : String := Default_Currency;
Fill : Character := Default_Fill;
Separator : Character := Default_Separator;
Radix_Mark : Character := Default_Radix_Mark;
Error : out Boolean) is
begin
if Pic.Real_Blank_When_Zero and then Item = 0 then
System.Formatting.Fill_Padding (Result, ' ');
else
declare
Currency_Length : constant Natural := Currency'Length;
Aft : constant Natural := Pic.Aft;
Item_Image : String (1 .. Fore + Aft + 2); -- sign and '.'
Item_Fore_Last, Item_Last : Natural;
Radix_Position : Integer := Pic.Radix_Position;
begin
if Pic.Has_Dollar = Previous then
Radix_Position := Radix_Position + Currency_Length - 1;
end if;
System.Formatting.Decimal.Image (
Item,
Item_Image,
Item_Fore_Last,
Item_Last,
Scale,
Signs => (' ', ' ', ' '), -- for skipping
Fore_Digits_Width => Fore,
Fore_Digits_Fill => ' ',
Aft_Width => Aft);
-- skip single zero before decimal point
if Item_Image (Item_Image'First + Fore - 1) = ' ' -- sign is blank
and then Item_Image (Item_Image'First + Fore) = '0'
then
Item_Image (Item_Image'First + Fore) := ' ';
end if;
-- before decimal point
declare
Result_Index : Natural := Result'First + Radix_Position - 2;
Pic_Index : Natural := Pic.Radix_Position - 1;
Pic_Leading_Index : Natural := Pic_Index;
Sign_Filled : Boolean := False;
Paren_Filled : Boolean := False;
Currency_Filled : Boolean := False;
Dollar_Used : Boolean := False;
begin
for I in reverse
Item_Image'First .. Item_Image'First + Fore
loop
exit when Item_Image (I) = ' ';
loop
if Pic_Index < Pic.Expanded'First then
Error := True; -- overflow
return; -- Layout_Error
end if;
pragma Assert (Result_Index >= Result'First);
if Pic.Expanded (Pic_Index) = '>' then
if Item < 0 then
Result (Result_Index) := ')';
else
Result (Result_Index) := ' ';
end if;
Result_Index := Result_Index - 1;
Pic_Index := Pic_Index - 1;
elsif Pic.Expanded (Pic_Index) = '_' then
Result (Result_Index) := Separator;
Result_Index := Result_Index - 1;
Pic_Index := Pic_Index - 1;
elsif Pic.Expanded (Pic_Index) = '-'
and then Pic_Index = Pic.First_Sign_Position
and then Item < 0
then
Result (Result_Index) := '-';
Result_Index := Result_Index - 1;
Pic_Index := Pic_Index - 1;
Sign_Filled := True;
else
exit;
end if;
end loop;
pragma Assert (Item_Image (I) /= ' ');
Result (Result_Index) := Item_Image (I);
Result_Index := Result_Index - 1;
Pic_Index := Pic_Index - 1;
end loop;
loop
if Pic_Leading_Index > Pic_Index then
Pic_Leading_Index := Pic_Index;
end if;
exit when Pic_Leading_Index < Pic.Expanded'First;
pragma Assert (Result_Index >= Result'First);
case Pic.Expanded (Pic_Leading_Index) is
when '$' =>
if Currency_Filled then
Result (Result_Index) := ' ';
Result_Index := Result_Index - 1;
else
Result (
Result_Index - Currency_Length + 1 ..
Result_Index) :=
Currency;
Result_Index := Result_Index - Currency_Length;
Currency_Filled := True;
Dollar_Used := True;
end if;
Pic_Index := Pic_Index - 1;
when '#' =>
if Currency_Filled then
Result (Result_Index) := ' ';
Result_Index := Result_Index - 1;
Pic_Index := Pic_Index - 1;
else
declare
N : Natural := Currency_Length;
begin
while N > 0 loop
if Pic_Index <= Pic_Leading_Index
and then (
Pic_Index < Pic.Expanded'First
or else (
Pic.Expanded (Pic_Index) /= '#'
and then Pic.Expanded (Pic_Index) /=
'_'))
then
Error := True;
return; -- Layout_Error
end if;
Pic_Index := Pic_Index - 1;
N := N - 1;
end loop;
end;
Result (
Result_Index - Currency_Length + 1 ..
Result_Index) :=
Currency;
Result_Index := Result_Index - Currency_Length;
Currency_Filled := True;
Pic_Leading_Index := Pic_Index;
end if;
when '+' =>
if Sign_Filled then
Result (Result_Index) := ' ';
elsif Item < 0 then
Result (Result_Index) := '-';
Sign_Filled := True;
else
Result (Result_Index) := '+';
Sign_Filled := True;
end if;
Result_Index := Result_Index - 1;
Pic_Index := Pic_Index - 1;
when '-' =>
if Sign_Filled then
Result (Result_Index) := ' ';
elsif Item < 0 then
Result (Result_Index) := '-';
Sign_Filled := True;
else
Result (Result_Index) := ' ';
end if;
Result_Index := Result_Index - 1;
Pic_Index := Pic_Index - 1;
when '<' =>
if not Paren_Filled and then Item < 0 then
Result (Result_Index) := '(';
Paren_Filled := True;
else
Result (Result_Index) := ' ';
end if;
Result_Index := Result_Index - 1;
Pic_Index := Pic_Index - 1;
when '9' =>
Result (Result_Index) := '0';
Result_Index := Result_Index - 1;
Pic_Index := Pic_Index - 1;
when '*' =>
Result (Result_Index) := Fill;
Result_Index := Result_Index - 1;
Pic_Index := Pic_Index - 1;
when '_' =>
if Pic_Leading_Index > Pic.Expanded'First
and then Pic.Expanded (Pic_Leading_Index - 1) =
Pic.Expanded (Pic_Leading_Index + 1)
then
Pic_Leading_Index := Pic_Leading_Index - 1;
else
Result (Result_Index) := ' ';
Result_Index := Result_Index - 1;
Pic_Index := Pic_Index - 1;
end if;
when others =>
Result (Result_Index) := ' ';
Result_Index := Result_Index - 1;
Pic_Index := Pic_Index - 1;
end case;
end loop;
if (Item < 0
and then not Sign_Filled
and then not Paren_Filled) -- minus is not presented
or else (
Pic.Has_Dollar = Previous
and then not Dollar_Used) -- all $ used for item
then
Error := True;
return; -- Layout_Error
end if;
pragma Assert (Result_Index = Result'First - 1);
end;
-- after decimal point
declare
Result_Index : Positive := Result'First + Radix_Position - 1;
Pic_Index : Natural := Pic.Radix_Position + 1;
Paren_Filled : Boolean := False;
Currency_Filled : Boolean := False;
begin
if Pic.Radix_Position <= Pic.Length
and then Pic.Expanded (Pic.Radix_Position) = '.'
then
Result (Result_Index) := Radix_Mark;
Result_Index := Result_Index + 1;
end if;
for I in Item_Image'First + Fore + 2 .. Item_Image'Last loop
exit when Pic_Index > Pic.Length;
if Pic.Expanded (Pic_Index) = '_' then
pragma Assert (Result_Index <= Result'Last);
Result (Result_Index) := Separator;
Result_Index := Result_Index + 1;
Pic_Index := Pic_Index + 1;
end if;
pragma Assert (Result_Index <= Result'Last);
Result (Result_Index) := Item_Image (I);
Result_Index := Result_Index + 1;
Pic_Index := Pic_Index + 1;
end loop;
while Pic_Index <= Pic.Length loop
pragma Assert (Result_Index <= Result'Last);
case Pic.Expanded (Pic_Index) is
when '#' =>
if Currency_Filled then
Result (Result_Index) := ' ';
Result_Index := Result_Index + 1;
Pic_Index := Pic_Index + 1;
else
declare
N : Natural := Currency_Length;
begin
while N > 0 loop
if Pic_Index > Pic.Length
or else Pic.Expanded (Pic_Index) /= '#'
then
Error := True;
return; -- Layout_Error
end if;
Pic_Index := Pic_Index + 1;
N := N - 1;
end loop;
end;
Result (
Result_Index ..
Result_Index + Currency_Length - 1) :=
Currency;
Result_Index := Result_Index + Currency_Length;
Currency_Filled := True;
end if;
when '>' =>
if not Paren_Filled and then Item < 0 then
Result (Result_Index) := ')';
Paren_Filled := True;
else
Result (Result_Index) := ' ';
end if;
Result_Index := Result_Index + 1;
Pic_Index := Pic_Index + 1;
when '_' =>
Result (Result_Index) := Separator;
Result_Index := Result_Index + 1;
Pic_Index := Pic_Index + 1;
when others =>
Result (Result_Index) := ' ';
Result_Index := Result_Index + 1;
Pic_Index := Pic_Index + 1;
end case;
end loop;
pragma Assert (Result_Index = Result'Last + 1);
end;
end;
end if;
Error := False;
end Image;
-- implementation
function Valid (
Pic_String : String;
Blank_When_Zero : Boolean := False)
return Boolean
is
Dummy : Picture;
Error : Boolean;
begin
To_Picture (
Pic_String,
Dummy,
Blank_When_Zero => Blank_When_Zero,
Error => Error);
return not Error;
end Valid;
function To_Picture (
Pic_String : String;
Blank_When_Zero : Boolean := False)
return Picture
is
Error : Boolean;
begin
return Result : Picture do
To_Picture (
Pic_String,
Result,
Blank_When_Zero => Blank_When_Zero,
Error => Error);
if Error then
Raise_Exception (Picture_Error'Identity);
end if;
end return;
end To_Picture;
function Pic_String (Pic : Picture) return String is
begin
return Pic.Expanded (1 .. Pic.Length);
end Pic_String;
function Blank_When_Zero (Pic : Picture) return Boolean is
begin
return Pic.Blank_When_Zero;
end Blank_When_Zero;
package body Decimal_Output is
function Overloaded_Length (Pic : Picture; Currency : String)
return Natural
renames Editing.Length;
function Overloaded_Length (Pic : Picture; Currency : Wide_String)
return Natural is
begin
return Overloaded_Length (
Pic,
Currency => String'(1 .. Currency'Length => '$'));
end Overloaded_Length;
function Overloaded_Length (Pic : Picture; Currency : Wide_Wide_String)
return Natural is
begin
return Overloaded_Length (
Pic,
Currency => String'(1 .. Currency'Length => '$'));
end Overloaded_Length;
function Overloaded_Valid (
Item : Num;
Pic : Picture;
Currency : String)
return Boolean
is
Error : Boolean;
Dummy : String (1 .. Length (Pic, Currency));
begin
Editing.Image (
Long_Long_Integer'Integer_Value (Item),
Dummy,
Num'Scale,
Num'Fore,
Pic,
Currency => Currency,
Fill => Default_Fill,
Separator => Default_Separator,
Radix_Mark => Default_Radix_Mark,
Error => Error);
return not Error;
end Overloaded_Valid;
function Overloaded_Valid (
Item : Num;
Pic : Picture;
Currency : Wide_String)
return Boolean is
begin
return Overloaded_Valid (
Item,
Pic,
Currency => String'(1 .. Currency'Length => '$'));
end Overloaded_Valid;
function Overloaded_Valid (
Item : Num;
Pic : Picture;
Currency : Wide_Wide_String)
return Boolean is
begin
return Overloaded_Valid (
Item,
Pic,
Currency => String'(1 .. Currency'Length => '$'));
end Overloaded_Valid;
function Overloaded_Image (
Item : Num;
Pic : Picture;
Currency : String;
Fill : Character;
Separator : Character;
Radix_Mark : Character)
return String
is
Error : Boolean;
begin
return Result : String (1 .. Length (Pic, Currency)) do
Editing.Image (
Long_Long_Integer'Integer_Value (Item),
Result,
Num'Scale,
Num'Fore,
Pic,
Currency => Currency,
Fill => Fill,
Separator => Separator,
Radix_Mark => Radix_Mark,
Error => Error);
if Error then
raise Layout_Error;
end if;
end return;
end Overloaded_Image;
function Overloaded_Image (
Item : Num;
Pic : Picture;
Currency : Wide_String;
Fill : Wide_Character;
Separator : Wide_Character;
Radix_Mark : Wide_Character)
return Wide_String
is
Currency_Length : constant Natural := Currency'Length;
Image : constant String :=
Overloaded_Image (
Item,
Pic,
Currency => String'(1 .. Currency_Length => '$'),
Fill => '*', -- Editing.Default_Fill
Separator => ',', -- Editing.Default_Separator
Radix_Mark => '.'); -- Editing.Default_Radix_Mark
begin
return Result : Wide_String (Image'Range) do
declare
I : Positive := Result'First;
begin
while I <= Result'Last loop
case Image (I) is
when '$' =>
Result (I .. I + Currency_Length - 1) := Currency;
I := I + Currency_Length;
when '*' =>
Result (I) := Fill;
I := I + 1;
when ',' =>
Result (I) := Separator;
I := I + 1;
when '.' =>
Result (I) := Radix_Mark;
I := I + 1;
when others =>
Result (I) :=
Wide_Character'Val (Character'Pos (Image (I)));
I := I + 1;
end case;
end loop;
end;
end return;
end Overloaded_Image;
function Overloaded_Image (
Item : Num;
Pic : Picture;
Currency : Wide_Wide_String;
Fill : Wide_Wide_Character;
Separator : Wide_Wide_Character;
Radix_Mark : Wide_Wide_Character)
return Wide_Wide_String
is
Currency_Length : constant Natural := Currency'Length;
Image : constant String :=
Overloaded_Image (
Item,
Pic,
Currency => String'(1 .. Currency_Length => '$'),
Fill => '*', -- Editing.Default_Fill
Separator => ',', -- Editing.Default_Separator
Radix_Mark => '.'); -- Editing.Default_Radix_Mark
begin
return Result : Wide_Wide_String (Image'Range) do
declare
I : Positive := Result'First;
begin
while I <= Result'Last loop
case Image (I) is
when '$' =>
Result (I .. I + Currency_Length - 1) := Currency;
I := I + Currency_Length;
when '*' =>
Result (I) := Fill;
I := I + 1;
when ',' =>
Result (I) := Separator;
I := I + 1;
when '.' =>
Result (I) := Radix_Mark;
I := I + 1;
when others =>
Result (I) :=
Wide_Wide_Character'Val (Character'Pos (Image (I)));
I := I + 1;
end case;
end loop;
end;
end return;
end Overloaded_Image;
procedure Overloaded_Put (
File : File_Type;
Item : Num;
Pic : Picture;
Currency : String;
Fill : Character;
Separator : Character;
Radix_Mark : Character) is
begin
Overloaded_Put (
File, -- checking the predicate
Overloaded_Image (
Item,
Pic,
Currency => Currency,
Fill => Fill,
Separator => Separator,
Radix_Mark => Radix_Mark));
end Overloaded_Put;
procedure Overloaded_Put (
File : File_Type;
Item : Num;
Pic : Picture;
Currency : Wide_String;
Fill : Wide_Character;
Separator : Wide_Character;
Radix_Mark : Wide_Character) is
begin
Overloaded_Put (
File, -- checking the predicate
Overloaded_Image (
Item,
Pic,
Currency => Currency,
Fill => Fill,
Separator => Separator,
Radix_Mark => Radix_Mark));
end Overloaded_Put;
procedure Overloaded_Put (
File : File_Type;
Item : Num;
Pic : Picture;
Currency : Wide_Wide_String;
Fill : Wide_Wide_Character;
Separator : Wide_Wide_Character;
Radix_Mark : Wide_Wide_Character) is
begin
Overloaded_Put (
File, -- checking the predicate
Overloaded_Image (
Item,
Pic,
Currency => Currency,
Fill => Fill,
Separator => Separator,
Radix_Mark => Radix_Mark));
end Overloaded_Put;
procedure Overloaded_Put (
Item : Num;
Pic : Picture;
Currency : String;
Fill : Character;
Separator : Character;
Radix_Mark : Character) is
begin
Overloaded_Put (
Current_Output.all,
Overloaded_Image (
Item,
Pic,
Currency => Currency,
Fill => Fill,
Separator => Separator,
Radix_Mark => Radix_Mark));
end Overloaded_Put;
procedure Overloaded_Put (
Item : Num;
Pic : Picture;
Currency : Wide_String;
Fill : Wide_Character;
Separator : Wide_Character;
Radix_Mark : Wide_Character) is
begin
Overloaded_Put (
Current_Output.all,
Overloaded_Image (
Item,
Pic,
Currency => Currency,
Fill => Fill,
Separator => Separator,
Radix_Mark => Radix_Mark));
end Overloaded_Put;
procedure Overloaded_Put (
Item : Num;
Pic : Picture;
Currency : Wide_Wide_String;
Fill : Wide_Wide_Character;
Separator : Wide_Wide_Character;
Radix_Mark : Wide_Wide_Character) is
begin
Overloaded_Put (
Current_Output.all,
Overloaded_Image (
Item,
Pic,
Currency => Currency,
Fill => Fill,
Separator => Separator,
Radix_Mark => Radix_Mark));
end Overloaded_Put;
procedure Overloaded_Put (
To : out String;
Item : Num;
Pic : Picture;
Currency : String;
Fill : Character;
Separator : Character;
Radix_Mark : Character) is
begin
Formatting.Tail (
To,
Overloaded_Image (
Item,
Pic,
Currency => Currency,
Fill => Fill,
Separator => Separator,
Radix_Mark => Radix_Mark));
end Overloaded_Put;
procedure Overloaded_Put (
To : out Wide_String;
Item : Num;
Pic : Picture;
Currency : Wide_String;
Fill : Wide_Character;
Separator : Wide_Character;
Radix_Mark : Wide_Character) is
begin
Formatting.Tail (
To,
Overloaded_Image (
Item,
Pic,
Currency => Currency,
Fill => Fill,
Separator => Separator,
Radix_Mark => Radix_Mark));
end Overloaded_Put;
procedure Overloaded_Put (
To : out Wide_Wide_String;
Item : Num;
Pic : Picture;
Currency : Wide_Wide_String;
Fill : Wide_Wide_Character;
Separator : Wide_Wide_Character;
Radix_Mark : Wide_Wide_Character) is
begin
Formatting.Tail (
To,
Overloaded_Image (
Item,
Pic,
Currency => Currency,
Fill => Fill,
Separator => Separator,
Radix_Mark => Radix_Mark));
end Overloaded_Put;
end Decimal_Output;
end Ada.Text_IO.Editing;
|
tum-ei-rcs/StratoX | Ada | 6,724 | ads | ------------------------------------------------------------------------------
-- --
-- GNAT RUN-TIME LIBRARY (GNARL) COMPONENTS --
-- --
-- S Y S T E M . B B . C P U _ P R I M I T I V E S --
-- --
-- S p e c --
-- --
-- Copyright (C) 1999-2002 Universidad Politecnica de Madrid --
-- Copyright (C) 2003-2004 The European Space Agency --
-- Copyright (C) 2003-2016, 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. --
-- --
-- --
-- --
-- --
-- --
-- You should have received a copy of the GNU General Public License and --
-- a copy of the GCC Runtime Library Exception along with this program; --
-- see the files COPYING3 and COPYING.RUNTIME respectively. If not, see --
-- <http://www.gnu.org/licenses/>. --
-- --
------------------------------------------------------------------------------
-- This package contains the primitives which are dependent on the
-- underlying processor.
pragma Restrictions (No_Elaboration_Code);
with System;
with System.BB.Parameters;
package System.BB.CPU_Primitives is
pragma Preelaborate;
type Word is mod 2**System.Word_Size;
------------------------
-- Context management --
------------------------
-- The context buffer is an abstract type that holds all values indexed by
-- Context_Id that make up a thread's state which are not otherwise stored
-- in main memory. This typically includes all user-visible registers, and
-- possibly some other status as well.
-- In case different contexts have different amounts of state (for example,
-- due to absence of a floating-point unit in a particular configuration,
-- or just the FPU not being used), it is expected that these details
-- are handled in the implementation, which should ignore updates of
-- unsupported state and return a default value for queries of such state.
type Context_Buffer is private;
type Context_Id is range 0 .. Parameters.Context_Buffer_Capacity - 1;
-- Type used for accessing to the different elements in the context buffer
procedure Context_Switch;
pragma Inline (Context_Switch);
-- Perform the context switch between the running_thread and the
-- first_thread. The value of running_thread will be updated.
function Get_Context
(Context : Context_Buffer;
Index : Context_Id) return Word;
pragma Inline (Get_Context);
-- Returns item of the specified context.
procedure Set_Context
(Context : in out Context_Buffer;
Index : Context_Id;
Value : Word);
pragma Inline (Set_Context);
-- Updates the given context.
procedure Initialize_Context
(Buffer : not null access Context_Buffer;
Program_Counter : System.Address;
Argument : System.Address;
Stack_Pointer : System.Address);
pragma Inline (Initialize_Context);
-- Initialize_Context inserts inside the context buffer the default
-- values for each register. The values for the stack pointer, the
-- program counter, and argument to be passed are provided as arguments.
---------------------------------
-- Interrupt and trap handling --
---------------------------------
type Vector_Id is range 0 .. Parameters.Trap_Vectors - 1;
procedure Install_Error_Handlers;
pragma Inline (Install_Error_Handlers);
-- Called at system initialization time to install a CPU specific
-- trap handler, GNAT_Error_Handler, that converts synchronous traps
-- to appropriate exceptions.
procedure Install_Trap_Handler
(Service_Routine : System.Address;
Vector : Vector_Id;
Synchronous : Boolean := False);
-- Install a new handler in the trap table, both for synchronous and
-- asynchronous traps. Interrupts must be disabled before the trap
-- handler is called.
procedure Disable_Interrupts;
pragma Inline (Disable_Interrupts);
-- All external interrupts (asynchronous traps) are disabled. Note
-- that this will take care of the CPU specific part of enabling and
-- disabling the interrupts. For systems were this is not sufficient, the
-- Board_Support.Set_Current_Priority routine must also be implemented in
-- order to do the board-specific enable/disable operations.
procedure Enable_Interrupts (Level : Integer);
pragma Inline (Enable_Interrupts);
-- Interrupts are enabled if they are above the value given by Level
procedure Initialize_CPU;
pragma Inline (Initialize_CPU);
-- Set the CPU up to use the proper stack for interrupts, initialize and
-- enable system trap handlers.
private
Context_Buffer_Size : constant :=
Parameters.Context_Buffer_Capacity * System.Word_Size;
-- Size calculated taken into account that the components are 32-bit, and
-- that we want then aligned on 64-bit boundaries.
type Context_Buffer is array (Context_Id) of System.Address;
for Context_Buffer'Size use Context_Buffer_Size;
for Context_Buffer'Alignment use 8;
-- This array contains all the registers that the thread needs to save
-- within its thread descriptor. Using double word boundaries allows us
-- to use double word loads and stores safely in the context switch.
end System.BB.CPU_Primitives;
|
AdaCore/gpr | Ada | 3,439 | adb | --
-- Copyright (C) 2019-2023, AdaCore
--
-- SPDX-License-Identifier: Apache-2.0
--
with Ada.Directories;
with Ada.Exceptions;
with Ada.Strings.Fixed;
with Ada.Text_IO;
with GPR2.Unit;
with GPR2.Context;
with GPR2.Path_Name;
with GPR2.Project.Source.Artifact;
with GPR2.Project.Source.Set;
with GPR2.Project.View;
with GPR2.Project.Tree;
with GPR2.Source_Info.Parser.Ada_Language;
with U3;
procedure Main is
use Ada;
use GPR2;
use GPR2.Project;
procedure Check (Project_Name : Filename_Type);
-- Do check the given project's sources
procedure Output_Filename (Filename : Path_Name.Full_Name);
-- Remove the leading tmp directory
-----------
-- Check --
-----------
procedure Check (Project_Name : Filename_Type) is
Prj : Project.Tree.Object;
Ctx : Context.Object;
View : Project.View.Object;
begin
Project.Tree.Load (Prj, Create (Project_Name), Ctx);
View := Prj.Root_Project;
Text_IO.Put_Line ("Project: " & String (View.Name));
for Source of View.Sources loop
declare
D : Path_Name.Object;
begin
Output_Filename (Source.Path_Name.Value);
Text_IO.Set_Col (20);
Text_IO.Put (" language: " & Image (Source.Language));
if Source.Has_Units then
for Unit of Source.Units loop
Text_IO.Set_Col (40);
Text_IO.Put ("Kind: "
& GPR2.Unit.Library_Unit_Type'Image (Unit.Kind));
Text_IO.Put_Line (" unit: " & String (Source.Unit_Name (Unit.Index)));
if Source.Artifacts.Has_Dependency (Unit.Index) then
D := Source.Artifacts.Dependency (Unit.Index);
if D.Exists then
Text_IO.Set_Col (40);
Text_IO.Put_Line
("deps: " & String (D.Simple_Name));
end if;
end if;
end loop;
end if;
end;
end loop;
-- remove the ali files after printing all source infos (so that we don't
-- remove a multi-unit ali before printing all of its units)
for Source of View.Sources loop
if Source.Has_Units then
for Unit of Source.Units loop
if Source.Artifacts.Has_Dependency (Unit.Index) then
declare
D : Path_Name.Object;
begin
D := Source.Artifacts.Dependency (Unit.Index);
if D.Exists then
Directories.Delete_File (D.Value);
end if;
end;
end if;
end loop;
end if;
end loop;
exception
when E : GPR2.Project_Error =>
Text_IO.Put_Line (Ada.Exceptions.Exception_Message (E));
for M of Prj.Log_Messages.all loop
Text_IO.Put_Line (M.Format);
end loop;
end Check;
---------------------
-- Output_Filename --
---------------------
procedure Output_Filename (Filename : Path_Name.Full_Name) is
I : constant Positive := Strings.Fixed.Index (Filename, "source-ali");
begin
Text_IO.Put (" > " & Filename (I + 8 .. Filename'Last));
end Output_Filename;
begin
U3;
for J in Boolean loop
Check ("source_ali.gpr");
end loop;
end Main;
|
ekoeppen/STM32_Generic_Ada_Drivers | Ada | 414 | ads | with STM32GD.Clock.Tree;
generic
with package Clock_Tree is new STM32GD.Clock.Tree (<>);
package STM32GD.Timeout is
type Microseconds is new Natural;
type Milliseconds is new Natural;
type Seconds is new Natural;
procedure Set (T : Microseconds);
procedure Set (T : Milliseconds);
procedure Set (T : Seconds);
procedure Await;
function Expired return Boolean;
end STM32GD.Timeout;
|
AdaCore/libadalang | Ada | 289 | adb | procedure Test is
generic
Y : in Integer;
package P_G is
type Arr is array (Integer range <>) of Boolean;
subtype R is Integer range 1 .. Y;
type R_Arr is new Arr (R);
end P_G;
package P is new P_G (Y => 10);
V : P.R_Arr;
begin
null;
end Test;
|
tum-ei-rcs/StratoX | Ada | 18,455 | ads | ------------------------------------------------------------------------------
-- --
-- GNAT COMPILER COMPONENTS --
-- --
-- S Y S T E M . L I B M _ D O U B L E --
-- --
-- S p e c --
-- --
-- Copyright (C) 2014-2016, Free Software Foundation, Inc. --
-- --
-- GNAT is free software; you can redistribute it and/or modify it under --
-- terms of the GNU General Public License as published by the Free Soft- --
-- ware Foundation; either version 3, or (at your option) any later ver- --
-- sion. GNAT is distributed in the hope that it will be useful, but WITH- --
-- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY --
-- or FITNESS FOR A PARTICULAR PURPOSE. --
-- --
-- --
-- --
-- --
-- --
-- You should have received a copy of the GNU General Public License and --
-- a copy of the GCC Runtime Library Exception along with this program; --
-- see the files COPYING3 and COPYING.RUNTIME respectively. If not, see --
-- <http://www.gnu.org/licenses/>. --
-- --
-- GNAT was originally developed by the GNAT team at New York University. --
-- Extensive contributions were provided by Ada Core Technologies Inc. --
-- --
------------------------------------------------------------------------------
-- This is the Ada Cert Math specific version of s-libdou.ads
with System.Libm_Prefix;
-- @llrset Libm
-- LLR Libm
-- ========
package System.Libm_Double is
pragma Pure;
package SLP renames System.Libm_Prefix;
-- This package provides an implementation of the various C99 functions
-- used in the Ada run time. It is intended to be used for targets that
-- do not have a C math library, or where the C math library isn't of
-- sufficient quality and accuracy to meet Ada requirements.
-- In case of error conditions, NaNs or infinities are returned as
-- recommended in clause F.9 of the C99 standard. When called from C code,
-- the implementation behaves as if the FENV_ACCESS state is off, assuming
-- default rounding behavior and exception behavior.
-- The following C99 elementary functions are provided:
-- Acos, Acosh, Asin, Asinh, Atan, Atan2, Atanh, Cosh, Exp, Exp2, Log,
-- Log1p, Log2, Pow, Sin, Sinh, Tan, Tanh
-- All functions with a NaN argument return a NaN result, except where
-- stated otherwise. Unless otherwise specified, where the symbol +- occurs
-- in both an argument and the result, the result has the same sign as
-- the argument.
-- Each function lists C special values, Ada expected values as well as
-- Ada accuracy requirements the function meets. For accuracy requirements
-- the maximum relative error (abbreviated as MRE) is given, as well as
-- the domain for which the accuracy is guaranteed, where applicable.
-- The maximum relative error is expressed as multiple of Eps,
-- where Eps is Long_Float'Model_Epsilon.
-- What about principal branch ???
----------
-- Acos --
----------
function Acos (X : Long_Float) return Long_Float
with Export, Convention => C, External_Name => SLP.Prefix & "acos";
-- @llr acos (Long_Float) Special Values
-- The Acos function shall return the following special values:
--
-- C99 special values:
-- Acos (1) = +0
-- Acos (x) = NaN if abs (x) > 1
--
-- Ada expected values:
-- Acos (0) = Pi/2.0 (tightly approximated)
-- Acos (-1) = Pi (tightly approximated)
-- Acos (x) return a result in [0, Pi] radians
--
-- @llr acos (Long_Float) Accuracy
-- The Acos function shall return the inverse cosine of <X> with the
-- following accuracy:
--
-- Ada accuracy requirements:
-- MRE <= 4.0 * Eps
-----------
-- Acosh --
-----------
function Acosh (X : Long_Float) return Long_Float
with Export, Convention => C, External_Name => SLP.Prefix & "acosh";
-- @llr acosh (Long_Float) Special Values
-- The Acosh function shall return the following special values:
--
-- C99 special values:
-- Acosh (1) = +0
-- Acosh (x) = NaN if abs X > 1
-- Acosh (+INF) = +INF
--
-- @llr acosh (Long_Float) Accuracy
-- The Acosh function shall return the inverse hyperbolic tangent of <X>
-- with the following accuracy:
--
-- Ada accuracy requirements:
-- MRE <= 8.0 * Eps
----------
-- Asin --
----------
function Asin (X : Long_Float) return Long_Float
with Export, Convention => C, External_Name => SLP.Prefix & "asin";
-- @llr asin (Long_Float) Special Values
-- The Asin function shall return the following special values:
--
-- C99 special values:
-- Asin (+-0) = +-0
-- Asin (x) = NaN if abs (x) > 1
--
-- Ada expected values:
-- Asin (1) = Pi/2.0 (tightly approximated)
-- Asin (-1) = -Pi/2 (tightly approximated)
-- Asin (x) return a result in [-Pi/2, Pi/2] radians
--
-- @llr asin (Long_Float) Accuracy
-- The Asin function shall return the inverse sine of <X> with the
-- following accuracy:
--
-- Ada accuracy requirements:
-- MRE <= 4.0 * Eps
-----------
-- Asinh --
-----------
function Asinh (X : Long_Float) return Long_Float
with Export, Convention => C, External_Name => SLP.Prefix & "asinh";
-- @llr asinh (Long_Float) Special Values
-- The Asinh function shall return the following special values:
--
-- C99 special values:
-- Asinh (0) = 0
-- Asinh (+INF) = +INF
--
-- @llr asinh (Long_Float) Accuracy
-- The Asinh function shall return the inverse hyperbolic sine of <X>
-- with the following accuracy:
--
-- Ada accuracy requirements:
-- MRE <= 8.0 * Eps
----------
-- Atan --
----------
function Atan (X : Long_Float) return Long_Float
with Export, Convention => C, External_Name => SLP.Prefix & "atan";
-- @llr atan (Long_Float) Special Values
-- The Atan function shall return the following special values:
--
-- C99 special values:
-- Atan (+-0) = +-Pi
-- Atan2 (+-INF) = +-0.5 * Pi
--
-- C expected values:
-- Atan (x) return a result in [-Pi/2, Pi/2]
-----------
-- Atan2 --
-----------
function Atan2 (Y : Long_Float; X : Long_Float) return Long_Float
with Export, Convention => C, External_Name => SLP.Prefix & "atan2";
-- @llr atan2 (Long_Float; Long_Float) Special Values
-- The Atan2 function shall return the following special values:
--
-- C99 special values:
-- Atan2 (+-0, -0) = +-Pi
-- Atan2 (+-0, +0) = +-0
-- Atan2 (+-0, x) = +-Pi, if x < 0
-- Atan2 (+-0, x) = +-0, if x > 0
-- Atan2 (y, +-0) = -0.5 * Pi, if y < 0
-- Atan2 (y, +-0) = 0.5 * Pi, if y > 0
-- Atan2 (+-y, -INF) = +-Pi, if y > 0 and y is finite
-- (tightly approximated)
-- Atan2 (+-y, -INF) = +-0, if y < 0 and y is finite
-- Atan2 (+-INF, x) = +-0.5 * Pi, if x is finite
-- (tightly approximated)
-- Atan2 (+-INF, -INF) = +-0.75 * Pi (tightly approximated)
-- Atan2 (+-INF, +INF) = +-0.25 * Pi (tightly approximated)
--
-- Ada expected values:
-- Atan2 (y, x) return a result in [-Pi, Pi]
--
-- @llr atan2 (Long_Float; Long_Float) Accuracy
-- The Atan2 function shall return the inverse tangent of <Y> / <X>
-- with the following accuracy:
--
-- Ada accuracy requirements:
-- MRE <= 4.0 * Eps
-----------
-- Atanh --
-----------
function Atanh (X : Long_Float) return Long_Float
with Export, Convention => C, External_Name => SLP.Prefix & "atanh";
-- @llr atanh (Long_Float) Special Values
-- The Atanh function shall return the following special values:
--
-- C99 special values:
-- Atanh (0) = 0
-- Atanh (+-1) = +- INF
-- Atanh (X) = NaN for abs X > 1
--
-- @llr atanh (Long_Float) Accuracy
-- The Atanh function shall return the inverse hyperbolic tangent of <X>
-- with the following accuracy:
--
-- Ada accuracy requirements:
-- MRE <= 8.0 * Eps
---------
-- Cos --
---------
function Cos (X : Long_Float) return Long_Float
with Export, Convention => C, External_Name => SLP.Prefix & "cos";
-- @llr cos (Long_Float) Special Values
-- The Cos function shall return the following special values:
--
-- C99 special values:
-- Cos (+-0) = 1
-- Cos (+-INF) = NaN
--
-- Ada expected values:
-- abs (Cos (x)) <= 1
--
-- @llr cos (Long_Float) Accuracy
-- The Cos function shall return the cosine of <X>
-- with the following accuracy:
--
-- Ada accuracy requirements:
-- MRE <= 2.0 * Eps
----------
-- Cosh --
----------
function Cosh (X : Long_Float) return Long_Float
with Export, Convention => C, External_Name => SLP.Prefix & "cosh";
-- @llr cosh (Long_Float) Special Values
-- The Cosh function shall return the following special values:
--
-- C99 special values:
-- Cosh (+-0) = 1
-- Cosh (+-INF) = +INF
--
-- Ada expected values:
-- abs (Cosh (x)) > 1
--
-- @llr cosh (Long_Float) Accuracy
-- The Cosh function shall return the hyperbolic cosine of <X>
-- with the following accuracy:
--
-- Ada accuracy requirements:
-- MRE <= 8.0 * Eps
---------
-- Exp --
---------
function Exp (X : Long_Float) return Long_Float
with Export, Convention => C, External_Name => SLP.Prefix & "exp";
-- @llr exp (Long_Float) Special Values
-- The Exp function shall return the following special values:
--
-- C99 special values:
-- Exp (+-0) = 1
-- Exp (-INF) = +0
-- Exp (+INF) = +INF
--
-- @llr exp (Long_Float) Accuracy
-- The Exp function shall return the exponential of <X>
-- with the following accuracy:
--
-- Ada accuracy requirements:
-- MRE <= 4.0 * Eps
----------
-- Exp2 --
----------
function Exp2 (X : Long_Float) return Long_Float
with Export, Convention => C, External_Name => SLP.Prefix & "exp2";
-- @llr exp2 (Long_Float) Special Values
-- The Exp2 function shall return the following special values:
--
-- C99 special values:
-- Exp2 (+-0) = 1
-- Exp2 (-INF) = +0
-- Exp2 (+INF) = +INF
--
-- @llr exp2 (Long_Float) Accuracy
-- The Exp2 function shall return the exponential of <X> in base 2
-- with the following accuracy:
--
-- Accuracy requirements:
-- MRE <= 4.0 * Eps
---------
-- Log --
---------
function Log (X : Long_Float) return Long_Float
with Export, Convention => C, External_Name => SLP.Prefix & "log";
-- @llr log (Long_Float) Special Values
-- The Log function shall return the following special values:
--
-- C99 special values:
-- Log (+-0) = -INF
-- Log (1) = +0
-- Log (x) = NaN if x<0
-- Log (+INF) = +INF
--
-- @llr log (Long_Float) Accuracy
-- The Log function shall return the logarithm of <X>
-- with the following accuracy:
--
-- Ada accuracy requirements:
-- MRE <= 4.0 * Eps
-----------
-- Log1p --
-----------
function Log1p (X : Long_Float) return Long_Float
with Export, Convention => C, External_Name => SLP.Prefix & "log1p";
-- @llr log1p (Long_Float) Special Values:
-- The Log1p function shall return the following special values:
--
-- C99 special values:
-- Log1p (+-0) = -INF
-- Log1p (1) = +0
-- Log1p (x) = NaN if x<0
-- Log1p (+INF) = +INF
--
-- @llr log1p (Long_Float) Accuracy
-- The Log1p function shall return the logarithm of <X> + 1
-- with the following accuracy:
--
-- Accuracy requirements:
-- MRE <= 4.0 * Eps
----------
-- Log2 --
----------
function Log2 (X : Long_Float) return Long_Float
with Export, Convention => C, External_Name => SLP.Prefix & "log2";
-- @llr log2 (Long_Float) Special Values
-- The Log2 function shall return the following special values:
--
-- C99 Special values:
-- Log2 (+-0) = -INF
-- Log2 (1) = +0
-- Log2 (x) = NaN if x<0
-- Log2 (+INF) = +INF
--
-- @llr log2 (Long_Float) Accuracy
-- The Log2 function shall return the logarithm of <X> in base 2
-- with the following accuracy:
--
-- Accuracy requirements:
-- MRE <= 4.0 * Eps
---------
-- Pow --
---------
function Pow (Left, Right : Long_Float) return Long_Float
with Export, Convention => C, External_Name => SLP.Prefix & "pow";
-- @llr pow (Long_Float; Long_Float) Special Values
-- The Pow function shall return the following special values
--
-- C99 Special values:
-- Pow (+-0, y) = +-INF, if y < 0 and y an odd integer
-- Pow (+-0, y) = +INF, if y < 0 and y not an odd integer
-- Pow (+-0, y) = +-0 if y > 0 and y an odd integer
-- Pow (+-0, y) = +0 if y > 0 and y not an odd integer
-- Pow (-1, +-INF) = 1
-- Pow (1, y) = 1 for any y, even a NaN
-- Pow (x, +-0) = 1 for any x, even a NaN
-- Pow (x, y) = NaN, if x < 0 and both x and y finite and not integer
-- Pow (x, -INF) = +INF if abs (x) < 1
-- Pow (x, -INF) = +0 if abs (x) > 1
-- Pow (x, +INF) = +0 if abs (x) < 1
-- Pow (x, +INF) = +INF if abs (x) > 1
-- Pow (-INF, y) = -0 if y < 0 and y an odd integer
-- Pow (-INF, y) = +0 if y < 0 and y not an odd integer
-- Pow (-INF, y) = -INF if y > 0 and y an odd integer
-- Pow (-INF, y) = +INF if y > 0 and y not an odd integer
-- Pow (+INF, y) = +0 if y < 0
-- Pow (+INF, y) = +INF if y > 0
--
-- @llr pow (Long_Float; Long_Float) Accuracy
-- The Pow function shall return <Left> to the power of <Right>
-- with the following accuracy:
--
-- Ada Accuracy requirements:
-- MRE <= (4.0 + abs (x * Log (y)) / 32) * Eps
---------
-- Sin --
---------
function Sin (X : Long_Float) return Long_Float
with Export, Convention => C, External_Name => SLP.Prefix & "sin";
-- @llr sin (Long_Float) Special Values
-- The Sin function shall return the following special values
--
-- C99 special values:
-- Sin (+-0) = +-0
-- Sin (+-INF) = NaN
--
-- @llr sin (Long_Float) Accuracy
-- The Sin function shall return the sine of <X>
-- with the following accuracy:
--
-- Ada accuracy requirements:
-- MRE <= 2.0 * Eps
----------
-- Sinh --
----------
function Sinh (X : Long_Float) return Long_Float
with Export, Convention => C, External_Name => SLP.Prefix & "sinh";
-- @llr sinh (Long_Float) Special Values
-- The Sinh function shall return the following special values:
--
-- C99 Special values:
-- Sinh (+-0) = +-0
-- Sinh (+-INF) = +-INF
--
-- @llr sinh (Long_Float) Accuracy
-- The Sinh function shall return the hyperbolic sine of <X>
-- with the following accuracy:
--
-- Ada accuracy requirements:
-- MRE <= 8.0 * Eps
----------
-- Sqrt --
----------
function Sqrt (X : Long_Float) return Long_Float
with Convention => C;
-- The Sqrt function shall return the following special values:
--
-- C99 special values:
-- Sqrt (+-0) = +-0
-- Sqrt (INF) = INF
-- Sqrt (X) = NaN, for X < 0.0
---------
-- Tan --
---------
function Tan (X : Long_Float) return Long_Float
with Export, Convention => C, External_Name => SLP.Prefix & "tan";
-- @llr tan (Long_Float) Special Values
-- The Tan function shall return the following special values:
--
-- C99 special values:
-- Tan (+-0) = +0
-- Tan (+-INF) = NaN
--
-- @llr tan (Long_Float) Accuracy
-- The Tan function shall return the tangent of <X>
-- with the following accuracy:
--
-- Ada accuracy requirements:
-- MRE <= 4.0 * Eps
----------
-- Tanh --
----------
function Tanh (X : Long_Float) return Long_Float
with Export, Convention => C, External_Name => SLP.Prefix & "tanh";
-- @llr tanh (Long_Float) Special Values
-- The Tanh function shall return the following special values:
--
-- C99 special values:
-- Tanh (+-0) = +-0
-- Tanh (+-INF) = +-1
--
-- @llr tanh (Long_Float) Accuracy
-- The Tanh function shall return the hyperbolic tangent of <X>
-- with the following accuracy:
--
-- Ada accuracy requirements:
-- MRE <= 8.0 * Eps
private
function Identity (X : Long_Float) return Long_Float is (X);
function Infinity return Long_Float
with Import, Convention => Intrinsic, External_Name => "__builtin_inf";
function NaN return Long_Float is (Infinity - Infinity);
function Exact (X : Long_Long_Float) return Long_Float is (Long_Float (X));
function Epsilon return Long_Float is (Long_Float'Model_Epsilon);
function Maximum_Relative_Error (X : Long_Float) return Float is
(Float (0.0 * X));
end System.Libm_Double;
|
zhmu/ananas | Ada | 10,975 | ads | ------------------------------------------------------------------------------
-- --
-- GNAT COMPILER COMPONENTS --
-- --
-- G N A T . C G I --
-- --
-- S p e c --
-- --
-- Copyright (C) 2000-2022, 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. --
-- --
------------------------------------------------------------------------------
-- This is a package to interface a GNAT program with a Web server via the
-- Common Gateway Interface (CGI).
-- Other related packages are:
-- GNAT.CGI.Cookie which deal with Web HTTP Cookies.
-- GNAT.CGI.Debug which output complete CGI runtime environment
-- Basically this package parse the CGI parameter which are a set of key/value
-- pairs. It builds a table whose index is the key and provides some services
-- to deal with this table.
-- Example:
-- Consider the following simple HTML form to capture a client name:
-- <!DOCTYPE HTML PUBLIC "-//W3C//DTD W3 HTML 3.2//EN">
-- <html>
-- <head>
-- <title>My Web Page</title>
-- </head>
-- <body>
-- <form action="/cgi-bin/new_client" method="POST">
-- <input type=text name=client_name>
-- <input type=submit name="Enter">
-- </form>
-- </body>
-- </html>
-- The following program will retrieve the client's name:
-- with GNAT.CGI;
-- procedure New_Client is
-- use GNAT;
-- procedure Add_Client_To_Database (Name : String) is
-- begin
-- ...
-- end Add_Client_To_Database;
-- begin
-- -- Check that we have 2 arguments (there is two inputs tag in
-- -- the HTML form) and that one of them is called "client_name".
-- if CGI.Argument_Count = 2
-- and then CGI.Key_Exists ("client_name")
-- then
-- Add_Client_To_Database (CGI.Value ("client_name"));
-- end if;
-- ...
-- CGI.Put_Header;
-- Text_IO.Put_Line ("<html><body>< ... Ok ... >");
-- exception
-- when CGI.Data_Error =>
-- CGI.Put_Header ("Location: /htdocs/error.html");
-- -- This returns the address of a Web page to be displayed
-- -- using a "Location:" header style.
-- end New_Client;
-- Note that the names in this package interface have been designed so that
-- they read nicely with the CGI prefix. The recommended style is to avoid
-- a use clause for GNAT.CGI, but to include a use clause for GNAT.
-- This package builds up a table of CGI parameters whose memory is not
-- released. A CGI program is expected to be a short lived program and
-- so it is adequate to have the underlying OS free the program on exit.
package GNAT.CGI is
Data_Error : exception;
-- This is raised when there is a problem with the CGI protocol. Either
-- the data could not be retrieved or the CGI environment is invalid.
--
-- The package will initialize itself by parsing the runtime CGI
-- environment during elaboration but we do not want to raise an
-- exception at this time, so the exception Data_Error is deferred
-- and will be raised when calling any services below (except for Ok).
Parameter_Not_Found : exception;
-- This exception is raised when a specific parameter is not found
Default_Header : constant String := "Content-type: text/html";
-- This is the default header returned by Put_Header. If the CGI program
-- returned data is not an HTML page, this header must be change to a
-- valid MIME type.
type Method_Type is (Get, Post);
-- The method used to pass parameter from the Web client to the
-- server. With the GET method parameters are passed via the command
-- line, with the POST method parameters are passed via environment
-- variables. Others methods are not supported by this implementation.
type Metavariable_Name is
(Auth_Type,
Content_Length,
Content_Type,
Document_Root, -- Web server dependent
Gateway_Interface,
HTTP_Accept,
HTTP_Accept_Encoding,
HTTP_Accept_Language,
HTTP_Connection,
HTTP_Cookie,
HTTP_Extension,
HTTP_From,
HTTP_Host,
HTTP_Referer,
HTTP_User_Agent,
Path,
Path_Info,
Path_Translated,
Query_String,
Remote_Addr,
Remote_Host,
Remote_Port, -- Web server dependent
Remote_Ident,
Remote_User,
Request_Method,
Request_URI, -- Web server dependent
Script_Filename, -- Web server dependent
Script_Name,
Server_Addr, -- Web server dependent
Server_Admin, -- Web server dependent
Server_Name,
Server_Port,
Server_Protocol,
Server_Signature, -- Web server dependent
Server_Software);
-- CGI metavariables that are set by the Web server during program
-- execution. All these variables are part of the restricted CGI runtime
-- environment and can be read using Metavariable service. The detailed
-- meanings of these metavariables are out of the scope of this
-- description. Please refer to http://www.w3.org/CGI/ for a description
-- of the CGI specification. Some metavariables are Web server dependent
-- and are not described in the cited document.
procedure Put_Header
(Header : String := Default_Header;
Force : Boolean := False);
-- Output standard CGI header by default. The header string is followed by
-- an empty line. This header must be the first answer sent back to the
-- server. Do nothing if this function has already been called and Force
-- is False.
function Ok return Boolean;
-- Returns True if the CGI environment is valid and False otherwise.
-- Every service used when the CGI environment is not valid will raise
-- the exception Data_Error.
function Method return Method_Type;
-- Returns the method used to call the CGI
function Metavariable
(Name : Metavariable_Name;
Required : Boolean := False) return String;
-- Returns parameter Name value. Returns the null string if Name
-- environment variable is not defined or raises Data_Error if
-- Required is set to True.
function Metavariable_Exists (Name : Metavariable_Name) return Boolean;
-- Returns True if the environment variable Name is defined in
-- the CGI runtime environment and False otherwise.
function URL return String;
-- Returns the URL used to call this script without the parameters.
-- The URL form is: http://<server_name>[:<server_port>]<script_name>
function Argument_Count return Natural;
-- Returns the number of parameters passed to the client. This is the
-- number of input tags in a form or the number of parameters passed to
-- the CGI via the command line.
---------------------------------------------------
-- Services to retrieve key/value CGI parameters --
---------------------------------------------------
function Value
(Key : String;
Required : Boolean := False) return String;
-- Returns the parameter value associated to the parameter named Key.
-- If parameter does not exist, returns an empty string if Required
-- is False and raises the exception Parameter_Not_Found otherwise.
function Value (Position : Positive) return String;
-- Returns the parameter value associated with the CGI parameter number
-- Position. Raises Parameter_Not_Found if there is no such parameter
-- (i.e. Position > Argument_Count)
function Key_Exists (Key : String) return Boolean;
-- Returns True if the parameter named Key exists and False otherwise
function Key (Position : Positive) return String;
-- Returns the parameter key associated with the CGI parameter number
-- Position. Raises the exception Parameter_Not_Found if there is no
-- such parameter (i.e. Position > Argument_Count)
generic
with procedure
Action
(Key : String;
Value : String;
Position : Positive;
Quit : in out Boolean);
procedure For_Every_Parameter;
-- Iterate through all existing key/value pairs and call the Action
-- supplied procedure. The Key and Value are set appropriately, Position
-- is the parameter order in the list, Quit is set to True by default.
-- Quit can be set to False to control the iterator termination.
private
function Decode (S : String) return String;
-- Decode Web string S. A string when passed to a CGI is encoded,
-- this function will decode the string to return the original
-- string's content. Every triplet of the form %HH (where H is an
-- hexadecimal number) is translated into the character such that:
-- Hex (Character'Pos (C)) = HH.
end GNAT.CGI;
|
reznikmm/matreshka | Ada | 4,899 | ads | ------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- Ada Modeling Framework --
-- --
-- Runtime Library Component --
-- --
------------------------------------------------------------------------------
-- --
-- Copyright © 2012-2013, Vadim Godunko <[email protected]> --
-- All rights reserved. --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions --
-- are met: --
-- --
-- * Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- --
-- * Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in the --
-- documentation and/or other materials provided with the distribution. --
-- --
-- * Neither the name of the Vadim Godunko, IE nor the names of its --
-- contributors may be used to endorse or promote products derived from --
-- this software without specific prior written permission. --
-- --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR --
-- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
-- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED --
-- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR --
-- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF --
-- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING --
-- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS --
-- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
-- --
------------------------------------------------------------------------------
-- $Revision$ $Date$
------------------------------------------------------------------------------
-- This file is generated, don't edit it.
------------------------------------------------------------------------------
with AMF.Generic_Collections;
package AMF.OCL.Loop_Exps.Collections is
pragma Preelaborate;
package OCL_Loop_Exp_Collections is
new AMF.Generic_Collections
(OCL_Loop_Exp,
OCL_Loop_Exp_Access);
type Set_Of_OCL_Loop_Exp is
new OCL_Loop_Exp_Collections.Set with null record;
Empty_Set_Of_OCL_Loop_Exp : constant Set_Of_OCL_Loop_Exp;
type Ordered_Set_Of_OCL_Loop_Exp is
new OCL_Loop_Exp_Collections.Ordered_Set with null record;
Empty_Ordered_Set_Of_OCL_Loop_Exp : constant Ordered_Set_Of_OCL_Loop_Exp;
type Bag_Of_OCL_Loop_Exp is
new OCL_Loop_Exp_Collections.Bag with null record;
Empty_Bag_Of_OCL_Loop_Exp : constant Bag_Of_OCL_Loop_Exp;
type Sequence_Of_OCL_Loop_Exp is
new OCL_Loop_Exp_Collections.Sequence with null record;
Empty_Sequence_Of_OCL_Loop_Exp : constant Sequence_Of_OCL_Loop_Exp;
private
Empty_Set_Of_OCL_Loop_Exp : constant Set_Of_OCL_Loop_Exp
:= (OCL_Loop_Exp_Collections.Set with null record);
Empty_Ordered_Set_Of_OCL_Loop_Exp : constant Ordered_Set_Of_OCL_Loop_Exp
:= (OCL_Loop_Exp_Collections.Ordered_Set with null record);
Empty_Bag_Of_OCL_Loop_Exp : constant Bag_Of_OCL_Loop_Exp
:= (OCL_Loop_Exp_Collections.Bag with null record);
Empty_Sequence_Of_OCL_Loop_Exp : constant Sequence_Of_OCL_Loop_Exp
:= (OCL_Loop_Exp_Collections.Sequence with null record);
end AMF.OCL.Loop_Exps.Collections;
|
AdaCore/langkit | Ada | 3,197 | ads | with Ada.Containers; use Ada.Containers;
with Ada.Exceptions; use Ada.Exceptions;
with Langkit_Support.Lexical_Envs; use Langkit_Support.Lexical_Envs;
with Langkit_Support.Lexical_Envs_Impl;
with Langkit_Support.Symbols;
with Langkit_Support.Text; use Langkit_Support.Text;
with Langkit_Support.Types; use Langkit_Support.Types;
package Support is
subtype Metadata is Integer;
function Get_Context_Version (Dummy_C : Character) return Version_Number
is (0);
function Node_Hash (Dummy_C : Character) return Hash_Type is (0);
function Node_Unit (Dummy_C : Character) return Generic_Unit_Ptr
is (No_Generic_Unit);
function Metadata_Hash (Dummy_MD : Metadata) return Hash_Type is (0);
function Combine (L, R : Metadata) return Metadata is (L + R);
function Parent (Dummy_Node : Character) return Character is (' ');
function Can_Reach (Dummy_Node, Dummy_From : Character) return Boolean
is (True);
function Is_Rebindable (Dummy_Node : Character) return Boolean is (True);
function Node_Image
(Node : Character; Dummy_Short : Boolean := True) return Text_Type
is (To_Text ("'" & Node & "'"));
function Acquire_Rebinding
(Dummy : Character;
Parent : Env_Rebindings;
Old_Env, New_Env : Lexical_Env) return Env_Rebindings
is (new Env_Rebindings_Type'(0, Parent, Old_Env, New_Env, Children => <>));
procedure Register_Rebinding
(Dummy_Node : Character; Dummy_Rebinding : Env_Rebindings) is null;
function Get_Unit_Version (Dummy : Generic_Unit_Ptr) return Version_Number
is (0);
type Ref_Category is (No_Cat);
type Ref_Categories is array (Ref_Category) of Boolean;
type Inner_Env_Assoc is null record;
function Get_Key
(Dummy : Inner_Env_Assoc) return Langkit_Support.Symbols.Symbol_Type
is (null);
function Get_Node (Dummy : Inner_Env_Assoc) return Character is (' ');
function Get_Metadata (Dummy : Inner_Env_Assoc) return Metadata
is (0);
type Inner_Env_Assoc_Array is null record;
function Length (Dummy : Inner_Env_Assoc_Array) return Natural is (0);
function Get
(Dummy_Self : Inner_Env_Assoc_Array;
Dummy_Index : Positive) return Inner_ENv_Assoc
is (raise Program_Error);
procedure Dec_Ref (Self : in out Inner_Env_Assoc_Array) is null;
function Properties_May_Raise (Dummy : Exception_Occurrence) return Boolean
is (False);
package Envs is new Langkit_Support.Lexical_Envs_Impl
(Get_Unit_Version => Get_Unit_Version,
Node_Type => Character,
Node_Metadata => Metadata,
No_Node => ' ',
Empty_Metadata => 0,
Node_Hash => Node_Hash,
Metadata_Hash => Metadata_Hash,
Combine => Combine,
Can_Reach => Can_Reach,
Is_Rebindable => Is_Rebindable,
Node_Text_Image => Node_Image,
Register_Rebinding => Register_Rebinding,
Ref_Category => Ref_Category,
Ref_Categories => Ref_Categories,
Inner_Env_Assoc => Inner_Env_Assoc,
Inner_Env_Assoc_Array => Inner_Env_Assoc_Array);
end Support;
|
reznikmm/matreshka | Ada | 6,900 | adb | ------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- Open Document Toolkit --
-- --
-- Runtime Library Component --
-- --
------------------------------------------------------------------------------
-- --
-- Copyright © 2014, Vadim Godunko <[email protected]> --
-- All rights reserved. --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions --
-- are met: --
-- --
-- * Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- --
-- * Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in the --
-- documentation and/or other materials provided with the distribution. --
-- --
-- * Neither the name of the Vadim Godunko, IE nor the names of its --
-- contributors may be used to endorse or promote products derived from --
-- this software without specific prior written permission. --
-- --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR --
-- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
-- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED --
-- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR --
-- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF --
-- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING --
-- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS --
-- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
-- --
------------------------------------------------------------------------------
-- $Revision$ $Date$
------------------------------------------------------------------------------
with Matreshka.DOM_Documents;
with Matreshka.ODF_String_Constants;
with ODF.DOM.Iterators;
with ODF.DOM.Visitors;
package body Matreshka.ODF_Text.Object_Count_Elements is
------------
-- Create --
------------
overriding function Create
(Parameters : not null access Matreshka.DOM_Elements.Element_L2_Parameters)
return Text_Object_Count_Element_Node is
begin
return Self : Text_Object_Count_Element_Node do
Matreshka.ODF_Text.Constructors.Initialize
(Self'Unchecked_Access,
Parameters.Document,
Matreshka.ODF_String_Constants.Text_Prefix);
end return;
end Create;
----------------
-- Enter_Node --
----------------
overriding procedure Enter_Node
(Self : not null access Text_Object_Count_Element_Node;
Visitor : in out XML.DOM.Visitors.Abstract_Visitor'Class;
Control : in out XML.DOM.Visitors.Traverse_Control) is
begin
if Visitor in ODF.DOM.Visitors.Abstract_ODF_Visitor'Class then
ODF.DOM.Visitors.Abstract_ODF_Visitor'Class
(Visitor).Enter_Text_Object_Count
(ODF.DOM.Text_Object_Count_Elements.ODF_Text_Object_Count_Access
(Self),
Control);
else
Matreshka.DOM_Elements.Abstract_Element_Node
(Self.all).Enter_Node (Visitor, Control);
end if;
end Enter_Node;
--------------------
-- Get_Local_Name --
--------------------
overriding function Get_Local_Name
(Self : not null access constant Text_Object_Count_Element_Node)
return League.Strings.Universal_String
is
pragma Unreferenced (Self);
begin
return Matreshka.ODF_String_Constants.Object_Count_Element;
end Get_Local_Name;
----------------
-- Leave_Node --
----------------
overriding procedure Leave_Node
(Self : not null access Text_Object_Count_Element_Node;
Visitor : in out XML.DOM.Visitors.Abstract_Visitor'Class;
Control : in out XML.DOM.Visitors.Traverse_Control) is
begin
if Visitor in ODF.DOM.Visitors.Abstract_ODF_Visitor'Class then
ODF.DOM.Visitors.Abstract_ODF_Visitor'Class
(Visitor).Leave_Text_Object_Count
(ODF.DOM.Text_Object_Count_Elements.ODF_Text_Object_Count_Access
(Self),
Control);
else
Matreshka.DOM_Elements.Abstract_Element_Node
(Self.all).Leave_Node (Visitor, Control);
end if;
end Leave_Node;
----------------
-- Visit_Node --
----------------
overriding procedure Visit_Node
(Self : not null access Text_Object_Count_Element_Node;
Iterator : in out XML.DOM.Visitors.Abstract_Iterator'Class;
Visitor : in out XML.DOM.Visitors.Abstract_Visitor'Class;
Control : in out XML.DOM.Visitors.Traverse_Control) is
begin
if Iterator in ODF.DOM.Iterators.Abstract_ODF_Iterator'Class then
ODF.DOM.Iterators.Abstract_ODF_Iterator'Class
(Iterator).Visit_Text_Object_Count
(Visitor,
ODF.DOM.Text_Object_Count_Elements.ODF_Text_Object_Count_Access
(Self),
Control);
else
Matreshka.DOM_Elements.Abstract_Element_Node
(Self.all).Visit_Node (Iterator, Visitor, Control);
end if;
end Visit_Node;
begin
Matreshka.DOM_Documents.Register_Element
(Matreshka.ODF_String_Constants.Text_URI,
Matreshka.ODF_String_Constants.Object_Count_Element,
Text_Object_Count_Element_Node'Tag);
end Matreshka.ODF_Text.Object_Count_Elements;
|
google-code/ada-security | Ada | 8,143 | adb | -----------------------------------------------------------------------
-- security-auth-oauth-facebook -- Facebook OAuth based authentication
-- Copyright (C) 2013, 2014 Stephane Carrez
-- Written by Stephane Carrez ([email protected])
--
-- Licensed under the Apache License, Version 2.0 (the "License");
-- you may not use this file except in compliance with the License.
-- You may obtain a copy of the License at
--
-- http://www.apache.org/licenses/LICENSE-2.0
--
-- Unless required by applicable law or agreed to in writing, software
-- distributed under the License is distributed on an "AS IS" BASIS,
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-- See the License for the specific language governing permissions and
-- limitations under the License.
-----------------------------------------------------------------------
with Util.Beans.Objects;
with Util.Beans.Objects.Time;
with Util.Serialize.Mappers.Record_Mapper;
with Util.Http.Rest;
package body Security.Auth.OAuth.Facebook is
--
TIME_SHIFT : constant Duration := 12 * 3600.0;
type Token_Info_Field_Type is (FIELD_APP_ID, FIELD_IS_VALID,
FIELD_EXPIRES, FIELD_ISSUED_AT,
FIELD_USER_ID, FIELD_EMAIL, FIELD_FIRST_NAME,
FIELD_LAST_NAME, FIELD_NAME, FIELD_LOCALE, FIELD_GENDER);
type Token_Info is record
App_Id : Ada.Strings.Unbounded.Unbounded_String;
Is_Valid : Boolean := False;
Expires : Ada.Calendar.Time;
Issued : Ada.Calendar.Time;
User_Id : Ada.Strings.Unbounded.Unbounded_String;
Email : Ada.Strings.Unbounded.Unbounded_String;
Name : Ada.Strings.Unbounded.Unbounded_String;
First_Name : Ada.Strings.Unbounded.Unbounded_String;
Last_Name : Ada.Strings.Unbounded.Unbounded_String;
Locale : Ada.Strings.Unbounded.Unbounded_String;
Gender : Ada.Strings.Unbounded.Unbounded_String;
end record;
type Token_Info_Access is access all Token_Info;
procedure Set_Member (Into : in out Token_Info;
Field : in Token_Info_Field_Type;
Value : in Util.Beans.Objects.Object);
procedure Set_Member (Into : in out Token_Info;
Field : in Token_Info_Field_Type;
Value : in Util.Beans.Objects.Object) is
begin
case Field is
when FIELD_APP_ID =>
Into.App_Id := Util.Beans.Objects.To_Unbounded_String (Value);
when FIELD_IS_VALID =>
Into.Is_Valid := Util.Beans.Objects.To_Boolean (Value);
when FIELD_EXPIRES =>
Into.Expires := Util.Beans.Objects.Time.To_Time (Value);
when FIELD_ISSUED_AT =>
Into.Issued := Util.Beans.Objects.Time.To_Time (Value);
when FIELD_USER_ID =>
Into.User_Id := Util.Beans.Objects.To_Unbounded_String (Value);
when FIELD_EMAIL =>
Into.Email := Util.Beans.Objects.To_Unbounded_String (Value);
when FIELD_NAME =>
Into.Name := Util.Beans.Objects.To_Unbounded_String (Value);
when FIELD_FIRST_NAME =>
Into.First_Name := Util.Beans.Objects.To_Unbounded_String (Value);
when FIELD_LAST_NAME =>
Into.Last_Name := Util.Beans.Objects.To_Unbounded_String (Value);
when FIELD_LOCALE =>
Into.Locale := Util.Beans.Objects.To_Unbounded_String (Value);
when FIELD_GENDER =>
Into.Gender := Util.Beans.Objects.To_Unbounded_String (Value);
end case;
end Set_Member;
package Token_Info_Mapper is
new Util.Serialize.Mappers.Record_Mapper (Element_Type => Token_Info,
Element_Type_Access => Token_Info_Access,
Fields => Token_Info_Field_Type,
Set_Member => Set_Member);
procedure Get_Token_Info is
new Util.Http.Rest.Rest_Get (Element_Mapper => Token_Info_Mapper);
Token_Info_Map : aliased Token_Info_Mapper.Mapper;
-- ------------------------------
-- Initialize the authentication realm.
-- ------------------------------
overriding
procedure Initialize (Realm : in out Manager;
Params : in Parameters'Class;
Provider : in String := PROVIDER_OPENID) is
Client : constant String := Params.Get_Parameter (Provider & ".client_id");
Secret : constant String := Params.Get_Parameter (Provider & ".secret");
begin
Security.Auth.OAuth.Manager (Realm).Initialize (Params, Provider);
Realm.App_Access_Token := To_Unbounded_String (Client & "|" & Secret);
end Initialize;
-- ------------------------------
-- Verify the OAuth access token and retrieve information about the user.
-- ------------------------------
overriding
procedure Verify_Access_Token (Realm : in Manager;
Assoc : in Association;
Request : in Parameters'Class;
Token : in Security.OAuth.Clients.Access_Token_Access;
Result : in out Authentication) is
pragma Unreferenced (Assoc, Request);
use type Ada.Calendar.Time;
T : constant String := Token.Get_Name;
Info : aliased Token_Info;
Now : constant Ada.Calendar.Time := Ada.Calendar.Clock;
begin
Get_Token_Info ("https://graph.facebook.com/debug_token?access_token="
& To_String (Realm.App_Access_Token)
& "&input_token=" & T,
Token_Info_Map'Access,
"/data",
Info'Unchecked_Access);
if not Info.Is_Valid then
Set_Result (Result, INVALID_SIGNATURE, "invalid access token returned");
elsif Info.Issued + TIME_SHIFT < Now then
Set_Result (Result, INVALID_SIGNATURE, "the access token issued more than 1 hour ago");
elsif Info.Expires + TIME_SHIFT < Now then
Set_Result (Result, INVALID_SIGNATURE, "the access token has expored");
elsif Length (Info.User_Id) = 0 then
Set_Result (Result, INVALID_SIGNATURE, "the access token refers to an empty user_id");
elsif Info.App_Id /= Realm.App.Get_Application_Identifier then
Set_Result (Result, INVALID_SIGNATURE,
"the access token was granted for another application");
else
Result.Identity := To_Unbounded_String ("https://graph.facebook.com/");
Append (Result.Identity, Info.User_Id);
Result.Claimed_Id := Result.Identity;
Get_Token_Info ("https://graph.facebook.com/" & To_String (Info.User_Id)
& "?access_token=" & T,
Token_Info_Map'Access,
"",
Info'Unchecked_Access);
Result.Email := Info.Email;
Result.Full_Name := Info.Name;
Result.First_Name := Info.First_Name;
Result.Last_Name := Info.Last_Name;
Result.Language := Info.Locale;
Result.Gender := Info.Gender;
Set_Result (Result, AUTHENTICATED, "authenticated");
end if;
end Verify_Access_Token;
begin
Token_Info_Map.Add_Mapping ("app_id", FIELD_APP_ID);
Token_Info_Map.Add_Mapping ("expires_at", FIELD_EXPIRES);
Token_Info_Map.Add_Mapping ("issued_at", FIELD_ISSUED_AT);
Token_Info_Map.Add_Mapping ("is_valid", FIELD_IS_VALID);
Token_Info_Map.Add_Mapping ("user_id", FIELD_USER_ID);
Token_Info_Map.Add_Mapping ("email", FIELD_EMAIL);
Token_Info_Map.Add_Mapping ("name", FIELD_NAME);
Token_Info_Map.Add_Mapping ("first_name", FIELD_FIRST_NAME);
Token_Info_Map.Add_Mapping ("last_name", FIELD_LAST_NAME);
Token_Info_Map.Add_Mapping ("locale", FIELD_LOCALE);
Token_Info_Map.Add_Mapping ("gender", FIELD_GENDER);
end Security.Auth.OAuth.Facebook;
|
AdaCore/libadalang | Ada | 2,321 | ads | --
-- Copyright (C) 2014-2022, AdaCore
-- SPDX-License-Identifier: Apache-2.0
--
with GNATCOLL.GMP; use GNATCOLL.GMP;
with GNATCOLL.GMP.Integers;
with GNATCOLL.GMP.Rational_Numbers;
with Libadalang.Analysis;
with Langkit_Support.Text; use Langkit_Support.Text;
-- This package implements an expression evaluator for Libadalang. The aim
-- is to allow at least evaluation of expressions that fit the definitions
-- of static expression in the Ada Reference Manual.
package Libadalang.Expr_Eval is
package LAL renames Libadalang.Analysis;
subtype Big_Integer is GNATCOLL.GMP.Integers.Big_Integer;
subtype Rational is GNATCOLL.GMP.Rational_Numbers.Rational;
subtype Double is GNATCOLL.GMP.Double;
type Expr_Kind is (Enum_Lit, Int, Real, String_Lit);
type Eval_Result (Kind : Expr_Kind := Int) is limited record
Expr_Type : LAL.Base_Type_Decl;
case Kind is
when Enum_Lit =>
Enum_Result : LAL.Enum_Literal_Decl;
when Int =>
Int_Result : Big_Integer;
when Real =>
Real_Result : Rational;
when String_Lit =>
String_Result : Unbounded_Text_Type;
-- First and Last are used to keep track of the String objects
-- bounds (this information is required to evaluate slices).
First, Last : Natural;
end case;
end record;
-- This data type represents the result of the evaluation of an expression
function As_Int (Self : Eval_Result) return Big_Integer;
-- Return the given evaluation result as an Integer, if applicable. This
-- will work for enum or int results, not for real results.
--
function As_String (Self : Eval_Result) return Unbounded_Text_Type;
-- Return the given evaluation result as a string, if applicable. This
-- will only work for string results.
function Image (Self : Eval_Result) return String;
-- Return a string representation of Self. Used for testing/debugging
-- purposes.
function Expr_Eval (E : LAL.Expr) return Eval_Result;
-- Evaluate the expression passed as parameter
function Expr_Eval_In_Env
(E : LAL.Expr; Env : LAL.Substitution_Array) return Eval_Result;
-- Evaluate the given expression in the context of the given environment
end Libadalang.Expr_Eval;
|
evgenijaZ/PP-labs | Ada | 1,668 | ads | package Data is
type Matrix is private;
type Vector is private;
protected type Mutex is
entry Seize;
procedure Release;
private
Owned : Boolean := False;
end Mutex;
My_Mutex :Mutex;
procedure Vector_Input(A : out Vector; N : in Integer);
procedure Vector_Output(A : in Vector; N : in Integer; S: in String);
procedure Vector_Generate (A : out Vector; N : in Integer);
procedure Matrix_Input(A : out Matrix; N : in Integer);
procedure Matrix_Output(A : in Matrix; N : in Integer; S: in String);
procedure Matrix_Generate (A : out Matrix; N : in Integer);
procedure Value_Generate (A : out Integer);
function F1(A : in Matrix; D : in Matrix; B : in Vector; N : in Integer) return Matrix;
function F2(a : in Integer; G : in Matrix; K : in Matrix; L : in Matrix; N : in Integer) return Matrix;
function F3(P : in Matrix; R : in Matrix; S : in Vector; T : in Vector; N : in Integer) return Vector;
function Amount ( A: in Vector; B: in Vector; N : in Integer) return Vector;
function Amount ( A: in Matrix; B: in Matrix; N : in Integer) return Matrix;
function Multiple ( A: in Integer; B: in out Matrix; N : in Integer) return Matrix;
function Multiple ( A: in Matrix; B: in Matrix; N : in Integer) return Matrix;
function Multiple ( A: in Matrix; B: in Vector; N : in Integer) return Vector;
function Max (A: Vector; N : in Integer) return Integer;
function Trans (A: in Matrix; N : in Integer) return Matrix;
private
type Vector is array(1..100) of Integer;
type Matrix is array (1..100,1..100) of Integer;
end Data;
|
Fabien-Chouteau/GESTE | Ada | 37,574 | ads | pragma Ada_2005;
pragma Style_Checks (Off);
with Interfaces.C; use Interfaces.C;
with GL_gl_h;
with System;
package GL_glu_h is
-- arg-macro: function gluErrorStringWIN (errCode)
-- return (LPCWSTR) gluErrorString(errCode);
GLU_VERSION_1_1 : constant := 1; -- c:\home\ochem\install\bin\../lib/gcc/i686-pc-mingw32/4.7.3/../../../../i686-pc-mingw32/include/GL/glu.h:111
GLU_VERSION_1_2 : constant := 1; -- c:\home\ochem\install\bin\../lib/gcc/i686-pc-mingw32/4.7.3/../../../../i686-pc-mingw32/include/GL/glu.h:112
GLU_INVALID_ENUM : constant := 100900; -- c:\home\ochem\install\bin\../lib/gcc/i686-pc-mingw32/4.7.3/../../../../i686-pc-mingw32/include/GL/glu.h:114
GLU_INVALID_VALUE : constant := 100901; -- c:\home\ochem\install\bin\../lib/gcc/i686-pc-mingw32/4.7.3/../../../../i686-pc-mingw32/include/GL/glu.h:115
GLU_OUT_OF_MEMORY : constant := 100902; -- c:\home\ochem\install\bin\../lib/gcc/i686-pc-mingw32/4.7.3/../../../../i686-pc-mingw32/include/GL/glu.h:116
GLU_INCOMPATIBLE_GL_VERSION : constant := 100903; -- c:\home\ochem\install\bin\../lib/gcc/i686-pc-mingw32/4.7.3/../../../../i686-pc-mingw32/include/GL/glu.h:117
GLU_VERSION : constant := 100800; -- c:\home\ochem\install\bin\../lib/gcc/i686-pc-mingw32/4.7.3/../../../../i686-pc-mingw32/include/GL/glu.h:119
GLU_EXTENSIONS : constant := 100801; -- c:\home\ochem\install\bin\../lib/gcc/i686-pc-mingw32/4.7.3/../../../../i686-pc-mingw32/include/GL/glu.h:120
-- unsupported macro: GLU_TRUE GL_TRUE
-- unsupported macro: GLU_FALSE GL_FALSE
GLU_SMOOTH : constant := 100000; -- c:\home\ochem\install\bin\../lib/gcc/i686-pc-mingw32/4.7.3/../../../../i686-pc-mingw32/include/GL/glu.h:125
GLU_FLAT : constant := 100001; -- c:\home\ochem\install\bin\../lib/gcc/i686-pc-mingw32/4.7.3/../../../../i686-pc-mingw32/include/GL/glu.h:126
GLU_NONE : constant := 100002; -- c:\home\ochem\install\bin\../lib/gcc/i686-pc-mingw32/4.7.3/../../../../i686-pc-mingw32/include/GL/glu.h:127
GLU_POINT : constant := 100010; -- c:\home\ochem\install\bin\../lib/gcc/i686-pc-mingw32/4.7.3/../../../../i686-pc-mingw32/include/GL/glu.h:129
GLU_LINE : constant := 100011; -- c:\home\ochem\install\bin\../lib/gcc/i686-pc-mingw32/4.7.3/../../../../i686-pc-mingw32/include/GL/glu.h:130
GLU_FILL : constant := 100012; -- c:\home\ochem\install\bin\../lib/gcc/i686-pc-mingw32/4.7.3/../../../../i686-pc-mingw32/include/GL/glu.h:131
GLU_SILHOUETTE : constant := 100013; -- c:\home\ochem\install\bin\../lib/gcc/i686-pc-mingw32/4.7.3/../../../../i686-pc-mingw32/include/GL/glu.h:132
GLU_OUTSIDE : constant := 100020; -- c:\home\ochem\install\bin\../lib/gcc/i686-pc-mingw32/4.7.3/../../../../i686-pc-mingw32/include/GL/glu.h:134
GLU_INSIDE : constant := 100021; -- c:\home\ochem\install\bin\../lib/gcc/i686-pc-mingw32/4.7.3/../../../../i686-pc-mingw32/include/GL/glu.h:135
GLU_TESS_MAX_COORD : constant := 1.0e150; -- c:\home\ochem\install\bin\../lib/gcc/i686-pc-mingw32/4.7.3/../../../../i686-pc-mingw32/include/GL/glu.h:137
GLU_TESS_WINDING_RULE : constant := 100140; -- c:\home\ochem\install\bin\../lib/gcc/i686-pc-mingw32/4.7.3/../../../../i686-pc-mingw32/include/GL/glu.h:139
GLU_TESS_BOUNDARY_ONLY : constant := 100141; -- c:\home\ochem\install\bin\../lib/gcc/i686-pc-mingw32/4.7.3/../../../../i686-pc-mingw32/include/GL/glu.h:140
GLU_TESS_TOLERANCE : constant := 100142; -- c:\home\ochem\install\bin\../lib/gcc/i686-pc-mingw32/4.7.3/../../../../i686-pc-mingw32/include/GL/glu.h:141
GLU_TESS_WINDING_ODD : constant := 100130; -- c:\home\ochem\install\bin\../lib/gcc/i686-pc-mingw32/4.7.3/../../../../i686-pc-mingw32/include/GL/glu.h:143
GLU_TESS_WINDING_NONZERO : constant := 100131; -- c:\home\ochem\install\bin\../lib/gcc/i686-pc-mingw32/4.7.3/../../../../i686-pc-mingw32/include/GL/glu.h:144
GLU_TESS_WINDING_POSITIVE : constant := 100132; -- c:\home\ochem\install\bin\../lib/gcc/i686-pc-mingw32/4.7.3/../../../../i686-pc-mingw32/include/GL/glu.h:145
GLU_TESS_WINDING_NEGATIVE : constant := 100133; -- c:\home\ochem\install\bin\../lib/gcc/i686-pc-mingw32/4.7.3/../../../../i686-pc-mingw32/include/GL/glu.h:146
GLU_TESS_WINDING_ABS_GEQ_TWO : constant := 100134; -- c:\home\ochem\install\bin\../lib/gcc/i686-pc-mingw32/4.7.3/../../../../i686-pc-mingw32/include/GL/glu.h:147
GLU_TESS_BEGIN : constant := 100100; -- c:\home\ochem\install\bin\../lib/gcc/i686-pc-mingw32/4.7.3/../../../../i686-pc-mingw32/include/GL/glu.h:149
GLU_TESS_VERTEX : constant := 100101; -- c:\home\ochem\install\bin\../lib/gcc/i686-pc-mingw32/4.7.3/../../../../i686-pc-mingw32/include/GL/glu.h:150
GLU_TESS_END : constant := 100102; -- c:\home\ochem\install\bin\../lib/gcc/i686-pc-mingw32/4.7.3/../../../../i686-pc-mingw32/include/GL/glu.h:151
GLU_TESS_ERROR : constant := 100103; -- c:\home\ochem\install\bin\../lib/gcc/i686-pc-mingw32/4.7.3/../../../../i686-pc-mingw32/include/GL/glu.h:152
GLU_TESS_EDGE_FLAG : constant := 100104; -- c:\home\ochem\install\bin\../lib/gcc/i686-pc-mingw32/4.7.3/../../../../i686-pc-mingw32/include/GL/glu.h:153
GLU_TESS_COMBINE : constant := 100105; -- c:\home\ochem\install\bin\../lib/gcc/i686-pc-mingw32/4.7.3/../../../../i686-pc-mingw32/include/GL/glu.h:154
GLU_TESS_BEGIN_DATA : constant := 100106; -- c:\home\ochem\install\bin\../lib/gcc/i686-pc-mingw32/4.7.3/../../../../i686-pc-mingw32/include/GL/glu.h:155
GLU_TESS_VERTEX_DATA : constant := 100107; -- c:\home\ochem\install\bin\../lib/gcc/i686-pc-mingw32/4.7.3/../../../../i686-pc-mingw32/include/GL/glu.h:156
GLU_TESS_END_DATA : constant := 100108; -- c:\home\ochem\install\bin\../lib/gcc/i686-pc-mingw32/4.7.3/../../../../i686-pc-mingw32/include/GL/glu.h:157
GLU_TESS_ERROR_DATA : constant := 100109; -- c:\home\ochem\install\bin\../lib/gcc/i686-pc-mingw32/4.7.3/../../../../i686-pc-mingw32/include/GL/glu.h:158
GLU_TESS_EDGE_FLAG_DATA : constant := 100110; -- c:\home\ochem\install\bin\../lib/gcc/i686-pc-mingw32/4.7.3/../../../../i686-pc-mingw32/include/GL/glu.h:159
GLU_TESS_COMBINE_DATA : constant := 100111; -- c:\home\ochem\install\bin\../lib/gcc/i686-pc-mingw32/4.7.3/../../../../i686-pc-mingw32/include/GL/glu.h:160
GLU_TESS_ERROR1 : constant := 100151; -- c:\home\ochem\install\bin\../lib/gcc/i686-pc-mingw32/4.7.3/../../../../i686-pc-mingw32/include/GL/glu.h:162
GLU_TESS_ERROR2 : constant := 100152; -- c:\home\ochem\install\bin\../lib/gcc/i686-pc-mingw32/4.7.3/../../../../i686-pc-mingw32/include/GL/glu.h:163
GLU_TESS_ERROR3 : constant := 100153; -- c:\home\ochem\install\bin\../lib/gcc/i686-pc-mingw32/4.7.3/../../../../i686-pc-mingw32/include/GL/glu.h:164
GLU_TESS_ERROR4 : constant := 100154; -- c:\home\ochem\install\bin\../lib/gcc/i686-pc-mingw32/4.7.3/../../../../i686-pc-mingw32/include/GL/glu.h:165
GLU_TESS_ERROR5 : constant := 100155; -- c:\home\ochem\install\bin\../lib/gcc/i686-pc-mingw32/4.7.3/../../../../i686-pc-mingw32/include/GL/glu.h:166
GLU_TESS_ERROR6 : constant := 100156; -- c:\home\ochem\install\bin\../lib/gcc/i686-pc-mingw32/4.7.3/../../../../i686-pc-mingw32/include/GL/glu.h:167
GLU_TESS_ERROR7 : constant := 100157; -- c:\home\ochem\install\bin\../lib/gcc/i686-pc-mingw32/4.7.3/../../../../i686-pc-mingw32/include/GL/glu.h:168
GLU_TESS_ERROR8 : constant := 100158; -- c:\home\ochem\install\bin\../lib/gcc/i686-pc-mingw32/4.7.3/../../../../i686-pc-mingw32/include/GL/glu.h:169
-- unsupported macro: GLU_TESS_MISSING_BEGIN_POLYGON GLU_TESS_ERROR1
-- unsupported macro: GLU_TESS_MISSING_BEGIN_CONTOUR GLU_TESS_ERROR2
-- unsupported macro: GLU_TESS_MISSING_END_POLYGON GLU_TESS_ERROR3
-- unsupported macro: GLU_TESS_MISSING_END_CONTOUR GLU_TESS_ERROR4
-- unsupported macro: GLU_TESS_COORD_TOO_LARGE GLU_TESS_ERROR5
-- unsupported macro: GLU_TESS_NEED_COMBINE_CALLBACK GLU_TESS_ERROR6
GLU_AUTO_LOAD_MATRIX : constant := 100200; -- c:\home\ochem\install\bin\../lib/gcc/i686-pc-mingw32/4.7.3/../../../../i686-pc-mingw32/include/GL/glu.h:178
GLU_CULLING : constant := 100201; -- c:\home\ochem\install\bin\../lib/gcc/i686-pc-mingw32/4.7.3/../../../../i686-pc-mingw32/include/GL/glu.h:179
GLU_SAMPLING_TOLERANCE : constant := 100203; -- c:\home\ochem\install\bin\../lib/gcc/i686-pc-mingw32/4.7.3/../../../../i686-pc-mingw32/include/GL/glu.h:180
GLU_DISPLAY_MODE : constant := 100204; -- c:\home\ochem\install\bin\../lib/gcc/i686-pc-mingw32/4.7.3/../../../../i686-pc-mingw32/include/GL/glu.h:181
GLU_PARAMETRIC_TOLERANCE : constant := 100202; -- c:\home\ochem\install\bin\../lib/gcc/i686-pc-mingw32/4.7.3/../../../../i686-pc-mingw32/include/GL/glu.h:182
GLU_SAMPLING_METHOD : constant := 100205; -- c:\home\ochem\install\bin\../lib/gcc/i686-pc-mingw32/4.7.3/../../../../i686-pc-mingw32/include/GL/glu.h:183
GLU_U_STEP : constant := 100206; -- c:\home\ochem\install\bin\../lib/gcc/i686-pc-mingw32/4.7.3/../../../../i686-pc-mingw32/include/GL/glu.h:184
GLU_V_STEP : constant := 100207; -- c:\home\ochem\install\bin\../lib/gcc/i686-pc-mingw32/4.7.3/../../../../i686-pc-mingw32/include/GL/glu.h:185
GLU_PATH_LENGTH : constant := 100215; -- c:\home\ochem\install\bin\../lib/gcc/i686-pc-mingw32/4.7.3/../../../../i686-pc-mingw32/include/GL/glu.h:187
GLU_PARAMETRIC_ERROR : constant := 100216; -- c:\home\ochem\install\bin\../lib/gcc/i686-pc-mingw32/4.7.3/../../../../i686-pc-mingw32/include/GL/glu.h:188
GLU_DOMAIN_DISTANCE : constant := 100217; -- c:\home\ochem\install\bin\../lib/gcc/i686-pc-mingw32/4.7.3/../../../../i686-pc-mingw32/include/GL/glu.h:189
GLU_MAP1_TRIM_2 : constant := 100210; -- c:\home\ochem\install\bin\../lib/gcc/i686-pc-mingw32/4.7.3/../../../../i686-pc-mingw32/include/GL/glu.h:191
GLU_MAP1_TRIM_3 : constant := 100211; -- c:\home\ochem\install\bin\../lib/gcc/i686-pc-mingw32/4.7.3/../../../../i686-pc-mingw32/include/GL/glu.h:192
GLU_OUTLINE_POLYGON : constant := 100240; -- c:\home\ochem\install\bin\../lib/gcc/i686-pc-mingw32/4.7.3/../../../../i686-pc-mingw32/include/GL/glu.h:194
GLU_OUTLINE_PATCH : constant := 100241; -- c:\home\ochem\install\bin\../lib/gcc/i686-pc-mingw32/4.7.3/../../../../i686-pc-mingw32/include/GL/glu.h:195
GLU_NURBS_ERROR1 : constant := 100251; -- c:\home\ochem\install\bin\../lib/gcc/i686-pc-mingw32/4.7.3/../../../../i686-pc-mingw32/include/GL/glu.h:197
GLU_NURBS_ERROR2 : constant := 100252; -- c:\home\ochem\install\bin\../lib/gcc/i686-pc-mingw32/4.7.3/../../../../i686-pc-mingw32/include/GL/glu.h:198
GLU_NURBS_ERROR3 : constant := 100253; -- c:\home\ochem\install\bin\../lib/gcc/i686-pc-mingw32/4.7.3/../../../../i686-pc-mingw32/include/GL/glu.h:199
GLU_NURBS_ERROR4 : constant := 100254; -- c:\home\ochem\install\bin\../lib/gcc/i686-pc-mingw32/4.7.3/../../../../i686-pc-mingw32/include/GL/glu.h:200
GLU_NURBS_ERROR5 : constant := 100255; -- c:\home\ochem\install\bin\../lib/gcc/i686-pc-mingw32/4.7.3/../../../../i686-pc-mingw32/include/GL/glu.h:201
GLU_NURBS_ERROR6 : constant := 100256; -- c:\home\ochem\install\bin\../lib/gcc/i686-pc-mingw32/4.7.3/../../../../i686-pc-mingw32/include/GL/glu.h:202
GLU_NURBS_ERROR7 : constant := 100257; -- c:\home\ochem\install\bin\../lib/gcc/i686-pc-mingw32/4.7.3/../../../../i686-pc-mingw32/include/GL/glu.h:203
GLU_NURBS_ERROR8 : constant := 100258; -- c:\home\ochem\install\bin\../lib/gcc/i686-pc-mingw32/4.7.3/../../../../i686-pc-mingw32/include/GL/glu.h:204
GLU_NURBS_ERROR9 : constant := 100259; -- c:\home\ochem\install\bin\../lib/gcc/i686-pc-mingw32/4.7.3/../../../../i686-pc-mingw32/include/GL/glu.h:205
GLU_NURBS_ERROR10 : constant := 100260; -- c:\home\ochem\install\bin\../lib/gcc/i686-pc-mingw32/4.7.3/../../../../i686-pc-mingw32/include/GL/glu.h:206
GLU_NURBS_ERROR11 : constant := 100261; -- c:\home\ochem\install\bin\../lib/gcc/i686-pc-mingw32/4.7.3/../../../../i686-pc-mingw32/include/GL/glu.h:207
GLU_NURBS_ERROR12 : constant := 100262; -- c:\home\ochem\install\bin\../lib/gcc/i686-pc-mingw32/4.7.3/../../../../i686-pc-mingw32/include/GL/glu.h:208
GLU_NURBS_ERROR13 : constant := 100263; -- c:\home\ochem\install\bin\../lib/gcc/i686-pc-mingw32/4.7.3/../../../../i686-pc-mingw32/include/GL/glu.h:209
GLU_NURBS_ERROR14 : constant := 100264; -- c:\home\ochem\install\bin\../lib/gcc/i686-pc-mingw32/4.7.3/../../../../i686-pc-mingw32/include/GL/glu.h:210
GLU_NURBS_ERROR15 : constant := 100265; -- c:\home\ochem\install\bin\../lib/gcc/i686-pc-mingw32/4.7.3/../../../../i686-pc-mingw32/include/GL/glu.h:211
GLU_NURBS_ERROR16 : constant := 100266; -- c:\home\ochem\install\bin\../lib/gcc/i686-pc-mingw32/4.7.3/../../../../i686-pc-mingw32/include/GL/glu.h:212
GLU_NURBS_ERROR17 : constant := 100267; -- c:\home\ochem\install\bin\../lib/gcc/i686-pc-mingw32/4.7.3/../../../../i686-pc-mingw32/include/GL/glu.h:213
GLU_NURBS_ERROR18 : constant := 100268; -- c:\home\ochem\install\bin\../lib/gcc/i686-pc-mingw32/4.7.3/../../../../i686-pc-mingw32/include/GL/glu.h:214
GLU_NURBS_ERROR19 : constant := 100269; -- c:\home\ochem\install\bin\../lib/gcc/i686-pc-mingw32/4.7.3/../../../../i686-pc-mingw32/include/GL/glu.h:215
GLU_NURBS_ERROR20 : constant := 100270; -- c:\home\ochem\install\bin\../lib/gcc/i686-pc-mingw32/4.7.3/../../../../i686-pc-mingw32/include/GL/glu.h:216
GLU_NURBS_ERROR21 : constant := 100271; -- c:\home\ochem\install\bin\../lib/gcc/i686-pc-mingw32/4.7.3/../../../../i686-pc-mingw32/include/GL/glu.h:217
GLU_NURBS_ERROR22 : constant := 100272; -- c:\home\ochem\install\bin\../lib/gcc/i686-pc-mingw32/4.7.3/../../../../i686-pc-mingw32/include/GL/glu.h:218
GLU_NURBS_ERROR23 : constant := 100273; -- c:\home\ochem\install\bin\../lib/gcc/i686-pc-mingw32/4.7.3/../../../../i686-pc-mingw32/include/GL/glu.h:219
GLU_NURBS_ERROR24 : constant := 100274; -- c:\home\ochem\install\bin\../lib/gcc/i686-pc-mingw32/4.7.3/../../../../i686-pc-mingw32/include/GL/glu.h:220
GLU_NURBS_ERROR25 : constant := 100275; -- c:\home\ochem\install\bin\../lib/gcc/i686-pc-mingw32/4.7.3/../../../../i686-pc-mingw32/include/GL/glu.h:221
GLU_NURBS_ERROR26 : constant := 100276; -- c:\home\ochem\install\bin\../lib/gcc/i686-pc-mingw32/4.7.3/../../../../i686-pc-mingw32/include/GL/glu.h:222
GLU_NURBS_ERROR27 : constant := 100277; -- c:\home\ochem\install\bin\../lib/gcc/i686-pc-mingw32/4.7.3/../../../../i686-pc-mingw32/include/GL/glu.h:223
GLU_NURBS_ERROR28 : constant := 100278; -- c:\home\ochem\install\bin\../lib/gcc/i686-pc-mingw32/4.7.3/../../../../i686-pc-mingw32/include/GL/glu.h:224
GLU_NURBS_ERROR29 : constant := 100279; -- c:\home\ochem\install\bin\../lib/gcc/i686-pc-mingw32/4.7.3/../../../../i686-pc-mingw32/include/GL/glu.h:225
GLU_NURBS_ERROR30 : constant := 100280; -- c:\home\ochem\install\bin\../lib/gcc/i686-pc-mingw32/4.7.3/../../../../i686-pc-mingw32/include/GL/glu.h:226
GLU_NURBS_ERROR31 : constant := 100281; -- c:\home\ochem\install\bin\../lib/gcc/i686-pc-mingw32/4.7.3/../../../../i686-pc-mingw32/include/GL/glu.h:227
GLU_NURBS_ERROR32 : constant := 100282; -- c:\home\ochem\install\bin\../lib/gcc/i686-pc-mingw32/4.7.3/../../../../i686-pc-mingw32/include/GL/glu.h:228
GLU_NURBS_ERROR33 : constant := 100283; -- c:\home\ochem\install\bin\../lib/gcc/i686-pc-mingw32/4.7.3/../../../../i686-pc-mingw32/include/GL/glu.h:229
GLU_NURBS_ERROR34 : constant := 100284; -- c:\home\ochem\install\bin\../lib/gcc/i686-pc-mingw32/4.7.3/../../../../i686-pc-mingw32/include/GL/glu.h:230
GLU_NURBS_ERROR35 : constant := 100285; -- c:\home\ochem\install\bin\../lib/gcc/i686-pc-mingw32/4.7.3/../../../../i686-pc-mingw32/include/GL/glu.h:231
GLU_NURBS_ERROR36 : constant := 100286; -- c:\home\ochem\install\bin\../lib/gcc/i686-pc-mingw32/4.7.3/../../../../i686-pc-mingw32/include/GL/glu.h:232
GLU_NURBS_ERROR37 : constant := 100287; -- c:\home\ochem\install\bin\../lib/gcc/i686-pc-mingw32/4.7.3/../../../../i686-pc-mingw32/include/GL/glu.h:233
GLU_CW : constant := 100120; -- c:\home\ochem\install\bin\../lib/gcc/i686-pc-mingw32/4.7.3/../../../../i686-pc-mingw32/include/GL/glu.h:239
GLU_CCW : constant := 100121; -- c:\home\ochem\install\bin\../lib/gcc/i686-pc-mingw32/4.7.3/../../../../i686-pc-mingw32/include/GL/glu.h:240
GLU_INTERIOR : constant := 100122; -- c:\home\ochem\install\bin\../lib/gcc/i686-pc-mingw32/4.7.3/../../../../i686-pc-mingw32/include/GL/glu.h:241
GLU_EXTERIOR : constant := 100123; -- c:\home\ochem\install\bin\../lib/gcc/i686-pc-mingw32/4.7.3/../../../../i686-pc-mingw32/include/GL/glu.h:242
GLU_UNKNOWN : constant := 100124; -- c:\home\ochem\install\bin\../lib/gcc/i686-pc-mingw32/4.7.3/../../../../i686-pc-mingw32/include/GL/glu.h:243
-- unsupported macro: GLU_BEGIN GLU_TESS_BEGIN
-- unsupported macro: GLU_VERTEX GLU_TESS_VERTEX
-- unsupported macro: GLU_END GLU_TESS_END
-- unsupported macro: GLU_ERROR GLU_TESS_ERROR
-- unsupported macro: GLU_EDGE_FLAG GLU_TESS_EDGE_FLAG
function gluErrorString (errCode : GL_gl_h.GLenum) return access GL_gl_h.GLubyte; -- c:\home\ochem\install\bin\../lib/gcc/i686-pc-mingw32/4.7.3/../../../../i686-pc-mingw32/include/GL/glu.h:24
pragma Import (Stdcall, gluErrorString, "gluErrorString");
function gluErrorUnicodeStringEXT (errCode : GL_gl_h.GLenum) return access wchar_t; -- c:\home\ochem\install\bin\../lib/gcc/i686-pc-mingw32/4.7.3/../../../../i686-pc-mingw32/include/GL/glu.h:25
pragma Import (Stdcall, gluErrorUnicodeStringEXT, "gluErrorUnicodeStringEXT");
function gluGetString (name : GL_gl_h.GLenum) return access GL_gl_h.GLubyte; -- c:\home\ochem\install\bin\../lib/gcc/i686-pc-mingw32/4.7.3/../../../../i686-pc-mingw32/include/GL/glu.h:26
pragma Import (Stdcall, gluGetString, "gluGetString");
procedure gluOrtho2D
(left : GL_gl_h.GLdouble;
right : GL_gl_h.GLdouble;
bottom : GL_gl_h.GLdouble;
top : GL_gl_h.GLdouble); -- c:\home\ochem\install\bin\../lib/gcc/i686-pc-mingw32/4.7.3/../../../../i686-pc-mingw32/include/GL/glu.h:27
pragma Import (Stdcall, gluOrtho2D, "gluOrtho2D");
procedure gluPerspective
(fovy : GL_gl_h.GLdouble;
aspect : GL_gl_h.GLdouble;
zNear : GL_gl_h.GLdouble;
zFar : GL_gl_h.GLdouble); -- c:\home\ochem\install\bin\../lib/gcc/i686-pc-mingw32/4.7.3/../../../../i686-pc-mingw32/include/GL/glu.h:28
pragma Import (Stdcall, gluPerspective, "gluPerspective");
procedure gluPickMatrix
(x : GL_gl_h.GLdouble;
y : GL_gl_h.GLdouble;
width : GL_gl_h.GLdouble;
height : GL_gl_h.GLdouble;
viewport : access GL_gl_h.GLint); -- c:\home\ochem\install\bin\../lib/gcc/i686-pc-mingw32/4.7.3/../../../../i686-pc-mingw32/include/GL/glu.h:29
pragma Import (Stdcall, gluPickMatrix, "gluPickMatrix");
procedure gluLookAt
(eyex : GL_gl_h.GLdouble;
eyey : GL_gl_h.GLdouble;
eyez : GL_gl_h.GLdouble;
centerx : GL_gl_h.GLdouble;
centery : GL_gl_h.GLdouble;
centerz : GL_gl_h.GLdouble;
upx : GL_gl_h.GLdouble;
upy : GL_gl_h.GLdouble;
upz : GL_gl_h.GLdouble); -- c:\home\ochem\install\bin\../lib/gcc/i686-pc-mingw32/4.7.3/../../../../i686-pc-mingw32/include/GL/glu.h:30
pragma Import (Stdcall, gluLookAt, "gluLookAt");
function gluProject
(objx : GL_gl_h.GLdouble;
objy : GL_gl_h.GLdouble;
objz : GL_gl_h.GLdouble;
modelMatrix : access GL_gl_h.GLdouble;
projMatrix : access GL_gl_h.GLdouble;
viewport : access GL_gl_h.GLint;
winx : access GL_gl_h.GLdouble;
winy : access GL_gl_h.GLdouble;
winz : access GL_gl_h.GLdouble) return int; -- c:\home\ochem\install\bin\../lib/gcc/i686-pc-mingw32/4.7.3/../../../../i686-pc-mingw32/include/GL/glu.h:31
pragma Import (Stdcall, gluProject, "gluProject");
function gluUnProject
(winx : GL_gl_h.GLdouble;
winy : GL_gl_h.GLdouble;
winz : GL_gl_h.GLdouble;
modelMatrix : access GL_gl_h.GLdouble;
projMatrix : access GL_gl_h.GLdouble;
viewport : access GL_gl_h.GLint;
objx : access GL_gl_h.GLdouble;
objy : access GL_gl_h.GLdouble;
objz : access GL_gl_h.GLdouble) return int; -- c:\home\ochem\install\bin\../lib/gcc/i686-pc-mingw32/4.7.3/../../../../i686-pc-mingw32/include/GL/glu.h:32
pragma Import (Stdcall, gluUnProject, "gluUnProject");
function gluScaleImage
(format : GL_gl_h.GLenum;
widthin : GL_gl_h.GLint;
heightin : GL_gl_h.GLint;
typein : GL_gl_h.GLenum;
datain : System.Address;
widthout : GL_gl_h.GLint;
heightout : GL_gl_h.GLint;
typeout : GL_gl_h.GLenum;
dataout : System.Address) return int; -- c:\home\ochem\install\bin\../lib/gcc/i686-pc-mingw32/4.7.3/../../../../i686-pc-mingw32/include/GL/glu.h:33
pragma Import (Stdcall, gluScaleImage, "gluScaleImage");
function gluBuild1DMipmaps
(target : GL_gl_h.GLenum;
components : GL_gl_h.GLint;
width : GL_gl_h.GLint;
format : GL_gl_h.GLenum;
c_type : GL_gl_h.GLenum;
data : System.Address) return int; -- c:\home\ochem\install\bin\../lib/gcc/i686-pc-mingw32/4.7.3/../../../../i686-pc-mingw32/include/GL/glu.h:34
pragma Import (Stdcall, gluBuild1DMipmaps, "gluBuild1DMipmaps");
function gluBuild2DMipmaps
(target : GL_gl_h.GLenum;
components : GL_gl_h.GLint;
width : GL_gl_h.GLint;
height : GL_gl_h.GLint;
format : GL_gl_h.GLenum;
c_type : GL_gl_h.GLenum;
data : System.Address) return int; -- c:\home\ochem\install\bin\../lib/gcc/i686-pc-mingw32/4.7.3/../../../../i686-pc-mingw32/include/GL/glu.h:35
pragma Import (Stdcall, gluBuild2DMipmaps, "gluBuild2DMipmaps");
-- skipped empty struct GLUnurbs
-- skipped empty struct GLUquadric
-- skipped empty struct GLUtesselator
-- skipped empty struct GLUnurbsObj
-- skipped empty struct GLUquadricObj
-- skipped empty struct GLUtesselatorObj
-- skipped empty struct GLUtriangulatorObj
function gluNewQuadric return System.Address; -- c:\home\ochem\install\bin\../lib/gcc/i686-pc-mingw32/4.7.3/../../../../i686-pc-mingw32/include/GL/glu.h:58
pragma Import (Stdcall, gluNewQuadric, "gluNewQuadric");
procedure gluDeleteQuadric (state : System.Address); -- c:\home\ochem\install\bin\../lib/gcc/i686-pc-mingw32/4.7.3/../../../../i686-pc-mingw32/include/GL/glu.h:59
pragma Import (Stdcall, gluDeleteQuadric, "gluDeleteQuadric");
procedure gluQuadricNormals (quadObject : System.Address; normals : GL_gl_h.GLenum); -- c:\home\ochem\install\bin\../lib/gcc/i686-pc-mingw32/4.7.3/../../../../i686-pc-mingw32/include/GL/glu.h:60
pragma Import (Stdcall, gluQuadricNormals, "gluQuadricNormals");
procedure gluQuadricTexture (quadObject : System.Address; textureCoords : GL_gl_h.GLboolean); -- c:\home\ochem\install\bin\../lib/gcc/i686-pc-mingw32/4.7.3/../../../../i686-pc-mingw32/include/GL/glu.h:61
pragma Import (Stdcall, gluQuadricTexture, "gluQuadricTexture");
procedure gluQuadricOrientation (quadObject : System.Address; orientation : GL_gl_h.GLenum); -- c:\home\ochem\install\bin\../lib/gcc/i686-pc-mingw32/4.7.3/../../../../i686-pc-mingw32/include/GL/glu.h:62
pragma Import (Stdcall, gluQuadricOrientation, "gluQuadricOrientation");
procedure gluQuadricDrawStyle (quadObject : System.Address; drawStyle : GL_gl_h.GLenum); -- c:\home\ochem\install\bin\../lib/gcc/i686-pc-mingw32/4.7.3/../../../../i686-pc-mingw32/include/GL/glu.h:63
pragma Import (Stdcall, gluQuadricDrawStyle, "gluQuadricDrawStyle");
procedure gluCylinder
(qobj : System.Address;
baseRadius : GL_gl_h.GLdouble;
topRadius : GL_gl_h.GLdouble;
height : GL_gl_h.GLdouble;
slices : GL_gl_h.GLint;
stacks : GL_gl_h.GLint); -- c:\home\ochem\install\bin\../lib/gcc/i686-pc-mingw32/4.7.3/../../../../i686-pc-mingw32/include/GL/glu.h:64
pragma Import (Stdcall, gluCylinder, "gluCylinder");
procedure gluDisk
(qobj : System.Address;
innerRadius : GL_gl_h.GLdouble;
outerRadius : GL_gl_h.GLdouble;
slices : GL_gl_h.GLint;
loops : GL_gl_h.GLint); -- c:\home\ochem\install\bin\../lib/gcc/i686-pc-mingw32/4.7.3/../../../../i686-pc-mingw32/include/GL/glu.h:65
pragma Import (Stdcall, gluDisk, "gluDisk");
procedure gluPartialDisk
(qobj : System.Address;
innerRadius : GL_gl_h.GLdouble;
outerRadius : GL_gl_h.GLdouble;
slices : GL_gl_h.GLint;
loops : GL_gl_h.GLint;
startAngle : GL_gl_h.GLdouble;
sweepAngle : GL_gl_h.GLdouble); -- c:\home\ochem\install\bin\../lib/gcc/i686-pc-mingw32/4.7.3/../../../../i686-pc-mingw32/include/GL/glu.h:66
pragma Import (Stdcall, gluPartialDisk, "gluPartialDisk");
procedure gluSphere
(qobj : System.Address;
radius : GL_gl_h.GLdouble;
slices : GL_gl_h.GLint;
stacks : GL_gl_h.GLint); -- c:\home\ochem\install\bin\../lib/gcc/i686-pc-mingw32/4.7.3/../../../../i686-pc-mingw32/include/GL/glu.h:67
pragma Import (Stdcall, gluSphere, "gluSphere");
procedure gluQuadricCallback
(qobj : System.Address;
which : GL_gl_h.GLenum;
fn : access procedure); -- c:\home\ochem\install\bin\../lib/gcc/i686-pc-mingw32/4.7.3/../../../../i686-pc-mingw32/include/GL/glu.h:68
pragma Import (Stdcall, gluQuadricCallback, "gluQuadricCallback");
function gluNewTess return System.Address; -- c:\home\ochem\install\bin\../lib/gcc/i686-pc-mingw32/4.7.3/../../../../i686-pc-mingw32/include/GL/glu.h:69
pragma Import (Stdcall, gluNewTess, "gluNewTess");
procedure gluDeleteTess (tess : System.Address); -- c:\home\ochem\install\bin\../lib/gcc/i686-pc-mingw32/4.7.3/../../../../i686-pc-mingw32/include/GL/glu.h:70
pragma Import (Stdcall, gluDeleteTess, "gluDeleteTess");
procedure gluTessBeginPolygon (tess : System.Address; polygon_data : System.Address); -- c:\home\ochem\install\bin\../lib/gcc/i686-pc-mingw32/4.7.3/../../../../i686-pc-mingw32/include/GL/glu.h:71
pragma Import (Stdcall, gluTessBeginPolygon, "gluTessBeginPolygon");
procedure gluTessBeginContour (tess : System.Address); -- c:\home\ochem\install\bin\../lib/gcc/i686-pc-mingw32/4.7.3/../../../../i686-pc-mingw32/include/GL/glu.h:72
pragma Import (Stdcall, gluTessBeginContour, "gluTessBeginContour");
procedure gluTessVertex
(tess : System.Address;
coords : access GL_gl_h.GLdouble;
data : System.Address); -- c:\home\ochem\install\bin\../lib/gcc/i686-pc-mingw32/4.7.3/../../../../i686-pc-mingw32/include/GL/glu.h:73
pragma Import (Stdcall, gluTessVertex, "gluTessVertex");
procedure gluTessEndContour (tess : System.Address); -- c:\home\ochem\install\bin\../lib/gcc/i686-pc-mingw32/4.7.3/../../../../i686-pc-mingw32/include/GL/glu.h:74
pragma Import (Stdcall, gluTessEndContour, "gluTessEndContour");
procedure gluTessEndPolygon (tess : System.Address); -- c:\home\ochem\install\bin\../lib/gcc/i686-pc-mingw32/4.7.3/../../../../i686-pc-mingw32/include/GL/glu.h:75
pragma Import (Stdcall, gluTessEndPolygon, "gluTessEndPolygon");
procedure gluTessProperty
(tess : System.Address;
which : GL_gl_h.GLenum;
value : GL_gl_h.GLdouble); -- c:\home\ochem\install\bin\../lib/gcc/i686-pc-mingw32/4.7.3/../../../../i686-pc-mingw32/include/GL/glu.h:76
pragma Import (Stdcall, gluTessProperty, "gluTessProperty");
procedure gluTessNormal
(tess : System.Address;
x : GL_gl_h.GLdouble;
y : GL_gl_h.GLdouble;
z : GL_gl_h.GLdouble); -- c:\home\ochem\install\bin\../lib/gcc/i686-pc-mingw32/4.7.3/../../../../i686-pc-mingw32/include/GL/glu.h:77
pragma Import (Stdcall, gluTessNormal, "gluTessNormal");
procedure gluTessCallback
(tess : System.Address;
which : GL_gl_h.GLenum;
fn : access procedure); -- c:\home\ochem\install\bin\../lib/gcc/i686-pc-mingw32/4.7.3/../../../../i686-pc-mingw32/include/GL/glu.h:78
pragma Import (Stdcall, gluTessCallback, "gluTessCallback");
procedure gluGetTessProperty
(tess : System.Address;
which : GL_gl_h.GLenum;
value : access GL_gl_h.GLdouble); -- c:\home\ochem\install\bin\../lib/gcc/i686-pc-mingw32/4.7.3/../../../../i686-pc-mingw32/include/GL/glu.h:79
pragma Import (Stdcall, gluGetTessProperty, "gluGetTessProperty");
function gluNewNurbsRenderer return System.Address; -- c:\home\ochem\install\bin\../lib/gcc/i686-pc-mingw32/4.7.3/../../../../i686-pc-mingw32/include/GL/glu.h:80
pragma Import (Stdcall, gluNewNurbsRenderer, "gluNewNurbsRenderer");
procedure gluDeleteNurbsRenderer (nobj : System.Address); -- c:\home\ochem\install\bin\../lib/gcc/i686-pc-mingw32/4.7.3/../../../../i686-pc-mingw32/include/GL/glu.h:81
pragma Import (Stdcall, gluDeleteNurbsRenderer, "gluDeleteNurbsRenderer");
procedure gluBeginSurface (nobj : System.Address); -- c:\home\ochem\install\bin\../lib/gcc/i686-pc-mingw32/4.7.3/../../../../i686-pc-mingw32/include/GL/glu.h:82
pragma Import (Stdcall, gluBeginSurface, "gluBeginSurface");
procedure gluBeginCurve (nobj : System.Address); -- c:\home\ochem\install\bin\../lib/gcc/i686-pc-mingw32/4.7.3/../../../../i686-pc-mingw32/include/GL/glu.h:83
pragma Import (Stdcall, gluBeginCurve, "gluBeginCurve");
procedure gluEndCurve (nobj : System.Address); -- c:\home\ochem\install\bin\../lib/gcc/i686-pc-mingw32/4.7.3/../../../../i686-pc-mingw32/include/GL/glu.h:84
pragma Import (Stdcall, gluEndCurve, "gluEndCurve");
procedure gluEndSurface (nobj : System.Address); -- c:\home\ochem\install\bin\../lib/gcc/i686-pc-mingw32/4.7.3/../../../../i686-pc-mingw32/include/GL/glu.h:85
pragma Import (Stdcall, gluEndSurface, "gluEndSurface");
procedure gluBeginTrim (nobj : System.Address); -- c:\home\ochem\install\bin\../lib/gcc/i686-pc-mingw32/4.7.3/../../../../i686-pc-mingw32/include/GL/glu.h:86
pragma Import (Stdcall, gluBeginTrim, "gluBeginTrim");
procedure gluEndTrim (nobj : System.Address); -- c:\home\ochem\install\bin\../lib/gcc/i686-pc-mingw32/4.7.3/../../../../i686-pc-mingw32/include/GL/glu.h:87
pragma Import (Stdcall, gluEndTrim, "gluEndTrim");
procedure gluPwlCurve
(nobj : System.Address;
count : GL_gl_h.GLint;
c_array : access GL_gl_h.GLfloat;
stride : GL_gl_h.GLint;
c_type : GL_gl_h.GLenum); -- c:\home\ochem\install\bin\../lib/gcc/i686-pc-mingw32/4.7.3/../../../../i686-pc-mingw32/include/GL/glu.h:88
pragma Import (Stdcall, gluPwlCurve, "gluPwlCurve");
procedure gluNurbsCurve
(nobj : System.Address;
nknots : GL_gl_h.GLint;
knot : access GL_gl_h.GLfloat;
stride : GL_gl_h.GLint;
ctlarray : access GL_gl_h.GLfloat;
order : GL_gl_h.GLint;
c_type : GL_gl_h.GLenum); -- c:\home\ochem\install\bin\../lib/gcc/i686-pc-mingw32/4.7.3/../../../../i686-pc-mingw32/include/GL/glu.h:89
pragma Import (Stdcall, gluNurbsCurve, "gluNurbsCurve");
procedure gluNurbsSurface
(nobj : System.Address;
sknot_count : GL_gl_h.GLint;
sknot : access float;
tknot_count : GL_gl_h.GLint;
tknot : access GL_gl_h.GLfloat;
s_stride : GL_gl_h.GLint;
t_stride : GL_gl_h.GLint;
ctlarray : access GL_gl_h.GLfloat;
sorder : GL_gl_h.GLint;
torder : GL_gl_h.GLint;
c_type : GL_gl_h.GLenum); -- c:\home\ochem\install\bin\../lib/gcc/i686-pc-mingw32/4.7.3/../../../../i686-pc-mingw32/include/GL/glu.h:90
pragma Import (Stdcall, gluNurbsSurface, "gluNurbsSurface");
procedure gluLoadSamplingMatrices
(nobj : System.Address;
modelMatrix : access GL_gl_h.GLfloat;
projMatrix : access GL_gl_h.GLfloat;
viewport : access GL_gl_h.GLint); -- c:\home\ochem\install\bin\../lib/gcc/i686-pc-mingw32/4.7.3/../../../../i686-pc-mingw32/include/GL/glu.h:91
pragma Import (Stdcall, gluLoadSamplingMatrices, "gluLoadSamplingMatrices");
procedure gluNurbsProperty
(nobj : System.Address;
property : GL_gl_h.GLenum;
value : GL_gl_h.GLfloat); -- c:\home\ochem\install\bin\../lib/gcc/i686-pc-mingw32/4.7.3/../../../../i686-pc-mingw32/include/GL/glu.h:92
pragma Import (Stdcall, gluNurbsProperty, "gluNurbsProperty");
procedure gluGetNurbsProperty
(nobj : System.Address;
property : GL_gl_h.GLenum;
value : access GL_gl_h.GLfloat); -- c:\home\ochem\install\bin\../lib/gcc/i686-pc-mingw32/4.7.3/../../../../i686-pc-mingw32/include/GL/glu.h:93
pragma Import (Stdcall, gluGetNurbsProperty, "gluGetNurbsProperty");
procedure gluNurbsCallback
(nobj : System.Address;
which : GL_gl_h.GLenum;
fn : access procedure); -- c:\home\ochem\install\bin\../lib/gcc/i686-pc-mingw32/4.7.3/../../../../i686-pc-mingw32/include/GL/glu.h:94
pragma Import (Stdcall, gluNurbsCallback, "gluNurbsCallback");
type GLUquadricErrorProc is access procedure (arg1 : GL_gl_h.GLenum);
pragma Convention (C, GLUquadricErrorProc); -- c:\home\ochem\install\bin\../lib/gcc/i686-pc-mingw32/4.7.3/../../../../i686-pc-mingw32/include/GL/glu.h:96
type GLUtessBeginProc is access procedure (arg1 : GL_gl_h.GLenum);
pragma Convention (C, GLUtessBeginProc); -- c:\home\ochem\install\bin\../lib/gcc/i686-pc-mingw32/4.7.3/../../../../i686-pc-mingw32/include/GL/glu.h:97
type GLUtessEdgeFlagProc is access procedure (arg1 : GL_gl_h.GLboolean);
pragma Convention (C, GLUtessEdgeFlagProc); -- c:\home\ochem\install\bin\../lib/gcc/i686-pc-mingw32/4.7.3/../../../../i686-pc-mingw32/include/GL/glu.h:98
type GLUtessVertexProc is access procedure (arg1 : System.Address);
pragma Convention (C, GLUtessVertexProc); -- c:\home\ochem\install\bin\../lib/gcc/i686-pc-mingw32/4.7.3/../../../../i686-pc-mingw32/include/GL/glu.h:99
type GLUtessEndProc is access procedure;
pragma Convention (C, GLUtessEndProc); -- c:\home\ochem\install\bin\../lib/gcc/i686-pc-mingw32/4.7.3/../../../../i686-pc-mingw32/include/GL/glu.h:100
type GLUtessErrorProc is access procedure (arg1 : GL_gl_h.GLenum);
pragma Convention (C, GLUtessErrorProc); -- c:\home\ochem\install\bin\../lib/gcc/i686-pc-mingw32/4.7.3/../../../../i686-pc-mingw32/include/GL/glu.h:101
type GLUtessCombineProc is access procedure
(arg1 : access GL_gl_h.GLdouble;
arg2 : System.Address;
arg3 : access GL_gl_h.GLfloat;
arg4 : System.Address);
pragma Convention (C, GLUtessCombineProc); -- c:\home\ochem\install\bin\../lib/gcc/i686-pc-mingw32/4.7.3/../../../../i686-pc-mingw32/include/GL/glu.h:102
type GLUtessBeginDataProc is access procedure (arg1 : GL_gl_h.GLenum; arg2 : System.Address);
pragma Convention (C, GLUtessBeginDataProc); -- c:\home\ochem\install\bin\../lib/gcc/i686-pc-mingw32/4.7.3/../../../../i686-pc-mingw32/include/GL/glu.h:103
type GLUtessEdgeFlagDataProc is access procedure (arg1 : GL_gl_h.GLboolean; arg2 : System.Address);
pragma Convention (C, GLUtessEdgeFlagDataProc); -- c:\home\ochem\install\bin\../lib/gcc/i686-pc-mingw32/4.7.3/../../../../i686-pc-mingw32/include/GL/glu.h:104
type GLUtessVertexDataProc is access procedure (arg1 : System.Address; arg2 : System.Address);
pragma Convention (C, GLUtessVertexDataProc); -- c:\home\ochem\install\bin\../lib/gcc/i686-pc-mingw32/4.7.3/../../../../i686-pc-mingw32/include/GL/glu.h:105
type GLUtessEndDataProc is access procedure (arg1 : System.Address);
pragma Convention (C, GLUtessEndDataProc); -- c:\home\ochem\install\bin\../lib/gcc/i686-pc-mingw32/4.7.3/../../../../i686-pc-mingw32/include/GL/glu.h:106
type GLUtessErrorDataProc is access procedure (arg1 : GL_gl_h.GLenum; arg2 : System.Address);
pragma Convention (C, GLUtessErrorDataProc); -- c:\home\ochem\install\bin\../lib/gcc/i686-pc-mingw32/4.7.3/../../../../i686-pc-mingw32/include/GL/glu.h:107
type GLUtessCombineDataProc is access procedure
(arg1 : access GL_gl_h.GLdouble;
arg2 : System.Address;
arg3 : access GL_gl_h.GLfloat;
arg4 : System.Address;
arg5 : System.Address);
pragma Convention (C, GLUtessCombineDataProc); -- c:\home\ochem\install\bin\../lib/gcc/i686-pc-mingw32/4.7.3/../../../../i686-pc-mingw32/include/GL/glu.h:108
type GLUnurbsErrorProc is access procedure (arg1 : GL_gl_h.GLenum);
pragma Convention (C, GLUnurbsErrorProc); -- c:\home\ochem\install\bin\../lib/gcc/i686-pc-mingw32/4.7.3/../../../../i686-pc-mingw32/include/GL/glu.h:109
procedure gluBeginPolygon (tess : System.Address); -- c:\home\ochem\install\bin\../lib/gcc/i686-pc-mingw32/4.7.3/../../../../i686-pc-mingw32/include/GL/glu.h:235
pragma Import (Stdcall, gluBeginPolygon, "gluBeginPolygon");
procedure gluNextContour (tess : System.Address; c_type : GL_gl_h.GLenum); -- c:\home\ochem\install\bin\../lib/gcc/i686-pc-mingw32/4.7.3/../../../../i686-pc-mingw32/include/GL/glu.h:236
pragma Import (Stdcall, gluNextContour, "gluNextContour");
procedure gluEndPolygon (tess : System.Address); -- c:\home\ochem\install\bin\../lib/gcc/i686-pc-mingw32/4.7.3/../../../../i686-pc-mingw32/include/GL/glu.h:237
pragma Import (Stdcall, gluEndPolygon, "gluEndPolygon");
end GL_glu_h;
|
stcarrez/dynamo | Ada | 2,780 | ads | -----------------------------------------------------------------------
-- gen-artifacts-distribs-exec -- External command based distribution artifact
-- Copyright (C) 2012 Stephane Carrez
-- Written by Stephane Carrez ([email protected])
--
-- Licensed under the Apache License, Version 2.0 (the "License");
-- you may not use this file except in compliance with the License.
-- You may obtain a copy of the License at
--
-- http://www.apache.org/licenses/LICENSE-2.0
--
-- Unless required by applicable law or agreed to in writing, software
-- distributed under the License is distributed on an "AS IS" BASIS,
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-- See the License for the specific language governing permissions and
-- limitations under the License.
-----------------------------------------------------------------------
with EL.Expressions;
-- The <b>Gen.Artifacts.Distribs.Exec</b> package provides distribution rules
-- to copy a file or a directory by using an external program. The rule is
-- created by using the following XML definition:
--
-- <install mode='exec' dir='target'>
-- <command>cmd #{src} #{dst}</command>
-- <fileset dir="source">
-- <include name="**/*"/>
-- </fileset>
-- </install>
--
-- The command is a string which can contain EL expressions that are
-- evaluated before executing the command. The command is executed for
-- each source file. The following EL variables are defined:
--
-- src defines the absolute source path
-- dst defines the target destination path
--
private package Gen.Artifacts.Distribs.Exec is
-- Create a distribution rule to copy a set of files or directories and
-- execute an external command.
function Create_Rule (Node : in DOM.Core.Node;
Copy : in Boolean) return Distrib_Rule_Access;
-- ------------------------------
-- Distribution artifact
-- ------------------------------
type Exec_Rule is new Distrib_Rule with private;
type Exec_Rule_Access is access all Exec_Rule'Class;
-- Get a name to qualify the installation rule (used for logs).
overriding
function Get_Install_Name (Rule : in Exec_Rule) return String;
overriding
procedure Install (Rule : in Exec_Rule;
Path : in String;
Files : in File_Vector;
Context : in out Generator'Class);
private
type Exec_Rule is new Distrib_Rule with record
Command : EL.Expressions.Expression;
Output : EL.Expressions.Expression;
Output_Append : Boolean;
Copy_First : Boolean := False;
Slow_Flag : Boolean := False;
end record;
end Gen.Artifacts.Distribs.Exec;
|
osannolik/ada-canopen | Ada | 744 | adb | package body ACO.Events is
procedure Process
(This : in out Node_Event_Manager)
is
begin
This.Node_Events.Process;
end Process;
overriding
procedure Update
(This : access Handler_Event_Listener;
Data : in Handler_Event_Data)
is
type Ref is access all Handler_Event_Listener'Class;
begin
if This.Event = Data.Event then
Ref (This).On_Event (Data);
end if;
end Update;
overriding
procedure Update
(This : access Event_Listener;
Data : in Event_Data)
is
type Ref is access all Event_Listener'Class;
begin
if This.Event = Data.Event then
Ref (This).On_Event (Data);
end if;
end Update;
end ACO.Events;
|
rveenker/sdlada | Ada | 561 | ads | -- -*- Mode: Ada -*-
-- Filename : maths.ads
-- Description : Sample shared library using an Ada and a C function as an example.
-- Author : Luke A. Guest
-- Created On : Sun Oct 27 17:50:33 2013
package Maths is
function Add (A, B : in Integer) return Integer with
Export => True,
Convention => Ada,
External_Name => "Add";
function Sub (A, B : in Integer) return Integer with
Import => True,
Convention => C,
External_Name => "sub";
end Maths;
|
charlie5/lace | Ada | 2,121 | adb | with
ada.unchecked_Deallocation;
package body physics.Model
is
----------
--- Forge
--
package body Forge
is
function new_physics_Model (Id : in model_Id := null_model_Id;
shape_Info : in a_Shape;
Scale : in Vector_3 := [1.0, 1.0, 1.0];
Mass : in Real := 0.0;
Friction : in Real := 0.1;
Restitution : in Real := 0.1;
-- Site : in Vector_3 := Origin_3D;
is_Tangible : in Boolean := True) return View
is
begin
return new Item' (Id => Id,
Scale => Scale,
shape_Info => shape_Info,
Shape => null,
Mass => Mass,
Friction => Friction,
Restitution => Restitution,
-- Site => Site,
is_Tangible => is_Tangible);
end new_physics_Model;
end Forge;
procedure define (Self : in out Item; Scale : in Vector_3)
is
begin
Self.Scale := Scale;
end define;
procedure destroy (Self : in out Item)
is
begin
null;
end destroy;
procedure free (Self : in out View)
is
procedure deallocate is new ada.unchecked_Deallocation (Item'Class,
View);
begin
Self.destroy;
deallocate (Self);
end free;
---------------
--- Attributes
--
function Id (Self : in Item'Class) return model_Id
is
begin
return Self.Id;
end Id;
procedure Id_is (Self : in out Item'Class; Now : in model_Id)
is
begin
Self.Id := Now;
end Id_is;
procedure Scale_is (Self : in out Item'Class; Now : in Vector_3)
is
begin
Self.Scale := Now;
end Scale_is;
end physics.Model;
|
AdaCore/training_material | Ada | 510 | adb | with Keys_Pkg;
with Ada.Text_IO; use Ada.Text_IO;
procedure Main is
procedure Generate (Count : Natural) is
Keys : array (1 .. Count) of Keys_Pkg.Key_T;
begin
Put_Line ("In use: " & Integer'image (Keys_Pkg.In_Use));
for I in Keys'range loop
Put_Line (" " & Keys_Pkg.Image (Keys (I)));
end loop;
end Generate;
begin
Put_Line ("In use: " & Integer'image (Keys_Pkg.In_Use));
Generate (4);
Put_Line ("In use: " & Integer'image (Keys_Pkg.In_Use));
end Main;
|
mfkiwl/ewok-kernel-security-OS | Ada | 4,324 | adb | --
-- Copyright 2018 The wookey project team <[email protected]>
-- - Ryad Benadjila
-- - Arnauld Michelizza
-- - Mathieu Renard
-- - Philippe Thierry
-- - Philippe Trebuchet
--
-- Licensed under the Apache License, Version 2.0 (the "License");
-- you may not use this file except in compliance with the License.
-- You may obtain a copy of the License at
--
-- http://www.apache.org/licenses/LICENSE-2.0
--
-- Unless required by applicable law or agreed to in writing, software
-- distributed under the License is distributed on an "AS IS" BASIS,
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-- See the License for the specific language governing permissions and
-- limitations under the License.
--
--
#if CONFIG_KERNEL_DOMAIN
with ewok.tasks;
#end if;
package body ewok.perm
with spark_mode => on
is
function dmashm_is_granted
(from : in t_real_task_id;
to : in t_real_task_id)
return boolean
is
begin
return ewok.perm_auto.com_dmashm_perm (from, to);
end dmashm_is_granted;
function ipc_is_granted
(from : in t_real_task_id;
to : in t_real_task_id)
return boolean
is
begin
return ewok.perm_auto.com_ipc_perm (from, to);
end ipc_is_granted;
#if CONFIG_KERNEL_DOMAIN
function is_same_domain
(from : in t_real_task_id;
to : in t_real_task_id)
return boolean
is
begin
return
ewok.tasks.get_domain (from) = ewok.tasks.get_domain (to);
end is_same_domain;
#end if;
function ressource_is_granted
(perm_name : in t_perm_name;
task_id : in config.applications.t_real_task_id)
return boolean
is
begin
-- is there some assertion checking that some ressources tuples are
-- forbidden
case perm_name is
when PERM_RES_DEV_DMA =>
return
ewok.perm_auto.ressource_perm_register_tab(task_id).DEV_DMA = 1;
when PERM_RES_DEV_CRYPTO_USR =>
return
ewok.perm_auto.ressource_perm_register_tab(task_id).DEV_CRYPTO = 1 or
ewok.perm_auto.ressource_perm_register_tab(task_id).DEV_CRYPTO = 3;
when PERM_RES_DEV_CRYPTO_CFG =>
return
ewok.perm_auto.ressource_perm_register_tab(task_id).DEV_CRYPTO = 2 or
ewok.perm_auto.ressource_perm_register_tab(task_id).DEV_CRYPTO = 3;
when PERM_RES_DEV_CRYPTO_FULL =>
return
ewok.perm_auto.ressource_perm_register_tab(task_id).DEV_CRYPTO = 3;
when PERM_RES_DEV_BUSES =>
return
ewok.perm_auto.ressource_perm_register_tab(task_id).DEV_BUS = 1;
when PERM_RES_DEV_EXTI =>
return
ewok.perm_auto.ressource_perm_register_tab(task_id).DEV_EXTI = 1;
when PERM_RES_DEV_TIM =>
return
ewok.perm_auto.ressource_perm_register_tab(task_id).DEV_TIM = 1;
when PERM_RES_TIM_GETMILLI =>
return
ewok.perm_auto.ressource_perm_register_tab(task_id).TIM_TIME > 0;
when PERM_RES_TIM_GETMICRO =>
return
ewok.perm_auto.ressource_perm_register_tab(task_id).TIM_TIME > 1;
when PERM_RES_TIM_GETCYCLE =>
return
ewok.perm_auto.ressource_perm_register_tab(task_id).TIM_TIME > 2;
when PERM_RES_TSK_FISR =>
return
ewok.perm_auto.ressource_perm_register_tab(task_id).TSK_FISR = 1;
when PERM_RES_TSK_FIPC =>
return
ewok.perm_auto.ressource_perm_register_tab(task_id).TSK_FIPC = 1;
when PERM_RES_TSK_RESET =>
return
ewok.perm_auto.ressource_perm_register_tab(task_id).TSK_RESET = 1;
when PERM_RES_TSK_UPGRADE =>
return
ewok.perm_auto.ressource_perm_register_tab(task_id).TSK_UPGRADE = 1;
when PERM_RES_TSK_RNG =>
return
ewok.perm_auto.ressource_perm_register_tab(task_id).TSK_RNG = 1;
when PERM_RES_MEM_DYNAMIC_MAP =>
return
ewok.perm_auto.ressource_perm_register_tab(task_id).MEM_DYNAMIC_MAP = 1;
end case;
end ressource_is_granted;
end ewok.perm;
|
stcarrez/ada-servlet | Ada | 1,001 | ads | -----------------------------------------------------------------------
-- Servlet testsuite - Ada Server Faces Test suite
-- Copyright (C) 2009, 2010, 2011 Stephane Carrez
-- Written by Stephane Carrez ([email protected])
--
-- Licensed under the Apache License, Version 2.0 (the "License");
-- you may not use this file except in compliance with the License.
-- You may obtain a copy of the License at
--
-- http://www.apache.org/licenses/LICENSE-2.0
--
-- Unless required by applicable law or agreed to in writing, software
-- distributed under the License is distributed on an "AS IS" BASIS,
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-- See the License for the specific language governing permissions and
-- limitations under the License.
-----------------------------------------------------------------------
with Util.Tests;
package Servlet.Testsuite is
function Suite return Util.Tests.Access_Test_Suite;
end Servlet.Testsuite;
|
zhmu/ananas | Ada | 273 | adb | -- { dg-do run }
with prefix1; use prefix1;
procedure test_prefix1 is
Val : Natural;
Obj : T;
--
begin
for J in Obj.Func'Range loop
Val := Obj.Func (J);
if Val /= 2 ** J then
raise Program_Error;
end if;
end loop;
end test_prefix1;
|
reznikmm/matreshka | Ada | 12,356 | adb | ------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- Localization, Internationalization, Globalization for Ada --
-- --
-- Testsuite Component --
-- --
------------------------------------------------------------------------------
-- --
-- Copyright © 2010-2012, Vadim Godunko <[email protected]> --
-- All rights reserved. --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions --
-- are met: --
-- --
-- * Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- --
-- * Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in the --
-- documentation and/or other materials provided with the distribution. --
-- --
-- * Neither the name of the Vadim Godunko, IE nor the names of its --
-- contributors may be used to endorse or promote products derived from --
-- this software without specific prior written permission. --
-- --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR --
-- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
-- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED --
-- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR --
-- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF --
-- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING --
-- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS --
-- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
-- --
------------------------------------------------------------------------------
-- $Revision$ $Date$
------------------------------------------------------------------------------
with Ada.Command_Line;
with Ada.Unchecked_Deallocation;
with Ada.Wide_Wide_Text_IO;
with League.Application;
with League.Characters;
with League.Strings.Cursors.Grapheme_Clusters;
procedure Grapheme_Cluster_Cursor_Test is
use League.Strings;
use League.Strings.Cursors.Grapheme_Clusters;
Break_Character : constant Wide_Wide_Character := '÷';
No_Break_Character : constant Wide_Wide_Character := '×';
type Wide_Wide_String_Access is access all Wide_Wide_String;
type Test_Data is array (Positive range <>) of Wide_Wide_String_Access;
type Test_Data_Access is access all Test_Data;
procedure Free is
new Ada.Unchecked_Deallocation
(Wide_Wide_String, Wide_Wide_String_Access);
procedure Free is
new Ada.Unchecked_Deallocation (Test_Data, Test_Data_Access);
procedure Read_Test_Data
(File_Name : String;
Process : not null access procedure
(Item : in out Universal_String;
Data : Test_Data));
procedure Deep_Free (X : in out Test_Data_Access);
procedure Do_Test (Item : in out Universal_String; Data : Test_Data);
---------------
-- Deep_Free --
---------------
procedure Deep_Free (X : in out Test_Data_Access) is
begin
for J in X'Range loop
Free (X (J));
end loop;
Free (X);
end Deep_Free;
-------------
-- Do_Test --
-------------
procedure Do_Test (Item : in out Universal_String; Data : Test_Data) is
J : Grapheme_Cluster_Cursor;
N : Natural := 1;
begin
-- Test forward-backward iterator
J.First (Item);
while J.Has_Element loop
if J.Element.To_Wide_Wide_String /= Data (N).all then
raise Program_Error;
end if;
J.Next;
N := N + 1;
end loop;
J.Previous;
N := N - 1;
while J.Has_Element loop
if J.Element.To_Wide_Wide_String /= Data (N).all then
raise Program_Error;
end if;
J.Previous;
N := N - 1;
end loop;
-- Test backward-forward iterator
J.Last (Item);
N := Data'Last;
while J.Has_Element loop
if J.Element.To_Wide_Wide_String /= Data (N).all then
raise Program_Error;
end if;
J.Previous;
N := N - 1;
end loop;
J.Next;
N := N + 1;
while J.Has_Element loop
if J.Element.To_Wide_Wide_String /= Data (N).all then
raise Program_Error;
end if;
J.Next;
N := N + 1;
end loop;
end Do_Test;
--------------------
-- Read_Test_Data --
--------------------
procedure Read_Test_Data
(File_Name : String;
Process : not null access procedure
(Item : in out Universal_String;
Data : Test_Data))
is
File : Ada.Wide_Wide_Text_IO.File_Type;
Line : Wide_Wide_String (1 .. 1_024);
Last : Natural;
begin
Ada.Wide_Wide_Text_IO.Open
(File, Ada.Wide_Wide_Text_IO.In_File, File_Name, "wcem=8");
while not Ada.Wide_Wide_Text_IO.End_Of_File (File) loop
Ada.Wide_Wide_Text_IO.Get_Line (File, Line, Last);
-- Remove comment
for J in 1 .. Last loop
if Line (J) = '#' then
Last := J - 1;
exit;
end if;
end loop;
-- Remove trailing spaces
for J in reverse 1 .. Last loop
if Line (J) /= ' ' then
Last := J - 1;
exit;
end if;
end loop;
if Last /= 0 then
declare
Token_First : Positive := 1;
Item : Wide_Wide_String_Access;
Data : Test_Data_Access;
Source : Wide_Wide_String_Access;
X : Universal_String;
procedure Skip_Spaces;
procedure Parse_Break_Indicator;
procedure Parse_Code_Point;
---------------------------
-- Parse_Break_Indicator --
---------------------------
procedure Parse_Break_Indicator is
Aux : Test_Data_Access := Data;
begin
Skip_Spaces;
case Line (Token_First) is
when Break_Character =>
if Item /= null then
if Data = null then
Data := new Test_Data (1 .. 1);
else
Data := new Test_Data (1 .. Aux'Last + 1);
Data (Aux'Range) := Aux.all;
Free (Aux);
end if;
Data (Data'Last) := Item;
Item := null;
end if;
when No_Break_Character =>
null;
when others =>
raise Constraint_Error with "Wrong format of the file";
end case;
Token_First := Token_First + 1;
end Parse_Break_Indicator;
----------------------
-- Parse_Code_Point --
----------------------
procedure Parse_Code_Point is
Token_Last : Positive;
Aux : Wide_Wide_String_Access := Item;
begin
Skip_Spaces;
Token_Last := Token_First;
while Token_Last <= Last loop
case Line (Token_Last) is
when '0' .. '9' | 'A' .. 'F' =>
null;
when ' ' =>
Token_Last := Token_Last - 1;
exit;
when others =>
raise Constraint_Error
with "Wrong format of the file";
end case;
Token_Last := Token_Last + 1;
end loop;
if Item = null then
Item := new Wide_Wide_String (1 .. 1);
else
Item := new Wide_Wide_String (1 .. Aux'Last + 1);
Item (Aux'Range) := Aux.all;
Free (Aux);
end if;
Item (Item'Last) :=
Wide_Wide_Character'Val
(Integer'Wide_Wide_Value
("16#" & Line (Token_First .. Token_Last) & '#'));
if Source = null then
Source := new Wide_Wide_String (1 .. 1);
else
Aux := Source;
Source := new Wide_Wide_String (1 .. Aux'Last + 1);
Source (Aux'Range) := Aux.all;
Free (Aux);
end if;
Source (Source'Last) :=
Wide_Wide_Character'Val
(Integer'Wide_Wide_Value
("16#" & Line (Token_First .. Token_Last) & '#'));
Token_First := Token_Last + 1;
end Parse_Code_Point;
-----------------
-- Skip_Spaces --
-----------------
procedure Skip_Spaces is
begin
for J in Token_First .. Last loop
if Line (J) /= ' ' then
Token_First := J;
exit;
end if;
end loop;
end Skip_Spaces;
OK : Boolean := True;
begin
Parse_Break_Indicator;
while Token_First <= Last loop
Parse_Code_Point;
Parse_Break_Indicator;
end loop;
-- Check whether all source characters are valid Unicode
-- characters. Unicode 6.1.0 introduce use of surrogate code
-- points in test data, these tests can't be used to check
-- Matreshka, because such data is invalid.
for J in Source'Range loop
if not League.Characters.To_Universal_Character
(Source (J)).Is_Valid
then
OK := False;
exit;
end if;
end loop;
if OK then
X := To_Universal_String (Source.all);
Process (X, Data.all);
end if;
Deep_Free (Data);
Free (Source);
end;
end if;
end loop;
Ada.Wide_Wide_Text_IO.Close (File);
end Read_Test_Data;
begin
Read_Test_Data
(Ada.Command_Line.Argument (1) & '/' & "auxiliary/GraphemeBreakTest.txt",
Do_Test'Access);
end Grapheme_Cluster_Cursor_Test;
|
adammw/rtp_labs | Ada | 1,133 | adb | with Ada.Text_IO, Ada.Strings.Unbounded, Ada.Strings.Unbounded.Text_IO, Ada.Characters.Handling;
use Ada.Text_IO, Ada.Strings.Unbounded, Ada.Strings.Unbounded.Text_IO, Ada.Characters.Handling;
procedure Hello is
Name : Unbounded_String;
Input : Character;
function Title_Case (Str : in String) return String is
Result : String(Str'Range);
LastCharacterWasSpace : Boolean := True;
begin
for C in Str'Range loop
if Str(C) = ' ' then
LastCharacterWasSpace := True;
Result(C) := Str(C);
elsif LastCharacterWasSpace then
Result(C) := To_Upper(Str(C));
LastCharacterWasSpace := False;
else
Result(C) := To_Lower(Str(C));
LastCharacterWasSpace := False;
end if;
end loop;
return Result;
end Title_Case;
begin
Put_Line("It's the Hello World example.");
loop
Put_Line("What's your name?");
Get_Line(Name);
Put_Line("Hello " & Title_Case(To_String(Name)) & "!");
Put_Line("It's a me, Mario!");
Put_Line("Again? (Y/N)");
Get(Input); Skip_Line;
exit when Input /= 'y' and Input /= 'Y';
end loop;
end Hello;
|
AdaCore/libadalang | Ada | 412 | adb | procedure Test is
package Pkg is
type R is private;
private
type R is null record;
end Pkg;
X : Pkg.R;
B : Boolean := Pkg."=" (X, X);
--% node.f_default_expr.f_name.p_referenced_decl()
generic
type T is (<>);
package Pkg_2 is
Y : T;
C : Boolean := "<" (Y, Y);
--% node.f_default_expr.f_name.p_referenced_decl()
end Pkg_2;
begin
null;
end Test;
|
AdaCore/gpr | Ada | 182 | ads | package p5_3 is
function p5_3_0 (Item : Integer) return Integer;
function p5_3_1 (Item : Integer) return Integer;
function p5_3_2 (Item : Integer) return Integer;
end p5_3;
|
vpodzime/ada-util | Ada | 2,299 | adb | -----------------------------------------------------------------------
-- Util-texts -- Various Text Transformation Utilities
-- Copyright (C) 2015 Stephane Carrez
-- Written by Stephane Carrez ([email protected])
--
-- Licensed under the Apache License, Version 2.0 (the "License");
-- you may not use this file except in compliance with the License.
-- You may obtain a copy of the License at
--
-- http://www.apache.org/licenses/LICENSE-2.0
--
-- Unless required by applicable law or agreed to in writing, software
-- distributed under the License is distributed on an "AS IS" BASIS,
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-- See the License for the specific language governing permissions and
-- limitations under the License.
-----------------------------------------------------------------------
package body Util.Strings.Transforms is
-- ------------------------------
-- Escape the content into the result stream using the JavaScript
-- escape rules.
-- ------------------------------
function Escape_Javascript (Content : String) return String is
Result : Ada.Strings.Unbounded.Unbounded_String;
begin
TR.Escape_Java_Script (Content, Result);
return Ada.Strings.Unbounded.To_String (Result);
end Escape_Javascript;
-- ------------------------------
-- Escape the content into the result stream using the Java
-- escape rules.
-- ------------------------------
function Escape_Java (Content : String) return String is
Result : Ada.Strings.Unbounded.Unbounded_String;
begin
TR.Escape_Java (Content, Result);
return Ada.Strings.Unbounded.To_String (Result);
end Escape_Java;
-- ------------------------------
-- Escape the content into the result stream using the XML
-- escape rules:
-- '<' -> '<'
-- '>' -> '>'
-- ''' -> '''
-- '&' -> '&'
-- -> '&#nnn;' if Character'Pos >= 128
-- ------------------------------
function Escape_Xml (Content : String) return String is
Result : Ada.Strings.Unbounded.Unbounded_String;
begin
TR.Escape_Xml (Content, Result);
return Ada.Strings.Unbounded.To_String (Result);
end Escape_Xml;
end Util.Strings.Transforms;
|
reznikmm/matreshka | Ada | 7,263 | ads | ------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- Web Framework --
-- --
-- Web API Definition --
-- --
------------------------------------------------------------------------------
-- --
-- Copyright © 2017, Vadim Godunko <[email protected]> --
-- All rights reserved. --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions --
-- are met: --
-- --
-- * Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- --
-- * Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in the --
-- documentation and/or other materials provided with the distribution. --
-- --
-- * Neither the name of the Vadim Godunko, IE nor the names of its --
-- contributors may be used to endorse or promote products derived from --
-- this software without specific prior written permission. --
-- --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR --
-- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
-- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED --
-- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR --
-- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF --
-- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING --
-- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS --
-- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
-- --
------------------------------------------------------------------------------
-- $Revision$ $Date$
------------------------------------------------------------------------------
with WebAPI.HTML.Elements;
with WebAPI.HTML.Validity_States;
package WebAPI.HTML.Option_Elements is
pragma Preelaborate;
type HTML_Option_Element is limited interface
and WebAPI.HTML.Elements.HTML_Element;
type HTML_Option_Element_Access is access all HTML_Option_Element'Class
with Storage_Size => 0;
-- XXX Not implemented
--
-- interface HTMLOptionElement : HTMLElement {
-- readonly attribute HTMLFormElement? form;
not overriding function Get_Disabled
(Self : not null access constant HTML_Option_Element)
return Boolean is abstract
with Import => True,
Convention => JavaScript_Property_Getter,
Link_Name => "disabled";
not overriding procedure Set_Disabled
(Self : not null access constant HTML_Option_Element;
To : Boolean) is abstract
with Import => True,
Convention => JavaScript_Property_Setter,
Link_Name => "disabled";
not overriding function Get_Label
(Self : not null access constant HTML_Option_Element)
return WebAPI.DOM_String is abstract
with Import => True,
Convention => JavaScript_Property_Getter,
Link_Name => "label";
not overriding procedure Set_Label
(Self : not null access constant HTML_Option_Element;
To : WebAPI.DOM_String) is abstract
with Import => True,
Convention => JavaScript_Property_Setter,
Link_Name => "label";
not overriding function Get_Default_Selected
(Self : not null access constant HTML_Option_Element)
return Boolean is abstract
with Import => True,
Convention => JavaScript_Property_Getter,
Link_Name => "defaultSelected";
not overriding procedure Set_Default_Selected
(Self : not null access constant HTML_Option_Element;
To : Boolean) is abstract
with Import => True,
Convention => JavaScript_Property_Setter,
Link_Name => "defaultSelected";
not overriding function Get_Selected
(Self : not null access constant HTML_Option_Element)
return Boolean is abstract
with Import => True,
Convention => JavaScript_Property_Getter,
Link_Name => "selected";
not overriding procedure Set_Selected
(Self : not null access constant HTML_Option_Element;
To : Boolean) is abstract
with Import => True,
Convention => JavaScript_Property_Setter,
Link_Name => "selected";
not overriding function Get_Value
(Self : not null access constant HTML_Option_Element)
return WebAPI.DOM_String is abstract
with Import => True,
Convention => JavaScript_Property_Getter,
Link_Name => "value";
not overriding procedure Set_Value
(Self : not null access constant HTML_Option_Element;
To : WebAPI.DOM_String) is abstract
with Import => True,
Convention => JavaScript_Property_Setter,
Link_Name => "value";
not overriding function Get_Text
(Self : not null access constant HTML_Option_Element)
return WebAPI.DOM_String is abstract
with Import => True,
Convention => JavaScript_Property_Getter,
Link_Name => "text";
not overriding procedure Set_Text
(Self : not null access constant HTML_Option_Element;
To : WebAPI.DOM_String) is abstract
with Import => True,
Convention => JavaScript_Property_Setter,
Link_Name => "text";
not overriding function Get_Index
(Self : not null access constant HTML_Option_Element)
return WebAPI.DOM_Long is abstract
with Import => True,
Convention => JavaScript_Property_Getter,
Link_Name => "index";
end WebAPI.HTML.Option_Elements;
|
AdaCore/gpr | Ada | 1,120 | adb | --
-- Copyright (C) 2021-2023, AdaCore
--
-- SPDX-License-Identifier: Apache-2.0
--
with Ada.Text_IO;
with GPR2.Context;
with GPR2.Log;
with GPR2.Path_Name;
with GPR2.Project.Tree;
procedure Main is
Tree : GPR2.Project.Tree.Object;
Context : GPR2.Context.Object;
use GPR2;
procedure Print_Messages is
begin
if Tree.Has_Messages then
for C in Tree.Log_Messages.Iterate
(False, True, True, True, True)
loop
Ada.Text_IO.Put_Line (GPR2.Log.Element (C).Format);
end loop;
end if;
end Print_Messages;
procedure Test (Project_Name : GPR2.Filename_Type) is
begin
Ada.Text_IO.Put_Line ("testing " & String (Project_Name));
Tree.Unload;
Tree.Load_Autoconf
(Filename => GPR2.Path_Name.Create_File
(GPR2.Project.Ensure_Extension (Project_Name),
GPR2.Path_Name.No_Resolution),
Context => Context);
Print_Messages;
exception
when Project_Error =>
Print_Messages;
end Test;
begin
Test ("data/var.gpr");
Test ("data/attr.gpr");
end Main;
|
kontena/ruby-packer | Ada | 3,035 | ads | ------------------------------------------------------------------------------
-- --
-- GNAT ncurses Binding Samples --
-- --
-- ncurses --
-- --
-- B O D Y --
-- --
------------------------------------------------------------------------------
-- Copyright (c) 2000,2006 Free Software Foundation, Inc. --
-- --
-- Permission is hereby granted, free of charge, to any person obtaining a --
-- copy of this software and associated documentation files (the --
-- "Software"), to deal in the Software without restriction, including --
-- without limitation the rights to use, copy, modify, merge, publish, --
-- distribute, distribute with modifications, sublicense, and/or sell --
-- copies of the Software, and to permit persons to whom the Software is --
-- furnished to do so, subject to the following conditions: --
-- --
-- The above copyright notice and this permission notice shall be included --
-- in all copies or substantial portions of the Software. --
-- --
-- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS --
-- OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF --
-- MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. --
-- IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, --
-- DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR --
-- OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR --
-- THE USE OR OTHER DEALINGS IN THE SOFTWARE. --
-- --
-- Except as contained in this notice, the name(s) of the above copyright --
-- holders shall not be used in advertising or otherwise to promote the --
-- sale, use or other dealings in this Software without prior written --
-- authorization. --
------------------------------------------------------------------------------
-- Author: Eugene V. Melaragno <[email protected]> 2000
-- Version Control
-- $Revision: 1.2 $
-- $Date: 2006/06/25 14:24:40 $
-- Binding Version 01.00
------------------------------------------------------------------------------
procedure ncurses2.attr_test;
|
smola/language-dataset | Ada | 757 | adb | ---------------------------------------------------------------------------
-- FILE : network-addresses-test.adb
-- SUBJECT : Body of a package that supports testing network addresses.
-- AUTHOR : (C) Copyright 2015 by Peter Chapin
--
-- Please send comments or bug reports to
--
-- Peter Chapin <[email protected]>
---------------------------------------------------------------------------
package body Network.Addresses.Test is
function "="(Address : IPv4; Raw : Network.Octet_Array) return Boolean is
begin
return
Address(1) = Raw(Raw'First + 0) and
Address(2) = Raw(Raw'First + 1) and
Address(3) = Raw(Raw'First + 2) and
Address(4) = Raw(Raw'First + 3);
end "=";
end Network.Addresses.Test;
|
AdaCore/Ada_Drivers_Library | Ada | 2,810 | adb | ------------------------------------------------------------------------------
-- --
-- Copyright (C) 2019, AdaCore --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions are --
-- met: --
-- 1. Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- 2. Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in --
-- the documentation and/or other materials provided with the --
-- distribution. --
-- 3. Neither the name of the copyright holder nor the names of its --
-- contributors may be used to endorse or promote products derived --
-- from this software without specific prior written permission. --
-- --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR --
-- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
-- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT --
-- LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, --
-- DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY --
-- THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT --
-- (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE --
-- OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
-- --
------------------------------------------------------------------------------
with MicroBit.IOs.NeoPixel;
package body HMI is
procedure Kitronik_Write (Buffer : UInt8_Array) is
begin
MicroBit.IOs.NeoPixel.Write (Pin => 0, Values => Buffer);
end Kitronik_Write;
procedure Button_CB
(Button : Button_Id;
State : Button_State)
is
begin
if Button = Button_A and then State = Released then
Motors_Enable := not Motors_Enable;
end if;
end Button_CB;
end HMI;
|
reznikmm/matreshka | Ada | 5,120 | ads | ------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- Ada Modeling Framework --
-- --
-- Runtime Library Component --
-- --
------------------------------------------------------------------------------
-- --
-- Copyright © 2012, Vadim Godunko <[email protected]> --
-- All rights reserved. --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions --
-- are met: --
-- --
-- * Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- --
-- * Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in the --
-- documentation and/or other materials provided with the distribution. --
-- --
-- * Neither the name of the Vadim Godunko, IE nor the names of its --
-- contributors may be used to endorse or promote products derived from --
-- this software without specific prior written permission. --
-- --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR --
-- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
-- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED --
-- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR --
-- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF --
-- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING --
-- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS --
-- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
-- --
------------------------------------------------------------------------------
-- $Revision$ $Date$
------------------------------------------------------------------------------
-- This file is generated, don't edit it.
------------------------------------------------------------------------------
with AMF.Internals.Utp_Elements;
with AMF.UML.Call_Operation_Actions;
with AMF.Utp.Start_Timer_Actions;
with AMF.Visitors;
package AMF.Internals.Utp_Start_Timer_Actions is
type Utp_Start_Timer_Action_Proxy is
limited new AMF.Internals.Utp_Elements.Utp_Element_Proxy
and AMF.Utp.Start_Timer_Actions.Utp_Start_Timer_Action with null record;
overriding function Get_Base_Call_Operation_Action
(Self : not null access constant Utp_Start_Timer_Action_Proxy)
return AMF.UML.Call_Operation_Actions.UML_Call_Operation_Action_Access;
-- Getter of StartTimerAction::base_CallOperationAction.
--
overriding procedure Set_Base_Call_Operation_Action
(Self : not null access Utp_Start_Timer_Action_Proxy;
To : AMF.UML.Call_Operation_Actions.UML_Call_Operation_Action_Access);
-- Setter of StartTimerAction::base_CallOperationAction.
--
overriding procedure Enter_Element
(Self : not null access constant Utp_Start_Timer_Action_Proxy;
Visitor : in out AMF.Visitors.Abstract_Visitor'Class;
Control : in out AMF.Visitors.Traverse_Control);
overriding procedure Leave_Element
(Self : not null access constant Utp_Start_Timer_Action_Proxy;
Visitor : in out AMF.Visitors.Abstract_Visitor'Class;
Control : in out AMF.Visitors.Traverse_Control);
overriding procedure Visit_Element
(Self : not null access constant Utp_Start_Timer_Action_Proxy;
Iterator : in out AMF.Visitors.Abstract_Iterator'Class;
Visitor : in out AMF.Visitors.Abstract_Visitor'Class;
Control : in out AMF.Visitors.Traverse_Control);
end AMF.Internals.Utp_Start_Timer_Actions;
|
reznikmm/matreshka | Ada | 9,453 | adb | ------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- XML Processor --
-- --
-- Runtime Library Component --
-- --
------------------------------------------------------------------------------
-- --
-- Copyright © 2013, Vadim Godunko <[email protected]> --
-- All rights reserved. --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions --
-- are met: --
-- --
-- * Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- --
-- * Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in the --
-- documentation and/or other materials provided with the distribution. --
-- --
-- * Neither the name of the Vadim Godunko, IE nor the names of its --
-- contributors may be used to endorse or promote products derived from --
-- this software without specific prior written permission. --
-- --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR --
-- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
-- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED --
-- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR --
-- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF --
-- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING --
-- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS --
-- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
-- --
------------------------------------------------------------------------------
-- $Revision$ $Date$
------------------------------------------------------------------------------
package body XML.Utilities.Namespace_Supports is
--------------------
-- Declare_Prefix --
--------------------
procedure Declare_Prefix
(Self : in out XML_Namespace_Support'Class;
Prefix : League.Strings.Universal_String;
Namespace_URI : League.Strings.Universal_String) is
begin
null;
end Declare_Prefix;
----------------
-- Initialize --
----------------
overriding procedure Initialize (Self : in out XML_Namespace_Support) is
begin
Self.Reset;
end Initialize;
-------------------
-- Namespace_URI --
-------------------
function Namespace_URI
(Self : XML_Namespace_Support'Class;
Prefix : League.Strings.Universal_String;
Component : Component_Kinds := Element)
return League.Strings.Universal_String
is
Position : constant String_Maps.Cursor
:= Self.Current.Namespace_URI.Find (Prefix);
begin
if Prefix.Is_Empty and Component = Attribute then
raise Program_Error;
end if;
if String_Maps.Has_Element (Position) then
return String_Maps.Element (Position);
end if;
raise Constraint_Error;
end Namespace_URI;
-----------------
-- Pop_Context --
-----------------
procedure Pop_Context (Self : in out XML_Namespace_Support'Class) is
begin
-- Clear accumulated mappings for future context.
Self.Future.Prefix.Clear;
Self.Future.Namespace_URI.Clear;
-- Set current prefix mapping from the stack and remove element from the
-- stack.
Self.Current := Self.Stack.Last_Element;
Self.Stack.Delete_Last;
end Pop_Context;
------------
-- Prefix --
------------
function Prefix
(Self : XML_Namespace_Support'Class;
Namespace_URI : League.Strings.Universal_String;
Component : Component_Kinds := Element)
return League.Strings.Universal_String
is
Position : constant String_Maps.Cursor
:= Self.Current.Prefix.Find (Namespace_URI);
Result : League.Strings.Universal_String;
begin
if String_Maps.Has_Element (Position) then
Result := String_Maps.Element (Position);
if Result.Is_Empty and Component = Attribute then
raise Constraint_Error;
end if;
return Result;
else
raise Constraint_Error;
end if;
end Prefix;
--------------
-- Prefixes --
--------------
function Prefixes
(Self : XML_Namespace_Support'Class;
Component : Component_Kinds := Element)
return League.String_Vectors.Universal_String_Vector
is
Result : League.String_Vectors.Universal_String_Vector;
begin
for P of Self.Current.Namespace_URI loop
if Component = Element or not P.Is_Empty then
Result.Append (P);
end if;
end loop;
return Result;
end Prefixes;
--------------
-- Prefixes --
--------------
function Prefixes
(Self : XML_Namespace_Support'Class;
Namespace_URI : League.Strings.Universal_String;
Component : Component_Kinds := Element)
return League.String_Vectors.Universal_String_Vector
is
use type League.Strings.Universal_String;
Result : League.String_Vectors.Universal_String_Vector;
begin
for P of Self.Current.Namespace_URI loop
if Self.Current.Namespace_URI (P) = Namespace_URI
and (Component = Element or not P.Is_Empty)
then
Result.Append (P);
end if;
end loop;
return Result;
end Prefixes;
------------------
-- Process_Name --
------------------
procedure Process_Name
(Self : XML_Namespace_Support'Class;
Qualified_Name : League.Strings.Universal_String;
Component : Component_Kinds;
Namespace_URI : out League.Strings.Universal_String;
Local_Name : out League.Strings.Universal_String)
is
Delimiter : constant Natural := Qualified_Name.Index (':');
Prefix : League.Strings.Universal_String;
begin
if Delimiter /= 0 then
Prefix := Qualified_Name.Slice (1, Delimiter - 1);
Local_Name :=
Qualified_Name.Slice (Delimiter + 1, Qualified_Name.Length);
elsif Component = Attribute then
Namespace_URI.Clear;
Local_Name.Clear;
return;
else
Local_Name := Qualified_Name;
end if;
Namespace_URI := Self.Namespace_URI (Prefix, Component);
end Process_Name;
------------------
-- Push_Context --
------------------
procedure Push_Context (Self : in out XML_Namespace_Support'Class) is
begin
-- Save current state in the stack.
Self.Stack.Append (Self.Current);
-- Compute new context using accumulated future prefix mappings.
for U of Self.Future.Prefix loop
Self.Current.Prefix.Include (U, Self.Future.Prefix (U));
end loop;
for P of Self.Future.Namespace_URI loop
Self.Current.Namespace_URI.Include (P, Self.Future.Namespace_URI (P));
end loop;
-- Clear accumulated mappings for future context.
Self.Future.Prefix.Clear;
Self.Future.Namespace_URI.Clear;
end Push_Context;
-----------
-- Reset --
-----------
procedure Reset (Self : in out XML_Namespace_Support'Class) is
XML_URI : constant League.Strings.Universal_String
:= League.Strings.To_Universal_String
("http://www.w3.org/XML/1998/namespace");
XML_Prefix : constant League.Strings.Universal_String
:= League.Strings.To_Universal_String ("xml");
begin
-- Clear internal state.
Self.Current.Prefix.Clear;
Self.Current.Namespace_URI.Clear;
Self.Future.Prefix.Clear;
Self.Future.Namespace_URI.Clear;
Self.Stack.Clear;
-- Define default prefix mapping.
Self.Current.Prefix.Insert (XML_URI, XML_Prefix);
Self.Current.Namespace_URI.Insert (XML_Prefix, XML_URI);
end Reset;
end XML.Utilities.Namespace_Supports;
|
psyomn/ash | Ada | 3,060 | adb | -- 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.Command_Line; use Ada.Command_Line;
with Ada.Strings.Fixed; use Ada.Strings.Fixed;
with Common_Utils; use Common_Utils;
package body CLI is
procedure Process_Command_Line_Arguments (Conf : in out Listener) is
Total : constant Natural := Argument_Count;
Count : Positive := 1;
Skip : Boolean := False;
begin
if Total = 0 then
return;
end if;
Argument_Parse_Loop : loop
declare
Current_Argument : constant String := Argument (Count);
First_Two : constant String := Current_Argument (1 .. 2);
Hyphenated : constant Boolean := Current_Argument (1) = '-';
begin
if Count + 1 > Argument_Count and Hyphenated then
raise CLI_Argument_Exception with "you need to provide a value";
else
Skip := True;
end if;
if First_Two = "-r" then Apply_Root_Dir_Flag (Conf, Count);
elsif First_Two = "-p" then Apply_Port_Flag (Conf, Count);
elsif First_Two = "-h" then Apply_Host_Flag (Conf, Count);
else raise CLI_Argument_Exception with "non existant flag";
end if;
end;
Count := Count + 1 + (if Skip then 1 else 0);
Skip := False;
exit Argument_Parse_Loop when Count > Total;
end loop Argument_Parse_Loop;
end Process_Command_Line_Arguments;
procedure Apply_Root_Dir_Flag (Conf : in out Listener; Index : Positive) is
New_Path : constant String := Trim (
Source => Argument (Index + 1),
Side => Both
);
begin
Empty_String (Conf.WS_Root_Path);
Conf.WS_Root_Path (1 .. New_Path'Last) := New_Path (1 .. New_Path'Last);
end Apply_Root_Dir_Flag;
procedure Apply_Port_Flag (Conf : in out Listener; Index : Positive) is
Arg : constant String := Argument (Index + 1);
New_Port : constant Natural := Positive'Value (Arg);
begin
Conf.Port_Number := New_Port;
end Apply_Port_Flag;
procedure Apply_Host_Flag (Conf : in out Listener; Index : Positive) is
New_Host : constant String := Trim (
Source => Argument (Index + 1),
Side => Both
);
begin
Empty_String (Conf.Host_Name);
Overwrite (
Source => Conf.Host_Name,
Position => 1,
New_Item => New_Host
);
end Apply_Host_Flag;
end CLI;
|
mitchelhaan/ncurses | Ada | 77,327 | adb | ------------------------------------------------------------------------------
-- --
-- GNAT ncurses Binding --
-- --
-- Terminal_Interface.Curses --
-- --
-- B O D Y --
-- --
------------------------------------------------------------------------------
-- Copyright (c) 1998 Free Software Foundation, Inc. --
-- --
-- Permission is hereby granted, free of charge, to any person obtaining a --
-- copy of this software and associated documentation files (the --
-- "Software"), to deal in the Software without restriction, including --
-- without limitation the rights to use, copy, modify, merge, publish, --
-- distribute, distribute with modifications, sublicense, and/or sell --
-- copies of the Software, and to permit persons to whom the Software is --
-- furnished to do so, subject to the following conditions: --
-- --
-- The above copyright notice and this permission notice shall be included --
-- in all copies or substantial portions of the Software. --
-- --
-- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS --
-- OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF --
-- MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. --
-- IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, --
-- DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR --
-- OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR --
-- THE USE OR OTHER DEALINGS IN THE SOFTWARE. --
-- --
-- Except as contained in this notice, the name(s) of the above copyright --
-- holders shall not be used in advertising or otherwise to promote the --
-- sale, use or other dealings in this Software without prior written --
-- authorization. --
------------------------------------------------------------------------------
-- Author: Juergen Pfeifer <[email protected]> 1996
-- Version Control:
-- $Revision: 1.15 $
-- Binding Version 00.93
------------------------------------------------------------------------------
with System;
with Terminal_Interface.Curses.Aux; use Terminal_Interface.Curses.Aux;
with Interfaces.C; use Interfaces.C;
with Interfaces.C.Strings; use Interfaces.C.Strings;
with Ada.Characters.Handling; use Ada.Characters.Handling;
with Ada.Strings.Fixed;
with Unchecked_Conversion;
package body Terminal_Interface.Curses is
use type System.Bit_Order;
package ASF renames Ada.Strings.Fixed;
type chtype_array is array (size_t range <>)
of aliased Attributed_Character;
pragma Convention (C, chtype_array);
------------------------------------------------------------------------------
function Key_Name (Key : in Real_Key_Code) return String
is
function Keyname (K : C_Int) return chars_ptr;
pragma Import (C, Keyname, "keyname");
Ch : Character;
begin
if Key <= Character'Pos (Character'Last) then
Ch := Character'Val (Key);
if Is_Control (Ch) then
return Un_Control (Attributed_Character'(Ch => Ch,
Color => Color_Pair'First,
Attr => Normal_Video));
elsif Is_Graphic (Ch) then
declare
S : String (1 .. 1);
begin
S (1) := Ch;
return S;
end;
else
return "";
end if;
else
return Fill_String (Keyname (C_Int (Key)));
end if;
end Key_Name;
procedure Key_Name (Key : in Real_Key_Code;
Name : out String)
is
begin
ASF.Move (Key_Name (Key), Name);
end Key_Name;
------------------------------------------------------------------------------
procedure Init_Screen
is
function Initscr return Window;
pragma Import (C, Initscr, "initscr");
function Check_Version (Major, Minor : C_Int) return C_Int;
pragma Import (C, Check_Version, "_nc_ada_vcheck");
W : Window;
begin
if (Check_Version (NC_Major_Version, NC_Minor_Version) = 0) then
raise Wrong_Curses_Version;
else
W := Initscr;
if W = Null_Window then
raise Curses_Exception;
end if;
end if;
end Init_Screen;
procedure End_Windows
is
function Endwin return C_Int;
pragma Import (C, Endwin, "endwin");
begin
if Endwin = Curses_Err then
raise Curses_Exception;
end if;
end End_Windows;
function Is_End_Window return Boolean
is
function Isendwin return C_Int;
pragma Import (C, Isendwin, "isendwin");
begin
if Isendwin = Curses_False then
return False;
else
return True;
end if;
end Is_End_Window;
------------------------------------------------------------------------------
procedure Move_Cursor (Win : in Window := Standard_Window;
Line : in Line_Position;
Column : in Column_Position)
is
function Wmove (Win : Window;
Line : C_Int;
Column : C_Int
) return C_Int;
pragma Import (C, Wmove, "wmove");
begin
if Wmove (Win, C_Int (Line), C_Int (Column)) = Curses_Err then
raise Curses_Exception;
end if;
end Move_Cursor;
------------------------------------------------------------------------------
procedure Add (Win : in Window := Standard_Window;
Ch : in Attributed_Character)
is
function Waddch (W : Window;
Ch : C_Int) return C_Int;
pragma Import (C, Waddch, "waddch");
begin
if Waddch (Win, Chtype_To_Cint (Ch)) = Curses_Err then
raise Curses_Exception;
end if;
end Add;
procedure Add (Win : in Window := Standard_Window;
Ch : in Character)
is
begin
Add (Win,
Attributed_Character'(Ch => Ch,
Color => Color_Pair'First,
Attr => Normal_Video));
end Add;
procedure Add
(Win : in Window := Standard_Window;
Line : in Line_Position;
Column : in Column_Position;
Ch : in Attributed_Character)
is
function mvwaddch (W : Window;
Y : C_Int;
X : C_Int;
Ch : C_Int) return C_Int;
pragma Import (C, mvwaddch, "mvwaddch");
begin
if mvwaddch (Win, C_Int (Line),
C_Int (Column),
Chtype_To_CInt (Ch)) = Curses_Err then
raise Curses_Exception;
end if;
end Add;
procedure Add
(Win : in Window := Standard_Window;
Line : in Line_Position;
Column : in Column_Position;
Ch : in Character)
is
begin
Add (Win,
Line,
Column,
Attributed_Character'(Ch => Ch,
Color => Color_Pair'First,
Attr => Normal_Video));
end Add;
procedure Add_With_Immediate_Echo
(Win : in Window := Standard_Window;
Ch : in Attributed_Character)
is
function Wechochar (W : Window;
Ch : C_Int) return C_Int;
pragma Import (C, Wechochar, "wechochar");
begin
if Wechochar (Win, Chtype_To_CInt (Ch)) = Curses_Err then
raise Curses_Exception;
end if;
end Add_With_Immediate_Echo;
procedure Add_With_Immediate_Echo
(Win : in Window := Standard_Window;
Ch : in Character)
is
begin
Add_With_Immediate_Echo
(Win,
Attributed_Character'(Ch => Ch,
Color => Color_Pair'First,
Attr => Normal_Video));
end Add_With_Immediate_Echo;
------------------------------------------------------------------------------
function Create (Number_Of_Lines : Line_Count;
Number_Of_Columns : Column_Count;
First_Line_Position : Line_Position;
First_Column_Position : Column_Position) return Window
is
function Newwin (Number_Of_Lines : C_Int;
Number_Of_Columns : C_Int;
First_Line_Position : C_Int;
First_Column_Position : C_Int) return Window;
pragma Import (C, Newwin, "newwin");
W : Window;
begin
W := Newwin (C_Int (Number_Of_Lines),
C_Int (Number_Of_Columns),
C_Int (First_Line_Position),
C_Int (First_Column_Position));
if W = Null_Window then
raise Curses_Exception;
end if;
return W;
end Create;
procedure Delete (Win : in out Window)
is
function Wdelwin (W : Window) return C_Int;
pragma Import (C, Wdelwin, "delwin");
begin
if Wdelwin (Win) = Curses_Err then
raise Curses_Exception;
end if;
Win := Null_Window;
end Delete;
function Sub_Window
(Win : Window := Standard_Window;
Number_Of_Lines : Line_Count;
Number_Of_Columns : Column_Count;
First_Line_Position : Line_Position;
First_Column_Position : Column_Position) return Window
is
function Subwin
(Win : Window;
Number_Of_Lines : C_Int;
Number_Of_Columns : C_Int;
First_Line_Position : C_Int;
First_Column_Position : C_Int) return Window;
pragma Import (C, Subwin, "subwin");
W : Window;
begin
W := Subwin (Win,
C_Int (Number_Of_Lines),
C_Int (Number_Of_Columns),
C_Int (First_Line_Position),
C_Int (First_Column_Position));
if W = Null_Window then
raise Curses_Exception;
end if;
return W;
end Sub_Window;
function Derived_Window
(Win : Window := Standard_Window;
Number_Of_Lines : Line_Count;
Number_Of_Columns : Column_Count;
First_Line_Position : Line_Position;
First_Column_Position : Column_Position) return Window
is
function Derwin
(Win : Window;
Number_Of_Lines : C_Int;
Number_Of_Columns : C_Int;
First_Line_Position : C_Int;
First_Column_Position : C_Int) return Window;
pragma Import (C, Derwin, "derwin");
W : Window;
begin
W := Derwin (Win,
C_Int (Number_Of_Lines),
C_Int (Number_Of_Columns),
C_Int (First_Line_Position),
C_Int (First_Column_Position));
if W = Null_Window then
raise Curses_Exception;
end if;
return W;
end Derived_Window;
function Duplicate (Win : Window) return Window
is
function Dupwin (Win : Window) return Window;
pragma Import (C, Dupwin, "dupwin");
W : Window := Dupwin (Win);
begin
if W = Null_Window then
raise Curses_Exception;
end if;
return W;
end Duplicate;
procedure Move_Window (Win : in Window;
Line : in Line_Position;
Column : in Column_Position)
is
function Mvwin (Win : Window;
Line : C_Int;
Column : C_Int) return C_Int;
pragma Import (C, Mvwin, "mvwin");
begin
if Mvwin (Win, C_Int (Line), C_Int (Column)) = Curses_Err then
raise Curses_Exception;
end if;
end Move_Window;
procedure Move_Derived_Window (Win : in Window;
Line : in Line_Position;
Column : in Column_Position)
is
function Mvderwin (Win : Window;
Line : C_Int;
Column : C_Int) return C_Int;
pragma Import (C, Mvderwin, "mvderwin");
begin
if Mvderwin (Win, C_Int (Line), C_Int (Column)) = Curses_Err then
raise Curses_Exception;
end if;
end Move_Derived_Window;
procedure Set_Synch_Mode (Win : in Window := Standard_Window;
Mode : in Boolean := False)
is
function Syncok (Win : Window;
Mode : C_Int) return C_Int;
pragma Import (C, Syncok, "syncok");
begin
if Syncok (Win, Boolean'Pos (Mode)) = Curses_Err then
raise Curses_Exception;
end if;
end Set_Synch_Mode;
------------------------------------------------------------------------------
procedure Add (Win : in Window := Standard_Window;
Str : in String;
Len : in Integer := -1)
is
type Char_Ptr is access all Interfaces.C.Char;
function Waddnstr (Win : Window;
Str : Char_Ptr;
Len : C_Int := -1) return C_Int;
pragma Import (C, Waddnstr, "waddnstr");
Txt : char_array (0 .. Str'Length);
Length : size_t;
begin
To_C (Str, Txt, Length);
if Waddnstr (Win, Txt (Txt'First)'Access, C_Int (Len)) = Curses_Err then
raise Curses_Exception;
end if;
end Add;
procedure Add
(Win : in Window := Standard_Window;
Line : in Line_Position;
Column : in Column_Position;
Str : in String;
Len : in Integer := -1)
is
begin
Move_Cursor (Win, Line, Column);
Add (Win, Str, Len);
end Add;
------------------------------------------------------------------------------
procedure Add
(Win : in Window := Standard_Window;
Str : in Attributed_String;
Len : in Integer := -1)
is
type Chtype_Ptr is access all Attributed_Character;
function Waddchnstr (Win : Window;
Str : Chtype_Ptr;
Len : C_Int := -1) return C_Int;
pragma Import (C, Waddchnstr, "waddchnstr");
Txt : chtype_array (0 .. Str'Length);
begin
for Length in 1 .. size_t (Str'Length) loop
Txt (Length - 1) := Str (Natural (Length));
end loop;
Txt (Str'Length) := Default_Character;
if Waddchnstr (Win,
Txt (Txt'First)'Access,
C_Int (Len)) = Curses_Err then
raise Curses_Exception;
end if;
end Add;
procedure Add
(Win : in Window := Standard_Window;
Line : in Line_Position;
Column : in Column_Position;
Str : in Attributed_String;
Len : in Integer := -1)
is
begin
Move_Cursor (Win, Line, Column);
Add (Win, Str, Len);
end Add;
------------------------------------------------------------------------------
procedure Border
(Win : in Window := Standard_Window;
Left_Side_Symbol : in Attributed_Character := Default_Character;
Right_Side_Symbol : in Attributed_Character := Default_Character;
Top_Side_Symbol : in Attributed_Character := Default_Character;
Bottom_Side_Symbol : in Attributed_Character := Default_Character;
Upper_Left_Corner_Symbol : in Attributed_Character := Default_Character;
Upper_Right_Corner_Symbol : in Attributed_Character := Default_Character;
Lower_Left_Corner_Symbol : in Attributed_Character := Default_Character;
Lower_Right_Corner_Symbol : in Attributed_Character := Default_Character)
is
function Wborder (W : Window;
LS : C_Int;
RS : C_Int;
TS : C_Int;
BS : C_Int;
ULC : C_Int;
URC : C_Int;
LLC : C_Int;
LRC : C_Int) return C_Int;
pragma Import (C, Wborder, "wborder");
begin
if Wborder (Win,
Chtype_To_CInt (Left_Side_Symbol),
Chtype_To_CInt (Right_Side_Symbol),
Chtype_To_CInt (Top_Side_Symbol),
Chtype_To_CInt (Bottom_Side_Symbol),
Chtype_To_CInt (Upper_Left_Corner_Symbol),
Chtype_To_CInt (Upper_Right_Corner_Symbol),
Chtype_To_CInt (Lower_Left_Corner_Symbol),
Chtype_To_CInt (Lower_Right_Corner_Symbol)
) = Curses_Err
then
raise Curses_Exception;
end if;
end Border;
procedure Box
(Win : in Window := Standard_Window;
Vertical_Symbol : in Attributed_Character := Default_Character;
Horizontal_Symbol : in Attributed_Character := Default_Character)
is
begin
Border (Win,
Vertical_Symbol, Vertical_Symbol,
Horizontal_Symbol, Horizontal_Symbol);
end Box;
procedure Horizontal_Line
(Win : in Window := Standard_Window;
Line_Size : in Natural;
Line_Symbol : in Attributed_Character := Default_Character)
is
function Whline (W : Window;
Ch : C_Int;
Len : C_Int) return C_Int;
pragma Import (C, Whline, "whline");
begin
if Whline (Win,
Chtype_To_CInt (Line_Symbol),
C_Int (Line_Size)) = Curses_Err then
raise Curses_Exception;
end if;
end Horizontal_Line;
procedure Vertical_Line
(Win : in Window := Standard_Window;
Line_Size : in Natural;
Line_Symbol : in Attributed_Character := Default_Character)
is
function Wvline (W : Window;
Ch : C_Int;
Len : C_Int) return C_Int;
pragma Import (C, Wvline, "wvline");
begin
if Wvline (Win,
Chtype_To_CInt (Line_Symbol),
C_Int (Line_Size)) = Curses_Err then
raise Curses_Exception;
end if;
end Vertical_Line;
------------------------------------------------------------------------------
function Get_Keystroke (Win : Window := Standard_Window)
return Real_Key_Code
is
function Wgetch (W : Window) return C_Int;
pragma Import (C, Wgetch, "wgetch");
C : constant C_Int := Wgetch (Win);
begin
if C = Curses_Err then
return Key_None;
else
return Real_Key_Code (C);
end if;
end Get_Keystroke;
procedure Undo_Keystroke (Key : in Real_Key_Code)
is
function Ungetch (Ch : C_Int) return C_Int;
pragma Import (C, Ungetch, "ungetch");
begin
if Ungetch (C_Int (Key)) = Curses_Err then
raise Curses_Exception;
end if;
end Undo_Keystroke;
function Has_Key (Key : Special_Key_Code) return Boolean
is
function Haskey (Key : C_Int) return C_Int;
pragma Import (C, Haskey, "has_key");
begin
if Haskey (C_Int (Key)) = Curses_False then
return False;
else
return True;
end if;
end Has_Key;
function Is_Function_Key (Key : Special_Key_Code) return Boolean
is
L : constant Special_Key_Code := Special_Key_Code (Natural (Key_F0) +
Natural (Function_Key_Number'Last));
begin
if (Key >= Key_F0) and then (Key <= L) then
return True;
else
return False;
end if;
end Is_Function_Key;
function Function_Key (Key : Real_Key_Code)
return Function_Key_Number
is
begin
if Is_Function_Key (Key) then
return Function_Key_Number (Key - Key_F0);
else
raise Constraint_Error;
end if;
end Function_Key;
function Function_Key_Code (Key : Function_Key_Number) return Real_Key_Code
is
begin
return Real_Key_Code (Natural (Key_F0) + Natural (Key));
end Function_Key_Code;
------------------------------------------------------------------------------
procedure Switch_Character_Attribute
(Win : in Window := Standard_Window;
Attr : in Character_Attribute_Set := Normal_Video;
On : in Boolean := True)
is
function Wattron (Win : Window;
C_Attr : C_Int) return C_Int;
pragma Import (C, Wattron, "wattr_on");
function Wattroff (Win : Window;
C_Attr : C_Int) return C_Int;
pragma Import (C, Wattroff, "wattr_off");
-- In Ada we use the On Boolean to control whether or not we want to
-- switch on or off the attributes in the set.
Err : C_Int;
AC : constant Attributed_Character := (Ch => Character'First,
Color => Color_Pair'First,
Attr => Attr);
begin
if On then
Err := Wattron (Win, Chtype_To_CInt (AC));
else
Err := Wattroff (Win, Chtype_To_CInt (AC));
end if;
if Err = Curses_Err then
raise Curses_Exception;
end if;
end Switch_Character_Attribute;
procedure Set_Character_Attributes
(Win : in Window := Standard_Window;
Attr : in Character_Attribute_Set := Normal_Video;
Color : in Color_Pair := Color_Pair'First)
is
function Wattrset (Win : Window;
C_Attr : C_Int) return C_Int;
pragma Import (C, Wattrset, "wattrset"); -- ??? wattr_set
begin
if Wattrset (Win,
Chtype_To_CInt (Attributed_Character'
(Ch => Character'First,
Color => Color,
Attr => Attr))) = Curses_Err then
raise Curses_Exception;
end if;
end Set_Character_Attributes;
function Get_Character_Attribute (Win : Window := Standard_Window)
return Character_Attribute_Set
is
function Wattrget (Win : Window) return C_Int;
pragma Import (C, Wattrget, "wattr_get");
Ch : Attributed_Character := CInt_To_Chtype (Wattrget (Win));
begin
return Ch.Attr;
end Get_Character_Attribute;
function Get_Character_Attribute (Win : Window := Standard_Window)
return Color_Pair
is
function Wattrget (Win : Window) return C_Int;
pragma Import (C, Wattrget, "wattr_get");
Ch : Attributed_Character := CInt_To_Chtype (Wattrget (Win));
begin
return Ch.Color;
end Get_Character_Attribute;
procedure Change_Attributes
(Win : in Window := Standard_Window;
Count : in Integer := -1;
Attr : in Character_Attribute_Set := Normal_Video;
Color : in Color_Pair := Color_Pair'First)
is
function Wchgat (Win : Window;
Cnt : C_Int;
Attr : C_Int;
Color : C_Short;
Opts : System.Address := System.Null_Address)
return C_Int;
pragma Import (C, Wchgat, "wchgat");
Ch : constant Attributed_Character :=
(Ch => Character'First, Color => Color_Pair'First, Attr => Attr);
begin
if Wchgat (Win, C_Int (Count), Chtype_To_CInt (Ch),
C_Short (Color)) = Curses_Err then
raise Curses_Exception;
end if;
end Change_Attributes;
procedure Change_Attributes
(Win : in Window := Standard_Window;
Line : in Line_Position := Line_Position'First;
Column : in Column_Position := Column_Position'First;
Count : in Integer := -1;
Attr : in Character_Attribute_Set := Normal_Video;
Color : in Color_Pair := Color_Pair'First)
is
begin
Move_Cursor (Win, Line, Column);
Change_Attributes (Win, Count, Attr, Color);
end Change_Attributes;
------------------------------------------------------------------------------
procedure Beep
is
function Beeper return C_Int;
pragma Import (C, Beeper, "beep");
begin
if Beeper = Curses_Err then
raise Curses_Exception;
end if;
end Beep;
procedure Flash_Screen
is
function Flash return C_Int;
pragma Import (C, Flash, "flash");
begin
if Flash = Curses_Err then
raise Curses_Exception;
end if;
end Flash_Screen;
------------------------------------------------------------------------------
procedure Set_Cbreak_Mode (SwitchOn : in Boolean := True)
is
function Cbreak return C_Int;
pragma Import (C, Cbreak, "cbreak");
function NoCbreak return C_Int;
pragma Import (C, NoCbreak, "nocbreak");
Err : C_Int;
begin
if SwitchOn then
Err := Cbreak;
else
Err := NoCbreak;
end if;
if Err = Curses_Err then
raise Curses_Exception;
end if;
end Set_Cbreak_Mode;
procedure Set_Raw_Mode (SwitchOn : in Boolean := True)
is
function Raw return C_Int;
pragma Import (C, Raw, "raw");
function NoRaw return C_Int;
pragma Import (C, NoRaw, "noraw");
Err : C_Int;
begin
if SwitchOn then
Err := Raw;
else
Err := NoRaw;
end if;
if Err = Curses_Err then
raise Curses_Exception;
end if;
end Set_Raw_Mode;
procedure Set_Echo_Mode (SwitchOn : in Boolean := True)
is
function Echo return C_Int;
pragma Import (C, Echo, "echo");
function NoEcho return C_Int;
pragma Import (C, NoEcho, "noecho");
Err : C_Int;
begin
if SwitchOn then
Err := Echo;
else
Err := NoEcho;
end if;
if Err = Curses_Err then
raise Curses_Exception;
end if;
end Set_Echo_Mode;
procedure Set_Meta_Mode (Win : in Window := Standard_Window;
SwitchOn : in Boolean := True)
is
function Meta (W : Window; Mode : C_Int) return C_Int;
pragma Import (C, Meta, "meta");
begin
if Meta (Win, Boolean'Pos (SwitchOn)) = Curses_Err then
raise Curses_Exception;
end if;
end Set_Meta_Mode;
procedure Set_KeyPad_Mode (Win : in Window := Standard_Window;
SwitchOn : in Boolean := True)
is
function Keypad (W : Window; Mode : C_Int) return C_Int;
pragma Import (C, Keypad, "keypad");
begin
if Keypad (Win, Boolean'Pos (SwitchOn)) = Curses_Err then
raise Curses_Exception;
end if;
end Set_KeyPad_Mode;
procedure Half_Delay (Amount : in Half_Delay_Amount)
is
function Halfdelay (Amount : C_Int) return C_Int;
pragma Import (C, Halfdelay, "halfdelay");
begin
if Halfdelay (C_Int (Amount)) = Curses_Err then
raise Curses_Exception;
end if;
end Half_Delay;
procedure Set_Flush_On_Interrupt_Mode
(Win : in Window := Standard_Window;
Mode : in Boolean := True)
is
function Intrflush (Win : Window; Mode : C_Int) return C_Int;
pragma Import (C, Intrflush, "intrflush");
begin
if Intrflush (Win, Boolean'Pos (Mode)) = Curses_Err then
raise Curses_Exception;
end if;
end Set_Flush_On_Interrupt_Mode;
procedure Set_Queue_Interrupt_Mode
(Win : in Window := Standard_Window;
Flush : in Boolean := True)
is
procedure Qiflush;
pragma Import (C, Qiflush, "qiflush");
procedure No_Qiflush;
pragma Import (C, No_Qiflush, "noqiflush");
begin
if Flush then
Qiflush;
else
No_Qiflush;
end if;
end Set_Queue_Interrupt_Mode;
procedure Set_NoDelay_Mode
(Win : in Window := Standard_Window;
Mode : in Boolean := False)
is
function Nodelay (Win : Window; Mode : C_Int) return C_Int;
pragma Import (C, Nodelay, "nodelay");
begin
if Nodelay (Win, Boolean'Pos (Mode)) = Curses_Err then
raise Curses_Exception;
end if;
end Set_NoDelay_Mode;
procedure Set_Timeout_Mode (Win : in Window := Standard_Window;
Mode : in Timeout_Mode;
Amount : in Natural)
is
function Wtimeout (Win : Window; Amount : C_Int) return C_Int;
pragma Import (C, Wtimeout, "wtimeout");
Time : C_Int;
begin
case Mode is
when Blocking => Time := -1;
when Non_Blocking => Time := 0;
when Delayed =>
if Amount = 0 then
raise CONSTRAINT_ERROR;
end if;
Time := C_Int (Amount);
end case;
if Wtimeout (Win, Time) = Curses_Err then
raise Curses_Exception;
end if;
end Set_Timeout_Mode;
procedure Set_Escape_Timer_Mode
(Win : in Window := Standard_Window;
Timer_Off : in Boolean := False)
is
function Notimeout (Win : Window; Mode : C_Int) return C_Int;
pragma Import (C, Notimeout, "notimeout");
begin
if Notimeout (Win, Boolean'Pos (Timer_Off)) = Curses_Err then
raise Curses_Exception;
end if;
end Set_Escape_Timer_Mode;
------------------------------------------------------------------------------
procedure Set_NL_Mode (SwitchOn : in Boolean := True)
is
function NL return C_Int;
pragma Import (C, NL, "nl");
function NoNL return C_Int;
pragma Import (C, NoNL, "nonl");
Err : C_Int;
begin
if SwitchOn then
Err := NL;
else
Err := NoNL;
end if;
if Err = Curses_Err then
raise Curses_Exception;
end if;
end Set_NL_Mode;
procedure Clear_On_Next_Update
(Win : in Window := Standard_Window;
Do_Clear : in Boolean := True)
is
function Clear_Ok (W : Window; Flag : C_Int) return C_Int;
pragma Import (C, Clear_Ok, "clearok");
begin
if Clear_Ok (Win, Boolean'Pos (Do_Clear)) = Curses_Err then
raise Curses_Exception;
end if;
end Clear_On_Next_Update;
procedure Use_Insert_Delete_Line
(Win : in Window := Standard_Window;
Do_Idl : in Boolean := True)
is
function IDL_Ok (W : Window; Flag : C_Int) return C_Int;
pragma Import (C, IDL_Ok, "idlok");
begin
if IDL_Ok (Win, Boolean'Pos (Do_Idl)) = Curses_Err then
raise Curses_Exception;
end if;
end Use_Insert_Delete_Line;
procedure Use_Insert_Delete_Character
(Win : in Window := Standard_Window;
Do_Idc : in Boolean := True)
is
function IDC_Ok (W : Window; Flag : C_Int) return C_Int;
pragma Import (C, IDC_Ok, "idcok");
begin
if IDC_Ok (Win, Boolean'Pos (Do_Idc)) = Curses_Err then
raise Curses_Exception;
end if;
end Use_Insert_Delete_Character;
procedure Leave_Cursor_After_Update
(Win : in Window := Standard_Window;
Do_Leave : in Boolean := True)
is
function Leave_Ok (W : Window; Flag : C_Int) return C_Int;
pragma Import (C, Leave_Ok, "leaveok");
begin
if Leave_Ok (Win, Boolean'Pos (Do_Leave)) = Curses_Err then
raise Curses_Exception;
end if;
end Leave_Cursor_After_Update;
procedure Immediate_Update_Mode
(Win : in Window := Standard_Window;
Mode : in Boolean := False)
is
function Immedok (Win : Window; Mode : C_Int) return C_Int;
pragma Import (C, Immedok, "immedok");
begin
if Immedok (Win, Boolean'Pos (Mode)) = Curses_Err then
raise Curses_Exception;
end if;
end Immediate_Update_Mode;
procedure Allow_Scrolling
(Win : in Window := Standard_Window;
Mode : in Boolean := False)
is
function Scrollok (Win : Window; Mode : C_Int) return C_Int;
pragma Import (C, Scrollok, "scrollok");
begin
if Scrollok (Win, Boolean'Pos (Mode)) = Curses_Err then
raise Curses_Exception;
end if;
end Allow_Scrolling;
function Scrolling_Allowed (Win : Window := Standard_Window) return Boolean
is
function Is_Scroll (Win : Window) return C_Int;
pragma Import (C, Is_Scroll, "_nc_ada_isscroll");
Res : constant C_Int := Is_Scroll (Win);
begin
case Res is
when Curses_True => return True;
when Curses_False => return False;
when others => raise Curses_Exception;
end case;
end Scrolling_Allowed;
procedure Set_Scroll_Region
(Win : in Window := Standard_Window;
Top_Line : in Line_Position;
Bottom_Line : in Line_Position)
is
function Wsetscrreg (Win : Window;
Lin : C_Int;
Col : C_Int) return C_Int;
pragma Import (C, Wsetscrreg, "wsetscrreg");
begin
if Wsetscrreg (Win, C_Int (Top_Line), C_Int (Bottom_Line))
= Curses_Err then
raise Curses_Exception;
end if;
end Set_Scroll_Region;
------------------------------------------------------------------------------
procedure Update_Screen
is
function Do_Update return C_Int;
pragma Import (C, Do_Update, "doupdate");
begin
if Do_Update = Curses_Err then
raise Curses_Exception;
end if;
end Update_Screen;
procedure Refresh (Win : in Window := Standard_Window)
is
function Wrefresh (W : Window) return C_Int;
pragma Import (C, Wrefresh, "wrefresh");
begin
if Wrefresh (Win) = Curses_Err then
raise Curses_Exception;
end if;
end Refresh;
procedure Refresh_Without_Update
(Win : in Window := Standard_Window)
is
function Wnoutrefresh (W : Window) return C_Int;
pragma Import (C, Wnoutrefresh, "wnoutrefresh");
begin
if Wnoutrefresh (Win) = Curses_Err then
raise Curses_Exception;
end if;
end Refresh_Without_Update;
procedure Redraw (Win : in Window := Standard_Window)
is
function Redrawwin (Win : Window) return C_Int;
pragma Import (C, Redrawwin, "redrawwin");
begin
if Redrawwin (Win) = Curses_Err then
raise Curses_Exception;
end if;
end Redraw;
procedure Redraw
(Win : in Window := Standard_Window;
Begin_Line : in Line_Position;
Line_Count : in Positive)
is
function Wredrawln (Win : Window; First : C_Int; Cnt : C_Int)
return C_Int;
pragma Import (C, Wredrawln, "wredrawln");
begin
if Wredrawln (Win,
C_Int (Begin_Line),
C_Int (Line_Count)) = Curses_Err then
raise Curses_Exception;
end if;
end Redraw;
------------------------------------------------------------------------------
procedure Erase (Win : in Window := Standard_Window)
is
function Werase (W : Window) return C_Int;
pragma Import (C, Werase, "werase");
begin
if Werase (Win) = Curses_Err then
raise Curses_Exception;
end if;
end Erase;
procedure Clear (Win : in Window := Standard_Window)
is
function Wclear (W : Window) return C_Int;
pragma Import (C, Wclear, "wclear");
begin
if Wclear (Win) = Curses_Err then
raise Curses_Exception;
end if;
end Clear;
procedure Clear_To_End_Of_Screen (Win : in Window := Standard_Window)
is
function Wclearbot (W : Window) return C_Int;
pragma Import (C, Wclearbot, "wclrtobot");
begin
if Wclearbot (Win) = Curses_Err then
raise Curses_Exception;
end if;
end Clear_To_End_Of_Screen;
procedure Clear_To_End_Of_Line (Win : in Window := Standard_Window)
is
function Wcleareol (W : Window) return C_Int;
pragma Import (C, Wcleareol, "wclrtoeol");
begin
if Wcleareol (Win) = Curses_Err then
raise Curses_Exception;
end if;
end Clear_To_End_Of_Line;
------------------------------------------------------------------------------
procedure Set_Background
(Win : in Window := Standard_Window;
Ch : in Attributed_Character)
is
procedure WBackground (W : in Window; Ch : in C_Int);
pragma Import (C, WBackground, "wbkgdset");
begin
WBackground (Win, Chtype_To_CInt (Ch));
end Set_Background;
procedure Change_Background
(Win : in Window := Standard_Window;
Ch : in Attributed_Character)
is
function WChangeBkgd (W : Window; Ch : C_Int)
return C_Int;
pragma Import (C, WChangeBkgd, "wbkgd");
begin
if WChangeBkgd (Win, Chtype_To_CInt (Ch)) = Curses_Err then
raise Curses_Exception;
end if;
end Change_Background;
function Get_Background (Win : Window := Standard_Window)
return Attributed_Character
is
function Wgetbkgd (Win : Window) return C_Int;
pragma Import (C, Wgetbkgd, "getbkgd");
begin
return CInt_To_Chtype (Wgetbkgd (Win));
end Get_Background;
------------------------------------------------------------------------------
procedure Change_Lines_Status (Win : in Window := Standard_Window;
Start : in Line_Position;
Count : in Positive;
State : in Boolean)
is
function Wtouchln (Win : Window;
Sta : C_Int;
Cnt : C_Int;
Chg : C_Int) return C_Int;
pragma Import (C, Wtouchln, "wtouchln");
begin
if Wtouchln (Win, C_Int (Start), C_Int (Count),
C_Int (Boolean'Pos (State))) = Curses_Err then
raise Curses_Exception;
end if;
end Change_Lines_Status;
procedure Touch (Win : in Window := Standard_Window)
is
Y : Line_Position;
X : Column_Position;
begin
Get_Size (Win, Y, X);
Change_Lines_Status (Win, 0, Positive (Y), True);
end Touch;
procedure Untouch (Win : in Window := Standard_Window)
is
Y : Line_Position;
X : Column_Position;
begin
Get_Size (Win, Y, X);
Change_Lines_Status (Win, 0, Positive (Y), False);
end Untouch;
procedure Touch (Win : in Window := Standard_Window;
Start : in Line_Position;
Count : in Positive)
is
begin
Change_Lines_Status (Win, Start, Count, True);
end Touch;
function Is_Touched
(Win : Window := Standard_Window;
Line : Line_Position) return Boolean
is
function WLineTouched (W : Window; L : C_Int) return C_Int;
pragma Import (C, WLineTouched, "is_linetouched");
begin
if WLineTouched (Win, C_Int (Line)) = Curses_False then
return False;
else
return True;
end if;
end Is_Touched;
function Is_Touched
(Win : Window := Standard_Window) return Boolean
is
function WWinTouched (W : Window) return C_Int;
pragma Import (C, WWinTouched, "is_wintouched");
begin
if WWinTouched (Win) = Curses_False then
return False;
else
return True;
end if;
end Is_Touched;
------------------------------------------------------------------------------
procedure Copy
(Source_Window : in Window;
Destination_Window : in Window;
Source_Top_Row : in Line_Position;
Source_Left_Column : in Column_Position;
Destination_Top_Row : in Line_Position;
Destination_Left_Column : in Column_Position;
Destination_Bottom_Row : in Line_Position;
Destination_Right_Column : in Column_Position;
Non_Destructive_Mode : in Boolean := True)
is
function Copywin (Src : Window;
Dst : Window;
Str : C_Int;
Slc : C_Int;
Dtr : C_Int;
Dlc : C_Int;
Dbr : C_Int;
Drc : C_Int;
Ndm : C_Int) return C_Int;
pragma Import (C, Copywin, "copywin");
begin
if Copywin (Source_Window,
Destination_Window,
C_Int (Source_Top_Row),
C_Int (Source_Left_Column),
C_Int (Destination_Top_Row),
C_Int (Destination_Left_Column),
C_Int (Destination_Bottom_Row),
C_Int (Destination_Right_Column),
Boolean'Pos (Non_Destructive_Mode)
) = Curses_Err then
raise Curses_Exception;
end if;
end Copy;
procedure Overwrite
(Source_Window : in Window;
Destination_Window : in Window)
is
function Overwrite (Src : Window; Dst : Window) return C_Int;
pragma Import (C, Overwrite, "overwrite");
begin
if Overwrite (Source_Window, Destination_Window) = Curses_Err then
raise Curses_Exception;
end if;
end Overwrite;
procedure Overlay
(Source_Window : in Window;
Destination_Window : in Window)
is
function Overlay (Src : Window; Dst : Window) return C_Int;
pragma Import (C, Overlay, "overlay");
begin
if Overlay (Source_Window, Destination_Window) = Curses_Err then
raise Curses_Exception;
end if;
end Overlay;
------------------------------------------------------------------------------
procedure Insert_Delete_Lines
(Win : in Window := Standard_Window;
Lines : in Integer := 1) -- default is to insert one line above
is
function Winsdelln (W : Window; N : C_Int) return C_Int;
pragma Import (C, Winsdelln, "winsdelln");
begin
if Winsdelln (Win, C_Int (Lines)) = Curses_Err then
raise Curses_Exception;
end if;
end Insert_Delete_Lines;
procedure Delete_Line (Win : in Window := Standard_Window)
is
begin
Insert_Delete_Lines (Win, -1);
end Delete_Line;
procedure Insert_Line (Win : in Window := Standard_Window)
is
begin
Insert_Delete_Lines (Win, 1);
end Insert_Line;
------------------------------------------------------------------------------
procedure Get_Size
(Win : in Window := Standard_Window;
Number_Of_Lines : out Line_Count;
Number_Of_Columns : out Column_Count)
is
type Int_Access is access all C_Int;
function Getmaxyx (W : Window; Y, X : Int_Access) return C_Int;
pragma Import (C, Getmaxyx, "_nc_ada_getmaxyx");
Y, X : aliased C_Int;
Err : constant C_Int := Getmaxyx (Win, Y'Access, X'Access);
begin
if Err = Curses_Err then
raise Curses_Exception;
else
Number_Of_Lines := Line_Count (Y);
Number_Of_Columns := Column_Count (X);
end if;
end Get_Size;
procedure Get_Window_Position
(Win : in Window := Standard_Window;
Top_Left_Line : out Line_Position;
Top_Left_Column : out Column_Position)
is
type Int_Access is access all C_Int;
function Getbegyx (W : Window; Y, X : Int_Access) return C_Int;
pragma Import (C, Getbegyx, "_nc_ada_getbegyx");
Y, X : aliased C_Int;
Err : constant C_Int := Getbegyx (Win, Y'Access, X'Access);
begin
if Err = Curses_Err then
raise Curses_Exception;
else
Top_Left_Line := Line_Position (Y);
Top_Left_Column := Column_Position (X);
end if;
end Get_Window_Position;
procedure Get_Cursor_Position
(Win : in Window := Standard_Window;
Line : out Line_Position;
Column : out Column_Position)
is
type Int_Access is access all C_Int;
function Getyx (W : Window; Y, X : Int_Access) return C_Int;
pragma Import (C, Getyx, "_nc_ada_getyx");
Y, X : aliased C_Int;
Err : constant C_Int := Getyx (Win, Y'Access, X'Access);
begin
if Err = Curses_Err then
raise Curses_Exception;
else
Line := Line_Position (Y);
Column := Column_Position (X);
end if;
end Get_Cursor_Position;
procedure Get_Origin_Relative_To_Parent
(Win : in Window;
Top_Left_Line : out Line_Position;
Top_Left_Column : out Column_Position;
Is_Not_A_Subwindow : out Boolean)
is
type Int_Access is access all C_Int;
function Getparyx (W : Window; Y, X : Int_Access) return C_Int;
pragma Import (C, Getparyx, "_nc_ada_getparyx");
Y, X : aliased C_Int;
Err : constant C_Int := Getparyx (Win, Y'Access, X'Access);
begin
if Err = Curses_Err then
raise Curses_Exception;
else
if Y = -1 then
Top_Left_Line := Line_Position'Last;
Top_Left_Column := Column_Position'Last;
Is_Not_A_Subwindow := True;
else
Top_Left_Line := Line_Position (Y);
Top_Left_Column := Column_Position (X);
Is_Not_A_Subwindow := False;
end if;
end if;
end Get_Origin_Relative_To_Parent;
------------------------------------------------------------------------------
function New_Pad (Lines : Line_Count;
Columns : Column_Count) return Window
is
function Newpad (Lines : C_Int; Columns : C_Int) return Window;
pragma Import (C, Newpad, "newpad");
W : Window;
begin
W := Newpad (C_Int (Lines), C_Int (Columns));
if W = Null_Window then
raise Curses_Exception;
end if;
return W;
end New_Pad;
function Sub_Pad
(Pad : Window;
Number_Of_Lines : Line_Count;
Number_Of_Columns : Column_Count;
First_Line_Position : Line_Position;
First_Column_Position : Column_Position) return Window
is
function Subpad
(Pad : Window;
Number_Of_Lines : C_Int;
Number_Of_Columns : C_Int;
First_Line_Position : C_Int;
First_Column_Position : C_Int) return Window;
pragma Import (C, Subpad, "subpad");
W : Window;
begin
W := Subpad (Pad,
C_Int (Number_Of_Lines),
C_Int (Number_Of_Columns),
C_Int (First_Line_Position),
C_Int (First_Column_Position));
if W = Null_Window then
raise Curses_Exception;
end if;
return W;
end Sub_Pad;
procedure Refresh
(Pad : in Window;
Source_Top_Row : in Line_Position;
Source_Left_Column : in Column_Position;
Destination_Top_Row : in Line_Position;
Destination_Left_Column : in Column_Position;
Destination_Bottom_Row : in Line_Position;
Destination_Right_Column : in Column_Position)
is
function Prefresh
(Pad : Window;
Source_Top_Row : C_Int;
Source_Left_Column : C_Int;
Destination_Top_Row : C_Int;
Destination_Left_Column : C_Int;
Destination_Bottom_Row : C_Int;
Destination_Right_Column : C_Int) return C_Int;
pragma Import (C, Prefresh, "prefresh");
begin
if Prefresh (Pad,
C_Int (Source_Top_Row),
C_Int (Source_Left_Column),
C_Int (Destination_Top_Row),
C_Int (Destination_Left_Column),
C_Int (Destination_Bottom_Row),
C_Int (Destination_Right_Column)) = Curses_Err then
raise Curses_Exception;
end if;
end Refresh;
procedure Refresh_Without_Update
(Pad : in Window;
Source_Top_Row : in Line_Position;
Source_Left_Column : in Column_Position;
Destination_Top_Row : in Line_Position;
Destination_Left_Column : in Column_Position;
Destination_Bottom_Row : in Line_Position;
Destination_Right_Column : in Column_Position)
is
function Pnoutrefresh
(Pad : Window;
Source_Top_Row : C_Int;
Source_Left_Column : C_Int;
Destination_Top_Row : C_Int;
Destination_Left_Column : C_Int;
Destination_Bottom_Row : C_Int;
Destination_Right_Column : C_Int) return C_Int;
pragma Import (C, Pnoutrefresh, "pnoutrefresh");
begin
if Pnoutrefresh (Pad,
C_Int (Source_Top_Row),
C_Int (Source_Left_Column),
C_Int (Destination_Top_Row),
C_Int (Destination_Left_Column),
C_Int (Destination_Bottom_Row),
C_Int (Destination_Right_Column)) = Curses_Err then
raise Curses_Exception;
end if;
end Refresh_Without_Update;
procedure Add_Character_To_Pad_And_Echo_It
(Pad : in Window;
Ch : in Attributed_Character)
is
function Pechochar (Pad : Window; Ch : C_Int)
return C_Int;
pragma Import (C, Pechochar, "pechochar");
begin
if Pechochar (Pad, Chtype_To_CInt (Ch)) = Curses_Err then
raise Curses_Exception;
end if;
end Add_Character_To_Pad_And_Echo_It;
procedure Add_Character_To_Pad_And_Echo_It
(Pad : in Window;
Ch : in Character)
is
begin
Add_Character_To_Pad_And_Echo_It
(Pad,
Attributed_Character'(Ch => Ch,
Color => Color_Pair'First,
Attr => Normal_Video));
end Add_Character_To_Pad_And_Echo_It;
------------------------------------------------------------------------------
procedure Scroll (Win : in Window := Standard_Window;
Amount : in Integer := 1)
is
function Wscrl (Win : Window; N : C_Int) return C_Int;
pragma Import (C, Wscrl, "wscrl");
begin
if Wscrl (Win, C_Int (Amount)) = Curses_Err then
raise Curses_Exception;
end if;
end Scroll;
------------------------------------------------------------------------------
procedure Delete_Character (Win : in Window := Standard_Window)
is
function Wdelch (Win : Window) return C_Int;
pragma Import (C, Wdelch, "wdelch");
begin
if Wdelch (Win) = Curses_Err then
raise Curses_Exception;
end if;
end Delete_Character;
procedure Delete_Character
(Win : in Window := Standard_Window;
Line : in Line_Position;
Column : in Column_Position)
is
function Mvwdelch (Win : Window;
Lin : C_Int;
Col : C_Int) return C_Int;
pragma Import (C, Mvwdelch, "mvwdelch");
begin
if Mvwdelch (Win, C_Int (Line), C_Int (Column)) = Curses_Err then
raise Curses_Exception;
end if;
end Delete_Character;
------------------------------------------------------------------------------
function Peek (Win : Window := Standard_Window)
return Attributed_Character
is
function Winch (Win : Window) return C_Int;
pragma Import (C, Winch, "winch");
begin
return CInt_To_Chtype (Winch (Win));
end Peek;
function Peek
(Win : Window := Standard_Window;
Line : Line_Position;
Column : Column_Position) return Attributed_Character
is
function Mvwinch (Win : Window;
Lin : C_Int;
Col : C_Int) return C_Int;
pragma Import (C, Mvwinch, "mvwinch");
begin
return CInt_To_Chtype (Mvwinch (Win, C_Int (Line), C_Int (Column)));
end Peek;
------------------------------------------------------------------------------
procedure Insert (Win : in Window := Standard_Window;
Ch : in Attributed_Character)
is
function Winsch (Win : Window; Ch : C_Int) return C_Int;
pragma Import (C, Winsch, "winsch");
begin
if Winsch (Win, Chtype_To_CInt (Ch)) = Curses_Err then
raise Curses_Exception;
end if;
end Insert;
procedure Insert
(Win : in Window := Standard_Window;
Line : in Line_Position;
Column : in Column_Position;
Ch : in Attributed_Character)
is
function Mvwinsch (Win : Window;
Lin : C_Int;
Col : C_Int;
Ch : C_Int) return C_Int;
pragma Import (C, Mvwinsch, "mvwinsch");
begin
if Mvwinsch (Win,
C_Int (Line),
C_Int (Column),
Chtype_To_CInt (Ch)) = Curses_Err then
raise Curses_Exception;
end if;
end Insert;
------------------------------------------------------------------------------
procedure Insert (Win : in Window := Standard_Window;
Str : in String;
Len : in Integer := -1)
is
type Char_Ptr is access all Interfaces.C.Char;
function Winsnstr (Win : Window;
Str : Char_Ptr;
Len : Integer := -1) return C_Int;
pragma Import (C, Winsnstr, "winsnstr");
Txt : char_array (0 .. Str'Length);
Length : size_t;
begin
To_C (Str, Txt, Length);
if Winsnstr (Win, Txt (Txt'First)'Access, Len) = Curses_Err then
raise Curses_Exception;
end if;
end Insert;
procedure Insert
(Win : in Window := Standard_Window;
Line : in Line_Position;
Column : in Column_Position;
Str : in String;
Len : in Integer := -1)
is
type Char_Ptr is access all Interfaces.C.Char;
function Mvwinsnstr (Win : Window;
Line : C_Int;
Column : C_Int;
Str : Char_Ptr;
Len : C_Int) return C_Int;
pragma Import (C, Mvwinsnstr, "mvwinsnstr");
Txt : char_array (0 .. Str'Length);
Length : size_t;
begin
To_C (Str, Txt, Length);
if Mvwinsnstr (Win, C_Int (Line), C_Int (Column),
Txt (Txt'First)'Access, C_Int (Len))
= Curses_Err then
raise Curses_Exception;
end if;
end Insert;
------------------------------------------------------------------------------
procedure Peek (Win : in Window := Standard_Window;
Str : out String;
Len : in Integer := -1)
is
function Winnstr (Win : Window;
Str : char_array;
Len : C_Int) return C_Int;
pragma Import (C, Winnstr, "winnstr");
N : Integer := Len;
Txt : char_array (0 .. Str'Length);
Cnt : Natural;
begin
if N < 0 then
N := Str'Length;
end if;
if N > Str'Length then
raise Constraint_Error;
end if;
Txt (0) := Interfaces.C.char'First;
if Winnstr (Win, Txt, C_Int (N)) = Curses_Err then
raise Curses_Exception;
end if;
To_Ada (Txt, Str, Cnt, True);
if Cnt < Str'Length then
Str ((Str'First + Cnt) .. Str'Last) := (others => ' ');
end if;
end Peek;
procedure Peek
(Win : in Window := Standard_Window;
Line : in Line_Position;
Column : in Column_Position;
Str : out String;
Len : in Integer := -1)
is
begin
Move_Cursor (Win, Line, Column);
Peek (Win, Str, Len);
end Peek;
------------------------------------------------------------------------------
procedure Peek
(Win : in Window := Standard_Window;
Str : out Attributed_String;
Len : in Integer := -1)
is
type Chtype_Ptr is access all Attributed_Character;
function Winchnstr (Win : Window;
Str : Chtype_Ptr;
Len : C_Int) return C_Int;
pragma Import (C, Winchnstr, "winchnstr");
N : Integer := Len;
Txt : chtype_array (0 .. Str'Length);
Cnt : Natural := 0;
begin
if N < 0 then
N := Str'Length;
end if;
if N > Str'Length then
raise Constraint_Error;
end if;
if Winchnstr (Win, Txt (Txt'First)'Access, C_Int (N)) = Curses_Err then
raise Curses_Exception;
end if;
for To in Str'Range loop
exit when Txt (size_t (Cnt)) = Default_Character;
Str (To) := Txt (size_t (Cnt));
Cnt := Cnt + 1;
end loop;
if Cnt < Str'Length then
Str ((Str'First + Cnt) .. Str'Last) :=
(others => (Ch => ' ',
Color => Color_Pair'First,
Attr => Normal_Video));
end if;
end Peek;
procedure Peek
(Win : in Window := Standard_Window;
Line : in Line_Position;
Column : in Column_Position;
Str : out Attributed_String;
Len : in Integer := -1)
is
begin
Move_Cursor (Win, Line, Column);
Peek (Win, Str, Len);
end Peek;
------------------------------------------------------------------------------
procedure Get (Win : in Window := Standard_Window;
Str : out String;
Len : in Integer := -1)
is
function Wgetnstr (Win : Window;
Str : char_array;
Len : C_Int) return C_Int;
pragma Import (C, Wgetnstr, "wgetnstr");
N : Integer := Len;
Txt : char_array (0 .. Str'Length);
Cnt : Natural;
begin
if N < 0 then
N := Str'Length;
end if;
if N > Str'Length then
raise Constraint_Error;
end if;
Txt (0) := Interfaces.C.char'First;
if Wgetnstr (Win, Txt, C_Int (N)) = Curses_Err then
raise Curses_Exception;
end if;
To_Ada (Txt, Str, Cnt, True);
if Cnt < Str'Length then
Str ((Str'First + Cnt) .. Str'Last) := (others => ' ');
end if;
end Get;
procedure Get
(Win : in Window := Standard_Window;
Line : in Line_Position;
Column : in Column_Position;
Str : out String;
Len : in Integer := -1)
is
begin
Move_Cursor (Win, Line, Column);
Get (Win, Str, Len);
end Get;
------------------------------------------------------------------------------
procedure Init_Soft_Label_Keys
(Format : in Soft_Label_Key_Format := Three_Two_Three)
is
function Slk_Init (Fmt : C_Int) return C_Int;
pragma Import (C, Slk_Init, "slk_init");
begin
if Slk_Init (Soft_Label_Key_Format'Pos (Format)) = Curses_Err then
raise Curses_Exception;
end if;
end Init_Soft_Label_Keys;
procedure Set_Soft_Label_Key (Label : in Label_Number;
Text : in String;
Fmt : in Label_Justification := Left)
is
type Char_Ptr is access all Interfaces.C.Char;
function Slk_Set (Label : C_Int;
Txt : Char_Ptr;
Fmt : C_Int) return C_Int;
pragma Import (C, Slk_Set, "slk_set");
Txt : char_array (0 .. Text'Length);
Len : size_t;
begin
To_C (Text, Txt, Len);
if Slk_Set (C_Int (Label),
Txt (Txt'First)'Access,
C_Int (Label_Justification'Pos (Fmt)))
= Curses_Err then
raise Curses_Exception;
end if;
end Set_Soft_Label_Key;
procedure Refresh_Soft_Label_Keys
is
function Slk_Refresh return C_Int;
pragma Import (C, Slk_Refresh, "slk_refresh");
begin
if Slk_Refresh = Curses_Err then
raise Curses_Exception;
end if;
end Refresh_Soft_Label_Keys;
procedure Refresh_Soft_Label_Keys_Without_Update
is
function Slk_Noutrefresh return C_Int;
pragma Import (C, Slk_Noutrefresh, "slk_noutrefresh");
begin
if Slk_Noutrefresh = Curses_Err then
raise Curses_Exception;
end if;
end Refresh_Soft_Label_Keys_Without_Update;
procedure Get_Soft_Label_Key (Label : in Label_Number;
Text : out String)
is
function Slk_Label (Label : C_Int) return chars_ptr;
pragma Import (C, Slk_Label, "slk_label");
begin
Fill_String (Slk_Label (C_Int (Label)), Text);
end Get_Soft_Label_Key;
function Get_Soft_Label_Key (Label : in Label_Number) return String
is
function Slk_Label (Label : C_Int) return chars_ptr;
pragma Import (C, Slk_Label, "slk_label");
begin
return Fill_String (Slk_Label (C_Int (Label)));
end Get_Soft_Label_Key;
procedure Clear_Soft_Label_Keys
is
function Slk_Clear return C_Int;
pragma Import (C, Slk_Clear, "slk_clear");
begin
if Slk_Clear = Curses_Err then
raise Curses_Exception;
end if;
end Clear_Soft_Label_Keys;
procedure Restore_Soft_Label_Keys
is
function Slk_Restore return C_Int;
pragma Import (C, Slk_Restore, "slk_restore");
begin
if Slk_Restore = Curses_Err then
raise Curses_Exception;
end if;
end Restore_Soft_Label_Keys;
procedure Touch_Soft_Label_Keys
is
function Slk_Touch return C_Int;
pragma Import (C, Slk_Touch, "slk_touch");
begin
if Slk_Touch = Curses_Err then
raise Curses_Exception;
end if;
end Touch_Soft_Label_Keys;
procedure Switch_Soft_Label_Key_Attributes
(Attr : in Character_Attribute_Set;
On : in Boolean := True)
is
function Slk_Attron (Ch : C_Int) return C_Int;
pragma Import (C, Slk_Attron, "slk_attron");
function Slk_Attroff (Ch : C_Int) return C_Int;
pragma Import (C, Slk_Attroff, "slk_attroff");
Err : C_Int;
Ch : constant Attributed_Character := (Ch => Character'First,
Attr => Attr,
Color => Color_Pair'First);
begin
if On then
Err := Slk_Attron (Chtype_To_CInt (Ch));
else
Err := Slk_Attroff (Chtype_To_CInt (Ch));
end if;
if Err = Curses_Err then
raise Curses_Exception;
end if;
end Switch_Soft_Label_Key_Attributes;
procedure Set_Soft_Label_Key_Attributes
(Attr : in Character_Attribute_Set := Normal_Video;
Color : in Color_Pair := Color_Pair'First)
is
function Slk_Attrset (Ch : C_Int) return C_Int;
pragma Import (C, Slk_Attrset, "slk_attrset");
Ch : constant Attributed_Character := (Ch => Character'First,
Attr => Attr,
Color => Color);
begin
if Slk_Attrset (Chtype_To_CInt (Ch)) = Curses_Err then
raise Curses_Exception;
end if;
end Set_Soft_Label_Key_Attributes;
function Get_Soft_Label_Key_Attributes return Character_Attribute_Set
is
function Slk_Attr return C_Int;
pragma Import (C, Slk_Attr, "slk_attr");
Attr : constant C_Int := Slk_Attr;
begin
return CInt_To_Chtype (Attr).Attr;
end Get_Soft_Label_Key_Attributes;
function Get_Soft_Label_Key_Attributes return Color_Pair
is
function Slk_Attr return C_Int;
pragma Import (C, Slk_Attr, "slk_attr");
Attr : constant C_Int := Slk_Attr;
begin
return CInt_To_Chtype (Attr).Color;
end Get_Soft_Label_Key_Attributes;
------------------------------------------------------------------------------
procedure Enable_Key (Key : in Special_Key_Code;
Enable : in Boolean := True)
is
function Keyok (Keycode : C_Int;
On_Off : C_Int) return C_Int;
pragma Import (C, Keyok, "keyok");
begin
if Keyok (C_Int (Key), Boolean'Pos (Enable)) = Curses_Err then
raise Curses_Exception;
end if;
end Enable_Key;
------------------------------------------------------------------------------
procedure Define_Key (Definition : in String;
Key : in Special_Key_Code)
is
type Char_Ptr is access all Interfaces.C.Char;
function Defkey (Def : Char_Ptr;
Key : C_Int) return C_Int;
pragma Import (C, Defkey, "define_key");
Txt : char_array (0 .. Definition'Length);
Length : size_t;
begin
To_C (Definition, Txt, Length);
if Defkey (Txt (Txt'First)'Access, C_Int (Key)) = Curses_Err then
raise Curses_Exception;
end if;
end Define_Key;
------------------------------------------------------------------------------
procedure Un_Control (Ch : in Attributed_Character;
Str : out String)
is
function Unctrl (Ch : C_Int) return chars_ptr;
pragma Import (C, Unctrl, "unctrl");
begin
Fill_String (Unctrl (Chtype_To_CInt (Ch)), Str);
end Un_Control;
function Un_Control (Ch : in Attributed_Character) return String
is
function Unctrl (Ch : C_Int) return chars_ptr;
pragma Import (C, Unctrl, "unctrl");
begin
return Fill_String (Unctrl (Chtype_To_CInt (Ch)));
end Un_Control;
procedure Delay_Output (Msecs : in Natural)
is
function Delayoutput (Msecs : C_Int) return C_Int;
pragma Import (C, Delayoutput, "delay_output");
begin
if Delayoutput (C_Int (Msecs)) = Curses_Err then
raise Curses_Exception;
end if;
end Delay_Output;
procedure Flush_Input
is
function Flushinp return C_Int;
pragma Import (C, Flushinp, "flushinp");
begin
if Flushinp = Curses_Err then -- docu says that never happens, but...
raise Curses_Exception;
end if;
end Flush_Input;
------------------------------------------------------------------------------
function Baudrate return Natural
is
function Baud return C_Int;
pragma Import (C, Baud, "baudrate");
begin
return Natural (Baud);
end Baudrate;
function Erase_Character return Character
is
function Erasechar return C_Int;
pragma Import (C, Erasechar, "erasechar");
begin
return Character'Val (Erasechar);
end Erase_Character;
function Kill_Character return Character
is
function Killchar return C_Int;
pragma Import (C, Killchar, "killchar");
begin
return Character'Val (Killchar);
end Kill_Character;
function Has_Insert_Character return Boolean
is
function Has_Ic return C_Int;
pragma Import (C, Has_Ic, "has_ic");
begin
if Has_Ic = Curses_False then
return False;
else
return True;
end if;
end Has_Insert_Character;
function Has_Insert_Line return Boolean
is
function Has_Il return C_Int;
pragma Import (C, Has_Il, "has_il");
begin
if Has_Il = Curses_False then
return False;
else
return True;
end if;
end Has_Insert_Line;
function Supported_Attributes return Character_Attribute_Set
is
function Termattrs return C_Int;
pragma Import (C, Termattrs, "termattrs");
Ch : constant Attributed_Character := CInt_To_Chtype (Termattrs);
begin
return Ch.Attr;
end Supported_Attributes;
procedure Long_Name (Name : out String)
is
function Longname return chars_ptr;
pragma Import (C, Longname, "longname");
begin
Fill_String (Longname, Name);
end Long_Name;
function Long_Name return String
is
function Longname return chars_ptr;
pragma Import (C, Longname, "longname");
begin
return Fill_String (Longname);
end Long_Name;
procedure Terminal_Name (Name : out String)
is
function Termname return chars_ptr;
pragma Import (C, Termname, "termname");
begin
Fill_String (Termname, Name);
end Terminal_Name;
function Terminal_Name return String
is
function Termname return chars_ptr;
pragma Import (C, Termname, "termname");
begin
return Fill_String (Termname);
end Terminal_Name;
------------------------------------------------------------------------------
procedure Init_Pair (Pair : in Redefinable_Color_Pair;
Fore : in Color_Number;
Back : in Color_Number)
is
function Initpair (Pair : C_Short;
Fore : C_Short;
Back : C_Short) return C_Int;
pragma Import (C, Initpair, "init_pair");
begin
if Integer (Pair) >= Number_Of_Color_Pairs then
raise Constraint_Error;
end if;
if Integer (Fore) >= Number_Of_Colors or else
Integer (Back) >= Number_Of_Colors then raise Constraint_Error;
end if;
if Initpair (C_Short (Pair), C_Short (Fore), C_Short (Back))
= Curses_Err then
raise Curses_Exception;
end if;
end Init_Pair;
procedure Pair_Content (Pair : in Color_Pair;
Fore : out Color_Number;
Back : out Color_Number)
is
type C_Short_Access is access all C_Short;
function Paircontent (Pair : C_Short;
Fp : C_Short_Access;
Bp : C_Short_Access) return C_Int;
pragma Import (C, Paircontent, "pair_content");
F, B : aliased C_Short;
begin
if Paircontent (C_Short (Pair), F'Access, B'Access) = Curses_Err then
raise Curses_Exception;
else
Fore := Color_Number (F);
Back := Color_Number (B);
end if;
end Pair_Content;
function Has_Colors return Boolean
is
function Hascolors return C_Int;
pragma Import (C, Hascolors, "has_colors");
begin
if Hascolors = Curses_False then
return False;
else
return True;
end if;
end Has_Colors;
procedure Init_Color (Color : in Color_Number;
Red : in RGB_Value;
Green : in RGB_Value;
Blue : in RGB_Value)
is
function Initcolor (Col : C_Short;
Red : C_Short;
Green : C_Short;
Blue : C_Short) return C_Int;
pragma Import (C, Initcolor, "init_color");
begin
if Initcolor (C_Short (Color), C_Short (Red), C_Short (Green),
C_Short (Blue)) = Curses_Err then
raise Curses_Exception;
end if;
end Init_Color;
function Can_Change_Color return Boolean
is
function Canchangecolor return C_Int;
pragma Import (C, Canchangecolor, "can_change_color");
begin
if Canchangecolor = Curses_False then
return False;
else
return True;
end if;
end Can_Change_Color;
procedure Color_Content (Color : in Color_Number;
Red : out RGB_Value;
Green : out RGB_Value;
Blue : out RGB_Value)
is
type C_Short_Access is access all C_Short;
function Colorcontent (Color : C_Short; R, G, B : C_Short_Access)
return C_Int;
pragma Import (C, Colorcontent, "color_content");
R, G, B : aliased C_Short;
begin
if Colorcontent (C_Short (Color), R'Access, G'Access, B'Access) =
Curses_Err then
raise Curses_Exception;
else
Red := RGB_Value (R);
Green := RGB_Value (G);
Blue := RGB_Value (B);
end if;
end Color_Content;
------------------------------------------------------------------------------
procedure Save_Curses_Mode (Mode : in Curses_Mode)
is
function Def_Prog_Mode return C_Int;
pragma Import (C, Def_Prog_Mode, "def_prog_mode");
function Def_Shell_Mode return C_Int;
pragma Import (C, Def_Shell_Mode, "def_shell_mode");
Err : C_Int;
begin
case Mode is
when Curses => Err := Def_Prog_Mode;
when Shell => Err := Def_Shell_Mode;
end case;
if Err = Curses_Err then
raise Curses_Exception;
end if;
end Save_Curses_Mode;
procedure Reset_Curses_Mode (Mode : in Curses_Mode)
is
function Reset_Prog_Mode return C_Int;
pragma Import (C, Reset_Prog_Mode, "reset_prog_mode");
function Reset_Shell_Mode return C_Int;
pragma Import (C, Reset_Shell_Mode, "reset_shell_mode");
Err : C_Int;
begin
case Mode is
when Curses => Err := Reset_Prog_Mode;
when Shell => Err := Reset_Shell_Mode;
end case;
if Err = Curses_Err then
raise Curses_Exception;
end if;
end Reset_Curses_Mode;
procedure Save_Terminal_State
is
function Savetty return C_Int;
pragma Import (C, Savetty, "savetty");
begin
if Savetty = Curses_Err then
raise Curses_Exception;
end if;
end Save_Terminal_State;
procedure Reset_Terminal_State
is
function Resetty return C_Int;
pragma Import (C, Resetty, "resetty");
begin
if Resetty = Curses_Err then
raise Curses_Exception;
end if;
end Reset_Terminal_State;
procedure Rip_Off_Lines (Lines : in Integer;
Proc : in Stdscr_Init_Proc)
is
function Ripoffline (Lines : C_Int;
Proc : Stdscr_Init_Proc) return C_Int;
pragma Import (C, Ripoffline, "_nc_ripoffline");
begin
if Ripoffline (C_Int (Lines), Proc) = Curses_Err then
raise Curses_Exception;
end if;
end Rip_Off_Lines;
procedure Set_Cursor_Visibility (Visibility : in out Cursor_Visibility)
is
function Curs_Set (Curs : C_Int) return C_Int;
pragma Import (C, Curs_Set, "curs_set");
Res : C_Int;
begin
Res := Curs_Set (Cursor_Visibility'Pos (Visibility));
if Res /= Curses_Err then
Visibility := Cursor_Visibility'Val (Res);
end if;
end Set_Cursor_Visibility;
procedure Nap_Milli_Seconds (Ms : in Natural)
is
function Napms (Ms : C_Int) return C_Int;
pragma Import (C, Napms, "napms");
begin
if Napms (C_Int (Ms)) = Curses_Err then
raise Curses_Exception;
end if;
end Nap_Milli_Seconds;
------------------------------------------------------------------------------
function Standard_Window return Window
is
Stdscr : Window;
pragma Import (C, Stdscr, "stdscr");
begin
return Stdscr;
end Standard_Window;
function Lines return Line_Count
is
C_Lines : C_Int;
pragma Import (C, C_Lines, "LINES");
begin
return Line_Count (C_Lines);
end Lines;
function Columns return Column_Count
is
C_Columns : C_Int;
pragma Import (C, C_Columns, "COLS");
begin
return Column_Count (C_Columns);
end Columns;
function Tab_Size return Natural
is
C_Tab_Size : C_Int;
pragma Import (C, C_Tab_Size, "TABSIZE");
begin
return Natural (C_Tab_Size);
end Tab_Size;
function Number_Of_Colors return Natural
is
C_Number_Of_Colors : C_Int;
pragma Import (C, C_Number_Of_Colors, "COLORS");
begin
return Natural (C_Number_Of_Colors);
end Number_Of_Colors;
function Number_Of_Color_Pairs return Natural
is
C_Number_Of_Color_Pairs : C_Int;
pragma Import (C, C_Number_Of_Color_Pairs, "COLOR_PAIRS");
begin
return Natural (C_Number_Of_Color_Pairs);
end Number_Of_Color_Pairs;
------------------------------------------------------------------------------
procedure Transform_Coordinates
(W : in Window := Standard_Window;
Line : in out Line_Position;
Column : in out Column_Position;
Dir : in Transform_Direction := From_Screen)
is
type Int_Access is access all C_Int;
function Transform (W : Window;
Y, X : Int_Access;
Dir : C_Int) return C_Int;
pragma Import (C, Transform, "_nc_ada_coord_transform");
X : aliased C_Int := C_Int (Column);
Y : aliased C_Int := C_Int (Line);
D : C_Int := 0;
R : C_Int;
begin
if Dir = To_Screen then
D := 1;
end if;
R := Transform (W, Y'Access, X'Access, D);
if R = Curses_False then
raise Curses_Exception;
else
Line := Line_Position (Y);
Column := Column_Position (X);
end if;
end Transform_Coordinates;
end Terminal_Interface.Curses;
|
reznikmm/matreshka | Ada | 4,783 | ads | ------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- Open Document Toolkit --
-- --
-- Runtime Library Component --
-- --
------------------------------------------------------------------------------
-- --
-- Copyright © 2014, Vadim Godunko <[email protected]> --
-- All rights reserved. --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions --
-- are met: --
-- --
-- * Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- --
-- * Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in the --
-- documentation and/or other materials provided with the distribution. --
-- --
-- * Neither the name of the Vadim Godunko, IE nor the names of its --
-- contributors may be used to endorse or promote products derived from --
-- this software without specific prior written permission. --
-- --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR --
-- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
-- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED --
-- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR --
-- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF --
-- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING --
-- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS --
-- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
-- --
------------------------------------------------------------------------------
-- $Revision$ $Date$
------------------------------------------------------------------------------
with XML.DOM.Visitors;
with ODF.DOM.Text_Index_Entry_Span_Elements;
package Matreshka.ODF_Text.Index_Entry_Span_Elements is
type Text_Index_Entry_Span_Element_Node is
new Matreshka.ODF_Text.Abstract_Text_Element_Node
and ODF.DOM.Text_Index_Entry_Span_Elements.ODF_Text_Index_Entry_Span
with null record;
overriding function Create
(Parameters : not null access Matreshka.DOM_Elements.Element_L2_Parameters)
return Text_Index_Entry_Span_Element_Node;
overriding function Get_Local_Name
(Self : not null access constant Text_Index_Entry_Span_Element_Node)
return League.Strings.Universal_String;
overriding procedure Enter_Node
(Self : not null access Text_Index_Entry_Span_Element_Node;
Visitor : in out XML.DOM.Visitors.Abstract_Visitor'Class;
Control : in out XML.DOM.Visitors.Traverse_Control);
overriding procedure Leave_Node
(Self : not null access Text_Index_Entry_Span_Element_Node;
Visitor : in out XML.DOM.Visitors.Abstract_Visitor'Class;
Control : in out XML.DOM.Visitors.Traverse_Control);
overriding procedure Visit_Node
(Self : not null access Text_Index_Entry_Span_Element_Node;
Iterator : in out XML.DOM.Visitors.Abstract_Iterator'Class;
Visitor : in out XML.DOM.Visitors.Abstract_Visitor'Class;
Control : in out XML.DOM.Visitors.Traverse_Control);
end Matreshka.ODF_Text.Index_Entry_Span_Elements;
|
tum-ei-rcs/StratoX | Ada | 77,679 | ads | -- This spec has been automatically generated from STM32F429x.svd
pragma Restrictions (No_Elaboration_Code);
pragma Ada_2012;
with HAL;
with System;
package STM32_SVD.TIM is
pragma Preelaborate;
---------------
-- Registers --
---------------
------------------
-- CR1_Register --
------------------
subtype CR1_CMS_Field is HAL.UInt2;
subtype CR1_CKD_Field is HAL.UInt2;
-- control register 1
type CR1_Register is record
-- Counter enable
CEN : Boolean := False;
-- Update disable
UDIS : Boolean := False;
-- Update request source
URS : Boolean := False;
-- One-pulse mode
OPM : Boolean := False;
-- Direction
DIR : Boolean := False;
-- Center-aligned mode selection
CMS : CR1_CMS_Field := 16#0#;
-- Auto-reload preload enable
ARPE : Boolean := False;
-- Clock division
CKD : CR1_CKD_Field := 16#0#;
-- unspecified
Reserved_10_31 : HAL.UInt22 := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for CR1_Register use record
CEN at 0 range 0 .. 0;
UDIS at 0 range 1 .. 1;
URS at 0 range 2 .. 2;
OPM at 0 range 3 .. 3;
DIR at 0 range 4 .. 4;
CMS at 0 range 5 .. 6;
ARPE at 0 range 7 .. 7;
CKD at 0 range 8 .. 9;
Reserved_10_31 at 0 range 10 .. 31;
end record;
------------------
-- CR2_Register --
------------------
subtype CR2_MMS_Field is HAL.UInt3;
-- control register 2
type CR2_Register is record
-- Capture/compare preloaded control
CCPC : Boolean := False;
-- unspecified
Reserved_1_1 : HAL.Bit := 16#0#;
-- Capture/compare control update selection
CCUS : Boolean := False;
-- Capture/compare DMA selection
CCDS : Boolean := False;
-- Master mode selection
MMS : CR2_MMS_Field := 16#0#;
-- TI1 selection
TI1S : Boolean := False;
-- Output Idle state 1
OIS1 : Boolean := False;
-- Output Idle state 1
OIS1N : Boolean := False;
-- Output Idle state 2
OIS2 : Boolean := False;
-- Output Idle state 2
OIS2N : Boolean := False;
-- Output Idle state 3
OIS3 : Boolean := False;
-- Output Idle state 3
OIS3N : Boolean := False;
-- Output Idle state 4
OIS4 : Boolean := False;
-- unspecified
Reserved_15_31 : HAL.UInt17 := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for CR2_Register use record
CCPC at 0 range 0 .. 0;
Reserved_1_1 at 0 range 1 .. 1;
CCUS at 0 range 2 .. 2;
CCDS at 0 range 3 .. 3;
MMS at 0 range 4 .. 6;
TI1S at 0 range 7 .. 7;
OIS1 at 0 range 8 .. 8;
OIS1N at 0 range 9 .. 9;
OIS2 at 0 range 10 .. 10;
OIS2N at 0 range 11 .. 11;
OIS3 at 0 range 12 .. 12;
OIS3N at 0 range 13 .. 13;
OIS4 at 0 range 14 .. 14;
Reserved_15_31 at 0 range 15 .. 31;
end record;
-------------------
-- SMCR_Register --
-------------------
subtype SMCR_SMS_Field is HAL.UInt3;
subtype SMCR_TS_Field is HAL.UInt3;
subtype SMCR_ETF_Field is HAL.UInt4;
subtype SMCR_ETPS_Field is HAL.UInt2;
-- slave mode control register
type SMCR_Register is record
-- Slave mode selection
SMS : SMCR_SMS_Field := 16#0#;
-- unspecified
Reserved_3_3 : HAL.Bit := 16#0#;
-- Trigger selection
TS : SMCR_TS_Field := 16#0#;
-- Master/Slave mode
MSM : Boolean := False;
-- External trigger filter
ETF : SMCR_ETF_Field := 16#0#;
-- External trigger prescaler
ETPS : SMCR_ETPS_Field := 16#0#;
-- External clock enable
ECE : Boolean := False;
-- External trigger polarity
ETP : Boolean := False;
-- unspecified
Reserved_16_31 : HAL.Short := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for SMCR_Register use record
SMS at 0 range 0 .. 2;
Reserved_3_3 at 0 range 3 .. 3;
TS at 0 range 4 .. 6;
MSM at 0 range 7 .. 7;
ETF at 0 range 8 .. 11;
ETPS at 0 range 12 .. 13;
ECE at 0 range 14 .. 14;
ETP at 0 range 15 .. 15;
Reserved_16_31 at 0 range 16 .. 31;
end record;
-------------------
-- DIER_Register --
-------------------
-- DMA/Interrupt enable register
type DIER_Register is record
-- Update interrupt enable
UIE : Boolean := False;
-- Capture/Compare 1 interrupt enable
CC1IE : Boolean := False;
-- Capture/Compare 2 interrupt enable
CC2IE : Boolean := False;
-- Capture/Compare 3 interrupt enable
CC3IE : Boolean := False;
-- Capture/Compare 4 interrupt enable
CC4IE : Boolean := False;
-- COM interrupt enable
COMIE : Boolean := False;
-- Trigger interrupt enable
TIE : Boolean := False;
-- Break interrupt enable
BIE : Boolean := False;
-- Update DMA request enable
UDE : Boolean := False;
-- Capture/Compare 1 DMA request enable
CC1DE : Boolean := False;
-- Capture/Compare 2 DMA request enable
CC2DE : Boolean := False;
-- Capture/Compare 3 DMA request enable
CC3DE : Boolean := False;
-- Capture/Compare 4 DMA request enable
CC4DE : Boolean := False;
-- COM DMA request enable
COMDE : Boolean := False;
-- Trigger DMA request enable
TDE : Boolean := False;
-- unspecified
Reserved_15_31 : HAL.UInt17 := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for DIER_Register use record
UIE at 0 range 0 .. 0;
CC1IE at 0 range 1 .. 1;
CC2IE at 0 range 2 .. 2;
CC3IE at 0 range 3 .. 3;
CC4IE at 0 range 4 .. 4;
COMIE at 0 range 5 .. 5;
TIE at 0 range 6 .. 6;
BIE at 0 range 7 .. 7;
UDE at 0 range 8 .. 8;
CC1DE at 0 range 9 .. 9;
CC2DE at 0 range 10 .. 10;
CC3DE at 0 range 11 .. 11;
CC4DE at 0 range 12 .. 12;
COMDE at 0 range 13 .. 13;
TDE at 0 range 14 .. 14;
Reserved_15_31 at 0 range 15 .. 31;
end record;
-----------------
-- SR_Register --
-----------------
-- status register
type SR_Register is record
-- Update interrupt flag
UIF : Boolean := False;
-- Capture/compare 1 interrupt flag
CC1IF : Boolean := False;
-- Capture/Compare 2 interrupt flag
CC2IF : Boolean := False;
-- Capture/Compare 3 interrupt flag
CC3IF : Boolean := False;
-- Capture/Compare 4 interrupt flag
CC4IF : Boolean := False;
-- COM interrupt flag
COMIF : Boolean := False;
-- Trigger interrupt flag
TIF : Boolean := False;
-- Break interrupt flag
BIF : Boolean := False;
-- unspecified
Reserved_8_8 : HAL.Bit := 16#0#;
-- Capture/Compare 1 overcapture flag
CC1OF : Boolean := False;
-- Capture/compare 2 overcapture flag
CC2OF : Boolean := False;
-- Capture/Compare 3 overcapture flag
CC3OF : Boolean := False;
-- Capture/Compare 4 overcapture flag
CC4OF : Boolean := False;
-- unspecified
Reserved_13_31 : HAL.UInt19 := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for SR_Register use record
UIF at 0 range 0 .. 0;
CC1IF at 0 range 1 .. 1;
CC2IF at 0 range 2 .. 2;
CC3IF at 0 range 3 .. 3;
CC4IF at 0 range 4 .. 4;
COMIF at 0 range 5 .. 5;
TIF at 0 range 6 .. 6;
BIF at 0 range 7 .. 7;
Reserved_8_8 at 0 range 8 .. 8;
CC1OF at 0 range 9 .. 9;
CC2OF at 0 range 10 .. 10;
CC3OF at 0 range 11 .. 11;
CC4OF at 0 range 12 .. 12;
Reserved_13_31 at 0 range 13 .. 31;
end record;
------------------
-- EGR_Register --
------------------
-- event generation register
type EGR_Register is record
-- Write-only. Update generation
UG : Boolean := False;
-- Write-only. Capture/compare 1 generation
CC1G : Boolean := False;
-- Write-only. Capture/compare 2 generation
CC2G : Boolean := False;
-- Write-only. Capture/compare 3 generation
CC3G : Boolean := False;
-- Write-only. Capture/compare 4 generation
CC4G : Boolean := False;
-- Write-only. Capture/Compare control update generation
COMG : Boolean := False;
-- Write-only. Trigger generation
TG : Boolean := False;
-- Write-only. Break generation
BG : Boolean := False;
-- unspecified
Reserved_8_31 : HAL.UInt24 := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for EGR_Register use record
UG at 0 range 0 .. 0;
CC1G at 0 range 1 .. 1;
CC2G at 0 range 2 .. 2;
CC3G at 0 range 3 .. 3;
CC4G at 0 range 4 .. 4;
COMG at 0 range 5 .. 5;
TG at 0 range 6 .. 6;
BG at 0 range 7 .. 7;
Reserved_8_31 at 0 range 8 .. 31;
end record;
---------------------------
-- CCMR1_Output_Register --
---------------------------
subtype CCMR1_Output_CC1S_Field is HAL.UInt2;
subtype CCMR1_Output_OC1M_Field is HAL.UInt3;
subtype CCMR1_Output_CC2S_Field is HAL.UInt2;
subtype CCMR1_Output_OC2M_Field is HAL.UInt3;
-- capture/compare mode register 1 (output mode)
type CCMR1_Output_Register is record
-- Capture/Compare 1 selection
CC1S : CCMR1_Output_CC1S_Field := 16#0#;
-- Output Compare 1 fast enable
OC1FE : Boolean := False;
-- Output Compare 1 preload enable
OC1PE : Boolean := False;
-- Output Compare 1 mode
OC1M : CCMR1_Output_OC1M_Field := 16#0#;
-- Output Compare 1 clear enable
OC1CE : Boolean := False;
-- Capture/Compare 2 selection
CC2S : CCMR1_Output_CC2S_Field := 16#0#;
-- Output Compare 2 fast enable
OC2FE : Boolean := False;
-- Output Compare 2 preload enable
OC2PE : Boolean := False;
-- Output Compare 2 mode
OC2M : CCMR1_Output_OC2M_Field := 16#0#;
-- Output Compare 2 clear enable
OC2CE : Boolean := False;
-- unspecified
Reserved_16_31 : HAL.Short := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for CCMR1_Output_Register use record
CC1S at 0 range 0 .. 1;
OC1FE at 0 range 2 .. 2;
OC1PE at 0 range 3 .. 3;
OC1M at 0 range 4 .. 6;
OC1CE at 0 range 7 .. 7;
CC2S at 0 range 8 .. 9;
OC2FE at 0 range 10 .. 10;
OC2PE at 0 range 11 .. 11;
OC2M at 0 range 12 .. 14;
OC2CE at 0 range 15 .. 15;
Reserved_16_31 at 0 range 16 .. 31;
end record;
--------------------------
-- CCMR1_Input_Register --
--------------------------
subtype CCMR1_Input_CC1S_Field is HAL.UInt2;
subtype CCMR1_Input_ICPCS_Field is HAL.UInt2;
subtype CCMR1_Input_IC1F_Field is HAL.UInt4;
subtype CCMR1_Input_CC2S_Field is HAL.UInt2;
subtype CCMR1_Input_IC2PCS_Field is HAL.UInt2;
subtype CCMR1_Input_IC2F_Field is HAL.UInt4;
-- capture/compare mode register 1 (input mode)
type CCMR1_Input_Register is record
-- Capture/Compare 1 selection
CC1S : CCMR1_Input_CC1S_Field := 16#0#;
-- Input capture 1 prescaler
ICPCS : CCMR1_Input_ICPCS_Field := 16#0#;
-- Input capture 1 filter
IC1F : CCMR1_Input_IC1F_Field := 16#0#;
-- Capture/Compare 2 selection
CC2S : CCMR1_Input_CC2S_Field := 16#0#;
-- Input capture 2 prescaler
IC2PCS : CCMR1_Input_IC2PCS_Field := 16#0#;
-- Input capture 2 filter
IC2F : CCMR1_Input_IC2F_Field := 16#0#;
-- unspecified
Reserved_16_31 : HAL.Short := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for CCMR1_Input_Register use record
CC1S at 0 range 0 .. 1;
ICPCS at 0 range 2 .. 3;
IC1F at 0 range 4 .. 7;
CC2S at 0 range 8 .. 9;
IC2PCS at 0 range 10 .. 11;
IC2F at 0 range 12 .. 15;
Reserved_16_31 at 0 range 16 .. 31;
end record;
---------------------------
-- CCMR2_Output_Register --
---------------------------
subtype CCMR2_Output_CC3S_Field is HAL.UInt2;
subtype CCMR2_Output_OC3M_Field is HAL.UInt3;
subtype CCMR2_Output_CC4S_Field is HAL.UInt2;
subtype CCMR2_Output_OC4M_Field is HAL.UInt3;
-- capture/compare mode register 2 (output mode)
type CCMR2_Output_Register is record
-- Capture/Compare 3 selection
CC3S : CCMR2_Output_CC3S_Field := 16#0#;
-- Output compare 3 fast enable
OC3FE : Boolean := False;
-- Output compare 3 preload enable
OC3PE : Boolean := False;
-- Output compare 3 mode
OC3M : CCMR2_Output_OC3M_Field := 16#0#;
-- Output compare 3 clear enable
OC3CE : Boolean := False;
-- Capture/Compare 4 selection
CC4S : CCMR2_Output_CC4S_Field := 16#0#;
-- Output compare 4 fast enable
OC4FE : Boolean := False;
-- Output compare 4 preload enable
OC4PE : Boolean := False;
-- Output compare 4 mode
OC4M : CCMR2_Output_OC4M_Field := 16#0#;
-- Output compare 4 clear enable
OC4CE : Boolean := False;
-- unspecified
Reserved_16_31 : HAL.Short := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for CCMR2_Output_Register use record
CC3S at 0 range 0 .. 1;
OC3FE at 0 range 2 .. 2;
OC3PE at 0 range 3 .. 3;
OC3M at 0 range 4 .. 6;
OC3CE at 0 range 7 .. 7;
CC4S at 0 range 8 .. 9;
OC4FE at 0 range 10 .. 10;
OC4PE at 0 range 11 .. 11;
OC4M at 0 range 12 .. 14;
OC4CE at 0 range 15 .. 15;
Reserved_16_31 at 0 range 16 .. 31;
end record;
--------------------------
-- CCMR2_Input_Register --
--------------------------
subtype CCMR2_Input_CC3S_Field is HAL.UInt2;
subtype CCMR2_Input_IC3PSC_Field is HAL.UInt2;
subtype CCMR2_Input_IC3F_Field is HAL.UInt4;
subtype CCMR2_Input_CC4S_Field is HAL.UInt2;
subtype CCMR2_Input_IC4PSC_Field is HAL.UInt2;
subtype CCMR2_Input_IC4F_Field is HAL.UInt4;
-- capture/compare mode register 2 (input mode)
type CCMR2_Input_Register is record
-- Capture/compare 3 selection
CC3S : CCMR2_Input_CC3S_Field := 16#0#;
-- Input capture 3 prescaler
IC3PSC : CCMR2_Input_IC3PSC_Field := 16#0#;
-- Input capture 3 filter
IC3F : CCMR2_Input_IC3F_Field := 16#0#;
-- Capture/Compare 4 selection
CC4S : CCMR2_Input_CC4S_Field := 16#0#;
-- Input capture 4 prescaler
IC4PSC : CCMR2_Input_IC4PSC_Field := 16#0#;
-- Input capture 4 filter
IC4F : CCMR2_Input_IC4F_Field := 16#0#;
-- unspecified
Reserved_16_31 : HAL.Short := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for CCMR2_Input_Register use record
CC3S at 0 range 0 .. 1;
IC3PSC at 0 range 2 .. 3;
IC3F at 0 range 4 .. 7;
CC4S at 0 range 8 .. 9;
IC4PSC at 0 range 10 .. 11;
IC4F at 0 range 12 .. 15;
Reserved_16_31 at 0 range 16 .. 31;
end record;
-------------------
-- CCER_Register --
-------------------
-- capture/compare enable register
type CCER_Register is record
-- Capture/Compare 1 output enable
CC1E : Boolean := False;
-- Capture/Compare 1 output Polarity
CC1P : Boolean := False;
-- Capture/Compare 1 complementary output enable
CC1NE : Boolean := False;
-- Capture/Compare 1 output Polarity
CC1NP : Boolean := False;
-- Capture/Compare 2 output enable
CC2E : Boolean := False;
-- Capture/Compare 2 output Polarity
CC2P : Boolean := False;
-- Capture/Compare 2 complementary output enable
CC2NE : Boolean := False;
-- Capture/Compare 2 output Polarity
CC2NP : Boolean := False;
-- Capture/Compare 3 output enable
CC3E : Boolean := False;
-- Capture/Compare 3 output Polarity
CC3P : Boolean := False;
-- Capture/Compare 3 complementary output enable
CC3NE : Boolean := False;
-- Capture/Compare 3 output Polarity
CC3NP : Boolean := False;
-- Capture/Compare 4 output enable
CC4E : Boolean := False;
-- Capture/Compare 3 output Polarity
CC4P : Boolean := False;
-- unspecified
Reserved_14_31 : HAL.UInt18 := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for CCER_Register use record
CC1E at 0 range 0 .. 0;
CC1P at 0 range 1 .. 1;
CC1NE at 0 range 2 .. 2;
CC1NP at 0 range 3 .. 3;
CC2E at 0 range 4 .. 4;
CC2P at 0 range 5 .. 5;
CC2NE at 0 range 6 .. 6;
CC2NP at 0 range 7 .. 7;
CC3E at 0 range 8 .. 8;
CC3P at 0 range 9 .. 9;
CC3NE at 0 range 10 .. 10;
CC3NP at 0 range 11 .. 11;
CC4E at 0 range 12 .. 12;
CC4P at 0 range 13 .. 13;
Reserved_14_31 at 0 range 14 .. 31;
end record;
------------------
-- CNT_Register --
------------------
subtype CNT_CNT_Field is HAL.Short;
-- counter
type CNT_Register is record
-- counter value
CNT : CNT_CNT_Field := 16#0#;
-- unspecified
Reserved_16_31 : HAL.Short := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for CNT_Register use record
CNT at 0 range 0 .. 15;
Reserved_16_31 at 0 range 16 .. 31;
end record;
------------------
-- PSC_Register --
------------------
subtype PSC_PSC_Field is HAL.Short;
-- prescaler
type PSC_Register is record
-- Prescaler value
PSC : PSC_PSC_Field := 16#0#;
-- unspecified
Reserved_16_31 : HAL.Short := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for PSC_Register use record
PSC at 0 range 0 .. 15;
Reserved_16_31 at 0 range 16 .. 31;
end record;
------------------
-- ARR_Register --
------------------
subtype ARR_ARR_Field is HAL.Short;
-- auto-reload register
type ARR_Register is record
-- Auto-reload value
ARR : ARR_ARR_Field := 16#0#;
-- unspecified
Reserved_16_31 : HAL.Short := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for ARR_Register use record
ARR at 0 range 0 .. 15;
Reserved_16_31 at 0 range 16 .. 31;
end record;
------------------
-- RCR_Register --
------------------
subtype RCR_REP_Field is HAL.Byte;
-- repetition counter register
type RCR_Register is record
-- Repetition counter value
REP : RCR_REP_Field := 16#0#;
-- unspecified
Reserved_8_31 : HAL.UInt24 := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for RCR_Register use record
REP at 0 range 0 .. 7;
Reserved_8_31 at 0 range 8 .. 31;
end record;
-------------------
-- CCR1_Register --
-------------------
subtype CCR1_CCR1_Field is HAL.Short;
-- capture/compare register 1
type CCR1_Register is record
-- Capture/Compare 1 value
CCR1 : CCR1_CCR1_Field := 16#0#;
-- unspecified
Reserved_16_31 : HAL.Short := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for CCR1_Register use record
CCR1 at 0 range 0 .. 15;
Reserved_16_31 at 0 range 16 .. 31;
end record;
-------------------
-- CCR2_Register --
-------------------
subtype CCR2_CCR2_Field is HAL.Short;
-- capture/compare register 2
type CCR2_Register is record
-- Capture/Compare 2 value
CCR2 : CCR2_CCR2_Field := 16#0#;
-- unspecified
Reserved_16_31 : HAL.Short := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for CCR2_Register use record
CCR2 at 0 range 0 .. 15;
Reserved_16_31 at 0 range 16 .. 31;
end record;
-------------------
-- CCR3_Register --
-------------------
subtype CCR3_CCR3_Field is HAL.Short;
-- capture/compare register 3
type CCR3_Register is record
-- Capture/Compare value
CCR3 : CCR3_CCR3_Field := 16#0#;
-- unspecified
Reserved_16_31 : HAL.Short := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for CCR3_Register use record
CCR3 at 0 range 0 .. 15;
Reserved_16_31 at 0 range 16 .. 31;
end record;
-------------------
-- CCR4_Register --
-------------------
subtype CCR4_CCR4_Field is HAL.Short;
-- capture/compare register 4
type CCR4_Register is record
-- Capture/Compare value
CCR4 : CCR4_CCR4_Field := 16#0#;
-- unspecified
Reserved_16_31 : HAL.Short := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for CCR4_Register use record
CCR4 at 0 range 0 .. 15;
Reserved_16_31 at 0 range 16 .. 31;
end record;
-------------------
-- BDTR_Register --
-------------------
subtype BDTR_DTG_Field is HAL.Byte;
subtype BDTR_LOCK_Field is HAL.UInt2;
-- break and dead-time register
type BDTR_Register is record
-- Dead-time generator setup
DTG : BDTR_DTG_Field := 16#0#;
-- Lock configuration
LOCK : BDTR_LOCK_Field := 16#0#;
-- Off-state selection for Idle mode
OSSI : Boolean := False;
-- Off-state selection for Run mode
OSSR : Boolean := False;
-- Break enable
BKE : Boolean := False;
-- Break polarity
BKP : Boolean := False;
-- Automatic output enable
AOE : Boolean := False;
-- Main output enable
MOE : Boolean := False;
-- unspecified
Reserved_16_31 : HAL.Short := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for BDTR_Register use record
DTG at 0 range 0 .. 7;
LOCK at 0 range 8 .. 9;
OSSI at 0 range 10 .. 10;
OSSR at 0 range 11 .. 11;
BKE at 0 range 12 .. 12;
BKP at 0 range 13 .. 13;
AOE at 0 range 14 .. 14;
MOE at 0 range 15 .. 15;
Reserved_16_31 at 0 range 16 .. 31;
end record;
------------------
-- DCR_Register --
------------------
subtype DCR_DBA_Field is HAL.UInt5;
subtype DCR_DBL_Field is HAL.UInt5;
-- DMA control register
type DCR_Register is record
-- DMA base address
DBA : DCR_DBA_Field := 16#0#;
-- unspecified
Reserved_5_7 : HAL.UInt3 := 16#0#;
-- DMA burst length
DBL : DCR_DBL_Field := 16#0#;
-- unspecified
Reserved_13_31 : HAL.UInt19 := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for DCR_Register use record
DBA at 0 range 0 .. 4;
Reserved_5_7 at 0 range 5 .. 7;
DBL at 0 range 8 .. 12;
Reserved_13_31 at 0 range 13 .. 31;
end record;
-------------------
-- DMAR_Register --
-------------------
subtype DMAR_DMAB_Field is HAL.Short;
-- DMA address for full transfer
type DMAR_Register is record
-- DMA register for burst accesses
DMAB : DMAR_DMAB_Field := 16#0#;
-- unspecified
Reserved_16_31 : HAL.Short := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for DMAR_Register use record
DMAB at 0 range 0 .. 15;
Reserved_16_31 at 0 range 16 .. 31;
end record;
------------------
-- CR2_Register --
------------------
-- control register 2
type CR2_Register_1 is record
-- unspecified
Reserved_0_2 : HAL.UInt3 := 16#0#;
-- Capture/compare DMA selection
CCDS : Boolean := False;
-- Master mode selection
MMS : CR2_MMS_Field := 16#0#;
-- TI1 selection
TI1S : Boolean := False;
-- unspecified
Reserved_8_31 : HAL.UInt24 := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for CR2_Register_1 use record
Reserved_0_2 at 0 range 0 .. 2;
CCDS at 0 range 3 .. 3;
MMS at 0 range 4 .. 6;
TI1S at 0 range 7 .. 7;
Reserved_8_31 at 0 range 8 .. 31;
end record;
-------------------
-- DIER_Register --
-------------------
-- DMA/Interrupt enable register
type DIER_Register_1 is record
-- Update interrupt enable
UIE : Boolean := False;
-- Capture/Compare 1 interrupt enable
CC1IE : Boolean := False;
-- Capture/Compare 2 interrupt enable
CC2IE : Boolean := False;
-- Capture/Compare 3 interrupt enable
CC3IE : Boolean := False;
-- Capture/Compare 4 interrupt enable
CC4IE : Boolean := False;
-- unspecified
Reserved_5_5 : HAL.Bit := 16#0#;
-- Trigger interrupt enable
TIE : Boolean := False;
-- unspecified
Reserved_7_7 : HAL.Bit := 16#0#;
-- Update DMA request enable
UDE : Boolean := False;
-- Capture/Compare 1 DMA request enable
CC1DE : Boolean := False;
-- Capture/Compare 2 DMA request enable
CC2DE : Boolean := False;
-- Capture/Compare 3 DMA request enable
CC3DE : Boolean := False;
-- Capture/Compare 4 DMA request enable
CC4DE : Boolean := False;
-- unspecified
Reserved_13_13 : HAL.Bit := 16#0#;
-- Trigger DMA request enable
TDE : Boolean := False;
-- unspecified
Reserved_15_31 : HAL.UInt17 := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for DIER_Register_1 use record
UIE at 0 range 0 .. 0;
CC1IE at 0 range 1 .. 1;
CC2IE at 0 range 2 .. 2;
CC3IE at 0 range 3 .. 3;
CC4IE at 0 range 4 .. 4;
Reserved_5_5 at 0 range 5 .. 5;
TIE at 0 range 6 .. 6;
Reserved_7_7 at 0 range 7 .. 7;
UDE at 0 range 8 .. 8;
CC1DE at 0 range 9 .. 9;
CC2DE at 0 range 10 .. 10;
CC3DE at 0 range 11 .. 11;
CC4DE at 0 range 12 .. 12;
Reserved_13_13 at 0 range 13 .. 13;
TDE at 0 range 14 .. 14;
Reserved_15_31 at 0 range 15 .. 31;
end record;
-----------------
-- SR_Register --
-----------------
-- status register
type SR_Register_1 is record
-- Update interrupt flag
UIF : Boolean := False;
-- Capture/compare 1 interrupt flag
CC1IF : Boolean := False;
-- Capture/Compare 2 interrupt flag
CC2IF : Boolean := False;
-- Capture/Compare 3 interrupt flag
CC3IF : Boolean := False;
-- Capture/Compare 4 interrupt flag
CC4IF : Boolean := False;
-- unspecified
Reserved_5_5 : HAL.Bit := 16#0#;
-- Trigger interrupt flag
TIF : Boolean := False;
-- unspecified
Reserved_7_8 : HAL.UInt2 := 16#0#;
-- Capture/Compare 1 overcapture flag
CC1OF : Boolean := False;
-- Capture/compare 2 overcapture flag
CC2OF : Boolean := False;
-- Capture/Compare 3 overcapture flag
CC3OF : Boolean := False;
-- Capture/Compare 4 overcapture flag
CC4OF : Boolean := False;
-- unspecified
Reserved_13_31 : HAL.UInt19 := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for SR_Register_1 use record
UIF at 0 range 0 .. 0;
CC1IF at 0 range 1 .. 1;
CC2IF at 0 range 2 .. 2;
CC3IF at 0 range 3 .. 3;
CC4IF at 0 range 4 .. 4;
Reserved_5_5 at 0 range 5 .. 5;
TIF at 0 range 6 .. 6;
Reserved_7_8 at 0 range 7 .. 8;
CC1OF at 0 range 9 .. 9;
CC2OF at 0 range 10 .. 10;
CC3OF at 0 range 11 .. 11;
CC4OF at 0 range 12 .. 12;
Reserved_13_31 at 0 range 13 .. 31;
end record;
------------------
-- EGR_Register --
------------------
-- event generation register
type EGR_Register_1 is record
-- Write-only. Update generation
UG : Boolean := False;
-- Write-only. Capture/compare 1 generation
CC1G : Boolean := False;
-- Write-only. Capture/compare 2 generation
CC2G : Boolean := False;
-- Write-only. Capture/compare 3 generation
CC3G : Boolean := False;
-- Write-only. Capture/compare 4 generation
CC4G : Boolean := False;
-- unspecified
Reserved_5_5 : HAL.Bit := 16#0#;
-- Write-only. Trigger generation
TG : Boolean := False;
-- unspecified
Reserved_7_31 : HAL.UInt25 := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for EGR_Register_1 use record
UG at 0 range 0 .. 0;
CC1G at 0 range 1 .. 1;
CC2G at 0 range 2 .. 2;
CC3G at 0 range 3 .. 3;
CC4G at 0 range 4 .. 4;
Reserved_5_5 at 0 range 5 .. 5;
TG at 0 range 6 .. 6;
Reserved_7_31 at 0 range 7 .. 31;
end record;
---------------------------
-- CCMR2_Output_Register --
---------------------------
-- capture/compare mode register 2 (output mode)
type CCMR2_Output_Register_1 is record
-- CC3S
CC3S : CCMR2_Output_CC3S_Field := 16#0#;
-- OC3FE
OC3FE : Boolean := False;
-- OC3PE
OC3PE : Boolean := False;
-- OC3M
OC3M : CCMR2_Output_OC3M_Field := 16#0#;
-- OC3CE
OC3CE : Boolean := False;
-- CC4S
CC4S : CCMR2_Output_CC4S_Field := 16#0#;
-- OC4FE
OC4FE : Boolean := False;
-- OC4PE
OC4PE : Boolean := False;
-- OC4M
OC4M : CCMR2_Output_OC4M_Field := 16#0#;
-- O24CE
O24CE : Boolean := False;
-- unspecified
Reserved_16_31 : HAL.Short := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for CCMR2_Output_Register_1 use record
CC3S at 0 range 0 .. 1;
OC3FE at 0 range 2 .. 2;
OC3PE at 0 range 3 .. 3;
OC3M at 0 range 4 .. 6;
OC3CE at 0 range 7 .. 7;
CC4S at 0 range 8 .. 9;
OC4FE at 0 range 10 .. 10;
OC4PE at 0 range 11 .. 11;
OC4M at 0 range 12 .. 14;
O24CE at 0 range 15 .. 15;
Reserved_16_31 at 0 range 16 .. 31;
end record;
-------------------
-- CCER_Register --
-------------------
-- capture/compare enable register
type CCER_Register_1 is record
-- Capture/Compare 1 output enable
CC1E : Boolean := False;
-- Capture/Compare 1 output Polarity
CC1P : Boolean := False;
-- unspecified
Reserved_2_2 : HAL.Bit := 16#0#;
-- Capture/Compare 1 output Polarity
CC1NP : Boolean := False;
-- Capture/Compare 2 output enable
CC2E : Boolean := False;
-- Capture/Compare 2 output Polarity
CC2P : Boolean := False;
-- unspecified
Reserved_6_6 : HAL.Bit := 16#0#;
-- Capture/Compare 2 output Polarity
CC2NP : Boolean := False;
-- Capture/Compare 3 output enable
CC3E : Boolean := False;
-- Capture/Compare 3 output Polarity
CC3P : Boolean := False;
-- unspecified
Reserved_10_10 : HAL.Bit := 16#0#;
-- Capture/Compare 3 output Polarity
CC3NP : Boolean := False;
-- Capture/Compare 4 output enable
CC4E : Boolean := False;
-- Capture/Compare 3 output Polarity
CC4P : Boolean := False;
-- unspecified
Reserved_14_14 : HAL.Bit := 16#0#;
-- Capture/Compare 4 output Polarity
CC4NP : Boolean := False;
-- unspecified
Reserved_16_31 : HAL.Short := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for CCER_Register_1 use record
CC1E at 0 range 0 .. 0;
CC1P at 0 range 1 .. 1;
Reserved_2_2 at 0 range 2 .. 2;
CC1NP at 0 range 3 .. 3;
CC2E at 0 range 4 .. 4;
CC2P at 0 range 5 .. 5;
Reserved_6_6 at 0 range 6 .. 6;
CC2NP at 0 range 7 .. 7;
CC3E at 0 range 8 .. 8;
CC3P at 0 range 9 .. 9;
Reserved_10_10 at 0 range 10 .. 10;
CC3NP at 0 range 11 .. 11;
CC4E at 0 range 12 .. 12;
CC4P at 0 range 13 .. 13;
Reserved_14_14 at 0 range 14 .. 14;
CC4NP at 0 range 15 .. 15;
Reserved_16_31 at 0 range 16 .. 31;
end record;
------------------
-- CNT_Register --
------------------
subtype CNT_CNT_L_Field is HAL.Short;
subtype CNT_CNT_H_Field is HAL.Short;
-- counter
type CNT_Register_1 is record
-- Low counter value
CNT_L : CNT_CNT_L_Field := 16#0#;
-- High counter value
CNT_H : CNT_CNT_H_Field := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for CNT_Register_1 use record
CNT_L at 0 range 0 .. 15;
CNT_H at 0 range 16 .. 31;
end record;
------------------
-- ARR_Register --
------------------
subtype ARR_ARR_L_Field is HAL.Short;
subtype ARR_ARR_H_Field is HAL.Short;
-- auto-reload register
type ARR_Register_1 is record
-- Low Auto-reload value
ARR_L : ARR_ARR_L_Field := 16#0#;
-- High Auto-reload value
ARR_H : ARR_ARR_H_Field := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for ARR_Register_1 use record
ARR_L at 0 range 0 .. 15;
ARR_H at 0 range 16 .. 31;
end record;
-------------------
-- CCR1_Register --
-------------------
subtype CCR1_CCR1_L_Field is HAL.Short;
subtype CCR1_CCR1_H_Field is HAL.Short;
-- capture/compare register 1
type CCR1_Register_1 is record
-- Low Capture/Compare 1 value
CCR1_L : CCR1_CCR1_L_Field := 16#0#;
-- High Capture/Compare 1 value
CCR1_H : CCR1_CCR1_H_Field := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for CCR1_Register_1 use record
CCR1_L at 0 range 0 .. 15;
CCR1_H at 0 range 16 .. 31;
end record;
-------------------
-- CCR2_Register --
-------------------
subtype CCR2_CCR2_L_Field is HAL.Short;
subtype CCR2_CCR2_H_Field is HAL.Short;
-- capture/compare register 2
type CCR2_Register_1 is record
-- Low Capture/Compare 2 value
CCR2_L : CCR2_CCR2_L_Field := 16#0#;
-- High Capture/Compare 2 value
CCR2_H : CCR2_CCR2_H_Field := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for CCR2_Register_1 use record
CCR2_L at 0 range 0 .. 15;
CCR2_H at 0 range 16 .. 31;
end record;
-------------------
-- CCR3_Register --
-------------------
subtype CCR3_CCR3_L_Field is HAL.Short;
subtype CCR3_CCR3_H_Field is HAL.Short;
-- capture/compare register 3
type CCR3_Register_1 is record
-- Low Capture/Compare value
CCR3_L : CCR3_CCR3_L_Field := 16#0#;
-- High Capture/Compare value
CCR3_H : CCR3_CCR3_H_Field := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for CCR3_Register_1 use record
CCR3_L at 0 range 0 .. 15;
CCR3_H at 0 range 16 .. 31;
end record;
-------------------
-- CCR4_Register --
-------------------
subtype CCR4_CCR4_L_Field is HAL.Short;
subtype CCR4_CCR4_H_Field is HAL.Short;
-- capture/compare register 4
type CCR4_Register_1 is record
-- Low Capture/Compare value
CCR4_L : CCR4_CCR4_L_Field := 16#0#;
-- High Capture/Compare value
CCR4_H : CCR4_CCR4_H_Field := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for CCR4_Register_1 use record
CCR4_L at 0 range 0 .. 15;
CCR4_H at 0 range 16 .. 31;
end record;
-----------------
-- OR_Register --
-----------------
subtype OR_ITR1_RMP_Field is HAL.UInt2;
-- TIM5 option register
type OR_Register is record
-- unspecified
Reserved_0_9 : HAL.UInt10 := 16#0#;
-- Timer Input 4 remap
ITR1_RMP : OR_ITR1_RMP_Field := 16#0#;
-- unspecified
Reserved_12_31 : HAL.UInt20 := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for OR_Register use record
Reserved_0_9 at 0 range 0 .. 9;
ITR1_RMP at 0 range 10 .. 11;
Reserved_12_31 at 0 range 12 .. 31;
end record;
-----------------
-- OR_Register --
-----------------
subtype OR_IT4_RMP_Field is HAL.UInt2;
-- TIM5 option register
type OR_Register_1 is record
-- unspecified
Reserved_0_5 : HAL.UInt6 := 16#0#;
-- Timer Input 4 remap
IT4_RMP : OR_IT4_RMP_Field := 16#0#;
-- unspecified
Reserved_8_31 : HAL.UInt24 := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for OR_Register_1 use record
Reserved_0_5 at 0 range 0 .. 5;
IT4_RMP at 0 range 6 .. 7;
Reserved_8_31 at 0 range 8 .. 31;
end record;
------------------
-- CR1_Register --
------------------
-- control register 1
type CR1_Register_1 is record
-- Counter enable
CEN : Boolean := False;
-- Update disable
UDIS : Boolean := False;
-- Update request source
URS : Boolean := False;
-- One-pulse mode
OPM : Boolean := False;
-- unspecified
Reserved_4_6 : HAL.UInt3 := 16#0#;
-- Auto-reload preload enable
ARPE : Boolean := False;
-- Clock division
CKD : CR1_CKD_Field := 16#0#;
-- unspecified
Reserved_10_31 : HAL.UInt22 := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for CR1_Register_1 use record
CEN at 0 range 0 .. 0;
UDIS at 0 range 1 .. 1;
URS at 0 range 2 .. 2;
OPM at 0 range 3 .. 3;
Reserved_4_6 at 0 range 4 .. 6;
ARPE at 0 range 7 .. 7;
CKD at 0 range 8 .. 9;
Reserved_10_31 at 0 range 10 .. 31;
end record;
------------------
-- CR2_Register --
------------------
-- control register 2
type CR2_Register_2 is record
-- unspecified
Reserved_0_3 : HAL.UInt4 := 16#0#;
-- Master mode selection
MMS : CR2_MMS_Field := 16#0#;
-- unspecified
Reserved_7_31 : HAL.UInt25 := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for CR2_Register_2 use record
Reserved_0_3 at 0 range 0 .. 3;
MMS at 0 range 4 .. 6;
Reserved_7_31 at 0 range 7 .. 31;
end record;
-------------------
-- SMCR_Register --
-------------------
-- slave mode control register
type SMCR_Register_1 is record
-- Slave mode selection
SMS : SMCR_SMS_Field := 16#0#;
-- unspecified
Reserved_3_3 : HAL.Bit := 16#0#;
-- Trigger selection
TS : SMCR_TS_Field := 16#0#;
-- Master/Slave mode
MSM : Boolean := False;
-- unspecified
Reserved_8_31 : HAL.UInt24 := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for SMCR_Register_1 use record
SMS at 0 range 0 .. 2;
Reserved_3_3 at 0 range 3 .. 3;
TS at 0 range 4 .. 6;
MSM at 0 range 7 .. 7;
Reserved_8_31 at 0 range 8 .. 31;
end record;
-------------------
-- DIER_Register --
-------------------
-- DMA/Interrupt enable register
type DIER_Register_2 is record
-- Update interrupt enable
UIE : Boolean := False;
-- Capture/Compare 1 interrupt enable
CC1IE : Boolean := False;
-- Capture/Compare 2 interrupt enable
CC2IE : Boolean := False;
-- unspecified
Reserved_3_5 : HAL.UInt3 := 16#0#;
-- Trigger interrupt enable
TIE : Boolean := False;
-- unspecified
Reserved_7_31 : HAL.UInt25 := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for DIER_Register_2 use record
UIE at 0 range 0 .. 0;
CC1IE at 0 range 1 .. 1;
CC2IE at 0 range 2 .. 2;
Reserved_3_5 at 0 range 3 .. 5;
TIE at 0 range 6 .. 6;
Reserved_7_31 at 0 range 7 .. 31;
end record;
-----------------
-- SR_Register --
-----------------
-- status register
type SR_Register_2 is record
-- Update interrupt flag
UIF : Boolean := False;
-- Capture/compare 1 interrupt flag
CC1IF : Boolean := False;
-- Capture/Compare 2 interrupt flag
CC2IF : Boolean := False;
-- unspecified
Reserved_3_5 : HAL.UInt3 := 16#0#;
-- Trigger interrupt flag
TIF : Boolean := False;
-- unspecified
Reserved_7_8 : HAL.UInt2 := 16#0#;
-- Capture/Compare 1 overcapture flag
CC1OF : Boolean := False;
-- Capture/compare 2 overcapture flag
CC2OF : Boolean := False;
-- unspecified
Reserved_11_31 : HAL.UInt21 := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for SR_Register_2 use record
UIF at 0 range 0 .. 0;
CC1IF at 0 range 1 .. 1;
CC2IF at 0 range 2 .. 2;
Reserved_3_5 at 0 range 3 .. 5;
TIF at 0 range 6 .. 6;
Reserved_7_8 at 0 range 7 .. 8;
CC1OF at 0 range 9 .. 9;
CC2OF at 0 range 10 .. 10;
Reserved_11_31 at 0 range 11 .. 31;
end record;
------------------
-- EGR_Register --
------------------
-- event generation register
type EGR_Register_2 is record
-- Write-only. Update generation
UG : Boolean := False;
-- Write-only. Capture/compare 1 generation
CC1G : Boolean := False;
-- Write-only. Capture/compare 2 generation
CC2G : Boolean := False;
-- unspecified
Reserved_3_5 : HAL.UInt3 := 16#0#;
-- Write-only. Trigger generation
TG : Boolean := False;
-- unspecified
Reserved_7_31 : HAL.UInt25 := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for EGR_Register_2 use record
UG at 0 range 0 .. 0;
CC1G at 0 range 1 .. 1;
CC2G at 0 range 2 .. 2;
Reserved_3_5 at 0 range 3 .. 5;
TG at 0 range 6 .. 6;
Reserved_7_31 at 0 range 7 .. 31;
end record;
---------------------------
-- CCMR1_Output_Register --
---------------------------
-- capture/compare mode register 1 (output mode)
type CCMR1_Output_Register_1 is record
-- Capture/Compare 1 selection
CC1S : CCMR1_Output_CC1S_Field := 16#0#;
-- Output Compare 1 fast enable
OC1FE : Boolean := False;
-- Output Compare 1 preload enable
OC1PE : Boolean := False;
-- Output Compare 1 mode
OC1M : CCMR1_Output_OC1M_Field := 16#0#;
-- unspecified
Reserved_7_7 : HAL.Bit := 16#0#;
-- Capture/Compare 2 selection
CC2S : CCMR1_Output_CC2S_Field := 16#0#;
-- Output Compare 2 fast enable
OC2FE : Boolean := False;
-- Output Compare 2 preload enable
OC2PE : Boolean := False;
-- Output Compare 2 mode
OC2M : CCMR1_Output_OC2M_Field := 16#0#;
-- unspecified
Reserved_15_31 : HAL.UInt17 := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for CCMR1_Output_Register_1 use record
CC1S at 0 range 0 .. 1;
OC1FE at 0 range 2 .. 2;
OC1PE at 0 range 3 .. 3;
OC1M at 0 range 4 .. 6;
Reserved_7_7 at 0 range 7 .. 7;
CC2S at 0 range 8 .. 9;
OC2FE at 0 range 10 .. 10;
OC2PE at 0 range 11 .. 11;
OC2M at 0 range 12 .. 14;
Reserved_15_31 at 0 range 15 .. 31;
end record;
--------------------------
-- CCMR1_Input_Register --
--------------------------
subtype CCMR1_Input_IC1F_Field_1 is HAL.UInt3;
subtype CCMR1_Input_IC2F_Field_1 is HAL.UInt3;
-- capture/compare mode register 1 (input mode)
type CCMR1_Input_Register_1 is record
-- Capture/Compare 1 selection
CC1S : CCMR1_Input_CC1S_Field := 16#0#;
-- Input capture 1 prescaler
ICPCS : CCMR1_Input_ICPCS_Field := 16#0#;
-- Input capture 1 filter
IC1F : CCMR1_Input_IC1F_Field_1 := 16#0#;
-- unspecified
Reserved_7_7 : HAL.Bit := 16#0#;
-- Capture/Compare 2 selection
CC2S : CCMR1_Input_CC2S_Field := 16#0#;
-- Input capture 2 prescaler
IC2PCS : CCMR1_Input_IC2PCS_Field := 16#0#;
-- Input capture 2 filter
IC2F : CCMR1_Input_IC2F_Field_1 := 16#0#;
-- unspecified
Reserved_15_31 : HAL.UInt17 := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for CCMR1_Input_Register_1 use record
CC1S at 0 range 0 .. 1;
ICPCS at 0 range 2 .. 3;
IC1F at 0 range 4 .. 6;
Reserved_7_7 at 0 range 7 .. 7;
CC2S at 0 range 8 .. 9;
IC2PCS at 0 range 10 .. 11;
IC2F at 0 range 12 .. 14;
Reserved_15_31 at 0 range 15 .. 31;
end record;
-------------------
-- CCER_Register --
-------------------
-- capture/compare enable register
type CCER_Register_2 is record
-- Capture/Compare 1 output enable
CC1E : Boolean := False;
-- Capture/Compare 1 output Polarity
CC1P : Boolean := False;
-- unspecified
Reserved_2_2 : HAL.Bit := 16#0#;
-- Capture/Compare 1 output Polarity
CC1NP : Boolean := False;
-- Capture/Compare 2 output enable
CC2E : Boolean := False;
-- Capture/Compare 2 output Polarity
CC2P : Boolean := False;
-- unspecified
Reserved_6_6 : HAL.Bit := 16#0#;
-- Capture/Compare 2 output Polarity
CC2NP : Boolean := False;
-- unspecified
Reserved_8_31 : HAL.UInt24 := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for CCER_Register_2 use record
CC1E at 0 range 0 .. 0;
CC1P at 0 range 1 .. 1;
Reserved_2_2 at 0 range 2 .. 2;
CC1NP at 0 range 3 .. 3;
CC2E at 0 range 4 .. 4;
CC2P at 0 range 5 .. 5;
Reserved_6_6 at 0 range 6 .. 6;
CC2NP at 0 range 7 .. 7;
Reserved_8_31 at 0 range 8 .. 31;
end record;
------------------
-- CR1_Register --
------------------
-- control register 1
type CR1_Register_2 is record
-- Counter enable
CEN : Boolean := False;
-- Update disable
UDIS : Boolean := False;
-- Update request source
URS : Boolean := False;
-- unspecified
Reserved_3_6 : HAL.UInt4 := 16#0#;
-- Auto-reload preload enable
ARPE : Boolean := False;
-- Clock division
CKD : CR1_CKD_Field := 16#0#;
-- unspecified
Reserved_10_31 : HAL.UInt22 := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for CR1_Register_2 use record
CEN at 0 range 0 .. 0;
UDIS at 0 range 1 .. 1;
URS at 0 range 2 .. 2;
Reserved_3_6 at 0 range 3 .. 6;
ARPE at 0 range 7 .. 7;
CKD at 0 range 8 .. 9;
Reserved_10_31 at 0 range 10 .. 31;
end record;
-------------------
-- DIER_Register --
-------------------
-- DMA/Interrupt enable register
type DIER_Register_3 is record
-- Update interrupt enable
UIE : Boolean := False;
-- Capture/Compare 1 interrupt enable
CC1IE : 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 DIER_Register_3 use record
UIE at 0 range 0 .. 0;
CC1IE at 0 range 1 .. 1;
Reserved_2_31 at 0 range 2 .. 31;
end record;
-----------------
-- SR_Register --
-----------------
-- status register
type SR_Register_3 is record
-- Update interrupt flag
UIF : Boolean := False;
-- Capture/compare 1 interrupt flag
CC1IF : Boolean := False;
-- unspecified
Reserved_2_8 : HAL.UInt7 := 16#0#;
-- Capture/Compare 1 overcapture flag
CC1OF : Boolean := False;
-- unspecified
Reserved_10_31 : HAL.UInt22 := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for SR_Register_3 use record
UIF at 0 range 0 .. 0;
CC1IF at 0 range 1 .. 1;
Reserved_2_8 at 0 range 2 .. 8;
CC1OF at 0 range 9 .. 9;
Reserved_10_31 at 0 range 10 .. 31;
end record;
------------------
-- EGR_Register --
------------------
-- event generation register
type EGR_Register_3 is record
-- Write-only. Update generation
UG : Boolean := False;
-- Write-only. Capture/compare 1 generation
CC1G : 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 EGR_Register_3 use record
UG at 0 range 0 .. 0;
CC1G at 0 range 1 .. 1;
Reserved_2_31 at 0 range 2 .. 31;
end record;
---------------------------
-- CCMR1_Output_Register --
---------------------------
-- capture/compare mode register 1 (output mode)
type CCMR1_Output_Register_2 is record
-- Capture/Compare 1 selection
CC1S : CCMR1_Output_CC1S_Field := 16#0#;
-- Output Compare 1 fast enable
OC1FE : Boolean := False;
-- Output Compare 1 preload enable
OC1PE : Boolean := False;
-- Output Compare 1 mode
OC1M : CCMR1_Output_OC1M_Field := 16#0#;
-- unspecified
Reserved_7_31 : HAL.UInt25 := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for CCMR1_Output_Register_2 use record
CC1S at 0 range 0 .. 1;
OC1FE at 0 range 2 .. 2;
OC1PE at 0 range 3 .. 3;
OC1M at 0 range 4 .. 6;
Reserved_7_31 at 0 range 7 .. 31;
end record;
--------------------------
-- CCMR1_Input_Register --
--------------------------
-- capture/compare mode register 1 (input mode)
type CCMR1_Input_Register_2 is record
-- Capture/Compare 1 selection
CC1S : CCMR1_Input_CC1S_Field := 16#0#;
-- Input capture 1 prescaler
ICPCS : CCMR1_Input_ICPCS_Field := 16#0#;
-- Input capture 1 filter
IC1F : CCMR1_Input_IC1F_Field := 16#0#;
-- unspecified
Reserved_8_31 : HAL.UInt24 := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for CCMR1_Input_Register_2 use record
CC1S at 0 range 0 .. 1;
ICPCS at 0 range 2 .. 3;
IC1F at 0 range 4 .. 7;
Reserved_8_31 at 0 range 8 .. 31;
end record;
-------------------
-- CCER_Register --
-------------------
-- capture/compare enable register
type CCER_Register_3 is record
-- Capture/Compare 1 output enable
CC1E : Boolean := False;
-- Capture/Compare 1 output Polarity
CC1P : Boolean := False;
-- unspecified
Reserved_2_2 : HAL.Bit := 16#0#;
-- Capture/Compare 1 output Polarity
CC1NP : 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 CCER_Register_3 use record
CC1E at 0 range 0 .. 0;
CC1P at 0 range 1 .. 1;
Reserved_2_2 at 0 range 2 .. 2;
CC1NP at 0 range 3 .. 3;
Reserved_4_31 at 0 range 4 .. 31;
end record;
-----------------
-- OR_Register --
-----------------
subtype OR_RMP_Field is HAL.UInt2;
-- option register
type OR_Register_2 is record
-- Input 1 remapping capability
RMP : OR_RMP_Field := 16#0#;
-- unspecified
Reserved_2_31 : HAL.UInt30 := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for OR_Register_2 use record
RMP at 0 range 0 .. 1;
Reserved_2_31 at 0 range 2 .. 31;
end record;
------------------
-- CR1_Register --
------------------
-- control register 1
type CR1_Register_3 is record
-- Counter enable
CEN : Boolean := False;
-- Update disable
UDIS : Boolean := False;
-- Update request source
URS : Boolean := False;
-- One-pulse mode
OPM : Boolean := False;
-- unspecified
Reserved_4_6 : HAL.UInt3 := 16#0#;
-- Auto-reload preload enable
ARPE : Boolean := False;
-- unspecified
Reserved_8_31 : HAL.UInt24 := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for CR1_Register_3 use record
CEN at 0 range 0 .. 0;
UDIS at 0 range 1 .. 1;
URS at 0 range 2 .. 2;
OPM at 0 range 3 .. 3;
Reserved_4_6 at 0 range 4 .. 6;
ARPE at 0 range 7 .. 7;
Reserved_8_31 at 0 range 8 .. 31;
end record;
-------------------
-- DIER_Register --
-------------------
-- DMA/Interrupt enable register
type DIER_Register_4 is record
-- Update interrupt enable
UIE : Boolean := False;
-- unspecified
Reserved_1_7 : HAL.UInt7 := 16#0#;
-- Update DMA request enable
UDE : 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 DIER_Register_4 use record
UIE at 0 range 0 .. 0;
Reserved_1_7 at 0 range 1 .. 7;
UDE at 0 range 8 .. 8;
Reserved_9_31 at 0 range 9 .. 31;
end record;
-----------------
-- SR_Register --
-----------------
-- status register
type SR_Register_4 is record
-- Update interrupt flag
UIF : Boolean := False;
-- unspecified
Reserved_1_31 : HAL.UInt31 := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for SR_Register_4 use record
UIF at 0 range 0 .. 0;
Reserved_1_31 at 0 range 1 .. 31;
end record;
------------------
-- EGR_Register --
------------------
-- event generation register
type EGR_Register_4 is record
-- Write-only. Update generation
UG : Boolean := False;
-- unspecified
Reserved_1_31 : HAL.UInt31 := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for EGR_Register_4 use record
UG at 0 range 0 .. 0;
Reserved_1_31 at 0 range 1 .. 31;
end record;
type CCMR1_Discriminent is
(
Output,
Input);
type CCMR1_Aliased_Register
(Disc : CCMR1_Discriminent := Output)
is record
case Disc is
when Output =>
Output : CCMR1_Output_Register;
when Input =>
Input : CCMR1_Input_Register;
end case;
end record
with Unchecked_Union;
for CCMR1_Aliased_Register use record
Output at 0 range 0 .. 31;
Input at 0 range 0 .. 31;
end record;
type CCMR2_Discriminent is
(
Output,
Input);
type CCMR2_Aliased_Register
(Disc : CCMR2_Discriminent := Output)
is record
case Disc is
when Output =>
Output : CCMR2_Output_Register;
when Input =>
Input : CCMR2_Input_Register;
end case;
end record
with Unchecked_Union;
for CCMR2_Aliased_Register use record
Output at 0 range 0 .. 31;
Input at 0 range 0 .. 31;
end record;
type CCMR2_Aliased_Register_1
(Disc : CCMR2_Discriminent := Output)
is record
case Disc is
when Output =>
Output : CCMR2_Output_Register_1;
when Input =>
Input : CCMR2_Input_Register;
end case;
end record
with Unchecked_Union;
for CCMR2_Aliased_Register_1 use record
Output at 0 range 0 .. 31;
Input at 0 range 0 .. 31;
end record;
type CCMR1_Aliased_Register_1
(Disc : CCMR1_Discriminent := Output)
is record
case Disc is
when Output =>
Output : CCMR1_Output_Register_1;
when Input =>
Input : CCMR1_Input_Register_1;
end case;
end record
with Unchecked_Union;
for CCMR1_Aliased_Register_1 use record
Output at 0 range 0 .. 31;
Input at 0 range 0 .. 31;
end record;
type CCMR1_Aliased_Register_2
(Disc : CCMR1_Discriminent := Output)
is record
case Disc is
when Output =>
Output : CCMR1_Output_Register_2;
when Input =>
Input : CCMR1_Input_Register_2;
end case;
end record
with Unchecked_Union;
for CCMR1_Aliased_Register_2 use record
Output at 0 range 0 .. 31;
Input at 0 range 0 .. 31;
end record;
-----------------
-- Peripherals --
-----------------
-- General purpose timers
type TIM2_Peripheral is record
-- control register 1
CR1 : CR1_Register;
-- control register 2
CR2 : CR2_Register_1;
-- slave mode control register
SMCR : SMCR_Register;
-- DMA/Interrupt enable register
DIER : DIER_Register_1;
-- status register
SR : SR_Register_1;
-- event generation register
EGR : EGR_Register_1;
-- capture/compare mode register 1 (output mode)
CCMR1 : CCMR1_Aliased_Register;
-- capture/compare mode register 2 (output mode)
CCMR2 : CCMR2_Aliased_Register_1;
-- capture/compare enable register
CCER : CCER_Register_1;
-- counter
CNT : CNT_Register_1;
-- prescaler
PSC : PSC_Register;
-- auto-reload register
ARR : ARR_Register_1;
-- capture/compare register 1
CCR1 : CCR1_Register_1;
-- capture/compare register 2
CCR2 : CCR2_Register_1;
-- capture/compare register 3
CCR3 : CCR3_Register_1;
-- capture/compare register 4
CCR4 : CCR4_Register_1;
-- DMA control register
DCR : DCR_Register;
-- DMA address for full transfer
DMAR : DMAR_Register;
-- TIM5 option register
OR_k : OR_Register;
end record
with Volatile;
for TIM2_Peripheral use record
CR1 at 0 range 0 .. 31;
CR2 at 4 range 0 .. 31;
SMCR at 8 range 0 .. 31;
DIER at 12 range 0 .. 31;
SR at 16 range 0 .. 31;
EGR at 20 range 0 .. 31;
CCMR1 at 24 range 0 .. 31;
CCMR2 at 28 range 0 .. 31;
CCER at 32 range 0 .. 31;
CNT at 36 range 0 .. 31;
PSC at 40 range 0 .. 31;
ARR at 44 range 0 .. 31;
CCR1 at 52 range 0 .. 31;
CCR2 at 56 range 0 .. 31;
CCR3 at 60 range 0 .. 31;
CCR4 at 64 range 0 .. 31;
DCR at 72 range 0 .. 31;
DMAR at 76 range 0 .. 31;
OR_k at 80 range 0 .. 31;
end record;
-- General purpose timers
TIM2_Periph : aliased TIM2_Peripheral
with Import, Address => TIM2_Base;
-- General purpose timers
type TIM3_Peripheral is record
-- control register 1
CR1 : CR1_Register;
-- control register 2
CR2 : CR2_Register_1;
-- slave mode control register
SMCR : SMCR_Register;
-- DMA/Interrupt enable register
DIER : DIER_Register_1;
-- status register
SR : SR_Register_1;
-- event generation register
EGR : EGR_Register_1;
-- capture/compare mode register 1 (output mode)
CCMR1 : CCMR1_Aliased_Register;
-- capture/compare mode register 2 (output mode)
CCMR2 : CCMR2_Aliased_Register_1;
-- capture/compare enable register
CCER : CCER_Register_1;
-- counter
CNT : CNT_Register_1;
-- prescaler
PSC : PSC_Register;
-- auto-reload register
ARR : ARR_Register_1;
-- capture/compare register 1
CCR1 : CCR1_Register_1;
-- capture/compare register 2
CCR2 : CCR2_Register_1;
-- capture/compare register 3
CCR3 : CCR3_Register_1;
-- capture/compare register 4
CCR4 : CCR4_Register_1;
-- DMA control register
DCR : DCR_Register;
-- DMA address for full transfer
DMAR : DMAR_Register;
end record
with Volatile;
for TIM3_Peripheral use record
CR1 at 0 range 0 .. 31;
CR2 at 4 range 0 .. 31;
SMCR at 8 range 0 .. 31;
DIER at 12 range 0 .. 31;
SR at 16 range 0 .. 31;
EGR at 20 range 0 .. 31;
CCMR1 at 24 range 0 .. 31;
CCMR2 at 28 range 0 .. 31;
CCER at 32 range 0 .. 31;
CNT at 36 range 0 .. 31;
PSC at 40 range 0 .. 31;
ARR at 44 range 0 .. 31;
CCR1 at 52 range 0 .. 31;
CCR2 at 56 range 0 .. 31;
CCR3 at 60 range 0 .. 31;
CCR4 at 64 range 0 .. 31;
DCR at 72 range 0 .. 31;
DMAR at 76 range 0 .. 31;
end record;
-- General purpose timers
TIM3_Periph : aliased TIM3_Peripheral
with Import, Address => TIM3_Base;
-- General purpose timers
TIM4_Periph : aliased TIM3_Peripheral
with Import, Address => TIM4_Base;
-- General-purpose-timers
type TIM5_Peripheral is record
-- control register 1
CR1 : CR1_Register;
-- control register 2
CR2 : CR2_Register_1;
-- slave mode control register
SMCR : SMCR_Register;
-- DMA/Interrupt enable register
DIER : DIER_Register_1;
-- status register
SR : SR_Register_1;
-- event generation register
EGR : EGR_Register_1;
-- capture/compare mode register 1 (output mode)
CCMR1 : CCMR1_Aliased_Register;
-- capture/compare mode register 2 (output mode)
CCMR2 : CCMR2_Aliased_Register_1;
-- capture/compare enable register
CCER : CCER_Register_1;
-- counter
CNT : CNT_Register_1;
-- prescaler
PSC : PSC_Register;
-- auto-reload register
ARR : ARR_Register_1;
-- capture/compare register 1
CCR1 : CCR1_Register_1;
-- capture/compare register 2
CCR2 : CCR2_Register_1;
-- capture/compare register 3
CCR3 : CCR3_Register_1;
-- capture/compare register 4
CCR4 : CCR4_Register_1;
-- DMA control register
DCR : DCR_Register;
-- DMA address for full transfer
DMAR : DMAR_Register;
-- TIM5 option register
OR_k : OR_Register_1;
end record
with Volatile;
for TIM5_Peripheral use record
CR1 at 0 range 0 .. 31;
CR2 at 4 range 0 .. 31;
SMCR at 8 range 0 .. 31;
DIER at 12 range 0 .. 31;
SR at 16 range 0 .. 31;
EGR at 20 range 0 .. 31;
CCMR1 at 24 range 0 .. 31;
CCMR2 at 28 range 0 .. 31;
CCER at 32 range 0 .. 31;
CNT at 36 range 0 .. 31;
PSC at 40 range 0 .. 31;
ARR at 44 range 0 .. 31;
CCR1 at 52 range 0 .. 31;
CCR2 at 56 range 0 .. 31;
CCR3 at 60 range 0 .. 31;
CCR4 at 64 range 0 .. 31;
DCR at 72 range 0 .. 31;
DMAR at 76 range 0 .. 31;
OR_k at 80 range 0 .. 31;
end record;
-- General-purpose-timers
TIM5_Periph : aliased TIM5_Peripheral
with Import, Address => TIM5_Base;
-- Basic timers
type TIM6_Peripheral is record
-- control register 1
CR1 : CR1_Register_3;
-- control register 2
CR2 : CR2_Register_2;
-- DMA/Interrupt enable register
DIER : DIER_Register_4;
-- status register
SR : SR_Register_4;
-- event generation register
EGR : EGR_Register_4;
-- counter
CNT : CNT_Register;
-- prescaler
PSC : PSC_Register;
-- auto-reload register
ARR : ARR_Register;
end record
with Volatile;
for TIM6_Peripheral use record
CR1 at 0 range 0 .. 31;
CR2 at 4 range 0 .. 31;
DIER at 12 range 0 .. 31;
SR at 16 range 0 .. 31;
EGR at 20 range 0 .. 31;
CNT at 36 range 0 .. 31;
PSC at 40 range 0 .. 31;
ARR at 44 range 0 .. 31;
end record;
-- Basic timers
TIM6_Periph : aliased TIM6_Peripheral
with Import, Address => TIM6_Base;
-- Basic timers
TIM7_Periph : aliased TIM6_Peripheral
with Import, Address => TIM7_Base;
-- General purpose timers
type TIM12_Peripheral is record
-- control register 1
CR1 : CR1_Register_1;
-- control register 2
CR2 : CR2_Register_2;
-- slave mode control register
SMCR : SMCR_Register_1;
-- DMA/Interrupt enable register
DIER : DIER_Register_2;
-- status register
SR : SR_Register_2;
-- event generation register
EGR : EGR_Register_2;
-- capture/compare mode register 1 (output mode)
CCMR1 : CCMR1_Aliased_Register_1;
-- capture/compare enable register
CCER : CCER_Register_2;
-- counter
CNT : CNT_Register;
-- prescaler
PSC : PSC_Register;
-- auto-reload register
ARR : ARR_Register;
-- capture/compare register 1
CCR1 : CCR1_Register;
-- capture/compare register 2
CCR2 : CCR2_Register;
end record
with Volatile;
for TIM12_Peripheral use record
CR1 at 0 range 0 .. 31;
CR2 at 4 range 0 .. 31;
SMCR at 8 range 0 .. 31;
DIER at 12 range 0 .. 31;
SR at 16 range 0 .. 31;
EGR at 20 range 0 .. 31;
CCMR1 at 24 range 0 .. 31;
CCER at 32 range 0 .. 31;
CNT at 36 range 0 .. 31;
PSC at 40 range 0 .. 31;
ARR at 44 range 0 .. 31;
CCR1 at 52 range 0 .. 31;
CCR2 at 56 range 0 .. 31;
end record;
-- General purpose timers
TIM12_Periph : aliased TIM12_Peripheral
with Import, Address => TIM12_Base;
-- General purpose timers
TIM9_Periph : aliased TIM12_Peripheral
with Import, Address => TIM9_Base;
-- General-purpose-timers
type TIM13_Peripheral is record
-- control register 1
CR1 : CR1_Register_2;
-- DMA/Interrupt enable register
DIER : DIER_Register_3;
-- status register
SR : SR_Register_3;
-- event generation register
EGR : EGR_Register_3;
-- capture/compare mode register 1 (output mode)
CCMR1 : CCMR1_Aliased_Register_2;
-- capture/compare enable register
CCER : CCER_Register_3;
-- counter
CNT : CNT_Register;
-- prescaler
PSC : PSC_Register;
-- auto-reload register
ARR : ARR_Register;
-- capture/compare register 1
CCR1 : CCR1_Register;
end record
with Volatile;
for TIM13_Peripheral use record
CR1 at 0 range 0 .. 31;
DIER at 12 range 0 .. 31;
SR at 16 range 0 .. 31;
EGR at 20 range 0 .. 31;
CCMR1 at 24 range 0 .. 31;
CCER at 32 range 0 .. 31;
CNT at 36 range 0 .. 31;
PSC at 40 range 0 .. 31;
ARR at 44 range 0 .. 31;
CCR1 at 52 range 0 .. 31;
end record;
-- General-purpose-timers
TIM13_Periph : aliased TIM13_Peripheral
with Import, Address => TIM13_Base;
-- General-purpose-timers
TIM14_Periph : aliased TIM13_Peripheral
with Import, Address => TIM14_Base;
-- General-purpose-timers
TIM10_Periph : aliased TIM13_Peripheral
with Import, Address => TIM10_Base;
-- Advanced-timers
type TIM1_Peripheral is record
-- control register 1
CR1 : CR1_Register;
-- control register 2
CR2 : CR2_Register;
-- slave mode control register
SMCR : SMCR_Register;
-- DMA/Interrupt enable register
DIER : DIER_Register;
-- status register
SR : SR_Register;
-- event generation register
EGR : EGR_Register;
-- capture/compare mode register 1 (output mode)
CCMR1 : CCMR1_Aliased_Register;
-- capture/compare mode register 2 (output mode)
CCMR2 : CCMR2_Aliased_Register;
-- capture/compare enable register
CCER : CCER_Register;
-- counter
CNT : CNT_Register;
-- prescaler
PSC : PSC_Register;
-- auto-reload register
ARR : ARR_Register;
-- repetition counter register
RCR : RCR_Register;
-- capture/compare register 1
CCR1 : CCR1_Register;
-- capture/compare register 2
CCR2 : CCR2_Register;
-- capture/compare register 3
CCR3 : CCR3_Register;
-- capture/compare register 4
CCR4 : CCR4_Register;
-- break and dead-time register
BDTR : BDTR_Register;
-- DMA control register
DCR : DCR_Register;
-- DMA address for full transfer
DMAR : DMAR_Register;
end record
with Volatile;
for TIM1_Peripheral use record
CR1 at 0 range 0 .. 31;
CR2 at 4 range 0 .. 31;
SMCR at 8 range 0 .. 31;
DIER at 12 range 0 .. 31;
SR at 16 range 0 .. 31;
EGR at 20 range 0 .. 31;
CCMR1 at 24 range 0 .. 31;
CCMR2 at 28 range 0 .. 31;
CCER at 32 range 0 .. 31;
CNT at 36 range 0 .. 31;
PSC at 40 range 0 .. 31;
ARR at 44 range 0 .. 31;
RCR at 48 range 0 .. 31;
CCR1 at 52 range 0 .. 31;
CCR2 at 56 range 0 .. 31;
CCR3 at 60 range 0 .. 31;
CCR4 at 64 range 0 .. 31;
BDTR at 68 range 0 .. 31;
DCR at 72 range 0 .. 31;
DMAR at 76 range 0 .. 31;
end record;
-- Advanced-timers
TIM1_Periph : aliased TIM1_Peripheral
with Import, Address => TIM1_Base;
-- Advanced-timers
TIM8_Periph : aliased TIM1_Peripheral
with Import, Address => TIM8_Base;
-- General-purpose-timers
type TIM11_Peripheral is record
-- control register 1
CR1 : CR1_Register_2;
-- DMA/Interrupt enable register
DIER : DIER_Register_3;
-- status register
SR : SR_Register_3;
-- event generation register
EGR : EGR_Register_3;
-- capture/compare mode register 1 (output mode)
CCMR1 : CCMR1_Aliased_Register_2;
-- capture/compare enable register
CCER : CCER_Register_3;
-- counter
CNT : CNT_Register;
-- prescaler
PSC : PSC_Register;
-- auto-reload register
ARR : ARR_Register;
-- capture/compare register 1
CCR1 : CCR1_Register;
-- option register
OR_k : OR_Register_2;
end record
with Volatile;
for TIM11_Peripheral use record
CR1 at 0 range 0 .. 31;
DIER at 12 range 0 .. 31;
SR at 16 range 0 .. 31;
EGR at 20 range 0 .. 31;
CCMR1 at 24 range 0 .. 31;
CCER at 32 range 0 .. 31;
CNT at 36 range 0 .. 31;
PSC at 40 range 0 .. 31;
ARR at 44 range 0 .. 31;
CCR1 at 52 range 0 .. 31;
OR_k at 80 range 0 .. 31;
end record;
-- General-purpose-timers
TIM11_Periph : aliased TIM11_Peripheral
with Import, Address => TIM11_Base;
end STM32_SVD.TIM;
|
reznikmm/webdriver | Ada | 435 | ads | -- Copyright (c) 2017 Maxim Reznik <[email protected]>
--
-- SPDX-License-Identifier: MIT
-- License-Filename: LICENSE
-------------------------------------------------------------
with League.Strings;
with WebDriver.Drivers;
package WebDriver.Remote is
function Create
(URL : League.Strings.Universal_String)
return WebDriver.Drivers.Driver'Class;
-- Connect to server ("Remote end")
end WebDriver.Remote;
|
AdaCore/gpr | Ada | 1,728 | adb | --
-- Copyright (C) 2019-2023, AdaCore
--
-- SPDX-License-Identifier: Apache-2.0
--
with Ada.Text_IO;
with Ada.Strings.Fixed;
with GPR2.Context;
with GPR2.Log;
with GPR2.Message;
with GPR2.Project.Tree;
procedure Main is
use Ada;
use GPR2;
use GPR2.Project;
Prj : Project.Tree.Object;
Ctx : Context.Object;
begin
Project.Tree.Load (Prj, Create ("demo.gpr"), Ctx);
if Prj.Has_Messages then
Text_IO.Put_Line ("Messages found:");
for C in Prj.Log_Messages.Iterate
(False, True, True, True, True)
loop
declare
M : constant Message.Object := Log.Element (C);
Mes : constant String := M.Format;
L : constant Natural :=
Strings.Fixed.Index (Mes, "/duplicate-project");
begin
if L /= 0 then
Text_IO.Put_Line (Mes (L .. Mes'Last));
else
Text_IO.Put_Line (Mes);
end if;
end;
end loop;
end if;
exception
when GPR2.Project_Error =>
if Prj.Has_Messages then
Text_IO.Put_Line ("Error Messages found:");
for C in Prj.Log_Messages.Iterate
(True, False, True, True, True)
loop
declare
M : constant Message.Object := Log.Element (C);
Mes : constant String := M.Format;
L : constant Natural :=
Strings.Fixed.Index (Mes, "/duplicate-project");
begin
if L /= 0 then
Text_IO.Put_Line (Mes (L .. Mes'Last));
else
Text_IO.Put_Line (Mes);
end if;
end;
end loop;
end if;
end Main;
|
ekoeppen/MSP430_Generic_Ada_Drivers | Ada | 271 | ads | with Interfaces; use Interfaces;
package MSPGD is
pragma Preelaborate;
type Buffer_Type is array (Integer range <>) of Unsigned_8;
procedure Standby with Inline_Always;
procedure Stop with Inline_Always;
procedure Reset with Inline_Always;
end MSPGD;
|
zhmu/ananas | Ada | 4,435 | ads | ------------------------------------------------------------------------------
-- --
-- GNAT COMPILER COMPONENTS --
-- --
-- S Y S T E M . T R A C E B A C K --
-- --
-- S p e c --
-- --
-- Copyright (C) 1999-2022, Free Software Foundation, Inc. --
-- --
-- GNAT is free software; you can redistribute it and/or modify it under --
-- terms of the GNU General Public License as published by the Free Soft- --
-- ware Foundation; either version 3, or (at your option) any later ver- --
-- sion. GNAT is distributed in the hope that it will be useful, but WITH- --
-- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY --
-- or FITNESS FOR A PARTICULAR PURPOSE. --
-- --
-- As a special exception under Section 7 of GPL version 3, you are granted --
-- additional permissions described in the GCC Runtime Library Exception, --
-- version 3.1, as published by the Free Software Foundation. --
-- --
-- You should have received a copy of the GNU General Public License and --
-- a copy of the GCC Runtime Library Exception along with this program; --
-- see the files COPYING3 and COPYING.RUNTIME respectively. If not, see --
-- <http://www.gnu.org/licenses/>. --
-- --
-- GNAT was originally developed by the GNAT team at New York University. --
-- Extensive contributions were provided by Ada Core Technologies Inc. --
-- --
------------------------------------------------------------------------------
-- This package provides a method for generating a traceback of the current
-- execution location. The traceback shows the locations of calls in the call
-- chain, up to either the top or a designated number of levels.
with System.Traceback_Entries;
package System.Traceback is
----------------
-- Call_Chain --
----------------
procedure Call_Chain
(Traceback : in out System.Traceback_Entries.Tracebacks_Array;
Max_Len : Natural;
Len : out Natural;
Exclude_Min : System.Address := System.Null_Address;
Exclude_Max : System.Address := System.Null_Address;
Skip_Frames : Natural := 1);
-- Store up to Max_Len code locations in Traceback, corresponding to the
-- current call chain.
--
-- Traceback is an array of addresses where the result will be stored.
--
-- Max_Len is the length of the Traceback array. If the call chain is
-- longer than this, then additional entries are discarded, and the
-- traceback is missing some of the highest level entries.
--
-- Len is the number of addresses returned in the Traceback array
--
-- Exclude_Min/Exclude_Max, if non null, provide a range of addresses
-- to ignore from the computation of the traceback.
--
-- Skip_Frames says how many of the most recent calls should at least
-- be excluded from the result, regardless of the exclusion bounds and
-- starting with this procedure itself: 1 means exclude the frame for
-- this procedure, 2 means 1 + exclude the frame for this procedure's
-- caller, ...
--
-- On return, the Traceback array is filled in, and Len indicates the
-- number of stored entries. The first entry is the most recent call,
-- and the last entry is the highest level call.
function C_Call_Chain
(Traceback : System.Address;
Max_Len : Natural) return Natural;
pragma Export (C, C_Call_Chain, "system__traceback__c_call_chain");
-- Version that can be used directly from C
end System.Traceback;
|
AdaCore/Ada_Drivers_Library | Ada | 5,103 | ads | -- This spec has been automatically generated from STM32F429x.svd
pragma Restrictions (No_Elaboration_Code);
pragma Ada_2012;
pragma Style_Checks (Off);
with HAL;
with System;
package STM32_SVD.PWR is
pragma Preelaborate;
---------------
-- Registers --
---------------
subtype CR_PLS_Field is HAL.UInt3;
subtype CR_VOS_Field is HAL.UInt2;
subtype CR_UDEN_Field is HAL.UInt2;
-- power control register
type CR_Register is record
-- Low-power deep sleep
LPDS : Boolean := False;
-- Power down deepsleep
PDDS : Boolean := False;
-- Clear wakeup flag
CWUF : Boolean := False;
-- Clear standby flag
CSBF : Boolean := False;
-- Power voltage detector enable
PVDE : Boolean := False;
-- PVD level selection
PLS : CR_PLS_Field := 16#0#;
-- Disable backup domain write protection
DBP : Boolean := False;
-- Flash power down in Stop mode
FPDS : Boolean := False;
-- Low-Power Regulator Low Voltage in deepsleep
LPLVDS : Boolean := False;
-- Main regulator low voltage in deepsleep mode
MRLVDS : Boolean := False;
-- unspecified
Reserved_12_12 : HAL.Bit := 16#0#;
-- ADCDC1
ADCDC1 : Boolean := False;
-- Regulator voltage scaling output selection
VOS : CR_VOS_Field := 16#3#;
-- Over-drive enable
ODEN : Boolean := False;
-- Over-drive switching enabled
ODSWEN : Boolean := False;
-- Under-drive enable in stop mode
UDEN : CR_UDEN_Field := 16#0#;
-- unspecified
Reserved_20_31 : HAL.UInt12 := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for CR_Register use record
LPDS at 0 range 0 .. 0;
PDDS at 0 range 1 .. 1;
CWUF at 0 range 2 .. 2;
CSBF at 0 range 3 .. 3;
PVDE at 0 range 4 .. 4;
PLS at 0 range 5 .. 7;
DBP at 0 range 8 .. 8;
FPDS at 0 range 9 .. 9;
LPLVDS at 0 range 10 .. 10;
MRLVDS at 0 range 11 .. 11;
Reserved_12_12 at 0 range 12 .. 12;
ADCDC1 at 0 range 13 .. 13;
VOS at 0 range 14 .. 15;
ODEN at 0 range 16 .. 16;
ODSWEN at 0 range 17 .. 17;
UDEN at 0 range 18 .. 19;
Reserved_20_31 at 0 range 20 .. 31;
end record;
subtype CSR_UDRDY_Field is HAL.UInt2;
-- power control/status register
type CSR_Register is record
-- Read-only. Wakeup flag
WUF : Boolean := False;
-- Read-only. Standby flag
SBF : Boolean := False;
-- Read-only. PVD output
PVDO : Boolean := False;
-- Read-only. Backup regulator ready
BRR : Boolean := False;
-- unspecified
Reserved_4_7 : HAL.UInt4 := 16#0#;
-- Enable WKUP pin
EWUP : Boolean := False;
-- Backup regulator enable
BRE : Boolean := False;
-- unspecified
Reserved_10_13 : HAL.UInt4 := 16#0#;
-- Regulator voltage scaling output selection ready bit
VOSRDY : Boolean := False;
-- unspecified
Reserved_15_15 : HAL.Bit := 16#0#;
-- Read-only. Over-drive mode ready
ODRDY : Boolean := False;
-- Read-only. Over-drive mode switching ready
ODSWRDY : Boolean := False;
-- Under-drive ready flag
UDRDY : CSR_UDRDY_Field := 16#0#;
-- unspecified
Reserved_20_31 : HAL.UInt12 := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for CSR_Register use record
WUF at 0 range 0 .. 0;
SBF at 0 range 1 .. 1;
PVDO at 0 range 2 .. 2;
BRR at 0 range 3 .. 3;
Reserved_4_7 at 0 range 4 .. 7;
EWUP at 0 range 8 .. 8;
BRE at 0 range 9 .. 9;
Reserved_10_13 at 0 range 10 .. 13;
VOSRDY at 0 range 14 .. 14;
Reserved_15_15 at 0 range 15 .. 15;
ODRDY at 0 range 16 .. 16;
ODSWRDY at 0 range 17 .. 17;
UDRDY at 0 range 18 .. 19;
Reserved_20_31 at 0 range 20 .. 31;
end record;
-----------------
-- Peripherals --
-----------------
-- Power control
type PWR_Peripheral is record
-- power control register
CR : aliased CR_Register;
-- power control/status register
CSR : aliased CSR_Register;
end record
with Volatile;
for PWR_Peripheral use record
CR at 16#0# range 0 .. 31;
CSR at 16#4# range 0 .. 31;
end record;
-- Power control
PWR_Periph : aliased PWR_Peripheral
with Import, Address => System'To_Address (16#40007000#);
end STM32_SVD.PWR;
|
zhmu/ananas | Ada | 516 | adb | package body Opt77_Pkg is
function Compare (S : String) return Boolean is
begin
return S = "Two";
end;
procedure Proc (S : String; N : in out Natural; To_Add : out Boolean) is
To_Take : Boolean := False;
To_Read : Boolean := False;
begin
To_Add := False;
if S = "One" then
To_Read := True;
To_Take := Compare (S);
end if;
if To_Read and not To_Take then
N := N + 1;
end if;
if To_Take then
To_Add := True;
end if;
end;
end Opt77_Pkg;
|
Componolit/libsparkcrypto | Ada | 2,328 | ads | -------------------------------------------------------------------------------
-- This file is part of libsparkcrypto.
--
-- Copyright (C) 2010, Alexander Senier
-- Copyright (C) 2010, secunet Security Networks AG
-- 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 nor the names of its contributors may be used
-- to endorse or promote products derived from this software without
-- specific prior written permission.
--
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
-- AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
-- IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
-- ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS
-- BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
-- CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
-- SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
-- INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
-- CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
-- ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
-- POSSIBILITY OF SUCH DAMAGE.
-------------------------------------------------------------------------------
with LSC.Internal.Types;
-------------------------------------------------------------------------------
-- Byte swapping for 64-bit words
-------------------------------------------------------------------------------
package LSC.Internal.Byteswap64
with
SPARK_Mode => On
is
pragma Pure;
-- Byte-swap @Value@
function Swap (Value : Types.Word64) return Types.Word64;
pragma Inline (Swap);
end LSC.Internal.Byteswap64;
|
osannolik/Ada_Drivers_Library | Ada | 26,232 | ads | -- This spec has been automatically generated from STM32F446x.svd
pragma Restrictions (No_Elaboration_Code);
pragma Ada_2012;
pragma Style_Checks (Off);
with HAL;
with System;
package STM32_SVD.ADC is
pragma Preelaborate;
---------------
-- Registers --
---------------
-- status register
type SR_Register is record
-- Analog watchdog flag
AWD : Boolean := False;
-- Regular channel end of conversion
EOC : Boolean := False;
-- Injected channel end of conversion
JEOC : Boolean := False;
-- Injected channel start flag
JSTRT : Boolean := False;
-- Regular channel start flag
STRT : Boolean := False;
-- Overrun
OVR : Boolean := False;
-- unspecified
Reserved_6_31 : HAL.UInt26 := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for SR_Register use record
AWD at 0 range 0 .. 0;
EOC at 0 range 1 .. 1;
JEOC at 0 range 2 .. 2;
JSTRT at 0 range 3 .. 3;
STRT at 0 range 4 .. 4;
OVR at 0 range 5 .. 5;
Reserved_6_31 at 0 range 6 .. 31;
end record;
subtype CR1_AWDCH_Field is HAL.UInt5;
subtype CR1_DISCNUM_Field is HAL.UInt3;
subtype CR1_RES_Field is HAL.UInt2;
-- control register 1
type CR1_Register is record
-- Analog watchdog channel select bits
AWDCH : CR1_AWDCH_Field := 16#0#;
-- Interrupt enable for EOC
EOCIE : Boolean := False;
-- Analog watchdog interrupt enable
AWDIE : Boolean := False;
-- Interrupt enable for injected channels
JEOCIE : Boolean := False;
-- Scan mode
SCAN : Boolean := False;
-- Enable the watchdog on a single channel in scan mode
AWDSGL : Boolean := False;
-- Automatic injected group conversion
JAUTO : Boolean := False;
-- Discontinuous mode on regular channels
DISCEN : Boolean := False;
-- Discontinuous mode on injected channels
JDISCEN : Boolean := False;
-- Discontinuous mode channel count
DISCNUM : CR1_DISCNUM_Field := 16#0#;
-- unspecified
Reserved_16_21 : HAL.UInt6 := 16#0#;
-- Analog watchdog enable on injected channels
JAWDEN : Boolean := False;
-- Analog watchdog enable on regular channels
AWDEN : Boolean := False;
-- Resolution
RES : CR1_RES_Field := 16#0#;
-- Overrun interrupt enable
OVRIE : Boolean := False;
-- unspecified
Reserved_27_31 : HAL.UInt5 := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for CR1_Register use record
AWDCH at 0 range 0 .. 4;
EOCIE at 0 range 5 .. 5;
AWDIE at 0 range 6 .. 6;
JEOCIE at 0 range 7 .. 7;
SCAN at 0 range 8 .. 8;
AWDSGL at 0 range 9 .. 9;
JAUTO at 0 range 10 .. 10;
DISCEN at 0 range 11 .. 11;
JDISCEN at 0 range 12 .. 12;
DISCNUM at 0 range 13 .. 15;
Reserved_16_21 at 0 range 16 .. 21;
JAWDEN at 0 range 22 .. 22;
AWDEN at 0 range 23 .. 23;
RES at 0 range 24 .. 25;
OVRIE at 0 range 26 .. 26;
Reserved_27_31 at 0 range 27 .. 31;
end record;
subtype CR2_JEXTSEL_Field is HAL.UInt4;
subtype CR2_JEXTEN_Field is HAL.UInt2;
subtype CR2_EXTSEL_Field is HAL.UInt4;
subtype CR2_EXTEN_Field is HAL.UInt2;
-- control register 2
type CR2_Register is record
-- A/D Converter ON / OFF
ADON : Boolean := False;
-- Continuous conversion
CONT : Boolean := False;
-- unspecified
Reserved_2_7 : HAL.UInt6 := 16#0#;
-- Direct memory access mode (for single ADC mode)
DMA : Boolean := False;
-- DMA disable selection (for single ADC mode)
DDS : Boolean := False;
-- End of conversion selection
EOCS : Boolean := False;
-- Data alignment
ALIGN : Boolean := False;
-- unspecified
Reserved_12_15 : HAL.UInt4 := 16#0#;
-- External event select for injected group
JEXTSEL : CR2_JEXTSEL_Field := 16#0#;
-- External trigger enable for injected channels
JEXTEN : CR2_JEXTEN_Field := 16#0#;
-- Start conversion of injected channels
JSWSTART : Boolean := False;
-- unspecified
Reserved_23_23 : HAL.Bit := 16#0#;
-- External event select for regular group
EXTSEL : CR2_EXTSEL_Field := 16#0#;
-- External trigger enable for regular channels
EXTEN : CR2_EXTEN_Field := 16#0#;
-- Start conversion of regular channels
SWSTART : Boolean := False;
-- unspecified
Reserved_31_31 : HAL.Bit := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for CR2_Register use record
ADON at 0 range 0 .. 0;
CONT at 0 range 1 .. 1;
Reserved_2_7 at 0 range 2 .. 7;
DMA at 0 range 8 .. 8;
DDS at 0 range 9 .. 9;
EOCS at 0 range 10 .. 10;
ALIGN at 0 range 11 .. 11;
Reserved_12_15 at 0 range 12 .. 15;
JEXTSEL at 0 range 16 .. 19;
JEXTEN at 0 range 20 .. 21;
JSWSTART at 0 range 22 .. 22;
Reserved_23_23 at 0 range 23 .. 23;
EXTSEL at 0 range 24 .. 27;
EXTEN at 0 range 28 .. 29;
SWSTART at 0 range 30 .. 30;
Reserved_31_31 at 0 range 31 .. 31;
end record;
-- SMPR1_SMP array element
subtype SMPR1_SMP_Element is HAL.UInt3;
-- SMPR1_SMP array
type SMPR1_SMP_Field_Array is array (10 .. 18) of SMPR1_SMP_Element
with Component_Size => 3, Size => 27;
-- Type definition for SMPR1_SMP
type SMPR1_SMP_Field
(As_Array : Boolean := False)
is record
case As_Array is
when False =>
-- SMP as a value
Val : HAL.UInt27;
when True =>
-- SMP as an array
Arr : SMPR1_SMP_Field_Array;
end case;
end record
with Unchecked_Union, Size => 27;
for SMPR1_SMP_Field use record
Val at 0 range 0 .. 26;
Arr at 0 range 0 .. 26;
end record;
-- sample time register 1
type SMPR1_Register is record
-- Sample time bits
SMP : SMPR1_SMP_Field := (As_Array => False, Val => 16#0#);
-- unspecified
Reserved_27_31 : HAL.UInt5 := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for SMPR1_Register use record
SMP at 0 range 0 .. 26;
Reserved_27_31 at 0 range 27 .. 31;
end record;
-- SMPR2_SMP array element
subtype SMPR2_SMP_Element is HAL.UInt3;
-- SMPR2_SMP array
type SMPR2_SMP_Field_Array is array (0 .. 9) of SMPR2_SMP_Element
with Component_Size => 3, Size => 30;
-- Type definition for SMPR2_SMP
type SMPR2_SMP_Field
(As_Array : Boolean := False)
is record
case As_Array is
when False =>
-- SMP as a value
Val : HAL.UInt30;
when True =>
-- SMP as an array
Arr : SMPR2_SMP_Field_Array;
end case;
end record
with Unchecked_Union, Size => 30;
for SMPR2_SMP_Field use record
Val at 0 range 0 .. 29;
Arr at 0 range 0 .. 29;
end record;
-- sample time register 2
type SMPR2_Register is record
-- Sample time bits
SMP : SMPR2_SMP_Field := (As_Array => False, Val => 16#0#);
-- unspecified
Reserved_30_31 : HAL.UInt2 := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for SMPR2_Register use record
SMP at 0 range 0 .. 29;
Reserved_30_31 at 0 range 30 .. 31;
end record;
subtype JOFR1_JOFFSET1_Field is HAL.UInt12;
-- injected channel data offset register x
type JOFR1_Register is record
-- Data offset for injected channel x
JOFFSET1 : JOFR1_JOFFSET1_Field := 16#0#;
-- unspecified
Reserved_12_31 : HAL.UInt20 := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for JOFR1_Register use record
JOFFSET1 at 0 range 0 .. 11;
Reserved_12_31 at 0 range 12 .. 31;
end record;
subtype JOFR2_JOFFSET2_Field is HAL.UInt12;
-- injected channel data offset register x
type JOFR2_Register is record
-- Data offset for injected channel x
JOFFSET2 : JOFR2_JOFFSET2_Field := 16#0#;
-- unspecified
Reserved_12_31 : HAL.UInt20 := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for JOFR2_Register use record
JOFFSET2 at 0 range 0 .. 11;
Reserved_12_31 at 0 range 12 .. 31;
end record;
subtype JOFR3_JOFFSET3_Field is HAL.UInt12;
-- injected channel data offset register x
type JOFR3_Register is record
-- Data offset for injected channel x
JOFFSET3 : JOFR3_JOFFSET3_Field := 16#0#;
-- unspecified
Reserved_12_31 : HAL.UInt20 := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for JOFR3_Register use record
JOFFSET3 at 0 range 0 .. 11;
Reserved_12_31 at 0 range 12 .. 31;
end record;
subtype JOFR4_JOFFSET4_Field is HAL.UInt12;
-- injected channel data offset register x
type JOFR4_Register is record
-- Data offset for injected channel x
JOFFSET4 : JOFR4_JOFFSET4_Field := 16#0#;
-- unspecified
Reserved_12_31 : HAL.UInt20 := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for JOFR4_Register use record
JOFFSET4 at 0 range 0 .. 11;
Reserved_12_31 at 0 range 12 .. 31;
end record;
subtype HTR_HT_Field is HAL.UInt12;
-- watchdog higher threshold register
type HTR_Register is record
-- Analog watchdog higher threshold
HT : HTR_HT_Field := 16#FFF#;
-- unspecified
Reserved_12_31 : HAL.UInt20 := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for HTR_Register use record
HT at 0 range 0 .. 11;
Reserved_12_31 at 0 range 12 .. 31;
end record;
subtype LTR_LT_Field is HAL.UInt12;
-- watchdog lower threshold register
type LTR_Register is record
-- Analog watchdog lower threshold
LT : LTR_LT_Field := 16#0#;
-- unspecified
Reserved_12_31 : HAL.UInt20 := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for LTR_Register use record
LT at 0 range 0 .. 11;
Reserved_12_31 at 0 range 12 .. 31;
end record;
-- SQR1_SQ array element
subtype SQR1_SQ_Element is HAL.UInt5;
-- SQR1_SQ array
type SQR1_SQ_Field_Array is array (13 .. 16) of SQR1_SQ_Element
with Component_Size => 5, Size => 20;
-- Type definition for SQR1_SQ
type SQR1_SQ_Field
(As_Array : Boolean := False)
is record
case As_Array is
when False =>
-- SQ as a value
Val : HAL.UInt20;
when True =>
-- SQ as an array
Arr : SQR1_SQ_Field_Array;
end case;
end record
with Unchecked_Union, Size => 20;
for SQR1_SQ_Field use record
Val at 0 range 0 .. 19;
Arr at 0 range 0 .. 19;
end record;
subtype SQR1_L_Field is HAL.UInt4;
-- regular sequence register 1
type SQR1_Register is record
-- 13th conversion in regular sequence
SQ : SQR1_SQ_Field := (As_Array => False, Val => 16#0#);
-- Regular channel sequence length
L : SQR1_L_Field := 16#0#;
-- unspecified
Reserved_24_31 : HAL.UInt8 := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for SQR1_Register use record
SQ at 0 range 0 .. 19;
L at 0 range 20 .. 23;
Reserved_24_31 at 0 range 24 .. 31;
end record;
-- SQR2_SQ array element
subtype SQR2_SQ_Element is HAL.UInt5;
-- SQR2_SQ array
type SQR2_SQ_Field_Array is array (7 .. 12) of SQR2_SQ_Element
with Component_Size => 5, Size => 30;
-- Type definition for SQR2_SQ
type SQR2_SQ_Field
(As_Array : Boolean := False)
is record
case As_Array is
when False =>
-- SQ as a value
Val : HAL.UInt30;
when True =>
-- SQ as an array
Arr : SQR2_SQ_Field_Array;
end case;
end record
with Unchecked_Union, Size => 30;
for SQR2_SQ_Field use record
Val at 0 range 0 .. 29;
Arr at 0 range 0 .. 29;
end record;
-- regular sequence register 2
type SQR2_Register is record
-- 7th conversion in regular sequence
SQ : SQR2_SQ_Field := (As_Array => False, Val => 16#0#);
-- unspecified
Reserved_30_31 : HAL.UInt2 := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for SQR2_Register use record
SQ at 0 range 0 .. 29;
Reserved_30_31 at 0 range 30 .. 31;
end record;
-- SQR3_SQ array element
subtype SQR3_SQ_Element is HAL.UInt5;
-- SQR3_SQ array
type SQR3_SQ_Field_Array is array (1 .. 6) of SQR3_SQ_Element
with Component_Size => 5, Size => 30;
-- Type definition for SQR3_SQ
type SQR3_SQ_Field
(As_Array : Boolean := False)
is record
case As_Array is
when False =>
-- SQ as a value
Val : HAL.UInt30;
when True =>
-- SQ as an array
Arr : SQR3_SQ_Field_Array;
end case;
end record
with Unchecked_Union, Size => 30;
for SQR3_SQ_Field use record
Val at 0 range 0 .. 29;
Arr at 0 range 0 .. 29;
end record;
-- regular sequence register 3
type SQR3_Register is record
-- 1st conversion in regular sequence
SQ : SQR3_SQ_Field := (As_Array => False, Val => 16#0#);
-- unspecified
Reserved_30_31 : HAL.UInt2 := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for SQR3_Register use record
SQ at 0 range 0 .. 29;
Reserved_30_31 at 0 range 30 .. 31;
end record;
-- JSQR_JSQ array element
subtype JSQR_JSQ_Element is HAL.UInt5;
-- JSQR_JSQ array
type JSQR_JSQ_Field_Array is array (1 .. 4) of JSQR_JSQ_Element
with Component_Size => 5, Size => 20;
-- Type definition for JSQR_JSQ
type JSQR_JSQ_Field
(As_Array : Boolean := False)
is record
case As_Array is
when False =>
-- JSQ as a value
Val : HAL.UInt20;
when True =>
-- JSQ as an array
Arr : JSQR_JSQ_Field_Array;
end case;
end record
with Unchecked_Union, Size => 20;
for JSQR_JSQ_Field use record
Val at 0 range 0 .. 19;
Arr at 0 range 0 .. 19;
end record;
subtype JSQR_JL_Field is HAL.UInt2;
-- injected sequence register
type JSQR_Register is record
-- 1st conversion in injected sequence
JSQ : JSQR_JSQ_Field := (As_Array => False, Val => 16#0#);
-- Injected sequence length
JL : JSQR_JL_Field := 16#0#;
-- unspecified
Reserved_22_31 : HAL.UInt10 := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for JSQR_Register use record
JSQ at 0 range 0 .. 19;
JL at 0 range 20 .. 21;
Reserved_22_31 at 0 range 22 .. 31;
end record;
subtype JDR_JDATA_Field is HAL.UInt16;
-- injected data register x
type JDR_Register is record
-- Read-only. Injected data
JDATA : JDR_JDATA_Field;
-- unspecified
Reserved_16_31 : HAL.UInt16;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for JDR_Register use record
JDATA at 0 range 0 .. 15;
Reserved_16_31 at 0 range 16 .. 31;
end record;
subtype DR_DATA_Field is HAL.UInt16;
-- regular data register
type DR_Register is record
-- Read-only. Regular data
DATA : DR_DATA_Field;
-- unspecified
Reserved_16_31 : HAL.UInt16;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for DR_Register use record
DATA at 0 range 0 .. 15;
Reserved_16_31 at 0 range 16 .. 31;
end record;
-- ADC Common status register
type CSR_Register is record
-- Read-only. Analog watchdog flag of ADC 1
AWD1 : Boolean;
-- Read-only. End of conversion of ADC 1
EOC1 : Boolean;
-- Read-only. Injected channel end of conversion of ADC 1
JEOC1 : Boolean;
-- Read-only. Injected channel Start flag of ADC 1
JSTRT1 : Boolean;
-- Read-only. Regular channel Start flag of ADC 1
STRT1 : Boolean;
-- Read-only. Overrun flag of ADC 1
OVR1 : Boolean;
-- unspecified
Reserved_6_7 : HAL.UInt2;
-- Read-only. Analog watchdog flag of ADC 2
AWD2 : Boolean;
-- Read-only. End of conversion of ADC 2
EOC2 : Boolean;
-- Read-only. Injected channel end of conversion of ADC 2
JEOC2 : Boolean;
-- Read-only. Injected channel Start flag of ADC 2
JSTRT2 : Boolean;
-- Read-only. Regular channel Start flag of ADC 2
STRT2 : Boolean;
-- Read-only. Overrun flag of ADC 2
OVR2 : Boolean;
-- unspecified
Reserved_14_15 : HAL.UInt2;
-- Read-only. Analog watchdog flag of ADC 3
AWD3 : Boolean;
-- Read-only. End of conversion of ADC 3
EOC3 : Boolean;
-- Read-only. Injected channel end of conversion of ADC 3
JEOC3 : Boolean;
-- Read-only. Injected channel Start flag of ADC 3
JSTRT3 : Boolean;
-- Read-only. Regular channel Start flag of ADC 3
STRT3 : Boolean;
-- Read-only. Overrun flag of ADC3
OVR3 : Boolean;
-- unspecified
Reserved_22_31 : HAL.UInt10;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for CSR_Register use record
AWD1 at 0 range 0 .. 0;
EOC1 at 0 range 1 .. 1;
JEOC1 at 0 range 2 .. 2;
JSTRT1 at 0 range 3 .. 3;
STRT1 at 0 range 4 .. 4;
OVR1 at 0 range 5 .. 5;
Reserved_6_7 at 0 range 6 .. 7;
AWD2 at 0 range 8 .. 8;
EOC2 at 0 range 9 .. 9;
JEOC2 at 0 range 10 .. 10;
JSTRT2 at 0 range 11 .. 11;
STRT2 at 0 range 12 .. 12;
OVR2 at 0 range 13 .. 13;
Reserved_14_15 at 0 range 14 .. 15;
AWD3 at 0 range 16 .. 16;
EOC3 at 0 range 17 .. 17;
JEOC3 at 0 range 18 .. 18;
JSTRT3 at 0 range 19 .. 19;
STRT3 at 0 range 20 .. 20;
OVR3 at 0 range 21 .. 21;
Reserved_22_31 at 0 range 22 .. 31;
end record;
subtype CCR_MULT_Field is HAL.UInt5;
subtype CCR_DELAY_Field is HAL.UInt4;
subtype CCR_DMA_Field is HAL.UInt2;
subtype CCR_ADCPRE_Field is HAL.UInt2;
-- ADC common control register
type CCR_Register is record
-- Multi ADC mode selection
MULT : CCR_MULT_Field := 16#0#;
-- unspecified
Reserved_5_7 : HAL.UInt3 := 16#0#;
-- Delay between 2 sampling phases
DELAY_k : CCR_DELAY_Field := 16#0#;
-- unspecified
Reserved_12_12 : HAL.Bit := 16#0#;
-- DMA disable selection for multi-ADC mode
DDS : Boolean := False;
-- Direct memory access mode for multi ADC mode
DMA : CCR_DMA_Field := 16#0#;
-- ADC prescaler
ADCPRE : CCR_ADCPRE_Field := 16#0#;
-- unspecified
Reserved_18_21 : HAL.UInt4 := 16#0#;
-- VBAT enable
VBATE : Boolean := False;
-- Temperature sensor and VREFINT enable
TSVREFE : Boolean := False;
-- unspecified
Reserved_24_31 : HAL.UInt8 := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for CCR_Register use record
MULT at 0 range 0 .. 4;
Reserved_5_7 at 0 range 5 .. 7;
DELAY_k at 0 range 8 .. 11;
Reserved_12_12 at 0 range 12 .. 12;
DDS at 0 range 13 .. 13;
DMA at 0 range 14 .. 15;
ADCPRE at 0 range 16 .. 17;
Reserved_18_21 at 0 range 18 .. 21;
VBATE at 0 range 22 .. 22;
TSVREFE at 0 range 23 .. 23;
Reserved_24_31 at 0 range 24 .. 31;
end record;
-- CDR_DATA array element
subtype CDR_DATA_Element is HAL.UInt16;
-- CDR_DATA array
type CDR_DATA_Field_Array is array (1 .. 2) of CDR_DATA_Element
with Component_Size => 16, Size => 32;
-- ADC common regular data register for dual and triple modes
type CDR_Register
(As_Array : Boolean := False)
is record
case As_Array is
when False =>
-- DATA as a value
Val : HAL.UInt32;
when True =>
-- DATA as an array
Arr : CDR_DATA_Field_Array;
end case;
end record
with Unchecked_Union, Size => 32, Volatile_Full_Access,
Bit_Order => System.Low_Order_First;
for CDR_Register use record
Val at 0 range 0 .. 31;
Arr at 0 range 0 .. 31;
end record;
-----------------
-- Peripherals --
-----------------
-- Analog-to-digital converter
type ADC1_Peripheral is record
-- status register
SR : aliased SR_Register;
-- control register 1
CR1 : aliased CR1_Register;
-- control register 2
CR2 : aliased CR2_Register;
-- sample time register 1
SMPR1 : aliased SMPR1_Register;
-- sample time register 2
SMPR2 : aliased SMPR2_Register;
-- injected channel data offset register x
JOFR1 : aliased JOFR1_Register;
-- injected channel data offset register x
JOFR2 : aliased JOFR2_Register;
-- injected channel data offset register x
JOFR3 : aliased JOFR3_Register;
-- injected channel data offset register x
JOFR4 : aliased JOFR4_Register;
-- watchdog higher threshold register
HTR : aliased HTR_Register;
-- watchdog lower threshold register
LTR : aliased LTR_Register;
-- regular sequence register 1
SQR1 : aliased SQR1_Register;
-- regular sequence register 2
SQR2 : aliased SQR2_Register;
-- regular sequence register 3
SQR3 : aliased SQR3_Register;
-- injected sequence register
JSQR : aliased JSQR_Register;
-- injected data register x
JDR1 : aliased JDR_Register;
-- injected data register x
JDR2 : aliased JDR_Register;
-- injected data register x
JDR3 : aliased JDR_Register;
-- injected data register x
JDR4 : aliased JDR_Register;
-- regular data register
DR : aliased DR_Register;
end record
with Volatile;
for ADC1_Peripheral use record
SR at 16#0# range 0 .. 31;
CR1 at 16#4# range 0 .. 31;
CR2 at 16#8# range 0 .. 31;
SMPR1 at 16#C# range 0 .. 31;
SMPR2 at 16#10# range 0 .. 31;
JOFR1 at 16#14# range 0 .. 31;
JOFR2 at 16#18# range 0 .. 31;
JOFR3 at 16#1C# range 0 .. 31;
JOFR4 at 16#20# range 0 .. 31;
HTR at 16#24# range 0 .. 31;
LTR at 16#28# range 0 .. 31;
SQR1 at 16#2C# range 0 .. 31;
SQR2 at 16#30# range 0 .. 31;
SQR3 at 16#34# range 0 .. 31;
JSQR at 16#38# range 0 .. 31;
JDR1 at 16#3C# range 0 .. 31;
JDR2 at 16#40# range 0 .. 31;
JDR3 at 16#44# range 0 .. 31;
JDR4 at 16#48# range 0 .. 31;
DR at 16#4C# range 0 .. 31;
end record;
-- Analog-to-digital converter
ADC1_Periph : aliased ADC1_Peripheral
with Import, Address => System'To_Address (16#40012000#);
-- Analog-to-digital converter
ADC2_Periph : aliased ADC1_Peripheral
with Import, Address => System'To_Address (16#40012100#);
-- Analog-to-digital converter
ADC3_Periph : aliased ADC1_Peripheral
with Import, Address => System'To_Address (16#40012200#);
-- Common ADC registers
type C_ADC_Peripheral is record
-- ADC Common status register
CSR : aliased CSR_Register;
-- ADC common control register
CCR : aliased CCR_Register;
-- ADC common regular data register for dual and triple modes
CDR : aliased CDR_Register;
end record
with Volatile;
for C_ADC_Peripheral use record
CSR at 16#0# range 0 .. 31;
CCR at 16#4# range 0 .. 31;
CDR at 16#8# range 0 .. 31;
end record;
-- Common ADC registers
C_ADC_Periph : aliased C_ADC_Peripheral
with Import, Address => System'To_Address (16#40012300#);
end STM32_SVD.ADC;
|
AdaCore/Ada_Drivers_Library | Ada | 17,180 | ads | -- This spec has been automatically generated from STM32F46_79x.svd
pragma Restrictions (No_Elaboration_Code);
pragma Ada_2012;
pragma Style_Checks (Off);
with HAL;
with System;
package STM32_SVD.DMA2D is
pragma Preelaborate;
---------------
-- Registers --
---------------
subtype CR_MODE_Field is HAL.UInt2;
-- control register
type CR_Register is record
-- Start
START : Boolean := False;
-- Suspend
SUSP : Boolean := False;
-- Abort
ABORT_k : Boolean := False;
-- unspecified
Reserved_3_7 : HAL.UInt5 := 16#0#;
-- Transfer error interrupt enable
TEIE : Boolean := False;
-- Transfer complete interrupt enable
TCIE : Boolean := False;
-- Transfer watermark interrupt enable
TWIE : Boolean := False;
-- CLUT access error interrupt enable
CAEIE : Boolean := False;
-- CLUT transfer complete interrupt enable
CTCIE : Boolean := False;
-- Configuration Error Interrupt Enable
CEIE : Boolean := False;
-- unspecified
Reserved_14_15 : HAL.UInt2 := 16#0#;
-- DMA2D mode
MODE : CR_MODE_Field := 16#0#;
-- unspecified
Reserved_18_31 : HAL.UInt14 := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for CR_Register use record
START at 0 range 0 .. 0;
SUSP at 0 range 1 .. 1;
ABORT_k at 0 range 2 .. 2;
Reserved_3_7 at 0 range 3 .. 7;
TEIE at 0 range 8 .. 8;
TCIE at 0 range 9 .. 9;
TWIE at 0 range 10 .. 10;
CAEIE at 0 range 11 .. 11;
CTCIE at 0 range 12 .. 12;
CEIE at 0 range 13 .. 13;
Reserved_14_15 at 0 range 14 .. 15;
MODE at 0 range 16 .. 17;
Reserved_18_31 at 0 range 18 .. 31;
end record;
-- Interrupt Status Register
type ISR_Register is record
-- Read-only. Transfer error interrupt flag
TEIF : Boolean;
-- Read-only. Transfer complete interrupt flag
TCIF : Boolean;
-- Read-only. Transfer watermark interrupt flag
TWIF : Boolean;
-- Read-only. CLUT access error interrupt flag
CAEIF : Boolean;
-- Read-only. CLUT transfer complete interrupt flag
CTCIF : Boolean;
-- Read-only. Configuration error interrupt flag
CEIF : Boolean;
-- unspecified
Reserved_6_31 : HAL.UInt26;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for ISR_Register use record
TEIF at 0 range 0 .. 0;
TCIF at 0 range 1 .. 1;
TWIF at 0 range 2 .. 2;
CAEIF at 0 range 3 .. 3;
CTCIF at 0 range 4 .. 4;
CEIF at 0 range 5 .. 5;
Reserved_6_31 at 0 range 6 .. 31;
end record;
-- interrupt flag clear register
type IFCR_Register is record
-- Clear Transfer error interrupt flag
CTEIF : Boolean := False;
-- Clear transfer complete interrupt flag
CTCIF : Boolean := False;
-- Clear transfer watermark interrupt flag
CTWIF : Boolean := False;
-- Clear CLUT access error interrupt flag
CAECIF : Boolean := False;
-- Clear CLUT transfer complete interrupt flag
CCTCIF : Boolean := False;
-- Clear configuration error interrupt flag
CCEIF : Boolean := False;
-- unspecified
Reserved_6_31 : HAL.UInt26 := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for IFCR_Register use record
CTEIF at 0 range 0 .. 0;
CTCIF at 0 range 1 .. 1;
CTWIF at 0 range 2 .. 2;
CAECIF at 0 range 3 .. 3;
CCTCIF at 0 range 4 .. 4;
CCEIF at 0 range 5 .. 5;
Reserved_6_31 at 0 range 6 .. 31;
end record;
subtype FGOR_LO_Field is HAL.UInt14;
-- foreground offset register
type FGOR_Register is record
-- Line offset
LO : FGOR_LO_Field := 16#0#;
-- unspecified
Reserved_14_31 : HAL.UInt18 := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for FGOR_Register use record
LO at 0 range 0 .. 13;
Reserved_14_31 at 0 range 14 .. 31;
end record;
subtype BGOR_LO_Field is HAL.UInt14;
-- background offset register
type BGOR_Register is record
-- Line offset
LO : BGOR_LO_Field := 16#0#;
-- unspecified
Reserved_14_31 : HAL.UInt18 := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for BGOR_Register use record
LO at 0 range 0 .. 13;
Reserved_14_31 at 0 range 14 .. 31;
end record;
subtype FGPFCCR_CM_Field is HAL.UInt4;
subtype FGPFCCR_CS_Field is HAL.UInt8;
subtype FGPFCCR_AM_Field is HAL.UInt2;
subtype FGPFCCR_ALPHA_Field is HAL.UInt8;
-- foreground PFC control register
type FGPFCCR_Register is record
-- Color mode
CM : FGPFCCR_CM_Field := 16#0#;
-- CLUT color mode
CCM : Boolean := False;
-- Start
START : Boolean := False;
-- unspecified
Reserved_6_7 : HAL.UInt2 := 16#0#;
-- CLUT size
CS : FGPFCCR_CS_Field := 16#0#;
-- Alpha mode
AM : FGPFCCR_AM_Field := 16#0#;
-- unspecified
Reserved_18_23 : HAL.UInt6 := 16#0#;
-- Alpha value
ALPHA : FGPFCCR_ALPHA_Field := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for FGPFCCR_Register use record
CM at 0 range 0 .. 3;
CCM at 0 range 4 .. 4;
START at 0 range 5 .. 5;
Reserved_6_7 at 0 range 6 .. 7;
CS at 0 range 8 .. 15;
AM at 0 range 16 .. 17;
Reserved_18_23 at 0 range 18 .. 23;
ALPHA at 0 range 24 .. 31;
end record;
subtype FGCOLR_BLUE_Field is HAL.UInt8;
subtype FGCOLR_GREEN_Field is HAL.UInt8;
subtype FGCOLR_RED_Field is HAL.UInt8;
-- foreground color register
type FGCOLR_Register is record
-- Blue Value
BLUE : FGCOLR_BLUE_Field := 16#0#;
-- Green Value
GREEN : FGCOLR_GREEN_Field := 16#0#;
-- Red Value
RED : FGCOLR_RED_Field := 16#0#;
-- unspecified
Reserved_24_31 : HAL.UInt8 := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for FGCOLR_Register use record
BLUE at 0 range 0 .. 7;
GREEN at 0 range 8 .. 15;
RED at 0 range 16 .. 23;
Reserved_24_31 at 0 range 24 .. 31;
end record;
subtype BGPFCCR_CM_Field is HAL.UInt4;
subtype BGPFCCR_CS_Field is HAL.UInt8;
subtype BGPFCCR_AM_Field is HAL.UInt2;
subtype BGPFCCR_ALPHA_Field is HAL.UInt8;
-- background PFC control register
type BGPFCCR_Register is record
-- Color mode
CM : BGPFCCR_CM_Field := 16#0#;
-- CLUT Color mode
CCM : Boolean := False;
-- Start
START : Boolean := False;
-- unspecified
Reserved_6_7 : HAL.UInt2 := 16#0#;
-- CLUT size
CS : BGPFCCR_CS_Field := 16#0#;
-- Alpha mode
AM : BGPFCCR_AM_Field := 16#0#;
-- unspecified
Reserved_18_23 : HAL.UInt6 := 16#0#;
-- Alpha value
ALPHA : BGPFCCR_ALPHA_Field := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for BGPFCCR_Register use record
CM at 0 range 0 .. 3;
CCM at 0 range 4 .. 4;
START at 0 range 5 .. 5;
Reserved_6_7 at 0 range 6 .. 7;
CS at 0 range 8 .. 15;
AM at 0 range 16 .. 17;
Reserved_18_23 at 0 range 18 .. 23;
ALPHA at 0 range 24 .. 31;
end record;
subtype BGCOLR_BLUE_Field is HAL.UInt8;
subtype BGCOLR_GREEN_Field is HAL.UInt8;
subtype BGCOLR_RED_Field is HAL.UInt8;
-- background color register
type BGCOLR_Register is record
-- Blue Value
BLUE : BGCOLR_BLUE_Field := 16#0#;
-- Green Value
GREEN : BGCOLR_GREEN_Field := 16#0#;
-- Red Value
RED : BGCOLR_RED_Field := 16#0#;
-- unspecified
Reserved_24_31 : HAL.UInt8 := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for BGCOLR_Register use record
BLUE at 0 range 0 .. 7;
GREEN at 0 range 8 .. 15;
RED at 0 range 16 .. 23;
Reserved_24_31 at 0 range 24 .. 31;
end record;
subtype OPFCCR_CM_Field is HAL.UInt3;
-- output PFC control register
type OPFCCR_Register is record
-- Color mode
CM : OPFCCR_CM_Field := 16#0#;
-- unspecified
Reserved_3_31 : HAL.UInt29 := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for OPFCCR_Register use record
CM at 0 range 0 .. 2;
Reserved_3_31 at 0 range 3 .. 31;
end record;
subtype OCOLR_BLUE_Field is HAL.UInt8;
subtype OCOLR_GREEN_Field is HAL.UInt8;
subtype OCOLR_RED_Field is HAL.UInt8;
subtype OCOLR_APLHA_Field is HAL.UInt8;
-- output color register
type OCOLR_Register is record
-- Blue Value
BLUE : OCOLR_BLUE_Field := 16#0#;
-- Green Value
GREEN : OCOLR_GREEN_Field := 16#0#;
-- Red Value
RED : OCOLR_RED_Field := 16#0#;
-- Alpha Channel Value
APLHA : OCOLR_APLHA_Field := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for OCOLR_Register use record
BLUE at 0 range 0 .. 7;
GREEN at 0 range 8 .. 15;
RED at 0 range 16 .. 23;
APLHA at 0 range 24 .. 31;
end record;
subtype OOR_LO_Field is HAL.UInt14;
-- output offset register
type OOR_Register is record
-- Line Offset
LO : OOR_LO_Field := 16#0#;
-- unspecified
Reserved_14_31 : HAL.UInt18 := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for OOR_Register use record
LO at 0 range 0 .. 13;
Reserved_14_31 at 0 range 14 .. 31;
end record;
subtype NLR_NL_Field is HAL.UInt16;
subtype NLR_PL_Field is HAL.UInt14;
-- number of line register
type NLR_Register is record
-- Number of lines
NL : NLR_NL_Field := 16#0#;
-- Pixel per lines
PL : NLR_PL_Field := 16#0#;
-- unspecified
Reserved_30_31 : HAL.UInt2 := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for NLR_Register use record
NL at 0 range 0 .. 15;
PL at 0 range 16 .. 29;
Reserved_30_31 at 0 range 30 .. 31;
end record;
subtype LWR_LW_Field is HAL.UInt16;
-- line watermark register
type LWR_Register is record
-- Line watermark
LW : LWR_LW_Field := 16#0#;
-- unspecified
Reserved_16_31 : HAL.UInt16 := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for LWR_Register use record
LW at 0 range 0 .. 15;
Reserved_16_31 at 0 range 16 .. 31;
end record;
subtype AMTCR_DT_Field is HAL.UInt8;
-- AHB master timer configuration register
type AMTCR_Register is record
-- Enable
EN : Boolean := False;
-- unspecified
Reserved_1_7 : HAL.UInt7 := 16#0#;
-- Dead Time
DT : AMTCR_DT_Field := 16#0#;
-- unspecified
Reserved_16_31 : HAL.UInt16 := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for AMTCR_Register use record
EN at 0 range 0 .. 0;
Reserved_1_7 at 0 range 1 .. 7;
DT at 0 range 8 .. 15;
Reserved_16_31 at 0 range 16 .. 31;
end record;
subtype FGCLUT_BLUE_Field is HAL.UInt8;
subtype FGCLUT_GREEN_Field is HAL.UInt8;
subtype FGCLUT_RED_Field is HAL.UInt8;
subtype FGCLUT_APLHA_Field is HAL.UInt8;
-- FGCLUT
type FGCLUT_Register is record
-- BLUE
BLUE : FGCLUT_BLUE_Field := 16#0#;
-- GREEN
GREEN : FGCLUT_GREEN_Field := 16#0#;
-- RED
RED : FGCLUT_RED_Field := 16#0#;
-- APLHA
APLHA : FGCLUT_APLHA_Field := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for FGCLUT_Register use record
BLUE at 0 range 0 .. 7;
GREEN at 0 range 8 .. 15;
RED at 0 range 16 .. 23;
APLHA at 0 range 24 .. 31;
end record;
subtype BGCLUT_BLUE_Field is HAL.UInt8;
subtype BGCLUT_GREEN_Field is HAL.UInt8;
subtype BGCLUT_RED_Field is HAL.UInt8;
subtype BGCLUT_APLHA_Field is HAL.UInt8;
-- BGCLUT
type BGCLUT_Register is record
-- BLUE
BLUE : BGCLUT_BLUE_Field := 16#0#;
-- GREEN
GREEN : BGCLUT_GREEN_Field := 16#0#;
-- RED
RED : BGCLUT_RED_Field := 16#0#;
-- APLHA
APLHA : BGCLUT_APLHA_Field := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for BGCLUT_Register use record
BLUE at 0 range 0 .. 7;
GREEN at 0 range 8 .. 15;
RED at 0 range 16 .. 23;
APLHA at 0 range 24 .. 31;
end record;
-----------------
-- Peripherals --
-----------------
-- DMA2D controller
type DMA2D_Peripheral is record
-- control register
CR : aliased CR_Register;
-- Interrupt Status Register
ISR : aliased ISR_Register;
-- interrupt flag clear register
IFCR : aliased IFCR_Register;
-- foreground memory address register
FGMAR : aliased HAL.UInt32;
-- foreground offset register
FGOR : aliased FGOR_Register;
-- background memory address register
BGMAR : aliased HAL.UInt32;
-- background offset register
BGOR : aliased BGOR_Register;
-- foreground PFC control register
FGPFCCR : aliased FGPFCCR_Register;
-- foreground color register
FGCOLR : aliased FGCOLR_Register;
-- background PFC control register
BGPFCCR : aliased BGPFCCR_Register;
-- background color register
BGCOLR : aliased BGCOLR_Register;
-- foreground CLUT memory address register
FGCMAR : aliased HAL.UInt32;
-- background CLUT memory address register
BGCMAR : aliased HAL.UInt32;
-- output PFC control register
OPFCCR : aliased OPFCCR_Register;
-- output color register
OCOLR : aliased OCOLR_Register;
-- output memory address register
OMAR : aliased HAL.UInt32;
-- output offset register
OOR : aliased OOR_Register;
-- number of line register
NLR : aliased NLR_Register;
-- line watermark register
LWR : aliased LWR_Register;
-- AHB master timer configuration register
AMTCR : aliased AMTCR_Register;
-- FGCLUT
FGCLUT : aliased FGCLUT_Register;
-- BGCLUT
BGCLUT : aliased BGCLUT_Register;
end record
with Volatile;
for DMA2D_Peripheral use record
CR at 16#0# range 0 .. 31;
ISR at 16#4# range 0 .. 31;
IFCR at 16#8# range 0 .. 31;
FGMAR at 16#C# range 0 .. 31;
FGOR at 16#10# range 0 .. 31;
BGMAR at 16#14# range 0 .. 31;
BGOR at 16#18# range 0 .. 31;
FGPFCCR at 16#1C# range 0 .. 31;
FGCOLR at 16#20# range 0 .. 31;
BGPFCCR at 16#24# range 0 .. 31;
BGCOLR at 16#28# range 0 .. 31;
FGCMAR at 16#2C# range 0 .. 31;
BGCMAR at 16#30# range 0 .. 31;
OPFCCR at 16#34# range 0 .. 31;
OCOLR at 16#38# range 0 .. 31;
OMAR at 16#3C# range 0 .. 31;
OOR at 16#40# range 0 .. 31;
NLR at 16#44# range 0 .. 31;
LWR at 16#48# range 0 .. 31;
AMTCR at 16#4C# range 0 .. 31;
FGCLUT at 16#400# range 0 .. 31;
BGCLUT at 16#800# range 0 .. 31;
end record;
-- DMA2D controller
DMA2D_Periph : aliased DMA2D_Peripheral
with Import, Address => System'To_Address (16#4002B000#);
end STM32_SVD.DMA2D;
|
danva994/AdaSDL2 | Ada | 263 | adb | package body SDL.Image is
procedure SDL_IMAGE_VERSION (X : access SDL_version) is
begin
X.major := SDL_IMAGE_MAJOR_VERSION;
X.minor := SDL_IMAGE_MINOR_VERSION;
X.patch := SDL_IMAGE_PATCHLEVEL;
end SDL_IMAGE_VERSION;
end SDL.Image;
|
optikos/oasis | Ada | 2,305 | ads | -- Copyright (c) 2019 Maxim Reznik <[email protected]>
--
-- SPDX-License-Identifier: MIT
-- License-Filename: LICENSE
-------------------------------------------------------------
with Program.Lexical_Elements;
with Program.Contexts;
package Program.Compilations is
pragma Pure;
-- A specific Compilation value is valid (usable) for as long as the
-- Context variable, used to create it, remains open. Once an Context is
-- closed, all associated Compilation values become invalid. It is
-- erroneous to use an invalid Compilation value.
type Compilation is limited interface;
-- The Ada Compilation abstraction:
--
-- The text of a program is submitted to the compiler in one or more
-- compilations. Each compilation is a succession of compilation units.
type Compilation_Access is access all Compilation'Class
with Storage_Size => 0;
function Is_Assigned (Self : access Compilation'Class) return Boolean
is (Self /= null);
not overriding function Context (Self : Compilation)
return not null Program.Contexts.Context_Access is abstract;
-- Return corresponding context
not overriding function Text_Name
(Self : Compilation) return Text is abstract;
-- Returns the name of the text, or other structure, that was the source of
-- the compilation that resulted in this Compilation. Returns a null string
-- if the text name is not available for any reason.
not overriding function Object_Name
(Self : Compilation) return Text is abstract;
-- Returns the name of the object, or other structure, that contains the
-- binary result of the compilation for this Compilation. Returns a null
-- string if the object name is not available for any reason.
not overriding function Line_Count
(Self : Compilation) return Natural is abstract;
not overriding function Line
(Self : Compilation;
Index : Positive) return Text is abstract;
not overriding function Lexical_Element_Count
(Self : Compilation) return Natural is abstract;
not overriding function Lexical_Element
(Self : Compilation;
Index : Positive) return Program.Lexical_Elements.Lexical_Element_Access
is abstract;
-- TODO: Compilation_Pragmas?
end Program.Compilations;
|
reznikmm/matreshka | Ada | 4,266 | ads | ------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- Ada Modeling Framework --
-- --
-- Runtime Library Component --
-- --
------------------------------------------------------------------------------
-- --
-- Copyright © 2012, Vadim Godunko <[email protected]> --
-- All rights reserved. --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions --
-- are met: --
-- --
-- * Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- --
-- * Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in the --
-- documentation and/or other materials provided with the distribution. --
-- --
-- * Neither the name of the Vadim Godunko, IE nor the names of its --
-- contributors may be used to endorse or promote products derived from --
-- this software without specific prior written permission. --
-- --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR --
-- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
-- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED --
-- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR --
-- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF --
-- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING --
-- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS --
-- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
-- --
------------------------------------------------------------------------------
-- $Revision$ $Date$
------------------------------------------------------------------------------
-- This package contains conversion subprograms from different subclasses of
-- elements into holders. They are required to simplify generated code,
-- otherwise creation of intermediate object should be done in reflections
-- module. Most probably this package can be removed for Ada2020.
------------------------------------------------------------------------------
with AMF.UMLDI.UML_Diagram_Elements;
with AMF.UMLDI.UML_Labels;
with AMF.UMLDI.UML_Styles;
package AMF.Internals.Holders.UMLDI_Holders is
function To_Holder
(Item : AMF.UMLDI.UML_Diagram_Elements.UMLDI_UML_Diagram_Element_Access)
return League.Holders.Holder;
function To_Holder
(Item : AMF.UMLDI.UML_Labels.UMLDI_UML_Label_Access)
return League.Holders.Holder;
function To_Holder
(Item : AMF.UMLDI.UML_Styles.UMLDI_UML_Style_Access)
return League.Holders.Holder;
end AMF.Internals.Holders.UMLDI_Holders;
|
tum-ei-rcs/StratoX | Ada | 9,156 | ads | ------------------------------------------------------------------------------
-- --
-- GNAT RUN-TIME COMPONENTS --
-- --
-- S Y S T E M . U N S I G N E D _ T Y P E S --
-- --
-- S p e c --
-- --
-- Copyright (C) 1992-2016, Free Software Foundation, Inc. --
-- --
-- GNAT is free software; you can redistribute it and/or modify it under --
-- terms of the GNU General Public License as published by the Free Soft- --
-- ware Foundation; either version 3, or (at your option) any later ver- --
-- sion. GNAT is distributed in the hope that it will be useful, but WITH- --
-- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY --
-- or FITNESS FOR A PARTICULAR PURPOSE. --
-- --
-- --
-- --
-- --
-- --
-- You should have received a copy of the GNU General Public License and --
-- a copy of the GCC Runtime Library Exception along with this program; --
-- see the files COPYING3 and COPYING.RUNTIME respectively. If not, see --
-- <http://www.gnu.org/licenses/>. --
-- --
-- GNAT was originally developed by the GNAT team at New York University. --
-- Extensive contributions were provided by Ada Core Technologies Inc. --
-- --
------------------------------------------------------------------------------
-- This package contains definitions of standard unsigned types that
-- correspond in size to the standard signed types declared in Standard,
-- and (unlike the types in Interfaces) have corresponding names. It
-- also contains some related definitions for other specialized types
-- used by the compiler in connection with packed array types.
pragma Compiler_Unit_Warning;
package System.Unsigned_Types is
pragma Pure;
pragma No_Elaboration_Code_All;
type Short_Short_Unsigned is mod 2 ** Short_Short_Integer'Size;
type Short_Unsigned is mod 2 ** Short_Integer'Size;
type Unsigned is mod 2 ** Integer'Size;
type Long_Unsigned is mod 2 ** Long_Integer'Size;
type Long_Long_Unsigned is mod 2 ** Long_Long_Integer'Size;
type Float_Unsigned is mod 2 ** Float'Size;
-- Used in the implementation of Is_Negative intrinsic (see Exp_Intr)
type Packed_Byte is mod 2 ** 8;
pragma Universal_Aliasing (Packed_Byte);
for Packed_Byte'Size use 8;
-- Component type for Packed_Bytes1, Packed_Bytes2 and Packed_Byte4 arrays.
-- As this type is used by the compiler to implement operations on user
-- packed array, it needs to be able to alias any type.
type Packed_Bytes1 is array (Natural range <>) of aliased Packed_Byte;
for Packed_Bytes1'Alignment use 1;
for Packed_Bytes1'Component_Size use Packed_Byte'Size;
pragma Suppress_Initialization (Packed_Bytes1);
-- This is the type used to implement packed arrays where no alignment
-- is required. This includes the cases of 1,2,4 (where we use direct
-- masking operations), and all odd component sizes (where the clusters
-- are not aligned anyway, see, e.g. System.Pack_07 in file s-pack07
-- for details.
type Packed_Bytes2 is new Packed_Bytes1;
for Packed_Bytes2'Alignment use Integer'Min (2, Standard'Maximum_Alignment);
pragma Suppress_Initialization (Packed_Bytes2);
-- This is the type used to implement packed arrays where an alignment
-- of 2 (is possible) is helpful for maximum efficiency of the get and
-- set routines in the corresponding library unit. This is true of all
-- component sizes that are even but not divisible by 4 (other than 2 for
-- which we use direct masking operations). In such cases, the clusters
-- can be assumed to be 2-byte aligned if the array is aligned. See for
-- example System.Pack_10 in file s-pack10).
type Packed_Bytes4 is new Packed_Bytes1;
for Packed_Bytes4'Alignment use Integer'Min (4, Standard'Maximum_Alignment);
pragma Suppress_Initialization (Packed_Bytes4);
-- This is the type used to implement packed arrays where an alignment
-- of 4 (if possible) is helpful for maximum efficiency of the get and
-- set routines in the corresponding library unit. This is true of all
-- component sizes that are divisible by 4 (other than powers of 2, which
-- are either handled by direct masking or not packed at all). In such
-- cases the clusters can be assumed to be 4-byte aligned if the array
-- is aligned (see System.Pack_12 in file s-pack12 as an example).
type Bits_1 is mod 2**1;
type Bits_2 is mod 2**2;
type Bits_4 is mod 2**4;
-- Types used for packed array conversions
subtype Bytes_F is Packed_Bytes4 (1 .. Float'Size / 8);
-- Type used in implementation of Is_Negative intrinsic (see Exp_Intr)
function Shift_Left
(Value : Short_Short_Unsigned;
Amount : Natural) return Short_Short_Unsigned;
function Shift_Right
(Value : Short_Short_Unsigned;
Amount : Natural) return Short_Short_Unsigned;
function Shift_Right_Arithmetic
(Value : Short_Short_Unsigned;
Amount : Natural) return Short_Short_Unsigned;
function Rotate_Left
(Value : Short_Short_Unsigned;
Amount : Natural) return Short_Short_Unsigned;
function Rotate_Right
(Value : Short_Short_Unsigned;
Amount : Natural) return Short_Short_Unsigned;
function Shift_Left
(Value : Short_Unsigned;
Amount : Natural) return Short_Unsigned;
function Shift_Right
(Value : Short_Unsigned;
Amount : Natural) return Short_Unsigned;
function Shift_Right_Arithmetic
(Value : Short_Unsigned;
Amount : Natural) return Short_Unsigned;
function Rotate_Left
(Value : Short_Unsigned;
Amount : Natural) return Short_Unsigned;
function Rotate_Right
(Value : Short_Unsigned;
Amount : Natural) return Short_Unsigned;
function Shift_Left
(Value : Unsigned;
Amount : Natural) return Unsigned;
function Shift_Right
(Value : Unsigned;
Amount : Natural) return Unsigned;
function Shift_Right_Arithmetic
(Value : Unsigned;
Amount : Natural) return Unsigned;
function Rotate_Left
(Value : Unsigned;
Amount : Natural) return Unsigned;
function Rotate_Right
(Value : Unsigned;
Amount : Natural) return Unsigned;
function Shift_Left
(Value : Long_Unsigned;
Amount : Natural) return Long_Unsigned;
function Shift_Right
(Value : Long_Unsigned;
Amount : Natural) return Long_Unsigned;
function Shift_Right_Arithmetic
(Value : Long_Unsigned;
Amount : Natural) return Long_Unsigned;
function Rotate_Left
(Value : Long_Unsigned;
Amount : Natural) return Long_Unsigned;
function Rotate_Right
(Value : Long_Unsigned;
Amount : Natural) return Long_Unsigned;
function Shift_Left
(Value : Long_Long_Unsigned;
Amount : Natural) return Long_Long_Unsigned;
function Shift_Right
(Value : Long_Long_Unsigned;
Amount : Natural) return Long_Long_Unsigned;
function Shift_Right_Arithmetic
(Value : Long_Long_Unsigned;
Amount : Natural) return Long_Long_Unsigned;
function Rotate_Left
(Value : Long_Long_Unsigned;
Amount : Natural) return Long_Long_Unsigned;
function Rotate_Right
(Value : Long_Long_Unsigned;
Amount : Natural) return Long_Long_Unsigned;
pragma Import (Intrinsic, Shift_Left);
pragma Import (Intrinsic, Shift_Right);
pragma Import (Intrinsic, Shift_Right_Arithmetic);
pragma Import (Intrinsic, Rotate_Left);
pragma Import (Intrinsic, Rotate_Right);
-- The following definitions are obsolescent. They were needed by the
-- previous version of the compiler and runtime, but are not needed
-- by the current version. We retain them to help with bootstrap path
-- problems. Also they seem harmless, and if any user programs have
-- been using these types, why discombobulate them?
subtype Packed_Bytes is Packed_Bytes4;
subtype Packed_Bytes_Unaligned is Packed_Bytes1;
end System.Unsigned_Types;
|
reznikmm/matreshka | Ada | 4,932 | ads | ------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- Ada Modeling Framework --
-- --
-- Runtime Library Component --
-- --
------------------------------------------------------------------------------
-- --
-- Copyright © 2011-2012, Vadim Godunko <[email protected]> --
-- All rights reserved. --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions --
-- are met: --
-- --
-- * Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- --
-- * Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in the --
-- documentation and/or other materials provided with the distribution. --
-- --
-- * Neither the name of the Vadim Godunko, IE nor the names of its --
-- contributors may be used to endorse or promote products derived from --
-- this software without specific prior written permission. --
-- --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR --
-- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
-- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED --
-- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR --
-- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF --
-- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING --
-- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS --
-- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
-- --
------------------------------------------------------------------------------
-- $Revision$ $Date$
------------------------------------------------------------------------------
-- This file is generated, don't edit it.
------------------------------------------------------------------------------
with AMF.Generic_Collections;
package AMF.UML.Namespaces.Collections is
pragma Preelaborate;
package UML_Namespace_Collections is
new AMF.Generic_Collections
(UML_Namespace,
UML_Namespace_Access);
type Set_Of_UML_Namespace is
new UML_Namespace_Collections.Set with null record;
Empty_Set_Of_UML_Namespace : constant Set_Of_UML_Namespace;
type Ordered_Set_Of_UML_Namespace is
new UML_Namespace_Collections.Ordered_Set with null record;
Empty_Ordered_Set_Of_UML_Namespace : constant Ordered_Set_Of_UML_Namespace;
type Bag_Of_UML_Namespace is
new UML_Namespace_Collections.Bag with null record;
Empty_Bag_Of_UML_Namespace : constant Bag_Of_UML_Namespace;
type Sequence_Of_UML_Namespace is
new UML_Namespace_Collections.Sequence with null record;
Empty_Sequence_Of_UML_Namespace : constant Sequence_Of_UML_Namespace;
private
Empty_Set_Of_UML_Namespace : constant Set_Of_UML_Namespace
:= (UML_Namespace_Collections.Set with null record);
Empty_Ordered_Set_Of_UML_Namespace : constant Ordered_Set_Of_UML_Namespace
:= (UML_Namespace_Collections.Ordered_Set with null record);
Empty_Bag_Of_UML_Namespace : constant Bag_Of_UML_Namespace
:= (UML_Namespace_Collections.Bag with null record);
Empty_Sequence_Of_UML_Namespace : constant Sequence_Of_UML_Namespace
:= (UML_Namespace_Collections.Sequence with null record);
end AMF.UML.Namespaces.Collections;
|
ekoeppen/STM32_Generic_Ada_Drivers | Ada | 986 | adb | with STM32GD.Systick; use STM32GD.Systick;
with STM32GD.Vectors;
with STM32_SVD; use STM32_SVD;
package body Monotonic_Counter is
procedure SysTick_Handler;
pragma Machine_Attribute (SysTick_Handler, "naked");
Vectors: STM32GD.Vectors.IRQ_Vectors := (
SysTick_Handler => Monotonic_Counter.SysTick_Handler'Address,
others => STM32GD.Vectors.Default_Handler'Address
) with Export;
pragma Linker_Section (Vectors, ".vectors");
procedure SysTick_Handler is
begin
Counter := Counter + 1;
if Counter = 0 then
Overflow := True;
end if;
end SysTick_Handler;
procedure Reset is
begin
Counter := 0;
Overflow := False;
Systick_Periph.RVR := (
RELOAD => 8_000_000 / 8_000);
Systick_Periph.CSR := (
ENABLE => 1,
TICKINT => 1,
CLKSOURCE => 1,
COUNTFLAG => 0,
Reserved_3_15 => 0,
Reserved_17_31 => 0);
end Reset;
end Monotonic_Counter;
|
LionelDraghi/smk | Ada | 3,006 | ads | -- -----------------------------------------------------------------------------
-- 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
-- -----------------------------------------------------------------------------
package List_Image.Unix_Predefined_Styles is
EOL : constant String := Unix_EOL;
-- Note that two identical packages exist, named :
-- List_Image.[Unix|Windows]_Predefined_Styles
-- The only difference between those packages is this platform specific
-- EOL definition.
-- --------------------------------------------------------------------------
-- Predefined multi-line style
-- --------------------------------------------------------------------------
--
-- - Bulleted_List_Style :
-- > - A
-- > - B
-- > - C
--
-- - Markdown_Bulleted_List_Style :
-- Like the bulleted list, but surrounded by
-- two empty lines (in some Markdown implementation, if the first bullet
-- is not preceded by an empty line, the list is not recognized)
--
-- - HTML_Bulleted_List_Style :
-- > <ul>
-- > <li>A</li>
-- > <li>B</li>
-- > <li>C</li>
-- > </ul>
-- Note : <ul></ul>, an empty list, is recognized by most navigator,
-- but seems to be illegal html.
-- No problem here, thanks to _If_Empty parameters nothing will
-- be generated if the list is empty.
--
-- --------------------------------------------------------------------------
package Bulleted_List_Style is new Image_Style
(Prefix => EOL & "- ",
Separator => EOL & "- ",
Postfix => EOL,
Prefix_If_Empty => "",
Postfix_If_Empty => "");
package Markdown_Bulleted_List_Style is new Image_Style
(Prefix => EOL & EOL & "- ",
Separator => EOL & "- ",
Postfix => EOL & EOL,
Prefix_If_Empty => EOL,
Postfix_If_Empty => "");
package HTML_Bulleted_List_Style is new Image_Style
(Prefix => "<ul>" & EOL & " <li>",
Separator => "</li>" & EOL & " <li>",
Postfix => "</li>" & EOL & "</ul>",
Prefix_If_Empty => "",
Postfix_If_Empty => "");
end List_Image.Unix_Predefined_Styles;
|
alexcamposruiz/dds-requestreply | Ada | 982 | ads | with DDS;
with Dds.DomainParticipant;
with DDS.Publisher;
with DDS.Subscriber;
with Ada.Finalization;
package DDS.Entity_Params is
type RTI_Connext_EntityParams is new Ada.Finalization.Limited_Controlled with record
Participant : DDS.DomainParticipant.Ref_Access;
Service_Name : DDS.String;
Request_Topic_Name : DDS.String;
Reply_Topic_Name : DDS.String;
Qos_Library_Name : DDS.String;
Qos_Profile_Name : DDS.String;
Datawriter_Qos : DDS.DataWriterQos;
Datareader_Qos : DDS.DataReaderQos;
Publisher : DDS.Publisher.Ref_Access;
Subscriber : DDS.Subscriber.Ref_Access;
end record;
subtype EntityParams is RTI_Connext_EntityParams;
function Validate (Self : RTI_Connext_EntityParams) return DDS.Boolean;
procedure Initialize (Object : in out RTI_Connext_EntityParams);
procedure Finalize (Object : in out RTI_Connext_EntityParams);
end DDS.Entity_Params;
|
reznikmm/matreshka | Ada | 4,033 | ads | ------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- Open Document Toolkit --
-- --
-- Runtime Library Component --
-- --
------------------------------------------------------------------------------
-- --
-- Copyright © 2014, Vadim Godunko <[email protected]> --
-- All rights reserved. --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions --
-- are met: --
-- --
-- * Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- --
-- * Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in the --
-- documentation and/or other materials provided with the distribution. --
-- --
-- * Neither the name of the Vadim Godunko, IE nor the names of its --
-- contributors may be used to endorse or promote products derived from --
-- this software without specific prior written permission. --
-- --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR --
-- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
-- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED --
-- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR --
-- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF --
-- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING --
-- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS --
-- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
-- --
------------------------------------------------------------------------------
-- $Revision$ $Date$
------------------------------------------------------------------------------
with ODF.DOM.Meta_Syllable_Count_Attributes;
package Matreshka.ODF_Meta.Syllable_Count_Attributes is
type Meta_Syllable_Count_Attribute_Node is
new Matreshka.ODF_Meta.Abstract_Meta_Attribute_Node
and ODF.DOM.Meta_Syllable_Count_Attributes.ODF_Meta_Syllable_Count_Attribute
with null record;
overriding function Create
(Parameters : not null access Matreshka.DOM_Attributes.Attribute_L2_Parameters)
return Meta_Syllable_Count_Attribute_Node;
overriding function Get_Local_Name
(Self : not null access constant Meta_Syllable_Count_Attribute_Node)
return League.Strings.Universal_String;
end Matreshka.ODF_Meta.Syllable_Count_Attributes;
|
ScottWLoyd/ada_dynamic_libs | Ada | 2,129 | adb | with Ada.Text_IO; use Ada.Text_IO;
with Interfaces.C;
with Ada.Unchecked_Conversion;
with Ada.Unchecked_Deallocation;
with Ada.Directories; use Ada.Directories;
with System;
with Ada.Calendar;
procedure Main is
type LPCSTR is access constant Interfaces.C.char; -- winnt.h
pragma Convention (C, LPCSTR);
function LoadLibrary (lpLibFileName : LPCSTR) return System.Address;
pragma Import (Stdcall, LoadLibrary, "LoadLibraryA");
-- winbase.h :3619
type PROC is access function return Interfaces.C.int; -- windef.h :175
pragma Convention (Stdcall, PROC);
subtype FARPROC is PROC; -- windef.h :173
function GetProcAddress (hModule : System.Address; lpProcName : LPCSTR) return FARPROC; -- winbase.h :997
pragma Import (Stdcall, GetProcAddress, "GetProcAddress"); -- winbase.h :997
function As_LPCSTR is new Ada.Unchecked_Conversion (Source => System.Address, Target => LPCSTR);
S : Search_Type;
D : Directory_Entry_Type;
Only_Files : constant Filter_Type := (Ordinary_File => True, others => False);
Dll_Name : constant String := "libtest.dll";
C_Name : aliased constant String := Dll_Name & ASCII.nul;
Proc_Name : aliased constant String := "do_stuff" & ASCII.nul;
Waiting : Boolean := True;
begin
while Waiting loop
Start_Search(S, ".", Dll_Name, Only_Files);
if More_Entries(S) then
Get_Next_Entry(S, D);
declare
use Ada.Calendar;
use type System.Address;
Lib_Handle : System.Address := System.Null_Address;
Do_Stuff_Handle : FARPROC;
Ignored : Interfaces.C.int;
begin
-- Plug-in file is older than 5 seconds, we do not want to try
-- loading a plug-in not yet fully compiled.
if Modification_Time (D) < Clock - 5.0 then
Waiting := False;
Lib_Handle := LoadLibrary(As_LPCSTR(C_Name'Address));
if Lib_Handle /= System.Null_Address then
Do_Stuff_Handle := GetProcAddress(Lib_Handle, As_LPCSTR(Proc_Name'Address));
Ignored := Do_Stuff_Handle.all;
end if;
end if;
end;
end if;
end loop;
end Main; |
AdaCore/training_material | Ada | 1,464 | adb | package body Basics is
procedure Swap (X, Y : in out Integer) is
Tmp : Integer := X;
begin
X := Y;
Y := Tmp;
end Swap;
procedure Bump_Rec (R : in out Rec) is
begin
case R.Disc is
when True =>
R.A := R.A + 1;
when False =>
R.B := R.B + 1;
end case;
end Bump_Rec;
procedure Swap_Table (T : in out Table; I, J : Index) is
begin
if I /= J then
Swap (T (I), T (J));
pragma Annotate (GNATprove, False_Positive,
"formal parameters * might be aliased",
"I /= J so T(I) and T(J) cannot alias");
end if;
end Swap_Table;
procedure Bump_The_Rec is
begin
Bump_Rec (The_Rec);
end Bump_The_Rec;
procedure Swap_The_Table (I, J : Index) is
begin
Swap_Table (The_Table, I, J);
end Swap_The_Table;
procedure Init_Rec (R : out Rec) is
begin
case R.Disc is
when True =>
R := (Disc => True, A => 1);
when False =>
R := (Disc => False, B => 1);
end case;
end Init_Rec;
procedure Init_Table (T : out Table) is
begin
T := (others => 0);
T (T'First) := 1;
T (T'Last) := 2;
end Init_Table;
procedure Init_The_Rec is
begin
Init_Rec (The_Rec);
end Init_The_Rec;
procedure Init_The_Table is
begin
Init_Table (The_Table);
end Init_The_Table;
end Basics;
|
sungyeon/drake | Ada | 329 | ads | pragma License (Unrestricted);
-- implementation unit required by compiler
with System.Unsigned_Types;
package System.Val_LLU is
pragma Pure;
-- required for Modular'Value by compiler (s-valllu.ads)
function Value_Long_Long_Unsigned (Str : String)
return Unsigned_Types.Long_Long_Unsigned;
end System.Val_LLU;
|
gspu/synth | Ada | 7,694 | ads | -- This file is covered by the Internet Software Consortium (ISC) License
-- Reference: ../License.txt
private with Replicant.Platform;
package PortScan.Packages is
-- This routine first removes all invalid packages (package from removed
-- port or older version) and inserts the origins of the remaining packages
-- into the port list for a limited tree scan.
procedure preclean_repository (repository : String);
-- If performing a limited build run (likely 99% of the use cases), only
-- the queued packages will be checked. The checks are limited to finding
-- options changes and dependency changes. Obsolete packages (related or
-- unrelated to upcoming build) are not removed; this would occur in
-- clean_repository(). These old packages will not interfere at this step.
procedure limited_sanity_check (repository : String; dry_run : Boolean;
suppress_remote : Boolean);
-- Iterate through the final build queue to remove any packages that
-- match the current package names (currently unused)
procedure remove_queue_packages (repository : String);
-- This procedure empties the given repository without discrimination.
-- (Well, it's limited to "*.pkg" matches, but normally that's everything)
-- (currently unused)
procedure wipe_out_repository (repository : String);
-- Sometimes, especially with the single ports-mgmt/pkg check, there is
-- nothing left to do after the sanity check. Let's provide a way to
-- detect that case.
function queue_is_empty return Boolean;
-- Returns the size of the queue before it was pared down.
function original_queue_size return Natural;
-- After the initial queue is created, and before the limited sanity
-- check, we go through each port and check if it has cached options.
-- If it does, then it's checked for validity. If it has too many or
-- too few options, or an option's name doesn't match, the port is
-- printed to stdout. The rest of the ports are checked, but at that
-- point the function has failed.
function limited_cached_options_check return Boolean;
-- Returns True on success; stores value in global external_repository
function located_external_repository return Boolean;
-- Returns the value of the stored external repository
function top_external_repository return String;
-- Given the full path of a package, query it for the port origin
function query_origin (fullpath : String) return String;
-- Given the full path of a package plus its port origin, return origin(@flavor)
function query_full_origin (fullpath, origin : String) return String;
-- Given the full path of a package, query it for the package base name
function query_pkgbase (fullpath : String) return String;
private
type dim_packages is array (scanners) of string_crate.Vector;
stored_packages : dim_packages;
stored_origins : dim_packages;
pkgscan_progress : dim_progress := (others => 0);
pkgscan_total : Natural := 0;
abi_formats : Replicant.package_abi;
external_repository : JT.Text;
original_queue_len : AC.Count_Type;
obsolete_pkg_log : TIO.File_Type;
obsolete_log_open : Boolean := False;
-- Debugging purposes only, can be turned on by environment variable
debug_dep_check : Boolean := False;
debug_opt_check : Boolean := False;
-- This function returns "True" if the scanned options exactly match
-- the options in the already-built package. Usually it's already known
-- that a package exists before the function is called, but an existence
-- check will be performed just in case (failure returns "False")
function passed_option_check (repository : String; id : port_id;
skip_exist_check : Boolean := False)
return Boolean;
-- This function returns "True" if the scanned dependencies match exactly
-- what the current ports tree has.
function passed_dependency_check (query_result : JT.Text; id : port_id)
return Boolean;
-- This function returns "True" if the scanned package has the expected
-- package ABI, e.g. dragonfly:4.6:x86:64, freebsd:10:amd64
function passed_abi_check (repository : String; id : port_id;
skip_exist_check : Boolean := False)
return Boolean;
-- This calculates the ABI for the platform and stores it. The value is
-- used by passed_abi_check()
procedure establish_package_architecture;
-- Scan directory that contains the packages (*.pkg) and stores the
-- file names in the container. Returns False if no packages are found.
function scan_repository (repository : String) return Boolean;
-- standard method to spawn commands in this package (and get output)
function generic_system_command (command : String) return JT.Text;
-- Evaluates the stored options. If none exists, return True
-- If Exists and all the options match exactly what has already been
-- scanned for the port (names, not values) then return True else False.
function passed_options_cache_check (id : port_id) return Boolean;
-- For each package in the query, check the ABI and options (this is the
-- only time they are checked). If those pass, query the dependencies,
-- store the result, and check them. Set the "deletion" flag as needed.
-- The dependency check is NOT performed yet.
procedure initial_package_scan (repository : String; id : port_id);
-- Same as above, but for packages in the external repository
procedure remote_package_scan (id : port_id);
-- The result of the dependency query giving "id" port_id
function result_of_dependency_query (repository : String; id : port_id)
return JT.Text;
-- Using the same make_queue as was used to scan the ports, use tasks
-- (up to 32) to do the initial scanning of the ports, including getting
-- the pkg dependency query.
procedure parallel_package_scan (repository : String; remote_scan : Boolean;
show_progress : Boolean);
-- Prior to this procedure, the list of existing packages is split as
-- a balanced array so this scan will query the package for its origin
-- and package name. If the origin still exists, the port will be
-- scanned for the current package name. If either check fails, the
-- package will be deleted, otherwise the origin will be preserved for
-- a further in-depth check.
procedure parallel_preliminary_package_scan (repository : String;
show_progress : Boolean);
-- given a port_id, return the package name (no .pkg extension!)
function id2pkgname (id : port_id) return String;
-- Turn on option and dependency debug checks programmatically
procedure activate_debugging_code;
-- Given an origin (already validated) and the name of the package in
-- focus, return True if "make -V PKGFILE:T" matches the filename
function current_package_name (origin, file_name : String) return Boolean;
-- Dedicated progress meter for prescanning packages
function package_scan_progress return String;
-- Open log to document packages that get deleted and the reason why
procedure start_obsolete_package_logging;
-- Write to log if open and optionally output a copy to screen.
procedure obsolete_notice (message : String; write_to_screen : Boolean);
end PortScan.Packages;
|
Fabien-Chouteau/GESTE | Ada | 12,016 | ads | package GESTE_Fonts.FreeSans5pt7b is
Font : constant Bitmap_Font_Ref;
private
FreeSans5pt7bBitmaps : aliased constant Font_Bitmap := (
16#00#, 16#00#, 16#00#, 16#01#, 16#00#, 16#40#, 16#10#, 16#04#, 16#01#,
16#00#, 16#40#, 16#00#, 16#04#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#,
16#00#, 16#00#, 16#A0#, 16#28#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#,
16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#,
16#0A#, 16#07#, 16#81#, 16#40#, 16#F8#, 16#14#, 16#05#, 16#00#, 16#00#,
16#00#, 16#00#, 16#00#, 16#00#, 16#80#, 16#70#, 16#2A#, 16#0A#, 16#01#,
16#C0#, 16#28#, 16#2A#, 16#07#, 16#80#, 16#80#, 16#00#, 16#00#, 16#00#,
16#00#, 16#00#, 16#64#, 16#25#, 16#09#, 16#81#, 16#A0#, 16#13#, 16#05#,
16#22#, 16#30#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#30#,
16#12#, 16#03#, 16#01#, 16#C0#, 16#5C#, 16#12#, 16#07#, 16#40#, 16#00#,
16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#80#, 16#20#, 16#00#, 16#00#,
16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#,
16#00#, 16#80#, 16#40#, 16#10#, 16#04#, 16#01#, 16#00#, 16#40#, 16#10#,
16#04#, 16#01#, 16#00#, 16#00#, 16#00#, 16#00#, 16#02#, 16#00#, 16#40#,
16#10#, 16#04#, 16#00#, 16#80#, 16#20#, 16#10#, 16#04#, 16#01#, 16#00#,
16#00#, 16#00#, 16#00#, 16#01#, 16#00#, 16#60#, 16#18#, 16#00#, 16#00#,
16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#,
16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#80#, 16#78#, 16#08#,
16#02#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#,
16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#04#, 16#01#, 16#00#,
16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#,
16#00#, 16#E0#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#,
16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#,
16#04#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#80#, 16#40#,
16#10#, 16#04#, 16#01#, 16#00#, 16#80#, 16#20#, 16#08#, 16#00#, 16#00#,
16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#70#, 16#12#, 16#08#, 16#82#,
16#20#, 16#88#, 16#12#, 16#07#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#,
16#00#, 16#00#, 16#20#, 16#18#, 16#02#, 16#00#, 16#80#, 16#20#, 16#08#,
16#02#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#70#,
16#12#, 16#00#, 16#80#, 16#60#, 16#20#, 16#10#, 16#0F#, 16#80#, 16#00#,
16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#70#, 16#22#, 16#00#, 16#80#,
16#C0#, 16#08#, 16#22#, 16#07#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#,
16#00#, 16#00#, 16#10#, 16#04#, 16#03#, 16#01#, 16#40#, 16#90#, 16#3E#,
16#01#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#78#,
16#10#, 16#07#, 16#01#, 16#20#, 16#08#, 16#22#, 16#07#, 16#00#, 16#00#,
16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#70#, 16#12#, 16#0B#, 16#03#,
16#20#, 16#88#, 16#12#, 16#07#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#,
16#00#, 16#00#, 16#F8#, 16#02#, 16#01#, 16#00#, 16#80#, 16#20#, 16#08#,
16#04#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#70#,
16#12#, 16#04#, 16#80#, 16#C0#, 16#C8#, 16#22#, 16#07#, 16#00#, 16#00#,
16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#70#, 16#12#, 16#08#, 16#81#,
16#20#, 16#78#, 16#12#, 16#07#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#,
16#00#, 16#00#, 16#00#, 16#00#, 16#04#, 16#00#, 16#00#, 16#00#, 16#00#,
16#04#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#,
16#00#, 16#04#, 16#00#, 16#00#, 16#00#, 16#00#, 16#04#, 16#01#, 16#00#,
16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#,
16#E0#, 16#C0#, 16#0C#, 16#00#, 16#80#, 16#00#, 16#00#, 16#00#, 16#00#,
16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#01#, 16#E0#, 16#00#, 16#1E#,
16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#,
16#00#, 16#00#, 16#00#, 16#C0#, 16#08#, 16#0C#, 16#04#, 16#00#, 16#00#,
16#00#, 16#00#, 16#00#, 16#01#, 16#C0#, 16#48#, 16#02#, 16#00#, 16#80#,
16#40#, 16#20#, 16#00#, 16#02#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#,
16#00#, 16#78#, 16#21#, 16#93#, 16#29#, 16#26#, 16#4A#, 16#94#, 16#96#,
16#C6#, 16#00#, 16#78#, 16#00#, 16#00#, 16#00#, 16#00#, 16#40#, 16#30#,
16#0A#, 16#02#, 16#81#, 16#20#, 16#7C#, 16#11#, 16#08#, 16#40#, 16#00#,
16#00#, 16#00#, 16#00#, 16#01#, 16#E0#, 16#44#, 16#11#, 16#07#, 16#81#,
16#10#, 16#44#, 16#11#, 16#07#, 16#80#, 16#00#, 16#00#, 16#00#, 16#00#,
16#00#, 16#F0#, 16#44#, 16#10#, 16#08#, 16#02#, 16#00#, 16#40#, 16#11#,
16#83#, 16#C0#, 16#00#, 16#00#, 16#00#, 16#00#, 16#01#, 16#E0#, 16#44#,
16#11#, 16#04#, 16#21#, 16#08#, 16#44#, 16#11#, 16#07#, 16#80#, 16#00#,
16#00#, 16#00#, 16#00#, 16#01#, 16#F0#, 16#40#, 16#10#, 16#07#, 16#C1#,
16#00#, 16#40#, 16#10#, 16#07#, 16#C0#, 16#00#, 16#00#, 16#00#, 16#00#,
16#01#, 16#F0#, 16#40#, 16#10#, 16#07#, 16#81#, 16#00#, 16#40#, 16#10#,
16#04#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#F0#, 16#42#,
16#10#, 16#08#, 16#02#, 16#38#, 16#42#, 16#10#, 16#83#, 16#E0#, 16#00#,
16#00#, 16#00#, 16#00#, 16#01#, 16#10#, 16#44#, 16#11#, 16#07#, 16#C1#,
16#10#, 16#44#, 16#11#, 16#04#, 16#40#, 16#00#, 16#00#, 16#00#, 16#00#,
16#01#, 16#00#, 16#40#, 16#10#, 16#04#, 16#01#, 16#00#, 16#40#, 16#10#,
16#04#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#40#, 16#10#,
16#04#, 16#01#, 16#00#, 16#40#, 16#10#, 16#24#, 16#07#, 16#00#, 16#00#,
16#00#, 16#00#, 16#00#, 16#01#, 16#10#, 16#48#, 16#14#, 16#07#, 16#01#,
16#40#, 16#48#, 16#11#, 16#04#, 16#40#, 16#00#, 16#00#, 16#00#, 16#00#,
16#01#, 16#00#, 16#40#, 16#10#, 16#04#, 16#01#, 16#00#, 16#40#, 16#10#,
16#07#, 16#80#, 16#00#, 16#00#, 16#00#, 16#00#, 16#01#, 16#0C#, 16#63#,
16#19#, 16#46#, 16#51#, 16#94#, 16#59#, 16#16#, 16#44#, 16#90#, 16#00#,
16#00#, 16#00#, 16#00#, 16#01#, 16#08#, 16#62#, 16#18#, 16#85#, 16#21#,
16#48#, 16#4A#, 16#11#, 16#84#, 16#60#, 16#00#, 16#00#, 16#00#, 16#00#,
16#00#, 16#F0#, 16#46#, 16#10#, 16#88#, 16#22#, 16#08#, 16#42#, 16#11#,
16#83#, 16#C0#, 16#00#, 16#00#, 16#00#, 16#00#, 16#01#, 16#E0#, 16#44#,
16#11#, 16#04#, 16#41#, 16#E0#, 16#40#, 16#10#, 16#04#, 16#00#, 16#00#,
16#00#, 16#00#, 16#00#, 16#00#, 16#F0#, 16#46#, 16#10#, 16#88#, 16#22#,
16#08#, 16#42#, 16#11#, 16#83#, 16#E0#, 16#00#, 16#00#, 16#00#, 16#00#,
16#01#, 16#F0#, 16#44#, 16#11#, 16#04#, 16#41#, 16#E0#, 16#44#, 16#11#,
16#04#, 16#40#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#E0#, 16#44#,
16#10#, 16#04#, 16#00#, 16#E0#, 16#04#, 16#11#, 16#07#, 16#80#, 16#00#,
16#00#, 16#00#, 16#00#, 16#03#, 16#F0#, 16#10#, 16#04#, 16#01#, 16#00#,
16#40#, 16#10#, 16#04#, 16#01#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#,
16#01#, 16#10#, 16#44#, 16#11#, 16#04#, 16#41#, 16#10#, 16#44#, 16#11#,
16#03#, 16#80#, 16#00#, 16#00#, 16#00#, 16#00#, 16#02#, 16#10#, 16#44#,
16#11#, 16#04#, 16#80#, 16#A0#, 16#28#, 16#0C#, 16#01#, 16#00#, 16#00#,
16#00#, 16#00#, 16#00#, 16#02#, 16#22#, 16#4C#, 16#93#, 16#25#, 16#51#,
16#54#, 16#53#, 16#08#, 16#C2#, 16#20#, 16#00#, 16#00#, 16#00#, 16#00#,
16#01#, 16#10#, 16#48#, 16#0A#, 16#03#, 16#00#, 16#C0#, 16#28#, 16#12#,
16#0C#, 16#40#, 16#00#, 16#00#, 16#00#, 16#00#, 16#03#, 16#10#, 16#44#,
16#0A#, 16#02#, 16#80#, 16#40#, 16#10#, 16#04#, 16#01#, 16#00#, 16#00#,
16#00#, 16#00#, 16#00#, 16#01#, 16#F0#, 16#08#, 16#02#, 16#01#, 16#00#,
16#80#, 16#60#, 16#10#, 16#0F#, 16#C0#, 16#00#, 16#00#, 16#00#, 16#00#,
16#01#, 16#80#, 16#40#, 16#10#, 16#04#, 16#01#, 16#00#, 16#40#, 16#10#,
16#04#, 16#01#, 16#00#, 16#00#, 16#00#, 16#00#, 16#02#, 16#00#, 16#80#,
16#20#, 16#04#, 16#01#, 16#00#, 16#40#, 16#10#, 16#02#, 16#00#, 16#00#,
16#00#, 16#00#, 16#00#, 16#03#, 16#00#, 16#40#, 16#10#, 16#04#, 16#01#,
16#00#, 16#40#, 16#10#, 16#04#, 16#01#, 16#00#, 16#00#, 16#00#, 16#00#,
16#00#, 16#00#, 16#20#, 16#18#, 16#05#, 16#00#, 16#40#, 16#00#, 16#00#,
16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#,
16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#,
16#00#, 16#00#, 16#00#, 16#01#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#,
16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#,
16#00#, 16#00#, 16#00#, 16#00#, 16#07#, 16#01#, 16#20#, 16#78#, 16#22#,
16#07#, 16#80#, 16#00#, 16#00#, 16#00#, 16#00#, 16#01#, 16#00#, 16#40#,
16#10#, 16#07#, 16#81#, 16#20#, 16#48#, 16#12#, 16#07#, 16#00#, 16#00#,
16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#07#, 16#02#,
16#20#, 16#80#, 16#22#, 16#07#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#,
16#00#, 16#20#, 16#08#, 16#02#, 16#07#, 16#83#, 16#20#, 16#88#, 16#32#,
16#07#, 16#80#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#,
16#00#, 16#07#, 16#02#, 16#20#, 16#F8#, 16#22#, 16#07#, 16#00#, 16#00#,
16#00#, 16#00#, 16#00#, 16#01#, 16#80#, 16#40#, 16#10#, 16#0E#, 16#01#,
16#00#, 16#40#, 16#10#, 16#04#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#,
16#00#, 16#00#, 16#00#, 16#00#, 16#07#, 16#82#, 16#20#, 16#88#, 16#22#,
16#07#, 16#82#, 16#20#, 16#00#, 16#00#, 16#00#, 16#01#, 16#00#, 16#40#,
16#10#, 16#07#, 16#01#, 16#20#, 16#48#, 16#12#, 16#04#, 16#80#, 16#00#,
16#00#, 16#00#, 16#00#, 16#01#, 16#00#, 16#00#, 16#00#, 16#04#, 16#01#,
16#00#, 16#40#, 16#10#, 16#04#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#,
16#01#, 16#00#, 16#00#, 16#00#, 16#04#, 16#01#, 16#00#, 16#40#, 16#10#,
16#04#, 16#01#, 16#00#, 16#00#, 16#00#, 16#00#, 16#01#, 16#00#, 16#40#,
16#10#, 16#05#, 16#01#, 16#80#, 16#60#, 16#14#, 16#04#, 16#80#, 16#00#,
16#00#, 16#00#, 16#00#, 16#02#, 16#00#, 16#80#, 16#20#, 16#08#, 16#02#,
16#00#, 16#80#, 16#20#, 16#08#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#,
16#00#, 16#00#, 16#00#, 16#00#, 16#07#, 16#61#, 16#24#, 16#51#, 16#14#,
16#45#, 16#10#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#,
16#00#, 16#07#, 16#01#, 16#20#, 16#48#, 16#12#, 16#04#, 16#80#, 16#00#,
16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#07#, 16#02#,
16#20#, 16#88#, 16#22#, 16#07#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#,
16#00#, 16#00#, 16#00#, 16#00#, 16#07#, 16#81#, 16#20#, 16#48#, 16#12#,
16#07#, 16#81#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#,
16#00#, 16#07#, 16#83#, 16#20#, 16#88#, 16#32#, 16#07#, 16#80#, 16#20#,
16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#06#, 16#01#,
16#00#, 16#40#, 16#10#, 16#04#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#,
16#00#, 16#00#, 16#00#, 16#00#, 16#07#, 16#02#, 16#40#, 16#70#, 16#22#,
16#07#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#,
16#10#, 16#0E#, 16#01#, 16#00#, 16#40#, 16#10#, 16#06#, 16#00#, 16#00#,
16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#04#, 16#81#,
16#20#, 16#48#, 16#12#, 16#07#, 16#80#, 16#00#, 16#00#, 16#00#, 16#00#,
16#00#, 16#00#, 16#00#, 16#00#, 16#08#, 16#81#, 16#40#, 16#50#, 16#18#,
16#02#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#,
16#00#, 16#09#, 16#22#, 16#A8#, 16#6C#, 16#1B#, 16#06#, 16#C0#, 16#00#,
16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#05#, 16#01#,
16#40#, 16#20#, 16#14#, 16#09#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#,
16#00#, 16#00#, 16#00#, 16#00#, 16#09#, 16#01#, 16#40#, 16#50#, 16#18#,
16#02#, 16#00#, 16#80#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#,
16#00#, 16#07#, 16#00#, 16#40#, 16#20#, 16#10#, 16#0F#, 16#80#, 16#00#,
16#00#, 16#00#, 16#00#, 16#01#, 16#80#, 16#40#, 16#10#, 16#04#, 16#01#,
16#00#, 16#40#, 16#10#, 16#04#, 16#01#, 16#00#, 16#00#, 16#00#, 16#00#,
16#01#, 16#00#, 16#40#, 16#10#, 16#04#, 16#01#, 16#00#, 16#40#, 16#10#,
16#04#, 16#01#, 16#00#, 16#00#, 16#00#, 16#00#, 16#01#, 16#00#, 16#40#,
16#10#, 16#04#, 16#00#, 16#80#, 16#20#, 16#10#, 16#04#, 16#01#, 16#00#,
16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#04#, 16#82#,
16#C0#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#);
Font_D : aliased constant Bitmap_Font :=
(
Bytes_Per_Glyph => 15,
Glyph_Width => 10,
Glyph_Height => 12,
Data => FreeSans5pt7bBitmaps'Access);
Font : constant Bitmap_Font_Ref := Font_D'Access;
end GESTE_Fonts.FreeSans5pt7b;
|
apple-oss-distributions/old_ncurses | Ada | 3,650 | ads | ------------------------------------------------------------------------------
-- --
-- GNAT ncurses Binding Samples --
-- --
-- Sample.My_Field_Type --
-- --
-- S P E C --
-- --
------------------------------------------------------------------------------
-- Copyright (c) 1998 Free Software Foundation, Inc. --
-- --
-- Permission is hereby granted, free of charge, to any person obtaining a --
-- copy of this software and associated documentation files (the --
-- "Software"), to deal in the Software without restriction, including --
-- without limitation the rights to use, copy, modify, merge, publish, --
-- distribute, distribute with modifications, sublicense, and/or sell --
-- copies of the Software, and to permit persons to whom the Software is --
-- furnished to do so, subject to the following conditions: --
-- --
-- The above copyright notice and this permission notice shall be included --
-- in all copies or substantial portions of the Software. --
-- --
-- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS --
-- OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF --
-- MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. --
-- IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, --
-- DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR --
-- OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR --
-- THE USE OR OTHER DEALINGS IN THE SOFTWARE. --
-- --
-- Except as contained in this notice, the name(s) of the above copyright --
-- holders shall not be used in advertising or otherwise to promote the --
-- sale, use or other dealings in this Software without prior written --
-- authorization. --
------------------------------------------------------------------------------
-- Author: Juergen Pfeifer <[email protected]> 1996
-- Version Control
-- $Revision: 1.1.1.1 $
-- Binding Version 01.00
------------------------------------------------------------------------------
with Terminal_Interface.Curses.Forms; use Terminal_Interface.Curses.Forms;
with Terminal_Interface.Curses.Forms.Field_Types.User;
use Terminal_Interface.Curses.Forms.Field_Types.User;
-- This is a very simple user defined field type. It accepts only a
-- defined character as input into the field.
--
package Sample.My_Field_Type is
type My_Data is new User_Defined_Field_Type with
record
Ch : Character;
end record;
function Field_Check (Fld : Field;
Typ : My_Data) return Boolean;
function Character_Check (Ch : Character;
Typ : My_Data) return Boolean;
end Sample.My_Field_Type;
|
stcarrez/ada-util | Ada | 21,965 | adb | -----------------------------------------------------------------------
-- util-encoders -- Encode/Decode streams and strings from one format to another
-- Copyright (C) 2009 - 2023 Stephane Carrez
-- Written by Stephane Carrez ([email protected])
--
-- Licensed under the Apache License, Version 2.0 (the "License");
-- you may not use this file except in compliance with the License.
-- You may obtain a copy of the License at
--
-- http://www.apache.org/licenses/LICENSE-2.0
--
-- Unless required by applicable law or agreed to in writing, software
-- distributed under the License is distributed on an "AS IS" BASIS,
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-- See the License for the specific language governing permissions and
-- limitations under the License.
-----------------------------------------------------------------------
with Ada.Strings.Unbounded;
with Ada.Unchecked_Deallocation;
with Util.Encoders.Base16;
with Util.Encoders.Base32;
with Util.Encoders.Base64;
with Util.Encoders.SHA1;
package body Util.Encoders is
use Ada;
use Ada.Strings.Unbounded;
subtype Offset is Ada.Streams.Stream_Element_Offset;
procedure Free is
new Ada.Unchecked_Deallocation (Transformer'Class, Transformer_Access);
MIN_BUFFER_SIZE : constant Streams.Stream_Element_Offset := 64;
MAX_BUFFER_SIZE : constant Streams.Stream_Element_Offset := 2_048;
function Best_Size (Length : Natural) return Streams.Stream_Element_Offset;
pragma Inline (Best_Size);
-- ------------------------------
-- Compute a good size for allocating a buffer on the stack
-- ------------------------------
function Best_Size (Length : Natural) return Streams.Stream_Element_Offset is
begin
if Length < Natural (MIN_BUFFER_SIZE) then
return MIN_BUFFER_SIZE;
elsif Length > Natural (MAX_BUFFER_SIZE) then
return MAX_BUFFER_SIZE;
else
return Streams.Stream_Element_Offset (((Length + 15) / 16) * 16);
end if;
end Best_Size;
-- ------------------------------
-- Create the secret key from the password string.
-- ------------------------------
function Create (Password : in String) return Secret_Key is
I : Stream_Element_Offset := 1;
begin
return Key : Secret_Key (Length => Password'Length) do
for C of Password loop
Key.Secret (I) := Character'Pos (C);
I := I + 1;
end loop;
end return;
end Create;
procedure Create (Password : in String;
Key : out Secret_Key) is
I : Stream_Element_Offset := 1;
begin
for C of Password loop
Key.Secret (I) := Character'Pos (C);
I := I + 1;
end loop;
end Create;
procedure Create (Password : in Stream_Element_Array;
Key : out Secret_Key) is
begin
Key.Secret := Password;
end Create;
overriding
procedure Finalize (Object : in out Secret_Key) is
begin
for I in Object.Secret'Range loop
Object.Secret (I) := 0;
end loop;
end Finalize;
-- ------------------------------
-- Encodes the input string <b>Data</b> using the transformation
-- rules provided by the <b>E</b> encoder.
--
-- Returns the encoded string.
--
-- Raises the <b>Encoding_Error</b> exception if the source string
-- cannot be encoded.
-- Raises the <b>Not_Supported</b> exception if the encoding is not
-- supported.
-- ------------------------------
function Encode (E : in Encoder;
Data : in String) return String is
begin
if E.Encode = null then
raise Not_Supported with "There is no encoder";
end if;
return E.Encode.Transform (Data);
end Encode;
function Encode_Binary (E : in Encoder;
Data : in Ada.Streams.Stream_Element_Array) return String is
begin
if E.Encode = null then
raise Not_Supported with "There is no encoder";
end if;
return E.Encode.all.Transform (Data);
end Encode_Binary;
function Encode_Unsigned_16 (E : in Encoder;
Value : in Interfaces.Unsigned_16) return String is
use type Interfaces.Unsigned_16;
Data : Ada.Streams.Stream_Element_Array (1 .. 2);
Val : Interfaces.Unsigned_16 := Value;
begin
for I in reverse Data'Range loop
Data (I) := Stream_Element (Val and 16#0ff#);
Val := Interfaces.Shift_Right (Val, 8);
end loop;
return E.Encode_Binary (Data);
end Encode_Unsigned_16;
function Encode_Unsigned_32 (E : in Encoder;
Value : in Interfaces.Unsigned_32) return String is
use type Interfaces.Unsigned_32;
Data : Ada.Streams.Stream_Element_Array (1 .. 4);
Val : Interfaces.Unsigned_32 := Value;
begin
for I in reverse Data'Range loop
Data (I) := Stream_Element (Val and 16#0ff#);
Val := Interfaces.Shift_Right (Val, 8);
end loop;
return E.Encode_Binary (Data);
end Encode_Unsigned_32;
function Encode_Unsigned_64 (E : in Encoder;
Value : in Interfaces.Unsigned_64) return String is
use type Interfaces.Unsigned_64;
Data : Ada.Streams.Stream_Element_Array (1 .. 8);
Val : Interfaces.Unsigned_64 := Value;
begin
for I in reverse Data'Range loop
Data (I) := Stream_Element (Val and 16#0ff#);
Val := Interfaces.Shift_Right (Val, 8);
end loop;
return E.Encode_Binary (Data);
end Encode_Unsigned_64;
-- ------------------------------
-- Decodes the input string <b>Data</b> using the transformation
-- rules provided by the <b>E</b> encoder.
--
-- Returns the encoded string.
--
-- Raises the <b>Encoding_Error</b> exception if the source string
-- cannot be decoded.
-- Raises the <b>Not_Supported</b> exception if the decoding is not
-- supported.
-- ------------------------------
function Decode (E : in Decoder;
Data : in String) return String is
begin
if E.Decode = null then
raise Not_Supported with "There is no decoder";
end if;
return E.Decode.Transform (Data);
end Decode;
function Decode_Binary (E : in Decoder;
Data : in String) return Ada.Streams.Stream_Element_Array is
Buf : Ada.Streams.Stream_Element_Array (Offset (Data'First) .. Offset (Data'Last));
for Buf'Address use Data'Address;
begin
if E.Decode = null then
raise Not_Supported with "There is no decoder";
end if;
return E.Decode.all.Transform (Buf);
end Decode_Binary;
function Decode_Key (E : in Decoder'Class;
Data : in String) return Secret_Key is
Buf : Ada.Streams.Stream_Element_Array (Offset (Data'First) .. Offset (Data'Last));
for Buf'Address use Data'Address;
begin
if E.Decode = null then
raise Not_Supported with "There is no decoder";
end if;
-- Decode in a Secret_Key large enough to handle the decoded content
-- and we return a Secret_Key with the correct length. The temp secret
-- key will have its finalizer that clears the buffer.
-- Constraint_Error will be raised if the temp secret is not large enough.
declare
Buf_Size : constant Streams.Stream_Element_Offset := Best_Size (Buf'Length);
Tmp_Key : Secret_Key (Length => Buf_Size);
Last_Encoded : Streams.Stream_Element_Offset;
Last : Streams.Stream_Element_Offset;
begin
E.Decode.Transform (Data => Buf,
Into => Tmp_Key.Secret,
Encoded => Last_Encoded,
Last => Last);
E.Decode.Finish (Tmp_Key.Secret (Last + 1 .. Tmp_Key.Secret'Last), Last);
return Key : Secret_Key (Last) do
Key.Secret := Tmp_Key.Secret (1 .. Last);
end return;
end;
end Decode_Key;
-- ------------------------------
-- Transform the input string <b>Data</b> using the transformation
-- rules provided by the <b>E</b> transformer.
--
-- Returns the transformed string.
--
-- Raises the <b>Encoding_Error</b> exception if the source string
-- cannot be transformed
-- ------------------------------
function Transform (E : in out Transformer'Class;
Data : in String) return String is
Buf_Size : constant Streams.Stream_Element_Offset := Best_Size (Data'Length);
Buf : Streams.Stream_Element_Array (1 .. Buf_Size);
Res : Streams.Stream_Element_Array (1 .. Buf_Size);
Tmp : String (1 .. Natural (Buf_Size));
Result : Ada.Strings.Unbounded.Unbounded_String;
Pos : Natural := Data'First;
Last : Streams.Stream_Element_Offset;
begin
while Pos <= Data'Last loop
declare
Last_Encoded : Streams.Stream_Element_Offset;
First_Encoded : Streams.Stream_Element_Offset := 1;
Size : Streams.Stream_Element_Offset;
Next_Pos : Natural;
begin
-- Fill the stream buffer with our input string
Size := Streams.Stream_Element_Offset (Data'Last - Pos + 1);
if Size > Buf'Length then
Size := Buf'Length;
end if;
for I in 1 .. Size loop
Buf (I) := Character'Pos (Data (Natural (I) + Pos - 1));
end loop;
Next_Pos := Pos + Natural (Size);
-- Encode that buffer and put the result in out result string.
loop
E.Transform (Data => Buf (First_Encoded .. Size),
Into => Res,
Encoded => Last_Encoded,
Last => Last);
-- If the encoder generated nothing, move the position backward
-- to take into account the remaining bytes not taken into account.
if Last < 1 then
Next_Pos := Next_Pos - Natural (Size - First_Encoded + 1);
exit;
end if;
for I in 1 .. Last loop
Tmp (Natural (I)) := Character'Val (Res (I));
end loop;
Append (Result, Tmp (1 .. Natural (Last)));
exit when Last_Encoded = Size;
First_Encoded := Last_Encoded + 1;
end loop;
-- The encoder cannot encode the data
if Pos = Next_Pos then
raise Encoding_Error with "Encoding cannot proceed";
end if;
Pos := Next_Pos;
end;
end loop;
Last := 0;
E.Finish (Into => Res,
Last => Last);
if Last > 0 then
for I in 1 .. Last loop
Tmp (Natural (I)) := Character'Val (Res (I));
end loop;
Append (Result, Tmp (1 .. Natural (Last)));
end if;
return To_String (Result);
end Transform;
-- ------------------------------
-- Transform the input string <b>Data</b> using the transformation
-- rules provided by the <b>E</b> transformer and return the data in
-- the <b>Into</b> array, setting <b>Last</b> to the last index.
--
-- Raises the <b>Encoding_Error</b> exception if the source string
-- cannot be transformed
-- ------------------------------
procedure Transform (E : in out Transformer'Class;
Data : in String;
Into : out Ada.Streams.Stream_Element_Array;
Last : out Ada.Streams.Stream_Element_Offset) is
Buf_Size : constant Streams.Stream_Element_Offset := Best_Size (Data'Length);
Buf : Streams.Stream_Element_Array (1 .. Buf_Size);
Pos : Natural := Data'First;
First : Streams.Stream_Element_Offset := Into'First;
begin
Last := Into'First - 1;
while Pos <= Data'Last and then Last < Into'Last loop
declare
Last_Encoded : Streams.Stream_Element_Offset;
Size : Streams.Stream_Element_Offset;
Next_Pos : Natural;
begin
-- Fill the stream buffer with our input string
Size := Streams.Stream_Element_Offset (Data'Last - Pos + 1);
if Size > Buf'Length then
Size := Buf'Length;
end if;
for I in 1 .. Size loop
Buf (I) := Character'Pos (Data (Natural (I) + Pos - 1));
end loop;
Next_Pos := Pos + Natural (Size);
-- Encode that buffer and put the result in the output data array.
E.Transform (Data => Buf (1 .. Size),
Into => Into (First .. Into'Last),
Encoded => Last_Encoded,
Last => Last);
-- If the encoded has not used all the data, update the position for the next run.
if Last_Encoded /= Size then
Next_Pos := Next_Pos - Natural (Size - Last_Encoded + 1);
end if;
-- The encoder cannot encode the data
if Pos = Next_Pos then
raise Encoding_Error with "Encoding cannot proceed";
end if;
First := Last;
Pos := Next_Pos;
end;
end loop;
if Pos <= Data'Last then
raise Encoding_Error with "Not enough space for encoding";
end if;
end Transform;
-- ------------------------------
-- Transform the input string <b>Data</b> using the transformation
-- rules provided by the <b>E</b> transformer.
--
-- Returns the transformed string.
--
-- Raises the <b>Encoding_Error</b> exception if the source string
-- cannot be transformed
-- ------------------------------
function Transform (E : in out Transformer'Class;
Data : in Streams.Stream_Element_Array) return String is
Buf_Size : constant Streams.Stream_Element_Offset := Best_Size (Data'Length);
Res : Streams.Stream_Element_Array (1 .. Buf_Size);
Tmp : String (1 .. Natural (Buf_Size));
Result : Ada.Strings.Unbounded.Unbounded_String;
Last_Encoded : Streams.Stream_Element_Offset;
Last : Streams.Stream_Element_Offset;
begin
-- Encode that buffer and put the result in out result string.
E.Transform (Data => Data,
Into => Res,
Encoded => Last_Encoded,
Last => Last);
E.Finish (Res (Last + 1 .. Res'Last), Last);
for I in 1 .. Last loop
Tmp (Natural (I)) := Character'Val (Res (I));
end loop;
Append (Result, Tmp (1 .. Natural (Last)));
return To_String (Result);
end Transform;
-- ------------------------------
-- Transform the input string <b>Data</b> using the transformation
-- rules provided by the <b>E</b> transformer.
--
-- Returns the transformed string.
--
-- Raises the <b>Encoding_Error</b> exception if the source string
-- cannot be transformed
-- ------------------------------
function Transform (E : in out Transformer'Class;
Data : in Streams.Stream_Element_Array)
return Streams.Stream_Element_Array is
Buf_Size : constant Streams.Stream_Element_Offset := Best_Size (Data'Length);
Res : Streams.Stream_Element_Array (1 .. Buf_Size);
Last_Encoded : Streams.Stream_Element_Offset;
Last : Streams.Stream_Element_Offset;
begin
-- Encode that buffer and put the result in out result string.
E.Transform (Data => Data,
Into => Res,
Encoded => Last_Encoded,
Last => Last);
E.Finish (Res (Last + 1 .. Res'Last), Last);
return Res (1 .. Last);
end Transform;
-- ------------------------------
-- Transform the input data into the target string.
-- ------------------------------
procedure Convert (E : in out Transformer'Class;
Data : in Ada.Streams.Stream_Element_Array;
Into : out String) is
Buf : Ada.Streams.Stream_Element_Array (Offset (Into'First) .. Offset (Into'Last));
for Buf'Address use Into'Address;
Last_Encoded : Offset;
Last : Offset;
begin
E.Transform (Data => Data,
Into => Buf,
Last => Last,
Encoded => Last_Encoded);
E.Finish (Buf (Last + 1 .. Buf'Last), Last);
end Convert;
-- ------------------------------
-- Encode the value represented by <tt>Val</tt> in the stream array <tt>Into</tt> starting
-- at position <tt>Pos</tt> in that array. The value is encoded using LEB128 format, 7-bits
-- at a time until all non zero bits are written. The <tt>Last</tt> parameter is updated
-- to indicate the position of the last valid byte written in <tt>Into</tt>.
-- ------------------------------
procedure Encode_LEB128 (Into : in out Ada.Streams.Stream_Element_Array;
Pos : in Ada.Streams.Stream_Element_Offset;
Val : in Interfaces.Unsigned_64;
Last : out Ada.Streams.Stream_Element_Offset) is
use type Interfaces.Unsigned_64;
P : Ada.Streams.Stream_Element_Offset := Pos;
V, U : Interfaces.Unsigned_64;
begin
V := Val;
loop
if V < 16#07F# then
Into (P) := Ada.Streams.Stream_Element (V);
Last := P;
return;
end if;
U := V and 16#07F#;
Into (P) := Ada.Streams.Stream_Element (U or 16#80#);
P := P + 1;
V := Interfaces.Shift_Right (V, 7);
end loop;
end Encode_LEB128;
-- ------------------------------
-- Decode from the byte array <tt>From</tt> the value represented as LEB128 format starting
-- at position <tt>Pos</tt> in that array. After decoding, the <tt>Last</tt> index is updated
-- to indicate the last position in the byte array.
-- ------------------------------
procedure Decode_LEB128 (From : in Ada.Streams.Stream_Element_Array;
Pos : in Ada.Streams.Stream_Element_Offset;
Val : out Interfaces.Unsigned_64;
Last : out Ada.Streams.Stream_Element_Offset) is
use type Interfaces.Unsigned_64;
use type Interfaces.Unsigned_8;
P : Ada.Streams.Stream_Element_Offset := Pos;
Value : Interfaces.Unsigned_64 := 0;
V : Interfaces.Unsigned_8;
Shift : Integer := 0;
begin
loop
V := Interfaces.Unsigned_8 (From (P));
if (V and 16#80#) = 0 then
Val := Interfaces.Shift_Left (Interfaces.Unsigned_64 (V), Shift) or Value;
Last := P + 1;
return;
end if;
V := V and 16#07F#;
Value := Interfaces.Shift_Left (Interfaces.Unsigned_64 (V), Shift) or Value;
P := P + 1;
Shift := Shift + 7;
end loop;
end Decode_LEB128;
-- ------------------------------
-- Create the encoder object for the specified algorithm.
-- ------------------------------
function Create (Name : String) return Encoder is
begin
if Name = BASE_16 or else Name = HEX then
return E : Encoder do
E.Encode := new Util.Encoders.Base16.Encoder;
end return;
elsif Name = BASE_64 then
return E : Encoder do
E.Encode := new Util.Encoders.Base64.Encoder;
end return;
elsif Name = BASE_64_URL then
return E : Encoder do
E.Encode := Util.Encoders.Base64.Create_URL_Encoder;
end return;
elsif Name = BASE_32 then
return E : Encoder do
E.Encode := Util.Encoders.Base32.Create_Encoder;
end return;
elsif Name = HASH_SHA1 then
return E : Encoder do
E.Encode := new Util.Encoders.SHA1.Encoder;
end return;
end if;
raise Not_Supported with "Invalid encoder: " & Name;
end Create;
-- ------------------------------
-- Create the encoder object for the specified algorithm.
-- ------------------------------
function Create (Name : String) return Decoder is
begin
if Name = BASE_16 or else Name = HEX then
return E : Decoder do
E.Decode := new Util.Encoders.Base16.Decoder;
end return;
elsif Name = BASE_64 then
return E : Decoder do
E.Decode := new Util.Encoders.Base64.Decoder;
end return;
elsif Name = BASE_64_URL then
return E : Decoder do
E.Decode := Util.Encoders.Base64.Create_URL_Decoder;
end return;
elsif Name = BASE_32 then
return E : Decoder do
E.Decode := Util.Encoders.Base32.Create_Decoder;
end return;
elsif Name = HASH_SHA1 then
return E : Decoder do
E.Decode := new Util.Encoders.Base64.Decoder;
end return;
end if;
raise Not_Supported with "Invalid encoder: " & Name;
end Create;
-- ------------------------------
-- Delete the transformers
-- ------------------------------
overriding
procedure Finalize (E : in out Encoder) is
begin
Free (E.Encode);
end Finalize;
-- ------------------------------
-- Delete the transformers
-- ------------------------------
overriding
procedure Finalize (E : in out Decoder) is
begin
Free (E.Decode);
end Finalize;
end Util.Encoders;
|
Sawchord/Ada_Drivers_Library | Ada | 22,035 | adb | ------------------------------------------------------------------------------
-- --
-- Copyright (C) 2015-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 the copyright holder nor the names of its --
-- contributors may be used to endorse or promote products derived --
-- from this software without specific prior written permission. --
-- --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR --
-- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
-- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT --
-- LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, --
-- DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY --
-- THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT --
-- (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE --
-- OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
-- --
------------------------------------------------------------------------------
with Ada.Unchecked_Conversion;
package body ST7735R is
---------------------------
-- Register definitions --
---------------------------
type MADCTL is record
Reserved1, Reserved2 : Boolean;
MH : Horizontal_Refresh_Order;
RGB : RGB_BGR_Order;
ML : Vertical_Refresh_Order;
MV : Boolean;
MX : Column_Address_Order;
MY : Row_Address_Order;
end record with Size => 8, Bit_Order => System.Low_Order_First;
for MADCTL use record
Reserved1 at 0 range 0 .. 0;
Reserved2 at 0 range 1 .. 1;
MH at 0 range 2 .. 2;
RGB at 0 range 3 .. 3;
ML at 0 range 4 .. 4;
MV at 0 range 5 .. 5;
MX at 0 range 6 .. 6;
MY at 0 range 7 .. 7;
end record;
function To_UInt8 is new Ada.Unchecked_Conversion (MADCTL, UInt8);
procedure Write_Command (LCD : ST7735R_Screen;
Cmd : UInt8);
procedure Write_Command (LCD : ST7735R_Screen;
Cmd : UInt8;
Data : HAL.UInt8_Array);
procedure Write_Data (LCD : ST7735R_Screen;
Data : UInt8);
pragma Unreferenced (Write_Data);
procedure Write_Data (LCD : ST7735R_Screen;
Data : HAL.UInt8_Array);
procedure Read_Data (LCD : ST7735R_Screen;
Data : out UInt16);
procedure Set_Command_Mode (LCD : ST7735R_Screen);
procedure Set_Data_Mode (LCD : ST7735R_Screen);
procedure Start_Transaction (LCD : ST7735R_Screen);
procedure End_Transaction (LCD : ST7735R_Screen);
----------------------
-- Set_Command_Mode --
----------------------
procedure Set_Command_Mode (LCD : ST7735R_Screen) is
begin
LCD.RS.Clear;
end Set_Command_Mode;
-------------------
-- Set_Data_Mode --
-------------------
procedure Set_Data_Mode (LCD : ST7735R_Screen) is
begin
LCD.RS.Set;
end Set_Data_Mode;
-----------------------
-- Start_Transaction --
-----------------------
procedure Start_Transaction (LCD : ST7735R_Screen) is
begin
LCD.CS.Clear;
end Start_Transaction;
---------------------
-- End_Transaction --
---------------------
procedure End_Transaction (LCD : ST7735R_Screen) is
begin
LCD.CS.Set;
end End_Transaction;
-------------------
-- Write_Command --
-------------------
procedure Write_Command (LCD : ST7735R_Screen;
Cmd : UInt8)
is
Status : SPI_Status;
begin
Start_Transaction (LCD);
Set_Command_Mode (LCD);
LCD.Port.Transmit (SPI_Data_8b'(1 => Cmd),
Status);
End_Transaction (LCD);
if Status /= Ok then
-- No error handling...
raise Program_Error;
end if;
end Write_Command;
-------------------
-- Write_Command --
-------------------
procedure Write_Command (LCD : ST7735R_Screen;
Cmd : UInt8;
Data : HAL.UInt8_Array)
is
begin
Write_Command (LCD, Cmd);
Write_Data (LCD, Data);
end Write_Command;
----------------
-- Write_Data --
----------------
procedure Write_Data (LCD : ST7735R_Screen;
Data : UInt8)
is
Status : SPI_Status;
begin
Start_Transaction (LCD);
Set_Data_Mode (LCD);
LCD.Port.Transmit (SPI_Data_8b'(1 => Data),
Status);
End_Transaction (LCD);
if Status /= Ok then
-- No error handling...
raise Program_Error;
end if;
end Write_Data;
----------------
-- Write_Data --
----------------
procedure Write_Data (LCD : ST7735R_Screen;
Data : HAL.UInt8_Array)
is
Status : SPI_Status;
begin
Start_Transaction (LCD);
Set_Data_Mode (LCD);
LCD.Port.Transmit (SPI_Data_8b (Data), Status);
if Status /= Ok then
-- No error handling...
raise Program_Error;
end if;
End_Transaction (LCD);
end Write_Data;
---------------
-- Read_Data --
---------------
procedure Read_Data (LCD : ST7735R_Screen;
Data : out UInt16)
is
SPI_Data : SPI_Data_16b (1 .. 1);
Status : SPI_Status;
begin
Start_Transaction (LCD);
Set_Data_Mode (LCD);
LCD.Port.Receive (SPI_Data, Status);
if Status /= Ok then
-- No error handling...
raise Program_Error;
end if;
End_Transaction (LCD);
Data := SPI_Data (SPI_Data'First);
end Read_Data;
----------------
-- Initialize --
----------------
procedure Initialize (LCD : in out ST7735R_Screen) is
begin
LCD.Layer.LCD := LCD'Unchecked_Access;
LCD.RST.Clear;
LCD.Time.Delay_Milliseconds (100);
LCD.RST.Set;
LCD.Time.Delay_Milliseconds (100);
-- Sleep Exit
Write_Command (LCD, 16#11#);
LCD.Time.Delay_Milliseconds (100);
LCD.Initialized := True;
end Initialize;
-----------------
-- Initialized --
-----------------
overriding
function Initialized (LCD : ST7735R_Screen) return Boolean is
(LCD.Initialized);
-------------
-- Turn_On --
-------------
procedure Turn_On (LCD : ST7735R_Screen) is
begin
Write_Command (LCD, 16#29#);
end Turn_On;
--------------
-- Turn_Off --
--------------
procedure Turn_Off (LCD : ST7735R_Screen) is
begin
Write_Command (LCD, 16#28#);
end Turn_Off;
--------------------------
-- Display_Inversion_On --
--------------------------
procedure Display_Inversion_On (LCD : ST7735R_Screen) is
begin
Write_Command (LCD, 16#21#);
end Display_Inversion_On;
---------------------------
-- Display_Inversion_Off --
---------------------------
procedure Display_Inversion_Off (LCD : ST7735R_Screen) is
begin
Write_Command (LCD, 16#20#);
end Display_Inversion_Off;
---------------
-- Gamma_Set --
---------------
procedure Gamma_Set (LCD : ST7735R_Screen; Gamma_Curve : UInt4) is
begin
Write_Command (LCD, 16#26#, (0 => UInt8 (Gamma_Curve)));
end Gamma_Set;
----------------------
-- Set_Pixel_Format --
----------------------
procedure Set_Pixel_Format (LCD : ST7735R_Screen; Pix_Fmt : Pixel_Format) is
Value : constant UInt8 := (case Pix_Fmt is
when Pixel_12bits => 2#011#,
when Pixel_16bits => 2#101#,
when Pixel_18bits => 2#110#);
begin
Write_Command (LCD, 16#3A#, (0 => Value));
end Set_Pixel_Format;
----------------------------
-- Set_Memory_Data_Access --
----------------------------
procedure Set_Memory_Data_Access
(LCD : ST7735R_Screen;
Color_Order : RGB_BGR_Order;
Vertical : Vertical_Refresh_Order;
Horizontal : Horizontal_Refresh_Order;
Row_Addr_Order : Row_Address_Order;
Column_Addr_Order : Column_Address_Order;
Row_Column_Exchange : Boolean)
is
Value : MADCTL;
begin
Value.MY := Row_Addr_Order;
Value.MX := Column_Addr_Order;
Value.MV := Row_Column_Exchange;
Value.ML := Vertical;
Value.RGB := Color_Order;
Value.MH := Horizontal;
Write_Command (LCD, 16#36#, (0 => To_UInt8 (Value)));
end Set_Memory_Data_Access;
---------------------------
-- Set_Frame_Rate_Normal --
---------------------------
procedure Set_Frame_Rate_Normal
(LCD : ST7735R_Screen;
RTN : UInt4;
Front_Porch : UInt6;
Back_Porch : UInt6)
is
begin
Write_Command (LCD, 16#B1#,
(UInt8 (RTN), UInt8 (Front_Porch), UInt8 (Back_Porch)));
end Set_Frame_Rate_Normal;
-------------------------
-- Set_Frame_Rate_Idle --
-------------------------
procedure Set_Frame_Rate_Idle
(LCD : ST7735R_Screen;
RTN : UInt4;
Front_Porch : UInt6;
Back_Porch : UInt6)
is
begin
Write_Command (LCD, 16#B2#,
(UInt8 (RTN), UInt8 (Front_Porch), UInt8 (Back_Porch)));
end Set_Frame_Rate_Idle;
---------------------------------
-- Set_Frame_Rate_Partial_Full --
---------------------------------
procedure Set_Frame_Rate_Partial_Full
(LCD : ST7735R_Screen;
RTN_Part : UInt4;
Front_Porch_Part : UInt6;
Back_Porch_Part : UInt6;
RTN_Full : UInt4;
Front_Porch_Full : UInt6;
Back_Porch_Full : UInt6)
is
begin
Write_Command (LCD, 16#B3#,
(UInt8 (RTN_Part),
UInt8 (Front_Porch_Part),
UInt8 (Back_Porch_Part),
UInt8 (RTN_Full),
UInt8 (Front_Porch_Full),
UInt8 (Back_Porch_Full)));
end Set_Frame_Rate_Partial_Full;
---------------------------
-- Set_Inversion_Control --
---------------------------
procedure Set_Inversion_Control
(LCD : ST7735R_Screen;
Normal, Idle, Full_Partial : Inversion_Control)
is
Value : UInt8 := 0;
begin
if Normal = Line_Inversion then
Value := Value or 2#100#;
end if;
if Idle = Line_Inversion then
Value := Value or 2#010#;
end if;
if Full_Partial = Line_Inversion then
Value := Value or 2#001#;
end if;
Write_Command (LCD, 16#B4#, (0 => Value));
end Set_Inversion_Control;
-------------------------
-- Set_Power_Control_1 --
-------------------------
procedure Set_Power_Control_1
(LCD : ST7735R_Screen;
AVDD : UInt3;
VRHP : UInt5;
VRHN : UInt5;
MODE : UInt2)
is
P1, P2, P3 : UInt8;
begin
P1 := Shift_Left (UInt8 (AVDD), 5) or UInt8 (VRHP);
P2 := UInt8 (VRHN);
P3 := Shift_Left (UInt8 (MODE), 6) or 2#00_0100#;
Write_Command (LCD, 16#C0#, (P1, P2, P3));
end Set_Power_Control_1;
-------------------------
-- Set_Power_Control_2 --
-------------------------
procedure Set_Power_Control_2
(LCD : ST7735R_Screen;
VGH25 : UInt2;
VGSEL : UInt2;
VGHBT : UInt2)
is
P1 : UInt8;
begin
P1 := Shift_Left (UInt8 (VGH25), 6) or
Shift_Left (UInt8 (VGSEL), 2) or
UInt8 (VGHBT);
Write_Command (LCD, 16#C1#, (0 => P1));
end Set_Power_Control_2;
-------------------------
-- Set_Power_Control_3 --
-------------------------
procedure Set_Power_Control_3
(LCD : ST7735R_Screen;
P1, P2 : UInt8)
is
begin
Write_Command (LCD, 16#C2#, (P1, P2));
end Set_Power_Control_3;
-------------------------
-- Set_Power_Control_4 --
-------------------------
procedure Set_Power_Control_4
(LCD : ST7735R_Screen;
P1, P2 : UInt8)
is
begin
Write_Command (LCD, 16#C3#, (P1, P2));
end Set_Power_Control_4;
-------------------------
-- Set_Power_Control_5 --
-------------------------
procedure Set_Power_Control_5
(LCD : ST7735R_Screen;
P1, P2 : UInt8)
is
begin
Write_Command (LCD, 16#C4#, (P1, P2));
end Set_Power_Control_5;
--------------
-- Set_Vcom --
--------------
procedure Set_Vcom (LCD : ST7735R_Screen; VCOMS : UInt6) is
begin
Write_Command (LCD, 16#C5#, (0 => UInt8 (VCOMS)));
end Set_Vcom;
------------------------
-- Set_Column_Address --
------------------------
procedure Set_Column_Address (LCD : ST7735R_Screen; X_Start, X_End : UInt16)
is
P1, P2, P3, P4 : UInt8;
begin
P1 := UInt8 (Shift_Right (X_Start and 16#FF#, 8));
P2 := UInt8 (X_Start and 16#FF#);
P3 := UInt8 (Shift_Right (X_End and 16#FF#, 8));
P4 := UInt8 (X_End and 16#FF#);
Write_Command (LCD, 16#2A#, (P1, P2, P3, P4));
end Set_Column_Address;
---------------------
-- Set_Row_Address --
---------------------
procedure Set_Row_Address (LCD : ST7735R_Screen; Y_Start, Y_End : UInt16)
is
P1, P2, P3, P4 : UInt8;
begin
P1 := UInt8 (Shift_Right (Y_Start and 16#FF#, 8));
P2 := UInt8 (Y_Start and 16#FF#);
P3 := UInt8 (Shift_Right (Y_End and 16#FF#, 8));
P4 := UInt8 (Y_End and 16#FF#);
Write_Command (LCD, 16#2B#, (P1, P2, P3, P4));
end Set_Row_Address;
-----------------
-- Set_Address --
-----------------
procedure Set_Address (LCD : ST7735R_Screen;
X_Start, X_End, Y_Start, Y_End : UInt16)
is
begin
Set_Column_Address (LCD, X_Start, X_End);
Set_Row_Address (LCD, Y_Start, Y_End);
end Set_Address;
---------------
-- Set_Pixel --
---------------
procedure Set_Pixel (LCD : ST7735R_Screen;
X, Y : UInt16;
Color : UInt16)
is
Data : HAL.UInt16_Array (1 .. 1) := (1 => Color);
begin
Set_Address (LCD, X, X + 1, Y, Y + 1);
Write_Raw_Pixels (LCD, Data);
end Set_Pixel;
-----------
-- Pixel --
-----------
function Pixel (LCD : ST7735R_Screen;
X, Y : UInt16)
return UInt16
is
Ret : UInt16;
begin
Set_Address (LCD, X, X + 1, Y, Y + 1);
Read_Data (LCD, Ret);
return Ret;
end Pixel;
----------------------
-- Write_Raw_Pixels --
----------------------
procedure Write_Raw_Pixels (LCD : ST7735R_Screen;
Data : in out HAL.UInt8_Array)
is
Index : Natural := Data'First + 1;
Tmp : UInt8;
begin
-- The ST7735R uses a different endianness than our bitmaps
while Index <= Data'Last loop
Tmp := Data (Index);
Data (Index) := Data (Index - 1);
Data (Index - 1) := Tmp;
Index := Index + 1;
end loop;
Write_Command (LCD, 16#2C#);
Write_Data (LCD, Data);
end Write_Raw_Pixels;
----------------------
-- Write_Raw_Pixels --
----------------------
procedure Write_Raw_Pixels (LCD : ST7735R_Screen;
Data : in out HAL.UInt16_Array)
is
Data_8b : HAL.UInt8_Array (1 .. Data'Length * 2)
with Address => Data'Address;
begin
Write_Raw_Pixels (LCD, Data_8b);
end Write_Raw_Pixels;
--------------------
-- Get_Max_Layers --
--------------------
overriding
function Max_Layers
(Display : ST7735R_Screen) return Positive is (1);
------------------
-- Is_Supported --
------------------
overriding
function Supported
(Display : ST7735R_Screen;
Mode : FB_Color_Mode) return Boolean is
(Mode = HAL.Bitmap.RGB_565);
---------------------
-- Set_Orientation --
---------------------
overriding
procedure Set_Orientation
(Display : in out ST7735R_Screen;
Orientation : Display_Orientation)
is
begin
null;
end Set_Orientation;
--------------
-- Set_Mode --
--------------
overriding
procedure Set_Mode
(Display : in out ST7735R_Screen;
Mode : Wait_Mode)
is
begin
null;
end Set_Mode;
---------------
-- Get_Width --
---------------
overriding
function Width
(Display : ST7735R_Screen) return Positive is (Screen_Width);
----------------
-- Get_Height --
----------------
overriding
function Height
(Display : ST7735R_Screen) return Positive is (Screen_Height);
----------------
-- Is_Swapped --
----------------
overriding
function Swapped
(Display : ST7735R_Screen) return Boolean is (False);
--------------------
-- Set_Background --
--------------------
overriding
procedure Set_Background
(Display : ST7735R_Screen; R, G, B : UInt8)
is
begin
-- Does it make sense when there's no alpha channel...
raise Program_Error;
end Set_Background;
----------------------
-- Initialize_Layer --
----------------------
overriding
procedure Initialize_Layer
(Display : in out ST7735R_Screen;
Layer : Positive;
Mode : FB_Color_Mode;
X : Natural := 0;
Y : Natural := 0;
Width : Positive := Positive'Last;
Height : Positive := Positive'Last)
is
pragma Unreferenced (X, Y, Width, Height, Display);
begin
if Layer /= 1 or else Mode /= RGB_565 then
raise Program_Error;
end if;
end Initialize_Layer;
-----------------
-- Initialized --
-----------------
overriding
function Initialized
(Display : ST7735R_Screen;
Layer : Positive) return Boolean
is
pragma Unreferenced (Display);
begin
return Layer = 1;
end Initialized;
------------------
-- Update_Layer --
------------------
overriding
procedure Update_Layer
(Display : in out ST7735R_Screen;
Layer : Positive;
Copy_Back : Boolean := False)
is
pragma Unreferenced (Copy_Back, Display);
begin
if Layer /= 1 then
raise Program_Error;
end if;
end Update_Layer;
-------------------
-- Update_Layers --
-------------------
overriding
procedure Update_Layers
(Display : in out ST7735R_Screen)
is
begin
Display.Update_Layer (1);
end Update_Layers;
--------------------
-- Get_Color_Mode --
--------------------
overriding
function Color_Mode
(Display : ST7735R_Screen;
Layer : Positive) return FB_Color_Mode
is
pragma Unreferenced (Display);
begin
if Layer /= 1 then
raise Program_Error;
end if;
return RGB_565;
end Color_Mode;
-----------------------
-- Get_Hidden_Buffer --
-----------------------
overriding
function Hidden_Buffer
(Display : in out ST7735R_Screen;
Layer : Positive) return not null HAL.Bitmap.Any_Bitmap_Buffer
is
begin
if Layer /= 1 then
raise Program_Error;
end if;
return Display.Layer'Unchecked_Access;
end Hidden_Buffer;
----------------
-- Pixel_Size --
----------------
overriding
function Pixel_Size
(Display : ST7735R_Screen;
Layer : Positive) return Positive is (16);
----------------
-- Set_Source --
----------------
overriding
procedure Set_Source (Buffer : in out ST7735R_Bitmap_Buffer;
Native : UInt32)
is
begin
Buffer.Native_Source := Native;
end Set_Source;
------------
-- Source --
------------
overriding
function Source
(Buffer : ST7735R_Bitmap_Buffer)
return UInt32
is
begin
return Buffer.Native_Source;
end Source;
---------------
-- Set_Pixel --
---------------
overriding
procedure Set_Pixel
(Buffer : in out ST7735R_Bitmap_Buffer;
Pt : Point)
is
begin
Buffer.LCD.Set_Pixel (UInt16 (Pt.X), UInt16 (Pt.Y),
UInt16 (Buffer.Native_Source));
end Set_Pixel;
---------------------
-- Set_Pixel_Blend --
---------------------
overriding
procedure Set_Pixel_Blend
(Buffer : in out ST7735R_Bitmap_Buffer;
Pt : Point) renames Set_Pixel;
-----------
-- Pixel --
-----------
overriding
function Pixel
(Buffer : ST7735R_Bitmap_Buffer;
Pt : Point)
return UInt32
is (UInt32 (Buffer.LCD.Pixel (UInt16 (Pt.X), UInt16 (Pt.Y))));
end ST7735R;
|
sonneveld/adazmq | Ada | 2,265 | adb | -- Task ventilator
-- Binds PUSH socket to tcp://localhost:5557
-- Sends batch of tasks to workers via that socket
with Ada.Command_Line;
with Ada.Text_IO;
with Ada.Numerics.Discrete_Random;
with GNAT.Formatted_String;
with ZMQ;
procedure TaskVent is
use type GNAT.Formatted_String.Formatted_String;
type Workload_T is range 1 .. 100;
package Random_Workload is new Ada.Numerics.Discrete_Random (Workload_T);
function Main return Ada.Command_Line.Exit_Status
is
Random_Workload_Seed : Random_Workload.Generator;
begin
declare
Context : ZMQ.Context_Type := ZMQ.New_Context;
-- Socket to send messages on
Sender : constant ZMQ.Socket_Type'Class := Context.New_Socket (ZMQ.ZMQ_PUSH);
-- Socket to send start of batch message on
Sink : constant ZMQ.Socket_Type'Class := Context.New_Socket (ZMQ.ZMQ_PUSH);
begin
Sender.Bind ("tcp://*:5557");
Sink.Connect ("tcp://localhost:5558");
Ada.Text_IO.Put ("Press Enter when the workers are ready: ");
declare
Dummy : String := Ada.Text_IO.Get_Line;
begin
null;
end;
Ada.Text_IO.Put_Line ("Sending tasks to workers...");
-- The first message is "0" and signals start of batch
Sink.Send ("0");
-- -- Initialize random number generator
Random_Workload.Reset (Random_Workload_Seed);
-- Send 100 tasks
declare
total_msec : Integer := 0; -- Total expected cost in msecs
begin
for Task_Nbr in 1 .. 100 loop
declare
-- Random workload from 1 to 100msecs
Workload : constant Workload_T := Random_Workload.Random (Random_Workload_Seed);
begin
total_msec := total_msec + Integer (Workload);
Sender.Send (-(+"%d"&Integer (Workload)));
end;
end loop;
Ada.Text_IO.Put_Line (-(+"Total expected cost: %d msec"&Integer (total_msec)));
end;
Sink.Close;
Sender.Close;
Context.Term;
end;
return 0;
end Main;
begin
Ada.Command_Line.Set_Exit_Status (Main);
end TaskVent;
|
jscparker/math_packages | Ada | 2,332 | adb |
with Ada.Numerics.Generic_Elementary_Functions;
package body Orbit_2 is
package mth is new Ada.Numerics.Generic_Elementary_Functions(Real);
use mth;
function Norm (Y : Dynamical_Variable)
return Real
is
Sum : Real := +0.0;
begin
for i in Dyn_Index loop
Sum := Sum + Abs Y(i);
--Sum := Sum + Y(i) * Y(i);
end loop;
return Sum;
end Norm;
function "-"
(Left : Dynamical_Variable;
Right : Dynamical_Variable)
return Dynamical_Variable
is
Result : Dynamical_Variable;
begin
for I in Dyn_Index loop
Result(I) := Left(I) - Right(I);
end loop;
return Result;
end "-";
function "*"
(Left : Real;
Right : Dynamical_Variable)
return Dynamical_Variable
is
Result : Dynamical_Variable;
begin
for I in Dyn_Index loop
Result(I) := Left * Right(I);
end loop;
return Result;
end "*";
function "+"
(Left : Dynamical_Variable;
Right : Dynamical_Variable)
return Dynamical_Variable
is
Result : Dynamical_Variable;
begin
for I in Dyn_Index loop
Result(I) := Left(I) + Right(I);
end loop;
return Result;
end "+";
-- The differential equation is dY/dt = F (t, Y)
function F
(Time : Real;
Y : Dynamical_Variable)
return Dynamical_Variable
is
Deriv : Dynamical_Variable;
R2, R3, R6, x, z : Real;
One : constant Real := +1.0;
Four : constant Real := +4.0;
Min_Allowed_Real : constant Real := 2.0**(Real'Machine_Emin / 2);
begin
x := Y(Dyn_Index'First + 0);
z := Y(Dyn_Index'First + 1);
R2 := x*x + z*z;
R6 := R2*R2*R2;
R3 := Sqrt (One / (R6 + Min_Allowed_Real));
Deriv(Dyn_Index'First + 0) := -Four * x * R3;
Deriv(Dyn_Index'First + 1) := -Four * z * R3;
return Deriv;
end F;
function Energy
(Y : in Dynamical_Variable;
Y_dot : in Dynamical_Variable)
return Real
is
x : Real := Y(Dyn_Index'First + 0);
z : Real := Y(Dyn_Index'First + 1);
u : Real := Y_dot(Dyn_Index'First + 0);
v : Real := Y_dot(Dyn_Index'First + 1);
R : Real;
Result : Real;
begin
R := Sqrt (X*X + Z*Z);
Result := 0.25 * (U*U + V*V) - 2.0 / R;
return Result;
end Energy;
end Orbit_2;
|
Rodeo-McCabe/orka | Ada | 3,616 | ads | -- SPDX-License-Identifier: Apache-2.0
--
-- Copyright (c) 2016 onox <[email protected]>
--
-- Licensed under the Apache License, Version 2.0 (the "License");
-- you may not use this file except in compliance with the License.
-- You may obtain a copy of the License at
--
-- http://www.apache.org/licenses/LICENSE-2.0
--
-- Unless required by applicable law or agreed to in writing, software
-- distributed under the License is distributed on an "AS IS" BASIS,
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-- See the License for the specific language governing permissions and
-- limitations under the License.
private with Ada.Containers.Indefinite_Holders;
private with Orka.Instances;
private with Orka.Rendering.Buffers.MDI;
private with Orka.Scenes.Singles.Trees;
private with Orka.Transforms.Singles.Matrices;
private with Orka.Types;
with Orka.Behaviors;
with Orka.Culling;
package Orka.Resources.Models is
pragma Preelaborate;
type Model_Instance is abstract limited new Behaviors.Behavior with private;
type Model_Instance_Ptr is not null access all Model_Instance'Class;
procedure Update_Transforms
(Object : in out Model_Instance;
View_Position : Behaviors.Vector4);
-----------------------------------------------------------------------------
type Model_Group is tagged limited private;
type Group_Access is access Model_Group;
procedure Add_Instance
(Object : access Model_Group;
Instance : in out Model_Instance_Ptr);
procedure Remove_Instance
(Object : in out Model_Group;
Instance : in out Model_Instance_Ptr);
procedure Cull (Object : in out Model_Group);
procedure Render (Object : in out Model_Group);
procedure After_Render (Object : in out Model_Group);
-----------------------------------------------------------------------------
type Model is limited new Resource with private;
type Model_Ptr is not null access all Model;
function Create_Group
(Object : aliased in out Model;
Culler : Culling.Culler_Ptr;
Capacity : Positive) return Group_Access;
Model_Load_Error : exception renames Resource_Load_Error;
private
package Trees renames Scenes.Singles.Trees;
package Transforms renames Orka.Transforms.Singles.Matrices;
type Cursor_Array is array (Positive range <>) of Trees.Cursor;
package Cursor_Array_Holder is new Ada.Containers.Indefinite_Holders
(Element_Type => Cursor_Array);
type Model_Scene is limited record
Scene : Trees.Tree;
Shapes : Cursor_Array_Holder.Holder;
end record;
type Model_Scene_Ptr is not null access Model_Scene;
type Model is limited new Resource with record
Scene : Model_Scene_Ptr;
Batch : Rendering.Buffers.MDI.Batch;
Bounds : Rendering.Buffers.Buffer (Types.Single_Vector_Type);
end record;
type Partition_Index_Type is mod 4;
package Model_Instances is new Orka.Instances (Partition_Index_Type);
type Model_Group is tagged limited record
Model : access Orka.Resources.Models.Model;
Instances : Model_Instances.Manager;
Cull_Instance : Culling.Cull_Instance;
Compacted_Transforms : Rendering.Buffers.Buffer (Types.Single_Matrix_Type);
Compacted_Commands : Rendering.Buffers.Buffer (Types.Elements_Command_Type);
end record;
type Model_Instance is abstract limited new Behaviors.Behavior with record
Group : access Model_Group;
Scene : Trees.Tree;
Instance : Model_Instances.Cursor;
end record;
end Orka.Resources.Models;
|
pombredanne/ravenadm | Ada | 4,477 | ads | -- This file is covered by the Internet Software Consortium (ISC) License
-- Reference: ../License.txt
with Terminal_Interface.Curses;
with Port_Specification;
with HelperText;
package Options_Dialog is
package TIC renames Terminal_Interface.Curses;
package PSP renames Port_Specification;
package HT renames HelperText;
-- Initialize the curses screen.
-- Returns False if no color support (curses not used at all)
function launch_dialog (specification : in out PSP.Portspecs) return Boolean;
dev_error : exception;
private
appline_max : constant Positive := 79;
type zones is (keymenu, dialog);
type group_type is (radio, restrict, unlimited);
subtype appline is TIC.Attributed_String (1 .. appline_max);
subtype optentry is String (1 .. 71);
type optentry_rec is record
template : optentry;
relative_vert : Positive;
default_value : Boolean;
current_value : Boolean;
ticked_value : Boolean;
member_group : Natural;
end record;
type grouping_rec is record
template : optentry;
relative_vert : Positive;
behavior : group_type;
end record;
type optstorage is array (1 .. 52) of optentry_rec;
type group_titles is array (1 .. 26) of grouping_rec;
type palette_rec is
record
palette : TIC.Color_Pair;
attribute : TIC.Character_Attribute_Set;
end record;
cursor_vis : TIC.Cursor_Visibility := TIC.Invisible;
app_width : constant TIC.Column_Count := 80;
dialog_height : constant TIC.Line_Count := 82;
normal : constant TIC.Character_Attribute_Set := (others => False);
bright : constant TIC.Character_Attribute_Set := (Bold_Character => True,
others => False);
dimmed : constant TIC.Character_Attribute_Set := (Dim_Character => True,
others => False);
zone_keymenu : TIC.Window;
zone_dialog : TIC.Window;
c_standard : TIC.Color_Pair;
c_key_desc : TIC.Color_Pair;
c_title : TIC.Color_Pair;
c_trimmings : TIC.Color_Pair;
c_optbox_title : TIC.Color_Pair;
c_group_text : TIC.Color_Pair;
c_group_trim : TIC.Color_Pair;
c_letters : TIC.Color_Pair;
c_options : TIC.Color_Pair;
c_inv_gray : TIC.Color_Pair;
c_tick_on : TIC.Color_Pair;
c_tick_delta : TIC.Color_Pair;
c_arrow : TIC.Color_Pair;
last_alphakey : Character := 'A';
num_std_options : Natural;
port_namebase : HT.Text;
port_version : HT.Text;
port_sdesc : HT.Text;
formatted_opts : optstorage;
formatted_grps : group_titles;
num_groups : Natural;
num_options : Natural;
arrow_points : Positive;
offset : Natural;
function establish_colors return Boolean;
function Start_Curses_Mode return Boolean;
function launch_keymenu_zone return Boolean;
function launch_dialog_zone return Boolean;
function zone_window (zone : zones) return TIC.Window;
function index_to_center (display_text : String) return TIC.Column_Position;
function title_bar_contents return String;
procedure Refresh_Zone (zone : zones);
procedure Return_To_Text_Mode;
procedure draw_static_keymenu;
procedure draw_static_dialog;
procedure terminate_dialog;
procedure setup_parameters (specification : PSP.Portspecs);
procedure handle_user_commands;
procedure populate_dialog;
procedure Scrawl
(zone : zones;
information : TIC.Attributed_String;
at_line : TIC.Line_Position;
at_column : TIC.Column_Position := 0);
function custom_message (message : String;
attribute : TIC.Character_Attribute_Set;
pen_color : TIC.Color_Pair) return TIC.Attributed_String;
procedure touch_up (ATS : in out TIC.Attributed_String;
From_index : Positive;
length : Positive;
attribute : TIC.Character_Attribute_Set;
pen_color : TIC.Color_Pair);
function colorize_groups (textdata : String) return TIC.Attributed_String;
function colorize_option (textdata : String) return TIC.Attributed_String;
procedure toggle_option (option_index : Positive);
procedure save_options;
end Options_Dialog;
|
docandrew/troodon | Ada | 1,108 | ads | pragma Ada_2012;
pragma Style_Checks (Off);
with Interfaces.C; use Interfaces.C;
package ft2build is
--***************************************************************************
-- *
-- * ft2build.h
-- *
-- * FreeType 2 build and setup macros.
-- *
-- * Copyright (C) 1996-2020 by
-- * David Turner, Robert Wilhelm, and Werner Lemberg.
-- *
-- * This file is part of the FreeType project, and may only be used,
-- * modified, and distributed under the terms of the FreeType project
-- * license, LICENSE.TXT. By continuing to use, modify, or distribute
-- * this file you indicate that you have read the license and
-- * understand and accept it fully.
-- *
--
--*************************************************************************
-- *
-- * This is the 'entry point' for FreeType header file inclusions, to be
-- * loaded before all other header files.
-- *
-- * A typical example is
-- *
-- * ```
-- * #include <ft2build.h>
-- * #include <freetype/freetype.h>
-- * ```
-- *
--
-- END
end ft2build;
|
tum-ei-rcs/StratoX | Ada | 6,546 | adb |
package body Generic_Queue with SPARK_Mode is
-- Buffer Structure:
-- | 0:X | 1:– | 2:– | 3:– |
-- ^h ^t
-- head(h) points to oldest, tail(t) to next free,
-- empty: t=h, full: t=h => Flag Self.hasElements required
---------------
-- copy_array
---------------
procedure copy_array (Self : in Buffer_Tag; elements : out Element_Array) with
Pre'Class => Self.Length >= elements'Length,
Post'Class => Self.Length = Self.Length'Old,
Global => null;
-- copies n front elements from Self to elements, where n=elements'length
procedure copy_array (Self : in Buffer_Tag; elements : out Element_Array) is
pos : Index_Type := Self.index_head;
begin
for e in elements'Range loop
elements (e) := Self.Buffer (pos);
pos := pos + 1; -- mod type. Does the right thing.
end loop;
end copy_array;
-----------
-- Length
-----------
function Length( Self : in Buffer_Tag ) return Length_Type is
begin
if Self.Full then
return Length_Type'Last;
else
return Length_Type( Index_Type(Self.index_tail - Self.index_head) );
end if;
end Length;
--------
-- Full
--------
function Full( Self : in Buffer_Tag ) return Boolean is ((Self.index_tail = Self.index_head) and Self.hasElements);
---------
-- Empty
---------
function Empty( Self : in Buffer_Tag ) return Boolean is (not Self.hasElements);
----------
-- clear
----------
procedure clear( Self : in out Buffer_Tag ) is
begin
Self.index_head := Index_Type'First;
Self.index_tail := Index_Type'First;
Self.hasElements := False;
end clear;
----------
-- fill
----------
-- procedure fill( Self : in out Buffer_Tag ) is
-- begin
-- Self.index_tail := Self.index_head;
-- Self.hasElements := True;
-- end fill;
-------------
-- push_back
-------------
procedure push_back( Self : in out Buffer_Tag; element : Element_Type) is
begin
if Self.Full then -- overflow
Self.index_head := Index_Type'Succ( Self.index_head );
if Self.Num_Overflows < Natural'Last then
Self.Num_Overflows := Self.Num_Overflows + 1;
end if;
end if;
Self.Buffer( Self.index_tail) := element;
Self.index_tail := Index_Type'Succ( Self.index_tail );
Self.hasElements := True;
end push_back;
--------------
-- push_front
--------------
procedure push_front( Self : in out Buffer_Tag; element : Element_Type ) is
begin
if Self.Full then -- overflow
Self.index_tail := Index_Type'Pred( Self.index_tail );
if Self.Num_Overflows < Natural'Last then
Self.Num_Overflows := Self.Num_Overflows + 1;
end if;
end if;
Self.index_head := Index_Type'Pred( Self.index_head );
Self.Buffer( Self.index_head) := element;
Self.hasElements := True;
end push_front;
-------------
-- pop_front
-------------
procedure pop_front( Self : in out Buffer_Tag; element : out Element_Type) is
begin
element := Self.Buffer( Self.index_head);
Self.index_head := Index_Type'Succ( Self.index_head );
if Self.index_tail = Self.index_head then
Self.hasElements := False;
end if;
end pop_front;
procedure pop_front( Self : in out Buffer_Tag; elements : out Element_Array ) is
begin
copy_array (Self, elements);
Self.index_head := Self.index_head + Index_Type'Mod (elements'Length);
if Self.index_tail = Self.index_head then
Self.hasElements := False;
end if;
end pop_front;
-- entry pop_front_blocking( Self : in out Buffer_Tag; element : out Element_Type ) when Self.hasElements is
-- begin
-- element := Self.Buffer( Self.index_head);
-- Self.index_head := Index_Type'Succ( Self.index_head );
-- if Self.index_tail = Self.index_head then
-- Self.hasElements := False;
-- end if;
-- end pop_front_blocking;
------------
-- pop_back
------------
procedure pop_back( Self : in out Buffer_Tag; element : out Element_Type) is
begin
Self.index_tail := Index_Type'Pred( Self.index_tail );
element := Self.Buffer( Self.index_tail);
if Self.index_tail = Self.index_head then
Self.hasElements := False;
end if;
end pop_back;
-----------
-- pop_all
-----------
procedure pop_all( Self : in out Buffer_Tag; elements : out Element_Array ) is
begin
copy_array (Self, elements);
Self.index_tail := 0;
Self.index_head := 0;
Self.hasElements := False;
end pop_all;
-----------
-- get_all
-----------
procedure get_all( Self : in Buffer_Tag; elements : out Element_Array ) is
begin
copy_array (Self, elements);
end get_all;
-------------
-- get_front
-------------
procedure get_front( Self : in Buffer_Tag; element : out Element_Type ) is
begin
element := Self.Buffer( Self.index_head );
end get_front;
procedure get_front( Self : in Buffer_Tag; elements : out Element_Array ) is
begin
copy_array (Self, elements);
end get_front;
-------------
-- get_back
-------------
procedure get_back( Self : in Buffer_Tag; element : out Element_Type ) is
begin
element := Self.Buffer( Self.index_tail - 1 );
end get_back;
-- FIXME: remove this function?
-- function get_at( Self : in out Buffer_Tag; index : Index_Type ) return Element_Type is
-- begin
-- pragma Assert ( Self.index_head <= index and index < Self.index_tail );
-- return Self.Buffer( index );
-- end get_at;
-----------------
-- get_nth_first
-----------------
procedure get_nth_first( Self : in Buffer_Tag; nth : Index_Type; element : out Element_Type) is
begin
pragma Assert ( Self.index_head <= Self.index_tail-1 - nth );
element := Self.Buffer( Self.index_tail-1 - nth );
end get_nth_first;
----------------
-- get_nth_last
----------------
procedure get_nth_last( Self : in Buffer_Tag; nth : Index_Type; element : out Element_Type) is
begin
pragma Assert ( Self.index_head + nth <= Self.index_tail-1 );
element := Self.Buffer( Self.index_head + nth );
end get_nth_last;
function Overflows( Self : in Buffer_Tag ) return Natural is
begin
return Self.Num_Overflows;
end Overflows;
end Generic_Queue;
|
rveenker/sdlada | Ada | 5,074 | adb | with Ada.Command_Line;
with Ada.Text_IO;
-- with Ada.Unchecked_Conversion;
-- with Interfaces.C.Pointers;
with SDL;
with SDL.Error;
with SDL.Events.Events;
with SDL.Events.Keyboards;
with SDL.Log;
with SDL.TTFs.Makers;
with SDL.Video.Palettes;
with SDL.Video.Pixel_Formats;
-- with SDL.Video.Pixels;
with SDL.Video.Rectangles;
-- with SDL.Video.Renderers.Makers;
-- with SDL.Video.Textures.Makers;
with SDL.Video.Surfaces;
with SDL.Video.Windows.Makers;
with SDL.Versions;
with System;
with System.Address_To_Access_Conversions;
procedure TTF is
W : SDL.Video.Windows.Window;
Window_Surface : SDL.Video.Surfaces.Surface;
-- Renderer : SDL.Video.Renderers.Renderer;
Font : SDL.TTFs.Fonts;
Text_Surface : SDL.Video.Surfaces.Surface;
-- Text_Texture : SDL.Video.Textures.Texture;
begin
if Ada.Command_Line.Argument_Count = 0 then
Ada.Text_IO.Put_Line ("Error! Enter TTF font path on command line.");
else
SDL.Log.Set (Category => SDL.Log.Application, Priority => SDL.Log.Debug);
if SDL.Initialise (Flags => SDL.Enable_Screen) = True and then SDL.TTFs.Initialise = True then
SDL.Video.Windows.Makers.Create (Win => W,
Title => "TTF (Esc to exit)",
Position => SDL.Natural_Coordinates'(X => 100, Y => 100),
Size => SDL.Positive_Sizes'(800, 640),
Flags => SDL.Video.Windows.Resizable);
-- SDL.Video.Renderers.Makers.Create (Renderer, W);
Window_Surface := W.Get_Surface;
-- SDL.TTFs.Makers.Create (Font, "/home/laguest/.fonts/Belga.ttf", 24);
SDL.TTFs.Makers.Create (Font, Ada.Command_Line.Argument (1), 36);
Text_Surface := Font.Render_Solid (Text => "Hello from SDLAda",
Colour => SDL.Video.Palettes.Colour'(Red => 0,
Green => 200,
Blue => 200,
Alpha => 255));
-- Text_Surface.Set_Blend_Mode (SDL.Video.None);
-- Text_Surface := Font.Render_Shaded (Text => "Hello from SDLAda",
-- Colour => SDL.Video.Palettes.Colour'(Red => 255,
-- Green => 255,
-- Blue => 255,
-- Alpha => 255),
-- Background_Colour => SDL.Video.Palettes.Colour'(Red => 0,
-- Green => 20,
-- Blue => 250,
-- Alpha => 255));
-- Text_Surface := Font.Render_Blended (Text => "Hello from SDLAda",
-- Colour => SDL.Video.Palettes.Colour'(Red => 50, others => 255));
-- SDL.Video.Textures.Makers.Create (Text_Texture, Renderer, Text_Surface);
Window_Surface.Blit (Source => Text_Surface);
W.Update_Surface;
-- Main loop.
declare
Event : SDL.Events.Events.Events;
Finished : Boolean := False;
use type SDL.Events.Event_Types;
use type SDL.Events.Keyboards.Key_Codes;
-- use type SDL.Events.Keyboards.Scan_Codes;
begin
-- W.Update_Surface; -- Shows the above two calls.
loop
while SDL.Events.Events.Poll (Event) loop
case Event.Common.Event_Type is
when SDL.Events.Quit =>
Finished := True;
when SDL.Events.Keyboards.Key_Down =>
if Event.Keyboard.Key_Sym.Key_Code = SDL.Events.Keyboards.Code_Escape then
Finished := True;
end if;
when others =>
null;
end case;
end loop;
-- Renderer.Clear;
-- Renderer.Copy (Text_Texture);
-- Renderer.Present;
exit when Finished;
end loop;
end;
SDL.Log.Put_Debug ("");
-- Window_Surface.Finalize;
W.Finalize;
SDL.TTFs.Finalise;
SDL.Finalise;
else
Ada.Text_IO.Put_Line ("Error! could not initialise SDL or SDL.TTF!");
end if;
end if;
end TTF;
|
zhmu/ananas | Ada | 165 | ads | pragma Profile_Warnings (Ravenscar);
with profile_warning_p;
package profile_warning is
pragma Elaborate_Body;
procedure I is new profile_warning_p.Proc;
end;
|
zhmu/ananas | Ada | 2,731 | ads | ------------------------------------------------------------------------------
-- --
-- GNAT COMPILER COMPONENTS --
-- --
-- O S I N T - L --
-- --
-- S p e c --
-- --
-- Copyright (C) 2001-2022, Free Software Foundation, Inc. --
-- --
-- GNAT is free software; you can redistribute it and/or modify it under --
-- terms of the GNU General Public License as published by the Free Soft- --
-- ware Foundation; either version 3, or (at your option) any later ver- --
-- sion. GNAT is distributed in the hope that it will be useful, but WITH- --
-- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY --
-- or FITNESS FOR A PARTICULAR PURPOSE. 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 contains the low level, operating system routines used only
-- in gnatls for command line processing and file input output.
package Osint.L is
function More_Lib_Files return Boolean;
-- Indicates whether more library information files remain to be processed.
-- Returns False right away if no source files, or if all source files
-- have been processed.
function Next_Main_Lib_File return File_Name_Type;
-- This function returns the name of the next library info file specified
-- on the command line. It is an error to call Next_Main_Lib_File if no
-- more library information files exist (i.e. Next_Main_Lib_File may be
-- called only if a previous call to More_Lib_Files returned True). This
-- name is the simple name, excluding any directory information.
end Osint.L;
|
msrLi/portingSources | Ada | 833 | adb | -- Copyright 2013-2014 Free Software Foundation, Inc.
--
-- This program is free software; you can redistribute it and/or modify
-- it under the terms of the GNU General Public License as published by
-- the Free Software Foundation; either version 3 of the License, or
-- (at your option) any later version.
--
-- This program is distributed in the hope that it will be useful,
-- but WITHOUT ANY WARRANTY; without even the implied warranty of
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-- GNU General Public License for more details.
--
-- You should have received a copy of the GNU General Public License
-- along with this program. If not, see <http://www.gnu.org/licenses/>.
package body Pck is
procedure Do_Nothing (A : System.Address) is
begin
null;
end Do_Nothing;
end Pck;
|
reznikmm/matreshka | Ada | 3,619 | ads | with Types.Accesses.Objects;
with Types.Accesses.Subprograms;
with Types.Arrays;
with Types.Discretes.Enumerations;
with Types.Discretes.Integers;
with Types.Discriminanteds.Protecteds;
with Types.Discriminanteds.Records.Taggeds;
with Types.Discriminanteds.Records;
with Types.Discriminanteds.Tasks;
with Types.Taggeds.Interfaces;
package Types.Visiters is
pragma Preelaborate;
type Type_Visiter is limited interface;
not overriding procedure Enumeration_Type
(Self : not null access Type_Visiter;
Value : not null Types.Discretes.Enumerations.Enumeration_Type_Access)
is abstract;
not overriding procedure Boolean_Type
(Self : not null access Type_Visiter;
Value : not null Types.Discretes.Enumerations.Enumeration_Type_Access)
is abstract;
not overriding procedure Character_Type
(Self : not null access Type_Visiter;
Value : not null Types.Discretes.Enumerations.Enumeration_Type_Access)
is abstract;
not overriding procedure Signed_Integer_Type
(Self : not null access Type_Visiter;
Value : not null Types.Discretes.Integers.Integer_Type_Access)
is abstract;
not overriding procedure Modular_Integer_Type
(Self : not null access Type_Visiter;
Value : not null Types.Discretes.Integers.Integer_Type_Access)
is abstract;
-- not overriding procedure Floating_Point_Type
-- (Self : not null access Type_Visiter;
-- Value : not null Types.Reals.Floating_Points.Floating_Point_Type_Access)
-- is abstract;
--
-- not overriding procedure Fixed_Point_Type
-- (Self : not null access Type_Visiter;
-- Value : not null Types.Reals.Fixed_Points.Fixed_Point_Type_Access)
-- is abstract;
--
-- not overriding procedure Decimal_Fixed_Point_Type
-- (Self : not null access Type_Visiter;
-- Value : not null Types.Reals.Decimal_Fixed_Points
-- .Decimal_Fixed_Point_Type_Access)
-- is abstract;
not overriding procedure Object_Access_Type
(Self : not null access Type_Visiter;
Value : not null Types.Accesses.Objects.Object_Access_Type_Access)
is abstract;
not overriding procedure Subprogram_Access_Type
(Self : not null access Type_Visiter;
Value : not null Types.Accesses.Subprograms.Subprogram_Access_Type_Access)
is abstract;
not overriding procedure Array_Type
(Self : not null access Type_Visiter;
Value : not null Types.Arrays.Array_Type_Access)
is abstract;
not overriding procedure String_Type
(Self : not null access Type_Visiter;
Value : not null Types.Arrays.Array_Type_Access)
is abstract;
not overriding procedure Record_Type
(Self : not null access Type_Visiter;
Value : not null Types.Discriminanteds.Records.Record_Type_Access)
is abstract;
not overriding procedure Tagged_Record_Type
(Self : not null access Type_Visiter;
Value : not null Types.Discriminanteds.Records.Taggeds
.Tagged_Record_Type_Access)
is abstract;
not overriding procedure Task_Type
(Self : not null access Type_Visiter;
Value : not null Types.Discriminanteds.Tasks.Task_Type_Access)
is abstract;
not overriding procedure Protected_Type
(Self : not null access Type_Visiter;
Value : not null Types.Discriminanteds.Protecteds.Protected_Type_Access)
is abstract;
not overriding procedure Interface_Type
(Self : not null access Type_Visiter;
Value : not null Types.Taggeds.Interfaces.Interface_Type_Access)
is abstract;
end Types.Visiters;
|
persan/protobuf-ada | Ada | 51,379 | adb | with Protobuf_Unittest.TestAllTypes.NestedMessage;
with Protobuf_Unittest.ForeignMessage;
with Protobuf_Unittest_Import.ImportMessage;
with Protobuf_Unittest_Import.PublicImportMessage;
with Google.Protobuf.Wire_Format;
with Google.Protobuf.Generic_Assertions.Assertions; use Google.Protobuf.Generic_Assertions.Assertions;
package body Test_Util is
use type Google.Protobuf.Wire_Format.PB_String;
use type Google.Protobuf.Wire_Format.PB_Byte;
use type Google.Protobuf.Wire_Format.PB_UInt32;
use type Google.Protobuf.Wire_Format.PB_UInt64;
use type Google.Protobuf.Wire_Format.PB_Double;
use type Google.Protobuf.Wire_Format.PB_Float;
use type Google.Protobuf.Wire_Format.PB_Bool;
use type Google.Protobuf.Wire_Format.PB_Int32;
use type Google.Protobuf.Wire_Format.PB_Int64;
use type Google.Protobuf.Wire_Format.PB_Field_Type;
use type Google.Protobuf.Wire_Format.PB_Wire_Type;
use type Google.Protobuf.Wire_Format.PB_Object_Size;
use type Google.Protobuf.Wire_Format.PB_String_Access;
use type Protobuf_Unittest.ForeignEnum;
use type Protobuf_Unittest_Import.ImportEnum;
use type Protobuf_Unittest.TestAllTypes.NestedEnum;
generic
type Value_Type is private;
procedure Generic_Equal
(Expected : in Value_Type;
Actual : in Value_Type;
Source_Info : in String := GNAT.Source_Info.File;
File_Info : in Natural := GNAT.Source_Info.Line);
procedure Generic_Equal
(Expected : in Value_Type;
Actual : in Value_Type;
Source_Info : in String := GNAT.Source_Info.File;
File_Info : in Natural := GNAT.Source_Info.Line)
is
begin
Assert (Expected = Actual, "", Source_Info, File_Info);
end Generic_Equal;
procedure Assert_Equal is new Generic_Equal (Protobuf_Unittest.ForeignEnum);
procedure Assert_Equal is new Generic_Equal (Protobuf_Unittest_Import.ImportEnum);
procedure Assert_Equal is new Generic_Equal (Protobuf_Unittest.TestAllTypes.NestedEnum);
--------------------
-- Set_All_Fields --
--------------------
procedure Set_All_Fields
(Message : in out Protobuf_Unittest.TestAllTypes.Instance)
is
begin
Set_Optional_Fields (Message);
Add_Repeated_Fields1 (Message);
Add_Repeated_Fields2 (Message);
Set_Default_Fields (Message);
end Set_All_Fields;
-------------------------
-- Set_Optional_Fields --
-------------------------
procedure Set_Optional_Fields
(Message : in out Protobuf_Unittest.TestAllTypes.Instance)
is
begin
Message.Set_Optional_Int32 (101);
Message.Set_Optional_Int64 (102);
Message.Set_Optional_Uint32 (103);
Message.Set_Optional_Uint64 (104);
Message.Set_Optional_Sint32 (105);
Message.Set_Optional_Sint64 (106);
Message.Set_Optional_Fixed32 (107);
Message.Set_Optional_Fixed64 (108);
Message.Set_Optional_Sfixed32(109);
Message.Set_Optional_Sfixed64(110);
Message.Set_Optional_Float (111.0);
Message.Set_Optional_Double (112.0);
Message.Set_Optional_Bool (True);
Message.Set_Optional_String ("115");
Message.Set_Optional_Bytes ("116");
Message.Get_Optional_Nested_Message .Set_Bb(118);
Message.Get_Optional_Foreign_Message .Set_C(119);
Message.Get_Optional_Import_Message .Set_D(120);
Message.Get_Optional_Public_Import_Message.Set_E(126);
Message.Get_Optional_Lazy_Message .Set_Bb(127);
Message.Set_Optional_Nested_Enum (Protobuf_Unittest.TestAllTypes.BAZ);
Message.Set_Optional_Foreign_Enum(Protobuf_Unittest.Foreign_BAZ);
Message.Set_Optional_Import_Enum (Protobuf_Unittest_Import.Import_BAZ);
end Set_Optional_Fields;
--------------------------
-- Add_Repeated_Fields1 --
--------------------------
procedure Add_Repeated_Fields1
(Message : in out Protobuf_Unittest.TestAllTypes.Instance)
is
begin
Message.Add_Repeated_Int32 (201);
Message.Add_Repeated_Int64 (202);
Message.Add_Repeated_Uint32 (203);
Message.Add_Repeated_Uint64 (204);
Message.Add_Repeated_Sint32 (205);
Message.Add_Repeated_Sint64 (206);
Message.Add_Repeated_Fixed32 (207);
Message.Add_Repeated_Fixed64 (208);
Message.Add_Repeated_Sfixed32(209);
Message.Add_Repeated_Sfixed64(210);
Message.Add_Repeated_Float (211.0);
Message.Add_Repeated_Double (212.0);
Message.Add_Repeated_Bool (True);
Message.Add_Repeated_String ("215");
Message.Add_Repeated_Bytes ("216");
Message.Add_Repeated_Nested_Message .Set_Bb(218);
Message.Add_Repeated_Foreign_Message.Set_C(219);
Message.Add_Repeated_Import_Message .Set_D(220);
Message.Add_Repeated_Lazy_Message .Set_Bb(227);
Message.Add_Repeated_Nested_Enum (Protobuf_Unittest.TestAllTypes.BAR);
Message.Add_Repeated_Foreign_Enum(Protobuf_Unittest.Foreign_BAR);
Message.Add_Repeated_Import_Enum (Protobuf_Unittest_Import.Import_BAR);
end Add_Repeated_Fields1;
--------------------------
-- Add_Repeated_Fields2 --
--------------------------
procedure Add_Repeated_Fields2
(Message : in out Protobuf_Unittest.TestAllTypes.Instance)
is
begin
-- Add a second one of each field.
Message.Add_Repeated_Int32 (301);
Message.Add_Repeated_Int64 (302);
Message.Add_Repeated_Uint32 (303);
Message.Add_Repeated_Uint64 (304);
Message.Add_Repeated_Sint32 (305);
Message.Add_Repeated_Sint64 (306);
Message.Add_Repeated_Fixed32 (307);
Message.Add_Repeated_Fixed64 (308);
Message.Add_Repeated_Sfixed32(309);
Message.Add_Repeated_Sfixed64(310);
Message.Add_Repeated_Float (311.0);
Message.Add_Repeated_Double (312.0);
Message.Add_Repeated_Bool (False);
Message.Add_Repeated_String ("315");
Message.Add_Repeated_Bytes ("316");
Message.Add_Repeated_Nested_Message .Set_Bb(318);
Message.Add_Repeated_Foreign_Message.Set_C(319);
Message.Add_Repeated_Import_Message .Set_D(320);
Message.Add_Repeated_Lazy_Message .Set_Bb(327);
Message.Add_Repeated_Nested_Enum (Protobuf_Unittest.TestAllTypes.BAZ);
Message.Add_Repeated_Foreign_Enum(Protobuf_Unittest.Foreign_BAZ);
Message.Add_Repeated_Import_Enum (Protobuf_Unittest_Import.Import_BAZ);
end Add_Repeated_Fields2;
------------------------
-- Set_Default_Fields --
------------------------
procedure Set_Default_Fields
(Message : in out Protobuf_Unittest.TestAllTypes.Instance)
is
begin
Message.Set_Default_Int32 (401);
Message.Set_Default_Int64 (402);
Message.Set_Default_Uint32 (403);
Message.Set_Default_Uint64 (404);
Message.Set_Default_Sint32 (405);
Message.Set_Default_Sint64 (406);
Message.Set_Default_Fixed32 (407);
Message.Set_Default_Fixed64 (408);
Message.Set_Default_Sfixed32(409);
Message.Set_Default_Sfixed64(410);
Message.Set_Default_Float (411.0);
Message.Set_Default_Double (412.0);
Message.Set_Default_Bool (False);
Message.Set_Default_String ("415");
Message.Set_Default_Bytes ("416");
Message.Set_Default_Nested_Enum (Protobuf_Unittest.TestAllTypes.FOO);
Message.Set_Default_Foreign_Enum(Protobuf_Unittest.Foreign_FOO);
Message.Set_Default_Import_Enum (Protobuf_Unittest_Import.Import_FOO);
end Set_Default_Fields;
-------------------------
-- Set_Unpacked_Fields --
-------------------------
procedure Set_Unpacked_Fields
(Message : in out Protobuf_Unittest.TestUnpackedTypes.Instance)
is
begin
-- The values applied here must match those of SetPackedFields.
Message.Add_Unpacked_Int32 (601);
Message.Add_Unpacked_Int64 (602);
Message.Add_Unpacked_Uint32 (603);
Message.Add_Unpacked_Uint64 (604);
Message.Add_Unpacked_Sint32 (605);
Message.Add_Unpacked_Sint64 (606);
Message.Add_Unpacked_Fixed32 (607);
Message.Add_Unpacked_Fixed64 (608);
Message.Add_Unpacked_Sfixed32(609);
Message.Add_Unpacked_Sfixed64(610);
Message.Add_Unpacked_Float (611.0);
Message.Add_Unpacked_Double (612.0);
Message.Add_Unpacked_Bool (true);
Message.Add_Unpacked_Enum (Protobuf_Unittest.FOREIGN_BAR);
-- Add a second one of each field
Message.Add_Unpacked_Int32 (701);
Message.Add_Unpacked_Int64 (702);
Message.Add_Unpacked_Uint32 (703);
Message.Add_Unpacked_Uint64 (704);
Message.Add_Unpacked_Sint32 (705);
Message.Add_Unpacked_Sint64 (706);
Message.Add_Unpacked_Fixed32 (707);
Message.Add_Unpacked_Fixed64 (708);
Message.Add_Unpacked_Sfixed32(709);
Message.Add_Unpacked_Sfixed64(710);
Message.Add_Unpacked_Float (711.0);
Message.Add_Unpacked_Double (712.0);
Message.Add_Unpacked_Bool (false);
Message.Add_Unpacked_Enum (Protobuf_Unittest.FOREIGN_BAZ);
end Set_Unpacked_Fields;
-----------------------
-- Set_Packed_Fields --
-----------------------
procedure Set_Packed_Fields
(Message : in out Protobuf_Unittest.TestPackedTypes.Instance)
is
begin
Message.Add_Packed_Int32 (601);
Message.Add_Packed_Int64 (602);
Message.Add_Packed_Uint32 (603);
Message.Add_Packed_Uint64 (604);
Message.Add_Packed_Sint32 (605);
Message.Add_Packed_Sint64 (606);
Message.Add_Packed_Fixed32 (607);
Message.Add_Packed_Fixed64 (608);
Message.Add_Packed_Sfixed32(609);
Message.Add_Packed_Sfixed64(610);
Message.Add_Packed_Float (611.0);
Message.Add_Packed_Double (612.0);
Message.Add_Packed_Bool (true);
Message.Add_Packed_Enum (Protobuf_Unittest.FOREIGN_BAR);
-- Add a second one of each field
Message.Add_Packed_Int32 (701);
Message.Add_Packed_Int64 (702);
Message.Add_Packed_Uint32 (703);
Message.Add_Packed_Uint64 (704);
Message.Add_Packed_Sint32 (705);
Message.Add_Packed_Sint64 (706);
Message.Add_Packed_Fixed32 (707);
Message.Add_Packed_Fixed64 (708);
Message.Add_Packed_Sfixed32(709);
Message.Add_Packed_Sfixed64(710);
Message.Add_Packed_Float (711.0);
Message.Add_Packed_Double (712.0);
Message.Add_Packed_Bool (false);
Message.Add_Packed_Enum (Protobuf_Unittest.FOREIGN_BAZ);
end Set_Packed_Fields;
----------------------------
-- Modify_Repeated_Fields --
----------------------------
procedure Modify_Repeated_Fields
(Message : in out Protobuf_Unittest.TestAllTypes.Instance)
is
begin
Message.Set_Repeated_Int32 (1, 501);
Message.Set_Repeated_Int64 (1, 502);
Message.Set_Repeated_Uint32 (1, 503);
Message.Set_Repeated_Uint64 (1, 504);
Message.Set_Repeated_Sint32 (1, 505);
Message.Set_Repeated_Sint64 (1, 506);
Message.Set_Repeated_Fixed32 (1, 507);
Message.Set_Repeated_Fixed64 (1, 508);
Message.Set_Repeated_Sfixed32(1, 509);
Message.Set_Repeated_Sfixed64(1, 510);
Message.Set_Repeated_Float (1, 511.0);
Message.Set_Repeated_Double (1, 512.0);
Message.Set_Repeated_Bool (1, true);
Message.Set_Repeated_String (1, "515");
Message.Set_Repeated_Bytes (1, "516");
Message.Get_Repeated_Nested_Message (1).Set_Bb(518);
Message.Get_Repeated_Foreign_Message(1).Set_C(519);
Message.Get_Repeated_Import_Message (1).Set_D(520);
Message.Get_Repeated_Lazy_Message (1).Set_Bb(527);
Message.Set_Repeated_Nested_Enum (1, Protobuf_Unittest.TestAllTypes.FOO);
Message.Set_Repeated_Foreign_Enum(1, Protobuf_Unittest.Foreign_FOO);
Message.Set_Repeated_Import_Enum (1, Protobuf_Unittest_Import.Import_FOO);
end Modify_Repeated_Fields;
--------------------------
-- Modify_Packed_Fields --
--------------------------
procedure Modify_Packed_Fields
(Message : in out Protobuf_Unittest.TestPackedTypes.Instance)
is
begin
Message.Set_Packed_Int32 (1, 801);
Message.Set_Packed_Int64 (1, 802);
Message.Set_Packed_Uint32 (1, 803);
Message.Set_Packed_Uint64 (1, 804);
Message.Set_Packed_Sint32 (1, 805);
Message.Set_Packed_Sint64 (1, 806);
Message.Set_Packed_Fixed32 (1, 807);
Message.Set_Packed_Fixed64 (1, 808);
Message.Set_Packed_Sfixed32(1, 809);
Message.Set_Packed_Sfixed64(1, 810);
Message.Set_Packed_Float (1, 811.0);
Message.Set_Packed_Double (1, 812.0);
Message.Set_Packed_Bool (1, true);
Message.Set_Packed_Enum (1, Protobuf_Unittest.FOREIGN_FOO);
end Modify_Packed_Fields;
---------------------------
-- Expect_All_Fields_Set --
---------------------------
procedure Expect_All_Fields_Set
(Message : in out Protobuf_Unittest.TestAllTypes.Instance)
is
begin
Assert_True (Message.Has_Optional_Int32 );
Assert_True (Message.Has_Optional_Int64 );
Assert_True (Message.Has_Optional_Uint32 );
Assert_True (Message.Has_Optional_Uint64 );
Assert_True (Message.Has_Optional_Sint32 );
Assert_True (Message.Has_Optional_Sint64 );
Assert_True (Message.Has_Optional_Fixed32 );
Assert_True (Message.Has_Optional_Fixed64 );
Assert_True (Message.Has_Optional_Sfixed32);
Assert_True (Message.Has_Optional_Sfixed64);
Assert_True (Message.Has_Optional_Float );
Assert_True (Message.Has_Optional_Double );
Assert_True (Message.Has_Optional_Bool );
Assert_True (Message.Has_Optional_String );
Assert_True (Message.Has_Optional_Bytes );
Assert_True (Message.Has_Optional_Nested_Message );
Assert_True (Message.Has_Optional_Foreign_Message );
Assert_True (Message.Has_Optional_Import_Message );
Assert_True (Message.Has_Optional_Public_Import_Message);
Assert_True (Message.Has_Optional_Lazy_Message );
Assert_True (Message.Get_Optional_Nested_Message .Has_Bb);
Assert_True (Message.Get_Optional_Foreign_Message .Has_C );
Assert_True (Message.Get_Optional_Import_Message .Has_D );
Assert_True (Message.Get_Optional_Public_Import_Message.Has_E );
Assert_True (Message.Get_Optional_Lazy_Message .Has_Bb);
Assert_True (Message.Has_Optional_Nested_Enum );
Assert_True (Message.Has_Optional_Foreign_Enum);
Assert_True (Message.Has_Optional_Import_Enum );
Assert_Equal (101 , Message.Get_Optional_Int32 );
Assert_Equal (102 , Message.Get_Optional_Int64 );
Assert_Equal (103 , Message.Get_Optional_Uint32 );
Assert_Equal (104 , Message.Get_Optional_Uint64 );
Assert_Equal (105 , Message.Get_Optional_Sint32 );
Assert_Equal (106 , Message.Get_Optional_Sint64 );
Assert_Equal (107 , Message.Get_Optional_Fixed32 );
Assert_Equal (108 , Message.Get_Optional_Fixed64 );
Assert_Equal (109 , Message.Get_Optional_Sfixed32);
Assert_Equal (110 , Message.Get_Optional_Sfixed64);
Assert_Equal (111.0, Message.Get_Optional_Float );
Assert_Equal (112.0, Message.Get_Optional_Double );
Assert_True ( Message.Get_Optional_Bool );
Assert_Equal ("115", Message.Get_Optional_String );
Assert_Equal ("116", Message.Get_Optional_Bytes );
Assert_Equal (118, Message.Get_Optional_Nested_Message .Get_Bb);
Assert_Equal (119, Message.Get_Optional_Foreign_Message .Get_C );
Assert_Equal (120, Message.Get_Optional_Import_Message .Get_D );
Assert_Equal (126, Message.Get_Optional_Public_Import_Message .Get_E );
Assert_Equal (127, Message.Get_Optional_Lazy_Message .Get_Bb);
Assert_Equal (Protobuf_Unittest.TestAllTypes.BAZ, Message.Get_Optional_Nested_Enum );
Assert_Equal (Protobuf_Unittest.FOREIGN_BAZ , Message.Get_Optional_Foreign_Enum);
Assert_Equal (Protobuf_Unittest_Import.Import_BAZ , Message.Get_Optional_Import_Enum );
--------------------------------------------------------------------
Assert_Equal (2, Message.Repeated_Int32_Size );
Assert_Equal (2, Message.Repeated_Int64_Size );
Assert_Equal (2, Message.Repeated_Uint32_Size );
Assert_Equal (2, Message.Repeated_Uint64_Size );
Assert_Equal (2, Message.Repeated_Sint32_Size );
Assert_Equal (2, Message.Repeated_Sint64_Size );
Assert_Equal (2, Message.Repeated_Fixed32_Size );
Assert_Equal (2, Message.Repeated_Fixed64_Size );
Assert_Equal (2, Message.Repeated_Sfixed32_Size);
Assert_Equal (2, Message.Repeated_Sfixed64_Size);
Assert_Equal (2, Message.Repeated_Float_Size );
Assert_Equal (2, Message.Repeated_Double_Size );
Assert_Equal (2, Message.Repeated_Bool_Size );
Assert_Equal (2, Message.Repeated_String_Size );
Assert_Equal (2, Message.Repeated_Bytes_Size );
Assert_Equal (2, Message.Repeated_Nested_Message_Size );
Assert_Equal (2, Message.Repeated_Foreign_Message_Size);
Assert_Equal (2, Message.Repeated_Import_Message_Size );
Assert_Equal (2, Message.Repeated_Lazy_Message_Size );
Assert_Equal (2, Message.Repeated_Nested_Enum_Size );
Assert_Equal (2, Message.Repeated_Foreign_Enum_Size );
Assert_Equal (2, Message.Repeated_Import_Enum_Size );
Assert_Equal (201 , Message.Get_Repeated_Int32 (0));
Assert_Equal (202 , Message.Get_Repeated_Int64 (0));
Assert_Equal (203 , Message.Get_Repeated_Uint32 (0));
Assert_Equal (204 , Message.Get_Repeated_Uint64 (0));
Assert_Equal (205 , Message.Get_Repeated_Sint32 (0));
Assert_Equal (206 , Message.Get_Repeated_Sint64 (0));
Assert_Equal (207 , Message.Get_Repeated_Fixed32 (0));
Assert_Equal (208 , Message.Get_Repeated_Fixed64 (0));
Assert_Equal (209 , Message.Get_Repeated_Sfixed32(0));
Assert_Equal (210 , Message.Get_Repeated_Sfixed64(0));
Assert_Equal (211.0, Message.Get_Repeated_Float (0));
Assert_Equal (212.0, Message.Get_Repeated_Double (0));
Assert_True ( Message.Get_Repeated_Bool (0));
Assert_Equal ("215", Message.Get_Repeated_String (0));
Assert_Equal ("216", Message.Get_Repeated_Bytes (0));
Assert_Equal (218, Message.Get_Repeated_Nested_Message (0).Get_Bb);
Assert_Equal (219, Message.Get_Repeated_Foreign_Message(0).Get_C );
Assert_Equal (220, Message.Get_Repeated_Import_Message (0).Get_D );
Assert_Equal (227, Message.Get_Repeated_Lazy_Message (0).Get_Bb);
Assert_Equal (Protobuf_Unittest.TestAllTypes.BAR, Message.Get_Repeated_Nested_Enum (0));
Assert_Equal (Protobuf_Unittest.FOREIGN_BAR , Message.Get_Repeated_Foreign_Enum(0));
Assert_Equal (Protobuf_Unittest_Import.Import_BAR , Message.Get_Repeated_Import_Enum (0));
Assert_Equal (301 , Message.Get_Repeated_Int32 (1));
Assert_Equal (302 , Message.Get_Repeated_Int64 (1));
Assert_Equal (303 , Message.Get_Repeated_Uint32 (1));
Assert_Equal (304 , Message.Get_Repeated_Uint64 (1));
Assert_Equal (305 , Message.Get_Repeated_Sint32 (1));
Assert_Equal (306 , Message.Get_Repeated_Sint64 (1));
Assert_Equal (307 , Message.Get_Repeated_Fixed32 (1));
Assert_Equal (308 , Message.Get_Repeated_Fixed64 (1));
Assert_Equal (309 , Message.Get_Repeated_Sfixed32(1));
Assert_Equal (310 , Message.Get_Repeated_Sfixed64(1));
Assert_Equal (311.0, Message.Get_Repeated_Float (1));
Assert_Equal (312.0, Message.Get_Repeated_Double (1));
Assert_False ( Message.Get_Repeated_Bool (1));
Assert_Equal ("315", Message.Get_Repeated_String (1));
Assert_Equal ("316", Message.Get_Repeated_Bytes (1));
Assert_Equal (318, Message.Get_Repeated_Nested_Message (1).Get_Bb);
Assert_Equal (319, Message.Get_Repeated_Foreign_Message(1).Get_C);
Assert_Equal (320, Message.Get_Repeated_Import_Message (1).Get_D);
Assert_Equal (327, Message.Get_Repeated_Lazy_Message (1).Get_Bb);
Assert_Equal (Protobuf_Unittest.TestAllTypes.BAZ , Message.Get_Repeated_Nested_Enum (1));
Assert_Equal (Protobuf_Unittest.FOREIGN_BAZ , Message.Get_Repeated_Foreign_Enum(1));
Assert_Equal (Protobuf_Unittest_Import.Import_BAZ , Message.Get_Repeated_Import_Enum (1));
--------------------------------------------------------------------
Assert_True (Message.Has_Default_Int32 );
Assert_True (Message.Has_Default_Int64 );
Assert_True (Message.Has_Default_Uint32 );
Assert_True (Message.Has_Default_Uint64 );
Assert_True (Message.Has_Default_Sint32 );
Assert_True (Message.Has_Default_Sint64 );
Assert_True (Message.Has_Default_Fixed32 );
Assert_True (Message.Has_Default_Fixed64 );
Assert_True (Message.Has_Default_Sfixed32);
Assert_True (Message.Has_Default_Sfixed64);
Assert_True (Message.Has_Default_Float );
Assert_True (Message.Has_Default_Double );
Assert_True (Message.Has_Default_Bool );
Assert_True (Message.Has_Default_String );
Assert_True (Message.Has_Default_Bytes );
Assert_True (Message.Has_Default_Nested_Enum );
Assert_True (Message.Has_Default_Foreign_Enum);
Assert_True (Message.Has_Default_Import_Enum );
Assert_Equal (401 , Message.Get_Default_Int32 );
Assert_Equal (402 , Message.Get_Default_Int64 );
Assert_Equal (403 , Message.Get_Default_Uint32 );
Assert_Equal (404 , Message.Get_Default_Uint64 );
Assert_Equal (405 , Message.Get_Default_Sint32 );
Assert_Equal (406 , Message.Get_Default_Sint64 );
Assert_Equal (407 , Message.Get_Default_Fixed32 );
Assert_Equal (408 , Message.Get_Default_Fixed64 );
Assert_Equal (409 , Message.Get_Default_Sfixed32);
Assert_Equal (410 , Message.Get_Default_Sfixed64);
Assert_Equal (411.0, Message.Get_Default_Float );
Assert_Equal (412.0, Message.Get_Default_Double );
Assert_False ( Message.Get_Default_Bool );
Assert_Equal ("415", Message.Get_Default_String );
Assert_Equal ("416", Message.Get_Default_Bytes );
Assert_Equal (Protobuf_Unittest.TestAllTypes.FOO , Message.Get_Default_Nested_Enum );
Assert_Equal (Protobuf_Unittest.FOREIGN_FOO , Message.Get_Default_Foreign_Enum);
Assert_Equal (Protobuf_Unittest_Import.Import_FOO, Message.Get_Default_Import_Enum );
end Expect_All_Fields_Set;
------------------------------
-- Expect_Packed_Fields_Set --
------------------------------
procedure Expect_Packed_Fields_Set
(Message : in Protobuf_Unittest.TestPackedTypes.Instance)
is
begin
Assert_Equal (2, Message.Packed_Int32_Size );
Assert_Equal (2, Message.Packed_Int64_Size );
Assert_Equal (2, Message.Packed_Uint32_Size );
Assert_Equal (2, Message.Packed_Uint64_Size );
Assert_Equal (2, Message.Packed_Sint32_Size );
Assert_Equal (2, Message.Packed_Sint64_Size );
Assert_Equal (2, Message.Packed_Fixed32_Size );
Assert_Equal (2, Message.Packed_Fixed64_Size );
Assert_Equal (2, Message.Packed_Sfixed32_Size);
Assert_Equal (2, Message.Packed_Sfixed64_Size);
Assert_Equal (2, Message.Packed_Float_Size );
Assert_Equal (2, Message.Packed_Double_Size );
Assert_Equal (2, Message.Packed_Bool_Size );
Assert_Equal (2, Message.Packed_Enum_Size );
Assert_Equal (601 , Message.Get_Packed_Int32 (0));
Assert_Equal (602 , Message.Get_Packed_Int64 (0));
Assert_Equal (603 , Message.Get_Packed_Uint32 (0));
Assert_Equal (604 , Message.Get_Packed_Uint64 (0));
Assert_Equal (605 , Message.Get_Packed_Sint32 (0));
Assert_Equal (606 , Message.Get_Packed_Sint64 (0));
Assert_Equal (607 , Message.Get_Packed_Fixed32 (0));
Assert_Equal (608 , Message.Get_Packed_Fixed64 (0));
Assert_Equal (609 , Message.Get_Packed_Sfixed32(0));
Assert_Equal (610 , Message.Get_Packed_Sfixed64(0));
Assert_Equal (611.0, Message.Get_Packed_Float (0));
Assert_Equal (612.0, Message.Get_Packed_Double (0));
Assert_True ( Message.Get_Packed_Bool (0));
Assert_Equal (Protobuf_Unittest.FOREIGN_BAR, Message.Get_Packed_Enum(0));
Assert_Equal (701 , Message.Get_Packed_Int32 (1));
Assert_Equal (702 , Message.Get_Packed_Int64 (1));
Assert_Equal (703 , Message.Get_Packed_Uint32 (1));
Assert_Equal (704 , Message.Get_Packed_Uint64 (1));
Assert_Equal (705 , Message.Get_Packed_Sint32 (1));
Assert_Equal (706 , Message.Get_Packed_Sint64 (1));
Assert_Equal (707 , Message.Get_Packed_Fixed32 (1));
Assert_Equal (708 , Message.Get_Packed_Fixed64 (1));
Assert_Equal (709 , Message.Get_Packed_Sfixed32(1));
Assert_Equal (710 , Message.Get_Packed_Sfixed64(1));
Assert_Equal (711.0, Message.Get_Packed_Float (1));
Assert_Equal (712.0, Message.Get_Packed_Double (1));
Assert_False ( Message.Get_Packed_Bool (1));
Assert_Equal (Protobuf_Unittest.FOREIGN_BAZ, Message.Get_Packed_Enum(1));
end Expect_Packed_Fields_Set;
--------------------------------
-- Expect_Unpacked_Fields_Set --
--------------------------------
procedure Expect_Unpacked_Fields_Set
(Message : in Protobuf_Unittest.TestUnpackedTypes.Instance)
is
begin
-- The values expected here must match those of ExpectPackedFieldsSet.
Assert_Equal (2, Message.Unpacked_Int32_Size );
Assert_Equal (2, Message.Unpacked_Int64_Size );
Assert_Equal (2, Message.Unpacked_Uint32_Size );
Assert_Equal (2, Message.Unpacked_Uint64_Size );
Assert_Equal (2, Message.Unpacked_Sint32_Size );
Assert_Equal (2, Message.Unpacked_Sint64_Size );
Assert_Equal (2, Message.Unpacked_Fixed32_Size );
Assert_Equal (2, Message.Unpacked_Fixed64_Size );
Assert_Equal (2, Message.Unpacked_Sfixed32_Size);
Assert_Equal (2, Message.Unpacked_Sfixed64_Size);
Assert_Equal (2, Message.Unpacked_Float_Size );
Assert_Equal (2, Message.Unpacked_Double_Size );
Assert_Equal (2, Message.Unpacked_Bool_Size );
Assert_Equal (2, Message.Unpacked_Enum_Size );
Assert_Equal (601 , Message.Get_Unpacked_Int32 (0));
Assert_Equal (602 , Message.Get_Unpacked_Int64 (0));
Assert_Equal (603 , Message.Get_Unpacked_Uint32 (0));
Assert_Equal (604 , Message.Get_Unpacked_Uint64 (0));
Assert_Equal (605 , Message.Get_Unpacked_Sint32 (0));
Assert_Equal (606 , Message.Get_Unpacked_Sint64 (0));
Assert_Equal (607 , Message.Get_Unpacked_Fixed32 (0));
Assert_Equal (608 , Message.Get_Unpacked_Fixed64 (0));
Assert_Equal (609 , Message.Get_Unpacked_Sfixed32(0));
Assert_Equal (610 , Message.Get_Unpacked_Sfixed64(0));
Assert_Equal (611.0, Message.Get_Unpacked_Float (0));
Assert_Equal (612.0, Message.Get_Unpacked_Double (0));
Assert_True ( Message.Get_Unpacked_Bool (0));
Assert_Equal (Protobuf_Unittest.FOREIGN_BAR, Message.Get_Unpacked_Enum(0));
Assert_Equal (701 , Message.Get_Unpacked_Int32 (1));
Assert_Equal (702 , Message.Get_Unpacked_Int64 (1));
Assert_Equal (703 , Message.Get_Unpacked_Uint32 (1));
Assert_Equal (704 , Message.Get_Unpacked_Uint64 (1));
Assert_Equal (705 , Message.Get_Unpacked_Sint32 (1));
Assert_Equal (706 , Message.Get_Unpacked_Sint64 (1));
Assert_Equal (707 , Message.Get_Unpacked_Fixed32 (1));
Assert_Equal (708 , Message.Get_Unpacked_Fixed64 (1));
Assert_Equal (709 , Message.Get_Unpacked_Sfixed32(1));
Assert_Equal (710 , Message.Get_Unpacked_Sfixed64(1));
Assert_Equal (711.0, Message.Get_Unpacked_Float (1));
Assert_Equal (712.0, Message.Get_Unpacked_Double (1));
Assert_False ( Message.Get_Unpacked_Bool (1));
Assert_Equal (Protobuf_Unittest.FOREIGN_BAZ, Message.Get_Unpacked_Enum(1));
end Expect_Unpacked_Fields_Set;
-------------------------------------
-- Expect_Repeated_Fields_Modified --
-------------------------------------
procedure Expect_Repeated_Fields_Modified
(Message : in Protobuf_Unittest.TestAllTypes.Instance)
is
begin
-- ModifyRepeatedFields only Sets the second Repeated element of each
-- field. In Addition to verifying this, we also verify that the first
-- element and size were *not* modified.
Assert_Equal (2, Message.Repeated_Int32_Size );
Assert_Equal (2, Message.Repeated_Int64_Size );
Assert_Equal (2, Message.Repeated_Uint32_Size );
Assert_Equal (2, Message.Repeated_Uint64_Size );
Assert_Equal (2, Message.Repeated_Sint32_Size );
Assert_Equal (2, Message.Repeated_Sint64_Size );
Assert_Equal (2, Message.Repeated_Fixed32_Size );
Assert_Equal (2, Message.Repeated_Fixed64_Size );
Assert_Equal (2, Message.Repeated_Sfixed32_Size);
Assert_Equal (2, Message.Repeated_Sfixed64_Size);
Assert_Equal (2, Message.Repeated_Float_Size );
Assert_Equal (2, Message.Repeated_Double_Size );
Assert_Equal (2, Message.Repeated_Bool_Size );
Assert_Equal (2, Message.Repeated_String_Size );
Assert_Equal (2, Message.Repeated_Bytes_Size );
Assert_Equal (2, Message.Repeated_Nested_Message_Size );
Assert_Equal (2, Message.Repeated_Foreign_Message_Size);
Assert_Equal (2, Message.Repeated_Import_Message_Size );
Assert_Equal (2, Message.Repeated_Lazy_Message_Size );
Assert_Equal (2, Message.Repeated_Nested_Enum_Size );
Assert_Equal (2, Message.Repeated_Foreign_Enum_Size );
Assert_Equal (2, Message.Repeated_Import_Enum_Size );
Assert_Equal (201 , Message.Get_Repeated_Int32 (0));
Assert_Equal (202 , Message.Get_Repeated_Int64 (0));
Assert_Equal (203 , Message.Get_Repeated_Uint32 (0));
Assert_Equal (204 , Message.Get_Repeated_Uint64 (0));
Assert_Equal (205 , Message.Get_Repeated_Sint32 (0));
Assert_Equal (206 , Message.Get_Repeated_Sint64 (0));
Assert_Equal (207 , Message.Get_Repeated_Fixed32 (0));
Assert_Equal (208 , Message.Get_Repeated_Fixed64 (0));
Assert_Equal (209 , Message.Get_Repeated_Sfixed32(0));
Assert_Equal (210 , Message.Get_Repeated_Sfixed64(0));
Assert_Equal (211.0, Message.Get_Repeated_Float (0));
Assert_Equal (212.0, Message.Get_Repeated_Double (0));
Assert_True ( Message.Get_Repeated_Bool (0));
Assert_Equal ("215", Message.Get_Repeated_String (0));
Assert_Equal ("216", Message.Get_Repeated_Bytes (0));
Assert_Equal (218, Message.Get_Repeated_Nested_Message (0).Get_Bb);
Assert_Equal (219, Message.Get_Repeated_Foreign_Message(0).Get_C);
Assert_Equal (220, Message.Get_Repeated_Import_Message (0).Get_D);
Assert_Equal (227, Message.Get_Repeated_Lazy_Message (0).Get_Bb);
Assert_Equal (Protobuf_Unittest.TestAllTypes.BAR, Message.Get_Repeated_Nested_Enum (0));
Assert_Equal (Protobuf_Unittest.FOREIGN_BAR , Message.Get_Repeated_Foreign_Enum(0));
Assert_Equal (Protobuf_Unittest_Import.Import_BAR , Message.Get_Repeated_Import_Enum (0));
-- Actually verify the second (modified) elements now.
Assert_Equal (501 , Message.Get_Repeated_Int32 (1));
Assert_Equal (502 , Message.Get_Repeated_Int64 (1));
Assert_Equal (503 , Message.Get_Repeated_Uint32 (1));
Assert_Equal (504 , Message.Get_Repeated_Uint64 (1));
Assert_Equal (505 , Message.Get_Repeated_Sint32 (1));
Assert_Equal (506 , Message.Get_Repeated_Sint64 (1));
Assert_Equal (507 , Message.Get_Repeated_Fixed32 (1));
Assert_Equal (508 , Message.Get_Repeated_Fixed64 (1));
Assert_Equal (509 , Message.Get_Repeated_Sfixed32(1));
Assert_Equal (510 , Message.Get_Repeated_Sfixed64(1));
Assert_Equal (511.0, Message.Get_Repeated_Float (1));
Assert_Equal (512.0, Message.Get_Repeated_Double (1));
Assert_True ( Message.Get_Repeated_Bool (1));
Assert_Equal ("515", Message.Get_Repeated_String (1));
Assert_Equal ("516", Message.Get_Repeated_Bytes (1));
Assert_Equal (518, Message.Get_Repeated_Nested_Message (1).Get_Bb);
Assert_Equal (519, Message.Get_Repeated_Foreign_Message(1).Get_C);
Assert_Equal (520, Message.Get_Repeated_Import_Message (1).Get_D);
Assert_Equal (527, Message.Get_Repeated_Lazy_Message (1).Get_Bb);
Assert_Equal (Protobuf_Unittest.TestAllTypes.FOO, Message.Get_Repeated_Nested_Enum (1));
Assert_Equal (Protobuf_Unittest.FOREIGN_FOO , Message.Get_Repeated_Foreign_Enum(1));
Assert_Equal (Protobuf_Unittest_Import.Import_FOO , Message.Get_Repeated_Import_Enum (1));
end Expect_Repeated_Fields_Modified;
-----------------------------------
-- Expect_Packed_Fields_Modified --
-----------------------------------
procedure Expect_Packed_Fields_Modified
(Message : in Protobuf_Unittest.TestPackedTypes.Instance)
is
begin
-- Do the same for Packed Repeated fields.
Assert_Equal (2, Message.Packed_Int32_Size );
Assert_Equal (2, Message.Packed_Int64_Size );
Assert_Equal (2, Message.Packed_Uint32_Size );
Assert_Equal (2, Message.Packed_Uint64_Size );
Assert_Equal (2, Message.Packed_Sint32_Size );
Assert_Equal (2, Message.Packed_Sint64_Size );
Assert_Equal (2, Message.Packed_Fixed32_Size );
Assert_Equal (2, Message.Packed_Fixed64_Size );
Assert_Equal (2, Message.Packed_Sfixed32_Size);
Assert_Equal (2, Message.Packed_Sfixed64_Size);
Assert_Equal (2, Message.Packed_Float_Size );
Assert_Equal (2, Message.Packed_Double_Size );
Assert_Equal (2, Message.Packed_Bool_Size );
Assert_Equal (2, Message.Packed_Enum_Size );
Assert_Equal (601 , Message.Get_Packed_Int32 (0));
Assert_Equal (602 , Message.Get_Packed_Int64 (0));
Assert_Equal (603 , Message.Get_Packed_Uint32 (0));
Assert_Equal (604 , Message.Get_Packed_Uint64 (0));
Assert_Equal (605 , Message.Get_Packed_Sint32 (0));
Assert_Equal (606 , Message.Get_Packed_Sint64 (0));
Assert_Equal (607 , Message.Get_Packed_Fixed32 (0));
Assert_Equal (608 , Message.Get_Packed_Fixed64 (0));
Assert_Equal (609 , Message.Get_Packed_Sfixed32(0));
Assert_Equal (610 , Message.Get_Packed_Sfixed64(0));
Assert_Equal (611.0, Message.Get_Packed_Float (0));
Assert_Equal (612.0, Message.Get_Packed_Double (0));
Assert_True ( Message.Get_Packed_Bool (0));
Assert_Equal (Protobuf_Unittest.FOREIGN_BAR, Message.Get_Packed_Enum(0));
-- Actually verify the second (modified) elements now.
Assert_Equal (801 , Message.Get_Packed_Int32 (1));
Assert_Equal (802 , Message.Get_Packed_Int64 (1));
Assert_Equal (803 , Message.Get_Packed_Uint32 (1));
Assert_Equal (804 , Message.Get_Packed_Uint64 (1));
Assert_Equal (805 , Message.Get_Packed_Sint32 (1));
Assert_Equal (806 , Message.Get_Packed_Sint64 (1));
Assert_Equal (807 , Message.Get_Packed_Fixed32 (1));
Assert_Equal (808 , Message.Get_Packed_Fixed64 (1));
Assert_Equal (809 , Message.Get_Packed_Sfixed32(1));
Assert_Equal (810 , Message.Get_Packed_Sfixed64(1));
Assert_Equal (811.0, Message.Get_Packed_Float (1));
Assert_Equal (812.0, Message.Get_Packed_Double (1));
Assert_True ( Message.Get_Packed_Bool (1));
Assert_Equal (Protobuf_Unittest.FOREIGN_FOO, Message.Get_Packed_Enum(1));
end Expect_Packed_Fields_Modified;
------------------
-- Expect_Clear --
------------------
procedure Expect_Clear (Message : in out Protobuf_Unittest.TestAllTypes.Instance) is
begin
-- has_Blah should initially be false for all Optional fields.
Assert_False (Message.Has_Optional_Int32 );
Assert_False (Message.Has_Optional_Int64 );
Assert_False (Message.Has_Optional_Uint32 );
Assert_False (Message.Has_Optional_Uint64 );
Assert_False (Message.Has_Optional_Sint32 );
Assert_False (Message.Has_Optional_Sint64 );
Assert_False (Message.Has_Optional_Fixed32 );
Assert_False (Message.Has_Optional_Fixed64 );
Assert_False (Message.Has_Optional_Sfixed32);
Assert_False (Message.Has_Optional_Sfixed64);
Assert_False (Message.Has_Optional_Float );
Assert_False (Message.Has_Optional_Double );
Assert_False (Message.Has_Optional_Bool );
Assert_False (Message.Has_Optional_String );
Assert_False (Message.Has_Optional_Bytes );
Assert_False (Message.Has_Optional_Nested_Message );
Assert_False (Message.Has_Optional_Foreign_Message );
Assert_False (Message.Has_Optional_Import_Message );
Assert_False (Message.Has_Optional_Public_Import_Message);
Assert_False (Message.Has_Optional_Lazy_Message );
Assert_False (Message.Has_Optional_Nested_Enum );
Assert_False (Message.Has_Optional_Foreign_Enum);
Assert_False (Message.Has_Optional_Import_Enum );
Assert_False (Message.Has_Optional_String_piece);
Assert_False (Message.Has_Optional_Cord);
-- Optional fields without defaults are Set to zero or something like it.
Assert_Equal (0 , Message.Get_Optional_Int32 );
Assert_Equal (0 , Message.Get_Optional_Int64 );
Assert_Equal (0 , Message.Get_Optional_Uint32 );
Assert_Equal (0 , Message.Get_Optional_Uint64 );
Assert_Equal (0 , Message.Get_Optional_Sint32 );
Assert_Equal (0 , Message.Get_Optional_Sint64 );
Assert_Equal (0 , Message.Get_Optional_Fixed32 );
Assert_Equal (0 , Message.Get_Optional_Fixed64 );
Assert_Equal (0 , Message.Get_Optional_Sfixed32);
Assert_Equal (0 , Message.Get_Optional_Sfixed64);
Assert_Equal (0.0 , Message.Get_Optional_Float );
Assert_Equal (0.0 , Message.Get_Optional_Double );
Assert_False ( Message.Get_Optional_Bool );
Assert_Equal ("" , Message.Get_Optional_String );
Assert_Equal ("" , Message.Get_Optional_Bytes );
-- Embedded Messages should also be clear.
Assert_False (Message.Get_Optional_Nested_Message .Has_Bb);
Assert_False (Message.Get_Optional_Foreign_Message .Has_C);
Assert_False (Message.Get_Optional_Import_Message .Has_D);
Assert_False (Message.Get_Optional_Public_Import_Message.Has_E);
Assert_False (Message.Get_Optional_Lazy_Message .Has_Bb);
Assert_Equal (0, Message.Get_Optional_Nested_Message .Get_Bb);
Assert_Equal (0, Message.Get_Optional_Foreign_Message .Get_C);
Assert_Equal (0, Message.Get_Optional_Import_Message .Get_D);
Assert_Equal (0, Message.Get_Optional_Public_Import_Message.Get_E);
Assert_Equal (0, Message.Get_Optional_Lazy_Message .Get_Bb);
-- Enums without defaults are Set to the first value in the enum.
Assert_Equal (Protobuf_Unittest.TestAllTypes.FOO , Message.Get_Optional_Nested_Enum );
Assert_Equal (Protobuf_Unittest.FOREIGN_FOO , Message.Get_Optional_Foreign_Enum);
Assert_Equal (Protobuf_Unittest_Import.Import_FOO, Message.Get_Optional_Import_Enum );
-- Repeated fields are empty.
Assert_Equal (0, Message.Repeated_Int32_Size );
Assert_Equal (0, Message.Repeated_Int64_Size );
Assert_Equal (0, Message.Repeated_Uint32_Size );
Assert_Equal (0, Message.Repeated_Uint64_Size );
Assert_Equal (0, Message.Repeated_Sint32_Size );
Assert_Equal (0, Message.Repeated_Sint64_Size );
Assert_Equal (0, Message.Repeated_Fixed32_Size );
Assert_Equal (0, Message.Repeated_Fixed64_Size );
Assert_Equal (0, Message.Repeated_Sfixed32_Size);
Assert_Equal (0, Message.Repeated_Sfixed64_Size);
Assert_Equal (0, Message.Repeated_Float_Size );
Assert_Equal (0, Message.Repeated_Double_Size );
Assert_Equal (0, Message.Repeated_Bool_Size );
Assert_Equal (0, Message.Repeated_String_Size );
Assert_Equal (0, Message.Repeated_Bytes_Size );
Assert_Equal (0, Message.Repeated_Nested_Message_Size );
Assert_Equal (0, Message.Repeated_Foreign_Message_Size);
Assert_Equal (0, Message.Repeated_Import_Message_Size );
Assert_Equal (0, Message.Repeated_Lazy_Message_Size );
Assert_Equal (0, Message.Repeated_Nested_Enum_Size );
Assert_Equal (0, Message.Repeated_Foreign_Enum_Size );
Assert_Equal (0, Message.Repeated_Import_Enum_Size );
Assert_Equal (0, Message.Repeated_String_piece_Size);
Assert_Equal (0, Message.Repeated_Cord_Size);
-- has_Blah should also be false for all default fields.
Assert_False (Message.Has_Default_Int32 );
Assert_False (Message.Has_Default_Int64 );
Assert_False (Message.Has_Default_Uint32 );
Assert_False (Message.Has_Default_Uint64 );
Assert_False (Message.Has_Default_Sint32 );
Assert_False (Message.Has_Default_Sint64 );
Assert_False (Message.Has_Default_Fixed32 );
Assert_False (Message.Has_Default_Fixed64 );
Assert_False (Message.Has_Default_Sfixed32);
Assert_False (Message.Has_Default_Sfixed64);
Assert_False (Message.Has_Default_Float );
Assert_False (Message.Has_Default_Double );
Assert_False (Message.Has_Default_Bool );
Assert_False (Message.Has_Default_String );
Assert_False (Message.Has_Default_Bytes );
Assert_False (Message.Has_Default_Nested_Enum );
Assert_False (Message.Has_Default_Foreign_Enum);
Assert_False (Message.Has_Default_Import_Enum );
-- Fields with defaults have their default values (duh).
Assert_Equal ( 41 , Message.Get_Default_Int32 );
Assert_Equal ( 42 , Message.Get_Default_Int64 );
Assert_Equal ( 43 , Message.Get_Default_Uint32 );
Assert_Equal ( 44 , Message.Get_Default_Uint64 );
Assert_Equal (-45 , Message.Get_Default_Sint32 );
Assert_Equal ( 46 , Message.Get_Default_Sint64 );
Assert_Equal ( 47 , Message.Get_Default_Fixed32 );
Assert_Equal ( 48 , Message.Get_Default_Fixed64 );
Assert_Equal ( 49 , Message.Get_Default_Sfixed32);
Assert_Equal (-50 , Message.Get_Default_Sfixed64);
Assert_Equal ( 51.5 , Message.Get_Default_Float );
Assert_Equal ( 52.0e3, Message.Get_Default_Double );
Assert_True ( Message.Get_Default_Bool );
Assert_Equal ("hello", Message.Get_Default_String );
Assert_Equal ("world", Message.Get_Default_Bytes );
Assert_Equal (Protobuf_Unittest.TestAllTypes.BAR, Message.Get_Default_Nested_Enum );
Assert_Equal (Protobuf_Unittest.FOREIGN_BAR , Message.Get_Default_Foreign_Enum);
Assert_Equal (Protobuf_Unittest_Import.Import_BAR, Message.Get_Default_Import_Enum );
end Expect_Clear;
-------------------------
-- Expect_Packed_Clear --
-------------------------
procedure Expect_Packed_Clear
(Message : in Protobuf_Unittest.TestPackedTypes.Instance)
is
begin
-- Packed Repeated fields are empty.
Assert_Equal (0, Message.Packed_Int32_Size );
Assert_Equal (0, Message.Packed_Int64_Size );
Assert_Equal (0, Message.Packed_Uint32_Size );
Assert_Equal (0, Message.Packed_Uint64_Size );
Assert_Equal (0, Message.Packed_Sint32_Size );
Assert_Equal (0, Message.Packed_Sint64_Size );
Assert_Equal (0, Message.Packed_Fixed32_Size );
Assert_Equal (0, Message.Packed_Fixed64_Size );
Assert_Equal (0, Message.Packed_Sfixed32_Size);
Assert_Equal (0, Message.Packed_Sfixed64_Size);
Assert_Equal (0, Message.Packed_Float_Size );
Assert_Equal (0, Message.Packed_Double_Size );
Assert_Equal (0, Message.Packed_Bool_Size );
Assert_Equal (0, Message.Packed_Enum_Size );
end Expect_Packed_Clear;
-----------------------------------
-- Expect_Last_Repeateds_Removed --
-----------------------------------
procedure Expect_Last_Repeateds_Removed
(Message : in Protobuf_Unittest.TestAllTypes.Instance)
is
begin
Assert_Equal (1, Message.Repeated_Int32_Size );
Assert_Equal (1, Message.Repeated_Int64_Size );
Assert_Equal (1, Message.Repeated_Uint32_Size );
Assert_Equal (1, Message.Repeated_Uint64_Size );
Assert_Equal (1, Message.Repeated_Sint32_Size );
Assert_Equal (1, Message.Repeated_Sint64_Size );
Assert_Equal (1, Message.Repeated_Fixed32_Size );
Assert_Equal (1, Message.Repeated_Fixed64_Size );
Assert_Equal (1, Message.Repeated_Sfixed32_Size);
Assert_Equal (1, Message.Repeated_Sfixed64_Size);
Assert_Equal (1, Message.Repeated_Float_Size );
Assert_Equal (1, Message.Repeated_Double_Size );
Assert_Equal (1, Message.Repeated_Bool_Size );
Assert_Equal (1, Message.Repeated_String_Size );
Assert_Equal (1, Message.Repeated_Bytes_Size );
Assert_Equal (1, Message.Repeated_Nested_Message_Size );
Assert_Equal (1, Message.Repeated_Foreign_Message_Size);
Assert_Equal (1, Message.Repeated_Import_Message_Size );
Assert_Equal (1, Message.Repeated_Import_Message_Size );
Assert_Equal (1, Message.Repeated_Nested_Enum_Size );
Assert_Equal (1, Message.Repeated_Foreign_Enum_Size );
Assert_Equal (1, Message.Repeated_Import_Enum_Size );
-- Test that the remaining element is the correct one.
Assert_Equal (201 , Message.Get_Repeated_Int32 (0));
Assert_Equal (202 , Message.Get_Repeated_Int64 (0));
Assert_Equal (203 , Message.Get_Repeated_Uint32 (0));
Assert_Equal (204 , Message.Get_Repeated_Uint64 (0));
Assert_Equal (205 , Message.Get_Repeated_Sint32 (0));
Assert_Equal (206 , Message.Get_Repeated_Sint64 (0));
Assert_Equal (207 , Message.Get_Repeated_Fixed32 (0));
Assert_Equal (208 , Message.Get_Repeated_Fixed64 (0));
Assert_Equal (209 , Message.Get_Repeated_Sfixed32(0));
Assert_Equal (210 , Message.Get_Repeated_Sfixed64(0));
Assert_Equal (211.0, Message.Get_Repeated_Float (0));
Assert_Equal (212.0, Message.Get_Repeated_Double (0));
Assert_True ( Message.Get_Repeated_Bool (0));
Assert_Equal ("215", Message.Get_Repeated_String (0));
Assert_Equal ("216", Message.Get_Repeated_Bytes (0));
Assert_Equal (218, Message.Get_Repeated_Nested_Message (0).Get_Bb);
Assert_Equal (219, Message.Get_Repeated_Foreign_Message(0).Get_C);
Assert_Equal (220, Message.Get_Repeated_Import_Message (0).Get_D);
Assert_Equal (220, Message.Get_Repeated_Import_Message (0).Get_D);
Assert_Equal (Protobuf_Unittest.TestAllTypes.BAR , Message.Get_Repeated_Nested_Enum (0));
Assert_Equal (Protobuf_Unittest.FOREIGN_BAR , Message.Get_Repeated_Foreign_Enum(0));
Assert_Equal (Protobuf_Unittest_Import.Import_BAR , Message.Get_Repeated_Import_Enum (0));
end Expect_Last_Repeateds_Removed;
------------------------------------
-- Expect_Last_Repeateds_Released --
------------------------------------
procedure Expect_Last_Repeateds_Released
(Message : in Protobuf_Unittest.TestAllTypes.Instance)
is
begin
Assert_Equal (1, Message.Repeated_Nested_Message_Size );
Assert_Equal (1, Message.Repeated_Foreign_Message_Size);
Assert_Equal (1, Message.Repeated_Import_Message_Size );
Assert_Equal (1, Message.Repeated_Import_Message_Size );
Assert_Equal (218, Message.Get_Repeated_Nested_Message (0).Get_Bb);
Assert_Equal (219, Message.Get_Repeated_Foreign_Message(0).Get_C);
Assert_Equal (220, Message.Get_Repeated_Import_Message (0).Get_D);
Assert_Equal (220, Message.Get_Repeated_Import_Message (0).Get_D);
end Expect_Last_Repeateds_Released;
------------------------------
-- Expect_Repeateds_Swapped --
------------------------------
procedure Expect_Repeateds_Swapped
(Message : in Protobuf_Unittest.TestAllTypes.Instance)
is
begin
Assert_Equal (2, Message.Repeated_Int32_Size );
Assert_Equal (2, Message.Repeated_Int64_Size );
Assert_Equal (2, Message.Repeated_Uint32_Size );
Assert_Equal (2, Message.Repeated_Uint64_Size );
Assert_Equal (2, Message.Repeated_Sint32_Size );
Assert_Equal (2, Message.Repeated_Sint64_Size );
Assert_Equal (2, Message.Repeated_Fixed32_Size );
Assert_Equal (2, Message.Repeated_Fixed64_Size );
Assert_Equal (2, Message.Repeated_Sfixed32_Size);
Assert_Equal (2, Message.Repeated_Sfixed64_Size);
Assert_Equal (2, Message.Repeated_Float_Size );
Assert_Equal (2, Message.Repeated_Double_Size );
Assert_Equal (2, Message.Repeated_Bool_Size );
Assert_Equal (2, Message.Repeated_String_Size );
Assert_Equal (2, Message.Repeated_Bytes_Size );
Assert_Equal (2, Message.Repeated_Nested_Message_Size );
Assert_Equal (2, Message.Repeated_Foreign_Message_Size);
Assert_Equal (2, Message.Repeated_Import_Message_Size );
Assert_Equal (2, Message.Repeated_Import_Message_Size );
Assert_Equal (2, Message.Repeated_Nested_Enum_Size );
Assert_Equal (2, Message.Repeated_Foreign_Enum_Size );
Assert_Equal (2, Message.Repeated_Import_Enum_Size );
-- Test that the first element and second element are flipped.
Assert_Equal (201 , Message.Get_Repeated_Int32 (1));
Assert_Equal (202 , Message.Get_Repeated_Int64 (1));
Assert_Equal (203 , Message.Get_Repeated_Uint32 (1));
Assert_Equal (204 , Message.Get_Repeated_Uint64 (1));
Assert_Equal (205 , Message.Get_Repeated_Sint32 (1));
Assert_Equal (206 , Message.Get_Repeated_Sint64 (1));
Assert_Equal (207 , Message.Get_Repeated_Fixed32 (1));
Assert_Equal (208 , Message.Get_Repeated_Fixed64 (1));
Assert_Equal (209 , Message.Get_Repeated_Sfixed32(1));
Assert_Equal (210 , Message.Get_Repeated_Sfixed64(1));
Assert_Equal (211.0, Message.Get_Repeated_Float (1));
Assert_Equal (212.0, Message.Get_Repeated_Double (1));
Assert_True ( Message.Get_Repeated_Bool (1));
Assert_Equal ("215", Message.Get_Repeated_String (1));
Assert_Equal ("216", Message.Get_Repeated_Bytes (1));
Assert_Equal (218, Message.Get_Repeated_Nested_Message (1).Get_Bb);
Assert_Equal (219, Message.Get_Repeated_Foreign_Message(1).Get_C);
Assert_Equal (220, Message.Get_Repeated_Import_Message (1).Get_D);
Assert_Equal (Protobuf_Unittest.TestAllTypes.BAR, Message.Get_Repeated_Nested_Enum (1));
Assert_Equal (Protobuf_Unittest.FOREIGN_BAR , Message.Get_Repeated_Foreign_Enum(1));
Assert_Equal (Protobuf_Unittest_Import.Import_BAR , Message.Get_Repeated_Import_Enum (1));
Assert_Equal (301 , Message.Get_Repeated_Int32 (0));
Assert_Equal (302 , Message.Get_Repeated_Int64 (0));
Assert_Equal (303 , Message.Get_Repeated_Uint32 (0));
Assert_Equal (304 , Message.Get_Repeated_Uint64 (0));
Assert_Equal (305 , Message.Get_Repeated_Sint32 (0));
Assert_Equal (306 , Message.Get_Repeated_Sint64 (0));
Assert_Equal (307 , Message.Get_Repeated_Fixed32 (0));
Assert_Equal (308 , Message.Get_Repeated_Fixed64 (0));
Assert_Equal (309 , Message.Get_Repeated_Sfixed32(0));
Assert_Equal (310 , Message.Get_Repeated_Sfixed64(0));
Assert_Equal (311.0, Message.Get_Repeated_Float (0));
Assert_Equal (312.0, Message.Get_Repeated_Double (0));
Assert_False ( Message.Get_Repeated_Bool (0));
Assert_Equal ("315", Message.Get_Repeated_String (0));
Assert_Equal ("316", Message.Get_Repeated_Bytes (0));
Assert_Equal (318, Message.Get_Repeated_Nested_Message (0).Get_Bb);
Assert_Equal (319, Message.Get_Repeated_Foreign_Message(0).Get_C);
Assert_Equal (320, Message.Get_Repeated_Import_Message (0).Get_D);
Assert_Equal (Protobuf_Unittest.TestAllTypes.BAZ, Message.Get_Repeated_Nested_Enum (0));
Assert_Equal (Protobuf_Unittest.FOREIGN_BAZ , Message.Get_Repeated_Foreign_Enum(0));
Assert_Equal (Protobuf_Unittest_Import.Import_BAZ, Message.Get_Repeated_Import_Enum (0));
end Expect_Repeateds_Swapped;
end Test_Util;
|
reznikmm/matreshka | Ada | 3,719 | ads | ------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- Open Document Toolkit --
-- --
-- Runtime Library Component --
-- --
------------------------------------------------------------------------------
-- --
-- Copyright © 2014, Vadim Godunko <[email protected]> --
-- All rights reserved. --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions --
-- are met: --
-- --
-- * Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- --
-- * Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in the --
-- documentation and/or other materials provided with the distribution. --
-- --
-- * Neither the name of the Vadim Godunko, IE nor the names of its --
-- contributors may be used to endorse or promote products derived from --
-- this software without specific prior written permission. --
-- --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR --
-- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
-- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED --
-- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR --
-- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF --
-- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING --
-- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS --
-- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
-- --
------------------------------------------------------------------------------
-- $Revision$ $Date$
------------------------------------------------------------------------------
with XML.DOM.Attributes;
package ODF.DOM.Text_Index_Scope_Attributes is
pragma Preelaborate;
type ODF_Text_Index_Scope_Attribute is limited interface
and XML.DOM.Attributes.DOM_Attribute;
type ODF_Text_Index_Scope_Attribute_Access is
access all ODF_Text_Index_Scope_Attribute'Class
with Storage_Size => 0;
end ODF.DOM.Text_Index_Scope_Attributes;
|
niechaojun/Amass | Ada | 2,108 | ads | -- Copyright 2017 Jeff Foley. All rights reserved.
-- Use of this source code is governed by Apache 2 LICENSE that can be found in the LICENSE file.
local json = require("json")
name = "VirusTotal"
type = "api"
function start()
setratelimit(15)
end
function vertical(ctx, domain)
local c
local cfg = datasrc_config()
if cfg ~= nil then
c = cfg.credentials
end
local haskey = true
if (c == nil or c.key == nil or c.key == "") then
haskey = false
end
local resp
local vurl = buildurl(domain)
if haskey then
vurl = apiurl(domain, c.key)
end
-- Check if the response data is in the graph database
if (cfg and cfg.ttl ~= nil and cfg.ttl > 0) then
resp = obtain_response(domain, cfg.ttl)
end
if (resp == nil or resp == "") then
local err
resp, err = request({
url=vurl,
headers={['Content-Type']="application/json"},
})
if (err ~= nil and err ~= "") then
return
end
if (cfg and cfg.ttl ~= nil and cfg.ttl > 0) then
cache_response(domain, resp)
end
end
local d = json.decode(resp)
if haskey then
if d['response_code'] ~= 1 then
log(ctx, name .. ": " .. vurl .. ": Response code " .. d['response_code'] .. ": " .. d['verbose_msg'])
return
end
for i, sub in pairs(d.subdomains) do
sendnames(ctx, sub)
end
else
for i, data in pairs(d.data) do
if data.type == "domain" then
sendnames(ctx, data.id)
end
end
end
end
function buildurl(domain)
return "https://www.virustotal.com/ui/domains/" .. domain .. "/subdomains?limit=40"
end
function apiurl(domain, key)
return "https://www.virustotal.com/vtapi/v2/domain/report?apikey=" .. key .. "&domain=" .. domain
end
function sendnames(ctx, content)
local names = find(content, subdomainre)
if names == nil then
return
end
for i, v in pairs(names) do
newname(ctx, v)
end
end
|
reznikmm/matreshka | Ada | 4,631 | adb | ------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- Open Document Toolkit --
-- --
-- Runtime Library Component --
-- --
------------------------------------------------------------------------------
-- --
-- Copyright © 2014, Vadim Godunko <[email protected]> --
-- All rights reserved. --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions --
-- are met: --
-- --
-- * Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- --
-- * Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in the --
-- documentation and/or other materials provided with the distribution. --
-- --
-- * Neither the name of the Vadim Godunko, IE nor the names of its --
-- contributors may be used to endorse or promote products derived from --
-- this software without specific prior written permission. --
-- --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR --
-- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
-- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED --
-- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR --
-- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF --
-- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING --
-- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS --
-- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
-- --
------------------------------------------------------------------------------
-- $Revision$ $Date$
------------------------------------------------------------------------------
with Matreshka.DOM_Documents;
with Matreshka.ODF_String_Constants;
with ODF.DOM.Iterators;
with ODF.DOM.Visitors;
package body Matreshka.ODF_Form.Allow_Inserts_Attributes is
------------
-- Create --
------------
overriding function Create
(Parameters : not null access Matreshka.DOM_Attributes.Attribute_L2_Parameters)
return Form_Allow_Inserts_Attribute_Node is
begin
return Self : Form_Allow_Inserts_Attribute_Node do
Matreshka.ODF_Form.Constructors.Initialize
(Self'Unchecked_Access,
Parameters.Document,
Matreshka.ODF_String_Constants.Form_Prefix);
end return;
end Create;
--------------------
-- Get_Local_Name --
--------------------
overriding function Get_Local_Name
(Self : not null access constant Form_Allow_Inserts_Attribute_Node)
return League.Strings.Universal_String
is
pragma Unreferenced (Self);
begin
return Matreshka.ODF_String_Constants.Allow_Inserts_Attribute;
end Get_Local_Name;
begin
Matreshka.DOM_Documents.Register_Attribute
(Matreshka.ODF_String_Constants.Form_URI,
Matreshka.ODF_String_Constants.Allow_Inserts_Attribute,
Form_Allow_Inserts_Attribute_Node'Tag);
end Matreshka.ODF_Form.Allow_Inserts_Attributes;
|
jwarwick/aoc_2020 | Ada | 1,189 | adb | with AUnit.Assertions; use AUnit.Assertions;
package body Day.Test is
procedure Test_Part1 (T : in out AUnit.Test_Cases.Test_Case'Class) is
pragma Unreferenced (T);
v : constant XMAS_Vector.Vector := load_file("test1.txt");
invalid : constant Long_Integer := first_invalid(v, 5);
begin
Assert(invalid = 127, "Wrong number, expected 127, got" & Long_Integer'IMAGE(invalid));
end Test_Part1;
procedure Test_Part2 (T : in out AUnit.Test_Cases.Test_Case'Class) is
pragma Unreferenced (T);
v : constant XMAS_Vector.Vector := load_file("test1.txt");
contig : constant Long_Integer := find_sum(v, 127);
begin
Assert(contig = 62, "Wrong number, expected 62, got" & Long_Integer'IMAGE(contig));
end Test_Part2;
function Name (T : Test) return AUnit.Message_String is
pragma Unreferenced (T);
begin
return AUnit.Format ("Test Day package");
end Name;
procedure Register_Tests (T : in out Test) is
use AUnit.Test_Cases.Registration;
begin
Register_Routine (T, Test_Part1'Access, "Test Part 1");
Register_Routine (T, Test_Part2'Access, "Test Part 2");
end Register_Tests;
end Day.Test;
|
zrmyers/GLFWAda | Ada | 3,046 | ads | --------------------------------------------------------------------------------
-- MIT License
--
-- Copyright (c) 2020 Zane Myers
--
-- Permission is hereby granted, free of charge, to any person obtaining a copy
-- of this software and associated documentation files (the "Software"), to deal
-- in the Software without restriction, including without limitation the rights
-- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-- copies of the Software, and to permit persons to whom the Software is
-- furnished to do so, subject to the following conditions:
--
-- The above copyright notice and this permission notice shall be included in all
-- copies or substantial portions of the Software.
--
-- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
-- SOFTWARE.
--------------------------------------------------------------------------------
--------------------------------------------------------------------------------
-- This file provides an interface to Data Types and operations for raising
-- exceptions after detection of an error in GLFW.
--------------------------------------------------------------------------------
with Interfaces.C;
private package Glfw.Error is
-- Return Codes that can be passed back from GLFW operations
type Enum_Return_Codes is (
NO_ERROR,
NOT_INITIALIZED,
NO_CURRENT_CONTEXT,
INVALID_ENUM,
INVALID_VALUE,
OUT_OF_MEMORY,
API_UNAVAILABLE,
VERSION_UNAVAILABLE,
PLATFORM_ERROR,
FORMAT_UNAVAILABLE,
NO_WINDOW_CONTEXT
);
-- Values to use for Return_Codes enumeration.
for Enum_Return_Codes use (
NO_ERROR => 16#00000000#,
NOT_INITIALIZED => 16#00010001#,
NO_CURRENT_CONTEXT => 16#00010002#,
INVALID_ENUM => 16#00010003#,
INVALID_VALUE => 16#00010004#,
OUT_OF_MEMORY => 16#00010005#,
API_UNAVAILABLE => 16#00010006#,
VERSION_UNAVAILABLE => 16#00010007#,
PLATFORM_ERROR => 16#00010008#,
FORMAT_UNAVAILABLE => 16#00010009#,
NO_WINDOW_CONTEXT => 16#0001000A#
);
for Enum_Return_Codes'Size use Interfaces.C.int'Size;
----------------------------------------------------------------------------
-- @brief
-- Check to see if any errors occurred, and then raise an exception if one
-- is present.
----------------------------------------------------------------------------
procedure Raise_If_Present;
end Glfw.Error;
|
AdaCore/Ada_Drivers_Library | Ada | 5,793 | adb | ------------------------------------------------------------------------------
-- --
-- Copyright (C) 2015, AdaCore --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions are --
-- met: --
-- 1. Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- 2. Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in --
-- the documentation and/or other materials provided with the --
-- distribution. --
-- 3. Neither the name of STMicroelectronics nor the names of its --
-- contributors may be used to endorse or promote products derived --
-- from this software without specific prior written permission. --
-- --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR --
-- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
-- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT --
-- LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, --
-- DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY --
-- THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT --
-- (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE --
-- OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
-- --
-- --
-- This file is based on: --
-- --
-- @file stm32f4xx_hal_rng.c --
-- @author MCD Application Team --
-- @version V1.1.0 --
-- @date 19-June-2014 --
-- @brief RNG HAL module driver. --
-- --
-- COPYRIGHT(c) 2014 STMicroelectronics --
------------------------------------------------------------------------------
with STM32_SVD.RCC; use STM32_SVD.RCC;
with STM32_SVD.RNG; use STM32_SVD.RNG;
package body STM32.RNG is
----------------------
-- Enable_RNG_Clock --
----------------------
procedure Enable_RNG_Clock is
begin
RCC_Periph.AHB2ENR.RNGEN := True;
end Enable_RNG_Clock;
----------------
-- Enable_RNG --
----------------
procedure Enable_RNG is
begin
RNG_Periph.CR.RNGEN := True;
end Enable_RNG;
-----------------
-- Disable_RNG --
-----------------
procedure Disable_RNG is
begin
RNG_Periph.CR.RNGEN := False;
end Disable_RNG;
---------------
-- Reset_RNG --
---------------
procedure Reset_RNG
is
begin
RCC_Periph.AHB2RSTR.RNGRST := True;
RCC_Periph.AHB2RSTR.RNGRST := False;
end Reset_RNG;
-----------------
-- RNG_Enabled --
-----------------
function RNG_Enabled return Boolean is
(RNG_Periph.CR.RNGEN);
--------------------------
-- Enable_RNG_Interrupt --
--------------------------
procedure Enable_RNG_Interrupt is
begin
RNG_Periph.CR.IE := True;
end Enable_RNG_Interrupt;
---------------------------
-- Disable_RNG_Interrupt --
---------------------------
procedure Disable_RNG_Interrupt is
begin
RNG_Periph.CR.IE := False;
end Disable_RNG_Interrupt;
---------------------------
-- RNG_Interrupt_Enabled --
---------------------------
function RNG_Interrupt_Enabled return Boolean is
(RNG_Periph.CR.IE);
--------------
-- RNG_Data --
--------------
function RNG_Data return UInt32
is (RNG_Periph.DR);
--------------------
-- RNG_Data_Ready --
--------------------
function RNG_Data_Ready return Boolean
is (RNG_Periph.SR.DRDY);
---------------------------
-- RNG_Seed_Error_Status --
---------------------------
function RNG_Seed_Error_Status return Boolean is
(RNG_Periph.SR.SECS);
----------------------------
-- RNG_Clock_Error_Status --
----------------------------
function RNG_Clock_Error_Status return Boolean is
(RNG_Periph.SR.CECS);
---------------------------------
-- Clear_RNG_Seed_Error_Status --
---------------------------------
procedure Clear_RNG_Seed_Error_Status
is
begin
RNG_Periph.SR.SECS := False;
end Clear_RNG_Seed_Error_Status;
----------------------------------
-- Clear_RNG_Clock_Error_Status --
----------------------------------
procedure Clear_RNG_Clock_Error_Status
is
begin
RNG_Periph.SR.CECS := False;
end Clear_RNG_Clock_Error_Status;
end STM32.RNG;
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.