repo_name
stringlengths 9
74
| language
stringclasses 1
value | length_bytes
int64 11
9.34M
| extension
stringclasses 2
values | content
stringlengths 11
9.34M
|
---|---|---|---|---|
dannyboywoop/AdventOfCode2019 | Ada | 659 | ads | with Array_Stuff;
use Array_Stuff;
package Intcode is
function Run_Program(program_data: in out Int_Arr) return Integer;
function Initialise_Program(program_data: Int_Arr;
noun, verb: Integer) return Int_Arr;
function Find_Start_Vals(program_data: Int_Arr;
desired_result: Integer) return Integer;
private
function Run_Operation(program_data: in out Int_Arr;
index: in out Natural) return Boolean;
type Opcode is (add, multiply, halt);
for Opcode use
(add => 1,
multiply => 2,
halt => 99
);
end Intcode;
|
stcarrez/ada-awa | Ada | 5,223 | ads | -----------------------------------------------------------------------
-- awa-services -- Services
-- Copyright (C) 2011, 2012, 2013, 2014 Stephane Carrez
-- Written by Stephane Carrez ([email protected])
--
-- Licensed under the Apache License, Version 2.0 (the "License");
-- you may not use this file except in compliance with the License.
-- You may obtain a copy of the License at
--
-- http://www.apache.org/licenses/LICENSE-2.0
--
-- Unless required by applicable law or agreed to in writing, software
-- distributed under the License is distributed on an "AS IS" BASIS,
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-- See the License for the specific language governing permissions and
-- limitations under the License.
-----------------------------------------------------------------------
with AWA.Applications;
with AWA.Users.Principals;
with AWA.Users.Models;
with ADO;
with ADO.Sessions;
with Util.Beans.Objects;
with Ada.Finalization;
-- The service context provides additional information to a service operation.
-- This context is composed of:
-- <ul>
-- <li>the optional user context which allows to identify the current user invoking the service,
-- <li>the database connections that the service can use,
-- <li>the other services provided by the application.
-- </ul>
package AWA.Services.Contexts is
type Service_Context is new Ada.Finalization.Limited_Controlled with private;
type Service_Context_Access is access all Service_Context'Class;
-- Get the application associated with the current service operation.
function Get_Application (Ctx : in Service_Context) return AWA.Applications.Application_Access;
-- Get the current database connection for reading.
function Get_Session (Ctx : in Service_Context_Access) return ADO.Sessions.Session;
-- Get the current database connection for reading and writing.
function Get_Master_Session (Ctx : in Service_Context_Access)
return ADO.Sessions.Master_Session;
-- Get the current user invoking the service operation.
-- Returns a null user if there is none.
function Get_User (Ctx : in Service_Context) return AWA.Users.Models.User_Ref;
-- Get the current user identifier invoking the service operation.
-- Returns NO_IDENTIFIER if there is none.
function Get_User_Identifier (Ctx : in Service_Context) return ADO.Identifier;
-- Get the current user session from the user invoking the service operation.
-- Returns a null session if there is none.
function Get_User_Session (Ctx : in Service_Context) return AWA.Users.Models.Session_Ref;
-- Starts a transaction.
procedure Start (Ctx : in out Service_Context);
-- Commits the current transaction. The database transaction is really committed by the
-- last <b>Commit</b> called.
procedure Commit (Ctx : in out Service_Context);
-- Rollback the current transaction. The database transaction is rollback at the first
-- call to <b>Rollback</b>.
procedure Rollback (Ctx : in out Service_Context);
-- Get the attribute registered under the given name in the HTTP session.
function Get_Session_Attribute (Ctx : in Service_Context;
Name : in String) return Util.Beans.Objects.Object;
-- Set the attribute registered under the given name in the HTTP session.
procedure Set_Session_Attribute (Ctx : in out Service_Context;
Name : in String;
Value : in Util.Beans.Objects.Object);
-- Initializes the service context.
overriding
procedure Initialize (Ctx : in out Service_Context);
-- Finalize the service context, rollback non-committed transaction, releases any object.
overriding
procedure Finalize (Ctx : in out Service_Context);
-- Set the current application and user context.
procedure Set_Context (Ctx : in out Service_Context;
Application : in AWA.Applications.Application_Access;
Principal : in AWA.Users.Principals.Principal_Access);
-- Get the current service context.
-- Returns null if the current thread is not associated with any service context.
function Current return Service_Context_Access;
-- Run the process procedure on behalf of the specific user and session.
-- This operation changes temporarily the identity of the current user principal and
-- executes the <tt>Process</tt> procedure.
generic
with procedure Process;
procedure Run_As (User : in AWA.Users.Models.User_Ref;
Session : in AWA.Users.Models.Session_Ref);
private
type Service_Context is new Ada.Finalization.Limited_Controlled with record
Previous : Service_Context_Access := null;
Application : AWA.Applications.Application_Access := null;
Principal : AWA.Users.Principals.Principal_Access := null;
Master : ADO.Sessions.Master_Session;
Slave : ADO.Sessions.Session;
Transaction : Integer := 0;
Active_Transaction : Boolean := False;
end record;
end AWA.Services.Contexts;
|
BrickBot/Bound-T-H8-300 | Ada | 4,508 | ads | -- Programs.Patching (decl)
--
-- Patching (modifying) the memory image of a target program, after it
-- has been loaded and before it is analysed.
--
-- When Bound-T analyses a target program, it starts from the statically
-- generated (linker-generated) memory image. In some programs, important
-- parts of the memory image are defined or altered by the start-up code
-- in ways that Bound-T does not track, giving a wrong analysis.
-- The most common example is setting up the trap/interrupt vectors.
-- Such dynamic initializations can be imitated by the patching services
-- in this package, although this tends to be cumbersome and sensitive
-- to changes in the memory layout of the target program.
--
-- The patches are given in "patch files" which are text files with a
-- generic surface syntax but where the detailed syntax and meaning depend
-- on the target processor. The present package provides operations to
-- name patch files and to read them and parse the surface syntax, but
-- the detailed interpretation and actual patching are delegated to the
-- target-specific operation Decoder.Patch_Code. At the moment, there is
-- no similar operation for patching constant data, but there may be
-- target-specific ways to make Patch_Code change data areas instead of
-- code areas.
--
-- 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 19:36:52 $
--
-- $Log: programs-patching.ads,v $
-- Revision 1.4 2015/10/24 19:36:52 niklas
-- Moved to free licence.
--
-- Revision 1.3 2011-09-01 19:58:47 niklas
-- BT-CH-0222: Option registry.
--
-- Revision 1.2 2008-11-09 21:41:24 niklas
-- BT-CH-0158: Option "-trace patch".
--
-- Revision 1.1 2006/02/27 20:04:50 niklas
-- First version.
--
with Options.Bool;
with Options.File_Sets;
package Programs.Patching is
Trace_Patching_Opt : aliased Options.Bool.Option_T (Default => False);
--
-- Whether to trace the patching actions.
--
Trace_Patching : Boolean renames Trace_Patching_Opt.Value;
Patch_Files : aliased Options.File_Sets.Option_T;
--
-- The (names of) the patch files, if given.
-- Empty set by default.
procedure Apply_Patches (
Program : in Program_T;
Valid : out Boolean);
--
-- Applies the set of patch files that has been defined
-- by the preceding (zero or more) calls of Add_Patch_File,
-- in the same order. That is, the patches from the file
-- named in the first Add_Patch_File are applied first.
-- Later patches may override earlier patches.
--
-- Program
-- The program to be patched. It has been initialized
-- by Decoder.Initialize.
-- Valid
-- Returned as True on success, False on failure.
end Programs.Patching;
|
charlie5/lace | Ada | 21,128 | adb | -- A GIF stream is made of several "blocks".
-- The image itself is contained in an Image Descriptor block.
--
with GID.Buffering, GID.Color_tables;
with Ada.Exceptions, Ada.Text_IO;
package body GID.Decoding_GIF is
generic
type Number is mod <>;
procedure Read_Intel_x86_number(
from : in out Input_buffer;
n : out Number
);
pragma Inline(Read_Intel_x86_number);
procedure Read_Intel_x86_number(
from : in out Input_buffer;
n : out Number
)
is
b: U8;
m: Number:= 1;
begin
n:= 0;
for i in 1..Number'Size/8 loop
GID.Buffering.Get_Byte(from, b);
n:= n + m * Number(b);
m:= m * 256;
end loop;
end Read_Intel_x86_number;
procedure Read_Intel is new Read_Intel_x86_number( U16 );
----------
-- Load --
----------
procedure Load (
image : in out Image_descriptor;
next_frame: out Ada.Calendar.Day_Duration
)
is
local: Image_descriptor;
-- With GIF, each frame is a local image with an eventual
-- palette, different dimensions, etc. ...
use GID.Buffering, Ada.Exceptions;
type GIFDescriptor is record
ImageLeft,
ImageTop,
ImageWidth,
ImageHeight : U16;
Depth : U8;
end record;
-- For loading from the GIF file
Descriptor : GIFDescriptor;
-- Coordinates
X, tlX, brX : Natural;
Y, tlY, brY : Natural;
-- Code information
subtype Code_size_range is Natural range 2..12;
CurrSize : Code_size_range;
subtype Color_type is U8;
Transp_color : Color_type:= 0;
-- GIF data is stored in blocks and sub-blocks.
-- We initialize block_read and block_size to force
-- reading and buffering the next sub-block
block_size : Natural:= 0;
block_read : Natural:= 0;
function Read_Byte return U8 is
pragma Inline(Read_Byte);
b: U8;
use Ada.Streams;
begin
if block_read >= block_size then
Get_Byte(image.buffer, b);
block_size:= Natural(b);
block_read:= 0;
end if;
Get_Byte(image.buffer, b);
block_read:= block_read + 1;
return b;
end Read_Byte;
-- Used while reading the codes
bits_in : U8:= 8;
bits_buf: U8;
-- Local procedure to read the next code from the file
function Read_Code return Natural is
bit_mask: Natural:= 1;
code: Natural:= 0;
begin
-- Read the code, bit by bit
for Counter in reverse 0..CurrSize - 1 loop
-- Next bit
bits_in:= bits_in + 1;
-- Maybe, a new byte needs to be loaded with a further 8 bits
if bits_in = 9 then
bits_buf:= Read_Byte;
bits_in := 1;
end if;
-- Add the current bit to the code
if (bits_buf and 1) > 0 then
code:= code + bit_mask;
end if;
bit_mask := bit_mask * 2;
bits_buf := bits_buf / 2;
end loop;
return code;
end Read_Code;
generic
-- Parameter(s) that are constant through
-- the whole image. Macro-expanded generics and
-- some optimization will trim corresponding "if's"
interlaced : Boolean;
transparency : Boolean;
pixel_mask : U32;
--
procedure GIF_Decode;
procedure GIF_Decode is
procedure Pixel_with_palette(b: U8) is
pragma Inline(Pixel_with_palette);
begin
if transparency and then b = Transp_color then
Put_Pixel(0,0,0, 0);
return;
end if;
case Primary_color_range'Modulus is
when 256 =>
Put_Pixel(
Primary_color_range(local.palette(Integer(b)).red),
Primary_color_range(local.palette(Integer(b)).green),
Primary_color_range(local.palette(Integer(b)).blue),
255
);
when 65_536 =>
Put_Pixel(
16#101# * Primary_color_range(local.palette(Integer(b)).red),
16#101# * Primary_color_range(local.palette(Integer(b)).green),
16#101# * Primary_color_range(local.palette(Integer(b)).blue),
-- 16#101# because max intensity FF goes to FFFF
65_535
);
when others =>
raise invalid_primary_color_range;
end case;
end Pixel_with_palette;
-- Interlacing
Interlace_pass : Natural range 1..4:= 1;
Span : Natural:= 7;
-- Local procedure to draw a pixel
procedure Next_Pixel(code: Natural) is
pragma Inline(Next_Pixel);
c : constant Color_Type:= Color_type(U32(code) and pixel_mask);
begin
-- Actually draw the pixel on screen buffer
if X < image.width then
if interlaced and mode = nice then
for i in reverse 0..Span loop
if Y+i < image.height then
Set_X_Y(X, image.height - (Y+i) - 1);
Pixel_with_palette(c);
end if;
end loop;
elsif Y < image.height then
Pixel_with_palette(c);
end if;
end if;
-- Move on to next pixel
X:= X + 1;
-- Or next row, if necessary
if X = brX then
X:= tlX;
if interlaced then
case Interlace_pass is
when 1 =>
Y:= Y + 8;
if Y >= brY then
Y:= 4;
Interlace_pass:= 2;
Span:= 3;
Feedback((Interlace_pass*100)/4);
end if;
when 2 =>
Y:= Y + 8;
if Y >= brY then
Y:= 2;
Interlace_pass:= 3;
Span:= 1;
Feedback((Interlace_pass*100)/4);
end if;
when 3 =>
Y:= Y + 4;
if Y >= brY then
Y:= 1;
Interlace_pass:= 4;
Span:= 0;
Feedback((Interlace_pass*100)/4);
end if;
when 4 =>
Y:= Y + 2;
end case;
if mode = fast and then Y < image.height then
Set_X_Y(X, image.height - Y - 1);
end if;
else -- not interlaced
Y:= Y + 1;
if Y < image.height then
Set_X_Y(X, image.height - Y - 1);
end if;
if Y mod 32 = 0 then
Feedback((Y*100)/image.height);
end if;
end if;
end if;
end Next_Pixel;
-- The string table
Prefix : array ( 0..4096 ) of Natural:= (others => 0);
Suffix : array ( 0..4096 ) of Natural:= (others => 0);
Stack : array ( 0..1024 ) of Natural;
-- Special codes (specific to GIF's flavour of LZW)
ClearCode : constant Natural:= 2 ** CurrSize; -- Reset code
EndingCode: constant Natural:= ClearCode + 1; -- End of file
FirstFree : constant Natural:= ClearCode + 2; -- Strings start here
Slot : Natural:= FirstFree; -- Last read code
InitCodeSize : constant Code_size_range:= CurrSize + 1;
TopSlot : Natural:= 2 ** InitCodeSize; -- Highest code for current size
Code : Natural;
StackPtr : Integer:= 0;
Fc : Integer:= 0;
Oc : Integer:= 0;
C : Integer;
BadCodeCount : Natural:= 0; -- the number of bad codes found
begin -- GIF_Decode
-- The decoder source and the cool comments are kindly donated by
-- André van Splunter.
--
CurrSize:= InitCodeSize;
-- This is the main loop. For each code we get we pass through the
-- linked list of prefix codes, pushing the corresponding "character"
-- for each code onto the stack. When the list reaches a single
-- "character" we push that on the stack too, and then start unstacking
-- each character for output in the correct order. Special handling is
-- included for the clear code, and the whole thing ends when we get
-- an ending code.
C := Read_Code;
while C /= EndingCode loop
-- If the code is a clear code, reinitialize all necessary items.
if C = ClearCode then
CurrSize := InitCodeSize;
Slot := FirstFree;
TopSlot := 2 ** CurrSize;
-- Continue reading codes until we get a non-clear code
-- (Another unlikely, but possible case...)
C := Read_Code;
while C = ClearCode loop
C := Read_Code;
end loop;
-- If we get an ending code immediately after a clear code
-- (Yet another unlikely case), then break out of the loop.
exit when C = EndingCode;
-- Finally, if the code is beyond the range of already set codes,
-- (This one had better NOT happen... I have no idea what will
-- result from this, but I doubt it will look good...) then set
-- it to color zero.
if C >= Slot then
C := 0;
end if;
Oc := C;
Fc := C;
-- And let us not forget to output the char...
Next_Pixel(C);
else -- C /= ClearCode
-- In this case, it's not a clear code or an ending code, so
-- it must be a code code... So we can now decode the code into
-- a stack of character codes. (Clear as mud, right?)
Code := C;
-- Here we go again with one of those off chances... If, on the
-- off chance, the code we got is beyond the range of those
-- already set up (Another thing which had better NOT happen...)
-- we trick the decoder into thinking it actually got the last
-- code read. (Hmmn... I'm not sure why this works...
-- But it does...)
if Code >= Slot then
if Code > Slot then
BadCodeCount := BadCodeCount + 1;
end if;
Code := Oc;
Stack (StackPtr) := Fc rem 256;
StackPtr := StackPtr + 1;
end if;
-- Here we scan back along the linked list of prefixes, pushing
-- helpless characters (ie. suffixes) onto the stack as we do so.
while Code >= FirstFree loop
Stack (StackPtr) := Suffix (Code);
StackPtr := StackPtr + 1;
Code := Prefix (Code);
end loop;
-- Push the last character on the stack, and set up the new
-- prefix and suffix, and if the required slot number is greater
-- than that allowed by the current bit size, increase the bit
-- size. (NOTE - If we are all full, we *don't* save the new
-- suffix and prefix... I'm not certain if this is correct...
-- it might be more proper to overwrite the last code...
Stack (StackPtr) := Code rem 256;
if Slot < TopSlot then
Suffix (Slot) := Code rem 256;
Fc := Code;
Prefix (Slot) := Oc;
Slot := Slot + 1;
Oc := C;
end if;
if Slot >= TopSlot then
if CurrSize < 12 then
TopSlot := TopSlot * 2;
CurrSize := CurrSize + 1;
end if;
end if;
-- Now that we've pushed the decoded string (in reverse order)
-- onto the stack, lets pop it off and output it...
loop
Next_Pixel(Stack (StackPtr));
exit when StackPtr = 0;
StackPtr := StackPtr - 1;
end loop;
end if;
C := Read_Code;
end loop;
if full_trace and then BadCodeCount > 0 then
Ada.Text_IO.Put_Line(
"Found" & Integer'Image(BadCodeCount) &
" bad codes"
);
end if;
end GIF_Decode;
-- Here we have several specialized instances of GIF_Decode,
-- with parameters known at compile-time -> optimizing compilers
-- will skip expensive tests about interlacing, transparency.
--
procedure GIF_Decode_interlaced_transparent_8 is
new GIF_Decode(True, True, 255);
procedure GIF_Decode_straight_transparent_8 is
new GIF_Decode(False, True, 255);
procedure GIF_Decode_interlaced_opaque_8 is
new GIF_Decode(True, False, 255);
procedure GIF_Decode_straight_opaque_8 is
new GIF_Decode(False, False, 255);
--
procedure Skip_sub_blocks is
temp: U8;
begin
sub_blocks_sequence:
loop
Get_Byte(image.buffer, temp ); -- load sub-block length byte
exit sub_blocks_sequence when temp = 0;
-- null sub-block = end of sub-block sequence
for i in 1..temp loop
Get_Byte(image.buffer, temp ); -- load sub-block byte
end loop;
end loop sub_blocks_sequence;
end Skip_sub_blocks;
temp, temp2, label: U8;
delay_frame: U16;
c: Character;
frame_interlaced: Boolean;
frame_transparency: Boolean:= False;
local_palette : Boolean;
--
separator : Character ;
-- Colour information
new_num_of_colours : Natural;
pixel_mask : U32;
BitsPerPixel : Natural;
begin -- Load
next_frame:= 0.0;
-- Scan various GIF blocks, until finding an image
loop
Get_Byte(image.buffer, temp);
separator:= Character'Val(temp);
if full_trace then
Ada.Text_IO.Put(
"GIF separator [" & separator &
"][" & U8'Image(temp) & ']'
);
end if;
case separator is
when ',' => -- 16#2C#
exit;
-- Image descriptor will begin
-- See: 20. Image Descriptor
when ';' => -- 16#3B#
if full_trace then
Ada.Text_IO.Put(" - End of GIF");
end if;
image.next_frame:= 0.0;
next_frame:= image.next_frame;
return; -- End of GIF image
when '!' => -- 16#21# Extensions
if full_trace then
Ada.Text_IO.Put(" - Extension");
end if;
Get_Byte(image.buffer, label );
case label is
when 16#F9# => -- See: 23. Graphic Control Extension
if full_trace then
Ada.Text_IO.Put_Line(" - Graphic Control Extension");
end if;
Get_Byte(image.buffer, temp );
if temp /= 4 then
Raise_Exception(
error_in_image_data'Identity,
"GIF: error in Graphic Control Extension"
);
end if;
Get_Byte(image.buffer, temp );
-- Reserved 3 Bits
-- Disposal Method 3 Bits
-- User Input Flag 1 Bit
-- Transparent Color Flag 1 Bit
frame_transparency:= (temp and 1) = 1;
Read_Intel(image.buffer, delay_frame);
image.next_frame:=
image.next_frame + Ada.Calendar.Day_Duration(delay_frame) / 100.0;
next_frame:= image.next_frame;
Get_Byte(image.buffer, temp );
Transp_color:= Color_Type(temp);
-- zero sub-block:
Get_Byte(image.buffer, temp );
when 16#FE# => -- See: 24. Comment Extension
if full_trace then
Ada.Text_IO.Put_Line(" - Comment Extension");
sub_blocks_sequence:
loop
Get_Byte(image.buffer, temp ); -- load sub-block length byte
exit sub_blocks_sequence when temp = 0;
-- null sub-block = end of sub-block sequence
for i in 1..temp loop
Get_Byte(image.buffer, temp2);
c:= Character'Val(temp2);
Ada.Text_IO.Put(c);
end loop;
end loop sub_blocks_sequence;
Ada.Text_IO.New_Line;
else
Skip_sub_blocks;
end if;
when 16#01# => -- See: 25. Plain Text Extension
if full_trace then
Ada.Text_IO.Put_Line(" - Plain Text Extension");
end if;
Skip_sub_blocks;
when 16#FF# => -- See: 26. Application Extension
if full_trace then
Ada.Text_IO.Put_Line(" - Application Extension");
end if;
Skip_sub_blocks;
when others =>
if full_trace then
Ada.Text_IO.Put_Line(" - Unused:" & U8'Image(label));
end if;
Skip_sub_blocks;
end case;
when others =>
Raise_Exception(
error_in_image_data'Identity,
"Unknown GIF separator: " & separator
);
end case;
end loop;
-- Load the image descriptor
Read_Intel(image.buffer, Descriptor.ImageLeft);
Read_Intel(image.buffer, Descriptor.ImageTop);
Read_Intel(image.buffer, Descriptor.ImageWidth);
Read_Intel(image.buffer, Descriptor.ImageHeight);
Get_Byte(image.buffer, Descriptor.Depth);
-- Get image corner coordinates
tlX := Natural(Descriptor.ImageLeft);
tlY := Natural(Descriptor.ImageTop);
brX := tlX + Natural(Descriptor.ImageWidth);
brY := tlY + Natural(Descriptor.ImageHeight);
-- Local Color Table Flag 1 Bit
-- Interlace Flag 1 Bit
-- Sort Flag 1 Bit
-- Reserved 2 Bits
-- Size of Local Color Table 3 Bits
--
frame_interlaced:= (Descriptor.Depth and 64) = 64;
local_palette:= (Descriptor.Depth and 128) = 128;
local.format:= GIF;
local.stream:= image.stream;
local.buffer:= image.buffer;
if local_palette then
-- Get amount of colours in image
BitsPerPixel := 1 + Natural(Descriptor.Depth and 7);
New_num_of_colours:= 2 ** BitsPerPixel;
-- 21. Local Color Table
local.palette:= new Color_table(0..New_num_of_colours-1);
Color_tables.Load_palette(local);
image.buffer:= local.buffer;
elsif image.palette = null then
Raise_Exception(
error_in_image_data'Identity,
"GIF: neither local, nor global palette"
);
else
-- Use global palette
New_num_of_colours:= 2 ** image.subformat_id;
-- usually <= 2** image.bits_per_pixel
-- Just copy main palette
local.palette:= new Color_table'(image.palette.all);
end if;
Pixel_mask:= U32(New_num_of_colours - 1);
if full_trace then
Ada.Text_IO.Put_Line(
" - Image, interlaced: " & Boolean'Image(frame_interlaced) &
"; local palette: " & Boolean'Image(local_palette) &
"; transparency: " & Boolean'Image(frame_transparency) &
"; transparency index:" & Color_type'Image(Transp_color)
);
end if;
-- Get initial code size
Get_Byte(image.buffer, temp );
if Natural(temp) not in Code_size_range then
Raise_Exception(
error_in_image_data'Identity,
"GIF: wrong LZW code size (must be in 2..12), is" &
U8'Image(temp)
);
end if;
CurrSize := Natural(temp);
-- Start at top left of image
X := Natural(Descriptor.ImageLeft);
Y := Natural(Descriptor.ImageTop);
Set_X_Y(X, image.height - Y - 1);
--
if new_num_of_colours < 256 then
-- "Rare" formats -> no need of best speed
declare
-- We create an instance with dynamic parameters
procedure GIF_Decode_general is
new GIF_Decode(frame_interlaced, frame_transparency, pixel_mask);
begin
GIF_Decode_general;
end;
else
-- 8 bit, usual format: we try to make things
-- faster with specialized instanciations...
if frame_interlaced then
if frame_transparency then
GIF_Decode_interlaced_transparent_8;
else
GIF_Decode_interlaced_opaque_8;
end if;
else -- straight (non-interlaced)
if frame_transparency then
GIF_Decode_straight_transparent_8;
else
GIF_Decode_straight_opaque_8;
end if;
end if;
end if;
Feedback(100);
--
Get_Byte(image.buffer, temp ); -- zero-size sub-block
end Load;
end GID.Decoding_GIF;
|
stcarrez/ada-util | Ada | 1,272 | ads | -----------------------------------------------------------------------
-- util-streams-sockets-tests -- Unit tests for socket streams
-- Copyright (C) 2012 Stephane Carrez
-- Written by Stephane Carrez ([email protected])
--
-- Licensed under the Apache License, Version 2.0 (the "License");
-- you may not use this file except in compliance with the License.
-- You may obtain a copy of the License at
--
-- http://www.apache.org/licenses/LICENSE-2.0
--
-- Unless required by applicable law or agreed to in writing, software
-- distributed under the License is distributed on an "AS IS" BASIS,
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-- See the License for the specific language governing permissions and
-- limitations under the License.
-----------------------------------------------------------------------
with Util.Tests;
package Util.Streams.Sockets.Tests is
procedure Add_Tests (Suite : in Util.Tests.Access_Test_Suite);
type Test is new Util.Tests.Test with null record;
-- Test reading and writing on a socket stream.
procedure Test_Socket_Read (T : in out Test);
-- Test socket initialization.
procedure Test_Socket_Init (T : in out Test);
end Util.Streams.Sockets.Tests;
|
fengjixuchui/ewok-kernel | Ada | 21,146 | adb | --
-- Copyright 2018 The wookey project team <[email protected]>
-- - Ryad Benadjila
-- - Arnauld Michelizza
-- - Mathieu Renard
-- - Philippe Thierry
-- - Philippe Trebuchet
--
-- Licensed under the Apache License, Version 2.0 (the "License");
-- you may not use this file except in compliance with the License.
-- You may obtain a copy of the License at
--
-- http://www.apache.org/licenses/LICENSE-2.0
--
-- Unless required by applicable law or agreed to in writing, software
-- distributed under the License is distributed on an "AS IS" BASIS,
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-- See the License for the specific language governing permissions and
-- limitations under the License.
--
--
with m4.cpu;
with m4.cpu.instructions;
with m4.mpu;
with ewok.debug;
with ewok.layout; use ewok.layout;
with ewok.devices_shared; use ewok.devices_shared;
with ewok.ipc; use ewok.ipc;
with ewok.softirq;
with ewok.devices;
with c.kernel;
with types.c; use type types.c.t_retval;
with applications; -- Automatically generated
with sections; -- Automatically generated
package body ewok.tasks
with spark_mode => off
is
procedure idle_task
is
begin
pragma DEBUG (debug.log (debug.INFO, "IDLE thread"));
m4.cpu.enable_irq;
loop
m4.cpu.instructions.wait_for_interrupt;
end loop;
end idle_task;
procedure finished_task
is
begin
loop null; end loop;
end finished_task;
procedure create_stack
(sp : in system_address;
pc : in system_address;
params : in ewok.t_parameters;
frame_a : out ewok.t_stack_frame_access)
is
begin
frame_a := to_stack_frame_access (sp - (t_stack_frame'size / 8));
frame_a.all.R0 := params(0);
frame_a.all.R1 := params(1);
frame_a.all.R2 := params(2);
frame_a.all.R3 := params(3);
frame_a.all.R4 := 0;
frame_a.all.R5 := 0;
frame_a.all.R6 := 0;
frame_a.all.R7 := 0;
frame_a.all.R8 := 0;
frame_a.all.R9 := 0;
frame_a.all.R10 := 0;
frame_a.all.R11 := 0;
frame_a.all.R12 := 0;
frame_a.all.exc_return := m4.cpu.EXC_THREAD_MODE;
frame_a.all.LR := to_system_address (finished_task'address);
frame_a.all.PC := pc;
frame_a.all.PSR := m4.cpu.t_PSR_register'
(ISR_NUMBER => 0,
ICI_IT_lo => 0,
GE => 0,
Thumb => 1,
ICI_IT_hi => 0,
DSP_overflow => 0,
Overflow => 0,
Carry => 0,
Zero => 0,
Negative => 0);
end create_stack;
procedure set_default_values (tsk : out t_task)
is
begin
tsk.name := " ";
tsk.entry_point := 0;
tsk.ttype := TASK_TYPE_USER;
tsk.mode := TASK_MODE_MAINTHREAD;
tsk.id := ID_UNUSED;
tsk.slot := 0;
tsk.num_slots := 0;
tsk.prio := 0;
#if CONFIG_KERNEL_DOMAIN
tsk.domain := 0;
#end if;
#if CONFIG_KERNEL_SCHED_DEBUG
tsk.count := 0;
tsk.force_count := 0;
tsk.isr_count := 0;
#end if;
#if CONFIG_KERNEL_DMA_ENABLE
tsk.num_dma_shms := 0;
tsk.dma_shm :=
(others => ewok.exported.dma.t_dma_shm_info'
(granted_id => ID_UNUSED,
accessed_id => ID_UNUSED,
base => 0,
size => 0,
access_type => ewok.exported.dma.SHM_ACCESS_READ));
tsk.num_dma_id := 0;
tsk.dma_id := (others => ewok.dma_shared.ID_DMA_UNUSED);
#end if;
tsk.init_done := false;
tsk.num_devs := 0;
tsk.num_devs_mounted := 0;
tsk.device_id := (others => ewok.devices_shared.ID_DEV_UNUSED);
tsk.mounted_device := (others => ewok.devices_shared.ID_DEV_UNUSED);
tsk.data_slot_start := 0;
tsk.data_slot_end := 0;
tsk.txt_slot_start := 0;
tsk.txt_slot_end := 0;
tsk.stack_size := 0;
tsk.state := TASK_STATE_EMPTY;
tsk.isr_state := TASK_STATE_EMPTY;
tsk.ipc_endpoints := (others => NULL);
tsk.ctx.frame_a := NULL;
tsk.isr_ctx := t_isr_context'(0, ID_DEV_UNUSED, ISR_STANDARD, NULL);
end set_default_values;
procedure init_softirq_task
is
params : constant t_parameters := (others => 0);
begin
-- Setting default values
set_default_values (tasks_list(ID_SOFTIRQ));
tasks_list(ID_SOFTIRQ).name := softirq_task_name;
tasks_list(ID_SOFTIRQ).entry_point :=
to_system_address (ewok.softirq.main_task'address);
if tasks_list(ID_SOFTIRQ).entry_point mod 2 = 0 then
tasks_list(ID_SOFTIRQ).entry_point :=
tasks_list(ID_SOFTIRQ).entry_point + 1;
end if;
tasks_list(ID_SOFTIRQ).ttype := TASK_TYPE_KERNEL;
tasks_list(ID_SOFTIRQ).mode := TASK_MODE_MAINTHREAD;
tasks_list(ID_SOFTIRQ).id := ID_SOFTIRQ;
tasks_list(ID_SOFTIRQ).slot := 0; -- unused
tasks_list(ID_SOFTIRQ).num_slots := 0; -- unused
-- Zeroing the stack
declare
stack : byte_array(1 .. STACK_SIZE_SOFTIRQ)
with address => to_address (STACK_TOP_SOFTIRQ - STACK_SIZE_SOFTIRQ);
begin
stack := (others => 0);
end;
-- Create the initial stack frame and set the stack pointer
create_stack
(STACK_TOP_SOFTIRQ,
tasks_list(ID_SOFTIRQ).entry_point,
params,
tasks_list(ID_SOFTIRQ).ctx.frame_a);
tasks_list(ID_SOFTIRQ).stack_size := STACK_SIZE_SOFTIRQ;
tasks_list(ID_SOFTIRQ).state := TASK_STATE_IDLE;
tasks_list(ID_SOFTIRQ).isr_state := TASK_STATE_IDLE;
for i in tasks_list(ID_SOFTIRQ).ipc_endpoints'range loop
tasks_list(ID_SOFTIRQ).ipc_endpoints(i) := NULL;
end loop;
pragma DEBUG (debug.log (debug.INFO, "Created SOFTIRQ context (pc: "
& system_address'image (tasks_list(ID_SOFTIRQ).entry_point)
& ") sp: "
& system_address'image
(to_system_address (tasks_list(ID_SOFTIRQ).ctx.frame_a))));
end init_softirq_task;
procedure init_idle_task
is
params : constant t_parameters := (others => 0);
begin
-- Setting default values
set_default_values (tasks_list(ID_KERNEL));
tasks_list(ID_KERNEL).name := idle_task_name;
tasks_list(ID_KERNEL).entry_point :=
to_system_address (idle_task'address);
if tasks_list(ID_KERNEL).entry_point mod 2 = 0 then
tasks_list(ID_KERNEL).entry_point :=
tasks_list(ID_KERNEL).entry_point + 1;
end if;
tasks_list(ID_KERNEL).ttype := TASK_TYPE_KERNEL;
tasks_list(ID_KERNEL).mode := TASK_MODE_MAINTHREAD;
tasks_list(ID_KERNEL).id := ID_KERNEL;
tasks_list(ID_KERNEL).slot := 0; -- unused
tasks_list(ID_KERNEL).num_slots := 0; -- unused
-- Zeroing the stack
declare
stack : byte_array(1 .. STACK_SIZE_IDLE)
with address => to_address (STACK_TOP_IDLE - STACK_SIZE_IDLE);
begin
stack := (others => 0);
end;
-- Create the initial stack frame and set the stack pointer
create_stack
(STACK_TOP_IDLE,
tasks_list(ID_KERNEL).entry_point,
params,
tasks_list(ID_KERNEL).ctx.frame_a);
tasks_list(ID_KERNEL).stack_size := STACK_SIZE_IDLE;
tasks_list(ID_KERNEL).state := TASK_STATE_RUNNABLE;
tasks_list(ID_KERNEL).isr_state := TASK_STATE_IDLE;
for i in tasks_list(ID_KERNEL).ipc_endpoints'range loop
tasks_list(ID_KERNEL).ipc_endpoints(i) := NULL;
end loop;
pragma DEBUG (debug.log (debug.INFO, "Created context for IDLE task (pc: "
& system_address'image (tasks_list(ID_KERNEL).entry_point)
& ") sp: "
& system_address'image
(to_system_address (tasks_list(ID_KERNEL).ctx.frame_a))));
end init_idle_task;
procedure init_apps
is
user_base : system_address;
params : t_parameters;
random : unsigned_32;
begin
if applications.t_real_task_id'last > ID_APP7 then
debug.panic ("Too many apps");
end if;
user_base := applications.txt_user_region_base;
for id in applications.list'range loop
set_default_values (tasks_list(id));
tasks_list(id).name := applications.list(id).name;
tasks_list(id).entry_point :=
user_base
+ to_unsigned_32 (applications.list(id).slot - 1)
* applications.txt_user_size / 8; -- this is MPU specific
if tasks_list(id).entry_point mod 2 = 0 then
tasks_list(id).entry_point := tasks_list(id).entry_point + 1;
end if;
tasks_list(id).ttype := TASK_TYPE_USER;
tasks_list(id).mode := TASK_MODE_MAINTHREAD;
tasks_list(id).id := id;
tasks_list(id).slot := applications.list(id).slot;
tasks_list(id).num_slots := applications.list(id).num_slots;
tasks_list(id).prio := applications.list(id).priority;
#if CONFIG_KERNEL_DOMAIN
tasks_list(id).domain := applications.list(id).domain;
#end if;
#if CONFIG_KERNEL_SCHED_DEBUG
tasks_list(id).count := 0;
tasks_list(id).force_count := 0;
tasks_list(id).isr_count := 0;
#end if;
#if CONFIG_KERNEL_DMA_ENABLE
tasks_list(id).num_dma_shms := 0;
tasks_list(id).dma_shm :=
(others => ewok.exported.dma.t_dma_shm_info'
(granted_id => ID_UNUSED,
accessed_id => ID_UNUSED,
base => 0,
size => 0,
access_type => ewok.exported.dma.SHM_ACCESS_READ));
tasks_list(id).num_dma_id := 0;
tasks_list(id).dma_id :=
(others => ewok.dma_shared.ID_DMA_UNUSED);
#end if;
tasks_list(id).num_devs := 0;
tasks_list(id).num_devs_mounted := 0;
tasks_list(id).device_id := (others => ID_DEV_UNUSED);
tasks_list(id).mounted_device := (others => ID_DEV_UNUSED);
tasks_list(id).init_done := false;
tasks_list(id).data_slot_start :=
USER_DATA_BASE
+ to_unsigned_32 (tasks_list(id).slot - 1)
* USER_DATA_SIZE;
tasks_list(id).data_slot_end :=
USER_DATA_BASE
+ to_unsigned_32
(tasks_list(id).slot + tasks_list(id).num_slots - 1)
* USER_DATA_SIZE;
tasks_list(id).txt_slot_start := tasks_list(id).entry_point - 1;
tasks_list(id).txt_slot_end :=
user_base
+ to_unsigned_32
(applications.list(id).slot + tasks_list(id).num_slots - 1)
* applications.txt_user_size / 8; -- this is MPU specific
tasks_list(id).stack_bottom := applications.list(id).stack_bottom;
tasks_list(id).stack_top := applications.list(id).stack_top;
tasks_list(id).stack_size := applications.list(id).stack_size;
tasks_list(id).state := TASK_STATE_RUNNABLE;
tasks_list(id).isr_state := TASK_STATE_IDLE;
for i in tasks_list(id).ipc_endpoints'range loop
tasks_list(id).ipc_endpoints(i) := NULL;
end loop;
-- Zeroing the stack
declare
stack : byte_array(1 .. unsigned_32 (tasks_list(id).stack_size))
with address => to_address
(tasks_list(id).data_slot_end -
unsigned_32 (tasks_list(id).stack_size));
begin
stack := (others => 0);
end;
--
-- Create the initial stack frame and set the stack pointer
--
-- Getting the stack "canary"
if c.kernel.get_random_u32 (random) /= types.c.SUCCESS then
debug.panic ("Unable to get random from TRNG source");
end if;
params := t_parameters'(to_unsigned_32 (id), random, 0, 0);
create_stack
(tasks_list(id).stack_top,
tasks_list(id).entry_point,
params,
tasks_list(id).ctx.frame_a);
tasks_list(id).isr_ctx.entry_point := applications.list(id).start_isr;
pragma DEBUG (debug.log (debug.INFO, "Created task " & tasks_list(id).name
& " (pc: " & system_address'image (tasks_list(id).entry_point)
& ", sp: " & system_address'image
(to_system_address (tasks_list(id).ctx.frame_a))
& ", ID" & t_task_id'image (id) & ")"));
end loop;
end init_apps;
function get_task (id : ewok.tasks_shared.t_task_id)
return t_task_access
is
begin
return tasks_list(id)'access;
end get_task;
function get_task_id (name : t_task_name)
return ewok.tasks_shared.t_task_id
is
-- String comparison is a bit tricky here because:
-- - We want it case-unsensitive ('a' and 'A' are the same)
-- - The nul character and space ' ' are consider the same
--
-- The following inner functions are needed to effect comparisons:
-- Convert a character to uppercase
function to_upper (c : character)
return character
is
val : constant natural := character'pos (c);
begin
return
(if c in 'a' .. 'z' then character'val (val - 16#20#) else c);
end;
-- Test if a character is 'nul'
function is_nul (c : character)
return boolean
is begin
return c = ASCII.NUL or c = ' ';
end;
-- Test if the 2 strings are the same
function is_same (s1: t_task_name; s2 : t_task_name)
return boolean
is begin
for i in t_task_name'range loop
if is_nul (s1(i)) and is_nul (s2(i)) then
return true;
end if;
if to_upper (s1(i)) /= to_upper (s2(i)) then
return false;
end if;
end loop;
return true;
end;
begin
for id in applications.list'range loop
if is_same (tasks_list(id).name, name) then
return id;
end if;
end loop;
return ID_UNUSED;
end get_task_id;
#if CONFIG_KERNEL_DOMAIN
function get_domain (id : in ewok.tasks_shared.t_task_id)
return unsigned_8
is
begin
return tasks_list(id).domain;
end get_domain;
#end if;
function get_state
(id : ewok.tasks_shared.t_task_id;
mode : t_task_mode)
return t_task_state
is
begin
if mode = TASK_MODE_MAINTHREAD then
return tasks_list(id).state;
else
return tasks_list(id).isr_state;
end if;
end get_state;
procedure set_state
(id : ewok.tasks_shared.t_task_id;
mode : t_task_mode;
state : t_task_state)
is
begin
if mode = TASK_MODE_MAINTHREAD then
tasks_list(id).state := state;
else
tasks_list(id).isr_state := state;
end if;
end set_state;
function get_mode
(id : in ewok.tasks_shared.t_task_id)
return t_task_mode
is
begin
return tasks_list(id).mode;
end get_mode;
procedure set_mode
(id : in ewok.tasks_shared.t_task_id;
mode : in ewok.tasks_shared.t_task_mode)
is
begin
tasks_list(id).mode := mode;
end set_mode;
function is_ipc_waiting
(id : in ewok.tasks_shared.t_task_id)
return boolean
is
begin
for i in tasks_list(id).ipc_endpoints'range loop
if tasks_list(id).ipc_endpoints(i) /= NULL
and then
tasks_list(id).ipc_endpoints(i).state = ewok.ipc.WAIT_FOR_RECEIVER
and then
ewok.ipc.to_task_id (tasks_list(id).ipc_endpoints(i).to) = id
then
return true;
end if;
end loop;
return false;
end;
procedure append_device
(id : in ewok.tasks_shared.t_task_id;
dev_id : in ewok.devices_shared.t_device_id;
descriptor : out unsigned_8;
success : out boolean)
is
begin
if tasks_list(id).num_devs = MAX_DEVS_PER_TASK then
descriptor := 0;
success := false;
return;
end if;
for i in tasks_list(id).device_id'range loop
if tasks_list(id).device_id(i) = ID_DEV_UNUSED then
tasks_list(id).device_id(i) := dev_id;
tasks_list(id).num_devs := tasks_list(id).num_devs + 1;
descriptor := i;
success := true;
return;
end if;
end loop;
raise program_error;
end append_device;
procedure remove_device
(id : in ewok.tasks_shared.t_task_id;
dev_id : in ewok.devices_shared.t_device_id;
success : out boolean)
is
begin
for i in tasks_list(id).device_id'range loop
if tasks_list(id).device_id(i) = dev_id then
tasks_list(id).device_id(i) := ID_DEV_UNUSED;
tasks_list(id).num_devs := tasks_list(id).num_devs - 1;
success := true;
return;
end if;
end loop;
success := false;
end remove_device;
function is_mounted
(id : in ewok.tasks_shared.t_task_id;
dev_id : in ewok.devices_shared.t_device_id)
return boolean
is
begin
for i in tasks_list(id).mounted_device'range loop
if tasks_list(id).mounted_device(i) = dev_id then
return true;
end if;
end loop;
return false;
end is_mounted;
procedure mount_device
(id : in ewok.tasks_shared.t_task_id;
dev_id : in ewok.devices_shared.t_device_id;
success : out boolean)
is
ok : boolean;
begin
-- The device is already mounted
if is_mounted (id, dev_id) then
success := false;
return;
end if;
-- No available MPU region to map the device in memory
if tasks_list(id).num_devs_mounted = ewok.mpu.MAX_DEVICE_REGIONS then
success := false;
return;
end if;
-- Mounting the device
for i in tasks_list(id).mounted_device'range loop
if tasks_list(id).mounted_device(i) = ID_DEV_UNUSED then
tasks_list(id).mounted_device(i) := dev_id;
tasks_list(id).num_devs_mounted :=
tasks_list(id).num_devs_mounted + 1;
-- Mapping the device in its related MPU region
ewok.devices.mpu_mapping_device
(dev_id, ewok.mpu.device_regions(i), ok);
if not ok then
tasks_list(id).mounted_device(i) := ID_DEV_UNUSED;
tasks_list(id).num_devs_mounted :=
tasks_list(id).num_devs_mounted - 1;
success := false;
return;
end if;
success := true;
return;
end if;
end loop;
raise program_error;
end mount_device;
procedure unmount_device
(id : in ewok.tasks_shared.t_task_id;
dev_id : in ewok.devices_shared.t_device_id;
success : out boolean)
is
begin
for i in tasks_list(id).mounted_device'range loop
if tasks_list(id).mounted_device(i) = dev_id then
tasks_list(id).mounted_device(i) := ID_DEV_UNUSED;
tasks_list(id).num_devs_mounted :=
tasks_list(id).num_devs_mounted - 1;
-- Unmapping the device from its related MPU region
m4.mpu.disable_region (ewok.mpu.device_regions(i));
success := true;
return;
end if;
end loop;
success := false;
end unmount_device;
function is_real_user (id : ewok.tasks_shared.t_task_id) return boolean
is
begin
return (id in applications.t_real_task_id);
end is_real_user;
procedure set_return_value
(id : in ewok.tasks_shared.t_task_id;
mode : in t_task_mode;
val : in unsigned_32)
is
begin
case mode is
when TASK_MODE_MAINTHREAD =>
tasks_list(id).ctx.frame_a.all.R0 := val;
when TASK_MODE_ISRTHREAD =>
tasks_list(id).isr_ctx.frame_a.all.R0 := val;
end case;
end set_return_value;
procedure task_init
is
begin
for id in tasks_list'range loop
set_default_values (tasks_list(id));
end loop;
init_idle_task;
init_softirq_task;
init_apps;
sections.task_map_data;
end task_init;
function is_init_done
(id : ewok.tasks_shared.t_task_id)
return boolean
is
begin
return tasks_list(id).init_done;
end is_init_done;
end ewok.tasks;
|
jhumphry/PRNG_Zoo | Ada | 4,137 | adb | --
-- PRNG Zoo
-- Copyright (c) 2014 - 2015, James Humphry
--
-- Permission to use, copy, modify, and/or distribute this software for any
-- purpose with or without fee is hereby granted, provided that the above
-- copyright notice and this permission notice appear in all copies.
--
-- THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
-- REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
-- AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
-- INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
-- LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
-- OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
-- PERFORMANCE OF THIS SOFTWARE.
with AUnit.Assertions; use AUnit.Assertions;
with PRNG_Zoo.Misc;
use all type PRNG_Zoo.Misc.glibc_random;
use all type PRNG_Zoo.Misc.KISS;
package body PRNGTests_Suite.Misc_Tests is
--------------------
-- Register_Tests --
--------------------
procedure Register_Tests (T: in out Misc_Test) is
use AUnit.Test_Cases.Registration;
begin
Register_Routine (T, Sanity_Check_GLib_Random'Access, "Basic sanity checks on GLib Random() generator.");
Register_Routine (T, Sanity_Check_KISS'Access, "Basic sanity checks on Marsaglia KISS generator.");
Register_Routine (T, Test_Glib_Random'Access, "Test GLib Random() generator against expected (initial) output");
Register_Routine (T, Sanity_Check_MurmurHash3'Access, "Basic sanity checks on generator based on MurmurHash3.");
Register_Routine (T, Sanity_Check_SplitMix'Access, "Basic sanity checks on SplitMix generator.");
end Register_Tests;
----------
-- Name --
----------
function Name (T : Misc_Test) return Test_String is
pragma Unreferenced (T);
begin
return Format ("Test miscellaneous PRNGs");
end Name;
------------
-- Set_Up --
------------
procedure Set_Up (T : in out Misc_Test) is
begin
null;
end Set_Up;
----------------------
-- Test_Glib_Random --
----------------------
procedure Test_Glib_Random (T : in out Test_Cases.Test_Case'Class) is
pragma Unreferenced (T);
G : Misc.glibc_random;
Expected_Array : constant U32_array := (
1804289383, 846930886, 1681692777, 1714636915,
1957747793, 424238335, 719885386, 1649760492,
596516649, 1189641421, 1025202362, 1350490027,
783368690, 1102520059, 2044897763, 1967513926,
1365180540, 1540383426, 304089172, 1303455736,
35005211, 521595368, 294702567, 1726956429,
336465782, 861021530, 278722862, 233665123,
2145174067, 468703135, 1101513929, 1801979802,
1315634022, 635723058, 1369133069, 1125898167,
1059961393, 2089018456, 628175011, 1656478042,
1131176229, 1653377373, 859484421, 1914544919,
608413784, 756898537, 1734575198, 1973594324,
149798315, 2038664370, 1129566413, 184803526,
412776091, 1424268980, 1911759956, 749241873,
137806862, 42999170, 982906996, 135497281,
511702305, 2084420925, 1937477084, 1827336327
);
begin
Reset(G, 1);
for E of Expected_Array loop
Assert(U32'(Generate(G)) = E,
"GLib Random() implementation produces unexpected result for seed 1");
end loop;
end Test_Glib_Random;
end PRNGTests_Suite.Misc_Tests;
|
riccardo-bernardini/eugen | Ada | 17,908 | adb | pragma Ada_2012;
with Ada.Characters.Handling;
with Ada.Strings.Fixed;
with Line_Arrays.Classified;
with Line_Arrays.Regexp_Classifiers;
with GNAT.Regpat;
with Ada.Text_IO; use Ada.Text_IO;
with Tokenize.Token_Vectors;
package body Node_List_Parsers is
use Ada.Characters.Handling;
function Chop (X : String) return String
is (Ada.Strings.Fixed.Trim (X, Ada.Strings.Both));
function Image (X : Integer) return String
is (Chop (Integer'Image (X)));
pragma Unreferenced (Image);
function Force_Case_Maybe (X : String; Case_Sensitive : Boolean) return String
is (if Case_Sensitive then X else To_Lower (X));
type Line_Class is (Header, Attribute, Text, Comment);
type Classified_Line (Class : Line_Class) is
record
case Class is
when Header =>
Name : Id;
when Attribute =>
Key : Id;
Value : Unbounded_String;
when Text =>
Content : Unbounded_String;
when Comment =>
null;
end case;
end record;
function Image (Item : Classified_Line) return String
is (Item.Class'Image &
(case Item.Class is
when Header =>
Bounded_Identifiers.To_String (Item.Name),
when Attribute =>
Bounded_Identifiers.To_String (Item.Key) & "," & To_String (Item.Value),
when Text =>
To_String (Item.Content),
when Comment =>
""));
function Extract (Item : String;
Matches : Gnat.Regpat.Match_Array;
Index : Natural)
return String
is (Item (Matches (Index).First .. Matches (Index).Last))
with Pre => Index <= Matches'Last;
function Extract (Item : String;
Matches : Gnat.Regpat.Match_Array;
Index : Natural)
return Id
is (Bounded_Identifiers.To_Bounded_String (To_Lower (Extract (Item, Matches, Index))))
with Pre => Index <= Matches'Last;
function Extract (Item : String;
Matches : Gnat.Regpat.Match_Array;
Index : Natural)
return Unbounded_String
is (To_Unbounded_String (Extract (Item, Matches, Index)))
with Pre => Index <= Matches'Last;
function Process_Header (Item : String;
Matches : Gnat.Regpat.Match_Array)
return Classified_Line
is (Classified_Line'(Class => Header,
Name => Extract (Item, Matches, 1)));
function Process_Attribute (Item : String;
Matches : Gnat.Regpat.Match_Array)
return Classified_Line
is (Classified_Line'(Class => Attribute,
Key => Extract (Item, Matches, 1),
Value => Extract (Item, Matches, 2)));
function Process_Text (Item : String;
Matches : Gnat.Regpat.Match_Array)
return Classified_Line
is (Classified_Line'(Class => Text,
Content => Extract (Item, Matches, 0)));
function Process_Comment (Item : String;
Matches : Gnat.Regpat.Match_Array)
return Classified_Line;
pragma Warnings (Off, Process_Comment);
function Process_Comment (Item : String;
Matches : Gnat.Regpat.Match_Array)
return Classified_Line
is (Classified_Line'(Class => Comment));
function Is_To_Be_Ignored (Line : Classified_Line) return Boolean
is (Line.Class = Comment);
-----------------------
-- Use_Default_Names --
-----------------------
function Use_Default_Names (Names : Name_Maps.Map) return Name_Maps.Map
is
use Name_Maps;
package Reverse_Maps is
new Ada.Containers.Indefinite_Ordered_Maps (Key_Type => Node_Class,
Element_Type => Id);
Rev : Reverse_Maps.Map;
True_Names : Name_Maps.Map;
begin
for Pos in Names.Iterate loop
if Rev.Contains (Element (Pos)) then
raise Constraint_Error;
end if;
Rev.Include (Key => Element (Pos),
New_Item => Key (Pos));
end loop;
for Cl in Node_Class loop
if Rev.Contains (Cl) then
True_Names.Include (Key => Rev (Cl),
New_Item => Cl);
else
True_Names.Include (Key => Bounded_Identifiers.To_Bounded_String (To_Lower (Node_Class'Image (Cl))),
New_Item => Cl);
end if;
end loop;
-- for Pos in True_Names.Iterate loop
-- Put_Line (To_String (Key (Pos)) & "=>" & Element (Pos)'Image);
-- end loop;
return True_Names;
end Use_Default_Names;
-----------
-- Parse --
-----------
function Parse
(Input : Line_Arrays.Line_Array;
Names : Name_Maps.Map := Name_Maps.Empty_Map;
Trimming : Trimming_Action := Both;
Line_Trimming : Trimming_Action := Both)
return Node_List
is
package My_Classifier is
new Line_Arrays.Regexp_Classifiers (Classified_Line => Classified_Line);
use My_Classifier;
package Classified is
new Line_Arrays.Classified (Classified_Line => Classified_Line,
Classifier_Type => Classifier_Type);
use Classified.Classified_Line_Vectors;
package Node_Vectors is
new Ada.Containers.Vectors (Index_Type => Positive,
Element_Type => Node_Type);
True_Names : constant Name_Maps.Map := Use_Default_Names (Names);
Result : Node_Vectors.Vector;
Id_Regex : constant String := "[[:alpha:]]+";
Classifier : constant Classifier_Type :=
Create (
(
P ("^ *\[ *(" & Id_Regex & ") *\] *$", Process_Header'Access),
P ("^#", Process_Comment'Access),
P ("^(" & Id_Regex & ") *:(.*)$", Process_Attribute'Access),
+Process_Text'Access
)
);
C_Lines : constant Classified.Classified_Line_Vectors.Vector :=
Classified.Classify (Classifier, Input);
Pos : Classified.Classified_Line_Vectors.Cursor := C_Lines.First;
----------------------
-- Skip_Empty_Lines --
----------------------
procedure Skip_Empty_Lines (C_Lines : Vector;
Pos : in out Cursor)
is
function Is_Empty (X : String) return Boolean
is (X'Length = 0 or else (for all Ch of X => Ch = ' '));
begin
while Pos /= No_Element
and then C_Lines (Pos).Class = Text
and then Is_Empty (To_String (C_Lines (Pos).Content))
loop
Next (Pos);
end loop;
-- Put_Line ("Fatto!");
end Skip_Empty_Lines;
------------------
-- Parse_Header --
------------------
procedure Parse_Header (C_Lines : Vector;
Pos : in out Cursor;
This_Node : out Node_Type)
is
begin
if C_Lines (Pos).Class /= Header then
raise Constraint_Error
with "expected header found "
& Image (C_Lines (Pos));
end if;
if not True_Names.Contains (C_Lines (Pos).Name) then
raise Constraint_Error with "unrecognized node '" & Bounded_Identifiers.To_String (C_Lines (Pos).Name) & "'";
end if;
This_Node.Class := True_Names.Element (C_Lines (Pos).Name);
Next (Pos);
end Parse_Header;
----------------------
-- Parse_Attributes --
----------------------
procedure Parse_Attributes (C_Lines : Vector;
Pos : in out Cursor;
This_Node : out Node_Type;
Trimming : Trimming_Action)
is
use Ada.Strings.Fixed;
function Trim (X : String; How : Trimming_Action) return String
is (case How is
when None => X,
when Head => Trim (X, Ada.Strings.Left),
when Tail => Trim (X, Ada.Strings.Right),
when Both => Trim (X, Ada.Strings.Both));
begin
while Pos /= No_Element and then C_Lines (Pos).Class = Attribute loop
This_Node.Attributes.Include (Key => C_Lines (Pos).Key,
New_Item => Trim (To_String (C_Lines (Pos).Value), Trimming));
Next (Pos);
end loop;
end Parse_Attributes;
-----------------------
-- Parse_Description --
-----------------------
procedure Parse_Description (C_Lines : Vector;
Pos : in out Cursor;
This_Node : out Node_Type)
is
function Is_Empty (X : String) return Boolean
is (X = ""
or else
(for all Ch of X => Is_Space (Ch)));
Buffer : Line_Arrays.Line_Array;
begin
while Pos /= No_Element and then C_Lines (Pos).Class = Text loop
Buffer.Append (To_String (C_Lines (Pos).Content));
Next (Pos);
end loop;
if Line_Trimming = Head or Line_Trimming = Both then
while not Buffer.Is_Empty and then Is_Empty (Buffer.First_Element) loop
Buffer.Delete_First;
end loop;
end if;
-- if Buffer.Is_Empty then
-- Put_Line ("VUOTO");
-- else
-- Put_Line ("In testa: (" & Buffer.First_Element & ")");
-- end if;
if Line_Trimming = Tail or Line_Trimming = Both then
while not Buffer.Is_Empty and then Is_Empty (Buffer.Last_Element) loop
Buffer.Delete_Last;
end loop;
end if;
This_Node.Description := Buffer;
end Parse_Description;
begin
Skip_Empty_Lines (C_Lines, Pos);
while Pos /= No_Element loop
declare
This_Node : Node_Type;
begin
Parse_Header (C_Lines, Pos, This_Node);
Parse_Attributes (C_Lines, Pos, This_Node, Trimming);
Parse_Description (C_Lines, Pos, This_Node);
Result.Append (This_Node);
end;
end loop;
declare
R : Node_List (Result.First_Index .. Result.Last_Index);
begin
for Idx in R'Range loop
R (Idx) := Result (Idx);
end loop;
return R;
end;
end Parse;
procedure Dump (Item : Node_List)
is
use Key_Value_Maps;
begin
for Node of Item loop
Put_Line ("CLASS = " & Node_Class'Image (Node.Class));
for Pos in Node.Attributes.Iterate loop
Put_Line ("'" & Bounded_Identifiers.To_String (Key (Pos)) & "' = '" & Element (Pos) & "'");
end loop;
Put_Line ("<description>");
for Line of Node.Description loop
Put_Line (Line);
end loop;
Put_Line ("</description>");
Put_Line ("******");
end loop;
end Dump;
----------
-- Next --
----------
procedure Next (X : in out Node_Scanner)
is
begin
if X.Cursor <= X.Nodes'Last then
X.Cursor := X.Cursor + 1;
end if;
end Next;
----------
-- Prev --
----------
procedure Prev (X : in out Node_Scanner)
is
begin
if X.Cursor > X.Nodes'First then
X.Cursor := X.Cursor - 1;
end if;
end Prev;
function Enumerative (Spec : String;
Allowed_Values : String;
Default : String := "";
Case_Sensitive : Boolean := False)
return Attribute_Check
is
use Tokenize;
Allowed : constant Token_Vectors.Vector :=
Token_Vectors.To_Vector (Split (To_Be_Splitted => Allowed_Values,
Separator => '|',
Collate_Separator => False));
Result : Attribute_Check :=
Attribute_Check'(Class => Enumerative_Class,
Attr => To_Id (Spec),
Allowed => ID_Vectors.Empty_Vector,
Default => To_Unbounded_String (Default),
Case_Sensitive => Case_Sensitive);
begin
for A of Allowed loop
declare
Tmp : constant String := Force_Case_Maybe (Chop (A), Case_Sensitive);
begin
if not Is_Valid_Id (Tmp) then
raise Constraint_Error with "'" & A & "' is not a valid Id";
end if;
Result.Allowed.Append (Bounded_Identifiers.To_Bounded_String (Tmp));
end;
end loop;
return Result;
end Enumerative;
-----------------
-- Alternative --
-----------------
function Alternative (Spec : String) return Attribute_Check
is
use Tokenize;
Alternatives : constant Token_Vectors.Vector :=
Token_Vectors.To_Vector (Split (To_Be_Splitted => Spec,
Separator => '|',
Collate_Separator => False));
Result : Attribute_Check (Alternative_Class);
begin
for Alt of Alternatives loop
if not Is_Valid_Id (Alt) then
raise Constraint_Error with "'" & Alt & "' is not a valid Id";
end if;
Result.Alternatives.Append (Bounded_Identifiers.To_Bounded_String (Alt));
end loop;
return Result;
end Alternative;
-----------
-- Check --
-----------
procedure Check (Checker : Attribute_Checker;
Node : in out Node_Type)
is
function Image (Names : ID_Vectors.Vector) return String
is
Result : Unbounded_String;
begin
for X of Names loop
Result := Result & Bounded_Identifiers.To_String (X) & ",";
end loop;
return "(" & To_String (Result) & ")";
end Image;
begin
for Ck of Checker.Checks loop
case Ck.Class is
when Mandatory_Class =>
if not Node.Attributes.Contains (Ck.Attribute) then
raise Missing_Mandatory
with Bounded_Identifiers.To_String (Ck.Attribute);
end if;
when Default_Class =>
if not Node.Attributes.Contains (Ck.Key) then
Node.Attributes.Insert (Key => Ck.Key,
New_Item => To_String (Ck.Value));
end if;
when Alternative_Class =>
declare
Counter : Natural := 0;
begin
for Alt of Ck.Alternatives loop
if Node.Attributes.Contains (Alt) then
Counter := Counter + 1;
end if;
end loop;
if Counter = 0 then
raise Missing_Alternative with Image (Ck.Alternatives);
elsif Counter > 1 then
raise Duplicate_Alternative with Image (Ck.Alternatives);
end if;
end;
when Enumerative_Class =>
if not Node.Attributes.Contains (Ck.Attr) then
if Ck.Default = Null_Unbounded_String then
raise Missing_Mandatory with Bounded_Identifiers.To_String (Ck.Attr);
else
Node.Attributes.Include (Key => Ck.attr,
New_Item => To_String (Ck.Default));
end if;
end if;
declare
Given : constant String :=
Force_Case_Maybe (Node.Attributes (Ck.Attr), Ck.Case_Sensitive);
begin
Node.Attributes.Include (Key => Ck.attr,
New_Item => Given);
if not Ck.Allowed.Contains (To_Id (Given)) then
raise Bad_Enumerative
with "Bad enumerative value '" & Given & "' for attribute"
& Bounded_Identifiers.To_String (Ck.Attr);
end if;
end;
end case;
end loop;
end Check;
-------------------------
-- Generic_Enumerative --
-------------------------
function Generic_Enumerative (Spec : String;
Default : String := "")
return Attribute_Check
is
Buffer : Unbounded_String;
begin
for Val in Enumerative_Type loop
Buffer := Buffer & Enumerative_Type'Image (Val);
if Val < Enumerative_Type'Last then
Buffer := Buffer & "|";
end if;
end loop;
return Enumerative (Spec => spec,
Allowed_Values => To_String (Buffer),
Default => Default,
Case_Sensitive => False);
end Generic_Enumerative;
end Node_List_Parsers;
|
stcarrez/dynamo | Ada | 6,968 | adb | ------------------------------------------------------------------------------
-- --
-- ASIS-for-GNAT IMPLEMENTATION COMPONENTS --
-- --
-- A 4 G . S T A N D --
-- --
-- B o d y --
-- --
-- Copyright (c) 1999-2003, Free Software Foundation, Inc. --
-- --
-- ASIS-for-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 --
-- Software Foundation; either version 2, or (at your option) any later --
-- version. ASIS-for-GNAT is distributed in the hope that it will be use- --
-- ful, but WITHOUT ANY WARRANTY; without even the implied warranty of MER- --
-- CHANTABILITY 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 ASIS-for-GNAT; see file --
-- COPYING. If not, write to the Free Software Foundation, 59 Temple Place --
-- - Suite 330, Boston, MA 02111-1307, USA. --
-- --
-- --
-- --
-- --
-- --
-- --
-- --
-- --
-- ASIS-for-GNAT was originally developed by the ASIS-for-GNAT team at the --
-- Software Engineering Laboratory of the Swiss Federal Institute of --
-- Technology (LGL-EPFL) in Lausanne, Switzerland, in cooperation with the --
-- Scientific Research Computer Center of Moscow State University (SRCC --
-- MSU), Russia, with funding partially provided by grants from the Swiss --
-- National Science Foundation and the Swiss Academy of Engineering --
-- Sciences. ASIS-for-GNAT is now maintained by Ada Core Technologies Inc --
-- (http://www.gnat.com). --
-- --
------------------------------------------------------------------------------
with Asis.Set_Get; use Asis.Set_Get;
with A4G.A_Types; use A4G.A_Types;
with A4G.Contt; use A4G.Contt;
with Stand; use Stand;
with Atree; use Atree;
with Sinfo; use Sinfo;
package body A4G.Stand is
--------------------------------
-- Get_Numeric_Error_Renaming --
--------------------------------
function Get_Numeric_Error_Renaming return Asis.Element is
Result : Asis.Element := Numeric_Error_Template;
begin
Set_Encl_Tree (Result, Get_Current_Tree);
Set_Enclosing_Context (Result, Get_Current_Cont);
Set_Obtained (Result, A_OS_Time);
return Result;
end Get_Numeric_Error_Renaming;
---------------------------
-- Is_Standard_Char_Type --
---------------------------
function Is_Standard_Char_Type (N : Node_Id) return Boolean is
Result : Boolean := False;
Type_Ent : Entity_Id;
begin
if Sloc (N) = Standard_Location and then
Nkind (N) = N_Enumeration_Type_Definition
then
Type_Ent := Defining_Identifier (Parent (N));
if Type_Ent in Standard_Character .. Standard_Wide_Character then
Result := True;
end if;
end if;
return Result;
end Is_Standard_Char_Type;
-------------------------
-- Standard_Char_Decls --
-------------------------
function Standard_Char_Decls
(Type_Definition : Asis.Type_Definition;
Implicit : Boolean := False)
return Asis.Element_List
is
Arg_Node : constant Node_Id := Node (Type_Definition);
Rel_Len : Asis.ASIS_Positive;
Type_Ent : Entity_Id;
Tmp_Template : Element := Char_Literal_Spec_Template;
begin
-- Adjusting the template for the artificial character literal
-- specification:
Set_Encl_Unit_Id (Tmp_Template, Encl_Unit_Id (Type_Definition));
Set_Encl_Tree (Tmp_Template, Encl_Tree (Type_Definition));
Set_Node (Tmp_Template, Arg_Node);
Set_R_Node (Tmp_Template, Arg_Node);
Set_Enclosing_Context (Tmp_Template, Encl_Cont_Id (Type_Definition));
Set_Obtained (Tmp_Template, A_OS_Time);
Set_From_Instance (Tmp_Template, Is_From_Instance (Type_Definition));
Set_From_Implicit (Tmp_Template, Implicit);
Set_From_Inherited (Tmp_Template, Implicit);
if Implicit then
Set_Special_Case (Tmp_Template, Not_A_Special_Case);
Set_Node_Field_1 (Tmp_Template, Parent (Arg_Node));
end if;
Type_Ent := Defining_Identifier (Parent (Arg_Node));
while Type_Ent /= Etype (Type_Ent) loop
Type_Ent := Etype (Type_Ent);
end loop;
if Type_Ent = Standard_Character then
Rel_Len := 256;
else
Rel_Len := 65536;
end if;
declare
Result : Asis.Element_List (1 .. Rel_Len) := (others => Tmp_Template);
begin
for J in 1 .. Rel_Len loop
Set_Character_Code (Result (J), Char_Code (J - 1));
end loop;
return Result;
end;
end Standard_Char_Decls;
----------------------
-- Stand_Char_Image --
----------------------
function Stand_Char_Image (Code : Char_Code) return Wide_String is
function Hex_Digits (J : Natural) return Wide_String;
-- converts J into Hex digits string
function Hex_Digits (J : Natural) return Wide_String is
Hexd : constant Wide_String := "0123456789abcdef";
begin
if J > 16#FF# then
return Hex_Digits (J / 256) & Hex_Digits (J mod 256);
else
return Hexd (J / 16 + 1) & Hexd (J mod 16 + 1);
end if;
end Hex_Digits;
begin
if Code in 16#20# .. 16#7E# then
return ''' & Wide_Character'Val (Code) & ''';
else
return "'[""" & Hex_Digits (Natural (Code)) & """]'";
end if;
end Stand_Char_Image;
end A4G.Stand;
|
AdaCore/gpr | Ada | 1,797 | adb | --
-- Copyright (C) 2019-2023, AdaCore
--
-- SPDX-License-Identifier: Apache-2.0
--
with Ada.Text_IO;
with GPR2.Context;
with GPR2.Project.View;
with GPR2.Project.Tree;
with GPR2.Project.Attribute.Set;
with GPR2.Project.Variable.Set;
procedure Main is
use Ada;
use GPR2;
use GPR2.Project;
procedure Display (Prj : Project.View.Object);
procedure Changed_Callback (Prj : Project.View.Object);
----------------------
-- Changed_Callback --
----------------------
procedure Changed_Callback (Prj : Project.View.Object) is
begin
Text_IO.Put_Line (">>> Changed_Callback for " & String (Prj.Name));
end Changed_Callback;
-------------
-- Display --
-------------
procedure Display (Prj : Project.View.Object) is
use GPR2.Project.Attribute.Set;
use GPR2.Project.Variable.Set.Set;
begin
Text_IO.Put (String (Prj.Name) & " ");
Text_IO.Set_Col (10);
Text_IO.Put_Line (Prj.Qualifier'Img);
for A in Prj.Attributes (With_Defaults => False).Iterate loop
Text_IO.Put
("A: " & Image (Attribute.Set.Element (A).Name.Id.Attr));
Text_IO.Put (" ->");
for V of Element (A).Values loop
Text_IO.Put (" " & V.Text);
end loop;
Text_IO.New_Line;
end loop;
end Display;
Prj : Project.Tree.Object;
Ctx : Context.Object;
begin
Text_IO.Put_Line ("//// OS set to Linux");
Ctx.Include ("OS", "Linux");
Project.Tree.Load (Prj, Create ("demo.gpr"), Ctx);
for P of Prj loop
Display (P);
end loop;
Text_IO.Put_Line ("//// OS set to Windows");
Ctx := Prj.Context;
Ctx.Include ("OS", "Windows");
Prj.Set_Context (Ctx, Changed_Callback'Access);
for P of Prj loop
Display (P);
end loop;
end Main;
|
hergin/ada2fuml | Ada | 63 | ads | package Class1 is
type Class1 is null record;
end Class1; |
reznikmm/matreshka | Ada | 4,798 | ads | ------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- Open Document Toolkit --
-- --
-- Runtime Library Component --
-- --
------------------------------------------------------------------------------
-- --
-- Copyright © 2014, Vadim Godunko <[email protected]> --
-- All rights reserved. --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions --
-- are met: --
-- --
-- * Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- --
-- * Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in the --
-- documentation and/or other materials provided with the distribution. --
-- --
-- * Neither the name of the Vadim Godunko, IE nor the names of its --
-- contributors may be used to endorse or promote products derived from --
-- this software without specific prior written permission. --
-- --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR --
-- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
-- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED --
-- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR --
-- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF --
-- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING --
-- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS --
-- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
-- --
------------------------------------------------------------------------------
-- $Revision$ $Date$
------------------------------------------------------------------------------
with XML.DOM.Visitors;
with ODF.DOM.Office_Document_Styles_Elements;
package Matreshka.ODF_Office.Document_Styles_Elements is
type Office_Document_Styles_Element_Node is
new Matreshka.ODF_Office.Abstract_Office_Element_Node
and ODF.DOM.Office_Document_Styles_Elements.ODF_Office_Document_Styles
with null record;
overriding function Create
(Parameters : not null access Matreshka.DOM_Elements.Element_L2_Parameters)
return Office_Document_Styles_Element_Node;
overriding function Get_Local_Name
(Self : not null access constant Office_Document_Styles_Element_Node)
return League.Strings.Universal_String;
overriding procedure Enter_Node
(Self : not null access Office_Document_Styles_Element_Node;
Visitor : in out XML.DOM.Visitors.Abstract_Visitor'Class;
Control : in out XML.DOM.Visitors.Traverse_Control);
overriding procedure Leave_Node
(Self : not null access Office_Document_Styles_Element_Node;
Visitor : in out XML.DOM.Visitors.Abstract_Visitor'Class;
Control : in out XML.DOM.Visitors.Traverse_Control);
overriding procedure Visit_Node
(Self : not null access Office_Document_Styles_Element_Node;
Iterator : in out XML.DOM.Visitors.Abstract_Iterator'Class;
Visitor : in out XML.DOM.Visitors.Abstract_Visitor'Class;
Control : in out XML.DOM.Visitors.Traverse_Control);
end Matreshka.ODF_Office.Document_Styles_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_SpreadMethod_Attributes is
pragma Preelaborate;
type ODF_Svg_SpreadMethod_Attribute is limited interface
and XML.DOM.Attributes.DOM_Attribute;
type ODF_Svg_SpreadMethod_Attribute_Access is
access all ODF_Svg_SpreadMethod_Attribute'Class
with Storage_Size => 0;
end ODF.DOM.Svg_SpreadMethod_Attributes;
|
SayCV/rtems-addon-packages | Ada | 3,619 | adb | ------------------------------------------------------------------------------
-- --
-- GNAT ncurses Binding Samples --
-- --
-- Sample.Helpers --
-- --
-- B O D Y --
-- --
------------------------------------------------------------------------------
-- Copyright (c) 1998-2009,2011 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$
-- $Date$
-- Binding Version 01.00
------------------------------------------------------------------------------
with Sample.Explanation; use Sample.Explanation;
-- This package contains some convenient helper routines used throughout
-- this example.
--
package body Sample.Helpers is
procedure Window_Title (Win : Window;
Title : String)
is
Height : Line_Count;
Width : Column_Count;
Pos : Column_Position := 0;
begin
Get_Size (Win, Height, Width);
if Title'Length < Width then
Pos := (Width - Title'Length) / 2;
end if;
Add (Win, 0, Pos, Title);
end Window_Title;
procedure Not_Implemented is
begin
Explain ("NOTIMPL");
end Not_Implemented;
end Sample.Helpers;
|
francesco-bongiovanni/ewok-kernel | Ada | 20,310 | adb | --
-- Copyright 2018 The wookey project team <[email protected]>
-- - Ryad Benadjila
-- - Arnauld Michelizza
-- - Mathieu Renard
-- - Philippe Thierry
-- - Philippe Trebuchet
--
-- Licensed under the Apache License, Version 2.0 (the "License");
-- you may not use this file except in compliance with the License.
-- You may obtain a copy of the License at
--
-- http://www.apache.org/licenses/LICENSE-2.0
--
-- Unless required by applicable law or agreed to in writing, software
-- distributed under the License is distributed on an "AS IS" BASIS,
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-- See the License for the specific language governing permissions and
-- limitations under the License.
--
--
with ewok.perm; use ewok.perm;
with ewok.exported.devices; use ewok.exported.devices;
with ewok.exported.interrupts; use ewok.exported.interrupts;
with ewok.exported.gpios; use ewok.exported.gpios;
with ewok.interrupts; use ewok.interrupts;
with ewok.sanitize;
with ewok.gpio;
with ewok.mpu;
with ewok.exti;
with ewok.tasks; use ewok.tasks;
with soc.nvic;
with soc.gpio;
with soc.interrupts; use soc.interrupts;
with c.socinfo; use type c.socinfo.t_device_soc_infos_access;
with types.c;
with debug;
package body ewok.devices
with spark_mode => off
is
procedure init
is begin
for i in registered_device'range loop
registered_device(i).status := DEV_STATE_UNUSED;
registered_device(i).task_id := ID_UNUSED;
registered_device(i).devinfo := NULL;
-- FIXME initialize registered_device(i).udev with 0 values
end loop;
end init;
function get_task_from_id(dev_id : t_device_id)
return t_task_id
is
begin
return registered_device(dev_id).task_id;
end get_task_from_id;
function get_user_device (dev_id : t_device_id)
return ewok.exported.devices.t_user_device_access
is
begin
if dev_id = ID_DEV_UNUSED then
raise program_error;
end if;
return registered_device(dev_id).udev'access;
end get_user_device;
function get_user_device_size (dev_id : t_device_id)
return unsigned_16
is
begin
if dev_id = ID_DEV_UNUSED then
raise program_error;
end if;
return registered_device(dev_id).udev.size;
end get_user_device_size;
function get_user_device_addr (dev_id : t_device_id)
return system_address
is
begin
if dev_id = ID_DEV_UNUSED then
raise program_error;
end if;
return registered_device(dev_id).udev.base_addr;
end get_user_device_addr;
function is_user_device_region_ro (dev_id : t_device_id)
return boolean
is
begin
if dev_id = ID_DEV_UNUSED then
raise program_error;
end if;
return boolean (registered_device(dev_id).devinfo.all.ro);
end is_user_device_region_ro;
function get_user_device_subregions_mask (dev_id : t_device_id)
return unsigned_8
is
begin
if dev_id = ID_DEV_UNUSED then
raise program_error;
end if;
return registered_device(dev_id).devinfo.all.subregions;
end get_user_device_subregions_mask;
function get_interrupt_config_from_interrupt
(interrupt : soc.interrupts.t_interrupt)
return ewok.exported.interrupts.t_interrupt_config_access
is
dev_id : t_device_id;
begin
-- Retrieving the dev_id from the interrupt
dev_id := ewok.interrupts.get_device_from_interrupt (interrupt);
if dev_id = ID_DEV_UNUSED then
return NULL;
end if;
-- Looking at each interrupts configured for this device
-- to retrieve the proper interrupt configuration informations
for i in 1 .. registered_device(dev_id).udev.interrupt_num loop
if registered_device(dev_id).udev.interrupts(i).interrupt = interrupt
then
return registered_device(dev_id).udev.interrupts(i)'access;
end if;
end loop;
return NULL;
end get_interrupt_config_from_interrupt;
------------------------
-- Device registering --
------------------------
procedure get_registered_device_entry
(dev_id : out t_device_id;
success : out boolean)
is
begin
for id in registered_device'range loop
if registered_device(id).status = DEV_STATE_UNUSED then
registered_device(id).status := DEV_STATE_RESERVED;
dev_id := id;
success := true;
return;
end if;
end loop;
dev_id := ID_DEV_UNUSED;
success := false;
end get_registered_device_entry;
procedure release_registered_device_entry (dev_id : t_device_id)
is begin
registered_device(dev_id).status := DEV_STATE_UNUSED;
registered_device(dev_id).task_id := ID_UNUSED;
registered_device(dev_id).devinfo := NULL;
-- FIXME initialize registered_device(dev_id).udev with 0 values
end release_registered_device_entry;
procedure register_device
(task_id : in t_task_id;
udev : in ewok.exported.devices.t_user_device_access;
dev_id : out t_device_id;
success : out boolean)
is
devinfo : c.socinfo.t_device_soc_infos_access;
len : constant natural := types.c.len (udev.all.name);
name : string (1 .. len);
begin
-- Convert C name to Ada string type for further log messages
types.c.to_ada (name, udev.all.name);
-- Is it an existing device ?
-- Note: GPIOs (size = 0) are not considered as devices despite a task
-- can register them. Thus, we don't look for them in c.socinfo
-- table.
if udev.all.size /= 0 then
devinfo := c.socinfo.soc_devmap_find_device
(udev.all.base_addr, udev.all.size);
if devinfo = NULL then
debug.log (debug.WARNING, "Can't find device " & name & "(addr:" &
system_address'image (udev.all.base_addr) & ", size:" &
unsigned_16'image (udev.all.size) & ")");
success := false;
return;
end if;
end if;
-- Is it already used ?
-- Note: GPIOs alone are not considered as devices. When the user
-- declares lone GPIOs, devinfo is NULL
for id in registered_device'range loop
if registered_device(id).status /= DEV_STATE_UNUSED and then
registered_device(id).devinfo /= NULL and then
registered_device(id).devinfo = devinfo
then
debug.log (debug.WARNING, "Device " & name & " is already used");
success := false;
return;
end if;
end loop;
-- Are the GPIOs already used ?
for i in 1 .. udev.gpio_num loop
if ewok.gpio.is_used (udev.gpios(i).kref) then
debug.log (debug.WARNING,
"Device " & name & ": some GPIOs are already used");
success := false;
return;
end if;
end loop;
-- Are the related EXTIs already used ?
for i in 1 .. udev.gpio_num loop
if boolean (udev.gpios(i).settings.set_exti) and then
ewok.exti.is_used (udev.gpios(i).kref)
then
debug.log (debug.WARNING,
"Device " & name & ": some EXTIs are already used");
success := false;
return;
end if;
end loop;
-- Is it possible to register interrupt handlers ?
for i in 1 .. udev.interrupt_num loop
if ewok.interrupts.is_interrupt_already_used
(udev.interrupts(i).interrupt)
then
debug.log (debug.WARNING,
"Device " & name & ": some interrupts are already used");
success := false;
return;
end if;
end loop;
-- Is it possible to register a device ?
get_registered_device_entry (dev_id, success);
if not success then
debug.log (debug.WARNING,
"register_device(): no slot left to register the device");
return;
end if;
-- Registering the device
debug.log (debug.INFO, "Registered device " & name & " (0x" &
system_address'image (udev.all.base_addr) & ")");
registered_device(dev_id).udev := udev.all;
registered_device(dev_id).task_id := task_id;
registered_device(dev_id).is_mapped := false;
registered_device(dev_id).devinfo := devinfo;
registered_device(dev_id).status := DEV_STATE_REGISTERED;
-- Registering GPIOs
for i in 1 .. udev.gpio_num loop
ewok.gpio.register (task_id, dev_id, udev.gpios(i)'access, success);
if not success then
raise program_error;
end if;
debug.log (debug.INFO,
"Registered GPIO port" &
soc.gpio.t_gpio_port_index'image (udev.gpios(i).kref.port) &
" pin " &
soc.gpio.t_gpio_pin_index'image (udev.gpios(i).kref.pin));
end loop;
-- Registering EXTIs
for i in 1 .. udev.gpio_num loop
ewok.exti.register (udev.gpios(i)'access, success);
if not success then
raise program_error;
end if;
end loop;
-- Registering handlers
for i in 1 .. udev.interrupt_num loop
ewok.interrupts.set_interrupt_handler
(udev.interrupts(i).interrupt,
udev.interrupts(i).handler,
task_id,
dev_id,
success);
if not success then
raise program_error;
end if;
end loop;
success := true;
end register_device;
procedure enable_device
(dev_id : in t_device_id;
success : out boolean)
is
irq : soc.nvic.t_irq_index;
interrupt : t_interrupt;
begin
-- Check if the device was already configured
if registered_device(dev_id).status /= DEV_STATE_REGISTERED then
raise program_error;
end if;
-- Configure and enable GPIOs
for i in 1 .. registered_device(dev_id).udev.gpio_num loop
ewok.gpio.config (registered_device(dev_id).udev.gpios(i)'access);
if registered_device(dev_id).udev.gpios(i).exti_trigger /=
GPIO_EXTI_TRIGGER_NONE
then
ewok.exti.enable (registered_device(dev_id).udev.gpios(i).kref);
end if;
end loop;
-- For each interrupt, enable its associated IRQ in the NVIC
for i in 1 .. registered_device(dev_id).udev.interrupt_num loop
interrupt := registered_device(dev_id).udev.interrupts(i).interrupt;
irq := soc.nvic.to_irq_number (interrupt);
soc.nvic.enable_irq (irq);
debug.log (debug.INFO, "IRQ enabled" & soc.nvic.t_irq_index'image (irq) & " (int:"
& t_interrupt'image (interrupt) & ")");
end loop;
-- Enable device's clock
if registered_device(dev_id).devinfo /= NULL then
c.socinfo.soc_devmap_enable_clock (registered_device(dev_id).devinfo.all);
declare
udev : constant t_user_device := registered_device(dev_id).udev;
name : string (1 .. types.c.len (udev.name));
begin
types.c.to_ada (name, udev.name);
debug.log (debug.INFO, "Enabled device " & name);
end;
end if;
registered_device(dev_id).status := DEV_STATE_ENABLED;
if registered_device(dev_id).udev.map_mode = DEV_MAP_AUTO then
registered_device(dev_id).is_mapped := true;
end if;
success := true;
end enable_device;
function sanitize_user_defined_interrupt
(udev : in ewok.exported.devices.t_user_device_access;
config : in ewok.exported.interrupts.t_interrupt_config;
task_id : in t_task_id)
return boolean
is
begin
if not ewok.sanitize.is_word_in_txt_slot
(to_system_address (config.handler), task_id)
then
debug.log (debug.WARNING, "Device handler not in TXT slot");
return false;
end if;
if config.interrupt not in INT_WWDG .. INT_HASH_RNG
then
debug.log (debug.WARNING, "Device interrupt not in range");
return false;
end if;
if config.mode = ISR_FORCE_MAINTHREAD and then
not ewok.perm.ressource_is_granted (PERM_RES_TSK_FISR, task_id)
then
debug.log (debug.WARNING, "Device ISR_FORCE_MAINTHREAD not allowed");
return false;
end if;
--
-- Verify posthooks
--
for i in 1 .. MAX_POSTHOOK_INSTR loop
if not config.posthook.action(i).instr'valid then
debug.log (debug.WARNING,
"Device posthook: invalid action requested");
return false;
end if;
case config.posthook.action(i).instr is
when POSTHOOK_NIL => null;
when POSTHOOK_READ =>
if config.posthook.action(i).read.offset > udev.all.size - 4 or
(config.posthook.action(i).read.offset and 2#11#) > 0
then
debug.log (debug.WARNING,
"Device posthook: wrong READ offset");
return false;
end if;
when POSTHOOK_WRITE =>
if config.posthook.action(i).write.offset > udev.all.size - 4 or
(config.posthook.action(i).write.offset and 2#11#) > 0
then
debug.log (debug.WARNING,
"Device posthook: wrong WRITE offset");
return false;
end if;
when POSTHOOK_WRITE_REG =>
if config.posthook.action(i).write_reg.offset_dest >
udev.all.size - 4
or (config.posthook.action(i).write_reg.offset_dest and 2#11#)
> 0
or config.posthook.action(i).write_reg.offset_src >
udev.all.size - 4
or (config.posthook.action(i).write_reg.offset_src and 2#11#)
> 0
then
debug.log (debug.WARNING,
"Device posthook: wrong AND offset");
return false;
end if;
when POSTHOOK_WRITE_MASK =>
if config.posthook.action(i).write_mask.offset_dest >
udev.all.size - 4
or (config.posthook.action(i).write_mask.offset_dest and 2#11#)
> 0
or config.posthook.action(i).write_mask.offset_src >
udev.all.size - 4
or (config.posthook.action(i).write_mask.offset_src and 2#11#)
> 0
or config.posthook.action(i).write_mask.offset_mask >
udev.all.size - 4
or (config.posthook.action(i).write_mask.offset_mask and 2#11#)
> 0
then
debug.log (debug.WARNING,
"Device posthook: wrong MASK offset");
return false;
end if;
end case;
end loop;
return true;
end sanitize_user_defined_interrupt;
function sanitize_user_defined_gpio
(udev : in ewok.exported.devices.t_user_device_access;
config : in ewok.exported.gpios.t_gpio_config;
task_id : in t_task_id)
return boolean
is
pragma unreferenced (udev);
begin
if config.exti_trigger /= GPIO_EXTI_TRIGGER_NONE and then
not ewok.perm.ressource_is_granted (PERM_RES_DEV_EXTI, task_id)
then
debug.log (debug.WARNING, "Device PERM_RES_DEV_EXTI not allowed");
return false;
end if;
if config.exti_handler /= 0 and then
not ewok.sanitize.is_word_in_txt_slot (config.exti_handler, task_id)
then
debug.log (debug.WARNING, "Device EXTI handler not in TXT slot");
return false;
end if;
return true;
end sanitize_user_defined_gpio;
function sanitize_user_defined_device
(udev : in ewok.exported.devices.t_user_device_access;
task_id : in t_task_id)
return boolean
is
devinfo : c.socinfo.t_device_soc_infos_access;
ok : boolean;
len : constant natural := types.c.len (udev.all.name);
name : string (1 .. natural'min (t_device_name'length, len));
begin
if udev.all.name(t_device_name'last) /= ASCII.NUL then
types.c.to_ada (name, udev.all.name(1 .. t_device_name'length));
debug.log (debug.WARNING, "Out-of-bound device name: " & name);
return false;
else
types.c.to_ada (name, udev.all.name);
end if;
if udev.all.size /= 0 then
devinfo :=
c.socinfo.soc_devmap_find_device (udev.all.base_addr, udev.all.size);
if devinfo = NULL then
debug.log (debug.WARNING, "Device at addr" & system_address'image
(udev.all.base_addr) & " with size" & unsigned_16'image (udev.all.size) &
": not found");
return false;
end if;
if not ewok.perm.ressource_is_granted (devinfo.minperm, task_id) then
debug.log (debug.WARNING, "Task" & t_task_id'image (task_id) &
" has not access to device " & name);
return false;
end if;
end if;
for i in 1 .. udev.all.interrupt_num loop
ok := sanitize_user_defined_interrupt
(udev, udev.all.interrupts(i), task_id);
if not ok then
debug.log (debug.WARNING, "Device " & name & ": invalid udev.interrupts parameter");
return false;
end if;
end loop;
for i in 1 .. udev.all.gpio_num loop
ok := sanitize_user_defined_gpio (udev, udev.all.gpios(i), task_id);
if not ok then
debug.log (debug.WARNING, "Device " & name & ": invalid udev.gpios parameter");
return false;
end if;
end loop;
if udev.all.map_mode = DEV_MAP_VOLUNTARY then
if not ewok.perm.ressource_is_granted (PERM_RES_MEM_DYNAMIC_MAP, task_id) then
debug.log (debug.WARNING, "Task" & t_task_id'image (task_id) &
" voluntary mapped device " & name & " not permited");
return false;
end if;
end if;
return true;
end sanitize_user_defined_device;
-------------------------------------------------
-- Marking devices to be mapped in user memory --
-------------------------------------------------
procedure map_device
(dev_id : in t_device_id;
success : out boolean)
is
task_id : constant t_task_id := ewok.devices.get_task_from_id (dev_id);
task_a : constant t_task_access := ewok.tasks.get_task (task_id);
begin
-- The device is already mapped
if registered_device(dev_id).is_mapped then
success := true;
return;
end if;
-- We are physically limited by the number of regions
if task_a.all.num_devs_mmapped = ewok.mpu.MPU_MAX_EMPTY_REGIONS then
success := false;
return;
end if;
registered_device(dev_id).is_mapped := true;
task_a.all.num_devs_mmapped := task_a.all.num_devs_mmapped + 1;
success := true;
end map_device;
procedure unmap_device
(dev_id : in t_device_id;
success : out boolean)
is
task_id : constant t_task_id := ewok.devices.get_task_from_id (dev_id);
task_a : constant t_task_access := ewok.tasks.get_task (task_id);
begin
-- The device is already unmapped
if not registered_device(dev_id).is_mapped then
success := true;
return;
end if;
task_a.all.num_devs_mmapped := task_a.all.num_devs_mmapped - 1;
registered_device(dev_id).is_mapped := false;
success := true;
end unmap_device;
function is_mapped (dev_id : t_device_id)
return boolean
is
begin
if dev_id = ID_DEV_UNUSED then
raise program_error;
end if;
return registered_device(dev_id).is_mapped;
end is_mapped;
end ewok.devices;
|
reznikmm/matreshka | Ada | 4,949 | ads | ------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- Ada Modeling Framework --
-- --
-- Tools 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$
------------------------------------------------------------------------------
-- Diagram Manager handles creation/modification/destruction of diagrams in
-- model and reflect these changes in GUI components.
------------------------------------------------------------------------------
private with Ada.Containers.Hashed_Maps;
private with Qt4.Graphics_Views;
with Qt4.Mdi_Areas;
private with AMF.CMOF.Properties;
private with AMF.Elements;
with AMF.Listeners;
private with AMF.UMLDI.UML_Diagrams.Hash;
private with League.Holders;
package Modeler.Diagram_Managers is
type Diagram_Manager is
limited new AMF.Listeners.Abstract_Listener with private;
type Diagram_Manager_Access is access all Diagram_Manager'Class;
package Constructors is
function Create
(Central_Widget : Qt4.Mdi_Areas.Q_Mdi_Area_Access)
return not null Diagram_Manager_Access;
end Constructors;
private
package Diagram_Maps is
new Ada.Containers.Hashed_Maps
(AMF.UMLDI.UML_Diagrams.UMLDI_UML_Diagram_Access,
Qt4.Graphics_Views.Q_Graphics_View_Access,
AMF.UMLDI.UML_Diagrams.Hash,
AMF.UMLDI.UML_Diagrams."=",
Qt4.Graphics_Views."=");
type Diagram_Manager is
limited new AMF.Listeners.Abstract_Listener with
record
Central_Widget : Qt4.Mdi_Areas.Q_Mdi_Area_Access;
-- Central widget of main window.
Diagram_Map : Diagram_Maps.Map;
-- Map from UMLDiagram to QGraphivsView.
end record;
overriding procedure Instance_Create
(Self : not null access Diagram_Manager;
Element : not null AMF.Elements.Element_Access);
end Modeler.Diagram_Managers;
|
Fabien-Chouteau/lvgl-ada | Ada | 8,715 | ads | with Lv.Area;
with Lv.Style;
package Lv.Objx.Label is
subtype Instance is Obj_T;
Lv_Label_Dot_Num : constant := 3;
Lv_Label_Pos_Last : constant := 16#FFFF#;
type Long_Mode_T is (Long_Expand, -- Expand the object size to the text size
Long_Break, -- Keep the object width, break the too long lines and expand the object height
Long_Scroll, -- Expand the object size and scroll the text on the parent (move the label object)
Long_Dot, -- Keep the size and write dots at the end if the text is too long
Long_Roll, -- Keep the size and roll the text infinitely
Long_Crop); -- Keep the size and crop the text out of it
type Align_T is (Align_Left, Align_Center, Align_Right);
-- Create a label objects
-- @param par pointer to an object, it will be the parent of the new label
-- @param copy pointer to a button object, if not NULL then the new object will be copied from it
-- @return pointer to the created button
function Create (Par : Obj_T; Copy : Obj_T) return Instance;
----------------------
-- Setter functions --
----------------------
-- Set a new text for a label. Memory will be allocated to store the text by the label.
-- @param self pointer to a label object
-- @param text '\0' terminated character string. NULL to refresh with the current text.
procedure Set_Text (Self : Instance; Text : C_String_Ptr);
-- Set a new text for a label from a character array. The array don't has to be '\0' terminated.
-- Memory will be allocated to store the array by the label.
-- @param self pointer to a label object
-- @param array array of characters or NULL to refresh the label
-- @param size the size of 'array' in bytes
procedure Set_Array_Text
(Self : Instance;
Arr : C_String_Ptr;
Size : Uint16_T);
-- Set a static text. It will not be saved by the label so the 'text' variable
-- has to be 'alive' while the label exist.
-- @param self pointer to a label object
-- @param text pointer to a text. NULL to refresh with the current text.
procedure Set_Static_Text
(Self : Instance;
Text : C_String_Ptr);
-- Set the behavior of the label with longer text then the object size
-- @param self pointer to a label object
-- @param long_mode the new mode from 'lv_label_long_mode' enum.
-- In LV_LONG_BREAK/LONG/ROLL the size of the label should be set AFTER this function
procedure Set_Long_Mode (Self : Instance; Long_Mode : Long_Mode_T);
-- Set the align of the label (left or center)
-- @param self pointer to a label object
-- @param align 'LV_LABEL_ALIGN_LEFT' or 'LV_LABEL_ALIGN_LEFT'
procedure Set_Align (Self : Instance; Align : Align_T);
-- Enable the recoloring by in-line commands
-- @param self pointer to a label object
-- @param recolor_en true: enable recoloring, false: disable
procedure Set_Recolor (Self : Instance; Recolor_En : U_Bool);
-- Set the label to draw (or not draw) background specified in its style's body
-- @param self pointer to a label object
-- @param body_en true: draw body; false: don't draw body
procedure Set_Body_Draw (Self : Instance; Body_En : U_Bool);
-- Set the label's animation speed in LV_LABEL_LONG_ROLL and SCROLL modes
-- @param self pointer to a label object
-- @param anim_speed speed of animation in px/sec unit
procedure Set_Anim_Speed (Self : Instance; Anim_Speed : Uint16_T);
-- Set the style of an label
-- @param self pointer to an label object
-- @param style pointer to a style
procedure Set_Style (Self : Instance; Style : Lv.Style.Style);
----------------------
-- Getter functions --
----------------------
-- Get the text of a label
-- @param self pointer to a label object
-- @return the text of the label
function Text (Self : Instance) return C_String_Ptr;
-- Get the long mode of a label
-- @param self pointer to a label object
-- @return the long mode
function Long_Mode (Self : Instance) return Long_Mode_T;
-- Get the align attribute
-- @param self pointer to a label object
-- @return LV_LABEL_ALIGN_LEFT or LV_LABEL_ALIGN_CENTER
function Align (Self : Instance) return Align_T;
-- Get the recoloring attribute
-- @param self pointer to a label object
-- @return true: recoloring is enabled, false: disable
function Recolor (Self : Instance) return U_Bool;
-- Get the body draw attribute
-- @param self pointer to a label object
-- @return true: draw body; false: don't draw body
function Body_Draw (Self : Instance) return U_Bool;
-- Get the label's animation speed in LV_LABEL_LONG_ROLL and SCROLL modes
-- @param self pointer to a label object
-- @return speed of animation in px/sec unit
function Anim_Speed (Self : Instance) return Uint16_T;
-- Get the relative x and y coordinates of a letter
-- @param self pointer to a label object
-- @param index index of the letter [0 ... text length]. Expressed in character index, not byte index (different in UTF-8)
-- @param pos store the result here (E.g. index = 0 gives 0;0 coordinates)
procedure Letter_Pos
(Self : Instance;
Index : Uint16_T;
Pos : access Lv.Area.Point_T);
-- Get the index of letter on a relative point of a label
-- @param self pointer to label object
-- @param pos pointer to point with coordinates on a the label
-- @return the index of the letter on the 'pos_p' point (E.g. on 0;0 is the 0. letter)
-- Expressed in character index and not byte index (different in UTF-8)
function Letter_On
(Self : Instance;
Pos : access Lv.Area.Point_T) return Uint16_T;
-- Get the style of an label object
-- @param self pointer to an label object
-- @return pointer to the label's style
function Style (Self : Instance) return Lv.Style.Style;
---------------------
-- Other functions --
---------------------
-- Insert a text to the label. The label text can not be static.
-- @param self pointer to a label object
-- @param pos character index to insert. Expressed in character index and not byte index (Different in UTF-8)
-- 0: before first char.
-- LV_LABEL_POS_LAST: after last char.
-- @param txt pointer to the text to insert
procedure Ins_Text
(Self : Instance;
Pos : Uint32_T;
Txt : C_String_Ptr);
-- Delete characters from a label. The label text can not be static.
-- @param self pointer to a label object
-- @param pos character index to insert. Expressed in character index and not byte index (Different in UTF-8)
-- 0: before first char.
-- @param cnt number of characters to cut
procedure Cut_Text (Self : Instance; Pos : Uint32_T; Cnt : Uint32_T);
-------------
-- Imports --
-------------
pragma Import (C, Create, "lv_label_create");
pragma Import (C, Set_Text, "lv_label_set_text");
pragma Import (C, Set_Array_Text, "lv_label_set_array_text");
pragma Import (C, Set_Static_Text, "lv_label_set_static_text");
pragma Import (C, Set_Long_Mode, "lv_label_set_long_mode");
pragma Import (C, Set_Align, "lv_label_set_align");
pragma Import (C, Set_Recolor, "lv_label_set_recolor");
pragma Import (C, Set_Body_Draw, "lv_label_set_body_draw");
pragma Import (C, Set_Anim_Speed, "lv_label_set_anim_speed");
pragma Import (C, Set_Style, "lv_label_set_style_inline");
pragma Import (C, Text, "lv_label_get_text");
pragma Import (C, Long_Mode, "lv_label_get_long_mode");
pragma Import (C, Align, "lv_label_get_align");
pragma Import (C, Recolor, "lv_label_get_recolor");
pragma Import (C, Body_Draw, "lv_label_get_body_draw");
pragma Import (C, Anim_Speed, "lv_label_get_anim_speed");
pragma Import (C, Letter_Pos, "lv_label_get_letter_pos");
pragma Import (C, Letter_On, "lv_label_get_letter_on");
pragma Import (C, Style, "lv_label_get_style_inline");
pragma Import (C, Ins_Text, "lv_label_ins_text");
pragma Import (C, Cut_Text, "lv_label_cut_text");
for Long_Mode_T'Size use 8;
for Long_Mode_T use (Long_Expand => 0,
Long_Break => 1,
Long_Scroll => 2,
Long_Dot => 3,
Long_Roll => 4,
Long_Crop => 5);
for Align_T'Size use 8;
for Align_T use (Align_Left => 0,
Align_Center => 1,
Align_Right => 2);
end Lv.Objx.Label;
|
gusthoff/ada_wavefiles_gtk_app | Ada | 78 | ads |
package WaveFiles_Gtk.Menu is
procedure Create;
end WaveFiles_Gtk.Menu;
|
ekoeppen/STM32_Generic_Ada_Drivers | Ada | 433 | adb | with Ada.Real_Time; use Ada.Real_Time;
with STM32GD.Board; use STM32GD.Board;
with STM32GD.SCB;
procedure Main is
Next_Release : Time := Clock;
Period : constant Time_Span := Milliseconds (500);
begin
Init;
LED.Set;
Text_IO.Put_Line ("Starting");
loop
Text_IO.Put_Line ("Waiting");
Next_Release := Next_Release + Period;
delay until Next_Release;
LED.Toggle;
end loop;
end Main;
|
reznikmm/matreshka | Ada | 4,001 | ads | ------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- Open Document Toolkit --
-- --
-- Runtime Library Component --
-- --
------------------------------------------------------------------------------
-- --
-- Copyright © 2014, Vadim Godunko <[email protected]> --
-- All rights reserved. --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions --
-- are met: --
-- --
-- * Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- --
-- * Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in the --
-- documentation and/or other materials provided with the distribution. --
-- --
-- * Neither the name of the Vadim Godunko, IE nor the names of its --
-- contributors may be used to endorse or promote products derived from --
-- this software without specific prior written permission. --
-- --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR --
-- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
-- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED --
-- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR --
-- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF --
-- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING --
-- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS --
-- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
-- --
------------------------------------------------------------------------------
-- $Revision$ $Date$
------------------------------------------------------------------------------
with ODF.DOM.Meta_Word_Count_Attributes;
package Matreshka.ODF_Meta.Word_Count_Attributes is
type Meta_Word_Count_Attribute_Node is
new Matreshka.ODF_Meta.Abstract_Meta_Attribute_Node
and ODF.DOM.Meta_Word_Count_Attributes.ODF_Meta_Word_Count_Attribute
with null record;
overriding function Create
(Parameters : not null access Matreshka.DOM_Attributes.Attribute_L2_Parameters)
return Meta_Word_Count_Attribute_Node;
overriding function Get_Local_Name
(Self : not null access constant Meta_Word_Count_Attribute_Node)
return League.Strings.Universal_String;
end Matreshka.ODF_Meta.Word_Count_Attributes;
|
AdaCore/Ada_Drivers_Library | Ada | 18,961 | adb | ------------------------------------------------------------------------------
-- --
-- Copyright (C) 2016-2020, AdaCore --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions are --
-- met: --
-- 1. Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- 2. Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in --
-- the documentation and/or other materials provided with the --
-- distribution. --
-- 3. Neither the name of the copyright holder nor the names of its --
-- contributors may be used to endorse or promote products derived --
-- from this software without specific prior written permission. --
-- --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR --
-- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
-- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT --
-- LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, --
-- DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY --
-- THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT --
-- (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE --
-- OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
-- --
------------------------------------------------------------------------------
with HAL; use HAL;
with nRF.GPIO; use nRF.GPIO;
with nRF.Device; use nRF.Device;
with MicroBit.Time; use MicroBit.Time;
with System.Machine_Code; use System.Machine_Code;
package body MicroBit.Display is
type Animation_Mode is (None, Scroll_Text);
Animation_Step_Duration_Ms : Natural := 200;
-- How many milliseconds between two animation steps
Animation_Elapsed : Natural := 0;
-- How many milliseconds since the last animation step
Animation_State : Animation_Mode := None;
-- Current animation
subtype Width is Natural range
Coord'First .. Coord'First + Coord'Range_Length * 2;
Bitmap : array (Width, Coord) of Boolean := (others => (others => False));
-- The bitmap width is 2 time the display size so we can instert hidden
-- characters to the right of the screen and scroll them in with the
-- Shift_Left procedure.
Current_X, Current_Y : Coord := 0;
-- Current coordinate in LED matrix scan
----------------------
-- Pixel to IO Pins --
----------------------
subtype Row_Range is Natural range 1 .. 3;
subtype Column_Range is Natural range 1 .. 9;
type LED_Point is record
Row_Id : Row_Range;
Column_Id : Column_Range;
end record;
Row_Points : array (Row_Range) of GPIO_Point :=
(P13, P14, P15);
Column_Points : array (Column_Range) of GPIO_Point :=
(P04, P05, P06, P07, P08, P09, P10, P11, P12);
Map : constant array (Coord, Coord) of LED_Point :=
(((1, 1), (3, 4), (2, 2), (1, 8), (3, 3)),
((2, 4), (3, 5), (1, 9), (1, 7), (2, 7)),
((1, 2), (3, 6), (2, 3), (1, 6), (3, 1)),
((2, 5), (3, 7), (3, 9), (1, 5), (2, 6)),
((1, 3), (3, 8), (2, 1), (1, 4), (3, 2))
);
--
--------------------
-- Text scrolling --
--------------------
Scroll_Text_Buffer : String (1 .. Scroll_Text_Max_Length) :=
(others => ASCII.NUL);
-- Buffer to stored the scroll text
Scroll_Text_Length : Natural := 0;
-- Length of the text stored in the Scroll_Text_Buffer
Scroll_Text_Index : Natural := 0;
-- Index of the character to display next
Scroll_Position : Natural := 0;
-- Scroll position in the screen
----------
-- Font --
----------
type Glyph is array (0 .. 4) of UInt5;
Font : constant array (0 .. 93) of Glyph :=
((2#00100#, -- !
2#00100#,
2#00100#,
2#00000#,
2#00100#),
(2#01010#, -- "
2#01010#,
2#00000#,
2#00000#,
2#00000#),
(2#01010#, -- #
2#11111#,
2#01010#,
2#11111#,
2#01010#),
(2#11110#, -- $
2#00101#,
2#01110#,
2#00100#,
2#01111#),
(2#10001#, -- %
2#01000#,
2#00100#,
2#00010#,
2#10001#),
(2#00100#, -- &
2#01010#,
2#00100#,
2#01010#,
2#10100#),
(2#01000#, -- '
2#00100#,
2#00000#,
2#00000#,
2#00000#),
(2#01000#, -- (
2#00100#,
2#00100#,
2#00100#,
2#01000#),
(2#00010#, -- )
2#00100#,
2#00100#,
2#00100#,
2#00010#),
(2#00000#, -- *
2#00100#,
2#01010#,
2#00100#,
2#00000#),
(2#00000#, -- +
2#00100#,
2#01110#,
2#00100#,
2#00000#),
(2#00000#, -- ,
2#00000#,
2#00000#,
2#00100#,
2#00010#),
(2#00000#, -- -
2#00000#,
2#01110#,
2#00000#,
2#00000#),
(2#00000#, -- .
2#00000#,
2#00000#,
2#00000#,
2#00010#),
(2#10000#, -- /
2#01000#,
2#00100#,
2#00010#,
2#00001#),
(2#01110#, -- 0
2#10001#,
2#10001#,
2#10001#,
2#01110#),
(2#00100#, -- 1
2#00110#,
2#00100#,
2#00100#,
2#00100#),
(2#01110#, -- 2
2#10001#,
2#01000#,
2#00100#,
2#11111#),
(2#01111#, -- 3
2#10000#,
2#01111#,
2#10000#,
2#01111#),
(2#01000#, -- 4
2#01010#,
2#01001#,
2#11111#,
2#01000#),
(2#11111#, -- 5
2#00001#,
2#01111#,
2#10000#,
2#01111#),
(2#01110#, -- 6
2#00001#,
2#00111#,
2#01001#,
2#01110#),
(2#01110#, -- 7
2#01000#,
2#00100#,
2#00100#,
2#00100#),
(2#01110#, -- 8
2#10001#,
2#01110#,
2#10001#,
2#01110#),
(2#01110#, -- 9
2#10001#,
2#11110#,
2#10000#,
2#01110#),
(2#00000#, -- :
2#00100#,
2#00000#,
2#00100#,
2#00000#),
(2#00000#, -- ;
2#00100#,
2#00000#,
2#00100#,
2#00010#),
(2#00000#, -- <
2#00100#,
2#00010#,
2#00100#,
2#00000#),
(2#00000#, -- =
2#01110#,
2#00000#,
2#01110#,
2#00000#),
(2#00000#, -- >
2#00100#,
2#01000#,
2#00100#,
2#00000#),
(2#00100#, -- ?
2#01000#,
2#00100#,
2#00000#,
2#00100#),
(2#01110#, -- @
2#10001#,
2#10101#,
2#10001#,
2#00110#),
(2#01110#, -- A
2#10001#,
2#11111#,
2#10001#,
2#10001#),
(2#01111#, -- B
2#10001#,
2#01111#,
2#10001#,
2#01111#),
(2#11110#, -- C
2#00001#,
2#00001#,
2#00001#,
2#11110#),
(2#01111#, -- D
2#10001#,
2#10001#,
2#10001#,
2#01111#),
(2#11111#, -- E
2#00001#,
2#00111#,
2#00001#,
2#11111#),
(2#11111#, -- F
2#00001#,
2#00111#,
2#00001#,
2#00001#),
(2#11110#, -- G
2#00001#,
2#11101#,
2#10001#,
2#01110#),
(2#10001#, -- H
2#10001#,
2#11111#,
2#10001#,
2#10001#),
(2#00100#, -- I
2#00100#,
2#00100#,
2#00100#,
2#00100#),
(2#10000#, -- J
2#10000#,
2#10000#,
2#10001#,
2#01110#),
(2#01001#, -- K
2#00101#,
2#00011#,
2#00101#,
2#01001#),
(2#00001#, -- L
2#00001#,
2#00001#,
2#00001#,
2#11111#),
(2#10001#, -- M
2#11011#,
2#10101#,
2#10001#,
2#10001#),
(2#10001#, -- N
2#10011#,
2#10101#,
2#11001#,
2#10001#),
(2#01110#, -- O
2#10001#,
2#10001#,
2#10001#,
2#01110#),
(2#01111#, -- P
2#10001#,
2#01111#,
2#00001#,
2#00001#),
(2#01110#, -- Q
2#10001#,
2#10001#,
2#11001#,
2#11110#),
(2#01111#, -- R
2#10001#,
2#01111#,
2#01001#,
2#10001#),
(2#11110#, -- S
2#00001#,
2#01110#,
2#10000#,
2#01111#),
(2#11111#, -- T
2#00100#,
2#00100#,
2#00100#,
2#00100#),
(2#10001#, -- U
2#10001#,
2#10001#,
2#10001#,
2#01110#),
(2#10001#, -- V
2#10001#,
2#01010#,
2#01010#,
2#00100#),
(2#10101#, -- W
2#10101#,
2#10101#,
2#01010#,
2#01010#),
(2#10001#, -- X
2#01010#,
2#00100#,
2#01010#,
2#10001#),
(2#10001#, -- Y
2#01010#,
2#00100#,
2#00100#,
2#00100#),
(2#11111#, -- Z
2#01000#,
2#00100#,
2#00010#,
2#11111#),
(2#01110#, -- [
2#00010#,
2#00010#,
2#00010#,
2#01110#),
(2#00001#, -- \
2#00010#,
2#00100#,
2#01000#,
2#10000#),
(2#01110#, -- ]
2#01000#,
2#01000#,
2#01000#,
2#01110#),
(2#00100#, -- ^
2#01010#,
2#10001#,
2#00000#,
2#00000#),
(2#00000#, -- _
2#00000#,
2#00000#,
2#00000#,
2#11111#),
(2#00010#, -- `
2#00100#,
2#00000#,
2#00000#,
2#00000#),
(2#01111#, -- a
2#10000#,
2#11110#,
2#10001#,
2#11110#),
(2#00001#, -- b
2#01111#,
2#10001#,
2#10001#,
2#01111#),
(2#01110#, -- c
2#10001#,
2#00001#,
2#10001#,
2#01110#),
(2#10000#, -- d
2#11110#,
2#10001#,
2#10001#,
2#11110#),
(2#01110#, -- e
2#10001#,
2#11111#,
2#00001#,
2#11110#),
(2#11110#, -- f
2#00001#,
2#00111#,
2#00001#,
2#00001#),
(2#01110#, -- g
2#10001#,
2#11110#,
2#10000#,
2#01111#),
(2#00001#, -- h
2#01111#,
2#10001#,
2#10001#,
2#10001#),
(2#00100#, -- i
2#00000#,
2#00100#,
2#00100#,
2#00100#),
(2#10000#, -- j
2#10000#,
2#10000#,
2#10000#,
2#01111#),
(2#10001#, -- k
2#01001#,
2#00111#,
2#01001#,
2#10001#),
(2#00001#, -- l
2#00001#,
2#00001#,
2#00001#,
2#11110#),
(2#01010#, -- m
2#10101#,
2#10101#,
2#10101#,
2#10101#),
(2#01111#, -- n
2#10001#,
2#10001#,
2#10001#,
2#10001#),
(2#01110#, -- o
2#10001#,
2#10001#,
2#10001#,
2#01110#),
(2#01111#, -- p
2#10001#,
2#10001#,
2#01111#,
2#00001#),
(2#11110#, -- q
2#10001#,
2#10001#,
2#11110#,
2#10000#),
(2#01101#, -- r
2#10011#,
2#00001#,
2#00001#,
2#00001#),
(2#11110#, -- s
2#00001#,
2#01110#,
2#10000#,
2#01111#),
(2#00001#, -- t
2#00111#,
2#00001#,
2#10001#,
2#01110#),
(2#10001#, -- u
2#10001#,
2#10001#,
2#11001#,
2#10110#),
(2#10001#, -- v
2#10001#,
2#01010#,
2#01010#,
2#00100#),
(2#10101#, -- w
2#10101#,
2#10101#,
2#10101#,
2#01010#),
(2#10001#, -- x
2#10001#,
2#01110#,
2#10001#,
2#10001#),
(2#10001#, -- y
2#10001#,
2#11110#,
2#10000#,
2#01111#),
(2#11111#, -- z
2#01000#,
2#00100#,
2#00010#,
2#11111#),
(2#00100#, -- {
2#00100#,
2#00010#,
2#00100#,
2#00100#),
(2#00100#, -- |
2#00100#,
2#00100#,
2#00100#,
2#00100#),
(2#00100#, -- }
2#00100#,
2#01000#,
2#00100#,
2#00100#),
(2#00000#, -- ~
2#00000#,
2#01010#,
2#10101#,
2#00000#)
);
procedure Print_C (X_Org : Width;
C : Character);
procedure Initialize;
procedure Tick_Handler;
procedure Update_Animation;
-------------
-- Print_C --
-------------
procedure Print_C (X_Org : Width;
C : Character)
is
C_Index : constant Integer := Character'Pos (C) - Character'Pos ('!');
begin
if C_Index not in Font'Range then
return;
end if;
for X in Coord loop
for Y in Coord loop
if X_Org + X in Width then
if (Font (C_Index) (Y) and 2**X) /= 0 then
Bitmap (X_Org + X, Y) := True;
end if;
end if;
end loop;
end loop;
end Print_C;
----------------
-- Initialize --
----------------
procedure Initialize is
Conf : GPIO_Configuration;
begin
Conf.Mode := Mode_Out;
Conf.Resistors := Pull_Up;
for Point of Row_Points loop
Point.Configure_IO (Conf);
Point.Clear;
end loop;
for Point of Column_Points loop
Point.Configure_IO (Conf);
Point.Set;
end loop;
if not Tick_Subscribe (Tick_Handler'Access) then
raise Program_Error;
end if;
end Initialize;
------------------
-- Tick_Handler --
------------------
procedure Tick_Handler is
begin
-- Turn Off
-- Row source current
Row_Points (Map (Current_X, Current_Y).Row_Id).Clear;
-- Column sink current
Column_Points (Map (Current_X, Current_Y).Column_Id).Set;
if Current_X = Coord'Last then
Current_X := Coord'First;
if Current_Y = Coord'Last then
Current_Y := Coord'First;
else
Current_Y := Current_Y + 1;
end if;
else
Current_X := Current_X + 1;
end if;
-- Turn on?
if Bitmap (Current_X, Current_Y) then
-- Row source current
Row_Points (Map (Current_X, Current_Y).Row_Id).Set;
-- Column sink current
Column_Points (Map (Current_X, Current_Y).Column_Id).Clear;
end if;
-- Animation
if Animation_Elapsed = Animation_Step_Duration_Ms then
Animation_Elapsed := 0;
Update_Animation;
else
Animation_Elapsed := Animation_Elapsed + 1;
end if;
end Tick_Handler;
----------------------
-- Update_Animation --
----------------------
procedure Update_Animation is
begin
case Animation_State is
when None =>
null;
when Scroll_Text =>
Shift_Left;
Scroll_Position := Scroll_Position + 1;
if Scroll_Position >= Coord'Range_Length + 1 then
-- We finished scrolling the current character
Scroll_Position := 0;
if Scroll_Text_Index > Scroll_Text_Length + 1 then
Animation_State := None;
elsif Scroll_Text_Index = Scroll_Text_Length + 1 then
null; -- Leave the screen empty until the character is flushed
else
-- Print new char
Print_C (5, Scroll_Text_Buffer (Scroll_Text_Index));
end if;
Scroll_Text_Index := Scroll_Text_Index + 1;
end if;
end case;
end Update_Animation;
---------
-- Set --
---------
procedure Set (X, Y : Coord) is
begin
Bitmap (X, Y) := True;
end Set;
-----------
-- Clear --
-----------
procedure Clear (X, Y : Coord) is
begin
Bitmap (X, Y) := False;
end Clear;
-----------
-- Clear --
-----------
procedure Clear is
begin
Bitmap := (others => (others => False));
end Clear;
-------------
-- Display --
-------------
procedure Display (C : Character) is
begin
Print_C (0, C);
end Display;
-------------
-- Display --
-------------
procedure Display (Str : String) is
begin
Display_Async (Str);
while Animation_State /= None loop
Asm (Template => "wfi", -- Wait for interrupt
Volatile => True);
end loop;
end Display;
-------------------
-- Display_Async --
-------------------
procedure Display_Async (Str : String) is
begin
Scroll_Text_Buffer (Scroll_Text_Buffer'First .. Scroll_Text_Buffer'First + Str'Length - 1) := Str;
Animation_State := Scroll_Text;
Scroll_Text_Length := Str'Length;
Scroll_Text_Index := Scroll_Text_Buffer'First;
Scroll_Position := Coord'Last + 1;
end Display_Async;
----------------
-- Shift_Left --
----------------
procedure Shift_Left is
begin
-- Shift pixel columns to the left, erasing the left most one
for X in Bitmap'First (1) .. Bitmap'Last (1) - 1 loop
for Y in Bitmap'Range (2) loop
Bitmap (X, Y) := Bitmap (X + 1, Y);
end loop;
end loop;
-- Insert black pixels to the right most column
for Y in Bitmap'Range (2) loop
Bitmap (Bitmap'Last (1), Y) := False;
end loop;
end Shift_Left;
---------------------------------
-- Set_Animation_Step_Duration --
---------------------------------
procedure Set_Animation_Step_Duration (Ms : Natural) is
begin
Animation_Step_Duration_Ms := Ms;
end Set_Animation_Step_Duration;
---------------------------
-- Animation_In_Progress --
---------------------------
function Animation_In_Progress return Boolean
is (Animation_State /= None);
begin
Initialize;
end MicroBit.Display;
|
zhmu/ananas | Ada | 151 | adb | -- { dg-do compile }
package body Forward_Anon is
function Get_Current return access Object is
begin
return Current_Object;
end;
end;
|
datacomo-dm/DMCloud | Ada | 13,605 | ads | ------------------------------------------------------------------------------
-- ZLib for Ada thick binding. --
-- --
-- Copyright (C) 2002-2004 Dmitriy Anisimkov --
-- --
-- This library is free software; you can redistribute it and/or modify --
-- it under the terms of the GNU General Public License as published by --
-- the Free Software Foundation; either version 2 of the License, or (at --
-- your option) any later version. --
-- --
-- This library is distributed in the hope that it will be useful, but --
-- WITHOUT ANY WARRANTY; without even the implied warranty of --
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU --
-- General Public License for more details. --
-- --
-- You should have received a copy of the GNU General Public License --
-- along with this library; if not, write to the Free Software Foundation, --
-- Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. --
-- --
-- As a special exception, if other files instantiate generics from this --
-- unit, or you link this unit with other files to produce an executable, --
-- this unit does not by itself cause the resulting executable to be --
-- covered by the GNU General Public License. This exception does not --
-- however invalidate any other reasons why the executable file might be --
-- covered by the GNU Public License. --
------------------------------------------------------------------------------
-- $Id: zlib.ads,v 1.1.1.1 2004/09/06 06:53:20 Administrator Exp $
with Ada.Streams;
with Interfaces;
package ZLib is
ZLib_Error : exception;
Status_Error : exception;
type Compression_Level is new Integer range -1 .. 9;
type Flush_Mode is private;
type Compression_Method is private;
type Window_Bits_Type is new Integer range 8 .. 15;
type Memory_Level_Type is new Integer range 1 .. 9;
type Unsigned_32 is new Interfaces.Unsigned_32;
type Strategy_Type is private;
type Header_Type is (None, Auto, Default, GZip);
-- Header type usage have a some limitation for inflate.
-- See comment for Inflate_Init.
subtype Count is Ada.Streams.Stream_Element_Count;
Default_Memory_Level : constant Memory_Level_Type := 8;
Default_Window_Bits : constant Window_Bits_Type := 15;
----------------------------------
-- Compression method constants --
----------------------------------
Deflated : constant Compression_Method;
-- Only one method allowed in this ZLib version
---------------------------------
-- Compression level constants --
---------------------------------
No_Compression : constant Compression_Level := 0;
Best_Speed : constant Compression_Level := 1;
Best_Compression : constant Compression_Level := 9;
Default_Compression : constant Compression_Level := -1;
--------------------------
-- Flush mode constants --
--------------------------
No_Flush : constant Flush_Mode;
-- Regular way for compression, no flush
Partial_Flush : constant Flush_Mode;
-- Will be removed, use Z_SYNC_FLUSH instead
Sync_Flush : constant Flush_Mode;
-- All pending output is flushed to the output buffer and the output
-- is aligned on a byte boundary, so that the decompressor can get all
-- input data available so far. (In particular avail_in is zero after the
-- call if enough output space has been provided before the call.)
-- Flushing may degrade compression for some compression algorithms and so
-- it should be used only when necessary.
Block_Flush : constant Flush_Mode;
-- Z_BLOCK requests that inflate() stop
-- if and when it get to the next deflate block boundary. When decoding the
-- zlib or gzip format, this will cause inflate() to return immediately
-- after the header and before the first block. When doing a raw inflate,
-- inflate() will go ahead and process the first block, and will return
-- when it gets to the end of that block, or when it runs out of data.
Full_Flush : constant Flush_Mode;
-- All output is flushed as with SYNC_FLUSH, and the compression state
-- is reset so that decompression can restart from this point if previous
-- compressed data has been damaged or if random access is desired. Using
-- Full_Flush too often can seriously degrade the compression.
Finish : constant Flush_Mode;
-- Just for tell the compressor that input data is complete.
------------------------------------
-- Compression strategy constants --
------------------------------------
-- RLE stategy could be used only in version 1.2.0 and later.
Filtered : constant Strategy_Type;
Huffman_Only : constant Strategy_Type;
RLE : constant Strategy_Type;
Default_Strategy : constant Strategy_Type;
Default_Buffer_Size : constant := 4096;
type Filter_Type is tagged limited private;
-- The filter is for compression and for decompression.
-- The usage of the type is depend of its initialization.
function Version return String;
pragma Inline (Version);
-- Return string representation of the ZLib version.
procedure Deflate_Init
(Filter : in out Filter_Type;
Level : in Compression_Level := Default_Compression;
Strategy : in Strategy_Type := Default_Strategy;
Method : in Compression_Method := Deflated;
Window_Bits : in Window_Bits_Type := Default_Window_Bits;
Memory_Level : in Memory_Level_Type := Default_Memory_Level;
Header : in Header_Type := Default);
-- Compressor initialization.
-- When Header parameter is Auto or Default, then default zlib header
-- would be provided for compressed data.
-- When Header is GZip, then gzip header would be set instead of
-- default header.
-- When Header is None, no header would be set for compressed data.
procedure Inflate_Init
(Filter : in out Filter_Type;
Window_Bits : in Window_Bits_Type := Default_Window_Bits;
Header : in Header_Type := Default);
-- Decompressor initialization.
-- Default header type mean that ZLib default header is expecting in the
-- input compressed stream.
-- Header type None mean that no header is expecting in the input stream.
-- GZip header type mean that GZip header is expecting in the
-- input compressed stream.
-- Auto header type mean that header type (GZip or Native) would be
-- detected automatically in the input stream.
-- Note that header types parameter values None, GZip and Auto are
-- supported for inflate routine only in ZLib versions 1.2.0.2 and later.
-- Deflate_Init is supporting all header types.
function Is_Open (Filter : in Filter_Type) return Boolean;
pragma Inline (Is_Open);
-- Is the filter opened for compression or decompression.
procedure Close
(Filter : in out Filter_Type;
Ignore_Error : in Boolean := False);
-- Closing the compression or decompressor.
-- If stream is closing before the complete and Ignore_Error is False,
-- The exception would be raised.
generic
with procedure Data_In
(Item : out Ada.Streams.Stream_Element_Array;
Last : out Ada.Streams.Stream_Element_Offset);
with procedure Data_Out
(Item : in Ada.Streams.Stream_Element_Array);
procedure Generic_Translate
(Filter : in out Filter_Type;
In_Buffer_Size : in Integer := Default_Buffer_Size;
Out_Buffer_Size : in Integer := Default_Buffer_Size);
-- Compress/decompress data fetch from Data_In routine and pass the result
-- to the Data_Out routine. User should provide Data_In and Data_Out
-- for compression/decompression data flow.
-- Compression or decompression depend on Filter initialization.
function Total_In (Filter : in Filter_Type) return Count;
pragma Inline (Total_In);
-- Returns total number of input bytes read so far
function Total_Out (Filter : in Filter_Type) return Count;
pragma Inline (Total_Out);
-- Returns total number of bytes output so far
function CRC32
(CRC : in Unsigned_32;
Data : in Ada.Streams.Stream_Element_Array)
return Unsigned_32;
pragma Inline (CRC32);
-- Compute CRC32, it could be necessary for make gzip format
procedure CRC32
(CRC : in out Unsigned_32;
Data : in Ada.Streams.Stream_Element_Array);
pragma Inline (CRC32);
-- Compute CRC32, it could be necessary for make gzip format
-------------------------------------------------
-- Below is more complex low level routines. --
-------------------------------------------------
procedure Translate
(Filter : in out Filter_Type;
In_Data : in Ada.Streams.Stream_Element_Array;
In_Last : out Ada.Streams.Stream_Element_Offset;
Out_Data : out Ada.Streams.Stream_Element_Array;
Out_Last : out Ada.Streams.Stream_Element_Offset;
Flush : in Flush_Mode);
-- Compress/decompress the In_Data buffer and place the result into
-- Out_Data. In_Last is the index of last element from In_Data accepted by
-- the Filter. Out_Last is the last element of the received data from
-- Filter. To tell the filter that incoming data are complete put the
-- Flush parameter to Finish.
function Stream_End (Filter : in Filter_Type) return Boolean;
pragma Inline (Stream_End);
-- Return the true when the stream is complete.
procedure Flush
(Filter : in out Filter_Type;
Out_Data : out Ada.Streams.Stream_Element_Array;
Out_Last : out Ada.Streams.Stream_Element_Offset;
Flush : in Flush_Mode);
pragma Inline (Flush);
-- Flushing the data from the compressor.
generic
with procedure Write
(Item : in Ada.Streams.Stream_Element_Array);
-- User should provide this routine for accept
-- compressed/decompressed data.
Buffer_Size : in Ada.Streams.Stream_Element_Offset
:= Default_Buffer_Size;
-- Buffer size for Write user routine.
procedure Write
(Filter : in out Filter_Type;
Item : in Ada.Streams.Stream_Element_Array;
Flush : in Flush_Mode := No_Flush);
-- Compress/Decompress data from Item to the generic parameter procedure
-- Write. Output buffer size could be set in Buffer_Size generic parameter.
generic
with procedure Read
(Item : out Ada.Streams.Stream_Element_Array;
Last : out Ada.Streams.Stream_Element_Offset);
-- User should provide data for compression/decompression
-- thru this routine.
Buffer : in out Ada.Streams.Stream_Element_Array;
-- Buffer for keep remaining data from the previous
-- back read.
Rest_First, Rest_Last : in out Ada.Streams.Stream_Element_Offset;
-- Rest_First have to be initialized to Buffer'Last + 1
-- Rest_Last have to be initialized to Buffer'Last
-- before usage.
Allow_Read_Some : in Boolean := False;
-- Is it allowed to return Last < Item'Last before end of data.
procedure Read
(Filter : in out Filter_Type;
Item : out Ada.Streams.Stream_Element_Array;
Last : out Ada.Streams.Stream_Element_Offset;
Flush : in Flush_Mode := No_Flush);
-- Compress/Decompress data from generic parameter procedure Read to the
-- Item. User should provide Buffer and initialized Rest_First, Rest_Last
-- indicators. If Allow_Read_Some is True, Read routines could return
-- Last < Item'Last only at end of stream.
private
use Ada.Streams;
pragma Assert (Ada.Streams.Stream_Element'Size = 8);
pragma Assert (Ada.Streams.Stream_Element'Modulus = 2**8);
type Flush_Mode is new Integer range 0 .. 5;
type Compression_Method is new Integer range 8 .. 8;
type Strategy_Type is new Integer range 0 .. 3;
No_Flush : constant Flush_Mode := 0;
Partial_Flush : constant Flush_Mode := 1;
Sync_Flush : constant Flush_Mode := 2;
Full_Flush : constant Flush_Mode := 3;
Finish : constant Flush_Mode := 4;
Block_Flush : constant Flush_Mode := 5;
Filtered : constant Strategy_Type := 1;
Huffman_Only : constant Strategy_Type := 2;
RLE : constant Strategy_Type := 3;
Default_Strategy : constant Strategy_Type := 0;
Deflated : constant Compression_Method := 8;
type Z_Stream;
type Z_Stream_Access is access all Z_Stream;
type Filter_Type is tagged limited record
Strm : Z_Stream_Access;
Compression : Boolean;
Stream_End : Boolean;
Header : Header_Type;
CRC : Unsigned_32;
Offset : Stream_Element_Offset;
-- Offset for gzip header/footer output.
end record;
end ZLib;
|
zhmu/ananas | Ada | 66,360 | ads | ------------------------------------------------------------------------------
-- --
-- GNAT RUN-TIME COMPONENTS --
-- --
-- A D A . S T R I N G S . M A P S . C O N S T A N T S --
-- --
-- S p e c --
-- --
-- Copyright (C) 1992-2022, Free Software Foundation, Inc. --
-- --
-- This specification is derived from the Ada Reference Manual for use with --
-- GNAT. The copyright notice above, and the license provisions that follow --
-- apply solely to the contents of the part following the private keyword. --
-- --
-- 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 Ada.Characters.Latin_1;
package Ada.Strings.Maps.Constants is
pragma Pure;
-- In accordance with Ada 2005 AI-362
Control_Set : constant Character_Set;
Graphic_Set : constant Character_Set;
Letter_Set : constant Character_Set;
Lower_Set : constant Character_Set;
Upper_Set : constant Character_Set;
Basic_Set : constant Character_Set;
Decimal_Digit_Set : constant Character_Set;
Hexadecimal_Digit_Set : constant Character_Set;
Alphanumeric_Set : constant Character_Set;
Special_Set : constant Character_Set;
ISO_646_Set : constant Character_Set;
Lower_Case_Map : constant Character_Mapping;
-- Maps to lower case for letters, else identity
Upper_Case_Map : constant Character_Mapping;
-- Maps to upper case for letters, else identity
Basic_Map : constant Character_Mapping;
-- Maps to basic letters for letters, else identity
private
package L renames Ada.Characters.Latin_1;
Control_Set : constant Character_Set :=
[L.NUL .. L.US => True,
L.DEL .. L.APC => True,
others => False];
Graphic_Set : constant Character_Set :=
[L.Space .. L.Tilde => True,
L.No_Break_Space .. L.LC_Y_Diaeresis => True,
others => False];
Letter_Set : constant Character_Set :=
['A' .. 'Z' => True,
L.LC_A .. L.LC_Z => True,
L.UC_A_Grave .. L.UC_O_Diaeresis => True,
L.UC_O_Oblique_Stroke .. L.LC_O_Diaeresis => True,
L.LC_O_Oblique_Stroke .. L.LC_Y_Diaeresis => True,
others => False];
Lower_Set : constant Character_Set :=
[L.LC_A .. L.LC_Z => True,
L.LC_German_Sharp_S .. L.LC_O_Diaeresis => True,
L.LC_O_Oblique_Stroke .. L.LC_Y_Diaeresis => True,
others => False];
Upper_Set : constant Character_Set :=
['A' .. 'Z' => True,
L.UC_A_Grave .. L.UC_O_Diaeresis => True,
L.UC_O_Oblique_Stroke .. L.UC_Icelandic_Thorn => True,
others => False];
Basic_Set : constant Character_Set :=
['A' .. 'Z' => True,
L.LC_A .. L.LC_Z => True,
L.UC_AE_Diphthong .. L.UC_AE_Diphthong => True,
L.LC_AE_Diphthong .. L.LC_AE_Diphthong => True,
L.LC_German_Sharp_S .. L.LC_German_Sharp_S => True,
L.UC_Icelandic_Thorn .. L.UC_Icelandic_Thorn => True,
L.LC_Icelandic_Thorn .. L.LC_Icelandic_Thorn => True,
L.UC_Icelandic_Eth .. L.UC_Icelandic_Eth => True,
L.LC_Icelandic_Eth .. L.LC_Icelandic_Eth => True,
others => False];
Decimal_Digit_Set : constant Character_Set :=
['0' .. '9' => True,
others => False];
Hexadecimal_Digit_Set : constant Character_Set :=
['0' .. '9' => True,
'A' .. 'F' => True,
L.LC_A .. L.LC_F => True,
others => False];
Alphanumeric_Set : constant Character_Set :=
['0' .. '9' => True,
'A' .. 'Z' => True,
L.LC_A .. L.LC_Z => True,
L.UC_A_Grave .. L.UC_O_Diaeresis => True,
L.UC_O_Oblique_Stroke .. L.LC_O_Diaeresis => True,
L.LC_O_Oblique_Stroke .. L.LC_Y_Diaeresis => True,
others => False];
Special_Set : constant Character_Set :=
[L.Space .. L.Solidus => True,
L.Colon .. L.Commercial_At => True,
L.Left_Square_Bracket .. L.Grave => True,
L.Left_Curly_Bracket .. L.Tilde => True,
L.No_Break_Space .. L.Inverted_Question => True,
L.Multiplication_Sign .. L.Multiplication_Sign => True,
L.Division_Sign .. L.Division_Sign => True,
others => False];
ISO_646_Set : constant Character_Set :=
[L.NUL .. L.DEL => True,
others => False];
Lower_Case_Map : constant Character_Mapping :=
(L.NUL & -- NUL 0
L.SOH & -- SOH 1
L.STX & -- STX 2
L.ETX & -- ETX 3
L.EOT & -- EOT 4
L.ENQ & -- ENQ 5
L.ACK & -- ACK 6
L.BEL & -- BEL 7
L.BS & -- BS 8
L.HT & -- HT 9
L.LF & -- LF 10
L.VT & -- VT 11
L.FF & -- FF 12
L.CR & -- CR 13
L.SO & -- SO 14
L.SI & -- SI 15
L.DLE & -- DLE 16
L.DC1 & -- DC1 17
L.DC2 & -- DC2 18
L.DC3 & -- DC3 19
L.DC4 & -- DC4 20
L.NAK & -- NAK 21
L.SYN & -- SYN 22
L.ETB & -- ETB 23
L.CAN & -- CAN 24
L.EM & -- EM 25
L.SUB & -- SUB 26
L.ESC & -- ESC 27
L.FS & -- FS 28
L.GS & -- GS 29
L.RS & -- RS 30
L.US & -- US 31
L.Space & -- ' ' 32
L.Exclamation & -- '!' 33
L.Quotation & -- '"' 34
L.Number_Sign & -- '#' 35
L.Dollar_Sign & -- '$' 36
L.Percent_Sign & -- '%' 37
L.Ampersand & -- '&' 38
L.Apostrophe & -- ''' 39
L.Left_Parenthesis & -- '(' 40
L.Right_Parenthesis & -- ')' 41
L.Asterisk & -- '*' 42
L.Plus_Sign & -- '+' 43
L.Comma & -- ',' 44
L.Hyphen & -- '-' 45
L.Full_Stop & -- '.' 46
L.Solidus & -- '/' 47
'0' & -- '0' 48
'1' & -- '1' 49
'2' & -- '2' 50
'3' & -- '3' 51
'4' & -- '4' 52
'5' & -- '5' 53
'6' & -- '6' 54
'7' & -- '7' 55
'8' & -- '8' 56
'9' & -- '9' 57
L.Colon & -- ':' 58
L.Semicolon & -- ';' 59
L.Less_Than_Sign & -- '<' 60
L.Equals_Sign & -- '=' 61
L.Greater_Than_Sign & -- '>' 62
L.Question & -- '?' 63
L.Commercial_At & -- '@' 64
L.LC_A & -- 'a' 65
L.LC_B & -- 'b' 66
L.LC_C & -- 'c' 67
L.LC_D & -- 'd' 68
L.LC_E & -- 'e' 69
L.LC_F & -- 'f' 70
L.LC_G & -- 'g' 71
L.LC_H & -- 'h' 72
L.LC_I & -- 'i' 73
L.LC_J & -- 'j' 74
L.LC_K & -- 'k' 75
L.LC_L & -- 'l' 76
L.LC_M & -- 'm' 77
L.LC_N & -- 'n' 78
L.LC_O & -- 'o' 79
L.LC_P & -- 'p' 80
L.LC_Q & -- 'q' 81
L.LC_R & -- 'r' 82
L.LC_S & -- 's' 83
L.LC_T & -- 't' 84
L.LC_U & -- 'u' 85
L.LC_V & -- 'v' 86
L.LC_W & -- 'w' 87
L.LC_X & -- 'x' 88
L.LC_Y & -- 'y' 89
L.LC_Z & -- 'z' 90
L.Left_Square_Bracket & -- '[' 91
L.Reverse_Solidus & -- '\' 92
L.Right_Square_Bracket & -- ']' 93
L.Circumflex & -- '^' 94
L.Low_Line & -- '_' 95
L.Grave & -- '`' 96
L.LC_A & -- 'a' 97
L.LC_B & -- 'b' 98
L.LC_C & -- 'c' 99
L.LC_D & -- 'd' 100
L.LC_E & -- 'e' 101
L.LC_F & -- 'f' 102
L.LC_G & -- 'g' 103
L.LC_H & -- 'h' 104
L.LC_I & -- 'i' 105
L.LC_J & -- 'j' 106
L.LC_K & -- 'k' 107
L.LC_L & -- 'l' 108
L.LC_M & -- 'm' 109
L.LC_N & -- 'n' 110
L.LC_O & -- 'o' 111
L.LC_P & -- 'p' 112
L.LC_Q & -- 'q' 113
L.LC_R & -- 'r' 114
L.LC_S & -- 's' 115
L.LC_T & -- 't' 116
L.LC_U & -- 'u' 117
L.LC_V & -- 'v' 118
L.LC_W & -- 'w' 119
L.LC_X & -- 'x' 120
L.LC_Y & -- 'y' 121
L.LC_Z & -- 'z' 122
L.Left_Curly_Bracket & -- '{' 123
L.Vertical_Line & -- '|' 124
L.Right_Curly_Bracket & -- '}' 125
L.Tilde & -- '~' 126
L.DEL & -- DEL 127
L.Reserved_128 & -- Reserved_128 128
L.Reserved_129 & -- Reserved_129 129
L.BPH & -- BPH 130
L.NBH & -- NBH 131
L.Reserved_132 & -- Reserved_132 132
L.NEL & -- NEL 133
L.SSA & -- SSA 134
L.ESA & -- ESA 135
L.HTS & -- HTS 136
L.HTJ & -- HTJ 137
L.VTS & -- VTS 138
L.PLD & -- PLD 139
L.PLU & -- PLU 140
L.RI & -- RI 141
L.SS2 & -- SS2 142
L.SS3 & -- SS3 143
L.DCS & -- DCS 144
L.PU1 & -- PU1 145
L.PU2 & -- PU2 146
L.STS & -- STS 147
L.CCH & -- CCH 148
L.MW & -- MW 149
L.SPA & -- SPA 150
L.EPA & -- EPA 151
L.SOS & -- SOS 152
L.Reserved_153 & -- Reserved_153 153
L.SCI & -- SCI 154
L.CSI & -- CSI 155
L.ST & -- ST 156
L.OSC & -- OSC 157
L.PM & -- PM 158
L.APC & -- APC 159
L.No_Break_Space & -- No_Break_Space 160
L.Inverted_Exclamation & -- Inverted_Exclamation 161
L.Cent_Sign & -- Cent_Sign 162
L.Pound_Sign & -- Pound_Sign 163
L.Currency_Sign & -- Currency_Sign 164
L.Yen_Sign & -- Yen_Sign 165
L.Broken_Bar & -- Broken_Bar 166
L.Section_Sign & -- Section_Sign 167
L.Diaeresis & -- Diaeresis 168
L.Copyright_Sign & -- Copyright_Sign 169
L.Feminine_Ordinal_Indicator & -- Feminine_Ordinal_Indicator 170
L.Left_Angle_Quotation & -- Left_Angle_Quotation 171
L.Not_Sign & -- Not_Sign 172
L.Soft_Hyphen & -- Soft_Hyphen 173
L.Registered_Trade_Mark_Sign & -- Registered_Trade_Mark_Sign 174
L.Macron & -- Macron 175
L.Degree_Sign & -- Degree_Sign 176
L.Plus_Minus_Sign & -- Plus_Minus_Sign 177
L.Superscript_Two & -- Superscript_Two 178
L.Superscript_Three & -- Superscript_Three 179
L.Acute & -- Acute 180
L.Micro_Sign & -- Micro_Sign 181
L.Pilcrow_Sign & -- Pilcrow_Sign 182
L.Middle_Dot & -- Middle_Dot 183
L.Cedilla & -- Cedilla 184
L.Superscript_One & -- Superscript_One 185
L.Masculine_Ordinal_Indicator & -- Masculine_Ordinal_Indicator 186
L.Right_Angle_Quotation & -- Right_Angle_Quotation 187
L.Fraction_One_Quarter & -- Fraction_One_Quarter 188
L.Fraction_One_Half & -- Fraction_One_Half 189
L.Fraction_Three_Quarters & -- Fraction_Three_Quarters 190
L.Inverted_Question & -- Inverted_Question 191
L.LC_A_Grave & -- UC_A_Grave 192
L.LC_A_Acute & -- UC_A_Acute 193
L.LC_A_Circumflex & -- UC_A_Circumflex 194
L.LC_A_Tilde & -- UC_A_Tilde 195
L.LC_A_Diaeresis & -- UC_A_Diaeresis 196
L.LC_A_Ring & -- UC_A_Ring 197
L.LC_AE_Diphthong & -- UC_AE_Diphthong 198
L.LC_C_Cedilla & -- UC_C_Cedilla 199
L.LC_E_Grave & -- UC_E_Grave 200
L.LC_E_Acute & -- UC_E_Acute 201
L.LC_E_Circumflex & -- UC_E_Circumflex 202
L.LC_E_Diaeresis & -- UC_E_Diaeresis 203
L.LC_I_Grave & -- UC_I_Grave 204
L.LC_I_Acute & -- UC_I_Acute 205
L.LC_I_Circumflex & -- UC_I_Circumflex 206
L.LC_I_Diaeresis & -- UC_I_Diaeresis 207
L.LC_Icelandic_Eth & -- UC_Icelandic_Eth 208
L.LC_N_Tilde & -- UC_N_Tilde 209
L.LC_O_Grave & -- UC_O_Grave 210
L.LC_O_Acute & -- UC_O_Acute 211
L.LC_O_Circumflex & -- UC_O_Circumflex 212
L.LC_O_Tilde & -- UC_O_Tilde 213
L.LC_O_Diaeresis & -- UC_O_Diaeresis 214
L.Multiplication_Sign & -- Multiplication_Sign 215
L.LC_O_Oblique_Stroke & -- UC_O_Oblique_Stroke 216
L.LC_U_Grave & -- UC_U_Grave 217
L.LC_U_Acute & -- UC_U_Acute 218
L.LC_U_Circumflex & -- UC_U_Circumflex 219
L.LC_U_Diaeresis & -- UC_U_Diaeresis 220
L.LC_Y_Acute & -- UC_Y_Acute 221
L.LC_Icelandic_Thorn & -- UC_Icelandic_Thorn 222
L.LC_German_Sharp_S & -- LC_German_Sharp_S 223
L.LC_A_Grave & -- LC_A_Grave 224
L.LC_A_Acute & -- LC_A_Acute 225
L.LC_A_Circumflex & -- LC_A_Circumflex 226
L.LC_A_Tilde & -- LC_A_Tilde 227
L.LC_A_Diaeresis & -- LC_A_Diaeresis 228
L.LC_A_Ring & -- LC_A_Ring 229
L.LC_AE_Diphthong & -- LC_AE_Diphthong 230
L.LC_C_Cedilla & -- LC_C_Cedilla 231
L.LC_E_Grave & -- LC_E_Grave 232
L.LC_E_Acute & -- LC_E_Acute 233
L.LC_E_Circumflex & -- LC_E_Circumflex 234
L.LC_E_Diaeresis & -- LC_E_Diaeresis 235
L.LC_I_Grave & -- LC_I_Grave 236
L.LC_I_Acute & -- LC_I_Acute 237
L.LC_I_Circumflex & -- LC_I_Circumflex 238
L.LC_I_Diaeresis & -- LC_I_Diaeresis 239
L.LC_Icelandic_Eth & -- LC_Icelandic_Eth 240
L.LC_N_Tilde & -- LC_N_Tilde 241
L.LC_O_Grave & -- LC_O_Grave 242
L.LC_O_Acute & -- LC_O_Acute 243
L.LC_O_Circumflex & -- LC_O_Circumflex 244
L.LC_O_Tilde & -- LC_O_Tilde 245
L.LC_O_Diaeresis & -- LC_O_Diaeresis 246
L.Division_Sign & -- Division_Sign 247
L.LC_O_Oblique_Stroke & -- LC_O_Oblique_Stroke 248
L.LC_U_Grave & -- LC_U_Grave 249
L.LC_U_Acute & -- LC_U_Acute 250
L.LC_U_Circumflex & -- LC_U_Circumflex 251
L.LC_U_Diaeresis & -- LC_U_Diaeresis 252
L.LC_Y_Acute & -- LC_Y_Acute 253
L.LC_Icelandic_Thorn & -- LC_Icelandic_Thorn 254
L.LC_Y_Diaeresis); -- LC_Y_Diaeresis 255
Upper_Case_Map : constant Character_Mapping :=
(L.NUL & -- NUL 0
L.SOH & -- SOH 1
L.STX & -- STX 2
L.ETX & -- ETX 3
L.EOT & -- EOT 4
L.ENQ & -- ENQ 5
L.ACK & -- ACK 6
L.BEL & -- BEL 7
L.BS & -- BS 8
L.HT & -- HT 9
L.LF & -- LF 10
L.VT & -- VT 11
L.FF & -- FF 12
L.CR & -- CR 13
L.SO & -- SO 14
L.SI & -- SI 15
L.DLE & -- DLE 16
L.DC1 & -- DC1 17
L.DC2 & -- DC2 18
L.DC3 & -- DC3 19
L.DC4 & -- DC4 20
L.NAK & -- NAK 21
L.SYN & -- SYN 22
L.ETB & -- ETB 23
L.CAN & -- CAN 24
L.EM & -- EM 25
L.SUB & -- SUB 26
L.ESC & -- ESC 27
L.FS & -- FS 28
L.GS & -- GS 29
L.RS & -- RS 30
L.US & -- US 31
L.Space & -- ' ' 32
L.Exclamation & -- '!' 33
L.Quotation & -- '"' 34
L.Number_Sign & -- '#' 35
L.Dollar_Sign & -- '$' 36
L.Percent_Sign & -- '%' 37
L.Ampersand & -- '&' 38
L.Apostrophe & -- ''' 39
L.Left_Parenthesis & -- '(' 40
L.Right_Parenthesis & -- ')' 41
L.Asterisk & -- '*' 42
L.Plus_Sign & -- '+' 43
L.Comma & -- ',' 44
L.Hyphen & -- '-' 45
L.Full_Stop & -- '.' 46
L.Solidus & -- '/' 47
'0' & -- '0' 48
'1' & -- '1' 49
'2' & -- '2' 50
'3' & -- '3' 51
'4' & -- '4' 52
'5' & -- '5' 53
'6' & -- '6' 54
'7' & -- '7' 55
'8' & -- '8' 56
'9' & -- '9' 57
L.Colon & -- ':' 58
L.Semicolon & -- ';' 59
L.Less_Than_Sign & -- '<' 60
L.Equals_Sign & -- '=' 61
L.Greater_Than_Sign & -- '>' 62
L.Question & -- '?' 63
L.Commercial_At & -- '@' 64
'A' & -- 'A' 65
'B' & -- 'B' 66
'C' & -- 'C' 67
'D' & -- 'D' 68
'E' & -- 'E' 69
'F' & -- 'F' 70
'G' & -- 'G' 71
'H' & -- 'H' 72
'I' & -- 'I' 73
'J' & -- 'J' 74
'K' & -- 'K' 75
'L' & -- 'L' 76
'M' & -- 'M' 77
'N' & -- 'N' 78
'O' & -- 'O' 79
'P' & -- 'P' 80
'Q' & -- 'Q' 81
'R' & -- 'R' 82
'S' & -- 'S' 83
'T' & -- 'T' 84
'U' & -- 'U' 85
'V' & -- 'V' 86
'W' & -- 'W' 87
'X' & -- 'X' 88
'Y' & -- 'Y' 89
'Z' & -- 'Z' 90
L.Left_Square_Bracket & -- '[' 91
L.Reverse_Solidus & -- '\' 92
L.Right_Square_Bracket & -- ']' 93
L.Circumflex & -- '^' 94
L.Low_Line & -- '_' 95
L.Grave & -- '`' 96
'A' & -- 'a' 97
'B' & -- 'b' 98
'C' & -- 'c' 99
'D' & -- 'd' 100
'E' & -- 'e' 101
'F' & -- 'f' 102
'G' & -- 'g' 103
'H' & -- 'h' 104
'I' & -- 'i' 105
'J' & -- 'j' 106
'K' & -- 'k' 107
'L' & -- 'l' 108
'M' & -- 'm' 109
'N' & -- 'n' 110
'O' & -- 'o' 111
'P' & -- 'p' 112
'Q' & -- 'q' 113
'R' & -- 'r' 114
'S' & -- 's' 115
'T' & -- 't' 116
'U' & -- 'u' 117
'V' & -- 'v' 118
'W' & -- 'w' 119
'X' & -- 'x' 120
'Y' & -- 'y' 121
'Z' & -- 'z' 122
L.Left_Curly_Bracket & -- '{' 123
L.Vertical_Line & -- '|' 124
L.Right_Curly_Bracket & -- '}' 125
L.Tilde & -- '~' 126
L.DEL & -- DEL 127
L.Reserved_128 & -- Reserved_128 128
L.Reserved_129 & -- Reserved_129 129
L.BPH & -- BPH 130
L.NBH & -- NBH 131
L.Reserved_132 & -- Reserved_132 132
L.NEL & -- NEL 133
L.SSA & -- SSA 134
L.ESA & -- ESA 135
L.HTS & -- HTS 136
L.HTJ & -- HTJ 137
L.VTS & -- VTS 138
L.PLD & -- PLD 139
L.PLU & -- PLU 140
L.RI & -- RI 141
L.SS2 & -- SS2 142
L.SS3 & -- SS3 143
L.DCS & -- DCS 144
L.PU1 & -- PU1 145
L.PU2 & -- PU2 146
L.STS & -- STS 147
L.CCH & -- CCH 148
L.MW & -- MW 149
L.SPA & -- SPA 150
L.EPA & -- EPA 151
L.SOS & -- SOS 152
L.Reserved_153 & -- Reserved_153 153
L.SCI & -- SCI 154
L.CSI & -- CSI 155
L.ST & -- ST 156
L.OSC & -- OSC 157
L.PM & -- PM 158
L.APC & -- APC 159
L.No_Break_Space & -- No_Break_Space 160
L.Inverted_Exclamation & -- Inverted_Exclamation 161
L.Cent_Sign & -- Cent_Sign 162
L.Pound_Sign & -- Pound_Sign 163
L.Currency_Sign & -- Currency_Sign 164
L.Yen_Sign & -- Yen_Sign 165
L.Broken_Bar & -- Broken_Bar 166
L.Section_Sign & -- Section_Sign 167
L.Diaeresis & -- Diaeresis 168
L.Copyright_Sign & -- Copyright_Sign 169
L.Feminine_Ordinal_Indicator & -- Feminine_Ordinal_Indicator 170
L.Left_Angle_Quotation & -- Left_Angle_Quotation 171
L.Not_Sign & -- Not_Sign 172
L.Soft_Hyphen & -- Soft_Hyphen 173
L.Registered_Trade_Mark_Sign & -- Registered_Trade_Mark_Sign 174
L.Macron & -- Macron 175
L.Degree_Sign & -- Degree_Sign 176
L.Plus_Minus_Sign & -- Plus_Minus_Sign 177
L.Superscript_Two & -- Superscript_Two 178
L.Superscript_Three & -- Superscript_Three 179
L.Acute & -- Acute 180
L.Micro_Sign & -- Micro_Sign 181
L.Pilcrow_Sign & -- Pilcrow_Sign 182
L.Middle_Dot & -- Middle_Dot 183
L.Cedilla & -- Cedilla 184
L.Superscript_One & -- Superscript_One 185
L.Masculine_Ordinal_Indicator & -- Masculine_Ordinal_Indicator 186
L.Right_Angle_Quotation & -- Right_Angle_Quotation 187
L.Fraction_One_Quarter & -- Fraction_One_Quarter 188
L.Fraction_One_Half & -- Fraction_One_Half 189
L.Fraction_Three_Quarters & -- Fraction_Three_Quarters 190
L.Inverted_Question & -- Inverted_Question 191
L.UC_A_Grave & -- UC_A_Grave 192
L.UC_A_Acute & -- UC_A_Acute 193
L.UC_A_Circumflex & -- UC_A_Circumflex 194
L.UC_A_Tilde & -- UC_A_Tilde 195
L.UC_A_Diaeresis & -- UC_A_Diaeresis 196
L.UC_A_Ring & -- UC_A_Ring 197
L.UC_AE_Diphthong & -- UC_AE_Diphthong 198
L.UC_C_Cedilla & -- UC_C_Cedilla 199
L.UC_E_Grave & -- UC_E_Grave 200
L.UC_E_Acute & -- UC_E_Acute 201
L.UC_E_Circumflex & -- UC_E_Circumflex 202
L.UC_E_Diaeresis & -- UC_E_Diaeresis 203
L.UC_I_Grave & -- UC_I_Grave 204
L.UC_I_Acute & -- UC_I_Acute 205
L.UC_I_Circumflex & -- UC_I_Circumflex 206
L.UC_I_Diaeresis & -- UC_I_Diaeresis 207
L.UC_Icelandic_Eth & -- UC_Icelandic_Eth 208
L.UC_N_Tilde & -- UC_N_Tilde 209
L.UC_O_Grave & -- UC_O_Grave 210
L.UC_O_Acute & -- UC_O_Acute 211
L.UC_O_Circumflex & -- UC_O_Circumflex 212
L.UC_O_Tilde & -- UC_O_Tilde 213
L.UC_O_Diaeresis & -- UC_O_Diaeresis 214
L.Multiplication_Sign & -- Multiplication_Sign 215
L.UC_O_Oblique_Stroke & -- UC_O_Oblique_Stroke 216
L.UC_U_Grave & -- UC_U_Grave 217
L.UC_U_Acute & -- UC_U_Acute 218
L.UC_U_Circumflex & -- UC_U_Circumflex 219
L.UC_U_Diaeresis & -- UC_U_Diaeresis 220
L.UC_Y_Acute & -- UC_Y_Acute 221
L.UC_Icelandic_Thorn & -- UC_Icelandic_Thorn 222
L.LC_German_Sharp_S & -- LC_German_Sharp_S 223
L.UC_A_Grave & -- LC_A_Grave 224
L.UC_A_Acute & -- LC_A_Acute 225
L.UC_A_Circumflex & -- LC_A_Circumflex 226
L.UC_A_Tilde & -- LC_A_Tilde 227
L.UC_A_Diaeresis & -- LC_A_Diaeresis 228
L.UC_A_Ring & -- LC_A_Ring 229
L.UC_AE_Diphthong & -- LC_AE_Diphthong 230
L.UC_C_Cedilla & -- LC_C_Cedilla 231
L.UC_E_Grave & -- LC_E_Grave 232
L.UC_E_Acute & -- LC_E_Acute 233
L.UC_E_Circumflex & -- LC_E_Circumflex 234
L.UC_E_Diaeresis & -- LC_E_Diaeresis 235
L.UC_I_Grave & -- LC_I_Grave 236
L.UC_I_Acute & -- LC_I_Acute 237
L.UC_I_Circumflex & -- LC_I_Circumflex 238
L.UC_I_Diaeresis & -- LC_I_Diaeresis 239
L.UC_Icelandic_Eth & -- LC_Icelandic_Eth 240
L.UC_N_Tilde & -- LC_N_Tilde 241
L.UC_O_Grave & -- LC_O_Grave 242
L.UC_O_Acute & -- LC_O_Acute 243
L.UC_O_Circumflex & -- LC_O_Circumflex 244
L.UC_O_Tilde & -- LC_O_Tilde 245
L.UC_O_Diaeresis & -- LC_O_Diaeresis 246
L.Division_Sign & -- Division_Sign 247
L.UC_O_Oblique_Stroke & -- LC_O_Oblique_Stroke 248
L.UC_U_Grave & -- LC_U_Grave 249
L.UC_U_Acute & -- LC_U_Acute 250
L.UC_U_Circumflex & -- LC_U_Circumflex 251
L.UC_U_Diaeresis & -- LC_U_Diaeresis 252
L.UC_Y_Acute & -- LC_Y_Acute 253
L.UC_Icelandic_Thorn & -- LC_Icelandic_Thorn 254
L.LC_Y_Diaeresis); -- LC_Y_Diaeresis 255
Basic_Map : constant Character_Mapping :=
(L.NUL & -- NUL 0
L.SOH & -- SOH 1
L.STX & -- STX 2
L.ETX & -- ETX 3
L.EOT & -- EOT 4
L.ENQ & -- ENQ 5
L.ACK & -- ACK 6
L.BEL & -- BEL 7
L.BS & -- BS 8
L.HT & -- HT 9
L.LF & -- LF 10
L.VT & -- VT 11
L.FF & -- FF 12
L.CR & -- CR 13
L.SO & -- SO 14
L.SI & -- SI 15
L.DLE & -- DLE 16
L.DC1 & -- DC1 17
L.DC2 & -- DC2 18
L.DC3 & -- DC3 19
L.DC4 & -- DC4 20
L.NAK & -- NAK 21
L.SYN & -- SYN 22
L.ETB & -- ETB 23
L.CAN & -- CAN 24
L.EM & -- EM 25
L.SUB & -- SUB 26
L.ESC & -- ESC 27
L.FS & -- FS 28
L.GS & -- GS 29
L.RS & -- RS 30
L.US & -- US 31
L.Space & -- ' ' 32
L.Exclamation & -- '!' 33
L.Quotation & -- '"' 34
L.Number_Sign & -- '#' 35
L.Dollar_Sign & -- '$' 36
L.Percent_Sign & -- '%' 37
L.Ampersand & -- '&' 38
L.Apostrophe & -- ''' 39
L.Left_Parenthesis & -- '(' 40
L.Right_Parenthesis & -- ')' 41
L.Asterisk & -- '*' 42
L.Plus_Sign & -- '+' 43
L.Comma & -- ',' 44
L.Hyphen & -- '-' 45
L.Full_Stop & -- '.' 46
L.Solidus & -- '/' 47
'0' & -- '0' 48
'1' & -- '1' 49
'2' & -- '2' 50
'3' & -- '3' 51
'4' & -- '4' 52
'5' & -- '5' 53
'6' & -- '6' 54
'7' & -- '7' 55
'8' & -- '8' 56
'9' & -- '9' 57
L.Colon & -- ':' 58
L.Semicolon & -- ';' 59
L.Less_Than_Sign & -- '<' 60
L.Equals_Sign & -- '=' 61
L.Greater_Than_Sign & -- '>' 62
L.Question & -- '?' 63
L.Commercial_At & -- '@' 64
'A' & -- 'A' 65
'B' & -- 'B' 66
'C' & -- 'C' 67
'D' & -- 'D' 68
'E' & -- 'E' 69
'F' & -- 'F' 70
'G' & -- 'G' 71
'H' & -- 'H' 72
'I' & -- 'I' 73
'J' & -- 'J' 74
'K' & -- 'K' 75
'L' & -- 'L' 76
'M' & -- 'M' 77
'N' & -- 'N' 78
'O' & -- 'O' 79
'P' & -- 'P' 80
'Q' & -- 'Q' 81
'R' & -- 'R' 82
'S' & -- 'S' 83
'T' & -- 'T' 84
'U' & -- 'U' 85
'V' & -- 'V' 86
'W' & -- 'W' 87
'X' & -- 'X' 88
'Y' & -- 'Y' 89
'Z' & -- 'Z' 90
L.Left_Square_Bracket & -- '[' 91
L.Reverse_Solidus & -- '\' 92
L.Right_Square_Bracket & -- ']' 93
L.Circumflex & -- '^' 94
L.Low_Line & -- '_' 95
L.Grave & -- '`' 96
L.LC_A & -- 'a' 97
L.LC_B & -- 'b' 98
L.LC_C & -- 'c' 99
L.LC_D & -- 'd' 100
L.LC_E & -- 'e' 101
L.LC_F & -- 'f' 102
L.LC_G & -- 'g' 103
L.LC_H & -- 'h' 104
L.LC_I & -- 'i' 105
L.LC_J & -- 'j' 106
L.LC_K & -- 'k' 107
L.LC_L & -- 'l' 108
L.LC_M & -- 'm' 109
L.LC_N & -- 'n' 110
L.LC_O & -- 'o' 111
L.LC_P & -- 'p' 112
L.LC_Q & -- 'q' 113
L.LC_R & -- 'r' 114
L.LC_S & -- 's' 115
L.LC_T & -- 't' 116
L.LC_U & -- 'u' 117
L.LC_V & -- 'v' 118
L.LC_W & -- 'w' 119
L.LC_X & -- 'x' 120
L.LC_Y & -- 'y' 121
L.LC_Z & -- 'z' 122
L.Left_Curly_Bracket & -- '{' 123
L.Vertical_Line & -- '|' 124
L.Right_Curly_Bracket & -- '}' 125
L.Tilde & -- '~' 126
L.DEL & -- DEL 127
L.Reserved_128 & -- Reserved_128 128
L.Reserved_129 & -- Reserved_129 129
L.BPH & -- BPH 130
L.NBH & -- NBH 131
L.Reserved_132 & -- Reserved_132 132
L.NEL & -- NEL 133
L.SSA & -- SSA 134
L.ESA & -- ESA 135
L.HTS & -- HTS 136
L.HTJ & -- HTJ 137
L.VTS & -- VTS 138
L.PLD & -- PLD 139
L.PLU & -- PLU 140
L.RI & -- RI 141
L.SS2 & -- SS2 142
L.SS3 & -- SS3 143
L.DCS & -- DCS 144
L.PU1 & -- PU1 145
L.PU2 & -- PU2 146
L.STS & -- STS 147
L.CCH & -- CCH 148
L.MW & -- MW 149
L.SPA & -- SPA 150
L.EPA & -- EPA 151
L.SOS & -- SOS 152
L.Reserved_153 & -- Reserved_153 153
L.SCI & -- SCI 154
L.CSI & -- CSI 155
L.ST & -- ST 156
L.OSC & -- OSC 157
L.PM & -- PM 158
L.APC & -- APC 159
L.No_Break_Space & -- No_Break_Space 160
L.Inverted_Exclamation & -- Inverted_Exclamation 161
L.Cent_Sign & -- Cent_Sign 162
L.Pound_Sign & -- Pound_Sign 163
L.Currency_Sign & -- Currency_Sign 164
L.Yen_Sign & -- Yen_Sign 165
L.Broken_Bar & -- Broken_Bar 166
L.Section_Sign & -- Section_Sign 167
L.Diaeresis & -- Diaeresis 168
L.Copyright_Sign & -- Copyright_Sign 169
L.Feminine_Ordinal_Indicator & -- Feminine_Ordinal_Indicator 170
L.Left_Angle_Quotation & -- Left_Angle_Quotation 171
L.Not_Sign & -- Not_Sign 172
L.Soft_Hyphen & -- Soft_Hyphen 173
L.Registered_Trade_Mark_Sign & -- Registered_Trade_Mark_Sign 174
L.Macron & -- Macron 175
L.Degree_Sign & -- Degree_Sign 176
L.Plus_Minus_Sign & -- Plus_Minus_Sign 177
L.Superscript_Two & -- Superscript_Two 178
L.Superscript_Three & -- Superscript_Three 179
L.Acute & -- Acute 180
L.Micro_Sign & -- Micro_Sign 181
L.Pilcrow_Sign & -- Pilcrow_Sign 182
L.Middle_Dot & -- Middle_Dot 183
L.Cedilla & -- Cedilla 184
L.Superscript_One & -- Superscript_One 185
L.Masculine_Ordinal_Indicator & -- Masculine_Ordinal_Indicator 186
L.Right_Angle_Quotation & -- Right_Angle_Quotation 187
L.Fraction_One_Quarter & -- Fraction_One_Quarter 188
L.Fraction_One_Half & -- Fraction_One_Half 189
L.Fraction_Three_Quarters & -- Fraction_Three_Quarters 190
L.Inverted_Question & -- Inverted_Question 191
'A' & -- UC_A_Grave 192
'A' & -- UC_A_Acute 193
'A' & -- UC_A_Circumflex 194
'A' & -- UC_A_Tilde 195
'A' & -- UC_A_Diaeresis 196
'A' & -- UC_A_Ring 197
L.UC_AE_Diphthong & -- UC_AE_Diphthong 198
'C' & -- UC_C_Cedilla 199
'E' & -- UC_E_Grave 200
'E' & -- UC_E_Acute 201
'E' & -- UC_E_Circumflex 202
'E' & -- UC_E_Diaeresis 203
'I' & -- UC_I_Grave 204
'I' & -- UC_I_Acute 205
'I' & -- UC_I_Circumflex 206
'I' & -- UC_I_Diaeresis 207
L.UC_Icelandic_Eth & -- UC_Icelandic_Eth 208
'N' & -- UC_N_Tilde 209
'O' & -- UC_O_Grave 210
'O' & -- UC_O_Acute 211
'O' & -- UC_O_Circumflex 212
'O' & -- UC_O_Tilde 213
'O' & -- UC_O_Diaeresis 214
L.Multiplication_Sign & -- Multiplication_Sign 215
'O' & -- UC_O_Oblique_Stroke 216
'U' & -- UC_U_Grave 217
'U' & -- UC_U_Acute 218
'U' & -- UC_U_Circumflex 219
'U' & -- UC_U_Diaeresis 220
'Y' & -- UC_Y_Acute 221
L.UC_Icelandic_Thorn & -- UC_Icelandic_Thorn 222
L.LC_German_Sharp_S & -- LC_German_Sharp_S 223
L.LC_A & -- LC_A_Grave 224
L.LC_A & -- LC_A_Acute 225
L.LC_A & -- LC_A_Circumflex 226
L.LC_A & -- LC_A_Tilde 227
L.LC_A & -- LC_A_Diaeresis 228
L.LC_A & -- LC_A_Ring 229
L.LC_AE_Diphthong & -- LC_AE_Diphthong 230
L.LC_C & -- LC_C_Cedilla 231
L.LC_E & -- LC_E_Grave 232
L.LC_E & -- LC_E_Acute 233
L.LC_E & -- LC_E_Circumflex 234
L.LC_E & -- LC_E_Diaeresis 235
L.LC_I & -- LC_I_Grave 236
L.LC_I & -- LC_I_Acute 237
L.LC_I & -- LC_I_Circumflex 238
L.LC_I & -- LC_I_Diaeresis 239
L.LC_Icelandic_Eth & -- LC_Icelandic_Eth 240
L.LC_N & -- LC_N_Tilde 241
L.LC_O & -- LC_O_Grave 242
L.LC_O & -- LC_O_Acute 243
L.LC_O & -- LC_O_Circumflex 244
L.LC_O & -- LC_O_Tilde 245
L.LC_O & -- LC_O_Diaeresis 246
L.Division_Sign & -- Division_Sign 247
L.LC_O & -- LC_O_Oblique_Stroke 248
L.LC_U & -- LC_U_Grave 249
L.LC_U & -- LC_U_Acute 250
L.LC_U & -- LC_U_Circumflex 251
L.LC_U & -- LC_U_Diaeresis 252
L.LC_Y & -- LC_Y_Acute 253
L.LC_Icelandic_Thorn & -- LC_Icelandic_Thorn 254
L.LC_Y); -- LC_Y_Diaeresis 255
end Ada.Strings.Maps.Constants;
|
JeremyGrosser/Ada_Drivers_Library | Ada | 1,939 | ads | -- This package was generated by the Ada_Drivers_Library project wizard script
package ADL_Config is
Architecture : constant String := "ARM"; -- From board definition
Board : constant String := "STM32F769_Discovery"; -- From command line
CPU_Core : constant String := "ARM Cortex-M7F"; -- From mcu definition
Device_Family : constant String := "STM32F7"; -- From board definition
Device_Name : constant String := "STM32F769NIHx"; -- From board definition
Has_Ravenscar_Full_Runtime : constant String := "True"; -- From board definition
Has_Ravenscar_SFP_Runtime : constant String := "True"; -- From board definition
Has_ZFP_Runtime : constant String := "False"; -- From board definition
High_Speed_External_Clock : constant := 25000000; -- From board definition
Max_Mount_Name_Length : constant := 128; -- From default value
Max_Mount_Points : constant := 2; -- From default value
Max_Path_Length : constant := 1024; -- From default value
Number_Of_Interrupts : constant := 0; -- From default value
Runtime_Name : constant String := "ravenscar-full-stm32f769disco"; -- From default value
Runtime_Name_Suffix : constant String := "stm32f769disco"; -- From board definition
Runtime_Profile : constant String := "ravenscar-full"; -- From command line
Use_Startup_Gen : constant Boolean := False; -- From command line
Vendor : constant String := "STMicro"; -- From board definition
end ADL_Config;
|
ohenley/ada-util | Ada | 4,908 | adb | -----------------------------------------------------------------------
-- util-commands-consoles-text -- Text console interface
-- Copyright (C) 2014, 2015, 2017, 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.
-----------------------------------------------------------------------
package body Util.Commands.Consoles.Text is
-- ------------------------------
-- Report an error message.
-- ------------------------------
overriding
procedure Error (Console : in out Console_Type;
Message : in String) is
pragma Unreferenced (Console);
begin
Ada.Text_IO.Put_Line (Message);
end Error;
-- ------------------------------
-- Report a notice message.
-- ------------------------------
overriding
procedure Notice (Console : in out Console_Type;
Kind : in Notice_Type;
Message : in String) is
pragma Unreferenced (Console, Kind);
begin
Ada.Text_IO.Put_Line (Message);
end Notice;
-- ------------------------------
-- Print the field value for the given field.
-- ------------------------------
overriding
procedure Print_Field (Console : in out Console_Type;
Field : in Field_Type;
Value : in String;
Justify : in Justify_Type := J_LEFT) is
use type Ada.Text_IO.Count;
Pos : constant Ada.Text_IO.Count := Ada.Text_IO.Count (Console.Cols (Field));
Size : constant Natural := Console.Sizes (Field);
Start : Natural := Value'First;
Last : constant Natural := Value'Last;
Pad : Natural := 0;
begin
case Justify is
when J_LEFT =>
if Value'Length > Size and Size > 0 then
Start := Last - Size + 1;
end if;
when J_RIGHT =>
if Value'Length < Size then
Pad := Size - Value'Length - 1;
else
Start := Last - Size + 1;
end if;
when J_CENTER =>
if Value'Length < Size then
Pad := (Size - Value'Length) / 2;
else
Start := Last - Size + 1;
end if;
when J_RIGHT_NO_FILL =>
if Value'Length >= Size then
Start := Last - Size + 1;
end if;
end case;
if Pad > 0 then
Ada.Text_IO.Set_Col (Pos + Ada.Text_IO.Count (Pad));
elsif Pos > 1 then
Ada.Text_IO.Set_Col (Pos);
end if;
Ada.Text_IO.Put (Value (Start .. Last));
end Print_Field;
-- ------------------------------
-- Print the title for the given field.
-- ------------------------------
overriding
procedure Print_Title (Console : in out Console_Type;
Field : in Field_Type;
Title : in String) is
use type Ada.Text_IO.Count;
Pos : constant Ada.Text_IO.Count := Ada.Text_IO.Count (Console.Cols (Field));
begin
if Pos > 1 then
Ada.Text_IO.Set_Col (Pos);
end if;
Ada.Text_IO.Put (Title);
end Print_Title;
-- ------------------------------
-- Start a new title in a report.
-- ------------------------------
overriding
procedure Start_Title (Console : in out Console_Type) is
begin
Console.Field_Count := 0;
Console.Sizes := (others => 0);
Console.Cols := (others => 1);
end Start_Title;
-- ------------------------------
-- Finish a new title in a report.
-- ------------------------------
procedure End_Title (Console : in out Console_Type) is
pragma Unreferenced (Console);
begin
Ada.Text_IO.New_Line;
end End_Title;
-- ------------------------------
-- Start a new row in a report.
-- ------------------------------
overriding
procedure Start_Row (Console : in out Console_Type) is
pragma Unreferenced (Console);
begin
null;
end Start_Row;
-- ------------------------------
-- Finish a new row in a report.
-- ------------------------------
overriding
procedure End_Row (Console : in out Console_Type) is
pragma Unreferenced (Console);
begin
Ada.Text_IO.New_Line;
end End_Row;
end Util.Commands.Consoles.Text;
|
DrenfongWong/tkm-rpc | Ada | 401 | ads | with Ada.Unchecked_Conversion;
package Tkmrpc.Request.Ike.Cc_Check_Ca.Convert is
function To_Request is new Ada.Unchecked_Conversion (
Source => Cc_Check_Ca.Request_Type,
Target => Request.Data_Type);
function From_Request is new Ada.Unchecked_Conversion (
Source => Request.Data_Type,
Target => Cc_Check_Ca.Request_Type);
end Tkmrpc.Request.Ike.Cc_Check_Ca.Convert;
|
gonma95/RealTimeSystem_CarDistrations | Ada | 4,223 | adb | -- Gonzalo Martin Rodriguez
-- Ivan Fernandez Samaniego
with Kernel.Serial_Output; use Kernel.Serial_Output;
with Ada.Real_Time; use Ada.Real_Time;
with System; use System;
with Tools; use Tools;
with devices; use devices;
with Driver; use Driver;
with Ada.Interrupts.Names;
package body State is
task body Display is
Siguiente_Instante: Time;
begin
Siguiente_Instante := Big_Bang + Milliseconds(1000);
loop
Starting_Notice ("Display");
Symptoms.Show_Symptoms;
Measures.Show_Distance;
Measures.Show_Speed;
Finishing_Notice ("Display");
delay until Siguiente_Instante;
Siguiente_Instante := Siguiente_Instante + Milliseconds(1000);
end loop;
end Display;
task body Risks is
Head_Symptom: Boolean := False;
Volantazo: Boolean := False;
Distancia_Insegura: Boolean := False;
Distancia_Imprudente: Boolean := False;
Peligro_Colision: Boolean := False;
Speed: Speed_Samples_Type := 0;
Siguiente_Instante: Time;
Mode: integer := 1;
begin
Siguiente_Instante := Big_Bang + Milliseconds(150);
loop
delay until Siguiente_Instante;
Siguiente_Instante := Siguiente_Instante + Milliseconds(150);
Starting_Notice ("Risks");
Symptoms.Read_Steering_Symptom (Volantazo);
Symptoms.Read_Head_Symptom (Head_Symptom);
Symptoms.Read_Distancia_Insegura (Distancia_Insegura);
Symptoms.Read_Distancia_Imprudente (Distancia_Imprudente);
Symptoms.Read_Peligro_Colision (Peligro_Colision);
Measures.Read_Speed (Speed);
Operation_Mode.Read_Mode (Mode);
if Volantazo and Mode < 3 and not Head_Symptom and not Distancia_Imprudente and not Distancia_Insegura and not Peligro_Colision then
Beep (1);
end if;
if Head_Symptom and Mode < 3 and Speed > 70 then
Beep (3);
elsif Head_Symptom and Mode < 3 then
Beep (2);
end if;
if Peligro_Colision and Mode < 3 and Head_Symptom then
Beep (5);
Activate_Brake;
elsif Distancia_Imprudente and Mode = 1 then
Light (On);
Beep (4);
elsif Distancia_Insegura and Mode = 1 then
Light (On);
elsif Mode /= 3 then
Light (Off);
end if;
Finishing_Notice ("Risks");
end loop;
end Risks;
task body Sporadic_Task is
Peligro_Colision: Boolean;
Head_Symptom: Boolean;
Mode: integer := 1;
begin
loop
Interruption_Handler.Change_Mode;
Starting_Notice("Iniciando tarea esporadica");
Operation_Mode.Read_Mode (Mode);
Symptoms.Read_Peligro_Colision (Peligro_Colision);
Symptoms.Read_Head_Symptom (Head_Symptom);
if Mode = 1 and not Peligro_Colision then
Operation_Mode.Write_Mode (2);
elsif Mode = 2 and not Peligro_Colision and not Head_Symptom then
Light (Off);
Operation_Mode.Write_Mode (3);
elsif Mode = 3 then
Operation_Mode.Write_Mode (1);
end if;
Put (": MODE :");
Put (Integer'Image(Mode));
Finishing_Notice("Finishing tarea esporadica");
end loop;
end Sporadic_Task;
protected body Operation_Mode is
procedure Write_Mode (Value: in integer) is
begin
Mode := Value;
Execution_Time(Milliseconds(2));
end Write_Mode;
procedure Read_Mode (Value: out integer) is
begin
Value := Mode;
end Read_Mode;
end Operation_Mode;
protected body Interruption_Handler is
procedure Validate_Entry is
begin
Enter := True;
Execution_Time(Milliseconds(2));
end Validate_Entry;
entry Change_Mode when Enter is
begin
Enter := False;
end Change_Mode;
end Interruption_Handler;
begin
null;
end State;
|
AdaCore/gpr | Ada | 20 | ads | package D is
end D;
|
reznikmm/matreshka | Ada | 46,390 | 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_Opaque_Behaviors;
with AMF.String_Collections;
with AMF.UML.Behavioral_Features;
with AMF.UML.Behaviored_Classifiers;
with AMF.UML.Behaviors.Collections;
with AMF.UML.Classes.Collections;
with AMF.UML.Classifier_Template_Parameters;
with AMF.UML.Classifiers.Collections;
with AMF.UML.Collaboration_Uses.Collections;
with AMF.UML.Connectable_Elements.Collections;
with AMF.UML.Connectors.Collections;
with AMF.UML.Constraints.Collections;
with AMF.UML.Dependencies.Collections;
with AMF.UML.Element_Imports.Collections;
with AMF.UML.Extensions.Collections;
with AMF.UML.Features.Collections;
with AMF.UML.Function_Behaviors;
with AMF.UML.Generalization_Sets.Collections;
with AMF.UML.Generalizations.Collections;
with AMF.UML.Interface_Realizations.Collections;
with AMF.UML.Named_Elements.Collections;
with AMF.UML.Namespaces;
with AMF.UML.Operations.Collections;
with AMF.UML.Package_Imports.Collections;
with AMF.UML.Packageable_Elements.Collections;
with AMF.UML.Packages.Collections;
with AMF.UML.Parameter_Sets.Collections;
with AMF.UML.Parameterable_Elements.Collections;
with AMF.UML.Parameters.Collections;
with AMF.UML.Ports.Collections;
with AMF.UML.Properties.Collections;
with AMF.UML.Receptions.Collections;
with AMF.UML.Redefinable_Elements.Collections;
with AMF.UML.Redefinable_Template_Signatures;
with AMF.UML.String_Expressions;
with AMF.UML.Substitutions.Collections;
with AMF.UML.Template_Bindings.Collections;
with AMF.UML.Template_Parameters;
with AMF.UML.Template_Signatures;
with AMF.UML.Types;
with AMF.UML.Use_Cases.Collections;
with AMF.Visitors;
package AMF.Internals.UML_Function_Behaviors is
type UML_Function_Behavior_Proxy is
limited new AMF.Internals.UML_Opaque_Behaviors.UML_Opaque_Behavior_Proxy
and AMF.UML.Function_Behaviors.UML_Function_Behavior with null record;
overriding function Get_Body
(Self : not null access constant UML_Function_Behavior_Proxy)
return AMF.String_Collections.Sequence_Of_String;
-- Getter of OpaqueBehavior::body.
--
-- Specifies the behavior in one or more languages.
overriding function Get_Language
(Self : not null access constant UML_Function_Behavior_Proxy)
return AMF.String_Collections.Ordered_Set_Of_String;
-- Getter of OpaqueBehavior::language.
--
-- Languages the body strings use in the same order as the body strings.
overriding function Get_Context
(Self : not null access constant UML_Function_Behavior_Proxy)
return AMF.UML.Behaviored_Classifiers.UML_Behaviored_Classifier_Access;
-- Getter of Behavior::context.
--
-- The classifier that is the context for the execution of the behavior.
-- If the behavior is owned by a BehavioredClassifier, that classifier is
-- the context. Otherwise, the context is the first BehavioredClassifier
-- reached by following the chain of owner relationships. For example,
-- following this algorithm, the context of an entry action in a state
-- machine is the classifier that owns the state machine. The features of
-- the context classifier as well as the elements visible to the context
-- classifier are visible to the behavior.
overriding function Get_Is_Reentrant
(Self : not null access constant UML_Function_Behavior_Proxy)
return Boolean;
-- Getter of Behavior::isReentrant.
--
-- Tells whether the behavior can be invoked while it is still executing
-- from a previous invocation.
overriding procedure Set_Is_Reentrant
(Self : not null access UML_Function_Behavior_Proxy;
To : Boolean);
-- Setter of Behavior::isReentrant.
--
-- Tells whether the behavior can be invoked while it is still executing
-- from a previous invocation.
overriding function Get_Owned_Parameter
(Self : not null access constant UML_Function_Behavior_Proxy)
return AMF.UML.Parameters.Collections.Ordered_Set_Of_UML_Parameter;
-- Getter of Behavior::ownedParameter.
--
-- References a list of parameters to the behavior which describes the
-- order and type of arguments that can be given when the behavior is
-- invoked and of the values which will be returned when the behavior
-- completes its execution.
overriding function Get_Owned_Parameter_Set
(Self : not null access constant UML_Function_Behavior_Proxy)
return AMF.UML.Parameter_Sets.Collections.Set_Of_UML_Parameter_Set;
-- Getter of Behavior::ownedParameterSet.
--
-- The ParameterSets owned by this Behavior.
overriding function Get_Postcondition
(Self : not null access constant UML_Function_Behavior_Proxy)
return AMF.UML.Constraints.Collections.Set_Of_UML_Constraint;
-- Getter of Behavior::postcondition.
--
-- An optional set of Constraints specifying what is fulfilled after the
-- execution of the behavior is completed, if its precondition was
-- fulfilled before its invocation.
overriding function Get_Precondition
(Self : not null access constant UML_Function_Behavior_Proxy)
return AMF.UML.Constraints.Collections.Set_Of_UML_Constraint;
-- Getter of Behavior::precondition.
--
-- An optional set of Constraints specifying what must be fulfilled when
-- the behavior is invoked.
overriding function Get_Redefined_Behavior
(Self : not null access constant UML_Function_Behavior_Proxy)
return AMF.UML.Behaviors.Collections.Set_Of_UML_Behavior;
-- Getter of Behavior::redefinedBehavior.
--
-- References a behavior that this behavior redefines. A subtype of
-- Behavior may redefine any other subtype of Behavior. If the behavior
-- implements a behavioral feature, it replaces the redefined behavior. If
-- the behavior is a classifier behavior, it extends the redefined
-- behavior.
overriding function Get_Specification
(Self : not null access constant UML_Function_Behavior_Proxy)
return AMF.UML.Behavioral_Features.UML_Behavioral_Feature_Access;
-- Getter of Behavior::specification.
--
-- Designates a behavioral feature that the behavior implements. The
-- behavioral feature must be owned by the classifier that owns the
-- behavior or be inherited by it. The parameters of the behavioral
-- feature and the implementing behavior must match. A behavior does not
-- need to have a specification, in which case it either is the classifer
-- behavior of a BehavioredClassifier or it can only be invoked by another
-- behavior of the classifier.
overriding procedure Set_Specification
(Self : not null access UML_Function_Behavior_Proxy;
To : AMF.UML.Behavioral_Features.UML_Behavioral_Feature_Access);
-- Setter of Behavior::specification.
--
-- Designates a behavioral feature that the behavior implements. The
-- behavioral feature must be owned by the classifier that owns the
-- behavior or be inherited by it. The parameters of the behavioral
-- feature and the implementing behavior must match. A behavior does not
-- need to have a specification, in which case it either is the classifer
-- behavior of a BehavioredClassifier or it can only be invoked by another
-- behavior of the classifier.
overriding function Get_Extension
(Self : not null access constant UML_Function_Behavior_Proxy)
return AMF.UML.Extensions.Collections.Set_Of_UML_Extension;
-- Getter of Class::extension.
--
-- References the Extensions that specify additional properties of the
-- metaclass. The property is derived from the extensions whose memberEnds
-- are typed by the Class.
overriding function Get_Is_Abstract
(Self : not null access constant UML_Function_Behavior_Proxy)
return Boolean;
-- Getter of Class::isAbstract.
--
-- True when a class is abstract.
-- If true, the Classifier does not provide a complete declaration and can
-- typically not be instantiated. An abstract classifier is intended to be
-- used by other classifiers e.g. as the target of general
-- metarelationships or generalization relationships.
overriding function Get_Is_Active
(Self : not null access constant UML_Function_Behavior_Proxy)
return Boolean;
-- Getter of Class::isActive.
--
-- Determines whether an object specified by this class is active or not.
-- If true, then the owning class is referred to as an active class. If
-- false, then such a class is referred to as a passive class.
overriding procedure Set_Is_Active
(Self : not null access UML_Function_Behavior_Proxy;
To : Boolean);
-- Setter of Class::isActive.
--
-- Determines whether an object specified by this class is active or not.
-- If true, then the owning class is referred to as an active class. If
-- false, then such a class is referred to as a passive class.
overriding function Get_Nested_Classifier
(Self : not null access constant UML_Function_Behavior_Proxy)
return AMF.UML.Classifiers.Collections.Ordered_Set_Of_UML_Classifier;
-- Getter of Class::nestedClassifier.
--
-- References all the Classifiers that are defined (nested) within the
-- Class.
overriding function Get_Owned_Attribute
(Self : not null access constant UML_Function_Behavior_Proxy)
return AMF.UML.Properties.Collections.Ordered_Set_Of_UML_Property;
-- Getter of Class::ownedAttribute.
--
-- The attributes (i.e. the properties) owned by the class.
overriding function Get_Owned_Operation
(Self : not null access constant UML_Function_Behavior_Proxy)
return AMF.UML.Operations.Collections.Ordered_Set_Of_UML_Operation;
-- Getter of Class::ownedOperation.
--
-- The operations owned by the class.
overriding function Get_Owned_Reception
(Self : not null access constant UML_Function_Behavior_Proxy)
return AMF.UML.Receptions.Collections.Set_Of_UML_Reception;
-- Getter of Class::ownedReception.
--
-- Receptions that objects of this class are willing to accept.
overriding function Get_Super_Class
(Self : not null access constant UML_Function_Behavior_Proxy)
return AMF.UML.Classes.Collections.Set_Of_UML_Class;
-- Getter of Class::superClass.
--
-- This gives the superclasses of a class.
overriding function Get_Classifier_Behavior
(Self : not null access constant UML_Function_Behavior_Proxy)
return AMF.UML.Behaviors.UML_Behavior_Access;
-- Getter of BehavioredClassifier::classifierBehavior.
--
-- A behavior specification that specifies the behavior of the classifier
-- itself.
overriding procedure Set_Classifier_Behavior
(Self : not null access UML_Function_Behavior_Proxy;
To : AMF.UML.Behaviors.UML_Behavior_Access);
-- Setter of BehavioredClassifier::classifierBehavior.
--
-- A behavior specification that specifies the behavior of the classifier
-- itself.
overriding function Get_Interface_Realization
(Self : not null access constant UML_Function_Behavior_Proxy)
return AMF.UML.Interface_Realizations.Collections.Set_Of_UML_Interface_Realization;
-- Getter of BehavioredClassifier::interfaceRealization.
--
-- The set of InterfaceRealizations owned by the BehavioredClassifier.
-- Interface realizations reference the Interfaces of which the
-- BehavioredClassifier is an implementation.
overriding function Get_Owned_Behavior
(Self : not null access constant UML_Function_Behavior_Proxy)
return AMF.UML.Behaviors.Collections.Set_Of_UML_Behavior;
-- Getter of BehavioredClassifier::ownedBehavior.
--
-- References behavior specifications owned by a classifier.
overriding function Get_Attribute
(Self : not null access constant UML_Function_Behavior_Proxy)
return AMF.UML.Properties.Collections.Set_Of_UML_Property;
-- Getter of Classifier::attribute.
--
-- Refers to all of the Properties that are direct (i.e. not inherited or
-- imported) attributes of the classifier.
overriding function Get_Collaboration_Use
(Self : not null access constant UML_Function_Behavior_Proxy)
return AMF.UML.Collaboration_Uses.Collections.Set_Of_UML_Collaboration_Use;
-- Getter of Classifier::collaborationUse.
--
-- References the collaboration uses owned by the classifier.
overriding function Get_Feature
(Self : not null access constant UML_Function_Behavior_Proxy)
return AMF.UML.Features.Collections.Set_Of_UML_Feature;
-- Getter of Classifier::feature.
--
-- Specifies each feature defined in the classifier.
-- Note that there may be members of the Classifier that are of the type
-- Feature but are not included in this association, e.g. inherited
-- features.
overriding function Get_General
(Self : not null access constant UML_Function_Behavior_Proxy)
return AMF.UML.Classifiers.Collections.Set_Of_UML_Classifier;
-- Getter of Classifier::general.
--
-- Specifies the general Classifiers for this Classifier.
-- References the general classifier in the Generalization relationship.
overriding function Get_Generalization
(Self : not null access constant UML_Function_Behavior_Proxy)
return AMF.UML.Generalizations.Collections.Set_Of_UML_Generalization;
-- Getter of Classifier::generalization.
--
-- Specifies the Generalization relationships for this Classifier. These
-- Generalizations navigaten to more general classifiers in the
-- generalization hierarchy.
overriding function Get_Inherited_Member
(Self : not null access constant UML_Function_Behavior_Proxy)
return AMF.UML.Named_Elements.Collections.Set_Of_UML_Named_Element;
-- Getter of Classifier::inheritedMember.
--
-- Specifies all elements inherited by this classifier from the general
-- classifiers.
overriding function Get_Is_Final_Specialization
(Self : not null access constant UML_Function_Behavior_Proxy)
return Boolean;
-- Getter of Classifier::isFinalSpecialization.
--
-- If true, the Classifier cannot be specialized by generalization. Note
-- that this property is preserved through package merge operations; that
-- is, the capability to specialize a Classifier (i.e.,
-- isFinalSpecialization =false) must be preserved in the resulting
-- Classifier of a package merge operation where a Classifier with
-- isFinalSpecialization =false is merged with a matching Classifier with
-- isFinalSpecialization =true: the resulting Classifier will have
-- isFinalSpecialization =false.
overriding procedure Set_Is_Final_Specialization
(Self : not null access UML_Function_Behavior_Proxy;
To : Boolean);
-- Setter of Classifier::isFinalSpecialization.
--
-- If true, the Classifier cannot be specialized by generalization. Note
-- that this property is preserved through package merge operations; that
-- is, the capability to specialize a Classifier (i.e.,
-- isFinalSpecialization =false) must be preserved in the resulting
-- Classifier of a package merge operation where a Classifier with
-- isFinalSpecialization =false is merged with a matching Classifier with
-- isFinalSpecialization =true: the resulting Classifier will have
-- isFinalSpecialization =false.
overriding function Get_Owned_Template_Signature
(Self : not null access constant UML_Function_Behavior_Proxy)
return AMF.UML.Redefinable_Template_Signatures.UML_Redefinable_Template_Signature_Access;
-- Getter of Classifier::ownedTemplateSignature.
--
-- The optional template signature specifying the formal template
-- parameters.
overriding procedure Set_Owned_Template_Signature
(Self : not null access UML_Function_Behavior_Proxy;
To : AMF.UML.Redefinable_Template_Signatures.UML_Redefinable_Template_Signature_Access);
-- Setter of Classifier::ownedTemplateSignature.
--
-- The optional template signature specifying the formal template
-- parameters.
overriding function Get_Owned_Use_Case
(Self : not null access constant UML_Function_Behavior_Proxy)
return AMF.UML.Use_Cases.Collections.Set_Of_UML_Use_Case;
-- Getter of Classifier::ownedUseCase.
--
-- References the use cases owned by this classifier.
overriding function Get_Powertype_Extent
(Self : not null access constant UML_Function_Behavior_Proxy)
return AMF.UML.Generalization_Sets.Collections.Set_Of_UML_Generalization_Set;
-- Getter of Classifier::powertypeExtent.
--
-- Designates the GeneralizationSet of which the associated Classifier is
-- a power type.
overriding function Get_Redefined_Classifier
(Self : not null access constant UML_Function_Behavior_Proxy)
return AMF.UML.Classifiers.Collections.Set_Of_UML_Classifier;
-- Getter of Classifier::redefinedClassifier.
--
-- References the Classifiers that are redefined by this Classifier.
overriding function Get_Representation
(Self : not null access constant UML_Function_Behavior_Proxy)
return AMF.UML.Collaboration_Uses.UML_Collaboration_Use_Access;
-- Getter of Classifier::representation.
--
-- References a collaboration use which indicates the collaboration that
-- represents this classifier.
overriding procedure Set_Representation
(Self : not null access UML_Function_Behavior_Proxy;
To : AMF.UML.Collaboration_Uses.UML_Collaboration_Use_Access);
-- Setter of Classifier::representation.
--
-- References a collaboration use which indicates the collaboration that
-- represents this classifier.
overriding function Get_Substitution
(Self : not null access constant UML_Function_Behavior_Proxy)
return AMF.UML.Substitutions.Collections.Set_Of_UML_Substitution;
-- Getter of Classifier::substitution.
--
-- References the substitutions that are owned by this Classifier.
overriding function Get_Template_Parameter
(Self : not null access constant UML_Function_Behavior_Proxy)
return AMF.UML.Classifier_Template_Parameters.UML_Classifier_Template_Parameter_Access;
-- Getter of Classifier::templateParameter.
--
-- The template parameter that exposes this element as a formal parameter.
overriding procedure Set_Template_Parameter
(Self : not null access UML_Function_Behavior_Proxy;
To : AMF.UML.Classifier_Template_Parameters.UML_Classifier_Template_Parameter_Access);
-- Setter of Classifier::templateParameter.
--
-- The template parameter that exposes this element as a formal parameter.
overriding function Get_Use_Case
(Self : not null access constant UML_Function_Behavior_Proxy)
return AMF.UML.Use_Cases.Collections.Set_Of_UML_Use_Case;
-- Getter of Classifier::useCase.
--
-- The set of use cases for which this Classifier is the subject.
overriding function Get_Element_Import
(Self : not null access constant UML_Function_Behavior_Proxy)
return AMF.UML.Element_Imports.Collections.Set_Of_UML_Element_Import;
-- Getter of Namespace::elementImport.
--
-- References the ElementImports owned by the Namespace.
overriding function Get_Imported_Member
(Self : not null access constant UML_Function_Behavior_Proxy)
return AMF.UML.Packageable_Elements.Collections.Set_Of_UML_Packageable_Element;
-- Getter of Namespace::importedMember.
--
-- References the PackageableElements that are members of this Namespace
-- as a result of either PackageImports or ElementImports.
overriding function Get_Member
(Self : not null access constant UML_Function_Behavior_Proxy)
return AMF.UML.Named_Elements.Collections.Set_Of_UML_Named_Element;
-- Getter of Namespace::member.
--
-- A collection of NamedElements identifiable within the Namespace, either
-- by being owned or by being introduced by importing or inheritance.
overriding function Get_Owned_Member
(Self : not null access constant UML_Function_Behavior_Proxy)
return AMF.UML.Named_Elements.Collections.Set_Of_UML_Named_Element;
-- Getter of Namespace::ownedMember.
--
-- A collection of NamedElements owned by the Namespace.
overriding function Get_Owned_Rule
(Self : not null access constant UML_Function_Behavior_Proxy)
return AMF.UML.Constraints.Collections.Set_Of_UML_Constraint;
-- Getter of Namespace::ownedRule.
--
-- Specifies a set of Constraints owned by this Namespace.
overriding function Get_Package_Import
(Self : not null access constant UML_Function_Behavior_Proxy)
return AMF.UML.Package_Imports.Collections.Set_Of_UML_Package_Import;
-- Getter of Namespace::packageImport.
--
-- References the PackageImports owned by the Namespace.
overriding function Get_Client_Dependency
(Self : not null access constant UML_Function_Behavior_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_Function_Behavior_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_Function_Behavior_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_Function_Behavior_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_Function_Behavior_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 Get_Package
(Self : not null access constant UML_Function_Behavior_Proxy)
return AMF.UML.Packages.UML_Package_Access;
-- Getter of Type::package.
--
-- Specifies the owning package of this classifier, if any.
overriding procedure Set_Package
(Self : not null access UML_Function_Behavior_Proxy;
To : AMF.UML.Packages.UML_Package_Access);
-- Setter of Type::package.
--
-- Specifies the owning package of this classifier, if any.
overriding function Get_Owning_Template_Parameter
(Self : not null access constant UML_Function_Behavior_Proxy)
return AMF.UML.Template_Parameters.UML_Template_Parameter_Access;
-- Getter of ParameterableElement::owningTemplateParameter.
--
-- The formal template parameter that owns this element.
overriding procedure Set_Owning_Template_Parameter
(Self : not null access UML_Function_Behavior_Proxy;
To : AMF.UML.Template_Parameters.UML_Template_Parameter_Access);
-- Setter of ParameterableElement::owningTemplateParameter.
--
-- The formal template parameter that owns this element.
overriding function Get_Template_Parameter
(Self : not null access constant UML_Function_Behavior_Proxy)
return AMF.UML.Template_Parameters.UML_Template_Parameter_Access;
-- Getter of ParameterableElement::templateParameter.
--
-- The template parameter that exposes this element as a formal parameter.
overriding procedure Set_Template_Parameter
(Self : not null access UML_Function_Behavior_Proxy;
To : AMF.UML.Template_Parameters.UML_Template_Parameter_Access);
-- Setter of ParameterableElement::templateParameter.
--
-- The template parameter that exposes this element as a formal parameter.
overriding function Get_Owned_Template_Signature
(Self : not null access constant UML_Function_Behavior_Proxy)
return AMF.UML.Template_Signatures.UML_Template_Signature_Access;
-- Getter of TemplateableElement::ownedTemplateSignature.
--
-- The optional template signature specifying the formal template
-- parameters.
overriding procedure Set_Owned_Template_Signature
(Self : not null access UML_Function_Behavior_Proxy;
To : AMF.UML.Template_Signatures.UML_Template_Signature_Access);
-- Setter of TemplateableElement::ownedTemplateSignature.
--
-- The optional template signature specifying the formal template
-- parameters.
overriding function Get_Template_Binding
(Self : not null access constant UML_Function_Behavior_Proxy)
return AMF.UML.Template_Bindings.Collections.Set_Of_UML_Template_Binding;
-- Getter of TemplateableElement::templateBinding.
--
-- The optional bindings from this element to templates.
overriding function Get_Is_Leaf
(Self : not null access constant UML_Function_Behavior_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_Function_Behavior_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_Function_Behavior_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_Function_Behavior_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_Owned_Port
(Self : not null access constant UML_Function_Behavior_Proxy)
return AMF.UML.Ports.Collections.Set_Of_UML_Port;
-- Getter of EncapsulatedClassifier::ownedPort.
--
-- References a set of ports that an encapsulated classifier owns.
overriding function Get_Owned_Connector
(Self : not null access constant UML_Function_Behavior_Proxy)
return AMF.UML.Connectors.Collections.Set_Of_UML_Connector;
-- Getter of StructuredClassifier::ownedConnector.
--
-- References the connectors owned by the classifier.
overriding function Get_Part
(Self : not null access constant UML_Function_Behavior_Proxy)
return AMF.UML.Properties.Collections.Set_Of_UML_Property;
-- Getter of StructuredClassifier::part.
--
-- References the properties specifying instances that the classifier owns
-- by composition. This association is derived, selecting those owned
-- properties where isComposite is true.
overriding function Get_Role
(Self : not null access constant UML_Function_Behavior_Proxy)
return AMF.UML.Connectable_Elements.Collections.Set_Of_UML_Connectable_Element;
-- Getter of StructuredClassifier::role.
--
-- References the roles that instances may play in this classifier.
overriding function Context
(Self : not null access constant UML_Function_Behavior_Proxy)
return AMF.UML.Behaviored_Classifiers.UML_Behaviored_Classifier_Access;
-- Operation Behavior::context.
--
-- Missing derivation for Behavior::/context : BehavioredClassifier
overriding function Extension
(Self : not null access constant UML_Function_Behavior_Proxy)
return AMF.UML.Extensions.Collections.Set_Of_UML_Extension;
-- Operation Class::extension.
--
-- Missing derivation for Class::/extension : Extension
overriding function Inherit
(Self : not null access constant UML_Function_Behavior_Proxy;
Inhs : AMF.UML.Named_Elements.Collections.Set_Of_UML_Named_Element)
return AMF.UML.Named_Elements.Collections.Set_Of_UML_Named_Element;
-- Operation Class::inherit.
--
-- The inherit operation is overridden to exclude redefined properties.
overriding function Super_Class
(Self : not null access constant UML_Function_Behavior_Proxy)
return AMF.UML.Classes.Collections.Set_Of_UML_Class;
-- Operation Class::superClass.
--
-- Missing derivation for Class::/superClass : Class
overriding function All_Features
(Self : not null access constant UML_Function_Behavior_Proxy)
return AMF.UML.Features.Collections.Set_Of_UML_Feature;
-- Operation Classifier::allFeatures.
--
-- The query allFeatures() gives all of the features in the namespace of
-- the classifier. In general, through mechanisms such as inheritance,
-- this will be a larger set than feature.
overriding function Conforms_To
(Self : not null access constant UML_Function_Behavior_Proxy;
Other : AMF.UML.Classifiers.UML_Classifier_Access)
return Boolean;
-- Operation Classifier::conformsTo.
--
-- 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.
overriding function General
(Self : not null access constant UML_Function_Behavior_Proxy)
return AMF.UML.Classifiers.Collections.Set_Of_UML_Classifier;
-- Operation Classifier::general.
--
-- The general classifiers are the classifiers referenced by the
-- generalization relationships.
overriding function Has_Visibility_Of
(Self : not null access constant UML_Function_Behavior_Proxy;
N : AMF.UML.Named_Elements.UML_Named_Element_Access)
return Boolean;
-- Operation Classifier::hasVisibilityOf.
--
-- The query hasVisibilityOf() determines whether a named element is
-- visible in the classifier. By default all are visible. It is only
-- called when the argument is something owned by a parent.
overriding function Inheritable_Members
(Self : not null access constant UML_Function_Behavior_Proxy;
C : AMF.UML.Classifiers.UML_Classifier_Access)
return AMF.UML.Named_Elements.Collections.Set_Of_UML_Named_Element;
-- Operation Classifier::inheritableMembers.
--
-- The query inheritableMembers() gives all of the members of a classifier
-- that may be inherited in one of its descendants, subject to whatever
-- visibility restrictions apply.
overriding function Inherited_Member
(Self : not null access constant UML_Function_Behavior_Proxy)
return AMF.UML.Named_Elements.Collections.Set_Of_UML_Named_Element;
-- Operation Classifier::inheritedMember.
--
-- The inheritedMember association is derived by inheriting the
-- inheritable members of the parents.
-- The inheritedMember association is derived by inheriting the
-- inheritable members of the parents.
overriding function Is_Template
(Self : not null access constant UML_Function_Behavior_Proxy)
return Boolean;
-- Operation Classifier::isTemplate.
--
-- The query isTemplate() returns whether this templateable element is
-- actually a template.
overriding function May_Specialize_Type
(Self : not null access constant UML_Function_Behavior_Proxy;
C : AMF.UML.Classifiers.UML_Classifier_Access)
return Boolean;
-- Operation Classifier::maySpecializeType.
--
-- The query maySpecializeType() determines whether this classifier may
-- have a generalization relationship to classifiers of the specified
-- type. By default a classifier may specialize classifiers of the same or
-- a more general type. It is intended to be redefined by classifiers that
-- have different specialization constraints.
overriding function Exclude_Collisions
(Self : not null access constant UML_Function_Behavior_Proxy;
Imps : AMF.UML.Packageable_Elements.Collections.Set_Of_UML_Packageable_Element)
return AMF.UML.Packageable_Elements.Collections.Set_Of_UML_Packageable_Element;
-- Operation Namespace::excludeCollisions.
--
-- The query excludeCollisions() excludes from a set of
-- PackageableElements any that would not be distinguishable from each
-- other in this namespace.
overriding function Get_Names_Of_Member
(Self : not null access constant UML_Function_Behavior_Proxy;
Element : AMF.UML.Named_Elements.UML_Named_Element_Access)
return AMF.String_Collections.Set_Of_String;
-- Operation Namespace::getNamesOfMember.
--
-- The query getNamesOfMember() takes importing into account. It gives
-- back the set of names that an element would have in an importing
-- namespace, either because it is owned, or if not owned then imported
-- individually, or if not individually then from a package.
-- The query getNamesOfMember() gives a set of all of the names that a
-- member would have in a Namespace. In general a member can have multiple
-- names in a Namespace if it is imported more than once with different
-- aliases. The query takes account of importing. It gives back the set of
-- names that an element would have in an importing namespace, either
-- because it is owned, or if not owned then imported individually, or if
-- not individually then from a package.
overriding function Import_Members
(Self : not null access constant UML_Function_Behavior_Proxy;
Imps : AMF.UML.Packageable_Elements.Collections.Set_Of_UML_Packageable_Element)
return AMF.UML.Packageable_Elements.Collections.Set_Of_UML_Packageable_Element;
-- Operation Namespace::importMembers.
--
-- The query importMembers() defines which of a set of PackageableElements
-- are actually imported into the namespace. This excludes hidden ones,
-- i.e., those which have names that conflict with names of owned members,
-- and also excludes elements which would have the same name when imported.
overriding function Imported_Member
(Self : not null access constant UML_Function_Behavior_Proxy)
return AMF.UML.Packageable_Elements.Collections.Set_Of_UML_Packageable_Element;
-- Operation Namespace::importedMember.
--
-- The importedMember property is derived from the ElementImports and the
-- PackageImports. References the PackageableElements that are members of
-- this Namespace as a result of either PackageImports or ElementImports.
overriding function Members_Are_Distinguishable
(Self : not null access constant UML_Function_Behavior_Proxy)
return Boolean;
-- Operation Namespace::membersAreDistinguishable.
--
-- The Boolean query membersAreDistinguishable() determines whether all of
-- the namespace's members are distinguishable within it.
overriding function Owned_Member
(Self : not null access constant UML_Function_Behavior_Proxy)
return AMF.UML.Named_Elements.Collections.Set_Of_UML_Named_Element;
-- Operation Namespace::ownedMember.
--
-- Missing derivation for Namespace::/ownedMember : NamedElement
overriding function All_Owning_Packages
(Self : not null access constant UML_Function_Behavior_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_Function_Behavior_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_Function_Behavior_Proxy)
return AMF.UML.Namespaces.UML_Namespace_Access;
-- Operation NamedElement::namespace.
--
-- Missing derivation for NamedElement::/namespace : Namespace
overriding function Conforms_To
(Self : not null access constant UML_Function_Behavior_Proxy;
Other : AMF.UML.Types.UML_Type_Access)
return Boolean;
-- Operation Type::conformsTo.
--
-- The query conformsTo() gives true for a type that conforms to another.
-- By default, two types do not conform to each other. This query is
-- intended to be redefined for specific conformance situations.
overriding function Is_Compatible_With
(Self : not null access constant UML_Function_Behavior_Proxy;
P : AMF.UML.Parameterable_Elements.UML_Parameterable_Element_Access)
return Boolean;
-- Operation ParameterableElement::isCompatibleWith.
--
-- The query isCompatibleWith() determines if this parameterable element
-- is compatible with the specified parameterable element. By default
-- parameterable element P is compatible with parameterable element Q if
-- the kind of P is the same or a subtype as the kind of Q. Subclasses
-- should override this operation to specify different compatibility
-- constraints.
overriding function Is_Template_Parameter
(Self : not null access constant UML_Function_Behavior_Proxy)
return Boolean;
-- Operation ParameterableElement::isTemplateParameter.
--
-- The query isTemplateParameter() determines if this parameterable
-- element is exposed as a formal template parameter.
overriding function Parameterable_Elements
(Self : not null access constant UML_Function_Behavior_Proxy)
return AMF.UML.Parameterable_Elements.Collections.Set_Of_UML_Parameterable_Element;
-- Operation TemplateableElement::parameterableElements.
--
-- The query parameterableElements() returns the set of elements that may
-- be used as the parametered elements for a template parameter of this
-- templateable element. By default, this set includes all the owned
-- elements. Subclasses may override this operation if they choose to
-- restrict the set of parameterable elements.
overriding function Is_Consistent_With
(Self : not null access constant UML_Function_Behavior_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_Function_Behavior_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 Owned_Port
(Self : not null access constant UML_Function_Behavior_Proxy)
return AMF.UML.Ports.Collections.Set_Of_UML_Port;
-- Operation EncapsulatedClassifier::ownedPort.
--
-- Missing derivation for EncapsulatedClassifier::/ownedPort : Port
overriding function Part
(Self : not null access constant UML_Function_Behavior_Proxy)
return AMF.UML.Properties.Collections.Set_Of_UML_Property;
-- Operation StructuredClassifier::part.
--
-- Missing derivation for StructuredClassifier::/part : Property
overriding procedure Enter_Element
(Self : not null access constant UML_Function_Behavior_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_Function_Behavior_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_Function_Behavior_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_Function_Behaviors;
|
twdroeger/ada-awa | Ada | 42,475 | adb | -----------------------------------------------------------------------
-- AWA.Settings.Models -- AWA.Settings.Models
-----------------------------------------------------------------------
-- File generated by ada-gen DO NOT MODIFY
-- Template used: templates/model/package-body.xhtml
-- Ada Generator: https://ada-gen.googlecode.com/svn/trunk Revision 1095
-----------------------------------------------------------------------
-- Copyright (C) 2019 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;
package body AWA.Settings.Models is
use type ADO.Objects.Object_Record_Access;
use type ADO.Objects.Object_Ref;
pragma Warnings (Off, "formal parameter * is not referenced");
function Setting_Key (Id : in ADO.Identifier) return ADO.Objects.Object_Key is
Result : ADO.Objects.Object_Key (Of_Type => ADO.Objects.KEY_INTEGER,
Of_Class => SETTING_DEF'Access);
begin
ADO.Objects.Set_Value (Result, Id);
return Result;
end Setting_Key;
function Setting_Key (Id : in String) return ADO.Objects.Object_Key is
Result : ADO.Objects.Object_Key (Of_Type => ADO.Objects.KEY_INTEGER,
Of_Class => SETTING_DEF'Access);
begin
ADO.Objects.Set_Value (Result, Id);
return Result;
end Setting_Key;
function "=" (Left, Right : Setting_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 Setting_Ref'Class;
Impl : out Setting_Access) is
Result : ADO.Objects.Object_Record_Access;
begin
Object.Prepare_Modify (Result);
Impl := Setting_Impl (Result.all)'Access;
end Set_Field;
-- Internal method to allocate the Object_Record instance
procedure Allocate (Object : in out Setting_Ref) is
Impl : Setting_Access;
begin
Impl := new Setting_Impl;
ADO.Objects.Set_Object (Object, Impl.all'Access);
end Allocate;
-- ----------------------------------------
-- Data object: Setting
-- ----------------------------------------
procedure Set_Id (Object : in out Setting_Ref;
Value : in ADO.Identifier) is
Impl : Setting_Access;
begin
Set_Field (Object, Impl);
ADO.Objects.Set_Field_Key_Value (Impl.all, 1, Value);
end Set_Id;
function Get_Id (Object : in Setting_Ref)
return ADO.Identifier is
Impl : constant Setting_Access
:= Setting_Impl (Object.Get_Object.all)'Access;
begin
return Impl.Get_Key_Value;
end Get_Id;
procedure Set_Name (Object : in out Setting_Ref;
Value : in String) is
Impl : Setting_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 Setting_Ref;
Value : in Ada.Strings.Unbounded.Unbounded_String) is
Impl : Setting_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 Setting_Ref)
return String is
begin
return Ada.Strings.Unbounded.To_String (Object.Get_Name);
end Get_Name;
function Get_Name (Object : in Setting_Ref)
return Ada.Strings.Unbounded.Unbounded_String is
Impl : constant Setting_Access
:= Setting_Impl (Object.Get_Load_Object.all)'Access;
begin
return Impl.Name;
end Get_Name;
-- Copy of the object.
procedure Copy (Object : in Setting_Ref;
Into : in out Setting_Ref) is
Result : Setting_Ref;
begin
if not Object.Is_Null then
declare
Impl : constant Setting_Access
:= Setting_Impl (Object.Get_Load_Object.all)'Access;
Copy : constant Setting_Access
:= new Setting_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;
procedure Find (Object : in out Setting_Ref;
Session : in out ADO.Sessions.Session'Class;
Query : in ADO.SQL.Query'Class;
Found : out Boolean) is
Impl : constant Setting_Access := new Setting_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 Setting_Ref;
Session : in out ADO.Sessions.Session'Class;
Id : in ADO.Identifier) is
Impl : constant Setting_Access := new Setting_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 Setting_Ref;
Session : in out ADO.Sessions.Session'Class;
Id : in ADO.Identifier;
Found : out Boolean) is
Impl : constant Setting_Access := new Setting_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 Save (Object : in out Setting_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 Setting_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;
procedure Delete (Object : in out Setting_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
-- --------------------
procedure Destroy (Object : access Setting_Impl) is
type Setting_Impl_Ptr is access all Setting_Impl;
procedure Unchecked_Free is new Ada.Unchecked_Deallocation
(Setting_Impl, Setting_Impl_Ptr);
pragma Warnings (Off, "*redundant conversion*");
Ptr : Setting_Impl_Ptr := Setting_Impl (Object.all)'Access;
pragma Warnings (On, "*redundant conversion*");
begin
Unchecked_Free (Ptr);
end Destroy;
procedure Find (Object : in out Setting_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, SETTING_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 Setting_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;
procedure Save (Object : in out Setting_Impl;
Session : in out ADO.Sessions.Master_Session'Class) is
Stmt : ADO.Statements.Update_Statement
:= Session.Create_Statement (SETTING_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;
procedure Create (Object : in out Setting_Impl;
Session : in out ADO.Sessions.Master_Session'Class) is
Query : ADO.Statements.Insert_Statement
:= Session.Create_Statement (SETTING_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;
procedure Delete (Object : in out Setting_Impl;
Session : in out ADO.Sessions.Master_Session'Class) is
Stmt : ADO.Statements.Delete_Statement
:= Session.Create_Statement (SETTING_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 Setting_Ref;
Name : in String) return Util.Beans.Objects.Object is
Obj : ADO.Objects.Object_Record_Access;
Impl : access Setting_Impl;
begin
if From.Is_Null then
return Util.Beans.Objects.Null_Object;
end if;
Obj := From.Get_Load_Object;
Impl := Setting_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 Setting_Vector;
Session : in out ADO.Sessions.Session'Class;
Query : in ADO.SQL.Query'Class) is
Stmt : ADO.Statements.Query_Statement
:= Session.Create_Statement (Query, SETTING_DEF'Access);
begin
Stmt.Execute;
Setting_Vectors.Clear (Object);
while Stmt.Has_Elements loop
declare
Item : Setting_Ref;
Impl : constant Setting_Access := new Setting_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 Setting_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 Global_Setting_Key (Id : in ADO.Identifier) return ADO.Objects.Object_Key is
Result : ADO.Objects.Object_Key (Of_Type => ADO.Objects.KEY_INTEGER,
Of_Class => GLOBAL_SETTING_DEF'Access);
begin
ADO.Objects.Set_Value (Result, Id);
return Result;
end Global_Setting_Key;
function Global_Setting_Key (Id : in String) return ADO.Objects.Object_Key is
Result : ADO.Objects.Object_Key (Of_Type => ADO.Objects.KEY_INTEGER,
Of_Class => GLOBAL_SETTING_DEF'Access);
begin
ADO.Objects.Set_Value (Result, Id);
return Result;
end Global_Setting_Key;
function "=" (Left, Right : Global_Setting_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 Global_Setting_Ref'Class;
Impl : out Global_Setting_Access) is
Result : ADO.Objects.Object_Record_Access;
begin
Object.Prepare_Modify (Result);
Impl := Global_Setting_Impl (Result.all)'Access;
end Set_Field;
-- Internal method to allocate the Object_Record instance
procedure Allocate (Object : in out Global_Setting_Ref) is
Impl : Global_Setting_Access;
begin
Impl := new Global_Setting_Impl;
Impl.Version := 0;
Impl.Server_Id := 0;
ADO.Objects.Set_Object (Object, Impl.all'Access);
end Allocate;
-- ----------------------------------------
-- Data object: Global_Setting
-- ----------------------------------------
procedure Set_Id (Object : in out Global_Setting_Ref;
Value : in ADO.Identifier) is
Impl : Global_Setting_Access;
begin
Set_Field (Object, Impl);
ADO.Objects.Set_Field_Key_Value (Impl.all, 1, Value);
end Set_Id;
function Get_Id (Object : in Global_Setting_Ref)
return ADO.Identifier is
Impl : constant Global_Setting_Access
:= Global_Setting_Impl (Object.Get_Object.all)'Access;
begin
return Impl.Get_Key_Value;
end Get_Id;
procedure Set_Value (Object : in out Global_Setting_Ref;
Value : in String) is
Impl : Global_Setting_Access;
begin
Set_Field (Object, Impl);
ADO.Objects.Set_Field_String (Impl.all, 2, Impl.Value, Value);
end Set_Value;
procedure Set_Value (Object : in out Global_Setting_Ref;
Value : in Ada.Strings.Unbounded.Unbounded_String) is
Impl : Global_Setting_Access;
begin
Set_Field (Object, Impl);
ADO.Objects.Set_Field_Unbounded_String (Impl.all, 2, Impl.Value, Value);
end Set_Value;
function Get_Value (Object : in Global_Setting_Ref)
return String is
begin
return Ada.Strings.Unbounded.To_String (Object.Get_Value);
end Get_Value;
function Get_Value (Object : in Global_Setting_Ref)
return Ada.Strings.Unbounded.Unbounded_String is
Impl : constant Global_Setting_Access
:= Global_Setting_Impl (Object.Get_Load_Object.all)'Access;
begin
return Impl.Value;
end Get_Value;
function Get_Version (Object : in Global_Setting_Ref)
return Integer is
Impl : constant Global_Setting_Access
:= Global_Setting_Impl (Object.Get_Load_Object.all)'Access;
begin
return Impl.Version;
end Get_Version;
procedure Set_Server_Id (Object : in out Global_Setting_Ref;
Value : in Integer) is
Impl : Global_Setting_Access;
begin
Set_Field (Object, Impl);
ADO.Objects.Set_Field_Integer (Impl.all, 4, Impl.Server_Id, Value);
end Set_Server_Id;
function Get_Server_Id (Object : in Global_Setting_Ref)
return Integer is
Impl : constant Global_Setting_Access
:= Global_Setting_Impl (Object.Get_Load_Object.all)'Access;
begin
return Impl.Server_Id;
end Get_Server_Id;
procedure Set_Setting (Object : in out Global_Setting_Ref;
Value : in AWA.Settings.Models.Setting_Ref'Class) is
Impl : Global_Setting_Access;
begin
Set_Field (Object, Impl);
ADO.Objects.Set_Field_Object (Impl.all, 5, Impl.Setting, Value);
end Set_Setting;
function Get_Setting (Object : in Global_Setting_Ref)
return AWA.Settings.Models.Setting_Ref'Class is
Impl : constant Global_Setting_Access
:= Global_Setting_Impl (Object.Get_Load_Object.all)'Access;
begin
return Impl.Setting;
end Get_Setting;
-- Copy of the object.
procedure Copy (Object : in Global_Setting_Ref;
Into : in out Global_Setting_Ref) is
Result : Global_Setting_Ref;
begin
if not Object.Is_Null then
declare
Impl : constant Global_Setting_Access
:= Global_Setting_Impl (Object.Get_Load_Object.all)'Access;
Copy : constant Global_Setting_Access
:= new Global_Setting_Impl;
begin
ADO.Objects.Set_Object (Result, Copy.all'Access);
Copy.Copy (Impl.all);
Copy.Value := Impl.Value;
Copy.Version := Impl.Version;
Copy.Server_Id := Impl.Server_Id;
Copy.Setting := Impl.Setting;
end;
end if;
Into := Result;
end Copy;
procedure Find (Object : in out Global_Setting_Ref;
Session : in out ADO.Sessions.Session'Class;
Query : in ADO.SQL.Query'Class;
Found : out Boolean) is
Impl : constant Global_Setting_Access := new Global_Setting_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 Global_Setting_Ref;
Session : in out ADO.Sessions.Session'Class;
Id : in ADO.Identifier) is
Impl : constant Global_Setting_Access := new Global_Setting_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 Global_Setting_Ref;
Session : in out ADO.Sessions.Session'Class;
Id : in ADO.Identifier;
Found : out Boolean) is
Impl : constant Global_Setting_Access := new Global_Setting_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 Save (Object : in out Global_Setting_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 Global_Setting_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;
procedure Delete (Object : in out Global_Setting_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
-- --------------------
procedure Destroy (Object : access Global_Setting_Impl) is
type Global_Setting_Impl_Ptr is access all Global_Setting_Impl;
procedure Unchecked_Free is new Ada.Unchecked_Deallocation
(Global_Setting_Impl, Global_Setting_Impl_Ptr);
pragma Warnings (Off, "*redundant conversion*");
Ptr : Global_Setting_Impl_Ptr := Global_Setting_Impl (Object.all)'Access;
pragma Warnings (On, "*redundant conversion*");
begin
Unchecked_Free (Ptr);
end Destroy;
procedure Find (Object : in out Global_Setting_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, GLOBAL_SETTING_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 Global_Setting_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;
procedure Save (Object : in out Global_Setting_Impl;
Session : in out ADO.Sessions.Master_Session'Class) is
Stmt : ADO.Statements.Update_Statement
:= Session.Create_Statement (GLOBAL_SETTING_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, -- value
Value => Object.Value);
Object.Clear_Modified (2);
end if;
if Object.Is_Modified (4) then
Stmt.Save_Field (Name => COL_3_2_NAME, -- server_id
Value => Object.Server_Id);
Object.Clear_Modified (4);
end if;
if Object.Is_Modified (5) then
Stmt.Save_Field (Name => COL_4_2_NAME, -- setting_id
Value => Object.Setting);
Object.Clear_Modified (5);
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;
procedure Create (Object : in out Global_Setting_Impl;
Session : in out ADO.Sessions.Master_Session'Class) is
Query : ADO.Statements.Insert_Statement
:= Session.Create_Statement (GLOBAL_SETTING_DEF'Access);
Result : Integer;
begin
Object.Version := 1;
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, -- value
Value => Object.Value);
Query.Save_Field (Name => COL_2_2_NAME, -- version
Value => Object.Version);
Query.Save_Field (Name => COL_3_2_NAME, -- server_id
Value => Object.Server_Id);
Query.Save_Field (Name => COL_4_2_NAME, -- setting_id
Value => Object.Setting);
Query.Execute (Result);
if Result /= 1 then
raise ADO.Objects.INSERT_ERROR;
end if;
ADO.Objects.Set_Created (Object);
end Create;
procedure Delete (Object : in out Global_Setting_Impl;
Session : in out ADO.Sessions.Master_Session'Class) is
Stmt : ADO.Statements.Delete_Statement
:= Session.Create_Statement (GLOBAL_SETTING_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 Global_Setting_Ref;
Name : in String) return Util.Beans.Objects.Object is
Obj : ADO.Objects.Object_Record_Access;
Impl : access Global_Setting_Impl;
begin
if From.Is_Null then
return Util.Beans.Objects.Null_Object;
end if;
Obj := From.Get_Load_Object;
Impl := Global_Setting_Impl (Obj.all)'Access;
if Name = "id" then
return ADO.Objects.To_Object (Impl.Get_Key);
elsif Name = "value" then
return Util.Beans.Objects.To_Object (Impl.Value);
elsif Name = "server_id" then
return Util.Beans.Objects.To_Object (Long_Long_Integer (Impl.Server_Id));
end if;
return Util.Beans.Objects.Null_Object;
end Get_Value;
procedure List (Object : in out Global_Setting_Vector;
Session : in out ADO.Sessions.Session'Class;
Query : in ADO.SQL.Query'Class) is
Stmt : ADO.Statements.Query_Statement
:= Session.Create_Statement (Query, GLOBAL_SETTING_DEF'Access);
begin
Stmt.Execute;
Global_Setting_Vectors.Clear (Object);
while Stmt.Has_Elements loop
declare
Item : Global_Setting_Ref;
Impl : constant Global_Setting_Access := new Global_Setting_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 Global_Setting_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.Value := Stmt.Get_Unbounded_String (1);
Object.Server_Id := Stmt.Get_Integer (3);
if not Stmt.Is_Null (4) then
Object.Setting.Set_Key_Value (Stmt.Get_Identifier (4), Session);
end if;
Object.Version := Stmt.Get_Integer (2);
ADO.Objects.Set_Created (Object);
end Load;
function User_Setting_Key (Id : in ADO.Identifier) return ADO.Objects.Object_Key is
Result : ADO.Objects.Object_Key (Of_Type => ADO.Objects.KEY_INTEGER,
Of_Class => USER_SETTING_DEF'Access);
begin
ADO.Objects.Set_Value (Result, Id);
return Result;
end User_Setting_Key;
function User_Setting_Key (Id : in String) return ADO.Objects.Object_Key is
Result : ADO.Objects.Object_Key (Of_Type => ADO.Objects.KEY_INTEGER,
Of_Class => USER_SETTING_DEF'Access);
begin
ADO.Objects.Set_Value (Result, Id);
return Result;
end User_Setting_Key;
function "=" (Left, Right : User_Setting_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 User_Setting_Ref'Class;
Impl : out User_Setting_Access) is
Result : ADO.Objects.Object_Record_Access;
begin
Object.Prepare_Modify (Result);
Impl := User_Setting_Impl (Result.all)'Access;
end Set_Field;
-- Internal method to allocate the Object_Record instance
procedure Allocate (Object : in out User_Setting_Ref) is
Impl : User_Setting_Access;
begin
Impl := new User_Setting_Impl;
Impl.Version := 0;
ADO.Objects.Set_Object (Object, Impl.all'Access);
end Allocate;
-- ----------------------------------------
-- Data object: User_Setting
-- ----------------------------------------
procedure Set_Id (Object : in out User_Setting_Ref;
Value : in ADO.Identifier) is
Impl : User_Setting_Access;
begin
Set_Field (Object, Impl);
ADO.Objects.Set_Field_Key_Value (Impl.all, 1, Value);
end Set_Id;
function Get_Id (Object : in User_Setting_Ref)
return ADO.Identifier is
Impl : constant User_Setting_Access
:= User_Setting_Impl (Object.Get_Object.all)'Access;
begin
return Impl.Get_Key_Value;
end Get_Id;
procedure Set_Value (Object : in out User_Setting_Ref;
Value : in String) is
Impl : User_Setting_Access;
begin
Set_Field (Object, Impl);
ADO.Objects.Set_Field_String (Impl.all, 2, Impl.Value, Value);
end Set_Value;
procedure Set_Value (Object : in out User_Setting_Ref;
Value : in Ada.Strings.Unbounded.Unbounded_String) is
Impl : User_Setting_Access;
begin
Set_Field (Object, Impl);
ADO.Objects.Set_Field_Unbounded_String (Impl.all, 2, Impl.Value, Value);
end Set_Value;
function Get_Value (Object : in User_Setting_Ref)
return String is
begin
return Ada.Strings.Unbounded.To_String (Object.Get_Value);
end Get_Value;
function Get_Value (Object : in User_Setting_Ref)
return Ada.Strings.Unbounded.Unbounded_String is
Impl : constant User_Setting_Access
:= User_Setting_Impl (Object.Get_Load_Object.all)'Access;
begin
return Impl.Value;
end Get_Value;
function Get_Version (Object : in User_Setting_Ref)
return Integer is
Impl : constant User_Setting_Access
:= User_Setting_Impl (Object.Get_Load_Object.all)'Access;
begin
return Impl.Version;
end Get_Version;
procedure Set_Setting (Object : in out User_Setting_Ref;
Value : in AWA.Settings.Models.Setting_Ref'Class) is
Impl : User_Setting_Access;
begin
Set_Field (Object, Impl);
ADO.Objects.Set_Field_Object (Impl.all, 4, Impl.Setting, Value);
end Set_Setting;
function Get_Setting (Object : in User_Setting_Ref)
return AWA.Settings.Models.Setting_Ref'Class is
Impl : constant User_Setting_Access
:= User_Setting_Impl (Object.Get_Load_Object.all)'Access;
begin
return Impl.Setting;
end Get_Setting;
procedure Set_User (Object : in out User_Setting_Ref;
Value : in AWA.Users.Models.User_Ref'Class) is
Impl : User_Setting_Access;
begin
Set_Field (Object, Impl);
ADO.Objects.Set_Field_Object (Impl.all, 5, Impl.User, Value);
end Set_User;
function Get_User (Object : in User_Setting_Ref)
return AWA.Users.Models.User_Ref'Class is
Impl : constant User_Setting_Access
:= User_Setting_Impl (Object.Get_Load_Object.all)'Access;
begin
return Impl.User;
end Get_User;
-- Copy of the object.
procedure Copy (Object : in User_Setting_Ref;
Into : in out User_Setting_Ref) is
Result : User_Setting_Ref;
begin
if not Object.Is_Null then
declare
Impl : constant User_Setting_Access
:= User_Setting_Impl (Object.Get_Load_Object.all)'Access;
Copy : constant User_Setting_Access
:= new User_Setting_Impl;
begin
ADO.Objects.Set_Object (Result, Copy.all'Access);
Copy.Copy (Impl.all);
Copy.Value := Impl.Value;
Copy.Version := Impl.Version;
Copy.Setting := Impl.Setting;
Copy.User := Impl.User;
end;
end if;
Into := Result;
end Copy;
procedure Find (Object : in out User_Setting_Ref;
Session : in out ADO.Sessions.Session'Class;
Query : in ADO.SQL.Query'Class;
Found : out Boolean) is
Impl : constant User_Setting_Access := new User_Setting_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 User_Setting_Ref;
Session : in out ADO.Sessions.Session'Class;
Id : in ADO.Identifier) is
Impl : constant User_Setting_Access := new User_Setting_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 User_Setting_Ref;
Session : in out ADO.Sessions.Session'Class;
Id : in ADO.Identifier;
Found : out Boolean) is
Impl : constant User_Setting_Access := new User_Setting_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 Save (Object : in out User_Setting_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 User_Setting_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;
procedure Delete (Object : in out User_Setting_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
-- --------------------
procedure Destroy (Object : access User_Setting_Impl) is
type User_Setting_Impl_Ptr is access all User_Setting_Impl;
procedure Unchecked_Free is new Ada.Unchecked_Deallocation
(User_Setting_Impl, User_Setting_Impl_Ptr);
pragma Warnings (Off, "*redundant conversion*");
Ptr : User_Setting_Impl_Ptr := User_Setting_Impl (Object.all)'Access;
pragma Warnings (On, "*redundant conversion*");
begin
Unchecked_Free (Ptr);
end Destroy;
procedure Find (Object : in out User_Setting_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, USER_SETTING_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 User_Setting_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;
procedure Save (Object : in out User_Setting_Impl;
Session : in out ADO.Sessions.Master_Session'Class) is
Stmt : ADO.Statements.Update_Statement
:= Session.Create_Statement (USER_SETTING_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, -- value
Value => Object.Value);
Object.Clear_Modified (2);
end if;
if Object.Is_Modified (4) then
Stmt.Save_Field (Name => COL_3_3_NAME, -- setting_id
Value => Object.Setting);
Object.Clear_Modified (4);
end if;
if Object.Is_Modified (5) then
Stmt.Save_Field (Name => COL_4_3_NAME, -- user_id
Value => Object.User);
Object.Clear_Modified (5);
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;
procedure Create (Object : in out User_Setting_Impl;
Session : in out ADO.Sessions.Master_Session'Class) is
Query : ADO.Statements.Insert_Statement
:= Session.Create_Statement (USER_SETTING_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, -- value
Value => Object.Value);
Query.Save_Field (Name => COL_2_3_NAME, -- version
Value => Object.Version);
Query.Save_Field (Name => COL_3_3_NAME, -- setting_id
Value => Object.Setting);
Query.Save_Field (Name => COL_4_3_NAME, -- user_id
Value => Object.User);
Query.Execute (Result);
if Result /= 1 then
raise ADO.Objects.INSERT_ERROR;
end if;
ADO.Objects.Set_Created (Object);
end Create;
procedure Delete (Object : in out User_Setting_Impl;
Session : in out ADO.Sessions.Master_Session'Class) is
Stmt : ADO.Statements.Delete_Statement
:= Session.Create_Statement (USER_SETTING_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 User_Setting_Ref;
Name : in String) return Util.Beans.Objects.Object is
Obj : ADO.Objects.Object_Record_Access;
Impl : access User_Setting_Impl;
begin
if From.Is_Null then
return Util.Beans.Objects.Null_Object;
end if;
Obj := From.Get_Load_Object;
Impl := User_Setting_Impl (Obj.all)'Access;
if Name = "id" then
return ADO.Objects.To_Object (Impl.Get_Key);
elsif Name = "value" then
return Util.Beans.Objects.To_Object (Impl.Value);
end if;
return Util.Beans.Objects.Null_Object;
end Get_Value;
-- ------------------------------
-- Load the object from current iterator position
-- ------------------------------
procedure Load (Object : in out User_Setting_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.Value := Stmt.Get_Unbounded_String (1);
if not Stmt.Is_Null (3) then
Object.Setting.Set_Key_Value (Stmt.Get_Identifier (3), Session);
end if;
if not Stmt.Is_Null (4) then
Object.User.Set_Key_Value (Stmt.Get_Identifier (4), Session);
end if;
Object.Version := Stmt.Get_Integer (2);
ADO.Objects.Set_Created (Object);
end Load;
end AWA.Settings.Models;
|
charlie5/lace | Ada | 910 | ads | with
openGL.Geometry;
package openGL.Model.capsule.lit_textured
--
-- Models a lit and textured capsule.
--
is
type Item is new Model.capsule.item with private;
type View is access all Item'Class;
---------
--- Forge
--
function new_Capsule (Radius : in Real;
Height : in Real;
Image : in asset_Name := null_Asset) return View;
--------------
--- Attributes
--
overriding
function to_GL_Geometries (Self : access Item; Textures : access Texture.name_Map_of_texture'Class;
Fonts : in Font.font_id_Map_of_font) return Geometry.views;
private
type Item is new Model.capsule.item with
record
Radius : Real;
Height : Real;
Image : asset_Name := null_Asset;
end record;
end openGL.Model.capsule.lit_textured;
|
AdaCore/spat | Ada | 12,310 | adb | ------------------------------------------------------------------------------
-- Copyright (C) 2020 by Heisenbug Ltd. ([email protected])
--
-- This work is free. You can redistribute it and/or modify it under the
-- terms of the Do What The Fuck You Want To Public License, Version 2,
-- as published by Sam Hocevar. See the LICENSE file for more details.
------------------------------------------------------------------------------
pragma License (Unrestricted);
with Ada.Containers.Vectors;
with SPAT.Proof_Attempt.List;
package body SPAT.Proof_Item is
package Checks_Lists is new
Ada.Containers.Vectors (Index_Type => Positive,
Element_Type => Proof_Attempt.List.T,
"=" => Proof_Attempt.List."=");
package Checks_By_Duration is new
Checks_Lists.Generic_Sorting ("<" => Proof_Attempt.List."<");
---------------------------------------------------------------------------
-- "<"
---------------------------------------------------------------------------
-- FIXME: We should be able to sort by Max_Success_Time, too.
overriding
function "<" (Left : in T;
Right : in T) return Boolean is
use type Proof_Item_Ids.Id;
begin
-- First by total time.
if Left.Total_Time /= Right.Total_Time then
return Left.Total_Time > Right.Total_Time;
end if;
-- Total time does not differ, try max time.
if Left.Max_Time /= Right.Max_Time then
return Left.Max_Time > Right.Max_Time;
end if;
-- By Rule (i.e. VC_LOOP_INVARIANT, VC_PRECONDITION, etc. pp.)
if Left.Rule /= Right.Rule then
return Left.Rule < Right.Rule;
end if;
-- By Severity (i.e. "info", "warning", ...)
if Left.Severity /= Right.Severity then
-- TODO: We should get a list of severities and actually sort them by
-- priority. For now, textual is all we have.
return Left.Severity < Right.Severity;
end if;
-- Locations are equal, go for last resort, the unique id.
if Entity_Location."=" (X => Entity_Location.T (Left),
Y => Entity_Location.T (Right))
then
return Left.Id < Right.Id;
end if;
-- By location (i.e. file:line:column).
return Entity_Location."<" (Left => Entity_Location.T (Left),
Right => Entity_Location.T (Right));
end "<";
---------------------------------------------------------------------------
-- Add_To_Tree
---------------------------------------------------------------------------
procedure Add_To_Tree (Object : in JSON_Value;
Version : in File_Version;
Tree : in out Entity.Tree.T;
Parent : in Entity.Tree.Cursor)
is
pragma Unreferenced (Version); -- Only for precondition.
-- Collect information about the timing of dependent attempts.
Max_Proof : Time_And_Steps := None;
Max_Success : Time_And_Steps := None;
Total_Time : Duration := 0.0;
Checks_List : Checks_Lists.Vector;
Check_Tree : constant JSON_Array :=
Object.Get (Field => Field_Names.Check_Tree);
Suppressed_Msg : constant Justification :=
(if Object.Has_Field (Field => Field_Names.Suppressed)
then
Justification
(Subject_Name'(Object.Get (Field => Field_Names.Suppressed)))
else Justification (Null_Name)); -- FIXME: Missing type check.
begin
-- Walk along the check_tree array to find all proof attempts and their
-- respective times.
for I in 1 .. GNATCOLL.JSON.Length (Arr => Check_Tree) loop
declare
Attempts : Proof_Attempt.List.T;
Element : constant JSON_Value :=
GNATCOLL.JSON.Get (Arr => Check_Tree,
Index => I);
begin
if
Preconditions.Ensure_Field (Object => Element,
Field => Field_Names.Proof_Attempts,
Kind => JSON_Object_Type)
then
declare
Attempt_List : constant JSON_Value
:= Element.Get (Field => Field_Names.Proof_Attempts);
------------------------------------------------------------
-- Mapping_CB
------------------------------------------------------------
procedure Mapping_CB (Name : in UTF8_String;
Value : in JSON_Value);
------------------------------------------------------------
-- Mapping_CB
------------------------------------------------------------
procedure Mapping_CB (Name : in UTF8_String;
Value : in JSON_Value) is
begin
if
Proof_Attempt.Has_Required_Fields (Object => Value)
then
declare
Attempt : constant Proof_Attempt.T :=
Proof_Attempt.Create
(Prover => Prover_Name (To_Name (Name)),
Object => Value);
use type Proof_Attempt.Prover_Result;
begin
Attempts.Append (New_Item => Attempt);
Max_Proof :=
Time_And_Steps'
(Time =>
Duration'Max (Max_Proof.Time,
Attempt.Time),
Steps =>
Prover_Steps'Max (Max_Proof.Steps,
Attempt.Steps));
if Attempt.Result = Proof_Attempt.Valid then
Max_Success :=
Time_And_Steps'
(Time =>
Duration'Max (Max_Success.Time,
Attempt.Time),
Steps =>
Prover_Steps'Max (Max_Success.Steps,
Attempt.Steps));
end if;
Total_Time := Total_Time + Attempt.Time;
end;
end if;
end Mapping_CB;
begin
-- We use Map_JSON_Object here, because the prover name is
-- dynamic and potentially unknown to us, so we can't do a
-- lookup.
GNATCOLL.JSON.Map_JSON_Object (Val => Attempt_List,
CB => Mapping_CB'Access);
end;
end if;
-- Handle the "trivial_true" object (since GNAT_CE_2020.
if
Preconditions.Ensure_Field (Object => Element,
Field => Field_Names.Transformations,
Kind => JSON_Object_Type)
then
declare
Transformation : constant JSON_Value
:= Element.Get (Field => Field_Names.Transformations);
begin
if
Transformation.Has_Field (Field => Field_Names.Trivial_True)
then
Attempts.Append (New_Item => Proof_Attempt.Trivial_True);
-- No timing updates needed here, as we assume 0.0 for
-- trivially true proofs.
end if;
end;
end if;
-- If not empty, add the current check tree to our list.
if not Attempts.Is_Empty then
Attempts.Sort_By_Duration; -- FIXME: Potentially unstable.
Checks_List.Append (New_Item => Attempts);
end if;
end;
end loop;
-- Sort checks list descending by duration.
Checks_By_Duration.Sort (Container => Checks_List);
declare
PI_Node : Entity.Tree.Cursor;
begin
-- Allocate node for our object.
Tree.Insert_Child
(Parent => Parent,
Before => Entity.Tree.No_Element,
New_Item => Proof_Item_Sentinel'(Entity.T with null record),
Position => PI_Node);
-- Now insert the whole object into the tree.
declare
PA_Node : Entity.Tree.Cursor;
begin
for Check of Checks_List loop
Tree.Insert_Child (Parent => PI_Node,
Before => Entity.Tree.No_Element,
New_Item =>
Checks_Sentinel'
(Entity.T with
Has_Failed_Attempts => True,
Is_Unproved => True),
Position => PA_Node);
for Attempt of Check loop
Tree.Insert_Child (Parent => PA_Node,
Before => Entity.Tree.No_Element,
New_Item => Attempt);
end loop;
-- Replace the Checks_Sentinel with proper data.
Tree.Replace_Element
(Position => PA_Node,
New_Item =>
Checks_Sentinel'
(Entity.T with
Has_Failed_Attempts => Check.Has_Failed_Attempts,
Is_Unproved => Check.Is_Unproved));
end loop;
end;
-- And finally replace the sentinel node with the full object.
declare
Has_Failed_Attempts : constant Boolean :=
(for some Check of Checks_List => Check.Has_Failed_Attempts);
Has_Unproved_Attempts : constant Boolean :=
(for some Check of Checks_List => Check.Is_Unproved);
Is_Unjustified : constant Boolean :=
Has_Unproved_Attempts and then
Suppressed_Msg = Justification (Null_Name);
begin
Tree.Replace_Element
(Position => PI_Node,
New_Item =>
T'(Entity_Location.Create (Object => Object) with
Suppressed => Suppressed_Msg,
Rule =>
Rule_Name
(Subject_Name'(Object.Get
(Field => Field_Names.Rule))),
Severity =>
Severity_Name
(Subject_Name'(Object.Get
(Field => Field_Names.Severity))),
Max_Success =>
(if Has_Unproved_Attempts
then None
else Max_Success),
Max_Proof => Max_Proof,
Total_Time => Total_Time,
Id => Proof_Item_Ids.Next,
Has_Failed_Attempts => Has_Failed_Attempts,
Has_Unproved_Attempts => Has_Unproved_Attempts,
Is_Unjustified => Is_Unjustified));
end;
end;
end Add_To_Tree;
---------------------------------------------------------------------------
-- Create
---------------------------------------------------------------------------
overriding
function Create (Object : in JSON_Value) return T is
(raise Program_Error with
"Create should not be called. Instead call Add_To_Tree.");
end SPAT.Proof_Item;
|
onox/orka | Ada | 2,084 | ads | -- SPDX-License-Identifier: Apache-2.0
--
-- Copyright (c) 2018 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 Ada.Exceptions;
with Orka.Smart_Pointers;
package Orka.Futures is
pragma Preelaborate;
type Status is (Waiting, Running, Done, Failed)
with Default_Value => Waiting;
subtype Non_Failed_Status is Status range Waiting .. Done;
type Future is synchronized interface;
procedure Wait_Until_Done
(Object : in out Future;
Value : out Status) is abstract
with Synchronization => By_Entry;
function Current_Status (Object : Future) return Status is abstract;
type Future_Access is access all Future'Class;
procedure Internal_Release (Value : in out Future_Access);
-- This is an internal subprogram and must not be called
package Pointers is new Orka.Smart_Pointers
(Future'Class, Future_Access, Internal_Release);
-----------------------------------------------------------------------------
type Promise is synchronized interface and Future;
procedure Set_Status
(Object : in out Promise;
Value : Non_Failed_Status) is abstract
with Synchronization => By_Protected_Procedure;
procedure Set_Failed
(Object : in out Promise;
Reason : Ada.Exceptions.Exception_Occurrence) is abstract
with Synchronization => By_Protected_Procedure;
private
type Releasable_Future is limited interface;
procedure Release
(Object : Releasable_Future;
Slot : not null Future_Access) is abstract;
end Orka.Futures;
|
sungyeon/drake | Ada | 1,652 | adb | package body Ada.Containers.Murmur_Hash_3 is
-- use MurmurHash3_x86_32
procedure Step (h1 : in out Hash_Type; Item : Hash_Type);
procedure Step (h1 : in out Hash_Type; Item : Hash_Type) is
c1 : constant := 16#cc9e2d51#;
c2 : constant := 16#1b873593#;
k1 : Hash_Type := Item;
begin
k1 := k1 * c1;
k1 := Rotate_Left (k1, 15);
k1 := k1 * c2;
h1 := h1 xor k1;
end Step;
-- implementation
function Initialize (Initiator : Hash_Type) return State is
begin
return (h1 => Initiator, len => 0);
end Initialize;
procedure Update (S : in out State; Item : Hash_Type) is
begin
Step (S.h1, Item);
S.h1 := Rotate_Left (S.h1, 13);
S.h1 := S.h1 * 5 + 16#e6546b64#;
S.len := S.len + 4;
end Update;
procedure Update (S : in out State; Item : Hash_8) is
begin
Step (S.h1, Hash_Type'Mod (Item));
S.len := S.len + 1;
end Update;
procedure Update (S : in out State; Item : Hash_16) is
begin
Step (S.h1, Hash_Type'Mod (Item));
S.len := S.len + 2;
end Update;
procedure Update (S : in out State; Item : Hash_24) is
begin
Step (S.h1, Hash_Type'Mod (Item));
S.len := S.len + 3;
end Update;
procedure Finalize (S : State; Digest : out Hash_Type) is
begin
Digest := S.h1 xor Hash_Type'Mod (S.len);
Digest := Digest xor Shift_Right (Digest, 16);
Digest := Digest * 16#85ebca6b#;
Digest := Digest xor Shift_Right (Digest, 13);
Digest := Digest * 16#c2b2ae35#;
Digest := Digest xor Shift_Right (Digest, 16);
end Finalize;
end Ada.Containers.Murmur_Hash_3;
|
reznikmm/matreshka | Ada | 4,768 | 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.Db_Table_Definitions_Elements;
package Matreshka.ODF_Db.Table_Definitions_Elements is
type Db_Table_Definitions_Element_Node is
new Matreshka.ODF_Db.Abstract_Db_Element_Node
and ODF.DOM.Db_Table_Definitions_Elements.ODF_Db_Table_Definitions
with null record;
overriding function Create
(Parameters : not null access Matreshka.DOM_Elements.Element_L2_Parameters)
return Db_Table_Definitions_Element_Node;
overriding function Get_Local_Name
(Self : not null access constant Db_Table_Definitions_Element_Node)
return League.Strings.Universal_String;
overriding procedure Enter_Node
(Self : not null access Db_Table_Definitions_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 Db_Table_Definitions_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 Db_Table_Definitions_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_Db.Table_Definitions_Elements;
|
charlie5/lace | Ada | 187 | ads | package openGL.Model.capsule
--
-- Provides an abstract base class for capsule models.
--
is
type Item is abstract new openGL.Model.item with null record;
end openGL.Model.capsule;
|
OneWingedShark/Risi | Ada | 2,067 | ads | Pragma Ada_2012;
Pragma Wide_Character_Encoding( UTF8 );
with
Risi_Script.Types.Patterns,
Risi_Script.Types.Identifier,
Risi_Script.Types.Identifier.Scope,
Risi_Script.Types.Implementation;
Package Risi_Script.Interfaces is
Use Risi_Script.Types.Patterns;
Type Stack_Interface is Interface;
Function Match(Object : Stack_Interface;
Pattern : Three_Quarter_Pattern
) return Boolean is (True);
Function Match(Object : Stack_Interface;
Pattern : Half_Pattern
) return Boolean is (True);
Package ID Renames Risi_Script.Types.Identifier;
Package IM Renames Risi_Script.Types.Implementation;
Package Scope Renames ID.Scope;
-- The VM type declares the interface for a virtual=machine's
-- implementation.
--
-- NOTE: MRE is a delicious Managed Runtime Environment.
Type VM is synchronized interface;
-- Creates a variable in the MRE.
Procedure Create_Variable( MRE : in out VM;
Value : IM.Representation;
Name : ID.Identifier:= "Evaluated";
Context : Scope.Scope:= Scope.Global
) is abstract;
-- Returns the internal representation of the indicated variable.
Function Retrieve_Variable( MRE : in out VM;
Name : ID.Identifier:= "Evaluated";
Context : Scope.Scope:= Scope.Global
) return IM.Representation is abstract;
Procedure Push_Parameter ( MRE : in out VM;
Value : IM.Representation
) is abstract;
Function Pop_Parameter ( MRE : in out VM
) return IM.Representation is abstract;
Function Peek_Parameter ( MRE : in out VM;
Location: Positive
) return IM.Representation is abstract;
End Risi_Script.Interfaces;
|
sungyeon/drake | Ada | 299 | ads | pragma License (Unrestricted);
-- implementation unit required by compiler
package System.Val_LLD is
pragma Pure;
-- required for Fixed'Value by compiler (s-valdec.ads)
function Value_Long_Long_Decimal (Str : String; Scale : Integer)
return Long_Long_Integer;
end System.Val_LLD;
|
zhmu/ananas | Ada | 2,858 | ads | ------------------------------------------------------------------------------
-- --
-- GNAT RUN-TIME COMPONENTS --
-- --
-- A D A . E X C E P T I O N S . I S _ N U L L _ O C C U R R E N C E --
-- --
-- S p e c --
-- --
-- Copyright (C) 2000-2022, Free Software Foundation, Inc. --
-- --
-- GNAT is free software; you can redistribute it and/or modify it under --
-- terms of the GNU General Public License as published by the Free Soft- --
-- ware Foundation; either version 3, or (at your option) any later ver- --
-- sion. GNAT is distributed in the hope that it will be useful, but WITH- --
-- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY --
-- or FITNESS FOR A PARTICULAR PURPOSE. --
-- --
-- As a special exception under Section 7 of GPL version 3, you are granted --
-- additional permissions described in the GCC Runtime Library Exception, --
-- version 3.1, as published by the Free Software Foundation. --
-- --
-- You should have received a copy of the GNU General Public License and --
-- a copy of the GCC Runtime Library Exception along with this program; --
-- see the files COPYING3 and COPYING.RUNTIME respectively. If not, see --
-- <http://www.gnu.org/licenses/>. --
-- --
-- GNAT was originally developed by the GNAT team at New York University. --
-- Extensive contributions were provided by Ada Core Technologies Inc. --
-- --
------------------------------------------------------------------------------
-- This is a GNAT-specific child function of Ada.Exceptions. It provides
-- clearly missing functionality for its parent package, and most reasonably
-- would simply be an added function to that package, but this change cannot
-- be made in a conforming manner.
function Ada.Exceptions.Is_Null_Occurrence
(X : Exception_Occurrence) return Boolean;
pragma Preelaborate (Ada.Exceptions.Is_Null_Occurrence);
-- This function yields True if X is Null_Occurrence, and False otherwise
|
NCommander/dnscatcher | Ada | 3,618 | 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 DNSCatcher.Network;
with DNSCatcher.Datasets; use DNSCatcher.Datasets;
-- @summary
-- Implements the Sender interface queue for UDP messages
--
-- @description
-- The outbound packet queue is used to handle all requests either being sent
-- to a client, or sending requests to upstream servers for results
--
package DNSCatcher.Network.UDP.Sender is
-- Send queue management task
task type Send_Packet_Task is
-- Initializes the sender queue
--
-- @value Socket
-- GNAT.Sockets Socket_Type
--
-- @value Packet_Queue
-- Raw package queue to use with the sender module
entry Initialize
(Socket : Socket_Type;
Packet_Queue : DNS_Raw_Packet_Queue_Ptr);
-- Starts the sender task
entry Start;
-- Stops the sender task
entry Stop;
end Send_Packet_Task;
type Send_Packet_Task_Ptr is access Send_Packet_Task;
-- UDP Sender interface used to queue outbound packets
--
-- @value Config
-- Configuration Pointer
--
-- @value Sender_Socket
-- Socket for the UDP port
--
-- @value Sender_Task
-- Internal pointer to the Sender task
--
-- @value Packet_Queue
-- Internal queue for packets to be sent
--
type UDP_Sender_Interface is new DNSCatcher.Network.Sender_Interface with
record
Sender_Socket : Socket_Type;
Sender_Task : Send_Packet_Task_Ptr;
Packet_Queue : DNS_Raw_Packet_Queue_Ptr;
end record;
type IPv4_UDP_Receiver_Interface_Ptr is access UDP_Sender_Interface;
-- Initializes the sender class interface
--
-- @value This
-- Class object
--
-- @value Config
-- Pointer to the configuration object
--
-- @value Socket
-- GNAT.Socket to use for UDP connections
procedure Initialize
(This : in out UDP_Sender_Interface;
Socket : Socket_Type);
-- Starts the interface
--
-- @value This
-- Class Object
procedure Start (This : in out UDP_Sender_Interface);
-- Cleanly shuts down the interface
--
-- @value This
-- Class Object
procedure Shutdown (This : in out UDP_Sender_Interface);
-- Returns the internal packet queue for this interface
--
-- @value This
-- Clas object
--
-- @returns
-- Pointer to the packet queue
--
function Get_Packet_Queue_Ptr
(This : in out UDP_Sender_Interface)
return DNS_Raw_Packet_Queue_Ptr;
end DNSCatcher.Network.UDP.Sender;
|
reznikmm/matreshka | Ada | 3,499 | ads | ------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- Localization, Internationalization, Globalization for Ada --
-- --
-- Runtime Library Component --
-- --
------------------------------------------------------------------------------
-- --
-- Copyright © 2011, 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.Holders.Generic_Floats;
package League.Holders.Floats is new League.Holders.Generic_Floats (Float);
pragma Preelaborate (League.Holders.Floats);
|
godunko/adawebpack | Ada | 59 | ads |
package Demo is
procedure Initialize_Demo;
end Demo;
|
zhmu/ananas | Ada | 5,609 | ads | ------------------------------------------------------------------------------
-- --
-- GNAT RUN-TIME LIBRARY (GNARL) COMPONENTS --
-- --
-- S Y S T E M . T A S K _ P R I M I T I V E S --
-- --
-- S p e c --
-- --
-- Copyright (C) 1991-2017, Florida State University --
-- Copyright (C) 1995-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/>. --
-- --
-- GNARL was developed by the GNARL team at Florida State University. --
-- Extensive contributions were provided by Ada Core Technologies, Inc. --
-- --
------------------------------------------------------------------------------
-- This is a POSIX-like version of this package where no alternate stack
-- is needed for stack checking.
-- Note: this file can only be used for POSIX compliant systems
with System.OS_Interface;
package System.Task_Primitives is
pragma Preelaborate;
type Lock is limited private;
-- Should be used for implementation of protected objects
type RTS_Lock is limited private;
-- Should be used inside the runtime system. The difference between Lock
-- and the RTS_Lock is that the later one serves only as a semaphore so
-- that do not check for ceiling violations.
type Suspension_Object is limited private;
-- Should be used for the implementation of Ada.Synchronous_Task_Control
type Task_Body_Access is access procedure;
-- Pointer to the task body's entry point (or possibly a wrapper declared
-- local to the GNARL).
type Private_Data is limited private;
-- Any information that the GNULLI needs maintained on a per-task basis.
-- A component of this type is guaranteed to be included in the
-- Ada_Task_Control_Block.
subtype Task_Address is System.Address;
Task_Address_Size : constant := Standard'Address_Size;
-- Type used for task addresses and its size
Alternate_Stack_Size : constant := 0;
-- No alternate signal stack is used on this platform
private
type RTS_Lock is new System.OS_Interface.pthread_mutex_t;
type Lock is record
WO : aliased RTS_Lock;
RW : aliased System.OS_Interface.pthread_rwlock_t;
end record;
type Suspension_Object is record
State : Boolean;
pragma Atomic (State);
-- Boolean that indicates whether the object is open. This field is
-- marked Atomic to ensure that we can read its value without locking
-- the access to the Suspension_Object.
Waiting : Boolean;
-- Flag showing if there is a task already suspended on this object
L : aliased RTS_Lock;
-- Protection for ensuring mutual exclusion on the Suspension_Object
CV : aliased System.OS_Interface.pthread_cond_t;
-- Condition variable used to queue threads until condition is signaled
end record;
type Private_Data is limited record
Thread : aliased System.OS_Interface.pthread_t;
pragma Atomic (Thread);
-- Thread field may be updated by two different threads of control.
-- (See, Enter_Task and Create_Task in s-taprop.adb). They put the same
-- value (thr_self value). We do not want to use lock on those
-- operations and the only thing we have to make sure is that they are
-- updated in atomic fashion.
LWP : aliased System.Address;
-- The purpose of this field is to provide a better tasking support on
-- gdb. The order of the two first fields (Thread and LWP) is important.
-- On targets where lwp is not relevant, this is equivalent to Thread.
CV : aliased System.OS_Interface.pthread_cond_t;
-- Should be commented ??? (in all versions of taspri)
L : aliased RTS_Lock;
-- Protection for all components is lock L
end record;
end System.Task_Primitives;
|
rogermc2/GA_Ada | Ada | 4,934 | ads |
with Interfaces; use Interfaces;
with Ada.Containers.Doubly_Linked_Lists;
with Ada.Containers.Vectors;
with Ada.Strings.Unbounded;
with Blade_Types; use Blade_Types;
with GA_Maths;
with Metric;
package Blade is
use Ada.Strings.Unbounded;
type Basis_Blade is record
Bitmap : Interfaces.Unsigned_32 := 0;
Weight : Float := 0.0;
end record;
type Complex_Basis_Blade is private;
type Basis_Blade_Array is array (Integer range <>) of Basis_Blade;
package Blade_List_Package is new Ada.Containers.Doubly_Linked_Lists
(Element_Type => Basis_Blade);
type Blade_List is new Blade_List_Package.List with null record;
package Blade_Vector_Package is new Ada.Containers.Vectors
(Index_Type => Natural, Element_Type => Basis_Blade);
type Blade_Vector is new Blade_Vector_Package.Vector with null record;
function "<" (Left, Right : Blade.Basis_Blade) return Boolean;
package Blade_Sort_Package is new
Blade_List_Package.Generic_Sorting ("<");
type Contraction_Type is (Left_Contraction, Right_Contraction,
Hestenes_Inner_Product,
Modified_Hestenes_Inner_Product);
Blade_Exception : Exception;
function "*" (S : Float; BB : Basis_Blade) return Basis_Blade;
function "*" (BB : Basis_Blade; S : Float) return Basis_Blade;
procedure Add_Blade (Blades : in out Blade_List; BB : Basis_Blade);
procedure Add_Blade (Blades : in out Blade_Vector;
Index : Natural; BB : Basis_Blade);
procedure Add_Blades (Blades : in out Blade_List; More_Blades : Blade_List);
function BB_First (BB_List : Blade_List) return Basis_Blade;
function BB_Item (BB_List : Blade_List; Index : Integer) return Basis_Blade;
function Bitmap (BB : Basis_Blade) return Unsigned_32;
function Blade_String (aBlade : Basis_Blade; BV_Names : Basis_Vector_Names)
return Ada.Strings.Unbounded.Unbounded_String;
function Canonical_Reordering_Sign (Map_A, Map_B : Unsigned_32) return Float;
function Geometric_Product (BA, BB : Basis_Blade) return Basis_Blade;
function Geometric_Product (BB : Basis_Blade; Sc : Float) return Basis_Blade;
function Geometric_Product (BA, BB : Basis_Blade;
Eigen_Vals : GA_Maths.Float_Array_Package.Real_Vector)
return Basis_Blade;
function Geometric_Product (BA, BB : Basis_Blade; Met : Metric.Metric_Record)
return Blade_List;
function Grade (BB : Basis_Blade) return Integer;
function Grade_Inversion (B : Basis_Blade) return Basis_Blade;
function Inner_Product (BA, BB : Basis_Blade; Cont : Contraction_Type)
return Basis_Blade;
function Inner_Product (BA, BB : Basis_Blade; Met : Metric.Metric_Record;
Cont : Contraction_Type) return Blade_List;
function List_Length (Blades : Blade_List) return Integer;
function Minus_1_Power (Power : Integer) return Integer;
function New_Basis_Blade (Bitmap : Unsigned_32; Weight : Float := 1.0)
return Basis_Blade;
function New_Basis_Blade (Weight : Float := 0.0) return Basis_Blade;
function New_Basis_Blade (Index : BV_Base; Weight : Float := 1.0)
return Basis_Blade;
function New_Basis_Blade (Index : E2_Base; Weight : Float := 1.0)
return Basis_Blade;
function New_Basis_Blade (Index : E3_Base; Weight : Float := 1.0)
return Basis_Blade;
function New_Basis_Blade (Index : C3_Base; Weight : Float := 1.0)
return Basis_Blade;
function New_Blade (Bitmap : Unsigned_32; Weight : Float := 1.0)
return Basis_Blade;
function New_Complex_Basis_Blade (Index : C3_Base;
Weight : GA_Maths.Complex_Types.Complex
:= (0.0, 1.0))
return Complex_Basis_Blade;
function New_Scalar_Blade (Weight : Float := 1.0) return Basis_Blade;
function New_Zero_Blade return Basis_Blade;
function Outer_Product (BA, BB : Basis_Blade) return Basis_Blade;
function Reverse_Blade (B : Basis_Blade) return Basis_Blade;
procedure Simplify (Blades : in out Blade_List);
procedure Update_Blade (BB : in out Basis_Blade; Weight : Float);
procedure Update_Blade (BB : in out Basis_Blade; Bitmap : Unsigned_32);
procedure Update_Blade (BB : in out Basis_Blade; Bitmap : Unsigned_32;
Weight : Float);
function Weight (BB : Basis_Blade) return Float;
private
type Complex_Basis_Blade is record
Bitmap : Unsigned_32 := 0;
Weight : GA_Maths.Complex_Types.Complex := (0.0, 0.0);
end record;
end Blade;
|
reznikmm/matreshka | Ada | 5,191 | adb | ------------------------------------------------------------------------------
-- --
-- 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$
------------------------------------------------------------------------------
with AMF.Elements;
with AMF.Holders.Elements;
package body AMF.Internals.Holders.DG_Holders is
---------------
-- To_Holder --
---------------
function To_Holder
(Item : AMF.DG.Canvases.DG_Canvas_Access)
return League.Holders.Holder is
begin
return
AMF.Holders.Elements.To_Holder (AMF.Elements.Element_Access (Item));
end To_Holder;
---------------
-- To_Holder --
---------------
function To_Holder
(Item : AMF.DG.Clip_Paths.DG_Clip_Path_Access)
return League.Holders.Holder is
begin
return
AMF.Holders.Elements.To_Holder (AMF.Elements.Element_Access (Item));
end To_Holder;
---------------
-- To_Holder --
---------------
function To_Holder
(Item : AMF.DG.Fills.DG_Fill_Access)
return League.Holders.Holder is
begin
return
AMF.Holders.Elements.To_Holder (AMF.Elements.Element_Access (Item));
end To_Holder;
---------------
-- To_Holder --
---------------
function To_Holder
(Item : AMF.DG.Graphical_Elements.DG_Graphical_Element_Access)
return League.Holders.Holder is
begin
return
AMF.Holders.Elements.To_Holder (AMF.Elements.Element_Access (Item));
end To_Holder;
---------------
-- To_Holder --
---------------
function To_Holder
(Item : AMF.DG.Groups.DG_Group_Access)
return League.Holders.Holder is
begin
return
AMF.Holders.Elements.To_Holder (AMF.Elements.Element_Access (Item));
end To_Holder;
---------------
-- To_Holder --
---------------
function To_Holder
(Item : AMF.DG.Markers.DG_Marker_Access)
return League.Holders.Holder is
begin
return
AMF.Holders.Elements.To_Holder (AMF.Elements.Element_Access (Item));
end To_Holder;
end AMF.Internals.Holders.DG_Holders;
|
niechaojun/Amass | Ada | 1,961 | ads | -- Copyright 2017 Jeff Foley. All rights reserved.
-- Use of this source code is governed by Apache 2 LICENSE that can be found in the LICENSE file.
local json = require("json")
name = "PassiveTotal"
type = "api"
function start()
setratelimit(5)
end
function check()
local c
local cfg = datasrc_config()
if cfg ~= nil then
c = cfg.credentials
end
if (c ~= nil and c.key ~= nil and
c.username ~= nil and c.key ~= "" and c.username ~= "") then
return true
end
return false
end
function vertical(ctx, domain)
local c
local cfg = datasrc_config()
if cfg ~= nil then
c = cfg.credentials
end
if (c == nil or c.key == nil or c.key == "" or
c.username == nil or c.username == "") then
return
end
local resp
local vurl = buildurl(domain)
-- Check if the response data is in the graph database
if (cfg.ttl ~= nil and cfg.ttl > 0) then
resp = obtain_response(domain, cfg.ttl)
end
if (resp == nil or resp == "") then
local err
resp, err = request({
url=vurl,
headers={['Content-Type']="application/json"},
id=c.username,
pass=c.key,
})
if (err ~= nil and err ~= "") then
return
end
if (cfg.ttl ~= nil and cfg.ttl > 0) then
cache_response(vurl, resp)
end
end
local d = json.decode(resp)
if (d == nil or d.success ~= true or #(d.subdomains) == 0) then
return
end
for i, sub in pairs(d.subdomains) do
sendnames(ctx, sub .. "." .. domain)
end
end
function buildurl(domain)
return "https://api.passivetotal.org/v2/enrichment/subdomains?query=" .. domain
end
function sendnames(ctx, content)
local names = find(content, subdomainre)
if names == nil then
return
end
for i, v in pairs(names) do
newname(ctx, v)
end
end
|
Componolit/libsparkcrypto | Ada | 2,315 | ads | -------------------------------------------------------------------------------
-- This file is part of libsparkcrypto.
--
-- @author Alexander Senier
-- @date 2019-01-09
--
-- Copyright (C) 2018 Componolit GmbH
-- All rights reserved.
--
-- Redistribution and use in source and binary forms, with or without
-- modification, are permitted provided that the following conditions are met:
--
-- * Redistributions of source code must retain the above copyright notice,
-- this list of conditions and the following disclaimer.
--
-- * Redistributions in binary form must reproduce the above copyright
-- notice, this list of conditions and the following disclaimer in the
-- documentation and/or other materials provided with the distribution.
--
-- * Neither the name of the nor the names of its contributors may be used
-- to endorse or promote products derived from this software without
-- specific prior written permission.
--
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
-- AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
-- IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
-- ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS
-- BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
-- CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
-- SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
-- INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
-- CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
-- ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
-- POSSIBILITY OF SUCH DAMAGE.
-------------------------------------------------------------------------------
with AUnit; use AUnit;
with AUnit.Test_Cases; use AUnit.Test_Cases;
-- @summary Tests AES
package LSC_Internal_Test_AES is
type Test_Case is new Test_Cases.Test_Case with null record;
procedure Register_Tests (T : in out Test_Case);
-- Register routines to be run
function Name (T : Test_Case) return Message_String;
-- Provide name identifying the test case
end LSC_Internal_Test_AES;
|
Schol-R-LEA/sarcos | Ada | 5,002 | ads | pragma Restrictions (No_Obsolescent_Features);
with Crash;
pragma Unreferenced (Crash);
with Multiboot; use Multiboot;
with VGA_Console; use VGA_Console;
-- with System.Address_To_Access_Conversions;
-- with Ada.Unchecked_Conversion;
use type Multiboot.Magic_Values;
procedure Bare_Bones is
Line : Screen_Height_Range := Screen_Height_Range'First;
procedure T is
begin
Put ("T called", Screen_Width_Range'First, Line);
end T;
function Hello return String is
begin
return "hello!!";
end Hello;
begin
-- null;
Clear;
Put ("Hello, bare bones in Ada",
Screen_Width_Range'First,
Line);
Line := Line + 1;
if Magic = Magic_Value then
Put ("Magic numbers match!", Screen_Width_Range'First, Line);
else
Put ("Magic numbers don't match!", Screen_Width_Range'First, Line); -- comment
raise Program_Error;
end if;
Line := Line + 1;
T;
Line := Line + 1;
Put (Hello, Screen_Width_Range'First, Line);
raise Program_Error;
-- if Info.Flags.Memory then
-- Put ("Memory info present", Screen_Width_Range'First, Line);
-- Line := Line + 1;
-- end if;
-- if Info.Flags.Boot_Device then
-- Put ("Boot device info present", Screen_Width_Range'First, Line);
-- Line := Line + 1;
-- end if;
-- if Info.Flags.Command_Line then
-- Put ("Command line info present", Screen_Width_Range'First, Line);
-- Line := Line + 1;
-- end if;
-- if Info.Flags.Modules then
-- Put ("Modules info present", Screen_Width_Range'First, Line);
-- Line := Line + 1;
-- if Info.Modules.Count = 2 then
-- declare
-- type My_Modules_Array is new Modules_Array
-- (1 .. Natural (Info.Modules.Count));
-- type My_Modules_Array_Access is access all My_Modules_Array;
-- -- My_Modules : aliased Modules_Array
-- -- (1 .. Natural (Info.Modules.Count));
-- -- pragma Unreferenced (My_Modules);
-- package To_Modules is new System.Address_To_Access_Conversions
-- (Object => My_Modules_Array_Access);
-- function Conv is new Ada.Unchecked_Conversion
-- (Source => To_Modules.Object_Pointer,
-- Target => My_Modules_Array_Access);
-- Modules : constant My_Modules_Array_Access :=
-- Conv (To_Modules.To_Pointer
-- (Info.Modules.First));
-- M : Multiboot.Modules;
-- pragma Unreferenced (M);
-- begin
-- Put ("2 modules loaded is correct",
-- Screen_Width_Range'First, Line);
-- for I in 1 .. Info.Modules.Count loop
-- M := Modules (Natural (I));
-- end loop;
-- Line := Line + 1;
-- end;
-- end if;
-- end if;
-- if Info.Flags.Symbol_Table then
-- Put ("Symbol table info present", Screen_Width_Range'First, Line);
-- Line := Line + 1;
-- end if;
-- if Info.Flags.Section_Header_Table then
-- Put ("Section header table info present",
-- Screen_Width_Range'First, Line);
-- Line := Line + 1;
-- end if;
-- if Info.Flags.BIOS_Memory_Map then
-- Put ("BIOS memory map info present", Screen_Width_Range'First, Line);
-- Line := Line + 1;
-- declare
-- Map : Memory_Map_Entry_Access := Multiboot.First_Memory_Map_Entry;
-- begin
-- while Map /= null loop
-- Map := Multiboot.Next_Memory_Map_Entry (Map);
-- end loop;
-- end;
-- end if;
-- if Info.Flags.Drives then
-- Put ("Drives info present", Screen_Width_Range'First, Line);
-- Line := Line + 1;
-- end if;
-- if Info.Flags.ROM_Configuration then
-- Put ("ROM configuration info present",
-- Screen_Width_Range'First, Line);
-- Line := Line + 1;
-- end if;
-- if Info.Flags.Boot_Loader then
-- Put ("Boot loader info present", Screen_Width_Range'First, Line);
-- Line := Line + 1;
-- end if;
-- if Info.Flags.APM_Table then
-- Put ("APM table info present", Screen_Width_Range'First, Line);
-- Line := Line + 1;
-- end if;
-- if Info.Flags.Graphics_Table then
-- Put ("Graphics table info present", Screen_Width_Range'First, Line);
-- Line := Line + 1;
-- end if;
-- raise Constraint_Error;
-- raise Console.TE;
-- raise Constraint_Error;
-- Put (Natural 'Image (54),
-- Screen_Width_Range'First,
-- Screen_Height_Range'First + 1);
-- exception
-- when Constraint_Error =>
-- Put ("Constraint Error caught", 1, 15);
-- when Program_Error =>
-- null;
-- when Console.TE =>
-- Put ("TE caught", 1, 2);
end Bare_Bones;
-- pragma No_Return (Bare_Bones);
|
alexcamposruiz/dds-requestreply | Ada | 34,092 | adb | pragma Ada_2012;
package body DDS.Request_Reply.Connext_C_Replier.Generic_REPLIER is
use type DDS.ReturnCode_T;
With_Warnings : constant boolean := False;
-- =========================================================================
-- =========================================================================
--
-- DDS_ReturnCode_t TReqTRepReplier_loan_or_copy_samplesI(
-- TReqTRepReplier * self,
-- DDS_ReturnCode_t inRetCode,
-- struct TReqSeq* received_data,
-- DDS_Boolean isLoan,
-- void **dataPtrArray,
-- int dataCount,
-- struct DDS_SampleInfoSeq* info_seq)
-- {
-- DDS_ReturnCode_t result = inRetCode;
--
-- if (inRetCode == DDS_RETCODE_NO_DATA) {
-- TReqSeq_set_length(received_data, 0);
-- goto done;
-- }
--
-- if (inRetCode != DDS_RETCODE_OK) {
-- goto done;
-- }
--
-- if (isLoan) {
-- /* loan buffer to sequence */
-- if (!TReqSeq_loan_discontiguous(received_data,
-- (TReq **)dataPtrArray, dataCount,
-- dataCount)) {
-- /* this should never happen */
-- result = DDS_RETCODE_ERROR;
-- /* since we failed to loan data to data seq, but data is already
-- taken, we will need to return it still.
-- Note that data will be lost in this case */
-- RTI_Connext_EntityUntypedImpl_return_loan(
-- self->parent._impl, dataPtrArray, info_seq);
-- }
-- } else {
-- /* data is already copied to dataSeqContiguousBuffer */
-- if (!TReqSeq_set_length(received_data, dataCount)) {
-- /* this should never happen */
-- result = DDS_RETCODE_ERROR;
-- }
-- }
--
-- done:
--
-- return result;
-- }
function Loan_Or_Copy_SamplesI
(Self : TReplier;
InRetCode : DDS.ReturnCode_T;
Received_Data : not null access ReqDataReader.Treats.Data_Sequences.Sequence;
IsLoan : DDS.Boolean;
DataPtrArray : not null access ReqDataReader.Treats.Data_Array;
DataCount : ReqDataReader.Treats.Index_Type;
Info_Seq : DDS.SampleInfo_Seq.Sequence) return DDS.ReturnCode_T is
Result : DDS.ReturnCode_T := InRetCode;
use ReqDataReader.Treats.Data_Sequences;
begin
if InRetCode = DDS.RETCODE_NO_DATA then
Set_Length (Received_Data, 0);
return Result;
end if;
if IsLoan then
-- /* loan buffer to sequence */
pragma Compile_Time_Warning (With_Warnings, "Check");
-- Loan_Discontiguous (Self => Received_Data,
-- Buffer => ReqDataReader.Treats.Element_Access'(DataPtrArray.all (DataPtrArray.all'First)'Access),
-- New_Length => DataCount,
-- New_Max => DataCount);
Set_Length (Received_Data, DataCount);
end if;
return DDS.RETCODE_OK;
exception
when others =>
return Result;
-- RTI.Connext_EntityUntypedImpl_Return_Loan (Self.Parent, DataPtrArray, Info_Seq);
end;
-- =========================================================================
-- =========================================================================
-- DDS_ReturnCode_t TReqTRepReplier_take_request(
-- TReqTRepReplier* self,
-- TReq * request,
-- struct DDS_SampleInfo * sample_info)
-- {
-- DDS_ReturnCode_t retCode = DDS_RETCODE_OK;
--
-- struct DDS_SampleInfoSeq info_seq = DDS_SEQUENCE_INITIALIZER;
-- void ** data = NULL;
-- int count = 0;
-- DDS_Boolean isLoan = DDS_BOOLEAN_TRUE;
--
-- if(self == NULL) {
-- DDSLog_exception(&DDS_LOG_BAD_PARAMETER_s,
-- "self");
-- return DDS_RETCODE_BAD_PARAMETER;
-- }
-- if(request == NULL) {
-- DDSLog_exception(&DDS_LOG_BAD_PARAMETER_s,
-- "request");
-- return DDS_RETCODE_BAD_PARAMETER;
-- }
-- if(sample_info == NULL) {
-- DDSLog_exception(&DDS_LOG_BAD_PARAMETER_s,
-- "sample_info");
-- return DDS_RETCODE_BAD_PARAMETER;
-- }
-- sample_info->valid_data = DDS_BOOLEAN_FALSE;
--
-- /* No read condition, get any reply */
-- retCode = RTI_Connext_EntityUntypedImpl_get_sample_loaned(
-- self->parent._impl,
-- &data,
-- &count,
-- &isLoan,
-- NULL,
-- &info_seq,
-- (DDS_Long)0, /* dataSeqLen */
-- (DDS_Long)0, /* dataSeqMaxLen */
-- DDS_BOOLEAN_TRUE, /* dataSeqHasOwnership */
-- 1,
-- NULL,
-- RTI_TRUE);
--
-- if (retCode != DDS_RETCODE_OK) {
-- if (retCode != DDS_RETCODE_NO_DATA ) {
-- DDSLog_exception(&RTI_LOG_ANY_FAILURE_s,
-- "get sample");
-- }
-- return retCode;
-- }
--
-- retCode = TReqTypeSupport_copy_data(request, *((TReq**)data));
-- if(retCode != DDS_RETCODE_OK) {
-- DDSLog_exception(&RTI_LOG_ANY_FAILURE_s,
-- "copy sample");
-- goto done;
-- }
--
-- if(DDS_SampleInfoSeq_get_length(&info_seq) != 0) {
-- /* TODO: implement copy function? */
-- *sample_info = DDS_SampleInfoSeq_get(&info_seq, 0);
-- }
--
-- done:
-- RTI_Connext_EntityUntypedImpl_return_loan(self->parent._impl, data, &info_seq);
-- return retCode;
-- }
------------------
-- Take_Request --
------------------
function Take_Request
(Self : not null access TReplier;
Request : out TReq.Data_Type;
Sample_Info : out DDS.SampleInfo) return DDS.ReturnCode_T
is
RetCode : ReturnCode_T;
--
-- struct DDS_SampleInfoSeq info_seq = DDS_SEQUENCE_INITIALIZER;
-- void ** data = NULL;
-- int count = 0;
-- DDS_Boolean isLoan = DDS_BOOLEAN_TRUE;
begin
sample_info.valid_data := False;
--
-- /* No read condition, get any reply */
-- retCode = RTI_Connext_EntityUntypedImpl_get_sample_loaned(
-- self->parent._impl,
-- &data,
-- &count,
-- &isLoan,
-- NULL,
-- &info_seq,
-- (DDS_Long)0, /* dataSeqLen */
-- (DDS_Long)0, /* dataSeqMaxLen */
-- DDS_BOOLEAN_TRUE, /* dataSeqHasOwnership */
-- 1,
-- NULL,
-- RTI_TRUE);
if (retCode /= DDS.RETCODE_OK) then
if (retCode /= DDS.RETCODE_NO_DATA ) then
DDSLog_Exception ("get sample");
end if;
return retCode;
end if;
--
-- retCode = TReqTypeSupport_copy_data(request, *((TReq**)data));
-- if(retCode != DDS_RETCODE_OK) {
-- DDSLog_exception(&RTI_LOG_ANY_FAILURE_s,
-- "copy sample");
-- goto done;
-- }
--
-- if(DDS_SampleInfoSeq_get_length(&info_seq) != 0) {
-- /* TODO: implement copy function? */
-- *sample_info = DDS_SampleInfoSeq_get(&info_seq, 0);
-- }
--
-- done:
-- RTI_Connext_EntityUntypedImpl_return_loan(self->parent._impl, data, &info_seq);
-- return retCode;
pragma Compile_Time_Warning (Standard.True,
"Take_Request unimplemented");
return raise Program_Error with "Unimplemented function Take_Request";
end Take_Request;
--
-- /* TODO: do checking on params */
-- DDS_ReturnCode_t TReqTRepReplier_take_requests(
-- TReqTRepReplier* self,
-- struct TReqSeq* requests,
-- struct DDS_SampleInfoSeq * info_seq,
-- DDS_Long max_request_count)
-- {
--
-- DDS_Long dataSeqLen = 0;
-- DDS_Long dataSeqMaxLen = 0;
-- DDS_Boolean dataSeqHasOwnership = DDS_BOOLEAN_FALSE;
-- DDS_Boolean isLoan = DDS_BOOLEAN_TRUE;
-- void **dataPtrArray = NULL;
-- int dataCount = 0;
-- DDS_ReturnCode_t result = DDS_RETCODE_OK;
-- TReq *dataSeqContiguousBuffer = NULL;
--
-- /* --- Check parameters --- */
-- if (requests == NULL) {
-- DDSLog_exception(&DDS_LOG_BAD_PARAMETER_s,
-- "requests is NULL");
-- return DDS_RETCODE_BAD_PARAMETER;
-- }
--
-- /* --- get dataSeq information --- */
-- dataSeqLen = TReqSeq_get_length(requests);
-- dataSeqMaxLen = TReqSeq_get_maximum(requests);
-- dataSeqHasOwnership = TReqSeq_has_ownership(requests);
-- dataSeqContiguousBuffer = TReqSeq_get_contiguous_bufferI(requests);
--
-- result = RTI_Connext_EntityUntypedImpl_get_sample_loaned(
-- self->parent._impl,
-- &dataPtrArray,
-- &dataCount,
-- &isLoan,
-- (void*)dataSeqContiguousBuffer,
-- info_seq,
-- dataSeqLen,
-- dataSeqMaxLen,
-- dataSeqHasOwnership,
-- max_request_count,
-- NULL,
-- RTI_TRUE);
--
-- result = TReqTRepReplier_loan_or_copy_samplesI(
-- self, result, requests,
-- isLoan, dataPtrArray, dataCount, info_seq);
--
-- if(result != DDS_RETCODE_OK && result != DDS_RETCODE_NO_DATA) {
-- DDSLog_exception(&DDS_LOG_BAD_PARAMETER_s,
-- "error loan or copying data");
-- }
--
-- return result;
-- }
-------------------
-- Take_Requests --
-------------------
function Take_Requests
(Self : not null access TReplier;
Request : out TReq.Data_Array;
Sample_Info : out DDS.SampleInfo_Seq.Sequence) return DDS.ReturnCode_T
is
begin
pragma Compile_Time_Warning (Standard.True,
"Take_Requests unimplemented");
return raise Program_Error with "Unimplemented function Take_Requests";
end Take_Requests;
-- =========================================================================
-- =========================================================================
--
-- DDS_ReturnCode_t TReqTRepReplier_read_request(
-- TReqTRepReplier* self,
-- TReq * request,
-- struct DDS_SampleInfo * sample_info)
-- {
-- DDS_ReturnCode_t retCode = DDS_RETCODE_OK;
--
-- struct DDS_SampleInfoSeq info_seq = DDS_SEQUENCE_INITIALIZER;
-- void ** data = NULL;
-- int count = 0;
-- DDS_Boolean isLoan = DDS_BOOLEAN_TRUE;
--
-- if(self == NULL) {
-- DDSLog_exception(&DDS_LOG_BAD_PARAMETER_s,
-- "self");
-- return DDS_RETCODE_BAD_PARAMETER;
-- }
-- if(request == NULL) {
-- DDSLog_exception(&DDS_LOG_BAD_PARAMETER_s,
-- "request");
-- return DDS_RETCODE_BAD_PARAMETER;
-- }
-- if(sample_info == NULL) {
-- DDSLog_exception(&DDS_LOG_BAD_PARAMETER_s,
-- "sample_info");
-- return DDS_RETCODE_BAD_PARAMETER;
-- }
-- sample_info->valid_data = DDS_BOOLEAN_FALSE;
--
-- /* No read condition, get any reply */
-- retCode = RTI_Connext_EntityUntypedImpl_get_sample_loaned(
-- self->parent._impl,
-- &data,
-- &count,
-- &isLoan,
-- NULL,
-- &info_seq,
-- (DDS_Long)0, /* dataSeqLen */
-- (DDS_Long)0, /* dataSeqMaxLen */
-- DDS_BOOLEAN_TRUE, /* dataSeqHasOwnership */
-- 1,
-- NULL,
-- RTI_FALSE);
--
-- if (retCode != DDS_RETCODE_OK) {
-- if (retCode != DDS_RETCODE_NO_DATA ) {
-- DDSLog_exception(&RTI_LOG_ANY_FAILURE_s,
-- "get sample");
-- }
-- return retCode;
-- }
--
-- retCode = TReqTypeSupport_copy_data(request, *((TReq**)data));
-- if(retCode != DDS_RETCODE_OK) {
-- DDSLog_exception(&RTI_LOG_ANY_FAILURE_s,
-- "copy sample");
-- goto done;
-- }
--
-- if(DDS_SampleInfoSeq_get_length(&info_seq) != 0) {
-- /* TODO: implement copy function? */
-- *sample_info = DDS_SampleInfoSeq_get(&info_seq, 0);
-- }
--
-- done:
-- RTI_Connext_EntityUntypedImpl_return_loan(self->parent._impl, data, &info_seq);
-- return retCode;
-- }
--
------------------
-- Read_Request --
------------------
function Read_Request
(Self : not null access TReplier;
Request : out TReq.Data_Type;
Sample_Info : out DDS.SampleInfo) return DDS.ReturnCode_T
is
begin
pragma Compile_Time_Warning (Standard.True,
"Read_Request unimplemented");
return raise Program_Error with "Unimplemented function Read_Request";
end Read_Request;
-- =========================================================================
-- =========================================================================
-- /* TODO: do checking on params */
-- DDS_ReturnCode_t TReqTRepReplier_read_requests(
-- TReqTRepReplier* self,
-- struct TReqSeq* requests,
-- struct DDS_SampleInfoSeq * info_seq,
-- DDS_Long max_request_count)
-- {
--
-- DDS_Long dataSeqLen = 0;
-- DDS_Long dataSeqMaxLen = 0;
-- DDS_Boolean dataSeqHasOwnership = DDS_BOOLEAN_FALSE;
-- DDS_Boolean isLoan = DDS_BOOLEAN_TRUE;
-- void **dataPtrArray = NULL;
-- int dataCount = 0;
-- DDS_ReturnCode_t result = DDS_RETCODE_OK;
-- TReq *dataSeqContiguousBuffer = NULL;
--
-- /* --- Check parameters --- */
-- if (requests == NULL) {
-- DDSLog_exception(&DDS_LOG_BAD_PARAMETER_s,
-- "requests is NULL");
-- return DDS_RETCODE_BAD_PARAMETER;
-- }
--
-- /* --- get dataSeq information --- */
-- dataSeqLen = TReqSeq_get_length(requests);
-- dataSeqMaxLen = TReqSeq_get_maximum(requests);
-- dataSeqHasOwnership = TReqSeq_has_ownership(requests);
-- dataSeqContiguousBuffer = TReqSeq_get_contiguous_bufferI(requests);
--
-- result = RTI_Connext_EntityUntypedImpl_get_sample_loaned(
-- self->parent._impl,
-- &dataPtrArray,
-- &dataCount,
-- &isLoan,
-- (void*)dataSeqContiguousBuffer,
-- info_seq,
-- dataSeqLen,
-- dataSeqMaxLen,
-- dataSeqHasOwnership,
-- max_request_count,
-- NULL,
-- RTI_FALSE);
--
-- result = TReqTRepReplier_loan_or_copy_samplesI(
-- self, result, requests,
-- isLoan, dataPtrArray, dataCount, info_seq);
--
-- if(result != DDS_RETCODE_OK && result != DDS_RETCODE_NO_DATA) {
-- DDSLog_exception(&DDS_LOG_BAD_PARAMETER_s,
-- "error loan or copying data");
-- }
--
-- return result;
-- }
------------------
-- Read_Request --
------------------
function Read_Requests
(Self : not null access TReplier;
Request : out TReq.Data_Type;
Sample_Info : out DDS.SampleInfo) return DDS.ReturnCode_T
is
begin
pragma Compile_Time_Warning (Standard.True,
"Read_Request unimplemented");
return raise Program_Error with "Unimplemented function Read_Request";
end Read_Requests;
-- =========================================================================
-- =========================================================================
--
-- DDS_ReturnCode_t TReqTRepReplier_receive_request(
-- TReqTRepReplier * self,
-- TReq * request,
-- struct DDS_SampleInfo * sample_info,
-- const struct DDS_Duration_t * max_wait)
-- {
-- DDS_ReturnCode_t retCode = DDS_RETCODE_OK;
--
-- if(self == NULL) {
-- DDSLog_exception(&DDS_LOG_BAD_PARAMETER_s,
-- "self");
-- return DDS_RETCODE_BAD_PARAMETER;
-- }
-- if(request == NULL) {
-- DDSLog_exception(&DDS_LOG_BAD_PARAMETER_s,
-- "request");
-- return DDS_RETCODE_BAD_PARAMETER;
-- }
-- if(sample_info == NULL) {
-- DDSLog_exception(&DDS_LOG_BAD_PARAMETER_s,
-- "sample_info");
-- return DDS_RETCODE_BAD_PARAMETER;
-- }
-- if(max_wait == NULL) {
-- DDSLog_exception(&DDS_LOG_BAD_PARAMETER_s,
-- "max_wait");
-- return DDS_RETCODE_BAD_PARAMETER;
-- }
-- sample_info->valid_data = DDS_BOOLEAN_FALSE;
--
-- retCode = RTI_Connext_Replier_wait_for_requests(
-- (RTI_Connext_Replier *) self, 1, max_wait);
-- if (retCode != DDS_RETCODE_OK) {
-- if (retCode != DDS_RETCODE_TIMEOUT) {
-- DDSLog_exception(&RTI_LOG_ANY_FAILURE_s,
-- "wait for requests");
-- }
-- return retCode;
-- }
--
-- retCode = TReqTRepReplier_take_request(self, request, sample_info);
-- if (retCode != DDS_RETCODE_OK) {
-- if (retCode != DDS_RETCODE_NO_DATA) {
-- DDSLog_exception(&RTI_LOG_ANY_FAILURE_s,
-- "get request");
-- }
-- return retCode;
-- }
--
-- return DDS_RETCODE_OK;
-- }
---------------------
-- Receive_Request --
---------------------
function Receive_Request
(Self : not null access TReplier; Request : out TReq.Data_Type;
Sample_Info : out DDS.SampleInfo; Max_Wait : DDS.Duration_T) return DDS
.ReturnCode_T
is
begin
pragma Compile_Time_Warning (Standard.True,
"Receive_Request unimplemented");
return raise Program_Error with "Unimplemented function Receive_Request";
end Receive_Request;
-- =========================================================================
-- =========================================================================
--
-- DDS_ReturnCode_t TReqTRepReplier_receive_requests(
-- TReqTRepReplier * self,
-- struct TReqSeq * requests,
-- struct DDS_SampleInfoSeq * info_seq,
-- DDS_Long min_count,
-- DDS_Long max_count,
-- const struct DDS_Duration_t * max_wait)
-- {
-- DDS_ReturnCode_t retCode = DDS_RETCODE_OK;
--
-- if(self == NULL) {
-- DDSLog_exception(&DDS_LOG_BAD_PARAMETER_s,
-- "self");
-- return DDS_RETCODE_BAD_PARAMETER;
-- }
-- if(requests == NULL) {
-- DDSLog_exception(&DDS_LOG_BAD_PARAMETER_s,
-- "requests");
-- return DDS_RETCODE_BAD_PARAMETER;
-- }
-- if(info_seq == NULL) {
-- DDSLog_exception(&DDS_LOG_BAD_PARAMETER_s,
-- "info_seq");
-- return DDS_RETCODE_BAD_PARAMETER;
-- }
-- if(max_wait == NULL) {
-- DDSLog_exception(&DDS_LOG_BAD_PARAMETER_s,
-- "max_wait");
-- return DDS_RETCODE_BAD_PARAMETER;
-- }
--
-- if (!RTI_Connext_EntityUntypedImpl_validate_receive_params(
-- self->parent._impl, RTI_FUNCTION_NAME, min_count, max_count, max_wait)) {
-- return DDS_RETCODE_BAD_PARAMETER;
-- }
--
-- retCode = RTI_Connext_Replier_wait_for_requests(
-- (RTI_Connext_Replier *) self, min_count, max_wait);
-- if (retCode != DDS_RETCODE_OK) {
-- if (retCode != DDS_RETCODE_TIMEOUT) {
-- DDSLog_exception(&RTI_LOG_ANY_FAILURE_s,
-- "wait for requests");
-- }
-- return retCode;
-- }
--
-- retCode = TReqTRepReplier_take_requests(
-- self, requests, info_seq, max_count);
-- if (retCode != DDS_RETCODE_OK) {
-- if (retCode != DDS_RETCODE_NO_DATA) {
-- DDSLog_exception(&RTI_LOG_ANY_FAILURE_s,
-- "get requests");
-- }
-- return retCode;
-- }
--
-- return DDS_RETCODE_OK;
-- }
--
----------------------
-- Receive_Requests --
----------------------
function Receive_Requests
(Self : not null access TReplier; Request : out TReq.Data_Array;
Sample_Info : out DDS.SampleInfo_Seq.Sequence;
Min_Reply_Count : DDS.long; Max_Reply_Count : DDS.long;
Max_Wait : DDS.Duration_T) return DDS.ReturnCode_T
is
begin
pragma Compile_Time_Warning (Standard.True,
"Receive_Requests unimplemented");
return raise Program_Error
with "Unimplemented function Receive_Requests";
end Receive_Requests;
-------------------
-- Read_Requests --
-------------------
function Read_Requests
(Self : not null access TReplier; Request : out TReq.Data_Array;
Sample_Info : out DDS.SampleInfo_Seq.Sequence) return DDS.ReturnCode_T
is
begin
pragma Compile_Time_Warning (Standard.True,
"Read_Requests unimplemented");
return raise Program_Error with "Unimplemented function Read_Requests";
end Read_Requests;
-- =========================================================================
-- =========================================================================
-- /* TODO: add TReqTRepReplier_send_reply_w_params API */
-- DDS_ReturnCode_t TReqTRepReplier_send_reply(
-- TReqTRepReplier* self,
-- TRep* reply,
-- const struct DDS_SampleIdentity_t * related_request_id)
-- {
-- DDS_ReturnCode_t retCode = DDS_RETCODE_OK;
-- struct DDS_WriteParams_t params = DDS_WRITEPARAMS_DEFAULT;
--
-- if(self == NULL) {
-- DDSLog_exception(&DDS_LOG_BAD_PARAMETER_s,
-- "self");
-- return DDS_RETCODE_BAD_PARAMETER;
-- }
-- if(reply == NULL) {
-- DDSLog_exception(&DDS_LOG_BAD_PARAMETER_s,
-- "reply");
-- return DDS_RETCODE_BAD_PARAMETER;
-- }
-- if(related_request_id == NULL) {
-- DDSLog_exception(&DDS_LOG_BAD_PARAMETER_s,
-- "related_request_id");
-- return DDS_RETCODE_BAD_PARAMETER;
-- }
--
-- retCode = RTI_Connext_ReplierUntypedImpl_send_sample(
-- self->parent._impl, (void*)reply, related_request_id, ¶ms);
--
-- if(retCode != DDS_RETCODE_OK) {
-- DDSLog_exception(&RTI_LOG_ANY_FAILURE_s,
-- "send reply");
-- }
-- return retCode;
-- }
----------------
-- Send_Reply --
----------------
function Send_Reply
(Self : not null access TReplier; Reply : TRep.Data_Type;
Related_Request_Info : DDS.SampleIdentity_T) return Dds.ReturnCode_T
is
begin
pragma Compile_Time_Warning (Standard.True, "Send_Reply unimplemented");
return raise Program_Error with "Unimplemented function Send_Reply";
end Send_Reply;
-- =========================================================================
-- =========================================================================
--
-- TRepDataWriter* TReqTRepReplier_get_reply_datawriter(TReqTRepReplier* self)
-- {
--
-- DDS_DataWriter * internal_writer = NULL;
--
-- if(self == NULL) {
-- DDSLog_exception(&DDS_LOG_BAD_PARAMETER_s,
-- "self");
-- return NULL;
-- }
--
-- internal_writer = RTI_Connext_EntityUntypedImpl_get_datawriter(self->parent._impl);
-- if(internal_writer == NULL) {
-- DDSLog_exception(&RTI_LOG_GET_FAILURE_s,
-- "reply DataWriter");
-- return NULL;
-- }
--
-- return TRepDataWriter_narrow(internal_writer);
-- }
----------------------------
-- Get_Reply_Datawriter --
----------------------------
function Get_Reply_Datawriter
(Self : not null access TReplier) return DDS.DataWriter.Ref_Access
is
begin
pragma Compile_Time_Warning (Standard.True,
"Get_Reply_Datawriter unimplemented");
return raise Program_Error
with "Unimplemented function Get_Reply_Datawriter";
end Get_Reply_Datawriter;
-- =========================================================================
-- =========================================================================
--
-- TReqDataReader * TReqTRepReplier_get_request_datareader(TReqTRepReplier* self)
-- {
--
-- DDS_DataReader* internal_reader = NULL;
--
-- if(self == NULL) {
-- DDSLog_exception(&DDS_LOG_BAD_PARAMETER_s,
-- "self");
-- return NULL;
-- }
--
-- internal_reader = RTI_Connext_EntityUntypedImpl_get_datareader(self->parent._impl);
-- if(internal_reader == NULL) {
-- DDSLog_exception(&RTI_LOG_GET_FAILURE_s,
-- "request DataReader");
-- return NULL;
-- }
--
-- return TReqDataReader_narrow(internal_reader);
-- }
----------------------------
-- Get_Request_Datareader --
----------------------------
function Get_Request_Datareader
(Self : not null access TReplier) return DDS.DataReader.Ref_Access
is
begin
pragma Compile_Time_Warning (Standard.True,
"Get_Request_Datareader unimplemented");
return raise Program_Error
with "Unimplemented function Get_Request_Datareader";
end Get_Request_Datareader;
-- =========================================================================
-- =========================================================================
--
-- DDS_ReturnCode_t TReqTRepReplier_return_loan(
-- TReqTRepReplier* self,
-- struct TReqSeq *replies,
-- struct DDS_SampleInfoSeq *info_seq)
-- {
-- DDS_ReturnCode_t retCode = DDS_RETCODE_OK;
-- TReqDataReader * reader = NULL;
--
-- if(self == NULL) {
-- DDSLog_exception(&DDS_LOG_BAD_PARAMETER_s,
-- "self");
-- return DDS_RETCODE_BAD_PARAMETER;
-- }
-- if(replies == NULL) {
-- DDSLog_exception(&DDS_LOG_BAD_PARAMETER_s,
-- "replies");
-- return DDS_RETCODE_BAD_PARAMETER;
-- }
-- if(info_seq == NULL) {
-- DDSLog_exception(&DDS_LOG_BAD_PARAMETER_s,
-- "info_seq");
-- return DDS_RETCODE_BAD_PARAMETER;
-- }
--
-- reader = TReqTRepReplier_get_request_datareader(self);
-- if (reader == NULL) {
-- DDSLog_exception(&RTI_LOG_GET_FAILURE_s,
-- "reader to return loan");
-- return DDS_RETCODE_ERROR;
-- }
--
-- retCode = TReqDataReader_return_loan(reader, replies, info_seq);
-- if(retCode != DDS_RETCODE_OK) {
-- DDSLog_exception(&RTI_LOG_ANY_FAILURE_s,
-- "return loan");
-- return retCode;
-- }
--
-- return retCode;
-- }
-----------------
-- Return_Loan --
-----------------
function Return_Loan
(Self : not null access TReplier; Request : out TReq.Data_Array;
Sample_Info : out DDS.SampleInfo_Seq.Sequence) return Dds.ReturnCode_T
is
begin
pragma Compile_Time_Warning (Standard.True, "Return_Loan unimplemented");
return raise Program_Error with "Unimplemented function Return_Loan";
end Return_Loan;
--
-- /* ----------------------------------------------------------------- */
-- /* End of $Id$ */
Dummy : Integer;
-- =========================================================================
-- =========================================================================
--
-- TReqTRepReplier * TReqTRepReplier_create(
-- DDS_DomainParticipant * participant,
-- char* service_name)
-- {
-- TReqTRepReplier* replier = NULL;
--
-- RTI_Connext_ReplierParams params = RTI_Connext_ReplierParams_INITIALIZER;
--
-- params.participant = participant;
-- params.service_name = (char*) service_name;
--
-- replier = TReqTRepReplier_create_w_params(¶ms);
-- if(replier == NULL) {
-- DDSLog_exception(&RTI_LOG_CREATION_FAILURE_s,
-- "replier with params");
-- return NULL;
-- }
--
-- return replier;
-- }
------------
-- Create --
------------
function Create
(Participant : DDS.DomainParticipant.Ref_Access;
Service_Name : DDS.String) return TReplier_Access
is
Params : RTI_Connext_ReplierParams;
begin
return Ret : TReplier_Access do
Params.Participant := Participant;
DDS.Copy (Params.Service_Name, Service_Name);
Ret := Create_W_Params (Params);
if Ret = null then
raise Constraint_Error with "unable to create Replier";
end if;
end return;
end Create;
-- =========================================================================
-- =========================================================================
--
-- TReqTRepReplier* TReqTRepReplier_create_w_params(
-- const RTI_Connext_ReplierParams* params)
-- {
-- TReqTRepReplier* replier = NULL;
-- struct DDS_DataReaderListener reader_listener =
-- DDS_DataReaderListener_INITIALIZER;
-- RTI_Connext_EntityParams entity_params;
-- DDS_ReturnCode_t retcode;
--
-- if(params == NULL) {
-- DDSLog_exception(&DDS_LOG_BAD_PARAMETER_s,
-- "params");
-- return NULL;
-- }
--
-- RTIOsapiHeap_allocateStructure(&replier, TReqTRepReplier);
-- if(replier == NULL) {
-- DDSLog_exception(&RTI_LOG_ANY_FAILURE_s,
-- "error creating a TReqTRepReplier");
-- goto finish;
-- }
--
-- if (params->listener != NULL) {
-- replier->parent.listener = *params->listener;
-- } else {
-- replier->parent.listener.on_request_available = NULL;
-- }
--
-- replier->parent._impl = RTI_Connext_ReplierUntypedImpl_create();
-- if(replier->parent._impl == NULL) {
-- DDSLog_exception(&RTI_LOG_CREATION_FAILURE_s,
-- "ReplierUntypedImpl");
-- goto finish;
-- }
--
-- RTI_Connext_ReplierParams_toEntityParams(params, &entity_params);
--
-- reader_listener.on_data_available = RTI_Connext_Replier_on_data_available;
-- reader_listener.as_listener.listener_data = replier;
--
-- retcode = RTI_Connext_ReplierUntypedImpl_initialize(
-- replier->parent._impl,
-- &entity_params,
-- &TReqTypeSupport_register_type,
-- TReqTypeSupport_get_type_name(),
-- &TRepTypeSupport_register_type,
-- TRepTypeSupport_get_type_name(),
-- sizeof(TReq),
-- params->listener != NULL ? &reader_listener : NULL);
--
-- if (retcode != DDS_RETCODE_OK) {
-- DDSLog_exception(&RTI_LOG_ANY_FAILURE_s,
-- "initialize ReplierUntypedImpl");
-- goto finish;
-- }
--
-- return replier;
--
-- finish:
-- if(replier != NULL) {
-- RTI_Connext_Replier_delete((RTI_Connext_Replier *) replier);
-- }
-- return NULL;
-- }
--
---------------------
-- Create_W_Params --
---------------------
function Create_W_Params
(Params : RTI_Connext_ReplierParams) return TReplier_Access
is
RetCode : Dds.ReturnCode_T;
Replier : TReplier_Access;
begin
Replier := new TReplier;
if Params.Listener /= null then
Replier.Listener := Params.Listener;
end if;
RetCode := RTI_Connext_ReplierParams_ToEntityParams (Params, Ret.Entity_Params);
-- reader_listener.on_data_available = RTI_Connext_Replier_on_data_available;
-- reader_listener.as_listener.listener_data = replier;
return Replier;
end Create_W_Params;
--------------------------
-- Get_Reply_Datawriter --
--------------------------
end DDS.Request_Reply.Connext_C_Replier.Generic_REPLIER;
|
Rodeo-McCabe/orka | Ada | 3,800 | adb | -- SPDX-License-Identifier: Apache-2.0
--
-- Copyright (c) 2013 Felix Krause <[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 Glfw.API;
with Glfw.Enums;
package body Glfw.Windows.Context is
procedure Make_Current (Window : access Glfw.Windows.Window'Class) is
begin
if Window = null then
if not Current.Initialized then
-- null is accepted to detach the current context, but an uninitialized
-- window *should* lead to an exception instead of detaching the
-- context, so we handle this here
raise Operation_Exception with "Window not initialized";
end if;
API.Make_Context_Current (System.Null_Address);
else
if not Window.Initialized then
raise Operation_Exception with "Window not initialized";
end if;
API.Make_Context_Current (Window.Handle);
end if;
end Make_Current;
function Current return access Glfw.Windows.Window'Class is
use type System.Address;
Raw : constant System.Address := API.Get_Current_Context;
begin
if Raw = System.Null_Address then
return null;
else
return Window_Ptr (Raw);
end if;
end Current;
procedure Swap_Buffers (Window : not null access Glfw.Windows.Window'Class) is
begin
API.Swap_Buffers (Window.Handle);
end Swap_Buffers;
procedure Set_Swap_Interval (Value : Swap_Interval) renames
API.Swap_Interval;
function Client_API (Window : not null access Glfw.Windows.Window'Class)
return API_Kind is
begin
return API.Get_Window_Attrib (Window.Handle, Enums.Client_API);
end Client_API;
function Profile (Window : not null access Glfw.Windows.Window'Class)
return OpenGL_Profile_Kind is
begin
return API.Get_Window_Attrib (Window.Handle, Enums.OpenGL_Profile);
end Profile;
procedure Get_Context_Version
(Window : not null access Glfw.Windows.Window'Class;
Major : out Positive;
Minor, Revision : out Natural) is
begin
Major := Positive (Interfaces.C.int'(
(API.Get_Window_Attrib (Window.Handle, Enums.Context_Version_Major))));
Minor := Natural (Interfaces.C.int'(
(API.Get_Window_Attrib (Window.Handle, Enums.Context_Version_Minor))));
Revision := Natural (Interfaces.C.int'(
(API.Get_Window_Attrib (Window.Handle, Enums.Context_Revision))));
end Get_Context_Version;
function Is_Forward_Compat
(Window : not null access Glfw.Windows.Window'Class) return Boolean is
begin
return Boolean (Bool'(API.Get_Window_Attrib
(Window.Handle, Enums.OpenGL_Forward_Compat)));
end Is_Forward_Compat;
function Is_Debug_Context
(Window : not null access Glfw.Windows.Window'Class) return Boolean is
begin
return Boolean (Bool'(API.Get_Window_Attrib
(Window.Handle, Enums.OpenGL_Debug_Context)));
end Is_Debug_Context;
function Robustness (Window : not null access Glfw.Windows.Window'Class)
return Robustness_Kind is
begin
return API.Get_Window_Attrib (Window.Handle, Enums.Context_Robustness);
end Robustness;
end Glfw.Windows.Context;
|
jwarwick/aoc_2020 | Ada | 434 | ads | -- AOC 2020, Day 23
package Day is
type Cup_Number is range 1..9;
type Cup_Number_Mod is mod Cup_Number'Last + 1;
type Cup_Index is range 0..8;
type Cup_Index_Mod is mod Cup_Index'Last + 1;
type Cup_Array is array(Cup_Index) of Cup_Number;
function play(c : in Cup_Array; steps : in Natural) return String;
function play2(c : in Cup_Array; total_cups : in Natural; steps : in Natural) return Long_Integer;
end Day;
|
sungyeon/drake | Ada | 462 | ads | pragma License (Unrestricted);
generic
type T (<>) is abstract tagged limited private;
type Parameters (<>) is limited private;
with function Constructor (Params : not null access Parameters)
return T is abstract;
function Ada.Tags.Generic_Dispatching_Constructor (
The_Tag : Tag;
Params : not null access Parameters)
return T'Class
with Import, Convention => Intrinsic;
pragma Preelaborate (Ada.Tags.Generic_Dispatching_Constructor);
|
stcarrez/mat | Ada | 1,257 | ads | -----------------------------------------------------------------------
-- mat-memory-tests -- Unit tests for MAT memory
-- Copyright (C) 2014 Stephane Carrez
-- Written by Stephane Carrez ([email protected])
--
-- Licensed under the Apache License, Version 2.0 (the "License");
-- you may not use this file except in compliance with the License.
-- You may obtain a copy of the License at
--
-- http://www.apache.org/licenses/LICENSE-2.0
--
-- Unless required by applicable law or agreed to in writing, software
-- distributed under the License is distributed on an "AS IS" BASIS,
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-- See the License for the specific language governing permissions and
-- limitations under the License.
-----------------------------------------------------------------------
with Util.Tests;
package MAT.Memory.Tests is
procedure Add_Tests (Suite : in Util.Tests.Access_Test_Suite);
type Test is new Util.Tests.Test with null record;
-- Test Probe_Malloc with update of memory slots.
procedure Test_Probe_Malloc (T : in out Test);
-- Test Probe_Free with update of memory slots.
procedure Test_Probe_Free (T : in out Test);
end MAT.Memory.Tests;
|
reznikmm/matreshka | Ada | 4,183 | adb | ------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- XML Processor --
-- --
-- Runtime Library Component --
-- --
------------------------------------------------------------------------------
-- --
-- Copyright © 2013, Vadim Godunko <[email protected]> --
-- All rights reserved. --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions --
-- are met: --
-- --
-- * Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- --
-- * Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in the --
-- documentation and/or other materials provided with the distribution. --
-- --
-- * Neither the name of the Vadim Godunko, IE nor the names of its --
-- contributors may be used to endorse or promote products derived from --
-- this software without specific prior written permission. --
-- --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR --
-- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
-- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED --
-- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR --
-- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF --
-- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING --
-- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS --
-- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
-- --
------------------------------------------------------------------------------
-- $Revision$ $Date$
------------------------------------------------------------------------------
with Matreshka.DOM_Nodes.Character_Datas;
package body XML.DOM.Nodes.Character_Datas is
--------------
-- Get_Data --
--------------
function Get_Data
(Self : DOM_Character_Data'Class) return League.Strings.Universal_String is
begin
return Matreshka.DOM_Nodes.Character_Data_Access (Self.Node).Data;
end Get_Data;
------------------
-- Replace_Data --
------------------
procedure Replace_Data
(Self : in out DOM_Character_Data'Class;
Offset : Positive;
Count : Natural;
Arg : League.Strings.Universal_String)
is
Node : constant Matreshka.DOM_Nodes.Character_Data_Access
:= Matreshka.DOM_Nodes.Character_Data_Access (Self.Node);
begin
Node.Data.Replace (Offset, Offset + Count - 1, Arg);
end Replace_Data;
end XML.DOM.Nodes.Character_Datas;
|
AdaCore/ada-traits-containers | Ada | 5,483 | ads | --
-- Copyright (C) 2015-2016, AdaCore
--
-- SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
--
-- This package provides signature packages that describe how to iterate over
-- containers.
-- Such cursors do not provide access to the elements that are in the
-- container, this is done via a separate instance of property maps (see
-- the package Conts.Properties for more information). Separating the two
-- concepts keeps them simpler:
-- We currently provide Forward, Bidirectional and Random_Access cursors
-- If accessing and modifying the elements was built into the concept of
-- cursors, we would need an extra version for all of these to mean
-- Constant_Forward, Constant_Bidirectional and Constant_Random_Access, and
-- perhaps even a concept of Write_Only cursor (for output streams for
-- instance).
pragma Ada_2012;
package Conts.Cursors with SPARK_Mode is
---------------------
-- Forward_Cursors --
---------------------
-- A package that describes how to use forward cursors. Each container
-- for which this is applicable provides an instance of this package,
-- and algorithms should take this package as a generic parameter.
generic
type Container_Type (<>) is limited private;
type Cursor_Type is private;
No_Element : Cursor_Type;
with function First (Self : Container_Type) return Cursor_Type is <>;
with function Has_Element (Self : Container_Type; Pos : Cursor_Type)
return Boolean is <>;
with function Next (Self : Container_Type; Pos : Cursor_Type)
return Cursor_Type is <>;
with function "=" (Left, Right : Cursor_Type) return Boolean is <>;
package Forward_Cursors is
subtype Container is Container_Type;
subtype Cursor is Cursor_Type;
end Forward_Cursors;
---------------------------
-- Bidirectional_Cursors --
---------------------------
generic
type Container_Type (<>) is limited private;
type Cursor_Type is private;
No_Element : Cursor_Type;
with function First (Self : Container_Type) return Cursor_Type is <>;
with function Has_Element (Self : Container_Type; Pos : Cursor_Type)
return Boolean is <>;
with function Next (Self : Container_Type; Pos : Cursor_Type)
return Cursor_Type is <>;
with function Previous (Self : Container_Type; Pos : Cursor_Type)
return Cursor_Type is <>;
package Bidirectional_Cursors is
subtype Container is Container_Type;
subtype Cursor is Cursor_Type;
-- A bidirectional cursor is also a forward cursor
package Forward is new Forward_Cursors (Container, Cursor, No_Element);
end Bidirectional_Cursors;
----------------------------
-- Random_Access_Cursors --
----------------------------
-- These are cursors that can access any element from a container, in no
-- specific order.
generic
type Container_Type (<>) is limited private;
type Index_Type is (<>);
No_Element : Index_Type;
with function First (Self : Container_Type) return Index_Type is <>;
-- Index of the first element in the container (often Index_Type'First)
-- ??? Can we remove this parameter and always use Index_Type'First
with function Last (Self : Container_Type) return Index_Type is <>;
-- Return the index of the last valid element in the container.
-- We do not use a Has_Element function, since having an explicit range
-- is more convenient for algorithms (for instance to select random
-- elements in the container).
with function Distance (Left, Right : Index_Type) return Integer is <>;
-- Return the number of elements between the two positions.
with function "+"
(Left : Index_Type; N : Integer) return Index_Type is <>;
-- Move Left forward or backward by a number of position.
package Random_Access_Cursors is
subtype Container is Container_Type;
subtype Index is Index_Type;
function Dist
(Left, Right : Index_Type) return Integer renames Distance;
function Add (Left : Index_Type; N : Integer) return Index_Type
renames "+";
function First_Index (Self : Container_Type) return Index_Type
renames First;
function Last_Index (Self : Container_Type) return Index_Type
renames Last;
-- Make visible to users of the package
-- ??? Why is this necessary in Ada.
function "-" (Left : Index_Type; N : Integer) return Index_Type
is (Left + (-N)) with Inline;
function Next (Self : Container_Type; Idx : Index_Type) return Index_Type
is (Idx + 1) with Inline;
function Previous
(Self : Container_Type; Idx : Index_Type) return Index_Type
is (Idx - 1) with Inline;
function Has_Element
(Self : Container_Type; Idx : Index_Type) return Boolean
is (Idx >= First (Self) and then Idx <= Last (Self)) with Inline;
-- This might be made efficient if you pass a First function that
-- returns a constant and if this contstant is Index_Type'First then
-- the compiler can simply remove the test.
-- A random cursor is also a bidirectional and forward cursor
package Bidirectional is
new Bidirectional_Cursors (Container, Index_Type, No_Element);
package Forward renames Bidirectional.Forward;
end Random_Access_Cursors;
end Conts.Cursors;
|
Tim-Tom/project-euler | Ada | 3,336 | adb | with Ada.Text_IO;
with Ada.Containers.Indefinite_Ordered_Maps;
with PrimeInstances;
with Ada.Numerics.Elementary_Functions;
package body Problem_39 is
package IO renames Ada.Text_IO;
package Math renames Ada.Numerics.Elementary_Functions;
package Positive_Primes renames PrimeInstances.Positive_Primes;
package Positive_Map is new Ada.Containers.Indefinite_Ordered_Maps(Key_Type => Positive,
Element_Type => Positive);
procedure Solve is
maximum : constant Positive := 1_000;
max_f : constant Float := Float(maximum);
-- To generate max_uv, we set u or v to 1 in the formula and solve for the other one.
max_u : constant Positive := Positive((Math.Sqrt(2.0*max_f + 1.0) - 3.0) / 2.0);
max_v : constant Positive := Positive((Math.Sqrt(4.0*max_f + 1.0) - 3.0) / 4.0);
-- This ends up super small. On the order of max ** (1/4)
primes : constant Positive_Primes.Sieve := Positive_Primes.Generate_Sieve(Positive(Math.Sqrt(Float(max_u))));
counts : Positive_Map.Map;
max_count : Positive := 1;
max_number : Positive := 12; -- 3 + 4 + 5
function Coprime(u,v : in Positive) return Boolean is
begin
for prime_index in primes'Range loop
declare
prime : constant Positive := primes(prime_index);
begin
if u mod prime = 0 and v mod prime = 0 then
return False;
end if;
end;
end loop;
return True;
end CoPrime;
procedure Add_Count(sum : in Positive) is
use Positive_Map;
location : constant Positive_Map.Cursor := counts.Find(sum);
begin
if location /= Positive_Map.No_Element then
declare
new_count : constant Positive := Positive_Map.Element(location) + 1;
begin
if new_count > max_count then
max_count := new_count;
max_number := sum;
end if;
counts.Replace_Element(location, new_count);
end;
else
counts.Insert(sum, 1);
end if;
end;
begin
for u in 1 .. max_u loop
-- Not primitive is u is odd
if u mod 2 = 1 then
V_Loop:
for v in 1 .. max_v loop
-- Not primitive unless the numbers are coprime.
if Coprime(u, v) then
declare
sum : constant Positive := 2*(u**2 + 3*u*v + 2*v**2);
begin
if sum <= maximum then
declare
scaled_sum : Positive := sum;
begin
loop
Add_Count(scaled_sum);
scaled_sum := scaled_sum + sum;
exit when scaled_sum > maximum;
end loop;
end;
else
exit V_Loop;
end if;
end;
end if;
end loop V_Loop;
end if;
end loop;
IO.Put_Line(Positive'Image(max_number));
end Solve;
end Problem_39;
|
reznikmm/matreshka | Ada | 4,651 | 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.Form_Time_Elements;
package Matreshka.ODF_Form.Time_Elements is
type Form_Time_Element_Node is
new Matreshka.ODF_Form.Abstract_Form_Element_Node
and ODF.DOM.Form_Time_Elements.ODF_Form_Time
with null record;
overriding function Create
(Parameters : not null access Matreshka.DOM_Elements.Element_L2_Parameters)
return Form_Time_Element_Node;
overriding function Get_Local_Name
(Self : not null access constant Form_Time_Element_Node)
return League.Strings.Universal_String;
overriding procedure Enter_Node
(Self : not null access Form_Time_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 Form_Time_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 Form_Time_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_Form.Time_Elements;
|
Statkus/json-ada | Ada | 9,038 | ads | -- Copyright (c) 2016 onox <[email protected]>
--
-- Licensed under the Apache License, Version 2.0 (the "License");
-- you may not use this file except in compliance with the License.
-- You may obtain a copy of the License at
--
-- http://www.apache.org/licenses/LICENSE-2.0
--
-- Unless required by applicable law or agreed to in writing, software
-- distributed under the License is distributed on an "AS IS" BASIS,
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-- See the License for the specific language governing permissions and
-- limitations under the License.
private with Ada.Containers.Vectors;
private with Ada.Containers.Indefinite_Vectors;
with Ada.Iterator_Interfaces;
with JSON.Streams;
generic
type Integer_Type is range <>;
type Float_Type is digits <>;
Maximum_Number_Length : Positive := 30;
Default_Maximum_Depth : Positive := 10;
package JSON.Types is
pragma Preelaborate;
Maximum_String_Length_Numbers : constant Positive := Maximum_Number_Length;
-----------------------------------------------------------------------------
-- Memory allocator --
-----------------------------------------------------------------------------
subtype Array_Offset is Natural;
type Memory_Allocator
(Maximum_Depth : Positive := Default_Maximum_Depth) is tagged limited private;
function Create_Array
(Object : Memory_Allocator;
Depth : Positive) return Array_Offset;
-- Internal function
function Create_Object
(Object : Memory_Allocator;
Depth : Positive) return Array_Offset;
-- Internal function
type Memory_Allocator_Ptr is not null access all Memory_Allocator;
-----------------------------------------------------------------------------
type Value_Kind is
(Array_Kind,
Object_Kind,
String_Kind,
Integer_Kind,
Float_Kind,
Boolean_Kind,
Null_Kind);
type JSON_Value (Kind : Value_Kind) is tagged private
with Constant_Indexing => Constant_Reference,
Default_Iterator => Iterate,
Iterator_Element => JSON_Value;
function Image (Object : JSON_Value) return String;
-- Value will raise an Invalid_Type_Error exception if
-- the JSON value is of the wrong kind
function Value (Object : JSON_Value) return String;
function Value (Object : JSON_Value) return Integer_Type;
function Value (Object : JSON_Value) return Float_Type;
function Value (Object : JSON_Value) return Boolean;
function Length (Object : JSON_Value) return Natural;
-- Object must be a JSON array or object
function Contains (Object : JSON_Value; Key : String) return Boolean;
-- Return True if the JSON object contains a key-value pair for
-- the given key
--
-- This function has a time complexity of O(n).
--
-- Object must be a JSON object.
function Get (Object : JSON_Value; Index : Positive) return JSON_Value;
-- Return the JSON value at the given index in the JSON array
--
-- Object must be a JSON array.
function Get (Object : JSON_Value; Key : String) return JSON_Value;
-- Return the JSON value for the given key in the JSON object
--
-- This function has a time complexity of O(n).
--
-- Object must be a JSON object.
Invalid_Type_Error : exception;
-----------------------------------------------------------------------------
procedure Append (Object : in out JSON_Value; Value : JSON_Value);
-- Internal procedure
procedure Insert
(Object : in out JSON_Value;
Key : JSON_Value;
Value : JSON_Value;
Check_Duplicate_Keys : Boolean)
with Pre => Key.Kind = String_Kind;
-- Internal procedure
-----------------------------------------------------------------------------
-- Helpers --
-----------------------------------------------------------------------------
function Get_Array_Or_Empty
(Object : JSON_Value; Key : String) return JSON_Value
with Inline;
function Get_Object_Or_Empty
(Object : JSON_Value; Key : String) return JSON_Value
with Inline;
function Get
(Object : JSON_Value;
Key : String;
Default : Integer_Type) return JSON_Value
with Inline;
function Get
(Object : JSON_Value;
Key : String;
Default : Float_Type) return JSON_Value
with Inline;
function Get
(Object : JSON_Value;
Key : String;
Default : Boolean) return JSON_Value
with Inline;
-----------------------------------------------------------------------------
-- Constructors --
-----------------------------------------------------------------------------
function Create_String
(Stream : Streams.Stream_Ptr;
Offset, Length : Streams.AS.Stream_Element_Offset) return JSON_Value;
function Create_Integer (Value : Integer_Type) return JSON_Value;
function Create_Float (Value : Float_Type) return JSON_Value;
function Create_Boolean (Value : Boolean) return JSON_Value;
function Create_Null return JSON_Value;
function Create_Array
(Allocator : Memory_Allocator_Ptr;
Depth : Positive) return JSON_Value;
function Create_Object
(Allocator : Memory_Allocator_Ptr;
Depth : Positive) return JSON_Value;
-----------------------------------------------------------------------------
-- Iterating --
-----------------------------------------------------------------------------
function Constant_Reference (Object : JSON_Value; Index : Positive)
return JSON_Value;
-- For Ada 2012 indexing syntax
function Constant_Reference (Object : JSON_Value; Key : String)
return JSON_Value;
-- For Ada 2012 indexing syntax
type Cursor (<>) is private;
function Constant_Reference (Object : aliased JSON_Value; Position : Cursor)
return JSON_Value;
function Has_Element (Position : Cursor) return Boolean;
package Value_Iterator_Interfaces is
new Ada.Iterator_Interfaces (Cursor, Has_Element);
function Iterate (Object : JSON_Value)
return Value_Iterator_Interfaces.Forward_Iterator'Class;
private
type JSON_Value (Kind : Value_Kind) is tagged record
case Kind is
when Array_Kind | Object_Kind =>
Allocator : Memory_Allocator_Ptr;
Depth : Positive;
Offset : Array_Offset;
Length : Natural;
when String_Kind =>
Stream : Streams.Stream_Ptr;
String_Offset, String_Length : Streams.AS.Stream_Element_Offset;
when Integer_Kind =>
Integer_Value : Integer_Type;
when Float_Kind =>
Float_Value : Float_Type;
when Boolean_Kind =>
Boolean_Value : Boolean;
when Null_Kind =>
null;
end case;
end record;
-----------------------------------------------------------------------------
-- Iterating --
-----------------------------------------------------------------------------
subtype Iterator_Kind is Value_Kind range Array_Kind .. Object_Kind;
type Cursor (Kind : Iterator_Kind) is record
Data : JSON_Value (Kind => Kind);
Index : Natural;
end record;
type Iterator (Kind : Iterator_Kind) is limited
new Value_Iterator_Interfaces.Forward_Iterator with
record
Data : JSON_Value (Kind => Kind);
end record;
overriding function First (Object : Iterator) return Cursor;
overriding function Next
(Object : Iterator;
Position : Cursor) return Cursor;
-----------------------------------------------------------------------------
-- Memory allocator --
-----------------------------------------------------------------------------
type Array_Value (Kind : Value_Kind := Null_Kind) is record
Value : JSON_Value (Kind => Kind);
end record;
type Key_Value_Pair (Kind : Value_Kind := Null_Kind) is record
Key : JSON_Value (Kind => String_Kind);
Element : JSON_Value (Kind => Kind);
end record;
package Array_Vectors is new Ada.Containers.Vectors (Positive, Array_Value);
package Object_Vectors is new Ada.Containers.Indefinite_Vectors (Positive, Key_Value_Pair);
type Array_Level_Array is array (Positive range <>) of Array_Vectors.Vector;
type Object_Level_Array is array (Positive range <>) of Object_Vectors.Vector;
type Memory_Allocator
(Maximum_Depth : Positive := Default_Maximum_Depth) is tagged limited
record
Array_Levels : Array_Level_Array (1 .. Maximum_Depth);
Object_Levels : Object_Level_Array (1 .. Maximum_Depth);
end record;
end JSON.Types;
|
reznikmm/matreshka | Ada | 4,755 | ads | ------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- Web Framework --
-- --
-- Tools Component --
-- --
------------------------------------------------------------------------------
-- --
-- Copyright © 2012-2013, Vadim Godunko <[email protected]> --
-- All rights reserved. --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions --
-- are met: --
-- --
-- * Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- --
-- * Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in the --
-- documentation and/or other materials provided with the distribution. --
-- --
-- * Neither the name of the Vadim Godunko, IE nor the names of its --
-- contributors may be used to endorse or promote products derived from --
-- this software without specific prior written permission. --
-- --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR --
-- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
-- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED --
-- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR --
-- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF --
-- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING --
-- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS --
-- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
-- --
------------------------------------------------------------------------------
-- $Revision$ $Date$
------------------------------------------------------------------------------
limited with WSDL.AST.Services;
package WSDL.AST.Endpoints is
pragma Preelaborate;
type Service_Access is access all WSDL.AST.Services.Service_Node'Class;
type Endpoint_Node is new WSDL.AST.Abstract_Node with record
Local_Name : League.Strings.Universal_String;
-- Local name part of the name of the operation.
Parent : Service_Access;
-- Value of {parent} property.
Binding_Name : Qualified_Name;
-- Name of the referenced binding component.
Binding : WSDL.AST.Binding_Access;
-- Value of {binding} property.
Address : League.Strings.Universal_String;
-- Value of {address} property.
end record;
type Endpoint_Access is access all Endpoint_Node'Class;
overriding procedure Enter
(Self : not null access Endpoint_Node;
Visitor : in out WSDL.Visitors.WSDL_Visitor'Class;
Control : in out WSDL.Iterators.Traverse_Control);
overriding procedure Leave
(Self : not null access Endpoint_Node;
Visitor : in out WSDL.Visitors.WSDL_Visitor'Class;
Control : in out WSDL.Iterators.Traverse_Control);
overriding procedure Visit
(Self : not null access Endpoint_Node;
Iterator : in out WSDL.Iterators.WSDL_Iterator'Class;
Visitor : in out WSDL.Visitors.WSDL_Visitor'Class;
Control : in out WSDL.Iterators.Traverse_Control);
end WSDL.AST.Endpoints;
|
zhmu/ananas | Ada | 3,237 | ads | ------------------------------------------------------------------------------
-- --
-- GNAT RUN-TIME COMPONENTS --
-- --
-- S Y S T E M . P A C K _ 1 1 9 --
-- --
-- S p e c --
-- --
-- Copyright (C) 1992-2022, Free Software Foundation, Inc. --
-- --
-- GNAT is free software; you can redistribute it and/or modify it under --
-- terms of the GNU General Public License as published by the Free Soft- --
-- ware Foundation; either version 3, or (at your option) any later ver- --
-- sion. GNAT is distributed in the hope that it will be useful, but WITH- --
-- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY --
-- or FITNESS FOR A PARTICULAR PURPOSE. --
-- --
-- As a special exception under Section 7 of GPL version 3, you are granted --
-- additional permissions described in the GCC Runtime Library Exception, --
-- version 3.1, as published by the Free Software Foundation. --
-- --
-- You should have received a copy of the GNU General Public License and --
-- a copy of the GCC Runtime Library Exception along with this program; --
-- see the files COPYING3 and COPYING.RUNTIME respectively. If not, see --
-- <http://www.gnu.org/licenses/>. --
-- --
-- GNAT was originally developed by the GNAT team at New York University. --
-- Extensive contributions were provided by Ada Core Technologies Inc. --
-- --
------------------------------------------------------------------------------
-- Handling of packed arrays with Component_Size = 119
package System.Pack_119 is
pragma Preelaborate;
Bits : constant := 119;
type Bits_119 is mod 2 ** Bits;
for Bits_119'Size use Bits;
-- In all subprograms below, Rev_SSO is set True if the array has the
-- non-default scalar storage order.
function Get_119
(Arr : System.Address;
N : Natural;
Rev_SSO : Boolean) return Bits_119 with Inline;
-- Arr is the address of the packed array, N is the zero-based
-- subscript. This element is extracted and returned.
procedure Set_119
(Arr : System.Address;
N : Natural;
E : Bits_119;
Rev_SSO : Boolean) with Inline;
-- Arr is the address of the packed array, N is the zero-based
-- subscript. This element is set to the given value.
end System.Pack_119;
|
mitchelhaan/ncurses | Ada | 3,927 | adb | ------------------------------------------------------------------------------
-- --
-- GNAT ncurses Binding --
-- --
-- Terminal_Interface.Curses.Forms.Field_Types.AlphaNumeric --
-- --
-- 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.3 $
-- Binding Version 00.93
------------------------------------------------------------------------------
with Interfaces.C;
with Terminal_Interface.Curses.Aux; use Terminal_Interface.Curses.Aux;
package body Terminal_Interface.Curses.Forms.Field_Types.AlphaNumeric is
use type Interfaces.C.Int;
procedure Set_Field_Type (Fld : in Field;
Typ : in AlphaNumeric_Field)
is
C_AlphaNumeric_Field_Type : C_Field_Type;
pragma Import (C, C_AlphaNumeric_Field_Type, "TYPE_ALNUM");
function Set_Fld_Type (F : Field := Fld;
Cft : C_Field_Type := C_AlphaNumeric_Field_Type;
Arg1 : C_Int) return C_Int;
pragma Import (C, Set_Fld_Type, "set_field_type");
Res : Eti_Error;
begin
Res := Set_Fld_Type (Arg1 => C_Int (Typ.Minimum_Field_Width));
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.AlphaNumeric;
|
zhmu/ananas | Ada | 354 | adb | -- { dg-do run }
-- { dg-options "-O2" }
with Opt35_Pkg; use Opt35_Pkg;
procedure Opt36 is
I : Integer := -1;
N : Natural := 0;
begin
loop
begin
I := I + 1;
I := I + F(0);
exception
when E => N := N + 1;
end;
exit when I = 1;
end loop;
if N /= 2 or I = 0 then
raise Program_Error;
end if;
end;
|
reznikmm/matreshka | Ada | 5,749 | ads | ------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- XML Processor --
-- --
-- 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_Nodes;
with XML.DOM.Processing_Instructions;
with XML.DOM.Visitors;
package Matreshka.DOM_Processing_Instructions is
pragma Preelaborate;
type Processing_Instruction_Node is new Matreshka.DOM_Nodes.Node
and XML.DOM.Processing_Instructions.DOM_Processing_Instruction
with null record;
overriding procedure Enter_Node
(Self : not null access Processing_Instruction_Node;
Visitor : in out XML.DOM.Visitors.Abstract_Visitor'Class;
Control : in out XML.DOM.Visitors.Traverse_Control);
-- Dispatch call to corresponding subprogram of visitor interface.
overriding function Get_Data
(Self : not null access constant Processing_Instruction_Node)
return League.Strings.Universal_String;
overriding function Get_Node_Type
(Self : not null access constant Processing_Instruction_Node)
return XML.DOM.Node_Type;
overriding function Get_Node_Value
(Self : not null access constant Processing_Instruction_Node)
return League.Strings.Universal_String renames Get_Data;
overriding function Get_Target
(Self : not null access constant Processing_Instruction_Node)
return League.Strings.Universal_String;
overriding function Get_Node_Name
(Self : not null access constant Processing_Instruction_Node)
return League.Strings.Universal_String renames Get_Target;
overriding procedure Set_Data
(Self : not null access Processing_Instruction_Node;
New_Data : League.Strings.Universal_String);
overriding procedure Set_Node_Value
(Self : not null access Processing_Instruction_Node;
New_Value : League.Strings.Universal_String) renames Set_Data;
overriding procedure Leave_Node
(Self : not null access Processing_Instruction_Node;
Visitor : in out XML.DOM.Visitors.Abstract_Visitor'Class;
Control : in out XML.DOM.Visitors.Traverse_Control);
-- Dispatch call to corresponding subprogram of visitor interface.
overriding procedure Visit_Node
(Self : not null access Processing_Instruction_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);
-- Dispatch call to corresponding subprogram of iterator interface.
end Matreshka.DOM_Processing_Instructions;
|
jamiepg1/sdlada | Ada | 4,059 | adb | --------------------------------------------------------------------------------------------------------------------
-- Copyright (c) 2014 Luke A. Guest
--
-- This software is provided 'as-is', without any express or implied
-- warranty. In no event will the authors be held liable for any damages
-- arising from the use of this software.
--
-- Permission is granted to anyone to use this software for any purpose,
-- including commercial applications, and to alter it and redistribute it
-- freely, subject to the following restrictions:
--
-- 1. The origin of this software must not be misrepresented; you must not
-- claim that you wrote the original software. If you use this software
-- in a product, an acknowledgment in the product documentation would be
-- appreciated but is not required.
--
-- 2. Altered source versions must be plainly marked as such, and must not be
-- misrepresented as being the original software.
--
-- 3. This notice may not be removed or altered from any source
-- distribution.
--------------------------------------------------------------------------------------------------------------------
package body SDL.Video.Displays is
use type System.Address;
use type C.int;
function Closest_Mode (Display : in Natural; Wanted : in Mode; Target : out Mode) return Boolean is
function SDL_Get_Closest_Display_Mode (D : C.int; W : in Mode; T : out Mode) return System.Address with
Import => True,
Convention => C,
External_Name => "SDL_GetClosestDisplayMode";
Result : System.Address := SDL_Get_Closest_Display_Mode (C.int (Display), Wanted, Target);
begin
return (Result = System.Null_Address);
end Closest_Mode;
function Current_Mode (Display : in Natural; Target : out Mode) return Boolean is
function SDL_Get_Current_Display_Mode (D : C.int; M : out Mode) return C.int with
Import => True,
Convention => C,
External_Name => "SDL_GetCurrentDisplayMode";
Result : C.int := SDL_Get_Current_Display_Mode (C.int (Display), Target);
begin
return (Result = Success);
end Current_Mode;
function Desktop_Mode (Display : in Natural; Target : out Mode) return Boolean is
function SDL_Get_Desktop_Display_Mode (D : C.int; M : out Mode) return C.int with
Import => True,
Convention => C,
External_Name => "SDL_GetDesktopDisplayMode";
Result : C.int := SDL_Get_Desktop_Display_Mode (C.int (Display), Target);
begin
return (Result = Success);
end Desktop_Mode;
function Display_Mode (Display : in Natural; Index : in Natural; Target : out Mode) return Boolean is
function SDL_Get_Display_Mode (D : in C.int; I : in C.int; T : out Mode) return C.int with
Import => True,
Convention => C,
External_Name => "SDL_GetDisplayMode";
Result : C.int := SDL_Get_Display_Mode (C.int (Display), C.int (Index), Target);
begin
return (Result = Success);
end Display_Mode;
function Total_Display_Modes (Display : in Natural; Total : out Positive) return Boolean is
function SDL_Get_Num_Display_Modes (I : in C.int) return C.int with
Import => True,
Convention => C,
External_Name => "SDL_GetNumDisplayModes";
Result : C.int := SDL_Get_Num_Display_Modes (C.int (Display));
begin
if Result >= 1 then
Total := Positive (Result);
return True;
end if;
return False;
end Total_Display_Modes;
function Display_Bounds (Display : in Natural; Bounds : out Rectangles.Rectangle) return Boolean is
function SDL_Get_Display_Bounds (D : in C.int; B : out Rectangles.Rectangle) return C.int with
Import => True,
Convention => C,
External_Name => "SDL_GetDisplayBounds";
Result : C.int := SDL_Get_Display_Bounds (C.int (Display), Bounds);
begin
return (Result = Success);
end Display_Bounds;
end SDL.Video.Displays;
|
onox/orka | Ada | 5,019 | adb | -- SPDX-License-Identifier: Apache-2.0
--
-- Copyright (c) 2022 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.Numerics.Kalman.SPKF;
package body Orka.Numerics.Kalman.UKF is
function Weights (N : Positive; A, B, K : Tensors.Element_Type) return Weights_Type is
L : constant Element_Type := Element_Type (N);
-- See equation 3.11 in Section 3.2.2 of [1]
Lambda : constant Element_Type := A**2 * (L + K) - L;
Mean_First : constant Element_Type := Lambda / (L + Lambda);
Count : constant Positive := 2 * N + 1;
Weights_Mean, Weights_Cov : Vector := Fill ((1 => Count), 1.0 / (2.0 * (L + Lambda)));
begin
Weights_Mean.Set ((1 => 1), Mean_First);
Weights_Cov.Set ((1 => 1), Mean_First + 1.0 - A**2 + B);
return
(N => N,
Kind => Filter_UKF,
Mean => Tensor_Holders.To_Holder (Weights_Mean),
Covariance => Tensor_Holders.To_Holder (Weights_Cov),
Scaling_Factor => L + Lambda);
end Weights;
function Create_Filter
(X : Vector;
P, Q, R : Matrix;
Weights : Weights_Type) return Filter is
begin
return Result : Filter (Weights.Kind, Dimension_X => Q.Rows, Dimension_Z => R.Rows) do
Result.Process_Noise := Tensor_Holders.To_Holder (Q);
Result.Measurement_Noise := Tensor_Holders.To_Holder (R);
Result.Weights := Weights;
Result.Estimate :=
(State => Tensor_Holders.To_Holder (X),
Covariance => Tensor_Holders.To_Holder (P));
end return;
end Create_Filter;
----------------------------------------------------------------------------
function Points_Covariance (Covariance : Matrix) return Matrix is (Cholesky (Covariance));
function UKF_Covariance
(Points_Left, Points_Right : Matrix;
Mean_Left, Mean_Right : Vector;
Weights : Vector) return Matrix
is
P : Matrix := Zeros ((Points_Left.Columns, Points_Right.Columns));
begin
for I in 1 .. Points_Left.Rows loop
declare
Left : Vector renames Points_Left.Get (I);
Right : Vector renames Points_Right.Get (I);
Weight : Element_Type renames Weights.Get (I);
begin
P := P + Weight * Outer (Left - Mean_Left, Right - Mean_Right);
end;
end loop;
return P;
end UKF_Covariance;
function Transform
(Phase : Update_Phase;
Points, Noise : Matrix;
Weights : Weights_Type) return State_Covariance
is
U : constant Vector := Matrix'(Weights.Mean.Constant_Reference * Points).Flatten;
begin
return
(State => Tensor_Holders.To_Holder (U),
Covariance => Tensor_Holders.To_Holder
(UKF_Covariance (Points, Points, U, U, Weights.Covariance.Constant_Reference) + Noise));
end Transform;
function Cross_Covariance
(X, Y : Matrix;
State_X, State_Y : State_Covariance;
Weights : Weights_Type) return Matrix
is
Mean_X : Vector renames State_X.State.Constant_Reference;
Mean_Y : Vector renames State_Y.State.Constant_Reference;
begin
return UKF_Covariance (X, Y, Mean_X, Mean_Y, Weights.Covariance.Constant_Reference);
end Cross_Covariance;
function Kalman_Gain (State_Y : State_Covariance; Cross_Covariance : Matrix) return Matrix is
(Cross_Covariance * State_Y.Covariance.Constant_Reference.Inverse);
function Posterior_Covariance
(State_X, State_Y : State_Covariance;
Kalman_Gain : Matrix) return Matrix
is
Pp : Matrix renames State_X.Covariance.Constant_Reference;
Pz : Matrix renames State_Y.Covariance.Constant_Reference;
begin
return Pp - Matrix'(Kalman_Gain * Matrix'(Pz * Kalman_Gain.Transpose));
end Posterior_Covariance;
----------------------------------------------------------------------------
package SPKF_Filter is new SPKF
(Points_Covariance, Transform, Cross_Covariance, Kalman_Gain, Posterior_Covariance);
procedure Predict_Update
(Object : in out Filter;
F : not null access function (Point : Vector; DT : Orka.Float_64) return Vector;
H : not null access function (Point : Vector) return Vector;
DT : Duration;
Measurement : Vector) renames SPKF_Filter.Predict_Update;
end Orka.Numerics.Kalman.UKF;
|
reznikmm/matreshka | Ada | 3,654 | 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.Chart_Title_Elements is
pragma Preelaborate;
type ODF_Chart_Title is limited interface
and XML.DOM.Elements.DOM_Element;
type ODF_Chart_Title_Access is
access all ODF_Chart_Title'Class
with Storage_Size => 0;
end ODF.DOM.Chart_Title_Elements;
|
reznikmm/matreshka | Ada | 6,941 | 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_Table.Table_Columns_Elements is
------------
-- Create --
------------
overriding function Create
(Parameters : not null access Matreshka.DOM_Elements.Element_L2_Parameters)
return Table_Table_Columns_Element_Node is
begin
return Self : Table_Table_Columns_Element_Node do
Matreshka.ODF_Table.Constructors.Initialize
(Self'Unchecked_Access,
Parameters.Document,
Matreshka.ODF_String_Constants.Table_Prefix);
end return;
end Create;
----------------
-- Enter_Node --
----------------
overriding procedure Enter_Node
(Self : not null access Table_Table_Columns_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_Table_Table_Columns
(ODF.DOM.Table_Table_Columns_Elements.ODF_Table_Table_Columns_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 Table_Table_Columns_Element_Node)
return League.Strings.Universal_String
is
pragma Unreferenced (Self);
begin
return Matreshka.ODF_String_Constants.Table_Columns_Element;
end Get_Local_Name;
----------------
-- Leave_Node --
----------------
overriding procedure Leave_Node
(Self : not null access Table_Table_Columns_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_Table_Table_Columns
(ODF.DOM.Table_Table_Columns_Elements.ODF_Table_Table_Columns_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 Table_Table_Columns_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_Table_Table_Columns
(Visitor,
ODF.DOM.Table_Table_Columns_Elements.ODF_Table_Table_Columns_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.Table_URI,
Matreshka.ODF_String_Constants.Table_Columns_Element,
Table_Table_Columns_Element_Node'Tag);
end Matreshka.ODF_Table.Table_Columns_Elements;
|
reznikmm/matreshka | Ada | 3,769 | 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.Text_Alphabetical_Index_Mark_Start_Elements is
pragma Preelaborate;
type ODF_Text_Alphabetical_Index_Mark_Start is limited interface
and XML.DOM.Elements.DOM_Element;
type ODF_Text_Alphabetical_Index_Mark_Start_Access is
access all ODF_Text_Alphabetical_Index_Mark_Start'Class
with Storage_Size => 0;
end ODF.DOM.Text_Alphabetical_Index_Mark_Start_Elements;
|
annexi-strayline/AURA | Ada | 4,211 | adb | ------------------------------------------------------------------------------
-- --
-- Ada User Repository Annex (AURA) --
-- ANNEXI-STRAYLINE Reference Implementation --
-- --
-- Core --
-- --
-- ------------------------------------------------------------------------ --
-- --
-- Copyright (C) 2019-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. --
-- --
------------------------------------------------------------------------------
with Unit_Names;
package body Registrar.Executive.Unit_Entry is
-----------
-- Image --
-----------
function Image (Order: Unit_Entry_Order) return String
is ( "[Unit_Entry_Order] (Registrar.Executive.Unit_Entry)" & New_Line &
"AURA : " & Boolean'Image (Order.AURA) & New_Line &
"File_Full_Name: " & UBS.To_String (Order.File_Full_Name) &
New_Line &
(if Order.AURA then
"AURA_Subsystem: " & Order.AURA_Subsystem.Name.To_UTF8_String
else
""));
-------------
-- Execute --
-------------
procedure Execute (Order: in out Unit_Entry_Order) is separate;
end Registrar.Executive.Unit_Entry;
|
reznikmm/matreshka | Ada | 43,256 | adb | ------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- XML Processor --
-- --
-- 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 Ada.Wide_Wide_Text_IO;
with League.IRIs;
with Matreshka.XML_Catalogs.Normalization;
package body Matreshka.XML_Catalogs.Handlers is
use Matreshka.XML_Catalogs.Entry_Files;
use type League.Strings.Universal_String;
XML_Catalogs_Namespace : constant League.Strings.Universal_String
:= League.Strings.To_Universal_String
("urn:oasis:names:tc:entity:xmlns:xml:catalog");
XML_Catalogs_1_0_Public_Id : constant League.Strings.Universal_String
:= League.Strings.To_Universal_String
("-//OASIS//DTD Entity Resolution XML Catalog V1.0//EN");
XML_Catalogs_1_1_Public_Id : constant League.Strings.Universal_String
:= League.Strings.To_Universal_String
("-//OASIS//DTD XML Catalogs V1.1//EN");
-- Tags names
Catalog_Tag_Name : constant League.Strings.Universal_String
:= League.Strings.To_Universal_String ("catalog");
Delegate_Public_Tag_Name : constant League.Strings.Universal_String
:= League.Strings.To_Universal_String ("delegatePublic");
Delegate_System_Tag_Name : constant League.Strings.Universal_String
:= League.Strings.To_Universal_String ("delegateSystem");
Delegate_URI_Tag_Name : constant League.Strings.Universal_String
:= League.Strings.To_Universal_String ("delegateURI");
Group_Tag_Name : constant League.Strings.Universal_String
:= League.Strings.To_Universal_String ("group");
Next_Catalog_Tag_Name : constant League.Strings.Universal_String
:= League.Strings.To_Universal_String ("nextCatalog");
Public_Tag_Name : constant League.Strings.Universal_String
:= League.Strings.To_Universal_String ("public");
Rewrite_System_Tag_Name : constant League.Strings.Universal_String
:= League.Strings.To_Universal_String ("rewriteSystem");
Rewrite_URI_Tag_Name : constant League.Strings.Universal_String
:= League.Strings.To_Universal_String ("rewriteURI");
System_Tag_Name : constant League.Strings.Universal_String
:= League.Strings.To_Universal_String ("system");
System_Suffix_Tag_Name : constant League.Strings.Universal_String
:= League.Strings.To_Universal_String ("systemSuffix");
URI_Tag_Name : constant League.Strings.Universal_String
:= League.Strings.To_Universal_String ("uri");
URI_Suffix_Tag_Name : constant League.Strings.Universal_String
:= League.Strings.To_Universal_String ("uriSuffix");
-- Attributes names
Catalog_Attribute_Name : constant League.Strings.Universal_String
:= League.Strings.To_Universal_String ("catalog");
Name_Attribute_Name : constant League.Strings.Universal_String
:= League.Strings.To_Universal_String ("name");
Prefer_Attribute_Name : constant League.Strings.Universal_String
:= League.Strings.To_Universal_String ("prefer");
Public_Id_Attribute_Name : constant League.Strings.Universal_String
:= League.Strings.To_Universal_String ("publicId");
Public_Id_Start_String_Attribute_Name :
constant League.Strings.Universal_String
:= League.Strings.To_Universal_String ("publicIdStartString");
Rewrite_Prefix_Attribute_Name : constant League.Strings.Universal_String
:= League.Strings.To_Universal_String ("rewritePrefix");
System_Id_Attribute_Name : constant League.Strings.Universal_String
:= League.Strings.To_Universal_String ("systemId");
System_Id_Start_String_Attribute_Name :
constant League.Strings.Universal_String
:= League.Strings.To_Universal_String ("systemIdStartString");
System_Id_Suffix_Attribute_Name : constant League.Strings.Universal_String
:= League.Strings.To_Universal_String ("systemIdSuffix");
URI_Attribute_Name : constant League.Strings.Universal_String
:= League.Strings.To_Universal_String ("uri");
URI_Start_String_Attribute_Name : constant League.Strings.Universal_String
:= League.Strings.To_Universal_String ("uriStartString");
URI_Suffix_Attribute_Name : constant League.Strings.Universal_String
:= League.Strings.To_Universal_String ("uriSuffix");
-- Attribute values images
System_Image : constant League.Strings.Universal_String
:= League.Strings.To_Universal_String ("system");
Public_Image : constant League.Strings.Universal_String
:= League.Strings.To_Universal_String ("public");
procedure Error
(Self : in out XML_Catalog_Handler'Class;
Message : League.Strings.Universal_String;
Success : out Boolean);
-- Sets Success to False and save Message as last error message.
procedure Error
(Self : in out XML_Catalog_Handler'Class;
Message : Wide_Wide_String;
Success : out Boolean);
-- Sets Success to False and save Message as last error message.
procedure Check_No_Fragment_Identifier
(Self : in out XML_Catalog_Handler'Class;
URI : League.Strings.Universal_String;
Success : in out Boolean);
-- Check that URI is not include fragment identifier.
procedure Process_Catalog_Start_Element
(Self : in out XML_Catalog_Handler'Class;
Attributes : XML.SAX.Attributes.SAX_Attributes;
Success : in out Boolean);
-- Processes start of "catalog" element.
procedure Process_Group_Start_Element
(Self : in out XML_Catalog_Handler'Class;
Attributes : XML.SAX.Attributes.SAX_Attributes;
Success : in out Boolean);
-- Processes start of "group" element.
procedure Process_Group_End_Element
(Self : in out XML_Catalog_Handler'Class;
Success : in out Boolean);
-- Processes end of "group" element.
procedure Process_Public_Start_Element
(Self : in out XML_Catalog_Handler'Class;
Attributes : XML.SAX.Attributes.SAX_Attributes;
Success : in out Boolean);
-- Processes start of "public" element.
procedure Process_System_Start_Element
(Self : in out XML_Catalog_Handler'Class;
Attributes : XML.SAX.Attributes.SAX_Attributes;
Success : in out Boolean);
-- Processes start of "system" element.
procedure Process_Rewrite_System_Start_Element
(Self : in out XML_Catalog_Handler'Class;
Attributes : XML.SAX.Attributes.SAX_Attributes;
Success : in out Boolean);
-- Processes start of "rewriteSystem" element.
procedure Process_System_Suffix_Start_Element
(Self : in out XML_Catalog_Handler'Class;
Attributes : XML.SAX.Attributes.SAX_Attributes;
Success : in out Boolean);
-- Processes start of "systemSuffix" element.
procedure Process_Delegate_Public_Start_Element
(Self : in out XML_Catalog_Handler'Class;
Attributes : XML.SAX.Attributes.SAX_Attributes;
Success : in out Boolean);
-- Processes start of "delegatePublic" element.
procedure Process_Delegate_System_Start_Element
(Self : in out XML_Catalog_Handler'Class;
Attributes : XML.SAX.Attributes.SAX_Attributes;
Success : in out Boolean);
-- Processes start of "delegateSystem" element.
procedure Process_URI_Start_Element
(Self : in out XML_Catalog_Handler'Class;
Attributes : XML.SAX.Attributes.SAX_Attributes;
Success : in out Boolean);
-- Processes start of "uri" element.
procedure Process_Rewrite_URI_Start_Element
(Self : in out XML_Catalog_Handler'Class;
Attributes : XML.SAX.Attributes.SAX_Attributes;
Success : in out Boolean);
-- Processes start of "rewriteURI" element.
procedure Process_URI_Suffix_Start_Element
(Self : in out XML_Catalog_Handler'Class;
Attributes : XML.SAX.Attributes.SAX_Attributes;
Success : in out Boolean);
-- Processes start of "uriSuffix" element.
procedure Process_Delegate_URI_Start_Element
(Self : in out XML_Catalog_Handler'Class;
Attributes : XML.SAX.Attributes.SAX_Attributes;
Success : in out Boolean);
-- Processes start of "delegateURI" element.
procedure Process_Next_Catalog_Start_Element
(Self : in out XML_Catalog_Handler'Class;
Attributes : XML.SAX.Attributes.SAX_Attributes;
Success : in out Boolean);
-- Processes start of "nextCatalog" element.
----------------------------------
-- Check_No_Fragment_Identifier --
----------------------------------
procedure Check_No_Fragment_Identifier
(Self : in out XML_Catalog_Handler'Class;
URI : League.Strings.Universal_String;
Success : in out Boolean) is
begin
if URI.Index ('#') /= 0 then
Error
(Self,
"URI reference should not include a fragment identifier",
Success);
end if;
end Check_No_Fragment_Identifier;
-----------------
-- End_Element --
-----------------
overriding procedure End_Element
(Self : in out XML_Catalog_Handler;
Namespace_URI : League.Strings.Universal_String;
Local_Name : League.Strings.Universal_String;
Qualified_Name : League.Strings.Universal_String;
Success : in out Boolean) is
begin
if Namespace_URI = XML_Catalogs_Namespace
and Local_Name = Group_Tag_Name
then
Process_Group_End_Element (Self, Success);
end if;
end End_Element;
-----------
-- Error --
-----------
procedure Error
(Self : in out XML_Catalog_Handler'Class;
Message : Wide_Wide_String;
Success : out Boolean) is
begin
Self.Diagnosis := League.Strings.To_Universal_String (Message);
Success := False;
end Error;
-----------
-- Error --
-----------
procedure Error
(Self : in out XML_Catalog_Handler'Class;
Message : League.Strings.Universal_String;
Success : out Boolean) is
begin
Self.Diagnosis := Message;
Success := False;
end Error;
-----------
-- Error --
-----------
overriding procedure Error
(Self : in out XML_Catalog_Handler;
Occurrence : XML.SAX.Parse_Exceptions.SAX_Parse_Exception;
Success : in out Boolean) is
begin
Ada.Wide_Wide_Text_IO.Put_Line
(Ada.Wide_Wide_Text_IO.Standard_Error,
"(error) " & Occurrence.Message.To_Wide_Wide_String);
end Error;
------------------
-- Error_String --
------------------
overriding function Error_String
(Self : XML_Catalog_Handler) return League.Strings.Universal_String is
begin
return Self.Diagnosis;
end Error_String;
-----------------
-- Fatal_Error --
-----------------
overriding procedure Fatal_Error
(Self : in out XML_Catalog_Handler;
Occurrence : XML.SAX.Parse_Exceptions.SAX_Parse_Exception) is
begin
Ada.Wide_Wide_Text_IO.Put_Line
(Ada.Wide_Wide_Text_IO.Standard_Error,
"(fatal) " & Occurrence.Message.To_Wide_Wide_String);
end Fatal_Error;
----------------------------
-- Get_Catalog_Entry_File --
----------------------------
function Get_Catalog_Entry_File
(Self : XML_Catalog_Handler)
return Matreshka.XML_Catalogs.Entry_Files.Catalog_Entry_File_Access is
begin
return Self.Entry_File;
end Get_Catalog_Entry_File;
-----------------------------------
-- Process_Catalog_Start_Element --
-----------------------------------
procedure Process_Catalog_Start_Element
(Self : in out XML_Catalog_Handler'Class;
Attributes : XML.SAX.Attributes.SAX_Attributes;
Success : in out Boolean)
is
-- [XML Catalogs] 6.5.1. The catalog Entry
--
-- "Each XML Catalog entry file consists of a single catalog element.
-- This element may set the global prefer value and global base URI. It
-- is otherwise just a container for the other elements.
--
-- <catalog
-- id = id
-- prefer = "system" | "public"
-- xml:base = uri-reference >
-- <!-- Content: (group | public | system | rewriteSystem
-- | systemSuffix | delegatePublic | delegateSystem | uri
-- | rewriteURI | uriSuffix | delegateURI | nextCatalog)+ -->
-- </catalog>"
Prefer_Index : constant Natural
:= Attributes.Index (Prefer_Attribute_Name);
begin
-- Analyze 'prefer' attribute when present.
if Prefer_Index /= 0 then
if Attributes.Value (Prefer_Index) = Public_Image then
Self.Current_Prefer_Mode := Public;
elsif Attributes.Value (Prefer_Index) = System_Image then
Self.Current_Prefer_Mode := System;
else
Self.Error ("Invalid value of 'prefer' attribute", Success);
end if;
end if;
-- Create new catalog entry file object.
Self.Entry_File :=
new Matreshka.XML_Catalogs.Entry_Files.Catalog_Entry_File;
Self.Entry_File.Default_Prefer_Mode := Self.Default_Prefer_Mode;
end Process_Catalog_Start_Element;
-------------------------------------------
-- Process_Delegate_Public_Start_Element --
-------------------------------------------
procedure Process_Delegate_Public_Start_Element
(Self : in out XML_Catalog_Handler'Class;
Attributes : XML.SAX.Attributes.SAX_Attributes;
Success : in out Boolean)
is
-- [XML Catalogs] 6.5.7. The delegatePublic Element
--
-- "The delegatePublic element associates an alternate catalog with a
-- partial public identifier.
--
-- <delegatePublic
-- id = id
-- publicIdStartString = public-identifier-prefix
-- catalog = uri-reference
-- xml:base = uri-reference />
--
-- A delegatePublic entry matches a public identifier if the normalized
-- value (Section 6.2, “Public Identifier Normalization”) of the public
-- identifier begins precisely with the normalized value of the
-- publicIdStartString attribute of the entry."
--
-- "If the value of the catalog attribute is relative, it must be made
-- absolute with respect to the base URI currently in effect."
Public_Id : constant League.Strings.Universal_String
:= Matreshka.XML_Catalogs.Normalization.Normalize_Public_Identifier
(Attributes.Value (Public_Id_Start_String_Attribute_Name));
Catalog : constant League.Strings.Universal_String
:= Self.Locator.Base_URI.Resolve
(League.IRIs.From_Universal_String
(Attributes.Value (Catalog_Attribute_Name))).To_Universal_String;
begin
-- Check that 'publicIdStartString' is not empty.
if Public_Id.Is_Empty then
Error (Self, "publicIdStartString is empty", Success);
return;
end if;
Self.Entry_File.Append
(new Delegate_Public_Entry'
(Public_Id, Catalog, Self.Current_Prefer_Mode));
end Process_Delegate_Public_Start_Element;
-------------------------------------------
-- Process_Delegate_System_Start_Element --
-------------------------------------------
procedure Process_Delegate_System_Start_Element
(Self : in out XML_Catalog_Handler'Class;
Attributes : XML.SAX.Attributes.SAX_Attributes;
Success : in out Boolean)
is
-- [XML Catalogs] 6.5.8. The delegateSystem Element
--
-- "The delegateSystem element associates an alternate catalog with a
-- partial system identifier.
--
-- <delegateSystem
-- id = id
-- systemIdStartString = string
-- catalog = uri-reference
-- xml:base = uri-reference />
--
-- A delegateSystem entry matches a system identifier if the normalized
-- value (Section 6.3, “System Identifier and URI Normalization”) of the
-- system identifier begins precisely with the normalized value of the
-- systemIdStartString attribute of the entry."
--
-- "If the value of the catalog attribute is relative, it must be made
-- absolute with respect to the base URI currently in effect."
System_Id : constant League.Strings.Universal_String
:= Matreshka.XML_Catalogs.Normalization.Normalize_System_Identifier
(Attributes.Value (System_Id_Start_String_Attribute_Name));
Catalog : constant League.Strings.Universal_String
:= Self.Locator.Base_URI.Resolve
(League.IRIs.From_Universal_String
(Attributes.Value (Catalog_Attribute_Name))).To_Universal_String;
begin
-- Check that 'systemIdStartString' is not empty.
if System_Id.Is_Empty then
Error (Self, "systemIdStartString is empty", Success);
return;
end if;
Self.Entry_File.Append
(new Delegate_System_Entry'(System_Id, Catalog));
end Process_Delegate_System_Start_Element;
----------------------------------------
-- Process_Delegate_URI_Start_Element --
----------------------------------------
procedure Process_Delegate_URI_Start_Element
(Self : in out XML_Catalog_Handler'Class;
Attributes : XML.SAX.Attributes.SAX_Attributes;
Success : in out Boolean)
is
-- [XML Catalogs] 6.5.12. The delegateURI Element
--
-- "The delegateURI element associates an alternate catalog with a
-- partial URI reference.
--
-- <delegateURI
-- id = id
-- uriStartString = string
-- catalog = uri-reference
-- xml:base = uri-reference />
--
-- A delegateURI entry matches a URI reference if the normalized value
-- (Section 6.3, “System Identifier and URI Normalization”) of the URI
-- reference begins precisely with the normalized value of the
-- uriStartString attribute of the entry.
--
-- If the value of the catalog attribute is relative, it must be made
-- absolute with respect to the base URI currently in effect."
URI : constant League.Strings.Universal_String
:= Matreshka.XML_Catalogs.Normalization.Normalize_URI
(Attributes.Value (URI_Start_String_Attribute_Name));
Catalog : constant League.Strings.Universal_String
:= Self.Locator.Base_URI.Resolve
(League.IRIs.From_Universal_String
(Attributes.Value (Catalog_Attribute_Name))).To_Universal_String;
begin
-- Check that 'uriStartString' is not empty.
if URI.Is_Empty then
Error (Self, "uriStartString is empty", Success);
return;
end if;
Self.Entry_File.Append (new Delegate_URI_Entry'(URI, Catalog));
end Process_Delegate_URI_Start_Element;
-------------------------------
-- Process_Group_End_Element --
-------------------------------
procedure Process_Group_End_Element
(Self : in out XML_Catalog_Handler'Class;
Success : in out Boolean) is
begin
-- Restore preference mode on leave of "group" element.
Self.Current_Prefer_Mode := Self.Previous_Prefer_Mode;
end Process_Group_End_Element;
---------------------------------
-- Process_Group_Start_Element --
---------------------------------
procedure Process_Group_Start_Element
(Self : in out XML_Catalog_Handler'Class;
Attributes : XML.SAX.Attributes.SAX_Attributes;
Success : in out Boolean)
is
-- [XML Catalogs] 6.5.2. The group Entry
--
-- "The group element is a convenience wrapper for specifying a prefer
-- setting or base URI for a set of catalog entries. It has no
-- semantics other than scoping these settings.
--
-- <group
-- id = id
-- prefer = "system" | "public"
-- xml:base = uri-reference >
-- <!-- Content: (public | system | rewriteSystem | systemSuffix |
-- delegatePublic | delegateSystem | uri | rewriteURI | uriSuffix |
-- delegateURI | nextCatalog)+ -->
-- </group>"
Prefer_Index : constant Natural
:= Attributes.Index (Prefer_Attribute_Name);
begin
-- Save current preference mode, analyze 'prefer' attribute when
-- present, otherwise preserve current mode.
Self.Previous_Prefer_Mode := Self.Current_Prefer_Mode;
if Prefer_Index /= 0 then
if Attributes.Value (Prefer_Index) = Public_Image then
Self.Current_Prefer_Mode := Public;
elsif Attributes.Value (Prefer_Index) = System_Image then
Self.Current_Prefer_Mode := System;
else
Self.Error ("Invalid value of 'prefer' attribute", Success);
end if;
end if;
end Process_Group_Start_Element;
----------------------------------------
-- Process_Next_Catalog_Start_Element --
----------------------------------------
procedure Process_Next_Catalog_Start_Element
(Self : in out XML_Catalog_Handler'Class;
Attributes : XML.SAX.Attributes.SAX_Attributes;
Success : in out Boolean)
is
-- [XML Catalogs] 6.5.13. The nextCatalog Element
--
-- "The nextCatalog elements indicate additional catalog entry file(s)
-- to be considered during the process of resolution.
--
-- <nextCatalog
-- id = id
-- catalog = uri-reference
-- xml:base = uri-reference />
--
-- If the value of the catalog attribute is relative, it must be made
-- absolute with respect to the base URI currently in effect.
--
-- Catalogs loaded due to a nextCatalog directive have an initial base
-- URI that is dependent on the location of the loaded catalog entry
-- file. No xml:base information is inherited from the originating
-- catalog.
Catalog : constant League.Strings.Universal_String
:= Self.Locator.Base_URI.Resolve
(League.IRIs.From_Universal_String
(Attributes.Value (Catalog_Attribute_Name))).To_Universal_String;
begin
Self.Entry_File.Append
(new Next_Catalog_Entry'(Catalog, Self.Default_Prefer_Mode, null));
end Process_Next_Catalog_Start_Element;
----------------------------------
-- Process_Public_Start_Element --
----------------------------------
procedure Process_Public_Start_Element
(Self : in out XML_Catalog_Handler'Class;
Attributes : XML.SAX.Attributes.SAX_Attributes;
Success : in out Boolean)
is
-- [XML Catalogs] 6.5.3. The public Entry
--
-- "The public element associates a URI reference with the public
-- identifier portion of an external identifier.
--
-- <public
-- id = id
-- publicId = public-identifier
-- uri = uri-reference
-- xml:base = uri-reference />
--
-- A public entry matches a public identifier if the normalized value
-- (Section 6.2, “Public Identifier Normalization”) of the public
-- identifier is lexically identical to the normalized value of the
-- publicId attribute of the entry.
--
-- If the value of the uri attribute is relative, it must be made
-- absolute with respect to the base URI currently in effect. The URI
-- reference should not include a fragment identifier."
Public_Id : constant League.Strings.Universal_String
:= Matreshka.XML_Catalogs.Normalization.Normalize_Public_Identifier
(Attributes.Value (Public_Id_Attribute_Name));
URI : constant League.Strings.Universal_String
:= Self.Locator.Base_URI.Resolve
(League.IRIs.From_Universal_String
(Attributes.Value (URI_Attribute_Name))).To_Universal_String;
begin
-- Check that 'publicId' is not empty.
if Public_Id.Is_Empty then
Error (Self, "publicId is empty", Success);
return;
end if;
-- Check that URI is not include a fragment identifier.
Check_No_Fragment_Identifier (Self, URI, Success);
if not Success then
return;
end if;
Self.Entry_File.Append
(new Public_Entry'(Public_Id, URI, Self.Current_Prefer_Mode));
end Process_Public_Start_Element;
------------------------------------------
-- Process_Rewrite_System_Start_Element --
------------------------------------------
procedure Process_Rewrite_System_Start_Element
(Self : in out XML_Catalog_Handler'Class;
Attributes : XML.SAX.Attributes.SAX_Attributes;
Success : in out Boolean)
is
-- [XML Catalogs] 6.5.5. The rewriteSystem Element
--
-- The rewriteSystem element rewrites the beginning of a system
-- identifier.
--
-- <rewriteSystem
-- id = id
-- systemIdStartString = string
-- rewritePrefix = uri-reference />
--
-- A rewriteSystem entry matches a system identifier if the normalized
-- value (Section 6.3, “System Identifier and URI Normalization”) of the
-- system identifier begins precisely with the normalized value of the
-- systemIdStartString attribute of the entry.
--
-- If the value of the rewritePrefix attribute is relative, it must be
-- made absolute with respect to the base URI currently in effect.
System_Id_Start_String : constant League.Strings.Universal_String
:= Matreshka.XML_Catalogs.Normalization.Normalize_System_Identifier
(Attributes.Value (System_Id_Start_String_Attribute_Name));
Rewrite_Prefix : constant League.Strings.Universal_String
:= Self.Locator.Base_URI.Resolve
(League.IRIs.From_Universal_String
(Attributes.Value
(Rewrite_Prefix_Attribute_Name))).To_Universal_String;
begin
-- Check that 'systemIdStartString' is not empty.
if System_Id_Start_String.Is_Empty then
Error (Self, "'systemIdStartString' is empty", Success);
return;
end if;
Self.Entry_File.Append
(new Rewrite_System_Entry'(System_Id_Start_String, Rewrite_Prefix));
end Process_Rewrite_System_Start_Element;
---------------------------------------
-- Process_Rewrite_URI_Start_Element --
---------------------------------------
procedure Process_Rewrite_URI_Start_Element
(Self : in out XML_Catalog_Handler'Class;
Attributes : XML.SAX.Attributes.SAX_Attributes;
Success : in out Boolean)
is
-- [XML Catalogs] 6.5.10. The rewriteURI Element
--
-- The rewriteURI element rewrites the beginning of a URI reference that
-- is not part of an external identifier.
--
-- <rewriteURI
-- id = id
-- uriStartString = string
-- rewritePrefix = uri-reference />
--
-- A rewriteURI entry matches a URI reference if the normalized value
-- (Section 6.3, “System Identifier and URI Normalization”) of the URI
-- reference begins precisely with the normalized value of the
-- uriStartString attribute of the entry.
--
-- If the value of the rewritePrefix attribute is relative, it must be
-- made absolute with respect to the base URI currently in effect.
URI_Start_String : constant League.Strings.Universal_String
:= Matreshka.XML_Catalogs.Normalization.Normalize_URI
(Attributes.Value (URI_Start_String_Attribute_Name));
Rewrite_Prefix : constant League.Strings.Universal_String
:= Self.Locator.Base_URI.Resolve
(League.IRIs.From_Universal_String
(Attributes.Value
(Rewrite_Prefix_Attribute_Name))).To_Universal_String;
begin
-- Check that 'uriStartString' is not empty.
if URI_Start_String.Is_Empty then
Error (Self, "'uriStartString' is empty", Success);
return;
end if;
Self.Entry_File.Append
(new Rewrite_URI_Entry'(URI_Start_String, Rewrite_Prefix));
end Process_Rewrite_URI_Start_Element;
----------------------------------
-- Process_System_Start_Element --
----------------------------------
procedure Process_System_Start_Element
(Self : in out XML_Catalog_Handler'Class;
Attributes : XML.SAX.Attributes.SAX_Attributes;
Success : in out Boolean)
is
-- [XML Catalogs] 6.5.4. The system Element
--
-- "The system element associates a URI reference with the system
-- identifier portion of an external identifier.
--
-- <system
-- id = id
-- systemId = string
-- uri = uri-reference
-- xml:base = uri-reference />
--
-- A system entry matches a system identifier if the normalized value
-- (Section 6.3, “System Identifier and URI Normalization”) of the
-- system identifier is lexically identical to the normalized value of
-- the systemId attribute of the entry.
--
-- If the value of the uri attribute is relative, it must be made
-- absolute with respect to the base URI currently in effect. The URI
-- reference should not include a fragment identifier."
System_Id : constant League.Strings.Universal_String
:= Matreshka.XML_Catalogs.Normalization.Normalize_System_Identifier
(Attributes.Value (System_Id_Attribute_Name));
URI : constant League.Strings.Universal_String
:= Self.Locator.Base_URI.Resolve
(League.IRIs.From_Universal_String
(Attributes.Value (URI_Attribute_Name))).To_Universal_String;
begin
-- Check that 'systemId' is not empty.
if System_Id.Is_Empty then
Error (Self, "systemId is empty", Success);
return;
end if;
-- Check that URI is not include a fragment identifier.
Check_No_Fragment_Identifier (Self, URI, Success);
if not Success then
return;
end if;
Self.Entry_File.Append (new System_Entry'(System_Id, URI));
end Process_System_Start_Element;
-----------------------------------------
-- Process_System_Suffix_Start_Element --
-----------------------------------------
procedure Process_System_Suffix_Start_Element
(Self : in out XML_Catalog_Handler'Class;
Attributes : XML.SAX.Attributes.SAX_Attributes;
Success : in out Boolean)
is
-- [XML Catalogs] 6.5.6. The systemSuffix Element
--
-- "The systemSuffix element associates a URI reference with the suffix
-- portion of a system identifier.
--
-- <systemSuffix
-- id = id
-- systemIdSuffix = string
-- uri = uri-reference
-- xml:base = uri-reference />
--
-- A systemSuffix entry matches a system identifier if the normalized
-- value (Section 6.3, “System Identifier and URI Normalization”) of the
-- system identifier ends precisely with the normalized value of the
-- systemIdSuffix attribute of the entry.
--
-- If the value of the uri attribute is relative, it must be made
-- absolute with respect to the base URI currently in effect. The URI
-- reference should not include a fragment identifier."
System_Id_Suffix : constant League.Strings.Universal_String
:= Matreshka.XML_Catalogs.Normalization.Normalize_System_Identifier
(Attributes.Value (System_Id_Suffix_Attribute_Name));
URI : constant League.Strings.Universal_String
:= Self.Locator.Base_URI.Resolve
(League.IRIs.From_Universal_String
(Attributes.Value (URI_Attribute_Name))).To_Universal_String;
begin
-- Check that 'systemIdSuffix' is not empty.
if System_Id_Suffix.Is_Empty then
Error (Self, "systemIdSuffix is empty", Success);
return;
end if;
-- Check that URI is not include a fragment identifier.
Check_No_Fragment_Identifier (Self, URI, Success);
if not Success then
return;
end if;
Self.Entry_File.Append (new System_Suffix_Entry'(System_Id_Suffix, URI));
end Process_System_Suffix_Start_Element;
-------------------------------
-- Process_URI_Start_Element --
-------------------------------
procedure Process_URI_Start_Element
(Self : in out XML_Catalog_Handler'Class;
Attributes : XML.SAX.Attributes.SAX_Attributes;
Success : in out Boolean)
is
-- [XML Catalogs] 6.5.9. The uri Element
--
-- The uri element associates an alternate URI reference with a URI
-- reference that is not part of an external identifier.
--
-- <uri
-- id = id
-- name = string
-- uri = uri-reference
-- xml:base = uri-reference />
--
-- A uri entry matches a URI reference if the normalized value (Section
-- 6.3, “System Identifier and URI Normalization”) of the URI reference
-- is lexically identical to the normalized value of the name attribute
-- of the entry."
--
-- "If the value of the uri attribute is relative, it must be made
-- absolute with respect to the base URI currently in effect."
Name : constant League.Strings.Universal_String
:= Matreshka.XML_Catalogs.Normalization.Normalize_URI
(Attributes.Value (Name_Attribute_Name));
URI : constant League.Strings.Universal_String
:= Self.Locator.Base_URI.Resolve
(League.IRIs.From_Universal_String
(Attributes.Value (URI_Attribute_Name))).To_Universal_String;
begin
-- Check that 'name' is not empty.
if Name.Is_Empty then
Error (Self, "name is empty", Success);
return;
end if;
Self.Entry_File.Append (new URI_Entry'(Name, URI));
end Process_URI_Start_Element;
--------------------------------------
-- Process_URI_Suffix_Start_Element --
--------------------------------------
procedure Process_URI_Suffix_Start_Element
(Self : in out XML_Catalog_Handler'Class;
Attributes : XML.SAX.Attributes.SAX_Attributes;
Success : in out Boolean)
is
-- [XML Catalogs] 6.5.11. The uriSuffix Element
--
-- "The uriSuffix element associates a URI reference with the suffix
-- portion of a URI reference that is not part of an external
-- identifier.
--
-- <uriSuffix
-- id = id
-- uriSuffix = string
-- uri = uri-reference
-- xml:base = uri-reference />
--
-- A uriSuffix entry matches a URI if the normalized value (Section 6.3,
-- “System Identifier and URI Normalization”) of the URI ends precisely
-- with the normalized value of the uriSuffix attribute of the entry.
--
-- If the value of the uri attribute is relative, it must be made
-- absolute with respect to the base URI currently in effect.
URI_Suffix : constant League.Strings.Universal_String
:= Matreshka.XML_Catalogs.Normalization.Normalize_URI
(Attributes.Value (URI_Suffix_Attribute_Name));
URI : constant League.Strings.Universal_String
:= Self.Locator.Base_URI.Resolve
(League.IRIs.From_Universal_String
(Attributes.Value (URI_Attribute_Name))).To_Universal_String;
begin
-- Check that 'uriSuffix' is not empty.
if URI_Suffix.Is_Empty then
Error (Self, "uriSuffix is empty", Success);
return;
end if;
Self.Entry_File.Append (new URI_Suffix_Entry'(URI_Suffix, URI));
end Process_URI_Suffix_Start_Element;
-----------------------------
-- Set_Default_Prefer_Mode --
-----------------------------
procedure Set_Default_Prefer_Mode
(Self : in out XML_Catalog_Handler'Class;
Mode : Matreshka.XML_Catalogs.Entry_Files.Prefer_Mode) is
begin
Self.Default_Prefer_Mode := Mode;
end Set_Default_Prefer_Mode;
--------------------------
-- Set_Document_Locator --
--------------------------
overriding procedure Set_Document_Locator
(Self : in out XML_Catalog_Handler;
Locator : XML.SAX.Locators.SAX_Locator) is
begin
Self.Locator := Locator;
end Set_Document_Locator;
--------------------
-- Start_Document --
--------------------
overriding procedure Start_Document
(Self : in out XML_Catalog_Handler;
Success : in out Boolean) is
begin
Self.Diagnosis := League.Strings.Empty_Universal_String;
Self.Current_Prefer_Mode := Self.Default_Prefer_Mode;
end Start_Document;
---------------
-- Start_DTD --
---------------
overriding procedure Start_DTD
(Self : in out XML_Catalog_Handler;
Name : League.Strings.Universal_String;
Public_Id : League.Strings.Universal_String;
System_Id : League.Strings.Universal_String;
Success : in out Boolean) is
begin
-- Check whether processed document is XML Catalogs entry file.
if Public_Id /= XML_Catalogs_1_0_Public_Id
and Public_Id /= XML_Catalogs_1_1_Public_Id
then
Self.Error ("Unknown XML Catalogs DTD", Success);
end if;
end Start_DTD;
-------------------
-- Start_Element --
-------------------
overriding procedure Start_Element
(Self : in out XML_Catalog_Handler;
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) is
begin
if Namespace_URI /= XML_Catalogs_Namespace then
-- Ignore all non-XML Catalogs elements.
return;
end if;
if Local_Name = Catalog_Tag_Name then
Process_Catalog_Start_Element (Self, Attributes, Success);
elsif Local_Name = Delegate_Public_Tag_Name then
Process_Delegate_Public_Start_Element (Self, Attributes, Success);
elsif Local_Name = Delegate_System_Tag_Name then
Process_Delegate_System_Start_Element (Self, Attributes, Success);
elsif Local_Name = Delegate_URI_Tag_Name then
Process_Delegate_URI_Start_Element (Self, Attributes, Success);
elsif Local_Name = Group_Tag_Name then
Process_Group_Start_Element (Self, Attributes, Success);
elsif Local_Name = Next_Catalog_Tag_Name then
Process_Next_Catalog_Start_Element (Self, Attributes, Success);
elsif Local_Name = Public_Tag_Name then
Process_Public_Start_Element (Self, Attributes, Success);
elsif Local_Name = Rewrite_System_Tag_Name then
Process_Rewrite_System_Start_Element (Self, Attributes, Success);
elsif Local_Name = Rewrite_URI_Tag_Name then
Process_Rewrite_URI_Start_Element (Self, Attributes, Success);
elsif Local_Name = System_Tag_Name then
Process_System_Start_Element (Self, Attributes, Success);
elsif Local_Name = System_Suffix_Tag_Name then
Process_System_Suffix_Start_Element (Self, Attributes, Success);
elsif Local_Name = URI_Tag_Name then
Process_URI_Start_Element (Self, Attributes, Success);
elsif Local_Name = URI_Suffix_Tag_Name then
Process_URI_Suffix_Start_Element (Self, Attributes, Success);
end if;
end Start_Element;
-------------
-- Warning --
-------------
overriding procedure Warning
(Self : in out XML_Catalog_Handler;
Occurrence : XML.SAX.Parse_Exceptions.SAX_Parse_Exception;
Success : in out Boolean) is
begin
Ada.Wide_Wide_Text_IO.Put_Line
(Ada.Wide_Wide_Text_IO.Standard_Error,
"(warning) " & Occurrence.Message.To_Wide_Wide_String);
end Warning;
end Matreshka.XML_Catalogs.Handlers;
|
sungyeon/drake | Ada | 1,292 | ads | pragma License (Unrestricted);
-- Ada 2012
with Ada.Containers.Synchronized_Queue_Interfaces;
with System;
generic
with package Queue_Interfaces is new Synchronized_Queue_Interfaces (<>);
Default_Ceiling : System.Any_Priority := System.Priority'Last;
package Ada.Containers.Unbounded_Synchronized_Queues is
pragma Preelaborate;
package Implementation is
-- not specified by the language
type Node;
type Node_Access is access Node;
type Node is record
Element : Queue_Interfaces.Element_Type;
Next : Node_Access;
end record;
end Implementation;
protected type Queue (Ceiling : System.Any_Priority := Default_Ceiling)
with Priority => Ceiling is
new Queue_Interfaces.Queue
with
overriding entry Enqueue (New_Item : Queue_Interfaces.Element_Type);
overriding entry Dequeue (Element : out Queue_Interfaces.Element_Type);
overriding function Current_Use return Count_Type;
overriding function Peak_Use return Count_Type;
private
First : Implementation.Node_Access := null;
Last : Implementation.Node_Access := null;
Current_Length : Count_Type := 0;
Peak_Length : Count_Type := 0;
end Queue;
private
end Ada.Containers.Unbounded_Synchronized_Queues;
|
reznikmm/matreshka | Ada | 40,350 | ads | ------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- Ada Modeling Framework --
-- --
-- Runtime Library Component --
-- --
------------------------------------------------------------------------------
-- --
-- Copyright © 2012, Vadim Godunko <[email protected]> --
-- All rights reserved. --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions --
-- are met: --
-- --
-- * Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- --
-- * Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in the --
-- documentation and/or other materials provided with the distribution. --
-- --
-- * Neither the name of the Vadim Godunko, IE nor the names of its --
-- contributors may be used to endorse or promote products derived from --
-- this software without specific prior written permission. --
-- --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR --
-- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
-- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED --
-- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR --
-- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF --
-- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING --
-- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS --
-- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
-- --
------------------------------------------------------------------------------
-- $Revision$ $Date$
------------------------------------------------------------------------------
-- This file is generated, don't edit it.
------------------------------------------------------------------------------
with AMF.Internals.OCL_Elements;
with AMF.OCL.Template_Parameter_Types;
with AMF.String_Collections;
with AMF.UML.Classifier_Template_Parameters;
with AMF.UML.Classifiers.Collections;
with AMF.UML.Collaboration_Uses.Collections;
with AMF.UML.Comments.Collections;
with AMF.UML.Constraints.Collections;
with AMF.UML.Dependencies.Collections;
with AMF.UML.Element_Imports.Collections;
with AMF.UML.Elements.Collections;
with AMF.UML.Features.Collections;
with AMF.UML.Generalization_Sets.Collections;
with AMF.UML.Generalizations.Collections;
with AMF.UML.Named_Elements.Collections;
with AMF.UML.Namespaces.Collections;
with AMF.UML.Package_Imports.Collections;
with AMF.UML.Packageable_Elements.Collections;
with AMF.UML.Packages.Collections;
with AMF.UML.Parameterable_Elements.Collections;
with AMF.UML.Properties.Collections;
with AMF.UML.Redefinable_Elements.Collections;
with AMF.UML.Redefinable_Template_Signatures;
with AMF.UML.String_Expressions;
with AMF.UML.Substitutions.Collections;
with AMF.UML.Template_Bindings.Collections;
with AMF.UML.Template_Parameters;
with AMF.UML.Template_Signatures;
with AMF.UML.Types;
with AMF.UML.Use_Cases.Collections;
with AMF.Visitors;
package AMF.Internals.OCL_Template_Parameter_Types is
type OCL_Template_Parameter_Type_Proxy is
limited new AMF.Internals.OCL_Elements.OCL_Element_Proxy
and AMF.OCL.Template_Parameter_Types.OCL_Template_Parameter_Type with null record;
overriding function Get_Specification
(Self : not null access constant OCL_Template_Parameter_Type_Proxy)
return AMF.Optional_String;
-- Getter of TemplateParameterType::specification.
--
overriding procedure Set_Specification
(Self : not null access OCL_Template_Parameter_Type_Proxy;
To : AMF.Optional_String);
-- Setter of TemplateParameterType::specification.
--
overriding function Get_Attribute
(Self : not null access constant OCL_Template_Parameter_Type_Proxy)
return AMF.UML.Properties.Collections.Set_Of_UML_Property;
-- Getter of Classifier::attribute.
--
-- Refers to all of the Properties that are direct (i.e. not inherited or
-- imported) attributes of the classifier.
overriding function Get_Collaboration_Use
(Self : not null access constant OCL_Template_Parameter_Type_Proxy)
return AMF.UML.Collaboration_Uses.Collections.Set_Of_UML_Collaboration_Use;
-- Getter of Classifier::collaborationUse.
--
-- References the collaboration uses owned by the classifier.
overriding function Get_Feature
(Self : not null access constant OCL_Template_Parameter_Type_Proxy)
return AMF.UML.Features.Collections.Set_Of_UML_Feature;
-- Getter of Classifier::feature.
--
-- Specifies each feature defined in the classifier.
-- Note that there may be members of the Classifier that are of the type
-- Feature but are not included in this association, e.g. inherited
-- features.
overriding function Get_General
(Self : not null access constant OCL_Template_Parameter_Type_Proxy)
return AMF.UML.Classifiers.Collections.Set_Of_UML_Classifier;
-- Getter of Classifier::general.
--
-- Specifies the general Classifiers for this Classifier.
-- References the general classifier in the Generalization relationship.
overriding function Get_Generalization
(Self : not null access constant OCL_Template_Parameter_Type_Proxy)
return AMF.UML.Generalizations.Collections.Set_Of_UML_Generalization;
-- Getter of Classifier::generalization.
--
-- Specifies the Generalization relationships for this Classifier. These
-- Generalizations navigaten to more general classifiers in the
-- generalization hierarchy.
overriding function Get_Inherited_Member
(Self : not null access constant OCL_Template_Parameter_Type_Proxy)
return AMF.UML.Named_Elements.Collections.Set_Of_UML_Named_Element;
-- Getter of Classifier::inheritedMember.
--
-- Specifies all elements inherited by this classifier from the general
-- classifiers.
overriding function Get_Is_Abstract
(Self : not null access constant OCL_Template_Parameter_Type_Proxy)
return Boolean;
-- Getter of Classifier::isAbstract.
--
-- If true, the Classifier does not provide a complete declaration and can
-- typically not be instantiated. An abstract classifier is intended to be
-- used by other classifiers e.g. as the target of general
-- metarelationships or generalization relationships.
overriding procedure Set_Is_Abstract
(Self : not null access OCL_Template_Parameter_Type_Proxy;
To : Boolean);
-- Setter of Classifier::isAbstract.
--
-- If true, the Classifier does not provide a complete declaration and can
-- typically not be instantiated. An abstract classifier is intended to be
-- used by other classifiers e.g. as the target of general
-- metarelationships or generalization relationships.
overriding function Get_Is_Final_Specialization
(Self : not null access constant OCL_Template_Parameter_Type_Proxy)
return Boolean;
-- Getter of Classifier::isFinalSpecialization.
--
-- If true, the Classifier cannot be specialized by generalization. Note
-- that this property is preserved through package merge operations; that
-- is, the capability to specialize a Classifier (i.e.,
-- isFinalSpecialization =false) must be preserved in the resulting
-- Classifier of a package merge operation where a Classifier with
-- isFinalSpecialization =false is merged with a matching Classifier with
-- isFinalSpecialization =true: the resulting Classifier will have
-- isFinalSpecialization =false.
overriding procedure Set_Is_Final_Specialization
(Self : not null access OCL_Template_Parameter_Type_Proxy;
To : Boolean);
-- Setter of Classifier::isFinalSpecialization.
--
-- If true, the Classifier cannot be specialized by generalization. Note
-- that this property is preserved through package merge operations; that
-- is, the capability to specialize a Classifier (i.e.,
-- isFinalSpecialization =false) must be preserved in the resulting
-- Classifier of a package merge operation where a Classifier with
-- isFinalSpecialization =false is merged with a matching Classifier with
-- isFinalSpecialization =true: the resulting Classifier will have
-- isFinalSpecialization =false.
overriding function Get_Owned_Template_Signature
(Self : not null access constant OCL_Template_Parameter_Type_Proxy)
return AMF.UML.Redefinable_Template_Signatures.UML_Redefinable_Template_Signature_Access;
-- Getter of Classifier::ownedTemplateSignature.
--
-- The optional template signature specifying the formal template
-- parameters.
overriding procedure Set_Owned_Template_Signature
(Self : not null access OCL_Template_Parameter_Type_Proxy;
To : AMF.UML.Redefinable_Template_Signatures.UML_Redefinable_Template_Signature_Access);
-- Setter of Classifier::ownedTemplateSignature.
--
-- The optional template signature specifying the formal template
-- parameters.
overriding function Get_Owned_Use_Case
(Self : not null access constant OCL_Template_Parameter_Type_Proxy)
return AMF.UML.Use_Cases.Collections.Set_Of_UML_Use_Case;
-- Getter of Classifier::ownedUseCase.
--
-- References the use cases owned by this classifier.
overriding function Get_Powertype_Extent
(Self : not null access constant OCL_Template_Parameter_Type_Proxy)
return AMF.UML.Generalization_Sets.Collections.Set_Of_UML_Generalization_Set;
-- Getter of Classifier::powertypeExtent.
--
-- Designates the GeneralizationSet of which the associated Classifier is
-- a power type.
overriding function Get_Redefined_Classifier
(Self : not null access constant OCL_Template_Parameter_Type_Proxy)
return AMF.UML.Classifiers.Collections.Set_Of_UML_Classifier;
-- Getter of Classifier::redefinedClassifier.
--
-- References the Classifiers that are redefined by this Classifier.
overriding function Get_Representation
(Self : not null access constant OCL_Template_Parameter_Type_Proxy)
return AMF.UML.Collaboration_Uses.UML_Collaboration_Use_Access;
-- Getter of Classifier::representation.
--
-- References a collaboration use which indicates the collaboration that
-- represents this classifier.
overriding procedure Set_Representation
(Self : not null access OCL_Template_Parameter_Type_Proxy;
To : AMF.UML.Collaboration_Uses.UML_Collaboration_Use_Access);
-- Setter of Classifier::representation.
--
-- References a collaboration use which indicates the collaboration that
-- represents this classifier.
overriding function Get_Substitution
(Self : not null access constant OCL_Template_Parameter_Type_Proxy)
return AMF.UML.Substitutions.Collections.Set_Of_UML_Substitution;
-- Getter of Classifier::substitution.
--
-- References the substitutions that are owned by this Classifier.
overriding function Get_Template_Parameter
(Self : not null access constant OCL_Template_Parameter_Type_Proxy)
return AMF.UML.Classifier_Template_Parameters.UML_Classifier_Template_Parameter_Access;
-- Getter of Classifier::templateParameter.
--
-- The template parameter that exposes this element as a formal parameter.
overriding procedure Set_Template_Parameter
(Self : not null access OCL_Template_Parameter_Type_Proxy;
To : AMF.UML.Classifier_Template_Parameters.UML_Classifier_Template_Parameter_Access);
-- Setter of Classifier::templateParameter.
--
-- The template parameter that exposes this element as a formal parameter.
overriding function Get_Use_Case
(Self : not null access constant OCL_Template_Parameter_Type_Proxy)
return AMF.UML.Use_Cases.Collections.Set_Of_UML_Use_Case;
-- Getter of Classifier::useCase.
--
-- The set of use cases for which this Classifier is the subject.
overriding function Get_Element_Import
(Self : not null access constant OCL_Template_Parameter_Type_Proxy)
return AMF.UML.Element_Imports.Collections.Set_Of_UML_Element_Import;
-- Getter of Namespace::elementImport.
--
-- References the ElementImports owned by the Namespace.
overriding function Get_Imported_Member
(Self : not null access constant OCL_Template_Parameter_Type_Proxy)
return AMF.UML.Packageable_Elements.Collections.Set_Of_UML_Packageable_Element;
-- Getter of Namespace::importedMember.
--
-- References the PackageableElements that are members of this Namespace
-- as a result of either PackageImports or ElementImports.
overriding function Get_Member
(Self : not null access constant OCL_Template_Parameter_Type_Proxy)
return AMF.UML.Named_Elements.Collections.Set_Of_UML_Named_Element;
-- Getter of Namespace::member.
--
-- A collection of NamedElements identifiable within the Namespace, either
-- by being owned or by being introduced by importing or inheritance.
overriding function Get_Owned_Member
(Self : not null access constant OCL_Template_Parameter_Type_Proxy)
return AMF.UML.Named_Elements.Collections.Set_Of_UML_Named_Element;
-- Getter of Namespace::ownedMember.
--
-- A collection of NamedElements owned by the Namespace.
overriding function Get_Owned_Rule
(Self : not null access constant OCL_Template_Parameter_Type_Proxy)
return AMF.UML.Constraints.Collections.Set_Of_UML_Constraint;
-- Getter of Namespace::ownedRule.
--
-- Specifies a set of Constraints owned by this Namespace.
overriding function Get_Package_Import
(Self : not null access constant OCL_Template_Parameter_Type_Proxy)
return AMF.UML.Package_Imports.Collections.Set_Of_UML_Package_Import;
-- Getter of Namespace::packageImport.
--
-- References the PackageImports owned by the Namespace.
overriding function Get_Client_Dependency
(Self : not null access constant OCL_Template_Parameter_Type_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
(Self : not null access constant OCL_Template_Parameter_Type_Proxy)
return AMF.Optional_String;
-- Getter of NamedElement::name.
--
-- The name of the NamedElement.
overriding procedure Set_Name
(Self : not null access OCL_Template_Parameter_Type_Proxy;
To : AMF.Optional_String);
-- Setter of NamedElement::name.
--
-- The name of the NamedElement.
overriding function Get_Name_Expression
(Self : not null access constant OCL_Template_Parameter_Type_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 OCL_Template_Parameter_Type_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 OCL_Template_Parameter_Type_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 OCL_Template_Parameter_Type_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 Get_Visibility
(Self : not null access constant OCL_Template_Parameter_Type_Proxy)
return AMF.UML.Optional_UML_Visibility_Kind;
-- Getter of NamedElement::visibility.
--
-- Determines where the NamedElement appears within different Namespaces
-- within the overall model, and its accessibility.
overriding procedure Set_Visibility
(Self : not null access OCL_Template_Parameter_Type_Proxy;
To : AMF.UML.Optional_UML_Visibility_Kind);
-- Setter of NamedElement::visibility.
--
-- Determines where the NamedElement appears within different Namespaces
-- within the overall model, and its accessibility.
overriding function Get_Owned_Comment
(Self : not null access constant OCL_Template_Parameter_Type_Proxy)
return AMF.UML.Comments.Collections.Set_Of_UML_Comment;
-- Getter of Element::ownedComment.
--
-- The Comments owned by this element.
overriding function Get_Owned_Element
(Self : not null access constant OCL_Template_Parameter_Type_Proxy)
return AMF.UML.Elements.Collections.Set_Of_UML_Element;
-- Getter of Element::ownedElement.
--
-- The Elements owned by this element.
overriding function Get_Owner
(Self : not null access constant OCL_Template_Parameter_Type_Proxy)
return AMF.UML.Elements.UML_Element_Access;
-- Getter of Element::owner.
--
-- The Element that owns this element.
overriding function Get_Package
(Self : not null access constant OCL_Template_Parameter_Type_Proxy)
return AMF.UML.Packages.UML_Package_Access;
-- Getter of Type::package.
--
-- Specifies the owning package of this classifier, if any.
overriding procedure Set_Package
(Self : not null access OCL_Template_Parameter_Type_Proxy;
To : AMF.UML.Packages.UML_Package_Access);
-- Setter of Type::package.
--
-- Specifies the owning package of this classifier, if any.
overriding function Get_Visibility
(Self : not null access constant OCL_Template_Parameter_Type_Proxy)
return AMF.UML.UML_Visibility_Kind;
-- Getter of PackageableElement::visibility.
--
-- Indicates that packageable elements must always have a visibility,
-- i.e., visibility is not optional.
overriding procedure Set_Visibility
(Self : not null access OCL_Template_Parameter_Type_Proxy;
To : AMF.UML.UML_Visibility_Kind);
-- Setter of PackageableElement::visibility.
--
-- Indicates that packageable elements must always have a visibility,
-- i.e., visibility is not optional.
overriding function Get_Owning_Template_Parameter
(Self : not null access constant OCL_Template_Parameter_Type_Proxy)
return AMF.UML.Template_Parameters.UML_Template_Parameter_Access;
-- Getter of ParameterableElement::owningTemplateParameter.
--
-- The formal template parameter that owns this element.
overriding procedure Set_Owning_Template_Parameter
(Self : not null access OCL_Template_Parameter_Type_Proxy;
To : AMF.UML.Template_Parameters.UML_Template_Parameter_Access);
-- Setter of ParameterableElement::owningTemplateParameter.
--
-- The formal template parameter that owns this element.
overriding function Get_Template_Parameter
(Self : not null access constant OCL_Template_Parameter_Type_Proxy)
return AMF.UML.Template_Parameters.UML_Template_Parameter_Access;
-- Getter of ParameterableElement::templateParameter.
--
-- The template parameter that exposes this element as a formal parameter.
overriding procedure Set_Template_Parameter
(Self : not null access OCL_Template_Parameter_Type_Proxy;
To : AMF.UML.Template_Parameters.UML_Template_Parameter_Access);
-- Setter of ParameterableElement::templateParameter.
--
-- The template parameter that exposes this element as a formal parameter.
overriding function Get_Owned_Template_Signature
(Self : not null access constant OCL_Template_Parameter_Type_Proxy)
return AMF.UML.Template_Signatures.UML_Template_Signature_Access;
-- Getter of TemplateableElement::ownedTemplateSignature.
--
-- The optional template signature specifying the formal template
-- parameters.
overriding procedure Set_Owned_Template_Signature
(Self : not null access OCL_Template_Parameter_Type_Proxy;
To : AMF.UML.Template_Signatures.UML_Template_Signature_Access);
-- Setter of TemplateableElement::ownedTemplateSignature.
--
-- The optional template signature specifying the formal template
-- parameters.
overriding function Get_Template_Binding
(Self : not null access constant OCL_Template_Parameter_Type_Proxy)
return AMF.UML.Template_Bindings.Collections.Set_Of_UML_Template_Binding;
-- Getter of TemplateableElement::templateBinding.
--
-- The optional bindings from this element to templates.
overriding function Get_Is_Leaf
(Self : not null access constant OCL_Template_Parameter_Type_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 OCL_Template_Parameter_Type_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 OCL_Template_Parameter_Type_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 OCL_Template_Parameter_Type_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 All_Features
(Self : not null access constant OCL_Template_Parameter_Type_Proxy)
return AMF.UML.Features.Collections.Set_Of_UML_Feature;
-- Operation Classifier::allFeatures.
--
-- The query allFeatures() gives all of the features in the namespace of
-- the classifier. In general, through mechanisms such as inheritance,
-- this will be a larger set than feature.
overriding function All_Parents
(Self : not null access constant OCL_Template_Parameter_Type_Proxy)
return AMF.UML.Classifiers.Collections.Set_Of_UML_Classifier;
-- Operation Classifier::allParents.
--
-- The query allParents() gives all of the direct and indirect ancestors
-- of a generalized Classifier.
overriding function Conforms_To
(Self : not null access constant OCL_Template_Parameter_Type_Proxy;
Other : AMF.UML.Classifiers.UML_Classifier_Access)
return Boolean;
-- Operation Classifier::conformsTo.
--
-- 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.
overriding function General
(Self : not null access constant OCL_Template_Parameter_Type_Proxy)
return AMF.UML.Classifiers.Collections.Set_Of_UML_Classifier;
-- Operation Classifier::general.
--
-- The general classifiers are the classifiers referenced by the
-- generalization relationships.
overriding function Has_Visibility_Of
(Self : not null access constant OCL_Template_Parameter_Type_Proxy;
N : AMF.UML.Named_Elements.UML_Named_Element_Access)
return Boolean;
-- Operation Classifier::hasVisibilityOf.
--
-- The query hasVisibilityOf() determines whether a named element is
-- visible in the classifier. By default all are visible. It is only
-- called when the argument is something owned by a parent.
overriding function Inherit
(Self : not null access constant OCL_Template_Parameter_Type_Proxy;
Inhs : AMF.UML.Named_Elements.Collections.Set_Of_UML_Named_Element)
return AMF.UML.Named_Elements.Collections.Set_Of_UML_Named_Element;
-- Operation Classifier::inherit.
--
-- The query inherit() defines how to inherit a set of elements. Here the
-- operation is defined to inherit them all. It is intended to be
-- redefined in circumstances where inheritance is affected by
-- redefinition.
-- The inherit operation is overridden to exclude redefined properties.
overriding function Inheritable_Members
(Self : not null access constant OCL_Template_Parameter_Type_Proxy;
C : AMF.UML.Classifiers.UML_Classifier_Access)
return AMF.UML.Named_Elements.Collections.Set_Of_UML_Named_Element;
-- Operation Classifier::inheritableMembers.
--
-- The query inheritableMembers() gives all of the members of a classifier
-- that may be inherited in one of its descendants, subject to whatever
-- visibility restrictions apply.
overriding function Inherited_Member
(Self : not null access constant OCL_Template_Parameter_Type_Proxy)
return AMF.UML.Named_Elements.Collections.Set_Of_UML_Named_Element;
-- Operation Classifier::inheritedMember.
--
-- The inheritedMember association is derived by inheriting the
-- inheritable members of the parents.
-- The inheritedMember association is derived by inheriting the
-- inheritable members of the parents.
overriding function Is_Template
(Self : not null access constant OCL_Template_Parameter_Type_Proxy)
return Boolean;
-- Operation Classifier::isTemplate.
--
-- The query isTemplate() returns whether this templateable element is
-- actually a template.
overriding function May_Specialize_Type
(Self : not null access constant OCL_Template_Parameter_Type_Proxy;
C : AMF.UML.Classifiers.UML_Classifier_Access)
return Boolean;
-- Operation Classifier::maySpecializeType.
--
-- The query maySpecializeType() determines whether this classifier may
-- have a generalization relationship to classifiers of the specified
-- type. By default a classifier may specialize classifiers of the same or
-- a more general type. It is intended to be redefined by classifiers that
-- have different specialization constraints.
overriding function Parents
(Self : not null access constant OCL_Template_Parameter_Type_Proxy)
return AMF.UML.Classifiers.Collections.Set_Of_UML_Classifier;
-- Operation Classifier::parents.
--
-- The query parents() gives all of the immediate ancestors of a
-- generalized Classifier.
overriding function Exclude_Collisions
(Self : not null access constant OCL_Template_Parameter_Type_Proxy;
Imps : AMF.UML.Packageable_Elements.Collections.Set_Of_UML_Packageable_Element)
return AMF.UML.Packageable_Elements.Collections.Set_Of_UML_Packageable_Element;
-- Operation Namespace::excludeCollisions.
--
-- The query excludeCollisions() excludes from a set of
-- PackageableElements any that would not be distinguishable from each
-- other in this namespace.
overriding function Get_Names_Of_Member
(Self : not null access constant OCL_Template_Parameter_Type_Proxy;
Element : AMF.UML.Named_Elements.UML_Named_Element_Access)
return AMF.String_Collections.Set_Of_String;
-- Operation Namespace::getNamesOfMember.
--
-- The query getNamesOfMember() takes importing into account. It gives
-- back the set of names that an element would have in an importing
-- namespace, either because it is owned, or if not owned then imported
-- individually, or if not individually then from a package.
-- The query getNamesOfMember() gives a set of all of the names that a
-- member would have in a Namespace. In general a member can have multiple
-- names in a Namespace if it is imported more than once with different
-- aliases. The query takes account of importing. It gives back the set of
-- names that an element would have in an importing namespace, either
-- because it is owned, or if not owned then imported individually, or if
-- not individually then from a package.
overriding function Import_Members
(Self : not null access constant OCL_Template_Parameter_Type_Proxy;
Imps : AMF.UML.Packageable_Elements.Collections.Set_Of_UML_Packageable_Element)
return AMF.UML.Packageable_Elements.Collections.Set_Of_UML_Packageable_Element;
-- Operation Namespace::importMembers.
--
-- The query importMembers() defines which of a set of PackageableElements
-- are actually imported into the namespace. This excludes hidden ones,
-- i.e., those which have names that conflict with names of owned members,
-- and also excludes elements which would have the same name when imported.
overriding function Imported_Member
(Self : not null access constant OCL_Template_Parameter_Type_Proxy)
return AMF.UML.Packageable_Elements.Collections.Set_Of_UML_Packageable_Element;
-- Operation Namespace::importedMember.
--
-- The importedMember property is derived from the ElementImports and the
-- PackageImports. References the PackageableElements that are members of
-- this Namespace as a result of either PackageImports or ElementImports.
overriding function Members_Are_Distinguishable
(Self : not null access constant OCL_Template_Parameter_Type_Proxy)
return Boolean;
-- Operation Namespace::membersAreDistinguishable.
--
-- The Boolean query membersAreDistinguishable() determines whether all of
-- the namespace's members are distinguishable within it.
overriding function Owned_Member
(Self : not null access constant OCL_Template_Parameter_Type_Proxy)
return AMF.UML.Named_Elements.Collections.Set_Of_UML_Named_Element;
-- Operation Namespace::ownedMember.
--
-- Missing derivation for Namespace::/ownedMember : NamedElement
overriding function All_Namespaces
(Self : not null access constant OCL_Template_Parameter_Type_Proxy)
return AMF.UML.Namespaces.Collections.Ordered_Set_Of_UML_Namespace;
-- Operation NamedElement::allNamespaces.
--
-- The query allNamespaces() gives the sequence of namespaces in which the
-- NamedElement is nested, working outwards.
overriding function All_Owning_Packages
(Self : not null access constant OCL_Template_Parameter_Type_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 OCL_Template_Parameter_Type_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 OCL_Template_Parameter_Type_Proxy)
return AMF.UML.Namespaces.UML_Namespace_Access;
-- Operation NamedElement::namespace.
--
-- Missing derivation for NamedElement::/namespace : Namespace
overriding function Qualified_Name
(Self : not null access constant OCL_Template_Parameter_Type_Proxy)
return League.Strings.Universal_String;
-- Operation NamedElement::qualifiedName.
--
-- When there is a name, and all of the containing namespaces have a name,
-- the qualified name is constructed from the names of the containing
-- namespaces.
overriding function Separator
(Self : not null access constant OCL_Template_Parameter_Type_Proxy)
return League.Strings.Universal_String;
-- Operation NamedElement::separator.
--
-- The query separator() gives the string that is used to separate names
-- when constructing a qualified name.
overriding function All_Owned_Elements
(Self : not null access constant OCL_Template_Parameter_Type_Proxy)
return AMF.UML.Elements.Collections.Set_Of_UML_Element;
-- Operation Element::allOwnedElements.
--
-- The query allOwnedElements() gives all of the direct and indirect owned
-- elements of an element.
overriding function Must_Be_Owned
(Self : not null access constant OCL_Template_Parameter_Type_Proxy)
return Boolean;
-- Operation Element::mustBeOwned.
--
-- The query mustBeOwned() indicates whether elements of this type must
-- have an owner. Subclasses of Element that do not require an owner must
-- override this operation.
overriding function Conforms_To
(Self : not null access constant OCL_Template_Parameter_Type_Proxy;
Other : AMF.UML.Types.UML_Type_Access)
return Boolean;
-- Operation Type::conformsTo.
--
-- The query conformsTo() gives true for a type that conforms to another.
-- By default, two types do not conform to each other. This query is
-- intended to be redefined for specific conformance situations.
overriding function Is_Compatible_With
(Self : not null access constant OCL_Template_Parameter_Type_Proxy;
P : AMF.UML.Parameterable_Elements.UML_Parameterable_Element_Access)
return Boolean;
-- Operation ParameterableElement::isCompatibleWith.
--
-- The query isCompatibleWith() determines if this parameterable element
-- is compatible with the specified parameterable element. By default
-- parameterable element P is compatible with parameterable element Q if
-- the kind of P is the same or a subtype as the kind of Q. Subclasses
-- should override this operation to specify different compatibility
-- constraints.
overriding function Is_Template_Parameter
(Self : not null access constant OCL_Template_Parameter_Type_Proxy)
return Boolean;
-- Operation ParameterableElement::isTemplateParameter.
--
-- The query isTemplateParameter() determines if this parameterable
-- element is exposed as a formal template parameter.
overriding function Parameterable_Elements
(Self : not null access constant OCL_Template_Parameter_Type_Proxy)
return AMF.UML.Parameterable_Elements.Collections.Set_Of_UML_Parameterable_Element;
-- Operation TemplateableElement::parameterableElements.
--
-- The query parameterableElements() returns the set of elements that may
-- be used as the parametered elements for a template parameter of this
-- templateable element. By default, this set includes all the owned
-- elements. Subclasses may override this operation if they choose to
-- restrict the set of parameterable elements.
overriding function Is_Consistent_With
(Self : not null access constant OCL_Template_Parameter_Type_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 OCL_Template_Parameter_Type_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 procedure Enter_Element
(Self : not null access constant OCL_Template_Parameter_Type_Proxy;
Visitor : in out AMF.Visitors.Abstract_Visitor'Class;
Control : in out AMF.Visitors.Traverse_Control);
overriding procedure Leave_Element
(Self : not null access constant OCL_Template_Parameter_Type_Proxy;
Visitor : in out AMF.Visitors.Abstract_Visitor'Class;
Control : in out AMF.Visitors.Traverse_Control);
overriding procedure Visit_Element
(Self : not null access constant OCL_Template_Parameter_Type_Proxy;
Iterator : in out AMF.Visitors.Abstract_Iterator'Class;
Visitor : in out AMF.Visitors.Abstract_Visitor'Class;
Control : in out AMF.Visitors.Traverse_Control);
end AMF.Internals.OCL_Template_Parameter_Types;
|
clairvoyant/anagram | Ada | 2,773 | adb | -- Check basic grammar constructor and debuger output
with Anagram.Grammars_Debug;
with Anagram.Grammars;
with Anagram.Grammars.Constructors;
with League.Strings;
procedure TS_00002 is
use Anagram.Grammars.Constructors;
C : Anagram.Grammars.Constructors.Constructor;
begin
C.Create_Terminal (League.Strings.To_Universal_String ("T2"));
C.Create_Terminal (League.Strings.To_Universal_String ("T1"));
C.Create_Terminal (League.Strings.To_Universal_String ("T3"));
declare
T1 : constant Part := C.Create_Terminal_Reference
(League.Strings.To_Universal_String ("t1"),
League.Strings.To_Universal_String ("T1"));
NT3 : constant Part := C.Create_Non_Terminal_Reference
(League.Strings.To_Universal_String ("nt3"),
League.Strings.To_Universal_String ("NT3"));
P2 : Production := C.Create_Production
(League.Strings.To_Universal_String ("P2"));
PL : Production_List := C.Create_Production_List;
begin
P2.Add (T1);
P2.Add (NT3);
PL.Add (P2);
C.Create_Non_Terminal (League.Strings.To_Universal_String ("NT2"), PL);
end;
declare
NT3 : constant Part := C.Create_Non_Terminal_Reference
(League.Strings.To_Universal_String ("nt3"),
League.Strings.To_Universal_String ("NT3"));
NT2 : constant Part := C.Create_Non_Terminal_Reference
(League.Strings.To_Universal_String ("nt2"),
League.Strings.To_Universal_String ("NT2"));
T3 : constant Part := C.Create_Terminal_Reference
(League.Strings.To_Universal_String ("t3"),
League.Strings.To_Universal_String ("T3"));
P1 : Production := C.Create_Production
(League.Strings.To_Universal_String ("P1"));
PL : Production_List := C.Create_Production_List;
begin
P1.Add (NT3);
P1.Add (NT2);
P1.Add (T3);
PL.Add (P1);
C.Create_Non_Terminal (League.Strings.To_Universal_String ("NT1"), PL);
end;
declare
T2 : constant Part := C.Create_Terminal_Reference
(League.Strings.To_Universal_String ("t2"),
League.Strings.To_Universal_String ("T2"));
NT1 : constant Part := C.Create_Non_Terminal_Reference
(League.Strings.To_Universal_String ("nt1"),
League.Strings.To_Universal_String ("NT1"));
P3 : Production := C.Create_Production
(League.Strings.To_Universal_String ("P3"));
PL : Production_List := C.Create_Production_List;
begin
P3.Add (T2);
P3.Add (NT1);
PL.Add (P3);
C.Create_Non_Terminal (League.Strings.To_Universal_String ("NT3"), PL);
end;
declare
Result : constant Anagram.Grammars.Grammar := C.Complete;
begin
Anagram.Grammars_Debug.Print (Result);
end;
end TS_00002;
|
stcarrez/babel | Ada | 3,562 | adb | -----------------------------------------------------------------------
-- babel-streams-cached -- Cached stream management
-- Copyright (C) 2014, 2015 Stephane.Carrez
-- Written by Stephane.Carrez ([email protected])
--
-- Licensed under the Apache License, Version 2.0 (the "License");
-- you may not use this file except in compliance with the License.
-- You may obtain a copy of the License at
--
-- http://www.apache.org/licenses/LICENSE-2.0
--
-- Unless required by applicable law or agreed to in writing, software
-- distributed under the License is distributed on an "AS IS" BASIS,
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-- See the License for the specific language governing permissions and
-- limitations under the License.
-----------------------------------------------------------------------
package body Babel.Streams.Cached is
package BAV renames Babel.Files.Buffers.Buffer_Access_Vectors;
-- ------------------------------
-- Load the file stream into the cache and use the buffer pool to obtain more buffers
-- for the cache.
-- ------------------------------
procedure Load (Stream : in out Stream_Type;
File : in out Babel.Streams.Stream_Type'Class;
Pool : in out Babel.Files.Buffers.Buffer_Pool) is
use type Babel.Files.Buffers.Buffer_Access;
Buffer : Babel.Files.Buffers.Buffer_Access;
begin
loop
File.Read (Buffer);
exit when Buffer = null;
Stream.Buffers.Append (Buffer);
Pool.Get_Buffer (Buffer);
File.Set_Buffer (Buffer);
end loop;
Stream.Current := Stream.Buffers.First;
end Load;
-- ------------------------------
-- Read the data stream as much as possible and return the result in a buffer.
-- The buffer is owned by the stream and need not be released. The same buffer may
-- or may not be returned by the next <tt>Read</tt> operation.
-- A null buffer is returned when the end of the data stream is reached.
-- ------------------------------
overriding
procedure Read (Stream : in out Stream_Type;
Buffer : out Babel.Files.Buffers.Buffer_Access) is
begin
if BAV.Has_Element (Stream.Current) then
Buffer := BAV.Element (Stream.Current);
BAV.Next (Stream.Current);
else
Buffer := null;
end if;
end Read;
-- ------------------------------
-- Write the buffer in the data stream.
-- ------------------------------
overriding
procedure Write (Stream : in out Stream_Type;
Buffer : in Babel.Files.Buffers.Buffer_Access) is
begin
null;
end Write;
-- ------------------------------
-- Prepare to read again the data stream from the beginning.
-- ------------------------------
overriding
procedure Rewind (Stream : in out Stream_Type) is
begin
Stream.Current := Stream.Buffers.First;
end Rewind;
-- ------------------------------
-- Release the buffers associated with the cache.
-- ------------------------------
overriding
procedure Finalize (Stream : in out Stream_Type) is
Buffer : Babel.Files.Buffers.Buffer_Access;
begin
while not Stream.Buffers.Is_Empty loop
Buffer := Stream.Buffers.Last_Element;
Babel.Files.Buffers.Release (Buffer);
Stream.Buffers.Delete_Last;
end loop;
Babel.Streams.Stream_Type (Stream).Finalize;
end Finalize;
end Babel.Streams.Cached;
|
RREE/ada-util | Ada | 1,612 | ads | -----------------------------------------------------------------------
-- streams.buffered.tests -- Unit tests for buffered streams
-- Copyright (C) 2010, 2011, 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 Util.Tests;
package Util.Streams.Buffered.Tests is
procedure Add_Tests (Suite : in Util.Tests.Access_Test_Suite);
type Test is new Util.Tests.Test with null record;
procedure Test_Read_Write (T : in out Test);
procedure Test_Write (T : in out Test);
-- procedure Test_Read_File_Missing (T : in out Test);
-- procedure Test_Read_File_Truncate (T : in out Test);
-- procedure Test_Write_File (T : in out Test);
-- procedure Test_Find_File_Path (T : in out Test);
-- Write on a buffer and force regular flush on a larger buffer
procedure Test_Write_Stream (T : in out Test);
-- Test reading UTF-8 file.
procedure Test_Read_UTF_8 (T : in out Test);
end Util.Streams.Buffered.Tests;
|
persan/A-gst | Ada | 10,643 | ads | pragma Ada_2005;
pragma Style_Checks (Off);
pragma Warnings (Off);
with Interfaces.C; use Interfaces.C;
with glib;
with glib.Values;
with System;
with GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstelement_h;
with GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstpad_h;
-- with GStreamer.GST_Low_Level.glib_2_0_glib_deprecated_gthread_h;
-- limited -- with GStreamer.GST_Low_Level.glib_2_0_glib_gthread_h;
-- limited with GStreamer.GST_Low_Level.glib_2_0_glib_gqueue_h;
with GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstsegment_h;
with System;
limited with GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstcaps_h;
limited with GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstbuffer_h;
with GLIB; -- with GStreamer.GST_Low_Level.glibconfig_h;
limited with GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstevent_h;
with glib;
package GStreamer.GST_Low_Level.gstreamer_0_10_gst_rtp_gstbasertpdepayload_h is
-- unsupported macro: GST_TYPE_BASE_RTP_DEPAYLOAD (gst_base_rtp_depayload_get_type())
-- arg-macro: function GST_BASE_RTP_DEPAYLOAD (obj)
-- return G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_BASE_RTP_DEPAYLOAD,GstBaseRTPDepayload);
-- arg-macro: function GST_BASE_RTP_DEPAYLOAD_CLASS (klass)
-- return G_TYPE_CHECK_CLASS_CAST((klass),GST_TYPE_BASE_RTP_DEPAYLOAD,GstBaseRTPDepayloadClass);
-- arg-macro: function GST_BASE_RTP_DEPAYLOAD_GET_CLASS (obj)
-- return G_TYPE_INSTANCE_GET_CLASS ((obj),GST_TYPE_BASE_RTP_DEPAYLOAD,GstBaseRTPDepayloadClass);
-- arg-macro: function GST_IS_BASE_RTP_DEPAYLOAD (obj)
-- return G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_BASE_RTP_DEPAYLOAD);
-- arg-macro: function GST_IS_BASE_RTP_DEPAYLOAD_CLASS (klass)
-- return G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_BASE_RTP_DEPAYLOAD);
-- arg-macro: function GST_BASE_RTP_DEPAYLOAD_SINKPAD (depayload)
-- return GST_BASE_RTP_DEPAYLOAD (depayload).sinkpad;
-- arg-macro: function GST_BASE_RTP_DEPAYLOAD_SRCPAD (depayload)
-- return GST_BASE_RTP_DEPAYLOAD (depayload).srcpad;
-- arg-macro: function QUEUE_LOCK_INIT (base)
-- return g_static_rec_mutex_init(andbase.queuelock);
-- arg-macro: function QUEUE_LOCK_FREE (base)
-- return g_static_rec_mutex_free(andbase.queuelock);
-- arg-macro: function QUEUE_LOCK (base)
-- return g_static_rec_mutex_lock(andbase.queuelock);
-- arg-macro: function QUEUE_UNLOCK (base)
-- return g_static_rec_mutex_unlock(andbase.queuelock);
-- GStreamer
-- * Copyright (C) <2005> Philippe Khalaf <[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.
--
-- this was presumably never meant to be public API, or should at least
-- * have been prefixed if it was. Don't use. (FIXME: remove in 0.11)
type GstBaseRTPDepayload;
type u_GstBaseRTPDepayload_u_gst_reserved_array is array (0 .. 2) of System.Address;
--subtype GstBaseRTPDepayload is u_GstBaseRTPDepayload; -- gst/rtp/gstbasertpdepayload.h:52
type GstBaseRTPDepayloadClass;
type u_GstBaseRTPDepayloadClass_u_gst_reserved_array is array (0 .. 1) of System.Address;
--subtype GstBaseRTPDepayloadClass is u_GstBaseRTPDepayloadClass; -- gst/rtp/gstbasertpdepayload.h:53
-- skipped empty struct u_GstBaseRTPDepayloadPrivate
-- skipped empty struct GstBaseRTPDepayloadPrivate
type GstBaseRTPDepayload is record
parent : aliased GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstelement_h.GstElement; -- gst/rtp/gstbasertpdepayload.h:58
sinkpad : access GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstpad_h.GstPad; -- gst/rtp/gstbasertpdepayload.h:60
srcpad : access GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstpad_h.GstPad; -- gst/rtp/gstbasertpdepayload.h:60
queuelock : aliased GStreamer.GST_Low_Level.glib_2_0_glib_deprecated_gthread_h.GStaticRecMutex; -- gst/rtp/gstbasertpdepayload.h:64
thread_running : aliased GLIB.gboolean; -- gst/rtp/gstbasertpdepayload.h:67
thread : access GStreamer.GST_Low_Level.glib_2_0_glib_gthread_h.GThread; -- gst/rtp/gstbasertpdepayload.h:69
clock_rate : aliased GLIB.guint; -- gst/rtp/gstbasertpdepayload.h:73
queue_delay : aliased GLIB.guint; -- gst/rtp/gstbasertpdepayload.h:77
queue : access GStreamer.GST_Low_Level.glib_2_0_glib_gqueue_h.GQueue; -- gst/rtp/gstbasertpdepayload.h:84
segment : aliased GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstsegment_h.GstSegment; -- gst/rtp/gstbasertpdepayload.h:86
need_newsegment : aliased GLIB.gboolean; -- gst/rtp/gstbasertpdepayload.h:87
priv : System.Address; -- gst/rtp/gstbasertpdepayload.h:90
u_gst_reserved : u_GstBaseRTPDepayload_u_gst_reserved_array; -- gst/rtp/gstbasertpdepayload.h:92
end record;
pragma Convention (C_Pass_By_Copy, GstBaseRTPDepayload); -- gst/rtp/gstbasertpdepayload.h:56
-- lock to protect the queue, deprecated
-- deprecated
-- the releaser thread, deprecated
-- this attribute must be set by the child
-- this value can be modified by the child if needed, deprecated
-- we will queue up to RTP_QUEUEDELAY ms of packets,
-- * reordering them if necessary
-- * dropping any packets that are more than
-- * RTP_QUEUEDELAY ms late, deprecated
--< private >
--*
-- * GstBaseRTPDepayloadClass:
-- * @parent_class: the parent class
-- * @set_caps: configure the depayloader
-- * @add_to_queue: (deprecated)
-- * @process: process incoming rtp packets
-- * @set_gst_timestamp: convert from RTP timestamp to GST timestamp
-- * @packet_lost: signal the depayloader about packet loss
-- * @handle_event: custom event handling
-- *
-- * Base class for audio RTP payloader.
--
type GstBaseRTPDepayloadClass is record
parent_class : aliased GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstelement_h.GstElementClass; -- gst/rtp/gstbasertpdepayload.h:109
set_caps : access function (arg1 : access GstBaseRTPDepayload; arg2 : access GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstcaps_h.GstCaps) return GLIB.gboolean; -- gst/rtp/gstbasertpdepayload.h:112
add_to_queue : access function (arg1 : access GstBaseRTPDepayload; arg2 : access GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstbuffer_h.GstBuffer) return GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstpad_h.GstFlowReturn; -- gst/rtp/gstbasertpdepayload.h:116
process : access function (arg1 : access GstBaseRTPDepayload; arg2 : access GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstbuffer_h.GstBuffer) return access GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstbuffer_h.GstBuffer; -- gst/rtp/gstbasertpdepayload.h:123
set_gst_timestamp : access procedure
(arg1 : access GstBaseRTPDepayload;
arg2 : GLIB.guint32;
arg3 : access GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstbuffer_h.GstBuffer); -- gst/rtp/gstbasertpdepayload.h:127
packet_lost : access function (arg1 : access GstBaseRTPDepayload; arg2 : access GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstevent_h.GstEvent) return GLIB.gboolean; -- gst/rtp/gstbasertpdepayload.h:132
handle_event : access function (arg1 : access GstBaseRTPDepayload; arg2 : access GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstevent_h.GstEvent) return GLIB.gboolean; -- gst/rtp/gstbasertpdepayload.h:137
u_gst_reserved : u_GstBaseRTPDepayloadClass_u_gst_reserved_array; -- gst/rtp/gstbasertpdepayload.h:140
end record;
pragma Convention (C_Pass_By_Copy, GstBaseRTPDepayloadClass); -- gst/rtp/gstbasertpdepayload.h:107
-- virtuals, inform the subclass of the caps.
-- non-pure function, default implementation in base class
-- * this does buffering, reordering and dropping, deprecated
-- pure virtual function, child must use this to process incoming
-- * rtp packets. If the child returns a buffer without a valid timestamp,
-- * the timestamp of @in will be applied to the result buffer and the
-- * buffer will be pushed. If this function returns %NULL, nothing is
-- * pushed.
-- non-pure function used to convert from RTP timestamp to GST timestamp
-- * this function is used by the child class before gst_pad_pushing
-- non-pure function used to to signal the depayloader about packet loss. the
-- * timestamp and duration are the estimated values of the lost packet.
-- * The default implementation of this message pushes a segment update.
-- the default implementation does the default actions for events but
-- * implementation can override.
-- * Since: 0.10.32
--< private >
function gst_base_rtp_depayload_get_type return GLIB.GType; -- gst/rtp/gstbasertpdepayload.h:143
pragma Import (C, gst_base_rtp_depayload_get_type, "gst_base_rtp_depayload_get_type");
function gst_base_rtp_depayload_push (filter : access GstBaseRTPDepayload; out_buf : access GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstbuffer_h.GstBuffer) return GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstpad_h.GstFlowReturn; -- gst/rtp/gstbasertpdepayload.h:145
pragma Import (C, gst_base_rtp_depayload_push, "gst_base_rtp_depayload_push");
function gst_base_rtp_depayload_push_ts
(filter : access GstBaseRTPDepayload;
timestamp : GLIB.guint32;
out_buf : access GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstbuffer_h.GstBuffer) return GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstpad_h.GstFlowReturn; -- gst/rtp/gstbasertpdepayload.h:146
pragma Import (C, gst_base_rtp_depayload_push_ts, "gst_base_rtp_depayload_push_ts");
function gst_base_rtp_depayload_push_list (filter : access GstBaseRTPDepayload; out_list : System.Address) return GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstpad_h.GstFlowReturn; -- gst/rtp/gstbasertpdepayload.h:148
pragma Import (C, gst_base_rtp_depayload_push_list, "gst_base_rtp_depayload_push_list");
end GStreamer.GST_Low_Level.gstreamer_0_10_gst_rtp_gstbasertpdepayload_h;
|
AdaDoom3/wayland_ada_binding | Ada | 2,397 | adb | ------------------------------------------------------------------------------
-- Copyright (C) 2016, 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 MERCHAN- --
-- TABILITY or FITNESS FOR A PARTICULAR PURPOSE. --
-- --
-- As a special exception under Section 7 of GPL version 3, you are granted --
-- additional permissions described in the GCC Runtime Library Exception, --
-- version 3.1, as published by the Free Software Foundation. --
-- --
-- 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.Containers; use Ada.Containers;
package body Conts.Maps is
------------------------
-- Initialize_Probing --
------------------------
overriding procedure Initialize_Probing
(Self : in out Perturbation_Probing;
Hash : Hash_Type;
Size : Hash_Type)
is
pragma Unreferenced (Size);
begin
Self.Pertub := Hash;
end Initialize_Probing;
------------------
-- Next_Probing --
------------------
overriding function Next_Probing
(Self : in out Perturbation_Probing;
Previous : Hash_Type) return Hash_Type
is
Candidate : constant Hash_Type :=
Previous * 4 + Previous + 1 + Self.Pertub;
begin
Self.Pertub := Self.Pertub / (2 ** 5);
return Candidate;
end Next_Probing;
end Conts.Maps;
|
charlie5/cBound | Ada | 1,917 | ads | -- This file is generated by SWIG. Please do *not* modify by hand.
--
with swig;
with interfaces.C;
package speech_tools_c
is
-- EST_Wave
--
subtype EST_Wave is swig.incomplete_class;
type EST_Wave_array is array (interfaces.C.Size_t range <>) of aliased speech_tools_c.EST_Wave;
-- EST_String
--
subtype EST_String is swig.incomplete_class;
type EST_String_array is array (interfaces.C.Size_t range <>) of aliased speech_tools_c.EST_String;
-- EST_Item_featfunc
--
subtype EST_Item_featfunc is swig.incomplete_class;
type EST_Item_featfunc_array is array (interfaces.C.Size_t range <>) of aliased speech_tools_c.EST_Item_featfunc;
-- EST_Item
--
subtype EST_Item is swig.incomplete_class;
type EST_Item_array is array (interfaces.C.Size_t range <>) of aliased speech_tools_c.EST_Item;
-- EST_Val
--
subtype EST_Val is swig.incomplete_class;
type EST_Val_array is array (interfaces.C.Size_t range <>) of aliased speech_tools_c.EST_Val;
-- LISP
--
subtype LISP is swig.incomplete_class;
type LISP_array is array (interfaces.C.Size_t range <>) of aliased speech_tools_c.LISP;
-- EST_Ngrammar
--
subtype EST_Ngrammar is swig.incomplete_class;
type EST_Ngrammar_array is array (interfaces.C.Size_t range <>) of aliased speech_tools_c.EST_Ngrammar;
-- EST_WFST
--
subtype EST_WFST is swig.incomplete_class;
type EST_WFST_array is array (interfaces.C.Size_t range <>) of aliased speech_tools_c.EST_WFST;
-- EST_Utterance
--
subtype EST_Utterance is swig.incomplete_class;
type EST_Utterance_array is array (interfaces.C.Size_t range <>) of aliased speech_tools_c.EST_Utterance;
-- UnitDatabase
--
subtype UnitDatabase is swig.incomplete_class;
type UnitDatabase_array is array (interfaces.C.Size_t range <>) of aliased speech_tools_c.UnitDatabase;
end speech_tools_c;
|
docandrew/troodon | Ada | 36,506 | adb | -- Steps for decoding a JPEG image
--
-- 1. Huffman decompression
-- 2. Inverse quantization
-- 3. Inverse cosine transform
-- 4. Upsampling
-- 5. Color transformation
-- 6. Image reconstruction
--
-- The JPEG decoder is largely inspired
-- by the NanoJPEG code by Martin J. Fiedler.
-- With the author's permission. Many thanks!
--
-- Other informations:
-- http://en.wikipedia.org/wiki/JPEG
-- !! ** Some optimizations to consider **
-- !! ssx, ssy ,ssxmax, ssymax
-- as generic parameters + specialized instances
-- !! consider only power-of-two upsampling factors ?
-- !! simplify upsampling loops in case of power-of-two upsampling factors
-- using Shift_Right
-- !! Col_IDCT output direct to "flat", or something similar to NanoJPEG
with GID.Buffering;
with Ada.Text_IO, Ada.Integer_Text_IO, Ada.IO_Exceptions;
package body GID.Decoding_JPG is
use GID.Buffering;
use Ada.Text_IO;
generic
type Number is mod <>;
procedure Big_endian_number(
from : in out Input_buffer;
n : out Number
);
pragma Inline(Big_endian_number);
procedure Big_endian_number(
from : in out Input_buffer;
n : out Number
)
is
b: U8;
begin
n:= 0;
for i in 1..Number'Size/8 loop
Get_Byte(from, b);
n:= n * 256 + Number(b);
end loop;
end Big_endian_number;
procedure Big_endian is new Big_endian_number( U16 );
procedure Read( image: in out Image_descriptor; sh: out Segment_head) is
b: U8;
id: constant array(JPEG_marker) of U8:=
( SOI => 16#D8#,
--
SOF_0 => 16#C0#, SOF_1 => 16#C1#, SOF_2 => 16#C2#, SOF_3 => 16#C3#,
SOF_5 => 16#C5#, SOF_6 => 16#C6#, SOF_7 => 16#C7#, SOF_8 => 16#C8#,
SOF_9 => 16#C9#, SOF_10 => 16#CA#, SOF_11 => 16#CB#, SOF_13 => 16#CD#,
SOF_14 => 16#CE#, SOF_15 => 16#CF#,
--
DHT => 16#C4#,
DAC => 16#CC#,
DQT => 16#DB#,
DRI => 16#DD#,
--
APP_0 => 16#E0#, APP_1 => 16#E1#, APP_2 => 16#E2#, APP_3 => 16#E3#,
APP_4 => 16#E4#, APP_5 => 16#E5#, APP_6 => 16#E6#, APP_7 => 16#E7#,
APP_8 => 16#E8#, APP_9 => 16#E9#, APP_10 => 16#EA#, APP_11 => 16#EB#,
APP_12 => 16#EC#, APP_13 => 16#ED#, APP_14 => 16#EE#,
--
COM => 16#FE#,
SOS => 16#DA#,
EOI => 16#D9#
);
begin
Get_Byte(image.buffer, b);
if b /= 16#FF# then
raise error_in_image_data with "JPEG: expected marker here";
end if;
Get_Byte(image.buffer, b);
for m in id'Range loop
if id(m)= b then
sh.kind:= m;
Big_endian(image.buffer, sh.length);
sh.length:= sh.length - 2;
-- We consider length of contents, without the FFxx marker.
if some_trace then
Put_Line(
"Segment [" & JPEG_marker'Image(sh.kind) &
"], length:" & U16'Image(sh.length));
end if;
return;
end if;
end loop;
raise error_in_image_data with "JPEG: unknown marker here: FF, " & U8'Image(b);
end Read;
shift_arg: constant array(0..15) of Integer:=
(1 => 0, 2 => 1, 4 => 2, 8 => 3, others => -1);
-- SOF - Start Of Frame (the real header)
procedure Read_SOF(image: in out Image_descriptor; sh: Segment_head) is
use Bounded_255;
b, bits_pp_primary, id_base: U8;
w, h: U16;
compo: JPEG_defs.Component;
begin
case sh.kind is
when SOF_0 =>
image.detailed_format:= To_Bounded_String("JPEG, Baseline DCT (SOF_0)");
when SOF_2 =>
image.detailed_format:= To_Bounded_String("JPEG, Progressive DCT (SOF_2)");
image.interlaced:= True;
when others =>
raise unsupported_image_subformat with
"JPEG: image type not yet supported: " & JPEG_marker'Image(sh.kind);
end case;
Get_Byte(image.buffer, bits_pp_primary);
if bits_pp_primary /= 8 then
raise unsupported_image_subformat with
"JPEG: bits per primary color=" & U8'Image(bits_pp_primary) & " (not supported)";
end if;
image.bits_per_pixel:= 3 * Positive(bits_pp_primary);
Big_endian(image.buffer, h);
Big_endian(image.buffer, w);
if w = 0 then
raise error_in_image_data with "JPEG: zero image width";
end if;
if h = 0 then
raise error_in_image_data with "JPEG: zero image height";
end if;
image.width := Positive_32 (w);
image.height := Positive_32 (h);
-- Number of components:
Get_Byte(image.buffer, b);
image.subformat_id:= Integer(b);
--
image.JPEG_stuff.max_samples_hor:= 0;
image.JPEG_stuff.max_samples_ver:= 0;
id_base := 1;
-- For each component: 3 bytes information: ID, sampling factors, quantization table number
for i in 1..image.subformat_id loop
-- Component ID (1 = Y, 2 = Cb, 3 = Cr, 4 = I, 5 = Q)
Get_Byte(image.buffer, b);
if b = 0 then
-- Workaround for a bug in some encoders, for instance Intel(R) JPEG Library,
-- version [2.0.18.50] as in some Photoshop versions : IDs are numbered 0, 1, 2.
id_base := 0;
end if;
if b - id_base > Component'Pos(Component'Last) then
raise error_in_image_data with "JPEG: SOF: invalid component ID: " & U8'Image(b);
end if;
compo:= JPEG_defs.Component'Val(b - id_base);
image.JPEG_stuff.components(compo):= True;
declare
stuff: JPEG_stuff_type renames image.JPEG_stuff;
info: JPEG_defs.Info_per_component_A renames stuff.info(compo);
begin
-- Sampling factors (bit 0-3 vert., 4-7 hor.)
Get_Byte(image.buffer, b);
info.samples_ver:= Natural(b mod 16);
info.samples_hor:= Natural(b / 16);
stuff.max_samples_hor:=
Integer'Max(stuff.max_samples_hor, info.samples_hor);
stuff.max_samples_ver:=
Integer'Max(stuff.max_samples_ver, info.samples_ver);
-- Quantization table number
Get_Byte(image.buffer, b);
info.qt_assoc:= Natural(b);
end;
end loop;
for c in Component loop
if image.JPEG_stuff.components(c) then
declare
stuff: JPEG_stuff_type renames image.JPEG_stuff;
info: JPEG_defs.Info_per_component_A renames stuff.info(c);
begin
info.up_factor_x:= stuff.max_samples_hor / info.samples_hor;
info.up_factor_y:= stuff.max_samples_ver / info.samples_ver;
info.shift_x:= shift_arg(info.up_factor_x);
info.shift_y:= shift_arg(info.up_factor_y);
end;
end if;
end loop;
if Natural(sh.length) < 6 + 3 * image.subformat_id then
raise error_in_image_data with "JPEG: SOF segment too short";
end if;
if some_trace then
Put_Line("Frame has following components:");
for c in JPEG_defs.Component loop
Put_Line(
JPEG_defs.Component'Image(c) & " -> " &
Boolean'Image(image.JPEG_stuff.components(c))
);
end loop;
end if;
if image.JPEG_stuff.components = YCbCr_set then
image.JPEG_stuff.color_space:= YCbCr;
elsif image.JPEG_stuff.components = Y_Grey_set then
image.JPEG_stuff.color_space:= Y_Grey;
image.greyscale:= True;
elsif image.JPEG_stuff.components = CMYK_set then
image.JPEG_stuff.color_space:= CMYK;
else
raise unsupported_image_subformat with
"JPEG: only YCbCr, Y_Grey and CMYK color spaces are currently supported";
end if;
image.detailed_format:= image.detailed_format & ", " &
JPEG_defs.Supported_color_space'Image(image.JPEG_stuff.color_space);
if some_trace then
Put_Line(
"Color space: " &
JPEG_defs.Supported_color_space'Image(image.JPEG_stuff.color_space)
);
end if;
if image.JPEG_stuff.color_space = CMYK then
raise unsupported_image_subformat with
"JPEG: CMYK color space is currently not properly decoded";
end if;
end Read_SOF;
procedure Read_DHT(image: in out Image_descriptor; data_length: Natural) is
remaining: Integer_M32:= Integer_M32(data_length); -- data remaining in segment
b: U8;
ht_idx: Natural;
kind: AC_DC;
counts: array(1..16) of Integer_M32;
idx: Natural;
currcnt, spread, remain_vlc: Integer_M32;
begin
multi_tables:
loop
Get_Byte(image.buffer, b);
remaining:= remaining - 1;
if b >= 8 then
kind:= AC;
else
kind:= DC;
end if;
ht_idx:= Natural(b and 7);
if some_trace then
Put_Line(
"Huffman Table (HT) #" &
Natural'Image(ht_idx) & ", " & AC_DC'Image(kind)
);
end if;
if image.JPEG_stuff.vlc_defs(kind, ht_idx) = null then
image.JPEG_stuff.vlc_defs(kind, ht_idx):= new VLC_table;
end if;
for i in counts'Range loop
Get_Byte(image.buffer, b);
remaining:= remaining - 1;
counts(i):= Integer_M32(b);
end loop;
remain_vlc:= 65_536;
spread:= 65_536;
idx:= 0;
for codelen in counts'Range loop
spread:= spread / 2;
currcnt:= counts(codelen);
if currcnt > 0 then
if remaining < currcnt then
raise error_in_image_data with "JPEG: DHT data too short";
end if;
remain_vlc:= remain_vlc - currcnt * spread;
if remain_vlc < 0 then
raise error_in_image_data with "JPEG: DHT table too short for data";
end if;
for i in reverse 1..currcnt loop
Get_Byte(image.buffer, b);
for j in reverse 1..spread loop
image.JPEG_stuff.vlc_defs(kind, ht_idx)(idx):=
(bits => U8(codelen), code => b);
idx:= idx + 1;
end loop;
end loop;
remaining:= remaining - currcnt;
end if;
end loop;
while remain_vlc > 0 loop
remain_vlc:= remain_vlc - 1;
image.JPEG_stuff.vlc_defs(kind, ht_idx)(idx).bits:= 0;
idx:= idx + 1;
end loop;
exit multi_tables when remaining <= 0;
end loop multi_tables;
end Read_DHT;
procedure Read_DQT(image: in out Image_descriptor; data_length: Natural) is
remaining: Integer:= data_length; -- data remaining in segment
b, q8: U8; q16: U16;
qt_idx: Natural;
high_prec: Boolean;
begin
multi_tables:
loop
Get_Byte(image.buffer, b);
remaining:= remaining - 1;
high_prec:= b >= 8;
qt_idx:= Natural(b and 7);
if some_trace then
Put_Line("Quantization Table (QT) #" & U8'Image(b));
end if;
for i in QT'Range loop
if high_prec then
Big_endian(image.buffer, q16);
remaining:= remaining - 2;
image.JPEG_stuff.qt_list(qt_idx)(i):= Natural(q16);
else
Get_Byte(image.buffer, q8);
remaining:= remaining - 1;
image.JPEG_stuff.qt_list(qt_idx)(i):= Natural(q8);
end if;
end loop;
exit multi_tables when remaining <= 0;
end loop multi_tables;
end Read_DQT;
procedure Read_DRI(image: in out Image_descriptor) is
ri: U16;
begin
Big_endian(image.buffer, ri);
if some_trace then
Put_Line(" Restart interval set to:" & U16'Image(ri));
end if;
image.JPEG_stuff.restart_interval:= Natural(ri);
end Read_DRI;
procedure Read_EXIF(image: in out Image_descriptor; data_length: Natural) is
b, orientation_value: U8;
x, ifd0_entries: Natural;
Exif_signature: constant String:= "Exif" & ASCII.NUL & ASCII.NUL;
signature: String(1..6);
IFD_tag: U16;
endianness: Character;
-- 'M' (Motorola) or 'I' (Intel): EXIF chunks may have different endiannesses,
-- even though the whole JPEG format has a fixed endianness!
begin
if some_trace then
Put_Line("APP1");
end if;
if data_length < 6 then
-- Skip segment data
for i in 1..data_length loop
Get_Byte(image.buffer, b);
end loop;
else
for i in 1..6 loop
Get_Byte(image.buffer, b);
signature(i):= Character'Val(b);
end loop;
if signature /= Exif_signature then
for i in 7..data_length loop -- Skip remaining of APP1 data
Get_Byte(image.buffer, b); -- since we don't know how to use it.
end loop;
if some_trace then
Put_Line("APP1 is not Exif");
end if;
return;
end if;
Get_Byte(image.buffer, b); -- TIFF 6.0 header (1st of 8 bytes)
endianness:= Character'Val(b);
if some_trace then
Put_Line("APP1 is Exif; endianness is " & endianness);
end if;
for i in 8..14 loop -- TIFF 6.0 header (2-8 of 8 bytes)
Get_Byte(image.buffer, b);
end loop;
-- Number of IFD0 entries (2 bytes)
ifd0_entries:= 0;
Get_Byte(image.buffer, b);
ifd0_entries:= Natural(b);
Get_Byte(image.buffer, b);
if endianness = 'I' then
ifd0_entries:= ifd0_entries + 16#100# * Natural(b);
else
ifd0_entries:= Natural(b) + 16#100# * ifd0_entries;
end if;
if some_trace then
Put_Line("EXIF's IFD0 has" & Natural'Image(ifd0_entries) & " entries.");
end if;
x:= 17;
while x <= data_length - 12 loop
Get_Byte(image.buffer, b);
IFD_tag:= U16(b);
Get_Byte(image.buffer, b);
if endianness = 'I' then
IFD_tag:= IFD_tag + 16#100# * U16(b);
else
IFD_tag:= U16(b) + 16#100# * IFD_tag;
end if;
if some_trace then
Put("IFD tag:"); Ada.Integer_Text_IO.Put(Natural(IFD_tag), Base => 16); New_Line;
end if;
for i in 3..8 loop
Get_Byte(image.buffer, b);
end loop;
if endianness = 'I' then
Get_Byte(image.buffer, orientation_value);
for i in 10..12 loop
Get_Byte(image.buffer, b);
end loop;
else
Get_Byte(image.buffer, b);
Get_Byte(image.buffer, orientation_value);
Get_Byte(image.buffer, b);
Get_Byte(image.buffer, b);
end if;
x:= x + 12;
if IFD_tag = 16#112# then
case orientation_value is
when 1 =>
image.display_orientation:= Unchanged;
when 8 =>
image.display_orientation:= Rotation_90;
when 3 =>
image.display_orientation:= Rotation_180;
when 6 =>
image.display_orientation:= Rotation_270;
when others =>
image.display_orientation:= Unchanged;
end case;
if some_trace then
Put_Line(
"IFD tag 0112: Orientation set to: " &
Orientation'Image(image.display_orientation)
);
end if;
exit;
end if;
end loop;
-- Skip rest of data
for i in x..data_length loop
Get_Byte(image.buffer, b);
end loop;
end if;
end Read_EXIF;
--------------------
-- Image decoding --
--------------------
procedure Load (
image : in out Image_descriptor;
next_frame: out Ada.Calendar.Day_Duration
)
is
--
-- Bit buffer
--
buf: U32:= 0;
bufbits: Natural:= 0;
function Show_bits(bits: Natural) return Natural is
newbyte, marker: U8;
begin
if bits=0 then
return 0;
end if;
while bufbits < bits loop
begin
Get_Byte(image.buffer, newbyte);
bufbits:= bufbits + 8;
buf:= buf * 256 + U32(newbyte);
if newbyte = 16#FF# then
Get_Byte(image.buffer, marker);
case marker is
when 0 =>
null;
when 16#D8# => -- SOI here ?
null;
-- 2015-04-26: occured in one (of many) picture
-- taken by an Olympus VG120,D705. See test/img/bcase_1.jpg
when 16#D9# => -- EOI here ?
null; -- !! signal end
when 16#D0# .. 16#D7# =>
bufbits:= bufbits + 8;
buf:= buf * 256 + U32(marker);
when others =>
raise error_in_image_data with
"JPEG: Invalid code (bit buffer): " & U8'Image(marker);
end case;
end if;
exception
when Ada.IO_Exceptions.End_Error =>
newbyte:= 16#FF#;
bufbits:= bufbits + 8;
buf:= buf * 256 + U32(newbyte);
end;
end loop;
return Natural(
Shift_Right(buf, bufbits - bits)
and
(Shift_Left(1, bits)-1)
);
end Show_bits;
procedure Skip_bits(bits: Natural) is
pragma Inline(Skip_bits);
dummy: Integer;
pragma Unreferenced (dummy);
begin
if bufbits < bits then
dummy:= Show_bits(bits);
end if;
bufbits:= bufbits - bits;
end Skip_bits;
function Get_bits(bits: Natural) return Integer is
pragma Inline(Get_bits);
res: constant Integer:= Show_bits(bits);
begin
Skip_bits(bits);
return res;
end Get_bits;
--
type Info_per_component_B is record
ht_idx_AC : Natural;
ht_idx_DC : Natural;
width, height, stride: Natural;
dcpred: Integer:= 0;
end record;
info_A: Component_info_A renames image.JPEG_stuff.info;
info_B: array(Component) of Info_per_component_B;
procedure Get_VLC(
vlc: VLC_table;
code: out U8;
value_ret: out Integer
)
is
-- Step 1 happens here: Huffman decompression
value: Integer:= Show_bits(16);
bits : Natural:= Natural(vlc(value).bits);
begin
if bits = 0 then
raise error_in_image_data with "JPEG: VLC table: bits = 0";
end if;
Skip_bits(bits);
value:= Integer(vlc(value).code);
code:= U8(value);
bits:= Natural(U32(value) and 15);
value_ret:= 0;
if bits /= 0 then
value:= Get_bits(bits);
if value < Integer(Shift_Left(U32'(1), bits - 1)) then
value:= value + 1 - Integer(Shift_Left(U32'(1), bits));
end if;
value_ret:= value;
end if;
end Get_VLC;
function Clip(x: Integer) return Integer is
pragma Inline(Clip);
begin
if x < 0 then
return 0;
elsif x > 255 then
return 255;
else
return x;
end if;
end Clip;
type Block_8x8 is array(0..63) of Integer;
-- Ordering within a 8x8 block, in zig-zag
zig_zag: constant Block_8x8:=
( 0, 1, 8, 16, 9, 2, 3, 10, 17, 24, 32, 25, 18,
11, 4, 5, 12, 19, 26, 33, 40, 48, 41, 34, 27, 20,
13, 6, 7, 14, 21, 28, 35, 42, 49, 56, 57, 50, 43,
36, 29, 22, 15, 23, 30, 37, 44, 51, 58, 59, 52, 45,
38, 31, 39, 46, 53, 60, 61, 54, 47, 55, 62, 63 );
procedure Decode_Block(c: Component; block: in out Block_8x8) is
value, coef: Integer;
code: U8;
qt_local: JPEG_defs.QT renames image.JPEG_stuff.qt_list(info_A(c).qt_assoc);
--
W1: constant:= 2841;
W2: constant:= 2676;
W3: constant:= 2408;
W5: constant:= 1609;
W6: constant:= 1108;
W7: constant:= 565;
--
procedure Row_IDCT(start: Integer) is
pragma Inline(Row_IDCT);
x0, x1, x2, x3, x4, x5, x6, x7, x8, val: Integer;
begin
x1:= block(start + 4) * 2**11;
x2:= block(start + 6);
x3:= block(start + 2);
x4:= block(start + 1);
x5:= block(start + 7);
x6:= block(start + 5);
x7:= block(start + 3);
if x1=0 and x2=0 and x3=0 and x4=0 and x5=0 and x6=0 and x7=0 then
val:= block(start + 0) * 8;
block(start + 0 .. start + 7):= (others => val);
else
x0:= (block(start + 0) * 2**11) + 128;
x8:= W7 * (x4 + x5);
x4:= x8 + (W1 - W7) * x4;
x5:= x8 - (W1 + W7) * x5;
x8:= W3 * (x6 + x7);
x6:= x8 - (W3 - W5) * x6;
x7:= x8 - (W3 + W5) * x7;
x8:= x0 + x1;
x0:= x0 - x1;
x1:= W6 * (x3 + x2);
x2:= x1 - (W2 + W6) * x2;
x3:= x1 + (W2 - W6) * x3;
x1:= x4 + x6;
x4:= x4 - x6;
x6:= x5 + x7;
x5:= x5 - x7;
x7:= x8 + x3;
x8:= x8 - x3;
x3:= x0 + x2;
x0:= x0 - x2;
x2:= (181 * (x4 + x5) + 128) / 256;
x4:= (181 * (x4 - x5) + 128) / 256;
block(start + 0):= (x7 + x1) / 256;
block(start + 1):= (x3 + x2) / 256;
block(start + 2):= (x0 + x4) / 256;
block(start + 3):= (x8 + x6) / 256;
block(start + 4):= (x8 - x6) / 256;
block(start + 5):= (x0 - x4) / 256;
block(start + 6):= (x3 - x2) / 256;
block(start + 7):= (x7 - x1) / 256;
end if;
end Row_IDCT;
procedure Col_IDCT(start: Integer) is
pragma Inline(Col_IDCT);
x0, x1, x2, x3, x4, x5, x6, x7, x8, val: Integer;
begin
x1:= block(start + 8*4) * 256;
x2:= block(start + 8*6);
x3:= block(start + 8*2);
x4:= block(start + 8*1);
x5:= block(start + 8*7);
x6:= block(start + 8*5);
x7:= block(start + 8*3);
if x1=0 and x2=0 and x3=0 and x4=0 and x5=0 and x6=0 and x7=0 then
val:= Clip(((block(start) + 32) / 2**6) + 128);
for row in reverse 0..7 loop
block(start + row * 8):= val;
end loop;
else
x0:= (block(start) * 256) + 8192;
x8:= W7 * (x4 + x5) + 4;
x4:= (x8 + (W1 - W7) * x4) / 8;
x5:= (x8 - (W1 + W7) * x5) / 8;
x8:= W3 * (x6 + x7) + 4;
x6:= (x8 - (W3 - W5) * x6) / 8;
x7:= (x8 - (W3 + W5) * x7) / 8;
x8:= x0 + x1;
x0:= x0 - x1;
x1:= W6 * (x3 + x2) + 4;
x2:= (x1 - (W2 + W6) * x2) / 8;
x3:= (x1 + (W2 - W6) * x3) / 8;
x1:= x4 + x6;
x4:= x4 - x6;
x6:= x5 + x7;
x5:= x5 - x7;
x7:= x8 + x3;
x8:= x8 - x3;
x3:= x0 + x2;
x0:= x0 - x2;
x2:= (181 * (x4 + x5) + 128) / 256;
x4:= (181 * (x4 - x5) + 128) / 256;
block(start + 8*0):= Clip(((x7 + x1) / 2**14) + 128);
block(start + 8*1):= Clip(((x3 + x2) / 2**14) + 128);
block(start + 8*2):= Clip(((x0 + x4) / 2**14) + 128);
block(start + 8*3):= Clip(((x8 + x6) / 2**14) + 128);
block(start + 8*4):= Clip(((x8 - x6) / 2**14) + 128);
block(start + 8*5):= Clip(((x0 - x4) / 2**14) + 128);
block(start + 8*6):= Clip(((x3 - x2) / 2**14) + 128);
block(start + 8*7):= Clip(((x7 - x1) / 2**14) + 128);
end if;
end Col_IDCT;
begin -- Decode_Block
--
-- Step 2 happens here: Inverse quantization
Get_VLC(image.JPEG_stuff.vlc_defs(DC, info_B(c).ht_idx_DC).all, code, value);
-- First value in block (0: top left) uses a predictor.
info_B(c).dcpred:= info_B(c).dcpred + value;
block:= (0 => info_B(c).dcpred * qt_local(0), others => 0);
coef:= 0;
loop
Get_VLC(image.JPEG_stuff.vlc_defs(AC, info_B(c).ht_idx_AC).all, code, value);
exit when code = 0; -- EOB
if (code and 16#0F#) = 0 and code /= 16#F0# then
raise error_in_image_data with "JPEG: error in VLC AC code for de-quantization";
end if;
coef:= coef + Integer(Shift_Right(code, 4)) + 1;
if coef > 63 then
raise error_in_image_data with "JPEG: coefficient for de-quantization is > 63";
end if;
block(zig_zag(coef)):= value * qt_local(coef);
exit when coef = 63;
end loop;
-- Step 3 happens here: Inverse cosine transform
for row in 0..7 loop
Row_IDCT(row * 8);
end loop;
for column in 0..7 loop
Col_IDCT(column);
end loop;
end Decode_Block;
type Macro_block is array(
Component range <>, -- component
Positive range <>, -- x sample range
Positive range <> -- y sample range
) of Block_8x8;
procedure Out_Pixel_8(br, bg, bb: U8) is
pragma Inline(Out_Pixel_8);
function Times_257(x: Primary_color_range) return Primary_color_range is
pragma Inline(Times_257);
begin
return 16 * (16 * x) + x; -- this is 257 * x, = 16#0101# * x
-- Numbers 8-bit -> no OA warning at instanciation. Returns x if type Primary_color_range is mod 2**8.
end Times_257;
full_opaque: constant Primary_color_range:= Primary_color_range'Last;
begin
case Primary_color_range'Modulus is
when 256 =>
Put_Pixel(
Primary_color_range(br),
Primary_color_range(bg),
Primary_color_range(bb),
full_opaque
);
when 65_536 =>
Put_Pixel(
Times_257(Primary_color_range(br)),
Times_257(Primary_color_range(bg)),
Times_257(Primary_color_range(bb)),
full_opaque
-- Times_257 makes max intensity FF go to FFFF
);
when others =>
raise invalid_primary_color_range with "JPEG: color range not supported";
end case;
end Out_Pixel_8;
-- !! might be generic parameters
ssxmax: constant Natural:= image.JPEG_stuff.max_samples_hor;
ssymax: constant Natural:= image.JPEG_stuff.max_samples_ver;
procedure Upsampling_and_output(
m: Macro_block;
x0, y0: Natural
)
is
flat: array(Component, 0..8*ssxmax-1, 0..8*ssymax-1) of Integer;
generic
color_space: Supported_color_space;
procedure Color_transformation_and_output;
--
procedure Color_transformation_and_output is
y_val, cb_val, cr_val, c_val, m_val, w_val: Integer;
y_val_8: U8;
begin
for ymb in flat'Range(3) loop
exit when y0+ymb >= Integer (image.height);
Set_X_Y(x0, Integer (image.height) - 1 - (y0+ymb));
for xmb in flat'Range(2) loop
exit when x0+xmb >= Integer (image.width);
case color_space is
when YCbCr =>
y_val := flat(Y, xmb, ymb) * 256;
cb_val:= flat(Cb, xmb, ymb) - 128;
cr_val:= flat(Cr, xmb, ymb) - 128;
Out_Pixel_8(
br => U8(Clip((y_val + 359 * cr_val + 128) / 256)),
bg => U8(Clip((y_val - 88 * cb_val - 183 * cr_val + 128) / 256)),
bb => U8(Clip((y_val + 454 * cb_val + 128) / 256))
);
when Y_Grey =>
y_val_8:= U8(flat(Y, xmb, ymb));
Out_Pixel_8(y_val_8, y_val_8, y_val_8);
when CMYK =>
-- !! find a working conversion formula.
-- perhaps it is more complicated (APP_2
-- color profile must be used ?)
c_val:= flat(Y, xmb, ymb);
m_val:= flat(Cb, xmb, ymb);
y_val:= flat(Cr, xmb, ymb);
w_val:= flat(I, xmb, ymb)-255;
Out_Pixel_8(
br => U8(255-Clip(c_val+w_val)),
bg => U8(255-Clip(m_val+w_val)),
bb => U8(255-Clip(y_val+w_val))
);
end case;
end loop;
end loop;
end Color_transformation_and_output;
--
procedure Ct_YCbCr is new Color_transformation_and_output(YCbCr);
procedure Ct_Y_Grey is new Color_transformation_and_output(Y_Grey);
procedure Ct_CMYK is new Color_transformation_and_output(CMYK);
blk_idx: Integer;
upsx, upsy: Natural;
begin
-- Step 4 happens here: Upsampling
for c in Component loop
if image.JPEG_stuff.components(c) then
upsx:= info_A(c).up_factor_x;
upsy:= info_A(c).up_factor_y;
for x in reverse 1..info_A(c).samples_hor loop
for y in reverse 1..info_A(c).samples_ver loop
-- We are at the 8x8 block level
blk_idx:= 63;
for y8 in reverse 0..7 loop
for x8 in reverse 0..7 loop
declare
val: constant Integer:= m(c,x,y)(blk_idx);
big_pixel_x: constant Natural:= upsx * (x8 + 8*(x-1));
big_pixel_y: constant Natural:= upsy * (y8 + 8*(y-1));
begin
-- Repeat pixels for component c, sample (x,y),
-- position (x8,y8).
for rx in reverse 0..upsx-1 loop
for ry in reverse 0..upsy-1 loop
flat(c, rx + big_pixel_x, ry + big_pixel_y):= val;
end loop;
end loop;
end;
blk_idx:= blk_idx - 1;
end loop;
end loop;
end loop;
end loop;
end if;
end loop;
-- Step 5 and 6 happen here: Color transformation and output
case image.JPEG_stuff.color_space is
when YCbCr =>
Ct_YCbCr;
when Y_Grey =>
Ct_Y_Grey;
when CMYK =>
Ct_CMYK;
end case;
end Upsampling_and_output;
-- Start Of Scan (and image data which follow)
--
procedure Read_SOS is
components, b, id_base: U8;
compo: Component:= Component'First;
mbx, mby: Natural:= 0;
mbsizex, mbsizey, mbwidth, mbheight: Natural;
rstcount: Natural:= image.JPEG_stuff.restart_interval;
nextrst: U16:= 0;
w: U16;
start_spectral_selection,
end_spectral_selection,
successive_approximation: U8;
begin
Get_Byte(image.buffer, components);
if some_trace then
Put_Line(
"Start of Scan (SOS), with" & U8'Image(components) & " components"
);
end if;
if image.subformat_id /= Natural(components) then
raise error_in_image_data with "JPEG: components mismatch in Scan segment";
end if;
id_base := 1;
for i in 1..components loop
Get_Byte(image.buffer, b);
if b = 0 then
-- Workaround for bugged encoder (see above)
id_base := 0;
end if;
if b - id_base > Component'Pos(Component'Last) then
raise error_in_image_data with "JPEG: Scan: invalid ID: " & U8'Image(b);
end if;
compo:= Component'Val(b - id_base);
if not image.JPEG_stuff.components(compo) then
raise error_in_image_data with
"JPEG: component " & Component'Image(compo) &
" has not been defined in the header (SOF) segment";
end if;
-- Huffman table selection
Get_Byte(image.buffer, b);
info_B(compo).ht_idx_AC:= Natural(b mod 16);
info_B(compo).ht_idx_DC:= Natural(b / 16);
end loop;
-- Parameters for progressive display format (SOF_2)
Get_Byte(image.buffer, start_spectral_selection);
Get_Byte(image.buffer, end_spectral_selection);
Get_Byte(image.buffer, successive_approximation);
--
-- End of SOS segment, image data follow.
--
mbsizex:= ssxmax * 8; -- pixels in a row of a macro-block
mbsizey:= ssymax * 8; -- pixels in a column of a macro-block
mbwidth := (Integer (image.width) + mbsizex - 1) / mbsizex;
-- width in macro-blocks
mbheight := (Integer (image.height) + mbsizey - 1) / mbsizey;
-- height in macro-blocks
if some_trace then
Put_Line(" mbsizex = " & Integer'Image(mbsizex));
Put_Line(" mbsizey = " & Integer'Image(mbsizey));
Put_Line(" mbwidth = " & Integer'Image(mbwidth));
Put_Line(" mbheight = " & Integer'Image(mbheight));
end if;
for c in Component loop
if image.JPEG_stuff.components(c) then
info_B(c).width := (Integer (image.width) * info_A(c).samples_hor + ssxmax - 1) / ssxmax;
info_B(c).height:= (Integer (image.height) * info_A(c).samples_ver + ssymax - 1) / ssymax;
info_B(c).stride:= (mbwidth * mbsizex * info_A(c).samples_hor) / ssxmax;
if some_trace then
Put_Line(" Details for component " & Component'Image(c));
Put_Line(" samples in x " & Integer'Image(info_A(c).samples_hor));
Put_Line(" samples in y " & Integer'Image(info_A(c).samples_ver));
Put_Line(" width " & Integer'Image(info_B(c).width));
Put_Line(" height " & Integer'Image(info_B(c).height));
Put_Line(" stride " & Integer'Image(info_B(c).stride));
Put_Line(
" AC/DC table index " &
Integer'Image(info_B(compo).ht_idx_AC) & ", " &
Integer'Image(info_B(compo).ht_idx_DC)
);
end if;
if (info_B(c).width < 3 and info_A(c).samples_hor /= ssxmax) or
(info_B(c).height < 3 and info_A(c).samples_ver /= ssymax)
then
raise error_in_image_data with
"JPEG: component " & Component'Image(c) & ": sample dimension mismatch";
end if;
end if;
end loop;
--
if image.interlaced then
raise unsupported_image_subformat with "JPEG: progressive format not yet functional";
end if;
declare
mb: Macro_block(Component, 1..ssxmax, 1..ssymax);
x0, y0: Integer:= 0;
begin
macro_blocks_loop:
loop
components_loop:
for c in Component loop
if image.JPEG_stuff.components(c) then
samples_y_loop:
for sby in 1..info_A(c).samples_ver loop
samples_x_loop:
for sbx in 1..info_A(c).samples_hor loop
Decode_Block(c, mb(c, sbx, sby));
end loop samples_x_loop;
end loop samples_y_loop;
end if;
end loop components_loop;
-- All components of the current macro-block are decoded.
-- Step 4, 5, 6 happen here: Upsampling, color transformation, output
Upsampling_and_output(mb, x0, y0);
--
mbx:= mbx + 1;
x0:= x0 + ssxmax * 8;
if mbx >= mbwidth then
mbx:= 0;
x0:= 0;
mby:= mby + 1;
y0:= y0 + ssymax * 8;
Feedback((100*mby)/mbheight);
exit macro_blocks_loop when mby >= mbheight;
end if;
if image.JPEG_stuff.restart_interval > 0 then
rstcount:= rstcount - 1;
if rstcount = 0 then
-- Here begins the restart.
bufbits:= Natural(U32(bufbits) and 16#F8#); -- byte alignment
-- Now the restart marker. We expect a
w:= U16(Get_bits(16));
if some_trace then
Put_Line(
" Restart #" & U16'Image(nextrst) &
" Code " & U16'Image(w) &
" after" & Natural'Image(image.JPEG_stuff.restart_interval) &
" macro blocks"
);
end if;
if w not in 16#FFD0# .. 16#FFD7# or (w and 7) /= nextrst then
raise error_in_image_data with
"JPEG: expected RST (restart) marker Nb " & U16'Image(nextrst);
end if;
nextrst:= (nextrst + 1) and 7;
rstcount:= image.JPEG_stuff.restart_interval;
-- Block-to-block predictor variables are reset.
for c in Component loop
info_B(c).dcpred:= 0;
end loop;
end if;
end if;
end loop macro_blocks_loop;
end;
end Read_SOS;
--
sh: Segment_head;
b: U8;
begin -- Load
loop
Read(image, sh);
case sh.kind is
when DQT => -- Quantization Table
Read_DQT(image, Natural(sh.length));
when DHT => -- Huffman Table
Read_DHT(image, Natural(sh.length));
when DRI => -- Restart Interval
Read_DRI(image);
when EOI => -- End Of Input
exit;
when SOS => -- Start Of Scan
Read_SOS;
exit;
when others =>
-- Skip segment data
for i in 1..sh.length loop
Get_Byte(image.buffer, b);
end loop;
end case;
end loop;
next_frame:= 0.0; -- still picture
end Load;
end GID.Decoding_JPG;
|
stcarrez/ada-util | Ada | 2,051 | ads | -----------------------------------------------------------------------
-- util-tests-tokenizers -- Split texts into tokens
-- Copyright (C) 2012 Stephane Carrez
-- Written by Stephane Carrez ([email protected])
--
-- Licensed under the Apache License, Version 2.0 (the "License");
-- you may not use this file except in compliance with the License.
-- You may obtain a copy of the License at
--
-- http://www.apache.org/licenses/LICENSE-2.0
--
-- Unless required by applicable law or agreed to in writing, software
-- distributed under the License is distributed on an "AS IS" BASIS,
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-- See the License for the specific language governing permissions and
-- limitations under the License.
-----------------------------------------------------------------------
with Ada.Strings;
generic
type Char is (<>);
type Input is array (Positive range <>) of Char;
with function Index (Item : in Input;
Pattern : in Input;
From : in Positive;
Going : in Ada.Strings.Direction := Ada.Strings.Forward)
return Natural is <>;
package Util.Texts.Tokenizers is
pragma Preelaborate;
-- Iterate over the tokens of the <b>Content</b> input. Each token is separated by
-- a pattern represented by <b>Pattern</b>. For each token, call the
-- procedure <b>Process</b> with the token. When <b>Going</b> is <b>Backward</b>,
-- scan the input from the end. Stop iterating over the tokens when the <b>Process</b>
-- procedure returns True in <b>Done</b>.
procedure Iterate_Tokens (Content : in Input;
Pattern : in Input;
Process : access procedure (Token : in Input;
Done : out Boolean);
Going : in Ada.Strings.Direction := Ada.Strings.Forward);
end Util.Texts.Tokenizers;
|
stcarrez/ada-asf | Ada | 6,613 | adb | -----------------------------------------------------------------------
-- demo_server -- Demo server for Ada Server Faces
-- Copyright (C) 2010, 2011, 2012, 2013, 2015, 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 Ada.IO_Exceptions;
with ASF.Server.Web;
with ASF.Servlets;
with ASF.Servlets.Faces;
with Servlet.Core.Files;
with Servlet.Core.Measures;
with ASF.Filters.Dump;
with ASF.Beans;
with ASF.Applications;
with ASF.Applications.Main;
with ASF.Applications.Main.Configs;
with ASF.Security.Servlets;
with Util.Beans.Objects;
with Util.Log.Loggers;
with AWS.Net.SSL;
with Countries;
with Volume;
with Messages;
with Facebook;
with Users;
procedure Demo_Server is
CONTEXT_PATH : constant String := "/demo";
CONFIG_PATH : constant String := "samples.properties";
Log : constant Util.Log.Loggers.Logger := Util.Log.Loggers.Create ("Openid");
Factory : ASF.Applications.Main.Application_Factory;
C : ASF.Applications.Config;
-- Application servlets.
App : aliased ASF.Applications.Main.Application;
Faces : aliased ASF.Servlets.Faces.Faces_Servlet;
Files : aliased Servlet.Core.Files.File_Servlet;
Auth : aliased ASF.Security.Servlets.Request_Auth_Servlet;
Verify_Auth : aliased ASF.Security.Servlets.Verify_Auth_Servlet;
Perf : aliased Servlet.Core.Measures.Measure_Servlet;
-- Debug filters.
Dump : aliased ASF.Filters.Dump.Dump_Filter;
FB_Auth : aliased Facebook.Facebook_Auth;
Bean : aliased Volume.Compute_Bean;
Conv : aliased Volume.Float_Converter;
None : ASF.Beans.Parameter_Bean_Ref.Ref;
-- Web application server
WS : ASF.Server.Web.AWS_Container;
begin
if not AWS.Net.SSL.Is_Supported then
Log.Error ("SSL is not supported by AWS.");
Log.Error ("SSL is required for the OpenID connector to connect to OpenID providers.");
Log.Error ("Please, rebuild AWS with SSL support.");
end if;
C.Set (ASF.Applications.VIEW_EXT, ".html");
C.Set (ASF.Applications.VIEW_DIR, "samples/web");
C.Set ("web.dir", "samples/web");
begin
C.Load_Properties (CONFIG_PATH);
Util.Log.Loggers.Initialize (CONFIG_PATH);
exception
when Ada.IO_Exceptions.Name_Error =>
Log.Error ("Cannot read application configuration file {0}", CONFIG_PATH);
end;
C.Set ("contextPath", CONTEXT_PATH);
App.Initialize (C, Factory);
App.Set_Global ("contextPath", CONTEXT_PATH);
App.Set_Global ("compute",
Util.Beans.Objects.To_Object (Bean'Unchecked_Access,
Util.Beans.Objects.STATIC));
FB_Auth.Set_Application_Identifier (C.Get ("facebook.client_id"));
FB_Auth.Set_Application_Secret (C.Get ("facebook.secret"));
FB_Auth.Set_Application_Callback (C.Get ("facebook.callback"));
FB_Auth.Set_Provider_URI ("https://graph.facebook.com/oauth/access_token");
App.Set_Global ("facebook",
Util.Beans.Objects.To_Object (FB_Auth'Unchecked_Access,
Util.Beans.Objects.STATIC));
App.Set_Global ("countries", Util.Beans.Objects.To_Object (Countries.Create_Country_List));
App.Set_Global ("user",
Util.Beans.Objects.To_Object (Users.User'Access, Util.Beans.Objects.STATIC));
-- Declare a global bean to identify this sample from within the XHTML files.
App.Set_Global ("sampleName", "volume");
-- Register the servlets and filters
App.Add_Servlet (Name => "faces", Server => Faces'Unchecked_Access);
App.Add_Servlet (Name => "files", Server => Files'Unchecked_Access);
App.Add_Filter (Name => "dump", Filter => Dump'Unchecked_Access);
App.Add_Servlet (Name => "perf", Server => Perf'Unchecked_Access);
App.Add_Filter (Name => "perf", Filter => Perf'Unchecked_Access);
App.Add_Servlet (Name => "auth", Server => Auth'Unchecked_Access);
App.Add_Servlet (Name => "verify-auth", Server => Verify_Auth'Unchecked_Access);
-- Define servlet mappings
App.Add_Mapping (Name => "faces", Pattern => "*.html");
App.Add_Mapping (Name => "files", Pattern => "*.css");
App.Add_Mapping (Name => "files", Pattern => "*.js");
App.Add_Mapping (Name => "files", Pattern => "*.png");
App.Add_Mapping (Name => "verify-auth", Pattern => "/auth/verify");
App.Add_Mapping (Name => "auth", Pattern => "/auth/auth/*");
App.Add_Mapping (Name => "perf", Pattern => "/statistics.xml");
App.Add_Filter_Mapping (Name => "dump", Pattern => "*.html");
App.Add_Filter_Mapping (Name => "dump", Pattern => "*.js");
App.Add_Filter_Mapping (Name => "perf", Pattern => "/auth/verify");
App.Add_Filter_Mapping (Name => "dump", Pattern => "/auth/verify");
App.Add_Filter_Mapping (Name => "perf", Pattern => "/auth/auth/*");
App.Add_Filter_Mapping (Name => "dump", Pattern => "/auth/auth/*");
App.Add_Converter (Name => "float", Converter => Conv'Unchecked_Access);
-- App.Register_Class (Name => "Image_Bean", Handler => Images.Create_Image_Bean'Access);
App.Register_Class (Name => "Message_Bean", Handler => Messages.Create_Message_Bean'Access);
App.Register_Class (Name => "Message_List", Handler => Messages.Create_Message_List'Access);
App.Register_Class (Name => "Friends_Bean", Handler => Facebook.Create_Friends_Bean'Access);
App.Register_Class (Name => "Feeds_Bean", Handler => Facebook.Create_Feed_List_Bean'Access);
App.Register (Name => "message", Class => "Message_Bean", Params => None);
App.Register (Name => "messages", Class => "Message_List", Params => None);
ASF.Applications.Main.Configs.Read_Configuration (App, "samples/web/WEB-INF/web.xml");
WS.Register_Application (CONTEXT_PATH, App'Unchecked_Access);
Log.Info ("Connect you browser to: http://localhost:8080/demo/compute.html");
WS.Start;
delay 6000.0;
end Demo_Server;
|
zhmu/ananas | Ada | 3,237 | ads | ------------------------------------------------------------------------------
-- --
-- GNAT RUN-TIME COMPONENTS --
-- --
-- S Y S T E M . P A C K _ 1 1 3 --
-- --
-- S p e c --
-- --
-- Copyright (C) 1992-2022, Free Software Foundation, Inc. --
-- --
-- GNAT is free software; you can redistribute it and/or modify it under --
-- terms of the GNU General Public License as published by the Free Soft- --
-- ware Foundation; either version 3, or (at your option) any later ver- --
-- sion. GNAT is distributed in the hope that it will be useful, but WITH- --
-- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY --
-- or FITNESS FOR A PARTICULAR PURPOSE. --
-- --
-- As a special exception under Section 7 of GPL version 3, you are granted --
-- additional permissions described in the GCC Runtime Library Exception, --
-- version 3.1, as published by the Free Software Foundation. --
-- --
-- You should have received a copy of the GNU General Public License and --
-- a copy of the GCC Runtime Library Exception along with this program; --
-- see the files COPYING3 and COPYING.RUNTIME respectively. If not, see --
-- <http://www.gnu.org/licenses/>. --
-- --
-- GNAT was originally developed by the GNAT team at New York University. --
-- Extensive contributions were provided by Ada Core Technologies Inc. --
-- --
------------------------------------------------------------------------------
-- Handling of packed arrays with Component_Size = 113
package System.Pack_113 is
pragma Preelaborate;
Bits : constant := 113;
type Bits_113 is mod 2 ** Bits;
for Bits_113'Size use Bits;
-- In all subprograms below, Rev_SSO is set True if the array has the
-- non-default scalar storage order.
function Get_113
(Arr : System.Address;
N : Natural;
Rev_SSO : Boolean) return Bits_113 with Inline;
-- Arr is the address of the packed array, N is the zero-based
-- subscript. This element is extracted and returned.
procedure Set_113
(Arr : System.Address;
N : Natural;
E : Bits_113;
Rev_SSO : Boolean) with Inline;
-- Arr is the address of the packed array, N is the zero-based
-- subscript. This element is set to the given value.
end System.Pack_113;
|
persan/AdaYaml | Ada | 12,153 | adb | -- part of AdaYaml, (c) 2017 Felix Krause
-- released under the terms of the MIT license, see the file "copying.txt"
package body Yaml.Events.Store is
function New_Store return Reference is
Ptr : constant not null Instance_Access := new Instance;
begin
return (Ada.Finalization.Controlled with Data => Ptr);
end New_Store;
function Value (Object : Reference) return Accessor is
((Data => Object.Data));
function Value (Object : Optional_Reference) return Accessor is
((Data => Object.Data));
function Optional (Object : Reference'Class) return Optional_Reference is
begin
Increase_Refcount (Object.Data);
return (Ada.Finalization.Controlled with Data => Object.Data);
end Optional;
function Required (Object : Optional_Reference'Class) return Reference is
begin
Increase_Refcount (Object.Data);
return (Ada.Finalization.Controlled with Data => Object.Data);
end Required;
procedure Memorize (Object : in out Instance; Item : Event; Force : Boolean)
is
use type Text.Reference;
begin
if Object.Stream_Count > 0 then
raise State_Error with
"cannot manipulate event queue while a Stream_Instance exists";
end if;
case Item.Kind is
when Annotation_Start =>
if Item.Annotation_Properties.Anchor /= Text.Empty then
Object.Anchor_Map.Include
(Item.Annotation_Properties.Anchor,
(Position => Object.Length + 1, Has_Been_Output => False));
elsif Object.Depth = 0 and not Force then
return;
end if;
if Object.Depth = After_Annotation_End then
Object.Depth := 1;
else
Object.Depth := Object.Depth + 1;
end if;
when Scalar =>
if Item.Scalar_Properties.Anchor /= Text.Empty then
Object.Anchor_Map.Include
(Item.Scalar_Properties.Anchor,
(Position => Object.Length + 1,
Has_Been_Output => False));
elsif Object.Depth = 0 and not Force then
return;
end if;
if Object.Depth = After_Annotation_End then
Object.Depth := 0;
end if;
when Mapping_Start =>
if Item.Collection_Properties.Anchor /= Text.Empty then
Object.Anchor_Map.Include
(Item.Collection_Properties.Anchor,
(Position => Object.Length + 1,
Has_Been_Output => False));
elsif Object.Depth = 0 and not Force then
return;
end if;
if Object.Depth = After_Annotation_End then
Object.Depth := 1;
else
Object.Depth := Object.Depth + 1;
end if;
when Sequence_Start =>
if Item.Collection_Properties.Anchor /= Text.Empty then
Object.Anchor_Map.Include
(Item.Collection_Properties.Anchor,
(Position => Object.Length + 1,
Has_Been_Output => False));
elsif Object.Depth = 0 and not Force then
return;
end if;
if Object.Depth = After_Annotation_End then
Object.Depth := 1;
else
Object.Depth := Object.Depth + 1;
end if;
when Mapping_End | Sequence_End =>
if Object.Depth = 0 and not Force then
return;
end if;
Object.Depth := Object.Depth - 1;
when Annotation_End =>
if Object.Depth = 0 and not Force then
return;
end if;
Object.Depth := Object.Depth - 1;
if Object.Depth = 0 then
Object.Depth := After_Annotation_End;
end if;
when others =>
if Object.Depth = 0 and not Force then
return;
elsif Object.Depth = After_Annotation_End then
Object.Depth := 0;
end if;
end case;
if Object.Length = Object.Data.all'Length then
Object.Grow;
end if;
Object.Length := Object.Length + 1;
Object.Data (Object.Length) := Item;
end Memorize;
procedure Memorize (Object : in out Instance; Item : Event) is
begin
Memorize (Object, Item, False);
end Memorize;
procedure Force_Memorize (Object : in out Instance; Item : Event;
Position : out Element_Cursor) is
begin
Memorize (Object, Item, True);
Position := Element_Cursor (Object.Length);
end Force_Memorize;
function Find (Object : Instance; Alias : Text.Reference)
return Anchor_Cursor is
(Anchor_Cursor (Object.Anchor_Map.Find (Alias)));
function Exists_In_Output (Position : Anchor_Cursor) return Boolean is
(Anchor_To_Index.Element
(Anchor_To_Index.Cursor (Position)).Has_Been_Output);
procedure Set_Exists_In_Output (Object : in out Instance;
Position : Anchor_Cursor) is
procedure Process (Key : Text.Reference;
Element : in out Anchor_Info) is
pragma Unreferenced (Key);
begin
Element.Has_Been_Output := True;
end Process;
begin
Anchor_To_Index.Update_Element (Object.Anchor_Map,
Anchor_To_Index.Cursor (Position),
Process'Access);
end Set_Exists_In_Output;
procedure Advance (Position : in out Element_Cursor) is
begin
Position := Element_Cursor'Succ (Position);
end Advance;
procedure Advance_At_Same_Level (Object : Instance;
Position : in out Element_Cursor) is
Depth : Natural := 0;
begin
loop
case Object.Data (Positive (Position)).Kind is
when Annotation_Start | Sequence_Start | Mapping_Start |
Document_Start =>
Depth := Depth + 1;
when Annotation_End =>
Depth := Depth - 1;
when Sequence_End | Mapping_End | Document_End =>
Depth := Depth - 1;
if Depth = 0 then
Position := Element_Cursor'Succ (Position);
return;
end if;
when Scalar | Alias =>
if Depth = 0 then
Position := Element_Cursor'Succ (Position);
return;
end if;
when Stream_Start | Stream_End =>
raise Stream_Error with "Unexpected event inside stream: " &
Object.Data (Positive (Position)).Kind'Img;
end case;
Position := Element_Cursor'Succ (Position);
end loop;
end Advance_At_Same_Level;
procedure Clear (Object : in out Instance) is
begin
if Object.Stream_Count > 0 then
raise State_Error with
"cannot manipulate event queue while a Stream_Instance exists";
end if;
Object.Anchor_Map.Clear;
Object.Depth := 0;
end Clear;
procedure Copy (Source : in Instance; Target : in out Instance) is
begin
if Target.Data.all'Length /= Source.Data.all'Length then
Target.Finalize;
Target.Data := new Event_Array (Source.Data.all'Range);
end if;
Target.Data.all := Source.Data.all;
Target.Length := Source.Length;
Target.Anchor_Map := Source.Anchor_Map;
Target.Depth := Source.Depth;
end Copy;
function Retrieve (Object : Reference'Class; Position : Anchor_Cursor)
return Stream_Reference is
Ptr : constant not null Stream_Instance_Access :=
new Stream_Instance'(Refcount_Base with Object => Reference (Object),
Depth => 0, Current => Anchor_To_Index.Element
(Anchor_To_Index.Cursor (Position)).Position);
begin
Object.Data.Stream_Count := Object.Data.Stream_Count + 1;
return Stream_Reference'(Ada.Finalization.Controlled with Data => Ptr);
end Retrieve;
function Retrieve (Object : Reference'Class; Position : Element_Cursor)
return Stream_Reference is
Ptr : constant not null Stream_Instance_Access :=
new Stream_Instance'(Refcount_Base with Object => Reference (Object),
Depth => 0, Current => Positive (Position));
begin
Object.Data.Stream_Count := Object.Data.Stream_Count + 1;
return Stream_Reference'(Ada.Finalization.Controlled with Data => Ptr);
end Retrieve;
function Value (Object : Stream_Reference) return Stream_Accessor is
((Data => Object.Data));
function Next (Object : in out Stream_Instance) return Event is
begin
if Object.Depth = 1 then
raise Constraint_Error with
"tried to query item after end of anchored node";
end if;
return Item : constant Event := Object.Object.Data.Data (Object.Current) do
case Item.Kind is
when Scalar => Object.Depth := Natural'Max (1, Object.Depth);
when Mapping_Start | Sequence_Start =>
Object.Depth := Natural'Max (2, Object.Depth + 1);
when others => null;
end case;
Object.Current := Object.Current + 1;
end return;
end Next;
function Exists (Object : Optional_Stream_Reference) return Boolean is
(Object.Data /= null);
function Value (Object : Optional_Stream_Reference) return Stream_Accessor is
((Data => Object.Data));
function Optional (Object : Stream_Reference'Class)
return Optional_Stream_Reference is
begin
Object.Data.Refcount := Object.Data.Refcount + 1;
return (Ada.Finalization.Controlled with Data => Object.Data);
end Optional;
procedure Clear (Object : in out Optional_Stream_Reference) is
begin
if Object.Data /= null then
Decrease_Refcount (Object.Data);
Object.Data := null;
end if;
end Clear;
function First (Object : Instance; Position : Anchor_Cursor) return Event is
(Object.Data (Anchor_To_Index.Element (Anchor_To_Index.Cursor
(Position)).Position));
function Element (Object : Instance; Position : Element_Cursor)
return Event is
(Object.Data (Positive (Position)));
procedure Adjust (Object : in out Reference) is
begin
Increase_Refcount (Object.Data);
end Adjust;
procedure Finalize (Object : in out Reference) is
begin
Decrease_Refcount (Object.Data);
end Finalize;
procedure Adjust (Object : in out Optional_Reference) is
begin
if Object.Data /= null then
Increase_Refcount (Object.Data);
end if;
end Adjust;
procedure Finalize (Object : in out Optional_Reference) is
begin
if Object.Data /= null then
Decrease_Refcount (Object.Data);
end if;
end Finalize;
procedure Finalize (Object : in out Stream_Instance) is
begin
Object.Object.Data.Stream_Count := Object.Object.Data.Stream_Count - 1;
end Finalize;
procedure Adjust (Object : in out Stream_Reference) is
begin
Increase_Refcount (Object.Data);
end Adjust;
procedure Finalize (Object : in out Stream_Reference) is
begin
Decrease_Refcount (Object.Data);
end Finalize;
procedure Adjust (Object : in out Optional_Stream_Reference) is
begin
if Object.Data /= null then
Increase_Refcount (Object.Data);
end if;
end Adjust;
procedure Finalize (Object : in out Optional_Stream_Reference) is
begin
if Object.Data /= null then
Decrease_Refcount (Object.Data);
end if;
end Finalize;
function To_Element_Cursor (Position : Anchor_Cursor) return Element_Cursor
is (if Position = No_Anchor then No_Element else
Element_Cursor (Anchor_To_Index.Element (Anchor_To_Index.Cursor
(Position)).Position));
end Yaml.Events.Store;
|
Tim-Tom/scratch | Ada | 899 | ads | with Ada.Containers.Vectors;
with Ada.Containers.Ordered_Maps;
with Ada.Containers.Ordered_Sets;
package Word_List is
subtype Word is String(1 .. 24);
type Pattern is new String(1 .. 24);
function "<"(a, b : Pattern) return Boolean;
function "="(a, b : Pattern) return Boolean;
package Word_Vectors is new Ada.Containers.Vectors(Element_Type => Word, Index_Type => Positive);
type Word_Vector is access Word_Vectors.Vector;
package Word_Lists is new Ada.Containers.Ordered_Maps(Element_Type => Word_Vector, Key_Type => Pattern);
package Pattern_Sets is new Ada.Containers.Ordered_Sets(Element_Type => Word_List.Pattern);
subtype Word_List is Word_Lists.Map;
subtype Pattern_Set is Pattern_Sets.Set;
function Make_Pattern(w : Word) return Pattern;
function Build_Word_List(filename : String; patterns : Pattern_Set) return Word_List;
end Word_List;
|
AdaCore/training_material | Ada | 28,690 | adb | -----------------------------------------------------------------------
-- Ada Labs --
-- --
-- Copyright (C) 2008-2013, AdaCore --
-- --
-- Labs is free software; you can redistribute it and/or modify it --
-- under the terms of the GNU General Public License as published by --
-- the Free Software Foundation; either version 2 of the License, or --
-- (at your option) any later version. --
-- --
-- This program is distributed in the hope that it will be useful, --
-- but WITHOUT ANY WARRANTY; without even the implied warranty of --
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU --
-- General Public License for more details. You should have received --
-- a copy of the GNU General Public License along with this program; --
-- if not, write to the Free Software Foundation, Inc., 59 Temple --
-- Place - Suite 330, Boston, MA 02111-1307, USA. --
-----------------------------------------------------------------------
with Interfaces.C; use Interfaces.C;
with Interfaces.C.Strings; use Interfaces.C.Strings;
with SDL_SDL_stdinc_h; use SDL_SDL_stdinc_h;
with SDL_SDL_video_h; use SDL_SDL_video_h;
with System;
with Ada.Text_IO; use Ada.Text_IO;
with SDL_SDL_error_h; use SDL_SDL_error_h;
with SDL_SDL_h; use SDL_SDL_h;
with System.Storage_Elements;
with System.Address_To_Access_Conversions;
with Interfaces; use Interfaces;
with SDL_SDL_events_h; use SDL_SDL_events_h;
with Ada.Real_Time; use Ada.Real_Time;
with Display.Basic.Fonts; use Display.Basic.Fonts;
with Display.Basic.Utils; use Display.Basic.Utils;
package body Display.Basic is
---------------
-- SDL STATE --
---------------
--Surface : access SDL_Surface;
-- Vid_Info : access SDL_VideoInfo;
-- Sdl_Width : constant Integer := 800;
-- Sdl_Height : constant Integer := 800;
-- BPP : constant Interfaces.C.int := 32;
-- Sdl_Flags : constant Interfaces.C.unsigned :=
-- SDL_HWSURFACE + SDL_RESIZABLE + SDL_DOUBLEBUF;
Initialized : boolean := False with Atomic, Volatile;
type Cart_Point is record
X, Y : Float;
end record;
-- function "+" (P : Cart_Point; S : SDL_Surface) return Screen_Point
-- is ((X => Integer (C.Zoom_Factor * P.X) + Integer(C.Surface.w / 2) + C.Center.X,
--Y => Integer(C.Surface.h / 2) - C.Center.Y - Integer (C.Zoom_Factor * P.Y)));
-- ((X => Integer (Zoom_Factor * P.X) + Integer(S.w / 2),
-- Y => Integer(S.h / 2) - Integer (Zoom_Factor * P.Y)));
function To_Screen_Point (C : T_Internal_Canvas; P : Cart_Point) return Screen_Point
is
((X => Integer (C.Zoom_Factor * P.X) + Integer(C.Surface.w / 2) - C.Center.X,
Y => Integer(C.Surface.h / 2) + C.Center.Y - Integer (C.Zoom_Factor * P.Y)));
function To_Point3d (Canvas : Canvas_ID; P : Screen_Point) return Point_3d is
C : T_Internal_Canvas := Get_Internal_Canvas(Canvas);
begin
return (Float(P.X - Integer(C.Surface.w / 2) - C.Center.X),
Float(Integer(C.Surface.w / 2) - C.Center.Y - P.Y),
0.0);
end To_Point3d;
function Get_Zoom_Factor(Canvas : Canvas_ID) return Float is (Get_Internal_Canvas(Canvas).Zoom_Factor);
procedure Set_Zoom_Factor (Canvas : Canvas_ID; ZF : Float) is
begin
Display.Basic.Utils.Set_Zoom_Factor(Canvas, ZF);
end Set_Zoom_Factor;
function To_Screen_Point (Canvas : Canvas_ID; P : Point_3d) return Screen_Point is
C : T_Internal_Canvas := Get_Internal_Canvas(Canvas);
begin
return To_Screen_Point(C, (P.X, P.Y));
end To_Screen_Point;
function Scale (Canvas: T_Internal_Canvas; L : Float) return Integer is (Integer (L * Canvas.Zoom_Factor));
procedure Set_Center (Canvas : Canvas_ID; Position : Point_3d) is
C : T_Internal_Canvas := Get_Internal_Canvas(Canvas);
begin
Display.Basic.Utils.Set_Center(Canvas, (Scale(C, Position.X), Scale(C, Position.Y)));
end Set_Center;
procedure Set_Center (Canvas : Canvas_ID; Position : Screen_Point) is
begin
Display.Basic.Utils.Set_Center(Canvas, Position);
end Set_Center;
function Get_Center (Canvas : Canvas_ID) return Screen_Point is
begin
return Display.Basic.Utils.Get_Center(Canvas);
end Get_Center;
-- ---------------
-- -- Set_Color --
-- ---------------
--
-- procedure Set_Color (Shape : in out Shape_Id; Color : Color_Type) is
-- begin
-- Shapes (Shape).Color := Color;
-- end Set_Color;
-- ---------------
-- -- Get_Color --
-- ---------------
--
-- function Get_Color (Shape : Shape_Id) return Color_Type is
-- begin
-- return Shapes (Shape).Color;
-- end Get_Color;
---------------
-- New_Shape --
---------------
----------------
-- New_Circle --
----------------
-- function New_Circle
-- (X : Float;
-- Y : Float;
-- Radius : Float;
-- Color : Color_Type)
-- return Shape_Id
-- is
-- Id : Shape_Index := New_Shape;
-- begin
-- Shapes (Id) := (Kind => Circle, X => X, Y => Y, Radius => Radius,
-- Color => Color);
-- return Id;
-- end New_Circle;
----------------
-- Get_Radius --
----------------
--------------
-- New_Line --
--------------
-- function New_Line
-- (X : Float;
-- Y : Float;
-- X2 : Float;
-- Y2 : Float;
-- Color : Color_Type) return Shape_Id
-- is
-- Id : Shape_Index := New_Shape;
-- begin
-- Shapes (Id) := (Kind => Line, X => X, Y => Y, End_X => X2, End_Y => Y2,
-- Color => Color);
-- return Id;
-- end New_Line;
-------------
-- New_Box --
-------------
-- function New_Box
-- (X, Y : Float;
-- Width, Height : Float;
-- Color : Color_Type)
-- return Shape_Id
-- is
-- Id : Shape_Index := New_Shape;
-- begin
-- Shapes (Id) := (Kind => Box, X => X, Y => Y, Width => Width,
-- Height => Height, Color => Color);
-- return Id;
-- end New_Box;
---------------
-- New_Torus --
---------------
-- function New_Torus
-- (X : Float;
-- Y : Float;
-- Inner_Radius : Float;
-- Outer_Radius : Float;
-- Color : Color_Type)
-- return Shape_Id
-- is
-- Id : Shape_Index := New_Shape;
-- begin
-- Shapes (Id) := (Kind => Torus, X => X, Y => Y,
-- Inner => Outer_Radius - Inner_Radius,
-- Outer => Outer_Radius,
-- Color => Color);
-- return Id;
-- end New_Torus;
-----------------
-- Draw_Circle --
-----------------
procedure Draw_Circle (Surface : access SDL_Surface; P : Screen_Point; Radius : Integer; Color : RGBA_T)
is
CX, CY, Radius_Error : Integer;
UC : Uint32 := RGBA_To_Uint32(Surface, Color);
begin
if SDL_LockSurface (Surface) < 0 then
raise Display_Error;
end if;
CX := Radius;
CY := 0;
Radius_Error := 1 - CX;
while CX >= CY loop
Put_Pixel (Surface, CX + P.X, CY + P.Y, UC);
Put_Pixel (Surface, CY + P.X, CX + P.Y, UC);
Put_Pixel (Surface, -CX + P.X, CY + P.Y, UC);
Put_Pixel (Surface, -CY + P.X, CX + P.Y, UC);
Put_Pixel (Surface, -CX + P.X, -CY + P.Y, UC);
Put_Pixel (Surface, -CY + P.X, -CX + P.Y, UC);
Put_Pixel (Surface, CX + P.X, -CY + P.Y, UC);
Put_Pixel (Surface, CY + P.X, -CX + P.Y, UC);
CY := CY + 1;
if Radius_Error < 0 then
Radius_Error := Radius_Error + (2 * CY + 1);
else
CX := CX - 1;
Radius_Error := Radius_Error + (2 * (CY - CX) + 1);
end if;
end loop;
SDL_UnlockSurface (Surface);
end Draw_Circle;
procedure Draw_Circle (Canvas : Canvas_ID; Position: Point_3d; Radius : Float; Color: RGBA_T) is
C : T_Internal_Canvas := Get_Internal_Canvas (Canvas);
begin
Draw_Circle(C.Surface,
To_Screen_Point(C, (Position.X, Position.Y)),
Scale (C, Radius),
Color);
end Draw_Circle;
procedure Draw_Circle (Canvas : Canvas_ID; Position: Screen_Point; Radius : Integer; Color: RGBA_T) is
C : T_Internal_Canvas := Get_Internal_Canvas (Canvas);
begin
Draw_Circle(C.Surface,
Position,
Radius,
Color);
end Draw_Circle;
---------------
-- Draw_Line --
---------------
-- procedure Draw_Line
-- (Surface : access SDL_Surface; P_Start, P_End : Screen_Point; Color : RGBA_Color)
-- is
-- DX : Integer := P_End.X - P_Start.X;
-- DY : Integer := P_End.Y - P_Start.Y;
-- D : Integer := 2 * DY - DX;
-- Y : Integer := P_Start.Y;
-- begin
-- Put_Pixel (Surface, P_Start.X, P_Start.Y, Color);
-- for X in P_Start.X +1 .. P_End.X loop
-- if D > 0 then
-- Y := Y + 1;
-- Put_Pixel (Surface, X, Y, Color);
-- D := D + (2 * DY - 2 * DX);
-- else
-- Put_Pixel (Surface, X, Y, Color);
-- D := D + (2 * DY);
-- end if;
-- end loop;
-- end Draw_Line;
procedure Draw_Line (Surface : access SDL_Surface; P0 : Screen_Point; P1 : Screen_Point; Color : Uint32) is
dx : constant Integer := abs (P1.X - P0.X);
sx : constant Integer := (if P0.X < P1.X then 1 else -1);
dy : constant Integer := abs (P1.Y - P0.Y);
sy : constant Integer := (if P0.Y < P1.Y then 1 else -1);
err : Integer := (if dx > dy then dx else - dy) / 2;
e2 : Integer;
X : Integer := P0.X;
Y : Integer := P0.Y;
begin
loop
Put_Pixel (Surface, X, Y, Color);
if X = P1.X and then Y = P1.Y then
return;
end if;
e2 := err;
if e2 > -dx then
err := err - dy;
X := X + sx;
end if;
if e2 < dy then
err := err + dx;
Y := Y + sy;
end if;
end loop;
end Draw_Line;
procedure Draw_Line (Surface : access SDL_Surface; P0 : Screen_Point; P1 : Screen_Point; Color : RGBA_T) is
begin
Draw_Line(Surface, P0, P1, RGBA_To_Uint32(Surface, Color));
end Draw_Line;
procedure Draw_Line (Canvas : Canvas_ID; P1: Point_3d; P2 : Point_3d; Color: RGBA_T) is
C : T_Internal_Canvas := Get_Internal_Canvas (Canvas);
begin
Draw_Line (C.Surface,
To_Screen_Point(C, (P1.X, P1.Y)),
To_Screen_Point(C, (P2.X, P2.Y)),
Color);
end Draw_Line;
procedure Draw_Line (Canvas : Canvas_ID; P1: Screen_Point; P2 : Screen_Point; Color: RGBA_T) is
C : T_Internal_Canvas := Get_Internal_Canvas (Canvas);
begin
Draw_Line (C.Surface,
P1,
P2,
Color);
end Draw_Line;
procedure Draw_Rect
(Surface: access SDL_Surface; P : Screen_Point; Width, Height : Integer; Color : RGBA_T)
is
UC : Uint32 := RGBA_To_Uint32(Surface, Color);
begin
Draw_Line(Surface, P, (P.x + Width - 1, P.Y), UC);
Draw_Line(Surface, P, (P.x, P.Y + Height - 1), UC);
Draw_Line(Surface, (P.x + Width - 1, P.Y), (P.x + Width - 1, P.Y + Height - 1), UC);
Draw_Line(Surface, (P.x, P.Y + Height - 1), (P.x + Width - 1, P.Y + Height - 1), UC);
end Draw_Rect;
procedure Draw_Fill_Rect
(Surface: access SDL_Surface; P : Screen_Point; Width, Height : Integer; Color : RGBA_T)
is
UC : Uint32 := RGBA_To_Uint32(Surface, Color);
begin
for I in 0 .. Width - 1 loop
for J in 0 .. Height - 1 loop
Put_Pixel (Surface, P.X + I, P.Y + J, UC);
end loop;
end loop;
end Draw_Fill_Rect;
procedure Draw_Rect(Canvas : Canvas_ID; Position : Point_3d; Width, Height : Float; Color : RGBA_T) is
IC : T_Internal_Canvas := Get_Internal_Canvas(Canvas);
begin
Draw_Rect(IC.Surface,
To_Screen_Point(IC, (Position.X, Position.Y)),
Scale(IC, Width),
Scale (IC, Height),
Color);
end Draw_Rect;
procedure Draw_Rect(Canvas : Canvas_ID; Position : Screen_Point; Width, Height : Integer; Color : RGBA_T) is
IC : T_Internal_Canvas := Get_Internal_Canvas(Canvas);
begin
Draw_Rect(IC.Surface,
Position,
Width,
Height,
Color);
end Draw_Rect;
procedure Draw_Fill_Rect (Canvas : Canvas_ID; Position : Point_3d; Width, Height : Float; Color : RGBA_T) is
IC : T_Internal_Canvas := Get_Internal_Canvas(Canvas);
begin
Draw_Fill_Rect(IC.Surface,
To_Screen_Point(IC, (Position.X, Position.Y)),
Scale(IC, Width),
Scale (IC, Height),
Color);
end Draw_Fill_Rect;
procedure Draw_Fill_Rect (Canvas : Canvas_ID; Position : Screen_Point; Width, Height : Integer; Color : RGBA_T) is
IC : T_Internal_Canvas := Get_Internal_Canvas(Canvas);
begin
Draw_Fill_Rect(IC.Surface,
Position,
Width,
Height,
Color);
end Draw_Fill_Rect;
---------------
------------------------
-- Draw_Filled_Circle --
------------------------
-- procedure Draw_Filled_Circle
-- (Surface : access SDL_Surface; P : Screen_Point; Radius : Integer; Color : RGBA_Color)
-- is
-- begin
-- if SDL_LockSurface (Surface) < 0 then
-- raise Display_Error;
-- end if;
--
-- for Y in -Radius .. Radius loop
-- for X in -Radius .. Radius loop
-- if X * X + Y * Y < Radius * Radius then
-- Put_Pixel (Surface, P.X + X, P.Y + Y, Color);
-- end if;
-- end loop;
-- end loop;
-- SDL_UnlockSurface (Surface);
--
-- end Draw_Filled_Circle;
procedure Draw_Filled_Circle (Surface : access SDL_Surface; P : Screen_Point; Radius : Integer; Color : RGBA_T) is
r : Integer := Radius;
x : Integer := -r;
y : Integer := 0;
err : Integer := 2 - 2 * r; --/ * II. Quadrant * /
UC : Uint32 := RGBA_To_Uint32(Surface, Color);
begin
if SDL_LockSurface (Surface) < 0 then
raise Display_Error;
end if;
if Radius <= 1 then
Put_Pixel (Surface, P.X, P.Y, UC);
else
while x < 0 loop
Draw_Line (Surface, (P.X - x, P.Y - y), (P.X + x, P.Y - y), UC);
Draw_Line (Surface, (P.X - x, P.Y + y), (P.X + x, P.Y + y), UC);
r := err;
if r <= y then
y := y + 1;
err := err + y * 2 + 1; -- / * e_xy + e_y < 0 * /
end if;
if r > x or else err > y then
x := x + 1;
err := err + x * 2 + 1; --/ * e_xy + e_x > 0 or no 2nd y - step * /
end if;
if x >= 0 then
return;
end if;
end loop;
end if;
SDL_UnlockSurface (Surface);
end Draw_Filled_Circle;
procedure Draw_Sphere (Canvas : Canvas_ID; Position: Screen_Point; Radius : Integer; Color: RGBA_T)is
C : T_Internal_Canvas := Get_Internal_Canvas (Canvas);
begin
Draw_Filled_Circle(C.Surface,
Position,
Radius,
Color);
end Draw_Sphere;
procedure Draw_Sphere (Canvas : Canvas_ID; Position: Point_3d; Radius : Float; Color: RGBA_T) is
C : T_Internal_Canvas := Get_Internal_Canvas (Canvas);
begin
Draw_Filled_Circle(C.Surface,
To_Screen_Point(C, (Position.X, Position.Y)),
Scale (C, Radius),
Color);
end Draw_Sphere;
---------------
-- Draw_Ring --
---------------
procedure Draw_Ring
(Surface : access SDL_Surface; P : Screen_Point; Radius, Inner_Radius : Integer; Color : RGBA_T) is
UC : Uint32 := RGBA_To_Uint32(Surface, Color);
begin
for Y in -Radius .. Radius loop
for X in -Radius .. Radius loop
declare
T : Integer := X * X + Y * Y;
begin
if T < Radius * Radius and then T >= Inner_Radius * Inner_Radius
then
Put_Pixel (Surface, P.X + X, P.Y + Y, UC);
end if;
end;
end loop;
end loop;
end Draw_Ring;
-- ----------
-- -- Draw --
-- ----------
--
-- procedure Draw (Canvas: T_Internal_Canvas; Inst : Shape) is
-- begin
-- case Inst.Kind is
-- when Circle =>
-- Draw_Filled_Circle
-- (Canvas.Surface,
-- To_Screen_Point(Canvas, (Inst.X, Inst.Y)),
-- Scale (Canvas, Inst.Radius),
-- Color_Map (Inst.Color));
-- when Torus =>
-- Draw_Ring
-- (Canvas.Surface,
-- To_Screen_Point(Canvas, (Inst.X, Inst.Y)), Scale (Canvas, Inst.Outer),
-- Scale (Canvas, Inst.Inner),
-- Color_Map (Inst.Color));
-- when Box =>
-- Draw_Box
-- (Canvas.Surface,
-- To_Screen_Point (Canvas, (Inst.X, Inst.Y)),
-- Scale (Canvas, Inst.Width),
-- Scale (Canvas, Inst.Height),
-- Color_Map (Inst.Color));
-- when Line =>
-- Draw_Line (Canvas.Surface,
-- To_Screen_Point(Canvas, (Inst.X, Inst.Y)),
-- To_Screen_Point(Canvas, (Inst.End_X, Inst.End_Y)),
-- Color_Map (Inst.Color));
-- when others => null;
-- end case;
-- end Draw;
-----------
-- Check --
-----------
procedure Check (Ret : Int) is
begin
if Ret /= 0 then
raise Display_Error;
end if;
end Check;
procedure Poll_Events;
----------
-- Draw --
----------
procedure Swap_Buffers (Window : Window_ID; Erase : Boolean := True) is
Canvas : T_Internal_Canvas := Get_Internal_Canvas(Get_Canvas(Window));
begin
-- if SDL_LockSurface (Canvas.Surface) < 0 then
-- raise Display_Error;
-- end if;
--
--
-- for Id in Shapes'First .. Max_Shape_Id loop
-- Draw (Canvas, Shapes (Id));
-- end loop;
-- SDL_UnlockSurface (Canvas.Surface);
if SDL_Flip (Canvas.Surface) < 0 then
raise Display_Error;
end if;
if Erase then
if SDL_FillRect (Canvas.Surface, null, 0) < 0 then
raise Display_Error;
end if;
end if;
Poll_Events;
end Swap_Buffers;
procedure Swap_Copy_Buffers (Window : Window_ID) is
begin
Swap_Buffers(Window, False);
end Swap_Copy_Buffers;
procedure Fill(Canvas : Canvas_ID; Color: RGBA_T) is
IC : T_Internal_Canvas := Get_Internal_Canvas(Canvas);
UC : Uint32 := RGBA_To_Uint32(IC.Surface, Color);
begin
if SDL_FillRect (IC.Surface, null, UC) < 0 then
raise Display_Error;
end if;
end Fill;
Internal_Cursor : Cursor_T := ((0,0), False);
Killed : Boolean := False
with Atomic;
function Is_Killed return Boolean is
begin
return Killed;
end Is_Killed;
procedure Poll_Events is
E : aliased SDL_Event;
begin
while SDL_PollEvent (E'Access) /= 0 loop
case unsigned (E.c_type) is
when SDL_SDL_events_h.SDL_Quit =>
Killed := True;
SDL_SDL_h.SDL_Quit;
when SDL_SDL_events_h.SDL_MOUSEBUTTONDOWN =>
Internal_Cursor.Position := (Integer(E.motion.x), Integer(E.motion.y));
Internal_Cursor.Pressed := True;
when SDL_SDL_events_h.SDL_MOUSEBUTTONUP =>
Internal_Cursor.Position := (Integer(E.motion.x), Integer(E.motion.y));
Internal_Cursor.Pressed := False;
when others =>
null;
end case;
end loop;
end Poll_Events;
function Get_Cursor_Status return Cursor_T is
begin
Poll_Events;
return Internal_Cursor;
end Get_Cursor_Status;
procedure Draw_Text (Canvas : Canvas_ID; Position: Point_3d; Text : String; Color: RGBA_T; Bg_Color : RGBA_T := Black; Wrap: Boolean := True) is
IC : T_Internal_Canvas := Get_Internal_Canvas(Canvas);
begin
Draw_String(IC,
P => To_Screen_Point(IC, (Position.X, Position.Y)),
Str => Text,
Font => Font8x8,
FG => Color,
BG => Bg_Color,
Wrap => Wrap);
end Draw_Text;
procedure Draw_Text (Canvas : Canvas_ID; Position: Screen_Point; Text : String; Color: RGBA_T; Bg_Color : RGBA_T := Black; Wrap: Boolean := True) is
IC : T_Internal_Canvas := Get_Internal_Canvas(Canvas);
begin
Draw_String(IC,
P => Position,
Str => Text,
Font => Font8x8,
FG => Color,
BG => Bg_Color,
Wrap => Wrap);
end Draw_Text;
function Get_Text_Size(Text : String) return Screen_Point is
begin
return String_Size (Font8x8, Text);
end Get_Text_Size;
procedure Set_Pixel (Canvas : Canvas_ID; Position : Screen_Point; Color : RGBA_T) is
IC : T_Internal_Canvas := Get_Internal_Canvas(Canvas);
begin
Display.Basic.Utils.Put_Pixel_Slow(Screen => IC.Surface,
X => Position.X,
Y => Position.Y,
Color => Color);
end Set_Pixel;
-------------------
-- Set_SDL_Video --
-------------------
type SDL_Window_Surface is record
surface : Canvas_ID;
vidInfo : access SDL_VideoInfo;
w : Integer := 400;
h : Integer := 400;
bpp : Interfaces.C.int := 32;
flags : Interfaces.C.unsigned := SDL_HWSURFACE + SDL_RESIZABLE + SDL_DOUBLEBUF;
end record;
type Windows_Array is array (Window_ID) of SDL_Window_Surface;
Nb_Windows : Integer := 0;
Stored_Windows : Windows_Array;
function Create_SDL_Window (Width : Integer; Height : Integer; Name : String) return SDL_Window_Surface;
function Create_Window (Width : Integer; Height : Integer; Name : String) return Window_ID is
Current_Id : Window_ID;
begin
Ada.Text_IO.Put_Line("Create Window Entry ");
if Nb_Windows = Windows_Array'Length then
raise Too_Many_Windows;
end if;
Current_Id := Window_ID (Integer (Window_ID'First) + Nb_Windows);
Stored_Windows(Current_Id) := Create_SDL_Window (Width, Height, Name);
Nb_Windows := Nb_Windows + 1;
return Current_Id;
end Create_Window;
SDL_S : access SDL_Surface;
function Create_SDL_Window (Width : Integer; Height : Integer; Name : String) return SDL_Window_Surface is
S : SDL_Window_Surface;
begin
Ada.Text_IO.Put_Line("Create_SDL_Window Entry ");
if not Initialized then
raise Graphical_Context_Not_Initialized;
end if;
-- To center a non-fullscreen window we need to set an environment
-- variable
Check (SDL_putenv(New_String ("SDL_VIDEO_CENTERED=center")));
-- the video info structure contains the current video mode. Prior to
-- calling setVideoMode, it contains the best available mode
-- for your system. Post setting the video mode, it contains
-- whatever values you set the video mode with.
-- First we point at the SDL structure, then test to see that the
-- point is right. Then we copy the data from the structure to
-- the safer vidInfo variable.
declare
ptr : System.Address := SDL_GetVideoInfo;
for ptr'Address use S.vidInfo'Address;
use type System.Address;
begin
if ptr = System.Null_Address then
Put_Line ("Error querying video info");
Put_Line(Value (SDL_GetError));
SDL_SDL_h.SDL_Quit;
end if;
end;
-- the setVideoMode function returns the current frame buffer as an
-- SDL_Surface. Again, we grab a pointer to it, then place its
-- content into the non pointery surface variable. I say 'non-pointery',
-- but this SDL variable must have a pointer in it because it can
-- access the current pixels in the framebuffer.
S.w := Width;
S.h := Height;
SDL_S := SDL_SetVideoMode(int (S.w), int (S.h), S.bpp,
S.flags);
if SDL_S = null then
Put_Line ("Error setting the video mode");
Put_Line(Value (SDL_GetError));
SDL_SDL_h.SDL_Quit;
raise Graphical_Context_Not_Initialized;
end if;
S.surface := Register_SDL_Surface(SDL_S);
-- Rather than set the video properties up in the constructor, I set
-- them in setVideo. The reason for this is that 2 pointers are used to
-- interact with SDL structures. Once used they convert their handles
-- into vidInfo and surface tamer variables. That this occurs inside
-- the function means the pointers will release their memory on function
-- exit.
SDL_WM_SetCaption (Title => New_String (Name), Icon => Null_Ptr);
return S;
end Create_SDL_Window;
function Get_Canvas(Window : Window_ID) return Canvas_ID is
begin
return Stored_Windows(Window).surface;
end Get_Canvas;
function Get_Canvas_Size(Canvas : Canvas_ID) return Screen_Point is
IC : T_Internal_Canvas := Get_Internal_Canvas(Canvas);
begin
return Screen_Point'(Integer(IC.Surface.w), Integer(IC.Surface.h));
end Get_Canvas_Size;
procedure Init is
begin
-- SDL is comprised of 8 subsystems. Here we initialize the video
if SDL_Init(SDL_INIT_VIDEO) < 0 then
Put_Line ("Error initializing SDL");
Put_Line(Value (SDL_GetError));
SDL_SDL_h.SDL_Quit;
raise Graphical_Context_Not_Initialized;
end if;
Initialized := True;
end Init;
procedure Enable_3d_Light (Canvas : Canvas_ID) is
begin
-- does not do anything without opengl
null;
end Enable_3d_Light;
procedure Disable_3d_Light (Canvas : Canvas_ID) is
begin
-- does not do anything without opengl
null;
end Disable_3d_Light;
procedure Set_3d_Light (Canvas : Canvas_ID;
Position : Point_3d;
Diffuse_Color : RGBA_T;
Ambient_Color : RGBA_T) is
begin
-- does not do anything without opengl
null;
end Set_3d_Light;
-------------------------
-- NOT YET IMPLEMENTED --
-------------------------
-- function New_Text
-- (X : Float;
-- Y : Float;
-- Text : String;
-- Color : Color_Type)
-- return Shape_Id is (Null_Shape_Id);
-- procedure Set_Text (V : in out Shape_Id; Text : String) is null;
-- function Get_Text (V : Shape_Id) return String is ("");
-- function Current_Key_Press return Key_Type is (0);
-- function To_Character (Key : Key_Type) return Character is (' ');
-- function To_Special (Key : Key_Type) return Special_Key is (KEY_NONE);
-- function Is_Special_Key (Key : Key_Type) return Boolean is (False);
-- function Is_Control_Key (Key : Key_Type) return Boolean is (False);
-- function Is_Shift_Key (Key : Key_Type) return Boolean is (False);
-- function Is_Alt_Key (Key : Key_Type) return Boolean is (False);
-- function Read_Last_Mouse_Position return Mouse_Position
-- is (No_Mouse_Position);
-- function At_End return Boolean is (False);
begin
Init;
end Display.Basic;
|
mitchelhaan/ncurses | Ada | 3,914 | adb | ------------------------------------------------------------------------------
-- --
-- GNAT ncurses Binding --
-- --
-- Terminal_Interface.Curses.Text_IO.Fixed_IO --
-- --
-- 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.6 $
-- Binding Version 00.93
------------------------------------------------------------------------------
with Ada.Text_IO;
with Terminal_Interface.Curses.Text_IO.Aux;
package body Terminal_Interface.Curses.Text_IO.Fixed_IO is
package Aux renames Terminal_Interface.Curses.Text_IO.Aux;
package FIXIO is new Ada.Text_IO.Fixed_IO (Num);
procedure Put
(Win : in Window;
Item : in Num;
Fore : in Field := Default_Fore;
Aft : in Field := Default_Aft;
Exp : in Field := Default_Exp)
is
Buf : String (1 .. Field'Last);
Len : Field := Fore + 1 + Aft;
begin
if Exp > 0 then
Len := Len + 1 + Exp;
end if;
FIXIO.Put (Buf, Item, Aft, Exp);
Aux.Put_Buf (Win, Buf, Len, False);
end Put;
procedure Put
(Item : in Num;
Fore : in Field := Default_Fore;
Aft : in Field := Default_Aft;
Exp : in Field := Default_Exp) is
begin
Put (Get_Window, Item, Fore, Aft, Exp);
end Put;
end Terminal_Interface.Curses.Text_IO.Fixed_IO;
|
AdaCore/langkit | Ada | 621 | ads | with Langkit_Support.Adalog.Main_Support;
use Langkit_Support.Adalog.Main_Support;
package Support is
use Int_Solver, Solver_Ifc;
type Transformer is new Int_Solver.Converter_Type with null record;
function Convert (Self : Transformer; Val : Integer) return Integer
is (Val * 3);
function Image (Self : Transformer) return String is ("*3");
type Pred is new Int_Solver.N_Predicate_Type with null record;
function Call (Dummy : Pred; Vals : Int_Solver.Value_Array) return Boolean
is (Vals (1) = Vals (2) * 2);
function Image (Dummy : Pred) return String is ("Is_Double_Of");
end Support;
|
MinimSecure/unum-sdk | Ada | 958 | adb | -- Copyright 2012-2016 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 A is
Nnn : String := "12345";
Www : Wide_String := "12345";
Rws : Wide_Wide_String := "12345";
begin
Do_Nothing (Nnn'Address); -- STOP
Do_Nothing (Www'Address);
Do_Nothing (Rws'Address);
end A;
|
BrickBot/Bound-T-H8-300 | Ada | 2,465 | ads | -- Version_Id (decl)
--
-- A function returning the Bound-T version, including the target
-- processor name and whether this version is open-source or
-- closed-source.
--
-- 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.3 $
-- $Date: 2015/10/29 15:00:24 $
--
-- $Log: version_id.ads,v $
-- Revision 1.3 2015/10/29 15:00:24 niklas
-- Added License.Source.Nature.
--
-- Revision 1.2 2015/10/24 19:36:53 niklas
-- Moved to free licence.
--
-- Revision 1.1 2011-08-31 04:17:14 niklas
-- Added for BT-CH-0222: Option registry. Option -dump. External help files.
--
function Version_Id return String;
--
-- The Bound-T version, including target processor name and
-- open/closed-source case.
|
SSOCsoft/Log_Reporter | Ada | 14,828 | adb | With
Ada.Tags,
Ada.Strings.Fixed,
Ada.Calendar.Formatting,
INI.Parameters,
INI.Section_to_Vector,
NSO.Types,
NSO.Helpers,
Gnoga.Types.Colors,
Gnoga.Gui.Element.Common,
Gnoga.Gui.Element.Table;
WITH
Ada.Text_IO;
with System.RPC;
with Gnoga.Gui.Element.Form;
Package Body Report_Form is
use NSO.Types, NSO.Helpers, INI.Parameters;
DEBUGGING : Constant Boolean := False;
-- For when multiple reports will be used.
Type Drop_Action is (Weather, Observation);
-- Handles the Start_Drag event.
Procedure Start_Drag (Object : in out Gnoga.Gui.Base.Base_Type'Class) is
Begin
if DEBUGGING then
Ada.Text_IO.Put_Line( "----START_DRAG----" );
end if;
End Start_Drag;
-- Handler; meant for dragging.
-- Currently unused.
procedure Do_It (Object : in out Gnoga.Gui.Base.Base_Type'Class) is
Begin
Null; -- Ada.Text_IO.Put_Line( "----DRAGGING----" );
End Do_It;
-- Handles the Drop event.
procedure Do_Drop(
Object : in out Gnoga.Gui.Base.Base_Type'Class;
X, Y : in Integer;
Drag_Text : in String
) is
Tag : String renames Ada.Tags.Expanded_Name( Object'Tag );
Begin
if DEBUGGING then
Ada.Text_IO.Put_Line( "DRAG-TEXT: " & Drag_Text );
end if;
HANDLE_ACTION:
Declare
Action : Drop_Action renames Drop_Action'Value( Drag_Text );
Begin
if DEBUGGING then
Ada.Text_IO.Put_Line( "----DROPPED "& Tag &"!!----" );
end if;
case Action is
when Weather =>
Declare
Use Gnoga.Gui.Element.Form, Gnoga.Gui.View;
Form : Form_Type'Class renames Form_Type'Class(Object);
View : My_Widget_Type'Class renames My_Widget_Type'Class(Form.Parent.all);
Begin
View.Weather_Div.Add_To_Form(Form);
End;
when Observation =>
Declare
Use Gnoga.Gui.Element.Form, Gnoga.Gui.View;
Form : Form_Type'Class renames Form_Type'Class(Object);
View : My_Widget_Type'Class renames My_Widget_Type'Class(Form.Parent.all);
Begin
View.Observation_Div.Add_To_Form(Form);
End;
end case;
End HANDLE_ACTION;
exception
when Constraint_Error => -- Undefined action / not in enumeration.
if DEBUGGING then
Ada.Text_IO.Put_Line( "Invalid action:'"&Drag_Text&"'." );
end if;
End Do_Drop;
Procedure Weather_Div(Object : in out Gnoga.Gui.Element.Common.DIV_Type;
View : in out My_Widget_Type ) is
Date : Gnoga.Gui.Element.Form.Date_Type;
Time : Gnoga.Gui.Element.Form.Time_Type;
Wind_Speed, Temperature, Seeing : Gnoga.Gui.Element.Form.Number_Type;
Conditions, Wind_Direction : Gnoga.Gui.Element.Form.Selection_Type;
Labels : Array(1..7) of Gnoga.Gui.Element.Form.Label_Type;
Procedure Add_Directions is new Add_Discrete( NSO.Types.Direction );
Procedure Add_Conditions is new Add_Discrete( NSO.Types.Sky );
Procedure Add_Label(
Label : in out Gnoga.Gui.Element.Form.Label_Type'Class;
Form : in out Gnoga.Gui.Element.Form.Form_Type'Class;
Item : in out Gnoga.Gui.Element.Element_Type'Class;
Text : String
) is
Begin
Label.Create(Form, Item, Text, Auto_Place => False);
Item.Place_Inside_Bottom_Of(Label);
End Add_Label;
Use Ada.Calendar.Formatting;
Function Time_String return String is
Use Ada.Strings.Fixed, Ada.Strings;
Time_Image : String renames Image( Ada.Calendar.Clock );
Space : Natural renames Index(Time_Image, " ", Time_Image'First);
Colon : Natural renames Index(Time_Image, ":", Time_Image'Last, Going => Backward);
Begin
Return Result : Constant String :=
Time_Image( Positive'Succ(Space)..Positive'Pred(Colon) );
End;
Function Date_String return String is
Use Ada.Strings.Fixed, Ada.Strings;
Time_Image : String renames Image( Ada.Calendar.Clock );
Space : Natural renames Index(Time_Image, " ", Time_Image'First);
Begin
Return Result : Constant String :=
Time_Image( Time_Image'First..Positive'Pred(Space) );
End;
Begin
Object.Create(View.Widget_Form, ID => "Weather");
Object.Draggable( True );
Object.On_Drag_Handler( Handler => Do_It'Access );
Object.On_Drag_Start_Handler( Drag_Text => Drop_Action'Image(Weather), Handler => Start_Drag'Access );
Object.Cursor( "grab" );
Object.Minimum_Width (Unit => "ex", Value => 40);
Object.Minimum_Height(Unit => "ex", Value => 06);
Object.Style(Name => "display", Value => "INLINE-BLOCK");
-----------------------
-- CREATE COMPONENTS --
-----------------------
Date.Create(Form => View.Widget_Form, ID => "Weather.Date", Value => Date_String);
Time.Create(Form => View.Widget_Form, ID => "Weather.Time", Value => Time_String);
Conditions.Create( View.Widget_Form, ID => "Weather.Condition" );
Wind_Direction.Create (View.Widget_Form, ID => "Weather.Wind_Direction");
Wind_Speed.Create( View.Widget_Form, ID => "Weather.Wind_Speed", Value => "0");
Wind_Speed.Maximum( 100 ); Wind_Speed.Minimum( 0 ); Wind_Speed.Step( 1 );
Temperature.Create( View.Widget_Form, ID => "Weather.Temperature", Value => "70");
Temperature.Maximum(120); Temperature.Minimum(-40); Temperature.Step(1);
Seeing.Create( View.Widget_Form, ID => "Weather.Seeing", Value => "5");
Seeing.Maximum(8); Seeing.Minimum(1); Seeing.Step(1);
-----------------
-- ADD OPTIONS --
-----------------
Add_Directions(View.Widget_Form, Wind_Direction);
Add_Conditions(View.Widget_Form, Conditions);
-------------------
-- PLACE OBJECTS --
-------------------
-- Date.Place_Inside_Top_Of( Object );
-- Time.Place_After(Date);
-- Conditions.Place_After(Time);
-- Wind_Direction.Place_After(Conditions);
-- Wind_Speed.Place_After(Wind_Direction);
-- Temperature.Place_After(Wind_Speed);
-- Seeing.Place_After(Temperature);
--------------------
-- CREATE LABELS --
--------------------
Add_Label( Labels(1), View.Widget_Form, Date, "Date:");
Add_Label( Labels(2), View.Widget_Form, Time, "Time:");
Add_Label( Labels(3), View.Widget_Form, Conditions, "Conditions:");
Add_Label( Labels(4), View.Widget_Form, Wind_Direction, "Wind Direction:");
Add_Label( Labels(5), View.Widget_Form, Wind_Speed, "Wind Speed:");
Add_Label( Labels(6), View.Widget_Form, Temperature, "Temperature:");
Add_Label( Labels(7), View.Widget_Form, Seeing, "Seeing:");
Labels(1).Place_Inside_Top_Of( Object );
For X in Positive'Succ(Labels'First)..Labels'Last loop
Labels(X).Place_After( Labels( Positive'Pred(X) ) );
end loop;
Object.Place_Inside_Bottom_Of( View.Widget_Form );
End Weather_Div;
-- Used to create our custom view
overriding
procedure Create (View : in out My_Widget_Type;
Parent : in out Gnoga.Gui.Base.Base_Type'Class;
ID : in String := "")
is
Multipart : Constant Boolean := True;
PlainText : Constant Boolean := False;
Function Encoding return Gnoga.Gui.Element.Form.Encoding_Type is
(if MultiPart then Gnoga.Gui.Element.Form.Multi_Part
elsif PlainText then Gnoga.Gui.Element.Form.Text
else Gnoga.Gui.Element.Form.URL_Encode
) with Inline, Pure_Function;
Function Drag_Here_SVG return String is
SVG_Head : Constant String :=
"<svg xmlns=""http://www.w3.org/2000/svg"" " &
"version=""1.1"" height=""3.5ex"" width=""20em"">";
Text_Head : Constant String :=
"<text x=""50%"" y=""50%"" fill=""dimgray"" font-size=""20"" " &
"dominant-baseline=""middle"" text-anchor=""middle"">";
Text_Tail : Constant String := "</text>";
SVG_Tail : Constant String := "</svg>";
Function Text( Item : String ) return String is
(Text_Head & Item & Text_Tail) with Inline;
Begin
Return SVG_Head & Text("Drag Reports Here") & SVG_Tail;
End Drag_Here_SVG;
use Gnoga.Gui.Element.Table;
Layout_Table : constant Table_Access := new Table_Type;
begin
Gnoga.Gui.View.View_Type (View).Create (Parent, ID);
View.Widget_Form.Create (View);
View.Widget_Form.On_Drop_Handler(Handler => Do_Drop'Access);
View.Widget_Form.Background_Color(if DEBUGGING then "RED" else "lightgray");
View.Widget_Form.Background_Image(
"data:image/svg+xml;utf8, " & Drag_Here_SVG
);
View.Widget_Form.Method (Value => Gnoga.Gui.Element.Form.Post);
View.Widget_Form.Encoding(Value => Encoding);
-- data:image/svg+xml;utf8, <svg xmlns='http://www.w3.org/2000/svg'><text x='50%' y='50%' fill='red'>TEST!!</text></svg>
--Drag_Here_SVG);
Layout_Table.Dynamic;
-- Marking an element Dynamic before creation tells Gnoga to garbage
-- collect, i.e. deallocate the element when it is parent is finalized.
Layout_Table.Create (View);
Layout_Table.Border("medium", Gnoga.Gui.Element.Double, Gnoga.Types.Colors.Dark_Red);
declare
Type Observation_Conditions is (Excellent, Good, Fair, Poor);
Procedure Add_Selections is new Add_Discrete(Observation_Conditions);
row : constant Table_Row_Access := new Table_Row_Type;
col1 : constant Table_Column_Access := new Table_Column_Type;
col2 : constant Table_Column_Access := new Table_Column_Type;
Operators : NSO.Types.String_Vector.Vector :=
INI.Section_to_Vector(Parameters,"Observers");
Type Categories is (fe_Name, fe_Observer, fe_Item);
Labels : Array(Categories) of Gnoga.Gui.Element.Form.Label_Type;
Division_X : Gnoga.Gui.Element.Common.DIV_Type renames
Gnoga.Gui.Element.Common.DIV_Type(View.Weather_Div);
begin
row.Dynamic;
col1.Dynamic;
col2.Dynamic;
row.Create (Layout_Table.all);
col1.Create (row.all); -- was "NAME"
col2.Create (row.all);
-- View.Name_Input.Create (Form => View.Widget_Form,
-- Size => 40,
-- Name => "Name");
-- -- The Name of the element is its variable name when submitted.
--
-- View.Name_Input.Required;
-- -- By marking Name_Input required, if the submit button is pushed
-- -- it will not allow submission and notify user unless element
-- -- if filled out.
--
-- View.Name_Input.Place_Holder ("(Only letters and spaces permitted)");
-- View.Name_Input.Pattern ("[a-zA-Z\ ]+");
-- -- Allow only a-z, A-Z and space characters
--
-- View.Name_Input.Place_Inside_Top_Of (col2.all);
-- -- Since forms are auto placed inside the Form, we need to move the
-- -- element where we would like it to display.
--
-- Labels(fe_Name).Create(View.Widget_Form, View.Name_Input, "Name:", False);
-- Labels(fe_Name).Place_Inside_Top_Of( col1.all );
---------------------------------
-- View.Stat_Input.Create(
-- -- ID =>,
-- Form => View.Widget_Form,
-- Multiple_Select => False,
-- Visible_Lines => 1,
-- Name => "Conditions"
-- );
-- Add_Selections( View.Widget_Form, View.Stat_Input );
View.Oper_Input.Create(
-- ID =>,
Form => View.Widget_Form,
Multiple_Select => False,
Visible_Lines => 1,
Name => "Observer"
);
if DEBUGGING then
Operators.Append("---DEBUG---");
end if;
Add_Vector( View.Widget_Form, View.Oper_Input,
Operators);
Labels(fe_Observer).Create(View.Widget_Form, View.Oper_Input, "Observer:", True);
view.Weather_Div.Create( view );
view.Observation_Div.Create( View );
--Division_X.Create(Parent, ID => "Weather");
--Weather_Div( Division_X, View );
end;
declare
row : constant Table_Row_Access := new Table_Row_Type;
col1 : constant Table_Column_Access := new Table_Column_Type;
col2 : constant Table_Column_Access := new Table_Column_Type;
begin
row.Dynamic;
col1.Dynamic;
col2.Dynamic;
row.Create (Layout_Table.all);
row.Style ("vertical-align", "top");
col1.Create (row.all, "Message");
col2.Create (row.all);
View.Message.Create (Form => View.Widget_Form,
Columns => (if DEBUGGING then 20 else 120),
Rows => (if DEBUGGING then 10 else 20),
Name => "Message");
View.Message.Style("background-size","100% 1.2em");
View.Message.Style("background-image",
"linear-gradient(90deg, transparent 79px, #abced4 79px, #abced4 81px, transparent 81px),"&
"linear-gradient(#eee .1em, transparent .1em)");
View.Message.Style("Wrap", "hard"); --Word_Wrap(True);
-- NOTE: This limit comes from Gnoga.Server.Connection. Within
-- Gnoga_HTTP_Content type, the Text field is defined as:
-- Aliased Strings_Edit.Streams.String_Stream (500);
View.Message.Attribute("maxlength", "4000" );
View.Message.Place_Inside_Top_Of (col2.all);
end;
View.My_Submit.Create (Form => View.Widget_Form, Value => "Submit");
View.My_Submit.Place_After (Layout_Table.all);
end Create;
End Report_Form;
|
reznikmm/matreshka | Ada | 6,542 | 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.CMOF.Elements.Collections;
with AMF.CMOF.Named_Elements;
with AMF.CMOF.Namespaces;
with AMF.CMOF.Opaque_Expressions;
with AMF.Internals.CMOF_Value_Specifications;
with AMF.String_Collections;
with AMF.Visitors;
package AMF.Internals.CMOF_Opaque_Expressions is
type CMOF_Opaque_Expression_Proxy is
limited new AMF.Internals.CMOF_Value_Specifications.CMOF_Value_Specification_Proxy
and AMF.CMOF.Opaque_Expressions.CMOF_Opaque_Expression
with null record;
-- XXX These subprograms are stubs
overriding function All_Owned_Elements
(Self : not null access constant CMOF_Opaque_Expression_Proxy)
return AMF.CMOF.Elements.Collections.Set_Of_CMOF_Element;
overriding function Get_Qualified_Name
(Self : not null access constant CMOF_Opaque_Expression_Proxy)
return Optional_String;
overriding function Is_Distinguishable_From
(Self : not null access constant CMOF_Opaque_Expression_Proxy;
N : AMF.CMOF.Named_Elements.CMOF_Named_Element_Access;
Ns : AMF.CMOF.Namespaces.CMOF_Namespace_Access)
return Boolean;
overriding function Is_Computable
(Self : not null access constant CMOF_Opaque_Expression_Proxy)
return Boolean;
overriding function Integer_Value
(Self : not null access constant CMOF_Opaque_Expression_Proxy)
return Integer;
overriding function Boolean_Value
(Self : not null access constant CMOF_Opaque_Expression_Proxy)
return Boolean;
overriding function String_Value
(Self : not null access constant CMOF_Opaque_Expression_Proxy)
return League.Strings.Universal_String;
overriding function Unlimited_Value
(Self : not null access constant CMOF_Opaque_Expression_Proxy)
return Unlimited_Natural;
overriding function Is_Null
(Self : not null access constant CMOF_Opaque_Expression_Proxy)
return Boolean;
overriding function Get_Body
(Self : not null access constant CMOF_Opaque_Expression_Proxy)
return AMF.String_Collections.Sequence_Of_String;
overriding function Get_Language
(Self : not null access constant CMOF_Opaque_Expression_Proxy)
return AMF.String_Collections.Ordered_Set_Of_String;
overriding procedure Enter_Element
(Self : not null access constant CMOF_Opaque_Expression_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 CMOF_Opaque_Expression_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 CMOF_Opaque_Expression_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.CMOF_Opaque_Expressions;
|
reznikmm/matreshka | Ada | 4,695 | 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.String_Value_Phonetic_Attributes is
------------
-- Create --
------------
overriding function Create
(Parameters : not null access Matreshka.DOM_Attributes.Attribute_L2_Parameters)
return Text_String_Value_Phonetic_Attribute_Node is
begin
return Self : Text_String_Value_Phonetic_Attribute_Node do
Matreshka.ODF_Text.Constructors.Initialize
(Self'Unchecked_Access,
Parameters.Document,
Matreshka.ODF_String_Constants.Text_Prefix);
end return;
end Create;
--------------------
-- Get_Local_Name --
--------------------
overriding function Get_Local_Name
(Self : not null access constant Text_String_Value_Phonetic_Attribute_Node)
return League.Strings.Universal_String
is
pragma Unreferenced (Self);
begin
return Matreshka.ODF_String_Constants.String_Value_Phonetic_Attribute;
end Get_Local_Name;
begin
Matreshka.DOM_Documents.Register_Attribute
(Matreshka.ODF_String_Constants.Text_URI,
Matreshka.ODF_String_Constants.String_Value_Phonetic_Attribute,
Text_String_Value_Phonetic_Attribute_Node'Tag);
end Matreshka.ODF_Text.String_Value_Phonetic_Attributes;
|
strenkml/EE368 | Ada | 65 | ads |
package Test.Cache is
procedure Run_Tests;
end Test.Cache;
|
charlie5/lace | Ada | 3,009 | adb | with
eGL.Binding,
Swig,
interfaces.C.Strings,
System;
procedure launch_egl_linkage_Test
--
-- Tests linkage to eGL functions.
-- Is not meant to be run.
--
is
use eGL,
eGL.Binding,
System;
an_EGLint : EGLint;
an_EGLdisplay : EGLdisplay;
an_EGLboolean : EGLboolean;
an_EGLsurface : EGLsurface;
an_EGLcontext : EGLcontext;
a_chars_ptr : interfaces.C.strings.chars_ptr;
a_void_ptr : swig.void_ptr;
an_EGLdisplay_pointer : access EGLdisplay;
begin
an_EGLint := eglGetError;
an_EGLdisplay := eglGetDisplay (null);
an_EGLboolean := eglInitialize (null_Address, null, null);
an_EGLboolean := eglTerminate (null_Address);
a_chars_ptr := eglQueryString (null_Address, 0);
an_EGLboolean := eglGetConfigs (null_Address, null, 0, null);
an_EGLboolean := eglChooseConfig (null_Address, null, null, 0, null);
an_EGLboolean := eglGetConfigAttrib (null_Address, null_Address, 0, null);
an_EGLsurface := eglCreateWindowSurface (null_Address, null_Address, 0, null);
an_EGLsurface := eglCreatePbufferSurface (null_Address, null_Address, null);
an_EGLsurface := eglCreatePixmapSurface (null_Address, null_Address, 0, null);
an_EGLboolean := eglDestroySurface (null_Address, null_Address);
an_EGLboolean := eglQuerySurface (null_Address, null_Address, 0, null);
an_EGLboolean := eglBindAPI (0);
an_EGLboolean := eglQueryAPI;
an_EGLboolean := eglWaitClient;
an_EGLboolean := eglReleaseThread;
an_EGLsurface := eglCreatePbufferFromClientBuffer
(null_Address, 0, null_Address, null_Address, null);
an_EGLboolean := eglSurfaceAttrib (null_Address, null_Address, 0, 0);
an_EGLboolean := eglBindTexImage (null_Address, null_Address, 0);
an_EGLboolean := eglReleaseTexImage (null_Address, null_Address, 0);
an_EGLboolean := eglSwapInterval (null_Address, 0);
an_EGLcontext := eglCreateContext (null_Address, null_Address, null_Address, null);
an_EGLboolean := eglDestroyContext (null_Address, null_Address);
an_EGLboolean := eglMakeCurrent (null_Address, null_Address, null_Address, null_Address);
an_EGLcontext := eglGetCurrentContext;
an_EGLsurface := eglGetCurrentSurface (0);
an_EGLdisplay := eglGetCurrentDisplay;
an_EGLboolean := eglQueryContext (null_Address, null_Address, 0, null);
an_EGLboolean := eglWaitGL;
an_EGLboolean := eglWaitNative (0);
an_EGLboolean := eglSwapBuffers (null_Address, null_Address);
an_EGLboolean := eglCopyBuffers (null_Address, null_Address, 0);
a_void_ptr := eglGetProcAddress (Interfaces.C.Strings.null_ptr);
an_EGLdisplay_pointer
:= egl_DEFAULT_DISPLAY;
an_EGLcontext := egl_NO_CONTEXT;
an_EGLdisplay := egl_NO_DISPLAY;
an_EGLsurface := egl_NO_SURFACE;
an_EGLint := egl_DONT_CARE;
end launch_egl_linkage_Test;
|
leo-brewin/ada-lapack | Ada | 3,111 | ads | generic
package Ada_Lapack.Extras is
----------------------------------------------------------------------------------
-- Some extra procedures built upon the Lapack routines.
-- determinants of a square marix ------------------------------------------------
function MatrixDeterm (Source : Real_Matrix) return Real;
function MatrixDeterm (Source : Complex_Matrix) return Complex;
-- eigenvalues of a square matrix ------------------------------------------------
function Eigenvalues (Source : Real_Matrix) return Complex_vector;
function Eigenvalues (Source : Complex_Matrix) return Complex_vector;
function EigenvaluesRealSymm (Source : Real_Matrix) return Real_Vector;
function EigenvaluesHermSymm (Source : Complex_Matrix) return Real_Vector;
-- eigenvalues and (right) eigenvectors of a square matrix -----------------------
procedure Eigensystem (Source : Real_Matrix;
Eigenvalues : out Complex_Vector;
Eigenvectors : out Complex_Matrix);
procedure Eigensystem (Source : Complex_Matrix;
Eigenvalues : out Complex_Vector;
Eigenvectors : out Complex_Matrix);
procedure EigensystemRealSymm (Source : Real_Matrix;
Eigenvalues : out Real_Vector;
Eigenvectors : out Real_Matrix);
procedure EigensystemHermSymm (Source : Complex_Matrix;
Eigenvalues : out Real_Vector;
Eigenvectors : out Complex_Matrix);
-- inverse of a square matrix ----------------------------------------------------
function MatrixInverse (Source : Real_Matrix) return Real_Matrix;
function MatrixInverse (Source : Complex_Matrix) return Complex_Matrix;
-- solutions of linear systems of equations --------------------------------------
function SolveSystem (Source_mat : Real_Matrix;
Source_rhs : Real_Vector) return Real_Vector;
function SolveSystem (Source_mat : Complex_Matrix;
Source_rhs : Complex_Vector) return Complex_Vector;
function SolveSystem (Source_mat : Real_Matrix;
Source_rhs : Real_Matrix) return Real_Matrix;
function SolveSystem (Source_mat : Complex_Matrix;
Source_rhs : Complex_Matrix) return Complex_Matrix;
function SolveSystemRealSymm (Source_mat : Real_Matrix;
Source_rhs : Real_Matrix) return Real_Matrix;
function SolveSystemHermSymm (Source_mat : Complex_Matrix;
Source_rhs : Complex_Matrix) return Complex_Matrix;
procedure SolveSystem
(Solution : out Real_Vector;
Source_mat : Real_Matrix;
Source_rhs : Real_Vector;
Size : Integer);
procedure SolveSystem
(Solution : out Complex_Vector;
Source_mat : Complex_Matrix;
Source_rhs : Complex_Vector;
Size : Integer);
end Ada_Lapack.Extras;
|
zhmu/ananas | Ada | 177 | adb | package body Generic_Inst12_Pkg1 is
procedure Inner_G (Val : T) is
begin
null;
end;
procedure Proc (Val : T) is
begin
null;
end;
end Generic_Inst12_Pkg1;
|
jorge-real/TTS-Runtime-Ravenscar | Ada | 11,522 | adb | with Ada.Real_Time; use Ada.Real_Time;
with Ada.Text_IO; use Ada.Text_IO;
with System; use System;
with Epoch_Support; use Epoch_Support;
with XAda.Dispatching.TTS;
with TT_Utilities;
with TT_Patterns;
package body TTS_Example_C is
Number_Of_Work_Ids : constant := 4;
Number_Of_Sync_Ids : constant := 2;
package TTS is new XAda.Dispatching.TTS
(Number_Of_Work_Ids, Number_Of_Sync_Ids, Priority'Last - 1);
package TT_Util is new TT_Utilities (TTS);
use TT_Util;
package TT_Patt is new TT_Patterns (TTS);
use TT_Patt;
-- Auxiliary for printing absolute times with respect to plan/cycle --
function Time_Str (T : Time) return String is
(Duration'Image ( To_Duration (T - TTS.Get_First_Plan_Release) * 1000) & " ms " &
"|" & Duration'Image ( To_Duration (T - TTS.Get_Last_Plan_Release) * 1000) & " ms ");
-- TT tasks --
-- Modular types to use cyclic phase counters. Each phase is a section of
-- the plan where we use a particular type of ending slot to measure jitter
-- in the next starting slot.
-- Ending slot types are empty, mode change, regular, sync, optional
-- and a continuation slot that requires holding. Starting slots are regular,
-- optional and sync.
type Mod_12 is mod 12;
type Mod_6 is mod 6;
type Stats_Data is
record
N : Natural := 0; -- Sample size so far
Max : Duration := 0.0; -- Maximum measured value
Min : Duration := Duration'Last; -- Minimum measured value
Avg : Duration := 0.0; -- Average
end record;
type Reg_Opt_Cases is array (Mod_12) of Stats_Data;
type Sync_Cases is array (Mod_6) of Stats_Data;
-- Stats data for all cases measured by task with this state.
-- Positions 0 to 11 of the array contain the stats data for the
-- following cases, respectively:
-- 0 => Em_Re; 1 => Em_Op;
-- 2 => Mo_Re; 3 => Mo_Op;
-- 4 => Re_Re; 5 => Re_Op;
-- 6 => Sy_Re; 7 => Sy_Op;
-- 8 => Op_Re; 9 => Op_Op
-- 10 => Ho_Re; 11 => Ho_Op;
--
-- Legend: Em = Empty; Re = Regular; Sy = Sync; M = Mode change
-- Op = Optional; Ho = Cont. with hold
--
RO_Data : Reg_Opt_Cases;
-- Stats data for cases measurted by sync task
Sy_Data : Sync_Cases;
-- State type for the task measuring jitter of regular and optional slots
type Reg_Opt_Task_State is new Simple_Task_State with
record
-- Cyclic counter for number of activation
Act_Counter : Mod_12 := 0;
end record;
procedure Initialize (S : in out Reg_Opt_Task_State) is null;
procedure Main_Code (S : in out Reg_Opt_Task_State);
type Any_Reg_Opt_Task_State is access all Reg_Opt_Task_State;
W1_State : aliased Reg_Opt_Task_State;
-- Worker 1: measures jitter of regular and optional slots
W1 : Simple_TT_Task
(Work_Id => 1, Task_State => W1_State'Access, Synced_Init => False);
procedure Main_Code (S : in out Reg_Opt_Task_State) is
Jitter : Duration;
D : Stats_Data; -- Stats data for the current phase
begin
Jitter := To_Duration (Clock - S.Release_Time);
D := RO_Data (S.Act_Counter);
-- One more sample
D.N := D.N + 1;
-- Calculate average
D.Avg := (D.Avg * (D.N - 1) + Jitter) / D.N;
-- Update Max
if Jitter > D.Max then
D.Max := Jitter;
end if;
-- Update Min
if Jitter < D.Min then
D.Min := Jitter;
end if;
RO_Data (S.Act_Counter) := D;
S.Act_Counter := S.Act_Counter + 1;
end Main_Code;
-- State type for auxiliary task has null initialisation and main code
type Aux_Task_State is new Simple_Task_State with null record;
procedure Initialize (S : in out Aux_Task_State) is null;
procedure Main_Code (S : in out Aux_Task_State) is null;
type Any_Aux_Task_State is access all Aux_Task_State;
W2_State : aliased Aux_Task_State;
-- Worker 2 is an auxiliary simple task with no actions
W2 : Simple_TT_Task
(Work_Id => 2, Task_State => W2_State'Access, Synced_Init => False);
type Synced_State is new Simple_Task_State with
record
Act_Counter : Mod_6 := 0;
end record;
procedure Initialize (S : in out Synced_State) is null;
procedure Main_Code (S: in out Synced_State);
S1_State : aliased Synced_State;
-- Synced task to measure jitter of sync slots
S1 : Simple_Synced_ET_Task
(Sync_Id => 1, Task_State => S1_State'Access, Synced_Init => False);
procedure Main_Code (S : in out Synced_State) is
Jitter : Duration;
D : Stats_Data;
begin
Jitter := To_Duration (Clock - S.Release_Time);
D := Sy_Data (S.Act_Counter);
-- One more sample
D.N := D.N + 1;
-- Calculate average
D.Avg := (D.Avg * (D.N - 1) + Jitter) / D.N;
-- Update Max
if Jitter > D.Max then
D.Max := Jitter;
end if;
-- Update Min
if Jitter < D.Min then
D.Min := Jitter;
end if;
Sy_Data (S.Act_Counter) := D;
S.Act_Counter := S.Act_Counter + 1;
end Main_Code;
S2_State: aliased Aux_Task_State;
-- Synced 2 is an auxiliary Synced task with null actions
S2 : Simple_Synced_ET_Task
(Sync_Id => 2, Task_State => S2_State'Access, Synced_Init => False);
type Aux_Sliced_Task_State is new Simple_Task_State with null record;
procedure Initialize (S : in out Aux_Sliced_Task_State) is null;
procedure Main_Code (S : in out Aux_Sliced_Task_State);
W3_State : aliased Aux_Sliced_Task_State;
-- Worker 3 is an auxiliary sliced task to causee "held" ending slots
W3 : Simple_TT_Task
(Work_Id => 3, Task_State => W3_State'Access, Synced_Init => False);
-- To make sliced task busy wait for a given time
procedure Main_Code (S : in out Aux_Sliced_Task_State) is
-- CPU time taken by main code of task = 1.5 slots for 10 ms slots
CPU_Interval : constant Time_Span := Milliseconds (15);
begin
loop
exit when Clock - S.Release_Time >= CPU_Interval;
end loop;
end Main_Code;
type Report_Task_State is new Simple_Task_State with null record;
procedure Initialize (S : in out Report_Task_State) is null;
procedure Main_Code (S : in out Report_Task_State);
W4_State : aliased Report_Task_State;
-- Worker 4 takes the final slot in the plan to print stats results
W4 : Simple_TT_Task
(Work_Id => 4, Task_State => W4_State'Access, Synced_Init => False);
type RO_Text_Labels is array (Mod_12) of String (1..2);
RO_Label : RO_Text_Labels := ("ER", "EO",
"MR", "MO",
"RR", "RO",
"SR", "SO",
"OR", "OO",
"HR", "HO");
type Sy_Text_Labels is array (Mod_6) of String (1..2);
Sy_Label : Sy_Text_Labels := ("ES", "MS", "RS", "SS", "OS", "HS");
-- Global max and min
G_Max : Duration := 0.0;
G_Min : Duration := Duration'Last;
procedure Main_Code (S : in out Report_Task_State) is
Max : Duration := 0.0;
Min : Duration := Duration'Last;
begin
Put_Line (" -------- Times in milliseconds -------");
Put_Line ("| Tr Max Avg Min |");
Put_Line (" --------------------------------------");
for I in Mod_12 loop
Put (RO_Label(I) & ":" &
Duration'Image (RO_Data (I).Max * 1_000.0) &
Duration'Image (RO_Data (I).Avg * 1_000.0) &
Duration'Image (RO_Data (I).Min * 1_000.0));
New_Line;
if RO_Data (I).Max > Max then
Max := RO_Data (I).Max;
end if;
if RO_Data (I).Min < Min then
Min := RO_Data (I).Min;
end if;
end loop;
New_Line;
for I in Mod_6 loop
Put (Sy_Label (I) & ": " &
Duration'Image (Sy_Data (I).Max * 1_000.0) &
Duration'Image (Sy_Data (I).Avg * 1_000.0) &
Duration'Image (Sy_Data (I).Min * 1_000.0));
New_Line;
if Sy_Data (I).Max > Max then
Max := Sy_Data (I).Max;
end if;
if Sy_Data (I).Min < Min then
Min := Sy_Data (I).Min;
end if;
end loop;
New_Line;
Put_Line (" Max =" & Duration'Image (Max * 1_000.0) &
" Min =" & Duration'Image (Min * 1_000.0));
if G_Max < Max then
G_Max := Max;
end if;
if G_Min > Min then
G_Min := Min;
end if;
Put_Line ("GMax =" & Duration'Image (G_Max * 1_000.0) &
" GMin =" & Duration'Image (G_Min * 1_000.0));
Put_Line (" --------------------------------------");
New_Line;
New_Line;
end Main_Code;
ms : constant Time_Span := Milliseconds (1);
-- The TT plan
TT_Plan : aliased TTS.Time_Triggered_Plan :=
( TT_Slot (Empty, 10*ms ), -- #00
TT_Slot (Regular, 10*ms, 1), -- #01
TT_Slot (Empty, 10*ms ), -- #02
TT_Slot (Optional, 10*ms, 1), -- #03
TT_Slot (Empty, 10*ms ), -- #04
TT_Slot (Sync, 10*ms, 1), -- #05
TT_Slot (Mode_Change, 10*ms ), -- #06
TT_Slot (Regular, 10*ms, 1), -- #07
TT_Slot (Mode_Change, 10*ms ), -- #08
TT_Slot (Optional, 10*ms, 1), -- #09
TT_Slot (Mode_Change, 10*ms ), -- #10
TT_Slot (Sync, 10*ms, 1), -- #11
TT_Slot (Regular, 10*ms, 2), -- #12
TT_Slot (Regular, 10*ms, 1), -- #13
TT_Slot (Regular, 10*ms, 2), -- #14
TT_Slot (Optional, 10*ms, 1), -- #15
TT_Slot (Regular, 10*ms, 2), -- #16
TT_Slot (Sync, 10*ms, 1), -- #17
TT_Slot (Sync, 10*ms, 2), -- #18
TT_Slot (Regular, 10*ms, 1), -- #19
TT_Slot (Sync, 10*ms, 2), -- #20
TT_Slot (Optional, 10*ms, 1), -- #21
TT_Slot (Sync, 10*ms, 2), -- #22
TT_Slot (Sync, 10*ms, 1), -- #23
TT_Slot (Optional, 10*ms, 2), -- #24
TT_Slot (Regular, 10*ms, 1), -- #25
TT_Slot (Optional, 10*ms, 2), -- #26
TT_Slot (Optional, 10*ms, 1), -- #27
TT_Slot (Optional, 10*ms, 2), -- #28
TT_Slot (Sync, 10*ms, 1), -- #29
TT_Slot (Continuation, 10*ms, 3), -- #30
TT_Slot (Regular, 10*ms, 1), -- #31
TT_Slot (Terminal, 10*ms, 3), -- #32
TT_Slot (Continuation, 10*ms, 3), -- #33
TT_Slot (Optional, 10*ms, 1), -- #34
TT_Slot (Terminal, 10*ms, 3), -- #35
TT_Slot (Continuation, 10*ms, 3), -- #36
TT_Slot (Sync, 10*ms, 1), -- #37
TT_Slot (Terminal, 10*ms, 3), -- #38
TT_Slot (Regular, 10*ms, 4)); -- #39
procedure Main is
begin
delay until Epoch_Support.Epoch;
TTS.Set_Plan (TT_Plan'Access);
delay until Ada.Real_Time.Time_Last;
end Main;
end TTS_Example_C;
|
charlie5/cBound | Ada | 1,760 | ads | -- This file is generated by SWIG. Please do not modify by hand.
--
with Interfaces;
with swig;
with Interfaces.C;
with Interfaces.C.Pointers;
package xcb.xcb_render_query_version_reply_t is
-- Item
--
type Item is record
response_type : aliased Interfaces.Unsigned_8;
pad0 : aliased Interfaces.Unsigned_8;
sequence : aliased Interfaces.Unsigned_16;
length : aliased Interfaces.Unsigned_32;
major_version : aliased Interfaces.Unsigned_32;
minor_version : aliased Interfaces.Unsigned_32;
pad1 : aliased swig.int8_t_Array (0 .. 15);
end record;
-- Item_Array
--
type Item_Array is
array
(Interfaces.C
.size_t range <>) of aliased xcb.xcb_render_query_version_reply_t
.Item;
-- Pointer
--
package C_Pointers is new Interfaces.C.Pointers
(Index => Interfaces.C.size_t,
Element => xcb.xcb_render_query_version_reply_t.Item,
Element_Array => xcb.xcb_render_query_version_reply_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_reply_t
.Pointer;
-- Pointer_Pointer
--
package C_Pointer_Pointers is new Interfaces.C.Pointers
(Index => Interfaces.C.size_t,
Element => xcb.xcb_render_query_version_reply_t.Pointer,
Element_Array => xcb.xcb_render_query_version_reply_t.Pointer_Array,
Default_Terminator => null);
subtype Pointer_Pointer is C_Pointer_Pointers.Pointer;
end xcb.xcb_render_query_version_reply_t;
|
reznikmm/matreshka | Ada | 3,699 | 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_Embedded_Text_Elements is
pragma Preelaborate;
type ODF_Number_Embedded_Text is limited interface
and XML.DOM.Elements.DOM_Element;
type ODF_Number_Embedded_Text_Access is
access all ODF_Number_Embedded_Text'Class
with Storage_Size => 0;
end ODF.DOM.Number_Embedded_Text_Elements;
|
Subsets and Splits
No saved queries yet
Save your SQL queries to embed, download, and access them later. Queries will appear here once saved.