repo_name
stringlengths 9
74
| language
stringclasses 1
value | length_bytes
int64 11
9.34M
| extension
stringclasses 2
values | content
stringlengths 11
9.34M
|
---|---|---|---|---|
msrLi/portingSources | Ada | 994 | ads | -- Copyright 2010-2014 Free Software Foundation, Inc.
--
-- This program is free software; you can redistribute it and/or modify
-- it under the terms of the GNU General Public License as published by
-- the Free Software Foundation; either version 3 of the License, or
-- (at your option) any later version.
--
-- This program is distributed in the hope that it will be useful,
-- but WITHOUT ANY WARRANTY; without even the implied warranty of
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-- GNU General Public License for more details.
--
-- You should have received a copy of the GNU General Public License
-- along with this program. If not, see <http://www.gnu.org/licenses/>.
package Pck is
type Shape is abstract tagged record
X, Y: Integer;
end record;
function Position_X (S : in Shape) return Integer;
type Circle is new Shape with record
R : Integer;
end record;
function Area (C : in Circle) return Integer;
end Pck;
|
burratoo/Acton | Ada | 934 | ads | ------------------------------------------------------------------------------------------
-- --
-- OAK COMPONENTS --
-- --
-- OAK.MEMORY --
-- --
-- Copyright (C) 2010-2021, Patrick Bernardi --
-- --
------------------------------------------------------------------------------------------
package Oak.Memory with Pure is
-- type Memory_Slice is access all Storage_Array;
private
end Oak.Memory;
|
AntoineLestrade/Automatic_Shutdown | Ada | 8,883 | adb | with Ada.Unchecked_Conversion;
with Glib; use Glib;
with Glib.Object; use Glib.Object;
with Glib.Values;
with Gtk.Arguments; use Gtk.Arguments;
with Gtk.Box; use Gtk.Box;
with Gtk.Button;
with Gtk.Button_Box;
with Gtk.Cell_Renderer_Text;
with Gtk.Combo_Box_Text;
with Gtk.Enums;
with Gtk.Handlers;
with Gtk.Label; use Gtk.Label;
with Gtk.Stock;
with Gtk.List_Store;use Gtk.List_Store;
with Gtk.Tree_Model;
with Gtkada.Bindings; use Gtkada.Bindings;
with Gtkada.Types; use Gtkada.Types;
with System;
with Widgets.Edit_Widget; use Widgets.Edit_Widget;
package body Widgets.Edit_Widget is
Klass : aliased Ada_Gobject_Class := Uninitialized_Class;
Signals : Chars_Ptr_Array := String (Signal_Submit) + String (Signal_Exit);
procedure Class_Init (Self : Gobject_Class);
pragma Convention (C, Class_Init);
procedure Class_Init (Self : Gobject_Class) is
begin
-- Set properties handler
null;
end Class_Init;
function Get_Type return Gtype is
begin
if Initialize_Class_Record
(Ancestor => Gtk.Box.Get_Vbox_Type,
Class_Record => Klass'Access,
Type_Name => "Edit_Widget",
Signals => Signals)
then
--Info := new GInterface_Info'(nul, null, System.Address);
--Add_Interface(Klass, Gtk.Box.Get_Vbox_Type, Info);
null;
end if;
return Klass.The_Type;
end Get_Type;
-------------
-- Gtk_New --
-------------
procedure Gtk_New (Self : out Edit_Widget_Acc_Class) is
begin
Self := new Edit_Widget_Record;
Widgets.Edit_Widget.Initialize (Self);
end Gtk_New;
----------------
-- Initialize --
----------------
procedure Initialize (Self : access Edit_Widget_Record'Class) is
Bx_Labels : Gtk.Box.Gtk_Hbox;
Bx_Buttons : Gtk.Button_Box.Gtk_Button_Box;
Btn : Gtk.Button.Gtk_Button;
Dummy_Bool : Boolean;
--List : Gtk_List_Store;
--List_Item : Gtk.Tree_Model.Gtk_Tree_Iter;
--Render : Gtk.Cell_Renderer_Text.Gtk_Cell_Renderer_Text;
begin
G_New(Object => Self,
Typ => Get_Type);
Gtk.Box.Initialize_Vbox (Box => Self);
--Gtk.Cell_Renderer_Text.Gtk_New(Render);
Gtk.Box.Gtk_New_Hbox(Box => Bx_Labels);
Bx_Labels.Pack_Start(Gtk.Label.Gtk_Label_New("Turn computer off in"), Expand => False);
-- Hours cb
-- Gtk.List_Store.Gtk_New(List, (0 => GType_String, 1 => GType_Int));
-- List.Append(List_Item);
-- List.Set(List_Item, 0, "0"); List.Set(List_Item, 1, 0);
-- List.Append(List_Item);
-- List.Set(List_Item, 0, "1"); List.Set(List_Item, 1, 1);
-- List.Append(List_Item);
-- List.Set(List_Item, 0, "2"); List.Set(List_Item, 1, 2);
-- List.Append(List_Item);
-- List.Set(List_Item, 0, "3"); List.Set(List_Item, 1, 3);
-- List.Append(List_Item);
-- List.Set(List_Item, 0, "4"); List.Set(List_Item, 1, 4);
-- List.Append(List_Item);
-- List.Set(List_Item, 0, "5"); List.Set(List_Item, 1, 5);
--
-- Gtk.Combo_Box.Gtk_New_With_Model(Cb, +List);
-- Cb.Pack_Start(Render, Expand=>True);
-- Cb.Add_Attribute(Render, "text", 0);
-- Cb.Add_Attribute(Render, "sensitive", 1);
-- Cb.Set_Id_Column(Id_Column => 1);
Gtk.Combo_Box_Text.Gtk_New(Self.Cb_Hours);
Self.Cb_Hours.Append_Text("0");
Self.Cb_Hours.Append_Text("1");
Self.Cb_Hours.Append_Text("2");
Self.Cb_Hours.Append_Text("3");
Self.Cb_Hours.Append_Text("5");
Dummy_Bool := Self.Cb_Hours.Set_Active_Id("2");
Bx_Labels.Pack_Start(Self.Cb_Hours);
Bx_Labels.Pack_Start(Gtk_Label_New("hours"));
-- Gtk.List_Store.Gtk_New(List, (0 => GType_String, 1 => GType_Int));
-- List.Append(List_Item);
-- List.Set(List_Item, 0, "0"); List.Set(List_Item, 1, 0);
-- List.Append(List_Item);
-- List.Set(List_Item, 0, "10"); List.Set(List_Item, 1, 10);
-- List.Append(List_Item);
-- List.Set(List_Item, 0, "20"); List.Set(List_Item, 1, 20);
-- List.Append(List_Item);
-- List.Set(List_Item, 0, "30"); List.Set(List_Item, 1, 30);
-- List.Append(List_Item);
-- List.Set(List_Item, 0, "40"); List.Set(List_Item, 1, 40);
-- List.Append(List_Item);
-- List.Set(List_Item, 0, "50"); List.Set(List_Item, 1, 50);
--
-- Gtk.Combo_Box.Gtk_New_With_Model(Cb, +List);
-- Cb.Pack_Start(Render, Expand=>True);
-- Cb.Add_Attribute(Render, "text", 0);
-- Cb.Add_Attribute(Render, "sensitive", 1);
-- Cb.Set_Id_Column(Id_Column => 1);
Gtk.Combo_Box_Text.Gtk_New(Self.Cb_Minutes);
Self.Cb_Minutes.Append_Text("0");
Self.Cb_Minutes.Append_Text("10");
Self.Cb_Minutes.Append_Text("20");
Self.Cb_Minutes.Append_Text("30");
Self.Cb_Minutes.Append_Text("40");
Self.Cb_Minutes.Append_Text("50");
Dummy_Bool := Self.Cb_Minutes.Set_Active_Id("0");
Bx_Labels.Pack_Start(Self.Cb_Minutes);
Bx_Labels.Pack_Start(Gtk_Label_New("minutes."));
Gtk.Button_Box.Gtk_New(Widget => Bx_Buttons,
Orientation => Gtk.Enums.Orientation_Horizontal);
Bx_Buttons.Set_Layout(Layout_Style => Gtk.Enums.Buttonbox_Spread);
Gtk.Button.Gtk_New(Btn, "Launch");
Bx_Buttons.Add(Btn);
Btn.On_Clicked(On_Bt_Launch_Click'Unrestricted_Access, Self);
Gtk.Button.Gtk_New_From_Stock(Btn, Gtk.Stock.Stock_Close);
Bx_Buttons.Add(Btn);
Btn.On_CLicked(On_Bt_Exit_Click'Unrestricted_Access, Self);
Self.Pack_Start (Bx_Labels);
Self.Pack_Start (Bx_Buttons);
-- Self.Bt_Test.On_Clicked
-- (On_Bt_Test_Click'Unrestricted_Access, Slot => Self);
end Initialize;
function Get_Delay(Self : not null access Edit_Widget_Record'Class) return Duration is
begin
return Duration(Integer'Value(Self.Cb_Hours.Get_Active_Text) * 3600 + Integer'Value(Self.Cb_Minutes.Get_Active_Text) * 60);
end Get_Delay;
-----------------------------------------------------------------------------
--- Callbacks
-----------------------------------------------------------------------------
function Address_To_Cb is new Ada.Unchecked_Conversion
(System.Address,
Cb_Edit_Widget_Target);
function Cb_To_Address is new Ada.Unchecked_Conversion
(Cb_Edit_Widget_Target,
System.Address);
package Internal_Cb is new Gtk.Handlers.Callback (Edit_Widget_Record);
procedure Marsh_Cb_Edit_Widget_Target
(Closure : Gclosure;
Return_Value : Glib.Values.Gvalue;
N_Params : Glib.Guint;
Params : Glib.Values.C_Gvalues;
Invocation_Hint : System.Address;
User_Data : System.Address);
pragma Convention (C, Marsh_Cb_Edit_Widget_Target);
procedure Marsh_Cb_Edit_Widget_Target
(Closure : Gclosure;
Return_Value : Glib.Values.Gvalue;
N_Params : Glib.Guint;
Params : Glib.Values.C_Gvalues;
Invocation_Hint : System.Address;
User_Data : System.Address)
is
pragma Unreferenced (Return_Value, N_Params, Invocation_Hint, User_Data);
H : constant Cb_Edit_Widget_Target :=
Address_To_Cb (Get_Callback (Closure));
Obj : constant Edit_Widget_Acc_Class :=
Edit_Widget_Acc_Class (Unchecked_To_Object (Params, 0));
begin
H (Obj);
exception
when E : others =>
Process_Exception (E);
end Marsh_Cb_Edit_Widget_Target;
PROCEDURE Connect
(Object : ACCESS Edit_Widget_Record'Class;
C_Name : Glib.Signal_Name;
Handler : Cb_Edit_Widget_Target;
After : Boolean) IS
BEGIN
Unchecked_Do_Signal_Connect
(Object => Object,
C_Name => C_Name & ASCII.NUL,
Marshaller => Marsh_Cb_Edit_Widget_Target'Access,
Handler => Cb_To_Address (Handler),
After => After);
END Connect;
procedure On_Submit
(Self : not null access Edit_Widget_Record;
Call : Cb_Edit_Widget_Target;
After : Boolean := False)
is
begin
Connect(Self, Signal_Submit, Call, After);
end On_Submit;
procedure On_Exit(Self : not null access Edit_Widget_Record;
Call : Cb_Edit_Widget_Target;
After : Boolean := False) is
begin
Connect(Self, Signal_Exit, Call, After);
end On_Exit;
procedure On_Bt_Launch_Click (Self : access Gobject_Record'Class) is
begin
Internal_Cb.Emit_By_Name (Edit_Widget_Acc_Class (Self), Signal_Submit);
end On_Bt_Launch_Click;
procedure On_Bt_Exit_Click(Self: access GObject_Record'Class) is
begin
Internal_Cb.Emit_By_Name(Edit_Widget_Acc_Class(Self), Signal_Exit);
end On_Bt_Exit_Click;
end Widgets.Edit_Widget;
|
AdaCore/Ada_Drivers_Library | Ada | 4,606 | adb | ------------------------------------------------------------------------------
-- --
-- Copyright (C) 2016, AdaCore --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions are --
-- met: --
-- 1. Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- 2. Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in --
-- the documentation and/or other materials provided with the --
-- distribution. --
-- 3. Neither the name of the copyright holder nor the names of its --
-- contributors may be used to endorse or promote products derived --
-- from this software without specific prior written permission. --
-- --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR --
-- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
-- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT --
-- LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, --
-- DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY --
-- THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT --
-- (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE --
-- OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
-- --
------------------------------------------------------------------------------
with Interfaces; use Interfaces;
package body Simple_Synthesizer is
------------------------
-- Set_Note_Frequency --
------------------------
procedure Set_Note_Frequency
(This : in out Synthesizer;
Note : Float)
is
begin
This.Note := Note;
end Set_Note_Frequency;
-------------------
-- Set_Frequency --
-------------------
overriding procedure Set_Frequency
(This : in out Synthesizer;
Frequency : Audio_Frequency)
is
begin
This.Frequency := Frequency;
end Set_Frequency;
--------------
-- Transmit --
--------------
overriding procedure Transmit
(This : in out Synthesizer;
Data : Audio_Buffer)
is
begin
raise Program_Error with "This Synthesizer doesn't take input";
end Transmit;
-------------
-- Receive --
-------------
overriding procedure Receive
(This : in out Synthesizer;
Data : out Audio_Buffer)
is
function Next_Sample return Integer_16;
Rate : constant Float :=
Float (Audio_Frequency'Enum_Rep (This.Frequency));
Note : constant Float := This.Note;
Amplitude : constant Float := Float (This.Amplitude);
Delt : constant Float := 2.0 / (Rate * (1.0 / Note));
-----------------
-- Next_Sample --
-----------------
function Next_Sample return Integer_16 is
begin
This.Last_Sample := This.Last_Sample + Delt;
if This.Last_Sample > 1.0 then
This.Last_Sample := -1.0;
end if;
return Integer_16 (This.Last_Sample * Amplitude);
end Next_Sample;
Tmp : Integer_16;
begin
if This.Stereo then
if Data'Length mod 2 /= 0 then
raise Program_Error with
"Audio buffer for stereo output should have even length";
end if;
for Index in 0 .. (Data'Length / 2) - 1 loop
Tmp := Next_Sample;
Data ((Index * 2) + Data'First) := Tmp;
Data ((Index * 2) + Data'First + 1) := Tmp;
end loop;
else
for Elt of Data loop
Elt := Next_Sample;
end loop;
end if;
end Receive;
end Simple_Synthesizer;
|
stcarrez/ada-ado | Ada | 2,268 | adb | -----------------------------------------------------------------------
-- ado-sql-tests -- SQL tests
-- Copyright (C) 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 Util.Test_Caller;
package body ADO.SQL.Tests is
package Caller is new Util.Test_Caller (Test, "ADO.SQL");
procedure Add_Tests (Suite : in Util.Tests.Access_Test_Suite) is
begin
Caller.Add_Test (Suite, "Test ADO.SQL.Read_File",
Test_Read_File'Access);
end Add_Tests;
-- ------------------------------
-- Test Read_SQL file and spliting a file in SQL statements.
-- ------------------------------
procedure Test_Read_File (T : in out Test) is
procedure Process (SQL : in String);
Count : Natural := 0;
procedure Process (SQL : in String) is
begin
T.Assert_Equals (")", SQL (SQL'Last .. SQL'Last));
if SQL (SQL'First) = 'I' then
Util.Tests.Assert_Matches (T, "INSERT .*", SQL,
"invalid SQL");
else
Util.Tests.Assert_Matches (T, ".*CREATE TABLE.*", SQL,
"invalid SQL");
end if;
Count := Count + 1;
end Process;
begin
ADO.SQL.Read_File ("regtests/files/read-1.sql", Process'Access);
Util.Tests.Assert_Equals (T, 6, Count, "Invalid number of SQL statements");
Count := 0;
ADO.SQL.Read_File ("regtests/files/read-2.sql", Process'Access);
Util.Tests.Assert_Equals (T, 3, Count, "Invalid number of SQL statements");
end Test_Read_File;
end ADO.SQL.Tests;
|
reznikmm/matreshka | Ada | 2,138 | adb |
with Text_IO, Ayacc_File_Names;
use Text_IO, Ayacc_File_Names;
package body Shift_Reduce_File is
SCCS_ID : constant String := "@(#) shift_reduce_file.ada, Version 1.2";
Rcs_ID : constant String := "$Header: /dc/uc/self/arcadia/ayacc/src/RCS/shift_reduce_file.a,v 1.2 1993/05/31 22:36:35 self Exp self $";
The_File : File_Type;
procedure Open_Write is
begin
Create(The_File, Out_File, Get_Shift_Reduce_File_Name);
Write_Line("package " & Shift_Reduce_Tables_Unit_Name & " is");
Write_Line("");
Write_Line(" type Small_Integer is range -32_000 .. 32_000;");
Write_Line("");
Write_Line(" type Shift_Reduce_Entry is record");
Write_Line(" T : Small_Integer;");
Write_Line(" Act : Small_Integer;");
Write_Line(" end record;");
Write_Line(" pragma Pack(Shift_Reduce_Entry);");
Write_Line("");
Write_Line(" subtype Row is Integer range -1 .. Integer'Last;");
Write_Line("");
Write_Line(" --pragma suppress(index_check);");
Write_Line("");
Write_Line(" type Shift_Reduce_Array is array " &
"(Row range <>) of Shift_Reduce_Entry;");
Write_Line("");
Write_Line(" Shift_Reduce_Matrix : constant Shift_Reduce_Array :=");
Write_Line(" ( (-1,-1) -- Dummy Entry");
New_Line(The_File);
exception
when Name_Error | Use_Error =>
Put_Line("Ayacc: Error Opening """ & Get_Shift_Reduce_File_Name & """.");
raise;
end Open_Write;
procedure Close_Read is
begin
Delete(The_File);
end Close_Read;
procedure Close_Write is
begin
Write_Line("end " & Shift_Reduce_Tables_Unit_Name & ";");
Close(The_File);
end Close_Write;
procedure Write(S: in String) is
begin
Put(The_File, S) ;
end;
procedure Write_Line(S: in String) is
begin
Put_Line(The_File, S);
end Write_Line;
procedure Write(C: in Character) is
begin
Put(The_File,C);
end;
end Shift_Reduce_File;
|
zhmu/ananas | Ada | 19,671 | adb | ------------------------------------------------------------------------------
-- --
-- GNAT LIBRARY COMPONENTS --
-- --
-- G N A T . S P I T B O L --
-- --
-- B o d y --
-- --
-- Copyright (C) 1998-2022, AdaCore --
-- --
-- GNAT is free software; you can redistribute it and/or modify it under --
-- terms of the GNU General Public License as published by the Free Soft- --
-- ware Foundation; either version 3, or (at your option) any later ver- --
-- sion. GNAT is distributed in the hope that it will be useful, but WITH- --
-- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY --
-- or FITNESS FOR A PARTICULAR PURPOSE. --
-- --
-- As a special exception under Section 7 of GPL version 3, you are granted --
-- additional permissions described in the GCC Runtime Library Exception, --
-- version 3.1, as published by the Free Software Foundation. --
-- --
-- You should have received a copy of the GNU General Public License and --
-- a copy of the GCC Runtime Library Exception along with this program; --
-- see the files COPYING3 and COPYING.RUNTIME respectively. If not, see --
-- <http://www.gnu.org/licenses/>. --
-- --
-- GNAT was originally developed by the GNAT team at New York University. --
-- Extensive contributions were provided by Ada Core Technologies Inc. --
-- --
------------------------------------------------------------------------------
with Ada.Strings; use Ada.Strings;
with Ada.Strings.Unbounded.Aux; use Ada.Strings.Unbounded.Aux;
with GNAT.Debug_Utilities; use GNAT.Debug_Utilities;
with GNAT.IO; use GNAT.IO;
with System.String_Hash;
with Ada.Unchecked_Deallocation;
package body GNAT.Spitbol is
---------
-- "&" --
---------
function "&" (Num : Integer; Str : String) return String is
begin
return S (Num) & Str;
end "&";
function "&" (Str : String; Num : Integer) return String is
begin
return Str & S (Num);
end "&";
function "&" (Num : Integer; Str : VString) return VString is
begin
return S (Num) & Str;
end "&";
function "&" (Str : VString; Num : Integer) return VString is
begin
return Str & S (Num);
end "&";
----------
-- Char --
----------
function Char (Num : Natural) return Character is
begin
return Character'Val (Num);
end Char;
----------
-- Lpad --
----------
function Lpad
(Str : VString;
Len : Natural;
Pad : Character := ' ') return VString
is
begin
if Length (Str) >= Len then
return Str;
else
return Tail (Str, Len, Pad);
end if;
end Lpad;
function Lpad
(Str : String;
Len : Natural;
Pad : Character := ' ') return VString
is
begin
if Str'Length >= Len then
return V (Str);
else
declare
R : String (1 .. Len);
begin
for J in 1 .. Len - Str'Length loop
R (J) := Pad;
end loop;
R (Len - Str'Length + 1 .. Len) := Str;
return V (R);
end;
end if;
end Lpad;
procedure Lpad
(Str : in out VString;
Len : Natural;
Pad : Character := ' ')
is
begin
if Length (Str) >= Len then
return;
else
Tail (Str, Len, Pad);
end if;
end Lpad;
-------
-- N --
-------
function N (Str : VString) return Integer is
S : Big_String_Access;
L : Natural;
begin
Get_String (Str, S, L);
return Integer'Value (S (1 .. L));
end N;
--------------------
-- Reverse_String --
--------------------
function Reverse_String (Str : VString) return VString is
S : Big_String_Access;
L : Natural;
begin
Get_String (Str, S, L);
declare
Result : String (1 .. L);
begin
for J in 1 .. L loop
Result (J) := S (L + 1 - J);
end loop;
return V (Result);
end;
end Reverse_String;
function Reverse_String (Str : String) return VString is
Result : String (1 .. Str'Length);
begin
for J in 1 .. Str'Length loop
Result (J) := Str (Str'Last + 1 - J);
end loop;
return V (Result);
end Reverse_String;
procedure Reverse_String (Str : in out VString) is
S : Big_String_Access;
L : Natural;
begin
Get_String (Str, S, L);
declare
Result : String (1 .. L);
begin
for J in 1 .. L loop
Result (J) := S (L + 1 - J);
end loop;
Set_Unbounded_String (Str, Result);
end;
end Reverse_String;
----------
-- Rpad --
----------
function Rpad
(Str : VString;
Len : Natural;
Pad : Character := ' ') return VString
is
begin
if Length (Str) >= Len then
return Str;
else
return Head (Str, Len, Pad);
end if;
end Rpad;
function Rpad
(Str : String;
Len : Natural;
Pad : Character := ' ') return VString
is
begin
if Str'Length >= Len then
return V (Str);
else
declare
R : String (1 .. Len);
begin
for J in Str'Length + 1 .. Len loop
R (J) := Pad;
end loop;
R (1 .. Str'Length) := Str;
return V (R);
end;
end if;
end Rpad;
procedure Rpad
(Str : in out VString;
Len : Natural;
Pad : Character := ' ')
is
begin
if Length (Str) >= Len then
return;
else
Head (Str, Len, Pad);
end if;
end Rpad;
-------
-- S --
-------
function S (Num : Integer) return String is
Buf : String (1 .. 30);
Ptr : Natural := Buf'Last + 1;
Val : Natural := abs (Num);
begin
loop
Ptr := Ptr - 1;
Buf (Ptr) := Character'Val (Val mod 10 + Character'Pos ('0'));
Val := Val / 10;
exit when Val = 0;
end loop;
if Num < 0 then
Ptr := Ptr - 1;
Buf (Ptr) := '-';
end if;
return Buf (Ptr .. Buf'Last);
end S;
------------
-- Substr --
------------
function Substr
(Str : VString;
Start : Positive;
Len : Natural) return VString
is
S : Big_String_Access;
L : Natural;
begin
Get_String (Str, S, L);
if Start > L then
raise Index_Error;
elsif Start + Len - 1 > L then
raise Length_Error;
else
return V (S (Start .. Start + Len - 1));
end if;
end Substr;
function Substr
(Str : String;
Start : Positive;
Len : Natural) return VString
is
begin
if Start > Str'Length then
raise Index_Error;
elsif Start + Len - 1 > Str'Length then
raise Length_Error;
else
return
V (Str (Str'First + Start - 1 .. Str'First + Start + Len - 2));
end if;
end Substr;
-----------
-- Table --
-----------
package body Table is
procedure Free is new
Ada.Unchecked_Deallocation (Hash_Element, Hash_Element_Ptr);
-----------------------
-- Local Subprograms --
-----------------------
function Hash is new System.String_Hash.Hash
(Character, String, Unsigned_32);
------------
-- Adjust --
------------
overriding procedure Adjust (Object : in out Table) is
Ptr1 : Hash_Element_Ptr;
Ptr2 : Hash_Element_Ptr;
begin
for J in Object.Elmts'Range loop
Ptr1 := Object.Elmts (J)'Unrestricted_Access;
if Ptr1.Name /= null then
loop
Ptr1.Name := new String'(Ptr1.Name.all);
exit when Ptr1.Next = null;
Ptr2 := Ptr1.Next;
Ptr1.Next := new Hash_Element'(Ptr2.all);
Ptr1 := Ptr1.Next;
end loop;
end if;
end loop;
end Adjust;
-----------
-- Clear --
-----------
procedure Clear (T : in out Table) is
Ptr1 : Hash_Element_Ptr;
Ptr2 : Hash_Element_Ptr;
begin
for J in T.Elmts'Range loop
if T.Elmts (J).Name /= null then
Free (T.Elmts (J).Name);
T.Elmts (J).Value := Null_Value;
Ptr1 := T.Elmts (J).Next;
T.Elmts (J).Next := null;
while Ptr1 /= null loop
Ptr2 := Ptr1.Next;
Free (Ptr1.Name);
Free (Ptr1);
Ptr1 := Ptr2;
end loop;
end if;
end loop;
end Clear;
----------------------
-- Convert_To_Array --
----------------------
function Convert_To_Array (T : Table) return Table_Array is
Num_Elmts : Natural := 0;
Elmt : Hash_Element_Ptr;
begin
for J in T.Elmts'Range loop
Elmt := T.Elmts (J)'Unrestricted_Access;
if Elmt.Name /= null then
loop
Num_Elmts := Num_Elmts + 1;
Elmt := Elmt.Next;
exit when Elmt = null;
end loop;
end if;
end loop;
declare
TA : Table_Array (1 .. Num_Elmts);
P : Natural := 1;
begin
for J in T.Elmts'Range loop
Elmt := T.Elmts (J)'Unrestricted_Access;
if Elmt.Name /= null then
loop
Set_Unbounded_String (TA (P).Name, Elmt.Name.all);
TA (P).Value := Elmt.Value;
P := P + 1;
Elmt := Elmt.Next;
exit when Elmt = null;
end loop;
end if;
end loop;
return TA;
end;
end Convert_To_Array;
----------
-- Copy --
----------
procedure Copy (From : Table; To : in out Table) is
Elmt : Hash_Element_Ptr;
begin
Clear (To);
for J in From.Elmts'Range loop
Elmt := From.Elmts (J)'Unrestricted_Access;
if Elmt.Name /= null then
loop
Set (To, Elmt.Name.all, Elmt.Value);
Elmt := Elmt.Next;
exit when Elmt = null;
end loop;
end if;
end loop;
end Copy;
------------
-- Delete --
------------
procedure Delete (T : in out Table; Name : Character) is
begin
Delete (T, String'(1 => Name));
end Delete;
procedure Delete (T : in out Table; Name : VString) is
S : Big_String_Access;
L : Natural;
begin
Get_String (Name, S, L);
Delete (T, S (1 .. L));
end Delete;
procedure Delete (T : in out Table; Name : String) is
Slot : constant Unsigned_32 := Hash (Name) mod T.N + 1;
Elmt : Hash_Element_Ptr := T.Elmts (Slot)'Unrestricted_Access;
Next : Hash_Element_Ptr;
begin
if Elmt.Name = null then
null;
elsif Elmt.Name.all = Name then
Free (Elmt.Name);
if Elmt.Next = null then
Elmt.Value := Null_Value;
return;
else
Next := Elmt.Next;
Elmt.Name := Next.Name;
Elmt.Value := Next.Value;
Elmt.Next := Next.Next;
Free (Next);
return;
end if;
else
loop
Next := Elmt.Next;
if Next = null then
return;
elsif Next.Name.all = Name then
Free (Next.Name);
Elmt.Next := Next.Next;
Free (Next);
return;
else
Elmt := Next;
end if;
end loop;
end if;
end Delete;
----------
-- Dump --
----------
procedure Dump (T : Table; Str : String := "Table") is
Num_Elmts : Natural := 0;
Elmt : Hash_Element_Ptr;
begin
for J in T.Elmts'Range loop
Elmt := T.Elmts (J)'Unrestricted_Access;
if Elmt.Name /= null then
loop
Num_Elmts := Num_Elmts + 1;
Put_Line
(Str & '<' & Image (Elmt.Name.all) & "> = " &
Img (Elmt.Value));
Elmt := Elmt.Next;
exit when Elmt = null;
end loop;
end if;
end loop;
if Num_Elmts = 0 then
Put_Line (Str & " is empty");
end if;
end Dump;
procedure Dump (T : Table_Array; Str : String := "Table_Array") is
begin
if T'Length = 0 then
Put_Line (Str & " is empty");
else
for J in T'Range loop
Put_Line
(Str & '(' & Image (To_String (T (J).Name)) & ") = " &
Img (T (J).Value));
end loop;
end if;
end Dump;
--------------
-- Finalize --
--------------
overriding procedure Finalize (Object : in out Table) is
Ptr1 : Hash_Element_Ptr;
Ptr2 : Hash_Element_Ptr;
begin
for J in Object.Elmts'Range loop
Ptr1 := Object.Elmts (J).Next;
Free (Object.Elmts (J).Name);
while Ptr1 /= null loop
Ptr2 := Ptr1.Next;
Free (Ptr1.Name);
Free (Ptr1);
Ptr1 := Ptr2;
end loop;
end loop;
end Finalize;
---------
-- Get --
---------
function Get (T : Table; Name : Character) return Value_Type is
begin
return Get (T, String'(1 => Name));
end Get;
function Get (T : Table; Name : VString) return Value_Type is
S : Big_String_Access;
L : Natural;
begin
Get_String (Name, S, L);
return Get (T, S (1 .. L));
end Get;
function Get (T : Table; Name : String) return Value_Type is
Slot : constant Unsigned_32 := Hash (Name) mod T.N + 1;
Elmt : Hash_Element_Ptr := T.Elmts (Slot)'Unrestricted_Access;
begin
if Elmt.Name = null then
return Null_Value;
else
loop
if Name = Elmt.Name.all then
return Elmt.Value;
else
Elmt := Elmt.Next;
if Elmt = null then
return Null_Value;
end if;
end if;
end loop;
end if;
end Get;
-------------
-- Present --
-------------
function Present (T : Table; Name : Character) return Boolean is
begin
return Present (T, String'(1 => Name));
end Present;
function Present (T : Table; Name : VString) return Boolean is
S : Big_String_Access;
L : Natural;
begin
Get_String (Name, S, L);
return Present (T, S (1 .. L));
end Present;
function Present (T : Table; Name : String) return Boolean is
Slot : constant Unsigned_32 := Hash (Name) mod T.N + 1;
Elmt : Hash_Element_Ptr := T.Elmts (Slot)'Unrestricted_Access;
begin
if Elmt.Name = null then
return False;
else
loop
if Name = Elmt.Name.all then
return True;
else
Elmt := Elmt.Next;
if Elmt = null then
return False;
end if;
end if;
end loop;
end if;
end Present;
---------
-- Set --
---------
procedure Set (T : in out Table; Name : VString; Value : Value_Type) is
S : Big_String_Access;
L : Natural;
begin
Get_String (Name, S, L);
Set (T, S (1 .. L), Value);
end Set;
procedure Set (T : in out Table; Name : Character; Value : Value_Type) is
begin
Set (T, String'(1 => Name), Value);
end Set;
procedure Set
(T : in out Table;
Name : String;
Value : Value_Type)
is
begin
if Value = Null_Value then
Delete (T, Name);
else
declare
Slot : constant Unsigned_32 := Hash (Name) mod T.N + 1;
Elmt : Hash_Element_Ptr := T.Elmts (Slot)'Unrestricted_Access;
subtype String1 is String (1 .. Name'Length);
begin
if Elmt.Name = null then
Elmt.Name := new String'(String1 (Name));
Elmt.Value := Value;
return;
else
loop
if Name = Elmt.Name.all then
Elmt.Value := Value;
return;
elsif Elmt.Next = null then
Elmt.Next := new Hash_Element'(
Name => new String'(String1 (Name)),
Value => Value,
Next => null);
return;
else
Elmt := Elmt.Next;
end if;
end loop;
end if;
end;
end if;
end Set;
end Table;
----------
-- Trim --
----------
function Trim (Str : VString) return VString is
begin
return Trim (Str, Right);
end Trim;
function Trim (Str : String) return VString is
begin
for J in reverse Str'Range loop
if Str (J) /= ' ' then
return V (Str (Str'First .. J));
end if;
end loop;
return Nul;
end Trim;
procedure Trim (Str : in out VString) is
begin
Trim (Str, Right);
end Trim;
-------
-- V --
-------
function V (Num : Integer) return VString is
Buf : String (1 .. 30);
Ptr : Natural := Buf'Last + 1;
Val : Natural := abs (Num);
begin
loop
Ptr := Ptr - 1;
Buf (Ptr) := Character'Val (Val mod 10 + Character'Pos ('0'));
Val := Val / 10;
exit when Val = 0;
end loop;
if Num < 0 then
Ptr := Ptr - 1;
Buf (Ptr) := '-';
end if;
return V (Buf (Ptr .. Buf'Last));
end V;
end GNAT.Spitbol;
|
persan/advent-of-code-2020 | Ada | 1,326 | adb | pragma Ada_2012;
package body Adventofcode.File_Line_Readers is
use Ada.Text_IO;
----------------
-- Read_Lines --
----------------
function Read_Lines (From_Path : String) return File_Reader is
begin
return Ret : File_Reader do
Ada.Text_IO.Open (Ret.F, In_File, From_Path);
end return;
end Read_Lines;
------------------
-- First_Cursor --
------------------
function First_Cursor (Cont : File_Reader) return Cursor is
begin
return Cursor'(0);
end First_Cursor;
-------------
-- Advance --
-------------
function Advance (Cont : File_Reader; Position : Cursor) return Cursor is
begin
return Cursor'(0);
end Advance;
------------------------
-- Cursor_Has_Element --
------------------------
function Cursor_Has_Element
(Cont : File_Reader; Position : Cursor) return Boolean
is
begin
return not End_Of_File (Cont.F);
end Cursor_Has_Element;
-----------------
-- Get_Element --
-----------------
function Get_Element (Cont : File_Reader; Position : Cursor) return String
is
begin
return Get_Line (Cont.F);
end Get_Element;
overriding procedure Finalize (Object : in out File_Reader) is
begin
Close (Object.F);
end;
end Adventofcode.File_Line_Readers;
|
Componolit/libsparkcrypto | Ada | 2,328 | ads | -------------------------------------------------------------------------------
-- This file is part of libsparkcrypto.
--
-- Copyright (C) 2010, Alexander Senier
-- Copyright (C) 2010, secunet Security Networks AG
-- All rights reserved.
--
-- Redistribution and use in source and binary forms, with or without
-- modification, are permitted provided that the following conditions are met:
--
-- * Redistributions of source code must retain the above copyright notice,
-- this list of conditions and the following disclaimer.
--
-- * Redistributions in binary form must reproduce the above copyright
-- notice, this list of conditions and the following disclaimer in the
-- documentation and/or other materials provided with the distribution.
--
-- * Neither the name of the nor the names of its contributors may be used
-- to endorse or promote products derived from this software without
-- specific prior written permission.
--
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
-- AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
-- IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
-- ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS
-- BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
-- CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
-- SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
-- INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
-- CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
-- ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
-- POSSIBILITY OF SUCH DAMAGE.
-------------------------------------------------------------------------------
with LSC.Internal.Types;
-------------------------------------------------------------------------------
-- Byte swapping for 32-bit words
-------------------------------------------------------------------------------
package LSC.Internal.Byteswap32
with
SPARK_Mode => On
is
pragma Pure;
-- Byte-swap @Value@
function Swap (Value : Types.Word32) return Types.Word32;
pragma Inline (Swap);
end LSC.Internal.Byteswap32;
|
AdaCore/libadalang | Ada | 733 | adb | procedure Test is
type Some_Interface is interface;
generic
type Cursor;
package Iterator_Interface is
type Iterator is interface;
function Get (It : Iterator) return Cursor is abstract;
end Iterator_Interface;
generic
type Elt_Type;
package Gen is
type Cursor is access Elt_Type;
package Int is new Iterator_Interface (Cursor);
type My_Iterator is abstract
new Some_Interface
and Int.Iterator
with null record;
end Gen;
package Inst is new Gen (Integer);
procedure Foo (X : Inst.My_Iterator'Class) is
I : access Integer := Inst.Get (X);
pragma Test_Statement;
begin
null;
end Foo;
begin
null;
end Test;
|
reznikmm/matreshka | Ada | 4,932 | ads | ------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- Ada Modeling Framework --
-- --
-- Runtime Library Component --
-- --
------------------------------------------------------------------------------
-- --
-- Copyright © 2012, Vadim Godunko <[email protected]> --
-- All rights reserved. --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions --
-- are met: --
-- --
-- * Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- --
-- * Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in the --
-- documentation and/or other materials provided with the distribution. --
-- --
-- * Neither the name of the Vadim Godunko, IE nor the names of its --
-- contributors may be used to endorse or promote products derived from --
-- this software without specific prior written permission. --
-- --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR --
-- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
-- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED --
-- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR --
-- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF --
-- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING --
-- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS --
-- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
-- --
------------------------------------------------------------------------------
-- $Revision$ $Date$
------------------------------------------------------------------------------
-- This file is generated, don't edit it.
------------------------------------------------------------------------------
with AMF.Generic_Collections;
package AMF.Utp.Data_Pools.Collections is
pragma Preelaborate;
package Utp_Data_Pool_Collections is
new AMF.Generic_Collections
(Utp_Data_Pool,
Utp_Data_Pool_Access);
type Set_Of_Utp_Data_Pool is
new Utp_Data_Pool_Collections.Set with null record;
Empty_Set_Of_Utp_Data_Pool : constant Set_Of_Utp_Data_Pool;
type Ordered_Set_Of_Utp_Data_Pool is
new Utp_Data_Pool_Collections.Ordered_Set with null record;
Empty_Ordered_Set_Of_Utp_Data_Pool : constant Ordered_Set_Of_Utp_Data_Pool;
type Bag_Of_Utp_Data_Pool is
new Utp_Data_Pool_Collections.Bag with null record;
Empty_Bag_Of_Utp_Data_Pool : constant Bag_Of_Utp_Data_Pool;
type Sequence_Of_Utp_Data_Pool is
new Utp_Data_Pool_Collections.Sequence with null record;
Empty_Sequence_Of_Utp_Data_Pool : constant Sequence_Of_Utp_Data_Pool;
private
Empty_Set_Of_Utp_Data_Pool : constant Set_Of_Utp_Data_Pool
:= (Utp_Data_Pool_Collections.Set with null record);
Empty_Ordered_Set_Of_Utp_Data_Pool : constant Ordered_Set_Of_Utp_Data_Pool
:= (Utp_Data_Pool_Collections.Ordered_Set with null record);
Empty_Bag_Of_Utp_Data_Pool : constant Bag_Of_Utp_Data_Pool
:= (Utp_Data_Pool_Collections.Bag with null record);
Empty_Sequence_Of_Utp_Data_Pool : constant Sequence_Of_Utp_Data_Pool
:= (Utp_Data_Pool_Collections.Sequence with null record);
end AMF.Utp.Data_Pools.Collections;
|
reznikmm/matreshka | Ada | 3,749 | ads | ------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- Open Document Toolkit --
-- --
-- Runtime Library Component --
-- --
------------------------------------------------------------------------------
-- --
-- Copyright © 2014, Vadim Godunko <[email protected]> --
-- All rights reserved. --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions --
-- are met: --
-- --
-- * Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- --
-- * Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in the --
-- documentation and/or other materials provided with the distribution. --
-- --
-- * Neither the name of the Vadim Godunko, IE nor the names of its --
-- contributors may be used to endorse or promote products derived from --
-- this software without specific prior written permission. --
-- --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR --
-- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
-- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED --
-- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR --
-- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF --
-- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING --
-- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS --
-- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
-- --
------------------------------------------------------------------------------
-- $Revision$ $Date$
------------------------------------------------------------------------------
with XML.DOM.Elements;
package ODF.DOM.Style_Presentation_Page_Layout_Elements is
pragma Preelaborate;
type ODF_Style_Presentation_Page_Layout is limited interface
and XML.DOM.Elements.DOM_Element;
type ODF_Style_Presentation_Page_Layout_Access is
access all ODF_Style_Presentation_Page_Layout'Class
with Storage_Size => 0;
end ODF.DOM.Style_Presentation_Page_Layout_Elements;
|
reznikmm/matreshka | Ada | 3,789 | 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 ODF.Constants;
package body Matreshka.ODF_Attributes.Style.Rel_Column_Width is
--------------------
-- Get_Local_Name --
--------------------
overriding function Get_Local_Name
(Self : not null access constant Style_Rel_Column_Width_Node)
return League.Strings.Universal_String is
begin
return ODF.Constants.Rel_Column_Width_Name;
end Get_Local_Name;
end Matreshka.ODF_Attributes.Style.Rel_Column_Width;
|
AdaCore/libadalang | Ada | 702 | adb | procedure Test is
generic
type T is abstract tagged private;
with procedure Foo (X : T) is abstract;
package Pkg is
procedure Bar (X : T'Class);
end Pkg;
package body Pkg is
procedure Bar (X : T'Class) is
begin
Foo (X);
--% node.f_call.p_is_dispatching_call()
end Bar;
end Pkg;
package T_Def is
type T is abstract tagged null record;
procedure Wow (X : T) is null;
end T_Def;
package Pkg_Inst is new Pkg (T_Def.T, T_Def.Wow);
package U_Def is
type U is new T_Def.T with null record;
overriding procedure Wow (X : U) is null;
end U_Def;
X : U_Def.U;
begin
Pkg_Inst.Bar (X);
end Test;
|
thorstel/Advent-of-Code-2018 | Ada | 2,949 | adb | with Ada.Text_IO; use Ada.Text_IO;
with Interfaces; use Interfaces;
with Ada.Containers.Vectors;
with Opcode_Helper;
procedure Day19 is
package OH is new Opcode_Helper (Register_Size => 6);
use OH;
subtype Op_String is String (1 .. 4);
type Instruction is record
Op : Op_String;
A : Unsigned_64;
B : Unsigned_64;
C : Unsigned_64;
end record;
package Instr_Vectors is new Ada.Containers.Vectors
(Index_Type => Natural,
Element_Type => Instruction);
use Instr_Vectors;
Program : Vector;
IP : Unsigned_64 := 0;
IP_Reg : Natural := 0;
Reg : Registers := (others => 0);
procedure Execute_Program is
begin
while IP < Unsigned_64 (Program.Length) loop
declare
Idx : constant Natural := Natural (IP);
Op : constant Op_String := Program (Idx).Op;
A : constant Unsigned_64 := Program (Idx).A;
B : constant Unsigned_64 := Program (Idx).B;
C : constant Unsigned_64 := Program (Idx).C;
begin
Reg (IP_Reg) := IP;
Reg := Execute_Instruction (Op, Reg, A, B, C);
IP := Reg (IP_Reg) + 1;
end;
end loop;
end Execute_Program;
begin
-- Input Handling
declare
File : File_Type;
begin
Open (File, In_File, "input.txt");
IP_Reg := Natural'Value (Get_Line (File) (5 .. 5));
while not End_Of_File (File) loop
declare
Line : constant String := Get_Line (File);
Op : constant Op_String := Line (1 .. 4);
I, J : Positive := 6;
ABC : array (Positive range 1 .. 3) of Unsigned_64;
K : Positive := ABC'First;
begin
while J <= Line'Last loop
if Line (J) = ' ' or J = Line'Last then
ABC (K) := Unsigned_64'Value (Line (I .. J));
K := K + 1;
I := J;
end if;
J := J + 1;
end loop;
Program.Append ((Op, ABC (1), ABC (2), ABC (3)));
end;
end loop;
Close (File);
end;
-- Part 1
Execute_Program;
Put_Line ("Part 1 =" & Unsigned_64'Image (Reg (0)));
-- Reset for part 2
Reg := (0 => 1, others => 0);
IP := 0;
-- Quit the program instead of continuing the loop
Program (Program.Last_Index).A := Unsigned_64 (Program.Length);
Execute_Program;
-- The program would now calculate the sum of divisors. We can do
-- that a lot faster. The corresponding register (in this case 5)
-- may be different with other inputs.
declare
Sum : Unsigned_64 := 0;
begin
for I in 1 .. Reg (5) loop
if Reg (5) mod I = 0 then
Sum := Sum + I;
end if;
end loop;
Put_Line ("Part 2 =" & Unsigned_64'Image (Sum));
end;
end Day19;
|
io7m/coreland-cgbc-doc | Ada | 173 | ads | with CGBC.Bounded_Generic_Strings;
package CGBC.Bounded_Wide_Strings is new Bounded_Generic_Strings
(Character_Type => Wide_Character,
String_Type => Wide_String);
|
shintakezou/drake | Ada | 17,860 | adb | with Ada.Exception_Identification.From_Here;
with Ada.Exceptions.Finally;
with Ada.Streams.Naked_Stream_IO.Standard_Files;
with System.Address_To_Named_Access_Conversions;
with System.Native_IO;
with System.Standard_Allocators;
with System.Storage_Elements;
with System.Wide_Startup; -- that is also linked by Ada.Command_Line
with System.Zero_Terminated_WStrings;
with System.Debug; -- assertions
with C.string;
with C.windef;
with C.winerror;
package body System.Native_Processes is
use Ada.Exception_Identification.From_Here;
use type Ada.Command_Line.Exit_Status;
use type Storage_Elements.Storage_Offset;
use type C.size_t;
use type C.windef.DWORD;
use type C.windef.WINBOOL;
use type C.windef.UINT;
use type C.winnt.HANDLE; -- C.void_ptr
use type C.winnt.LPWSTR; -- Command_Type
function memchr (
s : Address;
c : Integer;
n : Storage_Elements.Storage_Count)
return Address
with Import,
Convention => Intrinsic, External_Name => "__builtin_memchr";
package LPWSTR_Conv is
new Address_To_Named_Access_Conversions (C.winnt.WCHAR, C.winnt.LPWSTR);
package LPWSTR_ptr_Conv is
new Address_To_Named_Access_Conversions (
C.winnt.LPWSTR,
C.winnt.LPWSTR_ptr);
function "+" (Left : C.winnt.LPWSTR_ptr; Right : C.ptrdiff_t)
return C.winnt.LPWSTR_ptr
with Convention => Intrinsic;
pragma Inline_Always ("+");
function "+" (Left : C.winnt.LPWSTR_ptr; Right : C.ptrdiff_t)
return C.winnt.LPWSTR_ptr is
begin
return LPWSTR_ptr_Conv.To_Pointer (
LPWSTR_ptr_Conv.To_Address (Left)
+ Storage_Elements.Storage_Offset (Right)
* (C.winnt.LPWSTR'Size / Standard'Storage_Unit));
end "+";
procedure Reallocate (X : in out Command_Type; Length : C.size_t);
procedure Reallocate (X : in out Command_Type; Length : C.size_t) is
Size : constant Storage_Elements.Storage_Count :=
(Storage_Elements.Storage_Offset (Length) + 1) -- NUL
* (C.winnt.WCHAR'Size / Standard'Storage_Unit);
begin
X := LPWSTR_Conv.To_Pointer (
Standard_Allocators.Reallocate (LPWSTR_Conv.To_Address (X), Size));
end Reallocate;
procedure C_Append (
Command : Command_Type;
Index : in out C.size_t;
New_Item : not null C.winnt.LPWSTR);
procedure C_Append (
Command : Command_Type;
Index : in out C.size_t;
New_Item : not null C.winnt.LPWSTR)
is
New_Item_Length : constant C.size_t := C.string.wcslen (New_Item);
Command_All : C.winnt.WCHAR_array (
0 .. Index + New_Item_Length + 3); -- ' ' & '"' & '"' & NUL
for Command_All'Address use LPWSTR_Conv.To_Address (Command);
begin
if Index > 0 then
Command_All (Index) := C.winnt.WCHAR'Val (Character'Pos (' '));
Index := Index + 1;
end if;
declare
Has_Space : constant Boolean :=
C.string.wcschr (
New_Item,
C.wchar_t'Val (Character'Pos (' '))) /= null;
begin
if Has_Space then
Command_All (Index) := C.winnt.WCHAR'Val (Character'Pos ('"'));
Index := Index + 1;
end if;
if New_Item_Length > 0 then
declare
New_Item_All : C.winnt.WCHAR_array (0 .. New_Item_Length - 1);
for New_Item_All'Address use LPWSTR_Conv.To_Address (New_Item);
begin
Command_All (Index .. Index + New_Item_Length - 1) :=
New_Item_All;
Index := Index + New_Item_Length;
end;
end if;
if Has_Space then
Command_All (Index) := C.winnt.WCHAR'Val (Character'Pos ('"'));
Index := Index + 1;
end if;
end;
Command_All (Index) := C.winnt.WCHAR'Val (0);
end C_Append;
-- implementation
procedure Free (X : in out Command_Type) is
begin
Standard_Allocators.Free (LPWSTR_Conv.To_Address (X));
X := null;
end Free;
function Image (Command : Command_Type) return String is
begin
return Zero_Terminated_WStrings.Value (Command);
end Image;
procedure Value (
Command_Line : String;
Command : aliased out Command_Type)
is
Size : constant Storage_Elements.Storage_Count :=
(Command_Line'Length * Zero_Terminated_WStrings.Expanding + 1)
* (C.winnt.WCHAR'Size / Standard'Storage_Unit);
begin
Command := LPWSTR_Conv.To_Pointer (Standard_Allocators.Allocate (Size));
Zero_Terminated_WStrings.To_C (Command_Line, Command);
end Value;
procedure Append (
Command : aliased in out Command_Type;
New_Item : String)
is
W_New_Item : aliased C.winnt.WCHAR_array (
0 .. New_Item'Length * Zero_Terminated_WStrings.Expanding);
W_New_Item_Length : C.size_t;
Old_Length : C.size_t;
begin
Zero_Terminated_WStrings.To_C (
New_Item,
W_New_Item (0)'Access,
W_New_Item_Length);
if Command = null then
Old_Length := 0;
else
Old_Length := C.string.wcslen (Command);
end if;
Reallocate (
Command,
Old_Length + W_New_Item_Length + 3); -- space and a pair of '"'
C_Append (Command, Old_Length, W_New_Item (0)'Unchecked_Access);
end Append;
procedure Append (
Command : aliased in out Command_Type;
First : Positive;
Last : Natural)
is
pragma Assert (Last >= First);
Old_Length : C.size_t;
Additional_Length : C.size_t := 0;
begin
-- get length
for I in First .. Last loop
declare
P : constant C.winnt.LPWSTR_ptr :=
LPWSTR_ptr_Conv.To_Pointer (Wide_Startup.wargv)
+ C.ptrdiff_t (I);
begin
Additional_Length :=
Additional_Length
+ C.string.wcslen (P.all)
+ 3; -- space and a pair of '"'
end;
end loop;
if Command = null then
Old_Length := 0;
else
Old_Length := C.string.wcslen (Command);
end if;
Reallocate (Command, Old_Length + Additional_Length);
-- copy
declare
Index : C.size_t := Old_Length;
begin
for I in First .. Last loop
declare
P : constant C.winnt.LPWSTR_ptr :=
LPWSTR_ptr_Conv.To_Pointer (Wide_Startup.wargv)
+ C.ptrdiff_t (I);
begin
C_Append (Command, Index, P.all);
end;
end loop;
end;
end Append;
procedure Append_Argument (
Command_Line : in out String;
Last : in out Natural;
Argument : String)
is
Argument_Length : constant Natural := Argument'Length;
Has_Space : Boolean;
begin
-- add separator
if Last >= Command_Line'First then
if Last >= Command_Line'Last then
raise Constraint_Error;
end if;
Last := Last + 1;
Command_Line (Last) := ' ';
end if;
-- find space in argument
Has_Space := memchr (
Argument'Address,
Character'Pos (' '),
Storage_Elements.Storage_Offset (Argument_Length)) /= Null_Address;
-- open
if Has_Space then
if Last >= Command_Line'Last then
raise Constraint_Error;
end if;
Last := Last + 1;
Command_Line (Last) := '"';
end if;
-- argument
if Last + Argument_Length > Command_Line'Last then
raise Constraint_Error;
end if;
Command_Line (Last + 1 .. Last + Argument_Length) := Argument;
Last := Last + Argument_Length;
-- close
if Has_Space then
if Last >= Command_Line'Last then
raise Constraint_Error;
end if;
Last := Last + 1;
Command_Line (Last) := '"';
end if;
end Append_Argument;
-- child process management
procedure Wait (
Child : in out Process;
Milliseconds : C.windef.DWORD;
Terminated : out Boolean;
Status : out Ada.Command_Line.Exit_Status);
procedure Wait (
Child : in out Process;
Milliseconds : C.windef.DWORD;
Terminated : out Boolean;
Status : out Ada.Command_Line.Exit_Status) is
begin
case C.winbase.WaitForSingleObject (Child.Handle, Milliseconds) is
when C.winbase.WAIT_OBJECT_0 =>
declare
Max : constant := C.windef.DWORD'Modulus / 2; -- 2 ** 31
Exit_Code : aliased C.windef.DWORD;
Success : C.windef.WINBOOL;
begin
Success :=
C.winbase.GetExitCodeProcess (
Child.Handle,
Exit_Code'Access);
if C.winbase.CloseHandle (Child.Handle) = C.windef.FALSE
or else Success = C.windef.FALSE
then
Raise_Exception (Use_Error'Identity);
end if;
Child := Null_Process;
-- status code
if Exit_Code < Max then
Status := Ada.Command_Line.Exit_Status (Exit_Code);
else
-- terminated by an unhandled exception
Status := -1;
end if;
Terminated := True;
end;
when C.winerror.WAIT_TIMEOUT =>
Terminated := False;
when others =>
Raise_Exception (Use_Error'Identity);
end case;
end Wait;
-- implementation of child process management
function Is_Open (Child : Process) return Boolean is
begin
return Child.Handle /= C.winbase.INVALID_HANDLE_VALUE;
end Is_Open;
procedure Create (
Child : in out Process;
Command : Command_Type;
Directory : String := "";
Search_Path : Boolean := False;
Input : Ada.Streams.Naked_Stream_IO.Non_Controlled_File_Type;
Output : Ada.Streams.Naked_Stream_IO.Non_Controlled_File_Type;
Error : Ada.Streams.Naked_Stream_IO.Non_Controlled_File_Type)
is
pragma Unreferenced (Search_Path);
W_Directory : aliased C.winnt.WCHAR_array (0 .. Directory'Length);
Directory_Ref : access constant C.winnt.WCHAR;
Startup_Info : aliased C.winbase.STARTUPINFO;
Process_Info : aliased C.winbase.PROCESS_INFORMATION;
Current_Process : constant C.winnt.HANDLE := C.winbase.GetCurrentProcess;
subtype Handle_Index is Integer range 0 .. 2;
Source_Files :
array (Handle_Index) of
Ada.Streams.Naked_Stream_IO.Non_Controlled_File_Type;
Target_Handles : array (Handle_Index) of C.winnt.HANDLE;
Duplicated_Handles : array (Handle_Index) of aliased C.winnt.HANDLE;
Success : C.windef.WINBOOL;
begin
C.winbase.GetStartupInfo (Startup_Info'Access);
Startup_Info.dwFlags := C.winbase.STARTF_USESTDHANDLES
or C.winbase.STARTF_FORCEOFFFEEDBACK;
Source_Files (0) := Input;
Source_Files (1) := Output;
Source_Files (2) := Error;
for I in Handle_Index loop
declare
Source_Handle : constant C.winnt.HANDLE :=
Ada.Streams.Naked_Stream_IO.Handle (Source_Files (I));
begin
if Ada.Streams.Naked_Stream_IO.Is_Standard (Source_Files (I)) then
Duplicated_Handles (I) := C.winbase.INVALID_HANDLE_VALUE;
Target_Handles (I) := Source_Handle;
else
if C.winbase.DuplicateHandle (
hSourceProcessHandle => Current_Process,
hSourceHandle => Source_Handle,
hTargetProcessHandle => Current_Process,
lpTargetHandle => Duplicated_Handles (I)'Access,
dwDesiredAccess => 0,
bInheritHandle => 1,
dwOptions => C.winnt.DUPLICATE_SAME_ACCESS) =
C.windef.FALSE
then
Raise_Exception (Use_Error'Identity);
end if;
Target_Handles (I) := Duplicated_Handles (I);
end if;
end;
end loop;
Startup_Info.hStdInput := Target_Handles (0);
Startup_Info.hStdOutput := Target_Handles (1);
Startup_Info.hStdError := Target_Handles (2);
if Directory'Length > 0 then
Zero_Terminated_WStrings.To_C (Directory, W_Directory (0)'Access);
Directory_Ref := W_Directory (0)'Access;
else
Directory_Ref := null;
end if;
Success := C.winbase.CreateProcess (
lpApplicationName => null,
lpCommandLine => Command,
lpProcessAttributes => null,
lpThreadAttributes => null,
bInheritHandles => 1,
dwCreationFlags => 0,
lpEnvironment => C.windef.LPVOID (Null_Address),
lpCurrentDirectory => Directory_Ref,
lpStartupInfo => Startup_Info'Access,
lpProcessInformation => Process_Info'Access);
for I in Handle_Index loop
if Duplicated_Handles (I) /= C.winbase.INVALID_HANDLE_VALUE then
if C.winbase.CloseHandle (Duplicated_Handles (I)) =
C.windef.FALSE
then
Raise_Exception (Use_Error'Identity);
end if;
end if;
end loop;
if Success = C.windef.FALSE then
declare
Error : constant C.windef.DWORD := C.winbase.GetLastError;
begin
case Error is
when C.winerror.ERROR_FILE_NOT_FOUND
| C.winerror.ERROR_PATH_NOT_FOUND
| C.winerror.ERROR_INVALID_NAME =>
Raise_Exception (Name_Error'Identity);
when others =>
Raise_Exception (Native_IO.IO_Exception_Id (Error));
end case;
end;
else
if C.winbase.CloseHandle (Process_Info.hThread) = C.windef.FALSE then
Raise_Exception (Use_Error'Identity);
end if;
Child.Handle := Process_Info.hProcess;
end if;
end Create;
procedure Create (
Child : in out Process;
Command_Line : String;
Directory : String := "";
Search_Path : Boolean := False;
Input : Ada.Streams.Naked_Stream_IO.Non_Controlled_File_Type;
Output : Ada.Streams.Naked_Stream_IO.Non_Controlled_File_Type;
Error : Ada.Streams.Naked_Stream_IO.Non_Controlled_File_Type)
is
W_Command_Line : aliased C.winnt.WCHAR_array (
0 ..
Command_Line'Length * Zero_Terminated_WStrings.Expanding);
begin
Zero_Terminated_WStrings.To_C (Command_Line, W_Command_Line (0)'Access);
Create (
Child,
W_Command_Line (0)'Unchecked_Access,
Directory,
Search_Path,
Input,
Output,
Error);
end Create;
procedure Close (Child : in out Process) is
begin
if Is_Open (Child) then
declare
Success : C.windef.WINBOOL;
begin
Success := C.winbase.CloseHandle (Child.Handle);
pragma Check (Debug,
Check =>
Success /= C.windef.FALSE
or else Debug.Runtime_Error ("CloseHandle failed"));
end;
end if;
end Close;
procedure Wait (
Child : in out Process;
Status : out Ada.Command_Line.Exit_Status) is
begin
loop
declare
Terminated : Boolean;
begin
Wait (Child, C.winbase.INFINITE,
Terminated => Terminated, Status => Status);
exit when Terminated;
end;
end loop;
end Wait;
procedure Wait_Immediate (
Child : in out Process;
Terminated : out Boolean;
Status : out Ada.Command_Line.Exit_Status) is
begin
Wait (Child, 0, Terminated => Terminated, Status => Status);
end Wait_Immediate;
procedure Forced_Abort_Process (Child : Process) is
Code : constant C.windef.UINT := -1; -- the MSB should be 1 ???
begin
if C.winbase.TerminateProcess (Child.Handle, Code) = C.windef.FALSE then
declare
Exit_Code : aliased C.windef.DWORD;
begin
-- It is not an error if the process is already terminated.
if not (
C.winbase.GetLastError = C.winerror.ERROR_ACCESS_DENIED
and then C.winbase.GetExitCodeProcess (
Child.Handle,
Exit_Code'Access) /=
C.windef.FALSE
and then Exit_Code /= C.winbase.STILL_ACTIVE)
then
Raise_Exception (Use_Error'Identity);
end if;
end;
end if;
end Forced_Abort_Process;
-- implementation of pass a command to the shell
procedure Shell (
Command : Command_Type;
Status : out Ada.Command_Line.Exit_Status)
is
-- unimplemented, should use ShellExecute
package Holder is
new Ada.Exceptions.Finally.Scoped_Holder (Process, Close);
P : aliased Process := Null_Process;
begin
Holder.Assign (P);
Create (P, Command,
Search_Path => True,
Input => Ada.Streams.Naked_Stream_IO.Standard_Files.Standard_Input,
Output => Ada.Streams.Naked_Stream_IO.Standard_Files.Standard_Output,
Error => Ada.Streams.Naked_Stream_IO.Standard_Files.Standard_Error);
Wait (P, Status);
end Shell;
procedure Shell (
Command_Line : String;
Status : out Ada.Command_Line.Exit_Status)
is
package Holder is
new Ada.Exceptions.Finally.Scoped_Holder (Command_Type, Free);
Command : aliased Command_Type;
begin
Holder.Assign (Command);
Value (Command_Line, Command);
Shell (Command, Status);
end Shell;
end System.Native_Processes;
|
stcarrez/ada-css | Ada | 25,132 | adb |
with CSS.Parser.Parser_Goto;
with CSS.Parser.Parser_Tokens;
with CSS.Parser.Parser_Shift_Reduce;
with CSS.Parser.Lexer_IO;
with CSS.Parser.Lexer;
with CSS.Parser.Lexer_DFA;
with CSS.Core.Selectors;
with CSS.Core.Styles;
with CSS.Core.Medias;
with Ada.Text_IO;
package body CSS.Parser.Parser is
use Ada;
use CSS.Parser.Lexer;
use CSS.Core.Selectors;
use CSS.Parser.Lexer_DFA;
procedure YYParse;
procedure yyerror (Message : in String := "syntax error");
Document : CSS.Core.Sheets.CSSStylesheet_Access;
Current_Page : CSS.Core.Styles.CSSPageRule_Access;
Current_Rule : CSS.Core.Styles.CSSStyleRule_Access;
Current_Media : CSS.Core.Medias.CSSMediaRule_Access;
procedure yyerror (Message : in String := "syntax error") is
begin
Error_Count := Error_Count + 1;
Error (CSS.Parser.Lexer_DFA.yylineno, CSS.Parser.Lexer_DFA.yylinecol, Message);
end yyerror;
function Parse (Content : in String;
Document : in CSS.Core.Sheets.CSSStylesheet_Access) return Integer is
begin
Error_Count := 0;
CSS.Parser.Lexer_DFA.yylineno := 1;
CSS.Parser.Lexer_DFA.yylinecol := 1;
CSS.Parser.Lexer_IO.Open_Input (Content);
CSS.Parser.Parser.Document := Document;
Current_Rule := null;
Current_Media := null;
Current_Page := null;
YYParse;
Current_Rule := null;
Current_Media := null;
Current_Page := null;
CSS.Parser.Parser.Document := null;
CSS.Parser.Lexer_IO.Close_Input;
Parser_Tokens.YYLVal := EMPTY;
return Error_Count;
exception
when others =>
CSS.Parser.Parser.Document := null;
CSS.Parser.Lexer_IO.Close_Input;
Parser_Tokens.YYLVal := EMPTY;
raise;
end Parse;
procedure YYParse is
-- Rename User Defined Packages to Internal Names.
package yy_goto_tables renames
CSS.Parser.Parser_Goto;
package yy_shift_reduce_tables renames
CSS.Parser.Parser_Shift_Reduce;
package yy_tokens renames
CSS.Parser.Parser_Tokens;
use yy_tokens, yy_goto_tables, yy_shift_reduce_tables;
procedure yyerrok;
procedure yyclearin;
procedure handle_error;
subtype goto_row is yy_goto_tables.Row;
subtype reduce_row is yy_shift_reduce_tables.Row;
package yy is
-- the size of the value and state stacks
-- Affects error 'Stack size exceeded on state_stack'
stack_size : constant Natural := 256;
-- subtype rule is Natural;
subtype parse_state is Natural;
-- subtype nonterminal is Integer;
-- encryption constants
default : constant := -1;
first_shift_entry : constant := 0;
accept_code : constant := -3001;
error_code : constant := -3000;
-- stack data used by the parser
tos : Natural := 0;
value_stack : array (0 .. stack_size) of yy_tokens.YYSType;
state_stack : array (0 .. stack_size) of parse_state;
-- current input symbol and action the parser is on
action : Integer;
rule_id : Rule;
input_symbol : yy_tokens.Token := ERROR;
-- error recovery flag
error_flag : Natural := 0;
-- indicates 3 - (number of valid shifts after an error occurs)
look_ahead : Boolean := True;
index : reduce_row;
-- Is Debugging option on or off
debug : constant Boolean := False;
end yy;
procedure shift_debug (state_id : yy.parse_state; lexeme : yy_tokens.Token);
procedure reduce_debug (rule_id : Rule; state_id : yy.parse_state);
function goto_state
(state : yy.parse_state;
sym : Nonterminal) return yy.parse_state;
function parse_action
(state : yy.parse_state;
t : yy_tokens.Token) return Integer;
pragma Inline (goto_state, parse_action);
function goto_state (state : yy.parse_state;
sym : Nonterminal) return yy.parse_state is
index : goto_row;
begin
index := Goto_Offset (state);
while Goto_Matrix (index).Nonterm /= sym loop
index := index + 1;
end loop;
return Integer (Goto_Matrix (index).Newstate);
end goto_state;
function parse_action (state : yy.parse_state;
t : yy_tokens.Token) return Integer is
index : reduce_row;
tok_pos : Integer;
default : constant Integer := -1;
begin
tok_pos := yy_tokens.Token'Pos (t);
index := Shift_Reduce_Offset (state);
while Integer (Shift_Reduce_Matrix (index).T) /= tok_pos
and then Integer (Shift_Reduce_Matrix (index).T) /= default
loop
index := index + 1;
end loop;
return Integer (Shift_Reduce_Matrix (index).Act);
end parse_action;
-- error recovery stuff
procedure handle_error is
temp_action : Integer;
begin
if yy.error_flag = 3 then -- no shift yet, clobber input.
if yy.debug then
Text_IO.Put_Line (" -- Ayacc.YYParse: Error Recovery Clobbers "
& yy_tokens.Token'Image (yy.input_symbol));
end if;
if yy.input_symbol = yy_tokens.END_OF_INPUT then -- don't discard,
if yy.debug then
Text_IO.Put_Line (" -- Ayacc.YYParse: Can't discard END_OF_INPUT, quiting...");
end if;
raise yy_tokens.Syntax_Error;
end if;
yy.look_ahead := True; -- get next token
return; -- and try again...
end if;
if yy.error_flag = 0 then -- brand new error
yyerror ("Syntax Error");
end if;
yy.error_flag := 3;
-- find state on stack where error is a valid shift --
if yy.debug then
Text_IO.Put_Line (" -- Ayacc.YYParse: Looking for state with error as valid shift");
end if;
loop
if yy.debug then
Text_IO.Put_Line (" -- Ayacc.YYParse: Examining State "
& yy.parse_state'Image (yy.state_stack (yy.tos)));
end if;
temp_action := parse_action (yy.state_stack (yy.tos), ERROR);
if temp_action >= yy.first_shift_entry then
if yy.tos = yy.stack_size then
Text_IO.Put_Line (" -- Ayacc.YYParse: Stack size exceeded on state_stack");
raise yy_tokens.Syntax_Error;
end if;
yy.tos := yy.tos + 1;
yy.state_stack (yy.tos) := temp_action;
exit;
end if;
if yy.tos /= 0 then
yy.tos := yy.tos - 1;
end if;
if yy.tos = 0 then
if yy.debug then
Text_IO.Put_Line
(" -- Ayacc.YYParse: Error recovery popped entire stack, aborting...");
end if;
raise yy_tokens.Syntax_Error;
end if;
end loop;
if yy.debug then
Text_IO.Put_Line (" -- Ayacc.YYParse: Shifted error token in state "
& yy.parse_state'Image (yy.state_stack (yy.tos)));
end if;
end handle_error;
-- print debugging information for a shift operation
procedure shift_debug (state_id : yy.parse_state; lexeme : yy_tokens.Token) is
begin
Text_IO.Put_Line (" -- Ayacc.YYParse: Shift "
& yy.parse_state'Image (state_id) & " on input symbol "
& yy_tokens.Token'Image (lexeme));
end shift_debug;
-- print debugging information for a reduce operation
procedure reduce_debug (rule_id : Rule; state_id : yy.parse_state) is
begin
Text_IO.Put_Line (" -- Ayacc.YYParse: Reduce by rule "
& Rule'Image (rule_id) & " goto state "
& yy.parse_state'Image (state_id));
end reduce_debug;
-- make the parser believe that 3 valid shifts have occured.
-- used for error recovery.
procedure yyerrok is
begin
yy.error_flag := 0;
end yyerrok;
-- called to clear input symbol that caused an error.
procedure yyclearin is
begin
-- yy.input_symbol := YYLex;
yy.look_ahead := True;
end yyclearin;
begin
-- initialize by pushing state 0 and getting the first input symbol
yy.state_stack (yy.tos) := 0;
loop
yy.index := Shift_Reduce_Offset (yy.state_stack (yy.tos));
if Integer (Shift_Reduce_Matrix (yy.index).T) = yy.default then
yy.action := Integer (Shift_Reduce_Matrix (yy.index).Act);
else
if yy.look_ahead then
yy.look_ahead := False;
yy.input_symbol := YYLex;
end if;
yy.action := parse_action (yy.state_stack (yy.tos), yy.input_symbol);
end if;
if yy.action >= yy.first_shift_entry then -- SHIFT
if yy.debug then
shift_debug (yy.action, yy.input_symbol);
end if;
-- Enter new state
if yy.tos = yy.stack_size then
Text_IO.Put_Line (" Stack size exceeded on state_stack");
raise yy_tokens.Syntax_Error;
end if;
yy.tos := yy.tos + 1;
yy.state_stack (yy.tos) := yy.action;
yy.value_stack (yy.tos) := YYLVal;
if yy.error_flag > 0 then -- indicate a valid shift
yy.error_flag := yy.error_flag - 1;
end if;
-- Advance lookahead
yy.look_ahead := True;
elsif yy.action = yy.error_code then -- ERROR
handle_error;
elsif yy.action = yy.accept_code then
if yy.debug then
Text_IO.Put_Line (" -- Ayacc.YYParse: Accepting Grammar...");
end if;
exit;
else -- Reduce Action
-- Convert action into a rule
yy.rule_id := Rule (-1 * yy.action);
-- Execute User Action
-- user_action(yy.rule_id);
case yy.rule_id is
pragma Style_Checks (Off);
when 4 => -- #line 77
Error (yy.value_stack (yy.tos).Line, yy.value_stack (yy.tos).Column, "Invalid CSS selector component");
when 32 => -- #line 157
Current_Media := null;
when 33 => -- #line 160
Current_Media := null;
when 38 => -- #line 175
Current_Rule := null; Error (yylval.Line, yylval.Column, "Media condition error");
when 39 => -- #line 180
Current_Rule := null;
when 40 => -- #line 185
Current_Rule := null;
when 41 => -- #line 188
Error (yy.value_stack (yy.tos-2).Line, yy.value_stack (yy.tos-2).Column, "Invalid media selection after " & To_String (yy.value_stack (yy.tos-2))); yyerrok;
when 45 => -- #line 201
Current_Rule := null;
when 46 => -- #line 206
Current_Rule := null;
when 47 => -- #line 209
Current_Rule := null;
when 48 => -- #line 214
Current_Rule := null; Error (yy.value_stack (yy.tos-1).line, yy.value_stack (yy.tos).line, "Found @<font-face> rule");
when 49 => -- #line 219
Append_Media (Current_Media, Document, yy.value_stack (yy.tos));
when 50 => -- #line 222
Append_Media (Current_Media, Document, yy.value_stack (yy.tos));
when 53 => -- #line 233
Append_String (YYVal, yy.value_stack (yy.tos-1), yy.value_stack (yy.tos));
when 54 => -- #line 238
Set_String (YYVal, "not ", yy.value_stack (yy.tos-2).Line, yy.value_stack (yy.tos-2).Column); Append_String (YYVal, yy.value_stack (yy.tos));
when 55 => -- #line 241
Set_String (YYVal, "not ", yy.value_stack (yy.tos-3).Line, yy.value_stack (yy.tos-3).Column); Append_String (YYVal, yy.value_stack (yy.tos-1));
when 56 => -- #line 244
Set_String (YYVal, "only ", yy.value_stack (yy.tos-3).Line, yy.value_stack (yy.tos-3).Column); Append_String (YYVal, yy.value_stack (yy.tos-1));
when 57 => -- #line 247
YYVal := yy.value_stack (yy.tos-2); Append_String (YYVal, yy.value_stack (yy.tos));
when 59 => -- #line 255
Set_String (YYVal, " and ", yy.value_stack (yy.tos-2).Line, yy.value_stack (yy.tos-2).Column); Append_String (YYVal, yy.value_stack (yy.tos));
when 60 => -- #line 258
Set_String (YYVal, "", yylval.Line, yylval.Column);
when 63 => -- #line 269
YYVal := yy.value_stack (yy.tos-1); Append_String (YYVal, " "); Append_String (YYVal, yy.value_stack (yy.tos));
when 65 => -- #line 276
YYVal := yy.value_stack (yy.tos-1); Append_String (YYVal, " "); Append_String (YYVal, yy.value_stack (yy.tos));
when 67 => -- #line 283
Set_String (YYVal, "and ", yy.value_stack (yy.tos-2).Line, yy.value_stack (yy.tos-2).Column); Append_String (YYVal, yy.value_stack (yy.tos));
when 68 => -- #line 288
YYVal := yy.value_stack (yy.tos-1); Append_String (YYVal, " "); Append_String (YYVal, yy.value_stack (yy.tos));
when 70 => -- #line 295
Set_String (YYVal, "or ", yy.value_stack (yy.tos-1).Line, yy.value_stack (yy.tos-1).Column); Append_String (YYVal, yy.value_stack (yy.tos));
when 71 => -- #line 300
Set_String (YYVal, "(", yy.value_stack (yy.tos-3).Line, yy.value_stack (yy.tos-3).Column); Append_String (YYVal, yy.value_stack (yy.tos-3)); Append_String (YYVal, ")");
when 72 => -- #line 303
Set_String (YYVal, "(", yy.value_stack (yy.tos-3).Line, yy.value_stack (yy.tos-3).Column); Append_String (YYVal, yy.value_stack (yy.tos-3)); Append_String (YYVal, ")");
when 73 => -- #line 306
Set_String (YYVal, "(", yy.value_stack (yy.tos-3).Line, yy.value_stack (yy.tos-3).Column); Append_String (YYVal, yy.value_stack (yy.tos-3)); Append_String (YYVal, ")");
when 74 => -- #line 309
Error (yylval.Line, yylval.Column, "Invalid media in parens");
Set_String (YYVal, "", yylval.Line, yylval.Column); yyerrok;
when 75 => -- #line 315
Set_String (YYVal, "<=", yylval.Line, yylval.Column);
when 76 => -- #line 318
Set_String (YYVal, ">=", yylval.Line, yylval.Column);
when 77 => -- #line 321
Set_String (YYVal, ">", yylval.Line, yylval.Column);
when 78 => -- #line 324
Set_String (YYVal, "<", yylval.Line, yylval.Column);
when 79 => -- #line 329
YYVal := yy.value_stack (yy.tos-4); Append_String (YYVal, yy.value_stack (yy.tos-2)); Append_String (YYVal, yy.value_stack (yy.tos));
when 80 => -- #line 332
YYVal := yy.value_stack (yy.tos-6); Append_String (YYVal, yy.value_stack (yy.tos-4)); Append_String (YYVal, yy.value_stack (yy.tos-2)); Append_String (YYVal, yy.value_stack (yy.tos));
when 81 => -- #line 335
YYVal := yy.value_stack (yy.tos-4); Append_String (YYVal, yy.value_stack (yy.tos-2)); Append_String (YYVal, yy.value_stack (yy.tos));
when 82 => -- #line 338
YYVal := yy.value_stack (yy.tos-4); Append_String (YYVal, ": "); Append_String (YYVal, yy.value_stack (yy.tos));
when 84 => -- #line 345
YYVal := yy.value_stack (yy.tos);
when 85 => -- #line 348
YYVal := yy.value_stack (yy.tos);
when 86 => -- #line 353
Current_Page := null;
when 87 => -- #line 356
Current_Page := null;
when 88 => -- #line 361
null;
when 89 => -- #line 364
null;
when 90 => -- #line 369
Current_Page := new CSS.Core.Styles.CSSPageRule;
when 94 => -- #line 382
Set_Selector (YYVal, SEL_PSEUDO_ELEMENT, yy.value_stack (yy.tos));
when 95 => -- #line 387
Append_Property (Current_Page.Style, Document, yy.value_stack (yy.tos-1));
when 96 => -- #line 390
Append_Property (Current_Page.Style, Document, yy.value_stack (yy.tos-1));
when 97 => -- #line 395
YYVal := yy.value_stack (yy.tos-1);
when 98 => -- #line 398
YYVal := yy.value_stack (yy.tos-1);
when 99 => -- #line 403
Set_Selector_Type (YYVal, SEL_NEXT_SIBLING, yylineno, yylinecol);
when 100 => -- #line 406
Set_Selector_Type (YYVal, SEL_CHILD, yylineno, yylinecol);
when 101 => -- #line 409
Set_Selector_Type (YYVal, SEL_FOLLOWING_SIBLING, yylineno, yylinecol);
when 104 => -- #line 420
Current_Rule := null;
when 105 => -- #line 423
Current_Rule := null; Error (yy.value_stack (yy.tos-1).line, yy.value_stack (yy.tos-1).column, "Invalid CSS rule");
when 106 => -- #line 426
Current_Rule := null;
when 107 => -- #line 429
Error (yy.value_stack (yy.tos-2).Line, yy.value_stack (yy.tos-2).Column, "Syntax error in CSS rule");
when 108 => -- #line 434
YYVal := yy.value_stack (yy.tos-1);
when 109 => -- #line 437
YYVal := yy.value_stack (yy.tos);
when 111 => -- #line 444
Error (yy.value_stack (yy.tos-1).Line, yy.value_stack (yy.tos-1).Column, "Invalid CSS selector component");
when 112 => -- #line 449
Add_Selector_List (Current_Rule, Current_Media, Document, yy.value_stack (yy.tos));
when 113 => -- #line 452
Add_Selector_List (Current_Rule, Current_Media, Document, yy.value_stack (yy.tos));
when 114 => -- #line 457
Add_Selector (yy.value_stack (yy.tos-3), yy.value_stack (yy.tos-2), yy.value_stack (yy.tos-1)); YYVal := yy.value_stack (yy.tos-3);
when 115 => -- #line 460
Add_Selector (yy.value_stack (yy.tos-2), yy.value_stack (yy.tos-1)); YYVal := yy.value_stack (yy.tos-2);
when 116 => -- #line 463
YYVal := yy.value_stack (yy.tos-1);
when 117 => -- #line 468
Add_Selector_Filter (yy.value_stack (yy.tos-1), yy.value_stack (yy.tos)); YYVal := yy.value_stack (yy.tos-1);
when 119 => -- #line 475
Set_Selector (YYVal, SEL_ELEMENT, yy.value_stack (yy.tos));
when 120 => -- #line 478
Set_Selector (YYVal, SEL_IDENT, yy.value_stack (yy.tos));
when 121 => -- #line 481
Set_Selector (YYVal, SEL_CLASS, yy.value_stack (yy.tos));
when 124 => -- #line 488
Set_Selector (YYVal, SEL_NOT, yy.value_stack (yy.tos-2));
when 129 => -- #line 503
YYVal := yy.value_stack (yy.tos);
when 130 => -- #line 508
YYVal := yy.value_stack (yy.tos);
when 137 => -- #line 527
Set_Selector (YYVal, SEL_HAS_ATTRIBUTE, yy.value_stack (yy.tos-2));
when 138 => -- #line 530
Set_Selector (YYVal, yy.value_stack (yy.tos-4).Sel, yy.value_stack (yy.tos-6), yy.value_stack (yy.tos-2));
when 139 => -- #line 533
Set_Selector (YYVal, yy.value_stack (yy.tos-4).Sel, yy.value_stack (yy.tos-6), yy.value_stack (yy.tos-2));
when 140 => -- #line 536
Error (yy.value_stack (yy.tos).Line, yy.value_stack (yy.tos).column, "Invalid attribute definition.");
when 141 => -- #line 541
Set_Selector_Type (YYVal, SEL_EQ_ATTRIBUTE, yylineno, yylinecol);
when 142 => -- #line 544
Set_Selector_Type (YYVal, SEL_CONTAIN_ATTRIBUTE, yylineno, yylinecol);
when 143 => -- #line 547
Set_Selector_Type (YYVal, SEL_ORMATCH_ATTRIBUTE, yylineno, yylinecol);
when 144 => -- #line 550
Set_Selector_Type (YYVal, SEL_STARTS_ATTRIBUTE, yylineno, yylinecol);
when 145 => -- #line 553
Set_Selector_Type (YYVal, SEL_ENDS_ATTRIBUTE, yylineno, yylinecol);
when 146 => -- #line 556
Set_Selector_Type (YYVal, SEL_MATCH_ATTRIBUTE, yylineno, yylinecol);
when 147 => -- #line 561
Set_Selector (YYVal, SEL_PSEUDO_ELEMENT, yy.value_stack (yy.tos));
when 148 => -- #line 564
Set_Selector (YYVal, SEL_PSEUDO_CLASS, yy.value_stack (yy.tos));
when 149 => -- #line 567
Set_Selector (YYVal, SEL_FUNCTION, yy.value_stack (yy.tos-3));
when 152 => -- #line 578
YYVal := yy.value_stack (yy.tos);
when 153 => -- #line 583
YYVal := yy.value_stack (yy.tos);
when 154 => -- #line 586
YYVal := yy.value_stack (yy.tos-4);
when 155 => -- #line 589
YYVal := yy.value_stack (yy.tos-1);
when 156 => -- #line 594
Append_Property (Current_Rule, Current_Media, Document, yy.value_stack (yy.tos-1));
when 157 => -- #line 597
Append_Property (Current_Rule, Current_Media, Document, yy.value_stack (yy.tos));
Error (yy.value_stack (yy.tos-3).Line, yy.value_stack (yy.tos-3).Column, "Invalid property"); yyerrok;
when 158 => -- #line 601
YYVal := yy.value_stack (yy.tos-2); Error (yy.value_stack (yy.tos-1).Line, yy.value_stack (yy.tos-1).Column, "Invalid property (2)"); yyerrok;
when 159 => -- #line 604
Append_Property (Current_Rule, Current_Media, Document, yy.value_stack (yy.tos-1));
when 162 => -- #line 615
Set_Property (YYVal, yy.value_stack (yy.tos-4), yy.value_stack (yy.tos-1), True);
when 163 => -- #line 618
Set_Property (YYVal, yy.value_stack (yy.tos-3), yy.value_stack (yy.tos), False);
when 164 => -- #line 621
Error (yy.value_stack (yy.tos).Line, yy.value_stack (yy.tos).Column, "Missing ''' or '""' at end of string");
Set_Property (YYVal, yy.value_stack (yy.tos-3), EMPTY, False);
yyclearin;
when 165 => -- #line 627
Error (yy.value_stack (yy.tos).Line, yy.value_stack (yy.tos).Column, "Invalid property value: " & YYText);
Set_Property (YYVal, yy.value_stack (yy.tos-2), yy.value_stack (yy.tos-2), False);
yyclearin;
when 166 => -- #line 633
Error (yy.value_stack (yy.tos-1).Line, yy.value_stack (yy.tos-1).Column, "Missing ':' after property name");
Set_Property (YYVal, yy.value_stack (yy.tos-1), EMPTY, False);
yyclearin;
when 167 => -- #line 639
Error (yylval.Line, yylval.Column, "Invalid property name"); YYVal := EMPTY;
when 168 => -- #line 644
YYVal := yy.value_stack (yy.tos-1);
when 169 => -- #line 647
Warning (yy.value_stack (yy.tos-1).Line, yy.value_stack (yy.tos-1).Column, "IE7 '*' symbol hack is used"); YYVal := yy.value_stack (yy.tos-1);
when 171 => -- #line 656
CSS.Parser.Set_Function (YYVal, Document, yy.value_stack (yy.tos-4), yy.value_stack (yy.tos-2));
when 172 => -- #line 659
CSS.Parser.Set_Function (YYVal, Document, yy.value_stack (yy.tos-3), yy.value_stack (yy.tos-1));
when 173 => -- #line 662
Error (yy.value_stack (yy.tos-3).Line, yy.value_stack (yy.tos-3).Column, "Invalid function parameter");
when 174 => -- #line 667
CSS.Parser.Set_Expr (YYVal, yy.value_stack (yy.tos-3), yy.value_stack (yy.tos));
when 175 => -- #line 670
CSS.Parser.Set_Expr (YYVal, yy.value_stack (yy.tos-1), yy.value_stack (yy.tos));
when 176 => -- #line 673
YYVal := yy.value_stack (yy.tos);
when 177 => -- #line 678
CSS.Parser.Set_Expr (YYVal, yy.value_stack (yy.tos-3), yy.value_stack (yy.tos));
when 178 => -- #line 681
CSS.Parser.Set_Expr (YYVal, yy.value_stack (yy.tos-3), yy.value_stack (yy.tos));
when 179 => -- #line 684
CSS.Parser.Set_Expr (YYVal, yy.value_stack (yy.tos-1), yy.value_stack (yy.tos));
when 180 => -- #line 687
YYVal := yy.value_stack (yy.tos);
when 181 => -- #line 690
YYVal := yy.value_stack (yy.tos-1); -- CSS.Parser.Set_Parameter ($$, Document, $1, $5);
when 182 => -- #line 696
CSS.Parser.Set_Expr (YYVal, yy.value_stack (yy.tos-2), yy.value_stack (yy.tos));
when 183 => -- #line 699
CSS.Parser.Set_Expr (YYVal, yy.value_stack (yy.tos-1), yy.value_stack (yy.tos));
when 185 => -- #line 706
CSS.Parser.Set_Value (YYVal, Document, yy.value_stack (yy.tos));
when 186 => -- #line 709
CSS.Parser.Set_Value (YYVal, Document, yy.value_stack (yy.tos));
when 187 => -- #line 712
CSS.Parser.Set_Value (YYVal, Document, yy.value_stack (yy.tos));
when 188 => -- #line 715
CSS.Parser.Set_Value (YYVal, Document, yy.value_stack (yy.tos-1));
when 189 => -- #line 718
CSS.Parser.Set_Value (YYVal, Document, yy.value_stack (yy.tos-1));
when 190 => -- #line 721
CSS.Parser.Set_Value (YYVal, Document, yy.value_stack (yy.tos-1));
when 191 => -- #line 724
CSS.Parser.Set_Value (YYVal, Document, yy.value_stack (yy.tos));
when 192 => -- #line 727
YYVal := yy.value_stack (yy.tos);
when 193 => -- #line 730
Error (yy.value_stack (yy.tos).Line, yy.value_stack (yy.tos).Column, "Invalid url()"); YYVal := EMPTY;
when 194 => -- #line 735
YYVal := yy.value_stack (yy.tos-1);
when 195 => -- #line 738
YYVal := yy.value_stack (yy.tos-1);
when 196 => -- #line 741
YYVal := yy.value_stack (yy.tos-1);
when 197 => -- #line 744
YYVal := yy.value_stack (yy.tos-1);
when 198 => -- #line 747
YYVal := yy.value_stack (yy.tos-1);
when 199 => -- #line 750
YYVal := yy.value_stack (yy.tos-1);
when 200 => -- #line 753
YYVal := yy.value_stack (yy.tos-1);
when 201 => -- #line 756
YYVal := yy.value_stack (yy.tos-1);
when 202 => -- #line 761
Set_Color (YYVal, yy.value_stack (yy.tos-1));
pragma Style_Checks (On);
when others => null;
end case;
-- Pop RHS states and goto next state
yy.tos := yy.tos - Rule_Length (yy.rule_id) + 1;
if yy.tos > yy.stack_size then
Text_IO.Put_Line (" Stack size exceeded on state_stack");
raise yy_tokens.Syntax_Error;
end if;
yy.state_stack (yy.tos) := goto_state (yy.state_stack (yy.tos - 1),
Get_LHS_Rule (yy.rule_id));
yy.value_stack (yy.tos) := YYVal;
if yy.debug then
reduce_debug (yy.rule_id,
goto_state (yy.state_stack (yy.tos - 1),
Get_LHS_Rule (yy.rule_id)));
end if;
end if;
end loop;
end YYParse;
end CSS.Parser.Parser;
|
reznikmm/matreshka | Ada | 4,684 | 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.Anim_Animate_Elements;
package Matreshka.ODF_Anim.Animate_Elements is
type Anim_Animate_Element_Node is
new Matreshka.ODF_Anim.Abstract_Anim_Element_Node
and ODF.DOM.Anim_Animate_Elements.ODF_Anim_Animate
with null record;
overriding function Create
(Parameters : not null access Matreshka.DOM_Elements.Element_L2_Parameters)
return Anim_Animate_Element_Node;
overriding function Get_Local_Name
(Self : not null access constant Anim_Animate_Element_Node)
return League.Strings.Universal_String;
overriding procedure Enter_Node
(Self : not null access Anim_Animate_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 Anim_Animate_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 Anim_Animate_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_Anim.Animate_Elements;
|
zhmu/ananas | Ada | 2,247 | ads | ------------------------------------------------------------------------------
-- --
-- GNAT RUN-TIME COMPONENTS --
-- --
-- A D A . W I D E _ T E X T _ I O . E N U M E R A T I O N _ I O --
-- --
-- S p e c --
-- --
-- This specification is derived from the Ada Reference Manual for use with --
-- GNAT. In accordance with the copyright of that document, you can freely --
-- copy and modify this specification, provided that if you redistribute a --
-- modified version, any changes that you have made are clearly indicated. --
-- --
------------------------------------------------------------------------------
-- In Ada 95, the package Ada.Wide_Text_IO.Enumeration_IO is a subpackage
-- of Wide_Text_IO. In GNAT we make it a child package to avoid loading the
-- necessary code if Enumeration_IO is not instantiated. See the routine
-- Rtsfind.Check_Text_IO_Special_Unit for a description of how we patch up
-- the difference in semantics so that it is invisible to the Ada programmer.
private generic
type Enum is (<>);
package Ada.Wide_Text_IO.Enumeration_IO is
Default_Width : Field := 0;
Default_Setting : Type_Set := Upper_Case;
procedure Get (File : File_Type; Item : out Enum);
procedure Get (Item : out Enum);
procedure Put
(File : File_Type;
Item : Enum;
Width : Field := Default_Width;
Set : Type_Set := Default_Setting);
procedure Put
(Item : Enum;
Width : Field := Default_Width;
Set : Type_Set := Default_Setting);
procedure Get
(From : Wide_String;
Item : out Enum;
Last : out Positive);
procedure Put
(To : out Wide_String;
Item : Enum;
Set : Type_Set := Default_Setting);
end Ada.Wide_Text_IO.Enumeration_IO;
|
zhmu/ananas | Ada | 257 | adb | -- { dg-do run }
-- { dg-options "-g -O0 -gnata" }
procedure Concat3 is
procedure Show_Bug (S : in String)
is
Str : constant String := S & "-" with Alignment => 4;
begin
null;
end Show_Bug;
begin
Show_Bug ("BUG");
end Concat3; |
reznikmm/matreshka | Ada | 5,517 | ads | ------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- Web Framework --
-- --
-- Runtime Library Component --
-- --
------------------------------------------------------------------------------
-- --
-- Copyright © 2015, Vadim Godunko <[email protected]> --
-- All rights reserved. --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions --
-- are met: --
-- --
-- * Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- --
-- * Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in the --
-- documentation and/or other materials provided with the distribution. --
-- --
-- * Neither the name of the Vadim Godunko, IE nor the names of its --
-- contributors may be used to endorse or promote products derived from --
-- this software without specific prior written permission. --
-- --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR --
-- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
-- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED --
-- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR --
-- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF --
-- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING --
-- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS --
-- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
-- --
------------------------------------------------------------------------------
-- $Revision$ $Date$
------------------------------------------------------------------------------
private with Ada.Containers.Hashed_Maps;
with Spikedog.HTTP_Session_Managers;
with OPM.Stores;
package AWFC.Accounts.Sessions.Stores is
-- procedure Update_Last_Accessed_Time (Session : not null Session_Access);
-- Updates last_accessed_time to current time and update corresponding
-- field in database.
type Session_Manager is
new OPM.Stores.Abstract_Store
and Spikedog.HTTP_Session_Managers.HTTP_Session_Manager
with private;
overriding function Is_Session_Identifier_Valid
(Self : Session_Manager;
Identifier : League.Strings.Universal_String) return Boolean;
-- Returns True when given session identifier is valid (it can be processed
-- by session manager, but not necessary points to any active session).
overriding procedure Initialize (Self : in out Session_Manager);
overriding function Get_Session
(Self : in out Session_Manager;
Identifier : League.Strings.Universal_String)
return access Servlet.HTTP_Sessions.HTTP_Session'Class;
-- Returns session this specified identifier, or null when session with
-- given identifier is not known. When session is found its last access
-- time attribute is updated to current time.
overriding function New_Session
(Self : in out Session_Manager)
return access Servlet.HTTP_Sessions.HTTP_Session'Class;
procedure Update_User
(Self : in out Session_Manager'Class;
Session : not null Session_Access);
-- Update user identifer in database.
procedure Update_Session_Identifier
(Self : in out Session_Manager'Class;
Session : not null Session_Access;
Old : Session_Identifier);
-- Updates session identifier in database.
private
function Hash (Item : Session_Identifier) return Ada.Containers.Hash_Type;
package Session_Maps is
new Ada.Containers.Hashed_Maps
(Session_Identifier, Session_Access, Hash, "=");
type Session_Manager is
new OPM.Stores.Abstract_Store
and Spikedog.HTTP_Session_Managers.HTTP_Session_Manager with
record
Sessions : Session_Maps.Map;
end record;
end AWFC.Accounts.Sessions.Stores;
|
AdaCore/gpr | Ada | 3,568 | ads | ------------------------------------------------------------------------------
-- --
-- GPR2 PROJECT MANAGER --
-- --
-- Copyright (C) 2019-2023, AdaCore --
-- --
-- This is free software; you can redistribute it and/or modify it under --
-- terms of the GNU General Public License as published by the Free Soft- --
-- ware Foundation; either version 3, or (at your option) any later ver- --
-- sion. This software is distributed in the hope that it will be useful, --
-- but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHAN- --
-- TABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public --
-- License for more details. You should have received a copy of the GNU --
-- General Public License distributed with GNAT; see file COPYING. If not, --
-- see <http://www.gnu.org/licenses/>. --
-- --
------------------------------------------------------------------------------
with Ada.Strings.Unbounded;
with GPRname.Common;
with GPRname.Section;
with GPRname.Section.Vector;
package GPRname.Options is
use Ada.Strings.Unbounded;
use GPRname.Common;
use GPRname.Section;
type Object is tagged private;
-- Options for gprname
procedure Build_From_Command_Line (Self : in out Object);
-- Fill out a gprname options object from the command line
function Ignore_Duplicate_Files (Self : Object) return Boolean;
-- Returns the Ignore_Duplicate_Files flag for Self
function Ignore_Predefined_Units (Self : Object) return Boolean;
-- Returns the Ignore_Predefined_Units flag for Self
function No_Backup (Self : Object) return Boolean;
-- Returns the No_Backup flag for Self
function Prep_Switches (Self : Object) return String_Vector.Vector;
-- Returns the preprocessor switches for Self
function Project_File (Self : Object) return String;
-- Returns the project file for Self
function RTS (Self : Object) return String;
-- Returns the runtime for Self
function Target (Self : Object) return String;
-- Returns the target for Self
function Verbosity (Self : Object) return Verbosity_Level_Type;
-- Return the verbosity level for Self
function Sections (Self : Object) return Section.Vector.Object;
-- Returns the sections for Self
function Minimal_Dirs (Self : Object) return Boolean;
-- Returns the Minimal_Dirs flag for Self
private
type Object is tagged record
Project_File : Unbounded_String := Null_Unbounded_String;
Target : Unbounded_String := Null_Unbounded_String;
RTS : Unbounded_String := Null_Unbounded_String;
Verbosity : Verbosity_Level_Type := None;
Ignore_Duplicate_Files : Boolean := False;
Ignore_Predefined_Units : Boolean := False;
Follow_Symlinks : Boolean := False;
No_Backup : Boolean := False;
Minimal_Dirs : Boolean := False;
Verbose_Parsing : Integer := 0;
Sections : Section.Vector.Object;
Prep_Switches : String_Vector.Vector;
end record;
end GPRname.Options;
|
reznikmm/matreshka | Ada | 4,662 | ads | ------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- Open Document Toolkit --
-- --
-- Runtime Library Component --
-- --
------------------------------------------------------------------------------
-- --
-- Copyright © 2014, Vadim Godunko <[email protected]> --
-- All rights reserved. --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions --
-- are met: --
-- --
-- * Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- --
-- * Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in the --
-- documentation and/or other materials provided with the distribution. --
-- --
-- * Neither the name of the Vadim Godunko, IE nor the names of its --
-- contributors may be used to endorse or promote products derived from --
-- this software without specific prior written permission. --
-- --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR --
-- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
-- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED --
-- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR --
-- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF --
-- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING --
-- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS --
-- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
-- --
------------------------------------------------------------------------------
-- $Revision$ $Date$
------------------------------------------------------------------------------
with XML.DOM.Visitors;
with ODF.DOM.Form_Frame_Elements;
package Matreshka.ODF_Form.Frame_Elements is
type Form_Frame_Element_Node is
new Matreshka.ODF_Form.Abstract_Form_Element_Node
and ODF.DOM.Form_Frame_Elements.ODF_Form_Frame
with null record;
overriding function Create
(Parameters : not null access Matreshka.DOM_Elements.Element_L2_Parameters)
return Form_Frame_Element_Node;
overriding function Get_Local_Name
(Self : not null access constant Form_Frame_Element_Node)
return League.Strings.Universal_String;
overriding procedure Enter_Node
(Self : not null access Form_Frame_Element_Node;
Visitor : in out XML.DOM.Visitors.Abstract_Visitor'Class;
Control : in out XML.DOM.Visitors.Traverse_Control);
overriding procedure Leave_Node
(Self : not null access Form_Frame_Element_Node;
Visitor : in out XML.DOM.Visitors.Abstract_Visitor'Class;
Control : in out XML.DOM.Visitors.Traverse_Control);
overriding procedure Visit_Node
(Self : not null access Form_Frame_Element_Node;
Iterator : in out XML.DOM.Visitors.Abstract_Iterator'Class;
Visitor : in out XML.DOM.Visitors.Abstract_Visitor'Class;
Control : in out XML.DOM.Visitors.Traverse_Control);
end Matreshka.ODF_Form.Frame_Elements;
|
kjseefried/coreland-cgbc | Ada | 946 | adb | with Ada.Strings;
with CGBC.Bounded_Strings;
with Test;
procedure T_Bstr_Append_E01 is
package BS renames CGBC.Bounded_Strings;
TC : Test.Context_t;
S1 : BS.Bounded_String (8);
Caught : Boolean;
begin
Test.Initialize
(Test_Context => TC,
Program => "t_bstr_append_e01",
Test_DB => "TEST_DB",
Test_Results => "TEST_RESULTS");
BS.Append (S1, "ABCD");
pragma Assert (BS.Length (S1) = 4);
begin
Caught := False;
BS.Append
(Source => S1,
New_Item => "012345678",
Drop => Ada.Strings.Error);
exception
when Ada.Strings.Length_Error => Caught := True;
end;
Test.Check (TC, 205, Caught, "Caught");
Test.Check (TC, 206, BS.Length (S1) = 4, "BS.Length (S1) = 4");
Test.Check (TC, 207, BS.Maximum_Length (S1) = 8, "BS.Maximum_Length (S1) = 8");
Test.Check (TC, 208, BS.To_String (S1) = "ABCD", "BS.To_String (S1) = ""ABCD""");
end T_Bstr_Append_E01;
|
reznikmm/matreshka | Ada | 4,597 | 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_Db.Is_Nullable_Attributes is
------------
-- Create --
------------
overriding function Create
(Parameters : not null access Matreshka.DOM_Attributes.Attribute_L2_Parameters)
return Db_Is_Nullable_Attribute_Node is
begin
return Self : Db_Is_Nullable_Attribute_Node do
Matreshka.ODF_Db.Constructors.Initialize
(Self'Unchecked_Access,
Parameters.Document,
Matreshka.ODF_String_Constants.Db_Prefix);
end return;
end Create;
--------------------
-- Get_Local_Name --
--------------------
overriding function Get_Local_Name
(Self : not null access constant Db_Is_Nullable_Attribute_Node)
return League.Strings.Universal_String
is
pragma Unreferenced (Self);
begin
return Matreshka.ODF_String_Constants.Is_Nullable_Attribute;
end Get_Local_Name;
begin
Matreshka.DOM_Documents.Register_Attribute
(Matreshka.ODF_String_Constants.Db_URI,
Matreshka.ODF_String_Constants.Is_Nullable_Attribute,
Db_Is_Nullable_Attribute_Node'Tag);
end Matreshka.ODF_Db.Is_Nullable_Attributes;
|
reznikmm/matreshka | Ada | 4,592 | 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.Visible_Attributes is
------------
-- Create --
------------
overriding function Create
(Parameters : not null access Matreshka.DOM_Attributes.Attribute_L2_Parameters)
return Chart_Visible_Attribute_Node is
begin
return Self : Chart_Visible_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_Visible_Attribute_Node)
return League.Strings.Universal_String
is
pragma Unreferenced (Self);
begin
return Matreshka.ODF_String_Constants.Visible_Attribute;
end Get_Local_Name;
begin
Matreshka.DOM_Documents.Register_Attribute
(Matreshka.ODF_String_Constants.Chart_URI,
Matreshka.ODF_String_Constants.Visible_Attribute,
Chart_Visible_Attribute_Node'Tag);
end Matreshka.ODF_Chart.Visible_Attributes;
|
reznikmm/matreshka | Ada | 6,059 | adb | ------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- SQL Database Access --
-- --
-- Testsuite 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$
------------------------------------------------------------------------------
-- Check whether string value returned by SQLite3 database driver is
-- terminated properly.
------------------------------------------------------------------------------
with League.Holders.Integers;
with League.Strings;
with SQL.Databases;
with SQL.Options;
with SQL.Queries;
with Matreshka.Internals.SQL_Drivers.SQLite3.Factory;
pragma Unreferenced (Matreshka.Internals.SQL_Drivers.SQLite3.Factory);
procedure Main is
use type League.Strings.Universal_String;
function "+"
(Item : Wide_Wide_String) return League.Strings.Universal_String
renames League.Strings.To_Universal_String;
DB_Driver : constant League.Strings.Universal_String := +"SQLITE3";
DB_Options : SQL.Options.SQL_Options;
S1 : constant League.Strings.Universal_String := +"01234567890123456789";
S2 : constant League.Strings.Universal_String := +"0123456789";
Database : aliased SQL.Databases.SQL_Database
:= SQL.Databases.Create (DB_Driver, DB_Options);
begin
Database.Open;
declare
Query : SQL.Queries.SQL_Query := Database.Query;
begin
Query.Prepare
(+"CREATE TABLE test_data (id INTEGER, text CHARACTER VARYING (255))");
Query.Execute;
Query.Prepare
(+"INSERT INTO test_data (id, text) VALUES (:id, :text)");
Query.Bind_Value (+":id", League.Holders.Integers.To_Holder (1));
Query.Bind_Value (+":text", League.Holders.To_Holder (S1));
Query.Execute;
Query.Prepare
(+"INSERT INTO test_data (id, text) VALUES (:id, :text)");
Query.Bind_Value (+":id", League.Holders.Integers.To_Holder (2));
Query.Bind_Value (+":text", League.Holders.To_Holder (S2));
Query.Execute;
end;
declare
Query : SQL.Queries.SQL_Query := Database.Query;
R1 : League.Strings.Universal_String;
begin
Query.Prepare
(+"SELECT text FROM test_data WHERE id = :id");
Query.Bind_Value (+":id", League.Holders.Integers.To_Holder (1));
Query.Execute;
if not Query.Next then
raise Program_Error;
end if;
R1 := League.Holders.Element (Query.Value (1));
if R1 /= S1 then
raise Program_Error;
end if;
end;
declare
Query : SQL.Queries.SQL_Query := Database.Query;
R2 : League.Strings.Universal_String;
begin
Query.Prepare
(+"SELECT text FROM test_data WHERE id = :id");
Query.Bind_Value (+":id", League.Holders.Integers.To_Holder (2));
Query.Execute;
if not Query.Next then
raise Program_Error;
end if;
R2 := League.Holders.Element (Query.Value (1));
if R2 /= S2 then
raise Program_Error;
end if;
end;
Database.Close;
end Main;
|
charlie5/lace | Ada | 416 | ads | with
freetype_c.Pointers;
package freetype_c.FT_Size
is
subtype Item is Pointers.FT_SizeRec_Pointer;
type Item_array is array (C.Size_t range <>) of aliased FT_Size.Item;
type Pointer is access all freetype_c.FT_Size.Item;
type Pointer_array is array (C.Size_t range <>) of aliased FT_Size.Pointer;
type pointer_Pointer is access all FT_Size.Pointer;
end freetype_c.FT_Size;
|
Robert-Tice/EmbeddedFractal | Ada | 3,365 | adb | package body Fractal_Impl is
procedure Init (Viewport : Viewport_Info) is
begin
Float_Julia_Fractal.Init (Viewport => Viewport);
Fixed_Julia_Fractal.Init (Viewport => Viewport);
end Init;
procedure Compute_Image (Buffer : in out Buffer_Access)
is
begin
case Current_Computation is
when Fixed_Type =>
-- Fixed_Julia_Fractal.Increment_Frame;
Fixed_Julia_Fractal.Calculate_Image
(Buffer => Buffer);
when Float_Type =>
-- Float_Julia_Fractal.Increment_Frame;
Float_Julia_Fractal.Calculate_Image
(Buffer => Buffer);
end case;
end Compute_Image;
procedure Increment_Frame
is
begin
if Cnt_Up then
if Frame_Counter = UInt5'Last then
Cnt_Up := not Cnt_Up;
return;
else
Frame_Counter := Frame_Counter + 1;
return;
end if;
end if;
if Frame_Counter = UInt5'First then
Cnt_Up := not Cnt_Up;
return;
end if;
Frame_Counter := Frame_Counter - 1;
end Increment_Frame;
procedure RGB565_Color_Pixel (Z_Escape : Boolean;
Iter_Escape : Natural;
Px : out RGB565_Pixel)
is
Value : constant Integer := 765 * (Iter_Escape - 1) / Max_Iterations;
begin
if Z_Escape then
if Value > 510 then
Px := RGB565_Pixel'(Red => UInt5'Last - Frame_Counter,
Green => UInt6'Last,
Blue => UInt5 (Value rem Integer (UInt5'Last)));
elsif Value > 255 then
Px := RGB565_Pixel'(Red => UInt5'Last - Frame_Counter,
Green => UInt6 (Value rem Integer (UInt6'Last)),
Blue => UInt5'First + Frame_Counter);
else
Px := RGB565_Pixel'(Red => UInt5 (Value rem Integer (UInt5'Last)),
Green => UInt6'First + UInt6 (Frame_Counter),
Blue => UInt5'First);
end if;
else
Px := RGB565_Pixel'(Red => UInt5'First + Frame_Counter,
Green => UInt6'First + UInt6 (Frame_Counter),
Blue => UInt5'First + Frame_Counter);
end if;
end RGB565_Color_Pixel;
procedure Set_Computation_Type (Comp_Type : Computation_Enum)
is
begin
Current_Computation := Comp_Type;
end Set_Computation_Type;
procedure Compute_Row (Row : Natural;
Buffer : in out Buffer_Access)
is
begin
case Current_Computation is
when Fixed_Type =>
-- Fixed_Julia_Fractal.Increment_Frame;
Fixed_Julia_Fractal.Calculate_Row (Y => Row,
Idx => Buffer'First,
Buffer => Buffer);
when Float_Type =>
-- Float_Julia_Fractal.Increment_Frame;
Float_Julia_Fractal.Calculate_Row (Y => Row,
Idx => Buffer'First,
Buffer => Buffer);
end case;
end Compute_Row;
end Fractal_Impl;
|
sungyeon/drake | Ada | 10,480 | ads | pragma License (Unrestricted);
-- implementation unit
with Ada.IO_Exceptions;
with Ada.IO_Modes;
with Ada.Streams.Naked_Stream_IO.Standard_Files;
with System.Native_IO;
with System.Native_Text_IO;
package Ada.Naked_Text_IO is
-- the parameter Form
Default_Form : constant System.Native_Text_IO.Packed_Form := (
Stream_Form => Streams.Naked_Stream_IO.Default_Form,
External => IO_Modes.By_Target,
New_Line => IO_Modes.By_Target);
procedure Set (
Form : in out System.Native_Text_IO.Packed_Form;
Keyword : String;
Item : String);
function Pack (Form : String) return System.Native_Text_IO.Packed_Form;
procedure Unpack (
Form : System.Native_Text_IO.Packed_Form;
Result : out Streams.Naked_Stream_IO.Form_String;
Last : out Natural);
-- non-controlled
type Text_Type (<>) is limited private;
type Non_Controlled_File_Type is access all Text_Type;
procedure Create (
File : in out Non_Controlled_File_Type;
Mode : IO_Modes.File_Mode := IO_Modes.Out_File;
Name : String := "";
Form : System.Native_Text_IO.Packed_Form := Default_Form);
procedure Open (
File : in out Non_Controlled_File_Type;
Mode : IO_Modes.File_Mode;
Name : String;
Form : System.Native_Text_IO.Packed_Form := Default_Form);
procedure Close (
File : aliased in out Non_Controlled_File_Type;
Raise_On_Error : Boolean := True);
procedure Delete (File : aliased in out Non_Controlled_File_Type);
procedure Reset (
File : aliased in out Non_Controlled_File_Type;
Mode : IO_Modes.File_Mode);
function Mode (File : Non_Controlled_File_Type) return IO_Modes.File_Mode;
function Name (File : Non_Controlled_File_Type) return String;
function Form (File : Non_Controlled_File_Type)
return System.Native_Text_IO.Packed_Form;
function External (File : Non_Controlled_File_Type)
return IO_Modes.File_External;
pragma Inline (External);
function Is_Open (File : Non_Controlled_File_Type) return Boolean;
pragma Inline (Is_Open);
procedure Flush (File : Non_Controlled_File_Type);
procedure Set_Size (
File : Non_Controlled_File_Type;
Line_Length, Page_Length : Natural);
procedure Set_Line_Length (File : Non_Controlled_File_Type; To : Natural);
procedure Set_Page_Length (File : Non_Controlled_File_Type; To : Natural);
procedure Size (
File : Non_Controlled_File_Type;
Line_Length, Page_Length : out Natural);
function Line_Length (File : Non_Controlled_File_Type) return Natural;
function Page_Length (File : Non_Controlled_File_Type) return Natural;
pragma Inline (Line_Length);
pragma Inline (Page_Length);
procedure New_Line (
File : Non_Controlled_File_Type;
Spacing : Positive := 1);
procedure Skip_Line (
File : Non_Controlled_File_Type;
Spacing : Positive := 1);
function End_Of_Line (File : Non_Controlled_File_Type) return Boolean;
procedure New_Page (File : Non_Controlled_File_Type);
procedure Skip_Page (File : Non_Controlled_File_Type);
function End_Of_Page (File : Non_Controlled_File_Type) return Boolean;
function End_Of_File (File : Non_Controlled_File_Type) return Boolean;
procedure Set_Col (File : Non_Controlled_File_Type; To : Positive);
procedure Set_Line (File : Non_Controlled_File_Type; To : Positive);
procedure Position (
File : Non_Controlled_File_Type;
Col, Line : out Positive);
function Col (File : Non_Controlled_File_Type) return Positive;
function Line (File : Non_Controlled_File_Type) return Positive;
function Page (File : Non_Controlled_File_Type) return Positive;
pragma Inline (Col);
pragma Inline (Line);
pragma Inline (Page);
procedure Get (
File : Non_Controlled_File_Type;
Item : out Character);
procedure Get (
File : Non_Controlled_File_Type;
Item : out Wide_Character);
procedure Get (
File : Non_Controlled_File_Type;
Item : out Wide_Wide_Character);
procedure Put (
File : Non_Controlled_File_Type;
Item : Character);
procedure Put (
File : Non_Controlled_File_Type;
Item : Wide_Character);
procedure Put (
File : Non_Controlled_File_Type;
Item : Wide_Wide_Character);
procedure Look_Ahead (
File : Non_Controlled_File_Type;
Item : out Character;
End_Of_Line : out Boolean);
procedure Look_Ahead (
File : Non_Controlled_File_Type;
Item : out Wide_Character;
End_Of_Line : out Boolean);
procedure Look_Ahead (
File : Non_Controlled_File_Type;
Item : out Wide_Wide_Character;
End_Of_Line : out Boolean);
procedure Skip_Ahead (File : Non_Controlled_File_Type);
procedure Get_Immediate (
File : Non_Controlled_File_Type;
Item : out Character);
procedure Get_Immediate (
File : Non_Controlled_File_Type;
Item : out Wide_Character);
procedure Get_Immediate (
File : Non_Controlled_File_Type;
Item : out Wide_Wide_Character);
procedure Get_Immediate (
File : Non_Controlled_File_Type;
Item : out Character;
Available : out Boolean);
procedure Get_Immediate (
File : Non_Controlled_File_Type;
Item : out Wide_Character;
Available : out Boolean);
procedure Get_Immediate (
File : Non_Controlled_File_Type;
Item : out Wide_Wide_Character;
Available : out Boolean);
-- handle of stream for non-controlled
procedure Open (
File : in out Non_Controlled_File_Type;
Mode : IO_Modes.File_Mode;
Stream : not null access Streams.Root_Stream_Type'Class;
Name : String := "";
Form : System.Native_Text_IO.Packed_Form := Default_Form);
function Stream (File : not null Non_Controlled_File_Type)
return not null access Streams.Root_Stream_Type'Class;
function Stream_IO (File : Non_Controlled_File_Type)
return not null
access Streams.Naked_Stream_IO.Non_Controlled_File_Type;
pragma Inline (Stream_IO);
function Terminal_Handle (File : Non_Controlled_File_Type)
return System.Native_IO.Handle_Type;
-- standard I/O
Standard_Input : constant Non_Controlled_File_Type;
Standard_Output : constant Non_Controlled_File_Type;
Standard_Error : constant Non_Controlled_File_Type;
-- exceptions
Status_Error : exception
renames IO_Exceptions.Status_Error;
Mode_Error : exception
renames IO_Exceptions.Mode_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;
Layout_Error : exception
renames IO_Exceptions.Layout_Error;
private
type Virtual_Mark_Type is (None, EOP, EOP_EOF, EOF);
pragma Discard_Names (Virtual_Mark_Type);
type Text_Type is record -- "limited" prevents No_Elaboration_Code
Stream : System.Address := -- access Streams.Root_Stream_Type'Class
System.Null_Address;
File : aliased Streams.Naked_Stream_IO.Non_Controlled_File_Type;
Name : System.Native_IO.Name_Pointer; -- used when File is not assigned
Line : Natural := 1;
Page : Natural := 1;
Col : Natural := 1;
Line_Length : Natural := 0;
Page_Length : Natural := 0;
Last : Natural := 0;
Ahead_Last : Natural := 0; -- one-character Length, only In_File mode
Ahead_Col : Natural := 0; -- one-character Col
Looked_Ahead_Last : Natural := 0;
Looked_Ahead_Second : String (1 .. 3); -- second of surrogate pair
Buffer : System.Native_Text_IO.Buffer_Type;
End_Of_File : Boolean := False;
Virtual_Mark : Virtual_Mark_Type := None;
Mode : IO_Modes.File_Mode;
External : IO_Modes.File_External;
New_Line : IO_Modes.File_New_Line;
end record;
pragma Suppress_Initialization (Text_Type);
Standard_Input_Text : aliased Text_Type := (
Stream => System.Null_Address, -- be overwritten
File => Streams.Naked_Stream_IO.Standard_Files.Standard_Input,
Name => null,
Line => 1,
Page => 1,
Col => 1,
Line_Length => 0,
Page_Length => 0,
Last => 0,
Ahead_Last => 0,
Ahead_Col => 0,
Looked_Ahead_Last => 0,
Looked_Ahead_Second => (others => Character'Val (0)),
Buffer => (others => Character'Val (0)),
End_Of_File => False,
Virtual_Mark => None,
Mode => IO_Modes.In_File,
External => System.Native_Text_IO.Default_External, -- be overwritten
New_Line => System.Native_Text_IO.Default_New_Line);
Standard_Output_Text : aliased Text_Type := (
Stream => System.Null_Address, -- be overwritten
File => Streams.Naked_Stream_IO.Standard_Files.Standard_Output,
Name => null,
Line => 1,
Page => 1,
Col => 1,
Line_Length => 0,
Page_Length => 0,
Last => 0,
Ahead_Last => 0,
Ahead_Col => 0,
Looked_Ahead_Last => 0,
Looked_Ahead_Second => (others => Character'Val (0)),
Buffer => (others => Character'Val (0)),
End_Of_File => False,
Virtual_Mark => None,
Mode => IO_Modes.Out_File,
External => System.Native_Text_IO.Default_External, -- be overwritten
New_Line => System.Native_Text_IO.Default_New_Line);
Standard_Error_Text : aliased Text_Type := (
Stream => System.Null_Address, -- be overwritten
File => Streams.Naked_Stream_IO.Standard_Files.Standard_Error,
Name => null,
Line => 1,
Page => 1,
Col => 1,
Line_Length => 0,
Page_Length => 0,
Last => 0,
Ahead_Last => 0,
Ahead_Col => 0,
Looked_Ahead_Last => 0,
Looked_Ahead_Second => (others => Character'Val (0)),
Buffer => (others => Character'Val (0)),
End_Of_File => False,
Virtual_Mark => None,
Mode => IO_Modes.Out_File,
External => System.Native_Text_IO.Default_External, -- be overwritten
New_Line => System.Native_Text_IO.Default_New_Line);
Standard_Input : constant Non_Controlled_File_Type :=
Standard_Input_Text'Access;
Standard_Output : constant Non_Controlled_File_Type :=
Standard_Output_Text'Access;
Standard_Error : constant Non_Controlled_File_Type :=
Standard_Error_Text'Access;
end Ada.Naked_Text_IO;
|
rveenker/sdlada | Ada | 2,130 | adb | --------------------------------------------------------------------------------------------------------------------
-- Copyright (c) 2013-2020, Luke A. Guest
--
-- This software is provided 'as-is', without any express or implied
-- warranty. In no event will the authors be held liable for any damages
-- arising from the use of this software.
--
-- Permission is granted to anyone to use this software for any purpose,
-- including commercial applications, and to alter it and redistribute it
-- freely, subject to the following restrictions:
--
-- 1. The origin of this software must not be misrepresented; you must not
-- claim that you wrote the original software. If you use this software
-- in a product, an acknowledgment in the product documentation would be
-- appreciated but is not required.
--
-- 2. Altered source versions must be plainly marked as such, and must not be
-- misrepresented as being the original software.
--
-- 3. This notice may not be removed or altered from any source
-- distribution.
--------------------------------------------------------------------------------------------------------------------
-- Colour_Test_Cases
--------------------------------------------------------------------------------------------------------------------
with AUnit.Assertions; use AUnit.Assertions;
with SDL.Video.Palettes;
package body Colour_Test_Cases is
overriding
function Name (Test : Colour_Test_Case) return Message_String is
begin
return Format ("Colour test");
end Name;
overriding
procedure Run_Test (Test : in out Colour_Test_Case) is
use type SDL.Video.Palettes.Colour_Component;
Colour : SDL.Video.Palettes.Colour := (Red => 16#FF#, Green => 16#DD#, Blue => 16#AA#, Alpha => 16#88#);
begin
Assert (Colour.Red = C_Test.Red, "Red values do not match");
Assert (Colour.Green = C_Test.Green, "Green values do not match");
Assert (Colour.Blue = C_Test.Blue, "Blue values do not match");
Assert (Colour.Alpha = C_Test.Alpha, "Alpha values do not match");
end Run_Test;
end Colour_Test_Cases;
|
melwyncarlo/ProjectEuler | Ada | 303 | adb | with Ada.Text_IO;
with Ada.Integer_Text_IO;
-- Copyright 2021 Melwyn Francis Carlo
procedure A051 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 A051;
|
charlie5/aIDE | Ada | 1,161 | ads | with
AdaM.a_Type.decimal_fixed_point_type,
gtk.Widget;
private
with
gtk.gEntry,
gtk.Box,
gtk.Label,
gtk.Spin_Button,
gtk.Button;
package aIDE.Editor.of_decimal_type
is
type Item is new Editor.item with private;
type View is access all Item'Class;
package Forge
is
function to_Editor (the_Target : in AdaM.a_Type.decimal_fixed_point_type.view) return View;
end Forge;
overriding
function top_Widget (Self : in Item) return gtk.Widget.Gtk_Widget;
private
use gtk.Button,
gtk.gEntry,
gtk.Spin_Button,
gtk.Label,
gtk.Box;
type Item is new Editor.item with
record
Target : AdaM.a_Type.decimal_fixed_point_type.view;
top_Box : gtk_Box;
name_Entry : Gtk_Entry;
delta_Entry : Gtk_Entry;
digits_Entry : Gtk_Entry;
first_Entry : Gtk_Entry;
last_Entry : Gtk_Entry;
rid_Button : gtk_Button;
end record;
overriding
procedure freshen (Self : in out Item);
end aIDE.Editor.of_decimal_type;
|
zhmu/ananas | Ada | 3,172 | ads | ------------------------------------------------------------------------------
-- --
-- GNAT RUN-TIME COMPONENTS --
-- --
-- S Y S T E M . E X P I N T --
-- --
-- S p e c --
-- --
-- Copyright (C) 1992-2022, Free Software Foundation, Inc. --
-- --
-- GNAT is free software; you can redistribute it and/or modify it under --
-- terms of the GNU General Public License as published by the Free Soft- --
-- ware Foundation; either version 3, or (at your option) any later ver- --
-- sion. GNAT is distributed in the hope that it will be useful, but WITH- --
-- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY --
-- or FITNESS FOR A PARTICULAR PURPOSE. --
-- --
-- As a special exception under Section 7 of GPL version 3, you are granted --
-- additional permissions described in the GCC Runtime Library Exception, --
-- version 3.1, as published by the Free Software Foundation. --
-- --
-- You should have received a copy of the GNU General Public License and --
-- a copy of the GCC Runtime Library Exception along with this program; --
-- see the files COPYING3 and COPYING.RUNTIME respectively. If not, see --
-- <http://www.gnu.org/licenses/>. --
-- --
-- GNAT was originally developed by the GNAT team at New York University. --
-- Extensive contributions were provided by Ada Core Technologies Inc. --
-- --
------------------------------------------------------------------------------
-- Integer exponentiation (checks on)
-- Preconditions, postconditions, ghost code, loop invariants and assertions
-- in this unit are meant for analysis only, not for run-time checking, as it
-- would be too costly otherwise. This is enforced by setting the assertion
-- policy to Ignore.
pragma Assertion_Policy (Pre => Ignore,
Post => Ignore,
Ghost => Ignore,
Loop_Invariant => Ignore,
Assert => Ignore);
with System.Expont;
package System.Exp_Int
with SPARK_Mode
is
package Expont_Integer is new Expont (Integer);
function Exp_Integer (Left : Integer; Right : Natural) return Integer
renames Expont_Integer.Expon;
end System.Exp_Int;
|
RREE/ada-util | Ada | 2,162 | adb | -----------------------------------------------------------------------
-- encodes -- Encodes strings
-- Copyright (C) 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 Ada.Text_IO;
with Ada.Command_Line;
with Util.Encoders;
procedure Encodes is
use Util.Encoders;
Encode : Boolean := True;
Count : constant Natural := Ada.Command_Line.Argument_Count;
begin
if Count <= 1 then
Ada.Text_IO.Put_Line ("Usage: encodes {encoder} [-d|-e] string...");
Ada.Text_IO.Put_Line ("Encoders: " & Util.Encoders.BASE_64 & ", "
& Util.Encoders.BASE_64_URL & ", "
& Util.Encoders.BASE_16 & ", "
& Util.Encoders.HASH_SHA1);
return;
end if;
declare
Name : constant String := Ada.Command_Line.Argument (1);
C : constant Encoder := Util.Encoders.Create (Name);
D : constant Decoder := Util.Encoders.Create (Name);
begin
for I in 2 .. Count loop
declare
S : constant String := Ada.Command_Line.Argument (I);
begin
if S = "-d" then
Encode := False;
elsif S = "-e" then
Encode := True;
elsif Encode then
Ada.Text_IO.Put_Line ("Encodes " & Name & ": " & C.Encode (S));
else
Ada.Text_IO.Put_Line ("Decodes " & Name & ": " & D.Decode (S));
end if;
end;
end loop;
end;
end Encodes;
|
micahwelf/FLTK-Ada | Ada | 959 | ads |
with
FLTK.Devices.Graphics;
package FLTK.Devices.Surfaces is
type Surface_Device is new Device with private;
type Surface_Device_Reference (Data : not null access Surface_Device'Class) is
limited null record with Implicit_Dereference => Data;
package Forge is
function Create
(Graphics : in out FLTK.Devices.Graphics.Graphics_Driver)
return Surface_Device;
end Forge;
function Get_Current
return access Surface_Device'Class;
procedure Set_Current
(This : in out Surface_Device);
private
type Surface_Device is new Device with null record;
overriding procedure Finalize
(This : in out Surface_Device);
Original_Surface : aliased Surface_Device;
Current_Ptr : access Surface_Device'Class := Original_Surface'Access;
pragma Inline (Get_Current);
pragma Inline (Set_Current);
end FLTK.Devices.Surfaces;
|
kontena/ruby-packer | Ada | 4,267 | ads | ------------------------------------------------------------------------------
-- --
-- GNAT ncurses Binding --
-- --
-- Terminal_Interface.Curses.Terminfo --
-- --
-- S P E C --
-- --
------------------------------------------------------------------------------
-- Copyright (c) 2000,2003 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.4 $
-- Binding Version 01.00
------------------------------------------------------------------------------
with Interfaces.C;
package Terminal_Interface.Curses.Terminfo is
pragma Preelaborate (Terminal_Interface.Curses.Terminfo);
-- |=====================================================================
-- | Man page curs_terminfo.3x
-- |=====================================================================
-- Not implemented: setupterm, setterm, set_curterm, del_curterm,
-- restartterm, tparm, putp, vidputs, vidattr,
-- mvcur
type Terminfo_String is new String;
-- |
procedure Get_String (Name : String;
Value : out Terminfo_String;
Result : out Boolean);
function Has_String (Name : String) return Boolean;
-- AKA: tigetstr()
-- |
function Get_Flag (Name : String) return Boolean;
-- AKA: tigetflag()
-- |
function Get_Number (Name : String) return Integer;
-- AKA: tigetnum()
type putctype is access function (c : Interfaces.C.int)
return Interfaces.C.int;
pragma Convention (C, putctype);
-- |
procedure Put_String (Str : Terminfo_String;
affcnt : Natural := 1;
putc : putctype := null);
-- AKA: tputs()
end Terminal_Interface.Curses.Terminfo;
|
charlie5/lace | Ada | 716 | ads | with
openGL.surface_Profile,
openGL.Surface,
glx.Context;
package openGL.Context
--
-- Models an openGL (GLX) context.
--
is
type Item is tagged private;
type View is access all Item'Class;
procedure define (Self : in out Item; Profile : in surface_Profile.item'Class);
procedure make_Current (Self : in Item; read_Surface : in Surface.item;
write_Surface : in Surface.item);
function glx_Context_debug (Self : in Item'Class) return glx.Context.item; -- For debugging.
private
type Item is tagged
record
glx_Context : aliased glx.Context.item;
end record;
end openGL.Context;
|
zhmu/ananas | Ada | 8,740 | adb | ------------------------------------------------------------------------------
-- --
-- GNAT RUN-TIME COMPONENTS --
-- --
-- A D A . T E X T _ I O . E N U M E R A T I O N _ A U X --
-- --
-- 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 Ada.Text_IO.Generic_Aux; use Ada.Text_IO.Generic_Aux;
with Ada.Characters.Handling; use Ada.Characters.Handling;
-- Note: this package does not yet deal properly with wide characters ???
package body Ada.Text_IO.Enumeration_Aux is
------------------
-- Get_Enum_Lit --
------------------
procedure Get_Enum_Lit
(File : File_Type;
Buf : out String;
Buflen : out Natural)
is
ch : Integer;
C : Character;
begin
Buflen := 0;
Load_Skip (File);
ch := Getc (File);
C := Character'Val (ch);
-- Character literal case. If the initial character is a quote, then
-- we read as far as we can without backup (see ACVC test CE3905L)
if C = ''' then
Store_Char (File, ch, Buf, Buflen);
ch := Getc (File);
if ch in 16#20# .. 16#7E# or else ch >= 16#80# then
Store_Char (File, ch, Buf, Buflen);
ch := Getc (File);
if ch = Character'Pos (''') then
Store_Char (File, ch, Buf, Buflen);
else
Ungetc (ch, File);
end if;
else
Ungetc (ch, File);
end if;
-- Similarly for identifiers, read as far as we can, in particular,
-- do read a trailing underscore (again see ACVC test CE3905L to
-- understand why we do this, although it seems somewhat peculiar).
else
-- Identifier must start with a letter
if not Is_Letter (C) then
Ungetc (ch, File);
return;
end if;
-- If we do have a letter, loop through the characters quitting on
-- the first non-identifier character (note that this includes the
-- cases of hitting a line mark or page mark).
loop
C := Character'Val (ch);
Store_Char (File, Character'Pos (To_Upper (C)), Buf, Buflen);
ch := Getc (File);
exit when ch = EOF_Char;
C := Character'Val (ch);
exit when not Is_Letter (C)
and then not Is_Digit (C)
and then C /= '_';
exit when C = '_'
and then Buf (Buflen) = '_';
end loop;
Ungetc (ch, File);
end if;
end Get_Enum_Lit;
---------
-- Put --
---------
procedure Put
(File : File_Type;
Item : String;
Width : Field;
Set : Type_Set)
is
Actual_Width : constant Count := Count'Max (Count (Width), Item'Length);
begin
-- Deal with limited line length of output file
if Line_Length (File) /= 0 then
-- If actual width exceeds line length, raise Layout_Error
if Actual_Width > Line_Length (File) then
raise Layout_Error;
end if;
-- If full width cannot fit on current line move to new line
if Actual_Width + (Col (File) - 1) > Line_Length (File) then
New_Line (File);
end if;
end if;
-- Output in lower case if necessary
if Set = Lower_Case and then Item (Item'First) /= ''' then
declare
Iteml : String (Item'First .. Item'Last);
begin
for J in Item'Range loop
Iteml (J) := To_Lower (Item (J));
end loop;
Put_Item (File, Iteml);
end;
-- Otherwise output in upper case
else
Put_Item (File, Item);
end if;
-- Fill out item with spaces to width
for J in 1 .. Actual_Width - Item'Length loop
Put (File, ' ');
end loop;
end Put;
----------
-- Puts --
----------
procedure Puts
(To : out String;
Item : String;
Set : Type_Set)
is
Ptr : Natural;
begin
if Item'Length > To'Length then
raise Layout_Error;
else
Ptr := To'First;
for J in Item'Range loop
if Set = Lower_Case and then Item (Item'First) /= ''' then
To (Ptr) := To_Lower (Item (J));
else
To (Ptr) := Item (J);
end if;
Ptr := Ptr + 1;
end loop;
while Ptr <= To'Last loop
To (Ptr) := ' ';
Ptr := Ptr + 1;
end loop;
end if;
end Puts;
-------------------
-- Scan_Enum_Lit --
-------------------
procedure Scan_Enum_Lit
(From : String;
Start : out Natural;
Stop : out Natural)
is
C : Character;
-- Processing for Scan_Enum_Lit
begin
String_Skip (From, Start);
-- Character literal case. If the initial character is a quote, then
-- we read as far as we can without backup (see ACVC test CE3905L
-- which is for the analogous case for reading from a file).
if From (Start) = ''' then
Stop := Start;
if Stop = From'Last then
raise Data_Error;
else
Stop := Stop + 1;
end if;
if From (Stop) in ' ' .. '~'
or else From (Stop) >= Character'Val (16#80#)
then
if Stop = From'Last then
raise Data_Error;
else
Stop := Stop + 1;
if From (Stop) = ''' then
return;
end if;
end if;
end if;
raise Data_Error;
-- Similarly for identifiers, read as far as we can, in particular,
-- do read a trailing underscore (again see ACVC test CE3905L to
-- understand why we do this, although it seems somewhat peculiar).
else
-- Identifier must start with a letter
if not Is_Letter (From (Start)) then
raise Data_Error;
end if;
-- If we do have a letter, loop through the characters quitting on
-- the first non-identifier character (note that this includes the
-- cases of hitting a line mark or page mark).
Stop := Start;
while Stop < From'Last loop
C := From (Stop + 1);
exit when not Is_Letter (C)
and then not Is_Digit (C)
and then C /= '_';
exit when C = '_'
and then From (Stop) = '_';
Stop := Stop + 1;
end loop;
end if;
end Scan_Enum_Lit;
end Ada.Text_IO.Enumeration_Aux;
|
RREE/ada-util | Ada | 5,056 | adb | -----------------------------------------------------------------------
-- util-systems-dlls-tests -- Unit tests for shared libraries
-- Copyright (C) 2013, 2017, 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.Test_Caller;
package body Util.Systems.DLLs.Tests is
use Util.Tests;
use type System.Address;
procedure Load_Library (T : in out Test;
Lib : out Handle);
package Caller is new Util.Test_Caller (Test, "Systems.Dlls");
procedure Add_Tests (Suite : in Util.Tests.Access_Test_Suite) is
begin
Caller.Add_Test (Suite, "Test Util.Systems.Dlls.Load",
Test_Load'Access);
Caller.Add_Test (Suite, "Test Util.Systems.Dlls.Get_Symbol",
Test_Get_Symbol'Access);
end Add_Tests;
procedure Load_Library (T : in out Test;
Lib : out Handle) is
Lib1 : Handle;
Lib2 : Handle;
Lib3 : Handle;
Lib4 : Handle;
Lib5 : Handle;
begin
begin
Lib1 := Util.Systems.DLLs.Load ("libcrypto.so");
T.Assert (Lib1 /= Null_Handle, "Load operation returned null");
Lib := Lib1;
exception
when Load_Error =>
Lib1 := Null_Handle;
end;
begin
Lib2 := Util.Systems.DLLs.Load ("libcrypto.dylib");
T.Assert (Lib2 /= Null_Handle, "Load operation returned null");
Lib := Lib2;
exception
when Load_Error =>
Lib2 := Null_Handle;
end;
begin
Lib3 := Util.Systems.DLLs.Load ("zlib1.dll");
T.Assert (Lib3 /= Null_Handle, "Load operation returned null");
Lib := Lib3;
exception
when Load_Error =>
Lib3 := Null_Handle;
end;
begin
Lib4 := Util.Systems.DLLs.Load ("libz.so");
T.Assert (Lib4 /= Null_Handle, "Load operation returned null");
Lib := Lib4;
exception
when Load_Error =>
Lib4 := Null_Handle;
end;
begin
Lib5 := Util.Systems.DLLs.Load ("libgmp.so");
T.Assert (Lib5 /= Null_Handle, "Load operation returned null");
Lib := Lib5;
exception
when Load_Error =>
Lib5 := Null_Handle;
end;
T.Assert (Lib1 /= Null_Handle or Lib2 /= Null_Handle or Lib3 /= Null_Handle
or Lib4 /= Null_Handle or Lib5 /= Null_Handle,
"At least one Load operation should have succeeded");
end Load_Library;
-- ------------------------------
-- Test the loading a shared library.
-- ------------------------------
procedure Test_Load (T : in out Test) is
Lib : Handle;
begin
Load_Library (T, Lib);
begin
Lib := Util.Systems.DLLs.Load ("some-invalid-library");
T.Fail ("Load must raise an exception");
exception
when Load_Error =>
null;
end;
end Test_Load;
-- ------------------------------
-- Test getting a shared library symbol.
-- ------------------------------
procedure Test_Get_Symbol (T : in out Test) is
Lib : Handle;
Sym : System.Address := System.Null_Address;
begin
Load_Library (T, Lib);
T.Assert (Lib /= Null_Handle, "Load operation returned null");
begin
Sym := Util.Systems.DLLs.Get_Symbol (Lib, "EVP_sha1");
T.Assert (Sym /= System.Null_Address, "Get_Symbol returned null");
exception
when Not_Found =>
null;
end;
begin
Sym := Util.Systems.DLLs.Get_Symbol (Lib, "compress");
T.Assert (Sym /= System.Null_Address, "Get_Symbol returned null");
exception
when Not_Found =>
null;
end;
begin
Sym := Util.Systems.DLLs.Get_Symbol (Lib, "__gmpf_cmp");
T.Assert (Sym /= System.Null_Address, "Get_Symbol returned null");
exception
when Not_Found =>
null;
end;
-- We must have found one of the two symbols
T.Assert (Sym /= System.Null_Address, "Get_Symbol returned null");
begin
Sym := Util.Systems.DLLs.Get_Symbol (Lib, "some-invalid-symbol");
T.Fail ("The Get_Symbol operation must raise an exception");
exception
when Not_Found =>
null;
end;
end Test_Get_Symbol;
end Util.Systems.DLLs.Tests;
|
AdaCore/Ada_Drivers_Library | Ada | 12,563 | adb | ------------------------------------------------------------------------------
-- --
-- Copyright (C) 2016, AdaCore --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions are --
-- met: --
-- 1. Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- 2. Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in --
-- the documentation and/or other materials provided with the --
-- distribution. --
-- 3. Neither the name of STMicroelectronics nor the names of its --
-- contributors may be used to endorse or promote products derived --
-- from this software without specific prior written permission. --
-- --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR --
-- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
-- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT --
-- LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, --
-- DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY --
-- THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT --
-- (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE --
-- OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
-- --
-- --
-- This file is based on: --
-- --
-- @file stm32f7xx_hal_sai.c --
-- @author MCD Application Team --
-- @version V1.0.2 --
-- @date 21-September-2015 --
-- @brief This file provides firmware functions to manage the following --
-- functionalities of the Serial Audio Interface (SAI) --
-- peripheral: --
-- + Initialization/de-initialization functions --
-- + I/O operation functions --
-- + Peripheral Control functions --
-- + Peripheral State functions --
-- --
-- COPYRIGHT(c) 2015 STMicroelectronics --
------------------------------------------------------------------------------
with Ada.Real_Time; use Ada.Real_Time;
with STM32.Device; use STM32.Device;
with STM32_SVD; use STM32_SVD;
with STM32_SVD.SAI; use STM32_SVD.SAI;
with STM32_SVD.RCC; use STM32_SVD.RCC;
package body STM32.SAI is
type Block_Registers is record
-- AConfiguration register 1
CR1 : ACR1_Register;
-- AConfiguration register 2
CR2 : ACR2_Register;
-- AFRCR
FRCR : AFRCR_Register;
-- ASlot register
SLOTR : ASLOTR_Register;
-- AInterrupt mask register2
IM : AIM_Register;
-- AStatus register
SR : ASR_Register;
-- AClear flag register
CLRFR : ACLRFR_Register;
-- AData register
DR : UInt32;
end record with Volatile;
for Block_Registers use record
CR1 at 0 range 0 .. 31;
CR2 at 4 range 0 .. 31;
FRCR at 8 range 0 .. 31;
SLOTR at 12 range 0 .. 31;
IM at 16 range 0 .. 31;
SR at 20 range 0 .. 31;
CLRFR at 24 range 0 .. 31;
DR at 28 range 0 .. 31;
end record;
type Block_Registers_Access is access all Block_Registers;
function Get_Block
(Periph : SAI_Controller;
Block : SAI_Block) return Block_Registers_Access;
---------------
-- Get_Block --
---------------
function Get_Block
(Periph : SAI_Controller;
Block : SAI_Block) return Block_Registers_Access
is
BlockA : aliased Block_Registers
with Volatile, Import, Address => Periph.ACR1'Address;
BlockB : aliased Block_Registers
with Volatile, Import, Address => Periph.BCR1'Address;
begin
case Block is
when Block_A =>
return BlockA'Unchecked_Access;
when Block_B =>
return BlockB'Unchecked_Access;
end case;
end Get_Block;
------------------
-- Deinitialize --
------------------
procedure Deinitialize
(This : SAI_Controller;
Block : SAI_Block)
is
Block_Regs : constant Block_Registers_Access :=
Get_Block (This, Block);
Start : Time;
begin
-- Disable SAI
Block_Regs.CR1.SAIAEN := False;
Start := Clock;
while Block_Regs.CR1.SAIAEN loop
if Start + Seconds (1) < Clock then
raise Constraint_Error with "Cannot reset the SAI peripheral";
end if;
end loop;
-- Reset the SAI block interrupts
Block_Regs.IM := (others => <>);
Block_Regs.CLRFR :=
(Reserved_3_3 => 0,
Reserved_7_31 => 0,
others => True);
-- Flush the FIFO
Block_Regs.CR2.FFLUS := True;
end Deinitialize;
-------------
-- Enabled --
-------------
function Enabled (This : SAI_Controller;
Block : SAI_Block) return Boolean
is
Block_Regs : constant Block_Registers_Access :=
Get_Block (This, Block);
begin
return Block_Regs.CR1.SAIAEN;
end Enabled;
------------
-- Enable --
------------
procedure Enable
(This : SAI_Controller;
Block : SAI_Block)
is
Block_Regs : constant Block_Registers_Access :=
Get_Block (This, Block);
begin
Block_Regs.CR1.SAIAEN := True;
end Enable;
-------------
-- Disable --
-------------
procedure Disable
(This : SAI_Controller;
Block : SAI_Block)
is
Block_Regs : constant Block_Registers_Access :=
Get_Block (This, Block);
begin
Block_Regs.CR1.SAIAEN := False;
end Disable;
----------------
-- Enable_DMA --
----------------
procedure Enable_DMA
(This : SAI_Controller;
Block : SAI_Block)
is
Block_Regs : constant Block_Registers_Access :=
Get_Block (This, Block);
begin
Block_Regs.CR1.DMAEN := True;
end Enable_DMA;
---------------
-- DMA_Pause --
---------------
procedure DMA_Pause
(This : SAI_Controller;
Block : SAI_Block)
is
Block_Regs : constant Block_Registers_Access :=
Get_Block (This, Block);
begin
Block_Regs.CR1.DMAEN := False;
end DMA_Pause;
----------------
-- DMA_Resume --
----------------
procedure DMA_Resume
(This : SAI_Controller;
Block : SAI_Block)
is
Block_Regs : constant Block_Registers_Access :=
Get_Block (This, Block);
begin
Block_Regs.CR1.DMAEN := True;
if not Block_Regs.CR1.SAIAEN then
Enable (This, Block);
end if;
end DMA_Resume;
--------------
-- DMA_Stop --
--------------
procedure DMA_Stop
(This : SAI_Controller;
Block : SAI_Block)
is
Block_Regs : constant Block_Registers_Access :=
Get_Block (This, Block);
begin
Block_Regs.CR1.DMAEN := False;
Disable (This, Block);
end DMA_Stop;
---------------------------
-- Configure_Audio_Block --
---------------------------
procedure Configure_Audio_Block
(This : SAI_Controller;
Block : SAI_Block;
Frequency : SAI_Audio_Frequency;
Stereo_Mode : SAI_Mono_Stereo_Mode;
Mode : SAI_Audio_Mode;
MCD_Enabled : Boolean;
Protocol : SAI_Protocol_Configuration;
Data_Size : SAI_Data_Size;
Endianness : SAI_Endianness;
Clock_Strobing : SAI_Clock_Strobing_Edge;
Synchronization : SAI_Synchronization;
Output_Drive : SAI_Output_Drive;
FIFO_Threshold : SAI_FIFO_Threshold;
Tristate_Mgt : SAI_Tristate_Management := SD_Line_Driven;
Companding_Mode : SAI_Companding_Mode := No_Companding)
is
Block_Reg : constant Block_Registers_Access := Get_Block (This, Block);
Freq : UInt32;
Tmp_Clock : UInt32;
Mckdiv : UInt32;
begin
Deinitialize (This, Block);
-- Configure Master Clock using the following formula :
-- MCLK_x = SAI_CK_x / (MCKDIV[3:0] * 2) with MCLK_x = 256 * FS
-- FS = SAI_CK_x / (MCKDIV[3:0] * 2) * 256
-- MCKDIV[3:0] = SAI_CK_x / FS * 512
Freq := Get_Input_Clock (This);
-- Calculate *10 to keep some precision
Tmp_Clock := Freq * 10 / (Frequency * 512);
Mckdiv := Tmp_Clock / 10;
-- Round the result if needed
if (Tmp_Clock mod 10) > 8 then
Mckdiv := Mckdiv + 1;
end if;
Block_Reg.CR1 :=
(MODE => SAI_Audio_Mode'Enum_Rep (Mode),
PRTCFG => SAI_Protocol_Configuration'Enum_Rep (Protocol),
DS => SAI_Data_Size'Enum_Rep (Data_Size),
LSBFIRST => Endianness = Data_LSB_First,
CKSTR => Clock_Strobing = Clock_Strobing_Rising_Edge,
SYNCEN => SAI_Synchronization'Enum_Rep (Synchronization),
MONO => Stereo_Mode = Mono,
OutDri => Output_Drive = Drive_Immediate,
SAIAEN => False,
DMAEN => False,
NODIV => not MCD_Enabled,
MCJDIV => UInt4 (Mckdiv),
others => <>);
Block_Reg.CR2.FTH := SAI_FIFO_Threshold'Enum_Rep (FIFO_Threshold);
Block_Reg.CR2.FFLUS := False;
Block_Reg.CR2.TRIS := Tristate_Mgt = SD_Line_Released;
Block_Reg.CR2.COMP := SAI_Companding_Mode'Enum_Rep (Companding_Mode);
end Configure_Audio_Block;
---------------------------
-- Configure_Block_Frame --
---------------------------
procedure Configure_Block_Frame
(This : SAI_Controller;
Block : SAI_Block;
Frame_Length : UInt8;
Frame_Active : UInt7;
Frame_Sync : SAI_Frame_Synchronization;
FS_Polarity : SAI_Frame_Sync_Polarity;
FS_Offset : SAI_Frame_Sync_Offset)
is
Block_Reg : constant Block_Registers_Access := Get_Block (This, Block);
begin
Block_Reg.FRCR :=
(FRL => Frame_Length - 1,
FSALL => Frame_Active - 1,
FSDEF => Frame_Sync = FS_Frame_And_Channel_Identification,
FSPOL => FS_Polarity = FS_Active_High,
FSOFF => FS_Offset = Before_First_Bit,
others => <>);
end Configure_Block_Frame;
--------------------------
-- Configure_Block_Slot --
--------------------------
procedure Configure_Block_Slot
(This : SAI_Controller;
Block : SAI_Block;
First_Bit_Offset : UInt5;
Slot_Size : SAI_Slot_Size;
Number_Of_Slots : Slots_Number;
Enabled_Slots : SAI_Slots)
is
Block_Reg : constant Block_Registers_Access := Get_Block (This, Block);
begin
Block_Reg.SLOTR :=
(FBOFF => First_Bit_Offset,
SLOTSZ => SAI_Slot_Size'Enum_Rep (Slot_Size),
NBSLOT => UInt4 (Number_Of_Slots - 1),
SLOTEN => UInt16 (Enabled_Slots),
others => <>);
end Configure_Block_Slot;
end STM32.SAI;
|
micahwelf/FLTK-Ada | Ada | 2,246 | ads |
package FLTK.Widgets.Valuators.Counters is
type Counter is new Valuator with private;
type Counter_Reference (Data : not null access Counter'Class) is
limited null record with Implicit_Dereference => Data;
package Forge is
function Create
(X, Y, W, H : in Integer;
Text : in String)
return Counter;
end Forge;
function Get_Step
(This : in Counter)
return Long_Float;
procedure Set_Step
(This : in out Counter;
To : in Long_Float);
function Get_Long_Step
(This : in Counter)
return Long_Float;
procedure Set_Long_Step
(This : in out Counter;
To : in Long_Float);
function Get_Text_Color
(This : in Counter)
return Color;
procedure Set_Text_Color
(This : in out Counter;
To : in Color);
function Get_Text_Font
(This : in Counter)
return Font_Kind;
procedure Set_Text_Font
(This : in out Counter;
To : in Font_Kind);
function Get_Text_Size
(This : in Counter)
return Font_Size;
procedure Set_Text_Size
(This : in out Counter;
To : in Font_Size);
procedure Draw
(This : in out Counter);
function Handle
(This : in out Counter;
Event : in Event_Kind)
return Event_Outcome;
private
type Counter is new Valuator with record
-- Needed because Fl_Counter doesn't have
-- a way to retrieve this value otherwise.
Long_Step : Long_Float := 1.0;
end record;
overriding procedure Finalize
(This : in out Counter);
pragma Inline (Get_Step);
pragma Inline (Set_Step);
pragma Inline (Get_Long_Step);
pragma Inline (Set_Long_Step);
pragma Inline (Get_Text_Color);
pragma Inline (Set_Text_Color);
pragma Inline (Get_Text_Font);
pragma Inline (Set_Text_Font);
pragma Inline (Get_Text_Size);
pragma Inline (Set_Text_Size);
pragma Inline (Draw);
pragma Inline (Handle);
end FLTK.Widgets.Valuators.Counters;
|
godunko/adawebui | Ada | 6,704 | adb | ------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- Web Framework --
-- --
-- Runtime Library Component --
-- --
------------------------------------------------------------------------------
-- --
-- Copyright © 2017-2020, 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: 5761 $ $Date: 2017-05-20 11:06:31 +0300 (Sat, 20 May 2017) $
------------------------------------------------------------------------------
with Web.Window;
package body Web.UI.Widgets.Combo_Boxes.Strings is
------------------
-- Constructors --
------------------
package body Constructors is
type String_Combo_Box_Internal_Access is
access all String_Combo_Box'Class;
------------
-- Create --
------------
function Create
(Element : Web.HTML.Selects.HTML_Select_Element)
return not null String_Combo_Box_Access
is
Result : constant not null String_Combo_Box_Internal_Access
:= new String_Combo_Box;
begin
Initialize (Result.all, Element);
return String_Combo_Box_Access (Result);
end Create;
------------
-- Create --
------------
function Create
(Id : Web.Strings.Web_String) return not null String_Combo_Box_Access is
begin
return
Create (Web.Window.Document.Get_Element_By_Id (Id).As_HTML_Select);
end Create;
----------------
-- Initialize --
----------------
procedure Initialize
(Self : in out String_Combo_Box'Class;
Element : Web.HTML.Selects.HTML_Select_Element'Class) is
begin
Web.UI.Widgets.Combo_Boxes.Constructors.Initialize (Self, Element);
end Initialize;
end Constructors;
-------------------
-- Current_Value --
-------------------
function Current_Value
(Self : in out String_Combo_Box'Class) return Web.Strings.Web_String
is
Value : constant Web.Strings.Web_String
:= Self.Element.As_HTML_Select.Get_Value;
begin
if Value.Is_Empty then
raise Constraint_Error;
else
return Value;
end if;
end Current_Value;
-- ----------------------------------
-- -- Current_Index_Changed_Signal --
-- ----------------------------------
--
-- not overriding function Current_Index_Changed_Signal
-- (Self : in out Combo_Box)
-- return not null access WUI.String_Slots.Signal'Class is
-- begin
-- return Self.Current_Index_Changed'Unchecked_Access;
-- end Current_Index_Changed_Signal;
--
-- -----------------
-- -- Input_Event --
-- -----------------
--
-- overriding procedure Input_Event (Self : in out Combo_Box) is
-- Input : constant WebAPI.HTML.Select_Elements.HTML_Select_Element_Access
-- := WebAPI.HTML.Select_Elements.HTML_Select_Element_Access
-- (Self.Element);
--
-- begin
-- Self.Current_Index_Changed.Emit (Input.Get_Value);
-- end Input_Event;
--
-- -----------------------
-- -- Set_Current_Index --
-- -----------------------
--
-- not overriding procedure Set_Current_Index
-- (Self : in out Combo_Box;
-- To : League.Strings.Universal_String)
-- is
-- use type League.Strings.Universal_String;
--
-- Input : constant WebAPI.HTML.Select_Elements.HTML_Select_Element_Access
-- := WebAPI.HTML.Select_Elements.HTML_Select_Element_Access
-- (Self.Element);
--
-- begin
-- if Input.Get_Value /= To then
-- Input.Set_Value (To);
-- Self.Current_Index_Changed.Emit (Input.Get_Value);
-- -- 'input' event is not send when value is updated programmatically.
-- end if;
-- end Set_Current_Index;
end Web.UI.Widgets.Combo_Boxes.Strings;
|
reznikmm/matreshka | Ada | 9,866 | adb | ------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- Ada Modeling Framework --
-- --
-- Runtime Library Component --
-- --
------------------------------------------------------------------------------
-- --
-- Copyright © 2012, Vadim Godunko <[email protected]> --
-- All rights reserved. --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions --
-- are met: --
-- --
-- * Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- --
-- * Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in the --
-- documentation and/or other materials provided with the distribution. --
-- --
-- * Neither the name of the Vadim Godunko, IE nor the names of its --
-- contributors may be used to endorse or promote products derived from --
-- this software without specific prior written permission. --
-- --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR --
-- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
-- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED --
-- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR --
-- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF --
-- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING --
-- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS --
-- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
-- --
------------------------------------------------------------------------------
-- $Revision$ $Date$
------------------------------------------------------------------------------
-- This file is generated, don't edit it.
------------------------------------------------------------------------------
with AMF.DC;
with AMF.DG.Clip_Paths;
with AMF.DG.Groups;
with AMF.DG.Styles.Collections;
with AMF.Elements;
with AMF.Internals.Element_Collections;
with AMF.Internals.Helpers;
with AMF.Internals.Tables.DD_Attributes;
with AMF.Visitors.DG_Iterators;
with AMF.Visitors.DG_Visitors;
package body AMF.Internals.DG_Rectangles is
----------------
-- Get_Bounds --
----------------
overriding function Get_Bounds
(Self : not null access constant DG_Rectangle_Proxy)
return AMF.DC.DC_Bounds is
begin
return
AMF.Internals.Tables.DD_Attributes.Internal_Get_Bounds
(Self.Element);
end Get_Bounds;
----------------
-- Set_Bounds --
----------------
overriding procedure Set_Bounds
(Self : not null access DG_Rectangle_Proxy;
To : AMF.DC.DC_Bounds) is
begin
AMF.Internals.Tables.DD_Attributes.Internal_Set_Bounds
(Self.Element, To);
end Set_Bounds;
-----------------------
-- Get_Corner_Radius --
-----------------------
overriding function Get_Corner_Radius
(Self : not null access constant DG_Rectangle_Proxy)
return AMF.Real is
begin
return
AMF.Internals.Tables.DD_Attributes.Internal_Get_Corner_Radius
(Self.Element);
end Get_Corner_Radius;
-----------------------
-- Set_Corner_Radius --
-----------------------
overriding procedure Set_Corner_Radius
(Self : not null access DG_Rectangle_Proxy;
To : AMF.Real) is
begin
AMF.Internals.Tables.DD_Attributes.Internal_Set_Corner_Radius
(Self.Element, To);
end Set_Corner_Radius;
---------------
-- Get_Group --
---------------
overriding function Get_Group
(Self : not null access constant DG_Rectangle_Proxy)
return AMF.DG.Groups.DG_Group_Access is
begin
return
AMF.DG.Groups.DG_Group_Access
(AMF.Internals.Helpers.To_Element
(AMF.Internals.Tables.DD_Attributes.Internal_Get_Group
(Self.Element)));
end Get_Group;
---------------
-- Set_Group --
---------------
overriding procedure Set_Group
(Self : not null access DG_Rectangle_Proxy;
To : AMF.DG.Groups.DG_Group_Access) is
begin
AMF.Internals.Tables.DD_Attributes.Internal_Set_Group
(Self.Element,
AMF.Internals.Helpers.To_Element
(AMF.Elements.Element_Access (To)));
end Set_Group;
---------------------
-- Get_Local_Style --
---------------------
overriding function Get_Local_Style
(Self : not null access constant DG_Rectangle_Proxy)
return AMF.DG.Styles.Collections.Ordered_Set_Of_DG_Style is
begin
return
AMF.DG.Styles.Collections.Wrap
(AMF.Internals.Element_Collections.Wrap
(AMF.Internals.Tables.DD_Attributes.Internal_Get_Local_Style
(Self.Element)));
end Get_Local_Style;
----------------------
-- Get_Shared_Style --
----------------------
overriding function Get_Shared_Style
(Self : not null access constant DG_Rectangle_Proxy)
return AMF.DG.Styles.Collections.Ordered_Set_Of_DG_Style is
begin
return
AMF.DG.Styles.Collections.Wrap
(AMF.Internals.Element_Collections.Wrap
(AMF.Internals.Tables.DD_Attributes.Internal_Get_Shared_Style
(Self.Element)));
end Get_Shared_Style;
-------------------
-- Get_Transform --
-------------------
overriding function Get_Transform
(Self : not null access constant DG_Rectangle_Proxy)
return AMF.DG.Sequence_Of_DG_Transform is
begin
return
AMF.Internals.Tables.DD_Attributes.Internal_Get_Transform
(Self.Element);
end Get_Transform;
-------------------
-- Get_Clip_Path --
-------------------
overriding function Get_Clip_Path
(Self : not null access constant DG_Rectangle_Proxy)
return AMF.DG.Clip_Paths.DG_Clip_Path_Access is
begin
return
AMF.DG.Clip_Paths.DG_Clip_Path_Access
(AMF.Internals.Helpers.To_Element
(AMF.Internals.Tables.DD_Attributes.Internal_Get_Clip_Path
(Self.Element)));
end Get_Clip_Path;
-------------------
-- Set_Clip_Path --
-------------------
overriding procedure Set_Clip_Path
(Self : not null access DG_Rectangle_Proxy;
To : AMF.DG.Clip_Paths.DG_Clip_Path_Access) is
begin
AMF.Internals.Tables.DD_Attributes.Internal_Set_Clip_Path
(Self.Element,
AMF.Internals.Helpers.To_Element
(AMF.Elements.Element_Access (To)));
end Set_Clip_Path;
-------------------
-- Enter_Element --
-------------------
overriding procedure Enter_Element
(Self : not null access constant DG_Rectangle_Proxy;
Visitor : in out AMF.Visitors.Abstract_Visitor'Class;
Control : in out AMF.Visitors.Traverse_Control) is
begin
if Visitor in AMF.Visitors.DG_Visitors.DG_Visitor'Class then
AMF.Visitors.DG_Visitors.DG_Visitor'Class
(Visitor).Enter_Rectangle
(AMF.DG.Rectangles.DG_Rectangle_Access (Self),
Control);
end if;
end Enter_Element;
-------------------
-- Leave_Element --
-------------------
overriding procedure Leave_Element
(Self : not null access constant DG_Rectangle_Proxy;
Visitor : in out AMF.Visitors.Abstract_Visitor'Class;
Control : in out AMF.Visitors.Traverse_Control) is
begin
if Visitor in AMF.Visitors.DG_Visitors.DG_Visitor'Class then
AMF.Visitors.DG_Visitors.DG_Visitor'Class
(Visitor).Leave_Rectangle
(AMF.DG.Rectangles.DG_Rectangle_Access (Self),
Control);
end if;
end Leave_Element;
-------------------
-- Visit_Element --
-------------------
overriding procedure Visit_Element
(Self : not null access constant DG_Rectangle_Proxy;
Iterator : in out AMF.Visitors.Abstract_Iterator'Class;
Visitor : in out AMF.Visitors.Abstract_Visitor'Class;
Control : in out AMF.Visitors.Traverse_Control) is
begin
if Iterator in AMF.Visitors.DG_Iterators.DG_Iterator'Class then
AMF.Visitors.DG_Iterators.DG_Iterator'Class
(Iterator).Visit_Rectangle
(Visitor,
AMF.DG.Rectangles.DG_Rectangle_Access (Self),
Control);
end if;
end Visit_Element;
end AMF.Internals.DG_Rectangles;
|
persan/protobuf-ada | Ada | 41 | ads | package jspb.test is
end jspb.test; |
gabemgem/LITEC | Ada | 14,797 | adb | M:lab4Data
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$lcd_print$0$0({2}DF,SV:S),Z,0,0,0,0,0
S:Llab4Data.lcd_print$fmt$1$80({3}DG,SC:U),B,1,-5
S:Llab4Data.lcd_print$len$1$81({1}SC:U),R,0,0,[r6]
S:Llab4Data.lcd_print$i$1$81({1}SC:U),R,0,0,[]
S:Llab4Data.lcd_print$ap$1$81({1}DD,SC:U),R,0,0,[]
F:G$lcd_clear$0$0({2}DF,SV:S),Z,0,0,0,0,0
F:G$read_keypad$0$0({2}DF,SC:U),C,0,0,0,0,0
F:G$kpd_input$0$0({2}DF,SI:U),Z,0,0,0,0,0
F:G$delay_time$0$0({2}DF,SV:S),Z,0,0,0,0,0
F:G$i2c_start$0$0({2}DF,SV:S),Z,0,0,0,0,0
F:G$i2c_write$0$0({2}DF,SV:S),Z,0,0,0,0,0
F:G$i2c_write_and_stop$0$0({2}DF,SV:S),Z,0,0,0,0,0
F:G$i2c_read$0$0({2}DF,SC:U),Z,0,0,0,0,0
F:G$i2c_read_and_stop$0$0({2}DF,SC:U),Z,0,0,0,0,0
F:G$i2c_write_data$0$0({2}DF,SV:S),Z,0,0,0,0,0
F:G$i2c_read_data$0$0({2}DF,SV:S),Z,0,0,0,0,0
F:G$Accel_Init$0$0({2}DF,SV:S),Z,0,0,0,0,0
F:G$Accel_Init_C$0$0({2}DF,SV:S),Z,0,0,0,0,0
F:G$main$0$0({2}DF,SV:S),C,0,0,0,0,0
F:G$Port_Init$0$0({2}DF,SV:S),Z,0,0,0,0,0
F:G$XBR0_Init$0$0({2}DF,SV:S),Z,0,0,0,0,0
F:G$SMB_Init$0$0({2}DF,SV:S),Z,0,0,0,0,0
F:G$ADC_Init$0$0({2}DF,SV:S),Z,0,0,0,0,0
F:G$ADC_Convert$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$Interrupt_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
F:G$Read_Compass$0$0({2}DF,SV:S),Z,0,0,0,0,0
F:G$ReadRanger$0$0({2}DF,SI:U),Z,0,0,0,0,0
F:G$Ranger$0$0({2}DF,SV:S),Z,0,0,0,0,0
F:G$Steering_Servo$0$0({2}DF,SV:S),Z,0,0,0,0,0
S:Llab4Data.getchar$c$1$10({1}SC:U),R,0,0,[]
S:Llab4Data.getchar_nw$c$1$12({1}SC:U),R,0,0,[]
S:G$Data2$0$0({3}DA3d,SC:U),E,0,0
S:Llab4Data.aligned_alloc$size$1$39({2}SI:U),E,0,0
S:Llab4Data.aligned_alloc$alignment$1$39({2}SI:U),E,0,0
S:Llab4Data.lcd_clear$NumBytes$1$85({1}SC:U),E,0,0
S:Llab4Data.lcd_clear$Cmd$1$85({2}DA2d,SC:U),E,0,0
S:Llab4Data.read_keypad$i$1$86({1}SC:U),R,0,0,[r7]
S:Llab4Data.read_keypad$Data$1$86({2}DA2d,SC:U),E,0,0
S:Llab4Data.kpd_input$mode$1$88({1}SC:U),R,0,0,[r7]
S:Llab4Data.kpd_input$sum$1$89({2}SI:U),R,0,0,[r5,r6]
S:Llab4Data.kpd_input$key$1$89({1}SC:U),R,0,0,[r3]
S:Llab4Data.kpd_input$i$1$89({1}SC:U),R,0,0,[]
S:Llab4Data.i2c_write_data$start_reg$1$105({1}SC:U),E,0,0
S:Llab4Data.i2c_write_data$buffer$1$105({3}DG,SC:U),E,0,0
S:Llab4Data.i2c_write_data$num_bytes$1$105({1}SC:U),E,0,0
S:Llab4Data.i2c_write_data$addr$1$105({1}SC:U),R,0,0,[r7]
S:Llab4Data.i2c_write_data$i$1$106({1}SC:U),R,0,0,[]
S:Llab4Data.i2c_read_data$start_reg$1$107({1}SC:U),E,0,0
S:Llab4Data.i2c_read_data$buffer$1$107({3}DG,SC:U),E,0,0
S:Llab4Data.i2c_read_data$num_bytes$1$107({1}SC:U),E,0,0
S:Llab4Data.i2c_read_data$addr$1$107({1}SC:U),R,0,0,[r7]
S:Llab4Data.i2c_read_data$j$1$108({1}SC:U),R,0,0,[]
S:G$PCA_start$0$0({2}SI:U),E,0,0
S:G$ccount$0$0({1}SC:U),E,0,0
S:G$rcount$0$0({1}SC:U),E,0,0
S:G$heading$0$0({2}SI:U),E,0,0
S:G$desired$0$0({2}SI:U),E,0,0
S:G$rangervalue$0$0({2}SI:U),E,0,0
S:G$print_count$0$0({2}SI:U),E,0,0
S:G$input$0$0({1}SC:U),E,0,0
S:G$Data$0$0({2}DA2d,SC:U),E,0,0
S:G$adc$0$0({1}SC:U),E,0,0
S:G$loopcontrol$0$0({1}SC:U),E,0,0
S:G$PW_CENTER$0$0({2}SI:U),E,0,0
S:G$PW_RIGHT$0$0({2}SI:U),E,0,0
S:G$PW_LEFT$0$0({2}SI:U),E,0,0
S:G$SERVO_PW$0$0({2}SI:U),E,0,0
S:G$error$0$0({2}SI:S),E,0,0
S:G$k$0$0({4}SF:S),E,0,0
S:G$temp$0$0({2}SI:U),E,0,0
S:G$PW_MIN$0$0({2}SI:U),E,0,0
S:G$PW_MAX$0$0({2}SI:U),E,0,0
S:G$PW_NEUT$0$0({2}SI:U),E,0,0
S:G$MOTOR_PW$0$0({2}SI:U),E,0,0
S:G$obstacle$0$0({1}SC:U),E,0,0
S:G$stop$0$0({1}SC:U),E,0,0
S:Llab4Data.ReadRanger$range$1$152({2}SI:U),R,0,0,[]
S:Llab4Data.ReadRanger$addr$1$152({1}SC:U),R,0,0,[]
S:Llab4Data.lcd_print$text$1$81({80}DA80d,SC:U),F,0,0
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$BUS_BUSY$0$0({1}SX:U),J,0,0
S:G$BUS_EN$0$0({1}SX:U),J,0,0
S:G$BUS_START$0$0({1}SX:U),J,0,0
S:G$BUS_STOP$0$0({1}SX:U),J,0,0
S:G$BUS_INT$0$0({1}SX:U),J,0,0
S:G$BUS_AA$0$0({1}SX:U),J,0,0
S:G$BUS_FTE$0$0({1}SX:U),J,0,0
S:G$BUS_TOE$0$0({1}SX:U),J,0,0
S:G$BUS_SCL$0$0({1}SX:U),J,0,0
S:G$SS$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$atof$0$0({2}DF,SF:S),C,0,0
S:G$atoi$0$0({2}DF,SI:S),C,0,0
S:G$atol$0$0({2}DF,SL:S),C,0,0
S:G$_uitoa$0$0({2}DF,SV:S),C,0,0
S:G$_itoa$0$0({2}DF,SV:S),C,0,0
S:G$_ultoa$0$0({2}DF,SV:S),C,0,0
S:G$_ltoa$0$0({2}DF,SV:S),C,0,0
S:G$rand$0$0({2}DF,SI:S),C,0,0
S:G$srand$0$0({2}DF,SV:S),C,0,0
S:G$calloc$0$0({2}DF,DX,SV:S),C,0,0
S:G$malloc$0$0({2}DF,DX,SV:S),C,0,0
S:G$realloc$0$0({2}DF,DX,SV:S),C,0,0
S:G$aligned_alloc$0$0({2}DF,DG,SV:S),C,0,0
S:G$free$0$0({2}DF,SV:S),C,0,0
S:G$abs$0$0({2}DF,SI:S),C,0,0
S:G$labs$0$0({2}DF,SL:S),C,0,0
S:G$mblen$0$0({2}DF,SI:S),C,0,0
S:G$mbtowc$0$0({2}DF,SI:S),C,0,0
S:G$wctomb$0$0({2}DF,SI:S),C,0,0
S:G$memcpy$0$0({2}DF,DG,SV:S),C,0,0
S:G$memmove$0$0({2}DF,DG,SV:S),C,0,0
S:G$strcpy$0$0({2}DF,DG,SC:U),C,0,0
S:G$strncpy$0$0({2}DF,DG,SC:U),C,0,0
S:G$strcat$0$0({2}DF,DG,SC:U),C,0,0
S:G$strncat$0$0({2}DF,DG,SC:U),C,0,0
S:G$memcmp$0$0({2}DF,SI:S),C,0,0
S:G$strcmp$0$0({2}DF,SI:S),C,0,0
S:G$strncmp$0$0({2}DF,SI:S),C,0,0
S:G$strxfrm$0$0({2}DF,SI:U),C,0,0
S:G$memchr$0$0({2}DF,DG,SV:S),C,0,0
S:G$strchr$0$0({2}DF,DG,SC:U),C,0,0
S:G$strcspn$0$0({2}DF,SI:U),C,0,0
S:G$strpbrk$0$0({2}DF,DG,SC:U),C,0,0
S:G$strrchr$0$0({2}DF,DG,SC:U),C,0,0
S:G$strspn$0$0({2}DF,SI:U),C,0,0
S:G$strstr$0$0({2}DF,DG,SC:U),C,0,0
S:G$strtok$0$0({2}DF,DG,SC:U),C,0,0
S:G$memset$0$0({2}DF,DG,SV:S),C,0,0
S:G$strlen$0$0({2}DF,SI:U),C,0,0
S:G$key_test$0$0({2}DF,SV:S),C,0,0
S:G$i2c_stop_and_read$0$0({2}DF,SC:U),C,0,0
S:G$read_keypad$0$0({2}DF,SC:U),C,0,0
S:G$main$0$0({2}DF,SV:S),C,0,0
S:Flab4Data$__str_0$0$0({22}DA22d,SC:S),D,0,0
S:Flab4Data$__str_1$0$0({16}DA16d,SC:S),D,0,0
S:Flab4Data$__str_2$0$0({3}DA3d,SC:S),D,0,0
S:Flab4Data$__str_3$0$0({20}DA20d,SC:S),D,0,0
S:Flab4Data$__str_4$0$0({51}DA51d,SC:S),D,0,0
S:Flab4Data$__str_5$0$0({62}DA62d,SC:S),D,0,0
S:Flab4Data$__str_6$0$0({46}DA46d,SC:S),D,0,0
S:Flab4Data$__str_7$0$0({55}DA55d,SC:S),D,0,0
S:Flab4Data$__str_8$0$0({41}DA41d,SC:S),D,0,0
S:Flab4Data$__str_9$0$0({24}DA24d,SC:S),D,0,0
S:Flab4Data$__str_10$0$0({20}DA20d,SC:S),D,0,0
S:Flab4Data$__str_11$0$0({29}DA29d,SC:S),D,0,0
S:Flab4Data$__str_12$0$0({42}DA42d,SC:S),D,0,0
S:Flab4Data$__str_13$0$0({24}DA24d,SC:S),D,0,0
S:Flab4Data$__str_14$0$0({62}DA62d,SC:S),D,0,0
S:Flab4Data$__str_15$0$0({42}DA42d,SC:S),D,0,0
S:Flab4Data$__str_16$0$0({52}DA52d,SC:S),D,0,0
|
ficorax/PortAudioAda | Ada | 4,448 | adb | with Glib; use Glib;
with Gtk.Adjustment; use Gtk.Adjustment;
with Gtk.Button; use Gtk.Button;
with Gtk.Combo_Box; use Gtk.Combo_Box;
with Gtk.Combo_Box_Text; use Gtk.Combo_Box_Text;
with Gtk.Label; use Gtk.Label;
with Gtk.Main; use Gtk.Main;
with Gtk.Scale; use Gtk.Scale;
with Gtk.Spin_Button; use Gtk.Spin_Button;
with Gtk.Table; use Gtk.Table;
with Gtk.Window; use Gtk.Window;
with PortAudioAda; use PortAudioAda;
with GA_Sine_Callbacks; use GA_Sine_Callbacks;
with GA_Sine_Globals; use GA_Sine_Globals;
with GA_Sine_Package; use GA_Sine_Package;
procedure GA_Sine
is
window : Gtk_Window;
table : Gtk.Table.Gtk_Table;
label : Gtk.Label.Gtk_Label;
spin : Gtk.Spin_Button.Gtk_Spin_Button;
button : Gtk.Button.Gtk_Button;
adjust : Gtk.Adjustment.Gtk_Adjustment;
scale : Gtk.Scale.Gtk_Hscale;
combo : Gtk.Combo_Box_Text.Gtk_Combo_Box_Text;
err : PA_Error;
begin
err := PA_Initialize;
if err /= paNoError then
raise PortAudio_Exception with PA_Get_Error_Text (err);
end if;
Init;
Gtk_New (window);
Set_Title (window, "PortAudio Test: Sine");
Set_Size_Request (window, -1, -1);
Return_Handlers.Connect
(window,
"delete_event",
Return_Handlers.To_Marshaller (Delete_Event'Access));
Handlers.Connect (window,
"destroy",
Handlers.To_Marshaller (Destroy'Access));
-----------------------------------------------------------------------------
Gtk_New (table, 4, 3, True);
Set_Row_Spacings (table, 4);
Set_Col_Spacings (table, 10);
-- Labels
Gtk_New (label, "Frames per buffer");
Attach (table, label, 0, 1, 0, 1);
Gtk_New (label, "Sample rate");
Attach (table, label, 0, 1, 1, 2);
Gtk_New (label, "Amplitude");
Attach (table, label, 0, 1, 2, 3);
Gtk_New (label, "Frequency");
Attach (table, label, 0, 1, 3, 4);
-- Controls
Gtk_New (spin, 0.0, 1024.0, 16.0);
Attach (table, spin, 1, 2, 0, 1);
Set_Alignment (spin, 1.0);
Set_Value (spin, Gdouble (Frames_Per_Buffer));
SpinHand.Connect
(spin,
"value_changed",
SpinHand.To_Marshaller (Frames_Per_Buffer_Callback'Access));
options (EO_frames_Per_Buffer).optionWidget := spin;
options (EO_frames_Per_Buffer).optionUse := OU_Before;
Gtk_New (combo);
Attach (table, combo, 1, 2, 1, 2);
for i in sample_Rates'Range loop
Append_Text (combo, sample_Rates (i).txtRate);
end loop;
Set_Active (combo, 8);
CombHand.Connect
(combo,
"changed",
CombHand.To_Marshaller (Sample_Rate_Callback'Access));
options (EO_Sample_Rate).optionWidget := combo;
options (EO_Sample_Rate).optionUse := OU_Before;
Gtk_New (adjust, 0.0, 0.0, 1.0, 0.01, 0.1);
Gtk_New_Hscale (scale, adjust);
Attach (table, scale, 1, 2, 2, 3);
Set_Digits (scale, 2);
Set_Value (scale, Gdouble (gUserData.amplitude));
ScaleHand.Connect
(scale,
"value_changed",
ScaleHand.To_Marshaller (Amplitude_Callback'Access));
options (EO_Amplitude).optionWidget := spin;
options (EO_Amplitude).optionUse := OU_Before;
Gtk_New (adjust, 0.0, 16.351598, 8372.018085, 0.01, 10.0);
Gtk_New_Hscale (scale, adjust);
Set_Digits (scale, 2);
Attach (table, scale, 1, 2, 3, 4);
Set_Value (scale, Gdouble (gUserData.frequency));
ScaleHand.Connect
(scale,
"value_changed",
ScaleHand.To_Marshaller (Frequency_Callback'Access));
options (EO_Frequency).optionWidget := spin;
options (EO_Frequency).optionUse := OU_Before;
-- Buttons
Gtk_New (button, "Start");
Attach (table, button, 2, 3, 0, 1);
Handlers.Connect (button,
"clicked",
Handlers.To_Marshaller (Start_Callback'Access));
Gtk_New (button, "Stop");
Attach (table, button, 2, 3, 1, 2);
Handlers.Connect (button,
"clicked",
Handlers.To_Marshaller (Stop_Callback'Access));
Gtk_New (button, "Quit");
Attach (table, button, 2, 3, 3, 4);
Handlers.Connect (button,
"clicked",
Handlers.To_Marshaller (Destroy'Access));
-----------------------------------------------------------------------------
Add (window, table);
Show_All (window);
Main;
err := PA_Terminate;
if err /= paNoError then
raise PortAudio_Exception with PA_Get_Error_Text (err);
end if;
end GA_Sine;
|
reznikmm/matreshka | Ada | 44,621 | ads | ------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- Ada Modeling Framework --
-- --
-- Runtime Library Component --
-- --
------------------------------------------------------------------------------
-- --
-- Copyright © 2011-2012, Vadim Godunko <[email protected]> --
-- All rights reserved. --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions --
-- are met: --
-- --
-- * Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- --
-- * Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in the --
-- documentation and/or other materials provided with the distribution. --
-- --
-- * Neither the name of the Vadim Godunko, IE nor the names of its --
-- contributors may be used to endorse or promote products derived from --
-- this software without specific prior written permission. --
-- --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR --
-- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
-- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED --
-- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR --
-- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF --
-- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING --
-- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS --
-- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
-- --
------------------------------------------------------------------------------
-- $Revision$ $Date$
------------------------------------------------------------------------------
with AMF.Internals.UML_Classes;
with AMF.String_Collections;
with AMF.UML.Behaviors.Collections;
with AMF.UML.Classes.Collections;
with AMF.UML.Classifier_Template_Parameters;
with AMF.UML.Classifiers.Collections;
with AMF.UML.Collaboration_Uses.Collections;
with AMF.UML.Component_Realizations.Collections;
with AMF.UML.Components;
with AMF.UML.Connectable_Elements.Collections;
with AMF.UML.Connectors.Collections;
with AMF.UML.Constraints.Collections;
with AMF.UML.Dependencies.Collections;
with AMF.UML.Element_Imports.Collections;
with AMF.UML.Extensions.Collections;
with AMF.UML.Features.Collections;
with AMF.UML.Generalization_Sets.Collections;
with AMF.UML.Generalizations.Collections;
with AMF.UML.Interface_Realizations.Collections;
with AMF.UML.Interfaces.Collections;
with AMF.UML.Named_Elements.Collections;
with AMF.UML.Namespaces;
with AMF.UML.Operations.Collections;
with AMF.UML.Package_Imports.Collections;
with AMF.UML.Packageable_Elements.Collections;
with AMF.UML.Packages.Collections;
with AMF.UML.Parameterable_Elements.Collections;
with AMF.UML.Ports.Collections;
with AMF.UML.Properties.Collections;
with AMF.UML.Receptions.Collections;
with AMF.UML.Redefinable_Elements.Collections;
with AMF.UML.Redefinable_Template_Signatures;
with AMF.UML.String_Expressions;
with AMF.UML.Substitutions.Collections;
with AMF.UML.Template_Bindings.Collections;
with AMF.UML.Template_Parameters;
with AMF.UML.Template_Signatures;
with AMF.UML.Types;
with AMF.UML.Use_Cases.Collections;
with AMF.Visitors;
package AMF.Internals.UML_Components is
type UML_Component_Proxy is
limited new AMF.Internals.UML_Classes.UML_Class_Proxy
and AMF.UML.Components.UML_Component with null record;
overriding function Get_Is_Indirectly_Instantiated
(Self : not null access constant UML_Component_Proxy)
return Boolean;
-- Getter of Component::isIndirectlyInstantiated.
--
-- isIndirectlyInstantiated : Boolean {default = true} The kind of
-- instantiation that applies to a Component. If false, the component is
-- instantiated as an addressable object. If true, the Component is
-- defined at design-time, but at run-time (or execution-time) an object
-- specified by the Component does not exist, that is, the component is
-- instantiated indirectly, through the instantiation of its realizing
-- classifiers or parts. Several standard stereotypes use this meta
-- attribute (e.g., «specification», «focus», «subsystem»).
overriding procedure Set_Is_Indirectly_Instantiated
(Self : not null access UML_Component_Proxy;
To : Boolean);
-- Setter of Component::isIndirectlyInstantiated.
--
-- isIndirectlyInstantiated : Boolean {default = true} The kind of
-- instantiation that applies to a Component. If false, the component is
-- instantiated as an addressable object. If true, the Component is
-- defined at design-time, but at run-time (or execution-time) an object
-- specified by the Component does not exist, that is, the component is
-- instantiated indirectly, through the instantiation of its realizing
-- classifiers or parts. Several standard stereotypes use this meta
-- attribute (e.g., «specification», «focus», «subsystem»).
overriding function Get_Packaged_Element
(Self : not null access constant UML_Component_Proxy)
return AMF.UML.Packageable_Elements.Collections.Set_Of_UML_Packageable_Element;
-- Getter of Component::packagedElement.
--
-- The set of PackageableElements that a Component owns. In the namespace
-- of a component, all model elements that are involved in or related to
-- its definition may be owned or imported explicitly. These may include
-- e.g. Classes, Interfaces, Components, Packages, Use cases, Dependencies
-- (e.g. mappings), and Artifacts.
overriding function Get_Provided
(Self : not null access constant UML_Component_Proxy)
return AMF.UML.Interfaces.Collections.Set_Of_UML_Interface;
-- Getter of Component::provided.
--
-- The interfaces that the component exposes to its environment. These
-- interfaces may be Realized by the Component or any of its
-- realizingClassifiers, or they may be the Interfaces that are provided
-- by its public Ports.
overriding function Get_Realization
(Self : not null access constant UML_Component_Proxy)
return AMF.UML.Component_Realizations.Collections.Set_Of_UML_Component_Realization;
-- Getter of Component::realization.
--
-- The set of Realizations owned by the Component. Realizations reference
-- the Classifiers of which the Component is an abstraction; i.e., that
-- realize its behavior.
overriding function Get_Required
(Self : not null access constant UML_Component_Proxy)
return AMF.UML.Interfaces.Collections.Set_Of_UML_Interface;
-- Getter of Component::required.
--
-- The interfaces that the component requires from other components in its
-- environment in order to be able to offer its full set of provided
-- functionality. These interfaces may be used by the Component or any of
-- its realizingClassifiers, or they may be the Interfaces that are
-- required by its public Ports.
overriding function Get_Extension
(Self : not null access constant UML_Component_Proxy)
return AMF.UML.Extensions.Collections.Set_Of_UML_Extension;
-- Getter of Class::extension.
--
-- References the Extensions that specify additional properties of the
-- metaclass. The property is derived from the extensions whose memberEnds
-- are typed by the Class.
overriding function Get_Is_Abstract
(Self : not null access constant UML_Component_Proxy)
return Boolean;
-- Getter of Class::isAbstract.
--
-- True when a class is abstract.
-- If true, the Classifier does not provide a complete declaration and can
-- typically not be instantiated. An abstract classifier is intended to be
-- used by other classifiers e.g. as the target of general
-- metarelationships or generalization relationships.
overriding function Get_Is_Active
(Self : not null access constant UML_Component_Proxy)
return Boolean;
-- Getter of Class::isActive.
--
-- Determines whether an object specified by this class is active or not.
-- If true, then the owning class is referred to as an active class. If
-- false, then such a class is referred to as a passive class.
overriding procedure Set_Is_Active
(Self : not null access UML_Component_Proxy;
To : Boolean);
-- Setter of Class::isActive.
--
-- Determines whether an object specified by this class is active or not.
-- If true, then the owning class is referred to as an active class. If
-- false, then such a class is referred to as a passive class.
overriding function Get_Nested_Classifier
(Self : not null access constant UML_Component_Proxy)
return AMF.UML.Classifiers.Collections.Ordered_Set_Of_UML_Classifier;
-- Getter of Class::nestedClassifier.
--
-- References all the Classifiers that are defined (nested) within the
-- Class.
overriding function Get_Owned_Attribute
(Self : not null access constant UML_Component_Proxy)
return AMF.UML.Properties.Collections.Ordered_Set_Of_UML_Property;
-- Getter of Class::ownedAttribute.
--
-- The attributes (i.e. the properties) owned by the class.
overriding function Get_Owned_Operation
(Self : not null access constant UML_Component_Proxy)
return AMF.UML.Operations.Collections.Ordered_Set_Of_UML_Operation;
-- Getter of Class::ownedOperation.
--
-- The operations owned by the class.
overriding function Get_Owned_Reception
(Self : not null access constant UML_Component_Proxy)
return AMF.UML.Receptions.Collections.Set_Of_UML_Reception;
-- Getter of Class::ownedReception.
--
-- Receptions that objects of this class are willing to accept.
overriding function Get_Super_Class
(Self : not null access constant UML_Component_Proxy)
return AMF.UML.Classes.Collections.Set_Of_UML_Class;
-- Getter of Class::superClass.
--
-- This gives the superclasses of a class.
overriding function Get_Classifier_Behavior
(Self : not null access constant UML_Component_Proxy)
return AMF.UML.Behaviors.UML_Behavior_Access;
-- Getter of BehavioredClassifier::classifierBehavior.
--
-- A behavior specification that specifies the behavior of the classifier
-- itself.
overriding procedure Set_Classifier_Behavior
(Self : not null access UML_Component_Proxy;
To : AMF.UML.Behaviors.UML_Behavior_Access);
-- Setter of BehavioredClassifier::classifierBehavior.
--
-- A behavior specification that specifies the behavior of the classifier
-- itself.
overriding function Get_Interface_Realization
(Self : not null access constant UML_Component_Proxy)
return AMF.UML.Interface_Realizations.Collections.Set_Of_UML_Interface_Realization;
-- Getter of BehavioredClassifier::interfaceRealization.
--
-- The set of InterfaceRealizations owned by the BehavioredClassifier.
-- Interface realizations reference the Interfaces of which the
-- BehavioredClassifier is an implementation.
overriding function Get_Owned_Behavior
(Self : not null access constant UML_Component_Proxy)
return AMF.UML.Behaviors.Collections.Set_Of_UML_Behavior;
-- Getter of BehavioredClassifier::ownedBehavior.
--
-- References behavior specifications owned by a classifier.
overriding function Get_Attribute
(Self : not null access constant UML_Component_Proxy)
return AMF.UML.Properties.Collections.Set_Of_UML_Property;
-- Getter of Classifier::attribute.
--
-- Refers to all of the Properties that are direct (i.e. not inherited or
-- imported) attributes of the classifier.
overriding function Get_Collaboration_Use
(Self : not null access constant UML_Component_Proxy)
return AMF.UML.Collaboration_Uses.Collections.Set_Of_UML_Collaboration_Use;
-- Getter of Classifier::collaborationUse.
--
-- References the collaboration uses owned by the classifier.
overriding function Get_Feature
(Self : not null access constant UML_Component_Proxy)
return AMF.UML.Features.Collections.Set_Of_UML_Feature;
-- Getter of Classifier::feature.
--
-- Specifies each feature defined in the classifier.
-- Note that there may be members of the Classifier that are of the type
-- Feature but are not included in this association, e.g. inherited
-- features.
overriding function Get_General
(Self : not null access constant UML_Component_Proxy)
return AMF.UML.Classifiers.Collections.Set_Of_UML_Classifier;
-- Getter of Classifier::general.
--
-- Specifies the general Classifiers for this Classifier.
-- References the general classifier in the Generalization relationship.
overriding function Get_Generalization
(Self : not null access constant UML_Component_Proxy)
return AMF.UML.Generalizations.Collections.Set_Of_UML_Generalization;
-- Getter of Classifier::generalization.
--
-- Specifies the Generalization relationships for this Classifier. These
-- Generalizations navigaten to more general classifiers in the
-- generalization hierarchy.
overriding function Get_Inherited_Member
(Self : not null access constant UML_Component_Proxy)
return AMF.UML.Named_Elements.Collections.Set_Of_UML_Named_Element;
-- Getter of Classifier::inheritedMember.
--
-- Specifies all elements inherited by this classifier from the general
-- classifiers.
overriding function Get_Is_Final_Specialization
(Self : not null access constant UML_Component_Proxy)
return Boolean;
-- Getter of Classifier::isFinalSpecialization.
--
-- If true, the Classifier cannot be specialized by generalization. Note
-- that this property is preserved through package merge operations; that
-- is, the capability to specialize a Classifier (i.e.,
-- isFinalSpecialization =false) must be preserved in the resulting
-- Classifier of a package merge operation where a Classifier with
-- isFinalSpecialization =false is merged with a matching Classifier with
-- isFinalSpecialization =true: the resulting Classifier will have
-- isFinalSpecialization =false.
overriding procedure Set_Is_Final_Specialization
(Self : not null access UML_Component_Proxy;
To : Boolean);
-- Setter of Classifier::isFinalSpecialization.
--
-- If true, the Classifier cannot be specialized by generalization. Note
-- that this property is preserved through package merge operations; that
-- is, the capability to specialize a Classifier (i.e.,
-- isFinalSpecialization =false) must be preserved in the resulting
-- Classifier of a package merge operation where a Classifier with
-- isFinalSpecialization =false is merged with a matching Classifier with
-- isFinalSpecialization =true: the resulting Classifier will have
-- isFinalSpecialization =false.
overriding function Get_Owned_Template_Signature
(Self : not null access constant UML_Component_Proxy)
return AMF.UML.Redefinable_Template_Signatures.UML_Redefinable_Template_Signature_Access;
-- Getter of Classifier::ownedTemplateSignature.
--
-- The optional template signature specifying the formal template
-- parameters.
overriding procedure Set_Owned_Template_Signature
(Self : not null access UML_Component_Proxy;
To : AMF.UML.Redefinable_Template_Signatures.UML_Redefinable_Template_Signature_Access);
-- Setter of Classifier::ownedTemplateSignature.
--
-- The optional template signature specifying the formal template
-- parameters.
overriding function Get_Owned_Use_Case
(Self : not null access constant UML_Component_Proxy)
return AMF.UML.Use_Cases.Collections.Set_Of_UML_Use_Case;
-- Getter of Classifier::ownedUseCase.
--
-- References the use cases owned by this classifier.
overriding function Get_Powertype_Extent
(Self : not null access constant UML_Component_Proxy)
return AMF.UML.Generalization_Sets.Collections.Set_Of_UML_Generalization_Set;
-- Getter of Classifier::powertypeExtent.
--
-- Designates the GeneralizationSet of which the associated Classifier is
-- a power type.
overriding function Get_Redefined_Classifier
(Self : not null access constant UML_Component_Proxy)
return AMF.UML.Classifiers.Collections.Set_Of_UML_Classifier;
-- Getter of Classifier::redefinedClassifier.
--
-- References the Classifiers that are redefined by this Classifier.
overriding function Get_Representation
(Self : not null access constant UML_Component_Proxy)
return AMF.UML.Collaboration_Uses.UML_Collaboration_Use_Access;
-- Getter of Classifier::representation.
--
-- References a collaboration use which indicates the collaboration that
-- represents this classifier.
overriding procedure Set_Representation
(Self : not null access UML_Component_Proxy;
To : AMF.UML.Collaboration_Uses.UML_Collaboration_Use_Access);
-- Setter of Classifier::representation.
--
-- References a collaboration use which indicates the collaboration that
-- represents this classifier.
overriding function Get_Substitution
(Self : not null access constant UML_Component_Proxy)
return AMF.UML.Substitutions.Collections.Set_Of_UML_Substitution;
-- Getter of Classifier::substitution.
--
-- References the substitutions that are owned by this Classifier.
overriding function Get_Template_Parameter
(Self : not null access constant UML_Component_Proxy)
return AMF.UML.Classifier_Template_Parameters.UML_Classifier_Template_Parameter_Access;
-- Getter of Classifier::templateParameter.
--
-- The template parameter that exposes this element as a formal parameter.
overriding procedure Set_Template_Parameter
(Self : not null access UML_Component_Proxy;
To : AMF.UML.Classifier_Template_Parameters.UML_Classifier_Template_Parameter_Access);
-- Setter of Classifier::templateParameter.
--
-- The template parameter that exposes this element as a formal parameter.
overriding function Get_Use_Case
(Self : not null access constant UML_Component_Proxy)
return AMF.UML.Use_Cases.Collections.Set_Of_UML_Use_Case;
-- Getter of Classifier::useCase.
--
-- The set of use cases for which this Classifier is the subject.
overriding function Get_Element_Import
(Self : not null access constant UML_Component_Proxy)
return AMF.UML.Element_Imports.Collections.Set_Of_UML_Element_Import;
-- Getter of Namespace::elementImport.
--
-- References the ElementImports owned by the Namespace.
overriding function Get_Imported_Member
(Self : not null access constant UML_Component_Proxy)
return AMF.UML.Packageable_Elements.Collections.Set_Of_UML_Packageable_Element;
-- Getter of Namespace::importedMember.
--
-- References the PackageableElements that are members of this Namespace
-- as a result of either PackageImports or ElementImports.
overriding function Get_Member
(Self : not null access constant UML_Component_Proxy)
return AMF.UML.Named_Elements.Collections.Set_Of_UML_Named_Element;
-- Getter of Namespace::member.
--
-- A collection of NamedElements identifiable within the Namespace, either
-- by being owned or by being introduced by importing or inheritance.
overriding function Get_Owned_Member
(Self : not null access constant UML_Component_Proxy)
return AMF.UML.Named_Elements.Collections.Set_Of_UML_Named_Element;
-- Getter of Namespace::ownedMember.
--
-- A collection of NamedElements owned by the Namespace.
overriding function Get_Owned_Rule
(Self : not null access constant UML_Component_Proxy)
return AMF.UML.Constraints.Collections.Set_Of_UML_Constraint;
-- Getter of Namespace::ownedRule.
--
-- Specifies a set of Constraints owned by this Namespace.
overriding function Get_Package_Import
(Self : not null access constant UML_Component_Proxy)
return AMF.UML.Package_Imports.Collections.Set_Of_UML_Package_Import;
-- Getter of Namespace::packageImport.
--
-- References the PackageImports owned by the Namespace.
overriding function Get_Client_Dependency
(Self : not null access constant UML_Component_Proxy)
return AMF.UML.Dependencies.Collections.Set_Of_UML_Dependency;
-- Getter of NamedElement::clientDependency.
--
-- Indicates the dependencies that reference the client.
overriding function Get_Name_Expression
(Self : not null access constant UML_Component_Proxy)
return AMF.UML.String_Expressions.UML_String_Expression_Access;
-- Getter of NamedElement::nameExpression.
--
-- The string expression used to define the name of this named element.
overriding procedure Set_Name_Expression
(Self : not null access UML_Component_Proxy;
To : AMF.UML.String_Expressions.UML_String_Expression_Access);
-- Setter of NamedElement::nameExpression.
--
-- The string expression used to define the name of this named element.
overriding function Get_Namespace
(Self : not null access constant UML_Component_Proxy)
return AMF.UML.Namespaces.UML_Namespace_Access;
-- Getter of NamedElement::namespace.
--
-- Specifies the namespace that owns the NamedElement.
overriding function Get_Qualified_Name
(Self : not null access constant UML_Component_Proxy)
return AMF.Optional_String;
-- Getter of NamedElement::qualifiedName.
--
-- A name which allows the NamedElement to be identified within a
-- hierarchy of nested Namespaces. It is constructed from the names of the
-- containing namespaces starting at the root of the hierarchy and ending
-- with the name of the NamedElement itself.
overriding function Get_Package
(Self : not null access constant UML_Component_Proxy)
return AMF.UML.Packages.UML_Package_Access;
-- Getter of Type::package.
--
-- Specifies the owning package of this classifier, if any.
overriding procedure Set_Package
(Self : not null access UML_Component_Proxy;
To : AMF.UML.Packages.UML_Package_Access);
-- Setter of Type::package.
--
-- Specifies the owning package of this classifier, if any.
overriding function Get_Owning_Template_Parameter
(Self : not null access constant UML_Component_Proxy)
return AMF.UML.Template_Parameters.UML_Template_Parameter_Access;
-- Getter of ParameterableElement::owningTemplateParameter.
--
-- The formal template parameter that owns this element.
overriding procedure Set_Owning_Template_Parameter
(Self : not null access UML_Component_Proxy;
To : AMF.UML.Template_Parameters.UML_Template_Parameter_Access);
-- Setter of ParameterableElement::owningTemplateParameter.
--
-- The formal template parameter that owns this element.
overriding function Get_Template_Parameter
(Self : not null access constant UML_Component_Proxy)
return AMF.UML.Template_Parameters.UML_Template_Parameter_Access;
-- Getter of ParameterableElement::templateParameter.
--
-- The template parameter that exposes this element as a formal parameter.
overriding procedure Set_Template_Parameter
(Self : not null access UML_Component_Proxy;
To : AMF.UML.Template_Parameters.UML_Template_Parameter_Access);
-- Setter of ParameterableElement::templateParameter.
--
-- The template parameter that exposes this element as a formal parameter.
overriding function Get_Owned_Template_Signature
(Self : not null access constant UML_Component_Proxy)
return AMF.UML.Template_Signatures.UML_Template_Signature_Access;
-- Getter of TemplateableElement::ownedTemplateSignature.
--
-- The optional template signature specifying the formal template
-- parameters.
overriding procedure Set_Owned_Template_Signature
(Self : not null access UML_Component_Proxy;
To : AMF.UML.Template_Signatures.UML_Template_Signature_Access);
-- Setter of TemplateableElement::ownedTemplateSignature.
--
-- The optional template signature specifying the formal template
-- parameters.
overriding function Get_Template_Binding
(Self : not null access constant UML_Component_Proxy)
return AMF.UML.Template_Bindings.Collections.Set_Of_UML_Template_Binding;
-- Getter of TemplateableElement::templateBinding.
--
-- The optional bindings from this element to templates.
overriding function Get_Is_Leaf
(Self : not null access constant UML_Component_Proxy)
return Boolean;
-- Getter of RedefinableElement::isLeaf.
--
-- Indicates whether it is possible to further redefine a
-- RedefinableElement. If the value is true, then it is not possible to
-- further redefine the RedefinableElement. Note that this property is
-- preserved through package merge operations; that is, the capability to
-- redefine a RedefinableElement (i.e., isLeaf=false) must be preserved in
-- the resulting RedefinableElement of a package merge operation where a
-- RedefinableElement with isLeaf=false is merged with a matching
-- RedefinableElement with isLeaf=true: the resulting RedefinableElement
-- will have isLeaf=false. Default value is false.
overriding procedure Set_Is_Leaf
(Self : not null access UML_Component_Proxy;
To : Boolean);
-- Setter of RedefinableElement::isLeaf.
--
-- Indicates whether it is possible to further redefine a
-- RedefinableElement. If the value is true, then it is not possible to
-- further redefine the RedefinableElement. Note that this property is
-- preserved through package merge operations; that is, the capability to
-- redefine a RedefinableElement (i.e., isLeaf=false) must be preserved in
-- the resulting RedefinableElement of a package merge operation where a
-- RedefinableElement with isLeaf=false is merged with a matching
-- RedefinableElement with isLeaf=true: the resulting RedefinableElement
-- will have isLeaf=false. Default value is false.
overriding function Get_Redefined_Element
(Self : not null access constant UML_Component_Proxy)
return AMF.UML.Redefinable_Elements.Collections.Set_Of_UML_Redefinable_Element;
-- Getter of RedefinableElement::redefinedElement.
--
-- The redefinable element that is being redefined by this element.
overriding function Get_Redefinition_Context
(Self : not null access constant UML_Component_Proxy)
return AMF.UML.Classifiers.Collections.Set_Of_UML_Classifier;
-- Getter of RedefinableElement::redefinitionContext.
--
-- References the contexts that this element may be redefined from.
overriding function Get_Owned_Port
(Self : not null access constant UML_Component_Proxy)
return AMF.UML.Ports.Collections.Set_Of_UML_Port;
-- Getter of EncapsulatedClassifier::ownedPort.
--
-- References a set of ports that an encapsulated classifier owns.
overriding function Get_Owned_Connector
(Self : not null access constant UML_Component_Proxy)
return AMF.UML.Connectors.Collections.Set_Of_UML_Connector;
-- Getter of StructuredClassifier::ownedConnector.
--
-- References the connectors owned by the classifier.
overriding function Get_Part
(Self : not null access constant UML_Component_Proxy)
return AMF.UML.Properties.Collections.Set_Of_UML_Property;
-- Getter of StructuredClassifier::part.
--
-- References the properties specifying instances that the classifier owns
-- by composition. This association is derived, selecting those owned
-- properties where isComposite is true.
overriding function Get_Role
(Self : not null access constant UML_Component_Proxy)
return AMF.UML.Connectable_Elements.Collections.Set_Of_UML_Connectable_Element;
-- Getter of StructuredClassifier::role.
--
-- References the roles that instances may play in this classifier.
overriding function Provided
(Self : not null access constant UML_Component_Proxy)
return AMF.UML.Interfaces.Collections.Set_Of_UML_Interface;
-- Operation Component::provided.
--
-- Missing derivation for Component::/provided : Interface
overriding function Realized_Interfaces
(Self : not null access constant UML_Component_Proxy;
Classifier : AMF.UML.Classifiers.UML_Classifier_Access)
return AMF.UML.Interfaces.Collections.Set_Of_UML_Interface;
-- Operation Component::realizedInterfaces.
--
-- Utility returning the set of realized interfaces of a component.
overriding function Required
(Self : not null access constant UML_Component_Proxy)
return AMF.UML.Interfaces.Collections.Set_Of_UML_Interface;
-- Operation Component::required.
--
-- Missing derivation for Component::/required : Interface
overriding function Used_Interfaces
(Self : not null access constant UML_Component_Proxy;
Classifier : AMF.UML.Classifiers.UML_Classifier_Access)
return AMF.UML.Interfaces.Collections.Set_Of_UML_Interface;
-- Operation Component::usedInterfaces.
--
-- Utility returning the set of used interfaces of a component.
overriding function Extension
(Self : not null access constant UML_Component_Proxy)
return AMF.UML.Extensions.Collections.Set_Of_UML_Extension;
-- Operation Class::extension.
--
-- Missing derivation for Class::/extension : Extension
overriding function Inherit
(Self : not null access constant UML_Component_Proxy;
Inhs : AMF.UML.Named_Elements.Collections.Set_Of_UML_Named_Element)
return AMF.UML.Named_Elements.Collections.Set_Of_UML_Named_Element;
-- Operation Class::inherit.
--
-- The inherit operation is overridden to exclude redefined properties.
overriding function Super_Class
(Self : not null access constant UML_Component_Proxy)
return AMF.UML.Classes.Collections.Set_Of_UML_Class;
-- Operation Class::superClass.
--
-- Missing derivation for Class::/superClass : Class
overriding function All_Features
(Self : not null access constant UML_Component_Proxy)
return AMF.UML.Features.Collections.Set_Of_UML_Feature;
-- Operation Classifier::allFeatures.
--
-- The query allFeatures() gives all of the features in the namespace of
-- the classifier. In general, through mechanisms such as inheritance,
-- this will be a larger set than feature.
overriding function Conforms_To
(Self : not null access constant UML_Component_Proxy;
Other : AMF.UML.Classifiers.UML_Classifier_Access)
return Boolean;
-- Operation Classifier::conformsTo.
--
-- The query conformsTo() gives true for a classifier that defines a type
-- that conforms to another. This is used, for example, in the
-- specification of signature conformance for operations.
overriding function General
(Self : not null access constant UML_Component_Proxy)
return AMF.UML.Classifiers.Collections.Set_Of_UML_Classifier;
-- Operation Classifier::general.
--
-- The general classifiers are the classifiers referenced by the
-- generalization relationships.
overriding function Has_Visibility_Of
(Self : not null access constant UML_Component_Proxy;
N : AMF.UML.Named_Elements.UML_Named_Element_Access)
return Boolean;
-- Operation Classifier::hasVisibilityOf.
--
-- The query hasVisibilityOf() determines whether a named element is
-- visible in the classifier. By default all are visible. It is only
-- called when the argument is something owned by a parent.
overriding function Inheritable_Members
(Self : not null access constant UML_Component_Proxy;
C : AMF.UML.Classifiers.UML_Classifier_Access)
return AMF.UML.Named_Elements.Collections.Set_Of_UML_Named_Element;
-- Operation Classifier::inheritableMembers.
--
-- The query inheritableMembers() gives all of the members of a classifier
-- that may be inherited in one of its descendants, subject to whatever
-- visibility restrictions apply.
overriding function Inherited_Member
(Self : not null access constant UML_Component_Proxy)
return AMF.UML.Named_Elements.Collections.Set_Of_UML_Named_Element;
-- Operation Classifier::inheritedMember.
--
-- The inheritedMember association is derived by inheriting the
-- inheritable members of the parents.
-- The inheritedMember association is derived by inheriting the
-- inheritable members of the parents.
overriding function Is_Template
(Self : not null access constant UML_Component_Proxy)
return Boolean;
-- Operation Classifier::isTemplate.
--
-- The query isTemplate() returns whether this templateable element is
-- actually a template.
overriding function May_Specialize_Type
(Self : not null access constant UML_Component_Proxy;
C : AMF.UML.Classifiers.UML_Classifier_Access)
return Boolean;
-- Operation Classifier::maySpecializeType.
--
-- The query maySpecializeType() determines whether this classifier may
-- have a generalization relationship to classifiers of the specified
-- type. By default a classifier may specialize classifiers of the same or
-- a more general type. It is intended to be redefined by classifiers that
-- have different specialization constraints.
overriding function Exclude_Collisions
(Self : not null access constant UML_Component_Proxy;
Imps : AMF.UML.Packageable_Elements.Collections.Set_Of_UML_Packageable_Element)
return AMF.UML.Packageable_Elements.Collections.Set_Of_UML_Packageable_Element;
-- Operation Namespace::excludeCollisions.
--
-- The query excludeCollisions() excludes from a set of
-- PackageableElements any that would not be distinguishable from each
-- other in this namespace.
overriding function Get_Names_Of_Member
(Self : not null access constant UML_Component_Proxy;
Element : AMF.UML.Named_Elements.UML_Named_Element_Access)
return AMF.String_Collections.Set_Of_String;
-- Operation Namespace::getNamesOfMember.
--
-- The query getNamesOfMember() takes importing into account. It gives
-- back the set of names that an element would have in an importing
-- namespace, either because it is owned, or if not owned then imported
-- individually, or if not individually then from a package.
-- The query getNamesOfMember() gives a set of all of the names that a
-- member would have in a Namespace. In general a member can have multiple
-- names in a Namespace if it is imported more than once with different
-- aliases. The query takes account of importing. It gives back the set of
-- names that an element would have in an importing namespace, either
-- because it is owned, or if not owned then imported individually, or if
-- not individually then from a package.
overriding function Import_Members
(Self : not null access constant UML_Component_Proxy;
Imps : AMF.UML.Packageable_Elements.Collections.Set_Of_UML_Packageable_Element)
return AMF.UML.Packageable_Elements.Collections.Set_Of_UML_Packageable_Element;
-- Operation Namespace::importMembers.
--
-- The query importMembers() defines which of a set of PackageableElements
-- are actually imported into the namespace. This excludes hidden ones,
-- i.e., those which have names that conflict with names of owned members,
-- and also excludes elements which would have the same name when imported.
overriding function Imported_Member
(Self : not null access constant UML_Component_Proxy)
return AMF.UML.Packageable_Elements.Collections.Set_Of_UML_Packageable_Element;
-- Operation Namespace::importedMember.
--
-- The importedMember property is derived from the ElementImports and the
-- PackageImports. References the PackageableElements that are members of
-- this Namespace as a result of either PackageImports or ElementImports.
overriding function Members_Are_Distinguishable
(Self : not null access constant UML_Component_Proxy)
return Boolean;
-- Operation Namespace::membersAreDistinguishable.
--
-- The Boolean query membersAreDistinguishable() determines whether all of
-- the namespace's members are distinguishable within it.
overriding function Owned_Member
(Self : not null access constant UML_Component_Proxy)
return AMF.UML.Named_Elements.Collections.Set_Of_UML_Named_Element;
-- Operation Namespace::ownedMember.
--
-- Missing derivation for Namespace::/ownedMember : NamedElement
overriding function All_Owning_Packages
(Self : not null access constant UML_Component_Proxy)
return AMF.UML.Packages.Collections.Set_Of_UML_Package;
-- Operation NamedElement::allOwningPackages.
--
-- The query allOwningPackages() returns all the directly or indirectly
-- owning packages.
overriding function Is_Distinguishable_From
(Self : not null access constant UML_Component_Proxy;
N : AMF.UML.Named_Elements.UML_Named_Element_Access;
Ns : AMF.UML.Namespaces.UML_Namespace_Access)
return Boolean;
-- Operation NamedElement::isDistinguishableFrom.
--
-- The query isDistinguishableFrom() determines whether two NamedElements
-- may logically co-exist within a Namespace. By default, two named
-- elements are distinguishable if (a) they have unrelated types or (b)
-- they have related types but different names.
overriding function Namespace
(Self : not null access constant UML_Component_Proxy)
return AMF.UML.Namespaces.UML_Namespace_Access;
-- Operation NamedElement::namespace.
--
-- Missing derivation for NamedElement::/namespace : Namespace
overriding function Conforms_To
(Self : not null access constant UML_Component_Proxy;
Other : AMF.UML.Types.UML_Type_Access)
return Boolean;
-- Operation Type::conformsTo.
--
-- The query conformsTo() gives true for a type that conforms to another.
-- By default, two types do not conform to each other. This query is
-- intended to be redefined for specific conformance situations.
overriding function Is_Compatible_With
(Self : not null access constant UML_Component_Proxy;
P : AMF.UML.Parameterable_Elements.UML_Parameterable_Element_Access)
return Boolean;
-- Operation ParameterableElement::isCompatibleWith.
--
-- The query isCompatibleWith() determines if this parameterable element
-- is compatible with the specified parameterable element. By default
-- parameterable element P is compatible with parameterable element Q if
-- the kind of P is the same or a subtype as the kind of Q. Subclasses
-- should override this operation to specify different compatibility
-- constraints.
overriding function Is_Template_Parameter
(Self : not null access constant UML_Component_Proxy)
return Boolean;
-- Operation ParameterableElement::isTemplateParameter.
--
-- The query isTemplateParameter() determines if this parameterable
-- element is exposed as a formal template parameter.
overriding function Parameterable_Elements
(Self : not null access constant UML_Component_Proxy)
return AMF.UML.Parameterable_Elements.Collections.Set_Of_UML_Parameterable_Element;
-- Operation TemplateableElement::parameterableElements.
--
-- The query parameterableElements() returns the set of elements that may
-- be used as the parametered elements for a template parameter of this
-- templateable element. By default, this set includes all the owned
-- elements. Subclasses may override this operation if they choose to
-- restrict the set of parameterable elements.
overriding function Is_Consistent_With
(Self : not null access constant UML_Component_Proxy;
Redefinee : AMF.UML.Redefinable_Elements.UML_Redefinable_Element_Access)
return Boolean;
-- Operation RedefinableElement::isConsistentWith.
--
-- The query isConsistentWith() specifies, for any two RedefinableElements
-- in a context in which redefinition is possible, whether redefinition
-- would be logically consistent. By default, this is false; this
-- operation must be overridden for subclasses of RedefinableElement to
-- define the consistency conditions.
overriding function Is_Redefinition_Context_Valid
(Self : not null access constant UML_Component_Proxy;
Redefined : AMF.UML.Redefinable_Elements.UML_Redefinable_Element_Access)
return Boolean;
-- Operation RedefinableElement::isRedefinitionContextValid.
--
-- The query isRedefinitionContextValid() specifies whether the
-- redefinition contexts of this RedefinableElement are properly related
-- to the redefinition contexts of the specified RedefinableElement to
-- allow this element to redefine the other. By default at least one of
-- the redefinition contexts of this element must be a specialization of
-- at least one of the redefinition contexts of the specified element.
overriding function Owned_Port
(Self : not null access constant UML_Component_Proxy)
return AMF.UML.Ports.Collections.Set_Of_UML_Port;
-- Operation EncapsulatedClassifier::ownedPort.
--
-- Missing derivation for EncapsulatedClassifier::/ownedPort : Port
overriding function Part
(Self : not null access constant UML_Component_Proxy)
return AMF.UML.Properties.Collections.Set_Of_UML_Property;
-- Operation StructuredClassifier::part.
--
-- Missing derivation for StructuredClassifier::/part : Property
overriding procedure Enter_Element
(Self : not null access constant UML_Component_Proxy;
Visitor : in out AMF.Visitors.Abstract_Visitor'Class;
Control : in out AMF.Visitors.Traverse_Control);
-- Dispatch call to corresponding subprogram of visitor interface.
overriding procedure Leave_Element
(Self : not null access constant UML_Component_Proxy;
Visitor : in out AMF.Visitors.Abstract_Visitor'Class;
Control : in out AMF.Visitors.Traverse_Control);
-- Dispatch call to corresponding subprogram of visitor interface.
overriding procedure Visit_Element
(Self : not null access constant UML_Component_Proxy;
Iterator : in out AMF.Visitors.Abstract_Iterator'Class;
Visitor : in out AMF.Visitors.Abstract_Visitor'Class;
Control : in out AMF.Visitors.Traverse_Control);
-- Dispatch call to corresponding subprogram of iterator interface.
end AMF.Internals.UML_Components;
|
reznikmm/matreshka | Ada | 3,714 | 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.Table_Cell_Range_Source_Elements is
pragma Preelaborate;
type ODF_Table_Cell_Range_Source is limited interface
and XML.DOM.Elements.DOM_Element;
type ODF_Table_Cell_Range_Source_Access is
access all ODF_Table_Cell_Range_Source'Class
with Storage_Size => 0;
end ODF.DOM.Table_Cell_Range_Source_Elements;
|
AdaCore/gpr | Ada | 24 | ads | Package Dep is
end Dep;
|
reznikmm/matreshka | Ada | 3,612 | ads | ------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- Web Framework --
-- --
-- Testsuite 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$
------------------------------------------------------------------------------
-- Root package of automated test based on 'SOAP Version 1.2 Specification
-- Assertions and Test Collection (Second Edition)' document.
------------------------------------------------------------------------------
package SOAPConf is
pragma Pure;
end SOAPConf;
|
AdaCore/Ada_Drivers_Library | Ada | 11,925 | 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.DCMI is
pragma Preelaborate;
---------------
-- Registers --
---------------
subtype CR_FCRC_Field is HAL.UInt2;
subtype CR_EDM_Field is HAL.UInt2;
-- control register 1
type CR_Register is record
-- Capture enable
CAPTURE : Boolean := False;
-- Capture mode
CM : Boolean := False;
-- Crop feature
CROP : Boolean := False;
-- JPEG format
JPEG : Boolean := False;
-- Embedded synchronization select
ESS : Boolean := False;
-- Pixel clock polarity
PCKPOL : Boolean := False;
-- Horizontal synchronization polarity
HSPOL : Boolean := False;
-- Vertical synchronization polarity
VSPOL : Boolean := False;
-- Frame capture rate control
FCRC : CR_FCRC_Field := 16#0#;
-- Extended data mode
EDM : CR_EDM_Field := 16#0#;
-- unspecified
Reserved_12_13 : HAL.UInt2 := 16#0#;
-- DCMI enable
ENABLE : Boolean := False;
-- unspecified
Reserved_15_31 : HAL.UInt17 := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for CR_Register use record
CAPTURE at 0 range 0 .. 0;
CM at 0 range 1 .. 1;
CROP at 0 range 2 .. 2;
JPEG at 0 range 3 .. 3;
ESS at 0 range 4 .. 4;
PCKPOL at 0 range 5 .. 5;
HSPOL at 0 range 6 .. 6;
VSPOL at 0 range 7 .. 7;
FCRC at 0 range 8 .. 9;
EDM at 0 range 10 .. 11;
Reserved_12_13 at 0 range 12 .. 13;
ENABLE at 0 range 14 .. 14;
Reserved_15_31 at 0 range 15 .. 31;
end record;
-- status register
type SR_Register is record
-- Read-only. HSYNC
HSYNC : Boolean;
-- Read-only. VSYNC
VSYNC : Boolean;
-- Read-only. FIFO not empty
FNE : Boolean;
-- unspecified
Reserved_3_31 : HAL.UInt29;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for SR_Register use record
HSYNC at 0 range 0 .. 0;
VSYNC at 0 range 1 .. 1;
FNE at 0 range 2 .. 2;
Reserved_3_31 at 0 range 3 .. 31;
end record;
-- raw interrupt status register
type RIS_Register is record
-- Read-only. Capture complete raw interrupt status
FRAME_RIS : Boolean;
-- Read-only. Overrun raw interrupt status
OVR_RIS : Boolean;
-- Read-only. Synchronization error raw interrupt status
ERR_RIS : Boolean;
-- Read-only. VSYNC raw interrupt status
VSYNC_RIS : Boolean;
-- Read-only. Line raw interrupt status
LINE_RIS : Boolean;
-- unspecified
Reserved_5_31 : HAL.UInt27;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for RIS_Register use record
FRAME_RIS at 0 range 0 .. 0;
OVR_RIS at 0 range 1 .. 1;
ERR_RIS at 0 range 2 .. 2;
VSYNC_RIS at 0 range 3 .. 3;
LINE_RIS at 0 range 4 .. 4;
Reserved_5_31 at 0 range 5 .. 31;
end record;
-- interrupt enable register
type IER_Register is record
-- Capture complete interrupt enable
FRAME_IE : Boolean := False;
-- Overrun interrupt enable
OVR_IE : Boolean := False;
-- Synchronization error interrupt enable
ERR_IE : Boolean := False;
-- VSYNC interrupt enable
VSYNC_IE : Boolean := False;
-- Line interrupt enable
LINE_IE : Boolean := False;
-- unspecified
Reserved_5_31 : HAL.UInt27 := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for IER_Register use record
FRAME_IE at 0 range 0 .. 0;
OVR_IE at 0 range 1 .. 1;
ERR_IE at 0 range 2 .. 2;
VSYNC_IE at 0 range 3 .. 3;
LINE_IE at 0 range 4 .. 4;
Reserved_5_31 at 0 range 5 .. 31;
end record;
-- masked interrupt status register
type MIS_Register is record
-- Read-only. Capture complete masked interrupt status
FRAME_MIS : Boolean;
-- Read-only. Overrun masked interrupt status
OVR_MIS : Boolean;
-- Read-only. Synchronization error masked interrupt status
ERR_MIS : Boolean;
-- Read-only. VSYNC masked interrupt status
VSYNC_MIS : Boolean;
-- Read-only. Line masked interrupt status
LINE_MIS : Boolean;
-- unspecified
Reserved_5_31 : HAL.UInt27;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for MIS_Register use record
FRAME_MIS at 0 range 0 .. 0;
OVR_MIS at 0 range 1 .. 1;
ERR_MIS at 0 range 2 .. 2;
VSYNC_MIS at 0 range 3 .. 3;
LINE_MIS at 0 range 4 .. 4;
Reserved_5_31 at 0 range 5 .. 31;
end record;
-- interrupt clear register
type ICR_Register is record
-- Write-only. Capture complete interrupt status clear
FRAME_ISC : Boolean := False;
-- Write-only. Overrun interrupt status clear
OVR_ISC : Boolean := False;
-- Write-only. Synchronization error interrupt status clear
ERR_ISC : Boolean := False;
-- Write-only. Vertical synch interrupt status clear
VSYNC_ISC : Boolean := False;
-- Write-only. line interrupt status clear
LINE_ISC : Boolean := False;
-- unspecified
Reserved_5_31 : HAL.UInt27 := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for ICR_Register use record
FRAME_ISC at 0 range 0 .. 0;
OVR_ISC at 0 range 1 .. 1;
ERR_ISC at 0 range 2 .. 2;
VSYNC_ISC at 0 range 3 .. 3;
LINE_ISC at 0 range 4 .. 4;
Reserved_5_31 at 0 range 5 .. 31;
end record;
subtype ESCR_FSC_Field is HAL.UInt8;
subtype ESCR_LSC_Field is HAL.UInt8;
subtype ESCR_LEC_Field is HAL.UInt8;
subtype ESCR_FEC_Field is HAL.UInt8;
-- embedded synchronization code register
type ESCR_Register is record
-- Frame start delimiter code
FSC : ESCR_FSC_Field := 16#0#;
-- Line start delimiter code
LSC : ESCR_LSC_Field := 16#0#;
-- Line end delimiter code
LEC : ESCR_LEC_Field := 16#0#;
-- Frame end delimiter code
FEC : ESCR_FEC_Field := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for ESCR_Register use record
FSC at 0 range 0 .. 7;
LSC at 0 range 8 .. 15;
LEC at 0 range 16 .. 23;
FEC at 0 range 24 .. 31;
end record;
subtype ESUR_FSU_Field is HAL.UInt8;
subtype ESUR_LSU_Field is HAL.UInt8;
subtype ESUR_LEU_Field is HAL.UInt8;
subtype ESUR_FEU_Field is HAL.UInt8;
-- embedded synchronization unmask register
type ESUR_Register is record
-- Frame start delimiter unmask
FSU : ESUR_FSU_Field := 16#0#;
-- Line start delimiter unmask
LSU : ESUR_LSU_Field := 16#0#;
-- Line end delimiter unmask
LEU : ESUR_LEU_Field := 16#0#;
-- Frame end delimiter unmask
FEU : ESUR_FEU_Field := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for ESUR_Register use record
FSU at 0 range 0 .. 7;
LSU at 0 range 8 .. 15;
LEU at 0 range 16 .. 23;
FEU at 0 range 24 .. 31;
end record;
subtype CWSTRT_HOFFCNT_Field is HAL.UInt14;
subtype CWSTRT_VST_Field is HAL.UInt13;
-- crop window start
type CWSTRT_Register is record
-- Horizontal offset count
HOFFCNT : CWSTRT_HOFFCNT_Field := 16#0#;
-- unspecified
Reserved_14_15 : HAL.UInt2 := 16#0#;
-- Vertical start line count
VST : CWSTRT_VST_Field := 16#0#;
-- unspecified
Reserved_29_31 : HAL.UInt3 := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for CWSTRT_Register use record
HOFFCNT at 0 range 0 .. 13;
Reserved_14_15 at 0 range 14 .. 15;
VST at 0 range 16 .. 28;
Reserved_29_31 at 0 range 29 .. 31;
end record;
subtype CWSIZE_CAPCNT_Field is HAL.UInt14;
subtype CWSIZE_VLINE_Field is HAL.UInt14;
-- crop window size
type CWSIZE_Register is record
-- Capture count
CAPCNT : CWSIZE_CAPCNT_Field := 16#0#;
-- unspecified
Reserved_14_15 : HAL.UInt2 := 16#0#;
-- Vertical line count
VLINE : CWSIZE_VLINE_Field := 16#0#;
-- unspecified
Reserved_30_31 : HAL.UInt2 := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for CWSIZE_Register use record
CAPCNT at 0 range 0 .. 13;
Reserved_14_15 at 0 range 14 .. 15;
VLINE at 0 range 16 .. 29;
Reserved_30_31 at 0 range 30 .. 31;
end record;
-- DR_Byte array element
subtype DR_Byte_Element is HAL.UInt8;
-- DR_Byte array
type DR_Byte_Field_Array is array (0 .. 3) of DR_Byte_Element
with Component_Size => 8, Size => 32;
-- data register
type DR_Register
(As_Array : Boolean := False)
is record
case As_Array is
when False =>
-- Byte as a value
Val : HAL.UInt32;
when True =>
-- Byte as an array
Arr : DR_Byte_Field_Array;
end case;
end record
with Unchecked_Union, Size => 32, Volatile_Full_Access,
Bit_Order => System.Low_Order_First;
for DR_Register use record
Val at 0 range 0 .. 31;
Arr at 0 range 0 .. 31;
end record;
-----------------
-- Peripherals --
-----------------
-- Digital camera interface
type DCMI_Peripheral is record
-- control register 1
CR : aliased CR_Register;
-- status register
SR : aliased SR_Register;
-- raw interrupt status register
RIS : aliased RIS_Register;
-- interrupt enable register
IER : aliased IER_Register;
-- masked interrupt status register
MIS : aliased MIS_Register;
-- interrupt clear register
ICR : aliased ICR_Register;
-- embedded synchronization code register
ESCR : aliased ESCR_Register;
-- embedded synchronization unmask register
ESUR : aliased ESUR_Register;
-- crop window start
CWSTRT : aliased CWSTRT_Register;
-- crop window size
CWSIZE : aliased CWSIZE_Register;
-- data register
DR : aliased DR_Register;
end record
with Volatile;
for DCMI_Peripheral use record
CR at 16#0# range 0 .. 31;
SR at 16#4# range 0 .. 31;
RIS at 16#8# range 0 .. 31;
IER at 16#C# range 0 .. 31;
MIS at 16#10# range 0 .. 31;
ICR at 16#14# range 0 .. 31;
ESCR at 16#18# range 0 .. 31;
ESUR at 16#1C# range 0 .. 31;
CWSTRT at 16#20# range 0 .. 31;
CWSIZE at 16#24# range 0 .. 31;
DR at 16#28# range 0 .. 31;
end record;
-- Digital camera interface
DCMI_Periph : aliased DCMI_Peripheral
with Import, Address => System'To_Address (16#50050000#);
end STM32_SVD.DCMI;
|
zhmu/ananas | Ada | 3,373 | adb | ------------------------------------------------------------------------------
-- --
-- GNAT COMPILER COMPONENTS --
-- --
-- S Y S T E M . T A S K _ I N F O --
-- --
-- B o d y --
-- --
-- Copyright (C) 2007-2022, Free Software Foundation, Inc. --
-- --
-- GNAT is free software; you can redistribute it and/or modify it under --
-- terms of the GNU General Public License as published by the Free Soft- --
-- ware Foundation; either version 3, or (at your option) any later ver- --
-- sion. GNAT is distributed in the hope that it will be useful, but WITH- --
-- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY --
-- or FITNESS FOR A PARTICULAR PURPOSE. --
-- --
-- As a special exception under Section 7 of GPL version 3, you are granted --
-- additional permissions described in the GCC Runtime Library Exception, --
-- version 3.1, as published by the Free Software Foundation. --
-- --
-- You should have received a copy of the GNU General Public License and --
-- a copy of the GCC Runtime Library Exception along with this program; --
-- see the files COPYING3 and COPYING.RUNTIME respectively. If not, see --
-- <http://www.gnu.org/licenses/>. --
-- --
-- GNAT was originally developed by the GNAT team at New York University. --
-- Extensive contributions were provided by Ada Core Technologies Inc. --
-- --
------------------------------------------------------------------------------
-- This is the Windows (native) version of this module
with System.OS_Interface;
pragma Unreferenced (System.OS_Interface);
-- System.OS_Interface is not used today, but the protocol between the
-- run-time and the binder is that any tasking application uses
-- System.OS_Interface, so notify the binder with this "with" clause.
package body System.Task_Info is
N_CPU : Natural := 0;
pragma Atomic (N_CPU);
-- Cache CPU number. Use pragma Atomic to avoid a race condition when
-- setting N_CPU in Number_Of_Processors below.
--------------------------
-- Number_Of_Processors --
--------------------------
function Number_Of_Processors return Positive is
begin
if N_CPU = 0 then
declare
SI : aliased Win32.SYSTEM_INFO;
begin
Win32.GetSystemInfo (SI'Access);
N_CPU := Positive (SI.dwNumberOfProcessors);
end;
end if;
return N_CPU;
end Number_Of_Processors;
end System.Task_Info;
|
reznikmm/matreshka | Ada | 7,395 | adb | ------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- Web Framework --
-- --
-- Runtime Library Component --
-- --
------------------------------------------------------------------------------
-- --
-- Copyright © 2015, Vadim Godunko <[email protected]> --
-- All rights reserved. --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions --
-- are met: --
-- --
-- * Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- --
-- * Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in the --
-- documentation and/or other materials provided with the distribution. --
-- --
-- * Neither the name of the Vadim Godunko, IE nor the names of its --
-- contributors may be used to endorse or promote products derived from --
-- this software without specific prior written permission. --
-- --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR --
-- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
-- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED --
-- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR --
-- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF --
-- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING --
-- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS --
-- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
-- --
------------------------------------------------------------------------------
-- $Revision$ $Date$
------------------------------------------------------------------------------
with Ada.Unchecked_Deallocation;
package body Core.Objects is
-------------
-- Connect --
-------------
procedure Connect (Self : not null access Listener_Record'Class) is
begin
-- Append to list of listener records of collection.
if Self.Registry.Head = null then
Self.Registry.Head := Listener_Record_Access (Self);
Self.Registry.Tail := Listener_Record_Access (Self);
Self.Registry_Previous := null;
Self.Registry_Next := null;
else
Self.Registry_Previous := Self.Registry.Tail;
Self.Registry_Next := null;
Self.Registry.Tail.Registry_Next := Listener_Record_Access (Self);
Self.Registry.Tail := Listener_Record_Access (Self);
end if;
-- Append to list of listener records of object.
if Self.Object.Listener_Head = null then
Self.Object.Listener_Head := Listener_Record_Access (Self);
Self.Object.Listener_Tail := Listener_Record_Access (Self);
Self.Object_Previous := null;
Self.Object_Next := null;
else
Self.Object_Previous := Self.Object.Listener_Tail;
Self.Object_Next := null;
Self.Object.Listener_Tail.Object_Next :=
Listener_Record_Access (Self);
Self.Object.Listener_Tail := Listener_Record_Access (Self);
end if;
end Connect;
------------
-- Delete --
------------
procedure Delete (Item : not null Listener_Record_Access) is
procedure Free is
new Ada.Unchecked_Deallocation
(Listener_Record'Class, Listener_Record_Access);
Aux : Listener_Record_Access := Item;
begin
Aux.Disconnect;
Free (Aux);
end Delete;
----------------
-- Disconnect --
----------------
procedure Disconnect (Self : not null access Listener_Record'Class) is
Previous : Listener_Record_Access;
Next : Listener_Record_Access;
begin
-- Remove from list of listener records of collection.
Previous := Self.Registry_Previous;
Next := Self.Registry_Next;
Self.Registry_Previous := null;
Self.Registry_Next := null;
if Previous /= null then
Previous.Registry_Next := Next;
end if;
if Next /= null then
Next.Registry_Previous := Previous;
end if;
if Self.Registry.Head = Self then
Self.Registry.Head := Next;
end if;
if Self.Registry.Tail = Self then
Self.Registry.Tail := Previous;
end if;
-- Remove from list of listener records of object.
Previous := Self.Object_Previous;
Next := Self.Object_Next;
Self.Object_Previous := null;
Self.Object_Next := null;
if Previous /= null then
Previous.Object_Next := Next;
end if;
if Next /= null then
Next.Object_Previous := Previous;
end if;
if Self.Object.Listener_Head = Self then
Self.Object.Listener_Head := Next;
end if;
if Self.Object.Listener_Tail = Self then
Self.Object.Listener_Tail := Previous;
end if;
end Disconnect;
--------------
-- Finalize --
--------------
not overriding procedure Finalize (Self : in out Listener_Registry) is
begin
while Self.Head /= null loop
Delete (Self.Head);
-- Call of Delete will remove first element from this list, thus Head
-- will point to next listener record (of any).
end loop;
end Finalize;
--------------
-- Finalize --
--------------
not overriding procedure Finalize (Self : in out Abstract_Object) is
begin
while Self.Listener_Head /= null loop
Delete (Self.Listener_Head);
-- Call of Delete will remove first element from this list, thus Head
-- will point to next listener record (of any).
end loop;
end Finalize;
end Core.Objects;
|
reznikmm/matreshka | Ada | 4,639 | 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.Sort_Ascending_Attributes is
------------
-- Create --
------------
overriding function Create
(Parameters : not null access Matreshka.DOM_Attributes.Attribute_L2_Parameters)
return Text_Sort_Ascending_Attribute_Node is
begin
return Self : Text_Sort_Ascending_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_Sort_Ascending_Attribute_Node)
return League.Strings.Universal_String
is
pragma Unreferenced (Self);
begin
return Matreshka.ODF_String_Constants.Sort_Ascending_Attribute;
end Get_Local_Name;
begin
Matreshka.DOM_Documents.Register_Attribute
(Matreshka.ODF_String_Constants.Text_URI,
Matreshka.ODF_String_Constants.Sort_Ascending_Attribute,
Text_Sort_Ascending_Attribute_Node'Tag);
end Matreshka.ODF_Text.Sort_Ascending_Attributes;
|
hbarrientosg/cs-mp | Ada | 594 | adb | separate(practica_3)
--Esta es la funcion que suma los elementos de la columna de una matriz y los guarda en un vector
function Suma_Filas(M:Matriz) return Vector is
v:vector(M'range(2));
begin
for i in M'Range(2) loop
v(I):=m(1,i);--en el vector guardo el primer elemento de la columna la matriz
for j in 2..M'last loop
v(I):=v(I)+ M(J,I);-- le sumo al vector el resto de los elemento de la columna
end loop;
end loop;
return v;
exception
when Constraint_error =>
raise Error_Suma; --lanza error suma si existe un overflow en la suma ya que se sale del rango del tipo
end suma_filas;
|
AdaDoom3/wayland_ada_binding | Ada | 61,981 | ads | package Aida with Pure is
pragma SPARK_Mode;
subtype Int32_T is Standard.Integer range -2**31 .. (2**31 - 1);
subtype Pos32_T is Int32_T range 1 .. Int32_T'Last;
subtype Nat32_T is Int32_T range 0 .. Int32_T'Last;
type Hash32_T is mod 2**32;
package Character is
function Is_Digit (C : Standard.Character) return Boolean with
Contract_Cases => (C = '0' => Is_Digit'Result,
C = '1' => Is_Digit'Result,
C = '2' => Is_Digit'Result,
C = '3' => Is_Digit'Result,
C = '4' => Is_Digit'Result,
C = '5' => Is_Digit'Result,
C = '6' => Is_Digit'Result,
C = '7' => Is_Digit'Result,
C = '8' => Is_Digit'Result,
C = '9' => Is_Digit'Result,
C > '9' => Is_Digit'Result = False,
C < '0' => Is_Digit'Result = False);
function To_Int32 (Source : in Standard.Character) return Int32_T with
Pre => Is_Digit (Source),
Post => To_Int32'Result in 0..9,
Contract_Cases => (Source = '0' => To_Int32'Result = 0,
Source = '1' => To_Int32'Result = 1,
Source = '2' => To_Int32'Result = 2,
Source = '3' => To_Int32'Result = 3,
Source = '4' => To_Int32'Result = 4,
Source = '5' => To_Int32'Result = 5,
Source = '6' => To_Int32'Result = 6,
Source = '7' => To_Int32'Result = 7,
Source = '8' => To_Int32'Result = 8,
Source = '9' => To_Int32'Result = 9);
procedure To_Int32 (Source : in Standard.Character;
Target : out Int32_T) with
Pre => Is_Digit (Source),
Post => Target in 0 .. 9 and Target = To_Int32 (Source),
Contract_Cases => (Source = '0' => Target = 0,
Source = '1' => Target = 1,
Source = '2' => Target = 2,
Source = '3' => Target = 3,
Source = '4' => Target = 4,
Source = '5' => Target = 5,
Source = '6' => Target = 6,
Source = '7' => Target = 7,
Source = '8' => Target = 8,
Source = '9' => Target = 9);
function Is_One_Byte_UTF8 (C : Standard.Character) return Boolean is (Standard.Character'Pos (Standard.Character (C)) <= 127);
-- A UTF8 code point can be represented by 1-4 characters. The first 128 characters (US-ASCII) need only one byte.
end Character;
package Hash32 is
function Hash32 (This : Int32_T) return Hash32_T with
Global => null;
function Hash32 (This : Standard.String) return Hash32_T with
Global => null;
end Hash32;
package Int32 is
function To_String (This : Int32_T) return Standard.String with
Global => null,
Post => (if This < 0 then
To_String'Result'Length >= 2 and To_String'Result'Length <= 11 else
To_String'Result'Length >= 1 and To_String'Result'Length <= 10);
function To_Char (This : Int32_T) return Standard.Character with
Global => null,
Pre => This >= 0 and This <= 9;
-- Calculates the hash of an 32-bit Int32_T based upon the following post
-- on Stackoverlow:
-- http://stackoverflow.com/questions/664014/what-Int32_T-hash-function-are-good-that-accepts-an-Int32_T-hash-key
--
-- I found the following algorithm provides a very good statistical distribution.
-- Each input bit affects each output bit with about 50% probability.
-- There are no collisions (each input results in a different output).
-- The algorithm is fast except if the CPU doesn't have a
-- built-in Int32_T multiplication unit. C-Code:
--
-- unsigned int hash(unsigned int x) {
-- x = ((x >> 16) ^ x) * 0x45d9f3b;
-- x = ((x >> 16) ^ x) * 0x45d9f3b;
-- x = (x >> 16) ^ x;
-- return x;
-- }
--
-- The magic number was calculated using a special multi-threaded
-- test program that ran for many hours, which calculates the avalanche effect
-- (the number of output bits that change if a single input bit is changed;
-- should be nearly 16 on average), independence of output bit changes
-- (output bits should not depend on each other), and the probability of a change
-- in each output bit if any input bit is changed. The calculated values are better
-- than the 32-bit finalizer used by MurmurHash, and nearly as good (not quite) as when using AES.
function Hash32 (This : Int32_T) return Hash32_T with
Global => null;
end Int32;
package Float is
function To_String (This : Standard.Float) return Standard.String with
Global => null,
Post => To_String'Result'Length >= 1 and To_String'Result'Length <= 11;
end Float;
package String is
function I (Source : Standard.String;
Index : Nat32_T) return Int32_T is (Aida.Character.To_Int32 (Source (Source'First + Index))) with
Pre => Index < Source'Length and then Source'First + Index <= Source'Last and then Aida.Character.Is_Digit (Source (Source'First + Index));
procedure To_Int32 (Source : in Standard.String;
Target : out Int32_T;
Has_Failed : out Boolean) with
Global => null,
Contract_Cases => (Source'Length = 0 => Has_Failed,
Source'Length = 1 => (if Source(Source'First) = '-' then
Has_Failed
elsif Aida.Character.Is_Digit (Source (Source'First)) then
(Has_Failed = False and Target = I (Source, 0))
else
Has_Failed),
Source'Length = 2 => (if (for all Index in Source'Range => Aida.Character.Is_Digit (Source (Index))) then
(Has_Failed = False and
Target = 10*I (Source, 0) + I (Source, 1))
elsif ((Source (Source'First) = '-') and (for all Index in Int32_T range (Source'First + 1) .. Source'Last => Aida.Character.Is_Digit (Source (Index)))) then
(Has_Failed = False and Target = -I (Source, 1))
else
Has_Failed),
Source'Length = 3 => (if (for all Index in Source'Range => Aida.Character.Is_Digit (Source (Index))) then
(Has_Failed = False and
Target = 100*I (Source, 0) + 10*I (Source, 1) + I (Source, 2))
elsif ((Source (Source'First) = '-') and (for all Index in Int32_T range (Source'First + 1) .. Source'Last => Aida.Character.Is_Digit (Source (Index)))) then
(Has_Failed = False and Target = -10*I (Source, 1) - I (Source, 2))
else
Has_Failed),
Source'Length = 4 => (if (for all Index in Source'Range => Aida.Character.Is_Digit (Source (Index))) then
(Has_Failed = False and
Target = 1_000*I (Source, 0) + 100*I (Source, 1) + 10*I (Source, 2) + I (Source, 3))
elsif ((Source (Source'First) = '-') and (for all Index in Int32_T range (Source'First + 1) .. Source'Last => Aida.Character.Is_Digit (Source (Index)))) then
(Has_Failed = False and Target = -100*I (Source, 1) - 10*I (Source, 2) - I (Source, 3))
else
Has_Failed),
Source'Length = 5 => (if (for all Index in Source'Range => Aida.Character.Is_Digit (Source (Index))) then
(Has_Failed = False and
Target = 10_000*I (Source, 0) + 1_000*I (Source, 1) + 100*I (Source, 2) + 10*I (Source, 3) + I (Source, 4))
elsif ((Source (Source'First) = '-') and (for all Index in Int32_T range (Source'First + 1) .. Source'Last => Aida.Character.Is_Digit (Source (Index)))) then
(Has_Failed = False and Target = -1_000*I (Source, 1) - 100*I (Source, 2) - 10*I (Source, 3) - I (Source, 4))
else
Has_Failed),
Source'Length = 6 => (if (for all Index in Source'Range => Aida.Character.Is_Digit (Source (Index))) then
(Has_Failed = False and
Target = 100_000*I (Source, 0) + 10_000*I (Source, 1) + 1_000*I (Source, 2) + 100*I (Source, 3) + 10*I (Source, 4) + I (Source, 5))
elsif ((Source (Source'First) = '-') and (for all Index in Int32_T range (Source'First + 1) .. Source'Last => Aida.Character.Is_Digit (Source (Index)))) then
(Has_Failed = False and Target = -10_000*I (Source, 1) - 1_000*I (Source, 2) - 100*I (Source, 3) - 10*I (Source, 4) - I (Source, 5))
else
Has_Failed),
Source'Length = 7 => (if (for all Index in Source'Range => Aida.Character.Is_Digit (Source (Index))) then
(Has_Failed = False and
Target = 1_000_000*I (Source, 0) + 100_000*I (Source, 1) + 10_000*I (Source, 2) + 1_000*I (Source, 3) + 100*I (Source, 4) + 10*I (Source, 5) + I (Source, 6))
elsif ((Source (Source'First) = '-') and (for all Index in Int32_T range (Source'First + 1) .. Source'Last => Aida.Character.Is_Digit (Source (Index)))) then
(Has_Failed = False and Target = -100_000*I (Source, 1) - 10_000*I (Source, 2) - 1_000*I (Source, 3) - 100*I (Source, 4) - 10*I (Source, 5) - I (Source, 6))
else
Has_Failed),
Source'Length = 8 => (if (for all Index in Source'Range => Aida.Character.Is_Digit (Source (Index))) then
(Has_Failed = False and
Target = 10_000_000*I (Source, 0) + 1_000_000*I (Source, 1) + 100_000*I (Source, 2) + 10_000*I (Source, 3) + 1_000*I (Source, 4) + 100*I (Source, 5) + 10*I (Source, 6) + I (Source, 7))
elsif ((Source (Source'First) = '-') and (for all Index in Int32_T range (Source'First + 1) .. Source'Last => Aida.Character.Is_Digit (Source (Index)))) then
(Has_Failed = False and Target = -1_000_000*I (Source, 1) - 100_000*I (Source, 2) - 10_000*I (Source, 3) - 1_000*I (Source, 4) - 100*I (Source, 5) - 10*I (Source, 6) - I (Source, 7))
else
Has_Failed),
Source'Length = 9 => (if (for all Index in Source'Range => Aida.Character.Is_Digit (Source (Index))) then
(Has_Failed = False and
Target = 100_000_000*I (Source, 0) + 10_000_000*I (Source, 1) + 1_000_000*I (Source, 2) + 100_000*I (Source, 3) + 10_000*I (Source, 4) + 1_000*I (Source, 5) + 100*I (Source, 6) + 10*I (Source, 7) + I (Source, 8))
elsif ((Source (Source'First) = '-') and (for all Index in Int32_T range (Source'First + 1) .. Source'Last => Aida.Character.Is_Digit (Source (Index)))) then
(Has_Failed = False and Target = -10_000_000*I (Source, 1) - 1_000_000*I (Source, 2) - 100_000*I (Source, 3) - 10_000*I (Source, 4) - 1_000*I (Source, 5) - 100*I (Source, 6) - 10*I (Source, 7) - I (Source, 8))
else
Has_Failed),
Source'Length = 10 => (if (for all Index in Source'Range => Aida.Character.Is_Digit (Source (Index))) then
(if (Source(Source'First + 0) = '2' and
Source(Source'First + 1) = '1' and
Source(Source'First + 2) = '4' and
Source(Source'First + 3) = '7' and
Source(Source'First + 4) = '4' and
Source(Source'First + 5) = '8' and
Source(Source'First + 6) = '3' and
Source(Source'First + 7) = '6' and
Source(Source'First + 8) = '4' and
Source(Source'First + 9) < '8') then
(Has_Failed = False and
Target = 2_147_483_640 + I (Source, 9))
elsif (Source(Source'First + 0) = '2' and
Source(Source'First + 1) = '1' and
Source(Source'First + 2) = '4' and
Source(Source'First + 3) = '7' and
Source(Source'First + 4) = '4' and
Source(Source'First + 5) = '8' and
Source(Source'First + 6) = '3' and
Source(Source'First + 7) = '6' and
Source(Source'First + 8) < '4') then
(Has_Failed = False and
Target = 2_147_483_600 + 10*I (Source, 8) + I (Source, 9))
elsif (Source(Source'First + 0) = '2' and
Source(Source'First + 1) = '1' and
Source(Source'First + 2) = '4' and
Source(Source'First + 3) = '7' and
Source(Source'First + 4) = '4' and
Source(Source'First + 5) = '8' and
Source(Source'First + 6) = '3' and
Source(Source'First + 7) < '6') then
(Has_Failed = False and
Target = 2_147_483_000 + 100*I (Source, 7) + 10*I (Source, 8) + I (Source, 9))
elsif (Source(Source'First + 0) = '2' and
Source(Source'First + 1) = '1' and
Source(Source'First + 2) = '4' and
Source(Source'First + 3) = '7' and
Source(Source'First + 4) = '4' and
Source(Source'First + 5) = '8' and
Source(Source'First + 6) < '3') then
(Has_Failed = False and
Target = 2_147_480_000 + 1_000*I (Source, 6) + 100*I (Source, 7) + 10*I (Source, 8) + I (Source, 9))
elsif (Source(Source'First + 0) = '2' and
Source(Source'First + 1) = '1' and
Source(Source'First + 2) = '4' and
Source(Source'First + 3) = '7' and
Source(Source'First + 4) = '4' and
Source(Source'First + 5) < '8') then
(Has_Failed = False and
Target = 2_147_400_000 + 10_000*I (Source, 5) + 1_000*I (Source, 6) + 100*I (Source, 7) + 10*I (Source, 8) + I (Source, 9))
elsif (Source(Source'First + 0) = '2' and
Source(Source'First + 1) = '1' and
Source(Source'First + 2) = '4' and
Source(Source'First + 3) = '7' and
Source(Source'First + 4) < '4') then
(Has_Failed = False and
Target = 2_147_000_000 + 100_000*I (Source, 4) + 10_000*I (Source, 5) + 1_000*I (Source, 6) + 100*I (Source, 7) + 10*I (Source, 8) + I (Source, 9))
elsif (Source(Source'First + 0) = '2' and
Source(Source'First + 1) = '1' and
Source(Source'First + 2) = '4' and
Source(Source'First + 3) < '7') then
(Has_Failed = False and
Target = 2_140_000_000 + 1_000_000*I (Source, 3) + 100_000*I (Source, 4) + 10_000*I (Source, 5) + 1_000*I (Source, 6) + 100*I (Source, 7) + 10*I (Source, 8) + I (Source, 9))
elsif (Source(Source'First + 0) = '2' and
Source(Source'First + 1) = '1' and
Source(Source'First + 2) < '4') then
(Has_Failed = False and
Target = 2_100_000_000 + 10_000_000*I (Source, 2) + 1_000_000*I (Source, 3) + 100_000*I (Source, 4) + 10_000*I (Source, 5) + 1_000*I (Source, 6) + 100*I (Source, 7) + 10*I (Source, 8) + I (Source, 9))
elsif (Source(Source'First + 0) = '2' and
Source(Source'First + 1) < '1') then
(Has_Failed = False and
Target = 2_000_000_000 + 10_000_000*I (Source, 2) + 1_000_000*I (Source, 3) + 100_000*I (Source, 4) + 10_000*I (Source, 5) + 1_000*I (Source, 6) + 100*I (Source, 7) + 10*I (Source, 8) + I (Source, 9))
elsif (Source(Source'First + 0) < '2') then
(Has_Failed = False and
Target = 1_000_000_000*I (Source, 0) + 100_000_000*I (Source, 1) + 10_000_000*I (Source, 2) + 1_000_000*I (Source, 3) + 100_000*I (Source, 4) + 10_000*I (Source, 5) + 1_000*I (Source, 6) + 100*I (Source, 7) + 10*I (Source, 8) + I (Source, 9))
else
Has_Failed)
elsif ((Source (Source'First) = '-') and (for all Index in Int32_T range (Source'First + 1) .. Source'Last => Aida.Character.Is_Digit (Source (Index)))) then
(Has_Failed = False and
Target = -100_000_000*I (Source, 1) - 10_000_000*I (Source, 2) - 1_000_000*I (Source, 3) - 100_000*I (Source, 4) - 10_000*I (Source, 5) - 1_000*I (Source, 6) - 100*I (Source, 7) - 10*I (Source, 8) - I (Source, 9))
else
Has_Failed),
Source'Length = 11 => (if ((Source (Source'First) = '-') and (for all Index in Int32_T range (Source'First + 1) .. Source'Last => Aida.Character.Is_Digit (Source (Index)))) then
(if (Source(Source'First + 1) = '2' and
Source(Source'First + 2) = '1' and
Source(Source'First + 3) = '4' and
Source(Source'First + 4) = '7' and
Source(Source'First + 5) = '4' and
Source(Source'First + 6) = '8' and
Source(Source'First + 7) = '3' and
Source(Source'First + 8) = '6' and
Source(Source'First + 9) = '4' and
Source(Source'First + 10) <= '8') then
(Has_Failed = False and
Target = -2_147_483_640 - I (Source, 10))
elsif (Source(Source'First + 1) = '2' and
Source(Source'First + 2) = '1' and
Source(Source'First + 3) = '4' and
Source(Source'First + 4) = '7' and
Source(Source'First + 5) = '4' and
Source(Source'First + 6) = '8' and
Source(Source'First + 7) = '3' and
Source(Source'First + 8) = '6' and
Source(Source'First + 9) < '4') then
(Has_Failed = False and
Target = -2_147_483_600 - 10*I (Source, 9) - I (Source, 10))
elsif (Source(Source'First + 1) = '2' and
Source(Source'First + 2) = '1' and
Source(Source'First + 3) = '4' and
Source(Source'First + 4) = '7' and
Source(Source'First + 5) = '4' and
Source(Source'First + 6) = '8' and
Source(Source'First + 7) = '3' and
Source(Source'First + 8) < '6') then
(Has_Failed = False and
Target = -2_147_483_000 - 100*I (Source, 8) - 10*I (Source, 9) - I (Source, 10))
elsif (Source(Source'First + 1) = '2' and
Source(Source'First + 2) = '1' and
Source(Source'First + 3) = '4' and
Source(Source'First + 4) = '7' and
Source(Source'First + 5) = '4' and
Source(Source'First + 6) = '8' and
Source(Source'First + 7) < '3') then
(Has_Failed = False and
Target = -2_147_480_000 - 1_000*I (Source, 7) - 100*I (Source, 8) - 10*I (Source, 9) - I (Source, 10))
elsif
(Source(Source'First + 1) = '2' and
Source(Source'First + 2) = '1' and
Source(Source'First + 3) = '4' and
Source(Source'First + 4) = '7' and
Source(Source'First + 5) = '4' and
Source(Source'First + 6) < '8') then
(Has_Failed = False and
Target = -2_147_400_000 - 10_000*I (Source, 6) - 1_000*I (Source, 7) - 100*I (Source, 8) - 10*I (Source, 9) - I (Source, 10))
elsif (Source(Source'First + 1) = '2' and
Source(Source'First + 2) = '1' and
Source(Source'First + 3) = '4' and
Source(Source'First + 4) = '7' and
Source(Source'First + 5) < '4') then
(Has_Failed = False and
Target = -2_147_000_000 - 100_000*I (Source, 5) - 10_000*I (Source, 6) - 1_000*I (Source, 7) - 100*I (Source, 8) - 10*I (Source, 9) - I (Source, 10))
elsif (Source(Source'First + 1) = '2' and
Source(Source'First + 2) = '1' and
Source(Source'First + 3) = '4' and
Source(Source'First + 4) < '7') then
(Has_Failed = False and
Target = -2_140_000_000 - 1_000_000*I (Source, 4) - 100_000*I (Source, 5) - 10_000*I (Source, 6) - 1_000*I (Source, 7) - 100*I (Source, 8) - 10*I (Source, 9) - I (Source, 10))
elsif (Source(Source'First + 1) = '2' and
Source(Source'First + 2) = '1' and
Source(Source'First + 3) < '4') then
(Has_Failed = False and
Target = -2_100_000_000 - 10_000_000*I (Source, 3) - 1_000_000*I (Source, 4) - 100_000*I (Source, 5) - 10_000*I (Source, 6) - 1_000*I (Source, 7) - 100*I (Source, 8) - 10*I (Source, 9) - I (Source, 10))
elsif (Source(Source'First + 1) = '2' and
Source(Source'First + 2) < '1') then
(Has_Failed = False and
Target = -2_000_000_000 - 100_000_000*I (Source, 2) - 10_000_000*I (Source, 3) - 1_000_000*I (Source, 4) - 100_000*I (Source, 5) - 10_000*I (Source, 6) - 1_000*I (Source, 7) - 100*I (Source, 8) - 10*I (Source, 9) - I (Source, 10))
elsif (Source(Source'First + 1) < '2') then
(Has_Failed = False and
Target = -1_000_000_000*I (Source, 1) - 100_000_000*I (Source, 2) - 10_000_000*I (Source, 3) - 1_000_000*I (Source, 4) - 100_000*I (Source, 5) - 10_000*I (Source, 6) - 1_000*I (Source, 7) - 100*I (Source, 8) - 10*I (Source, 9) - I (Source, 10))
else
Has_Failed)
else
Has_Failed),
Source'Length >= 12 => Has_Failed);
function To_Int32 (Source : Standard.String) return Int32_T with
Global => null,
Pre => ((Source'Length >= 1 and Source'Length <= 11) and then (
if Source'Length = 1 then
Aida.Character.Is_Digit (Source (Source'First))
elsif (Source'Length >= 2 and Source'Length <= 9) then
((for all Index in Source'Range => Aida.Character.Is_Digit (Source (Index))) or
((Source (Source'First) = '-') and (for all Index in Int32_T range (Source'First + 1) .. Source'Last => Aida.Character.Is_Digit (Source (Index)))))
elsif Source'Length = 10 then
(((Source (Source'First) = '-') and (for all Index in Int32_T range (Source'First + 1) .. Source'Last => Aida.Character.Is_Digit (Source (Index)))) or
((for all Index in Source'Range => Aida.Character.Is_Digit (Source (Index))) and then
((Source(Source'First + 0) = '2' and
Source(Source'First + 1) = '1' and
Source(Source'First + 2) = '4' and
Source(Source'First + 3) = '7' and
Source(Source'First + 4) = '4' and
Source(Source'First + 5) = '8' and
Source(Source'First + 6) = '3' and
Source(Source'First + 7) = '6' and
Source(Source'First + 8) = '4' and
Source(Source'First + 9) < '8') or
(Source(Source'First + 0) = '2' and
Source(Source'First + 1) = '1' and
Source(Source'First + 2) = '4' and
Source(Source'First + 3) = '7' and
Source(Source'First + 4) = '4' and
Source(Source'First + 5) = '8' and
Source(Source'First + 6) = '3' and
Source(Source'First + 7) = '6' and
Source(Source'First + 8) < '4') or
(Source(Source'First + 0) = '2' and
Source(Source'First + 1) = '1' and
Source(Source'First + 2) = '4' and
Source(Source'First + 3) = '7' and
Source(Source'First + 4) = '4' and
Source(Source'First + 5) = '8' and
Source(Source'First + 6) = '3' and
Source(Source'First + 7) < '6') or
(Source(Source'First + 0) = '2' and
Source(Source'First + 1) = '1' and
Source(Source'First + 2) = '4' and
Source(Source'First + 3) = '7' and
Source(Source'First + 4) = '4' and
Source(Source'First + 5) = '8' and
Source(Source'First + 6) < '3') or
(Source(Source'First + 0) = '2' and
Source(Source'First + 1) = '1' and
Source(Source'First + 2) = '4' and
Source(Source'First + 3) = '7' and
Source(Source'First + 4) = '4' and
Source(Source'First + 5) < '8') or
(Source(Source'First + 0) = '2' and
Source(Source'First + 1) = '1' and
Source(Source'First + 2) = '4' and
Source(Source'First + 3) = '7' and
Source(Source'First + 4) < '4') or
(Source(Source'First + 0) = '2' and
Source(Source'First + 1) = '1' and
Source(Source'First + 2) = '4' and
Source(Source'First + 3) < '7') or
(Source(Source'First + 0) = '2' and
Source(Source'First + 1) = '1' and
Source(Source'First + 2) < '4') or
(Source(Source'First + 0) = '2' and
Source(Source'First + 1) < '1') or
(Source(Source'First + 0) < '2'))))
elsif Source'Length = 11 then
(((Source (Source'First) = '-') and (for all Index in Int32_T range (Source'First + 1) .. Source'Last => Aida.Character.Is_Digit (Source (Index)))) and then
((Source(Source'First + 1) = '2' and
Source(Source'First + 2) = '1' and
Source(Source'First + 3) = '4' and
Source(Source'First + 4) = '7' and
Source(Source'First + 5) = '4' and
Source(Source'First + 6) = '8' and
Source(Source'First + 7) = '3' and
Source(Source'First + 8) = '6' and
Source(Source'First + 9) = '4' and
Source(Source'First + 10) <= '8') or
(Source(Source'First + 1) = '2' and
Source(Source'First + 2) = '1' and
Source(Source'First + 3) = '4' and
Source(Source'First + 4) = '7' and
Source(Source'First + 5) = '4' and
Source(Source'First + 6) = '8' and
Source(Source'First + 7) = '3' and
Source(Source'First + 8) = '6' and
Source(Source'First + 9) < '4') or
(Source(Source'First + 1) = '2' and
Source(Source'First + 2) = '1' and
Source(Source'First + 3) = '4' and
Source(Source'First + 4) = '7' and
Source(Source'First + 5) = '4' and
Source(Source'First + 6) = '8' and
Source(Source'First + 7) = '3' and
Source(Source'First + 8) < '6') or
(Source(Source'First + 1) = '2' and
Source(Source'First + 2) = '1' and
Source(Source'First + 3) = '4' and
Source(Source'First + 4) = '7' and
Source(Source'First + 5) = '4' and
Source(Source'First + 6) = '8' and
Source(Source'First + 7) < '3') or
(Source(Source'First + 1) = '2' and
Source(Source'First + 2) = '1' and
Source(Source'First + 3) = '4' and
Source(Source'First + 4) = '7' and
Source(Source'First + 5) = '4' and
Source(Source'First + 6) < '8') or
(Source(Source'First + 1) = '2' and
Source(Source'First + 2) = '1' and
Source(Source'First + 3) = '4' and
Source(Source'First + 4) = '7' and
Source(Source'First + 5) < '4') or
(Source(Source'First + 1) = '2' and
Source(Source'First + 2) = '1' and
Source(Source'First + 3) = '4' and
Source(Source'First + 4) < '7') or
(Source(Source'First + 1) = '2' and
Source(Source'First + 2) = '1' and
Source(Source'First + 3) < '4') or
(Source(Source'First + 1) = '2' and
Source(Source'First + 2) < '1') or
(Source(Source'First + 1) < '2'))))),
Contract_Cases => (Source'Length = 1 => To_Int32'Result = I (Source, 0),
Source'Length = 2 => (if (for all Index in Source'Range => Aida.Character.Is_Digit (Source (Index))) then
(To_Int32'Result = 10*I (Source, 0) + I (Source, 1))
elsif ((Source (Source'First) = '-') and (for all Index in Int32_T range (Source'First + 1) .. Source'Last => Aida.Character.Is_Digit (Source (Index)))) then
(To_Int32'Result = -I (Source, 1))),
Source'Length = 3 => (if (for all Index in Source'Range => Aida.Character.Is_Digit (Source (Index))) then
(To_Int32'Result = 100*I (Source, 0) + 10*I (Source, 1) + I (Source, 2))
elsif ((Source (Source'First) = '-') and (for all Index in Int32_T range (Source'First + 1) .. Source'Last => Aida.Character.Is_Digit (Source (Index)))) then
(To_Int32'Result = -10*I (Source, 1) - I (Source, 2))),
Source'Length = 4 => (if (for all Index in Source'Range => Aida.Character.Is_Digit (Source (Index))) then
(To_Int32'Result = 1_000*I (Source, 0) + 100*I (Source, 1) + 10*I (Source, 2) + I (Source, 3))
elsif ((Source (Source'First) = '-') and (for all Index in Int32_T range (Source'First + 1) .. Source'Last => Aida.Character.Is_Digit (Source (Index)))) then
(To_Int32'Result = -100*I (Source, 1) - 10*I (Source, 2) - I (Source, 3))),
Source'Length = 5 => (if (for all Index in Source'Range => Aida.Character.Is_Digit (Source (Index))) then
(To_Int32'Result = 10_000*I (Source, 0) + 1_000*I (Source, 1) + 100*I (Source, 2) + 10*I (Source, 3) + I (Source, 4))
elsif ((Source (Source'First) = '-') and (for all Index in Int32_T range (Source'First + 1) .. Source'Last => Aida.Character.Is_Digit (Source (Index)))) then
(To_Int32'Result = -1_000*I (Source, 1) - 100*I (Source, 2) - 10*I (Source, 3) - I (Source, 4))),
Source'Length = 6 => (if (for all Index in Source'Range => Aida.Character.Is_Digit (Source (Index))) then
(To_Int32'Result = 100_000*I (Source, 0) + 10_000*I (Source, 1) + 1_000*I (Source, 2) + 100*I (Source, 3) + 10*I (Source, 4) + I (Source, 5))
elsif ((Source (Source'First) = '-') and (for all Index in Int32_T range (Source'First + 1) .. Source'Last => Aida.Character.Is_Digit (Source (Index)))) then
(To_Int32'Result = -10_000*I (Source, 1) - 1_000*I (Source, 2) - 100*I (Source, 3) - 10*I (Source, 4) - I (Source, 5))),
Source'Length = 7 => (if (for all Index in Source'Range => Aida.Character.Is_Digit (Source (Index))) then
(To_Int32'Result = 1_000_000*I (Source, 0) + 100_000*I (Source, 1) + 10_000*I (Source, 2) + 1_000*I (Source, 3) + 100*I (Source, 4) + 10*I (Source, 5) + I (Source, 6))
elsif ((Source (Source'First) = '-') and (for all Index in Int32_T range (Source'First + 1) .. Source'Last => Aida.Character.Is_Digit (Source (Index)))) then
(To_Int32'Result = -100_000*I (Source, 1) - 10_000*I (Source, 2) - 1_000*I (Source, 3) - 100*I (Source, 4) - 10*I (Source, 5) - I (Source, 6))),
Source'Length = 8 => (if (for all Index in Source'Range => Aida.Character.Is_Digit (Source (Index))) then
(To_Int32'Result = 10_000_000*I (Source, 0) + 1_000_000*I (Source, 1) + 100_000*I (Source, 2) + 10_000*I (Source, 3) + 1_000*I (Source, 4) + 100*I (Source, 5) + 10*I (Source, 6) + I (Source, 7))
elsif ((Source (Source'First) = '-') and (for all Index in Int32_T range (Source'First + 1) .. Source'Last => Aida.Character.Is_Digit (Source (Index)))) then
(To_Int32'Result = -1_000_000*I (Source, 1) - 100_000*I (Source, 2) - 10_000*I (Source, 3) - 1_000*I (Source, 4) - 100*I (Source, 5) - 10*I (Source, 6) - I (Source, 7))),
Source'Length = 9 => (if (for all Index in Source'Range => Aida.Character.Is_Digit (Source (Index))) then
(To_Int32'Result = 100_000_000*I (Source, 0) + 10_000_000*I (Source, 1) + 1_000_000*I (Source, 2) + 100_000*I (Source, 3) + 10_000*I (Source, 4) + 1_000*I (Source, 5) + 100*I (Source, 6) + 10*I (Source, 7) + I (Source, 8))
elsif ((Source (Source'First) = '-') and (for all Index in Int32_T range (Source'First + 1) .. Source'Last => Aida.Character.Is_Digit (Source (Index)))) then
(To_Int32'Result = -10_000_000*I (Source, 1) - 1_000_000*I (Source, 2) - 100_000*I (Source, 3) - 10_000*I (Source, 4) - 1_000*I (Source, 5) - 100*I (Source, 6) - 10*I (Source, 7) - I (Source, 8))),
Source'Length = 10 => (if (for all Index in Source'Range => Aida.Character.Is_Digit (Source (Index))) then
(if (Source(Source'First + 0) = '2' and
Source(Source'First + 1) = '1' and
Source(Source'First + 2) = '4' and
Source(Source'First + 3) = '7' and
Source(Source'First + 4) = '4' and
Source(Source'First + 5) = '8' and
Source(Source'First + 6) = '3' and
Source(Source'First + 7) = '6' and
Source(Source'First + 8) = '4' and
Source(Source'First + 9) < '8') then
(To_Int32'Result = 2_147_483_640 + I (Source, 9))
elsif (Source(Source'First + 0) = '2' and
Source(Source'First + 1) = '1' and
Source(Source'First + 2) = '4' and
Source(Source'First + 3) = '7' and
Source(Source'First + 4) = '4' and
Source(Source'First + 5) = '8' and
Source(Source'First + 6) = '3' and
Source(Source'First + 7) = '6' and
Source(Source'First + 8) < '4') then
(To_Int32'Result = 2_147_483_600 + 10*I (Source, 8) + I (Source, 9))
elsif (Source(Source'First + 0) = '2' and
Source(Source'First + 1) = '1' and
Source(Source'First + 2) = '4' and
Source(Source'First + 3) = '7' and
Source(Source'First + 4) = '4' and
Source(Source'First + 5) = '8' and
Source(Source'First + 6) = '3' and
Source(Source'First + 7) < '6') then
(To_Int32'Result = 2_147_483_000 + 100*I (Source, 7) + 10*I (Source, 8) + I (Source, 9))
elsif (Source(Source'First + 0) = '2' and
Source(Source'First + 1) = '1' and
Source(Source'First + 2) = '4' and
Source(Source'First + 3) = '7' and
Source(Source'First + 4) = '4' and
Source(Source'First + 5) = '8' and
Source(Source'First + 6) < '3') then
(To_Int32'Result = 2_147_480_000 + 1_000*I (Source, 6) + 100*I (Source, 7) + 10*I (Source, 8) + I (Source, 9))
elsif (Source(Source'First + 0) = '2' and
Source(Source'First + 1) = '1' and
Source(Source'First + 2) = '4' and
Source(Source'First + 3) = '7' and
Source(Source'First + 4) = '4' and
Source(Source'First + 5) < '8') then
(To_Int32'Result = 2_147_400_000 + 10_000*I (Source, 5) + 1_000*I (Source, 6) + 100*I (Source, 7) + 10*I (Source, 8) + I (Source, 9))
elsif (Source(Source'First + 0) = '2' and
Source(Source'First + 1) = '1' and
Source(Source'First + 2) = '4' and
Source(Source'First + 3) = '7' and
Source(Source'First + 4) < '4') then
(To_Int32'Result = 2_147_000_000 + 100_000*I (Source, 4) + 10_000*I (Source, 5) + 1_000*I (Source, 6) + 100*I (Source, 7) + 10*I (Source, 8) + I (Source, 9))
elsif (Source(Source'First + 0) = '2' and
Source(Source'First + 1) = '1' and
Source(Source'First + 2) = '4' and
Source(Source'First + 3) < '7') then
(To_Int32'Result = 2_140_000_000 + 1_000_000*I (Source, 3) + 100_000*I (Source, 4) + 10_000*I (Source, 5) + 1_000*I (Source, 6) + 100*I (Source, 7) + 10*I (Source, 8) + I (Source, 9))
elsif (Source(Source'First + 0) = '2' and
Source(Source'First + 1) = '1' and
Source(Source'First + 2) < '4') then
(To_Int32'Result = 2_100_000_000 + 10_000_000*I (Source, 2) + 1_000_000*I (Source, 3) + 100_000*I (Source, 4) + 10_000*I (Source, 5) + 1_000*I (Source, 6) + 100*I (Source, 7) + 10*I (Source, 8) + I (Source, 9))
elsif (Source(Source'First + 0) = '2' and
Source(Source'First + 1) < '1') then
(To_Int32'Result = 2_000_000_000 + 10_000_000*I (Source, 2) + 1_000_000*I (Source, 3) + 100_000*I (Source, 4) + 10_000*I (Source, 5) + 1_000*I (Source, 6) + 100*I (Source, 7) + 10*I (Source, 8) + I (Source, 9))
elsif (Source(Source'First + 0) < '2') then
(To_Int32'Result = 1_000_000_000*I (Source, 0) + 100_000_000*I (Source, 1) + 10_000_000*I (Source, 2) + 1_000_000*I (Source, 3) + 100_000*I (Source, 4) + 10_000*I (Source, 5) + 1_000*I (Source, 6) + 100*I (Source, 7) + 10*I (Source, 8) + I (Source, 9)))
elsif ((Source (Source'First) = '-') and (for all Index in Int32_T range (Source'First + 1) .. Source'Last => Aida.Character.Is_Digit (Source (Index)))) then
(To_Int32'Result = -100_000_000*I (Source, 1) - 10_000_000*I (Source, 2) - 1_000_000*I (Source, 3) - 100_000*I (Source, 4) - 10_000*I (Source, 5) - 1_000*I (Source, 6) - 100*I (Source, 7) - 10*I (Source, 8) - I (Source, 9))),
Source'Length = 11 => (if ((Source (Source'First) = '-') and (for all Index in Int32_T range (Source'First + 1) .. Source'Last => Aida.Character.Is_Digit (Source (Index)))) then
(if (Source(Source'First + 1) = '2' and
Source(Source'First + 2) = '1' and
Source(Source'First + 3) = '4' and
Source(Source'First + 4) = '7' and
Source(Source'First + 5) = '4' and
Source(Source'First + 6) = '8' and
Source(Source'First + 7) = '3' and
Source(Source'First + 8) = '6' and
Source(Source'First + 9) = '4' and
Source(Source'First + 10) <= '8') then
(To_Int32'Result = -2_147_483_640 - I (Source, 10))
elsif (Source(Source'First + 1) = '2' and
Source(Source'First + 2) = '1' and
Source(Source'First + 3) = '4' and
Source(Source'First + 4) = '7' and
Source(Source'First + 5) = '4' and
Source(Source'First + 6) = '8' and
Source(Source'First + 7) = '3' and
Source(Source'First + 8) = '6' and
Source(Source'First + 9) < '4') then
(To_Int32'Result = -2_147_483_600 - 10*I (Source, 9) - I (Source, 10))
elsif (Source(Source'First + 1) = '2' and
Source(Source'First + 2) = '1' and
Source(Source'First + 3) = '4' and
Source(Source'First + 4) = '7' and
Source(Source'First + 5) = '4' and
Source(Source'First + 6) = '8' and
Source(Source'First + 7) = '3' and
Source(Source'First + 8) < '6') then
(To_Int32'Result = -2_147_483_000 - 100*I (Source, 8) - 10*I (Source, 9) - I (Source, 10))
elsif (Source(Source'First + 1) = '2' and
Source(Source'First + 2) = '1' and
Source(Source'First + 3) = '4' and
Source(Source'First + 4) = '7' and
Source(Source'First + 5) = '4' and
Source(Source'First + 6) = '8' and
Source(Source'First + 7) < '3') then
(To_Int32'Result = -2_147_480_000 - 1_000*I (Source, 7) - 100*I (Source, 8) - 10*I (Source, 9) - I (Source, 10))
elsif
(Source(Source'First + 1) = '2' and
Source(Source'First + 2) = '1' and
Source(Source'First + 3) = '4' and
Source(Source'First + 4) = '7' and
Source(Source'First + 5) = '4' and
Source(Source'First + 6) < '8') then
(To_Int32'Result = -2_147_400_000 - 10_000*I (Source, 6) - 1_000*I (Source, 7) - 100*I (Source, 8) - 10*I (Source, 9) - I (Source, 10))
elsif (Source(Source'First + 1) = '2' and
Source(Source'First + 2) = '1' and
Source(Source'First + 3) = '4' and
Source(Source'First + 4) = '7' and
Source(Source'First + 5) < '4') then
(To_Int32'Result = -2_147_000_000 - 100_000*I (Source, 5) - 10_000*I (Source, 6) - 1_000*I (Source, 7) - 100*I (Source, 8) - 10*I (Source, 9) - I (Source, 10))
elsif (Source(Source'First + 1) = '2' and
Source(Source'First + 2) = '1' and
Source(Source'First + 3) = '4' and
Source(Source'First + 4) < '7') then
(To_Int32'Result = -2_140_000_000 - 1_000_000*I (Source, 4) - 100_000*I (Source, 5) - 10_000*I (Source, 6) - 1_000*I (Source, 7) - 100*I (Source, 8) - 10*I (Source, 9) - I (Source, 10))
elsif (Source(Source'First + 1) = '2' and
Source(Source'First + 2) = '1' and
Source(Source'First + 3) < '4') then
(To_Int32'Result = -2_100_000_000 - 10_000_000*I (Source, 3) - 1_000_000*I (Source, 4) - 100_000*I (Source, 5) - 10_000*I (Source, 6) - 1_000*I (Source, 7) - 100*I (Source, 8) - 10*I (Source, 9) - I (Source, 10))
elsif (Source(Source'First + 1) = '2' and
Source(Source'First + 2) < '1') then
(To_Int32'Result = -2_000_000_000 - 100_000_000*I (Source, 2) - 10_000_000*I (Source, 3) - 1_000_000*I (Source, 4) - 100_000*I (Source, 5) - 10_000*I (Source, 6) - 1_000*I (Source, 7) - 100*I (Source, 8) - 10*I (Source, 9) - I (Source, 10))
elsif (Source(Source'First + 1) < '2') then
(To_Int32'Result = -1_000_000_000*I (Source, 1) - 100_000_000*I (Source, 2) - 10_000_000*I (Source, 3) - 1_000_000*I (Source, 4) - 100_000*I (Source, 5) - 10_000*I (Source, 6) - 1_000*I (Source, 7) - 100*I (Source, 8) - 10*I (Source, 9) - I (Source, 10)))));
procedure To_Float (Source : in Standard.String;
Target : out Standard.Float;
Has_Failed : out Boolean) with
Global => null;
function Is_Latin1_Graphic_Characters (Text : Standard.String) return Boolean with
Global => null;
function Starts_With (This : Standard.String;
Searched_For : Standard.String) return Boolean with
Global => null,
Pre => Searched_For'Length > 0;
function Hash32 (This : Standard.String) return Hash32_T with
Global => null;
function Concat (Left, Right : Standard.String) return Standard.String with
Global => null,
Pre => Left'Length < Pos32_T'Last/2 and Right'Length < Pos32_T'Last/2,
Post => Concat'Result'Length = Left'Length + Right'Length;
end String;
type Max_Hash_Map_Size_T is range 3..(2**31);
end Aida;
|
docandrew/troodon | Ada | 10,830 | adb | with Ada.Text_IO;
with Ada.Unchecked_Deallocation;
package body GID.Decoding_PNG.Huffman is
procedure Build(t: out Huff_tree; descr: in Huff_descriptor) is
curr, alloc: Natural;
code, mask: Unsigned_32;
begin
alloc:= root;
for i in descr'Range loop
if descr(i).length > 0 then
curr:= root;
code:= Unsigned_32(descr(i).code);
mask:= Shift_Left(Unsigned_32'(1), descr(i).length-1);
for j in 0..descr(i).length-1 loop
if (code and mask) /= 0 then
if t.node(curr).one = nil then
alloc:= alloc + 1;
t.node(curr).one:= alloc;
end if;
curr:= t.node(curr).one;
else
if t.node(curr).zero = nil then
alloc:= alloc + 1;
t.node(curr).zero:= alloc;
end if;
curr:= t.node(curr).zero;
end if;
mask:= Shift_Right(mask, 1);
end loop;
t.node(curr).n:= i;
end if;
end loop;
t.last:= alloc;
end Build;
-- Free huffman tables starting with table where t points to
procedure HufT_free ( tl: in out p_Table_list ) is
procedure Dispose is new
Ada.Unchecked_Deallocation( HufT_table, p_HufT_table );
procedure Dispose is new
Ada.Unchecked_Deallocation( Table_list, p_Table_list );
current: p_Table_list;
tcount : Natural:= 0; -- just a stat. Idea: replace table_list with an array
tot_length: Natural:= 0;
begin
if full_trace then
Ada.Text_IO.Put("[HufT_Free... ");
end if;
while tl /= null loop
if full_trace then
tcount:= tcount+1;
tot_length:= tot_length + tl.table'Length;
end if;
Dispose( tl.table ); -- destroy the Huffman table
current:= tl;
tl := tl.next;
Dispose( current ); -- destroy the current node
end loop;
if full_trace then
Ada.Text_IO.Put_Line(
Integer'Image(tcount)& " tables, of" &
Integer'Image(tot_length)& " tot. length]"
);
end if;
end HufT_free;
-- Build huffman table from code lengths given by array b
procedure HufT_build ( b : Length_array;
s : Integer;
d, e : Length_array;
tl : out p_Table_list;
m : in out Integer;
huft_incomplete : out Boolean)
is
b_max : constant:= 16;
b_maxp1: constant:= b_max + 1;
-- bit length count table
count : array( 0 .. b_maxp1 ) of Integer:= (others=> 0);
f : Integer; -- i repeats in table every f entries
g : Integer; -- max. code length
i, -- counter, current code
j : Integer; -- counter
kcc : Integer; -- number of bits in current code
c_idx, v_idx: Natural; -- array indices
current_table_ptr : p_HufT_table:= null;
current_node_ptr : p_Table_list:= null; -- curr. node for the curr. table
new_node_ptr : p_Table_list; -- new node for the new table
new_entry: HufT; -- table entry for structure assignment
u : array( 0..b_max ) of p_HufT_table; -- table stack
n_max : constant:= 288;
-- values in order of bit length
v : array( 0..n_max ) of Integer:= (others=> 0);
el_v, el_v_m_s: Integer;
w : Natural:= 0; -- bits before this table
offset, code_stack : array( 0..b_maxp1 ) of Integer;
table_level : Integer:= -1;
bits : array( Integer'(-1)..b_maxp1 ) of Integer;
-- ^bits(table_level) = # bits in table of level table_level
y : Integer; -- number of dummy codes added
z : Natural:= 0; -- number of entries in current table
el : Integer; -- length of eob code=code 256
no_copy_length_array: constant Boolean:= d'Length=0 or e'Length=0;
begin
if full_trace then
Ada.Text_IO.Put("[HufT_Build...");
end if;
tl:= null;
if b'Length > 256 then -- set length of EOB code, if any
el := Natural(b(256));
else
el := b_max;
end if;
-- Generate counts for each bit length
for k in b'Range loop
if b(k) > b_max then
-- m := 0; -- GNAT 2005 doesn't like it (warning).
raise huft_error;
end if;
count( Natural(b(k)) ):= count( Natural(b(k)) ) + 1;
end loop;
if count(0) = b'Length then
m := 0;
huft_incomplete:= False; -- spotted by Tucker Taft, 19-Aug-2004
return; -- complete
end if;
-- Find minimum and maximum length, bound m by those
j := 1;
while j <= b_max and then count(j) = 0 loop
j:= j + 1;
end loop;
kcc := j;
if m < j then
m := j;
end if;
i := b_max;
while i > 0 and then count(i) = 0 loop
i:= i - 1;
end loop;
g := i;
if m > i then
m := i;
end if;
-- Adjust last length count to fill out codes, if needed
y := Integer( Shift_Left(Unsigned_32'(1), j) ); -- y:= 2 ** j;
while j < i loop
y := y - count(j);
if y < 0 then
raise huft_error;
end if;
y:= y * 2;
j:= j + 1;
end loop;
y:= y - count(i);
if y < 0 then
raise huft_error;
end if;
count(i):= count(i) + y;
-- Generate starting offsets into the value table for each length
offset(1) := 0;
j:= 0;
for idx in 2..i loop
j:= j + count( idx-1 );
offset( idx ) := j;
end loop;
-- Make table of values in order of bit length
for idx in b'Range loop
j := Natural(b(idx));
if j /= 0 then
v( offset(j) ) := idx-b'First;
offset(j):= offset(j) + 1;
end if;
end loop;
-- Generate huffman codes and for each, make the table entries
code_stack(0) := 0;
i := 0;
v_idx:= v'First;
bits(-1) := 0;
-- go through the bit lengths (kcc already is bits in shortest code)
for k in kcc .. g loop
for am1 in reverse 0 .. count(k)-1 loop -- a counts codes of length k
-- here i is the huffman code of length k bits for value v(v_idx)
while k > w + bits(table_level) loop
w:= w + bits(table_level); -- Length of tables to this position
table_level:= table_level+ 1;
z:= g - w; -- Compute min size table <= m bits
if z > m then
z := m;
end if;
j := k - w;
f := Integer(Shift_Left(Unsigned_32'(1), j)); -- f:= 2 ** j;
if f > am1 + 2 then -- Try a k-w bit table
f:= f - (am1 + 2);
c_idx:= k;
loop -- Try smaller tables up to z bits
j:= j + 1;
exit when j >= z;
f := f * 2;
c_idx:= c_idx + 1;
exit when f - count(c_idx) <= 0;
f:= f - count(c_idx);
end loop;
end if;
if w + j > el and then w < el then
j:= el - w; -- Make EOB code end at table
end if;
if w = 0 then
j := m; -- Fix: main table always m bits!
end if;
z:= Integer(Shift_Left(Unsigned_32'(1), j)); -- z:= 2 ** j;
bits(table_level) := j;
-- Allocate and link new table
begin
current_table_ptr := new HufT_table ( 0..z );
new_node_ptr := new Table_list'( current_table_ptr, null );
exception
when Storage_Error =>
raise huft_out_of_memory;
end;
if current_node_ptr = null then -- first table
tl:= new_node_ptr;
else
current_node_ptr.next:= new_node_ptr; -- not my first...
end if;
current_node_ptr:= new_node_ptr; -- always non-Null from there
u( table_level ):= current_table_ptr;
-- Connect to last table, if there is one
if table_level > 0 then
code_stack(table_level) := i;
new_entry.bits := bits(table_level-1);
new_entry.extra_bits := 16 + j;
new_entry.next_table := current_table_ptr;
j := Integer(
Shift_Right( Unsigned_32(i) and
(Shift_Left(Unsigned_32'(1), w) - 1 ),
w - bits(table_level-1) )
);
-- Test against bad input!
if j > u( table_level - 1 )'Last then
raise huft_error;
end if;
u( table_level - 1 ) (j) := new_entry;
end if;
end loop;
-- Set up table entry in new_entry
new_entry.bits := k - w;
new_entry.next_table:= null; -- Unused
if v_idx >= b'Length then
new_entry.extra_bits := invalid;
else
el_v:= v(v_idx);
el_v_m_s:= el_v - s;
if el_v_m_s < 0 then -- Simple code, raw value
if el_v < 256 then
new_entry.extra_bits:= 16;
else
new_entry.extra_bits:= 15;
end if;
new_entry.n := el_v;
else -- Non-simple -> lookup in lists
if no_copy_length_array then
raise huft_error;
end if;
new_entry.extra_bits := Natural(e( el_v_m_s ));
new_entry.n := Natural(d( el_v_m_s ));
end if;
v_idx:= v_idx + 1;
end if;
-- fill code-like entries with new_entry
f := Integer( Shift_Left( Unsigned_32'(1) , k - w ));
-- i.e. f := 2 ** (k-w);
j := Integer( Shift_Right( Unsigned_32(i), w ) );
while j < z loop
current_table_ptr(j) := new_entry;
j:= j + f;
end loop;
-- backwards increment the k-bit code i
j := Integer( Shift_Left( Unsigned_32'(1) , k - 1 ));
-- i.e.: j:= 2 ** (k-1)
while ( Unsigned_32(i) and Unsigned_32(j) ) /= 0 loop
i := Integer( Unsigned_32(i) xor Unsigned_32(j) );
j := j / 2;
end loop;
i := Integer( Unsigned_32(i) xor Unsigned_32(j) );
-- backup over finished tables
while
Integer(Unsigned_32(i) and (Shift_Left(1, w)-1)) /=
code_stack(table_level)
loop
table_level:= table_level - 1;
w:= w - bits(table_level); -- Size of previous table!
end loop;
end loop; -- am1
end loop; -- k
if full_trace then
Ada.Text_IO.Put_Line("finished]");
end if;
huft_incomplete:= y /= 0 and g /= 1;
exception
when others =>
HufT_free( tl );
raise;
end HufT_build;
end GID.Decoding_PNG.Huffman;
|
rkoeninger/life | Ada | 554 | adb | package body Life_Pkg is
-------------
-- Gtk_New --
-------------
procedure Gtk_New (Life_Value : out Life_Access) is
begin
-- Generated stub: replace with real body!
pragma Compile_Time_Warning (Standard.True, "Gtk_New unimplemented");
end;
----------------
-- Initialize --
----------------
procedure Initialize (Life_Value : out Life_Record'Class) is
begin
-- Generated stub: replace with real body!
pragma Compile_Time_Warning (Standard.True, "Initialize unimplemented");
end;
end;
|
ekoeppen/STM32_Generic_Ada_Drivers | Ada | 2,738 | ads | pragma Style_Checks (Off);
-- This spec has been automatically generated from STM32L0x1.svd
pragma Restrictions (No_Elaboration_Code);
with System;
package STM32_SVD.CRC is
pragma Preelaborate;
---------------
-- Registers --
---------------
subtype IDR_IDR_Field is STM32_SVD.Byte;
-- Independent data register
type IDR_Register is record
-- General-purpose 8-bit data register bits
IDR : IDR_IDR_Field := 16#0#;
-- unspecified
Reserved_8_31 : STM32_SVD.UInt24 := 16#0#;
end record
with Volatile_Full_Access, Object_Size => 32,
Bit_Order => System.Low_Order_First;
for IDR_Register use record
IDR at 0 range 0 .. 7;
Reserved_8_31 at 0 range 8 .. 31;
end record;
subtype CR_RESET_Field is STM32_SVD.Bit;
subtype CR_POLYSIZE_Field is STM32_SVD.UInt2;
subtype CR_REV_IN_Field is STM32_SVD.UInt2;
subtype CR_REV_OUT_Field is STM32_SVD.Bit;
-- Control register
type CR_Register is record
-- Write-only. RESET bit
RESET : CR_RESET_Field := 16#0#;
-- unspecified
Reserved_1_2 : STM32_SVD.UInt2 := 16#0#;
-- Polynomial size
POLYSIZE : CR_POLYSIZE_Field := 16#0#;
-- Reverse input data
REV_IN : CR_REV_IN_Field := 16#0#;
-- Reverse output data
REV_OUT : CR_REV_OUT_Field := 16#0#;
-- unspecified
Reserved_8_31 : STM32_SVD.UInt24 := 16#0#;
end record
with Volatile_Full_Access, Object_Size => 32,
Bit_Order => System.Low_Order_First;
for CR_Register use record
RESET at 0 range 0 .. 0;
Reserved_1_2 at 0 range 1 .. 2;
POLYSIZE at 0 range 3 .. 4;
REV_IN at 0 range 5 .. 6;
REV_OUT at 0 range 7 .. 7;
Reserved_8_31 at 0 range 8 .. 31;
end record;
-----------------
-- Peripherals --
-----------------
-- Cyclic redundancy check calculation unit
type CRC_Peripheral is record
-- Data register
DR : aliased STM32_SVD.UInt32;
-- Independent data register
IDR : aliased IDR_Register;
-- Control register
CR : aliased CR_Register;
-- Initial CRC value
INIT : aliased STM32_SVD.UInt32;
-- polynomial
POL : aliased STM32_SVD.UInt32;
end record
with Volatile;
for CRC_Peripheral use record
DR at 16#0# range 0 .. 31;
IDR at 16#4# range 0 .. 31;
CR at 16#8# range 0 .. 31;
INIT at 16#10# range 0 .. 31;
POL at 16#14# range 0 .. 31;
end record;
-- Cyclic redundancy check calculation unit
CRC_Periph : aliased CRC_Peripheral
with Import, Address => CRC_Base;
end STM32_SVD.CRC;
|
im-prakher/Amass | Ada | 1,576 | ads | -- Copyright 2017 Jeff Foley. All rights reserved.
-- Use of this source code is governed by Apache 2 LICENSE that can be found in the LICENSE file.
local json = require("json")
name = "Shodan"
type = "api"
function start()
setratelimit(2)
end
function check()
if (api ~= nil and api.key ~= nil and api.key ~= "") then
return true
end
return false
end
function vertical(ctx, domain)
if (api == nil or api.key == nil or api.key == "") then
return
end
local resp
local vurl = buildurl(domain)
-- Check if the response data is in the graph database
if (api.ttl ~= nil and api.ttl > 0) then
resp = obtain_response(vurl, api.ttl)
end
if (resp == nil or resp == "") then
local err
resp, err = request({
url=vurl,
headers={['Content-Type']="application/json"},
})
if (err ~= nil and err ~= "") then
return
end
if (api.ttl ~= nil and api.ttl > 0) then
cache_response(vurl, resp)
end
end
local d = json.decode(resp)
if (d == nil or #(d.subdomains) == 0) then
return
end
for i, sub in pairs(d.subdomains) do
sendnames(ctx, sub .. "." .. domain)
end
end
function buildurl(domain)
return "https://api.shodan.io/dns/domain/" .. domain .. "?key=" .. api.key
end
function sendnames(ctx, content)
local names = find(content, subdomainre)
if names == nil then
return
end
for i, v in pairs(names) do
newname(ctx, v)
end
end
|
faelys/natools | Ada | 1,565 | ads | ------------------------------------------------------------------------------
-- Copyright (c) 2015-2016, Natacha Porté --
-- --
-- Permission to use, copy, modify, and distribute this software for any --
-- purpose with or without fee is hereby granted, provided that the above --
-- copyright notice and this permission notice appear in all copies. --
-- --
-- THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES --
-- WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF --
-- MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR --
-- ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES --
-- WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN --
-- ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF --
-- OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. --
------------------------------------------------------------------------------
with Natools.Tests;
package Natools.Time_Keys.Tests is
package NT renames Natools.Tests;
procedure All_Tests (Report : in out NT.Reporter'Class);
procedure Leap_Second (Report : in out NT.Reporter'Class);
procedure Roundtrips (Report : in out NT.Reporter'Class);
procedure Subsecond_Rounding (Report : in out NT.Reporter'Class);
end Natools.Time_Keys.Tests;
|
stcarrez/babel | Ada | 5,309 | ads | -----------------------------------------------------------------------
-- babel-files-maps -- Hash maps for files and directories
-- Copyright (C) 2014 Stephane.Carrez
-- Written by Stephane.Carrez ([email protected])
--
-- Licensed under the Apache License, Version 2.0 (the "License");
-- you may not use this file except in compliance with the License.
-- You may obtain a copy of the License at
--
-- http://www.apache.org/licenses/LICENSE-2.0
--
-- Unless required by applicable law or agreed to in writing, software
-- distributed under the License is distributed on an "AS IS" BASIS,
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-- See the License for the specific language governing permissions and
-- limitations under the License.
-----------------------------------------------------------------------
with Ada.Containers.Hashed_Maps;
with Util.Strings;
package Babel.Files.Maps is
-- Babel.Base.Get_File_Map (Directory, File_Map);
-- Babel.Base.Get_Directory_Map (Directory, Dir_Map);
-- File_Map.Find (New_File);
-- Dir_Map.Find (New_File);
-- Hash string -> File
package File_Maps is new
Ada.Containers.Hashed_Maps (Key_Type => Util.Strings.Name_Access,
Element_Type => File_Type,
Hash => Util.Strings.Hash,
Equivalent_Keys => Util.Strings.Equivalent_Keys,
"=" => "=");
subtype File_Map is File_Maps.Map;
subtype File_Cursor is File_Maps.Cursor;
-- Find the file with the given name in the file map.
function Find (From : in File_Map;
Name : in String) return File_Cursor;
-- Find the file with the given name in the file map.
function Find (From : in File_Map;
Name : in String) return File_Type;
-- Insert the file in the file map.
procedure Insert (Into : in out File_Map;
File : in File_Type);
-- Hash string -> Directory
package Directory_Maps is new
Ada.Containers.Hashed_Maps (Key_Type => Util.Strings.Name_Access,
Element_Type => Directory_Type,
Hash => Util.Strings.Hash,
Equivalent_Keys => Util.Strings.Equivalent_Keys,
"=" => "=");
subtype Directory_Map is Directory_Maps.Map;
subtype Directory_Cursor is Directory_Maps.Cursor;
-- Find the directory with the given name in the directory map.
function Find (From : in Directory_Map;
Name : in String) return Directory_Cursor;
-- Find the directory with the given name in the directory map.
function Find (From : in Directory_Map;
Name : in String) return Directory_Type;
procedure Add_File (Dirs : in out Directory_Map;
Files : in out File_Map;
Path : in String;
File : out File_Type);
type Differential_Container is new Babel.Files.Default_Container with private;
-- Add the file with the given name in the container.
overriding
procedure Add_File (Into : in out Differential_Container;
Element : in File_Type);
-- Add the directory with the given name in the container.
overriding
procedure Add_Directory (Into : in out Differential_Container;
Element : in Directory_Type);
-- Create a new file instance with the given name in the container.
overriding
function Create (Into : in Differential_Container;
Name : in String) return File_Type;
-- Create a new directory instance with the given name in the container.
overriding
function Create (Into : in Differential_Container;
Name : in String) return Directory_Type;
-- Find the file with the given name in this file container.
-- Returns NO_FILE if the file was not found.
overriding
function Find (From : in Differential_Container;
Name : in String) return File_Type;
-- Find the directory with the given name in this file container.
-- Returns NO_DIRECTORY if the directory was not found.
overriding
function Find (From : in Differential_Container;
Name : in String) return Directory_Type;
-- Set the directory object associated with the container.
overriding
procedure Set_Directory (Into : in out Differential_Container;
Directory : in Directory_Type);
-- Prepare the differential container by setting up the known files and known
-- directories. The <tt>Update</tt> procedure is called to give access to the
-- maps that can be updated.
procedure Prepare (Container : in out Differential_Container;
Update : access procedure (Files : in out File_Map;
Dirs : in out Directory_Map));
private
type Differential_Container is new Babel.Files.Default_Container with record
Known_Files : File_Map;
Known_Dirs : Directory_Map;
end record;
end Babel.Files.Maps;
|
Letractively/ada-ado | Ada | 4,516 | adb | -----------------------------------------------------------------------
-- ado.schemas -- Database Schemas
-- 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 ADO.Statements;
with ADO.SQL;
with Ada.Strings.Fixed;
package body ADO.Schemas.Mysql is
use ADO.Statements;
use ADO.Databases;
procedure Load_Table_Schema (C : in Connection'Class;
Table : in Table_Definition);
function String_To_Type (Value : in String) return Column_Type;
function String_To_Type (Value : in String) return Column_Type is
Pos : Natural;
begin
if Value = "date" then
return T_DATE;
elsif Value = "datetime" then
return T_DATE_TIME;
elsif Value = "int(11)" then
return T_INTEGER;
elsif Value = "bigint(20)" then
return T_LONG_INTEGER;
elsif Value = "tinyint(4)" then
return T_TINYINT;
elsif Value = "smallint(6)" then
return T_SMALLINT;
elsif Value = "longblob" then
return T_BLOB;
end if;
Pos := Ada.Strings.Fixed.Index (Value, "(");
if Pos > 0 then
declare
Name : constant String := Value (Value'First .. Pos - 1);
begin
if Name = "varchar" then
return T_VARCHAR;
elsif Name = "decimal" then
return T_FLOAT;
elsif Name = "int" then
return T_INTEGER;
elsif Name = "bigint" then
return T_LONG_INTEGER;
else
return T_UNKNOWN;
end if;
end;
end if;
return T_UNKNOWN;
end String_To_Type;
-- ------------------------------
-- Load the table definition
-- ------------------------------
procedure Load_Table_Schema (C : in Connection'Class;
Table : in Table_Definition) is
Name : constant String := Get_Name (Table);
Stmt : Query_Statement := C.Create_Statement ("show full columns from ");
Last : Column_Definition := null;
Col : Column_Definition;
Value : Unbounded_String;
Query : constant ADO.SQL.Query_Access := Stmt.Get_Query;
begin
ADO.SQL.Append_Name (Target => Query.SQL, Name => Name);
Stmt.Execute;
while Stmt.Has_Elements loop
Col := new Column;
Col.Name := Stmt.Get_Unbounded_String (0);
Col.Collation := Stmt.Get_Unbounded_String (2);
Col.Default := Stmt.Get_Unbounded_String (5);
if Last /= null then
Last.Next_Column := Col;
else
Table.First_Column := Col;
end if;
Value := Stmt.Get_Unbounded_String (1);
Col.Col_Type := String_To_Type (To_String (Value));
Value := Stmt.Get_Unbounded_String (3);
Col.Is_Null := Value = "YES";
Last := Col;
Stmt.Next;
end loop;
end Load_Table_Schema;
-- ------------------------------
-- Load the database schema
-- ------------------------------
procedure Load_Schema (C : in ADO.Databases.Connection'Class;
Schema : out Schema_Definition) is
Stmt : Query_Statement := C.Create_Statement ("show tables");
Table : Table_Definition;
Last : Table_Definition := null;
begin
Schema.Schema := new ADO.Schemas.Schema;
Stmt.Execute;
while Stmt.Has_Elements loop
Table := new ADO.Schemas.Table;
Table.Name := Stmt.Get_Unbounded_String (0);
if Last /= null then
Last.Next_Table := Table;
else
Schema.Schema.First_Table := Table;
end if;
Load_Table_Schema (C, Table);
Last := Table;
Stmt.Next;
end loop;
end Load_Schema;
end ADO.Schemas.Mysql;
|
charlie5/cBound | Ada | 1,852 | ads | -- This file is generated by SWIG. Please do not modify by hand.
--
with Interfaces;
with swig;
with Interfaces.C;
with Interfaces.C.Pointers;
package xcb.xcb_get_screen_saver_reply_t is
-- Item
--
type Item is record
response_type : aliased Interfaces.Unsigned_8;
pad0 : aliased Interfaces.Unsigned_8;
sequence : aliased Interfaces.Unsigned_16;
length : aliased Interfaces.Unsigned_32;
timeout : aliased Interfaces.Unsigned_16;
interval : aliased Interfaces.Unsigned_16;
prefer_blanking : aliased Interfaces.Unsigned_8;
allow_exposures : aliased Interfaces.Unsigned_8;
pad1 : aliased swig.int8_t_Array (0 .. 17);
end record;
-- Item_Array
--
type Item_Array is
array
(Interfaces.C
.size_t range <>) of aliased xcb.xcb_get_screen_saver_reply_t
.Item;
-- Pointer
--
package C_Pointers is new Interfaces.C.Pointers
(Index => Interfaces.C.size_t,
Element => xcb.xcb_get_screen_saver_reply_t.Item,
Element_Array => xcb.xcb_get_screen_saver_reply_t.Item_Array,
Default_Terminator => (others => <>));
subtype Pointer is C_Pointers.Pointer;
-- Pointer_Array
--
type Pointer_Array is
array
(Interfaces.C
.size_t range <>) of aliased xcb.xcb_get_screen_saver_reply_t
.Pointer;
-- Pointer_Pointer
--
package C_Pointer_Pointers is new Interfaces.C.Pointers
(Index => Interfaces.C.size_t,
Element => xcb.xcb_get_screen_saver_reply_t.Pointer,
Element_Array => xcb.xcb_get_screen_saver_reply_t.Pointer_Array,
Default_Terminator => null);
subtype Pointer_Pointer is C_Pointer_Pointers.Pointer;
end xcb.xcb_get_screen_saver_reply_t;
|
stcarrez/ada-keystore | Ada | 1,115 | ads | -----------------------------------------------------------------------
-- keystore-coverage -- Specific tests for coverage
-- Copyright (C) 2020 Stephane Carrez
-- Written by Stephane Carrez ([email protected])
--
-- Licensed under the Apache License, Version 2.0 (the "License");
-- you may not use this file except in compliance with the License.
-- You may obtain a copy of the License at
--
-- http://www.apache.org/licenses/LICENSE-2.0
--
-- Unless required by applicable law or agreed to in writing, software
-- distributed under the License is distributed on an "AS IS" BASIS,
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-- See the License for the specific language governing permissions and
-- limitations under the License.
-----------------------------------------------------------------------
with Util.Tests;
private package Keystore.Coverage is
procedure Add_Tests (Suite : in Util.Tests.Access_Test_Suite);
type Test is new Util.Tests.Test with null record;
procedure Test_Deep_Coverage (T : in out Test);
end Keystore.Coverage;
|
charlie5/cBound | Ada | 1,760 | ads | -- This file is generated by SWIG. Please do not modify by hand.
--
with Interfaces;
with swig;
with Interfaces.C;
with Interfaces.C.Pointers;
package xcb.xcb_render_query_filters_reply_t is
-- Item
--
type Item is record
response_type : aliased Interfaces.Unsigned_8;
pad0 : aliased Interfaces.Unsigned_8;
sequence : aliased Interfaces.Unsigned_16;
length : aliased Interfaces.Unsigned_32;
num_aliases : aliased Interfaces.Unsigned_32;
num_filters : aliased Interfaces.Unsigned_32;
pad1 : aliased swig.int8_t_Array (0 .. 15);
end record;
-- Item_Array
--
type Item_Array is
array
(Interfaces.C
.size_t range <>) of aliased xcb.xcb_render_query_filters_reply_t
.Item;
-- Pointer
--
package C_Pointers is new Interfaces.C.Pointers
(Index => Interfaces.C.size_t,
Element => xcb.xcb_render_query_filters_reply_t.Item,
Element_Array => xcb.xcb_render_query_filters_reply_t.Item_Array,
Default_Terminator => (others => <>));
subtype Pointer is C_Pointers.Pointer;
-- Pointer_Array
--
type Pointer_Array is
array
(Interfaces.C
.size_t range <>) of aliased xcb.xcb_render_query_filters_reply_t
.Pointer;
-- Pointer_Pointer
--
package C_Pointer_Pointers is new Interfaces.C.Pointers
(Index => Interfaces.C.size_t,
Element => xcb.xcb_render_query_filters_reply_t.Pointer,
Element_Array => xcb.xcb_render_query_filters_reply_t.Pointer_Array,
Default_Terminator => null);
subtype Pointer_Pointer is C_Pointer_Pointers.Pointer;
end xcb.xcb_render_query_filters_reply_t;
|
burratoo/Acton | Ada | 26,453 | adb | ------------------------------------------------------------------------------------------
-- --
-- OAK COMPONENTS --
-- --
-- OAK.STORAGE.TIME_PRIORITY_POOL --
-- --
-- Copyright (C) 2013-2021, Patrick Bernardi --
-- --
------------------------------------------------------------------------------------------
package body Oak.Storage.Time_Priority_Pool is
pragma Suppress (All_Checks);
-- ???? TODO: Need to write some code to verify this actually works. Spark
-- should help.
-----------------------
-- Local Subprograms --
-----------------------
procedure Allocate_Node
(Pool : in out Pool_Type;
New_Node : out Node_Location);
-- Allocate storage for a node.
procedure Deallocate_Node
(Pool : in out Pool_Type;
Node_Id : in Node_Location);
-- Deallocate a node from the storage pool. The node to be deallocated must
-- already be removed from the tree. TODO: add function to search tree for
-- node as a precondition.
function Max_Priority_For_Subtree
(Pool : in Pool_Type; Subtree : in Node_Location)
return Priority_Type;
-- Calculates the maximum priority that a node in the subtree possesses.
procedure Node_Has_Updated
(Pool : in out Pool_Type;
Node_Id : in Node_Location;
Old_Key : in Key_Type);
-- Checks to see if the node is in the right position in the tree after
-- the time associated with the node has been updated.
procedure Rotate_Left (Pool : in out Pool_Type;
Node_Id : in Node_Location);
procedure Rotate_Right (Pool : in out Pool_Type;
Node_Id : in Node_Location);
-- Red-Black Tree procedures. Rotates the subtree head defined by the
-- Node_Id left (right) such that it becomes the left (right) child of its
-- right (left) child which itself becomes the new head node for the
-- subtree.
-------------------
-- Allocate_Node --
-------------------
procedure Allocate_Node
(Pool : in out Pool_Type;
New_Node : out Node_Location) is
begin
-- Unallocated nodes live in one of two places. The first is in the bulk
-- free store which is the group of unallocated nodes at the right end
-- of the storage array (assuming that node are allocated from the array
-- left to right. When a pool is first initialised all the nodes but the
-- No_Node node are part of the bulk free store.
--
-- The second group of unallocated nodes live on the free list. Nodes
-- are added to the free list when they are unallocated and they are not
-- next to the bulk free store, where in this case the node joins that
-- store. This dual store approach prevents the need to have to
-- initialise the free list during setup, which would be an O(n)
-- operation. The free list is a linked list using the nodes' right
-- link.
--
-- The array looks like this (x marks an allocated node):
--
-- ---------------------------------------------------------------------
-- | x | | x | x | | | x | | | x | | | | | | | |
-- ---------------------------------------------------------------------
-- ^-----------^---^-------^---^ | ^ --- Bulk Free Store ----|
-- | |
-- Free_list Bulk_Free
--
if Pool.Free_List = No_Node then
-- The free list is empty so we allocate a node from the bulk free
-- store.
if Pool.Bulk_Free = No_Node then
-- No more room in the pool!
raise Pool_Capacity_Error with "No room in the pool!";
end if;
New_Node := Pool.Bulk_Free;
Pool.Bulk_Free := Pool.Bulk_Free + 1;
else
-- Extract a node from the free list.
New_Node := Pool.Free_List;
Pool.Free_List := Pool.Nodes (Pool.Free_List).Right;
end if;
end Allocate_Node;
---------------------
-- Deallocate_Node --
---------------------
procedure Deallocate_Node
(Pool : in out Pool_Type;
Node_Id : in Node_Location) is
begin
-- See the Allocate_Node procedure above for a description of how free
-- nodes are stored.
if Node_Id + 1 = Pool.Bulk_Free then
-- The next node is adjacent to the bulk free store, so we move the
-- node inside it.
Pool.Nodes (Node_Id).Has_Element := False;
Pool.Bulk_Free := Node_Id;
else
-- Add the node to the free list.
Pool.Nodes (Node_Id).Right := Pool.Free_List;
Pool.Free_List := Node_Id;
end if;
end Deallocate_Node;
-----------------
-- Delete_Item --
-----------------
procedure Delete_Item
(Pool : in out Pool_Type;
Item_Id : in Node_Location) is
begin
if In_Tree (Pool, Item_Id) then
Remove_Node (Pool, Item_Id);
end if;
Deallocate_Node (Pool, Item_Id);
end Delete_Item;
-----------------------
-- Find_Earlest_Item --
-----------------------
function Find_Earliest_Item
(In_Pool : in Pool_Type;
Above_Priority : in Priority_Type := Priority_Type'First)
return Node_Location
is
N : Node_Array renames In_Pool.Nodes;
Current_Node : Node_Location := In_Pool.Root;
Selected_Node : Node_Location;
begin
while Current_Node /= No_Node loop
-- The current node has been selected as having a priority above the
-- requested priority.
Selected_Node := Current_Node;
-- Try to find an earlier node that satisfies the requested priority.
if N (Current_Node).Left_Priority > Above_Priority then
-- There is an eariler node that statisfies the priority.
Current_Node := N (Current_Node).Left;
elsif Priority (N (Current_Node).Element) > Above_Priority then
-- This node is the earliest node that satisfies the priority
-- requirement.
Current_Node := No_Node;
elsif N (Current_Node).Right_Priority > Above_Priority then
-- The eariliest node that satisfies the priority requiement
-- exists on the right side of the node (i.e. the earliest node
-- that satisfies the priority requirement occurs after this
-- node).
Current_Node := N (Current_Node).Right;
else
-- This means we are at a node where neither it or its children
-- can satisfy the priority requirement. The only time this should
-- occur is the root node.
pragma Assert (Current_Node = In_Pool.Root);
Current_Node := No_Node;
Selected_Node := No_Node;
end if;
end loop;
return Selected_Node;
end Find_Earliest_Item;
-------------------------
-- Generic_Update_Time --
-------------------------
procedure Generic_Update_Time
(Pool : in out Pool_Type;
Item_Id : in Node_Location;
Time : in Oak_Time.Time)
is
Element : Element_Type renames Pool.Nodes (Item_Id).Element;
Old_Key : constant Key_Type := Key (Element => Element);
begin
Set_Time (Element, Time);
if In_Tree (Pool, Item_Id) then
Node_Has_Updated (Pool, Item_Id, Old_Key);
end if;
end Generic_Update_Time;
-----------------
-- Insert_Node --
-----------------
procedure Insert_Node (Pool : in out Pool_Type; Node : in Node_Location) is
N : Node_Array renames Pool.Nodes;
Current_Node : Node_Location := Pool.Root;
Parent_Node : Node_Location := No_Node;
Grandparent_Node : Node_Location;
Uncle_Node : Node_Location;
Node_Priority : constant Priority_Type := Priority (N (Node).Element);
begin
-- Insert the node as a leaf in the appropriate spot.
while Current_Node /= No_Node loop
Parent_Node := Current_Node;
if N (Node).Element < N (Current_Node).Element then
if Node_Priority > N (Current_Node).Left_Priority then
-- Update priority references on the way down.
N (Current_Node).Left_Priority := Node_Priority;
end if;
Current_Node := N (Current_Node).Left;
else
if Node_Priority > N (Current_Node).Right_Priority then
-- Update priority references on the way down.
N (Current_Node).Right_Priority := Node_Priority;
end if;
Current_Node := N (Current_Node).Right;
end if;
end loop;
N (Node).Parent := Parent_Node;
if Parent_Node = No_Node then
Pool.Root := Node;
elsif N (Node).Element < N (Parent_Node).Element then
N (Parent_Node).Left := Node;
else
N (Parent_Node).Right := Node;
end if;
-- Set Node properties
N (Node).Left := No_Node;
N (Node).Right := No_Node;
N (Node).Colour := Red;
N (Node).Left_Priority := First_Priority;
N (Node).Right_Priority := First_Priority;
-- Repair tree due to insertion
Current_Node := Node;
while N (N (Current_Node).Parent).Colour = Red loop
Parent_Node := N (Current_Node).Parent;
Grandparent_Node := N (Parent_Node).Parent;
if Parent_Node = N (Grandparent_Node).Left then
Uncle_Node := N (Grandparent_Node).Right;
if N (Uncle_Node).Colour = Red then
N (Parent_Node).Colour := Black;
N (Uncle_Node).Colour := Black;
N (Grandparent_Node).Colour := Red;
Current_Node := Grandparent_Node;
else
if Current_Node = N (Parent_Node).Right then
Current_Node := Parent_Node;
Rotate_Left (Pool, Current_Node);
end if;
Parent_Node := N (Current_Node).Parent;
Grandparent_Node := N (Parent_Node).Parent;
N (Parent_Node).Colour := Black;
N (Grandparent_Node).Colour := Red;
Rotate_Right (Pool, Grandparent_Node);
end if;
else
pragma Assert (Parent_Node = N (Grandparent_Node).Right);
Uncle_Node := N (Grandparent_Node).Left;
if N (Uncle_Node).Colour = Red then
N (Parent_Node).Colour := Black;
N (Uncle_Node).Colour := Black;
N (Grandparent_Node).Colour := Red;
Current_Node := Grandparent_Node;
else
if Current_Node = N (Parent_Node).Left then
Current_Node := Parent_Node;
Rotate_Right (Pool, Current_Node);
end if;
Parent_Node := N (Current_Node).Parent;
Grandparent_Node := N (Parent_Node).Parent;
N (Parent_Node).Colour := Black;
N (Grandparent_Node).Colour := Red;
Rotate_Left (Pool, Grandparent_Node);
end if;
end if;
end loop;
N (Pool.Root).Colour := Black;
N (Node).In_Tree := True;
end Insert_Node;
------------------------------
-- Max_Priority_For_Subtree --
------------------------------
function Max_Priority_For_Subtree
(Pool : in Pool_Type; Subtree : in Node_Location) return Priority_Type
is
N : Node_Array renames Pool.Nodes;
Max_Priority : Priority_Type;
begin
Max_Priority := Priority_Type'Max
(Priority (N (Subtree).Element), N (Subtree).Left_Priority);
Max_Priority :=
Priority_Type'Max
(Max_Priority, N (Subtree).Right_Priority);
return Max_Priority;
end Max_Priority_For_Subtree;
--------------
-- New_Item --
--------------
procedure New_Item
(Pool : in out Pool_Type;
Item : in Element_Type;
Item_Id : out Node_Location;
Add_To_Tree : in Boolean := True) is
begin
if Is_Pool_Full (Pool) then
-- No more room in the pool!
raise Pool_Capacity_Error with "No room in the pool!";
end if;
Allocate_Node
(Pool => Pool,
New_Node => Item_Id);
Pool.Nodes (Item_Id) := (Colour => Black,
Has_Element => True,
In_Tree => False,
Parent => No_Node,
Left => No_Node,
Right => No_Node,
Left_Priority => First_Priority,
Right_Priority => First_Priority,
Element => Item);
if Add_To_Tree then
Insert_Node
(Pool => Pool,
Node => Item_Id);
end if;
end New_Item;
-----------------
-- Remove_Node --
-----------------
procedure Remove_Node (Pool : in out Pool_Type; Node : in Node_Location)
is
N : Node_Array renames Pool.Nodes;
procedure Fixup (X : in out Node_Location;
Repair_Structure : in Boolean);
function Minimum_Node (X : in Node_Location)
return Node_Location;
procedure Transplant (X, Y : in Node_Location);
-----------
-- Fixup --
-----------
procedure Fixup (X : in out Node_Location; Repair_Structure : Boolean) is
Sibling : Node_Location;
Structure_Repaired : Boolean := not Repair_Structure;
begin
-- While there can exist a point where we no longer need to repair
-- the tree, the same cannot be said for the priority references,
-- particularly when a transplant has occured. Thus we still need
-- to work our way to the root node.
while X /= Pool.Root loop
if X = N (N (X).Parent).Left then
-- X is a left child
-- Fix up priority references
declare
Parent : Node_Type renames N (N (X).Parent);
begin
if X = No_Node then
Parent.Left_Priority := First_Priority;
else
Parent.Left_Priority :=
Max_Priority_For_Subtree (Pool, X);
end if;
end;
-- Fix up tree structure
if not Structure_Repaired then
Sibling := N (N (X).Parent).Right;
if N (Sibling).Colour = Red then
N (Sibling).Colour := Black;
N (N (X).Parent).Colour := Red;
Rotate_Left (Pool, N (X).Parent);
Sibling := N (N (X).Parent).Right;
end if;
if N (N (Sibling).Left).Colour = Black
and then N (N (Sibling).Right).Colour = Black
then
N (Sibling).Colour := Red;
else
if N (N (Sibling).Right).Colour = Black then
N (N (Sibling).Left).Colour := Black;
N (Sibling).Colour := Red;
Rotate_Right (Pool, Sibling);
Sibling := N (N (X).Parent).Right;
end if;
N (Sibling).Colour := N (N (X).Parent).Colour;
N (N (X).Parent).Colour := Black;
N (N (Sibling).Right).Colour := Black;
Rotate_Left (Pool, N (X).Parent);
Structure_Repaired := True;
end if;
end if;
else
-- X is a left child
pragma Assert (X = N (N (X).Parent).Right);
-- Fix up priority references
declare
Parent : Node_Type renames N (N (X).Parent);
begin
if X = No_Node then
Parent.Right_Priority := First_Priority;
else
Parent.Right_Priority :=
Max_Priority_For_Subtree (Pool, X);
end if;
end;
-- Fix up tree structure
if not Structure_Repaired then
Sibling := N (N (X).Parent).Left;
if N (Sibling).Colour = Red then
N (Sibling).Colour := Black;
N (N (X).Parent).Colour := Red;
Rotate_Right (Pool, N (X).Parent);
Sibling := N (N (X).Parent).Left;
end if;
if N (N (Sibling).Right).Colour = Black
and then N (N (Sibling).Left).Colour = Black
then
N (Sibling).Colour := Red;
else
if N (N (Sibling).Left).Colour = Black then
N (N (Sibling).Right).Colour := Black;
N (Sibling).Colour := Red;
Rotate_Left (Pool, Sibling);
Sibling := N (N (X).Parent).Left;
end if;
N (Sibling).Colour := N (N (X).Parent).Colour;
N (N (X).Parent).Colour := Black;
N (N (Sibling).Left).Colour := Black;
Rotate_Right (Pool, N (X).Parent);
Structure_Repaired := True;
end if;
end if;
end if;
X := N (X).Parent;
-- If the colour of the new node is black, the tree structure
-- volations have been resolved. This is normally at the top of
-- CLRS's algorithm as part of the while condition.
if N (X).Colour = Black then
Structure_Repaired := True;
end if;
end loop;
-- The root node is always black.
N (X).Colour := Black;
end Fixup;
------------------
-- Minimum_Node --
------------------
function Minimum_Node (X : in Node_Location) return Node_Location is
Min : Node_Location := X;
begin
while N (Min).Left /= No_Node loop
Min := N (Min).Left;
end loop;
return Min;
end Minimum_Node;
----------------
-- Transplant --
----------------
procedure Transplant (X, Y : in Node_Location) is
begin
if N (X).Parent = No_Node then
Pool.Root := Y;
elsif X = N (N (X).Parent).Left then
N (N (X).Parent).Left := Y;
else
N (N (X).Parent).Right := Y;
end if;
N (Y).Parent := N (X).Parent;
end Transplant;
Replacement_Node : Node_Location;
-- Node that replaces Node when it is removed from the tree.
Fill_Node : Node_Location;
-- The node that fills the spot of the replacement node or the deleted
-- node.
Replacement_Original_Colour : Node_Colour;
begin
Replacement_Node := Node;
Replacement_Original_Colour := N (Replacement_Node).Colour;
if N (Node).Left = No_Node then
Fill_Node := N (Node).Right;
Transplant (Node, Fill_Node);
elsif N (Node).Right = No_Node then
Fill_Node := N (Node).Left;
Transplant (Node, Fill_Node);
else
Replacement_Node := Minimum_Node (N (Node).Right);
Replacement_Original_Colour := N (Replacement_Node).Colour;
Fill_Node := N (Replacement_Node).Right;
if N (Replacement_Node).Parent = Node then
N (Fill_Node).Parent := Replacement_Node;
else
Transplant (Replacement_Node, N (Replacement_Node).Right);
N (Replacement_Node).Right := N (Node).Right;
N (Replacement_Node).Right_Priority := N (Node).Right_Priority;
N (N (Replacement_Node).Right).Parent := Replacement_Node;
end if;
Transplant (Node, Replacement_Node);
N (Replacement_Node).Left := N (Node).Left;
N (Replacement_Node).Left_Priority := N (Node).Left_Priority;
N (N (Replacement_Node).Left).Parent := Replacement_Node;
N (Replacement_Node).Colour := N (Node).Colour;
end if;
if Replacement_Original_Colour = Black then
Fixup (Fill_Node, Repair_Structure => True);
else
Fixup (Fill_Node, Repair_Structure => False);
end if;
N (Node).In_Tree := False;
N (Node).Parent := No_Node;
N (Node).Left := No_Node;
N (Node).Right := No_Node;
end Remove_Node;
------------------
-- Replace_Item --
------------------
procedure Replace_Item
(Pool : in out Pool_Type;
Item_Id : in Node_Location;
Contents : in Element_Type)
is
Node : Node_Type renames Pool.Nodes (Item_Id);
Old_Key : constant Key_Type := Key (Node.Element);
begin
Node.Element := Contents;
if In_Tree (Pool, Item_Id) then
Node_Has_Updated (Pool, Item_Id, Old_Key);
end if;
end Replace_Item;
----------------------
-- Node_Has_Updated --
----------------------
procedure Node_Has_Updated
(Pool : in out Pool_Type;
Node_Id : in Node_Location;
Old_Key : in Key_Type)
is
Node : Node_Type renames Pool.Nodes (Node_Id);
begin
if Key (Node.Element) = Old_Key then
return;
else
Remove_Node (Pool, Node_Id);
Insert_Node (Pool, Node_Id);
end if;
end Node_Has_Updated;
-----------------
-- Rotate_Left --
-----------------
procedure Rotate_Left
(Pool : in out Pool_Type;
Node_Id : in Node_Location)
is
N : Node_Array renames Pool.Nodes;
Old_Head : constant Node_Location := Node_Id;
New_Head : constant Node_Location := N (Old_Head).Right;
begin
-- The procedure takes this tree headed by Old_Head:
--
-- \
-- Old_Head
-- / \
-- A New_Head
-- / \
-- B C
--
-- and transforms it into the tree headed by New_Head:
--
-- \
-- New_Head
-- / \
-- Old_Head C
-- / \
-- A B
--
N (Old_Head).Right := N (New_Head).Left;
if N (New_Head).Left /= No_Node then
N (N (New_Head).Left).Parent := Old_Head;
end if;
N (New_Head).Parent := N (Old_Head).Parent;
if N (Old_Head).Parent = No_Node then
Pool.Root := New_Head;
elsif Old_Head = N (N (Old_Head).Parent).Left then
N (N (Old_Head).Parent).Left := New_Head;
else
pragma Assert (Old_Head = N (N (Old_Head).Parent).Right);
N (N (Old_Head).Parent).Right := New_Head;
end if;
N (New_Head).Left := Old_Head;
N (Old_Head).Parent := New_Head;
-- Update priority branches
N (Old_Head).Right_Priority := N (New_Head).Left_Priority;
-- New_Head's left priority is the maximum of Old_Head's priority and
-- Old_Head's left and right priorities.
N (New_Head).Left_Priority := Max_Priority_For_Subtree (Pool, Old_Head);
end Rotate_Left;
------------------
-- Rotate_Right --
-------------------
-- The procedure takes this tree headed by Old_Head:
--
-- \
-- Old_Head
-- / \
-- New_Head C
-- / \
-- A B
--
-- and transforms it into the tree headed by New_Head:
--
-- \
-- New_Head
-- / \
-- A Old_Head
-- / \
-- B C
--
procedure Rotate_Right
(Pool : in out Pool_Type;
Node_Id : in Node_Location)
is
N : Node_Array renames Pool.Nodes;
Old_Head : constant Node_Location := Node_Id;
New_Head : constant Node_Location := N (Old_Head).Left;
begin
N (Old_Head).Left := N (New_Head).Right;
if N (New_Head).Right /= No_Node then
N (N (New_Head).Right).Parent := Old_Head;
end if;
N (New_Head).Parent := N (Old_Head).Parent;
if N (Old_Head).Parent = No_Node then
Pool.Root := New_Head;
elsif Old_Head = N (N (Old_Head).Parent).Left then
N (N (Old_Head).Parent).Left := New_Head;
else
pragma Assert (Old_Head = N (N (Old_Head).Parent).Right);
N (N (Old_Head).Parent).Right := New_Head;
end if;
N (New_Head).Right := Old_Head;
N (Old_Head).Parent := New_Head;
-- Update priority branches
N (Old_Head).Left_Priority := N (New_Head).Right_Priority;
-- New_Head's right priority is the maximum of Old_Head's priority and
-- Old_Head's left and right priorities.
N (New_Head).Right_Priority := Max_Priority_For_Subtree (Pool, Old_Head);
end Rotate_Right;
end Oak.Storage.Time_Priority_Pool;
|
AdaCore/langkit | Ada | 1,360 | adb | with Ada.Text_IO; use Ada.Text_IO;
with Langkit_Support.Text; use Langkit_Support.Text;
with Libfoolang.Analysis; use Libfoolang.Analysis;
with Support; use Support;
procedure Main is
Buffer : constant String := "example" & ASCII.LF;
Ctx : Analysis_Context;
U : Analysis_Unit;
N : Foo_Node;
Dummy : Boolean;
begin
Put_Line ("main.adb: Starting...");
New_Line;
-- Create an analysis context with our event handler
Ctx := Create_Context (Event_Handler => Create_Event_Handler ("MyEH"));
-- Trigger the "unit parsed" event twice: once for the initial parsing, and
-- once for a reparsing.
Put_Line ("== unit parsed ==");
New_Line;
U := Ctx.Get_From_Buffer (Filename => "main.txt", Buffer => Buffer);
U := Ctx.Get_From_Buffer (Filename => "main.txt", Buffer => Buffer);
-- Trigger the "unit requested" event with various parameters
Put_Line ("== unit requested ==");
New_Line;
N := U.Root;
Dummy := N.P_Trigger_Unit_Requested
(Name => To_Unbounded_Text ("foo_1"), Found => True, Error => False);
Dummy := N.P_Trigger_Unit_Requested
(Name => To_Unbounded_Text ("foo_2"), Found => False, Error => False);
Dummy := N.P_Trigger_Unit_Requested
(Name => To_Unbounded_Text ("foo_3"), Found => False, Error => True);
Put_Line ("main.adb: Done.");
end Main;
|
AdaCore/libadalang | Ada | 241 | adb | procedure Testextreturn is
function Foo return Integer is
begin
return A : Integer do
A := 12;
pragma Test_Statement;
end return;
pragma Test_Statement;
end Foo;
begin
null;
end Testextreturn;
|
jorge-real/TTS-Runtime-Ravenscar | Ada | 2,808 | adb | with Ada.Real_Time; use Ada.Real_Time;
package body TT_Utilities is
---------------------------------
-- Constructors of Time_Slots --
---------------------------------
-- Auxiliary function for constructing slots --
function TT_Slot (Kind : Slot_Type ;
Slot_Duration : Time_Span;
Slot_Id : Positive := Positive'Last;
Padding : Time_Span := Time_Span_Zero)
return TTS.Time_Slot_Access
is
New_Slot : TTS.Time_Slot_Access;
begin
case Kind is
when Empty =>
New_Slot := new TTS.Empty_Slot'(Slot_Duration => Slot_Duration);
when Mode_Change =>
New_Slot := new TTS.Mode_Change_Slot'(Slot_Duration => Slot_Duration);
when Regular | Terminal =>
New_Slot := new TTS.Regular_Slot'(Slot_Duration => Slot_Duration,
Work_Id => TTS.TT_Work_Id(Slot_Id),
Is_Continuation => False,
Padding => Padding);
when Continuation =>
New_Slot := new TTS.Regular_Slot'(Slot_Duration => Slot_Duration,
Work_Id => TTS.TT_Work_Id(Slot_Id),
Is_Continuation => True,
Padding => Padding);
when Optional =>
New_Slot := new TTS.Optional_Slot'(Slot_Duration => Slot_Duration,
Work_Id => TTS.TT_Work_Id(Slot_Id),
Is_Continuation => False,
Padding => Padding);
when Optional_Continuation =>
New_Slot := new TTS.Optional_Slot'(Slot_Duration => Slot_Duration,
Work_Id => TTS.TT_Work_Id(Slot_Id),
Is_Continuation => True,
Padding => Padding);
when Sync =>
New_Slot := new TTS.Sync_Slot'(Slot_Duration => Slot_Duration,
Sync_Id => TTS.TT_Sync_Id(Slot_Id));
end case;
return New_Slot;
end TT_Slot;
procedure Set_TT_Slot (Slot : TTS.Time_Slot_Access;
Kind : Slot_Type;
Slot_Duration : Time_Span;
Slot_Id : Positive := Positive'Last;
Padding : Time_Span := Ada.Real_Time.Time_Span_Zero)
is
begin
null;
end Set_TT_Slot;
end TT_Utilities;
|
reznikmm/matreshka | Ada | 3,769 | ads | ------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- Open Document Toolkit --
-- --
-- Runtime Library Component --
-- --
------------------------------------------------------------------------------
-- --
-- Copyright © 2014, Vadim Godunko <[email protected]> --
-- All rights reserved. --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions --
-- are met: --
-- --
-- * Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- --
-- * Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in the --
-- documentation and/or other materials provided with the distribution. --
-- --
-- * Neither the name of the Vadim Godunko, IE nor the names of its --
-- contributors may be used to endorse or promote products derived from --
-- this software without specific prior written permission. --
-- --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR --
-- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
-- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED --
-- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR --
-- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF --
-- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING --
-- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS --
-- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
-- --
------------------------------------------------------------------------------
-- $Revision$ $Date$
------------------------------------------------------------------------------
with XML.DOM.Attributes;
package ODF.DOM.Style_Text_Underline_Style_Attributes is
pragma Preelaborate;
type ODF_Style_Text_Underline_Style_Attribute is limited interface
and XML.DOM.Attributes.DOM_Attribute;
type ODF_Style_Text_Underline_Style_Attribute_Access is
access all ODF_Style_Text_Underline_Style_Attribute'Class
with Storage_Size => 0;
end ODF.DOM.Style_Text_Underline_Style_Attributes;
|
reznikmm/matreshka | Ada | 4,743 | 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_Presentation.Use_Date_Time_Name_Attributes is
------------
-- Create --
------------
overriding function Create
(Parameters : not null access Matreshka.DOM_Attributes.Attribute_L2_Parameters)
return Presentation_Use_Date_Time_Name_Attribute_Node is
begin
return Self : Presentation_Use_Date_Time_Name_Attribute_Node do
Matreshka.ODF_Presentation.Constructors.Initialize
(Self'Unchecked_Access,
Parameters.Document,
Matreshka.ODF_String_Constants.Presentation_Prefix);
end return;
end Create;
--------------------
-- Get_Local_Name --
--------------------
overriding function Get_Local_Name
(Self : not null access constant Presentation_Use_Date_Time_Name_Attribute_Node)
return League.Strings.Universal_String
is
pragma Unreferenced (Self);
begin
return Matreshka.ODF_String_Constants.Use_Date_Time_Name_Attribute;
end Get_Local_Name;
begin
Matreshka.DOM_Documents.Register_Attribute
(Matreshka.ODF_String_Constants.Presentation_URI,
Matreshka.ODF_String_Constants.Use_Date_Time_Name_Attribute,
Presentation_Use_Date_Time_Name_Attribute_Node'Tag);
end Matreshka.ODF_Presentation.Use_Date_Time_Name_Attributes;
|
rveenker/sdlada | Ada | 4,369 | ads | -- ----------------------------------------------------------------- --
-- AdaSDL --
-- Thin binding to Simple Direct Media Layer --
-- Copyright (C) 2000-2012 A.M.F.Vargas --
-- Antonio M. M. Ferreira Vargas --
-- Manhente - Barcelos - Portugal --
-- http://adasdl.sourceforge.net --
-- E-mail: [email protected] --
-- ----------------------------------------------------------------- --
-- --
-- This library is free software; you can redistribute it and/or --
-- modify it under the terms of the GNU General Public --
-- License as published by the Free Software Foundation; either --
-- version 2 of the License, or (at your option) any later version. --
-- --
-- This library is distributed in the hope that it will be useful, --
-- but WITHOUT ANY WARRANTY; without even the implied warranty of --
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU --
-- General Public License for more details. --
-- --
-- You should have received a copy of the GNU General Public --
-- License along with this library; if not, write to the --
-- Free Software Foundation, Inc., 59 Temple Place - Suite 330, --
-- Boston, MA 02111-1307, USA. --
-- --
-- As a special exception, if other files instantiate generics from --
-- this unit, or you link this unit with other files to produce an --
-- executable, this unit does not by itself cause the resulting --
-- executable to be covered by the GNU General Public License. This --
-- exception does not however invalidate any other reasons why the --
-- executable file might be covered by the GNU Public License. --
-- ----------------------------------------------------------------- --
with Interfaces.C.Pointers;
generic
type The_Element is mod <>;
type The_Element_Array is
array (Interfaces.C.size_t range <>) of aliased The_Element;
package UintN_PtrOps is
package C renames Interfaces.C;
package Operations is
new Interfaces.C.Pointers (
Index => Interfaces.C.size_t,
Element => The_Element,
Element_Array => The_Element_Array,
Default_Terminator => 0);
subtype Pointer is Operations.Pointer;
function Value
(Ref : in Pointer;
Terminator : in The_Element)
return The_Element_Array renames Operations.Value;
function Value
(Ref : in Pointer;
Length : in C.ptrdiff_t)
return The_Element_Array renames Operations.Value;
--------------------------------
-- C-style Pointer Arithmetic --
--------------------------------
function "+" (Left : in Pointer; Right : in C.ptrdiff_t) return Pointer
renames Operations."+";
function "+" (Left : in C.ptrdiff_t; Right : in Pointer) return Pointer
renames Operations."+";
function "-" (Left : in Pointer; Right : in C.ptrdiff_t) return Pointer
renames Operations."-";
function "-" (Left : in Pointer; Right : in Pointer) return C.ptrdiff_t
renames Operations."-";
procedure Increment (Ref : in out Pointer)
renames Operations.Increment;
procedure Decrement (Ref : in out Pointer)
renames Operations.Increment;
function Virtual_Length
(Ref : in Pointer;
Terminator : in The_Element := 0)
return C.ptrdiff_t renames Operations.Virtual_Length;
procedure Copy_Terminated_Array
(Source : in Pointer;
Target : in Pointer;
Limit : in C.ptrdiff_t := C.ptrdiff_t'Last;
Terminator : in The_Element := 0)
renames Operations.Copy_Terminated_Array;
procedure Copy_Array
(Source : in Pointer;
Target : in Pointer;
Length : in C.ptrdiff_t)
renames Operations.Copy_Array;
end UintN_PtrOps;
|
timmyjose-compilers/arithmetic-expression-evaluator-in-ada | Ada | 1,046 | adb | package body My_Custom_Int is
function Image (E : in My_Custom_Int) return String is
begin
return "My_Custom_Int { Int_Val = " & Integer'Image (E.Int_Val) & " }";
end Image;
function "=" (L, R : in My_Custom_Int) return Boolean is
begin
return L.Int_Val = R.Int_Val;
end "=";
function "+" (L, R : in My_Custom_Int) return My_Custom_Int is
Temp : My_Custom_Int;
begin
Temp.Int_Val := L.Int_Val + R.Int_Val;
return Temp;
end "+";
function "-" (L, R : in My_Custom_Int) return My_Custom_Int is
Temp : My_Custom_Int;
begin
Temp.Int_Val := L.Int_Val - R.Int_Val;
return Temp;
end "-";
function "*" (L, R : in My_Custom_Int) return My_Custom_Int is
Temp : My_Custom_Int;
begin
Temp.Int_Val := L.Int_Val * R.Int_Val;
return Temp;
end "*";
function "/" (L, R : in My_Custom_Int) return My_Custom_Int is
Temp : My_Custom_Int;
begin
Temp.Int_Val := L.Int_Val / R.Int_Val;
return Temp;
end "/";
end My_Custom_Int;
|
albinjal/ada_basic | Ada | 1,244 | adb | with Date_Package; use Date_Package;
with Ada.Text_IO; use Ada.Text_IO;
package body Person_Handling is
function "="(Person1, Person2: in Person) return Boolean is
begin
return Person1.Birth = Person2.Birth;
end;
function ">"(Person1, Person2: in Person) return Boolean is
begin
return Person1.Birth > Person2.Birth;
end;
function "<"(Person1, Person2: in Person) return Boolean is
begin
return Person1.Birth < Person2.Birth;
end;
procedure Put(Pers: in Person) is
begin
Put(Pers.Name(1..Pers.Name_Length)); Put(" ");
Put(Pers.Address(1..Pers.Address_Length)); Put(" ");
Put(Pers.Birth); Put(" ");
end Put;
procedure Get(Pers: out Person) is
Name: String(1..20);
Address: String(1..20);
Birth: Date_Type;
begin
Put("Namn: ");
Get_Line(Pers.Name, Pers.Name_Length);
if Pers.Name_Length >= 20 then Skip_Line; end if;
Put("Adress: ");
Get_Line(Pers.Address, Pers.Address_Length);
if Pers.Address_Length >= 20 then Skip_Line; end if;
Put("Födelsedatum: ");
Get(Pers.Birth);
Skip_Line;
end Get;
end Person_Handling; |
Fabien-Chouteau/pygamer-simulator | Ada | 7,932 | adb | with Ada.Exceptions;
with GNAT.OS_Lib;
with Ada.Text_IO; use Ada.Text_IO;
with Sf.Window.VideoMode; use Sf.Window.VideoMode;
with Sf.Graphics; use Sf.Graphics;
with Sf.Graphics.Sprite; use Sf.Graphics.Sprite;
with Sf.Graphics.Texture; use Sf.Graphics.Texture;
with Sf.Graphics.RenderTexture; use Sf.Graphics.RenderTexture;
with Sf.Graphics.View; use Sf.Graphics.View;
with Sf.Graphics.RenderWindow; use Sf.Graphics.RenderWindow;
with Sf.Window.Window; use Sf.Window.Window;
with Sf.Window.Event; use Sf.Window.Event;
with Sf.Window.Keyboard; use Sf.Window.Keyboard;
with Sf; use Sf;
with Ada.Real_Time; use Ada.Real_Time;
with Sf.System.Vector2; use Sf.System.Vector2;
with Ada.Unchecked_Conversion;
with simulator_assets;
package body PyGamer is
function Hack_SF_Binding is new Ada.Unchecked_Conversion (sfSprite_Ptr,
sfView_Ptr);
--------------
-- Set_View --
--------------
procedure Set_View (View : Sf.Graphics.sfView_Ptr;
Width, Height : sfUint32)
is
Win_Ratio : constant Float := Float (Width) / Float (Height);
View_Ratio : constant Float := Float (getSize (View).x) / Float (getSize (View).y);
Size_X : Float := 1.0;
Size_Y : Float := 1.0;
Pos_X : Float := 0.0;
Pos_Y : Float := 0.0;
Horizontal_Spacing : Boolean := True;
begin
if Win_Ratio < View_Ratio then
Size_Y := Win_Ratio / View_Ratio;
Pos_Y := (1.0 - Size_Y) / 2.0;
else
Size_X := View_Ratio / Win_Ratio;
Pos_X := (1.0 - Size_X) / 2.0;
end if;
setViewport (View, (Pos_X, Pos_Y, Size_X, Size_Y));
end Set_View;
task Periodic_Update is
end Periodic_Update;
---------------------
-- Periodic_Update --
---------------------
task body Periodic_Update is
BG_Width : constant := 730;
BG_Height : constant := 411;
Mode : constant Sf.Window.VideoMode.sfVideoMode :=
(BG_Width, BG_Height, 32);
Params : sfContextSettings := sfDefaultContextSettings;
Window : Sf.Graphics.sfRenderWindow_Ptr;
Framebuffer_Texture : Sf.Graphics.sfTexture_Ptr;
Render_Texture : Sf.Graphics.sfRenderTexture_Ptr;
PG_Texture : Sf.Graphics.sfTexture_Ptr;
PG_Sprite : Sf.Graphics.sfSprite_Ptr;
Screen_Sprite : Sf.Graphics.sfSprite_Ptr;
Sprite_Left : Sf.Graphics.sfSprite_Ptr;
Sprite_Right : Sf.Graphics.sfSprite_Ptr;
Letter_Box_View : Sf.Graphics.sfView_Ptr;
Event : sfEvent;
Period : constant Time_Span := Milliseconds (1000 / 60);
Next_Release : Time := Clock + Period;
Pressed : Boolean;
Screen_Scale : constant := 287.0 / Float (Screen_Width);
Screen_Offset : constant sfVector2f := (231.0, 66.0);
begin
Framebuffer_Texture := Create (Screen_Width, Screen_Height);
if Framebuffer_Texture = null then
Put_Line ("Failed to create screen texture");
GNAT.OS_Lib.OS_Exit (1);
end if;
declare
Ptr : constant simulator_assets.Content_Access :=
simulator_assets.Get_Content ("pygamer.png").Content;
begin
PG_Texture := createFromMemory (Ptr.all'Address, Ptr.all'Length);
end;
if PG_Texture = null then
Put_Line ("Failed to create PyGamer texture");
GNAT.OS_Lib.OS_Exit (1);
end if;
Render_Texture := create (Screen_Width, Screen_Height, False);
if Render_Texture = null then
Put_Line ("Could not create render texture");
GNAT.OS_Lib.OS_Exit (1);
end if;
Screen_Sprite := Create;
if Screen_Sprite = null then
Put_Line ("Could not create screen sprite");
GNAT.OS_Lib.OS_Exit (1);
end if;
SetTexture (Screen_Sprite, getTexture (Render_Texture));
scale (Screen_Sprite, (Screen_Scale, Screen_Scale));
setPosition (Screen_Sprite, Screen_Offset);
Sprite_Left := Create;
if Sprite_Left = null then
Put_Line ("Could not create sprite");
GNAT.OS_Lib.OS_Exit (1);
end if;
SetTexture (Sprite_Left, Framebuffer_Texture);
Sprite_Right := Create;
if Sprite_Right = null then
Put_Line ("Could not create sprite");
GNAT.OS_Lib.OS_Exit (1);
end if;
SetTexture (Sprite_Right, Framebuffer_Texture);
PG_Sprite := Create;
if PG_Sprite = null then
Put_Line ("Could not create sprite");
GNAT.OS_Lib.OS_Exit (1);
end if;
SetTexture (PG_Sprite, PG_Texture);
Window := Create (Mode, "PyGamer simulator", sfResize or sfClose, Params);
if Window = null then
Put_Line ("Failed to create window");
GNAT.OS_Lib.OS_Exit (1);
end if;
SetVerticalSyncEnabled (Window, sfFalse);
SetVisible (Window, sfTrue);
Letter_Box_View := create;
if Letter_Box_View = null then
Put_Line ("Failed to create view");
GNAT.OS_Lib.OS_Exit (1);
end if;
setSize (Letter_Box_View, (Float (BG_Width), Float (BG_Height)));
setCenter (Letter_Box_View,
(Float (BG_Width) / 2.0, Float (BG_Height) / 2.0));
Set_View (Letter_Box_View, getSize (Window).x, getSize (Window).y);
loop
delay until Next_Release;
Next_Release := Next_Release + Period;
while pollEvent (Window, Event) loop
if Event.eventType = sfEvtClosed then
Close (Window);
Put_Line ("Attempting to close");
GNAT.OS_Lib.OS_Exit (0);
end if;
if Event.eventType = sfEvtResized then
Set_View (Letter_Box_View, Event.size.width, Event.size.height);
end if;
if Event.eventType in sfEvtKeyPressed | sfEvtKeyReleased then
Pressed := Event.eventType = sfEvtKeyPressed;
case Event.key.code is
when sfKeyLeft =>
SFML_Pressed (Left) := Pressed;
when sfKeyRight =>
SFML_Pressed (Right) := Pressed;
when sfKeyDown =>
SFML_Pressed (Down) := Pressed;
when sfKeyUp =>
SFML_Pressed (Up) := Pressed;
when sfKeyZ =>
SFML_Pressed (B) := Pressed;
when sfKeyX =>
SFML_Pressed (A) := Pressed;
when sfKeyReturn =>
SFML_Pressed (Start) := Pressed;
when sfKeyC =>
SFML_Pressed (Sel) := Pressed;
when sfKeyEscape =>
Close (Window);
Put_Line ("Attempting to close");
GNAT.OS_Lib.OS_Exit (0);
when others =>
null;
end case;
end if;
end loop;
updateFromPixels (texture => Framebuffer_Texture,
pixels => Frame_Buffer (Frame_Buffer'First)'access,
width => Screen_Width,
height => Screen_Height,
x => 0,
y => 0);
setPosition (Sprite_Right,
(Float (Scroll_Val) - Float (Screen_Width), 0.0));
setPosition (Sprite_Left,
(Float (Scroll_Val), 0.0));
drawSprite (Render_Texture, Hack_SF_Binding (Sprite_Right));
drawSprite (Render_Texture, Hack_SF_Binding (Sprite_Left));
display (Render_Texture);
clear (Window);
drawSprite (Window, PG_Sprite);
drawSprite (Window, Screen_Sprite);
setView (Window, Letter_Box_View);
display (Window);
end loop;
exception
when E : others =>
Put_Line (Ada.Exceptions.Exception_Message (E));
GNAT.OS_Lib.OS_Exit (1);
end Periodic_Update;
end PyGamer;
|
matthieun/Ada-Synthetizer | Ada | 9,320 | adb | -- The Beer-Ware License (revision 42)
--
-- Jacob Sparre Andersen <[email protected]> wrote this. As long as you
-- retain this notice you can do whatever you want with this stuff. If we meet
-- some day, and you think this stuff is worth it, you can buy me a beer in
-- return.
--
-- Jacob Sparre Andersen
with
Interfaces.C.Strings;
package body Sound.Mono is
procedure Close (Line : in out Line_Type) is
use type Interfaces.C.int;
Error : Interfaces.C.int;
begin
Error := snd_pcm_close (Line);
if Error /= 0 then
raise Program_Error with "snd_pcm_close failed: " & Error'Img;
end if;
end Close;
function Is_Open (Line : in Line_Type) return Boolean is
use Sound.ALSA;
begin
case snd_pcm_state (Line) is
when Prepared | Running =>
return True;
when Open | Setup | XRun | Draining | Paused | Suspended
| Disconnected =>
return False;
end case;
end Is_Open;
procedure Open (Line : in out Line_Type;
Mode : in Line_Mode;
Resolution : in out Sample_Frequency;
Buffer_Size : in out Duration;
Period : in out Duration) is
use Interfaces.C, Interfaces.C.Strings, Sound.ALSA;
Name : aliased char_array := To_C ("plughw:0,0");
Error : Interfaces.C.int;
Local_Line : aliased Line_Type := Line;
Settings : aliased Sound.ALSA.snd_pcm_hw_params_t;
begin
Error := snd_pcm_open (pcmp => Local_Line'Access,
name => To_Chars_Ptr (Name'Unchecked_Access),
stream => Sound.ALSA.Value (Mode),
mode => 0);
if Error /= 0 then
raise Program_Error with "Error code (snd_pcm_open): " & Error'Img;
end if;
Clear_Settings :
begin
Error := snd_pcm_hw_params_any (pcm => Local_Line,
params => Settings'Access);
if Error /= 0 then
raise Program_Error with
"Error code (snd_pcm_hw_params_any): " & Error'Img;
end if;
end Clear_Settings;
Set_Resampling_Rate :
begin
Error := snd_pcm_hw_params_set_rate_resample
(pcm => Local_Line,
params => Settings'Access,
val => False);
if Error /= 0 then
raise Program_Error with
"Error code (snd_pcm_hw_params_set_rate_resample): " & Error'Img;
end if;
end Set_Resampling_Rate;
Set_Sampling_Layout :
begin
Error := snd_pcm_hw_params_set_access
(pcm => Local_Line,
params => Settings'Access,
val => Read_Write_Interleaved);
if Error /= 0 then
raise Program_Error with
"Error code (snd_pcm_hw_params_set_access): " & Error'Img;
end if;
end Set_Sampling_Layout;
Set_Recording_Format :
begin
Error := snd_pcm_hw_params_set_format
(pcm => Local_Line,
params => Settings'Access,
format => Sound.ALSA.Signed_16_Bit);
if Error /= 0 then
raise Program_Error with
"Error code (snd_pcm_hw_params_set_format): " & Error'Img;
end if;
end Set_Recording_Format;
Set_Channel_Count :
begin
Error := snd_pcm_hw_params_set_channels
(pcm => Local_Line,
params => Settings'Access,
val => 1);
if Error /= 0 then
raise Program_Error with
"Error code (snd_pcm_hw_params_set_channels): " & Error'Img;
end if;
end Set_Channel_Count;
Set_Sample_Frequency :
declare
Sample_Rate : aliased Interfaces.C.unsigned :=
Interfaces.C.unsigned (Resolution);
Approximation : aliased Sound.ALSA.Approximation_Direction := 0;
begin
Error := snd_pcm_hw_params_set_rate_near
(pcm => Local_Line,
params => Settings'Access,
val => Sample_Rate'Access,
dir => Approximation'Access);
if Error /= 0 then
raise Program_Error with
"Error code (snd_pcm_hw_params_set_rate_near): " & Error'Img;
end if;
Resolution := Sample_Frequency (Sample_Rate);
end Set_Sample_Frequency;
Set_Buffer_Time :
declare
Buffer_Time : aliased Interfaces.C.unsigned :=
Interfaces.C.unsigned (1_000_000 * Buffer_Size);
Approximation : aliased Sound.ALSA.Approximation_Direction := 0;
begin
Error := snd_pcm_hw_params_set_buffer_time_near
(pcm => Local_Line,
params => Settings'Access,
val => Buffer_Time'Access,
dir => Approximation'Access);
if Error /= 0 then
raise Program_Error with
"Error code (snd_pcm_hw_params_set_buffer_time_near): " &
Error'Img;
end if;
Buffer_Size := Duration (Buffer_Time) / 1_000_000.0;
end Set_Buffer_Time;
Set_Period :
declare
Period_Time : aliased Interfaces.C.unsigned :=
Interfaces.C.unsigned (1_000_000 * Period);
Approximation : aliased Sound.ALSA.Approximation_Direction := 0;
begin
Error := snd_pcm_hw_params_set_period_time_near
(pcm => Local_Line,
params => Settings'Access,
val => Period_Time'Access,
dir => Approximation'Access);
if Error /= 0 then
raise Program_Error with
"Error code (snd_pcm_hw_params_set_period_time_near): " &
Error'Img;
end if;
Period := Duration (Period_Time) / 1_000_000.0;
end Set_Period;
Register_Settings :
begin
Error := snd_pcm_hw_params (pcm => Local_Line,
params => Settings'Access);
if Error /= 0 then
raise Program_Error with
"Error code (snd_pcm_hw_params): " & Error'Img;
end if;
end Register_Settings;
Line := Local_Line;
end Open;
procedure Read (Line : in Line_Type;
Item : out Frame_Array;
Last : out Natural) is
pragma Unmodified (Item); -- As we cheat with "function snd_pcm_readi".
function snd_pcm_readi (pcm : in Line_Type;
buffer : in Frame_Array; -- actually "out"
size : in ALSA.snd_pcm_uframes_t)
return ALSA.snd_pcm_sframes_t;
pragma Import (C, snd_pcm_readi);
use type Sound.ALSA.snd_pcm_sframes_t;
Received_Frame_Count : Sound.ALSA.snd_pcm_sframes_t;
begin
Received_Frame_Count := snd_pcm_readi (pcm => Line,
buffer => Item,
size => Item'Length);
if Received_Frame_Count < 0 then
raise Program_Error with
"snd_pcm_readi failed: " & Received_Frame_Count'Img;
else
Last := Item'First - 1 + Natural (Received_Frame_Count);
end if;
end Read;
procedure Write (Line : in Line_Type;
Item : in Frame_Array;
Last : out Natural) is
function snd_pcm_writei (pcm : in Line_Type;
buffer : in Frame_Array;
size : in ALSA.snd_pcm_uframes_t)
return ALSA.snd_pcm_sframes_t;
pragma Import (C, snd_pcm_writei);
function snd_pcm_recover (pcm : in Line_Type;
frames : in ALSA.snd_pcm_sframes_t;
i : in Interfaces.C.int)
return ALSA.snd_pcm_sframes_t;
pragma Import (C, snd_pcm_recover);
use type Sound.ALSA.snd_pcm_sframes_t;
-- use type Interfaces.C.int;
Written_Frame_Count : Sound.ALSA.snd_pcm_sframes_t;
-- RetCode : Interfaces.C.int;
begin
-- RetCode := snd_pcm_drain (Line);
-- if RetCode < 0 then
-- raise Program_Error with
-- "snd_pcm_drain failed: " & Integer'Image (Integer (RetCode));
-- end if;
Written_Frame_Count := snd_pcm_writei (pcm => Line,
buffer => Item,
size => Item'Length);
if Written_Frame_Count < 0 then
Written_Frame_Count := snd_pcm_recover (Line,
Written_Frame_Count, 0);
end if;
if Written_Frame_Count < 0 then
raise Program_Error with
"snd_pcm_writei failed: " & Written_Frame_Count'Img;
else
Last := Item'First - 1 + Natural (Written_Frame_Count);
end if;
end Write;
end Sound.Mono;
|
tum-ei-rcs/StratoX | Ada | 1,264 | ads | -- Institution: Technische Universität München
-- Department: Realtime Computer Systems (RCS)
-- Project: StratoX
-- Module: Helper
--
-- Authors: Emanuel Regnath ([email protected])
--
-- Description: Helper functions
--
-- ToDo:
-- [ ] Implementation
package Helper with SPARK_Mode is
generic
type Numeric_Type is range <>;
function addWrap(x : Numeric_Type;
inc : Numeric_Type) return Numeric_Type;
-- function deltaWrap(
-- low : Integer;
-- high : Integer)
-- return Integer
-- is ( if low < high then (high - low)
-- else (high'Last - low) + (high - low'First) );
-- to polar
procedure delay_ms (ms : Natural);
-- Saturate a Float value within a given range.
function Saturate
(Value : Float;
Min_Value : Float;
Max_Value : Float) return Float is
(if Value < Min_Value then
Min_Value
elsif Value > Max_Value then
Max_Value
else
Value);
pragma Inline (Saturate);
subtype Sign_Type is Float range -1.0 .. 1.0;
function sgn( x : Float ) return Sign_Type is
( if x = 0.0 then 0.0 elsif x > 0.0 then 1.0 else -1.0 );
end Helper;
|
reznikmm/matreshka | Ada | 3,779 | 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.Table_Bind_Styles_To_Content_Attributes is
pragma Preelaborate;
type ODF_Table_Bind_Styles_To_Content_Attribute is limited interface
and XML.DOM.Attributes.DOM_Attribute;
type ODF_Table_Bind_Styles_To_Content_Attribute_Access is
access all ODF_Table_Bind_Styles_To_Content_Attribute'Class
with Storage_Size => 0;
end ODF.DOM.Table_Bind_Styles_To_Content_Attributes;
|
reznikmm/matreshka | Ada | 14,793 | ads | ------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- Web Framework --
-- --
-- Tools 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$
------------------------------------------------------------------------------
-- Declaration of WSDL assertions and violation reporting utilities.
------------------------------------------------------------------------------
with League.Strings;
with WSDL.Diagnoses;
package WSDL.Assertions is
type WSDL_Assertion is
(Description_1001,
-- The value of the targetNamespace attribute information item SHOULD be
-- dereferencable.
Description_1002,
-- It SHOULD resolve to a human or machine processable document that
-- directly or indirectly defines the intended semantics of those
-- components.
Description_1003,
-- It MAY resolve to a WSDL 2.0 document that provides service
-- description information for that namespace.
Description_1004,
-- If a WSDL 2.0 document is split into multiple WSDL 2.0 documents
-- (which may be combined as needed via 4.1 Including Descriptions),
-- then the targetNamespace attribute information item SHOULD resolve to
-- a master WSDL 2.0 document that includes all the WSDL 2.0 documents
-- needed for that service description.
Description_1005,
-- Zero or more element information items amongst its [children], in
-- order as follows:
Description_1006,
-- Its value MUST be an absolute IRI (see [IETF RFC 3987]) and should be
-- dereferencable.
Types_1007,
-- Each XML Schema element declaration MUST have a unique QName.
Types_1008,
-- Each XML Schema type definition MUST have a unique QName.
Interface_1009,
-- To avoid circular definitions, an interface MUST NOT appear in the
-- set of interfaces it extends, either directly or indirectly.
Interface_1010,
-- For each Interface component in the {interfaces} property of a
-- Description component, the {name} property MUST be unique.
Interface_1011,
-- The list of xs:QName in an extends attribute information item MUST
-- NOT contain duplicates.
Interface_1012,
-- Its value, if present, MUST contain absolute IRIs (see [IETF RFC
-- 3987]).
InterfaceFault_1013,
-- An xs:token with one of the values #any, #none, #other, or #element.
InterfaceFault_1014,
-- When the {message content model} property has the value #any or #none
-- the {element declaration} property MUST be empty.
InterfaceFault_1015,
-- In cases where, due to an interface extending one or more other
-- interfaces, two or more Interface Fault components have the same
-- value for their {name} property, then the component models of those
-- Interface Fault components MUST be equivalent (see 2.15 Equivalence
-- of Components).
InterfaceFault_1016,
-- For the above reason, it is considered good practice to ensure, where
-- necessary, that the local name of the {name} property of Interface
-- Fault components within a namespace SHOULD be unique, thus allowing
-- such derivation to occur without inadvertent error.
InterfaceFault_1017,
-- If the element attribute information item has a value, then it MUST
-- resolve to an Element Declaration component from the {element
-- declarations} property of the Description component.
InterfaceOperation_1018,
-- This xs:anyURI MUST be an absolute IRI (see [IETF RFC 3987]).
InterfaceOperation_1019,
-- These xs:anyURIs MUST be absolute IRIs (see [IETF RFC 3986]).
InterfaceOperation_1020,
-- In cases where, due to an interface extending one or more other
-- interfaces, two or more Interface Operation components have the same
-- value for their {name} property, then the component models of those
-- Interface Operation components MUST be equivalent (see 2.15
-- Equivalence of Components).
InterfaceOperation_1021,
-- For the above reason, it is considered good practice to ensure, where
-- necessary, that the {name} property of Interface Operation components
-- within a namespace SHOULD be unique, thus allowing such derivation to
-- occur without inadvertent error.
MEP_1022,
-- A message exchange pattern is itself uniquely identified by an
-- absolute IRI, which is used as the value of the {message exchange
-- pattern} property of the Interface Operation component, and which
-- specifies the fault propagation ruleset that its faults obey.
InterfaceOperation_1023,
-- An Interface Operation component MUST satisfy the specification
-- defined by each operation style identified by its {style} property.
MessageLabel_1024,
-- The value of this property MUST match the name of a placeholder
-- message defined by the message exchange pattern.
InterfaceMessageReference_1025,
-- An xs:token with one of the values in or out, indicating whether the
-- message is coming to the service or going from the service,
-- respectively.
InterfaceMessageReference_1026,
-- The direction MUST be the same as the direction of the message
-- identified by the {message label} property in the {message exchange
-- pattern} of the Interface Operation component this is contained
-- within.
InterfaceMessageReference_1027,
-- An xs:token with one of the values #any, #none, #other, or #element.
InterfaceMessageReference_1028,
-- When the {message content model} property has the value #any or
-- #none, the {element declaration} property MUST be empty.
InterfaceMessageReference_1029,
-- For each Interface Message Reference component in the {interface
-- message references} property of an Interface Operation component, its
-- {message label} property MUST be unique.
MessageLabel_1030,
-- If the messageLabel attribute information item of an interface
-- message reference element information item is present, then its
-- actual value MUST match the {message label} of some placeholder
-- message with {direction} equal to the message direction.
MessageLabel_1031,
-- If the messageLabel attribute information item of an interface
-- message reference element information item is absent then there MUST
-- be a unique placeholder message with {direction} equal to the message
-- direction.
MessageLabel_1032,
-- If the local name is input then the message exchange pattern MUST
-- have at least one placeholder message with direction "In".
MessageLabel_1033,
-- If the local name is output then the message exchange pattern MUST
-- have at least one placeholder message with direction "Out".
MessageLabel_1034,
-- If the local name is infault then the message exchange pattern MUST
-- support at least one fault in the "In" direction.
MessageLabel_1035,
-- If the local name is outfault then the message exchange pattern MUST
-- support at least one fault in the "Out" direction.
InterfaceFaultReference_1037,
-- The value of this property MUST match the name of a placeholder
-- message defined by the message exchange pattern.
InterfaceFaultReference_1038,
-- The direction MUST be consistent with the direction implied by the
-- fault propagation ruleset used in the message exchange pattern of the
-- operation.
InterfaceFaultReference_1039,
-- For each Interface Fault Reference component in the {interface fault
-- references} property of an Interface Operation component, the
-- combination of its {interface fault} and {message label} properties
-- MUST be unique.
InterfaceFaultReference_1040,
-- The messageLabel attribute information item MUST be present in the
-- XML representation of an Interface Fault Reference component with a
-- given {direction}, if the {message exchange pattern} of the parent
-- Interface Operation component has more than one fault with that
-- direction.
MessageLabel_1041,
-- The messageLabel attribute information item of an interface fault
-- reference element information item MUST be present if the message
-- exchange pattern has more than one placeholder message with
-- {direction} equal to the message direction.
MessageLabel_1042,
-- If the messageLabel attribute information item of an interface fault
-- reference element information item is present then its actual value
-- MUST match the {message label} of some placeholder message with
-- {direction} equal to the message direction.
MessageLabel_1043,
-- If the messageLabel attribute information item of an interface fault
-- reference element information item is absent then there MUST be a
-- unique placeholder message with {direction} equal to the message
-- direction.
Binding_1044,
-- If a Binding component specifies any operation-specific binding
-- details (by including Binding Operation components) or any fault
-- binding details (by including Binding Fault components), then it MUST
-- specify an interface the Binding component applies to, so as to
-- indicate which interface the operations come from.
Binding_1045,
-- A Binding component that defines bindings for an Interface component
-- MUST define bindings for all the operations of that Interface
-- component.
Binding_1046,
-- Similarly, whenever a reusable Binding component (i.e. one that does
-- not specify an Interface component) is applied to a specific
-- Interface component in the context of an Endpoint component (see
-- 2.13.1 The Endpoint Component), the Binding component MUST define
-- bindings for each Interface Operation and Interface Fault component
-- of the Interface component, via a combination of properties defined
-- on the Binding component itself and default binding rules specific to
-- its binding type.
Binding_1047,
-- A Binding component that defines bindings for an Interface component
-- MUST define bindings for all the faults of that Interface component
-- that are referenced from any of the operations in that Interface
-- component.
Binding_1048,
-- This xs:anyURI MUST be an absolute IRI as defined by [IETF RFC 3987].
Binding_1049,
-- For each Binding component in the {bindings} property of a
-- Description component, the {name} property MUST be unique.
BindingFault_1050,
-- For each Binding Fault component in the {binding faults} property of
-- a Binding component, the {interface fault} property MUST be unique.
BindingOperation_1051);
-- For each Binding Operation component in the {binding operations}
-- property of a Binding component, the {interface operation} property
-- MUST be unique.
procedure Report
(File : League.Strings.Universal_String;
Line : WSDL.Diagnoses.Line_Number;
Column : WSDL.Diagnoses.Column_Number;
Assertion : WSDL_Assertion);
-- Reports assertion.
end WSDL.Assertions;
|
AdaCore/Ada_Drivers_Library | Ada | 11,582 | adb | ------------------------------------------------------------------------------
-- --
-- Copyright (C) 2020, AdaCore --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions are --
-- met: --
-- 1. Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- 2. Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in --
-- the documentation and/or other materials provided with the --
-- distribution. --
-- 3. Neither the name of AdaCore nor the names of its --
-- contributors may be used to endorse or promote products derived --
-- from this software without specific prior written permission. --
-- --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR --
-- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
-- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT --
-- LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, --
-- DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY --
-- THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT --
-- (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE --
-- OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
-- --
------------------------------------------------------------------------------
package body PCD8544 is
-------------------
-- Chip_Select --
-------------------
procedure Chip_Select (This : PCD8544_Device; Enabled : in Boolean)
is
begin
if This.CS /= null then
if Enabled then
This.CS.Clear;
else
This.CS.Set;
end if;
end if;
end Chip_Select;
-------------
-- Reset --
-------------
procedure Reset (This : in out PCD8544_Device) is
begin
if This.RST /= null then
This.RST.Clear;
This.RST.Set;
-- The datasheet specifies 100ns minimum for reset but this was
-- unreliable in testing, so we use a longer delay.
This.Time.Delay_Microseconds (100);
end if;
end Reset;
----------------
-- Transmit --
----------------
procedure Transmit (This : PCD8544_Device; Data : in UInt8) is
Status : SPI_Status;
begin
This.Chip_Select (True);
This.DC.Clear;
This.Port.Transmit (SPI_Data_8b'(1 => Data), Status);
This.Chip_Select (False);
if Status /= Ok then
raise SPI_Error with "PCD8544 SPI command transmit failed: " & Status'Image;
end if;
end Transmit;
----------------
-- Transmit --
----------------
procedure Transmit (This : PCD8544_Device; Data : in UInt8_Array) is
Status : SPI_Status;
begin
This.Chip_Select (True);
This.DC.Set;
This.Port.Transmit (SPI_Data_8b (Data), Status);
This.Chip_Select (False);
if Status /= Ok then
raise SPI_Error with "PCD8544 SPI data transmit failed: " & Status'Image;
end if;
end Transmit;
---------------------
-- Extended_Mode --
---------------------
procedure Extended_Mode (This : in out PCD8544_Device) is
begin
if This.FR.Extended_Mode /= True then
This.FR.Extended_Mode := True;
This.Transmit (PCD8544_CMD_FUNCTION or Convert (This.FR));
end if;
end Extended_Mode;
------------------
-- Basic_Mode --
------------------
procedure Basic_Mode (This : in out PCD8544_Device) is
begin
if This.FR.Extended_Mode /= False then
This.FR.Extended_Mode := False;
This.Transmit (PCD8544_CMD_FUNCTION or Convert (This.FR));
end if;
end Basic_Mode;
--------------------
-- Set_Contrast --
--------------------
procedure Set_Contrast
(This : in out PCD8544_Device;
Contrast : in PCD8544_Contrast) is
begin
This.Extended_Mode;
This.Transmit (PCD8544_CMD_SET_VOP or Contrast);
end Set_Contrast;
----------------
-- Set_Bias --
----------------
procedure Set_Bias
(This : in out PCD8544_Device;
Bias : in PCD8544_Bias) is
begin
This.Extended_Mode;
This.Transmit (PCD8544_CMD_SET_BIAS or Bias);
end Set_Bias;
-----------------------
-- Set_Temperature --
-----------------------
procedure Set_Temperature
(This : in out PCD8544_Device;
TC : in PCD8544_Temperature_Coefficient) is
begin
This.Extended_Mode;
This.Transmit (PCD8544_CMD_SET_TC or TC);
end Set_Temperature;
------------------------
-- Set_Display_Mode --
------------------------
procedure Set_Display_Mode
(This : in out PCD8544_Device;
Enable : in Boolean;
Invert : in Boolean) is
begin
This.Basic_Mode;
This.DR.Enable := Enable;
This.DR.Invert := Invert;
This.Transmit (PCD8544_CMD_DISPLAY or Convert (This.DR));
end Set_Display_Mode;
------------------
-- Initialize --
------------------
procedure Initialize (This : in out PCD8544_Device) is
Default_FR : PCD8544_Function_Register;
Default_DR : PCD8544_Display_Register;
begin
This.DC.Clear;
This.Reset;
This.FR := Default_FR;
This.DR := Default_DR;
-- Power on must be separate from other commands.
This.FR.Power_Down := False;
This.Transmit (PCD8544_CMD_FUNCTION or Convert (This.FR));
This.Set_Contrast (PCD8544_Default_Contrast);
This.Set_Bias (PCD8544_Default_Bias);
This.Set_Temperature (PCD8544_Default_Temperature_Coefficient);
This.FR.Extended_Mode := False;
This.FR.Address_Mode := Vertical;
This.Transmit (PCD8544_CMD_FUNCTION or Convert (This.FR));
This.Set_Display_Mode
(Enable => True,
Invert => True);
This.Device_Initialized := True;
end Initialize;
------------------------
-- Write_Raw_Pixels --
------------------------
procedure Write_Raw_Pixels
(This : in out PCD8544_Device;
Data : UInt8_Array)
is
begin
This.Chip_Select (True);
This.Basic_Mode;
This.Transmit (PCD8544_CMD_SET_X or 0);
This.Transmit (PCD8544_CMD_SET_Y or 0);
This.Transmit (Data);
This.Chip_Select (False);
end Write_Raw_Pixels;
-------------------
-- Initialized --
-------------------
overriding function Initialized (This : PCD8544_Device) return Boolean is
(This.Device_Initialized);
------------------
-- Max_Layers --
------------------
overriding function Max_Layers (This : PCD8544_Device) return Positive is
(1);
-----------------
-- Supported --
-----------------
overriding function Supported
(This : PCD8544_Device; Mode : FB_Color_Mode) return Boolean is
(Mode = HAL.Bitmap.M_1);
-----------------------
-- Set_Orientation --
-----------------------
overriding procedure Set_Orientation
(This : in out PCD8544_Device; Orientation : Display_Orientation)
is
begin
null;
end Set_Orientation;
----------------
-- Set_Mode --
----------------
overriding procedure Set_Mode
(This : in out PCD8544_Device; Mode : Wait_Mode) is null;
-------------
-- Width --
-------------
overriding function Width (This : PCD8544_Device) return Positive is
(Device_Width);
--------------
-- Height --
--------------
overriding function Height (This : PCD8544_Device) return Positive is
(Device_Height);
---------------
-- Swapped --
---------------
overriding function Swapped (This : PCD8544_Device) return Boolean is
(False);
----------------------
-- Set_Background --
----------------------
overriding procedure Set_Background (This : PCD8544_Device; R, G, B : UInt8)
is
begin
raise Program_Error;
end Set_Background;
------------------------
-- Initialize_Layer --
------------------------
overriding procedure Initialize_Layer
(This : in out PCD8544_Device;
Layer : Positive;
Mode : FB_Color_Mode;
X, Y : Natural := 0;
Width : Positive := Positive'Last;
Height : Positive := Positive'Last)
is
pragma Unreferenced (X, Y, Width, Height);
begin
if Layer /= 1 or else Mode /= M_1 then
raise Program_Error;
end if;
This.Memory_Layer.Actual_Width := This.Width;
This.Memory_Layer.Actual_Height := This.Height;
This.Memory_Layer.Addr := This.Memory_Layer.Data'Address;
This.Memory_Layer.Actual_Color_Mode := Mode;
for I in This.Memory_Layer.Data'Range loop
This.Memory_Layer.Data (I) := 0;
end loop;
This.Layer_Initialized := True;
end Initialize_Layer;
-------------------
-- Initialized --
-------------------
overriding function Initialized
(This : PCD8544_Device;
Layer : Positive) return Boolean
is
begin
return Layer = 1 and then This.Layer_Initialized;
end Initialized;
--------------------
-- Update_Layer --
--------------------
overriding procedure Update_Layer
(This : in out PCD8544_Device;
Layer : Positive;
Copy_Back : Boolean := False)
is
pragma Unreferenced (Copy_Back);
begin
if Layer /= 1 then
raise Program_Error;
end if;
This.Write_Raw_Pixels (This.Memory_Layer.Data);
end Update_Layer;
------------------
-- Color_Mode --
------------------
overriding function Color_Mode
(This : PCD8544_Device; Layer : Positive) return FB_Color_Mode
is
pragma Unreferenced (This);
begin
if Layer /= 1 then
raise Program_Error;
end if;
return M_1;
end Color_Mode;
---------------------
-- Hidden_Buffer --
---------------------
overriding function Hidden_Buffer
(This : in out PCD8544_Device; Layer : Positive)
return not null HAL.Bitmap.Any_Bitmap_Buffer
is
begin
if Layer /= 1 then
raise Program_Error;
end if;
return This.Memory_Layer'Unchecked_Access;
end Hidden_Buffer;
---------------------
-- Update_Layers --
---------------------
overriding procedure Update_Layers (This : in out PCD8544_Device) is
begin
This.Update_Layer (1);
end Update_Layers;
------------------
-- Pixel_Size --
------------------
overriding function Pixel_Size
(Display : PCD8544_Device; Layer : Positive) return Positive is
(1);
end PCD8544;
|
reznikmm/matreshka | Ada | 4,711 | 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.Frame_Display_Scrollbar_Attributes is
------------
-- Create --
------------
overriding function Create
(Parameters : not null access Matreshka.DOM_Attributes.Attribute_L2_Parameters)
return Draw_Frame_Display_Scrollbar_Attribute_Node is
begin
return Self : Draw_Frame_Display_Scrollbar_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_Frame_Display_Scrollbar_Attribute_Node)
return League.Strings.Universal_String
is
pragma Unreferenced (Self);
begin
return Matreshka.ODF_String_Constants.Frame_Display_Scrollbar_Attribute;
end Get_Local_Name;
begin
Matreshka.DOM_Documents.Register_Attribute
(Matreshka.ODF_String_Constants.Draw_URI,
Matreshka.ODF_String_Constants.Frame_Display_Scrollbar_Attribute,
Draw_Frame_Display_Scrollbar_Attribute_Node'Tag);
end Matreshka.ODF_Draw.Frame_Display_Scrollbar_Attributes;
|
onox/orka | Ada | 1,574 | adb | -- SPDX-License-Identifier: Apache-2.0
--
-- Copyright (c) 2018 onox <[email protected]>
--
-- Licensed under the Apache License, Version 2.0 (the "License");
-- you may not use this file except in compliance with the License.
-- You may obtain a copy of the License at
--
-- http://www.apache.org/licenses/LICENSE-2.0
--
-- Unless required by applicable law or agreed to in writing, software
-- distributed under the License is distributed on an "AS IS" BASIS,
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-- See the License for the specific language governing permissions and
-- limitations under the License.
with Ada.Text_IO;
package body Package_9_Jobs is
function Clone_Job
(Job : Orka.Jobs.Parallel_Job_Ptr;
Length : Positive) return Orka.Jobs.Dependency_Array
is
Object : constant Test_Parallel_Job := Test_Parallel_Job (Job.all);
begin
return Result : constant Orka.Jobs.Dependency_Array (1 .. Length)
:= (others => new Test_Parallel_Job'(Object));
end Clone_Job;
overriding
procedure Execute
(Object : Test_Sequential_Job;
Context : Orka.Jobs.Execution_Context'Class) is
begin
Ada.Text_IO.Put_Line ("Sequential job " & Object.ID'Image);
end Execute;
overriding
procedure Execute
(Object : Test_Parallel_Job;
Context : Orka.Jobs.Execution_Context'Class;
From, To : Positive) is
begin
Ada.Text_IO.Put_Line ("Parallel job (" & From'Image & " .. " & To'Image & ")");
end Execute;
end Package_9_Jobs;
|
cborao/Ada-P1-words | Ada | 4,952 | adb | with Ada.Text_IO;
with Ada.Command_Line;
with Word_Lists;
with Ada.Strings.Unbounded;
with Ada.Exceptions;
procedure words is
package ASU renames Ada.Strings.Unbounded;
package ACL renames Ada.Command_Line;
package ATI renames Ada.Text_IO;
package WL renames Word_Lists;
File_Name: ASU.Unbounded_String;
Fich: Ada.Text_IO.File_Type;
List: WL.Word_List_Type;
Word: ASU.Unbounded_String;
Count: Natural;
procedure Print_Menu is
--Imprime el menú interactivo
begin
ATI.New_Line;
ATI.Put_Line("Options");
ATI.Put_Line("1 Add Word");
ATI.Put_Line("2 Delete Word");
ATI.Put_Line("3 Search Word");
ATI.Put_Line("4 Show all words");
ATI.Put_Line("5 Quit");
ATI.New_Line;
ATI.Put("Your option? ");
end Print_Menu;
--Divide las líneas en palabras y las almacena en la lista
procedure Divide_In_Words (Line: in out Asu.Unbounded_String; Delimiter: in string) is
Word: ASU.Unbounded_String;
Eol: Boolean;
Position: Integer;
begin
Eol := False;
while not Eol loop
Position := ASU.Index(Line, Delimiter);
-- Si la línea no tiene más palabras
if ASU.Length(Line) = 0 then
Eol := True;
-- Si ya no hay mas delimitadores
elsif ASU.Index(Line, Delimiter) = 0 then
Word := ASU.Tail(Line, ASU.Length(Line) - Position);
WL.Add_Word(List, Word);
Eol := True;
else
Eol := False;
-- Si hay dos blancos seguidos
if (Position - 1) = 0 then
-- Me salta el blanco
ASU.Tail(Line, ASU.Length(Line) - Position);
else
Word := ASU.Head (Line, Position - 1);
ASU.Tail(Line, ASU.Length(Line) - Position);
WL.Add_Word(List, Word);
end if;
end if;
end loop;
end Divide_In_Words;
--Lee el fichero
procedure Read_Fich is
Line: ASU.Unbounded_String;
begin
while not ATI.End_Of_File(Fich) loop
Line := ASU.To_Unbounded_String(Ada.Text_IO.Get_Line(Fich));
Divide_In_Words(Line, " ");
end loop;
end Read_Fich;
procedure Basic_Mode (List: in out WL.Word_List_Type;
Word: in out ASU.Unbounded_String;
Count: in out Natural) is
begin
WL.Max_Word(List, Word, Count);
ATI.Put("The most frequent word: ");
ATI.Put("|" & ASU.To_String(Word) & "| -" );
ATI.Put_Line(Integer'Image(Count));
ATI.New_Line;
ATI.New_Line;
end Basic_Mode;
procedure Interactive_Mode (List: in out WL.Word_List_Type;
Word: in out ASU.Unbounded_String;
Count: in out Natural) is
Option: Integer;
begin
-- Muestra el menú y realiza las diferentes funciones hasta que pulsamos el quit
loop
begin
Print_Menu;
Option := Integer'Value(ATI.Get_Line);
case Option is
-- Añade una palabra a la lista
when 1 =>
ATI.Put("Word? ");
Word := ASU.To_Unbounded_String(ATI.Get_Line);
WL.Add_Word(List, Word);
ATI.Put_Line("Word |" & ASU.To_String(Word)
& "| added");
-- Borra una palabra de la lista
when 2 =>
ATI.Put("Word? ");
Word := ASU.To_Unbounded_String(ATI.Get_Line);
WL.Delete_Word (List, Word);
ATI.New_Line;
ATI.Put("|" & ASU.To_String(Word) & "| "
& "deleted");
ATI.New_Line;
-- Busca una palabra en la lista
when 3 =>
ATI.Put("Word? ");
Word := ASU.To_Unbounded_String(ATI.Get_Line);
WL.Search_Word(List, Word, Count);
ATI.New_Line;
ATI.Put("|" & ASU.To_String(Word) & "| - " );
ATI.Put_Line(Integer'Image(Count));
-- Imprime la lista
when 4 =>
WL.Print_All(List);
-- Imprime la palabra que más aparece y sale del bucle
when 5 =>
WL.Max_Word(List, Word, Count);
ATI.Put("The most frequent word: ");
ATI.Put("|" & ASU.To_String(Word) & "| -" );
ATI.Put_Line(Integer'Image(Count));
ATI.New_Line;
ATI.New_Line;
when others =>
ATI.Put_Line("Not implemented");
end case;
exception
when Constraint_Error =>
ATI.Put_Line("Incorrect Option");
end;
exit when Option = 5;
end loop;
end Interactive_Mode;
begin
Count := 0;
if ACL.Argument(1) = "-i" then
File_Name := ASU.To_Unbounded_String(ACL.Argument(2));
ATI.Open(Fich, ATI.In_File, ASU.To_String(File_Name));
Read_Fich;
Interactive_Mode(List, Word, Count);
Ada.Text_IO.Close(Fich);
else
File_Name := ASU.To_Unbounded_String(ACL.Argument(1));
ATI.Open(Fich, ATI.In_File, ASU.To_String(File_Name));
Read_Fich;
Basic_Mode(List, Word, Count);
Ada.Text_IO.Close(Fich);
end if;
exception
when ATI.Name_Error =>
if ACL.Argument(1) = "-i" then
ATI.Put_Line(ACL.Argument(2) & ": file not found");
Interactive_Mode(List, Word, Count);
elsif ACL.Argument_Count = 1 then
ATI.Put_Line(ACL.Argument(1) & ": file not found");
else
ATI.Put_Line("usage: words [-i] <filename>");
ATI.New_Line;
end if;
when Constraint_Error =>
ATI.Put_Line("usage: words [-i] <filename>");
ATI.New_Line;
end words;
|
zhmu/ananas | Ada | 2,764 | ads | ------------------------------------------------------------------------------
-- --
-- GNAT LIBRARY COMPONENTS --
-- --
-- ADA.STRINGS.FIXED.EQUAL_CASE_INSENSITIVE --
-- --
-- S p e c --
-- --
-- Copyright (C) 2011-2022, Free Software Foundation, Inc. --
-- --
-- This specification is derived from the Ada Reference Manual for use with --
-- GNAT. The copyright notice above, and the license provisions that follow --
-- apply solely to the contents of the part following the private keyword. --
-- --
-- GNAT is free software; you can redistribute it and/or modify it under --
-- terms of the GNU General Public License as published by the Free Soft- --
-- ware Foundation; either version 3, or (at your option) any later ver- --
-- sion. GNAT is distributed in the hope that it will be useful, but WITH- --
-- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY --
-- or FITNESS FOR A PARTICULAR PURPOSE. --
-- --
-- As a special exception under Section 7 of GPL version 3, you are granted --
-- additional permissions described in the GCC Runtime Library Exception, --
-- version 3.1, as published by the Free Software Foundation. --
-- --
-- You should have received a copy of the GNU General Public License and --
-- a copy of the GCC Runtime Library Exception along with this program; --
-- see the files COPYING3 and COPYING.RUNTIME respectively. If not, see --
-- <http://www.gnu.org/licenses/>. --
-- --
-- This unit was originally developed by Matthew J Heaney. --
------------------------------------------------------------------------------
with Ada.Strings.Equal_Case_Insensitive;
function Ada.Strings.Fixed.Equal_Case_Insensitive
(Left, Right : String)
return Boolean renames Ada.Strings.Equal_Case_Insensitive;
pragma Pure (Ada.Strings.Fixed.Equal_Case_Insensitive);
|
ekoeppen/STM32_Generic_Ada_Drivers | Ada | 2,040 | adb | with Ada.Real_Time; use Ada.Real_Time;
with STM32_SVD; use STM32_SVD;
with STM32_SVD.TIM; use STM32_SVD.TIM;
with STM32_SVD.RCC; use STM32_SVD.RCC;
package body STM32GD.Timer.Peripheral is
Timer_Callback : Timer_Callback_Type := null;
Frequency : constant Natural := 1_000;
CK_INT : constant Natural := 8_000_000;
Repeat : Boolean;
First : Boolean;
procedure Start (Time : Time_Span; Callback : Timer_Callback_Type);
protected body IRQ_Handler is
procedure Handler is
begin
if Timer = Timer_3 then
TIM3_Periph.SR.UIF := 0;
end if;
if Timer_Callback /= null then
if not First then
if not Repeat then
Stop;
end if;
Timer_Callback.all;
else
First := False;
end if;
end if;
end Handler;
end IRQ_Handler;
procedure Init is
begin
if Timer = Timer_3 then
RCC_Periph.APB1ENR.TIM3EN := 1;
TIM3_Periph.PSC.PSC := UInt16 (CK_INT / Frequency);
TIM3_Periph.CR1.ARPE := 1;
end if;
end Init;
procedure Start (Time : Time_Span; Callback : Timer_Callback_Type) is
MS : UInt16;
begin
MS := UInt16 (To_Duration (Time) * 1_000);
Timer_Callback := Callback;
First := True;
if Timer = Timer_3 then
TIM3_Periph.CNT.CNT := 0;
TIM3_Periph.ARR.ARR := MS;
TIM3_Periph.CR1.CEN := 1;
TIM3_Periph.DIER.UIE := 1;
end if;
end Start;
procedure Stop is
begin
if Timer = Timer_3 then
TIM3_Periph.CR1.CEN := 0;
TIM3_Periph.DIER.UIE := 0;
end if;
end Stop;
procedure After (Time : Time_Span; Callback : Timer_Callback_Type) is
begin
Repeat := False;
Start (Time, Callback);
end After;
procedure Every (Interval : Time_Span; Callback : Timer_Callback_Type) is
begin
Repeat := True;
Start (Interval, Callback);
end Every;
end STM32GD.Timer.Peripheral;
|
Anderstask1/Sanntidsprogrammering | Ada | 3,426 | adb | with Ada.Text_IO, Ada.Integer_Text_IO, Ada.Numerics.Float_Random;
use Ada.Text_IO, Ada.Integer_Text_IO, Ada.Numerics.Float_Random;
procedure exercise8 is
Count_Failed : exception; -- Exception to be raised when counting fails
Gen : Generator; -- Random number generator
protected type Transaction_Manager (N : Positive) is
entry Finished;
function Commit return Boolean;
procedure Signal_Abort;
private
Finished_Gate_Open : Boolean := False;
Aborted : Boolean := False;
Should_Commit : Boolean := True;
end Transaction_Manager;
protected body Transaction_Manager is
entry Finished when Finished_Gate_Open or Finished'Count = N is
begin
------------------------------------------
-- PART 3: Modify the Finished entry
------------------------------------------
if Finished'Count = N-1 then
Finished_Gate_Open := True;
Should_Commit := not Aborted;
end if;
if Finished'Count = 0 then
Finished_Gate_Open := False;
Aborted := False;
end if;
end Finished;
procedure Signal_Abort is
begin
Aborted := True;
end Signal_Abort;
function Commit return Boolean is
begin
return Should_Commit;
end Commit;
------------------------------------------
-- PART 2: Create the Wait_Until_Aborted entry
------------------------------------------
end Transaction_Manager;
function Unreliable_Slow_Add (x : Integer) return Integer is
Error_Rate : Constant := 0.15; -- (between 0 and 1)
begin
if Random(Gen) > Error_Rate then
delay Duration(Random(Gen) * 5.0);
return X + 10;
else
delay Duration(Random(Gen) * 1.0);
raise Count_Failed;
end if;
end Unreliable_Slow_Add;
task type Transaction_Worker (Initial : Integer; Manager : access Transaction_Manager);
task body Transaction_Worker is
Num : Integer := Initial;
Prev : Integer := Num;
Round_Num : Integer := 0;
begin
Put_Line ("Worker" & Integer'Image(Initial) & " started");
loop
Put_Line ("Worker" & Integer'Image(Initial) & " started round" & Integer'Image(Round_Num));
Round_Num := Round_Num + 1;
------------------------------------------
-- PART 1: Select-Then-Abort statement
------------------------------------------
begin
Num := Unreliable_Slow_Add(Num);
exception
when Count_Failed =>
Manager.Signal_Abort;
end;
Manager.Finished;
if Manager.Commit = True then
Put_Line (" Worker" & Integer'Image(Initial) & " comitting" & Integer'Image(Num));
else
Put_Line (" Worker" & Integer'Image(Initial) &
" reverting from" & Integer'Image(Num) &
" to" & Integer'Image(Prev));
Num := Prev;
end if;
Prev := Num;
delay 0.5;
end loop;
end Transaction_Worker;
Manager : aliased Transaction_Manager (3);
Worker_1 : Transaction_Worker (0, Manager'Access);
Worker_2 : Transaction_Worker (1, Manager'Access);
Worker_3 : Transaction_Worker (2, Manager'Access);
begin
Reset(Gen); -- Seed the random number generator
end exercise8;
|
yannickmoy/bbqueue-ada | Ada | 3,716 | adb | package body Array_Slices
with SPARK_Mode
is
------------
-- Create --
------------
function Create (Addr : System.Address; Size : Count_Type) return Slice is
begin
if Size = 0 then
return Empty_Slice;
end if;
return Ret : Slice do
Ret.F := Index_Type'First;
Ret.L := Index_Type'First + Index_Type (Size) - 1;
Ret.Addr := Addr;
end return;
end Create;
-----------
-- Empty --
-----------
function Empty (This : Slice) return Boolean
is (This.L < This.F);
-----------
-- First --
-----------
function First (This : Slice) return Index_Type
is (This.F);
----------
-- Last --
----------
function Last (This : Slice) return Index_Type
is (This.L);
------------
-- Length --
------------
function Length (This : Slice) return Count_Type
is (if Empty (This)
then 0
else Count_Type (This.L - This.F + 1));
--------------
-- In_Range --
--------------
function In_Range (This : Slice; Index : Index_Type) return Boolean
is (Index in This.F .. This.L);
---------
-- Set --
---------
procedure Set (This : in out Slice; Index : Index_Type; Data : Element_Type) is
pragma SPARK_Mode (Off);
Arr : Virt_Arr with Address => This.Addr;
begin
Arr (Index) := Data;
end Set;
---------
-- Set --
---------
procedure Set (This : in out Slice; From : Index_Type; Data : Array_Type) is
pragma SPARK_Mode (Off);
Arr : Virt_Arr with Address => This.Addr;
begin
Arr (From .. From + Data'Length - 1) := Data;
end Set;
----------
-- Read --
----------
procedure Read (This : Slice; From : Index_Type; Data : out Array_Type) is
pragma SPARK_Mode (Off);
Arr : Virt_Arr with Address => This.Addr;
begin
Data := Arr (From .. From + Data'Length - 1);
end Read;
-------------
-- Element --
-------------
function Element (This : Slice; Index : Index_Type) return Element_Type is
pragma SPARK_Mode (Off);
Arr : Virt_Arr with Address => This.Addr;
begin
return Arr (Index);
end Element;
----------
-- Addr --
----------
function Addr (This : Slice; Index : Index_Type) return System.Address is
pragma SPARK_Mode (Off);
Arr : Virt_Arr with Address => This.Addr;
begin
return Arr (Index)'Address;
end Addr;
----------
-- Addr --
----------
function Addr (This : Slice) return System.Address
is (Addr (This, This.F));
package body Callbacks is
pragma SPARK_Mode (Off);
----------
-- Read --
----------
procedure Read
(This : Slice;
Callback : not null access procedure (Data : Array_Type))
is
pragma SPARK_Mode (Off);
Arr : Virt_Arr with Address => This.Addr;
begin
Callback (Arr (This.F .. This.L));
end Read;
-----------
-- Write --
-----------
procedure Write
(This : in out Slice;
Callback : not null access procedure (Data : out Array_Type))
is
pragma SPARK_Mode (Off);
Arr : Virt_Arr with Address => This.Addr;
begin
Callback (Arr (This.F .. This.L));
end Write;
----------------
-- Read_Write --
----------------
procedure Read_Write
(This : in out Slice;
Callback : not null access procedure (Data : in out Array_Type))
is
pragma SPARK_Mode (Off);
Arr : Virt_Arr with Address => This.Addr;
begin
Callback (Arr (This.F .. This.L));
end Read_Write;
end Callbacks;
end Array_Slices;
|
charlie5/lace | Ada | 848 | ads | with
opengl.surface_Profile,
opengl.Display;
private
with
eGL;
package opengl.Surface
--
-- Models an openGL surface.
--
is
type Item is tagged private;
type Items is array (Positive range <>) of aliased Item;
type View is access all Item'class;
type Views is array (Positive range <>) of View;
-- Forge
--
procedure define (Self : in out Item; surface_Profile : in opengl.surface_Profile.item'Class;
Display : in opengl.Display.item;
Window_Id : in Natural);
-- Operations
--
procedure swap_Buffers (Self : in Item);
private
type Item is tagged
record
egl_Surface : egl.EGLSurface;
Display : openGL.Display.item;
end record;
end opengl.Surface;
|
BrickBot/Bound-T-H8-300 | Ada | 22,088 | adb | -- Flow.Slim (body)
--
-- A component of the Bound-T Worst-Case Execution Time Tool.
--
-------------------------------------------------------------------------------
-- Copyright (c) 1999 .. 2015 Tidorum Ltd
-- All rights reserved.
--
-- Redistribution and use in source and binary forms, with or without
-- modification, are permitted provided that the following conditions are met:
--
-- 1. Redistributions of source code must retain the above copyright notice, this
-- list of conditions and the following disclaimer.
-- 2. Redistributions in binary form must reproduce the above copyright notice,
-- this list of conditions and the following disclaimer in the documentation
-- and/or other materials provided with the distribution.
--
-- This software is provided by the copyright holders and contributors "as is" and
-- any express or implied warranties, including, but not limited to, the implied
-- warranties of merchantability and fitness for a particular purpose are
-- disclaimed. In no event shall the copyright owner or contributors be liable for
-- any direct, indirect, incidental, special, exemplary, or consequential damages
-- (including, but not limited to, procurement of substitute goods or services;
-- loss of use, data, or profits; or business interruption) however caused and
-- on any theory of liability, whether in contract, strict liability, or tort
-- (including negligence or otherwise) arising in any way out of the use of this
-- software, even if advised of the possibility of such damage.
--
-- Other modules (files) of this software composition should contain their
-- own copyright statements, which may have different copyright and usage
-- conditions. The above conditions apply to this file.
-------------------------------------------------------------------------------
--
-- $Revision: 1.15 $
-- $Date: 2015/10/24 20:05:48 $
--
-- $Log: flow-slim.adb,v $
-- Revision 1.15 2015/10/24 20:05:48 niklas
-- Moved to free licence.
--
-- Revision 1.14 2009-10-07 19:26:10 niklas
-- BT-CH-0183: Cell-sets are a tagged-type class.
--
-- Revision 1.13 2009-01-18 08:08:27 niklas
-- Moved context clause to body. Removed unused locals.
--
-- Revision 1.12 2007/10/28 09:32:46 niklas
-- BT-CH-0092: Arithmetic analysis of dynamic data refs is optional.
--
-- Revision 1.11 2007/03/29 15:18:03 niklas
-- BT-CH-0056.
--
-- Revision 1.10 2007/02/13 20:22:07 Niklas
-- BT-CH-0044.
--
-- Revision 1.9 2007/01/25 21:25:16 niklas
-- BT-CH-0043.
--
-- Revision 1.8 2006/02/27 09:30:00 niklas
-- Added functions Edges_Into and Edges_From.
--
-- Revision 1.7 2005/02/16 21:11:45 niklas
-- BT-CH-0002.
--
-- Revision 1.6 2004/04/26 20:20:00 niklas
-- First Tidorum version.
-- Taking Cell_T stuff from Storage instead of Arithmetic.
--
-- Revision 1.5 2001/03/16 14:56:53 holsti
-- Cells_Accessed uses only Bare edges.
--
-- Revision 1.4 2001/03/16 11:14:07 holsti
-- Cells_Accessed includes edge conditions (NC_045).
--
-- Revision 1.3 2000/08/21 13:07:27 holsti
-- Edgeless graphs allowed (Max_Edge return Edge_Count_T).
--
-- Revision 1.2 2000/07/16 13:12:47 holsti
-- Fused nodes (and edges) are deleted from the slimmed graph.
--
-- Revision 1.1 2000/07/14 20:35:07 holsti
-- First version.
--
with Faults;
with Flow.Computation;
with Flow.Slim.Opt;
with Output;
with Storage.Bitvec_Cell_Sets;
with Unchecked_Deallocation;
package body Flow.Slim is
--
-- Graph object type:
--
type Nodes_T is array (Node_Index_T range <>) of Node_T;
--
-- All the nodes of slimmed graph.
type Edges_T is array (Edge_Index_T range <>) of Edge_T;
--
-- All the edges of a slimmed graph.
type Graph_Object_T (
Max_Node : Node_Index_T;
Max_Edge : Edge_Count_T)
is record
Original : Flow.Graph_T;
Living : Life.Living_T;
Model : Computation.Model_Ref;
Nodes : Nodes_T (1 .. Max_Node);
Edges : Edges_T (1 .. Max_Edge);
end record;
--
-- The main structure of a slimmed graph.
--
-- Original
-- The original graph on which this slimmed graph is based.
-- Equals Flow.Computation.Graph (Model).
--
-- Living
-- The set of "live" assignments and the computation model
-- associated with the Original graph and the slimmed graph.
-- Note that Living_T is a reference type.
--
-- Model
-- The computation model that defines the feasible part of
-- the Original graph and the arithmetic effects and conditions
-- in the graph. Model equals Flow.Life.Model (Living).
--
-- Nodes
-- All the nodes in this graph. Even nodes that have been
-- fused are represented, but their Fusion components point
-- to the same Fusion_T object. Nodes that are infeasible
-- under the computation model or that have been fused are
-- not considered to exist in the slimmed graph. The "proxy"
-- node that stands for a set of fused nodes does exist.
--
-- Edges
-- All the edges in this graph, however infeasible edges or
-- those of the Deleted kind shall not be considered as
-- existing edges.
procedure Unchecked_Discard is new Unchecked_Deallocation (
Object => Graph_Object_T,
Name => Graph_T);
procedure Free (Item : in out Graph_T)
--
-- Discards the Item with optional Deallocate.
--
is
begin
if Opt.Deallocate then
Unchecked_Discard (Item);
else
Item := null;
end if;
exception when others => Faults.Deallocation;
end Free;
function Max_Node (Graph : Graph_T) return Node_Index_T
is
begin
return Graph.Max_Node;
end Max_Node;
function Max_Edge (Graph : Graph_T) return Edge_Count_T
is
begin
return Graph.Max_Edge;
end Max_Edge;
function Living (Graph : Graph_T) return Life.Living_T
is
begin
return Graph.Living;
end Living;
--
-- Fusion object:
--
type Edge_Index_List_T is array (Positive range <>) of Edge_Index_T;
--
-- For the lists of incoming and outgoing edges of a fusion.
type Fusion_T (
Number_Into : Natural;
Number_From : Natural)
is record
Index : Node_Index_T;
Flux : Calculator.Flux_T;
Into : Edge_Index_List_T (1 .. Number_Into);
From : Edge_Index_List_T (1 .. Number_From);
end record;
--
-- A fusion node.
--
-- Index
-- The index assigned to this fusion. It will be one of
-- indices of the nodes that were fused.
--
-- Flux
-- The flux of the fusion (see function Flux).
--
-- Into, From
-- The (indices of) edges entering and leaving the fusion node.
-- All the From edges will normally be Fluxed (when the fusion is
-- completed by Set_Flux operations).
-- The Into edged may be Bare or Fluxed, depending on their
-- source node.
procedure Unchecked_Discard is new Unchecked_Deallocation (
Object => Fusion_T,
Name => Fusion_Ref);
procedure Free (Item : in out Fusion_Ref)
--
-- Discards the Item with optional Deallocate.
--
is
begin
if Opt.Deallocate then
Unchecked_Discard (Item);
else
Item := null;
end if;
exception when others => Faults.Deallocation;
end Free;
procedure Free (Node : in out Node_T)
--
-- Frees any dynamic storage allocated for this node.
--
is
begin
if Node.Exists and then Node.Kind = Fusion then
Free (Node.Fusion);
end if;
end Free;
procedure Check_That (Exists : in Boolean)
--
-- Ensure that we access only existing data.
--
is
begin
if not Exists then
Output.Fault (
Location => "Flow.Slim.Check_That",
Text => "Access deleted graph element");
raise No_Such_Node;
-- Could also be No_Such_Edge.
end if;
end Check_That;
function Index (Node : Node_T) return Node_Index_T
is
begin
Check_That (Node.Exists);
case Node.Kind is
when Basic => return Flow.Index (Node.Basic);
when Fusion => return Node.Fusion.Index;
end case;
end Index;
function Node_At (
Index : Node_Index_T;
Within : Graph_T)
return Node_T
is
Node : Node_T;
-- The result.
begin
Node := Within.Nodes(Index);
if not Node.Exists then
raise No_Such_Node;
end if;
return Node;
end Node_At;
function Basic (Node : Basic_Node_T) return Flow.Node_T
is
begin
Check_That (Node.Exists);
return Node.Basic;
end Basic;
function Flux (Node : Fusion_Node_T) return Calculator.Flux_T
is
begin
Check_That (Node.Exists);
return Node.Fusion.Flux;
end Flux;
--
-- Edge operations:
--
function Index (Edge : Edge_T) return Edge_Index_T
is
begin
Check_That (Edge.Exists);
case Edge.Kind is
when Bare => return Flow.Index (Edge.Bare);
when Fluxed => return Edge.Index;
end case;
end Index;
function Edge_At (
Index : Edge_Index_T;
Within : Graph_T)
return Edge_T
is
Edge : Edge_T;
-- The result.
begin
Edge := Within.Edges(Index);
if not Edge.Exists then
raise No_Such_Edge;
end if;
return Edge;
end Edge_At;
function Source (Edge : Edge_T) return Node_T
is
begin
Check_That (Edge.Exists);
return Edge.Graph.Nodes(Edge.Source);
end Source;
function Target (Edge : Edge_T) return Node_T
is
begin
Check_That (Edge.Exists);
return Edge.Graph.Nodes(Edge.Target);
end Target;
function Condition (Edge : Bare_Edge_T)
return Arithmetic.Condition_T
is
begin
Check_That (Edge.Exists);
return Flow.Computation.Condition (
Edge => Step_Edge (Edge.Bare),
Under => Edge.Graph.Model);
end Condition;
function Flux (Edge : Fluxed_Edge_T)
return Calculator.Flux_T
is
begin
Check_That (Edge.Exists);
return Edge.Flux;
end Flux;
function Edges_At (
Indices : Edge_Index_List_T;
Within : Graph_T)
return Edge_List_T
--
-- The edges at the given indices within the given graph.
--
is
Edges : Edge_List_T (Indices'Range);
-- The result.
begin
for I in Indices'Range loop
Edges(I) := Edge_At (Indices(I), Within);
end loop;
return Edges;
end Edges_At;
function Slim_Edges (
Edges : Flow.Edge_List_T;
Within : Graph_T)
return Edge_List_T
--
-- The edges in the slimmed graph that correspond to (have the
-- same indices as) the given edges in the original graph.
--
is
Slims : Edge_List_T (Edges'Range);
-- The result.
begin
for E in Edges'Range loop
Slims(E) := Edge_At (Flow.Index (Edges(E)), Within);
end loop;
return Slims;
end Slim_Edges;
function Edges_Into (Node : Node_T; Within : Graph_T)
return Edge_List_T
is
begin
Check_That (Node.Exists);
case Node.Kind is
when Basic =>
return Slim_Edges (
Edges => Flow.Edges_Into (Node.Basic, Within.Original),
Within => Within);
when Fusion =>
return Edges_At (Node.Fusion.Into, Within);
end case;
end Edges_Into;
function Edges_From (Node : Node_T; Within : Graph_T)
return Edge_List_T
is
begin
Check_That (Node.Exists);
case Node.Kind is
when Basic =>
return Slim_Edges (
Edges => Flow.Edges_From (Node.Basic, Within.Original),
Within => Within);
when Fusion =>
return Edges_At (Node.Fusion.From, Within);
end case;
end Edges_From;
--
-- GRAPH CONSTRUCTION AND SLIMMING
--
procedure Make_Graph (
Model : in Flow.Computation.Model_Ref;
Graph : out Graph_T)
--
-- Creates a slimmed graph based on a computation Model and fills
-- the Node and Edge lists of the Graph with the nodes and edges
-- that are feasible under the Model.
--
is
Source : constant Flow.Graph_T := Computation.Graph (Model);
-- The underlying ordinary flow-graph.
Node : Flow.Node_T;
-- A node in the Source graph.
Edge : Flow.Edge_T;
-- An edge in the Source graph.
begin
Graph := new Graph_Object_T (
Max_Node => Flow.Max_Node (Source),
Max_Edge => Flow.Max_Edge (Source));
Graph.Original := Source;
-- Graph.Living is not yet assigned.
Computation.Refer (
From => Graph.Model,
To => Model);
for N in Graph.Nodes'Range loop
Node := Flow.Node_At (N, Source);
Graph.Nodes(N) := (
Kind => Basic,
Exists => Computation.Is_Feasible (Node, Model),
Basic => Node);
end loop;
for E in Graph.Edges'Range loop
Edge := Flow.Edge_At (E, Source);
Graph.Edges(E) := (
Kind => Bare,
Exists => Computation.Is_Feasible (Edge, Model),
Graph => Graph,
Source => Flow.Index (Flow.Source (Edge)),
Target => Flow.Index (Flow.Target (Edge)),
Bare => Edge);
end loop;
end Make_Graph;
function Entire_Graph (
Living : Flow.Life.Living_T)
return Graph_T
is
Graph : Graph_T;
-- The new graph.
begin
Make_Graph (
Model => Life.Model (Living).all,
Graph => Graph);
Graph.Living := Living;
return Graph;
end Entire_Graph;
procedure Destroy (Graph : in out Graph_T)
is
begin
-- Discard the reference to the computation model:
Computation.Discard (Graph.Model);
-- Release all the Fusions:
for N in Graph.Nodes'Range loop
Free (Graph.Nodes(N));
end loop;
-- Release the slimmed graph object:
Free (Graph);
-- The reference to the associated Flow.Life.Living_T is
-- not a counted one, so it silently disappears.
end Destroy;
procedure Fuse (
Nodes : in Node_Set_T;
Proxy : in Node_Index_T;
Flux : in Calculator.Flux_T;
Within : in out Graph_T)
is
Indices : constant Flow.Node_Index_List_T := To_Index_List (Nodes);
-- The indices of the nodes to be fused.
Num_Into : Natural := 0;
Num_From : Natural := 0;
-- The number of edges entering and leaving the fusion.
Edges_Into : Edge_Index_List_T (1 .. Within.Edges'Length);
-- The edges (indices) entering and leaving the fusion
-- are Edges_Into (1 .. Num_Into).
Edges_From : Edge_Index_List_T (1 .. Within.Edges'Length);
-- The edges (indices) entering and leaving the fusion
-- are Edges_Into (1 .. Num_From).
Fusion : Fusion_Ref;
-- The result.
procedure Fuse_Edge (Edge : in out Edge_T)
--
-- Check if the edge is involved in the fusion.
-- Delete edges internal to the fusion.
-- Accumulate edges entering and leaving the fusion and
-- update their target or source index, respectively.
--
is
begin
if Nodes(Edge.Source) and Nodes(Edge.Target) then
-- The edge is internal to the fusion.
Edge.Exists := False;
elsif Nodes(Edge.Source) then
-- The edge leaves the fusion.
Num_From := Num_From + 1;
Edges_From (Num_From) := Index (Edge);
Edge.Source := Proxy;
elsif Nodes(Edge.Target) then
-- The edge enters the fusion.
Num_Into := Num_Into + 1;
Edges_Into (Num_Into) := Index (Edge);
Edge.Target := Proxy;
end if;
end Fuse_Edge;
procedure Fuse_Node (Index : in Node_Index_T)
--
-- Given the Index of one of the fused nodes, update the
-- node to mark it as part of this fusion.
--
is
Node : Node_T renames Within.Nodes(Index);
-- The node to be updated.
begin
if Node.Exists then
Free (Node);
-- Free the earlier Fusion object, if any.
if Index = Proxy then
-- This will be the new fusion node:
Node := (
Kind => Flow.Slim.Fusion,
Exists => True,
Fusion => Fusion);
else
-- Delete fused node:
Node.Exists := False;
end if;
end if;
end Fuse_Node;
begin -- Fuse
-- Check Proxy validity:
if not Nodes(Proxy) then
Output.Fault (
Location => "Flow.Slim.Fuse",
Text => "Proxy is not in fused set");
raise Constraint_Error;
end if;
-- Scan and update the edges:
for E in Within.Edges'Range loop
if Within.Edges(E).Exists then
Fuse_Edge (Edge => Within.Edges(E));
end if;
end loop;
-- Create the fusion object:
Fusion := new Fusion_T'(
Number_Into => Num_Into,
Number_From => Num_From,
Index => Proxy,
Flux => Flux,
Into => Edges_Into (1 .. Num_Into),
From => Edges_From (1 .. Num_From));
-- Scan the fused nodes and delete them all, except
-- for the Proxy which will become the fusion:
for F in Indices'Range loop
Fuse_Node (Index => Indices(F));
end loop;
end Fuse;
procedure Set_Flux (
Edge : in Edge_Index_T;
Flux : in Calculator.Flux_T;
Within : in out Graph_T)
is
E : Edge_T renames Within.Edges(Edge);
-- The edge to be updated.
begin
Check_That (E.Exists);
-- Check that the edge source is a fusion (this is
-- a feature of the way Bound-T uses fusion, and is
-- thus to be deleted if this package is used in other
-- ways):
Check_That (Within.Nodes(E.Source).Exists);
if Within.Nodes(E.Source).Kind /= Fusion then
Output.Fault (
Location => "Flow.Slim.Set_Flux",
Text =>
"Edge" & Edge_Index_T'Image (Edge)
& ", source (node"
& Node_Index_T'Image(E.Source)
& ") is not a fusion");
end if;
-- Update the edge:
case E.Kind is
when Bare =>
-- Transform E from Bare to Fluxed:
E := (
Kind => Fluxed,
Exists => True,
Graph => E.Graph,
Source => E.Source,
Target => E.Target,
Index => Flow.Index (E.Bare),
Flux => Flux);
when Fluxed =>
-- Just update the flux:
E.Flux := Flux;
end case;
end Set_Flux;
function Edges (
From : Node_Set_T;
Into : Node_Set_T;
Within : Graph_T)
return Edge_List_T
is
List : Edge_List_T (1 .. Within.Edges'Length);
Last : Natural := 0;
-- The result will be List(1 .. Last).
begin
for E in Within.Edges'Range loop
declare
Edge : Edge_T renames Within.Edges(E);
begin
if Edge.Exists
and then (From(Edge.Source) and Into(Edge.Target))
then
-- This edge is acceptable.
Last := Last + 1;
List(Last) := Edge;
end if;
end;
end loop;
return List(1 .. Last);
end Edges;
function Cells_Accessed (
By : Node_Set_T;
Within : Graph_T)
return Storage.Cell_Set_T
is
use Storage.Bitvec_Cell_Sets;
Accessed : Set_T;
-- The result under construction.
-- Initially empty.
procedure Add_From (Edge : in Edge_T)
--
-- Adds the cells accessed by the precondition of the Edge,
-- if the Edge is bare. Basis cells for boundable memory
-- references are included.
--
-- Precondition: The Edge exists (and Elvis is alive).
--
-- For Fluxed edges, it can be assumed that the cells in
-- the flux also occur in the the source node, and are
-- therefore included in the result of Cells_Accessed for
-- that reason so the Fluxed edges can be ignored here.
--
is
begin
if Edge.Kind = Bare then
Arithmetic.Add_Cells_Used (
By => Flow.Computation.Condition (
Edge => Step_Edge (Edge.Bare),
Under => Within.Model),
Refs => True,
To => Accessed);
end if;
end Add_From;
procedure Add_From (Node : in Node_T)
--
-- Adds the cells accessed by this node.
--
is
begin
case Node.Kind is
when Basic =>
Flow.Life.Add_Cells_Accessed (
By => Node.Basic,
Living => Within.Living,
To => Accessed);
when Fusion =>
Storage.Mixed.Add (
Cells => Calculator.Cells_Of (Node.Fusion.Flux),
To => Accessed);
end case;
end Add_From;
begin -- Cells_Accessed
-- Scan the nodes in the set:
for N in Within.Nodes'Range loop
if Within.Nodes(N).Exists
and then By(N)
then
Add_From (Node => Within.Nodes(N));
end if;
end loop;
-- Scan the edges leaving the nodes in the set:
for E in Within.Edges'Range loop
if Within.Edges(E).Exists
and then By(Within.Edges(E).Source)
then
Add_From (Edge => Within.Edges(E));
end if;
end loop;
-- And that's all folks.
return Accessed;
end Cells_Accessed;
end Flow.Slim;
|
tomekw/simple_blockchain | Ada | 1,796 | adb | with Ada.Calendar.Formatting; use Ada.Calendar.Formatting;
with GNAT.SHA256;
package body Simple_Blockchain.Block is
function Get_Data (This : Object) return String is (To_String (This.Data));
function Get_Hash (This : Object) return String is (This.Hash);
function Get_Nonce (This : Object) return Long_Long_Integer is (This.Nonce);
function Get_Previous_Hash (This : Object) return String is (This.Previous_Hash);
function Get_Timestamp (This : Object) return Time is (This.Timestamp);
function Image (This : Object) return String is
begin
return "Hash: " & Get_Hash (This) &
", Previous hash: " & Get_Previous_Hash (This) &
", Timestamp: " & Image (Get_Timestamp (This)) &
", Nonce: " & Get_Nonce (This)'Image &
", Data: " & Get_Data (This);
end Image;
function Make (Previous_Hash : String; Data : String) return Object is
Now : Time := Clock;
Nonce : Long_Long_Integer := 0;
begin
return (
Hash => Calculate_Hash (Previous_Hash, Now, Nonce, Data),
Previous_Hash => Previous_Hash,
Timestamp => Now,
Nonce => Nonce,
Data => To_Unbounded_String (Data));
end Make;
procedure Recalculate_Hash (This : in out Object) is
begin
This.Nonce := Get_Nonce (This) + 1;
This.Timestamp := Clock;
This.Hash := Calculate_Hash (Get_Previous_Hash (This), Get_Timestamp (This), Get_Nonce (This), Get_Data (This));
end Recalculate_Hash;
function Calculate_Hash (Previous_Hash : String; Timestamp : Time; Nonce : Long_Long_Integer; Data: String) return String is
begin
return GNAT.SHA256.Digest (Previous_Hash & Image (Timestamp) & Nonce'Image & Data);
end Calculate_Hash;
end Simple_Blockchain.Block;
|
sf17k/sdlada | Ada | 4,298 | adb | --------------------------------------------------------------------------------------------------------------------
-- Copyright (c) 2014-2015 Luke A. Guest
--
-- This software is provided 'as-is', without any express or implied
-- warranty. In no event will the authors be held liable for any damages
-- arising from the use of this software.
--
-- Permission is granted to anyone to use this software for any purpose,
-- including commercial applications, and to alter it and redistribute it
-- freely, subject to the following restrictions:
--
-- 1. The origin of this software must not be misrepresented; you must not
-- claim that you wrote the original software. If you use this software
-- in a product, an acknowledgment in the product documentation would be
-- appreciated but is not required.
--
-- 2. Altered source versions must be plainly marked as such, and must not be
-- misrepresented as being the original software.
--
-- 3. This notice may not be removed or altered from any source
-- distribution.
--------------------------------------------------------------------------------------------------------------------
with Interfaces.C;
package body SDL.CPUS is
package C renames Interfaces.C;
use type C.int;
function Count return Positive is
function SDL_Get_CPU_Count return C.int with
Import => True,
Convention => C,
External_Name => "SDL_GetCPUCount";
begin
return Positive (SDL_Get_CPU_Count);
end Count;
function Cache_Line_Size return Positive is
function SDL_Cache_Line_Size return C.int with
Import => True,
Convention => C,
External_Name => "SDL_GetCPUCacheLineSize";
begin
return Positive (SDL_Cache_Line_Size);
end Cache_Line_Size;
function Has_3DNow return Boolean is
function SDL_Has_3DNow return C.int with
Import => True,
Convention => C,
External_Name => "SDL_Has3DNow";
begin
return (if SDL_Has_3DNow = 1 then True else False);
end Has_3DNow;
function Has_AltiVec return Boolean is
function SDL_Has_AltiVec return C.int with
Import => True,
Convention => C,
External_Name => "SDL_HasAltiVec";
begin
return (if SDL_Has_AltiVec = 1 then True else False);
end Has_AltiVec;
function Has_MMX return Boolean is
function SDL_Has_MMX return C.int with
Import => True,
Convention => C,
External_Name => "SDL_HasMMX";
begin
return (if SDL_Has_MMX = 1 then True else False);
end Has_MMX;
function Has_RDTSC return Boolean is
function SDL_Has_RDTSC return C.int with
Import => True,
Convention => C,
External_Name => "SDL_HasRDTSC";
begin
return (if SDL_Has_RDTSC = 1 then True else False);
end Has_RDTSC;
function Has_SSE return Boolean is
function SDL_Has_SSE return C.int with
Import => True,
Convention => C,
External_Name => "SDL_HasSSE";
begin
return (if SDL_Has_SSE = 1 then True else False);
end Has_SSE;
function Has_SSE_2 return Boolean is
function SDL_Has_SSE_2 return C.int with
Import => True,
Convention => C,
External_Name => "SDL_HasSSE2";
begin
return (if SDL_Has_SSE_2 = 1 then True else False);
end Has_SSE_2;
function Has_SSE_3 return Boolean is
function SDL_Has_SSE_3 return C.int with
Import => True,
Convention => C,
External_Name => "SDL_HasSSE3";
begin
return (if SDL_Has_SSE_3 = 1 then True else False);
end Has_SSE_3;
function Has_SSE_4_1 return Boolean is
function SDL_Has_SSE_4_1 return C.int with
Import => True,
Convention => C,
External_Name => "SDL_HasSSE41";
begin
return (if SDL_Has_SSE_4_1 = 1 then True else False);
end Has_SSE_4_1;
function Has_SSE_4_2 return Boolean is
function SDL_Has_SSE_4_2 return C.int with
Import => True,
Convention => C,
External_Name => "SDL_HasSSE42";
begin
return (if SDL_Has_SSE_4_2 = 1 then True else False);
end Has_SSE_4_2;
end SDL.CPUS;
|
sparre/Command-Line-Parser-Generator | Ada | 197 | adb | with Ada.Text_IO;
package body Subtype_Chains_1 is
procedure Something_To_Call is
begin
Ada.Text_IO.Put_Line (" Something_To_Call;");
end Something_To_Call;
end Subtype_Chains_1;
|
laurentzh/CHIP-8 | Ada | 2,293 | adb | with BMP_Fonts;
with HAL.Bitmap; use HAL.Bitmap;
with HAL.Framebuffer; use HAL.Framebuffer;
with Inputs; use Inputs;
with LCD_Std_Out;
with STM32.Board; use STM32.Board;
with Interfaces; use Interfaces;
package body Gfx is
procedure Init_Draw is
begin
-- Initialize LCD
Display.Initialize;
Display.Initialize_Layer(1, ARGB_8888);
Display.Initialize_Layer(2, ARGB_8888);
Display.Set_Orientation(Landscape);
-- Set Background color
LCD_Std_Out.Set_Font (BMP_Fonts.Font8x8);
LCD_Std_Out.Current_Background_Color := Black;
Clear_Layer(1);
Clear_Layer(2);
-- Apply color
LCD_Std_Out.Clear_Screen;
end Init_Draw;
procedure Draw_Keyboard(Mem : Memory) is
begin
for Y in Layout_Array'Range(1) loop
for X in Layout_Array'Range(2) loop
Draw_Key(Mem, X, Y);
end loop;
end loop;
Display.Update_Layer(1, False);
end Draw_Keyboard;
procedure Draw_Key(Mem : Memory; X : Integer; Y : Integer) is
Nibble : Byte;
begin
for I in 0 .. 4 loop
Nibble := Shift_Right(Mem(Word(5 * Layout(Y, X) + I)), 4);
for J in 0 .. 3 loop
if (Shift_Right(Nibble, 3 - J) and 1) = 1 then
Draw_Key_Pixel(X * 40 + J * 3 + 16, 160 + 40 * Y + I * 3 + 12);
end if;
end loop;
end loop;
end Draw_Key;
procedure Draw_Key_Pixel(X : Integer; Y : Integer) is
Pt : constant Point := (X, Y);
Rct : constant Rect := (Pt, 3, 3);
begin
Display.Hidden_Buffer(1).Set_Source(White);
Display.Hidden_Buffer(1).Fill_Rect(Rct);
end Draw_Key_Pixel;
procedure Draw_Pixel(X : Integer; Y : Integer; Pixel : Boolean) is
Color : constant Bitmap_Color := (if Pixel then White else Transparent);
Pt : constant Point := (X * 5, Y * 5);
Rct : constant Rect := (Pt, 5, 5);
begin
Display.Hidden_Buffer(2).Set_Source(Color);
Display.Hidden_Buffer(2).Fill_Rect(Rct);
end Draw_Pixel;
procedure Clear_Layer(Layer : Integer) is
begin
Display.Hidden_Buffer(Layer).Set_Source(Transparent);
Display.Hidden_Buffer(Layer).Fill;
Display.Hidden_Buffer(Layer).Set_Source(White);
end Clear_Layer;
end Gfx;
|
reznikmm/matreshka | Ada | 4,719 | 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_Presentation.Preset_Sub_Type_Attributes is
------------
-- Create --
------------
overriding function Create
(Parameters : not null access Matreshka.DOM_Attributes.Attribute_L2_Parameters)
return Presentation_Preset_Sub_Type_Attribute_Node is
begin
return Self : Presentation_Preset_Sub_Type_Attribute_Node do
Matreshka.ODF_Presentation.Constructors.Initialize
(Self'Unchecked_Access,
Parameters.Document,
Matreshka.ODF_String_Constants.Presentation_Prefix);
end return;
end Create;
--------------------
-- Get_Local_Name --
--------------------
overriding function Get_Local_Name
(Self : not null access constant Presentation_Preset_Sub_Type_Attribute_Node)
return League.Strings.Universal_String
is
pragma Unreferenced (Self);
begin
return Matreshka.ODF_String_Constants.Preset_Sub_Type_Attribute;
end Get_Local_Name;
begin
Matreshka.DOM_Documents.Register_Attribute
(Matreshka.ODF_String_Constants.Presentation_URI,
Matreshka.ODF_String_Constants.Preset_Sub_Type_Attribute,
Presentation_Preset_Sub_Type_Attribute_Node'Tag);
end Matreshka.ODF_Presentation.Preset_Sub_Type_Attributes;
|
tum-ei-rcs/StratoX | Ada | 5,859 | ads | -- Ada Unit Library
--
-- Authors: Emanuel Regnath ([email protected])
--
-- Description: Library for physical calculations
--
-- ToDo:
-- [ ] rename to Units.Mechanics3D or Physics.Units, Physics.Vector3D
with Ada.Numerics.Generic_Real_Arrays;
package Units.Vectors with SPARK_Mode is
package Unit_Arrays_Pack is new Ada.Numerics.Generic_Real_Arrays(Base_Unit_Type);
subtype Scalar is Base_Unit_Type;
type Vector3D_Type is array(1 .. 3) of Base_Unit_Type;
type Polar_Coordinates_Type is (Phi, Rho, Psi);
type Earth_Coordinates_Type is (LONGITUDE, LATITUDE, ALTITUDE);
type Cartesian_Coordinates_Type is (X, Y, Z);
type Cartesian_Vector_Type is array(Cartesian_Coordinates_Type) of Base_Unit_Type;
subtype Translation_Vector_Array is Vector3D_Type; -- of Length_Type;
--subtype Position_Vector is Karthesian_Vector_Type with Dimension => (Symbol => 'm', Meter => 1, others => 0);
-- type Dim_Vector_Type is array(Cartesian_Coordinates_Type) of Base_Unit_Type with Dimension_System =>
-- ((Unit_Name => Meter, Unit_Symbol => 'm', Dim_Symbol => 'L'),
-- (Unit_Name => Kilogram, Unit_Symbol => "kg", Dim_Symbol => 'M'),
-- (Unit_Name => Second, Unit_Symbol => 's', Dim_Symbol => 'T'),
-- (Unit_Name => Ampere, Unit_Symbol => 'A', Dim_Symbol => 'I'),
-- (Unit_Name => Kelvin, Unit_Symbol => 'K', Dim_Symbol => "Theta"),
-- (Unit_Name => Radian, Unit_Symbol => "Rad", Dim_Symbol => "A"));
type Translation_Vector is array(Cartesian_Coordinates_Type) of Length_Type; -- of Length_Type;
type Linear_Velocity_Vector is array(Cartesian_Coordinates_Type) of Linear_Velocity_Type;
type Linear_Acceleration_Vector is array(Cartesian_Coordinates_Type) of Linear_Acceleration_Type;
--
--
-- type Orientation_Dimension_Type is (R, P, Y);
-- subtype Orientation_Vector_Type is Unit_Arrays.Real_Vector(Orientation_Dimension_Type) of Angle_Type;
--
-- subtype Orientation_Vector is Orientation_Vector_Type of Angle_Type;
-- subtype Rotation_Vector is Orientation_Vector_Type of Angle_Type;
type Magnetic_Flux_Density_Vector is array(Cartesian_Coordinates_Type) of Magnetic_Flux_Density_Type;
-- Rotation Systems
type Tait_Bryan_Angle_Type is (ROLL, PITCH, YAW);
type Euler_Angle_Type is (X1, Z2, X3);
type Angular_Vector is array(Cartesian_Coordinates_Type) of Base_Unit_Type;
type Unit_Vector is array(Tait_Bryan_Angle_Type) of Angle_Type;
type Angle_Vector is array(Cartesian_Coordinates_Type) of Angle_Type;
type Rotation_Vector is array(Cartesian_Coordinates_Type) of Angle_Type;
type Angular_Velocity_Vector is array(Cartesian_Coordinates_Type) of Angular_Velocity_Type;
type Angular_Acceleration_Vector is array(Cartesian_Coordinates_Type) of Angular_Velocity_Type;
function "+" (Left, Right : Translation_Vector) return Translation_Vector is
( ( Left(X) + Right(X),
Left(Y) + Right(Y),
Left(Z) + Right(Z)
) );
function "+" (Left, Right : Angle_Vector) return Angle_Vector is
( Left(X) + Right(X), Left(Y) + Right(Y), Left(Z) + Right(Z) );
function "+" (Left, Right : Rotation_Vector) return Rotation_Vector is
( Left(X) + Right(X), Left(Y) + Right(Y), Left(Z) + Right(Z) );
function "*" (Left : Base_Unit_Type; Right : Rotation_Vector) return Rotation_Vector is
( ( Unit_Type(Left) * Right(X), Unit_Type(Left) * Right(Y), Unit_Type(Left) * Right(Z) ) );
function "+" (Left, Right : Angular_Velocity_Vector) return Angular_Velocity_Vector is
( ( Left(X) + Right(X),
Left(Y) + Right(Y),
Left(Z) + Right(Z)
) );
function "-" (Left, Right : Angular_Velocity_Vector) return Angular_Velocity_Vector is
( ( Left(X) - Right(X),
Left(Y) - Right(Y),
Left(Z) - Right(Z)
) );
function "*" (Left : Angular_Velocity_Vector; Right : Time_Type) return Rotation_Vector is
( ( Left(X) * Right, Left(Y) * Right, Left(Z) * Right ) );
function "*" (Left : Linear_Velocity_Vector; Right : Time_Type) return Translation_Vector is
( ( Left(X) * Right, Left(Y) * Right, Left(Z) * Right ) );
function Unit_Square (val : Base_Unit_Type) return Base_Unit_Type with
Post => Unit_Square'Result >= Base_Unit_Type (0.0);
-- numerically safe power val*val
procedure rotate(vector : in out Cartesian_Vector_Type; axis : Cartesian_Coordinates_Type; angle : Angle_Type);
function "abs" (vector : Cartesian_Vector_Type) return Base_Unit_Type;
function "abs" (vector : Angular_Vector) return Base_Unit_Type;
function "abs" (vector : Linear_Acceleration_Vector) return Linear_Acceleration_Type;
-- Matrices
subtype Unit_Matrix is Unit_Arrays_Pack.Real_Matrix; -- array(Natural <>, Natural <>) of
type Unit_Vector2D is array(1..2) of Base_Unit_Type;
type Unit_Matrix2D is array(1..2, 1..2) of Base_Unit_Type;
-- subtype Unit_Vector2D is Unit_Arrays_Pack.Real_Vector(1..2);
--subtype Unit_Vector3D is Unit_Arrays_Pack.Real_Vector(1..3);
subtype Unit_Matrix3D is Unit_Arrays_Pack.Real_Matrix(1..3, 1..3);
function "+" (Left, Right : Unit_Vector2D) return Unit_Vector2D is
( Left(1) + Right(1), Left(2) + Right(2) );
function "-" (Left, Right : Unit_Vector2D) return Unit_Vector2D is
( Left(1) - Right(1), Left(2) - Right(2) );
-- n×n Identity Matrix
function Eye( n : Natural ) return Unit_Matrix;
-- with Pre => n > 0;
-- n×n Matrix with all elements 1.0
function Ones( n : Natural ) return Unit_Matrix;
-- with Pre => n > 0;
-- n×n Matrix with all elements 0.0
function Zeros( n : Natural ) return Unit_Matrix;
-- with Pre => n > 0;
procedure setOnes( A : in out Unit_Matrix; first : Natural; last : Natural);
end Units.Vectors;
|
stcarrez/dynamo | Ada | 31,370 | adb | ------------------------------------------------------------------------------
-- --
-- ASIS-for-GNAT IMPLEMENTATION COMPONENTS --
-- --
-- A 4 G . S K I P _ T B --
-- --
-- B o d y --
-- --
-- Copyright (C) 1995-2012, 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). --
-- --
------------------------------------------------------------------------------
with Asis.Definitions; use Asis.Definitions;
with Asis.Elements; use Asis.Elements;
with Asis.Expressions; use Asis.Expressions;
with Asis.Set_Get; use Asis.Set_Get;
with A4G.A_Debug; use A4G.A_Debug;
with A4G.A_Sinput; use A4G.A_Sinput;
with A4G.A_Types; use A4G.A_Types;
with A4G.Int_Knds; use A4G.Int_Knds;
with Atree; use Atree;
with Output; use Output;
with Sinfo; use Sinfo;
package body A4G.Skip_TB is
-- In fact, there is a very few different cases of skipping the "syntax
-- sugar", but we implement this skipping by means of look-up table
-- for ease of maintenance.
-------------------------------
-- Specific Serach Functions --
-------------------------------
type Find_Source_Location_Type is access
function (E : Asis.Element; S : Source_Ptr) return Source_Ptr;
-- All the specific search functions are of the designated profile of
-- this access-to-function type. We need the Element parameter to
-- define the presennce or absence of optional component, because
-- such optional components may have trailing brackets specific for
-- them
function No_Brackets (E : Asis.Element; S : Source_Ptr) return Source_Ptr;
-- No seaqrch is made, the argument is returned
function Search_Right_Parenthesis
(E : Asis.Element;
S : Source_Ptr)
return Source_Ptr;
-- The location of the right-most ')' is returned. The search is started
-- the position S + 1, so if S itself points to ')', S will not be
-- returned
function Search_QE_Right_Parenthesis
(E : Asis.Element;
S : Source_Ptr)
return Source_Ptr;
-- Version of the previous function for a qualified expression. If the
-- argument is an aggregate which does not Needs_Extra_Parentheses, this
-- function is equivalent to No_Brackets, otherwise is the same as
-- Search_Right_Parenthesis
function Search_Attr_Right_Parenthesis
(E : Asis.Element;
S : Source_Ptr)
return Source_Ptr;
-- If E has a static expression as part of attribute designator,
-- this function looks for the location of the right-most ')'.
-- otherwise it makes no search.
-- E should be of A_First_Attribute, A_Last_Attribute, A_Length_Attribute,
-- A_Range_Attribute, An_Implementation_Defined_Attribute or
-- An_Unknown_Attribute kind only, otherwise ASIS_Inappropriate_Element
-- will be raised
function Search_Before_Semicolon
(E : Asis.Element;
S : Source_Ptr)
return Source_Ptr;
-- This is a somewhat special case: a task/protected declaration ends
-- with "end [identifier];", but the corresponding definition ends
-- with "end [identifier]", that is, *without* ";" .
-- When this function is called, it is supposed, that S points
-- to the trailing semicolon of the last component of a task/protected
-- definition or to the first character of the trailing end in case
-- if there is no component
function Search_Semicolon
(E : Asis.Element;
S : Source_Ptr)
return Source_Ptr;
-- The location of the rigt-most ';' is returned, starting from the
-- position next to S, but not S itself
function Clear_After_Funcion_Call
(E : Asis.Element;
S : Source_Ptr)
return Source_Ptr;
-- For a function call we have to make a differenve between an infix
-- call (no trailing brackets to skip) and prefix call, and in the
-- latter case - between the case when there is no parameter (no
-- trailing brackets to skip) and the case when there is(are) a
-- parameter(s) (a ')' should be skipped)
function Skip_WP (E : Asis.Element; S : Source_Ptr) return Source_Ptr;
-- This function handles a special case with
-- A_Formal_Derived_Type_Definition: in skips 'with private"
-- keywords, if any
function Search_End_Of_Box
(E : Asis.Element;
S : Source_Ptr)
return Source_Ptr;
-- If E may contain a box as the end of its text image, this function
-- returns the location of the '>' that is the end of this box, otherwise
-- it returns S. It is supposed that there is no other '<' between S and
-- the end of box except '<' that is the beginning of the box to look for.
function A_Bug (E : Asis.Element; S : Source_Ptr) return Source_Ptr;
-- This function should never be called. We need it for "others"
-- choise in the aggregate initializing the look-up table for those
-- values of Internal_Element_Kinds which should never be processed
-- (they correspond to implicit root and universal types). This
-- function raises Internal_Implementation_Error
------------------
-- Serach Array --
------------------
Skip_Switch : constant array (Internal_Element_Kinds) of
Find_Source_Location_Type :=
(An_All_Calls_Remote_Pragma ..
-- An_Asynchronous_Pragma
-- An_Atomic_Pragma
-- An_Atomic_Components_Pragma
-- An_Attach_Handler_Pragma
-- A_Controlled_Pragma
-- A_Convention_Pragma
-- An_Elaborate_All_Pragma
-- An_Elaborate_Body_Pragma
-- An_Export_Pragma
-- An_Import_Pragma
-- An_Inline_Pragma
-- An_Inspection_Point_Pragma
-- An_Interrupt_Handler_Pragma
-- An_Interrupt_Priority_Pragma
-- A_List_Pragma
-- A_Locking_Policy_Pragma
-- A_Normalize_Scalars_Pragma
-- An_Optimize_Pragma
-- A_Pack_Pragma
-- A_Page_Pragma
-- A_Preelaborate_Pragma
-- A_Priority_Pragma
-- A_Pure_Pragma
-- A_Queuing_Policy_Pragma
-- A_Remote_Call_Interface_Pragma
-- A_Remote_Types_Pragma
-- A_Restrictions_Pragma
-- A_Reviewable_Pragma
-- A_Shared_Passive_Pragma
-- A_Suppress_Pragma
-- A_Task_Dispatching_Policy_Pragma
-- A_Volatile_Pragma
-- A_Volatile_Components_Pragma
-- An_Implementation_Defined_Pragma
An_Unknown_Pragma => Search_Semicolon'Access,
A_Defining_Identifier ..
-- A_Defining_Character_Literal
-- A_Defining_Enumeration_Literal
-- A_Defining_And_Operator
-- A_Defining_Or_Operator
-- A_Defining_Xor_Operator
-- A_Defining_Equal_Operator
-- A_Defining_Not_Equal_Operator
-- A_Defining_Less_Than_Operator
-- A_Defining_Less_Than_Or_Equal_Operator
-- A_Defining_Greater_Than_Operator
-- A_Defining_Greater_Than_Or_Equal_Operator
-- A_Defining_Plus_Operator
-- A_Defining_Minus_Operator
-- A_Defining_Concatenate_Operator
-- A_Defining_Unary_Plus_Operator
-- A_Defining_Unary_Minus_Operator
-- A_Defining_Multiply_Operator
-- A_Defining_Divide_Operator
-- A_Defining_Mod_Operator
-- A_Defining_Rem_Operator
-- A_Defining_Exponentiate_Operator
-- A_Defining_Abs_Operator
-- A_Defining_Not_Operator
A_Defining_Expanded_Name => No_Brackets'Access,
An_Ordinary_Type_Declaration ..
-- A_Task_Type_Declaration
-- A_Protected_Type_Declaration
-- An_Incomplete_Type_Declaration
-- A_Private_Type_Declaration
-- A_Private_Extension_Declaration
-- A_Subtype_Declaration
-- A_Variable_Declaration
-- A_Constant_Declaration
-- A_Deferred_Constant_Declaration
-- A_Single_Task_Declaration
-- A_Single_Protected_Declaration
-- An_Integer_Number_Declaration
A_Real_Number_Declaration => Search_Semicolon'Access,
An_Enumeration_Literal_Specification => No_Brackets'Access,
A_Discriminant_Specification => No_Brackets'Access,
A_Component_Declaration => Search_Semicolon'Access,
A_Loop_Parameter_Specification => No_Brackets'Access,
A_Generalized_Iterator_Specification => No_Brackets'Access,
An_Element_Iterator_Specification => No_Brackets'Access,
A_Procedure_Declaration => Search_Semicolon'Access,
A_Function_Declaration => Search_Semicolon'Access,
A_Parameter_Specification => No_Brackets'Access,
A_Procedure_Body_Declaration ..
A_Function_Body_Declaration => Search_Semicolon'Access,
A_Return_Variable_Specification => No_Brackets'Access,
A_Return_Constant_Specification => No_Brackets'Access,
A_Null_Procedure_Declaration ..
-- An_Expression_Function_Declaration
-- A_Package_Declaration
-- A_Package_Body_Declaration
-- A_Package_Body_Declaration
-- An_Object_Renaming_Declaration
-- An_Exception_Renaming_Declaration
-- A_Package_Renaming_Declaration
-- A_Procedure_Renaming_Declaration
-- A_Function_Renaming_Declaration
-- A_Generic_Package_Renaming_Declaration
-- A_Generic_Procedure_Renaming_Declaration
-- A_Generic_Function_Renaming_Declaration
-- A_Task_Body_Declaration
-- A_Protected_Body_Declaration
-- An_Entry_Declaration
An_Entry_Body_Declaration => Search_Semicolon'Access,
An_Entry_Index_Specification => No_Brackets'Access,
A_Procedure_Body_Stub ..
-- A_Function_Body_Stub
-- A_Package_Body_Stub
-- A_Task_Body_Stub
-- A_Protected_Body_Stub
An_Exception_Declaration => Search_Semicolon'Access,
A_Choice_Parameter_Specification => No_Brackets'Access,
A_Generic_Procedure_Declaration ..
-- A_Generic_Function_Declaration
-- A_Generic_Package_Declaration
-- A_Package_Instantiation
-- A_Procedure_Instantiation
-- A_Function_Instantiation
-- A_Formal_Object_Declaration
-- A_Formal_Type_Declaration
-- A_Formal_Procedure_Declaration
-- A_Formal_Function_Declaration
-- A_Formal_Package_Declaration
A_Formal_Package_Declaration_With_Box => Search_Semicolon'Access,
A_Derived_Type_Definition => No_Brackets'Access,
A_Derived_Record_Extension_Definition => No_Brackets'Access,
An_Enumeration_Type_Definition => Search_Right_Parenthesis'Access,
A_Signed_Integer_Type_Definition ..
-- A_Modular_Type_Definition
---------------------------------------------------------
-- !!! They all are implicit and cannot have image
-- |
-- |-> A_Root_Integer_Definition
-- |-> A_Root_Real_Definition
-- |-> A_Root_Fixed_Definition
-- |-> A_Universal_Integer_Definition
-- |-> A_Universal_Real_Definition
-- +-> A_Universal_Fixed_Definition
---------------------------------------------------------
-- A_Floating_Point_Definition
-- An_Ordinary_Fixed_Point_Definition
-- A_Decimal_Fixed_Point_Definition
-- An_Unconstrained_Array_Definition
-- A_Constrained_Array_Definition
-- A_Record_Type_Definition
-- A_Tagged_Record_Type_Definition
-- A_Pool_Specific_Access_To_Variable
-- An_Access_To_Variable
An_Access_To_Constant => No_Brackets'Access,
An_Access_To_Procedure => Search_Right_Parenthesis'Access,
An_Access_To_Protected_Procedure => Search_Right_Parenthesis'Access,
An_Access_To_Function ..
-- An_Access_To_Protected_Function
-- A_Subtype_Indication
-- A_Range_Attribute_Reference
-- A_Simple_Expression_Range
-- A_Digits_Constraint
A_Delta_Constraint => No_Brackets'Access,
An_Index_Constraint => Search_Right_Parenthesis'Access,
A_Discriminant_Constraint => Search_Right_Parenthesis'Access,
A_Component_Definition ..
-- A_Discrete_Subtype_Indication_As_Subtype_Definition
-- A_Discrete_Range_Attribute_Reference_As_Subtype_Definition
-- A_Discrete_Simple_Expression_Range_As_Subtype_Definition
-- A_Discrete_Subtype_Indication
-- A_Discrete_Range_Attribute_Reference
-- A_Discrete_Simple_Expression_Range
An_Unknown_Discriminant_Part => No_Brackets'Access,
A_Known_Discriminant_Part => Search_Right_Parenthesis'Access,
A_Record_Definition => No_Brackets'Access,
A_Null_Record_Definition => No_Brackets'Access,
A_Null_Component => Search_Semicolon'Access,
A_Variant_Part => Search_Semicolon'Access,
A_Variant ..
An_Others_Choice => No_Brackets'Access,
-- --|A2005 start
An_Anonymous_Access_To_Variable ..
An_Anonymous_Access_To_Constant => No_Brackets'Access,
An_Anonymous_Access_To_Procedure ..
An_Anonymous_Access_To_Protected_Procedure =>
Search_Right_Parenthesis'Access,
An_Anonymous_Access_To_Function ..
An_Anonymous_Access_To_Protected_Function => No_Brackets'Access,
-- --|A2005 end
A_Private_Type_Definition ..
-- A_Tagged_Private_Type_Definition
A_Private_Extension_Definition => No_Brackets'Access,
A_Task_Definition ..
A_Protected_Definition => Search_Before_Semicolon'Access,
A_Formal_Private_Type_Definition ..
A_Formal_Tagged_Private_Type_Definition => No_Brackets'Access,
A_Formal_Derived_Type_Definition => Skip_WP'Access,
A_Formal_Discrete_Type_Definition ..
-- A_Formal_Signed_Integer_Type_Definition
-- A_Formal_Modular_Type_Definition
-- A_Formal_Floating_Point_Definition
-- A_Formal_Ordinary_Fixed_Point_Definition
-- A_Formal_Decimal_Fixed_Point_Definition
-- A_Formal_Unconstrained_Array_Definition
-- A_Formal_Constrained_Array_Definition
-- A_Formal_Pool_Specific_Access_To_Variable
-- A_Formal_Access_To_Variable
A_Formal_Access_To_Constant => No_Brackets'Access,
A_Formal_Access_To_Procedure =>
Search_Right_Parenthesis'Access,
A_Formal_Access_To_Protected_Procedure =>
Search_Right_Parenthesis'Access,
A_Formal_Access_To_Function ..
-- A_Formal_Access_To_Protected_Function
-- An_Integer_Literal
-- A_Real_Literal
-- A_String_Literal
-- An_Identifier
-- An_And_Operator
-- An_Or_Operator
-- An_Xor_Operator
-- An_Equal_Operator
-- A_Not_Equal_Operator
-- A_Less_Than_Operator
-- A_Less_Than_Or_Equal_Operator
-- A_Greater_Than_Operator
-- A_Greater_Than_Or_Equal_Operator
-- A_Plus_Operator
-- A_Minus_Operator
-- A_Concatenate_Operator
-- A_Unary_Plus_Operator
-- A_Unary_Minus_Operator
-- A_Multiply_Operator
-- A_Divide_Operator
-- A_Mod_Operator
-- A_Rem_Operator
-- An_Exponentiate_Operator
-- An_Abs_Operator
-- A_Not_Operator
-- A_Character_Literal
-- An_Enumeration_Literal
An_Explicit_Dereference => No_Brackets'Access,
A_Function_Call => Clear_After_Funcion_Call'Access,
An_Indexed_Component ..
A_Slice => Search_Right_Parenthesis'Access,
A_Selected_Component => No_Brackets'Access,
An_Access_Attribute ..
-- An_Address_Attribute
-- An_Adjacent_Attribute
-- An_Aft_Attribute
-- An_Alignment_Attribute
-- A_Base_Attribute
-- A_Bit_Order_Attribute
-- A_Body_Version_Attribute
-- A_Callable_Attribute
-- A_Caller_Attribute
-- A_Ceiling_Attribute
-- A_Class_Attribute
-- A_Component_Size_Attribute
-- A_Compose_Attribute
-- A_Constrained_Attribute
-- A_Copy_Sign_Attribute
-- A_Count_Attribute
-- A_Definite_Attribute
-- A_Delta_Attribute
-- A_Denorm_Attribute
-- A_Digits_Attribute
-- An_Exponent_Attribute
An_External_Tag_Attribute => No_Brackets'Access,
A_First_Attribute => Search_Attr_Right_Parenthesis'Access,
A_First_Bit_Attribute ..
-- A_Floor_Attribute
-- A_Fore_Attribute
-- A_Fraction_Attribute
-- An_Identity_Attribute
-- An_Image_Attribute
An_Input_Attribute => No_Brackets'Access,
A_Last_Attribute => Search_Attr_Right_Parenthesis'Access,
A_Last_Bit_Attribute => No_Brackets'Access,
A_Leading_Part_Attribute => No_Brackets'Access,
A_Length_Attribute => Search_Attr_Right_Parenthesis'Access,
A_Machine_Attribute ..
-- A_Machine_Emax_Attribute
-- A_Machine_Emin_Attribute
-- A_Machine_Mantissa_Attribute
-- A_Machine_Overflows_Attribute
-- A_Machine_Radix_Attribute
-- A_Machine_Rounds_Attribute
-- A_Max_Attribute
-- A_Max_Size_In_Storage_Elements_Attribute
-- A_Min_Attribute
-- A_Model_Attribute
-- A_Model_Emin_Attribute
-- A_Model_Epsilon_Attribute
-- A_Model_Mantissa_Attribute
-- A_Model_Small_Attribute
-- A_Modulus_Attribute
-- An_Output_Attribute
-- A_Partition_ID_Attribute
-- A_Pos_Attribute
-- A_Position_Attribute
A_Pred_Attribute => No_Brackets'Access,
A_Range_Attribute => Search_Attr_Right_Parenthesis'Access,
A_Read_Attribute ..
-- A_Remainder_Attribute
-- A_Round_Attribute
-- A_Rounding_Attribute
-- A_Safe_First_Attribute
-- A_Safe_Last_Attribute
-- A_Scale_Attribute
-- A_Scaling_Attribute
-- A_Signed_Zeros_Attribute
-- A_Size_Attribute
-- A_Small_Attribute
-- A_Storage_Pool_Attribute
-- A_Storage_Size_Attribute
-- A_Succ_Attribute
-- A_Tag_Attribute
-- A_Terminated_Attribute
-- A_Truncation_Attribute
-- An_Unbiased_Rounding_Attribute
-- An_Unchecked_Access_Attribute
-- A_Val_Attribute
-- A_Valid_Attribute
-- A_Value_Attribute
-- A_Version_Attribute
-- A_Wide_Image_Attribute
-- A_Wide_Value_Attribute
-- A_Wide_Width_Attribute
-- A_Width_Attribute
-- A_Write_Attribute
-- |A2006 start
-- New Ada 2005 attributes. To be alphabetically ordered later
-- A_Machine_Rounding_Attribute
-- A_Mod_Attribute
-- A_Priority_Attribute
-- A_Stream_Size_Attribute
-- A_Wide_Wide_Image_Attribute
-- A_Wide_Wide_Value_Attribute
A_Wide_Wide_Width_Attribute => No_Brackets'Access,
-- |A2006 end
An_Implementation_Defined_Attribute ..
An_Unknown_Attribute => Search_Attr_Right_Parenthesis'Access,
A_Record_Aggregate ..
-- An_Extension_Aggregate
-- A_Positional_Array_Aggregate
A_Named_Array_Aggregate => Search_Right_Parenthesis'Access,
An_And_Then_Short_Circuit ..
-- An_Or_Else_Short_Circuit
-- An_In_Range_Membership_Test
-- A_Not_In_Range_Membership_Test
-- An_In_Type_Membership_Test
-- A_Not_In_Type_Membership_Test
A_Null_Literal => No_Brackets'Access,
A_Parenthesized_Expression ..
A_Type_Conversion => Search_Right_Parenthesis'Access,
A_Qualified_Expression => Search_QE_Right_Parenthesis'Access,
An_Allocation_From_Subtype ..
An_Allocation_From_Qualified_Expression => No_Brackets'Access,
A_Case_Expression => No_Brackets'Access, -- Ada 2012
An_If_Expression => No_Brackets'Access, -- Ada 2012
A_For_All_Quantified_Expression => No_Brackets'Access, -- Ada 2012
A_For_Some_Quantified_Expression => No_Brackets'Access, -- Ada 2012
A_Pragma_Argument_Association ..
-- A_Discriminant_Association
-- A_Record_Component_Association
-- An_Array_Component_Association
A_Parameter_Association => No_Brackets'Access,
A_Generic_Association => Search_End_Of_Box'Access,
A_Null_Statement ..
-- An_Assignment_Statement
-- An_If_Statement
-- A_Case_Statement
-- A_Loop_Statement
-- A_While_Loop_Statement
-- A_For_Loop_Statement
-- A_Block_Statement
-- An_Exit_Statement
-- A_Goto_Statement
-- A_Procedure_Call_Statement
-- A_Return_Statement
-- An_Accept_Statement
-- An_Entry_Call_Statement
-- A_Requeue_Statement
-- A_Requeue_Statement_With_Abort
-- A_Delay_Until_Statement
-- A_Delay_Relative_Statement
-- A_Terminate_Alternative_Statement
-- A_Selective_Accept_Statement
-- A_Timed_Entry_Call_Statement
-- A_Conditional_Entry_Call_Statement
-- An_Asynchronous_Select_Statement
-- An_Abort_Statement
-- A_Raise_Statement
A_Code_Statement => Search_Semicolon'Access,
An_If_Path ..
-- An_Elsif_Path
-- An_Else_Path
-- A_Case_Path
-- A_Select_Path
-- An_Or_Path
-- A_Then_Abort_Path
-- A_Case_Expression_Path -- ASIS 2012
-- An_If_Expression_Path -- ASIS 2012
-- An_Elsif_Expression_Path -- ASIS 2012
An_Else_Expression_Path => No_Brackets'Access, -- Ada 2012
A_Use_Package_Clause ..
-- A_Use_Type_Clause
-- A_Use_All_Type_Clause -- Ada 2012
-- A_With_Clause
-- An_Attribute_Definition_Clause
-- An_Enumeration_Representation_Clause
-- A_Record_Representation_Clause
-- An_At_Clause
A_Component_Clause => Search_Semicolon'Access,
An_Exception_Handler => No_Brackets'Access,
others => A_Bug'Access);
-----------
-- A_Bug --
-----------
function A_Bug (E : Asis.Element; S : Source_Ptr) return Source_Ptr is
begin
pragma Unreferenced (E);
-- This function should never be called
raise Internal_Implementation_Error;
return S;
end A_Bug;
------------------------------
-- Clear_After_Funcion_Call --
------------------------------
function Clear_After_Funcion_Call
(E : Asis.Element;
S : Source_Ptr)
return Source_Ptr
is
begin
if Is_Prefix_Call (E) then
if Is_Nil (Function_Call_Parameters (E)) then
return No_Brackets (E, S);
else
return Search_Right_Parenthesis (E, S);
end if;
else
return No_Brackets (E, S);
end if;
end Clear_After_Funcion_Call;
-----------------------------
-- Needs_Extra_Parentheses --
-----------------------------
function Needs_Extra_Parentheses (E : Asis.Element) return Boolean is
Result : Boolean := False;
N : Node_Id;
begin
if Int_Kind (E) in A_Record_Aggregate .. A_Named_Array_Aggregate then
N := R_Node (E);
if Paren_Count (N) = 1 and then
Nkind (Parent (N)) = N_Qualified_Expression
then
Result := True;
end if;
end if;
return Result;
end Needs_Extra_Parentheses;
-----------------
-- No_Brackets --
-----------------
function No_Brackets (E : Asis.Element; S : Source_Ptr) return Source_Ptr is
begin
pragma Unreferenced (E);
return S;
end No_Brackets;
-----------------------------------
-- Search_Attr_Right_Parenthesis --
-----------------------------------
function Search_Attr_Right_Parenthesis
(E : Asis.Element;
S : Source_Ptr)
return Source_Ptr
is
begin
if Is_Nil (Attribute_Designator_Expressions (E)) then
return No_Brackets (E, S);
else
return Search_Right_Parenthesis (E, S);
end if;
end Search_Attr_Right_Parenthesis;
-----------------------------
-- Search_Before_Semicolon --
-----------------------------
function Search_Before_Semicolon
(E : Asis.Element;
S : Source_Ptr)
return Source_Ptr
is
S_P : Source_Ptr;
Result : Source_Ptr;
begin
-- first, we have to check where we are: at ';' or at the beginning of
-- the reserved word "end" in case if there is no components,
-- and if we are at ';', we have to go to "end":
if Get_Character (S) = ';' then
S_P := Next_Identifier (S);
elsif Asis.Definitions.Is_Private_Present (E) then
-- patological case of empty efinition with private part
S_P := S + 7;
else
S_P := S;
S_P := Rightmost_Non_Blank (S_P);
end if;
Result := S_P + 2;
-- the last character of "end"
S_P := S_P + 3;
-- the first character after "end"
S_P := Rightmost_Non_Blank (S_P);
-- and the final check - what follows the final "end"
if Get_Character (S_P) /= ';' then
-- there is an identifier after "end"
Result := Get_Word_End (P => S_P,
In_Word => In_Identifier'Access);
end if;
return Result;
end Search_Before_Semicolon;
-----------------------
-- Search_End_Of_Box --
-----------------------
function Search_End_Of_Box
(E : Asis.Element;
S : Source_Ptr)
return Source_Ptr
is
Result : Source_Ptr := S;
begin
case Int_Kind (E) is
when A_Generic_Association =>
if Is_Nil (Actual_Parameter (E)) then
Result := Search_Rightmost_Symbol (S, '<');
Result := Result + 1;
end if;
when others =>
null;
end case;
return Result;
end Search_End_Of_Box;
---------------------------------
-- Search_QE_Right_Parenthesis --
---------------------------------
function Search_QE_Right_Parenthesis
(E : Asis.Element;
S : Source_Ptr)
return Source_Ptr
is
Result : Source_Ptr := S;
Tmp : constant Asis.Element := Converted_Or_Qualified_Expression (E);
begin
if Int_Kind (Tmp) not in A_Record_Aggregate .. A_Named_Array_Aggregate
or else Needs_Extra_Parentheses (Tmp)
then
Result := Search_Rightmost_Symbol (S + 1, ')');
end if;
return Result;
end Search_QE_Right_Parenthesis;
------------------------------
-- Search_Right_Parenthesis --
------------------------------
function Search_Right_Parenthesis
(E : Asis.Element;
S : Source_Ptr)
return Source_Ptr
is
begin
pragma Unreferenced (E);
return Search_Rightmost_Symbol (S + 1, ')');
end Search_Right_Parenthesis;
----------------------
-- Search_Semicolon --
----------------------
function Search_Semicolon
(E : Asis.Element;
S : Source_Ptr)
return Source_Ptr
is
pragma Unreferenced (E);
S_P : Source_Ptr;
begin
S_P := Search_Rightmost_Symbol (S + 1, ';');
return S_P;
end Search_Semicolon;
-------------
-- Skip_WP --
-------------
function Skip_WP (E : Asis.Element; S : Source_Ptr) return Source_Ptr is
S_P : Source_Ptr;
begin
-- just jump to the trailing semicolon, and then - to the end of
-- the previous word, this should handle properly cases where there
-- are and where there are not "with private" keywords
S_P := Search_Semicolon (E, S);
S_P := Search_Prev_Word (S_P);
return S_P;
end Skip_WP;
----------------------------
-- Skip_Trailing_Brackets --
----------------------------
function Skip_Trailing_Brackets
(E : Asis.Element;
S : Source_Ptr)
return Source_Ptr
is
begin
-- all that this function does is switching to the function
-- implementing the specific processing for the given element
-- kind
if Debug_Flag_X then
Write_Str (" Skip_Trailing_Brackets - called for ");
Write_Str (Internal_Element_Kinds'Image (Int_Kind (E)));
Write_Eol;
Write_Eol;
end if;
return Skip_Switch (Int_Kind (E)) (E, S);
end Skip_Trailing_Brackets;
end A4G.Skip_TB;
|
zhmu/ananas | Ada | 1,163 | adb | -- { dg-do run }
with System; use System;
with Ada.Text_IO; use Ada.Text_IO;
procedure Conv1 is
type Short is mod 2**16;
type R_L is record
S : Short;
C : Character;
end record;
for R_L'Bit_Order use Low_Order_First;
for R_L'Scalar_Storage_Order use Low_Order_First;
for R_L use record
S at 0 range 0 .. 15;
C at 2 range 0 .. 7;
end record;
type R_H is new R_L;
for R_H'Bit_Order use High_Order_First;
for R_H'Scalar_Storage_Order use High_Order_First;
for R_H use record
S at 0 range 0 .. 15;
C at 2 range 0 .. 7;
end record;
procedure Dump (Name : String; S : Short; C : Character) is
begin
Put_Line (Name & " = (S =>" & S'Img & ", C => '" & C & "')");
end Dump;
X_L : R_L;
X_H : R_H;
begin
X_L.S := 12345;
X_L.C := 'a';
Dump ("X_L", X_L.S, X_L.C);
-- { dg-output "X_L = \\(S => 12345, C => 'a'\\).*\n" }
X_H.S := 23456;
X_H.C := 'b';
Dump ("X_H", X_H.S, X_H.C);
-- { dg-output "X_H = \\(S => 23456, C => 'b'\\).*\n" }
X_H := R_H (X_L);
Dump ("X_H", X_H.S, X_H.C);
-- { dg-output "X_H = \\(S => 12345, C => 'a'\\).*\n" }
end;
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.