repo_name
stringlengths 9
74
| language
stringclasses 1
value | length_bytes
int64 11
9.34M
| extension
stringclasses 2
values | content
stringlengths 11
9.34M
|
---|---|---|---|---|
AdaCore/gpr | Ada | 30 | ads | package C is
null;
end C;
|
AdaCore/libadalang | Ada | 154 | adb | limited with Ada.Text_IO;
procedure Foo is
function "+" (S : String) return String is (S);
begin
Ada.Text_IO.Put_Line (+"Hello, world!");
end Foo;
|
Holt59/Ada-SDL | Ada | 5,449 | adb | --------------------------------------------
-- --
-- PACKAGE GAME - PARTIE ADA --
-- --
-- GAME.ADB --
-- --
-- Gestion des outils de base --
-- --
-- Créateur : CAPELLE Mikaël --
-- Adresse : [email protected] --
-- --
-- Dernière modification : 14 / 06 / 2011 --
-- --
--------------------------------------------
with Interfaces.C; use Interfaces.C;
with Ada.Exceptions; use Ada.Exceptions;
with Game.Gtype; use Game.Gtype;
with Interfaces.C.Pointers;
with Ada.Strings.Unbounded;
package body Game is
------------
-- ADJUST --
------------
function C_Convert_Surf (S : in SDL_Surface;
HW : in Int) return SDL_Surface;
pragma Import(C,C_Convert_Surf,"convert_surface");
procedure Adjust (S : in out Surface) is
begin
if S.Surf /= Null_SDL_Surface and S.Surf /= C_Screen then
S.Surf := C_Convert_Surf (S.Surf, 1);
end if;
end Adjust;
-----------------
-- CHANGE_ICON --
-----------------
procedure C_SetIcon_Surf(S : in SDL_Surface);
pragma Import(C,C_SetIcon_Surf,"change_icon_surface");
procedure C_SetIcon_String(S : in Char_Array);
pragma Import(C,C_SetIcon_String,"change_icon_string");
procedure Change_Icon(Name : in String) is
begin
C_SetIcon_String(To_C(Name));
end Change_Icon;
procedure Change_Icon(Surf : in Surface) is
begin
C_SetIcon_Surf(Surf.Surf);
end Change_Icon;
--------------
-- FINALIZE --
--------------
procedure Finalize (S : in out Surface) is
begin
if S.Surf /= Null_SDL_Surface and S.Surf /= C_Screen then
Free_Surface(S);
end if;
end Finalize;
------------------
-- FREE_SURFACE --
------------------
procedure C_Free_Surface(S : in SDL_Surface);
pragma Import (C,C_Free_Surface,"free_surface");
procedure Free_Surface(S : in out Surface) is
begin
if S.Surf /= Null_SDL_Surface and S.Surf /= C_Screen then
C_Free_Surface(S.Surf);
S.Surf := null;
end if;
end Free_Surface;
----------
-- INIT --
----------
----------------------
-- T : Timer --
-- V : Video --
-- A : Audio --
-- C : Cdrom --
-- J : Joystick --
-- TTF : Font --
-- E : Everything --
-- F : ... --
----------------------
function C_Init(T,V,A,C,J,TTF,E,F : in Int) return Int;
pragma Import(C,C_Init,"init");
procedure Init(Timer : in Boolean := True;
Video : in Boolean := True;
Audio : in Boolean := True;
Font : in Boolean := True;
Frequency : in Positive := 44100) is
T : Int := 0;
V : Int := 0;
A : Int := 0;
TTF : Int := 0;
Result : Int := 0;
begin
if Timer then T := 1; end if;
if Video then V := 1; end if;
if Audio then A := 1; end if;
if Font then TTF := 1; end if;
Result := c_Init(T,V,A,0,0,TTF,0,Int(Frequency));
if Result = -1 then
Ada.Exceptions.Raise_Exception(Init_Error'Identity,"Erreur d'initialisation du module Game : " & Game.Error);
elsif Result = -2 then
Ada.Exceptions.Raise_Exception(Init_Error'Identity,"Erreur d'initialisation du module Font : " & Game.Error);
elsif Result = -3 then
Ada.Exceptions.Raise_Exception(Init_Error'Identity,"Erreur d'initialisation du module Audio : " & Game.Error);
end if;
end Init;
----------------
-- INITIALIZE --
----------------
procedure Initialize (S : in out Surface) is
begin
S.Surf := Null_SDL_Surface;
end Initialize;
---------------
-- SET_TITLE --
---------------
procedure C_Set_Title(S : in Char_Array);
pragma Import(C,C_Set_Title,"change_title");
procedure Change_Title(Name : in String) is
begin
C_Set_Title(To_C(Name));
end Change_Title;
----------
-- QUIT --
----------
procedure C_Quit;
pragma Import(C,C_Quit,"quit");
procedure Quit is
begin
C_Quit;
end Quit;
------------
-- ERRORS --
------------
package Char_Ptrs is
new Interfaces.C.Pointers (Index => Interfaces.C.Size_T,
Element => Interfaces.C.Char,
Element_Array => Interfaces.C.Char_Array,
Default_Terminator => Interfaces.C.Nul);
use Ada.Strings.Unbounded;
-- Types :
-- 1 - SDL
-- 2 - SDL_image
-- 3 - SDL_ttf
-- 4 - SDL_mixer
procedure Set_Error(S : in Char_Array; Typ : in Int);
pragma Import(C,Set_Error,"set_error");
function Get_Error(Typ : in Int) return Char_Ptrs.Pointer;
pragma Import(C,Get_Error,"get_error");
function Error return String is
Tmp : Unbounded_String;
begin
for T in 1..4 loop
Tmp := To_Unbounded_String(To_Ada(Char_Ptrs.Value(Get_Error(Int(T)))));
if Tmp /= "" then
Set_Error(To_C(""),Int(T));
exit;
end if;
end loop;
return To_String(Tmp);
end Error;
end Game;
|
AdaCore/gpr | Ada | 45 | adb | pragma No_Body;
-- Parsing should fail here. |
reznikmm/matreshka | Ada | 9,071 | ads | ------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- Web Framework --
-- --
-- Web API Definition --
-- --
------------------------------------------------------------------------------
-- --
-- Copyright © 2014-2015, Vadim Godunko <[email protected]> --
-- All rights reserved. --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions --
-- are met: --
-- --
-- * Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- --
-- * Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in the --
-- documentation and/or other materials provided with the distribution. --
-- --
-- * Neither the name of the Vadim Godunko, IE nor the names of its --
-- contributors may be used to endorse or promote products derived from --
-- this software without specific prior written permission. --
-- --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR --
-- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
-- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED --
-- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR --
-- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF --
-- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING --
-- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS --
-- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
-- --
------------------------------------------------------------------------------
-- $Revision$ $Date$
------------------------------------------------------------------------------
-- This package provides binding to interface Event as defined by DOM Level 4
-- specification.
------------------------------------------------------------------------------
limited with WebAPI.DOM.Event_Targets;
package WebAPI.DOM.Events is
pragma Preelaborate;
type Event is limited interface;
not overriding function Get_Event_Type
(Self : not null access constant Event)
return WebAPI.DOM_String is abstract
with Import => True,
Convention => JavaScript_Property_Getter,
Link_Name => "type";
-- The name of the event (case-insensitive). The name must be an XML name.
not overriding function Get_Target
(Self : not null access constant Event)
return WebAPI.DOM.Event_Targets.Event_Target_Access is abstract
with Import => True,
Convention => JavaScript_Property_Getter,
Link_Name => "target";
-- Used to indicate the EventTarget to which the event was originally
-- dispatched.
not overriding function Get_Current_Target
(Self : not null access constant Event)
return WebAPI.DOM.Event_Targets.Event_Target_Access is abstract
with Import => True,
Convention => JavaScript_Property_Getter,
Link_Name => "currentTarget";
-- Used to indicate the EventTarget whose EventListeners are currently
-- being processed. This is particularly useful during capturing and
-- bubbling.
not overriding function Get_Event_Phase
(Self : not null access constant Event)
return WebAPI.DOM.Event_Phases is abstract
with Import => True,
Convention => JavaScript_Property_Getter,
Link_Name => "eventPhase";
-- Returns the event's phase, which is one of NONE, CAPTURING_PHASE,
-- AT_TARGET, and BUBBLING_PHASE.
not overriding procedure Stop_Propagation
(Self : not null access Event) is abstract
with Import => True,
Convention => JavaScript_Method,
Link_Name => "stopPropagation";
-- The stopPropagation method is used prevent further propagation of an
-- event during event flow. If this method is called by any EventListener
-- the event will cease propagating through the tree. The event will
-- complete dispatch to all listeners on the current EventTarget before
-- event flow stops. This method may be used during any stage of event
-- flow.
not overriding procedure Stop_Immediate_Propagation
(Self : not null access Event) is abstract
with Import => True,
Convention => JavaScript_Method,
Link_Name => "stopImmediatePropagation()";
-- Invoking this method prevents event from reaching any registered event
-- listeners after the current one finishes running and, when dispatched in
-- a tree, also prevents event from reaching any other objects.
not overriding function Bubbles
(Self : not null access constant Event) return Boolean is abstract
with Import => True,
Convention => JavaScript_Property_Getter,
Link_Name => "bubbles";
-- Used to indicate whether or not an event is a bubbling event. If the
-- event can bubble the value is true, else the value is false.
not overriding function Cancelable
(Self : not null access constant Event) return Boolean is abstract
with Import => True,
Convention => JavaScript_Property_Getter,
Link_Name => "cancelable";
-- Used to indicate whether or not an event can have its default action
-- prevented. If the default action can be prevented the value is true,
-- else the value is false.
not overriding procedure Prevent_Default
(Self : not null access Event) is abstract
with Import => True,
Convention => JavaScript_Method,
Link_Name => "preventDefault";
-- If an event is cancelable, the preventDefault method is used to signify
-- that the event is to be canceled, meaning any default action normally
-- taken by the implementation as a result of the event will not occur.
-- If, during any stage of event flow, the preventDefault method is called
-- the event is canceled. Any default action associated with the event
-- will not occur. Calling this method for a non - cancelable event has no
-- effect. Once preventDefault has been called it will remain in effect
-- throughout the remainder of the event's propagation. This method may be
-- used during any stage of event flow.
not overriding function Get_Default_Prevented
(Self : not null access constant Event) return Boolean is abstract
with Import => True,
Convention => JavaScript_Property_Getter,
Link_Name => "defaultPrevented";
-- Returns true if preventDefault() was invoked while the cancelable
-- attribute value is true, and false otherwise.
not overriding function Get_Is_Trusted
(Self : not null access constant Event) return Boolean is abstract
with Import => True,
Convention => JavaScript_Property_Getter,
Link_Name => "isTrusted";
-- Returns true if event was dispatched by the user agent, and false
-- otherwise.
not overriding function Get_Time_Stamp
(Self : not null access constant Event)
return WebAPI.DOM_Time_Stamp is abstract
with Import => True,
Convention => JavaScript_Property_Getter,
Link_Name => "timeStamp";
-- Returns the creation time of event as the number of milliseconds that
-- passed since 00:00:00 UTC on 1 January 1970.
end WebAPI.DOM.Events;
|
faelys/natools | Ada | 1,955 | ads | ------------------------------------------------------------------------------
-- Copyright (c) 2013, Natacha Porté --
-- --
-- Permission to use, copy, modify, and distribute this software for any --
-- purpose with or without fee is hereby granted, provided that the above --
-- copyright notice and this permission notice appear in all copies. --
-- --
-- THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES --
-- WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF --
-- MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR --
-- ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES --
-- WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN --
-- ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF --
-- OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. --
------------------------------------------------------------------------------
------------------------------------------------------------------------------
-- Natools.References.Tools exposes subprograms to peek into private parts --
-- of Natools.Reference, for debug or testing purposes. --
------------------------------------------------------------------------------
generic
package Natools.References.Tools is
pragma Preelaborate (Tools);
function Is_Consistent (Left, Right : Reference) return Boolean;
-- Check that counter and data equality are consistent
function Is_Valid (Ref : Reference) return Boolean;
-- Check consistency for internal state
function Count (Ref : Reference) return Natural;
-- Return the number of references to held object
end Natools.References.Tools;
|
MinimSecure/unum-sdk | Ada | 1,664 | adb | -- Copyright 2012-2019 Free Software Foundation, Inc.
--
-- This program is free software; you can redistribute it and/or modify
-- it under the terms of the GNU General Public License as published by
-- the Free Software Foundation; either version 3 of the License, or
-- (at your option) any later version.
--
-- This program is distributed in the hope that it will be useful,
-- but WITHOUT ANY WARRANTY; without even the implied warranty of
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-- GNU General Public License for more details.
--
-- You should have received a copy of the GNU General Public License
-- along with this program. If not, see <http://www.gnu.org/licenses/>.
with Pck; use Pck;
procedure Foo is
type Table is array (Positive range <>) of Integer;
type Table_Access is access Table;
type Object (N : Integer) is record
Ptr : Table_Access;
Data : Table (1 .. N);
end record;
My_Object : Object := (N => 3, Ptr => null, Data => (3, 5, 8));
-- Same as above, but with a pointer to an unconstrained packed array.
type Byte is range 0 .. 255;
type P_Table is array (Positive range <>) of Byte;
pragma Pack (P_Table);
type P_Table_Access is access P_Table;
type P_Object (N : Integer) is record
Ptr : P_Table_Access;
Data : P_Table (1 .. N);
end record;
My_P_Object : P_Object := (N => 3, Ptr => null, Data => (3, 5, 8));
begin
My_Object.Ptr := new Table'(13, 21, 34); -- STOP1
My_P_Object.Ptr := new P_Table'(13, 21, 34);
Do_Nothing (My_Object'Address); -- STOP2
Do_Nothing (My_P_Object'Address);
end Foo;
|
stcarrez/ada-util | Ada | 17,119 | adb | -----------------------------------------------------------------------
-- util-http-clients-tests -- Unit tests for HTTP client
-- Copyright (C) 2012, 2020, 2021, 2022 Stephane Carrez
-- Written by Stephane Carrez ([email protected])
--
-- Licensed under the Apache License, Version 2.0 (the "License");
-- you may not use this file except in compliance with the License.
-- You may obtain a copy of the License at
--
-- http://www.apache.org/licenses/LICENSE-2.0
--
-- Unless required by applicable law or agreed to in writing, software
-- distributed under the License is distributed on an "AS IS" BASIS,
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-- See the License for the specific language governing permissions and
-- limitations under the License.
-----------------------------------------------------------------------
with Ada.Unchecked_Deallocation;
with Ada.Streams;
with Util.Test_Caller;
with Util.Strings.Transforms;
with Util.Http.Tools;
with Util.Http.Mimes;
with Util.Strings;
with Util.Log.Loggers;
package body Util.Http.Clients.Tests is
use type Ada.Strings.Unbounded.Unbounded_String;
-- The logger
Log : constant Util.Log.Loggers.Logger := Util.Log.Loggers.Create ("Util.Http.Clients.Tests");
package body Http_Tests is
package Caller is new Util.Test_Caller (Http_Test, "Http-" & NAME);
procedure Add_Tests (Suite : in Util.Tests.Access_Test_Suite) is
begin
Caller.Add_Test (Suite, "Test Util.Http.Clients." & NAME & ".Get",
Test_Http_Get'Access);
Caller.Add_Test (Suite, "Test Util.Http.Clients." & NAME & ".Head",
Test_Http_Head'Access);
Caller.Add_Test (Suite, "Test Util.Http.Clients." & NAME & ".Post",
Test_Http_Post'Access);
Caller.Add_Test (Suite, "Test Util.Http.Clients." & NAME & ".Put",
Test_Http_Put'Access);
Caller.Add_Test (Suite, "Test Util.Http.Clients." & NAME & ".Delete",
Test_Http_Delete'Access);
Caller.Add_Test (Suite, "Test Util.Http.Clients." & NAME & ".Options",
Test_Http_Options'Access);
Caller.Add_Test (Suite, "Test Util.Http.Clients." & NAME & ".Patch",
Test_Http_Patch'Access);
Caller.Add_Test (Suite, "Test Util.Http.Clients." & NAME & ".Get (timeout)",
Test_Http_Timeout'Access);
Caller.Add_Test (Suite, "Test Util.Http.Clients." & NAME & ".Get (Blob)",
Test_Http_Binary'Access);
end Add_Tests;
overriding
procedure Set_Up (T : in out Http_Test) is
begin
Test (T).Set_Up;
Register;
end Set_Up;
end Http_Tests;
overriding
procedure Set_Up (T : in out Test) is
begin
Log.Info ("Starting test server");
T.Server := new Test_Server;
T.Server.Start;
end Set_Up;
overriding
procedure Tear_Down (T : in out Test) is
procedure Free is
new Ada.Unchecked_Deallocation (Object => Test_Server'Class,
Name => Test_Server_Access);
begin
if T.Server /= null then
Log.Info ("Stopping test server");
T.Server.Stop;
Free (T.Server);
T.Server := null;
end if;
end Tear_Down;
-- ------------------------------
-- Process the line received by the server.
-- ------------------------------
overriding
procedure Process_Line (Into : in out Test_Server;
Line : in Ada.Strings.Unbounded.Unbounded_String;
Stream : in out Util.Streams.Texts.Reader_Stream'Class;
Client : in out Util.Streams.Sockets.Socket_Stream'Class) is
L : constant String := Ada.Strings.Unbounded.To_String (Line);
Pos : Natural := Util.Strings.Index (L, ' ');
begin
if Pos > 0 and then Into.Method = UNKNOWN then
if L (L'First .. Pos - 1) = "GET" then
Into.Method := GET;
elsif L (L'First .. Pos - 1) = "HEAD" then
Into.Method := HEAD;
elsif L (L'First .. Pos - 1) = "POST" then
Into.Method := POST;
elsif L (L'First .. Pos - 1) = "PUT" then
Into.Method := PUT;
elsif L (L'First .. Pos - 1) = "DELETE" then
Into.Method := DELETE;
elsif L (L'First .. Pos - 1) = "OPTIONS" then
Into.Method := OPTIONS;
elsif L (L'First .. Pos - 1) = "PATCH" then
Into.Method := PATCH;
else
Into.Method := UNKNOWN;
end if;
declare
Last : constant Natural := Util.Strings.Index (L, ' ', Pos + 1);
begin
Into.Uri := Ada.Strings.Unbounded.To_Unbounded_String (L (Pos + 1 .. Last - 1));
end;
end if;
Pos := Util.Strings.Index (L, ':');
if Pos > 0 then
if L (L'First .. Pos) = "Content-Type:" then
Into.Content_Type
:= Ada.Strings.Unbounded.To_Unbounded_String (L (Pos + 2 .. L'Last - 2));
elsif L (L'First .. Pos) = "Content-Length:" then
Into.Length := Natural'Value (L (Pos + 1 .. L'Last - 2));
end if;
end if;
-- Don't answer if we check the timeout.
if Into.Test_Timeout then
return;
end if;
if L'Length = 2 and then Into.Length > 0 then
for I in 1 .. Into.Length loop
declare
C : Character;
begin
Stream.Read (C);
Ada.Strings.Unbounded.Append (Into.Result, C);
end;
end loop;
declare
Output : Util.Streams.Texts.Print_Stream;
begin
Output.Initialize (Client'Unchecked_Access);
Output.Write ("HTTP/1.1 200 Found" & ASCII.CR & ASCII.LF);
Output.Write ("Content-Length: 4" & ASCII.CR & ASCII.LF);
Output.Write ("Content-Type: ");
Output.Write (Util.Http.Mimes.Text);
Output.Write (ASCII.CR & ASCII.LF);
Output.Write (ASCII.CR & ASCII.LF);
Output.Write ("OK" & ASCII.CR & ASCII.LF);
Output.Flush;
end;
elsif L'Length = 2 then
declare
Output : Util.Streams.Texts.Print_Stream;
begin
Output.Initialize (Client'Unchecked_Access);
if Into.Uri = "/image" then
Output.Write ("HTTP/1.1 200 Found" & ASCII.CR & ASCII.LF);
Output.Write ("Content-Length: 8000" & ASCII.CR & ASCII.LF);
Output.Write ("Content-Type: ");
Output.Write (Util.Http.Mimes.Octet);
Output.Write (ASCII.CR & ASCII.LF);
Output.Write (ASCII.CR & ASCII.LF);
for I in 1 .. 8000 loop
Output.Write (Character'Val (I mod 256));
end loop;
else
Output.Write ("HTTP/1.1 204 No Content" & ASCII.CR & ASCII.LF);
Output.Write (ASCII.CR & ASCII.LF);
end if;
Output.Flush;
end;
end if;
Log.Info ("Received: {0}", L);
end Process_Line;
-- ------------------------------
-- Get the test server base URI.
-- ------------------------------
function Get_Uri (T : in Test) return String is
begin
return "http://" & T.Server.Get_Host & ":" & Util.Strings.Image (T.Server.Get_Port);
end Get_Uri;
-- ------------------------------
-- Test the http Get operation.
-- ------------------------------
procedure Test_Http_Get (T : in out Test) is
Request : Client;
Reply : Response;
begin
Request.Get ("http://www.google.com", Reply);
Request.Set_Timeout (5.0);
Request.Set_Header ("Accept", "text/html");
Util.Http.Add_Int_Header (Request, "DNT", 0);
T.Assert (Reply.Get_Status = 200 or else Reply.Get_Status = 302,
"Get status is invalid: " & Natural'Image (Reply.Get_Status));
Util.Http.Tools.Save_Response (Util.Tests.Get_Test_Path ("http_get.txt"), Reply, True);
-- Check the content.
declare
Content : constant String := Util.Strings.Transforms.To_Lower_Case (Reply.Get_Body);
begin
Util.Tests.Assert_Matches (T, ".*html.*", Content, "Invalid GET content");
end;
T.Assert (Reply.Contains_Header ("Content-Type"), "Header Content-Type not found");
T.Assert (not Reply.Contains_Header ("Content-Type-Invalid-Missing"),
"Some invalid header found");
-- Check one header.
declare
Content : constant String := Reply.Get_Header ("Content-Type");
begin
T.Assert (Content'Length > 0, "Empty Content-Type header");
Util.Tests.Assert_Matches (T, ".*text/html.*", Content, "Invalid content type");
end;
end Test_Http_Get;
-- ------------------------------
-- Test the http HEAD operation.
-- ------------------------------
procedure Test_Http_Head (T : in out Test) is
Request : Client;
Reply : Response;
begin
Request.Head ("http://www.google.com", Reply);
Request.Set_Timeout (5.0);
Request.Add_Header ("Accept", "text/html");
T.Assert (Reply.Get_Status = 200 or else Reply.Get_Status = 302,
"Get status is invalid: " & Natural'Image (Reply.Get_Status));
Util.Http.Tools.Save_Response (Util.Tests.Get_Test_Path ("http_head.txt"), Reply, True);
T.Assert (Reply.Contains_Header ("Content-Type"), "Header Content-Type not found");
T.Assert (not Reply.Contains_Header ("Content-Type-Invalid-Missing"),
"Some invalid header found");
-- Check one header.
declare
Content : constant String := Reply.Get_Header ("Content-Type");
begin
T.Assert (Content'Length > 0, "Empty Content-Type header");
Util.Tests.Assert_Matches (T, ".*text/html.*", Content, "Invalid content type");
end;
end Test_Http_Head;
-- ------------------------------
-- Test the http POST operation.
-- ------------------------------
procedure Test_Http_Post (T : in out Test) is
Request : Client;
Reply : Response;
Uri : constant String := T.Get_Uri;
begin
Log.Info ("Post on " & Uri);
T.Server.Method := UNKNOWN;
Request.Post (Uri & "/post",
"p1=1", Reply);
T.Assert (T.Server.Method = POST, "Invalid method received by server");
Util.Tests.Assert_Equals (T, "application/x-www-form-urlencoded", T.Server.Content_Type,
"Invalid content type received by server");
Util.Tests.Assert_Equals (T, "OK" & ASCII.CR & ASCII.LF, Reply.Get_Body, "Invalid response");
Util.Http.Tools.Save_Response (Util.Tests.Get_Test_Path ("http_post.txt"), Reply, True);
end Test_Http_Post;
-- ------------------------------
-- Test the http PUT operation.
-- ------------------------------
procedure Test_Http_Put (T : in out Test) is
Request : Client;
Reply : Response;
Uri : constant String := T.Get_Uri;
begin
Log.Info ("Put on " & Uri);
T.Server.Method := UNKNOWN;
Request.Add_Header ("Content-Type", "application/x-www-form-urlencoded");
Request.Set_Timeout (1.0);
T.Assert (Request.Contains_Header ("Content-Type"), "Missing Content-Type");
Request.Put (Uri & "/put",
"p1=1", Reply);
T.Assert (T.Server.Method = PUT, "Invalid method received by server");
Util.Tests.Assert_Equals (T, "application/x-www-form-urlencoded", T.Server.Content_Type,
"Invalid content type received by server");
Util.Tests.Assert_Equals (T, "OK" & ASCII.CR & ASCII.LF, Reply.Get_Body, "Invalid response");
Util.Http.Tools.Save_Response (Util.Tests.Get_Test_Path ("http_put.txt"), Reply, True);
end Test_Http_Put;
-- ------------------------------
-- Test the http DELETE operation.
-- ------------------------------
procedure Test_Http_Delete (T : in out Test) is
Request : Client;
Reply : Response;
Uri : constant String := T.Get_Uri;
begin
Log.Info ("Delete on " & Uri);
T.Server.Method := UNKNOWN;
Request.Add_Header ("Content-Type", "application/x-www-form-urlencoded");
Request.Set_Timeout (1.0);
T.Assert (Request.Contains_Header ("Content-Type"), "Missing Content-Type");
Request.Delete (Uri & "/delete", Reply);
T.Assert (T.Server.Method = DELETE, "Invalid method received by server");
Util.Tests.Assert_Equals (T, "application/x-www-form-urlencoded", T.Server.Content_Type,
"Invalid content type received by server");
Util.Tests.Assert_Equals (T, "", Reply.Get_Body, "Invalid response");
Util.Tests.Assert_Equals (T, 204, Reply.Get_Status, "Invalid status response");
end Test_Http_Delete;
-- ------------------------------
-- Test the http OPTIONS operation.
-- ------------------------------
procedure Test_Http_Options (T : in out Test) is
Request : Client;
Reply : Response;
Uri : constant String := T.Get_Uri;
begin
Log.Info ("Delete on " & Uri);
T.Server.Method := UNKNOWN;
Request.Add_Header ("Content-Type", "application/x-www-form-urlencoded");
Request.Set_Timeout (1.0);
T.Assert (Request.Contains_Header ("Content-Type"), "Missing Content-Type");
Request.Options (Uri & "/options", Reply);
T.Assert (T.Server.Method = OPTIONS, "Invalid method received by server");
Util.Tests.Assert_Equals (T, "application/x-www-form-urlencoded", T.Server.Content_Type,
"Invalid content type received by server");
Util.Tests.Assert_Equals (T, "", Reply.Get_Body, "Invalid response");
Util.Tests.Assert_Equals (T, 204, Reply.Get_Status, "Invalid status response");
end Test_Http_Options;
-- ------------------------------
-- Test the http PATCH operation.
-- ------------------------------
procedure Test_Http_Patch (T : in out Test) is
Request : Client;
Reply : Response;
Uri : constant String := T.Get_Uri;
begin
Log.Info ("Patch on " & Uri);
T.Server.Method := UNKNOWN;
Request.Add_Header ("Content-Type", "application/x-www-form-urlencoded");
Request.Set_Timeout (1.0);
T.Assert (Request.Contains_Header ("Content-Type"), "Missing Content-Type");
Request.Patch (Uri & "/patch", "patch-content", Reply);
T.Assert (T.Server.Method = PATCH, "Invalid method received by server");
Util.Tests.Assert_Equals (T, "application/x-www-form-urlencoded", T.Server.Content_Type,
"Invalid content type received by server");
Util.Tests.Assert_Equals (T, 200, Reply.Get_Status, "Invalid status response");
Util.Tests.Assert_Equals (T, "OK" & ASCII.CR & ASCII.LF, Reply.Get_Body, "Invalid response");
end Test_Http_Patch;
-- ------------------------------
-- Test the http timeout.
-- ------------------------------
procedure Test_Http_Timeout (T : in out Test) is
Request : Client;
Reply : Response;
Uri : constant String := T.Get_Uri;
begin
Log.Info ("Timeout on " & Uri);
T.Server.Test_Timeout := True;
T.Server.Method := UNKNOWN;
Request.Set_Timeout (0.5);
begin
Request.Get (Uri & "/timeout", Reply);
T.Fail ("No Connection_Error exception raised");
exception
when Connection_Error =>
null;
end;
end Test_Http_Timeout;
-- ------------------------------
-- Test the http GET with binary content.
-- ------------------------------
procedure Test_Http_Binary (T : in out Test) is
use Ada.Streams;
Request : Client;
Reply : Response;
Uri : constant String := T.Get_Uri;
Data : Util.Blobs.Blob_Ref;
begin
Log.Info ("Get on " & Uri);
T.Server.Method := UNKNOWN;
Request.Set_Timeout (1.0);
Request.Get (Uri & "/image", Reply);
T.Assert (T.Server.Method = GET, "Invalid method received by server");
Util.Tests.Assert_Equals (T, "/image", T.Server.Uri,
"Invalid URI received by server");
Util.Tests.Assert_Equals (T, 200, Reply.Get_Status, "Invalid status response");
Data := Reply.Get_Body;
T.Assert (not Data.Is_Null, "Null blob body in response");
Util.Tests.Assert_Equals (T, 8000, Natural (Data.Value.Len), "Invalid data length");
for I in 1 .. 8000 loop
Util.Tests.Assert_Equals (T, I mod 256,
Natural (Data.Value.Data (Stream_Element_Offset (I))),
"Invalid content at " & Natural'Image (I));
end loop;
end Test_Http_Binary;
end Util.Http.Clients.Tests;
|
reznikmm/matreshka | Ada | 16,239 | adb | -- Copyright (c) 1990 Regents of the University of California.
-- All rights reserved.
--
-- The primary authors of ayacc were David Taback and Deepak Tolani.
-- Enhancements were made by Ronald J. Schmalz.
--
-- Send requests for ayacc information to [email protected]
-- Send bug reports for ayacc to [email protected]
--
-- Redistribution and use in source and binary forms are permitted
-- provided that the above copyright notice and this paragraph are
-- duplicated in all such forms and that any documentation,
-- advertising materials, and other materials related to such
-- distribution and use acknowledge that the software was developed
-- by the University of California, Irvine. The name of the
-- University may not be used to endorse or promote products derived
-- from this software without specific prior written permission.
-- THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
-- IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
-- WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
-- Module : command_line_interface.ada
-- Component of : common_library
-- Version : 1.2
-- Date : 11/21/86 16:02:24
-- SCCS File : disk21~/rschm/hasee/sccs/common_library/sccs/sxcommand_line_interface.ada
with Text_IO; use Text_IO;
with String_scanner;
----------------------------------------------------------------
Package body command_line_interface is
SCCS_ID : constant String := "@(#) command_line_interface.addisk21~/rschm/hasee/sccs/common_library, Version 1.2";
--| Provides primitives for getting at the command line arguments.
--| Overview
Package sp renames String_pkg;
Package ss renames String_scanner;
type Name_value is --| Name/Value pair
record
Name: sp.String_type; --| Name of value
Value: sp.String_type; --| Value associated with name
Was_retrieved: boolean:=FALSE; --| Flag indicating whether name-value
end record; -- association has been retrieved by tool
type Token_type is (Ada_ID,Word,Bound_to,None);
Package Token_type_IO is new Enumeration_IO(Token_type);
use Token_type_IO;
Maximum_Command_Length : constant := 1024;
subtype Command_Line_Type is String (1 .. Maximum_Command_Length);
Arg_string : Command_Line_Type; --| String obtained from operating system
N_arg_count: Argument_count; --| Count of named args
P_arg_count: Argument_count; --| Count of positional args
Rejected: boolean := FALSE;
Tool_Name : String_Type;
Named_args: array(argument_index)
of Name_value;
Positional_args: array(argument_index)
of sp.String_type;
procedure Read_Command_Line
(Command_Args : out Command_Line_Type) is separate;
--**
--| Description: Read_Command_Line is the machine dependent interface to
--| the Operating System Command Line.
--**
----------------------------------------------------------------
-- Local functions:
procedure Set_Tool_Name (To : in String) is
begin
Tool_Name := Create (To & ": ");
end Set_Tool_Name;
procedure CLI_Error (Error_Message : in String) is
begin
New_Line;
Put_Line (Value (Tool_Name) & Error_Message);
end CLI_Error;
procedure Get_token(
Scan_string : in out ss.Scanner;
Argument : in out sp.String_type;
Kind: in out Token_type
) is
Last_arg: sp.String_type;
Last_kind: Token_type;
Found: boolean;
Delimeter: sp.String_type;
Delim_string: ss.Scanner;
More_commas: boolean := FALSE;
Tail: sp.String_type;
begin
if Rejected then
Argument := Last_arg;
Kind := Last_kind;
Rejected := FALSE;
else
if ss.Is_sequence(" ,",Scan_string) then
ss.Scan_sequence(" ,",Scan_string,Found,Delimeter);
Delim_string := ss.Make_scanner(Delimeter);
loop
ss.Skip_space(Delim_string);
exit when not ss.More(Delim_string);
ss.Forward(Delim_string);
if More_commas then
CLI_Error ("Missing Positional Argument.");
raise missing_positional_arg;
end if;
More_commas := TRUE;
end loop;
end if;
if ss.Is_Ada_Id(Scan_string) then
ss.Scan_Ada_Id(Scan_string,Found,Argument);
if ss.Is_Literal("=>",Scan_string) or
ss.Is_Literal("""",Scan_string) or
ss.Is_sequence(" ,",Scan_string) or
not ss.More(Scan_string) then
Kind := Ada_ID;
else
if ss.Is_not_sequence(" ,",Scan_string) then
ss.Scan_not_sequence(" ,",Scan_string,Found,Tail);
Argument := sp."&"(Argument,Tail);
Kind := Word;
else
ss.Scan_word(Scan_string,Found,Tail);
Argument := sp."&"(Argument,Tail);
Kind := Word;
end if;
end if;
elsif ss.Is_Literal("=>",Scan_string) then
ss.Scan_Literal("=>",Scan_string,Found);
Argument := sp.Create("=>");
Kind := Bound_to;
elsif ss.Is_quoted(Scan_string) then
ss.Scan_quoted(Scan_string,Found,Argument);
Kind := Word;
elsif ss.Is_enclosed('(',')',Scan_string) then
ss.Scan_enclosed('(',')',Scan_string,Found,Argument);
Kind := Word;
elsif ss.Is_not_sequence(" ,",Scan_string) then
ss.Scan_not_sequence(" ,",Scan_string,Found,Argument);
Kind := Word;
elsif ss.Is_word(Scan_string) then
ss.Scan_word(Scan_string,Found,Argument);
Kind := Word;
else
Argument := sp.Create("");
Kind := None;
end if;
Last_kind := Kind;
Last_arg := Argument;
end if;
end Get_token;
-----------------------------------------------------------------------
procedure Save_named(
Name : in sp.String_type;
Value : in sp.String_type
) is
begin
N_arg_count := N_arg_count + 1;
Named_args(N_arg_count).Name := Name;
Named_args(N_arg_count).Value := Value;
end Save_named;
procedure Save_positional(
Value : in sp.String_type
) is
begin
if N_arg_count > 0 then
CLI_Error ("Invalid Parameter Order, " &
"Positional arguments must precede Named.");
raise invalid_parameter_order;
end if;
P_arg_count := P_arg_count + 1;
Positional_args(P_arg_count) := Value;
end Save_positional;
procedure Reject_token is
begin
Rejected := TRUE;
end Reject_token;
----------------------------------------------------------------
procedure Initialize (Tool_Name : in String) is
begin
Set_Tool_Name (To => Tool_Name);
declare
type State_type is (Have_nothing,Have_Ada_ID,Have_bound_to);
Start_Index : integer; --|
End_Index: integer; --| Indices of characters in argument string
Scan_string: ss.Scanner; --| Scanned argument string
Argument: sp.String_Type; --| Argument scanned from argument string
Kind: Token_type; --| Kind of argument- WORD, =>, Ada_ID
Old_arg: sp.String_Type; --| Previously scanned argument
Found: boolean;
State: State_type := Have_nothing;
--| State of argument in decision tree
begin
Start_Index := Arg_string'first;
End_Index := Arg_string'first;
N_arg_count := 0;
P_arg_count := 0;
-- Get the command line from the operating system
Read_Command_Line (Arg_String);
-- Remove trailing blanks and final semicolon
for i in reverse Arg_string'range loop
if Arg_string(i) /= ' ' then
if Arg_string(i) = ';' then
End_Index := i - 1;
else
End_Index := i;
end if;
exit;
end if;
end loop;
Skip_Leading_White_Space :
for i in Arg_String'First .. End_Index
loop
if Arg_String (i) /= ' ' and then
Arg_String (i) /= Ascii.HT then
Start_Index := i;
exit Skip_Leading_White_Space;
end if;
end loop Skip_Leading_White_Space;
Verify_Balanced_Parentheses :
declare
Left_Parens : Natural := 0;
Right_Parens : Natural := 0;
begin
for i in Start_Index .. End_Index
loop
if Arg_String (i) = '(' then
Left_Parens := Left_Parens + 1;
elsif Arg_String (i) = ')' then
Right_Parens := Right_Parens + 1;
end if;
end loop;
if Left_Parens /= Right_Parens then
CLI_Error ("Unbalanced Parentheses.");
raise Unbalanced_Parentheses;
end if;
end Verify_Balanced_Parentheses;
-- Convert argument string to scanner and remove enclosing parantheses
Scan_string := ss.Make_scanner(sp.Create(
Arg_string(Start_Index .. End_Index)));
if ss.Is_enclosed('(',')',Scan_string) then
ss.Mark(Scan_string);
ss.Scan_enclosed('(',')',Scan_string,Found,Argument);
ss.Skip_Space(Scan_string);
if not ss.More(Scan_string) then
ss.Destroy_Scanner(Scan_string);
Scan_string := ss.Make_scanner(Argument);
else
ss.Restore(Scan_string);
end if;
end if;
-- Parse argument string and save arguments
loop
Get_token(Scan_string,Argument,Kind);
case State is
when Have_nothing =>
case Kind is
when Ada_ID =>
Old_arg := Argument;
State := Have_Ada_ID;
when Word =>
Save_positional(Argument);
State := Have_nothing;
when Bound_to =>
State := Have_nothing;
CLI_Error ("Invalid Named Association.");
raise invalid_named_association;
when None =>
null;
end case;
when Have_Ada_ID =>
case Kind is
when Ada_ID =>
Save_positional(Old_arg);
Old_arg := Argument;
State := Have_Ada_ID;
when Word =>
Save_positional(Old_arg);
Save_positional(Argument);
State := Have_nothing;
when Bound_to =>
State := Have_bound_to;
when None =>
Save_positional(Old_arg);
end case;
when Have_bound_to =>
case Kind is
when Ada_ID | Word =>
Save_named(Old_arg,Argument);
State := Have_nothing;
when Bound_to =>
State := Have_bound_to;
CLI_Error ("Invalid Named Association.");
raise invalid_named_association;
when None =>
CLI_Error ("Invalid Named Association.");
raise invalid_named_association;
end case;
end case;
exit when Kind = None;
end loop;
end;
end Initialize;
--------------------------------------------------------------------------
function Named_arg_count --| Return number of named arguments
return Argument_count is
begin
return N_arg_count;
end;
----------------------------------------------------------------
function Positional_arg_count --| Return number of positional arguments
return Argument_count is
begin
return P_arg_count;
end;
----------------------------------------------------------------
function Positional_arg_value( --| Return an argument value
N: Argument_index --| Position of desired argument
) return string is --| Raises: no_arg
--| Effects: Return the Nth argument. If there is no argument at
--| position N, no_arg is raised.
--| N/A: modifies, errors
begin
if N > P_arg_count then
CLI_Error ("Internal Error, Argument" & Argument_Index'Image (N) &
" does not exist. Please submit an LCR.");
raise no_arg;
else
return sp.Value(Positional_args(N));
end if;
end;
----------------------------------------------------------------
function Positional_arg_value( --| Return an argument value
N: Argument_index --| Position of desired argument
) return sp.String_type is --| Raises: no_arg
--| Effects: Return the Nth argument. If there is no argument at
--| position N, no_arg is raised.
--| N/A: modifies, errors
begin
if N > P_arg_count then
CLI_Error ("Internal Error, Argument" & Argument_Index'Image (N) &
" does not exist. Please submit an LCR.");
raise no_arg;
else
return Positional_args(N);
end if;
end;
----------------------------------------------------------------
function Named_arg_value(--| Return a named argument value
Name: string;
Default: string
) return string is
--| Effects: Return the value associated with Name on the command
--| line. If there was none, return Default.
begin
for i in 1..N_arg_count
loop
if sp.Equal(sp.Upper(Named_args(i).Name),sp.Upper(sp.Create(Name))) then
Named_args(i).Was_retrieved := TRUE;
return sp.Value(Named_args(i).Value);
end if;
end loop;
return Default;
end;
function Named_arg_value(--| Return a named argument value
Name: string;
Default: string
) return String_Type is
--| Effects: Return the value associated with Name on the command
--| line. If there was none, return Default.
begin
return Create (Named_Arg_Value (Name, Default));
end Named_Arg_Value;
----------------------------------------------------------------
function Named_arg_value(--| Return a named argument value
Name: string;
Default: sp.String_type
) return sp.String_type is
--| Effects: Return the value associated with Name on the command
--| line. If there was none, return Default.
begin
for i in 1..N_arg_count
loop
if sp.Equal(sp.Upper(Named_args(i).Name),sp.Upper(sp.Create(Name))) then
Named_args(i).Was_retrieved := TRUE;
return Named_args(i).Value;
end if;
end loop;
return Default;
end;
----------------------------------------------------------------
function Arguments --| Return the entire argument string
return string is
--| Effects: Return the entire command line, except for the name
--| of the command itself.
begin
return Arg_string;
end;
----------------------------------------------------------------
function Parse_Aggregate (Aggregate_Text : in String)
return String_Lists.List is
type State_type is (Have_Nothing,
Have_Ada_ID,
Have_Bound_To);
First : Natural := Aggregate_Text'First;
Last : Natural := Aggregate_Text'Last;
Component_List : String_Lists.List := String_Lists.Create;
Argument : sp.String_Type; --| Argument scanned from argument string
Kind : Token_type; --| Kind of argument- WORD, =>, Ada_ID
Scan_string : ss.Scanner; --| Scanned argument string
Aggregate_Contents : String_Type;
Enclosed_Aggregate_Found : Boolean := False;
begin
if Aggregate_Text'Length > 0 then
Scan_String := SS.Make_Scanner (Create (Aggregate_Text (First .. Last)));
SS.Scan_Enclosed ( '(', ')',
Scan_String,
Found => Enclosed_Aggregate_Found,
Result => Aggregate_Contents,
Skip => True);
if Enclosed_Aggregate_Found then
SS.Destroy_Scanner (Scan_String);
Scan_String := SS.Make_Scanner (Aggregate_Contents);
end if;
Parse_Aggregate_String :
loop
Get_token(Scan_string, Argument, Kind);
exit Parse_Aggregate_String when Kind = None;
String_Lists.Attach (Component_List, Argument);
end loop Parse_Aggregate_String;
end if;
return Component_List;
end Parse_Aggregate;
function Parse_Aggregate
(Aggregate_Text : in String_Type)
return String_Lists.List is
begin
return Parse_Aggregate (Value (Aggregate_Text));
end Parse_Aggregate;
----------------------------------------------------------------
function Convert (Parameter_Text : in String) return Parameter_Type is
begin
return Parameter_Type'Value (Parameter_Text);
exception
when Constraint_Error =>
CLI_Error ("Invalid Parameter, """ &
Value (Mixed (Parameter_Text)) &
""" is not a legal value for type " &
Value (Mixed (Type_Name)) & '.');
raise Invalid_Parameter;
end Convert;
----------------------------------------------------------------
procedure Finalize is --| Raises: unreferenced_named_arg
begin
for i in 1..Named_arg_count loop
if Named_args(i).Was_retrieved = FALSE then
CLI_Error ("Invalid Parameter Association, " &
Value (Mixed (Named_Args (i).Name)) &
" is not a valid Formal Parameter.");
raise unreferenced_named_arg;
end if;
end loop;
end Finalize;
-------------------------------------------------------------------
end command_line_interface;
|
Fabien-Chouteau/Ada_Drivers_Library | Ada | 5,690 | adb | ------------------------------------------------------------------------------
-- --
-- Copyright (C) 2019, AdaCore --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions are --
-- met: --
-- 1. Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- 2. Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in --
-- the documentation and/or other materials provided with the --
-- distribution. --
-- 3. Neither the name of the copyright holder nor the names of its --
-- contributors may be used to endorse or promote products derived --
-- from this software without specific prior written permission. --
-- --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR --
-- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
-- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT --
-- LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, --
-- DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY --
-- THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT --
-- (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE --
-- OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
-- --
------------------------------------------------------------------------------
-- Bit-bang a sequence of color LED values to a one-pin LED strip (WS2812B
-- or similar).
with System.Machine_Code; use System, System.Machine_Code;
with NRF51_SVD.GPIO; use NRF51_SVD.GPIO;
with MicroBit.Time;
package body MicroBit.IOs.NeoPixel is
-----------
-- Write --
-----------
procedure Write (Pin : Pin_Id; Values : UInt8_Array) is
Point : constant GPIO_Point := Points (Pin);
Mask : constant UInt32 := 2 ** Point.Pin;
EOL : constant String := ASCII.LF & ASCII.HT;
begin
-- Set pin to digital out mode and reset strip
Set (Pin, False);
MicroBit.Time.Delay_Ms (1);
-- The following loop is very time-sensitive. The bit frame is 1.25 Ás,
-- i.e. 20 cycles of the 16 MHz clock. So, we run it with IRQs disabled,
-- and carefully account for every cycle.
-- Code taken from:
-- https://github.com/Microsoft/pxt-ws2812b/blob/master/sendBuffer.asm
Asm (" cpsid i @ disable irq" & EOL &
" b .start" & EOL &
".nextbit: @ c0" & EOL &
" str %2, [%1, #0] @ pin := hi c2" & EOL &
" tst r6, r0 @ c3" & EOL &
" bne .islate @ c4" & EOL &
" str %2, [%0, #0] @ pin := lo c6" & EOL &
".islate:" & EOL &
" lsr r6, r6, #1 @ r6 >>= 1 c7" & EOL &
" bne .justbit @ c8" & EOL &
"@ not just a bit - need new byte" & EOL &
" add %3, #1 @ buf++ c9" & EOL &
" sub %4, #1 @ len-- c10" & EOL &
" bcc .stop @ if (len<0) goto .stop c11" & EOL &
".start:" & EOL &
" movs r6, #0x80 @ reset mask c12" & EOL &
" nop @ c13" & EOL &
".common: @ c13" & EOL &
" str %2, [%0, #0] @ pin := lo c15" & EOL &
" @ always re-load byte - it just fits with the" & EOL &
" @ cycles better this way." & EOL &
" ldrb r0, [%3, #0] @ r0 := *buf c17" & EOL &
" b .nextbit @ c20" & EOL &
".justbit: @ c10" & EOL &
" @ no nops, branch taken is already 3 cycles" & EOL &
" b .common @ c13" & EOL &
".stop:" & EOL &
" str %2, [%0, #0] @ pin := lo" & EOL &
" cpsie i @ enable irq",
Inputs => (Address'Asm_Input ("l", GPIO_Periph.OUTCLR'Address), -- %0
Address'Asm_Input ("l", GPIO_Periph.OUTSET'Address), -- %1
UInt32'Asm_Input ("l", Mask), -- %2
Address'Asm_Input ("l", Values'Address), -- %3
Natural'Asm_Input ("l", Values'Length)), -- %4
Volatile => True,
Clobber => "r0,r6");
end Write;
end MicroBit.IOs.NeoPixel;
|
gabemgem/LITEC | Ada | 9,495 | adb | M:worksheet_07
F:G$SYSCLK_Init$0$0({2}DF,SV:S),C,0,0,0,0,0
F:G$UART0_Init$0$0({2}DF,SV:S),C,0,0,0,0,0
F:G$Sys_Init$0$0({2}DF,SV:S),C,0,0,0,0,0
F:G$putchar$0$0({2}DF,SV:S),C,0,0,0,0,0
F:G$getchar$0$0({2}DF,SC:U),C,0,0,0,0,0
F:G$getchar_nw$0$0({2}DF,SC:U),C,0,0,0,0,0
F:G$main$0$0({2}DF,SV:S),C,0,0,0,0,0
F:G$XBR0_Init$0$0({2}DF,SV:S),Z,0,0,0,0,0
F:G$Interrupt_Init$0$0({2}DF,SV:S),Z,0,0,0,0,0
F:G$PCA_Init$0$0({2}DF,SV:S),Z,0,0,0,0,0
F:G$PCA_ISR$0$0({2}DF,SV:S),Z,0,0,1,9,0
S:Lworksheet_07.getchar$c$1$10({1}SC:U),R,0,0,[]
S:Lworksheet_07.getchar_nw$c$1$12({1}SC:U),R,0,0,[]
S:G$PW$0$0({2}SI:U),E,0,0
S:G$PCA_start$0$0({2}SI:U),E,0,0
S:Lworksheet_07.main$input$1$31({1}SC:U),R,0,0,[r7]
S:G$P0$0$0({1}SC:U),I,0,0
S:G$SP$0$0({1}SC:U),I,0,0
S:G$DPL$0$0({1}SC:U),I,0,0
S:G$DPH$0$0({1}SC:U),I,0,0
S:G$P4$0$0({1}SC:U),I,0,0
S:G$P5$0$0({1}SC:U),I,0,0
S:G$P6$0$0({1}SC:U),I,0,0
S:G$PCON$0$0({1}SC:U),I,0,0
S:G$TCON$0$0({1}SC:U),I,0,0
S:G$TMOD$0$0({1}SC:U),I,0,0
S:G$TL0$0$0({1}SC:U),I,0,0
S:G$TL1$0$0({1}SC:U),I,0,0
S:G$TH0$0$0({1}SC:U),I,0,0
S:G$TH1$0$0({1}SC:U),I,0,0
S:G$CKCON$0$0({1}SC:U),I,0,0
S:G$PSCTL$0$0({1}SC:U),I,0,0
S:G$P1$0$0({1}SC:U),I,0,0
S:G$TMR3CN$0$0({1}SC:U),I,0,0
S:G$TMR3RLL$0$0({1}SC:U),I,0,0
S:G$TMR3RLH$0$0({1}SC:U),I,0,0
S:G$TMR3L$0$0({1}SC:U),I,0,0
S:G$TMR3H$0$0({1}SC:U),I,0,0
S:G$P7$0$0({1}SC:U),I,0,0
S:G$SCON$0$0({1}SC:U),I,0,0
S:G$SCON0$0$0({1}SC:U),I,0,0
S:G$SBUF$0$0({1}SC:U),I,0,0
S:G$SBUF0$0$0({1}SC:U),I,0,0
S:G$SPI0CFG$0$0({1}SC:U),I,0,0
S:G$SPI0DAT$0$0({1}SC:U),I,0,0
S:G$ADC1$0$0({1}SC:U),I,0,0
S:G$SPI0CKR$0$0({1}SC:U),I,0,0
S:G$CPT0CN$0$0({1}SC:U),I,0,0
S:G$CPT1CN$0$0({1}SC:U),I,0,0
S:G$P2$0$0({1}SC:U),I,0,0
S:G$EMI0TC$0$0({1}SC:U),I,0,0
S:G$EMI0CF$0$0({1}SC:U),I,0,0
S:G$PRT0CF$0$0({1}SC:U),I,0,0
S:G$P0MDOUT$0$0({1}SC:U),I,0,0
S:G$PRT1CF$0$0({1}SC:U),I,0,0
S:G$P1MDOUT$0$0({1}SC:U),I,0,0
S:G$PRT2CF$0$0({1}SC:U),I,0,0
S:G$P2MDOUT$0$0({1}SC:U),I,0,0
S:G$PRT3CF$0$0({1}SC:U),I,0,0
S:G$P3MDOUT$0$0({1}SC:U),I,0,0
S:G$IE$0$0({1}SC:U),I,0,0
S:G$SADDR0$0$0({1}SC:U),I,0,0
S:G$ADC1CN$0$0({1}SC:U),I,0,0
S:G$ADC1CF$0$0({1}SC:U),I,0,0
S:G$AMX1SL$0$0({1}SC:U),I,0,0
S:G$P3IF$0$0({1}SC:U),I,0,0
S:G$SADEN1$0$0({1}SC:U),I,0,0
S:G$EMI0CN$0$0({1}SC:U),I,0,0
S:G$_XPAGE$0$0({1}SC:U),I,0,0
S:G$P3$0$0({1}SC:U),I,0,0
S:G$OSCXCN$0$0({1}SC:U),I,0,0
S:G$OSCICN$0$0({1}SC:U),I,0,0
S:G$P74OUT$0$0({1}SC:U),I,0,0
S:G$FLSCL$0$0({1}SC:U),I,0,0
S:G$FLACL$0$0({1}SC:U),I,0,0
S:G$IP$0$0({1}SC:U),I,0,0
S:G$SADEN0$0$0({1}SC:U),I,0,0
S:G$AMX0CF$0$0({1}SC:U),I,0,0
S:G$AMX0SL$0$0({1}SC:U),I,0,0
S:G$ADC0CF$0$0({1}SC:U),I,0,0
S:G$P1MDIN$0$0({1}SC:U),I,0,0
S:G$ADC0L$0$0({1}SC:U),I,0,0
S:G$ADC0H$0$0({1}SC:U),I,0,0
S:G$SMB0CN$0$0({1}SC:U),I,0,0
S:G$SMB0STA$0$0({1}SC:U),I,0,0
S:G$SMB0DAT$0$0({1}SC:U),I,0,0
S:G$SMB0ADR$0$0({1}SC:U),I,0,0
S:G$ADC0GTL$0$0({1}SC:U),I,0,0
S:G$ADC0GTH$0$0({1}SC:U),I,0,0
S:G$ADC0LTL$0$0({1}SC:U),I,0,0
S:G$ADC0LTH$0$0({1}SC:U),I,0,0
S:G$T2CON$0$0({1}SC:U),I,0,0
S:G$T4CON$0$0({1}SC:U),I,0,0
S:G$RCAP2L$0$0({1}SC:U),I,0,0
S:G$RCAP2H$0$0({1}SC:U),I,0,0
S:G$TL2$0$0({1}SC:U),I,0,0
S:G$TH2$0$0({1}SC:U),I,0,0
S:G$SMB0CR$0$0({1}SC:U),I,0,0
S:G$PSW$0$0({1}SC:U),I,0,0
S:G$REF0CN$0$0({1}SC:U),I,0,0
S:G$DAC0L$0$0({1}SC:U),I,0,0
S:G$DAC0H$0$0({1}SC:U),I,0,0
S:G$DAC0CN$0$0({1}SC:U),I,0,0
S:G$DAC1L$0$0({1}SC:U),I,0,0
S:G$DAC1H$0$0({1}SC:U),I,0,0
S:G$DAC1CN$0$0({1}SC:U),I,0,0
S:G$PCA0CN$0$0({1}SC:U),I,0,0
S:G$PCA0MD$0$0({1}SC:U),I,0,0
S:G$PCA0CPM0$0$0({1}SC:U),I,0,0
S:G$PCA0CPM1$0$0({1}SC:U),I,0,0
S:G$PCA0CPM2$0$0({1}SC:U),I,0,0
S:G$PCA0CPM3$0$0({1}SC:U),I,0,0
S:G$PCA0CPM4$0$0({1}SC:U),I,0,0
S:G$ACC$0$0({1}SC:U),I,0,0
S:G$XBR0$0$0({1}SC:U),I,0,0
S:G$XBR1$0$0({1}SC:U),I,0,0
S:G$XBR2$0$0({1}SC:U),I,0,0
S:G$RCAP4L$0$0({1}SC:U),I,0,0
S:G$RCAP4H$0$0({1}SC:U),I,0,0
S:G$EIE1$0$0({1}SC:U),I,0,0
S:G$EIE2$0$0({1}SC:U),I,0,0
S:G$ADC0CN$0$0({1}SC:U),I,0,0
S:G$PCA0L$0$0({1}SC:U),I,0,0
S:G$PCA0CPL0$0$0({1}SC:U),I,0,0
S:G$PCA0CPL1$0$0({1}SC:U),I,0,0
S:G$PCA0CPL2$0$0({1}SC:U),I,0,0
S:G$PCA0CPL3$0$0({1}SC:U),I,0,0
S:G$PCA0CPL4$0$0({1}SC:U),I,0,0
S:G$RSTSRC$0$0({1}SC:U),I,0,0
S:G$B$0$0({1}SC:U),I,0,0
S:G$SCON1$0$0({1}SC:U),I,0,0
S:G$SBUF1$0$0({1}SC:U),I,0,0
S:G$SADDR1$0$0({1}SC:U),I,0,0
S:G$TL4$0$0({1}SC:U),I,0,0
S:G$TH4$0$0({1}SC:U),I,0,0
S:G$EIP1$0$0({1}SC:U),I,0,0
S:G$EIP2$0$0({1}SC:U),I,0,0
S:G$SPI0CN$0$0({1}SC:U),I,0,0
S:G$PCA0H$0$0({1}SC:U),I,0,0
S:G$PCA0CPH0$0$0({1}SC:U),I,0,0
S:G$PCA0CPH1$0$0({1}SC:U),I,0,0
S:G$PCA0CPH2$0$0({1}SC:U),I,0,0
S:G$PCA0CPH3$0$0({1}SC:U),I,0,0
S:G$PCA0CPH4$0$0({1}SC:U),I,0,0
S:G$WDTCN$0$0({1}SC:U),I,0,0
S:G$TMR0$0$0({2}SI:U),I,0,0
S:G$TMR1$0$0({2}SI:U),I,0,0
S:G$TMR2$0$0({2}SI:U),I,0,0
S:G$RCAP2$0$0({2}SI:U),I,0,0
S:G$TMR3$0$0({2}SI:U),I,0,0
S:G$TMR3RL$0$0({2}SI:U),I,0,0
S:G$TMR4$0$0({2}SI:U),I,0,0
S:G$RCAP4$0$0({2}SI:U),I,0,0
S:G$ADC0$0$0({2}SI:U),I,0,0
S:G$ADC0GT$0$0({2}SI:U),I,0,0
S:G$ADC0LT$0$0({2}SI:U),I,0,0
S:G$DAC0$0$0({2}SI:U),I,0,0
S:G$DAC1$0$0({2}SI:U),I,0,0
S:G$PCA0$0$0({2}SI:U),I,0,0
S:G$PCA0CP0$0$0({2}SI:U),I,0,0
S:G$PCA0CP1$0$0({2}SI:U),I,0,0
S:G$PCA0CP2$0$0({2}SI:U),I,0,0
S:G$PCA0CP3$0$0({2}SI:U),I,0,0
S:G$PCA0CP4$0$0({2}SI:U),I,0,0
S:G$P0_0$0$0({1}SX:U),J,0,0
S:G$P0_1$0$0({1}SX:U),J,0,0
S:G$P0_2$0$0({1}SX:U),J,0,0
S:G$P0_3$0$0({1}SX:U),J,0,0
S:G$P0_4$0$0({1}SX:U),J,0,0
S:G$P0_5$0$0({1}SX:U),J,0,0
S:G$P0_6$0$0({1}SX:U),J,0,0
S:G$P0_7$0$0({1}SX:U),J,0,0
S:G$IT0$0$0({1}SX:U),J,0,0
S:G$IE0$0$0({1}SX:U),J,0,0
S:G$IT1$0$0({1}SX:U),J,0,0
S:G$IE1$0$0({1}SX:U),J,0,0
S:G$TR0$0$0({1}SX:U),J,0,0
S:G$TF0$0$0({1}SX:U),J,0,0
S:G$TR1$0$0({1}SX:U),J,0,0
S:G$TF1$0$0({1}SX:U),J,0,0
S:G$P1_0$0$0({1}SX:U),J,0,0
S:G$P1_1$0$0({1}SX:U),J,0,0
S:G$P1_2$0$0({1}SX:U),J,0,0
S:G$P1_3$0$0({1}SX:U),J,0,0
S:G$P1_4$0$0({1}SX:U),J,0,0
S:G$P1_5$0$0({1}SX:U),J,0,0
S:G$P1_6$0$0({1}SX:U),J,0,0
S:G$P1_7$0$0({1}SX:U),J,0,0
S:G$RI$0$0({1}SX:U),J,0,0
S:G$RI0$0$0({1}SX:U),J,0,0
S:G$TI$0$0({1}SX:U),J,0,0
S:G$TI0$0$0({1}SX:U),J,0,0
S:G$RB8$0$0({1}SX:U),J,0,0
S:G$RB80$0$0({1}SX:U),J,0,0
S:G$TB8$0$0({1}SX:U),J,0,0
S:G$TB80$0$0({1}SX:U),J,0,0
S:G$REN$0$0({1}SX:U),J,0,0
S:G$REN0$0$0({1}SX:U),J,0,0
S:G$SM2$0$0({1}SX:U),J,0,0
S:G$SM20$0$0({1}SX:U),J,0,0
S:G$MCE0$0$0({1}SX:U),J,0,0
S:G$SM1$0$0({1}SX:U),J,0,0
S:G$SM10$0$0({1}SX:U),J,0,0
S:G$SM0$0$0({1}SX:U),J,0,0
S:G$SM00$0$0({1}SX:U),J,0,0
S:G$S0MODE$0$0({1}SX:U),J,0,0
S:G$P2_0$0$0({1}SX:U),J,0,0
S:G$P2_1$0$0({1}SX:U),J,0,0
S:G$P2_2$0$0({1}SX:U),J,0,0
S:G$P2_3$0$0({1}SX:U),J,0,0
S:G$P2_4$0$0({1}SX:U),J,0,0
S:G$P2_5$0$0({1}SX:U),J,0,0
S:G$P2_6$0$0({1}SX:U),J,0,0
S:G$P2_7$0$0({1}SX:U),J,0,0
S:G$EX0$0$0({1}SX:U),J,0,0
S:G$ET0$0$0({1}SX:U),J,0,0
S:G$EX1$0$0({1}SX:U),J,0,0
S:G$ET1$0$0({1}SX:U),J,0,0
S:G$ES0$0$0({1}SX:U),J,0,0
S:G$ES$0$0({1}SX:U),J,0,0
S:G$ET2$0$0({1}SX:U),J,0,0
S:G$EA$0$0({1}SX:U),J,0,0
S:G$P3_0$0$0({1}SX:U),J,0,0
S:G$P3_1$0$0({1}SX:U),J,0,0
S:G$P3_2$0$0({1}SX:U),J,0,0
S:G$P3_3$0$0({1}SX:U),J,0,0
S:G$P3_4$0$0({1}SX:U),J,0,0
S:G$P3_5$0$0({1}SX:U),J,0,0
S:G$P3_6$0$0({1}SX:U),J,0,0
S:G$P3_7$0$0({1}SX:U),J,0,0
S:G$PX0$0$0({1}SX:U),J,0,0
S:G$PT0$0$0({1}SX:U),J,0,0
S:G$PX1$0$0({1}SX:U),J,0,0
S:G$PT1$0$0({1}SX:U),J,0,0
S:G$PS0$0$0({1}SX:U),J,0,0
S:G$PS$0$0({1}SX:U),J,0,0
S:G$PT2$0$0({1}SX:U),J,0,0
S:G$SMBTOE$0$0({1}SX:U),J,0,0
S:G$SMBFTE$0$0({1}SX:U),J,0,0
S:G$AA$0$0({1}SX:U),J,0,0
S:G$SI$0$0({1}SX:U),J,0,0
S:G$STO$0$0({1}SX:U),J,0,0
S:G$STA$0$0({1}SX:U),J,0,0
S:G$ENSMB$0$0({1}SX:U),J,0,0
S:G$BUSY$0$0({1}SX:U),J,0,0
S:G$CPRL2$0$0({1}SX:U),J,0,0
S:G$CT2$0$0({1}SX:U),J,0,0
S:G$TR2$0$0({1}SX:U),J,0,0
S:G$EXEN2$0$0({1}SX:U),J,0,0
S:G$TCLK$0$0({1}SX:U),J,0,0
S:G$RCLK$0$0({1}SX:U),J,0,0
S:G$EXF2$0$0({1}SX:U),J,0,0
S:G$TF2$0$0({1}SX:U),J,0,0
S:G$P$0$0({1}SX:U),J,0,0
S:G$F1$0$0({1}SX:U),J,0,0
S:G$OV$0$0({1}SX:U),J,0,0
S:G$RS0$0$0({1}SX:U),J,0,0
S:G$RS1$0$0({1}SX:U),J,0,0
S:G$F0$0$0({1}SX:U),J,0,0
S:G$AC$0$0({1}SX:U),J,0,0
S:G$CY$0$0({1}SX:U),J,0,0
S:G$CCF0$0$0({1}SX:U),J,0,0
S:G$CCF1$0$0({1}SX:U),J,0,0
S:G$CCF2$0$0({1}SX:U),J,0,0
S:G$CCF3$0$0({1}SX:U),J,0,0
S:G$CCF4$0$0({1}SX:U),J,0,0
S:G$CR$0$0({1}SX:U),J,0,0
S:G$CF$0$0({1}SX:U),J,0,0
S:G$ADLJST$0$0({1}SX:U),J,0,0
S:G$AD0LJST$0$0({1}SX:U),J,0,0
S:G$ADWINT$0$0({1}SX:U),J,0,0
S:G$AD0WINT$0$0({1}SX:U),J,0,0
S:G$ADSTM0$0$0({1}SX:U),J,0,0
S:G$AD0CM0$0$0({1}SX:U),J,0,0
S:G$ADSTM1$0$0({1}SX:U),J,0,0
S:G$AD0CM1$0$0({1}SX:U),J,0,0
S:G$ADBUSY$0$0({1}SX:U),J,0,0
S:G$AD0BUSY$0$0({1}SX:U),J,0,0
S:G$ADCINT$0$0({1}SX:U),J,0,0
S:G$AD0INT$0$0({1}SX:U),J,0,0
S:G$ADCTM$0$0({1}SX:U),J,0,0
S:G$AD0TM$0$0({1}SX:U),J,0,0
S:G$ADCEN$0$0({1}SX:U),J,0,0
S:G$AD0EN$0$0({1}SX:U),J,0,0
S:G$SPIEN$0$0({1}SX:U),J,0,0
S:G$MSTEN$0$0({1}SX:U),J,0,0
S:G$SLVSEL$0$0({1}SX:U),J,0,0
S:G$TXBSY$0$0({1}SX:U),J,0,0
S:G$RXOVRN$0$0({1}SX:U),J,0,0
S:G$MODF$0$0({1}SX:U),J,0,0
S:G$WCOL$0$0({1}SX:U),J,0,0
S:G$SPIF$0$0({1}SX:U),J,0,0
S:G$SYSCLK_Init$0$0({2}DF,SV:S),C,0,0
S:G$UART0_Init$0$0({2}DF,SV:S),C,0,0
S:G$Sys_Init$0$0({2}DF,SV:S),C,0,0
S:G$getchar_nw$0$0({2}DF,SC:U),C,0,0
S:G$_print_format$0$0({2}DF,SI:S),C,0,0
S:G$printf_small$0$0({2}DF,SV:S),C,0,0
S:G$printf$0$0({2}DF,SI:S),C,0,0
S:G$vprintf$0$0({2}DF,SI:S),C,0,0
S:G$sprintf$0$0({2}DF,SI:S),C,0,0
S:G$vsprintf$0$0({2}DF,SI:S),C,0,0
S:G$puts$0$0({2}DF,SI:S),C,0,0
S:G$getchar$0$0({2}DF,SC:U),C,0,0
S:G$putchar$0$0({2}DF,SV:S),C,0,0
S:G$printf_fast$0$0({2}DF,SV:S),C,0,0
S:G$printf_fast_f$0$0({2}DF,SV:S),C,0,0
S:G$printf_tiny$0$0({2}DF,SV:S),C,0,0
S:G$main$0$0({2}DF,SV:S),C,0,0
S:Fworksheet_07$__str_0$0$0({13}DA13d,SC:S),D,0,0
S:Fworksheet_07$__str_1$0$0({41}DA41d,SC:S),D,0,0
S:Fworksheet_07$__str_2$0$0({41}DA41d,SC:S),D,0,0
S:Fworksheet_07$__str_3$0$0({37}DA37d,SC:S),D,0,0
S:Fworksheet_07$__str_4$0$0({37}DA37d,SC:S),D,0,0
S:Fworksheet_07$__str_5$0$0({33}DA33d,SC:S),D,0,0
|
reznikmm/matreshka | Ada | 3,609 | ads | ------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- Ada Modeling Framework --
-- --
-- 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$
------------------------------------------------------------------------------
package Generator.Reflection is
procedure Generate_Reflection_Specification;
-- Generates specification of reflection package.
procedure Generate_Reflection_Implementation;
-- Generates implementation of reflection package.
end Generator.Reflection;
|
francesco-bongiovanni/ewok-kernel | Ada | 3,056 | ads | --
-- 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.tasks_shared; use ewok.tasks_shared;
with soc.dma.interfaces;
with types.c;
package ewok.exported.dma
with spark_mode => off
is
-- Specify DMA elements to (re)configure
type t_config_mask is new soc.dma.interfaces.t_config_mask;
--
-- User defined DMA configuration
--
type t_mode is new soc.dma.interfaces.t_mode;
type t_transfer_dir is new soc.dma.interfaces.t_transfer_dir;
type t_priority_level is new soc.dma.interfaces.t_priority_level;
type t_data_size is new soc.dma.interfaces.t_data_size;
type t_burst_size is new soc.dma.interfaces.t_burst_size;
type t_flow_controller is new soc.dma.interfaces.t_flow_controller;
type t_controller is new soc.dma.t_dma_periph_index with size => 8;
subtype t_stream is unsigned_8 range 0 .. 7;
subtype t_channel is unsigned_8 range 0 .. 7;
type t_dma_user_config is record
in_addr : system_address;
out_addr : system_address;
in_priority : t_priority_level;
out_priority : t_priority_level;
size : unsigned_16; -- size in bytes
controller : t_controller := ID_DMA1;
channel : t_channel := 0;
stream : t_stream := 0;
flow_controller : t_flow_controller;
transfer_dir : t_transfer_dir;
mode : t_mode;
memory_inc : types.c.bool;
periph_inc : types.c.bool;
data_size : t_data_size;
mem_burst_size : t_burst_size;
periph_burst_size : t_burst_size;
in_handler : system_address; -- ISR
out_handler : system_address; -- ISR
end record;
type t_dma_user_config_access is access all t_dma_user_config;
type t_dma_shm_access is (SHM_ACCESS_READ, SHM_ACCESS_WRITE);
-- The caller (accessed_id) grant access to another task (granted_id)
-- to a range in its inner memory space. That mechanism permits to the
-- 'granted' to configure the DMA with an address that belongs to
-- the 'accessed' task.
type t_dma_shm_info is record
granted_id : t_task_id;
accessed_id : t_task_id; -- caller
base : system_address;
size : unsigned_16;
access_type : t_dma_shm_access;
end record;
end ewok.exported.dma;
|
chenrongchao/coinapi-sdk | Ada | 20,263 | ads | -- OEML _ REST API
-- This section will provide necessary information about the `CoinAPI OEML REST API` protocol. This API is also available in the Postman application: <a href=\"https://postman.coinapi.io/\" target=\"_blank\">https://postman.coinapi.io/</a>
--
-- The version of the OpenAPI document: v1
-- Contact: [email protected]
--
-- NOTE: This package is auto generated by OpenAPI-Generator 5.0.1.
-- https://openapi-generator.tech
-- Do not edit the class manually.
with Swagger.Streams;
with Ada.Containers.Vectors;
package .Models is
type Severity_Type is
record
end record;
package Severity_Type_Vectors is
new Ada.Containers.Vectors (Index_Type => Positive,
Element_Type => Severity_Type);
procedure Serialize (Into : in out Swagger.Streams.Output_Stream'Class;
Name : in String;
Value : in Severity_Type);
procedure Serialize (Into : in out Swagger.Streams.Output_Stream'Class;
Name : in String;
Value : in Severity_Type_Vectors.Vector);
procedure Deserialize (From : in Swagger.Value_Type;
Name : in String;
Value : out Severity_Type);
procedure Deserialize (From : in Swagger.Value_Type;
Name : in String;
Value : out Severity_Type_Vectors.Vector);
-- ------------------------------
-- Message object.
-- ------------------------------
type Message_Type is
record
P_Type : Swagger.Nullable_UString;
Severity : .Models.Severity_Type;
Exchange_Id : Swagger.Nullable_UString;
Message : Swagger.Nullable_UString;
end record;
package Message_Type_Vectors is
new Ada.Containers.Vectors (Index_Type => Positive,
Element_Type => Message_Type);
procedure Serialize (Into : in out Swagger.Streams.Output_Stream'Class;
Name : in String;
Value : in Message_Type);
procedure Serialize (Into : in out Swagger.Streams.Output_Stream'Class;
Name : in String;
Value : in Message_Type_Vectors.Vector);
procedure Deserialize (From : in Swagger.Value_Type;
Name : in String;
Value : out Message_Type);
procedure Deserialize (From : in Swagger.Value_Type;
Name : in String;
Value : out Message_Type_Vectors.Vector);
-- ------------------------------
-- JSON validation error.
-- ------------------------------
type ValidationError_Type is
record
P_Type : Swagger.Nullable_UString;
Title : Swagger.Nullable_UString;
Status : Swagger.Number;
Trace_Id : Swagger.Nullable_UString;
Errors : Swagger.Nullable_UString;
end record;
package ValidationError_Type_Vectors is
new Ada.Containers.Vectors (Index_Type => Positive,
Element_Type => ValidationError_Type);
procedure Serialize (Into : in out Swagger.Streams.Output_Stream'Class;
Name : in String;
Value : in ValidationError_Type);
procedure Serialize (Into : in out Swagger.Streams.Output_Stream'Class;
Name : in String;
Value : in ValidationError_Type_Vectors.Vector);
procedure Deserialize (From : in Swagger.Value_Type;
Name : in String;
Value : out ValidationError_Type);
procedure Deserialize (From : in Swagger.Value_Type;
Name : in String;
Value : out ValidationError_Type_Vectors.Vector);
type OrdType_Type is
record
end record;
package OrdType_Type_Vectors is
new Ada.Containers.Vectors (Index_Type => Positive,
Element_Type => OrdType_Type);
procedure Serialize (Into : in out Swagger.Streams.Output_Stream'Class;
Name : in String;
Value : in OrdType_Type);
procedure Serialize (Into : in out Swagger.Streams.Output_Stream'Class;
Name : in String;
Value : in OrdType_Type_Vectors.Vector);
procedure Deserialize (From : in Swagger.Value_Type;
Name : in String;
Value : out OrdType_Type);
procedure Deserialize (From : in Swagger.Value_Type;
Name : in String;
Value : out OrdType_Type_Vectors.Vector);
type OrdStatus_Type is
record
end record;
package OrdStatus_Type_Vectors is
new Ada.Containers.Vectors (Index_Type => Positive,
Element_Type => OrdStatus_Type);
procedure Serialize (Into : in out Swagger.Streams.Output_Stream'Class;
Name : in String;
Value : in OrdStatus_Type);
procedure Serialize (Into : in out Swagger.Streams.Output_Stream'Class;
Name : in String;
Value : in OrdStatus_Type_Vectors.Vector);
procedure Deserialize (From : in Swagger.Value_Type;
Name : in String;
Value : out OrdStatus_Type);
procedure Deserialize (From : in Swagger.Value_Type;
Name : in String;
Value : out OrdStatus_Type_Vectors.Vector);
type OrderCancelAllRequest_Type is
record
Exchange_Id : Swagger.UString;
end record;
package OrderCancelAllRequest_Type_Vectors is
new Ada.Containers.Vectors (Index_Type => Positive,
Element_Type => OrderCancelAllRequest_Type);
procedure Serialize (Into : in out Swagger.Streams.Output_Stream'Class;
Name : in String;
Value : in OrderCancelAllRequest_Type);
procedure Serialize (Into : in out Swagger.Streams.Output_Stream'Class;
Name : in String;
Value : in OrderCancelAllRequest_Type_Vectors.Vector);
procedure Deserialize (From : in Swagger.Value_Type;
Name : in String;
Value : out OrderCancelAllRequest_Type);
procedure Deserialize (From : in Swagger.Value_Type;
Name : in String;
Value : out OrderCancelAllRequest_Type_Vectors.Vector);
type OrderCancelSingleRequest_Type is
record
Exchange_Id : Swagger.UString;
Exchange_Order_Id : Swagger.Nullable_UString;
Client_Order_Id : Swagger.Nullable_UString;
end record;
package OrderCancelSingleRequest_Type_Vectors is
new Ada.Containers.Vectors (Index_Type => Positive,
Element_Type => OrderCancelSingleRequest_Type);
procedure Serialize (Into : in out Swagger.Streams.Output_Stream'Class;
Name : in String;
Value : in OrderCancelSingleRequest_Type);
procedure Serialize (Into : in out Swagger.Streams.Output_Stream'Class;
Name : in String;
Value : in OrderCancelSingleRequest_Type_Vectors.Vector);
procedure Deserialize (From : in Swagger.Value_Type;
Name : in String;
Value : out OrderCancelSingleRequest_Type);
procedure Deserialize (From : in Swagger.Value_Type;
Name : in String;
Value : out OrderCancelSingleRequest_Type_Vectors.Vector);
type OrdSide_Type is
record
end record;
package OrdSide_Type_Vectors is
new Ada.Containers.Vectors (Index_Type => Positive,
Element_Type => OrdSide_Type);
procedure Serialize (Into : in out Swagger.Streams.Output_Stream'Class;
Name : in String;
Value : in OrdSide_Type);
procedure Serialize (Into : in out Swagger.Streams.Output_Stream'Class;
Name : in String;
Value : in OrdSide_Type_Vectors.Vector);
procedure Deserialize (From : in Swagger.Value_Type;
Name : in String;
Value : out OrdSide_Type);
procedure Deserialize (From : in Swagger.Value_Type;
Name : in String;
Value : out OrdSide_Type_Vectors.Vector);
type TimeInForce_Type is
record
end record;
package TimeInForce_Type_Vectors is
new Ada.Containers.Vectors (Index_Type => Positive,
Element_Type => TimeInForce_Type);
procedure Serialize (Into : in out Swagger.Streams.Output_Stream'Class;
Name : in String;
Value : in TimeInForce_Type);
procedure Serialize (Into : in out Swagger.Streams.Output_Stream'Class;
Name : in String;
Value : in TimeInForce_Type_Vectors.Vector);
procedure Deserialize (From : in Swagger.Value_Type;
Name : in String;
Value : out TimeInForce_Type);
procedure Deserialize (From : in Swagger.Value_Type;
Name : in String;
Value : out TimeInForce_Type_Vectors.Vector);
type OrderNewSingleRequest_Type is
record
Exchange_Id : Swagger.UString;
Client_Order_Id : Swagger.UString;
Symbol_Id_Exchange : Swagger.Nullable_UString;
Symbol_Id_Coinapi : Swagger.Nullable_UString;
Amount_Order : Swagger.Number;
Price : Swagger.Number;
Side : .Models.OrdSide_Type;
Order_Type : .Models.OrdType_Type;
Time_In_Force : .Models.TimeInForce_Type;
Expire_Time : Swagger.Nullable_Date;
Exec_Inst : Swagger.UString_Vectors.Vector;
end record;
package OrderNewSingleRequest_Type_Vectors is
new Ada.Containers.Vectors (Index_Type => Positive,
Element_Type => OrderNewSingleRequest_Type);
procedure Serialize (Into : in out Swagger.Streams.Output_Stream'Class;
Name : in String;
Value : in OrderNewSingleRequest_Type);
procedure Serialize (Into : in out Swagger.Streams.Output_Stream'Class;
Name : in String;
Value : in OrderNewSingleRequest_Type_Vectors.Vector);
procedure Deserialize (From : in Swagger.Value_Type;
Name : in String;
Value : out OrderNewSingleRequest_Type);
procedure Deserialize (From : in Swagger.Value_Type;
Name : in String;
Value : out OrderNewSingleRequest_Type_Vectors.Vector);
-- ------------------------------
-- Relay fill information on working orders.
-- ------------------------------
type Fills_Type is
record
Time : Swagger.Nullable_Date;
Price : Swagger.Number;
Amount : Swagger.Number;
end record;
package Fills_Type_Vectors is
new Ada.Containers.Vectors (Index_Type => Positive,
Element_Type => Fills_Type);
procedure Serialize (Into : in out Swagger.Streams.Output_Stream'Class;
Name : in String;
Value : in Fills_Type);
procedure Serialize (Into : in out Swagger.Streams.Output_Stream'Class;
Name : in String;
Value : in Fills_Type_Vectors.Vector);
procedure Deserialize (From : in Swagger.Value_Type;
Name : in String;
Value : out Fills_Type);
procedure Deserialize (From : in Swagger.Value_Type;
Name : in String;
Value : out Fills_Type_Vectors.Vector);
type OrderExecutionReport_Type is
record
Exchange_Id : Swagger.UString;
Client_Order_Id : Swagger.UString;
Symbol_Id_Exchange : Swagger.Nullable_UString;
Symbol_Id_Coinapi : Swagger.Nullable_UString;
Amount_Order : Swagger.Number;
Price : Swagger.Number;
Side : .Models.OrdSide_Type;
Order_Type : .Models.OrdType_Type;
Time_In_Force : .Models.TimeInForce_Type;
Expire_Time : Swagger.Nullable_Date;
Exec_Inst : Swagger.UString_Vectors.Vector;
Client_Order_Id_Format_Exchange : Swagger.UString;
Exchange_Order_Id : Swagger.Nullable_UString;
Amount_Open : Swagger.Number;
Amount_Filled : Swagger.Number;
Avg_Px : Swagger.Number;
Status : .Models.OrdStatus_Type;
Status_History : Swagger.UString_Vectors.Vector_Vectors.Vector;
Error_Message : Swagger.Nullable_UString;
Fills : .Models.Fills_Type_Vectors.Vector;
end record;
package OrderExecutionReport_Type_Vectors is
new Ada.Containers.Vectors (Index_Type => Positive,
Element_Type => OrderExecutionReport_Type);
procedure Serialize (Into : in out Swagger.Streams.Output_Stream'Class;
Name : in String;
Value : in OrderExecutionReport_Type);
procedure Serialize (Into : in out Swagger.Streams.Output_Stream'Class;
Name : in String;
Value : in OrderExecutionReport_Type_Vectors.Vector);
procedure Deserialize (From : in Swagger.Value_Type;
Name : in String;
Value : out OrderExecutionReport_Type);
procedure Deserialize (From : in Swagger.Value_Type;
Name : in String;
Value : out OrderExecutionReport_Type_Vectors.Vector);
type OrderExecutionReportAllOf_Type is
record
Client_Order_Id_Format_Exchange : Swagger.UString;
Exchange_Order_Id : Swagger.Nullable_UString;
Amount_Open : Swagger.Number;
Amount_Filled : Swagger.Number;
Avg_Px : Swagger.Number;
Status : .Models.OrdStatus_Type;
Status_History : Swagger.UString_Vectors.Vector_Vectors.Vector;
Error_Message : Swagger.Nullable_UString;
Fills : .Models.Fills_Type_Vectors.Vector;
end record;
package OrderExecutionReportAllOf_Type_Vectors is
new Ada.Containers.Vectors (Index_Type => Positive,
Element_Type => OrderExecutionReportAllOf_Type);
procedure Serialize (Into : in out Swagger.Streams.Output_Stream'Class;
Name : in String;
Value : in OrderExecutionReportAllOf_Type);
procedure Serialize (Into : in out Swagger.Streams.Output_Stream'Class;
Name : in String;
Value : in OrderExecutionReportAllOf_Type_Vectors.Vector);
procedure Deserialize (From : in Swagger.Value_Type;
Name : in String;
Value : out OrderExecutionReportAllOf_Type);
procedure Deserialize (From : in Swagger.Value_Type;
Name : in String;
Value : out OrderExecutionReportAllOf_Type_Vectors.Vector);
type BalanceData_Type is
record
Asset_Id_Exchange : Swagger.Nullable_UString;
Asset_Id_Coinapi : Swagger.Nullable_UString;
Balance : float;
Available : float;
Locked : float;
Last_Updated_By : Swagger.Nullable_UString;
Rate_Usd : float;
Traded : float;
end record;
package BalanceData_Type_Vectors is
new Ada.Containers.Vectors (Index_Type => Positive,
Element_Type => BalanceData_Type);
procedure Serialize (Into : in out Swagger.Streams.Output_Stream'Class;
Name : in String;
Value : in BalanceData_Type);
procedure Serialize (Into : in out Swagger.Streams.Output_Stream'Class;
Name : in String;
Value : in BalanceData_Type_Vectors.Vector);
procedure Deserialize (From : in Swagger.Value_Type;
Name : in String;
Value : out BalanceData_Type);
procedure Deserialize (From : in Swagger.Value_Type;
Name : in String;
Value : out BalanceData_Type_Vectors.Vector);
type Balance_Type is
record
Exchange_Id : Swagger.Nullable_UString;
Data : .Models.BalanceData_Type_Vectors.Vector;
end record;
package Balance_Type_Vectors is
new Ada.Containers.Vectors (Index_Type => Positive,
Element_Type => Balance_Type);
procedure Serialize (Into : in out Swagger.Streams.Output_Stream'Class;
Name : in String;
Value : in Balance_Type);
procedure Serialize (Into : in out Swagger.Streams.Output_Stream'Class;
Name : in String;
Value : in Balance_Type_Vectors.Vector);
procedure Deserialize (From : in Swagger.Value_Type;
Name : in String;
Value : out Balance_Type);
procedure Deserialize (From : in Swagger.Value_Type;
Name : in String;
Value : out Balance_Type_Vectors.Vector);
type Position_Type is
record
Exchange_Id : Swagger.Nullable_UString;
Data : .Models.PositionData_Type_Vectors.Vector;
end record;
package Position_Type_Vectors is
new Ada.Containers.Vectors (Index_Type => Positive,
Element_Type => Position_Type);
procedure Serialize (Into : in out Swagger.Streams.Output_Stream'Class;
Name : in String;
Value : in Position_Type);
procedure Serialize (Into : in out Swagger.Streams.Output_Stream'Class;
Name : in String;
Value : in Position_Type_Vectors.Vector);
procedure Deserialize (From : in Swagger.Value_Type;
Name : in String;
Value : out Position_Type);
procedure Deserialize (From : in Swagger.Value_Type;
Name : in String;
Value : out Position_Type_Vectors.Vector);
type PositionData_Type is
record
Symbol_Id_Exchange : Swagger.Nullable_UString;
Symbol_Id_Coinapi : Swagger.Nullable_UString;
Avg_Entry_Price : Swagger.Number;
Quantity : Swagger.Number;
Side : .Models.OrdSide_Type;
Unrealized_Pnl : Swagger.Number;
Leverage : Swagger.Number;
Cross_Margin : Swagger.Nullable_Boolean;
Liquidation_Price : Swagger.Number;
Raw_Data : Swagger.Object;
end record;
package PositionData_Type_Vectors is
new Ada.Containers.Vectors (Index_Type => Positive,
Element_Type => PositionData_Type);
procedure Serialize (Into : in out Swagger.Streams.Output_Stream'Class;
Name : in String;
Value : in PositionData_Type);
procedure Serialize (Into : in out Swagger.Streams.Output_Stream'Class;
Name : in String;
Value : in PositionData_Type_Vectors.Vector);
procedure Deserialize (From : in Swagger.Value_Type;
Name : in String;
Value : out PositionData_Type);
procedure Deserialize (From : in Swagger.Value_Type;
Name : in String;
Value : out PositionData_Type_Vectors.Vector);
end .Models;
|
AdaCore/training_material | Ada | 119 | ads | package Debug_Pkg is
procedure Save_Occurrence; -- needs a parameter!
procedure Print_Exceptions;
end Debug_Pkg;
|
melwyncarlo/ProjectEuler | Ada | 303 | adb | with Ada.Text_IO;
with Ada.Integer_Text_IO;
-- Copyright 2021 Melwyn Francis Carlo
procedure A091 is
use Ada.Text_IO;
use Ada.Integer_Text_IO;
Str : constant String (1 .. 12) := "Hello World ";
Num : constant Integer := 2021;
begin
Put (Str);
Put (Num, Width => 0);
end A091;
|
SSOCsoft/Log_Reporter | Ada | 8,077 | ads | With
NSO.JSON,
Ada.Finalization,
Ada.Characters.Latin_1,
Ada.Containers.Ordered_Maps,
Ada.Calendar,
Gnoga.Gui.Base,
Gnoga.Gui.Element.Form,
Gnoga.Gui.Element.Common;
Limited with
Report_Form;
Package NSO.Types.Report_Objects is
Function Debug_Action_Event return Gnoga.Gui.Base.Action_Event;
-- The base report-type for NSO reports.
Type Abstract_Report is abstract new Gnoga.Gui.Element.Common.DIV_Type
with record
Drag_Start,
Drag : Gnoga.Gui.Base.Action_Event := Debug_Action_Event;
end record;
-- We *could* use the drag and drag-start callbacks as class-wide functions,
-- but this would mean we would lose the ability to have custom callbacks,
-- as might be used for debugging, and instead treating everything uniformly.
-- Function Get_Drag_Start_Handler(Input : Abstract_Report'Class) return Action_Event;
-- Function Get_Drag_Handler (Input : Abstract_Report'Class) return Action_Event;
-- Class-wide; calls Add_Self, which populates the form-elements to be sent.
procedure Add_to_Form(
Self : in Abstract_Report'Class;
Form : in out Gnoga.Gui.Element.Form.Form_Type'Class
);
-- Adds the data for the report to the form for submission.
procedure Add_Self(
Self : in Abstract_Report;
Form : in out Gnoga.Gui.Element.Form.Form_Type'Class
) is abstract;
Function Get_Name(
Self : in Abstract_Report
) return String is abstract with Inline;
-- Generic_Create adds a draggable DIV to the Parent, complete with a
-- standard styling; Populate_DiV is the method which contains the
-- report-speciffic construction.
Generic
Type UI_Report_Div(<>) is new Abstract_Report with private;
with Procedure Populate_Div(
Object : in out UI_Report_Div;
Form : in out Gnoga.Gui.Element.Form.Form_Type'Class
);
Name : String;
Procedure Generic_Create(Report : in out UI_Report_Div;
Parent : in out Gnoga.Gui.Base.Base_Type'Class;
Content : in String := "";
ID : in String := ""
);
-- Given an Input, presumed to be a JSON Object-type, Object_Filter will
-- return the result analogous to Input[Name]; raises PROGRAM_ERROR when the
-- Input parameter is not an instance of JSON.Object_Object.
Generic
Name : String;
Function Object_Filter(Input : JSON.Instance'Class)
return JSON.Instance'Class;
Generic
Type Element(<>) is private;
with Package Date_Time_Map is new Ada.Containers.Indefinite_Ordered_Maps(
Key_Type => Ada.Calendar.Time,
Element_Type => Element,
others => <>
);
Default : in Element;
Current : in out Date_Time_Map.Cursor;
Result : in out Date_Time_Map.Map;
Report_Name : in String := "";
with Procedure On_Null is null;
with Procedure On_Boolean( Value : in Boolean ) is null;
with Procedure On_String ( Value : in String ) is null;
with Procedure On_Number ( Value : in JSON.Number ) is null;
with procedure On_Array ( Index : Natural; Value : in JSON.Instance'Class ) is null;
with procedure On_Object ( Key : String; Value : in JSON.Instance'Class ) is null;
Function Process_Date_Time(Data : JSON.Instance'Class) return Date_Time_Map.Map;
Package Date_Time_Indexed_Report is
-----------------------------
-- TIME/DATE SUBPROGRAMS --
-----------------------------
Function Time_String(Time : Ada.Calendar.Time:= Ada.Calendar.Clock) return String;
Function Date_String(Time : Ada.Calendar.Time:= Ada.Calendar.Clock) return String;
Type Date_Time_Report is abstract new Abstract_Report with record
Date : Gnoga.Gui.Element.Form.Date_Type;
Time : Gnoga.Gui.Element.Form.Time_Type;
end record;
Procedure Date_Time_Div(
Object : in out Date_Time_Report'Class;
Form : in out Gnoga.Gui.Element.Form.Form_Type'Class
);
End Date_Time_Indexed_Report;
Private
-- The Abstract_Form_Entry type is the DIV that is added to the HTML-Form to
-- be submitted to the system; as such, it is tied to the Report-type that
-- generates the data to place in the form for submission.
Type Abstract_Form_Entry(For_Report : not null access constant Abstract_Report'Class)
is abstract new Gnoga.Gui.Element.Common.DIV_Type
with null record;
-- Generic_Form_Entry creates a non-abstract instance of Abstract_Form_Entry
-- from the Report_type/Report, it also has an Index function for wrapping
-- a name in brackets, and a Name function for aiding in uniform naming,
-- lastly
Generic
Type Report_Type is new Abstract_Report with private;
Report : in access constant Report_Type;
Form : in out Gnoga.Gui.Element.Form.Form_Type'Class;
Label : in String;
Package Generic_Form_Entry is
Use Gnoga.Gui.Element.Common;
Type Instance is new Abstract_Form_Entry(For_Report => Report)
with null record;
-- Finalize will add the instance to the Form.
Overriding
Procedure Finalize (Object : in out Instance);
-- -- IA is the access-type of the singlton element Form_Entry.
-- Type IA is Access all Instance;
-- Returns '[' & Input & ']'.
-- Intended for use working with form-parameters.
Function Index( Input : String ) return String with Inline;
-- This function returns the concatenation of:
-- GET_NAME, Indicies, and Index(Input).
-- Example given Indices of "[Date][Time]", an Input of "Item" and a
-- Report.Get_Name of "Steve", the String returned is:
-- "Steve[Date][Time][Item]".
Generic
Indices : String;
Function Name( Input : String ) return String with Inline;
-- This object *IS* the DIV which holds the form-elements to submit.
Form_Entry : Instance;
-- Every entry should have a "trash icon" to allow deletion of the record.
Trash : Constant IMG_Access := new IMG_Type;
-- Components is a generic for facilitating the creation of a set of
-- HTML-Form elements which hold the datum of the record for submitting.
Generic
Type T is new Gnoga.Gui.Element.Form.Form_Element_Type with private;
--Gnoga.Gui.Element.Element_Type with private;
Type A is Access All T;
Length : Positive;
Package Components is
Tuple : Constant Array(1..Length) of A:= (Others => new T);
Procedure Place_Items;
Procedure Set_Attributes;
End Components;
Private
Package Latin_1 renames Ada.Characters.Latin_1;
Left_Bracket : Character renames Latin_1.Left_Square_Bracket; -- [
Right_Bracket : Character renames Latin_1.Right_Square_Bracket; -- ]
Bracket_Divide : Constant String := Right_Bracket & Left_Bracket; -- ][
End Generic_Form_Entry;
-- This Name-Binder ensures that the report's string-value of the name is
-- uniform across the report-package; this is useful for ensuring that the
-- value is consistent across related-but-disconnected items like the
-- form submission parameters.
Generic
Name : String;
Type Report_Type(<>) is new Abstract_Report with private;
Package Name_Binder is
Report_Name : Constant String := Name;
Function Get_Name(Self: Report_Type) return String is
(Report_Name) with Inline;
End Name_Binder;
End NSO.Types.Report_Objects;
|
persan/A-gst | Ada | 38,610 | ads | pragma Ada_2005;
pragma Style_Checks (Off);
pragma Warnings (Off);
with Interfaces.C; use Interfaces.C;
with GLIB; -- with GStreamer.GST_Low_Level.glibconfig_h;
with glib;
with glib.Values;
with System;
package GStreamer.GST_Low_Level.gstreamer_0_10_gst_riff_riff_ids_h is
-- unsupported macro: GST_RIFF_RIFF_WAVE GST_MAKE_FOURCC ('W','A','V','E')
-- unsupported macro: GST_RIFF_RIFF_AVI GST_MAKE_FOURCC ('A','V','I',' ')
-- unsupported macro: GST_RIFF_RIFF_CDXA GST_MAKE_FOURCC ('C','D','X','A')
-- unsupported macro: GST_RIFF_TAG_RIFF GST_MAKE_FOURCC ('R','I','F','F')
-- unsupported macro: GST_RIFF_TAG_AVF0 GST_MAKE_FOURCC ('A','V','F','0')
-- unsupported macro: GST_RIFF_TAG_RIFX GST_MAKE_FOURCC ('R','I','F','X')
-- unsupported macro: GST_RIFF_TAG_LIST GST_MAKE_FOURCC ('L','I','S','T')
-- unsupported macro: GST_RIFF_TAG_avih GST_MAKE_FOURCC ('a','v','i','h')
-- unsupported macro: GST_RIFF_TAG_strd GST_MAKE_FOURCC ('s','t','r','d')
-- unsupported macro: GST_RIFF_TAG_strn GST_MAKE_FOURCC ('s','t','r','n')
-- unsupported macro: GST_RIFF_TAG_strh GST_MAKE_FOURCC ('s','t','r','h')
-- unsupported macro: GST_RIFF_TAG_strf GST_MAKE_FOURCC ('s','t','r','f')
-- unsupported macro: GST_RIFF_TAG_vedt GST_MAKE_FOURCC ('v','e','d','t')
-- unsupported macro: GST_RIFF_TAG_JUNK GST_MAKE_FOURCC ('J','U','N','K')
-- unsupported macro: GST_RIFF_TAG_JUNQ GST_MAKE_FOURCC ('J','U','N','Q')
-- unsupported macro: GST_RIFF_TAG_idx1 GST_MAKE_FOURCC ('i','d','x','1')
-- unsupported macro: GST_RIFF_TAG_dmlh GST_MAKE_FOURCC ('d','m','l','h')
-- unsupported macro: GST_RIFF_TAG_ID32 GST_MAKE_FOURCC ('I','D','3','2')
-- unsupported macro: GST_RIFF_TAG_IDVX GST_MAKE_FOURCC ('I','D','V','X')
-- unsupported macro: GST_RIFF_TAG_fmt GST_MAKE_FOURCC ('f','m','t',' ')
-- unsupported macro: GST_RIFF_TAG_data GST_MAKE_FOURCC ('d','a','t','a')
-- unsupported macro: GST_RIFF_TAG_plst GST_MAKE_FOURCC ('p','l','s','t')
-- unsupported macro: GST_RIFF_TAG_cue GST_MAKE_FOURCC ('c','u','e',' ')
-- unsupported macro: GST_RIFF_TAG_bext GST_MAKE_FOURCC ('b','e','x','t')
-- unsupported macro: GST_RIFF_TAG_BEXT GST_MAKE_FOURCC ('B','E','X','T')
-- unsupported macro: GST_RIFF_TAG_fact GST_MAKE_FOURCC ('f','a','c','t')
-- unsupported macro: GST_RIFF_TAG_acid GST_MAKE_FOURCC ('a','c','i','d')
-- unsupported macro: GST_RIFF_LIST_movi GST_MAKE_FOURCC ('m','o','v','i')
-- unsupported macro: GST_RIFF_LIST_hdrl GST_MAKE_FOURCC ('h','d','r','l')
-- unsupported macro: GST_RIFF_LIST_odml GST_MAKE_FOURCC ('o','d','m','l')
-- unsupported macro: GST_RIFF_LIST_strl GST_MAKE_FOURCC ('s','t','r','l')
-- unsupported macro: GST_RIFF_LIST_INFO GST_MAKE_FOURCC ('I','N','F','O')
-- unsupported macro: GST_RIFF_LIST_AVIX GST_MAKE_FOURCC ('A','V','I','X')
-- unsupported macro: GST_RIFF_LIST_adtl GST_MAKE_FOURCC ('a','d','t','l')
-- unsupported macro: GST_RIFF_FCC_vids GST_MAKE_FOURCC ('v','i','d','s')
-- unsupported macro: GST_RIFF_FCC_auds GST_MAKE_FOURCC ('a','u','d','s')
-- unsupported macro: GST_RIFF_FCC_pads GST_MAKE_FOURCC ('p','a','d','s')
-- unsupported macro: GST_RIFF_FCC_txts GST_MAKE_FOURCC ('t','x','t','s')
-- unsupported macro: GST_RIFF_FCC_vidc GST_MAKE_FOURCC ('v','i','d','c')
-- unsupported macro: GST_RIFF_FCC_iavs GST_MAKE_FOURCC ('i','a','v','s')
-- unsupported macro: GST_RIFF_FCCH_RLE GST_MAKE_FOURCC ('R','L','E',' ')
-- unsupported macro: GST_RIFF_FCCH_msvc GST_MAKE_FOURCC ('m','s','v','c')
-- unsupported macro: GST_RIFF_FCCH_MSVC GST_MAKE_FOURCC ('M','S','V','C')
-- unsupported macro: GST_RIFF_INFO_IARL GST_MAKE_FOURCC ('I','A','R','L')
-- unsupported macro: GST_RIFF_INFO_IART GST_MAKE_FOURCC ('I','A','R','T')
-- unsupported macro: GST_RIFF_INFO_ICMS GST_MAKE_FOURCC ('I','C','M','S')
-- unsupported macro: GST_RIFF_INFO_ICMT GST_MAKE_FOURCC ('I','C','M','T')
-- unsupported macro: GST_RIFF_INFO_ICOP GST_MAKE_FOURCC ('I','C','O','P')
-- unsupported macro: GST_RIFF_INFO_ICRD GST_MAKE_FOURCC ('I','C','R','D')
-- unsupported macro: GST_RIFF_INFO_ICRP GST_MAKE_FOURCC ('I','C','R','P')
-- unsupported macro: GST_RIFF_INFO_IDIM GST_MAKE_FOURCC ('I','D','I','M')
-- unsupported macro: GST_RIFF_INFO_IDPI GST_MAKE_FOURCC ('I','D','P','I')
-- unsupported macro: GST_RIFF_INFO_IENG GST_MAKE_FOURCC ('I','E','N','G')
-- unsupported macro: GST_RIFF_INFO_IGNR GST_MAKE_FOURCC ('I','G','N','R')
-- unsupported macro: GST_RIFF_INFO_IKEY GST_MAKE_FOURCC ('I','K','E','Y')
-- unsupported macro: GST_RIFF_INFO_ILGT GST_MAKE_FOURCC ('I','L','G','T')
-- unsupported macro: GST_RIFF_INFO_IMED GST_MAKE_FOURCC ('I','M','E','D')
-- unsupported macro: GST_RIFF_INFO_INAM GST_MAKE_FOURCC ('I','N','A','M')
-- unsupported macro: GST_RIFF_INFO_IPLT GST_MAKE_FOURCC ('I','P','L','T')
-- unsupported macro: GST_RIFF_INFO_IPRD GST_MAKE_FOURCC ('I','P','R','D')
-- unsupported macro: GST_RIFF_INFO_ISBJ GST_MAKE_FOURCC ('I','S','B','J')
-- unsupported macro: GST_RIFF_INFO_ISFT GST_MAKE_FOURCC ('I','S','F','T')
-- unsupported macro: GST_RIFF_INFO_ISHP GST_MAKE_FOURCC ('I','S','H','P')
-- unsupported macro: GST_RIFF_INFO_ISRC GST_MAKE_FOURCC ('I','S','R','C')
-- unsupported macro: GST_RIFF_INFO_ISRF GST_MAKE_FOURCC ('I','S','R','F')
-- unsupported macro: GST_RIFF_INFO_ITCH GST_MAKE_FOURCC ('I','T','C','H')
-- unsupported macro: GST_RIFF_FF00 GST_MAKE_FOURCC (0xFF,0xFF,0x00,0x00)
-- unsupported macro: GST_RIFF_00 GST_MAKE_FOURCC ('0', '0',0x00,0x00)
-- unsupported macro: GST_RIFF_01 GST_MAKE_FOURCC ('0', '1',0x00,0x00)
-- unsupported macro: GST_RIFF_02 GST_MAKE_FOURCC ('0', '2',0x00,0x00)
-- unsupported macro: GST_RIFF_03 GST_MAKE_FOURCC ('0', '3',0x00,0x00)
-- unsupported macro: GST_RIFF_04 GST_MAKE_FOURCC ('0', '4',0x00,0x00)
-- unsupported macro: GST_RIFF_05 GST_MAKE_FOURCC ('0', '5',0x00,0x00)
-- unsupported macro: GST_RIFF_06 GST_MAKE_FOURCC ('0', '6',0x00,0x00)
-- unsupported macro: GST_RIFF_07 GST_MAKE_FOURCC ('0', '7',0x00,0x00)
-- unsupported macro: GST_RIFF_00pc GST_MAKE_FOURCC ('0', '0', 'p', 'c')
-- unsupported macro: GST_RIFF_01pc GST_MAKE_FOURCC ('0', '1', 'p', 'c')
-- unsupported macro: GST_RIFF_00dc GST_MAKE_FOURCC ('0', '0', 'd', 'c')
-- unsupported macro: GST_RIFF_00dx GST_MAKE_FOURCC ('0', '0', 'd', 'x')
-- unsupported macro: GST_RIFF_00db GST_MAKE_FOURCC ('0', '0', 'd', 'b')
-- unsupported macro: GST_RIFF_00xx GST_MAKE_FOURCC ('0', '0', 'x', 'x')
-- unsupported macro: GST_RIFF_00id GST_MAKE_FOURCC ('0', '0', 'i', 'd')
-- unsupported macro: GST_RIFF_00rt GST_MAKE_FOURCC ('0', '0', 'r', 't')
-- unsupported macro: GST_RIFF_0021 GST_MAKE_FOURCC ('0', '0', '2', '1')
-- unsupported macro: GST_RIFF_00iv GST_MAKE_FOURCC ('0', '0', 'i', 'v')
-- unsupported macro: GST_RIFF_0031 GST_MAKE_FOURCC ('0', '0', '3', '1')
-- unsupported macro: GST_RIFF_0032 GST_MAKE_FOURCC ('0', '0', '3', '2')
-- unsupported macro: GST_RIFF_00vc GST_MAKE_FOURCC ('0', '0', 'v', 'c')
-- unsupported macro: GST_RIFF_00xm GST_MAKE_FOURCC ('0', '0', 'x', 'm')
-- unsupported macro: GST_RIFF_01wb GST_MAKE_FOURCC ('0', '1', 'w', 'b')
-- unsupported macro: GST_RIFF_01dc GST_MAKE_FOURCC ('0', '1', 'd', 'c')
-- unsupported macro: GST_RIFF_00__ GST_MAKE_FOURCC ('0', '0', '_', '_')
-- unsupported macro: GST_RIFF_cram GST_MAKE_FOURCC ('c', 'r', 'a', 'm')
-- unsupported macro: GST_RIFF_CRAM GST_MAKE_FOURCC ('C', 'R', 'A', 'M')
-- unsupported macro: GST_RIFF_wham GST_MAKE_FOURCC ('w', 'h', 'a', 'm')
-- unsupported macro: GST_RIFF_WHAM GST_MAKE_FOURCC ('W', 'H', 'A', 'M')
-- unsupported macro: GST_RIFF_rgb GST_MAKE_FOURCC (0x00,0x00,0x00,0x00)
-- unsupported macro: GST_RIFF_RGB GST_MAKE_FOURCC ('R', 'G', 'B', ' ')
-- unsupported macro: GST_RIFF_RAW GST_MAKE_FOURCC ('R', 'A', 'W', ' ')
-- unsupported macro: GST_RIFF_DIB GST_MAKE_FOURCC ('D', 'I', 'B', ' ')
-- unsupported macro: GST_RIFF_rle8 GST_MAKE_FOURCC (0x01,0x00,0x00,0x00)
-- unsupported macro: GST_RIFF_RLE8 GST_MAKE_FOURCC ('R', 'L', 'E', '8')
-- unsupported macro: GST_RIFF_rle4 GST_MAKE_FOURCC (0x02,0x00,0x00,0x00)
-- unsupported macro: GST_RIFF_RLE4 GST_MAKE_FOURCC ('R', 'L', 'E', '4')
-- unsupported macro: GST_RIFF_none GST_MAKE_FOURCC (0x00,0x00,0xFF,0xFF)
-- unsupported macro: GST_RIFF_NONE GST_MAKE_FOURCC ('N', 'O', 'N', 'E')
-- unsupported macro: GST_RIFF_pack GST_MAKE_FOURCC (0x01,0x00,0xFF,0xFF)
-- unsupported macro: GST_RIFF_PACK GST_MAKE_FOURCC ('P', 'A', 'C', 'K')
-- unsupported macro: GST_RIFF_tran GST_MAKE_FOURCC (0x02,0x00,0xFF,0xFF)
-- unsupported macro: GST_RIFF_TRAN GST_MAKE_FOURCC ('T', 'R', 'A', 'N')
-- unsupported macro: GST_RIFF_ccc GST_MAKE_FOURCC (0x03,0x00,0xFF,0xFF)
-- unsupported macro: GST_RIFF_CCC GST_MAKE_FOURCC ('C', 'C', 'C', ' ')
-- unsupported macro: GST_RIFF_cyuv GST_MAKE_FOURCC ('c', 'y', 'u', 'v')
-- unsupported macro: GST_RIFF_CYUV GST_MAKE_FOURCC ('C', 'Y', 'U', 'V')
-- unsupported macro: GST_RIFF_jpeg GST_MAKE_FOURCC (0x04,0x00,0xFF,0xFF)
-- unsupported macro: GST_RIFF_JPEG GST_MAKE_FOURCC ('J', 'P', 'E', 'G')
-- unsupported macro: GST_RIFF_MJPG GST_MAKE_FOURCC ('M', 'J', 'P', 'G')
-- unsupported macro: GST_RIFF_mJPG GST_MAKE_FOURCC ('m', 'J', 'P', 'G')
-- unsupported macro: GST_RIFF_IJPG GST_MAKE_FOURCC ('I', 'J', 'P', 'G')
-- unsupported macro: GST_RIFF_rt21 GST_MAKE_FOURCC ('r', 't', '2', '1')
-- unsupported macro: GST_RIFF_RT21 GST_MAKE_FOURCC ('R', 'T', '2', '1')
-- unsupported macro: GST_RIFF_iv31 GST_MAKE_FOURCC ('i', 'v', '3', '1')
-- unsupported macro: GST_RIFF_IV31 GST_MAKE_FOURCC ('I', 'V', '3', '1')
-- unsupported macro: GST_RIFF_iv32 GST_MAKE_FOURCC ('i', 'v', '3', '2')
-- unsupported macro: GST_RIFF_IV32 GST_MAKE_FOURCC ('I', 'V', '3', '2')
-- unsupported macro: GST_RIFF_iv41 GST_MAKE_FOURCC ('i', 'v', '4', '1')
-- unsupported macro: GST_RIFF_IV41 GST_MAKE_FOURCC ('I', 'V', '4', '1')
-- unsupported macro: GST_RIFF_iv50 GST_MAKE_FOURCC ('i', 'v', '5', '0')
-- unsupported macro: GST_RIFF_IV50 GST_MAKE_FOURCC ('I', 'V', '5', '0')
-- unsupported macro: GST_RIFF_cvid GST_MAKE_FOURCC ('c', 'v', 'i', 'd')
-- unsupported macro: GST_RIFF_CVID GST_MAKE_FOURCC ('C', 'V', 'I', 'D')
-- unsupported macro: GST_RIFF_ULTI GST_MAKE_FOURCC ('U', 'L', 'T', 'I')
-- unsupported macro: GST_RIFF_ulti GST_MAKE_FOURCC ('u', 'l', 't', 'i')
-- unsupported macro: GST_RIFF_YUV9 GST_MAKE_FOURCC ('Y', 'V', 'U', '9')
-- unsupported macro: GST_RIFF_YVU9 GST_MAKE_FOURCC ('Y', 'U', 'V', '9')
-- unsupported macro: GST_RIFF_XMPG GST_MAKE_FOURCC ('X', 'M', 'P', 'G')
-- unsupported macro: GST_RIFF_xmpg GST_MAKE_FOURCC ('x', 'm', 'p', 'g')
-- unsupported macro: GST_RIFF_VDOW GST_MAKE_FOURCC ('V', 'D', 'O', 'W')
-- unsupported macro: GST_RIFF_MVI1 GST_MAKE_FOURCC ('M', 'V', 'I', '1')
-- unsupported macro: GST_RIFF_v422 GST_MAKE_FOURCC ('v', '4', '2', '2')
-- unsupported macro: GST_RIFF_V422 GST_MAKE_FOURCC ('V', '4', '2', '2')
-- unsupported macro: GST_RIFF_mvi1 GST_MAKE_FOURCC ('m', 'v', 'i', '1')
-- unsupported macro: GST_RIFF_MPIX GST_MAKE_FOURCC (0x04,0x00, 'i', '1')
-- unsupported macro: GST_RIFF_AURA GST_MAKE_FOURCC ('A', 'U', 'R', 'A')
-- unsupported macro: GST_RIFF_DMB1 GST_MAKE_FOURCC ('D', 'M', 'B', '1')
-- unsupported macro: GST_RIFF_dmb1 GST_MAKE_FOURCC ('d', 'm', 'b', '1')
-- unsupported macro: GST_RIFF_BW10 GST_MAKE_FOURCC ('B', 'W', '1', '0')
-- unsupported macro: GST_RIFF_bw10 GST_MAKE_FOURCC ('b', 'w', '1', '0')
-- unsupported macro: GST_RIFF_yuy2 GST_MAKE_FOURCC ('y', 'u', 'y', '2')
-- unsupported macro: GST_RIFF_YUY2 GST_MAKE_FOURCC ('Y', 'U', 'Y', '2')
-- unsupported macro: GST_RIFF_YUV8 GST_MAKE_FOURCC ('Y', 'U', 'V', '8')
-- unsupported macro: GST_RIFF_WINX GST_MAKE_FOURCC ('W', 'I', 'N', 'X')
-- unsupported macro: GST_RIFF_WPY2 GST_MAKE_FOURCC ('W', 'P', 'Y', '2')
-- unsupported macro: GST_RIFF_m263 GST_MAKE_FOURCC ('m', '2', '6', '3')
-- unsupported macro: GST_RIFF_M263 GST_MAKE_FOURCC ('M', '2', '6', '3')
-- unsupported macro: GST_RIFF_H263 GST_MAKE_FOURCC ('H', '2', '6', '3')
-- unsupported macro: GST_RIFF_h263 GST_MAKE_FOURCC ('h', '2', '6', '3')
-- unsupported macro: GST_RIFF_i263 GST_MAKE_FOURCC ('i', '2', '6', '3')
-- unsupported macro: GST_RIFF_L263 GST_MAKE_FOURCC ('L', '2', '6', '3')
-- unsupported macro: GST_RIFF_x263 GST_MAKE_FOURCC ('x', '2', '6', '3')
-- unsupported macro: GST_RIFF_VSSH GST_MAKE_FOURCC ( 'V', 'S', 'S', 'H')
-- unsupported macro: GST_RIFF_Q1_0 GST_MAKE_FOURCC ('Q', '1',0x2e, '0')
-- unsupported macro: GST_RIFF_SFMC GST_MAKE_FOURCC ('S', 'F', 'M', 'C')
-- unsupported macro: GST_RIFF_y41p GST_MAKE_FOURCC ('y', '4', '1', 'p')
-- unsupported macro: GST_RIFF_Y41P GST_MAKE_FOURCC ('Y', '4', '1', 'P')
-- unsupported macro: GST_RIFF_yv12 GST_MAKE_FOURCC ('y', 'v', '1', '2')
-- unsupported macro: GST_RIFF_YV12 GST_MAKE_FOURCC ('Y', 'V', '1', '2')
-- unsupported macro: GST_RIFF_vixl GST_MAKE_FOURCC ('v', 'i', 'x', 'l')
-- unsupported macro: GST_RIFF_VIXL GST_MAKE_FOURCC ('V', 'I', 'X', 'L')
-- unsupported macro: GST_RIFF_iyuv GST_MAKE_FOURCC ('i', 'y', 'u', 'v')
-- unsupported macro: GST_RIFF_IYUV GST_MAKE_FOURCC ('I', 'Y', 'U', 'V')
-- unsupported macro: GST_RIFF_i420 GST_MAKE_FOURCC ('i', '4', '2', '0')
-- unsupported macro: GST_RIFF_I420 GST_MAKE_FOURCC ('I', '4', '2', '0')
-- unsupported macro: GST_RIFF_vyuy GST_MAKE_FOURCC ('v', 'y', 'u', 'y')
-- unsupported macro: GST_RIFF_VYUY GST_MAKE_FOURCC ('V', 'Y', 'U', 'Y')
-- unsupported macro: GST_RIFF_DIV3 GST_MAKE_FOURCC ('D', 'I', 'V', '3')
-- unsupported macro: GST_RIFF_rpza GST_MAKE_FOURCC ('r', 'p', 'z', 'a')
-- unsupported macro: GST_RIFF_azpr GST_MAKE_FOURCC ('a', 'z', 'p', 'r')
-- unsupported macro: GST_RIFF_ISFT GST_MAKE_FOURCC ('I', 'S', 'F', 'T')
-- unsupported macro: GST_RIFF_IDIT GST_MAKE_FOURCC ('I', 'D', 'I', 'T')
-- unsupported macro: GST_RIFF_00AM GST_MAKE_FOURCC ('0', '0', 'A', 'M')
-- unsupported macro: GST_RIFF_DISP GST_MAKE_FOURCC ('D', 'I', 'S', 'P')
-- unsupported macro: GST_RIFF_ISBJ GST_MAKE_FOURCC ('I', 'S', 'B', 'J')
-- unsupported macro: GST_RIFF_rec GST_MAKE_FOURCC ('r', 'e', 'c', ' ')
GST_RIFF_STRH_DISABLED : constant := 16#000000001#; -- gst/riff/riff-ids.h:246
GST_RIFF_STRH_VIDEOPALCHANGES : constant := 16#000010000#; -- gst/riff/riff-ids.h:247
GST_RIFF_WAVE_FORMAT_UNKNOWN : constant := (16#0000#); -- gst/riff/riff-ids.h:284
GST_RIFF_WAVE_FORMAT_PCM : constant := (16#0001#); -- gst/riff/riff-ids.h:285
GST_RIFF_WAVE_FORMAT_ADPCM : constant := (16#0002#); -- gst/riff/riff-ids.h:286
GST_RIFF_WAVE_FORMAT_IEEE_FLOAT : constant := (16#0003#); -- gst/riff/riff-ids.h:287
GST_RIFF_WAVE_FORMAT_VSELP : constant := (16#0004#); -- gst/riff/riff-ids.h:288
GST_RIFF_WAVE_FORMAT_IBM_CVSD : constant := (16#0005#); -- gst/riff/riff-ids.h:289
GST_RIFF_WAVE_FORMAT_ALAW : constant := (16#0006#); -- gst/riff/riff-ids.h:290
GST_RIFF_WAVE_FORMAT_MULAW : constant := (16#0007#); -- gst/riff/riff-ids.h:291
GST_RIFF_WAVE_FORMAT_WMS : constant := (16#000a#); -- gst/riff/riff-ids.h:292
GST_RIFF_WAVE_FORMAT_OKI_ADPCM : constant := (16#0010#); -- gst/riff/riff-ids.h:293
GST_RIFF_WAVE_FORMAT_DVI_ADPCM : constant := (16#0011#); -- gst/riff/riff-ids.h:294
GST_RIFF_WAVE_FORMAT_MEDIASPACE_ADPCM : constant := (16#0012#); -- gst/riff/riff-ids.h:295
GST_RIFF_WAVE_FORMAT_SIERRA_ADPCM : constant := (16#0013#); -- gst/riff/riff-ids.h:296
GST_RIFF_WAVE_FORMAT_G723_ADPCM : constant := (16#0014#); -- gst/riff/riff-ids.h:297
GST_RIFF_WAVE_FORMAT_DIGISTD : constant := (16#0015#); -- gst/riff/riff-ids.h:298
GST_RIFF_WAVE_FORMAT_DIGIFIX : constant := (16#0016#); -- gst/riff/riff-ids.h:299
GST_RIFF_WAVE_FORMAT_DIALOGIC_OKI_ADPCM : constant := (16#0017#); -- gst/riff/riff-ids.h:300
GST_RIFF_WAVE_FORMAT_MEDIAVISION_ADPCM : constant := (16#0018#); -- gst/riff/riff-ids.h:301
GST_RIFF_WAVE_FORMAT_CU_CODEC : constant := (16#0019#); -- gst/riff/riff-ids.h:302
GST_RIFF_WAVE_FORMAT_YAMAHA_ADPCM : constant := (16#0020#); -- gst/riff/riff-ids.h:303
GST_RIFF_WAVE_FORMAT_SONARC : constant := (16#0021#); -- gst/riff/riff-ids.h:304
GST_RIFF_WAVE_FORMAT_DSP_TRUESPEECH : constant := (16#0022#); -- gst/riff/riff-ids.h:305
GST_RIFF_WAVE_FORMAT_ECHOSC1 : constant := (16#0023#); -- gst/riff/riff-ids.h:306
GST_RIFF_WAVE_FORMAT_AUDIOFILE_AF36 : constant := (16#0024#); -- gst/riff/riff-ids.h:307
GST_RIFF_WAVE_FORMAT_APTX : constant := (16#0025#); -- gst/riff/riff-ids.h:308
GST_RIFF_WAVE_FORMAT_AUDIOFILE_AF10 : constant := (16#0026#); -- gst/riff/riff-ids.h:309
GST_RIFF_WAVE_FORMAT_PROSODY_1612 : constant := (16#0027#); -- gst/riff/riff-ids.h:310
GST_RIFF_WAVE_FORMAT_LRC : constant := (16#0028#); -- gst/riff/riff-ids.h:311
GST_RIFF_WAVE_FORMAT_DOLBY_AC2 : constant := (16#0030#); -- gst/riff/riff-ids.h:312
GST_RIFF_WAVE_FORMAT_GSM610 : constant := (16#0031#); -- gst/riff/riff-ids.h:313
GST_RIFF_WAVE_FORMAT_MSN : constant := (16#0032#); -- gst/riff/riff-ids.h:314
GST_RIFF_WAVE_FORMAT_ANTEX_ADPCME : constant := (16#0033#); -- gst/riff/riff-ids.h:315
GST_RIFF_WAVE_FORMAT_CONTROL_RES_VQLPC : constant := (16#0034#); -- gst/riff/riff-ids.h:316
GST_RIFF_WAVE_FORMAT_DIGIREAL : constant := (16#0035#); -- gst/riff/riff-ids.h:317
GST_RIFF_WAVE_FORMAT_DIGIADPCM : constant := (16#0036#); -- gst/riff/riff-ids.h:318
GST_RIFF_WAVE_FORMAT_CONTROL_RES_CR10 : constant := (16#0037#); -- gst/riff/riff-ids.h:319
GST_RIFF_WAVE_FORMAT_NMS_VBXADPCM : constant := (16#0038#); -- gst/riff/riff-ids.h:320
GST_RIFF_WAVE_FORMAT_CS_IMAADPCM : constant := (16#0039#); -- gst/riff/riff-ids.h:321
GST_RIFF_WAVE_FORMAT_ECHOSC3 : constant := (16#003A#); -- gst/riff/riff-ids.h:322
GST_RIFF_WAVE_FORMAT_ROCKWELL_ADPCM : constant := (16#003B#); -- gst/riff/riff-ids.h:323
GST_RIFF_WAVE_FORMAT_ROCKWELL_DIGITALK : constant := (16#003C#); -- gst/riff/riff-ids.h:324
GST_RIFF_WAVE_FORMAT_XEBEC : constant := (16#003D#); -- gst/riff/riff-ids.h:325
GST_RIFF_WAVE_FORMAT_ITU_G721_ADPCM : constant := (16#0040#); -- gst/riff/riff-ids.h:326
GST_RIFF_WAVE_FORMAT_G728_CELP : constant := (16#0041#); -- gst/riff/riff-ids.h:327
GST_RIFF_WAVE_FORMAT_MSG723 : constant := (16#0042#); -- gst/riff/riff-ids.h:328
GST_RIFF_WAVE_FORMAT_MPEGL12 : constant := (16#0050#); -- gst/riff/riff-ids.h:329
GST_RIFF_WAVE_FORMAT_RT24 : constant := (16#0052#); -- gst/riff/riff-ids.h:330
GST_RIFF_WAVE_FORMAT_PAC : constant := (16#0053#); -- gst/riff/riff-ids.h:331
GST_RIFF_WAVE_FORMAT_MPEGL3 : constant := (16#0055#); -- gst/riff/riff-ids.h:332
GST_RIFF_WAVE_FORMAT_AMR_NB : constant := (16#0057#); -- gst/riff/riff-ids.h:333
GST_RIFF_WAVE_FORMAT_AMR_WB : constant := (16#0058#); -- gst/riff/riff-ids.h:334
GST_RIFF_WAVE_FORMAT_LUCENT_G723 : constant := (16#0059#); -- gst/riff/riff-ids.h:335
GST_RIFF_WAVE_FORMAT_CIRRUS : constant := (16#0060#); -- gst/riff/riff-ids.h:336
GST_RIFF_WAVE_FORMAT_ADPCM_IMA_DK4 : constant := (16#0061#); -- gst/riff/riff-ids.h:337
GST_RIFF_WAVE_FORMAT_ADPCM_IMA_DK3 : constant := (16#0062#); -- gst/riff/riff-ids.h:338
GST_RIFF_WAVE_FORMAT_CANOPUS_ATRAC : constant := (16#0063#); -- gst/riff/riff-ids.h:344
GST_RIFF_WAVE_FORMAT_G726_ADPCM : constant := (16#0064#); -- gst/riff/riff-ids.h:345
GST_RIFF_WAVE_FORMAT_G722_ADPCM : constant := (16#0065#); -- gst/riff/riff-ids.h:346
GST_RIFF_WAVE_FORMAT_DSAT_DISPLAY : constant := (16#0067#); -- gst/riff/riff-ids.h:347
GST_RIFF_WAVE_FORMAT_ADPCM_IMA_WAV : constant := (16#0069#); -- gst/riff/riff-ids.h:348
GST_RIFF_WAVE_FORMAT_VOXWARE_AC8 : constant := (16#0070#); -- gst/riff/riff-ids.h:353
GST_RIFF_WAVE_FORMAT_VOXWARE_AC10 : constant := (16#0071#); -- gst/riff/riff-ids.h:354
GST_RIFF_WAVE_FORMAT_VOXWARE_AC16 : constant := (16#0072#); -- gst/riff/riff-ids.h:355
GST_RIFF_WAVE_FORMAT_VOXWARE_AC20 : constant := (16#0073#); -- gst/riff/riff-ids.h:356
GST_RIFF_WAVE_FORMAT_VOXWARE_METAVOICE : constant := (16#0074#); -- gst/riff/riff-ids.h:357
GST_RIFF_WAVE_FORMAT_VOXWARE_METASOUND : constant := (16#0075#); -- gst/riff/riff-ids.h:358
GST_RIFF_WAVE_FORMAT_VOXWARE_RT29HW : constant := (16#0076#); -- gst/riff/riff-ids.h:359
GST_RIFF_WAVE_FORMAT_VOXWARE_VR12 : constant := (16#0077#); -- gst/riff/riff-ids.h:360
GST_RIFF_WAVE_FORMAT_VOXWARE_VR18 : constant := (16#0078#); -- gst/riff/riff-ids.h:361
GST_RIFF_WAVE_FORMAT_VOXWARE_TQ40 : constant := (16#0079#); -- gst/riff/riff-ids.h:362
GST_RIFF_WAVE_FORMAT_SOFTSOUND : constant := (16#0080#); -- gst/riff/riff-ids.h:363
GST_RIFF_WAVE_FORMAT_VOXWARE_TQ60 : constant := (16#0081#); -- gst/riff/riff-ids.h:364
GST_RIFF_WAVE_FORMAT_MSRT24 : constant := (16#0082#); -- gst/riff/riff-ids.h:365
GST_RIFF_WAVE_FORMAT_G729A : constant := (16#0083#); -- gst/riff/riff-ids.h:366
GST_RIFF_WAVE_FORMAT_MVI_MVI2 : constant := (16#0084#); -- gst/riff/riff-ids.h:367
GST_RIFF_WAVE_FORMAT_DF_G726 : constant := (16#0085#); -- gst/riff/riff-ids.h:368
GST_RIFF_WAVE_FORMAT_DF_GSM610 : constant := (16#0086#); -- gst/riff/riff-ids.h:369
GST_RIFF_WAVE_FORMAT_ISIAUDIO : constant := (16#0088#); -- gst/riff/riff-ids.h:370
GST_RIFF_WAVE_FORMAT_ONLIVE : constant := (16#0089#); -- gst/riff/riff-ids.h:371
GST_RIFF_WAVE_FORMAT_SBC24 : constant := (16#0091#); -- gst/riff/riff-ids.h:372
GST_RIFF_WAVE_FORMAT_DOLBY_AC3_SPDIF : constant := (16#0092#); -- gst/riff/riff-ids.h:373
GST_RIFF_WAVE_FORMAT_MEDIASONIC_G723 : constant := (16#0093#); -- gst/riff/riff-ids.h:374
GST_RIFF_WAVE_FORMAT_PROSODY_8KBPS : constant := (16#0094#); -- gst/riff/riff-ids.h:375
GST_RIFF_WAVE_FORMAT_ZYXEL_ADPCM : constant := (16#0097#); -- gst/riff/riff-ids.h:376
GST_RIFF_WAVE_FORMAT_PHILIPS_LPCBB : constant := (16#0098#); -- gst/riff/riff-ids.h:377
GST_RIFF_WAVE_FORMAT_PACKED : constant := (16#0099#); -- gst/riff/riff-ids.h:378
GST_RIFF_WAVE_FORMAT_MALDEN_PHONYTALK : constant := (16#00A0#); -- gst/riff/riff-ids.h:379
GST_RIFF_WAVE_FORMAT_AAC : constant := (16#00ff#); -- gst/riff/riff-ids.h:380
GST_RIFF_WAVE_FORMAT_RHETOREX_ADPCM : constant := (16#0100#); -- gst/riff/riff-ids.h:381
GST_RIFF_IBM_FORMAT_MULAW : constant := (16#0101#); -- gst/riff/riff-ids.h:382
GST_RIFF_IBM_FORMAT_ALAW : constant := (16#0102#); -- gst/riff/riff-ids.h:383
GST_RIFF_IBM_FORMAT_ADPCM : constant := (16#0103#); -- gst/riff/riff-ids.h:384
GST_RIFF_WAVE_FORMAT_VIVO_G723 : constant := (16#0111#); -- gst/riff/riff-ids.h:385
GST_RIFF_WAVE_FORMAT_VIVO_SIREN : constant := (16#0112#); -- gst/riff/riff-ids.h:386
GST_RIFF_WAVE_FORMAT_DIGITAL_G723 : constant := (16#0123#); -- gst/riff/riff-ids.h:387
GST_RIFF_WAVE_FORMAT_SANYO_LD_ADPCM : constant := (16#0125#); -- gst/riff/riff-ids.h:388
GST_RIFF_WAVE_FORMAT_SIPROLAB_ACEPLNET : constant := (16#0130#); -- gst/riff/riff-ids.h:389
GST_RIFF_WAVE_FORMAT_SIPROLAB_ACELP4800 : constant := (16#0131#); -- gst/riff/riff-ids.h:390
GST_RIFF_WAVE_FORMAT_SIPROLAB_ACELP8V3 : constant := (16#0132#); -- gst/riff/riff-ids.h:391
GST_RIFF_WAVE_FORMAT_SIPROLAB_G729 : constant := (16#0133#); -- gst/riff/riff-ids.h:392
GST_RIFF_WAVE_FORMAT_SIPROLAB_G729A : constant := (16#0134#); -- gst/riff/riff-ids.h:393
GST_RIFF_WAVE_FORMAT_SIPROLAB_KELVIN : constant := (16#0135#); -- gst/riff/riff-ids.h:394
GST_RIFF_WAVE_FORMAT_G726ADPCM : constant := (16#0140#); -- gst/riff/riff-ids.h:395
GST_RIFF_WAVE_FORMAT_QUALCOMM_PUREVOICE : constant := (16#0150#); -- gst/riff/riff-ids.h:396
GST_RIFF_WAVE_FORMAT_QUALCOMM_HALFRATE : constant := (16#0151#); -- gst/riff/riff-ids.h:397
GST_RIFF_WAVE_FORMAT_TUBGSM : constant := (16#0155#); -- gst/riff/riff-ids.h:398
GST_RIFF_WAVE_FORMAT_WMAV1 : constant := (16#0160#); -- gst/riff/riff-ids.h:399
GST_RIFF_WAVE_FORMAT_WMAV2 : constant := (16#0161#); -- gst/riff/riff-ids.h:400
GST_RIFF_WAVE_FORMAT_WMAV3 : constant := (16#0162#); -- gst/riff/riff-ids.h:401
GST_RIFF_WAVE_FORMAT_WMAV3_L : constant := (16#0163#); -- gst/riff/riff-ids.h:402
GST_RIFF_WAVE_FORMAT_CREATIVE_ADPCM : constant := (16#0200#); -- gst/riff/riff-ids.h:403
GST_RIFF_WAVE_FORMAT_CREATIVE_FASTSPEECH8 : constant := (16#0202#); -- gst/riff/riff-ids.h:404
GST_RIFF_WAVE_FORMAT_CREATIVE_FASTSPEECH10 : constant := (16#0203#); -- gst/riff/riff-ids.h:405
GST_RIFF_WAVE_FORMAT_UHER_ADPCM : constant := (16#0210#); -- gst/riff/riff-ids.h:406
GST_RIFF_WAVE_FORMAT_QUARTERDECK : constant := (16#0220#); -- gst/riff/riff-ids.h:407
GST_RIFF_WAVE_FORMAT_ILINK_VC : constant := (16#0230#); -- gst/riff/riff-ids.h:408
GST_RIFF_WAVE_FORMAT_RAW_SPORT : constant := (16#0240#); -- gst/riff/riff-ids.h:409
GST_RIFF_WAVE_FORMAT_IPI_HSX : constant := (16#0250#); -- gst/riff/riff-ids.h:410
GST_RIFF_WAVE_FORMAT_IPI_RPELP : constant := (16#0251#); -- gst/riff/riff-ids.h:411
GST_RIFF_WAVE_FORMAT_CS2 : constant := (16#0260#); -- gst/riff/riff-ids.h:412
GST_RIFF_WAVE_FORMAT_SONY_ATRAC3 : constant := (16#0270#); -- gst/riff/riff-ids.h:413
GST_RIFF_WAVE_FORMAT_SIREN : constant := (16#028E#); -- gst/riff/riff-ids.h:414
GST_RIFF_WAVE_FORMAT_FM_TOWNS_SND : constant := (16#0300#); -- gst/riff/riff-ids.h:415
GST_RIFF_WAVE_FORMAT_BTV_DIGITAL : constant := (16#0400#); -- gst/riff/riff-ids.h:416
GST_RIFF_WAVE_FORMAT_IMC : constant := (16#0401#); -- gst/riff/riff-ids.h:417
GST_RIFF_WAVE_FORMAT_QDESIGN_MUSIC : constant := (16#0450#); -- gst/riff/riff-ids.h:418
GST_RIFF_WAVE_FORMAT_VME_VMPCM : constant := (16#0680#); -- gst/riff/riff-ids.h:419
GST_RIFF_WAVE_FORMAT_TPC : constant := (16#0681#); -- gst/riff/riff-ids.h:420
GST_RIFF_WAVE_FORMAT_OLIGSM : constant := (16#1000#); -- gst/riff/riff-ids.h:421
GST_RIFF_WAVE_FORMAT_OLIADPCM : constant := (16#1001#); -- gst/riff/riff-ids.h:422
GST_RIFF_WAVE_FORMAT_OLICELP : constant := (16#1002#); -- gst/riff/riff-ids.h:423
GST_RIFF_WAVE_FORMAT_OLISBC : constant := (16#1003#); -- gst/riff/riff-ids.h:424
GST_RIFF_WAVE_FORMAT_OLIOPR : constant := (16#1004#); -- gst/riff/riff-ids.h:425
GST_RIFF_WAVE_FORMAT_LH_CODEC : constant := (16#1100#); -- gst/riff/riff-ids.h:426
GST_RIFF_WAVE_FORMAT_NORRIS : constant := (16#1400#); -- gst/riff/riff-ids.h:427
GST_RIFF_WAVE_FORMAT_SOUNDSPACE_MUSICOMPRESS : constant := (16#1500#); -- gst/riff/riff-ids.h:428
GST_RIFF_WAVE_FORMAT_A52 : constant := (16#2000#); -- gst/riff/riff-ids.h:429
GST_RIFF_WAVE_FORMAT_DTS : constant := (16#2001#); -- gst/riff/riff-ids.h:430
GST_RIFF_WAVE_FORMAT_SONIC : constant := (16#2048#); -- gst/riff/riff-ids.h:431
GST_RIFF_WAVE_FORMAT_SONIC_LS : constant := (16#2048#); -- gst/riff/riff-ids.h:432
GST_RIFF_WAVE_FORMAT_AAC_AC : constant := (16#4143#); -- gst/riff/riff-ids.h:433
GST_RIFF_WAVE_FORMAT_VORBIS1 : constant := (16#674f#); -- gst/riff/riff-ids.h:434
GST_RIFF_WAVE_FORMAT_VORBIS2 : constant := (16#6750#); -- gst/riff/riff-ids.h:435
GST_RIFF_WAVE_FORMAT_VORBIS3 : constant := (16#6751#); -- gst/riff/riff-ids.h:436
GST_RIFF_WAVE_FORMAT_VORBIS1PLUS : constant := (16#676f#); -- gst/riff/riff-ids.h:437
GST_RIFF_WAVE_FORMAT_VORBIS2PLUS : constant := (16#6770#); -- gst/riff/riff-ids.h:438
GST_RIFF_WAVE_FORMAT_VORBIS3PLUS : constant := (16#6771#); -- gst/riff/riff-ids.h:439
GST_RIFF_WAVE_FORMAT_AAC_pm : constant := (16#706d#); -- gst/riff/riff-ids.h:440
GST_RIFF_WAVE_FORMAT_GSM_AMR_CBR : constant := (16#7A21#); -- gst/riff/riff-ids.h:441
GST_RIFF_WAVE_FORMAT_GSM_AMR_VBR : constant := (16#7A22#); -- gst/riff/riff-ids.h:442
GST_RIFF_WAVE_FORMAT_FLAC : constant := (16#F1AC#); -- gst/riff/riff-ids.h:443
GST_RIFF_WAVE_FORMAT_EXTENSIBLE : constant := (16#FFFE#); -- gst/riff/riff-ids.h:444
GST_RIFF_IF_LIST : constant := (16#00000001#); -- gst/riff/riff-ids.h:470
GST_RIFF_IF_KEYFRAME : constant := (16#00000010#); -- gst/riff/riff-ids.h:471
GST_RIFF_IF_NO_TIME : constant := (16#00000100#); -- gst/riff/riff-ids.h:472
GST_RIFF_IF_COMPUSE : constant := (16#0FFF0000#); -- gst/riff/riff-ids.h:473
-- GStreamer RIFF I/O
-- * Copyright (C) 2003 Ronald Bultje <[email protected]>
-- *
-- * riff-ids.h: RIFF IDs and structs
-- *
-- * 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.
--
-- RIFF types
-- tags
-- WAV stuff
-- LIST types
-- fcc types
-- fcc handlers
-- INFO types - see http://www.saettler.com/RIFFMCI/riffmci.html
--********Chunk Names**************
--********VIDEO CODECS*************
-- And this here's the mistakes that need to be supported
--********** FND in MJPG *********
-- common data structures
-- stream type
type gst_riff_strh is record
c_type : aliased GLIB.guint32; -- gst/riff/riff-ids.h:242
fcc_handler : aliased GLIB.guint32; -- gst/riff/riff-ids.h:243
flags : aliased GLIB.guint32; -- gst/riff/riff-ids.h:244
priority : aliased GLIB.guint32; -- gst/riff/riff-ids.h:248
init_frames : aliased GLIB.guint32; -- gst/riff/riff-ids.h:249
scale : aliased GLIB.guint32; -- gst/riff/riff-ids.h:250
rate : aliased GLIB.guint32; -- gst/riff/riff-ids.h:251
start : aliased GLIB.guint32; -- gst/riff/riff-ids.h:252
length : aliased GLIB.guint32; -- gst/riff/riff-ids.h:253
bufsize : aliased GLIB.guint32; -- gst/riff/riff-ids.h:254
quality : aliased GLIB.guint32; -- gst/riff/riff-ids.h:255
samplesize : aliased GLIB.guint32; -- gst/riff/riff-ids.h:256
end record;
pragma Convention (C_Pass_By_Copy, gst_riff_strh); -- gst/riff/riff-ids.h:241
-- fcc_handler
-- flags values
-- initial frames (???)
-- suggested buffer size
-- rcFrame, RECT structure(struct of 4 shorts)
-- gint32 left;
-- gint32 top;
-- gint32 right;
-- gint32 bottom;
--
--subtype gst_riff_strh is u_gst_riff_strh; -- gst/riff/riff-ids.h:263
-- == BitMapInfoHeader
type gst_riff_strf_vids is record
size : aliased GLIB.guint32; -- gst/riff/riff-ids.h:266
width : aliased GLIB.guint32; -- gst/riff/riff-ids.h:267
height : aliased GLIB.guint32; -- gst/riff/riff-ids.h:268
planes : aliased GLIB.guint16; -- gst/riff/riff-ids.h:269
bit_cnt : aliased GLIB.guint16; -- gst/riff/riff-ids.h:270
compression : aliased GLIB.guint32; -- gst/riff/riff-ids.h:271
image_size : aliased GLIB.guint32; -- gst/riff/riff-ids.h:272
xpels_meter : aliased GLIB.guint32; -- gst/riff/riff-ids.h:273
ypels_meter : aliased GLIB.guint32; -- gst/riff/riff-ids.h:274
num_colors : aliased GLIB.guint32; -- gst/riff/riff-ids.h:275
imp_colors : aliased GLIB.guint32; -- gst/riff/riff-ids.h:276
end record;
pragma Convention (C_Pass_By_Copy, gst_riff_strf_vids); -- gst/riff/riff-ids.h:265
-- used colors
-- important colors
-- may be more for some codecs
--subtype gst_riff_strf_vids is u_gst_riff_strf_vids; -- gst/riff/riff-ids.h:278
-- == WaveHeader (?)
type gst_riff_strf_auds is record
format : aliased GLIB.guint16; -- gst/riff/riff-ids.h:282
channels : aliased GLIB.guint16; -- gst/riff/riff-ids.h:445
rate : aliased GLIB.guint32; -- gst/riff/riff-ids.h:446
av_bps : aliased GLIB.guint32; -- gst/riff/riff-ids.h:447
blockalign : aliased GLIB.guint16; -- gst/riff/riff-ids.h:448
size : aliased GLIB.guint16; -- gst/riff/riff-ids.h:453
end record;
pragma Convention (C_Pass_By_Copy, gst_riff_strf_auds); -- gst/riff/riff-ids.h:281
--*** from public Microsoft RIFF docs *****
-- FIXME: where are these from? are they used at all?
-- FIXME: where are these from? are they used at all?
-- missing field:
--subtype gst_riff_strf_auds is u_gst_riff_strf_auds; -- gst/riff/riff-ids.h:454
type gst_riff_strf_iavs is record
DVAAuxSrc : aliased GLIB.guint32; -- gst/riff/riff-ids.h:457
DVAAuxCtl : aliased GLIB.guint32; -- gst/riff/riff-ids.h:458
DVAAuxSrc1 : aliased GLIB.guint32; -- gst/riff/riff-ids.h:459
DVAAuxCtl1 : aliased GLIB.guint32; -- gst/riff/riff-ids.h:460
DVVAuxSrc : aliased GLIB.guint32; -- gst/riff/riff-ids.h:461
DVVAuxCtl : aliased GLIB.guint32; -- gst/riff/riff-ids.h:462
DVReserved1 : aliased GLIB.guint32; -- gst/riff/riff-ids.h:463
DVReserved2 : aliased GLIB.guint32; -- gst/riff/riff-ids.h:464
end record;
pragma Convention (C_Pass_By_Copy, gst_riff_strf_iavs); -- gst/riff/riff-ids.h:456
--subtype gst_riff_strf_iavs is u_gst_riff_strf_iavs; -- gst/riff/riff-ids.h:465
type gst_riff_index_entry is record
id : aliased GLIB.guint32; -- gst/riff/riff-ids.h:468
flags : aliased GLIB.guint32; -- gst/riff/riff-ids.h:469
offset : aliased GLIB.guint32; -- gst/riff/riff-ids.h:474
size : aliased GLIB.guint32; -- gst/riff/riff-ids.h:475
end record;
pragma Convention (C_Pass_By_Copy, gst_riff_index_entry); -- gst/riff/riff-ids.h:467
--subtype gst_riff_index_entry is u_gst_riff_index_entry; -- gst/riff/riff-ids.h:476
type gst_riff_dmlh is record
totalframes : aliased GLIB.guint32; -- gst/riff/riff-ids.h:479
end record;
pragma Convention (C_Pass_By_Copy, gst_riff_dmlh); -- gst/riff/riff-ids.h:478
--subtype gst_riff_dmlh is u_gst_riff_dmlh; -- gst/riff/riff-ids.h:480
-- taken from libsndfile/wav.c (LGPL)
-- 4 bytes (int) type of file:
-- * this appears to be a bit mask,however some combinations
-- * are probably impossible and/or qualified as "errors"
-- *
-- * 0x01 On: One Shot Off: Loop
-- * 0x02 On: Root note is Set Off: No root
-- * 0x04 On: Stretch is On, Off: Strech is OFF
-- * 0x08 On: Disk Based Off: Ram based
-- * 0x10 On: ?????????? Off: ????????? (Acidizer puts that ON)
--
type gst_riff_acid is record
loop_type : aliased GLIB.guint32; -- gst/riff/riff-ids.h:494
root_note : aliased GLIB.guint16; -- gst/riff/riff-ids.h:500
unknown1 : aliased GLIB.guint16; -- gst/riff/riff-ids.h:504
unknown2 : aliased GLIB.gfloat; -- gst/riff/riff-ids.h:505
number_of_beats : aliased GLIB.guint32; -- gst/riff/riff-ids.h:512
meter_d : aliased GLIB.guint16; -- gst/riff/riff-ids.h:513
meter_n : aliased GLIB.guint16; -- gst/riff/riff-ids.h:513
tempo : aliased GLIB.gfloat; -- gst/riff/riff-ids.h:514
end record;
pragma Convention (C_Pass_By_Copy, gst_riff_acid); -- gst/riff/riff-ids.h:483
-- 2 bytes (short) root note
-- * if type 0x10 is OFF : [C,C#,(...),B] -> [0x30 to 0x3B]
-- * if type 0x10 is ON : [C,C#,(...),B] -> [0x3C to 0x47]
-- * (both types fit on same MIDI pitch albeit different octaves, so who cares)
--
-- 2 bytes (short) ??? always set to 0x8000
-- * 4 bytes (float) ??? seems to be always 0
--
-- GStreamer RIFF I/O
-- * Copyright (C) 2003 Ronald Bultje <[email protected]>
-- *
-- * riff-ids.h: RIFF IDs and structs
-- *
-- * 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.
--
-- GStreamer RIFF I/O
-- * Copyright (C) 2003 Ronald Bultje <[email protected]>
-- *
-- * riff-ids.h: RIFF IDs and structs
-- *
-- * 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.
--
-- RIFF types
-- 4 bytes (int) number of beats
-- * 2 bytes (short) meter denominator //always 4 in SF/ACID
-- * 2 bytes (short) meter numerator //always 4 in SF/ACID
-- * //are we sure about the order?? usually its num/denom
-- * 4 bytes (float) tempo
--
--subtype gst_riff_acid is u_gst_riff_acid; -- gst/riff/riff-ids.h:515
end GStreamer.GST_Low_Level.gstreamer_0_10_gst_riff_riff_ids_h;
|
AdaCore/training_material | Ada | 1,095 | ads | pragma Restrictions (No_Elaboration_Code);
pragma Ada_2012;
pragma Style_Checks (Off);
with HAL;
with System;
package STM32_SVD.RNG is
pragma Preelaborate;
---------------
-- Registers --
---------------
-- control register
type CR_Register is null record;
-- TODO: Implement the CR_Register record type according to the
-- STM32F429Discovery datasheet.
-- status register
type SR_Register is null record;
-- TODO: Implement the SR_Register record type according to the
-- STM32F429Discovery datasheet.
-----------------
-- Peripherals --
-----------------
-- Random number generator
type RNG_Peripheral is null record;
-- TODO: Implement the RNG_Peripheral record type according to the
-- STM32F429Discovery datasheet.
-- Use the previously defined CR_Register and SR_Register record types.
-- Random number generator
RNG_Periph : aliased RNG_Peripheral with
Import;
-- TODO: Map RNG_Periph to the physical address specified in the
-- STM32F429Discovery datasheet.
end STM32_SVD.RNG;
|
onox/orka | Ada | 1,183 | ads | -- 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.Doubles.Tensors.GPU;
with Generic_Test_Tensors_Matrices;
with Test_Fixtures_GPU_Tensors;
use all type Orka.Numerics.Doubles.Tensors.GPU.GPU_QR_Factorization;
package Test_Tensors_GPU_Doubles_Matrices is new Generic_Test_Tensors_Matrices
("GPU - Doubles",
Test_Fixtures_GPU_Tensors.Test_Fixture,
Orka.Numerics.Doubles.Tensors,
Orka.Numerics.Doubles.Tensors.GPU.GPU_Tensor,
Orka.Numerics.Doubles.Tensors.GPU.GPU_QR_Factorization,
Orka.Numerics.Doubles.Tensors.GPU.Initialize_Shaders);
|
hfegran/efx32_ada_examples | Ada | 692 | adb | with Ada.Real_time; use Ada.Real_Time;
with Leds; use Leds;
procedure Main is
Duration : constant Time_Span := Milliseconds(100);
begin
Led_Init;
loop
Blink(LED0, Blue, Duration);
Blink(LED1, Green, Duration);
Blink(LED0, Cyan, Duration);
Blink(LED1, Red, Duration);
Blink(LED0, Magenta, Duration);
Blink(LED1, Yellow, Duration);
Blink(LED0, White, Duration);
Blink(LED1, Blue, Duration);
Blink(LED0, Green, Duration);
Blink(LED1, Cyan, Duration);
Blink(LED0, Red, Duration);
Blink(LED1, Magenta, Duration);
Blink(LED0, Yellow, Duration);
Blink(LED1, White, Duration);
end loop;
end Main;
|
landgraf/nanomsg-ada | Ada | 2,457 | adb | -- The MIT License (MIT)
-- Copyright (c) 2015 Pavel Zhukov <[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 Nanomsg.Domains;
with Nanomsg.Pair;
with Aunit.Assertions;
package body Nanomsg.Test_Socket_Bind_Connect is
procedure Run_Test (T : in out TC) is
-- Download attachments based on number selection
-- Download attachments based on timestamp selection
use Aunit.Assertions;
Address : constant String := "tcp://127.0.0.1:5555";
begin
Nanomsg.Socket.Init (T.Socket1, Nanomsg.Domains.Af_Sp, Nanomsg.Pair.Nn_Pair);
Nanomsg.Socket.Init (T.Socket2, Nanomsg.Domains.Af_Sp, Nanomsg.Pair.Nn_Pair);
Assert (Condition => not T.Socket1.Is_Null, Message => "Failed to initialize socket1");
Assert (Condition => not T.Socket2.Is_Null, Message => "Failed to initialize socket2");
Assert (Condition => T.Socket1.Get_Fd /= T.Socket2.Get_Fd,
Message => "Descriptors collision!");
Nanomsg.Socket.Bind (T.Socket1, "tcp://*:5555");
Nanomsg.Socket.Connect (T.Socket2, Address);
end Run_Test;
function Name (T : TC) return Message_String is
begin
return Aunit.Format ("Test case name : Socket bind/connect tests");
end Name;
procedure Tear_Down (T : in out Tc) is
begin
T.Socket1.Close;
T.Socket2.Close;
end Tear_Down;
end Nanomsg.Test_Socket_Bind_Connect;
|
onox/orka | Ada | 6,943 | adb | -- SPDX-License-Identifier: Apache-2.0
--
-- Copyright (c) 2017 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.Numerics.Generic_Elementary_Functions;
package body Orka.Transforms.SIMD_Quaternions is
package EF is new Ada.Numerics.Generic_Elementary_Functions (Vectors.Element_Type);
function Vector_Part (Elements : Quaternion) return Vector4 is
begin
return Result : Vector4 := Vector4 (Elements) do
Result (W) := 0.0;
end return;
end Vector_Part;
function "+" (Left, Right : Quaternion) return Quaternion is
use Vectors;
begin
return Quaternion (Vector4 (Left) + Vector4 (Right));
end "+";
function "*" (Left, Right : Quaternion) return Quaternion is
use Vectors;
Lv : constant Vector4 := Vector_Part (Left);
Rv : constant Vector4 := Vector_Part (Right);
Ls : constant Vectors.Element_Type := Left (W);
Rs : constant Vectors.Element_Type := Right (W);
V : constant Vector4 := Ls * Rv + Rs * Lv + Vectors.Cross (Lv, Rv);
S : constant Element_Type := Ls * Rs - Vectors.Dot (Lv, Rv);
begin
return Result : Quaternion := Quaternion (V) do
Result (W) := S;
end return;
end "*";
function "*" (Left : Vectors.Element_Type; Right : Quaternion) return Quaternion is
use Vectors;
begin
return Quaternion (Left * Vector4 (Right));
end "*";
function "*" (Left : Quaternion; Right : Vectors.Element_Type) return Quaternion is
(Right * Left);
-- Scalar multiplication is commutative
function Conjugate (Elements : Quaternion) return Quaternion is
Element_W : constant Vectors.Element_Type := Elements (W);
use Vectors;
begin
return Result : Quaternion := Quaternion (-Vector4 (Elements)) do
Result (W) := Element_W;
end return;
end Conjugate;
function Inverse (Elements : Quaternion) return Quaternion is
Length : constant Vectors.Element_Type := Vectors.Magnitude2 (Vector4 (Elements));
begin
return Quaternion (Vectors.Divide_Or_Zero
(Vector4 (Conjugate (Elements)), (Length, Length, Length, Length)));
end Inverse;
function Norm (Elements : Quaternion) return Vectors.Element_Type is
(Vectors.Magnitude (Vector4 (Elements)));
function Normalize (Elements : Quaternion) return Quaternion is
(Quaternion (Vectors.Normalize (Vector4 (Elements))));
function Normalized (Elements : Quaternion) return Boolean is
(Vectors.Normalized (Vector4 (Elements)));
function To_Axis_Angle (Elements : Quaternion) return Axis_Angle is
use type Vectors.Element_Type;
Angle : constant Vectors.Element_Type := EF.Arccos (Elements (W)) * 2.0;
SA : constant Vectors.Element_Type := EF.Sin (Angle / 2.0);
begin
if SA /= 0.0 then
declare
use Vectors;
Axis : Vector4 := Vector4 (Elements) * (1.0 / SA);
begin
Axis (W) := 0.0;
return (Axis => Vectors.Direction (Vectors.Normalize (Axis)), Angle => Angle);
end;
else
-- Singularity occurs when angle is 0. Return an arbitrary axis
return (Axis => (1.0, 0.0, 0.0, 0.0), Angle => 0.0);
end if;
end To_Axis_Angle;
function From_Axis_Angle (Value : Axis_Angle) return Quaternion is
(R (Axis => Vector4 (Value.Axis), Angle => Value.Angle));
function R
(Axis : Vector4;
Angle : Vectors.Element_Type) return Quaternion
is
use type Vectors.Element_Type;
CA : constant Vectors.Element_Type := EF.Cos (Angle / 2.0);
SA : constant Vectors.Element_Type := EF.Sin (Angle / 2.0);
use Vectors;
Result : Quaternion := Quaternion (Axis * SA);
begin
Result (W) := CA;
return Normalize (Result);
end R;
function R (Left, Right : Vector4) return Quaternion is
use type Vectors.Element_Type;
S : constant Vector4 := Vectors.Normalize (Left);
T : constant Vector4 := Vectors.Normalize (Right);
E : constant Vectors.Element_Type := Vectors.Dot (S, T);
SRE : constant Vectors.Element_Type := EF.Sqrt (2.0 * (1.0 + E));
use Vectors;
begin
-- Division by zero if Left and Right are in opposite direction.
-- Use rotation axis perpendicular to s and angle of 180 degrees
if SRE /= 0.0 then
-- Equation 4.53 from chapter 4.3 Quaternions from Real-Time Rendering
-- (third edition, 2008)
declare
Result : Quaternion := Quaternion ((1.0 / SRE) * Vectors.Cross (S, T));
begin
Result (W) := SRE / 2.0;
return Normalize (Result);
end;
else
if abs S (Z) < abs S (X) then
return R ((S (Y), -S (X), 0.0, 0.0), Ada.Numerics.Pi);
else
return R ((0.0, -S (Z), S (Y), 0.0), Ada.Numerics.Pi);
end if;
end if;
end R;
function Difference (Left, Right : Quaternion) return Quaternion is
begin
return Right * Conjugate (Left);
end Difference;
function Rotate
(Vector : Vector4;
Rotation : Quaternion) return Vector4
is (Vectors.Vector_Type (Rotation * Quaternion (Vector) * Conjugate (Rotation)));
function Lerp
(Left, Right : Quaternion;
Time : Vectors.Element_Type) return Quaternion
is
use type Vectors.Element_Type;
begin
return Normalize ((1.0 - Time) * Left + Time * Right);
end Lerp;
function Slerp
(Left, Right : Quaternion;
Time : Vectors.Element_Type) return Quaternion
is
use type Vectors.Element_Type;
function Clamp (V : Vectors.Element_Type) return Vectors.Element_Type is
(Vectors.Element_Type'Max (-1.0, Vectors.Element_Type'Min (V, 1.0)));
Cos_Angle : constant Vectors.Element_Type := Vectors.Dot (Vector4 (Left), Vector4 (Right));
Angle : constant Vectors.Element_Type := EF.Arccos (Clamp (Cos_Angle));
SA : constant Vectors.Element_Type := EF.Sin (Angle);
SL : constant Vectors.Element_Type := EF.Sin ((1.0 - Time) * Angle);
SR : constant Vectors.Element_Type := EF.Sin (Time * Angle);
use Vectors;
begin
if SA = 0.0 then
return Lerp (Left, Right, Time);
else
return Normalize ((SL / SA) * Left + (SR / SA) * Right);
end if;
end Slerp;
end Orka.Transforms.SIMD_Quaternions;
|
Ekrekr/Adamazing | Ada | 5,663 | adb | with Ada.Text_IO;
use Ada.Text_IO;
with Ada.Integer_Text_IO;
use Ada.Integer_Text_IO;
with Ada.Containers.Vectors;
with Ada.Numerics.Discrete_Random;
procedure Maze (Size : Integer) is
-- A grid is a 2d array of cells. A cell can either be Fresh (not
-- inspected), Front (Inspected but not set), Clear (inspected and
-- traversable), Blocked (inspected and not traversable), Start or Finish.
type Cell is (Fresh, Front, Clear, Blocked, Start, Finish);
type Grid is array(NATURAL range 1..Size, NATURAL range 1..Size) of Cell;
-- Coordinates are a vector of them are used to to keep track of the
-- frontier.
type Coord is array(NATURAL range 1..2) of NATURAL;
package Coord_Vector is new Ada.Containers.Vectors
(Index_Type => Natural,
Element_Type => Coord);
Start_Coord : Coord := (2, 2);
End_Coord : Coord := (Size-1, Size-1);
Maze_Grid : Grid;
-- Frontier cells are any uninspected cell adjacent to an inspected cell.
Frontier : Coord_Vector.Vector;
Frontier_Cursor : Coord_Vector.Cursor;
-- Set every sell to Fresh, and resets frontier vector.
procedure Clear_Maze is
begin
for I in Maze_Grid'Range (1) loop
for J in Maze_Grid'Range (2) loop
Maze_Grid (I, J) := Fresh;
end loop;
end loop;
Frontier.Clear;
Frontier.Append (Start_Coord);
Maze_Grid (Start_Coord (1), Start_Coord (2)) := Front;
end Clear_Maze;
-- Draw a single cell given the enumerate representation.
procedure Put_Cell (C : Cell) is
begin
if C = Clear then
Put (" ");
elsif C = Blocked then
Put ("██");
elsif C = Start then
Put ("S ");
elsif C = Finish then
Put ("F ");
else
Put (" ");
end if;
end Put_Cell;
-- Draw the full maze in its current form.
procedure Put_Maze is
begin
New_Line(1);
for I in Maze_Grid'Range (1) loop
for J in Maze_Grid'Range (2) loop
Put_Cell (Maze_Grid (I, J));
end loop;
New_Line (1);
end loop;
end Put_Maze;
-- Generate the outside barrier of the maze.
procedure Set_Border is
begin
for I in 1 .. Size loop
Maze_Grid (1, I) := Blocked;
Maze_Grid (Size, I) := Blocked;
Maze_Grid (I, 1) := Blocked;
Maze_Grid (I, Size) := Blocked;
end loop;
end Set_Border;
-- Inspect and act on adjacent cells to a frontier coordinate.
procedure Check_Frontier (C : Coord) is
C_Y : Integer := C (1);
C_X : Integer := C (2);
Y : Integer;
X : Integer;
type Coord_Quad is array(NATURAL range 1..4) of Coord;
New_Coords : Coord_Quad := ((C_Y - 2, C_X), (C_Y, C_X + 2),
(C_Y + 2, C_X), (C_Y, C_X - 2));
New_C : Coord;
begin
for I in New_Coords'Range loop
New_C := New_Coords (I);
Y := New_C (1);
X := New_C (2);
-- Only consider the node if it is within the bounds of the grid.
if Y >= 2 and Y <= Size - 1 and X >= 2 and X <= Size - 1 then
-- If the new node is a frontier then draw a 3-width barrier
-- between, from the direction of the original node to the new
-- node.
if Maze_Grid(Y, X) = Front then
if C_Y > Y then
Maze_Grid(Y + 1, X - 1) := Blocked;
Maze_Grid(Y + 1, X) := Blocked;
Maze_Grid(Y + 1, X + 1) := Blocked;
elsif C_Y < Y then
Maze_Grid(Y - 1, X - 1) := Blocked;
Maze_Grid(Y - 1, X) := Blocked;
Maze_Grid(Y - 1, X + 1) := Blocked;
end if;
if C_X > X then
Maze_Grid(Y + 1, X + 1) := Blocked;
Maze_Grid(Y, X + 1) := Blocked;
Maze_Grid(Y - 1, X + 1) := Blocked;
elsif C_X < X then
Maze_Grid(Y + 1, X - 1) := Blocked;
Maze_Grid(Y, X - 1) := Blocked;
Maze_Grid(Y - 1, X - 1) := Blocked;
end if;
elsif Maze_Grid(Y, X) = Fresh then
Maze_Grid(Y, X) := Front;
Frontier.Append (New_C);
end if;
end if;
end loop;
end Check_Frontier;
-- Selects a random coordinate from the frontier.
Function Rand_Int (Max : Integer) Return Integer is
subtype Int_Range is Integer range 1 .. Max;
package R is new Ada.Numerics.Discrete_Random (Int_Range);
use R;
G : Generator;
Begin
Reset (G);
Return Random(G);
End Rand_Int;
-- Proceeds with a step through the breadth-first search generation.
-- 1. Select a random frontier node from the list of frontier nodes.
-- 2. For all nodes adjacent to this node:
-- a. If the node is already a fontier, place a barrier between the two.
-- b. If the node has not been traversed, and add it to the list.
-- 3. Mark the selected node as traversable and remove it from the list.
procedure Find_Route is
C : Coord;
Search : Integer;
begin
while Integer (Frontier.Length) > 0 loop
Search := Rand_Int (Integer (Frontier.Length));
C := Frontier.Element (Search - 1);
Check_Frontier (C);
Maze_Grid (C (1), C (2)) := Clear;
Frontier.Delete (Search - 1, 1);
end loop;
Maze_Grid (Start_Coord (1), Start_Coord (2)) := Start;
Maze_Grid (End_Coord (1), End_Coord (2)) := Finish;
end Find_Route;
begin
clear_maze;
Set_Border;
Find_Route;
Put_Maze;
end Maze;
|
PThierry/ewok-kernel | Ada | 37 | adb | ../stm32f439/soc-usart-interfaces.adb |
reznikmm/matreshka | Ada | 4,616 | 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_Chart.Mean_Value_Attributes is
------------
-- Create --
------------
overriding function Create
(Parameters : not null access Matreshka.DOM_Attributes.Attribute_L2_Parameters)
return Chart_Mean_Value_Attribute_Node is
begin
return Self : Chart_Mean_Value_Attribute_Node do
Matreshka.ODF_Chart.Constructors.Initialize
(Self'Unchecked_Access,
Parameters.Document,
Matreshka.ODF_String_Constants.Chart_Prefix);
end return;
end Create;
--------------------
-- Get_Local_Name --
--------------------
overriding function Get_Local_Name
(Self : not null access constant Chart_Mean_Value_Attribute_Node)
return League.Strings.Universal_String
is
pragma Unreferenced (Self);
begin
return Matreshka.ODF_String_Constants.Mean_Value_Attribute;
end Get_Local_Name;
begin
Matreshka.DOM_Documents.Register_Attribute
(Matreshka.ODF_String_Constants.Chart_URI,
Matreshka.ODF_String_Constants.Mean_Value_Attribute,
Chart_Mean_Value_Attribute_Node'Tag);
end Matreshka.ODF_Chart.Mean_Value_Attributes;
|
reznikmm/matreshka | Ada | 4,115 | 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.Style_Text_Line_Through_Style_Attributes;
package Matreshka.ODF_Style.Text_Line_Through_Style_Attributes is
type Style_Text_Line_Through_Style_Attribute_Node is
new Matreshka.ODF_Style.Abstract_Style_Attribute_Node
and ODF.DOM.Style_Text_Line_Through_Style_Attributes.ODF_Style_Text_Line_Through_Style_Attribute
with null record;
overriding function Create
(Parameters : not null access Matreshka.DOM_Attributes.Attribute_L2_Parameters)
return Style_Text_Line_Through_Style_Attribute_Node;
overriding function Get_Local_Name
(Self : not null access constant Style_Text_Line_Through_Style_Attribute_Node)
return League.Strings.Universal_String;
end Matreshka.ODF_Style.Text_Line_Through_Style_Attributes;
|
reznikmm/matreshka | Ada | 8,112 | adb | ------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- Localization, Internationalization, Globalization for Ada --
-- --
-- Runtime Library Component --
-- --
------------------------------------------------------------------------------
-- --
-- Copyright © 2010 Vadim Godunko <[email protected]> --
-- --
-- Matreshka 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. Matreshka is distributed in the hope that it will be useful, --
-- but WITHOUT ANY WARRANTY; without even the implied warranty of --
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General --
-- Public License for more details. You should have received a copy of the --
-- GNU General Public License distributed with Matreshka; see file COPYING. --
-- If not, write to the Free Software Foundation, 51 Franklin Street, --
-- Fifth Floor, Boston, MA 02110-1301, 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. --
-- --
------------------------------------------------------------------------------
-- $Revision$ $Date$
------------------------------------------------------------------------------
with Ada.Characters.Latin_1;
with Ada.Strings.Unbounded;
with Ada.Strings.Fixed;
package body Matreshka.Internals.Regexps.Compiler.Debug is
----------
-- Dump --
----------
function Dump (Pattern : not null Shared_Pattern_Access) return String is
use Ada.Characters.Latin_1;
use Ada.Strings;
use Ada.Strings.Fixed;
use Ada.Strings.Unbounded;
procedure Dump (N : Positive);
Indent : Positive := 1;
Offset : constant := 3;
Line : Unbounded_String;
Result : Unbounded_String;
procedure Dump (N : Positive) is
begin
Append (Result, Line);
Append (Result, LF);
Line := Indent * ' ';
Append
(Line,
Trim (Integer'Image (N), Both)
& ' '
& Node_Kinds'Image (Pattern.AST (N).Kind));
case Pattern.AST (N).Kind is
when N_None =>
null;
when N_Match_Any =>
null;
when N_Subexpression =>
if Pattern.AST (N).Capture then
Append (Line, " {capture}");
end if;
Indent := Indent + Offset;
Dump (Get_Expression (Pattern, N));
Indent := Indent - Offset;
when N_Match_Code | N_Member_Code =>
Append
(Line,
' '
& Wide_Wide_Character'Image
(Wide_Wide_Character'Val (Pattern.AST (N).Code)));
when N_Match_Property | N_Member_Property =>
case Pattern.AST (N).Value.Kind is
when None =>
null;
when General_Category =>
Append (Line, " General_Category is");
for J in Pattern.AST (N).Value.GC_Flags'Range loop
if Pattern.AST (N).Value.GC_Flags (J) then
Append
(Line,
' '
& Matreshka.Internals.Unicode.Ucd.
General_Category'Image
(J));
end if;
end loop;
when Binary =>
Append
(Line,
' '
& Matreshka.Internals.Unicode.Ucd.
Boolean_Properties'Image
(Pattern.AST (N).Value.Property));
end case;
if Pattern.AST (N).Negative then
Append (Line, " {negative}");
end if;
when N_Member_Range =>
Append
(Line,
' '
& Wide_Wide_Character'Image
(Wide_Wide_Character'Val (Pattern.AST (N).Low))
& " .. "
& Wide_Wide_Character'Image
(Wide_Wide_Character'Val (Pattern.AST (N).High)));
when N_Character_Class =>
if Pattern.AST (N).Negated then
Append (Line, " {negated}");
end if;
Indent := Indent + Offset;
Dump (Get_Members (Pattern, N));
Indent := Indent - Offset;
when N_Multiplicity =>
Append
(Line,
" ["
& Trim (Natural'Image (Pattern.AST (N).Lower), Both)
& "..");
if Pattern.AST (N).Upper /= Natural'Last then
Append
(Line,
Trim (Natural'Image (Pattern.AST (N).Upper), Both) & ']');
else
Append (Line, "Infinity]");
end if;
if Pattern.AST (N).Greedy then
Append (Line, " {greedy}");
else
Append (Line, " {lazy}");
end if;
Indent := Indent + Offset;
Dump (Get_Expression (Pattern, N));
Indent := Indent - Offset;
when N_Alternation =>
Indent := Indent + Offset;
Append (Result, Line);
Append (Result, LF);
Line := Indent * ' ';
Append (Line, "first");
Indent := Indent + Offset;
Dump (Get_Preferred (Pattern, N));
Indent := Indent - Offset;
Indent := Indent - Offset;
Indent := Indent + Offset;
Append (Result, Line);
Append (Result, LF);
Line := Indent * ' ';
Append (Line, "second");
Indent := Indent + Offset;
Dump (Get_Fallback (Pattern, N));
Indent := Indent - Offset;
Indent := Indent - Offset;
when N_Anchor =>
if Pattern.AST (N).Start_Of_Line then
Append (Line, " {start of line}");
end if;
if Pattern.AST (N).End_Of_Line then
Append (Line, " {end of line}");
end if;
end case;
if Pattern.AST (N).Next /= 0 then
Dump (Pattern.AST (N).Next);
end if;
end Dump;
begin
Dump (Pattern.List (Pattern.Start).Head);
Append (Result, Line);
Append (Result, LF);
return To_String (Result);
end Dump;
end Matreshka.Internals.Regexps.Compiler.Debug;
|
kjseefried/coreland-cgbc | Ada | 2,110 | adb | with BHT_Support;
with Test;
procedure T_BHT_07 is
TC : Test.Context_t;
package BST4 renames BHT_Support.String_Tables4;
Called : Boolean;
Correct_Key : Boolean;
Correct_Value : Boolean;
Expected_Key : BHT_Support.Key_Type4 := "ZZZZ";
Expected_Value : constant Natural := 1;
Exists : Boolean;
Inserted : Boolean;
procedure Process
(Key : BHT_Support.Key_Type4;
Data : Natural) is
begin
Called := True;
Correct_Key := Key = Expected_Key;
Correct_Value := Data = Expected_Value;
end Process;
procedure Query is new BST4.Query_Element (Process);
begin
Test.Initialize
(Test_Context => TC,
Program => "t_bht_07",
Test_DB => "TEST_DB",
Test_Results => "TEST_RESULTS");
BST4.Insert
(Container => BHT_Support.Map,
Key => BHT_Support.Keys (1),
Element => Expected_Value,
Inserted => Inserted);
pragma Assert (Inserted);
Called := False;
Query
(Container => BHT_Support.Map,
Key => "BBBB",
Exists => Exists);
Test.Check
(Test_Context => TC,
Test => 17,
Condition => Called = False,
Statement => "Called = False");
Test.Check
(Test_Context => TC,
Test => 18,
Condition => Exists = False,
Statement => "Exists = False");
Correct_Value := False;
Correct_Key := False;
Expected_Key := BHT_Support.Keys (1);
Query
(Container => BHT_Support.Map,
Key => BHT_Support.Keys (1),
Exists => Exists);
Test.Check
(Test_Context => TC,
Test => 19,
Condition => Called,
Statement => "Called");
Test.Check
(Test_Context => TC,
Test => 20,
Condition => Exists,
Statement => "Exists");
Test.Check
(Test_Context => TC,
Test => 21,
Condition => Correct_Key,
Statement => "Correct_Key");
Test.Check
(Test_Context => TC,
Test => 23,
Condition => Correct_Value,
Statement => "Correct_Value");
end T_BHT_07;
|
stcarrez/ada-css | Ada | 7,337 | adb | -----------------------------------------------------------------------
-- css-analysis-parser -- Rule parser for CSS Analysis
-- Copyright (C) 2017 Stephane Carrez
-- Written by Stephane Carrez ([email protected])
--
-- Licensed under the Apache License, Version 2.0 (the "License");
-- you may not use this file except in compliance with the License.
-- You may obtain a copy of the License at
--
-- http://www.apache.org/licenses/LICENSE-2.0
--
-- Unless required by applicable law or agreed to in writing, software
-- distributed under the License is distributed on an "AS IS" BASIS,
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-- See the License for the specific language governing permissions and
-- limitations under the License.
-----------------------------------------------------------------------
with Ada.Directories;
with Util.Strings;
with Util.Log.Locations;
with CSS.Analysis.Parser.Parser;
with CSS.Analysis.Parser.Parser_Tokens;
package body CSS.Analysis.Parser is
use Ada.Strings.Unbounded;
Current_File : Util.Log.Locations.File_Info_Access;
Current_Repository : CSS.Analysis.Rules.Repository_Access;
-- ------------------------------
-- Load all the rule definition files stored in the given directory.
-- ------------------------------
procedure Load_All (Path : in String;
Repository : in Rules.Repository_Access) is
use Ada.Directories;
Search : Search_Type;
Filter : constant Filter_Type := (Ordinary_File => True, others => False);
Ent : Directory_Entry_Type;
begin
if not Exists (Path) then
Log.Info ("Path {0} does not exist.", Path);
return;
end if;
if Kind (Path) /= Directory then
Log.Error ("Path '{0}' is not a directory.", Path);
return;
end if;
Log.Info ("Scanning directory '{0}' for rule definitions", Path);
Start_Search (Search, Directory => Path, Pattern => "*.def", Filter => Filter);
while More_Entries (Search) loop
Get_Next_Entry (Search, Ent);
declare
Full_Path : constant String := Full_Name (Ent);
begin
Load (Full_Path, Repository);
end;
end loop;
end Load_All;
-- ------------------------------
-- Load the rule definition file and populate the rule repository.
-- ------------------------------
procedure Load (Path : in String;
Repository : Rules.Repository_Access) is
Res : Integer;
begin
Log.Info ("Loading rule definition file {0}", Path);
Current_File := Util.Log.Locations.Create_File_Info (Path, Path'First);
Current_Repository := Repository;
Res := CSS.Analysis.Parser.Parser.Parse (Path);
if Res /= 0 then
Log.Error ("Found {0} errors while parsing {1}", Util.Strings.Image (Res), Path);
end if;
exception
when Parser_Tokens.Syntax_Error =>
Log.Error ("Syntax error while parsing {0}", Path);
end Load;
-- ------------------------------
-- Set the token to represent an identifier at the given source position.
-- ------------------------------
procedure Set_Ident (Into : in out YYstype;
Text : in String;
Line : in Natural;
Column : in Natural) is
begin
Log.Debug ("Identifier {0}", Text);
Into.Rule := null;
Into.Token := To_Unbounded_String (Text);
Into.Line := Line;
Into.Column := Column;
end Set_Ident;
-- ------------------------------
-- Get the value token as an integer.
-- ------------------------------
function Get_Value (Token : in YYstype) return Natural is
begin
return Natural'Value (To_String (Token.Token));
end Get_Value;
-- ------------------------------
-- Create a property rule.
-- ------------------------------
procedure Create_Property (Name : in YYstype;
Rule : in YYstype) is
begin
for Prop_Name of Name.Names loop
if Prop_Name (Prop_Name'First) = '<' then
Current_Repository.Create_Definition (Prop_Name, Rule.Rule);
else
Current_Repository.Create_Property (Prop_Name, Rule.Rule);
end if;
end loop;
end Create_Property;
-- ------------------------------
-- Create a definition rule.
-- ------------------------------
procedure Create_Definition (Name : in YYstype;
Rule : in YYstype) is
begin
Current_Repository.Create_Definition (To_String (Name.Token), Rule.Rule);
end Create_Definition;
-- ------------------------------
-- Create a type or a reference to a definition rule.
-- ------------------------------
procedure Create_Type_Or_Reference (Into : out YYstype;
Name : in YYstype) is
Loc : constant Rules.Location
:= Util.Log.Locations.Create_Line_Info (Current_File, Name.Line, Name.Column);
begin
Into := Name;
Into.Rule := Current_Repository.Create_Definition (To_String (Name.Token), Loc);
end Create_Type_Or_Reference;
-- ------------------------------
-- Create an identifier rule.
-- ------------------------------
procedure Create_Identifier (Into : out YYstype;
Name : in YYstype) is
Loc : constant Rules.Location
:= Util.Log.Locations.Create_Line_Info (Current_File, Name.Line, Name.Column);
begin
Into := Name;
Into.Rule := Rules.Create_Identifier (To_String (Name.Token), Loc);
end Create_Identifier;
-- ------------------------------
-- Create an function with parameter rules.
-- ------------------------------
procedure Create_Function (Into : out YYstype;
Name : in YYstype;
Params : in YYstype) is
Loc : constant Rules.Location
:= Util.Log.Locations.Create_Line_Info (Current_File, Name.Line, Name.Column);
begin
Into := Name;
Into.Rule := Rules.Create_Function (To_String (Name.Token), Params.Rule, Loc);
end Create_Function;
-- Create a list of property names.
procedure Create_Names (List : in out YYstype;
Name : in YYstype) is
begin
List.Names.Append (To_String (Name.Token));
end Create_Names;
procedure Append_Group (Into : out YYstype;
Group : in YYstype;
Item : in YYstype;
Kind : in Rules.Group_Type) is
begin
Into := Group;
Rules.Append_Group (Into.Rule, Group.Rule, Item.Rule, Kind);
end Append_Group;
-- ------------------------------
-- Report an error message while parsing the rule definition file.
-- ------------------------------
procedure Error (Line : in Natural;
Column : in Natural;
Message : in String) is
begin
Log.Error ("{0}:{1} {2}", Util.Log.Locations.Relative_Path (Current_File.all) & ":"
& Util.Strings.Image (Line), Util.Strings.Image (Column), Message);
end Error;
end CSS.Analysis.Parser;
|
reznikmm/matreshka | Ada | 4,367 | adb | ------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- Open Document Toolkit --
-- --
-- Runtime Library Component --
-- --
------------------------------------------------------------------------------
-- --
-- Copyright © 2013, Vadim Godunko <[email protected]> --
-- All rights reserved. --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions --
-- are met: --
-- --
-- * Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- --
-- * Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in the --
-- documentation and/or other materials provided with the distribution. --
-- --
-- * Neither the name of the Vadim Godunko, IE nor the names of its --
-- contributors may be used to endorse or promote products derived from --
-- this software without specific prior written permission. --
-- --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR --
-- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
-- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED --
-- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR --
-- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF --
-- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING --
-- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS --
-- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
-- --
------------------------------------------------------------------------------
-- $Revision$ $Date$
------------------------------------------------------------------------------
with Matreshka.DOM_Nodes;
with XML.DOM.Elements.Internals;
package body ODF.DOM.Elements.Style.Table_Column_Properties.Internals is
------------
-- Create --
------------
function Create
(Node : Matreshka.ODF_Elements.Style.Table_Column_Properties.Style_Table_Column_Properties_Access)
return ODF.DOM.Elements.Style.Table_Column_Properties.ODF_Style_Table_Column_Properties is
begin
return
(XML.DOM.Elements.Internals.Create
(Matreshka.DOM_Nodes.Element_Access (Node)) with null record);
end Create;
----------
-- Wrap --
----------
function Wrap
(Node : Matreshka.ODF_Elements.Style.Table_Column_Properties.Style_Table_Column_Properties_Access)
return ODF.DOM.Elements.Style.Table_Column_Properties.ODF_Style_Table_Column_Properties is
begin
return
(XML.DOM.Elements.Internals.Wrap
(Matreshka.DOM_Nodes.Element_Access (Node)) with null record);
end Wrap;
end ODF.DOM.Elements.Style.Table_Column_Properties.Internals;
|
io7m/coreland-openal-ada | Ada | 2,428 | adb | with OpenAL.Source;
with OpenAL.Context.Error;
with OpenAL.Context;
with Test;
procedure sources_001 is
package AL_Source renames OpenAL.Source;
package ALC renames OpenAL.Context;
package ALC_Error renames OpenAL.Context.Error;
Device : ALC.Device_t;
Context : ALC.Context_t;
OK : Boolean;
Sources : AL_Source.Source_Array_t (1 .. 5);
TC : Test.Context_t;
use type ALC.Device_t;
use type ALC.Context_t;
use type ALC_Error.Error_t;
procedure Finish is
begin
ALC.Destroy_Context (Context);
ALC.Close_Device (Device);
end Finish;
procedure Init is
begin
Device := ALC.Open_Default_Device;
pragma Assert (Device /= ALC.Invalid_Device);
Context := ALC.Create_Context (Device);
pragma Assert (Context /= ALC.Invalid_Context);
OK := ALC.Make_Context_Current (Context);
pragma Assert (OK);
end Init;
begin
Test.Initialize
(Test_Context => TC,
Program => "sources_001",
Test_DB => "TEST_DB",
Test_Results => "TEST_RESULTS");
Init;
AL_Source.Generate_Sources (Sources);
Test.Check (TC, 27, ALC_Error.Get_Error (Device) = ALC_Error.No_Error,
"ALC_Error.Get_Error (Device) = ALC_Error.No_Error");
Test.Check (TC, 28, AL_Source.Is_Valid (Sources (1)), "AL_Source.Is_Valid (Sources (1))");
Test.Check (TC, 29, AL_Source.Is_Valid (Sources (2)), "AL_Source.Is_Valid (Sources (2))");
Test.Check (TC, 30, AL_Source.Is_Valid (Sources (3)), "AL_Source.Is_Valid (Sources (3))");
Test.Check (TC, 31, AL_Source.Is_Valid (Sources (4)), "AL_Source.Is_Valid (Sources (4))");
Test.Check (TC, 32, AL_Source.Is_Valid (Sources (5)), "AL_Source.Is_Valid (Sources (5))");
AL_Source.Delete_Sources (Sources);
Test.Check (TC, 33, ALC_Error.Get_Error (Device) = ALC_Error.No_Error,
"ALC_Error.Get_Error (Device) = ALC_Error.No_Error");
Test.Check (TC, 34, AL_Source.Is_Valid (Sources (1)) = False, "AL_Source.Is_Valid (Sources (1)) = False");
Test.Check (TC, 35, AL_Source.Is_Valid (Sources (2)) = False, "AL_Source.Is_Valid (Sources (2)) = False");
Test.Check (TC, 36, AL_Source.Is_Valid (Sources (3)) = False, "AL_Source.Is_Valid (Sources (3)) = False");
Test.Check (TC, 37, AL_Source.Is_Valid (Sources (4)) = False, "AL_Source.Is_Valid (Sources (4)) = False");
Test.Check (TC, 38, AL_Source.Is_Valid (Sources (5)) = False, "AL_Source.Is_Valid (Sources (5)) = False");
Finish;
end sources_001;
|
zhmu/ananas | Ada | 119 | ads | -- { dg-do compile }
with Private2_Pkg; use Private2_Pkg;
package Private2 is
type R is new Rec2;
end Private2;
|
community-ssu/ncurses | Ada | 8,469 | adb | ------------------------------------------------------------------------------
-- --
-- GNAT ncurses Binding --
-- --
-- Terminal_Interface.Curses.Mouse --
-- --
-- B O D Y --
-- --
------------------------------------------------------------------------------
-- Copyright (c) 1998-2004,2008 Free Software Foundation, Inc. --
-- --
-- Permission is hereby granted, free of charge, to any person obtaining a --
-- copy of this software and associated documentation files (the --
-- "Software"), to deal in the Software without restriction, including --
-- without limitation the rights to use, copy, modify, merge, publish, --
-- distribute, distribute with modifications, sublicense, and/or sell --
-- copies of the Software, and to permit persons to whom the Software is --
-- furnished to do so, subject to the following conditions: --
-- --
-- The above copyright notice and this permission notice shall be included --
-- in all copies or substantial portions of the Software. --
-- --
-- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS --
-- OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF --
-- MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. --
-- IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, --
-- DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR --
-- OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR --
-- THE USE OR OTHER DEALINGS IN THE SOFTWARE. --
-- --
-- Except as contained in this notice, the name(s) of the above copyright --
-- holders shall not be used in advertising or otherwise to promote the --
-- sale, use or other dealings in this Software without prior written --
-- authorization. --
------------------------------------------------------------------------------
-- Author: Juergen Pfeifer, 1996
-- Version Control:
-- $Revision: 1.23 $
-- $Date: 2008/11/16 00:19:59 $
-- Binding Version 01.00
------------------------------------------------------------------------------
with Terminal_Interface.Curses.Aux; use Terminal_Interface.Curses.Aux;
with Interfaces.C; use Interfaces.C;
use Interfaces;
package body Terminal_Interface.Curses.Mouse is
use type System.Bit_Order;
function Has_Mouse return Boolean
is
function Mouse_Avail return C_Int;
pragma Import (C, Mouse_Avail, "has_mouse");
begin
if Has_Key (Key_Mouse) or else Mouse_Avail /= 0 then
return True;
else
return False;
end if;
end Has_Mouse;
function Get_Mouse return Mouse_Event
is
type Event_Access is access all Mouse_Event;
function Getmouse (Ev : Event_Access) return C_Int;
pragma Import (C, Getmouse, "getmouse");
Event : aliased Mouse_Event;
begin
if Getmouse (Event'Access) = Curses_Err then
raise Curses_Exception;
end if;
return Event;
end Get_Mouse;
procedure Register_Reportable_Event (Button : in Mouse_Button;
State : in Button_State;
Mask : in out Event_Mask)
is
Button_Nr : constant Natural := Mouse_Button'Pos (Button);
State_Nr : constant Natural := Button_State'Pos (State);
begin
if Button in Modifier_Keys and then State /= Pressed then
raise Curses_Exception;
else
if Button in Real_Buttons then
Mask := Mask or ((2 ** (6 * Button_Nr)) ** State_Nr);
else
Mask := Mask or (BUTTON_CTRL ** (Button_Nr - 4));
end if;
end if;
end Register_Reportable_Event;
procedure Register_Reportable_Events (Button : in Mouse_Button;
State : in Button_States;
Mask : in out Event_Mask)
is
begin
for S in Button_States'Range loop
if State (S) then
Register_Reportable_Event (Button, S, Mask);
end if;
end loop;
end Register_Reportable_Events;
function Start_Mouse (Mask : Event_Mask := All_Events)
return Event_Mask
is
function MMask (M : Event_Mask;
O : access Event_Mask) return Event_Mask;
pragma Import (C, MMask, "mousemask");
R : Event_Mask;
Old : aliased Event_Mask;
begin
R := MMask (Mask, Old'Access);
if R = No_Events then
Beep;
end if;
return Old;
end Start_Mouse;
procedure End_Mouse (Mask : in Event_Mask := No_Events)
is
begin
if Mask /= No_Events then
Beep;
end if;
end End_Mouse;
procedure Dispatch_Event (Mask : in Event_Mask;
Button : out Mouse_Button;
State : out Button_State);
procedure Dispatch_Event (Mask : in Event_Mask;
Button : out Mouse_Button;
State : out Button_State) is
L : Event_Mask;
begin
Button := Alt; -- preset to non real button;
if (Mask and BUTTON1_EVENTS) /= 0 then
Button := Left;
elsif (Mask and BUTTON2_EVENTS) /= 0 then
Button := Middle;
elsif (Mask and BUTTON3_EVENTS) /= 0 then
Button := Right;
elsif (Mask and BUTTON4_EVENTS) /= 0 then
Button := Button4;
end if;
if Button in Real_Buttons then
L := 2 ** (6 * Mouse_Button'Pos (Button));
for I in Button_State'Range loop
if (Mask and L) /= 0 then
State := I;
exit;
end if;
L := 2 * L;
end loop;
else
State := Pressed;
if (Mask and BUTTON_CTRL) /= 0 then
Button := Control;
elsif (Mask and BUTTON_SHIFT) /= 0 then
Button := Shift;
elsif (Mask and BUTTON_ALT) /= 0 then
Button := Alt;
end if;
end if;
end Dispatch_Event;
procedure Get_Event (Event : in Mouse_Event;
Y : out Line_Position;
X : out Column_Position;
Button : out Mouse_Button;
State : out Button_State)
is
Mask : constant Event_Mask := Event.Bstate;
begin
X := Column_Position (Event.X);
Y := Line_Position (Event.Y);
Dispatch_Event (Mask, Button, State);
end Get_Event;
procedure Unget_Mouse (Event : in Mouse_Event)
is
function Ungetmouse (Ev : Mouse_Event) return C_Int;
pragma Import (C, Ungetmouse, "ungetmouse");
begin
if Ungetmouse (Event) = Curses_Err then
raise Curses_Exception;
end if;
end Unget_Mouse;
function Enclosed_In_Window (Win : Window := Standard_Window;
Event : Mouse_Event) return Boolean
is
function Wenclose (Win : Window; Y : C_Int; X : C_Int)
return Curses_Bool;
pragma Import (C, Wenclose, "wenclose");
begin
if Wenclose (Win, C_Int (Event.Y), C_Int (Event.X))
= Curses_Bool_False then
return False;
else
return True;
end if;
end Enclosed_In_Window;
function Mouse_Interval (Msec : Natural := 200) return Natural
is
function Mouseinterval (Msec : C_Int) return C_Int;
pragma Import (C, Mouseinterval, "mouseinterval");
begin
return Natural (Mouseinterval (C_Int (Msec)));
end Mouse_Interval;
end Terminal_Interface.Curses.Mouse;
|
jrcarter/Lined | Ada | 1,500 | ads | with Lined.Buffer;
with PragmARC.Matching.Character_Regular_Expression;
package Lined.Searching is
function Terminator (Pattern : String; Delimiter : Character; Classes : Boolean := True) return Positive;
-- Returns the index in Pattern of the first occurence of Delimiter that is not preceded by an escape
-- (PragmARC.Matching.Character_Regular_Expression.Escape_Item) or, if Classes, in a class ('[', ']')
-- Classes of False is useful for finding the terminator of a replacement string
-- Raises Invalid_Input if Pattern does not contain such an occurence of Delimiter
procedure Process (Pattern : in String)
with
Post => Pattern = Current;
-- Processes Pattern for future searches and stores Pattern for calls to Search
-- Makes Current return Pattern
-- Raises Invalid_Input if Pattern is not a valid pattern; Current will return "" in this case
function Current return String;
-- Returns the pattern most recently processed by Process
-- Returns "" if Process raised Invalid_Input
-- Initially returns ""
function Search (Current : Natural; Forward : Boolean) return Positive;
-- Returns the number of the next (if Forward) or previous (if not Forward) line matching Searching.Current
-- Raises Invalid_Input if no line matches
function Search (Line : String) return PragmARC.Matching.Character_Regular_Expression.Result;
-- Returns PragmARC.Character_Regular_Expression_Matcher.Location (Current, Line)
end Lined.Searching;
|
reznikmm/matreshka | Ada | 4,728 | ads | ------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- Open Document Toolkit --
-- --
-- Runtime Library Component --
-- --
------------------------------------------------------------------------------
-- --
-- Copyright © 2014, Vadim Godunko <[email protected]> --
-- All rights reserved. --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions --
-- are met: --
-- --
-- * Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- --
-- * Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in the --
-- documentation and/or other materials provided with the distribution. --
-- --
-- * Neither the name of the Vadim Godunko, IE nor the names of its --
-- contributors may be used to endorse or promote products derived from --
-- this software without specific prior written permission. --
-- --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR --
-- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
-- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED --
-- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR --
-- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF --
-- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING --
-- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS --
-- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
-- --
------------------------------------------------------------------------------
-- $Revision$ $Date$
------------------------------------------------------------------------------
with XML.DOM.Visitors;
with ODF.DOM.Text_Index_Title_Elements;
package Matreshka.ODF_Text.Index_Title_Elements is
type Text_Index_Title_Element_Node is
new Matreshka.ODF_Text.Abstract_Text_Element_Node
and ODF.DOM.Text_Index_Title_Elements.ODF_Text_Index_Title
with null record;
overriding function Create
(Parameters : not null access Matreshka.DOM_Elements.Element_L2_Parameters)
return Text_Index_Title_Element_Node;
overriding function Get_Local_Name
(Self : not null access constant Text_Index_Title_Element_Node)
return League.Strings.Universal_String;
overriding procedure Enter_Node
(Self : not null access Text_Index_Title_Element_Node;
Visitor : in out XML.DOM.Visitors.Abstract_Visitor'Class;
Control : in out XML.DOM.Visitors.Traverse_Control);
overriding procedure Leave_Node
(Self : not null access Text_Index_Title_Element_Node;
Visitor : in out XML.DOM.Visitors.Abstract_Visitor'Class;
Control : in out XML.DOM.Visitors.Traverse_Control);
overriding procedure Visit_Node
(Self : not null access Text_Index_Title_Element_Node;
Iterator : in out XML.DOM.Visitors.Abstract_Iterator'Class;
Visitor : in out XML.DOM.Visitors.Abstract_Visitor'Class;
Control : in out XML.DOM.Visitors.Traverse_Control);
end Matreshka.ODF_Text.Index_Title_Elements;
|
reznikmm/matreshka | Ada | 3,643 | ads | ------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- Web Framework --
-- --
-- Tools Component --
-- --
------------------------------------------------------------------------------
-- --
-- Copyright © 2015-2018, Vadim Godunko <[email protected]> --
-- All rights reserved. --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions --
-- are met: --
-- --
-- * Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- --
-- * Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in the --
-- documentation and/or other materials provided with the distribution. --
-- --
-- * Neither the name of the Vadim Godunko, IE nor the names of its --
-- contributors may be used to endorse or promote products derived from --
-- this software without specific prior written permission. --
-- --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR --
-- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
-- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED --
-- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR --
-- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF --
-- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING --
-- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS --
-- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
-- --
------------------------------------------------------------------------------
-- $Revision$ $Date$
------------------------------------------------------------------------------
with Asis;
with Engines.Contexts;
package Properties.Declarations.Incomplete_Type is
function Is_Simple_Type
(Engine : access Engines.Contexts.Context;
Element : Asis.Declaration;
Name : Engines.Boolean_Property) return Boolean;
end Properties.Declarations.Incomplete_Type;
|
stcarrez/ada-keystore | Ada | 1,141 | ads | -----------------------------------------------------------------------
-- keystore-io-tests -- Tests for keystore IO
-- 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 Util.Tests;
package Keystore.IO.Tests is
procedure Add_Tests (Suite : in Util.Tests.Access_Test_Suite);
type Test is new Util.Tests.Test with null record;
procedure Test_File_IO (T : in out Test);
procedure Test_Perf_IO (T : in out Test);
end Keystore.IO.Tests;
|
reznikmm/matreshka | Ada | 4,776 | 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.Number_Boolean_Style_Elements;
package Matreshka.ODF_Number.Boolean_Style_Elements is
type Number_Boolean_Style_Element_Node is
new Matreshka.ODF_Number.Abstract_Number_Element_Node
and ODF.DOM.Number_Boolean_Style_Elements.ODF_Number_Boolean_Style
with null record;
overriding function Create
(Parameters : not null access Matreshka.DOM_Elements.Element_L2_Parameters)
return Number_Boolean_Style_Element_Node;
overriding function Get_Local_Name
(Self : not null access constant Number_Boolean_Style_Element_Node)
return League.Strings.Universal_String;
overriding procedure Enter_Node
(Self : not null access Number_Boolean_Style_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 Number_Boolean_Style_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 Number_Boolean_Style_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_Number.Boolean_Style_Elements;
|
reznikmm/coroutines | Ada | 2,511 | adb | -- Copyright (c) 2019 Maxim Reznik <[email protected]>
--
-- SPDX-License-Identifier: MIT
-- License-Filename: LICENSE
-------------------------------------------------------------
with Ada.Characters.Latin_1;
with Ada.Streams;
with Ada.Strings.Fixed;
with Ada.Text_IO;
with GNAT.Sockets;
with Coroutines.Polling;
procedure CR_Test_Proc is
function Get (URL : String) return Ada.Streams.Stream_Element_Array;
-- Make HTTP GET request
function Get (URL : String) return Ada.Streams.Stream_Element_Array is
use type Ada.Streams.Stream_Element_Offset;
Socket : GNAT.Sockets.Socket_Type;
Slash : constant Natural := Ada.Strings.Fixed.Index
(Source => URL,
Pattern => "/",
From => URL'First + 7);
Host : constant String := URL (URL'First + 7 .. Slash - 1);
Request : String := "GET " & URL (Slash .. URL'Last) & " HTTP/1.1"
& Ada.Characters.Latin_1.CR
& Ada.Characters.Latin_1.LF
& "Host: " & Host
& Ada.Characters.Latin_1.CR
& Ada.Characters.Latin_1.LF
& Ada.Characters.Latin_1.CR
& Ada.Characters.Latin_1.LF;
Data : Ada.Streams.Stream_Element_Array (1 .. Request'Length)
with Import, Convention => Ada, Address => Request'Address;
Last : Ada.Streams.Stream_Element_Offset;
Address : GNAT.Sockets.Sock_Addr_Type;
begin
Address.Addr := GNAT.Sockets.Addresses
(GNAT.Sockets.Get_Host_By_Name (Host), 1);
Address.Port := 80;
GNAT.Sockets.Create_Socket (Socket);
GNAT.Sockets.Connect_Socket (Socket, Address);
GNAT.Sockets.Send_Socket (Socket, Data, Last);
pragma Assert (Last = Data'Last);
-- Suspend current coroutine unti the socket has input.
Coroutines.Yield
(Coroutines.Polling.Watch
(File => Coroutines.Polling.FD (GNAT.Sockets.To_C (Socket)),
Events => (Coroutines.Polling.Input => True, others => False)));
declare
Output : Ada.Streams.Stream_Element_Array (1 .. 4096);
begin
GNAT.Sockets.Receive_Socket (Socket, Output, Last);
-- Code := 200;
Ada.Text_IO.Put_Line ("Last=" & (Last'Img));
return Output (1 .. Last);
end;
end Get;
Response : Ada.Streams.Stream_Element_Array :=
Get ("http://www.google.com/");
Text : String (1 .. Response'Length)
with Import, Convention => Ada, Address => Response'Address;
begin
Ada.Text_IO.Put_Line (Text);
end CR_Test_Proc;
|
jhumphry/SPARK_SipHash | Ada | 2,913 | adb | -- SipHash.Discrete
-- Implementing SipHash over a generic (relatively small) discrete type
-- Copyright (c) 2015, James Humphry - see LICENSE file for details
with Interfaces;
use all type Interfaces.Unsigned_64;
function SipHash.Discrete (m : T_Array) return Hash_Type is
subtype T_Array_8 is T_Array(T_Index'First..T_Index'First+7);
T_Offset : constant Integer := T'Pos(T'First);
function T_Array_8_to_U64_LE (S : in T_Array_8) return U64 with Inline;
function T_Array_Tail_to_U64_LE (S : in T_Array)
return U64
with Inline, Pre => (S'Length <= 7 and then S'Length > 0);
function T_Array_8_to_U64_LE (S : in T_Array_8) return U64 is
(U64(T'Pos(S(S'First)) - T_Offset)
or Shift_Left(U64(T'Pos(S(S'First+1)) - T_Offset), 8)
or Shift_Left(U64(T'Pos(S(S'First+2)) - T_Offset), 16)
or Shift_Left(U64(T'Pos(S(S'First+3)) - T_Offset), 24)
or Shift_Left(U64(T'Pos(S(S'First+4)) - T_Offset), 32)
or Shift_Left(U64(T'Pos(S(S'First+5)) - T_Offset), 40)
or Shift_Left(U64(T'Pos(S(S'First+6)) - T_Offset), 48)
or Shift_Left(U64(T'Pos(S(S'First+7)) - T_Offset), 56));
function T_Array_Tail_to_U64_LE (S : in T_Array)
return U64 is
R : U64 := 0;
Shift : Natural := 0;
T_I : T;
begin
for I in 0..S'Length-1 loop
pragma Loop_Invariant (Shift = I * 8);
T_I := S(S'First + T_Index'Base(I));
R := R or Shift_Left(U64(T'Pos(T_I) - T_Offset), Shift);
Shift := Shift + 8;
end loop;
return R;
end T_Array_Tail_to_U64_LE;
m_pos : T_Index'Base := 0;
m_i : U64;
v : SipHash_State := Get_Initial_State;
w : constant Natural := (m'Length / 8) + 1;
begin
-- This compile-time check is useful for GNAT but in GNATprove it currently
-- just generates a warning that it can not yet prove them correct.
pragma Warnings (GNATprove, Off, "Compile_Time_Error");
pragma Compile_Time_Error ((T'Size > 8),
"SipHash.Discrete only works for discrete " &
"types which fit into one byte.");
pragma Warnings (GNATprove, On, "Compile_Time_Error");
for I in 1..w-1 loop
pragma Loop_Invariant (m_pos = T_Index'Base(I - 1) * 8);
m_i := T_Array_8_to_U64_LE(m(m'First + m_pos..m'First + m_pos + 7));
v(3) := v(3) xor m_i;
for J in 1..c_rounds loop
Sip_Round(v);
end loop;
v(0) := v(0) xor m_i;
m_pos := m_pos + 8;
end loop;
if m_pos < m'Length then
m_i := T_Array_Tail_to_U64_LE(m(m'First + m_pos .. m'Last));
else
m_i := 0;
end if;
m_i := m_i or Shift_Left(U64(m'Length mod 256), 56);
v(3) := v(3) xor m_i;
for J in 1..c_rounds loop
Sip_Round(v);
end loop;
v(0) := v(0) xor m_i;
return Hash_Type'Mod(Sip_Finalization(v));
end SipHash.Discrete;
|
reznikmm/matreshka | Ada | 3,687 | ads | ------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- Open Document Toolkit --
-- --
-- Runtime Library Component --
-- --
------------------------------------------------------------------------------
-- --
-- Copyright © 2013, Vadim Godunko <[email protected]> --
-- All rights reserved. --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions --
-- are met: --
-- --
-- * Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- --
-- * Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in the --
-- documentation and/or other materials provided with the distribution. --
-- --
-- * Neither the name of the Vadim Godunko, IE nor the names of its --
-- contributors may be used to endorse or promote products derived from --
-- this software without specific prior written permission. --
-- --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR --
-- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
-- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED --
-- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR --
-- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF --
-- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING --
-- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS --
-- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
-- --
------------------------------------------------------------------------------
-- $Revision$ $Date$
------------------------------------------------------------------------------
with XML.DOM.Attributes;
package ODF.DOM.Attributes.Style.Text_Underline_Color is
type ODF_Style_Text_Underline_Color is
new XML.DOM.Attributes.DOM_Attribute with private;
private
type ODF_Style_Text_Underline_Color is
new XML.DOM.Attributes.DOM_Attribute with null record;
end ODF.DOM.Attributes.Style.Text_Underline_Color;
|
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.Db_Table_Type_Filter_Elements is
pragma Preelaborate;
type ODF_Db_Table_Type_Filter is limited interface
and XML.DOM.Elements.DOM_Element;
type ODF_Db_Table_Type_Filter_Access is
access all ODF_Db_Table_Type_Filter'Class
with Storage_Size => 0;
end ODF.DOM.Db_Table_Type_Filter_Elements;
|
stcarrez/dynamo | Ada | 4,761 | ads | -----------------------------------------------------------------------
-- gen-artifacts -- Artifacts for Code Generator
-- Copyright (C) 2011, 2012, 2018, 2021 Stephane Carrez
-- Written by Stephane Carrez ([email protected])
--
-- Licensed under the Apache License, Version 2.0 (the "License");
-- you may not use this file except in compliance with the License.
-- You may obtain a copy of the License at
--
-- http://www.apache.org/licenses/LICENSE-2.0
--
-- Unless required by applicable law or agreed to in writing, software
-- distributed under the License is distributed on an "AS IS" BASIS,
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-- See the License for the specific language governing permissions and
-- limitations under the License.
-----------------------------------------------------------------------
with Ada.Finalization;
with DOM.Core;
with Util.Log;
with Gen.Model;
with Gen.Model.Packages;
with Gen.Model.Projects;
-- The <b>Gen.Artifacts</b> package represents the methods and process to prepare,
-- control and realize the code generation.
package Gen.Artifacts is
type Iteration_Mode is (ITERATION_PACKAGE, ITERATION_TABLE);
type Generator is limited interface and Util.Log.Logging;
-- Report an error and set the exit status accordingly
procedure Error (Handler : in out Generator;
Message : in String;
Arg1 : in String;
Arg2 : in String := "") is abstract;
-- Get the config directory path.
function Get_Config_Directory (Handler : in Generator) return String is abstract;
-- Get the result directory path.
function Get_Result_Directory (Handler : in Generator) return String is abstract;
-- Get the configuration parameter.
function Get_Parameter (Handler : in Generator;
Name : in String;
Default : in String := "") return String is abstract;
-- Get the configuration parameter.
function Get_Parameter (Handler : in Generator;
Name : in String;
Default : in Boolean := False) return Boolean is abstract;
-- Tell the generator to activate the generation of the given template name.
-- The name is a property name that must be defined in generator.properties to
-- indicate the template file. Several artifacts can trigger the generation
-- of a given template. The template is generated only once.
procedure Add_Generation (Handler : in out Generator;
Name : in String;
Mode : in Iteration_Mode;
Mapping : in String) is abstract;
-- Scan the dynamo directories and execute the <b>Process</b> procedure with the
-- directory path.
procedure Scan_Directories (Handler : in Generator;
Process : not null access
procedure (Dir : in String)) is abstract;
-- ------------------------------
-- Model Definition
-- ------------------------------
type Artifact is abstract new Ada.Finalization.Limited_Controlled with private;
-- After the configuration file is read, processes the node whose root
-- is passed in <b>Node</b> and initializes the <b>Model</b> with the information.
procedure Initialize (Handler : in out Artifact;
Path : in String;
Node : in DOM.Core.Node;
Model : in out Gen.Model.Packages.Model_Definition'Class;
Context : in out Generator'Class);
-- Prepare the model after all the configuration files have been read and before
-- actually invoking the generation.
procedure Prepare (Handler : in out Artifact;
Model : in out Gen.Model.Packages.Model_Definition'Class;
Project : in out Gen.Model.Projects.Project_Definition'Class;
Context : in out Generator'Class) is null;
-- After the generation, perform a finalization step for the generation process.
procedure Finish (Handler : in out Artifact;
Model : in out Gen.Model.Packages.Model_Definition'Class;
Project : in out Gen.Model.Projects.Project_Definition'Class;
Context : in out Generator'Class) is null;
-- Check whether this artifact has been initialized.
function Is_Initialized (Handler : in Artifact) return Boolean;
private
type Artifact is abstract new Ada.Finalization.Limited_Controlled with record
Initialized : Boolean := False;
end record;
end Gen.Artifacts;
|
optikos/oasis | Ada | 3,793 | ads | -- Copyright (c) 2019 Maxim Reznik <[email protected]>
--
-- SPDX-License-Identifier: MIT
-- License-Filename: LICENSE
-------------------------------------------------------------
with Program.Lexical_Elements;
with Program.Elements.Incomplete_Type_Definitions;
with Program.Element_Visitors;
package Program.Nodes.Incomplete_Type_Definitions is
pragma Preelaborate;
type Incomplete_Type_Definition is
new Program.Nodes.Node
and Program.Elements.Incomplete_Type_Definitions
.Incomplete_Type_Definition
and Program.Elements.Incomplete_Type_Definitions
.Incomplete_Type_Definition_Text
with private;
function Create
(Tagged_Token : Program.Lexical_Elements.Lexical_Element_Access)
return Incomplete_Type_Definition;
type Implicit_Incomplete_Type_Definition is
new Program.Nodes.Node
and Program.Elements.Incomplete_Type_Definitions
.Incomplete_Type_Definition
with private;
function Create
(Is_Part_Of_Implicit : Boolean := False;
Is_Part_Of_Inherited : Boolean := False;
Is_Part_Of_Instance : Boolean := False;
Has_Tagged : Boolean := False)
return Implicit_Incomplete_Type_Definition
with Pre =>
Is_Part_Of_Implicit or Is_Part_Of_Inherited or Is_Part_Of_Instance;
private
type Base_Incomplete_Type_Definition is
abstract new Program.Nodes.Node
and Program.Elements.Incomplete_Type_Definitions
.Incomplete_Type_Definition
with null record;
procedure Initialize
(Self : aliased in out Base_Incomplete_Type_Definition'Class);
overriding procedure Visit
(Self : not null access Base_Incomplete_Type_Definition;
Visitor : in out Program.Element_Visitors.Element_Visitor'Class);
overriding function Is_Incomplete_Type_Definition_Element
(Self : Base_Incomplete_Type_Definition)
return Boolean;
overriding function Is_Definition_Element
(Self : Base_Incomplete_Type_Definition)
return Boolean;
type Incomplete_Type_Definition is
new Base_Incomplete_Type_Definition
and Program.Elements.Incomplete_Type_Definitions
.Incomplete_Type_Definition_Text
with record
Tagged_Token : Program.Lexical_Elements.Lexical_Element_Access;
end record;
overriding function To_Incomplete_Type_Definition_Text
(Self : aliased in out Incomplete_Type_Definition)
return Program.Elements.Incomplete_Type_Definitions
.Incomplete_Type_Definition_Text_Access;
overriding function Tagged_Token
(Self : Incomplete_Type_Definition)
return Program.Lexical_Elements.Lexical_Element_Access;
overriding function Has_Tagged
(Self : Incomplete_Type_Definition)
return Boolean;
type Implicit_Incomplete_Type_Definition is
new Base_Incomplete_Type_Definition
with record
Is_Part_Of_Implicit : Boolean;
Is_Part_Of_Inherited : Boolean;
Is_Part_Of_Instance : Boolean;
Has_Tagged : Boolean;
end record;
overriding function To_Incomplete_Type_Definition_Text
(Self : aliased in out Implicit_Incomplete_Type_Definition)
return Program.Elements.Incomplete_Type_Definitions
.Incomplete_Type_Definition_Text_Access;
overriding function Is_Part_Of_Implicit
(Self : Implicit_Incomplete_Type_Definition)
return Boolean;
overriding function Is_Part_Of_Inherited
(Self : Implicit_Incomplete_Type_Definition)
return Boolean;
overriding function Is_Part_Of_Instance
(Self : Implicit_Incomplete_Type_Definition)
return Boolean;
overriding function Has_Tagged
(Self : Implicit_Incomplete_Type_Definition)
return Boolean;
end Program.Nodes.Incomplete_Type_Definitions;
|
afrl-rq/OpenUxAS | Ada | 8,670 | adb | with Ada.Containers.Formal_Hashed_Maps;
with Ada.Strings.Hash;
with Ada.Directories;
with DOM.Core.Documents;
with DOM.Core.Elements;
with Input_Sources.Strings;
with DOM.Readers;
with Sax.Encodings;
with UxAS.Common.String_Constant;
package body UxAS.Comms.LMCP_Net_Client.Service is
function Hashed_Service_Type_Name (Element : Service_Type_Name) return Ada.Containers.Hash_Type is
(Ada.Strings.Hash (Value (Element)));
package Creation_Function_To_Service_Names is new Ada.Containers.Formal_Hashed_Maps
(Element_Type => Service_Creation_Function_Pointer,
Key_Type => Service_Type_Name,
Hash => Hashed_Service_Type_Name,
Equivalent_Keys => "=");
Function_Map_Capacity : constant := 100; -- arbitrary
subtype Creation_Function_Map is Creation_Function_To_Service_Names.Map
(Function_Map_Capacity,
Creation_Function_To_Service_Names.Default_Modulus (Function_Map_Capacity));
--------------------------------
-- Creation_Function_Registry --
--------------------------------
-- static
-- std::unordered_map<std::string, ServiceBase::serviceCreationFunctionPointer>&
-- createFunctionByServiceType()
-- We implement createFunctionByServiceType via this simple decl
Creation_Function_Registry : Creation_Function_Map;
-------------------------------------------------
-- Register_Service_Creation_Function_Pointers --
-------------------------------------------------
procedure Register_Service_Creation_Function_Pointers
(Service_Type_Names : Service_Type_Names_List;
Associated_Creator : Service_Creation_Function_Pointer)
is
use Creation_Function_To_Service_Names;
C : Cursor;
begin
for Name of Service_Type_Names loop
C := Find (Creation_Function_Registry, Name);
if C = No_Element then
Insert (Creation_Function_Registry, Name, Associated_Creator);
else
-- note that the C++ version issues a warning here
Replace_Element (Creation_Function_Registry, C, Associated_Creator);
end if;
end loop;
end Register_Service_Creation_Function_Pointers;
-----------------------
-- Construct_Service --
-----------------------
procedure Construct_Service
(This : in out Service_Base;
Service_Type : String;
Work_Directory_Name : String)
is
begin
This.Construct_Client;
-- ServiceBase::ServiceBase(const std::string& serviceType, const std::string& workDirectoryName)
-- : m_serviceType(serviceType), m_workDirectoryName(workDirectoryName)
-- {
-- m_serviceId = m_networkId;
Copy (Service_Type, This.Service_Type);
Copy (Work_Directory_Name, This.Work_Directory_Name);
This.Service_Id := UInt32'Mod (This.Network_Id);
This.Is_Constructed := True;
end Construct_Service;
-------------------------
-- Instantiate_Service --
-------------------------
function Instantiate_Service
(Type_Name : String)
return Any_Service
is
Result : Any_Service;
Target : constant Service_Type_Name := Instance (Service_Type_Name_Max_Length, Type_Name);
Creator : Service_Creation_Function_Pointer;
use Creation_Function_To_Service_Names;
C : Cursor;
begin
-- static
-- std::unique_ptr<ServiceBase>
-- instantiateService(const std::string& serviceType)
-- {
-- auto it = createFunctionByServiceType().find(serviceType);
-- ServiceBase * newService(it == createFunctionByServiceType().end() ? nullptr : (it->second)());
-- std::unique_ptr<ServiceBase> service(newService);
-- return (service);
-- };
C := Find (Creation_Function_Registry, Target);
if C = No_Element then
return null;
end if;
Creator := Element (Creation_Function_Registry, C); -- get the creator function
Result := Creator.all; -- call the function
return Result;
end Instantiate_Service;
-----------------------
-- Configure_Service --
-----------------------
procedure Configure_Service
(This : in out Service_Base;
Parent_Of_Work_Directory : String;
ServiceXml : String;
Result : out Boolean)
is
use DOM.Core;
use DOM.Readers;
use Input_Sources.Strings;
Input : String_Input;
Reader : Tree_Reader;
Doc : Document;
begin
Input_Sources.Strings.Open (ServiceXml, Sax.Encodings.Encoding, Input);
Reader.Parse (Input);
Close (Input);
Doc := Get_Tree (Reader);
Configure_Service
(Service_Base'Class (This),
Parent_Of_Work_Directory,
Documents.Get_Element (Doc),
This.Is_Configured);
Result := This.Is_Configured;
end Configure_Service;
-----------------------
-- Configure_Service --
-----------------------
procedure Configure_Service
(This : in out Service_Base;
Parent_Of_Work_Directory : String;
Service_XML_Node : DOM.Core.Element;
Result : out Boolean)
is
function Slash_Appended (S : String) return String with
Pre => S'Length > 0,
Post => Slash_Appended'Result (Slash_Appended'Result'Last) = '/';
function Slash_Appended (S : String) return String is
(if S (S'Last) = '/' then S else S & "/");
begin
if This.Work_Directory_Name /= "" then
Copy (Slash_Appended (Parent_Of_Work_Directory) & Slash_Appended (Value (This.Work_Directory_Name)),
To => This.Work_Directory_Path);
else
Clear (This.Work_Directory_Path);
end if;
Configure_Network_Client
(This,
Subclass_Type_Name => Value (This.Service_Type),
Processing_Kind => This.Processing_Type,
Network_Client_XML_Node => Service_XML_Node,
Result => Result);
if Result then
declare
Group : constant DOM.Core.DOM_String := DOM.Core.Elements.Get_Attribute (Service_XML_Node, Name => UxAS.Common.String_Constant.MessageGroup);
begin
if Group /= "" then
-- set source group value that will be assigned to source group field of sent messages
Copy (Group, To => This.Message_Source_Group);
-- subscribe to messages addressed to non-empty source group value
This.Add_Subscription_Address (Group, Success => Result);
end if;
end;
end if;
This.Is_Configured := Result;
end Configure_Service;
----------------------------------
-- Initialize_And_Start_Service --
----------------------------------
procedure Initialize_And_Start_Service
(This : in out Service_Base;
Result : out Boolean)
is
begin
Result := False;
if This.Is_Configured then
if not Empty (This.Work_Directory_Path) then
begin
Ada.Directories.Create_Path (Value (This.Work_Directory_Path));
exception -- TODO !!!!!
when others =>
return;
end;
end if;
Initialize_And_Start (This, Result);
end if;
end Initialize_And_Start_Service;
---------------------------
-- Get_Unique_Service_Id --
---------------------------
function Get_Unique_Service_Id return Int64 is
Result : Int64;
begin
Get_Unique_Network_Client_Id (Result);
return Result;
end Get_Unique_Service_Id;
--------------------
-- Get_Service_Id --
--------------------
function Get_Service_Id (This : Service_Base) return UInt32 is
(This.Service_Id);
----------------------
-- Get_Service_Type --
----------------------
function Get_Service_Type (This : Service_Base) return String is
(Value (This.Service_Type));
-----------------------------
-- Get_Work_Directory_Name --
-----------------------------
function Get_Work_Directory_Name (This : Service_Base) return String is
(Value (This.Work_Directory_Name));
----------------
-- Configured --
----------------
function Configured (This : Service_Base) return Boolean is
(This.Is_Configured);
-----------------
-- Constructed --
-----------------
function Constructed (This : Service_Base) return Boolean is
(This.Is_Constructed);
end UxAS.Comms.LMCP_Net_Client.Service;
|
reznikmm/matreshka | Ada | 4,615 | 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.Page_Adjust_Attributes is
------------
-- Create --
------------
overriding function Create
(Parameters : not null access Matreshka.DOM_Attributes.Attribute_L2_Parameters)
return Text_Page_Adjust_Attribute_Node is
begin
return Self : Text_Page_Adjust_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_Page_Adjust_Attribute_Node)
return League.Strings.Universal_String
is
pragma Unreferenced (Self);
begin
return Matreshka.ODF_String_Constants.Page_Adjust_Attribute;
end Get_Local_Name;
begin
Matreshka.DOM_Documents.Register_Attribute
(Matreshka.ODF_String_Constants.Text_URI,
Matreshka.ODF_String_Constants.Page_Adjust_Attribute,
Text_Page_Adjust_Attribute_Node'Tag);
end Matreshka.ODF_Text.Page_Adjust_Attributes;
|
Sejik/SignalAnalysis | Ada | 4,249 | adb | ----------------------------------------------------------------
-- ZLib for Ada thick binding. --
-- --
-- Copyright (C) 2002-2003 Dmitriy Anisimkov --
-- --
-- Open source license information is in the zlib.ads file. --
----------------------------------------------------------------
-- $Id: read.adb,v 1.2 2007/06/14 11:55:45 duncan Exp $
-- Test/demo program for the generic read interface.
with Ada.Numerics.Discrete_Random;
with Ada.Streams;
with Ada.Text_IO;
with ZLib;
procedure Read is
use Ada.Streams;
------------------------------------
-- Test configuration parameters --
------------------------------------
File_Size : Stream_Element_Offset := 100_000;
Continuous : constant Boolean := False;
-- If this constant is True, the test would be repeated again and again,
-- with increment File_Size for every iteration.
Header : constant ZLib.Header_Type := ZLib.Default;
-- Do not use Header other than Default in ZLib versions 1.1.4 and older.
Init_Random : constant := 8;
-- We are using the same random sequence, in case of we catch bug,
-- so we would be able to reproduce it.
-- End --
Pack_Size : Stream_Element_Offset;
Offset : Stream_Element_Offset;
Filter : ZLib.Filter_Type;
subtype Visible_Symbols
is Stream_Element range 16#20# .. 16#7E#;
package Random_Elements is new
Ada.Numerics.Discrete_Random (Visible_Symbols);
Gen : Random_Elements.Generator;
Period : constant Stream_Element_Offset := 200;
-- Period constant variable for random generator not to be very random.
-- Bigger period, harder random.
Read_Buffer : Stream_Element_Array (1 .. 2048);
Read_First : Stream_Element_Offset;
Read_Last : Stream_Element_Offset;
procedure Reset;
procedure Read
(Item : out Stream_Element_Array;
Last : out Stream_Element_Offset);
-- this procedure is for generic instantiation of
-- ZLib.Read
-- reading data from the File_In.
procedure Read is new ZLib.Read
(Read,
Read_Buffer,
Rest_First => Read_First,
Rest_Last => Read_Last);
----------
-- Read --
----------
procedure Read
(Item : out Stream_Element_Array;
Last : out Stream_Element_Offset) is
begin
Last := Stream_Element_Offset'Min
(Item'Last,
Item'First + File_Size - Offset);
for J in Item'First .. Last loop
if J < Item'First + Period then
Item (J) := Random_Elements.Random (Gen);
else
Item (J) := Item (J - Period);
end if;
Offset := Offset + 1;
end loop;
end Read;
-----------
-- Reset --
-----------
procedure Reset is
begin
Random_Elements.Reset (Gen, Init_Random);
Pack_Size := 0;
Offset := 1;
Read_First := Read_Buffer'Last + 1;
Read_Last := Read_Buffer'Last;
end Reset;
begin
Ada.Text_IO.Put_Line ("ZLib " & ZLib.Version);
loop
for Level in ZLib.Compression_Level'Range loop
Ada.Text_IO.Put ("Level ="
& ZLib.Compression_Level'Image (Level));
-- Deflate using generic instantiation.
ZLib.Deflate_Init
(Filter,
Level,
Header => Header);
Reset;
Ada.Text_IO.Put
(Stream_Element_Offset'Image (File_Size) & " ->");
loop
declare
Buffer : Stream_Element_Array (1 .. 1024);
Last : Stream_Element_Offset;
begin
Read (Filter, Buffer, Last);
Pack_Size := Pack_Size + Last - Buffer'First + 1;
exit when Last < Buffer'Last;
end;
end loop;
Ada.Text_IO.Put_Line (Stream_Element_Offset'Image (Pack_Size));
ZLib.Close (Filter);
end loop;
exit when not Continuous;
File_Size := File_Size + 1;
end loop;
end Read;
|
faelys/natools | Ada | 927 | adb | with Interfaces; use Interfaces;
package body Natools.Static_Maps.S_Expressions.Conditionals.Strings.S is
P : constant array (0 .. 0) of Natural :=
(0 .. 0 => 4);
T1 : constant array (0 .. 0) of Unsigned_8 :=
(0 .. 0 => 4);
T2 : constant array (0 .. 0) of Unsigned_8 :=
(0 .. 0 => 3);
G : constant array (0 .. 4) of Unsigned_8 :=
(0, 0, 0, 0, 1);
function Hash (S : String) return Natural is
F : constant Natural := S'First - 1;
L : constant Natural := S'Length;
F1, F2 : Natural := 0;
J : Natural;
begin
for K in P'Range loop
exit when L < P (K);
J := Character'Pos (S (P (K) + F));
F1 := (F1 + Natural (T1 (K)) * J) mod 5;
F2 := (F2 + Natural (T2 (K)) * J) mod 5;
end loop;
return (Natural (G (F1)) + Natural (G (F2))) mod 2;
end Hash;
end Natools.Static_Maps.S_Expressions.Conditionals.Strings.S;
|
reznikmm/matreshka | Ada | 3,483 | ads | ------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- Open Document Toolkit --
-- --
-- Runtime Library Component --
-- --
------------------------------------------------------------------------------
-- --
-- Copyright © 2013, Vadim Godunko <[email protected]> --
-- All rights reserved. --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions --
-- are met: --
-- --
-- * Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- --
-- * Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in the --
-- documentation and/or other materials provided with the distribution. --
-- --
-- * Neither the name of the Vadim Godunko, IE nor the names of its --
-- contributors may be used to endorse or promote products derived from --
-- this software without specific prior written permission. --
-- --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR --
-- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
-- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED --
-- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR --
-- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF --
-- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING --
-- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS --
-- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
-- --
------------------------------------------------------------------------------
-- $Revision$ $Date$
------------------------------------------------------------------------------
with League.Strings;
package ODF.Internals.Reader is
procedure Read (Path : League.Strings.Universal_String);
end ODF.Internals.Reader;
|
onox/orka | Ada | 721 | ads | -- SPDX-License-Identifier: Apache-2.0
--
-- Copyright (c) 2020 onox <[email protected]>
--
-- Licensed under the Apache License, Version 2.0 (the "License");
-- you may not use this file except in compliance with the License.
-- You may obtain a copy of the License at
--
-- http://www.apache.org/licenses/LICENSE-2.0
--
-- Unless required by applicable law or agreed to in writing, software
-- distributed under the License is distributed on an "AS IS" BASIS,
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-- See the License for the specific language governing permissions and
-- limitations under the License.
package Orka.SIMD.FMA is
pragma Pure;
end Orka.SIMD.FMA;
|
AdaCore/training_material | Ada | 1,238 | ads | pragma Ada_2005;
pragma Style_Checks (Off);
with Interfaces.C; use Interfaces.C;
package clflushoptintrin_h is
-- Copyright (C) 2013-2017 Free Software Foundation, Inc.
-- This file is part of GCC.
-- GCC 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, or (at your option)
-- any later version.
-- GCC 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.
-- 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/>.
-- skipped func _mm_clflushopt
end clflushoptintrin_h;
|
Heziode/lsystem-editor | Ada | 1,509 | ads | -------------------------------------------------------------------------------
-- LSE -- L-System Editor
-- Author: Heziode
--
-- License:
-- MIT License
--
-- Copyright (c) 2018 Quentin Dauprat (Heziode) <[email protected]>
--
-- Permission is hereby granted, free of charge, to any person obtaining a
-- copy of this software and associated documentation files (the "Software"),
-- to deal in the Software without restriction, including without limitation
-- the rights to use, copy, modify, merge, publish, distribute, sublicense,
-- and/or sell copies of the Software, and to permit persons to whom the
-- Software is furnished to do so, subject to the following conditions:
--
-- The above copyright notice and this permission notice shall be included in
-- all copies or substantial portions of the Software.
--
-- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
-- FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
-- DEALINGS IN THE SOFTWARE.
-------------------------------------------------------------------------------
-- @description
-- This package encompass all project.
--
package LSE is
pragma Pure;
end LSE;
|
AdaCore/libadalang | Ada | 2,535 | adb | with Ada.Characters.Conversions; use Ada.Characters.Conversions;
with Ada.Text_IO; use Ada.Text_IO;
with Libadalang.Analysis; use Libadalang.Analysis;
with Libadalang.Common; use Libadalang.Common;
with Libadalang.Iterators; use Libadalang.Iterators;
procedure Main is
Ctx : constant Analysis_Context := Create_Context;
Unit : constant Analysis_Unit := Get_From_File (Ctx, "foo.adb");
procedure Put_Node (N : Ada_Node);
-- Put the image of N on the standard output
procedure Run_Find
(Filename, Label : String;
Predicate : Ada_Node_Predicate);
-- Load the Filename unit and then show all nodes that Predicate matches in
-- this unit.
--------------
-- Put_Node --
--------------
procedure Put_Node (N : Ada_Node) is
begin
Put_Line (" " & N.Image);
end Put_Node;
--------------
-- Run_Find --
--------------
procedure Run_Find
(Filename, Label : String;
Predicate : Ada_Node_Predicate) is
begin
Put_Line ("[" & Filename & "] " & Label & ":");
for Node of Find (Ctx.Get_From_File (Filename).Root, Predicate).Consume
loop
Put_Node (Node);
end loop;
New_Line;
end Run_Find;
begin
declare
It : Ada_Node_Iterators.Iterator'Class := Traverse (Unit.Root);
begin
Put_Line ("[foo.adb] All nodes from root:");
Ada_Node_Iterators.Iterate (It, Put_Node'Access);
New_Line;
end;
Put_Line
("[foo.adb] All nodes from null:");
for Node of Traverse (No_Ada_Node).Consume loop
Put_Node (Node);
end loop;
New_Line;
Run_Find ("foo.adb", "All identifiers", Kind_Is (Ada_Identifier));
Run_Find ("pkg-foo.ads", "All declarations of Foo",
Decl_Defines ("Foo"));
Run_Find ("pkg-foo.ads", "All declarations of ""+""",
Decl_Defines ("""+"""));
Run_Find ("pkg-foo.ads",
"All declarations of Foo that are types or components",
Decl_Defines ("Foo") and (Kind_In (Ada_Concrete_Type_Decl,
Ada_Formal_Type_Decl)
or Kind_Is (Ada_Component_Decl)));
declare
Foo_Type : constant Type_Decl := Find_First
(Ctx.Get_From_File ("pkg.ads").Root,
Kind_In (Ada_Concrete_Type_Decl, Ada_Formal_Type_Decl)).As_Type_Decl;
begin
Run_Find ("pkg.ads", "All references to the Foo type",
Xref_Is (Foo_Type.F_Name));
end;
Put_Line ("Done.");
end Main;
|
charlie5/lace | Ada | 3,117 | adb | package body gel.Dolly.following
is
overriding
procedure define (Self : in out Item)
is
begin
null;
end define;
overriding
procedure destroy (Self : in out Item)
is
begin
null;
end destroy;
--------------
--- Attributes
--
procedure follow (Self : in out Item; the_Sprite : in gel.Sprite.view)
is
begin
Self.Sprite := the_Sprite;
end follow;
overriding
procedure allow_linear_Motion (Self : in out Item; Allow : in Boolean := True)
is
begin
Self.allow_linear_Motion := Allow;
end allow_linear_Motion;
overriding
procedure allow_orbital_Motion (Self : in out Item; Allow : in Boolean := True)
is
begin
Self.allow_orbital_Motion := Allow;
end allow_orbital_Motion;
function Offset (Self : in Item) return math.Vector_3
is
begin
return Self.sprite_Offset;
end Offset;
procedure Offset_is (Self : in out Item; Now : in math.Vector_3)
is
begin
Self.sprite_Offset := Now;
end Offset_is;
--------------
--- Operations
--
overriding
procedure freshen (Self : in out Item)
is
use Math,
linear_Algebra_3D;
Speed : math.Real renames Self.Speed;
the_sprite_Site : constant math.Vector_3 := Self.Sprite.Site;
the_Camera : constant gel.Camera.view := Self.Cameras.first_Element;
begin
-- Linear motion.
--
if Self.allow_linear_Motion
then
if Self.Motion (Forward) then Self.sprite_Offset := Self.sprite_Offset - the_Camera.Spin * [0.0, 0.0, 0.1 * Speed]; end if;
if Self.Motion (Backward) then Self.sprite_Offset := Self.sprite_Offset + the_Camera.Spin * [0.0, 0.0, 0.1 * Speed]; end if;
if Self.Motion (Up) then Self.sprite_Offset := Self.sprite_Offset + the_Camera.Spin * [0.0, 0.1 * Speed, 0.0]; end if;
if Self.Motion (Down) then Self.sprite_Offset := Self.sprite_Offset - the_Camera.Spin * [0.0, 0.1 * Speed, 0.0]; end if;
end if;
-- Orbit.
--
if Self.allow_orbital_Motion
then
if Self.Motion (Left)
then
Self.camera_y_Spin := Self.camera_y_Spin - 0.01 * Speed;
Self.sprite_Offset := y_Rotation_from (-0.01 * Speed) * Self.sprite_Offset;
the_Camera.Spin_is (xyz_Rotation (Self.camera_x_Spin,
Self.camera_y_Spin,
Self.camera_z_Spin));
end if;
if Self.Motion (Right)
then
Self.camera_y_Spin := Self.camera_y_Spin + 0.01 * Speed;
Self.sprite_Offset := y_Rotation_from (0.01 * Speed) * Self.sprite_Offset;
the_Camera.Spin_is (xyz_Rotation (Self.camera_x_Spin,
Self.camera_y_Spin,
Self.camera_z_Spin));
end if;
end if;
the_Camera.Site_is (the_sprite_Site + Self.sprite_Offset);
end freshen;
end gel.Dolly.following;
|
tum-ei-rcs/StratoX | Ada | 196 | adb | package body unav with SPARK_Mode is
function Get_Distance return Length_Type is
darc : Unit_Type := 0.5;
begin
return 2.0 * EARTH_RADIUS * darc;
end Get_Distance;
end unav;
|
OneWingedShark/Byron | Ada | 3,858 | adb | Pragma Ada_2012;
Pragma Assertion_Policy( Check );
with
Byron.Generics.Vector,
Byron.Generics.Iterator,
Lexington.Aux.Constants.Delimiters,
Ada.Containers.Vectors,
Ada.Containers.Formal_Vectors;
use
Lexington.Aux.Constants.Delimiters;
Procedure Lexington.Aux.P5(Data : in out Token_Vector_Pkg.Vector) is
Package VP renames Token_Vector_Pkg;
Package TP renames Token_Pkg;
Package Index_Vector_pkg is new Ada.Containers.Vectors(
Index_Type => Positive,
Element_Type => Positive
);
Use Type Ada.Containers.Count_Type;
Mem : Index_Vector_pkg.Vector;--( 2*(1024**2) );
procedure Make_Tokens(Position : VP.Cursor) is
Element : Token renames VP.Element( Position );
Index : Positive renames VP.To_Index(Position);
ID : Token_ID renames TP.ID( Element );
Value : Wide_Wide_String renames Lexington.Aux.Token_Pkg.Lexeme(Element);
Next : VP.Cursor := VP.Next( Position );
Next_ID : Constant Token_ID := (if VP.Has_Element(Next)
then TP.ID( VP.Element(Next) )
else Nil
);
Primary : Wide_Wide_Character renames To_Chr(ID);
Secondary: Wide_Wide_Character renames To_Chr(Next_ID);
Procedure Replace_With(ID : Token_ID) is
Deletion_Index : Constant Positive := Positive'Succ(Index);
Lexeme : Constant Wide_Wide_String := (1 => Primary, 2 => Secondary);
begin
Data.Replace_Element(Position, Lexington.Aux.Token_Pkg.Make_Token(ID,Lexeme) );
Index_Vector_pkg.Append(Container => Mem, New_Item => Deletion_Index );
end Replace_With;
begin
case ID is
When ch_Less_Than =>
case Next_ID is
when ch_Less_Than => Replace_With(ss_Open_Label); -- <<
when ch_Equal => Replace_With(ss_Less_Equal); -- <=
When ch_Greater_Than => Replace_With(ss_Box); -- <>
when others => Null;
end case;
When ch_Greater_Than =>
case Next_ID is
when ch_Greater_Than => Replace_With(ss_Close_Label); -- >>
when ch_Equal => Replace_With(ss_Greater_Equal); -- >=
when others => Null;
end case;
when ch_Slash =>
case Next_ID is
when ch_Equal => Replace_With(ss_Not_Equal); -- /=
when others => Null;
end case;
when ch_Colon =>
case Next_ID is
when ch_Equal => Replace_With(ss_Assign); -- :=
when others => Null;
end case;
when ch_Astrisk =>
case Next_ID is
when ch_Astrisk => Replace_With(ss_Exponent); -- **
when others => Null;
end case;
when ch_Equal =>
case Next_ID is
when ch_Greater_Than => Replace_With(ss_Arrow); -- =>
when others => Null;
end case;
When ch_Period =>
case Next_ID is
when ch_Period => Replace_With(ss_Dillipsis); -- ..
when others => Null;
end case;
When others => Null;
end case;
end Make_Tokens;
use all type Index_Vector_pkg.Vector;
Package Mem_Vec is new Byron.Generics.Vector(
Vector => Index_Vector_pkg.Vector,
Index_Type => Positive,
Element_Type => Positive
);
Procedure Delete_Data( Index : Positive ) renames Data.Delete;
Procedure Delete_Data is new Byron.Generics.Iterator(Mem_Vec, Delete_Data);
Begin
Data.Iterate( Make_Tokens'Access );
-- Delete excess elements.
Delete_Data( Mem );
End Lexington.Aux.P5;
|
reznikmm/matreshka | Ada | 3,657 | ads | ------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- Ada Modeling Framework --
-- --
-- Runtime Library Component --
-- --
------------------------------------------------------------------------------
-- --
-- Copyright © 2011-2012, Vadim Godunko <[email protected]> --
-- All rights reserved. --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions --
-- are met: --
-- --
-- * Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- --
-- * Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in the --
-- documentation and/or other materials provided with the distribution. --
-- --
-- * Neither the name of the Vadim Godunko, IE nor the names of its --
-- contributors may be used to endorse or promote products derived from --
-- this software without specific prior written permission. --
-- --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR --
-- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
-- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED --
-- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR --
-- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF --
-- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING --
-- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS --
-- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
-- --
------------------------------------------------------------------------------
-- $Revision$ $Date$
------------------------------------------------------------------------------
-- This file is generated, don't edit it.
------------------------------------------------------------------------------
with AMF.Elements.Generic_Hash;
function AMF.UML.Read_Link_Object_End_Actions.Hash is
new AMF.Elements.Generic_Hash (UML_Read_Link_Object_End_Action, UML_Read_Link_Object_End_Action_Access);
|
RREE/ada-util | Ada | 6,251 | ads | -----------------------------------------------------------------------
-- util-concurrent-arrays -- Concurrent Arrays
-- Copyright (C) 2012, 2017 Stephane Carrez
-- Written by Stephane Carrez ([email protected])
--
-- Licensed under the Apache License, Version 2.0 (the "License");
-- you may not use this file except in compliance with the License.
-- You may obtain a copy of the License at
--
-- http://www.apache.org/licenses/LICENSE-2.0
--
-- Unless required by applicable law or agreed to in writing, software
-- distributed under the License is distributed on an "AS IS" BASIS,
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-- See the License for the specific language governing permissions and
-- limitations under the License.
-----------------------------------------------------------------------
with Ada.Finalization;
with Util.Concurrent.Counters;
-- == Introduction ==
-- The <b>Util.Concurrent.Arrays</b> generic package defines an array which provides a
-- concurrent read only access and a protected exclusive write access. This implementation
-- is intended to be used in applications that have to frequently iterate over the array
-- content. Adding or removing elements in the array is assumed to be a not so frequent
-- operation. Based on these assumptions, updating the array is implemented by
-- using the <tt>copy on write</tt> design pattern. Read access is provided through a
-- reference object that can be shared by multiple readers.
--
-- == Declaration ==
-- The package must be instantiated using the element type representing the array element.
--
-- package My_Array is new Util.Concurrent.Arrays (Element_Type => Integer);
--
-- == Adding Elements ==
-- The vector instance is declared and elements are added as follows:
--
-- C : My_Array.Vector;
--
-- C.Append (E1);
--
-- == Iterating over the array ==
-- To read and iterate over the vector, a task will get a reference to the vector array
-- and it will iterate over it. The reference will be held until the reference object is
-- finalized. While doing so, if another task updates the vector, a new vector array will
-- be associated with the vector instance (but this will not change the reader's references).
--
-- R : My_Array.Ref := C.Get;
--
-- R.Iterate (Process'Access);
-- ...
-- R.Iterate (Process'Access);
--
-- In the above example, the two `Iterate` operations will iterate over the same list of
-- elements, even if another task appends an element in the middle.
--
-- Notes:
-- * This package is close to the Java class `java.util.concurrent.CopyOnWriteArrayList`.
--
-- * The package implements voluntarily a very small subset of `Ada.Containers.Vectors`.
--
-- * The implementation does not use the Ada container for performance and size reasons.
--
-- * The `Iterate` and `Reverse_Iterate` operation give a direct access to the element.
generic
type Element_Type is private;
with function "=" (Left, Right : in Element_Type) return Boolean is <>;
package Util.Concurrent.Arrays is
-- The reference to the read-only vector elements.
type Ref is tagged private;
-- Returns True if the container is empty.
function Is_Empty (Container : in Ref) return Boolean;
-- Iterate over the vector elements and execute the <b>Process</b> procedure
-- with the element as parameter.
procedure Iterate (Container : in Ref;
Process : not null access procedure (Item : in Element_Type));
-- Iterate over the vector elements in reverse order and execute the <b>Process</b> procedure
-- with the element as parameter.
procedure Reverse_Iterate (Container : in Ref;
Process : not null access procedure (Item : in Element_Type));
-- Vector of elements.
type Vector is new Ada.Finalization.Limited_Controlled with private;
-- Get a read-only reference to the vector elements. The referenced vector will never
-- be modified.
function Get (Container : in Vector'Class) return Ref;
-- Append the element to the vector. The modification will not be visible to readers
-- until they call the <b>Get</b> function.
procedure Append (Container : in out Vector;
Item : in Element_Type);
-- Remove the element represented by <b>Item</b> from the vector. The modification will
-- not be visible to readers until they call the <b>Get</b> function.
procedure Remove (Container : in out Vector;
Item : in Element_Type);
-- Release the vector elements.
overriding
procedure Finalize (Object : in out Vector);
private
-- To store the vector elements, we use an array which is allocated dynamically.
-- The generated code is smaller compared to the use of Ada vectors container.
type Element_Array is array (Positive range <>) of Element_Type;
type Element_Array_Access is access all Element_Array;
Null_Element_Array : constant Element_Array_Access := null;
type Vector_Record (Len : Positive) is record
Ref_Counter : Util.Concurrent.Counters.Counter;
List : Element_Array (1 .. Len);
end record;
type Vector_Record_Access is access all Vector_Record;
type Ref is new Ada.Finalization.Controlled with record
Target : Vector_Record_Access := null;
end record;
-- Release the reference. Invoke <b>Finalize</b> and free the storage if it was
-- the last reference.
overriding
procedure Finalize (Obj : in out Ref);
-- Update the reference counter after an assignment.
overriding
procedure Adjust (Obj : in out Ref);
-- Vector of objects
protected type Protected_Vector is
-- Get a readonly reference to the vector.
function Get return Ref;
-- Append the element to the vector.
procedure Append (Item : in Element_Type);
-- Remove the element from the vector.
procedure Remove (Item : in Element_Type);
private
Elements : Ref;
end Protected_Vector;
type Vector is new Ada.Finalization.Limited_Controlled with record
List : Protected_Vector;
end record;
end Util.Concurrent.Arrays;
|
reznikmm/matreshka | Ada | 3,759 | ads | ------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- Open Document Toolkit --
-- --
-- Runtime Library Component --
-- --
------------------------------------------------------------------------------
-- --
-- Copyright © 2014, Vadim Godunko <[email protected]> --
-- All rights reserved. --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions --
-- are met: --
-- --
-- * Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- --
-- * Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in the --
-- documentation and/or other materials provided with the distribution. --
-- --
-- * Neither the name of the Vadim Godunko, IE nor the names of its --
-- contributors may be used to endorse or promote products derived from --
-- this software without specific prior written permission. --
-- --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR --
-- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
-- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED --
-- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR --
-- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF --
-- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING --
-- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS --
-- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
-- --
------------------------------------------------------------------------------
-- $Revision$ $Date$
------------------------------------------------------------------------------
with XML.DOM.Attributes;
package ODF.DOM.Draw_Path_Stretchpoint_Y_Attributes is
pragma Preelaborate;
type ODF_Draw_Path_Stretchpoint_Y_Attribute is limited interface
and XML.DOM.Attributes.DOM_Attribute;
type ODF_Draw_Path_Stretchpoint_Y_Attribute_Access is
access all ODF_Draw_Path_Stretchpoint_Y_Attribute'Class
with Storage_Size => 0;
end ODF.DOM.Draw_Path_Stretchpoint_Y_Attributes;
|
byblakeorriver/coinapi-sdk | Ada | 3,400 | ads | -- EMS _ REST API
-- This section will provide necessary information about the `CoinAPI EMS REST API` protocol. <br/> This API is also available in the Postman application: <a href=\"https://postman.coinapi.io/\" target=\"_blank\">https://postman.coinapi.io/</a> <br/><br/> Implemented Standards: * [HTTP1.0](https://datatracker.ietf.org/doc/html/rfc1945) * [HTTP1.1](https://datatracker.ietf.org/doc/html/rfc2616) * [HTTP2.0](https://datatracker.ietf.org/doc/html/rfc7540) ### Endpoints <table> <thead> <tr> <th>Deployment method</th> <th>Environment</th> <th>Url</th> </tr> </thead> <tbody> <tr> <td>Managed Cloud</td> <td>Production</td> <td>Use <a href=\"#ems_docs_sh\">Managed Cloud REST API /v1/locations</a> to get specific endpoints to each server site where your deployments span</td> </tr> <tr> <td>Managed Cloud</td> <td>Sandbox</td> <td><code>https://ems_gateway_aws_eu_central_1_dev.coinapi.io/</code></td> </tr> <tr> <td>Self Hosted</td> <td>Production</td> <td>IP Address of the <code>ems_gateway</code> container/excecutable in the closest server site to the caller location</td> </tr> <tr> <td>Self Hosted</td> <td>Sandbox</td> <td>IP Address of the <code>ems_gateway</code> container/excecutable in the closest server site to the caller location</td> </tr> </tbody> </table> ### Authentication If the software is deployed as `Self_Hosted` then API do not require authentication as inside your infrastructure, your company is responsible for the security and access controls. <br/><br/> If the software is deployed in our `Managed Cloud`, there are 2 methods for authenticating with us, you only need to use one: 1. Custom authorization header named `X_CoinAPI_Key` with the API Key 2. Query string parameter named `apikey` with the API Key 3. <a href=\"#certificate\">TLS Client Certificate</a> from the `Managed Cloud REST API` (/v1/certificate/pem endpoint) while establishing a TLS session with us. #### Custom authorization header You can authorize by providing additional custom header named `X_CoinAPI_Key` and API key as its value. Assuming that your API key is `73034021_THIS_IS_SAMPLE_KEY`, then the authorization header you should send to us will look like: <br/><br/> `X_CoinAPI_Key: 73034021_THIS_IS_SAMPLE_KEY` <aside class=\"success\">This method is recommended by us and you should use it in production environments.</aside> #### Query string authorization parameter You can authorize by providing an additional parameter named `apikey` with a value equal to your API key in the query string of your HTTP request. Assuming that your API key is `73034021_THIS_IS_SAMPLE_KEY` and that you want to request all balances, then your query string should look like this: <br/><br/> `GET /v1/balances?apikey=73034021_THIS_IS_SAMPLE_KEY` <aside class=\"notice\">Query string method may be more practical for development activities.</aside>
-- ------------ EDIT NOTE ------------
-- This file was generated with openapi-generator. You can modify it to implement
-- the server. After you modify this file, you should add the following line
-- to the .openapi-generator-ignore file:
--
-- src/.ads
--
-- Then, you can drop this edit note comment.
-- ------------ EDIT NOTE ------------
package is
end ;
|
reznikmm/matreshka | Ada | 4,735 | 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_Draw.Wrap_Influence_On_Position_Attributes is
------------
-- Create --
------------
overriding function Create
(Parameters : not null access Matreshka.DOM_Attributes.Attribute_L2_Parameters)
return Draw_Wrap_Influence_On_Position_Attribute_Node is
begin
return Self : Draw_Wrap_Influence_On_Position_Attribute_Node do
Matreshka.ODF_Draw.Constructors.Initialize
(Self'Unchecked_Access,
Parameters.Document,
Matreshka.ODF_String_Constants.Draw_Prefix);
end return;
end Create;
--------------------
-- Get_Local_Name --
--------------------
overriding function Get_Local_Name
(Self : not null access constant Draw_Wrap_Influence_On_Position_Attribute_Node)
return League.Strings.Universal_String
is
pragma Unreferenced (Self);
begin
return Matreshka.ODF_String_Constants.Wrap_Influence_On_Position_Attribute;
end Get_Local_Name;
begin
Matreshka.DOM_Documents.Register_Attribute
(Matreshka.ODF_String_Constants.Draw_URI,
Matreshka.ODF_String_Constants.Wrap_Influence_On_Position_Attribute,
Draw_Wrap_Influence_On_Position_Attribute_Node'Tag);
end Matreshka.ODF_Draw.Wrap_Influence_On_Position_Attributes;
|
silky/synth | Ada | 10,174 | ads | -- This file is covered by the Internet Software Consortium (ISC) License
-- Reference: ../License.txt
with Ada.Text_IO;
with JohnnyText;
with Definitions; use Definitions;
private with Ada.Characters.Latin_1;
private with Ada.Directories;
private with Parameters;
private with Unix;
package Replicant is
package JT renames JohnnyText;
package TIO renames Ada.Text_IO;
scenario_unexpected : exception;
type slave_options is record
need_procfs : Boolean := False;
need_linprocfs : Boolean := False;
skip_cwrappers : Boolean := False;
end record;
type package_abi is record
calculated_abi : JT.Text;
calculated_alt_abi : JT.Text;
calc_abi_noarch : JT.Text;
calc_alt_abi_noarch : JT.Text;
end record;
-- For every single port to be built, the build need to first be created
-- and then destroyed when the build is complete.
procedure launch_slave (id : builders; opts : slave_options);
procedure destroy_slave (id : builders; opts : slave_options);
-- This needs to be run as soon as the configuration profile is loaded,
-- env before the "initialize" function
procedure set_platform;
-- This procedure needs to be run once.
-- It basically sets the operating system "flavor" which affects the
-- mount command spawning. It also creates the password database
procedure initialize (testmode : Boolean; num_cores : cpu_range);
-- This removes the password database
procedure finalize;
-- Returns True if any mounts are detected (used by pilot)
function synth_mounts_exist return Boolean;
-- Returns True if any _work/_localbase dirs are detected (used by pilot)
function disk_workareas_exist return Boolean;
-- Returns True if the attempt to clear mounts is successful.
function clear_existing_mounts return Boolean;
-- Returns True if the attempt to remove the disk work areas is successful
function clear_existing_workareas return Boolean;
-- The actual command to build a local repository (Returns True on success)
function build_repository (id : builders; sign_command : String := "")
return Boolean;
-- Returns all the UNAME_x environment variables
-- They will be passed to the buildcycle package
function jail_environment return JT.Text;
-- On FreeBSD, if "/boot" exists but "/boot/modules" does not, return True
-- This is a pre-run validity check
function boot_modules_directory_missing return Boolean;
root_localbase : constant String := "/usr/local";
private
package PM renames Parameters;
package AD renames Ada.Directories;
package LAT renames Ada.Characters.Latin_1;
type mount_mode is (readonly, readwrite);
type flavors is (unknown, freebsd, dragonfly, netbsd, linux, solaris);
type folder_operation is (lock, unlock);
type folder is (bin, sbin, lib, libexec,
usr_bin,
usr_include,
usr_lib,
usr_libdata,
usr_libexec,
usr_sbin,
usr_share,
usr_lib32, xports, options, packages, distfiles,
dev, etc, etc_default, etc_mtree, etc_rcd, home, linux,
proc, root, tmp, var, wrkdirs, usr_local, usr_src, ccache,
boot, usr_x11r7, usr_games);
subtype subfolder is folder range bin .. usr_share;
subtype filearch is String (1 .. 11);
-- home and root need to be set readonly
reference_base : constant String := "Base";
root_bin : constant String := "/bin";
root_sbin : constant String := "/sbin";
root_X11R7 : constant String := "/usr/X11R7";
root_usr_bin : constant String := "/usr/bin";
root_usr_games : constant String := "/usr/games";
root_usr_include : constant String := "/usr/include";
root_usr_lib : constant String := "/usr/lib";
root_usr_lib32 : constant String := "/usr/lib32";
root_usr_libdata : constant String := "/usr/libdata";
root_usr_libexec : constant String := "/usr/libexec";
root_usr_sbin : constant String := "/usr/sbin";
root_usr_share : constant String := "/usr/share";
root_usr_src : constant String := "/usr/src";
root_dev : constant String := "/dev";
root_etc : constant String := "/etc";
root_etc_default : constant String := "/etc/defaults";
root_etc_mtree : constant String := "/etc/mtree";
root_etc_rcd : constant String := "/etc/rc.d";
root_lib : constant String := "/lib";
root_tmp : constant String := "/tmp";
root_var : constant String := "/var";
root_home : constant String := "/home";
root_boot : constant String := "/boot";
root_kmodules : constant String := "/boot/modules";
root_lmodules : constant String := "/boot/modules.local";
root_root : constant String := "/root";
root_proc : constant String := "/proc";
root_linux : constant String := "/compat/linux";
root_linproc : constant String := "/compat/linux/proc";
root_xports : constant String := "/xports";
root_options : constant String := "/options";
root_libexec : constant String := "/libexec";
root_wrkdirs : constant String := "/construction";
root_packages : constant String := "/packages";
root_distfiles : constant String := "/distfiles";
root_ccache : constant String := "/ccache";
chroot : constant String := "/usr/sbin/chroot ";
platform_type : flavors := unknown;
smp_cores : cpu_range := cpu_range'First;
support_locks : Boolean;
developer_mode : Boolean;
abn_log_ready : Boolean;
builder_env : JT.Text;
abnormal_log : TIO.File_Type;
abnormal_cmd_logname : constant String := "05_abnormal_command_output.log";
-- Throws exception if mount attempt was unsuccessful
procedure mount_nullfs (target, mount_point : String;
mode : mount_mode := readonly);
-- Throws exception if mount attempt was unsuccessful
procedure mount_tmpfs (mount_point : String; max_size_M : Natural := 0);
-- Throws exception if unmount attempt was unsuccessful
procedure unmount (device_or_node : String);
-- Throws exception if directory was not successfully created
procedure forge_directory (target : String);
-- Return the full path of the mount point
function location (mount_base : String; point : folder) return String;
function mount_target (point : folder) return String;
-- Query configuration to determine the master mount
function get_master_mount return String;
function get_slave_mount (id : builders) return String;
-- returns "SLXX" where XX is a zero-padded integer (01 .. 32)
function slave_name (id : builders) return String;
-- locks and unlocks folders, even from root
procedure folder_access (path : String; operation : folder_operation);
-- self explanatory
procedure create_symlink (destination, symbolic_link : String);
-- generic command, throws exception if exit code is not 0
procedure execute (command : String);
procedure silent_exec (command : String);
function internal_system_command (command : String) return JT.Text;
-- create slave's /var directory tree. Path should be an empty directory.
procedure populate_var_folder (path : String);
-- create /etc/make.conf in slave
procedure create_make_conf (path_to_etc : String;
skip_cwrappers : Boolean);
-- create /etc/passwd (and databases) to define system users
procedure create_passwd (path_to_etc : String);
procedure create_base_passwd (path_to_mm : String);
-- create /etc/group to define root user
procedure create_group (path_to_etc : String);
procedure create_base_group (path_to_mm : String);
-- copy host's /etc/resolv.conf to slave
procedure copy_resolv_conf (path_to_etc : String);
-- copy host's /etc/mtree files to slave
procedure copy_mtree_files (path_to_mtree : String);
-- copy host's conf defaults
procedure copy_rc_default (path_to_etc : String);
-- create minimal /etc/services
procedure create_etc_services (path_to_etc : String);
-- create a dummy fstab for linux packages (looks for linprocfs)
procedure create_etc_fstab (path_to_etc : String);
-- create /etc/shells, required by install scripts of some packages
procedure create_etc_shells (path_to_etc : String);
-- mount the devices
procedure mount_devices (path_to_dev : String);
procedure unmount_devices (path_to_dev : String);
-- execute ldconfig as last action of slave creation
procedure execute_ldconfig (id : builders);
-- Used for per-profile make.conf fragments (if they exist)
procedure concatenate_makeconf (makeconf_handle : TIO.File_Type;
target_name : String);
-- Wrapper for rm -rf <directory>
procedure annihilate_directory_tree (tree : String);
-- This is only done for FreeBSD. For DragonFly, it's a null-op
procedure mount_linprocfs (mount_point : String);
-- It turns out at least one major port uses procfs (gnustep)
procedure mount_procfs (path_to_proc : String);
procedure unmount_procfs (path_to_proc : String);
-- Used to generic mtree exclusion files
procedure write_common_mtree_exclude_base (mtreefile : TIO.File_Type);
procedure write_preinstall_section (mtreefile : TIO.File_Type);
procedure create_mtree_exc_preconfig (path_to_mm : String);
procedure create_mtree_exc_preinst (path_to_mm : String);
-- capture unexpected output while setting up builders (e.g. mount)
procedure start_abnormal_logging;
procedure stop_abnormal_logging;
-- Generic directory copy utility (ordinary files only)
function copy_directory_contents (src_directory : String;
tgt_directory : String;
pattern : String) return Boolean;
end Replicant;
|
nerilex/ada-util | Ada | 26,928 | adb | -----------------------------------------------------------------------
-- util-serialize-io-json -- JSON Serialization Driver
-- Copyright (C) 2010, 2011, 2012, 2016 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 Interfaces;
with Ada.Characters.Latin_1;
with Ada.Characters.Wide_Wide_Latin_1;
with Ada.IO_Exceptions;
with Util.Strings;
with Util.Streams;
with Util.Streams.Buffered;
with Util.Dates.ISO8601;
package body Util.Serialize.IO.JSON is
use Ada.Strings.Unbounded;
-- -----------------------
-- Set the target output stream.
-- -----------------------
procedure Initialize (Stream : in out Output_Stream;
Output : in Util.Streams.Texts.Print_Stream_Access) is
begin
Stream.Stream := Output;
end Initialize;
-- -----------------------
-- Flush the buffer (if any) to the sink.
-- -----------------------
overriding
procedure Flush (Stream : in out Output_Stream) is
begin
Stream.Stream.Flush;
end Flush;
-- -----------------------
-- Close the sink.
-- -----------------------
overriding
procedure Close (Stream : in out Output_Stream) is
begin
Stream.Stream.Close;
end Close;
-- -----------------------
-- Write the buffer array to the output stream.
-- -----------------------
overriding
procedure Write (Stream : in out Output_Stream;
Buffer : in Ada.Streams.Stream_Element_Array) is
begin
Stream.Stream.Write (Buffer);
end Write;
-- -----------------------
-- Write a raw character on the stream.
-- -----------------------
procedure Write (Stream : in out Output_Stream;
Char : in Character) is
begin
Stream.Stream.Write (Char);
end Write;
-- -----------------------
-- Write a wide character on the stream doing some conversion if necessary.
-- The default implementation translates the wide character to a UTF-8 sequence.
-- -----------------------
procedure Write_Wide (Stream : in out Output_Stream;
Item : in Wide_Wide_Character) is
begin
Stream.Stream.Write_Wide (Item);
end Write_Wide;
-- -----------------------
-- Write a raw string on the stream.
-- -----------------------
procedure Write (Stream : in out Output_Stream;
Item : in String) is
begin
Stream.Stream.Write (Item);
end Write;
-- -----------------------
-- Start a JSON document. This operation writes the initial JSON marker ('{').
-- -----------------------
procedure Start_Document (Stream : in out Output_Stream) is
begin
Stream.Write ('{');
end Start_Document;
-- -----------------------
-- Finish a JSON document by writing the final JSON marker ('}').
-- -----------------------
procedure End_Document (Stream : in out Output_Stream) is
begin
Stream.Write ('}');
end End_Document;
-- -----------------------
-- Write the string as a quoted JSON string
-- -----------------------
procedure Write_String (Stream : in out Output_Stream;
Value : in String) is
begin
Stream.Write ('"');
for I in Value'Range loop
declare
C : constant Character := Value (I);
begin
if C = '"' then
Stream.Write ("\""");
elsif C = '\' then
Stream.Write ("\\");
elsif Character'Pos (C) >= 16#20# then
Stream.Write (C);
else
case C is
when Ada.Characters.Latin_1.BS =>
Stream.Write ("\b");
when Ada.Characters.Latin_1.VT =>
Stream.Write ("\f");
when Ada.Characters.Latin_1.LF =>
Stream.Write ("\n");
when Ada.Characters.Latin_1.CR =>
Stream.Write ("\r");
when Ada.Characters.Latin_1.HT =>
Stream.Write ("\t");
when others =>
Util.Streams.Texts.TR.To_Hex (Stream.Stream.all, C);
end case;
end if;
end;
end loop;
Stream.Write ('"');
end Write_String;
-- -----------------------
-- Write the value as a JSON string. Special characters are escaped using the JSON
-- escape rules.
-- -----------------------
procedure Write_Wide_String (Stream : in out Output_Stream;
Value : in Wide_Wide_String) is
begin
Stream.Write ('"');
for I in Value'Range loop
declare
C : constant Wide_Wide_Character := Value (I);
begin
if C = '"' then
Stream.Write ("\""");
elsif C = '\' then
Stream.Write ("\\");
elsif Wide_Wide_Character'Pos (C) >= 16#20# then
Util.Streams.Texts.Write_Char (Stream.Stream.all, C);
else
case C is
when Ada.Characters.Wide_Wide_Latin_1.BS =>
Stream.Write ("\b");
when Ada.Characters.Wide_Wide_Latin_1.VT =>
Stream.Write ("\f");
when Ada.Characters.Wide_Wide_Latin_1.LF =>
Stream.Write ("\n");
when Ada.Characters.Wide_Wide_Latin_1.CR =>
Stream.Write ("\r");
when Ada.Characters.Wide_Wide_Latin_1.HT =>
Stream.Write ("\t");
when others =>
Util.Streams.Texts.WTR.To_Hex (Stream.Stream.all, C);
end case;
end if;
end;
end loop;
Stream.Write ('"');
end Write_Wide_String;
procedure Write_Field_Name (Stream : in out Output_Stream;
Name : in String) is
Current : access Node_Info := Node_Info_Stack.Current (Stream.Stack);
begin
if Current /= null then
if Current.Has_Fields then
Stream.Write (',');
else
Current.Has_Fields := True;
end if;
end if;
if Name'Length > 0 and then (Current = null or else not Current.Is_Array) then
Stream.Write_String (Name);
Stream.Write (':');
end if;
end Write_Field_Name;
-- -----------------------
-- Start writing an object identified by the given name
-- -----------------------
procedure Start_Entity (Stream : in out Output_Stream;
Name : in String) is
Current : access Node_Info := Node_Info_Stack.Current (Stream.Stack);
begin
Stream.Write_Field_Name (Name);
Node_Info_Stack.Push (Stream.Stack);
Current := Node_Info_Stack.Current (Stream.Stack);
Current.Has_Fields := False;
Current.Is_Array := False;
Stream.Write ('{');
end Start_Entity;
-- -----------------------
-- Finish writing an object identified by the given name
-- -----------------------
procedure End_Entity (Stream : in out Output_Stream;
Name : in String) is
pragma Unreferenced (Name);
begin
Node_Info_Stack.Pop (Stream.Stack);
Stream.Write ('}');
end End_Entity;
-- -----------------------
-- Write the attribute name/value pair.
-- -----------------------
overriding
procedure Write_Attribute (Stream : in out Output_Stream;
Name : in String;
Value : in String) is
begin
Stream.Write_Field_Name (Name);
Stream.Write_String (Value);
end Write_Attribute;
overriding
procedure Write_Wide_Attribute (Stream : in out Output_Stream;
Name : in String;
Value : in Wide_Wide_String) is
begin
Stream.Write_Field_Name (Name);
Stream.Write_Wide_String (Value);
end Write_Wide_Attribute;
overriding
procedure Write_Attribute (Stream : in out Output_Stream;
Name : in String;
Value : in Integer) is
begin
Stream.Write_Field_Name (Name);
Stream.Write (Integer'Image (Value));
end Write_Attribute;
overriding
procedure Write_Attribute (Stream : in out Output_Stream;
Name : in String;
Value : in Boolean) is
begin
Stream.Write_Field_Name (Name);
if Value then
Stream.Write ("true");
else
Stream.Write ("false");
end if;
end Write_Attribute;
-- -----------------------
-- Write an attribute member from the current object
-- -----------------------
procedure Write_Attribute (Stream : in out Output_Stream;
Name : in String;
Value : in Util.Beans.Objects.Object) is
use Util.Beans.Objects;
begin
Stream.Write_Field_Name (Name);
case Util.Beans.Objects.Get_Type (Value) is
when TYPE_NULL =>
Stream.Write ("null");
when TYPE_BOOLEAN =>
if Util.Beans.Objects.To_Boolean (Value) then
Stream.Write ("true");
else
Stream.Write ("false");
end if;
when TYPE_INTEGER =>
Stream.Stream.Write (Util.Beans.Objects.To_Long_Long_Integer (Value));
when others =>
Stream.Write_String (Util.Beans.Objects.To_String (Value));
end case;
end Write_Attribute;
-- -----------------------
-- Write an object value as an entity
-- -----------------------
procedure Write_Entity (Stream : in out Output_Stream;
Name : in String;
Value : in Util.Beans.Objects.Object) is
begin
Stream.Write_Attribute (Name, Value);
end Write_Entity;
-- -----------------------
-- Write a JSON name/value pair (see Write_Attribute).
-- -----------------------
overriding
procedure Write_Entity (Stream : in out Output_Stream;
Name : in String;
Value : in String) is
begin
Stream.Write_Attribute (Name, Value);
end Write_Entity;
overriding
procedure Write_Wide_Entity (Stream : in out Output_Stream;
Name : in String;
Value : in Wide_Wide_String) is
begin
Stream.Write_Wide_Attribute (Name, Value);
end Write_Wide_Entity;
-- -----------------------
-- Write a JSON name/value pair (see Write_Attribute).
-- -----------------------
overriding
procedure Write_Entity (Stream : in out Output_Stream;
Name : in String;
Value : in Integer) is
begin
Stream.Write_Attribute (Name, Value);
end Write_Entity;
overriding
procedure Write_Entity (Stream : in out Output_Stream;
Name : in String;
Value : in Ada.Calendar.Time) is
begin
Stream.Write_Entity (Name, Util.Dates.ISO8601.Image (Value, Util.Dates.ISO8601.SUBSECOND));
end Write_Entity;
overriding
procedure Write_Entity (Stream : in out Output_Stream;
Name : in String;
Value : in Boolean) is
begin
Stream.Write_Attribute (Name, Value);
end Write_Entity;
overriding
procedure Write_Long_Entity (Stream : in out Output_Stream;
Name : in String;
Value : in Long_Long_Integer) is
begin
Stream.Write_Attribute (Name, Integer (Value));
end Write_Long_Entity;
overriding
procedure Write_Enum_Entity (Stream : in out Output_Stream;
Name : in String;
Value : in String) is
begin
Stream.Write_Entity (Name, Value);
end Write_Enum_Entity;
-- -----------------------
-- Start an array that will contain the specified number of elements
-- Example: "list": [
-- -----------------------
overriding
procedure Start_Array (Stream : in out Output_Stream;
Name : in String) is
Current : access Node_Info := Node_Info_Stack.Current (Stream.Stack);
begin
if Current /= null then
if Current.Has_Fields then
Stream.Write (',');
else
Current.Has_Fields := True;
end if;
end if;
Node_Info_Stack.Push (Stream.Stack);
Current := Node_Info_Stack.Current (Stream.Stack);
Current.Has_Fields := False;
Current.Is_Array := True;
Stream.Write_String (Name);
Stream.Write (':');
Stream.Write ('[');
end Start_Array;
-- -----------------------
-- Finishes an array
-- -----------------------
overriding
procedure End_Array (Stream : in out Output_Stream;
Name : in String) is
begin
Node_Info_Stack.Pop (Stream.Stack);
Stream.Write (']');
end End_Array;
-- -----------------------
-- Get the current location (file and line) to report an error message.
-- -----------------------
function Get_Location (Handler : in Parser) return String is
begin
return Util.Strings.Image (Handler.Line_Number);
end Get_Location;
procedure Parse (Handler : in out Parser;
Stream : in out Util.Streams.Buffered.Buffered_Stream'Class) is
-- Put back a token in the buffer.
procedure Put_Back (P : in out Parser'Class;
Token : in Token_Type);
-- Parse the expression buffer to find the next token.
procedure Peek (P : in out Parser'Class;
Token : out Token_Type);
function Hexdigit (C : in Character) return Interfaces.Unsigned_32;
-- Parse a list of members
-- members ::= pair | pair ',' members
-- pair ::= string ':' value
-- value ::= string | number | object | array | true | false | null
procedure Parse_Pairs (P : in out Parser'Class);
-- Parse a value
-- value ::= string | number | object | array | true | false | null
procedure Parse_Value (P : in out Parser'Class;
Name : in String);
procedure Parse (P : in out Parser'Class);
procedure Parse (P : in out Parser'Class) is
Token : Token_Type;
begin
Peek (P, Token);
if Token /= T_LEFT_BRACE then
P.Error ("Missing '{'");
end if;
Parse_Pairs (P);
Peek (P, Token);
if Token /= T_RIGHT_BRACE then
P.Error ("Missing '}'");
end if;
end Parse;
-- ------------------------------
-- Parse a list of members
-- members ::= pair | pair ',' members
-- pair ::= string ':' value
-- value ::= string | number | object | array | true | false | null
-- ------------------------------
procedure Parse_Pairs (P : in out Parser'Class) is
Current_Name : Unbounded_String;
Token : Token_Type;
begin
loop
Peek (P, Token);
if Token /= T_STRING then
Put_Back (P, Token);
return;
end if;
Current_Name := P.Token;
Peek (P, Token);
if Token /= T_COLON then
P.Error ("Missing ':'");
end if;
Parse_Value (P, To_String (Current_Name));
Peek (P, Token);
if Token /= T_COMMA then
Put_Back (P, Token);
return;
end if;
end loop;
end Parse_Pairs;
function Hexdigit (C : in Character) return Interfaces.Unsigned_32 is
use type Interfaces.Unsigned_32;
begin
if C >= '0' and C <= '9' then
return Character'Pos (C) - Character'Pos ('0');
elsif C >= 'a' and C <= 'f' then
return Character'Pos (C) - Character'Pos ('a') + 10;
elsif C >= 'A' and C <= 'F' then
return Character'Pos (C) - Character'Pos ('A') + 10;
else
raise Constraint_Error with "Invalid hexdigit: " & C;
end if;
end Hexdigit;
-- ------------------------------
-- Parse a value
-- value ::= string | number | object | array | true | false | null
-- ------------------------------
procedure Parse_Value (P : in out Parser'Class;
Name : in String) is
Token : Token_Type;
begin
Peek (P, Token);
case Token is
when T_LEFT_BRACE =>
P.Start_Object (Name);
Parse_Pairs (P);
Peek (P, Token);
if Token /= T_RIGHT_BRACE then
P.Error ("Missing '}'");
end if;
P.Finish_Object (Name);
--
when T_LEFT_BRACKET =>
P.Start_Array (Name);
Peek (P, Token);
if Token /= T_RIGHT_BRACKET then
Put_Back (P, Token);
loop
Parse_Value (P, Name);
Peek (P, Token);
exit when Token = T_RIGHT_BRACKET;
if Token /= T_COMMA then
P.Error ("Missing ']'");
end if;
end loop;
end if;
P.Finish_Array (Name);
when T_NULL =>
P.Set_Member (Name, Util.Beans.Objects.Null_Object);
when T_NUMBER =>
P.Set_Member (Name, Util.Beans.Objects.To_Object (P.Token));
when T_STRING =>
P.Set_Member (Name, Util.Beans.Objects.To_Object (P.Token));
when T_TRUE =>
P.Set_Member (Name, Util.Beans.Objects.To_Object (True));
when T_FALSE =>
P.Set_Member (Name, Util.Beans.Objects.To_Object (False));
when T_EOF =>
P.Error ("End of stream reached");
return;
when others =>
P.Error ("Invalid token");
end case;
end Parse_Value;
-- ------------------------------
-- Put back a token in the buffer.
-- ------------------------------
procedure Put_Back (P : in out Parser'Class;
Token : in Token_Type) is
begin
P.Pending_Token := Token;
end Put_Back;
-- ------------------------------
-- Parse the expression buffer to find the next token.
-- ------------------------------
procedure Peek (P : in out Parser'Class;
Token : out Token_Type) is
C, C1 : Character;
begin
-- If a token was put back, return it.
if P.Pending_Token /= T_EOF then
Token := P.Pending_Token;
P.Pending_Token := T_EOF;
return;
end if;
if P.Has_Pending_Char then
C := P.Pending_Char;
else
-- Skip white spaces
loop
Stream.Read (Char => C);
if C = Ada.Characters.Latin_1.LF then
P.Line_Number := P.Line_Number + 1;
else
exit when C /= ' '
and C /= Ada.Characters.Latin_1.CR and C /= Ada.Characters.Latin_1.HT;
end if;
end loop;
end if;
P.Has_Pending_Char := False;
-- See what we have and continue parsing.
case C is
-- Literal string using double quotes
-- Collect up to the end of the string and put
-- the result in the parser token result.
when '"' =>
Delete (P.Token, 1, Length (P.Token));
loop
Stream.Read (Char => C1);
if C1 = '\' then
Stream.Read (Char => C1);
case C1 is
when '"' | '\' | '/' =>
null;
when 'b' =>
C1 := Ada.Characters.Latin_1.BS;
when 'f' =>
C1 := Ada.Characters.Latin_1.VT;
when 'n' =>
C1 := Ada.Characters.Latin_1.LF;
when 'r' =>
C1 := Ada.Characters.Latin_1.CR;
when 't' =>
C1 := Ada.Characters.Latin_1.HT;
when 'u' =>
declare
use Interfaces;
C2, C3, C4 : Character;
Val : Interfaces.Unsigned_32;
begin
Stream.Read (Char => C1);
Stream.Read (Char => C2);
Stream.Read (Char => C3);
Stream.Read (Char => C4);
Val := Interfaces.Shift_Left (Hexdigit (C1), 12);
Val := Val + Interfaces.Shift_Left (Hexdigit (C2), 8);
Val := Val + Interfaces.Shift_Left (Hexdigit (C3), 4);
Val := Val + Hexdigit (C4);
-- Encode the value as an UTF-8 string.
if Val >= 16#1000# then
Append (P.Token, Character'Val (16#E0# or Shift_Right (Val, 12)));
Val := Val and 16#0fff#;
Append (P.Token, Character'Val (16#80# or Shift_Right (Val, 6)));
Val := Val and 16#03f#;
C1 := Character'Val (16#80# or Val);
elsif Val >= 16#80# then
Append (P.Token, Character'Val (16#C0# or Shift_Right (Val, 6)));
Val := Val and 16#03f#;
C1 := Character'Val (16#80# or Val);
else
C1 := Character'Val (Val);
end if;
end;
when others =>
P.Error ("Invalid character '" & C1 & "' in \x sequence");
end case;
elsif C1 = C then
Token := T_STRING;
return;
end if;
Append (P.Token, C1);
end loop;
-- Number
when '-' | '0' .. '9' =>
Delete (P.Token, 1, Length (P.Token));
Append (P.Token, C);
loop
Stream.Read (Char => C);
exit when C not in '0' .. '9';
Append (P.Token, C);
end loop;
if C = '.' then
Append (P.Token, C);
loop
Stream.Read (Char => C);
exit when C not in '0' .. '9';
Append (P.Token, C);
end loop;
end if;
if C = 'e' or C = 'E' then
Append (P.Token, C);
Stream.Read (Char => C);
if C = '+' or C = '-' then
Append (P.Token, C);
Stream.Read (Char => C);
end if;
loop
Stream.Read (Char => C);
exit when C not in '0' .. '9';
Append (P.Token, C);
end loop;
end if;
if C /= ' ' and C /= Ada.Characters.Latin_1.HT then
P.Has_Pending_Char := True;
P.Pending_Char := C;
end if;
Token := T_NUMBER;
return;
-- Parse a name composed of letters or digits.
when 'a' .. 'z' | 'A' .. 'Z' =>
Delete (P.Token, 1, Length (P.Token));
Append (P.Token, C);
loop
Stream.Read (Char => C);
exit when not (C in 'a' .. 'z' or C in 'A' .. 'Z'
or C in '0' .. '9' or C = '_');
Append (P.Token, C);
end loop;
-- Putback the last character unless we can ignore it.
if C /= ' ' and C /= Ada.Characters.Latin_1.HT then
P.Has_Pending_Char := True;
P.Pending_Char := C;
end if;
-- and empty eq false ge gt le lt ne not null true
case Element (P.Token, 1) is
when 'n' | 'N' =>
if P.Token = "null" then
Token := T_NULL;
return;
end if;
when 'f' | 'F' =>
if P.Token = "false" then
Token := T_FALSE;
return;
end if;
when 't' | 'T' =>
if P.Token = "true" then
Token := T_TRUE;
return;
end if;
when others =>
null;
end case;
Token := T_UNKNOWN;
return;
when '{' =>
Token := T_LEFT_BRACE;
return;
when '}' =>
Token := T_RIGHT_BRACE;
return;
when '[' =>
Token := T_LEFT_BRACKET;
return;
when ']' =>
Token := T_RIGHT_BRACKET;
return;
when ':' =>
Token := T_COLON;
return;
when ',' =>
Token := T_COMMA;
return;
when others =>
Token := T_UNKNOWN;
return;
end case;
exception
when Ada.IO_Exceptions.Data_Error =>
Token := T_EOF;
return;
end Peek;
begin
Parser'Class (Handler).Start_Object ("");
Parse (Handler);
Parser'Class (Handler).Finish_Object ("");
end Parse;
end Util.Serialize.IO.JSON;
|
reznikmm/matreshka | Ada | 4,838 | ads | ------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- Open Document Toolkit --
-- --
-- Runtime Library Component --
-- --
------------------------------------------------------------------------------
-- --
-- Copyright © 2014, Vadim Godunko <[email protected]> --
-- All rights reserved. --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions --
-- are met: --
-- --
-- * Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- --
-- * Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in the --
-- documentation and/or other materials provided with the distribution. --
-- --
-- * Neither the name of the Vadim Godunko, IE nor the names of its --
-- contributors may be used to endorse or promote products derived from --
-- this software without specific prior written permission. --
-- --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR --
-- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
-- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED --
-- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR --
-- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF --
-- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING --
-- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS --
-- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
-- --
------------------------------------------------------------------------------
-- $Revision$ $Date$
------------------------------------------------------------------------------
with XML.DOM.Visitors;
with ODF.DOM.Text_User_Index_Mark_Start_Elements;
package Matreshka.ODF_Text.User_Index_Mark_Start_Elements is
type Text_User_Index_Mark_Start_Element_Node is
new Matreshka.ODF_Text.Abstract_Text_Element_Node
and ODF.DOM.Text_User_Index_Mark_Start_Elements.ODF_Text_User_Index_Mark_Start
with null record;
overriding function Create
(Parameters : not null access Matreshka.DOM_Elements.Element_L2_Parameters)
return Text_User_Index_Mark_Start_Element_Node;
overriding function Get_Local_Name
(Self : not null access constant Text_User_Index_Mark_Start_Element_Node)
return League.Strings.Universal_String;
overriding procedure Enter_Node
(Self : not null access Text_User_Index_Mark_Start_Element_Node;
Visitor : in out XML.DOM.Visitors.Abstract_Visitor'Class;
Control : in out XML.DOM.Visitors.Traverse_Control);
overriding procedure Leave_Node
(Self : not null access Text_User_Index_Mark_Start_Element_Node;
Visitor : in out XML.DOM.Visitors.Abstract_Visitor'Class;
Control : in out XML.DOM.Visitors.Traverse_Control);
overriding procedure Visit_Node
(Self : not null access Text_User_Index_Mark_Start_Element_Node;
Iterator : in out XML.DOM.Visitors.Abstract_Iterator'Class;
Visitor : in out XML.DOM.Visitors.Abstract_Visitor'Class;
Control : in out XML.DOM.Visitors.Traverse_Control);
end Matreshka.ODF_Text.User_Index_Mark_Start_Elements;
|
AdaCore/gpr | Ada | 136 | ads | --
-- Copyright (C) 2021-2023, AdaCore
--
-- SPDX-License-Identifier: Apache-2.0
--
package Test is
pragma Pure (Test);
end Test;
|
ekoeppen/STM32_Generic_Ada_Drivers | Ada | 2,313 | adb | with STM32_SVD; use STM32_SVD;
with STM32_SVD.GPIO;
with STM32_SVD.USB; use STM32_SVD.USB;
with STM32_SVD.RCC;
with Ada.Interrupts.Names;
with Ada.Text_IO;
package body STM32GD.USB.Peripheral is
procedure Init is
begin
STM32_SVD.RCC.RCC_Periph.APB1ENR.USBEN := 1;
STM32_SVD.RCC.RCC_Periph.APB1RSTR.USBRST := 1;
STM32_SVD.RCC.RCC_Periph.APB1RSTR.USBRST:= 0;
USB_Periph.CNTR.FRES := 1;
USB_Periph.CNTR := (
CTRM => 1, WKUPM => 1, RESETM => 1, SUSPM => 1,
Reserved_5_7 => 0, Reserved_16_31 => 0, others => 0
);
end Init;
procedure Handle_Reset is
BTable_Offset : Integer := 0;
begin
Ada.Text_IO.Put_Line ("Reset");
USB_Periph.DADDR.ADD := 0;
USB_Periph.DADDR.EF := 1;
BTable_Offset := EP0_Reset_Callback (BTable_Offset);
BTable_Offset := EP1_Reset_Callback (BTable_Offset);
BTable_Offset := EP2_Reset_Callback (BTable_Offset);
BTable_Offset := EP3_Reset_Callback (BTable_Offset);
BTable_Offset := EP4_Reset_Callback (BTable_Offset);
BTable_Offset := EP5_Reset_Callback (BTable_Offset);
BTable_Offset := EP6_Reset_Callback (BTable_Offset);
BTable_Offset := EP7_Reset_Callback (BTable_Offset);
end Handle_Reset;
protected body Handler is
procedure IRQ_Handler is
begin
if USB_Periph.ISTR.CTR = 1 then
USB_Periph.ISTR.CTR := 0;
Ada.Text_IO.Put_Line ("Control");
case USB_Periph.ISTR.EP_ID is
when 0 => EP0_Handler_Callback (USB_Periph.ISTR.DIR = 1);
when others => EP0_Handler_Callback (USB_Periph.ISTR.DIR = 1);
end case;
elsif USB_Periph.ISTR.RESET = 1 then
USB_Periph.ISTR.RESET := 0;
Handle_Reset;
elsif USB_Periph.ISTR.WKUP = 1 then
USB_Periph.ISTR.WKUP := 0;
USB_Periph.CNTR := (
CTRM => 1, WKUPM => 1, RESETM => 1, SUSPM => 1,
Reserved_5_7 => 0, Reserved_16_31 => 0, others => 0
);
Ada.Text_IO.Put_Line ("Wakeup");
elsif USB_Periph.ISTR.SUSP = 1 then
USB_Periph.ISTR.SUSP := 0;
USB_Periph.CNTR.LPMODE := 1;
USB_Periph.CNTR.FSUSP := 1;
Ada.Text_IO.Put_Line ("Suspend");
end if;
end IRQ_Handler;
end Handler;
end STM32GD.USB.Peripheral;
|
reznikmm/matreshka | Ada | 7,021 | 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.Highlighted_Range_Elements is
------------
-- Create --
------------
overriding function Create
(Parameters : not null access Matreshka.DOM_Elements.Element_L2_Parameters)
return Table_Highlighted_Range_Element_Node is
begin
return Self : Table_Highlighted_Range_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_Highlighted_Range_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_Highlighted_Range
(ODF.DOM.Table_Highlighted_Range_Elements.ODF_Table_Highlighted_Range_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_Highlighted_Range_Element_Node)
return League.Strings.Universal_String
is
pragma Unreferenced (Self);
begin
return Matreshka.ODF_String_Constants.Highlighted_Range_Element;
end Get_Local_Name;
----------------
-- Leave_Node --
----------------
overriding procedure Leave_Node
(Self : not null access Table_Highlighted_Range_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_Highlighted_Range
(ODF.DOM.Table_Highlighted_Range_Elements.ODF_Table_Highlighted_Range_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_Highlighted_Range_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_Highlighted_Range
(Visitor,
ODF.DOM.Table_Highlighted_Range_Elements.ODF_Table_Highlighted_Range_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.Highlighted_Range_Element,
Table_Highlighted_Range_Element_Node'Tag);
end Matreshka.ODF_Table.Highlighted_Range_Elements;
|
annexi-strayline/AURA | Ada | 6,945 | ads | ------------------------------------------------------------------------------
-- --
-- Ada User Repository Annex (AURA) --
-- ANNEXI-STRAYLINE Reference Implementation --
-- --
-- Command Line Interface --
-- --
-- ------------------------------------------------------------------------ --
-- --
-- Copyright (C) 2019, ANNEXI-STRAYLINE Trans-Human Ltd. --
-- All rights reserved. --
-- --
-- Original Contributors: --
-- * Richard Wai (ANNEXI-STRAYLINE) --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions are --
-- met: --
-- --
-- * Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- --
-- * Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in --
-- the documentation and/or other materials provided with the --
-- distribution. --
-- --
-- * Neither the name of the copyright holder nor the names of its --
-- contributors may be used to endorse or promote products derived --
-- from this software without specific prior written permission. --
-- --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A --
-- PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
-- OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT --
-- LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, --
-- DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY --
-- THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT --
-- (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE --
-- OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
-- --
------------------------------------------------------------------------------
-- This package implements an extremely simply Ada (and gpr) lexical parser,
-- which utilized by the various other subsystems of the AURA CLI
--
-- This parser only handles parsing and categorizing each of the 7 types of
-- "lexical elements" defined by the Ada Reference Manual.
--
-- Obviously this parser should be invoked from the start of the Ada source.
with Ada.Streams;
with Ada.Strings.Wide_Wide_Unbounded;
package Ada_Lexical_Parser is
Invalid_Ada: exception;
type Lexical_Category is
(Delimiter,
Identifier,
Reserved_Word,
Numeric_Literal,
Character_Literal,
String_Literal,
Comment);
package WWU renames Ada.Strings.Wide_Wide_Unbounded;
type Lexical_Element is
record
Category: Lexical_Category;
Content : WWU.Unbounded_Wide_Wide_String;
end record;
-- Note that Character and String literals will be stripped of the
-- enclosing ''' or '"', respectivly
type Source_Position is
record
Absolute_Position: Positive := 1; -- Characters from start of stream
Line : Positive := 1;
Column : Positive := 1;
end record;
type Source_Buffer
(Stream: not null access Ada.Streams.Root_Stream_Type'Class)
is private;
-- The source buffer is used to permit look-ahead capabilities
-- when identifying compound delimiters
------------------
-- Next_Element --
------------------
function Next_Element (Source: in out Source_Buffer)
return Lexical_Element;
-- Returns the next lexical element in the Source_File.
--
-- -- Explicit Raises --
-- * Invalid_Ada: an illegal condition in the source was found.
-- Position (Source) will reveal to position of the
-- offending character
-------------------
-- Last_Position --
-------------------
function Last_Position (Source: Source_Buffer) return Source_Position;
-- Returns the position at of the first character of the last element
-- retrieved, or the last character to indicate invalid Ada
-- (Invalid_Ada raised during a call to Next_Element)
private
subtype Buffer_Count is Natural range 0 .. 10;
subtype Buffer_Index is Buffer_Count range 1 .. 10;
type Stream_Buffer is array (Buffer_Index) of Wide_Wide_Character;
type Line_Column_History is array (Buffer_Index) of Positive;
type Source_Buffer
(Stream: not null access Ada.Streams.Root_Stream_Type'Class)
is record
Content : Stream_Buffer;
Level : Buffer_Count := 0;
Next_Pos : Source_Position;
Last_Pos : Source_Position;
Line_History: Line_Column_History := (others => 1);
Last_Line : Buffer_Index := 1;
-- We track the last column of each previous line for the
-- maximum length of the buffer, so that we can backtrack the
-- column position when going "up" a line
--
-- Line_History takes the form of a circular buffer. This should be
-- fine, since it should mean the backtracking can never actually
-- cause the buffer to circle back ahead of itself
end record;
function Last_Position (Source: Source_Buffer) return Source_Position
is (Source.Last_Pos);
end Ada_Lexical_Parser;
|
faelys/natools | Ada | 200 | ads | package Natools.S_Expressions.Printers.Pretty.Config.Newline_Enc is
pragma Preelaborate;
function Hash (S : String) return Natural;
end Natools.S_Expressions.Printers.Pretty.Config.Newline_Enc;
|
msrLi/portingSources | Ada | 1,014 | adb | -- Copyright 2011-2014 Free Software Foundation, Inc.
--
-- This program is free software; you can redistribute it and/or modify
-- it under the terms of the GNU General Public License as published by
-- the Free Software Foundation; either version 3 of the License, or
-- (at your option) any later version.
--
-- This program is distributed in the hope that it will be useful,
-- but WITHOUT ANY WARRANTY; without even the implied warranty of
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-- GNU General Public License for more details.
--
-- You should have received a copy of the GNU General Public License
-- along with this program. If not, see <http://www.gnu.org/licenses/>.
with Pck; use Pck;
procedure Foo is
type BA is access all Boolean;
type BAs is array (1 .. 1) of BA;
type Blob is record
Val : Integer;
Bees : BAs;
end record;
My_Blob : Blob := (Val => 1, Bees => (1 => null));
begin
Do_Nothing (My_Blob'Address); -- STOP
end Foo;
|
stcarrez/dynamo | Ada | 5,261 | ads | ------------------------------------------------------------------------------
-- --
-- ASIS-for-GNAT IMPLEMENTATION COMPONENTS --
-- --
-- A S I S . T E X T . S E T _ G E T --
-- --
-- S p e c --
-- --
-- Copyright (c) 1995-2006, 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, 51 Franklin --
-- Street, Fifth Floor, Boston, MA 02110-1301, 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 AdaCore --
-- (http://www.adacore.com). --
-- --
------------------------------------------------------------------------------
package Asis.Text.Set_Get is
---------
-- Get --
---------
function Line_Length (L : Line) return Character_Position;
-- Returns line length. Note, that this is the length in the original
-- source, counted in wide characters, but not the length in the internal
-- representation counted in one-byte characters
function Line_Location (L : Line) return Source_Ptr;
-- when Line Location is obtained, the tree is resetted if needed
function Valid (L : Line) return Boolean;
-- chechs, if the argument is valid, that is, if the Context
-- from which this line was obtained is still opened
function Line_Wide_Image (L : Line) return Wide_String;
-- Returns the line image as the line is represented in the original
-- source text
function Debug_Image (The_Span : Span) return String;
-- Produces the debug output for its argument
---------
-- Set --
---------
procedure Set_Line_Length (L : in out Line; N : Character_Position);
procedure Set_Line_Location (L : in out Line; S : Source_Ptr);
-- this procedure is intended to correct the Sloc field in
-- the first line from a line list covering a given Span.
-- This means, that all the fields of the Line to be corrected
-- have been already set as pointing to the beginning of
-- a given line. Together with setting the Sloc field, this
-- procedure adjust the Rel_Sloc field.
procedure Set_Lines (LList : in out Line_List; El : Element);
-- This procedure creates LList as a list of lines
-- accessable through El. It gets LList as a list
-- of Nil_Lines and makes the proper settings for
-- the components of each line, making them non-nil
-- It takes all the characteristics of these lines from El,
-- that is, from the tree on which El is based. This is
-- "tree-swapping-safe" procedure.
-- The only call to this procedure is in the third
-- Asis.Text.Lines function, which explicitly specifies
-- the bounds of the Line_List to be returned (that is, LList).
-- The caller makes all the checks needed to make sure, that
-- the compilation enclosing El really contains lines with numbers
-- LList'First and LList'Last
end Asis.Text.Set_Get;
|
AdaCore/training_material | Ada | 10,317 | adb | -- This code is a subset of ADA.STRINGS.FIXED implementation in GNAT
with Ada.Strings.Maps; use Ada.Strings.Maps;
package body String_Fixed with SPARK_Mode is
-----------------------
-- Local Subprograms --
-----------------------
function Belongs
(Element : Character;
Set : Maps.Character_Set;
Test : Membership) return Boolean;
pragma Inline (Belongs);
-- Determines if the given element is in (Test = Inside) or not in
-- (Test = Outside) the given character set.
-------------
-- Belongs --
-------------
function Belongs
(Element : Character;
Set : Maps.Character_Set;
Test : Membership) return Boolean
is
begin
if Test = Inside then
return Is_In (Element, Set);
else
return not Is_In (Element, Set);
end if;
end Belongs;
------------------------
-- Search Subprograms --
------------------------
-----------
-- Index --
-----------
function Index
(Source : String;
Set : Maps.Character_Set;
Test : Membership := Inside;
Going : Direction := Forward) return Natural
is
begin
-- Forwards case
if Going = Forward then
for J in Source'Range loop
if Belongs (Source (J), Set, Test) then
return J;
end if;
end loop;
-- Backwards case
else
for J in reverse Source'Range loop
if Belongs (Source (J), Set, Test) then
return J;
end if;
end loop;
end if;
-- Fall through if no match
return 0;
end Index;
function Index
(Source : String;
Set : Maps.Character_Set;
From : Positive;
Test : Membership := Inside;
Going : Direction := Forward) return Natural
is
begin
-- AI05-056 : if source is empty result is always 0.
if Source'Length = 0 then
return 0;
elsif Going = Forward then
if From < Source'First then
raise Index_Error;
end if;
return
Index (Source (From .. Source'Last), Set, Test, Forward);
else
if From > Source'Last then
raise Index_Error;
end if;
return
Index (Source (Source'First .. From), Set, Test, Backward);
end if;
end Index;
---------------------
-- Index_Non_Blank --
---------------------
function Index_Non_Blank
(Source : String;
Going : Direction := Forward) return Natural
is
begin
if Going = Forward then
for J in Source'Range loop
if Source (J) /= ' ' then
return J;
end if;
end loop;
else -- Going = Backward
for J in reverse Source'Range loop
if Source (J) /= ' ' then
return J;
end if;
end loop;
end if;
-- Fall through if no match
return 0;
end Index_Non_Blank;
function Index_Non_Blank
(Source : String;
From : Positive;
Going : Direction := Forward) return Natural
is
begin
if Going = Forward then
if From < Source'First then
raise Index_Error;
end if;
return
Index_Non_Blank (Source (From .. Source'Last), Forward);
else
if From > Source'Last then
raise Index_Error;
end if;
return
Index_Non_Blank (Source (Source'First .. From), Backward);
end if;
end Index_Non_Blank;
---------
-- "*" --
---------
function "*"
(Left : Natural;
Right : Character) return String
is
Result : String (1 .. Left);
begin
for J in Result'Range loop
Result (J) := Right;
end loop;
return Result;
end "*";
------------
-- Delete --
------------
function Delete
(Source : String;
From : Positive;
Through : Natural) return String
is
begin
if From > Through then
declare
subtype Result_Type is String (1 .. Source'Length);
begin
return Result_Type (Source);
end;
elsif From not in Source'Range
or else Through > Source'Last
then
raise Index_Error;
else
declare
Front : constant Integer := From - Source'First;
Result : String (1 .. Source'Length - (Through - From + 1));
begin
Result (1 .. Front) :=
Source (Source'First .. From - 1);
Result (Front + 1 .. Result'Last) :=
Source (Through + 1 .. Source'Last);
return Result;
end;
end if;
end Delete;
----------
-- Head --
----------
function Head
(Source : String;
Count : Natural;
Pad : Character := Space) return String
is
subtype Result_Type is String (1 .. Count);
begin
if Count < Source'Length then
return
Result_Type (Source (Source'First .. Source'First + Count - 1));
else
declare
Result : Result_Type;
begin
Result (1 .. Source'Length) := Source;
for J in Source'Length + 1 .. Count loop
Result (J) := Pad;
end loop;
return Result;
end;
end if;
end Head;
------------
-- Insert --
------------
function Insert
(Source : String;
Before : Positive;
New_Item : String) return String
is
Result : String (1 .. Source'Length + New_Item'Length);
Front : constant Integer := Before - Source'First;
begin
if Before not in Source'First .. Source'Last + 1 then
raise Index_Error;
end if;
Result (1 .. Front) :=
Source (Source'First .. Before - 1);
Result (Front + 1 .. Front + New_Item'Length) :=
New_Item;
Result (Front + New_Item'Length + 1 .. Result'Last) :=
Source (Before .. Source'Last);
return Result;
end Insert;
---------------
-- Overwrite --
---------------
function Overwrite
(Source : String;
Position : Positive;
New_Item : String) return String
is
begin
if Position not in Source'First .. Source'Last + 1 then
raise Index_Error;
end if;
declare
Result_Length : constant Natural :=
Integer'Max
(Source'Length,
Position - Source'First + New_Item'Length);
Result : String (1 .. Result_Length);
Front : constant Integer := Position - Source'First;
begin
Result (1 .. Front) :=
Source (Source'First .. Position - 1);
Result (Front + 1 .. Front + New_Item'Length) :=
New_Item;
Result (Front + New_Item'Length + 1 .. Result'Length) :=
Source (Position + New_Item'Length .. Source'Last);
return Result;
end;
end Overwrite;
----------
-- Tail --
----------
function Tail
(Source : String;
Count : Natural;
Pad : Character := Space) return String
is
subtype Result_Type is String (1 .. Count);
begin
if Count < Source'Length then
return Result_Type (Source (Source'Last - Count + 1 .. Source'Last));
-- Pad on left
else
declare
Result : Result_Type;
begin
for J in 1 .. Count - Source'Length loop
Result (J) := Pad;
end loop;
Result (Count - Source'Length + 1 .. Count) := Source;
return Result;
end;
end if;
end Tail;
----------
-- Trim --
----------
function Trim
(Source : String;
Side : Trim_End) return String
is
begin
case Side is
when Ada.Strings.Left =>
declare
Low : constant Natural := Index_Non_Blank (Source, Forward);
begin
-- All blanks case
if Low = 0 then
return "";
end if;
declare
subtype Result_Type is String (1 .. Source'Last - Low + 1);
begin
return Result_Type (Source (Low .. Source'Last));
end;
end;
when Ada.Strings.Right =>
declare
High : constant Natural := Index_Non_Blank (Source, Backward);
begin
-- All blanks case
if High = 0 then
return "";
end if;
declare
subtype Result_Type is String (1 .. High - Source'First + 1);
begin
return Result_Type (Source (Source'First .. High));
end;
end;
when Ada.Strings.Both =>
declare
Low : constant Natural := Index_Non_Blank (Source, Forward);
begin
-- All blanks case
if Low = 0 then
return "";
end if;
declare
High : constant Natural :=
Index_Non_Blank (Source, Backward);
subtype Result_Type is String (1 .. High - Low + 1);
begin
return Result_Type (Source (Low .. High));
end;
end;
end case;
end Trim;
function Trim
(Source : String;
Left : Maps.Character_Set;
Right : Maps.Character_Set) return String
is
High, Low : Integer;
begin
Low := Index (Source, Set => Left, Test => Outside, Going => Forward);
-- Case where source comprises only characters in Left
if Low = 0 then
return "";
end if;
High :=
Index (Source, Set => Right, Test => Outside, Going => Backward);
-- Case where source comprises only characters in Right
if High = 0 then
return "";
end if;
declare
Lgth : constant Integer := High - Low + 1;
subtype Result_Type is String (1 .. Lgth);
begin
return Result_Type (Source (Low .. High));
end;
end Trim;
end String_Fixed;
|
jrmarino/AdaBase | Ada | 2,029 | adb | with AdaBase;
with Connect;
with CommonText;
with Ada.Text_IO;
with AdaBase.Results.Sets;
procedure Spatial2 is
package CON renames Connect;
package TIO renames Ada.Text_IO;
package ARS renames AdaBase.Results.Sets;
package CT renames CommonText;
begin
CON.connect_database;
declare
sql : constant String :=
"SELECT" &
" sp_point" &
", ST_AsText (sp_point) as tx_point" &
", sp_linestring" &
", ST_AsText (sp_linestring) as tx_linestring" &
", sp_multi_point" &
", ST_AsText (sp_multi_point) as tx_multi_point" &
", sp_multi_line_string" &
", ST_AsText (sp_multi_line_string) as tx_multi_line_string" &
", sp_polygon" &
", ST_AsText (sp_polygon) as tx_polygon" &
", sp_outer_ring" &
", ST_AsText (sp_outer_ring) as tx_outer_ring" &
", sp_multi_polygon" &
", ST_AsText (sp_multi_polygon) as tx_multi_polygon" &
", sp_geo_collection" &
", ST_AsText (sp_geo_collection) as tx_geo_collection" &
", sp_geometry" &
", ST_AsText (sp_geometry) as tx_geometry" &
", sp_coll2" &
", ST_AsText (sp_coll2) as tx_coll2" &
", sp_geometry2" &
", ST_AsText (sp_geometry2) as tx_geometry2" &
" FROM spatial_plus";
stmt : CON.Stmt_Type := CON.DR.query (sql);
row : ARS.Datarow;
begin
if not stmt.successful then
TIO.Put_Line (stmt.last_driver_message);
return;
end if;
loop
row := stmt.fetch_next;
exit when row.data_exhausted;
for x in Natural range 1 .. row.count loop
TIO.Put (" column : ");
TIO.Put (stmt.column_name (x));
TIO.Put_Line (" : " & row.column (x).native_type'Img);
TIO.Put_Line (row.column (x).as_string);
end loop;
end loop;
end;
CON.DR.disconnect;
end Spatial2;
|
OneWingedShark/Byron | Ada | 191 | ads | Pragma Ada_2012;
Pragma Assertion_Policy( Check );
With
Lexington.Token_Vector_Pkg;
-- Filters out text-artifact tokens.
Procedure Lexington.Aux.P19(Data : in out Token_Vector_Pkg.Vector);
|
stcarrez/ada-keystore | Ada | 5,277 | adb | -----------------------------------------------------------------------
-- akt-configs -- Configuration
-- Copyright (C) 2019, 2021, 2022 Stephane Carrez
-- Written by Stephane Carrez ([email protected])
--
-- Licensed under the Apache License, Version 2.0 (the "License");
-- you may not use this file except in compliance with the License.
-- You may obtain a copy of the License at
--
-- http://www.apache.org/licenses/LICENSE-2.0
--
-- Unless required by applicable law or agreed to in writing, software
-- distributed under the License is distributed on an "AS IS" BASIS,
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-- See the License for the specific language governing permissions and
-- limitations under the License.
-----------------------------------------------------------------------
with Ada.Environment_Variables;
with Ada.Directories;
with Ada.Strings.Unbounded;
with Interfaces.C.Strings;
with Util.Files;
with Util.Log.Loggers;
with Util.Systems.Os;
with Util.Beans.Objects;
with Util.Properties;
package body AKT.Configs is
use Ada.Strings.Unbounded;
package UBO renames Util.Beans.Objects;
-- The logger
Log : constant Util.Log.Loggers.Logger := Util.Log.Loggers.Create ("AKT.Configs");
function Get_Default_Path return String;
Cfg : Util.Properties.Manager;
Cfg_Path : Ada.Strings.Unbounded.Unbounded_String;
-- ------------------------------
-- Get the default configuration path.
-- ------------------------------
function Get_Default_Path return String is
begin
if not Ada.Environment_Variables.Exists ("HOME") then
return "akt.properties";
end if;
declare
Home : constant String := Ada.Environment_Variables.Value ("HOME");
begin
return Util.Files.Compose (Home, ".config/akt/akt.properties");
end;
end Get_Default_Path;
-- ------------------------------
-- Get the directory which contains the named keys.
-- ------------------------------
function Get_Directory_Key_Path return String is
Val : constant UBO.Object := Cfg.Get_Value (NAMED_KEY_DIR);
begin
if not UBO.Is_Null (Val) then
return UBO.To_String (Val);
end if;
if not Ada.Environment_Variables.Exists ("HOME") then
return "";
end if;
declare
Home : constant String := Ada.Environment_Variables.Value ("HOME");
begin
return Util.Files.Compose (Home, ".config/akt/keys");
end;
end Get_Directory_Key_Path;
-- ------------------------------
-- Initialize the configuration.
-- ------------------------------
procedure Initialize (Path : in String) is
Def_Path : constant String := Get_Default_Path;
begin
if Path'Length > 0 and then Ada.Directories.Exists (Path) then
Log.Info ("Loading configuration {0}", Path);
Cfg.Load_Properties (Path);
Cfg_Path := Ada.Strings.Unbounded.To_Unbounded_String (Path);
elsif Ada.Directories.Exists (Def_Path) then
Log.Info ("Loading user global configuration {0}", Def_Path);
Cfg.Load_Properties (Def_Path);
Cfg_Path := Ada.Strings.Unbounded.To_Unbounded_String (Def_Path);
end if;
if Path'Length > 0 then
Cfg_Path := Ada.Strings.Unbounded.To_Unbounded_String (Path);
end if;
end Initialize;
-- ------------------------------
-- Save the configuration.
-- ------------------------------
procedure Save is
Path : constant String
:= (if Length (Cfg_Path) = 0 then Get_Default_Path else To_String (Cfg_Path));
Dir : constant String := Ada.Directories.Containing_Directory (Path);
P : Interfaces.C.Strings.chars_ptr;
begin
Log.Info ("Saving configuration {0}", Path);
if not Ada.Directories.Exists (Path) then
Ada.Directories.Create_Path (Dir);
P := Interfaces.C.Strings.New_String (Dir);
if Util.Systems.Os.Sys_Chmod (P, 8#0700#) /= 0 then
Log.Error (-("cannot set the permission of {0}"), Dir);
end if;
Interfaces.C.Strings.Free (P);
end if;
Cfg.Save_Properties (Path);
-- Set the permission on the file to allow only the user to read/write that file.
P := Interfaces.C.Strings.New_String (Path);
if Util.Systems.Os.Sys_Chmod (P, 8#0600#) /= 0 then
Log.Error (-("cannot set the permission of {0}"), Path);
end if;
Interfaces.C.Strings.Free (P);
end Save;
-- ------------------------------
-- Get the configuration parameter.
-- ------------------------------
function Get (Name : in String) return String is
begin
return Cfg.Get (Name);
end Get;
-- ------------------------------
-- Set the configuration parameter.
-- ------------------------------
procedure Set (Name : in String;
Value : in String) is
begin
Cfg.Set (Name, Value);
end Set;
-- ------------------------------
-- Returns true if the configuration parameter is defined.
-- ------------------------------
function Exists (Name : in String) return Boolean is
begin
return Cfg.Exists (Name);
end Exists;
end AKT.Configs;
|
Rahul24-06/ADA-Line-Follower-using-STM32-Nucleo-64 | Ada | 16,366 | adb | with reg;
package body pinconfig is
use type reg.Word;
procedure Enable_Input (Pin : in Pin_ID; Mode : in Input_Mode) is
begin
case Pin is
when Pin_2 =>
reg.RCC_AHB1ENR := reg.RCC_AHB1ENR
or 2#10_0000#; -- bit 5
reg.GPIOF_MODER := reg.GPIOF_MODER
and 2#0011_1111_1111_1111_1111_1111_1111_1111#; -- bits 30-31
if Mode = Pulled_Up then
reg.GPIOF_PUPDR := (reg.GPIOF_PUPDR
and 2#0011_1111_1111_1111_1111_1111_1111_1111#)
or 2#0100_0000_0000_0000_0000_0000_0000_0000#;
else
reg.GPIOF_PUPDR := reg.GPIOF_PUPDR
and 2#0011_1111_1111_1111_1111_1111_1111_1111#;
end if;
when Pin_3 =>
reg.RCC_AHB1ENR := reg.RCC_AHB1ENR
or 2#1_0000#; -- bit 4
reg.GPIOE_MODER := reg.GPIOE_MODER
and 2#1111_0011_1111_1111_1111_1111_1111_1111#; -- bits 26-27
if Mode = Pulled_Up then
reg.GPIOE_PUPDR := (reg.GPIOE_PUPDR
and 2#1111_0011_1111_1111_1111_1111_1111_1111#)
or 2#0000_0100_0000_0000_0000_0000_0000_0000#;
else
reg.GPIOE_PUPDR := reg.GPIOE_PUPDR
and 2#1111_0011_1111_1111_1111_1111_1111_1111#;
end if;
when Pin_4 =>
reg.RCC_AHB1ENR := reg.RCC_AHB1ENR
or 2#10_0000#; -- bit 5
reg.GPIOF_MODER := reg.GPIOF_MODER
and 2#1100_1111_1111_1111_1111_1111_1111_1111#; -- bits 28-29
if Mode = Pulled_Up then
reg.GPIOF_PUPDR := (reg.GPIOF_PUPDR
and 2#1100_1111_1111_1111_1111_1111_1111_1111#)
or 2#0001_0000_0000_0000_0000_0000_0000_0000#;
else
reg.GPIOF_PUPDR := reg.GPIOF_PUPDR
and 2#1100_1111_1111_1111_1111_1111_1111_1111#;
end if;
when Pin_5 =>
reg.RCC_AHB1ENR := reg.RCC_AHB1ENR
or 2#1_0000#; -- bit 4
reg.GPIOE_MODER := reg.GPIOE_MODER
and 2#1111_1111_0011_1111_1111_1111_1111_1111#; -- bits 22-23
if Mode = Pulled_Up then
reg.GPIOE_PUPDR := (reg.GPIOE_PUPDR
and 2#1111_1111_0011_1111_1111_1111_1111_1111#)
or 2#0000_0000_0100_0000_0000_0000_0000_0000#;
else
reg.GPIOE_PUPDR := reg.GPIOE_PUPDR
and 2#1111_1111_0011_1111_1111_1111_1111_1111#;
end if;
when Pin_6 =>
reg.RCC_AHB1ENR := reg.RCC_AHB1ENR
or 2#1_0000#; -- bit 4
reg.GPIOE_MODER := reg.GPIOE_MODER
and 2#1111_1111_1111_0011_1111_1111_1111_1111#; -- bits 18-19
if Mode = Pulled_Up then
reg.GPIOE_PUPDR := (reg.GPIOE_PUPDR
and 2#1111_1111_1111_0011_1111_1111_1111_1111#)
or 2#0000_0000_0000_0100_0000_0000_0000_0000#;
else
reg.GPIOE_PUPDR := reg.GPIOE_PUPDR
and 2#1111_1111_1111_0011_1111_1111_1111_1111#;
end if;
when Pin_7 =>
reg.RCC_AHB1ENR := reg.RCC_AHB1ENR
or 2#10_0000#; -- bit 5
reg.GPIOF_MODER := reg.GPIOF_MODER
and 2#1111_0011_1111_1111_1111_1111_1111_1111#; -- bits 26-27
if Mode = Pulled_Up then
reg.GPIOF_PUPDR := (reg.GPIOF_PUPDR
and 2#1111_0011_1111_1111_1111_1111_1111_1111#)
or 2#0000_0100_0000_0000_0000_0000_0000_0000#;
else
reg.GPIOF_PUPDR := reg.GPIOF_PUPDR
and 2#1111_0011_1111_1111_1111_1111_1111_1111#;
end if;
when Pin_8 =>
reg.RCC_AHB1ENR := reg.RCC_AHB1ENR
or 2#10_0000#; -- bit 5
reg.GPIOF_MODER := reg.GPIOF_MODER
and 2#1111_1100_1111_1111_1111_1111_1111_1111#; -- bits 24-25
if Mode = Pulled_Up then
reg.GPIOF_PUPDR := (reg.GPIOF_PUPDR
and 2#1111_1100_1111_1111_1111_1111_1111_1111#)
or 2#0000_0001_0000_0000_0000_0000_0000_0000#;
else
reg.GPIOF_PUPDR := reg.GPIOF_PUPDR
and 2#1111_1100_1111_1111_1111_1111_1111_1111#;
end if;
when Pin_9 =>
reg.RCC_AHB1ENR := reg.RCC_AHB1ENR
or 2#1000#; -- bit 3
reg.GPIOD_MODER := reg.GPIOD_MODER
and 2#0011_1111_1111_1111_1111_1111_1111_1111#; -- bit pair 30-31
if Mode = Pulled_Up then
reg.GPIOD_PUPDR := (reg.GPIOD_PUPDR
and 2#0011_1111_1111_1111_1111_1111_1111_1111#)
or 2#0100_0000_0000_0000_0000_0000_0000_0000#;
else
reg.GPIOD_PUPDR := reg.GPIOD_PUPDR
and 2#0011_1111_1111_1111_1111_1111_1111_1111#;
end if;
when Pin_10 =>
reg.RCC_AHB1ENR := reg.RCC_AHB1ENR
or 2#1000#; -- bit 3
reg.GPIOD_MODER := reg.GPIOD_MODER
and 2#1100_1111_1111_1111_1111_1111_1111_1111#; -- bit pair 28-29
if Mode = Pulled_Up then
reg.GPIOD_PUPDR := (reg.GPIOD_PUPDR
and 2#1100_1111_1111_1111_1111_1111_1111_1111#)
or 2#0001_0000_0000_0000_0000_0000_0000_0000#;
else
reg.GPIOD_PUPDR := reg.GPIOD_PUPDR
and 2#1100_1111_1111_1111_1111_1111_1111_1111#;
end if;
when Pin_11 =>
reg.RCC_AHB1ENR := reg.RCC_AHB1ENR
or 2#1#; -- bit 0
reg.GPIOA_MODER := reg.GPIOA_MODER
and 2#1111_1111_1111_1111_0011_1111_1111_1111#; -- bit pair 14-15
if Mode = Pulled_Up then
reg.GPIOA_PUPDR := (reg.GPIOA_PUPDR
and 2#1111_1111_1111_1111_0011_1111_1111_1111#)
or 2#0000_0000_0000_0000_0100_0000_0000_0000#;
else
reg.GPIOA_PUPDR := reg.GPIOA_PUPDR
and 2#1111_1111_1111_1111_0011_1111_1111_1111#;
end if;
when Pin_12 =>
reg.RCC_AHB1ENR := reg.RCC_AHB1ENR
or 2#1#; -- bit 0
reg.GPIOA_MODER := reg.GPIOA_MODER
and 2#1111_1111_1111_1111_1100_1111_1111_1111#; -- bit pair 12-13
if Mode = Pulled_Up then
reg.GPIOA_PUPDR := (reg.GPIOA_PUPDR
and 2#1111_1111_1111_1111_1100_1111_1111_1111#)
or 2#0000_0000_0000_0000_0001_0000_0000_0000#;
else
reg.GPIOA_PUPDR := reg.GPIOA_PUPDR
and 2#1111_1111_1111_1111_1100_1111_1111_1111#;
end if;
when Pin_13 =>
reg.RCC_AHB1ENR := reg.RCC_AHB1ENR
or 2#1#; -- bit 0
reg.GPIOA_MODER := reg.GPIOA_MODER
and 2#1111_1111_1111_1111_1111_0011_1111_1111#; -- bit pair 10-11
if Mode = Pulled_Up then
reg.GPIOA_PUPDR := (reg.GPIOA_PUPDR
and 2#1111_1111_1111_1111_1111_0011_1111_1111#)
or 2#0000_0000_0000_0000_0000_0100_0000_0000#;
else
reg.GPIOA_PUPDR := reg.GPIOA_PUPDR
and 2#1111_1111_1111_1111_1111_0011_1111_1111#;
end if;
end case;
end Enable_Input;
procedure Enable_Output (Pin : in Pin_ID) is
begin
case Pin is
when Pin_2 =>
reg.RCC_AHB1ENR := reg.RCC_AHB1ENR
or 2#10_0000#; -- bit 5
reg.GPIOF_MODER := (reg.GPIOF_MODER
and 2#0011_1111_1111_1111_1111_1111_1111_1111#)
or 2#0100_0000_0000_0000_0000_0000_0000_0000#; -- bits 30-31
when Pin_3 =>
reg.RCC_AHB1ENR := reg.RCC_AHB1ENR
or 2#1_0000#; -- bit 4
reg.GPIOE_MODER := (reg.GPIOE_MODER
and 2#1111_0011_1111_1111_1111_1111_1111_1111#)
or 2#0000_0100_0000_0000_0000_0000_0000_0000#; -- bits 26-27
when Pin_4 =>
reg.RCC_AHB1ENR := reg.RCC_AHB1ENR
or 2#10_0000#; -- bit 5
reg.GPIOF_MODER := (reg.GPIOF_MODER
and 2#1100_1111_1111_1111_1111_1111_1111_1111#)
or 2#0001_0000_0000_0000_0000_0000_0000_0000#; -- bits 28-29
when Pin_5 =>
reg.RCC_AHB1ENR := reg.RCC_AHB1ENR
or 2#1_0000#; -- bit 4
reg.GPIOE_MODER := (reg.GPIOE_MODER
and 2#1111_1111_0011_1111_1111_1111_1111_1111#)
or 2#0000_0000_0100_0000_0000_0000_0000_0000#; -- bits 22-23
when Pin_6 =>
reg.RCC_AHB1ENR := reg.RCC_AHB1ENR
or 2#1_0000#; -- bit 4
reg.GPIOE_MODER := (reg.GPIOE_MODER
and 2#1111_1111_1111_0011_1111_1111_1111_1111#)
or 2#0000_0000_0000_0100_0000_0000_0000_0000#; -- bits 18-19
when Pin_7 =>
reg.RCC_AHB1ENR := reg.RCC_AHB1ENR
or 2#10_0000#; -- bit 5
reg.GPIOF_MODER := (reg.GPIOF_MODER
and 2#1111_0011_1111_1111_1111_1111_1111_1111#)
or 2#0000_0100_0000_0000_0000_0000_0000_0000#; -- bits 26-27
when Pin_8 =>
reg.RCC_AHB1ENR := reg.RCC_AHB1ENR
or 2#10_0000#; -- bit 5
reg.GPIOF_MODER := (reg.GPIOF_MODER
and 2#1111_1100_1111_1111_1111_1111_1111_1111#)
or 2#0000_0001_0000_0000_0000_0000_0000_0000#; -- bits 24-25
when Pin_9 =>
reg.RCC_AHB1ENR := reg.RCC_AHB1ENR
or 2#1000#; -- bit 3
reg.GPIOD_MODER := (reg.GPIOD_MODER
and 2#0011_1111_1111_1111_1111_1111_1111_1111#)
or 2#0100_0000_0000_0000_0000_0000_0000_0000#; -- bits 30-31
when Pin_10 =>
reg.RCC_AHB1ENR := reg.RCC_AHB1ENR
or 2#1000#; -- bit 3
reg.GPIOD_MODER := (reg.GPIOD_MODER
and 2#1100_1111_1111_1111_1111_1111_1111_1111#)
or 2#0001_0000_0000_0000_0000_0000_0000_0000#; -- bits 28-29
when Pin_11 =>
reg.RCC_AHB1ENR := reg.RCC_AHB1ENR
or 2#1#; -- bit 0
reg.GPIOA_MODER := (reg.GPIOA_MODER
and 2#1111_1111_1111_1111_0011_1111_1111_1111#)
or 2#0000_0000_0000_0000_0100_0000_0000_0000#; -- bits 14-15
when Pin_12 =>
reg.RCC_AHB1ENR := reg.RCC_AHB1ENR
or 2#1#; -- bit 0
reg.GPIOA_MODER := (reg.GPIOA_MODER
and 2#1111_1111_1111_1111_1100_1111_1111_1111#)
or 2#0000_0000_0000_0000_0001_0000_0000_0000#; -- bits 12-13
when Pin_13 =>
reg.RCC_AHB1ENR := reg.RCC_AHB1ENR
or 2#1#; -- bit 0
reg.GPIOA_MODER := (reg.GPIOA_MODER
and 2#1111_1111_1111_1111_1111_0011_1111_1111#)
or 2#0000_0000_0000_0000_0000_0100_0000_0000#; -- bits 10-11
end case;
end Enable_Output;
procedure Read (Pin : in Pin_ID; State : out Boolean) is
Data : reg.Word;
begin
case Pin is
when Pin_2 =>
Data := reg.GPIOF_IDR;
State := (Data and 2#1000_0000_0000_0000#) /= 0; -- bit 15
when Pin_3 =>
Data := reg.GPIOE_IDR;
State := (Data and 2#10_0000_0000_0000#) /= 0; -- bit 13
when Pin_4 =>
Data := reg.GPIOF_IDR;
State := (Data and 2#100_0000_0000_0000#) /= 0; -- bit 14
when Pin_5 =>
Data := reg.GPIOE_IDR;
State := (Data and 2#1000_0000_0000#) /= 0; -- bit 11
when Pin_6 =>
Data := reg.GPIOE_IDR;
State := (Data and 2#10_0000_0000#) /= 0; -- bit 9
when Pin_7 =>
Data := reg.GPIOF_IDR;
State := (Data and 2#10_0000_0000_0000#) /= 0; -- bit 13
when Pin_8 =>
Data := reg.GPIOF_IDR;
State := (Data and 2#1_0000_0000_0000#) /= 0; -- bit 12
when Pin_9 =>
Data := reg.GPIOD_IDR;
State := (Data and 2#1000_0000_0000_0000#) /= 0; -- bit 15
when Pin_10 =>
Data := reg.GPIOD_IDR;
State := (Data and 2#100_0000_0000_0000#) /= 0; -- bit 14
when Pin_11 =>
Data := reg.GPIOA_IDR;
State := (Data and 2#1000_0000#) /= 0; -- bit 7
when Pin_12 =>
Data := reg.GPIOA_IDR;
State := (Data and 2#100_0000#) /= 0; -- bit 6
when Pin_13 =>
Data := reg.GPIOA_IDR;
State := (Data and 2#10_0000#) /= 0; -- bit 5
end case;
end Read;
procedure Write (Pin : in Pin_ID; State : Boolean) is
begin
case Pin is
when Pin_2 =>
if State then
reg.GPIOF_BSRR := 2#1000_0000_0000_0000#; -- bit 15
else
reg.GPIOF_BSRR := 2#1000_0000_0000_0000_0000_0000_0000_0000#;
end if;
when Pin_3 =>
if State then
reg.GPIOE_BSRR := 2#10_0000_0000_0000#; -- bit 13
else
reg.GPIOE_BSRR := 2#10_0000_0000_0000_0000_0000_0000_0000#;
end if;
when Pin_4 =>
if State then
reg.GPIOF_BSRR := 2#100_0000_0000_0000#; -- bit 14
else
reg.GPIOF_BSRR := 2#100_0000_0000_0000_0000_0000_0000_0000#;
end if;
when Pin_5 =>
if State then
reg.GPIOE_BSRR := 2#1000_0000_0000#; -- bit 11
else
reg.GPIOE_BSRR := 2#1000_0000_0000_0000_0000_0000_0000#;
end if;
when Pin_6 =>
if State then
reg.GPIOE_BSRR := 2#10_0000_0000#; -- bit 9
else
reg.GPIOE_BSRR := 2#10_0000_0000_0000_0000_0000_0000#;
end if;
when Pin_7 =>
if State then
reg.GPIOF_BSRR := 2#10_0000_0000_0000#; -- bit 13
else
reg.GPIOF_BSRR := 2#10_0000_0000_0000_0000_0000_0000_0000#;
end if;
when Pin_8 =>
if State then
reg.GPIOF_BSRR := 2#1_0000_0000_0000#; -- bit 12
else
reg.GPIOF_BSRR := 2#1_0000_0000_0000_0000_0000_0000_0000#;
end if;
when Pin_9 =>
if State then
reg.GPIOD_BSRR := 2#1000_0000_0000_0000#; -- bit 15
else
reg.GPIOD_BSRR := 2#1000_0000_0000_0000_0000_0000_0000_0000#;
end if;
when Pin_10 =>
if State then
reg.GPIOD_BSRR := 2#100_0000_0000_0000#; -- bit 14
else
reg.GPIOD_BSRR := 2#100_0000_0000_0000_0000_0000_0000_0000#;
end if;
when Pin_11 =>
if State then
reg.GPIOA_BSRR := 2#1000_0000#; -- bit 7
else
reg.GPIOA_BSRR := 2#1000_0000_0000_0000_0000_0000#;
end if;
when Pin_12 =>
if State then
reg.GPIOA_BSRR := 2#100_0000#; -- bit 6
else
reg.GPIOA_BSRR := 2#100_0000_0000_0000_0000_0000#;
end if;
when Pin_13 =>
if State then
reg.GPIOA_BSRR := 2#10_0000#; -- bit 5
else
reg.GPIOA_BSRR := 2#10_0000_0000_0000_0000_0000#;
end if;
end case;
end Write;
end reg; |
grim7reaper/SipHash | Ada | 5,619 | adb | ------------------------------------------------------------------------
-- Copyright (c) 2014 Sylvain Laperche <[email protected]>
-- All rights reserved.
--
-- Redistribution and use in source and binary forms, with or without
-- modification, are permitted provided that the following conditions
-- are met:
-- 1. Redistributions of source code must retain the above copyright
-- notice, this list of conditions and the following disclaimer.
-- 2. Redistributions in binary form must reproduce the above copyright
-- notice, this list of conditions and the following disclaimer in
-- the documentation and/or other materials provided with the
-- distribution.
-- 3. Neither the name of author 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 HOLDERS AND CONTRIBUTORSBE LIABLE FOR ANY DIRECT,
-- INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
-- (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
-- SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
-- HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
-- STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
-- ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
-- OF THE POSSIBILITY OF SUCH DAMAGE.
------------------------------------------------------------------------
with Ada.Text_IO;
with SipHash.PRF;
---------------------------------------------------------------------
-- Tests.Block_Interface
--
-- Purpose:
-- This procedure tests the Block interface of SipHash.
-- Exceptions:
-- None.
-- References:
-- [1]J.-P. Aumasson and D. J. Bernstein, “SipHash: a fast short-input
-- PRF.” 18-Sep-2012 (https://131002.net/siphash/siphash.pdf)
-- [2]J.-P. Aumasson and D. J. Bernstein, "Reference C implementation"
-- (https://131002.net/siphash/siphash24.c)
---------------------------------------------------------------------
procedure Tests.Block_Interface is
package T_IO renames Ada.Text_IO;
package SipHash24 is new SipHash.PRF(Nb_Compression_Rounds => 2,
Nb_Finalization_Rounds => 4);
---------------------------------------------------------------------
-- Test_Paper
--
-- Purpose:
-- This function tests the implementation against the test values
-- provided in the original paper (Cf. Appendix A, p. 19 of [1]).
-- Return:
-- Returns True if the test passed, otherwise False.
-- Exceptions:
-- None.
---------------------------------------------------------------------
function Test_Paper
return Boolean is
Result : SipHash.U64;
begin
Result := SipHash24.Hash(Paper_Input, Key);
if Result /= Paper_Output then
Put_Error("Test_Paper", Paper_Output, Result);
return False;
else
return True;
end if;
end Test_Paper;
---------------------------------------------------------------------
-- Test_Empty_Input
--
-- Purpose:
-- This function tests the implementation with an empty input.
-- Return:
-- Returns True if the test passed, otherwise False.
-- Exceptions:
-- None.
---------------------------------------------------------------------
function Test_Empty_Input
return Boolean is
Result : SipHash.U64;
begin
Result := SipHash24.Hash(Empty_Input, Key);
if Result /= Empty_Output then
Put_Error("Test_Empty_Input", Empty_Output, Result);
return False;
else
return True;
end if;
end Test_Empty_Input;
---------------------------------------------------------------------
-- Test_Reference_Implementation
--
-- Purpose:
-- This function tests the implementation against the test values
-- provided in the reference C implementation (Cf. [2]).
-- Return:
-- Returns True if the test passed, otherwise False.
-- Exceptions:
-- None.
---------------------------------------------------------------------
function Test_Reference_Implementation
return Boolean is
Input : SipHash.Byte_Sequence(1..63);
Result : SipHash.U64;
Status : Boolean := True;
begin
-- Test the following inputs:
-- Input = 00 (1 byte)
-- Input = 00 01 (2 bytes)
-- Input = 00 01 02 (3 bytes)
-- ...
-- Input = 00 01 02 ... 3e (63 bytes)
for I in Input'Range loop
Input(I) := SipHash.U8(I-1);
Result := SipHash24.Hash(Input(1..I), Key);
if Result /= C_Ref_Output(I) then
Put_Error("Test_Reference_Implementation",
C_Ref_Output(I), Result);
Status := False;
exit;
end if;
end loop;
return Status;
end Test_Reference_Implementation;
Status : Boolean := True;
begin
T_IO.Put_Line("SipHash v" & SipHash.Version_String);
Status := Status and Test_Paper;
Status := Status and Test_Empty_Input;
Status := Status and Test_Reference_Implementation;
-- Check if everything went well.
if Status then
T_IO.Put_Line("All tests passed!");
end if;
end Tests.Block_Interface;
|
mitchelhaan/ncurses | Ada | 3,447 | ads | ------------------------------------------------------------------------------
-- --
-- GNAT ncurses Binding --
-- --
-- Terminal_Interface.Curses.Forms.Field_Types.RegExp --
-- --
-- S P E C --
-- --
------------------------------------------------------------------------------
-- Copyright (c) 1998 Free Software Foundation, Inc. --
-- --
-- Permission is hereby granted, free of charge, to any person obtaining a --
-- copy of this software and associated documentation files (the --
-- "Software"), to deal in the Software without restriction, including --
-- without limitation the rights to use, copy, modify, merge, publish, --
-- distribute, distribute with modifications, sublicense, and/or sell --
-- copies of the Software, and to permit persons to whom the Software is --
-- furnished to do so, subject to the following conditions: --
-- --
-- The above copyright notice and this permission notice shall be included --
-- in all copies or substantial portions of the Software. --
-- --
-- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS --
-- OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF --
-- MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. --
-- IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, --
-- DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR --
-- OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR --
-- THE USE OR OTHER DEALINGS IN THE SOFTWARE. --
-- --
-- Except as contained in this notice, the name(s) of the above copyright --
-- holders shall not be used in advertising or otherwise to promote the --
-- sale, use or other dealings in this Software without prior written --
-- authorization. --
------------------------------------------------------------------------------
-- Author: Juergen Pfeifer <[email protected]> 1996
-- Version Control:
-- $Revision: 1.5 $
-- Binding Version 00.93
------------------------------------------------------------------------------
package Terminal_Interface.Curses.Forms.Field_Types.RegExp is
pragma Preelaborate (RegExp);
type String_Access is access String;
type Regular_Expression_Field is new Field_Type with
record
Regular_Expression : String_Access;
end record;
procedure Set_Field_Type (Fld : in Field;
Typ : in Regular_Expression_Field);
pragma Inline (Set_Field_Type);
end Terminal_Interface.Curses.Forms.Field_Types.RegExp;
|
redparavoz/ada-wiki | Ada | 3,764 | ads | -----------------------------------------------------------------------
-- wiki-streams-html -- Wiki HTML output stream
-- Copyright (C) 2011, 2012, 2013, 2015, 2016 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 Wiki.Strings;
-- === HTML Output Stream ===
-- The <tt>Wiki.Writers</tt> package defines the interfaces used by the renderer to write
-- their outputs.
--
-- The <tt>Input_Stream</tt> interface defines the interface that must be implemented to
-- read the source Wiki content. The <tt>Read</tt> procedure is called by the parser
-- repeatedly while scanning the Wiki content.
package Wiki.Streams.Html is
type Html_Output_Stream is limited interface and Output_Stream;
type Html_Output_Stream_Access is access all Html_Output_Stream'Class;
-- Write an XML attribute within an XML element.
-- The attribute value is escaped according to the XML escape rules.
procedure Write_Wide_Attribute (Writer : in out Html_Output_Stream;
Name : in String;
Content : in Wiki.Strings.UString) is abstract;
-- Write an XML attribute within an XML element.
-- The attribute value is escaped according to the XML escape rules.
procedure Write_Wide_Attribute (Writer : in out Html_Output_Stream;
Name : in String;
Content : in Wide_Wide_String) is abstract;
-- Start an XML element with the given name.
procedure Start_Element (Writer : in out Html_Output_Stream;
Name : in String) is abstract;
-- Closes an XML element of the given name.
procedure End_Element (Writer : in out Html_Output_Stream;
Name : in String) is abstract;
-- Write a text escaping any character as necessary.
procedure Write_Wide_Text (Writer : in out Html_Output_Stream;
Content : in Wiki.Strings.WString) is abstract;
-- Write a character on the response stream and escape that character as necessary.
procedure Write_Escape (Stream : in out Html_Output_Stream'Class;
Char : in Wiki.Strings.WChar);
-- Write a string on the response stream and escape the characters as necessary.
procedure Write_Escape (Stream : in out Html_Output_Stream'Class;
Content : in Wiki.Strings.WString);
-- Write an XML attribute within an XML element.
-- The attribute value is escaped according to the XML escape rules.
procedure Write_Escape_Attribute (Stream : in out Html_Output_Stream'Class;
Name : in String;
Content : in Wiki.Strings.WString);
-- Write an XML attribute within an XML element.
-- The attribute value is escaped according to the XML escape rules.
procedure Write_Attribute (Writer : in out Html_Output_Stream'Class;
Name : in String;
Content : in String);
end Wiki.Streams.Html;
|
stcarrez/ada-util | Ada | 3,622 | ads | -----------------------------------------------------------------------
-- util-encoders-ecc -- Error Correction Code
-- Copyright (C) 2019, 2022 Stephane Carrez
-- Written by Stephane Carrez ([email protected])
--
-- Licensed under the Apache License, Version 2.0 (the "License");
-- you may not use this file except in compliance with the License.
-- You may obtain a copy of the License at
--
-- http://www.apache.org/licenses/LICENSE-2.0
--
-- Unless required by applicable law or agreed to in writing, software
-- distributed under the License is distributed on an "AS IS" BASIS,
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-- See the License for the specific language governing permissions and
-- limitations under the License.
-----------------------------------------------------------------------
-- == Error Correction Code ==
-- The `Util.Encoders.ECC` package provides operations to support error correction codes.
-- The error correction works on blocks of 256 or 512 bytes and can detect 2-bit errors
-- and correct 1-bit error. The ECC uses only three additional bytes.
-- The ECC algorithm implemented by this package is implemented by several NAND Flash
-- memory. It can be used to increase the robustness of data to bit-tempering when
-- the data is restored from an external storage (note that if the external storage has
-- its own ECC correction, adding another software ECC correction will probably not help).
--
-- The ECC code is generated by using the `Make` procedure that gets a block of 256 or
-- 512 bytes and produces the 3 bytes ECC code. The ECC code must be saved together with
-- the data block.
--
-- Code : Util.Encoders.ECC.ECC_Code;
-- ...
-- Util.Encoders.ECC.Make (Data, Code);
--
-- When reading the data block, you can verify and correct it by running again the
-- `Make` procedure on the data block and then compare the current ECC code with the
-- expected ECC code produced by the first call. The `Correct` function is then called
-- with the data block, the expected ECC code that was saved with the data block and
-- the computed ECC code.
--
-- New_Code : Util.Encoders.ECC.ECC_Code;
-- ...
-- Util.Encoders.ECC.Make (Data, New_Code);
-- case Util.Encoders.ECC.Correct (Data, Expect_Code, New_Code) is
-- when NO_ERROR | CORRECTABLE_ERROR => ...
-- when others => ...
-- end case;
package Util.Encoders.ECC is
type ECC_Result is (NO_ERROR, CORRECTABLE_ERROR, UNCORRECTABLE_ERROR, ECC_ERROR);
subtype ECC_Code is Ada.Streams.Stream_Element_Array (0 .. 2);
-- Make the 3 bytes ECC code that corresponds to the data array.
procedure Make (Data : in Ada.Streams.Stream_Element_Array;
Code : out ECC_Code) with
Pre => Data'Length in 256 | 512;
-- Check and correct the data array according to the expected ECC codes and current codes.
-- At most one bit can be fixed and two error bits can be detected.
function Correct (Data : in out Ada.Streams.Stream_Element_Array;
Expect_Code : in ECC_Code;
Current_Code : in ECC_Code) return ECC_Result with
Pre => Data'Length in 256 | 512;
-- Check and correct the data array according to the expected ECC codes and current codes.
-- At most one bit can be fixed and two error bits can be detected.
function Correct (Data : in out Ada.Streams.Stream_Element_Array;
Expect_Code : in ECC_Code) return ECC_Result with
Pre => Data'Length in 256 | 512;
end Util.Encoders.ECC;
|
reznikmm/matreshka | Ada | 1,305 | ads | with Ada.Containers.Vectors;
with Ada.Streams;
with GNAT.CRC32;
with League.Calendars;
with League.Strings;
with Zip.IO;
package Zip.Metadata is
type File_Record is record
File_Name : League.Strings.Universal_String;
Method : Compression_Method;
Last_Modified : League.Calendars.Date_Time;
CRC32 : GNAT.CRC32.CRC32;
Compressed_Size : Ada.Streams.Stream_Element_Offset;
Uncompressed_Size : Ada.Streams.Stream_Element_Offset;
Has_Data_Descriptor : Boolean;
Local_Header_Offset : Ada.Streams.Stream_Element_Offset;
end record;
package File_Record_Vectors is
new Ada.Containers.Vectors (Positive, File_Record);
type Central_Directory is record
Files : File_Record_Vectors.Vector;
end record;
function Read (File : access Zip.IO.File_Type) return Central_Directory;
procedure Write
(Stream : access Ada.Streams.Root_Stream_Type'Class;
Offset : Zip.Zip_File_Offset;
Directory : Central_Directory);
procedure Read_Local_File_Header
(Stream : access Zip.IO.File_Type;
Header : out File_Record);
procedure Write_Local_File_Header
(Stream : access Ada.Streams.Root_Stream_Type'Class;
Header : File_Record);
end Zip.Metadata;
|
esbullington/aflex | Ada | 33,219 | adb | -- Copyright (c) 1990 Regents of the University of California.
-- All rights reserved.
--
-- This software was developed by John Self of the Arcadia project
-- at the University of California, Irvine.
--
-- Redistribution and use in source and binary forms are permitted
-- provided that the above copyright notice and this paragraph are
-- duplicated in all such forms and that any documentation,
-- advertising materials, and other materials related to such
-- distribution and use acknowledge that the software was developed
-- by the University of California, Irvine. The name of the
-- University may not be used to endorse or promote products derived
-- from this software without specific prior written permission.
-- THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
-- IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
-- WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
-- TITLE template manager
-- AUTHOR: John Self (UCI)
-- DESCRIPTION supports output of internalized templates for the IO and DFA
-- packages.
-- NOTES This package is quite a memory hog, and is really only useful on
-- virtual memory systems. It could use an external file to store the
-- templates like the skeleton manager. This would save memory at the
-- cost of a slight reduction in speed and the necessity of keeping
-- copies of the template files in a known place.
-- $Header: /dc/uc/self/arcadia/aflex/ada/src/RCS/template_managerB.a,v 1.21 1992/12/29 22:46:15 self Exp self $
-- 6-Aug-2008 GdM : Added Input_Line
-- 26-Dec-2006 GdM : Added Output_Column and Output_New_Line
with FILE_STRING, MISC_DEFS, Text_IO, EXTERNAL_FILE_MANAGER, MISC; use
FILE_STRING, MISC_DEFS, Text_IO;
package body TEMPLATE_MANAGER is
type FILE_ARRAY is array(POSITIVE range <>) of VSTRING;
DFA_TEMPLATE : constant FILE_ARRAY := (
--DFA TEMPLATE START
VSTR(" -- Warning: This file is automatically generated by AFLEX."),
VSTR(" -- It is useless to modify it. Change the "".Y"" & "".L"" files instead."),
VSTR(""),
VSTR(" yytext_ptr : integer; -- points to start of yytext in buffer"),
VSTR(""),
VSTR(" -- yy_ch_buf has to be 2 characters longer than YY_BUF_SIZE because we need"),
VSTR(" -- to put in 2 end-of-buffer characters (this is explained where it is"),
VSTR(" -- done) at the end of yy_ch_buf"),
VSTR(""),
VSTR(" -- ----------------------------------------------------------------------------"),
VSTR(" -- If the buffer size variable YY_READ_BUF_SIZE is too small, then"),
VSTR(" -- big comments won't be parsed and the parser stops."),
VSTR(" -- YY_READ_BUF_SIZE should be at least as large as the number of ASCII bytes in"),
VSTR(" -- comments that need to be parsed."),
VSTR(""),
VSTR(" YY_READ_BUF_SIZE : constant integer := 75_000;"),
VSTR(" -- ----------------------------------------------------------------------------"),
VSTR(""),
VSTR(" YY_BUF_SIZE : constant integer := YY_READ_BUF_SIZE * 2; -- size of input buffer"),
VSTR(" type unbounded_character_array is array(integer range <>) of character;"),
VSTR(" subtype ch_buf_type is unbounded_character_array(0..YY_BUF_SIZE + 1);"),
VSTR(" yy_ch_buf : ch_buf_type;"), VSTR("yy_cp, yy_bp : integer;"),
VSTR(""),
VSTR(" -- yy_hold_char holds the character lost when yytext is formed"),
VSTR(" yy_hold_char : character;"),
VSTR(" yy_c_buf_p : integer; -- points to current character in buffer"),
VSTR(""),
VSTR(" function YYText return string;"),
VSTR(" function YYLength return integer;"),
VSTR(" procedure YY_DO_BEFORE_ACTION;"),
VSTR(" --These variables are needed between calls to YYLex."),
VSTR(" yy_init : boolean := true; -- do we need to initialize YYLex?"),
VSTR(" yy_start : integer := 0; -- current start state number"),
VSTR(" subtype yy_state_type is integer;"),
VSTR(" yy_last_accepting_state : yy_state_type;"),
VSTR(" yy_last_accepting_cpos : integer;"),
VSTR("%%"),
-- Package Body:
VSTR(" -- Warning: This file is automatically generated by AFLEX."),
VSTR(" -- It is useless to modify it. Change the "".Y"" & "".L"" files instead."),
VSTR(""),
VSTR(" -- Nov 2002. Fixed insufficient buffer size bug causing"),
VSTR(" -- damage to comments at about the 1000-th character"),
VSTR(""),
VSTR(" function YYText return String is"),
VSTR(" J : Integer := yytext_ptr;"),
VSTR(" begin"),
VSTR(" while J <= yy_ch_buf'Last and then yy_ch_buf (J) /= ASCII.NUL loop"),
VSTR(" J := J + 1;"),
VSTR(" end loop;"),
VSTR(""),
VSTR(" declare"),
VSTR(" subtype Sliding_Type is String (1 .. J - yytext_ptr);"),
VSTR(" begin"),
VSTR(" return Sliding_Type (yy_ch_buf (yytext_ptr .. J - 1));"),
VSTR(" end;"),
VSTR(" end YYText;"),
VSTR(""),
VSTR(" -- Returns the length of the matched text"),
VSTR(""),
VSTR(" function YYLength return Integer is"),
VSTR(" begin"),
VSTR(" return yy_cp - yy_bp;"),
VSTR(" end YYLength;"),
VSTR(""),
VSTR(" -- Done after the current pattern has been matched and before the"),
VSTR(" -- corresponding action - sets up yytext"),
VSTR(""),
VSTR(" procedure YY_DO_BEFORE_ACTION is"),
VSTR(" begin"),
VSTR(" yytext_ptr := yy_bp;"),
VSTR(" yy_hold_char := yy_ch_buf (yy_cp);"),
VSTR(" yy_ch_buf (yy_cp) := ASCII.NUL;"),
VSTR(" yy_c_buf_p := yy_cp;"),
VSTR(" end YY_DO_BEFORE_ACTION;"),
VSTR("")
--DFA TEMPLATE END
);
-- VSTR("function YYText return string is"),
-- VSTR(" i : Integer;"),
-- VSTR(" str_loc : Integer := 1;"),
-- VSTR(" buffer : String (1..1024);"),
-- VSTR(" EMPTY_STRING : constant String := """";"),
-- VSTR("begin"),
-- VSTR(" -- find end of buffer"),
-- VSTR(" i := yytext_ptr;"),
-- VSTR(" while yy_ch_buf (i) /= ASCII.NUL loop"),
-- VSTR(" buffer (str_loc) := yy_ch_buf (i);"),
-- VSTR(" i := i + 1;"),
-- VSTR(" str_loc := str_loc + 1;"),
-- VSTR(" end loop;"),
-- VSTR("-- return yy_ch_buf(yytext_ptr.. i - 1);"),
-- VSTR(""),
-- VSTR(" if str_loc < 2 then"),
-- VSTR(" return EMPTY_STRING;"),
-- VSTR(" else"),
-- VSTR(" return buffer (1 .. str_loc - 1);"),
-- VSTR(" end if;"),
DFA_CURRENT_LINE : INTEGER := 1;
IO_TEMPLATE : constant FILE_ARRAY := (
--IO TEMPLATE START
VSTR("-- Warning: This file is automatically generated by AFLEX."),
VSTR("-- It is useless to modify it. Change the "".Y"" & "".L"" files instead."),
VSTR(""),
VSTR("with Text_IO; use Text_IO;"),
VSTR(""),
VSTR("%%"),
VSTR(" -- Warning: This file is automatically generated by AFLEX."),
VSTR(" -- It is useless to modify it. Change the "".Y"" & "".L"" files instead."),
VSTR(""),
VSTR(" user_input_file : file_type;"),
VSTR(" user_output_file : file_type;"),
VSTR(" NULL_IN_INPUT : exception;"),
VSTR(" AFLEX_INTERNAL_ERROR : exception;"),
VSTR(" UNEXPECTED_LAST_MATCH : exception;"),
VSTR(" PUSHBACK_OVERFLOW : exception;"),
VSTR(" AFLEX_SCANNER_JAMMED : exception;"),
VSTR(" type eob_action_type is ( EOB_ACT_RESTART_SCAN,"),
VSTR(" EOB_ACT_END_OF_FILE,"),
VSTR(" EOB_ACT_LAST_MATCH );"),
VSTR(" YY_END_OF_BUFFER_CHAR : constant character:= ASCII.NUL;"),
VSTR(" yy_n_chars : integer; -- number of characters read into yy_ch_buf"),
VSTR(""),
VSTR(" -- true when we've seen an EOF for the current input file"),
VSTR(" yy_eof_has_been_seen : boolean;"), VSTR(""),
VSTR("-- UMASS CODES :" ),
VSTR(" -- In order to support YY_Get_Token_Line, we need"),
VSTR(" -- a variable to hold current line."),
VSTR(" type String_Ptr is access string;"),
VSTR(" Saved_Tok_Line1 : String_Ptr := Null;"),
VSTR(" Line_Number_Of_Saved_Tok_Line1 : integer := 0;"),
VSTR(" Saved_Tok_Line2 : String_Ptr := Null;"),
VSTR(" Line_Number_Of_Saved_Tok_Line2 : integer := 0;"),
VSTR(" -- Aflex will try to get next buffer before it processs the"),
VSTR(" -- last token. Since now Aflex has been changed to accept"),
VSTR(" -- one line by one line, the last token in the buffer is"),
VSTR(" -- always end_of_line ( or end_of_buffer ). So before the"),
VSTR(" -- end_of_line is processed, next line will be retrieved"),
VSTR(" -- into the buffer. So we need to maintain two lines,"),
VSTR(" -- which line will be returned in Get_Token_Line is"),
VSTR(" -- determined according to the line number. It is the same"),
VSTR(" -- reason that we can not reinitialize tok_end_col to 0 in"),
VSTR(" -- Yy_Input, but we must do it in yylex after we process the"),
VSTR(" -- end_of_line."),
VSTR(" Tok_Begin_Line : integer := 1;"),
VSTR(" Tok_End_Line : integer := 1;"),
VSTR(" Tok_End_Col : integer := 0;"),
VSTR(" Tok_Begin_Col : integer := 0;"),
VSTR(" Token_At_End_Of_Line : Boolean := False;"),
VSTR(" -- Indicates whether or not last matched token is end_of_line."),
VSTR("-- END OF UMASS CODES."),
VSTR(""),
VSTR(" procedure YY_INPUT (buf: out unbounded_character_array; result: out integer; max_size: in integer);"),
VSTR(" function yy_get_next_buffer return eob_action_type;"),
VSTR(" procedure yyUnput ( c : Character; yy_bp: in out Integer );"),
VSTR(" procedure Unput (c : Character);"),
VSTR(" function Input return Character;"),
VSTR(" procedure Output (c : Character);"),
VSTR(" procedure Output_New_Line;"),
VSTR(" function Output_Column return Text_IO.Count;"),
VSTR(" function Input_Line return Text_IO.Count;"),
VSTR(" function yyWrap return Boolean;"),
VSTR(" procedure Open_Input (fname : in String);"),
VSTR(" procedure Close_Input;"),
VSTR(" procedure Create_Output (fname : in String := """");"),
VSTR(" procedure Close_Output;"),
VSTR(""),
VSTR("-- UMASS CODES :"),
VSTR(" procedure Yy_Get_Token_Line ( Yy_Line_String : out String;"),
VSTR(" Yy_Line_Length : out Natural );"),
VSTR(" -- Returnes the entire line in the input, on which the currently"),
VSTR(" -- matched token resides."),
VSTR(""),
VSTR(" function Yy_Line_Number return Natural;"),
VSTR(" -- Returns the line number of the currently matched token."),
VSTR(" -- In case a token spans lines, then the line number of the first line"),
VSTR(" -- is returned."),
VSTR(""),
VSTR(" function Yy_Begin_Column return Natural;"),
VSTR(" function Yy_End_Column return Natural;"),
VSTR(" -- Returns the beginning and ending column positions of the"),
VSTR(" -- currently mathched token. If the token spans lines then the"),
VSTR(" -- begin column number is the column number on the first line"),
VSTR(" -- and the end columne number is the column number on the last line."),
VSTR(""),
VSTR("-- END OF UMASS CODES."),
VSTR(""),
VSTR("%%"),
VSTR(" -- Warning: This file is automatically generated by AFLEX."),
VSTR(" -- It is useless to modify it. Change the "".Y"" & "".L"" files instead."),
VSTR(""),
VSTR(" -- gets input and stuffs it into 'buf'. number of characters read, or YY_NULL,"),
VSTR(" -- is returned in 'result'."),
VSTR(""),
VSTR(" procedure YY_INPUT (buf: out unbounded_character_array; result: out Integer; max_size: in Integer) is"),
VSTR(" c : Character;"),
VSTR(" i : Integer := 1;"),
VSTR(" loc : Integer := buf'first;"),
VSTR("-- UMASS CODES :"),
VSTR(" -- Since buf is an out parameter which is not readable"),
VSTR(" -- and saved lines is a string pointer which space must"),
VSTR(" -- be allocated after we know the size, we maintain"),
VSTR(" -- an extra buffer to collect the input line and"),
VSTR(" -- save it into the saved line 2."),
VSTR(" Temp_Line : String ( 1 .. YY_BUF_SIZE + 2 );"),
VSTR("-- END OF UMASS CODES."),
VSTR(" begin"),
VSTR("-- UMASS CODES :"),
VSTR(" -- buf := ( others => ASCII.NUL ); -- CvdL: does not work in GNAT"),
VSTR(" for j in buf'first .. buf'last loop"),
VSTR(" buf (j) := ASCII.NUL;"),
VSTR(" end loop;"),
VSTR(" -- Move the saved lines forward."),
VSTR(" Saved_Tok_Line1 := Saved_Tok_Line2;"),
VSTR(" Line_Number_Of_Saved_Tok_Line1 := Line_Number_Of_Saved_Tok_Line2;"),
VSTR("-- END OF UMASS CODES."),
VSTR(""),
VSTR(" if is_open (user_input_file) then"),
VSTR(" while i <= max_size loop"),
VSTR(" if end_of_line (user_input_file) then -- Ada ate our newline, put it back on the end."),
VSTR(" buf(loc) := ASCII.LF;"),
VSTR(" skip_line (user_input_file, 1);"),
VSTR("-- UMASS CODES :"),
VSTR(" -- We try to get one line by one line. So we return"),
VSTR(" -- here because we saw the end_of_line."),
VSTR(" result := i;"),
VSTR(" Temp_Line (i) := ASCII.LF;"),
VSTR(" Saved_Tok_Line2 := new String ( 1 .. i );"),
VSTR(" Saved_Tok_Line2 ( 1 .. i ) := Temp_Line ( 1 .. i );"),
VSTR(" Line_Number_Of_Saved_Tok_Line2 := Line_Number_Of_Saved_Tok_Line1 + 1;"),
VSTR(" return;"),
VSTR("-- END OF UMASS CODES."),
VSTR(" else"),
VSTR(" -- UCI CODES CHANGED:"),
VSTR("-- The following codes are modified. Previous codes is commented out."),
VSTR("-- The purpose of doing this is to make it possible to set Temp_Line"),
VSTR("-- in Ayacc-extension specific codes. Definitely, we can read the character"),
VSTR("-- into the Temp_Line and then set the buf. But Temp_Line will only"),
VSTR("-- be used in Ayacc-extension specific codes which makes this approach impossible."),
VSTR(" get (user_input_file, c);"),
VSTR(" buf (loc) := c;"),
VSTR("-- get (user_input_file, buf (loc));"),
VSTR("-- UMASS CODES :"),
VSTR(" Temp_Line (i) := c;"),
VSTR("-- END OF UMASS CODES."),
VSTR(" end if;"),
VSTR(""),
VSTR(" loc := loc + 1;"),
VSTR(" i := i + 1;"),
VSTR(" end loop;"),
VSTR(" else"),
VSTR(" while i <= max_size loop"),
VSTR(" if end_of_line then -- Ada ate our newline, put it back on the end."),
VSTR(" buf (loc) := ASCII.LF;"),
VSTR(" skip_line (1);"),
VSTR("-- UMASS CODES :"),
VSTR("-- We try to get one line by one line. So we return"),
VSTR("-- here because we saw the end_of_line."),
VSTR(" result := i;"),
VSTR(" Temp_Line (i) := ASCII.LF;"),
VSTR(" Saved_Tok_Line2 := new String ( 1 .. i );"),
VSTR(" Saved_Tok_Line2 ( 1 .. i ) := Temp_Line ( 1 .. i );"),
VSTR(" Line_Number_Of_Saved_Tok_Line2 := Line_Number_Of_Saved_Tok_Line1 + 1;"),
VSTR(" return;"),
VSTR("-- END OF UMASS CODES."),
VSTR("%%"),
VSTR(" -- Warning: This file is automatically generated by AFLEX."),
VSTR(" -- It is useless to modify it. Change the "".Y"" & "".L"" files instead."),
VSTR(""),
VSTR(" else"),
VSTR(" -- The following codes are modified. Previous codes is commented out."),
VSTR(" -- The purpose of doing this is to make it possible to set Temp_Line"),
VSTR(" -- in Ayacc-extension specific codes. Definitely, we can read the character"),
VSTR(" -- into the Temp_Line and then set the buf. But Temp_Line will only"),
VSTR(" -- be used in Ayacc-extension specific codes which makes this approach impossible."),
VSTR(" get (c);"),
VSTR(" buf (loc) := c;"),
VSTR("-- get (buf (loc));"),
VSTR("-- UMASS CODES :"),
VSTR(" Temp_Line (i) := c;"),
VSTR("-- END OF UMASS CODES."),
VSTR(" end if; "),
VSTR(""),
VSTR(" loc := loc + 1;"),
VSTR(" i := i + 1;"),
VSTR(" end loop;"),
VSTR(" end if; -- for input file being standard input"),
VSTR(""),
VSTR(" result := i - 1; "),
VSTR("-- UMASS CODES :"),
VSTR(" -- Since we get one line by one line, if we"),
VSTR(" -- reach here, it means that current line have"),
VSTR(" -- more that max_size characters. So it is"),
VSTR(" -- impossible to hold the whole line. We"),
VSTR(" -- report the warning message and continue."),
VSTR(" buf (loc - 1) := Ascii.LF;"),
VSTR(" if is_open (user_input_file) then"),
VSTR(" skip_line (user_input_file, 1);"),
VSTR(" else"),
VSTR(" skip_line (1);"),
VSTR(" end if;"),
VSTR(" Temp_Line (i - 1) := ASCII.LF;"),
VSTR(" Saved_Tok_Line2 := new String ( 1 .. i - 1);"),
VSTR(" Saved_Tok_Line2 ( 1 .. i - 1 ) := Temp_Line ( 1 .. i - 1 );"),
VSTR(" Line_Number_Of_Saved_Tok_Line2 := Line_Number_Of_Saved_Tok_Line1 + 1;"),
VSTR(" Put_Line ( ""Input line """),
VSTR(" & Integer'Image ( Line_Number_Of_Saved_Tok_Line2 )"),
VSTR(" & ""has more than """),
VSTR(" & Integer'Image ( max_size )"),
VSTR(" & "" characters, ... truncated."" );"),
VSTR("-- END OF UMASS CODES."),
VSTR(" exception"),
VSTR(" when END_ERROR => result := i - 1;"),
VSTR(" -- when we hit EOF we need to set yy_eof_has_been_seen"),
VSTR(" yy_eof_has_been_seen := true;"),
VSTR("-- UMASS CODES :"),
VSTR("-- Processing incomplete line."),
VSTR(" if i /= 1 then"),
VSTR(" -- Current line is not empty but do not have end_of_line."),
VSTR(" -- So current line is incomplete line. But we still need"),
VSTR(" -- to save it."),
VSTR(" Saved_Tok_Line2 := new String ( 1 .. i - 1 );"),
VSTR(" Saved_Tok_Line2 ( 1 .. i - 1 ) := Temp_Line ( 1 .. i - 1 );"),
VSTR(" Line_Number_Of_Saved_Tok_Line2 := Line_Number_Of_Saved_Tok_Line1 + 1;"),
VSTR(" end if;"),
VSTR("-- END OF UMASS CODES."),
VSTR("end YY_INPUT;"),
VSTR(""),
VSTR("-- yy_get_next_buffer - try to read in new buffer"),
VSTR("--"),
VSTR("-- returns a code representing an action"),
VSTR("-- EOB_ACT_LAST_MATCH - "),
VSTR("-- EOB_ACT_RESTART_SCAN - restart the scanner"),
VSTR("-- EOB_ACT_END_OF_FILE - end of file"),
VSTR(""),
VSTR(" function yy_get_next_buffer return eob_action_type is"),
VSTR(" dest : Integer := 0;"),
VSTR(" source : Integer := yytext_ptr - 1; -- copy prev. char, too"),
VSTR(" number_to_move : Integer;"),
VSTR(" ret_val : eob_action_type;"),
VSTR(" num_to_read : Integer;"),
VSTR(" begin "),
VSTR(" if yy_c_buf_p > yy_n_chars + 1 then"),
VSTR(" raise NULL_IN_INPUT;"),
VSTR(" end if;"),
VSTR(""),
VSTR(" -- try to read more data"),
VSTR(""),
VSTR(" -- first move last chars to start of buffer"),
VSTR(" number_to_move := yy_c_buf_p - yytext_ptr;"),
VSTR(""),
VSTR(" for i in 0 .. number_to_move - 1 loop"),
VSTR(" yy_ch_buf (dest) := yy_ch_buf (source);"),
VSTR(" dest := dest + 1;"),
VSTR(" source := source + 1;"),
VSTR(" end loop;"),
VSTR(""),
VSTR(" if yy_eof_has_been_seen then"),
VSTR(" -- don't do the read, it's not guaranteed to return an EOF,"),
VSTR(" -- just force an EOF"),
VSTR(""),
VSTR(" yy_n_chars := 0;"),
VSTR(" else"),
VSTR(" num_to_read := YY_BUF_SIZE - number_to_move - 1;"),
VSTR(""),
VSTR(" if num_to_read > YY_READ_BUF_SIZE then"),
VSTR(" num_to_read := YY_READ_BUF_SIZE;"),
VSTR(" end if;"),
VSTR(""),
VSTR(" -- read in more data"),
VSTR(" YY_INPUT (yy_ch_buf (number_to_move .. yy_ch_buf'last), yy_n_chars, num_to_read);"),
VSTR(" end if;"),
VSTR(" if yy_n_chars = 0 then"),
VSTR(" if number_to_move = 1 then"),
VSTR(" ret_val := EOB_ACT_END_OF_FILE;"),
VSTR(" else"),
VSTR(" ret_val := EOB_ACT_LAST_MATCH;"),
VSTR(" end if;"),
VSTR(""),
VSTR(" yy_eof_has_been_seen := true;"),
VSTR(" else"),
VSTR(" ret_val := EOB_ACT_RESTART_SCAN;"),
VSTR(" end if;"),
VSTR(" "),
VSTR(" yy_n_chars := yy_n_chars + number_to_move;"),
VSTR(" yy_ch_buf (yy_n_chars) := YY_END_OF_BUFFER_CHAR;"),
VSTR(" yy_ch_buf (yy_n_chars + 1) := YY_END_OF_BUFFER_CHAR;"),
VSTR(""),
VSTR(" -- yytext begins at the second character in"),
VSTR(" -- yy_ch_buf; the first character is the one which"),
VSTR(" -- preceded it before reading in the latest buffer;"),
VSTR(" -- it needs to be kept around in case it's a"),
VSTR(" -- newline, so yy_get_previous_state() will have"),
VSTR(" -- with '^' rules active"),
VSTR(""),
VSTR(" yytext_ptr := 1;"),
VSTR(""),
VSTR(" return ret_val;"),
VSTR(" end yy_get_next_buffer;"),
VSTR(""),
VSTR(" procedure yyunput (c : Character; yy_bp: in out Integer) is"),
VSTR(" number_to_move : Integer;"),
VSTR(" dest : Integer;"),
VSTR(" source : Integer;"),
VSTR(" tmp_yy_cp : Integer;"),
VSTR(" begin"),
VSTR(" tmp_yy_cp := yy_c_buf_p;"),
VSTR(" yy_ch_buf (tmp_yy_cp) := yy_hold_char; -- undo effects of setting up yytext"),
VSTR(""),
VSTR(" if tmp_yy_cp < 2 then"),
VSTR(" -- need to shift things up to make room"),
VSTR(" number_to_move := yy_n_chars + 2; -- +2 for EOB chars"),
VSTR(" dest := YY_BUF_SIZE + 2;"),
VSTR(" source := number_to_move;"),
VSTR(""),
VSTR(" while source > 0 loop"),
VSTR(" dest := dest - 1;"),
VSTR(" source := source - 1;"),
VSTR(" yy_ch_buf (dest) := yy_ch_buf (source);"),
VSTR(" end loop;"),
VSTR(""),
VSTR(" tmp_yy_cp := tmp_yy_cp + dest - source;"),
VSTR(" yy_bp := yy_bp + dest - source;"),
VSTR(" yy_n_chars := YY_BUF_SIZE;"),
VSTR(""),
VSTR(" if tmp_yy_cp < 2 then"),
VSTR(" raise PUSHBACK_OVERFLOW;"),
VSTR(" end if;"),
VSTR(" end if;"),
VSTR(""),
VSTR(" if tmp_yy_cp > yy_bp and then yy_ch_buf (tmp_yy_cp-1) = ASCII.LF then"),
VSTR(" yy_ch_buf (tmp_yy_cp-2) := ASCII.LF;"),
VSTR(" end if;"),
VSTR(""),
VSTR(" tmp_yy_cp := tmp_yy_cp - 1;"),
VSTR(" yy_ch_buf (tmp_yy_cp) := c;"),
VSTR(""),
VSTR(" -- Note: this code is the text of YY_DO_BEFORE_ACTION, only"),
VSTR(" -- here we get different yy_cp and yy_bp's"),
VSTR(" yytext_ptr := yy_bp;"),
VSTR(" yy_hold_char := yy_ch_buf (tmp_yy_cp);"),
VSTR(" yy_ch_buf (tmp_yy_cp) := ASCII.NUL;"),
VSTR(" yy_c_buf_p := tmp_yy_cp;"),
VSTR(" end yyunput;"),
VSTR(""),
VSTR(" procedure Unput(c : Character) is"),
VSTR(" begin"),
VSTR(" yyunput (c, yy_bp);"),
VSTR(" end Unput;"),
VSTR(""),
VSTR(" function Input return Character is"),
VSTR(" c : Character;"),
VSTR(" begin"),
VSTR(" yy_ch_buf (yy_c_buf_p) := yy_hold_char;"),
VSTR(""),
VSTR(" if yy_ch_buf (yy_c_buf_p) = YY_END_OF_BUFFER_CHAR then"),
VSTR(" -- need more input"),
VSTR(" yytext_ptr := yy_c_buf_p;"),
VSTR(" yy_c_buf_p := yy_c_buf_p + 1;"),
VSTR(""),
VSTR(" case yy_get_next_buffer is"),
VSTR(" -- this code, unfortunately, is somewhat redundant with"),
VSTR(" -- that above"),
VSTR(""),
VSTR(" when EOB_ACT_END_OF_FILE =>"),
VSTR(" if yywrap then"),
VSTR(" yy_c_buf_p := yytext_ptr;"),
VSTR(" return ASCII.NUL;"),
VSTR(" end if;"),
VSTR(""),
VSTR(" yy_ch_buf (0) := ASCII.LF;"),
VSTR(" yy_n_chars := 1;"),
VSTR(" yy_ch_buf (yy_n_chars) := YY_END_OF_BUFFER_CHAR;"),
VSTR(" yy_ch_buf (yy_n_chars + 1) := YY_END_OF_BUFFER_CHAR;"),
VSTR(" yy_eof_has_been_seen := false;"),
VSTR(" yy_c_buf_p := 1;"),
VSTR(" yytext_ptr := yy_c_buf_p;"),
VSTR(" yy_hold_char := yy_ch_buf (yy_c_buf_p);"),
VSTR(""),
VSTR(" return ( Input );"),
VSTR(" when EOB_ACT_RESTART_SCAN =>"),
VSTR(" yy_c_buf_p := yytext_ptr;"),
VSTR(""),
VSTR(" when EOB_ACT_LAST_MATCH =>"),
VSTR(" raise UNEXPECTED_LAST_MATCH;"),
VSTR(" end case;"),
VSTR(" end if;"),
VSTR(""),
VSTR(" c := yy_ch_buf (yy_c_buf_p);"),
VSTR(" yy_c_buf_p := yy_c_buf_p + 1;"),
VSTR(" yy_hold_char := yy_ch_buf (yy_c_buf_p);"),
VSTR(""),
VSTR(" return c;"),
VSTR(" end Input;"),
VSTR(""),
VSTR(" procedure Output(c : Character) is"),
VSTR(" begin"),
VSTR(" if Is_Open (user_output_file) then"),
VSTR(" Text_IO.Put (user_output_file, c);"),
VSTR(" else"),
VSTR(" Text_IO.Put (c);"),
VSTR(" end if;"),
VSTR(" end Output;"),
VSTR(""),
VSTR(" procedure Output_New_Line is"),
VSTR(" begin"),
VSTR(" if Is_Open (user_output_file) then"),
VSTR(" Text_IO.New_Line (user_output_file);"),
VSTR(" else"),
VSTR(" Text_IO.New_Line;"),
VSTR(" end if;"),
VSTR(" end Output_New_Line;"),
VSTR(""),
VSTR(" function Output_Column return Text_IO.Count is"),
VSTR(" begin"),
VSTR(" if Is_Open (user_output_file) then"),
VSTR(" return Text_IO.Col (user_output_file);"),
VSTR(" else"),
VSTR(" return Text_IO.Col;"),
VSTR(" end if;"),
VSTR(" end Output_Column;"),
VSTR(""),
VSTR(" function Input_Line return Text_IO.Count is"),
VSTR(" l: Text_IO.Count:= 1;"),
VSTR(" begin"),
VSTR("-- UMASS CODES :"),
VSTR(" l:= Text_IO.Count(Line_Number_Of_Saved_Tok_Line2);"), -- Tok_Begin_Line is fuzzy
VSTR("-- END OF UMASS CODES."),
VSTR(" return l; -- from file, always 1"),
VSTR(" -- if is_open(user_input_file) then"),
VSTR(" -- return Text_IO.Line(user_input_file);"),
VSTR(" -- else"),
VSTR(" -- return Text_IO.Line;"),
VSTR(" -- end if;"),
VSTR(" end Input_Line;"),
VSTR(""),
VSTR(" -- default yywrap function - always treat EOF as an EOF"),
VSTR(" function yywrap return boolean is"),
VSTR(" begin"),
VSTR(" return true;"),
VSTR(" end yywrap;"),
VSTR(""),
VSTR(" procedure Open_Input (fname : in String) is"),
VSTR(" begin"),
VSTR(" yy_init := true;"),
VSTR(" Open (user_input_file, in_file, fname);"),
VSTR(" end Open_Input;"),
VSTR(""),
VSTR(" procedure Create_Output (fname : in String := """") is"),
VSTR(" begin"),
VSTR(" if fname /= """" then"),
VSTR(" Create (user_output_file, out_file, fname);"),
VSTR(" end if;"),
VSTR(" end Create_Output;"),
VSTR(""),
VSTR(" procedure Close_Input is"),
VSTR(" begin"),
VSTR(" if Is_Open (user_input_file) then"),
VSTR(" Text_IO.Close (user_input_file);"),
VSTR(" end if;"),
VSTR(" end Close_Input;"),
VSTR(""),
VSTR(" procedure Close_Output is"),
VSTR(" begin"),
VSTR(" if Is_Open (user_output_file) then"),
VSTR(" Text_IO.Close (user_output_file);"),
VSTR(" end if;"),
VSTR(" end Close_Output;"),
VSTR(""),
VSTR("-- UMASS CODES :"),
VSTR(" procedure Yy_Get_Token_Line ( Yy_Line_String : out String;"),
VSTR(" Yy_Line_Length : out Natural ) is"),
VSTR(" begin"),
VSTR(" -- Currently processing line is either in saved token line1 or"),
VSTR(" -- in saved token line2."),
VSTR(" if Yy_Line_Number = Line_Number_Of_Saved_Tok_Line1 then"),
VSTR(" Yy_Line_Length := Saved_Tok_Line1.all'length;"),
VSTR(" Yy_Line_String ( Yy_Line_String'First .. ( Yy_Line_String'First + Saved_Tok_Line1.all'length - 1 ))"),
VSTR(" := Saved_Tok_Line1 ( 1 .. Saved_Tok_Line1.all'length );"),
VSTR(" else"),
VSTR(" Yy_Line_Length := Saved_Tok_Line2.all'length;"),
VSTR(" Yy_Line_String ( Yy_Line_String'First .. ( Yy_Line_String'First + Saved_Tok_Line2.all'length - 1 ))"),
VSTR(" := Saved_Tok_Line2 ( 1 .. Saved_Tok_Line2.all'length );"),
VSTR(" end if;"),
VSTR(" end Yy_Get_Token_Line;"),
VSTR(""),
VSTR(" function Yy_Line_Number return Natural is"),
VSTR(" begin"),
VSTR(" return Tok_Begin_Line;"),
VSTR(" end Yy_Line_Number;"),
VSTR(""),
VSTR(" function Yy_Begin_Column return Natural is"),
VSTR(" begin"),
VSTR(" return Tok_Begin_Col;"),
VSTR(" end Yy_Begin_Column;"),
VSTR(""),
VSTR(" function Yy_End_Column return Natural is"),
VSTR(" begin"),
VSTR(" return Tok_End_Col;"),
VSTR(" end Yy_End_Column;"),
VSTR(""),
VSTR("-- END OF UMASS CODES."),
VSTR("")
--IO TEMPLATE END
);
IO_CURRENT_LINE : INTEGER := 1;
procedure TEMPLATE_OUT(OUTFILE : in FILE_TYPE;
CURRENT_TEMPLATE : in FILE_ARRAY;
LINE_NUMBER : in out INTEGER) is
BUF : VSTRING;
-- UMASS CODES :
Umass_Codes : Boolean := False;
-- Indicates whether or not current line of the template
-- is the Umass codes.
-- END OF UMASS CODES.
begin
while not (LINE_NUMBER > CURRENT_TEMPLATE'LAST) loop
BUF := CURRENT_TEMPLATE(LINE_NUMBER);
LINE_NUMBER := LINE_NUMBER + 1;
if ((FILE_STRING.LEN(BUF) >= 2) and then ((CHAR(BUF, 1) = '%') and (CHAR(
BUF, 2) = '%'))) then
exit;
else
-- UMASS CODES :
-- In the template, the codes between "-- UMASS CODES : " and
-- "-- END OF UMASS CODES." are specific to be used by Ayacc-extension.
-- Ayacc-extension has more power in error recovery. So we
-- generate those codes only when Ayacc_Extension_Flag is True.
if FILE_STRING.STR(BUF) = "-- UMASS CODES :" then
Umass_Codes := True;
end if;
if not Umass_Codes or else
Ayacc_Extension_Flag then
FILE_STRING.PUT_LINE(OUTFILE,BUF);
end if;
if FILE_STRING.STR(BUF) = "-- END OF UMASS CODES." then
Umass_Codes := False;
end if;
-- END OF UMASS CODES.
-- UCI CODES commented out :
-- The following line is commented out because it is done in Umass codes.
-- FILE_STRING.PUT_LINE(OUTFILE,BUF);
end if;
end loop;
end TEMPLATE_OUT;
procedure GENERATE_DFA_FILE is
DFA_OUT_FILE : FILE_TYPE;
begin
EXTERNAL_FILE_MANAGER.GET_DFA_FILE(DFA_OUT_FILE, True);
Text_IO.PUT_LINE(DFA_OUT_FILE, "pragma Style_Checks (Off);");
Text_IO.PUT_LINE(DFA_OUT_FILE, "package " & MISC.PACKAGE_NAME &
"_dfa is");
if DDEBUG then
-- make a scanner that output acceptance information
Text_IO.PUT_LINE(DFA_OUT_FILE, "aflex_debug : boolean := true;");
else
Text_IO.PUT_LINE(DFA_OUT_FILE, "aflex_debug : boolean := false;");
end if;
TEMPLATE_OUT(DFA_OUT_FILE, DFA_TEMPLATE, DFA_CURRENT_LINE);
Text_IO.PUT_LINE(DFA_OUT_FILE, "end " & MISC.PACKAGE_NAME & "_dfa;"
);
Text_IO.Close(DFA_OUT_FILE);
EXTERNAL_FILE_MANAGER.GET_DFA_FILE(DFA_OUT_FILE, False);
Text_IO.NEW_LINE(DFA_OUT_FILE);
Text_IO.PUT_LINE(DFA_OUT_FILE, "pragma Style_Checks (Off);");
Text_IO.PUT(DFA_OUT_FILE, "with " & MISC.PACKAGE_NAME & "_dfa" &
"; ");
Text_IO.PUT_LINE(DFA_OUT_FILE, "use " & MISC.PACKAGE_NAME & "_dfa; ");
Text_IO.PUT_LINE(DFA_OUT_FILE, "package body " & MISC.PACKAGE_NAME
& "_dfa is");
TEMPLATE_OUT(DFA_OUT_FILE, DFA_TEMPLATE, DFA_CURRENT_LINE);
Text_IO.PUT_LINE(DFA_OUT_FILE, "end " & MISC.PACKAGE_NAME & "_dfa;"
);
end GENERATE_DFA_FILE;
procedure GENERATE_IO_FILE is
IO_OUT_FILE : FILE_TYPE;
begin
EXTERNAL_FILE_MANAGER.GET_IO_FILE(IO_OUT_FILE, True);
Text_IO.PUT_LINE(IO_OUT_FILE, "pragma Style_Checks (Off);");
Text_IO.PUT(IO_OUT_FILE, "with " & MISC.PACKAGE_NAME & "_dfa; ");
Text_IO.PUT_LINE(IO_OUT_FILE, "use " & MISC.PACKAGE_NAME & "_dfa; ");
TEMPLATE_OUT(IO_OUT_FILE, IO_TEMPLATE, IO_CURRENT_LINE);
Text_IO.PUT_LINE(IO_OUT_FILE, "package " & MISC.PACKAGE_NAME &
"_io is");
TEMPLATE_OUT(IO_OUT_FILE, IO_TEMPLATE, IO_CURRENT_LINE);
Text_IO.PUT_LINE(IO_OUT_FILE, "end " & MISC.PACKAGE_NAME & "_io;")
;
Text_IO.Close(IO_OUT_FILE);
EXTERNAL_FILE_MANAGER.GET_IO_FILE(IO_OUT_FILE, False);
Text_IO.NEW_LINE(IO_OUT_FILE);
Text_IO.PUT_LINE(IO_OUT_FILE, "pragma Style_Checks (Off);");
Text_IO.PUT_LINE(IO_OUT_FILE, "package body " & MISC.PACKAGE_NAME
& "_io is");
TEMPLATE_OUT(IO_OUT_FILE, IO_TEMPLATE, IO_CURRENT_LINE);
-- If we're generating a scanner for interactive mode we need to generate
-- a YY_INPUT that stops at the end of each line
if INTERACTIVE then
Text_IO.PUT_LINE(IO_OUT_FILE,
" i := i + 1; -- update counter, miss end of loop");
Text_IO.PUT_LINE(IO_OUT_FILE,
" exit; -- in interactive mode return at end of line.");
end if;
TEMPLATE_OUT(IO_OUT_FILE, IO_TEMPLATE, IO_CURRENT_LINE);
Text_IO.PUT_LINE(IO_OUT_FILE, "end " & MISC.PACKAGE_NAME & "_io;")
;
end GENERATE_IO_FILE;
end TEMPLATE_MANAGER;
|
MinimSecure/unum-sdk | Ada | 1,882 | adb | -- Copyright 2005-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/>.
procedure P is
type Index is (One, Two, Three);
type Table is array (Integer range 1 .. 3) of Integer;
type ETable is array (Index) of Integer;
type RTable is array (Index range Two .. Three) of Integer;
type UTable is array (Positive range <>) of Integer;
type PTable is array (Index) of Boolean;
pragma Pack (PTable);
function Get_UTable (I : Integer) return UTable is
begin
return Utable'(1 => I, 2 => 2, 3 => 3);
end Get_UTable;
One_Two_Three : Table := (1, 2, 3);
E_One_Two_Three : ETable := (1, 2, 3);
R_Two_Three : RTable := (2, 3);
U_One_Two_Three : UTable := Get_UTable (1);
P_One_Two_Three : PTable := (False, True, True);
Few_Reps : UTable := (1, 2, 3, 3, 3, 3, 3, 4, 5);
Many_Reps : UTable := (1, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 4, 5);
Empty : array (1 .. 0) of Integer := (others => 0);
begin
One_Two_Three (1) := 4; -- START
E_One_Two_Three (One) := 4;
R_Two_Three (Two) := 4;
U_One_Two_Three (U_One_Two_Three'First) := 4;
P_One_Two_Three (One) := True;
Few_Reps (Few_Reps'First) := 2;
Many_Reps (Many_Reps'First) := 2;
Empty := (others => 1);
end P;
|
zhmu/ananas | Ada | 258 | ads | package interface5 is
type B is tagged null record;
type I is interface;
function F (Object : I) return access I is abstract;
type Child is new B and I with null record;
function F (Object : Child) return access Child;
end interface5;
|
stcarrez/ada-util | Ada | 1,706 | ads | -----------------------------------------------------------------------
-- Util.Beans.Objects.Discrete_Tests - Generic simple test for discrete object types
-- Copyright (C) 2009, 2010, 2011 Stephane Carrez
-- Written by Stephane Carrez ([email protected])
--
-- Licensed under the Apache License, Version 2.0 (the "License");
-- you may not use this file except in compliance with the License.
-- You may obtain a copy of the License at
--
-- http://www.apache.org/licenses/LICENSE-2.0
--
-- Unless required by applicable law or agreed to in writing, software
-- distributed under the License is distributed on an "AS IS" BASIS,
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-- See the License for the specific language governing permissions and
-- limitations under the License.
-----------------------------------------------------------------------
with Util.Tests;
generic
type Test_Type is private;
with function To_Type (Obj : Util.Beans.Objects.Object) return Test_Type is <>;
with function To_Object_Test (V : Test_Type) return Util.Beans.Objects.Object is <>;
with function "-" (Left, Right : Test_Type) return Test_Type is <>;
with function "+" (Left, Right : Test_Type) return Test_Type is <>;
with function "=" (Left, Right : Test_Type) return Boolean is <>;
with function Value (S : String) return Test_Type;
Test_Name : String;
Test_Values : String;
package Util.Beans.Objects.Discrete_Tests is
type Test is new Util.Tests.Test with record
I1 : Integer;
I2 : Integer;
end record;
procedure Add_Tests (Suite : in Util.Tests.Access_Test_Suite);
end Util.Beans.Objects.Discrete_Tests;
|
reznikmm/matreshka | Ada | 3,434 | 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$
------------------------------------------------------------------------------
package AMF.DC.Point_Collections is
pragma Preelaborate;
end AMF.DC.Point_Collections;
|
AdaCore/gpr | Ada | 9,024 | adb | --
-- Copyright (C) 2014-2022, AdaCore
-- SPDX-License-Identifier: Apache-2.0
--
with Ada.Command_Line;
with Ada.Environment_Variables;
with Ada.Exceptions; use Ada.Exceptions;
with Ada.Text_IO; use Ada.Text_IO;
with Ada.Unchecked_Deallocation;
with Gpr_Parser_Support.Images;
with Gpr_Parser_Support.Vectors;
package body Gpr_Parser_Support.Adalog.Generic_Main_Support is
procedure Free is new Ada.Unchecked_Deallocation
(Logic_Var_Record, Refs.Logic_Var);
-- The following booleans determine which solver configurations to run in
-- tests. The ``Setup_Traces`` procedure initializes them with default
-- values, possibly modified depending on environment variables, for
-- convenience when debugging tests.
Run_Sym_Without_Opts : Boolean;
Run_Sym_With_Opts : Boolean;
------------
-- Create --
------------
function Create (Name : String) return Refs.Logic_Var is
begin
return R : constant Refs.Logic_Var := new Logic_Var_Record do
Reset (R);
R.Dbg_Name := new String'(Name);
Variables.Append (R);
end return;
end Create;
---------
-- "+" --
---------
function "+" (R : Relation) return Relation is
begin
Relations.Append (R);
return R;
end "+";
---------------
-- Solve_All --
---------------
procedure Solve_All (Rel : Relation; Timeout : Natural := 0) is
type Var_And_Val is record
Var : Refs.Logic_Var;
Defined : Boolean;
Val : T;
end record;
-- We want to keep track of the various solutions found. Since solution
-- values are stored in variables, this means that we need to save the
-- values when a solution is found, as the next solution will override
-- them in variables.
function Image (Self : Var_And_Val) return String
is
(Refs.Image (Self.Var) & " = "
& (if Self.Defined
then Image (Self.Val)
else "<undefined>"));
type Solution is array (Positive range <>) of Var_And_Val;
type Solution_Access is access all Solution;
procedure Free is new Ada.Unchecked_Deallocation
(Solution, Solution_Access);
package Solution_Vectors is new Gpr_Parser_Support.Vectors
(Solution_Access);
procedure Free (Self : in out Solution_Vectors.Vector);
-- Free all solutions in Self and destroy the vector
function Equivalent
(Left, Right : Solution_Vectors.Vector) return Boolean;
-- Return whether the two vectors of solutions are equal
Solutions : Solution_Vectors.Vector :=
Solution_Vectors.Empty_Vector;
Solutions_Without_Opts : Solution_Vectors.Vector :=
Solution_Vectors.Empty_Vector;
function Solution_Callback (Vars : Logic_Var_Array) return Boolean;
-- Callback for ``Solve``. Print the given solution and append it to
-- ``Solutions``, then return True to continue looking for other
-- solutions.
function Image is new Gpr_Parser_Support.Images.Array_Image
(Var_And_Val, Positive, Solution);
procedure Run_Solve (Opts : Solve_Options_Type);
-- Wrapper around the ``Solve`` procedure, to catch and display uncaught
-- exceptions.
----------
-- Free --
----------
procedure Free (Self : in out Solution_Vectors.Vector) is
S_Mut : Solution_Access;
begin
for S of Self loop
S_Mut := S;
Free (S_Mut);
end loop;
Self.Destroy;
end Free;
----------------
-- Equivalent --
----------------
function Equivalent
(Left, Right : Solution_Vectors.Vector) return Boolean
is
begin
if Left.Length /= Right.Length then
return False;
end if;
for I in 1 .. Left.Length loop
declare
S_L : Solution renames Left.Get (I).all;
S_R : Solution renames Right.Get (I).all;
begin
if S_L'Length /= S_R'Length then
return False;
end if;
for J in S_L'Range loop
declare
L : Var_And_Val renames S_L (J);
R : Var_And_Val renames S_R (J);
begin
if Refs."/=" (L.Var, R.Var)
or else L.Defined /= R.Defined
or else (L.Defined and then L.Val /= R.Val)
then
return False;
end if;
end;
end loop;
end;
end loop;
return True;
end Equivalent;
-----------------------
-- Solution_Callback --
-----------------------
function Solution_Callback (Vars : Logic_Var_Array) return Boolean is
S : constant Solution_Access := new Solution (Vars'Range);
begin
for I in Vars'Range loop
declare
V : Refs.Logic_Var renames Vars (I);
begin
S (I) := (Var => V,
Defined => Refs.Is_Defined (V),
Val => Refs.Get_Value (V));
end;
end loop;
Solutions.Append (S);
Put_Line ("Solution: " & Image (S.all));
return True;
end Solution_Callback;
---------------
-- Run_Solve --
---------------
procedure Run_Solve (Opts : Solve_Options_Type) is
begin
Solve (Rel, Solution_Callback'Access, Opts, Timeout);
exception
when Early_Binding_Error =>
Put_Line ("Resolution failed with Early_Binding_Error");
when Timeout_Error =>
Put_Line ("Resolution failed with Timeout_Error");
when Exc : others =>
Put_Line (" -> " & Exception_Name (Exc)
& ": " & Exception_Message (Exc));
end Run_Solve;
begin
Put_Line ("Solving relation:");
Put_Line (Image (Rel));
-- Solve both without and with optimizations
if Run_Sym_Without_Opts then
Put_Line ("... without optimizations:");
Run_Solve ((others => False));
New_Line;
Solutions_Without_Opts := Solutions;
Solutions := Solution_Vectors.Empty_Vector;
end if;
if Run_Sym_With_Opts then
Put_Line ("... with all optimizations:");
Run_Solve ((others => True));
New_Line;
end if;
-- Check that we had the same results in both cases
if Run_Sym_Without_Opts
and then Run_Sym_With_Opts
and then not Equivalent (Solutions_Without_Opts, Solutions)
then
Put_Line ("ERROR: solutions are not the same");
New_Line;
Ada.Command_Line.Set_Exit_Status (Ada.Command_Line.Failure);
end if;
-- Clean up, we are done
Free (Solutions_Without_Opts);
Free (Solutions);
exception
when others =>
Free (Solutions_Without_Opts);
Free (Solutions);
raise;
end Solve_All;
---------
-- "-" --
---------
function "-" (S : String) return String_Access is
begin
return Result : constant String_Access := new String'(S) do
Strings.Append (Result);
end return;
end "-";
--------------
-- Run_Main --
--------------
procedure Run_Main (Main : access procedure) is
begin
Setup_Traces;
Main.all;
Finalize;
end Run_Main;
------------------
-- Setup_Traces --
------------------
procedure Setup_Traces is
package Env renames Ada.Environment_Variables;
Var_Name : constant String := "ADALOG_SOLVER_CFG";
Cfg : constant String := Env.Value (Var_Name, Default => "");
begin
GNATCOLL.Traces.Parse_Config_File;
Run_Sym_Without_Opts := False;
Run_Sym_With_Opts := False;
if Cfg = "" then
Run_Sym_Without_Opts := True;
Run_Sym_With_Opts := True;
elsif Cfg = "sym" then
Run_Sym_Without_Opts := True;
elsif Cfg = "sym-opts" then
Run_Sym_With_Opts := True;
else
raise Program_Error
with "Invalid value for env var """ & Var_Name & """";
end if;
end Setup_Traces;
--------------
-- Finalize --
--------------
procedure Finalize is
Used : Boolean := False;
begin
for R of Relations loop
Used := True;
Dec_Ref (R);
end loop;
for V of Variables loop
Refs.Destroy (V.all);
Free (V);
end loop;
for S of Strings loop
Free (S);
end loop;
Relations := Relation_Vectors.Empty_Vector;
Variables := Variable_Vectors.Empty_Vector;
Strings := String_Access_Vectors.Empty_Vector;
if Used then
Put_Line ("Done.");
end if;
end Finalize;
end Gpr_Parser_Support.Adalog.Generic_Main_Support;
|
zenharris/ada-bbs | Ada | 276 | ads | with Ada.Strings.Unbounded; use Ada.Strings.Unbounded;
package Message is
-- pragma Pure (Message);
Version : constant String := "0.0.1";
UserLoggedIn : Boolean := False;
UserLoggedName : Unbounded_String;
UserLoggedFullName : Unbounded_String;
end Message;
|
zhmu/ananas | Ada | 6,246 | adb | ------------------------------------------------------------------------------
-- --
-- GNAT RUN-TIME COMPONENTS --
-- --
-- S Y S T E M . P A C K _ 6 1 --
-- --
-- B o d y --
-- --
-- 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. --
-- --
------------------------------------------------------------------------------
with System.Storage_Elements;
with System.Unsigned_Types;
package body System.Pack_61 is
subtype Bit_Order is System.Bit_Order;
Reverse_Bit_Order : constant Bit_Order :=
Bit_Order'Val (1 - Bit_Order'Pos (System.Default_Bit_Order));
subtype Ofs is System.Storage_Elements.Storage_Offset;
subtype Uns is System.Unsigned_Types.Unsigned;
subtype N07 is System.Unsigned_Types.Unsigned range 0 .. 7;
use type System.Storage_Elements.Storage_Offset;
use type System.Unsigned_Types.Unsigned;
type Cluster is record
E0, E1, E2, E3, E4, E5, E6, E7 : Bits_61;
end record;
for Cluster use record
E0 at 0 range 0 * Bits .. 0 * Bits + Bits - 1;
E1 at 0 range 1 * Bits .. 1 * Bits + Bits - 1;
E2 at 0 range 2 * Bits .. 2 * Bits + Bits - 1;
E3 at 0 range 3 * Bits .. 3 * Bits + Bits - 1;
E4 at 0 range 4 * Bits .. 4 * Bits + Bits - 1;
E5 at 0 range 5 * Bits .. 5 * Bits + Bits - 1;
E6 at 0 range 6 * Bits .. 6 * Bits + Bits - 1;
E7 at 0 range 7 * Bits .. 7 * Bits + Bits - 1;
end record;
for Cluster'Size use Bits * 8;
for Cluster'Alignment use Integer'Min (Standard'Maximum_Alignment,
1 +
1 * Boolean'Pos (Bits mod 2 = 0) +
2 * Boolean'Pos (Bits mod 4 = 0));
-- Use maximum possible alignment, given the bit field size, since this
-- will result in the most efficient code possible for the field.
type Cluster_Ref is access Cluster;
type Rev_Cluster is new Cluster
with Bit_Order => Reverse_Bit_Order,
Scalar_Storage_Order => Reverse_Bit_Order;
type Rev_Cluster_Ref is access Rev_Cluster;
------------
-- Get_61 --
------------
function Get_61
(Arr : System.Address;
N : Natural;
Rev_SSO : Boolean) return Bits_61
is
A : constant System.Address := Arr + Bits * Ofs (Uns (N) / 8);
C : Cluster_Ref with Address => A'Address, Import;
RC : Rev_Cluster_Ref with Address => A'Address, Import;
begin
if Rev_SSO then
case N07 (Uns (N) mod 8) is
when 0 => return RC.E0;
when 1 => return RC.E1;
when 2 => return RC.E2;
when 3 => return RC.E3;
when 4 => return RC.E4;
when 5 => return RC.E5;
when 6 => return RC.E6;
when 7 => return RC.E7;
end case;
else
case N07 (Uns (N) mod 8) is
when 0 => return C.E0;
when 1 => return C.E1;
when 2 => return C.E2;
when 3 => return C.E3;
when 4 => return C.E4;
when 5 => return C.E5;
when 6 => return C.E6;
when 7 => return C.E7;
end case;
end if;
end Get_61;
------------
-- Set_61 --
------------
procedure Set_61
(Arr : System.Address;
N : Natural;
E : Bits_61;
Rev_SSO : Boolean)
is
A : constant System.Address := Arr + Bits * Ofs (Uns (N) / 8);
C : Cluster_Ref with Address => A'Address, Import;
RC : Rev_Cluster_Ref with Address => A'Address, Import;
begin
if Rev_SSO then
case N07 (Uns (N) mod 8) is
when 0 => RC.E0 := E;
when 1 => RC.E1 := E;
when 2 => RC.E2 := E;
when 3 => RC.E3 := E;
when 4 => RC.E4 := E;
when 5 => RC.E5 := E;
when 6 => RC.E6 := E;
when 7 => RC.E7 := E;
end case;
else
case N07 (Uns (N) mod 8) is
when 0 => C.E0 := E;
when 1 => C.E1 := E;
when 2 => C.E2 := E;
when 3 => C.E3 := E;
when 4 => C.E4 := E;
when 5 => C.E5 := E;
when 6 => C.E6 := E;
when 7 => C.E7 := E;
end case;
end if;
end Set_61;
end System.Pack_61;
|
AdaCore/Ada_Drivers_Library | Ada | 9,170 | ads | -- This spec has been automatically generated from STM32F7x.svd
pragma Restrictions (No_Elaboration_Code);
pragma Ada_2012;
pragma Style_Checks (Off);
with HAL;
with System;
package STM32_SVD.PWR is
pragma Preelaborate;
---------------
-- Registers --
---------------
subtype CR1_PLS_Field is HAL.UInt3;
subtype CR1_VOS_Field is HAL.UInt2;
subtype CR1_UDEN_Field is HAL.UInt2;
-- power control register
type CR1_Register is record
-- Low-power deep sleep
LPDS : Boolean := False;
-- Power down deepsleep
PDDS : Boolean := False;
-- unspecified
Reserved_2_2 : HAL.Bit := 16#0#;
-- Clear standby flag
CSBF : Boolean := False;
-- Power voltage detector enable
PVDE : Boolean := False;
-- PVD level selection
PLS : CR1_PLS_Field := 16#0#;
-- Disable backup domain write protection
DBP : Boolean := False;
-- Flash power down in Stop mode
FPDS : Boolean := False;
-- Low-power regulator in deepsleep under-drive mode
LPUDS : Boolean := False;
-- Main regulator in deepsleep under-drive mode
MRUDS : Boolean := False;
-- unspecified
Reserved_12_12 : HAL.Bit := 16#0#;
-- ADCDC1
ADCDC1 : Boolean := False;
-- Regulator voltage scaling output selection
VOS : CR1_VOS_Field := 16#3#;
-- Over-drive enable
ODEN : Boolean := False;
-- Over-drive switching enabled
ODSWEN : Boolean := False;
-- Under-drive enable in stop mode
UDEN : CR1_UDEN_Field := 16#0#;
-- unspecified
Reserved_20_31 : HAL.UInt12 := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for CR1_Register use record
LPDS at 0 range 0 .. 0;
PDDS at 0 range 1 .. 1;
Reserved_2_2 at 0 range 2 .. 2;
CSBF at 0 range 3 .. 3;
PVDE at 0 range 4 .. 4;
PLS at 0 range 5 .. 7;
DBP at 0 range 8 .. 8;
FPDS at 0 range 9 .. 9;
LPUDS at 0 range 10 .. 10;
MRUDS at 0 range 11 .. 11;
Reserved_12_12 at 0 range 12 .. 12;
ADCDC1 at 0 range 13 .. 13;
VOS at 0 range 14 .. 15;
ODEN at 0 range 16 .. 16;
ODSWEN at 0 range 17 .. 17;
UDEN at 0 range 18 .. 19;
Reserved_20_31 at 0 range 20 .. 31;
end record;
subtype CSR1_UDRDY_Field is HAL.UInt2;
-- power control/status register
type CSR1_Register is record
-- Read-only. Wakeup internal flag
WUIF : Boolean := False;
-- Read-only. Standby flag
SBF : Boolean := False;
-- Read-only. PVD output
PVDO : Boolean := False;
-- Read-only. Backup regulator ready
BRR : Boolean := False;
-- unspecified
Reserved_4_8 : HAL.UInt5 := 16#0#;
-- Backup regulator enable
BRE : Boolean := False;
-- unspecified
Reserved_10_13 : HAL.UInt4 := 16#0#;
-- Regulator voltage scaling output selection ready bit
VOSRDY : Boolean := False;
-- unspecified
Reserved_15_15 : HAL.Bit := 16#0#;
-- Over-drive mode ready
ODRDY : Boolean := False;
-- Over-drive mode switching ready
ODSWRDY : Boolean := False;
-- Under-drive ready flag
UDRDY : CSR1_UDRDY_Field := 16#0#;
-- unspecified
Reserved_20_31 : HAL.UInt12 := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for CSR1_Register use record
WUIF at 0 range 0 .. 0;
SBF at 0 range 1 .. 1;
PVDO at 0 range 2 .. 2;
BRR at 0 range 3 .. 3;
Reserved_4_8 at 0 range 4 .. 8;
BRE at 0 range 9 .. 9;
Reserved_10_13 at 0 range 10 .. 13;
VOSRDY at 0 range 14 .. 14;
Reserved_15_15 at 0 range 15 .. 15;
ODRDY at 0 range 16 .. 16;
ODSWRDY at 0 range 17 .. 17;
UDRDY at 0 range 18 .. 19;
Reserved_20_31 at 0 range 20 .. 31;
end record;
-- CR2_CWUPF array
type CR2_CWUPF_Field_Array is array (1 .. 6) of Boolean
with Component_Size => 1, Size => 6;
-- Type definition for CR2_CWUPF
type CR2_CWUPF_Field
(As_Array : Boolean := False)
is record
case As_Array is
when False =>
-- CWUPF as a value
Val : HAL.UInt6;
when True =>
-- CWUPF as an array
Arr : CR2_CWUPF_Field_Array;
end case;
end record
with Unchecked_Union, Size => 6;
for CR2_CWUPF_Field use record
Val at 0 range 0 .. 5;
Arr at 0 range 0 .. 5;
end record;
-- CR2_WUPP array
type CR2_WUPP_Field_Array is array (1 .. 6) of Boolean
with Component_Size => 1, Size => 6;
-- Type definition for CR2_WUPP
type CR2_WUPP_Field
(As_Array : Boolean := False)
is record
case As_Array is
when False =>
-- WUPP as a value
Val : HAL.UInt6;
when True =>
-- WUPP as an array
Arr : CR2_WUPP_Field_Array;
end case;
end record
with Unchecked_Union, Size => 6;
for CR2_WUPP_Field use record
Val at 0 range 0 .. 5;
Arr at 0 range 0 .. 5;
end record;
-- power control register
type CR2_Register is record
-- Read-only. Clear Wakeup Pin flag for PA0
CWUPF : CR2_CWUPF_Field := (As_Array => False, Val => 16#0#);
-- unspecified
Reserved_6_7 : HAL.UInt2 := 16#0#;
-- Wakeup pin polarity bit for PA0
WUPP : CR2_WUPP_Field := (As_Array => False, Val => 16#0#);
-- unspecified
Reserved_14_31 : HAL.UInt18 := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for CR2_Register use record
CWUPF at 0 range 0 .. 5;
Reserved_6_7 at 0 range 6 .. 7;
WUPP at 0 range 8 .. 13;
Reserved_14_31 at 0 range 14 .. 31;
end record;
-- CSR2_WUPF array
type CSR2_WUPF_Field_Array is array (1 .. 6) of Boolean
with Component_Size => 1, Size => 6;
-- Type definition for CSR2_WUPF
type CSR2_WUPF_Field
(As_Array : Boolean := False)
is record
case As_Array is
when False =>
-- WUPF as a value
Val : HAL.UInt6;
when True =>
-- WUPF as an array
Arr : CSR2_WUPF_Field_Array;
end case;
end record
with Unchecked_Union, Size => 6;
for CSR2_WUPF_Field use record
Val at 0 range 0 .. 5;
Arr at 0 range 0 .. 5;
end record;
-- CSR2_EWUP array
type CSR2_EWUP_Field_Array is array (1 .. 6) of Boolean
with Component_Size => 1, Size => 6;
-- Type definition for CSR2_EWUP
type CSR2_EWUP_Field
(As_Array : Boolean := False)
is record
case As_Array is
when False =>
-- EWUP as a value
Val : HAL.UInt6;
when True =>
-- EWUP as an array
Arr : CSR2_EWUP_Field_Array;
end case;
end record
with Unchecked_Union, Size => 6;
for CSR2_EWUP_Field use record
Val at 0 range 0 .. 5;
Arr at 0 range 0 .. 5;
end record;
-- power control/status register
type CSR2_Register is record
-- Read-only. Wakeup Pin flag for PA0
WUPF : CSR2_WUPF_Field := (As_Array => False, Val => 16#0#);
-- unspecified
Reserved_6_7 : HAL.UInt2 := 16#0#;
-- Enable Wakeup pin for PA0
EWUP : CSR2_EWUP_Field := (As_Array => False, Val => 16#0#);
-- unspecified
Reserved_14_31 : HAL.UInt18 := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for CSR2_Register use record
WUPF at 0 range 0 .. 5;
Reserved_6_7 at 0 range 6 .. 7;
EWUP at 0 range 8 .. 13;
Reserved_14_31 at 0 range 14 .. 31;
end record;
-----------------
-- Peripherals --
-----------------
-- Power control
type PWR_Peripheral is record
-- power control register
CR1 : aliased CR1_Register;
-- power control/status register
CSR1 : aliased CSR1_Register;
-- power control register
CR2 : aliased CR2_Register;
-- power control/status register
CSR2 : aliased CSR2_Register;
end record
with Volatile;
for PWR_Peripheral use record
CR1 at 16#0# range 0 .. 31;
CSR1 at 16#4# range 0 .. 31;
CR2 at 16#8# range 0 .. 31;
CSR2 at 16#C# range 0 .. 31;
end record;
-- Power control
PWR_Periph : aliased PWR_Peripheral
with Import, Address => System'To_Address (16#40007000#);
end STM32_SVD.PWR;
|
Fabien-Chouteau/coffee-clock | Ada | 54,722 | ads | -- This file was generated by bmp2ada
with Giza.Image;
with Giza.Image.DMA2D;
use Giza.Image.DMA2D;
package digit_2 is
pragma Style_Checks (Off);
CLUT : aliased constant L4_CLUT_T := (
(R => 0, G => 0, B => 0),
(R => 255, G => 0, B => 0), others => (0, 0, 0));
Data : aliased constant L4_Data_T := (
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 1, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 16, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17,
17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 16, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 16, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17,
17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 16, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17,
17, 17, 17, 17, 17, 17, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 16, 17, 17, 17, 17, 17, 17, 17,
17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17,
17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 16,
17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 1,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17,
17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17,
17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17,
17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17,
17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 17, 17, 17,
17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17,
17, 17, 17, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17,
17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17,
17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17,
17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17,
17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 17, 17, 17,
17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17,
17, 17, 17, 17, 17, 17, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17,
17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17,
17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17,
17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 1, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17,
17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 17, 17, 17,
17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17,
17, 17, 17, 17, 17, 17, 17, 17, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17,
17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17,
17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17,
17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17,
17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 17, 17, 17,
17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17,
17, 17, 17, 17, 17, 17, 17, 17, 17, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17,
17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17,
17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17,
17, 17, 17, 17, 17, 17, 17, 17, 17, 1, 0, 0, 0, 0, 0, 0, 16, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17,
1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 17,
17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 17, 17, 17,
17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 16, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17,
17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 16, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 16, 17, 17, 17, 17, 17, 17, 17,
17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17,
17, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 17, 17, 17,
17, 17, 17, 17, 17, 17, 17, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 16, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17,
17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 17, 17, 17, 17, 17, 17, 17, 17, 17, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 1, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 17, 17, 17, 17, 17, 17, 17, 17, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 16, 17, 17, 17, 17,
17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 17, 17, 17, 17, 17, 17, 17, 1, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17,
17, 17, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 17, 17, 17, 17, 17, 17, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 16, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 17, 17, 17,
17, 17, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 16, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17,
17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 17, 17, 17, 17, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 17, 17, 17, 17, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 16, 17, 17,
17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 17, 17, 17, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 16, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17,
17, 17, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 17, 17, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 17, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17,
17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 1, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 16, 17,
17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 16, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17,
17, 17, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 16, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 16, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17,
17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 1, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 17,
17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17,
17, 17, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17,
17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 1, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 17,
17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17,
17, 17, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17,
17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 16, 17,
17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 16, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17,
17, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 16, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 16, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17,
17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 1, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 17, 17,
17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17,
17, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 16, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 16, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17,
17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 17, 17, 17,
17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 16, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 16, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17,
17, 17, 17, 17, 17, 17, 17, 17, 17, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 16, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 16, 17, 17, 17, 17,
17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 1, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 16, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17,
17, 17, 17, 17, 17, 17, 17, 17, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 16, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 17, 17, 17, 17, 17, 17, 17,
17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 16, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 16, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17,
17, 17, 17, 17, 17, 17, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 16, 17, 17, 17, 17, 17, 17, 17, 17, 17,
17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 16,
17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17,
17, 17, 17, 17, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 16, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17,
17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 16, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 1, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 17, 17, 17,
17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17,
17, 17, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 16, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17,
17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 16, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 17, 17, 17, 17, 17, 17,
17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 16, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 1,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17,
17, 17, 17, 17, 17, 17, 17, 17, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 16, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 17, 17, 17, 17, 17, 17, 17, 17, 17,
17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 16, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 1, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 16, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17,
17, 17, 17, 17, 17, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 16, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17,
17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 16, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 17, 17, 17,
17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 16, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17,
17, 17, 17, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 16, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17,
17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 16, 17, 17, 17, 17, 17,
17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 16, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 16, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17,
17, 17, 17, 17, 17, 17, 17, 17, 17, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 16, 17, 17, 17, 17, 17, 17, 17, 17,
17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
16, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17,
17, 17, 17, 17, 17, 17, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 16, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17,
17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 16, 17, 17,
17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17,
17, 17, 17, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 16, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17,
17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 1, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 16, 17, 17, 17, 17, 17,
17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 16, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17,
17, 17, 17, 17, 17, 17, 17, 17, 17, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 16, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 17, 17, 17, 17, 17, 17, 17, 17,
17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 16, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 1, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
16, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17,
17, 17, 17, 17, 17, 17, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 16, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17,
17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 16, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 1, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 17, 17,
17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 16, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17,
17, 17, 17, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17,
17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17,
17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17,
17, 17, 17, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17,
17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 17, 17, 17,
17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17,
17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17,
17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17,
17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17,
17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17,
17, 17, 17, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17,
17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 17, 17, 17,
17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17,
17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17,
17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17,
17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17,
17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17,
17, 17, 17, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17,
17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 17, 17, 17,
17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17,
17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17,
17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17,
17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17,
17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17,
17, 17, 17, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17,
17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 17, 17, 17,
17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17,
17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17,
17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17,
17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17,
17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17,
17, 17, 17, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17,
17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 17, 17, 17,
17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17,
17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17,
17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17,
17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17,
17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17,
17, 17, 17, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17,
17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 17, 17, 17,
17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17,
17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17,
17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17,
17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17,
17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17,
17, 17, 17, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17,
17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 17, 17, 17,
17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17,
17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
);
Image : constant Giza.Image.Ref := new Giza.Image.DMA2D.Instance'
(Mode => L4, W => 160, H => 195, Length => 15600, L4_CLUT => CLUT'Access, L4_Data => Data'Access);
pragma Style_Checks (On);
end digit_2;
|
sungyeon/drake | Ada | 3,062 | ads | pragma License (Unrestricted);
with Ada.IO_Exceptions;
with Ada.IO_Modes;
private with Ada.Streams; -- [gcc-5] can not find it by below "with Stream_IO"
private with Ada.Streams.Stream_IO;
generic
type Element_Type (<>) is private;
package Ada.Sequential_IO is
type File_Type is limited private;
-- Similar to Text_IO in AI12-0054-2:
-- subtype Open_File_Type is File_Type
-- with
-- Dynamic_Predicate => Is_Open (Open_File_Type),
-- Predicate_Failure => raise Status_Error with "File not open";
-- subtype Input_File_Type is Open_File_Type
-- with
-- Dynamic_Predicate => Mode (Input_File_Type) = In_File,
-- Predicate_Failure =>
-- raise Mode_Error with
-- "Cannot read file: " & Name (Input_File_Type);
-- subtype Output_File_Type is Open_File_Type
-- with
-- Dynamic_Predicate => Mode (Output_File_Type) /= In_File,
-- Predicate_Failure =>
-- raise Mode_Error with
-- "Cannot write file: " & Name (Output_File_Type);
-- type File_Mode is (In_File, Out_File, Append_File);
type File_Mode is new IO_Modes.File_Mode; -- for conversion
-- File management
procedure Create (
File : in out File_Type;
Mode : File_Mode := Out_File;
Name : String := "";
Form : String := "");
procedure Open (
File : in out File_Type;
Mode : File_Mode;
Name : String;
Form : String := "");
procedure Close (File : in out File_Type);
procedure Delete (File : in out File_Type);
procedure Reset (File : in out File_Type; Mode : File_Mode);
procedure Reset (File : in out File_Type);
function Mode (
File : File_Type) -- Open_File_Type
return File_Mode;
function Name (
File : File_Type) -- Open_File_Type
return String;
function Form (
File : File_Type) -- Open_File_Type
return String;
pragma Inline (Mode);
pragma Inline (Name);
pragma Inline (Form);
function Is_Open (File : File_Type) return Boolean;
pragma Inline (Is_Open);
procedure Flush (
File : File_Type); -- Output_File_Type
-- AI12-0130-1
-- Input and output operations
procedure Read (
File : File_Type; -- Input_File_Type
Item : out Element_Type);
procedure Write (
File : File_Type; -- Output_File_Type
Item : Element_Type);
function End_Of_File (
File : File_Type) -- Input_File_Type
return Boolean;
pragma Inline (End_Of_File);
-- Exceptions
Status_Error : exception
renames IO_Exceptions.Status_Error;
Mode_Error : exception
renames IO_Exceptions.Mode_Error;
Name_Error : exception
renames IO_Exceptions.Name_Error;
Use_Error : exception
renames IO_Exceptions.Use_Error;
Device_Error : exception
renames IO_Exceptions.Device_Error;
End_Error : exception
renames IO_Exceptions.End_Error;
Data_Error : exception
renames IO_Exceptions.Data_Error;
private
type File_Type is new Streams.Stream_IO.File_Type;
end Ada.Sequential_IO;
|
apple-oss-distributions/old_ncurses | Ada | 14,054 | adb | ------------------------------------------------------------------------------
-- --
-- GNAT ncurses Binding Samples --
-- --
-- Sample.Explanation --
-- --
-- B O D Y --
-- --
------------------------------------------------------------------------------
-- Copyright (c) 1998 Free Software Foundation, Inc. --
-- --
-- Permission is hereby granted, free of charge, to any person obtaining a --
-- copy of this software and associated documentation files (the --
-- "Software"), to deal in the Software without restriction, including --
-- without limitation the rights to use, copy, modify, merge, publish, --
-- distribute, distribute with modifications, sublicense, and/or sell --
-- copies of the Software, and to permit persons to whom the Software is --
-- furnished to do so, subject to the following conditions: --
-- --
-- The above copyright notice and this permission notice shall be included --
-- in all copies or substantial portions of the Software. --
-- --
-- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS --
-- OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF --
-- MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. --
-- IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, --
-- DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR --
-- OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR --
-- THE USE OR OTHER DEALINGS IN THE SOFTWARE. --
-- --
-- Except as contained in this notice, the name(s) of the above copyright --
-- holders shall not be used in advertising or otherwise to promote the --
-- sale, use or other dealings in this Software without prior written --
-- authorization. --
------------------------------------------------------------------------------
-- Author: Juergen Pfeifer <[email protected]> 1996
-- Version Control
-- $Revision: 1.1.1.1 $
-- Binding Version 01.00
------------------------------------------------------------------------------
-- Poor mans help system. This scans a sequential file for key lines and
-- then reads the lines up to the next key. Those lines are presented in
-- a window as help or explanation.
--
with Ada.Text_IO; use Ada.Text_IO;
with Ada.Unchecked_Deallocation;
with Terminal_Interface.Curses; use Terminal_Interface.Curses;
with Terminal_Interface.Curses.Panels; use Terminal_Interface.Curses.Panels;
with Sample.Keyboard_Handler; use Sample.Keyboard_Handler;
with Sample.Manifest; use Sample.Manifest;
with Sample.Function_Key_Setting; use Sample.Function_Key_Setting;
with Sample.Helpers; use Sample.Helpers;
package body Sample.Explanation is
Help_Keys : constant String := "HELPKEYS";
In_Help : constant String := "INHELP";
File_Name : String := "explain.msg";
F : File_Type;
type Help_Line;
type Help_Line_Access is access Help_Line;
pragma Controlled (Help_Line_Access);
type String_Access is access String;
pragma Controlled (String_Access);
type Help_Line is
record
Prev, Next : Help_Line_Access;
Line : String_Access;
end record;
procedure Explain (Key : in String;
Win : in Window);
procedure Release_String is
new Ada.Unchecked_Deallocation (String,
String_Access);
procedure Release_Help_Line is
new Ada.Unchecked_Deallocation (Help_Line,
Help_Line_Access);
function Search (Key : String) return Help_Line_Access;
procedure Release_Help (Root : in out Help_Line_Access);
procedure Explain (Key : in String)
is
begin
Explain (Key, Null_Window);
end Explain;
procedure Explain (Key : in String;
Win : in Window)
is
-- Retrieve the text associated with this key and display it in this
-- window. If no window argument is passed, the routine will create
-- a temporary window and use it.
function Filter_Key return Real_Key_Code;
procedure Unknown_Key;
procedure Redo;
procedure To_Window (C : in out Help_Line_Access;
More : in out Boolean);
Frame : Window := Null_Window;
W : Window := Win;
K : Real_Key_Code;
P : Panel;
Height : Line_Count;
Width : Column_Count;
Help : Help_Line_Access := Search (Key);
Current : Help_Line_Access;
Top_Line : Help_Line_Access;
Has_More : Boolean;
procedure Unknown_Key
is
begin
Add (W, "Help message with ID ");
Add (W, Key);
Add (W, " not found.");
Add (W, Character'Val (10));
Add (W, "Press the Function key labelled 'Quit' key to continue.");
end Unknown_Key;
procedure Redo
is
H : Help_Line_Access := Top_Line;
begin
if Top_Line /= null then
for L in 0 .. (Height - 1) loop
Add (W, L, 0, H.Line.all);
exit when H.Next = null;
H := H.Next;
end loop;
else
Unknown_Key;
end if;
end Redo;
function Filter_Key return Real_Key_Code
is
K : Real_Key_Code;
begin
loop
K := Get_Key (W);
if K in Special_Key_Code'Range then
case K is
when HELP_CODE =>
if not Find_Context (In_Help) then
Push_Environment (In_Help, False);
Explain (In_Help, W);
Pop_Environment;
Redo;
end if;
when EXPLAIN_CODE =>
if not Find_Context (Help_Keys) then
Push_Environment (Help_Keys, False);
Explain (Help_Keys, W);
Pop_Environment;
Redo;
end if;
when others => exit;
end case;
else
exit;
end if;
end loop;
return K;
end Filter_Key;
procedure To_Window (C : in out Help_Line_Access;
More : in out Boolean)
is
L : Line_Position := 0;
begin
loop
Add (W, L, 0, C.Line.all);
L := L + 1;
exit when C.Next = null or else L = Height;
C := C.Next;
end loop;
if C.Next /= null then
pragma Assert (L = Height);
More := True;
else
More := False;
end if;
end To_Window;
begin
if W = Null_Window then
Push_Environment ("HELP");
Default_Labels;
Frame := New_Window (Lines - 2, Columns, 0, 0);
if Has_Colors then
Set_Background (Win => Frame,
Ch => (Ch => ' ',
Color => Help_Color,
Attr => Normal_Video));
Set_Character_Attributes (Win => Frame,
Attr => Normal_Video,
Color => Help_Color);
Erase (Frame);
end if;
Box (Frame);
Set_Character_Attributes (Frame, (Reverse_Video => True,
others => False));
Add (Frame, Lines - 3, 2, "Cursor Up/Down scrolls");
Set_Character_Attributes (Frame); -- Back to default.
Window_Title (Frame, "Explanation");
W := Derived_Window (Frame, Lines - 4, Columns - 2, 1, 1);
Refresh_Without_Update (Frame);
Get_Size (W, Height, Width);
Set_Meta_Mode (W);
Set_KeyPad_Mode (W);
Allow_Scrolling (W, True);
Set_Echo_Mode (False);
P := Create (Frame);
Top (P);
Update_Panels;
else
Clear (W);
Refresh_Without_Update (W);
end if;
Current := Help; Top_Line := Help;
if null = Help then
Unknown_Key;
loop
K := Filter_Key;
exit when K = QUIT_CODE;
end loop;
else
To_Window (Current, Has_More);
if Has_More then
-- This means there are more lines available, so we have to go
-- into a scroll manager.
loop
K := Filter_Key;
if K in Special_Key_Code'Range then
case K is
when Key_Cursor_Down =>
if Current.Next /= null then
Move_Cursor (W, Height - 1, 0);
Scroll (W, 1);
Current := Current.Next;
Top_Line := Top_Line.Next;
Add (W, Current.Line.all);
end if;
when Key_Cursor_Up =>
if Top_Line.Prev /= null then
Move_Cursor (W, 0, 0);
Scroll (W, -1);
Top_Line := Top_Line.Prev;
Current := Current.Prev;
Add (W, Top_Line.Line.all);
end if;
when QUIT_CODE => exit;
when others => null;
end case;
end if;
end loop;
else
loop
K := Filter_Key;
exit when K = QUIT_CODE;
end loop;
end if;
end if;
Clear (W);
if Frame /= Null_Window then
Clear (Frame);
Delete (P);
Delete (W);
Delete (Frame);
Pop_Environment;
end if;
Update_Panels;
Update_Screen;
Release_Help (Help);
end Explain;
function Search (Key : String) return Help_Line_Access
is
Last : Natural;
Buffer : String (1 .. 256);
Root : Help_Line_Access := null;
Current : Help_Line_Access;
Tail : Help_Line_Access := null;
function Next_Line return Boolean;
function Next_Line return Boolean
is
H_End : constant String := "#END";
begin
Get_Line (F, Buffer, Last);
if Last = H_End'Length and then H_End = Buffer (1 .. Last) then
return False;
else
return True;
end if;
end Next_Line;
begin
Reset (F);
Outer :
loop
exit when not Next_Line;
if Last = (1 + Key'Length) and then Key = Buffer (2 .. Last)
and then Buffer (1) = '#' then
loop
exit when not Next_Line;
exit when Buffer (1) = '#';
Current := new Help_Line'(null, null,
new String'(Buffer (1 .. Last)));
if Tail = null then
Release_Help (Root);
Root := Current;
else
Tail.Next := Current;
Current.Prev := Tail;
end if;
Tail := Current;
end loop;
exit Outer;
end if;
end loop Outer;
return Root;
end Search;
procedure Release_Help (Root : in out Help_Line_Access)
is
Next : Help_Line_Access;
begin
loop
exit when Root = null;
Next := Root.Next;
Release_String (Root.Line);
Release_Help_Line (Root);
Root := Next;
end loop;
end Release_Help;
procedure Explain_Context
is
begin
Explain (Context);
end Explain_Context;
procedure Notepad (Key : in String)
is
H : constant Help_Line_Access := Search (Key);
T : Help_Line_Access := H;
N : Line_Count := 1;
L : Line_Position := 0;
W : Window;
P : Panel;
begin
if H /= null then
loop
T := T.Next;
exit when T = null;
N := N + 1;
end loop;
W := New_Window (N + 2, Columns, Lines - N - 2, 0);
if Has_Colors then
Set_Background (Win => W,
Ch => (Ch => ' ',
Color => Notepad_Color,
Attr => Normal_Video));
Set_Character_Attributes (Win => W,
Attr => Normal_Video,
Color => Notepad_Color);
Erase (W);
end if;
Box (W);
Window_Title (W, "Notepad");
P := New_Panel (W);
T := H;
loop
Add (W, L + 1, 1, T.Line.all, Integer (Columns - 2));
L := L + 1;
T := T.Next;
exit when T = null;
end loop;
T := H;
Release_Help (T);
Refresh_Without_Update (W);
Notepad_To_Context (P);
end if;
end Notepad;
begin
Open (F, In_File, File_Name);
end Sample.Explanation;
|
sparre/Command-Line-Parser-Generator | Ada | 759 | ads | with Ada.Containers,
Ada.Strings.Unbounded;
private
package An_Application.Command_Line_Parser.Argument is
type Instance is tagged
record
Key : Ada.Strings.Unbounded.Unbounded_String;
Value : Ada.Strings.Unbounded.Unbounded_String;
end record;
overriding
function "=" (Left, Right : in Instance) return Boolean;
function Compose (Key : in String;
Value : in String) return Instance;
function Equal_Keys (Left, Right : in Instance) return Boolean;
function Key_Hash (Item : in Instance) return Ada.Containers.Hash_Type;
function Image (Item : in Instance) return String;
function Value (Item : in String) return Instance;
end An_Application.Command_Line_Parser.Argument;
|
AdaCore/libadalang | Ada | 524 | adb | procedure Test is
On_Type : String := Float'Image (2.0);
pragma Test_Statement;
My_Float : Float := 2.0;
On_Expr : String := My_Float'Image;
pragma Test_Statement;
On_Qualified_Expr : String := Float'(2.0)'Image;
pragma Test_Statement;
Wide_Image : Wide_String := Float'Wide_Image (2.0);
pragma Test_Statement;
With_Subscript : String := Float'Image (2.0) (1 .. 2);
pragma Test_Statement;
Slice : String := My_Float'Image (1 .. 2);
pragma Test_Statement;
begin
null;
end Test;
|
twdroeger/ada-awa | Ada | 26,229 | adb | -----------------------------------------------------------------------
-- awa-workspaces-module -- Module workspaces
-- Copyright (C) 2011, 2012, 2013, 2017, 2018, 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.Calendar;
with AWA.Modules.Beans;
with AWA.Modules.Get;
with ADO.SQL;
with ADO.Sessions.Entities;
with ADO.Queries;
with ADO.Statements;
with Security.Policies.Roles;
with Util.Log.Loggers;
with Util.Mail;
with AWA.Users.Modules;
with AWA.Workspaces.Beans;
package body AWA.Workspaces.Modules is
use type ADO.Identifier;
package APS renames AWA.Permissions.Services;
package ASC renames AWA.Services.Contexts;
Log : constant Util.Log.Loggers.Logger := Util.Log.Loggers.Create ("AWA.Workspaces.Module");
package Register is new AWA.Modules.Beans (Module => Workspace_Module,
Module_Access => Workspace_Module_Access);
-- ------------------------------
-- Initialize the workspaces module.
-- ------------------------------
overriding
procedure Initialize (Plugin : in out Workspace_Module;
App : in AWA.Modules.Application_Access;
Props : in ASF.Applications.Config) is
Sec_Manager : constant Security.Policies.Policy_Manager_Access
:= Plugin.Get_Application.Get_Security_Manager;
begin
Log.Info ("Initializing the workspaces module");
-- Register here any bean class, servlet, filter.
Register.Register (Plugin => Plugin,
Name => "AWA.Workspaces.Beans.Workspaces_Bean",
Handler => AWA.Workspaces.Beans.Create_Workspaces_Bean'Access);
Register.Register (Plugin => Plugin,
Name => "AWA.Workspaces.Beans.Member_List_Bean",
Handler => AWA.Workspaces.Beans.Create_Member_List_Bean'Access);
Register.Register (Plugin => Plugin,
Name => "AWA.Workspaces.Beans.Invitation_Bean",
Handler => AWA.Workspaces.Beans.Create_Invitation_Bean'Access);
Register.Register (Plugin => Plugin,
Name => "AWA.Workspaces.Beans.Member_Bean",
Handler => AWA.Workspaces.Beans.Create_Member_Bean'Access);
AWA.Modules.Module (Plugin).Initialize (App, Props);
Plugin.User_Manager := AWA.Users.Modules.Get_User_Manager;
Plugin.Perm_Manager := APS.Permission_Manager'Class (Sec_Manager.all)'Access;
Plugin.Add_Listener (AWA.Users.Modules.NAME, Plugin'Unchecked_Access);
end Initialize;
-- ------------------------------
-- Configures the module after its initialization and after having read its XML configuration.
-- ------------------------------
overriding
procedure Configure (Plugin : in out Workspace_Module;
Props : in ASF.Applications.Config) is
pragma Unreferenced (Props);
List : constant String := Plugin.Get_Config (PARAM_PERMISSIONS_LIST);
begin
Plugin.Owner_Permissions := Ada.Strings.Unbounded.To_Unbounded_String (List);
Plugin.Allow_WS_Create := Plugin.Get_Config (PARAM_ALLOW_WORKSPACE_CREATE);
end Configure;
-- ------------------------------
-- Get the list of permissions for the workspace owner.
-- ------------------------------
function Get_Owner_Permissions (Manager : in Workspace_Module) return Permission_Index_Array is
use Ada.Strings.Unbounded;
begin
return Security.Permissions.Get_Permission_Array (To_String (Manager.Owner_Permissions));
end Get_Owner_Permissions;
-- ------------------------------
-- Get the workspace module.
-- ------------------------------
function Get_Workspace_Module return Workspace_Module_Access is
function Get is new AWA.Modules.Get (Workspace_Module, Workspace_Module_Access, NAME);
begin
return Get;
end Get_Workspace_Module;
-- ------------------------------
-- Get the current workspace associated with the current user.
-- If the user has not workspace, create one.
-- ------------------------------
procedure Get_Workspace (Session : in out ADO.Sessions.Master_Session;
Context : in AWA.Services.Contexts.Service_Context_Access;
Workspace : out AWA.Workspaces.Models.Workspace_Ref) is
User : constant AWA.Users.Models.User_Ref := Context.Get_User;
WS : AWA.Workspaces.Models.Workspace_Ref;
Member : AWA.Workspaces.Models.Workspace_Member_Ref;
Query : ADO.SQL.Query;
Found : Boolean;
Plugin : constant Workspace_Module_Access := Get_Workspace_Module;
begin
if User.Is_Null then
Log.Error ("There is no current user. The workspace cannot be identified");
Workspace := AWA.Workspaces.Models.Null_Workspace;
return;
end if;
-- Find the workspace associated with the current user.
Query.Add_Param (User.Get_Id);
Query.Set_Filter ("o.owner_id = ?");
WS.Find (Session, Query, Found);
if Found then
Workspace := WS;
return;
end if;
-- Check that the user has the permission to create a new workspace.
AWA.Permissions.Check (Permission => ACL_Create_Workspace.Permission,
Entity => User);
-- Create a workspace for this user.
WS.Set_Owner (User);
WS.Set_Create_Date (Ada.Calendar.Clock);
WS.Save (Session);
-- Create the member instance for this user.
Member.Set_Workspace (WS);
Member.Set_Member (User);
Member.Set_Role ("Owner");
Member.Set_Join_Date (ADO.Nullable_Time '(Is_Null => False, Value => WS.Get_Create_Date));
Member.Save (Session);
-- And give full control of the workspace for this user
Add_Permission (Session => Session,
User => User.Get_Id,
Entity => WS,
Workspace => WS.Get_Id,
List => Plugin.Get_Owner_Permissions);
Workspace := WS;
end Get_Workspace;
-- ------------------------------
-- Create a workspace for the user.
-- ------------------------------
procedure Create_Workspace (Module : in Workspace_Module;
Workspace : out AWA.Workspaces.Models.Workspace_Ref) is
Ctx : constant ASC.Service_Context_Access := AWA.Services.Contexts.Current;
User : constant AWA.Users.Models.User_Ref := Ctx.Get_User;
DB : ADO.Sessions.Master_Session := AWA.Services.Contexts.Get_Master_Session (Ctx);
WS : AWA.Workspaces.Models.Workspace_Ref;
Member : AWA.Workspaces.Models.Workspace_Member_Ref;
begin
if User.Is_Null then
Log.Error ("There is no current user. The workspace cannot be identified");
Workspace := AWA.Workspaces.Models.Null_Workspace;
return;
end if;
-- Check that the user has the permission to create a new workspace.
AWA.Permissions.Check (Permission => ACL_Create_Workspace.Permission,
Entity => User);
DB.Begin_Transaction;
-- Create a workspace for this user.
WS.Set_Owner (User);
WS.Set_Create_Date (Ada.Calendar.Clock);
WS.Save (DB);
-- Create the member instance for this user.
Member.Set_Workspace (WS);
Member.Set_Member (User);
Member.Set_Role ("Owner");
Member.Set_Join_Date (ADO.Nullable_Time '(Is_Null => False, Value => WS.Get_Create_Date));
Member.Save (DB);
-- And give full control of the workspace for this user
Add_Permission (Session => DB,
User => User.Get_Id,
Entity => WS,
Workspace => WS.Get_Id,
List => Module.Get_Owner_Permissions);
Workspace := WS;
DB.Commit;
end Create_Workspace;
-- ------------------------------
-- Load the invitation from the access key and verify that the key is still valid.
-- ------------------------------
procedure Load_Invitation (Module : in Workspace_Module;
Key : in String;
Invitation : in out AWA.Workspaces.Models.Invitation_Ref'Class;
Inviter : in out AWA.Users.Models.User_Ref) is
pragma Unreferenced (Module);
use type Ada.Calendar.Time;
Ctx : constant ASC.Service_Context_Access := AWA.Services.Contexts.Current;
DB : ADO.Sessions.Master_Session := AWA.Services.Contexts.Get_Master_Session (Ctx);
Query : ADO.SQL.Query;
DB_Key : AWA.Users.Models.Access_Key_Ref;
Found : Boolean;
begin
Log.Debug ("Loading invitation from key {0}", Key);
Query.Set_Filter ("o.access_key = :key");
Query.Bind_Param ("key", Key);
DB_Key.Find (DB, Query, Found);
if not Found then
Log.Info ("Invitation key {0} does not exist");
raise Not_Found;
end if;
if DB_Key.Get_Expire_Date < Ada.Calendar.Clock then
Log.Info ("Invitation key {0} has expired");
raise Not_Found;
end if;
Query.Set_Filter ("o.invitee_id = :user");
Query.Bind_Param ("user", DB_Key.Get_User.Get_Id);
Invitation.Find (DB, Query, Found);
if not Found then
Log.Warn ("Invitation key {0} has been withdawn");
raise Not_Found;
end if;
Inviter := AWA.Users.Models.User_Ref (Invitation.Get_Inviter);
end Load_Invitation;
-- ------------------------------
-- Accept the invitation identified by the access key.
-- ------------------------------
procedure Accept_Invitation (Module : in Workspace_Module;
Key : in String) is
use type Ada.Calendar.Time;
Ctx : constant ASC.Service_Context_Access := AWA.Services.Contexts.Current;
User : constant AWA.Users.Models.User_Ref := Ctx.Get_User;
DB : ADO.Sessions.Master_Session := AWA.Services.Contexts.Get_Master_Session (Ctx);
Query : ADO.SQL.Query;
DB_Key : AWA.Users.Models.Access_Key_Ref;
Found : Boolean;
Invitation : AWA.Workspaces.Models.Invitation_Ref;
Invitee_Id : ADO.Identifier;
Workspace_Id : ADO.Identifier;
Member : AWA.Workspaces.Models.Workspace_Member_Ref;
User_Member : AWA.Workspaces.Models.Workspace_Member_Ref;
Now : constant Ada.Calendar.Time := Ada.Calendar.Clock;
begin
Log.Debug ("Accept invitation with key {0}", Key);
Ctx.Start;
-- Get the access key and verify its validity.
Query.Set_Filter ("o.access_key = :key");
Query.Bind_Param ("key", Key);
DB_Key.Find (DB, Query, Found);
if not Found then
Log.Info ("Invitation key {0} does not exist", Key);
raise Not_Found;
end if;
if DB_Key.Get_Expire_Date < Now then
Log.Info ("Invitation key {0} has expired", Key);
raise Not_Found;
end if;
-- Find the invitation associated with the access key.
Invitee_Id := DB_Key.Get_User.Get_Id;
Query.Set_Filter ("o.invitee_id = :user");
Query.Bind_Param ("user", Invitee_Id);
Invitation.Find (DB, Query, Found);
if not Found then
Log.Warn ("Invitation key {0} has been withdawn", Key);
raise Not_Found;
end if;
Member := AWA.Workspaces.Models.Workspace_Member_Ref (Invitation.Get_Member);
Workspace_Id := Invitation.Get_Workspace.Get_Id;
-- Update the workspace member relation.
Member.Set_Join_Date (ADO.Nullable_Time '(Is_Null => False,
Value => Now));
Invitation.Set_Acceptance_Date (ADO.Nullable_Time '(Is_Null => False,
Value => Now));
-- The user who received the invitation is different from the user who is
-- logged and accepted the validation. Since the key is verified, this is
-- the same user but the user who accepted the invitation registered using
-- another email address.
if Invitee_Id /= User.Get_Id then
-- Check whether the user is not already part of the workspace.
Query.Clear;
Query.Set_Filter ("o.member_id = ? AND o.workspace_id = ?");
Query.Add_Param (User.Get_Id);
Query.Add_Param (Workspace_Id);
User_Member.Find (DB, Query, Found);
if Found then
Member.Delete (DB);
Invitation.Delete (DB);
Log.Info ("Invitation accepted by user who is already a member");
else
Member.Set_Member (User);
Log.Info ("Invitation accepted by user with another email address");
Invitation.Set_Invitee (User);
end if;
end if;
if not Member.Is_Null then
Member.Save (DB);
end if;
DB_Key.Delete (DB);
if not Invitation.Is_Null then
Invitation.Save (DB);
-- Send the accepted invitation event.
declare
Event : AWA.Events.Module_Event;
begin
Event.Set_Parameter ("invitee_email", User.Get_Email.Get_Email);
Event.Set_Parameter ("invitee_name", User.Get_Name);
Event.Set_Parameter ("message", Invitation.Get_Message);
Event.Set_Parameter ("inviter_email", Invitation.Get_Inviter.Get_Email.Get_Email);
Event.Set_Parameter ("inviter_name", Invitation.Get_Inviter.Get_Name);
Event.Set_Event_Kind (Accept_Invitation_Event.Kind);
Module.Send_Event (Event);
end;
end if;
Ctx.Commit;
end Accept_Invitation;
-- ------------------------------
-- Send the invitation to the user.
-- ------------------------------
procedure Send_Invitation (Module : in Workspace_Module;
Invitation : in out AWA.Workspaces.Models.Invitation_Ref'Class) is
Ctx : constant ASC.Service_Context_Access := AWA.Services.Contexts.Current;
DB : ADO.Sessions.Master_Session := AWA.Services.Contexts.Get_Master_Session (Ctx);
User : constant AWA.Users.Models.User_Ref := Ctx.Get_User;
WS : AWA.Workspaces.Models.Workspace_Ref;
Query : ADO.SQL.Query;
Found : Boolean;
Key : AWA.Users.Models.Access_Key_Ref;
Email : AWA.Users.Models.Email_Ref;
Invitee : AWA.Users.Models.User_Ref;
Invit : AWA.Workspaces.Models.Invitation_Ref;
Member : AWA.Workspaces.Models.Workspace_Member_Ref;
Invite_Address : constant String := Invitation.Get_Email;
Email_Address : constant Util.Mail.Email_Address
:= Util.Mail.Parse_Address (Invite_Address);
begin
Log.Info ("Sending invitation to {0}", Invite_Address);
if User.Is_Null then
Log.Error ("There is no current user. The workspace cannot be identified");
return;
end if;
-- Find the workspace associated with the current user.
Query.Set_Join ("INNER JOIN awa_workspace_member AS m ON m.workspace_id = o.id");
Query.Set_Filter ("m.member_id = ?");
Query.Add_Param (User.Get_Id);
WS.Find (DB, Query, Found);
if not Found then
Log.Error ("The current user has no associated workspace");
return;
end if;
-- Check that the user has the permission to invite users in the workspace.
AWA.Permissions.Check (Permission => ACL_Invite_User.Permission,
Entity => WS);
Ctx.Start;
Query.Clear;
Query.Set_Filter ("o.email = ?");
Query.Add_Param (Email_Address.Address);
Email.Find (DB, Query, Found);
if not Found then
Email.Set_User_Id (0);
Email.Set_Email (Email_Address.Address);
Email.Save (DB);
Invitee.Set_Email (Email);
Invitee.Set_Name (Email_Address.Name);
Invitee.Set_First_Name (Util.Mail.Get_First_Name (Email_Address));
Invitee.Set_Last_Name (Util.Mail.Get_Last_Name (Email_Address));
Invitee.Save (DB);
Email.Set_User_Id (Invitee.Get_Id);
Email.Save (DB);
else
Invitee.Load (DB, Email.Get_User_Id);
end if;
-- Create the workspace member relation.
Query.Clear;
Query.Set_Filter ("o.member_id = ? AND o.workspace_id = ?");
Query.Add_Param (Invitee.Get_Id);
Query.Add_Param (WS.Get_Id);
Member.Find (DB, Query, Found);
if not Found then
Member.Set_Member (Invitee);
Member.Set_Workspace (WS);
Member.Set_Role ("Invited");
Member.Save (DB);
end if;
-- Check for a previous invitation for the user and delete it.
Query.Set_Filter ("o.invitee_id = ? AND o.workspace_id = ?");
Invit.Find (DB, Query, Found);
if Found then
Key := AWA.Users.Models.Access_Key_Ref (Invit.Get_Access_Key);
Key.Delete (DB);
if not Invitation.Is_Inserted or else Invit.Get_Id /= Invitation.Get_Id then
Invit.Delete (DB);
end if;
end if;
Key := AWA.Users.Models.Access_Key_Ref (Invitation.Get_Access_Key);
Module.User_Manager.Create_Access_Key (Invitee, Key, AWA.Users.Models.INVITATION_KEY,
365 * 86400.0, DB);
Key.Save (DB);
Invitation.Set_Access_Key (Key);
Invitation.Set_Inviter (User);
Invitation.Set_Invitee (Invitee);
Invitation.Set_Workspace (WS);
Invitation.Set_Create_Date (Ada.Calendar.Clock);
Invitation.Set_Member (Member);
Invitation.Save (DB);
-- Send the email with the reset password key
declare
Event : AWA.Events.Module_Event;
begin
Event.Set_Parameter ("key", Key.Get_Access_Key);
Event.Set_Parameter ("email", Ada.Strings.Unbounded.To_String (Email_Address.Address));
Event.Set_Parameter ("name", Invitee.Get_Name);
Event.Set_Parameter ("message", Invitation.Get_Message);
Event.Set_Parameter ("inviter", User.Get_Name);
Event.Set_Event_Kind (Invite_User_Event.Kind);
Module.Send_Event (Event);
end;
Ctx.Commit;
end Send_Invitation;
-- ------------------------------
-- Delete the member from the workspace. Remove the invitation if there is one.
-- ------------------------------
procedure Delete_Member (Module : in Workspace_Module;
Member_Id : in ADO.Identifier) is
pragma Unreferenced (Module);
Ctx : constant ASC.Service_Context_Access := AWA.Services.Contexts.Current;
DB : ADO.Sessions.Master_Session := AWA.Services.Contexts.Get_Master_Session (Ctx);
User : constant AWA.Users.Models.User_Ref := Ctx.Get_User;
Query : ADO.SQL.Query;
Found : Boolean;
Key : AWA.Users.Models.Access_Key_Ref;
Member : AWA.Workspaces.Models.Workspace_Member_Ref;
Invitation : AWA.Workspaces.Models.Invitation_Ref;
User_Id : ADO.Identifier;
Workspace_Id : ADO.Identifier;
User_Image : constant String := ADO.Identifier'Image (Member_Id);
begin
Log.Info ("Delete user member {0}", User_Image);
-- Get the workspace member instance for the user and remove it.
Member.Load (DB, Member_Id, Found);
if not Found then
Log.Error ("User member {0} does not exist", User_Image);
return;
end if;
User_Id := Member.Get_Member.Get_Id;
Workspace_Id := Member.Get_Workspace.Get_Id;
if User.Get_Id = User_Id then
Log.Warn ("Refusing to delete the current user {0}", User_Image);
return;
end if;
-- Check that the user has the permission to delete users from the workspace.
AWA.Permissions.Check (Permission => ACL_Delete_User.Permission,
Entity => Workspace_Id);
Ctx.Start;
Member.Delete (DB);
-- Get the invitation and remove it.
Query.Set_Filter ("o.member_id = ?");
Query.Add_Param (Member_Id);
Invitation.Find (DB, Query, Found);
if Found then
Key := AWA.Users.Models.Access_Key_Ref (Invitation.Get_Access_Key);
Key.Delete (DB);
Invitation.Delete (DB);
end if;
-- Remove all permissions assigned to the user in the workspace.
AWA.Permissions.Services.Delete_Permissions (DB, User_Id, Workspace_Id);
Ctx.Commit;
end Delete_Member;
-- ------------------------------
-- Add a list of permissions for all the users of the workspace that have the appropriate
-- role. Workspace members will be able to access the given database entity for the
-- specified list of permissions.
-- ------------------------------
procedure Add_Permission (Session : in out ADO.Sessions.Master_Session;
User : in ADO.Identifier;
Entity : in ADO.Objects.Object_Ref'Class;
Workspace : in ADO.Identifier;
List : in Security.Permissions.Permission_Index_Array) is
Ctx : constant ASC.Service_Context_Access := AWA.Services.Contexts.Current;
Key : constant ADO.Objects.Object_Key := Entity.Get_Key;
Id : constant ADO.Identifier := ADO.Objects.Get_Value (Key);
Kind : constant ADO.Entity_Type
:= ADO.Sessions.Entities.Find_Entity_Type (Session => Session,
Object => Key);
Manager : constant AWA.Permissions.Services.Permission_Manager_Access
:= AWA.Permissions.Services.Get_Permission_Manager (Ctx);
begin
for Perm of List loop
declare
Member : ADO.Identifier;
Query : ADO.Queries.Context;
Names : constant Security.Policies.Roles.Role_Name_Array
:= Manager.Get_Role_Names (Perm);
Need_Sep : Boolean := False;
User_Added : Boolean := False;
begin
if Names'Length > 0 then
Query.Set_Query (AWA.Workspaces.Models.Query_Member_In_Role);
ADO.SQL.Append (Query.Filter, "user_member.workspace_id = :workspace_id");
ADO.SQL.Append (Query.Filter, " AND user_member.role IN (");
for Name of Names loop
ADO.SQL.Append (Query.Filter, (if Need_Sep then ",?" else "?"));
Query.Add_Param (Name.all);
Need_Sep := True;
end loop;
Query.Bind_Param ("workspace_id", Workspace);
ADO.SQL.Append (Query.Filter, ")");
declare
Stmt : ADO.Statements.Query_Statement := Session.Create_Statement (Query);
begin
Stmt.Execute;
while Stmt.Has_Elements loop
Member := Stmt.Get_Identifier (0);
if Member = User then
User_Added := True;
end if;
Manager.Add_Permission (Session => Session,
User => Member,
Entity => Id,
Kind => Kind,
Workspace => Workspace,
Permission => Perm);
Stmt.Next;
end loop;
end;
end if;
if not User_Added then
Manager.Add_Permission (Session => Session,
User => User,
Entity => Id,
Kind => Kind,
Workspace => Workspace,
Permission => Perm);
end if;
end;
end loop;
end Add_Permission;
-- ------------------------------
-- The `On_Create` procedure is called by `Notify_Create` to notify the creation of the user.
-- ------------------------------
overriding
procedure On_Create (Module : in Workspace_Module;
User : in AWA.Users.Models.User_Ref'Class) is
Ctx : constant ASC.Service_Context_Access := ASC.Current;
Kind : ADO.Entity_Type;
begin
if Module.Allow_WS_Create then
declare
DB : ADO.Sessions.Master_Session := ASC.Get_Master_Session (Ctx);
begin
Ctx.Start;
Kind := ADO.Sessions.Entities.Find_Entity_Type (DB, Models.WORKSPACE_TABLE);
Module.Perm_Manager.Add_Permission (Session => DB,
User => User.Get_Id,
Entity => ADO.NO_IDENTIFIER,
Kind => Kind,
Workspace => ADO.NO_IDENTIFIER,
Permission => ACL_Create_Workspace.Permission);
Ctx.Commit;
end;
end if;
end On_Create;
end AWA.Workspaces.Modules;
|
reznikmm/matreshka | Ada | 9,272 | adb | ------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- Web Framework --
-- --
-- Runtime Library Component --
-- --
------------------------------------------------------------------------------
-- --
-- Copyright © 2016-2017, Vadim Godunko <[email protected]> --
-- All rights reserved. --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions --
-- are met: --
-- --
-- * Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- --
-- * Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in the --
-- documentation and/or other materials provided with the distribution. --
-- --
-- * Neither the name of the Vadim Godunko, IE nor the names of its --
-- contributors may be used to endorse or promote products derived from --
-- this software without specific prior written permission. --
-- --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR --
-- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
-- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED --
-- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR --
-- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF --
-- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING --
-- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS --
-- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
-- --
------------------------------------------------------------------------------
-- $Revision$ $Date$
------------------------------------------------------------------------------
with WebAPI.HTML.Globals;
package body WUI.Widgets.Spin_Boxes.Generic_Integers is
procedure Internal_Set_Value
(Self : in out Integer_Spin_Box'Class;
To : Data_Type;
Update : Boolean);
-- Sets value, emit signal when value was modified, and update value of
-- input element when Update is True.
------------------
-- Change_Event --
------------------
overriding procedure Change_Event (Self : in out Integer_Spin_Box) is
Input : constant WebAPI.HTML.Input_Elements.HTML_Input_Element_Access
:= WebAPI.HTML.Input_Elements.HTML_Input_Element_Access
(Self.Element);
begin
if not Input.Get_Validity.Get_Valid then
if Input.Get_Validity.Get_Bad_Input then
Self.Internal_Set_Value
(Data_Type'Wide_Wide_Value
(League.Strings.To_Wide_Wide_String (Input.Get_Min)), True);
elsif Input.Get_Validity.Get_Range_Overflow then
Self.Internal_Set_Value
(Data_Type'Wide_Wide_Value
(League.Strings.To_Wide_Wide_String (Input.Get_Max)), True);
elsif Input.Get_Validity.Get_Range_Underflow then
Self.Internal_Set_Value
(Data_Type'Wide_Wide_Value
(League.Strings.To_Wide_Wide_String (Input.Get_Min)), True);
elsif Input.Get_Validity.Get_Value_Missing then
Self.Internal_Set_Value
(Data_Type'Wide_Wide_Value
(League.Strings.To_Wide_Wide_String (Input.Get_Min)), True);
end if;
end if;
Self.Editing_Finished.Emit;
end Change_Event;
------------------
-- Constructors --
------------------
package body Constructors is
type Integer_Spin_Box_Internal_Access is
access all Integer_Spin_Box'Class;
------------
-- Create --
------------
function Create
(Element :
not null WebAPI.HTML.Input_Elements.HTML_Input_Element_Access)
return not null Integer_Spin_Box_Access
is
Result : constant not null Integer_Spin_Box_Internal_Access
:= new Integer_Spin_Box;
begin
Initialize (Result.all, Element);
return Integer_Spin_Box_Access (Result);
end Create;
------------
-- Create --
------------
function Create
(Id : League.Strings.Universal_String)
return not null Integer_Spin_Box_Access is
begin
return
Create
(WebAPI.HTML.Input_Elements.HTML_Input_Element_Access
(WebAPI.HTML.Globals.Window.Get_Document.Get_Element_By_Id
(Id)));
end Create;
----------------
-- Initialize --
----------------
procedure Initialize
(Self : in out Integer_Spin_Box'Class;
Element :
not null WebAPI.HTML.Input_Elements.HTML_Input_Element_Access) is
begin
WUI.Widgets.Spin_Boxes.Constructors.Initialize (Self, Element);
-- Extract properties value from HTML element.
Self.Last_Value :=
Data_Type'Wide_Wide_Value
(League.Strings.To_Wide_Wide_String (Element.Get_Value));
end Initialize;
end Constructors;
-----------------
-- Input_Event --
-----------------
overriding procedure Input_Event (Self : in out Integer_Spin_Box) is
Input : constant WebAPI.HTML.Input_Elements.HTML_Input_Element_Access
:= WebAPI.HTML.Input_Elements.HTML_Input_Element_Access
(Self.Element);
begin
if Input.Get_Validity.Get_Valid then
Self.Last_Value :=
Data_Type'Wide_Wide_Value
(League.Strings.To_Wide_Wide_String
(WebAPI.HTML.Input_Elements.HTML_Input_Element_Access
(Self.Element).Get_Value));
Self.Value_Changed.Emit (Self.Last_Value);
end if;
end Input_Event;
------------------------
-- Internal_Set_Value --
------------------------
procedure Internal_Set_Value
(Self : in out Integer_Spin_Box'Class;
To : Data_Type;
Update : Boolean)
is
Input : constant WebAPI.HTML.Input_Elements.HTML_Input_Element_Access
:= WebAPI.HTML.Input_Elements.HTML_Input_Element_Access
(Self.Element);
begin
if Self.Last_Value /= To then
Self.Last_Value := To;
Input.Set_Value
(League.Strings.To_Universal_String
(Data_Type'Wide_Wide_Image (To)));
Self.Value_Changed.Emit (To);
-- 'input' event is not send when value is changed programmatically.
elsif Update then
Input.Set_Value
(League.Strings.To_Universal_String
(Data_Type'Wide_Wide_Image (To)));
end if;
end Internal_Set_Value;
---------------
-- Step_Down --
---------------
overriding procedure Step_Down (Self : in out Integer_Spin_Box) is
begin
raise Program_Error;
end Step_Down;
-------------
-- Step_Up --
-------------
overriding procedure Step_Up (Self : in out Integer_Spin_Box) is
begin
raise Program_Error;
end Step_Up;
---------------
-- Set_Value --
---------------
not overriding procedure Set_Value
(Self : in out Integer_Spin_Box;
To : Data_Type) is
begin
Self.Internal_Set_Value (To, False);
end Set_Value;
-----------
-- Value --
-----------
not overriding function Value (Self : Integer_Spin_Box) return Data_Type is
begin
return Self.Last_Value;
end Value;
--------------------------
-- Value_Changed_Signal --
--------------------------
not overriding function Value_Changed_Signal
(Self : in out Integer_Spin_Box)
return not null access Integer_Slots.Signal'Class is
begin
return Self.Value_Changed'Unchecked_Access;
end Value_Changed_Signal;
end WUI.Widgets.Spin_Boxes.Generic_Integers;
|
jwarwick/aoc_2020 | Ada | 221 | ads | -- AOC 2020, Day 7
package Day is
function valid_bag_colors return Natural;
function valid_test_bag_colors return Natural;
function nested_bags return Natural;
function nested_test_bags return Natural;
end Day;
|
AdaCore/gpr | Ada | 103 | adb | with Ada.Text_IO;
procedure Print (Text : String) is
begin
Ada.Text_IO.Put_Line (Text);
end Print;
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.