repo_name
stringlengths 9
74
| language
stringclasses 1
value | length_bytes
int64 11
9.34M
| extension
stringclasses 2
values | content
stringlengths 11
9.34M
|
---|---|---|---|---|
charlie5/aShell | Ada | 1,464 | adb | with
POSIX.Configurable_System_Limits,
Shell,
Ada.Text_IO;
procedure Test_Max_Pipes
is
procedure Log (Message : in String)
renames Ada.Text_IO.Put_Line;
procedure NL (Count : in Ada.Text_IO.Positive_Count := 1)
renames Ada.Text_IO.New_Line;
Max_Pipes : constant Natural := POSIX.Configurable_System_Limits.Open_Files_Maximum / 2 -- Two files per pipe (read_end and write_end).
- 2; -- Two files allocated to the main process.
Pipes : array (1 .. Max_Pipes) of Shell.Pipe;
Count : Natural := 0;
procedure Close_All
is
begin
for i in 1 .. Count
loop
Shell.Close (Pipes (i));
end loop;
end Close_All;
begin
NL;
Log ("Begin max pipes test.");
Log ("Max pipes:" & Max_Pipes'Image);
loop
declare
use Shell;
P : constant Shell.Pipe := To_Pipe;
begin
Count := Count + 1;
Pipes (Count) := P;
exit when Count = Pipes'Last;
end;
end loop;
Log ("All" & Pipes'Length'Image & " pipes opened successfuly.");
Close_All;
NL;
exception
when Shell.Too_Many_Pipes_Error =>
Close_All;
Log ("Opened" & Count'Image & " pipes.");
Log ("End max pipes test.");
NL;
when others =>
Close_All;
NL;
raise;
end Test_Max_Pipes;
|
reznikmm/matreshka | Ada | 3,754 | 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.Draw_Visible_Area_Width_Attributes is
pragma Preelaborate;
type ODF_Draw_Visible_Area_Width_Attribute is limited interface
and XML.DOM.Attributes.DOM_Attribute;
type ODF_Draw_Visible_Area_Width_Attribute_Access is
access all ODF_Draw_Visible_Area_Width_Attribute'Class
with Storage_Size => 0;
end ODF.DOM.Draw_Visible_Area_Width_Attributes;
|
MatrixMike/Ada_Drivers_Library | Ada | 3,165 | adb | ------------------------------------------------------------------------------
-- --
-- Copyright (C) 2018, AdaCore --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions are --
-- met: --
-- 1. Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- 2. Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in --
-- the documentation and/or other materials provided with the --
-- distribution. --
-- 3. Neither the name of the copyright holder nor the names of its --
-- contributors may be used to endorse or promote products derived --
-- from this software without specific prior written permission. --
-- --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR --
-- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
-- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT --
-- LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, --
-- DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY --
-- THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT --
-- (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE --
-- OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
-- --
------------------------------------------------------------------------------
with MicroBit.I2C;
package body MicroBit.Accelerometer is
Init_Done : Boolean := False;
Acc : MMA8653.MMA8653_Accelerometer (MicroBit.I2C.Controller);
-----------------
-- Initialized --
-----------------
function Initialized return Boolean
is (Init_Done);
----------------
-- Initialize --
----------------
procedure Initialize is
begin
if not MicroBit.I2C.Initialized then
MicroBit.I2C.Initialize;
end if;
Acc.Configure (MMA8653.Two_G,
MMA8653.High_Resolution,
MMA8653.High_Resolution);
Init_Done := True;
end Initialize;
----------
-- Data --
----------
function Data return MMA8653.All_Axes_Data
is (Acc.Read_Data);
end MicroBit.Accelerometer;
|
persan/A-gst | Ada | 10,629 | ads | pragma Ada_2005;
pragma Style_Checks (Off);
pragma Warnings (Off);
with Interfaces.C; use Interfaces.C;
with glib;
limited with GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstbuffer_h;
with glib;
with glib.Values;
with System;
with System;
limited with GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstcaps_h;
limited with GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstevent_h;
with GLIB; -- with GStreamer.GST_Low_Level.glibconfig_h;
package GStreamer.GST_Low_Level.gstreamer_0_10_gst_dataprotocol_dataprotocol_h is
-- unsupported macro: GST_TYPE_DP_VERSION (gst_dp_version_get_type ())
GST_DP_VERSION_MAJOR : constant := 0; -- gst/dataprotocol/dataprotocol.h:52
GST_DP_VERSION_MINOR : constant := 2; -- gst/dataprotocol/dataprotocol.h:58
GST_DP_HEADER_LENGTH : constant := 62; -- gst/dataprotocol/dataprotocol.h:65
-- GStreamer
-- * Copyright (C) 1999 Erik Walthinsen <[email protected]>
-- * Copyright (C) 2004,2006 Thomas Vander Stichele <thomas at apestaart dot org>
-- *
-- * dataprotocol.h: Functions implementing the GStreamer Data Protocol
-- *
-- * This library is free software; you can redistribute it and/or
-- * modify it under the terms of the GNU Library General Public
-- * License as published by the Free Software Foundation; either
-- * version 2 of the License, or (at your option) any later version.
-- *
-- * This library is distributed in the hope that it will be useful,
-- * but WITHOUT ANY WARRANTY; without even the implied warranty of
-- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-- * Library General Public License for more details.
-- *
-- * You should have received a copy of the GNU Library General Public
-- * License along with this library; if not, write to the
-- * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
-- * Boston, MA 02111-1307, USA.
--
--*
-- * GstDPVersion:
-- * @GST_DP_VERSION_0_2: protocol version 0.2
-- * @GST_DP_VERSION_1_0: protocol version 1.0
-- *
-- * The version of the GDP protocol being used.
--
subtype GstDPVersion is unsigned;
GST_DP_VERSION_0_2 : constant GstDPVersion := 1;
GST_DP_VERSION_1_0 : constant GstDPVersion := 2; -- gst/dataprotocol/dataprotocol.h:42
function gst_dp_version_get_type return GLIB.GType; -- gst/dataprotocol/dataprotocol.h:44
pragma Import (C, gst_dp_version_get_type, "gst_dp_version_get_type");
--*
-- * GST_DP_VERSION_MAJOR:
-- *
-- * The major version number of the GStreamer Data Protocol.
--
--*
-- * GST_DP_VERSION_MINOR:
-- *
-- * The minor version number of the GStreamer Data Protocol.
--
--*
-- * GST_DP_HEADER_LENGTH:
-- *
-- * The header size in bytes.
--
--*
-- * GstDPHeaderFlag:
-- * @GST_DP_HEADER_FLAG_NONE: No flag present.
-- * @GST_DP_HEADER_FLAG_CRC_HEADER: a header CRC field is present.
-- * @GST_DP_HEADER_FLAG_CRC_PAYLOAD: a payload CRC field is present.
-- * @GST_DP_HEADER_FLAG_CRC: a CRC for header and payload is present.
-- *
-- * header flags for the dataprotocol.
--
type GstDPHeaderFlag is
(GST_DP_HEADER_FLAG_NONE,
GST_DP_HEADER_FLAG_CRC_HEADER,
GST_DP_HEADER_FLAG_CRC_PAYLOAD,
GST_DP_HEADER_FLAG_CRC);
pragma Convention (C, GstDPHeaderFlag); -- gst/dataprotocol/dataprotocol.h:81
--*
-- * GstDPPayloadType:
-- * @GST_DP_PAYLOAD_NONE: Invalid payload type.
-- * @GST_DP_PAYLOAD_BUFFER: #GstBuffer payload packet.
-- * @GST_DP_PAYLOAD_CAPS: #GstCaps payload packet.
-- * @GST_DP_PAYLOAD_EVENT_NONE: First value of #GstEvent payload packets.
-- *
-- * The GDP payload types. a #GstEvent payload type is encoded with the
-- * event type number starting from @GST_DP_PAYLOAD_EVENT_NONE.
--
subtype GstDPPayloadType is unsigned;
GST_DP_PAYLOAD_NONE : constant GstDPPayloadType := 0;
GST_DP_PAYLOAD_BUFFER : constant GstDPPayloadType := 1;
GST_DP_PAYLOAD_CAPS : constant GstDPPayloadType := 2;
GST_DP_PAYLOAD_EVENT_NONE : constant GstDPPayloadType := 64; -- gst/dataprotocol/dataprotocol.h:98
type GstDPHeaderFromBufferFunction is access function
(arg1 : access constant GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstbuffer_h.GstBuffer;
arg2 : GstDPHeaderFlag;
arg3 : access GLIB.guint;
arg4 : System.Address) return GLIB.gboolean;
pragma Convention (C, GstDPHeaderFromBufferFunction); -- gst/dataprotocol/dataprotocol.h:100
type GstDPPacketFromCapsFunction is access function
(arg1 : access constant GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstcaps_h.GstCaps;
arg2 : GstDPHeaderFlag;
arg3 : access GLIB.guint;
arg4 : System.Address;
arg5 : System.Address) return GLIB.gboolean;
pragma Convention (C, GstDPPacketFromCapsFunction); -- gst/dataprotocol/dataprotocol.h:104
type GstDPPacketFromEventFunction is access function
(arg1 : access constant GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstevent_h.GstEvent;
arg2 : GstDPHeaderFlag;
arg3 : access GLIB.guint;
arg4 : System.Address;
arg5 : System.Address) return GLIB.gboolean;
pragma Convention (C, GstDPPacketFromEventFunction); -- gst/dataprotocol/dataprotocol.h:109
--*
-- * GstDPPacketizer:
-- * @version: the #GstDPVersion of the protocol to be used
-- * @header_from_buffer: buffer serializer function
-- * @packet_from_caps: caps serializer function
-- * @packet_from_event: event serializer function
-- *
-- * Data protocol packetizer handle.
--
type GstDPPacketizer_u_gst_reserved_array is array (0 .. 3) of System.Address;
type GstDPPacketizer is record
version : aliased GstDPVersion; -- gst/dataprotocol/dataprotocol.h:125
header_from_buffer : GstDPHeaderFromBufferFunction; -- gst/dataprotocol/dataprotocol.h:127
packet_from_caps : GstDPPacketFromCapsFunction; -- gst/dataprotocol/dataprotocol.h:128
packet_from_event : GstDPPacketFromEventFunction; -- gst/dataprotocol/dataprotocol.h:129
u_gst_reserved : GstDPPacketizer_u_gst_reserved_array; -- gst/dataprotocol/dataprotocol.h:132
end record;
pragma Convention (C_Pass_By_Copy, GstDPPacketizer); -- gst/dataprotocol/dataprotocol.h:133
-- skipped anonymous struct anon_369
--< private >
procedure gst_dp_init; -- gst/dataprotocol/dataprotocol.h:136
pragma Import (C, gst_dp_init, "gst_dp_init");
-- packetizer
function gst_dp_packetizer_new (version : GstDPVersion) return access GstDPPacketizer; -- gst/dataprotocol/dataprotocol.h:140
pragma Import (C, gst_dp_packetizer_new, "gst_dp_packetizer_new");
procedure gst_dp_packetizer_free (packetizer : access GstDPPacketizer); -- gst/dataprotocol/dataprotocol.h:141
pragma Import (C, gst_dp_packetizer_free, "gst_dp_packetizer_free");
-- crc checksum
function gst_dp_crc (buffer : access GLIB.guint8; length : GLIB.guint) return GLIB.guint16; -- gst/dataprotocol/dataprotocol.h:144
pragma Import (C, gst_dp_crc, "gst_dp_crc");
-- payload information from header
function gst_dp_header_payload_length (header : access GLIB.guint8) return GLIB.guint32; -- gst/dataprotocol/dataprotocol.h:148
pragma Import (C, gst_dp_header_payload_length, "gst_dp_header_payload_length");
function gst_dp_header_payload_type (header : access GLIB.guint8) return GstDPPayloadType; -- gst/dataprotocol/dataprotocol.h:150
pragma Import (C, gst_dp_header_payload_type, "gst_dp_header_payload_type");
-- converting from GstBuffer/GstEvent/GstCaps
function gst_dp_header_from_buffer
(buffer : access constant GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstbuffer_h.GstBuffer;
flags : GstDPHeaderFlag;
length : access GLIB.guint;
header : System.Address) return GLIB.gboolean; -- gst/dataprotocol/dataprotocol.h:154
pragma Import (C, gst_dp_header_from_buffer, "gst_dp_header_from_buffer");
function gst_dp_packet_from_caps
(caps : access constant GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstcaps_h.GstCaps;
flags : GstDPHeaderFlag;
length : access GLIB.guint;
header : System.Address;
payload : System.Address) return GLIB.gboolean; -- gst/dataprotocol/dataprotocol.h:160
pragma Import (C, gst_dp_packet_from_caps, "gst_dp_packet_from_caps");
function gst_dp_packet_from_event
(event : access constant GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstevent_h.GstEvent;
flags : GstDPHeaderFlag;
length : access GLIB.guint;
header : System.Address;
payload : System.Address) return GLIB.gboolean; -- gst/dataprotocol/dataprotocol.h:167
pragma Import (C, gst_dp_packet_from_event, "gst_dp_packet_from_event");
-- converting to GstBuffer/GstEvent/GstCaps
function gst_dp_buffer_from_header (header_length : GLIB.guint; header : access GLIB.guint8) return access GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstbuffer_h.GstBuffer; -- gst/dataprotocol/dataprotocol.h:174
pragma Import (C, gst_dp_buffer_from_header, "gst_dp_buffer_from_header");
function gst_dp_caps_from_packet
(header_length : GLIB.guint;
header : access GLIB.guint8;
payload : access GLIB.guint8) return access GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstcaps_h.GstCaps; -- gst/dataprotocol/dataprotocol.h:176
pragma Import (C, gst_dp_caps_from_packet, "gst_dp_caps_from_packet");
function gst_dp_event_from_packet
(header_length : GLIB.guint;
header : access GLIB.guint8;
payload : access GLIB.guint8) return access GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstevent_h.GstEvent; -- gst/dataprotocol/dataprotocol.h:179
pragma Import (C, gst_dp_event_from_packet, "gst_dp_event_from_packet");
-- validation
function gst_dp_validate_header (header_length : GLIB.guint; header : access GLIB.guint8) return GLIB.gboolean; -- gst/dataprotocol/dataprotocol.h:184
pragma Import (C, gst_dp_validate_header, "gst_dp_validate_header");
function gst_dp_validate_payload
(header_length : GLIB.guint;
header : access GLIB.guint8;
payload : access GLIB.guint8) return GLIB.gboolean; -- gst/dataprotocol/dataprotocol.h:186
pragma Import (C, gst_dp_validate_payload, "gst_dp_validate_payload");
function gst_dp_validate_packet
(header_length : GLIB.guint;
header : access GLIB.guint8;
payload : access GLIB.guint8) return GLIB.gboolean; -- gst/dataprotocol/dataprotocol.h:189
pragma Import (C, gst_dp_validate_packet, "gst_dp_validate_packet");
end GStreamer.GST_Low_Level.gstreamer_0_10_gst_dataprotocol_dataprotocol_h;
|
stcarrez/ada-ado | Ada | 2,954 | adb | -----------------------------------------------------------------------
-- Print_User -- Example to find an object from the database
-- Copyright (C) 2010, 2011, 2018 Stephane Carrez
-- Written by Stephane Carrez ([email protected])
--
-- Licensed under the Apache License, Version 2.0 (the "License");
-- you may not use this file except in compliance with the License.
-- You may obtain a copy of the License at
--
-- http://www.apache.org/licenses/LICENSE-2.0
--
-- Unless required by applicable law or agreed to in writing, software
-- distributed under the License is distributed on an "AS IS" BASIS,
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-- See the License for the specific language governing permissions and
-- limitations under the License.
-----------------------------------------------------------------------
with ADO;
with ADO.Drivers;
with ADO.Configs;
with ADO.Sessions;
with ADO.Connections;
with ADO.SQL;
with ADO.Sessions.Factory;
with Samples.User.Model;
with Util.Log.Loggers;
with Ada.Text_IO;
with Ada.Exceptions;
with Ada.Command_Line;
procedure Print_User is
use ADO;
use Samples.User.Model;
Factory : ADO.Sessions.Factory.Session_Factory;
begin
Util.Log.Loggers.Initialize ("samples.properties");
-- Initialize the database drivers.
ADO.Drivers.Initialize ("samples.properties");
if Ada.Command_Line.Argument_Count < 1 then
Ada.Text_IO.Put_Line ("Usage: print_user user-name ...");
Ada.Text_IO.Put_Line ("Example: print_user joe");
Ada.Command_Line.Set_Exit_Status (2);
return;
end if;
-- Create and configure the connection pool
Factory.Create (ADO.Configs.Get_Config ("ado.database"));
declare
Session : ADO.Sessions.Session := Factory.Get_Session;
User : User_Ref;
Found : Boolean;
begin
for I in 1 .. Ada.Command_Line.Argument_Count loop
declare
User_Name : constant String := Ada.Command_Line.Argument (I);
Query : ADO.SQL.Query;
begin
Ada.Text_IO.Put_Line ("Searching '" & User_Name & "'...");
Query.Bind_Param (1, User_Name);
Query.Set_Filter ("name = ?");
User.Find (Session => Session, Query => Query, Found => Found);
if Found then
Ada.Text_IO.Put_Line (" Id : " & Identifier'Image (User.Get_Id));
Ada.Text_IO.Put_Line (" User : " & User.Get_Name);
Ada.Text_IO.Put_Line (" Email : " & User.Get_Email);
else
Ada.Text_IO.Put_Line (" User '" & User_Name & "' does not exist");
end if;
end;
end loop;
end;
exception
when E : ADO.Connections.Database_Error | ADO.Sessions.Connection_Error =>
Ada.Text_IO.Put_Line ("Cannot connect to database: "
& Ada.Exceptions.Exception_Message (E));
end Print_User;
|
tum-ei-rcs/StratoX | Ada | 13,326 | adb | ------------------------------------------------------------------------------
-- --
-- Copyright (C) 2016, AdaCore --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions are --
-- met: --
-- 1. Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- 2. Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in --
-- the documentation and/or other materials provided with the --
-- distribution. --
-- 3. Neither the name of STMicroelectronics nor the names of its --
-- contributors may be used to endorse or promote products derived --
-- from this software without specific prior written permission. --
-- --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR --
-- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
-- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT --
-- LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, --
-- DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY --
-- THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT --
-- (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE --
-- OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
-- --
-- --
-- This file is based on: --
-- --
-- @file stm32f7xx_hal_sai.c --
-- @author MCD Application Team --
-- @version V1.0.2 --
-- @date 21-September-2015 --
-- @brief This file provides firmware functions to manage the following --
-- functionalities of the Serial Audio Interface (SAI) --
-- peripheral: --
-- + Initialization/de-initialization functions --
-- + I/O operation functions --
-- + Peripheral Control functions --
-- + Peripheral State functions --
-- --
-- COPYRIGHT(c) 2015 STMicroelectronics --
------------------------------------------------------------------------------
with System; use System;
with Ada.Real_Time; use Ada.Real_Time;
with STM32.Device; use STM32.Device;
with STM32_SVD; use STM32_SVD;
with STM32_SVD.SAI; use STM32_SVD.SAI;
with STM32_SVD.RCC; use STM32_SVD.RCC;
package body STM32.SAI is
type Block_Registers is record
-- AConfiguration register 1
CR1 : ACR1_Register;
-- AConfiguration register 2
CR2 : ACR2_Register;
-- AFRCR
FRCR : AFRCR_Register;
-- ASlot register
SLOTR : ASLOTR_Register;
-- AInterrupt mask register2
IM : AIM_Register;
-- AStatus register
SR : ASR_Register;
-- AClear flag register
CLRFR : ACLRFR_Register;
-- AData register
DR : Word;
end record with Volatile;
for Block_Registers use record
CR1 at 0 range 0 .. 31;
CR2 at 4 range 0 .. 31;
FRCR at 8 range 0 .. 31;
SLOTR at 12 range 0 .. 31;
IM at 16 range 0 .. 31;
SR at 20 range 0 .. 31;
CLRFR at 24 range 0 .. 31;
DR at 28 range 0 .. 31;
end record;
type Block_Registers_Access is access all Block_Registers;
function Get_Block
(Periph : SAI_Controller;
Block : SAI_Block) return Block_Registers_Access;
function Get_Input_Clock (Periph : SAI_Controller) return Word;
---------------
-- Get_Block --
---------------
function Get_Block
(Periph : SAI_Controller;
Block : SAI_Block) return Block_Registers_Access
is
BlockA : aliased Block_Registers
with Volatile, Import, Address => Periph.ACR1'Address;
BlockB : aliased Block_Registers
with Volatile, Import, Address => Periph.BCR1'Address;
begin
case Block is
when Block_A =>
return BlockA'Unchecked_Access;
when Block_B =>
return BlockB'Unchecked_Access;
end case;
end Get_Block;
---------------------
-- Get_Input_Clock --
---------------------
function Get_Input_Clock (Periph : SAI_Controller) return Word
is
Input_Selector : UInt2;
VCO_Input : Word;
SAI_First_Level : Word;
begin
if Periph'Address = SAI1_Base then
Input_Selector := RCC_Periph.DKCFGR1.SAI1SEL;
else
Input_Selector := RCC_Periph.DKCFGR1.SAI2SEL;
end if;
-- This driver doesn't support external source clock
if Input_Selector > 1 then
raise Constraint_Error
with "External PLL SAI source clock unsupported";
end if;
if not RCC_Periph.PLLCFGR.PLLSRC then
-- PLLSAI SRC is HSI
VCO_Input := HSI_VALUE / Word (RCC_Periph.PLLCFGR.PLLM);
else
-- PLLSAI SRC is HSE
VCO_Input := HSE_VALUE / Word (RCC_Periph.PLLCFGR.PLLM);
end if;
if Input_Selector = 0 then
-- PLLSAI is the clock source
-- VCO out = VCO in & PLLSAIN
-- SAI firstlevel = VCO out / PLLSAIQ
SAI_First_Level :=
VCO_Input * Word (RCC_Periph.PLLSAICFGR.PLLSAIN) /
Word (RCC_Periph.PLLSAICFGR.PLLSAIQ);
-- SAI frequency is SAI First level / PLLSAIDIVQ
return SAI_First_Level / Word (RCC_Periph.DKCFGR1.PLLSAIDIVQ);
else
-- PLLI2S as clock source
SAI_First_Level :=
VCO_Input * Word (RCC_Periph.PLLI2SCFGR.PLLI2SN) /
Word (RCC_Periph.PLLI2SCFGR.PLLI2SQ);
-- SAI frequency is SAI First level / PLLI2SDIVQ
return SAI_First_Level / Word (RCC_Periph.DKCFGR1.PLLI2SDIV + 1);
end if;
end Get_Input_Clock;
------------------
-- Deinitialize --
------------------
procedure Deinitialize
(Periph : SAI_Controller;
Block : SAI_Block)
is
Block_Regs : constant Block_Registers_Access :=
Get_Block (Periph, Block);
Start : Time;
begin
-- Disable SAI
Block_Regs.CR1.SAIAEN := False;
Start := Clock;
while Block_Regs.CR1.SAIAEN loop
if Start + Seconds (1) < Clock then
raise Constraint_Error with "Cannot reset the SAI peripheral";
end if;
end loop;
-- Reset the SAI block interrupts
Block_Regs.IM := (others => <>);
Block_Regs.CLRFR :=
(Reserved_3_3 => 0,
Reserved_7_31 => 0,
others => True);
-- Flush the FIFO
Block_Regs.CR2.FFLUS := True;
end Deinitialize;
-------------
-- Enabled --
-------------
function Enabled (Periph : SAI_Controller;
Block : SAI_Block) return Boolean
is
Block_Regs : constant Block_Registers_Access :=
Get_Block (Periph, Block);
begin
return Block_Regs.CR1.SAIAEN;
end Enabled;
------------
-- Enable --
------------
procedure Enable
(Periph : SAI_Controller;
Block : SAI_Block)
is
Block_Regs : constant Block_Registers_Access :=
Get_Block (Periph, Block);
begin
Block_Regs.CR1.SAIAEN := True;
end Enable;
-------------
-- Disable --
-------------
procedure Disable
(Periph : SAI_Controller;
Block : SAI_Block)
is
Block_Regs : constant Block_Registers_Access :=
Get_Block (Periph, Block);
begin
Block_Regs.CR1.SAIAEN := False;
end Disable;
----------------
-- Enable_DMA --
----------------
procedure Enable_DMA
(Periph : SAI_Controller;
Block : SAI_Block)
is
Block_Regs : constant Block_Registers_Access :=
Get_Block (Periph, Block);
begin
Block_Regs.CR1.DMAEN := True;
end Enable_DMA;
---------------------------
-- Configure_Audio_Block --
---------------------------
procedure Configure_Audio_Block
(Periph : SAI_Controller;
Block : SAI_Block;
Frequency : Audio_Frequency;
Stereo_Mode : SAI_Mono_Stereo_Mode;
Mode : SAI_Audio_Mode;
MCD_Enabled : Boolean;
Protocol : SAI_Protocol_Configuration;
Data_Size : SAI_Data_Size;
Endianness : SAI_Endianness;
Clock_Strobing : SAI_Clock_Strobing_Edge;
Synchronization : SAI_Synchronization;
Output_Drive : SAI_Output_Drive;
FIFO_Threshold : SAI_FIFO_Threshold;
Tristate_Mgt : SAI_Tristate_Management := SD_Line_Driven;
Companding_Mode : SAI_Companding_Mode := No_Companding)
is
Block_Reg : constant Block_Registers_Access := Get_Block (Periph, Block);
Freq : Word;
Tmp_Clock : Word;
Mckdiv : Word;
begin
Deinitialize (Periph, Block);
-- Configure Master Clock using the following formula :
-- MCLK_x = SAI_CK_x / (MCKDIV[3:0] * 2) with MCLK_x = 256 * FS
-- FS = SAI_CK_x / (MCKDIV[3:0] * 2) * 256
-- MCKDIV[3:0] = SAI_CK_x / FS * 512
Freq := Get_Input_Clock (Periph);
-- Calculate *10 to keep some precision
Tmp_Clock := Freq * 10 / (Frequency * 512);
Mckdiv := Tmp_Clock / 10;
-- Round the result if needed
if (Tmp_Clock mod 10) > 8 then
Mckdiv := Mckdiv + 1;
end if;
Block_Reg.CR1 :=
(MODE => SAI_Audio_Mode'Enum_Rep (Mode),
PRTCFG => SAI_Protocol_Configuration'Enum_Rep (Protocol),
DS => SAI_Data_Size'Enum_Rep (Data_Size),
LSBFIRST => Endianness = Data_LSB_First,
CKSTR => Clock_Strobing = Clock_Strobing_Rising_Edge,
SYNCEN => SAI_Synchronization'Enum_Rep (Synchronization),
MONO => Stereo_Mode = Mono,
OutDri => Output_Drive = Drive_Immediate,
SAIAEN => False,
DMAEN => False,
NODIV => not MCD_Enabled,
MCJDIV => UInt4 (Mckdiv),
others => <>);
Block_Reg.CR2.FTH := SAI_FIFO_Threshold'Enum_Rep (FIFO_Threshold);
Block_Reg.CR2.FFLUS := False;
Block_Reg.CR2.TRIS := Tristate_Mgt = SD_Line_Released;
Block_Reg.CR2.COMP := SAI_Companding_Mode'Enum_Rep (Companding_Mode);
end Configure_Audio_Block;
---------------------------
-- Configure_Block_Frame --
---------------------------
procedure Configure_Block_Frame
(Periph : SAI_Controller;
Block : SAI_Block;
Frame_Length : Byte;
Frame_Active : UInt7;
Frame_Sync : SAI_Frame_Synchronization;
FS_Polarity : SAI_Frame_Sync_Polarity;
FS_Offset : SAI_Frame_Sync_Offset)
is
Block_Reg : constant Block_Registers_Access := Get_Block (Periph, Block);
begin
Block_Reg.FRCR :=
(FRL => Frame_Length - 1,
FSALL => Frame_Active - 1,
FSDEF => Frame_Sync = FS_Frame_And_Channel_Identification,
FSPOL => FS_Polarity = FS_Active_High,
FSOFF => FS_Offset = Before_First_Bit,
others => <>);
end Configure_Block_Frame;
--------------------------
-- Configure_Block_Slot --
--------------------------
procedure Configure_Block_Slot
(Periph : SAI_Controller;
Block : SAI_Block;
First_Bit_Offset : UInt5;
Slot_Size : SAI_Slot_Size;
Number_Of_Slots : Slots_Number;
Enabled_Slots : SAI_Slots)
is
Block_Reg : constant Block_Registers_Access := Get_Block (Periph, Block);
begin
Block_Reg.SLOTR :=
(FBOFF => First_Bit_Offset,
SLOTSZ => SAI_Slot_Size'Enum_Rep (Slot_Size),
NBSLOT => UInt4 (Number_Of_Slots - 1),
SLOTEN => Short (Enabled_Slots),
others => <>);
end Configure_Block_Slot;
end STM32.SAI;
|
reznikmm/matreshka | Ada | 3,694 | 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.Chart_Lines_Attributes is
pragma Preelaborate;
type ODF_Chart_Lines_Attribute is limited interface
and XML.DOM.Attributes.DOM_Attribute;
type ODF_Chart_Lines_Attribute_Access is
access all ODF_Chart_Lines_Attribute'Class
with Storage_Size => 0;
end ODF.DOM.Chart_Lines_Attributes;
|
msrLi/portingSources | Ada | 964 | adb | -- Copyright 2012-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/>.
with Pck; use Pck;
procedure Foo is
type Small is range 0 .. 1000;
Small_Value : Small := 10;
begin
for J in 1 .. 10 loop
Small_Value := Small_Value + Small (J);
Do_Nothing (Small_Value'Address); -- STOP
end loop;
end Foo;
|
AdaCore/libadalang | Ada | 374 | ads | package Invalid is
function F return Integer is (0);
type Rec is null record;
Bad_Decl : constant Integer := F'First;
--% node.f_default_expr.p_eval_as_int
Bad_Type : constant Integer := Rec'First;
--% node.f_default_expr.p_eval_as_int
Unknown_Decl : constant Integer := Invalid_Subtype'First;
--% node.f_default_expr.p_eval_as_int
end Invalid;
|
vpodzime/ada-util | Ada | 5,409 | ads | -----------------------------------------------------------------------
-- Util.beans.factory -- Bean Registration and Factory
-- Copyright (C) 2010 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 Util.Beans.Basic;
with Util.Beans.Methods;
private with Ada.Containers.Indefinite_Hashed_Maps;
private with Ada.Strings.Unbounded.Hash;
-- The <b>EL.Beans.Factory</b> package is a registry for the creation
-- of request, session and application beans.
package Util.Beans.Factory is
-- The bean definition is a small descriptor used by the
-- factory to create the bean instance when it is needed.
-- It also defines the methods that can be specified and
-- invoked as part of a <b>Method_Expression</b>.
type Bean_Definition (Method_Count : Natural) is abstract tagged limited record
Methods : Util.Beans.Methods.Method_Binding_Array (1 .. Method_Count);
end record;
type Bean_Definition_Access is access constant Bean_Definition'Class;
-- Create a bean.
function Create (Def : in Bean_Definition)
return Util.Beans.Basic.Readonly_Bean_Access is abstract;
-- Free the bean instance.
procedure Destroy (Def : in Bean_Definition;
Bean : in out Util.Beans.Basic.Readonly_Bean_Access) is abstract;
-- Defines the scope of the bean instance.
type Scope_Type is
(
-- Application scope means the bean is shared by all sessions and requests
APPLICATION_SCOPE,
-- Session scope means the bean is created one for each session.
SESSION_SCOPE,
-- Request scope means the bean is created for each request
REQUEST_SCOPE,
ANY_SCOPE);
-- ------------------------------
-- Binding
-- ------------------------------
type Binding is interface;
type Binding_Access is access all Binding'Class;
procedure Create (Factory : in Binding;
Name : in Ada.Strings.Unbounded.Unbounded_String;
Result : out Util.Beans.Basic.Readonly_Bean_Access;
Definition : out Bean_Definition_Access;
Scope : out Scope_Type) is abstract;
-- ------------------------------
-- Bean Factory
-- ------------------------------
-- Factory for bean creation
type Bean_Factory is limited private;
-- Register under the given name a function to create the bean instance when
-- it is accessed for a first time. The scope defines the scope of the bean.
-- bean
procedure Register (Factory : in out Bean_Factory;
Name : in String;
Definition : in Bean_Definition_Access;
Scope : in Scope_Type := REQUEST_SCOPE);
-- Register under the given name a function to create the bean instance when
-- it is accessed for a first time. The scope defines the scope of the bean.
-- bean
procedure Register (Factory : in out Bean_Factory;
Name : in String;
Bind : in Binding_Access);
-- Register all the definitions from a factory to a main factory.
procedure Register (Factory : in out Bean_Factory;
From : in Bean_Factory);
-- Create a bean by using the create operation registered for the name
procedure Create (Factory : in Bean_Factory;
Name : in Ada.Strings.Unbounded.Unbounded_String;
Result : out Util.Beans.Basic.Readonly_Bean_Access;
Definition : out Bean_Definition_Access;
Scope : out Scope_Type);
type Simple_Binding is new Binding with private;
procedure Create (Factory : in Simple_Binding;
Name : in Ada.Strings.Unbounded.Unbounded_String;
Result : out Util.Beans.Basic.Readonly_Bean_Access;
Definition : out Bean_Definition_Access;
Scope : out Scope_Type);
private
type Simple_Binding is new Binding with record
Def : Bean_Definition_Access;
Scope : Scope_Type;
end record;
type Simple_Binding_Access is access all Simple_Binding;
use Ada.Strings.Unbounded;
package Bean_Maps is new
Ada.Containers.Indefinite_Hashed_Maps (Key_Type => Unbounded_String,
Element_Type => Binding_Access,
Hash => Ada.Strings.Unbounded.Hash,
Equivalent_Keys => "=");
type Bean_Factory is limited record
Map : Bean_Maps.Map;
end record;
end Util.Beans.Factory;
|
faelys/natools | Ada | 198 | ads | package Natools.S_Expressions.Printers.Pretty.Config.Quoted_Cmd is
pragma Preelaborate;
function Hash (S : String) return Natural;
end Natools.S_Expressions.Printers.Pretty.Config.Quoted_Cmd;
|
stcarrez/ada-util | Ada | 3,245 | adb | -----------------------------------------------------------------------
-- util-systems-os-tests -- Unit tests for OS specific operations
-- Copyright (C) 2014, 2015, 2016, 2021 Stephane Carrez
-- Written by Stephane Carrez ([email protected])
--
-- Licensed under the Apache License, Version 2.0 (the "License");
-- you may not use this file except in compliance with the License.
-- You may obtain a copy of the License at
--
-- http://www.apache.org/licenses/LICENSE-2.0
--
-- Unless required by applicable law or agreed to in writing, software
-- distributed under the License is distributed on an "AS IS" BASIS,
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-- See the License for the specific language governing permissions and
-- limitations under the License.
-----------------------------------------------------------------------
with Ada.Directories;
with Util.Test_Caller;
with Util.Systems.Types;
with Interfaces.C.Strings;
package body Util.Systems.Os.Tests is
package Caller is new Util.Test_Caller (Test, "Systems.OS");
procedure Add_Tests (Suite : in Util.Tests.Access_Test_Suite) is
begin
Caller.Add_Test (Suite, "Test Util.Systems.Os.Sys_Stat (File)",
Test_Stat'Access);
Caller.Add_Test (Suite, "Test Util.Systems.Os.Sys_Stat (Directory)",
Test_Stat_Directory'Access);
end Add_Tests;
-- ------------------------------
-- Test the Sys_Stat operation.
-- ------------------------------
procedure Test_Stat (T : in out Test) is
use Interfaces.C;
use Util.Systems.Types;
Info : array (1 .. 2) of aliased Util.Systems.Types.Stat_Type;
Path : constant String := Util.Tests.Get_Path ("regtests/files/test-1.json");
Name : Util.Systems.Os.Ptr := Interfaces.C.Strings.New_String (Path);
Res : Integer;
begin
Info (2).st_dev := 16#12345678#;
Res := Sys_Stat (Name, Info (1)'Unchecked_Access);
T.Assert (Res = 0, "Sys_Stat must return 0");
T.Assert (Info (1).st_size > 0, "Sys_Stat must return the correct size");
T.Assert (Info (2).st_dev = 16#12345678#, "Suspecting invalid size for Stat_Type");
T.Assert (Info (1).st_size = off_t (Ada.Directories.Size (Path)),
"Invalid size returned by Sys_Stat");
T.Assert ((Info (1).st_mode and S_IFMT) = S_IFREG, "st_mode must indicate a regular file");
Interfaces.C.Strings.Free (Name);
end Test_Stat;
-- ------------------------------
-- Test the Sys_Stat operation.
-- ------------------------------
procedure Test_Stat_Directory (T : in out Test) is
use Interfaces.C;
use Util.Systems.Types;
Stat : aliased Util.Systems.Types.Stat_Type;
Path : constant String := Util.Tests.Get_Path ("regtests/files");
Name : Util.Systems.Os.Ptr := Interfaces.C.Strings.New_String (Path);
Res : Integer;
begin
Res := Sys_Stat (Name, Stat'Unchecked_Access);
T.Assert (Res = 0, "Sys_Stat must return 0");
T.Assert ((Stat.st_mode and S_IFMT) = S_IFDIR, "st_mode must indicate a directory");
Interfaces.C.Strings.Free (Name);
end Test_Stat_Directory;
end Util.Systems.Os.Tests;
|
charlie5/cBound | Ada | 1,786 | ads | -- This file is generated by SWIG. Please do not modify by hand.
--
with Interfaces;
with Interfaces.C;
with Interfaces.C.Pointers;
package xcb.xcb_alloc_color_planes_request_t is
-- Item
--
type Item is record
major_opcode : aliased Interfaces.Unsigned_8;
contiguous : aliased Interfaces.Unsigned_8;
length : aliased Interfaces.Unsigned_16;
cmap : aliased xcb.xcb_colormap_t;
colors : aliased Interfaces.Unsigned_16;
reds : aliased Interfaces.Unsigned_16;
greens : aliased Interfaces.Unsigned_16;
blues : aliased Interfaces.Unsigned_16;
end record;
-- Item_Array
--
type Item_Array is
array
(Interfaces.C
.size_t range <>) of aliased xcb.xcb_alloc_color_planes_request_t
.Item;
-- Pointer
--
package C_Pointers is new Interfaces.C.Pointers
(Index => Interfaces.C.size_t,
Element => xcb.xcb_alloc_color_planes_request_t.Item,
Element_Array => xcb.xcb_alloc_color_planes_request_t.Item_Array,
Default_Terminator => (others => <>));
subtype Pointer is C_Pointers.Pointer;
-- Pointer_Array
--
type Pointer_Array is
array
(Interfaces.C
.size_t range <>) of aliased xcb.xcb_alloc_color_planes_request_t
.Pointer;
-- Pointer_Pointer
--
package C_Pointer_Pointers is new Interfaces.C.Pointers
(Index => Interfaces.C.size_t,
Element => xcb.xcb_alloc_color_planes_request_t.Pointer,
Element_Array => xcb.xcb_alloc_color_planes_request_t.Pointer_Array,
Default_Terminator => null);
subtype Pointer_Pointer is C_Pointer_Pointers.Pointer;
end xcb.xcb_alloc_color_planes_request_t;
|
AdaCore/libadalang | Ada | 46 | ads | package A is
type T is null record;
end A;
|
optikos/oasis | Ada | 5,782 | ads | -- Copyright (c) 2019 Maxim Reznik <[email protected]>
--
-- SPDX-License-Identifier: MIT
-- License-Filename: LICENSE
-------------------------------------------------------------
with Program.Lexical_Elements;
with Program.Elements.Defining_Identifiers;
with Program.Elements.Aspect_Specifications;
with Program.Elements.Package_Body_Stubs;
with Program.Element_Visitors;
package Program.Nodes.Package_Body_Stubs is
pragma Preelaborate;
type Package_Body_Stub is
new Program.Nodes.Node
and Program.Elements.Package_Body_Stubs.Package_Body_Stub
and Program.Elements.Package_Body_Stubs.Package_Body_Stub_Text
with private;
function Create
(Package_Token : not null Program.Lexical_Elements
.Lexical_Element_Access;
Body_Token : not null Program.Lexical_Elements
.Lexical_Element_Access;
Name : not null Program.Elements.Defining_Identifiers
.Defining_Identifier_Access;
Is_Token : not null Program.Lexical_Elements
.Lexical_Element_Access;
Separate_Token : not null Program.Lexical_Elements
.Lexical_Element_Access;
With_Token : Program.Lexical_Elements.Lexical_Element_Access;
Aspects : Program.Elements.Aspect_Specifications
.Aspect_Specification_Vector_Access;
Semicolon_Token : not null Program.Lexical_Elements
.Lexical_Element_Access)
return Package_Body_Stub;
type Implicit_Package_Body_Stub is
new Program.Nodes.Node
and Program.Elements.Package_Body_Stubs.Package_Body_Stub
with private;
function Create
(Name : not null Program.Elements.Defining_Identifiers
.Defining_Identifier_Access;
Aspects : Program.Elements.Aspect_Specifications
.Aspect_Specification_Vector_Access;
Is_Part_Of_Implicit : Boolean := False;
Is_Part_Of_Inherited : Boolean := False;
Is_Part_Of_Instance : Boolean := False)
return Implicit_Package_Body_Stub
with Pre =>
Is_Part_Of_Implicit or Is_Part_Of_Inherited or Is_Part_Of_Instance;
private
type Base_Package_Body_Stub is
abstract new Program.Nodes.Node
and Program.Elements.Package_Body_Stubs.Package_Body_Stub
with record
Name : not null Program.Elements.Defining_Identifiers
.Defining_Identifier_Access;
Aspects : Program.Elements.Aspect_Specifications
.Aspect_Specification_Vector_Access;
end record;
procedure Initialize (Self : aliased in out Base_Package_Body_Stub'Class);
overriding procedure Visit
(Self : not null access Base_Package_Body_Stub;
Visitor : in out Program.Element_Visitors.Element_Visitor'Class);
overriding function Name
(Self : Base_Package_Body_Stub)
return not null Program.Elements.Defining_Identifiers
.Defining_Identifier_Access;
overriding function Aspects
(Self : Base_Package_Body_Stub)
return Program.Elements.Aspect_Specifications
.Aspect_Specification_Vector_Access;
overriding function Is_Package_Body_Stub_Element
(Self : Base_Package_Body_Stub)
return Boolean;
overriding function Is_Declaration_Element
(Self : Base_Package_Body_Stub)
return Boolean;
type Package_Body_Stub is
new Base_Package_Body_Stub
and Program.Elements.Package_Body_Stubs.Package_Body_Stub_Text
with record
Package_Token : not null Program.Lexical_Elements
.Lexical_Element_Access;
Body_Token : not null Program.Lexical_Elements
.Lexical_Element_Access;
Is_Token : not null Program.Lexical_Elements
.Lexical_Element_Access;
Separate_Token : not null Program.Lexical_Elements
.Lexical_Element_Access;
With_Token : Program.Lexical_Elements.Lexical_Element_Access;
Semicolon_Token : not null Program.Lexical_Elements
.Lexical_Element_Access;
end record;
overriding function To_Package_Body_Stub_Text
(Self : aliased in out Package_Body_Stub)
return Program.Elements.Package_Body_Stubs.Package_Body_Stub_Text_Access;
overriding function Package_Token
(Self : Package_Body_Stub)
return not null Program.Lexical_Elements.Lexical_Element_Access;
overriding function Body_Token
(Self : Package_Body_Stub)
return not null Program.Lexical_Elements.Lexical_Element_Access;
overriding function Is_Token
(Self : Package_Body_Stub)
return not null Program.Lexical_Elements.Lexical_Element_Access;
overriding function Separate_Token
(Self : Package_Body_Stub)
return not null Program.Lexical_Elements.Lexical_Element_Access;
overriding function With_Token
(Self : Package_Body_Stub)
return Program.Lexical_Elements.Lexical_Element_Access;
overriding function Semicolon_Token
(Self : Package_Body_Stub)
return not null Program.Lexical_Elements.Lexical_Element_Access;
type Implicit_Package_Body_Stub is
new Base_Package_Body_Stub
with record
Is_Part_Of_Implicit : Boolean;
Is_Part_Of_Inherited : Boolean;
Is_Part_Of_Instance : Boolean;
end record;
overriding function To_Package_Body_Stub_Text
(Self : aliased in out Implicit_Package_Body_Stub)
return Program.Elements.Package_Body_Stubs.Package_Body_Stub_Text_Access;
overriding function Is_Part_Of_Implicit
(Self : Implicit_Package_Body_Stub)
return Boolean;
overriding function Is_Part_Of_Inherited
(Self : Implicit_Package_Body_Stub)
return Boolean;
overriding function Is_Part_Of_Instance
(Self : Implicit_Package_Body_Stub)
return Boolean;
end Program.Nodes.Package_Body_Stubs;
|
reznikmm/matreshka | Ada | 3,689 | ads | ------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- Open Document Toolkit --
-- --
-- Runtime Library Component --
-- --
------------------------------------------------------------------------------
-- --
-- Copyright © 2014, Vadim Godunko <[email protected]> --
-- All rights reserved. --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions --
-- are met: --
-- --
-- * Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- --
-- * Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in the --
-- documentation and/or other materials provided with the distribution. --
-- --
-- * Neither the name of the Vadim Godunko, IE nor the names of its --
-- contributors may be used to endorse or promote products derived from --
-- this software without specific prior written permission. --
-- --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR --
-- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
-- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED --
-- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR --
-- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF --
-- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING --
-- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS --
-- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
-- --
------------------------------------------------------------------------------
-- $Revision$ $Date$
------------------------------------------------------------------------------
with XML.DOM.Attributes;
package ODF.DOM.Text_Title_Attributes is
pragma Preelaborate;
type ODF_Text_Title_Attribute is limited interface
and XML.DOM.Attributes.DOM_Attribute;
type ODF_Text_Title_Attribute_Access is
access all ODF_Text_Title_Attribute'Class
with Storage_Size => 0;
end ODF.DOM.Text_Title_Attributes;
|
sungyeon/drake | Ada | 7,380 | ads | pragma License (Unrestricted); -- BSD 3-Clause
-- translated unit from dSFMT
--
-- Copyright (c) 2007, 2008, 2009 Mutsuo Saito, Makoto Matsumoto
-- and Hiroshima University.
-- Copyright (c) 2011, 2002 Mutsuo Saito, Makoto Matsumoto, Hiroshima
-- University and The University of Tokyo.
-- 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 Hiroshima 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 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.
--
-- Ada version: 2018 yt
with Ada.IO_Exceptions;
with Interfaces;
generic
-- Mersenne Exponent. The period of the sequence is a multiple of 2^MEXP-1.
MEXP : Natural;
-- the pick up position of the array.
POS1 : Natural;
-- the parameter of shift left as four 32-bit registers.
SL1 : Natural;
-- A bitmask, used in the recursion. These parameters are introduced to
-- break symmetry of SIMD.
MSK1 : Interfaces.Unsigned_64;
MSK2 : Interfaces.Unsigned_64;
FIX1 : Interfaces.Unsigned_64;
FIX2 : Interfaces.Unsigned_64;
-- These definitions are part of a 128-bit period certification vector.
PCV1 : Interfaces.Unsigned_64;
PCV2 : Interfaces.Unsigned_64;
package Ada.Numerics.dSFMT is
-- Double precision SIMD oriented Fast Mersenne Twister(dSFMT)
-- pseudorandom number generator based on IEEE 754 format.
pragma Preelaborate;
type Long_Float_Array is array (Natural range <>) of Long_Float;
for Long_Float_Array'Alignment use 16;
subtype Unsigned_32 is Interfaces.Unsigned_32;
type Unsigned_32_Array is
array (Natural range <>) of aliased Interfaces.Unsigned_32;
for Unsigned_32_Array'Alignment use 16;
-- Identification string
function Id return String;
DSFMT_MEXP : Natural
renames MEXP;
-- Basic facilities
type Generator is limited private;
function Random_1_To_Less_Than_2 (Gen : aliased in out Generator)
return Long_Float;
function Random_0_To_Less_Than_1 (Gen : aliased in out Generator)
return Long_Float;
function Random_Greater_Than_0_To_1 (Gen : aliased in out Generator)
return Long_Float;
function Random_Greater_Than_0_To_Less_Than_1 (
Gen : aliased in out Generator)
return Long_Float;
pragma Inline (Random_1_To_Less_Than_2);
pragma Inline (Random_0_To_Less_Than_1);
pragma Inline (Random_Greater_Than_0_To_1);
pragma Inline (Random_Greater_Than_0_To_Less_Than_1);
procedure Fill_Random_1_To_Less_Than_2 (
Gen : aliased in out Generator;
Item : out Long_Float_Array);
procedure Fill_Random_0_To_Less_Than_1 (
Gen : aliased in out Generator;
Item : out Long_Float_Array);
procedure Fill_Random_Greater_Than_0_To_1 (
Gen : aliased in out Generator;
Item : out Long_Float_Array);
procedure Fill_Random_Greater_Than_0_To_Less_Than_1 (
Gen : aliased in out Generator;
Item : out Long_Float_Array);
function Initialize return Generator;
function Initialize (Initiator : Unsigned_32) return Generator;
function Initialize (Initiator : Unsigned_32_Array) return Generator;
procedure Reset (Gen : in out Generator);
procedure Reset (Gen : in out Generator; Initiator : Integer);
-- Advanced facilities
type State is private;
pragma Preelaborable_Initialization (State); -- uninitialized
function Initialize return State;
function Initialize (Initiator : Unsigned_32) return State;
function Initialize (Initiator : Unsigned_32_Array) return State;
procedure Save (Gen : Generator; To_State : out State);
procedure Reset (Gen : in out Generator; From_State : State);
function Reset (From_State : State) return Generator;
Max_Image_Width : constant Natural;
function Image (Of_State : State) return String;
function Value (Coded_State : String) return State;
Default_Initiator : constant := 1234; -- test.c
-- This constant means the minimum size of array used for
-- Fill_Random_... procedures.
Min_Array_Length : constant Natural;
-- Exceptions
Use_Error : exception
renames IO_Exceptions.Use_Error;
-- Note: Initialize propagates Use_Error if it failed.
private
pragma Compile_Time_Error (Long_Float'Size /= 64, "Long_Float'Size /= 64");
subtype Unsigned_64 is Interfaces.Unsigned_64;
type Unsigned_64_Array is
array (Natural range <>) of aliased Interfaces.Unsigned_64;
for Unsigned_64_Array'Alignment use 16;
-- the parameters of DSFMT
LOW_MASK : constant := 16#000FFFFFFFFFFFFF#;
HIGH_CONST : constant := 16#3FF0000000000000#;
SR : constant := 12;
-- DSFMT generator has an internal state array of 128-bit integers, and N
-- is its size.
N : constant Natural := (MEXP - 128) / 104 + 1;
-- N32 is the size of internal state array when regarded as an array of
-- 32-bit integers.
N32 : constant Natural := N * 4;
-- N64 is the size of internal state array when regarded as an array of
-- 64-bit integers.
Min_Array_Length : constant Natural := N * 2;
N64 : Natural renames Min_Array_Length;
Max_Image_Width : constant Natural := (N64 + 2) * (64 / 4 + 1) + 32 / 4;
-- 128-bit data type
type w128_t is array (0 .. 1) of Unsigned_64;
for w128_t'Alignment use 16;
pragma Suppress_Initialization (w128_t);
type w128_t_Array is array (Natural range <>) of aliased w128_t
with Convention => Ada_Pass_By_Reference;
pragma Suppress_Initialization (w128_t_Array);
subtype w128_t_Array_1 is w128_t_Array (0 .. 0);
subtype w128_t_Array_N is w128_t_Array (0 .. N - 1);
type State is record
-- the 128-bit internal state array
status : aliased w128_t_Array_N;
lung : aliased w128_t; -- status (N)
idx : Integer;
end record;
pragma Suppress_Initialization (State);
type Generator is limited record
dsfmt : aliased State := Initialize (Default_Initiator);
end record;
end Ada.Numerics.dSFMT;
|
AdaCore/Ada_Drivers_Library | Ada | 4,171 | adb | ------------------------------------------------------------------------------
-- --
-- Copyright (C) 2016, AdaCore --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions are --
-- met: --
-- 1. Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- 2. Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in --
-- the documentation and/or other materials provided with the --
-- distribution. --
-- 3. Neither the name of the copyright holder nor the names of its --
-- contributors may be used to endorse or promote products derived --
-- from this software without specific prior written permission. --
-- --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR --
-- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
-- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT --
-- LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, --
-- DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY --
-- THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT --
-- (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE --
-- OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
-- --
------------------------------------------------------------------------------
package body BNO055_I2C_IO is
----------
-- Read --
----------
procedure Read
(This : Any_IO_Port;
Register : UInt8;
Value : out UInt8)
is
Incoming : I2C_Data (1 .. 1);
Result : I2C_Status;
begin
Mem_Read
(This.Port.all,
This.Device,
Mem_Addr => UInt16 (Register),
Mem_Addr_Size => Memory_Size_8b,
Data => Incoming,
Status => Result);
if Result /= Ok then
raise Program_Error with "I2C read error:" & Result'Img;
end if;
Value := Incoming (1);
end Read;
-----------
-- Write --
-----------
procedure Write
(This : Any_IO_Port;
Register : UInt8;
Value : UInt8)
is
Outgoing : constant I2C_Data (1 .. 1) := (1 => Value);
Result : I2C_Status;
begin
Mem_Write
(This.Port.all,
This.Device,
Mem_Addr => UInt16 (Register),
Mem_Addr_Size => Memory_Size_8b,
Data => Outgoing,
Status => Result);
if Result /= Ok then
raise Program_Error with "I2C write error:" & Result'Img;
end if;
end Write;
-----------------
-- Read_Buffer --
-----------------
procedure Read_Buffer
(This : Any_IO_Port;
Register : UInt8;
Value : out I2C_Data)
is
Result : I2C_Status;
begin
Mem_Read
(This.Port.all,
This.Device,
Mem_Addr => UInt16 (Register),
Mem_Addr_Size => Memory_Size_8b,
Data => Value,
Status => Result);
if Result /= Ok then
raise Program_Error with "I2C read buff error:" & Result'Img;
end if;
end Read_Buffer;
end BNO055_I2C_IO;
|
stcarrez/dynamo | Ada | 4,697 | adb | -----------------------------------------------------------------------
-- gen-model-enums -- Enum definitions
-- Copyright (C) 2011, 2012, 2018, 2021, 2022 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 Gen.Model.Enums is
-- ------------------------------
-- Get the value identified by the name.
-- If the name cannot be found, the method should return the Null object.
-- ------------------------------
overriding
function Get_Value (From : Value_Definition;
Name : String) return UBO.Object is
begin
if Name = "value" then
return UBO.To_Object (From.Number);
else
return Definition (From).Get_Value (Name);
end if;
end Get_Value;
-- ------------------------------
-- Get the value identified by the name.
-- If the name cannot be found, the method should return the Null object.
-- ------------------------------
overriding
function Get_Value (From : Enum_Definition;
Name : String) return UBO.Object is
begin
if Name = "values" then
return From.Values_Bean;
elsif Name = "name" then
return UBO.To_Object (From.Type_Name);
elsif Name = "isEnum" or else Name = "isDiscrete" then
return UBO.To_Object (True);
elsif Name = "sqlType" then
if Length (From.Sql_Type) > 0 then
return UBO.To_Object (Mappings.Get_Type_Name (From.Sql_Type));
else
return UBO.To_Object (Mappings.Get_Type_Name (To_UString ("enum")));
end if;
else
return Mappings.Mapping_Definition (From).Get_Value (Name);
end if;
end Get_Value;
-- ------------------------------
-- Compare two enum literals.
-- ------------------------------
function "<" (Left, Right : in Value_Definition_Access) return Boolean is
begin
return Left.Number < Right.Number;
end "<";
-- ------------------------------
-- Prepare the generation of the model.
-- ------------------------------
overriding
procedure Prepare (O : in out Enum_Definition) is
procedure Sort is new Value_List.Sort_On ("<");
begin
O.Target := O.Type_Name;
Sort (O.Values);
end Prepare;
-- ------------------------------
-- Initialize the table definition instance.
-- ------------------------------
overriding
procedure Initialize (O : in out Enum_Definition) is
begin
O.Values_Bean := UBO.To_Object (O.Values'Unchecked_Access,
UBO.STATIC);
end Initialize;
-- ------------------------------
-- Add an enum value to this enum definition and return the new value.
-- ------------------------------
procedure Add_Value (Enum : in out Enum_Definition;
Name : in String;
Value : out Value_Definition_Access) is
begin
Value := new Value_Definition;
Value.Set_Name (Name);
Value.Number := Enum.Values.Get_Count;
Enum.Values.Append (Value);
end Add_Value;
-- ------------------------------
-- Create an enum with the given name.
-- ------------------------------
function Create_Enum (Name : in UString) return Enum_Definition_Access is
Enum : constant Enum_Definition_Access := new Enum_Definition;
begin
Enum.Set_Name (Name);
declare
use Ada.Strings.Unbounded;
Pos : constant Natural := Index (Enum.Name, ".", Ada.Strings.Backward);
begin
if Pos > 0 then
Enum.Pkg_Name := Unbounded_Slice (Enum.Name, 1, Pos - 1);
Enum.Type_Name := Unbounded_Slice (Enum.Name, Pos + 1, Length (Enum.Name));
Enum.Nullable_Type := "Nullable_" & Enum.Type_Name;
else
Enum.Pkg_Name := To_UString ("ADO");
Enum.Type_Name := Enum.Name;
Enum.Nullable_Type := "Nullable_" & Enum.Name;
end if;
end;
return Enum;
end Create_Enum;
end Gen.Model.Enums;
|
reznikmm/matreshka | Ada | 3,739 | 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.Number_Format_Source_Attributes is
pragma Preelaborate;
type ODF_Number_Format_Source_Attribute is limited interface
and XML.DOM.Attributes.DOM_Attribute;
type ODF_Number_Format_Source_Attribute_Access is
access all ODF_Number_Format_Source_Attribute'Class
with Storage_Size => 0;
end ODF.DOM.Number_Format_Source_Attributes;
|
pdaxrom/Kino2 | Ada | 3,382 | ads | ------------------------------------------------------------------------------
-- --
-- GNAT ncurses Binding Samples --
-- --
-- Sample.Header_Handler --
-- --
-- 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, 1996
-- Contact: http://www.familiepfeifer.de/Contact.aspx?Lang=en
-- Version Control
-- $Revision: 1.8 $
-- Binding Version 01.00
------------------------------------------------------------------------------
with Terminal_Interface.Curses; use Terminal_Interface.Curses;
-- This package handles the painting of the header line of the screen.
--
package Sample.Header_Handler is
procedure Init_Header_Handler;
-- Initialize the handler for the headerlines.
procedure Update_Header_Window;
-- Update the information in the header window
end Sample.Header_Handler;
|
reznikmm/matreshka | Ada | 22,630 | ads | ------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- Ada Modeling Framework --
-- --
-- Runtime Library Component --
-- --
------------------------------------------------------------------------------
-- --
-- Copyright © 2011-2012, Vadim Godunko <[email protected]> --
-- All rights reserved. --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions --
-- are met: --
-- --
-- * Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- --
-- * Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in the --
-- documentation and/or other materials provided with the distribution. --
-- --
-- * Neither the name of the Vadim Godunko, IE nor the names of its --
-- contributors may be used to endorse or promote products derived from --
-- this software without specific prior written permission. --
-- --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR --
-- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
-- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED --
-- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR --
-- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF --
-- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING --
-- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS --
-- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
-- --
------------------------------------------------------------------------------
-- $Revision$ $Date$
------------------------------------------------------------------------------
with AMF.Internals.UML_Named_Elements;
with AMF.UML.Activities;
with AMF.UML.Activity_Edges.Collections;
with AMF.UML.Activity_Groups.Collections;
with AMF.UML.Activity_Nodes.Collections;
with AMF.UML.Activity_Partitions.Collections;
with AMF.UML.Add_Structural_Feature_Value_Actions;
with AMF.UML.Classifiers.Collections;
with AMF.UML.Constraints.Collections;
with AMF.UML.Dependencies.Collections;
with AMF.UML.Exception_Handlers.Collections;
with AMF.UML.Input_Pins.Collections;
with AMF.UML.Interruptible_Activity_Regions.Collections;
with AMF.UML.Named_Elements;
with AMF.UML.Namespaces;
with AMF.UML.Output_Pins.Collections;
with AMF.UML.Packages.Collections;
with AMF.UML.Redefinable_Elements.Collections;
with AMF.UML.String_Expressions;
with AMF.UML.Structural_Features;
with AMF.UML.Structured_Activity_Nodes;
with AMF.Visitors;
package AMF.Internals.UML_Add_Structural_Feature_Value_Actions is
type UML_Add_Structural_Feature_Value_Action_Proxy is
limited new AMF.Internals.UML_Named_Elements.UML_Named_Element_Proxy
and AMF.UML.Add_Structural_Feature_Value_Actions.UML_Add_Structural_Feature_Value_Action with null record;
overriding function Get_Insert_At
(Self : not null access constant UML_Add_Structural_Feature_Value_Action_Proxy)
return AMF.UML.Input_Pins.UML_Input_Pin_Access;
-- Getter of AddStructuralFeatureValueAction::insertAt.
--
-- Gives the position at which to insert a new value or move an existing
-- value in ordered structural features. The type of the pin is
-- UnlimitedNatural, but the value cannot be zero. This pin is omitted for
-- unordered structural features.
overriding procedure Set_Insert_At
(Self : not null access UML_Add_Structural_Feature_Value_Action_Proxy;
To : AMF.UML.Input_Pins.UML_Input_Pin_Access);
-- Setter of AddStructuralFeatureValueAction::insertAt.
--
-- Gives the position at which to insert a new value or move an existing
-- value in ordered structural features. The type of the pin is
-- UnlimitedNatural, but the value cannot be zero. This pin is omitted for
-- unordered structural features.
overriding function Get_Is_Replace_All
(Self : not null access constant UML_Add_Structural_Feature_Value_Action_Proxy)
return Boolean;
-- Getter of AddStructuralFeatureValueAction::isReplaceAll.
--
-- Specifies whether existing values of the structural feature of the
-- object should be removed before adding the new value.
overriding procedure Set_Is_Replace_All
(Self : not null access UML_Add_Structural_Feature_Value_Action_Proxy;
To : Boolean);
-- Setter of AddStructuralFeatureValueAction::isReplaceAll.
--
-- Specifies whether existing values of the structural feature of the
-- object should be removed before adding the new value.
overriding function Get_Result
(Self : not null access constant UML_Add_Structural_Feature_Value_Action_Proxy)
return AMF.UML.Output_Pins.UML_Output_Pin_Access;
-- Getter of WriteStructuralFeatureAction::result.
--
-- Gives the output pin on which the result is put.
overriding procedure Set_Result
(Self : not null access UML_Add_Structural_Feature_Value_Action_Proxy;
To : AMF.UML.Output_Pins.UML_Output_Pin_Access);
-- Setter of WriteStructuralFeatureAction::result.
--
-- Gives the output pin on which the result is put.
overriding function Get_Value
(Self : not null access constant UML_Add_Structural_Feature_Value_Action_Proxy)
return AMF.UML.Input_Pins.UML_Input_Pin_Access;
-- Getter of WriteStructuralFeatureAction::value.
--
-- Value to be added or removed from the structural feature.
overriding procedure Set_Value
(Self : not null access UML_Add_Structural_Feature_Value_Action_Proxy;
To : AMF.UML.Input_Pins.UML_Input_Pin_Access);
-- Setter of WriteStructuralFeatureAction::value.
--
-- Value to be added or removed from the structural feature.
overriding function Get_Object
(Self : not null access constant UML_Add_Structural_Feature_Value_Action_Proxy)
return AMF.UML.Input_Pins.UML_Input_Pin_Access;
-- Getter of StructuralFeatureAction::object.
--
-- Gives the input pin from which the object whose structural feature is
-- to be read or written is obtained.
overriding procedure Set_Object
(Self : not null access UML_Add_Structural_Feature_Value_Action_Proxy;
To : AMF.UML.Input_Pins.UML_Input_Pin_Access);
-- Setter of StructuralFeatureAction::object.
--
-- Gives the input pin from which the object whose structural feature is
-- to be read or written is obtained.
overriding function Get_Structural_Feature
(Self : not null access constant UML_Add_Structural_Feature_Value_Action_Proxy)
return AMF.UML.Structural_Features.UML_Structural_Feature_Access;
-- Getter of StructuralFeatureAction::structuralFeature.
--
-- Structural feature to be read.
overriding procedure Set_Structural_Feature
(Self : not null access UML_Add_Structural_Feature_Value_Action_Proxy;
To : AMF.UML.Structural_Features.UML_Structural_Feature_Access);
-- Setter of StructuralFeatureAction::structuralFeature.
--
-- Structural feature to be read.
overriding function Get_Context
(Self : not null access constant UML_Add_Structural_Feature_Value_Action_Proxy)
return AMF.UML.Classifiers.UML_Classifier_Access;
-- Getter of Action::context.
--
-- The classifier that owns the behavior of which this action is a part.
overriding function Get_Input
(Self : not null access constant UML_Add_Structural_Feature_Value_Action_Proxy)
return AMF.UML.Input_Pins.Collections.Ordered_Set_Of_UML_Input_Pin;
-- Getter of Action::input.
--
-- The ordered set of input pins connected to the Action. These are among
-- the total set of inputs.
overriding function Get_Is_Locally_Reentrant
(Self : not null access constant UML_Add_Structural_Feature_Value_Action_Proxy)
return Boolean;
-- Getter of Action::isLocallyReentrant.
--
-- If true, the action can begin a new, concurrent execution, even if
-- there is already another execution of the action ongoing. If false, the
-- action cannot begin a new execution until any previous execution has
-- completed.
overriding procedure Set_Is_Locally_Reentrant
(Self : not null access UML_Add_Structural_Feature_Value_Action_Proxy;
To : Boolean);
-- Setter of Action::isLocallyReentrant.
--
-- If true, the action can begin a new, concurrent execution, even if
-- there is already another execution of the action ongoing. If false, the
-- action cannot begin a new execution until any previous execution has
-- completed.
overriding function Get_Local_Postcondition
(Self : not null access constant UML_Add_Structural_Feature_Value_Action_Proxy)
return AMF.UML.Constraints.Collections.Set_Of_UML_Constraint;
-- Getter of Action::localPostcondition.
--
-- Constraint that must be satisfied when executed is completed.
overriding function Get_Local_Precondition
(Self : not null access constant UML_Add_Structural_Feature_Value_Action_Proxy)
return AMF.UML.Constraints.Collections.Set_Of_UML_Constraint;
-- Getter of Action::localPrecondition.
--
-- Constraint that must be satisfied when execution is started.
overriding function Get_Output
(Self : not null access constant UML_Add_Structural_Feature_Value_Action_Proxy)
return AMF.UML.Output_Pins.Collections.Ordered_Set_Of_UML_Output_Pin;
-- Getter of Action::output.
--
-- The ordered set of output pins connected to the Action. The action
-- places its results onto pins in this set.
overriding function Get_Handler
(Self : not null access constant UML_Add_Structural_Feature_Value_Action_Proxy)
return AMF.UML.Exception_Handlers.Collections.Set_Of_UML_Exception_Handler;
-- Getter of ExecutableNode::handler.
--
-- A set of exception handlers that are examined if an uncaught exception
-- propagates to the outer level of the executable node.
overriding function Get_Activity
(Self : not null access constant UML_Add_Structural_Feature_Value_Action_Proxy)
return AMF.UML.Activities.UML_Activity_Access;
-- Getter of ActivityNode::activity.
--
-- Activity containing the node.
overriding procedure Set_Activity
(Self : not null access UML_Add_Structural_Feature_Value_Action_Proxy;
To : AMF.UML.Activities.UML_Activity_Access);
-- Setter of ActivityNode::activity.
--
-- Activity containing the node.
overriding function Get_In_Group
(Self : not null access constant UML_Add_Structural_Feature_Value_Action_Proxy)
return AMF.UML.Activity_Groups.Collections.Set_Of_UML_Activity_Group;
-- Getter of ActivityNode::inGroup.
--
-- Groups containing the node.
overriding function Get_In_Interruptible_Region
(Self : not null access constant UML_Add_Structural_Feature_Value_Action_Proxy)
return AMF.UML.Interruptible_Activity_Regions.Collections.Set_Of_UML_Interruptible_Activity_Region;
-- Getter of ActivityNode::inInterruptibleRegion.
--
-- Interruptible regions containing the node.
overriding function Get_In_Partition
(Self : not null access constant UML_Add_Structural_Feature_Value_Action_Proxy)
return AMF.UML.Activity_Partitions.Collections.Set_Of_UML_Activity_Partition;
-- Getter of ActivityNode::inPartition.
--
-- Partitions containing the node.
overriding function Get_In_Structured_Node
(Self : not null access constant UML_Add_Structural_Feature_Value_Action_Proxy)
return AMF.UML.Structured_Activity_Nodes.UML_Structured_Activity_Node_Access;
-- Getter of ActivityNode::inStructuredNode.
--
-- Structured activity node containing the node.
overriding procedure Set_In_Structured_Node
(Self : not null access UML_Add_Structural_Feature_Value_Action_Proxy;
To : AMF.UML.Structured_Activity_Nodes.UML_Structured_Activity_Node_Access);
-- Setter of ActivityNode::inStructuredNode.
--
-- Structured activity node containing the node.
overriding function Get_Incoming
(Self : not null access constant UML_Add_Structural_Feature_Value_Action_Proxy)
return AMF.UML.Activity_Edges.Collections.Set_Of_UML_Activity_Edge;
-- Getter of ActivityNode::incoming.
--
-- Edges that have the node as target.
overriding function Get_Outgoing
(Self : not null access constant UML_Add_Structural_Feature_Value_Action_Proxy)
return AMF.UML.Activity_Edges.Collections.Set_Of_UML_Activity_Edge;
-- Getter of ActivityNode::outgoing.
--
-- Edges that have the node as source.
overriding function Get_Redefined_Node
(Self : not null access constant UML_Add_Structural_Feature_Value_Action_Proxy)
return AMF.UML.Activity_Nodes.Collections.Set_Of_UML_Activity_Node;
-- Getter of ActivityNode::redefinedNode.
--
-- Inherited nodes replaced by this node in a specialization of the
-- activity.
overriding function Get_Is_Leaf
(Self : not null access constant UML_Add_Structural_Feature_Value_Action_Proxy)
return Boolean;
-- Getter of RedefinableElement::isLeaf.
--
-- Indicates whether it is possible to further redefine a
-- RedefinableElement. If the value is true, then it is not possible to
-- further redefine the RedefinableElement. Note that this property is
-- preserved through package merge operations; that is, the capability to
-- redefine a RedefinableElement (i.e., isLeaf=false) must be preserved in
-- the resulting RedefinableElement of a package merge operation where a
-- RedefinableElement with isLeaf=false is merged with a matching
-- RedefinableElement with isLeaf=true: the resulting RedefinableElement
-- will have isLeaf=false. Default value is false.
overriding procedure Set_Is_Leaf
(Self : not null access UML_Add_Structural_Feature_Value_Action_Proxy;
To : Boolean);
-- Setter of RedefinableElement::isLeaf.
--
-- Indicates whether it is possible to further redefine a
-- RedefinableElement. If the value is true, then it is not possible to
-- further redefine the RedefinableElement. Note that this property is
-- preserved through package merge operations; that is, the capability to
-- redefine a RedefinableElement (i.e., isLeaf=false) must be preserved in
-- the resulting RedefinableElement of a package merge operation where a
-- RedefinableElement with isLeaf=false is merged with a matching
-- RedefinableElement with isLeaf=true: the resulting RedefinableElement
-- will have isLeaf=false. Default value is false.
overriding function Get_Redefined_Element
(Self : not null access constant UML_Add_Structural_Feature_Value_Action_Proxy)
return AMF.UML.Redefinable_Elements.Collections.Set_Of_UML_Redefinable_Element;
-- Getter of RedefinableElement::redefinedElement.
--
-- The redefinable element that is being redefined by this element.
overriding function Get_Redefinition_Context
(Self : not null access constant UML_Add_Structural_Feature_Value_Action_Proxy)
return AMF.UML.Classifiers.Collections.Set_Of_UML_Classifier;
-- Getter of RedefinableElement::redefinitionContext.
--
-- References the contexts that this element may be redefined from.
overriding function Get_Client_Dependency
(Self : not null access constant UML_Add_Structural_Feature_Value_Action_Proxy)
return AMF.UML.Dependencies.Collections.Set_Of_UML_Dependency;
-- Getter of NamedElement::clientDependency.
--
-- Indicates the dependencies that reference the client.
overriding function Get_Name_Expression
(Self : not null access constant UML_Add_Structural_Feature_Value_Action_Proxy)
return AMF.UML.String_Expressions.UML_String_Expression_Access;
-- Getter of NamedElement::nameExpression.
--
-- The string expression used to define the name of this named element.
overriding procedure Set_Name_Expression
(Self : not null access UML_Add_Structural_Feature_Value_Action_Proxy;
To : AMF.UML.String_Expressions.UML_String_Expression_Access);
-- Setter of NamedElement::nameExpression.
--
-- The string expression used to define the name of this named element.
overriding function Get_Namespace
(Self : not null access constant UML_Add_Structural_Feature_Value_Action_Proxy)
return AMF.UML.Namespaces.UML_Namespace_Access;
-- Getter of NamedElement::namespace.
--
-- Specifies the namespace that owns the NamedElement.
overriding function Get_Qualified_Name
(Self : not null access constant UML_Add_Structural_Feature_Value_Action_Proxy)
return AMF.Optional_String;
-- Getter of NamedElement::qualifiedName.
--
-- A name which allows the NamedElement to be identified within a
-- hierarchy of nested Namespaces. It is constructed from the names of the
-- containing namespaces starting at the root of the hierarchy and ending
-- with the name of the NamedElement itself.
overriding function Context
(Self : not null access constant UML_Add_Structural_Feature_Value_Action_Proxy)
return AMF.UML.Classifiers.UML_Classifier_Access;
-- Operation Action::context.
--
-- Missing derivation for Action::/context : Classifier
overriding function Is_Consistent_With
(Self : not null access constant UML_Add_Structural_Feature_Value_Action_Proxy;
Redefinee : AMF.UML.Redefinable_Elements.UML_Redefinable_Element_Access)
return Boolean;
-- Operation RedefinableElement::isConsistentWith.
--
-- The query isConsistentWith() specifies, for any two RedefinableElements
-- in a context in which redefinition is possible, whether redefinition
-- would be logically consistent. By default, this is false; this
-- operation must be overridden for subclasses of RedefinableElement to
-- define the consistency conditions.
overriding function Is_Redefinition_Context_Valid
(Self : not null access constant UML_Add_Structural_Feature_Value_Action_Proxy;
Redefined : AMF.UML.Redefinable_Elements.UML_Redefinable_Element_Access)
return Boolean;
-- Operation RedefinableElement::isRedefinitionContextValid.
--
-- The query isRedefinitionContextValid() specifies whether the
-- redefinition contexts of this RedefinableElement are properly related
-- to the redefinition contexts of the specified RedefinableElement to
-- allow this element to redefine the other. By default at least one of
-- the redefinition contexts of this element must be a specialization of
-- at least one of the redefinition contexts of the specified element.
overriding function All_Owning_Packages
(Self : not null access constant UML_Add_Structural_Feature_Value_Action_Proxy)
return AMF.UML.Packages.Collections.Set_Of_UML_Package;
-- Operation NamedElement::allOwningPackages.
--
-- The query allOwningPackages() returns all the directly or indirectly
-- owning packages.
overriding function Is_Distinguishable_From
(Self : not null access constant UML_Add_Structural_Feature_Value_Action_Proxy;
N : AMF.UML.Named_Elements.UML_Named_Element_Access;
Ns : AMF.UML.Namespaces.UML_Namespace_Access)
return Boolean;
-- Operation NamedElement::isDistinguishableFrom.
--
-- The query isDistinguishableFrom() determines whether two NamedElements
-- may logically co-exist within a Namespace. By default, two named
-- elements are distinguishable if (a) they have unrelated types or (b)
-- they have related types but different names.
overriding function Namespace
(Self : not null access constant UML_Add_Structural_Feature_Value_Action_Proxy)
return AMF.UML.Namespaces.UML_Namespace_Access;
-- Operation NamedElement::namespace.
--
-- Missing derivation for NamedElement::/namespace : Namespace
overriding procedure Enter_Element
(Self : not null access constant UML_Add_Structural_Feature_Value_Action_Proxy;
Visitor : in out AMF.Visitors.Abstract_Visitor'Class;
Control : in out AMF.Visitors.Traverse_Control);
-- Dispatch call to corresponding subprogram of visitor interface.
overriding procedure Leave_Element
(Self : not null access constant UML_Add_Structural_Feature_Value_Action_Proxy;
Visitor : in out AMF.Visitors.Abstract_Visitor'Class;
Control : in out AMF.Visitors.Traverse_Control);
-- Dispatch call to corresponding subprogram of visitor interface.
overriding procedure Visit_Element
(Self : not null access constant UML_Add_Structural_Feature_Value_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);
-- Dispatch call to corresponding subprogram of iterator interface.
end AMF.Internals.UML_Add_Structural_Feature_Value_Actions;
|
reznikmm/matreshka | Ada | 4,755 | 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.Presentation_Show_Elements;
package Matreshka.ODF_Presentation.Show_Elements is
type Presentation_Show_Element_Node is
new Matreshka.ODF_Presentation.Abstract_Presentation_Element_Node
and ODF.DOM.Presentation_Show_Elements.ODF_Presentation_Show
with null record;
overriding function Create
(Parameters : not null access Matreshka.DOM_Elements.Element_L2_Parameters)
return Presentation_Show_Element_Node;
overriding function Get_Local_Name
(Self : not null access constant Presentation_Show_Element_Node)
return League.Strings.Universal_String;
overriding procedure Enter_Node
(Self : not null access Presentation_Show_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 Presentation_Show_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 Presentation_Show_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_Presentation.Show_Elements;
|
stcarrez/ada-util | Ada | 7,718 | adb | -----------------------------------------------------------------------
-- util-serialize-io-form-tests -- Unit tests for form parser
-- Copyright (C) 2018, 2021 Stephane Carrez
-- Written by Stephane Carrez ([email protected])
--
-- Licensed under the Apache License, Version 2.0 (the "License");
-- you may not use this file except in compliance with the License.
-- You may obtain a copy of the License at
--
-- http://www.apache.org/licenses/LICENSE-2.0
--
-- Unless required by applicable law or agreed to in writing, software
-- distributed under the License is distributed on an "AS IS" BASIS,
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-- See the License for the specific language governing permissions and
-- limitations under the License.
-----------------------------------------------------------------------
with Ada.Streams.Stream_IO;
with Ada.Characters.Wide_Wide_Latin_1;
with Ada.Calendar.Formatting;
with Util.Test_Caller;
with Util.Log.Loggers;
with Util.Streams.Files;
with Util.Beans.Objects.Readers;
package body Util.Serialize.IO.Form.Tests is
use Util.Log;
Log : constant Loggers.Logger := Loggers.Create ("Util.Serialize.IO.Form");
package Caller is new Util.Test_Caller (Test, "Serialize.IO.Form");
procedure Add_Tests (Suite : in Util.Tests.Access_Test_Suite) is
begin
Caller.Add_Test (Suite, "Test Util.Serialize.IO.Form.Parse (parse errors)",
Test_Parse_Error'Access);
Caller.Add_Test (Suite, "Test Util.Serialize.IO.Form.Parse (parse Ok)",
Test_Parser'Access);
Caller.Add_Test (Suite, "Test Util.Serialize.IO.Form.Write",
Test_Output'Access);
Caller.Add_Test (Suite, "Test Util.Serialize.IO.Form.Read",
Test_Read'Access);
end Add_Tests;
-- ------------------------------
-- Check various form parsing errors.
-- ------------------------------
procedure Test_Parse_Error (T : in out Test) is
procedure Check_Parse_Error (Content : in String);
procedure Check_Parse_Error (Content : in String) is
P : Parser;
R : Util.Beans.Objects.Readers.Reader;
begin
P.Parse_String (Content, R);
T.Assert (P.Has_Error, "No error detected for '" & Content & "'");
end Check_Parse_Error;
begin
Check_Parse_Error ("bad");
Check_Parse_Error ("bad=%rw%ad");
end Test_Parse_Error;
-- ------------------------------
-- Check various (basic) JSformON valid strings (no mapper).
-- ------------------------------
procedure Test_Parser (T : in out Test) is
procedure Check_Parse (Content : in String);
procedure Check_Parse (Content : in String) is
P : Parser;
R : Util.Beans.Objects.Readers.Reader;
begin
P.Parse_String (Content, R);
exception
when Parse_Error =>
Log.Error ("Parse error for: " & Content);
T.Fail ("Parse error for: " & Content);
end Check_Parse;
begin
Check_Parse ("name=value");
Check_Parse ("name=value¶m=value");
Check_Parse ("name+name=value+value");
Check_Parse ("name%20%30=value%23%ce");
end Test_Parser;
-- ------------------------------
-- Generate some output stream for the test.
-- ------------------------------
procedure Write_Stream (Stream : in out Util.Serialize.IO.Output_Stream'Class) is
Name : Ada.Strings.Unbounded.Unbounded_String;
Wide : constant Wide_Wide_String :=
Ada.Characters.Wide_Wide_Latin_1.CR &
Ada.Characters.Wide_Wide_Latin_1.LF &
Ada.Characters.Wide_Wide_Latin_1.HT &
Wide_Wide_Character'Val (16#080#) &
Wide_Wide_Character'Val (16#1fC#) &
Wide_Wide_Character'Val (16#20AC#) & -- Euro sign
Wide_Wide_Character'Val (16#2acbf#);
T : constant Ada.Calendar.Time := Ada.Calendar.Formatting.Time_Of (2011, 11, 19, 23, 0, 0);
begin
Ada.Strings.Unbounded.Append (Name, "Katniss Everdeen");
Stream.Start_Document;
Stream.Start_Entity ("root");
Stream.Start_Entity ("person");
Stream.Write_Attribute ("id", 1);
Stream.Write_Attribute ("name", Name);
Stream.Write_Entity ("name", Name);
Stream.Write_Entity ("gender", "female");
Stream.Write_Entity ("volunteer", True);
Stream.Write_Entity ("age", 17);
Stream.Write_Entity ("date", T);
Stream.Write_Wide_Entity ("skin", "olive skin");
Stream.Start_Array ("badges");
Stream.Start_Entity ("badge");
Stream.Write_Entity ("level", "gold");
Stream.Write_Entity ("name", "hunter");
Stream.End_Entity ("badge");
Stream.Start_Entity ("badge");
Stream.Write_Entity ("level", "gold");
Stream.Write_Entity ("name", "archery");
Stream.End_Entity ("badge");
Stream.End_Array ("badges");
Stream.Start_Entity ("district");
Stream.Write_Attribute ("id", 12);
Stream.Write_Wide_Attribute ("industry", "Coal mining");
Stream.Write_Attribute ("state", "<destroyed>");
Stream.Write_Long_Entity ("members", 10_000);
Stream.Write_Entity ("description", "<TBW>&""");
Stream.Write_Wide_Entity ("wescape", "'""<>&;,@!`~[]{}^%*()-+=");
Stream.Write_Entity ("escape", "'""<>&;,@!`~\[]{}^%*()-+=");
Stream.Write_Wide_Entity ("wide", Wide);
Stream.End_Entity ("district");
Stream.End_Entity ("person");
Stream.End_Entity ("root");
Stream.End_Document;
end Write_Stream;
-- ------------------------------
-- Test the JSON output stream generation.
-- ------------------------------
procedure Test_Output (T : in out Test) is
File : aliased Util.Streams.Files.File_Stream;
Buffer : aliased Util.Streams.Texts.Print_Stream;
Stream : Util.Serialize.IO.Form.Output_Stream;
Expect : constant String := Util.Tests.Get_Path ("regtests/expect/test-stream.form");
Path : constant String := Util.Tests.Get_Test_Path ("test-stream.form");
begin
File.Create (Mode => Ada.Streams.Stream_IO.Out_File, Name => Path);
Buffer.Initialize (Output => File'Unchecked_Access, Size => 10000);
Stream.Initialize (Output => Buffer'Unchecked_Access);
Write_Stream (Stream);
Stream.Close;
Util.Tests.Assert_Equal_Files (T => T,
Expect => Expect,
Test => Path,
Message => "Form output serialization");
end Test_Output;
-- ------------------------------
-- Test reading a form content into an Object tree.
-- ------------------------------
procedure Test_Read (T : in out Test) is
Path : constant String := Util.Tests.Get_Path ("regtests/files/pass-01.form");
Root : Util.Beans.Objects.Object;
Value : Util.Beans.Objects.Object;
begin
Root := Read (Path);
T.Assert (not Util.Beans.Objects.Is_Null (Root), "Read should not return null object");
T.Assert (not Util.Beans.Objects.Is_Array (Root), "Root object is not an array");
Value := Util.Beans.Objects.Get_Value (Root, "home");
Util.Tests.Assert_Equals (T, "Cosby",
Util.Beans.Objects.To_String (Value),
"Invalid first parameter");
Value := Util.Beans.Objects.Get_Value (Root, "favorite flavor");
Util.Tests.Assert_Equals (T, "flies",
Util.Beans.Objects.To_String (Value),
"Invalid second parameter");
end Test_Read;
end Util.Serialize.IO.Form.Tests;
|
persan/AdaYaml | Ada | 6,230 | adb | -- part of AdaYaml, (c) 2017 Felix Krause
-- released under the terms of the MIT license, see the file "copying.txt"
package body Yaml.Presenter.Analysis is
function Features (S : String) return Scalar_Features is
Pos : Positive := S'First;
Cur : Character;
Cur_Word_Length : Natural := 0;
Cur_Line_Length : Natural := 0;
-- states
procedure Read_Beginning (Ret : out Scalar_Features) is
begin
if S'Length = 0 then
Ret := (Max_Word_Length => 0, Max_Line_Length => 0,
Single_Line_Length => 0, Quoting_Needed => Single,
Unquoted_Single_Line => True, Folding_Possible => True,
Contains_Non_Printable => False,
Leading_Spaces => 0, Trailing_Linefeeds => 0);
else
Ret := (Max_Word_Length => 0,
Max_Line_Length => 0,
Single_Line_Length => 0,
Quoting_Needed => None,
Unquoted_Single_Line => True,
Folding_Possible => True,
Contains_Non_Printable => False,
Leading_Spaces => 0,
Trailing_Linefeeds => 0);
Cur := S (Pos);
if Cur = ' ' then
Ret.Quoting_Needed := Single;
loop
Ret.Leading_Spaces := Ret.Leading_Spaces + 1;
Cur_Word_Length := Cur_Word_Length + 1;
Cur_Line_Length := Cur_Line_Length + 1;
Pos := Pos + 1;
exit when Pos > S'Last;
Cur := S (Pos);
exit when Cur /= ' ';
end loop;
end if;
end if;
end Read_Beginning;
procedure Read_Word (Ret : in out Scalar_Features) is
begin
if Cur = '#' then
Ret.Quoting_Needed :=
Necessary_Quoting'Max (Ret.Quoting_Needed, Single);
Ret.Unquoted_Single_Line := False;
end if;
loop
case Cur is
when ':' =>
Ret.Single_Line_Length := Ret.Single_Line_Length + 1;
if Pos < S'Last and then S (Pos + 1) = ' ' then
Ret.Quoting_Needed :=
Necessary_Quoting'Max (Ret.Quoting_Needed, Single);
Ret.Unquoted_Single_Line := False;
Pos := Pos + 1;
return;
end if;
when Character'Val (7) .. Character'Val (9) =>
Ret.Quoting_Needed := Double;
Ret.Single_Line_Length := Ret.Single_Line_Length + 2;
Ret.Contains_Non_Printable := True;
when '"' =>
if Pos = S'First then
Ret.Quoting_Needed :=
Necessary_Quoting'Max (Ret.Quoting_Needed, Single);
Ret.Single_Line_Length := Ret.Single_Line_Length + 2;
Ret.Unquoted_Single_Line := False;
else
Ret.Single_Line_Length := Ret.Single_Line_Length + 1;
end if;
when others =>
Ret.Single_Line_Length := Ret.Single_Line_Length + 1;
end case;
Pos := Pos + 1;
exit when Pos > S'Last;
Cur := S (Pos);
exit when Cur in ' ' | Character'Val (10);
Cur_Word_Length := Cur_Word_Length + 1;
Cur_Line_Length := Cur_Line_Length + 1;
end loop;
end Read_Word;
procedure Read_Newlines (Ret : in out Scalar_Features) is
begin
Ret.Max_Line_Length :=
Natural'Max (Ret.Max_Line_Length, Cur_Line_Length);
Cur_Line_Length := 0;
Ret.Max_Word_Length :=
Natural'Max (Ret.Max_Word_Length, Cur_Word_Length);
Cur_Word_Length := 0;
loop
Ret.Trailing_Linefeeds := Ret.Trailing_Linefeeds + 1;
Pos := Pos + 1;
exit when Pos > S'Last;
Cur := S (Pos);
exit when Cur /= Character'Val (10);
end loop;
if Pos <= S'Last then
Ret.Trailing_Linefeeds := 0;
end if;
end Read_Newlines;
procedure Read_Space_After_Word (Ret : in out Scalar_Features) is
begin
Cur_Line_Length := Cur_Line_Length + 1;
Ret.Single_Line_Length := Ret.Single_Line_Length + 1;
Pos := Pos + 1;
if Pos > S'Last then
Ret.Quoting_Needed :=
Necessary_Quoting'Max (Ret.Quoting_Needed, Single);
Ret.Unquoted_Single_Line := False;
Cur_Word_Length := Cur_Word_Length + 1;
Cur_Line_Length := Cur_Line_Length + 1;
return;
end if;
Cur := S (Pos);
if Cur in ' ' | Character'Val (10) then
Cur_Word_Length := Cur_Word_Length + 1;
while Cur = ' ' loop
Cur_Word_Length := Cur_Word_Length + 1;
Cur_Line_Length := Cur_Line_Length + 1;
Ret.Single_Line_Length := Ret.Single_Line_Length + 1;
Pos := Pos + 1;
exit when Pos > S'Last;
end loop;
else
Ret.Max_Word_Length :=
Natural'Max (Ret.Max_Word_Length, Cur_Word_Length);
Cur_Word_Length := 0;
end if;
end Read_Space_After_Word;
begin
return Ret : Scalar_Features do
Read_Beginning (Ret);
if Pos <= S'Last then
loop
Read_Word (Ret);
exit when Pos > S'Last;
loop
case Cur is
when ' ' => Read_Space_After_Word (Ret);
when Character'Val (10) => Read_Newlines (Ret);
when others => null; -- never happens
end case;
exit when Pos > S'Last or else
not (Cur in ' ' | Character'Val (10));
end loop;
exit when Pos > S'Last;
end loop;
end if;
end return;
end Features;
end Yaml.Presenter.Analysis;
|
stcarrez/helios | Ada | 2,227 | ads | -----------------------------------------------------------------------
-- helios-monitor-cpu -- Linux CPU monitor
-- Copyright (C) 2017 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 Helios.Monitor.CPU is
type Agent_Type is new Helios.Monitor.Agent_Type with record
User_Time : Schemas.Definition_Type_Access;
Nice_Time : Schemas.Definition_Type_Access;
Sys_Time : Schemas.Definition_Type_Access;
Idle_Time : Schemas.Definition_Type_Access;
Iowait_Time : Schemas.Definition_Type_Access;
Irq_Time : Schemas.Definition_Type_Access;
Softirq_Time : Schemas.Definition_Type_Access;
Steal_Time : Schemas.Definition_Type_Access;
Guest_Time : Schemas.Definition_Type_Access;
Guest_Nice_Time : Schemas.Definition_Type_Access;
Ctx_Count : Schemas.Definition_Type_Access;
Softirq_Count : Schemas.Definition_Type_Access;
Processes_Count : Schemas.Definition_Type_Access;
Running_Count : Schemas.Definition_Type_Access;
Blocked_Count : Schemas.Definition_Type_Access;
Intr_Count : Schemas.Definition_Type_Access;
end record;
-- Start the agent and build the definition tree.
overriding
procedure Start (Agent : in out Agent_Type;
Config : in Util.Properties.Manager);
-- Collect the values in the snapshot.
overriding
procedure Collect (Agent : in out Agent_Type;
Values : in out Datas.Snapshot_Type);
end Helios.Monitor.CPU;
|
apple-oss-distributions/old_ncurses | Ada | 3,853 | adb | ------------------------------------------------------------------------------
-- --
-- GNAT ncurses Binding --
-- --
-- Terminal_Interface.Curses.Forms.Field_Types.IPV4_Address --
-- --
-- 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.1.1.1 $
-- Binding Version 01.00
------------------------------------------------------------------------------
with Interfaces.C;
with Terminal_Interface.Curses.Aux; use Terminal_Interface.Curses.Aux;
package body Terminal_Interface.Curses.Forms.Field_Types.IPV4_Address is
use type Interfaces.C.int;
procedure Set_Field_Type (Fld : in Field;
Typ : in Internet_V4_Address_Field)
is
C_IPV4_Field_Type : C_Field_Type;
pragma Import (C, C_IPV4_Field_Type, "TYPE_IPV4");
function Set_Fld_Type (F : Field := Fld;
Cft : C_Field_Type := C_IPV4_Field_Type)
return C_Int;
pragma Import (C, Set_Fld_Type, "set_field_type");
Res : Eti_Error;
begin
Res := Set_Fld_Type;
if Res /= E_Ok then
Eti_Exception (Res);
end if;
Wrap_Builtin (Fld, Typ);
end Set_Field_Type;
end Terminal_Interface.Curses.Forms.Field_Types.IPV4_Address;
|
reznikmm/matreshka | Ada | 3,597 | ads | ------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- Ada Modeling Framework --
-- --
-- Runtime Library Component --
-- --
------------------------------------------------------------------------------
-- --
-- Copyright © 2011-2012, Vadim Godunko <[email protected]> --
-- All rights reserved. --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions --
-- are met: --
-- --
-- * Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- --
-- * Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in the --
-- documentation and/or other materials provided with the distribution. --
-- --
-- * Neither the name of the Vadim Godunko, IE nor the names of its --
-- contributors may be used to endorse or promote products derived from --
-- this software without specific prior written permission. --
-- --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR --
-- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
-- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED --
-- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR --
-- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF --
-- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING --
-- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS --
-- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
-- --
------------------------------------------------------------------------------
-- $Revision$ $Date$
------------------------------------------------------------------------------
-- This file is generated, don't edit it.
------------------------------------------------------------------------------
with AMF.Elements.Generic_Hash;
function AMF.UML.Triggers.Hash is
new AMF.Elements.Generic_Hash (UML_Trigger, UML_Trigger_Access);
|
reznikmm/matreshka | Ada | 3,853 | ads | ------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- Web Framework --
-- --
-- Runtime Library Component --
-- --
------------------------------------------------------------------------------
-- --
-- Copyright © 2014, Vadim Godunko <[email protected]> --
-- All rights reserved. --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions --
-- are met: --
-- --
-- * Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- --
-- * Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in the --
-- documentation and/or other materials provided with the distribution. --
-- --
-- * Neither the name of the Vadim Godunko, IE nor the names of its --
-- contributors may be used to endorse or promote products derived from --
-- this software without specific prior written permission. --
-- --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR --
-- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
-- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED --
-- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR --
-- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF --
-- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING --
-- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS --
-- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
-- --
------------------------------------------------------------------------------
-- $Revision$ $Date$
------------------------------------------------------------------------------
package Servlet.Async_Listeners is
pragma Preelaborate;
type Async_Listener is limited interface;
not overriding procedure On_Complete
(Self : not null access Async_Listener) is null;
not overriding procedure On_Error
(Self : not null access Async_Listener) is null;
not overriding procedure On_Start_Async
(Self : not null access Async_Listener) is null;
not overriding procedure On_Timeout
(Self : not null access Async_Listener) is null;
end Servlet.Async_Listeners;
|
vpodzime/ada-util | Ada | 16,572 | adb | -----------------------------------------------------------------------
-- properties -- Generic name/value property management
-- Copyright (C) 2001 - 2017 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.Unchecked_Deallocation;
with Ada.Unchecked_Conversion;
with Ada.Directories;
with Ada.Containers.Vectors;
with Ada.Strings.Fixed;
with Util.Log.Loggers;
with Util.Files;
package body Util.Properties.Bundles is
Log : constant Util.Log.Loggers.Logger := Util.Log.Loggers.Create ("Util.Properties.Bundles");
procedure Free is
new Ada.Unchecked_Deallocation (Manager'Class,
Bundle_Manager_Access);
-- Implementation of the Bundle
-- (this allows to decouples the implementation from the API)
package Interface_P is
type Manager is new Util.Properties.Interface_P.Manager with private;
-- Get the value identified by the name.
-- If the name cannot be found, the method should return the Null object.
overriding
function Get_Value (From : in Manager;
Name : in String) return Util.Beans.Objects.Object;
-- Set the value identified by the name.
-- If the map contains the given name, the value changed.
-- Otherwise name is added to the map and the value associated with it.
overriding
procedure Set_Value (From : in out Manager;
Name : in String;
Value : in Util.Beans.Objects.Object);
-- Returns TRUE if the property exists.
overriding
function Exists (Self : in Manager;
Name : in String)
return Boolean;
-- Remove the property given its name.
overriding
procedure Remove (Self : in out Manager;
Name : in String);
-- Iterate over the properties and execute the given procedure passing the
-- property name and its value.
overriding
procedure Iterate (Self : in Manager;
Process : access procedure (Name : in String;
Item : in Util.Beans.Objects.Object));
procedure Load_Properties (Self : in out Manager;
File : in String);
-- Deep copy of properties stored in 'From' to 'To'.
function Create_Copy (Self : in Manager)
return Util.Properties.Interface_P.Manager_Access;
procedure Add_Bundle (Self : in out Manager;
Props : in Util.Properties.Manager_Access);
private
use type Util.Properties.Manager_Access;
package PropertyList is new Ada.Containers.Vectors
(Element_Type => Util.Properties.Manager_Access,
Index_Type => Natural,
"=" => "=");
type Manager is new Util.Properties.Interface_P.Manager with record
List : PropertyList.Vector;
Props : aliased Util.Properties.Manager;
end record;
end Interface_P;
procedure Add_Bundle (Self : in out Manager;
Props : in Manager_Access) is
use type Util.Properties.Interface_P.Manager_Access;
begin
Interface_P.Manager'Class (Self.Impl.all).Add_Bundle (Props);
end Add_Bundle;
procedure Initialize (Object : in out Manager) is
use Util.Properties.Interface_P;
begin
Object.Impl := new Util.Properties.Bundles.Interface_P.Manager;
Util.Concurrent.Counters.Increment (Object.Impl.Count);
end Initialize;
procedure Adjust (Object : in out Manager) is
use Util.Properties.Interface_P;
begin
if Object.Impl = null then
Object.Impl := new Util.Properties.Bundles.Interface_P.Manager;
end if;
Util.Concurrent.Counters.Increment (Object.Impl.Count);
end Adjust;
-- ------------------------------
-- Initialize the bundle factory and specify where the property files are stored.
-- ------------------------------
procedure Initialize (Factory : in out Loader;
Path : in String) is
begin
Log.Info ("Initialize bundle factory to load from {0}", Path);
Factory.Path := To_Unbounded_String (Path);
end Initialize;
-- ------------------------------
-- Load the bundle with the given name and for the given locale name.
-- ------------------------------
procedure Load_Bundle (Factory : in out Loader;
Name : in String;
Locale : in String;
Bundle : out Manager'Class) is
Found : Boolean := False;
begin
Log.Info ("Load bundle {0} for language {1}", Name, Locale);
Find_Bundle (Factory, Name, Locale, Bundle, Found);
if not Found then
Load_Bundle (Factory, Name, Found);
if not Found then
Log.Error ("Bundle {0} not found", Name);
raise NO_BUNDLE with "No bundle '" & Name & "'";
end if;
Find_Bundle (Factory, Name, Locale, Bundle, Found);
if not Found then
Log.Error ("Bundle {0} not found", Name);
raise NO_BUNDLE with "No bundle '" & Name & "'";
end if;
end if;
end Load_Bundle;
-- ------------------------------
-- Find the bundle with the given name and for the given locale name.
-- ------------------------------
procedure Find_Bundle (Factory : in out Loader;
Name : in String;
Locale : in String;
Bundle : out Manager'Class;
Found : out Boolean) is
use Ada.Strings;
use type Util.Properties.Manager_Access;
Loc_Name : constant String := '_' & Locale;
Last_Pos : Integer := Loc_Name'Last;
begin
Log.Info ("Looking for bundle {0} and language {1}", Name, Locale);
Found := False;
Factory.Lock.Read;
declare
Pos : Bundle_Map.Cursor;
begin
while Last_Pos + 1 >= Loc_Name'First loop
declare
Bundle_Name : aliased constant String
:= Name & Loc_Name (Loc_Name'First .. Last_Pos);
begin
Log.Debug ("Searching for {0}", Bundle_Name);
Pos := Factory.Bundles.Find (Bundle_Name'Unrestricted_Access);
if Bundle_Map.Has_Element (Pos) then
Bundle.Finalize;
Bundle.Impl := Bundle_Map.Element (Pos).Impl;
Util.Concurrent.Counters.Increment (Bundle.Impl.Count);
Found := True;
exit;
end if;
end;
if Last_Pos > Loc_Name'First then
Last_Pos := Fixed.Index (Loc_Name, "_", Last_Pos - 1, Backward) - 1;
else
Last_Pos := Last_Pos - 1;
end if;
end loop;
exception
when others =>
Factory.Lock.Release_Read;
raise;
end;
Factory.Lock.Release_Read;
end Find_Bundle;
-- ------------------------------
-- Load the bundle with the given name and for the given locale name.
-- ------------------------------
procedure Load_Bundle (Factory : in out Loader;
Name : in String;
Found : out Boolean) is
use Ada.Directories;
use Ada.Strings;
use Util.Strings;
use Ada.Containers;
use Util.Strings.String_Set;
use Bundle_Map;
procedure Process_File (Name : in String;
File_Path : in String;
Done : out Boolean);
Path : constant String := To_String (Factory.Path);
Pattern : constant String := Name & "*.properties";
Names : Util.Strings.String_Set.Set;
procedure Process_File (Name : in String;
File_Path : in String;
Done : out Boolean) is
subtype Cursor is Bundle_Map.Cursor;
Base_Name : aliased constant String := Name (Name'First .. Name'Last - 11);
Pos : constant Cursor := Factory.Bundles.Find (Base_Name'Unchecked_Access);
Bundle_Name : Name_Access;
Bundle : Bundle_Manager_Access;
begin
Log.Debug ("Loading file {0}", File_Path);
if Bundle_Map.Has_Element (Pos) then
Bundle := Bundle_Map.Element (Pos);
else
Bundle := new Manager;
Bundle_Name := new String '(Base_Name);
Factory.Bundles.Include (Key => Bundle_Name, New_Item => Bundle);
Names.Insert (Bundle_Name);
end if;
Interface_P.Manager'Class (Bundle.Impl.all).Load_Properties (File_Path);
Found := True;
Done := False;
end Process_File;
begin
Log.Info ("Reading bundle {1} in directory {0}", Path, Name);
Found := False;
Factory.Lock.Write;
begin
Util.Files.Iterate_Files_Path (Pattern => Pattern,
Path => Path,
Process => Process_File'Access,
Going => Ada.Strings.Backward);
-- Link the property files to implement the localization default rules.
while Names.Length > 0 loop
declare
Name_Pos : String_Set.Cursor := Names.First;
Bundle_Name : constant Name_Access := String_Set.Element (Name_Pos);
Idx : Natural := Fixed.Index (Bundle_Name.all, "_", Backward);
Bundle_Pos : constant Bundle_Map.Cursor := Factory.Bundles.Find (Bundle_Name);
Bundle : constant Bundle_Manager_Access := Element (Bundle_Pos);
begin
Names.Delete (Name_Pos);
-- Associate the property bundle to the first existing parent
-- Ex: message_fr_CA -> message_fr
-- message_fr_CA -> message
while Idx > 0 loop
declare
Name : aliased constant String
:= Bundle_Name (Bundle_Name'First .. Idx - 1);
Pos : constant Bundle_Map.Cursor
:= Factory.Bundles.Find (Name'Unchecked_Access);
begin
if Bundle_Map.Has_Element (Pos) then
Bundle.Add_Bundle (Bundle_Map.Element (Pos).all'Access);
Idx := 0;
else
Idx := Fixed.Index (Bundle_Name.all, "_", Idx - 1, Backward);
end if;
end;
end loop;
end;
end loop;
exception
when others =>
Factory.Lock.Release_Write;
raise;
end;
Factory.Lock.Release_Write;
exception
when Name_Error =>
Log.Error ("Cannot read directory: {0}", Path);
end Load_Bundle;
-- Implementation of the Bundle
-- (this allows to decouples the implementation from the API)
package body Interface_P is
use PropertyList;
-- Get the value identified by the name.
-- If the name cannot be found, the method should return the Null object.
overriding
function Get_Value (From : in Manager;
Name : in String) return Util.Beans.Objects.Object is
Result : Util.Beans.Objects.Object := From.Props.Get_Value (Name);
begin
if Util.Beans.Objects.Is_Null (Result) then
declare
Iter : Cursor := From.List.First;
begin
while Has_Element (Iter) loop
Result := Element (Iter).all.Get_Value (Name);
exit when not Util.Beans.Objects.Is_Null (Result);
Iter := Next (Iter);
end loop;
end;
end if;
return Result;
end Get_Value;
-- Set the value identified by the name.
-- If the map contains the given name, the value changed.
-- Otherwise name is added to the map and the value associated with it.
overriding
procedure Set_Value (From : in out Manager;
Name : in String;
Value : in Util.Beans.Objects.Object) is
begin
raise NOT_WRITEABLE with "Bundle is readonly";
end Set_Value;
-- ------------------------------
-- Returns TRUE if the property exists.
-- ------------------------------
function Exists (Self : in Manager; Name : in String)
return Boolean is
Iter : Cursor := Self.List.First;
begin
if Self.Props.Exists (Name) then
return True;
end if;
while Has_Element (Iter) loop
if Element (Iter).Exists (Name) then
return True;
end if;
Iter := Next (Iter);
end loop;
return False;
end Exists;
procedure Load_Properties (Self : in out Manager;
File : in String) is
begin
Self.Props.Load_Properties (File);
end Load_Properties;
-- ------------------------------
-- Remove the property given its name.
-- ------------------------------
procedure Remove (Self : in out Manager;
Name : in String) is
begin
raise NOT_WRITEABLE with "Bundle is readonly";
end Remove;
-- Iterate over the properties and execute the given procedure passing the
-- property name and its value.
procedure Iterate (Self : in Manager;
Process : access procedure (Name : in String;
Item : in Util.Beans.Objects.Object)) is
begin
raise Program_Error with "Iterate is not implemented on Bundle";
end Iterate;
-- ------------------------------
-- Deep copy of properties stored in 'From' to 'To'.
-- ------------------------------
function Create_Copy (Self : in Manager)
return Util.Properties.Interface_P.Manager_Access is
pragma Unreferenced (Self);
begin
return null;
end Create_Copy;
procedure Add_Bundle (Self : in out Manager;
Props : in Util.Properties.Manager_Access) is
begin
Self.List.Append (Props);
end Add_Bundle;
end Interface_P;
-- ------------------------------
-- Clear the bundle cache
-- ------------------------------
procedure Clear_Cache (Factory : in out Loader) is
use Util.Strings;
use Bundle_Map;
function To_String_Access is
new Ada.Unchecked_Conversion (Source => Util.Strings.Name_Access,
Target => Ada.Strings.Unbounded.String_Access);
begin
Log.Info ("Clearing bundle cache");
Factory.Lock.Write;
loop
declare
Pos : Bundle_Map.Cursor := Factory.Bundles.First;
Name : Ada.Strings.Unbounded.String_Access;
Node : Bundle_Manager_Access;
begin
exit when not Has_Element (Pos);
Node := Element (Pos);
Name := To_String_Access (Key (Pos));
Factory.Bundles.Delete (Pos);
Free (Node);
Free (Name);
end;
end loop;
Factory.Lock.Release_Write;
end Clear_Cache;
-- ------------------------------
-- Finalize the bundle loader and clear the cache
-- ------------------------------
procedure Finalize (Factory : in out Loader) is
begin
Clear_Cache (Factory);
end Finalize;
end Util.Properties.Bundles;
|
reznikmm/matreshka | Ada | 5,239 | ads | ------------------------------------------------------------------------------
-- --
-- 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$
------------------------------------------------------------------------------
private with Ada.Containers.Vectors;
private with League.Strings;
with XML.DOM.Nodes.Documents;
private with XML.SAX.Attributes;
with XML.SAX.Content_Handlers;
package Matreshka.DOM_Builders is
type DOM_Builder is
limited new XML.SAX.Content_Handlers.SAX_Content_Handler with private;
function Get_Document
(Self : DOM_Builder'Class)
return XML.DOM.Nodes.Documents.DOM_Document_Access;
private
package Node_Vectors is
new Ada.Containers.Vectors
(Positive,
XML.DOM.Nodes.DOM_Node_Access,
XML.DOM.Nodes."=");
type DOM_Builder is
limited new XML.SAX.Content_Handlers.SAX_Content_Handler with record
Document : XML.DOM.Nodes.Documents.DOM_Document_Access;
Current : XML.DOM.Nodes.DOM_Node_Access;
Parent : XML.DOM.Nodes.DOM_Node_Access;
Stack : Node_Vectors.Vector;
end record;
overriding procedure Characters
(Self : in out DOM_Builder;
Text : League.Strings.Universal_String;
Success : in out Boolean);
overriding procedure End_Element
(Self : in out DOM_Builder;
Namespace_URI : League.Strings.Universal_String;
Local_Name : League.Strings.Universal_String;
Qualified_Name : League.Strings.Universal_String;
Success : in out Boolean);
overriding function Error_String
(Self : DOM_Builder) return League.Strings.Universal_String;
overriding procedure Start_Document
(Self : in out DOM_Builder;
Success : in out Boolean);
overriding procedure Start_Element
(Self : in out DOM_Builder;
Namespace_URI : League.Strings.Universal_String;
Local_Name : League.Strings.Universal_String;
Qualified_Name : League.Strings.Universal_String;
Attributes : XML.SAX.Attributes.SAX_Attributes;
Success : in out Boolean);
end Matreshka.DOM_Builders;
|
io7m/coreland-vector-ada | Ada | 1,834 | adb | with ada.text_io;
with vector;
with vector.assign;
procedure assi_single is
package io renames ada.text_io;
package v16 is new vector (16);
package v16_assign is new v16.assign;
use type v16.scalar_f_t;
base_a : constant v16.vector_f_t := (others => 1.0);
base_b : constant v16.vector_f_t := (others => 2.0);
base_r : v16.vector_f_t := (others => 2.0);
testno : integer := 0;
procedure sys_exit (e: integer);
pragma import (c, sys_exit, "exit");
procedure fail (want, got : v16.scalar_f_t; index: integer) is
s_tnum : constant string := integer'image (testno);
s_index : constant string := integer'image (index);
s_want : constant string := v16.scalar_f_t'image (want);
s_got : constant string := v16.scalar_f_t'image (got);
begin
io.put_line ("[" & s_tnum & "][" & s_index & "] fail " & s_want & " /= " & s_got);
sys_exit (1);
end fail;
procedure pass (want, got : v16.scalar_f_t; index: integer) is
s_tnum : constant string := integer'image (testno);
s_index : constant string := integer'image (index);
s_want : constant string := v16.scalar_f_t'image (want);
s_got : constant string := v16.scalar_f_t'image (got);
begin
io.put_line ("[" & s_tnum & "][" & s_index & "] " & s_want & " = " & s_got);
end pass;
procedure check (vec : v16.vector_f_t) is
begin
for index in vec'range loop
if vec (index) /= base_r (index) then
fail (want => base_r (index), got => vec (index), index => index);
else
pass (want => base_r (index), got => vec (index), index => index);
end if;
end loop;
testno := testno + 1;
end check;
begin
--
-- assign, in place
--
declare
tmp_a : v16.vector_f_t := base_a;
begin
v16_assign.f (tmp_a, base_b);
check (tmp_a);
end;
end assi_single;
|
stcarrez/ada-awa | Ada | 890 | ads | -----------------------------------------------------------------------
-- awa-converters -- Converters
-- 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.
-----------------------------------------------------------------------
package AWA.Converters is
end AWA.Converters;
|
peterfrankjohnson/assembler | Ada | 1,435 | ads | with Ada.Text_IO, Ada.Integer_Text_IO;
use Ada;
--package BTree
procedure Tree is
type Node;
type Tree is access Node;
type Node is record
Item: Integer;
Left,Right: Tree;
end record;
procedure Preorder (T: Tree) is
begin
if (T/=null) then
Integer_Text_IO.Put (T.Item);
Text_IO.New_Line;
Preorder (T.Left);
Preorder (T.Right);
end if;
end Preorder;
procedure Inorder (T: Tree) is
begin
if (T/=null) then
Inorder (T.Left);
Integer_Text_IO.Put (T.Item);
Text_IO.New_Line;
Inorder (T.Right);
end if;
end Inorder;
procedure Insert (I: Integer; T: in out Tree) is
begin
if T=null then
T := new Node'(I, null, null);
elsif I<T.Item then
Insert (I, T.Left);
else
Insert (I, T.Right);
end if;
end Insert;
type Item_Array is array (Integer range <>) of Integer;
procedure Insert (A: Item_Array; T: in out Tree) is
begin
for I in A'Range loop
Insert (A(I), T);
end loop;
end Insert;
T : Tree := null;
Data : constant Item_Array := (16,5,2,8,7,19,18,22,20,21,23);
begin
Insert (Data, T);
Preorder (T);
Inorder (T);
end Tree;
--end BTree; |
annexi-strayline/AURA | Ada | 4,222 | ads | ------------------------------------------------------------------------------
-- --
-- Ada User Repository Annex (AURA) --
-- ANNEXI-STRAYLINE Reference Implementation --
-- --
-- Command Line Interface --
-- --
-- ------------------------------------------------------------------------ --
-- --
-- Copyright (C) 2020, ANNEXI-STRAYLINE Trans-Human Ltd. --
-- All rights reserved. --
-- --
-- Original Contributors: --
-- * Richard Wai (ANNEXI-STRAYLINE) --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions are --
-- met: --
-- --
-- * Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- --
-- * Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in --
-- the documentation and/or other materials provided with the --
-- distribution. --
-- --
-- * Neither the name of the copyright holder nor the names of its --
-- contributors may be used to endorse or promote products derived --
-- from this software without specific prior written permission. --
-- --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A --
-- PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
-- OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT --
-- LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, --
-- DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY --
-- THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT --
-- (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE --
-- OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
-- --
------------------------------------------------------------------------------
-- This package contains the prototype AURA and AURA.Auto_Configure packages.
--
-- The auto generation for both packages must be kept synchronized with this
-- file!
with Ada.Strings.Unbounded;
with Ada.Containers.Vectors;
with Platform_Info;
package Prototypes with Preelaborate is
package AURA is
Platform_Family : String renames Platform_Info.Platform_Family;
Platform_Flavor : String renames Platform_Info.Platform_Flavor;
Platform_Distribution: String renames Platform_Info.Platform_Distribution;
Platform_Version : String renames Platform_Info.Platform_Version;
Platform_Architecture: String renames Platform_Info.Platform_Architecture;
end AURA;
end Prototypes;
|
ohenley/ada-util | Ada | 3,936 | ads | -----------------------------------------------------------------------
-- util-nullables -- Basic types that can hold a null value
-- Copyright (C) 2017 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.Calendar;
with Ada.Strings.Unbounded;
-- === Nullable types ===
-- Sometimes it is necessary to represent a simple data type with an optional boolean information
-- that indicates whether the value is valid or just null. The concept of nullable type is often
-- used in databases but also in JSON data representation. The <tt>Util.Nullables</tt> package
-- provides several standard type to express the null capability of a value.
--
-- By default a nullable instance is created with the null flag set.
package Util.Nullables is
use type Ada.Strings.Unbounded.Unbounded_String;
use type Ada.Calendar.Time;
-- ------------------------------
-- A boolean which can be null.
-- ------------------------------
type Nullable_Boolean is record
Value : Boolean := False;
Is_Null : Boolean := True;
end record;
-- Return True if the two nullable times are identical (both null or both same value).
function "=" (Left, Right : in Nullable_Boolean) return Boolean is
(Left.Is_Null = Right.Is_Null and (Left.Is_Null or else Left.Value = Right.Value));
-- ------------------------------
-- An integer which can be null.
-- ------------------------------
type Nullable_Integer is record
Value : Integer := 0;
Is_Null : Boolean := True;
end record;
-- Return True if the two nullable times are identical (both null or both same value).
function "=" (Left, Right : in Nullable_Integer) return Boolean is
(Left.Is_Null = Right.Is_Null and (Left.Is_Null or else Left.Value = Right.Value));
-- ------------------------------
-- A long which can be null.
-- ------------------------------
type Nullable_Long is record
Value : Long_Long_Integer := 0;
Is_Null : Boolean := True;
end record;
-- Return True if the two nullable times are identical (both null or both same value).
function "=" (Left, Right : in Nullable_Long) return Boolean is
(Left.Is_Null = Right.Is_Null and (Left.Is_Null or else Left.Value = Right.Value));
-- ------------------------------
-- A string which can be null.
-- ------------------------------
type Nullable_String is record
Value : Ada.Strings.Unbounded.Unbounded_String;
Is_Null : Boolean := True;
end record;
-- Return True if the two nullable times are identical (both null or both same value).
function "=" (Left, Right : in Nullable_String) return Boolean is
(Left.Is_Null = Right.Is_Null and (Left.Is_Null or else Left.Value = Right.Value));
-- ------------------------------
-- A date which can be null.
-- ------------------------------
type Nullable_Time is record
Value : Ada.Calendar.Time;
Is_Null : Boolean := True;
end record;
-- Return True if the two nullable times are identical (both null or both same time).
function "=" (Left, Right : in Nullable_Time) return Boolean is
(Left.Is_Null = Right.Is_Null and (Left.Is_Null or else Left.Value = Right.Value));
end Util.Nullables;
|
tum-ei-rcs/StratoX | Ada | 3,873 | ads | ------------------------------------------------------------------------------
-- --
-- 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.h --
-- @author MCD Application Team --
-- @version V1.1.0 --
-- @date 19-June-2014 --
-- @brief Header file of RNG HAL module. --
-- --
-- COPYRIGHT(c) 2014 STMicroelectronics --
------------------------------------------------------------------------------
-- This file provides the API for the random number generator on the STM32F4
-- (ARM Cortex M4F) microcontrollers from ST Microelectronics.
--
-- Random numbers are acquired by responding to interrupts from the on-board
-- generator.
package STM32.RNG.Interrupts is
procedure Initialize_RNG with
Post => RNG_Interrupt_Enabled;
-- Must be called once, prior to any call to get a random number via
-- interrupts. Both necessary and sufficient.
-- Enables the clock as well.
function Random return Interfaces.Unsigned_32;
-- Uses the interrupt interface to get the next available number.
-- NB: call Initialize_RNG before any calls to this function.
end STM32.RNG.Interrupts;
|
NCommander/dnscatcher | Ada | 1,296 | ads | -- Copyright 2019 Michael Casadevall <[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 AUnit.Test_Suites;
package Packet_Processor_Test_Suite is
function Suite return AUnit.Test_Suites.Access_Test_Suite;
end Packet_Processor_Test_Suite;
|
thorstel/Advent-of-Code-2018 | Ada | 3,758 | adb | with Ada.Containers.Ordered_Sets,
Ada.Containers.Vectors; use Ada.Containers;
with Ada.Text_IO; use Ada.Text_IO;
with Interfaces; use Interfaces;
with Input16; use Input16, Input16.OH;
procedure Day16 is
subtype Op_String is String (1 .. 4);
package String_Sets is new Ordered_Sets (Element_Type => Op_String);
package String_Set_Vectors is new Vectors
(Index_Type => Positive,
Element_Type => String_Sets.Set,
"=" => String_Sets."=");
Opcodes : array (Natural range 0 .. 15) of String_Set_Vectors.Vector;
Opcode_Lookup : array (Natural range 0 .. 15) of Op_String :=
("addr", "addi", "mulr", "muli", "banr", "bani", "borr", "bori",
"setr", "seti", "gtir", "gtri", "gtrr", "eqir", "eqri", "eqrr");
Part1_Count : Natural := 0;
begin
-- Part 1
for I in Part1_Input'Range loop
declare
Sample : constant Sample_Record := Part1_Input (I);
A : constant Unsigned_64 := Sample.Instr (1);
B : constant Unsigned_64 := Sample.Instr (2);
C : constant Unsigned_64 := Sample.Instr (3);
Match_Count : Natural := 0;
Possible_Opcodes : String_Sets.Set;
begin
for I in Opcode_Lookup'Range loop
declare
Op : constant Op_String := Opcode_Lookup (I);
begin
if Execute_Instruction (Op, Sample.Before, A, B, C) = Sample.After
then
Match_Count := Match_Count + 1;
Possible_Opcodes.Insert (Op);
end if;
end;
end loop;
Opcodes (Natural (Sample.Instr (0))).Append (Possible_Opcodes);
if Match_Count >= 3 then
Part1_Count := Part1_Count + 1;
end if;
end;
end loop;
Put_Line ("Part 1 =" & Natural'Image (Part1_Count));
-- Part 2 Setup (find the opcode values)
declare
Opcode : array (Natural range 0 .. 15) of String_Sets.Set;
Is_Finished : Boolean := False;
begin
for Op in Opcodes'Range loop
declare
Set : String_Sets.Set := Opcodes (Op).First_Element;
begin
for I in Opcodes (Op).First_Index + 1 .. Opcodes (Op).Last_Index
loop
Set := String_Sets.Intersection (Set, Opcodes (Op) (I));
end loop;
Opcode (Op) := Set;
end;
end loop;
while not Is_Finished loop
Is_Finished := True;
for I in Opcode'Range loop
if Opcode (I).Length = 1 then
Opcode_Lookup (I) := Opcode (I).First_Element;
for J in Opcode'Range loop
if J /= I then
Opcode (J).Exclude (Opcode (I).First_Element);
end if;
end loop;
else
Is_Finished := False;
end if;
end loop;
end loop;
end;
Put_Line ("Opcodes:");
for I in Opcode_Lookup'Range loop
Put_Line (Natural'Image (I) & " " & Opcode_Lookup (I));
end loop;
-- Part 2 Solution
declare
Reg : Registers := (0, 0, 0, 0);
begin
for I in Part2_Input'Range loop
declare
Op : constant Natural := Natural (Part2_Input (I) (0));
A : constant Unsigned_64 := Part2_Input (I) (1);
B : constant Unsigned_64 := Part2_Input (I) (2);
C : constant Unsigned_64 := Part2_Input (I) (3);
begin
Reg := Execute_Instruction (Opcode_Lookup (Op), Reg, A, B, C);
end;
end loop;
Put_Line ("Part 2 =" & Unsigned_64'Image (Reg (3)));
end;
end Day16;
|
charlie5/lace | Ada | 4,097 | adb | with
openGL.Errors,
openGL.Buffer,
openGL.Tasks,
GL.Binding,
GL.lean;
package body openGL.Primitive.indexed
is
---------
--- Forge
--
procedure define (Self : in out Item; Kind : in facet_Kind;
Indices : in openGL.Indices;
line_Width : in Real)
is
use openGL.Buffer.indices.Forge;
buffer_Indices : aliased openGL.Indices := [Indices'Range => <>];
begin
for Each in buffer_Indices'Range
loop
buffer_Indices (Each) := Indices (Each) - 1; -- Adjust indices to zero-based indexing for GL.
end loop;
Self.facet_Kind := Kind;
Self.Indices := new Buffer.indices.Object' (to_Buffer (buffer_Indices'Access,
usage => Buffer.static_Draw));
Self.line_Width := line_Width;
end define;
procedure define (Self : in out Item; Kind : in facet_Kind;
Indices : in long_Indices;
line_Width : in Real)
is
use openGL.Buffer.indices.Forge;
buffer_Indices : aliased openGL.Indices := [Indices'Range => <>];
begin
for Each in buffer_Indices'Range
loop
buffer_Indices (Each) := Index_t (Indices (Each) - 1); -- Adjust indices to zero-based indexing for GL.
end loop;
Self.facet_Kind := Kind;
Self.Indices := new openGL.Buffer.indices.Object' (to_Buffer (buffer_Indices'Access,
usage => Buffer.static_Draw));
Self.line_Width := line_Width;
end define;
function new_Primitive (Kind : in facet_Kind;
Indices : in openGL.Indices;
line_Width : in Real := unused_line_Width) return Primitive.indexed.view
is
Self : constant View := new Item;
begin
define (Self.all, Kind, Indices, line_Width);
return Self;
end new_Primitive;
function new_Primitive (Kind : in facet_Kind;
Indices : in long_Indices;
line_Width : in Real := unused_line_Width) return Primitive.indexed.view
is
Self : constant View := new Item;
begin
define (Self.all, Kind, Indices, line_Width);
return Self;
end new_Primitive;
overriding
procedure destroy (Self : in out Item)
is
the_Indices : Buffer.view := Buffer.view (Self.Indices);
begin
Buffer.free (the_Indices);
Self.Indices := null;
end destroy;
--------------
-- Attributes
--
procedure Indices_are (Self : in out Item; Now : in Indices)
is
use Buffer.indices;
buffer_Indices : aliased Indices := [Now'Range => <>];
begin
for Each in buffer_Indices'Range
loop
buffer_Indices (Each) := Now (Each) - 1; -- Adjust indices to zero-based-indexing for GL.
end loop;
Self.Indices.set (to => buffer_Indices);
end Indices_are;
procedure Indices_are (Self : in out Item; Now : in long_Indices)
is
use Buffer.indices;
buffer_Indices : aliased Indices := [Now'Range => <>];
begin
for Each in buffer_Indices'Range
loop
buffer_Indices (Each) := Index_t (Now (Each) - 1); -- Adjust indices to zero-based-indexing for GL.
end loop;
Self.Indices.set (to => buffer_Indices);
end Indices_are;
--------------
-- Operations
--
overriding
procedure render (Self : in out Item)
is
use GL,
GL.Binding,
GL.lean;
begin
Tasks.check;
Primitive.item (Self).render; -- Do base class render.
Self.Indices.enable;
glDrawElements (Thin (Self.facet_Kind),
gl.GLint (Self.Indices.Length),
GL_UNSIGNED_SHORT,
null);
Errors.log;
end render;
end openGL.Primitive.indexed;
|
sungyeon/drake | Ada | 581 | ads | pragma License (Unrestricted); -- BSD 3-Clause
-- translated unit from SFMT (SFMT-params19937.h)
with Ada.Numerics.SFMT;
package Ada.Numerics.SFMT_19937 is
new SFMT (
MEXP => 19937,
POS1 => 122,
SL1 => 18,
SL2 => 1,
SR1 => 11,
SR2 => 1,
MSK1 => 16#dfffffef#,
MSK2 => 16#ddfecb7f#,
MSK3 => 16#bffaffff#,
MSK4 => 16#bffffff6#,
PARITY1 => 16#00000001#,
PARITY2 => 16#00000000#,
PARITY3 => 16#00000000#,
PARITY4 => 16#13c9e684#);
-- For normal use.
pragma Preelaborate (Ada.Numerics.SFMT_19937);
|
zhmu/ananas | Ada | 5,685 | adb | ------------------------------------------------------------------------------
-- --
-- GNAT LIBRARY COMPONENTS --
-- --
-- G N A T . D E B U G _ U T I L I T I E S --
-- --
-- B o d y --
-- --
-- Copyright (C) 1997-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. --
-- --
------------------------------------------------------------------------------
with System; use System;
with System.Storage_Elements; use System.Storage_Elements;
package body GNAT.Debug_Utilities is
H : constant array (0 .. 15) of Character := "0123456789ABCDEF";
-- Table of hex digits
-----------
-- Image --
-----------
-- Address case
function Image (A : Address) return Image_String is
S : Image_String;
P : Natural;
N : Integer_Address;
U : Natural := 0;
begin
S (S'Last) := '#';
P := Address_Image_Length - 1;
N := To_Integer (A);
while P > 3 loop
if U = 4 then
S (P) := '_';
P := P - 1;
U := 1;
else
U := U + 1;
end if;
S (P) := H (Integer (N mod 16));
P := P - 1;
N := N / 16;
end loop;
S (1 .. 3) := "16#";
return S;
end Image;
-----------
-- Image --
-----------
-- String case
function Image (S : String) return String is
W : String (1 .. 2 * S'Length + 2);
P : Positive := 1;
begin
W (1) := '"';
for J in S'Range loop
if S (J) = '"' then
P := P + 1;
W (P) := '"';
end if;
P := P + 1;
W (P) := S (J);
end loop;
P := P + 1;
W (P) := '"';
return W (1 .. P);
end Image;
-------------
-- Image_C --
-------------
function Image_C (A : Address) return Image_C_String is
S : Image_C_String;
N : Integer_Address := To_Integer (A);
begin
for P in reverse 3 .. S'Last loop
S (P) := H (Integer (N mod 16));
N := N / 16;
end loop;
S (1 .. 2) := "0x";
return S;
end Image_C;
-----------
-- Value --
-----------
function Value (S : String) return System.Address is
Base : Integer_Address := 10;
Res : Integer_Address := 0;
Last : Natural := S'Last;
C : Character;
N : Integer_Address;
begin
-- Skip final Ada 95 base character
if S (Last) = '#' or else S (Last) = ':' then
Last := Last - 1;
end if;
-- Loop through characters
for J in S'First .. Last loop
C := S (J);
-- C format hex constant
if C = 'x' then
if Res /= 0 then
raise Constraint_Error;
end if;
Base := 16;
-- Ada form based literal
elsif C = '#' or else C = ':' then
Base := Res;
Res := 0;
-- Ignore all underlines
elsif C = '_' then
null;
-- Otherwise must have digit
else
if C in '0' .. '9' then
N := Character'Pos (C) - Character'Pos ('0');
elsif C in 'A' .. 'F' then
N := Character'Pos (C) - (Character'Pos ('A') - 10);
elsif C in 'a' .. 'f' then
N := Character'Pos (C) - (Character'Pos ('a') - 10);
else
raise Constraint_Error;
end if;
if N >= Base then
raise Constraint_Error;
else
Res := Res * Base + N;
end if;
end if;
end loop;
return To_Address (Res);
end Value;
end GNAT.Debug_Utilities;
|
AdaCore/libadalang | Ada | 91 | ads | package Pkg1 is
procedure Foo;
--% node.p_body_part()
end Pkg1;
--% node.p_body_part
|
fnarenji/BoiteMaker | Ada | 2,779 | adb | with ada.unchecked_deallocation;
with ada.characters.latin_1;
use ada.characters.latin_1;
package body generic_linked_list is
-- Instanciation du deallocateur pour le pool d'access node_t
procedure node_unchecked_deallocation is new ada.unchecked_deallocation(node_t, node_ptr);
function create(element : element_t) return node_ptr is
node : constant node_ptr := new node_t;
begin
node.all := (element => element, next_node => null);
return node;
end;
function add_after(node : node_ptr; element : element_t) return node_ptr is
begin
add_after(node, element);
return move_next(node);
end;
procedure add_after(node : node_ptr; element : element_t) is
new_node : constant node_ptr := new node_t;
begin
new_node.all := (element => element, next_node => null);
node.next_node := new_node;
end;
procedure remove_next(node : node_ptr) is
next_node : node_ptr := node.next_node;
begin
if next_node = null then
raise no_node;
end if;
-- Supprime le noeud de la chaine
node.next_node := next_node.next_node;
-- Libération de la mémoire du noeud
node_unchecked_deallocation(next_node);
end;
function has_next(node : node_ptr) return boolean is
begin
return node.next_node /= null;
end;
function move_next(node : node_ptr) return node_ptr is
begin
if node.next_node = null then
raise no_node;
end if;
return node.next_node;
end;
function elem(node : node_ptr) return element_t is
begin
return node.all.element;
end;
procedure destroy(node : in out node_ptr) is
begin
if has_next(node) then
destroy(node.next_node);
end if;
node_unchecked_deallocation(node);
end;
function to_string(node : node_ptr; to_string : to_string_function_t) return string is
-- Helper de récursion permettant la génération de la chaine pour le to_string
function to_string_helper(node : node_ptr; to_string : to_string_function_t) return string is
s : constant string := ada.characters.latin_1.HT & to_string.all(elem(node));
begin
if has_next(node) then
return s
& ','
& ada.characters.latin_1.LF
& to_string_helper(move_next(node), to_string);
end if;
return s & ada.characters.latin_1.LF;
end;
begin
return "["
& ada.characters.latin_1.LF
& to_string_helper(node, to_string)
& ada.characters.latin_1.HT
& "]";
end;
end generic_linked_list;
|
BrickBot/Bound-T-H8-300 | Ada | 10,914 | adb | -- Least_Fixpoint (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.4 $
-- $Date: 2015/10/24 20:05:49 $
--
-- $Log: least_fixpoint.adb,v $
-- Revision 1.4 2015/10/24 20:05:49 niklas
-- Moved to free licence.
--
-- Revision 1.3 2005-05-09 15:31:01 niklas
-- Added the parameter Least_Fixpoint.Afters, to choose between the
-- pre-values and the post-values of the solution. The value-origin
-- analysis needs post-values.
--
-- Revision 1.2 2004/04/28 19:19:40 niklas
-- First Tidorum version.
-- Added a Value parameter to the generic formal Successors function so
-- that the successor node-set can depend on the current value, for
-- example to elide infeasible edges.
-- Removed the built-in iteration-tracing feature (the generic formals
-- Node_Image and Value_Image and the internal operation Show_Values
-- and its calls). If tracing is desired, it should be implemented in
-- the actual operations bound to the generic formals.
--
-- Revision 1.1 2001/01/07 21:54:22 holsti
-- First version.
--
with Bounded_Queues;
with Bounded_Set_Pool;
with Ada.Text_IO;
with Ada.Exceptions;
function Least_Fixpoint (
Nodes : Node_List;
Edges : Natural;
Within : Graph;
Afters : Boolean := False)
return Value_List
is
subtype Node_Index_T is Positive range Nodes'Range;
--
-- Identifies a node in various arrays.
subtype Node_Values_T is Value_List (Node_Index_T);
--
-- A value for each node.
Pre : Node_Values_T;
Post : Node_Values_T;
--
-- The pre-value and post-value of each node.
package Target_Nodes is new Bounded_Queues (
Element_Type => Node_Index_T);
--
-- Implements queues of nodes (identified by node indices).
-- These nodes will be the target nodes of the work-list edges.
Work_Targets : Target_Nodes.Queue_Type (Max_Length => Nodes'Length);
--
-- The target nodes in the work-list.
package Source_Nodes is new Bounded_Set_Pool (
Element_Type => Node_Index_T,
Max_Elements => Edges);
--
-- Implements sets of source-nodes (identified by node indices).
Work_Sources : array (Node_Index_T) of Source_Nodes.Set_Type;
--
-- For each target node N in Work_Targets, Work_Sources(N)
-- contains the source-nodes of the edges in the work-list,
-- for the target node N.
procedure Add_To_Work (Source, Target : in Node)
--
-- Adds the edge Source->Target to the work-list.
--
is
S : constant Node_Index_T := Index_Of (Source);
T : constant Node_Index_T := Index_Of (Target);
-- The indices of the source and target nodes.
begin
if Source_Nodes.Empty (Work_Sources(T)) then
-- The work-list contains no other edges for Target.
-- The target-node must be put into Work_Targets:
Target_Nodes.Put (Element => T, Into => Work_Targets);
end if;
-- In any case, the source-node is added to the work-list
-- for this target-node:
Source_Nodes.Add (Element => S, To => Work_Sources(T));
end Add_To_Work;
procedure Add_Edges_To_Work (
Source : in Node;
Index : in Node_Index_T)
--
-- Adds, to the work list, all the edges from the given node
-- to its successor nodes under the current Post value flowing
-- from the node. Index is assumed to be Index_Of (Source).
--
is
Succ : constant Node_List :=
Successors (
After => Source,
Post => Post (Index),
Within => Within);
--
-- The successor nodes for this Source for the
-- current Post value of the Source.
begin
for S in Succ'range loop
Add_To_Work (
Source => Source,
Target => Succ(S));
end loop;
end Add_Edges_To_Work;
procedure Take_From_Work (
Index : out Node_Index_T;
Empty : out Boolean)
--
-- Takes the first target node from the work-list and returns
-- its index if the work-list was not empty, else returns Empty
-- as True.
--
is
begin
Target_Nodes.Get (
From => Work_Targets,
Element => Index);
Empty := False;
exception
when Target_Nodes.Underflow =>
Empty := True;
Index := Node_Index_T'First;
-- To avoid invalid value.
end Take_From_Work;
procedure Process (Target_Index : Node_Index_T)
--
-- Processes a target node taken from the work-list, by re-merging
-- all the changed post-values into the pre-value of the target.
-- If the pre-value grows, the target's post-value is updated, and
-- if the post-value grows, all the target's out-edges are put in
-- the work-list.
--
is
Target_Node : constant Node := Nodes(Target_Index);
-- The target-node being processed.
Sources : Source_Nodes.Set_Type
renames Work_Sources (Target_Index);
-- The source-nodes listed in the work-list for this target-node.
-- These are the predecessors of the target which have changed
-- post-values since the target's pre-value was last updated.
Source_Index : Node_Index_T;
-- The index of a source-node.
Grew : Boolean;
-- A Merge operation made the pre-value grow,
Pre_Grew : Boolean := False;
-- Some Merge operation made the pre-value grow.
Post_Grew : Boolean;
-- The Transform operation made the post-value grow.
begin
-- Merge the post-value for each edge listed in
-- the work-list for this target:
while not Source_Nodes.Empty (Sources)
loop
Source_Nodes.Take (
From => Sources,
Element => Source_Index);
Merge (
Source => Nodes(Source_Index),
Post => Post (Source_Index),
Target => Target_Node,
Pre => Pre (Target_Index),
Grew => Grew);
Pre_Grew := Pre_Grew or Grew;
end loop;
if Pre_Grew then
-- The pre-value grew, so update the post-value:
Transform (
Pre => Pre (Target_Index),
Via => Target_Node,
Post => Post(Target_Index),
Grew => Post_Grew);
if Post_Grew then
-- The post-value grew, so we must (by and by)
-- update the pre-values of the successors:
Add_Edges_To_Work (
Source => Target_Node,
Index => Target_Index);
end if;
end if;
end Process;
--
-- Iteration variables:
--
Post_Grew : Boolean;
--
-- If the initial Transform for a node gave a non-Bottom
-- post-value.
No_More_Work : Boolean;
--
-- If there is no more work to do (empty work-list).
Working_Target : Node_Index_T;
--
-- The target node, from the work-list, on which to work.
procedure Report_Exception (Occurrence : Ada.Exceptions.Exception_Occurrence)
--
-- Report an (unexpected) exception from this function.
--
is
use Ada.Text_IO;
use Ada.Exceptions;
X_Info : constant String := Exception_Information (Occurrence);
Target_Index : Node_Index_T;
Source_Index : Node_Index_T;
Empty : Boolean;
begin
Put_Line ("Exception: " & X_Info);
Put_Line ("Work-lists:");
loop
Take_From_Work (Target_Index, Empty);
exit when Empty;
Put_Line (
"Target Node "
& Node_Index_T'Image (Target_Index));
while not Source_Nodes.Empty (Work_Sources (Target_Index))
loop
Source_Nodes.Take (
From => Work_Sources (Target_Index),
Element => Source_Index);
Put_Line (
" Source Node "
& Node_Index_T'Image (Source_Index));
end loop;
end loop;
end Report_Exception;
begin -- Least_Fixpoint
-- Initialise the pre- and post-values and the work-list:
for N in Node_Index_T loop
Initialize (
Via => Nodes (N),
Pre => Pre (N),
Post => Post (N),
Grew => Post_Grew);
if Post_Grew then
Add_Edges_To_Work (
Source => Nodes(N),
Index => N);
end if;
end loop;
-- Iterate:
loop
Take_From_Work (
Index => Working_Target,
Empty => No_More_Work);
exit when No_More_Work;
Process (Target_Index => Working_Target);
end loop;
-- Decide what to return and what to discard:
if Afters then
-- Discard the pre-values and return the post-values:
for P in Pre'Range loop
Finalize (Pre(P));
end loop;
return Post;
else
-- Discard the post-values and return the pre-values:
for P in Pre'Range loop
Finalize (Post(P));
end loop;
return Pre;
end if;
exception
when X : Target_Nodes.Overflow =>
Report_Exception (X);
raise;
when X : Source_Nodes.Underflow =>
Report_Exception (X);
raise;
when X : Source_Nodes.Overflow =>
Report_Exception (X);
raise;
end Least_Fixpoint;
|
Rodeo-McCabe/orka | Ada | 1,512 | 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.
with Orka.SIMD.SSE2.Doubles;
package Orka.SIMD.SSE4_1.Doubles.Math is
pragma Pure;
use Orka.SIMD.SSE2.Doubles;
function Round (Elements : m128d; Rounding : Unsigned_32) return m128d
with Import, Convention => Intrinsic, External_Name => "__builtin_ia32_roundpd";
function Round_Nearest_Integer (Elements : m128d) return m128d is
(Round (Elements, 0));
-- Round each element to the nearest integer
function Floor (Elements : m128d) return m128d is
(Round (Elements, 1));
-- Round each element down to an integer value
function Ceil (Elements : m128d) return m128d is
(Round (Elements, 2));
-- Round each element up to an integer value
function Round_Truncate (Elements : m128d) return m128d is
(Round (Elements, 3));
-- Round each element to zero
end Orka.SIMD.SSE4_1.Doubles.Math;
|
faelys/natools | Ada | 19,117 | adb | ------------------------------------------------------------------------------
-- Copyright (c) 2013-2015, Natacha Porté --
-- --
-- Permission to use, copy, modify, and distribute this software for any --
-- purpose with or without fee is hereby granted, provided that the above --
-- copyright notice and this permission notice appear in all copies. --
-- --
-- THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES --
-- WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF --
-- MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR --
-- ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES --
-- WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN --
-- ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF --
-- OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. --
------------------------------------------------------------------------------
with Natools.S_Expressions.Parsers;
package body Natools.S_Expressions.Test_Tools is
Hex_Digits : constant String := "0123456789ABCDEF";
function Encode_Hex (Value : Offset; Length : Positive) return String;
function Hex_Slice
(Address : Offset;
Address_Length : Positive;
Data : Atom;
Width : Positive)
return String;
function Is_Printable (Data : Octet) return Boolean;
function Is_Printable (Data : Atom) return Boolean;
-- Return whether Data can be dumped directed as a String or Character
------------------------------
-- Local Helper Subprograms --
------------------------------
function Encode_Hex (Value : Offset; Length : Positive) return String is
I : Natural := Length;
Digit : Natural;
Current : Offset := Value;
begin
return Result : String (1 .. Length) := (others => '0') do
while Current /= 0 and I /= 0 loop
Digit := Natural (Current mod 16);
Result (I) := Hex_Digits (Hex_Digits'First + Digit);
I := I - 1;
Current := Current / 16;
end loop;
end return;
end Encode_Hex;
function Hex_Slice
(Address : Offset;
Address_Length : Positive;
Data : Atom;
Width : Positive)
return String
is
Total_Length : constant Positive
:= Address_Length + 4 + 4 * Width;
Hex_Start : constant Positive := Address_Length + 2;
Raw_Start : constant Positive := Hex_Start + 3 * Width + 1;
Digit : Octet;
begin
return Result : String (1 .. Total_Length) := (others => ' ') do
Result (1 .. Address_Length) := Encode_Hex (Address, Address_Length);
for I in 0 .. Width - 1 loop
exit when Data'First + Offset (I) not in Data'Range;
Digit := Data (Data'First + Offset (I));
Result (Hex_Start + 3 * I) := Hex_Digits (Hex_Digits'First
+ Natural (Digit / 16));
Result (Hex_Start + 3 * I + 1) := Hex_Digits (Hex_Digits'First
+ Natural (Digit mod 16));
if Is_Printable (Digit) then
Result (Raw_Start + I) := Character'Val (Digit);
else
Result (Raw_Start + I) := '.';
end if;
end loop;
end return;
end Hex_Slice;
function Is_Printable (Data : Octet) return Boolean is
begin
return Data in 32 .. 127;
end Is_Printable;
function Is_Printable (Data : Atom) return Boolean is
begin
if Data'Length > 100 then
return False;
end if;
for I in Data'Range loop
if not Is_Printable (Data (I)) then
return False;
end if;
end loop;
return True;
end Is_Printable;
------------------
-- Public Tools --
------------------
procedure Dump_Atom
(Report : in out NT.Reporter'Class;
Data : in Atom;
Label : in String := "")
is
I, Length : Offset := 0;
begin
if Is_Printable (Data) then
if Label'Length > 0 then
Report.Info (Label & ": """ & To_String (Data) & '"');
else
Report.Info ('"' & To_String (Data) & '"');
end if;
else
if Label'Length > 0 then
Report.Info
(Label & ":" & Natural'Image (Data'Length) & " octets");
end if;
while I < Data'Length loop
Length := Offset'Min (16, Data'Length - I);
Report.Info (Hex_Slice
(I, 8,
Data (Data'First + I .. Data'First + I + Length - 1), 16));
I := I + 16;
end loop;
end if;
end Dump_Atom;
procedure Dump_Atom -- Cut and pasted code because generics crash gnat
(Test : in out NT.Test;
Data : in Atom;
Label : in String := "")
is
I, Length : Offset := 0;
begin
if Is_Printable (Data) then
if Label'Length > 0 then
Test.Info (Label & ": """ & To_String (Data) & '"');
else
Test.Info ('"' & To_String (Data) & '"');
end if;
else
if Label'Length > 0 then
Test.Info
(Label & ":" & Natural'Image (Data'Length) & " octets");
end if;
while I < Data'Length loop
Length := Offset'Min (16, Data'Length - I);
Test.Info (Hex_Slice
(I, 8,
Data (Data'First + I .. Data'First + I + Length - 1), 16));
I := I + 16;
end loop;
end if;
end Dump_Atom;
procedure Test_Atom
(Report : in out NT.Reporter'Class;
Test_Name : in String;
Expected : in Atom;
Found : in Atom) is
begin
if Found = Expected then
Report.Item (Test_Name, NT.Success);
else
Report.Item (Test_Name, NT.Fail);
Dump_Atom (Report, Found, "Found");
Dump_Atom (Report, Expected, "Expected");
end if;
end Test_Atom;
procedure Test_Atom
(Test : in out NT.Test;
Expected : in Atom;
Found : in Atom) is
begin
if Found /= Expected then
Test.Fail;
Dump_Atom (Test, Found, "Found");
Dump_Atom (Test, Expected, "Expected");
end if;
end Test_Atom;
procedure Test_Atom_Accessors
(Test : in out NT.Test;
Tested : in Descriptor'Class;
Expected : in Atom;
Expected_Level : in Integer := -1;
Context : in String := "")
is
Context_Given : Boolean := Context = "";
procedure Fail_With_Context;
procedure Fail_With_Context is
begin
if not Context_Given then
Test.Fail (Context);
Context_Given := True;
else
Test.Fail;
end if;
end Fail_With_Context;
Print_Expected : Boolean := False;
begin
if Tested.Current_Event /= Events.Add_Atom then
if Context /= "" then
Test.Error (Context);
end if;
Test.Error ("Test_Atom_Accessors called with current event "
& Events.Event'Image (Tested.Current_Event));
return;
end if;
if Expected_Level >= 0 then
Current_Level_Test :
declare
Level : constant Natural := Tested.Current_Level;
begin
if Level /= Expected_Level then
Fail_With_Context;
Test.Info ("Current_Level is"
& Integer'Image (Level)
& ", expected"
& Integer'Image (Expected_Level));
end if;
end Current_Level_Test;
end if;
Current_Atom_Test :
declare
Current_Atom : constant Atom := Tested.Current_Atom;
begin
if Current_Atom /= Expected then
Print_Expected := True;
Fail_With_Context;
Dump_Atom (Test, Current_Atom, "Current_Atom");
end if;
end Current_Atom_Test;
Query_Atom_Test :
declare
procedure Process (Data : in Atom);
Calls : Natural := 0;
Buffer : Atom_Buffers.Atom_Buffer;
procedure Process (Data : in Atom) is
begin
Calls := Calls + 1;
Buffer.Append (Data);
end Process;
begin
Tested.Query_Atom (Process'Access);
if Calls = 0 then
Fail_With_Context;
Test.Info ("Query_Atom did not call Process");
elsif Calls > 1 then
Fail_With_Context;
Test.Info ("Query_Atom called Process" & Integer'Image (Calls)
& " times");
Print_Expected := True;
Dump_Atom (Test, Buffer.Data, "Buffer");
elsif Buffer.Data /= Expected then
Print_Expected := True;
Fail_With_Context;
Dump_Atom (Test, Buffer.Data, "Query_Atom");
end if;
end Query_Atom_Test;
Long_Read_Atom_Test :
declare
Buffer : Atom (21 .. Expected'Length + 30);
Length : Count;
begin
Tested.Read_Atom (Buffer, Length);
if Buffer (Buffer'First .. Buffer'First + Length - 1) /= Expected then
Print_Expected := True;
Fail_With_Context;
Dump_Atom
(Test,
Buffer (Buffer'First .. Buffer'First + Length - 1),
"Read_Atom");
end if;
end Long_Read_Atom_Test;
Short_Read_Atom_Test :
declare
Buffer : Atom (11 .. Expected'Length / 2 + 10);
Length : Count;
begin
Tested.Read_Atom (Buffer, Length);
if Expected (Expected'First .. Expected'First + Buffer'Length - 1)
/= Buffer
then
Print_Expected := True;
Fail_With_Context;
Dump_Atom (Test, Buffer, "Short Read_Atom");
end if;
end Short_Read_Atom_Test;
if Print_Expected then
Dump_Atom (Test, Expected, "Expected");
end if;
end Test_Atom_Accessors;
procedure Test_Atom_Accessor_Exceptions
(Test : in out NT.Test;
Tested : in Descriptor'Class;
Context : in String := "")
is
Context_Given : Boolean := Context = "";
procedure Fail_With_Context;
procedure Fail_With_Context is
begin
if not Context_Given then
Test.Fail (Context);
Context_Given := True;
else
Test.Fail;
end if;
end Fail_With_Context;
begin
if Tested.Current_Event = Events.Add_Atom then
if Context /= "" then
Test.Error (Context);
end if;
Test.Error ("Test_Atom_Accessor_Exceptions during Events.Add_Atom");
return;
end if;
Current_Atom_Test :
begin
declare
Data : constant Atom := Tested.Current_Atom;
begin
Fail_With_Context;
Test.Info ("No exception raised in Current_Atom");
Dump_Atom (Test, Data, "Returned value");
end;
exception
when Program_Error => null;
when Error : others =>
Fail_With_Context;
Test.Info ("Wrong exception raised in Current_Atom");
Test.Report_Exception (Error, NT.Fail);
end Current_Atom_Test;
Query_Atom_Test :
declare
procedure Process (Data : in Atom);
Calls : Natural := 0;
Buffer : Atom_Buffers.Atom_Buffer;
procedure Process (Data : in Atom) is
begin
Calls := Calls + 1;
Buffer.Append (Data);
end Process;
begin
Tested.Query_Atom (Process'Access);
Fail_With_Context;
Test.Info ("No exception raised in Query_Atom");
Dump_Atom (Test, Buffer.Data,
"Buffer from" & Natural'Image (Calls) & " calls");
exception
when Program_Error => null;
when Error : others =>
Fail_With_Context;
Test.Info ("Wrong exception raised in Query_Atom");
Test.Report_Exception (Error, NT.Fail);
end Query_Atom_Test;
Read_Atom_Test :
declare
Buffer : Atom (0 .. 31) := (others => 46);
Length : Count;
begin
Tested.Read_Atom (Buffer, Length);
Fail_With_Context;
Test.Info ("No exception raised in Read_Atom");
Test.Info ("Returned Length:" & Count'Image (Length));
Dump_Atom (Test, Buffer, "Output Buffer");
exception
when Program_Error => null;
when Error : others =>
Fail_With_Context;
Test.Info ("Wrong exception raised in Read_Atom");
Test.Report_Exception (Error, NT.Fail);
end Read_Atom_Test;
end Test_Atom_Accessor_Exceptions;
procedure Next_And_Check
(Test : in out NT.Test;
Tested : in out Descriptor'Class;
Expected : in Events.Event;
Level : in Natural;
Context : in String := "")
is
Event : Events.Event;
begin
Tested.Next (Event);
if Event /= Expected then
if Context /= "" then
Test.Fail (Context);
end if;
Test.Fail ("Found event "
& Events.Event'Image (Event)
& ", expected "
& Events.Event'Image (Expected));
elsif Tested.Current_Level /= Level then
if Context /= "" then
Test.Fail (Context);
end if;
Test.Fail ("Found event "
& Events.Event'Image (Event)
& " at level"
& Integer'Image (Tested.Current_Level)
& ", expected"
& Integer'Image (Level));
end if;
end Next_And_Check;
procedure Next_And_Check
(Test : in out NT.Test;
Tested : in out Descriptor'Class;
Expected : in Atom;
Level : in Natural;
Context : in String := "")
is
Event : Events.Event;
begin
Tested.Next (Event);
if Event /= Events.Add_Atom then
if Context /= "" then
Test.Fail (Context);
end if;
Test.Fail ("Found event "
& Events.Event'Image (Event)
& ", expected Add_Atom");
else
Test_Tools.Test_Atom_Accessors
(Test, Tested, Expected, Level, Context);
end if;
end Next_And_Check;
function To_S_Expression (Text : String) return Caches.Reference is
begin
return To_S_Expression (To_Atom (Text));
end To_S_Expression;
function To_S_Expression (Data : Atom) return Caches.Reference is
Stream : aliased Memory_Stream;
Parser : Parsers.Stream_Parser (Stream'Access);
begin
Stream.Write (Data);
Parser.Next;
return Caches.Move (Parser);
end To_S_Expression;
-------------------
-- Memory Stream --
-------------------
overriding procedure Read
(Stream : in out Memory_Stream;
Item : out Ada.Streams.Stream_Element_Array;
Last : out Ada.Streams.Stream_Element_Offset) is
begin
Last := Item'First - 1;
while Last + 1 in Item'Range
and then Stream.Read_Pointer < Stream.Internal.Length
loop
Stream.Read_Pointer := Stream.Read_Pointer + 1;
Last := Last + 1;
Item (Last) := Stream.Internal.Element (Stream.Read_Pointer);
end loop;
end Read;
overriding procedure Write
(Stream : in out Memory_Stream;
Item : in Ada.Streams.Stream_Element_Array) is
begin
if Stream.Read_Pointer >= Stream.Internal.Length then
Stream.Internal.Soft_Reset;
Stream.Read_Pointer := 0;
end if;
Stream.Internal.Append (Item);
if not Stream.Mismatch then
for I in Item'Range loop
if Stream.Expect_Pointer + 1 > Stream.Expected.Length
or else Stream.Expected.Element (Stream.Expect_Pointer + 1)
/= Item (I)
then
Stream.Mismatch := True;
exit;
end if;
Stream.Expect_Pointer := Stream.Expect_Pointer + 1;
end loop;
end if;
end Write;
function Get_Data (Stream : Memory_Stream) return Atom is
begin
return Stream.Internal.Data;
end Get_Data;
function Unread_Data (Stream : Memory_Stream) return Atom is
begin
if Stream.Read_Pointer < Stream.Internal.Length then
return Stream.Internal.Raw_Query.Data.all
(Stream.Read_Pointer + 1 .. Stream.Internal.Length);
else
return Null_Atom;
end if;
end Unread_Data;
procedure Set_Data
(Stream : in out Memory_Stream;
Data : in Atom) is
begin
Stream.Internal.Soft_Reset;
Stream.Internal.Append (Data);
end Set_Data;
function Unread_Expected (Stream : Memory_Stream) return Atom is
begin
if Stream.Expect_Pointer < Stream.Expected.Length then
return Stream.Expected.Raw_Query.Data.all
(Stream.Expect_Pointer + 1 .. Stream.Expected.Length);
else
return Null_Atom;
end if;
end Unread_Expected;
procedure Set_Expected
(Stream : in out Memory_Stream;
Data : in Atom;
Reset_Mismatch : in Boolean := True) is
begin
Stream.Expected.Soft_Reset;
Stream.Expected.Append (Data);
Stream.Expect_Pointer := 0;
if Reset_Mismatch then
Stream.Mismatch := False;
end if;
end Set_Expected;
function Has_Mismatch (Stream : Memory_Stream) return Boolean is
begin
return Stream.Mismatch;
end Has_Mismatch;
procedure Reset_Mismatch (Stream : in out Memory_Stream) is
begin
Stream.Mismatch := False;
end Reset_Mismatch;
function Mismatch_Index (Stream : Memory_Stream) return Count is
begin
if Stream.Mismatch then
return Stream.Expect_Pointer + 1;
else
return 0;
end if;
end Mismatch_Index;
procedure Check_Stream
(Stream : in Test_Tools.Memory_Stream;
Test : in out NT.Test) is
begin
if Stream.Has_Mismatch or else Stream.Unread_Expected /= Null_Atom then
if Stream.Has_Mismatch then
Test.Fail ("Mismatch at position"
& Count'Image (Stream.Mismatch_Index));
declare
Stream_Data : Atom renames Stream.Get_Data;
begin
Test_Tools.Dump_Atom
(Test,
Stream_Data (Stream_Data'First .. Stream.Mismatch_Index - 1),
"Matching data");
Test_Tools.Dump_Atom
(Test,
Stream_Data (Stream.Mismatch_Index .. Stream_Data'Last),
"Mismatching data");
end;
end if;
if Stream.Unread_Expected /= Null_Atom then
Test.Fail;
Test_Tools.Dump_Atom
(Test,
Stream.Unread_Expected,
"Left to expect");
end if;
end if;
end Check_Stream;
end Natools.S_Expressions.Test_Tools;
|
AdaCore/ada-traits-containers | Ada | 7,595 | ads | --
-- Copyright (C) 2015-2016, AdaCore
--
-- SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
--
-- A generic and general list implementation
-- By providing appropriate values for the formal parameters, the same
-- implementation can be used for bounded and unbounded containers, or for
-- constrained and unconstrained elements.
--
-- Design: in C++ STL, none of the methods are virtual, so there is no
-- dynamic dispatching. We achieve the same here by using 'Class
-- parameters. This still let's use Ada2012 dot notation (the reason why
-- we use a tagged type, in addition to the Iterable aspect), while
-- increasing the performance (the count-with-explicit-loop goes from 0.25s
-- to 0.51s when we do not use 'Class parameters).
pragma Ada_2012;
with Conts.Cursors;
with Conts.Lists.Storage;
with Conts.Lists.Impl;
with Conts.Properties;
generic
with package Storage is new Conts.Lists.Storage.Traits (<>);
-- Describes how the nodes of the list are stored.
package Conts.Lists.Generics with SPARK_Mode is
pragma Assertion_Policy
(Pre => Suppressible, Ghost => Suppressible, Post => Ignore);
subtype Element_Type is Storage.Elements.Element_Type;
subtype Returned_Type is Storage.Elements.Returned_Type;
subtype Stored_Type is Storage.Elements.Stored_Type;
subtype Constant_Returned_Type is Storage.Elements.Constant_Returned_Type;
package Impl is new Conts.Lists.Impl (Storage);
subtype Base_List is Impl.Base_List;
subtype Cursor is Impl.Cursor;
No_Element : constant Cursor := Impl.No_Element;
use type Cursor;
procedure Append
(Self : in out Base_List'Class;
Element : Element_Type;
Count : Count_Type := 1)
renames Impl.Append;
-- Append Count copies of Element to the list.
-- Complexity: O(1)
procedure Insert
(Self : in out Base_List'Class;
Before : Cursor;
Element : Element_Type;
Count : Count_Type := 1)
renames Impl.Insert;
-- Insert Count copies of Element before the element at position Before.
-- If Before is No_Element, the copies are appended to the list.
-- Complexity: O(1)
function Length (Self : Base_List'Class) return Count_Type
renames Impl.Length;
-- Return the number of elements in the list.
-- Complexity: O(n) (in practice, constant)
function Is_Empty (Self : Base_List'Class) return Boolean
renames Impl.Is_Empty;
-- Whether the list is empty.
-- Complexity: O(1)
function Capacity (Self : Base_List'Class) return Count_Type
renames Impl.Capacity;
-- Return the maximal number of elements in the list. This will be
-- Count_Type'Last for unbounded containers.
-- Complexity: constant
procedure Clear (Self : in out Base_List'Class)
renames Impl.Clear;
-- Free the contents of the list
-- Complexity: O(n)
procedure Assign (Self : in out Base_List'Class; Source : Base_List'Class)
renames Impl.Assign;
-- Replace all elements of Self with a copy of the elements of Source.
-- When the list is controlled, this has the same behavior as calling
-- Self := Source.
-- Complexity: O(n)
function First (Self : Base_List'Class) return Cursor
renames Impl.First;
function Element
(Self : Base_List'Class; Position : Cursor) return Constant_Returned_Type
renames Impl.Element;
function Has_Element
(Self : Base_List'Class; Position : Cursor) return Boolean
renames Impl.Has_Element;
function Next
(Self : Base_List'Class; Position : Cursor) return Cursor
renames Impl.Next;
function Previous
(Self : Base_List'Class; Position : Cursor) return Cursor
renames Impl.Previous;
-- We pass the container explicitly for the sake of writing the pre
-- and post conditions.
-- Complexity: constant for all cursor operations.
procedure Next (Self : Base_List'Class; Position : in out Cursor)
renames Impl.Next;
function "=" (Left, Right : Cursor) return Boolean renames Impl."=";
use type Element_Type;
function As_Element
(Self : Base_List'Class; Position : Cursor) return Element_Type
is (Storage.Elements.To_Element (Element (Self, Position)))
with
Pre => Impl.P_Mem (Impl.Positions (Self), Position),
Post => As_Element'Result = Element
(Impl.Model (Self), Impl.P_Get (Impl.Positions (Self), Position));
pragma Annotate (GNATprove, Inline_For_Proof, As_Element);
procedure Replace_Element
(Self : in out Base_List'Class;
Position : Cursor;
Element : Element_Type)
renames Impl.Replace_Element;
-- If Position is a valid position in the container, it replaces the
-- element at that position with Element.
procedure Delete
(Self : in out Base_List'Class;
Position : in out Cursor;
Count : Count_Type := 1)
renames Impl.Delete;
-- Delete Count elements starting at Position, or all the elements starting
-- at Position if there are fewer than Count elements starting at
-- Position).
-- Finally, sets Position to the first item after the deleted ones.
-- ??? Should we provide a Copy function ?
-- This cannot be provided in this generic package, since the type could
-- be constrained and/or limited, so it has to be provided in all child
-- packages. However, when the type is controlled it is much easier to
-- just use the standard assignment operator, so providing Copy is not
-- needed (only when base type is limited)
------------------
-- for-of loops --
------------------
type List is new Base_List with null record
with Constant_Indexing => Constant_Reference,
Iterable => (First => First_Primitive,
Next => Next_Primitive,
Has_Element => Has_Element_Primitive,
Element => Element_Primitive);
function Constant_Reference
(Self : List; Position : Cursor) return Constant_Returned_Type
is (Element (Self, Position))
with
Inline,
Pre'Class => Impl.P_Mem (Impl.Positions (Self), Position);
-----------
-- Model --
-----------
-- The following subprograms are used to write loop invariants for SPARK
function Model (Self : List'Class) return Impl.M.Sequence
is (Impl.Model (Self))
with Ghost;
pragma Annotate (GNATprove, Iterable_For_Proof, "Model", Model);
function Element (S : Impl.M.Sequence; I : Count_Type) return Element_Type
renames Impl.Element;
--------------------
-- Cursors traits --
--------------------
package Cursors is
package Bidirectional is new Conts.Cursors.Bidirectional_Cursors
(Container_Type => Base_List'Class,
Cursor_Type => Cursor,
No_Element => No_Element,
First => First,
Next => Next,
Has_Element => Has_Element,
Previous => Previous);
package Forward renames Bidirectional.Forward;
end Cursors;
-------------------------
-- Getters and setters --
-------------------------
package Maps is
package Element is new Conts.Properties.Read_Only_Maps
(Cursors.Forward.Container, Cursors.Forward.Cursor,
Element_Type, As_Element);
package Constant_Returned is new Conts.Properties.Read_Only_Maps
(Cursors.Forward.Container, Cursors.Forward.Cursor,
Storage.Elements.Constant_Returned, Conts.Lists.Generics.Element);
end Maps;
end Conts.Lists.Generics;
|
emilybache/GildedRose-Refactoring-Kata | Ada | 799 | adb | with Ada.Strings.Unbounded;
use Ada.Strings.Unbounded;
package body Items is
function Integer_Image(Self : in Integer) return String is
Img : constant String := Integer'Image(Self);
begin
if Self < 0 then
return Img;
else
return Img(2 .. Img'Length);
end if;
end;
function To_String(Self : in Item) return String is
Name : constant Unbounded_String := Self.Name;
Sell_In : constant Unbounded_String := To_Unbounded_String(Integer_Image(Self.Sell_In));
Quality : constant Unbounded_String := To_Unbounded_String(Integer_Image(Self.Quality));
Ret : Unbounded_String;
begin
Append(Ret, Name);
Append(Ret, ", ");
Append(Ret, Sell_In);
Append(Ret, ", ");
Append(Ret, Quality);
return To_String(Ret);
end;
end Items;
|
stcarrez/ada-awa | Ada | 55,258 | adb | -----------------------------------------------------------------------
-- AWA.Events.Models -- AWA.Events.Models
-----------------------------------------------------------------------
-- File generated by Dynamo DO NOT MODIFY
-- Template used: templates/model/package-body.xhtml
-- Ada Generator: https://github.com/stcarrez/dynamo Version 1.4.0
-----------------------------------------------------------------------
-- Copyright (C) 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.
-----------------------------------------------------------------------
pragma Warnings (Off);
with Ada.Unchecked_Deallocation;
with Util.Beans.Objects.Time;
pragma Warnings (On);
package body AWA.Events.Models is
pragma Style_Checks ("-mrIu");
pragma Warnings (Off, "formal parameter * is not referenced");
pragma Warnings (Off, "use clause for type *");
pragma Warnings (Off, "use clause for private type *");
use type ADO.Objects.Object_Record_Access;
use type ADO.Objects.Object_Ref;
function Message_Type_Key (Id : in ADO.Identifier) return ADO.Objects.Object_Key is
Result : ADO.Objects.Object_Key (Of_Type => ADO.Objects.KEY_INTEGER,
Of_Class => MESSAGE_TYPE_DEF'Access);
begin
ADO.Objects.Set_Value (Result, Id);
return Result;
end Message_Type_Key;
function Message_Type_Key (Id : in String) return ADO.Objects.Object_Key is
Result : ADO.Objects.Object_Key (Of_Type => ADO.Objects.KEY_INTEGER,
Of_Class => MESSAGE_TYPE_DEF'Access);
begin
ADO.Objects.Set_Value (Result, Id);
return Result;
end Message_Type_Key;
function "=" (Left, Right : Message_Type_Ref'Class) return Boolean is
begin
return ADO.Objects.Object_Ref'Class (Left) = ADO.Objects.Object_Ref'Class (Right);
end "=";
procedure Set_Field (Object : in out Message_Type_Ref'Class;
Impl : out Message_Type_Access) is
Result : ADO.Objects.Object_Record_Access;
begin
Object.Prepare_Modify (Result);
Impl := Message_Type_Impl (Result.all)'Access;
end Set_Field;
-- Internal method to allocate the Object_Record instance
overriding
procedure Allocate (Object : in out Message_Type_Ref) is
Impl : Message_Type_Access;
begin
Impl := new Message_Type_Impl;
ADO.Objects.Set_Object (Object, Impl.all'Access);
end Allocate;
-- ----------------------------------------
-- Data object: Message_Type
-- ----------------------------------------
procedure Set_Id (Object : in out Message_Type_Ref;
Value : in ADO.Identifier) is
Impl : Message_Type_Access;
begin
Set_Field (Object, Impl);
ADO.Objects.Set_Field_Key_Value (Impl.all, 1, Value);
end Set_Id;
function Get_Id (Object : in Message_Type_Ref)
return ADO.Identifier is
Impl : constant Message_Type_Access
:= Message_Type_Impl (Object.Get_Object.all)'Access;
begin
return Impl.Get_Key_Value;
end Get_Id;
procedure Set_Name (Object : in out Message_Type_Ref;
Value : in String) is
Impl : Message_Type_Access;
begin
Set_Field (Object, Impl);
ADO.Objects.Set_Field_String (Impl.all, 2, Impl.Name, Value);
end Set_Name;
procedure Set_Name (Object : in out Message_Type_Ref;
Value : in Ada.Strings.Unbounded.Unbounded_String) is
Impl : Message_Type_Access;
begin
Set_Field (Object, Impl);
ADO.Objects.Set_Field_Unbounded_String (Impl.all, 2, Impl.Name, Value);
end Set_Name;
function Get_Name (Object : in Message_Type_Ref)
return String is
begin
return Ada.Strings.Unbounded.To_String (Object.Get_Name);
end Get_Name;
function Get_Name (Object : in Message_Type_Ref)
return Ada.Strings.Unbounded.Unbounded_String is
Impl : constant Message_Type_Access
:= Message_Type_Impl (Object.Get_Load_Object.all)'Access;
begin
return Impl.Name;
end Get_Name;
-- Copy of the object.
procedure Copy (Object : in Message_Type_Ref;
Into : in out Message_Type_Ref) is
Result : Message_Type_Ref;
begin
if not Object.Is_Null then
declare
Impl : constant Message_Type_Access
:= Message_Type_Impl (Object.Get_Load_Object.all)'Access;
Copy : constant Message_Type_Access
:= new Message_Type_Impl;
begin
ADO.Objects.Set_Object (Result, Copy.all'Access);
Copy.Copy (Impl.all);
Copy.Name := Impl.Name;
end;
end if;
Into := Result;
end Copy;
overriding
procedure Find (Object : in out Message_Type_Ref;
Session : in out ADO.Sessions.Session'Class;
Query : in ADO.SQL.Query'Class;
Found : out Boolean) is
Impl : constant Message_Type_Access := new Message_Type_Impl;
begin
Impl.Find (Session, Query, Found);
if Found then
ADO.Objects.Set_Object (Object, Impl.all'Access);
else
ADO.Objects.Set_Object (Object, null);
Destroy (Impl);
end if;
end Find;
procedure Load (Object : in out Message_Type_Ref;
Session : in out ADO.Sessions.Session'Class;
Id : in ADO.Identifier) is
Impl : constant Message_Type_Access := new Message_Type_Impl;
Found : Boolean;
Query : ADO.SQL.Query;
begin
Query.Bind_Param (Position => 1, Value => Id);
Query.Set_Filter ("id = ?");
Impl.Find (Session, Query, Found);
if not Found then
Destroy (Impl);
raise ADO.Objects.NOT_FOUND;
end if;
ADO.Objects.Set_Object (Object, Impl.all'Access);
end Load;
procedure Load (Object : in out Message_Type_Ref;
Session : in out ADO.Sessions.Session'Class;
Id : in ADO.Identifier;
Found : out Boolean) is
Impl : constant Message_Type_Access := new Message_Type_Impl;
Query : ADO.SQL.Query;
begin
Query.Bind_Param (Position => 1, Value => Id);
Query.Set_Filter ("id = ?");
Impl.Find (Session, Query, Found);
if not Found then
Destroy (Impl);
else
ADO.Objects.Set_Object (Object, Impl.all'Access);
end if;
end Load;
overriding
procedure Save (Object : in out Message_Type_Ref;
Session : in out ADO.Sessions.Master_Session'Class) is
Impl : ADO.Objects.Object_Record_Access := Object.Get_Object;
begin
if Impl = null then
Impl := new Message_Type_Impl;
ADO.Objects.Set_Object (Object, Impl);
end if;
if not ADO.Objects.Is_Created (Impl.all) then
Impl.Create (Session);
else
Impl.Save (Session);
end if;
end Save;
overriding
procedure Delete (Object : in out Message_Type_Ref;
Session : in out ADO.Sessions.Master_Session'Class) is
Impl : constant ADO.Objects.Object_Record_Access := Object.Get_Object;
begin
if Impl /= null then
Impl.Delete (Session);
end if;
end Delete;
-- --------------------
-- Free the object
-- --------------------
overriding
procedure Destroy (Object : access Message_Type_Impl) is
type Message_Type_Impl_Ptr is access all Message_Type_Impl;
procedure Unchecked_Free is new Ada.Unchecked_Deallocation
(Message_Type_Impl, Message_Type_Impl_Ptr);
pragma Warnings (Off, "*redundant conversion*");
Ptr : Message_Type_Impl_Ptr := Message_Type_Impl (Object.all)'Access;
pragma Warnings (On, "*redundant conversion*");
begin
Unchecked_Free (Ptr);
end Destroy;
overriding
procedure Find (Object : in out Message_Type_Impl;
Session : in out ADO.Sessions.Session'Class;
Query : in ADO.SQL.Query'Class;
Found : out Boolean) is
Stmt : ADO.Statements.Query_Statement
:= Session.Create_Statement (Query, MESSAGE_TYPE_DEF'Access);
begin
Stmt.Execute;
if Stmt.Has_Elements then
Object.Load (Stmt, Session);
Stmt.Next;
Found := not Stmt.Has_Elements;
else
Found := False;
end if;
end Find;
overriding
procedure Load (Object : in out Message_Type_Impl;
Session : in out ADO.Sessions.Session'Class) is
Found : Boolean;
Query : ADO.SQL.Query;
Id : constant ADO.Identifier := Object.Get_Key_Value;
begin
Query.Bind_Param (Position => 1, Value => Id);
Query.Set_Filter ("id = ?");
Object.Find (Session, Query, Found);
if not Found then
raise ADO.Objects.NOT_FOUND;
end if;
end Load;
overriding
procedure Save (Object : in out Message_Type_Impl;
Session : in out ADO.Sessions.Master_Session'Class) is
Stmt : ADO.Statements.Update_Statement
:= Session.Create_Statement (MESSAGE_TYPE_DEF'Access);
begin
if Object.Is_Modified (1) then
Stmt.Save_Field (Name => COL_0_1_NAME, -- id
Value => Object.Get_Key);
Object.Clear_Modified (1);
end if;
if Object.Is_Modified (2) then
Stmt.Save_Field (Name => COL_1_1_NAME, -- name
Value => Object.Name);
Object.Clear_Modified (2);
end if;
if Stmt.Has_Save_Fields then
Stmt.Set_Filter (Filter => "id = ?");
Stmt.Add_Param (Value => Object.Get_Key);
declare
Result : Integer;
begin
Stmt.Execute (Result);
if Result /= 1 then
if Result /= 0 then
raise ADO.Objects.UPDATE_ERROR;
end if;
end if;
end;
end if;
end Save;
overriding
procedure Create (Object : in out Message_Type_Impl;
Session : in out ADO.Sessions.Master_Session'Class) is
Query : ADO.Statements.Insert_Statement
:= Session.Create_Statement (MESSAGE_TYPE_DEF'Access);
Result : Integer;
begin
Session.Allocate (Id => Object);
Query.Save_Field (Name => COL_0_1_NAME, -- id
Value => Object.Get_Key);
Query.Save_Field (Name => COL_1_1_NAME, -- name
Value => Object.Name);
Query.Execute (Result);
if Result /= 1 then
raise ADO.Objects.INSERT_ERROR;
end if;
ADO.Objects.Set_Created (Object);
end Create;
overriding
procedure Delete (Object : in out Message_Type_Impl;
Session : in out ADO.Sessions.Master_Session'Class) is
Stmt : ADO.Statements.Delete_Statement
:= Session.Create_Statement (MESSAGE_TYPE_DEF'Access);
begin
Stmt.Set_Filter (Filter => "id = ?");
Stmt.Add_Param (Value => Object.Get_Key);
Stmt.Execute;
end Delete;
-- ------------------------------
-- Get the bean attribute identified by the name.
-- ------------------------------
overriding
function Get_Value (From : in Message_Type_Ref;
Name : in String) return Util.Beans.Objects.Object is
Obj : ADO.Objects.Object_Record_Access;
Impl : access Message_Type_Impl;
begin
if From.Is_Null then
return Util.Beans.Objects.Null_Object;
end if;
Obj := From.Get_Load_Object;
Impl := Message_Type_Impl (Obj.all)'Access;
if Name = "id" then
return ADO.Objects.To_Object (Impl.Get_Key);
elsif Name = "name" then
return Util.Beans.Objects.To_Object (Impl.Name);
end if;
return Util.Beans.Objects.Null_Object;
end Get_Value;
procedure List (Object : in out Message_Type_Vector;
Session : in out ADO.Sessions.Session'Class;
Query : in ADO.SQL.Query'Class) is
Stmt : ADO.Statements.Query_Statement
:= Session.Create_Statement (Query, MESSAGE_TYPE_DEF'Access);
begin
Stmt.Execute;
Message_Type_Vectors.Clear (Object);
while Stmt.Has_Elements loop
declare
Item : Message_Type_Ref;
Impl : constant Message_Type_Access := new Message_Type_Impl;
begin
Impl.Load (Stmt, Session);
ADO.Objects.Set_Object (Item, Impl.all'Access);
Object.Append (Item);
end;
Stmt.Next;
end loop;
end List;
-- ------------------------------
-- Load the object from current iterator position
-- ------------------------------
procedure Load (Object : in out Message_Type_Impl;
Stmt : in out ADO.Statements.Query_Statement'Class;
Session : in out ADO.Sessions.Session'Class) is
pragma Unreferenced (Session);
begin
Object.Set_Key_Value (Stmt.Get_Identifier (0));
Object.Name := Stmt.Get_Unbounded_String (1);
ADO.Objects.Set_Created (Object);
end Load;
function Queue_Key (Id : in ADO.Identifier) return ADO.Objects.Object_Key is
Result : ADO.Objects.Object_Key (Of_Type => ADO.Objects.KEY_INTEGER,
Of_Class => QUEUE_DEF'Access);
begin
ADO.Objects.Set_Value (Result, Id);
return Result;
end Queue_Key;
function Queue_Key (Id : in String) return ADO.Objects.Object_Key is
Result : ADO.Objects.Object_Key (Of_Type => ADO.Objects.KEY_INTEGER,
Of_Class => QUEUE_DEF'Access);
begin
ADO.Objects.Set_Value (Result, Id);
return Result;
end Queue_Key;
function "=" (Left, Right : Queue_Ref'Class) return Boolean is
begin
return ADO.Objects.Object_Ref'Class (Left) = ADO.Objects.Object_Ref'Class (Right);
end "=";
procedure Set_Field (Object : in out Queue_Ref'Class;
Impl : out Queue_Access) is
Result : ADO.Objects.Object_Record_Access;
begin
Object.Prepare_Modify (Result);
Impl := Queue_Impl (Result.all)'Access;
end Set_Field;
-- Internal method to allocate the Object_Record instance
overriding
procedure Allocate (Object : in out Queue_Ref) is
Impl : Queue_Access;
begin
Impl := new Queue_Impl;
Impl.Server_Id := 0;
ADO.Objects.Set_Object (Object, Impl.all'Access);
end Allocate;
-- ----------------------------------------
-- Data object: Queue
-- ----------------------------------------
procedure Set_Id (Object : in out Queue_Ref;
Value : in ADO.Identifier) is
Impl : Queue_Access;
begin
Set_Field (Object, Impl);
ADO.Objects.Set_Field_Key_Value (Impl.all, 1, Value);
end Set_Id;
function Get_Id (Object : in Queue_Ref)
return ADO.Identifier is
Impl : constant Queue_Access
:= Queue_Impl (Object.Get_Object.all)'Access;
begin
return Impl.Get_Key_Value;
end Get_Id;
procedure Set_Server_Id (Object : in out Queue_Ref;
Value : in Integer) is
Impl : Queue_Access;
begin
Set_Field (Object, Impl);
ADO.Objects.Set_Field_Integer (Impl.all, 2, Impl.Server_Id, Value);
end Set_Server_Id;
function Get_Server_Id (Object : in Queue_Ref)
return Integer is
Impl : constant Queue_Access
:= Queue_Impl (Object.Get_Load_Object.all)'Access;
begin
return Impl.Server_Id;
end Get_Server_Id;
procedure Set_Name (Object : in out Queue_Ref;
Value : in String) is
Impl : Queue_Access;
begin
Set_Field (Object, Impl);
ADO.Objects.Set_Field_String (Impl.all, 3, Impl.Name, Value);
end Set_Name;
procedure Set_Name (Object : in out Queue_Ref;
Value : in Ada.Strings.Unbounded.Unbounded_String) is
Impl : Queue_Access;
begin
Set_Field (Object, Impl);
ADO.Objects.Set_Field_Unbounded_String (Impl.all, 3, Impl.Name, Value);
end Set_Name;
function Get_Name (Object : in Queue_Ref)
return String is
begin
return Ada.Strings.Unbounded.To_String (Object.Get_Name);
end Get_Name;
function Get_Name (Object : in Queue_Ref)
return Ada.Strings.Unbounded.Unbounded_String is
Impl : constant Queue_Access
:= Queue_Impl (Object.Get_Load_Object.all)'Access;
begin
return Impl.Name;
end Get_Name;
-- Copy of the object.
procedure Copy (Object : in Queue_Ref;
Into : in out Queue_Ref) is
Result : Queue_Ref;
begin
if not Object.Is_Null then
declare
Impl : constant Queue_Access
:= Queue_Impl (Object.Get_Load_Object.all)'Access;
Copy : constant Queue_Access
:= new Queue_Impl;
begin
ADO.Objects.Set_Object (Result, Copy.all'Access);
Copy.Copy (Impl.all);
Copy.Server_Id := Impl.Server_Id;
Copy.Name := Impl.Name;
end;
end if;
Into := Result;
end Copy;
overriding
procedure Find (Object : in out Queue_Ref;
Session : in out ADO.Sessions.Session'Class;
Query : in ADO.SQL.Query'Class;
Found : out Boolean) is
Impl : constant Queue_Access := new Queue_Impl;
begin
Impl.Find (Session, Query, Found);
if Found then
ADO.Objects.Set_Object (Object, Impl.all'Access);
else
ADO.Objects.Set_Object (Object, null);
Destroy (Impl);
end if;
end Find;
procedure Load (Object : in out Queue_Ref;
Session : in out ADO.Sessions.Session'Class;
Id : in ADO.Identifier) is
Impl : constant Queue_Access := new Queue_Impl;
Found : Boolean;
Query : ADO.SQL.Query;
begin
Query.Bind_Param (Position => 1, Value => Id);
Query.Set_Filter ("id = ?");
Impl.Find (Session, Query, Found);
if not Found then
Destroy (Impl);
raise ADO.Objects.NOT_FOUND;
end if;
ADO.Objects.Set_Object (Object, Impl.all'Access);
end Load;
procedure Load (Object : in out Queue_Ref;
Session : in out ADO.Sessions.Session'Class;
Id : in ADO.Identifier;
Found : out Boolean) is
Impl : constant Queue_Access := new Queue_Impl;
Query : ADO.SQL.Query;
begin
Query.Bind_Param (Position => 1, Value => Id);
Query.Set_Filter ("id = ?");
Impl.Find (Session, Query, Found);
if not Found then
Destroy (Impl);
else
ADO.Objects.Set_Object (Object, Impl.all'Access);
end if;
end Load;
overriding
procedure Save (Object : in out Queue_Ref;
Session : in out ADO.Sessions.Master_Session'Class) is
Impl : ADO.Objects.Object_Record_Access := Object.Get_Object;
begin
if Impl = null then
Impl := new Queue_Impl;
ADO.Objects.Set_Object (Object, Impl);
end if;
if not ADO.Objects.Is_Created (Impl.all) then
Impl.Create (Session);
else
Impl.Save (Session);
end if;
end Save;
overriding
procedure Delete (Object : in out Queue_Ref;
Session : in out ADO.Sessions.Master_Session'Class) is
Impl : constant ADO.Objects.Object_Record_Access := Object.Get_Object;
begin
if Impl /= null then
Impl.Delete (Session);
end if;
end Delete;
-- --------------------
-- Free the object
-- --------------------
overriding
procedure Destroy (Object : access Queue_Impl) is
type Queue_Impl_Ptr is access all Queue_Impl;
procedure Unchecked_Free is new Ada.Unchecked_Deallocation
(Queue_Impl, Queue_Impl_Ptr);
pragma Warnings (Off, "*redundant conversion*");
Ptr : Queue_Impl_Ptr := Queue_Impl (Object.all)'Access;
pragma Warnings (On, "*redundant conversion*");
begin
Unchecked_Free (Ptr);
end Destroy;
overriding
procedure Find (Object : in out Queue_Impl;
Session : in out ADO.Sessions.Session'Class;
Query : in ADO.SQL.Query'Class;
Found : out Boolean) is
Stmt : ADO.Statements.Query_Statement
:= Session.Create_Statement (Query, QUEUE_DEF'Access);
begin
Stmt.Execute;
if Stmt.Has_Elements then
Object.Load (Stmt, Session);
Stmt.Next;
Found := not Stmt.Has_Elements;
else
Found := False;
end if;
end Find;
overriding
procedure Load (Object : in out Queue_Impl;
Session : in out ADO.Sessions.Session'Class) is
Found : Boolean;
Query : ADO.SQL.Query;
Id : constant ADO.Identifier := Object.Get_Key_Value;
begin
Query.Bind_Param (Position => 1, Value => Id);
Query.Set_Filter ("id = ?");
Object.Find (Session, Query, Found);
if not Found then
raise ADO.Objects.NOT_FOUND;
end if;
end Load;
overriding
procedure Save (Object : in out Queue_Impl;
Session : in out ADO.Sessions.Master_Session'Class) is
Stmt : ADO.Statements.Update_Statement
:= Session.Create_Statement (QUEUE_DEF'Access);
begin
if Object.Is_Modified (1) then
Stmt.Save_Field (Name => COL_0_2_NAME, -- id
Value => Object.Get_Key);
Object.Clear_Modified (1);
end if;
if Object.Is_Modified (2) then
Stmt.Save_Field (Name => COL_1_2_NAME, -- server_id
Value => Object.Server_Id);
Object.Clear_Modified (2);
end if;
if Object.Is_Modified (3) then
Stmt.Save_Field (Name => COL_2_2_NAME, -- name
Value => Object.Name);
Object.Clear_Modified (3);
end if;
if Stmt.Has_Save_Fields then
Stmt.Set_Filter (Filter => "id = ?");
Stmt.Add_Param (Value => Object.Get_Key);
declare
Result : Integer;
begin
Stmt.Execute (Result);
if Result /= 1 then
if Result /= 0 then
raise ADO.Objects.UPDATE_ERROR;
end if;
end if;
end;
end if;
end Save;
overriding
procedure Create (Object : in out Queue_Impl;
Session : in out ADO.Sessions.Master_Session'Class) is
Query : ADO.Statements.Insert_Statement
:= Session.Create_Statement (QUEUE_DEF'Access);
Result : Integer;
begin
Session.Allocate (Id => Object);
Query.Save_Field (Name => COL_0_2_NAME, -- id
Value => Object.Get_Key);
Query.Save_Field (Name => COL_1_2_NAME, -- server_id
Value => Object.Server_Id);
Query.Save_Field (Name => COL_2_2_NAME, -- name
Value => Object.Name);
Query.Execute (Result);
if Result /= 1 then
raise ADO.Objects.INSERT_ERROR;
end if;
ADO.Objects.Set_Created (Object);
end Create;
overriding
procedure Delete (Object : in out Queue_Impl;
Session : in out ADO.Sessions.Master_Session'Class) is
Stmt : ADO.Statements.Delete_Statement
:= Session.Create_Statement (QUEUE_DEF'Access);
begin
Stmt.Set_Filter (Filter => "id = ?");
Stmt.Add_Param (Value => Object.Get_Key);
Stmt.Execute;
end Delete;
-- ------------------------------
-- Get the bean attribute identified by the name.
-- ------------------------------
overriding
function Get_Value (From : in Queue_Ref;
Name : in String) return Util.Beans.Objects.Object is
Obj : ADO.Objects.Object_Record_Access;
Impl : access Queue_Impl;
begin
if From.Is_Null then
return Util.Beans.Objects.Null_Object;
end if;
Obj := From.Get_Load_Object;
Impl := Queue_Impl (Obj.all)'Access;
if Name = "id" then
return ADO.Objects.To_Object (Impl.Get_Key);
elsif Name = "server_id" then
return Util.Beans.Objects.To_Object (Long_Long_Integer (Impl.Server_Id));
elsif Name = "name" then
return Util.Beans.Objects.To_Object (Impl.Name);
end if;
return Util.Beans.Objects.Null_Object;
end Get_Value;
-- ------------------------------
-- Load the object from current iterator position
-- ------------------------------
procedure Load (Object : in out Queue_Impl;
Stmt : in out ADO.Statements.Query_Statement'Class;
Session : in out ADO.Sessions.Session'Class) is
pragma Unreferenced (Session);
begin
Object.Set_Key_Value (Stmt.Get_Identifier (0));
Object.Server_Id := Stmt.Get_Integer (1);
Object.Name := Stmt.Get_Unbounded_String (2);
ADO.Objects.Set_Created (Object);
end Load;
function Message_Key (Id : in ADO.Identifier) return ADO.Objects.Object_Key is
Result : ADO.Objects.Object_Key (Of_Type => ADO.Objects.KEY_INTEGER,
Of_Class => MESSAGE_DEF'Access);
begin
ADO.Objects.Set_Value (Result, Id);
return Result;
end Message_Key;
function Message_Key (Id : in String) return ADO.Objects.Object_Key is
Result : ADO.Objects.Object_Key (Of_Type => ADO.Objects.KEY_INTEGER,
Of_Class => MESSAGE_DEF'Access);
begin
ADO.Objects.Set_Value (Result, Id);
return Result;
end Message_Key;
function "=" (Left, Right : Message_Ref'Class) return Boolean is
begin
return ADO.Objects.Object_Ref'Class (Left) = ADO.Objects.Object_Ref'Class (Right);
end "=";
procedure Set_Field (Object : in out Message_Ref'Class;
Impl : out Message_Access) is
Result : ADO.Objects.Object_Record_Access;
begin
Object.Prepare_Modify (Result);
Impl := Message_Impl (Result.all)'Access;
end Set_Field;
-- Internal method to allocate the Object_Record instance
overriding
procedure Allocate (Object : in out Message_Ref) is
Impl : Message_Access;
begin
Impl := new Message_Impl;
Impl.Create_Date := ADO.DEFAULT_TIME;
Impl.Priority := 0;
Impl.Count := 0;
Impl.Server_Id := 0;
Impl.Task_Id := 0;
Impl.Status := Message_Status_Type'First;
Impl.Processing_Date.Is_Null := True;
Impl.Version := 0;
Impl.Entity_Id := ADO.NO_IDENTIFIER;
Impl.Entity_Type := 0;
Impl.Finish_Date.Is_Null := True;
ADO.Objects.Set_Object (Object, Impl.all'Access);
end Allocate;
-- ----------------------------------------
-- Data object: Message
-- ----------------------------------------
procedure Set_Id (Object : in out Message_Ref;
Value : in ADO.Identifier) is
Impl : Message_Access;
begin
Set_Field (Object, Impl);
ADO.Objects.Set_Field_Key_Value (Impl.all, 1, Value);
end Set_Id;
function Get_Id (Object : in Message_Ref)
return ADO.Identifier is
Impl : constant Message_Access
:= Message_Impl (Object.Get_Object.all)'Access;
begin
return Impl.Get_Key_Value;
end Get_Id;
procedure Set_Create_Date (Object : in out Message_Ref;
Value : in Ada.Calendar.Time) is
Impl : Message_Access;
begin
Set_Field (Object, Impl);
ADO.Objects.Set_Field_Time (Impl.all, 2, Impl.Create_Date, Value);
end Set_Create_Date;
function Get_Create_Date (Object : in Message_Ref)
return Ada.Calendar.Time is
Impl : constant Message_Access
:= Message_Impl (Object.Get_Load_Object.all)'Access;
begin
return Impl.Create_Date;
end Get_Create_Date;
procedure Set_Priority (Object : in out Message_Ref;
Value : in Integer) is
Impl : Message_Access;
begin
Set_Field (Object, Impl);
ADO.Objects.Set_Field_Integer (Impl.all, 3, Impl.Priority, Value);
end Set_Priority;
function Get_Priority (Object : in Message_Ref)
return Integer is
Impl : constant Message_Access
:= Message_Impl (Object.Get_Load_Object.all)'Access;
begin
return Impl.Priority;
end Get_Priority;
procedure Set_Count (Object : in out Message_Ref;
Value : in Integer) is
Impl : Message_Access;
begin
Set_Field (Object, Impl);
ADO.Objects.Set_Field_Integer (Impl.all, 4, Impl.Count, Value);
end Set_Count;
function Get_Count (Object : in Message_Ref)
return Integer is
Impl : constant Message_Access
:= Message_Impl (Object.Get_Load_Object.all)'Access;
begin
return Impl.Count;
end Get_Count;
procedure Set_Parameters (Object : in out Message_Ref;
Value : in String) is
Impl : Message_Access;
begin
Set_Field (Object, Impl);
ADO.Objects.Set_Field_String (Impl.all, 5, Impl.Parameters, Value);
end Set_Parameters;
procedure Set_Parameters (Object : in out Message_Ref;
Value : in Ada.Strings.Unbounded.Unbounded_String) is
Impl : Message_Access;
begin
Set_Field (Object, Impl);
ADO.Objects.Set_Field_Unbounded_String (Impl.all, 5, Impl.Parameters, Value);
end Set_Parameters;
function Get_Parameters (Object : in Message_Ref)
return String is
begin
return Ada.Strings.Unbounded.To_String (Object.Get_Parameters);
end Get_Parameters;
function Get_Parameters (Object : in Message_Ref)
return Ada.Strings.Unbounded.Unbounded_String is
Impl : constant Message_Access
:= Message_Impl (Object.Get_Load_Object.all)'Access;
begin
return Impl.Parameters;
end Get_Parameters;
procedure Set_Server_Id (Object : in out Message_Ref;
Value : in Integer) is
Impl : Message_Access;
begin
Set_Field (Object, Impl);
ADO.Objects.Set_Field_Integer (Impl.all, 6, Impl.Server_Id, Value);
end Set_Server_Id;
function Get_Server_Id (Object : in Message_Ref)
return Integer is
Impl : constant Message_Access
:= Message_Impl (Object.Get_Load_Object.all)'Access;
begin
return Impl.Server_Id;
end Get_Server_Id;
procedure Set_Task_Id (Object : in out Message_Ref;
Value : in Integer) is
Impl : Message_Access;
begin
Set_Field (Object, Impl);
ADO.Objects.Set_Field_Integer (Impl.all, 7, Impl.Task_Id, Value);
end Set_Task_Id;
function Get_Task_Id (Object : in Message_Ref)
return Integer is
Impl : constant Message_Access
:= Message_Impl (Object.Get_Load_Object.all)'Access;
begin
return Impl.Task_Id;
end Get_Task_Id;
procedure Set_Status (Object : in out Message_Ref;
Value : in Message_Status_Type) is
procedure Set_Field_Discrete is
new ADO.Objects.Set_Field_Operation
(Message_Status_Type);
Impl : Message_Access;
begin
Set_Field (Object, Impl);
Set_Field_Discrete (Impl.all, 8, Impl.Status, Value);
end Set_Status;
function Get_Status (Object : in Message_Ref)
return Message_Status_Type is
Impl : constant Message_Access
:= Message_Impl (Object.Get_Load_Object.all)'Access;
begin
return Impl.Status;
end Get_Status;
procedure Set_Processing_Date (Object : in out Message_Ref;
Value : in ADO.Nullable_Time) is
Impl : Message_Access;
begin
Set_Field (Object, Impl);
ADO.Objects.Set_Field_Time (Impl.all, 9, Impl.Processing_Date, Value);
end Set_Processing_Date;
function Get_Processing_Date (Object : in Message_Ref)
return ADO.Nullable_Time is
Impl : constant Message_Access
:= Message_Impl (Object.Get_Load_Object.all)'Access;
begin
return Impl.Processing_Date;
end Get_Processing_Date;
function Get_Version (Object : in Message_Ref)
return Integer is
Impl : constant Message_Access
:= Message_Impl (Object.Get_Load_Object.all)'Access;
begin
return Impl.Version;
end Get_Version;
procedure Set_Entity_Id (Object : in out Message_Ref;
Value : in ADO.Identifier) is
Impl : Message_Access;
begin
Set_Field (Object, Impl);
ADO.Objects.Set_Field_Identifier (Impl.all, 11, Impl.Entity_Id, Value);
end Set_Entity_Id;
function Get_Entity_Id (Object : in Message_Ref)
return ADO.Identifier is
Impl : constant Message_Access
:= Message_Impl (Object.Get_Load_Object.all)'Access;
begin
return Impl.Entity_Id;
end Get_Entity_Id;
procedure Set_Entity_Type (Object : in out Message_Ref;
Value : in ADO.Entity_Type) is
Impl : Message_Access;
begin
Set_Field (Object, Impl);
ADO.Objects.Set_Field_Entity_Type (Impl.all, 12, Impl.Entity_Type, Value);
end Set_Entity_Type;
function Get_Entity_Type (Object : in Message_Ref)
return ADO.Entity_Type is
Impl : constant Message_Access
:= Message_Impl (Object.Get_Load_Object.all)'Access;
begin
return Impl.Entity_Type;
end Get_Entity_Type;
procedure Set_Finish_Date (Object : in out Message_Ref;
Value : in ADO.Nullable_Time) is
Impl : Message_Access;
begin
Set_Field (Object, Impl);
ADO.Objects.Set_Field_Time (Impl.all, 13, Impl.Finish_Date, Value);
end Set_Finish_Date;
function Get_Finish_Date (Object : in Message_Ref)
return ADO.Nullable_Time is
Impl : constant Message_Access
:= Message_Impl (Object.Get_Load_Object.all)'Access;
begin
return Impl.Finish_Date;
end Get_Finish_Date;
procedure Set_Queue (Object : in out Message_Ref;
Value : in Queue_Ref'Class) is
Impl : Message_Access;
begin
Set_Field (Object, Impl);
ADO.Objects.Set_Field_Object (Impl.all, 14, Impl.Queue, Value);
end Set_Queue;
function Get_Queue (Object : in Message_Ref)
return Queue_Ref'Class is
Impl : constant Message_Access
:= Message_Impl (Object.Get_Load_Object.all)'Access;
begin
return Impl.Queue;
end Get_Queue;
procedure Set_Message_Type (Object : in out Message_Ref;
Value : in Message_Type_Ref'Class) is
Impl : Message_Access;
begin
Set_Field (Object, Impl);
ADO.Objects.Set_Field_Object (Impl.all, 15, Impl.Message_Type, Value);
end Set_Message_Type;
function Get_Message_Type (Object : in Message_Ref)
return Message_Type_Ref'Class is
Impl : constant Message_Access
:= Message_Impl (Object.Get_Load_Object.all)'Access;
begin
return Impl.Message_Type;
end Get_Message_Type;
procedure Set_User (Object : in out Message_Ref;
Value : in AWA.Users.Models.User_Ref'Class) is
Impl : Message_Access;
begin
Set_Field (Object, Impl);
ADO.Objects.Set_Field_Object (Impl.all, 16, Impl.User, Value);
end Set_User;
function Get_User (Object : in Message_Ref)
return AWA.Users.Models.User_Ref'Class is
Impl : constant Message_Access
:= Message_Impl (Object.Get_Load_Object.all)'Access;
begin
return Impl.User;
end Get_User;
procedure Set_Session (Object : in out Message_Ref;
Value : in AWA.Users.Models.Session_Ref'Class) is
Impl : Message_Access;
begin
Set_Field (Object, Impl);
ADO.Objects.Set_Field_Object (Impl.all, 17, Impl.Session, Value);
end Set_Session;
function Get_Session (Object : in Message_Ref)
return AWA.Users.Models.Session_Ref'Class is
Impl : constant Message_Access
:= Message_Impl (Object.Get_Load_Object.all)'Access;
begin
return Impl.Session;
end Get_Session;
-- Copy of the object.
procedure Copy (Object : in Message_Ref;
Into : in out Message_Ref) is
Result : Message_Ref;
begin
if not Object.Is_Null then
declare
Impl : constant Message_Access
:= Message_Impl (Object.Get_Load_Object.all)'Access;
Copy : constant Message_Access
:= new Message_Impl;
begin
ADO.Objects.Set_Object (Result, Copy.all'Access);
Copy.Copy (Impl.all);
Copy.Create_Date := Impl.Create_Date;
Copy.Priority := Impl.Priority;
Copy.Count := Impl.Count;
Copy.Parameters := Impl.Parameters;
Copy.Server_Id := Impl.Server_Id;
Copy.Task_Id := Impl.Task_Id;
Copy.Status := Impl.Status;
Copy.Processing_Date := Impl.Processing_Date;
Copy.Version := Impl.Version;
Copy.Entity_Id := Impl.Entity_Id;
Copy.Entity_Type := Impl.Entity_Type;
Copy.Finish_Date := Impl.Finish_Date;
Copy.Queue := Impl.Queue;
Copy.Message_Type := Impl.Message_Type;
Copy.User := Impl.User;
Copy.Session := Impl.Session;
end;
end if;
Into := Result;
end Copy;
overriding
procedure Find (Object : in out Message_Ref;
Session : in out ADO.Sessions.Session'Class;
Query : in ADO.SQL.Query'Class;
Found : out Boolean) is
Impl : constant Message_Access := new Message_Impl;
begin
Impl.Find (Session, Query, Found);
if Found then
ADO.Objects.Set_Object (Object, Impl.all'Access);
else
ADO.Objects.Set_Object (Object, null);
Destroy (Impl);
end if;
end Find;
procedure Load (Object : in out Message_Ref;
Session : in out ADO.Sessions.Session'Class;
Id : in ADO.Identifier) is
Impl : constant Message_Access := new Message_Impl;
Found : Boolean;
Query : ADO.SQL.Query;
begin
Query.Bind_Param (Position => 1, Value => Id);
Query.Set_Filter ("id = ?");
Impl.Find (Session, Query, Found);
if not Found then
Destroy (Impl);
raise ADO.Objects.NOT_FOUND;
end if;
ADO.Objects.Set_Object (Object, Impl.all'Access);
end Load;
procedure Load (Object : in out Message_Ref;
Session : in out ADO.Sessions.Session'Class;
Id : in ADO.Identifier;
Found : out Boolean) is
Impl : constant Message_Access := new Message_Impl;
Query : ADO.SQL.Query;
begin
Query.Bind_Param (Position => 1, Value => Id);
Query.Set_Filter ("id = ?");
Impl.Find (Session, Query, Found);
if not Found then
Destroy (Impl);
else
ADO.Objects.Set_Object (Object, Impl.all'Access);
end if;
end Load;
procedure Reload (Object : in out Message_Ref;
Session : in out ADO.Sessions.Session'Class;
Updated : out Boolean) is
Result : ADO.Objects.Object_Record_Access;
Impl : Message_Access;
Query : ADO.SQL.Query;
Id : ADO.Identifier;
begin
if Object.Is_Null then
raise ADO.Objects.NULL_ERROR;
end if;
Object.Prepare_Modify (Result);
Impl := Message_Impl (Result.all)'Access;
Id := ADO.Objects.Get_Key_Value (Impl.all);
Query.Bind_Param (Position => 1, Value => Id);
Query.Bind_Param (Position => 2, Value => Impl.Version);
Query.Set_Filter ("id = ? AND version != ?");
declare
Stmt : ADO.Statements.Query_Statement
:= Session.Create_Statement (Query, MESSAGE_DEF'Access);
begin
Stmt.Execute;
if Stmt.Has_Elements then
Updated := True;
Impl.Load (Stmt, Session);
else
Updated := False;
end if;
end;
end Reload;
overriding
procedure Save (Object : in out Message_Ref;
Session : in out ADO.Sessions.Master_Session'Class) is
Impl : ADO.Objects.Object_Record_Access := Object.Get_Object;
begin
if Impl = null then
Impl := new Message_Impl;
ADO.Objects.Set_Object (Object, Impl);
end if;
if not ADO.Objects.Is_Created (Impl.all) then
Impl.Create (Session);
else
Impl.Save (Session);
end if;
end Save;
overriding
procedure Delete (Object : in out Message_Ref;
Session : in out ADO.Sessions.Master_Session'Class) is
Impl : constant ADO.Objects.Object_Record_Access := Object.Get_Object;
begin
if Impl /= null then
Impl.Delete (Session);
end if;
end Delete;
-- --------------------
-- Free the object
-- --------------------
overriding
procedure Destroy (Object : access Message_Impl) is
type Message_Impl_Ptr is access all Message_Impl;
procedure Unchecked_Free is new Ada.Unchecked_Deallocation
(Message_Impl, Message_Impl_Ptr);
pragma Warnings (Off, "*redundant conversion*");
Ptr : Message_Impl_Ptr := Message_Impl (Object.all)'Access;
pragma Warnings (On, "*redundant conversion*");
begin
Unchecked_Free (Ptr);
end Destroy;
overriding
procedure Find (Object : in out Message_Impl;
Session : in out ADO.Sessions.Session'Class;
Query : in ADO.SQL.Query'Class;
Found : out Boolean) is
Stmt : ADO.Statements.Query_Statement
:= Session.Create_Statement (Query, MESSAGE_DEF'Access);
begin
Stmt.Execute;
if Stmt.Has_Elements then
Object.Load (Stmt, Session);
Stmt.Next;
Found := not Stmt.Has_Elements;
else
Found := False;
end if;
end Find;
overriding
procedure Load (Object : in out Message_Impl;
Session : in out ADO.Sessions.Session'Class) is
Found : Boolean;
Query : ADO.SQL.Query;
Id : constant ADO.Identifier := Object.Get_Key_Value;
begin
Query.Bind_Param (Position => 1, Value => Id);
Query.Set_Filter ("id = ?");
Object.Find (Session, Query, Found);
if not Found then
raise ADO.Objects.NOT_FOUND;
end if;
end Load;
overriding
procedure Save (Object : in out Message_Impl;
Session : in out ADO.Sessions.Master_Session'Class) is
Stmt : ADO.Statements.Update_Statement
:= Session.Create_Statement (MESSAGE_DEF'Access);
begin
if Object.Is_Modified (1) then
Stmt.Save_Field (Name => COL_0_3_NAME, -- id
Value => Object.Get_Key);
Object.Clear_Modified (1);
end if;
if Object.Is_Modified (2) then
Stmt.Save_Field (Name => COL_1_3_NAME, -- create_date
Value => Object.Create_Date);
Object.Clear_Modified (2);
end if;
if Object.Is_Modified (3) then
Stmt.Save_Field (Name => COL_2_3_NAME, -- priority
Value => Object.Priority);
Object.Clear_Modified (3);
end if;
if Object.Is_Modified (4) then
Stmt.Save_Field (Name => COL_3_3_NAME, -- count
Value => Object.Count);
Object.Clear_Modified (4);
end if;
if Object.Is_Modified (5) then
Stmt.Save_Field (Name => COL_4_3_NAME, -- parameters
Value => Object.Parameters);
Object.Clear_Modified (5);
end if;
if Object.Is_Modified (6) then
Stmt.Save_Field (Name => COL_5_3_NAME, -- server_id
Value => Object.Server_Id);
Object.Clear_Modified (6);
end if;
if Object.Is_Modified (7) then
Stmt.Save_Field (Name => COL_6_3_NAME, -- task_id
Value => Object.Task_Id);
Object.Clear_Modified (7);
end if;
if Object.Is_Modified (8) then
Stmt.Save_Field (Name => COL_7_3_NAME, -- status
Value => Integer (Message_Status_Type'Enum_Rep (Object.Status)));
Object.Clear_Modified (8);
end if;
if Object.Is_Modified (9) then
Stmt.Save_Field (Name => COL_8_3_NAME, -- processing_date
Value => Object.Processing_Date);
Object.Clear_Modified (9);
end if;
if Object.Is_Modified (11) then
Stmt.Save_Field (Name => COL_10_3_NAME, -- entity_id
Value => Object.Entity_Id);
Object.Clear_Modified (11);
end if;
if Object.Is_Modified (12) then
Stmt.Save_Field (Name => COL_11_3_NAME, -- entity_type
Value => Object.Entity_Type);
Object.Clear_Modified (12);
end if;
if Object.Is_Modified (13) then
Stmt.Save_Field (Name => COL_12_3_NAME, -- finish_date
Value => Object.Finish_Date);
Object.Clear_Modified (13);
end if;
if Object.Is_Modified (14) then
Stmt.Save_Field (Name => COL_13_3_NAME, -- queue_id
Value => Object.Queue);
Object.Clear_Modified (14);
end if;
if Object.Is_Modified (15) then
Stmt.Save_Field (Name => COL_14_3_NAME, -- message_type_id
Value => Object.Message_Type);
Object.Clear_Modified (15);
end if;
if Object.Is_Modified (16) then
Stmt.Save_Field (Name => COL_15_3_NAME, -- user_id
Value => Object.User);
Object.Clear_Modified (16);
end if;
if Object.Is_Modified (17) then
Stmt.Save_Field (Name => COL_16_3_NAME, -- session_id
Value => Object.Session);
Object.Clear_Modified (17);
end if;
if Stmt.Has_Save_Fields then
Object.Version := Object.Version + 1;
Stmt.Save_Field (Name => "version",
Value => Object.Version);
Stmt.Set_Filter (Filter => "id = ? and version = ?");
Stmt.Add_Param (Value => Object.Get_Key);
Stmt.Add_Param (Value => Object.Version - 1);
declare
Result : Integer;
begin
Stmt.Execute (Result);
if Result /= 1 then
if Result /= 0 then
raise ADO.Objects.UPDATE_ERROR;
else
raise ADO.Objects.LAZY_LOCK;
end if;
end if;
end;
end if;
end Save;
overriding
procedure Create (Object : in out Message_Impl;
Session : in out ADO.Sessions.Master_Session'Class) is
Query : ADO.Statements.Insert_Statement
:= Session.Create_Statement (MESSAGE_DEF'Access);
Result : Integer;
begin
Object.Version := 1;
Session.Allocate (Id => Object);
Query.Save_Field (Name => COL_0_3_NAME, -- id
Value => Object.Get_Key);
Query.Save_Field (Name => COL_1_3_NAME, -- create_date
Value => Object.Create_Date);
Query.Save_Field (Name => COL_2_3_NAME, -- priority
Value => Object.Priority);
Query.Save_Field (Name => COL_3_3_NAME, -- count
Value => Object.Count);
Query.Save_Field (Name => COL_4_3_NAME, -- parameters
Value => Object.Parameters);
Query.Save_Field (Name => COL_5_3_NAME, -- server_id
Value => Object.Server_Id);
Query.Save_Field (Name => COL_6_3_NAME, -- task_id
Value => Object.Task_Id);
Query.Save_Field (Name => COL_7_3_NAME, -- status
Value => Integer (Message_Status_Type'Enum_Rep (Object.Status)));
Query.Save_Field (Name => COL_8_3_NAME, -- processing_date
Value => Object.Processing_Date);
Query.Save_Field (Name => COL_9_3_NAME, -- version
Value => Object.Version);
Query.Save_Field (Name => COL_10_3_NAME, -- entity_id
Value => Object.Entity_Id);
Query.Save_Field (Name => COL_11_3_NAME, -- entity_type
Value => Object.Entity_Type);
Query.Save_Field (Name => COL_12_3_NAME, -- finish_date
Value => Object.Finish_Date);
Query.Save_Field (Name => COL_13_3_NAME, -- queue_id
Value => Object.Queue);
Query.Save_Field (Name => COL_14_3_NAME, -- message_type_id
Value => Object.Message_Type);
Query.Save_Field (Name => COL_15_3_NAME, -- user_id
Value => Object.User);
Query.Save_Field (Name => COL_16_3_NAME, -- session_id
Value => Object.Session);
Query.Execute (Result);
if Result /= 1 then
raise ADO.Objects.INSERT_ERROR;
end if;
ADO.Objects.Set_Created (Object);
end Create;
overriding
procedure Delete (Object : in out Message_Impl;
Session : in out ADO.Sessions.Master_Session'Class) is
Stmt : ADO.Statements.Delete_Statement
:= Session.Create_Statement (MESSAGE_DEF'Access);
begin
Stmt.Set_Filter (Filter => "id = ?");
Stmt.Add_Param (Value => Object.Get_Key);
Stmt.Execute;
end Delete;
-- ------------------------------
-- Get the bean attribute identified by the name.
-- ------------------------------
overriding
function Get_Value (From : in Message_Ref;
Name : in String) return Util.Beans.Objects.Object is
Obj : ADO.Objects.Object_Record_Access;
Impl : access Message_Impl;
begin
if From.Is_Null then
return Util.Beans.Objects.Null_Object;
end if;
Obj := From.Get_Load_Object;
Impl := Message_Impl (Obj.all)'Access;
if Name = "id" then
return ADO.Objects.To_Object (Impl.Get_Key);
elsif Name = "create_date" then
return Util.Beans.Objects.Time.To_Object (Impl.Create_Date);
elsif Name = "priority" then
return Util.Beans.Objects.To_Object (Long_Long_Integer (Impl.Priority));
elsif Name = "count" then
return Util.Beans.Objects.To_Object (Long_Long_Integer (Impl.Count));
elsif Name = "parameters" then
return Util.Beans.Objects.To_Object (Impl.Parameters);
elsif Name = "server_id" then
return Util.Beans.Objects.To_Object (Long_Long_Integer (Impl.Server_Id));
elsif Name = "task_id" then
return Util.Beans.Objects.To_Object (Long_Long_Integer (Impl.Task_Id));
elsif Name = "status" then
return Message_Status_Type_Objects.To_Object (Impl.Status);
elsif Name = "processing_date" then
if Impl.Processing_Date.Is_Null then
return Util.Beans.Objects.Null_Object;
else
return Util.Beans.Objects.Time.To_Object (Impl.Processing_Date.Value);
end if;
elsif Name = "entity_id" then
return Util.Beans.Objects.To_Object (Long_Long_Integer (Impl.Entity_Id));
elsif Name = "entity_type" then
return Util.Beans.Objects.To_Object (Long_Long_Integer (Impl.Entity_Type));
elsif Name = "finish_date" then
if Impl.Finish_Date.Is_Null then
return Util.Beans.Objects.Null_Object;
else
return Util.Beans.Objects.Time.To_Object (Impl.Finish_Date.Value);
end if;
end if;
return Util.Beans.Objects.Null_Object;
end Get_Value;
procedure List (Object : in out Message_Vector;
Session : in out ADO.Sessions.Session'Class;
Query : in ADO.SQL.Query'Class) is
Stmt : ADO.Statements.Query_Statement
:= Session.Create_Statement (Query, MESSAGE_DEF'Access);
begin
Stmt.Execute;
Message_Vectors.Clear (Object);
while Stmt.Has_Elements loop
declare
Item : Message_Ref;
Impl : constant Message_Access := new Message_Impl;
begin
Impl.Load (Stmt, Session);
ADO.Objects.Set_Object (Item, Impl.all'Access);
Object.Append (Item);
end;
Stmt.Next;
end loop;
end List;
-- ------------------------------
-- Load the object from current iterator position
-- ------------------------------
procedure Load (Object : in out Message_Impl;
Stmt : in out ADO.Statements.Query_Statement'Class;
Session : in out ADO.Sessions.Session'Class) is
begin
Object.Set_Key_Value (Stmt.Get_Identifier (0));
Object.Create_Date := Stmt.Get_Time (1);
Object.Priority := Stmt.Get_Integer (2);
Object.Count := Stmt.Get_Integer (3);
Object.Parameters := Stmt.Get_Unbounded_String (4);
Object.Server_Id := Stmt.Get_Integer (5);
Object.Task_Id := Stmt.Get_Integer (6);
Object.Status := Message_Status_Type'Enum_Val (Stmt.Get_Integer (7));
Object.Processing_Date := Stmt.Get_Nullable_Time (8);
Object.Entity_Id := Stmt.Get_Identifier (10);
Object.Entity_Type := ADO.Entity_Type (Stmt.Get_Integer (11));
Object.Finish_Date := Stmt.Get_Nullable_Time (12);
if not Stmt.Is_Null (13) then
Object.Queue.Set_Key_Value (Stmt.Get_Identifier (13), Session);
end if;
if not Stmt.Is_Null (14) then
Object.Message_Type.Set_Key_Value (Stmt.Get_Identifier (14), Session);
end if;
if not Stmt.Is_Null (15) then
Object.User.Set_Key_Value (Stmt.Get_Identifier (15), Session);
end if;
if not Stmt.Is_Null (16) then
Object.Session.Set_Key_Value (Stmt.Get_Identifier (16), Session);
end if;
Object.Version := Stmt.Get_Integer (9);
ADO.Objects.Set_Created (Object);
end Load;
end AWA.Events.Models;
|
reznikmm/matreshka | Ada | 6,960 | 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.User_Index_Mark_Elements is
------------
-- Create --
------------
overriding function Create
(Parameters : not null access Matreshka.DOM_Elements.Element_L2_Parameters)
return Text_User_Index_Mark_Element_Node is
begin
return Self : Text_User_Index_Mark_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_User_Index_Mark_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_User_Index_Mark
(ODF.DOM.Text_User_Index_Mark_Elements.ODF_Text_User_Index_Mark_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_User_Index_Mark_Element_Node)
return League.Strings.Universal_String
is
pragma Unreferenced (Self);
begin
return Matreshka.ODF_String_Constants.User_Index_Mark_Element;
end Get_Local_Name;
----------------
-- Leave_Node --
----------------
overriding procedure Leave_Node
(Self : not null access Text_User_Index_Mark_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_User_Index_Mark
(ODF.DOM.Text_User_Index_Mark_Elements.ODF_Text_User_Index_Mark_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_User_Index_Mark_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_User_Index_Mark
(Visitor,
ODF.DOM.Text_User_Index_Mark_Elements.ODF_Text_User_Index_Mark_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.User_Index_Mark_Element,
Text_User_Index_Mark_Element_Node'Tag);
end Matreshka.ODF_Text.User_Index_Mark_Elements;
|
micahwelf/FLTK-Ada | Ada | 4,695 | adb |
with
Interfaces.C.Strings,
System;
use type
System.Address;
package body FLTK.Widgets.Clocks.Updated is
procedure clock_set_draw_hook
(W, D : in System.Address);
pragma Import (C, clock_set_draw_hook, "clock_set_draw_hook");
pragma Inline (clock_set_draw_hook);
procedure clock_set_handle_hook
(W, H : in System.Address);
pragma Import (C, clock_set_handle_hook, "clock_set_handle_hook");
pragma Inline (clock_set_handle_hook);
function new_fl_clock
(X, Y, W, H : in Interfaces.C.int;
Text : in Interfaces.C.char_array)
return System.Address;
pragma Import (C, new_fl_clock, "new_fl_clock");
pragma Inline (new_fl_clock);
function new_fl_clock2
(K : in Interfaces.C.unsigned_char;
X, Y, W, H : in Interfaces.C.int;
Text : in Interfaces.C.char_array)
return System.Address;
pragma Import (C, new_fl_clock2, "new_fl_clock2");
pragma Inline (new_fl_clock2);
procedure free_fl_clock
(F : in System.Address);
pragma Import (C, free_fl_clock, "free_fl_clock");
pragma Inline (free_fl_clock);
procedure fl_clock_draw
(W : in System.Address);
pragma Import (C, fl_clock_draw, "fl_clock_draw");
pragma Inline (fl_clock_draw);
procedure fl_clock_draw2
(C : in System.Address;
X, Y, W, H : in Interfaces.C.int);
pragma Import (C, fl_clock_draw2, "fl_clock_draw2");
pragma Inline (fl_clock_draw2);
function fl_clock_handle
(W : in System.Address;
E : in Interfaces.C.int)
return Interfaces.C.int;
pragma Import (C, fl_clock_handle, "fl_clock_handle");
pragma Inline (fl_clock_handle);
procedure Finalize
(This : in out Updated_Clock) is
begin
if This.Void_Ptr /= System.Null_Address and then
This in Updated_Clock'Class
then
free_fl_clock (This.Void_Ptr);
This.Void_Ptr := System.Null_Address;
end if;
Finalize (Clock (This));
end Finalize;
package body Forge is
function Create
(X, Y, W, H : in Integer;
Text : in String)
return Updated_Clock is
begin
return This : Updated_Clock do
This.Void_Ptr := new_fl_clock
(Interfaces.C.int (X),
Interfaces.C.int (Y),
Interfaces.C.int (W),
Interfaces.C.int (H),
Interfaces.C.To_C (Text));
fl_widget_set_user_data
(This.Void_Ptr,
Widget_Convert.To_Address (This'Unchecked_Access));
clock_set_draw_hook (This.Void_Ptr, Draw_Hook'Address);
clock_set_handle_hook (This.Void_Ptr, Handle_Hook'Address);
end return;
end Create;
function Create
(Kind : in Box_Kind;
X, Y, W, H : in Integer;
Text : in String)
return Updated_Clock is
begin
return This : Updated_Clock do
This.Void_Ptr := new_fl_clock2
(Box_Kind'Pos (Kind),
Interfaces.C.int (X),
Interfaces.C.int (Y),
Interfaces.C.int (W),
Interfaces.C.int (H),
Interfaces.C.To_C (Text));
fl_widget_set_user_data
(This.Void_Ptr,
Widget_Convert.To_Address (This'Unchecked_Access));
clock_set_draw_hook (This.Void_Ptr, Draw_Hook'Address);
clock_set_handle_hook (This.Void_Ptr, Handle_Hook'Address);
end return;
end Create;
end Forge;
procedure Draw
(This : in out Updated_Clock) is
begin
fl_clock_draw (This.Void_Ptr);
end Draw;
procedure Draw
(This : in out Clock;
X, Y, W, H : in Integer) is
begin
fl_clock_draw2
(This.Void_Ptr,
Interfaces.C.int (X),
Interfaces.C.int (Y),
Interfaces.C.int (W),
Interfaces.C.int (H));
end Draw;
function Handle
(This : in out Updated_Clock;
Event : in Event_Kind)
return Event_Outcome is
begin
return Event_Outcome'Val
(fl_clock_handle (This.Void_Ptr, Event_Kind'Pos (Event)));
end Handle;
end FLTK.Widgets.Clocks.Updated;
|
DrenfongWong/tkm-rpc | Ada | 654 | adb | with Tkmrpc.Servers.Ike;
with Tkmrpc.Response.Ike.Tkm_Reset.Convert;
package body Tkmrpc.Operation_Handlers.Ike.Tkm_Reset is
-------------------------------------------------------------------------
procedure Handle (Req : Request.Data_Type; Res : out Response.Data_Type) is
pragma Unreferenced (Req);
Specific_Res : Response.Ike.Tkm_Reset.Response_Type;
begin
Specific_Res := Response.Ike.Tkm_Reset.Null_Response;
Servers.Ike.Tkm_Reset (Result => Specific_Res.Header.Result);
Res := Response.Ike.Tkm_Reset.Convert.To_Response (S => Specific_Res);
end Handle;
end Tkmrpc.Operation_Handlers.Ike.Tkm_Reset;
|
charlie5/lace | Ada | 8,129 | ads | with
gel.remote.World,
gel.World,
gel.Camera,
gel.Keyboard,
gel.Mouse,
gel.Sprite,
gel.Dolly,
gel.Window,
openGL.Renderer.lean,
openGL.Font,
lace.Event,
lace.Response,
lace.Subject,
lace.Observer,
lace.Subject_and_deferred_Observer,
ada.Containers.Vectors;
package gel.Applet
--
-- Provides an application model, configured with a single window.
--
is
type Item is limited new lace.Subject_and_deferred_Observer.item with private;
type View is access all Item'Class;
----------
--- Forge
--
package Forge
is
function to_Applet (Name : in String;
use_Window : in gel.Window.view) return Item;
function new_Applet (Name : in String;
use_Window : in gel.Window.view) return View;
end Forge;
overriding
procedure destroy (Self : in out Item);
procedure free (Self : in out View);
---------------
--- Attributes
--
function is_Open (Self : in Item) return Boolean;
function Window (Self : in Item) return gel.Window.view;
function Renderer (Self : in Item) return openGL.Renderer.lean.view;
function Keyboard (Self : in Item) return access gel.Keyboard.item'Class;
function Mouse (Self : in Item) return access gel.Mouse .item'Class;
function Dolly (Self : access Item) return gel.Dolly.view;
function last_Keypress (Self : access Item) return gel.Keyboard.Key;
function world_Count (Self : in Item) return Natural;
function Worlds (Self : in Item) return gel.World.views;
function World (Self : in Item; Id : in world_Id := 1) return gel.World.view;
function World_as_iFace (Self : in Item; Id : in world_Id := 1) return gel.remote.World.view;
function Camera (Self : in Item; world_Id : in gel.world_Id := 1;
camera_Id : in gel.camera_Id := 1) return gel.Camera.view;
function Font (Self : in Item) return opengl.Font.font_Id;
function titles_Font (Self : in Item) return opengl.Font.font_Id;
---------------------------------
--- Add a new world and camera(s)
--
use type gel.Camera.view;
package camera_Vectors is new ada.Containers.Vectors (Positive, gel.Camera.view);
subtype camera_Vector is camera_Vectors.Vector;
type world_Info is
record
World : gel.World.view;
Cameras : camera_Vector;
end record;
type world_Info_view is access all world_Info;
procedure add (Self : in out Item; the_World : in world_Info_view);
procedure add_new_World (Self : in out Item; Name : in String;
space_Kind : in physics.space_Kind);
function new_World (Self : access Item; Name : in String;
space_Kind : in physics.space_Kind) return gel.World.view;
---------------
--- Operations
--
use Math;
procedure evolve_all_Worlds (Self : in out Item; By : in Duration);
procedure add (Self : in out Item; the_Sprite : in gel.Sprite.view);
procedure add (Self : in out Item; the_Sprite : in gel.Sprite.view;
at_site : in Vector_3);
procedure Dolly_is (Self : access Item; Now : in gel.Dolly.view);
procedure enable_simple_Dolly (Self : access Item; in_World : in world_Id);
procedure enable_following_Dolly (Self : access Item; Follow : in gel.Sprite.view);
procedure enable_Mouse (Self : access Item; detect_Motion : in Boolean);
procedure prepare (Self : access Item) is null;
procedure freshen (Self : in out Item);
--
-- processes window events and then redraws the window.
procedure take_Screenshot (Self : in out Item; Filename : in String);
procedure request_Quit (Self : in out Item);
----------
--- Events
--
function local_Subject_and_Observer
(Self : access Item) return lace.Subject_and_deferred_Observer.view;
function local_Subject (Self : access Item) return lace.Subject.view;
function local_Observer (Self : access Item) return lace.Observer.view;
private
use type Sprite.view;
package sprite_Vectors is new ada.containers.Vectors (Positive, Sprite.view);
-------------------
--- Event Responses
--
type applet_event_Response is abstract new lace.Response.item with
record
Applet : gel.Applet.view;
end record;
-- 'add_new_Sprite' Response
--
type add_new_Sprite is new applet_event_Response with null record;
overriding
function Name (Self : in add_new_Sprite) return String;
overriding
procedure respond (Self : in out add_new_Sprite; to_Event : in lace.Event.item'Class);
the_add_new_sprite_Response : aliased add_new_Sprite;
-- 'Keyboard' Responses
--
type key_press_Response is new applet_event_Response with null record;
overriding
procedure respond (Self : in out key_press_Response; to_Event : in lace.Event.item'Class);
type key_release_Response is new applet_event_Response with null record;
overriding
procedure respond (Self : in out key_release_Response; to_Event : in lace.Event.item'Class);
-- 'Mouse' Responses
--
type button_press_Response is new applet_event_Response with null record;
overriding
procedure respond (Self : in out button_press_Response; to_Event : in lace.Event.item'Class);
type button_release_Response is new applet_event_Response with null record;
overriding
procedure respond (Self : in out button_release_Response; to_Event : in lace.Event.item'Class);
type mouse_motion_Response is new applet_event_Response with null record;
overriding
procedure respond (Self : in out mouse_motion_Response; to_Event : in lace.Event.item'Class);
-- 'Screen' Resize Response
--
type resize_event_Response is new applet_event_Response with null record;
overriding
procedure respond (Self : in out resize_event_Response; to_Event : in lace.Event.Item'Class);
----------------
--- world_Vector
--
use type gel.World.view;
package world_Vectors is new ada.Containers.Vectors (Positive, world_Info_view);
subtype world_Vector is world_Vectors.Vector;
--------------
-- Applet Item
--
type Item is limited new lace.Subject_and_deferred_Observer.item with
record
local_Subject_and_Observer : lace.Subject_and_deferred_Observer.view := new lace.Subject_and_deferred_Observer.item;
Worlds : World_Vector;
Window : gel.Window.view;
resize_Response : aliased applet.resize_event_Response;
Keyboard : access gel.Keyboard.item'Class;
key_press_Response : aliased applet.key_press_Response;
key_release_Response : aliased applet.key_release_Response;
Mouse : access gel.Mouse.item'Class;
button_press_Response : aliased applet.button_press_Response;
button_release_Response : aliased applet.button_release_Response;
mouse_motion_Response : aliased applet.mouse_motion_Response;
Renderer : openGL.Renderer.lean.view;
Font : opengl.Font.font_Id := (openGL.to_Asset ("assets/opengl/font/LiberationMono-Regular.ttf"), 30);
titles_Font : opengl.Font.font_Id := (openGL.to_Asset ("assets/opengl/font/LiberationMono-Regular.ttf"), 40);
is_capturing_Video : Boolean := False;
Dolly : gel.Dolly.view;
last_pressed_Key : gel.Keyboard.Key := gel.Keyboard.Nil;
key_Focus : gel.Sprite.view;
quit_Requested : Boolean := False;
end record;
global_Window : gel.Window.view;
end gel.Applet;
|
reznikmm/torrent | Ada | 500 | adb | -- Copyright (c) 2020 Maxim Reznik <[email protected]>
--
-- SPDX-License-Identifier: MIT
-- License-Filename: LICENSE
-------------------------------------------------------------
package body Torrent.Shutdown is
protected body Signal is
entry Wait_SIGINT when SIGINT_Triggered is
begin
SIGINT_Triggered := False;
end Wait_SIGINT;
procedure Handle is
begin
SIGINT_Triggered := True;
end Handle;
end Signal;
end Torrent.Shutdown;
|
Fabien-Chouteau/Ada_Drivers_Library | Ada | 5,412 | ads | -- This spec has been automatically generated from cm4.svd
pragma Restrictions (No_Elaboration_Code);
pragma Ada_2012;
pragma Style_Checks (Off);
with HAL;
with System;
-- 24Bit System Tick Timer for use in RTOS
package Cortex_M_SVD.SysTick is
pragma Preelaborate;
---------------
-- Registers --
---------------
-- Enable SysTick Timer
type CSR_ENABLE_Field is
(
-- counter disabled
Disable,
-- counter enabled
Enable)
with Size => 1;
for CSR_ENABLE_Field use
(Disable => 0,
Enable => 1);
-- Generate Tick Interrupt
type CSR_TICKINT_Field is
(
-- Counting down to zero does not assert the SysTick exception request
Enable,
-- Counting down to zero asserts the SysTick exception request
Disable)
with Size => 1;
for CSR_TICKINT_Field use
(Enable => 0,
Disable => 1);
-- Source to count from
type CSR_CLKSOURCE_Field is
(
-- External Clock
External_Clk,
-- CPU Clock
Cpu_Clk)
with Size => 1;
for CSR_CLKSOURCE_Field use
(External_Clk => 0,
Cpu_Clk => 1);
-- SysTick Control and Status Register
type SYST_CSR_Register is record
-- Enable SysTick Timer
ENABLE : CSR_ENABLE_Field := Cortex_M_SVD.SysTick.Disable;
-- Generate Tick Interrupt
TICKINT : CSR_TICKINT_Field := Cortex_M_SVD.SysTick.Enable;
-- Source to count from
CLKSOURCE : CSR_CLKSOURCE_Field := Cortex_M_SVD.SysTick.Cpu_Clk;
-- unspecified
Reserved_3_15 : HAL.UInt13 := 16#0#;
-- SysTick counted to zero
COUNTFLAG : Boolean := False;
-- unspecified
Reserved_17_31 : HAL.UInt15 := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for SYST_CSR_Register use record
ENABLE at 0 range 0 .. 0;
TICKINT at 0 range 1 .. 1;
CLKSOURCE at 0 range 2 .. 2;
Reserved_3_15 at 0 range 3 .. 15;
COUNTFLAG at 0 range 16 .. 16;
Reserved_17_31 at 0 range 17 .. 31;
end record;
subtype SYST_RVR_RELOAD_Field is HAL.UInt24;
-- SysTick Reload Value Register
type SYST_RVR_Register is record
-- Value to auto reload SysTick after reaching zero
RELOAD : SYST_RVR_RELOAD_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 SYST_RVR_Register use record
RELOAD at 0 range 0 .. 23;
Reserved_24_31 at 0 range 24 .. 31;
end record;
subtype SYST_CVR_CURRENT_Field is HAL.UInt24;
-- SysTick Current Value Register
type SYST_CVR_Register is record
-- Current value
CURRENT : SYST_CVR_CURRENT_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 SYST_CVR_Register use record
CURRENT at 0 range 0 .. 23;
Reserved_24_31 at 0 range 24 .. 31;
end record;
subtype SYST_CALIB_TENMS_Field is HAL.UInt24;
-- Clock Skew
type CALIB_SKEW_Field is
(
-- 10ms calibration value is exact
Exact,
-- 10ms calibration value is inexact, because of the clock frequency
Inexact)
with Size => 1;
for CALIB_SKEW_Field use
(Exact => 0,
Inexact => 1);
-- No Ref
type CALIB_NOREF_Field is
(
-- Ref Clk available
Ref_Clk_Available,
-- Ref Clk not available
Ref_Clk_Unavailable)
with Size => 1;
for CALIB_NOREF_Field use
(Ref_Clk_Available => 0,
Ref_Clk_Unavailable => 1);
-- SysTick Calibration Value Register
type SYST_CALIB_Register is record
-- Read-only. Reload value to use for 10ms timing
TENMS : SYST_CALIB_TENMS_Field;
-- unspecified
Reserved_24_29 : HAL.UInt6;
-- Read-only. Clock Skew
SKEW : CALIB_SKEW_Field;
-- Read-only. No Ref
NOREF : CALIB_NOREF_Field;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for SYST_CALIB_Register use record
TENMS at 0 range 0 .. 23;
Reserved_24_29 at 0 range 24 .. 29;
SKEW at 0 range 30 .. 30;
NOREF at 0 range 31 .. 31;
end record;
-----------------
-- Peripherals --
-----------------
-- 24Bit System Tick Timer for use in RTOS
type SysTick_Peripheral is record
-- SysTick Control and Status Register
CSR : aliased SYST_CSR_Register;
-- SysTick Reload Value Register
RVR : aliased SYST_RVR_Register;
-- SysTick Current Value Register
CVR : aliased SYST_CVR_Register;
-- SysTick Calibration Value Register
CALIB : aliased SYST_CALIB_Register;
end record
with Volatile;
for SysTick_Peripheral use record
CSR at 16#0# range 0 .. 31;
RVR at 16#4# range 0 .. 31;
CVR at 16#8# range 0 .. 31;
CALIB at 16#C# range 0 .. 31;
end record;
-- 24Bit System Tick Timer for use in RTOS
SysTick_Periph : aliased SysTick_Peripheral
with Import, Address => SysTick_Base;
end Cortex_M_SVD.SysTick;
|
zhmu/ananas | Ada | 710 | adb | -- { dg-do compile }
-- { dg-options "-gnata" }
procedure Predicate11 is
type T_BYTES is new Integer range 0 .. 2**15 - 1 with Size => 32;
subtype TYPE5_SCALAR is T_BYTES
with Dynamic_Predicate => TYPE5_SCALAR mod 4 = 0;
subtype Cond is Integer
with dynamic_predicate => (if cond < 5 then false else True);
Thing1 : Type5_Scalar := 7; -- { dg-warning "check will fail at run time" }
function OK (C :Type5_scalar) return Boolean is (True);
Thing2 : Type5_Scalar;
Thing3 : Cond;
begin
if not OK (7) then raise Program_Error; end if; -- { dg-warning "check will fail at run time" }
Thing2 := 8;
Thing3 := 1; -- { dg-warning "check will fail at run time" }
end;
|
reznikmm/matreshka | Ada | 3,633 | 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 XML.DOM.Elements;
package ODF.DOM.Elements.Table.Table_Cell is
type ODF_Table_Table_Cell is
new XML.DOM.Elements.DOM_Element with private;
private
type ODF_Table_Table_Cell is
new XML.DOM.Elements.DOM_Element with null record;
end ODF.DOM.Elements.Table.Table_Cell;
|
GPUWorks/lumen2 | Ada | 3,466 | ads |
-- Lumen.Internal -- Internal declarations not intended for user applications
--
-- Chip Richards, NiEstu, Phoenix AZ, Spring 2010
-- This code is covered by the ISC License:
--
-- Copyright © 2010, NiEstu
--
-- Permission to use, copy, modify, and/or distribute this software for any
-- purpose with or without fee is hereby granted, provided that the above
-- copyright notice and this permission notice appear in all copies.
--
-- The software is provided "as is" and the author disclaims all warranties
-- with regard to this software including all implied warranties of
-- merchantability and fitness. In no event shall the author be liable for any
-- special, direct, indirect, or consequential damages or any damages
-- whatsoever resulting from loss of use, data or profits, whether in an
-- action of contract, negligence or other tortious action, arising out of or
-- in connection with the use or performance of this software.
-- Environment
with System;
package Lumen.Internal is
---------------------------------------------------------------------------
-- Xlib stuff needed for our window info record
type Atom is new Long_Integer;
type Display_Pointer is new System.Address;
Null_Display_Pointer : constant Display_Pointer :=
Display_Pointer (System.Null_Address);
type Screen_Depth is new Natural;
type Screen_Number is new Natural;
type Visual_ID is new Long_Integer;
type Window_ID is new Long_Integer;
type X_Visual_Info is record
Visual : System.Address;
Visual_Ident : Visual_ID;
Screen : Screen_Number;
Depth : Screen_Depth;
Class : Integer;
Red_Mask : Long_Integer;
Green_Mask : Long_Integer;
Blue_Mask : Long_Integer;
Colormap_Size : Natural;
Bits_Per_RGB : Natural;
end record;
type X_Visual_Info_Pointer is access all X_Visual_Info;
---------------------------------------------------------------------------
-- The GL rendering context type
type GLX_Context is new System.Address;
Null_Context : constant GLX_Context := GLX_Context (System.Null_Address);
---------------------------------------------------------------------------
-- The native window type
type Window_Internal is record
Display : Display_Pointer := Null_Display_Pointer;
Window : Window_ID := 0;
Visual : X_Visual_Info_Pointer := null;
Width : Natural := 0;
Height : Natural := 0;
Context : GLX_Context := Null_Context;
end record;
---------------------------------------------------------------------------
-- Values used to compute record rep clause values that are portable
-- between 32- and 64-bit systems
Is_32 : constant := Boolean'Pos (System.Word_Size = 32);
Is_64 : constant := 1 - Is_32;
Word_Bytes : constant := Integer'Size / System.Storage_Unit;
Word_Bits : constant := Integer'Size - 1;
Long_Bytes : constant := Long_Integer'Size / System.Storage_Unit;
Long_Bits : constant := Long_Integer'Size - 1;
---------------------------------------------------------------------------
-- The maximum length of an event data record
type Padding is array (1 .. 23) of Long_Integer;
---------------------------------------------------------------------------
end Lumen.Internal;
|
ohenley/COVID-19_Simulator | Ada | 769 | ads | with Qt; use Qt;
package CovidSimForm is
type Simulation_Engine is (Lancet, XPH_Pharmaceutical);
covidsim_form : QWidgetH;
procedure covidsim_form_init (parent : QWidgetH := null);
procedure slot_change_simulation_engine (simulation_engine_beautiful_name : QStringH);
pragma Convention (C, slot_change_simulation_engine);
procedure slot_change_scenario (scenario_beautiful_name : QStringH);
pragma Convention (C, slot_change_scenario);
procedure slot_change_iterations (iterations: Integer);
pragma Convention (C, slot_change_iterations);
procedure slot_change_population (population: Integer);
pragma Convention (C, slot_change_population);
procedure slot_export_to_csv;
pragma Convention (C, slot_export_to_csv);
end;
|
RREE/ada-util | Ada | 4,442 | adb | -----------------------------------------------------------------------
-- util-encoders-quoted_printable -- Encode/Decode a stream in quoted-printable
-- Copyright (C) 2020 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.Characters.Handling;
with Interfaces;
package body Util.Encoders.Quoted_Printable is
use Ada.Characters.Handling;
use type Interfaces.Unsigned_8;
function From_Hex (C : in Character) return Interfaces.Unsigned_8 is
(if C >= '0' and C <= '9' then Character'Pos (C) - Character'Pos ('0')
elsif C >= 'A' and C <= 'F' then Character'Pos (C) - Character'Pos ('A') + 10
else 0);
function From_Hex (C1, C2 : in Character) return Character is
(Character'Val (From_Hex (C2) + Interfaces.Shift_Left (From_Hex (C1), 4)));
-- ------------------------------
-- Decode the Quoted-Printable string and return the result.
-- When Strict is true, raises the Encoding_Error exception if the
-- format is invalid. Otherwise, ignore invalid encoding.
-- ------------------------------
function Decode (Content : in String;
Strict : in Boolean := True) return String is
Result : String (1 .. Content'Length);
Read_Pos : Natural := Content'First;
Write_Pos : Natural := Result'First - 1;
C : Character;
C2 : Character;
begin
while Read_Pos <= Content'Last loop
C := Content (Read_Pos);
if C = '=' then
exit when Read_Pos = Content'Last;
if Read_Pos + 2 > Content'Last then
exit when not Strict;
raise Encoding_Error;
end if;
Read_Pos := Read_Pos + 1;
C := Content (Read_Pos);
if not Is_Hexadecimal_Digit (C) then
exit when not Strict;
raise Encoding_Error;
end if;
C2 := Content (Read_Pos + 1);
if not Is_Hexadecimal_Digit (C) then
exit when not Strict;
raise Encoding_Error;
end if;
Write_Pos := Write_Pos + 1;
Result (Write_Pos) := From_Hex (C, C2);
Read_Pos := Read_Pos + 1;
else
Write_Pos := Write_Pos + 1;
Result (Write_Pos) := C;
end if;
Read_Pos := Read_Pos + 1;
end loop;
return Result (1 .. Write_Pos);
end Decode;
-- ------------------------------
-- Decode the "Q" encoding, similar to Quoted-Printable but with
-- spaces that can be replaced by '_'.
-- See RFC 2047.
-- ------------------------------
function Q_Decode (Content : in String) return String is
Result : String (1 .. Content'Length);
Read_Pos : Natural := Content'First;
Write_Pos : Natural := Result'First - 1;
C : Character;
C2 : Character;
begin
while Read_Pos <= Content'Last loop
C := Content (Read_Pos);
if C = '=' then
exit when Read_Pos = Content'Last or else Read_Pos + 2 > Content'Last;
Read_Pos := Read_Pos + 1;
C := Content (Read_Pos);
exit when not Is_Hexadecimal_Digit (C);
C2 := Content (Read_Pos + 1);
exit when not Is_Hexadecimal_Digit (C);
Write_Pos := Write_Pos + 1;
Result (Write_Pos) := From_Hex (C, C2);
Read_Pos := Read_Pos + 1;
elsif C = '_' then
Write_Pos := Write_Pos + 1;
Result (Write_Pos) := ' ';
else
Write_Pos := Write_Pos + 1;
Result (Write_Pos) := C;
end if;
Read_Pos := Read_Pos + 1;
end loop;
return Result (1 .. Write_Pos);
end Q_Decode;
end Util.Encoders.Quoted_Printable;
|
reznikmm/markdown | Ada | 8,770 | adb | -- SPDX-FileCopyrightText: 2020 Max Reznik <[email protected]>
--
-- SPDX-License-Identifier: MIT
----------------------------------------------------------------
with League.Regexps;
with Markdown.Common_Patterns;
with Markdown.Visitors;
package body Markdown.Link_Reference_Definitions is
function "+" (Text : Wide_Wide_String)
return League.Regexps.Regexp_Pattern
is (League.Regexps.Compile (League.Strings.To_Universal_String (Text)));
Blank_Pattern : League.Regexps.Regexp_Pattern renames
Markdown.Common_Patterns.Blank_Pattern;
Link_Label : Wide_Wide_String renames Markdown.Common_Patterns.Link_Label;
-- Groups: 2
Link_Title : Wide_Wide_String renames Markdown.Common_Patterns.Link_Title;
-- Groups: 4
Label_Pattern : constant League.Regexps.Regexp_Pattern :=
+("^\ {0,3}(" & Link_Label & ")\:" &
-- Grps:1 2,3
"[\ \t\n\v\f\r\>]*"
);
Space_Pattern : constant League.Regexps.Regexp_Pattern :=
+("^[\ \t\n\v\f\r\>]*");
Title_Pattern : constant League.Regexps.Regexp_Pattern :=
+("^[\ \t\n\v\f\r\>]*(" & Link_Title & ")?[\ \t\n\v\f\r\>]*$");
-- Groups: 1 2,3,4,5
Title_Close_Group : constant array (Positive range 1 .. 3) of Positive :=
(2, 3, 5); -- Close title group numbers
-----------------
-- Append_Line --
-----------------
overriding procedure Append_Line
(Self : in out Link_Reference_Definition;
Line : Markdown.Blocks.Text_Line;
CIP : Can_Interrupt_Paragraph;
Ok : in out Boolean)
is
pragma Unreferenced (CIP);
Last : Natural;
Text : League.Strings.Universal_String := Line.Line;
Match : League.Regexps.Regexp_Match;
begin
if Self.Has_Title then
Ok := False;
elsif not Self.Has_URL then
Match := Space_Pattern.Find_Match (Text);
pragma Assert (Match.Is_Matched);
Text := Text.Tail_From (Match.Last_Index + 1); -- drop spaces
Markdown.Common_Patterns.Parse_Link_Destination
(Line => Text,
Last => Last,
URL => Self.URL);
Self.Has_URL := Last > 0;
if Last = 0 then
Ok := False;
elsif Last = Text.Length then
Ok := True;
else
Text := Text.Tail_From (Last + 1); -- drop link dest
Match := Title_Pattern.Find_Match (Text);
Ok := Match.Is_Matched;
if Ok then
Self.Has_Title :=
(for some J of Title_Close_Group =>
Match.Last_Index (J) >= Match.First_Index (J));
Text := Match.Capture (1);
if Self.Has_Title then
Self.Title.Append (Text.Slice (2, Text.Length - 1));
elsif not Text.Is_Empty then
Self.Start := Text (1).To_Wide_Wide_Character;
Self.Title.Append (Text.Tail_From (2));
end if;
else
null; -- FIXME: Turn the block into a paragraph?
end if;
end if;
elsif Self.Title.Is_Empty then
Match := Title_Pattern.Find_Match (Text);
Ok := Match.Is_Matched;
if Ok then
Self.Has_Title :=
(for some J of Title_Close_Group =>
Match.Last_Index (J) >= Match.First_Index (J));
Text := Match.Capture (1);
if Self.Has_Title then
Self.Title.Append (Text.Slice (2, Text.Length - 1));
elsif not Text.Is_Empty then
Self.Start := Text (1).To_Wide_Wide_Character;
Self.Title.Append (Text.Tail_From (2));
end if;
else
null; -- FIXME: Turn the block into a paragraph?
end if;
elsif Blank_Pattern.Find_Match (Text).Is_Matched then
Ok := False;
null; -- FIXME: Turn the block into a paragraph?
else
declare
Escape : Boolean := False;
To : Natural := 0;
Stop : constant Wide_Wide_Character :=
(if Self.Start = '(' then ')' else Self.Start);
begin
for J in 1 .. Text.Length loop
if Escape then
Escape := False;
elsif Text (J).To_Wide_Wide_Character = '\' then
Escape := True;
elsif Text (J).To_Wide_Wide_Character = Stop then
Self.Has_Title := True;
To := J;
exit;
end if;
end loop;
Ok := not Escape and then To in 0 | Text.Length;
if Self.Has_Title and To > 1 then
Self.Title.Append (Text.Tail_From (To - 1));
elsif Ok then
Self.Title.Append (Text);
else
null; -- FIXME: Turn the block into a paragraph?
end if;
end;
end if;
end Append_Line;
------------
-- Create --
------------
overriding function Create
(Line : not null access Markdown.Blocks.Text_Line)
return Link_Reference_Definition
is
Last : Natural;
Text : League.Strings.Universal_String := Line.Line;
Match : League.Regexps.Regexp_Match :=
Label_Pattern.Find_Match (Text);
begin
pragma Assert (Match.Is_Matched);
return Self : Link_Reference_Definition do
Self.Label := Match.Capture (1);
if Match.Last_Index < Text.Length then
Text := Text.Tail_From (Match.Last_Index + 1); -- drop label
Markdown.Common_Patterns.Parse_Link_Destination
(Line => Text,
Last => Last,
URL => Self.URL);
Self.Has_URL := Last > 0;
pragma Assert (Last > 0);
if Last < Text.Length then
Text := Text.Tail_From (Last + 1); -- drop link dest
Match := Title_Pattern.Find_Match (Text);
Self.Has_Title :=
(for some J of Title_Close_Group =>
Match.Last_Index (J) >= Match.First_Index (J));
Text := Match.Capture (1);
if Self.Has_Title then
Self.Title.Append (Text.Slice (2, Text.Length - 1));
elsif not Text.Is_Empty then
Self.Start := Text (1).To_Wide_Wide_Character;
Self.Title.Append (Text.Tail_From (2));
end if;
end if;
end if;
Line.Line.Clear;
end return;
end Create;
-----------------
-- Destination --
-----------------
function Destination
(Self : Link_Reference_Definition'Class)
return League.Strings.Universal_String is
begin
return Self.URL;
end Destination;
------------
-- Filter --
------------
procedure Filter
(Line : Markdown.Blocks.Text_Line;
Tag : in out Ada.Tags.Tag;
CIP : out Can_Interrupt_Paragraph)
is
Ignore : League.Strings.Universal_String;
Last : Natural;
Text : League.Strings.Universal_String := Line.Line;
Match : constant League.Regexps.Regexp_Match :=
Label_Pattern.Find_Match (Line.Line);
begin
CIP := False;
if Match.Is_Matched then
if Match.Last_Index < Text.Length then
Text := Text.Tail_From (Match.Last_Index + 1); -- drop label
Markdown.Common_Patterns.Parse_Link_Destination
(Line => Text,
Last => Last,
URL => Ignore);
if Last = 0 then
return; -- Wrong link destination
elsif Last < Text.Length then
Text := Text.Tail_From (Last + 1); -- drop link dest
if not Title_Pattern.Find_Match (Text).Is_Matched then
return; -- Wrong link title
end if;
end if;
end if;
Tag := Link_Reference_Definition'Tag;
end if;
end Filter;
-----------
-- Label --
-----------
function Label
(Self : Link_Reference_Definition'Class)
return League.Strings.Universal_String is
begin
return Self.Label;
end Label;
-----------
-- Title --
-----------
function Title
(Self : Link_Reference_Definition'Class)
return League.String_Vectors.Universal_String_Vector is
begin
return Self.Title;
end Title;
-----------
-- Visit --
-----------
overriding procedure Visit
(Self : in out Link_Reference_Definition;
Visitor : in out Markdown.Visitors.Visitor'Class) is
begin
Visitor.Link_Reference_Definition (Self);
end Visit;
end Markdown.Link_Reference_Definitions;
|
riccardo-bernardini/eugen | Ada | 3,767 | ads | -------------------------------------------------------------------------------
-- DEpendency PLOtter for ada packages (DePlo) --
-- --
-- Copyright (C) 2012, Riccardo Bernardini --
-- --
-- This file is part of DePlo. --
-- --
-- DePlo is free software: you can redistribute it and/or modify --
-- it under the terms of the GNU General Public License as published by --
-- the Free Software Foundation, either version 2 of the License, or --
-- (at your option) any later version. --
-- --
-- DePlo 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 DePlo. If not, see <http://www.gnu.org/licenses/>. --
-------------------------------------------------------------------------------
--
-- This package provides method for working with "arrays of line."
-- Nothing georgious, really, just a place where few handy routines
-- are kept.
--
with Ada.Containers.Indefinite_Vectors;
with Ada.Sequential_IO;
package Line_Arrays is
package Character_IO is
new Ada.Sequential_IO (Character);
package Line_Containers is
new Ada.Containers.Indefinite_Vectors (Index_Type => Positive,
Element_Type => String);
subtype Line_Array is Line_Containers.Vector;
type Line_Terminator is -- Which caracters sequence ends the line?
(
CR, -- Only Carriage Return ends the line
LF, -- Only Line Feed ends the line
CRLF, -- Only the sequence CR + LF ends the line
Any -- Any of the above combination is admitted
);
subtype Valid_Line_Terminator is Line_Terminator range CR .. CRLF;
function Split
(Input : String;
Terminator : Line_Terminator := Any)
return Line_Array;
-- Split a string into an array of lines, splitting at the specified
-- line terminator
function Read
(Filename : String;
Terminator : Line_Terminator := Any)
return Line_Array;
-- Read a file and split its content a string into an array of lines,
-- splitting at the specified line terminator
function Read
(Input : Character_IO.File_Type;
Terminator : Line_Terminator := Any)
return Line_Array;
-- Read a file and split its content a string into an array of lines,
-- splitting at the specified line terminator
function Join
(Input : Line_Array;
Terminator : Valid_Line_Terminator := CR)
return String;
-- Inverse of split: take an array of line and join them together
-- with the specified terminator
function Join
(Input : Line_Array;
Terminator : String)
return String;
-- Generalization of the other Join; in this case the terminator
-- can be any string. Quite similar to the join in many script languages.
function "=" (Left, Right : Line_Array) return Boolean;
end Line_Arrays;
|
optikos/oasis | Ada | 3,399 | ads | -- Copyright (c) 2019 Maxim Reznik <[email protected]>
--
-- SPDX-License-Identifier: MIT
-- License-Filename: LICENSE
-------------------------------------------------------------
with Program.Elements.Declarations;
with Program.Lexical_Elements;
with Program.Elements.Defining_Names;
with Program.Elements.Parameter_Specifications;
with Program.Elements.Aspect_Specifications;
package Program.Elements.Procedure_Declarations is
pragma Pure (Program.Elements.Procedure_Declarations);
type Procedure_Declaration is
limited interface and Program.Elements.Declarations.Declaration;
type Procedure_Declaration_Access is access all Procedure_Declaration'Class
with Storage_Size => 0;
not overriding function Name
(Self : Procedure_Declaration)
return not null Program.Elements.Defining_Names.Defining_Name_Access
is abstract;
not overriding function Parameters
(Self : Procedure_Declaration)
return Program.Elements.Parameter_Specifications
.Parameter_Specification_Vector_Access is abstract;
not overriding function Aspects
(Self : Procedure_Declaration)
return Program.Elements.Aspect_Specifications
.Aspect_Specification_Vector_Access is abstract;
not overriding function Has_Not
(Self : Procedure_Declaration)
return Boolean is abstract;
not overriding function Has_Overriding
(Self : Procedure_Declaration)
return Boolean is abstract;
not overriding function Has_Abstract
(Self : Procedure_Declaration)
return Boolean is abstract;
type Procedure_Declaration_Text is limited interface;
type Procedure_Declaration_Text_Access is
access all Procedure_Declaration_Text'Class with Storage_Size => 0;
not overriding function To_Procedure_Declaration_Text
(Self : aliased in out Procedure_Declaration)
return Procedure_Declaration_Text_Access is abstract;
not overriding function Not_Token
(Self : Procedure_Declaration_Text)
return Program.Lexical_Elements.Lexical_Element_Access is abstract;
not overriding function Overriding_Token
(Self : Procedure_Declaration_Text)
return Program.Lexical_Elements.Lexical_Element_Access is abstract;
not overriding function Procedure_Token
(Self : Procedure_Declaration_Text)
return not null Program.Lexical_Elements.Lexical_Element_Access
is abstract;
not overriding function Left_Bracket_Token
(Self : Procedure_Declaration_Text)
return Program.Lexical_Elements.Lexical_Element_Access is abstract;
not overriding function Right_Bracket_Token
(Self : Procedure_Declaration_Text)
return Program.Lexical_Elements.Lexical_Element_Access is abstract;
not overriding function Is_Token
(Self : Procedure_Declaration_Text)
return Program.Lexical_Elements.Lexical_Element_Access is abstract;
not overriding function Abstract_Token
(Self : Procedure_Declaration_Text)
return Program.Lexical_Elements.Lexical_Element_Access is abstract;
not overriding function With_Token
(Self : Procedure_Declaration_Text)
return Program.Lexical_Elements.Lexical_Element_Access is abstract;
not overriding function Semicolon_Token
(Self : Procedure_Declaration_Text)
return not null Program.Lexical_Elements.Lexical_Element_Access
is abstract;
end Program.Elements.Procedure_Declarations;
|
AdaCore/Ada_Drivers_Library | Ada | 10,461 | 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. --
-- --
------------------------------------------------------------------------------
package body CS43L22 is
---------------
-- I2C_Write --
---------------
procedure I2C_Write (This : in out CS43L22_Device;
Reg : UInt8;
Value : UInt8)
is
Status : I2C_Status;
begin
This.Port.Mem_Write
(Addr => CS43L22_I2C_Addr,
Mem_Addr => UInt16 (Reg),
Mem_Addr_Size => Memory_Size_8b,
Data => (1 => Value),
Status => Status);
end I2C_Write;
--------------
-- I2C_Read --
--------------
function I2C_Read (This : in out CS43L22_Device;
Reg : UInt8)
return UInt8
is
Status : I2C_Status;
Data : I2C_Data (1 .. 1);
begin
This.Port.Mem_Read
(Addr => CS43L22_I2C_Addr,
Mem_Addr => UInt16 (Reg),
Mem_Addr_Size => Memory_Size_8b,
Data => Data,
Status => Status);
return Data (1);
end I2C_Read;
----------
-- Init --
----------
procedure Init
(This : in out CS43L22_Device;
Output : Output_Device;
Volume : Volume_Level;
Frequency : Audio_Frequency)
is
pragma Unreferenced (Frequency);
begin
-- Codec set to power OFF
This.I2C_Write (CS43L22_REG_POWER_CTL1, 16#01#);
-- Save output device for mute ON/OFF procedure
This.Set_Output_Mode (Output);
-- Clock configuration: auto detection
This.I2C_Write (CS43L22_REG_CLOCKING_CTL, 16#81#);
-- Set the Slave Mode and the audio Standard
This.I2C_Write (CS43L22_REG_INTERFACE_CTL1, 16#04#);
-- Set the Master volume */
This.Set_Volume (Volume);
-- If the Speaker is enabled, set the Mono mode and volume attenuation
-- level
if (Output /= Headphone) then
-- Set the Speaker Mono mode
This.I2C_Write (CS43L22_REG_PLAYBACK_CTL2, 16#06#);
-- Set the Speaker attenuation level
This.I2C_Write (CS43L22_REG_SPEAKER_A_VOL, 16#00#);
This.I2C_Write (CS43L22_REG_SPEAKER_B_VOL, 16#00#);
end if;
-- Additional configuration for the CODEC. These configurations are
-- done to reduce the time needed for the Codec to power off. If these
-- configurations are removed, then a long delay should be added between
-- powering off the Codec and switching off the I2S peripheral MCLK
-- clock (which is the operating clock for Codec).
-- If this delay is not inserted, then the codec will not shut down
-- properly and it results in high noise after shut down.
-- Disable the analog soft ramp
This.I2C_Write (CS43L22_REG_ANALOG_ZC_SR_SETT, 16#00#);
-- Disable the digital soft ramp
This.I2C_Write (CS43L22_REG_MISC_CTL, 16#04#);
-- Disable the limiter attack level
This.I2C_Write (CS43L22_REG_LIMIT_CTL1, 16#00#);
-- Adjust Bass and Treble levels */
This.I2C_Write (CS43L22_REG_TONE_CTL, 16#0F#);
-- Adjust PCM volume level */
This.I2C_Write (CS43L22_REG_PCMA_VOL, 16#0A#);
This.I2C_Write (CS43L22_REG_PCMB_VOL, 16#0A#);
end Init;
-------------
-- Read_ID --
-------------
function Read_ID (This : in out CS43L22_Device) return UInt8 is
begin
return This.I2C_Read (CS43L22_REG_ID) and CS43L22_ID_MASK;
end Read_ID;
----------
-- Play --
----------
procedure Play (This : in out CS43L22_Device) is
begin
if not This.Output_Enabled then
-- Enable the digital soft ramp
This.I2C_Write (CS43L22_REG_MISC_CTL, 16#06#);
-- Enable output device
This.Set_Mute (Mute_Off);
-- Power on the Codec
This.I2C_Write (CS43L22_REG_POWER_CTL1, 16#9E#);
This.Output_Enabled := True;
end if;
end Play;
-----------
-- Pause --
-----------
procedure Pause (This : in out CS43L22_Device) is
begin
-- Pause the audio playing
This.Set_Mute (Mute_On);
-- CODEC in powersave mode
This.I2C_Write (CS43L22_REG_POWER_CTL1, 16#01#);
end Pause;
------------
-- Resume --
------------
procedure Resume (This : in out CS43L22_Device) is
begin
-- Unmute the output first
This.Set_Mute (Mute_Off);
This.Time.Delay_Milliseconds (1);
This.I2C_Write (CS43L22_REG_POWER_CTL2, This.Output_Dev);
-- Exit the power save mode
This.I2C_Write (CS43L22_REG_POWER_CTL1, 16#9E#);
end Resume;
----------
-- Stop --
----------
procedure Stop (This : in out CS43L22_Device) is
begin
if This.Output_Enabled then
-- Mute the output first
This.Set_Mute (Mute_On);
-- Disable the digital soft ramp
This.I2C_Write (CS43L22_REG_MISC_CTL, 16#04#);
-- Power down the DAC and the speaker
This.I2C_Write (CS43L22_REG_POWER_CTL1, 16#9F#);
This.Output_Enabled := False;
end if;
end Stop;
----------------
-- Set_Volume --
----------------
procedure Set_Volume (This : in out CS43L22_Device; Volume : Volume_Level)
is
-- Actual Volume in range 0 .. 16#3F#
Converted_Volume : UInt8 :=
UInt8 (UInt16 (Volume) * 200 / 100);
begin
-- range goes the following:
-- 0 dB .. +12 dB: coded from 0 to 24
-- -102 dB .. -0.5 dB: coded from 52 to 255
-- -102 dB: applied for values in range 25 .. 52
-- so we have a valid range of volume from -102 to +12 in steps of 0.5
-- which means 225 significant values
-- 200 .. 224 for positive dB
-- 0 .. 199 for negative dB
-- However positive values may lead to saturated output. We thus limit
-- the volume to the -102 .. 0dB range
if Converted_Volume >= 200 then
Converted_Volume := Converted_Volume - 200;
else
Converted_Volume := Converted_Volume + 52;
end if;
This.I2C_Write (CS43L22_REG_MASTER_A_VOL, Converted_Volume);
This.I2C_Write (CS43L22_REG_MASTER_B_VOL, Converted_Volume);
end Set_Volume;
--------------
-- Set_Mute --
--------------
procedure Set_Mute (This : in out CS43L22_Device; Cmd : Mute) is
begin
if This.Output_Enabled then
case Cmd is
when Mute_On =>
This.I2C_Write (CS43L22_REG_POWER_CTL2, 16#FF#);
This.I2C_Write (CS43L22_REG_HEADPHONE_A_VOL, 16#01#);
This.I2C_Write (CS43L22_REG_HEADPHONE_B_VOL, 16#01#);
when Mute_Off =>
This.I2C_Write (CS43L22_REG_HEADPHONE_A_VOL, 16#00#);
This.I2C_Write (CS43L22_REG_HEADPHONE_B_VOL, 16#00#);
This.I2C_Write (CS43L22_REG_POWER_CTL2, This.Output_Dev);
end case;
end if;
end Set_Mute;
---------------------
-- Set_Output_Mode --
---------------------
procedure Set_Output_Mode (This : in out CS43L22_Device;
Device : Output_Device)
is
begin
case Device is
when No_Output =>
This.Output_Dev := 0;
when Speaker =>
This.Output_Dev := 16#FA#;
when Headphone =>
This.Output_Dev := 16#AF#;
when Both =>
This.Output_Dev := 16#AA#;
when Auto =>
This.Output_Dev := 16#05#;
end case;
This.I2C_Write (CS43L22_REG_POWER_CTL2, This.Output_Dev);
end Set_Output_Mode;
-------------------
-- Set_Frequency --
-------------------
procedure Set_Frequency (This : in out CS43L22_Device;
Freq : Audio_Frequency)
is
pragma Unreferenced (This, Freq);
begin
-- CODEC is automatically detecting the frequency. No need to do
-- anything here.
null;
end Set_Frequency;
-----------
-- Reset --
-----------
procedure Reset (This : in out CS43L22_Device)
is
pragma Unreferenced (This);
begin
null;
end Reset;
end CS43L22;
|
danieagle/ASAP-Modular_Hashing | Ada | 7,037 | ads | ------------------------------------------------------------------------------
-- --
-- Modular Hash Infrastructure --
-- --
-- SHA2 (256) --
-- --
-- ------------------------------------------------------------------------ --
-- --
-- Copyright (C) 2019-2021, ANNEXI-STRAYLINE Trans-Human Ltd. --
-- All rights reserved. --
-- --
-- Original Contributors: --
-- * Ensi Martini (ANNEXI-STRAYLINE) --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions are --
-- met: --
-- --
-- * Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- --
-- * Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in --
-- the documentation and/or other materials provided with the --
-- distribution. --
-- --
-- * Neither the name of the copyright holder nor the names of its --
-- contributors may be used to endorse or promote products derived --
-- from this software without specific prior written permission. --
-- --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A --
-- PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
-- OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT --
-- LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, --
-- DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY --
-- THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT --
-- (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE --
-- OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
-- --
------------------------------------------------------------------------------
with Interfaces;
with Ada.Streams;
package Modular_Hashing.SHA256 is
type SHA256_Hash is new Hash with private;
-- The final hash is a 256-bit message digest, which can also be displayed
-- as a 64 character hex string and is 32 bytes long
overriding function "<" (Left, Right : SHA256_Hash) return Boolean;
overriding function ">" (Left, Right : SHA256_Hash) return Boolean;
overriding function "=" (Left, Right : SHA256_Hash) return Boolean;
SHA256_Hash_Bytes: constant := 32;
overriding function Binary_Bytes (Value: SHA256_Hash) return Positive is
(SHA256_Hash_Bytes);
overriding function Binary (Value: SHA256_Hash) return Hash_Binary_Value
with Post => Binary'Result'Length = SHA256_Hash_Bytes;
type SHA256_Engine is new Hash_Algorithm with private;
overriding
procedure Write (Stream : in out SHA256_Engine;
Item : in Ada.Streams.Stream_Element_Array);
overriding procedure Reset (Engine : in out SHA256_Engine);
overriding function Digest (Engine : in out SHA256_Engine)
return Hash'Class;
private
use Ada.Streams, Interfaces;
type Message_Digest is array (1 .. 8) of Unsigned_32;
type SHA256_Hash is new Hash with
record
Digest: Message_Digest;
end record;
-------------------
-- SHA256_Engine --
-------------------
-- SHA-2 Defined initialization constants
H0_Initial: constant := 16#6a09e667#;
H1_Initial: constant := 16#bb67ae85#;
H2_Initial: constant := 16#3c6ef372#;
H3_Initial: constant := 16#a54ff53a#;
H4_Initial: constant := 16#510e527f#;
H5_Initial: constant := 16#9b05688c#;
H6_Initial: constant := 16#1f83d9ab#;
H7_Initial: constant := 16#5be0cd19#;
type K_Arr is array (1 .. 64) of Unsigned_32;
K : constant K_Arr :=
(16#428a2f98#, 16#71374491#, 16#b5c0fbcf#, 16#e9b5dba5#,
16#3956c25b#, 16#59f111f1#, 16#923f82a4#, 16#ab1c5ed5#,
16#d807aa98#, 16#12835b01#, 16#243185be#, 16#550c7dc3#,
16#72be5d74#, 16#80deb1fe#, 16#9bdc06a7#, 16#c19bf174#,
16#e49b69c1#, 16#efbe4786#, 16#0fc19dc6#, 16#240ca1cc#,
16#2de92c6f#, 16#4a7484aa#, 16#5cb0a9dc#, 16#76f988da#,
16#983e5152#, 16#a831c66d#, 16#b00327c8#, 16#bf597fc7#,
16#c6e00bf3#, 16#d5a79147#, 16#06ca6351#, 16#14292967#,
16#27b70a85#, 16#2e1b2138#, 16#4d2c6dfc#, 16#53380d13#,
16#650a7354#, 16#766a0abb#, 16#81c2c92e#, 16#92722c85#,
16#a2bfe8a1#, 16#a81a664b#, 16#c24b8b70#, 16#c76c51a3#,
16#d192e819#, 16#d6990624#, 16#f40e3585#, 16#106aa070#,
16#19a4c116#, 16#1e376c08#, 16#2748774c#, 16#34b0bcb5#,
16#391c0cb3#, 16#4ed8aa4a#, 16#5b9cca4f#, 16#682e6ff3#,
16#748f82ee#, 16#78a5636f#, 16#84c87814#, 16#8cc70208#,
16#90befffa#, 16#a4506ceb#, 16#bef9a3f7#, 16#c67178f2#);
type SHA256_Engine is new Hash_Algorithm with record
Last_Element_Index : Stream_Element_Offset := 0;
Buffer : Stream_Element_Array(1 .. 64);
Message_Length : Unsigned_64 := 0;
H0 : Unsigned_32 := H0_Initial;
H1 : Unsigned_32 := H1_Initial;
H2 : Unsigned_32 := H2_Initial;
H3 : Unsigned_32 := H3_Initial;
H4 : Unsigned_32 := H4_Initial;
H5 : Unsigned_32 := H5_Initial;
H6 : Unsigned_32 := H6_Initial;
H7 : Unsigned_32 := H7_Initial;
end record;
end Modular_Hashing.SHA256;
|
yannickmoy/SPARKNaCl | Ada | 18,230 | ads | ------------------------------------------------------------------------------
-- Copyright (c) 2020,2021 Protean Code Limited
-- All rights reserved.
--
-- "Simplified" (2-Clause) BSD Licence
--
-- 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.
------------------------------------------------------------------------------
with Ada.Unchecked_Conversion;
with Interfaces; use Interfaces;
package SPARKNaCl
with Pure,
SPARK_Mode => On
is
--==============================================
-- Exported types and constants
--
-- These are needed by clients, or by the
-- specifications of child packages
--==============================================
subtype Byte is Unsigned_8;
subtype I32 is Integer_32;
subtype N32 is I32 range 0 .. I32'Last;
subtype I32_Bit is I32 range 0 .. 1;
subtype I64 is Integer_64;
subtype I64_Byte is I64 range 0 .. 255;
subtype I64_Bit is I64 range 0 .. 1;
-- Byte_Seq and constrained subtypes thereof
type Byte_Seq is array (N32 range <>) of Byte;
subtype Index_8 is I32 range 0 .. 7;
subtype Index_16 is I32 range 0 .. 15;
subtype Index_24 is I32 range 0 .. 23;
subtype Index_32 is I32 range 0 .. 31;
subtype Index_64 is I32 range 0 .. 63;
subtype Bytes_8 is Byte_Seq (Index_8);
subtype Bytes_16 is Byte_Seq (Index_16);
subtype Bytes_24 is Byte_Seq (Index_24);
subtype Bytes_32 is Byte_Seq (Index_32);
subtype Bytes_64 is Byte_Seq (Index_64);
Zero_Bytes_16 : constant Bytes_16 := (others => 0);
Zero_Bytes_32 : constant Bytes_32 := (others => 0);
-- A sequence of I64 values, but where each is limited to
-- values 0 .. 255;
type I64_Byte_Seq is array (N32 range <>) of I64_Byte;
-- Sequences of I64 values and subtypes thereof
type I64_Seq is array (N32 range <>) of I64;
subtype I64_Seq_64 is I64_Seq (Index_64);
--------------------------------------------------------
-- Constant time equality test
--------------------------------------------------------
-- Primitive operation of Byte_Seq, so inheritable
function Equal (X, Y : in Byte_Seq) return Boolean
with Pure_Function,
Global => null,
Pre => X'First = Y'First and
X'Last = Y'Last,
Post => Equal'Result =
(for all I in X'Range => X (I) = Y (I));
--------------------------------------------------------
-- Data sanitization
--------------------------------------------------------
-- Primitive operation of Byte_Seq, so inheritable.
-- In their "Volatiles are mis-compiled..." paper,
-- Regehr et al. recommend that calls to such subprograms
-- should never be in-lined as a way to prevent
-- the incorrect optimization (to nothing) of such a call,
-- so we apply No_Inline here.
pragma Warnings (GNATProve, Off, "No_Inline");
procedure Sanitize (R : out Byte_Seq)
with Global => null,
No_Inline;
private
--==============================================
-- Local types - visible below, in this package
-- body and in the bodies of child packages
--==============================================
subtype U16 is Unsigned_16;
subtype U32 is Unsigned_32;
subtype U64 is Unsigned_64;
subtype Index_4 is I32 range 0 .. 3;
subtype Index_15 is I32 range 0 .. 14;
subtype Index_20 is I32 range 0 .. 19;
subtype Index_31 is I32 range 0 .. 30;
subtype Index_256 is I32 range 0 .. 255;
subtype Bytes_4 is Byte_Seq (Index_4);
subtype Bytes_256 is Byte_Seq (Index_256);
type U32_Seq is array (N32 range <>) of U32;
type U64_Seq is array (N32 range <>) of U64;
subtype U32_Seq_4 is U32_Seq (Index_4);
subtype U32_Seq_16 is U32_Seq (Index_16);
subtype I64_Byte_Seq_32 is I64_Byte_Seq (Index_32);
subtype U64_Seq_16 is U64_Seq (Index_16);
subtype U64_Seq_8 is U64_Seq (Index_8);
-- Constant Sigma used for initialization of Core Salsa20
-- function in both Stream and Cryptobox packages
Sigma : constant Bytes_16 :=
(0 => Character'Pos ('e'),
1 => Character'Pos ('x'),
2 => Character'Pos ('p'),
3 => Character'Pos ('a'),
4 => Character'Pos ('n'),
5 => Character'Pos ('d'),
6 => Character'Pos (' '),
7 => Character'Pos ('3'),
8 => Character'Pos ('2'),
9 => Character'Pos ('-'),
10 => Character'Pos ('b'),
11 => Character'Pos ('y'),
12 => Character'Pos ('t'),
13 => Character'Pos ('e'),
14 => Character'Pos (' '),
15 => Character'Pos ('k'));
-------------------------------------------------------------------------
-- Constants common to the whole library
--
-- Some "Huffman-lite coding" is applied to names here - the most
-- frequently used constants having abbreviated names.
-------------------------------------------------------------------------
-- GF "Limbs" are stored modulo 65536
--
-- "LM" = "Limb Modulus"
-- "LMM1" = "Limb Modulus Minus 1"
LM : constant := 65536;
LMM1 : constant := 65535;
-- The modulus of curve 25519 is (2**255 - 19).
-- In the reduction of GF values, we sometime need to multiply a limb
-- value by 2**256 mod (2**255 - 19), which is actually equal to 38,
-- since 2**256 = (2 * (2**255 - 19)) + 38
--
-- "R2256" = "Remainder of 2**256 (modulo 2**255-19)"
R2256 : constant := 38;
-------------------------------------------------------------------------
-- Bounds on All GF Limbs
--
-- In the most general case, we define GF_Any_Limb so it can take
-- on the value of any GF limb at any point including intermediate
-- values inside the "*", "-" and "+" operations.
--
-- Lower bound on GF_Any_Limb
--
-- During a subtraction of a GF, a limb can also reach -65535,
-- but this can be rounded down to -65536 by addition of a -1 carry,
-- so the lower bound is -65536
--
-- Upper bound on GF_Any_Limb
--
-- During the "reduction modulo 2**255-19" phase of the "*"
-- operation, each limb GF (I) is added to R2256 * GF (I + 16)
-- The worst-case upper bound of this result is when I = 0,
-- where GF (0) has upper bound MGFLP and GF (16) has upper bound
-- 15 * MGFLP.
--
-- Therefore the upper bound of Any_GF_Limb is
-- (R2256 * 15 + 1) * MGFLP = 571 * MGFLP
-------------------------------------------------------------------------
-- "Maximum GF Limb Coefficient"
MGFLC : constant := (R2256 * 15) + 1;
-- In multiplying two normalized GFs, a simple product of
-- two limbs is bounded to 65535**2. This comes up in
-- predicates and subtypes below, so a named number here
-- is called for. The name "MGFLP" is short for
-- "Maximum GF Limb Product"
MGFLP : constant := LMM1 * LMM1;
-- The max value of a GF32_Any_Limb is the upper bound on digit 0
-- following ONE application of Product_To_Seminormal_GF to the
-- intermidiate result of a "*" operation. This value is actually
-- a bit less than 2**27 which justifies that subsequence normalization
-- steps can all be done in 32-bir arithmetic.
--
-- See the declaration of Seminormal_GF_LSL below for detail of
-- how this value is derived.
GF32_Any_Limb_Max : constant := (LMM1 + R2256 * ((53 * MGFLP) / LM));
subtype GF32_Any_Limb is I32
range -LM .. GF32_Any_Limb_Max;
type GF32 is array (Index_16) of GF32_Any_Limb;
-- In the "*" operator for GF, intermediate results require
-- 64 bit integers before being normalized, so...
subtype GF64_Any_Limb is I64 range -LM .. (MGFLC * MGFLP);
type GF64 is array (Index_16) of GF64_Any_Limb;
-- GF64 Product Accumulator - used in "*" to accumulate the
-- intermediate results of Left * Right
type GF64_PA is array (Index_31) of GF64_Any_Limb;
-------------------------------------------------------------------------
subtype GF64_Normal_Limb is GF64_Any_Limb range 0 .. LMM1;
subtype GF32_Normal_Limb is GF32_Any_Limb range 0 .. LMM1;
subtype GF16_Normal_Limb is U16;
subtype Normal_GF64 is GF64
with Dynamic_Predicate =>
(for all I in Index_16 => Normal_GF64 (I) in GF64_Normal_Limb);
subtype Normal_GF32 is GF32
with Dynamic_Predicate =>
(for all I in Index_16 => Normal_GF32 (I) in GF32_Normal_Limb);
type Normal_GF is array (Index_16) of GF16_Normal_Limb
with Alignment => 4;
-------------------------------------------------------------------------
-------------------------------------------------------------------------
-- Subtypes supporting "+" operation on GF
--
-- In a "+" operation, intermediate result limbs peak at +131070, so
subtype GF_Sum_Limb is I32 range 0 .. (LMM1 * 2);
subtype Sum_GF is GF32
with Dynamic_Predicate =>
(for all I in Index_16 => Sum_GF (I) in GF_Sum_Limb);
-------------------------------------------------------------------------
-------------------------------------------------------------------------
-- Subtypes supporting "-" operation on GF
--
-- In a "-" operation, each limb of the intermediate result is
-- increased by 65536 to make sure it's not negative, and one
-- is taken off the next limb up to balance the value.
--
-- This means that
-- Limb 0 is in range (0 - 65535) + 65536 .. (65535 - 0) + 65536
-- which is 1 .. 131071
-- Limbs 1 .. 15 are in range (0 - 65535) + 65535 .. (65535 - 0) + 65535
-- which is 0 .. 131070
--
-- Finally, to balance the -1 value carried into limb 16, limb 0
-- is reduced by R2256, so...
subtype Difference_GF is GF32
with Dynamic_Predicate =>
((Difference_GF (0) in (1 - R2256) .. (2 * LMM1) + 1) and
(for all K in Index_16 range 1 .. 15 =>
Difference_GF (K) in 0 .. 2 * LMM1));
-------------------------------------------------------------------------
-- Subtypes supporting "*" operation on GF
--
-- A GF which is the result of multiplying two other Normalized GFs,
-- but BEFORE normalization is applied has the following bounds on
-- its limbs. The upperbound on Limb 0 is MGFLC * MGFLP as in
-- GF_Any_Limb, but the upper bound reduces by 37 * MGFLP
-- for each limb onwards...
--
-- Lower-bound here is 0 since "*" always takes Normal_GF
-- parameters, so an intermediate limb can never be negative.
subtype Product_GF is GF64
with Dynamic_Predicate =>
(for all I in Index_16 =>
Product_GF (I) >= 0 and
Product_GF (I) <=
(MGFLC - 37 * GF64_Any_Limb (I)) * MGFLP);
----------------------------------------------------------------------
-- A "Seminormal GF" is the result of applying a single
-- normalization step to a Product_GF
--
-- Least Significant Limb ("LSL") of a Seminormal GF.
-- LSL is initially normalized to 0 .. 65535, but gets
-- R2256 * Carry added to it, where Carry is (Limb 15 / 65536)
-- The upper-bound on Limb 15 is given by substituting I = 14
-- into the Dynamic_Predicate above, so
-- (MGFLC - 37 * 14) * MGFLP = 53 * MGFLP
-- See the body of Product_To_Seminormal for the full
-- proof of this upper-bound
subtype Seminormal_GF_LSL is GF32_Any_Limb
range 0 .. GF32_Any_Limb_Max;
-- Limbs 1 though 15 are in 0 .. 65535, but the
-- Least Significant Limb 0 is in GF_Seminormal_Product_LSL
subtype Seminormal_GF is GF32
with Dynamic_Predicate =>
(Seminormal_GF (0) in Seminormal_GF_LSL and
(for all I in Index_16 range 1 .. 15 =>
Seminormal_GF (I) in GF32_Normal_Limb));
------------------------------------------------------------------------
-- A "Nearly-normal GF" is the result of applying either:
-- 1. TWO normalization steps to a Product_GF
-- OR
-- 2. ONE normalization step to the SUM of 2 normalized GFs
-- OR
-- 3. ONE normalization step to the DIFFERENCE of 2 normalized GFs
--
-- The least-significant-limb is normalized to 0 .. 65535, but then
-- has +R2256 or -R2256 added to it, so its range is...
subtype Nearlynormal_GF is GF32
with Dynamic_Predicate =>
((Nearlynormal_GF (0) in -R2256 .. LMM1 + R2256) and
(for all K in Index_16 range 1 .. 15 =>
(Nearlynormal_GF (K) in GF32_Normal_Limb)));
------------------------------------------------------------------------
--=================================================
-- Constants, used in more than one child package
--=================================================
GF_0 : constant Normal_GF := (others => 0);
GF32_0 : constant Normal_GF32 := (others => 0);
GF_1 : constant Normal_GF := (1, others => 0);
--==================
-- Local functions
--==================
function To_U64 is new Ada.Unchecked_Conversion (I64, U64);
function To_I64 is new Ada.Unchecked_Conversion (U64, I64);
function To_U32 is new Ada.Unchecked_Conversion (I32, U32);
function To_I32 is new Ada.Unchecked_Conversion (U32, I32);
-- returns equivalent of X >> 16 in C, doing an arithmetic
-- shift right when X is negative, assuming 2's complement
-- representation
function ASR64_16 (X : in I64) return I64
is (To_I64 (Shift_Right_Arithmetic (To_U64 (X), 16)))
with Post => (if X >= 0 then ASR64_16'Result = X / LM else
ASR64_16'Result = ((X + 1) / LM) - 1);
pragma Annotate (GNATprove,
False_Positive,
"postcondition might fail",
"From definition of arithmetic shift right");
-- returns equivalent of X >> 16 in C, doing an arithmetic
-- shift right when X is negative, assuming 2's complement
-- representation
function ASR32_16 (X : in I32) return I32
is (To_I32 (Shift_Right_Arithmetic (To_U32 (X), 16)))
with Post => (if X >= 0 then ASR32_16'Result = X / LM else
ASR32_16'Result = ((X + 1) / LM) - 1);
pragma Annotate (GNATprove,
False_Positive,
"postcondition might fail",
"From definition of arithmetic shift right");
-- returns equivalent of X >> 8 in C, doing an arithmetic
-- shift right when X is negative, assuming 2's complement
-- representation
function ASR_8 (X : in I64) return I64
is (To_I64 (Shift_Right_Arithmetic (To_U64 (X), 8)))
with Post => (if X >= 0 then ASR_8'Result = X / 256 else
ASR_8'Result = ((X + 1) / 256) - 1);
pragma Annotate (GNATprove,
False_Positive,
"postcondition might fail",
"From definition of arithmetic shift right");
-- returns equivalent of X >> 4 in C, doing an arithmetic
-- shift right when X is negative, assuming 2's complement
-- representation
function ASR_4 (X : in I64) return I64
is (To_I64 (Shift_Right_Arithmetic (To_U64 (X), 4)))
with Post => (if X >= 0 then ASR_4'Result = X / 16 else
ASR_4'Result = ((X + 1) / 16) - 1);
pragma Annotate (GNATprove,
False_Positive,
"postcondition might fail",
"From definition of arithmetic shift right");
--===============================
-- Local subprogram declarations
--===============================
function "+" (Left, Right : in Normal_GF) return Normal_GF
with Pure_Function,
Global => null;
function "-" (Left, Right : in Normal_GF) return Normal_GF
with Pure_Function,
Global => null;
function "*" (Left, Right : in Normal_GF) return Normal_GF
with Pure_Function,
Global => null;
function Square (A : in Normal_GF) return Normal_GF
is (A * A)
with Pure_Function,
Global => null;
-- Additional sanitization procedures for local types
procedure Sanitize_U32 (R : out U32)
with Global => null,
No_Inline;
procedure Sanitize_U16 (R : out U16)
with Global => null,
No_Inline;
procedure Sanitize_U64 (R : out U64)
with Global => null,
No_Inline;
procedure Sanitize_GF32 (R : out GF32)
with Global => null,
No_Inline,
Post => R in Normal_GF32;
procedure Sanitize_GF16 (R : out Normal_GF)
with Global => null,
No_Inline,
Post => R in Normal_GF;
procedure Sanitize_GF64_PA (R : out GF64_PA)
with Global => null,
No_Inline;
procedure Sanitize_I64_Seq (R : out I64_Seq)
with Global => null,
No_Inline;
procedure Sanitize_Boolean (R : out Boolean)
with Global => null,
No_Inline;
end SPARKNaCl;
|
persan/A-gst | Ada | 27,877 | ads | pragma Ada_2005;
pragma Style_Checks (Off);
pragma Warnings (Off);
with Interfaces.C; use Interfaces.C;
limited with GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstpad_h;
with glib;
with glib;
with glib.Values;
with System;
limited with GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstcaps_h;
with Interfaces.C.Strings;
limited with GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstbuffer_h;
with GLIB; -- with GStreamer.GST_Low_Level.glibconfig_h;
with GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstformat_h;
limited with GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstevent_h;
with GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstclock_h;
-- limited with GStreamer.GST_Low_Level.glib_2_0_glib_gerror_h;
with System;
package GStreamer.GST_Low_Level.gstreamer_0_10_gst_video_video_h is
GST_VIDEO_BYTE1_MASK_32 : aliased constant String := "0xFF000000" & ASCII.NUL; -- gst/video/video.h:124
GST_VIDEO_BYTE2_MASK_32 : aliased constant String := "0x00FF0000" & ASCII.NUL; -- gst/video/video.h:125
GST_VIDEO_BYTE3_MASK_32 : aliased constant String := "0x0000FF00" & ASCII.NUL; -- gst/video/video.h:126
GST_VIDEO_BYTE4_MASK_32 : aliased constant String := "0x000000FF" & ASCII.NUL; -- gst/video/video.h:127
GST_VIDEO_BYTE1_MASK_24 : aliased constant String := "0x00FF0000" & ASCII.NUL; -- gst/video/video.h:129
GST_VIDEO_BYTE2_MASK_24 : aliased constant String := "0x0000FF00" & ASCII.NUL; -- gst/video/video.h:130
GST_VIDEO_BYTE3_MASK_24 : aliased constant String := "0x000000FF" & ASCII.NUL; -- gst/video/video.h:131
GST_VIDEO_BYTE1_MASK_32_INT : constant := 16#FF000000#; -- gst/video/video.h:133
GST_VIDEO_BYTE2_MASK_32_INT : constant := 16#00FF0000#; -- gst/video/video.h:134
GST_VIDEO_BYTE3_MASK_32_INT : constant := 16#0000FF00#; -- gst/video/video.h:135
GST_VIDEO_BYTE4_MASK_32_INT : constant := 16#000000FF#; -- gst/video/video.h:136
GST_VIDEO_BYTE1_MASK_24_INT : constant := 16#00FF0000#; -- gst/video/video.h:138
GST_VIDEO_BYTE2_MASK_24_INT : constant := 16#0000FF00#; -- gst/video/video.h:139
GST_VIDEO_BYTE3_MASK_24_INT : constant := 16#000000FF#; -- gst/video/video.h:140
GST_VIDEO_COMP1_MASK_16 : aliased constant String := "0xf800" & ASCII.NUL; -- gst/video/video.h:142
GST_VIDEO_COMP2_MASK_16 : aliased constant String := "0x07e0" & ASCII.NUL; -- gst/video/video.h:143
GST_VIDEO_COMP3_MASK_16 : aliased constant String := "0x001f" & ASCII.NUL; -- gst/video/video.h:144
GST_VIDEO_COMP1_MASK_15 : aliased constant String := "0x7c00" & ASCII.NUL; -- gst/video/video.h:146
GST_VIDEO_COMP2_MASK_15 : aliased constant String := "0x03e0" & ASCII.NUL; -- gst/video/video.h:147
GST_VIDEO_COMP3_MASK_15 : aliased constant String := "0x001f" & ASCII.NUL; -- gst/video/video.h:148
GST_VIDEO_COMP1_MASK_16_INT : constant := 16#f800#; -- gst/video/video.h:150
GST_VIDEO_COMP2_MASK_16_INT : constant := 16#07e0#; -- gst/video/video.h:151
GST_VIDEO_COMP3_MASK_16_INT : constant := 16#001f#; -- gst/video/video.h:152
GST_VIDEO_COMP1_MASK_15_INT : constant := 16#7c00#; -- gst/video/video.h:154
GST_VIDEO_COMP2_MASK_15_INT : constant := 16#03e0#; -- gst/video/video.h:155
GST_VIDEO_COMP3_MASK_15_INT : constant := 16#001f#; -- gst/video/video.h:156
-- unsupported macro: GST_VIDEO_RED_MASK_16 GST_VIDEO_COMP1_MASK_16
-- unsupported macro: GST_VIDEO_GREEN_MASK_16 GST_VIDEO_COMP2_MASK_16
-- unsupported macro: GST_VIDEO_BLUE_MASK_16 GST_VIDEO_COMP3_MASK_16
-- unsupported macro: GST_VIDEO_RED_MASK_15 GST_VIDEO_COMP1_MASK_15
-- unsupported macro: GST_VIDEO_GREEN_MASK_15 GST_VIDEO_COMP2_MASK_15
-- unsupported macro: GST_VIDEO_BLUE_MASK_15 GST_VIDEO_COMP3_MASK_15
-- unsupported macro: GST_VIDEO_RED_MASK_16_INT GST_VIDEO_COMP1_MASK_16_INT
-- unsupported macro: GST_VIDEO_GREEN_MASK_16_INT GST_VIDEO_COMP2_MASK_16_INT
-- unsupported macro: GST_VIDEO_BLUE_MASK_16_INT GST_VIDEO_COMP3_MASK_16_INT
-- unsupported macro: GST_VIDEO_RED_MASK_15_INT GST_VIDEO_COMP1_MASK_15_INT
-- unsupported macro: GST_VIDEO_GREEN_MASK_15_INT GST_VIDEO_COMP2_MASK_15_INT
-- unsupported macro: GST_VIDEO_BLUE_MASK_15_INT GST_VIDEO_COMP3_MASK_15_INT
GST_VIDEO_SIZE_RANGE : aliased constant String := "(int) [ 1, max ]" & ASCII.NUL; -- gst/video/video.h:176
GST_VIDEO_FPS_RANGE : aliased constant String := "(fraction) [ 0, max ]" & ASCII.NUL; -- gst/video/video.h:177
-- unsupported macro: GST_VIDEO_CAPS_RGB __GST_VIDEO_CAPS_MAKE_24 (1, 2, 3)
-- unsupported macro: GST_VIDEO_CAPS_BGR __GST_VIDEO_CAPS_MAKE_24 (3, 2, 1)
-- unsupported macro: GST_VIDEO_CAPS_RGBx __GST_VIDEO_CAPS_MAKE_32 (1, 2, 3)
-- unsupported macro: GST_VIDEO_CAPS_xRGB __GST_VIDEO_CAPS_MAKE_32 (2, 3, 4)
-- unsupported macro: GST_VIDEO_CAPS_BGRx __GST_VIDEO_CAPS_MAKE_32 (3, 2, 1)
-- unsupported macro: GST_VIDEO_CAPS_xBGR __GST_VIDEO_CAPS_MAKE_32 (4, 3, 2)
-- unsupported macro: GST_VIDEO_CAPS_RGBA __GST_VIDEO_CAPS_MAKE_32A (1, 2, 3, 4)
-- unsupported macro: GST_VIDEO_CAPS_ARGB __GST_VIDEO_CAPS_MAKE_32A (2, 3, 4, 1)
-- unsupported macro: GST_VIDEO_CAPS_BGRA __GST_VIDEO_CAPS_MAKE_32A (3, 2, 1, 4)
-- unsupported macro: GST_VIDEO_CAPS_ABGR __GST_VIDEO_CAPS_MAKE_32A (4, 3, 2, 1)
-- unsupported macro: GST_VIDEO_CAPS_xRGB_HOST_ENDIAN GST_VIDEO_CAPS_BGRx
-- unsupported macro: GST_VIDEO_CAPS_BGRx_HOST_ENDIAN GST_VIDEO_CAPS_xRGB
-- unsupported macro: GST_VIDEO_CAPS_RGB_16 __GST_VIDEO_CAPS_MAKE_16 (1, 2, 3)
-- unsupported macro: GST_VIDEO_CAPS_BGR_16 __GST_VIDEO_CAPS_MAKE_16 (3, 2, 1)
-- unsupported macro: GST_VIDEO_CAPS_RGB_15 __GST_VIDEO_CAPS_MAKE_15 (1, 2, 3)
-- unsupported macro: GST_VIDEO_CAPS_BGR_15 __GST_VIDEO_CAPS_MAKE_15 (3, 2, 1)
-- unsupported macro: GST_VIDEO_CAPS_r210 "video/x-raw-rgb, " "bpp = (int) 32, " "depth = (int) 30, " "endianness = (int) BIG_ENDIAN, " "red_mask = (int) 0x3ff00000, " "green_mask = (int) 0x000ffc00, " "blue_mask = (int) 0x000003ff, " "width = " GST_VIDEO_SIZE_RANGE ", " "height = " GST_VIDEO_SIZE_RANGE ", " "framerate = " GST_VIDEO_FPS_RANGE
-- unsupported macro: GST_VIDEO_CAPS_ARGB_64 __GST_VIDEO_CAPS_MAKE_64A (2, 3, 4, 1)
-- unsupported macro: GST_VIDEO_CAPS_RGB8_PALETTED "video/x-raw-rgb, bpp = (int)8, depth = (int)8, " "width = "GST_VIDEO_SIZE_RANGE" , " "height = " GST_VIDEO_SIZE_RANGE ", " "framerate = "GST_VIDEO_FPS_RANGE
-- arg-macro: procedure GST_VIDEO_CAPS_YUV (fourcc)
-- "video/x-raw-yuv, " "format = (fourcc) " fourcc ", " "width = " GST_VIDEO_SIZE_RANGE ", " "height = " GST_VIDEO_SIZE_RANGE ", " "framerate = " GST_VIDEO_FPS_RANGE
-- unsupported macro: GST_VIDEO_CAPS_GRAY8 "video/x-raw-gray, " "bpp = (int) 8, " "depth = (int) 8, " "width = " GST_VIDEO_SIZE_RANGE ", " "height = " GST_VIDEO_SIZE_RANGE ", " "framerate = " GST_VIDEO_FPS_RANGE
-- arg-macro: procedure GST_VIDEO_CAPS_GRAY16 (endianness)
-- "video/x-raw-gray, " "bpp = (int) 16, " "depth = (int) 16, " "endianness = (int) " endianness ", " "width = " GST_VIDEO_SIZE_RANGE ", " "height = " GST_VIDEO_SIZE_RANGE ", " "framerate = " GST_VIDEO_FPS_RANGE
-- unsupported macro: GST_VIDEO_BUFFER_TFF GST_BUFFER_FLAG_MEDIA1
-- unsupported macro: GST_VIDEO_BUFFER_RFF GST_BUFFER_FLAG_MEDIA2
-- unsupported macro: GST_VIDEO_BUFFER_ONEFIELD GST_BUFFER_FLAG_MEDIA3
-- unsupported macro: GST_VIDEO_BUFFER_PROGRESSIVE GST_BUFFER_FLAG_MEDIA4
-- GStreamer
-- * Copyright (C) <1999> Erik Walthinsen <[email protected]>
-- * Library <2002> Ronald Bultje <[email protected]>
-- *
-- * This library is free software; you can redistribute it and/or
-- * modify it under the terms of the GNU Library General Public
-- * License as published by the Free Software Foundation; either
-- * version 2 of the License, or (at your option) any later version.
-- *
-- * This library is distributed in the hope that it will be useful,
-- * but WITHOUT ANY WARRANTY; without even the implied warranty of
-- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-- * Library General Public License for more details.
-- *
-- * You should have received a copy of the GNU Library General Public
-- * License along with this library; if not, write to the
-- * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
-- * Boston, MA 02111-1307, USA.
--
--*
-- * GstVideoFormat:
-- * @GST_VIDEO_FORMAT_UNKNOWN: Unknown or unset video format id
-- * @GST_VIDEO_FORMAT_I420: planar 4:2:0 YUV
-- * @GST_VIDEO_FORMAT_YV12: planar 4:2:0 YVU (like I420 but UV planes swapped)
-- * @GST_VIDEO_FORMAT_YUY2: packed 4:2:2 YUV (Y0-U0-Y1-V0 Y2-U2-Y3-V2 Y4 ...)
-- * @GST_VIDEO_FORMAT_UYVY: packed 4:2:2 YUV (U0-Y0-V0-Y1 U2-Y2-V2-Y3 U4 ...)
-- * @GST_VIDEO_FORMAT_AYUV: packed 4:4:4 YUV with alpha channel (A0-Y0-U0-V0 ...)
-- * @GST_VIDEO_FORMAT_RGBx: sparse rgb packed into 32 bit, space last
-- * @GST_VIDEO_FORMAT_BGRx: sparse reverse rgb packed into 32 bit, space last
-- * @GST_VIDEO_FORMAT_xRGB: sparse rgb packed into 32 bit, space first
-- * @GST_VIDEO_FORMAT_xBGR: sparse reverse rgb packed into 32 bit, space first
-- * @GST_VIDEO_FORMAT_RGBA: rgb with alpha channel last
-- * @GST_VIDEO_FORMAT_BGRA: reverse rgb with alpha channel last
-- * @GST_VIDEO_FORMAT_ARGB: rgb with alpha channel first
-- * @GST_VIDEO_FORMAT_ABGR: reverse rgb with alpha channel first
-- * @GST_VIDEO_FORMAT_RGB: rgb
-- * @GST_VIDEO_FORMAT_BGR: reverse rgb
-- * @GST_VIDEO_FORMAT_Y41B: planar 4:1:1 YUV (Since: 0.10.18)
-- * @GST_VIDEO_FORMAT_Y42B: planar 4:2:2 YUV (Since: 0.10.18)
-- * @GST_VIDEO_FORMAT_YVYU: packed 4:2:2 YUV (Y0-V0-Y1-U0 Y2-V2-Y3-U2 Y4 ...) (Since: 0.10.23)
-- * @GST_VIDEO_FORMAT_Y444: planar 4:4:4 YUV (Since: 0.10.24)
-- * @GST_VIDEO_FORMAT_v210: packed 4:2:2 10-bit YUV, complex format (Since: 0.10.24)
-- * @GST_VIDEO_FORMAT_v216: packed 4:2:2 16-bit YUV, Y0-U0-Y1-V1 order (Since: 0.10.24)
-- * @GST_VIDEO_FORMAT_NV12: planar 4:2:0 YUV with interleaved UV plane (Since: 0.10.26)
-- * @GST_VIDEO_FORMAT_NV21: planar 4:2:0 YUV with interleaved VU plane (Since: 0.10.26)
-- * @GST_VIDEO_FORMAT_GRAY8: 8-bit grayscale (Since: 0.10.29)
-- * @GST_VIDEO_FORMAT_GRAY16_BE: 16-bit grayscale, most significant byte first (Since: 0.10.29)
-- * @GST_VIDEO_FORMAT_GRAY16_LE: 16-bit grayscale, least significant byte first (Since: 0.10.29)
-- * @GST_VIDEO_FORMAT_v308: packed 4:4:4 YUV (Since: 0.10.29)
-- * @GST_VIDEO_FORMAT_Y800: same as GST_VIDEO_FORMAT_GRAY8 (Since: 0.10.30)
-- * @GST_VIDEO_FORMAT_Y16: same as GST_VIDEO_FORMAT_GRAY16_LE (Since: 0.10.30)
-- * @GST_VIDEO_FORMAT_RGB16: rgb 5-6-5 bits per component (Since: 0.10.30)
-- * @GST_VIDEO_FORMAT_BGR16: reverse rgb 5-6-5 bits per component (Since: 0.10.30)
-- * @GST_VIDEO_FORMAT_RGB15: rgb 5-5-5 bits per component (Since: 0.10.30)
-- * @GST_VIDEO_FORMAT_BGR15: reverse rgb 5-5-5 bits per component (Since: 0.10.30)
-- * @GST_VIDEO_FORMAT_UYVP: packed 10-bit 4:2:2 YUV (U0-Y0-V0-Y1 U2-Y2-V2-Y3 U4 ...) (Since: 0.10.31)
-- * @GST_VIDEO_FORMAT_A420: planar 4:4:2:0 AYUV (Since: 0.10.31)
-- * @GST_VIDEO_FORMAT_RGB8_PALETTED: 8-bit paletted RGB (Since: 0.10.32)
-- * @GST_VIDEO_FORMAT_YUV9: planar 4:1:0 YUV (Since: 0.10.32)
-- * @GST_VIDEO_FORMAT_YVU9: planar 4:1:0 YUV (like YUV9 but UV planes swapped) (Since: 0.10.32)
-- * @GST_VIDEO_FORMAT_IYU1: packed 4:1:1 YUV (Cb-Y0-Y1-Cr-Y2-Y3 ...) (Since: 0.10.32)
-- * @GST_VIDEO_FORMAT_ARGB64: rgb with alpha channel first, 16 bits per channel (Since: 0.10.33)
-- * @GST_VIDEO_FORMAT_AYUV64: packed 4:4:4 YUV with alpha channel, 16 bits per channel (A0-Y0-U0-V0 ...) (Since: 0.10.33)
-- * @GST_VIDEO_FORMAT_r210: packed 4:4:4 RGB, 10 bits per channel (Since: 0.10.33)
-- *
-- * Enum value describing the most common video formats.
--
type GstVideoFormat is
(GST_VIDEO_FORMAT_UNKNOWN,
GST_VIDEO_FORMAT_I420,
GST_VIDEO_FORMAT_YV12,
GST_VIDEO_FORMAT_YUY2,
GST_VIDEO_FORMAT_UYVY,
GST_VIDEO_FORMAT_AYUV,
GST_VIDEO_FORMAT_RGBx,
GST_VIDEO_FORMAT_BGRx,
GST_VIDEO_FORMAT_xRGB,
GST_VIDEO_FORMAT_xBGR,
GST_VIDEO_FORMAT_RGBA,
GST_VIDEO_FORMAT_BGRA,
GST_VIDEO_FORMAT_ARGB,
GST_VIDEO_FORMAT_ABGR,
GST_VIDEO_FORMAT_RGB,
GST_VIDEO_FORMAT_BGR,
GST_VIDEO_FORMAT_Y41B,
GST_VIDEO_FORMAT_Y42B,
GST_VIDEO_FORMAT_YVYU,
GST_VIDEO_FORMAT_Y444,
GST_VIDEO_FORMAT_v210,
GST_VIDEO_FORMAT_v216,
GST_VIDEO_FORMAT_NV12,
GST_VIDEO_FORMAT_NV21,
GST_VIDEO_FORMAT_GRAY8,
GST_VIDEO_FORMAT_GRAY16_BE,
GST_VIDEO_FORMAT_GRAY16_LE,
GST_VIDEO_FORMAT_v308,
GST_VIDEO_FORMAT_Y800,
GST_VIDEO_FORMAT_Y16,
GST_VIDEO_FORMAT_RGB16,
GST_VIDEO_FORMAT_BGR16,
GST_VIDEO_FORMAT_RGB15,
GST_VIDEO_FORMAT_BGR15,
GST_VIDEO_FORMAT_UYVP,
GST_VIDEO_FORMAT_A420,
GST_VIDEO_FORMAT_RGB8_PALETTED,
GST_VIDEO_FORMAT_YUV9,
GST_VIDEO_FORMAT_YVU9,
GST_VIDEO_FORMAT_IYU1,
GST_VIDEO_FORMAT_ARGB64,
GST_VIDEO_FORMAT_AYUV64,
GST_VIDEO_FORMAT_r210);
pragma Convention (C, GstVideoFormat); -- gst/video/video.h:122
-- consider the next 2 protected
-- 24 bit
-- 32 bit
-- 32 bit alpha
-- note: the macro name uses the order on BE systems
-- 15/16 bit
-- 30 bit
-- 64 bit alpha
--*
-- * GST_VIDEO_CAPS_RGB8_PALETTED:
-- *
-- * Generic caps string for 8-bit paletted RGB video, for use in pad templates.
-- *
-- * Since: 0.10.32
--
--*
-- * GST_VIDEO_CAPS_YUV:
-- * @fourcc: YUV fourcc format that describes the pixel layout, as string
-- * (e.g. "I420", "YV12", "YUY2", "AYUV", etc.)
-- *
-- * Generic caps string for YUV video, for use in pad templates.
--
--*
-- * GST_VIDEO_CAPS_GRAY8:
-- *
-- * Generic caps string for 8-bit grayscale video, for use in pad templates.
-- *
-- * Since: 0.10.29
--
--*
-- * GST_VIDEO_CAPS_GRAY16:
-- * @endianness: endianness as string, ie. either "1234", "4321", "BIG_ENDIAN"
-- * or "LITTLE_ENDIAN"
-- *
-- * Generic caps string for 16-bit grayscale video, for use in pad templates.
-- *
-- * Since: 0.10.29
--
-- buffer flags
--*
-- * GST_VIDEO_BUFFER_TFF:
-- *
-- * If the #GstBuffer is interlaced, then the first field in the video frame is
-- * the top field. If unset, the bottom field is first.
-- *
-- * Since: 0.10.23
--
--*
-- * GST_VIDEO_BUFFER_RFF:
-- *
-- * If the #GstBuffer is interlaced, then the first field (as defined by the
-- * %GST_VIDEO_BUFFER_TFF flag setting) is repeated.
-- *
-- * Since: 0.10.23
--
--*
-- * GST_VIDEO_BUFFER_ONEFIELD:
-- *
-- * If the #GstBuffer is interlaced, then only the first field (as defined by the
-- * %GST_VIDEO_BUFFER_TFF flag setting) is to be displayed.
-- *
-- * Since: 0.10.23
--
--*
-- * GST_VIDEO_BUFFER_PROGRESSIVE:
-- *
-- * If the #GstBuffer is telecined, then the buffer is progressive if the
-- * %GST_VIDEO_BUFFER_PROGRESSIVE flag is set, else it is telecine mixed.
-- *
-- * Since: 0.10.33
--
-- functions
function gst_video_frame_rate (pad : access GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstpad_h.GstPad) return access constant Glib.Values.GValue; -- gst/video/video.h:440
pragma Import (C, gst_video_frame_rate, "gst_video_frame_rate");
function gst_video_get_size
(pad : access GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstpad_h.GstPad;
width : access GLIB.gint;
height : access GLIB.gint) return GLIB.gboolean; -- gst/video/video.h:442
pragma Import (C, gst_video_get_size, "gst_video_get_size");
function gst_video_calculate_display_ratio
(dar_n : access GLIB.guint;
dar_d : access GLIB.guint;
video_width : GLIB.guint;
video_height : GLIB.guint;
video_par_n : GLIB.guint;
video_par_d : GLIB.guint;
display_par_n : GLIB.guint;
display_par_d : GLIB.guint) return GLIB.gboolean; -- gst/video/video.h:446
pragma Import (C, gst_video_calculate_display_ratio, "gst_video_calculate_display_ratio");
function gst_video_format_parse_caps
(caps : access constant GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstcaps_h.GstCaps;
format : access GstVideoFormat;
width : access int;
height : access int) return GLIB.gboolean; -- gst/video/video.h:455
pragma Import (C, gst_video_format_parse_caps, "gst_video_format_parse_caps");
function gst_video_format_parse_caps_interlaced (caps : access GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstcaps_h.GstCaps; interlaced : access GLIB.gboolean) return GLIB.gboolean; -- gst/video/video.h:460
pragma Import (C, gst_video_format_parse_caps_interlaced, "gst_video_format_parse_caps_interlaced");
function gst_video_parse_caps_pixel_aspect_ratio
(caps : access GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstcaps_h.GstCaps;
par_n : access int;
par_d : access int) return GLIB.gboolean; -- gst/video/video.h:464
pragma Import (C, gst_video_parse_caps_pixel_aspect_ratio, "gst_video_parse_caps_pixel_aspect_ratio");
function gst_video_parse_caps_framerate
(caps : access GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstcaps_h.GstCaps;
fps_n : access int;
fps_d : access int) return GLIB.gboolean; -- gst/video/video.h:468
pragma Import (C, gst_video_parse_caps_framerate, "gst_video_parse_caps_framerate");
function gst_video_parse_caps_color_matrix (caps : access GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstcaps_h.GstCaps) return Interfaces.C.Strings.chars_ptr; -- gst/video/video.h:472
pragma Import (C, gst_video_parse_caps_color_matrix, "gst_video_parse_caps_color_matrix");
function gst_video_parse_caps_chroma_site (caps : access GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstcaps_h.GstCaps) return Interfaces.C.Strings.chars_ptr; -- gst/video/video.h:474
pragma Import (C, gst_video_parse_caps_chroma_site, "gst_video_parse_caps_chroma_site");
function gst_video_parse_caps_palette (caps : access GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstcaps_h.GstCaps) return access GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstbuffer_h.GstBuffer; -- gst/video/video.h:476
pragma Import (C, gst_video_parse_caps_palette, "gst_video_parse_caps_palette");
-- create caps given format and details
function gst_video_format_new_caps
(format : GstVideoFormat;
width : int;
height : int;
framerate_n : int;
framerate_d : int;
par_n : int;
par_d : int) return access GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstcaps_h.GstCaps; -- gst/video/video.h:480
pragma Import (C, gst_video_format_new_caps, "gst_video_format_new_caps");
function gst_video_format_new_caps_interlaced
(format : GstVideoFormat;
width : int;
height : int;
framerate_n : int;
framerate_d : int;
par_n : int;
par_d : int;
interlaced : GLIB.gboolean) return access GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstcaps_h.GstCaps; -- gst/video/video.h:486
pragma Import (C, gst_video_format_new_caps_interlaced, "gst_video_format_new_caps_interlaced");
function gst_video_format_new_template_caps (format : GstVideoFormat) return access GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstcaps_h.GstCaps; -- gst/video/video.h:493
pragma Import (C, gst_video_format_new_template_caps, "gst_video_format_new_template_caps");
-- format properties
function gst_video_format_from_fourcc (fourcc : GLIB.guint32) return GstVideoFormat; -- gst/video/video.h:497
pragma Import (C, gst_video_format_from_fourcc, "gst_video_format_from_fourcc");
function gst_video_format_to_fourcc (format : GstVideoFormat) return GLIB.guint32; -- gst/video/video.h:499
pragma Import (C, gst_video_format_to_fourcc, "gst_video_format_to_fourcc");
function gst_video_format_is_rgb (format : GstVideoFormat) return GLIB.gboolean; -- gst/video/video.h:501
pragma Import (C, gst_video_format_is_rgb, "gst_video_format_is_rgb");
function gst_video_format_is_yuv (format : GstVideoFormat) return GLIB.gboolean; -- gst/video/video.h:503
pragma Import (C, gst_video_format_is_yuv, "gst_video_format_is_yuv");
function gst_video_format_is_gray (format : GstVideoFormat) return GLIB.gboolean; -- gst/video/video.h:505
pragma Import (C, gst_video_format_is_gray, "gst_video_format_is_gray");
function gst_video_format_has_alpha (format : GstVideoFormat) return GLIB.gboolean; -- gst/video/video.h:507
pragma Import (C, gst_video_format_has_alpha, "gst_video_format_has_alpha");
function gst_video_format_get_component_depth (format : GstVideoFormat; component : int) return int; -- gst/video/video.h:510
pragma Import (C, gst_video_format_get_component_depth, "gst_video_format_get_component_depth");
function gst_video_format_get_row_stride
(format : GstVideoFormat;
component : int;
width : int) return int; -- gst/video/video.h:513
pragma Import (C, gst_video_format_get_row_stride, "gst_video_format_get_row_stride");
function gst_video_format_get_pixel_stride (format : GstVideoFormat; component : int) return int; -- gst/video/video.h:517
pragma Import (C, gst_video_format_get_pixel_stride, "gst_video_format_get_pixel_stride");
function gst_video_format_get_component_width
(format : GstVideoFormat;
component : int;
width : int) return int; -- gst/video/video.h:520
pragma Import (C, gst_video_format_get_component_width, "gst_video_format_get_component_width");
function gst_video_format_get_component_height
(format : GstVideoFormat;
component : int;
height : int) return int; -- gst/video/video.h:524
pragma Import (C, gst_video_format_get_component_height, "gst_video_format_get_component_height");
function gst_video_format_get_component_offset
(format : GstVideoFormat;
component : int;
width : int;
height : int) return int; -- gst/video/video.h:528
pragma Import (C, gst_video_format_get_component_offset, "gst_video_format_get_component_offset");
function gst_video_format_get_size
(format : GstVideoFormat;
width : int;
height : int) return int; -- gst/video/video.h:533
pragma Import (C, gst_video_format_get_size, "gst_video_format_get_size");
function gst_video_get_size_from_caps (caps : access constant GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstcaps_h.GstCaps; size : access GLIB.gint) return GLIB.gboolean; -- gst/video/video.h:537
pragma Import (C, gst_video_get_size_from_caps, "gst_video_get_size_from_caps");
function gst_video_format_convert
(format : GstVideoFormat;
width : int;
height : int;
fps_n : int;
fps_d : int;
src_format : GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstformat_h.GstFormat;
src_value : GLIB.gint64;
dest_format : GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstformat_h.GstFormat;
dest_value : access GLIB.gint64) return GLIB.gboolean; -- gst/video/video.h:539
pragma Import (C, gst_video_format_convert, "gst_video_format_convert");
-- video still frame event creation and parsing
function gst_video_event_new_still_frame (in_still : GLIB.gboolean) return access GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstevent_h.GstEvent; -- gst/video/video.h:551
pragma Import (C, gst_video_event_new_still_frame, "gst_video_event_new_still_frame");
function gst_video_event_parse_still_frame (event : access GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstevent_h.GstEvent; in_still : access GLIB.gboolean) return GLIB.gboolean; -- gst/video/video.h:553
pragma Import (C, gst_video_event_parse_still_frame, "gst_video_event_parse_still_frame");
-- video force key unit event creation and parsing
function gst_video_event_new_downstream_force_key_unit
(timestamp : GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstclock_h.GstClockTime;
streamtime : GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstclock_h.GstClockTime;
runningtime : GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstclock_h.GstClockTime;
all_headers : GLIB.gboolean;
count : GLIB.guint) return access GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstevent_h.GstEvent; -- gst/video/video.h:557
pragma Import (C, gst_video_event_new_downstream_force_key_unit, "gst_video_event_new_downstream_force_key_unit");
function gst_video_event_parse_downstream_force_key_unit
(event : access GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstevent_h.GstEvent;
timestamp : access GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstclock_h.GstClockTime;
streamtime : access GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstclock_h.GstClockTime;
runningtime : access GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstclock_h.GstClockTime;
all_headers : access GLIB.gboolean;
count : access GLIB.guint) return GLIB.gboolean; -- gst/video/video.h:563
pragma Import (C, gst_video_event_parse_downstream_force_key_unit, "gst_video_event_parse_downstream_force_key_unit");
function gst_video_event_new_upstream_force_key_unit
(running_time : GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstclock_h.GstClockTime;
all_headers : GLIB.gboolean;
count : GLIB.guint) return access GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstevent_h.GstEvent; -- gst/video/video.h:570
pragma Import (C, gst_video_event_new_upstream_force_key_unit, "gst_video_event_new_upstream_force_key_unit");
function gst_video_event_parse_upstream_force_key_unit
(event : access GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstevent_h.GstEvent;
running_time : access GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstclock_h.GstClockTime;
all_headers : access GLIB.gboolean;
count : access GLIB.guint) return GLIB.gboolean; -- gst/video/video.h:574
pragma Import (C, gst_video_event_parse_upstream_force_key_unit, "gst_video_event_parse_upstream_force_key_unit");
function gst_video_event_is_force_key_unit (event : access GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstevent_h.GstEvent) return GLIB.gboolean; -- gst/video/video.h:579
pragma Import (C, gst_video_event_is_force_key_unit, "gst_video_event_is_force_key_unit");
-- convert/encode video frame from one format to another
type GstVideoConvertFrameCallback is access procedure
(arg1 : access GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstbuffer_h.GstBuffer;
arg2 : access Glib.Error.GError;
arg3 : System.Address);
pragma Convention (C, GstVideoConvertFrameCallback); -- gst/video/video.h:583
procedure gst_video_convert_frame_async
(buf : access GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstbuffer_h.GstBuffer;
to_caps : access constant GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstcaps_h.GstCaps;
timeout : GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstclock_h.GstClockTime;
callback : GstVideoConvertFrameCallback;
user_data : System.Address;
destroy_notify : GStreamer.GST_Low_Level.glib_2_0_glib_gtypes_h.GDestroyNotify); -- gst/video/video.h:585
pragma Import (C, gst_video_convert_frame_async, "gst_video_convert_frame_async");
function gst_video_convert_frame
(buf : access GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstbuffer_h.GstBuffer;
to_caps : access constant GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstcaps_h.GstCaps;
timeout : GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstclock_h.GstClockTime;
error : System.Address) return access GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstbuffer_h.GstBuffer; -- gst/video/video.h:592
pragma Import (C, gst_video_convert_frame, "gst_video_convert_frame");
end GStreamer.GST_Low_Level.gstreamer_0_10_gst_video_video_h;
|
reznikmm/matreshka | Ada | 4,833 | 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.Generic_Collections;
package AMF.DG.Patterns.Collections is
pragma Preelaborate;
package DG_Pattern_Collections is
new AMF.Generic_Collections
(DG_Pattern,
DG_Pattern_Access);
type Set_Of_DG_Pattern is
new DG_Pattern_Collections.Set with null record;
Empty_Set_Of_DG_Pattern : constant Set_Of_DG_Pattern;
type Ordered_Set_Of_DG_Pattern is
new DG_Pattern_Collections.Ordered_Set with null record;
Empty_Ordered_Set_Of_DG_Pattern : constant Ordered_Set_Of_DG_Pattern;
type Bag_Of_DG_Pattern is
new DG_Pattern_Collections.Bag with null record;
Empty_Bag_Of_DG_Pattern : constant Bag_Of_DG_Pattern;
type Sequence_Of_DG_Pattern is
new DG_Pattern_Collections.Sequence with null record;
Empty_Sequence_Of_DG_Pattern : constant Sequence_Of_DG_Pattern;
private
Empty_Set_Of_DG_Pattern : constant Set_Of_DG_Pattern
:= (DG_Pattern_Collections.Set with null record);
Empty_Ordered_Set_Of_DG_Pattern : constant Ordered_Set_Of_DG_Pattern
:= (DG_Pattern_Collections.Ordered_Set with null record);
Empty_Bag_Of_DG_Pattern : constant Bag_Of_DG_Pattern
:= (DG_Pattern_Collections.Bag with null record);
Empty_Sequence_Of_DG_Pattern : constant Sequence_Of_DG_Pattern
:= (DG_Pattern_Collections.Sequence with null record);
end AMF.DG.Patterns.Collections;
|
reznikmm/matreshka | Ada | 7,567 | adb | ------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- Ada Modeling Framework --
-- --
-- Runtime Library Component --
-- --
------------------------------------------------------------------------------
-- --
-- Copyright © 2011-2012, Vadim Godunko <[email protected]> --
-- All rights reserved. --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions --
-- are met: --
-- --
-- * Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- --
-- * Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in the --
-- documentation and/or other materials provided with the distribution. --
-- --
-- * Neither the name of the Vadim Godunko, IE nor the names of its --
-- contributors may be used to endorse or promote products derived from --
-- this software without specific prior written permission. --
-- --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR --
-- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
-- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED --
-- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR --
-- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF --
-- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING --
-- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS --
-- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
-- --
------------------------------------------------------------------------------
-- $Revision$ $Date$
------------------------------------------------------------------------------
with AMF.Internals.Element_Collections;
with AMF.Internals.Helpers;
with AMF.Internals.Tables.CMOF_Attributes;
package body AMF.Internals.CMOF_Classifiers is
use AMF.Internals.Tables.CMOF_Attributes;
-----------------
-- Conforms_To --
-----------------
overriding function Conforms_To
(Self : not null access constant CMOF_Classifier_Proxy;
Other : AMF.CMOF.Types.CMOF_Type_Access)
return Boolean
is
-- 7.3.8 Classifier (from Kernel, Dependencies, PowerTypes, Interfaces)
--
-- [6] The query conformsTo() gives true for a classifier that defines a
-- type that conforms to another. This is used, for example, in the
-- specification of signature conformance for operations.
--
-- Classifier::conformsTo(other: Classifier): Boolean;
--
-- conformsTo = (self=other) or (self.allParents()->includes(other))
use type AMF.CMOF.Types.CMOF_Type_Access;
Generals : constant AMF.CMOF.Classifiers.Collections.Set_Of_CMOF_Classifier
:= Self.Get_General;
General : AMF.CMOF.Classifiers.CMOF_Classifier_Access;
begin
if AMF.CMOF.Types.CMOF_Type_Access (Self) = Other then
-- Class always conforms to itself.
return True;
end if;
for J in 1 .. Generals.Length loop
General := Generals.Element (J);
if General.Conforms_To (Other) then
-- If general classifier conforms to the specified type when
-- classifier conforms to is also.
return True;
end if;
end loop;
-- Otherwise, classifier doesn't conforms to the type.
return False;
end Conforms_To;
-------------------
-- Get_Attribute --
-------------------
overriding function Get_Attribute
(Self : not null access constant CMOF_Classifier_Proxy)
return AMF.CMOF.Properties.Collections.Set_Of_CMOF_Property is
begin
return
AMF.CMOF.Properties.Collections.Wrap
(AMF.Internals.Element_Collections.Wrap
(Internal_Get_Attribute (Self.Element)));
end Get_Attribute;
-----------------
-- Get_Feature --
-----------------
overriding function Get_Feature
(Self : not null access constant CMOF_Classifier_Proxy)
return AMF.CMOF.Features.Collections.Set_Of_CMOF_Feature is
begin
return
AMF.CMOF.Features.Collections.Wrap
(AMF.Internals.Element_Collections.Wrap
(Internal_Get_Feature (Self.Element)));
end Get_Feature;
-----------------
-- Get_General --
-----------------
overriding function Get_General
(Self : not null access constant CMOF_Classifier_Proxy)
return AMF.CMOF.Classifiers.Collections.Set_Of_CMOF_Classifier is
begin
return
AMF.CMOF.Classifiers.Collections.Wrap
(AMF.Internals.Element_Collections.Wrap
(Internal_Get_General (Self.Element)));
end Get_General;
--------------------------
-- Get_Inherited_Member --
--------------------------
overriding function Get_Inherited_Member
(Self : not null access constant CMOF_Classifier_Proxy)
return AMF.CMOF.Named_Elements.Collections.Set_Of_CMOF_Named_Element is
begin
return
AMF.CMOF.Named_Elements.Collections.Wrap
(AMF.Internals.Element_Collections.Wrap
(Internal_Get_Inherited_Member (Self.Element)));
end Get_Inherited_Member;
---------------------------------
-- Get_Is_Final_Specialization --
---------------------------------
overriding function Get_Is_Final_Specialization
(Self : not null access constant CMOF_Classifier_Proxy)
return Boolean is
begin
return Internal_Get_Is_Final_Specialization (Self.Element);
end Get_Is_Final_Specialization;
-----------------
-- Get_Package --
-----------------
overriding function Get_Package
(Self : not null access constant CMOF_Classifier_Proxy)
return AMF.CMOF.Packages.CMOF_Package_Access is
begin
return
AMF.CMOF.Packages.CMOF_Package_Access
(AMF.Internals.Helpers.To_Element (Internal_Get_Package (Self.Element)));
end Get_Package;
end AMF.Internals.CMOF_Classifiers;
|
reznikmm/matreshka | Ada | 3,694 | ads | ------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- Open Document Toolkit --
-- --
-- Runtime Library Component --
-- --
------------------------------------------------------------------------------
-- --
-- Copyright © 2014, Vadim Godunko <[email protected]> --
-- All rights reserved. --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions --
-- are met: --
-- --
-- * Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- --
-- * Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in the --
-- documentation and/or other materials provided with the distribution. --
-- --
-- * Neither the name of the Vadim Godunko, IE nor the names of its --
-- contributors may be used to endorse or promote products derived from --
-- this software without specific prior written permission. --
-- --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR --
-- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
-- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED --
-- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR --
-- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF --
-- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING --
-- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS --
-- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
-- --
------------------------------------------------------------------------------
-- $Revision$ $Date$
------------------------------------------------------------------------------
with XML.DOM.Elements;
package ODF.DOM.Number_Number_Style_Elements is
pragma Preelaborate;
type ODF_Number_Number_Style is limited interface
and XML.DOM.Elements.DOM_Element;
type ODF_Number_Number_Style_Access is
access all ODF_Number_Number_Style'Class
with Storage_Size => 0;
end ODF.DOM.Number_Number_Style_Elements;
|
reznikmm/matreshka | Ada | 1,674 | ads | -- Copyright (c) 1990 Regents of the University of California.
-- All rights reserved.
--
-- This software was developed by John Self of the Arcadia project
-- at the University of California, Irvine.
--
-- Redistribution and use in source and binary forms are permitted
-- provided that the above copyright notice and this paragraph are
-- duplicated in all such forms and that any documentation,
-- advertising materials, and other materials related to such
-- distribution and use acknowledge that the software was developed
-- by the University of California, Irvine. The name of the
-- University may not be used to endorse or promote products derived
-- from this software without specific prior written permission.
-- THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
-- IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
-- WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
-- TITLE template manager
-- AUTHOR: John Self (UCI)
-- DESCRIPTION supports output of internalized templates for the IO and DFA
-- packages.
-- NOTES This package is quite a memory hog, and is really only useful on
-- virtual memory systems. It could use an external file to store the
-- templates like the skeleton manager. This would save memory at the
-- cost of a slight reduction in speed and the necessity of keeping
-- copies of the template files in a known place.
-- $Header: /co/ua/self/arcadia/aflex/ada/src/RCS/template_managerS.a,v 1.3 90/01/12 15:20:49 self Exp Locker: self $
package TEMPLATE_MANAGER is
procedure GENERATE_DFA_FILE;
procedure GENERATE_IO_FILE;
end TEMPLATE_MANAGER;
|
reznikmm/matreshka | Ada | 4,117 | 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 League.Strings;
with Matreshka.DOM_Attributes;
with Matreshka.DOM_Nodes;
package Matreshka.ODF_SMIL is
type Abstract_SMIL_Attribute_Node is
abstract new Matreshka.DOM_Attributes.Abstract_Attribute_L2_Node with
record
Prefix : League.Strings.Universal_String;
end record;
overriding function Get_Namespace_URI
(Self : not null access constant Abstract_SMIL_Attribute_Node)
return League.Strings.Universal_String;
package Constructors is
procedure Initialize
(Self : not null access Abstract_SMIL_Attribute_Node'Class;
Document : not null Matreshka.DOM_Nodes.Document_Access;
Prefix : League.Strings.Universal_String)
with Inline => True;
end Constructors;
end Matreshka.ODF_SMIL;
|
reznikmm/matreshka | Ada | 3,604 | ads | ------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- Localization, Internationalization, Globalization for Ada --
-- --
-- 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$
------------------------------------------------------------------------------
package League.Locales.Constructors is
function Create_Locale
(Language : League.Strings.Universal_String) return Locale;
-- Creates locale for specified language. Language is two characters
-- lowercase string.
end League.Locales.Constructors;
|
charlie5/cBound | Ada | 1,682 | ads | -- This file is generated by SWIG. Please do not modify by hand.
--
with Interfaces;
with Interfaces.C;
with Interfaces.C.Pointers;
package xcb.xcb_render_query_version_request_t is
-- Item
--
type Item is record
major_opcode : aliased Interfaces.Unsigned_8;
minor_opcode : aliased Interfaces.Unsigned_8;
length : aliased Interfaces.Unsigned_16;
client_major_version : aliased Interfaces.Unsigned_32;
client_minor_version : aliased Interfaces.Unsigned_32;
end record;
-- Item_Array
--
type Item_Array is
array
(Interfaces.C
.size_t range <>) of aliased xcb.xcb_render_query_version_request_t
.Item;
-- Pointer
--
package C_Pointers is new Interfaces.C.Pointers
(Index => Interfaces.C.size_t,
Element => xcb.xcb_render_query_version_request_t.Item,
Element_Array => xcb.xcb_render_query_version_request_t.Item_Array,
Default_Terminator => (others => <>));
subtype Pointer is C_Pointers.Pointer;
-- Pointer_Array
--
type Pointer_Array is
array
(Interfaces.C
.size_t range <>) of aliased xcb.xcb_render_query_version_request_t
.Pointer;
-- Pointer_Pointer
--
package C_Pointer_Pointers is new Interfaces.C.Pointers
(Index => Interfaces.C.size_t,
Element => xcb.xcb_render_query_version_request_t.Pointer,
Element_Array => xcb.xcb_render_query_version_request_t.Pointer_Array,
Default_Terminator => null);
subtype Pointer_Pointer is C_Pointer_Pointers.Pointer;
end xcb.xcb_render_query_version_request_t;
|
zhmu/ananas | Ada | 212 | adb | -- PR ada/38394
-- Reporter: Michael Völske <[email protected]>
-- { dg-do assemble }
package body Array13 is
procedure Foo is
X, Y : T;
begin
null;
end;
end Array13;
|
reznikmm/matreshka | Ada | 3,739 | ads | ------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- Open Document Toolkit --
-- --
-- Runtime Library Component --
-- --
------------------------------------------------------------------------------
-- --
-- Copyright © 2014, Vadim Godunko <[email protected]> --
-- All rights reserved. --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions --
-- are met: --
-- --
-- * Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- --
-- * Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in the --
-- documentation and/or other materials provided with the distribution. --
-- --
-- * Neither the name of the Vadim Godunko, IE nor the names of its --
-- contributors may be used to endorse or promote products derived from --
-- this software without specific prior written permission. --
-- --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR --
-- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
-- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED --
-- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR --
-- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF --
-- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING --
-- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS --
-- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
-- --
------------------------------------------------------------------------------
-- $Revision$ $Date$
------------------------------------------------------------------------------
with XML.DOM.Attributes;
package ODF.DOM.Style_Diagonal_Tl_Br_Attributes is
pragma Preelaborate;
type ODF_Style_Diagonal_Tl_Br_Attribute is limited interface
and XML.DOM.Attributes.DOM_Attribute;
type ODF_Style_Diagonal_Tl_Br_Attribute_Access is
access all ODF_Style_Diagonal_Tl_Br_Attribute'Class
with Storage_Size => 0;
end ODF.DOM.Style_Diagonal_Tl_Br_Attributes;
|
AaronC98/PlaneSystem | Ada | 22,519 | adb | ------------------------------------------------------------------------------
-- Ada Web Server --
-- --
-- Copyright (C) 2004-2017, AdaCore --
-- --
-- This library is free software; you can redistribute it and/or modify --
-- it under terms of the GNU General Public License as published by the --
-- Free Software Foundation; either version 3, or (at your option) any --
-- later version. This library is distributed in the hope that it will be --
-- useful, but WITHOUT ANY WARRANTY; without even the implied warranty of --
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. --
-- --
-- --
-- --
-- --
-- --
-- You should have received a copy of the GNU General Public License and --
-- a copy of the GCC Runtime Library Exception along with this program; --
-- see the files COPYING3 and COPYING.RUNTIME respectively. If not, see --
-- <http://www.gnu.org/licenses/>. --
-- --
-- --
-- --
-- --
-- --
-- --
-- --
------------------------------------------------------------------------------
pragma Ada_2012;
with Ada.Directories;
with Ada.IO_Exceptions;
with Ada.Streams.Stream_IO;
with AWS.Headers.Values;
with AWS.Messages;
with AWS.Net.Buffered;
with AWS.Translator;
with AWS.Utils;
package body AWS.Attachments is
use Ada.Streams;
function "+"
(V : String) return Unbounded_String renames To_Unbounded_String;
UID : Utils.Counter (0);
-- Unique Id used for generating the MIME boundaries
---------
-- Add --
---------
procedure Add
(Attachments : in out List;
Filename : String;
Content_Id : String;
Headers : AWS.Headers.List := AWS.Headers.Empty_List;
Name : String := "";
Encode : Encoding := None)
is
Data : constant Content := File
(Filename, Encode, Content_Id, MIME.Content_Type (Filename));
begin
if Name = "" then
Add (Attachments, Filename, Data, Headers);
else
Add (Attachments, Name, Data, Headers);
end if;
end Add;
procedure Add
(Attachments : in out List;
Filename : String;
Headers : AWS.Headers.List;
Name : String := "";
Encode : Encoding := None)
is
Data : constant Content := File
(Filename, Encode, "", MIME.Content_Type (Filename));
begin
if Name = "" then
Add (Attachments, Filename, Data, Headers);
else
Add (Attachments, Name, Data, Headers);
end if;
end Add;
procedure Add
(Attachments : in out List;
Name : String;
Data : Content;
Headers : AWS.Headers.List := AWS.Headers.Empty_List)
is
Has_Content_Type : constant Boolean :=
Headers.Exist (AWS.Messages.Content_Type_Token);
Has_Content_TE : constant Boolean :=
Headers.Exist
(AWS.Messages.Content_Transfer_Encoding_Token);
A : Element :=
(AWS.Attachments.Data, Headers,
Data.Length + AWS.Headers.Length (Headers), Data);
begin
if Data.Filename = Null_Unbounded_String then
if Data.Content_Type /= Null_Unbounded_String then
A.Headers.Update
(Name => AWS.Messages.Content_Type_Token,
Value => To_String (Data.Content_Type));
end if;
else
A.Headers.Add
(Name => AWS.Messages.Content_Disposition_Token,
Value => "attachment; filename=""" & Name & '"');
if Data.Content_Type = Null_Unbounded_String then
if not Has_Content_Type then
-- Content_Type is not in A.Headers nor defined with Data,
-- create one based on the file name.
A.Headers.Add
(Name => AWS.Messages.Content_Type_Token,
Value => MIME.Content_Type (Name) & "; name="""
& Name & '"');
end if;
else
A.Headers.Update
(Name => AWS.Messages.Content_Type_Token,
Value => To_String (Data.Content_Type) & "; name="""
& Name & '"');
end if;
if Data.Encode = None and then not Has_Content_TE then
if MIME.Is_Text (MIME.Content_Type (Name)) then
A.Headers.Add
(Name => AWS.Messages.Content_Transfer_Encoding_Token,
Value => "8bit");
else
A.Headers.Add
(Name => AWS.Messages.Content_Transfer_Encoding_Token,
Value => "binary");
end if;
end if;
end if;
if Data.Encode = Base64 then
A.Headers.Update
(Name => AWS.Messages.Content_Transfer_Encoding_Token,
Value => "base64");
end if;
if Data.Content_Id /= Null_Unbounded_String then
A.Headers.Add
(Name => AWS.Messages.Content_Id_Token,
Value => '<' & To_String (Data.Content_Id) & '>');
end if;
Attachments.Vector.Append (A);
end Add;
procedure Add
(Parts : in out Alternatives;
Data : Content) is
begin
Parts.Parts.Append (Data);
end Add;
procedure Add
(Attachments : in out List;
Parts : Alternatives) is
begin
Attachments.Vector.Append (Element (Parts));
end Add;
----------------
-- Content_Id --
----------------
function Content_Id (Attachment : Element) return String is
begin
return AWS.Headers.Get (Attachment.Headers, Messages.Content_Id_Token);
end Content_Id;
------------------
-- Content_Type --
------------------
function Content_Type (Attachment : Element) return String is
begin
return AWS.Headers.Values.Get_Unnamed_Value
(AWS.Headers.Get (Attachment.Headers, Messages.Content_Type_Token));
end Content_Type;
-----------
-- Count --
-----------
function Count (Attachments : List) return Natural is
begin
return Natural (Attachment_Table.Length (Attachments.Vector));
end Count;
----------
-- File --
----------
function File
(Filename : String;
Encode : Encoding := None;
Content_Id : String := "";
Content_Type : String := MIME.Text_Plain) return Content is
begin
return Content'(File, Natural (Utils.File_Size (Filename)),
Content_Id => +Content_Id,
Content_Type => +Content_Type,
Filename => +Filename,
Encode => Encode);
end File;
--------------
-- Filename --
--------------
function Filename (Attachment : Element) return String is
Result : Unbounded_String;
begin
if AWS.Headers.Exist
(Attachment.Headers, Messages.Content_Disposition_Token)
then
Result :=
+(AWS.Headers.Values.Search
(AWS.Headers.Get
(Attachment.Headers, Messages.Content_Disposition_Token),
"filename"));
end if;
if Result = Null_Unbounded_String
and then
AWS.Headers.Exist
(Attachment.Headers, Messages.Content_Type_Token)
then
Result :=
+(AWS.Headers.Values.Search
(AWS.Headers.Get
(Attachment.Headers, Messages.Content_Type_Token),
"name"));
end if;
return To_String (Result);
end Filename;
--------------------------
-- For_Every_Attachment --
--------------------------
procedure For_Every_Attachment (Attachments : List) is
Quit : Boolean := False;
begin
for J in 1 .. Count (Attachments) loop
Action (Get (Attachments, J), J, Quit);
exit when Quit;
end loop;
end For_Every_Attachment;
---------
-- Get --
---------
function Get
(Attachments : List;
Index : Positive) return Element is
begin
return Attachment_Table.Element
(Container => Attachments.Vector, Index => Index);
end Get;
---------
-- Get --
---------
function Get
(Attachments : List;
Content_Id : String) return Element
is
function Get_CID (Content_Id : String) return String;
-- Returns Content_Id stripped from possibly surrounding
-- '<' '>' and prefixing "cid:".
-------------
-- Get_CID --
-------------
function Get_CID (Content_Id : String) return String is
begin
if Content_Id (Content_Id'First) = '<'
and then Content_Id (Content_Id'Last) = '>'
then
return Get_CID
(Content_Id (Content_Id'First + 1 .. Content_Id'Last - 1));
elsif Content_Id'Length > 4
and then
Content_Id (Content_Id'First .. Content_Id'First + 3) = "cid:"
then
return Content_Id (Content_Id'First + 4 .. Content_Id'Last);
else
return Content_Id;
end if;
end Get_CID;
CID : constant String := Get_CID (Content_Id);
Attachment : Element;
begin
for J in 1 .. Count (Attachments) loop
Attachment := Get (Attachments, J);
if AWS.Attachments.Content_Id (Attachment) = CID
or else AWS.Attachments.Content_Id (Attachment) = '<' & CID & '>'
then
return Attachment;
end if;
end loop;
-- No Content ID matched the request
raise Constraint_Error;
end Get;
-------------
-- Headers --
-------------
function Headers (Attachment : Element) return AWS.Headers.List is
begin
return Attachment.Headers;
end Headers;
-------------
-- Iterate --
-------------
procedure Iterate
(Attachments : List;
Process : not null access procedure (Attachment : Element)) is
begin
for Position in Attachments.Vector.Iterate loop
Attachment_Table.Query_Element (Position, Process);
end loop;
end Iterate;
----------
-- Kind --
----------
function Kind (Attachment : Element) return Attachment_Kind is
begin
return Attachment.Kind;
end Kind;
------------
-- Length --
------------
function Length
(Attachments : List;
Boundary : String) return Positive
is
L : Positive;
begin
-- The length of all start boundaries, and the 2 characters longer
-- end boundary.
L := (Boundary'Length + 6) * (Count (Attachments) + 1) + 2;
-- Add all content lengths
for J in 1 .. Count (Attachments) loop
L := L + Element (Element'(Get (Attachments, J))).Total_Length;
end loop;
return L;
end Length;
--------------------
-- Local_Filename --
--------------------
function Local_Filename (Attachment : Element) return String is
begin
return To_String (Attachment.Data.Filename);
end Local_Filename;
-----------
-- Reset --
-----------
procedure Reset
(Attachments : in out List;
Delete_Files : Boolean) is
begin
if Delete_Files then
for J in 1 .. Count (Attachments) loop
begin
Directories.Delete_File
(Name => Local_Filename (Element'(Get (Attachments, J))));
exception
when IO_Exceptions.Name_Error | IO_Exceptions.Use_Error =>
null;
end;
end loop;
end if;
Attachment_Table.Clear (Attachments.Vector);
end Reset;
---------------
-- Root_MIME --
---------------
function Root_MIME (Attachments : List) return Root_MIME_Kind is
begin
if Count (Attachments) = 1
and then Kind (Element'(Get (Attachments, 1))) = Alternative
then
return Multipart_Alternative;
else
return Multipart_Mixed;
end if;
end Root_MIME;
----------
-- Send --
----------
procedure Send
(Socket : AWS.Net.Socket_Type'Class;
Attachments : List;
Boundary : String)
is
procedure Send_Attachment (Attachment : Element);
-- Sends one Attachment, including the start boundary
procedure Send_Content (Attachment : Element);
-- Set an in-memory content
procedure Send_Content (Data : Content);
procedure Send_Alternative (Attachment : Element);
-- Send an alternative part
Pref_Suf : constant String := "--";
-- The MIME boundary prefix and suffix
Simple_Alternative : constant Boolean :=
Root_MIME (Attachments) = Multipart_Alternative;
----------------------
-- Send_Alternative --
----------------------
procedure Send_Alternative (Attachment : Element) is
A_Boundary : Unbounded_String;
begin
if not Simple_Alternative then
-- This is not the first element, we issue an embedded MIME
-- content.
Net.Buffered.Put_Line (Socket, Pref_Suf & Boundary);
Send_MIME_Header
(Socket, Attachments,
Alternative => True,
Boundary => A_Boundary);
else
A_Boundary := To_Unbounded_String (Boundary);
end if;
-- Send alternatives
for Part of Attachment.Parts loop
Net.Buffered.Put_Line (Socket, Pref_Suf & To_String (A_Boundary));
Net.Buffered.Put_Line
(Socket, Messages.Content_Type (To_String (Part.Content_Type)));
Net.Buffered.New_Line (Socket);
Send_Content (Part);
end loop;
if not Simple_Alternative then
-- Ends the alternative part
Net.Buffered.New_Line (Socket);
Net.Buffered.Put_Line
(Socket, Pref_Suf & To_String (A_Boundary) & Pref_Suf);
end if;
end Send_Alternative;
---------------------
-- Send_Attachment --
---------------------
procedure Send_Attachment (Attachment : Element) is
begin
case Attachment.Kind is
when Data => Send_Content (Attachment);
when Alternative => Send_Alternative (Attachment);
end case;
end Send_Attachment;
------------------
-- Send_Content --
------------------
procedure Send_Content (Attachment : Element) is
begin
-- Send multipart message start boundary
Net.Buffered.Put_Line (Socket, Pref_Suf & Boundary);
-- Send header
AWS.Headers.Send_Header (Socket, Attachment.Headers);
Net.Buffered.New_Line (Socket);
Send_Content (Attachment.Data);
end Send_Content;
procedure Send_Content (Data : Content) is
procedure Send_File;
procedure Send_Content;
------------------
-- Send_Content --
------------------
procedure Send_Content is
Content_Len : constant Positive := Length (Data.Content);
procedure Send;
-- Send standard content
procedure Send_Base64;
-- Send a base64 content
----------
-- Send --
----------
procedure Send is
Chunk_Shift : constant := 1023;
K : Positive := 1;
L : Natural;
begin
loop
L := Integer'Min (K + Chunk_Shift, Content_Len);
Net.Buffered.Put (Socket, Slice (Data.Content, K, L));
exit when L = Content_Len;
K := L + 1;
end loop;
Net.Buffered.New_Line (Socket);
end Send;
-----------------
-- Send_Base64 --
-----------------
procedure Send_Base64 is
Chunk_Size : constant := 60;
K : Positive := 1;
begin
while K <= Content_Len loop
if K + Chunk_Size - 1 > Content_Len then
Net.Buffered.Put_Line
(Socket,
Slice (Data.Content, K, Content_Len));
K := Content_Len + 1;
else
Net.Buffered.Put_Line
(Socket,
Slice (Data.Content, K, K + Chunk_Size - 1));
K := K + Chunk_Size;
end if;
end loop;
end Send_Base64;
begin
case Data.Encode is
when None => Send;
when Base64 => Send_Base64;
end case;
end Send_Content;
---------------
-- Send_File --
---------------
procedure Send_File is
procedure Send;
-- Send file as-is
procedure Send_Base64;
-- Send file encoded in Base64
File : Streams.Stream_IO.File_Type;
----------
-- Send --
----------
procedure Send is
Buffer : Streams.Stream_Element_Array (1 .. 4_096);
Last : Streams.Stream_Element_Offset;
begin
-- Send file content
while not Streams.Stream_IO.End_Of_File (File) loop
Streams.Stream_IO.Read (File, Buffer, Last);
Net.Buffered.Write (Socket, Buffer (1 .. Last));
end loop;
Net.Buffered.New_Line (Socket);
exception
when Net.Socket_Error =>
-- Properly close the file if needed
if Streams.Stream_IO.Is_Open (File) then
Streams.Stream_IO.Close (File);
end if;
raise;
end Send;
-----------------
-- Send_Base64 --
-----------------
procedure Send_Base64 is
Buffer_Size : constant := 60;
-- Note that this size must be a multiple of 3, this is
-- important to have proper chunk MIME encoding.
Buffer : Streams.Stream_Element_Array (1 .. Buffer_Size);
Last : Streams.Stream_Element_Offset;
begin
while not Streams.Stream_IO.End_Of_File (File) loop
Streams.Stream_IO.Read (File, Buffer, Last);
Net.Buffered.Put_Line
(Socket,
AWS.Translator.Base64_Encode (Buffer (1 .. Last)));
end loop;
end Send_Base64;
begin
Stream_IO.Open
(File, Streams.Stream_IO.In_File, To_String (Data.Filename));
case Data.Encode is
when None => Send;
when Base64 => Send_Base64;
end case;
Stream_IO.Close (File);
end Send_File;
begin
case Data.Kind is
when File => Send_File;
when AWS.Attachments.Data => Send_Content;
end case;
end Send_Content;
begin
-- Send the attachments
for J in 1 .. Integer (Attachments.Vector.Length) loop
Send_Attachment
(Attachment_Table.Element
(Container => Attachments.Vector,
Index => J));
end loop;
-- Send multipart message end boundary
Net.Buffered.Put_Line (Socket, Pref_Suf & Boundary & Pref_Suf);
end Send;
----------------------
-- Send_MIME_Header --
----------------------
procedure Send_MIME_Header
(Socket : Net.Socket_Type'Class;
Attachments : List;
Boundary : out Unbounded_String;
Alternative : Boolean := False)
is
L_Boundary : constant String :=
"----=_NextPart_" & Utils.Random_String (10) & "."
& Utils.Image (UID.Value);
begin
UID.Increment;
Boundary := To_Unbounded_String (L_Boundary);
if Alternative
or else Root_MIME (Attachments) = Multipart_Alternative
then
Net.Buffered.Put_Line
(Socket,
Messages.Content_Type ("multipart/alternative", L_Boundary));
else
Net.Buffered.Put_Line
(Socket,
Messages.Content_Type ("multipart/mixed", L_Boundary));
end if;
Net.Buffered.New_Line (Socket);
end Send_MIME_Header;
-----------
-- Value --
-----------
function Value
(Data : Unbounded_String;
Name : String := "";
Encode : Encoding := None;
Content_Id : String := "";
Content_Type : String := MIME.Text_Plain) return Content
is
CD : Unbounded_String;
begin
if Encode = Base64 then
Translator.Base64_Encode (Data, CD);
else
CD := Data;
end if;
return Content'(Attachments.Data, Length (Data),
Content_Id => +Content_Id,
Content_Type => +Content_Type,
Filename => +Name,
Encode => Encode,
Content => CD);
end Value;
end AWS.Attachments;
|
jhumphry/Ada_BinToAsc | Ada | 3,922 | ads | -- BinToAsc_Suite.Base64_Tests
-- Unit tests for BinToAsc
-- Copyright (c) 2015, James Humphry - see LICENSE file for details
with AUnit; use AUnit;
with AUnit.Test_Cases; use AUnit.Test_Cases;
with RFC4648;
with BinToAsc_Suite.Utils;
package BinToAsc_Suite.Base64_Tests is
Base64_Test_Vectors : constant Test_Vector_Array := ((TBS(""), TBS("")),
(TBS("f"), TBS("Zg==")),
(TBS("fo"), TBS("Zm8=")),
(TBS("foo"), TBS("Zm9v")),
(TBS("foob"), TBS("Zm9vYg==")),
(TBS("fooba"), TBS("Zm9vYmE=")),
(TBS("foobar"), TBS("Zm9vYmFy")));
type Base64_Test is new Test_Cases.Test_Case with null record;
procedure Register_Tests (T: in out Base64_Test);
function Name (T : Base64_Test) return Test_String;
procedure Set_Up (T : in out Base64_Test);
procedure Check_Symmetry is
new BinToAsc_Suite.Utils.Check_Symmetry(BToA => RFC4648.BToA,
Codec_To_String => RFC4648.Base64.Base64_To_String,
Codec_To_Bin => RFC4648.Base64.Base64_To_Bin);
procedure Check_Length is
new BinToAsc_Suite.Utils.Check_Length(BToA => RFC4648.BToA,
Codec_To_String => RFC4648.Base64.Base64_To_String,
Codec_To_Bin => RFC4648.Base64.Base64_To_Bin);
procedure Check_Test_Vectors_To_String is
new BinToAsc_Suite.Utils.Check_Test_Vectors_To_String(Test_Vectors => Base64_Test_Vectors,
Codec_To_String => RFC4648.Base64.Base64_To_String);
procedure Check_Test_Vectors_To_Bin is
new BinToAsc_Suite.Utils.Check_Test_Vectors_To_Bin(Test_Vectors => Base64_Test_Vectors,
Codec_To_Bin => RFC4648.Base64.Base64_To_Bin);
procedure Check_Test_Vectors_Incremental_To_String is
new BinToAsc_Suite.Utils.Check_Test_Vectors_Incremental_To_String(Test_Vectors => Base64_Test_Vectors,
Codec_To_String => RFC4648.Base64.Base64_To_String,
Max_Buffer_Length => 20);
procedure Check_Test_Vectors_Incremental_To_Bin is
new BinToAsc_Suite.Utils.Check_Test_Vectors_Incremental_To_Bin(Test_Vectors => Base64_Test_Vectors,
Codec_To_Bin => RFC4648.Base64.Base64_To_Bin,
Max_Buffer_Length => 20);
procedure Check_Test_Vectors_By_Char_To_String is
new BinToAsc_Suite.Utils.Check_Test_Vectors_By_Char_To_String(Test_Vectors => Base64_Test_Vectors,
Codec_To_String => RFC4648.Base64.Base64_To_String,
Max_Buffer_Length => 20);
procedure Check_Test_Vectors_By_Char_To_Bin is
new BinToAsc_Suite.Utils.Check_Test_Vectors_By_Char_To_Bin(Test_Vectors => Base64_Test_Vectors,
Codec_To_Bin => RFC4648.Base64.Base64_To_Bin,
Max_Buffer_Length => 20);
procedure Check_Padding (T : in out Test_Cases.Test_Case'Class);
procedure Check_Junk_Rejection (T : in out Test_Cases.Test_Case'Class);
procedure Check_Junk_Rejection_By_Char (T : in out Test_Cases.Test_Case'Class);
end BinToAsc_Suite.Base64_Tests;
|
strenkml/EE368 | Ada | 1,528 | ads |
with Memory.Container; use Memory.Container;
with Ada.Containers.Vectors;
package Memory.Arbiter is
type Arbiter_Type is new Container_Type with private;
type Arbiter_Pointer is access all Arbiter_Type'Class;
function Create_Arbiter(next : access Memory_Type'Class)
return Arbiter_Pointer;
overriding
function Clone(mem : Arbiter_Type) return Memory_Pointer;
overriding
procedure Reset(mem : in out Arbiter_Type;
context : in Natural);
overriding
procedure Set_Port(mem : in out Arbiter_Type;
port : in Natural;
ready : out Boolean);
overriding
procedure Read(mem : in out Arbiter_Type;
address : in Address_Type;
size : in Positive);
overriding
procedure Write(mem : in out Arbiter_Type;
address : in Address_Type;
size : in Positive);
overriding
procedure Idle(mem : in out Arbiter_Type;
cycles : in Time_Type);
overriding
function To_String(mem : Arbiter_Type) return Unbounded_String;
private
package Pending_Vectors is new Vectors(Natural, Time_Type);
type Arbiter_Type is new Container_Type with record
-- The current port.
port : Natural := 0;
-- Keep track of the earliest time the next even can happen for
-- each port.
pending : Pending_Vectors.Vector;
end record;
end Memory.Arbiter;
|
adamnemecek/GA_Ada | Ada | 2,183 | adb |
with Ada.Strings.Unbounded;
with Ada.Text_IO; use Ada.Text_IO;
with Blade;
with GA_Maths;
with GA_Utilities;
with Metric;
with Multivector; use Multivector;
with Multivector_Type;
procedure Test_MV is
use Blade.Names_Package;
BV_Names : Blade.Basis_Vector_Names;
Met_Matrix : constant Metric.Metric_Matrix (1 .. 5, 1 .. 5) :=
((0.0, 0.0, 0.0, 0.0, -1.0),
(0.0, 1.0, 0.0, 0.0, 0.0),
(0.0, 0.0, 1.0, 0.0, 0.0),
(0.0, 0.0, 0.0 ,1.0, 0.0),
(-1.0, 0.0, 0.0 , 0.0, 0.0));
Met : constant Metric.Metric_Record := Metric.New_Metric (Met_Matrix);
no_bv : Multivector.Multivector := Get_Basis_Vector (Blade.C3_no);
e1_bv : Multivector.Multivector := Get_Basis_Vector (Blade.C3_e1);
e2_bv : Multivector.Multivector := Get_Basis_Vector (Blade.C3_e2);
e3_bv : Multivector.Multivector := Get_Basis_Vector (Blade.C3_e3);
ni_bv : Multivector.Multivector := Get_Basis_Vector (Blade.C3_ni);
MV_A : Multivector.Multivector;
MV_AI_1 : Multivector.Multivector;
MV_Info : Multivector_Type.MV_Type_Record;
begin
BV_Names.Append (Ada.Strings.Unbounded.To_Unbounded_String ("no"));
BV_Names.Append (Ada.Strings.Unbounded.To_Unbounded_String ("e1"));
BV_Names.Append (Ada.Strings.Unbounded.To_Unbounded_String ("e2"));
BV_Names.Append (Ada.Strings.Unbounded.To_Unbounded_String ("e3"));
BV_Names.Append (Ada.Strings.Unbounded.To_Unbounded_String ("ni"));
MV_A := e1_bv + Outer_Product (e2_bv, (Outer_Product (e3_bv, e1_bv)));
GA_Utilities.Print_Multivector ("MV_A", MV_A);
New_Line;
MV_Info := Multivector_Type.Init (MV_A);
GA_Utilities.Print_Multivector_Info ("MV A Info", MV_Info);
New_Line;
MV_A := e1_bv + Outer_Product (e2_bv, e3_bv);
Put_Line ("Test_MV calling General_Inverse.");
MV_AI_1 := General_Inverse (MV_A, Met);
GA_Utilities.Print_Multivector ("MV_AI_1", MV_AI_1);
MV_Info := Multivector_Type.Init (MV_AI_1);
GA_Utilities.Print_Multivector_Info ("MV AI 1 Info", MV_Info);
exception
when anError : others =>
Put_Line ("An exception occurred in Test_MV.");
raise;
end Test_MV;
|
OneWingedShark/Byron | Ada | 264 | ads | Pragma Ada_2012;
Pragma Assertion_Policy( Check );
-- Byron.Internals is the top-level for internal packages and subprograms, it is
-- intended as a parent primarily to private packages.
Package Byron.Internals with Pure, SPARK_Mode => On is
End Byron.Internals;
|
AdaCore/gpr | Ada | 37,768 | adb | ------------------------------------------------------------------------------
-- --
-- GPR2 PROJECT MANAGER --
-- --
-- Copyright (C) 2019-2023, AdaCore --
-- --
-- This is free software; you can redistribute it and/or modify it under --
-- terms of the GNU General Public License as published by the Free Soft- --
-- ware Foundation; either version 3, or (at your option) any later ver- --
-- sion. This software is distributed in the hope that it will be useful, --
-- but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHAN- --
-- TABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public --
-- License for more details. You should have received a copy of the GNU --
-- General Public License distributed with GNAT; see file COPYING. If not, --
-- see <http://www.gnu.org/licenses/>. --
-- --
------------------------------------------------------------------------------
with Ada.Calendar.Formatting;
with Ada.Calendar.Time_Zones;
with Ada.Characters.Handling;
with Ada.Directories;
with Ada.Streams.Stream_IO;
with Ada.Strings.Fixed;
with Ada.Strings.Maps.Constants;
with Ada.Unchecked_Deallocation;
with GNAT.Rewrite_Data;
with GNAT.String_Split;
with GPR2.Version;
package body GPR2.Compilation.Protocol is
use Ada.Calendar;
use Ada.Calendar.Formatting;
use Ada.Directories;
use Ada.Streams;
use Ada.Strings.Fixed;
use Ada.Strings.Maps;
use GNAT.String_Split;
Args_Sep : constant Character := '|';
-- Channel's argument separator
function Image (N : Natural) return String;
-- Returns string representation of N without leading space
procedure Send_File_Internal
(Channel : Communication_Channel;
Path_Name : String;
Cmd : Command_Kind;
Time_Stamp : GPR2.Time_Stamp.Data);
-- Send file Path_Name over the channel with rewritting if needed
procedure Send_RAW_File_Content
(Channel : Communication_Channel;
Path_Name : String);
-- Send the file content untranslated
procedure Set_File_Stamp
(Path_Name : String; Time_Stamp : GPR2.Time_Stamp.Data) with Inline;
-- Set modification time stamp to the given file
Buffer_Size : constant := 256 * 1_024; -- 256Kb
type Buffer_Access is access Stream_Element_Array;
-- Used for RAW data
procedure Unchecked_Free is
new Ada.Unchecked_Deallocation (Stream_Element_Array, Buffer_Access);
------------
-- Adjust --
------------
overriding procedure Adjust (Channel : in out Communication_Channel) is
begin
Channel.Refs.Increment;
end Adjust;
overriding procedure Adjust (Cmd : in out Command) is
begin
Cmd.Refs.Increment;
end Adjust;
----------
-- Args --
----------
function Args (Cmd : Command) return OS_Lib.Argument_List_Access is
begin
return Cmd.Args;
end Args;
-------------------
-- Clear_Rewrite --
-------------------
procedure Clear_Rewrite (Channel : in out Communication_Channel) is
begin
Channel.WD_From := Null_Unbounded_String;
Channel.WD_To := Null_Unbounded_String;
Channel.CD_From := Null_Unbounded_String;
Channel.CD_To := Null_Unbounded_String;
end Clear_Rewrite;
-----------
-- Close --
-----------
procedure Close (Channel : in out Communication_Channel) is
begin
begin
-- Make sure we never fail, the other end-point could have already
-- closed the channel (hard ctrl-c).
Shutdown_Socket (Channel.Sock);
exception
when others =>
null;
end;
-- Now close associated socket
begin
Close_Socket (Channel.Sock);
exception
when others =>
null;
end;
Channel.Sock := No_Socket;
Clear_Rewrite (Channel);
end Close;
------------
-- Create --
------------
function Create
(Sock : Socket_Type;
Virtual : Boolean := False) return Communication_Channel is
begin
return Communication_Channel'
(Finalization.Controlled
with Sock, (if Virtual then null else Stream (Sock)),
Null_Unbounded_String, Null_Unbounded_String,
Null_Unbounded_String, Null_Unbounded_String,
new Shared_Counter (1));
end Create;
--------------
-- Finalize --
--------------
overriding procedure Finalize (Channel : in out Communication_Channel) is
procedure Unchecked_Free is
new Unchecked_Deallocation (Shared_Counter, Shared_Counter_Access);
C : Shared_Counter_Access := Channel.Refs;
begin
Channel.Refs := null;
C.Decrement;
if C.Count = 0 then
Free (Channel.Channel);
Unchecked_Free (C);
end if;
end Finalize;
overriding procedure Finalize (Cmd : in out Command) is
procedure Unchecked_Free is
new Unchecked_Deallocation (Shared_Counter, Shared_Counter_Access);
C : Shared_Counter_Access := Cmd.Refs;
begin
Cmd.Refs := null;
C.Decrement;
if C.Count = 0 then
OS_Lib.Free (Cmd.Args);
Unchecked_Free (C);
end if;
end Finalize;
-----------------
-- Get_Command --
-----------------
function Get_Command
(Channel : Communication_Channel'Class) return Command
is
use Ada.Streams.Stream_IO;
function Handle_File (Cmd : Command) return Command;
-- A file has been received, write it to disk
function Handle_RAW_File (Cmd : Command) return Command;
-- A file has been received, write it to disk, no rewrite taking place
procedure Handle_Output (Cmd : in out Command);
-- A display output is received, read it and store it into the command
-----------------
-- Handle_File --
-----------------
function Handle_File (Cmd : Command) return Command is
procedure Input
(Item : out Stream_Element_Array;
Last : out Stream_Element_Offset);
-- Read and return some data from channel
procedure Output (Item : Stream_Element_Array);
-- Write data to file
File_Name : constant String :=
Translate_Receive (Channel, Cmd.Args (2).all);
Dir : constant String := Containing_Directory (File_Name);
Size : Stream_Element_Count :=
Stream_Element_Count'Value (Cmd.Args (1).all);
-- Number of bytes remaining to be read from channel
Rewriter : Rewrite_Data.Buffer :=
Rewrite_Data.Create
(To_String (Channel.WD_To),
To_String (Channel.WD_From));
Rewriter_CD : aliased Rewrite_Data.Buffer :=
Rewrite_Data.Create
(To_String (Channel.CD_To),
To_String (Channel.CD_From));
File : File_Type;
-----------
-- Input --
-----------
procedure Input
(Item : out Stream_Element_Array;
Last : out Stream_Element_Offset) is
begin
if Size = 0 then
Last := 0;
else
Last := Stream_Element_Count'Min (Item'Length, Size);
Stream_Element_Array'Read
(Channel.Channel, Item (Item'First .. Last));
Size := Size - Last;
end if;
end Input;
------------
-- Output --
------------
procedure Output (Item : Stream_Element_Array) is
begin
Write (File, Item);
end Output;
begin
Rewrite_Data.Link (Rewriter, Rewriter_CD'Unchecked_Access);
if Dir /= "" and then not Exists (Dir) then
Create_Directory (Dir);
end if;
begin
Create (File, Out_File, File_Name);
Rewrite_Data.Rewrite (Rewriter, Input'Access, Output'Access);
Close (File);
-- Set time stamp if any
if Cmd.Args'Length = 3 then
Set_File_Stamp
(File_Name, Time_Stamp.Data (Args (Cmd) (3).all));
end if;
exception
when others =>
if Is_Open (File) then
Close (File);
end if;
end;
return Get_Command (Channel);
end Handle_File;
-------------------
-- Handle_Output --
-------------------
procedure Handle_Output (Cmd : in out Command) is
function Is_Number (Cmd : Command) return Boolean is
(Is_Subset
(To_Set (Cmd.Args (1).all), Constants.Decimal_Digit_Set));
begin
if Cmd.Args'Length = 2
and then Is_Number (Cmd)
then
declare
Size : constant Natural :=
Natural'Value (Cmd.Args (1).all);
Result : String (1 .. Size);
begin
if Size = 0 then
Cmd.Output := Null_Unbounded_String;
else
String'Read (Channel.Channel, Result);
Cmd.Output := To_Unbounded_String (Result);
end if;
end;
else
raise Wrong_Command
with "Expected DP found " & Command_Kind'Image (Cmd.Cmd);
end if;
end Handle_Output;
---------------------
-- Handle_RAW_File --
---------------------
function Handle_RAW_File (Cmd : Command) return Command is
File_Name : constant String :=
Translate_Receive (Channel, Cmd.Args (1).all);
Dir : constant String := Containing_Directory (File_Name);
Time_Stamp : GPR2.Time_Stamp.Data := GPR2.Time_Stamp.Empty;
begin
if Dir /= "" and then not Exists (Dir) then
Create_Directory (Dir);
end if;
if Cmd.Args'Length = 2 then
-- We have a time-stamp, use it
Time_Stamp := GPR2.Time_Stamp.Data (Args (Cmd) (2).all);
end if;
Get_RAW_File_Content (Channel, File_Name, Time_Stamp);
return Get_Command (Channel);
end Handle_RAW_File;
Result : Command;
Args : Slice_Set;
begin
declare
Line : constant String := String'Input (Channel.Channel);
C : constant String :=
(if Line'Length >= 2
then Line (Line'First .. Line'First + 1)
else "");
begin
if C in
"EX" | "AK" | "TS" | "ES" | "FL" | "FR" | "OK" | "KO"
| "CX" | "CU" | "DP" | "EC" | "PG" | "SY" | "IR"
then
Result.Cmd := Command_Kind'Value (C);
-- Slice arguments
Create
(Args,
Line (Line'First + 2 .. Line'Last),
String'(1 => Args_Sep));
Result.Args :=
new OS_Lib.Argument_List (1 .. Integer (Slice_Count (Args)));
for K in Result.Args'Range loop
Result.Args (K) := new String'(Slice (Args, Slice_Number (K)));
end loop;
if Result.Cmd = FL then
-- We got some file data to write
return Handle_File (Result);
elsif Result.Cmd = FR then
return Handle_RAW_File (Result);
elsif Result.Cmd = DP then
-- We got an output to display
Handle_Output (Result);
elsif Result.Cmd = EX then
-- Last - 1 parameter is the compiler options, ensure that we
-- are using native directory separator. This is a requirement
-- to have a cross compilation from a Windows builder to a
-- Linux slave.
declare
F_Idx : constant Positive :=
Result.Args'Last - 1;
Filename : constant String :=
To_Native_Directory_Separator
(Result.Args (F_Idx).all);
begin
OS_Lib.Free (Result.Args (F_Idx));
Result.Args (F_Idx) := new String'(Filename);
end;
end if;
else
if Line'Length > 0 then
raise Wrong_Command with Line;
else
raise Wrong_Command with "empty command line";
end if;
end if;
return Result;
end;
exception
when others =>
-- Any exception means that the channel has been closed. Return an
-- EC command (which has no parameter).
Result.Cmd := SI;
OS_Lib.Free (Result.Args);
Result.Args := new OS_Lib.Argument_List (1 .. 0);
return Result;
end Get_Command;
-----------------
-- Get_Context --
-----------------
procedure Get_Context
(Channel : Communication_Channel;
Target : out Unbounded_String;
Project_Name : out Unbounded_String;
Build_Env : out Unbounded_String;
Sync : out Boolean;
Timestamp : out Time_Stamp.Data;
Version : out Unbounded_String;
Hash : out Unbounded_String;
Included_Artifact_Patterns : out Unbounded_String;
Is_Ping : out Boolean)
is
Line : constant Command := Get_Command (Channel);
begin
Is_Ping := False;
-- Note that to ensure GPRslave stays compatible with old
-- version of GNAT Pro and GPRbuild all parameters after the
-- 6th must be optional when retrieving the context. Note doing
-- that will make GPRslave raise an exception instead of
-- reporting a proper non-compatible context.
if Line.Cmd = CX
and then Line.Args'Length >= 6
then
Target := To_Unbounded_String (Line.Args (1).all);
Project_Name := To_Unbounded_String (Line.Args (2).all);
Build_Env := To_Unbounded_String (Line.Args (3).all);
Sync := Boolean'Value (Line.Args (4).all);
Timestamp := Time_Stamp.Data (Line.Args (5).all);
Version := To_Unbounded_String (Line.Args (6).all);
if Line.Args'Length > 6 then
Hash := To_Unbounded_String (Line.Args (7).all);
else
Hash := Null_Unbounded_String;
end if;
if Line.Args'Length > 7 then
Included_Artifact_Patterns :=
To_Unbounded_String (Line.Args (8).all);
else
Included_Artifact_Patterns := Null_Unbounded_String;
end if;
elsif Line.Cmd = PG then
Is_Ping := True;
else
raise Wrong_Command
with "Expected CX found " & Command_Kind'Image (Line.Cmd);
end if;
end Get_Context;
-----------------------
-- Get_Info_Response --
-----------------------
procedure Get_Info_Response
(Channel : Communication_Channel;
Version_String : out Unbounded_String;
Current_UTC_Time : out Time_Stamp.Data;
GPR_Hash : out Unbounded_String;
Success : out Boolean)
is
Cmd : constant Command := Get_Command (Channel);
begin
if Cmd.Args'Length = 3
and then Cmd.Cmd in OK | KO
then
Version_String := To_Unbounded_String (Cmd.Args (1).all);
Current_UTC_Time := Time_Stamp.Data (Cmd.Args (2).all);
GPR_Hash := To_Unbounded_String (Cmd.Args (3).all);
Success := (if Kind (Cmd) = KO then False);
else
Success := False;
end if;
end Get_Info_Response;
-------------
-- Get_Pid --
-------------
procedure Get_Pid
(Channel : Communication_Channel;
Pid : out Remote_Id;
Success : out Boolean)
is
Cmd : constant Command := Get_Command (Channel);
begin
if Cmd.Args'Length = 1
and then Cmd.Cmd in OK | KO
then
Pid := Remote_Id'Value (Cmd.Args (1).all);
Success := (if Kind (Cmd) = KO then False);
else
Success := False;
end if;
end Get_Pid;
--------------------------
-- Get_RAW_File_Content --
--------------------------
procedure Get_RAW_File_Content
(Channel : Communication_Channel;
Path_Name : String;
Timestamp : Time_Stamp.Data := Time_Stamp.Empty)
is
use type Time_Stamp.Data;
Buffer : Buffer_Access;
Last : Stream_Element_Offset;
Size : Stream_Element_Offset;
File : Stream_IO.File_Type;
begin
Buffer := new Stream_Element_Array (1 .. Buffer_Size);
Stream_IO.Create (File, Stream_IO.Out_File, Path_Name);
loop
-- Get the size
Stream_Element_Offset'Read (Channel.Channel, Size);
exit when Size = 0;
-- Read this chunk
while Size > 0 loop
Receive_Socket (Channel.Sock, Buffer (1 .. Size), Last);
if Last = 0 then
-- Last = First - 1 then socket closed by peer
raise Socket_Error;
end if;
Stream_IO.Write (File, Buffer (1 .. Last));
Size := Size - Last;
end loop;
end loop;
Stream_IO.Close (File);
if Timestamp /= Time_Stamp.Empty then
Set_File_Stamp (Path_Name, Timestamp);
end if;
Unchecked_Free (Buffer);
exception
when others =>
-- If the file was opened, let's close it
if Stream_IO.Is_Open (File) then
Stream_IO.Delete (File);
elsif Exists (Path_Name) then
-- If the file has been created, make sure it is deleted as the
-- content may be truncated.
Delete_File (Path_Name);
end if;
Unchecked_Free (Buffer);
raise;
end Get_RAW_File_Content;
-----------
-- Image --
-----------
function Image (N : Natural) return String is
N_Img : constant String := Natural'Image (N);
begin
return N_Img (N_Img'First + 1 .. N_Img'Last);
end Image;
----------------
-- Initialize --
----------------
overriding procedure Initialize (Channel : in out Communication_Channel) is
begin
Channel.Refs := new Shared_Counter (1);
end Initialize;
overriding procedure Initialize (Cmd : in out Command) is
begin
Cmd.Refs := new Shared_Counter (1);
end Initialize;
----------
-- Kind --
----------
function Kind (Cmd : Command) return Command_Kind is
begin
return Cmd.Cmd;
end Kind;
------------
-- Output --
------------
function Output (Cmd : Command) return Unbounded_String is
begin
return Cmd.Output;
end Output;
--------------
-- Send_Ack --
--------------
procedure Send_Ack (Channel : Communication_Channel; Pid : Remote_Id) is
begin
String'Output
(Channel.Channel, Command_Kind'Image (AK) & Image (Pid));
end Send_Ack;
-------------------
-- Send_Clean_Up --
-------------------
procedure Send_Clean_Up
(Channel : Communication_Channel; Project_Name : String) is
begin
String'Output
(Channel.Channel, Command_Kind'Image (CU) & Project_Name);
end Send_Clean_Up;
------------------
-- Send_Context --
------------------
procedure Send_Context
(Channel : Communication_Channel;
Target : String;
Project_Name : String;
Build_Env : String;
Sync : Boolean;
Hash : String;
Included_Artifact_Patterns : String) is
begin
String'Output
(Channel.Channel,
Command_Kind'Image (CX) & Target & Args_Sep & Project_Name
& Args_Sep & Build_Env
& Args_Sep & Boolean'Image (Sync)
& Args_Sep & String (Time_Stamp.UTC_Time)
& Args_Sep & Version.Long_Value (Host => False)
& Args_Sep & Hash
& Args_Sep & Included_Artifact_Patterns);
end Send_Context;
-----------------------------
-- Send_End_Of_Compilation --
-----------------------------
procedure Send_End_Of_Compilation (Channel : Communication_Channel) is
begin
String'Output (Channel.Channel, Command_Kind'Image (EC));
end Send_End_Of_Compilation;
---------------------------
-- Send_End_Of_File_List --
---------------------------
procedure Send_End_Of_File_List (Channel : Communication_Channel) is
begin
String'Output (Channel.Channel, Command_Kind'Image (ES));
end Send_End_Of_File_List;
---------------
-- Send_Exec --
---------------
procedure Send_Exec
(Channel : Communication_Channel;
Project : String;
Dir : String;
Language : String;
Target : String;
Runtime : String;
Options : Containers.Value_List;
Obj_Name : Name_Type;
Dep_Name : String;
Env : String;
Filter : access function (Str, Sep : String) return String := null)
is
function Filter_Wrapper (Str, Sep : String) return String
is (if Filter = null then Str else Filter (Str, Sep));
R_Cmd : Unbounded_String;
begin
-- Options are serialized into a string and separated with Opts_Sep
for K in Options.First_Index .. Options.Last_Index loop
Append (R_Cmd, Filter_Wrapper (Options (K), WD_Path_Tag));
if K /= Options.Last_Index then
Append (R_Cmd, Opts_Sep);
end if;
end loop;
-- Send the command over the channel
String'Output
(Channel.Channel,
Command_Kind'Image (EX)
& Filter_Wrapper (Project, WD_Path_Tag)
& Args_Sep & Dir
& Args_Sep & Language
& Args_Sep & Target
& Args_Sep & Runtime
& Args_Sep & String (Obj_Name)
& Args_Sep & Dep_Name
& Args_Sep & To_String (R_Cmd)
& Args_Sep & Filter_Wrapper (Env, WD_Path_Tag));
end Send_Exec;
---------------
-- Send_File --
---------------
procedure Send_File
(Channel : Communication_Channel;
Path_Name : String;
Rewrite : Boolean;
Keep_Time_Stamp : Boolean := False)
is
Time_Stamp : GPR2.Time_Stamp.Data := GPR2.Time_Stamp.Empty;
begin
if Keep_Time_Stamp then
Time_Stamp := GPR2.Time_Stamp.From_Time
(Modification_Time (Path_Name)
- Duration (Time_Zones.UTC_Time_Offset) * 60.0);
end if;
if Rewrite then
Send_File_Internal (Channel, Path_Name, FL, Time_Stamp);
else
if Exists (Path_Name) then
String'Output
(Channel.Channel,
Command_Kind'Image (FR)
& Translate_Send (Channel, Path_Name)
& (if Keep_Time_Stamp then Args_Sep & String (Time_Stamp)
else ""));
Send_RAW_File_Content (Channel, Path_Name);
end if;
end if;
end Send_File;
------------------------
-- Send_File_Internal --
------------------------
procedure Send_File_Internal
(Channel : Communication_Channel;
Path_Name : String;
Cmd : Command_Kind;
Time_Stamp : GPR2.Time_Stamp.Data)
is
use Ada.Streams.Stream_IO;
use type GPR2.Time_Stamp.Data;
procedure Input
(Item : out Stream_Element_Array; Last : out Stream_Element_Offset);
-- Get input data from file
procedure Output (Item : Stream_Element_Array);
-- Send data to channel
function File_Size return Natural;
-- Compute the size of the file as rewritten
File : File_Type;
F_Size : Natural;
Rewriter : Rewrite_Data.Buffer :=
Rewrite_Data.Create
(To_String (Channel.WD_From),
To_String (Channel.WD_To));
Rewriter_CD : aliased Rewrite_Data.Buffer :=
Rewrite_Data.Create
(To_String (Channel.CD_From),
To_String (Channel.CD_To));
---------------
-- File_Size --
---------------
function File_Size return Natural is
procedure Count (Item : Stream_Element_Array);
-- Count bytes
Result : Natural := Natural (Size (Path_Name));
-----------
-- Count --
-----------
procedure Count (Item : Stream_Element_Array) is
begin
Result := Result + Item'Length;
end Count;
begin
if Channel.WD_From /= Null_Unbounded_String
and then Length (Channel.WD_From) <= Result
then
Result := 0;
Rewrite_Data.Rewrite (Rewriter, Input'Access, Count'Access);
Reset (File);
end if;
return Result;
end File_Size;
-----------
-- Input --
-----------
procedure Input
(Item : out Stream_Element_Array; Last : out Stream_Element_Offset) is
begin
if End_Of_File (File) then
Last := 0;
else
Read (File, Item, Last);
end if;
end Input;
------------
-- Output --
------------
procedure Output (Item : Stream_Element_Array) is
begin
Stream_Element_Array'Write (Channel.Channel, Item);
end Output;
begin
Rewrite_Data.Link (Rewriter, Rewriter_CD'Unchecked_Access);
if Exists (Path_Name) then
begin
Open (File, In_File, Path_Name);
-- First compute the file size as translated, note that this
-- means that we are parsing the file twice.
F_Size := File_Size;
String'Output
(Channel.Channel,
Command_Kind'Image (Cmd) & Image (F_Size)
& Args_Sep & Translate_Send (Channel, Path_Name)
& (if Time_Stamp /= GPR2.Time_Stamp.Empty
then Args_Sep & String (Time_Stamp) else ""));
if F_Size /= 0 then
Rewrite_Data.Rewrite (Rewriter, Input'Access, Output'Access);
end if;
Close (File);
exception
when others =>
if Is_Open (File) then
Close (File);
end if;
end;
else
raise Constraint_Error with "File not found : " & Path_Name;
end if;
end Send_File_Internal;
-----------------------
-- Send_Info_Request --
-----------------------
procedure Send_Info_Request (Channel : Communication_Channel) is
begin
String'Output (Channel.Channel, Command_Kind'Image (IR));
end Send_Info_Request;
------------------------
-- Send_Info_Response --
------------------------
procedure Send_Info_Response
(Channel : Communication_Channel;
Version_String : String;
Current_UTC_Time : Time_Stamp.Data;
GPR_Hash : String) is
begin
String'Output
(Channel.Channel, Command_Kind'Image (OK) &
Version_String & Args_Sep &
String (Current_UTC_Time) & Args_Sep &
GPR_Hash);
end Send_Info_Response;
-------------
-- Send_Ko --
-------------
procedure Send_Ko
(Channel : Communication_Channel; Pid : Compilation.Remote_Id) is
begin
String'Output
(Channel.Channel, Command_Kind'Image (KO) & Image (Pid));
end Send_Ko;
procedure Send_Ko
(Channel : Communication_Channel;
Message : String := "") is
begin
String'Output (Channel.Channel, Command_Kind'Image (KO) & Message);
end Send_Ko;
procedure Send_Ko
(Channel : Communication_Channel;
Files : File_Data_Set.Vector)
is
Args : Unbounded_String;
First : Boolean := True;
begin
for F of Files loop
if First then
First := False;
else
Append (Args, Args_Sep);
end if;
Append (Args, To_String (F.Path_Name));
end loop;
String'Output
(Channel.Channel, Command_Kind'Image (KO) & To_String (Args));
end Send_Ko;
-------------
-- Send_Ok --
-------------
procedure Send_Ok
(Channel : Communication_Channel; Pid : Compilation.Remote_Id) is
begin
String'Output
(Channel.Channel, Command_Kind'Image (OK) & Image (Pid));
end Send_Ok;
procedure Send_Ok (Channel : Communication_Channel) is
begin
String'Output (Channel.Channel, Command_Kind'Image (OK));
end Send_Ok;
-----------------
-- Send_Output --
-----------------
procedure Send_Output
(Channel : Communication_Channel; File_Name : String) is
begin
Send_File_Internal (Channel, File_Name, DP, Time_Stamp.Empty);
end Send_Output;
------------------------
-- Send_Ping_Response --
------------------------
procedure Send_Ping_Response
(Channel : Communication_Channel;
Version_String : String;
Current_UTC_Time : Time_Stamp.Data;
GPR_Hash : String) is
begin
String'Output
(Channel.Channel, Command_Kind'Image (OK) &
Version_String & ASCII.GS &
String (Current_UTC_Time) & ASCII.GS &
GPR_Hash);
end Send_Ping_Response;
---------------------------
-- Send_RAW_File_Content --
---------------------------
procedure Send_RAW_File_Content
(Channel : Communication_Channel;
Path_Name : String)
is
type Buffer_Access is access Stream_Element_Array;
procedure Unchecked_Free is
new Unchecked_Deallocation (Stream_Element_Array, Buffer_Access);
Buffer : Buffer_Access;
Last : Stream_Element_Offset;
Sent : Stream_Element_Offset;
File : Stream_IO.File_Type;
begin
Buffer := new Stream_Element_Array (1 .. Buffer_Size);
-- A somewhat large buffer is needed to transfer big file efficiently.
-- Here we use a buffer which should be large enough for read most file
-- contents in one OS call.
--
-- This is allocated on the heap to avoid too much pressure on the
-- stack of the tasks.
-- Open the file in shared mode as multiple tasks could have
-- to send it.
Stream_IO.Open
(File, Stream_IO.In_File, Path_Name, Form => "shared=yes");
-- Always send an empty stream element array at the end.
-- This is used as EOF tag.
loop
Stream_IO.Read (File, Buffer.all, Last);
-- Send the chunk size
Stream_Element_Offset'Write (Channel.Channel, Last);
exit when Last = 0;
-- Send the chunk data
Sent := 1;
loop
Send_Socket (Channel.Sock, Buffer (Sent .. Last), Sent);
exit when Sent = Last;
Sent := Sent + 1;
end loop;
end loop;
Stream_IO.Close (File);
Unchecked_Free (Buffer);
exception
when others =>
if Stream_IO.Is_Open (File) then
Stream_IO.Close (File);
end if;
Unchecked_Free (Buffer);
raise;
end Send_RAW_File_Content;
-----------------------
-- Send_Slave_Config --
-----------------------
procedure Send_Slave_Config
(Channel : Communication_Channel;
Max_Process : Positive;
Root_Directory : String;
Clock_Status : Boolean) is
begin
String'Output
(Channel.Channel,
Command_Kind'Image (OK)
& Image (Max_Process)
& Args_Sep & Root_Directory
& Args_Sep & Boolean'Image (Clock_Status));
end Send_Slave_Config;
-----------------------
-- Send_Sync_Request --
-----------------------
procedure Send_Sync_Request (Channel : Communication_Channel) is
begin
String'Output (Channel.Channel, Command_Kind'Image (SY));
end Send_Sync_Request;
--------------------
-- Set_File_Stamp --
--------------------
procedure Set_File_Stamp
(Path_Name : String; Time_Stamp : GPR2.Time_Stamp.Data)
is
use type Time_Zones.Time_Offset;
TS : constant String (GPR2.Time_Stamp.Data'Range) := String (Time_Stamp);
T : constant Time :=
Time_Of (Year => Year_Number'Value (TS (1 .. 4)),
Month => Month_Number'Value (TS (5 .. 6)),
Day => Day_Number'Value (TS (7 .. 8)),
Hour => Hour_Number'Value (TS (9 .. 10)),
Minute => Minute_Number'Value (TS (11 .. 12)),
Second => Second_Number'Value (TS (13 .. 14)),
Time_Zone => -Time_Zones.UTC_Time_Offset);
-- Time_Zone is negative to translate the UTC Time_Stamp to local time
begin
OS_Lib.Set_File_Last_Modify_Time_Stamp
(Path_Name,
OS_Lib.GM_Time_Of
(Year => Formatting.Year (T),
Month => Formatting.Month (T),
Day => Formatting.Day (T),
Hour => Formatting.Hour (T),
Minute => Formatting.Minute (T),
Second => Formatting.Second (T)));
end Set_File_Stamp;
--------------------
-- Set_Rewrite_CD --
--------------------
procedure Set_Rewrite_CD
(Channel : in out Communication_Channel; Path : String)
is
P : String := OS_Lib.Normalize_Pathname
(Path, Case_Sensitive => not On_Windows);
begin
if On_Windows then
-- On Windows the mapping file contains non normalized pathname. The
-- format is an upper-case driver letter, all the remaining of the
-- path is lower-case and the directory separator is a slash. We
-- ensure that the compiler path registered follows this format
-- to properly rewrite the runtime path in the mapping file.
pragma Warnings (Off, "this code can never be executed and has been");
P (P'First) := Characters.Handling.To_Upper (P (P'First));
P := Strings.Fixed.Translate (P, Strings.Maps.To_Mapping ("\", "/"));
pragma Warnings (On);
end if;
Channel.CD_From := To_Unbounded_String (P);
Channel.CD_To := To_Unbounded_String (CD_Path_Tag);
end Set_Rewrite_CD;
--------------------
-- Set_Rewrite_WD --
--------------------
procedure Set_Rewrite_WD
(Channel : in out Communication_Channel; Path : String) is
begin
Channel.WD_From := To_Unbounded_String (Path);
Channel.WD_To := To_Unbounded_String (WD_Path_Tag);
end Set_Rewrite_WD;
----------
-- Sock --
----------
function Sock (Channel : Communication_Channel) return Socket_Type is
begin
return Channel.Sock;
end Sock;
----------------
-- Sync_Files --
----------------
procedure Sync_Files
(Channel : Communication_Channel;
Root_Dir : String;
Files : File_Data_Set.Vector) is
begin
Create_Args : declare
Args : Unbounded_String;
First : Boolean := True;
begin
for F of Files loop
if First then
First := False;
else
Append (Args, Args_Sep);
end if;
Append (Args, F.Path_Name);
Append (Args, Args_Sep);
Append (Args, String (F.Timestamp));
Append (Args, Args_Sep);
Append (Args, Boolean'Image (F.Is_Executable));
end loop;
String'Output
(Channel.Channel,
Command_Kind'Image (TS) & To_String (Args));
end Create_Args;
declare
Cmd : constant Command := Get_Command (Channel);
begin
if Kind (Cmd) = KO then
for Filename of Args (Cmd).all loop
Send_RAW_File_Content
(Channel,
(if Root_Dir = ""
then ""
else Root_Dir & OS_Lib.Directory_Separator) & Filename.all);
end loop;
end if;
end;
end Sync_Files;
-----------------------
-- Translate_Receive --
-----------------------
function Translate_Receive
(Channel : Communication_Channel; Str : String) return String
is
P : constant Natural := Index (Str, To_String (Channel.WD_To));
begin
if P = 0 then
return Str;
else
-- Make sure we translate the filename to native directory seprator
return To_Native_Directory_Separator
(To_String (Channel.WD_From)
& Str (P + Length (Channel.WD_To) .. Str'Last));
end if;
end Translate_Receive;
--------------------
-- Translate_Send --
--------------------
function Translate_Send
(Channel : Communication_Channel; Str : String) return String
is
P : constant Natural := Index (Str, To_String (Channel.WD_From));
begin
if P = 0 then
return Str;
else
return To_String (Channel.WD_To)
& Str (P + Length (Channel.WD_From) .. Str'Last);
end if;
end Translate_Send;
end GPR2.Compilation.Protocol;
|
Kurinkitos/Twizy-Security | Ada | 1,125 | adb | with Ada.Numerics.Generic_Elementary_Functions;
package body Mathutil with SPARK_Mode => Off is
package FloatingMath is
new Ada.Numerics.Generic_Elementary_Functions(FloatingNumber);
function ArcTan(Y : FloatingNumber; X : FloatingNumber) return FloatingNumber
is
begin
return FloatingMath.ArcTan(Y / X, 1.0, 360.0);
end ArcTan;
function Sin(X : FloatingNumber) return FloatingNumber
is
begin
return FloatingMath.Sin(X, 360.0);
end;
function Cos(X : FloatingNumber) return FloatingNumber
is
begin
return FloatingMath.Cos(X, 360.0);
end;
function Tan(X : FloatingNumber) return FloatingNumber
is
begin
return FloatingMath.Tan(X, 360.0);
end;
function Sin_r(X : FloatingNumber) return FloatingNumber
is
begin
return FloatingMath.Sin(X);
end;
function Cos_r(X : FloatingNumber) return FloatingNumber
is
begin
return FloatingMath.Cos(X);
end;
function Tan_r(X : FloatingNumber) return FloatingNumber
is
begin
return FloatingMath.Tan(X);
end;
function Sqrt(X : FloatingNumber) return FloatingNumber
is
begin
return FloatingMath.Sqrt(X);
end Sqrt;
end;
|
reznikmm/matreshka | Ada | 4,647 | ads | ------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- Localization, Internationalization, Globalization for Ada --
-- --
-- Runtime Library Component --
-- --
------------------------------------------------------------------------------
-- --
-- Copyright © 2011-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 package provides binding to subset of Windows API.
------------------------------------------------------------------------------
with Interfaces.C.Strings;
with Interfaces.C.Pointers;
with System;
with Matreshka.Internals.Strings.C;
with Matreshka.Internals.Utf16;
package Matreshka.Internals.Windows is
pragma Preelaborate;
subtype DWORD is interfaces.C.unsigned_long;
subtype LONG is Interfaces.C.long;
subtype LPCSTR is Interfaces.C.Strings.chars_ptr;
subtype LPWSTR is Matreshka.Internals.Strings.C.Utf16_Code_Unit_Access;
subtype LPWCH is LPWSTR;
type LPCWSTR is access constant Matreshka.Internals.Utf16.Utf16_Code_Unit;
pragma Convention (C, LPCWSTR);
function wcslen (str : LPWSTR) return Interfaces.C.size_t;
pragma Import (C, wcslen);
type HMODULE is new System.Address;
-----------------------------------------------------------
-- Used in command line/environment conversion package --
-----------------------------------------------------------
package WCHAR_Pointers is
new Interfaces.C.Pointers
(Matreshka.Internals.Utf16.Utf16_String_Index,
Matreshka.Internals.Utf16.Utf16_Code_Unit,
Matreshka.Internals.Utf16.Unaligned_Utf16_String,
0);
end Matreshka.Internals.Windows;
|
KLOC-Karsten/adaoled | Ada | 1,868 | ads | --
-- Monochrome Bitmap Graphics Library
--
--
with Interfaces; use Interfaces;
with Bitmap_Graphics; use Bitmap_Graphics;
generic
Width : Natural;
Height : Natural;
package Bitmap_Buffer is
type Content is array ( 0 .. (Width * Height/8) ) of Unsigned_8;
type Buffer is record
Data : Content;
end record;
type Buffer_Ref is access all Buffer;
-- Set the color for the whole buffer.
procedure Set
(Buf: Buffer_Ref; Clr: Color);
-- Set the color for one point.
procedure Set
(Buf: Buffer_Ref; P: Point; Clr: Color);
-- Draw a point with a color.
procedure Dot
(Buf:Buffer_Ref; P:Point; Size:Positive:=1; Clr:Color:=White);
-- Draw a line from P to Q.
procedure Line
(Buf:Buffer_Ref; P,Q: Point; Size:Positive:=1; Clr:Color:=White);
-- Outline a rectangle P,Q
procedure Rectangle
(Buf:Buffer_Ref; P,Q: Point; Size:Positive:=1; Clr:Color:=White);
procedure Fill_Rectangle
(Buf:Buffer_Ref; P,Q: Point; Clr:Color:=White);
procedure Circle
(Buf:Buffer_Ref; P: Point; R: Natural; Size: Positive:=1; Clr: Color:=White);
procedure Fill_Circle
(Buf:Buffer_Ref; P: Point; R: Natural; Clr: Color:=White);
procedure Put
(Buf : Buffer_Ref;
P : Point;
Ch : Character;
Size: Positive;
Fgnd: Color:= White;
Bgnd: Color:= Black);
procedure Put
(Buf : Buffer_Ref;
P : Point;
Str : String;
Size: Positive;
Fgnd: Color:= White;
Bgnd: Color:= Black);
procedure Put
(Buf : Buffer_Ref;
P : Point;
Num : Natural;
Size: Positive;
Fgnd: Color:= White;
Bgnd: Color:= Black);
procedure Bitmap
(Buf : Buffer_Ref;
P : Point;
Bytes : Byte_Array_Access;
Siz : Size);
procedure Bitmap
(Buf : Buffer_Ref;
P : Point;
Icon : Bitmap_Icon);
end Bitmap_Buffer;
|
charlie5/cBound | Ada | 1,530 | ads | -- This file is generated by SWIG. Please do not modify by hand.
--
with Interfaces;
with Interfaces.C;
with Interfaces.C.Pointers;
package xcb.xcb_map_request_event_t is
-- Item
--
type Item is record
response_type : aliased Interfaces.Unsigned_8;
pad0 : aliased Interfaces.Unsigned_8;
sequence : aliased Interfaces.Unsigned_16;
parent : aliased xcb.xcb_window_t;
window : aliased xcb.xcb_window_t;
end record;
-- Item_Array
--
type Item_Array is
array
(Interfaces.C.size_t range <>) of aliased xcb.xcb_map_request_event_t
.Item;
-- Pointer
--
package C_Pointers is new Interfaces.C.Pointers
(Index => Interfaces.C.size_t,
Element => xcb.xcb_map_request_event_t.Item,
Element_Array => xcb.xcb_map_request_event_t.Item_Array,
Default_Terminator => (others => <>));
subtype Pointer is C_Pointers.Pointer;
-- Pointer_Array
--
type Pointer_Array is
array
(Interfaces.C.size_t range <>) of aliased xcb.xcb_map_request_event_t
.Pointer;
-- Pointer_Pointer
--
package C_Pointer_Pointers is new Interfaces.C.Pointers
(Index => Interfaces.C.size_t,
Element => xcb.xcb_map_request_event_t.Pointer,
Element_Array => xcb.xcb_map_request_event_t.Pointer_Array,
Default_Terminator => null);
subtype Pointer_Pointer is C_Pointer_Pointers.Pointer;
end xcb.xcb_map_request_event_t;
|
stcarrez/sql-benchmark | Ada | 25,833 | ads | -------------------------------------------------------------------------------------
--
-- EXCEL_OUT - A low level package for writing Microsoft Excel (*) files
--
-- Pure Ada 95 code, 100% portable: OS-, CPU- and compiler- independent.
--
-- Version / date / download info: see the version, reference, web strings
-- defined at the end of the public part of this package.
-- Legal licensing note:
-- Copyright (c) 2009 .. 2018 Gautier de Montmollin
-- 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.
-- NB: this is the MIT License, as found 12-Sep-2007 on the site
-- http://www.opensource.org/licenses/mit-license.php
-- Derived from ExcelOut by Frank Schoonjans in Modula-2 - thanks!
-- (*) All Trademarks mentioned are properties of their respective owners.
-------------------------------------------------------------------------------------
--
-- Follow these steps to create an Excel spreadsheet stream:
--
-- 1. Create
--
-- 2. Optional settings, before any data output:
-- | Write_default_column_width
-- | Write_column_width for specific columns
-- | Write_default_row_height
-- | Write_row_height for specific rows
-- | Define_font, then Define_format
--
-- 3. | Write(xl, row, column, data): row by row, column by column
-- | Put(xl, data) : same, but column is auto-incremented
-- | New_Line(xl),... : other "Text_IO"-like (full list below)
-- | Use_format, influences the format of data written next
--
-- 4. Close
--
-- 5. (Excel_Out_String only) function Contents returns the full .xls
--------------------------------------------------------------------------
with Ada.Calendar; use Ada.Calendar;
with Ada.Streams.Stream_IO;
with Ada.Strings.Unbounded; use Ada.Strings.Unbounded;
with Ada.Text_IO;
package Excel_Out is
-----------------------------------------------------------------
-- The abstract Excel output stream root type. --
-- From this package, you can use the following derived types: --
-- * Excel_Out_File : output in a file --
-- * Excel_Out_String : output in a string --
-- Of course you can define your own derived types. --
-----------------------------------------------------------------
type Excel_Out_Stream is abstract tagged private;
----------------------------------
-- (2) Before any cell content: --
----------------------------------
-- * Page layout for printing
procedure Header(xl : Excel_Out_Stream; page_header_string: String);
procedure Footer(xl : Excel_Out_Stream; page_footer_string: String);
--
procedure Left_Margin(xl : Excel_Out_Stream; inches: Long_Float);
procedure Right_Margin(xl : Excel_Out_Stream; inches: Long_Float);
procedure Top_Margin(xl : Excel_Out_Stream; inches: Long_Float);
procedure Bottom_Margin(xl : Excel_Out_Stream; inches: Long_Float);
procedure Margins(xl : Excel_Out_Stream; left, right, top, bottom: Long_Float);
--
procedure Print_Row_Column_Headers(xl : Excel_Out_Stream);
procedure Print_Gridlines(xl : Excel_Out_Stream);
--
type Orientation_choice is (landscape, portrait);
type Scale_or_fit_choice is (scale, fit);
procedure Page_Setup(
xl : Excel_Out_Stream;
scaling_percents : Positive:= 100;
fit_width_with_n_pages : Natural:= 1; -- 0: as many as possible
fit_height_with_n_pages: Natural:= 1; -- 0: as many as possible
orientation : Orientation_choice:= portrait;
scale_or_fit : Scale_or_fit_choice:= scale
);
-- * The column width unit is as it appears in Excel when you resize a column.
-- It is the width of a '0' in a standard font.
procedure Write_default_column_width(xl : in out Excel_Out_Stream; width : Positive);
procedure Write_column_width(xl : in out Excel_Out_Stream; column: Positive; width: Natural);
procedure Write_column_width(
xl : in out Excel_Out_Stream;
first_column,
last_column : Positive;
width : Natural
);
-- * The row height unit is in font points, as appearing when you
-- resize a row in Excel. A zero height means the row is hidden.
procedure Write_default_row_height(xl: Excel_Out_Stream; height: Positive);
procedure Write_row_height(xl : Excel_Out_Stream; row: Positive; height : Natural);
----------------------
-- Formatting cells --
----------------------
-- A cell format is, as you can see in the format dialog
-- in Excel, a combination of:
-- - a number format
-- - a set of alignements
-- - a font
-- - and other optional things to come here...
-- Formats are user-defined except one which is predefined: Default_format
type Format_type is private;
function Default_format(xl: Excel_Out_Stream) return Format_type;
-- What you get when creating a new sheet in Excel: Default_font,...
-- * Number format
type Number_format_type is private;
-- Built-in number formats
general : constant Number_format_type;
decimal_0 : constant Number_format_type;
decimal_2 : constant Number_format_type;
decimal_0_thousands_separator: constant Number_format_type; -- 1'234'000
decimal_2_thousands_separator: constant Number_format_type; -- 1'234'000.00
percent_0 : constant Number_format_type; -- 3%, 0%, -4%
percent_2 : constant Number_format_type;
percent_0_plus : constant Number_format_type; -- +3%, 0%, -4%
percent_2_plus : constant Number_format_type;
scientific : constant Number_format_type;
dd_mm_yyyy : constant Number_format_type;
dd_mm_yyyy_hh_mm : constant Number_format_type;
hh_mm : constant Number_format_type;
hh_mm_ss : constant Number_format_type;
procedure Define_number_format(
xl : in out Excel_Out_Stream;
format : out Number_format_type;
format_string: in String
);
-- * Fonts are user-defined, one is predefined: Default_font
type Font_type is private;
function Default_font(xl: Excel_Out_Stream) return Font_type;
-- Arial 10, regular, "automatic" color
type Color_type is
(automatic,
black, white, red, green, blue, yellow, magenta, cyan,
dark_red, dark_green, dark_blue, olive, purple, teal, silver, grey);
type Font_style is private;
-- For combining font styles (e.g.: bold & underlined):
function "&"(a,b: Font_style) return Font_style;
regular : constant Font_style;
italic : constant Font_style;
bold : constant Font_style;
bold_italic : constant Font_style;
underlined : constant Font_style;
struck_out : constant Font_style;
shadowed : constant Font_style;
condensed : constant Font_style;
extended : constant Font_style;
procedure Define_font(
xl : in out Excel_Out_Stream;
font_name : String;
height : Positive;
font : out Font_type;
-- optional:
style : Font_style:= regular;
color : Color_type:= automatic
);
type Horizontal_alignment is (
general_alignment, to_left, centred, to_right, filled,
justified, centred_across_selection, -- (BIFF4-BIFF8)
distributed -- (BIFF8, Excel 10.0 ("XP") and later only)
);
type Vertical_alignment is (
top_alignment, centred, bottom_alignment,
justified, -- (BIFF5-BIFF8)
distributed -- (BIFF8, Excel 10.0 ("XP") and later only)
);
type Text_orientation is (
normal,
stacked, -- vertical, top to bottom
rotated_90, -- vertical, rotated 90 degrees counterclockwise
rotated_270 -- vertical, rotated 90 degrees clockwise
);
type Cell_border is private;
-- Operator for combining borders (e.g.: left & top):
function "&"(a,b: Cell_border) return Cell_border;
no_border : constant Cell_border;
left : constant Cell_border;
right : constant Cell_border;
top : constant Cell_border;
bottom : constant Cell_border;
box : constant Cell_border;
procedure Define_format(
xl : in out Excel_Out_Stream;
font : in Font_type; -- Default_font(xl), or given by Define_font
number_format : in Number_format_type; -- built-in, or given by Define_number_format
cell_format : out Format_type;
-- Optional parameters --
horizontal_align : in Horizontal_alignment:= general_alignment;
border : in Cell_border:= no_border;
shaded : in Boolean:= False; -- Add a dotted background pattern
background_color : in Color_type:= automatic;
wrap_text : in Boolean:= False;
vertical_align : in Vertical_alignment:= bottom_alignment;
text_orient : in Text_orientation:= normal
);
------------------------
-- (3) Cell contents: --
------------------------
-- NB: you need to write with ascending row index and with ascending
-- column index within a row; otherwise Excel issues a protest
procedure Write(xl: in out Excel_Out_Stream; r,c : Positive; num : Long_Float);
procedure Write(xl: in out Excel_Out_Stream; r,c : Positive; num : Integer);
procedure Write(xl: in out Excel_Out_Stream; r,c : Positive; str : String);
procedure Write(xl: in out Excel_Out_Stream; r,c : Positive; str : Unbounded_String);
procedure Write(xl: in out Excel_Out_Stream; r,c : Positive; date: Time);
-- "Ada.Text_IO" - like output.
-- No need to specify row & column each time.
-- Write 'Put(x, content)' where x is an Excel_Out_Stream just
-- as if x was a File_Type, and vice-versa.
--
procedure Put(xl: in out Excel_Out_Stream; num : Long_Float);
procedure Put(xl : in out Excel_Out_Stream;
num : in Integer;
width : in Ada.Text_IO.Field := 0; -- ignored
base : in Ada.Text_IO.Number_Base := 10
);
procedure Put(xl: in out Excel_Out_Stream; str : String);
procedure Put(xl: in out Excel_Out_Stream; str : Unbounded_String);
procedure Put(xl: in out Excel_Out_Stream; date: Time);
--
procedure Put_Line(xl: in out Excel_Out_Stream; num : Long_Float);
procedure Put_Line(xl: in out Excel_Out_Stream; num : Integer);
procedure Put_Line(xl: in out Excel_Out_Stream; str : String);
procedure Put_Line(xl: in out Excel_Out_Stream; str : Unbounded_String);
procedure Put_Line(xl: in out Excel_Out_Stream; date: Time);
--
procedure New_Line(xl: in out Excel_Out_Stream; Spacing : Positive := 1);
-- Get current column and row. The next Put will put contents in that cell.
--
function Col(xl: in Excel_Out_Stream) return Positive; -- Text_IO naming
function Column(xl: in Excel_Out_Stream) return Positive; -- Excel naming
function Line(xl: in Excel_Out_Stream) return Positive; -- Text_IO naming
function Row(xl: in Excel_Out_Stream) return Positive; -- Excel naming
-- Relative / absolute jumps
procedure Jump(xl: in out Excel_Out_Stream; rows, columns: Natural);
procedure Jump_to(xl: in out Excel_Out_Stream; row, column: Positive);
procedure Next(xl: in out Excel_Out_Stream; columns: Natural:= 1); -- Jump 0 or more cells right
procedure Next_Row(xl: in out Excel_Out_Stream; rows: Natural:= 1); -- Jump 0 or more cells down
--
-- Merge a certain amount of cells with the last one,
-- right to that cell, on the same row.
procedure Merge(xl: in out Excel_Out_Stream; cells: Positive);
procedure Write_cell_comment(xl: Excel_Out_Stream; row, column: Positive; text: String);
procedure Write_cell_comment_at_cursor(xl: Excel_Out_Stream; text: String);
-- Cells written after Use_format will be using the given format,
-- defined by Define_format.
procedure Use_format(
xl : in out Excel_Out_Stream;
format : in Format_type
);
procedure Use_default_format(xl: in out Excel_Out_Stream);
-- The Freeze Pane methods can be called anytime before Close
procedure Freeze_Panes(xl: in out Excel_Out_Stream; row, column: Positive);
procedure Freeze_Panes_at_cursor(xl: in out Excel_Out_Stream);
procedure Freeze_Top_Row(xl: in out Excel_Out_Stream);
procedure Freeze_First_Column(xl: in out Excel_Out_Stream);
-- Zoom level. Example: for 85%, call with parameters 85, 100.
procedure Zoom_level(xl: in out Excel_Out_Stream; numerator, denominator: Positive);
-- Set_Index and Index are not directly useful for Excel_Out users.
-- They are private indeed, but they must be visible (RM 3.9.3(10)).
-- Set the index on the stream
procedure Set_Index (xl: in out Excel_Out_Stream;
to: Ada.Streams.Stream_IO.Positive_Count)
is abstract;
-- Return the index of the stream
function Index (xl: Excel_Out_Stream) return Ada.Streams.Stream_IO.Count
is abstract;
Excel_stream_not_created,
Excel_stream_not_closed,
Decreasing_row_index,
Decreasing_column_index,
Row_out_of_range,
Column_out_of_range : exception;
type Excel_type is (
BIFF2, -- Excel 2.1, 2,2
BIFF3, -- Excel 3.0
BIFF4 -- Excel 4.0
-- BIFF5, -- Excel 5.0 to 7.0
-- BIFF8 -- Excel 8.0 (97) to 11.0 (2003) - UTF-16 support
);
Default_Excel_type: constant Excel_type:= BIFF4;
-- Assumed encoding for types Character and String (8-bit):
type Encoding_type is (
Windows_CP_874, -- Thai
Windows_CP_932, -- Japanese Shift-JIS
Windows_CP_936, -- Chinese Simplified GBK
Windows_CP_949, -- Korean (Wansung)
Windows_CP_950, -- Chinese Traditional BIG5
Windows_CP_1250, -- Latin II (Central European)
Windows_CP_1251, -- Cyrillic
Windows_CP_1252, -- Latin I, superset of ISO 8859-1
Windows_CP_1253, -- Greek
Windows_CP_1254, -- Turkish
Windows_CP_1255, -- Hebrew
Windows_CP_1256, -- Arabic
Windows_CP_1257, -- Baltic
Windows_CP_1258, -- Vietnamese
Windows_CP_1361, -- Korean (Johab)
Apple_Roman
);
Default_encoding: constant Encoding_type:= Windows_CP_1252;
-----------------------------------------------------------------
-- Here, the derived stream types pre-defined in this package. --
-----------------------------------------------------------------
-- * Output to a file:
type Excel_Out_File is new Excel_Out_Stream with private;
procedure Create(
xl : in out Excel_Out_File;
file_name : String;
excel_format : Excel_type := Default_Excel_type;
encoding : Encoding_type := Default_encoding
);
procedure Close(xl : in out Excel_Out_File);
function Is_Open(xl : in Excel_Out_File) return Boolean;
-- * Output to a string (to be compressed, packaged, transmitted, ... ):
type Excel_Out_String is new Excel_Out_Stream with private;
procedure Create(
xl : in out Excel_Out_String;
excel_format : Excel_type := Default_Excel_type;
encoding : Encoding_type := Default_encoding
);
procedure Close(xl : in out Excel_Out_String);
function Contents(xl: Excel_Out_String) return String;
----------------------------------------------------------------
-- Information about this package - e.g. for an "about" box --
----------------------------------------------------------------
version : constant String:= "17";
reference : constant String:= "18-Oct-2018";
web : constant String:= "http://excel-writer.sf.net/";
-- hopefully the latest version is at that URL... -----^
private
----------------------------------------
-- Raw Streams, with 'Read and 'Write --
----------------------------------------
type XL_Raw_Stream_Class is access all Ada.Streams.Root_Stream_Type'Class;
type Font_type is new Natural;
type Number_format_type is new Natural;
type Format_type is new Natural;
subtype XF_Range is Integer range 0..62; -- after 62 we'd need to use an IXFE (5.62)
max_font : constant:= 62;
max_format: constant:= 62;
-- Theoretically, we would not need to memorize the XF informations
-- and just give the XF identifier given with Format_type, but some
-- versions of Excel with some locales mix up the font and numerical format
-- when giving 0 for the cell attributes (see Cell_attributes, 2.5.13)
-- Added Mar-2011.
type XF_Info is record
font: Font_type;
numb: Number_format_type;
end record;
type XF_Definition is array(XF_Range) of XF_Info;
-- Built-in number formats
general : constant Number_format_type:= 0;
decimal_0 : constant Number_format_type:= 1;
decimal_2 : constant Number_format_type:= 2;
decimal_0_thousands_separator: constant Number_format_type:= 3; -- 1'234'000
decimal_2_thousands_separator: constant Number_format_type:= 4; -- 1'234'000.00
no_currency_0 : constant Number_format_type:= 5;
no_currency_red_0 : constant Number_format_type:= 6;
no_currency_2 : constant Number_format_type:= 7;
no_currency_red_2 : constant Number_format_type:= 8;
currency_0 : constant Number_format_type:= 9; -- 5 in BIFF2, BIFF3 (sob!)
currency_red_0 : constant Number_format_type:= 10; -- 6 in BIFF2, BIFF3...
currency_2 : constant Number_format_type:= 11;
currency_red_2 : constant Number_format_type:= 12;
percent_0 : constant Number_format_type:= 13; -- 3%, 0%, -4%
percent_2 : constant Number_format_type:= 14;
scientific : constant Number_format_type:= 15;
fraction_1 : constant Number_format_type:= 16;
fraction_2 : constant Number_format_type:= 17;
dd_mm_yyyy : constant Number_format_type:= 18; -- 14 in BIFF3, 12 in BIFF2 (re-sob!)
dd_mmm_yy : constant Number_format_type:= 19; -- 15 in BIFF3, 13 in BIFF2...
dd_mmm : constant Number_format_type:= 20;
mmm_yy : constant Number_format_type:= 21;
h_mm_AM_PM : constant Number_format_type:= 22;
h_mm_ss_AM_PM : constant Number_format_type:= 23;
hh_mm : constant Number_format_type:= 24;
hh_mm_ss : constant Number_format_type:= 25;
dd_mm_yyyy_hh_mm : constant Number_format_type:= 26;
-- End of Excel built-in formats
last_built_in : constant Number_format_type:= dd_mm_yyyy_hh_mm;
percent_0_plus : constant Number_format_type:= 27; -- +3%, 0%, -4%
percent_2_plus : constant Number_format_type:= 28;
date_iso : constant Number_format_type:= 29; -- ISO 8601 format: 2014-03-16
date_h_m_iso : constant Number_format_type:= 30; -- date, hour, minutes
date_h_m_s_iso : constant Number_format_type:= 31; -- date, hour, minutes, seconds
-- End of our custom formats
last_custom : constant Number_format_type:= date_h_m_s_iso;
type Col_width_set is array(1..256) of Boolean;
-- We have a concrete type as hidden ancestor of the Excel_Out_Stream root
-- type. A variable of that type is initialized with default values and
-- can help re-initialize a Excel_Out_Stream when re-used several times.
-- See the Reset procedure in body.
-- The abstract Excel_Out_Stream could have default values, but using a
-- variable of this type to reset values is not Ada compliant (LRM:3.9.3(8))
--
type Excel_Out_Pre_Root_Type is tagged record
xl_stream : XL_Raw_Stream_Class;
format : Excel_type := Default_Excel_type;
encoding : Encoding_type := Default_encoding;
dimrecpos : Ada.Streams.Stream_IO.Positive_Count;
maxcolumn : Positive:= 1;
maxrow : Positive:= 1;
fonts : Integer:= -1; -- [-1..max_font]
xfs : Integer:= -1; -- [-1..XF_Range'Last]
xf_in_use : XF_Range:= 0;
xf_def : XF_Definition;
number_fmt : Number_format_type:= last_custom;
def_font : Font_type;
def_fmt : Format_type; -- Default format; used for "Normal" style
cma_fmt : Format_type; -- Format used for defining "Comma" style
ccy_fmt : Format_type; -- Format used for defining "Currency" style
pct_fmt : Format_type; -- Format used for defining "Percent" style
is_created : Boolean:= False;
is_closed : Boolean:= False;
curr_row : Positive:= 1;
curr_col : Positive:= 1;
frz_panes : Boolean:= False;
freeze_row : Positive;
freeze_col : Positive;
zoom_num : Positive:= 100;
zoom_den : Positive:= 100;
defcolwdth : Natural:= 0; -- 0 = not set; 1/256 of the width of the zero character
std_col_width: Col_width_set:= (others => True);
end record;
type Excel_Out_Stream is abstract new Excel_Out_Pre_Root_Type with null record;
type Font_style_single is
(bold_single,
italic_single,
underlined_single,
struck_out_single,
outlined_single,
shadowed_single,
condensed_single,
extended_single);
type Font_style is array(Font_style_single) of Boolean;
regular : constant Font_style:= (others => False);
italic : constant Font_style:= (italic_single => True, others => False);
bold : constant Font_style:= (bold_single => True, others => False);
bold_italic : constant Font_style:= bold or italic;
underlined : constant Font_style:= (underlined_single => True, others => False);
struck_out : constant Font_style:= (struck_out_single => True, others => False);
shadowed : constant Font_style:= (shadowed_single => True, others => False);
condensed : constant Font_style:= (condensed_single => True, others => False);
extended : constant Font_style:= (extended_single => True, others => False);
type Cell_border_single is
(left_single,
right_single,
top_single,
bottom_single);
type Cell_border is array(Cell_border_single) of Boolean;
no_border : constant Cell_border:= (others => False);
left : constant Cell_border:= (left_single => True, others => False);
right : constant Cell_border:= (right_single => True, others => False);
top : constant Cell_border:= (top_single => True, others => False);
bottom : constant Cell_border:= (bottom_single => True, others => False);
box : constant Cell_border:= (others => True);
----------------------
-- Output to a file --
----------------------
type XL_file_acc is
access Ada.Streams.Stream_IO.File_Type;
type Excel_Out_File is new Excel_Out_Stream with record
xl_file : XL_file_acc:= null; -- access to the "physical" Excel file
end record;
-- Set the index on the file
procedure Set_Index (xl: in out Excel_Out_File;
To: Ada.Streams.Stream_IO.Positive_Count);
-- Return the index of the file
function Index (xl: Excel_Out_File) return Ada.Streams.Stream_IO.Count;
------------------------
-- Output to a string --
------------------------
-- Code reused from Zip_Streams
--- *** We define here a complete in-memory stream:
type Unbounded_Stream is new Ada.Streams.Root_Stream_Type with
record
Unb : Ada.Strings.Unbounded.Unbounded_String;
Loc : Integer := 1;
end record;
-- Read data from the stream.
procedure Read
(Stream : in out Unbounded_Stream;
Item : out Ada.Streams.Stream_Element_Array;
Last : out Ada.Streams.Stream_Element_Offset);
-- write data to the stream, starting from the current index.
-- Data will be overwritten from index is already available.
procedure Write
(Stream : in out Unbounded_Stream;
Item : Ada.Streams.Stream_Element_Array);
-- Set the index on the stream
procedure Set_Index (S : access Unbounded_Stream; To : Positive);
-- returns the index of the stream
function Index (S: access Unbounded_Stream) return Integer;
--- ***
type Unbounded_Stream_Acc is access Unbounded_Stream;
type Excel_Out_String is new Excel_Out_Stream with record
xl_memory: Unbounded_Stream_Acc;
end record;
-- Set the index on the Excel string stream
procedure Set_Index (xl: in out Excel_Out_String;
To: Ada.Streams.Stream_IO.Positive_Count);
-- Return the index of the Excel string stream
function Index (xl: Excel_Out_String) return Ada.Streams.Stream_IO.Count;
end Excel_Out;
|
kontena/ruby-packer | Ada | 3,622 | ads | ------------------------------------------------------------------------------
-- --
-- GNAT ncurses Binding Samples --
-- --
-- Sample.My_Field_Type --
-- --
-- S P E C --
-- --
------------------------------------------------------------------------------
-- Copyright (c) 1998,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: Juergen Pfeifer, 1996
-- Version Control
-- $Revision: 1.12 $
-- 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;
|
reznikmm/slimp | Ada | 634 | ads | -- Copyright (c) 2019 Maxim Reznik <[email protected]>
--
-- SPDX-License-Identifier: MIT
-- License-Filename: LICENSE
-------------------------------------------------------------
with Slim.Message_Visiters;
with Slim.Messages.BUTN;
package Slim.Players.Common_Play_Visiters is
type Visiter (Player : not null access Players.Player) is
abstract new Slim.Message_Visiters.Visiter with null record;
overriding procedure BUTN
(Self : in out Visiter;
Message : not null access Slim.Messages.BUTN.BUTN_Message);
procedure Update_Display (Self : in out Player);
end Slim.Players.Common_Play_Visiters;
|
io7m/coreland-openal-ada | Ada | 241 | ads | -- Automatically generated, do not edit.
package OpenAL.Extension.Float32_Thin is
-- Constants
AL_FORMAT_MONO_FLOAT32 : constant := 16#10010#;
AL_FORMAT_STEREO_FLOAT32 : constant := 16#10011#;
end OpenAL.Extension.Float32_Thin;
|
charlie5/aIDE | Ada | 1,734 | adb | with
AdaM.Factory;
package body AdaM.library_Unit.a_body
is
-- Storage Pool
--
record_Version : constant := 1;
pool_Size : constant := 5_000;
package Pool is new AdaM.Factory.Pools (".adam-store",
"library_Units-body",
pool_Size,
record_Version,
library_Unit.a_body.item,
library_Unit.a_body.view);
-- Forge
--
procedure define (Self : in out Item)
is
begin
null;
end define;
overriding
procedure destruct (Self : in out Item)
is
begin
null;
end destruct;
function new_Subprogram return View
is
new_View : constant library_Unit.a_body.view := Pool.new_Item;
begin
define (library_Unit.a_body.item (new_View.all));
return new_View;
end new_Subprogram;
procedure free (Self : in out library_Unit.a_body.view)
is
begin
destruct (library_Unit.a_body.item (Self.all));
Pool.free (Self);
end free;
-- Attributes
--
overriding
function Id (Self : access Item) return AdaM.Id
is
begin
return Pool.to_Id (Self);
end Id;
-- Streams
--
procedure View_write (Stream : not null access Ada.Streams.Root_Stream_Type'Class;
Self : in View)
renames Pool.View_write;
procedure View_read (Stream : not null access Ada.Streams.Root_Stream_Type'Class;
Self : out View)
renames Pool.View_read;
end AdaM.library_Unit.a_body;
|
dkm/atomic | Ada | 109 | ads | with Interfaces;
with Atomic.Signed;
package Atomic.Signed_32 is new Atomic.Signed (Interfaces.Integer_32);
|
kjseefried/coreland-cgbc | Ada | 8,376 | adb | package body CGBC.Bounded_Hashed_Open_Maps is
procedure Find_Index
(Key_Table : in Map_Keys;
Key : in Key_Type;
Found : out Boolean;
Index : out Count_Type);
--
-- Clear
--
procedure Clear (Container : in out Map) is
begin
for Index in Container.Keys.Buckets'Range loop
Container.Keys.Buckets (Index).State := Empty;
end loop;
Container.Keys.Used := 0;
end Clear;
--
-- Contains
--
function Contains
(Container : in Map;
Key : in Key_Type) return Boolean
is
Found : Boolean;
Index : Count_Type;
begin
Found := False;
if Container.Keys.Used > 0 then
Find_Index
(Key_Table => Container.Keys,
Key => Key,
Found => Found,
Index => Index);
end if;
return Found;
end Contains;
--
-- Delete
--
procedure Delete
(Container : in out Map;
Key : in Key_Type;
Deleted : out Boolean)
is
Index : Count_Type;
Found : Boolean;
begin
Deleted := False;
if Container.Keys.Used > 0 then
Find_Index
(Key_Table => Container.Keys,
Key => Key,
Found => Found,
Index => Index);
if Found then
pragma Assert
((Index >= Container.Keys.Buckets'First) and
(Index <= Container.Keys.Buckets'Last));
declare
Current_Bucket : Bucket_Type renames Container.Keys.Buckets (Index);
begin
pragma Assert (Current_Bucket.State = Used);
Current_Bucket.State := Bounded_Hashed_Open_Maps.Deleted;
Container.Keys.Used := Container.Keys.Used - 1;
Deleted := True;
end;
end if;
end if;
end Delete;
--
-- Exclude
--
procedure Exclude
(Container : in out Map;
Key : in Key_Type)
is
Deleted : Boolean;
begin
-- Deleted is unused.
pragma Warnings (Off);
Delete
(Container => Container,
Key => Key,
Deleted => Deleted);
pragma Warnings (On);
end Exclude;
--
-- Find
--
function Find
(Container : in Map;
Key : in Key_Type) return Cursor
is
C : Cursor := No_Element;
Found : Boolean;
Index : Count_Type;
begin
if Container.Keys.Used > 0 then
Find_Index
(Key_Table => Container.Keys,
Key => Key,
Found => Found,
Index => Index);
if Found then
C := Cursor (Index);
end if;
end if;
return C;
end Find;
--
-- Find_Index
--
procedure Find_Index
(Key_Table : in Map_Keys;
Key : in Key_Type;
Found : out Boolean;
Index : out Count_Type)
is
Hash_Value : Hash_Type;
begin
Found := False;
Hash_Value := Hash (Key);
Index := Count_Type (Hash_Value mod Hash_Type (Key_Table.Buckets'Last)) + 1;
pragma Assert
((Index >= Key_Table.Buckets'First) and
(Index <= Key_Table.Buckets'Last));
for Attempt in Key_Table.Buckets'Range loop
declare
Current_Bucket : Bucket_Type renames Key_Table.Buckets (Index);
begin
case Current_Bucket.State is
when Empty =>
Found := False;
exit;
when Used =>
Found := Equivalent_Keys
(Left => Current_Bucket.Key,
Right => Key);
if Found then
exit;
end if;
when Deleted =>
if Current_Bucket.Key = Key then
exit;
end if;
end case;
end;
-- Simple linear probing.
if Index /= Key_Table.Buckets'Last then
Index := Index + 1;
else
Index := Key_Table.Buckets'First;
end if;
end loop;
end Find_Index;
--
-- First
--
function First (Container : in Map) return Cursor is
C : Cursor;
begin
C := No_Element;
if Container.Keys.Used > 0 then
for Index in Container.Keys.Buckets'Range loop
if Container.Keys.Buckets (Index).State = Used then
C := Index;
exit;
end if;
end loop;
end if;
return C;
end First;
--
-- Next
--
function Next
(Container : in Map;
Position : in Cursor) return Cursor
is
C : Cursor := No_Element;
begin
if Valid_Cursor (Container, Position) then
for Index in Count_Type (Position + 1) .. Container.Capacity loop
if Container.Keys.Buckets (Index).State = Used then
C := Index;
exit;
end if;
end loop;
end if;
return C;
end Next;
procedure Next
(Container : in Map;
Position : in out Cursor) is
begin
Position := Next (Container, Position);
end Next;
--
-- Include
--
procedure Include
(Container : in out Map;
Key : in Key_Type;
Element : in Element_Type;
Included : out Boolean) is
begin
if Contains (Container, Key) then
Replace_Element
(Container => Container,
Key => Key,
Element => Element,
Exists => Included);
pragma Assert (Included);
else
Insert
(Container => Container,
Key => Key,
Element => Element,
Inserted => Included);
end if;
end Include;
--
-- Insert.
--
procedure Insert
(Container : in out Map;
Key : in Key_Type;
Element : in Element_Type;
Inserted : out Boolean)
is
Index : Count_Type;
Found : Boolean;
begin
if Container.Keys.Used = Container.Capacity then
Inserted := False;
else
Find_Index
(Key_Table => Container.Keys,
Key => Key,
Found => Found,
Index => Index);
pragma Assert
((Index >= Container.Keys.Buckets'First) and
(Index <= Container.Keys.Buckets'Last));
if Found then
Inserted := False;
else
declare
Current_Bucket : Bucket_Type renames Container.Keys.Buckets (Index);
begin
pragma Assert (Current_Bucket.State /= Used);
Current_Bucket.Key := Key;
Current_Bucket.State := Used;
Container.Elements (Index) := Element;
Container.Keys.Used := Container.Keys.Used + 1;
Inserted := True;
end;
end if;
end if;
end Insert;
--
-- Is_Empty
--
function Is_Empty (Container : in Map) return Boolean is
begin
return Length (Container) = 0;
end Is_Empty;
--
-- Last
--
function Last (Container : in Map) return Cursor is
C : Cursor := No_Element;
begin
if Container.Keys.Used > 0 then
for Index in reverse Container.Keys.Buckets'Range loop
if Container.Keys.Buckets (Index).State = Used then
C := Index;
exit;
end if;
end loop;
end if;
return C;
end Last;
--
-- Length
--
function Length (Container : in Map) return Count_Type is
begin
return Container.Keys.Used;
end Length;
--
-- Replace_Element
--
procedure Replace_Element
(Container : in out Map;
Key : in Key_Type;
Element : in Element_Type;
Exists : out Boolean)
is
Index : Count_Type;
begin
Exists := False;
if Container.Keys.Used > 0 then
Find_Index
(Key_Table => Container.Keys,
Key => Key,
Found => Exists,
Index => Index);
pragma Assert
((Index >= Container.Keys.Buckets'First) and
(Index <= Container.Keys.Buckets'Last));
if Exists then
pragma Assert (Container.Keys.Buckets (Index).State = Used);
Container.Elements (Index) := Element;
end if;
end if;
end Replace_Element;
--
-- Valid_Cursor
--
function Valid_Cursor
(Container : in Map;
Position : in Cursor) return Boolean is
begin
if Position >= Container.Keys.Buckets'First and
Position <= Container.Capacity then
pragma Assert (Position /= No_Element);
return Container.Keys.Buckets (Position).State = Used;
else
return False;
end if;
end Valid_Cursor;
end CGBC.Bounded_Hashed_Open_Maps;
|
reznikmm/matreshka | Ada | 3,744 | ads | ------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- Open Document Toolkit --
-- --
-- Runtime Library Component --
-- --
------------------------------------------------------------------------------
-- --
-- Copyright © 2014, Vadim Godunko <[email protected]> --
-- All rights reserved. --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions --
-- are met: --
-- --
-- * Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- --
-- * Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in the --
-- documentation and/or other materials provided with the distribution. --
-- --
-- * Neither the name of the Vadim Godunko, IE nor the names of its --
-- contributors may be used to endorse or promote products derived from --
-- this software without specific prior written permission. --
-- --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR --
-- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
-- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED --
-- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR --
-- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF --
-- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING --
-- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS --
-- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
-- --
------------------------------------------------------------------------------
-- $Revision$ $Date$
------------------------------------------------------------------------------
with XML.DOM.Elements;
package ODF.DOM.Style_Table_Column_Properties_Elements is
pragma Preelaborate;
type ODF_Style_Table_Column_Properties is limited interface
and XML.DOM.Elements.DOM_Element;
type ODF_Style_Table_Column_Properties_Access is
access all ODF_Style_Table_Column_Properties'Class
with Storage_Size => 0;
end ODF.DOM.Style_Table_Column_Properties_Elements;
|
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.Svg_Mathematical_Attributes is
pragma Preelaborate;
type ODF_Svg_Mathematical_Attribute is limited interface
and XML.DOM.Attributes.DOM_Attribute;
type ODF_Svg_Mathematical_Attribute_Access is
access all ODF_Svg_Mathematical_Attribute'Class
with Storage_Size => 0;
end ODF.DOM.Svg_Mathematical_Attributes;
|
reznikmm/matreshka | Ada | 6,922 | 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_Config.Config_Item_Elements is
------------
-- Create --
------------
overriding function Create
(Parameters : not null access Matreshka.DOM_Elements.Element_L2_Parameters)
return Config_Config_Item_Element_Node is
begin
return Self : Config_Config_Item_Element_Node do
Matreshka.ODF_Config.Constructors.Initialize
(Self'Unchecked_Access,
Parameters.Document,
Matreshka.ODF_String_Constants.Config_Prefix);
end return;
end Create;
----------------
-- Enter_Node --
----------------
overriding procedure Enter_Node
(Self : not null access Config_Config_Item_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_Config_Config_Item
(ODF.DOM.Config_Config_Item_Elements.ODF_Config_Config_Item_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 Config_Config_Item_Element_Node)
return League.Strings.Universal_String
is
pragma Unreferenced (Self);
begin
return Matreshka.ODF_String_Constants.Config_Item_Element;
end Get_Local_Name;
----------------
-- Leave_Node --
----------------
overriding procedure Leave_Node
(Self : not null access Config_Config_Item_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_Config_Config_Item
(ODF.DOM.Config_Config_Item_Elements.ODF_Config_Config_Item_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 Config_Config_Item_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_Config_Config_Item
(Visitor,
ODF.DOM.Config_Config_Item_Elements.ODF_Config_Config_Item_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.Config_URI,
Matreshka.ODF_String_Constants.Config_Item_Element,
Config_Config_Item_Element_Node'Tag);
end Matreshka.ODF_Config.Config_Item_Elements;
|
godunko/adagl | Ada | 3,564 | ads | ------------------------------------------------------------------------------
-- --
-- Ada binding for OpenGL/WebGL --
-- --
-- Runtime Library Component --
-- --
------------------------------------------------------------------------------
-- --
-- Copyright © 2016-2018, 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. --
-- --
------------------------------------------------------------------------------
with WebAPI.WebGL.Rendering_Contexts;
package OpenGL.Contexts.Internals is
pragma Preelaborate;
function WebGL_Context
(Self : OpenGL_Context'Class)
return WebAPI.WebGL.Rendering_Contexts.WebGL_Rendering_Context_Access;
-- Returns associated WebGL_Rendering_Context.
function Current_WebGL_Context
return WebAPI.WebGL.Rendering_Contexts.WebGL_Rendering_Context_Access;
-- Returns current WebGL_Rendering_Context.
end OpenGL.Contexts.Internals;
|
zhmu/ananas | Ada | 984 | ads | with Discr59_Pkg2;
package Discr59_Pkg1 is
subtype Index_Type is Natural range 1 .. 300;
type Code_Type is (Global_Query, Status_Query, Alert);
type Id_Type is (None, At_Command, At_Response);
package My_G is new Discr59_Pkg2 (21);
type Arr is array (Index_Type range <>) of My_G.Token_Type;
type Unit_List_Type (Last : Natural) is record
A : Arr (1 .. Last);
end record;
type At_Response_Type (Kind : Code_Type; Units : Natural) is record
case Kind is
when Global_Query => Global_Query : Unit_List_Type (Units);
when Status_Query => null;
when Alert => Alert : Unit_List_Type (Units);
end case;
end record;
type Rec (Kind : Id_Type; Code : Code_Type; Units : Natural) is record
case Kind is
when None => null;
when At_Command => null;
when At_Response => At_Response : At_Response_Type (Code, Units);
end case;
end record;
end Discr59_Pkg1;
|
AdaCore/gpr | Ada | 13,921 | adb | --
-- Copyright (C) 2019-2023, AdaCore
--
-- SPDX-License-Identifier: Apache-2.0 WITH LLVM-Exception
--
with Ada.Text_IO;
with GNAT.OS_Lib;
with GNAT.String_Split;
with GPR2.KB;
with GPR2.Message;
with GPR2.Project.Attribute;
with GPR2.Project.Attribute_Index;
with GPR2.Project.Definition;
with GPR2.Project.Registry.Attribute;
with GPR2.Source_Reference.Value;
with GPR2.View_Ids;
package body GPR2.Project.Configuration is
package PRA renames Project.Registry.Attribute;
--------------------
-- Archive_Suffix --
--------------------
function Archive_Suffix (Self : Object) return Filename_Type is
begin
return Filename_Type
(-Self.Conf.Attribute (PRA.Archive_Suffix).Value.Unchecked_Text);
end Archive_Suffix;
------------------
-- Bind_To_Tree --
------------------
procedure Bind_To_Tree
(Self : in out Object;
Tree : not null access Project.Tree.Object)
is
Data : Definition.Data;
begin
Data.Trees.Project := Self.Project;
Data.Kind := K_Configuration;
Data.Tree := Tree;
Data.Path := Path_Name.Create_Directory
(Filename_Type
(Self.Project.Path_Name.Dir_Name));
Data.Unique_Id := GPR2.View_Ids.Config_View_Id;
Self.Conf := Definition.Register (Data);
end Bind_To_Tree;
------------------------
-- Corresponding_View --
------------------------
function Corresponding_View (Self : Object) return Project.View.Object is
begin
return Self.Conf;
end Corresponding_View;
------------
-- Create --
------------
function Create
(Language : Language_Id;
Version : Optional_Name_Type := No_Name;
Runtime : Optional_Name_Type := No_Name;
Path : Filename_Optional := No_Filename;
Name : Optional_Name_Type := No_Name) return Description
is
function "+" (Str : Optional_Name_Type) return Unbounded_String
is (To_Unbounded_String (String (Str)));
begin
return Description'
(Language => Language,
Version => +Version,
Runtime => +Runtime,
Path => +String (Path),
Name => +Name);
end Create;
function Create
(Settings : Description_Set;
Target : Name_Type;
Project : GPR2.Path_Name.Object;
Base : in out GPR2.KB.Object;
Save_Name : GPR2.Path_Name.Object := GPR2.Path_Name.Undefined;
Environment : GPR2.Environment.Object :=
GPR2.Environment.Process_Environment)
return Object
is
Settings_Local : Description_Set := Settings;
Native_Target : constant Boolean := Target = "all";
Result : Object;
Configuration_String : Unbounded_String;
Parsing_Messages : Log.Object;
Project_Path : constant Path_Name.Object :=
(if Project.Has_Dir_Name then Project
else Create (Project.Name));
-- Project may be not even found at this stage, but since we ignore
-- all errors at first parsing we don't know it yet. We need to resolve
-- the Project path name for proper error reporting.
function Check_Runtime_Dir (Dir : Path_Name.Object) return Boolean;
-- Checks if Dir can be a runtime directory
function Locate_Runtime
(Dir : Filename_Optional; Path : String) return Path_Name.Object;
-- Returns runtime DIR directory resolved against Path or Undefined
-- if nothing is found.
-----------------------
-- Check_Runtime_Dir --
-----------------------
function Check_Runtime_Dir (Dir : Path_Name.Object) return Boolean is
Adalib_Dir : constant Path_Name.Object :=
Path_Name.Create_Directory
("adalib", Filename_Type (Dir.Value));
Adainclude_Dir : constant Path_Name.Object :=
Path_Name.Create_Directory
("adainclude", Filename_Type (Dir.Value));
AOP_File : constant Path_Name.Object :=
Path_Name.Create_File
("ada_object_path", Filename_Type (Dir.Value));
ASP_File : constant Path_Name.Object :=
Path_Name.Create_File
("ada_source_path", Filename_Type (Dir.Value));
begin
return (Adalib_Dir.Exists or else AOP_File.Exists)
and then (Adainclude_Dir.Exists or else ASP_File.Exists);
end Check_Runtime_Dir;
--------------------
-- Locate_Runtime --
--------------------
function Locate_Runtime
(Dir : Filename_Optional; Path : String) return Path_Name.Object is
use GNAT;
Paths : GNAT.String_Split.Slice_Set;
Runtime_Dir : Path_Name.Object;
begin
String_Split.Create (Paths, Path, (1 => OS_Lib.Path_Separator));
for J in 1 .. String_Split.Slice_Count (Paths) loop
Runtime_Dir := Path_Name.Create_Directory
(Dir,
Filename_Optional (String_Split.Slice (Paths, J)));
if Runtime_Dir.Exists then
return Runtime_Dir;
end if;
end loop;
return Path_Name.Undefined;
end Locate_Runtime;
begin
-- Ada runtime has a special 3 step lookup:
-- 1) check <runtime> subdir relatively to root project location
-- 2) check <runtime> subdir relatively to GPR_RUNTIME_PATH value
-- 3) pass it as is to configuration creation.
--
-- If step 1 or 2 results in a valid runtime dir, pass full path
-- to it to configuration creation.
-- If on step 2 corresponding directory is found, but it does not
-- have runtime features, configuration is abandoned.
for Descr in Settings_Local'Range loop
if Settings_Local (Descr).Language = Ada_Language
and then Runtime (Settings_Local (Descr)) /= No_Name
and then not GNAT.OS_Lib.Is_Absolute_Path
(To_String (Settings_Local (Descr).Runtime))
then
declare
Runtime_Dir : Path_Name.Object :=
Path_Name.Create_Directory
(Filename_Optional (Runtime (Settings_Local (Descr))),
Filename_Optional (Project_Path.Dir_Name));
begin
if Runtime_Dir.Exists and then Check_Runtime_Dir (Runtime_Dir)
then
Settings_Local (Descr).Runtime :=
To_Unbounded_String (Runtime_Dir.Value);
exit;
end if;
if Environment.Exists ("GPR_RUNTIME_PATH") then
Runtime_Dir := Locate_Runtime
(Filename_Optional (Runtime (Settings_Local (Descr))),
Environment.Value ("GPR_RUNTIME_PATH"));
if Runtime_Dir.Is_Defined and then Runtime_Dir.Exists then
if Check_Runtime_Dir (Runtime_Dir) then
Settings_Local (Descr).Runtime :=
To_Unbounded_String (Runtime_Dir.Value);
exit;
else
Result.Messages.Append
(Message.Create
(Message.Error,
"invalid runtime directory " & Runtime_Dir.Value,
Sloc => Source_Reference.Create
(Project_Path.Value, 0, 0)));
return Result;
end if;
end if;
end if;
end;
exit;
end if;
end loop;
if Native_Target then
-- Normalize implicit target
declare
Normalized : constant Name_Type :=
Base.Normalized_Target (GPR2.KB.Default_Target);
begin
if Normalized = "unknown" then
Configuration_String :=
Base.Configuration
(Settings => Settings_Local,
Target => GPR2.KB.Default_Target,
Messages => Result.Messages,
Fallback => True,
Environment => Environment);
else
Configuration_String :=
Base.Configuration
(Settings => Settings_Local,
Target => Normalized,
Messages => Result.Messages,
Fallback => True,
Environment => Environment);
end if;
end;
else
Configuration_String :=
Base.Configuration
(Settings => Settings_Local,
Target => Target,
Messages => Result.Messages,
Fallback => False,
Environment => Environment);
end if;
if Configuration_String /= Null_Unbounded_String then
if Save_Name.Is_Defined then
declare
Output : Text_IO.File_Type;
begin
Ada.Text_IO.Create (Output, Ada.Text_IO.Out_File,
String (Save_Name.Value));
Ada.Text_IO.Put_Line
(Output, To_String (Configuration_String));
Ada.Text_IO.Close (Output);
end;
end if;
if Path_Name.Temporary_Directory.Is_Defined then
Result.Project :=
GPR2.Project.Parser.Parse
(Contents => Configuration_String,
Messages => Parsing_Messages,
Pseudo_Filename => Path_Name.Create_File
("autoconf.cgpr",
Filename_Type (Path_Name.Temporary_Directory.Value)));
else
Result.Project :=
GPR2.Project.Parser.Parse
(Contents => Configuration_String,
Messages => Parsing_Messages,
Pseudo_Filename => Path_Name.Create_File
("autoconf.cgpr",
Filename_Type (Project_Path.Dir_Name)));
end if;
for M of Parsing_Messages loop
Result.Messages.Append (M);
end loop;
for S of Settings loop
Result.Descriptions.Append (S);
end loop;
else
for Msg of Base.Log_Messages loop
Result.Messages.Append (Msg);
end loop;
Result.Messages.Append
(Message.Create
(Message.Error,
"cannot create configuration file",
Sloc => Source_Reference.Create (Project_Path.Value, 0, 0)));
end if;
Result.Cache.Set (Config_Cache_Object'(others => <>));
return Result;
end Create;
----------------------------
-- Dependency_File_Suffix --
----------------------------
function Dependency_File_Suffix
(Self : Object;
Language : Language_Id) return Filename_Type
is
pragma Unreferenced (Self);
begin
-- ??? there is no attribute in the configuration file for this, so we
-- end up having hard coded value for Ada and all other languages.
if Language = Ada_Language then
return ".ali";
else
return ".d";
end if;
end Dependency_File_Suffix;
---------------
-- Externals --
---------------
function Externals (Self : Object) return Containers.Name_List is
begin
return Self.Project.Externals;
end Externals;
-------------------
-- Has_Externals --
-------------------
function Has_Externals (Self : Object) return Boolean is
begin
return Self.Project.Is_Defined and then Self.Project.Has_Externals;
end Has_Externals;
------------------
-- Has_Messages --
------------------
function Has_Messages (Self : Object) return Boolean is
begin
return not Self.Messages.Is_Empty;
end Has_Messages;
----------
-- Load --
----------
function Load
(Filename : Path_Name.Object) return Object
is
Result : Object;
begin
Result.Project :=
Project.Parser.Parse
(Filename, GPR2.Path_Name.Set.Empty_Set, Result.Messages);
-- Continue only if there is no parsing error on the configuration
-- project.
Result.Cache.Set (Config_Cache_Object'(others => <>));
return Result;
end Load;
------------------
-- Log_Messages --
------------------
function Log_Messages (Self : Object) return Log.Object is
begin
return Self.Messages;
end Log_Messages;
------------------------
-- Object_File_Suffix --
------------------------
function Object_File_Suffix
(Self : Object;
Language : Language_Id) return Filename_Type
is
Attr : constant Project.Attribute.Object :=
Self.Conf.Attribute
(Name => PRA.Compiler.Object_File_Suffix,
Index => Attribute_Index.Create (Language));
begin
if Attr.Is_Defined then
return Filename_Type (Attr.Value.Text);
else
return ".o";
end if;
end Object_File_Suffix;
-------------
-- Runtime --
-------------
function Runtime
(Self : Object; Language : Language_Id) return Optional_Name_Type is
begin
for Description of Self.Descriptions loop
if Description.Language = Language then
return Optional_Name_Type (To_String (Description.Runtime));
end if;
end loop;
return "";
end Runtime;
begin
Definition.Bind_Configuration_To_Tree := Bind_To_Tree'Access;
end GPR2.Project.Configuration;
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.